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
7,800
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/qe/StorableIndexSet.java
StorableIndexSet.markClustered
public void markClustered(boolean clustered) { Map<StorableIndex<S>, StorableIndex<S>> replacements = null; for (StorableIndex<S> index : this) { StorableIndex<S> replacement = index.clustered(clustered); if (replacement != index) { if (replacements == null) { replacements = new HashMap<StorableIndex<S>, StorableIndex<S>>(); } replacements.put(index, replacement); } } replaceEntries(replacements); }
java
public void markClustered(boolean clustered) { Map<StorableIndex<S>, StorableIndex<S>> replacements = null; for (StorableIndex<S> index : this) { StorableIndex<S> replacement = index.clustered(clustered); if (replacement != index) { if (replacements == null) { replacements = new HashMap<StorableIndex<S>, StorableIndex<S>>(); } replacements.put(index, replacement); } } replaceEntries(replacements); }
[ "public", "void", "markClustered", "(", "boolean", "clustered", ")", "{", "Map", "<", "StorableIndex", "<", "S", ">", ",", "StorableIndex", "<", "S", ">", ">", "replacements", "=", "null", ";", "for", "(", "StorableIndex", "<", "S", ">", "index", ":", "this", ")", "{", "StorableIndex", "<", "S", ">", "replacement", "=", "index", ".", "clustered", "(", "clustered", ")", ";", "if", "(", "replacement", "!=", "index", ")", "{", "if", "(", "replacements", "==", "null", ")", "{", "replacements", "=", "new", "HashMap", "<", "StorableIndex", "<", "S", ">", ",", "StorableIndex", "<", "S", ">", ">", "(", ")", ";", "}", "replacements", ".", "put", "(", "index", ",", "replacement", ")", ";", "}", "}", "replaceEntries", "(", "replacements", ")", ";", "}" ]
Marks all indexes as clustered or non-clustered. @param clustered true to mark clustered; false to mark non-clustered @see StorableIndex#isClustered() @since 1.2
[ "Marks", "all", "indexes", "as", "clustered", "or", "non", "-", "clustered", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/StorableIndexSet.java#L210-L222
7,801
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/qe/StorableIndexSet.java
StorableIndexSet.uniquify
public void uniquify(StorableInfo<S> info) { if (info == null) { throw new IllegalArgumentException(); } uniquify(info.getPrimaryKey()); }
java
public void uniquify(StorableInfo<S> info) { if (info == null) { throw new IllegalArgumentException(); } uniquify(info.getPrimaryKey()); }
[ "public", "void", "uniquify", "(", "StorableInfo", "<", "S", ">", "info", ")", "{", "if", "(", "info", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", ")", ";", "}", "uniquify", "(", "info", ".", "getPrimaryKey", "(", ")", ")", ";", "}" ]
Augment non-unique indexes with primary key properties, thus making them unique. @throws IllegalArgumentException if info is null
[ "Augment", "non", "-", "unique", "indexes", "with", "primary", "key", "properties", "thus", "making", "them", "unique", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/StorableIndexSet.java#L230-L235
7,802
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/qe/StorableIndexSet.java
StorableIndexSet.uniquify
public void uniquify(StorableKey<S> key) { if (key == null) { throw new IllegalArgumentException(); } // Replace indexes which were are implied unique, even if they are not // declared as such. { Map<StorableIndex<S>, StorableIndex<S>> replacements = null; for (StorableIndex<S> index : this) { if (!index.isUnique() && isUniqueImplied(index)) { if (replacements == null) { replacements = new HashMap<StorableIndex<S>, StorableIndex<S>>(); } replacements.put(index, index.unique(true)); } } replaceEntries(replacements); } // Now augment with key properties. { Map<StorableIndex<S>, StorableIndex<S>> replacements = null; for (StorableIndex<S> index : this) { StorableIndex<S> replacement = index.uniquify(key); if (replacement != index) { if (replacements == null) { replacements = new HashMap<StorableIndex<S>, StorableIndex<S>>(); } replacements.put(index, replacement); } } replaceEntries(replacements); } }
java
public void uniquify(StorableKey<S> key) { if (key == null) { throw new IllegalArgumentException(); } // Replace indexes which were are implied unique, even if they are not // declared as such. { Map<StorableIndex<S>, StorableIndex<S>> replacements = null; for (StorableIndex<S> index : this) { if (!index.isUnique() && isUniqueImplied(index)) { if (replacements == null) { replacements = new HashMap<StorableIndex<S>, StorableIndex<S>>(); } replacements.put(index, index.unique(true)); } } replaceEntries(replacements); } // Now augment with key properties. { Map<StorableIndex<S>, StorableIndex<S>> replacements = null; for (StorableIndex<S> index : this) { StorableIndex<S> replacement = index.uniquify(key); if (replacement != index) { if (replacements == null) { replacements = new HashMap<StorableIndex<S>, StorableIndex<S>>(); } replacements.put(index, replacement); } } replaceEntries(replacements); } }
[ "public", "void", "uniquify", "(", "StorableKey", "<", "S", ">", "key", ")", "{", "if", "(", "key", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", ")", ";", "}", "// Replace indexes which were are implied unique, even if they are not\r", "// declared as such.\r", "{", "Map", "<", "StorableIndex", "<", "S", ">", ",", "StorableIndex", "<", "S", ">", ">", "replacements", "=", "null", ";", "for", "(", "StorableIndex", "<", "S", ">", "index", ":", "this", ")", "{", "if", "(", "!", "index", ".", "isUnique", "(", ")", "&&", "isUniqueImplied", "(", "index", ")", ")", "{", "if", "(", "replacements", "==", "null", ")", "{", "replacements", "=", "new", "HashMap", "<", "StorableIndex", "<", "S", ">", ",", "StorableIndex", "<", "S", ">", ">", "(", ")", ";", "}", "replacements", ".", "put", "(", "index", ",", "index", ".", "unique", "(", "true", ")", ")", ";", "}", "}", "replaceEntries", "(", "replacements", ")", ";", "}", "// Now augment with key properties.\r", "{", "Map", "<", "StorableIndex", "<", "S", ">", ",", "StorableIndex", "<", "S", ">", ">", "replacements", "=", "null", ";", "for", "(", "StorableIndex", "<", "S", ">", "index", ":", "this", ")", "{", "StorableIndex", "<", "S", ">", "replacement", "=", "index", ".", "uniquify", "(", "key", ")", ";", "if", "(", "replacement", "!=", "index", ")", "{", "if", "(", "replacements", "==", "null", ")", "{", "replacements", "=", "new", "HashMap", "<", "StorableIndex", "<", "S", ">", ",", "StorableIndex", "<", "S", ">", ">", "(", ")", ";", "}", "replacements", ".", "put", "(", "index", ",", "replacement", ")", ";", "}", "}", "replaceEntries", "(", "replacements", ")", ";", "}", "}" ]
Augment non-unique indexes with key properties, thus making them unique. @throws IllegalArgumentException if key is null
[ "Augment", "non", "-", "unique", "indexes", "with", "key", "properties", "thus", "making", "them", "unique", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/StorableIndexSet.java#L242-L277
7,803
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/qe/StorableIndexSet.java
StorableIndexSet.isUniqueImplied
private boolean isUniqueImplied(StorableIndex<S> candidate) { if (candidate.isUnique()) { return true; } if (this.size() <= 1) { return false; } Set<StorableProperty<S>> candidateProps = new HashSet<StorableProperty<S>>(); for (int i=candidate.getPropertyCount(); --i>=0; ) { candidateProps.add(candidate.getProperty(i)); } search: for (StorableIndex<S> index : this) { if (!index.isUnique()) { continue search; } for (int i=index.getPropertyCount(); --i>=0; ) { if (!candidateProps.contains(index.getProperty(i))) { continue search; } } return true; } return false; }
java
private boolean isUniqueImplied(StorableIndex<S> candidate) { if (candidate.isUnique()) { return true; } if (this.size() <= 1) { return false; } Set<StorableProperty<S>> candidateProps = new HashSet<StorableProperty<S>>(); for (int i=candidate.getPropertyCount(); --i>=0; ) { candidateProps.add(candidate.getProperty(i)); } search: for (StorableIndex<S> index : this) { if (!index.isUnique()) { continue search; } for (int i=index.getPropertyCount(); --i>=0; ) { if (!candidateProps.contains(index.getProperty(i))) { continue search; } } return true; } return false; }
[ "private", "boolean", "isUniqueImplied", "(", "StorableIndex", "<", "S", ">", "candidate", ")", "{", "if", "(", "candidate", ".", "isUnique", "(", ")", ")", "{", "return", "true", ";", "}", "if", "(", "this", ".", "size", "(", ")", "<=", "1", ")", "{", "return", "false", ";", "}", "Set", "<", "StorableProperty", "<", "S", ">", ">", "candidateProps", "=", "new", "HashSet", "<", "StorableProperty", "<", "S", ">", ">", "(", ")", ";", "for", "(", "int", "i", "=", "candidate", ".", "getPropertyCount", "(", ")", ";", "--", "i", ">=", "0", ";", ")", "{", "candidateProps", ".", "add", "(", "candidate", ".", "getProperty", "(", "i", ")", ")", ";", "}", "search", ":", "for", "(", "StorableIndex", "<", "S", ">", "index", ":", "this", ")", "{", "if", "(", "!", "index", ".", "isUnique", "(", ")", ")", "{", "continue", "search", ";", "}", "for", "(", "int", "i", "=", "index", ".", "getPropertyCount", "(", ")", ";", "--", "i", ">=", "0", ";", ")", "{", "if", "(", "!", "candidateProps", ".", "contains", "(", "index", ".", "getProperty", "(", "i", ")", ")", ")", "{", "continue", "search", ";", "}", "}", "return", "true", ";", "}", "return", "false", ";", "}" ]
Return true if index is unique or fully contains the members of a unique index.
[ "Return", "true", "if", "index", "is", "unique", "or", "fully", "contains", "the", "members", "of", "a", "unique", "index", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/StorableIndexSet.java#L330-L356
7,804
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/qe/StorableIndexSet.java
StorableIndexSet.isRedundant
private boolean isRedundant(List<StorableIndex<S>> group, StorableIndex<S> candidate, Map<StorableIndex<S>, StorableIndex<S>> mergedReplacements) { // All visited group members will have an equal or greater number of // properties. This is ensured by the ordering of the set. int count = candidate.getPropertyCount(); ListIterator<StorableIndex<S>> it = group.listIterator(); groupScan: while (it.hasNext()) { StorableIndex<S> member = it.next(); boolean moreQualified = false; boolean canReverse = true; boolean reverse = false; for (int i=0; i<count; i++) { Direction candidateOrder = candidate.getPropertyDirection(i); if (candidateOrder == Direction.UNSPECIFIED) { // Property direction is unspecified, so no need to compare // direction. Move on to next property. continue; } Direction memberOrder = member.getPropertyDirection(i); if (memberOrder == Direction.UNSPECIFIED) { // Candidate index is more qualified because member // property under examination hasn't specified a // direction. Move on to next property to continue checking // if a merge is possible. moreQualified = true; continue; } if (reverse) { candidateOrder = candidateOrder.reverse(); } if (candidateOrder == memberOrder) { // Direction exactly matches, move on to next property. canReverse = false; continue; } // If this point is reached, then the direction would match if // one was reversed. For an index to fully match, all // properties must be reversed. if (canReverse) { // Switch to reverse mode and move on to next property. reverse = true; canReverse = false; continue; } // Match failed and merge is not possible. continue groupScan; } if (moreQualified) { // Candidate is more qualified than all members compared to so // far, but it can be merged. Once merged, it is redundant. Direction[] directions = member.getPropertyDirections(); for (int i=0; i<count; i++) { if (directions[i] == Direction.UNSPECIFIED) { Direction direction = candidate.getPropertyDirection(i); directions[i] = reverse ? direction.reverse() : direction; } } StorableIndex<S> merged = new StorableIndex<S>(member.getProperties(), directions) .unique(member.isUnique()); mergedReplacements.put(member, merged); it.set(merged); } // Candidate is redundant. return true; } return false; }
java
private boolean isRedundant(List<StorableIndex<S>> group, StorableIndex<S> candidate, Map<StorableIndex<S>, StorableIndex<S>> mergedReplacements) { // All visited group members will have an equal or greater number of // properties. This is ensured by the ordering of the set. int count = candidate.getPropertyCount(); ListIterator<StorableIndex<S>> it = group.listIterator(); groupScan: while (it.hasNext()) { StorableIndex<S> member = it.next(); boolean moreQualified = false; boolean canReverse = true; boolean reverse = false; for (int i=0; i<count; i++) { Direction candidateOrder = candidate.getPropertyDirection(i); if (candidateOrder == Direction.UNSPECIFIED) { // Property direction is unspecified, so no need to compare // direction. Move on to next property. continue; } Direction memberOrder = member.getPropertyDirection(i); if (memberOrder == Direction.UNSPECIFIED) { // Candidate index is more qualified because member // property under examination hasn't specified a // direction. Move on to next property to continue checking // if a merge is possible. moreQualified = true; continue; } if (reverse) { candidateOrder = candidateOrder.reverse(); } if (candidateOrder == memberOrder) { // Direction exactly matches, move on to next property. canReverse = false; continue; } // If this point is reached, then the direction would match if // one was reversed. For an index to fully match, all // properties must be reversed. if (canReverse) { // Switch to reverse mode and move on to next property. reverse = true; canReverse = false; continue; } // Match failed and merge is not possible. continue groupScan; } if (moreQualified) { // Candidate is more qualified than all members compared to so // far, but it can be merged. Once merged, it is redundant. Direction[] directions = member.getPropertyDirections(); for (int i=0; i<count; i++) { if (directions[i] == Direction.UNSPECIFIED) { Direction direction = candidate.getPropertyDirection(i); directions[i] = reverse ? direction.reverse() : direction; } } StorableIndex<S> merged = new StorableIndex<S>(member.getProperties(), directions) .unique(member.isUnique()); mergedReplacements.put(member, merged); it.set(merged); } // Candidate is redundant. return true; } return false; }
[ "private", "boolean", "isRedundant", "(", "List", "<", "StorableIndex", "<", "S", ">", ">", "group", ",", "StorableIndex", "<", "S", ">", "candidate", ",", "Map", "<", "StorableIndex", "<", "S", ">", ",", "StorableIndex", "<", "S", ">", ">", "mergedReplacements", ")", "{", "// All visited group members will have an equal or greater number of\r", "// properties. This is ensured by the ordering of the set.\r", "int", "count", "=", "candidate", ".", "getPropertyCount", "(", ")", ";", "ListIterator", "<", "StorableIndex", "<", "S", ">", ">", "it", "=", "group", ".", "listIterator", "(", ")", ";", "groupScan", ":", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "StorableIndex", "<", "S", ">", "member", "=", "it", ".", "next", "(", ")", ";", "boolean", "moreQualified", "=", "false", ";", "boolean", "canReverse", "=", "true", ";", "boolean", "reverse", "=", "false", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "count", ";", "i", "++", ")", "{", "Direction", "candidateOrder", "=", "candidate", ".", "getPropertyDirection", "(", "i", ")", ";", "if", "(", "candidateOrder", "==", "Direction", ".", "UNSPECIFIED", ")", "{", "// Property direction is unspecified, so no need to compare\r", "// direction. Move on to next property.\r", "continue", ";", "}", "Direction", "memberOrder", "=", "member", ".", "getPropertyDirection", "(", "i", ")", ";", "if", "(", "memberOrder", "==", "Direction", ".", "UNSPECIFIED", ")", "{", "// Candidate index is more qualified because member\r", "// property under examination hasn't specified a\r", "// direction. Move on to next property to continue checking\r", "// if a merge is possible.\r", "moreQualified", "=", "true", ";", "continue", ";", "}", "if", "(", "reverse", ")", "{", "candidateOrder", "=", "candidateOrder", ".", "reverse", "(", ")", ";", "}", "if", "(", "candidateOrder", "==", "memberOrder", ")", "{", "// Direction exactly matches, move on to next property.\r", "canReverse", "=", "false", ";", "continue", ";", "}", "// If this point is reached, then the direction would match if\r", "// one was reversed. For an index to fully match, all\r", "// properties must be reversed.\r", "if", "(", "canReverse", ")", "{", "// Switch to reverse mode and move on to next property.\r", "reverse", "=", "true", ";", "canReverse", "=", "false", ";", "continue", ";", "}", "// Match failed and merge is not possible.\r", "continue", "groupScan", ";", "}", "if", "(", "moreQualified", ")", "{", "// Candidate is more qualified than all members compared to so\r", "// far, but it can be merged. Once merged, it is redundant.\r", "Direction", "[", "]", "directions", "=", "member", ".", "getPropertyDirections", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "count", ";", "i", "++", ")", "{", "if", "(", "directions", "[", "i", "]", "==", "Direction", ".", "UNSPECIFIED", ")", "{", "Direction", "direction", "=", "candidate", ".", "getPropertyDirection", "(", "i", ")", ";", "directions", "[", "i", "]", "=", "reverse", "?", "direction", ".", "reverse", "(", ")", ":", "direction", ";", "}", "}", "StorableIndex", "<", "S", ">", "merged", "=", "new", "StorableIndex", "<", "S", ">", "(", "member", ".", "getProperties", "(", ")", ",", "directions", ")", ".", "unique", "(", "member", ".", "isUnique", "(", ")", ")", ";", "mergedReplacements", ".", "put", "(", "member", ",", "merged", ")", ";", "it", ".", "set", "(", "merged", ")", ";", "}", "// Candidate is redundant.\r", "return", "true", ";", "}", "return", "false", ";", "}" ]
Returns true if candidate index is less qualified than an existing group member, or if it was merged with another group member. If it was merged, then an entry is placed in the merged map, and the given group list is updated.
[ "Returns", "true", "if", "candidate", "index", "is", "less", "qualified", "than", "an", "existing", "group", "member", "or", "if", "it", "was", "merged", "with", "another", "group", "member", ".", "If", "it", "was", "merged", "then", "an", "entry", "is", "placed", "in", "the", "merged", "map", "and", "the", "given", "group", "list", "is", "updated", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/StorableIndexSet.java#L379-L460
7,805
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/repo/map/MapStorage.java
MapStorage.doTryUpdateNoLock
private boolean doTryUpdateNoLock(S storable) { S existing = mMap.get(new Key<S>(storable, mFullComparator)); if (existing == null) { return false; } else { // Copy altered values to existing object. existing.markAllPropertiesDirty(); storable.copyDirtyProperties(existing); existing.markAllPropertiesClean(); // Copy all values to user object, to simulate a reload. storable.markAllPropertiesDirty(); existing.copyAllProperties(storable); storable.markAllPropertiesClean(); return true; } }
java
private boolean doTryUpdateNoLock(S storable) { S existing = mMap.get(new Key<S>(storable, mFullComparator)); if (existing == null) { return false; } else { // Copy altered values to existing object. existing.markAllPropertiesDirty(); storable.copyDirtyProperties(existing); existing.markAllPropertiesClean(); // Copy all values to user object, to simulate a reload. storable.markAllPropertiesDirty(); existing.copyAllProperties(storable); storable.markAllPropertiesClean(); return true; } }
[ "private", "boolean", "doTryUpdateNoLock", "(", "S", "storable", ")", "{", "S", "existing", "=", "mMap", ".", "get", "(", "new", "Key", "<", "S", ">", "(", "storable", ",", "mFullComparator", ")", ")", ";", "if", "(", "existing", "==", "null", ")", "{", "return", "false", ";", "}", "else", "{", "// Copy altered values to existing object.\r", "existing", ".", "markAllPropertiesDirty", "(", ")", ";", "storable", ".", "copyDirtyProperties", "(", "existing", ")", ";", "existing", ".", "markAllPropertiesClean", "(", ")", ";", "// Copy all values to user object, to simulate a reload.\r", "storable", ".", "markAllPropertiesDirty", "(", ")", ";", "existing", ".", "copyAllProperties", "(", "storable", ")", ";", "storable", ".", "markAllPropertiesClean", "(", ")", ";", "return", "true", ";", "}", "}" ]
Caller must hold write lock.
[ "Caller", "must", "hold", "write", "lock", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/repo/map/MapStorage.java#L389-L406
7,806
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/repo/map/MapStorage.java
MapStorage.mapPut
void mapPut(S storable) { mMap.put(new Key<S>(storable, mFullComparator), storable); }
java
void mapPut(S storable) { mMap.put(new Key<S>(storable, mFullComparator), storable); }
[ "void", "mapPut", "(", "S", "storable", ")", "{", "mMap", ".", "put", "(", "new", "Key", "<", "S", ">", "(", "storable", ",", "mFullComparator", ")", ",", "storable", ")", ";", "}" ]
Called by MapTransaction, which implicitly holds lock.
[ "Called", "by", "MapTransaction", "which", "implicitly", "holds", "lock", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/repo/map/MapStorage.java#L448-L450
7,807
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/synthetic/SyntheticPropertyList.java
SyntheticPropertyList.addProperty
public void addProperty(String propertyName, Direction direction) { if (propertyName == null) { throw new IllegalArgumentException(); } if (direction == null) { direction = Direction.UNSPECIFIED; } if (direction != Direction.UNSPECIFIED) { if (propertyName.length() > 0) { if (propertyName.charAt(0) == '-' || propertyName.charAt(0) == '+') { // Overrule the direction. propertyName = propertyName.substring(1); } } propertyName = direction.toCharacter() + propertyName; } mPropertyList.add(propertyName); }
java
public void addProperty(String propertyName, Direction direction) { if (propertyName == null) { throw new IllegalArgumentException(); } if (direction == null) { direction = Direction.UNSPECIFIED; } if (direction != Direction.UNSPECIFIED) { if (propertyName.length() > 0) { if (propertyName.charAt(0) == '-' || propertyName.charAt(0) == '+') { // Overrule the direction. propertyName = propertyName.substring(1); } } propertyName = direction.toCharacter() + propertyName; } mPropertyList.add(propertyName); }
[ "public", "void", "addProperty", "(", "String", "propertyName", ",", "Direction", "direction", ")", "{", "if", "(", "propertyName", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", ")", ";", "}", "if", "(", "direction", "==", "null", ")", "{", "direction", "=", "Direction", ".", "UNSPECIFIED", ";", "}", "if", "(", "direction", "!=", "Direction", ".", "UNSPECIFIED", ")", "{", "if", "(", "propertyName", ".", "length", "(", ")", ">", "0", ")", "{", "if", "(", "propertyName", ".", "charAt", "(", "0", ")", "==", "'", "'", "||", "propertyName", ".", "charAt", "(", "0", ")", "==", "'", "'", ")", "{", "// Overrule the direction.\r", "propertyName", "=", "propertyName", ".", "substring", "(", "1", ")", ";", "}", "}", "propertyName", "=", "direction", ".", "toCharacter", "(", ")", "+", "propertyName", ";", "}", "mPropertyList", ".", "add", "(", "propertyName", ")", ";", "}" ]
Adds a property to this index, with the specified direction. @param propertyName name of property to add to index @param direction optional direction of property
[ "Adds", "a", "property", "to", "this", "index", "with", "the", "specified", "direction", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/synthetic/SyntheticPropertyList.java#L56-L75
7,808
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/cursor/SortedCursor.java
SortedCursor.createComparator
public static <S> Comparator<S> createComparator(Class<S> type, String... orderProperties) { BeanComparator bc = BeanComparator.forClass(type); if (Storable.class.isAssignableFrom(type)) { StorableInfo info = StorableIntrospector.examine((Class) type); for (String property : orderProperties) { bc = orderBy(bc, OrderedProperty.parse(info, property)); } } else { for (String property : orderProperties) { Class propertyType; { String name = property; if (name.startsWith("+") || name.startsWith("-")) { name = name.substring(1); } propertyType = propertyType(type, name); } bc = orderBy(bc, property, propertyType, Direction.ASCENDING); } } return bc; }
java
public static <S> Comparator<S> createComparator(Class<S> type, String... orderProperties) { BeanComparator bc = BeanComparator.forClass(type); if (Storable.class.isAssignableFrom(type)) { StorableInfo info = StorableIntrospector.examine((Class) type); for (String property : orderProperties) { bc = orderBy(bc, OrderedProperty.parse(info, property)); } } else { for (String property : orderProperties) { Class propertyType; { String name = property; if (name.startsWith("+") || name.startsWith("-")) { name = name.substring(1); } propertyType = propertyType(type, name); } bc = orderBy(bc, property, propertyType, Direction.ASCENDING); } } return bc; }
[ "public", "static", "<", "S", ">", "Comparator", "<", "S", ">", "createComparator", "(", "Class", "<", "S", ">", "type", ",", "String", "...", "orderProperties", ")", "{", "BeanComparator", "bc", "=", "BeanComparator", ".", "forClass", "(", "type", ")", ";", "if", "(", "Storable", ".", "class", ".", "isAssignableFrom", "(", "type", ")", ")", "{", "StorableInfo", "info", "=", "StorableIntrospector", ".", "examine", "(", "(", "Class", ")", "type", ")", ";", "for", "(", "String", "property", ":", "orderProperties", ")", "{", "bc", "=", "orderBy", "(", "bc", ",", "OrderedProperty", ".", "parse", "(", "info", ",", "property", ")", ")", ";", "}", "}", "else", "{", "for", "(", "String", "property", ":", "orderProperties", ")", "{", "Class", "propertyType", ";", "{", "String", "name", "=", "property", ";", "if", "(", "name", ".", "startsWith", "(", "\"+\"", ")", "||", "name", ".", "startsWith", "(", "\"-\"", ")", ")", "{", "name", "=", "name", ".", "substring", "(", "1", ")", ";", "}", "propertyType", "=", "propertyType", "(", "type", ",", "name", ")", ";", "}", "bc", "=", "orderBy", "(", "bc", ",", "property", ",", "propertyType", ",", "Direction", ".", "ASCENDING", ")", ";", "}", "}", "return", "bc", ";", "}" ]
Convenience method to create a comparator which orders storables by the given order-by properties. The property names may be prefixed with '+' or '-' to indicate ascending or descending order. If the prefix is omitted, ascending order is assumed. @param type type of storable to create comparator for @param orderProperties list of properties to order by @throws IllegalArgumentException if any property is null or not a member of storable type
[ "Convenience", "method", "to", "create", "a", "comparator", "which", "orders", "storables", "by", "the", "given", "order", "-", "by", "properties", ".", "The", "property", "names", "may", "be", "prefixed", "with", "+", "or", "-", "to", "indicate", "ascending", "or", "descending", "order", ".", "If", "the", "prefix", "is", "omitted", "ascending", "order", "is", "assumed", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/cursor/SortedCursor.java#L67-L90
7,809
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/cursor/SortedCursor.java
SortedCursor.createComparator
public static <S extends Storable> Comparator<S> createComparator(OrderedProperty<S>... properties) { if (properties == null || properties.length == 0 || properties[0] == null) { throw new IllegalArgumentException(); } Class<S> type = properties[0].getChainedProperty().getPrimeProperty().getEnclosingType(); BeanComparator bc = BeanComparator.forClass(type); for (OrderedProperty<S> property : properties) { if (property == null) { throw new IllegalArgumentException(); } bc = orderBy(bc, property); } return bc; }
java
public static <S extends Storable> Comparator<S> createComparator(OrderedProperty<S>... properties) { if (properties == null || properties.length == 0 || properties[0] == null) { throw new IllegalArgumentException(); } Class<S> type = properties[0].getChainedProperty().getPrimeProperty().getEnclosingType(); BeanComparator bc = BeanComparator.forClass(type); for (OrderedProperty<S> property : properties) { if (property == null) { throw new IllegalArgumentException(); } bc = orderBy(bc, property); } return bc; }
[ "public", "static", "<", "S", "extends", "Storable", ">", "Comparator", "<", "S", ">", "createComparator", "(", "OrderedProperty", "<", "S", ">", "...", "properties", ")", "{", "if", "(", "properties", "==", "null", "||", "properties", ".", "length", "==", "0", "||", "properties", "[", "0", "]", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", ")", ";", "}", "Class", "<", "S", ">", "type", "=", "properties", "[", "0", "]", ".", "getChainedProperty", "(", ")", ".", "getPrimeProperty", "(", ")", ".", "getEnclosingType", "(", ")", ";", "BeanComparator", "bc", "=", "BeanComparator", ".", "forClass", "(", "type", ")", ";", "for", "(", "OrderedProperty", "<", "S", ">", "property", ":", "properties", ")", "{", "if", "(", "property", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", ")", ";", "}", "bc", "=", "orderBy", "(", "bc", ",", "property", ")", ";", "}", "return", "bc", ";", "}" ]
Convenience method to create a comparator which orders storables by the given properties. @param properties list of properties to order by @throws IllegalArgumentException if no properties or if any property is null
[ "Convenience", "method", "to", "create", "a", "comparator", "which", "orders", "storables", "by", "the", "given", "properties", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/cursor/SortedCursor.java#L118-L137
7,810
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/cursor/SortedCursor.java
SortedCursor.chainToBeanString
private static String chainToBeanString(ChainedProperty property) { int count = property.getChainCount(); if (count <= 0) { return property.getPrimeProperty().getBeanName(); } StringBuilder b = new StringBuilder(); b.append(property.getPrimeProperty().getBeanName()); for (int i=0; i<count; i++) { b.append('.'); b.append(property.getChainedProperty(i).getBeanName()); } return b.toString(); }
java
private static String chainToBeanString(ChainedProperty property) { int count = property.getChainCount(); if (count <= 0) { return property.getPrimeProperty().getBeanName(); } StringBuilder b = new StringBuilder(); b.append(property.getPrimeProperty().getBeanName()); for (int i=0; i<count; i++) { b.append('.'); b.append(property.getChainedProperty(i).getBeanName()); } return b.toString(); }
[ "private", "static", "String", "chainToBeanString", "(", "ChainedProperty", "property", ")", "{", "int", "count", "=", "property", ".", "getChainCount", "(", ")", ";", "if", "(", "count", "<=", "0", ")", "{", "return", "property", ".", "getPrimeProperty", "(", ")", ".", "getBeanName", "(", ")", ";", "}", "StringBuilder", "b", "=", "new", "StringBuilder", "(", ")", ";", "b", ".", "append", "(", "property", ".", "getPrimeProperty", "(", ")", ".", "getBeanName", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "count", ";", "i", "++", ")", "{", "b", ".", "append", "(", "'", "'", ")", ";", "b", ".", "append", "(", "property", ".", "getChainedProperty", "(", "i", ")", ".", "getBeanName", "(", ")", ")", ";", "}", "return", "b", ".", "toString", "(", ")", ";", "}" ]
Creates a dotted name string using the bean property names.
[ "Creates", "a", "dotted", "name", "string", "using", "the", "bean", "property", "names", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/cursor/SortedCursor.java#L207-L221
7,811
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/cursor/SortedCursor.java
SortedCursor.comparator
public Comparator<S> comparator() { if (mChunkMatcher == null) { return mChunkSorter; } return new Comparator<S>() { public int compare(S a, S b) { int result = mChunkMatcher.compare(a, b); if (result == 0) { result = mChunkSorter.compare(a, b); } return result; } }; }
java
public Comparator<S> comparator() { if (mChunkMatcher == null) { return mChunkSorter; } return new Comparator<S>() { public int compare(S a, S b) { int result = mChunkMatcher.compare(a, b); if (result == 0) { result = mChunkSorter.compare(a, b); } return result; } }; }
[ "public", "Comparator", "<", "S", ">", "comparator", "(", ")", "{", "if", "(", "mChunkMatcher", "==", "null", ")", "{", "return", "mChunkSorter", ";", "}", "return", "new", "Comparator", "<", "S", ">", "(", ")", "{", "public", "int", "compare", "(", "S", "a", ",", "S", "b", ")", "{", "int", "result", "=", "mChunkMatcher", ".", "compare", "(", "a", ",", "b", ")", ";", "if", "(", "result", "==", "0", ")", "{", "result", "=", "mChunkSorter", ".", "compare", "(", "a", ",", "b", ")", ";", "}", "return", "result", ";", "}", "}", ";", "}" ]
Returns a comparator representing the effective sort order of this cursor.
[ "Returns", "a", "comparator", "representing", "the", "effective", "sort", "order", "of", "this", "cursor", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/cursor/SortedCursor.java#L277-L290
7,812
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/repo/jdbc/SQLStatement.java
SQLStatement.buildStatement
public String buildStatement(int initialCapacity, FilterValues<S> filterValues) { StringBuilder b = new StringBuilder(initialCapacity); this.appendTo(b, filterValues); return b.toString(); }
java
public String buildStatement(int initialCapacity, FilterValues<S> filterValues) { StringBuilder b = new StringBuilder(initialCapacity); this.appendTo(b, filterValues); return b.toString(); }
[ "public", "String", "buildStatement", "(", "int", "initialCapacity", ",", "FilterValues", "<", "S", ">", "filterValues", ")", "{", "StringBuilder", "b", "=", "new", "StringBuilder", "(", "initialCapacity", ")", ";", "this", ".", "appendTo", "(", "b", ",", "filterValues", ")", ";", "return", "b", ".", "toString", "(", ")", ";", "}" ]
Builds a statement string from the given values. @param initialCapacity expected size of finished string length. Should be value returned from maxLength. @param filterValues values may be needed to build complete statement
[ "Builds", "a", "statement", "string", "from", "the", "given", "values", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/repo/jdbc/SQLStatement.java#L41-L45
7,813
michael-rapp/AndroidMaterialValidation
library/src/main/java/de/mrapp/android/validation/Validators.java
Validators.conjunctive
@SafeVarargs public static <Type> Validator<Type> conjunctive(@NonNull final Context context, @NonNull final Validator<Type>... validators) { return ConjunctiveValidator.create(context, R.string.default_error_message, validators); }
java
@SafeVarargs public static <Type> Validator<Type> conjunctive(@NonNull final Context context, @NonNull final Validator<Type>... validators) { return ConjunctiveValidator.create(context, R.string.default_error_message, validators); }
[ "@", "SafeVarargs", "public", "static", "<", "Type", ">", "Validator", "<", "Type", ">", "conjunctive", "(", "@", "NonNull", "final", "Context", "context", ",", "@", "NonNull", "final", "Validator", "<", "Type", ">", "...", "validators", ")", "{", "return", "ConjunctiveValidator", ".", "create", "(", "context", ",", "R", ".", "string", ".", "default_error_message", ",", "validators", ")", ";", "}" ]
Creates and returns a validator, which allows to combine multiple validators in a conjunctive manner. If all single validators succeed, the resulting validator will also succeed. @param <Type> The type of the values, which should be validated @param context The context, which should be used to retrieve the error message, as an instance of the class {@link Context}. The context may not be null @param validators The single validators, the validator should consist of, as an array of the type {@link Validator}. The validators may neither be null, nor empty @return The validator, which has been created, as an instance of the type {@link Validator}
[ "Creates", "and", "returns", "a", "validator", "which", "allows", "to", "combine", "multiple", "validators", "in", "a", "conjunctive", "manner", ".", "If", "all", "single", "validators", "succeed", "the", "resulting", "validator", "will", "also", "succeed", "." ]
ac8693baeac7abddf2e38a47da4c1849d4661a8b
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/Validators.java#L178-L182
7,814
michael-rapp/AndroidMaterialValidation
library/src/main/java/de/mrapp/android/validation/Validators.java
Validators.regex
public static Validator<CharSequence> regex(@NonNull final CharSequence errorMessage, @NonNull final Pattern regex) { return new RegexValidator(errorMessage, regex); }
java
public static Validator<CharSequence> regex(@NonNull final CharSequence errorMessage, @NonNull final Pattern regex) { return new RegexValidator(errorMessage, regex); }
[ "public", "static", "Validator", "<", "CharSequence", ">", "regex", "(", "@", "NonNull", "final", "CharSequence", "errorMessage", ",", "@", "NonNull", "final", "Pattern", "regex", ")", "{", "return", "new", "RegexValidator", "(", "errorMessage", ",", "regex", ")", ";", "}" ]
Creates and returns a validator, which allows to validate texts to ensure, that they match a certain regular expression. @param errorMessage The error message, which should be shown, if the validation fails, as an instance of the type {@link CharSequence}. The error message may not be null @param regex The regular expression, which should be used to validate the texts, as an instance of the class {@link Pattern}. The regular expression may not be null @return The validator, which has been created, as an instance of the type {@link Validator}
[ "Creates", "and", "returns", "a", "validator", "which", "allows", "to", "validate", "texts", "to", "ensure", "that", "they", "match", "a", "certain", "regular", "expression", "." ]
ac8693baeac7abddf2e38a47da4c1849d4661a8b
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/Validators.java#L302-L305
7,815
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/spi/AbstractRepositoryBuilder.java
AbstractRepositoryBuilder.assertReady
public final void assertReady() throws ConfigurationException { ArrayList<String> messages = new ArrayList<String>(); errorCheck(messages); int size = messages.size(); if (size == 0) { return; } StringBuilder b = new StringBuilder(); if (size > 1) { b.append("Multiple problems: "); } for (int i=0; i<size; i++) { if (i > 0) { b.append("; "); } b.append(messages.get(i)); } throw new ConfigurationException(b.toString()); }
java
public final void assertReady() throws ConfigurationException { ArrayList<String> messages = new ArrayList<String>(); errorCheck(messages); int size = messages.size(); if (size == 0) { return; } StringBuilder b = new StringBuilder(); if (size > 1) { b.append("Multiple problems: "); } for (int i=0; i<size; i++) { if (i > 0) { b.append("; "); } b.append(messages.get(i)); } throw new ConfigurationException(b.toString()); }
[ "public", "final", "void", "assertReady", "(", ")", "throws", "ConfigurationException", "{", "ArrayList", "<", "String", ">", "messages", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "errorCheck", "(", "messages", ")", ";", "int", "size", "=", "messages", ".", "size", "(", ")", ";", "if", "(", "size", "==", "0", ")", "{", "return", ";", "}", "StringBuilder", "b", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "size", ">", "1", ")", "{", "b", ".", "append", "(", "\"Multiple problems: \"", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "size", ";", "i", "++", ")", "{", "if", "(", "i", ">", "0", ")", "{", "b", ".", "append", "(", "\"; \"", ")", ";", "}", "b", ".", "append", "(", "messages", ".", "get", "(", "i", ")", ")", ";", "}", "throw", "new", "ConfigurationException", "(", "b", ".", "toString", "(", ")", ")", ";", "}" ]
Throw a configuration exception if the configuration is not filled out sufficiently and correctly such that a repository could be instantiated from it.
[ "Throw", "a", "configuration", "exception", "if", "the", "configuration", "is", "not", "filled", "out", "sufficiently", "and", "correctly", "such", "that", "a", "repository", "could", "be", "instantiated", "from", "it", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/spi/AbstractRepositoryBuilder.java#L78-L96
7,816
michael-rapp/AndroidMaterialValidation
example/src/main/java/de/mrapp/android/validation/example/MainActivity.java
MainActivity.initializeUsernameEditText
private void initializeUsernameEditText() { usernameEditText = (EditText) findViewById(R.id.username_edit_text); usernameEditText.addValidator( Validators.notEmpty(this, R.string.not_empty_validator_error_message)); usernameEditText.addValidator(Validators .maxLength(this, R.string.max_length_validator_error_messsage, MAX_CHARACTERS)); usernameEditText.addValidator(Validators .letterOrNumber(this, R.string.letter_or_number_validator_error_message, Case.CASE_INSENSITIVE, false, new char[]{'-', '_'})); }
java
private void initializeUsernameEditText() { usernameEditText = (EditText) findViewById(R.id.username_edit_text); usernameEditText.addValidator( Validators.notEmpty(this, R.string.not_empty_validator_error_message)); usernameEditText.addValidator(Validators .maxLength(this, R.string.max_length_validator_error_messsage, MAX_CHARACTERS)); usernameEditText.addValidator(Validators .letterOrNumber(this, R.string.letter_or_number_validator_error_message, Case.CASE_INSENSITIVE, false, new char[]{'-', '_'})); }
[ "private", "void", "initializeUsernameEditText", "(", ")", "{", "usernameEditText", "=", "(", "EditText", ")", "findViewById", "(", "R", ".", "id", ".", "username_edit_text", ")", ";", "usernameEditText", ".", "addValidator", "(", "Validators", ".", "notEmpty", "(", "this", ",", "R", ".", "string", ".", "not_empty_validator_error_message", ")", ")", ";", "usernameEditText", ".", "addValidator", "(", "Validators", ".", "maxLength", "(", "this", ",", "R", ".", "string", ".", "max_length_validator_error_messsage", ",", "MAX_CHARACTERS", ")", ")", ";", "usernameEditText", ".", "addValidator", "(", "Validators", ".", "letterOrNumber", "(", "this", ",", "R", ".", "string", ".", "letter_or_number_validator_error_message", ",", "Case", ".", "CASE_INSENSITIVE", ",", "false", ",", "new", "char", "[", "]", "{", "'", "'", ",", "'", "'", "}", ")", ")", ";", "}" ]
Initializes the edit text, which allows to enter an username.
[ "Initializes", "the", "edit", "text", "which", "allows", "to", "enter", "an", "username", "." ]
ac8693baeac7abddf2e38a47da4c1849d4661a8b
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/example/src/main/java/de/mrapp/android/validation/example/MainActivity.java#L94-L103
7,817
michael-rapp/AndroidMaterialValidation
example/src/main/java/de/mrapp/android/validation/example/MainActivity.java
MainActivity.initializePasswordEditText
private void initializePasswordEditText() { passwordEditText = (PasswordEditText) findViewById(R.id.password_edit_text); passwordEditText.addValidator(Validators .minLength(this, R.string.password_min_length_validator_error_message, MIN_PASSWORD_LENGTH)); passwordEditText.addValidator(Validators .maxLength(this, R.string.max_length_validator_error_messsage, MAX_CHARACTERS)); passwordEditText.addValidator( Validators.noWhitespace(this, R.string.no_whitespace_validator_error_message)); passwordEditText.addAllConstraints(Constraints.minLength(SUGGESTED_PASSWORD_LENGTH), Constraints.containsLetter(), Constraints.containsNumber(), Constraints.containsSymbol()); passwordEditText.addAllHelperTextIds(R.string.password_edit_text_helper_text0, R.string.password_edit_text_helper_text1, R.string.password_edit_text_helper_text2, R.string.password_edit_text_helper_text3, R.string.password_edit_text_helper_text4); passwordEditText.addAllHelperTextColorIds(R.color.password_edit_text_helper_text_color0, R.color.password_edit_text_helper_text_color1, R.color.password_edit_text_helper_text_color2, R.color.password_edit_text_helper_text_color3, R.color.password_edit_text_helper_text_color4); }
java
private void initializePasswordEditText() { passwordEditText = (PasswordEditText) findViewById(R.id.password_edit_text); passwordEditText.addValidator(Validators .minLength(this, R.string.password_min_length_validator_error_message, MIN_PASSWORD_LENGTH)); passwordEditText.addValidator(Validators .maxLength(this, R.string.max_length_validator_error_messsage, MAX_CHARACTERS)); passwordEditText.addValidator( Validators.noWhitespace(this, R.string.no_whitespace_validator_error_message)); passwordEditText.addAllConstraints(Constraints.minLength(SUGGESTED_PASSWORD_LENGTH), Constraints.containsLetter(), Constraints.containsNumber(), Constraints.containsSymbol()); passwordEditText.addAllHelperTextIds(R.string.password_edit_text_helper_text0, R.string.password_edit_text_helper_text1, R.string.password_edit_text_helper_text2, R.string.password_edit_text_helper_text3, R.string.password_edit_text_helper_text4); passwordEditText.addAllHelperTextColorIds(R.color.password_edit_text_helper_text_color0, R.color.password_edit_text_helper_text_color1, R.color.password_edit_text_helper_text_color2, R.color.password_edit_text_helper_text_color3, R.color.password_edit_text_helper_text_color4); }
[ "private", "void", "initializePasswordEditText", "(", ")", "{", "passwordEditText", "=", "(", "PasswordEditText", ")", "findViewById", "(", "R", ".", "id", ".", "password_edit_text", ")", ";", "passwordEditText", ".", "addValidator", "(", "Validators", ".", "minLength", "(", "this", ",", "R", ".", "string", ".", "password_min_length_validator_error_message", ",", "MIN_PASSWORD_LENGTH", ")", ")", ";", "passwordEditText", ".", "addValidator", "(", "Validators", ".", "maxLength", "(", "this", ",", "R", ".", "string", ".", "max_length_validator_error_messsage", ",", "MAX_CHARACTERS", ")", ")", ";", "passwordEditText", ".", "addValidator", "(", "Validators", ".", "noWhitespace", "(", "this", ",", "R", ".", "string", ".", "no_whitespace_validator_error_message", ")", ")", ";", "passwordEditText", ".", "addAllConstraints", "(", "Constraints", ".", "minLength", "(", "SUGGESTED_PASSWORD_LENGTH", ")", ",", "Constraints", ".", "containsLetter", "(", ")", ",", "Constraints", ".", "containsNumber", "(", ")", ",", "Constraints", ".", "containsSymbol", "(", ")", ")", ";", "passwordEditText", ".", "addAllHelperTextIds", "(", "R", ".", "string", ".", "password_edit_text_helper_text0", ",", "R", ".", "string", ".", "password_edit_text_helper_text1", ",", "R", ".", "string", ".", "password_edit_text_helper_text2", ",", "R", ".", "string", ".", "password_edit_text_helper_text3", ",", "R", ".", "string", ".", "password_edit_text_helper_text4", ")", ";", "passwordEditText", ".", "addAllHelperTextColorIds", "(", "R", ".", "color", ".", "password_edit_text_helper_text_color0", ",", "R", ".", "color", ".", "password_edit_text_helper_text_color1", ",", "R", ".", "color", ".", "password_edit_text_helper_text_color2", ",", "R", ".", "color", ".", "password_edit_text_helper_text_color3", ",", "R", ".", "color", ".", "password_edit_text_helper_text_color4", ")", ";", "}" ]
Initializes the edit text, which allows to enter a password.
[ "Initializes", "the", "edit", "text", "which", "allows", "to", "enter", "a", "password", "." ]
ac8693baeac7abddf2e38a47da4c1849d4661a8b
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/example/src/main/java/de/mrapp/android/validation/example/MainActivity.java#L108-L128
7,818
michael-rapp/AndroidMaterialValidation
example/src/main/java/de/mrapp/android/validation/example/MainActivity.java
MainActivity.initializePasswordRepetitionEditText
private void initializePasswordRepetitionEditText() { passwordRepetitionEditText = (EditText) findViewById(R.id.password_repetition_edit_text); passwordRepetitionEditText.addValidator( Validators.equal(this, R.string.equal_validator_error_message, passwordEditText)); }
java
private void initializePasswordRepetitionEditText() { passwordRepetitionEditText = (EditText) findViewById(R.id.password_repetition_edit_text); passwordRepetitionEditText.addValidator( Validators.equal(this, R.string.equal_validator_error_message, passwordEditText)); }
[ "private", "void", "initializePasswordRepetitionEditText", "(", ")", "{", "passwordRepetitionEditText", "=", "(", "EditText", ")", "findViewById", "(", "R", ".", "id", ".", "password_repetition_edit_text", ")", ";", "passwordRepetitionEditText", ".", "addValidator", "(", "Validators", ".", "equal", "(", "this", ",", "R", ".", "string", ".", "equal_validator_error_message", ",", "passwordEditText", ")", ")", ";", "}" ]
Initializes the edit text, which allows to enter a password repetition.
[ "Initializes", "the", "edit", "text", "which", "allows", "to", "enter", "a", "password", "repetition", "." ]
ac8693baeac7abddf2e38a47da4c1849d4661a8b
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/example/src/main/java/de/mrapp/android/validation/example/MainActivity.java#L133-L137
7,819
michael-rapp/AndroidMaterialValidation
example/src/main/java/de/mrapp/android/validation/example/MainActivity.java
MainActivity.initializeGenderSpinner
private void initializeGenderSpinner() { genderSpinner = (Spinner) findViewById(R.id.gender_spinner); genderSpinner .addValidator(Validators.notNull(this, R.string.not_null_validator_error_message)); }
java
private void initializeGenderSpinner() { genderSpinner = (Spinner) findViewById(R.id.gender_spinner); genderSpinner .addValidator(Validators.notNull(this, R.string.not_null_validator_error_message)); }
[ "private", "void", "initializeGenderSpinner", "(", ")", "{", "genderSpinner", "=", "(", "Spinner", ")", "findViewById", "(", "R", ".", "id", ".", "gender_spinner", ")", ";", "genderSpinner", ".", "addValidator", "(", "Validators", ".", "notNull", "(", "this", ",", "R", ".", "string", ".", "not_null_validator_error_message", ")", ")", ";", "}" ]
Initializes the spinner, which allows to choose a gender.
[ "Initializes", "the", "spinner", "which", "allows", "to", "choose", "a", "gender", "." ]
ac8693baeac7abddf2e38a47da4c1849d4661a8b
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/example/src/main/java/de/mrapp/android/validation/example/MainActivity.java#L142-L146
7,820
michael-rapp/AndroidMaterialValidation
example/src/main/java/de/mrapp/android/validation/example/MainActivity.java
MainActivity.initializeFirstNameEditText
private void initializeFirstNameEditText() { firstNameEditText = (EditText) findViewById(R.id.first_name_edit_text); firstNameEditText.addValidator(Validators .minLength(this, R.string.min_length_validator_error_message, MIN_NAME_LENGTH)); firstNameEditText.addValidator(Validators.beginsWithUppercaseLetter(this, R.string.begins_with_uppercase_letter_validator_error_message)); firstNameEditText.addValidator(Validators .letter(this, R.string.letter_validator_error_message, Case.CASE_INSENSITIVE, false, new char[]{'-'})); }
java
private void initializeFirstNameEditText() { firstNameEditText = (EditText) findViewById(R.id.first_name_edit_text); firstNameEditText.addValidator(Validators .minLength(this, R.string.min_length_validator_error_message, MIN_NAME_LENGTH)); firstNameEditText.addValidator(Validators.beginsWithUppercaseLetter(this, R.string.begins_with_uppercase_letter_validator_error_message)); firstNameEditText.addValidator(Validators .letter(this, R.string.letter_validator_error_message, Case.CASE_INSENSITIVE, false, new char[]{'-'})); }
[ "private", "void", "initializeFirstNameEditText", "(", ")", "{", "firstNameEditText", "=", "(", "EditText", ")", "findViewById", "(", "R", ".", "id", ".", "first_name_edit_text", ")", ";", "firstNameEditText", ".", "addValidator", "(", "Validators", ".", "minLength", "(", "this", ",", "R", ".", "string", ".", "min_length_validator_error_message", ",", "MIN_NAME_LENGTH", ")", ")", ";", "firstNameEditText", ".", "addValidator", "(", "Validators", ".", "beginsWithUppercaseLetter", "(", "this", ",", "R", ".", "string", ".", "begins_with_uppercase_letter_validator_error_message", ")", ")", ";", "firstNameEditText", ".", "addValidator", "(", "Validators", ".", "letter", "(", "this", ",", "R", ".", "string", ".", "letter_validator_error_message", ",", "Case", ".", "CASE_INSENSITIVE", ",", "false", ",", "new", "char", "[", "]", "{", "'", "'", "}", ")", ")", ";", "}" ]
Initializes the edit text, which allows to enter a first name.
[ "Initializes", "the", "edit", "text", "which", "allows", "to", "enter", "a", "first", "name", "." ]
ac8693baeac7abddf2e38a47da4c1849d4661a8b
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/example/src/main/java/de/mrapp/android/validation/example/MainActivity.java#L151-L160
7,821
michael-rapp/AndroidMaterialValidation
example/src/main/java/de/mrapp/android/validation/example/MainActivity.java
MainActivity.initializeLastNameEditText
private void initializeLastNameEditText() { lastNameEditText = (EditText) findViewById(R.id.last_name_edit_text); lastNameEditText.addValidator(Validators .minLength(this, R.string.min_length_validator_error_message, MIN_NAME_LENGTH)); lastNameEditText.addValidator(Validators.beginsWithUppercaseLetter(this, R.string.begins_with_uppercase_letter_validator_error_message)); lastNameEditText.addValidator(Validators .letter(this, R.string.letter_validator_error_message, Case.CASE_INSENSITIVE, false, new char[]{'-'})); }
java
private void initializeLastNameEditText() { lastNameEditText = (EditText) findViewById(R.id.last_name_edit_text); lastNameEditText.addValidator(Validators .minLength(this, R.string.min_length_validator_error_message, MIN_NAME_LENGTH)); lastNameEditText.addValidator(Validators.beginsWithUppercaseLetter(this, R.string.begins_with_uppercase_letter_validator_error_message)); lastNameEditText.addValidator(Validators .letter(this, R.string.letter_validator_error_message, Case.CASE_INSENSITIVE, false, new char[]{'-'})); }
[ "private", "void", "initializeLastNameEditText", "(", ")", "{", "lastNameEditText", "=", "(", "EditText", ")", "findViewById", "(", "R", ".", "id", ".", "last_name_edit_text", ")", ";", "lastNameEditText", ".", "addValidator", "(", "Validators", ".", "minLength", "(", "this", ",", "R", ".", "string", ".", "min_length_validator_error_message", ",", "MIN_NAME_LENGTH", ")", ")", ";", "lastNameEditText", ".", "addValidator", "(", "Validators", ".", "beginsWithUppercaseLetter", "(", "this", ",", "R", ".", "string", ".", "begins_with_uppercase_letter_validator_error_message", ")", ")", ";", "lastNameEditText", ".", "addValidator", "(", "Validators", ".", "letter", "(", "this", ",", "R", ".", "string", ".", "letter_validator_error_message", ",", "Case", ".", "CASE_INSENSITIVE", ",", "false", ",", "new", "char", "[", "]", "{", "'", "'", "}", ")", ")", ";", "}" ]
Initializes the edit text, which allows to enter a last name.
[ "Initializes", "the", "edit", "text", "which", "allows", "to", "enter", "a", "last", "name", "." ]
ac8693baeac7abddf2e38a47da4c1849d4661a8b
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/example/src/main/java/de/mrapp/android/validation/example/MainActivity.java#L165-L174
7,822
michael-rapp/AndroidMaterialValidation
example/src/main/java/de/mrapp/android/validation/example/MainActivity.java
MainActivity.initializeValidateButton
private void initializeValidateButton() { Button button = (Button) findViewById(R.id.validate_button); button.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { usernameEditText.validate(); passwordEditText.validate(); passwordRepetitionEditText.validate(); genderSpinner.validate(); firstNameEditText.validate(); lastNameEditText.validate(); additionalInformationEditText.validate(); } }); }
java
private void initializeValidateButton() { Button button = (Button) findViewById(R.id.validate_button); button.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { usernameEditText.validate(); passwordEditText.validate(); passwordRepetitionEditText.validate(); genderSpinner.validate(); firstNameEditText.validate(); lastNameEditText.validate(); additionalInformationEditText.validate(); } }); }
[ "private", "void", "initializeValidateButton", "(", ")", "{", "Button", "button", "=", "(", "Button", ")", "findViewById", "(", "R", ".", "id", ".", "validate_button", ")", ";", "button", ".", "setOnClickListener", "(", "new", "OnClickListener", "(", ")", "{", "@", "Override", "public", "void", "onClick", "(", "final", "View", "v", ")", "{", "usernameEditText", ".", "validate", "(", ")", ";", "passwordEditText", ".", "validate", "(", ")", ";", "passwordRepetitionEditText", ".", "validate", "(", ")", ";", "genderSpinner", ".", "validate", "(", ")", ";", "firstNameEditText", ".", "validate", "(", ")", ";", "lastNameEditText", ".", "validate", "(", ")", ";", "additionalInformationEditText", ".", "validate", "(", ")", ";", "}", "}", ")", ";", "}" ]
Initializes the button, which allows to validate the values of all views.
[ "Initializes", "the", "button", "which", "allows", "to", "validate", "the", "values", "of", "all", "views", "." ]
ac8693baeac7abddf2e38a47da4c1849d4661a8b
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/example/src/main/java/de/mrapp/android/validation/example/MainActivity.java#L187-L203
7,823
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/repo/jdbc/LoggingDataSource.java
LoggingDataSource.create
public static DataSource create(DataSource ds, Log log) { if (ds == null) { throw new IllegalArgumentException(); } if (log == null) { log = LogFactory.getLog(LoggingDataSource.class); } if (!log.isDebugEnabled()) { return ds; } return new LoggingDataSource(log, ds); }
java
public static DataSource create(DataSource ds, Log log) { if (ds == null) { throw new IllegalArgumentException(); } if (log == null) { log = LogFactory.getLog(LoggingDataSource.class); } if (!log.isDebugEnabled()) { return ds; } return new LoggingDataSource(log, ds); }
[ "public", "static", "DataSource", "create", "(", "DataSource", "ds", ",", "Log", "log", ")", "{", "if", "(", "ds", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", ")", ";", "}", "if", "(", "log", "==", "null", ")", "{", "log", "=", "LogFactory", ".", "getLog", "(", "LoggingDataSource", ".", "class", ")", ";", "}", "if", "(", "!", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "return", "ds", ";", "}", "return", "new", "LoggingDataSource", "(", "log", ",", "ds", ")", ";", "}" ]
Wraps the given DataSource which logs to the given log. If debug logging is disabled, the original DataSource is returned.
[ "Wraps", "the", "given", "DataSource", "which", "logs", "to", "the", "given", "log", ".", "If", "debug", "logging", "is", "disabled", "the", "original", "DataSource", "is", "returned", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/repo/jdbc/LoggingDataSource.java#L48-L59
7,824
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/repo/sleepycat/BDBStorage.java
BDBStorage.getPrimaryDatabase
Object getPrimaryDatabase() throws FetchException { Object database = mPrimaryDatabase; if (database == null) { checkClosed(); throw new IllegalStateException("BDBStorage not opened"); } return database; }
java
Object getPrimaryDatabase() throws FetchException { Object database = mPrimaryDatabase; if (database == null) { checkClosed(); throw new IllegalStateException("BDBStorage not opened"); } return database; }
[ "Object", "getPrimaryDatabase", "(", ")", "throws", "FetchException", "{", "Object", "database", "=", "mPrimaryDatabase", ";", "if", "(", "database", "==", "null", ")", "{", "checkClosed", "(", ")", ";", "throw", "new", "IllegalStateException", "(", "\"BDBStorage not opened\"", ")", ";", "}", "return", "database", ";", "}" ]
Caller must hold transaction lock. May throw FetchException if storage is closed.
[ "Caller", "must", "hold", "transaction", "lock", ".", "May", "throw", "FetchException", "if", "storage", "is", "closed", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBStorage.java#L739-L746
7,825
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/repo/sleepycat/BDBStorage.java
BDBStorage.checkClosed
void checkClosed() throws FetchException { TransactionScope<Txn> scope = localTransactionScope(); // Lock out shutdown task. scope.getLock().lock(); try { if (mPrimaryDatabase == null) { // If shutting down, this will force us to block forever. try { scope.getTxn(); } catch (Exception e) { // Don't care. } // Okay, not shutting down, so throw exception. throw new FetchException("Repository closed"); } } finally { scope.getLock().unlock(); } }
java
void checkClosed() throws FetchException { TransactionScope<Txn> scope = localTransactionScope(); // Lock out shutdown task. scope.getLock().lock(); try { if (mPrimaryDatabase == null) { // If shutting down, this will force us to block forever. try { scope.getTxn(); } catch (Exception e) { // Don't care. } // Okay, not shutting down, so throw exception. throw new FetchException("Repository closed"); } } finally { scope.getLock().unlock(); } }
[ "void", "checkClosed", "(", ")", "throws", "FetchException", "{", "TransactionScope", "<", "Txn", ">", "scope", "=", "localTransactionScope", "(", ")", ";", "// Lock out shutdown task.\r", "scope", ".", "getLock", "(", ")", ".", "lock", "(", ")", ";", "try", "{", "if", "(", "mPrimaryDatabase", "==", "null", ")", "{", "// If shutting down, this will force us to block forever.\r", "try", "{", "scope", ".", "getTxn", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "// Don't care.\r", "}", "// Okay, not shutting down, so throw exception.\r", "throw", "new", "FetchException", "(", "\"Repository closed\"", ")", ";", "}", "}", "finally", "{", "scope", ".", "getLock", "(", ")", ".", "unlock", "(", ")", ";", "}", "}" ]
If open, returns normally. If shutting down, blocks forever. Otherwise, if closed, throws FetchException. Method blocks forever on shutdown to prevent threads from starting work that will likely fail along the way.
[ "If", "open", "returns", "normally", ".", "If", "shutting", "down", "blocks", "forever", ".", "Otherwise", "if", "closed", "throws", "FetchException", ".", "Method", "blocks", "forever", "on", "shutdown", "to", "prevent", "threads", "from", "starting", "work", "that", "will", "likely", "fail", "along", "the", "way", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBStorage.java#L789-L808
7,826
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/qe/IndexedQueryAnalyzer.java
IndexedQueryAnalyzer.isProperJoin
private boolean isProperJoin(StorableProperty<?> property) throws SupportException, RepositoryException { if (!property.isJoin() || property.isQuery()) { return false; } // Make up a filter over the join's internal properties and then search // for an index that filters with no remainder. Filter<?> filter = Filter.getOpenFilter(property.getEnclosingType()); int count = property.getJoinElementCount(); for (int i=0; i<count; i++) { filter = filter.and(property.getInternalJoinElement(i).getName(), RelOp.EQ); } // Java generics are letting me down. I cannot use proper specification // because compiler gets confused with all the wildcards. Collection indexes = indexesFor(filter.getStorableType()); if (indexes != null) { for (Object index : indexes) { FilteringScore score = FilteringScore.evaluate((StorableIndex) index, filter); if (score.getRemainderCount() == 0) { return true; } } } return false; }
java
private boolean isProperJoin(StorableProperty<?> property) throws SupportException, RepositoryException { if (!property.isJoin() || property.isQuery()) { return false; } // Make up a filter over the join's internal properties and then search // for an index that filters with no remainder. Filter<?> filter = Filter.getOpenFilter(property.getEnclosingType()); int count = property.getJoinElementCount(); for (int i=0; i<count; i++) { filter = filter.and(property.getInternalJoinElement(i).getName(), RelOp.EQ); } // Java generics are letting me down. I cannot use proper specification // because compiler gets confused with all the wildcards. Collection indexes = indexesFor(filter.getStorableType()); if (indexes != null) { for (Object index : indexes) { FilteringScore score = FilteringScore.evaluate((StorableIndex) index, filter); if (score.getRemainderCount() == 0) { return true; } } } return false; }
[ "private", "boolean", "isProperJoin", "(", "StorableProperty", "<", "?", ">", "property", ")", "throws", "SupportException", ",", "RepositoryException", "{", "if", "(", "!", "property", ".", "isJoin", "(", ")", "||", "property", ".", "isQuery", "(", ")", ")", "{", "return", "false", ";", "}", "// Make up a filter over the join's internal properties and then search\r", "// for an index that filters with no remainder.\r", "Filter", "<", "?", ">", "filter", "=", "Filter", ".", "getOpenFilter", "(", "property", ".", "getEnclosingType", "(", ")", ")", ";", "int", "count", "=", "property", ".", "getJoinElementCount", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "count", ";", "i", "++", ")", "{", "filter", "=", "filter", ".", "and", "(", "property", ".", "getInternalJoinElement", "(", "i", ")", ".", "getName", "(", ")", ",", "RelOp", ".", "EQ", ")", ";", "}", "// Java generics are letting me down. I cannot use proper specification\r", "// because compiler gets confused with all the wildcards.\r", "Collection", "indexes", "=", "indexesFor", "(", "filter", ".", "getStorableType", "(", ")", ")", ";", "if", "(", "indexes", "!=", "null", ")", "{", "for", "(", "Object", "index", ":", "indexes", ")", "{", "FilteringScore", "score", "=", "FilteringScore", ".", "evaluate", "(", "(", "StorableIndex", ")", "index", ",", "filter", ")", ";", "if", "(", "score", ".", "getRemainderCount", "(", ")", "==", "0", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Checks if the property is a join and its internal properties are fully indexed.
[ "Checks", "if", "the", "property", "is", "a", "join", "and", "its", "internal", "properties", "are", "fully", "indexed", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/IndexedQueryAnalyzer.java#L250-L279
7,827
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/util/ConversionComparator.java
ConversionComparator.primitiveWidth
private static int primitiveWidth(TypeDesc type) { switch (type.getTypeCode()) { default: return 0; case TypeDesc.BOOLEAN_CODE: return 1; case TypeDesc.BYTE_CODE: return 2; case TypeDesc.SHORT_CODE: return 3; case TypeDesc.CHAR_CODE: return 4; case TypeDesc.INT_CODE: return 5; case TypeDesc.FLOAT_CODE: return 6; case TypeDesc.LONG_CODE: return 7; case TypeDesc.DOUBLE_CODE: return 8; } }
java
private static int primitiveWidth(TypeDesc type) { switch (type.getTypeCode()) { default: return 0; case TypeDesc.BOOLEAN_CODE: return 1; case TypeDesc.BYTE_CODE: return 2; case TypeDesc.SHORT_CODE: return 3; case TypeDesc.CHAR_CODE: return 4; case TypeDesc.INT_CODE: return 5; case TypeDesc.FLOAT_CODE: return 6; case TypeDesc.LONG_CODE: return 7; case TypeDesc.DOUBLE_CODE: return 8; } }
[ "private", "static", "int", "primitiveWidth", "(", "TypeDesc", "type", ")", "{", "switch", "(", "type", ".", "getTypeCode", "(", ")", ")", "{", "default", ":", "return", "0", ";", "case", "TypeDesc", ".", "BOOLEAN_CODE", ":", "return", "1", ";", "case", "TypeDesc", ".", "BYTE_CODE", ":", "return", "2", ";", "case", "TypeDesc", ".", "SHORT_CODE", ":", "return", "3", ";", "case", "TypeDesc", ".", "CHAR_CODE", ":", "return", "4", ";", "case", "TypeDesc", ".", "INT_CODE", ":", "return", "5", ";", "case", "TypeDesc", ".", "FLOAT_CODE", ":", "return", "6", ";", "case", "TypeDesc", ".", "LONG_CODE", ":", "return", "7", ";", "case", "TypeDesc", ".", "DOUBLE_CODE", ":", "return", "8", ";", "}", "}" ]
1 = boolean, 2 = byte, 3 = short, 4 = char, 5 = int, 6 = float, 7 = long, 8 = double
[ "1", "=", "boolean", "2", "=", "byte", "3", "=", "short", "4", "=", "char", "5", "=", "int", "6", "=", "float", "7", "=", "long", "8", "=", "double" ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/util/ConversionComparator.java#L179-L200
7,828
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/filter/PropertyFilter.java
PropertyFilter.getBoxedType
public Class<?> getBoxedType() { if (mBoxedType == null) { mBoxedType = TypeDesc.forClass(getType()).toObjectType().toClass(); } return mBoxedType; }
java
public Class<?> getBoxedType() { if (mBoxedType == null) { mBoxedType = TypeDesc.forClass(getType()).toObjectType().toClass(); } return mBoxedType; }
[ "public", "Class", "<", "?", ">", "getBoxedType", "(", ")", "{", "if", "(", "mBoxedType", "==", "null", ")", "{", "mBoxedType", "=", "TypeDesc", ".", "forClass", "(", "getType", "(", ")", ")", ".", "toObjectType", "(", ")", ".", "toClass", "(", ")", ";", "}", "return", "mBoxedType", ";", "}" ]
Returns the type of the ChainedProperty property, boxed into an object if primitive.
[ "Returns", "the", "type", "of", "the", "ChainedProperty", "property", "boxed", "into", "an", "object", "if", "primitive", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/filter/PropertyFilter.java#L200-L205
7,829
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/filter/PropertyFilter.java
PropertyFilter.constant
public PropertyFilter<S> constant(Object value) { if (mBindID == BOUND_CONSTANT) { if (mConstant == null) { if (value == null) { return this; } } else if (mConstant.equals(value)) { return this; } } return getCanonical(mProperty, mOp, adaptValue(value)); }
java
public PropertyFilter<S> constant(Object value) { if (mBindID == BOUND_CONSTANT) { if (mConstant == null) { if (value == null) { return this; } } else if (mConstant.equals(value)) { return this; } } return getCanonical(mProperty, mOp, adaptValue(value)); }
[ "public", "PropertyFilter", "<", "S", ">", "constant", "(", "Object", "value", ")", "{", "if", "(", "mBindID", "==", "BOUND_CONSTANT", ")", "{", "if", "(", "mConstant", "==", "null", ")", "{", "if", "(", "value", "==", "null", ")", "{", "return", "this", ";", "}", "}", "else", "if", "(", "mConstant", ".", "equals", "(", "value", ")", ")", "{", "return", "this", ";", "}", "}", "return", "getCanonical", "(", "mProperty", ",", "mOp", ",", "adaptValue", "(", "value", ")", ")", ";", "}" ]
Returns another PropertyFilter instance which is bound to the given constant value. @throws IllegalArgumentException if value is not compatible with property type
[ "Returns", "another", "PropertyFilter", "instance", "which", "is", "bound", "to", "the", "given", "constant", "value", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/filter/PropertyFilter.java#L284-L295
7,830
cose-wg/COSE-JAVA
src/main/java/COSE/ASN1.java
ASN1.EncodeSubjectPublicKeyInfo
public static byte[] EncodeSubjectPublicKeyInfo(byte[] algorithm, byte[] keyBytes) throws CoseException { // SPKI ::= SEQUENCE { // algorithm SEQUENCE { // oid = id-ecPublicKey {1 2 840 10045 2} // namedCurve = oid for algorithm // } // subjectPublicKey BIT STRING CONTAINS key bytes // } try { ArrayList<byte[]> xxx = new ArrayList<byte[]>(); xxx.add(algorithm); xxx.add(new byte[]{3}); xxx.add(ComputeLength(keyBytes.length+1)); xxx.add(new byte[]{0}); xxx.add(keyBytes); return Sequence(xxx); } catch (ArrayIndexOutOfBoundsException e) { System.out.print(e.toString()); throw e; } }
java
public static byte[] EncodeSubjectPublicKeyInfo(byte[] algorithm, byte[] keyBytes) throws CoseException { // SPKI ::= SEQUENCE { // algorithm SEQUENCE { // oid = id-ecPublicKey {1 2 840 10045 2} // namedCurve = oid for algorithm // } // subjectPublicKey BIT STRING CONTAINS key bytes // } try { ArrayList<byte[]> xxx = new ArrayList<byte[]>(); xxx.add(algorithm); xxx.add(new byte[]{3}); xxx.add(ComputeLength(keyBytes.length+1)); xxx.add(new byte[]{0}); xxx.add(keyBytes); return Sequence(xxx); } catch (ArrayIndexOutOfBoundsException e) { System.out.print(e.toString()); throw e; } }
[ "public", "static", "byte", "[", "]", "EncodeSubjectPublicKeyInfo", "(", "byte", "[", "]", "algorithm", ",", "byte", "[", "]", "keyBytes", ")", "throws", "CoseException", "{", "// SPKI ::= SEQUENCE {", "// algorithm SEQUENCE {", "// oid = id-ecPublicKey {1 2 840 10045 2}", "// namedCurve = oid for algorithm", "// }", "// subjectPublicKey BIT STRING CONTAINS key bytes", "// }", "try", "{", "ArrayList", "<", "byte", "[", "]", ">", "xxx", "=", "new", "ArrayList", "<", "byte", "[", "]", ">", "(", ")", ";", "xxx", ".", "add", "(", "algorithm", ")", ";", "xxx", ".", "add", "(", "new", "byte", "[", "]", "{", "3", "}", ")", ";", "xxx", ".", "add", "(", "ComputeLength", "(", "keyBytes", ".", "length", "+", "1", ")", ")", ";", "xxx", ".", "add", "(", "new", "byte", "[", "]", "{", "0", "}", ")", ";", "xxx", ".", "add", "(", "keyBytes", ")", ";", "return", "Sequence", "(", "xxx", ")", ";", "}", "catch", "(", "ArrayIndexOutOfBoundsException", "e", ")", "{", "System", ".", "out", ".", "print", "(", "e", ".", "toString", "(", ")", ")", ";", "throw", "e", ";", "}", "}" ]
Encode a subject public key info structure from an OID and the data bytes for the key This function assumes that we are encoding an EC Public key.d @param algorithm - encoded Object Identifier @param keyBytes - encoded key bytes @return - encoded SPKI @throws CoseException - ASN encoding error.
[ "Encode", "a", "subject", "public", "key", "info", "structure", "from", "an", "OID", "and", "the", "data", "bytes", "for", "the", "key", "This", "function", "assumes", "that", "we", "are", "encoding", "an", "EC", "Public", "key", ".", "d" ]
f972b11ab4c9a18f911bc49a15225a6951cf6f63
https://github.com/cose-wg/COSE-JAVA/blob/f972b11ab4c9a18f911bc49a15225a6951cf6f63/src/main/java/COSE/ASN1.java#L70-L93
7,831
cose-wg/COSE-JAVA
src/main/java/COSE/ASN1.java
ASN1.EncodeEcPrivateKey
public static byte[] EncodeEcPrivateKey(byte[] oid, byte[] keyBytes, byte[] spki) throws CoseException { // ECPrivateKey ::= SEQUENCE { // version INTEGER {1} // privateKey OCTET STRING // parameters [0] OBJECT IDENTIFIER = named curve // public key [1] BIT STRING OPTIONAL // } // ArrayList<byte[]> xxx = new ArrayList<byte[]>(); xxx.add(new byte[]{2, 1, 1}); xxx.add(OctetStringTag); xxx.add(ComputeLength(keyBytes.length)); xxx.add(keyBytes); xxx.add(new byte[]{(byte)0xa0}); xxx.add(ComputeLength(oid.length)); xxx.add(oid); if (spki != null) { xxx.add(new byte[]{(byte)0xa1}); xxx.add(ComputeLength(spki.length+1)); xxx.add(new byte[]{0}); xxx.add(spki); } byte[] ecPrivateKey = Sequence(xxx); return ecPrivateKey; }
java
public static byte[] EncodeEcPrivateKey(byte[] oid, byte[] keyBytes, byte[] spki) throws CoseException { // ECPrivateKey ::= SEQUENCE { // version INTEGER {1} // privateKey OCTET STRING // parameters [0] OBJECT IDENTIFIER = named curve // public key [1] BIT STRING OPTIONAL // } // ArrayList<byte[]> xxx = new ArrayList<byte[]>(); xxx.add(new byte[]{2, 1, 1}); xxx.add(OctetStringTag); xxx.add(ComputeLength(keyBytes.length)); xxx.add(keyBytes); xxx.add(new byte[]{(byte)0xa0}); xxx.add(ComputeLength(oid.length)); xxx.add(oid); if (spki != null) { xxx.add(new byte[]{(byte)0xa1}); xxx.add(ComputeLength(spki.length+1)); xxx.add(new byte[]{0}); xxx.add(spki); } byte[] ecPrivateKey = Sequence(xxx); return ecPrivateKey; }
[ "public", "static", "byte", "[", "]", "EncodeEcPrivateKey", "(", "byte", "[", "]", "oid", ",", "byte", "[", "]", "keyBytes", ",", "byte", "[", "]", "spki", ")", "throws", "CoseException", "{", "// ECPrivateKey ::= SEQUENCE {", "// version INTEGER {1}", "// privateKey OCTET STRING", "// parameters [0] OBJECT IDENTIFIER = named curve", "// public key [1] BIT STRING OPTIONAL", "// }", "//", "ArrayList", "<", "byte", "[", "]", ">", "xxx", "=", "new", "ArrayList", "<", "byte", "[", "]", ">", "(", ")", ";", "xxx", ".", "add", "(", "new", "byte", "[", "]", "{", "2", ",", "1", ",", "1", "}", ")", ";", "xxx", ".", "add", "(", "OctetStringTag", ")", ";", "xxx", ".", "add", "(", "ComputeLength", "(", "keyBytes", ".", "length", ")", ")", ";", "xxx", ".", "add", "(", "keyBytes", ")", ";", "xxx", ".", "add", "(", "new", "byte", "[", "]", "{", "(", "byte", ")", "0xa0", "}", ")", ";", "xxx", ".", "add", "(", "ComputeLength", "(", "oid", ".", "length", ")", ")", ";", "xxx", ".", "add", "(", "oid", ")", ";", "if", "(", "spki", "!=", "null", ")", "{", "xxx", ".", "add", "(", "new", "byte", "[", "]", "{", "(", "byte", ")", "0xa1", "}", ")", ";", "xxx", ".", "add", "(", "ComputeLength", "(", "spki", ".", "length", "+", "1", ")", ")", ";", "xxx", ".", "add", "(", "new", "byte", "[", "]", "{", "0", "}", ")", ";", "xxx", ".", "add", "(", "spki", ")", ";", "}", "byte", "[", "]", "ecPrivateKey", "=", "Sequence", "(", "xxx", ")", ";", "return", "ecPrivateKey", ";", "}" ]
Encode an EC Private key @param oid - curve to use @param keyBytes - bytes of the key @param spki - optional SPKI @return encoded private key @throws CoseException - from lower level
[ "Encode", "an", "EC", "Private", "key" ]
f972b11ab4c9a18f911bc49a15225a6951cf6f63
https://github.com/cose-wg/COSE-JAVA/blob/f972b11ab4c9a18f911bc49a15225a6951cf6f63/src/main/java/COSE/ASN1.java#L103-L131
7,832
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/GenericStorableCodec.java
GenericStorableCodec.getInstance
@SuppressWarnings("unchecked") static synchronized <S extends Storable> GenericStorableCodec<S> getInstance (GenericStorableCodecFactory factory, GenericEncodingStrategy<S> encodingStrategy, boolean isMaster, Layout layout, RawSupport support) throws SupportException { Object layoutKey = layout == null ? null : new LayoutKey(layout); Object key = KeyFactory.createKey(new Object[] {encodingStrategy, isMaster, layoutKey}); Class<? extends S> storableImpl = (Class<? extends S>) cCache.get(key); if (storableImpl == null) { storableImpl = generateStorable(encodingStrategy, isMaster, layout); cCache.put(key, storableImpl); } return new GenericStorableCodec<S> (key, factory, encodingStrategy.getType(), storableImpl, encodingStrategy, layout, support); }
java
@SuppressWarnings("unchecked") static synchronized <S extends Storable> GenericStorableCodec<S> getInstance (GenericStorableCodecFactory factory, GenericEncodingStrategy<S> encodingStrategy, boolean isMaster, Layout layout, RawSupport support) throws SupportException { Object layoutKey = layout == null ? null : new LayoutKey(layout); Object key = KeyFactory.createKey(new Object[] {encodingStrategy, isMaster, layoutKey}); Class<? extends S> storableImpl = (Class<? extends S>) cCache.get(key); if (storableImpl == null) { storableImpl = generateStorable(encodingStrategy, isMaster, layout); cCache.put(key, storableImpl); } return new GenericStorableCodec<S> (key, factory, encodingStrategy.getType(), storableImpl, encodingStrategy, layout, support); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "static", "synchronized", "<", "S", "extends", "Storable", ">", "GenericStorableCodec", "<", "S", ">", "getInstance", "(", "GenericStorableCodecFactory", "factory", ",", "GenericEncodingStrategy", "<", "S", ">", "encodingStrategy", ",", "boolean", "isMaster", ",", "Layout", "layout", ",", "RawSupport", "support", ")", "throws", "SupportException", "{", "Object", "layoutKey", "=", "layout", "==", "null", "?", "null", ":", "new", "LayoutKey", "(", "layout", ")", ";", "Object", "key", "=", "KeyFactory", ".", "createKey", "(", "new", "Object", "[", "]", "{", "encodingStrategy", ",", "isMaster", ",", "layoutKey", "}", ")", ";", "Class", "<", "?", "extends", "S", ">", "storableImpl", "=", "(", "Class", "<", "?", "extends", "S", ">", ")", "cCache", ".", "get", "(", "key", ")", ";", "if", "(", "storableImpl", "==", "null", ")", "{", "storableImpl", "=", "generateStorable", "(", "encodingStrategy", ",", "isMaster", ",", "layout", ")", ";", "cCache", ".", "put", "(", "key", ",", "storableImpl", ")", ";", "}", "return", "new", "GenericStorableCodec", "<", "S", ">", "(", "key", ",", "factory", ",", "encodingStrategy", ".", "getType", "(", ")", ",", "storableImpl", ",", "encodingStrategy", ",", "layout", ",", "support", ")", ";", "}" ]
Returns an instance of the codec. The Storable type itself may be an interface or a class. If it is a class, then it must not be final, and it must have a public, no-arg constructor. @param isMaster when true, version properties and sequences are managed @param layout when non-null, encode a storable layout generation value in one or four bytes. Generation 0..127 is encoded in one byte, and 128..max is encoded in four bytes, with the most significant bit set. @param support binds generated storable with a storage layer @throws SupportException if Storable is not supported @throws amazon.carbonado.MalformedTypeException if Storable type is not well-formed @throws IllegalArgumentException if type is null
[ "Returns", "an", "instance", "of", "the", "codec", ".", "The", "Storable", "type", "itself", "may", "be", "an", "interface", "or", "a", "class", ".", "If", "it", "is", "a", "class", "then", "it", "must", "not", "be", "final", "and", "it", "must", "have", "a", "public", "no", "-", "arg", "constructor", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/GenericStorableCodec.java#L88-L112
7,833
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/GenericStorableCodec.java
GenericStorableCodec.getSearchKeyFactory
@SuppressWarnings("unchecked") public SearchKeyFactory<S> getSearchKeyFactory(OrderedProperty<S>[] properties) { // This KeyFactory makes arrays work as hashtable keys. Object key = KeyFactory.createKey(new Object[] {mCodecKey, properties}); synchronized (cCodecSearchKeyFactories) { SearchKeyFactory<S> factory = (SearchKeyFactory<S>) cCodecSearchKeyFactories.get(key); if (factory == null) { factory = generateSearchKeyFactory(properties); cCodecSearchKeyFactories.put(key, factory); } return factory; } }
java
@SuppressWarnings("unchecked") public SearchKeyFactory<S> getSearchKeyFactory(OrderedProperty<S>[] properties) { // This KeyFactory makes arrays work as hashtable keys. Object key = KeyFactory.createKey(new Object[] {mCodecKey, properties}); synchronized (cCodecSearchKeyFactories) { SearchKeyFactory<S> factory = (SearchKeyFactory<S>) cCodecSearchKeyFactories.get(key); if (factory == null) { factory = generateSearchKeyFactory(properties); cCodecSearchKeyFactories.put(key, factory); } return factory; } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "SearchKeyFactory", "<", "S", ">", "getSearchKeyFactory", "(", "OrderedProperty", "<", "S", ">", "[", "]", "properties", ")", "{", "// This KeyFactory makes arrays work as hashtable keys.\r", "Object", "key", "=", "KeyFactory", ".", "createKey", "(", "new", "Object", "[", "]", "{", "mCodecKey", ",", "properties", "}", ")", ";", "synchronized", "(", "cCodecSearchKeyFactories", ")", "{", "SearchKeyFactory", "<", "S", ">", "factory", "=", "(", "SearchKeyFactory", "<", "S", ">", ")", "cCodecSearchKeyFactories", ".", "get", "(", "key", ")", ";", "if", "(", "factory", "==", "null", ")", "{", "factory", "=", "generateSearchKeyFactory", "(", "properties", ")", ";", "cCodecSearchKeyFactories", ".", "put", "(", "key", ",", "factory", ")", ";", "}", "return", "factory", ";", "}", "}" ]
Returns a search key factory, which is useful for implementing indexes and queries. @param properties properties to build the search key from
[ "Returns", "a", "search", "key", "factory", "which", "is", "useful", "for", "implementing", "indexes", "and", "queries", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/GenericStorableCodec.java#L482-L495
7,834
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/GenericStorableCodec.java
GenericStorableCodec.getDecoder
@Deprecated public Decoder<S> getDecoder(int generation) throws FetchNoneException, FetchException { try { synchronized (mLayout) { IntHashMap decoders = mDecoders; if (decoders == null) { mDecoders = decoders = new IntHashMap(); } Decoder<S> decoder = (Decoder<S>) decoders.get(generation); if (decoder == null) { synchronized (cCodecDecoders) { Object altLayoutKey = new LayoutKey(mLayout.getGeneration(generation)); Object key = KeyFactory.createKey // Note: Generation is still required in the key // because an equivalent layout (with different generation) // might have been supplied by Layout.getGeneration. (new Object[] {mCodecKey, generation, altLayoutKey}); decoder = (Decoder<S>) cCodecDecoders.get(key); if (decoder == null) { decoder = generateDecoder(generation); cCodecDecoders.put(key, decoder); } } mDecoders.put(generation, decoder); } return decoder; } } catch (NullPointerException e) { if (mLayout == null) { throw new FetchNoneException("Layout evolution not supported"); } throw e; } }
java
@Deprecated public Decoder<S> getDecoder(int generation) throws FetchNoneException, FetchException { try { synchronized (mLayout) { IntHashMap decoders = mDecoders; if (decoders == null) { mDecoders = decoders = new IntHashMap(); } Decoder<S> decoder = (Decoder<S>) decoders.get(generation); if (decoder == null) { synchronized (cCodecDecoders) { Object altLayoutKey = new LayoutKey(mLayout.getGeneration(generation)); Object key = KeyFactory.createKey // Note: Generation is still required in the key // because an equivalent layout (with different generation) // might have been supplied by Layout.getGeneration. (new Object[] {mCodecKey, generation, altLayoutKey}); decoder = (Decoder<S>) cCodecDecoders.get(key); if (decoder == null) { decoder = generateDecoder(generation); cCodecDecoders.put(key, decoder); } } mDecoders.put(generation, decoder); } return decoder; } } catch (NullPointerException e) { if (mLayout == null) { throw new FetchNoneException("Layout evolution not supported"); } throw e; } }
[ "@", "Deprecated", "public", "Decoder", "<", "S", ">", "getDecoder", "(", "int", "generation", ")", "throws", "FetchNoneException", ",", "FetchException", "{", "try", "{", "synchronized", "(", "mLayout", ")", "{", "IntHashMap", "decoders", "=", "mDecoders", ";", "if", "(", "decoders", "==", "null", ")", "{", "mDecoders", "=", "decoders", "=", "new", "IntHashMap", "(", ")", ";", "}", "Decoder", "<", "S", ">", "decoder", "=", "(", "Decoder", "<", "S", ">", ")", "decoders", ".", "get", "(", "generation", ")", ";", "if", "(", "decoder", "==", "null", ")", "{", "synchronized", "(", "cCodecDecoders", ")", "{", "Object", "altLayoutKey", "=", "new", "LayoutKey", "(", "mLayout", ".", "getGeneration", "(", "generation", ")", ")", ";", "Object", "key", "=", "KeyFactory", ".", "createKey", "// Note: Generation is still required in the key\r", "// because an equivalent layout (with different generation)\r", "// might have been supplied by Layout.getGeneration.\r", "(", "new", "Object", "[", "]", "{", "mCodecKey", ",", "generation", ",", "altLayoutKey", "}", ")", ";", "decoder", "=", "(", "Decoder", "<", "S", ">", ")", "cCodecDecoders", ".", "get", "(", "key", ")", ";", "if", "(", "decoder", "==", "null", ")", "{", "decoder", "=", "generateDecoder", "(", "generation", ")", ";", "cCodecDecoders", ".", "put", "(", "key", ",", "decoder", ")", ";", "}", "}", "mDecoders", ".", "put", "(", "generation", ",", "decoder", ")", ";", "}", "return", "decoder", ";", "}", "}", "catch", "(", "NullPointerException", "e", ")", "{", "if", "(", "mLayout", "==", "null", ")", "{", "throw", "new", "FetchNoneException", "(", "\"Layout evolution not supported\"", ")", ";", "}", "throw", "e", ";", "}", "}" ]
Returns a data decoder for the given generation. @throws FetchNoneException if generation is unknown @deprecated use direct decode method
[ "Returns", "a", "data", "decoder", "for", "the", "given", "generation", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/GenericStorableCodec.java#L514-L547
7,835
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/cursor/ControllerCursor.java
ControllerCursor.apply
public static <S> Cursor<S> apply(Cursor<S> source, Query.Controller controller) { return controller == null ? source : new ControllerCursor<S>(source, controller); }
java
public static <S> Cursor<S> apply(Cursor<S> source, Query.Controller controller) { return controller == null ? source : new ControllerCursor<S>(source, controller); }
[ "public", "static", "<", "S", ">", "Cursor", "<", "S", ">", "apply", "(", "Cursor", "<", "S", ">", "source", ",", "Query", ".", "Controller", "controller", ")", "{", "return", "controller", "==", "null", "?", "source", ":", "new", "ControllerCursor", "<", "S", ">", "(", "source", ",", "controller", ")", ";", "}" ]
Returns a ControllerCursor depending on whether a controller instance is passed in or not. @param controller optional controller which can abort query operation @throws IllegalArgumentException if source is null
[ "Returns", "a", "ControllerCursor", "depending", "on", "whether", "a", "controller", "instance", "is", "passed", "in", "or", "not", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/cursor/ControllerCursor.java#L38-L40
7,836
cose-wg/COSE-JAVA
src/main/java/COSE/Attribute.java
Attribute.AddProtected
@Deprecated public void AddProtected(HeaderKeys label, byte[] value) throws CoseException { addAttribute(label, value, PROTECTED); }
java
@Deprecated public void AddProtected(HeaderKeys label, byte[] value) throws CoseException { addAttribute(label, value, PROTECTED); }
[ "@", "Deprecated", "public", "void", "AddProtected", "(", "HeaderKeys", "label", ",", "byte", "[", "]", "value", ")", "throws", "CoseException", "{", "addAttribute", "(", "label", ",", "value", ",", "PROTECTED", ")", ";", "}" ]
Set an attribute in the protect bucket of the COSE object @param label CBOR object which identifies the attribute in the map @param value byte array of value @deprecated As of COSE 0.9.0, use addAttribute(HeaderKeys, byte[], Attribute.PROTECTED); @exception CoseException COSE Package exception
[ "Set", "an", "attribute", "in", "the", "protect", "bucket", "of", "the", "COSE", "object" ]
f972b11ab4c9a18f911bc49a15225a6951cf6f63
https://github.com/cose-wg/COSE-JAVA/blob/f972b11ab4c9a18f911bc49a15225a6951cf6f63/src/main/java/COSE/Attribute.java#L205-L208
7,837
cose-wg/COSE-JAVA
src/main/java/COSE/Attribute.java
Attribute.AddUnprotected
@Deprecated public void AddUnprotected(CBORObject label, CBORObject value) throws CoseException { addAttribute(label, value, UNPROTECTED); }
java
@Deprecated public void AddUnprotected(CBORObject label, CBORObject value) throws CoseException { addAttribute(label, value, UNPROTECTED); }
[ "@", "Deprecated", "public", "void", "AddUnprotected", "(", "CBORObject", "label", ",", "CBORObject", "value", ")", "throws", "CoseException", "{", "addAttribute", "(", "label", ",", "value", ",", "UNPROTECTED", ")", ";", "}" ]
Set an attribute in the unprotected bucket of the COSE object @param label value identifies the attribute in the map @param value value to be associated with the label @deprecated As of COSE 0.9.1, use addAttribute(HeaderKeys, byte[], Attribute.UNPROTECTED); @exception CoseException COSE Package exception
[ "Set", "an", "attribute", "in", "the", "unprotected", "bucket", "of", "the", "COSE", "object" ]
f972b11ab4c9a18f911bc49a15225a6951cf6f63
https://github.com/cose-wg/COSE-JAVA/blob/f972b11ab4c9a18f911bc49a15225a6951cf6f63/src/main/java/COSE/Attribute.java#L219-L222
7,838
cose-wg/COSE-JAVA
src/main/java/COSE/Attribute.java
Attribute.removeAttribute
public void removeAttribute(CBORObject label) throws CoseException { if (objProtected.ContainsKey(label)) { if (rgbProtected != null) throw new CoseException("Operation would modify integrity protected attributes"); objProtected.Remove(label); } if (objUnprotected.ContainsKey(label)) objUnprotected.Remove(label); if (objDontSend.ContainsKey(label)) objDontSend.Remove(label); }
java
public void removeAttribute(CBORObject label) throws CoseException { if (objProtected.ContainsKey(label)) { if (rgbProtected != null) throw new CoseException("Operation would modify integrity protected attributes"); objProtected.Remove(label); } if (objUnprotected.ContainsKey(label)) objUnprotected.Remove(label); if (objDontSend.ContainsKey(label)) objDontSend.Remove(label); }
[ "public", "void", "removeAttribute", "(", "CBORObject", "label", ")", "throws", "CoseException", "{", "if", "(", "objProtected", ".", "ContainsKey", "(", "label", ")", ")", "{", "if", "(", "rgbProtected", "!=", "null", ")", "throw", "new", "CoseException", "(", "\"Operation would modify integrity protected attributes\"", ")", ";", "objProtected", ".", "Remove", "(", "label", ")", ";", "}", "if", "(", "objUnprotected", ".", "ContainsKey", "(", "label", ")", ")", "objUnprotected", ".", "Remove", "(", "label", ")", ";", "if", "(", "objDontSend", ".", "ContainsKey", "(", "label", ")", ")", "objDontSend", ".", "Remove", "(", "label", ")", ";", "}" ]
Remove an attribute from the set of all attribute maps. @param label attribute to be removed @exception CoseException if integrity protection would be modified.
[ "Remove", "an", "attribute", "from", "the", "set", "of", "all", "attribute", "maps", "." ]
f972b11ab4c9a18f911bc49a15225a6951cf6f63
https://github.com/cose-wg/COSE-JAVA/blob/f972b11ab4c9a18f911bc49a15225a6951cf6f63/src/main/java/COSE/Attribute.java#L334-L341
7,839
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/repo/map/Key.java
Key.callSetPropertyValue
private static void callSetPropertyValue(CodeBuilder b, OrderedProperty<?> op) { StorableProperty<?> property = op.getChainedProperty().getLastProperty(); TypeDesc propType = TypeDesc.forClass(property.getType()); if (propType != TypeDesc.OBJECT) { TypeDesc objectType = propType.toObjectType(); b.checkCast(objectType); // Potentially unbox primitive. b.convert(objectType, propType); } b.invoke(property.getWriteMethod()); }
java
private static void callSetPropertyValue(CodeBuilder b, OrderedProperty<?> op) { StorableProperty<?> property = op.getChainedProperty().getLastProperty(); TypeDesc propType = TypeDesc.forClass(property.getType()); if (propType != TypeDesc.OBJECT) { TypeDesc objectType = propType.toObjectType(); b.checkCast(objectType); // Potentially unbox primitive. b.convert(objectType, propType); } b.invoke(property.getWriteMethod()); }
[ "private", "static", "void", "callSetPropertyValue", "(", "CodeBuilder", "b", ",", "OrderedProperty", "<", "?", ">", "op", ")", "{", "StorableProperty", "<", "?", ">", "property", "=", "op", ".", "getChainedProperty", "(", ")", ".", "getLastProperty", "(", ")", ";", "TypeDesc", "propType", "=", "TypeDesc", ".", "forClass", "(", "property", ".", "getType", "(", ")", ")", ";", "if", "(", "propType", "!=", "TypeDesc", ".", "OBJECT", ")", "{", "TypeDesc", "objectType", "=", "propType", ".", "toObjectType", "(", ")", ";", "b", ".", "checkCast", "(", "objectType", ")", ";", "// Potentially unbox primitive.\r", "b", ".", "convert", "(", "objectType", ",", "propType", ")", ";", "}", "b", ".", "invoke", "(", "property", ".", "getWriteMethod", "(", ")", ")", ";", "}" ]
Creates code to call set method. Assumes Storable and property value are already on the stack.
[ "Creates", "code", "to", "call", "set", "method", ".", "Assumes", "Storable", "and", "property", "value", "are", "already", "on", "the", "stack", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/repo/map/Key.java#L257-L267
7,840
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/repo/replicated/BlobReplicationTrigger.java
BlobReplicationTrigger.create
static <S extends Storable> BlobReplicationTrigger<S> create(Storage<S> masterStorage) { Map<String, ? extends StorableProperty<S>> properties = StorableIntrospector.examine(masterStorage.getStorableType()).getDataProperties(); List<String> blobNames = new ArrayList<String>(2); for (StorableProperty<S> property : properties.values()) { if (property.getType() == Blob.class) { blobNames.add(property.getName()); } } if (blobNames.size() == 0) { return null; } return new BlobReplicationTrigger<S>(masterStorage, blobNames.toArray(new String[blobNames.size()])); }
java
static <S extends Storable> BlobReplicationTrigger<S> create(Storage<S> masterStorage) { Map<String, ? extends StorableProperty<S>> properties = StorableIntrospector.examine(masterStorage.getStorableType()).getDataProperties(); List<String> blobNames = new ArrayList<String>(2); for (StorableProperty<S> property : properties.values()) { if (property.getType() == Blob.class) { blobNames.add(property.getName()); } } if (blobNames.size() == 0) { return null; } return new BlobReplicationTrigger<S>(masterStorage, blobNames.toArray(new String[blobNames.size()])); }
[ "static", "<", "S", "extends", "Storable", ">", "BlobReplicationTrigger", "<", "S", ">", "create", "(", "Storage", "<", "S", ">", "masterStorage", ")", "{", "Map", "<", "String", ",", "?", "extends", "StorableProperty", "<", "S", ">", ">", "properties", "=", "StorableIntrospector", ".", "examine", "(", "masterStorage", ".", "getStorableType", "(", ")", ")", ".", "getDataProperties", "(", ")", ";", "List", "<", "String", ">", "blobNames", "=", "new", "ArrayList", "<", "String", ">", "(", "2", ")", ";", "for", "(", "StorableProperty", "<", "S", ">", "property", ":", "properties", ".", "values", "(", ")", ")", "{", "if", "(", "property", ".", "getType", "(", ")", "==", "Blob", ".", "class", ")", "{", "blobNames", ".", "add", "(", "property", ".", "getName", "(", ")", ")", ";", "}", "}", "if", "(", "blobNames", ".", "size", "(", ")", "==", "0", ")", "{", "return", "null", ";", "}", "return", "new", "BlobReplicationTrigger", "<", "S", ">", "(", "masterStorage", ",", "blobNames", ".", "toArray", "(", "new", "String", "[", "blobNames", ".", "size", "(", ")", "]", ")", ")", ";", "}" ]
Returns null if no Blobs need to be replicated.
[ "Returns", "null", "if", "no", "Blobs", "need", "to", "be", "replicated", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/repo/replicated/BlobReplicationTrigger.java#L54-L72
7,841
cose-wg/COSE-JAVA
src/main/java/COSE/Sign1Message.java
Sign1Message.sign
public void sign(OneKey key) throws CoseException { if (rgbContent == null) throw new CoseException("No Content Specified"); if (rgbSignature != null) return; if (rgbProtected == null) { if (objProtected.size() > 0) rgbProtected = objProtected.EncodeToBytes(); else rgbProtected = new byte[0]; } CBORObject obj = CBORObject.NewArray(); obj.Add(contextString); obj.Add(rgbProtected); obj.Add(externalData); obj.Add(rgbContent); rgbSignature = computeSignature(obj.EncodeToBytes(), key); ProcessCounterSignatures(); }
java
public void sign(OneKey key) throws CoseException { if (rgbContent == null) throw new CoseException("No Content Specified"); if (rgbSignature != null) return; if (rgbProtected == null) { if (objProtected.size() > 0) rgbProtected = objProtected.EncodeToBytes(); else rgbProtected = new byte[0]; } CBORObject obj = CBORObject.NewArray(); obj.Add(contextString); obj.Add(rgbProtected); obj.Add(externalData); obj.Add(rgbContent); rgbSignature = computeSignature(obj.EncodeToBytes(), key); ProcessCounterSignatures(); }
[ "public", "void", "sign", "(", "OneKey", "key", ")", "throws", "CoseException", "{", "if", "(", "rgbContent", "==", "null", ")", "throw", "new", "CoseException", "(", "\"No Content Specified\"", ")", ";", "if", "(", "rgbSignature", "!=", "null", ")", "return", ";", "if", "(", "rgbProtected", "==", "null", ")", "{", "if", "(", "objProtected", ".", "size", "(", ")", ">", "0", ")", "rgbProtected", "=", "objProtected", ".", "EncodeToBytes", "(", ")", ";", "else", "rgbProtected", "=", "new", "byte", "[", "0", "]", ";", "}", "CBORObject", "obj", "=", "CBORObject", ".", "NewArray", "(", ")", ";", "obj", ".", "Add", "(", "contextString", ")", ";", "obj", ".", "Add", "(", "rgbProtected", ")", ";", "obj", ".", "Add", "(", "externalData", ")", ";", "obj", ".", "Add", "(", "rgbContent", ")", ";", "rgbSignature", "=", "computeSignature", "(", "obj", ".", "EncodeToBytes", "(", ")", ",", "key", ")", ";", "ProcessCounterSignatures", "(", ")", ";", "}" ]
Create a signature for the message if one does not exist. @param key key to use to sign the message @exception CoseException Errors generated by the COSE module
[ "Create", "a", "signature", "for", "the", "message", "if", "one", "does", "not", "exist", "." ]
f972b11ab4c9a18f911bc49a15225a6951cf6f63
https://github.com/cose-wg/COSE-JAVA/blob/f972b11ab4c9a18f911bc49a15225a6951cf6f63/src/main/java/COSE/Sign1Message.java#L63-L81
7,842
cose-wg/COSE-JAVA
src/main/java/COSE/Sign1Message.java
Sign1Message.validate
public boolean validate(OneKey cnKey) throws CoseException { CBORObject obj = CBORObject.NewArray(); obj.Add(contextString); if (objProtected.size() > 0) obj.Add(rgbProtected); else obj.Add(CBORObject.FromObject(new byte[0])); obj.Add(externalData); obj.Add(rgbContent); return validateSignature(obj.EncodeToBytes(), rgbSignature, cnKey); }
java
public boolean validate(OneKey cnKey) throws CoseException { CBORObject obj = CBORObject.NewArray(); obj.Add(contextString); if (objProtected.size() > 0) obj.Add(rgbProtected); else obj.Add(CBORObject.FromObject(new byte[0])); obj.Add(externalData); obj.Add(rgbContent); return validateSignature(obj.EncodeToBytes(), rgbSignature, cnKey); }
[ "public", "boolean", "validate", "(", "OneKey", "cnKey", ")", "throws", "CoseException", "{", "CBORObject", "obj", "=", "CBORObject", ".", "NewArray", "(", ")", ";", "obj", ".", "Add", "(", "contextString", ")", ";", "if", "(", "objProtected", ".", "size", "(", ")", ">", "0", ")", "obj", ".", "Add", "(", "rgbProtected", ")", ";", "else", "obj", ".", "Add", "(", "CBORObject", ".", "FromObject", "(", "new", "byte", "[", "0", "]", ")", ")", ";", "obj", ".", "Add", "(", "externalData", ")", ";", "obj", ".", "Add", "(", "rgbContent", ")", ";", "return", "validateSignature", "(", "obj", ".", "EncodeToBytes", "(", ")", ",", "rgbSignature", ",", "cnKey", ")", ";", "}" ]
Validate the signature on the message using the passed in key. @param cnKey key to use for validation @return true if the signature validates @throws CoseException Errors generated by the COSE module
[ "Validate", "the", "signature", "on", "the", "message", "using", "the", "passed", "in", "key", "." ]
f972b11ab4c9a18f911bc49a15225a6951cf6f63
https://github.com/cose-wg/COSE-JAVA/blob/f972b11ab4c9a18f911bc49a15225a6951cf6f63/src/main/java/COSE/Sign1Message.java#L91-L99
7,843
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/gen/MasterStorableGenerator.java
MasterStorableGenerator.addEnterTransaction
private Label addEnterTransaction(CodeBuilder b, String opType, LocalVariable txnVar) { if (!alwaysHasTxn(opType)) { return null; } // Repository repo = masterSupport.getRootRepository(); TypeDesc repositoryType = TypeDesc.forClass(Repository.class); TypeDesc transactionType = TypeDesc.forClass(Transaction.class); TypeDesc triggerSupportType = TypeDesc.forClass(TriggerSupport.class); TypeDesc masterSupportType = TypeDesc.forClass(MasterSupport.class); TypeDesc isolationLevelType = TypeDesc.forClass(IsolationLevel.class); b.loadThis(); b.loadField(StorableGenerator.SUPPORT_FIELD_NAME, triggerSupportType); b.invokeInterface(masterSupportType, "getRootRepository", repositoryType, null); if (requiresTxnForUpdate(opType)) { // Always create nested transaction. // txn = repo.enterTransaction(); // txn.setForUpdate(true); b.invokeInterface(repositoryType, ENTER_TRANSACTION_METHOD_NAME, transactionType, null); b.storeLocal(txnVar); b.loadLocal(txnVar); b.loadConstant(true); b.invokeInterface(transactionType, SET_FOR_UPDATE_METHOD_NAME, null, new TypeDesc[] {TypeDesc.BOOLEAN}); } else { LocalVariable repoVar = b.createLocalVariable(null, repositoryType); b.storeLocal(repoVar); // if (repo.getTransactionIsolationLevel() != null) { // txn = null; // } else { // txn = repo.enterTransaction(); // } b.loadLocal(repoVar); b.invokeInterface(repositoryType, GET_TRANSACTION_ISOLATION_LEVEL_METHOD_NAME, isolationLevelType, null); Label notInTxn = b.createLabel(); b.ifNullBranch(notInTxn, true); b.loadNull(); Label storeTxn = b.createLabel(); b.branch(storeTxn); notInTxn.setLocation(); b.loadLocal(repoVar); b.invokeInterface(repositoryType, ENTER_TRANSACTION_METHOD_NAME, transactionType, null); storeTxn.setLocation(); b.storeLocal(txnVar); } return b.createLabel().setLocation(); }
java
private Label addEnterTransaction(CodeBuilder b, String opType, LocalVariable txnVar) { if (!alwaysHasTxn(opType)) { return null; } // Repository repo = masterSupport.getRootRepository(); TypeDesc repositoryType = TypeDesc.forClass(Repository.class); TypeDesc transactionType = TypeDesc.forClass(Transaction.class); TypeDesc triggerSupportType = TypeDesc.forClass(TriggerSupport.class); TypeDesc masterSupportType = TypeDesc.forClass(MasterSupport.class); TypeDesc isolationLevelType = TypeDesc.forClass(IsolationLevel.class); b.loadThis(); b.loadField(StorableGenerator.SUPPORT_FIELD_NAME, triggerSupportType); b.invokeInterface(masterSupportType, "getRootRepository", repositoryType, null); if (requiresTxnForUpdate(opType)) { // Always create nested transaction. // txn = repo.enterTransaction(); // txn.setForUpdate(true); b.invokeInterface(repositoryType, ENTER_TRANSACTION_METHOD_NAME, transactionType, null); b.storeLocal(txnVar); b.loadLocal(txnVar); b.loadConstant(true); b.invokeInterface(transactionType, SET_FOR_UPDATE_METHOD_NAME, null, new TypeDesc[] {TypeDesc.BOOLEAN}); } else { LocalVariable repoVar = b.createLocalVariable(null, repositoryType); b.storeLocal(repoVar); // if (repo.getTransactionIsolationLevel() != null) { // txn = null; // } else { // txn = repo.enterTransaction(); // } b.loadLocal(repoVar); b.invokeInterface(repositoryType, GET_TRANSACTION_ISOLATION_LEVEL_METHOD_NAME, isolationLevelType, null); Label notInTxn = b.createLabel(); b.ifNullBranch(notInTxn, true); b.loadNull(); Label storeTxn = b.createLabel(); b.branch(storeTxn); notInTxn.setLocation(); b.loadLocal(repoVar); b.invokeInterface(repositoryType, ENTER_TRANSACTION_METHOD_NAME, transactionType, null); storeTxn.setLocation(); b.storeLocal(txnVar); } return b.createLabel().setLocation(); }
[ "private", "Label", "addEnterTransaction", "(", "CodeBuilder", "b", ",", "String", "opType", ",", "LocalVariable", "txnVar", ")", "{", "if", "(", "!", "alwaysHasTxn", "(", "opType", ")", ")", "{", "return", "null", ";", "}", "// Repository repo = masterSupport.getRootRepository();\r", "TypeDesc", "repositoryType", "=", "TypeDesc", ".", "forClass", "(", "Repository", ".", "class", ")", ";", "TypeDesc", "transactionType", "=", "TypeDesc", ".", "forClass", "(", "Transaction", ".", "class", ")", ";", "TypeDesc", "triggerSupportType", "=", "TypeDesc", ".", "forClass", "(", "TriggerSupport", ".", "class", ")", ";", "TypeDesc", "masterSupportType", "=", "TypeDesc", ".", "forClass", "(", "MasterSupport", ".", "class", ")", ";", "TypeDesc", "isolationLevelType", "=", "TypeDesc", ".", "forClass", "(", "IsolationLevel", ".", "class", ")", ";", "b", ".", "loadThis", "(", ")", ";", "b", ".", "loadField", "(", "StorableGenerator", ".", "SUPPORT_FIELD_NAME", ",", "triggerSupportType", ")", ";", "b", ".", "invokeInterface", "(", "masterSupportType", ",", "\"getRootRepository\"", ",", "repositoryType", ",", "null", ")", ";", "if", "(", "requiresTxnForUpdate", "(", "opType", ")", ")", "{", "// Always create nested transaction.\r", "// txn = repo.enterTransaction();\r", "// txn.setForUpdate(true);\r", "b", ".", "invokeInterface", "(", "repositoryType", ",", "ENTER_TRANSACTION_METHOD_NAME", ",", "transactionType", ",", "null", ")", ";", "b", ".", "storeLocal", "(", "txnVar", ")", ";", "b", ".", "loadLocal", "(", "txnVar", ")", ";", "b", ".", "loadConstant", "(", "true", ")", ";", "b", ".", "invokeInterface", "(", "transactionType", ",", "SET_FOR_UPDATE_METHOD_NAME", ",", "null", ",", "new", "TypeDesc", "[", "]", "{", "TypeDesc", ".", "BOOLEAN", "}", ")", ";", "}", "else", "{", "LocalVariable", "repoVar", "=", "b", ".", "createLocalVariable", "(", "null", ",", "repositoryType", ")", ";", "b", ".", "storeLocal", "(", "repoVar", ")", ";", "// if (repo.getTransactionIsolationLevel() != null) {\r", "// txn = null;\r", "// } else {\r", "// txn = repo.enterTransaction();\r", "// }\r", "b", ".", "loadLocal", "(", "repoVar", ")", ";", "b", ".", "invokeInterface", "(", "repositoryType", ",", "GET_TRANSACTION_ISOLATION_LEVEL_METHOD_NAME", ",", "isolationLevelType", ",", "null", ")", ";", "Label", "notInTxn", "=", "b", ".", "createLabel", "(", ")", ";", "b", ".", "ifNullBranch", "(", "notInTxn", ",", "true", ")", ";", "b", ".", "loadNull", "(", ")", ";", "Label", "storeTxn", "=", "b", ".", "createLabel", "(", ")", ";", "b", ".", "branch", "(", "storeTxn", ")", ";", "notInTxn", ".", "setLocation", "(", ")", ";", "b", ".", "loadLocal", "(", "repoVar", ")", ";", "b", ".", "invokeInterface", "(", "repositoryType", ",", "ENTER_TRANSACTION_METHOD_NAME", ",", "transactionType", ",", "null", ")", ";", "storeTxn", ".", "setLocation", "(", ")", ";", "b", ".", "storeLocal", "(", "txnVar", ")", ";", "}", "return", "b", ".", "createLabel", "(", ")", ".", "setLocation", "(", ")", ";", "}" ]
Generates code to enter a transaction, if required and if none in progress. @param opType type of operation, Insert, Update, or Delete @param txnVar required variable of type Transaction for storing transaction @return optional try start label for transaction
[ "Generates", "code", "to", "enter", "a", "transaction", "if", "required", "and", "if", "none", "in", "progress", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/gen/MasterStorableGenerator.java#L1002-L1063
7,844
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/gen/MasterStorableGenerator.java
MasterStorableGenerator.unsetVersionProperty
private void unsetVersionProperty(CodeBuilder b) throws SupportException { StorableProperty<?> property = mInfo.getVersionProperty(); // Set the property state to uninitialized. { String stateFieldName = StorableGenerator.PROPERTY_STATE_FIELD_NAME + (property.getNumber() >> 4); b.loadThis(); b.loadThis(); b.loadField(stateFieldName, TypeDesc.INT); int shift = (property.getNumber() & 0xf) * 2; b.loadConstant(~(StorableGenerator.PROPERTY_STATE_MASK << shift)); b.math(Opcode.IAND); b.storeField(stateFieldName, TypeDesc.INT); } // Zero the property value. TypeDesc type = TypeDesc.forClass(property.getType()); b.loadThis(); CodeBuilderUtil.blankValue(b, type); b.storeField(property.getName(), type); }
java
private void unsetVersionProperty(CodeBuilder b) throws SupportException { StorableProperty<?> property = mInfo.getVersionProperty(); // Set the property state to uninitialized. { String stateFieldName = StorableGenerator.PROPERTY_STATE_FIELD_NAME + (property.getNumber() >> 4); b.loadThis(); b.loadThis(); b.loadField(stateFieldName, TypeDesc.INT); int shift = (property.getNumber() & 0xf) * 2; b.loadConstant(~(StorableGenerator.PROPERTY_STATE_MASK << shift)); b.math(Opcode.IAND); b.storeField(stateFieldName, TypeDesc.INT); } // Zero the property value. TypeDesc type = TypeDesc.forClass(property.getType()); b.loadThis(); CodeBuilderUtil.blankValue(b, type); b.storeField(property.getName(), type); }
[ "private", "void", "unsetVersionProperty", "(", "CodeBuilder", "b", ")", "throws", "SupportException", "{", "StorableProperty", "<", "?", ">", "property", "=", "mInfo", ".", "getVersionProperty", "(", ")", ";", "// Set the property state to uninitialized.\r", "{", "String", "stateFieldName", "=", "StorableGenerator", ".", "PROPERTY_STATE_FIELD_NAME", "+", "(", "property", ".", "getNumber", "(", ")", ">>", "4", ")", ";", "b", ".", "loadThis", "(", ")", ";", "b", ".", "loadThis", "(", ")", ";", "b", ".", "loadField", "(", "stateFieldName", ",", "TypeDesc", ".", "INT", ")", ";", "int", "shift", "=", "(", "property", ".", "getNumber", "(", ")", "&", "0xf", ")", "*", "2", ";", "b", ".", "loadConstant", "(", "~", "(", "StorableGenerator", ".", "PROPERTY_STATE_MASK", "<<", "shift", ")", ")", ";", "b", ".", "math", "(", "Opcode", ".", "IAND", ")", ";", "b", ".", "storeField", "(", "stateFieldName", ",", "TypeDesc", ".", "INT", ")", ";", "}", "// Zero the property value.\r", "TypeDesc", "type", "=", "TypeDesc", ".", "forClass", "(", "property", ".", "getType", "(", ")", ")", ";", "b", ".", "loadThis", "(", ")", ";", "CodeBuilderUtil", ".", "blankValue", "(", "b", ",", "type", ")", ";", "b", ".", "storeField", "(", "property", ".", "getName", "(", ")", ",", "type", ")", ";", "}" ]
Sets the version property to its initial uninitialized state.
[ "Sets", "the", "version", "property", "to", "its", "initial", "uninitialized", "state", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/gen/MasterStorableGenerator.java#L1227-L1248
7,845
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/gen/MasterStorableGenerator.java
MasterStorableGenerator.addNormalizationRollback
private void addNormalizationRollback(CodeBuilder b, Label doTryStart, List<PropertyCopy> unnormalized) { if (unnormalized == null) { return; } Label doTryEnd = b.createLabel().setLocation(); b.dup(); Label success = b.createLabel(); b.ifZeroComparisonBranch(success, "!="); for (int i=0; i<2; i++) { if (i == 0) { } else { b.exceptionHandler(doTryStart, doTryEnd, null); } // Rollback normalized properties. for (PropertyCopy copy : unnormalized) { copy.restore(b); } if (i == 0) { b.branch(success); } else { b.throwObject(); } } success.setLocation(); }
java
private void addNormalizationRollback(CodeBuilder b, Label doTryStart, List<PropertyCopy> unnormalized) { if (unnormalized == null) { return; } Label doTryEnd = b.createLabel().setLocation(); b.dup(); Label success = b.createLabel(); b.ifZeroComparisonBranch(success, "!="); for (int i=0; i<2; i++) { if (i == 0) { } else { b.exceptionHandler(doTryStart, doTryEnd, null); } // Rollback normalized properties. for (PropertyCopy copy : unnormalized) { copy.restore(b); } if (i == 0) { b.branch(success); } else { b.throwObject(); } } success.setLocation(); }
[ "private", "void", "addNormalizationRollback", "(", "CodeBuilder", "b", ",", "Label", "doTryStart", ",", "List", "<", "PropertyCopy", ">", "unnormalized", ")", "{", "if", "(", "unnormalized", "==", "null", ")", "{", "return", ";", "}", "Label", "doTryEnd", "=", "b", ".", "createLabel", "(", ")", ".", "setLocation", "(", ")", ";", "b", ".", "dup", "(", ")", ";", "Label", "success", "=", "b", ".", "createLabel", "(", ")", ";", "b", ".", "ifZeroComparisonBranch", "(", "success", ",", "\"!=\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "2", ";", "i", "++", ")", "{", "if", "(", "i", "==", "0", ")", "{", "}", "else", "{", "b", ".", "exceptionHandler", "(", "doTryStart", ",", "doTryEnd", ",", "null", ")", ";", "}", "// Rollback normalized properties.\r", "for", "(", "PropertyCopy", "copy", ":", "unnormalized", ")", "{", "copy", ".", "restore", "(", "b", ")", ";", "}", "if", "(", "i", "==", "0", ")", "{", "b", ".", "branch", "(", "success", ")", ";", "}", "else", "{", "b", ".", "throwObject", "(", ")", ";", "}", "}", "success", ".", "setLocation", "(", ")", ";", "}" ]
Assumes a boolean is on the stack, as returned by doTryInsert or doTryUpdate.
[ "Assumes", "a", "boolean", "is", "on", "the", "stack", "as", "returned", "by", "doTryInsert", "or", "doTryUpdate", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/gen/MasterStorableGenerator.java#L1329-L1359
7,846
cose-wg/COSE-JAVA
src/main/java/COSE/Encrypt0Message.java
Encrypt0Message.EncodeCBORObject
@Override protected CBORObject EncodeCBORObject() throws CoseException { if (rgbEncrypt == null) throw new CoseException("Encrypt function not called"); CBORObject obj = CBORObject.NewArray(); if (objProtected.size() > 0) obj.Add(objProtected.EncodeToBytes()); else obj.Add(CBORObject.FromObject(new byte[0])); obj.Add(objUnprotected); if (emitContent) obj.Add(rgbEncrypt); else obj.Add(CBORObject.Null); return obj; }
java
@Override protected CBORObject EncodeCBORObject() throws CoseException { if (rgbEncrypt == null) throw new CoseException("Encrypt function not called"); CBORObject obj = CBORObject.NewArray(); if (objProtected.size() > 0) obj.Add(objProtected.EncodeToBytes()); else obj.Add(CBORObject.FromObject(new byte[0])); obj.Add(objUnprotected); if (emitContent) obj.Add(rgbEncrypt); else obj.Add(CBORObject.Null); return obj; }
[ "@", "Override", "protected", "CBORObject", "EncodeCBORObject", "(", ")", "throws", "CoseException", "{", "if", "(", "rgbEncrypt", "==", "null", ")", "throw", "new", "CoseException", "(", "\"Encrypt function not called\"", ")", ";", "CBORObject", "obj", "=", "CBORObject", ".", "NewArray", "(", ")", ";", "if", "(", "objProtected", ".", "size", "(", ")", ">", "0", ")", "obj", ".", "Add", "(", "objProtected", ".", "EncodeToBytes", "(", ")", ")", ";", "else", "obj", ".", "Add", "(", "CBORObject", ".", "FromObject", "(", "new", "byte", "[", "0", "]", ")", ")", ";", "obj", ".", "Add", "(", "objUnprotected", ")", ";", "if", "(", "emitContent", ")", "obj", ".", "Add", "(", "rgbEncrypt", ")", ";", "else", "obj", ".", "Add", "(", "CBORObject", ".", "Null", ")", ";", "return", "obj", ";", "}" ]
Internal function used to construct the CBORObject @return the constructed CBORObject @throws CoseException if the content has not yet been encrypted
[ "Internal", "function", "used", "to", "construct", "the", "CBORObject" ]
f972b11ab4c9a18f911bc49a15225a6951cf6f63
https://github.com/cose-wg/COSE-JAVA/blob/f972b11ab4c9a18f911bc49a15225a6951cf6f63/src/main/java/COSE/Encrypt0Message.java#L74-L88
7,847
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyEncoder.java
KeyEncoder.encodeDesc
public static int encodeDesc(Integer value, byte[] dst, int dstOffset) { if (value == null) { dst[dstOffset] = NULL_BYTE_LOW; return 1; } else { dst[dstOffset] = NOT_NULL_BYTE_LOW; DataEncoder.encode(~value.intValue(), dst, dstOffset + 1); return 5; } }
java
public static int encodeDesc(Integer value, byte[] dst, int dstOffset) { if (value == null) { dst[dstOffset] = NULL_BYTE_LOW; return 1; } else { dst[dstOffset] = NOT_NULL_BYTE_LOW; DataEncoder.encode(~value.intValue(), dst, dstOffset + 1); return 5; } }
[ "public", "static", "int", "encodeDesc", "(", "Integer", "value", ",", "byte", "[", "]", "dst", ",", "int", "dstOffset", ")", "{", "if", "(", "value", "==", "null", ")", "{", "dst", "[", "dstOffset", "]", "=", "NULL_BYTE_LOW", ";", "return", "1", ";", "}", "else", "{", "dst", "[", "dstOffset", "]", "=", "NOT_NULL_BYTE_LOW", ";", "DataEncoder", ".", "encode", "(", "~", "value", ".", "intValue", "(", ")", ",", "dst", ",", "dstOffset", "+", "1", ")", ";", "return", "5", ";", "}", "}" ]
Encodes the given signed Integer object into exactly 1 or 5 bytes for descending order. If the Integer object is never expected to be null, consider encoding as an int primitive. @param value optional signed Integer value to encode @param dst destination for encoded bytes @param dstOffset offset into destination array @return amount of bytes written
[ "Encodes", "the", "given", "signed", "Integer", "object", "into", "exactly", "1", "or", "5", "bytes", "for", "descending", "order", ".", "If", "the", "Integer", "object", "is", "never", "expected", "to", "be", "null", "consider", "encoding", "as", "an", "int", "primitive", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyEncoder.java#L62-L71
7,848
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyEncoder.java
KeyEncoder.encodeDesc
public static int encodeDesc(Long value, byte[] dst, int dstOffset) { if (value == null) { dst[dstOffset] = NULL_BYTE_LOW; return 1; } else { dst[dstOffset] = NOT_NULL_BYTE_LOW; DataEncoder.encode(~value.longValue(), dst, dstOffset + 1); return 9; } }
java
public static int encodeDesc(Long value, byte[] dst, int dstOffset) { if (value == null) { dst[dstOffset] = NULL_BYTE_LOW; return 1; } else { dst[dstOffset] = NOT_NULL_BYTE_LOW; DataEncoder.encode(~value.longValue(), dst, dstOffset + 1); return 9; } }
[ "public", "static", "int", "encodeDesc", "(", "Long", "value", ",", "byte", "[", "]", "dst", ",", "int", "dstOffset", ")", "{", "if", "(", "value", "==", "null", ")", "{", "dst", "[", "dstOffset", "]", "=", "NULL_BYTE_LOW", ";", "return", "1", ";", "}", "else", "{", "dst", "[", "dstOffset", "]", "=", "NOT_NULL_BYTE_LOW", ";", "DataEncoder", ".", "encode", "(", "~", "value", ".", "longValue", "(", ")", ",", "dst", ",", "dstOffset", "+", "1", ")", ";", "return", "9", ";", "}", "}" ]
Encodes the given signed Long object into exactly 1 or 9 bytes for descending order. If the Long object is never expected to be null, consider encoding as a long primitive. @param value optional signed Long value to encode @param dst destination for encoded bytes @param dstOffset offset into destination array @return amount of bytes written
[ "Encodes", "the", "given", "signed", "Long", "object", "into", "exactly", "1", "or", "9", "bytes", "for", "descending", "order", ".", "If", "the", "Long", "object", "is", "never", "expected", "to", "be", "null", "consider", "encoding", "as", "a", "long", "primitive", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyEncoder.java#L94-L103
7,849
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyEncoder.java
KeyEncoder.encodeDesc
public static int encodeDesc(Byte value, byte[] dst, int dstOffset) { if (value == null) { dst[dstOffset] = NULL_BYTE_LOW; return 1; } else { dst[dstOffset] = NOT_NULL_BYTE_LOW; dst[dstOffset + 1] = (byte)(value ^ 0x7f); return 2; } }
java
public static int encodeDesc(Byte value, byte[] dst, int dstOffset) { if (value == null) { dst[dstOffset] = NULL_BYTE_LOW; return 1; } else { dst[dstOffset] = NOT_NULL_BYTE_LOW; dst[dstOffset + 1] = (byte)(value ^ 0x7f); return 2; } }
[ "public", "static", "int", "encodeDesc", "(", "Byte", "value", ",", "byte", "[", "]", "dst", ",", "int", "dstOffset", ")", "{", "if", "(", "value", "==", "null", ")", "{", "dst", "[", "dstOffset", "]", "=", "NULL_BYTE_LOW", ";", "return", "1", ";", "}", "else", "{", "dst", "[", "dstOffset", "]", "=", "NOT_NULL_BYTE_LOW", ";", "dst", "[", "dstOffset", "+", "1", "]", "=", "(", "byte", ")", "(", "value", "^", "0x7f", ")", ";", "return", "2", ";", "}", "}" ]
Encodes the given signed Byte object into exactly 1 or 2 bytes for descending order. If the Byte object is never expected to be null, consider encoding as a byte primitive. @param value optional signed Byte value to encode @param dst destination for encoded bytes @param dstOffset offset into destination array @return amount of bytes written
[ "Encodes", "the", "given", "signed", "Byte", "object", "into", "exactly", "1", "or", "2", "bytes", "for", "descending", "order", ".", "If", "the", "Byte", "object", "is", "never", "expected", "to", "be", "null", "consider", "encoding", "as", "a", "byte", "primitive", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyEncoder.java#L126-L135
7,850
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyEncoder.java
KeyEncoder.encodeDesc
public static int encodeDesc(Short value, byte[] dst, int dstOffset) { if (value == null) { dst[dstOffset] = NULL_BYTE_LOW; return 1; } else { dst[dstOffset] = NOT_NULL_BYTE_LOW; DataEncoder.encode((short) ~value.shortValue(), dst, dstOffset + 1); return 3; } }
java
public static int encodeDesc(Short value, byte[] dst, int dstOffset) { if (value == null) { dst[dstOffset] = NULL_BYTE_LOW; return 1; } else { dst[dstOffset] = NOT_NULL_BYTE_LOW; DataEncoder.encode((short) ~value.shortValue(), dst, dstOffset + 1); return 3; } }
[ "public", "static", "int", "encodeDesc", "(", "Short", "value", ",", "byte", "[", "]", "dst", ",", "int", "dstOffset", ")", "{", "if", "(", "value", "==", "null", ")", "{", "dst", "[", "dstOffset", "]", "=", "NULL_BYTE_LOW", ";", "return", "1", ";", "}", "else", "{", "dst", "[", "dstOffset", "]", "=", "NOT_NULL_BYTE_LOW", ";", "DataEncoder", ".", "encode", "(", "(", "short", ")", "~", "value", ".", "shortValue", "(", ")", ",", "dst", ",", "dstOffset", "+", "1", ")", ";", "return", "3", ";", "}", "}" ]
Encodes the given signed Short object into exactly 1 or 3 bytes for descending order. If the Short object is never expected to be null, consider encoding as a short primitive. @param value optional signed Short value to encode @param dst destination for encoded bytes @param dstOffset offset into destination array @return amount of bytes written
[ "Encodes", "the", "given", "signed", "Short", "object", "into", "exactly", "1", "or", "3", "bytes", "for", "descending", "order", ".", "If", "the", "Short", "object", "is", "never", "expected", "to", "be", "null", "consider", "encoding", "as", "a", "short", "primitive", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyEncoder.java#L159-L168
7,851
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyEncoder.java
KeyEncoder.encodeDesc
public static int encodeDesc(Character value, byte[] dst, int dstOffset) { if (value == null) { dst[dstOffset] = NULL_BYTE_LOW; return 1; } else { dst[dstOffset] = NOT_NULL_BYTE_LOW; DataEncoder.encode((char) ~value.charValue(), dst, dstOffset + 1); return 3; } }
java
public static int encodeDesc(Character value, byte[] dst, int dstOffset) { if (value == null) { dst[dstOffset] = NULL_BYTE_LOW; return 1; } else { dst[dstOffset] = NOT_NULL_BYTE_LOW; DataEncoder.encode((char) ~value.charValue(), dst, dstOffset + 1); return 3; } }
[ "public", "static", "int", "encodeDesc", "(", "Character", "value", ",", "byte", "[", "]", "dst", ",", "int", "dstOffset", ")", "{", "if", "(", "value", "==", "null", ")", "{", "dst", "[", "dstOffset", "]", "=", "NULL_BYTE_LOW", ";", "return", "1", ";", "}", "else", "{", "dst", "[", "dstOffset", "]", "=", "NOT_NULL_BYTE_LOW", ";", "DataEncoder", ".", "encode", "(", "(", "char", ")", "~", "value", ".", "charValue", "(", ")", ",", "dst", ",", "dstOffset", "+", "1", ")", ";", "return", "3", ";", "}", "}" ]
Encodes the given Character object into exactly 1 or 3 bytes for descending order. If the Character object is never expected to be null, consider encoding as a char primitive. @param value optional Character value to encode @param dst destination for encoded bytes @param dstOffset offset into destination array @return amount of bytes written
[ "Encodes", "the", "given", "Character", "object", "into", "exactly", "1", "or", "3", "bytes", "for", "descending", "order", ".", "If", "the", "Character", "object", "is", "never", "expected", "to", "be", "null", "consider", "encoding", "as", "a", "char", "primitive", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyEncoder.java#L191-L200
7,852
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyEncoder.java
KeyEncoder.encodeDesc
public static void encodeDesc(Boolean value, byte[] dst, int dstOffset) { if (value == null) { dst[dstOffset] = NULL_BYTE_LOW; } else { dst[dstOffset] = value.booleanValue() ? (byte)127 : (byte)128; } }
java
public static void encodeDesc(Boolean value, byte[] dst, int dstOffset) { if (value == null) { dst[dstOffset] = NULL_BYTE_LOW; } else { dst[dstOffset] = value.booleanValue() ? (byte)127 : (byte)128; } }
[ "public", "static", "void", "encodeDesc", "(", "Boolean", "value", ",", "byte", "[", "]", "dst", ",", "int", "dstOffset", ")", "{", "if", "(", "value", "==", "null", ")", "{", "dst", "[", "dstOffset", "]", "=", "NULL_BYTE_LOW", ";", "}", "else", "{", "dst", "[", "dstOffset", "]", "=", "value", ".", "booleanValue", "(", ")", "?", "(", "byte", ")", "127", ":", "(", "byte", ")", "128", ";", "}", "}" ]
Encodes the given Boolean object into exactly 1 byte for descending order. @param value optional Boolean value to encode @param dst destination for encoded bytes @param dstOffset offset into destination array
[ "Encodes", "the", "given", "Boolean", "object", "into", "exactly", "1", "byte", "for", "descending", "order", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyEncoder.java#L221-L227
7,853
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyEncoder.java
KeyEncoder.encodeDesc
public static void encodeDesc(float value, byte[] dst, int dstOffset) { int bits = Float.floatToIntBits(value); if (bits >= 0) { bits ^= 0x7fffffff; } dst[dstOffset ] = (byte)(bits >> 24); dst[dstOffset + 1] = (byte)(bits >> 16); dst[dstOffset + 2] = (byte)(bits >> 8); dst[dstOffset + 3] = (byte)bits; }
java
public static void encodeDesc(float value, byte[] dst, int dstOffset) { int bits = Float.floatToIntBits(value); if (bits >= 0) { bits ^= 0x7fffffff; } dst[dstOffset ] = (byte)(bits >> 24); dst[dstOffset + 1] = (byte)(bits >> 16); dst[dstOffset + 2] = (byte)(bits >> 8); dst[dstOffset + 3] = (byte)bits; }
[ "public", "static", "void", "encodeDesc", "(", "float", "value", ",", "byte", "[", "]", "dst", ",", "int", "dstOffset", ")", "{", "int", "bits", "=", "Float", ".", "floatToIntBits", "(", "value", ")", ";", "if", "(", "bits", ">=", "0", ")", "{", "bits", "^=", "0x7fffffff", ";", "}", "dst", "[", "dstOffset", "]", "=", "(", "byte", ")", "(", "bits", ">>", "24", ")", ";", "dst", "[", "dstOffset", "+", "1", "]", "=", "(", "byte", ")", "(", "bits", ">>", "16", ")", ";", "dst", "[", "dstOffset", "+", "2", "]", "=", "(", "byte", ")", "(", "bits", ">>", "8", ")", ";", "dst", "[", "dstOffset", "+", "3", "]", "=", "(", "byte", ")", "bits", ";", "}" ]
Encodes the given float into exactly 4 bytes for descending order. @param value float value to encode @param dst destination for encoded bytes @param dstOffset offset into destination array
[ "Encodes", "the", "given", "float", "into", "exactly", "4", "bytes", "for", "descending", "order", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyEncoder.java#L236-L245
7,854
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyEncoder.java
KeyEncoder.encodeDesc
public static void encodeDesc(Float value, byte[] dst, int dstOffset) { if (value == null) { DataEncoder.encode(~0x7fffffff, dst, dstOffset); } else { encodeDesc(value.floatValue(), dst, dstOffset); } }
java
public static void encodeDesc(Float value, byte[] dst, int dstOffset) { if (value == null) { DataEncoder.encode(~0x7fffffff, dst, dstOffset); } else { encodeDesc(value.floatValue(), dst, dstOffset); } }
[ "public", "static", "void", "encodeDesc", "(", "Float", "value", ",", "byte", "[", "]", "dst", ",", "int", "dstOffset", ")", "{", "if", "(", "value", "==", "null", ")", "{", "DataEncoder", ".", "encode", "(", "~", "0x7fffffff", ",", "dst", ",", "dstOffset", ")", ";", "}", "else", "{", "encodeDesc", "(", "value", ".", "floatValue", "(", ")", ",", "dst", ",", "dstOffset", ")", ";", "}", "}" ]
Encodes the given Float object into exactly 4 bytes for descending order. A non-canonical NaN value is used to represent null. @param value optional Float value to encode @param dst destination for encoded bytes @param dstOffset offset into destination array
[ "Encodes", "the", "given", "Float", "object", "into", "exactly", "4", "bytes", "for", "descending", "order", ".", "A", "non", "-", "canonical", "NaN", "value", "is", "used", "to", "represent", "null", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyEncoder.java#L255-L261
7,855
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyEncoder.java
KeyEncoder.encodeDesc
public static void encodeDesc(double value, byte[] dst, int dstOffset) { long bits = Double.doubleToLongBits(value); if (bits >= 0) { bits ^= 0x7fffffffffffffffL; } int w = (int)(bits >> 32); dst[dstOffset ] = (byte)(w >> 24); dst[dstOffset + 1] = (byte)(w >> 16); dst[dstOffset + 2] = (byte)(w >> 8); dst[dstOffset + 3] = (byte)w; w = (int)bits; dst[dstOffset + 4] = (byte)(w >> 24); dst[dstOffset + 5] = (byte)(w >> 16); dst[dstOffset + 6] = (byte)(w >> 8); dst[dstOffset + 7] = (byte)w; }
java
public static void encodeDesc(double value, byte[] dst, int dstOffset) { long bits = Double.doubleToLongBits(value); if (bits >= 0) { bits ^= 0x7fffffffffffffffL; } int w = (int)(bits >> 32); dst[dstOffset ] = (byte)(w >> 24); dst[dstOffset + 1] = (byte)(w >> 16); dst[dstOffset + 2] = (byte)(w >> 8); dst[dstOffset + 3] = (byte)w; w = (int)bits; dst[dstOffset + 4] = (byte)(w >> 24); dst[dstOffset + 5] = (byte)(w >> 16); dst[dstOffset + 6] = (byte)(w >> 8); dst[dstOffset + 7] = (byte)w; }
[ "public", "static", "void", "encodeDesc", "(", "double", "value", ",", "byte", "[", "]", "dst", ",", "int", "dstOffset", ")", "{", "long", "bits", "=", "Double", ".", "doubleToLongBits", "(", "value", ")", ";", "if", "(", "bits", ">=", "0", ")", "{", "bits", "^=", "0x7fffffffffffffff", "", "L", ";", "}", "int", "w", "=", "(", "int", ")", "(", "bits", ">>", "32", ")", ";", "dst", "[", "dstOffset", "]", "=", "(", "byte", ")", "(", "w", ">>", "24", ")", ";", "dst", "[", "dstOffset", "+", "1", "]", "=", "(", "byte", ")", "(", "w", ">>", "16", ")", ";", "dst", "[", "dstOffset", "+", "2", "]", "=", "(", "byte", ")", "(", "w", ">>", "8", ")", ";", "dst", "[", "dstOffset", "+", "3", "]", "=", "(", "byte", ")", "w", ";", "w", "=", "(", "int", ")", "bits", ";", "dst", "[", "dstOffset", "+", "4", "]", "=", "(", "byte", ")", "(", "w", ">>", "24", ")", ";", "dst", "[", "dstOffset", "+", "5", "]", "=", "(", "byte", ")", "(", "w", ">>", "16", ")", ";", "dst", "[", "dstOffset", "+", "6", "]", "=", "(", "byte", ")", "(", "w", ">>", "8", ")", ";", "dst", "[", "dstOffset", "+", "7", "]", "=", "(", "byte", ")", "w", ";", "}" ]
Encodes the given double into exactly 8 bytes for descending order. @param value double value to encode @param dst destination for encoded bytes @param dstOffset offset into destination array
[ "Encodes", "the", "given", "double", "into", "exactly", "8", "bytes", "for", "descending", "order", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyEncoder.java#L270-L285
7,856
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyEncoder.java
KeyEncoder.encodeDesc
public static void encodeDesc(Double value, byte[] dst, int dstOffset) { if (value == null) { DataEncoder.encode(~0x7fffffffffffffffL, dst, dstOffset); } else { encodeDesc(value.doubleValue(), dst, dstOffset); } }
java
public static void encodeDesc(Double value, byte[] dst, int dstOffset) { if (value == null) { DataEncoder.encode(~0x7fffffffffffffffL, dst, dstOffset); } else { encodeDesc(value.doubleValue(), dst, dstOffset); } }
[ "public", "static", "void", "encodeDesc", "(", "Double", "value", ",", "byte", "[", "]", "dst", ",", "int", "dstOffset", ")", "{", "if", "(", "value", "==", "null", ")", "{", "DataEncoder", ".", "encode", "(", "~", "0x7fffffffffffffff", "L", ",", "dst", ",", "dstOffset", ")", ";", "}", "else", "{", "encodeDesc", "(", "value", ".", "doubleValue", "(", ")", ",", "dst", ",", "dstOffset", ")", ";", "}", "}" ]
Encodes the given Double object into exactly 8 bytes for descending order. A non-canonical NaN value is used to represent null. @param value optional Double value to encode @param dst destination for encoded bytes @param dstOffset offset into destination array
[ "Encodes", "the", "given", "Double", "object", "into", "exactly", "8", "bytes", "for", "descending", "order", ".", "A", "non", "-", "canonical", "NaN", "value", "is", "used", "to", "represent", "null", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyEncoder.java#L295-L301
7,857
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyEncoder.java
KeyEncoder.encodeDesc
public static int encodeDesc(BigInteger value, byte[] dst, int dstOffset) { /* Encoding of first byte: 0x00: null high (unused) 0x01: positive signum; four bytes follow for value length 0x02..0x7f: positive signum; value length 7e range, 1..126 0x80..0xfd: negative signum; value length 7e range, 1..126 0xfe: negative signum; four bytes follow for value length 0xff: null low */ if (value == null) { dst[dstOffset] = NULL_BYTE_LOW; return 1; } byte[] bytes = value.toByteArray(); // Always at least one. int bytesLength = bytes.length; int headerSize; if (bytesLength < 0x7f) { if (value.signum() < 0) { dst[dstOffset] = (byte) (bytesLength + 0x7f); } else { dst[dstOffset] = (byte) (0x80 - bytesLength); } headerSize = 1; } else { dst[dstOffset] = (byte) (value.signum() < 0 ? 0xfe : 1); int encodedLen = value.signum() < 0 ? bytesLength : -bytesLength; DataEncoder.encode(encodedLen, dst, dstOffset + 1); headerSize = 5; } dstOffset += headerSize; for (int i=0; i<bytesLength; i++) { dst[dstOffset + i] = (byte) ~bytes[i]; } return headerSize + bytesLength; }
java
public static int encodeDesc(BigInteger value, byte[] dst, int dstOffset) { /* Encoding of first byte: 0x00: null high (unused) 0x01: positive signum; four bytes follow for value length 0x02..0x7f: positive signum; value length 7e range, 1..126 0x80..0xfd: negative signum; value length 7e range, 1..126 0xfe: negative signum; four bytes follow for value length 0xff: null low */ if (value == null) { dst[dstOffset] = NULL_BYTE_LOW; return 1; } byte[] bytes = value.toByteArray(); // Always at least one. int bytesLength = bytes.length; int headerSize; if (bytesLength < 0x7f) { if (value.signum() < 0) { dst[dstOffset] = (byte) (bytesLength + 0x7f); } else { dst[dstOffset] = (byte) (0x80 - bytesLength); } headerSize = 1; } else { dst[dstOffset] = (byte) (value.signum() < 0 ? 0xfe : 1); int encodedLen = value.signum() < 0 ? bytesLength : -bytesLength; DataEncoder.encode(encodedLen, dst, dstOffset + 1); headerSize = 5; } dstOffset += headerSize; for (int i=0; i<bytesLength; i++) { dst[dstOffset + i] = (byte) ~bytes[i]; } return headerSize + bytesLength; }
[ "public", "static", "int", "encodeDesc", "(", "BigInteger", "value", ",", "byte", "[", "]", "dst", ",", "int", "dstOffset", ")", "{", "/* Encoding of first byte:\r\n\r\n 0x00: null high (unused)\r\n 0x01: positive signum; four bytes follow for value length\r\n 0x02..0x7f: positive signum; value length 7e range, 1..126\r\n 0x80..0xfd: negative signum; value length 7e range, 1..126\r\n 0xfe: negative signum; four bytes follow for value length\r\n 0xff: null low\r\n */", "if", "(", "value", "==", "null", ")", "{", "dst", "[", "dstOffset", "]", "=", "NULL_BYTE_LOW", ";", "return", "1", ";", "}", "byte", "[", "]", "bytes", "=", "value", ".", "toByteArray", "(", ")", ";", "// Always at least one.\r", "int", "bytesLength", "=", "bytes", ".", "length", ";", "int", "headerSize", ";", "if", "(", "bytesLength", "<", "0x7f", ")", "{", "if", "(", "value", ".", "signum", "(", ")", "<", "0", ")", "{", "dst", "[", "dstOffset", "]", "=", "(", "byte", ")", "(", "bytesLength", "+", "0x7f", ")", ";", "}", "else", "{", "dst", "[", "dstOffset", "]", "=", "(", "byte", ")", "(", "0x80", "-", "bytesLength", ")", ";", "}", "headerSize", "=", "1", ";", "}", "else", "{", "dst", "[", "dstOffset", "]", "=", "(", "byte", ")", "(", "value", ".", "signum", "(", ")", "<", "0", "?", "0xfe", ":", "1", ")", ";", "int", "encodedLen", "=", "value", ".", "signum", "(", ")", "<", "0", "?", "bytesLength", ":", "-", "bytesLength", ";", "DataEncoder", ".", "encode", "(", "encodedLen", ",", "dst", ",", "dstOffset", "+", "1", ")", ";", "headerSize", "=", "5", ";", "}", "dstOffset", "+=", "headerSize", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "bytesLength", ";", "i", "++", ")", "{", "dst", "[", "dstOffset", "+", "i", "]", "=", "(", "byte", ")", "~", "bytes", "[", "i", "]", ";", "}", "return", "headerSize", "+", "bytesLength", ";", "}" ]
Encodes the given optional BigInteger into a variable amount of bytes for descending order. If the BigInteger is null, exactly 1 byte is written. Otherwise, the amount written can be determined by calling calculateEncodedLength. @param value BigInteger value to encode, may be null @param dst destination for encoded bytes @param dstOffset offset into destination array @return amount of bytes written @since 1.2
[ "Encodes", "the", "given", "optional", "BigInteger", "into", "a", "variable", "amount", "of", "bytes", "for", "descending", "order", ".", "If", "the", "BigInteger", "is", "null", "exactly", "1", "byte", "is", "written", ".", "Otherwise", "the", "amount", "written", "can", "be", "determined", "by", "calling", "calculateEncodedLength", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyEncoder.java#L366-L407
7,858
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyEncoder.java
KeyEncoder.calculateEncodedLength
public static int calculateEncodedLength(BigInteger value) { if (value == null) { return 1; } int bytesLength = (value.bitLength() >> 3) + 1; return bytesLength < 0x7f ? (1 + bytesLength) : (5 + bytesLength); }
java
public static int calculateEncodedLength(BigInteger value) { if (value == null) { return 1; } int bytesLength = (value.bitLength() >> 3) + 1; return bytesLength < 0x7f ? (1 + bytesLength) : (5 + bytesLength); }
[ "public", "static", "int", "calculateEncodedLength", "(", "BigInteger", "value", ")", "{", "if", "(", "value", "==", "null", ")", "{", "return", "1", ";", "}", "int", "bytesLength", "=", "(", "value", ".", "bitLength", "(", ")", ">>", "3", ")", "+", "1", ";", "return", "bytesLength", "<", "0x7f", "?", "(", "1", "+", "bytesLength", ")", ":", "(", "5", "+", "bytesLength", ")", ";", "}" ]
Returns the amount of bytes required to encode a BigInteger. @param value BigInteger value to encode, may be null @return amount of bytes needed to encode @since 1.2
[ "Returns", "the", "amount", "of", "bytes", "required", "to", "encode", "a", "BigInteger", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyEncoder.java#L416-L422
7,859
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyEncoder.java
KeyEncoder.encodeDesc
public static int encodeDesc(BigDecimal value, byte[] dst, int dstOffset) { if (value == null) { dst[dstOffset] = NULL_BYTE_LOW; return 1; } if (value.signum() == 0) { dst[dstOffset] = (byte) 0x7f; return 1; } return encode(value).copyDescTo(dst, dstOffset); }
java
public static int encodeDesc(BigDecimal value, byte[] dst, int dstOffset) { if (value == null) { dst[dstOffset] = NULL_BYTE_LOW; return 1; } if (value.signum() == 0) { dst[dstOffset] = (byte) 0x7f; return 1; } return encode(value).copyDescTo(dst, dstOffset); }
[ "public", "static", "int", "encodeDesc", "(", "BigDecimal", "value", ",", "byte", "[", "]", "dst", ",", "int", "dstOffset", ")", "{", "if", "(", "value", "==", "null", ")", "{", "dst", "[", "dstOffset", "]", "=", "NULL_BYTE_LOW", ";", "return", "1", ";", "}", "if", "(", "value", ".", "signum", "(", ")", "==", "0", ")", "{", "dst", "[", "dstOffset", "]", "=", "(", "byte", ")", "0x7f", ";", "return", "1", ";", "}", "return", "encode", "(", "value", ")", ".", "copyDescTo", "(", "dst", ",", "dstOffset", ")", ";", "}" ]
Encodes the given optional BigDecimal into a variable amount of bytes for descending order. If the BigDecimal is null, exactly 1 byte is written. Otherwise, the amount written can be determined by calling calculateEncodedLength. <p><i>Note:</i> It is recommended that value be normalized by stripping trailing zeros. This makes searching by value much simpler. @param value BigDecimal value to encode, may be null @param dst destination for encoded bytes @param dstOffset offset into destination array @return amount of bytes written @since 1.2
[ "Encodes", "the", "given", "optional", "BigDecimal", "into", "a", "variable", "amount", "of", "bytes", "for", "descending", "order", ".", "If", "the", "BigDecimal", "is", "null", "exactly", "1", "byte", "is", "written", ".", "Otherwise", "the", "amount", "written", "can", "be", "determined", "by", "calling", "calculateEncodedLength", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyEncoder.java#L467-L479
7,860
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyEncoder.java
KeyEncoder.calculateEncodedLength
public static int calculateEncodedLength(BigDecimal value) { if (value == null || value.signum() == 0) { return 1; } return encode(value).mLength; }
java
public static int calculateEncodedLength(BigDecimal value) { if (value == null || value.signum() == 0) { return 1; } return encode(value).mLength; }
[ "public", "static", "int", "calculateEncodedLength", "(", "BigDecimal", "value", ")", "{", "if", "(", "value", "==", "null", "||", "value", ".", "signum", "(", ")", "==", "0", ")", "{", "return", "1", ";", "}", "return", "encode", "(", "value", ")", ".", "mLength", ";", "}" ]
Returns the amount of bytes required to encode a BigDecimal. <p><i>Note:</i> It is recommended that value be normalized by stripping trailing zeros. This makes searching by value much simpler. @param value BigDecimal value to encode, may be null @return amount of bytes needed to encode @since 1.2
[ "Returns", "the", "amount", "of", "bytes", "required", "to", "encode", "a", "BigDecimal", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyEncoder.java#L491-L497
7,861
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyEncoder.java
KeyEncoder.encode
public static int encode(byte[] value, int valueOffset, int valueLength, byte[] dst, int dstOffset) { return encode(value, valueOffset, valueLength, dst, dstOffset, 0); }
java
public static int encode(byte[] value, int valueOffset, int valueLength, byte[] dst, int dstOffset) { return encode(value, valueOffset, valueLength, dst, dstOffset, 0); }
[ "public", "static", "int", "encode", "(", "byte", "[", "]", "value", ",", "int", "valueOffset", ",", "int", "valueLength", ",", "byte", "[", "]", "dst", ",", "int", "dstOffset", ")", "{", "return", "encode", "(", "value", ",", "valueOffset", ",", "valueLength", ",", "dst", ",", "dstOffset", ",", "0", ")", ";", "}" ]
Encodes the given optional unsigned byte array into a variable amount of bytes. If the byte array is null, exactly 1 byte is written. Otherwise, the amount written can be determined by calling calculateEncodedLength. @param value byte array value to encode, may be null @param valueOffset offset into byte array @param valueLength length of data in byte array @param dst destination for encoded bytes @param dstOffset offset into destination array @return amount of bytes written
[ "Encodes", "the", "given", "optional", "unsigned", "byte", "array", "into", "a", "variable", "amount", "of", "bytes", ".", "If", "the", "byte", "array", "is", "null", "exactly", "1", "byte", "is", "written", ".", "Otherwise", "the", "amount", "written", "can", "be", "determined", "by", "calling", "calculateEncodedLength", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyEncoder.java#L712-L715
7,862
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyEncoder.java
KeyEncoder.encodeDesc
public static int encodeDesc(byte[] value, byte[] dst, int dstOffset) { if (value == null) { dst[dstOffset] = NULL_BYTE_LOW; return 1; } return encode(value, 0, value.length, dst, dstOffset, -1); }
java
public static int encodeDesc(byte[] value, byte[] dst, int dstOffset) { if (value == null) { dst[dstOffset] = NULL_BYTE_LOW; return 1; } return encode(value, 0, value.length, dst, dstOffset, -1); }
[ "public", "static", "int", "encodeDesc", "(", "byte", "[", "]", "value", ",", "byte", "[", "]", "dst", ",", "int", "dstOffset", ")", "{", "if", "(", "value", "==", "null", ")", "{", "dst", "[", "dstOffset", "]", "=", "NULL_BYTE_LOW", ";", "return", "1", ";", "}", "return", "encode", "(", "value", ",", "0", ",", "value", ".", "length", ",", "dst", ",", "dstOffset", ",", "-", "1", ")", ";", "}" ]
Encodes the given optional unsigned byte array into a variable amount of bytes for descending order. If the byte array is null, exactly 1 byte is written. Otherwise, the amount written is determined by calling calculateEncodedLength. @param value byte array value to encode, may be null @param dst destination for encoded bytes @param dstOffset offset into destination array @return amount of bytes written
[ "Encodes", "the", "given", "optional", "unsigned", "byte", "array", "into", "a", "variable", "amount", "of", "bytes", "for", "descending", "order", ".", "If", "the", "byte", "array", "is", "null", "exactly", "1", "byte", "is", "written", ".", "Otherwise", "the", "amount", "written", "is", "determined", "by", "calling", "calculateEncodedLength", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyEncoder.java#L728-L734
7,863
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyEncoder.java
KeyEncoder.emitDigit
private static void emitDigit(int value, byte[] dst, int dstOffset, int xorMask) { // The first byte is computed as ((value / 192) + 32) and the second // byte is computed as ((value % 192) + 32). To speed things up a bit, // the integer division and remainder operations are replaced with a // scaled multiplication. // approximate value / 192 int a = (value * 21845) >> 22; // approximate value % 192 // Note: the value 192 was chosen as a divisor because a multiply by // 192 can be replaced with two summed shifts. int b = value - ((a << 7) + (a << 6)); if (b == 192) { // Fix error. a++; b = 0; } dst[dstOffset++] = (byte)((a + 32) ^ xorMask); dst[dstOffset] = (byte)((b + 32) ^ xorMask); }
java
private static void emitDigit(int value, byte[] dst, int dstOffset, int xorMask) { // The first byte is computed as ((value / 192) + 32) and the second // byte is computed as ((value % 192) + 32). To speed things up a bit, // the integer division and remainder operations are replaced with a // scaled multiplication. // approximate value / 192 int a = (value * 21845) >> 22; // approximate value % 192 // Note: the value 192 was chosen as a divisor because a multiply by // 192 can be replaced with two summed shifts. int b = value - ((a << 7) + (a << 6)); if (b == 192) { // Fix error. a++; b = 0; } dst[dstOffset++] = (byte)((a + 32) ^ xorMask); dst[dstOffset] = (byte)((b + 32) ^ xorMask); }
[ "private", "static", "void", "emitDigit", "(", "int", "value", ",", "byte", "[", "]", "dst", ",", "int", "dstOffset", ",", "int", "xorMask", ")", "{", "// The first byte is computed as ((value / 192) + 32) and the second\r", "// byte is computed as ((value % 192) + 32). To speed things up a bit,\r", "// the integer division and remainder operations are replaced with a\r", "// scaled multiplication.\r", "// approximate value / 192\r", "int", "a", "=", "(", "value", "*", "21845", ")", ">>", "22", ";", "// approximate value % 192\r", "// Note: the value 192 was chosen as a divisor because a multiply by\r", "// 192 can be replaced with two summed shifts.\r", "int", "b", "=", "value", "-", "(", "(", "a", "<<", "7", ")", "+", "(", "a", "<<", "6", ")", ")", ";", "if", "(", "b", "==", "192", ")", "{", "// Fix error.\r", "a", "++", ";", "b", "=", "0", ";", "}", "dst", "[", "dstOffset", "++", "]", "=", "(", "byte", ")", "(", "(", "a", "+", "32", ")", "^", "xorMask", ")", ";", "dst", "[", "dstOffset", "]", "=", "(", "byte", ")", "(", "(", "b", "+", "32", ")", "^", "xorMask", ")", ";", "}" ]
Emits a base-32768 digit using exactly two bytes. The first byte is in the range 32..202 and the second byte is in the range 32..223. @param value digit value in the range 0..32767 @param dst destination for encoded bytes @param dstOffset offset into destination array @param xorMask 0 for normal encoding, -1 for descending encoding
[ "Emits", "a", "base", "-", "32768", "digit", "using", "exactly", "two", "bytes", ".", "The", "first", "byte", "is", "in", "the", "range", "32", "..", "202", "and", "the", "second", "byte", "is", "in", "the", "range", "32", "..", "223", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyEncoder.java#L826-L847
7,864
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyEncoder.java
KeyEncoder.calculateEncodedStringLength
public static int calculateEncodedStringLength(String value) { int encodedLen = 1; if (value != null) { int valueLength = value.length(); for (int i = 0; i < valueLength; i++) { int c = value.charAt(i); if (c <= (0x7f - 2)) { encodedLen++; } else if (c <= (12415 - 2)) { encodedLen += 2; } else { if (c >= 0xd800 && c <= 0xdbff) { // Found a high surrogate. Verify that surrogate pair is // well-formed. Low surrogate must follow high surrogate. if (i + 1 < valueLength) { int c2 = value.charAt(i + 1); if (c2 >= 0xdc00 && c2 <= 0xdfff) { i++; } } } encodedLen += 3; } } } return encodedLen; }
java
public static int calculateEncodedStringLength(String value) { int encodedLen = 1; if (value != null) { int valueLength = value.length(); for (int i = 0; i < valueLength; i++) { int c = value.charAt(i); if (c <= (0x7f - 2)) { encodedLen++; } else if (c <= (12415 - 2)) { encodedLen += 2; } else { if (c >= 0xd800 && c <= 0xdbff) { // Found a high surrogate. Verify that surrogate pair is // well-formed. Low surrogate must follow high surrogate. if (i + 1 < valueLength) { int c2 = value.charAt(i + 1); if (c2 >= 0xdc00 && c2 <= 0xdfff) { i++; } } } encodedLen += 3; } } } return encodedLen; }
[ "public", "static", "int", "calculateEncodedStringLength", "(", "String", "value", ")", "{", "int", "encodedLen", "=", "1", ";", "if", "(", "value", "!=", "null", ")", "{", "int", "valueLength", "=", "value", ".", "length", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "valueLength", ";", "i", "++", ")", "{", "int", "c", "=", "value", ".", "charAt", "(", "i", ")", ";", "if", "(", "c", "<=", "(", "0x7f", "-", "2", ")", ")", "{", "encodedLen", "++", ";", "}", "else", "if", "(", "c", "<=", "(", "12415", "-", "2", ")", ")", "{", "encodedLen", "+=", "2", ";", "}", "else", "{", "if", "(", "c", ">=", "0xd800", "&&", "c", "<=", "0xdbff", ")", "{", "// Found a high surrogate. Verify that surrogate pair is\r", "// well-formed. Low surrogate must follow high surrogate.\r", "if", "(", "i", "+", "1", "<", "valueLength", ")", "{", "int", "c2", "=", "value", ".", "charAt", "(", "i", "+", "1", ")", ";", "if", "(", "c2", ">=", "0xdc00", "&&", "c2", "<=", "0xdfff", ")", "{", "i", "++", ";", "}", "}", "}", "encodedLen", "+=", "3", ";", "}", "}", "}", "return", "encodedLen", ";", "}" ]
Returns the amount of bytes required to encode the given String. @param value String to encode, may be null
[ "Returns", "the", "amount", "of", "bytes", "required", "to", "encode", "the", "given", "String", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyEncoder.java#L1015-L1041
7,865
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyEncoder.java
KeyEncoder.encodeSingleDesc
public static byte[] encodeSingleDesc(byte[] value, int prefixPadding, int suffixPadding) { int length = value.length; if (prefixPadding <= 0 && suffixPadding <= 0 && length == 0) { return value; } byte[] dst = new byte[prefixPadding + length + suffixPadding]; while (--length >= 0) { dst[prefixPadding + length] = (byte) (~value[length]); } return dst; }
java
public static byte[] encodeSingleDesc(byte[] value, int prefixPadding, int suffixPadding) { int length = value.length; if (prefixPadding <= 0 && suffixPadding <= 0 && length == 0) { return value; } byte[] dst = new byte[prefixPadding + length + suffixPadding]; while (--length >= 0) { dst[prefixPadding + length] = (byte) (~value[length]); } return dst; }
[ "public", "static", "byte", "[", "]", "encodeSingleDesc", "(", "byte", "[", "]", "value", ",", "int", "prefixPadding", ",", "int", "suffixPadding", ")", "{", "int", "length", "=", "value", ".", "length", ";", "if", "(", "prefixPadding", "<=", "0", "&&", "suffixPadding", "<=", "0", "&&", "length", "==", "0", ")", "{", "return", "value", ";", "}", "byte", "[", "]", "dst", "=", "new", "byte", "[", "prefixPadding", "+", "length", "+", "suffixPadding", "]", ";", "while", "(", "--", "length", ">=", "0", ")", "{", "dst", "[", "prefixPadding", "+", "length", "]", "=", "(", "byte", ")", "(", "~", "value", "[", "length", "]", ")", ";", "}", "return", "dst", ";", "}" ]
Encodes the given byte array for use when there is only a single required property, descending order, whose type is a byte array. The original byte array is returned if the length and padding lengths are zero. @param prefixPadding amount of extra bytes to allocate at start of encoded byte array @param suffixPadding amount of extra bytes to allocate at end of encoded byte array
[ "Encodes", "the", "given", "byte", "array", "for", "use", "when", "there", "is", "only", "a", "single", "required", "property", "descending", "order", "whose", "type", "is", "a", "byte", "array", ".", "The", "original", "byte", "array", "is", "returned", "if", "the", "length", "and", "padding", "lengths", "are", "zero", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyEncoder.java#L1061-L1071
7,866
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyEncoder.java
KeyEncoder.encodeSingleNullableDesc
public static byte[] encodeSingleNullableDesc(byte[] value, int prefixPadding, int suffixPadding) { if (prefixPadding <= 0 && suffixPadding <= 0) { if (value == null) { return new byte[] {NULL_BYTE_LOW}; } int length = value.length; if (length == 0) { return new byte[] {NOT_NULL_BYTE_LOW}; } byte[] dst = new byte[1 + length]; dst[0] = NOT_NULL_BYTE_LOW; while (--length >= 0) { dst[1 + length] = (byte) (~value[length]); } return dst; } if (value == null) { byte[] dst = new byte[prefixPadding + 1 + suffixPadding]; dst[prefixPadding] = NULL_BYTE_LOW; return dst; } int length = value.length; byte[] dst = new byte[prefixPadding + 1 + length + suffixPadding]; dst[prefixPadding] = NOT_NULL_BYTE_LOW; while (--length >= 0) { dst[prefixPadding + 1 + length] = (byte) (~value[length]); } return dst; }
java
public static byte[] encodeSingleNullableDesc(byte[] value, int prefixPadding, int suffixPadding) { if (prefixPadding <= 0 && suffixPadding <= 0) { if (value == null) { return new byte[] {NULL_BYTE_LOW}; } int length = value.length; if (length == 0) { return new byte[] {NOT_NULL_BYTE_LOW}; } byte[] dst = new byte[1 + length]; dst[0] = NOT_NULL_BYTE_LOW; while (--length >= 0) { dst[1 + length] = (byte) (~value[length]); } return dst; } if (value == null) { byte[] dst = new byte[prefixPadding + 1 + suffixPadding]; dst[prefixPadding] = NULL_BYTE_LOW; return dst; } int length = value.length; byte[] dst = new byte[prefixPadding + 1 + length + suffixPadding]; dst[prefixPadding] = NOT_NULL_BYTE_LOW; while (--length >= 0) { dst[prefixPadding + 1 + length] = (byte) (~value[length]); } return dst; }
[ "public", "static", "byte", "[", "]", "encodeSingleNullableDesc", "(", "byte", "[", "]", "value", ",", "int", "prefixPadding", ",", "int", "suffixPadding", ")", "{", "if", "(", "prefixPadding", "<=", "0", "&&", "suffixPadding", "<=", "0", ")", "{", "if", "(", "value", "==", "null", ")", "{", "return", "new", "byte", "[", "]", "{", "NULL_BYTE_LOW", "}", ";", "}", "int", "length", "=", "value", ".", "length", ";", "if", "(", "length", "==", "0", ")", "{", "return", "new", "byte", "[", "]", "{", "NOT_NULL_BYTE_LOW", "}", ";", "}", "byte", "[", "]", "dst", "=", "new", "byte", "[", "1", "+", "length", "]", ";", "dst", "[", "0", "]", "=", "NOT_NULL_BYTE_LOW", ";", "while", "(", "--", "length", ">=", "0", ")", "{", "dst", "[", "1", "+", "length", "]", "=", "(", "byte", ")", "(", "~", "value", "[", "length", "]", ")", ";", "}", "return", "dst", ";", "}", "if", "(", "value", "==", "null", ")", "{", "byte", "[", "]", "dst", "=", "new", "byte", "[", "prefixPadding", "+", "1", "+", "suffixPadding", "]", ";", "dst", "[", "prefixPadding", "]", "=", "NULL_BYTE_LOW", ";", "return", "dst", ";", "}", "int", "length", "=", "value", ".", "length", ";", "byte", "[", "]", "dst", "=", "new", "byte", "[", "prefixPadding", "+", "1", "+", "length", "+", "suffixPadding", "]", ";", "dst", "[", "prefixPadding", "]", "=", "NOT_NULL_BYTE_LOW", ";", "while", "(", "--", "length", ">=", "0", ")", "{", "dst", "[", "prefixPadding", "+", "1", "+", "length", "]", "=", "(", "byte", ")", "(", "~", "value", "[", "length", "]", ")", ";", "}", "return", "dst", ";", "}" ]
Encodes the given byte array for use when there is only a single nullable property, descending order, whose type is a byte array. @param prefixPadding amount of extra bytes to allocate at start of encoded byte array @param suffixPadding amount of extra bytes to allocate at end of encoded byte array
[ "Encodes", "the", "given", "byte", "array", "for", "use", "when", "there", "is", "only", "a", "single", "nullable", "property", "descending", "order", "whose", "type", "is", "a", "byte", "array", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyEncoder.java#L1088-L1121
7,867
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/DataEncoder.java
DataEncoder.encode
public static void encode(int value, byte[] dst, int dstOffset) { value ^= 0x80000000; dst[dstOffset ] = (byte)(value >> 24); dst[dstOffset + 1] = (byte)(value >> 16); dst[dstOffset + 2] = (byte)(value >> 8); dst[dstOffset + 3] = (byte)value; }
java
public static void encode(int value, byte[] dst, int dstOffset) { value ^= 0x80000000; dst[dstOffset ] = (byte)(value >> 24); dst[dstOffset + 1] = (byte)(value >> 16); dst[dstOffset + 2] = (byte)(value >> 8); dst[dstOffset + 3] = (byte)value; }
[ "public", "static", "void", "encode", "(", "int", "value", ",", "byte", "[", "]", "dst", ",", "int", "dstOffset", ")", "{", "value", "^=", "0x80000000", ";", "dst", "[", "dstOffset", "]", "=", "(", "byte", ")", "(", "value", ">>", "24", ")", ";", "dst", "[", "dstOffset", "+", "1", "]", "=", "(", "byte", ")", "(", "value", ">>", "16", ")", ";", "dst", "[", "dstOffset", "+", "2", "]", "=", "(", "byte", ")", "(", "value", ">>", "8", ")", ";", "dst", "[", "dstOffset", "+", "3", "]", "=", "(", "byte", ")", "value", ";", "}" ]
Encodes the given signed integer into exactly 4 bytes. @param value signed integer value to encode @param dst destination for encoded bytes @param dstOffset offset into destination array
[ "Encodes", "the", "given", "signed", "integer", "into", "exactly", "4", "bytes", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/DataEncoder.java#L47-L53
7,868
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/DataEncoder.java
DataEncoder.encode
public static int encode(Integer value, byte[] dst, int dstOffset) { if (value == null) { dst[dstOffset] = NULL_BYTE_HIGH; return 1; } else { dst[dstOffset] = NOT_NULL_BYTE_HIGH; encode(value.intValue(), dst, dstOffset + 1); return 5; } }
java
public static int encode(Integer value, byte[] dst, int dstOffset) { if (value == null) { dst[dstOffset] = NULL_BYTE_HIGH; return 1; } else { dst[dstOffset] = NOT_NULL_BYTE_HIGH; encode(value.intValue(), dst, dstOffset + 1); return 5; } }
[ "public", "static", "int", "encode", "(", "Integer", "value", ",", "byte", "[", "]", "dst", ",", "int", "dstOffset", ")", "{", "if", "(", "value", "==", "null", ")", "{", "dst", "[", "dstOffset", "]", "=", "NULL_BYTE_HIGH", ";", "return", "1", ";", "}", "else", "{", "dst", "[", "dstOffset", "]", "=", "NOT_NULL_BYTE_HIGH", ";", "encode", "(", "value", ".", "intValue", "(", ")", ",", "dst", ",", "dstOffset", "+", "1", ")", ";", "return", "5", ";", "}", "}" ]
Encodes the given signed Integer object into exactly 1 or 5 bytes. If the Integer object is never expected to be null, consider encoding as an int primitive. @param value optional signed Integer value to encode @param dst destination for encoded bytes @param dstOffset offset into destination array @return amount of bytes written
[ "Encodes", "the", "given", "signed", "Integer", "object", "into", "exactly", "1", "or", "5", "bytes", ".", "If", "the", "Integer", "object", "is", "never", "expected", "to", "be", "null", "consider", "encoding", "as", "an", "int", "primitive", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/DataEncoder.java#L65-L74
7,869
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/DataEncoder.java
DataEncoder.encode
public static void encode(long value, byte[] dst, int dstOffset) { int w = ((int)(value >> 32)) ^ 0x80000000; dst[dstOffset ] = (byte)(w >> 24); dst[dstOffset + 1] = (byte)(w >> 16); dst[dstOffset + 2] = (byte)(w >> 8); dst[dstOffset + 3] = (byte)w; w = (int)value; dst[dstOffset + 4] = (byte)(w >> 24); dst[dstOffset + 5] = (byte)(w >> 16); dst[dstOffset + 6] = (byte)(w >> 8); dst[dstOffset + 7] = (byte)w; }
java
public static void encode(long value, byte[] dst, int dstOffset) { int w = ((int)(value >> 32)) ^ 0x80000000; dst[dstOffset ] = (byte)(w >> 24); dst[dstOffset + 1] = (byte)(w >> 16); dst[dstOffset + 2] = (byte)(w >> 8); dst[dstOffset + 3] = (byte)w; w = (int)value; dst[dstOffset + 4] = (byte)(w >> 24); dst[dstOffset + 5] = (byte)(w >> 16); dst[dstOffset + 6] = (byte)(w >> 8); dst[dstOffset + 7] = (byte)w; }
[ "public", "static", "void", "encode", "(", "long", "value", ",", "byte", "[", "]", "dst", ",", "int", "dstOffset", ")", "{", "int", "w", "=", "(", "(", "int", ")", "(", "value", ">>", "32", ")", ")", "^", "0x80000000", ";", "dst", "[", "dstOffset", "]", "=", "(", "byte", ")", "(", "w", ">>", "24", ")", ";", "dst", "[", "dstOffset", "+", "1", "]", "=", "(", "byte", ")", "(", "w", ">>", "16", ")", ";", "dst", "[", "dstOffset", "+", "2", "]", "=", "(", "byte", ")", "(", "w", ">>", "8", ")", ";", "dst", "[", "dstOffset", "+", "3", "]", "=", "(", "byte", ")", "w", ";", "w", "=", "(", "int", ")", "value", ";", "dst", "[", "dstOffset", "+", "4", "]", "=", "(", "byte", ")", "(", "w", ">>", "24", ")", ";", "dst", "[", "dstOffset", "+", "5", "]", "=", "(", "byte", ")", "(", "w", ">>", "16", ")", ";", "dst", "[", "dstOffset", "+", "6", "]", "=", "(", "byte", ")", "(", "w", ">>", "8", ")", ";", "dst", "[", "dstOffset", "+", "7", "]", "=", "(", "byte", ")", "w", ";", "}" ]
Encodes the given signed long into exactly 8 bytes. @param value signed long value to encode @param dst destination for encoded bytes @param dstOffset offset into destination array
[ "Encodes", "the", "given", "signed", "long", "into", "exactly", "8", "bytes", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/DataEncoder.java#L83-L94
7,870
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/DataEncoder.java
DataEncoder.encode
public static int encode(Long value, byte[] dst, int dstOffset) { if (value == null) { dst[dstOffset] = NULL_BYTE_HIGH; return 1; } else { dst[dstOffset] = NOT_NULL_BYTE_HIGH; encode(value.longValue(), dst, dstOffset + 1); return 9; } }
java
public static int encode(Long value, byte[] dst, int dstOffset) { if (value == null) { dst[dstOffset] = NULL_BYTE_HIGH; return 1; } else { dst[dstOffset] = NOT_NULL_BYTE_HIGH; encode(value.longValue(), dst, dstOffset + 1); return 9; } }
[ "public", "static", "int", "encode", "(", "Long", "value", ",", "byte", "[", "]", "dst", ",", "int", "dstOffset", ")", "{", "if", "(", "value", "==", "null", ")", "{", "dst", "[", "dstOffset", "]", "=", "NULL_BYTE_HIGH", ";", "return", "1", ";", "}", "else", "{", "dst", "[", "dstOffset", "]", "=", "NOT_NULL_BYTE_HIGH", ";", "encode", "(", "value", ".", "longValue", "(", ")", ",", "dst", ",", "dstOffset", "+", "1", ")", ";", "return", "9", ";", "}", "}" ]
Encodes the given signed Long object into exactly 1 or 9 bytes. If the Long object is never expected to be null, consider encoding as a long primitive. @param value optional signed Long value to encode @param dst destination for encoded bytes @param dstOffset offset into destination array @return amount of bytes written
[ "Encodes", "the", "given", "signed", "Long", "object", "into", "exactly", "1", "or", "9", "bytes", ".", "If", "the", "Long", "object", "is", "never", "expected", "to", "be", "null", "consider", "encoding", "as", "a", "long", "primitive", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/DataEncoder.java#L106-L115
7,871
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/DataEncoder.java
DataEncoder.encode
public static int encode(Byte value, byte[] dst, int dstOffset) { if (value == null) { dst[dstOffset] = NULL_BYTE_HIGH; return 1; } else { dst[dstOffset] = NOT_NULL_BYTE_HIGH; dst[dstOffset + 1] = (byte)(value ^ 0x80); return 2; } }
java
public static int encode(Byte value, byte[] dst, int dstOffset) { if (value == null) { dst[dstOffset] = NULL_BYTE_HIGH; return 1; } else { dst[dstOffset] = NOT_NULL_BYTE_HIGH; dst[dstOffset + 1] = (byte)(value ^ 0x80); return 2; } }
[ "public", "static", "int", "encode", "(", "Byte", "value", ",", "byte", "[", "]", "dst", ",", "int", "dstOffset", ")", "{", "if", "(", "value", "==", "null", ")", "{", "dst", "[", "dstOffset", "]", "=", "NULL_BYTE_HIGH", ";", "return", "1", ";", "}", "else", "{", "dst", "[", "dstOffset", "]", "=", "NOT_NULL_BYTE_HIGH", ";", "dst", "[", "dstOffset", "+", "1", "]", "=", "(", "byte", ")", "(", "value", "^", "0x80", ")", ";", "return", "2", ";", "}", "}" ]
Encodes the given signed Byte object into exactly 1 or 2 bytes. If the Byte object is never expected to be null, consider encoding as a byte primitive. @param value optional signed Byte value to encode @param dst destination for encoded bytes @param dstOffset offset into destination array @return amount of bytes written
[ "Encodes", "the", "given", "signed", "Byte", "object", "into", "exactly", "1", "or", "2", "bytes", ".", "If", "the", "Byte", "object", "is", "never", "expected", "to", "be", "null", "consider", "encoding", "as", "a", "byte", "primitive", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/DataEncoder.java#L138-L147
7,872
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/DataEncoder.java
DataEncoder.encode
public static void encode(short value, byte[] dst, int dstOffset) { value ^= 0x8000; dst[dstOffset ] = (byte)(value >> 8); dst[dstOffset + 1] = (byte)value; }
java
public static void encode(short value, byte[] dst, int dstOffset) { value ^= 0x8000; dst[dstOffset ] = (byte)(value >> 8); dst[dstOffset + 1] = (byte)value; }
[ "public", "static", "void", "encode", "(", "short", "value", ",", "byte", "[", "]", "dst", ",", "int", "dstOffset", ")", "{", "value", "^=", "0x8000", ";", "dst", "[", "dstOffset", "]", "=", "(", "byte", ")", "(", "value", ">>", "8", ")", ";", "dst", "[", "dstOffset", "+", "1", "]", "=", "(", "byte", ")", "value", ";", "}" ]
Encodes the given signed short into exactly 2 bytes. @param value signed short value to encode @param dst destination for encoded bytes @param dstOffset offset into destination array
[ "Encodes", "the", "given", "signed", "short", "into", "exactly", "2", "bytes", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/DataEncoder.java#L156-L160
7,873
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/DataEncoder.java
DataEncoder.encode
public static int encode(Short value, byte[] dst, int dstOffset) { if (value == null) { dst[dstOffset] = NULL_BYTE_HIGH; return 1; } else { dst[dstOffset] = NOT_NULL_BYTE_HIGH; encode(value.shortValue(), dst, dstOffset + 1); return 3; } }
java
public static int encode(Short value, byte[] dst, int dstOffset) { if (value == null) { dst[dstOffset] = NULL_BYTE_HIGH; return 1; } else { dst[dstOffset] = NOT_NULL_BYTE_HIGH; encode(value.shortValue(), dst, dstOffset + 1); return 3; } }
[ "public", "static", "int", "encode", "(", "Short", "value", ",", "byte", "[", "]", "dst", ",", "int", "dstOffset", ")", "{", "if", "(", "value", "==", "null", ")", "{", "dst", "[", "dstOffset", "]", "=", "NULL_BYTE_HIGH", ";", "return", "1", ";", "}", "else", "{", "dst", "[", "dstOffset", "]", "=", "NOT_NULL_BYTE_HIGH", ";", "encode", "(", "value", ".", "shortValue", "(", ")", ",", "dst", ",", "dstOffset", "+", "1", ")", ";", "return", "3", ";", "}", "}" ]
Encodes the given signed Short object into exactly 1 or 3 bytes. If the Short object is never expected to be null, consider encoding as a short primitive. @param value optional signed Short value to encode @param dst destination for encoded bytes @param dstOffset offset into destination array @return amount of bytes written
[ "Encodes", "the", "given", "signed", "Short", "object", "into", "exactly", "1", "or", "3", "bytes", ".", "If", "the", "Short", "object", "is", "never", "expected", "to", "be", "null", "consider", "encoding", "as", "a", "short", "primitive", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/DataEncoder.java#L172-L181
7,874
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/DataEncoder.java
DataEncoder.encode
public static int encode(Character value, byte[] dst, int dstOffset) { if (value == null) { dst[dstOffset] = NULL_BYTE_HIGH; return 1; } else { dst[dstOffset] = NOT_NULL_BYTE_HIGH; encode(value.charValue(), dst, dstOffset + 1); return 3; } }
java
public static int encode(Character value, byte[] dst, int dstOffset) { if (value == null) { dst[dstOffset] = NULL_BYTE_HIGH; return 1; } else { dst[dstOffset] = NOT_NULL_BYTE_HIGH; encode(value.charValue(), dst, dstOffset + 1); return 3; } }
[ "public", "static", "int", "encode", "(", "Character", "value", ",", "byte", "[", "]", "dst", ",", "int", "dstOffset", ")", "{", "if", "(", "value", "==", "null", ")", "{", "dst", "[", "dstOffset", "]", "=", "NULL_BYTE_HIGH", ";", "return", "1", ";", "}", "else", "{", "dst", "[", "dstOffset", "]", "=", "NOT_NULL_BYTE_HIGH", ";", "encode", "(", "value", ".", "charValue", "(", ")", ",", "dst", ",", "dstOffset", "+", "1", ")", ";", "return", "3", ";", "}", "}" ]
Encodes the given Character object into exactly 1 or 3 bytes. If the Character object is never expected to be null, consider encoding as a char primitive. @param value optional Character value to encode @param dst destination for encoded bytes @param dstOffset offset into destination array @return amount of bytes written
[ "Encodes", "the", "given", "Character", "object", "into", "exactly", "1", "or", "3", "bytes", ".", "If", "the", "Character", "object", "is", "never", "expected", "to", "be", "null", "consider", "encoding", "as", "a", "char", "primitive", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/DataEncoder.java#L205-L214
7,875
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/DataEncoder.java
DataEncoder.encode
public static void encode(Boolean value, byte[] dst, int dstOffset) { if (value == null) { dst[dstOffset] = NULL_BYTE_HIGH; } else { dst[dstOffset] = value.booleanValue() ? (byte)128 : (byte)127; } }
java
public static void encode(Boolean value, byte[] dst, int dstOffset) { if (value == null) { dst[dstOffset] = NULL_BYTE_HIGH; } else { dst[dstOffset] = value.booleanValue() ? (byte)128 : (byte)127; } }
[ "public", "static", "void", "encode", "(", "Boolean", "value", ",", "byte", "[", "]", "dst", ",", "int", "dstOffset", ")", "{", "if", "(", "value", "==", "null", ")", "{", "dst", "[", "dstOffset", "]", "=", "NULL_BYTE_HIGH", ";", "}", "else", "{", "dst", "[", "dstOffset", "]", "=", "value", ".", "booleanValue", "(", ")", "?", "(", "byte", ")", "128", ":", "(", "byte", ")", "127", ";", "}", "}" ]
Encodes the given Boolean object into exactly 1 byte. @param value optional Boolean value to encode @param dst destination for encoded bytes @param dstOffset offset into destination array
[ "Encodes", "the", "given", "Boolean", "object", "into", "exactly", "1", "byte", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/DataEncoder.java#L234-L240
7,876
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/DataEncoder.java
DataEncoder.encode
public static void encode(float value, byte[] dst, int dstOffset) { int bits = Float.floatToIntBits(value); bits ^= (bits < 0) ? 0xffffffff : 0x80000000; dst[dstOffset ] = (byte)(bits >> 24); dst[dstOffset + 1] = (byte)(bits >> 16); dst[dstOffset + 2] = (byte)(bits >> 8); dst[dstOffset + 3] = (byte)bits; }
java
public static void encode(float value, byte[] dst, int dstOffset) { int bits = Float.floatToIntBits(value); bits ^= (bits < 0) ? 0xffffffff : 0x80000000; dst[dstOffset ] = (byte)(bits >> 24); dst[dstOffset + 1] = (byte)(bits >> 16); dst[dstOffset + 2] = (byte)(bits >> 8); dst[dstOffset + 3] = (byte)bits; }
[ "public", "static", "void", "encode", "(", "float", "value", ",", "byte", "[", "]", "dst", ",", "int", "dstOffset", ")", "{", "int", "bits", "=", "Float", ".", "floatToIntBits", "(", "value", ")", ";", "bits", "^=", "(", "bits", "<", "0", ")", "?", "0xffffffff", ":", "0x80000000", ";", "dst", "[", "dstOffset", "]", "=", "(", "byte", ")", "(", "bits", ">>", "24", ")", ";", "dst", "[", "dstOffset", "+", "1", "]", "=", "(", "byte", ")", "(", "bits", ">>", "16", ")", ";", "dst", "[", "dstOffset", "+", "2", "]", "=", "(", "byte", ")", "(", "bits", ">>", "8", ")", ";", "dst", "[", "dstOffset", "+", "3", "]", "=", "(", "byte", ")", "bits", ";", "}" ]
Encodes the given float into exactly 4 bytes. @param value float value to encode @param dst destination for encoded bytes @param dstOffset offset into destination array
[ "Encodes", "the", "given", "float", "into", "exactly", "4", "bytes", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/DataEncoder.java#L249-L256
7,877
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/DataEncoder.java
DataEncoder.encode
public static void encode(Float value, byte[] dst, int dstOffset) { if (value == null) { encode(0x7fffffff, dst, dstOffset); } else { encode(value.floatValue(), dst, dstOffset); } }
java
public static void encode(Float value, byte[] dst, int dstOffset) { if (value == null) { encode(0x7fffffff, dst, dstOffset); } else { encode(value.floatValue(), dst, dstOffset); } }
[ "public", "static", "void", "encode", "(", "Float", "value", ",", "byte", "[", "]", "dst", ",", "int", "dstOffset", ")", "{", "if", "(", "value", "==", "null", ")", "{", "encode", "(", "0x7fffffff", ",", "dst", ",", "dstOffset", ")", ";", "}", "else", "{", "encode", "(", "value", ".", "floatValue", "(", ")", ",", "dst", ",", "dstOffset", ")", ";", "}", "}" ]
Encodes the given Float object into exactly 4 bytes. A non-canonical NaN value is used to represent null. @param value optional Float value to encode @param dst destination for encoded bytes @param dstOffset offset into destination array
[ "Encodes", "the", "given", "Float", "object", "into", "exactly", "4", "bytes", ".", "A", "non", "-", "canonical", "NaN", "value", "is", "used", "to", "represent", "null", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/DataEncoder.java#L266-L272
7,878
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/DataEncoder.java
DataEncoder.calculateEncodedLength
public static int calculateEncodedLength(BigInteger value) { if (value == null) { return 1; } int byteCount = (value.bitLength() >> 3) + 1; return unsignedVarIntLength(byteCount) + byteCount; }
java
public static int calculateEncodedLength(BigInteger value) { if (value == null) { return 1; } int byteCount = (value.bitLength() >> 3) + 1; return unsignedVarIntLength(byteCount) + byteCount; }
[ "public", "static", "int", "calculateEncodedLength", "(", "BigInteger", "value", ")", "{", "if", "(", "value", "==", "null", ")", "{", "return", "1", ";", "}", "int", "byteCount", "=", "(", "value", ".", "bitLength", "(", ")", ">>", "3", ")", "+", "1", ";", "return", "unsignedVarIntLength", "(", "byteCount", ")", "+", "byteCount", ";", "}" ]
Returns the amount of bytes required to encode the given BigInteger. @param value BigInteger value to encode, may be null @return amount of bytes needed to encode @since 1.2
[ "Returns", "the", "amount", "of", "bytes", "required", "to", "encode", "the", "given", "BigInteger", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/DataEncoder.java#L347-L353
7,879
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/DataEncoder.java
DataEncoder.calculateEncodedLength
public static int calculateEncodedLength(BigDecimal value) { if (value == null) { return 1; } return signedVarIntLength(value.scale()) + calculateEncodedLength(value.unscaledValue()); }
java
public static int calculateEncodedLength(BigDecimal value) { if (value == null) { return 1; } return signedVarIntLength(value.scale()) + calculateEncodedLength(value.unscaledValue()); }
[ "public", "static", "int", "calculateEncodedLength", "(", "BigDecimal", "value", ")", "{", "if", "(", "value", "==", "null", ")", "{", "return", "1", ";", "}", "return", "signedVarIntLength", "(", "value", ".", "scale", "(", ")", ")", "+", "calculateEncodedLength", "(", "value", ".", "unscaledValue", "(", ")", ")", ";", "}" ]
Returns the amount of bytes required to encode the given BigDecimal. @param value BigDecimal value to encode, may be null @return amount of bytes needed to encode @since 1.2
[ "Returns", "the", "amount", "of", "bytes", "required", "to", "encode", "the", "given", "BigDecimal", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/DataEncoder.java#L382-L387
7,880
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/DataEncoder.java
DataEncoder.writeLength
public static int writeLength(int valueLength, OutputStream out) throws IOException { if (valueLength < 128) { out.write(valueLength); return 1; } else if (valueLength < 16384) { out.write((valueLength >> 8) | 0x80); out.write(valueLength); return 2; } else if (valueLength < 2097152) { out.write((valueLength >> 16) | 0xc0); out.write(valueLength >> 8); out.write(valueLength); return 3; } else if (valueLength < 268435456) { out.write((valueLength >> 24) | 0xe0); out.write(valueLength >> 16); out.write(valueLength >> 8); out.write(valueLength); return 4; } else { out.write(0xf0); out.write(valueLength >> 24); out.write(valueLength >> 16); out.write(valueLength >> 8); out.write(valueLength); return 5; } }
java
public static int writeLength(int valueLength, OutputStream out) throws IOException { if (valueLength < 128) { out.write(valueLength); return 1; } else if (valueLength < 16384) { out.write((valueLength >> 8) | 0x80); out.write(valueLength); return 2; } else if (valueLength < 2097152) { out.write((valueLength >> 16) | 0xc0); out.write(valueLength >> 8); out.write(valueLength); return 3; } else if (valueLength < 268435456) { out.write((valueLength >> 24) | 0xe0); out.write(valueLength >> 16); out.write(valueLength >> 8); out.write(valueLength); return 4; } else { out.write(0xf0); out.write(valueLength >> 24); out.write(valueLength >> 16); out.write(valueLength >> 8); out.write(valueLength); return 5; } }
[ "public", "static", "int", "writeLength", "(", "int", "valueLength", ",", "OutputStream", "out", ")", "throws", "IOException", "{", "if", "(", "valueLength", "<", "128", ")", "{", "out", ".", "write", "(", "valueLength", ")", ";", "return", "1", ";", "}", "else", "if", "(", "valueLength", "<", "16384", ")", "{", "out", ".", "write", "(", "(", "valueLength", ">>", "8", ")", "|", "0x80", ")", ";", "out", ".", "write", "(", "valueLength", ")", ";", "return", "2", ";", "}", "else", "if", "(", "valueLength", "<", "2097152", ")", "{", "out", ".", "write", "(", "(", "valueLength", ">>", "16", ")", "|", "0xc0", ")", ";", "out", ".", "write", "(", "valueLength", ">>", "8", ")", ";", "out", ".", "write", "(", "valueLength", ")", ";", "return", "3", ";", "}", "else", "if", "(", "valueLength", "<", "268435456", ")", "{", "out", ".", "write", "(", "(", "valueLength", ">>", "24", ")", "|", "0xe0", ")", ";", "out", ".", "write", "(", "valueLength", ">>", "16", ")", ";", "out", ".", "write", "(", "valueLength", ">>", "8", ")", ";", "out", ".", "write", "(", "valueLength", ")", ";", "return", "4", ";", "}", "else", "{", "out", ".", "write", "(", "0xf0", ")", ";", "out", ".", "write", "(", "valueLength", ">>", "24", ")", ";", "out", ".", "write", "(", "valueLength", ">>", "16", ")", ";", "out", ".", "write", "(", "valueLength", ">>", "8", ")", ";", "out", ".", "write", "(", "valueLength", ")", ";", "return", "5", ";", "}", "}" ]
Writes a positive length value in up to five bytes. @return number of bytes written @since 1.2
[ "Writes", "a", "positive", "length", "value", "in", "up", "to", "five", "bytes", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/DataEncoder.java#L616-L643
7,881
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/DataEncoder.java
DataEncoder.encodeSingle
public static byte[] encodeSingle(byte[] value, int prefixPadding, int suffixPadding) { if (prefixPadding <= 0 && suffixPadding <= 0) { return value; } int length = value.length; byte[] dst = new byte[prefixPadding + length + suffixPadding]; System.arraycopy(value, 0, dst, prefixPadding, length); return dst; }
java
public static byte[] encodeSingle(byte[] value, int prefixPadding, int suffixPadding) { if (prefixPadding <= 0 && suffixPadding <= 0) { return value; } int length = value.length; byte[] dst = new byte[prefixPadding + length + suffixPadding]; System.arraycopy(value, 0, dst, prefixPadding, length); return dst; }
[ "public", "static", "byte", "[", "]", "encodeSingle", "(", "byte", "[", "]", "value", ",", "int", "prefixPadding", ",", "int", "suffixPadding", ")", "{", "if", "(", "prefixPadding", "<=", "0", "&&", "suffixPadding", "<=", "0", ")", "{", "return", "value", ";", "}", "int", "length", "=", "value", ".", "length", ";", "byte", "[", "]", "dst", "=", "new", "byte", "[", "prefixPadding", "+", "length", "+", "suffixPadding", "]", ";", "System", ".", "arraycopy", "(", "value", ",", "0", ",", "dst", ",", "prefixPadding", ",", "length", ")", ";", "return", "dst", ";", "}" ]
Encodes the given byte array for use when there is only a single property, whose type is a byte array. The original byte array is returned if the padding lengths are zero. @param prefixPadding amount of extra bytes to allocate at start of encoded byte array @param suffixPadding amount of extra bytes to allocate at end of encoded byte array
[ "Encodes", "the", "given", "byte", "array", "for", "use", "when", "there", "is", "only", "a", "single", "property", "whose", "type", "is", "a", "byte", "array", ".", "The", "original", "byte", "array", "is", "returned", "if", "the", "padding", "lengths", "are", "zero", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/DataEncoder.java#L653-L661
7,882
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/DataEncoder.java
DataEncoder.encodeSingleNullable
public static byte[] encodeSingleNullable(byte[] value, int prefixPadding, int suffixPadding) { if (prefixPadding <= 0 && suffixPadding <= 0) { if (value == null) { return new byte[] {NULL_BYTE_HIGH}; } int length = value.length; if (length == 0) { return new byte[] {NOT_NULL_BYTE_HIGH}; } byte[] dst = new byte[1 + length]; dst[0] = NOT_NULL_BYTE_HIGH; System.arraycopy(value, 0, dst, 1, length); return dst; } if (value == null) { byte[] dst = new byte[prefixPadding + 1 + suffixPadding]; dst[prefixPadding] = NULL_BYTE_HIGH; return dst; } int length = value.length; byte[] dst = new byte[prefixPadding + 1 + length + suffixPadding]; dst[prefixPadding] = NOT_NULL_BYTE_HIGH; System.arraycopy(value, 0, dst, prefixPadding + 1, length); return dst; }
java
public static byte[] encodeSingleNullable(byte[] value, int prefixPadding, int suffixPadding) { if (prefixPadding <= 0 && suffixPadding <= 0) { if (value == null) { return new byte[] {NULL_BYTE_HIGH}; } int length = value.length; if (length == 0) { return new byte[] {NOT_NULL_BYTE_HIGH}; } byte[] dst = new byte[1 + length]; dst[0] = NOT_NULL_BYTE_HIGH; System.arraycopy(value, 0, dst, 1, length); return dst; } if (value == null) { byte[] dst = new byte[prefixPadding + 1 + suffixPadding]; dst[prefixPadding] = NULL_BYTE_HIGH; return dst; } int length = value.length; byte[] dst = new byte[prefixPadding + 1 + length + suffixPadding]; dst[prefixPadding] = NOT_NULL_BYTE_HIGH; System.arraycopy(value, 0, dst, prefixPadding + 1, length); return dst; }
[ "public", "static", "byte", "[", "]", "encodeSingleNullable", "(", "byte", "[", "]", "value", ",", "int", "prefixPadding", ",", "int", "suffixPadding", ")", "{", "if", "(", "prefixPadding", "<=", "0", "&&", "suffixPadding", "<=", "0", ")", "{", "if", "(", "value", "==", "null", ")", "{", "return", "new", "byte", "[", "]", "{", "NULL_BYTE_HIGH", "}", ";", "}", "int", "length", "=", "value", ".", "length", ";", "if", "(", "length", "==", "0", ")", "{", "return", "new", "byte", "[", "]", "{", "NOT_NULL_BYTE_HIGH", "}", ";", "}", "byte", "[", "]", "dst", "=", "new", "byte", "[", "1", "+", "length", "]", ";", "dst", "[", "0", "]", "=", "NOT_NULL_BYTE_HIGH", ";", "System", ".", "arraycopy", "(", "value", ",", "0", ",", "dst", ",", "1", ",", "length", ")", ";", "return", "dst", ";", "}", "if", "(", "value", "==", "null", ")", "{", "byte", "[", "]", "dst", "=", "new", "byte", "[", "prefixPadding", "+", "1", "+", "suffixPadding", "]", ";", "dst", "[", "prefixPadding", "]", "=", "NULL_BYTE_HIGH", ";", "return", "dst", ";", "}", "int", "length", "=", "value", ".", "length", ";", "byte", "[", "]", "dst", "=", "new", "byte", "[", "prefixPadding", "+", "1", "+", "length", "+", "suffixPadding", "]", ";", "dst", "[", "prefixPadding", "]", "=", "NOT_NULL_BYTE_HIGH", ";", "System", ".", "arraycopy", "(", "value", ",", "0", ",", "dst", ",", "prefixPadding", "+", "1", ",", "length", ")", ";", "return", "dst", ";", "}" ]
Encodes the given byte array for use when there is only a single nullable property, whose type is a byte array. @param prefixPadding amount of extra bytes to allocate at start of encoded byte array @param suffixPadding amount of extra bytes to allocate at end of encoded byte array
[ "Encodes", "the", "given", "byte", "array", "for", "use", "when", "there", "is", "only", "a", "single", "nullable", "property", "whose", "type", "is", "a", "byte", "array", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/DataEncoder.java#L678-L706
7,883
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/spi/AbstractRepository.java
AbstractRepository.getCapability
@SuppressWarnings("unchecked") public <C extends Capability> C getCapability(Class<C> capabilityType) { if (capabilityType.isInstance(this)) { return (C) this; } return null; }
java
@SuppressWarnings("unchecked") public <C extends Capability> C getCapability(Class<C> capabilityType) { if (capabilityType.isInstance(this)) { return (C) this; } return null; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "C", "extends", "Capability", ">", "C", "getCapability", "(", "Class", "<", "C", ">", "capabilityType", ")", "{", "if", "(", "capabilityType", ".", "isInstance", "(", "this", ")", ")", "{", "return", "(", "C", ")", "this", ";", "}", "return", "null", ";", "}" ]
Default implementation checks if Repository implements Capability interface, and if so, returns the Repository.
[ "Default", "implementation", "checks", "if", "Repository", "implements", "Capability", "interface", "and", "if", "so", "returns", "the", "Repository", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/spi/AbstractRepository.java#L134-L140
7,884
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/spi/AbstractRepository.java
AbstractRepository.setAutoShutdownEnabled
public synchronized void setAutoShutdownEnabled(boolean enabled) { try { if (mShutdownHook == null) { if (enabled) { ShutdownHook hook = new ShutdownHook(this); Runtime.getRuntime().addShutdownHook(hook); mShutdownHook = hook; } } else { if (!enabled) { Runtime.getRuntime().removeShutdownHook(mShutdownHook); mShutdownHook = null; } } } catch (IllegalStateException e) { // Shutdown is in progress so make no changes. } }
java
public synchronized void setAutoShutdownEnabled(boolean enabled) { try { if (mShutdownHook == null) { if (enabled) { ShutdownHook hook = new ShutdownHook(this); Runtime.getRuntime().addShutdownHook(hook); mShutdownHook = hook; } } else { if (!enabled) { Runtime.getRuntime().removeShutdownHook(mShutdownHook); mShutdownHook = null; } } } catch (IllegalStateException e) { // Shutdown is in progress so make no changes. } }
[ "public", "synchronized", "void", "setAutoShutdownEnabled", "(", "boolean", "enabled", ")", "{", "try", "{", "if", "(", "mShutdownHook", "==", "null", ")", "{", "if", "(", "enabled", ")", "{", "ShutdownHook", "hook", "=", "new", "ShutdownHook", "(", "this", ")", ";", "Runtime", ".", "getRuntime", "(", ")", ".", "addShutdownHook", "(", "hook", ")", ";", "mShutdownHook", "=", "hook", ";", "}", "}", "else", "{", "if", "(", "!", "enabled", ")", "{", "Runtime", ".", "getRuntime", "(", ")", ".", "removeShutdownHook", "(", "mShutdownHook", ")", ";", "mShutdownHook", "=", "null", ";", "}", "}", "}", "catch", "(", "IllegalStateException", "e", ")", "{", "// Shutdown is in progress so make no changes.\r", "}", "}" ]
Required by ShutdownCapability.
[ "Required", "by", "ShutdownCapability", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/spi/AbstractRepository.java#L157-L174
7,885
michael-rapp/AndroidMaterialValidation
library/src/main/java/de/mrapp/android/validation/validators/NegateValidator.java
NegateValidator.setValidator
public final void setValidator(@NonNull final Validator<Type> validator) { Condition.INSTANCE.ensureNotNull(validator, "The validator may not be null"); this.validator = validator; }
java
public final void setValidator(@NonNull final Validator<Type> validator) { Condition.INSTANCE.ensureNotNull(validator, "The validator may not be null"); this.validator = validator; }
[ "public", "final", "void", "setValidator", "(", "@", "NonNull", "final", "Validator", "<", "Type", ">", "validator", ")", "{", "Condition", ".", "INSTANCE", ".", "ensureNotNull", "(", "validator", ",", "\"The validator may not be null\"", ")", ";", "this", ".", "validator", "=", "validator", ";", "}" ]
Sets the validator, whose result should be negated. @param validator The validator, which should be set, as an instance of the type {@link Validator}. The validator may not be null
[ "Sets", "the", "validator", "whose", "result", "should", "be", "negated", "." ]
ac8693baeac7abddf2e38a47da4c1849d4661a8b
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/validators/NegateValidator.java#L133-L136
7,886
cose-wg/COSE-JAVA
src/main/java/COSE/Signer.java
Signer.setupKey
private void setupKey(OneKey key) throws CoseException { CBORObject cn2; CBORObject cn; cnKey = key; if (rgbSignature != null) return; cn = key.get(KeyKeys.Algorithm); if (cn != null) { cn2 = findAttribute(HeaderKeys.Algorithm); if (cn2 == null) addAttribute(HeaderKeys.Algorithm, cn, Attribute.PROTECTED); } cn = key.get(KeyKeys.KeyId); if (cn != null) { cn2 = findAttribute(HeaderKeys.KID); if (cn2 == null) addAttribute(HeaderKeys.KID, cn, Attribute.UNPROTECTED); } }
java
private void setupKey(OneKey key) throws CoseException { CBORObject cn2; CBORObject cn; cnKey = key; if (rgbSignature != null) return; cn = key.get(KeyKeys.Algorithm); if (cn != null) { cn2 = findAttribute(HeaderKeys.Algorithm); if (cn2 == null) addAttribute(HeaderKeys.Algorithm, cn, Attribute.PROTECTED); } cn = key.get(KeyKeys.KeyId); if (cn != null) { cn2 = findAttribute(HeaderKeys.KID); if (cn2 == null) addAttribute(HeaderKeys.KID, cn, Attribute.UNPROTECTED); } }
[ "private", "void", "setupKey", "(", "OneKey", "key", ")", "throws", "CoseException", "{", "CBORObject", "cn2", ";", "CBORObject", "cn", ";", "cnKey", "=", "key", ";", "if", "(", "rgbSignature", "!=", "null", ")", "return", ";", "cn", "=", "key", ".", "get", "(", "KeyKeys", ".", "Algorithm", ")", ";", "if", "(", "cn", "!=", "null", ")", "{", "cn2", "=", "findAttribute", "(", "HeaderKeys", ".", "Algorithm", ")", ";", "if", "(", "cn2", "==", "null", ")", "addAttribute", "(", "HeaderKeys", ".", "Algorithm", ",", "cn", ",", "Attribute", ".", "PROTECTED", ")", ";", "}", "cn", "=", "key", ".", "get", "(", "KeyKeys", ".", "KeyId", ")", ";", "if", "(", "cn", "!=", "null", ")", "{", "cn2", "=", "findAttribute", "(", "HeaderKeys", ".", "KID", ")", ";", "if", "(", "cn2", "==", "null", ")", "addAttribute", "(", "HeaderKeys", ".", "KID", ",", "cn", ",", "Attribute", ".", "UNPROTECTED", ")", ";", "}", "}" ]
Set the key on the object, if there is not a signature on this object then set the algorithm and the key id from the key if they exist on the key and do not exist in the message. @param key key to be used]
[ "Set", "the", "key", "on", "the", "object", "if", "there", "is", "not", "a", "signature", "on", "this", "object", "then", "set", "the", "algorithm", "and", "the", "key", "id", "from", "the", "key", "if", "they", "exist", "on", "the", "key", "and", "do", "not", "exist", "in", "the", "message", "." ]
f972b11ab4c9a18f911bc49a15225a6951cf6f63
https://github.com/cose-wg/COSE-JAVA/blob/f972b11ab4c9a18f911bc49a15225a6951cf6f63/src/main/java/COSE/Signer.java#L72-L91
7,887
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/repo/map/MapRepositoryBuilder.java
MapRepositoryBuilder.newRepository
public static Repository newRepository() { try { MapRepositoryBuilder builder = new MapRepositoryBuilder(); return builder.build(); } catch (RepositoryException e) { // Not expected. throw new RuntimeException(e); } }
java
public static Repository newRepository() { try { MapRepositoryBuilder builder = new MapRepositoryBuilder(); return builder.build(); } catch (RepositoryException e) { // Not expected. throw new RuntimeException(e); } }
[ "public", "static", "Repository", "newRepository", "(", ")", "{", "try", "{", "MapRepositoryBuilder", "builder", "=", "new", "MapRepositoryBuilder", "(", ")", ";", "return", "builder", ".", "build", "(", ")", ";", "}", "catch", "(", "RepositoryException", "e", ")", "{", "// Not expected.\r", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}" ]
Convenience method to build a new MapRepository.
[ "Convenience", "method", "to", "build", "a", "new", "MapRepository", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/repo/map/MapRepositoryBuilder.java#L61-L69
7,888
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/repo/map/MapRepositoryBuilder.java
MapRepositoryBuilder.setLockTimeout
public void setLockTimeout(int timeout, TimeUnit unit) { if (timeout < 0 || unit == null) { throw new IllegalArgumentException(); } mLockTimeout = timeout; mLockTimeoutUnit = unit; }
java
public void setLockTimeout(int timeout, TimeUnit unit) { if (timeout < 0 || unit == null) { throw new IllegalArgumentException(); } mLockTimeout = timeout; mLockTimeoutUnit = unit; }
[ "public", "void", "setLockTimeout", "(", "int", "timeout", ",", "TimeUnit", "unit", ")", "{", "if", "(", "timeout", "<", "0", "||", "unit", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", ")", ";", "}", "mLockTimeout", "=", "timeout", ";", "mLockTimeoutUnit", "=", "unit", ";", "}" ]
Set the lock timeout. Default value is 500 milliseconds.
[ "Set", "the", "lock", "timeout", ".", "Default", "value", "is", "500", "milliseconds", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/repo/map/MapRepositoryBuilder.java#L130-L136
7,889
michael-rapp/AndroidMaterialValidation
library/src/main/java/de/mrapp/android/validation/validators/AbstractValidator.java
AbstractValidator.setIcon
public final void setIcon(@NonNull final Context context, @DrawableRes final int resourceId) { Condition.INSTANCE.ensureNotNull(context, "The context may not be null"); this.icon = ContextCompat.getDrawable(context, resourceId); }
java
public final void setIcon(@NonNull final Context context, @DrawableRes final int resourceId) { Condition.INSTANCE.ensureNotNull(context, "The context may not be null"); this.icon = ContextCompat.getDrawable(context, resourceId); }
[ "public", "final", "void", "setIcon", "(", "@", "NonNull", "final", "Context", "context", ",", "@", "DrawableRes", "final", "int", "resourceId", ")", "{", "Condition", ".", "INSTANCE", ".", "ensureNotNull", "(", "context", ",", "\"The context may not be null\"", ")", ";", "this", ".", "icon", "=", "ContextCompat", ".", "getDrawable", "(", "context", ",", "resourceId", ")", ";", "}" ]
Sets the icon, which should be shown, if the validation fails. @param context The context, which should be used to retrieve the icon, as an instance of the class {@link Context}. The context may not be null @param resourceId The resource ID of the drawable resource, which contains the icon, which should be set, as an {@link Integer} value. The resource ID must correspond to a valid drawable resource
[ "Sets", "the", "icon", "which", "should", "be", "shown", "if", "the", "validation", "fails", "." ]
ac8693baeac7abddf2e38a47da4c1849d4661a8b
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/validators/AbstractValidator.java#L126-L129
7,890
michael-rapp/AndroidMaterialValidation
library/src/main/java/de/mrapp/android/validation/PasswordEditText.java
PasswordEditText.obtainPasswordVerificationPrefix
private void obtainPasswordVerificationPrefix(@NonNull final TypedArray typedArray) { String format = typedArray.getString(R.styleable.PasswordEditText_passwordVerificationPrefix); if (format == null) { format = getResources().getString(R.string.password_verification_prefix); } setPasswordVerificationPrefix(format); }
java
private void obtainPasswordVerificationPrefix(@NonNull final TypedArray typedArray) { String format = typedArray.getString(R.styleable.PasswordEditText_passwordVerificationPrefix); if (format == null) { format = getResources().getString(R.string.password_verification_prefix); } setPasswordVerificationPrefix(format); }
[ "private", "void", "obtainPasswordVerificationPrefix", "(", "@", "NonNull", "final", "TypedArray", "typedArray", ")", "{", "String", "format", "=", "typedArray", ".", "getString", "(", "R", ".", "styleable", ".", "PasswordEditText_passwordVerificationPrefix", ")", ";", "if", "(", "format", "==", "null", ")", "{", "format", "=", "getResources", "(", ")", ".", "getString", "(", "R", ".", "string", ".", "password_verification_prefix", ")", ";", "}", "setPasswordVerificationPrefix", "(", "format", ")", ";", "}" ]
Obtains the prefix of helper texts, which are shown depending on the password strength, from a specific typed array. @param typedArray The typed array, the prefix should be obtained from, as an instance of the class {@link TypedArray}. The typed array may not be null
[ "Obtains", "the", "prefix", "of", "helper", "texts", "which", "are", "shown", "depending", "on", "the", "password", "strength", "from", "a", "specific", "typed", "array", "." ]
ac8693baeac7abddf2e38a47da4c1849d4661a8b
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/PasswordEditText.java#L127-L136
7,891
michael-rapp/AndroidMaterialValidation
library/src/main/java/de/mrapp/android/validation/PasswordEditText.java
PasswordEditText.createTextChangeListener
private TextWatcher createTextChangeListener() { return new TextWatcher() { @Override public final void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) { } @Override public final void onTextChanged(final CharSequence s, final int start, final int before, final int count) { } @Override public final void afterTextChanged(final Editable s) { verifyPasswordStrength(); } }; }
java
private TextWatcher createTextChangeListener() { return new TextWatcher() { @Override public final void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) { } @Override public final void onTextChanged(final CharSequence s, final int start, final int before, final int count) { } @Override public final void afterTextChanged(final Editable s) { verifyPasswordStrength(); } }; }
[ "private", "TextWatcher", "createTextChangeListener", "(", ")", "{", "return", "new", "TextWatcher", "(", ")", "{", "@", "Override", "public", "final", "void", "beforeTextChanged", "(", "final", "CharSequence", "s", ",", "final", "int", "start", ",", "final", "int", "count", ",", "final", "int", "after", ")", "{", "}", "@", "Override", "public", "final", "void", "onTextChanged", "(", "final", "CharSequence", "s", ",", "final", "int", "start", ",", "final", "int", "before", ",", "final", "int", "count", ")", "{", "}", "@", "Override", "public", "final", "void", "afterTextChanged", "(", "final", "Editable", "s", ")", "{", "verifyPasswordStrength", "(", ")", ";", "}", "}", ";", "}" ]
Creates and returns a listener, which allows to verify the password strength, when the password has been changed. @return The listener, which has been created, as an instance of the type {@link TextWatcher}
[ "Creates", "and", "returns", "a", "listener", "which", "allows", "to", "verify", "the", "password", "strength", "when", "the", "password", "has", "been", "changed", "." ]
ac8693baeac7abddf2e38a47da4c1849d4661a8b
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/PasswordEditText.java#L144-L165
7,892
michael-rapp/AndroidMaterialValidation
library/src/main/java/de/mrapp/android/validation/PasswordEditText.java
PasswordEditText.verifyPasswordStrength
private void verifyPasswordStrength() { if (isEnabled() && !constraints.isEmpty() && !TextUtils.isEmpty(getText())) { float score = getPasswordStrength(); adaptHelperText(score); } else { setHelperText(regularHelperText); } }
java
private void verifyPasswordStrength() { if (isEnabled() && !constraints.isEmpty() && !TextUtils.isEmpty(getText())) { float score = getPasswordStrength(); adaptHelperText(score); } else { setHelperText(regularHelperText); } }
[ "private", "void", "verifyPasswordStrength", "(", ")", "{", "if", "(", "isEnabled", "(", ")", "&&", "!", "constraints", ".", "isEmpty", "(", ")", "&&", "!", "TextUtils", ".", "isEmpty", "(", "getText", "(", ")", ")", ")", "{", "float", "score", "=", "getPasswordStrength", "(", ")", ";", "adaptHelperText", "(", "score", ")", ";", "}", "else", "{", "setHelperText", "(", "regularHelperText", ")", ";", "}", "}" ]
Verifies the strength of the current password, depending on the constraints, which have been added and adapts the appearance of the view accordingly.
[ "Verifies", "the", "strength", "of", "the", "current", "password", "depending", "on", "the", "constraints", "which", "have", "been", "added", "and", "adapts", "the", "appearance", "of", "the", "view", "accordingly", "." ]
ac8693baeac7abddf2e38a47da4c1849d4661a8b
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/PasswordEditText.java#L171-L178
7,893
michael-rapp/AndroidMaterialValidation
library/src/main/java/de/mrapp/android/validation/PasswordEditText.java
PasswordEditText.getPasswordStrength
private float getPasswordStrength() { int absoluteScore = 0; CharSequence password = getView().getText(); for (Constraint<CharSequence> constraint : constraints) { if (constraint.isSatisfied(password)) { absoluteScore++; } } return ((float) absoluteScore / (float) constraints.size()); }
java
private float getPasswordStrength() { int absoluteScore = 0; CharSequence password = getView().getText(); for (Constraint<CharSequence> constraint : constraints) { if (constraint.isSatisfied(password)) { absoluteScore++; } } return ((float) absoluteScore / (float) constraints.size()); }
[ "private", "float", "getPasswordStrength", "(", ")", "{", "int", "absoluteScore", "=", "0", ";", "CharSequence", "password", "=", "getView", "(", ")", ".", "getText", "(", ")", ";", "for", "(", "Constraint", "<", "CharSequence", ">", "constraint", ":", "constraints", ")", "{", "if", "(", "constraint", ".", "isSatisfied", "(", "password", ")", ")", "{", "absoluteScore", "++", ";", "}", "}", "return", "(", "(", "float", ")", "absoluteScore", "/", "(", "float", ")", "constraints", ".", "size", "(", ")", ")", ";", "}" ]
Returns the strength of the current password, depending on the constraints, which have been added. @return The fraction of constraints, which are satisfied, as a {@link Float} value between 0.0 and 1.0
[ "Returns", "the", "strength", "of", "the", "current", "password", "depending", "on", "the", "constraints", "which", "have", "been", "added", "." ]
ac8693baeac7abddf2e38a47da4c1849d4661a8b
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/PasswordEditText.java#L187-L198
7,894
michael-rapp/AndroidMaterialValidation
library/src/main/java/de/mrapp/android/validation/PasswordEditText.java
PasswordEditText.adaptHelperText
private void adaptHelperText(final float score) { if (!helperTexts.isEmpty()) { CharSequence helperText = getHelperText(score); if (helperText != null) { int color = getHelperTextColor(score); helperText = "<font color=\"" + color + "\">" + helperText + "</font>"; String prefix = getPasswordVerificationPrefix(); if (prefix != null) { prefix = "<font color=\"" + regularHelperTextColor + "\">" + prefix + ": </font>"; } else { prefix = ""; } setHelperText(Html.fromHtml(prefix + helperText)); } else { setHelperText(regularHelperText); } } else { setHelperText(regularHelperText); } }
java
private void adaptHelperText(final float score) { if (!helperTexts.isEmpty()) { CharSequence helperText = getHelperText(score); if (helperText != null) { int color = getHelperTextColor(score); helperText = "<font color=\"" + color + "\">" + helperText + "</font>"; String prefix = getPasswordVerificationPrefix(); if (prefix != null) { prefix = "<font color=\"" + regularHelperTextColor + "\">" + prefix + ": </font>"; } else { prefix = ""; } setHelperText(Html.fromHtml(prefix + helperText)); } else { setHelperText(regularHelperText); } } else { setHelperText(regularHelperText); } }
[ "private", "void", "adaptHelperText", "(", "final", "float", "score", ")", "{", "if", "(", "!", "helperTexts", ".", "isEmpty", "(", ")", ")", "{", "CharSequence", "helperText", "=", "getHelperText", "(", "score", ")", ";", "if", "(", "helperText", "!=", "null", ")", "{", "int", "color", "=", "getHelperTextColor", "(", "score", ")", ";", "helperText", "=", "\"<font color=\\\"\"", "+", "color", "+", "\"\\\">\"", "+", "helperText", "+", "\"</font>\"", ";", "String", "prefix", "=", "getPasswordVerificationPrefix", "(", ")", ";", "if", "(", "prefix", "!=", "null", ")", "{", "prefix", "=", "\"<font color=\\\"\"", "+", "regularHelperTextColor", "+", "\"\\\">\"", "+", "prefix", "+", "\": </font>\"", ";", "}", "else", "{", "prefix", "=", "\"\"", ";", "}", "setHelperText", "(", "Html", ".", "fromHtml", "(", "prefix", "+", "helperText", ")", ")", ";", "}", "else", "{", "setHelperText", "(", "regularHelperText", ")", ";", "}", "}", "else", "{", "setHelperText", "(", "regularHelperText", ")", ";", "}", "}" ]
Adapts the helper text, depending on a specific password strength. @param score The password strength as a {@link Float} value between 0.0 and 1.0, which represents the fraction of constraints, which are satisfied
[ "Adapts", "the", "helper", "text", "depending", "on", "a", "specific", "password", "strength", "." ]
ac8693baeac7abddf2e38a47da4c1849d4661a8b
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/PasswordEditText.java#L207-L230
7,895
michael-rapp/AndroidMaterialValidation
library/src/main/java/de/mrapp/android/validation/PasswordEditText.java
PasswordEditText.getHelperText
private CharSequence getHelperText(final float score) { if (!helperTexts.isEmpty()) { float interval = 1.0f / helperTexts.size(); int index = (int) Math.floor(score / interval) - 1; index = Math.max(index, 0); index = Math.min(index, helperTexts.size() - 1); return helperTexts.get(index); } return null; }
java
private CharSequence getHelperText(final float score) { if (!helperTexts.isEmpty()) { float interval = 1.0f / helperTexts.size(); int index = (int) Math.floor(score / interval) - 1; index = Math.max(index, 0); index = Math.min(index, helperTexts.size() - 1); return helperTexts.get(index); } return null; }
[ "private", "CharSequence", "getHelperText", "(", "final", "float", "score", ")", "{", "if", "(", "!", "helperTexts", ".", "isEmpty", "(", ")", ")", "{", "float", "interval", "=", "1.0f", "/", "helperTexts", ".", "size", "(", ")", ";", "int", "index", "=", "(", "int", ")", "Math", ".", "floor", "(", "score", "/", "interval", ")", "-", "1", ";", "index", "=", "Math", ".", "max", "(", "index", ",", "0", ")", ";", "index", "=", "Math", ".", "min", "(", "index", ",", "helperTexts", ".", "size", "(", ")", "-", "1", ")", ";", "return", "helperTexts", ".", "get", "(", "index", ")", ";", "}", "return", "null", ";", "}" ]
Returns the helper text, which corresponds to a specific password strength. @param score The password strength as a {@link Float} value between 0.0 and 1.0, which represents the fraction of constraints, which are satisfied @return The helper text as an instance of the type {@link CharSequence} or null, if no helper text for the given password strength is available
[ "Returns", "the", "helper", "text", "which", "corresponds", "to", "a", "specific", "password", "strength", "." ]
ac8693baeac7abddf2e38a47da4c1849d4661a8b
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/PasswordEditText.java#L241-L251
7,896
michael-rapp/AndroidMaterialValidation
library/src/main/java/de/mrapp/android/validation/PasswordEditText.java
PasswordEditText.getHelperTextColor
private int getHelperTextColor(final float score) { if (!helperTextColors.isEmpty()) { float interval = 1.0f / helperTextColors.size(); int index = (int) Math.floor(score / interval) - 1; index = Math.max(index, 0); index = Math.min(index, helperTextColors.size() - 1); return helperTextColors.get(index); } return regularHelperTextColor; }
java
private int getHelperTextColor(final float score) { if (!helperTextColors.isEmpty()) { float interval = 1.0f / helperTextColors.size(); int index = (int) Math.floor(score / interval) - 1; index = Math.max(index, 0); index = Math.min(index, helperTextColors.size() - 1); return helperTextColors.get(index); } return regularHelperTextColor; }
[ "private", "int", "getHelperTextColor", "(", "final", "float", "score", ")", "{", "if", "(", "!", "helperTextColors", ".", "isEmpty", "(", ")", ")", "{", "float", "interval", "=", "1.0f", "/", "helperTextColors", ".", "size", "(", ")", ";", "int", "index", "=", "(", "int", ")", "Math", ".", "floor", "(", "score", "/", "interval", ")", "-", "1", ";", "index", "=", "Math", ".", "max", "(", "index", ",", "0", ")", ";", "index", "=", "Math", ".", "min", "(", "index", ",", "helperTextColors", ".", "size", "(", ")", "-", "1", ")", ";", "return", "helperTextColors", ".", "get", "(", "index", ")", ";", "}", "return", "regularHelperTextColor", ";", "}" ]
Returns the color of the helper text, which corresponds to a specific password strength. @param score The password strength as a {@link Float} value between 0.0 and 1.0, which represents the fraction of constraints, which are satisfied @return The color of the helper text as an {@link Integer} value
[ "Returns", "the", "color", "of", "the", "helper", "text", "which", "corresponds", "to", "a", "specific", "password", "strength", "." ]
ac8693baeac7abddf2e38a47da4c1849d4661a8b
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/PasswordEditText.java#L261-L271
7,897
michael-rapp/AndroidMaterialValidation
library/src/main/java/de/mrapp/android/validation/PasswordEditText.java
PasswordEditText.addConstraint
public final void addConstraint(@NonNull final Constraint<CharSequence> constraint) { Condition.INSTANCE.ensureNotNull(constraint, "The constraint may not be null"); if (!constraints.contains(constraint)) { constraints.add(constraint); verifyPasswordStrength(); } }
java
public final void addConstraint(@NonNull final Constraint<CharSequence> constraint) { Condition.INSTANCE.ensureNotNull(constraint, "The constraint may not be null"); if (!constraints.contains(constraint)) { constraints.add(constraint); verifyPasswordStrength(); } }
[ "public", "final", "void", "addConstraint", "(", "@", "NonNull", "final", "Constraint", "<", "CharSequence", ">", "constraint", ")", "{", "Condition", ".", "INSTANCE", ".", "ensureNotNull", "(", "constraint", ",", "\"The constraint may not be null\"", ")", ";", "if", "(", "!", "constraints", ".", "contains", "(", "constraint", ")", ")", "{", "constraints", ".", "add", "(", "constraint", ")", ";", "verifyPasswordStrength", "(", ")", ";", "}", "}" ]
Adds a new constraint, which should be used to verify the password strength. @param constraint The constraint, which should be added, as an instance of the type {@link Constraint}. The constraint may not be null
[ "Adds", "a", "new", "constraint", "which", "should", "be", "used", "to", "verify", "the", "password", "strength", "." ]
ac8693baeac7abddf2e38a47da4c1849d4661a8b
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/PasswordEditText.java#L367-L374
7,898
michael-rapp/AndroidMaterialValidation
library/src/main/java/de/mrapp/android/validation/PasswordEditText.java
PasswordEditText.addAllConstraints
public final void addAllConstraints( @NonNull final Collection<Constraint<CharSequence>> constraints) { Condition.INSTANCE.ensureNotNull(constraints, "The collection may not be null"); for (Constraint<CharSequence> constraint : constraints) { addConstraint(constraint); } }
java
public final void addAllConstraints( @NonNull final Collection<Constraint<CharSequence>> constraints) { Condition.INSTANCE.ensureNotNull(constraints, "The collection may not be null"); for (Constraint<CharSequence> constraint : constraints) { addConstraint(constraint); } }
[ "public", "final", "void", "addAllConstraints", "(", "@", "NonNull", "final", "Collection", "<", "Constraint", "<", "CharSequence", ">", ">", "constraints", ")", "{", "Condition", ".", "INSTANCE", ".", "ensureNotNull", "(", "constraints", ",", "\"The collection may not be null\"", ")", ";", "for", "(", "Constraint", "<", "CharSequence", ">", "constraint", ":", "constraints", ")", "{", "addConstraint", "(", "constraint", ")", ";", "}", "}" ]
Adds all constraints, which are contained by a specific collection. @param constraints A collection, which contains the constraints, which should be added, as an instance of the type {@link Collection} or an empty collection, if no constraints should be added
[ "Adds", "all", "constraints", "which", "are", "contained", "by", "a", "specific", "collection", "." ]
ac8693baeac7abddf2e38a47da4c1849d4661a8b
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/PasswordEditText.java#L384-L391
7,899
michael-rapp/AndroidMaterialValidation
library/src/main/java/de/mrapp/android/validation/PasswordEditText.java
PasswordEditText.removeConstraint
public final void removeConstraint(@NonNull final Constraint<CharSequence> constraint) { Condition.INSTANCE.ensureNotNull(constraint, "The constraint may not be null"); constraints.remove(constraint); verifyPasswordStrength(); }
java
public final void removeConstraint(@NonNull final Constraint<CharSequence> constraint) { Condition.INSTANCE.ensureNotNull(constraint, "The constraint may not be null"); constraints.remove(constraint); verifyPasswordStrength(); }
[ "public", "final", "void", "removeConstraint", "(", "@", "NonNull", "final", "Constraint", "<", "CharSequence", ">", "constraint", ")", "{", "Condition", ".", "INSTANCE", ".", "ensureNotNull", "(", "constraint", ",", "\"The constraint may not be null\"", ")", ";", "constraints", ".", "remove", "(", "constraint", ")", ";", "verifyPasswordStrength", "(", ")", ";", "}" ]
Removes a specific constraint, which should not be used to verify the password strength, anymore. @param constraint The constraint, which should be removed, as an instance of the type {@link Constraint}. The constraint may not be null
[ "Removes", "a", "specific", "constraint", "which", "should", "not", "be", "used", "to", "verify", "the", "password", "strength", "anymore", "." ]
ac8693baeac7abddf2e38a47da4c1849d4661a8b
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/PasswordEditText.java#L414-L418