id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
136,500
stevespringett/Alpine
alpine/src/main/java/alpine/util/BooleanUtil.java
BooleanUtil.valueOf
public static boolean valueOf(String value) { return (value != null) && (value.trim().equalsIgnoreCase("true") || value.trim().equals("1")); }
java
public static boolean valueOf(String value) { return (value != null) && (value.trim().equalsIgnoreCase("true") || value.trim().equals("1")); }
[ "public", "static", "boolean", "valueOf", "(", "String", "value", ")", "{", "return", "(", "value", "!=", "null", ")", "&&", "(", "value", ".", "trim", "(", ")", ".", "equalsIgnoreCase", "(", "\"true\"", ")", "||", "value", ".", "trim", "(", ")", "."...
Determines if the specified string contains 'true' or '1' @param value a String representation of a boolean to convert @return a boolean @since 1.0.0
[ "Determines", "if", "the", "specified", "string", "contains", "true", "or", "1" ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/util/BooleanUtil.java#L41-L43
136,501
stevespringett/Alpine
alpine/src/main/java/alpine/crypto/DataEncryption.java
DataEncryption.encryptAsBytes
public static byte[] encryptAsBytes(final SecretKey secretKey, final String plainText) throws Exception { final byte[] clean = plainText.getBytes(); // Generating IV int ivSize = 16; final byte[] iv = new byte[ivSize]; final SecureRandom random = new SecureRandom(); random.nextBytes(iv); final IvParameterSpec ivParameterSpec = new IvParameterSpec(iv); // Encrypt final Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); cipher.init(Cipher.ENCRYPT_MODE, secretKey, ivParameterSpec); final byte[] encrypted = cipher.doFinal(clean); // Combine IV and encrypted parts final byte[] encryptedIVAndText = new byte[ivSize + encrypted.length]; System.arraycopy(iv, 0, encryptedIVAndText, 0, ivSize); System.arraycopy(encrypted, 0, encryptedIVAndText, ivSize, encrypted.length); return encryptedIVAndText; }
java
public static byte[] encryptAsBytes(final SecretKey secretKey, final String plainText) throws Exception { final byte[] clean = plainText.getBytes(); // Generating IV int ivSize = 16; final byte[] iv = new byte[ivSize]; final SecureRandom random = new SecureRandom(); random.nextBytes(iv); final IvParameterSpec ivParameterSpec = new IvParameterSpec(iv); // Encrypt final Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); cipher.init(Cipher.ENCRYPT_MODE, secretKey, ivParameterSpec); final byte[] encrypted = cipher.doFinal(clean); // Combine IV and encrypted parts final byte[] encryptedIVAndText = new byte[ivSize + encrypted.length]; System.arraycopy(iv, 0, encryptedIVAndText, 0, ivSize); System.arraycopy(encrypted, 0, encryptedIVAndText, ivSize, encrypted.length); return encryptedIVAndText; }
[ "public", "static", "byte", "[", "]", "encryptAsBytes", "(", "final", "SecretKey", "secretKey", ",", "final", "String", "plainText", ")", "throws", "Exception", "{", "final", "byte", "[", "]", "clean", "=", "plainText", ".", "getBytes", "(", ")", ";", "// ...
Encrypts the specified plainText using AES-256. @param plainText the text to encrypt @param secretKey the secret key to use to encrypt with @return the encrypted bytes @throws Exception a number of exceptions may be thrown @since 1.3.0
[ "Encrypts", "the", "specified", "plainText", "using", "AES", "-", "256", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/crypto/DataEncryption.java#L51-L72
136,502
stevespringett/Alpine
alpine/src/main/java/alpine/crypto/DataEncryption.java
DataEncryption.encryptAsBytes
public static byte[] encryptAsBytes(final String plainText) throws Exception { final SecretKey secretKey = KeyManager.getInstance().getSecretKey(); return encryptAsBytes(secretKey, plainText); }
java
public static byte[] encryptAsBytes(final String plainText) throws Exception { final SecretKey secretKey = KeyManager.getInstance().getSecretKey(); return encryptAsBytes(secretKey, plainText); }
[ "public", "static", "byte", "[", "]", "encryptAsBytes", "(", "final", "String", "plainText", ")", "throws", "Exception", "{", "final", "SecretKey", "secretKey", "=", "KeyManager", ".", "getInstance", "(", ")", ".", "getSecretKey", "(", ")", ";", "return", "e...
Encrypts the specified plainText using AES-256. This method uses the default secret key. @param plainText the text to encrypt @return the encrypted bytes @throws Exception a number of exceptions may be thrown @since 1.3.0
[ "Encrypts", "the", "specified", "plainText", "using", "AES", "-", "256", ".", "This", "method", "uses", "the", "default", "secret", "key", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/crypto/DataEncryption.java#L81-L84
136,503
stevespringett/Alpine
alpine/src/main/java/alpine/crypto/DataEncryption.java
DataEncryption.encryptAsString
public static String encryptAsString(final SecretKey secretKey, final String plainText) throws Exception { return Base64.getEncoder().encodeToString(encryptAsBytes(secretKey, plainText)); }
java
public static String encryptAsString(final SecretKey secretKey, final String plainText) throws Exception { return Base64.getEncoder().encodeToString(encryptAsBytes(secretKey, plainText)); }
[ "public", "static", "String", "encryptAsString", "(", "final", "SecretKey", "secretKey", ",", "final", "String", "plainText", ")", "throws", "Exception", "{", "return", "Base64", ".", "getEncoder", "(", ")", ".", "encodeToString", "(", "encryptAsBytes", "(", "se...
Encrypts the specified plainText using AES-256 and returns a Base64 encoded representation of the encrypted bytes. @param secretKey the secret key to use to encrypt with @param plainText the text to encrypt @return a Base64 encoded representation of the encrypted bytes @throws Exception a number of exceptions may be thrown @since 1.3.0
[ "Encrypts", "the", "specified", "plainText", "using", "AES", "-", "256", "and", "returns", "a", "Base64", "encoded", "representation", "of", "the", "encrypted", "bytes", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/crypto/DataEncryption.java#L95-L97
136,504
stevespringett/Alpine
alpine/src/main/java/alpine/crypto/DataEncryption.java
DataEncryption.decryptAsBytes
public static byte[] decryptAsBytes(final SecretKey secretKey, final byte[] encryptedIvTextBytes) throws Exception { int ivSize = 16; // Extract IV final byte[] iv = new byte[ivSize]; System.arraycopy(encryptedIvTextBytes, 0, iv, 0, iv.length); final IvParameterSpec ivParameterSpec = new IvParameterSpec(iv); // Extract encrypted bytes final int encryptedSize = encryptedIvTextBytes.length - ivSize; final byte[] encryptedBytes = new byte[encryptedSize]; System.arraycopy(encryptedIvTextBytes, ivSize, encryptedBytes, 0, encryptedSize); // Decrypt final Cipher cipherDecrypt = Cipher.getInstance("AES/CBC/PKCS5Padding"); cipherDecrypt.init(Cipher.DECRYPT_MODE, secretKey, ivParameterSpec); return cipherDecrypt.doFinal(encryptedBytes); }
java
public static byte[] decryptAsBytes(final SecretKey secretKey, final byte[] encryptedIvTextBytes) throws Exception { int ivSize = 16; // Extract IV final byte[] iv = new byte[ivSize]; System.arraycopy(encryptedIvTextBytes, 0, iv, 0, iv.length); final IvParameterSpec ivParameterSpec = new IvParameterSpec(iv); // Extract encrypted bytes final int encryptedSize = encryptedIvTextBytes.length - ivSize; final byte[] encryptedBytes = new byte[encryptedSize]; System.arraycopy(encryptedIvTextBytes, ivSize, encryptedBytes, 0, encryptedSize); // Decrypt final Cipher cipherDecrypt = Cipher.getInstance("AES/CBC/PKCS5Padding"); cipherDecrypt.init(Cipher.DECRYPT_MODE, secretKey, ivParameterSpec); return cipherDecrypt.doFinal(encryptedBytes); }
[ "public", "static", "byte", "[", "]", "decryptAsBytes", "(", "final", "SecretKey", "secretKey", ",", "final", "byte", "[", "]", "encryptedIvTextBytes", ")", "throws", "Exception", "{", "int", "ivSize", "=", "16", ";", "// Extract IV", "final", "byte", "[", "...
Decrypts the specified bytes using AES-256. @param secretKey the secret key to decrypt with @param encryptedIvTextBytes the text to decrypt @return the decrypted bytes @throws Exception a number of exceptions may be thrown @since 1.3.0
[ "Decrypts", "the", "specified", "bytes", "using", "AES", "-", "256", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/crypto/DataEncryption.java#L119-L136
136,505
stevespringett/Alpine
alpine/src/main/java/alpine/crypto/DataEncryption.java
DataEncryption.decryptAsBytes
public static byte[] decryptAsBytes(final byte[] encryptedIvTextBytes) throws Exception { final SecretKey secretKey = KeyManager.getInstance().getSecretKey(); return decryptAsBytes(secretKey, encryptedIvTextBytes); }
java
public static byte[] decryptAsBytes(final byte[] encryptedIvTextBytes) throws Exception { final SecretKey secretKey = KeyManager.getInstance().getSecretKey(); return decryptAsBytes(secretKey, encryptedIvTextBytes); }
[ "public", "static", "byte", "[", "]", "decryptAsBytes", "(", "final", "byte", "[", "]", "encryptedIvTextBytes", ")", "throws", "Exception", "{", "final", "SecretKey", "secretKey", "=", "KeyManager", ".", "getInstance", "(", ")", ".", "getSecretKey", "(", ")", ...
Decrypts the specified bytes using AES-256. This method uses the default secret key. @param encryptedIvTextBytes the text to decrypt @return the decrypted bytes @throws Exception a number of exceptions may be thrown @since 1.3.0
[ "Decrypts", "the", "specified", "bytes", "using", "AES", "-", "256", ".", "This", "method", "uses", "the", "default", "secret", "key", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/crypto/DataEncryption.java#L145-L148
136,506
stevespringett/Alpine
alpine/src/main/java/alpine/util/Pageable.java
Pageable.setCurrentPage
private void setCurrentPage(int page) { if (page >= totalPages) { this.currentPage = totalPages; } else if (page <= 1) { this.currentPage = 1; } else { this.currentPage = page; } // now work out where the sub-list should start and end startingIndex = pageSize * (currentPage -1); if (startingIndex < 0) { startingIndex = 0; } endingIndex = startingIndex + pageSize; if (endingIndex > list.size()) { endingIndex = list.size(); } }
java
private void setCurrentPage(int page) { if (page >= totalPages) { this.currentPage = totalPages; } else if (page <= 1) { this.currentPage = 1; } else { this.currentPage = page; } // now work out where the sub-list should start and end startingIndex = pageSize * (currentPage -1); if (startingIndex < 0) { startingIndex = 0; } endingIndex = startingIndex + pageSize; if (endingIndex > list.size()) { endingIndex = list.size(); } }
[ "private", "void", "setCurrentPage", "(", "int", "page", ")", "{", "if", "(", "page", ">=", "totalPages", ")", "{", "this", ".", "currentPage", "=", "totalPages", ";", "}", "else", "if", "(", "page", "<=", "1", ")", "{", "this", ".", "currentPage", "...
Specifies a specific page to jump to. @param page the page to jump to
[ "Specifies", "a", "specific", "page", "to", "jump", "to", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/util/Pageable.java#L133-L151
136,507
stevespringett/Alpine
alpine/src/main/java/alpine/util/HttpUtil.java
HttpUtil.getSessionAttribute
@SuppressWarnings("unchecked") public static <T> T getSessionAttribute(final HttpSession session, final String key) { if (session != null) { return (T) session.getAttribute(key); } return null; }
java
@SuppressWarnings("unchecked") public static <T> T getSessionAttribute(final HttpSession session, final String key) { if (session != null) { return (T) session.getAttribute(key); } return null; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "T", ">", "T", "getSessionAttribute", "(", "final", "HttpSession", "session", ",", "final", "String", "key", ")", "{", "if", "(", "session", "!=", "null", ")", "{", "return", "(",...
Returns a session attribute as the type of object stored. @param session session where the attribute is stored @param key the attributes key @param <T> the type of object expected @return the requested object @since 1.0.0
[ "Returns", "a", "session", "attribute", "as", "the", "type", "of", "object", "stored", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/util/HttpUtil.java#L41-L47
136,508
stevespringett/Alpine
alpine/src/main/java/alpine/util/HttpUtil.java
HttpUtil.getRequestAttribute
@SuppressWarnings("unchecked") public static <T> T getRequestAttribute(final HttpServletRequest request, final String key) { if (request != null) { return (T) request.getAttribute(key); } return null; }
java
@SuppressWarnings("unchecked") public static <T> T getRequestAttribute(final HttpServletRequest request, final String key) { if (request != null) { return (T) request.getAttribute(key); } return null; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "T", ">", "T", "getRequestAttribute", "(", "final", "HttpServletRequest", "request", ",", "final", "String", "key", ")", "{", "if", "(", "request", "!=", "null", ")", "{", "return",...
Returns a request attribute as the type of object stored. @param request request of the attribute @param key the attributes key @param <T> the type of the object expected @return the requested object @since 1.0.0
[ "Returns", "a", "request", "attribute", "as", "the", "type", "of", "object", "stored", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/util/HttpUtil.java#L58-L64
136,509
stevespringett/Alpine
alpine/src/main/java/alpine/util/MapperUtil.java
MapperUtil.readAsObjectOf
public static <T> T readAsObjectOf(Class<T> clazz, String value) { final ObjectMapper mapper = new ObjectMapper(); try { return mapper.readValue(value, clazz); } catch (IOException e) { LOGGER.error(e.getMessage(), e.fillInStackTrace()); } return null; }
java
public static <T> T readAsObjectOf(Class<T> clazz, String value) { final ObjectMapper mapper = new ObjectMapper(); try { return mapper.readValue(value, clazz); } catch (IOException e) { LOGGER.error(e.getMessage(), e.fillInStackTrace()); } return null; }
[ "public", "static", "<", "T", ">", "T", "readAsObjectOf", "(", "Class", "<", "T", ">", "clazz", ",", "String", "value", ")", "{", "final", "ObjectMapper", "mapper", "=", "new", "ObjectMapper", "(", ")", ";", "try", "{", "return", "mapper", ".", "readVa...
Reads in a String value and returns the object for which it represents. @param clazz The expected class of the value @param value the value to parse @param <T> The expected type to return @return the mapped object
[ "Reads", "in", "a", "String", "value", "and", "returns", "the", "object", "for", "which", "it", "represents", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/util/MapperUtil.java#L46-L54
136,510
stevespringett/Alpine
alpine/src/main/java/alpine/auth/JsonWebToken.java
JsonWebToken.validateToken
public boolean validateToken(final String token) { try { final JwtParser jwtParser = Jwts.parser().setSigningKey(key); jwtParser.parse(token); this.subject = jwtParser.parseClaimsJws(token).getBody().getSubject(); this.expiration = jwtParser.parseClaimsJws(token).getBody().getExpiration(); return true; } catch (SignatureException e) { LOGGER.info(SecurityMarkers.SECURITY_FAILURE, "Received token that did not pass signature verification"); } catch (ExpiredJwtException e) { LOGGER.debug(SecurityMarkers.SECURITY_FAILURE, "Received expired token"); } catch (MalformedJwtException e) { LOGGER.debug(SecurityMarkers.SECURITY_FAILURE, "Received malformed token"); LOGGER.debug(SecurityMarkers.SECURITY_FAILURE, e.getMessage()); } catch (UnsupportedJwtException | IllegalArgumentException e) { LOGGER.error(SecurityMarkers.SECURITY_FAILURE, e.getMessage()); } return false; }
java
public boolean validateToken(final String token) { try { final JwtParser jwtParser = Jwts.parser().setSigningKey(key); jwtParser.parse(token); this.subject = jwtParser.parseClaimsJws(token).getBody().getSubject(); this.expiration = jwtParser.parseClaimsJws(token).getBody().getExpiration(); return true; } catch (SignatureException e) { LOGGER.info(SecurityMarkers.SECURITY_FAILURE, "Received token that did not pass signature verification"); } catch (ExpiredJwtException e) { LOGGER.debug(SecurityMarkers.SECURITY_FAILURE, "Received expired token"); } catch (MalformedJwtException e) { LOGGER.debug(SecurityMarkers.SECURITY_FAILURE, "Received malformed token"); LOGGER.debug(SecurityMarkers.SECURITY_FAILURE, e.getMessage()); } catch (UnsupportedJwtException | IllegalArgumentException e) { LOGGER.error(SecurityMarkers.SECURITY_FAILURE, e.getMessage()); } return false; }
[ "public", "boolean", "validateToken", "(", "final", "String", "token", ")", "{", "try", "{", "final", "JwtParser", "jwtParser", "=", "Jwts", ".", "parser", "(", ")", ".", "setSigningKey", "(", "key", ")", ";", "jwtParser", ".", "parse", "(", "token", ")"...
Validates a JWT by ensuring the signature matches and validates against the SecretKey and checks the expiration date. @param token the token to validate @return true if validation successful, false if not @since 1.0.0
[ "Validates", "a", "JWT", "by", "ensuring", "the", "signature", "matches", "and", "validates", "against", "the", "SecretKey", "and", "checks", "the", "expiration", "date", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/auth/JsonWebToken.java#L149-L167
136,511
stevespringett/Alpine
alpine/src/main/java/alpine/auth/JsonWebToken.java
JsonWebToken.addDays
private Date addDays(final Date date, final int days) { final Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.add(Calendar.DATE, days); //minus number would decrement the days return cal.getTime(); }
java
private Date addDays(final Date date, final int days) { final Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.add(Calendar.DATE, days); //minus number would decrement the days return cal.getTime(); }
[ "private", "Date", "addDays", "(", "final", "Date", "date", ",", "final", "int", "days", ")", "{", "final", "Calendar", "cal", "=", "Calendar", ".", "getInstance", "(", ")", ";", "cal", ".", "setTime", "(", "date", ")", ";", "cal", ".", "add", "(", ...
Create a new future Date from the specified Date. @param date The date to base the future date from @param days The number of dates to + offset @return a future date
[ "Create", "a", "new", "future", "Date", "from", "the", "specified", "Date", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/auth/JsonWebToken.java#L176-L181
136,512
stevespringett/Alpine
alpine/src/main/java/alpine/event/framework/AbstractChainableEvent.java
AbstractChainableEvent.linkChainIdentifier
private Event linkChainIdentifier(Event event) { if (event instanceof ChainableEvent) { ChainableEvent chainableEvent = (ChainableEvent)event; chainableEvent.setChainIdentifier(this.getChainIdentifier()); return chainableEvent; } return event; }
java
private Event linkChainIdentifier(Event event) { if (event instanceof ChainableEvent) { ChainableEvent chainableEvent = (ChainableEvent)event; chainableEvent.setChainIdentifier(this.getChainIdentifier()); return chainableEvent; } return event; }
[ "private", "Event", "linkChainIdentifier", "(", "Event", "event", ")", "{", "if", "(", "event", "instanceof", "ChainableEvent", ")", "{", "ChainableEvent", "chainableEvent", "=", "(", "ChainableEvent", ")", "event", ";", "chainableEvent", ".", "setChainIdentifier", ...
Assigns the chain identifier for the specified event to the chain identifier value of this instance. This requires the specified event to be an instance of ChainableEvent. @param event the event to chain @return a chained event
[ "Assigns", "the", "chain", "identifier", "for", "the", "specified", "event", "to", "the", "chain", "identifier", "value", "of", "this", "instance", ".", "This", "requires", "the", "specified", "event", "to", "be", "an", "instance", "of", "ChainableEvent", "." ...
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/event/framework/AbstractChainableEvent.java#L135-L142
136,513
stevespringett/Alpine
alpine/src/main/java/alpine/upgrade/UpgradeExecutor.java
UpgradeExecutor.executeUpgrades
public void executeUpgrades(final List<Class<? extends UpgradeItem>> classes) throws UpgradeException { final Connection connection = getConnection(qm); final UpgradeMetaProcessor installedUpgrades = new UpgradeMetaProcessor(connection); DbUtil.initPlatformName(connection); // Initialize DbUtil // First, we need to ensure the schema table is populated on a clean install // But we do so without passing any version. try { installedUpgrades.updateSchemaVersion(null); } catch (SQLException e) { LOGGER.error("Failed to update schema version", e); return; } for (final Class<? extends UpgradeItem> upgradeClass : classes) { try { @SuppressWarnings("unchecked") final Constructor constructor = upgradeClass.getConstructor(); final UpgradeItem upgradeItem = (UpgradeItem) constructor.newInstance(); if (upgradeItem.shouldUpgrade(qm, connection)) { if (!installedUpgrades.hasUpgradeRan(upgradeClass)) { LOGGER.info("Upgrade class " + upgradeClass.getName() + " about to run."); final long startTime = System.currentTimeMillis(); upgradeItem.executeUpgrade(qm, connection); final long endTime = System.currentTimeMillis(); installedUpgrades.installUpgrade(upgradeClass, startTime, endTime); installedUpgrades.updateSchemaVersion(new VersionComparator(upgradeItem.getSchemaVersion())); LOGGER.info("Completed running upgrade class " + upgradeClass.getName() + " in " + (endTime - startTime) + " ms."); } else { LOGGER.debug("Upgrade class " + upgradeClass.getName() + " has already ran, skipping."); } } else { LOGGER.debug("Upgrade class " + upgradeClass.getName() + " does not need to run."); } } catch (Exception e) { DbUtil.rollback(connection); LOGGER.error("Error in executing upgrade class: " + upgradeClass.getName(), e); throw new UpgradeException(e); } } }
java
public void executeUpgrades(final List<Class<? extends UpgradeItem>> classes) throws UpgradeException { final Connection connection = getConnection(qm); final UpgradeMetaProcessor installedUpgrades = new UpgradeMetaProcessor(connection); DbUtil.initPlatformName(connection); // Initialize DbUtil // First, we need to ensure the schema table is populated on a clean install // But we do so without passing any version. try { installedUpgrades.updateSchemaVersion(null); } catch (SQLException e) { LOGGER.error("Failed to update schema version", e); return; } for (final Class<? extends UpgradeItem> upgradeClass : classes) { try { @SuppressWarnings("unchecked") final Constructor constructor = upgradeClass.getConstructor(); final UpgradeItem upgradeItem = (UpgradeItem) constructor.newInstance(); if (upgradeItem.shouldUpgrade(qm, connection)) { if (!installedUpgrades.hasUpgradeRan(upgradeClass)) { LOGGER.info("Upgrade class " + upgradeClass.getName() + " about to run."); final long startTime = System.currentTimeMillis(); upgradeItem.executeUpgrade(qm, connection); final long endTime = System.currentTimeMillis(); installedUpgrades.installUpgrade(upgradeClass, startTime, endTime); installedUpgrades.updateSchemaVersion(new VersionComparator(upgradeItem.getSchemaVersion())); LOGGER.info("Completed running upgrade class " + upgradeClass.getName() + " in " + (endTime - startTime) + " ms."); } else { LOGGER.debug("Upgrade class " + upgradeClass.getName() + " has already ran, skipping."); } } else { LOGGER.debug("Upgrade class " + upgradeClass.getName() + " does not need to run."); } } catch (Exception e) { DbUtil.rollback(connection); LOGGER.error("Error in executing upgrade class: " + upgradeClass.getName(), e); throw new UpgradeException(e); } } }
[ "public", "void", "executeUpgrades", "(", "final", "List", "<", "Class", "<", "?", "extends", "UpgradeItem", ">", ">", "classes", ")", "throws", "UpgradeException", "{", "final", "Connection", "connection", "=", "getConnection", "(", "qm", ")", ";", "final", ...
Performs the execution of upgrades in the order defined by the specified array. @param classes the upgrade classes @throws UpgradeException if errors are encountered @since 1.2.0
[ "Performs", "the", "execution", "of", "upgrades", "in", "the", "order", "defined", "by", "the", "specified", "array", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/upgrade/UpgradeExecutor.java#L62-L103
136,514
stevespringett/Alpine
alpine/src/main/java/alpine/upgrade/UpgradeExecutor.java
UpgradeExecutor.getConnection
private Connection getConnection(AlpineQueryManager aqm) { final JDOConnection jdoConnection = aqm.getPersistenceManager().getDataStoreConnection(); if (jdoConnection != null) { if (jdoConnection.getNativeConnection() instanceof Connection) { return (Connection)jdoConnection.getNativeConnection(); } } return null; }
java
private Connection getConnection(AlpineQueryManager aqm) { final JDOConnection jdoConnection = aqm.getPersistenceManager().getDataStoreConnection(); if (jdoConnection != null) { if (jdoConnection.getNativeConnection() instanceof Connection) { return (Connection)jdoConnection.getNativeConnection(); } } return null; }
[ "private", "Connection", "getConnection", "(", "AlpineQueryManager", "aqm", ")", "{", "final", "JDOConnection", "jdoConnection", "=", "aqm", ".", "getPersistenceManager", "(", ")", ".", "getDataStoreConnection", "(", ")", ";", "if", "(", "jdoConnection", "!=", "nu...
This connection should never be closed.
[ "This", "connection", "should", "never", "be", "closed", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/upgrade/UpgradeExecutor.java#L108-L116
136,515
stevespringett/Alpine
alpine/src/main/java/alpine/util/UuidUtil.java
UuidUtil.isValidUUID
public static boolean isValidUUID(String uuid) { return !StringUtils.isEmpty(uuid) && UUID_PATTERN.matcher(uuid).matches(); }
java
public static boolean isValidUUID(String uuid) { return !StringUtils.isEmpty(uuid) && UUID_PATTERN.matcher(uuid).matches(); }
[ "public", "static", "boolean", "isValidUUID", "(", "String", "uuid", ")", "{", "return", "!", "StringUtils", ".", "isEmpty", "(", "uuid", ")", "&&", "UUID_PATTERN", ".", "matcher", "(", "uuid", ")", ".", "matches", "(", ")", ";", "}" ]
Determines if the specified string is a valid UUID. @param uuid the UUID to evaluate @return true if UUID is valid, false if invalid @since 1.0.0
[ "Determines", "if", "the", "specified", "string", "is", "a", "valid", "UUID", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/util/UuidUtil.java#L65-L67
136,516
stevespringett/Alpine
alpine/src/main/java/alpine/auth/LdapAuthenticationService.java
LdapAuthenticationService.autoProvision
private LdapUser autoProvision(final AlpineQueryManager qm) throws AlpineAuthenticationException { LOGGER.debug("Provisioning: " + username); LdapUser user = null; final LdapConnectionWrapper ldap = new LdapConnectionWrapper(); DirContext dirContext = null; try { dirContext = ldap.createDirContext(); final SearchResult result = ldap.searchForSingleUsername(dirContext, username); if (result != null) { user = new LdapUser(); user.setUsername(username); user.setDN(result.getNameInNamespace()); user.setEmail(ldap.getAttribute(result, LdapConnectionWrapper.ATTRIBUTE_MAIL)); user = qm.persist(user); // Dynamically assign team membership (if enabled) if (LdapConnectionWrapper.TEAM_SYNCHRONIZATION) { final List<String> groupDNs = ldap.getGroups(dirContext, user); user = qm.synchronizeTeamMembership(user, groupDNs); } } else { LOGGER.warn("Could not find '" + username + "' in the directory while provisioning the user. Ensure '" + Config.AlpineKey.LDAP_ATTRIBUTE_NAME.getPropertyName() + "' is defined correctly"); throw new AlpineAuthenticationException(AlpineAuthenticationException.CauseType.UNMAPPED_ACCOUNT); } } catch (NamingException e) { LOGGER.error("An error occurred while auto-provisioning an authenticated user", e); throw new AlpineAuthenticationException(AlpineAuthenticationException.CauseType.OTHER); } finally { ldap.closeQuietly(dirContext); } return user; }
java
private LdapUser autoProvision(final AlpineQueryManager qm) throws AlpineAuthenticationException { LOGGER.debug("Provisioning: " + username); LdapUser user = null; final LdapConnectionWrapper ldap = new LdapConnectionWrapper(); DirContext dirContext = null; try { dirContext = ldap.createDirContext(); final SearchResult result = ldap.searchForSingleUsername(dirContext, username); if (result != null) { user = new LdapUser(); user.setUsername(username); user.setDN(result.getNameInNamespace()); user.setEmail(ldap.getAttribute(result, LdapConnectionWrapper.ATTRIBUTE_MAIL)); user = qm.persist(user); // Dynamically assign team membership (if enabled) if (LdapConnectionWrapper.TEAM_SYNCHRONIZATION) { final List<String> groupDNs = ldap.getGroups(dirContext, user); user = qm.synchronizeTeamMembership(user, groupDNs); } } else { LOGGER.warn("Could not find '" + username + "' in the directory while provisioning the user. Ensure '" + Config.AlpineKey.LDAP_ATTRIBUTE_NAME.getPropertyName() + "' is defined correctly"); throw new AlpineAuthenticationException(AlpineAuthenticationException.CauseType.UNMAPPED_ACCOUNT); } } catch (NamingException e) { LOGGER.error("An error occurred while auto-provisioning an authenticated user", e); throw new AlpineAuthenticationException(AlpineAuthenticationException.CauseType.OTHER); } finally { ldap.closeQuietly(dirContext); } return user; }
[ "private", "LdapUser", "autoProvision", "(", "final", "AlpineQueryManager", "qm", ")", "throws", "AlpineAuthenticationException", "{", "LOGGER", ".", "debug", "(", "\"Provisioning: \"", "+", "username", ")", ";", "LdapUser", "user", "=", "null", ";", "final", "Lda...
Automatically creates an LdapUser, sets the value of various LDAP attributes, and persists the user to the database. @param qm the query manager to use @return the persisted LdapUser object @throws AlpineAuthenticationException if an exception occurs @since 1.4.0
[ "Automatically", "creates", "an", "LdapUser", "sets", "the", "value", "of", "various", "LDAP", "attributes", "and", "persists", "the", "user", "to", "the", "database", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/auth/LdapAuthenticationService.java#L106-L136
136,517
stevespringett/Alpine
alpine/src/main/java/alpine/auth/LdapAuthenticationService.java
LdapAuthenticationService.validateCredentials
private boolean validateCredentials() { LOGGER.debug("Validating credentials for: " + username); final LdapConnectionWrapper ldap = new LdapConnectionWrapper(); DirContext dirContext = null; LdapContext ldapContext = null; try (AlpineQueryManager qm = new AlpineQueryManager()) { final LdapUser ldapUser = qm.getLdapUser(username); if (ldapUser != null && ldapUser.getDN() != null && ldapUser.getDN().contains("=")) { ldapContext = ldap.createLdapContext(ldapUser.getDN(), password); LOGGER.debug("The supplied credentials are valid for: " + username); return true; } else { dirContext = ldap.createDirContext(); final SearchResult result = ldap.searchForSingleUsername(dirContext, username); if (result != null ) { ldapContext = ldap.createLdapContext(result.getNameInNamespace(), password); LOGGER.debug("The supplied credentials are invalid for: " + username); return true; } } } catch (NamingException e) { LOGGER.debug("An error occurred while attempting to validate credentials", e); } finally { ldap.closeQuietly(ldapContext); ldap.closeQuietly(dirContext); } return false; }
java
private boolean validateCredentials() { LOGGER.debug("Validating credentials for: " + username); final LdapConnectionWrapper ldap = new LdapConnectionWrapper(); DirContext dirContext = null; LdapContext ldapContext = null; try (AlpineQueryManager qm = new AlpineQueryManager()) { final LdapUser ldapUser = qm.getLdapUser(username); if (ldapUser != null && ldapUser.getDN() != null && ldapUser.getDN().contains("=")) { ldapContext = ldap.createLdapContext(ldapUser.getDN(), password); LOGGER.debug("The supplied credentials are valid for: " + username); return true; } else { dirContext = ldap.createDirContext(); final SearchResult result = ldap.searchForSingleUsername(dirContext, username); if (result != null ) { ldapContext = ldap.createLdapContext(result.getNameInNamespace(), password); LOGGER.debug("The supplied credentials are invalid for: " + username); return true; } } } catch (NamingException e) { LOGGER.debug("An error occurred while attempting to validate credentials", e); } finally { ldap.closeQuietly(ldapContext); ldap.closeQuietly(dirContext); } return false; }
[ "private", "boolean", "validateCredentials", "(", ")", "{", "LOGGER", ".", "debug", "(", "\"Validating credentials for: \"", "+", "username", ")", ";", "final", "LdapConnectionWrapper", "ldap", "=", "new", "LdapConnectionWrapper", "(", ")", ";", "DirContext", "dirCo...
Asserts a users credentials. Returns a boolean value indicating if assertion was successful or not. @return true if assertion was successful, false if not @since 1.0.0
[ "Asserts", "a", "users", "credentials", ".", "Returns", "a", "boolean", "value", "indicating", "if", "assertion", "was", "successful", "or", "not", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/auth/LdapAuthenticationService.java#L145-L172
136,518
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/PersistenceManagerFactory.java
PersistenceManagerFactory.createPersistenceManager
public static PersistenceManager createPersistenceManager() { if (Config.isUnitTestsEnabled()) { pmf = (JDOPersistenceManagerFactory)JDOHelper.getPersistenceManagerFactory(JdoProperties.unit(), "Alpine"); } if (pmf == null) { throw new IllegalStateException("Context is not initialized yet."); } return pmf.getPersistenceManager(); }
java
public static PersistenceManager createPersistenceManager() { if (Config.isUnitTestsEnabled()) { pmf = (JDOPersistenceManagerFactory)JDOHelper.getPersistenceManagerFactory(JdoProperties.unit(), "Alpine"); } if (pmf == null) { throw new IllegalStateException("Context is not initialized yet."); } return pmf.getPersistenceManager(); }
[ "public", "static", "PersistenceManager", "createPersistenceManager", "(", ")", "{", "if", "(", "Config", ".", "isUnitTestsEnabled", "(", ")", ")", "{", "pmf", "=", "(", "JDOPersistenceManagerFactory", ")", "JDOHelper", ".", "getPersistenceManagerFactory", "(", "Jdo...
Creates a new JDO PersistenceManager. @return a PersistenceManager
[ "Creates", "a", "new", "JDO", "PersistenceManager", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/PersistenceManagerFactory.java#L76-L84
136,519
stevespringett/Alpine
alpine/src/main/java/alpine/auth/LdapConnectionWrapper.java
LdapConnectionWrapper.createLdapContext
public LdapContext createLdapContext(final String userDn, final String password) throws NamingException { LOGGER.debug("Creating LDAP context for: " +userDn); if (StringUtils.isEmpty(userDn) || StringUtils.isEmpty(password)) { throw new NamingException("Username or password cannot be empty or null"); } final Hashtable<String, String> env = new Hashtable<>(); if (StringUtils.isNotBlank(LDAP_SECURITY_AUTH)) { env.put(Context.SECURITY_AUTHENTICATION, LDAP_SECURITY_AUTH); } env.put(Context.SECURITY_PRINCIPAL, userDn); env.put(Context.SECURITY_CREDENTIALS, password); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, LDAP_URL); if (IS_LDAP_SSLTLS) { env.put("java.naming.ldap.factory.socket", "alpine.crypto.RelaxedSSLSocketFactory"); } try { return new InitialLdapContext(env, null); } catch (CommunicationException e) { LOGGER.error("Failed to connect to directory server", e); throw(e); } catch (NamingException e) { throw new NamingException("Failed to authenticate user"); } }
java
public LdapContext createLdapContext(final String userDn, final String password) throws NamingException { LOGGER.debug("Creating LDAP context for: " +userDn); if (StringUtils.isEmpty(userDn) || StringUtils.isEmpty(password)) { throw new NamingException("Username or password cannot be empty or null"); } final Hashtable<String, String> env = new Hashtable<>(); if (StringUtils.isNotBlank(LDAP_SECURITY_AUTH)) { env.put(Context.SECURITY_AUTHENTICATION, LDAP_SECURITY_AUTH); } env.put(Context.SECURITY_PRINCIPAL, userDn); env.put(Context.SECURITY_CREDENTIALS, password); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, LDAP_URL); if (IS_LDAP_SSLTLS) { env.put("java.naming.ldap.factory.socket", "alpine.crypto.RelaxedSSLSocketFactory"); } try { return new InitialLdapContext(env, null); } catch (CommunicationException e) { LOGGER.error("Failed to connect to directory server", e); throw(e); } catch (NamingException e) { throw new NamingException("Failed to authenticate user"); } }
[ "public", "LdapContext", "createLdapContext", "(", "final", "String", "userDn", ",", "final", "String", "password", ")", "throws", "NamingException", "{", "LOGGER", ".", "debug", "(", "\"Creating LDAP context for: \"", "+", "userDn", ")", ";", "if", "(", "StringUt...
Asserts a users credentials. Returns an LdapContext if assertion is successful or an exception for any other reason. @param userDn the users DN to assert @param password the password to assert @return the LdapContext upon a successful connection @throws NamingException when unable to establish a connection @since 1.4.0
[ "Asserts", "a", "users", "credentials", ".", "Returns", "an", "LdapContext", "if", "assertion", "is", "successful", "or", "an", "exception", "for", "any", "other", "reason", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/auth/LdapConnectionWrapper.java#L82-L106
136,520
stevespringett/Alpine
alpine/src/main/java/alpine/auth/LdapConnectionWrapper.java
LdapConnectionWrapper.createDirContext
public DirContext createDirContext() throws NamingException { LOGGER.debug("Creating directory service context (DirContext)"); final Hashtable<String, String> env = new Hashtable<>(); env.put(Context.SECURITY_PRINCIPAL, BIND_USERNAME); env.put(Context.SECURITY_CREDENTIALS, BIND_PASSWORD); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, LDAP_URL); if (IS_LDAP_SSLTLS) { env.put("java.naming.ldap.factory.socket", "alpine.crypto.RelaxedSSLSocketFactory"); } return new InitialDirContext(env); }
java
public DirContext createDirContext() throws NamingException { LOGGER.debug("Creating directory service context (DirContext)"); final Hashtable<String, String> env = new Hashtable<>(); env.put(Context.SECURITY_PRINCIPAL, BIND_USERNAME); env.put(Context.SECURITY_CREDENTIALS, BIND_PASSWORD); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, LDAP_URL); if (IS_LDAP_SSLTLS) { env.put("java.naming.ldap.factory.socket", "alpine.crypto.RelaxedSSLSocketFactory"); } return new InitialDirContext(env); }
[ "public", "DirContext", "createDirContext", "(", ")", "throws", "NamingException", "{", "LOGGER", ".", "debug", "(", "\"Creating directory service context (DirContext)\"", ")", ";", "final", "Hashtable", "<", "String", ",", "String", ">", "env", "=", "new", "Hashtab...
Creates a DirContext with the applications configuration settings. @return a DirContext @throws NamingException if an exception is thrown @since 1.4.0
[ "Creates", "a", "DirContext", "with", "the", "applications", "configuration", "settings", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/auth/LdapConnectionWrapper.java#L114-L125
136,521
stevespringett/Alpine
alpine/src/main/java/alpine/auth/LdapConnectionWrapper.java
LdapConnectionWrapper.getGroups
public List<String> getGroups(final DirContext dirContext, final LdapUser ldapUser) throws NamingException { LOGGER.debug("Retrieving groups for: " + ldapUser.getDN()); final List<String> groupDns = new ArrayList<>(); final String searchFilter = variableSubstitution(USER_GROUPS_FILTER, ldapUser); final SearchControls sc = new SearchControls(); sc.setSearchScope(SearchControls.SUBTREE_SCOPE); final NamingEnumeration<SearchResult> ne = dirContext.search(BASE_DN, searchFilter, sc); while (hasMoreEnum(ne)) { final SearchResult result = ne.next(); groupDns.add(result.getNameInNamespace()); LOGGER.debug("Found group: " + result.getNameInNamespace() + " for user: " + ldapUser.getDN()); } closeQuietly(ne); return groupDns; }
java
public List<String> getGroups(final DirContext dirContext, final LdapUser ldapUser) throws NamingException { LOGGER.debug("Retrieving groups for: " + ldapUser.getDN()); final List<String> groupDns = new ArrayList<>(); final String searchFilter = variableSubstitution(USER_GROUPS_FILTER, ldapUser); final SearchControls sc = new SearchControls(); sc.setSearchScope(SearchControls.SUBTREE_SCOPE); final NamingEnumeration<SearchResult> ne = dirContext.search(BASE_DN, searchFilter, sc); while (hasMoreEnum(ne)) { final SearchResult result = ne.next(); groupDns.add(result.getNameInNamespace()); LOGGER.debug("Found group: " + result.getNameInNamespace() + " for user: " + ldapUser.getDN()); } closeQuietly(ne); return groupDns; }
[ "public", "List", "<", "String", ">", "getGroups", "(", "final", "DirContext", "dirContext", ",", "final", "LdapUser", "ldapUser", ")", "throws", "NamingException", "{", "LOGGER", ".", "debug", "(", "\"Retrieving groups for: \"", "+", "ldapUser", ".", "getDN", "...
Retrieves a list of all groups the user is a member of. @param dirContext a DirContext @param ldapUser the LdapUser to retrieve group membership for @return A list of Strings representing the fully qualified DN of each group @throws NamingException if an exception is thrown @since 1.4.0
[ "Retrieves", "a", "list", "of", "all", "groups", "the", "user", "is", "a", "member", "of", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/auth/LdapConnectionWrapper.java#L135-L149
136,522
stevespringett/Alpine
alpine/src/main/java/alpine/auth/LdapConnectionWrapper.java
LdapConnectionWrapper.getGroups
public List<String> getGroups(final DirContext dirContext) throws NamingException { LOGGER.debug("Retrieving all groups"); final List<String> groupDns = new ArrayList<>(); final SearchControls sc = new SearchControls(); sc.setSearchScope(SearchControls.SUBTREE_SCOPE); final NamingEnumeration<SearchResult> ne = dirContext.search(BASE_DN, GROUPS_FILTER, sc); while (hasMoreEnum(ne)) { final SearchResult result = ne.next(); groupDns.add(result.getNameInNamespace()); LOGGER.debug("Found group: " + result.getNameInNamespace()); } closeQuietly(ne); return groupDns; }
java
public List<String> getGroups(final DirContext dirContext) throws NamingException { LOGGER.debug("Retrieving all groups"); final List<String> groupDns = new ArrayList<>(); final SearchControls sc = new SearchControls(); sc.setSearchScope(SearchControls.SUBTREE_SCOPE); final NamingEnumeration<SearchResult> ne = dirContext.search(BASE_DN, GROUPS_FILTER, sc); while (hasMoreEnum(ne)) { final SearchResult result = ne.next(); groupDns.add(result.getNameInNamespace()); LOGGER.debug("Found group: " + result.getNameInNamespace()); } closeQuietly(ne); return groupDns; }
[ "public", "List", "<", "String", ">", "getGroups", "(", "final", "DirContext", "dirContext", ")", "throws", "NamingException", "{", "LOGGER", ".", "debug", "(", "\"Retrieving all groups\"", ")", ";", "final", "List", "<", "String", ">", "groupDns", "=", "new",...
Retrieves a list of all the groups in the directory. @param dirContext a DirContext @return A list of Strings representing the fully qualified DN of each group @throws NamingException if an exception if thrown @since 1.4.0
[ "Retrieves", "a", "list", "of", "all", "the", "groups", "in", "the", "directory", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/auth/LdapConnectionWrapper.java#L158-L171
136,523
stevespringett/Alpine
alpine/src/main/java/alpine/auth/LdapConnectionWrapper.java
LdapConnectionWrapper.getAttribute
public String getAttribute(final DirContext ctx, final String dn, final String attributeName) throws NamingException { final Attributes attributes = ctx.getAttributes(dn); return getAttribute(attributes, attributeName); }
java
public String getAttribute(final DirContext ctx, final String dn, final String attributeName) throws NamingException { final Attributes attributes = ctx.getAttributes(dn); return getAttribute(attributes, attributeName); }
[ "public", "String", "getAttribute", "(", "final", "DirContext", "ctx", ",", "final", "String", "dn", ",", "final", "String", "attributeName", ")", "throws", "NamingException", "{", "final", "Attributes", "attributes", "=", "ctx", ".", "getAttributes", "(", "dn",...
Retrieves an attribute by its name for the specified dn. @param ctx the DirContext to use @param dn the distinguished name of the entry to obtain the attribute value for @param attributeName the name of the attribute to return @return the value of the attribute, or null if not found @throws NamingException if an exception is thrown @since 1.4.0
[ "Retrieves", "an", "attribute", "by", "its", "name", "for", "the", "specified", "dn", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/auth/LdapConnectionWrapper.java#L225-L228
136,524
stevespringett/Alpine
alpine/src/main/java/alpine/auth/LdapConnectionWrapper.java
LdapConnectionWrapper.getAttribute
public String getAttribute(final SearchResult result, final String attributeName) throws NamingException { return getAttribute(result.getAttributes(), attributeName); }
java
public String getAttribute(final SearchResult result, final String attributeName) throws NamingException { return getAttribute(result.getAttributes(), attributeName); }
[ "public", "String", "getAttribute", "(", "final", "SearchResult", "result", ",", "final", "String", "attributeName", ")", "throws", "NamingException", "{", "return", "getAttribute", "(", "result", ".", "getAttributes", "(", ")", ",", "attributeName", ")", ";", "...
Retrieves an attribute by its name for the specified search result. @param result the search result of the entry to obtain the attribute value for @param attributeName the name of the attribute to return @return the value of the attribute, or null if not found @throws NamingException if an exception is thrown @since 1.4.0
[ "Retrieves", "an", "attribute", "by", "its", "name", "for", "the", "specified", "search", "result", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/auth/LdapConnectionWrapper.java#L238-L240
136,525
stevespringett/Alpine
alpine/src/main/java/alpine/auth/LdapConnectionWrapper.java
LdapConnectionWrapper.getAttribute
public String getAttribute(final Attributes attributes, final String attributeName) throws NamingException { if (attributes == null || attributes.size() == 0) { return null; } else { final Attribute attribute = attributes.get(attributeName); if (attribute != null) { final Object o = attribute.get(); if (o instanceof String) { return (String) attribute.get(); } } } return null; }
java
public String getAttribute(final Attributes attributes, final String attributeName) throws NamingException { if (attributes == null || attributes.size() == 0) { return null; } else { final Attribute attribute = attributes.get(attributeName); if (attribute != null) { final Object o = attribute.get(); if (o instanceof String) { return (String) attribute.get(); } } } return null; }
[ "public", "String", "getAttribute", "(", "final", "Attributes", "attributes", ",", "final", "String", "attributeName", ")", "throws", "NamingException", "{", "if", "(", "attributes", "==", "null", "||", "attributes", ".", "size", "(", ")", "==", "0", ")", "{...
Retrieves an attribute by its name. @param attributes the list of attributes to query on @param attributeName the name of the attribute to return @return the value of the attribute, or null if not found @throws NamingException if an exception is thrown @since 1.4.0
[ "Retrieves", "an", "attribute", "by", "its", "name", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/auth/LdapConnectionWrapper.java#L250-L263
136,526
stevespringett/Alpine
alpine/src/main/java/alpine/auth/LdapConnectionWrapper.java
LdapConnectionWrapper.formatPrincipal
private static String formatPrincipal(final String username) { if (StringUtils.isNotBlank(LDAP_AUTH_USERNAME_FMT)) { return String.format(LDAP_AUTH_USERNAME_FMT, username); } return username; }
java
private static String formatPrincipal(final String username) { if (StringUtils.isNotBlank(LDAP_AUTH_USERNAME_FMT)) { return String.format(LDAP_AUTH_USERNAME_FMT, username); } return username; }
[ "private", "static", "String", "formatPrincipal", "(", "final", "String", "username", ")", "{", "if", "(", "StringUtils", ".", "isNotBlank", "(", "LDAP_AUTH_USERNAME_FMT", ")", ")", "{", "return", "String", ".", "format", "(", "LDAP_AUTH_USERNAME_FMT", ",", "use...
Formats the principal in username@domain format or in a custom format if is specified in the config file. If LDAP_AUTH_USERNAME_FMT is configured to a non-empty value, the substring %s in this value will be replaced with the entered username. The recommended format of this value depends on your LDAP server(Active Directory, OpenLDAP, etc.). Examples: alpine.ldap.auth.username.format=%s alpine.ldap.auth.username.format=%s@company.com @param username the username @return a formatted user principal @since 1.4.0
[ "Formats", "the", "principal", "in", "username" ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/auth/LdapConnectionWrapper.java#L276-L281
136,527
stevespringett/Alpine
alpine/src/main/java/alpine/util/GravatarUtil.java
GravatarUtil.generateHash
public static String generateHash(String emailAddress) { if (StringUtils.isBlank(emailAddress)) { return null; } return DigestUtils.md5Hex(emailAddress.trim().toLowerCase()).toLowerCase(); }
java
public static String generateHash(String emailAddress) { if (StringUtils.isBlank(emailAddress)) { return null; } return DigestUtils.md5Hex(emailAddress.trim().toLowerCase()).toLowerCase(); }
[ "public", "static", "String", "generateHash", "(", "String", "emailAddress", ")", "{", "if", "(", "StringUtils", ".", "isBlank", "(", "emailAddress", ")", ")", "{", "return", "null", ";", "}", "return", "DigestUtils", ".", "md5Hex", "(", "emailAddress", ".",...
Generates a hash value from the specified email address. Returns null if emailAddress is empty or null. @param emailAddress the email address to generate a hash from @return a hash value of the specified email address @since 1.0.0
[ "Generates", "a", "hash", "value", "from", "the", "specified", "email", "address", ".", "Returns", "null", "if", "emailAddress", "is", "empty", "or", "null", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/util/GravatarUtil.java#L44-L49
136,528
stevespringett/Alpine
alpine/src/main/java/alpine/util/GravatarUtil.java
GravatarUtil.getGravatarUrl
public static String getGravatarUrl(String emailAddress) { String hash = generateHash(emailAddress); if (hash == null) { return "https://www.gravatar.com/avatar/00000000000000000000000000000000" + ".jpg?d=mm"; } else { return "https://www.gravatar.com/avatar/" + hash + ".jpg?d=mm"; } }
java
public static String getGravatarUrl(String emailAddress) { String hash = generateHash(emailAddress); if (hash == null) { return "https://www.gravatar.com/avatar/00000000000000000000000000000000" + ".jpg?d=mm"; } else { return "https://www.gravatar.com/avatar/" + hash + ".jpg?d=mm"; } }
[ "public", "static", "String", "getGravatarUrl", "(", "String", "emailAddress", ")", "{", "String", "hash", "=", "generateHash", "(", "emailAddress", ")", ";", "if", "(", "hash", "==", "null", ")", "{", "return", "\"https://www.gravatar.com/avatar/0000000000000000000...
Generates a Gravatar URL for the specified email address. If the email address is blank or does not have a Gravatar, will fallback to usingthe mystery-man image. @param emailAddress the email address to generate the Gravatar URL from @return a Gravatar URL for the specified email address @since 1.0.0
[ "Generates", "a", "Gravatar", "URL", "for", "the", "specified", "email", "address", ".", "If", "the", "email", "address", "is", "blank", "or", "does", "not", "have", "a", "Gravatar", "will", "fallback", "to", "usingthe", "mystery", "-", "man", "image", "."...
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/util/GravatarUtil.java#L86-L93
136,529
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/AlpineQueryManager.java
AlpineQueryManager.getApiKey
@SuppressWarnings("unchecked") public ApiKey getApiKey(final String key) { final Query query = pm.newQuery(ApiKey.class, "key == :key"); final List<ApiKey> result = (List<ApiKey>) query.execute(key); return Collections.isEmpty(result) ? null : result.get(0); }
java
@SuppressWarnings("unchecked") public ApiKey getApiKey(final String key) { final Query query = pm.newQuery(ApiKey.class, "key == :key"); final List<ApiKey> result = (List<ApiKey>) query.execute(key); return Collections.isEmpty(result) ? null : result.get(0); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "ApiKey", "getApiKey", "(", "final", "String", "key", ")", "{", "final", "Query", "query", "=", "pm", ".", "newQuery", "(", "ApiKey", ".", "class", ",", "\"key == :key\"", ")", ";", "final", "Li...
Returns an API key. @param key the key to return @return an ApiKey @since 1.0.0
[ "Returns", "an", "API", "key", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AlpineQueryManager.java#L85-L90
136,530
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/AlpineQueryManager.java
AlpineQueryManager.regenerateApiKey
public ApiKey regenerateApiKey(final ApiKey apiKey) { pm.currentTransaction().begin(); apiKey.setKey(ApiKeyGenerator.generate()); pm.currentTransaction().commit(); return pm.getObjectById(ApiKey.class, apiKey.getId()); }
java
public ApiKey regenerateApiKey(final ApiKey apiKey) { pm.currentTransaction().begin(); apiKey.setKey(ApiKeyGenerator.generate()); pm.currentTransaction().commit(); return pm.getObjectById(ApiKey.class, apiKey.getId()); }
[ "public", "ApiKey", "regenerateApiKey", "(", "final", "ApiKey", "apiKey", ")", "{", "pm", ".", "currentTransaction", "(", ")", ".", "begin", "(", ")", ";", "apiKey", ".", "setKey", "(", "ApiKeyGenerator", ".", "generate", "(", ")", ")", ";", "pm", ".", ...
Regenerates an API key. This method does not create a new ApiKey object, rather it uses the existing ApiKey object and simply creates a new key string. @param apiKey the ApiKey object to regenerate the key of. @return an ApiKey @since 1.0.0
[ "Regenerates", "an", "API", "key", ".", "This", "method", "does", "not", "create", "a", "new", "ApiKey", "object", "rather", "it", "uses", "the", "existing", "ApiKey", "object", "and", "simply", "creates", "a", "new", "key", "string", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AlpineQueryManager.java#L100-L105
136,531
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/AlpineQueryManager.java
AlpineQueryManager.createApiKey
public ApiKey createApiKey(final Team team) { final List<Team> teams = new ArrayList<>(); teams.add(team); pm.currentTransaction().begin(); final ApiKey apiKey = new ApiKey(); apiKey.setKey(ApiKeyGenerator.generate()); apiKey.setTeams(teams); pm.makePersistent(apiKey); pm.currentTransaction().commit(); return pm.getObjectById(ApiKey.class, apiKey.getId()); }
java
public ApiKey createApiKey(final Team team) { final List<Team> teams = new ArrayList<>(); teams.add(team); pm.currentTransaction().begin(); final ApiKey apiKey = new ApiKey(); apiKey.setKey(ApiKeyGenerator.generate()); apiKey.setTeams(teams); pm.makePersistent(apiKey); pm.currentTransaction().commit(); return pm.getObjectById(ApiKey.class, apiKey.getId()); }
[ "public", "ApiKey", "createApiKey", "(", "final", "Team", "team", ")", "{", "final", "List", "<", "Team", ">", "teams", "=", "new", "ArrayList", "<>", "(", ")", ";", "teams", ".", "add", "(", "team", ")", ";", "pm", ".", "currentTransaction", "(", ")...
Creates a new ApiKey object, including a cryptographically secure API key string. @param team The team to create the key for @return an ApiKey
[ "Creates", "a", "new", "ApiKey", "object", "including", "a", "cryptographically", "secure", "API", "key", "string", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AlpineQueryManager.java#L113-L123
136,532
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/AlpineQueryManager.java
AlpineQueryManager.getLdapUser
@SuppressWarnings("unchecked") public LdapUser getLdapUser(final String username) { final Query query = pm.newQuery(LdapUser.class, "username == :username"); final List<LdapUser> result = (List<LdapUser>) query.execute(username); return Collections.isEmpty(result) ? null : result.get(0); }
java
@SuppressWarnings("unchecked") public LdapUser getLdapUser(final String username) { final Query query = pm.newQuery(LdapUser.class, "username == :username"); final List<LdapUser> result = (List<LdapUser>) query.execute(username); return Collections.isEmpty(result) ? null : result.get(0); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "LdapUser", "getLdapUser", "(", "final", "String", "username", ")", "{", "final", "Query", "query", "=", "pm", ".", "newQuery", "(", "LdapUser", ".", "class", ",", "\"username == :username\"", ")", ...
Retrieves an LdapUser containing the specified username. If the username does not exist, returns null. @param username The username to retrieve @return an LdapUser @since 1.0.0
[ "Retrieves", "an", "LdapUser", "containing", "the", "specified", "username", ".", "If", "the", "username", "does", "not", "exist", "returns", "null", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AlpineQueryManager.java#L132-L137
136,533
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/AlpineQueryManager.java
AlpineQueryManager.getLdapUsers
@SuppressWarnings("unchecked") public List<LdapUser> getLdapUsers() { final Query query = pm.newQuery(LdapUser.class); query.setOrdering("username asc"); return (List<LdapUser>) query.execute(); }
java
@SuppressWarnings("unchecked") public List<LdapUser> getLdapUsers() { final Query query = pm.newQuery(LdapUser.class); query.setOrdering("username asc"); return (List<LdapUser>) query.execute(); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "List", "<", "LdapUser", ">", "getLdapUsers", "(", ")", "{", "final", "Query", "query", "=", "pm", ".", "newQuery", "(", "LdapUser", ".", "class", ")", ";", "query", ".", "setOrdering", "(", "...
Returns a complete list of all LdapUser objects, in ascending order by username. @return a list of LdapUsers @since 1.0.0
[ "Returns", "a", "complete", "list", "of", "all", "LdapUser", "objects", "in", "ascending", "order", "by", "username", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AlpineQueryManager.java#L144-L149
136,534
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/AlpineQueryManager.java
AlpineQueryManager.createLdapUser
public LdapUser createLdapUser(final String username) { pm.currentTransaction().begin(); final LdapUser user = new LdapUser(); user.setUsername(username); user.setDN("Syncing..."); pm.makePersistent(user); pm.currentTransaction().commit(); EventService.getInstance().publish(new LdapSyncEvent(user.getUsername())); return getObjectById(LdapUser.class, user.getId()); }
java
public LdapUser createLdapUser(final String username) { pm.currentTransaction().begin(); final LdapUser user = new LdapUser(); user.setUsername(username); user.setDN("Syncing..."); pm.makePersistent(user); pm.currentTransaction().commit(); EventService.getInstance().publish(new LdapSyncEvent(user.getUsername())); return getObjectById(LdapUser.class, user.getId()); }
[ "public", "LdapUser", "createLdapUser", "(", "final", "String", "username", ")", "{", "pm", ".", "currentTransaction", "(", ")", ".", "begin", "(", ")", ";", "final", "LdapUser", "user", "=", "new", "LdapUser", "(", ")", ";", "user", ".", "setUsername", ...
Creates a new LdapUser object with the specified username. @param username The username of the new LdapUser. This must reference an existing username in the directory service @return an LdapUser @since 1.0.0
[ "Creates", "a", "new", "LdapUser", "object", "with", "the", "specified", "username", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AlpineQueryManager.java#L157-L166
136,535
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/AlpineQueryManager.java
AlpineQueryManager.updateLdapUser
public LdapUser updateLdapUser(final LdapUser transientUser) { final LdapUser user = getObjectById(LdapUser.class, transientUser.getId()); pm.currentTransaction().begin(); user.setDN(transientUser.getDN()); pm.currentTransaction().commit(); return pm.getObjectById(LdapUser.class, user.getId()); }
java
public LdapUser updateLdapUser(final LdapUser transientUser) { final LdapUser user = getObjectById(LdapUser.class, transientUser.getId()); pm.currentTransaction().begin(); user.setDN(transientUser.getDN()); pm.currentTransaction().commit(); return pm.getObjectById(LdapUser.class, user.getId()); }
[ "public", "LdapUser", "updateLdapUser", "(", "final", "LdapUser", "transientUser", ")", "{", "final", "LdapUser", "user", "=", "getObjectById", "(", "LdapUser", ".", "class", ",", "transientUser", ".", "getId", "(", ")", ")", ";", "pm", ".", "currentTransactio...
Updates the specified LdapUser. @param transientUser the optionally detached LdapUser object to update. @return an LdapUser @since 1.0.0
[ "Updates", "the", "specified", "LdapUser", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AlpineQueryManager.java#L174-L180
136,536
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/AlpineQueryManager.java
AlpineQueryManager.updateManagedUser
public ManagedUser updateManagedUser(final ManagedUser transientUser) { final ManagedUser user = getObjectById(ManagedUser.class, transientUser.getId()); pm.currentTransaction().begin(); user.setFullname(transientUser.getFullname()); user.setEmail(transientUser.getEmail()); user.setForcePasswordChange(transientUser.isForcePasswordChange()); user.setNonExpiryPassword(transientUser.isNonExpiryPassword()); user.setSuspended(transientUser.isSuspended()); if (transientUser.getPassword() != null) { if (!user.getPassword().equals(transientUser.getPassword())) { user.setLastPasswordChange(new Date()); } user.setPassword(transientUser.getPassword()); } pm.currentTransaction().commit(); return pm.getObjectById(ManagedUser.class, user.getId()); }
java
public ManagedUser updateManagedUser(final ManagedUser transientUser) { final ManagedUser user = getObjectById(ManagedUser.class, transientUser.getId()); pm.currentTransaction().begin(); user.setFullname(transientUser.getFullname()); user.setEmail(transientUser.getEmail()); user.setForcePasswordChange(transientUser.isForcePasswordChange()); user.setNonExpiryPassword(transientUser.isNonExpiryPassword()); user.setSuspended(transientUser.isSuspended()); if (transientUser.getPassword() != null) { if (!user.getPassword().equals(transientUser.getPassword())) { user.setLastPasswordChange(new Date()); } user.setPassword(transientUser.getPassword()); } pm.currentTransaction().commit(); return pm.getObjectById(ManagedUser.class, user.getId()); }
[ "public", "ManagedUser", "updateManagedUser", "(", "final", "ManagedUser", "transientUser", ")", "{", "final", "ManagedUser", "user", "=", "getObjectById", "(", "ManagedUser", ".", "class", ",", "transientUser", ".", "getId", "(", ")", ")", ";", "pm", ".", "cu...
Updates the specified ManagedUser. @param transientUser the optionally detached ManagedUser object to update. @return an ManagedUser @since 1.0.0
[ "Updates", "the", "specified", "ManagedUser", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AlpineQueryManager.java#L274-L290
136,537
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/AlpineQueryManager.java
AlpineQueryManager.getManagedUser
@SuppressWarnings("unchecked") public ManagedUser getManagedUser(final String username) { final Query query = pm.newQuery(ManagedUser.class, "username == :username"); final List<ManagedUser> result = (List<ManagedUser>) query.execute(username); return Collections.isEmpty(result) ? null : result.get(0); }
java
@SuppressWarnings("unchecked") public ManagedUser getManagedUser(final String username) { final Query query = pm.newQuery(ManagedUser.class, "username == :username"); final List<ManagedUser> result = (List<ManagedUser>) query.execute(username); return Collections.isEmpty(result) ? null : result.get(0); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "ManagedUser", "getManagedUser", "(", "final", "String", "username", ")", "{", "final", "Query", "query", "=", "pm", ".", "newQuery", "(", "ManagedUser", ".", "class", ",", "\"username == :username\"", ...
Returns a ManagedUser with the specified username. If the username does not exist, returns null. @param username The username to retrieve @return a ManagedUser @since 1.0.0
[ "Returns", "a", "ManagedUser", "with", "the", "specified", "username", ".", "If", "the", "username", "does", "not", "exist", "returns", "null", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AlpineQueryManager.java#L299-L304
136,538
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/AlpineQueryManager.java
AlpineQueryManager.getManagedUsers
@SuppressWarnings("unchecked") public List<ManagedUser> getManagedUsers() { final Query query = pm.newQuery(ManagedUser.class); query.setOrdering("username asc"); return (List<ManagedUser>) query.execute(); }
java
@SuppressWarnings("unchecked") public List<ManagedUser> getManagedUsers() { final Query query = pm.newQuery(ManagedUser.class); query.setOrdering("username asc"); return (List<ManagedUser>) query.execute(); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "List", "<", "ManagedUser", ">", "getManagedUsers", "(", ")", "{", "final", "Query", "query", "=", "pm", ".", "newQuery", "(", "ManagedUser", ".", "class", ")", ";", "query", ".", "setOrdering", ...
Returns a complete list of all ManagedUser objects, in ascending order by username. @return a List of ManagedUsers @since 1.0.0
[ "Returns", "a", "complete", "list", "of", "all", "ManagedUser", "objects", "in", "ascending", "order", "by", "username", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AlpineQueryManager.java#L311-L316
136,539
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/AlpineQueryManager.java
AlpineQueryManager.getUserPrincipal
public UserPrincipal getUserPrincipal(String username) { final UserPrincipal principal = getManagedUser(username); if (principal != null) { return principal; } return getLdapUser(username); }
java
public UserPrincipal getUserPrincipal(String username) { final UserPrincipal principal = getManagedUser(username); if (principal != null) { return principal; } return getLdapUser(username); }
[ "public", "UserPrincipal", "getUserPrincipal", "(", "String", "username", ")", "{", "final", "UserPrincipal", "principal", "=", "getManagedUser", "(", "username", ")", ";", "if", "(", "principal", "!=", "null", ")", "{", "return", "principal", ";", "}", "retur...
Resolves a UserPrincipal. Default order resolution is to first match on ManagedUser then on LdapUser. This may be configurable in a future release. @param username the username of the principal to retrieve @return a UserPrincipal if found, null if not found @since 1.0.0
[ "Resolves", "a", "UserPrincipal", ".", "Default", "order", "resolution", "is", "to", "first", "match", "on", "ManagedUser", "then", "on", "LdapUser", ".", "This", "may", "be", "configurable", "in", "a", "future", "release", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AlpineQueryManager.java#L326-L332
136,540
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/AlpineQueryManager.java
AlpineQueryManager.getTeams
@SuppressWarnings("unchecked") public List<Team> getTeams() { pm.getFetchPlan().addGroup(Team.FetchGroup.ALL.name()); final Query query = pm.newQuery(Team.class); query.setOrdering("name asc"); return (List<Team>) query.execute(); }
java
@SuppressWarnings("unchecked") public List<Team> getTeams() { pm.getFetchPlan().addGroup(Team.FetchGroup.ALL.name()); final Query query = pm.newQuery(Team.class); query.setOrdering("name asc"); return (List<Team>) query.execute(); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "List", "<", "Team", ">", "getTeams", "(", ")", "{", "pm", ".", "getFetchPlan", "(", ")", ".", "addGroup", "(", "Team", ".", "FetchGroup", ".", "ALL", ".", "name", "(", ")", ")", ";", "fin...
Returns a complete list of all Team objects, in ascending order by name. @return a List of Teams @since 1.0.0
[ "Returns", "a", "complete", "list", "of", "all", "Team", "objects", "in", "ascending", "order", "by", "name", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AlpineQueryManager.java#L361-L367
136,541
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/AlpineQueryManager.java
AlpineQueryManager.updateTeam
public Team updateTeam(final Team transientTeam) { final Team team = getObjectByUuid(Team.class, transientTeam.getUuid()); pm.currentTransaction().begin(); team.setName(transientTeam.getName()); //todo assign permissions pm.currentTransaction().commit(); return pm.getObjectById(Team.class, team.getId()); }
java
public Team updateTeam(final Team transientTeam) { final Team team = getObjectByUuid(Team.class, transientTeam.getUuid()); pm.currentTransaction().begin(); team.setName(transientTeam.getName()); //todo assign permissions pm.currentTransaction().commit(); return pm.getObjectById(Team.class, team.getId()); }
[ "public", "Team", "updateTeam", "(", "final", "Team", "transientTeam", ")", "{", "final", "Team", "team", "=", "getObjectByUuid", "(", "Team", ".", "class", ",", "transientTeam", ".", "getUuid", "(", ")", ")", ";", "pm", ".", "currentTransaction", "(", ")"...
Updates the specified Team. @param transientTeam the optionally detached Team object to update @return a Team @since 1.0.0
[ "Updates", "the", "specified", "Team", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AlpineQueryManager.java#L375-L382
136,542
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/AlpineQueryManager.java
AlpineQueryManager.addUserToTeam
public boolean addUserToTeam(final UserPrincipal user, final Team team) { List<Team> teams = user.getTeams(); boolean found = false; if (teams == null) { teams = new ArrayList<>(); } for (final Team t: teams) { if (team.getUuid().equals(t.getUuid())) { found = true; } } if (!found) { pm.currentTransaction().begin(); teams.add(team); user.setTeams(teams); pm.currentTransaction().commit(); return true; } return false; }
java
public boolean addUserToTeam(final UserPrincipal user, final Team team) { List<Team> teams = user.getTeams(); boolean found = false; if (teams == null) { teams = new ArrayList<>(); } for (final Team t: teams) { if (team.getUuid().equals(t.getUuid())) { found = true; } } if (!found) { pm.currentTransaction().begin(); teams.add(team); user.setTeams(teams); pm.currentTransaction().commit(); return true; } return false; }
[ "public", "boolean", "addUserToTeam", "(", "final", "UserPrincipal", "user", ",", "final", "Team", "team", ")", "{", "List", "<", "Team", ">", "teams", "=", "user", ".", "getTeams", "(", ")", ";", "boolean", "found", "=", "false", ";", "if", "(", "team...
Associates a UserPrincipal to a Team. @param user The user to bind @param team The team to bind @return true if operation was successful, false if not. This is not an indication of team association, an unsuccessful return value may be due to the team or user not existing, or a binding that already exists between the two. @since 1.0.0
[ "Associates", "a", "UserPrincipal", "to", "a", "Team", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AlpineQueryManager.java#L393-L412
136,543
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/AlpineQueryManager.java
AlpineQueryManager.removeUserFromTeam
public boolean removeUserFromTeam(final UserPrincipal user, final Team team) { final List<Team> teams = user.getTeams(); if (teams == null) { return false; } boolean found = false; for (final Team t: teams) { if (team.getUuid().equals(t.getUuid())) { found = true; } } if (found) { pm.currentTransaction().begin(); teams.remove(team); user.setTeams(teams); pm.currentTransaction().commit(); return true; } return false; }
java
public boolean removeUserFromTeam(final UserPrincipal user, final Team team) { final List<Team> teams = user.getTeams(); if (teams == null) { return false; } boolean found = false; for (final Team t: teams) { if (team.getUuid().equals(t.getUuid())) { found = true; } } if (found) { pm.currentTransaction().begin(); teams.remove(team); user.setTeams(teams); pm.currentTransaction().commit(); return true; } return false; }
[ "public", "boolean", "removeUserFromTeam", "(", "final", "UserPrincipal", "user", ",", "final", "Team", "team", ")", "{", "final", "List", "<", "Team", ">", "teams", "=", "user", ".", "getTeams", "(", ")", ";", "if", "(", "teams", "==", "null", ")", "{...
Removes the association of a UserPrincipal to a Team. @param user The user to unbind @param team The team to unbind @return true if operation was successful, false if not. This is not an indication of team disassociation, an unsuccessful return value may be due to the team or user not existing, or a binding that may not exist. @since 1.0.0
[ "Removes", "the", "association", "of", "a", "UserPrincipal", "to", "a", "Team", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AlpineQueryManager.java#L422-L441
136,544
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/AlpineQueryManager.java
AlpineQueryManager.createPermission
public Permission createPermission(final String name, final String description) { pm.currentTransaction().begin(); final Permission permission = new Permission(); permission.setName(name); permission.setDescription(description); pm.makePersistent(permission); pm.currentTransaction().commit(); return getObjectById(Permission.class, permission.getId()); }
java
public Permission createPermission(final String name, final String description) { pm.currentTransaction().begin(); final Permission permission = new Permission(); permission.setName(name); permission.setDescription(description); pm.makePersistent(permission); pm.currentTransaction().commit(); return getObjectById(Permission.class, permission.getId()); }
[ "public", "Permission", "createPermission", "(", "final", "String", "name", ",", "final", "String", "description", ")", "{", "pm", ".", "currentTransaction", "(", ")", ".", "begin", "(", ")", ";", "final", "Permission", "permission", "=", "new", "Permission", ...
Creates a Permission object. @param name The name of the permission @param description the permissions description @return a Permission @since 1.1.0
[ "Creates", "a", "Permission", "object", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AlpineQueryManager.java#L450-L458
136,545
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/AlpineQueryManager.java
AlpineQueryManager.getPermission
@SuppressWarnings("unchecked") public Permission getPermission(final String name) { final Query query = pm.newQuery(Permission.class, "name == :name"); final List<Permission> result = (List<Permission>) query.execute(name); return Collections.isEmpty(result) ? null : result.get(0); }
java
@SuppressWarnings("unchecked") public Permission getPermission(final String name) { final Query query = pm.newQuery(Permission.class, "name == :name"); final List<Permission> result = (List<Permission>) query.execute(name); return Collections.isEmpty(result) ? null : result.get(0); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "Permission", "getPermission", "(", "final", "String", "name", ")", "{", "final", "Query", "query", "=", "pm", ".", "newQuery", "(", "Permission", ".", "class", ",", "\"name == :name\"", ")", ";", ...
Retrieves a Permission by its name. @param name The name of the permission @return a Permission @since 1.1.0
[ "Retrieves", "a", "Permission", "by", "its", "name", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AlpineQueryManager.java#L466-L471
136,546
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/AlpineQueryManager.java
AlpineQueryManager.getPermissions
@SuppressWarnings("unchecked") public List<Permission> getPermissions() { final Query query = pm.newQuery(Permission.class); query.setOrdering("name asc"); return (List<Permission>) query.execute(); }
java
@SuppressWarnings("unchecked") public List<Permission> getPermissions() { final Query query = pm.newQuery(Permission.class); query.setOrdering("name asc"); return (List<Permission>) query.execute(); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "List", "<", "Permission", ">", "getPermissions", "(", ")", "{", "final", "Query", "query", "=", "pm", ".", "newQuery", "(", "Permission", ".", "class", ")", ";", "query", ".", "setOrdering", "(...
Returns a list of all Permissions defined in the system. @return a List of Permission objects @since 1.1.0
[ "Returns", "a", "list", "of", "all", "Permissions", "defined", "in", "the", "system", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AlpineQueryManager.java#L478-L483
136,547
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/AlpineQueryManager.java
AlpineQueryManager.getEffectivePermissions
public List<Permission> getEffectivePermissions(UserPrincipal user) { final LinkedHashSet<Permission> permissions = new LinkedHashSet<>(); if (user.getPermissions() != null) { permissions.addAll(user.getPermissions()); } if (user.getTeams() != null) { for (final Team team: user.getTeams()) { final List<Permission> teamPermissions = getObjectById(Team.class, team.getId()).getPermissions(); if (teamPermissions != null) { permissions.addAll(teamPermissions); } } } return new ArrayList<>(permissions); }
java
public List<Permission> getEffectivePermissions(UserPrincipal user) { final LinkedHashSet<Permission> permissions = new LinkedHashSet<>(); if (user.getPermissions() != null) { permissions.addAll(user.getPermissions()); } if (user.getTeams() != null) { for (final Team team: user.getTeams()) { final List<Permission> teamPermissions = getObjectById(Team.class, team.getId()).getPermissions(); if (teamPermissions != null) { permissions.addAll(teamPermissions); } } } return new ArrayList<>(permissions); }
[ "public", "List", "<", "Permission", ">", "getEffectivePermissions", "(", "UserPrincipal", "user", ")", "{", "final", "LinkedHashSet", "<", "Permission", ">", "permissions", "=", "new", "LinkedHashSet", "<>", "(", ")", ";", "if", "(", "user", ".", "getPermissi...
Determines the effective permissions for the specified user by collecting a List of all permissions assigned to the user either directly, or through team membership. @param user the user to retrieve permissions for @return a List of Permission objects @since 1.1.0
[ "Determines", "the", "effective", "permissions", "for", "the", "specified", "user", "by", "collecting", "a", "List", "of", "all", "permissions", "assigned", "to", "the", "user", "either", "directly", "or", "through", "team", "membership", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AlpineQueryManager.java#L493-L507
136,548
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/AlpineQueryManager.java
AlpineQueryManager.hasPermission
public boolean hasPermission(final UserPrincipal user, String permissionName, boolean includeTeams) { Query query; if (user instanceof ManagedUser) { query = pm.newQuery(Permission.class, "name == :permissionName && managedUsers.contains(:user)"); } else { query = pm.newQuery(Permission.class, "name == :permissionName && ldapUsers.contains(:user)"); } query.setResult("count(id)"); final long count = (Long) query.execute(permissionName, user); if (count > 0) { return true; } if (includeTeams) { for (final Team team: user.getTeams()) { if (hasPermission(team, permissionName)) { return true; } } } return false; }
java
public boolean hasPermission(final UserPrincipal user, String permissionName, boolean includeTeams) { Query query; if (user instanceof ManagedUser) { query = pm.newQuery(Permission.class, "name == :permissionName && managedUsers.contains(:user)"); } else { query = pm.newQuery(Permission.class, "name == :permissionName && ldapUsers.contains(:user)"); } query.setResult("count(id)"); final long count = (Long) query.execute(permissionName, user); if (count > 0) { return true; } if (includeTeams) { for (final Team team: user.getTeams()) { if (hasPermission(team, permissionName)) { return true; } } } return false; }
[ "public", "boolean", "hasPermission", "(", "final", "UserPrincipal", "user", ",", "String", "permissionName", ",", "boolean", "includeTeams", ")", "{", "Query", "query", ";", "if", "(", "user", "instanceof", "ManagedUser", ")", "{", "query", "=", "pm", ".", ...
Determines if the specified UserPrincipal has been assigned the specified permission. @param user the UserPrincipal to query @param permissionName the name of the permission @param includeTeams if true, will query all Team membership assigned to the user for the specified permission @return true if the user has the permission assigned, false if not @since 1.0.0
[ "Determines", "if", "the", "specified", "UserPrincipal", "has", "been", "assigned", "the", "specified", "permission", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AlpineQueryManager.java#L528-L548
136,549
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/AlpineQueryManager.java
AlpineQueryManager.hasPermission
public boolean hasPermission(final Team team, String permissionName) { final Query query = pm.newQuery(Permission.class, "name == :permissionName && teams.contains(:team)"); query.setResult("count(id)"); return (Long) query.execute(permissionName, team) > 0; }
java
public boolean hasPermission(final Team team, String permissionName) { final Query query = pm.newQuery(Permission.class, "name == :permissionName && teams.contains(:team)"); query.setResult("count(id)"); return (Long) query.execute(permissionName, team) > 0; }
[ "public", "boolean", "hasPermission", "(", "final", "Team", "team", ",", "String", "permissionName", ")", "{", "final", "Query", "query", "=", "pm", ".", "newQuery", "(", "Permission", ".", "class", ",", "\"name == :permissionName && teams.contains(:team)\"", ")", ...
Determines if the specified Team has been assigned the specified permission. @param team the Team to query @param permissionName the name of the permission @return true if the team has the permission assigned, false if not @since 1.0.0
[ "Determines", "if", "the", "specified", "Team", "has", "been", "assigned", "the", "specified", "permission", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AlpineQueryManager.java#L557-L561
136,550
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/AlpineQueryManager.java
AlpineQueryManager.hasPermission
public boolean hasPermission(final ApiKey apiKey, String permissionName) { if (apiKey.getTeams() == null) { return false; } for (final Team team: apiKey.getTeams()) { final List<Permission> teamPermissions = getObjectById(Team.class, team.getId()).getPermissions(); for (final Permission permission: teamPermissions) { if (permission.getName().equals(permissionName)) { return true; } } } return false; }
java
public boolean hasPermission(final ApiKey apiKey, String permissionName) { if (apiKey.getTeams() == null) { return false; } for (final Team team: apiKey.getTeams()) { final List<Permission> teamPermissions = getObjectById(Team.class, team.getId()).getPermissions(); for (final Permission permission: teamPermissions) { if (permission.getName().equals(permissionName)) { return true; } } } return false; }
[ "public", "boolean", "hasPermission", "(", "final", "ApiKey", "apiKey", ",", "String", "permissionName", ")", "{", "if", "(", "apiKey", ".", "getTeams", "(", ")", "==", "null", ")", "{", "return", "false", ";", "}", "for", "(", "final", "Team", "team", ...
Determines if the specified ApiKey has been assigned the specified permission. @param apiKey the ApiKey to query @param permissionName the name of the permission @return true if the apiKey has the permission assigned, false if not @since 1.1.1
[ "Determines", "if", "the", "specified", "ApiKey", "has", "been", "assigned", "the", "specified", "permission", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AlpineQueryManager.java#L570-L583
136,551
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/AlpineQueryManager.java
AlpineQueryManager.getMappedLdapGroup
@SuppressWarnings("unchecked") public MappedLdapGroup getMappedLdapGroup(final Team team, final String dn) { final Query query = pm.newQuery(MappedLdapGroup.class, "team == :team && dn == :dn"); final List<MappedLdapGroup> result = (List<MappedLdapGroup>) query.execute(team, dn); return Collections.isEmpty(result) ? null : result.get(0); }
java
@SuppressWarnings("unchecked") public MappedLdapGroup getMappedLdapGroup(final Team team, final String dn) { final Query query = pm.newQuery(MappedLdapGroup.class, "team == :team && dn == :dn"); final List<MappedLdapGroup> result = (List<MappedLdapGroup>) query.execute(team, dn); return Collections.isEmpty(result) ? null : result.get(0); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "MappedLdapGroup", "getMappedLdapGroup", "(", "final", "Team", "team", ",", "final", "String", "dn", ")", "{", "final", "Query", "query", "=", "pm", ".", "newQuery", "(", "MappedLdapGroup", ".", "cl...
Retrieves a MappedLdapGroup object for the specified Team and LDAP group. @param team a Team object @param dn a String representation of Distinguished Name @return a MappedLdapGroup if found, or null if no mapping exists @since 1.4.0
[ "Retrieves", "a", "MappedLdapGroup", "object", "for", "the", "specified", "Team", "and", "LDAP", "group", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AlpineQueryManager.java#L592-L597
136,552
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/AlpineQueryManager.java
AlpineQueryManager.getMappedLdapGroups
@SuppressWarnings("unchecked") public List<MappedLdapGroup> getMappedLdapGroups(final Team team) { final Query query = pm.newQuery(MappedLdapGroup.class, "team == :team"); return (List<MappedLdapGroup>) query.execute(team); }
java
@SuppressWarnings("unchecked") public List<MappedLdapGroup> getMappedLdapGroups(final Team team) { final Query query = pm.newQuery(MappedLdapGroup.class, "team == :team"); return (List<MappedLdapGroup>) query.execute(team); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "List", "<", "MappedLdapGroup", ">", "getMappedLdapGroups", "(", "final", "Team", "team", ")", "{", "final", "Query", "query", "=", "pm", ".", "newQuery", "(", "MappedLdapGroup", ".", "class", ",", ...
Retrieves a List of MappedLdapGroup objects for the specified Team. @param team a Team object @return a List of MappedLdapGroup objects @since 1.4.0
[ "Retrieves", "a", "List", "of", "MappedLdapGroup", "objects", "for", "the", "specified", "Team", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AlpineQueryManager.java#L605-L609
136,553
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/AlpineQueryManager.java
AlpineQueryManager.getMappedLdapGroups
@SuppressWarnings("unchecked") public List<MappedLdapGroup> getMappedLdapGroups(final String dn) { final Query query = pm.newQuery(MappedLdapGroup.class, "dn == :dn"); return (List<MappedLdapGroup>) query.execute(dn); }
java
@SuppressWarnings("unchecked") public List<MappedLdapGroup> getMappedLdapGroups(final String dn) { final Query query = pm.newQuery(MappedLdapGroup.class, "dn == :dn"); return (List<MappedLdapGroup>) query.execute(dn); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "List", "<", "MappedLdapGroup", ">", "getMappedLdapGroups", "(", "final", "String", "dn", ")", "{", "final", "Query", "query", "=", "pm", ".", "newQuery", "(", "MappedLdapGroup", ".", "class", ",", ...
Retrieves a List of MappedLdapGroup objects for the specified DN. @param dn a String representation of Distinguished Name @return a List of MappedLdapGroup objects @since 1.4.0
[ "Retrieves", "a", "List", "of", "MappedLdapGroup", "objects", "for", "the", "specified", "DN", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AlpineQueryManager.java#L617-L621
136,554
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/AlpineQueryManager.java
AlpineQueryManager.createMappedLdapGroup
public MappedLdapGroup createMappedLdapGroup(final Team team, final String dn) { pm.currentTransaction().begin(); final MappedLdapGroup mapping = new MappedLdapGroup(); mapping.setTeam(team); mapping.setDn(dn); pm.makePersistent(mapping); pm.currentTransaction().commit(); return getObjectById(MappedLdapGroup.class, mapping.getId()); }
java
public MappedLdapGroup createMappedLdapGroup(final Team team, final String dn) { pm.currentTransaction().begin(); final MappedLdapGroup mapping = new MappedLdapGroup(); mapping.setTeam(team); mapping.setDn(dn); pm.makePersistent(mapping); pm.currentTransaction().commit(); return getObjectById(MappedLdapGroup.class, mapping.getId()); }
[ "public", "MappedLdapGroup", "createMappedLdapGroup", "(", "final", "Team", "team", ",", "final", "String", "dn", ")", "{", "pm", ".", "currentTransaction", "(", ")", ".", "begin", "(", ")", ";", "final", "MappedLdapGroup", "mapping", "=", "new", "MappedLdapGr...
Creates a MappedLdapGroup object. @param team The team to map @param dn the distinguished name of the LDAP group to map @return a MappedLdapGroup @since 1.4.0
[ "Creates", "a", "MappedLdapGroup", "object", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AlpineQueryManager.java#L641-L649
136,555
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/AlpineQueryManager.java
AlpineQueryManager.updateEventServiceLog
public EventServiceLog updateEventServiceLog(EventServiceLog eventServiceLog) { if (eventServiceLog != null) { final EventServiceLog log = getObjectById(EventServiceLog.class, eventServiceLog.getId()); if (log != null) { pm.currentTransaction().begin(); log.setCompleted(new Timestamp(new Date().getTime())); pm.currentTransaction().commit(); return pm.getObjectById(EventServiceLog.class, log.getId()); } } return null; }
java
public EventServiceLog updateEventServiceLog(EventServiceLog eventServiceLog) { if (eventServiceLog != null) { final EventServiceLog log = getObjectById(EventServiceLog.class, eventServiceLog.getId()); if (log != null) { pm.currentTransaction().begin(); log.setCompleted(new Timestamp(new Date().getTime())); pm.currentTransaction().commit(); return pm.getObjectById(EventServiceLog.class, log.getId()); } } return null; }
[ "public", "EventServiceLog", "updateEventServiceLog", "(", "EventServiceLog", "eventServiceLog", ")", "{", "if", "(", "eventServiceLog", "!=", "null", ")", "{", "final", "EventServiceLog", "log", "=", "getObjectById", "(", "EventServiceLog", ".", "class", ",", "even...
Updates a EventServiceLog. @param eventServiceLog the EventServiceLog to update @return an updated EventServiceLog
[ "Updates", "a", "EventServiceLog", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AlpineQueryManager.java#L677-L688
136,556
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/AlpineQueryManager.java
AlpineQueryManager.getConfigProperty
@SuppressWarnings("unchecked") public ConfigProperty getConfigProperty(final String groupName, final String propertyName) { final Query query = pm.newQuery(ConfigProperty.class, "groupName == :groupName && propertyName == :propertyName"); final List<ConfigProperty> result = (List<ConfigProperty>) query.execute(groupName, propertyName); return Collections.isEmpty(result) ? null : result.get(0); }
java
@SuppressWarnings("unchecked") public ConfigProperty getConfigProperty(final String groupName, final String propertyName) { final Query query = pm.newQuery(ConfigProperty.class, "groupName == :groupName && propertyName == :propertyName"); final List<ConfigProperty> result = (List<ConfigProperty>) query.execute(groupName, propertyName); return Collections.isEmpty(result) ? null : result.get(0); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "ConfigProperty", "getConfigProperty", "(", "final", "String", "groupName", ",", "final", "String", "propertyName", ")", "{", "final", "Query", "query", "=", "pm", ".", "newQuery", "(", "ConfigProperty"...
Returns a ConfigProperty with the specified groupName and propertyName. @param groupName the group name of the config property @param propertyName the name of the property @return a ConfigProperty object @since 1.3.0
[ "Returns", "a", "ConfigProperty", "with", "the", "specified", "groupName", "and", "propertyName", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AlpineQueryManager.java#L712-L717
136,557
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/AlpineQueryManager.java
AlpineQueryManager.getConfigProperties
@SuppressWarnings("unchecked") public List<ConfigProperty> getConfigProperties() { final Query query = pm.newQuery(ConfigProperty.class); query.setOrdering("groupName asc, propertyName asc"); return (List<ConfigProperty>) query.execute(); }
java
@SuppressWarnings("unchecked") public List<ConfigProperty> getConfigProperties() { final Query query = pm.newQuery(ConfigProperty.class); query.setOrdering("groupName asc, propertyName asc"); return (List<ConfigProperty>) query.execute(); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "List", "<", "ConfigProperty", ">", "getConfigProperties", "(", ")", "{", "final", "Query", "query", "=", "pm", ".", "newQuery", "(", "ConfigProperty", ".", "class", ")", ";", "query", ".", "setOr...
Returns a list of ConfigProperty objects. @return a List of ConfigProperty objects @since 1.3.0
[ "Returns", "a", "list", "of", "ConfigProperty", "objects", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AlpineQueryManager.java#L737-L742
136,558
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/AlpineQueryManager.java
AlpineQueryManager.createConfigProperty
public ConfigProperty createConfigProperty(final String groupName, final String propertyName, final String propertyValue, final ConfigProperty.PropertyType propertyType, final String description) { pm.currentTransaction().begin(); final ConfigProperty configProperty = new ConfigProperty(); configProperty.setGroupName(groupName); configProperty.setPropertyName(propertyName); configProperty.setPropertyValue(propertyValue); configProperty.setPropertyType(propertyType); configProperty.setDescription(description); pm.makePersistent(configProperty); pm.currentTransaction().commit(); return getObjectById(ConfigProperty.class, configProperty.getId()); }
java
public ConfigProperty createConfigProperty(final String groupName, final String propertyName, final String propertyValue, final ConfigProperty.PropertyType propertyType, final String description) { pm.currentTransaction().begin(); final ConfigProperty configProperty = new ConfigProperty(); configProperty.setGroupName(groupName); configProperty.setPropertyName(propertyName); configProperty.setPropertyValue(propertyValue); configProperty.setPropertyType(propertyType); configProperty.setDescription(description); pm.makePersistent(configProperty); pm.currentTransaction().commit(); return getObjectById(ConfigProperty.class, configProperty.getId()); }
[ "public", "ConfigProperty", "createConfigProperty", "(", "final", "String", "groupName", ",", "final", "String", "propertyName", ",", "final", "String", "propertyValue", ",", "final", "ConfigProperty", ".", "PropertyType", "propertyType", ",", "final", "String", "desc...
Creates a ConfigProperty object. @param groupName the group name of the property @param propertyName the name of the property @param propertyValue the value of the property @param propertyType the type of property @param description a description of the property @return a ConfigProperty object @since 1.3.0
[ "Creates", "a", "ConfigProperty", "object", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AlpineQueryManager.java#L754-L767
136,559
stevespringett/Alpine
alpine/src/main/java/alpine/filters/HpkpFilter.java
HpkpFilter.formatPolicy
private String formatPolicy() { final StringBuilder sb = new StringBuilder(); sb.append("pin-sha256").append("=\"").append(primaryHash).append("\"; "); sb.append("pin-sha256").append("=\"").append(backupHash).append("\"; "); sb.append("max-age").append("=").append(maxAge); if (includeSubdomains) { sb.append("; ").append("includeSubDomains"); } if (reportUri != null) { sb.append("; ").append("report-uri").append("=\"").append(reportUri).append("\""); } return sb.toString(); }
java
private String formatPolicy() { final StringBuilder sb = new StringBuilder(); sb.append("pin-sha256").append("=\"").append(primaryHash).append("\"; "); sb.append("pin-sha256").append("=\"").append(backupHash).append("\"; "); sb.append("max-age").append("=").append(maxAge); if (includeSubdomains) { sb.append("; ").append("includeSubDomains"); } if (reportUri != null) { sb.append("; ").append("report-uri").append("=\"").append(reportUri).append("\""); } return sb.toString(); }
[ "private", "String", "formatPolicy", "(", ")", "{", "final", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "\"pin-sha256\"", ")", ".", "append", "(", "\"=\\\"\"", ")", ".", "append", "(", "primaryHash", ")", ...
Formats the HPKP policy header. @return a properly formatted HPKP header
[ "Formats", "the", "HPKP", "policy", "header", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/filters/HpkpFilter.java#L134-L148
136,560
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/PaginatedResult.java
PaginatedResult.getList
@SuppressWarnings("unchecked") public <T> List<T> getList(Class<T> clazz) { return (List<T>) objects; }
java
@SuppressWarnings("unchecked") public <T> List<T> getList(Class<T> clazz) { return (List<T>) objects; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", ">", "List", "<", "T", ">", "getList", "(", "Class", "<", "T", ">", "clazz", ")", "{", "return", "(", "List", "<", "T", ">", ")", "objects", ";", "}" ]
Retrieves a List of objects from the result. @param <T> the type defined in the List @param clazz the type defined in the List @return a Collection of objects from the result. @since 1.0.0
[ "Retrieves", "a", "List", "of", "objects", "from", "the", "result", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/PaginatedResult.java#L86-L89
136,561
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/PaginatedResult.java
PaginatedResult.getSet
@SuppressWarnings("unchecked") public <T> Set<T> getSet(Class<T> clazz) { return (Set<T>) objects; }
java
@SuppressWarnings("unchecked") public <T> Set<T> getSet(Class<T> clazz) { return (Set<T>) objects; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", ">", "Set", "<", "T", ">", "getSet", "(", "Class", "<", "T", ">", "clazz", ")", "{", "return", "(", "Set", "<", "T", ">", ")", "objects", ";", "}" ]
Retrieves a Set of objects from the result. @param <T> the type defined in the Set @param clazz the type defined in the Set @return a Collection of objects from the result. @since 1.0.0
[ "Retrieves", "a", "Set", "of", "objects", "from", "the", "result", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/PaginatedResult.java#L98-L101
136,562
stevespringett/Alpine
alpine/src/main/java/alpine/persistence/PaginatedResult.java
PaginatedResult.setObjects
public void setObjects(Object object) { if (Collection.class.isAssignableFrom(object.getClass())) { this.objects = (Collection) object; } }
java
public void setObjects(Object object) { if (Collection.class.isAssignableFrom(object.getClass())) { this.objects = (Collection) object; } }
[ "public", "void", "setObjects", "(", "Object", "object", ")", "{", "if", "(", "Collection", ".", "class", ".", "isAssignableFrom", "(", "object", ".", "getClass", "(", ")", ")", ")", "{", "this", ".", "objects", "=", "(", "Collection", ")", "object", "...
Specifies a Collection of objects from the result. @param object a Collection of objects from the result. @since 1.0.0
[ "Specifies", "a", "Collection", "of", "objects", "from", "the", "result", "." ]
6c5ef5e1ba4f38922096f1307d3950c09edb3093
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/PaginatedResult.java#L128-L132
136,563
republicofgavin/PauseResumeAudioRecorder
library/src/main/java/com/github/republicofgavin/pauseresumeaudiorecorder/PauseResumeAudioRecorder.java
PauseResumeAudioRecorder.setAudioEncoding
public void setAudioEncoding(final int audioEncoding){ if (audioEncoding !=AudioFormat.ENCODING_PCM_8BIT && audioEncoding !=AudioFormat.ENCODING_PCM_16BIT){ throw new IllegalArgumentException("Invalid encoding"); } else if (currentAudioState.get()!=PREPARED_STATE && currentAudioState.get()!=INITIALIZED_STATE ){ throw new IllegalStateException("Cannot modify audio encoding during a non-prepared and non-initialized state"); } this.audioEncoding=audioEncoding; }
java
public void setAudioEncoding(final int audioEncoding){ if (audioEncoding !=AudioFormat.ENCODING_PCM_8BIT && audioEncoding !=AudioFormat.ENCODING_PCM_16BIT){ throw new IllegalArgumentException("Invalid encoding"); } else if (currentAudioState.get()!=PREPARED_STATE && currentAudioState.get()!=INITIALIZED_STATE ){ throw new IllegalStateException("Cannot modify audio encoding during a non-prepared and non-initialized state"); } this.audioEncoding=audioEncoding; }
[ "public", "void", "setAudioEncoding", "(", "final", "int", "audioEncoding", ")", "{", "if", "(", "audioEncoding", "!=", "AudioFormat", ".", "ENCODING_PCM_8BIT", "&&", "audioEncoding", "!=", "AudioFormat", ".", "ENCODING_PCM_16BIT", ")", "{", "throw", "new", "Illeg...
Sets the encoding for the audio file. @param audioEncoding Must be {@link AudioFormat}.ENCODING_PCM_8BIT or {@link AudioFormat}.ENCODING_PCM_16BIT. @throws IllegalArgumentException If the encoding is not {@link AudioFormat}.ENCODING_PCM_8BIT or {@link AudioFormat}.ENCODING_PCM_16BIT @throws IllegalStateException If it is being modified when it is not in INITIALIZED_STATE or PREPARED_STATE.
[ "Sets", "the", "encoding", "for", "the", "audio", "file", "." ]
938128a6266fb5bd7b60f844b5d7e56e1899d4e2
https://github.com/republicofgavin/PauseResumeAudioRecorder/blob/938128a6266fb5bd7b60f844b5d7e56e1899d4e2/library/src/main/java/com/github/republicofgavin/pauseresumeaudiorecorder/PauseResumeAudioRecorder.java#L143-L151
136,564
republicofgavin/PauseResumeAudioRecorder
library/src/main/java/com/github/republicofgavin/pauseresumeaudiorecorder/PauseResumeAudioRecorder.java
PauseResumeAudioRecorder.setSampleRate
public void setSampleRate(final int sampleRateInHertz){ if (sampleRateInHertz!=DEFAULT_AUDIO_SAMPLE_RATE_HERTZ && sampleRateInHertz !=22050 && sampleRateInHertz != 16000 && sampleRateInHertz !=11025){ throw new IllegalArgumentException("Invalid sample rate given"); } else if (currentAudioState.get()!=PREPARED_STATE && currentAudioState.get()!=INITIALIZED_STATE ){ throw new IllegalStateException("Recorder cannot have its sample rate changed when it is not in an initialized or prepared state"); } this.sampleRateInHertz=sampleRateInHertz; }
java
public void setSampleRate(final int sampleRateInHertz){ if (sampleRateInHertz!=DEFAULT_AUDIO_SAMPLE_RATE_HERTZ && sampleRateInHertz !=22050 && sampleRateInHertz != 16000 && sampleRateInHertz !=11025){ throw new IllegalArgumentException("Invalid sample rate given"); } else if (currentAudioState.get()!=PREPARED_STATE && currentAudioState.get()!=INITIALIZED_STATE ){ throw new IllegalStateException("Recorder cannot have its sample rate changed when it is not in an initialized or prepared state"); } this.sampleRateInHertz=sampleRateInHertz; }
[ "public", "void", "setSampleRate", "(", "final", "int", "sampleRateInHertz", ")", "{", "if", "(", "sampleRateInHertz", "!=", "DEFAULT_AUDIO_SAMPLE_RATE_HERTZ", "&&", "sampleRateInHertz", "!=", "22050", "&&", "sampleRateInHertz", "!=", "16000", "&&", "sampleRateInHertz",...
Sets the sample rate for the recording. @param sampleRateInHertz The sample rate to record the audio with. @throws IllegalArgumentException If the sample rate is not: 44100,22050,16000, or 11025 @throws IllegalStateException If the API is called while the recorder is not initialized or prepared.
[ "Sets", "the", "sample", "rate", "for", "the", "recording", "." ]
938128a6266fb5bd7b60f844b5d7e56e1899d4e2
https://github.com/republicofgavin/PauseResumeAudioRecorder/blob/938128a6266fb5bd7b60f844b5d7e56e1899d4e2/library/src/main/java/com/github/republicofgavin/pauseresumeaudiorecorder/PauseResumeAudioRecorder.java#L184-L193
136,565
republicofgavin/PauseResumeAudioRecorder
library/src/main/java/com/github/republicofgavin/pauseresumeaudiorecorder/PauseResumeAudioRecorder.java
PauseResumeAudioRecorder.setChannel
public void setChannel(final int channelConfig){ if(channelConfig != AudioFormat.CHANNEL_IN_MONO && channelConfig !=AudioFormat.CHANNEL_IN_STEREO && channelConfig != AudioFormat.CHANNEL_IN_DEFAULT){ throw new IllegalArgumentException("Invalid channel given."); } else if (currentAudioState.get()!=PREPARED_STATE && currentAudioState.get()!=INITIALIZED_STATE ){ throw new IllegalStateException("Recorder cannot have its file changed when it is in an initialized or prepared state"); } this.channelConfig=channelConfig; }
java
public void setChannel(final int channelConfig){ if(channelConfig != AudioFormat.CHANNEL_IN_MONO && channelConfig !=AudioFormat.CHANNEL_IN_STEREO && channelConfig != AudioFormat.CHANNEL_IN_DEFAULT){ throw new IllegalArgumentException("Invalid channel given."); } else if (currentAudioState.get()!=PREPARED_STATE && currentAudioState.get()!=INITIALIZED_STATE ){ throw new IllegalStateException("Recorder cannot have its file changed when it is in an initialized or prepared state"); } this.channelConfig=channelConfig; }
[ "public", "void", "setChannel", "(", "final", "int", "channelConfig", ")", "{", "if", "(", "channelConfig", "!=", "AudioFormat", ".", "CHANNEL_IN_MONO", "&&", "channelConfig", "!=", "AudioFormat", ".", "CHANNEL_IN_STEREO", "&&", "channelConfig", "!=", "AudioFormat",...
Sets the channel. @param channelConfig {@link AudioFormat}.CHANNEL_IN_MONO, {@link AudioFormat}.CHANNEL_IN_DEFAULT, or {@link AudioFormat}.CHANNEL_IN_STEREO @throws IllegalArgumentException if it is not Mono or Stereo. @throws IllegalStateException If the channel is changed when it is not in a prepared or initialized state.
[ "Sets", "the", "channel", "." ]
938128a6266fb5bd7b60f844b5d7e56e1899d4e2
https://github.com/republicofgavin/PauseResumeAudioRecorder/blob/938128a6266fb5bd7b60f844b5d7e56e1899d4e2/library/src/main/java/com/github/republicofgavin/pauseresumeaudiorecorder/PauseResumeAudioRecorder.java#L201-L209
136,566
republicofgavin/PauseResumeAudioRecorder
library/src/main/java/com/github/republicofgavin/pauseresumeaudiorecorder/PauseResumeAudioRecorder.java
PauseResumeAudioRecorder.pauseRecording
public void pauseRecording(){ if (currentAudioState.get()==RECORDING_STATE){ currentAudioState.getAndSet(PAUSED_STATE); onTimeCompletedTimer.cancel(); remainingMaxTimeInMillis=remainingMaxTimeInMillis-(System.currentTimeMillis()-recordingStartTimeMillis); } else{ Log.w(TAG,"Audio recording is not recording"); } }
java
public void pauseRecording(){ if (currentAudioState.get()==RECORDING_STATE){ currentAudioState.getAndSet(PAUSED_STATE); onTimeCompletedTimer.cancel(); remainingMaxTimeInMillis=remainingMaxTimeInMillis-(System.currentTimeMillis()-recordingStartTimeMillis); } else{ Log.w(TAG,"Audio recording is not recording"); } }
[ "public", "void", "pauseRecording", "(", ")", "{", "if", "(", "currentAudioState", ".", "get", "(", ")", "==", "RECORDING_STATE", ")", "{", "currentAudioState", ".", "getAndSet", "(", "PAUSED_STATE", ")", ";", "onTimeCompletedTimer", ".", "cancel", "(", ")", ...
Pauses the recording if the recorder is in a recording state. Does nothing if in another state. Paused media recorder halts the max time countdown.
[ "Pauses", "the", "recording", "if", "the", "recorder", "is", "in", "a", "recording", "state", ".", "Does", "nothing", "if", "in", "another", "state", ".", "Paused", "media", "recorder", "halts", "the", "max", "time", "countdown", "." ]
938128a6266fb5bd7b60f844b5d7e56e1899d4e2
https://github.com/republicofgavin/PauseResumeAudioRecorder/blob/938128a6266fb5bd7b60f844b5d7e56e1899d4e2/library/src/main/java/com/github/republicofgavin/pauseresumeaudiorecorder/PauseResumeAudioRecorder.java#L242-L251
136,567
republicofgavin/PauseResumeAudioRecorder
library/src/main/java/com/github/republicofgavin/pauseresumeaudiorecorder/PauseResumeAudioRecorder.java
PauseResumeAudioRecorder.resumeRecording
public void resumeRecording(){ if (currentAudioState.get()==PAUSED_STATE){ recordingStartTimeMillis=System.currentTimeMillis(); currentAudioState.getAndSet(RECORDING_STATE); onTimeCompletedTimer=new Timer(true); onTimeCompletionTimerTask=new MaxTimeTimerTask(); onTimeCompletedTimer.schedule(onTimeCompletionTimerTask,remainingMaxTimeInMillis); } else { Log.w(TAG,"Audio recording is not paused"); } }
java
public void resumeRecording(){ if (currentAudioState.get()==PAUSED_STATE){ recordingStartTimeMillis=System.currentTimeMillis(); currentAudioState.getAndSet(RECORDING_STATE); onTimeCompletedTimer=new Timer(true); onTimeCompletionTimerTask=new MaxTimeTimerTask(); onTimeCompletedTimer.schedule(onTimeCompletionTimerTask,remainingMaxTimeInMillis); } else { Log.w(TAG,"Audio recording is not paused"); } }
[ "public", "void", "resumeRecording", "(", ")", "{", "if", "(", "currentAudioState", ".", "get", "(", ")", "==", "PAUSED_STATE", ")", "{", "recordingStartTimeMillis", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "currentAudioState", ".", "getAndSet", ...
Resumes the audio recording. Does nothing if the recorder is in a non-recording state.
[ "Resumes", "the", "audio", "recording", ".", "Does", "nothing", "if", "the", "recorder", "is", "in", "a", "non", "-", "recording", "state", "." ]
938128a6266fb5bd7b60f844b5d7e56e1899d4e2
https://github.com/republicofgavin/PauseResumeAudioRecorder/blob/938128a6266fb5bd7b60f844b5d7e56e1899d4e2/library/src/main/java/com/github/republicofgavin/pauseresumeaudiorecorder/PauseResumeAudioRecorder.java#L256-L267
136,568
republicofgavin/PauseResumeAudioRecorder
library/src/main/java/com/github/republicofgavin/pauseresumeaudiorecorder/PauseResumeAudioRecorder.java
PauseResumeAudioRecorder.stopRecording
public void stopRecording(){ if (currentAudioState.get()== PAUSED_STATE || currentAudioState.get()==RECORDING_STATE){ currentAudioState.getAndSet(STOPPED_STATE); onTimeCompletedTimer.cancel(); onTimeCompletedTimer=null; onTimeCompletionTimerTask=null; } else{ Log.w(TAG,"Audio recording is not in a paused or recording state."); } currentAudioRecordingThread=null;//The existing thread will die out on its own, but not before attempting to convert the file into WAV format. }
java
public void stopRecording(){ if (currentAudioState.get()== PAUSED_STATE || currentAudioState.get()==RECORDING_STATE){ currentAudioState.getAndSet(STOPPED_STATE); onTimeCompletedTimer.cancel(); onTimeCompletedTimer=null; onTimeCompletionTimerTask=null; } else{ Log.w(TAG,"Audio recording is not in a paused or recording state."); } currentAudioRecordingThread=null;//The existing thread will die out on its own, but not before attempting to convert the file into WAV format. }
[ "public", "void", "stopRecording", "(", ")", "{", "if", "(", "currentAudioState", ".", "get", "(", ")", "==", "PAUSED_STATE", "||", "currentAudioState", ".", "get", "(", ")", "==", "RECORDING_STATE", ")", "{", "currentAudioState", ".", "getAndSet", "(", "STO...
Stops the audio recording if it is in a paused or recording state. Does nothing if the recorder is already stopped. @throws IllegalStateException If the recorder is not in a paused, recording, or stopped state.
[ "Stops", "the", "audio", "recording", "if", "it", "is", "in", "a", "paused", "or", "recording", "state", ".", "Does", "nothing", "if", "the", "recorder", "is", "already", "stopped", "." ]
938128a6266fb5bd7b60f844b5d7e56e1899d4e2
https://github.com/republicofgavin/PauseResumeAudioRecorder/blob/938128a6266fb5bd7b60f844b5d7e56e1899d4e2/library/src/main/java/com/github/republicofgavin/pauseresumeaudiorecorder/PauseResumeAudioRecorder.java#L273-L284
136,569
buschmais/jqa-java-plugin
src/main/java/com/buschmais/jqassistant/plugin/java/impl/scanner/visitor/AbstractAnnotationVisitor.java
AbstractAnnotationVisitor.createValue
private <T extends ValueDescriptor<?>> T createValue(Class<T> type, String name) { if (name != null) { this.arrayValueDescriptor = null; } String valueName; if (arrayValueDescriptor != null) { valueName = "[" + getArrayValue().size() + "]"; } else { valueName = name; } T valueDescriptor = visitorHelper.getValueDescriptor(type); valueDescriptor.setName(valueName); return valueDescriptor; }
java
private <T extends ValueDescriptor<?>> T createValue(Class<T> type, String name) { if (name != null) { this.arrayValueDescriptor = null; } String valueName; if (arrayValueDescriptor != null) { valueName = "[" + getArrayValue().size() + "]"; } else { valueName = name; } T valueDescriptor = visitorHelper.getValueDescriptor(type); valueDescriptor.setName(valueName); return valueDescriptor; }
[ "private", "<", "T", "extends", "ValueDescriptor", "<", "?", ">", ">", "T", "createValue", "(", "Class", "<", "T", ">", "type", ",", "String", "name", ")", "{", "if", "(", "name", "!=", "null", ")", "{", "this", ".", "arrayValueDescriptor", "=", "nul...
Create a value descriptor of given type and name and initializes it. @param type The class type. @param name The name @param <T> The type. @return The initialized descriptor.
[ "Create", "a", "value", "descriptor", "of", "given", "type", "and", "name", "and", "initializes", "it", "." ]
4c050943e9c28cf1c4a08aa962d5b5bf03c4fe54
https://github.com/buschmais/jqa-java-plugin/blob/4c050943e9c28cf1c4a08aa962d5b5bf03c4fe54/src/main/java/com/buschmais/jqassistant/plugin/java/impl/scanner/visitor/AbstractAnnotationVisitor.java#L98-L111
136,570
buschmais/jqa-java-plugin
src/main/java/com/buschmais/jqassistant/plugin/java/impl/scanner/visitor/AbstractAnnotationVisitor.java
AbstractAnnotationVisitor.addValue
private void addValue(String name, ValueDescriptor<?> value) { if (arrayValueDescriptor != null && name == null) { getArrayValue().add(value); } else { setValue(descriptor, value); } }
java
private void addValue(String name, ValueDescriptor<?> value) { if (arrayValueDescriptor != null && name == null) { getArrayValue().add(value); } else { setValue(descriptor, value); } }
[ "private", "void", "addValue", "(", "String", "name", ",", "ValueDescriptor", "<", "?", ">", "value", ")", "{", "if", "(", "arrayValueDescriptor", "!=", "null", "&&", "name", "==", "null", ")", "{", "getArrayValue", "(", ")", ".", "add", "(", "value", ...
Add the descriptor as value to the current annotation or array value. @param name The name. @param value The value.
[ "Add", "the", "descriptor", "as", "value", "to", "the", "current", "annotation", "or", "array", "value", "." ]
4c050943e9c28cf1c4a08aa962d5b5bf03c4fe54
https://github.com/buschmais/jqa-java-plugin/blob/4c050943e9c28cf1c4a08aa962d5b5bf03c4fe54/src/main/java/com/buschmais/jqassistant/plugin/java/impl/scanner/visitor/AbstractAnnotationVisitor.java#L121-L127
136,571
buschmais/jqa-java-plugin
src/main/java/com/buschmais/jqassistant/plugin/java/impl/scanner/visitor/AbstractAnnotationVisitor.java
AbstractAnnotationVisitor.getArrayValue
private List<ValueDescriptor<?>> getArrayValue() { List<ValueDescriptor<?>> values = arrayValueDescriptor.getValue(); if (values == null) { values = new LinkedList<>(); arrayValueDescriptor.setValue(values); } return values; }
java
private List<ValueDescriptor<?>> getArrayValue() { List<ValueDescriptor<?>> values = arrayValueDescriptor.getValue(); if (values == null) { values = new LinkedList<>(); arrayValueDescriptor.setValue(values); } return values; }
[ "private", "List", "<", "ValueDescriptor", "<", "?", ">", ">", "getArrayValue", "(", ")", "{", "List", "<", "ValueDescriptor", "<", "?", ">", ">", "values", "=", "arrayValueDescriptor", ".", "getValue", "(", ")", ";", "if", "(", "values", "==", "null", ...
Get the array of referenced values. @return The array of referenced values.
[ "Get", "the", "array", "of", "referenced", "values", "." ]
4c050943e9c28cf1c4a08aa962d5b5bf03c4fe54
https://github.com/buschmais/jqa-java-plugin/blob/4c050943e9c28cf1c4a08aa962d5b5bf03c4fe54/src/main/java/com/buschmais/jqassistant/plugin/java/impl/scanner/visitor/AbstractAnnotationVisitor.java#L134-L141
136,572
buschmais/jqa-java-plugin
src/main/java/com/buschmais/jqassistant/plugin/java/api/scanner/SignatureHelper.java
SignatureHelper.getType
public static String getType(final Type t) { switch (t.getSort()) { case Type.ARRAY: return getType(t.getElementType()); default: return t.getClassName(); } }
java
public static String getType(final Type t) { switch (t.getSort()) { case Type.ARRAY: return getType(t.getElementType()); default: return t.getClassName(); } }
[ "public", "static", "String", "getType", "(", "final", "Type", "t", ")", "{", "switch", "(", "t", ".", "getSort", "(", ")", ")", "{", "case", "Type", ".", "ARRAY", ":", "return", "getType", "(", "t", ".", "getElementType", "(", ")", ")", ";", "defa...
Return the type name of the given ASM type. @param t The ASM type. @return The type name.
[ "Return", "the", "type", "name", "of", "the", "given", "ASM", "type", "." ]
4c050943e9c28cf1c4a08aa962d5b5bf03c4fe54
https://github.com/buschmais/jqa-java-plugin/blob/4c050943e9c28cf1c4a08aa962d5b5bf03c4fe54/src/main/java/com/buschmais/jqassistant/plugin/java/api/scanner/SignatureHelper.java#L46-L53
136,573
buschmais/jqa-java-plugin
src/main/java/com/buschmais/jqassistant/plugin/java/api/scanner/SignatureHelper.java
SignatureHelper.getMethodSignature
public static String getMethodSignature(String name, String rawSignature) { StringBuilder signature = new StringBuilder(); String returnType = org.objectweb.asm.Type.getReturnType(rawSignature).getClassName(); if (returnType != null) { signature.append(returnType); signature.append(' '); } signature.append(name); signature.append('('); org.objectweb.asm.Type[] types = org.objectweb.asm.Type.getArgumentTypes(rawSignature); for (int i = 0; i < types.length; i++) { if (i > 0) { signature.append(','); } signature.append(types[i].getClassName()); } signature.append(')'); return signature.toString(); }
java
public static String getMethodSignature(String name, String rawSignature) { StringBuilder signature = new StringBuilder(); String returnType = org.objectweb.asm.Type.getReturnType(rawSignature).getClassName(); if (returnType != null) { signature.append(returnType); signature.append(' '); } signature.append(name); signature.append('('); org.objectweb.asm.Type[] types = org.objectweb.asm.Type.getArgumentTypes(rawSignature); for (int i = 0; i < types.length; i++) { if (i > 0) { signature.append(','); } signature.append(types[i].getClassName()); } signature.append(')'); return signature.toString(); }
[ "public", "static", "String", "getMethodSignature", "(", "String", "name", ",", "String", "rawSignature", ")", "{", "StringBuilder", "signature", "=", "new", "StringBuilder", "(", ")", ";", "String", "returnType", "=", "org", ".", "objectweb", ".", "asm", ".",...
Return a method signature. @param name The method name. @param rawSignature The signature containing parameter, return and exception values. @return The method signature.
[ "Return", "a", "method", "signature", "." ]
4c050943e9c28cf1c4a08aa962d5b5bf03c4fe54
https://github.com/buschmais/jqa-java-plugin/blob/4c050943e9c28cf1c4a08aa962d5b5bf03c4fe54/src/main/java/com/buschmais/jqassistant/plugin/java/api/scanner/SignatureHelper.java#L65-L83
136,574
buschmais/jqa-java-plugin
src/main/java/com/buschmais/jqassistant/plugin/java/api/scanner/SignatureHelper.java
SignatureHelper.getFieldSignature
public static String getFieldSignature(String name, String rawSignature) { StringBuilder signature = new StringBuilder(); String returnType = org.objectweb.asm.Type.getType(rawSignature).getClassName(); signature.append(returnType); signature.append(' '); signature.append(name); return signature.toString(); }
java
public static String getFieldSignature(String name, String rawSignature) { StringBuilder signature = new StringBuilder(); String returnType = org.objectweb.asm.Type.getType(rawSignature).getClassName(); signature.append(returnType); signature.append(' '); signature.append(name); return signature.toString(); }
[ "public", "static", "String", "getFieldSignature", "(", "String", "name", ",", "String", "rawSignature", ")", "{", "StringBuilder", "signature", "=", "new", "StringBuilder", "(", ")", ";", "String", "returnType", "=", "org", ".", "objectweb", ".", "asm", ".", ...
Return a field signature. @param name The field name. @param rawSignature The signature containing the type value. @return The field signature.
[ "Return", "a", "field", "signature", "." ]
4c050943e9c28cf1c4a08aa962d5b5bf03c4fe54
https://github.com/buschmais/jqa-java-plugin/blob/4c050943e9c28cf1c4a08aa962d5b5bf03c4fe54/src/main/java/com/buschmais/jqassistant/plugin/java/api/scanner/SignatureHelper.java#L94-L101
136,575
buschmais/jqa-java-plugin
src/main/java/com/buschmais/jqassistant/plugin/java/impl/scanner/visitor/VisitorHelper.java
VisitorHelper.getMethodDescriptor
MethodDescriptor getMethodDescriptor(TypeCache.CachedType<?> cachedType, String signature) { MethodDescriptor methodDescriptor = cachedType.getMethod(signature); if (methodDescriptor == null) { if (signature.startsWith(CONSTRUCTOR_METHOD)) { methodDescriptor = scannerContext.getStore().create(ConstructorDescriptor.class); } else { methodDescriptor = scannerContext.getStore().create(MethodDescriptor.class); } methodDescriptor.setSignature(signature); cachedType.addMember(signature, methodDescriptor); } return methodDescriptor; }
java
MethodDescriptor getMethodDescriptor(TypeCache.CachedType<?> cachedType, String signature) { MethodDescriptor methodDescriptor = cachedType.getMethod(signature); if (methodDescriptor == null) { if (signature.startsWith(CONSTRUCTOR_METHOD)) { methodDescriptor = scannerContext.getStore().create(ConstructorDescriptor.class); } else { methodDescriptor = scannerContext.getStore().create(MethodDescriptor.class); } methodDescriptor.setSignature(signature); cachedType.addMember(signature, methodDescriptor); } return methodDescriptor; }
[ "MethodDescriptor", "getMethodDescriptor", "(", "TypeCache", ".", "CachedType", "<", "?", ">", "cachedType", ",", "String", "signature", ")", "{", "MethodDescriptor", "methodDescriptor", "=", "cachedType", ".", "getMethod", "(", "signature", ")", ";", "if", "(", ...
Return the method descriptor for the given type and method signature. @param cachedType The containing type. @param signature The method signature. @return The method descriptor.
[ "Return", "the", "method", "descriptor", "for", "the", "given", "type", "and", "method", "signature", "." ]
4c050943e9c28cf1c4a08aa962d5b5bf03c4fe54
https://github.com/buschmais/jqa-java-plugin/blob/4c050943e9c28cf1c4a08aa962d5b5bf03c4fe54/src/main/java/com/buschmais/jqassistant/plugin/java/impl/scanner/visitor/VisitorHelper.java#L96-L108
136,576
buschmais/jqa-java-plugin
src/main/java/com/buschmais/jqassistant/plugin/java/impl/scanner/visitor/VisitorHelper.java
VisitorHelper.addInvokes
void addInvokes(MethodDescriptor methodDescriptor, final Integer lineNumber, MethodDescriptor invokedMethodDescriptor) { InvokesDescriptor invokesDescriptor = scannerContext.getStore().create(methodDescriptor, InvokesDescriptor.class, invokedMethodDescriptor); invokesDescriptor.setLineNumber(lineNumber); }
java
void addInvokes(MethodDescriptor methodDescriptor, final Integer lineNumber, MethodDescriptor invokedMethodDescriptor) { InvokesDescriptor invokesDescriptor = scannerContext.getStore().create(methodDescriptor, InvokesDescriptor.class, invokedMethodDescriptor); invokesDescriptor.setLineNumber(lineNumber); }
[ "void", "addInvokes", "(", "MethodDescriptor", "methodDescriptor", ",", "final", "Integer", "lineNumber", ",", "MethodDescriptor", "invokedMethodDescriptor", ")", "{", "InvokesDescriptor", "invokesDescriptor", "=", "scannerContext", ".", "getStore", "(", ")", ".", "crea...
Add a invokes relation between two methods. @param methodDescriptor The invoking method. @param lineNumber The line number. @param invokedMethodDescriptor The invoked method.
[ "Add", "a", "invokes", "relation", "between", "two", "methods", "." ]
4c050943e9c28cf1c4a08aa962d5b5bf03c4fe54
https://github.com/buschmais/jqa-java-plugin/blob/4c050943e9c28cf1c4a08aa962d5b5bf03c4fe54/src/main/java/com/buschmais/jqassistant/plugin/java/impl/scanner/visitor/VisitorHelper.java#L136-L139
136,577
buschmais/jqa-java-plugin
src/main/java/com/buschmais/jqassistant/plugin/java/impl/scanner/visitor/VisitorHelper.java
VisitorHelper.addReads
void addReads(MethodDescriptor methodDescriptor, final Integer lineNumber, FieldDescriptor fieldDescriptor) { ReadsDescriptor readsDescriptor = scannerContext.getStore().create(methodDescriptor, ReadsDescriptor.class, fieldDescriptor); readsDescriptor.setLineNumber(lineNumber); }
java
void addReads(MethodDescriptor methodDescriptor, final Integer lineNumber, FieldDescriptor fieldDescriptor) { ReadsDescriptor readsDescriptor = scannerContext.getStore().create(methodDescriptor, ReadsDescriptor.class, fieldDescriptor); readsDescriptor.setLineNumber(lineNumber); }
[ "void", "addReads", "(", "MethodDescriptor", "methodDescriptor", ",", "final", "Integer", "lineNumber", ",", "FieldDescriptor", "fieldDescriptor", ")", "{", "ReadsDescriptor", "readsDescriptor", "=", "scannerContext", ".", "getStore", "(", ")", ".", "create", "(", "...
Add a reads relation between a method and a field. @param methodDescriptor The method. @param lineNumber The line number. @param fieldDescriptor The field.
[ "Add", "a", "reads", "relation", "between", "a", "method", "and", "a", "field", "." ]
4c050943e9c28cf1c4a08aa962d5b5bf03c4fe54
https://github.com/buschmais/jqa-java-plugin/blob/4c050943e9c28cf1c4a08aa962d5b5bf03c4fe54/src/main/java/com/buschmais/jqassistant/plugin/java/impl/scanner/visitor/VisitorHelper.java#L151-L154
136,578
buschmais/jqa-java-plugin
src/main/java/com/buschmais/jqassistant/plugin/java/impl/scanner/visitor/VisitorHelper.java
VisitorHelper.addWrites
void addWrites(MethodDescriptor methodDescriptor, final Integer lineNumber, FieldDescriptor fieldDescriptor) { WritesDescriptor writesDescriptor = scannerContext.getStore().create(methodDescriptor, WritesDescriptor.class, fieldDescriptor); writesDescriptor.setLineNumber(lineNumber); }
java
void addWrites(MethodDescriptor methodDescriptor, final Integer lineNumber, FieldDescriptor fieldDescriptor) { WritesDescriptor writesDescriptor = scannerContext.getStore().create(methodDescriptor, WritesDescriptor.class, fieldDescriptor); writesDescriptor.setLineNumber(lineNumber); }
[ "void", "addWrites", "(", "MethodDescriptor", "methodDescriptor", ",", "final", "Integer", "lineNumber", ",", "FieldDescriptor", "fieldDescriptor", ")", "{", "WritesDescriptor", "writesDescriptor", "=", "scannerContext", ".", "getStore", "(", ")", ".", "create", "(", ...
Add a writes relation between a method and a field. @param methodDescriptor The method. @param lineNumber The line number. @param fieldDescriptor The field.
[ "Add", "a", "writes", "relation", "between", "a", "method", "and", "a", "field", "." ]
4c050943e9c28cf1c4a08aa962d5b5bf03c4fe54
https://github.com/buschmais/jqa-java-plugin/blob/4c050943e9c28cf1c4a08aa962d5b5bf03c4fe54/src/main/java/com/buschmais/jqassistant/plugin/java/impl/scanner/visitor/VisitorHelper.java#L166-L169
136,579
buschmais/jqa-java-plugin
src/main/java/com/buschmais/jqassistant/plugin/java/impl/scanner/visitor/VisitorHelper.java
VisitorHelper.addAnnotation
AnnotationVisitor addAnnotation(TypeCache.CachedType containingDescriptor, AnnotatedDescriptor annotatedDescriptor, String typeName) { if (typeName == null) { return null; } if (jQASuppress.class.getName().equals(typeName)) { JavaSuppressDescriptor javaSuppressDescriptor = scannerContext.getStore().addDescriptorType(annotatedDescriptor, JavaSuppressDescriptor.class); return new SuppressAnnotationVisitor(javaSuppressDescriptor); } TypeDescriptor type = resolveType(typeName, containingDescriptor).getTypeDescriptor(); AnnotationValueDescriptor annotationDescriptor = scannerContext.getStore().create(AnnotationValueDescriptor.class); annotationDescriptor.setType(type); annotatedDescriptor.getAnnotatedBy().add(annotationDescriptor); return new AnnotationValueVisitor(containingDescriptor, annotationDescriptor, this); }
java
AnnotationVisitor addAnnotation(TypeCache.CachedType containingDescriptor, AnnotatedDescriptor annotatedDescriptor, String typeName) { if (typeName == null) { return null; } if (jQASuppress.class.getName().equals(typeName)) { JavaSuppressDescriptor javaSuppressDescriptor = scannerContext.getStore().addDescriptorType(annotatedDescriptor, JavaSuppressDescriptor.class); return new SuppressAnnotationVisitor(javaSuppressDescriptor); } TypeDescriptor type = resolveType(typeName, containingDescriptor).getTypeDescriptor(); AnnotationValueDescriptor annotationDescriptor = scannerContext.getStore().create(AnnotationValueDescriptor.class); annotationDescriptor.setType(type); annotatedDescriptor.getAnnotatedBy().add(annotationDescriptor); return new AnnotationValueVisitor(containingDescriptor, annotationDescriptor, this); }
[ "AnnotationVisitor", "addAnnotation", "(", "TypeCache", ".", "CachedType", "containingDescriptor", ",", "AnnotatedDescriptor", "annotatedDescriptor", ",", "String", "typeName", ")", "{", "if", "(", "typeName", "==", "null", ")", "{", "return", "null", ";", "}", "i...
Add an annotation descriptor of the given type name to an annotated descriptor. @param annotatedDescriptor The annotated descriptor. @param typeName The type name of the annotation. @return The annotation descriptor.
[ "Add", "an", "annotation", "descriptor", "of", "the", "given", "type", "name", "to", "an", "annotated", "descriptor", "." ]
4c050943e9c28cf1c4a08aa962d5b5bf03c4fe54
https://github.com/buschmais/jqa-java-plugin/blob/4c050943e9c28cf1c4a08aa962d5b5bf03c4fe54/src/main/java/com/buschmais/jqassistant/plugin/java/impl/scanner/visitor/VisitorHelper.java#L229-L242
136,580
buschmais/jqa-java-plugin
src/main/java/com/buschmais/jqassistant/plugin/java/api/scanner/TypeCache.java
TypeCache.get
public CachedType get(String fullQualifiedName) { CachedType cachedType = lruCache.getIfPresent(fullQualifiedName); if (cachedType != null) { return cachedType; } cachedType = softCache.getIfPresent(fullQualifiedName); if (cachedType != null) { lruCache.put(fullQualifiedName, cachedType); } return cachedType; }
java
public CachedType get(String fullQualifiedName) { CachedType cachedType = lruCache.getIfPresent(fullQualifiedName); if (cachedType != null) { return cachedType; } cachedType = softCache.getIfPresent(fullQualifiedName); if (cachedType != null) { lruCache.put(fullQualifiedName, cachedType); } return cachedType; }
[ "public", "CachedType", "get", "(", "String", "fullQualifiedName", ")", "{", "CachedType", "cachedType", "=", "lruCache", ".", "getIfPresent", "(", "fullQualifiedName", ")", ";", "if", "(", "cachedType", "!=", "null", ")", "{", "return", "cachedType", ";", "}"...
Find a type by its fully qualified named. @param fullQualifiedName The fqn. @return The cached type or <code>null</code>.
[ "Find", "a", "type", "by", "its", "fully", "qualified", "named", "." ]
4c050943e9c28cf1c4a08aa962d5b5bf03c4fe54
https://github.com/buschmais/jqa-java-plugin/blob/4c050943e9c28cf1c4a08aa962d5b5bf03c4fe54/src/main/java/com/buschmais/jqassistant/plugin/java/api/scanner/TypeCache.java#L41-L51
136,581
buschmais/jqa-java-plugin
src/main/java/com/buschmais/jqassistant/plugin/java/impl/scanner/visitor/ClassVisitor.java
ClassVisitor.getVisibility
private VisibilityModifier getVisibility(int flags) { if (hasFlag(flags, Opcodes.ACC_PRIVATE)) { return VisibilityModifier.PRIVATE; } else if (hasFlag(flags, Opcodes.ACC_PROTECTED)) { return VisibilityModifier.PROTECTED; } else if (hasFlag(flags, Opcodes.ACC_PUBLIC)) { return VisibilityModifier.PUBLIC; } else { return VisibilityModifier.DEFAULT; } }
java
private VisibilityModifier getVisibility(int flags) { if (hasFlag(flags, Opcodes.ACC_PRIVATE)) { return VisibilityModifier.PRIVATE; } else if (hasFlag(flags, Opcodes.ACC_PROTECTED)) { return VisibilityModifier.PROTECTED; } else if (hasFlag(flags, Opcodes.ACC_PUBLIC)) { return VisibilityModifier.PUBLIC; } else { return VisibilityModifier.DEFAULT; } }
[ "private", "VisibilityModifier", "getVisibility", "(", "int", "flags", ")", "{", "if", "(", "hasFlag", "(", "flags", ",", "Opcodes", ".", "ACC_PRIVATE", ")", ")", "{", "return", "VisibilityModifier", ".", "PRIVATE", ";", "}", "else", "if", "(", "hasFlag", ...
Returns the AccessModifier for the flag pattern. @param flags the flags @return the AccessModifier
[ "Returns", "the", "AccessModifier", "for", "the", "flag", "pattern", "." ]
4c050943e9c28cf1c4a08aa962d5b5bf03c4fe54
https://github.com/buschmais/jqa-java-plugin/blob/4c050943e9c28cf1c4a08aa962d5b5bf03c4fe54/src/main/java/com/buschmais/jqassistant/plugin/java/impl/scanner/visitor/ClassVisitor.java#L243-L253
136,582
buschmais/jqa-java-plugin
src/main/java/com/buschmais/jqassistant/plugin/java/impl/scanner/visitor/ClassVisitor.java
ClassVisitor.getJavaType
private Class<? extends ClassFileDescriptor> getJavaType(int flags) { if (hasFlag(flags, Opcodes.ACC_ANNOTATION)) { return AnnotationTypeDescriptor.class; } else if (hasFlag(flags, Opcodes.ACC_ENUM)) { return EnumTypeDescriptor.class; } else if (hasFlag(flags, Opcodes.ACC_INTERFACE)) { return InterfaceTypeDescriptor.class; } return ClassTypeDescriptor.class; }
java
private Class<? extends ClassFileDescriptor> getJavaType(int flags) { if (hasFlag(flags, Opcodes.ACC_ANNOTATION)) { return AnnotationTypeDescriptor.class; } else if (hasFlag(flags, Opcodes.ACC_ENUM)) { return EnumTypeDescriptor.class; } else if (hasFlag(flags, Opcodes.ACC_INTERFACE)) { return InterfaceTypeDescriptor.class; } return ClassTypeDescriptor.class; }
[ "private", "Class", "<", "?", "extends", "ClassFileDescriptor", ">", "getJavaType", "(", "int", "flags", ")", "{", "if", "(", "hasFlag", "(", "flags", ",", "Opcodes", ".", "ACC_ANNOTATION", ")", ")", "{", "return", "AnnotationTypeDescriptor", ".", "class", "...
Determine the types label to be applied to a class node. @param flags The access flags. @return The types label.
[ "Determine", "the", "types", "label", "to", "be", "applied", "to", "a", "class", "node", "." ]
4c050943e9c28cf1c4a08aa962d5b5bf03c4fe54
https://github.com/buschmais/jqa-java-plugin/blob/4c050943e9c28cf1c4a08aa962d5b5bf03c4fe54/src/main/java/com/buschmais/jqassistant/plugin/java/impl/scanner/visitor/ClassVisitor.java#L262-L271
136,583
jankroken/commandline
src/main/java/com/github/jankroken/commandline/domain/internal/LongOrCompactTokenizer.java
LongOrCompactTokenizer.peek
public Token peek() { if (!splitTokens.isEmpty()) { return splitTokens.peek(); } final var value = stringIterator.peek(); if (argumentEscapeEncountered) { return new ArgumentToken(value); } if (Objects.equals(value, argumentTerminator)) { return new ArgumentToken(value); } if (argumentTerminator != null) { return new ArgumentToken(value); } if (isArgumentEscape(value)) { argumentEscapeEncountered = true; return peek(); } if (isSwitch(value)) { if (isShortSwitchList(value)) { var tokens = splitSwitchTokens(value); return tokens.get(0); } else { return new SwitchToken(value.substring(2), value); } } else { return new ArgumentToken(value); } }
java
public Token peek() { if (!splitTokens.isEmpty()) { return splitTokens.peek(); } final var value = stringIterator.peek(); if (argumentEscapeEncountered) { return new ArgumentToken(value); } if (Objects.equals(value, argumentTerminator)) { return new ArgumentToken(value); } if (argumentTerminator != null) { return new ArgumentToken(value); } if (isArgumentEscape(value)) { argumentEscapeEncountered = true; return peek(); } if (isSwitch(value)) { if (isShortSwitchList(value)) { var tokens = splitSwitchTokens(value); return tokens.get(0); } else { return new SwitchToken(value.substring(2), value); } } else { return new ArgumentToken(value); } }
[ "public", "Token", "peek", "(", ")", "{", "if", "(", "!", "splitTokens", ".", "isEmpty", "(", ")", ")", "{", "return", "splitTokens", ".", "peek", "(", ")", ";", "}", "final", "var", "value", "=", "stringIterator", ".", "peek", "(", ")", ";", "if",...
this is a mess - need to be cleaned up
[ "this", "is", "a", "mess", "-", "need", "to", "be", "cleaned", "up" ]
6c0c11dbd102974f05f175ddfe1cba7fbb0cf341
https://github.com/jankroken/commandline/blob/6c0c11dbd102974f05f175ddfe1cba7fbb0cf341/src/main/java/com/github/jankroken/commandline/domain/internal/LongOrCompactTokenizer.java#L35-L65
136,584
jankroken/commandline
src/main/java/com/github/jankroken/commandline/domain/internal/LongOrCompactTokenizer.java
LongOrCompactTokenizer.next
public Token next() { if (!splitTokens.isEmpty()) { return splitTokens.remove(); } var value = stringIterator.next(); if (argumentEscapeEncountered) { return new ArgumentToken(value); } if (Objects.equals(value, argumentTerminator)) { argumentTerminator = null; return new ArgumentToken(value); } if (argumentTerminator != null) { return new ArgumentToken(value); } if (isArgumentEscape(value)) { argumentEscapeEncountered = true; return next(); } if (isSwitch(value)) { if (isShortSwitchList(value)) { splitTokens.addAll(splitSwitchTokens(value)); return splitTokens.remove(); } else { return new SwitchToken(value.substring(2), value); } } else { return new ArgumentToken(value); } }
java
public Token next() { if (!splitTokens.isEmpty()) { return splitTokens.remove(); } var value = stringIterator.next(); if (argumentEscapeEncountered) { return new ArgumentToken(value); } if (Objects.equals(value, argumentTerminator)) { argumentTerminator = null; return new ArgumentToken(value); } if (argumentTerminator != null) { return new ArgumentToken(value); } if (isArgumentEscape(value)) { argumentEscapeEncountered = true; return next(); } if (isSwitch(value)) { if (isShortSwitchList(value)) { splitTokens.addAll(splitSwitchTokens(value)); return splitTokens.remove(); } else { return new SwitchToken(value.substring(2), value); } } else { return new ArgumentToken(value); } }
[ "public", "Token", "next", "(", ")", "{", "if", "(", "!", "splitTokens", ".", "isEmpty", "(", ")", ")", "{", "return", "splitTokens", ".", "remove", "(", ")", ";", "}", "var", "value", "=", "stringIterator", ".", "next", "(", ")", ";", "if", "(", ...
this is a mess - needs to be cleaned up
[ "this", "is", "a", "mess", "-", "needs", "to", "be", "cleaned", "up" ]
6c0c11dbd102974f05f175ddfe1cba7fbb0cf341
https://github.com/jankroken/commandline/blob/6c0c11dbd102974f05f175ddfe1cba7fbb0cf341/src/main/java/com/github/jankroken/commandline/domain/internal/LongOrCompactTokenizer.java#L68-L99
136,585
jankroken/commandline
src/main/java/com/github/jankroken/commandline/CommandLineParser.java
CommandLineParser.parse
public static <T> T parse(Class<T> optionClass, String[] args, OptionStyle style) throws IllegalAccessException, InstantiationException, InvocationTargetException { T spec; try { spec = optionClass.getConstructor().newInstance(); } catch (NoSuchMethodException noSuchMethodException) { throw new RuntimeException(noSuchMethodException); } var optionSet = new OptionSet(spec, MAIN_OPTIONS); Tokenizer tokenizer; if (style == SIMPLE) { tokenizer = new SimpleTokenizer(new PeekIterator<>(new ArrayIterator<>(args))); } else { tokenizer = new LongOrCompactTokenizer(new PeekIterator<>(new ArrayIterator<>(args))); } optionSet.consumeOptions(tokenizer); return spec; }
java
public static <T> T parse(Class<T> optionClass, String[] args, OptionStyle style) throws IllegalAccessException, InstantiationException, InvocationTargetException { T spec; try { spec = optionClass.getConstructor().newInstance(); } catch (NoSuchMethodException noSuchMethodException) { throw new RuntimeException(noSuchMethodException); } var optionSet = new OptionSet(spec, MAIN_OPTIONS); Tokenizer tokenizer; if (style == SIMPLE) { tokenizer = new SimpleTokenizer(new PeekIterator<>(new ArrayIterator<>(args))); } else { tokenizer = new LongOrCompactTokenizer(new PeekIterator<>(new ArrayIterator<>(args))); } optionSet.consumeOptions(tokenizer); return spec; }
[ "public", "static", "<", "T", ">", "T", "parse", "(", "Class", "<", "T", ">", "optionClass", ",", "String", "[", "]", "args", ",", "OptionStyle", "style", ")", "throws", "IllegalAccessException", ",", "InstantiationException", ",", "InvocationTargetException", ...
A command line parser. It takes two arguments, a class and an argument list, and returns an instance of the class, populated from the argument list based on the annotations in the class. The class must have a no argument constructor. @param <T> The type of the provided class @param optionClass A class that contains annotated setters that options/arguments will be assigned to @param args The provided argument list, typically the argument from the static main method @return An instance of the provided class, populated with the options and arguments of the argument list @throws IllegalAccessException May be thrown when invoking the setters in the specified class @throws InstantiationException May be thrown when creating an instance of the specified class @throws InvocationTargetException May be thrown when invoking the setters in the specified class @throws com.github.jankroken.commandline.domain.InternalErrorException This indicates an internal error in the parser, and will not normally be thrown @throws com.github.jankroken.commandline.domain.InvalidCommandLineException This indicates that the command line specified does not match the annotations in the provided class @throws com.github.jankroken.commandline.domain.InvalidOptionConfigurationException This indicates that the annotations of setters in the provided class are not valid @throws com.github.jankroken.commandline.domain.UnrecognizedSwitchException This indicates that the argument list contains a switch which is not specified by the class annotations
[ "A", "command", "line", "parser", ".", "It", "takes", "two", "arguments", "a", "class", "and", "an", "argument", "list", "and", "returns", "an", "instance", "of", "the", "class", "populated", "from", "the", "argument", "list", "based", "on", "the", "annota...
6c0c11dbd102974f05f175ddfe1cba7fbb0cf341
https://github.com/jankroken/commandline/blob/6c0c11dbd102974f05f175ddfe1cba7fbb0cf341/src/main/java/com/github/jankroken/commandline/CommandLineParser.java#L36-L53
136,586
ibm-bluemix-mobile-services/bms-clientsdk-android-push
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/push/api/MFPPushNotificationDismissHandler.java
MFPPushNotificationDismissHandler.onReceive
@Override public void onReceive(Context context, Intent intent) { String messageId = intent.getStringExtra(ID); MFPPush.getInstance().changeStatus(messageId, MFPPushNotificationStatus.DISMISSED); }
java
@Override public void onReceive(Context context, Intent intent) { String messageId = intent.getStringExtra(ID); MFPPush.getInstance().changeStatus(messageId, MFPPushNotificationStatus.DISMISSED); }
[ "@", "Override", "public", "void", "onReceive", "(", "Context", "context", ",", "Intent", "intent", ")", "{", "String", "messageId", "=", "intent", ".", "getStringExtra", "(", "ID", ")", ";", "MFPPush", ".", "getInstance", "(", ")", ".", "changeStatus", "(...
This method is called when a notification is dimissed or cleared from the notification tray. @param context This is the context of the application @param intent Intent which invoked this receiver
[ "This", "method", "is", "called", "when", "a", "notification", "is", "dimissed", "or", "cleared", "from", "the", "notification", "tray", "." ]
26c048637e81a6942004693919558f3d9aa8c674
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-push/blob/26c048637e81a6942004693919558f3d9aa8c674/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/push/api/MFPPushNotificationDismissHandler.java#L35-L39
136,587
ibm-bluemix-mobile-services/bms-clientsdk-android-push
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/push/api/MFPPush.java
MFPPush.isPushSupported
public boolean isPushSupported() { String version = android.os.Build.VERSION.RELEASE.substring(0, 3); return (Double.valueOf(version) >= MIN_SUPPORTED_ANDRIOD_VERSION); }
java
public boolean isPushSupported() { String version = android.os.Build.VERSION.RELEASE.substring(0, 3); return (Double.valueOf(version) >= MIN_SUPPORTED_ANDRIOD_VERSION); }
[ "public", "boolean", "isPushSupported", "(", ")", "{", "String", "version", "=", "android", ".", "os", ".", "Build", ".", "VERSION", ".", "RELEASE", ".", "substring", "(", "0", ",", "3", ")", ";", "return", "(", "Double", ".", "valueOf", "(", "version"...
Checks whether push notification is supported. @return true if push is supported, false otherwise.
[ "Checks", "whether", "push", "notification", "is", "supported", "." ]
26c048637e81a6942004693919558f3d9aa8c674
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-push/blob/26c048637e81a6942004693919558f3d9aa8c674/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/push/api/MFPPush.java#L364-L367
136,588
ibm-bluemix-mobile-services/bms-clientsdk-android-push
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/push/api/MFPPush.java
MFPPush.registerDeviceWithUserId
public void registerDeviceWithUserId(String userId, MFPPushResponseListener<String> listener) { if (isInitialized) { this.registerResponseListener = listener; setAppForeground(true); logger.info("MFPPush:register() - Retrieving senderId from MFPPush server."); getSenderIdFromServerAndRegisterInBackground(userId); } else { logger.error("MFPPush:register() - An error occured while registering for MFPPush service. Push not initialized with call to initialize()"); } }
java
public void registerDeviceWithUserId(String userId, MFPPushResponseListener<String> listener) { if (isInitialized) { this.registerResponseListener = listener; setAppForeground(true); logger.info("MFPPush:register() - Retrieving senderId from MFPPush server."); getSenderIdFromServerAndRegisterInBackground(userId); } else { logger.error("MFPPush:register() - An error occured while registering for MFPPush service. Push not initialized with call to initialize()"); } }
[ "public", "void", "registerDeviceWithUserId", "(", "String", "userId", ",", "MFPPushResponseListener", "<", "String", ">", "listener", ")", "{", "if", "(", "isInitialized", ")", "{", "this", ".", "registerResponseListener", "=", "listener", ";", "setAppForeground", ...
Registers the device for Push notifications with the given alias and consumerId @param listener - Mandatory listener class. When the device is successfully registered with Push service the {@link MFPPushResponseListener}.onSuccess method is called with the deviceId. {@link MFPPushResponseListener}.onFailure method is called otherwise @param userId - The UserId for registration.
[ "Registers", "the", "device", "for", "Push", "notifications", "with", "the", "given", "alias", "and", "consumerId" ]
26c048637e81a6942004693919558f3d9aa8c674
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-push/blob/26c048637e81a6942004693919558f3d9aa8c674/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/push/api/MFPPush.java#L380-L391
136,589
ibm-bluemix-mobile-services/bms-clientsdk-android-push
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/push/api/MFPPush.java
MFPPush.subscribe
public void subscribe(final String tagName, final MFPPushResponseListener<String> listener) { if (isAbleToSubscribe()) { MFPPushUrlBuilder builder = new MFPPushUrlBuilder(applicationId); String path = builder.getSubscriptionsUrl(); logger.debug("MFPPush:subscribe() - The tag subscription path is: " + path); MFPPushInvoker invoker = MFPPushInvoker.newInstance(appContext, path, Request.POST, clientSecret); invoker.setJSONRequestBody(buildSubscription(tagName)); invoker.setResponseListener(new ResponseListener() { @Override public void onSuccess(Response response) { //Subscription successfully created. logger.info("MFPPush:subscribe() - Tag subscription successfully created. The response is: " + response.toString()); listener.onSuccess(tagName); } @Override public void onFailure(Response response, Throwable throwable, JSONObject jsonObject) { //Error while subscribing to tags. logger.error("MFPPush: Error while subscribing to tags"); listener.onFailure(getException(response,throwable,jsonObject)); } }); invoker.execute(); } }
java
public void subscribe(final String tagName, final MFPPushResponseListener<String> listener) { if (isAbleToSubscribe()) { MFPPushUrlBuilder builder = new MFPPushUrlBuilder(applicationId); String path = builder.getSubscriptionsUrl(); logger.debug("MFPPush:subscribe() - The tag subscription path is: " + path); MFPPushInvoker invoker = MFPPushInvoker.newInstance(appContext, path, Request.POST, clientSecret); invoker.setJSONRequestBody(buildSubscription(tagName)); invoker.setResponseListener(new ResponseListener() { @Override public void onSuccess(Response response) { //Subscription successfully created. logger.info("MFPPush:subscribe() - Tag subscription successfully created. The response is: " + response.toString()); listener.onSuccess(tagName); } @Override public void onFailure(Response response, Throwable throwable, JSONObject jsonObject) { //Error while subscribing to tags. logger.error("MFPPush: Error while subscribing to tags"); listener.onFailure(getException(response,throwable,jsonObject)); } }); invoker.execute(); } }
[ "public", "void", "subscribe", "(", "final", "String", "tagName", ",", "final", "MFPPushResponseListener", "<", "String", ">", "listener", ")", "{", "if", "(", "isAbleToSubscribe", "(", ")", ")", "{", "MFPPushUrlBuilder", "builder", "=", "new", "MFPPushUrlBuilde...
Subscribes to the given tag @param tagName name of the tag @param listener Mandatory listener class. When the subscription is created successfully the {@link MFPPushResponseListener}.onSuccess method is called with the tagName for which subscription is created. {@link MFPPushResponseListener}.onFailure method is called otherwise
[ "Subscribes", "to", "the", "given", "tag" ]
26c048637e81a6942004693919558f3d9aa8c674
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-push/blob/26c048637e81a6942004693919558f3d9aa8c674/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/push/api/MFPPush.java#L433-L459
136,590
ibm-bluemix-mobile-services/bms-clientsdk-android-push
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/push/api/MFPPush.java
MFPPush.unsubscribe
public void unsubscribe(final String tagName, final MFPPushResponseListener<String> listener) { if (isAbleToSubscribe()) { MFPPushUrlBuilder builder = new MFPPushUrlBuilder(applicationId); String path = builder.getSubscriptionsUrl(deviceId, tagName); if (path == DEVICE_ID_NULL) { listener.onFailure(new MFPPushException("The device is not registered yet. Please register device before calling subscriptions API")); return; } logger.debug("MFPPush:unsubscribe() - The tag unsubscription path is: " + path); MFPPushInvoker invoker = MFPPushInvoker.newInstance(appContext, path, Request.DELETE, clientSecret); invoker.setResponseListener(new ResponseListener() { @Override public void onSuccess(Response response) { logger.info("MFPPush:unsubscribe() - Tag unsubscription successful. The response is: " + response.toString()); listener.onSuccess(tagName); } @Override public void onFailure(Response response, Throwable throwable, JSONObject jsonObject) { //Error while Unsubscribing to tags. logger.error("MFPPush: Error while Unsubscribing to tags"); listener.onFailure(getException(response,throwable,jsonObject)); } }); invoker.execute(); } }
java
public void unsubscribe(final String tagName, final MFPPushResponseListener<String> listener) { if (isAbleToSubscribe()) { MFPPushUrlBuilder builder = new MFPPushUrlBuilder(applicationId); String path = builder.getSubscriptionsUrl(deviceId, tagName); if (path == DEVICE_ID_NULL) { listener.onFailure(new MFPPushException("The device is not registered yet. Please register device before calling subscriptions API")); return; } logger.debug("MFPPush:unsubscribe() - The tag unsubscription path is: " + path); MFPPushInvoker invoker = MFPPushInvoker.newInstance(appContext, path, Request.DELETE, clientSecret); invoker.setResponseListener(new ResponseListener() { @Override public void onSuccess(Response response) { logger.info("MFPPush:unsubscribe() - Tag unsubscription successful. The response is: " + response.toString()); listener.onSuccess(tagName); } @Override public void onFailure(Response response, Throwable throwable, JSONObject jsonObject) { //Error while Unsubscribing to tags. logger.error("MFPPush: Error while Unsubscribing to tags"); listener.onFailure(getException(response,throwable,jsonObject)); } }); invoker.execute(); } }
[ "public", "void", "unsubscribe", "(", "final", "String", "tagName", ",", "final", "MFPPushResponseListener", "<", "String", ">", "listener", ")", "{", "if", "(", "isAbleToSubscribe", "(", ")", ")", "{", "MFPPushUrlBuilder", "builder", "=", "new", "MFPPushUrlBuil...
Unsubscribes to the given tag @param tagName name of the tag @param listener Mandatory listener class. When the subscription is deleted successfully the {@link MFPPushResponseListener}.onSuccess method is called with the tagName for which subscription is deleted. {@link MFPPushResponseListener}.onFailure method is called otherwise
[ "Unsubscribes", "to", "the", "given", "tag" ]
26c048637e81a6942004693919558f3d9aa8c674
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-push/blob/26c048637e81a6942004693919558f3d9aa8c674/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/push/api/MFPPush.java#L471-L501
136,591
ibm-bluemix-mobile-services/bms-clientsdk-android-push
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/push/api/MFPPush.java
MFPPush.unregister
public void unregister(final MFPPushResponseListener<String> listener) { MFPPushUrlBuilder builder = new MFPPushUrlBuilder(applicationId); if (this.deviceId == null) { this.deviceId = MFPPushUtils.getContentFromSharedPreferences(appContext, applicationId + DEVICE_ID); } String path = builder.getUnregisterUrl(deviceId); logger.debug("MFPPush:unregister() - The device unregister url is: " + path); MFPPushInvoker invoker = MFPPushInvoker.newInstance(appContext, path, Request.DELETE, clientSecret); invoker.setResponseListener(new ResponseListener() { @Override public void onSuccess(Response response) { logger.info("MFPPush:unregister() - Successfully unregistered device. Response is: " + response.toString()); isTokenUpdatedOnServer = false; listener.onSuccess("Device Successfully unregistered from receiving push notifications."); } @Override public void onFailure(Response response, Throwable throwable, JSONObject jsonObject) { logger.error("MFPPush: Error while unregistered device"); listener.onFailure(getException(response,throwable,jsonObject)); } }); invoker.execute(); }
java
public void unregister(final MFPPushResponseListener<String> listener) { MFPPushUrlBuilder builder = new MFPPushUrlBuilder(applicationId); if (this.deviceId == null) { this.deviceId = MFPPushUtils.getContentFromSharedPreferences(appContext, applicationId + DEVICE_ID); } String path = builder.getUnregisterUrl(deviceId); logger.debug("MFPPush:unregister() - The device unregister url is: " + path); MFPPushInvoker invoker = MFPPushInvoker.newInstance(appContext, path, Request.DELETE, clientSecret); invoker.setResponseListener(new ResponseListener() { @Override public void onSuccess(Response response) { logger.info("MFPPush:unregister() - Successfully unregistered device. Response is: " + response.toString()); isTokenUpdatedOnServer = false; listener.onSuccess("Device Successfully unregistered from receiving push notifications."); } @Override public void onFailure(Response response, Throwable throwable, JSONObject jsonObject) { logger.error("MFPPush: Error while unregistered device"); listener.onFailure(getException(response,throwable,jsonObject)); } }); invoker.execute(); }
[ "public", "void", "unregister", "(", "final", "MFPPushResponseListener", "<", "String", ">", "listener", ")", "{", "MFPPushUrlBuilder", "builder", "=", "new", "MFPPushUrlBuilder", "(", "applicationId", ")", ";", "if", "(", "this", ".", "deviceId", "==", "null", ...
Unregister the device from Push Server @param listener Mandatory listener class. When the subscription is deleted successfully the {@link MFPPushResponseListener}.onSuccess method is called with the tagName for which subscription is deleted. {@link MFPPushResponseListener}.onFailure method is called otherwise
[ "Unregister", "the", "device", "from", "Push", "Server" ]
26c048637e81a6942004693919558f3d9aa8c674
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-push/blob/26c048637e81a6942004693919558f3d9aa8c674/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/push/api/MFPPush.java#L512-L538
136,592
ibm-bluemix-mobile-services/bms-clientsdk-android-push
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/push/api/MFPPush.java
MFPPush.getTags
public void getTags(final MFPPushResponseListener<List<String>> listener) { MFPPushUrlBuilder builder = new MFPPushUrlBuilder(applicationId); String path = builder.getTagsUrl(); MFPPushInvoker invoker = MFPPushInvoker.newInstance(appContext, path, Request.GET, clientSecret); invoker.setResponseListener(new ResponseListener() { @Override public void onSuccess(Response response) { logger.info("MFPPush:getTags() - Successfully retreived tags. The response is: " + response.toString()); List<String> tagNames = new ArrayList<String>(); try { String responseText = response.getResponseText(); JSONArray tags = (JSONArray) (new JSONObject(responseText)).get(TAGS); Log.d("JSONArray of tags is: ", tags.toString()); int tagsCnt = tags.length(); for (int tagsIdx = 0; tagsIdx < tagsCnt; tagsIdx++) { Log.d("Adding tag: ", tags.getJSONObject(tagsIdx).toString()); tagNames.add(tags.getJSONObject(tagsIdx) .getString(NAME)); } listener.onSuccess(tagNames); } catch (JSONException e) { logger.error("MFPPush: getTags() - Error while retrieving tags. Error is: " + e.getMessage()); listener.onFailure(new MFPPushException(e)); } } @Override public void onFailure(Response response, Throwable throwable, JSONObject jsonObject) { //Error while getting tags. logger.error("MFPPush: Error while getting tags"); listener.onFailure(getException(response,throwable,jsonObject)); } }); invoker.execute(); }
java
public void getTags(final MFPPushResponseListener<List<String>> listener) { MFPPushUrlBuilder builder = new MFPPushUrlBuilder(applicationId); String path = builder.getTagsUrl(); MFPPushInvoker invoker = MFPPushInvoker.newInstance(appContext, path, Request.GET, clientSecret); invoker.setResponseListener(new ResponseListener() { @Override public void onSuccess(Response response) { logger.info("MFPPush:getTags() - Successfully retreived tags. The response is: " + response.toString()); List<String> tagNames = new ArrayList<String>(); try { String responseText = response.getResponseText(); JSONArray tags = (JSONArray) (new JSONObject(responseText)).get(TAGS); Log.d("JSONArray of tags is: ", tags.toString()); int tagsCnt = tags.length(); for (int tagsIdx = 0; tagsIdx < tagsCnt; tagsIdx++) { Log.d("Adding tag: ", tags.getJSONObject(tagsIdx).toString()); tagNames.add(tags.getJSONObject(tagsIdx) .getString(NAME)); } listener.onSuccess(tagNames); } catch (JSONException e) { logger.error("MFPPush: getTags() - Error while retrieving tags. Error is: " + e.getMessage()); listener.onFailure(new MFPPushException(e)); } } @Override public void onFailure(Response response, Throwable throwable, JSONObject jsonObject) { //Error while getting tags. logger.error("MFPPush: Error while getting tags"); listener.onFailure(getException(response,throwable,jsonObject)); } }); invoker.execute(); }
[ "public", "void", "getTags", "(", "final", "MFPPushResponseListener", "<", "List", "<", "String", ">", ">", "listener", ")", "{", "MFPPushUrlBuilder", "builder", "=", "new", "MFPPushUrlBuilder", "(", "applicationId", ")", ";", "String", "path", "=", "builder", ...
Get the list of tags @param listener Mandatory listener class. When the list of tags are successfully retrieved the {@link MFPPushResponseListener} .onSuccess method is called with the list of tagNames {@link MFPPushResponseListener}.onFailure method is called otherwise
[ "Get", "the", "list", "of", "tags" ]
26c048637e81a6942004693919558f3d9aa8c674
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-push/blob/26c048637e81a6942004693919558f3d9aa8c674/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/push/api/MFPPush.java#L549-L585
136,593
ibm-bluemix-mobile-services/bms-clientsdk-android-push
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/push/api/MFPPush.java
MFPPush.getSubscriptions
public void getSubscriptions( final MFPPushResponseListener<List<String>> listener) { MFPPushUrlBuilder builder = new MFPPushUrlBuilder(applicationId); String path = builder.getSubscriptionsUrl(deviceId, null); if (path == DEVICE_ID_NULL) { listener.onFailure(new MFPPushException("The device is not registered yet. Please register device before calling subscriptions API")); return; } MFPPushInvoker invoker = MFPPushInvoker.newInstance(appContext, path, Request.GET, clientSecret); invoker.setResponseListener(new ResponseListener() { @Override public void onSuccess(Response response) { List<String> tagNames = new ArrayList<String>(); try { JSONArray tags = (JSONArray) (new JSONObject(response.getResponseText())) .get(SUBSCRIPTIONS); int tagsCnt = tags.length(); for (int tagsIdx = 0; tagsIdx < tagsCnt; tagsIdx++) { tagNames.add(tags.getJSONObject(tagsIdx) .getString(TAG_NAME)); } listener.onSuccess(tagNames); } catch (JSONException e) { logger.error("MFPPush: getSubscriptions() - Failure while getting subscriptions. Failure response is: " + e.getMessage()); listener.onFailure(new MFPPushException(e)); } } @Override public void onFailure(Response response, Throwable throwable, JSONObject jsonObject) { //Error while getSubscriptions. logger.error("MFPPush: Error while getSubscriptions"); listener.onFailure(getException(response,throwable,jsonObject)); } }); invoker.execute(); }
java
public void getSubscriptions( final MFPPushResponseListener<List<String>> listener) { MFPPushUrlBuilder builder = new MFPPushUrlBuilder(applicationId); String path = builder.getSubscriptionsUrl(deviceId, null); if (path == DEVICE_ID_NULL) { listener.onFailure(new MFPPushException("The device is not registered yet. Please register device before calling subscriptions API")); return; } MFPPushInvoker invoker = MFPPushInvoker.newInstance(appContext, path, Request.GET, clientSecret); invoker.setResponseListener(new ResponseListener() { @Override public void onSuccess(Response response) { List<String> tagNames = new ArrayList<String>(); try { JSONArray tags = (JSONArray) (new JSONObject(response.getResponseText())) .get(SUBSCRIPTIONS); int tagsCnt = tags.length(); for (int tagsIdx = 0; tagsIdx < tagsCnt; tagsIdx++) { tagNames.add(tags.getJSONObject(tagsIdx) .getString(TAG_NAME)); } listener.onSuccess(tagNames); } catch (JSONException e) { logger.error("MFPPush: getSubscriptions() - Failure while getting subscriptions. Failure response is: " + e.getMessage()); listener.onFailure(new MFPPushException(e)); } } @Override public void onFailure(Response response, Throwable throwable, JSONObject jsonObject) { //Error while getSubscriptions. logger.error("MFPPush: Error while getSubscriptions"); listener.onFailure(getException(response,throwable,jsonObject)); } }); invoker.execute(); }
[ "public", "void", "getSubscriptions", "(", "final", "MFPPushResponseListener", "<", "List", "<", "String", ">", ">", "listener", ")", "{", "MFPPushUrlBuilder", "builder", "=", "new", "MFPPushUrlBuilder", "(", "applicationId", ")", ";", "String", "path", "=", "bu...
Get the list of tags subscribed to @param listener Mandatory listener class. When the list of tags subscribed to are successfully retrieved the {@link MFPPushResponseListener} .onSuccess method is called with the list of tagNames {@link MFPPushResponseListener}.onFailure method is called otherwise
[ "Get", "the", "list", "of", "tags", "subscribed", "to" ]
26c048637e81a6942004693919558f3d9aa8c674
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-push/blob/26c048637e81a6942004693919558f3d9aa8c674/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/push/api/MFPPush.java#L596-L637
136,594
ibm-bluemix-mobile-services/bms-clientsdk-android-push
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/push/api/MFPPush.java
MFPPush.setNotificationOptions
private void setNotificationOptions(Context context,MFPPushNotificationOptions options) { if (this.appContext == null) { this.appContext = context.getApplicationContext(); } this.options = options; Gson gson = new Gson(); String json = gson.toJson(options); SharedPreferences sharedPreferences = appContext.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); MFPPushUtils.storeContentInSharedPreferences(sharedPreferences, MFPPush.PREFS_MESSAGES_OPTIONS, json); }
java
private void setNotificationOptions(Context context,MFPPushNotificationOptions options) { if (this.appContext == null) { this.appContext = context.getApplicationContext(); } this.options = options; Gson gson = new Gson(); String json = gson.toJson(options); SharedPreferences sharedPreferences = appContext.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); MFPPushUtils.storeContentInSharedPreferences(sharedPreferences, MFPPush.PREFS_MESSAGES_OPTIONS, json); }
[ "private", "void", "setNotificationOptions", "(", "Context", "context", ",", "MFPPushNotificationOptions", "options", ")", "{", "if", "(", "this", ".", "appContext", "==", "null", ")", "{", "this", ".", "appContext", "=", "context", ".", "getApplicationContext", ...
Set the default push notification options for notifications. @param context - this is the Context of the application from getApplicationContext() @param options - The MFPPushNotificationOptions with the default parameters
[ "Set", "the", "default", "push", "notification", "options", "for", "notifications", "." ]
26c048637e81a6942004693919558f3d9aa8c674
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-push/blob/26c048637e81a6942004693919558f3d9aa8c674/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/push/api/MFPPush.java#L656-L666
136,595
ibm-bluemix-mobile-services/bms-clientsdk-android-push
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/push/api/MFPPush.java
MFPPush.setNotificationStatusListener
public void setNotificationStatusListener(MFPPushNotificationStatusListener statusListener) { this.statusListener = statusListener; synchronized (pendingStatus) { if(!pendingStatus.isEmpty()) { for(Map.Entry<String, MFPPushNotificationStatus> entry : pendingStatus.entrySet()) { changeStatus(entry.getKey(), entry.getValue()); } pendingStatus.clear(); } } }
java
public void setNotificationStatusListener(MFPPushNotificationStatusListener statusListener) { this.statusListener = statusListener; synchronized (pendingStatus) { if(!pendingStatus.isEmpty()) { for(Map.Entry<String, MFPPushNotificationStatus> entry : pendingStatus.entrySet()) { changeStatus(entry.getKey(), entry.getValue()); } pendingStatus.clear(); } } }
[ "public", "void", "setNotificationStatusListener", "(", "MFPPushNotificationStatusListener", "statusListener", ")", "{", "this", ".", "statusListener", "=", "statusListener", ";", "synchronized", "(", "pendingStatus", ")", "{", "if", "(", "!", "pendingStatus", ".", "i...
Set the listener class to receive the notification status changes. @param statusListener - Mandatory listener class. When the notification status changes {@link MFPPushNotificationStatusListener}.onStatusChange method is called
[ "Set", "the", "listener", "class", "to", "receive", "the", "notification", "status", "changes", "." ]
26c048637e81a6942004693919558f3d9aa8c674
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-push/blob/26c048637e81a6942004693919558f3d9aa8c674/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/push/api/MFPPush.java#L673-L683
136,596
ibm-bluemix-mobile-services/bms-clientsdk-android-push
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/push/api/MFPPush.java
MFPPush.getMessagesFromSharedPreferences
public boolean getMessagesFromSharedPreferences(int notificationId) { boolean gotMessages = false; SharedPreferences sharedPreferences = appContext.getSharedPreferences( PREFS_NAME, Context.MODE_PRIVATE); int countOfStoredMessages = sharedPreferences.getInt(MFPPush.PREFS_NOTIFICATION_COUNT, 0); if (countOfStoredMessages > 0) { String key = null; try { Map<String, ?> allEntriesFromSharedPreferences = sharedPreferences.getAll(); Map<String, String> notificationEntries = new HashMap<String, String>(); for (Map.Entry<String, ?> entry : allEntriesFromSharedPreferences.entrySet()) { String rKey = entry.getKey(); if (entry.getKey().startsWith(PREFS_NOTIFICATION_MSG)) { notificationEntries.put(rKey, entry.getValue().toString()); } } for (Map.Entry<String, String> entry : notificationEntries.entrySet()) { String nKey = entry.getKey(); key = nKey; String msg = sharedPreferences.getString(nKey, null); if (msg != null) { gotMessages = true; logger.debug("MFPPush:getMessagesFromSharedPreferences() - Messages retrieved from shared preferences."); MFPInternalPushMessage pushMessage = new MFPInternalPushMessage( new JSONObject(msg)); if (notificationId != 0) { if (notificationId == pushMessage.getNotificationId()) { isFromNotificationBar = true; messageFromBar = pushMessage; MFPPushUtils.removeContentFromSharedPreferences(sharedPreferences, nKey); MFPPushUtils.storeContentInSharedPreferences(sharedPreferences, MFPPush.PREFS_NOTIFICATION_COUNT, countOfStoredMessages - 1); break; } } else { synchronized (pending) { pending.add(pushMessage); } MFPPushUtils.removeContentFromSharedPreferences(sharedPreferences, nKey); } } } } catch (JSONException e) { MFPPushUtils.removeContentFromSharedPreferences(sharedPreferences, key); } if (notificationId == 0) { MFPPushUtils.storeContentInSharedPreferences(sharedPreferences, MFPPush.PREFS_NOTIFICATION_COUNT, 0); } } return gotMessages; }
java
public boolean getMessagesFromSharedPreferences(int notificationId) { boolean gotMessages = false; SharedPreferences sharedPreferences = appContext.getSharedPreferences( PREFS_NAME, Context.MODE_PRIVATE); int countOfStoredMessages = sharedPreferences.getInt(MFPPush.PREFS_NOTIFICATION_COUNT, 0); if (countOfStoredMessages > 0) { String key = null; try { Map<String, ?> allEntriesFromSharedPreferences = sharedPreferences.getAll(); Map<String, String> notificationEntries = new HashMap<String, String>(); for (Map.Entry<String, ?> entry : allEntriesFromSharedPreferences.entrySet()) { String rKey = entry.getKey(); if (entry.getKey().startsWith(PREFS_NOTIFICATION_MSG)) { notificationEntries.put(rKey, entry.getValue().toString()); } } for (Map.Entry<String, String> entry : notificationEntries.entrySet()) { String nKey = entry.getKey(); key = nKey; String msg = sharedPreferences.getString(nKey, null); if (msg != null) { gotMessages = true; logger.debug("MFPPush:getMessagesFromSharedPreferences() - Messages retrieved from shared preferences."); MFPInternalPushMessage pushMessage = new MFPInternalPushMessage( new JSONObject(msg)); if (notificationId != 0) { if (notificationId == pushMessage.getNotificationId()) { isFromNotificationBar = true; messageFromBar = pushMessage; MFPPushUtils.removeContentFromSharedPreferences(sharedPreferences, nKey); MFPPushUtils.storeContentInSharedPreferences(sharedPreferences, MFPPush.PREFS_NOTIFICATION_COUNT, countOfStoredMessages - 1); break; } } else { synchronized (pending) { pending.add(pushMessage); } MFPPushUtils.removeContentFromSharedPreferences(sharedPreferences, nKey); } } } } catch (JSONException e) { MFPPushUtils.removeContentFromSharedPreferences(sharedPreferences, key); } if (notificationId == 0) { MFPPushUtils.storeContentInSharedPreferences(sharedPreferences, MFPPush.PREFS_NOTIFICATION_COUNT, 0); } } return gotMessages; }
[ "public", "boolean", "getMessagesFromSharedPreferences", "(", "int", "notificationId", ")", "{", "boolean", "gotMessages", "=", "false", ";", "SharedPreferences", "sharedPreferences", "=", "appContext", ".", "getSharedPreferences", "(", "PREFS_NAME", ",", "Context", "."...
Based on the PREFS_NOTIFICATION_COUNT value, fetch all the stored notifications in the same order from the shared preferences and save it onto the list. This method will ensure that the notifications are sent to the Application in the same order in which they arrived.
[ "Based", "on", "the", "PREFS_NOTIFICATION_COUNT", "value", "fetch", "all", "the", "stored", "notifications", "in", "the", "same", "order", "from", "the", "shared", "preferences", "and", "save", "it", "onto", "the", "list", ".", "This", "method", "will", "ensur...
26c048637e81a6942004693919558f3d9aa8c674
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-push/blob/26c048637e81a6942004693919558f3d9aa8c674/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/push/api/MFPPush.java#L1237-L1294
136,597
ibm-bluemix-mobile-services/bms-clientsdk-android-push
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/push/internal/MFPPushUtils.java
MFPPushUtils.removeContentFromSharedPreferences
public static void removeContentFromSharedPreferences(SharedPreferences sharedPreferences, String key ) { Editor editor = sharedPreferences.edit(); String msg = sharedPreferences.getString(key, null); editor.remove(key); editor.commit(); }
java
public static void removeContentFromSharedPreferences(SharedPreferences sharedPreferences, String key ) { Editor editor = sharedPreferences.edit(); String msg = sharedPreferences.getString(key, null); editor.remove(key); editor.commit(); }
[ "public", "static", "void", "removeContentFromSharedPreferences", "(", "SharedPreferences", "sharedPreferences", ",", "String", "key", ")", "{", "Editor", "editor", "=", "sharedPreferences", ".", "edit", "(", ")", ";", "String", "msg", "=", "sharedPreferences", ".",...
Remove the key from SharedPreferences
[ "Remove", "the", "key", "from", "SharedPreferences" ]
26c048637e81a6942004693919558f3d9aa8c674
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-push/blob/26c048637e81a6942004693919558f3d9aa8c674/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/push/internal/MFPPushUtils.java#L97-L103
136,598
ibm-bluemix-mobile-services/bms-clientsdk-android-push
lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/push/internal/MFPPushUtils.java
MFPPushUtils.storeContentInSharedPreferences
public static void storeContentInSharedPreferences(SharedPreferences sharedPreferences, String key, String value ) { Editor editor = sharedPreferences.edit(); editor.putString(key, value); editor.commit(); }
java
public static void storeContentInSharedPreferences(SharedPreferences sharedPreferences, String key, String value ) { Editor editor = sharedPreferences.edit(); editor.putString(key, value); editor.commit(); }
[ "public", "static", "void", "storeContentInSharedPreferences", "(", "SharedPreferences", "sharedPreferences", ",", "String", "key", ",", "String", "value", ")", "{", "Editor", "editor", "=", "sharedPreferences", ".", "edit", "(", ")", ";", "editor", ".", "putStrin...
Store the key, value in SharedPreferences
[ "Store", "the", "key", "value", "in", "SharedPreferences" ]
26c048637e81a6942004693919558f3d9aa8c674
https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-push/blob/26c048637e81a6942004693919558f3d9aa8c674/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/push/internal/MFPPushUtils.java#L106-L110
136,599
IanGClifton/AndroidFloatLabel
FloatLabel/src/com/iangclifton/android/floatlabel/FloatLabel.java
FloatLabel.setText
public void setText(CharSequence text, TextView.BufferType type) { mEditText.setText(text, type); }
java
public void setText(CharSequence text, TextView.BufferType type) { mEditText.setText(text, type); }
[ "public", "void", "setText", "(", "CharSequence", "text", ",", "TextView", ".", "BufferType", "type", ")", "{", "mEditText", ".", "setText", "(", "text", ",", "type", ")", ";", "}" ]
Sets the EditText's text with label animation @param text CharSequence to set @param type TextView.BufferType
[ "Sets", "the", "EditText", "s", "text", "with", "label", "animation" ]
b0a39c26f010f17d5f3648331e9784a41e025c0d
https://github.com/IanGClifton/AndroidFloatLabel/blob/b0a39c26f010f17d5f3648331e9784a41e025c0d/FloatLabel/src/com/iangclifton/android/floatlabel/FloatLabel.java#L270-L272