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
8,000
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java
GenericEncodingStrategy.getLobFromLocator
private void getLobFromLocator(CodeAssembler a, StorablePropertyInfo info) { if (!info.isLob()) { throw new IllegalArgumentException(); } TypeDesc type = info.getStorageType(); String name; if (Blob.class.isAssignableFrom(type.toClass())) { name = "getBlob"; } else if (Clob.class.isAssignableFrom(type.toClass())) { name = "getClob"; } else { throw new IllegalArgumentException(); } a.invokeInterface(TypeDesc.forClass(RawSupport.class), name, type, new TypeDesc[] {TypeDesc.forClass(Storable.class), TypeDesc.STRING, TypeDesc.LONG}); }
java
private void getLobFromLocator(CodeAssembler a, StorablePropertyInfo info) { if (!info.isLob()) { throw new IllegalArgumentException(); } TypeDesc type = info.getStorageType(); String name; if (Blob.class.isAssignableFrom(type.toClass())) { name = "getBlob"; } else if (Clob.class.isAssignableFrom(type.toClass())) { name = "getClob"; } else { throw new IllegalArgumentException(); } a.invokeInterface(TypeDesc.forClass(RawSupport.class), name, type, new TypeDesc[] {TypeDesc.forClass(Storable.class), TypeDesc.STRING, TypeDesc.LONG}); }
[ "private", "void", "getLobFromLocator", "(", "CodeAssembler", "a", ",", "StorablePropertyInfo", "info", ")", "{", "if", "(", "!", "info", ".", "isLob", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", ")", ";", "}", "TypeDesc", "type", "=", "info", ".", "getStorageType", "(", ")", ";", "String", "name", ";", "if", "(", "Blob", ".", "class", ".", "isAssignableFrom", "(", "type", ".", "toClass", "(", ")", ")", ")", "{", "name", "=", "\"getBlob\"", ";", "}", "else", "if", "(", "Clob", ".", "class", ".", "isAssignableFrom", "(", "type", ".", "toClass", "(", ")", ")", ")", "{", "name", "=", "\"getClob\"", ";", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", ")", ";", "}", "a", ".", "invokeInterface", "(", "TypeDesc", ".", "forClass", "(", "RawSupport", ".", "class", ")", ",", "name", ",", "type", ",", "new", "TypeDesc", "[", "]", "{", "TypeDesc", ".", "forClass", "(", "Storable", ".", "class", ")", ",", "TypeDesc", ".", "STRING", ",", "TypeDesc", ".", "LONG", "}", ")", ";", "}" ]
Generates code to get a Lob from a locator from RawSupport. RawSupport instance, Storable instance, property name and long locator must be on the stack. Result is a Lob on the stack, which may be null.
[ "Generates", "code", "to", "get", "a", "Lob", "from", "a", "locator", "from", "RawSupport", ".", "RawSupport", "instance", "Storable", "instance", "property", "name", "and", "long", "locator", "must", "be", "on", "the", "stack", ".", "Result", "is", "a", "Lob", "on", "the", "stack", "which", "may", "be", "null", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java#L1808-L1826
8,001
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java
GenericEncodingStrategy.pushDecodingInstanceVar
protected void pushDecodingInstanceVar(CodeAssembler a, int ordinal, LocalVariable instanceVar) { if (instanceVar == null) { // Push this to stack in preparation for storing a property. a.loadThis(); } else if (instanceVar.getType() != TypeDesc.forClass(Object[].class)) { // Push reference to stack in preparation for storing a property. a.loadLocal(instanceVar); } else { // Push array and index to stack in preparation for storing a property. a.loadLocal(instanceVar); a.loadConstant(ordinal); } }
java
protected void pushDecodingInstanceVar(CodeAssembler a, int ordinal, LocalVariable instanceVar) { if (instanceVar == null) { // Push this to stack in preparation for storing a property. a.loadThis(); } else if (instanceVar.getType() != TypeDesc.forClass(Object[].class)) { // Push reference to stack in preparation for storing a property. a.loadLocal(instanceVar); } else { // Push array and index to stack in preparation for storing a property. a.loadLocal(instanceVar); a.loadConstant(ordinal); } }
[ "protected", "void", "pushDecodingInstanceVar", "(", "CodeAssembler", "a", ",", "int", "ordinal", ",", "LocalVariable", "instanceVar", ")", "{", "if", "(", "instanceVar", "==", "null", ")", "{", "// Push this to stack in preparation for storing a property.\r", "a", ".", "loadThis", "(", ")", ";", "}", "else", "if", "(", "instanceVar", ".", "getType", "(", ")", "!=", "TypeDesc", ".", "forClass", "(", "Object", "[", "]", ".", "class", ")", ")", "{", "// Push reference to stack in preparation for storing a property.\r", "a", ".", "loadLocal", "(", "instanceVar", ")", ";", "}", "else", "{", "// Push array and index to stack in preparation for storing a property.\r", "a", ".", "loadLocal", "(", "instanceVar", ")", ";", "a", ".", "loadConstant", "(", "ordinal", ")", ";", "}", "}" ]
Push decoding instanceVar to stack in preparation to calling storePropertyValue. @param ordinal zero-based property ordinal, used only if instanceVar refers to an object array. @param instanceVar local variable referencing Storable instance, defaults to "this" if null. If variable type is an Object array, then property values are written to the runtime value of this array instead of a Storable instance. @see #storePropertyValue storePropertyValue
[ "Push", "decoding", "instanceVar", "to", "stack", "in", "preparation", "to", "calling", "storePropertyValue", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java#L2356-L2369
8,002
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java
GenericEncodingStrategy.decodeGeneration
private void decodeGeneration(CodeAssembler a, LocalVariable encodedVar, int offset, int generation, Label altGenerationHandler) { if (offset < 0) { throw new IllegalArgumentException(); } if (generation < 0) { return; } LocalVariable actualGeneration = a.createLocalVariable(null, TypeDesc.INT); a.loadLocal(encodedVar); a.loadConstant(offset); a.loadFromArray(TypeDesc.BYTE); a.storeLocal(actualGeneration); a.loadLocal(actualGeneration); Label compareGeneration = a.createLabel(); a.ifZeroComparisonBranch(compareGeneration, ">="); // Decode four byte generation format. a.loadLocal(actualGeneration); a.loadConstant(24); a.math(Opcode.ISHL); a.loadConstant(0x7fffffff); a.math(Opcode.IAND); for (int i=1; i<4; i++) { a.loadLocal(encodedVar); a.loadConstant(offset + i); a.loadFromArray(TypeDesc.BYTE); a.loadConstant(0xff); a.math(Opcode.IAND); int shift = 8 * (3 - i); if (shift > 0) { a.loadConstant(shift); a.math(Opcode.ISHL); } a.math(Opcode.IOR); } a.storeLocal(actualGeneration); compareGeneration.setLocation(); a.loadConstant(generation); a.loadLocal(actualGeneration); Label generationMatches = a.createLabel(); a.ifComparisonBranch(generationMatches, "=="); if (altGenerationHandler != null) { a.loadLocal(actualGeneration); a.branch(altGenerationHandler); } else { // Throw CorruptEncodingException. TypeDesc corruptEncodingEx = TypeDesc.forClass(CorruptEncodingException.class); a.newObject(corruptEncodingEx); a.dup(); a.loadConstant(generation); // expected generation a.loadLocal(actualGeneration); // actual generation a.invokeConstructor(corruptEncodingEx, new TypeDesc[] {TypeDesc.INT, TypeDesc.INT}); a.throwObject(); } generationMatches.setLocation(); }
java
private void decodeGeneration(CodeAssembler a, LocalVariable encodedVar, int offset, int generation, Label altGenerationHandler) { if (offset < 0) { throw new IllegalArgumentException(); } if (generation < 0) { return; } LocalVariable actualGeneration = a.createLocalVariable(null, TypeDesc.INT); a.loadLocal(encodedVar); a.loadConstant(offset); a.loadFromArray(TypeDesc.BYTE); a.storeLocal(actualGeneration); a.loadLocal(actualGeneration); Label compareGeneration = a.createLabel(); a.ifZeroComparisonBranch(compareGeneration, ">="); // Decode four byte generation format. a.loadLocal(actualGeneration); a.loadConstant(24); a.math(Opcode.ISHL); a.loadConstant(0x7fffffff); a.math(Opcode.IAND); for (int i=1; i<4; i++) { a.loadLocal(encodedVar); a.loadConstant(offset + i); a.loadFromArray(TypeDesc.BYTE); a.loadConstant(0xff); a.math(Opcode.IAND); int shift = 8 * (3 - i); if (shift > 0) { a.loadConstant(shift); a.math(Opcode.ISHL); } a.math(Opcode.IOR); } a.storeLocal(actualGeneration); compareGeneration.setLocation(); a.loadConstant(generation); a.loadLocal(actualGeneration); Label generationMatches = a.createLabel(); a.ifComparisonBranch(generationMatches, "=="); if (altGenerationHandler != null) { a.loadLocal(actualGeneration); a.branch(altGenerationHandler); } else { // Throw CorruptEncodingException. TypeDesc corruptEncodingEx = TypeDesc.forClass(CorruptEncodingException.class); a.newObject(corruptEncodingEx); a.dup(); a.loadConstant(generation); // expected generation a.loadLocal(actualGeneration); // actual generation a.invokeConstructor(corruptEncodingEx, new TypeDesc[] {TypeDesc.INT, TypeDesc.INT}); a.throwObject(); } generationMatches.setLocation(); }
[ "private", "void", "decodeGeneration", "(", "CodeAssembler", "a", ",", "LocalVariable", "encodedVar", ",", "int", "offset", ",", "int", "generation", ",", "Label", "altGenerationHandler", ")", "{", "if", "(", "offset", "<", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", ")", ";", "}", "if", "(", "generation", "<", "0", ")", "{", "return", ";", "}", "LocalVariable", "actualGeneration", "=", "a", ".", "createLocalVariable", "(", "null", ",", "TypeDesc", ".", "INT", ")", ";", "a", ".", "loadLocal", "(", "encodedVar", ")", ";", "a", ".", "loadConstant", "(", "offset", ")", ";", "a", ".", "loadFromArray", "(", "TypeDesc", ".", "BYTE", ")", ";", "a", ".", "storeLocal", "(", "actualGeneration", ")", ";", "a", ".", "loadLocal", "(", "actualGeneration", ")", ";", "Label", "compareGeneration", "=", "a", ".", "createLabel", "(", ")", ";", "a", ".", "ifZeroComparisonBranch", "(", "compareGeneration", ",", "\">=\"", ")", ";", "// Decode four byte generation format.\r", "a", ".", "loadLocal", "(", "actualGeneration", ")", ";", "a", ".", "loadConstant", "(", "24", ")", ";", "a", ".", "math", "(", "Opcode", ".", "ISHL", ")", ";", "a", ".", "loadConstant", "(", "0x7fffffff", ")", ";", "a", ".", "math", "(", "Opcode", ".", "IAND", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "4", ";", "i", "++", ")", "{", "a", ".", "loadLocal", "(", "encodedVar", ")", ";", "a", ".", "loadConstant", "(", "offset", "+", "i", ")", ";", "a", ".", "loadFromArray", "(", "TypeDesc", ".", "BYTE", ")", ";", "a", ".", "loadConstant", "(", "0xff", ")", ";", "a", ".", "math", "(", "Opcode", ".", "IAND", ")", ";", "int", "shift", "=", "8", "*", "(", "3", "-", "i", ")", ";", "if", "(", "shift", ">", "0", ")", "{", "a", ".", "loadConstant", "(", "shift", ")", ";", "a", ".", "math", "(", "Opcode", ".", "ISHL", ")", ";", "}", "a", ".", "math", "(", "Opcode", ".", "IOR", ")", ";", "}", "a", ".", "storeLocal", "(", "actualGeneration", ")", ";", "compareGeneration", ".", "setLocation", "(", ")", ";", "a", ".", "loadConstant", "(", "generation", ")", ";", "a", ".", "loadLocal", "(", "actualGeneration", ")", ";", "Label", "generationMatches", "=", "a", ".", "createLabel", "(", ")", ";", "a", ".", "ifComparisonBranch", "(", "generationMatches", ",", "\"==\"", ")", ";", "if", "(", "altGenerationHandler", "!=", "null", ")", "{", "a", ".", "loadLocal", "(", "actualGeneration", ")", ";", "a", ".", "branch", "(", "altGenerationHandler", ")", ";", "}", "else", "{", "// Throw CorruptEncodingException.\r", "TypeDesc", "corruptEncodingEx", "=", "TypeDesc", ".", "forClass", "(", "CorruptEncodingException", ".", "class", ")", ";", "a", ".", "newObject", "(", "corruptEncodingEx", ")", ";", "a", ".", "dup", "(", ")", ";", "a", ".", "loadConstant", "(", "generation", ")", ";", "// expected generation\r", "a", ".", "loadLocal", "(", "actualGeneration", ")", ";", "// actual generation\r", "a", ".", "invokeConstructor", "(", "corruptEncodingEx", ",", "new", "TypeDesc", "[", "]", "{", "TypeDesc", ".", "INT", ",", "TypeDesc", ".", "INT", "}", ")", ";", "a", ".", "throwObject", "(", ")", ";", "}", "generationMatches", ".", "setLocation", "(", ")", ";", "}" ]
Generates code that ensures a matching generation value exists in the byte array referenced by the local variable, throwing a CorruptEncodingException otherwise. @param generation if less than zero, no code is generated
[ "Generates", "code", "that", "ensures", "a", "matching", "generation", "value", "exists", "in", "the", "byte", "array", "referenced", "by", "the", "local", "variable", "throwing", "a", "CorruptEncodingException", "otherwise", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java#L2541-L2604
8,003
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/qe/AbstractQuery.java
AbstractQuery.checkSliceArguments
protected boolean checkSliceArguments(long from, Long to) { if (from < 0) { throw new IllegalArgumentException("Slice from is negative: " + from); } if (to == null) { if (from == 0) { return false; } } else if (from > to) { throw new IllegalArgumentException ("Slice from is more than to: " + from + " > " + to); } return true; }
java
protected boolean checkSliceArguments(long from, Long to) { if (from < 0) { throw new IllegalArgumentException("Slice from is negative: " + from); } if (to == null) { if (from == 0) { return false; } } else if (from > to) { throw new IllegalArgumentException ("Slice from is more than to: " + from + " > " + to); } return true; }
[ "protected", "boolean", "checkSliceArguments", "(", "long", "from", ",", "Long", "to", ")", "{", "if", "(", "from", "<", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Slice from is negative: \"", "+", "from", ")", ";", "}", "if", "(", "to", "==", "null", ")", "{", "if", "(", "from", "==", "0", ")", "{", "return", "false", ";", "}", "}", "else", "if", "(", "from", ">", "to", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Slice from is more than to: \"", "+", "from", "+", "\" > \"", "+", "to", ")", ";", "}", "return", "true", ";", "}" ]
Called by sliced fetch to ensure that arguments are valid. @return false if from is 0 and to is null @throws IllegalArgumentException if arguments are invalid @since 1.2
[ "Called", "by", "sliced", "fetch", "to", "ensure", "that", "arguments", "are", "valid", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/AbstractQuery.java#L195-L208
8,004
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/util/TaskQueueThread.java
TaskQueueThread.execute
public void execute(Runnable task, long timeoutMillis) throws RejectedExecutionException { if (task == null) { throw new NullPointerException("Cannot accept null task"); } synchronized (this) { if (mState != STATE_RUNNING && mState != STATE_NOT_STARTED) { throw new RejectedExecutionException("Task queue is shutdown"); } } try { if (!mQueue.offer(task, timeoutMillis, TimeUnit.MILLISECONDS)) { throw new RejectedExecutionException("Unable to enqueue task after waiting " + timeoutMillis + " milliseconds"); } } catch (InterruptedException e) { throw new RejectedExecutionException(e); } }
java
public void execute(Runnable task, long timeoutMillis) throws RejectedExecutionException { if (task == null) { throw new NullPointerException("Cannot accept null task"); } synchronized (this) { if (mState != STATE_RUNNING && mState != STATE_NOT_STARTED) { throw new RejectedExecutionException("Task queue is shutdown"); } } try { if (!mQueue.offer(task, timeoutMillis, TimeUnit.MILLISECONDS)) { throw new RejectedExecutionException("Unable to enqueue task after waiting " + timeoutMillis + " milliseconds"); } } catch (InterruptedException e) { throw new RejectedExecutionException(e); } }
[ "public", "void", "execute", "(", "Runnable", "task", ",", "long", "timeoutMillis", ")", "throws", "RejectedExecutionException", "{", "if", "(", "task", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"Cannot accept null task\"", ")", ";", "}", "synchronized", "(", "this", ")", "{", "if", "(", "mState", "!=", "STATE_RUNNING", "&&", "mState", "!=", "STATE_NOT_STARTED", ")", "{", "throw", "new", "RejectedExecutionException", "(", "\"Task queue is shutdown\"", ")", ";", "}", "}", "try", "{", "if", "(", "!", "mQueue", ".", "offer", "(", "task", ",", "timeoutMillis", ",", "TimeUnit", ".", "MILLISECONDS", ")", ")", "{", "throw", "new", "RejectedExecutionException", "(", "\"Unable to enqueue task after waiting \"", "+", "timeoutMillis", "+", "\" milliseconds\"", ")", ";", "}", "}", "catch", "(", "InterruptedException", "e", ")", "{", "throw", "new", "RejectedExecutionException", "(", "e", ")", ";", "}", "}" ]
Enqueue a task to run. @param task task to enqueue @param timeoutMillis maximum time to wait for queue to have an available slot @throws RejectedExecutionException if wait interrupted, timeout expires, or shutdown has been called
[ "Enqueue", "a", "task", "to", "run", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/util/TaskQueueThread.java#L85-L102
8,005
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/util/TaskQueueThread.java
TaskQueueThread.shutdown
public synchronized void shutdown() { if (mState == STATE_STOPPED) { return; } if (mState == STATE_NOT_STARTED) { mState = STATE_STOPPED; return; } mState = STATE_SHOULD_STOP; // Inject stop task into the queue so it knows to stop, in case we're blocked. mQueue.offer(STOP_TASK); }
java
public synchronized void shutdown() { if (mState == STATE_STOPPED) { return; } if (mState == STATE_NOT_STARTED) { mState = STATE_STOPPED; return; } mState = STATE_SHOULD_STOP; // Inject stop task into the queue so it knows to stop, in case we're blocked. mQueue.offer(STOP_TASK); }
[ "public", "synchronized", "void", "shutdown", "(", ")", "{", "if", "(", "mState", "==", "STATE_STOPPED", ")", "{", "return", ";", "}", "if", "(", "mState", "==", "STATE_NOT_STARTED", ")", "{", "mState", "=", "STATE_STOPPED", ";", "return", ";", "}", "mState", "=", "STATE_SHOULD_STOP", ";", "// Inject stop task into the queue so it knows to stop, in case we're blocked.\r", "mQueue", ".", "offer", "(", "STOP_TASK", ")", ";", "}" ]
Indicate that this task queue thread should finish running its enqueued tasks and then exit. Enqueueing new tasks will result in a RejectedExecutionException being thrown. Join on this thread to wait for it to exit.
[ "Indicate", "that", "this", "task", "queue", "thread", "should", "finish", "running", "its", "enqueued", "tasks", "and", "then", "exit", ".", "Enqueueing", "new", "tasks", "will", "result", "in", "a", "RejectedExecutionException", "being", "thrown", ".", "Join", "on", "this", "thread", "to", "wait", "for", "it", "to", "exit", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/util/TaskQueueThread.java#L110-L121
8,006
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/sequence/SequenceValueGenerator.java
SequenceValueGenerator.reset
public void reset(int initialValue) throws FetchException, PersistException { synchronized (mStoredSequence) { Transaction txn = mRepository.enterTopTransaction(null); txn.setForUpdate(true); try { boolean doUpdate = mStoredSequence.tryLoad(); mStoredSequence.setInitialValue(initialValue); // Start as small as possible to allow signed long comparisons to work. mStoredSequence.setNextValue(Long.MIN_VALUE); if (doUpdate) { mStoredSequence.update(); } else { mStoredSequence.insert(); } txn.commit(); mHasReservedValues = false; } finally { txn.exit(); } } }
java
public void reset(int initialValue) throws FetchException, PersistException { synchronized (mStoredSequence) { Transaction txn = mRepository.enterTopTransaction(null); txn.setForUpdate(true); try { boolean doUpdate = mStoredSequence.tryLoad(); mStoredSequence.setInitialValue(initialValue); // Start as small as possible to allow signed long comparisons to work. mStoredSequence.setNextValue(Long.MIN_VALUE); if (doUpdate) { mStoredSequence.update(); } else { mStoredSequence.insert(); } txn.commit(); mHasReservedValues = false; } finally { txn.exit(); } } }
[ "public", "void", "reset", "(", "int", "initialValue", ")", "throws", "FetchException", ",", "PersistException", "{", "synchronized", "(", "mStoredSequence", ")", "{", "Transaction", "txn", "=", "mRepository", ".", "enterTopTransaction", "(", "null", ")", ";", "txn", ".", "setForUpdate", "(", "true", ")", ";", "try", "{", "boolean", "doUpdate", "=", "mStoredSequence", ".", "tryLoad", "(", ")", ";", "mStoredSequence", ".", "setInitialValue", "(", "initialValue", ")", ";", "// Start as small as possible to allow signed long comparisons to work.\r", "mStoredSequence", ".", "setNextValue", "(", "Long", ".", "MIN_VALUE", ")", ";", "if", "(", "doUpdate", ")", "{", "mStoredSequence", ".", "update", "(", ")", ";", "}", "else", "{", "mStoredSequence", ".", "insert", "(", ")", ";", "}", "txn", ".", "commit", "(", ")", ";", "mHasReservedValues", "=", "false", ";", "}", "finally", "{", "txn", ".", "exit", "(", ")", ";", "}", "}", "}" ]
Reset the sequence. @param initialValue first value produced by sequence
[ "Reset", "the", "sequence", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/sequence/SequenceValueGenerator.java#L160-L180
8,007
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/sequence/SequenceValueGenerator.java
SequenceValueGenerator.returnReservedValues
public boolean returnReservedValues() throws FetchException, PersistException { synchronized (mStoredSequence) { if (mHasReservedValues) { Transaction txn = mRepository.enterTopTransaction(null); txn.setForUpdate(true); try { // Compare known StoredSequence with current persistent // one. If same, then reserved values can be returned. StoredSequence current = mStorage.prepare(); current.setName(mStoredSequence.getName()); if (current.tryLoad() && current.equals(mStoredSequence)) { mStoredSequence.setNextValue(mNextValue + mIncrement); mStoredSequence.update(); txn.commit(); mHasReservedValues = false; return true; } } finally { txn.exit(); } } } return false; }
java
public boolean returnReservedValues() throws FetchException, PersistException { synchronized (mStoredSequence) { if (mHasReservedValues) { Transaction txn = mRepository.enterTopTransaction(null); txn.setForUpdate(true); try { // Compare known StoredSequence with current persistent // one. If same, then reserved values can be returned. StoredSequence current = mStorage.prepare(); current.setName(mStoredSequence.getName()); if (current.tryLoad() && current.equals(mStoredSequence)) { mStoredSequence.setNextValue(mNextValue + mIncrement); mStoredSequence.update(); txn.commit(); mHasReservedValues = false; return true; } } finally { txn.exit(); } } } return false; }
[ "public", "boolean", "returnReservedValues", "(", ")", "throws", "FetchException", ",", "PersistException", "{", "synchronized", "(", "mStoredSequence", ")", "{", "if", "(", "mHasReservedValues", ")", "{", "Transaction", "txn", "=", "mRepository", ".", "enterTopTransaction", "(", "null", ")", ";", "txn", ".", "setForUpdate", "(", "true", ")", ";", "try", "{", "// Compare known StoredSequence with current persistent\r", "// one. If same, then reserved values can be returned.\r", "StoredSequence", "current", "=", "mStorage", ".", "prepare", "(", ")", ";", "current", ".", "setName", "(", "mStoredSequence", ".", "getName", "(", ")", ")", ";", "if", "(", "current", ".", "tryLoad", "(", ")", "&&", "current", ".", "equals", "(", "mStoredSequence", ")", ")", "{", "mStoredSequence", ".", "setNextValue", "(", "mNextValue", "+", "mIncrement", ")", ";", "mStoredSequence", ".", "update", "(", ")", ";", "txn", ".", "commit", "(", ")", ";", "mHasReservedValues", "=", "false", ";", "return", "true", ";", "}", "}", "finally", "{", "txn", ".", "exit", "(", ")", ";", "}", "}", "}", "return", "false", ";", "}" ]
Allow any unused reserved values to be returned for re-use. If the repository is shared by other processes, then reserved values might not be returnable. <p>This method should be called during the shutdown process of a repository, although calling it does not invalidate this SequenceValueGenerator. If getNextValue is called again, it will reserve values again. @return true if reserved values were returned
[ "Allow", "any", "unused", "reserved", "values", "to", "be", "returned", "for", "re", "-", "use", ".", "If", "the", "repository", "is", "shared", "by", "other", "processes", "then", "reserved", "values", "might", "not", "be", "returnable", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/sequence/SequenceValueGenerator.java#L254-L277
8,008
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/sequence/SequenceValueGenerator.java
SequenceValueGenerator.nextUnadjustedValue
private long nextUnadjustedValue() throws FetchException, PersistException { if (mHasReservedValues) { long next = mNextValue + mIncrement; mNextValue = next; if (next < mStoredSequence.getNextValue()) { return next; } mHasReservedValues = false; } Transaction txn = mRepository.enterTopTransaction(null); txn.setForUpdate(true); try { // Assume that StoredSequence is stale, so reload. mStoredSequence.load(); long next = mStoredSequence.getNextValue(); long nextStored = next + mReserveAmount * mIncrement; if (next >= 0 && nextStored < 0) { // Wrapped around. There might be just a few values left. long avail = (Long.MAX_VALUE - next) / mIncrement; if (avail > 0) { nextStored = next + avail * mIncrement; } else { // Throw a PersistException since sequences are applied during // insert operations, and inserts can only throw PersistExceptions. throw new PersistException ("Sequence exhausted: " + mStoredSequence.getName()); } } mStoredSequence.setNextValue(nextStored); mStoredSequence.update(); txn.commit(); mNextValue = next; mHasReservedValues = true; return next; } finally { txn.exit(); } }
java
private long nextUnadjustedValue() throws FetchException, PersistException { if (mHasReservedValues) { long next = mNextValue + mIncrement; mNextValue = next; if (next < mStoredSequence.getNextValue()) { return next; } mHasReservedValues = false; } Transaction txn = mRepository.enterTopTransaction(null); txn.setForUpdate(true); try { // Assume that StoredSequence is stale, so reload. mStoredSequence.load(); long next = mStoredSequence.getNextValue(); long nextStored = next + mReserveAmount * mIncrement; if (next >= 0 && nextStored < 0) { // Wrapped around. There might be just a few values left. long avail = (Long.MAX_VALUE - next) / mIncrement; if (avail > 0) { nextStored = next + avail * mIncrement; } else { // Throw a PersistException since sequences are applied during // insert operations, and inserts can only throw PersistExceptions. throw new PersistException ("Sequence exhausted: " + mStoredSequence.getName()); } } mStoredSequence.setNextValue(nextStored); mStoredSequence.update(); txn.commit(); mNextValue = next; mHasReservedValues = true; return next; } finally { txn.exit(); } }
[ "private", "long", "nextUnadjustedValue", "(", ")", "throws", "FetchException", ",", "PersistException", "{", "if", "(", "mHasReservedValues", ")", "{", "long", "next", "=", "mNextValue", "+", "mIncrement", ";", "mNextValue", "=", "next", ";", "if", "(", "next", "<", "mStoredSequence", ".", "getNextValue", "(", ")", ")", "{", "return", "next", ";", "}", "mHasReservedValues", "=", "false", ";", "}", "Transaction", "txn", "=", "mRepository", ".", "enterTopTransaction", "(", "null", ")", ";", "txn", ".", "setForUpdate", "(", "true", ")", ";", "try", "{", "// Assume that StoredSequence is stale, so reload.\r", "mStoredSequence", ".", "load", "(", ")", ";", "long", "next", "=", "mStoredSequence", ".", "getNextValue", "(", ")", ";", "long", "nextStored", "=", "next", "+", "mReserveAmount", "*", "mIncrement", ";", "if", "(", "next", ">=", "0", "&&", "nextStored", "<", "0", ")", "{", "// Wrapped around. There might be just a few values left.\r", "long", "avail", "=", "(", "Long", ".", "MAX_VALUE", "-", "next", ")", "/", "mIncrement", ";", "if", "(", "avail", ">", "0", ")", "{", "nextStored", "=", "next", "+", "avail", "*", "mIncrement", ";", "}", "else", "{", "// Throw a PersistException since sequences are applied during\r", "// insert operations, and inserts can only throw PersistExceptions.\r", "throw", "new", "PersistException", "(", "\"Sequence exhausted: \"", "+", "mStoredSequence", ".", "getName", "(", ")", ")", ";", "}", "}", "mStoredSequence", ".", "setNextValue", "(", "nextStored", ")", ";", "mStoredSequence", ".", "update", "(", ")", ";", "txn", ".", "commit", "(", ")", ";", "mNextValue", "=", "next", ";", "mHasReservedValues", "=", "true", ";", "return", "next", ";", "}", "finally", "{", "txn", ".", "exit", "(", ")", ";", "}", "}" ]
Assumes caller has synchronized on mStoredSequence
[ "Assumes", "caller", "has", "synchronized", "on", "mStoredSequence" ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/sequence/SequenceValueGenerator.java#L280-L322
8,009
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/util/AnnotationDescParser.java
AnnotationDescParser.parse
public Annotation parse(Annotation rootAnnotation) { mPos = 0; if (parseTag() != TAG_ANNOTATION) { throw error("Malformed"); } TypeDesc rootAnnotationType = parseTypeDesc(); if (rootAnnotation == null) { rootAnnotation = buildRootAnnotation(rootAnnotationType); } else if (!rootAnnotationType.equals(rootAnnotation.getType())) { throw new IllegalArgumentException ("Annotation type of \"" + rootAnnotationType + "\" does not match expected type of \"" + rootAnnotation.getType()); } parseAnnotation(rootAnnotation, rootAnnotationType); return rootAnnotation; }
java
public Annotation parse(Annotation rootAnnotation) { mPos = 0; if (parseTag() != TAG_ANNOTATION) { throw error("Malformed"); } TypeDesc rootAnnotationType = parseTypeDesc(); if (rootAnnotation == null) { rootAnnotation = buildRootAnnotation(rootAnnotationType); } else if (!rootAnnotationType.equals(rootAnnotation.getType())) { throw new IllegalArgumentException ("Annotation type of \"" + rootAnnotationType + "\" does not match expected type of \"" + rootAnnotation.getType()); } parseAnnotation(rootAnnotation, rootAnnotationType); return rootAnnotation; }
[ "public", "Annotation", "parse", "(", "Annotation", "rootAnnotation", ")", "{", "mPos", "=", "0", ";", "if", "(", "parseTag", "(", ")", "!=", "TAG_ANNOTATION", ")", "{", "throw", "error", "(", "\"Malformed\"", ")", ";", "}", "TypeDesc", "rootAnnotationType", "=", "parseTypeDesc", "(", ")", ";", "if", "(", "rootAnnotation", "==", "null", ")", "{", "rootAnnotation", "=", "buildRootAnnotation", "(", "rootAnnotationType", ")", ";", "}", "else", "if", "(", "!", "rootAnnotationType", ".", "equals", "(", "rootAnnotation", ".", "getType", "(", ")", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Annotation type of \\\"\"", "+", "rootAnnotationType", "+", "\"\\\" does not match expected type of \\\"\"", "+", "rootAnnotation", ".", "getType", "(", ")", ")", ";", "}", "parseAnnotation", "(", "rootAnnotation", ",", "rootAnnotationType", ")", ";", "return", "rootAnnotation", ";", "}" ]
Parses the given annotation, returning the root annotation that received the results. @param rootAnnotation root annotation @return root annotation @throws IllegalArgumentExcecption if annotation is malformed
[ "Parses", "the", "given", "annotation", "returning", "the", "root", "annotation", "that", "received", "the", "results", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/util/AnnotationDescParser.java#L56-L76
8,010
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/cursor/FilteredCursor.java
FilteredCursor.applyFilter
public static <S extends Storable> Cursor<S> applyFilter(Cursor<S> cursor, Class<S> type, String filter, Object... filterValues) { Filter<S> f = Filter.filterFor(type, filter).bind(); FilterValues<S> fv = f.initialFilterValues().withValues(filterValues); return applyFilter(f, fv, cursor); }
java
public static <S extends Storable> Cursor<S> applyFilter(Cursor<S> cursor, Class<S> type, String filter, Object... filterValues) { Filter<S> f = Filter.filterFor(type, filter).bind(); FilterValues<S> fv = f.initialFilterValues().withValues(filterValues); return applyFilter(f, fv, cursor); }
[ "public", "static", "<", "S", "extends", "Storable", ">", "Cursor", "<", "S", ">", "applyFilter", "(", "Cursor", "<", "S", ">", "cursor", ",", "Class", "<", "S", ">", "type", ",", "String", "filter", ",", "Object", "...", "filterValues", ")", "{", "Filter", "<", "S", ">", "f", "=", "Filter", ".", "filterFor", "(", "type", ",", "filter", ")", ".", "bind", "(", ")", ";", "FilterValues", "<", "S", ">", "fv", "=", "f", ".", "initialFilterValues", "(", ")", ".", "withValues", "(", "filterValues", ")", ";", "return", "applyFilter", "(", "f", ",", "fv", ",", "cursor", ")", ";", "}" ]
Returns a Cursor that is filtered by the given filter expression and values. @param cursor cursor to wrap @param type type of storable @param filter filter to apply @param filterValues values for filter @return wrapped cursor which filters results @throws IllegalStateException if any values are not specified @throws IllegalArgumentException if any argument is null @since 1.2
[ "Returns", "a", "Cursor", "that", "is", "filtered", "by", "the", "given", "filter", "expression", "and", "values", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/cursor/FilteredCursor.java#L49-L57
8,011
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/cursor/FilteredCursor.java
FilteredCursor.applyFilter
public static <S extends Storable> Cursor<S> applyFilter(Filter<S> filter, FilterValues<S> filterValues, Cursor<S> cursor) { if (filter.isOpen()) { return cursor; } if (filter.isClosed()) { throw new IllegalArgumentException(); } // Make sure the filter is the same one that filterValues should be using. filter = filter.bind(); Object[] values = filterValues == null ? null : filterValues.getValuesFor(filter); return FilteredCursorGenerator.getFactory(filter).newFilteredCursor(cursor, values); }
java
public static <S extends Storable> Cursor<S> applyFilter(Filter<S> filter, FilterValues<S> filterValues, Cursor<S> cursor) { if (filter.isOpen()) { return cursor; } if (filter.isClosed()) { throw new IllegalArgumentException(); } // Make sure the filter is the same one that filterValues should be using. filter = filter.bind(); Object[] values = filterValues == null ? null : filterValues.getValuesFor(filter); return FilteredCursorGenerator.getFactory(filter).newFilteredCursor(cursor, values); }
[ "public", "static", "<", "S", "extends", "Storable", ">", "Cursor", "<", "S", ">", "applyFilter", "(", "Filter", "<", "S", ">", "filter", ",", "FilterValues", "<", "S", ">", "filterValues", ",", "Cursor", "<", "S", ">", "cursor", ")", "{", "if", "(", "filter", ".", "isOpen", "(", ")", ")", "{", "return", "cursor", ";", "}", "if", "(", "filter", ".", "isClosed", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", ")", ";", "}", "// Make sure the filter is the same one that filterValues should be using.\r", "filter", "=", "filter", ".", "bind", "(", ")", ";", "Object", "[", "]", "values", "=", "filterValues", "==", "null", "?", "null", ":", "filterValues", ".", "getValuesFor", "(", "filter", ")", ";", "return", "FilteredCursorGenerator", ".", "getFactory", "(", "filter", ")", ".", "newFilteredCursor", "(", "cursor", ",", "values", ")", ";", "}" ]
Returns a Cursor that is filtered by the given Filter and FilterValues. The given Filter must be composed only of the same PropertyFilter instances as used to construct the FilterValues. An IllegalStateException will result otherwise. @param filter filter to apply @param filterValues values for filter, which may be null if filter has no parameters @param cursor cursor to wrap @return wrapped cursor which filters results @throws IllegalStateException if any values are not specified @throws IllegalArgumentException if filter is closed
[ "Returns", "a", "Cursor", "that", "is", "filtered", "by", "the", "given", "Filter", "and", "FilterValues", ".", "The", "given", "Filter", "must", "be", "composed", "only", "of", "the", "same", "PropertyFilter", "instances", "as", "used", "to", "construct", "the", "FilterValues", ".", "An", "IllegalStateException", "will", "result", "otherwise", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/cursor/FilteredCursor.java#L72-L88
8,012
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/spi/ExceptionTransformer.java
ExceptionTransformer.toFetchException
public FetchException toFetchException(Throwable e) { FetchException fe = transformIntoFetchException(e); if (fe != null) { return fe; } Throwable cause = e.getCause(); if (cause != null) { fe = transformIntoFetchException(cause); if (fe != null) { return fe; } } else { cause = e; } return new FetchException(cause); }
java
public FetchException toFetchException(Throwable e) { FetchException fe = transformIntoFetchException(e); if (fe != null) { return fe; } Throwable cause = e.getCause(); if (cause != null) { fe = transformIntoFetchException(cause); if (fe != null) { return fe; } } else { cause = e; } return new FetchException(cause); }
[ "public", "FetchException", "toFetchException", "(", "Throwable", "e", ")", "{", "FetchException", "fe", "=", "transformIntoFetchException", "(", "e", ")", ";", "if", "(", "fe", "!=", "null", ")", "{", "return", "fe", ";", "}", "Throwable", "cause", "=", "e", ".", "getCause", "(", ")", ";", "if", "(", "cause", "!=", "null", ")", "{", "fe", "=", "transformIntoFetchException", "(", "cause", ")", ";", "if", "(", "fe", "!=", "null", ")", "{", "return", "fe", ";", "}", "}", "else", "{", "cause", "=", "e", ";", "}", "return", "new", "FetchException", "(", "cause", ")", ";", "}" ]
Transforms the given throwable into an appropriate fetch exception. If it already is a fetch exception, it is simply casted. @param e required exception to transform @return FetchException, never null
[ "Transforms", "the", "given", "throwable", "into", "an", "appropriate", "fetch", "exception", ".", "If", "it", "already", "is", "a", "fetch", "exception", "it", "is", "simply", "casted", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/spi/ExceptionTransformer.java#L60-L77
8,013
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/spi/ExceptionTransformer.java
ExceptionTransformer.toPersistException
public PersistException toPersistException(Throwable e) { PersistException pe = transformIntoPersistException(e); if (pe != null) { return pe; } Throwable cause = e.getCause(); if (cause != null) { pe = transformIntoPersistException(cause); if (pe != null) { return pe; } } else { cause = e; } return new PersistException(cause); }
java
public PersistException toPersistException(Throwable e) { PersistException pe = transformIntoPersistException(e); if (pe != null) { return pe; } Throwable cause = e.getCause(); if (cause != null) { pe = transformIntoPersistException(cause); if (pe != null) { return pe; } } else { cause = e; } return new PersistException(cause); }
[ "public", "PersistException", "toPersistException", "(", "Throwable", "e", ")", "{", "PersistException", "pe", "=", "transformIntoPersistException", "(", "e", ")", ";", "if", "(", "pe", "!=", "null", ")", "{", "return", "pe", ";", "}", "Throwable", "cause", "=", "e", ".", "getCause", "(", ")", ";", "if", "(", "cause", "!=", "null", ")", "{", "pe", "=", "transformIntoPersistException", "(", "cause", ")", ";", "if", "(", "pe", "!=", "null", ")", "{", "return", "pe", ";", "}", "}", "else", "{", "cause", "=", "e", ";", "}", "return", "new", "PersistException", "(", "cause", ")", ";", "}" ]
Transforms the given throwable into an appropriate persist exception. If it already is a persist exception, it is simply casted. @param e required exception to transform @return PersistException, never null
[ "Transforms", "the", "given", "throwable", "into", "an", "appropriate", "persist", "exception", ".", "If", "it", "already", "is", "a", "persist", "exception", "it", "is", "simply", "casted", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/spi/ExceptionTransformer.java#L86-L103
8,014
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/spi/ExceptionTransformer.java
ExceptionTransformer.toRepositoryException
public RepositoryException toRepositoryException(Throwable e) { RepositoryException re = transformIntoRepositoryException(e); if (re != null) { return re; } Throwable cause = e.getCause(); if (cause != null) { re = transformIntoRepositoryException(cause); if (re != null) { return re; } } else { cause = e; } return new RepositoryException(cause); }
java
public RepositoryException toRepositoryException(Throwable e) { RepositoryException re = transformIntoRepositoryException(e); if (re != null) { return re; } Throwable cause = e.getCause(); if (cause != null) { re = transformIntoRepositoryException(cause); if (re != null) { return re; } } else { cause = e; } return new RepositoryException(cause); }
[ "public", "RepositoryException", "toRepositoryException", "(", "Throwable", "e", ")", "{", "RepositoryException", "re", "=", "transformIntoRepositoryException", "(", "e", ")", ";", "if", "(", "re", "!=", "null", ")", "{", "return", "re", ";", "}", "Throwable", "cause", "=", "e", ".", "getCause", "(", ")", ";", "if", "(", "cause", "!=", "null", ")", "{", "re", "=", "transformIntoRepositoryException", "(", "cause", ")", ";", "if", "(", "re", "!=", "null", ")", "{", "return", "re", ";", "}", "}", "else", "{", "cause", "=", "e", ";", "}", "return", "new", "RepositoryException", "(", "cause", ")", ";", "}" ]
Transforms the given throwable into an appropriate repository exception. If it already is a repository exception, it is simply casted. @param e required exception to transform @return RepositoryException, never null
[ "Transforms", "the", "given", "throwable", "into", "an", "appropriate", "repository", "exception", ".", "If", "it", "already", "is", "a", "repository", "exception", "it", "is", "simply", "casted", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/spi/ExceptionTransformer.java#L112-L129
8,015
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/layout/Layout.java
Layout.getDataProperties
public List<LayoutProperty> getDataProperties() throws FetchException { List<LayoutProperty> all = getAllProperties(); List<LayoutProperty> data = new ArrayList<LayoutProperty>(all.size() - 1); for (LayoutProperty property : all) { if (!property.isPrimaryKeyMember()) { data.add(property); } } return Collections.unmodifiableList(data); }
java
public List<LayoutProperty> getDataProperties() throws FetchException { List<LayoutProperty> all = getAllProperties(); List<LayoutProperty> data = new ArrayList<LayoutProperty>(all.size() - 1); for (LayoutProperty property : all) { if (!property.isPrimaryKeyMember()) { data.add(property); } } return Collections.unmodifiableList(data); }
[ "public", "List", "<", "LayoutProperty", ">", "getDataProperties", "(", ")", "throws", "FetchException", "{", "List", "<", "LayoutProperty", ">", "all", "=", "getAllProperties", "(", ")", ";", "List", "<", "LayoutProperty", ">", "data", "=", "new", "ArrayList", "<", "LayoutProperty", ">", "(", "all", ".", "size", "(", ")", "-", "1", ")", ";", "for", "(", "LayoutProperty", "property", ":", "all", ")", "{", "if", "(", "!", "property", ".", "isPrimaryKeyMember", "(", ")", ")", "{", "data", ".", "add", "(", "property", ")", ";", "}", "}", "return", "Collections", ".", "unmodifiableList", "(", "data", ")", ";", "}" ]
Returns all the non-primary key properties of this layout, in their proper order.
[ "Returns", "all", "the", "non", "-", "primary", "key", "properties", "of", "this", "layout", "in", "their", "proper", "order", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/layout/Layout.java#L250-L259
8,016
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/layout/Layout.java
Layout.getAllProperties
public List<LayoutProperty> getAllProperties() throws FetchException { List<LayoutProperty> all = mAllProperties; if (all == null) { Cursor <StoredLayoutProperty> cursor = mLayoutFactory.mPropertyStorage .query("layoutID = ?") .with(mStoredLayout.getLayoutID()) .orderBy("ordinal") .fetch(); try { List<LayoutProperty> list = new ArrayList<LayoutProperty>(); while (cursor.hasNext()) { list.add(new LayoutProperty(cursor.next())); } mAllProperties = all = Collections.unmodifiableList(list); } finally { cursor.close(); } } return all; }
java
public List<LayoutProperty> getAllProperties() throws FetchException { List<LayoutProperty> all = mAllProperties; if (all == null) { Cursor <StoredLayoutProperty> cursor = mLayoutFactory.mPropertyStorage .query("layoutID = ?") .with(mStoredLayout.getLayoutID()) .orderBy("ordinal") .fetch(); try { List<LayoutProperty> list = new ArrayList<LayoutProperty>(); while (cursor.hasNext()) { list.add(new LayoutProperty(cursor.next())); } mAllProperties = all = Collections.unmodifiableList(list); } finally { cursor.close(); } } return all; }
[ "public", "List", "<", "LayoutProperty", ">", "getAllProperties", "(", ")", "throws", "FetchException", "{", "List", "<", "LayoutProperty", ">", "all", "=", "mAllProperties", ";", "if", "(", "all", "==", "null", ")", "{", "Cursor", "<", "StoredLayoutProperty", ">", "cursor", "=", "mLayoutFactory", ".", "mPropertyStorage", ".", "query", "(", "\"layoutID = ?\"", ")", ".", "with", "(", "mStoredLayout", ".", "getLayoutID", "(", ")", ")", ".", "orderBy", "(", "\"ordinal\"", ")", ".", "fetch", "(", ")", ";", "try", "{", "List", "<", "LayoutProperty", ">", "list", "=", "new", "ArrayList", "<", "LayoutProperty", ">", "(", ")", ";", "while", "(", "cursor", ".", "hasNext", "(", ")", ")", "{", "list", ".", "add", "(", "new", "LayoutProperty", "(", "cursor", ".", "next", "(", ")", ")", ")", ";", "}", "mAllProperties", "=", "all", "=", "Collections", ".", "unmodifiableList", "(", "list", ")", ";", "}", "finally", "{", "cursor", ".", "close", "(", ")", ";", "}", "}", "return", "all", ";", "}" ]
Returns all the properties of this layout, in their proper order.
[ "Returns", "all", "the", "properties", "of", "this", "layout", "in", "their", "proper", "order", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/layout/Layout.java#L264-L288
8,017
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/layout/Layout.java
Layout.getGeneration
public Layout getGeneration(int generation) throws FetchNoneException, FetchException { try { Storage<StoredLayoutEquivalence> equivStorage = mLayoutFactory.mRepository.storageFor(StoredLayoutEquivalence.class); StoredLayoutEquivalence equiv = equivStorage.prepare(); equiv.setStorableTypeName(getStorableTypeName()); equiv.setGeneration(generation); if (equiv.tryLoad()) { generation = equiv.getMatchedGeneration(); } } catch (RepositoryException e) { throw e.toFetchException(); } return new Layout(mLayoutFactory, getStoredLayoutByGeneration(generation)); }
java
public Layout getGeneration(int generation) throws FetchNoneException, FetchException { try { Storage<StoredLayoutEquivalence> equivStorage = mLayoutFactory.mRepository.storageFor(StoredLayoutEquivalence.class); StoredLayoutEquivalence equiv = equivStorage.prepare(); equiv.setStorableTypeName(getStorableTypeName()); equiv.setGeneration(generation); if (equiv.tryLoad()) { generation = equiv.getMatchedGeneration(); } } catch (RepositoryException e) { throw e.toFetchException(); } return new Layout(mLayoutFactory, getStoredLayoutByGeneration(generation)); }
[ "public", "Layout", "getGeneration", "(", "int", "generation", ")", "throws", "FetchNoneException", ",", "FetchException", "{", "try", "{", "Storage", "<", "StoredLayoutEquivalence", ">", "equivStorage", "=", "mLayoutFactory", ".", "mRepository", ".", "storageFor", "(", "StoredLayoutEquivalence", ".", "class", ")", ";", "StoredLayoutEquivalence", "equiv", "=", "equivStorage", ".", "prepare", "(", ")", ";", "equiv", ".", "setStorableTypeName", "(", "getStorableTypeName", "(", ")", ")", ";", "equiv", ".", "setGeneration", "(", "generation", ")", ";", "if", "(", "equiv", ".", "tryLoad", "(", ")", ")", "{", "generation", "=", "equiv", ".", "getMatchedGeneration", "(", ")", ";", "}", "}", "catch", "(", "RepositoryException", "e", ")", "{", "throw", "e", ".", "toFetchException", "(", ")", ";", "}", "return", "new", "Layout", "(", "mLayoutFactory", ",", "getStoredLayoutByGeneration", "(", "generation", ")", ")", ";", "}" ]
Returns the layout for a particular generation of this layout's type. @throws FetchNoneException if generation not found
[ "Returns", "the", "layout", "for", "a", "particular", "generation", "of", "this", "layout", "s", "type", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/layout/Layout.java#L325-L340
8,018
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/layout/Layout.java
Layout.previousGeneration
public Layout previousGeneration() throws FetchException { Cursor<StoredLayout> cursor = mLayoutFactory.mLayoutStorage .query("storableTypeName = ? & generation < ?") .with(getStorableTypeName()).with(getGeneration()) .orderBy("-generation") .fetch(); try { if (cursor.hasNext()) { return new Layout(mLayoutFactory, cursor.next()); } } finally { cursor.close(); } return null; }
java
public Layout previousGeneration() throws FetchException { Cursor<StoredLayout> cursor = mLayoutFactory.mLayoutStorage .query("storableTypeName = ? & generation < ?") .with(getStorableTypeName()).with(getGeneration()) .orderBy("-generation") .fetch(); try { if (cursor.hasNext()) { return new Layout(mLayoutFactory, cursor.next()); } } finally { cursor.close(); } return null; }
[ "public", "Layout", "previousGeneration", "(", ")", "throws", "FetchException", "{", "Cursor", "<", "StoredLayout", ">", "cursor", "=", "mLayoutFactory", ".", "mLayoutStorage", ".", "query", "(", "\"storableTypeName = ? & generation < ?\"", ")", ".", "with", "(", "getStorableTypeName", "(", ")", ")", ".", "with", "(", "getGeneration", "(", ")", ")", ".", "orderBy", "(", "\"-generation\"", ")", ".", "fetch", "(", ")", ";", "try", "{", "if", "(", "cursor", ".", "hasNext", "(", ")", ")", "{", "return", "new", "Layout", "(", "mLayoutFactory", ",", "cursor", ".", "next", "(", ")", ")", ";", "}", "}", "finally", "{", "cursor", ".", "close", "(", ")", ";", "}", "return", "null", ";", "}" ]
Returns the previous known generation of the storable's layout, or null if none. @return a layout with a lower generation, or null if none
[ "Returns", "the", "previous", "known", "generation", "of", "the", "storable", "s", "layout", "or", "null", "if", "none", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/layout/Layout.java#L429-L445
8,019
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/layout/Layout.java
Layout.reconstruct
public Class<? extends Storable> reconstruct(ClassLoader loader) throws FetchException, SupportException { Class<? extends Storable> reconstructed = reconstruct(this, loader); mLayoutFactory.registerReconstructed(reconstructed, this); return reconstructed; }
java
public Class<? extends Storable> reconstruct(ClassLoader loader) throws FetchException, SupportException { Class<? extends Storable> reconstructed = reconstruct(this, loader); mLayoutFactory.registerReconstructed(reconstructed, this); return reconstructed; }
[ "public", "Class", "<", "?", "extends", "Storable", ">", "reconstruct", "(", "ClassLoader", "loader", ")", "throws", "FetchException", ",", "SupportException", "{", "Class", "<", "?", "extends", "Storable", ">", "reconstructed", "=", "reconstruct", "(", "this", ",", "loader", ")", ";", "mLayoutFactory", ".", "registerReconstructed", "(", "reconstructed", ",", "this", ")", ";", "return", "reconstructed", ";", "}" ]
Reconstructs the storable type defined by this layout by returning an auto-generated class. The reconstructed storable type will not contain everything in the original, but rather the minimum required to decode persisted instances. @param loader optional ClassLoader to load reconstruct class into, if it has not been loaded yet
[ "Reconstructs", "the", "storable", "type", "defined", "by", "this", "layout", "by", "returning", "an", "auto", "-", "generated", "class", ".", "The", "reconstructed", "storable", "type", "will", "not", "contain", "everything", "in", "the", "original", "but", "rather", "the", "minimum", "required", "to", "decode", "persisted", "instances", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/layout/Layout.java#L490-L496
8,020
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/layout/Layout.java
Layout.equalLayouts
public boolean equalLayouts(Layout layout) throws FetchException { if (this == layout) { return true; } return getStorableTypeName().equals(layout.getStorableTypeName()) && getAllProperties().equals(layout.getAllProperties()) && Arrays.equals(mStoredLayout.getExtraData(), layout.mStoredLayout.getExtraData()); }
java
public boolean equalLayouts(Layout layout) throws FetchException { if (this == layout) { return true; } return getStorableTypeName().equals(layout.getStorableTypeName()) && getAllProperties().equals(layout.getAllProperties()) && Arrays.equals(mStoredLayout.getExtraData(), layout.mStoredLayout.getExtraData()); }
[ "public", "boolean", "equalLayouts", "(", "Layout", "layout", ")", "throws", "FetchException", "{", "if", "(", "this", "==", "layout", ")", "{", "return", "true", ";", "}", "return", "getStorableTypeName", "(", ")", ".", "equals", "(", "layout", ".", "getStorableTypeName", "(", ")", ")", "&&", "getAllProperties", "(", ")", ".", "equals", "(", "layout", ".", "getAllProperties", "(", ")", ")", "&&", "Arrays", ".", "equals", "(", "mStoredLayout", ".", "getExtraData", "(", ")", ",", "layout", ".", "mStoredLayout", ".", "getExtraData", "(", ")", ")", ";", "}" ]
Returns true if the given layout matches this one. Layout ID, generation, and creation info is not considered in the comparison.
[ "Returns", "true", "if", "the", "given", "layout", "matches", "this", "one", ".", "Layout", "ID", "generation", "and", "creation", "info", "is", "not", "considered", "in", "the", "comparison", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/layout/Layout.java#L545-L552
8,021
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/layout/Layout.java
Layout.insert
void insert(boolean readOnly, int generation) throws PersistException { if (mAllProperties == null) { throw new IllegalStateException(); } mStoredLayout.setGeneration(generation); if (readOnly) { return; } try { mStoredLayout.insert(); } catch (UniqueConstraintException e) { // If existing record logically matches, update to allow replication. StoredLayout existing = mStoredLayout.prepare(); mStoredLayout.copyPrimaryKeyProperties(existing); try { existing.load(); } catch (FetchException e2) { throw e2.toPersistException(); } if (existing.getGeneration() != generation || !existing.getStorableTypeName().equals(getStorableTypeName()) || !Arrays.equals(existing.getExtraData(), mStoredLayout.getExtraData())) { throw e; } mStoredLayout.setVersionNumber(existing.getVersionNumber()); mStoredLayout.update(); } for (LayoutProperty property : mAllProperties) { property.insert(); } }
java
void insert(boolean readOnly, int generation) throws PersistException { if (mAllProperties == null) { throw new IllegalStateException(); } mStoredLayout.setGeneration(generation); if (readOnly) { return; } try { mStoredLayout.insert(); } catch (UniqueConstraintException e) { // If existing record logically matches, update to allow replication. StoredLayout existing = mStoredLayout.prepare(); mStoredLayout.copyPrimaryKeyProperties(existing); try { existing.load(); } catch (FetchException e2) { throw e2.toPersistException(); } if (existing.getGeneration() != generation || !existing.getStorableTypeName().equals(getStorableTypeName()) || !Arrays.equals(existing.getExtraData(), mStoredLayout.getExtraData())) { throw e; } mStoredLayout.setVersionNumber(existing.getVersionNumber()); mStoredLayout.update(); } for (LayoutProperty property : mAllProperties) { property.insert(); } }
[ "void", "insert", "(", "boolean", "readOnly", ",", "int", "generation", ")", "throws", "PersistException", "{", "if", "(", "mAllProperties", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", ")", ";", "}", "mStoredLayout", ".", "setGeneration", "(", "generation", ")", ";", "if", "(", "readOnly", ")", "{", "return", ";", "}", "try", "{", "mStoredLayout", ".", "insert", "(", ")", ";", "}", "catch", "(", "UniqueConstraintException", "e", ")", "{", "// If existing record logically matches, update to allow replication.\r", "StoredLayout", "existing", "=", "mStoredLayout", ".", "prepare", "(", ")", ";", "mStoredLayout", ".", "copyPrimaryKeyProperties", "(", "existing", ")", ";", "try", "{", "existing", ".", "load", "(", ")", ";", "}", "catch", "(", "FetchException", "e2", ")", "{", "throw", "e2", ".", "toPersistException", "(", ")", ";", "}", "if", "(", "existing", ".", "getGeneration", "(", ")", "!=", "generation", "||", "!", "existing", ".", "getStorableTypeName", "(", ")", ".", "equals", "(", "getStorableTypeName", "(", ")", ")", "||", "!", "Arrays", ".", "equals", "(", "existing", ".", "getExtraData", "(", ")", ",", "mStoredLayout", ".", "getExtraData", "(", ")", ")", ")", "{", "throw", "e", ";", "}", "mStoredLayout", ".", "setVersionNumber", "(", "existing", ".", "getVersionNumber", "(", ")", ")", ";", "mStoredLayout", ".", "update", "(", ")", ";", "}", "for", "(", "LayoutProperty", "property", ":", "mAllProperties", ")", "{", "property", ".", "insert", "(", ")", ";", "}", "}" ]
Assumes caller is in a transaction.
[ "Assumes", "caller", "is", "in", "a", "transaction", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/layout/Layout.java#L582-L617
8,022
cose-wg/COSE-JAVA
src/main/java/COSE/SignMessage.java
SignMessage.DecodeFromCBORObject
@Override protected void DecodeFromCBORObject(CBORObject obj) throws CoseException { if (obj.size() != 4) throw new CoseException("Invalid SignMessage structure"); if (obj.get(0).getType() == CBORType.ByteString) { rgbProtected = obj.get(0).GetByteString(); if (obj.get(0).GetByteString().length == 0) { objProtected = CBORObject.NewMap(); } else { objProtected = CBORObject.DecodeFromBytes(rgbProtected); if (objProtected.size() == 0) rgbProtected = new byte[0]; } } else throw new CoseException("Invalid SignMessage structure"); if (obj.get(1).getType() == CBORType.Map) { objUnprotected = obj.get(1); } else throw new CoseException("Invalid SignMessage structure"); if (obj.get(2).getType() == CBORType.ByteString) rgbContent = obj.get(2).GetByteString(); else if (!obj.get(2).isNull()) throw new CoseException("Invalid SignMessage structure"); if (obj.get(3).getType() == CBORType.Array) { for (int i=0; i<obj.get(3).size(); i++) { Signer signer = new Signer(); signer.DecodeFromCBORObject(obj.get(3).get(i)); signerList.add(signer); } } else throw new CoseException("Invalid SignMessage structure"); }
java
@Override protected void DecodeFromCBORObject(CBORObject obj) throws CoseException { if (obj.size() != 4) throw new CoseException("Invalid SignMessage structure"); if (obj.get(0).getType() == CBORType.ByteString) { rgbProtected = obj.get(0).GetByteString(); if (obj.get(0).GetByteString().length == 0) { objProtected = CBORObject.NewMap(); } else { objProtected = CBORObject.DecodeFromBytes(rgbProtected); if (objProtected.size() == 0) rgbProtected = new byte[0]; } } else throw new CoseException("Invalid SignMessage structure"); if (obj.get(1).getType() == CBORType.Map) { objUnprotected = obj.get(1); } else throw new CoseException("Invalid SignMessage structure"); if (obj.get(2).getType() == CBORType.ByteString) rgbContent = obj.get(2).GetByteString(); else if (!obj.get(2).isNull()) throw new CoseException("Invalid SignMessage structure"); if (obj.get(3).getType() == CBORType.Array) { for (int i=0; i<obj.get(3).size(); i++) { Signer signer = new Signer(); signer.DecodeFromCBORObject(obj.get(3).get(i)); signerList.add(signer); } } else throw new CoseException("Invalid SignMessage structure"); }
[ "@", "Override", "protected", "void", "DecodeFromCBORObject", "(", "CBORObject", "obj", ")", "throws", "CoseException", "{", "if", "(", "obj", ".", "size", "(", ")", "!=", "4", ")", "throw", "new", "CoseException", "(", "\"Invalid SignMessage structure\"", ")", ";", "if", "(", "obj", ".", "get", "(", "0", ")", ".", "getType", "(", ")", "==", "CBORType", ".", "ByteString", ")", "{", "rgbProtected", "=", "obj", ".", "get", "(", "0", ")", ".", "GetByteString", "(", ")", ";", "if", "(", "obj", ".", "get", "(", "0", ")", ".", "GetByteString", "(", ")", ".", "length", "==", "0", ")", "{", "objProtected", "=", "CBORObject", ".", "NewMap", "(", ")", ";", "}", "else", "{", "objProtected", "=", "CBORObject", ".", "DecodeFromBytes", "(", "rgbProtected", ")", ";", "if", "(", "objProtected", ".", "size", "(", ")", "==", "0", ")", "rgbProtected", "=", "new", "byte", "[", "0", "]", ";", "}", "}", "else", "throw", "new", "CoseException", "(", "\"Invalid SignMessage structure\"", ")", ";", "if", "(", "obj", ".", "get", "(", "1", ")", ".", "getType", "(", ")", "==", "CBORType", ".", "Map", ")", "{", "objUnprotected", "=", "obj", ".", "get", "(", "1", ")", ";", "}", "else", "throw", "new", "CoseException", "(", "\"Invalid SignMessage structure\"", ")", ";", "if", "(", "obj", ".", "get", "(", "2", ")", ".", "getType", "(", ")", "==", "CBORType", ".", "ByteString", ")", "rgbContent", "=", "obj", ".", "get", "(", "2", ")", ".", "GetByteString", "(", ")", ";", "else", "if", "(", "!", "obj", ".", "get", "(", "2", ")", ".", "isNull", "(", ")", ")", "throw", "new", "CoseException", "(", "\"Invalid SignMessage structure\"", ")", ";", "if", "(", "obj", ".", "get", "(", "3", ")", ".", "getType", "(", ")", "==", "CBORType", ".", "Array", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "obj", ".", "get", "(", "3", ")", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Signer", "signer", "=", "new", "Signer", "(", ")", ";", "signer", ".", "DecodeFromCBORObject", "(", "obj", ".", "get", "(", "3", ")", ".", "get", "(", "i", ")", ")", ";", "signerList", ".", "add", "(", "signer", ")", ";", "}", "}", "else", "throw", "new", "CoseException", "(", "\"Invalid SignMessage structure\"", ")", ";", "}" ]
Internal function used in creating a SignMessage object from a byte string. @param obj COSE_Sign encoded object. @throws CoseException Errors generated by the COSE module
[ "Internal", "function", "used", "in", "creating", "a", "SignMessage", "object", "from", "a", "byte", "string", "." ]
f972b11ab4c9a18f911bc49a15225a6951cf6f63
https://github.com/cose-wg/COSE-JAVA/blob/f972b11ab4c9a18f911bc49a15225a6951cf6f63/src/main/java/COSE/SignMessage.java#L58-L90
8,023
cose-wg/COSE-JAVA
src/main/java/COSE/SignMessage.java
SignMessage.EncodeCBORObject
@Override protected CBORObject EncodeCBORObject() throws CoseException { sign(); CBORObject obj = CBORObject.NewArray(); obj.Add(rgbProtected); obj.Add(objUnprotected); if (emitContent) obj.Add(rgbContent); else obj.Add(null); CBORObject signers = CBORObject.NewArray(); obj.Add(signers); for (Signer r : signerList) { signers.Add(r.EncodeToCBORObject()); } return obj; }
java
@Override protected CBORObject EncodeCBORObject() throws CoseException { sign(); CBORObject obj = CBORObject.NewArray(); obj.Add(rgbProtected); obj.Add(objUnprotected); if (emitContent) obj.Add(rgbContent); else obj.Add(null); CBORObject signers = CBORObject.NewArray(); obj.Add(signers); for (Signer r : signerList) { signers.Add(r.EncodeToCBORObject()); } return obj; }
[ "@", "Override", "protected", "CBORObject", "EncodeCBORObject", "(", ")", "throws", "CoseException", "{", "sign", "(", ")", ";", "CBORObject", "obj", "=", "CBORObject", ".", "NewArray", "(", ")", ";", "obj", ".", "Add", "(", "rgbProtected", ")", ";", "obj", ".", "Add", "(", "objUnprotected", ")", ";", "if", "(", "emitContent", ")", "obj", ".", "Add", "(", "rgbContent", ")", ";", "else", "obj", ".", "Add", "(", "null", ")", ";", "CBORObject", "signers", "=", "CBORObject", ".", "NewArray", "(", ")", ";", "obj", ".", "Add", "(", "signers", ")", ";", "for", "(", "Signer", "r", ":", "signerList", ")", "{", "signers", ".", "Add", "(", "r", ".", "EncodeToCBORObject", "(", ")", ")", ";", "}", "return", "obj", ";", "}" ]
Internal function used to create a serialization of a COSE_Sign message @return CBOR object which can be encoded. @throws CoseException Errors generated by the COSE module
[ "Internal", "function", "used", "to", "create", "a", "serialization", "of", "a", "COSE_Sign", "message" ]
f972b11ab4c9a18f911bc49a15225a6951cf6f63
https://github.com/cose-wg/COSE-JAVA/blob/f972b11ab4c9a18f911bc49a15225a6951cf6f63/src/main/java/COSE/SignMessage.java#L98-L116
8,024
cose-wg/COSE-JAVA
src/main/java/COSE/SignMessage.java
SignMessage.sign
public void sign() throws CoseException { if (rgbProtected == null) { if (objProtected.size() == 0) rgbProtected = new byte[0]; else rgbProtected = objProtected.EncodeToBytes(); } for (Signer r : signerList) { r.sign(rgbProtected, rgbContent); } ProcessCounterSignatures(); }
java
public void sign() throws CoseException { if (rgbProtected == null) { if (objProtected.size() == 0) rgbProtected = new byte[0]; else rgbProtected = objProtected.EncodeToBytes(); } for (Signer r : signerList) { r.sign(rgbProtected, rgbContent); } ProcessCounterSignatures(); }
[ "public", "void", "sign", "(", ")", "throws", "CoseException", "{", "if", "(", "rgbProtected", "==", "null", ")", "{", "if", "(", "objProtected", ".", "size", "(", ")", "==", "0", ")", "rgbProtected", "=", "new", "byte", "[", "0", "]", ";", "else", "rgbProtected", "=", "objProtected", ".", "EncodeToBytes", "(", ")", ";", "}", "for", "(", "Signer", "r", ":", "signerList", ")", "{", "r", ".", "sign", "(", "rgbProtected", ",", "rgbContent", ")", ";", "}", "ProcessCounterSignatures", "(", ")", ";", "}" ]
Causes a signature to be created for every signer that does not already have one. @throws CoseException Errors generated by the COSE module
[ "Causes", "a", "signature", "to", "be", "created", "for", "every", "signer", "that", "does", "not", "already", "have", "one", "." ]
f972b11ab4c9a18f911bc49a15225a6951cf6f63
https://github.com/cose-wg/COSE-JAVA/blob/f972b11ab4c9a18f911bc49a15225a6951cf6f63/src/main/java/COSE/SignMessage.java#L162-L173
8,025
cose-wg/COSE-JAVA
src/main/java/COSE/SignMessage.java
SignMessage.validate
public boolean validate(Signer signerToUse) throws CoseException { for (Signer r : signerList) { if (r == signerToUse) { return r.validate(rgbProtected, rgbContent); } } throw new CoseException("Signer not found"); }
java
public boolean validate(Signer signerToUse) throws CoseException { for (Signer r : signerList) { if (r == signerToUse) { return r.validate(rgbProtected, rgbContent); } } throw new CoseException("Signer not found"); }
[ "public", "boolean", "validate", "(", "Signer", "signerToUse", ")", "throws", "CoseException", "{", "for", "(", "Signer", "r", ":", "signerList", ")", "{", "if", "(", "r", "==", "signerToUse", ")", "{", "return", "r", ".", "validate", "(", "rgbProtected", ",", "rgbContent", ")", ";", "}", "}", "throw", "new", "CoseException", "(", "\"Signer not found\"", ")", ";", "}" ]
Validate the signature on a message for a specific signer. The signer is required to be one of the Signer objects attached to the message. The key must be attached to the signer before making this call. @param signerToUse which signer to validate with @return true if the message validates with the signer @throws CoseException Errors generated by the COSE module
[ "Validate", "the", "signature", "on", "a", "message", "for", "a", "specific", "signer", ".", "The", "signer", "is", "required", "to", "be", "one", "of", "the", "Signer", "objects", "attached", "to", "the", "message", ".", "The", "key", "must", "be", "attached", "to", "the", "signer", "before", "making", "this", "call", "." ]
f972b11ab4c9a18f911bc49a15225a6951cf6f63
https://github.com/cose-wg/COSE-JAVA/blob/f972b11ab4c9a18f911bc49a15225a6951cf6f63/src/main/java/COSE/SignMessage.java#L185-L193
8,026
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepositoryBuilder.java
JDBCRepositoryBuilder.getDataSource
public DataSource getDataSource() throws ConfigurationException { if (mDataSource == null) { if (mDriverClassName != null && mURL != null) { try { mDataSource = new SimpleDataSource (mDriverClassName, mURL, mUsername, mPassword); } catch (SQLException e) { Throwable cause = e.getCause(); if (cause == null) { cause = e; } throw new ConfigurationException(cause); } } } DataSource ds = mDataSource; if (getDataSourceLogging() && !(ds instanceof LoggingDataSource)) { ds = LoggingDataSource.create(ds); } return ds; }
java
public DataSource getDataSource() throws ConfigurationException { if (mDataSource == null) { if (mDriverClassName != null && mURL != null) { try { mDataSource = new SimpleDataSource (mDriverClassName, mURL, mUsername, mPassword); } catch (SQLException e) { Throwable cause = e.getCause(); if (cause == null) { cause = e; } throw new ConfigurationException(cause); } } } DataSource ds = mDataSource; if (getDataSourceLogging() && !(ds instanceof LoggingDataSource)) { ds = LoggingDataSource.create(ds); } return ds; }
[ "public", "DataSource", "getDataSource", "(", ")", "throws", "ConfigurationException", "{", "if", "(", "mDataSource", "==", "null", ")", "{", "if", "(", "mDriverClassName", "!=", "null", "&&", "mURL", "!=", "null", ")", "{", "try", "{", "mDataSource", "=", "new", "SimpleDataSource", "(", "mDriverClassName", ",", "mURL", ",", "mUsername", ",", "mPassword", ")", ";", "}", "catch", "(", "SQLException", "e", ")", "{", "Throwable", "cause", "=", "e", ".", "getCause", "(", ")", ";", "if", "(", "cause", "==", "null", ")", "{", "cause", "=", "e", ";", "}", "throw", "new", "ConfigurationException", "(", "cause", ")", ";", "}", "}", "}", "DataSource", "ds", "=", "mDataSource", ";", "if", "(", "getDataSourceLogging", "(", ")", "&&", "!", "(", "ds", "instanceof", "LoggingDataSource", ")", ")", "{", "ds", "=", "LoggingDataSource", ".", "create", "(", "ds", ")", ";", "}", "return", "ds", ";", "}" ]
Returns the source of JDBC connections, which defaults to a non-pooling source if driver class, driver URL, username, and password are all supplied. @throws ConfigurationException if driver class wasn't found
[ "Returns", "the", "source", "of", "JDBC", "connections", "which", "defaults", "to", "a", "non", "-", "pooling", "source", "if", "driver", "class", "driver", "URL", "username", "and", "password", "are", "all", "supplied", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepositoryBuilder.java#L149-L171
8,027
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepositoryBuilder.java
JDBCRepositoryBuilder.setSuppressReload
public void setSuppressReload(boolean suppress, String className) { if (mSuppressReloadMap == null) { mSuppressReloadMap = new HashMap<String, Boolean>(); } mSuppressReloadMap.put(className, suppress); }
java
public void setSuppressReload(boolean suppress, String className) { if (mSuppressReloadMap == null) { mSuppressReloadMap = new HashMap<String, Boolean>(); } mSuppressReloadMap.put(className, suppress); }
[ "public", "void", "setSuppressReload", "(", "boolean", "suppress", ",", "String", "className", ")", "{", "if", "(", "mSuppressReloadMap", "==", "null", ")", "{", "mSuppressReloadMap", "=", "new", "HashMap", "<", "String", ",", "Boolean", ">", "(", ")", ";", "}", "mSuppressReloadMap", ".", "put", "(", "className", ",", "suppress", ")", ";", "}" ]
By default, JDBCRepository reloads Storables after every insert or update. This ensures that any applied defaults or triggered changes are available to the Storable. If the database has no such defaults or triggers, suppressing reload can improve performance. <p>Note: If Storable has a version property and auto versioning is not enabled, or if the Storable has any automatic properties, the Storable might still be reloaded. @param suppress true to suppress, false to unsuppress @param className name of Storable type to suppress reload for; pass null to suppress all @since 1.1.3
[ "By", "default", "JDBCRepository", "reloads", "Storables", "after", "every", "insert", "or", "update", ".", "This", "ensures", "that", "any", "applied", "defaults", "or", "triggered", "changes", "are", "available", "to", "the", "Storable", ".", "If", "the", "database", "has", "no", "such", "defaults", "or", "triggers", "suppressing", "reload", "can", "improve", "performance", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepositoryBuilder.java#L358-L363
8,028
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyDecoder.java
KeyDecoder.decodeIntegerObjDesc
public static Integer decodeIntegerObjDesc(byte[] src, int srcOffset) throws CorruptEncodingException { try { int b = src[srcOffset]; if (b == NULL_BYTE_HIGH || b == NULL_BYTE_LOW) { return null; } return decodeIntDesc(src, srcOffset + 1); } catch (IndexOutOfBoundsException e) { throw new CorruptEncodingException(null, e); } }
java
public static Integer decodeIntegerObjDesc(byte[] src, int srcOffset) throws CorruptEncodingException { try { int b = src[srcOffset]; if (b == NULL_BYTE_HIGH || b == NULL_BYTE_LOW) { return null; } return decodeIntDesc(src, srcOffset + 1); } catch (IndexOutOfBoundsException e) { throw new CorruptEncodingException(null, e); } }
[ "public", "static", "Integer", "decodeIntegerObjDesc", "(", "byte", "[", "]", "src", ",", "int", "srcOffset", ")", "throws", "CorruptEncodingException", "{", "try", "{", "int", "b", "=", "src", "[", "srcOffset", "]", ";", "if", "(", "b", "==", "NULL_BYTE_HIGH", "||", "b", "==", "NULL_BYTE_LOW", ")", "{", "return", "null", ";", "}", "return", "decodeIntDesc", "(", "src", ",", "srcOffset", "+", "1", ")", ";", "}", "catch", "(", "IndexOutOfBoundsException", "e", ")", "{", "throw", "new", "CorruptEncodingException", "(", "null", ",", "e", ")", ";", "}", "}" ]
Decodes a signed Integer object from exactly 1 or 5 bytes, as encoded for descending order. If null is returned, then 1 byte was read. @param src source of encoded bytes @param srcOffset offset into source array @return signed Integer object or null
[ "Decodes", "a", "signed", "Integer", "object", "from", "exactly", "1", "or", "5", "bytes", "as", "encoded", "for", "descending", "order", ".", "If", "null", "is", "returned", "then", "1", "byte", "was", "read", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyDecoder.java#L58-L70
8,029
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyDecoder.java
KeyDecoder.decodeLongObjDesc
public static Long decodeLongObjDesc(byte[] src, int srcOffset) throws CorruptEncodingException { try { int b = src[srcOffset]; if (b == NULL_BYTE_HIGH || b == NULL_BYTE_LOW) { return null; } return decodeLongDesc(src, srcOffset + 1); } catch (IndexOutOfBoundsException e) { throw new CorruptEncodingException(null, e); } }
java
public static Long decodeLongObjDesc(byte[] src, int srcOffset) throws CorruptEncodingException { try { int b = src[srcOffset]; if (b == NULL_BYTE_HIGH || b == NULL_BYTE_LOW) { return null; } return decodeLongDesc(src, srcOffset + 1); } catch (IndexOutOfBoundsException e) { throw new CorruptEncodingException(null, e); } }
[ "public", "static", "Long", "decodeLongObjDesc", "(", "byte", "[", "]", "src", ",", "int", "srcOffset", ")", "throws", "CorruptEncodingException", "{", "try", "{", "int", "b", "=", "src", "[", "srcOffset", "]", ";", "if", "(", "b", "==", "NULL_BYTE_HIGH", "||", "b", "==", "NULL_BYTE_LOW", ")", "{", "return", "null", ";", "}", "return", "decodeLongDesc", "(", "src", ",", "srcOffset", "+", "1", ")", ";", "}", "catch", "(", "IndexOutOfBoundsException", "e", ")", "{", "throw", "new", "CorruptEncodingException", "(", "null", ",", "e", ")", ";", "}", "}" ]
Decodes a signed Long object from exactly 1 or 9 bytes, as encoded for descending order. If null is returned, then 1 byte was read. @param src source of encoded bytes @param srcOffset offset into source array @return signed Long object or null
[ "Decodes", "a", "signed", "Long", "object", "from", "exactly", "1", "or", "9", "bytes", "as", "encoded", "for", "descending", "order", ".", "If", "null", "is", "returned", "then", "1", "byte", "was", "read", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyDecoder.java#L94-L106
8,030
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyDecoder.java
KeyDecoder.decodeByteDesc
public static byte decodeByteDesc(byte[] src, int srcOffset) throws CorruptEncodingException { try { return (byte)(src[srcOffset] ^ 0x7f); } catch (IndexOutOfBoundsException e) { throw new CorruptEncodingException(null, e); } }
java
public static byte decodeByteDesc(byte[] src, int srcOffset) throws CorruptEncodingException { try { return (byte)(src[srcOffset] ^ 0x7f); } catch (IndexOutOfBoundsException e) { throw new CorruptEncodingException(null, e); } }
[ "public", "static", "byte", "decodeByteDesc", "(", "byte", "[", "]", "src", ",", "int", "srcOffset", ")", "throws", "CorruptEncodingException", "{", "try", "{", "return", "(", "byte", ")", "(", "src", "[", "srcOffset", "]", "^", "0x7f", ")", ";", "}", "catch", "(", "IndexOutOfBoundsException", "e", ")", "{", "throw", "new", "CorruptEncodingException", "(", "null", ",", "e", ")", ";", "}", "}" ]
Decodes a signed byte from exactly 1 byte, as encoded for descending order. @param src source of encoded bytes @param srcOffset offset into source array @return signed byte value
[ "Decodes", "a", "signed", "byte", "from", "exactly", "1", "byte", "as", "encoded", "for", "descending", "order", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyDecoder.java#L116-L124
8,031
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyDecoder.java
KeyDecoder.decodeByteObjDesc
public static Byte decodeByteObjDesc(byte[] src, int srcOffset) throws CorruptEncodingException { try { int b = src[srcOffset]; if (b == NULL_BYTE_HIGH || b == NULL_BYTE_LOW) { return null; } return decodeByteDesc(src, srcOffset + 1); } catch (IndexOutOfBoundsException e) { throw new CorruptEncodingException(null, e); } }
java
public static Byte decodeByteObjDesc(byte[] src, int srcOffset) throws CorruptEncodingException { try { int b = src[srcOffset]; if (b == NULL_BYTE_HIGH || b == NULL_BYTE_LOW) { return null; } return decodeByteDesc(src, srcOffset + 1); } catch (IndexOutOfBoundsException e) { throw new CorruptEncodingException(null, e); } }
[ "public", "static", "Byte", "decodeByteObjDesc", "(", "byte", "[", "]", "src", ",", "int", "srcOffset", ")", "throws", "CorruptEncodingException", "{", "try", "{", "int", "b", "=", "src", "[", "srcOffset", "]", ";", "if", "(", "b", "==", "NULL_BYTE_HIGH", "||", "b", "==", "NULL_BYTE_LOW", ")", "{", "return", "null", ";", "}", "return", "decodeByteDesc", "(", "src", ",", "srcOffset", "+", "1", ")", ";", "}", "catch", "(", "IndexOutOfBoundsException", "e", ")", "{", "throw", "new", "CorruptEncodingException", "(", "null", ",", "e", ")", ";", "}", "}" ]
Decodes a signed Byte object from exactly 1 or 2 bytes, as encoded for descending order. If null is returned, then 1 byte was read. @param src source of encoded bytes @param srcOffset offset into source array @return signed Byte object or null
[ "Decodes", "a", "signed", "Byte", "object", "from", "exactly", "1", "or", "2", "bytes", "as", "encoded", "for", "descending", "order", ".", "If", "null", "is", "returned", "then", "1", "byte", "was", "read", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyDecoder.java#L134-L146
8,032
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyDecoder.java
KeyDecoder.decodeShortDesc
public static short decodeShortDesc(byte[] src, int srcOffset) throws CorruptEncodingException { try { return (short)(((src[srcOffset] << 8) | (src[srcOffset + 1] & 0xff)) ^ 0x7fff); } catch (IndexOutOfBoundsException e) { throw new CorruptEncodingException(null, e); } }
java
public static short decodeShortDesc(byte[] src, int srcOffset) throws CorruptEncodingException { try { return (short)(((src[srcOffset] << 8) | (src[srcOffset + 1] & 0xff)) ^ 0x7fff); } catch (IndexOutOfBoundsException e) { throw new CorruptEncodingException(null, e); } }
[ "public", "static", "short", "decodeShortDesc", "(", "byte", "[", "]", "src", ",", "int", "srcOffset", ")", "throws", "CorruptEncodingException", "{", "try", "{", "return", "(", "short", ")", "(", "(", "(", "src", "[", "srcOffset", "]", "<<", "8", ")", "|", "(", "src", "[", "srcOffset", "+", "1", "]", "&", "0xff", ")", ")", "^", "0x7fff", ")", ";", "}", "catch", "(", "IndexOutOfBoundsException", "e", ")", "{", "throw", "new", "CorruptEncodingException", "(", "null", ",", "e", ")", ";", "}", "}" ]
Decodes a signed short from exactly 2 bytes, as encoded for descending order. @param src source of encoded bytes @param srcOffset offset into source array @return signed short value
[ "Decodes", "a", "signed", "short", "from", "exactly", "2", "bytes", "as", "encoded", "for", "descending", "order", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyDecoder.java#L156-L164
8,033
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyDecoder.java
KeyDecoder.decodeShortObjDesc
public static Short decodeShortObjDesc(byte[] src, int srcOffset) throws CorruptEncodingException { try { int b = src[srcOffset]; if (b == NULL_BYTE_HIGH || b == NULL_BYTE_LOW) { return null; } return decodeShortDesc(src, srcOffset + 1); } catch (IndexOutOfBoundsException e) { throw new CorruptEncodingException(null, e); } }
java
public static Short decodeShortObjDesc(byte[] src, int srcOffset) throws CorruptEncodingException { try { int b = src[srcOffset]; if (b == NULL_BYTE_HIGH || b == NULL_BYTE_LOW) { return null; } return decodeShortDesc(src, srcOffset + 1); } catch (IndexOutOfBoundsException e) { throw new CorruptEncodingException(null, e); } }
[ "public", "static", "Short", "decodeShortObjDesc", "(", "byte", "[", "]", "src", ",", "int", "srcOffset", ")", "throws", "CorruptEncodingException", "{", "try", "{", "int", "b", "=", "src", "[", "srcOffset", "]", ";", "if", "(", "b", "==", "NULL_BYTE_HIGH", "||", "b", "==", "NULL_BYTE_LOW", ")", "{", "return", "null", ";", "}", "return", "decodeShortDesc", "(", "src", ",", "srcOffset", "+", "1", ")", ";", "}", "catch", "(", "IndexOutOfBoundsException", "e", ")", "{", "throw", "new", "CorruptEncodingException", "(", "null", ",", "e", ")", ";", "}", "}" ]
Decodes a signed Short object from exactly 1 or 3 bytes, as encoded for descending order. If null is returned, then 1 byte was read. @param src source of encoded bytes @param srcOffset offset into source array @return signed Short object or null
[ "Decodes", "a", "signed", "Short", "object", "from", "exactly", "1", "or", "3", "bytes", "as", "encoded", "for", "descending", "order", ".", "If", "null", "is", "returned", "then", "1", "byte", "was", "read", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyDecoder.java#L174-L186
8,034
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyDecoder.java
KeyDecoder.decodeCharDesc
public static char decodeCharDesc(byte[] src, int srcOffset) throws CorruptEncodingException { try { return (char)~((src[srcOffset] << 8) | (src[srcOffset + 1] & 0xff)); } catch (IndexOutOfBoundsException e) { throw new CorruptEncodingException(null, e); } }
java
public static char decodeCharDesc(byte[] src, int srcOffset) throws CorruptEncodingException { try { return (char)~((src[srcOffset] << 8) | (src[srcOffset + 1] & 0xff)); } catch (IndexOutOfBoundsException e) { throw new CorruptEncodingException(null, e); } }
[ "public", "static", "char", "decodeCharDesc", "(", "byte", "[", "]", "src", ",", "int", "srcOffset", ")", "throws", "CorruptEncodingException", "{", "try", "{", "return", "(", "char", ")", "~", "(", "(", "src", "[", "srcOffset", "]", "<<", "8", ")", "|", "(", "src", "[", "srcOffset", "+", "1", "]", "&", "0xff", ")", ")", ";", "}", "catch", "(", "IndexOutOfBoundsException", "e", ")", "{", "throw", "new", "CorruptEncodingException", "(", "null", ",", "e", ")", ";", "}", "}" ]
Decodes a char from exactly 2 bytes, as encoded for descending order. @param src source of encoded bytes @param srcOffset offset into source array @return char value
[ "Decodes", "a", "char", "from", "exactly", "2", "bytes", "as", "encoded", "for", "descending", "order", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyDecoder.java#L195-L203
8,035
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyDecoder.java
KeyDecoder.decodeCharacterObjDesc
public static Character decodeCharacterObjDesc(byte[] src, int srcOffset) throws CorruptEncodingException { try { int b = src[srcOffset]; if (b == NULL_BYTE_HIGH || b == NULL_BYTE_LOW) { return null; } return decodeCharDesc(src, srcOffset + 1); } catch (IndexOutOfBoundsException e) { throw new CorruptEncodingException(null, e); } }
java
public static Character decodeCharacterObjDesc(byte[] src, int srcOffset) throws CorruptEncodingException { try { int b = src[srcOffset]; if (b == NULL_BYTE_HIGH || b == NULL_BYTE_LOW) { return null; } return decodeCharDesc(src, srcOffset + 1); } catch (IndexOutOfBoundsException e) { throw new CorruptEncodingException(null, e); } }
[ "public", "static", "Character", "decodeCharacterObjDesc", "(", "byte", "[", "]", "src", ",", "int", "srcOffset", ")", "throws", "CorruptEncodingException", "{", "try", "{", "int", "b", "=", "src", "[", "srcOffset", "]", ";", "if", "(", "b", "==", "NULL_BYTE_HIGH", "||", "b", "==", "NULL_BYTE_LOW", ")", "{", "return", "null", ";", "}", "return", "decodeCharDesc", "(", "src", ",", "srcOffset", "+", "1", ")", ";", "}", "catch", "(", "IndexOutOfBoundsException", "e", ")", "{", "throw", "new", "CorruptEncodingException", "(", "null", ",", "e", ")", ";", "}", "}" ]
Decodes a Character object from exactly 1 or 3 bytes, as encoded for descending order. If null is returned, then 1 byte was read. @param src source of encoded bytes @param srcOffset offset into source array @return Character object or null
[ "Decodes", "a", "Character", "object", "from", "exactly", "1", "or", "3", "bytes", "as", "encoded", "for", "descending", "order", ".", "If", "null", "is", "returned", "then", "1", "byte", "was", "read", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyDecoder.java#L213-L225
8,036
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyDecoder.java
KeyDecoder.decodeBooleanDesc
public static boolean decodeBooleanDesc(byte[] src, int srcOffset) throws CorruptEncodingException { try { return src[srcOffset] == 127; } catch (IndexOutOfBoundsException e) { throw new CorruptEncodingException(null, e); } }
java
public static boolean decodeBooleanDesc(byte[] src, int srcOffset) throws CorruptEncodingException { try { return src[srcOffset] == 127; } catch (IndexOutOfBoundsException e) { throw new CorruptEncodingException(null, e); } }
[ "public", "static", "boolean", "decodeBooleanDesc", "(", "byte", "[", "]", "src", ",", "int", "srcOffset", ")", "throws", "CorruptEncodingException", "{", "try", "{", "return", "src", "[", "srcOffset", "]", "==", "127", ";", "}", "catch", "(", "IndexOutOfBoundsException", "e", ")", "{", "throw", "new", "CorruptEncodingException", "(", "null", ",", "e", ")", ";", "}", "}" ]
Decodes a boolean from exactly 1 byte, as encoded for descending order. @param src source of encoded bytes @param srcOffset offset into source array @return boolean value
[ "Decodes", "a", "boolean", "from", "exactly", "1", "byte", "as", "encoded", "for", "descending", "order", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyDecoder.java#L234-L242
8,037
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyDecoder.java
KeyDecoder.decodeFloatDesc
public static float decodeFloatDesc(byte[] src, int srcOffset) throws CorruptEncodingException { int bits = DataDecoder.decodeFloatBits(src, srcOffset); if (bits >= 0) { bits ^= 0x7fffffff; } return Float.intBitsToFloat(bits); }
java
public static float decodeFloatDesc(byte[] src, int srcOffset) throws CorruptEncodingException { int bits = DataDecoder.decodeFloatBits(src, srcOffset); if (bits >= 0) { bits ^= 0x7fffffff; } return Float.intBitsToFloat(bits); }
[ "public", "static", "float", "decodeFloatDesc", "(", "byte", "[", "]", "src", ",", "int", "srcOffset", ")", "throws", "CorruptEncodingException", "{", "int", "bits", "=", "DataDecoder", ".", "decodeFloatBits", "(", "src", ",", "srcOffset", ")", ";", "if", "(", "bits", ">=", "0", ")", "{", "bits", "^=", "0x7fffffff", ";", "}", "return", "Float", ".", "intBitsToFloat", "(", "bits", ")", ";", "}" ]
Decodes a float from exactly 4 bytes, as encoded for descending order. @param src source of encoded bytes @param srcOffset offset into source array @return float value
[ "Decodes", "a", "float", "from", "exactly", "4", "bytes", "as", "encoded", "for", "descending", "order", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyDecoder.java#L276-L284
8,038
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyDecoder.java
KeyDecoder.decodeDoubleDesc
public static double decodeDoubleDesc(byte[] src, int srcOffset) throws CorruptEncodingException { long bits = DataDecoder.decodeDoubleBits(src, srcOffset); if (bits >= 0) { bits ^= 0x7fffffffffffffffL; } return Double.longBitsToDouble(bits); }
java
public static double decodeDoubleDesc(byte[] src, int srcOffset) throws CorruptEncodingException { long bits = DataDecoder.decodeDoubleBits(src, srcOffset); if (bits >= 0) { bits ^= 0x7fffffffffffffffL; } return Double.longBitsToDouble(bits); }
[ "public", "static", "double", "decodeDoubleDesc", "(", "byte", "[", "]", "src", ",", "int", "srcOffset", ")", "throws", "CorruptEncodingException", "{", "long", "bits", "=", "DataDecoder", ".", "decodeDoubleBits", "(", "src", ",", "srcOffset", ")", ";", "if", "(", "bits", ">=", "0", ")", "{", "bits", "^=", "0x7fffffffffffffff", "", "L", ";", "}", "return", "Double", ".", "longBitsToDouble", "(", "bits", ")", ";", "}" ]
Decodes a double from exactly 8 bytes, as encoded for descending order. @param src source of encoded bytes @param srcOffset offset into source array @return double value
[ "Decodes", "a", "double", "from", "exactly", "8", "bytes", "as", "encoded", "for", "descending", "order", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyDecoder.java#L310-L318
8,039
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyDecoder.java
KeyDecoder.decode
public static int decode(byte[] src, int srcOffset, BigInteger[] valueRef) throws CorruptEncodingException { int headerSize; int bytesLength; byte[] bytes; try { int header = src[srcOffset]; if (header == NULL_BYTE_HIGH || header == NULL_BYTE_LOW) { valueRef[0] = null; return 1; } header &= 0xff; if (header > 1 && header < 0xfe) { if (header < 0x80) { bytesLength = 0x80 - header; } else { bytesLength = header - 0x7f; } headerSize = 1; } else { bytesLength = Math.abs(DataDecoder.decodeInt(src, srcOffset + 1)); headerSize = 5; } bytes = new byte[bytesLength]; System.arraycopy(src, srcOffset + headerSize, bytes, 0, bytesLength); } catch (IndexOutOfBoundsException e) { throw new CorruptEncodingException(null, e); } valueRef[0] = new BigInteger(bytes); return headerSize + bytesLength; }
java
public static int decode(byte[] src, int srcOffset, BigInteger[] valueRef) throws CorruptEncodingException { int headerSize; int bytesLength; byte[] bytes; try { int header = src[srcOffset]; if (header == NULL_BYTE_HIGH || header == NULL_BYTE_LOW) { valueRef[0] = null; return 1; } header &= 0xff; if (header > 1 && header < 0xfe) { if (header < 0x80) { bytesLength = 0x80 - header; } else { bytesLength = header - 0x7f; } headerSize = 1; } else { bytesLength = Math.abs(DataDecoder.decodeInt(src, srcOffset + 1)); headerSize = 5; } bytes = new byte[bytesLength]; System.arraycopy(src, srcOffset + headerSize, bytes, 0, bytesLength); } catch (IndexOutOfBoundsException e) { throw new CorruptEncodingException(null, e); } valueRef[0] = new BigInteger(bytes); return headerSize + bytesLength; }
[ "public", "static", "int", "decode", "(", "byte", "[", "]", "src", ",", "int", "srcOffset", ",", "BigInteger", "[", "]", "valueRef", ")", "throws", "CorruptEncodingException", "{", "int", "headerSize", ";", "int", "bytesLength", ";", "byte", "[", "]", "bytes", ";", "try", "{", "int", "header", "=", "src", "[", "srcOffset", "]", ";", "if", "(", "header", "==", "NULL_BYTE_HIGH", "||", "header", "==", "NULL_BYTE_LOW", ")", "{", "valueRef", "[", "0", "]", "=", "null", ";", "return", "1", ";", "}", "header", "&=", "0xff", ";", "if", "(", "header", ">", "1", "&&", "header", "<", "0xfe", ")", "{", "if", "(", "header", "<", "0x80", ")", "{", "bytesLength", "=", "0x80", "-", "header", ";", "}", "else", "{", "bytesLength", "=", "header", "-", "0x7f", ";", "}", "headerSize", "=", "1", ";", "}", "else", "{", "bytesLength", "=", "Math", ".", "abs", "(", "DataDecoder", ".", "decodeInt", "(", "src", ",", "srcOffset", "+", "1", ")", ")", ";", "headerSize", "=", "5", ";", "}", "bytes", "=", "new", "byte", "[", "bytesLength", "]", ";", "System", ".", "arraycopy", "(", "src", ",", "srcOffset", "+", "headerSize", ",", "bytes", ",", "0", ",", "bytesLength", ")", ";", "}", "catch", "(", "IndexOutOfBoundsException", "e", ")", "{", "throw", "new", "CorruptEncodingException", "(", "null", ",", "e", ")", ";", "}", "valueRef", "[", "0", "]", "=", "new", "BigInteger", "(", "bytes", ")", ";", "return", "headerSize", "+", "bytesLength", ";", "}" ]
Decodes the given BigInteger as originally encoded for ascending order. @param src source of encoded data @param srcOffset offset into encoded data @param valueRef decoded BigInteger is stored in element 0, which may be null @return amount of bytes read from source @throws CorruptEncodingException if source data is corrupt @since 1.2
[ "Decodes", "the", "given", "BigInteger", "as", "originally", "encoded", "for", "ascending", "order", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyDecoder.java#L347-L383
8,040
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyDecoder.java
KeyDecoder.decodeDesc
public static int decodeDesc(byte[] src, int srcOffset, BigInteger[] valueRef) throws CorruptEncodingException { int headerSize; int bytesLength; byte[] bytes; try { int header = src[srcOffset]; if (header == NULL_BYTE_HIGH || header == NULL_BYTE_LOW) { valueRef[0] = null; return 1; } header &= 0xff; if (header > 1 && header < 0xfe) { if (header < 0x80) { bytesLength = 0x80 - header; } else { bytesLength = header - 0x7f; } headerSize = 1; } else { bytesLength = Math.abs(DataDecoder.decodeInt(src, srcOffset + 1)); headerSize = 5; } bytes = new byte[bytesLength]; srcOffset += headerSize; for (int i=0; i<bytesLength; i++) { bytes[i] = (byte) ~src[srcOffset + i]; } } catch (IndexOutOfBoundsException e) { throw new CorruptEncodingException(null, e); } valueRef[0] = new BigInteger(bytes); return headerSize + bytesLength; }
java
public static int decodeDesc(byte[] src, int srcOffset, BigInteger[] valueRef) throws CorruptEncodingException { int headerSize; int bytesLength; byte[] bytes; try { int header = src[srcOffset]; if (header == NULL_BYTE_HIGH || header == NULL_BYTE_LOW) { valueRef[0] = null; return 1; } header &= 0xff; if (header > 1 && header < 0xfe) { if (header < 0x80) { bytesLength = 0x80 - header; } else { bytesLength = header - 0x7f; } headerSize = 1; } else { bytesLength = Math.abs(DataDecoder.decodeInt(src, srcOffset + 1)); headerSize = 5; } bytes = new byte[bytesLength]; srcOffset += headerSize; for (int i=0; i<bytesLength; i++) { bytes[i] = (byte) ~src[srcOffset + i]; } } catch (IndexOutOfBoundsException e) { throw new CorruptEncodingException(null, e); } valueRef[0] = new BigInteger(bytes); return headerSize + bytesLength; }
[ "public", "static", "int", "decodeDesc", "(", "byte", "[", "]", "src", ",", "int", "srcOffset", ",", "BigInteger", "[", "]", "valueRef", ")", "throws", "CorruptEncodingException", "{", "int", "headerSize", ";", "int", "bytesLength", ";", "byte", "[", "]", "bytes", ";", "try", "{", "int", "header", "=", "src", "[", "srcOffset", "]", ";", "if", "(", "header", "==", "NULL_BYTE_HIGH", "||", "header", "==", "NULL_BYTE_LOW", ")", "{", "valueRef", "[", "0", "]", "=", "null", ";", "return", "1", ";", "}", "header", "&=", "0xff", ";", "if", "(", "header", ">", "1", "&&", "header", "<", "0xfe", ")", "{", "if", "(", "header", "<", "0x80", ")", "{", "bytesLength", "=", "0x80", "-", "header", ";", "}", "else", "{", "bytesLength", "=", "header", "-", "0x7f", ";", "}", "headerSize", "=", "1", ";", "}", "else", "{", "bytesLength", "=", "Math", ".", "abs", "(", "DataDecoder", ".", "decodeInt", "(", "src", ",", "srcOffset", "+", "1", ")", ")", ";", "headerSize", "=", "5", ";", "}", "bytes", "=", "new", "byte", "[", "bytesLength", "]", ";", "srcOffset", "+=", "headerSize", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "bytesLength", ";", "i", "++", ")", "{", "bytes", "[", "i", "]", "=", "(", "byte", ")", "~", "src", "[", "srcOffset", "+", "i", "]", ";", "}", "}", "catch", "(", "IndexOutOfBoundsException", "e", ")", "{", "throw", "new", "CorruptEncodingException", "(", "null", ",", "e", ")", ";", "}", "valueRef", "[", "0", "]", "=", "new", "BigInteger", "(", "bytes", ")", ";", "return", "headerSize", "+", "bytesLength", ";", "}" ]
Decodes the given BigInteger as originally encoded for descending order. @param src source of encoded data @param srcOffset offset into encoded data @param valueRef decoded BigInteger is stored in element 0, which may be null @return amount of bytes read from source @throws CorruptEncodingException if source data is corrupt @since 1.2
[ "Decodes", "the", "given", "BigInteger", "as", "originally", "encoded", "for", "descending", "order", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyDecoder.java#L395-L435
8,041
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyDecoder.java
KeyDecoder.decode
public static int decode(byte[] src, int srcOffset, BigDecimal[] valueRef) throws CorruptEncodingException { return decode(src, srcOffset, valueRef, 0); }
java
public static int decode(byte[] src, int srcOffset, BigDecimal[] valueRef) throws CorruptEncodingException { return decode(src, srcOffset, valueRef, 0); }
[ "public", "static", "int", "decode", "(", "byte", "[", "]", "src", ",", "int", "srcOffset", ",", "BigDecimal", "[", "]", "valueRef", ")", "throws", "CorruptEncodingException", "{", "return", "decode", "(", "src", ",", "srcOffset", ",", "valueRef", ",", "0", ")", ";", "}" ]
Decodes the given BigDecimal as originally encoded for ascending order. @param src source of encoded data @param srcOffset offset into encoded data @param valueRef decoded BigDecimal is stored in element 0, which may be null @return amount of bytes read from source @throws CorruptEncodingException if source data is corrupt @since 1.2
[ "Decodes", "the", "given", "BigDecimal", "as", "originally", "encoded", "for", "ascending", "order", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyDecoder.java#L447-L451
8,042
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/KeyDecoder.java
KeyDecoder.decode
public static int decode(byte[] src, int srcOffset, byte[][] valueRef) throws CorruptEncodingException { try { return decode(src, srcOffset, valueRef, 0); } catch (IndexOutOfBoundsException e) { throw new CorruptEncodingException(null, e); } }
java
public static int decode(byte[] src, int srcOffset, byte[][] valueRef) throws CorruptEncodingException { try { return decode(src, srcOffset, valueRef, 0); } catch (IndexOutOfBoundsException e) { throw new CorruptEncodingException(null, e); } }
[ "public", "static", "int", "decode", "(", "byte", "[", "]", "src", ",", "int", "srcOffset", ",", "byte", "[", "]", "[", "]", "valueRef", ")", "throws", "CorruptEncodingException", "{", "try", "{", "return", "decode", "(", "src", ",", "srcOffset", ",", "valueRef", ",", "0", ")", ";", "}", "catch", "(", "IndexOutOfBoundsException", "e", ")", "{", "throw", "new", "CorruptEncodingException", "(", "null", ",", "e", ")", ";", "}", "}" ]
Decodes the given byte array as originally encoded for ascending order. The decoding stops when any kind of terminator or illegal byte has been read. The decoded bytes are stored in valueRef. @param src source of encoded data @param srcOffset offset into encoded data @param valueRef decoded byte array is stored in element 0, which may be null @return amount of bytes read from source @throws CorruptEncodingException if source data is corrupt
[ "Decodes", "the", "given", "byte", "array", "as", "originally", "encoded", "for", "ascending", "order", ".", "The", "decoding", "stops", "when", "any", "kind", "of", "terminator", "or", "illegal", "byte", "has", "been", "read", ".", "The", "decoded", "bytes", "are", "stored", "in", "valueRef", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyDecoder.java#L599-L607
8,043
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/qe/UnionQueryExecutor.java
UnionQueryExecutor.getFilter
public Filter<S> getFilter() { Filter<S> filter = null; for (QueryExecutor<S> executor : mExecutors) { Filter<S> subFilter = executor.getFilter(); filter = filter == null ? subFilter : filter.or(subFilter); } return filter; }
java
public Filter<S> getFilter() { Filter<S> filter = null; for (QueryExecutor<S> executor : mExecutors) { Filter<S> subFilter = executor.getFilter(); filter = filter == null ? subFilter : filter.or(subFilter); } return filter; }
[ "public", "Filter", "<", "S", ">", "getFilter", "(", ")", "{", "Filter", "<", "S", ">", "filter", "=", "null", ";", "for", "(", "QueryExecutor", "<", "S", ">", "executor", ":", "mExecutors", ")", "{", "Filter", "<", "S", ">", "subFilter", "=", "executor", ".", "getFilter", "(", ")", ";", "filter", "=", "filter", "==", "null", "?", "subFilter", ":", "filter", ".", "or", "(", "subFilter", ")", ";", "}", "return", "filter", ";", "}" ]
Returns the combined filter of the wrapped executors.
[ "Returns", "the", "combined", "filter", "of", "the", "wrapped", "executors", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/UnionQueryExecutor.java#L119-L126
8,044
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/qe/UnionQueryExecutor.java
UnionQueryExecutor.printNative
@Override public boolean printNative(Appendable app, int indentLevel, FilterValues<S> values) throws IOException { boolean result = false; for (QueryExecutor<S> executor : mExecutors) { result |= executor.printNative(app, indentLevel, values); } return result; }
java
@Override public boolean printNative(Appendable app, int indentLevel, FilterValues<S> values) throws IOException { boolean result = false; for (QueryExecutor<S> executor : mExecutors) { result |= executor.printNative(app, indentLevel, values); } return result; }
[ "@", "Override", "public", "boolean", "printNative", "(", "Appendable", "app", ",", "int", "indentLevel", ",", "FilterValues", "<", "S", ">", "values", ")", "throws", "IOException", "{", "boolean", "result", "=", "false", ";", "for", "(", "QueryExecutor", "<", "S", ">", "executor", ":", "mExecutors", ")", "{", "result", "|=", "executor", ".", "printNative", "(", "app", ",", "indentLevel", ",", "values", ")", ";", "}", "return", "result", ";", "}" ]
Prints native queries of the wrapped executors.
[ "Prints", "native", "queries", "of", "the", "wrapped", "executors", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/UnionQueryExecutor.java#L135-L144
8,045
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/info/StorableIndex.java
StorableIndex.parseNameDescriptor
@SuppressWarnings("unchecked") public static <S extends Storable> StorableIndex<S> parseNameDescriptor (String desc, StorableInfo<S> info) throws IllegalArgumentException { String name = info.getStorableType().getName(); if (!desc.startsWith(name)) { throw new IllegalArgumentException("Descriptor starts with wrong type name: \"" + desc + "\", \"" + name + '"'); } Map<String, ? extends StorableProperty<S>> allProperties = info.getAllProperties(); List<StorableProperty<S>> properties = new ArrayList<StorableProperty<S>>(); List<Direction> directions = new ArrayList<Direction>(); boolean unique; try { int pos = name.length(); if (desc.charAt(pos++) != '~') { throw new IllegalArgumentException("Invalid syntax"); } { int pos2 = nextSep(desc, pos); String attr = desc.substring(pos, pos2); if (attr.equals("U")) { unique = true; } else if (attr.equals("N")) { unique = false; } else { throw new IllegalArgumentException("Unknown attribute"); } pos = pos2; } while (pos < desc.length()) { char sign = desc.charAt(pos++); if (sign == '+') { directions.add(Direction.ASCENDING); } else if (sign == '-') { directions.add(Direction.DESCENDING); } else if (sign == '~') { directions.add(Direction.UNSPECIFIED); } else { throw new IllegalArgumentException("Unknown property direction"); } int pos2 = nextSep(desc, pos); String propertyName = desc.substring(pos, pos2); StorableProperty<S> property = allProperties.get(propertyName); if (property == null) { throw new IllegalArgumentException("Unknown property: " + propertyName); } properties.add(property); pos = pos2; } } catch (IndexOutOfBoundsException e) { throw new IllegalArgumentException("Invalid syntax"); } int size = properties.size(); if (size == 0 || size != directions.size()) { throw new IllegalArgumentException("No properties specified"); } StorableIndex<S> index = new StorableIndex<S> (properties.toArray(new StorableProperty[size]), directions.toArray(new Direction[size])); return index.unique(unique); }
java
@SuppressWarnings("unchecked") public static <S extends Storable> StorableIndex<S> parseNameDescriptor (String desc, StorableInfo<S> info) throws IllegalArgumentException { String name = info.getStorableType().getName(); if (!desc.startsWith(name)) { throw new IllegalArgumentException("Descriptor starts with wrong type name: \"" + desc + "\", \"" + name + '"'); } Map<String, ? extends StorableProperty<S>> allProperties = info.getAllProperties(); List<StorableProperty<S>> properties = new ArrayList<StorableProperty<S>>(); List<Direction> directions = new ArrayList<Direction>(); boolean unique; try { int pos = name.length(); if (desc.charAt(pos++) != '~') { throw new IllegalArgumentException("Invalid syntax"); } { int pos2 = nextSep(desc, pos); String attr = desc.substring(pos, pos2); if (attr.equals("U")) { unique = true; } else if (attr.equals("N")) { unique = false; } else { throw new IllegalArgumentException("Unknown attribute"); } pos = pos2; } while (pos < desc.length()) { char sign = desc.charAt(pos++); if (sign == '+') { directions.add(Direction.ASCENDING); } else if (sign == '-') { directions.add(Direction.DESCENDING); } else if (sign == '~') { directions.add(Direction.UNSPECIFIED); } else { throw new IllegalArgumentException("Unknown property direction"); } int pos2 = nextSep(desc, pos); String propertyName = desc.substring(pos, pos2); StorableProperty<S> property = allProperties.get(propertyName); if (property == null) { throw new IllegalArgumentException("Unknown property: " + propertyName); } properties.add(property); pos = pos2; } } catch (IndexOutOfBoundsException e) { throw new IllegalArgumentException("Invalid syntax"); } int size = properties.size(); if (size == 0 || size != directions.size()) { throw new IllegalArgumentException("No properties specified"); } StorableIndex<S> index = new StorableIndex<S> (properties.toArray(new StorableProperty[size]), directions.toArray(new Direction[size])); return index.unique(unique); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "S", "extends", "Storable", ">", "StorableIndex", "<", "S", ">", "parseNameDescriptor", "(", "String", "desc", ",", "StorableInfo", "<", "S", ">", "info", ")", "throws", "IllegalArgumentException", "{", "String", "name", "=", "info", ".", "getStorableType", "(", ")", ".", "getName", "(", ")", ";", "if", "(", "!", "desc", ".", "startsWith", "(", "name", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Descriptor starts with wrong type name: \\\"\"", "+", "desc", "+", "\"\\\", \\\"\"", "+", "name", "+", "'", "'", ")", ";", "}", "Map", "<", "String", ",", "?", "extends", "StorableProperty", "<", "S", ">", ">", "allProperties", "=", "info", ".", "getAllProperties", "(", ")", ";", "List", "<", "StorableProperty", "<", "S", ">", ">", "properties", "=", "new", "ArrayList", "<", "StorableProperty", "<", "S", ">", ">", "(", ")", ";", "List", "<", "Direction", ">", "directions", "=", "new", "ArrayList", "<", "Direction", ">", "(", ")", ";", "boolean", "unique", ";", "try", "{", "int", "pos", "=", "name", ".", "length", "(", ")", ";", "if", "(", "desc", ".", "charAt", "(", "pos", "++", ")", "!=", "'", "'", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Invalid syntax\"", ")", ";", "}", "{", "int", "pos2", "=", "nextSep", "(", "desc", ",", "pos", ")", ";", "String", "attr", "=", "desc", ".", "substring", "(", "pos", ",", "pos2", ")", ";", "if", "(", "attr", ".", "equals", "(", "\"U\"", ")", ")", "{", "unique", "=", "true", ";", "}", "else", "if", "(", "attr", ".", "equals", "(", "\"N\"", ")", ")", "{", "unique", "=", "false", ";", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", "\"Unknown attribute\"", ")", ";", "}", "pos", "=", "pos2", ";", "}", "while", "(", "pos", "<", "desc", ".", "length", "(", ")", ")", "{", "char", "sign", "=", "desc", ".", "charAt", "(", "pos", "++", ")", ";", "if", "(", "sign", "==", "'", "'", ")", "{", "directions", ".", "add", "(", "Direction", ".", "ASCENDING", ")", ";", "}", "else", "if", "(", "sign", "==", "'", "'", ")", "{", "directions", ".", "add", "(", "Direction", ".", "DESCENDING", ")", ";", "}", "else", "if", "(", "sign", "==", "'", "'", ")", "{", "directions", ".", "add", "(", "Direction", ".", "UNSPECIFIED", ")", ";", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", "\"Unknown property direction\"", ")", ";", "}", "int", "pos2", "=", "nextSep", "(", "desc", ",", "pos", ")", ";", "String", "propertyName", "=", "desc", ".", "substring", "(", "pos", ",", "pos2", ")", ";", "StorableProperty", "<", "S", ">", "property", "=", "allProperties", ".", "get", "(", "propertyName", ")", ";", "if", "(", "property", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Unknown property: \"", "+", "propertyName", ")", ";", "}", "properties", ".", "add", "(", "property", ")", ";", "pos", "=", "pos2", ";", "}", "}", "catch", "(", "IndexOutOfBoundsException", "e", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Invalid syntax\"", ")", ";", "}", "int", "size", "=", "properties", ".", "size", "(", ")", ";", "if", "(", "size", "==", "0", "||", "size", "!=", "directions", ".", "size", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"No properties specified\"", ")", ";", "}", "StorableIndex", "<", "S", ">", "index", "=", "new", "StorableIndex", "<", "S", ">", "(", "properties", ".", "toArray", "(", "new", "StorableProperty", "[", "size", "]", ")", ",", "directions", ".", "toArray", "(", "new", "Direction", "[", "size", "]", ")", ")", ";", "return", "index", ".", "unique", "(", "unique", ")", ";", "}" ]
Parses an index descriptor and returns an index object. @param desc name descriptor, as created by {@link #getNameDescriptor} @param info info on storable type @return index represented by descriptor @throws IllegalArgumentException if error in descriptor syntax or if it refers to unknown properties
[ "Parses", "an", "index", "descriptor", "and", "returns", "an", "index", "object", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/info/StorableIndex.java#L51-L126
8,046
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/info/StorableIndex.java
StorableIndex.nextSep
private static int nextSep(String desc, int pos) { int pos2 = desc.length(); // assume we'll find none int candidate = desc.indexOf('+', pos); if (candidate > 0) { pos2=candidate; } candidate = desc.indexOf('-', pos); if (candidate>0) { pos2 = Math.min(candidate, pos2); } candidate = desc.indexOf('~', pos); if (candidate>0) { pos2 = Math.min(candidate, pos2); } return pos2; }
java
private static int nextSep(String desc, int pos) { int pos2 = desc.length(); // assume we'll find none int candidate = desc.indexOf('+', pos); if (candidate > 0) { pos2=candidate; } candidate = desc.indexOf('-', pos); if (candidate>0) { pos2 = Math.min(candidate, pos2); } candidate = desc.indexOf('~', pos); if (candidate>0) { pos2 = Math.min(candidate, pos2); } return pos2; }
[ "private", "static", "int", "nextSep", "(", "String", "desc", ",", "int", "pos", ")", "{", "int", "pos2", "=", "desc", ".", "length", "(", ")", ";", "// assume we'll find none\r", "int", "candidate", "=", "desc", ".", "indexOf", "(", "'", "'", ",", "pos", ")", ";", "if", "(", "candidate", ">", "0", ")", "{", "pos2", "=", "candidate", ";", "}", "candidate", "=", "desc", ".", "indexOf", "(", "'", "'", ",", "pos", ")", ";", "if", "(", "candidate", ">", "0", ")", "{", "pos2", "=", "Math", ".", "min", "(", "candidate", ",", "pos2", ")", ";", "}", "candidate", "=", "desc", ".", "indexOf", "(", "'", "'", ",", "pos", ")", ";", "if", "(", "candidate", ">", "0", ")", "{", "pos2", "=", "Math", ".", "min", "(", "candidate", ",", "pos2", ")", ";", "}", "return", "pos2", ";", "}" ]
Find the first subsequent occurrance of '+', '-', or '~' in the string or the end of line if none are there @param desc string to search @param pos starting position in string @return position of next separator, or end of string if none present
[ "Find", "the", "first", "subsequent", "occurrance", "of", "+", "-", "or", "~", "in", "the", "string", "or", "the", "end", "of", "line", "if", "none", "are", "there" ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/info/StorableIndex.java#L135-L152
8,047
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/info/StorableIndex.java
StorableIndex.getOrderedProperty
public OrderedProperty<S> getOrderedProperty(int index) { return OrderedProperty.get(mProperties[index], mDirections[index]); }
java
public OrderedProperty<S> getOrderedProperty(int index) { return OrderedProperty.get(mProperties[index], mDirections[index]); }
[ "public", "OrderedProperty", "<", "S", ">", "getOrderedProperty", "(", "int", "index", ")", "{", "return", "OrderedProperty", ".", "get", "(", "mProperties", "[", "index", "]", ",", "mDirections", "[", "index", "]", ")", ";", "}" ]
Returns a specific property in this index, with the direction folded in.
[ "Returns", "a", "specific", "property", "in", "this", "index", "with", "the", "direction", "folded", "in", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/info/StorableIndex.java#L388-L390
8,048
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/info/StorableIndex.java
StorableIndex.getOrderedProperties
@SuppressWarnings("unchecked") public OrderedProperty<S>[] getOrderedProperties() { OrderedProperty<S>[] ordered = new OrderedProperty[mProperties.length]; for (int i=mProperties.length; --i>=0; ) { ordered[i] = OrderedProperty.get(mProperties[i], mDirections[i]); } return ordered; }
java
@SuppressWarnings("unchecked") public OrderedProperty<S>[] getOrderedProperties() { OrderedProperty<S>[] ordered = new OrderedProperty[mProperties.length]; for (int i=mProperties.length; --i>=0; ) { ordered[i] = OrderedProperty.get(mProperties[i], mDirections[i]); } return ordered; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "OrderedProperty", "<", "S", ">", "[", "]", "getOrderedProperties", "(", ")", "{", "OrderedProperty", "<", "S", ">", "[", "]", "ordered", "=", "new", "OrderedProperty", "[", "mProperties", ".", "length", "]", ";", "for", "(", "int", "i", "=", "mProperties", ".", "length", ";", "--", "i", ">=", "0", ";", ")", "{", "ordered", "[", "i", "]", "=", "OrderedProperty", ".", "get", "(", "mProperties", "[", "i", "]", ",", "mDirections", "[", "i", "]", ")", ";", "}", "return", "ordered", ";", "}" ]
Returns a new array with all the properties in it, with directions folded in.
[ "Returns", "a", "new", "array", "with", "all", "the", "properties", "in", "it", "with", "directions", "folded", "in", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/info/StorableIndex.java#L396-L403
8,049
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/info/StorableIndex.java
StorableIndex.unique
public StorableIndex<S> unique(boolean unique) { if (unique == mUnique) { return this; } return new StorableIndex<S>(mProperties, mDirections, unique, mClustered, false); }
java
public StorableIndex<S> unique(boolean unique) { if (unique == mUnique) { return this; } return new StorableIndex<S>(mProperties, mDirections, unique, mClustered, false); }
[ "public", "StorableIndex", "<", "S", ">", "unique", "(", "boolean", "unique", ")", "{", "if", "(", "unique", "==", "mUnique", ")", "{", "return", "this", ";", "}", "return", "new", "StorableIndex", "<", "S", ">", "(", "mProperties", ",", "mDirections", ",", "unique", ",", "mClustered", ",", "false", ")", ";", "}" ]
Returns a StorableIndex instance which is unique or not.
[ "Returns", "a", "StorableIndex", "instance", "which", "is", "unique", "or", "not", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/info/StorableIndex.java#L420-L425
8,050
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/info/StorableIndex.java
StorableIndex.clustered
public StorableIndex<S> clustered(boolean clustered) { if (clustered == mClustered) { return this; } return new StorableIndex<S>(mProperties, mDirections, mUnique, clustered, false); }
java
public StorableIndex<S> clustered(boolean clustered) { if (clustered == mClustered) { return this; } return new StorableIndex<S>(mProperties, mDirections, mUnique, clustered, false); }
[ "public", "StorableIndex", "<", "S", ">", "clustered", "(", "boolean", "clustered", ")", "{", "if", "(", "clustered", "==", "mClustered", ")", "{", "return", "this", ";", "}", "return", "new", "StorableIndex", "<", "S", ">", "(", "mProperties", ",", "mDirections", ",", "mUnique", ",", "clustered", ",", "false", ")", ";", "}" ]
Returns a StorableIndex instance which is clustered or not.
[ "Returns", "a", "StorableIndex", "instance", "which", "is", "clustered", "or", "not", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/info/StorableIndex.java#L430-L435
8,051
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/info/StorableIndex.java
StorableIndex.reverse
public StorableIndex<S> reverse() { Direction[] directions = mDirections; specified: { for (int i=directions.length; --i>=0; ) { if (directions[i] != Direction.UNSPECIFIED) { break specified; } } // Completely unspecified direction, so nothing to reverse. return this; } directions = directions.clone(); for (int i=directions.length; --i>=0; ) { directions[i] = directions[i].reverse(); } return new StorableIndex<S>(mProperties, directions, mUnique, mClustered, false); }
java
public StorableIndex<S> reverse() { Direction[] directions = mDirections; specified: { for (int i=directions.length; --i>=0; ) { if (directions[i] != Direction.UNSPECIFIED) { break specified; } } // Completely unspecified direction, so nothing to reverse. return this; } directions = directions.clone(); for (int i=directions.length; --i>=0; ) { directions[i] = directions[i].reverse(); } return new StorableIndex<S>(mProperties, directions, mUnique, mClustered, false); }
[ "public", "StorableIndex", "<", "S", ">", "reverse", "(", ")", "{", "Direction", "[", "]", "directions", "=", "mDirections", ";", "specified", ":", "{", "for", "(", "int", "i", "=", "directions", ".", "length", ";", "--", "i", ">=", "0", ";", ")", "{", "if", "(", "directions", "[", "i", "]", "!=", "Direction", ".", "UNSPECIFIED", ")", "{", "break", "specified", ";", "}", "}", "// Completely unspecified direction, so nothing to reverse.\r", "return", "this", ";", "}", "directions", "=", "directions", ".", "clone", "(", ")", ";", "for", "(", "int", "i", "=", "directions", ".", "length", ";", "--", "i", ">=", "0", ";", ")", "{", "directions", "[", "i", "]", "=", "directions", "[", "i", "]", ".", "reverse", "(", ")", ";", "}", "return", "new", "StorableIndex", "<", "S", ">", "(", "mProperties", ",", "directions", ",", "mUnique", ",", "mClustered", ",", "false", ")", ";", "}" ]
Returns a StorableIndex instance with all the properties reversed.
[ "Returns", "a", "StorableIndex", "instance", "with", "all", "the", "properties", "reversed", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/info/StorableIndex.java#L440-L459
8,052
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/info/StorableIndex.java
StorableIndex.setDefaultDirection
public StorableIndex<S> setDefaultDirection(Direction direction) { Direction[] directions = mDirections; unspecified: { for (int i=directions.length; --i>=0; ) { if (directions[i] == Direction.UNSPECIFIED) { break unspecified; } } // Completely specified direction, so nothing to alter. return this; } directions = directions.clone(); for (int i=directions.length; --i>=0; ) { if (directions[i] == Direction.UNSPECIFIED) { directions[i] = direction; } } return new StorableIndex<S>(mProperties, directions, mUnique, mClustered, false); }
java
public StorableIndex<S> setDefaultDirection(Direction direction) { Direction[] directions = mDirections; unspecified: { for (int i=directions.length; --i>=0; ) { if (directions[i] == Direction.UNSPECIFIED) { break unspecified; } } // Completely specified direction, so nothing to alter. return this; } directions = directions.clone(); for (int i=directions.length; --i>=0; ) { if (directions[i] == Direction.UNSPECIFIED) { directions[i] = direction; } } return new StorableIndex<S>(mProperties, directions, mUnique, mClustered, false); }
[ "public", "StorableIndex", "<", "S", ">", "setDefaultDirection", "(", "Direction", "direction", ")", "{", "Direction", "[", "]", "directions", "=", "mDirections", ";", "unspecified", ":", "{", "for", "(", "int", "i", "=", "directions", ".", "length", ";", "--", "i", ">=", "0", ";", ")", "{", "if", "(", "directions", "[", "i", "]", "==", "Direction", ".", "UNSPECIFIED", ")", "{", "break", "unspecified", ";", "}", "}", "// Completely specified direction, so nothing to alter.\r", "return", "this", ";", "}", "directions", "=", "directions", ".", "clone", "(", ")", ";", "for", "(", "int", "i", "=", "directions", ".", "length", ";", "--", "i", ">=", "0", ";", ")", "{", "if", "(", "directions", "[", "i", "]", "==", "Direction", ".", "UNSPECIFIED", ")", "{", "directions", "[", "i", "]", "=", "direction", ";", "}", "}", "return", "new", "StorableIndex", "<", "S", ">", "(", "mProperties", ",", "directions", ",", "mUnique", ",", "mClustered", ",", "false", ")", ";", "}" ]
Returns a StorableIndex instance with all unspecified directions set to the given direction. Returns this if all directions are already specified. @param direction direction to replace all unspecified directions
[ "Returns", "a", "StorableIndex", "instance", "with", "all", "unspecified", "directions", "set", "to", "the", "given", "direction", ".", "Returns", "this", "if", "all", "directions", "are", "already", "specified", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/info/StorableIndex.java#L468-L489
8,053
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/info/StorableIndex.java
StorableIndex.uniquify
public StorableIndex<S> uniquify(StorableKey<S> key) { if (key == null) { throw new IllegalArgumentException(); } if (isUnique()) { return this; } StorableIndex<S> index = this; for (OrderedProperty<S> keyProp : key.getProperties()) { index = index.addProperty (keyProp.getChainedProperty().getPrimeProperty(), keyProp.getDirection()); } return index.unique(true); }
java
public StorableIndex<S> uniquify(StorableKey<S> key) { if (key == null) { throw new IllegalArgumentException(); } if (isUnique()) { return this; } StorableIndex<S> index = this; for (OrderedProperty<S> keyProp : key.getProperties()) { index = index.addProperty (keyProp.getChainedProperty().getPrimeProperty(), keyProp.getDirection()); } return index.unique(true); }
[ "public", "StorableIndex", "<", "S", ">", "uniquify", "(", "StorableKey", "<", "S", ">", "key", ")", "{", "if", "(", "key", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", ")", ";", "}", "if", "(", "isUnique", "(", ")", ")", "{", "return", "this", ";", "}", "StorableIndex", "<", "S", ">", "index", "=", "this", ";", "for", "(", "OrderedProperty", "<", "S", ">", "keyProp", ":", "key", ".", "getProperties", "(", ")", ")", "{", "index", "=", "index", ".", "addProperty", "(", "keyProp", ".", "getChainedProperty", "(", ")", ".", "getPrimeProperty", "(", ")", ",", "keyProp", ".", "getDirection", "(", ")", ")", ";", "}", "return", "index", ".", "unique", "(", "true", ")", ";", "}" ]
Returns a StorableIndex which is unique, possibly by appending properties from the given key. If index is already unique, it is returned as-is.
[ "Returns", "a", "StorableIndex", "which", "is", "unique", "possibly", "by", "appending", "properties", "from", "the", "given", "key", ".", "If", "index", "is", "already", "unique", "it", "is", "returned", "as", "-", "is", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/info/StorableIndex.java#L524-L541
8,054
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/info/StorableIndex.java
StorableIndex.getTypeDescriptor
public String getTypeDescriptor() { StringBuilder b = new StringBuilder(); int count = getPropertyCount(); for (int i=0; i<count; i++) { StorableProperty property = getProperty(i); if (property.isNullable()) { b.append('N'); } b.append(TypeDesc.forClass(property.getType()).getDescriptor()); } return b.toString(); }
java
public String getTypeDescriptor() { StringBuilder b = new StringBuilder(); int count = getPropertyCount(); for (int i=0; i<count; i++) { StorableProperty property = getProperty(i); if (property.isNullable()) { b.append('N'); } b.append(TypeDesc.forClass(property.getType()).getDescriptor()); } return b.toString(); }
[ "public", "String", "getTypeDescriptor", "(", ")", "{", "StringBuilder", "b", "=", "new", "StringBuilder", "(", ")", ";", "int", "count", "=", "getPropertyCount", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "count", ";", "i", "++", ")", "{", "StorableProperty", "property", "=", "getProperty", "(", "i", ")", ";", "if", "(", "property", ".", "isNullable", "(", ")", ")", "{", "b", ".", "append", "(", "'", "'", ")", ";", "}", "b", ".", "append", "(", "TypeDesc", ".", "forClass", "(", "property", ".", "getType", "(", ")", ")", ".", "getDescriptor", "(", ")", ")", ";", "}", "return", "b", ".", "toString", "(", ")", ";", "}" ]
Converts this index into a parseable type descriptor string, which basically consists of Java type descriptors appended together. There is one slight difference. Types which may be null are prefixed with a 'N' character.
[ "Converts", "this", "index", "into", "a", "parseable", "type", "descriptor", "string", "which", "basically", "consists", "of", "Java", "type", "descriptors", "appended", "together", ".", "There", "is", "one", "slight", "difference", ".", "Types", "which", "may", "be", "null", "are", "prefixed", "with", "a", "N", "character", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/info/StorableIndex.java#L576-L589
8,055
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/info/StorableIndex.java
StorableIndex.appendTo
public void appendTo(Appendable app) throws IOException { app.append("{properties=["); int length = mProperties.length; for (int i=0; i<length; i++) { if (i > 0) { app.append(", "); } app.append(mDirections[i].toCharacter()); app.append(mProperties[i].getName()); } app.append(']'); app.append(", unique="); app.append(String.valueOf(isUnique())); app.append('}'); }
java
public void appendTo(Appendable app) throws IOException { app.append("{properties=["); int length = mProperties.length; for (int i=0; i<length; i++) { if (i > 0) { app.append(", "); } app.append(mDirections[i].toCharacter()); app.append(mProperties[i].getName()); } app.append(']'); app.append(", unique="); app.append(String.valueOf(isUnique())); app.append('}'); }
[ "public", "void", "appendTo", "(", "Appendable", "app", ")", "throws", "IOException", "{", "app", ".", "append", "(", "\"{properties=[\"", ")", ";", "int", "length", "=", "mProperties", ".", "length", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "{", "if", "(", "i", ">", "0", ")", "{", "app", ".", "append", "(", "\", \"", ")", ";", "}", "app", ".", "append", "(", "mDirections", "[", "i", "]", ".", "toCharacter", "(", ")", ")", ";", "app", ".", "append", "(", "mProperties", "[", "i", "]", ".", "getName", "(", ")", ")", ";", "}", "app", ".", "append", "(", "'", "'", ")", ";", "app", ".", "append", "(", "\", unique=\"", ")", ";", "app", ".", "append", "(", "String", ".", "valueOf", "(", "isUnique", "(", ")", ")", ")", ";", "app", ".", "append", "(", "'", "'", ")", ";", "}" ]
Appends the same results as toString, but without the "StorableIndex" prefix.
[ "Appends", "the", "same", "results", "as", "toString", "but", "without", "the", "StorableIndex", "prefix", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/info/StorableIndex.java#L629-L643
8,056
michael-rapp/AndroidMaterialValidation
library/src/main/java/de/mrapp/android/validation/EditText.java
EditText.obtainMaxNumberOfCharacters
private void obtainMaxNumberOfCharacters(@NonNull final TypedArray typedArray) { setMaxNumberOfCharacters(typedArray.getInt(R.styleable.EditText_maxNumberOfCharacters, DEFAULT_MAX_NUMBER_OF_CHARACTERS)); }
java
private void obtainMaxNumberOfCharacters(@NonNull final TypedArray typedArray) { setMaxNumberOfCharacters(typedArray.getInt(R.styleable.EditText_maxNumberOfCharacters, DEFAULT_MAX_NUMBER_OF_CHARACTERS)); }
[ "private", "void", "obtainMaxNumberOfCharacters", "(", "@", "NonNull", "final", "TypedArray", "typedArray", ")", "{", "setMaxNumberOfCharacters", "(", "typedArray", ".", "getInt", "(", "R", ".", "styleable", ".", "EditText_maxNumberOfCharacters", ",", "DEFAULT_MAX_NUMBER_OF_CHARACTERS", ")", ")", ";", "}" ]
Obtains the maximum number of characters, the edit text should be allowed to contain, from a specific typed array. @param typedArray The typed array, the maximum number of characters, the edit text should be allowed to contain, should be obtained from, as an instance of the class {@link TypedArray}. The typed array may not be null
[ "Obtains", "the", "maximum", "number", "of", "characters", "the", "edit", "text", "should", "be", "allowed", "to", "contain", "from", "a", "specific", "typed", "array", "." ]
ac8693baeac7abddf2e38a47da4c1849d4661a8b
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/EditText.java#L236-L239
8,057
michael-rapp/AndroidMaterialValidation
library/src/main/java/de/mrapp/android/validation/EditText.java
EditText.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) { if (isValidatedOnValueChange()) { validate(); } adaptMaxNumberOfCharactersMessage(); } }; }
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) { if (isValidatedOnValueChange()) { validate(); } adaptMaxNumberOfCharactersMessage(); } }; }
[ "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", ")", "{", "if", "(", "isValidatedOnValueChange", "(", ")", ")", "{", "validate", "(", ")", ";", "}", "adaptMaxNumberOfCharactersMessage", "(", ")", ";", "}", "}", ";", "}" ]
Creates and returns a listener, which allows to validate the value of the view, when its text 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", "validate", "the", "value", "of", "the", "view", "when", "its", "text", "has", "been", "changed", "." ]
ac8693baeac7abddf2e38a47da4c1849d4661a8b
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/EditText.java#L467-L492
8,058
michael-rapp/AndroidMaterialValidation
library/src/main/java/de/mrapp/android/validation/EditText.java
EditText.getMaxNumberOfCharactersMessage
private CharSequence getMaxNumberOfCharactersMessage() { int maxLength = getMaxNumberOfCharacters(); int currentLength = getView().length(); return String .format(getResources().getString(R.string.edit_text_size_violation_error_message), currentLength, maxLength); }
java
private CharSequence getMaxNumberOfCharactersMessage() { int maxLength = getMaxNumberOfCharacters(); int currentLength = getView().length(); return String .format(getResources().getString(R.string.edit_text_size_violation_error_message), currentLength, maxLength); }
[ "private", "CharSequence", "getMaxNumberOfCharactersMessage", "(", ")", "{", "int", "maxLength", "=", "getMaxNumberOfCharacters", "(", ")", ";", "int", "currentLength", "=", "getView", "(", ")", ".", "length", "(", ")", ";", "return", "String", ".", "format", "(", "getResources", "(", ")", ".", "getString", "(", "R", ".", "string", ".", "edit_text_size_violation_error_message", ")", ",", "currentLength", ",", "maxLength", ")", ";", "}" ]
Returns the message, which shows how many characters, in relation to the maximum number of characters, the edit text is allowed to contain, have already been entered. @return The message, which shows how many characters, in relation to the maximum number of characters, the edit text is allowed to contain, have already been typed, as an instance of the type {@link CharSequence}
[ "Returns", "the", "message", "which", "shows", "how", "many", "characters", "in", "relation", "to", "the", "maximum", "number", "of", "characters", "the", "edit", "text", "is", "allowed", "to", "contain", "have", "already", "been", "entered", "." ]
ac8693baeac7abddf2e38a47da4c1849d4661a8b
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/EditText.java#L502-L508
8,059
michael-rapp/AndroidMaterialValidation
library/src/main/java/de/mrapp/android/validation/EditText.java
EditText.setMaxNumberOfCharacters
public final void setMaxNumberOfCharacters(final int maxNumberOfCharacters) { if (maxNumberOfCharacters != -1) { Condition.INSTANCE.ensureAtLeast(maxNumberOfCharacters, 1, "The maximum number of characters must be at least 1"); } this.maxNumberOfCharacters = maxNumberOfCharacters; adaptMaxNumberOfCharactersMessage(); }
java
public final void setMaxNumberOfCharacters(final int maxNumberOfCharacters) { if (maxNumberOfCharacters != -1) { Condition.INSTANCE.ensureAtLeast(maxNumberOfCharacters, 1, "The maximum number of characters must be at least 1"); } this.maxNumberOfCharacters = maxNumberOfCharacters; adaptMaxNumberOfCharactersMessage(); }
[ "public", "final", "void", "setMaxNumberOfCharacters", "(", "final", "int", "maxNumberOfCharacters", ")", "{", "if", "(", "maxNumberOfCharacters", "!=", "-", "1", ")", "{", "Condition", ".", "INSTANCE", ".", "ensureAtLeast", "(", "maxNumberOfCharacters", ",", "1", ",", "\"The maximum number of characters must be at least 1\"", ")", ";", "}", "this", ".", "maxNumberOfCharacters", "=", "maxNumberOfCharacters", ";", "adaptMaxNumberOfCharactersMessage", "(", ")", ";", "}" ]
Sets the maximum number of characters, the edit text should be allowed to contain. @param maxNumberOfCharacters The maximum number of characters, which should be set, as an {@link Integer} value. The maximum number of characters must be at least 1 or -1, if the number of characters should not be restricted
[ "Sets", "the", "maximum", "number", "of", "characters", "the", "edit", "text", "should", "be", "allowed", "to", "contain", "." ]
ac8693baeac7abddf2e38a47da4c1849d4661a8b
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/EditText.java#L653-L661
8,060
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceAccess.java
SyntheticStorableReferenceAccess.copyToMasterPrimaryKey
public void copyToMasterPrimaryKey(Storable reference, S master) throws FetchException { try { mCopyToMasterPkMethod.invoke(reference, master); } catch (Exception e) { ThrowUnchecked.fireFirstDeclaredCause(e, FetchException.class); } }
java
public void copyToMasterPrimaryKey(Storable reference, S master) throws FetchException { try { mCopyToMasterPkMethod.invoke(reference, master); } catch (Exception e) { ThrowUnchecked.fireFirstDeclaredCause(e, FetchException.class); } }
[ "public", "void", "copyToMasterPrimaryKey", "(", "Storable", "reference", ",", "S", "master", ")", "throws", "FetchException", "{", "try", "{", "mCopyToMasterPkMethod", ".", "invoke", "(", "reference", ",", "master", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "ThrowUnchecked", ".", "fireFirstDeclaredCause", "(", "e", ",", "FetchException", ".", "class", ")", ";", "}", "}" ]
Sets all the primary key properties of the given master, using the applicable properties of the given reference. @param reference source of property values @param master master whose primary key properties will be set
[ "Sets", "all", "the", "primary", "key", "properties", "of", "the", "given", "master", "using", "the", "applicable", "properties", "of", "the", "given", "reference", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceAccess.java#L113-L119
8,061
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceAccess.java
SyntheticStorableReferenceAccess.copyFromMaster
public void copyFromMaster(Storable reference, S master) throws FetchException { try { mCopyFromMasterMethod.invoke(reference, master); } catch (Exception e) { ThrowUnchecked.fireFirstDeclaredCause(e, FetchException.class); } }
java
public void copyFromMaster(Storable reference, S master) throws FetchException { try { mCopyFromMasterMethod.invoke(reference, master); } catch (Exception e) { ThrowUnchecked.fireFirstDeclaredCause(e, FetchException.class); } }
[ "public", "void", "copyFromMaster", "(", "Storable", "reference", ",", "S", "master", ")", "throws", "FetchException", "{", "try", "{", "mCopyFromMasterMethod", ".", "invoke", "(", "reference", ",", "master", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "ThrowUnchecked", ".", "fireFirstDeclaredCause", "(", "e", ",", "FetchException", ".", "class", ")", ";", "}", "}" ]
Sets all the properties of the given reference, using the applicable properties of the given master. @param reference reference whose properties will be set @param master source of property values
[ "Sets", "all", "the", "properties", "of", "the", "given", "reference", "using", "the", "applicable", "properties", "of", "the", "given", "master", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceAccess.java#L128-L134
8,062
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceAccess.java
SyntheticStorableReferenceAccess.isConsistent
public boolean isConsistent(Storable reference, S master) throws FetchException { try { return (Boolean) mIsConsistentMethod.invoke(reference, master); } catch (Exception e) { ThrowUnchecked.fireFirstDeclaredCause(e, FetchException.class); // Not reached. return false; } }
java
public boolean isConsistent(Storable reference, S master) throws FetchException { try { return (Boolean) mIsConsistentMethod.invoke(reference, master); } catch (Exception e) { ThrowUnchecked.fireFirstDeclaredCause(e, FetchException.class); // Not reached. return false; } }
[ "public", "boolean", "isConsistent", "(", "Storable", "reference", ",", "S", "master", ")", "throws", "FetchException", "{", "try", "{", "return", "(", "Boolean", ")", "mIsConsistentMethod", ".", "invoke", "(", "reference", ",", "master", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "ThrowUnchecked", ".", "fireFirstDeclaredCause", "(", "e", ",", "FetchException", ".", "class", ")", ";", "// Not reached.\r", "return", "false", ";", "}", "}" ]
Returns true if the properties of the given reference match those contained in the master, excluding any version property. This will always return true after a call to copyFromMaster. @param reference reference whose properties will be tested @param master source of property values
[ "Returns", "true", "if", "the", "properties", "of", "the", "given", "reference", "match", "those", "contained", "in", "the", "master", "excluding", "any", "version", "property", ".", "This", "will", "always", "return", "true", "after", "a", "call", "to", "copyFromMaster", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceAccess.java#L144-L152
8,063
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/info/OrderedProperty.java
OrderedProperty.parse
public static <S extends Storable> OrderedProperty<S> parse(StorableInfo<S> info, String str) throws IllegalArgumentException { return parse(info, str, Direction.ASCENDING); }
java
public static <S extends Storable> OrderedProperty<S> parse(StorableInfo<S> info, String str) throws IllegalArgumentException { return parse(info, str, Direction.ASCENDING); }
[ "public", "static", "<", "S", "extends", "Storable", ">", "OrderedProperty", "<", "S", ">", "parse", "(", "StorableInfo", "<", "S", ">", "info", ",", "String", "str", ")", "throws", "IllegalArgumentException", "{", "return", "parse", "(", "info", ",", "str", ",", "Direction", ".", "ASCENDING", ")", ";", "}" ]
Parses an ordering property, which may start with a '+' or '-' to indicate direction. Prefix of '~' indicates unspecified direction. If ordering prefix not specified, default direction is ascending. @param info Info for Storable type containing property @param str string to parse @throws IllegalArgumentException if any required parameter is null or string format is incorrect
[ "Parses", "an", "ordering", "property", "which", "may", "start", "with", "a", "+", "or", "-", "to", "indicate", "direction", ".", "Prefix", "of", "~", "indicates", "unspecified", "direction", ".", "If", "ordering", "prefix", "not", "specified", "default", "direction", "is", "ascending", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/info/OrderedProperty.java#L70-L75
8,064
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/info/OrderedProperty.java
OrderedProperty.parse
public static <S extends Storable> OrderedProperty<S> parse(StorableInfo<S> info, String str, Direction defaultDirection) throws IllegalArgumentException { if (info == null || str == null || defaultDirection == null) { throw new IllegalArgumentException(); } Direction direction = defaultDirection; if (str.length() > 0) { if (str.charAt(0) == '+') { direction = Direction.ASCENDING; str = str.substring(1); } else if (str.charAt(0) == '-') { direction = Direction.DESCENDING; str = str.substring(1); } else if (str.charAt(0) == '~') { direction = Direction.UNSPECIFIED; str = str.substring(1); } } if (direction == null) { direction = Direction.ASCENDING; } return get(ChainedProperty.parse(info, str), direction); }
java
public static <S extends Storable> OrderedProperty<S> parse(StorableInfo<S> info, String str, Direction defaultDirection) throws IllegalArgumentException { if (info == null || str == null || defaultDirection == null) { throw new IllegalArgumentException(); } Direction direction = defaultDirection; if (str.length() > 0) { if (str.charAt(0) == '+') { direction = Direction.ASCENDING; str = str.substring(1); } else if (str.charAt(0) == '-') { direction = Direction.DESCENDING; str = str.substring(1); } else if (str.charAt(0) == '~') { direction = Direction.UNSPECIFIED; str = str.substring(1); } } if (direction == null) { direction = Direction.ASCENDING; } return get(ChainedProperty.parse(info, str), direction); }
[ "public", "static", "<", "S", "extends", "Storable", ">", "OrderedProperty", "<", "S", ">", "parse", "(", "StorableInfo", "<", "S", ">", "info", ",", "String", "str", ",", "Direction", "defaultDirection", ")", "throws", "IllegalArgumentException", "{", "if", "(", "info", "==", "null", "||", "str", "==", "null", "||", "defaultDirection", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", ")", ";", "}", "Direction", "direction", "=", "defaultDirection", ";", "if", "(", "str", ".", "length", "(", ")", ">", "0", ")", "{", "if", "(", "str", ".", "charAt", "(", "0", ")", "==", "'", "'", ")", "{", "direction", "=", "Direction", ".", "ASCENDING", ";", "str", "=", "str", ".", "substring", "(", "1", ")", ";", "}", "else", "if", "(", "str", ".", "charAt", "(", "0", ")", "==", "'", "'", ")", "{", "direction", "=", "Direction", ".", "DESCENDING", ";", "str", "=", "str", ".", "substring", "(", "1", ")", ";", "}", "else", "if", "(", "str", ".", "charAt", "(", "0", ")", "==", "'", "'", ")", "{", "direction", "=", "Direction", ".", "UNSPECIFIED", ";", "str", "=", "str", ".", "substring", "(", "1", ")", ";", "}", "}", "if", "(", "direction", "==", "null", ")", "{", "direction", "=", "Direction", ".", "ASCENDING", ";", "}", "return", "get", "(", "ChainedProperty", ".", "parse", "(", "info", ",", "str", ")", ",", "direction", ")", ";", "}" ]
Parses an ordering property, which may start with a '+' or '-' to indicate direction. Prefix of '~' indicates unspecified direction. @param info Info for Storable type containing property @param str string to parse @param defaultDirection default direction if not specified in string. If null, ascending order is defaulted. @throws IllegalArgumentException if any required parameter is null or string format is incorrect
[ "Parses", "an", "ordering", "property", "which", "may", "start", "with", "a", "+", "or", "-", "to", "indicate", "direction", ".", "Prefix", "of", "~", "indicates", "unspecified", "direction", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/info/OrderedProperty.java#L88-L113
8,065
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/synthetic/SyntheticProperty.java
SyntheticProperty.addAccessorAnnotationDescriptor
public void addAccessorAnnotationDescriptor(String annotationDesc) { if (mAnnotationDescs == null) { mAnnotationDescs = new ArrayList<String>(4); } mAnnotationDescs.add(annotationDesc); }
java
public void addAccessorAnnotationDescriptor(String annotationDesc) { if (mAnnotationDescs == null) { mAnnotationDescs = new ArrayList<String>(4); } mAnnotationDescs.add(annotationDesc); }
[ "public", "void", "addAccessorAnnotationDescriptor", "(", "String", "annotationDesc", ")", "{", "if", "(", "mAnnotationDescs", "==", "null", ")", "{", "mAnnotationDescs", "=", "new", "ArrayList", "<", "String", ">", "(", "4", ")", ";", "}", "mAnnotationDescs", ".", "add", "(", "annotationDesc", ")", ";", "}" ]
Add an arbitrary annotation to the property accessor method, as specified by a descriptor. @see com.amazon.carbonado.util.AnnotationDescPrinter
[ "Add", "an", "arbitrary", "annotation", "to", "the", "property", "accessor", "method", "as", "specified", "by", "a", "descriptor", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/synthetic/SyntheticProperty.java#L193-L198
8,066
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/synthetic/SyntheticProperty.java
SyntheticProperty.getAccessorAnnotationDescriptors
public List<String> getAccessorAnnotationDescriptors() { if (mAnnotationDescs == null) { return Collections.emptyList(); } return Collections.unmodifiableList(mAnnotationDescs); }
java
public List<String> getAccessorAnnotationDescriptors() { if (mAnnotationDescs == null) { return Collections.emptyList(); } return Collections.unmodifiableList(mAnnotationDescs); }
[ "public", "List", "<", "String", ">", "getAccessorAnnotationDescriptors", "(", ")", "{", "if", "(", "mAnnotationDescs", "==", "null", ")", "{", "return", "Collections", ".", "emptyList", "(", ")", ";", "}", "return", "Collections", ".", "unmodifiableList", "(", "mAnnotationDescs", ")", ";", "}" ]
Returns all the added accessor annotation descriptors in an unmodifiable list.
[ "Returns", "all", "the", "added", "accessor", "annotation", "descriptors", "in", "an", "unmodifiable", "list", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/synthetic/SyntheticProperty.java#L203-L208
8,067
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/txn/TransactionManager.java
TransactionManager.localScope
public TransactionScope<Txn> localScope() { TransactionScope<Txn> scope = mLocalScope.get(); if (scope == null) { int state; synchronized (this) { state = mState; scope = new TransactionScope<Txn>(this, state != OPEN); mAllScopes.put(scope, null); } mLocalScope.set(scope); if (state == SUSPENDED) { // Immediately suspend new scope. scope.getLock().lock(); } } return scope; }
java
public TransactionScope<Txn> localScope() { TransactionScope<Txn> scope = mLocalScope.get(); if (scope == null) { int state; synchronized (this) { state = mState; scope = new TransactionScope<Txn>(this, state != OPEN); mAllScopes.put(scope, null); } mLocalScope.set(scope); if (state == SUSPENDED) { // Immediately suspend new scope. scope.getLock().lock(); } } return scope; }
[ "public", "TransactionScope", "<", "Txn", ">", "localScope", "(", ")", "{", "TransactionScope", "<", "Txn", ">", "scope", "=", "mLocalScope", ".", "get", "(", ")", ";", "if", "(", "scope", "==", "null", ")", "{", "int", "state", ";", "synchronized", "(", "this", ")", "{", "state", "=", "mState", ";", "scope", "=", "new", "TransactionScope", "<", "Txn", ">", "(", "this", ",", "state", "!=", "OPEN", ")", ";", "mAllScopes", ".", "put", "(", "scope", ",", "null", ")", ";", "}", "mLocalScope", ".", "set", "(", "scope", ")", ";", "if", "(", "state", "==", "SUSPENDED", ")", "{", "// Immediately suspend new scope.\r", "scope", ".", "getLock", "(", ")", ".", "lock", "(", ")", ";", "}", "}", "return", "scope", ";", "}" ]
Returns the thread-local TransactionScope, creating it if needed.
[ "Returns", "the", "thread", "-", "local", "TransactionScope", "creating", "it", "if", "needed", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/txn/TransactionManager.java#L59-L75
8,068
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/txn/TransactionManager.java
TransactionManager.close
public synchronized void close(boolean suspend) throws RepositoryException { if (mState == SUSPENDED) { // If suspended, attempting to close again will likely deadlock. return; } if (suspend) { for (TransactionScope<?> scope : mAllScopes.keySet()) { // Lock scope but don't release it. This prevents other threads // from beginning work during shutdown, which will likely fail // along the way. scope.getLock().lock(); } } mState = suspend ? SUSPENDED : CLOSED; for (TransactionScope<?> scope : mAllScopes.keySet()) { scope.close(); } mAllScopes.clear(); mLocalScope.remove(); }
java
public synchronized void close(boolean suspend) throws RepositoryException { if (mState == SUSPENDED) { // If suspended, attempting to close again will likely deadlock. return; } if (suspend) { for (TransactionScope<?> scope : mAllScopes.keySet()) { // Lock scope but don't release it. This prevents other threads // from beginning work during shutdown, which will likely fail // along the way. scope.getLock().lock(); } } mState = suspend ? SUSPENDED : CLOSED; for (TransactionScope<?> scope : mAllScopes.keySet()) { scope.close(); } mAllScopes.clear(); mLocalScope.remove(); }
[ "public", "synchronized", "void", "close", "(", "boolean", "suspend", ")", "throws", "RepositoryException", "{", "if", "(", "mState", "==", "SUSPENDED", ")", "{", "// If suspended, attempting to close again will likely deadlock.\r", "return", ";", "}", "if", "(", "suspend", ")", "{", "for", "(", "TransactionScope", "<", "?", ">", "scope", ":", "mAllScopes", ".", "keySet", "(", ")", ")", "{", "// Lock scope but don't release it. This prevents other threads\r", "// from beginning work during shutdown, which will likely fail\r", "// along the way.\r", "scope", ".", "getLock", "(", ")", ".", "lock", "(", ")", ";", "}", "}", "mState", "=", "suspend", "?", "SUSPENDED", ":", "CLOSED", ";", "for", "(", "TransactionScope", "<", "?", ">", "scope", ":", "mAllScopes", ".", "keySet", "(", ")", ")", "{", "scope", ".", "close", "(", ")", ";", "}", "mAllScopes", ".", "clear", "(", ")", ";", "mLocalScope", ".", "remove", "(", ")", ";", "}" ]
Closes all transaction scopes. Should be called only when repository is closed. @param suspend when true, indefinitely suspend all threads interacting with transactions
[ "Closes", "all", "transaction", "scopes", ".", "Should", "be", "called", "only", "when", "repository", "is", "closed", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/txn/TransactionManager.java#L140-L163
8,069
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java
JDBCStorableIntrospector.examine
@SuppressWarnings("unchecked") public static <S extends Storable> JDBCStorableInfo<S> examine (Class<S> type, DataSource ds, String catalog, String schema) throws SQLException, SupportException { return examine(type, ds, catalog, schema, null, false); }
java
@SuppressWarnings("unchecked") public static <S extends Storable> JDBCStorableInfo<S> examine (Class<S> type, DataSource ds, String catalog, String schema) throws SQLException, SupportException { return examine(type, ds, catalog, schema, null, false); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "S", "extends", "Storable", ">", "JDBCStorableInfo", "<", "S", ">", "examine", "(", "Class", "<", "S", ">", "type", ",", "DataSource", "ds", ",", "String", "catalog", ",", "String", "schema", ")", "throws", "SQLException", ",", "SupportException", "{", "return", "examine", "(", "type", ",", "ds", ",", "catalog", ",", "schema", ",", "null", ",", "false", ")", ";", "}" ]
Examines the given class and returns a JDBCStorableInfo describing it. A MalformedTypeException is thrown for a variety of reasons if the given class is not a well-defined Storable type or if it can't match up with an entity in the external database. @param type Storable type to examine @param ds source of JDBC connections to use for matching to a table @param catalog optional catalog to search @param schema optional schema to search @throws MalformedTypeException if Storable type is not well-formed @throws RepositoryException if there was a problem in accessing the database @throws IllegalArgumentException if type is null
[ "Examines", "the", "given", "class", "and", "returns", "a", "JDBCStorableInfo", "describing", "it", ".", "A", "MalformedTypeException", "is", "thrown", "for", "a", "variety", "of", "reasons", "if", "the", "given", "class", "is", "not", "a", "well", "-", "defined", "Storable", "type", "or", "if", "it", "can", "t", "match", "up", "with", "an", "entity", "in", "the", "external", "database", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java#L102-L108
8,070
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java
JDBCStorableIntrospector.getAccessInfo
private static AccessInfo getAccessInfo (StorableProperty property, int dataType, String dataTypeName, int columnSize, int decimalDigits) { AccessInfo info = getAccessInfo (property.getType(), dataType, dataTypeName, columnSize, decimalDigits); if (info != null) { return info; } // Dynamically typed data sources (e.g. SQLite3) always report // dataType as java.sql.Types.VARCHAR. Infer the dataType from the // dataTypeName and try again. if (dataType == java.sql.Types.VARCHAR) { Integer dataTypeMapping = typeNameToDataTypeMapping.get(dataTypeName.toUpperCase()); if (dataTypeMapping != null) { info = getAccessInfo (property.getType(), dataTypeMapping, dataTypeName, columnSize, decimalDigits); if (info != null) { return info; } } } // See if an appropriate adapter exists. StorablePropertyAdapter adapter = property.getAdapter(); if (adapter != null) { Method[] toMethods = adapter.findAdaptMethodsTo(property.getType()); for (Method toMethod : toMethods) { Class fromType = toMethod.getParameterTypes()[0]; // Verify that reverse adapt method exists as well... if (adapter.findAdaptMethod(property.getType(), fromType) != null) { // ...and try to get access info for fromType. info = getAccessInfo (fromType, dataType, dataTypeName, columnSize, decimalDigits); if (info != null) { info.setAdapter(adapter); return info; } } } } return null; }
java
private static AccessInfo getAccessInfo (StorableProperty property, int dataType, String dataTypeName, int columnSize, int decimalDigits) { AccessInfo info = getAccessInfo (property.getType(), dataType, dataTypeName, columnSize, decimalDigits); if (info != null) { return info; } // Dynamically typed data sources (e.g. SQLite3) always report // dataType as java.sql.Types.VARCHAR. Infer the dataType from the // dataTypeName and try again. if (dataType == java.sql.Types.VARCHAR) { Integer dataTypeMapping = typeNameToDataTypeMapping.get(dataTypeName.toUpperCase()); if (dataTypeMapping != null) { info = getAccessInfo (property.getType(), dataTypeMapping, dataTypeName, columnSize, decimalDigits); if (info != null) { return info; } } } // See if an appropriate adapter exists. StorablePropertyAdapter adapter = property.getAdapter(); if (adapter != null) { Method[] toMethods = adapter.findAdaptMethodsTo(property.getType()); for (Method toMethod : toMethods) { Class fromType = toMethod.getParameterTypes()[0]; // Verify that reverse adapt method exists as well... if (adapter.findAdaptMethod(property.getType(), fromType) != null) { // ...and try to get access info for fromType. info = getAccessInfo (fromType, dataType, dataTypeName, columnSize, decimalDigits); if (info != null) { info.setAdapter(adapter); return info; } } } } return null; }
[ "private", "static", "AccessInfo", "getAccessInfo", "(", "StorableProperty", "property", ",", "int", "dataType", ",", "String", "dataTypeName", ",", "int", "columnSize", ",", "int", "decimalDigits", ")", "{", "AccessInfo", "info", "=", "getAccessInfo", "(", "property", ".", "getType", "(", ")", ",", "dataType", ",", "dataTypeName", ",", "columnSize", ",", "decimalDigits", ")", ";", "if", "(", "info", "!=", "null", ")", "{", "return", "info", ";", "}", "// Dynamically typed data sources (e.g. SQLite3) always report \r", "// dataType as java.sql.Types.VARCHAR. Infer the dataType from the \r", "// dataTypeName and try again.\r", "if", "(", "dataType", "==", "java", ".", "sql", ".", "Types", ".", "VARCHAR", ")", "{", "Integer", "dataTypeMapping", "=", "typeNameToDataTypeMapping", ".", "get", "(", "dataTypeName", ".", "toUpperCase", "(", ")", ")", ";", "if", "(", "dataTypeMapping", "!=", "null", ")", "{", "info", "=", "getAccessInfo", "(", "property", ".", "getType", "(", ")", ",", "dataTypeMapping", ",", "dataTypeName", ",", "columnSize", ",", "decimalDigits", ")", ";", "if", "(", "info", "!=", "null", ")", "{", "return", "info", ";", "}", "}", "}", "// See if an appropriate adapter exists.\r", "StorablePropertyAdapter", "adapter", "=", "property", ".", "getAdapter", "(", ")", ";", "if", "(", "adapter", "!=", "null", ")", "{", "Method", "[", "]", "toMethods", "=", "adapter", ".", "findAdaptMethodsTo", "(", "property", ".", "getType", "(", ")", ")", ";", "for", "(", "Method", "toMethod", ":", "toMethods", ")", "{", "Class", "fromType", "=", "toMethod", ".", "getParameterTypes", "(", ")", "[", "0", "]", ";", "// Verify that reverse adapt method exists as well...\r", "if", "(", "adapter", ".", "findAdaptMethod", "(", "property", ".", "getType", "(", ")", ",", "fromType", ")", "!=", "null", ")", "{", "// ...and try to get access info for fromType.\r", "info", "=", "getAccessInfo", "(", "fromType", ",", "dataType", ",", "dataTypeName", ",", "columnSize", ",", "decimalDigits", ")", ";", "if", "(", "info", "!=", "null", ")", "{", "info", ".", "setAdapter", "(", "adapter", ")", ";", "return", "info", ";", "}", "}", "}", "}", "return", "null", ";", "}" ]
Figures out how to best access the given property, or returns null if not supported. An adapter may be applied. @return null if not supported
[ "Figures", "out", "how", "to", "best", "access", "the", "given", "property", "or", "returns", "null", "if", "not", "supported", ".", "An", "adapter", "may", "be", "applied", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java#L592-L636
8,071
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java
JDBCStorableIntrospector.appendToSentence
private static void appendToSentence(StringBuilder buf, String[] names) { for (int i=0; i<names.length; i++) { if (i > 0) { if (i + 1 >= names.length) { buf.append(" or "); } else { buf.append(", "); } } buf.append('"'); buf.append(names[i]); buf.append('"'); } }
java
private static void appendToSentence(StringBuilder buf, String[] names) { for (int i=0; i<names.length; i++) { if (i > 0) { if (i + 1 >= names.length) { buf.append(" or "); } else { buf.append(", "); } } buf.append('"'); buf.append(names[i]); buf.append('"'); } }
[ "private", "static", "void", "appendToSentence", "(", "StringBuilder", "buf", ",", "String", "[", "]", "names", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "names", ".", "length", ";", "i", "++", ")", "{", "if", "(", "i", ">", "0", ")", "{", "if", "(", "i", "+", "1", ">=", "names", ".", "length", ")", "{", "buf", ".", "append", "(", "\" or \"", ")", ";", "}", "else", "{", "buf", ".", "append", "(", "\", \"", ")", ";", "}", "}", "buf", ".", "append", "(", "'", "'", ")", ";", "buf", ".", "append", "(", "names", "[", "i", "]", ")", ";", "buf", ".", "append", "(", "'", "'", ")", ";", "}", "}" ]
Appends words to a sentence as an "or" list.
[ "Appends", "words", "to", "a", "sentence", "as", "an", "or", "list", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java#L878-L891
8,072
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java
JDBCStorableIntrospector.generateAliases
static String[] generateAliases(String base) { int length = base.length(); if (length <= 1) { return new String[]{base.toUpperCase(), base.toLowerCase()}; } ArrayList<String> aliases = new ArrayList<String>(4); StringBuilder buf = new StringBuilder(); int i; for (i=0; i<length; ) { char c = base.charAt(i++); if (c == '_' || !Character.isJavaIdentifierPart(c)) { // Keep scanning for first letter. buf.append(c); } else { buf.append(Character.toUpperCase(c)); break; } } boolean canSeparate = false; boolean appendedIdentifierPart = false; for (; i<length; i++) { char c = base.charAt(i); if (c == '_' || !Character.isJavaIdentifierPart(c)) { canSeparate = false; appendedIdentifierPart = false; } else if (Character.isLowerCase(c)) { canSeparate = true; appendedIdentifierPart = true; } else { if (appendedIdentifierPart && i + 1 < length && Character.isLowerCase(base.charAt(i + 1))) { canSeparate = true; } if (canSeparate) { buf.append('_'); } canSeparate = false; appendedIdentifierPart = true; } buf.append(c); } String derived = buf.toString(); addToSet(aliases, derived.toUpperCase()); addToSet(aliases, derived.toLowerCase()); addToSet(aliases, derived); addToSet(aliases, base.toUpperCase()); addToSet(aliases, base.toLowerCase()); addToSet(aliases, base); return aliases.toArray(new String[aliases.size()]); }
java
static String[] generateAliases(String base) { int length = base.length(); if (length <= 1) { return new String[]{base.toUpperCase(), base.toLowerCase()}; } ArrayList<String> aliases = new ArrayList<String>(4); StringBuilder buf = new StringBuilder(); int i; for (i=0; i<length; ) { char c = base.charAt(i++); if (c == '_' || !Character.isJavaIdentifierPart(c)) { // Keep scanning for first letter. buf.append(c); } else { buf.append(Character.toUpperCase(c)); break; } } boolean canSeparate = false; boolean appendedIdentifierPart = false; for (; i<length; i++) { char c = base.charAt(i); if (c == '_' || !Character.isJavaIdentifierPart(c)) { canSeparate = false; appendedIdentifierPart = false; } else if (Character.isLowerCase(c)) { canSeparate = true; appendedIdentifierPart = true; } else { if (appendedIdentifierPart && i + 1 < length && Character.isLowerCase(base.charAt(i + 1))) { canSeparate = true; } if (canSeparate) { buf.append('_'); } canSeparate = false; appendedIdentifierPart = true; } buf.append(c); } String derived = buf.toString(); addToSet(aliases, derived.toUpperCase()); addToSet(aliases, derived.toLowerCase()); addToSet(aliases, derived); addToSet(aliases, base.toUpperCase()); addToSet(aliases, base.toLowerCase()); addToSet(aliases, base); return aliases.toArray(new String[aliases.size()]); }
[ "static", "String", "[", "]", "generateAliases", "(", "String", "base", ")", "{", "int", "length", "=", "base", ".", "length", "(", ")", ";", "if", "(", "length", "<=", "1", ")", "{", "return", "new", "String", "[", "]", "{", "base", ".", "toUpperCase", "(", ")", ",", "base", ".", "toLowerCase", "(", ")", "}", ";", "}", "ArrayList", "<", "String", ">", "aliases", "=", "new", "ArrayList", "<", "String", ">", "(", "4", ")", ";", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", ")", ";", "int", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "length", ";", ")", "{", "char", "c", "=", "base", ".", "charAt", "(", "i", "++", ")", ";", "if", "(", "c", "==", "'", "'", "||", "!", "Character", ".", "isJavaIdentifierPart", "(", "c", ")", ")", "{", "// Keep scanning for first letter.\r", "buf", ".", "append", "(", "c", ")", ";", "}", "else", "{", "buf", ".", "append", "(", "Character", ".", "toUpperCase", "(", "c", ")", ")", ";", "break", ";", "}", "}", "boolean", "canSeparate", "=", "false", ";", "boolean", "appendedIdentifierPart", "=", "false", ";", "for", "(", ";", "i", "<", "length", ";", "i", "++", ")", "{", "char", "c", "=", "base", ".", "charAt", "(", "i", ")", ";", "if", "(", "c", "==", "'", "'", "||", "!", "Character", ".", "isJavaIdentifierPart", "(", "c", ")", ")", "{", "canSeparate", "=", "false", ";", "appendedIdentifierPart", "=", "false", ";", "}", "else", "if", "(", "Character", ".", "isLowerCase", "(", "c", ")", ")", "{", "canSeparate", "=", "true", ";", "appendedIdentifierPart", "=", "true", ";", "}", "else", "{", "if", "(", "appendedIdentifierPart", "&&", "i", "+", "1", "<", "length", "&&", "Character", ".", "isLowerCase", "(", "base", ".", "charAt", "(", "i", "+", "1", ")", ")", ")", "{", "canSeparate", "=", "true", ";", "}", "if", "(", "canSeparate", ")", "{", "buf", ".", "append", "(", "'", "'", ")", ";", "}", "canSeparate", "=", "false", ";", "appendedIdentifierPart", "=", "true", ";", "}", "buf", ".", "append", "(", "c", ")", ";", "}", "String", "derived", "=", "buf", ".", "toString", "(", ")", ";", "addToSet", "(", "aliases", ",", "derived", ".", "toUpperCase", "(", ")", ")", ";", "addToSet", "(", "aliases", ",", "derived", ".", "toLowerCase", "(", ")", ")", ";", "addToSet", "(", "aliases", ",", "derived", ")", ";", "addToSet", "(", "aliases", ",", "base", ".", "toUpperCase", "(", ")", ")", ";", "addToSet", "(", "aliases", ",", "base", ".", "toLowerCase", "(", ")", ")", ";", "addToSet", "(", "aliases", ",", "base", ")", ";", "return", "aliases", ".", "toArray", "(", "new", "String", "[", "aliases", ".", "size", "(", ")", "]", ")", ";", "}" ]
Generates aliases for the given name, converting camel case form into various underscore forms.
[ "Generates", "aliases", "for", "the", "given", "name", "converting", "camel", "case", "form", "into", "various", "underscore", "forms", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java#L897-L954
8,073
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/qe/QueryHints.java
QueryHints.with
public QueryHints with(QueryHint hint, Object value) { if (hint == null) { throw new IllegalArgumentException("Null hint"); } if (value == null) { throw new IllegalArgumentException("Null value"); } EnumMap<QueryHint, Object> map; if (mMap == null) { map = new EnumMap<QueryHint, Object>(QueryHint.class); } else { map = mMap.clone(); } map.put(hint, value); return new QueryHints(map); }
java
public QueryHints with(QueryHint hint, Object value) { if (hint == null) { throw new IllegalArgumentException("Null hint"); } if (value == null) { throw new IllegalArgumentException("Null value"); } EnumMap<QueryHint, Object> map; if (mMap == null) { map = new EnumMap<QueryHint, Object>(QueryHint.class); } else { map = mMap.clone(); } map.put(hint, value); return new QueryHints(map); }
[ "public", "QueryHints", "with", "(", "QueryHint", "hint", ",", "Object", "value", ")", "{", "if", "(", "hint", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Null hint\"", ")", ";", "}", "if", "(", "value", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Null value\"", ")", ";", "}", "EnumMap", "<", "QueryHint", ",", "Object", ">", "map", ";", "if", "(", "mMap", "==", "null", ")", "{", "map", "=", "new", "EnumMap", "<", "QueryHint", ",", "Object", ">", "(", "QueryHint", ".", "class", ")", ";", "}", "else", "{", "map", "=", "mMap", ".", "clone", "(", ")", ";", "}", "map", ".", "put", "(", "hint", ",", "value", ")", ";", "return", "new", "QueryHints", "(", "map", ")", ";", "}" ]
Returns a new QueryHints object with the given hint and value. @throws IllegalArgumentException if hint or value is null
[ "Returns", "a", "new", "QueryHints", "object", "with", "the", "given", "hint", "and", "value", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/QueryHints.java#L59-L74
8,074
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/qe/QueryHints.java
QueryHints.without
public QueryHints without(QueryHint hint) { if (hint == null || mMap == null || !mMap.containsKey(hint)) { return this; } EnumMap<QueryHint, Object> map = mMap.clone(); map.remove(hint); if (map.size() == 0) { map = null; } return new QueryHints(map); }
java
public QueryHints without(QueryHint hint) { if (hint == null || mMap == null || !mMap.containsKey(hint)) { return this; } EnumMap<QueryHint, Object> map = mMap.clone(); map.remove(hint); if (map.size() == 0) { map = null; } return new QueryHints(map); }
[ "public", "QueryHints", "without", "(", "QueryHint", "hint", ")", "{", "if", "(", "hint", "==", "null", "||", "mMap", "==", "null", "||", "!", "mMap", ".", "containsKey", "(", "hint", ")", ")", "{", "return", "this", ";", "}", "EnumMap", "<", "QueryHint", ",", "Object", ">", "map", "=", "mMap", ".", "clone", "(", ")", ";", "map", ".", "remove", "(", "hint", ")", ";", "if", "(", "map", ".", "size", "(", ")", "==", "0", ")", "{", "map", "=", "null", ";", "}", "return", "new", "QueryHints", "(", "map", ")", ";", "}" ]
Returns a new QueryHints object without the given hint.
[ "Returns", "a", "new", "QueryHints", "object", "without", "the", "given", "hint", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/QueryHints.java#L79-L89
8,075
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/qe/QueryHints.java
QueryHints.get
public Object get(QueryHint hint) { return hint == null ? null : (mMap == null ? null : mMap.get(hint)); }
java
public Object get(QueryHint hint) { return hint == null ? null : (mMap == null ? null : mMap.get(hint)); }
[ "public", "Object", "get", "(", "QueryHint", "hint", ")", "{", "return", "hint", "==", "null", "?", "null", ":", "(", "mMap", "==", "null", "?", "null", ":", "mMap", ".", "get", "(", "hint", ")", ")", ";", "}" ]
Returns null if hint is not provided.
[ "Returns", "null", "if", "hint", "is", "not", "provided", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/QueryHints.java#L101-L103
8,076
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/RawCursor.java
RawCursor.toNext
protected int toNext(int amount) throws FetchException { if (amount <= 1) { return (amount <= 0) ? 0 : (toNext() ? 1 : 0); } int count = 0; disableKeyAndValue(); try { while (amount > 0) { if (toNext()) { count++; amount--; } else { break; } } } finally { enableKeyAndValue(); } return count; }
java
protected int toNext(int amount) throws FetchException { if (amount <= 1) { return (amount <= 0) ? 0 : (toNext() ? 1 : 0); } int count = 0; disableKeyAndValue(); try { while (amount > 0) { if (toNext()) { count++; amount--; } else { break; } } } finally { enableKeyAndValue(); } return count; }
[ "protected", "int", "toNext", "(", "int", "amount", ")", "throws", "FetchException", "{", "if", "(", "amount", "<=", "1", ")", "{", "return", "(", "amount", "<=", "0", ")", "?", "0", ":", "(", "toNext", "(", ")", "?", "1", ":", "0", ")", ";", "}", "int", "count", "=", "0", ";", "disableKeyAndValue", "(", ")", ";", "try", "{", "while", "(", "amount", ">", "0", ")", "{", "if", "(", "toNext", "(", ")", ")", "{", "count", "++", ";", "amount", "--", ";", "}", "else", "{", "break", ";", "}", "}", "}", "finally", "{", "enableKeyAndValue", "(", ")", ";", "}", "return", "count", ";", "}" ]
Move the cursor to the next available entry, incrementing by the amount given. The actual amount incremented is returned. If the amount is less then requested, the cursor must be positioned after the last available entry. Subclasses may wish to override this method with a faster implementation. <p>Calling to toNext(1) is equivalent to calling toNext(). @param amount positive amount to advance @return actual amount advanced @throws IllegalStateException if cursor is not opened
[ "Move", "the", "cursor", "to", "the", "next", "available", "entry", "incrementing", "by", "the", "amount", "given", ".", "The", "actual", "amount", "incremented", "is", "returned", ".", "If", "the", "amount", "is", "less", "then", "requested", "the", "cursor", "must", "be", "positioned", "after", "the", "last", "available", "entry", ".", "Subclasses", "may", "wish", "to", "override", "this", "method", "with", "a", "faster", "implementation", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/RawCursor.java#L353-L375
8,077
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/RawCursor.java
RawCursor.toNextKey
protected boolean toNextKey() throws FetchException { byte[] initialKey = getCurrentKey(); if (initialKey == null) { return false; } disableValue(); try { while (true) { if (toNext()) { byte[] currentKey = getCurrentKey(); if (currentKey == null) { return false; } if (compareKeysPartially(currentKey, initialKey) > 0) { break; } } else { return false; } } } finally { enableKeyAndValue(); } return true; }
java
protected boolean toNextKey() throws FetchException { byte[] initialKey = getCurrentKey(); if (initialKey == null) { return false; } disableValue(); try { while (true) { if (toNext()) { byte[] currentKey = getCurrentKey(); if (currentKey == null) { return false; } if (compareKeysPartially(currentKey, initialKey) > 0) { break; } } else { return false; } } } finally { enableKeyAndValue(); } return true; }
[ "protected", "boolean", "toNextKey", "(", ")", "throws", "FetchException", "{", "byte", "[", "]", "initialKey", "=", "getCurrentKey", "(", ")", ";", "if", "(", "initialKey", "==", "null", ")", "{", "return", "false", ";", "}", "disableValue", "(", ")", ";", "try", "{", "while", "(", "true", ")", "{", "if", "(", "toNext", "(", ")", ")", "{", "byte", "[", "]", "currentKey", "=", "getCurrentKey", "(", ")", ";", "if", "(", "currentKey", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(", "compareKeysPartially", "(", "currentKey", ",", "initialKey", ")", ">", "0", ")", "{", "break", ";", "}", "}", "else", "{", "return", "false", ";", "}", "}", "}", "finally", "{", "enableKeyAndValue", "(", ")", ";", "}", "return", "true", ";", "}" ]
Move the cursor to the next unique key, returning false if none. If false is returned, the cursor must be positioned after the last available entry. Subclasses may wish to override this method with a faster implementation. @return true if moved to next unique key @throws IllegalStateException if cursor is not opened
[ "Move", "the", "cursor", "to", "the", "next", "unique", "key", "returning", "false", "if", "none", ".", "If", "false", "is", "returned", "the", "cursor", "must", "be", "positioned", "after", "the", "last", "available", "entry", ".", "Subclasses", "may", "wish", "to", "override", "this", "method", "with", "a", "faster", "implementation", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/RawCursor.java#L386-L412
8,078
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/RawCursor.java
RawCursor.toPrevious
protected int toPrevious(int amount) throws FetchException { if (amount <= 1) { return (amount <= 0) ? 0 : (toPrevious() ? 1 : 0); } int count = 0; disableKeyAndValue(); try { while (amount > 0) { if (toPrevious()) { count++; amount--; } else { break; } } } finally { enableKeyAndValue(); } return count; }
java
protected int toPrevious(int amount) throws FetchException { if (amount <= 1) { return (amount <= 0) ? 0 : (toPrevious() ? 1 : 0); } int count = 0; disableKeyAndValue(); try { while (amount > 0) { if (toPrevious()) { count++; amount--; } else { break; } } } finally { enableKeyAndValue(); } return count; }
[ "protected", "int", "toPrevious", "(", "int", "amount", ")", "throws", "FetchException", "{", "if", "(", "amount", "<=", "1", ")", "{", "return", "(", "amount", "<=", "0", ")", "?", "0", ":", "(", "toPrevious", "(", ")", "?", "1", ":", "0", ")", ";", "}", "int", "count", "=", "0", ";", "disableKeyAndValue", "(", ")", ";", "try", "{", "while", "(", "amount", ">", "0", ")", "{", "if", "(", "toPrevious", "(", ")", ")", "{", "count", "++", ";", "amount", "--", ";", "}", "else", "{", "break", ";", "}", "}", "}", "finally", "{", "enableKeyAndValue", "(", ")", ";", "}", "return", "count", ";", "}" ]
Move the cursor to the previous available entry, decrementing by the amount given. The actual amount decremented is returned. If the amount is less then requested, the cursor must be positioned before the first available entry. Subclasses may wish to override this method with a faster implementation. <p>Calling to toPrevious(1) is equivalent to calling toPrevious(). @param amount positive amount to retreat @return actual amount retreated @throws IllegalStateException if cursor is not opened
[ "Move", "the", "cursor", "to", "the", "previous", "available", "entry", "decrementing", "by", "the", "amount", "given", ".", "The", "actual", "amount", "decremented", "is", "returned", ".", "If", "the", "amount", "is", "less", "then", "requested", "the", "cursor", "must", "be", "positioned", "before", "the", "first", "available", "entry", ".", "Subclasses", "may", "wish", "to", "override", "this", "method", "with", "a", "faster", "implementation", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/RawCursor.java#L437-L459
8,079
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/RawCursor.java
RawCursor.toPreviousKey
protected boolean toPreviousKey() throws FetchException { byte[] initialKey = getCurrentKey(); if (initialKey == null) { return false; } disableValue(); try { while (true) { if (toPrevious()) { byte[] currentKey = getCurrentKey(); if (currentKey == null) { return false; } if (compareKeysPartially(getCurrentKey(), initialKey) < 0) { break; } } else { return false; } } } finally { enableKeyAndValue(); } return true; }
java
protected boolean toPreviousKey() throws FetchException { byte[] initialKey = getCurrentKey(); if (initialKey == null) { return false; } disableValue(); try { while (true) { if (toPrevious()) { byte[] currentKey = getCurrentKey(); if (currentKey == null) { return false; } if (compareKeysPartially(getCurrentKey(), initialKey) < 0) { break; } } else { return false; } } } finally { enableKeyAndValue(); } return true; }
[ "protected", "boolean", "toPreviousKey", "(", ")", "throws", "FetchException", "{", "byte", "[", "]", "initialKey", "=", "getCurrentKey", "(", ")", ";", "if", "(", "initialKey", "==", "null", ")", "{", "return", "false", ";", "}", "disableValue", "(", ")", ";", "try", "{", "while", "(", "true", ")", "{", "if", "(", "toPrevious", "(", ")", ")", "{", "byte", "[", "]", "currentKey", "=", "getCurrentKey", "(", ")", ";", "if", "(", "currentKey", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(", "compareKeysPartially", "(", "getCurrentKey", "(", ")", ",", "initialKey", ")", "<", "0", ")", "{", "break", ";", "}", "}", "else", "{", "return", "false", ";", "}", "}", "}", "finally", "{", "enableKeyAndValue", "(", ")", ";", "}", "return", "true", ";", "}" ]
Move the cursor to the previous unique key, returning false if none. If false is returned, the cursor must be positioned before the first available entry. Subclasses may wish to override this method with a faster implementation. @return true if moved to previous unique key @throws IllegalStateException if cursor is not opened
[ "Move", "the", "cursor", "to", "the", "previous", "unique", "key", "returning", "false", "if", "none", ".", "If", "false", "is", "returned", "the", "cursor", "must", "be", "positioned", "before", "the", "first", "available", "entry", ".", "Subclasses", "may", "wish", "to", "override", "this", "method", "with", "a", "faster", "implementation", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/RawCursor.java#L470-L496
8,080
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/RawCursor.java
RawCursor.toBoundedFirst
private boolean toBoundedFirst() throws FetchException { if (mStartBound == null) { if (!toFirst()) { return false; } } else { if (!toFirst(mStartBound.clone())) { return false; } if (!mInclusiveStart) { byte[] currentKey = getCurrentKey(); if (currentKey == null) { return false; } if (compareKeysPartially(mStartBound, currentKey) == 0) { if (!toNextKey()) { return false; } } } } if (mEndBound != null) { byte[] currentKey = getCurrentKey(); if (currentKey == null) { return false; } int result = compareKeysPartially(currentKey, mEndBound); if (result >= 0) { if (result > 0 || !mInclusiveEnd) { return false; } } } return prefixMatches(); }
java
private boolean toBoundedFirst() throws FetchException { if (mStartBound == null) { if (!toFirst()) { return false; } } else { if (!toFirst(mStartBound.clone())) { return false; } if (!mInclusiveStart) { byte[] currentKey = getCurrentKey(); if (currentKey == null) { return false; } if (compareKeysPartially(mStartBound, currentKey) == 0) { if (!toNextKey()) { return false; } } } } if (mEndBound != null) { byte[] currentKey = getCurrentKey(); if (currentKey == null) { return false; } int result = compareKeysPartially(currentKey, mEndBound); if (result >= 0) { if (result > 0 || !mInclusiveEnd) { return false; } } } return prefixMatches(); }
[ "private", "boolean", "toBoundedFirst", "(", ")", "throws", "FetchException", "{", "if", "(", "mStartBound", "==", "null", ")", "{", "if", "(", "!", "toFirst", "(", ")", ")", "{", "return", "false", ";", "}", "}", "else", "{", "if", "(", "!", "toFirst", "(", "mStartBound", ".", "clone", "(", ")", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "mInclusiveStart", ")", "{", "byte", "[", "]", "currentKey", "=", "getCurrentKey", "(", ")", ";", "if", "(", "currentKey", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(", "compareKeysPartially", "(", "mStartBound", ",", "currentKey", ")", "==", "0", ")", "{", "if", "(", "!", "toNextKey", "(", ")", ")", "{", "return", "false", ";", "}", "}", "}", "}", "if", "(", "mEndBound", "!=", "null", ")", "{", "byte", "[", "]", "currentKey", "=", "getCurrentKey", "(", ")", ";", "if", "(", "currentKey", "==", "null", ")", "{", "return", "false", ";", "}", "int", "result", "=", "compareKeysPartially", "(", "currentKey", ",", "mEndBound", ")", ";", "if", "(", "result", ">=", "0", ")", "{", "if", "(", "result", ">", "0", "||", "!", "mInclusiveEnd", ")", "{", "return", "false", ";", "}", "}", "}", "return", "prefixMatches", "(", ")", ";", "}" ]
Calls toFirst, but considers start and end bounds.
[ "Calls", "toFirst", "but", "considers", "start", "and", "end", "bounds", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/RawCursor.java#L539-L575
8,081
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/raw/RawCursor.java
RawCursor.toBoundedLast
private boolean toBoundedLast() throws FetchException { if (mEndBound == null) { if (!toLast()) { return false; } } else { if (!toLast(mEndBound.clone())) { return false; } if (!mInclusiveEnd) { byte[] currentKey = getCurrentKey(); if (currentKey == null) { return false; } if (compareKeysPartially(mEndBound, currentKey) == 0) { if (!toPreviousKey()) { return false; } } } } if (mStartBound != null) { byte[] currentKey = getCurrentKey(); if (currentKey == null) { return false; } int result = compareKeysPartially(currentKey, mStartBound); if (result <= 0) { if (result < 0 || !mInclusiveStart) { return false; } } } return prefixMatches(); }
java
private boolean toBoundedLast() throws FetchException { if (mEndBound == null) { if (!toLast()) { return false; } } else { if (!toLast(mEndBound.clone())) { return false; } if (!mInclusiveEnd) { byte[] currentKey = getCurrentKey(); if (currentKey == null) { return false; } if (compareKeysPartially(mEndBound, currentKey) == 0) { if (!toPreviousKey()) { return false; } } } } if (mStartBound != null) { byte[] currentKey = getCurrentKey(); if (currentKey == null) { return false; } int result = compareKeysPartially(currentKey, mStartBound); if (result <= 0) { if (result < 0 || !mInclusiveStart) { return false; } } } return prefixMatches(); }
[ "private", "boolean", "toBoundedLast", "(", ")", "throws", "FetchException", "{", "if", "(", "mEndBound", "==", "null", ")", "{", "if", "(", "!", "toLast", "(", ")", ")", "{", "return", "false", ";", "}", "}", "else", "{", "if", "(", "!", "toLast", "(", "mEndBound", ".", "clone", "(", ")", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "mInclusiveEnd", ")", "{", "byte", "[", "]", "currentKey", "=", "getCurrentKey", "(", ")", ";", "if", "(", "currentKey", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(", "compareKeysPartially", "(", "mEndBound", ",", "currentKey", ")", "==", "0", ")", "{", "if", "(", "!", "toPreviousKey", "(", ")", ")", "{", "return", "false", ";", "}", "}", "}", "}", "if", "(", "mStartBound", "!=", "null", ")", "{", "byte", "[", "]", "currentKey", "=", "getCurrentKey", "(", ")", ";", "if", "(", "currentKey", "==", "null", ")", "{", "return", "false", ";", "}", "int", "result", "=", "compareKeysPartially", "(", "currentKey", ",", "mStartBound", ")", ";", "if", "(", "result", "<=", "0", ")", "{", "if", "(", "result", "<", "0", "||", "!", "mInclusiveStart", ")", "{", "return", "false", ";", "}", "}", "}", "return", "prefixMatches", "(", ")", ";", "}" ]
for preserving key.
[ "for", "preserving", "key", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/RawCursor.java#L579-L615
8,082
michael-rapp/AndroidMaterialValidation
library/src/main/java/de/mrapp/android/validation/Spinner.java
Spinner.obtainHintColor
private void obtainHintColor(@NonNull final TypedArray typedArray) { ColorStateList colors = typedArray.getColorStateList(R.styleable.Spinner_android_textColorHint); if (colors == null) { TypedArray styledAttributes = getContext().getTheme() .obtainStyledAttributes(new int[]{android.R.attr.textColorSecondary}); colors = ColorStateList.valueOf(styledAttributes.getColor(0, 0)); } setHintTextColor(colors); }
java
private void obtainHintColor(@NonNull final TypedArray typedArray) { ColorStateList colors = typedArray.getColorStateList(R.styleable.Spinner_android_textColorHint); if (colors == null) { TypedArray styledAttributes = getContext().getTheme() .obtainStyledAttributes(new int[]{android.R.attr.textColorSecondary}); colors = ColorStateList.valueOf(styledAttributes.getColor(0, 0)); } setHintTextColor(colors); }
[ "private", "void", "obtainHintColor", "(", "@", "NonNull", "final", "TypedArray", "typedArray", ")", "{", "ColorStateList", "colors", "=", "typedArray", ".", "getColorStateList", "(", "R", ".", "styleable", ".", "Spinner_android_textColorHint", ")", ";", "if", "(", "colors", "==", "null", ")", "{", "TypedArray", "styledAttributes", "=", "getContext", "(", ")", ".", "getTheme", "(", ")", ".", "obtainStyledAttributes", "(", "new", "int", "[", "]", "{", "android", ".", "R", ".", "attr", ".", "textColorSecondary", "}", ")", ";", "colors", "=", "ColorStateList", ".", "valueOf", "(", "styledAttributes", ".", "getColor", "(", "0", ",", "0", ")", ")", ";", "}", "setHintTextColor", "(", "colors", ")", ";", "}" ]
Obtains the color of the hint, which should be shown, when no item is selected, from a specific typed array. @param typedArray The typed array, the hint should be obtained from, as an instance of the class {@link TypedArray}. The typed array may not be null
[ "Obtains", "the", "color", "of", "the", "hint", "which", "should", "be", "shown", "when", "no", "item", "is", "selected", "from", "a", "specific", "typed", "array", "." ]
ac8693baeac7abddf2e38a47da4c1849d4661a8b
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/Spinner.java#L203-L214
8,083
michael-rapp/AndroidMaterialValidation
library/src/main/java/de/mrapp/android/validation/Spinner.java
Spinner.createItemSelectedListener
private OnItemSelectedListener createItemSelectedListener() { return new OnItemSelectedListener() { @Override public void onItemSelected(final AdapterView<?> parent, final View view, final int position, final long id) { if (getOnItemSelectedListener() != null) { getOnItemSelectedListener().onItemSelected(parent, view, position, id); } if (isValidatedOnValueChange() && position != 0) { validate(); } } @Override public void onNothingSelected(final AdapterView<?> parent) { if (getOnItemSelectedListener() != null) { getOnItemSelectedListener().onNothingSelected(parent); } } }; }
java
private OnItemSelectedListener createItemSelectedListener() { return new OnItemSelectedListener() { @Override public void onItemSelected(final AdapterView<?> parent, final View view, final int position, final long id) { if (getOnItemSelectedListener() != null) { getOnItemSelectedListener().onItemSelected(parent, view, position, id); } if (isValidatedOnValueChange() && position != 0) { validate(); } } @Override public void onNothingSelected(final AdapterView<?> parent) { if (getOnItemSelectedListener() != null) { getOnItemSelectedListener().onNothingSelected(parent); } } }; }
[ "private", "OnItemSelectedListener", "createItemSelectedListener", "(", ")", "{", "return", "new", "OnItemSelectedListener", "(", ")", "{", "@", "Override", "public", "void", "onItemSelected", "(", "final", "AdapterView", "<", "?", ">", "parent", ",", "final", "View", "view", ",", "final", "int", "position", ",", "final", "long", "id", ")", "{", "if", "(", "getOnItemSelectedListener", "(", ")", "!=", "null", ")", "{", "getOnItemSelectedListener", "(", ")", ".", "onItemSelected", "(", "parent", ",", "view", ",", "position", ",", "id", ")", ";", "}", "if", "(", "isValidatedOnValueChange", "(", ")", "&&", "position", "!=", "0", ")", "{", "validate", "(", ")", ";", "}", "}", "@", "Override", "public", "void", "onNothingSelected", "(", "final", "AdapterView", "<", "?", ">", "parent", ")", "{", "if", "(", "getOnItemSelectedListener", "(", ")", "!=", "null", ")", "{", "getOnItemSelectedListener", "(", ")", ".", "onNothingSelected", "(", "parent", ")", ";", "}", "}", "}", ";", "}" ]
Creates and returns a listener, which allows to validate the value of the view, when the selected item has been changed. @return The listener, which has been created, as an instance of the type {@link OnItemSelectedListener}
[ "Creates", "and", "returns", "a", "listener", "which", "allows", "to", "validate", "the", "value", "of", "the", "view", "when", "the", "selected", "item", "has", "been", "changed", "." ]
ac8693baeac7abddf2e38a47da4c1849d4661a8b
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/Spinner.java#L276-L299
8,084
michael-rapp/AndroidMaterialValidation
library/src/main/java/de/mrapp/android/validation/Spinner.java
Spinner.setHint
public final void setHint(@Nullable final CharSequence hint) { this.hint = hint; if (getAdapter() != null) { ProxySpinnerAdapter proxyAdapter = (ProxySpinnerAdapter) getAdapter(); setAdapter(proxyAdapter.getAdapter()); } }
java
public final void setHint(@Nullable final CharSequence hint) { this.hint = hint; if (getAdapter() != null) { ProxySpinnerAdapter proxyAdapter = (ProxySpinnerAdapter) getAdapter(); setAdapter(proxyAdapter.getAdapter()); } }
[ "public", "final", "void", "setHint", "(", "@", "Nullable", "final", "CharSequence", "hint", ")", "{", "this", ".", "hint", "=", "hint", ";", "if", "(", "getAdapter", "(", ")", "!=", "null", ")", "{", "ProxySpinnerAdapter", "proxyAdapter", "=", "(", "ProxySpinnerAdapter", ")", "getAdapter", "(", ")", ";", "setAdapter", "(", "proxyAdapter", ".", "getAdapter", "(", ")", ")", ";", "}", "}" ]
Sets the hint, which should be displayed, when no item is selected. @param hint The hint, which should be set, as an instance of the type {@link CharSequence} or null, if no hint should be set
[ "Sets", "the", "hint", "which", "should", "be", "displayed", "when", "no", "item", "is", "selected", "." ]
ac8693baeac7abddf2e38a47da4c1849d4661a8b
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/Spinner.java#L409-L416
8,085
michael-rapp/AndroidMaterialValidation
library/src/main/java/de/mrapp/android/validation/Spinner.java
Spinner.setHintTextColor
public final void setHintTextColor(final ColorStateList colors) { this.hintColor = colors; if (getAdapter() != null) { ProxySpinnerAdapter proxyAdapter = (ProxySpinnerAdapter) getAdapter(); setAdapter(proxyAdapter.getAdapter()); } }
java
public final void setHintTextColor(final ColorStateList colors) { this.hintColor = colors; if (getAdapter() != null) { ProxySpinnerAdapter proxyAdapter = (ProxySpinnerAdapter) getAdapter(); setAdapter(proxyAdapter.getAdapter()); } }
[ "public", "final", "void", "setHintTextColor", "(", "final", "ColorStateList", "colors", ")", "{", "this", ".", "hintColor", "=", "colors", ";", "if", "(", "getAdapter", "(", ")", "!=", "null", ")", "{", "ProxySpinnerAdapter", "proxyAdapter", "=", "(", "ProxySpinnerAdapter", ")", "getAdapter", "(", ")", ";", "setAdapter", "(", "proxyAdapter", ".", "getAdapter", "(", ")", ")", ";", "}", "}" ]
Sets the color of the hint, which should be displayed, when no item is selected. @param colors The color, which should be set, as an instance of the class {@link ColorStateList}
[ "Sets", "the", "color", "of", "the", "hint", "which", "should", "be", "displayed", "when", "no", "item", "is", "selected", "." ]
ac8693baeac7abddf2e38a47da4c1849d4661a8b
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/Spinner.java#L455-L462
8,086
michael-rapp/AndroidMaterialValidation
library/src/main/java/de/mrapp/android/validation/Spinner.java
Spinner.setPopupBackgroundDrawable
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public final void setPopupBackgroundDrawable(final Drawable background) { getView().setPopupBackgroundDrawable(background); }
java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public final void setPopupBackgroundDrawable(final Drawable background) { getView().setPopupBackgroundDrawable(background); }
[ "@", "TargetApi", "(", "Build", ".", "VERSION_CODES", ".", "JELLY_BEAN", ")", "public", "final", "void", "setPopupBackgroundDrawable", "(", "final", "Drawable", "background", ")", "{", "getView", "(", ")", ".", "setPopupBackgroundDrawable", "(", "background", ")", ";", "}" ]
Set the background drawable for the spinner's popup window of choices. Only valid in MODE_DROPDOWN; this method is a no-op in other modes. @param background Background drawable
[ "Set", "the", "background", "drawable", "for", "the", "spinner", "s", "popup", "window", "of", "choices", ".", "Only", "valid", "in", "MODE_DROPDOWN", ";", "this", "method", "is", "a", "no", "-", "op", "in", "other", "modes", "." ]
ac8693baeac7abddf2e38a47da4c1849d4661a8b
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/Spinner.java#L473-L476
8,087
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/qe/FilteringScore.java
FilteringScore.evaluate
public static <S extends Storable> FilteringScore<S> evaluate(StorableIndex<S> index, Filter<S> filter) { if (index == null) { throw new IllegalArgumentException("Index required"); } return evaluate(index.getOrderedProperties(), index.isUnique(), index.isClustered(), filter); }
java
public static <S extends Storable> FilteringScore<S> evaluate(StorableIndex<S> index, Filter<S> filter) { if (index == null) { throw new IllegalArgumentException("Index required"); } return evaluate(index.getOrderedProperties(), index.isUnique(), index.isClustered(), filter); }
[ "public", "static", "<", "S", "extends", "Storable", ">", "FilteringScore", "<", "S", ">", "evaluate", "(", "StorableIndex", "<", "S", ">", "index", ",", "Filter", "<", "S", ">", "filter", ")", "{", "if", "(", "index", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Index required\"", ")", ";", "}", "return", "evaluate", "(", "index", ".", "getOrderedProperties", "(", ")", ",", "index", ".", "isUnique", "(", ")", ",", "index", ".", "isClustered", "(", ")", ",", "filter", ")", ";", "}" ]
Evaluates the given index for its filtering capabilities against the given filter. @param index index to evaluate @param filter filter which cannot contain any logical 'or' operations. @throws IllegalArgumentException if index is null or filter is not supported
[ "Evaluates", "the", "given", "index", "for", "its", "filtering", "capabilities", "against", "the", "given", "filter", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/FilteringScore.java#L79-L90
8,088
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/qe/FilteringScore.java
FilteringScore.nullCompare
static int nullCompare(Object first, Object second) { if (first == null) { if (second != null) { return 1; } } else if (second == null) { return -1; } return 0; }
java
static int nullCompare(Object first, Object second) { if (first == null) { if (second != null) { return 1; } } else if (second == null) { return -1; } return 0; }
[ "static", "int", "nullCompare", "(", "Object", "first", ",", "Object", "second", ")", "{", "if", "(", "first", "==", "null", ")", "{", "if", "(", "second", "!=", "null", ")", "{", "return", "1", ";", "}", "}", "else", "if", "(", "second", "==", "null", ")", "{", "return", "-", "1", ";", "}", "return", "0", ";", "}" ]
Comparison orders null high.
[ "Comparison", "orders", "null", "high", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/FilteringScore.java#L267-L276
8,089
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/qe/FilteringScore.java
FilteringScore.split
static <S extends Storable> List<Filter<S>> split(Filter<S> filter) { return filter == null ? null : filter.conjunctiveNormalFormSplit(); }
java
static <S extends Storable> List<Filter<S>> split(Filter<S> filter) { return filter == null ? null : filter.conjunctiveNormalFormSplit(); }
[ "static", "<", "S", "extends", "Storable", ">", "List", "<", "Filter", "<", "S", ">", ">", "split", "(", "Filter", "<", "S", ">", "filter", ")", "{", "return", "filter", "==", "null", "?", "null", ":", "filter", ".", "conjunctiveNormalFormSplit", "(", ")", ";", "}" ]
Splits the filter from its conjunctive normal form. And'ng the filters together produces the original filter.
[ "Splits", "the", "filter", "from", "its", "conjunctive", "normal", "form", ".", "And", "ng", "the", "filters", "together", "produces", "the", "original", "filter", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/FilteringScore.java#L282-L284
8,090
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/qe/FilteringScore.java
FilteringScore.getHandledFilter
public Filter<S> getHandledFilter() { Filter<S> identity = getIdentityFilter(); Filter<S> rangeStart = buildCompositeFilter(getRangeStartFilters()); Filter<S> rangeEnd = buildCompositeFilter(getRangeEndFilters()); return and(and(identity, rangeStart), rangeEnd); }
java
public Filter<S> getHandledFilter() { Filter<S> identity = getIdentityFilter(); Filter<S> rangeStart = buildCompositeFilter(getRangeStartFilters()); Filter<S> rangeEnd = buildCompositeFilter(getRangeEndFilters()); return and(and(identity, rangeStart), rangeEnd); }
[ "public", "Filter", "<", "S", ">", "getHandledFilter", "(", ")", "{", "Filter", "<", "S", ">", "identity", "=", "getIdentityFilter", "(", ")", ";", "Filter", "<", "S", ">", "rangeStart", "=", "buildCompositeFilter", "(", "getRangeStartFilters", "(", ")", ")", ";", "Filter", "<", "S", ">", "rangeEnd", "=", "buildCompositeFilter", "(", "getRangeEndFilters", "(", ")", ")", ";", "return", "and", "(", "and", "(", "identity", ",", "rangeStart", ")", ",", "rangeEnd", ")", ";", "}" ]
Returns the composite handled filter, or null if no matches at all.
[ "Returns", "the", "composite", "handled", "filter", "or", "null", "if", "no", "matches", "at", "all", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/FilteringScore.java#L485-L491
8,091
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/qe/FilteringScore.java
FilteringScore.getCoveringRemainderFilter
public Filter<S> getCoveringRemainderFilter() { if (mCoveringRemainderFilter == null) { List<? extends Filter<S>> remainderFilters = mRemainderFilters; List<? extends Filter<S>> coveringFilters = mCoveringFilters; if (coveringFilters.size() < remainderFilters.size()) { Filter<S> composite = null; for (int i=0; i<remainderFilters.size(); i++) { Filter<S> subFilter = remainderFilters.get(i); if (!coveringFilters.contains(subFilter)) { if (composite == null) { composite = subFilter; } else { composite = composite.and(subFilter); } } } mCoveringRemainderFilter = composite; } } return mCoveringRemainderFilter; }
java
public Filter<S> getCoveringRemainderFilter() { if (mCoveringRemainderFilter == null) { List<? extends Filter<S>> remainderFilters = mRemainderFilters; List<? extends Filter<S>> coveringFilters = mCoveringFilters; if (coveringFilters.size() < remainderFilters.size()) { Filter<S> composite = null; for (int i=0; i<remainderFilters.size(); i++) { Filter<S> subFilter = remainderFilters.get(i); if (!coveringFilters.contains(subFilter)) { if (composite == null) { composite = subFilter; } else { composite = composite.and(subFilter); } } } mCoveringRemainderFilter = composite; } } return mCoveringRemainderFilter; }
[ "public", "Filter", "<", "S", ">", "getCoveringRemainderFilter", "(", ")", "{", "if", "(", "mCoveringRemainderFilter", "==", "null", ")", "{", "List", "<", "?", "extends", "Filter", "<", "S", ">", ">", "remainderFilters", "=", "mRemainderFilters", ";", "List", "<", "?", "extends", "Filter", "<", "S", ">", ">", "coveringFilters", "=", "mCoveringFilters", ";", "if", "(", "coveringFilters", ".", "size", "(", ")", "<", "remainderFilters", ".", "size", "(", ")", ")", "{", "Filter", "<", "S", ">", "composite", "=", "null", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "remainderFilters", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Filter", "<", "S", ">", "subFilter", "=", "remainderFilters", ".", "get", "(", "i", ")", ";", "if", "(", "!", "coveringFilters", ".", "contains", "(", "subFilter", ")", ")", "{", "if", "(", "composite", "==", "null", ")", "{", "composite", "=", "subFilter", ";", "}", "else", "{", "composite", "=", "composite", ".", "and", "(", "subFilter", ")", ";", "}", "}", "}", "mCoveringRemainderFilter", "=", "composite", ";", "}", "}", "return", "mCoveringRemainderFilter", ";", "}" ]
Returns the composite remainder filter without including the covering filter. Returns null if no remainder. @since 1.2
[ "Returns", "the", "composite", "remainder", "filter", "without", "including", "the", "covering", "filter", ".", "Returns", "null", "if", "no", "remainder", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/FilteringScore.java#L605-L625
8,092
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/qe/FilteringScore.java
FilteringScore.canMergeRemainderFilter
public boolean canMergeRemainderFilter(FilteringScore<S> other) { if (this == other || (!hasAnyMatches() && !other.hasAnyMatches())) { return true; } return isIndexClustered() == other.isIndexClustered() && isIndexUnique() == other.isIndexUnique() && getIndexPropertyCount() == other.getIndexPropertyCount() && getArrangementScore() == other.getArrangementScore() && getPreferenceScore().equals(other.getPreferenceScore()) && shouldReverseRange() == other.shouldReverseRange() // List comparisons assume identical ordering, but this is // not strictly required. Since the different scores likely // originated from the same complex filter, the ordering // likely matches. A set equality test is not needed. && getIdentityFilters().equals(other.getIdentityFilters()) && getRangeStartFilters().equals(other.getRangeStartFilters()) && getRangeEndFilters().equals(other.getRangeEndFilters()); }
java
public boolean canMergeRemainderFilter(FilteringScore<S> other) { if (this == other || (!hasAnyMatches() && !other.hasAnyMatches())) { return true; } return isIndexClustered() == other.isIndexClustered() && isIndexUnique() == other.isIndexUnique() && getIndexPropertyCount() == other.getIndexPropertyCount() && getArrangementScore() == other.getArrangementScore() && getPreferenceScore().equals(other.getPreferenceScore()) && shouldReverseRange() == other.shouldReverseRange() // List comparisons assume identical ordering, but this is // not strictly required. Since the different scores likely // originated from the same complex filter, the ordering // likely matches. A set equality test is not needed. && getIdentityFilters().equals(other.getIdentityFilters()) && getRangeStartFilters().equals(other.getRangeStartFilters()) && getRangeEndFilters().equals(other.getRangeEndFilters()); }
[ "public", "boolean", "canMergeRemainderFilter", "(", "FilteringScore", "<", "S", ">", "other", ")", "{", "if", "(", "this", "==", "other", "||", "(", "!", "hasAnyMatches", "(", ")", "&&", "!", "other", ".", "hasAnyMatches", "(", ")", ")", ")", "{", "return", "true", ";", "}", "return", "isIndexClustered", "(", ")", "==", "other", ".", "isIndexClustered", "(", ")", "&&", "isIndexUnique", "(", ")", "==", "other", ".", "isIndexUnique", "(", ")", "&&", "getIndexPropertyCount", "(", ")", "==", "other", ".", "getIndexPropertyCount", "(", ")", "&&", "getArrangementScore", "(", ")", "==", "other", ".", "getArrangementScore", "(", ")", "&&", "getPreferenceScore", "(", ")", ".", "equals", "(", "other", ".", "getPreferenceScore", "(", ")", ")", "&&", "shouldReverseRange", "(", ")", "==", "other", ".", "shouldReverseRange", "(", ")", "// List comparisons assume identical ordering, but this is\r", "// not strictly required. Since the different scores likely\r", "// originated from the same complex filter, the ordering\r", "// likely matches. A set equality test is not needed.\r", "&&", "getIdentityFilters", "(", ")", ".", "equals", "(", "other", ".", "getIdentityFilters", "(", ")", ")", "&&", "getRangeStartFilters", "(", ")", ".", "equals", "(", "other", ".", "getRangeStartFilters", "(", ")", ")", "&&", "getRangeEndFilters", "(", ")", ".", "equals", "(", "other", ".", "getRangeEndFilters", "(", ")", ")", ";", "}" ]
Returns true if the given score uses an index exactly the same as this one. The only allowed differences are in the remainder filter.
[ "Returns", "true", "if", "the", "given", "score", "uses", "an", "index", "exactly", "the", "same", "as", "this", "one", ".", "The", "only", "allowed", "differences", "are", "in", "the", "remainder", "filter", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/FilteringScore.java#L648-L666
8,093
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/qe/FilteringScore.java
FilteringScore.mergeRemainderFilter
public Filter<S> mergeRemainderFilter(FilteringScore<S> other) { Filter<S> thisRemainderFilter = getRemainderFilter(); if (this == other) { return thisRemainderFilter; } Filter<S> otherRemainderFilter = other.getRemainderFilter(); if (thisRemainderFilter == null) { return otherRemainderFilter; } else if (otherRemainderFilter == null) { return thisRemainderFilter; } else if (thisRemainderFilter.equals(otherRemainderFilter)) { return thisRemainderFilter; } else { return thisRemainderFilter.or(otherRemainderFilter); } }
java
public Filter<S> mergeRemainderFilter(FilteringScore<S> other) { Filter<S> thisRemainderFilter = getRemainderFilter(); if (this == other) { return thisRemainderFilter; } Filter<S> otherRemainderFilter = other.getRemainderFilter(); if (thisRemainderFilter == null) { return otherRemainderFilter; } else if (otherRemainderFilter == null) { return thisRemainderFilter; } else if (thisRemainderFilter.equals(otherRemainderFilter)) { return thisRemainderFilter; } else { return thisRemainderFilter.or(otherRemainderFilter); } }
[ "public", "Filter", "<", "S", ">", "mergeRemainderFilter", "(", "FilteringScore", "<", "S", ">", "other", ")", "{", "Filter", "<", "S", ">", "thisRemainderFilter", "=", "getRemainderFilter", "(", ")", ";", "if", "(", "this", "==", "other", ")", "{", "return", "thisRemainderFilter", ";", "}", "Filter", "<", "S", ">", "otherRemainderFilter", "=", "other", ".", "getRemainderFilter", "(", ")", ";", "if", "(", "thisRemainderFilter", "==", "null", ")", "{", "return", "otherRemainderFilter", ";", "}", "else", "if", "(", "otherRemainderFilter", "==", "null", ")", "{", "return", "thisRemainderFilter", ";", "}", "else", "if", "(", "thisRemainderFilter", ".", "equals", "(", "otherRemainderFilter", ")", ")", "{", "return", "thisRemainderFilter", ";", "}", "else", "{", "return", "thisRemainderFilter", ".", "or", "(", "otherRemainderFilter", ")", ";", "}", "}" ]
Merges the remainder filter of this score with the one given using an 'or' operation. Call canMergeRemainderFilter first to verify if the merge makes any sense. Returns null if no remainder filter at all.
[ "Merges", "the", "remainder", "filter", "of", "this", "score", "with", "the", "one", "given", "using", "an", "or", "operation", ".", "Call", "canMergeRemainderFilter", "first", "to", "verify", "if", "the", "merge", "makes", "any", "sense", ".", "Returns", "null", "if", "no", "remainder", "filter", "at", "all", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/FilteringScore.java#L673-L691
8,094
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/qe/FilteringScore.java
FilteringScore.findCoveringMatches
private List<Filter<S>> findCoveringMatches() { List<Filter<S>> coveringFilters = null; boolean check = !mRemainderFilters.isEmpty() && (mIdentityFilters.size() > 0 || mRangeStartFilters.size() > 0 || mRangeEndFilters.size() > 0); if (check) { // Any remainder property which is provided by the index is a covering match. for (Filter<S> subFilter : mRemainderFilters) { if (isProvidedByIndex(subFilter)) { if (coveringFilters == null) { coveringFilters = new ArrayList<Filter<S>>(); } coveringFilters.add(subFilter); } } } return prepareList(coveringFilters); }
java
private List<Filter<S>> findCoveringMatches() { List<Filter<S>> coveringFilters = null; boolean check = !mRemainderFilters.isEmpty() && (mIdentityFilters.size() > 0 || mRangeStartFilters.size() > 0 || mRangeEndFilters.size() > 0); if (check) { // Any remainder property which is provided by the index is a covering match. for (Filter<S> subFilter : mRemainderFilters) { if (isProvidedByIndex(subFilter)) { if (coveringFilters == null) { coveringFilters = new ArrayList<Filter<S>>(); } coveringFilters.add(subFilter); } } } return prepareList(coveringFilters); }
[ "private", "List", "<", "Filter", "<", "S", ">", ">", "findCoveringMatches", "(", ")", "{", "List", "<", "Filter", "<", "S", ">>", "coveringFilters", "=", "null", ";", "boolean", "check", "=", "!", "mRemainderFilters", ".", "isEmpty", "(", ")", "&&", "(", "mIdentityFilters", ".", "size", "(", ")", ">", "0", "||", "mRangeStartFilters", ".", "size", "(", ")", ">", "0", "||", "mRangeEndFilters", ".", "size", "(", ")", ">", "0", ")", ";", "if", "(", "check", ")", "{", "// Any remainder property which is provided by the index is a covering match.\r", "for", "(", "Filter", "<", "S", ">", "subFilter", ":", "mRemainderFilters", ")", "{", "if", "(", "isProvidedByIndex", "(", "subFilter", ")", ")", "{", "if", "(", "coveringFilters", "==", "null", ")", "{", "coveringFilters", "=", "new", "ArrayList", "<", "Filter", "<", "S", ">", ">", "(", ")", ";", "}", "coveringFilters", ".", "add", "(", "subFilter", ")", ";", "}", "}", "}", "return", "prepareList", "(", "coveringFilters", ")", ";", "}" ]
Finds covering matches from the remainder.
[ "Finds", "covering", "matches", "from", "the", "remainder", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/FilteringScore.java#L747-L768
8,095
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/info/StorableIntrospector.java
StorableIntrospector.main
public static void main(String[] args) throws Exception { for (String arg : args) { Class clazz = Class.forName(arg); System.out.println("Examining: " + clazz.getName()); try { examine(clazz); System.out.println("Passed"); } catch (MalformedTypeException e) { System.out.println("Malformed type: " + e.getMalformedType().getName()); for (String message : e.getMessages()) { System.out.println(message); } } } }
java
public static void main(String[] args) throws Exception { for (String arg : args) { Class clazz = Class.forName(arg); System.out.println("Examining: " + clazz.getName()); try { examine(clazz); System.out.println("Passed"); } catch (MalformedTypeException e) { System.out.println("Malformed type: " + e.getMalformedType().getName()); for (String message : e.getMessages()) { System.out.println(message); } } } }
[ "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "throws", "Exception", "{", "for", "(", "String", "arg", ":", "args", ")", "{", "Class", "clazz", "=", "Class", ".", "forName", "(", "arg", ")", ";", "System", ".", "out", ".", "println", "(", "\"Examining: \"", "+", "clazz", ".", "getName", "(", ")", ")", ";", "try", "{", "examine", "(", "clazz", ")", ";", "System", ".", "out", ".", "println", "(", "\"Passed\"", ")", ";", "}", "catch", "(", "MalformedTypeException", "e", ")", "{", "System", ".", "out", ".", "println", "(", "\"Malformed type: \"", "+", "e", ".", "getMalformedType", "(", ")", ".", "getName", "(", ")", ")", ";", "for", "(", "String", "message", ":", "e", ".", "getMessages", "(", ")", ")", "{", "System", ".", "out", ".", "println", "(", "message", ")", ";", "}", "}", "}", "}" ]
Test program which examines candidate Storable classes. If any fail, an exception is thrown. @param args names of classes to examine
[ "Test", "program", "which", "examines", "candidate", "Storable", "classes", ".", "If", "any", "fail", "an", "exception", "is", "thrown", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/info/StorableIntrospector.java#L132-L146
8,096
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/info/StorableIntrospector.java
StorableIntrospector.checkTypeParameter
@SuppressWarnings("unchecked") private static void checkTypeParameter(List<String> errorMessages, Class type) { // Only check classes and interfaces that extend Storable. if (type != null && Storable.class.isAssignableFrom(type)) { if (Storable.class == type) { return; } } else { return; } // Check all superclasses and interfaces. checkTypeParameter(errorMessages, type.getSuperclass()); for (Class c : type.getInterfaces()) { checkTypeParameter(errorMessages, c); } for (Type t : type.getGenericInterfaces()) { if (t instanceof ParameterizedType) { ParameterizedType pt = (ParameterizedType)t; if (pt.getRawType() == Storable.class) { // Found exactly which parameter is passed directly to // Storable. Make sure that it is in the proper bounds. Type arg = pt.getActualTypeArguments()[0]; Class param; if (arg instanceof ParameterizedType) { Type raw = ((ParameterizedType)arg).getRawType(); if (raw instanceof Class) { param = (Class)raw; } else { continue; } } else if (arg instanceof Class) { param = (Class)arg; } else if (arg instanceof TypeVariable) { // TODO continue; } else { continue; } if (Storable.class.isAssignableFrom(param)) { if (!param.isAssignableFrom(type)) { errorMessages.add ("Type parameter passed from " + type + " to Storable must be a " + type.getName() + ": " + param); return; } } else { errorMessages.add ("Type parameter passed from " + type + " to Storable must be a Storable: " + param); return; } } } } }
java
@SuppressWarnings("unchecked") private static void checkTypeParameter(List<String> errorMessages, Class type) { // Only check classes and interfaces that extend Storable. if (type != null && Storable.class.isAssignableFrom(type)) { if (Storable.class == type) { return; } } else { return; } // Check all superclasses and interfaces. checkTypeParameter(errorMessages, type.getSuperclass()); for (Class c : type.getInterfaces()) { checkTypeParameter(errorMessages, c); } for (Type t : type.getGenericInterfaces()) { if (t instanceof ParameterizedType) { ParameterizedType pt = (ParameterizedType)t; if (pt.getRawType() == Storable.class) { // Found exactly which parameter is passed directly to // Storable. Make sure that it is in the proper bounds. Type arg = pt.getActualTypeArguments()[0]; Class param; if (arg instanceof ParameterizedType) { Type raw = ((ParameterizedType)arg).getRawType(); if (raw instanceof Class) { param = (Class)raw; } else { continue; } } else if (arg instanceof Class) { param = (Class)arg; } else if (arg instanceof TypeVariable) { // TODO continue; } else { continue; } if (Storable.class.isAssignableFrom(param)) { if (!param.isAssignableFrom(type)) { errorMessages.add ("Type parameter passed from " + type + " to Storable must be a " + type.getName() + ": " + param); return; } } else { errorMessages.add ("Type parameter passed from " + type + " to Storable must be a Storable: " + param); return; } } } } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "static", "void", "checkTypeParameter", "(", "List", "<", "String", ">", "errorMessages", ",", "Class", "type", ")", "{", "// Only check classes and interfaces that extend Storable.\r", "if", "(", "type", "!=", "null", "&&", "Storable", ".", "class", ".", "isAssignableFrom", "(", "type", ")", ")", "{", "if", "(", "Storable", ".", "class", "==", "type", ")", "{", "return", ";", "}", "}", "else", "{", "return", ";", "}", "// Check all superclasses and interfaces.\r", "checkTypeParameter", "(", "errorMessages", ",", "type", ".", "getSuperclass", "(", ")", ")", ";", "for", "(", "Class", "c", ":", "type", ".", "getInterfaces", "(", ")", ")", "{", "checkTypeParameter", "(", "errorMessages", ",", "c", ")", ";", "}", "for", "(", "Type", "t", ":", "type", ".", "getGenericInterfaces", "(", ")", ")", "{", "if", "(", "t", "instanceof", "ParameterizedType", ")", "{", "ParameterizedType", "pt", "=", "(", "ParameterizedType", ")", "t", ";", "if", "(", "pt", ".", "getRawType", "(", ")", "==", "Storable", ".", "class", ")", "{", "// Found exactly which parameter is passed directly to\r", "// Storable. Make sure that it is in the proper bounds.\r", "Type", "arg", "=", "pt", ".", "getActualTypeArguments", "(", ")", "[", "0", "]", ";", "Class", "param", ";", "if", "(", "arg", "instanceof", "ParameterizedType", ")", "{", "Type", "raw", "=", "(", "(", "ParameterizedType", ")", "arg", ")", ".", "getRawType", "(", ")", ";", "if", "(", "raw", "instanceof", "Class", ")", "{", "param", "=", "(", "Class", ")", "raw", ";", "}", "else", "{", "continue", ";", "}", "}", "else", "if", "(", "arg", "instanceof", "Class", ")", "{", "param", "=", "(", "Class", ")", "arg", ";", "}", "else", "if", "(", "arg", "instanceof", "TypeVariable", ")", "{", "// TODO\r", "continue", ";", "}", "else", "{", "continue", ";", "}", "if", "(", "Storable", ".", "class", ".", "isAssignableFrom", "(", "param", ")", ")", "{", "if", "(", "!", "param", ".", "isAssignableFrom", "(", "type", ")", ")", "{", "errorMessages", ".", "add", "(", "\"Type parameter passed from \"", "+", "type", "+", "\" to Storable must be a \"", "+", "type", ".", "getName", "(", ")", "+", "\": \"", "+", "param", ")", ";", "return", ";", "}", "}", "else", "{", "errorMessages", ".", "add", "(", "\"Type parameter passed from \"", "+", "type", "+", "\" to Storable must be a Storable: \"", "+", "param", ")", ";", "return", ";", "}", "}", "}", "}", "}" ]
Make sure that the parameter type that is specified to Storable can be assigned to a Storable, and that the given type can be assigned to it. Put another way, the upper bound is Storable, and the lower bound is the given type. type <= parameterized type <= Storable
[ "Make", "sure", "that", "the", "parameter", "type", "that", "is", "specified", "to", "Storable", "can", "be", "assigned", "to", "a", "Storable", "and", "that", "the", "given", "type", "can", "be", "assigned", "to", "it", ".", "Put", "another", "way", "the", "upper", "bound", "is", "Storable", "and", "the", "lower", "bound", "is", "the", "given", "type", ".", "type", "<", "=", "parameterized", "type", "<", "=", "Storable" ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/info/StorableIntrospector.java#L913-L970
8,097
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/info/StorableIntrospector.java
StorableIntrospector.gatherAllDeclaredMethods
private static Map<String, Method> gatherAllDeclaredMethods(Class clazz) { Map<String, Method> methods = new HashMap<String, Method>(); gatherAllDeclaredMethods(methods, clazz); return methods; }
java
private static Map<String, Method> gatherAllDeclaredMethods(Class clazz) { Map<String, Method> methods = new HashMap<String, Method>(); gatherAllDeclaredMethods(methods, clazz); return methods; }
[ "private", "static", "Map", "<", "String", ",", "Method", ">", "gatherAllDeclaredMethods", "(", "Class", "clazz", ")", "{", "Map", "<", "String", ",", "Method", ">", "methods", "=", "new", "HashMap", "<", "String", ",", "Method", ">", "(", ")", ";", "gatherAllDeclaredMethods", "(", "methods", ",", "clazz", ")", ";", "return", "methods", ";", "}" ]
Returns a new modifiable mapping of method signatures to methods. @return map of {@link #createSig signatures} to methods
[ "Returns", "a", "new", "modifiable", "mapping", "of", "method", "signatures", "to", "methods", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/info/StorableIntrospector.java#L1575-L1579
8,098
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/info/StorableIntrospector.java
StorableIntrospector.createSig
private static String createSig(Method m) { return m.getName() + ':' + MethodDesc.forMethod(m).getDescriptor(); }
java
private static String createSig(Method m) { return m.getName() + ':' + MethodDesc.forMethod(m).getDescriptor(); }
[ "private", "static", "String", "createSig", "(", "Method", "m", ")", "{", "return", "m", ".", "getName", "(", ")", "+", "'", "'", "+", "MethodDesc", ".", "forMethod", "(", "m", ")", ".", "getDescriptor", "(", ")", ";", "}" ]
Create a representation of the signature which includes the method name. This uniquely identifies the method. @param m method to describe
[ "Create", "a", "representation", "of", "the", "signature", "which", "includes", "the", "method", "name", ".", "This", "uniquely", "identifies", "the", "method", "." ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/info/StorableIntrospector.java#L1604-L1606
8,099
Carbonado/Carbonado
src/main/java/com/amazon/carbonado/lob/ByteArrayBlob.java
ByteArrayBlob.ensureLengthForWrite
private void ensureLengthForWrite(int ilength) { if (ilength > mLength) { if (ilength <= mData.length) { mLength = ilength; } else { int newLength = mData.length * 2; if (newLength < ilength) { newLength = ilength; } byte[] newData = new byte[newLength]; System.arraycopy(mData, 0, newData, 0, mLength); mData = newData; } mLength = ilength; } }
java
private void ensureLengthForWrite(int ilength) { if (ilength > mLength) { if (ilength <= mData.length) { mLength = ilength; } else { int newLength = mData.length * 2; if (newLength < ilength) { newLength = ilength; } byte[] newData = new byte[newLength]; System.arraycopy(mData, 0, newData, 0, mLength); mData = newData; } mLength = ilength; } }
[ "private", "void", "ensureLengthForWrite", "(", "int", "ilength", ")", "{", "if", "(", "ilength", ">", "mLength", ")", "{", "if", "(", "ilength", "<=", "mData", ".", "length", ")", "{", "mLength", "=", "ilength", ";", "}", "else", "{", "int", "newLength", "=", "mData", ".", "length", "*", "2", ";", "if", "(", "newLength", "<", "ilength", ")", "{", "newLength", "=", "ilength", ";", "}", "byte", "[", "]", "newData", "=", "new", "byte", "[", "newLength", "]", ";", "System", ".", "arraycopy", "(", "mData", ",", "0", ",", "newData", ",", "0", ",", "mLength", ")", ";", "mData", "=", "newData", ";", "}", "mLength", "=", "ilength", ";", "}", "}" ]
Caller must be synchronized
[ "Caller", "must", "be", "synchronized" ]
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/lob/ByteArrayBlob.java#L297-L312