idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
3,100
void detach ( ) { mLock . lock ( ) ; try { if ( mDetached || mTxnMgr . removeLocalScope ( this ) ) { mDetached = true ; } else { throw new IllegalStateException ( "Transaction is attached to a different thread" ) ; } } finally { mLock . unlock ( ) ; } }
Called by TransactionImpl .
3,101
void close ( ) throws RepositoryException { mLock . lock ( ) ; if ( mClosed ) { mLock . unlock ( ) ; return ; } Map < Class < ? > , CursorList < TransactionImpl < Txn > > > cursors ; try { cursors = mCursors ; mCursors = null ; while ( mActive != null ) { mActive . exit ( ) ; } } finally { mTxnMgr = ( TransactionManage...
Exits all transactions and closes all cursors . Should be called only when repository is closed .
3,102
@ SuppressWarnings ( "unchecked" ) public void addKey ( StorableKey < S > key ) { if ( key == null ) { throw new IllegalArgumentException ( ) ; } add ( new StorableIndex < S > ( key , Direction . UNSPECIFIED ) ) ; }
Adds the key as a unique index preserving the property arrangement .
3,103
public void reduce ( Direction defaultDirection ) { List < StorableIndex < S > > group = new ArrayList < StorableIndex < S > > ( ) ; Map < StorableIndex < S > , StorableIndex < S > > mergedReplacements = new TreeMap < StorableIndex < S > , StorableIndex < S > > ( STORABLE_INDEX_COMPARATOR ) ; Iterator < StorableIndex <...
Reduces the size of the set by removing redundant indexes and merges others together .
3,104
public void setDefaultDirection ( Direction defaultDirection ) { if ( defaultDirection != Direction . UNSPECIFIED ) { Map < StorableIndex < S > , StorableIndex < S > > replacements = null ; for ( StorableIndex < S > index : this ) { StorableIndex < S > replacement = index . setDefaultDirection ( defaultDirection ) ; if...
Set the default direction for all index properties .
3,105
public void markClustered ( boolean clustered ) { Map < StorableIndex < S > , StorableIndex < S > > replacements = null ; for ( StorableIndex < S > index : this ) { StorableIndex < S > replacement = index . clustered ( clustered ) ; if ( replacement != index ) { if ( replacements == null ) { replacements = new HashMap ...
Marks all indexes as clustered or non - clustered .
3,106
public void uniquify ( StorableInfo < S > info ) { if ( info == null ) { throw new IllegalArgumentException ( ) ; } uniquify ( info . getPrimaryKey ( ) ) ; }
Augment non - unique indexes with primary key properties thus making them unique .
3,107
public void uniquify ( StorableKey < S > key ) { if ( key == null ) { throw new IllegalArgumentException ( ) ; } { Map < StorableIndex < S > , StorableIndex < S > > replacements = null ; for ( StorableIndex < S > index : this ) { if ( ! index . isUnique ( ) && isUniqueImplied ( index ) ) { if ( replacements == null ) {...
Augment non - unique indexes with key properties thus making them unique .
3,108
private boolean isUniqueImplied ( StorableIndex < S > candidate ) { if ( candidate . isUnique ( ) ) { return true ; } if ( this . size ( ) <= 1 ) { return false ; } Set < StorableProperty < S > > candidateProps = new HashSet < StorableProperty < S > > ( ) ; for ( int i = candidate . getPropertyCount ( ) ; -- i >= 0 ; )...
Return true if index is unique or fully contains the members of a unique index .
3,109
private boolean isRedundant ( List < StorableIndex < S > > group , StorableIndex < S > candidate , Map < StorableIndex < S > , StorableIndex < S > > mergedReplacements ) { int count = candidate . getPropertyCount ( ) ; ListIterator < StorableIndex < S > > it = group . listIterator ( ) ; groupScan : while ( it . hasNext...
Returns true if candidate index is less qualified than an existing group member or if it was merged with another group member . If it was merged then an entry is placed in the merged map and the given group list is updated .
3,110
private boolean doTryUpdateNoLock ( S storable ) { S existing = mMap . get ( new Key < S > ( storable , mFullComparator ) ) ; if ( existing == null ) { return false ; } else { existing . markAllPropertiesDirty ( ) ; storable . copyDirtyProperties ( existing ) ; existing . markAllPropertiesClean ( ) ; storable . markAll...
Caller must hold write lock .
3,111
void mapPut ( S storable ) { mMap . put ( new Key < S > ( storable , mFullComparator ) , storable ) ; }
Called by MapTransaction which implicitly holds lock .
3,112
public void addProperty ( String propertyName , Direction direction ) { if ( propertyName == null ) { throw new IllegalArgumentException ( ) ; } if ( direction == null ) { direction = Direction . UNSPECIFIED ; } if ( direction != Direction . UNSPECIFIED ) { if ( propertyName . length ( ) > 0 ) { if ( propertyName . cha...
Adds a property to this index with the specified direction .
3,113
public static < S > Comparator < S > createComparator ( Class < S > type , String ... orderProperties ) { BeanComparator bc = BeanComparator . forClass ( type ) ; if ( Storable . class . isAssignableFrom ( type ) ) { StorableInfo info = StorableIntrospector . examine ( ( Class ) type ) ; for ( String property : orderPr...
Convenience method to create a comparator which orders storables by the given order - by properties . The property names may be prefixed with + or - to indicate ascending or descending order . If the prefix is omitted ascending order is assumed .
3,114
public static < S extends Storable > Comparator < S > createComparator ( OrderedProperty < S > ... properties ) { if ( properties == null || properties . length == 0 || properties [ 0 ] == null ) { throw new IllegalArgumentException ( ) ; } Class < S > type = properties [ 0 ] . getChainedProperty ( ) . getPrimeProperty...
Convenience method to create a comparator which orders storables by the given properties .
3,115
private static String chainToBeanString ( ChainedProperty property ) { int count = property . getChainCount ( ) ; if ( count <= 0 ) { return property . getPrimeProperty ( ) . getBeanName ( ) ; } StringBuilder b = new StringBuilder ( ) ; b . append ( property . getPrimeProperty ( ) . getBeanName ( ) ) ; for ( int i = 0 ...
Creates a dotted name string using the bean property names .
3,116
public Comparator < S > comparator ( ) { if ( mChunkMatcher == null ) { return mChunkSorter ; } return new Comparator < S > ( ) { public int compare ( S a , S b ) { int result = mChunkMatcher . compare ( a , b ) ; if ( result == 0 ) { result = mChunkSorter . compare ( a , b ) ; } return result ; } } ; }
Returns a comparator representing the effective sort order of this cursor .
3,117
public String buildStatement ( int initialCapacity , FilterValues < S > filterValues ) { StringBuilder b = new StringBuilder ( initialCapacity ) ; this . appendTo ( b , filterValues ) ; return b . toString ( ) ; }
Builds a statement string from the given values .
3,118
public static < Type > Validator < Type > conjunctive ( final Context context , final Validator < Type > ... validators ) { return ConjunctiveValidator . create ( context , R . string . default_error_message , validators ) ; }
Creates and returns a validator which allows to combine multiple validators in a conjunctive manner . If all single validators succeed the resulting validator will also succeed .
3,119
public static Validator < CharSequence > regex ( final CharSequence errorMessage , final Pattern regex ) { return new RegexValidator ( errorMessage , regex ) ; }
Creates and returns a validator which allows to validate texts to ensure that they match a certain regular expression .
3,120
public final void assertReady ( ) throws ConfigurationException { ArrayList < String > messages = new ArrayList < String > ( ) ; errorCheck ( messages ) ; int size = messages . size ( ) ; if ( size == 0 ) { return ; } StringBuilder b = new StringBuilder ( ) ; if ( size > 1 ) { b . append ( "Multiple problems: " ) ; } f...
Throw a configuration exception if the configuration is not filled out sufficiently and correctly such that a repository could be instantiated from it .
3,121
private void initializeUsernameEditText ( ) { usernameEditText = ( EditText ) findViewById ( R . id . username_edit_text ) ; usernameEditText . addValidator ( Validators . notEmpty ( this , R . string . not_empty_validator_error_message ) ) ; usernameEditText . addValidator ( Validators . maxLength ( this , R . string ...
Initializes the edit text which allows to enter an username .
3,122
private void initializePasswordEditText ( ) { passwordEditText = ( PasswordEditText ) findViewById ( R . id . password_edit_text ) ; passwordEditText . addValidator ( Validators . minLength ( this , R . string . password_min_length_validator_error_message , MIN_PASSWORD_LENGTH ) ) ; passwordEditText . addValidator ( Va...
Initializes the edit text which allows to enter a password .
3,123
private void initializePasswordRepetitionEditText ( ) { passwordRepetitionEditText = ( EditText ) findViewById ( R . id . password_repetition_edit_text ) ; passwordRepetitionEditText . addValidator ( Validators . equal ( this , R . string . equal_validator_error_message , passwordEditText ) ) ; }
Initializes the edit text which allows to enter a password repetition .
3,124
private void initializeGenderSpinner ( ) { genderSpinner = ( Spinner ) findViewById ( R . id . gender_spinner ) ; genderSpinner . addValidator ( Validators . notNull ( this , R . string . not_null_validator_error_message ) ) ; }
Initializes the spinner which allows to choose a gender .
3,125
private void initializeFirstNameEditText ( ) { firstNameEditText = ( EditText ) findViewById ( R . id . first_name_edit_text ) ; firstNameEditText . addValidator ( Validators . minLength ( this , R . string . min_length_validator_error_message , MIN_NAME_LENGTH ) ) ; firstNameEditText . addValidator ( Validators . begi...
Initializes the edit text which allows to enter a first name .
3,126
private void initializeLastNameEditText ( ) { lastNameEditText = ( EditText ) findViewById ( R . id . last_name_edit_text ) ; lastNameEditText . addValidator ( Validators . minLength ( this , R . string . min_length_validator_error_message , MIN_NAME_LENGTH ) ) ; lastNameEditText . addValidator ( Validators . beginsWit...
Initializes the edit text which allows to enter a last name .
3,127
private void initializeValidateButton ( ) { Button button = ( Button ) findViewById ( R . id . validate_button ) ; button . setOnClickListener ( new OnClickListener ( ) { public void onClick ( final View v ) { usernameEditText . validate ( ) ; passwordEditText . validate ( ) ; passwordRepetitionEditText . validate ( ) ...
Initializes the button which allows to validate the values of all views .
3,128
public static DataSource create ( DataSource ds , Log log ) { if ( ds == null ) { throw new IllegalArgumentException ( ) ; } if ( log == null ) { log = LogFactory . getLog ( LoggingDataSource . class ) ; } if ( ! log . isDebugEnabled ( ) ) { return ds ; } return new LoggingDataSource ( log , ds ) ; }
Wraps the given DataSource which logs to the given log . If debug logging is disabled the original DataSource is returned .
3,129
Object getPrimaryDatabase ( ) throws FetchException { Object database = mPrimaryDatabase ; if ( database == null ) { checkClosed ( ) ; throw new IllegalStateException ( "BDBStorage not opened" ) ; } return database ; }
Caller must hold transaction lock . May throw FetchException if storage is closed .
3,130
void checkClosed ( ) throws FetchException { TransactionScope < Txn > scope = localTransactionScope ( ) ; scope . getLock ( ) . lock ( ) ; try { if ( mPrimaryDatabase == null ) { try { scope . getTxn ( ) ; } catch ( Exception e ) { } throw new FetchException ( "Repository closed" ) ; } } finally { scope . getLock ( ) ....
If open returns normally . If shutting down blocks forever . Otherwise if closed throws FetchException . Method blocks forever on shutdown to prevent threads from starting work that will likely fail along the way .
3,131
private boolean isProperJoin ( StorableProperty < ? > property ) throws SupportException , RepositoryException { if ( ! property . isJoin ( ) || property . isQuery ( ) ) { return false ; } Filter < ? > filter = Filter . getOpenFilter ( property . getEnclosingType ( ) ) ; int count = property . getJoinElementCount ( ) ;...
Checks if the property is a join and its internal properties are fully indexed .
3,132
private static int primitiveWidth ( TypeDesc type ) { switch ( type . getTypeCode ( ) ) { default : return 0 ; case TypeDesc . BOOLEAN_CODE : return 1 ; case TypeDesc . BYTE_CODE : return 2 ; case TypeDesc . SHORT_CODE : return 3 ; case TypeDesc . CHAR_CODE : return 4 ; case TypeDesc . INT_CODE : return 5 ; case TypeDe...
1 = boolean 2 = byte 3 = short 4 = char 5 = int 6 = float 7 = long 8 = double
3,133
public Class < ? > getBoxedType ( ) { if ( mBoxedType == null ) { mBoxedType = TypeDesc . forClass ( getType ( ) ) . toObjectType ( ) . toClass ( ) ; } return mBoxedType ; }
Returns the type of the ChainedProperty property boxed into an object if primitive .
3,134
public PropertyFilter < S > constant ( Object value ) { if ( mBindID == BOUND_CONSTANT ) { if ( mConstant == null ) { if ( value == null ) { return this ; } } else if ( mConstant . equals ( value ) ) { return this ; } } return getCanonical ( mProperty , mOp , adaptValue ( value ) ) ; }
Returns another PropertyFilter instance which is bound to the given constant value .
3,135
public static byte [ ] EncodeSubjectPublicKeyInfo ( byte [ ] algorithm , byte [ ] keyBytes ) throws CoseException { try { ArrayList < byte [ ] > xxx = new ArrayList < byte [ ] > ( ) ; xxx . add ( algorithm ) ; xxx . add ( new byte [ ] { 3 } ) ; xxx . add ( ComputeLength ( keyBytes . length + 1 ) ) ; xxx . add ( new byt...
Encode a subject public key info structure from an OID and the data bytes for the key This function assumes that we are encoding an EC Public key . d
3,136
public static byte [ ] EncodeEcPrivateKey ( byte [ ] oid , byte [ ] keyBytes , byte [ ] spki ) throws CoseException { ArrayList < byte [ ] > xxx = new ArrayList < byte [ ] > ( ) ; xxx . add ( new byte [ ] { 2 , 1 , 1 } ) ; xxx . add ( OctetStringTag ) ; xxx . add ( ComputeLength ( keyBytes . length ) ) ; xxx . add ( ke...
Encode an EC Private key
3,137
@ SuppressWarnings ( "unchecked" ) static synchronized < S extends Storable > GenericStorableCodec < S > getInstance ( GenericStorableCodecFactory factory , GenericEncodingStrategy < S > encodingStrategy , boolean isMaster , Layout layout , RawSupport support ) throws SupportException { Object layoutKey = layout == nul...
Returns an instance of the codec . The Storable type itself may be an interface or a class . If it is a class then it must not be final and it must have a public no - arg constructor .
3,138
@ SuppressWarnings ( "unchecked" ) public SearchKeyFactory < S > getSearchKeyFactory ( OrderedProperty < S > [ ] properties ) { Object key = KeyFactory . createKey ( new Object [ ] { mCodecKey , properties } ) ; synchronized ( cCodecSearchKeyFactories ) { SearchKeyFactory < S > factory = ( SearchKeyFactory < S > ) cCod...
Returns a search key factory which is useful for implementing indexes and queries .
3,139
public Decoder < S > getDecoder ( int generation ) throws FetchNoneException , FetchException { try { synchronized ( mLayout ) { IntHashMap decoders = mDecoders ; if ( decoders == null ) { mDecoders = decoders = new IntHashMap ( ) ; } Decoder < S > decoder = ( Decoder < S > ) decoders . get ( generation ) ; if ( decode...
Returns a data decoder for the given generation .
3,140
public static < S > Cursor < S > apply ( Cursor < S > source , Query . Controller controller ) { return controller == null ? source : new ControllerCursor < S > ( source , controller ) ; }
Returns a ControllerCursor depending on whether a controller instance is passed in or not .
3,141
public void AddProtected ( HeaderKeys label , byte [ ] value ) throws CoseException { addAttribute ( label , value , PROTECTED ) ; }
Set an attribute in the protect bucket of the COSE object
3,142
public void AddUnprotected ( CBORObject label , CBORObject value ) throws CoseException { addAttribute ( label , value , UNPROTECTED ) ; }
Set an attribute in the unprotected bucket of the COSE object
3,143
public void removeAttribute ( CBORObject label ) throws CoseException { if ( objProtected . ContainsKey ( label ) ) { if ( rgbProtected != null ) throw new CoseException ( "Operation would modify integrity protected attributes" ) ; objProtected . Remove ( label ) ; } if ( objUnprotected . ContainsKey ( label ) ) objUnp...
Remove an attribute from the set of all attribute maps .
3,144
private static void callSetPropertyValue ( CodeBuilder b , OrderedProperty < ? > op ) { StorableProperty < ? > property = op . getChainedProperty ( ) . getLastProperty ( ) ; TypeDesc propType = TypeDesc . forClass ( property . getType ( ) ) ; if ( propType != TypeDesc . OBJECT ) { TypeDesc objectType = propType . toObj...
Creates code to call set method . Assumes Storable and property value are already on the stack .
3,145
static < S extends Storable > BlobReplicationTrigger < S > create ( Storage < S > masterStorage ) { Map < String , ? extends StorableProperty < S > > properties = StorableIntrospector . examine ( masterStorage . getStorableType ( ) ) . getDataProperties ( ) ; List < String > blobNames = new ArrayList < String > ( 2 ) ;...
Returns null if no Blobs need to be replicated .
3,146
public void sign ( OneKey key ) throws CoseException { if ( rgbContent == null ) throw new CoseException ( "No Content Specified" ) ; if ( rgbSignature != null ) return ; if ( rgbProtected == null ) { if ( objProtected . size ( ) > 0 ) rgbProtected = objProtected . EncodeToBytes ( ) ; else rgbProtected = new byte [ 0 ]...
Create a signature for the message if one does not exist .
3,147
public boolean validate ( OneKey cnKey ) throws CoseException { CBORObject obj = CBORObject . NewArray ( ) ; obj . Add ( contextString ) ; if ( objProtected . size ( ) > 0 ) obj . Add ( rgbProtected ) ; else obj . Add ( CBORObject . FromObject ( new byte [ 0 ] ) ) ; obj . Add ( externalData ) ; obj . Add ( rgbContent )...
Validate the signature on the message using the passed in key .
3,148
private Label addEnterTransaction ( CodeBuilder b , String opType , LocalVariable txnVar ) { if ( ! alwaysHasTxn ( opType ) ) { return null ; } TypeDesc repositoryType = TypeDesc . forClass ( Repository . class ) ; TypeDesc transactionType = TypeDesc . forClass ( Transaction . class ) ; TypeDesc triggerSupportType = Ty...
Generates code to enter a transaction if required and if none in progress .
3,149
private void unsetVersionProperty ( CodeBuilder b ) throws SupportException { StorableProperty < ? > property = mInfo . getVersionProperty ( ) ; { String stateFieldName = StorableGenerator . PROPERTY_STATE_FIELD_NAME + ( property . getNumber ( ) >> 4 ) ; b . loadThis ( ) ; b . loadThis ( ) ; b . loadField ( stateFieldN...
Sets the version property to its initial uninitialized state .
3,150
private void addNormalizationRollback ( CodeBuilder b , Label doTryStart , List < PropertyCopy > unnormalized ) { if ( unnormalized == null ) { return ; } Label doTryEnd = b . createLabel ( ) . setLocation ( ) ; b . dup ( ) ; Label success = b . createLabel ( ) ; b . ifZeroComparisonBranch ( success , "!=" ) ; for ( in...
Assumes a boolean is on the stack as returned by doTryInsert or doTryUpdate .
3,151
protected CBORObject EncodeCBORObject ( ) throws CoseException { if ( rgbEncrypt == null ) throw new CoseException ( "Encrypt function not called" ) ; CBORObject obj = CBORObject . NewArray ( ) ; if ( objProtected . size ( ) > 0 ) obj . Add ( objProtected . EncodeToBytes ( ) ) ; else obj . Add ( CBORObject . FromObject...
Internal function used to construct the CBORObject
3,152
public static int encodeDesc ( Integer value , byte [ ] dst , int dstOffset ) { if ( value == null ) { dst [ dstOffset ] = NULL_BYTE_LOW ; return 1 ; } else { dst [ dstOffset ] = NOT_NULL_BYTE_LOW ; DataEncoder . encode ( ~ value . intValue ( ) , dst , dstOffset + 1 ) ; return 5 ; } }
Encodes the given signed Integer object into exactly 1 or 5 bytes for descending order . If the Integer object is never expected to be null consider encoding as an int primitive .
3,153
public static int encodeDesc ( Long value , byte [ ] dst , int dstOffset ) { if ( value == null ) { dst [ dstOffset ] = NULL_BYTE_LOW ; return 1 ; } else { dst [ dstOffset ] = NOT_NULL_BYTE_LOW ; DataEncoder . encode ( ~ value . longValue ( ) , dst , dstOffset + 1 ) ; return 9 ; } }
Encodes the given signed Long object into exactly 1 or 9 bytes for descending order . If the Long object is never expected to be null consider encoding as a long primitive .
3,154
public static int encodeDesc ( Byte value , byte [ ] dst , int dstOffset ) { if ( value == null ) { dst [ dstOffset ] = NULL_BYTE_LOW ; return 1 ; } else { dst [ dstOffset ] = NOT_NULL_BYTE_LOW ; dst [ dstOffset + 1 ] = ( byte ) ( value ^ 0x7f ) ; return 2 ; } }
Encodes the given signed Byte object into exactly 1 or 2 bytes for descending order . If the Byte object is never expected to be null consider encoding as a byte primitive .
3,155
public static int encodeDesc ( Short value , byte [ ] dst , int dstOffset ) { if ( value == null ) { dst [ dstOffset ] = NULL_BYTE_LOW ; return 1 ; } else { dst [ dstOffset ] = NOT_NULL_BYTE_LOW ; DataEncoder . encode ( ( short ) ~ value . shortValue ( ) , dst , dstOffset + 1 ) ; return 3 ; } }
Encodes the given signed Short object into exactly 1 or 3 bytes for descending order . If the Short object is never expected to be null consider encoding as a short primitive .
3,156
public static int encodeDesc ( Character value , byte [ ] dst , int dstOffset ) { if ( value == null ) { dst [ dstOffset ] = NULL_BYTE_LOW ; return 1 ; } else { dst [ dstOffset ] = NOT_NULL_BYTE_LOW ; DataEncoder . encode ( ( char ) ~ value . charValue ( ) , dst , dstOffset + 1 ) ; return 3 ; } }
Encodes the given Character object into exactly 1 or 3 bytes for descending order . If the Character object is never expected to be null consider encoding as a char primitive .
3,157
public static void encodeDesc ( Boolean value , byte [ ] dst , int dstOffset ) { if ( value == null ) { dst [ dstOffset ] = NULL_BYTE_LOW ; } else { dst [ dstOffset ] = value . booleanValue ( ) ? ( byte ) 127 : ( byte ) 128 ; } }
Encodes the given Boolean object into exactly 1 byte for descending order .
3,158
public static void encodeDesc ( float value , byte [ ] dst , int dstOffset ) { int bits = Float . floatToIntBits ( value ) ; if ( bits >= 0 ) { bits ^= 0x7fffffff ; } dst [ dstOffset ] = ( byte ) ( bits >> 24 ) ; dst [ dstOffset + 1 ] = ( byte ) ( bits >> 16 ) ; dst [ dstOffset + 2 ] = ( byte ) ( bits >> 8 ) ; dst [ ds...
Encodes the given float into exactly 4 bytes for descending order .
3,159
public static void encodeDesc ( Float value , byte [ ] dst , int dstOffset ) { if ( value == null ) { DataEncoder . encode ( ~ 0x7fffffff , dst , dstOffset ) ; } else { encodeDesc ( value . floatValue ( ) , dst , dstOffset ) ; } }
Encodes the given Float object into exactly 4 bytes for descending order . A non - canonical NaN value is used to represent null .
3,160
public static void encodeDesc ( double value , byte [ ] dst , int dstOffset ) { long bits = Double . doubleToLongBits ( value ) ; if ( bits >= 0 ) { bits ^= 0x7fffffffffffffffL ; } int w = ( int ) ( bits >> 32 ) ; dst [ dstOffset ] = ( byte ) ( w >> 24 ) ; dst [ dstOffset + 1 ] = ( byte ) ( w >> 16 ) ; dst [ dstOffset ...
Encodes the given double into exactly 8 bytes for descending order .
3,161
public static void encodeDesc ( Double value , byte [ ] dst , int dstOffset ) { if ( value == null ) { DataEncoder . encode ( ~ 0x7fffffffffffffffL , dst , dstOffset ) ; } else { encodeDesc ( value . doubleValue ( ) , dst , dstOffset ) ; } }
Encodes the given Double object into exactly 8 bytes for descending order . A non - canonical NaN value is used to represent null .
3,162
public static int encodeDesc ( BigInteger value , byte [ ] dst , int dstOffset ) { if ( value == null ) { dst [ dstOffset ] = NULL_BYTE_LOW ; return 1 ; } byte [ ] bytes = value . toByteArray ( ) ; int bytesLength = bytes . length ; int headerSize ; if ( bytesLength < 0x7f ) { if ( value . signum ( ) < 0 ) { dst [ dstO...
Encodes the given optional BigInteger into a variable amount of bytes for descending order . If the BigInteger is null exactly 1 byte is written . Otherwise the amount written can be determined by calling calculateEncodedLength .
3,163
public static int calculateEncodedLength ( BigInteger value ) { if ( value == null ) { return 1 ; } int bytesLength = ( value . bitLength ( ) >> 3 ) + 1 ; return bytesLength < 0x7f ? ( 1 + bytesLength ) : ( 5 + bytesLength ) ; }
Returns the amount of bytes required to encode a BigInteger .
3,164
public static int encodeDesc ( BigDecimal value , byte [ ] dst , int dstOffset ) { if ( value == null ) { dst [ dstOffset ] = NULL_BYTE_LOW ; return 1 ; } if ( value . signum ( ) == 0 ) { dst [ dstOffset ] = ( byte ) 0x7f ; return 1 ; } return encode ( value ) . copyDescTo ( dst , dstOffset ) ; }
Encodes the given optional BigDecimal into a variable amount of bytes for descending order . If the BigDecimal is null exactly 1 byte is written . Otherwise the amount written can be determined by calling calculateEncodedLength .
3,165
public static int calculateEncodedLength ( BigDecimal value ) { if ( value == null || value . signum ( ) == 0 ) { return 1 ; } return encode ( value ) . mLength ; }
Returns the amount of bytes required to encode a BigDecimal .
3,166
public static int encode ( byte [ ] value , int valueOffset , int valueLength , byte [ ] dst , int dstOffset ) { return encode ( value , valueOffset , valueLength , dst , dstOffset , 0 ) ; }
Encodes the given optional unsigned byte array into a variable amount of bytes . If the byte array is null exactly 1 byte is written . Otherwise the amount written can be determined by calling calculateEncodedLength .
3,167
public static int encodeDesc ( byte [ ] value , byte [ ] dst , int dstOffset ) { if ( value == null ) { dst [ dstOffset ] = NULL_BYTE_LOW ; return 1 ; } return encode ( value , 0 , value . length , dst , dstOffset , - 1 ) ; }
Encodes the given optional unsigned byte array into a variable amount of bytes for descending order . If the byte array is null exactly 1 byte is written . Otherwise the amount written is determined by calling calculateEncodedLength .
3,168
private static void emitDigit ( int value , byte [ ] dst , int dstOffset , int xorMask ) { int a = ( value * 21845 ) >> 22 ; int b = value - ( ( a << 7 ) + ( a << 6 ) ) ; if ( b == 192 ) { a ++ ; b = 0 ; } dst [ dstOffset ++ ] = ( byte ) ( ( a + 32 ) ^ xorMask ) ; dst [ dstOffset ] = ( byte ) ( ( b + 32 ) ^ xorMask ) ;...
Emits a base - 32768 digit using exactly two bytes . The first byte is in the range 32 .. 202 and the second byte is in the range 32 .. 223 .
3,169
public static int calculateEncodedStringLength ( String value ) { int encodedLen = 1 ; if ( value != null ) { int valueLength = value . length ( ) ; for ( int i = 0 ; i < valueLength ; i ++ ) { int c = value . charAt ( i ) ; if ( c <= ( 0x7f - 2 ) ) { encodedLen ++ ; } else if ( c <= ( 12415 - 2 ) ) { encodedLen += 2 ;...
Returns the amount of bytes required to encode the given String .
3,170
public static byte [ ] encodeSingleDesc ( byte [ ] value , int prefixPadding , int suffixPadding ) { int length = value . length ; if ( prefixPadding <= 0 && suffixPadding <= 0 && length == 0 ) { return value ; } byte [ ] dst = new byte [ prefixPadding + length + suffixPadding ] ; while ( -- length >= 0 ) { dst [ prefi...
Encodes the given byte array for use when there is only a single required property descending order whose type is a byte array . The original byte array is returned if the length and padding lengths are zero .
3,171
public static byte [ ] encodeSingleNullableDesc ( byte [ ] value , int prefixPadding , int suffixPadding ) { if ( prefixPadding <= 0 && suffixPadding <= 0 ) { if ( value == null ) { return new byte [ ] { NULL_BYTE_LOW } ; } int length = value . length ; if ( length == 0 ) { return new byte [ ] { NOT_NULL_BYTE_LOW } ; }...
Encodes the given byte array for use when there is only a single nullable property descending order whose type is a byte array .
3,172
public static void encode ( int value , byte [ ] dst , int dstOffset ) { value ^= 0x80000000 ; dst [ dstOffset ] = ( byte ) ( value >> 24 ) ; dst [ dstOffset + 1 ] = ( byte ) ( value >> 16 ) ; dst [ dstOffset + 2 ] = ( byte ) ( value >> 8 ) ; dst [ dstOffset + 3 ] = ( byte ) value ; }
Encodes the given signed integer into exactly 4 bytes .
3,173
public static int encode ( Integer value , byte [ ] dst , int dstOffset ) { if ( value == null ) { dst [ dstOffset ] = NULL_BYTE_HIGH ; return 1 ; } else { dst [ dstOffset ] = NOT_NULL_BYTE_HIGH ; encode ( value . intValue ( ) , dst , dstOffset + 1 ) ; return 5 ; } }
Encodes the given signed Integer object into exactly 1 or 5 bytes . If the Integer object is never expected to be null consider encoding as an int primitive .
3,174
public static void encode ( long value , byte [ ] dst , int dstOffset ) { int w = ( ( int ) ( value >> 32 ) ) ^ 0x80000000 ; dst [ dstOffset ] = ( byte ) ( w >> 24 ) ; dst [ dstOffset + 1 ] = ( byte ) ( w >> 16 ) ; dst [ dstOffset + 2 ] = ( byte ) ( w >> 8 ) ; dst [ dstOffset + 3 ] = ( byte ) w ; w = ( int ) value ; ds...
Encodes the given signed long into exactly 8 bytes .
3,175
public static int encode ( Long value , byte [ ] dst , int dstOffset ) { if ( value == null ) { dst [ dstOffset ] = NULL_BYTE_HIGH ; return 1 ; } else { dst [ dstOffset ] = NOT_NULL_BYTE_HIGH ; encode ( value . longValue ( ) , dst , dstOffset + 1 ) ; return 9 ; } }
Encodes the given signed Long object into exactly 1 or 9 bytes . If the Long object is never expected to be null consider encoding as a long primitive .
3,176
public static int encode ( Byte value , byte [ ] dst , int dstOffset ) { if ( value == null ) { dst [ dstOffset ] = NULL_BYTE_HIGH ; return 1 ; } else { dst [ dstOffset ] = NOT_NULL_BYTE_HIGH ; dst [ dstOffset + 1 ] = ( byte ) ( value ^ 0x80 ) ; return 2 ; } }
Encodes the given signed Byte object into exactly 1 or 2 bytes . If the Byte object is never expected to be null consider encoding as a byte primitive .
3,177
public static void encode ( short value , byte [ ] dst , int dstOffset ) { value ^= 0x8000 ; dst [ dstOffset ] = ( byte ) ( value >> 8 ) ; dst [ dstOffset + 1 ] = ( byte ) value ; }
Encodes the given signed short into exactly 2 bytes .
3,178
public static int encode ( Short value , byte [ ] dst , int dstOffset ) { if ( value == null ) { dst [ dstOffset ] = NULL_BYTE_HIGH ; return 1 ; } else { dst [ dstOffset ] = NOT_NULL_BYTE_HIGH ; encode ( value . shortValue ( ) , dst , dstOffset + 1 ) ; return 3 ; } }
Encodes the given signed Short object into exactly 1 or 3 bytes . If the Short object is never expected to be null consider encoding as a short primitive .
3,179
public static int encode ( Character value , byte [ ] dst , int dstOffset ) { if ( value == null ) { dst [ dstOffset ] = NULL_BYTE_HIGH ; return 1 ; } else { dst [ dstOffset ] = NOT_NULL_BYTE_HIGH ; encode ( value . charValue ( ) , dst , dstOffset + 1 ) ; return 3 ; } }
Encodes the given Character object into exactly 1 or 3 bytes . If the Character object is never expected to be null consider encoding as a char primitive .
3,180
public static void encode ( Boolean value , byte [ ] dst , int dstOffset ) { if ( value == null ) { dst [ dstOffset ] = NULL_BYTE_HIGH ; } else { dst [ dstOffset ] = value . booleanValue ( ) ? ( byte ) 128 : ( byte ) 127 ; } }
Encodes the given Boolean object into exactly 1 byte .
3,181
public static void encode ( float value , byte [ ] dst , int dstOffset ) { int bits = Float . floatToIntBits ( value ) ; bits ^= ( bits < 0 ) ? 0xffffffff : 0x80000000 ; dst [ dstOffset ] = ( byte ) ( bits >> 24 ) ; dst [ dstOffset + 1 ] = ( byte ) ( bits >> 16 ) ; dst [ dstOffset + 2 ] = ( byte ) ( bits >> 8 ) ; dst [...
Encodes the given float into exactly 4 bytes .
3,182
public static void encode ( Float value , byte [ ] dst , int dstOffset ) { if ( value == null ) { encode ( 0x7fffffff , dst , dstOffset ) ; } else { encode ( value . floatValue ( ) , dst , dstOffset ) ; } }
Encodes the given Float object into exactly 4 bytes . A non - canonical NaN value is used to represent null .
3,183
public static int calculateEncodedLength ( BigInteger value ) { if ( value == null ) { return 1 ; } int byteCount = ( value . bitLength ( ) >> 3 ) + 1 ; return unsignedVarIntLength ( byteCount ) + byteCount ; }
Returns the amount of bytes required to encode the given BigInteger .
3,184
public static int calculateEncodedLength ( BigDecimal value ) { if ( value == null ) { return 1 ; } return signedVarIntLength ( value . scale ( ) ) + calculateEncodedLength ( value . unscaledValue ( ) ) ; }
Returns the amount of bytes required to encode the given BigDecimal .
3,185
public static int writeLength ( int valueLength , OutputStream out ) throws IOException { if ( valueLength < 128 ) { out . write ( valueLength ) ; return 1 ; } else if ( valueLength < 16384 ) { out . write ( ( valueLength >> 8 ) | 0x80 ) ; out . write ( valueLength ) ; return 2 ; } else if ( valueLength < 2097152 ) { o...
Writes a positive length value in up to five bytes .
3,186
public static byte [ ] encodeSingle ( byte [ ] value , int prefixPadding , int suffixPadding ) { if ( prefixPadding <= 0 && suffixPadding <= 0 ) { return value ; } int length = value . length ; byte [ ] dst = new byte [ prefixPadding + length + suffixPadding ] ; System . arraycopy ( value , 0 , dst , prefixPadding , le...
Encodes the given byte array for use when there is only a single property whose type is a byte array . The original byte array is returned if the padding lengths are zero .
3,187
public static byte [ ] encodeSingleNullable ( byte [ ] value , int prefixPadding , int suffixPadding ) { if ( prefixPadding <= 0 && suffixPadding <= 0 ) { if ( value == null ) { return new byte [ ] { NULL_BYTE_HIGH } ; } int length = value . length ; if ( length == 0 ) { return new byte [ ] { NOT_NULL_BYTE_HIGH } ; } b...
Encodes the given byte array for use when there is only a single nullable property whose type is a byte array .
3,188
@ SuppressWarnings ( "unchecked" ) public < C extends Capability > C getCapability ( Class < C > capabilityType ) { if ( capabilityType . isInstance ( this ) ) { return ( C ) this ; } return null ; }
Default implementation checks if Repository implements Capability interface and if so returns the Repository .
3,189
public synchronized void setAutoShutdownEnabled ( boolean enabled ) { try { if ( mShutdownHook == null ) { if ( enabled ) { ShutdownHook hook = new ShutdownHook ( this ) ; Runtime . getRuntime ( ) . addShutdownHook ( hook ) ; mShutdownHook = hook ; } } else { if ( ! enabled ) { Runtime . getRuntime ( ) . removeShutdown...
Required by ShutdownCapability .
3,190
public final void setValidator ( final Validator < Type > validator ) { Condition . INSTANCE . ensureNotNull ( validator , "The validator may not be null" ) ; this . validator = validator ; }
Sets the validator whose result should be negated .
3,191
private void setupKey ( OneKey key ) throws CoseException { CBORObject cn2 ; CBORObject cn ; cnKey = key ; if ( rgbSignature != null ) return ; cn = key . get ( KeyKeys . Algorithm ) ; if ( cn != null ) { cn2 = findAttribute ( HeaderKeys . Algorithm ) ; if ( cn2 == null ) addAttribute ( HeaderKeys . Algorithm , cn , At...
Set the key on the object if there is not a signature on this object then set the algorithm and the key id from the key if they exist on the key and do not exist in the message .
3,192
public static Repository newRepository ( ) { try { MapRepositoryBuilder builder = new MapRepositoryBuilder ( ) ; return builder . build ( ) ; } catch ( RepositoryException e ) { throw new RuntimeException ( e ) ; } }
Convenience method to build a new MapRepository .
3,193
public void setLockTimeout ( int timeout , TimeUnit unit ) { if ( timeout < 0 || unit == null ) { throw new IllegalArgumentException ( ) ; } mLockTimeout = timeout ; mLockTimeoutUnit = unit ; }
Set the lock timeout . Default value is 500 milliseconds .
3,194
public final void setIcon ( final Context context , final int resourceId ) { Condition . INSTANCE . ensureNotNull ( context , "The context may not be null" ) ; this . icon = ContextCompat . getDrawable ( context , resourceId ) ; }
Sets the icon which should be shown if the validation fails .
3,195
private void obtainPasswordVerificationPrefix ( final TypedArray typedArray ) { String format = typedArray . getString ( R . styleable . PasswordEditText_passwordVerificationPrefix ) ; if ( format == null ) { format = getResources ( ) . getString ( R . string . password_verification_prefix ) ; } setPasswordVerification...
Obtains the prefix of helper texts which are shown depending on the password strength from a specific typed array .
3,196
private TextWatcher createTextChangeListener ( ) { return new TextWatcher ( ) { public final void beforeTextChanged ( final CharSequence s , final int start , final int count , final int after ) { } public final void onTextChanged ( final CharSequence s , final int start , final int before , final int count ) { } publi...
Creates and returns a listener which allows to verify the password strength when the password has been changed .
3,197
private void verifyPasswordStrength ( ) { if ( isEnabled ( ) && ! constraints . isEmpty ( ) && ! TextUtils . isEmpty ( getText ( ) ) ) { float score = getPasswordStrength ( ) ; adaptHelperText ( score ) ; } else { setHelperText ( regularHelperText ) ; } }
Verifies the strength of the current password depending on the constraints which have been added and adapts the appearance of the view accordingly .
3,198
private float getPasswordStrength ( ) { int absoluteScore = 0 ; CharSequence password = getView ( ) . getText ( ) ; for ( Constraint < CharSequence > constraint : constraints ) { if ( constraint . isSatisfied ( password ) ) { absoluteScore ++ ; } } return ( ( float ) absoluteScore / ( float ) constraints . size ( ) ) ;...
Returns the strength of the current password depending on the constraints which have been added .
3,199
private void adaptHelperText ( final float score ) { if ( ! helperTexts . isEmpty ( ) ) { CharSequence helperText = getHelperText ( score ) ; if ( helperText != null ) { int color = getHelperTextColor ( score ) ; helperText = "<font color=\"" + color + "\">" + helperText + "</font>" ; String prefix = getPasswordVerific...
Adapts the helper text depending on a specific password strength .