idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
3,300 | private void loadBlankValue ( CodeAssembler a , TypeDesc type ) { switch ( type . getTypeCode ( ) ) { case TypeDesc . OBJECT_CODE : a . loadNull ( ) ; break ; case TypeDesc . LONG_CODE : a . loadConstant ( 0L ) ; break ; case TypeDesc . FLOAT_CODE : a . loadConstant ( 0.0f ) ; break ; case TypeDesc . DOUBLE_CODE : a . loadConstant ( 0.0d ) ; break ; case TypeDesc . INT_CODE : default : a . loadConstant ( 0 ) ; break ; } } | Generates code that loads zero false or null to the stack . |
3,301 | private int staticEncodingLength ( GenericPropertyInfo info ) { TypeDesc type = info . getStorageType ( ) ; TypeDesc primType = type . toPrimitiveType ( ) ; if ( primType == null ) { if ( info . isLob ( ) ) { return 8 ; } } else { if ( info . isNullable ( ) ) { switch ( primType . getTypeCode ( ) ) { case TypeDesc . BYTE_CODE : return ~ 1 ; case TypeDesc . BOOLEAN_CODE : return 1 ; case TypeDesc . SHORT_CODE : case TypeDesc . CHAR_CODE : return ~ 1 ; case TypeDesc . INT_CODE : return ~ 1 ; case TypeDesc . FLOAT_CODE : return 4 ; case TypeDesc . LONG_CODE : return ~ 1 ; case TypeDesc . DOUBLE_CODE : return 8 ; } } else { switch ( type . getTypeCode ( ) ) { case TypeDesc . BYTE_CODE : case TypeDesc . BOOLEAN_CODE : return 1 ; case TypeDesc . SHORT_CODE : case TypeDesc . CHAR_CODE : return 2 ; case TypeDesc . INT_CODE : case TypeDesc . FLOAT_CODE : return 4 ; case TypeDesc . LONG_CODE : case TypeDesc . DOUBLE_CODE : return 8 ; } } } return ~ 0 ; } | Returns a negative value if encoding is variable . The minimum static amount is computed from the one s compliment . Of the types with variable encoding lengths only for primitives is the minimum static amount returned more than zero . |
3,302 | private int encodeProperty ( CodeAssembler a , TypeDesc type , Mode mode , boolean descending ) { TypeDesc [ ] params = new TypeDesc [ ] { type , TypeDesc . forClass ( byte [ ] . class ) , TypeDesc . INT } ; if ( type . isPrimitive ( ) ) { if ( mode == Mode . KEY && descending ) { a . invokeStatic ( KeyEncoder . class . getName ( ) , "encodeDesc" , null , params ) ; } else { a . invokeStatic ( DataEncoder . class . getName ( ) , "encode" , null , params ) ; } switch ( type . getTypeCode ( ) ) { case TypeDesc . BYTE_CODE : case TypeDesc . BOOLEAN_CODE : return 1 ; case TypeDesc . SHORT_CODE : case TypeDesc . CHAR_CODE : return 2 ; default : case TypeDesc . INT_CODE : case TypeDesc . FLOAT_CODE : return 4 ; case TypeDesc . LONG_CODE : case TypeDesc . DOUBLE_CODE : return 8 ; } } else if ( type . toPrimitiveType ( ) != null ) { int adjust ; TypeDesc retType ; switch ( type . toPrimitiveType ( ) . getTypeCode ( ) ) { case TypeDesc . BOOLEAN_CODE : adjust = 1 ; retType = null ; break ; case TypeDesc . FLOAT_CODE : adjust = 4 ; retType = null ; break ; case TypeDesc . DOUBLE_CODE : adjust = 8 ; retType = null ; break ; default : adjust = 0 ; retType = TypeDesc . INT ; } if ( mode == Mode . KEY && descending ) { a . invokeStatic ( KeyEncoder . class . getName ( ) , "encodeDesc" , retType , params ) ; } else { a . invokeStatic ( DataEncoder . class . getName ( ) , "encode" , retType , params ) ; } return adjust ; } else { if ( mode == Mode . KEY ) { if ( descending ) { a . invokeStatic ( KeyEncoder . class . getName ( ) , "encodeDesc" , TypeDesc . INT , params ) ; } else { a . invokeStatic ( KeyEncoder . class . getName ( ) , "encode" , TypeDesc . INT , params ) ; } } else { a . invokeStatic ( DataEncoder . class . getName ( ) , "encode" , TypeDesc . INT , params ) ; } return 0 ; } } | Generates code that calls an encoding method in DataEncoder or KeyEncoder . Parameters must already be on the stack . |
3,303 | private void encodeGeneration ( CodeAssembler a , LocalVariable encodedVar , int offset , int generation ) { if ( offset < 0 ) { throw new IllegalArgumentException ( ) ; } if ( generation < 0 ) { return ; } if ( generation < 128 ) { a . loadLocal ( encodedVar ) ; a . loadConstant ( offset ) ; a . loadConstant ( ( byte ) generation ) ; a . storeToArray ( TypeDesc . BYTE ) ; } else { generation |= 0x80000000 ; for ( int i = 0 ; i < 4 ; i ++ ) { a . loadLocal ( encodedVar ) ; a . loadConstant ( offset + i ) ; a . loadConstant ( ( byte ) ( generation >> ( 8 * ( 3 - i ) ) ) ) ; a . storeToArray ( TypeDesc . BYTE ) ; } } } | Generates code that stores a one or four byte generation value into a byte array referenced by the local variable . |
3,304 | private void getLobLocator ( CodeAssembler a , StorablePropertyInfo info ) { if ( ! info . isLob ( ) ) { throw new IllegalArgumentException ( ) ; } a . invokeInterface ( TypeDesc . forClass ( RawSupport . class ) , "getLocator" , TypeDesc . LONG , new TypeDesc [ ] { info . getStorageType ( ) } ) ; } | Generates code to get a Lob locator value from RawSupport . RawSupport instance and Lob instance must be on the stack . Result is a long locator value on the stack . |
3,305 | 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 . |
3,306 | protected void pushDecodingInstanceVar ( CodeAssembler a , int ordinal , LocalVariable instanceVar ) { if ( instanceVar == null ) { a . loadThis ( ) ; } else if ( instanceVar . getType ( ) != TypeDesc . forClass ( Object [ ] . class ) ) { a . loadLocal ( instanceVar ) ; } else { a . loadLocal ( instanceVar ) ; a . loadConstant ( ordinal ) ; } } | Push decoding instanceVar to stack in preparation to calling storePropertyValue . |
3,307 | 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 , ">=" ) ; 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 { TypeDesc corruptEncodingEx = TypeDesc . forClass ( CorruptEncodingException . class ) ; a . newObject ( corruptEncodingEx ) ; a . dup ( ) ; a . loadConstant ( generation ) ; a . loadLocal ( actualGeneration ) ; 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 . |
3,308 | 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 . |
3,309 | 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 . |
3,310 | public synchronized void shutdown ( ) { if ( mState == STATE_STOPPED ) { return ; } if ( mState == STATE_NOT_STARTED ) { mState = STATE_STOPPED ; return ; } mState = STATE_SHOULD_STOP ; 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 . |
3,311 | 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 ) ; mStoredSequence . setNextValue ( Long . MIN_VALUE ) ; if ( doUpdate ) { mStoredSequence . update ( ) ; } else { mStoredSequence . insert ( ) ; } txn . commit ( ) ; mHasReservedValues = false ; } finally { txn . exit ( ) ; } } } | Reset the sequence . |
3,312 | public boolean returnReservedValues ( ) throws FetchException , PersistException { synchronized ( mStoredSequence ) { if ( mHasReservedValues ) { Transaction txn = mRepository . enterTopTransaction ( null ) ; txn . setForUpdate ( true ) ; try { 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 . |
3,313 | 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 { mStoredSequence . load ( ) ; long next = mStoredSequence . getNextValue ( ) ; long nextStored = next + mReserveAmount * mIncrement ; if ( next >= 0 && nextStored < 0 ) { long avail = ( Long . MAX_VALUE - next ) / mIncrement ; if ( avail > 0 ) { nextStored = next + avail * mIncrement ; } else { 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 |
3,314 | 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 . |
3,315 | 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 . |
3,316 | 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 ( ) ; } 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 . |
3,317 | 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 . |
3,318 | 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 . |
3,319 | 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 . |
3,320 | 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 . |
3,321 | 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 . |
3,322 | 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 . |
3,323 | 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 . |
3,324 | 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 . |
3,325 | 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 . |
3,326 | 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 ) { 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 . |
3,327 | 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 . |
3,328 | 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 |
3,329 | 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 . |
3,330 | 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 . |
3,331 | 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 . |
3,332 | 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 . |
3,333 | 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 . |
3,334 | 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 . |
3,335 | 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 . |
3,336 | 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 . |
3,337 | 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 . |
3,338 | 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 . |
3,339 | 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 . |
3,340 | 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 . |
3,341 | 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 . |
3,342 | 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 . |
3,343 | 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 ) ; } | Decodes a double from exactly 8 bytes as encoded for descending order . |
3,344 | 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 . |
3,345 | 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 . |
3,346 | 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 . |
3,347 | 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 . |
3,348 | 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 . |
3,349 | 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 . |
3,350 | @ 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 . |
3,351 | private static int nextSep ( String desc , int pos ) { int pos2 = desc . length ( ) ; 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 |
3,352 | 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 . |
3,353 | @ 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 . |
3,354 | 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 . |
3,355 | 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 . |
3,356 | public StorableIndex < S > reverse ( ) { Direction [ ] directions = mDirections ; specified : { for ( int i = directions . length ; -- i >= 0 ; ) { if ( directions [ i ] != Direction . UNSPECIFIED ) { break specified ; } } 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 . |
3,357 | public StorableIndex < S > setDefaultDirection ( Direction direction ) { Direction [ ] directions = mDirections ; unspecified : { for ( int i = directions . length ; -- i >= 0 ; ) { if ( directions [ i ] == Direction . UNSPECIFIED ) { break unspecified ; } } 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 . |
3,358 | 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 . |
3,359 | 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 ( ) ; } | 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 . |
3,360 | 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 . |
3,361 | private void obtainMaxNumberOfCharacters ( 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 . |
3,362 | 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 ) { } 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 . |
3,363 | 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 . |
3,364 | 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 . |
3,365 | 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 . |
3,366 | 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 . |
3,367 | public boolean isConsistent ( Storable reference , S master ) throws FetchException { try { return ( Boolean ) mIsConsistentMethod . invoke ( reference , master ) ; } catch ( Exception e ) { ThrowUnchecked . fireFirstDeclaredCause ( e , FetchException . class ) ; 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 . |
3,368 | 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 . |
3,369 | 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 . |
3,370 | 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 . |
3,371 | 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 . |
3,372 | 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 ) { scope . getLock ( ) . lock ( ) ; } } return scope ; } | Returns the thread - local TransactionScope creating it if needed . |
3,373 | public synchronized void close ( boolean suspend ) throws RepositoryException { if ( mState == SUSPENDED ) { return ; } if ( suspend ) { for ( TransactionScope < ? > scope : mAllScopes . keySet ( ) ) { 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 . |
3,374 | @ 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 . |
3,375 | 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 ; } 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 ; } } } StorablePropertyAdapter adapter = property . getAdapter ( ) ; if ( adapter != null ) { Method [ ] toMethods = adapter . findAdaptMethodsTo ( property . getType ( ) ) ; for ( Method toMethod : toMethods ) { Class fromType = toMethod . getParameterTypes ( ) [ 0 ] ; if ( adapter . findAdaptMethod ( property . getType ( ) , fromType ) != null ) { 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 . |
3,376 | 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 . |
3,377 | 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 ) ) { 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 . |
3,378 | 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 . |
3,379 | 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 . |
3,380 | public Object get ( QueryHint hint ) { return hint == null ? null : ( mMap == null ? null : mMap . get ( hint ) ) ; } | Returns null if hint is not provided . |
3,381 | 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 . |
3,382 | 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 . |
3,383 | 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 . |
3,384 | 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 . |
3,385 | 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 . |
3,386 | 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 . |
3,387 | private void obtainHintColor ( 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 . |
3,388 | private OnItemSelectedListener createItemSelectedListener ( ) { return new OnItemSelectedListener ( ) { 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 ( ) ; } } 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 . |
3,389 | public final void setHint ( 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 . |
3,390 | 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 . |
3,391 | @ 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 . |
3,392 | 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 . |
3,393 | 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 . |
3,394 | 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 . |
3,395 | 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 . |
3,396 | 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 . |
3,397 | 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 ( ) && 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 . |
3,398 | 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 . |
3,399 | 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 ) { 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 . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.