idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
3,500
public Method [ ] findAdaptMethodsFrom ( Class from ) { Method [ ] methods = mAdaptMethods ; List < Method > candidates = new ArrayList < Method > ( methods . length ) ; for ( int i = methods . length ; -- i >= 0 ; ) { Method method = methods [ i ] ; if ( method . getParameterTypes ( ) [ 0 ] . isAssignableFrom ( from ) ) { candidates . add ( method ) ; } } return ( Method [ ] ) candidates . toArray ( new Method [ candidates . size ( ) ] ) ; }
Returns all the adapt methods that convert from the given type .
3,501
@ SuppressWarnings ( "unchecked" ) public Method [ ] findAdaptMethodsTo ( Class to ) { Method [ ] methods = mAdaptMethods ; List < Method > candidates = new ArrayList < Method > ( methods . length ) ; for ( int i = methods . length ; -- i >= 0 ; ) { Method method = methods [ i ] ; if ( to . isAssignableFrom ( method . getReturnType ( ) ) ) { candidates . add ( method ) ; } } reduceCandidates ( candidates , to ) ; return ( Method [ ] ) candidates . toArray ( new Method [ candidates . size ( ) ] ) ; }
Returns all the adapt methods that convert to the given type .
3,502
public static < Type > ConjunctiveConstraint < Type > create ( final Constraint < Type > [ ] constraints ) { return new ConjunctiveConstraint < > ( constraints ) ; }
Creates and returns a constraint which allows to combine multiple constraints in a conjunctive manner .
3,503
protected < S extends Storable > GenericEncodingStrategy < S > createStrategy ( Class < S > type , StorableIndex < S > pkIndex ) throws SupportException { return new GenericEncodingStrategy < S > ( type , pkIndex ) ; }
Override to return a different EncodingStrategy .
3,504
public static < T > Comparator < T > arrayComparator ( Class < T > arrayType , boolean unsigned ) { if ( ! arrayType . isArray ( ) ) { throw new IllegalArgumentException ( ) ; } Comparator c ; TypeDesc componentType = TypeDesc . forClass ( arrayType . getComponentType ( ) ) ; switch ( componentType . getTypeCode ( ) ) { case TypeDesc . BYTE_CODE : c = unsigned ? UnsignedByteArray : SignedByteArray ; break ; case TypeDesc . SHORT_CODE : c = unsigned ? UnsignedShortArray : SignedShortArray ; break ; case TypeDesc . INT_CODE : c = unsigned ? UnsignedIntArray : SignedIntArray ; break ; case TypeDesc . LONG_CODE : c = unsigned ? UnsignedLongArray : SignedLongArray ; break ; case TypeDesc . BOOLEAN_CODE : c = BooleanArray ; break ; case TypeDesc . CHAR_CODE : c = CharArray ; break ; case TypeDesc . FLOAT_CODE : c = FloatArray ; break ; case TypeDesc . DOUBLE_CODE : c = DoubleArray ; break ; case TypeDesc . OBJECT_CODE : default : if ( componentType . isArray ( ) ) { c = new ComparatorArray ( arrayComparator ( componentType . toClass ( ) , unsigned ) ) ; } else if ( Comparable . class . isAssignableFrom ( componentType . toClass ( ) ) ) { c = ComparableArray ; } else { c = null ; } break ; } return ( Comparator < T > ) c ; }
Returns a comparator which can sort single or multi - dimensional arrays of primitves or Comparables .
3,505
public static < S extends Storable > Filter < S > filterFor ( Class < S > type , String expression ) { SoftValuedCache < Object , Filter < S > > filterCache = getFilterCache ( type ) ; synchronized ( filterCache ) { Filter < S > filter = filterCache . get ( expression ) ; if ( filter == null ) { filter = new FilterParser < S > ( type , expression ) . parseRoot ( ) ; filterCache . put ( expression , filter ) ; } return filter ; } }
Returns a cached filter instance that operates on the given type and filter expression .
3,506
public static < S extends Storable > OpenFilter < S > getOpenFilter ( Class < S > type ) { SoftValuedCache < Object , Filter < S > > filterCache = getFilterCache ( type ) ; synchronized ( filterCache ) { Filter < S > filter = filterCache . get ( OPEN_KEY ) ; if ( filter == null ) { filter = OpenFilter . getCanonical ( type ) ; filterCache . put ( OPEN_KEY , filter ) ; } return ( OpenFilter < S > ) filter ; } }
Returns a cached filter instance that operates on the given type which allows all results to pass through .
3,507
public static < S extends Storable > ClosedFilter < S > getClosedFilter ( Class < S > type ) { SoftValuedCache < Object , Filter < S > > filterCache = getFilterCache ( type ) ; synchronized ( filterCache ) { Filter < S > filter = filterCache . get ( CLOSED_KEY ) ; if ( filter == null ) { filter = ClosedFilter . getCanonical ( type ) ; filterCache . put ( CLOSED_KEY , filter ) ; } return ( ClosedFilter < S > ) filter ; } }
Returns a cached filter instance that operates on the given type which prevents any results from passing through .
3,508
public FilterValues < S > initialFilterValues ( ) { FilterValues < S > filterValues = mFilterValues ; if ( filterValues == null ) { buildFilterValues ( ) ; filterValues = mFilterValues ; } return filterValues ; }
Returns a FilterValues instance for assigning values to a Filter . Returns null if Filter has no parameters .
3,509
PropertyFilterList < S > getTailPropertyFilterList ( ) { PropertyFilterList < S > tail = mTailPropertyFilterList ; if ( tail == null ) { buildFilterValues ( ) ; tail = mTailPropertyFilterList ; } return tail ; }
Returns tail of linked list and so it can only be traversed by getting previous nodes .
3,510
public final Filter < S > andExists ( String propertyName , Filter < ? > subFilter ) { ChainedProperty < S > prop = new FilterParser < S > ( mType , propertyName ) . parseChainedProperty ( ) ; return and ( ExistsFilter . build ( prop , subFilter , false ) ) ; }
Returns a combined filter instance that accepts records which are only accepted by this filter and the exists test applied to a join .
3,511
public final Filter < S > andNotExists ( String propertyName , Filter < ? > subFilter ) { ChainedProperty < S > prop = new FilterParser < S > ( mType , propertyName ) . parseChainedProperty ( ) ; return and ( ExistsFilter . build ( prop , subFilter , true ) ) ; }
Returns a combined filter instance that accepts records which are only accepted by this filter and the not exists test applied to a join .
3,512
public final Filter < S > orExists ( String propertyName , Filter < ? > subFilter ) { ChainedProperty < S > prop = new FilterParser < S > ( mType , propertyName ) . parseChainedProperty ( ) ; return or ( ExistsFilter . build ( prop , subFilter , false ) ) ; }
Returns a combined filter instance that accepts records which are accepted either by this filter or the exists test applied to a join .
3,513
public final Filter < S > orNotExists ( String propertyName , Filter < ? > subFilter ) { ChainedProperty < S > prop = new FilterParser < S > ( mType , propertyName ) . parseChainedProperty ( ) ; return or ( ExistsFilter . build ( prop , subFilter , true ) ) ; }
Returns a combined filter instance that accepts records which are accepted either by this filter or the not exists test applied to a join .
3,514
public List < Filter < S > > disjunctiveNormalFormSplit ( ) { final List < Filter < S > > list = new ArrayList < Filter < S > > ( ) ; disjunctiveNormalForm ( ) . accept ( new Visitor < S , Object , Object > ( ) { public Object visit ( AndFilter < S > filter , Object param ) { list . add ( filter ) ; return null ; } public Object visit ( PropertyFilter < S > filter , Object param ) { list . add ( filter ) ; return null ; } public Object visit ( ExistsFilter < S > filter , Object param ) { list . add ( filter ) ; return null ; } } , null ) ; return Collections . unmodifiableList ( list ) ; }
Splits the filter from its disjunctive normal form . Or ng the filters together produces the full disjunctive normal form .
3,515
public List < Filter < S > > conjunctiveNormalFormSplit ( ) { final List < Filter < S > > list = new ArrayList < Filter < S > > ( ) ; conjunctiveNormalForm ( ) . accept ( new Visitor < S , Object , Object > ( ) { public Object visit ( OrFilter < S > filter , Object param ) { list . add ( filter ) ; return null ; } public Object visit ( PropertyFilter < S > filter , Object param ) { list . add ( filter ) ; return null ; } public Object visit ( ExistsFilter < S > filter , Object param ) { list . add ( filter ) ; return null ; } } , null ) ; return Collections . unmodifiableList ( list ) ; }
Splits the filter from its conjunctive normal form . And ng the filters together produces the full conjunctive normal form .
3,516
NotJoined notJoinedFromCNF ( ChainedProperty < S > joinProperty ) { return new NotJoined ( getOpenFilter ( joinProperty . getLastProperty ( ) . getJoinedType ( ) ) , this ) ; }
Should only be called on a filter in conjunctive normal form .
3,517
public static int decodeInt ( byte [ ] src , int srcOffset ) throws CorruptEncodingException { try { int value = ( src [ srcOffset ] << 24 ) | ( ( src [ srcOffset + 1 ] & 0xff ) << 16 ) | ( ( src [ srcOffset + 2 ] & 0xff ) << 8 ) | ( src [ srcOffset + 3 ] & 0xff ) ; return value ^ 0x80000000 ; } catch ( IndexOutOfBoundsException e ) { throw new CorruptEncodingException ( null , e ) ; } }
Decodes a signed integer from exactly 4 bytes .
3,518
public static Integer decodeIntegerObj ( byte [ ] src , int srcOffset ) throws CorruptEncodingException { try { int b = src [ srcOffset ] ; if ( b == NULL_BYTE_HIGH || b == NULL_BYTE_LOW ) { return null ; } return decodeInt ( src , srcOffset + 1 ) ; } catch ( IndexOutOfBoundsException e ) { throw new CorruptEncodingException ( null , e ) ; } }
Decodes a signed Integer object from exactly 1 or 5 bytes . If null is returned then 1 byte was read .
3,519
public static long decodeLong ( byte [ ] src , int srcOffset ) throws CorruptEncodingException { try { return ( ( ( long ) ( ( ( src [ srcOffset ] ) << 24 ) | ( ( src [ srcOffset + 1 ] & 0xff ) << 16 ) | ( ( src [ srcOffset + 2 ] & 0xff ) << 8 ) | ( ( src [ srcOffset + 3 ] & 0xff ) ) ) ^ 0x80000000 ) << 32 ) | ( ( ( long ) ( ( ( src [ srcOffset + 4 ] ) << 24 ) | ( ( src [ srcOffset + 5 ] & 0xff ) << 16 ) | ( ( src [ srcOffset + 6 ] & 0xff ) << 8 ) | ( ( src [ srcOffset + 7 ] & 0xff ) ) ) & 0xffffffffL ) ) ; } catch ( IndexOutOfBoundsException e ) { throw new CorruptEncodingException ( null , e ) ; } }
Decodes a signed long from exactly 8 bytes .
3,520
public static Long decodeLongObj ( byte [ ] src , int srcOffset ) throws CorruptEncodingException { try { int b = src [ srcOffset ] ; if ( b == NULL_BYTE_HIGH || b == NULL_BYTE_LOW ) { return null ; } return decodeLong ( src , srcOffset + 1 ) ; } catch ( IndexOutOfBoundsException e ) { throw new CorruptEncodingException ( null , e ) ; } }
Decodes a signed Long object from exactly 1 or 9 bytes . If null is returned then 1 byte was read .
3,521
public static byte decodeByte ( byte [ ] src , int srcOffset ) throws CorruptEncodingException { try { return ( byte ) ( src [ srcOffset ] ^ 0x80 ) ; } catch ( IndexOutOfBoundsException e ) { throw new CorruptEncodingException ( null , e ) ; } }
Decodes a signed byte from exactly 1 byte .
3,522
public static Byte decodeByteObj ( byte [ ] src , int srcOffset ) throws CorruptEncodingException { try { int b = src [ srcOffset ] ; if ( b == NULL_BYTE_HIGH || b == NULL_BYTE_LOW ) { return null ; } return decodeByte ( src , srcOffset + 1 ) ; } catch ( IndexOutOfBoundsException e ) { throw new CorruptEncodingException ( null , e ) ; } }
Decodes a signed Byte object from exactly 1 or 2 bytes . If null is returned then 1 byte was read .
3,523
public static short decodeShort ( byte [ ] src , int srcOffset ) throws CorruptEncodingException { try { return ( short ) ( ( ( src [ srcOffset ] << 8 ) | ( src [ srcOffset + 1 ] & 0xff ) ) ^ 0x8000 ) ; } catch ( IndexOutOfBoundsException e ) { throw new CorruptEncodingException ( null , e ) ; } }
Decodes a signed short from exactly 2 bytes .
3,524
public static Short decodeShortObj ( byte [ ] src , int srcOffset ) throws CorruptEncodingException { try { int b = src [ srcOffset ] ; if ( b == NULL_BYTE_HIGH || b == NULL_BYTE_LOW ) { return null ; } return decodeShort ( src , srcOffset + 1 ) ; } catch ( IndexOutOfBoundsException e ) { throw new CorruptEncodingException ( null , e ) ; } }
Decodes a signed Short object from exactly 1 or 3 bytes . If null is returned then 1 byte was read .
3,525
public static char decodeChar ( 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 .
3,526
public static Character decodeCharacterObj ( byte [ ] src , int srcOffset ) throws CorruptEncodingException { try { int b = src [ srcOffset ] ; if ( b == NULL_BYTE_HIGH || b == NULL_BYTE_LOW ) { return null ; } return decodeChar ( src , srcOffset + 1 ) ; } catch ( IndexOutOfBoundsException e ) { throw new CorruptEncodingException ( null , e ) ; } }
Decodes a Character object from exactly 1 or 3 bytes . If null is returned then 1 byte was read .
3,527
public static boolean decodeBoolean ( byte [ ] src , int srcOffset ) throws CorruptEncodingException { try { return src [ srcOffset ] == ( byte ) 128 ; } catch ( IndexOutOfBoundsException e ) { throw new CorruptEncodingException ( null , e ) ; } }
Decodes a boolean from exactly 1 byte .
3,528
public static Boolean decodeBooleanObj ( byte [ ] src , int srcOffset ) throws CorruptEncodingException { try { switch ( src [ srcOffset ] ) { case NULL_BYTE_LOW : case NULL_BYTE_HIGH : return null ; case ( byte ) 128 : return Boolean . TRUE ; default : return Boolean . FALSE ; } } catch ( IndexOutOfBoundsException e ) { throw new CorruptEncodingException ( null , e ) ; } }
Decodes a Boolean object from exactly 1 byte .
3,529
public static float decodeFloat ( byte [ ] src , int srcOffset ) throws CorruptEncodingException { int bits = decodeFloatBits ( src , srcOffset ) ; bits ^= ( bits < 0 ) ? 0x80000000 : 0xffffffff ; return Float . intBitsToFloat ( bits ) ; }
Decodes a float from exactly 4 bytes .
3,530
public static double decodeDouble ( byte [ ] src , int srcOffset ) throws CorruptEncodingException { long bits = decodeDoubleBits ( src , srcOffset ) ; bits ^= ( bits < 0 ) ? 0x8000000000000000L : 0xffffffffffffffffL ; return Double . longBitsToDouble ( bits ) ; }
Decodes a double from exactly 8 bytes .
3,531
public static int decode ( byte [ ] src , int srcOffset , BigInteger [ ] valueRef ) throws CorruptEncodingException { byte [ ] [ ] bytesRef = new byte [ 1 ] [ ] ; int amt = decode ( src , srcOffset , bytesRef ) ; valueRef [ 0 ] = ( bytesRef [ 0 ] == null ) ? null : new BigInteger ( bytesRef [ 0 ] ) ; return amt ; }
Decodes a BigInteger .
3,532
public static int decode ( byte [ ] src , int srcOffset , BigDecimal [ ] valueRef ) throws CorruptEncodingException { try { final int originalOffset = srcOffset ; int b = src [ srcOffset ++ ] & 0xff ; if ( b >= 0xf8 ) { valueRef [ 0 ] = null ; return 1 ; } int scale ; if ( b <= 0x7f ) { scale = b ; } else if ( b <= 0xbf ) { scale = ( ( b & 0x3f ) << 8 ) | ( src [ srcOffset ++ ] & 0xff ) ; } else if ( b <= 0xdf ) { scale = ( ( b & 0x1f ) << 16 ) | ( ( src [ srcOffset ++ ] & 0xff ) << 8 ) | ( src [ srcOffset ++ ] & 0xff ) ; } else if ( b <= 0xef ) { scale = ( ( b & 0x0f ) << 24 ) | ( ( src [ srcOffset ++ ] & 0xff ) << 16 ) | ( ( src [ srcOffset ++ ] & 0xff ) << 8 ) | ( src [ srcOffset ++ ] & 0xff ) ; } else { scale = ( ( src [ srcOffset ++ ] & 0xff ) << 24 ) | ( ( src [ srcOffset ++ ] & 0xff ) << 16 ) | ( ( src [ srcOffset ++ ] & 0xff ) << 8 ) | ( src [ srcOffset ++ ] & 0xff ) ; } if ( ( scale & 1 ) != 0 ) { scale = ( ~ ( scale >> 1 ) ) | ( 1 << 31 ) ; } else { scale >>>= 1 ; } BigInteger [ ] unscaledRef = new BigInteger [ 1 ] ; int amt = decode ( src , srcOffset , unscaledRef ) ; valueRef [ 0 ] = new BigDecimal ( unscaledRef [ 0 ] , scale ) ; return ( srcOffset + amt ) - originalOffset ; } catch ( IndexOutOfBoundsException e ) { throw new CorruptEncodingException ( null , e ) ; } }
Decodes a BigDecimal .
3,533
public static int decode ( byte [ ] src , int srcOffset , byte [ ] [ ] valueRef ) throws CorruptEncodingException { try { final int originalOffset = srcOffset ; int b = src [ srcOffset ++ ] & 0xff ; if ( b >= 0xf8 ) { valueRef [ 0 ] = null ; return 1 ; } int valueLength ; if ( b <= 0x7f ) { valueLength = b ; } else if ( b <= 0xbf ) { valueLength = ( ( b & 0x3f ) << 8 ) | ( src [ srcOffset ++ ] & 0xff ) ; } else if ( b <= 0xdf ) { valueLength = ( ( b & 0x1f ) << 16 ) | ( ( src [ srcOffset ++ ] & 0xff ) << 8 ) | ( src [ srcOffset ++ ] & 0xff ) ; } else if ( b <= 0xef ) { valueLength = ( ( b & 0x0f ) << 24 ) | ( ( src [ srcOffset ++ ] & 0xff ) << 16 ) | ( ( src [ srcOffset ++ ] & 0xff ) << 8 ) | ( src [ srcOffset ++ ] & 0xff ) ; } else { valueLength = ( ( src [ srcOffset ++ ] & 0xff ) << 24 ) | ( ( src [ srcOffset ++ ] & 0xff ) << 16 ) | ( ( src [ srcOffset ++ ] & 0xff ) << 8 ) | ( src [ srcOffset ++ ] & 0xff ) ; } if ( valueLength == 0 ) { valueRef [ 0 ] = EMPTY_BYTE_ARRAY ; } else { byte [ ] value = new byte [ valueLength ] ; System . arraycopy ( src , srcOffset , value , 0 , valueLength ) ; valueRef [ 0 ] = value ; } return srcOffset - originalOffset + valueLength ; } catch ( IndexOutOfBoundsException e ) { throw new CorruptEncodingException ( null , e ) ; } }
Decodes the given byte array .
3,534
public static void readFully ( InputStream in , byte [ ] b ) throws IOException , EOFException { final int length = b . length ; int total = 0 ; while ( total < length ) { int amt = in . read ( b , total , length - total ) ; if ( amt < 0 ) { throw new EOFException ( ) ; } total += amt ; } }
Reads as many bytes from the stream as is necessary to fill the given byte array . An EOFException is thrown if the stream end is encountered .
3,535
public static < Type > Constraint < Type > conjunctive ( final Constraint < Type > ... constraints ) { return ConjunctiveConstraint . create ( constraints ) ; }
Creates and returns a constraint which allows to combine multiple constraints in a conjunctive manner . Only if all single constraints are satisfied the resulting constraint will also be satisfied .
3,536
public static < Type > Constraint < Type > disjunctive ( final Constraint < Type > ... constraints ) { return DisjunctiveConstraint . create ( constraints ) ; }
Creates and returns a constraint which allows to combine multiple constraints in a disjunctive manner . If at least one constraint is satisfied the resulting constraint will also be satisfied .
3,537
public static < S extends Storable > SyntheticStorableReferenceAccess < S > getIndexAccess ( StorableIndex < S > index ) throws SupportException { index = index . clustered ( false ) ; synchronized ( cCache ) { SyntheticStorableReferenceAccess < S > access = cCache . get ( index ) ; if ( access != null ) { return access ; } Class < S > type = index . getProperty ( 0 ) . getEnclosingType ( ) ; SyntheticStorableReferenceBuilder < S > builder = new SyntheticStorableReferenceBuilder < S > ( type , index . isUnique ( ) ) ; for ( int i = 0 ; i < index . getPropertyCount ( ) ; i ++ ) { StorableProperty < S > source = index . getProperty ( i ) ; builder . addKeyProperty ( source . getName ( ) , index . getPropertyDirection ( i ) ) ; } builder . build ( ) ; access = builder . getReferenceAccess ( ) ; cCache . put ( index , access ) ; return access ; } }
Returns a new or cached index access instance . The caching of accessors is soft so if no references remain to a given instance it may be garbage collected . A subsequent call will return a newly created instance .
3,538
public void forceCheckpoint ( ) throws PersistException { if ( mCheckpointer != null ) { mCheckpointer . forceCheckpoint ( ) ; } else { try { env_checkpoint ( ) ; } catch ( Exception e ) { throw toPersistException ( e ) ; } } }
Forces a checkpoint to run now even if checkpointer is suspended or disabled . If a checkpoint is in progress then this method will block until it is finished and then run another checkpoint . This method does not return until the requested checkpoint has finished .
3,539
String getDatabaseName ( String dbName ) { if ( mFileNameMap == null ) { return null ; } String name = mFileNameMap . get ( dbName ) ; if ( name == null && dbName != null ) { name = mFileNameMap . get ( null ) ; } if ( name == null ) { return null ; } if ( mDatabaseHook != null ) { try { dbName = mDatabaseHook . databaseName ( dbName ) ; } catch ( IncompatibleClassChangeError e ) { } } return dbName ; }
Returns null if name should not be used .
3,540
Integer getDatabasePageSize ( Class < ? extends Storable > type ) { if ( mDatabasePageSizes == null ) { return null ; } Integer size = mDatabasePageSizes . get ( type ) ; if ( size == null && type != null ) { size = mDatabasePageSizes . get ( null ) ; } return size ; }
Returns the desired page size for the given type or null for default .
3,541
Txn txn_begin ( Txn parent , IsolationLevel level , int timeout , TimeUnit unit ) throws Exception { return txn_begin ( parent , level ) ; }
Subclass should override this method to actually apply the timeout
3,542
@ SuppressWarnings ( "unchecked" ) public static < S extends Storable > ChainedProperty < S > get ( StorableProperty < S > prime ) { return ( ChainedProperty < S > ) cCanonical . put ( new ChainedProperty < S > ( prime , null , null ) ) ; }
Returns a canonical instance which has no chain .
3,543
public boolean isNullable ( ) { if ( mPrime . isNullable ( ) ) { return true ; } if ( mChain != null ) { for ( StorableProperty < ? > prop : mChain ) { if ( prop . isNullable ( ) ) { return true ; } } } return false ; }
Returns true if any property in the chain can be null .
3,544
public boolean isDerived ( ) { if ( mPrime . isDerived ( ) ) { return true ; } if ( mChain != null ) { for ( StorableProperty < ? > prop : mChain ) { if ( prop . isDerived ( ) ) { return true ; } } } return false ; }
Returns true if any property in the chain is derived .
3,545
public boolean isOuterJoin ( int index ) throws IndexOutOfBoundsException { if ( index < 0 ) { throw new IndexOutOfBoundsException ( ) ; } if ( mOuterJoin == null ) { if ( index > getChainCount ( ) ) { throw new IndexOutOfBoundsException ( ) ; } return false ; } return mOuterJoin [ index ] ; }
Returns true if the property at the given index should be treated as an outer join . Index zero is the prime property .
3,546
public ChainedProperty < S > trim ( ) { if ( getChainCount ( ) == 0 ) { throw new IllegalStateException ( ) ; } if ( getChainCount ( ) == 1 ) { if ( ! isOuterJoin ( 0 ) ) { return get ( mPrime ) ; } else { return get ( mPrime , null , new boolean [ ] { true } ) ; } } StorableProperty < ? > [ ] newChain = new StorableProperty [ getChainCount ( ) - 1 ] ; System . arraycopy ( mChain , 0 , newChain , 0 , newChain . length ) ; boolean [ ] newOuterJoin = mOuterJoin ; if ( newOuterJoin != null && newOuterJoin . length > ( newChain . length + 1 ) ) { newOuterJoin = new boolean [ newChain . length + 1 ] ; System . arraycopy ( mOuterJoin , 0 , newOuterJoin , 0 , newChain . length + 1 ) ; } return get ( mPrime , newChain , newOuterJoin ) ; }
Returns a new ChainedProperty with the last property in the chain removed .
3,547
public ChainedProperty < ? > tail ( ) { if ( getChainCount ( ) == 0 ) { throw new IllegalStateException ( ) ; } if ( getChainCount ( ) == 1 ) { if ( ! isOuterJoin ( 1 ) ) { return get ( mChain [ 0 ] ) ; } else { return get ( mChain [ 0 ] , null , new boolean [ ] { true } ) ; } } StorableProperty < ? > [ ] newChain = new StorableProperty [ getChainCount ( ) - 1 ] ; System . arraycopy ( mChain , 1 , newChain , 0 , newChain . length ) ; boolean [ ] newOuterJoin = mOuterJoin ; if ( newOuterJoin != null ) { newOuterJoin = new boolean [ newChain . length + 1 ] ; System . arraycopy ( mOuterJoin , 1 , newOuterJoin , 0 , mOuterJoin . length - 1 ) ; } return get ( mChain [ 0 ] , newChain , newOuterJoin ) ; }
Returns a new ChainedProperty which contains everything that follows this ChainedProperty s prime property .
3,548
private static boolean identityEquals ( Object [ ] a , Object [ ] a2 ) { if ( a == a2 ) { return true ; } if ( a == null || a2 == null ) { return false ; } int length = a . length ; if ( a2 . length != length ) { return false ; } for ( int i = 0 ; i < length ; i ++ ) { if ( a [ i ] != a2 [ i ] ) { return false ; } } return true ; }
Compares objects for equality using == operator instead of equals method .
3,549
public void appendTo ( Appendable app ) throws IOException { appendPropTo ( app , mPrime . getName ( ) , isOuterJoin ( 0 ) ) ; StorableProperty < ? > [ ] chain = mChain ; if ( chain != null ) { for ( int i = 0 ; i < chain . length ; i ++ ) { app . append ( '.' ) ; appendPropTo ( app , chain [ i ] . getName ( ) , isOuterJoin ( i + 1 ) ) ; } } }
Appends the chained property formatted as name . subname . subsubname . This format is parseable only if the chain is composed of valid many - to - one joins .
3,550
public boolean verify ( PrintStream out ) throws RepositoryException { final StorableCodecFactory codecFactory = mStorableCodecFactory ; final String name = mName ; final boolean readOnly = mReadOnly ; final boolean runCheckpointer = mRunCheckpointer ; final boolean runDeadlockDetector = mRunDeadlockDetector ; final boolean lockConflictDeadlockDetect = mLockConflictDeadlockDetect ; final boolean isPrivate = mPrivate ; if ( mName == null ) { mName = "BDB verification" ; } if ( mStorableCodecFactory == null ) { mStorableCodecFactory = new CompressedStorableCodecFactory ( mCompressionMap ) ; } mReadOnly = true ; mRunCheckpointer = false ; mRunDeadlockDetector = false ; mLockConflictDeadlockDetect = false ; try { assertReady ( ) ; File homeFile = getEnvironmentHomeFile ( ) ; if ( ! homeFile . exists ( ) ) { throw new RepositoryException ( "Environment home directory does not exist: " + homeFile ) ; } AtomicReference < Repository > rootRef = new AtomicReference < Repository > ( ) ; BDBRepository repo ; try { repo = getRepositoryConstructor ( ) . newInstance ( rootRef , this ) ; } catch ( Exception e ) { ThrowUnchecked . fireFirstDeclaredCause ( e , RepositoryException . class ) ; return false ; } rootRef . set ( repo ) ; try { return repo . verify ( out ) ; } catch ( Exception e ) { throw repo . toRepositoryException ( e ) ; } finally { repo . close ( ) ; } } finally { mName = name ; mStorableCodecFactory = codecFactory ; mReadOnly = readOnly ; mRunCheckpointer = runCheckpointer ; mRunDeadlockDetector = runDeadlockDetector ; mLockConflictDeadlockDetect = lockConflictDeadlockDetect ; } }
Opens the BDB environment checks if it is corrupt and then closes it . Only one process should open the environment for verification . Expect it to take a long time .
3,551
public void setProduct ( String product ) { mProduct = product == null ? DEFAULT_PRODUCT : BDBProduct . forString ( product ) ; }
Sets the BDB product to use which defaults to JE . Also supported is DB and DB_HA . If not supported an IllegalArgumentException is thrown .
3,552
public void setEnvironmentHomeFile ( File envHome ) { try { envHome = envHome . getCanonicalFile ( ) ; } catch ( IOException e ) { } mEnvHome = envHome ; }
Sets the repository environment home directory which is required .
3,553
public void setFileName ( String filename , String typeName ) { mSingleFileName = null ; if ( mFileNames == null ) { mFileNames = new HashMap < String , String > ( ) ; } mFileNames . put ( typeName , filename ) ; }
Specify the file that a BDB database should reside in except for log files and caches . The filename is relative to the environment home unless data directories have been specified . For BDBRepositories that are log files only this configuration is ignored .
3,554
public void setDatabasePageSize ( Integer bytes , Class < ? extends Storable > type ) { if ( mDatabasePageSizes == null ) { mDatabasePageSizes = new HashMap < Class < ? > , Integer > ( ) ; } mDatabasePageSizes . put ( type , bytes ) ; }
Sets the desired page size for a given type . If not specified the page size applies to all types .
3,555
public void setCompressor ( String type , String compressionType ) { mStorableCodecFactory = null ; compressionType = compressionType . toUpperCase ( ) ; if ( mCompressionMap == null ) { mCompressionMap = new HashMap < String , CompressionType > ( ) ; } CompressionType compressionEnum = CompressionType . valueOf ( compressionType ) ; if ( compressionEnum != null ) { mCompressionMap . put ( type , compressionEnum ) ; } }
Set the compressor for the given class overriding a custom StorableCodecFactory .
3,556
public String getCompressor ( String type ) { if ( mCompressionMap == null ) { return null ; } return mCompressionMap . get ( type ) . toString ( ) ; }
Return the compressor used for the given storable .
3,557
@ SuppressWarnings ( "unchecked" ) private Constructor < BDBRepository > getRepositoryConstructor ( ) throws ClassCastException , ClassNotFoundException , NoSuchMethodException { String packageName ; { String thisClassName = getClass ( ) . getName ( ) ; packageName = thisClassName . substring ( 0 , thisClassName . lastIndexOf ( '.' ) ) ; } String className = packageName + '.' + getBDBProduct ( ) . name ( ) + "_Repository" ; Class repoClass = Class . forName ( className ) ; if ( BDBRepository . class . isAssignableFrom ( repoClass ) ) { return repoClass . getDeclaredConstructor ( AtomicReference . class , BDBRepositoryBuilder . class ) ; } throw new ClassCastException ( "Not an instance of BDBRepository: " + repoClass . getName ( ) ) ; }
Looks up appropriate repository via reflection whose name is derived from the BDB product string .
3,558
public boolean canMergeRemainderOrdering ( OrderingScore < S > other ) { if ( this == other || ( getHandledCount ( ) == 0 && other . getHandledCount ( ) == 0 ) ) { return true ; } if ( isIndexClustered ( ) == other . isIndexClustered ( ) && getIndexPropertyCount ( ) == other . getIndexPropertyCount ( ) && shouldReverseOrder ( ) == other . shouldReverseOrder ( ) && getHandledOrdering ( ) . equals ( other . getHandledOrdering ( ) ) ) { OrderingList < S > thisRemainderOrdering = getRemainderOrdering ( ) ; OrderingList < S > otherRemainderOrdering = other . getRemainderOrdering ( ) ; int size = Math . min ( thisRemainderOrdering . size ( ) , otherRemainderOrdering . size ( ) ) ; for ( int i = 0 ; i < size ; i ++ ) { if ( ! thisRemainderOrdering . get ( i ) . equals ( otherRemainderOrdering . get ( i ) ) ) { return false ; } } return true ; } return false ; }
Returns true if the given score uses an index exactly the same as this one . The only allowed differences are in the count of remainder orderings .
3,559
public OrderingList < S > mergeRemainderOrdering ( OrderingScore < S > other ) { OrderingList < S > thisRemainderOrdering = getRemainderOrdering ( ) ; if ( this == other ) { return thisRemainderOrdering ; } OrderingList < S > otherRemainderOrdering = other . getRemainderOrdering ( ) ; if ( thisRemainderOrdering . size ( ) == 0 ) { return otherRemainderOrdering ; } else { if ( otherRemainderOrdering . size ( ) == 0 ) { return thisRemainderOrdering ; } else if ( thisRemainderOrdering . size ( ) >= otherRemainderOrdering . size ( ) ) { return thisRemainderOrdering ; } else { return otherRemainderOrdering ; } } }
Merges the remainder orderings of this score with the one given . Call canMergeRemainderOrdering first to verify if the merge makes any sense .
3,560
protected void fillBytes ( int value , long count ) throws BitStreamException { if ( count < PAD_LIMIT ) { for ( int i = 0 ; i < count ; i ++ ) writeByte ( value ) ; return ; } byte b = ( byte ) value ; byte [ ] buffer = getBuffer ( b ) ; int len ; if ( buffer == null ) { len = count > PAD_BUFFER ? PAD_BUFFER : ( int ) count ; buffer = new byte [ len ] ; Arrays . fill ( buffer , b ) ; } else { len = PAD_BUFFER ; } if ( count <= len ) { writeBytes ( buffer , 0 , ( int ) count ) ; return ; } long limit = count / len ; for ( long i = 0 ; i < limit ; i ++ ) { writeBytes ( buffer , 0 , len ) ; } int r = ( int ) ( count - limit * len ) ; if ( r != 0 ) writeBytes ( buffer , 0 , r ) ; }
Writes a single value repeatedly into the sequence .
3,561
private void executeOperation ( DbUnitDatabasePopulator populator , DataSource dataSource ) throws Exception { Connection connection = null ; try { connection = getConnection ( dataSource ) ; populator . populate ( connection ) ; } finally { if ( connection != null && ! isConnectionTransactional ( connection , dataSource ) ) { releaseConnection ( connection , dataSource ) ; } } }
Execute a DBUbit operation
3,562
public BitVector range ( int from , int to ) { if ( from < 0 ) throw new IllegalArgumentException ( ) ; if ( to < from ) throw new IllegalArgumentException ( ) ; from += start ; to += start ; if ( to > finish ) throw new IllegalArgumentException ( ) ; return new BitVector ( from , to , bits , mutable ) ; }
bypasses duplicate for efficiency
3,563
private void perform ( int operation , int position , long bs , int length ) { checkBitsLength ( length ) ; position = adjPosition ( position ) ; checkMutable ( ) ; performAdj ( operation , position , bs , length ) ; }
assumes address size is size of long
3,564
private void setBitsImpl ( int position , long value , int length ) { int i = position >> ADDRESS_BITS ; int s = position & ADDRESS_MASK ; long m = length == ADDRESS_SIZE ? - 1L : ( 1L << length ) - 1L ; long v = value & m ; performAdjSet ( length , i , s , m , v ) ; }
length guaranteed to be non - zero
3,565
private void performSetAdj ( int position , boolean value ) { checkMutable ( ) ; final int i = position >> ADDRESS_BITS ; final long m = 1L << ( position & ADDRESS_MASK ) ; if ( value ) { bits [ i ] |= m ; } else { bits [ i ] &= ~ m ; } }
specialized implementation for the common case of setting an individual bit
3,566
private boolean getThenPerformAdj ( int operation , int position , boolean value ) { checkMutable ( ) ; final int i = position >> ADDRESS_BITS ; final long m = 1L << ( position & ADDRESS_MASK ) ; final long v = bits [ i ] & m ; switch ( operation ) { case SET : if ( value ) { bits [ i ] |= m ; } else { bits [ i ] &= ~ m ; } break ; case AND : if ( value ) { } else { bits [ i ] &= ~ m ; } break ; case OR : if ( value ) { bits [ i ] |= m ; } else { } break ; case XOR : if ( value ) { bits [ i ] ^= m ; } else { } break ; } return v != 0 ; }
separate implementation from performAdj is an optimization
3,567
public BitsoWithdrawal [ ] getWithdrawals ( String [ ] withdrawalsIds , String ... queryParameters ) throws BitsoAPIException , BitsoPayloadException , BitsoServerException { String request = "/api/v3/withdrawals" ; if ( ( withdrawalsIds != null ) && ( queryParameters != null && queryParameters . length > 0 ) ) { return null ; } if ( withdrawalsIds != null ) { String withdrawalsIdsParameters = processQueryParameters ( "-" , withdrawalsIds ) ; request += ( ( withdrawalsIdsParameters != null ) ? "/" + withdrawalsIdsParameters : "" ) ; } if ( queryParameters != null && queryParameters . length > 0 ) { String parsedQueryParametes = processQueryParameters ( "&" , queryParameters ) ; request += ( ( parsedQueryParametes != null ) ? "?" + parsedQueryParametes : "" ) ; } String getResponse = sendBitsoGet ( request ) ; JSONArray payloadJSON = ( JSONArray ) getJSONPayload ( getResponse ) ; int totalElements = payloadJSON . length ( ) ; BitsoWithdrawal [ ] withdrawals = new BitsoWithdrawal [ totalElements ] ; for ( int i = 0 ; i < totalElements ; i ++ ) { withdrawals [ i ] = new BitsoWithdrawal ( payloadJSON . getJSONObject ( i ) ) ; } return withdrawals ; }
The request needs withdrawalsIds or queryParameters not both . In case both parameters are provided null will be returned
3,568
public BitsoFunding [ ] getFundings ( String [ ] fundingssIds , String ... queryParameters ) throws BitsoAPIException , BitsoPayloadException , BitsoServerException { String request = "/api/v3/fundings" ; if ( ( fundingssIds != null && ( queryParameters != null && queryParameters . length > 0 ) ) ) { return null ; } if ( fundingssIds != null ) { String fundingssIdsParameters = processQueryParameters ( "-" , fundingssIds ) ; request += ( ( fundingssIdsParameters != null ) ? "/" + fundingssIdsParameters : "" ) ; } if ( queryParameters != null && queryParameters . length > 0 ) { String parsedQueryParametes = processQueryParameters ( "&" , queryParameters ) ; request += ( ( parsedQueryParametes != null ) ? "?" + parsedQueryParametes : "" ) ; } String getResponse = sendBitsoGet ( request ) ; JSONArray payloadJSON = ( JSONArray ) getJSONPayload ( getResponse ) ; int totalElements = payloadJSON . length ( ) ; BitsoFunding [ ] fundings = new BitsoFunding [ totalElements ] ; for ( int i = 0 ; i < totalElements ; i ++ ) { fundings [ i ] = new BitsoFunding ( payloadJSON . getJSONObject ( i ) ) ; } return fundings ; }
The request needs fundingssIds or queryParameters not both . In case both parameters are provided null will be returned
3,569
public BitsoTrade [ ] getUserTrades ( String [ ] tradesIds , String ... queryParameters ) throws BitsoAPIException , BitsoPayloadException , BitsoServerException { String request = "/api/v3/user_trades" ; if ( ( tradesIds != null && ( queryParameters != null && queryParameters . length > 0 ) ) ) { return null ; } if ( tradesIds != null ) { String fundingssIdsParameters = processQueryParameters ( "-" , tradesIds ) ; request += ( ( fundingssIdsParameters != null ) ? "/" + fundingssIdsParameters : "" ) ; } if ( queryParameters != null && queryParameters . length > 0 ) { String parsedQueryParametes = processQueryParameters ( "&" , queryParameters ) ; request += ( ( parsedQueryParametes != null ) ? "?" + parsedQueryParametes : "" ) ; } String getResponse = sendBitsoGet ( request ) ; JSONArray payloadJSON = ( JSONArray ) getJSONPayload ( getResponse ) ; int totalElements = payloadJSON . length ( ) ; BitsoTrade [ ] trades = new BitsoTrade [ totalElements ] ; for ( int i = 0 ; i < totalElements ; i ++ ) { trades [ i ] = new BitsoTrade ( payloadJSON . getJSONObject ( i ) ) ; } return trades ; }
The request needs tradesIds or queryParameters not both . In case both parameters are provided null will be returned
3,570
static void writeBits ( WriteStream writer , long bits , int count ) { for ( int i = ( count - 1 ) & ~ 7 ; i >= 0 ; i -= 8 ) { writer . writeByte ( ( byte ) ( bits >>> i ) ) ; } }
not does not mask off the supplied long - that is responsibility of caller
3,571
static long readBits ( ReadStream reader , int count ) { long bits = 0L ; for ( int i = ( count - 1 ) >> 3 ; i >= 0 ; i -- ) { bits <<= 8 ; bits |= reader . readByte ( ) & 0xff ; } return bits ; }
not does not mask off the returned long - that is responsibility of caller
3,572
private ITableMetaData mergeTableMetaData ( List < Column > columnsToMerge , ITableMetaData originalMetaData ) throws DataSetException { Column [ ] columns = new Column [ originalMetaData . getColumns ( ) . length + columnsToMerge . size ( ) ] ; System . arraycopy ( originalMetaData . getColumns ( ) , 0 , columns , 0 , originalMetaData . getColumns ( ) . length ) ; for ( int i = 0 ; i < columnsToMerge . size ( ) ; i ++ ) { Column column = columnsToMerge . get ( i ) ; columns [ columns . length - columnsToMerge . size ( ) + i ] = column ; } return new DefaultTableMetaData ( originalMetaData . getTableName ( ) , columns ) ; }
merges the existing columns with the potentially new ones .
3,573
protected void handleMissingColumns ( Attributes attributes ) throws DataSetException { List < Column > columnsToMerge = new ArrayList < Column > ( ) ; ITableMetaData activeMetaData = getActiveMetaData ( ) ; int attributeLength = attributes . getLength ( ) ; for ( int i = 0 ; i < attributeLength ; i ++ ) { try { activeMetaData . getColumnIndex ( getAttributeNameFromCache ( attributes . getQName ( i ) ) ) ; } catch ( NoSuchColumnException e ) { columnsToMerge . add ( new Column ( getAttributeNameFromCache ( attributes . getQName ( i ) ) , DataType . UNKNOWN ) ) ; } } if ( ! columnsToMerge . isEmpty ( ) ) { if ( _columnSensing ) { logger . debug ( "Column sensing enabled. Will create a new metaData with potentially new columns if needed" ) ; activeMetaData = mergeTableMetaData ( columnsToMerge , activeMetaData ) ; _orderedTableNameMap . update ( activeMetaData . getTableName ( ) , activeMetaData ) ; _consumer . startTable ( activeMetaData ) ; } else { StringBuilder extraColumnNames = new StringBuilder ( ) ; for ( Column col : columnsToMerge ) { extraColumnNames . append ( extraColumnNames . length ( ) > 0 ? "," : "" ) . append ( col . getColumnName ( ) ) ; } if ( logger . isWarnEnabled ( ) ) { StringBuilder msg = new StringBuilder ( ) ; msg . append ( "Extra columns ({}) on line {} for table {} (global line number is {}). Those columns will be ignored." ) ; msg . append ( "\n\tPlease add the extra columns to line 1," + " or use a DTD to make sure the value of those columns are populated" ) ; msg . append ( " or specify 'columnSensing=true' for your FlatXmlProducer." ) ; msg . append ( "\n\tSee FAQ for more details." ) ; logger . warn ( msg . toString ( ) , new Object [ ] { extraColumnNames . toString ( ) , _lineNumber + 1 , activeMetaData . getTableName ( ) , _lineNumberGlobal } ) ; } } } }
parses the attributes in the current row and checks whether a new column is found .
3,574
public static < T , K extends Enum < K > > CSVParserBuilder < T , K > aParser ( Function < CSVRecord , T > mapper ) { CSVParserBuilder < T , K > builder = new CSVParserBuilder < T , K > ( ) ; builder . recordMapper = mapper ; return builder ; }
Create new parser using supplied mapping function .
3,575
public static < T , K extends Enum < K > > CSVParserBuilder < T , K > aParser ( Function < CSVRecordWithHeader < K > , T > mapper , Class < K > fields ) { CSVParserBuilder < T , K > builder = new CSVParserBuilder < T , K > ( ) ; builder . recordWithHeaderMapper = mapper ; builder . subsetView = FieldSubsetView . forSourceSuppliedHeader ( fields ) ; return builder ; }
Create new header - aware parser using supplied mapping function .
3,576
public CSVParserBuilder < T , K > usingExplicitHeader ( String ... header ) { Objects . requireNonNull ( subsetView ) ; this . subsetView = FieldSubsetView . forExplicitHeader ( subsetView . getFieldSubset ( ) , header ) ; return this ; }
Use supplied header and do not take header from the source .
3,577
public CSVParserBuilder < T , K > usingSeparatorWithNoQuotes ( char separator ) { this . metadata = new CSVFileMetadata ( separator , Optional . empty ( ) ) ; return this ; }
Use specified character as field separator .
3,578
public CSVParserBuilder < T , K > usingSeparatorWithQuote ( char separator , char quote ) { this . metadata = new CSVFileMetadata ( separator , Optional . of ( quote ) ) ; return this ; }
Use specified characters as field separator and quote character . Quote character can be escaped by preceding it with another quote character .
3,579
public CSVParser < T > build ( ) { return subsetView == null ? new QuickCSVParser < T , K > ( bufferSize , metadata , recordMapper , charset ) : new QuickCSVParser < T , K > ( bufferSize , metadata , recordWithHeaderMapper , subsetView , charset ) ; }
Construct parser using current setting
3,580
protected void writeByte ( int value ) throws BitStreamException { try { out . write ( value ) ; } catch ( IOException e ) { throw new BitStreamException ( e ) ; } }
byte based methods
3,581
public static BigDecimal getFeeInPercentage ( BigDecimal thirtyDayVolume ) { if ( thirtyDayVolume . compareTo ( new BigDecimal ( "1" ) ) <= 0 ) { return new BigDecimal ( "1" ) ; } else if ( thirtyDayVolume . compareTo ( new BigDecimal ( "2.5" ) ) <= 0 ) { return new BigDecimal ( "0.95" ) ; } else if ( thirtyDayVolume . compareTo ( new BigDecimal ( "4" ) ) <= 0 ) { return new BigDecimal ( "0.9" ) ; } else if ( thirtyDayVolume . compareTo ( new BigDecimal ( "6.5" ) ) <= 0 ) { return new BigDecimal ( "0.85" ) ; } else if ( thirtyDayVolume . compareTo ( new BigDecimal ( "9" ) ) <= 0 ) { return new BigDecimal ( "0.8" ) ; } else if ( thirtyDayVolume . compareTo ( new BigDecimal ( "12" ) ) <= 0 ) { return new BigDecimal ( "0.75" ) ; } else if ( thirtyDayVolume . compareTo ( new BigDecimal ( "18" ) ) <= 0 ) { return new BigDecimal ( "0.7" ) ; } else if ( thirtyDayVolume . compareTo ( new BigDecimal ( "25" ) ) <= 0 ) { return new BigDecimal ( "0.65" ) ; } else if ( thirtyDayVolume . compareTo ( new BigDecimal ( "32" ) ) <= 0 ) { return new BigDecimal ( "0.60" ) ; } else if ( thirtyDayVolume . compareTo ( new BigDecimal ( "40" ) ) <= 0 ) { return new BigDecimal ( "0.55" ) ; } else if ( thirtyDayVolume . compareTo ( new BigDecimal ( "55" ) ) <= 0 ) { return new BigDecimal ( "0.5" ) ; } else if ( thirtyDayVolume . compareTo ( new BigDecimal ( "75" ) ) <= 0 ) { return new BigDecimal ( "0.45" ) ; } else if ( thirtyDayVolume . compareTo ( new BigDecimal ( "100" ) ) <= 0 ) { return new BigDecimal ( "0.4" ) ; } else if ( thirtyDayVolume . compareTo ( new BigDecimal ( "125" ) ) <= 0 ) { return new BigDecimal ( "0.35" ) ; } else if ( thirtyDayVolume . compareTo ( new BigDecimal ( "160" ) ) <= 0 ) { return new BigDecimal ( "0.3" ) ; } else if ( thirtyDayVolume . compareTo ( new BigDecimal ( "200" ) ) <= 0 ) { return new BigDecimal ( "0.25" ) ; } else if ( thirtyDayVolume . compareTo ( new BigDecimal ( "250" ) ) <= 0 ) { return new BigDecimal ( "0.2" ) ; } else if ( thirtyDayVolume . compareTo ( new BigDecimal ( "320" ) ) <= 0 ) { return new BigDecimal ( "0.15" ) ; } else { return new BigDecimal ( "0.10" ) ; } }
Accessed July 28 2015
3,582
public static BitWriter writerTo ( int [ ] ints , long size ) { if ( ints == null ) throw new IllegalArgumentException ( "null ints" ) ; if ( size < 0 ) throw new IllegalArgumentException ( "negative size" ) ; long maxSize = ( ( long ) ints . length ) << 5 ; if ( size > maxSize ) throw new IllegalArgumentException ( "size exceeds maximum permitted by array length" ) ; return new IntArrayBitWriter ( ints ) ; }
Writes bits to an array of ints up - to a specified limit .
3,583
static int compareLexical ( BitStore a , BitStore b ) { int aSize = a . size ( ) ; int bSize = b . size ( ) ; int diff = a . size ( ) - b . size ( ) ; ListIterator < Integer > as = a . ones ( ) . positions ( aSize ) ; ListIterator < Integer > bs = b . ones ( ) . positions ( bSize ) ; while ( true ) { boolean ap = as . hasPrevious ( ) ; boolean bp = bs . hasPrevious ( ) ; if ( ap && bp ) { int ai = as . previous ( ) ; int bi = bs . previous ( ) + diff ; if ( ai == bi ) continue ; return ai > bi ? 1 : - 1 ; } else { return bp ? - 1 : 1 ; } } }
expects a strictly longer than b
3,584
static int gcd ( int a , int b ) { while ( a != b ) { if ( a > b ) { int na = a % b ; if ( na == 0 ) return b ; a = na ; } else { int nb = b % a ; if ( nb == 0 ) return a ; b = nb ; } } return a ; }
duplicated here to avoid dependencies
3,585
private static void transferImpl ( BitReader reader , BitWriter writer , long count ) { while ( count >= 64 ) { long bits = reader . readLong ( 64 ) ; writer . write ( bits , 64 ) ; count -= 64 ; } if ( count != 0L ) { long bits = reader . readLong ( ( int ) count ) ; writer . write ( bits , ( int ) count ) ; } }
private static methods
3,586
private void doWrite ( int bits , int count ) { int frontBits = ( ( int ) position ) & 31 ; int firstInt = ( int ) ( position >> 5 ) ; int sumBits = count + frontBits ; if ( sumBits <= 32 ) { int i = ints [ firstInt ] ; int mask = frontMask ( frontBits ) | backMask ( sumBits ) ; i &= mask ; i |= ( bits << ( 32 - sumBits ) ) & ~ mask ; ints [ firstInt ] = i ; } else { int i = ints [ firstInt ] ; int mask = frontMask ( frontBits ) ; i &= mask ; int lostBits = sumBits - 32 ; i |= ( bits >> lostBits ) & ~ mask ; ints [ firstInt ] = i ; i = ints [ firstInt + 1 ] ; mask = backMask ( lostBits ) ; i &= mask ; i |= ( bits << ( 32 - lostBits ) ) & ~ mask ; ints [ firstInt + 1 ] = i ; } }
assumes count is non - zero
3,587
public static void write ( IDataSet dataSet , OutputStream out ) throws IOException , DataSetException { logger . debug ( "write(dataSet={}, out={}) - start" , dataSet , out ) ; FlatXmlWriter datasetWriter = new FlatXmlWriter ( out ) ; datasetWriter . setIncludeEmptyTable ( true ) ; datasetWriter . write ( dataSet ) ; }
Write the specified dataset to the specified output stream as xml .
3,588
private boolean hasStep ( final SlideContent slideContent ) { boolean res = false ; for ( final S step : getStepList ( ) ) { if ( step . name ( ) . equalsIgnoreCase ( slideContent . getName ( ) ) ) { res = true ; } } return res ; }
Check if step defined in xml exist into current step list .
3,589
public SlideContent getDefaultContent ( ) { SlideContent res = null ; if ( getSlide ( ) . getContent ( ) != null && ! getSlide ( ) . getContent ( ) . isEmpty ( ) ) { res = getSlide ( ) . getContent ( ) . get ( 0 ) ; } return res ; }
Return the default content or null .
3,590
public SlideContent getContent ( final SlideStep slideStep ) { SlideContent res = null ; if ( getSlide ( ) . getContent ( ) != null && ! getSlide ( ) . getContent ( ) . isEmpty ( ) ) { for ( final SlideContent sc : getSlide ( ) . getContent ( ) ) { if ( sc . getName ( ) != null && ! sc . getName ( ) . isEmpty ( ) && sc . getName ( ) . equals ( slideStep . name ( ) ) ) { res = sc ; } } } return res == null ? getDefaultContent ( ) : res ; }
Return the default content or null for the given step .
3,591
private Animation buildAnimation ( final AnimationType animationType ) { Animation animation = null ; switch ( animationType ) { case MOVE_TO_RIGHT : animation = buildHorizontalAnimation ( 0 , 2000 , 0 , 0 ) ; break ; case MOVE_TO_LEFT : animation = buildHorizontalAnimation ( 0 , - 2000 , 0 , 0 ) ; break ; case MOVE_TO_TOP : animation = buildHorizontalAnimation ( 0 , 0 , 0 , - 1000 ) ; break ; case MOVE_TO_BOTTOM : animation = buildHorizontalAnimation ( 0 , 0 , 0 , 1000 ) ; break ; case MOVE_FROM_RIGHT : animation = buildHorizontalAnimation ( 2000 , 0 , 0 , 0 ) ; break ; case MOVE_FROM_LEFT : animation = buildHorizontalAnimation ( - 2000 , 0 , 0 , 0 ) ; break ; case MOVE_FROM_TOP : animation = buildHorizontalAnimation ( 0 , 0 , - 1000 , 0 ) ; break ; case MOVE_FROM_BOTTOM : animation = buildHorizontalAnimation ( 0 , 0 , 1000 , 0 ) ; break ; case FADE_IN : animation = FadeTransitionBuilder . create ( ) . node ( node ( ) ) . fromValue ( 0 ) . toValue ( 1.0 ) . duration ( Duration . seconds ( 1 ) ) . build ( ) ; break ; case FADE_OUT : animation = FadeTransitionBuilder . create ( ) . node ( node ( ) ) . fromValue ( 1.0 ) . toValue ( 0.0 ) . duration ( Duration . seconds ( 1 ) ) . build ( ) ; break ; case SCALE_FROM_MAX : animation = buildScaleAnimation ( 20.0 , 1.0 , true ) ; break ; case SCALE_FROM_MIN : animation = buildScaleAnimation ( 0.0 , 1.0 , true ) ; break ; case SCALE_TO_MAX : animation = buildScaleAnimation ( 1.0 , 20.0 , false ) ; break ; case SCALE_TO_MIN : animation = buildScaleAnimation ( 1.0 , 0.0 , false ) ; break ; case SLIDING_TOP_BOTTOM_PROGRESSIVE : animation = buildSliding ( ) ; break ; case TILE_IN : break ; case TILE_OUT : break ; case TILE_IN_60_K : break ; case TILE_OUT_60_K : break ; default : } return animation ; }
Build an animation .
3,592
private double findAngle ( final double fromX , final double fromY , final double toX , final double toY ) { final double yDelta = toY - fromY ; final double y = Math . sin ( yDelta ) * Math . cos ( toX ) ; final double x = Math . cos ( fromX ) * Math . sin ( toX ) - Math . sin ( fromX ) * Math . cos ( toX ) * Math . cos ( yDelta ) ; double angle = Math . toDegrees ( Math . atan2 ( y , x ) ) ; while ( angle < 0 ) { angle += 360 ; } return ( float ) angle % 360 ; }
Return the right angle for the given coordinate .
3,593
@ SuppressWarnings ( "unchecked" ) private void callCommand ( final Wave wave ) { final Command command = wave . contains ( JRebirthWaves . REUSE_COMMAND ) && wave . get ( JRebirthWaves . REUSE_COMMAND ) ? globalFacade ( ) . commandFacade ( ) . retrieve ( ( Class < Command > ) wave . componentClass ( ) ) : globalFacade ( ) . commandFacade ( ) . retrieve ( ( Class < Command > ) wave . componentClass ( ) , wave . wUID ( ) ) ; if ( command == null ) { LOGGER . error ( COMMAND_NOT_FOUND_ERROR , wave . toString ( ) ) ; this . unprocessedWaveHandler . manageUnprocessedWave ( COMMAND_NOT_FOUND_MESSAGE . getText ( ) , wave ) ; } else { command . run ( wave ) ; } }
Call dynamically a command .
3,594
@ SuppressWarnings ( "unchecked" ) private void returnData ( final Wave wave ) { final Service service = globalFacade ( ) . serviceFacade ( ) . retrieve ( ( Class < Service > ) wave . componentClass ( ) ) ; if ( service == null ) { LOGGER . error ( SERVICE_NOT_FOUND_ERROR , wave . toString ( ) ) ; this . unprocessedWaveHandler . manageUnprocessedWave ( SERVICE_NOT_FOUND_MESSAGE . getText ( ) , wave ) ; } else { final ServiceTaskBase < ? > task = ( ServiceTaskBase < ? > ) service . returnData ( wave ) ; if ( task != null && CoreParameters . FOLLOW_UP_SERVICE_TASKS . get ( ) ) { globalFacade ( ) . serviceFacade ( ) . retrieve ( TaskTrackerService . class ) . trackTask ( task ) ; } } }
Call a service method by using a task worker .
3,595
private void processUndefinedWave ( final Wave wave ) throws WaveException { LOGGER . info ( NOTIFIER_CONSUMES , wave . toString ( ) ) ; wave . status ( Status . Consumed ) ; if ( this . notifierMap . containsKey ( wave . waveType ( ) ) ) { final WaveSubscription ws = this . notifierMap . get ( wave . waveType ( ) ) ; wave . setWaveHandlers ( ws . getWaveHandlers ( ) . stream ( ) . filter ( wh -> wh . check ( wave ) ) . collect ( Collectors . toList ( ) ) ) ; for ( final WaveHandler waveHandler : new ArrayList < > ( wave . getWaveHandlers ( ) ) ) { waveHandler . handle ( wave ) ; } } else { LOGGER . warn ( NO_WAVE_LISTENER , wave . waveType ( ) . toString ( ) ) ; if ( CoreParameters . DEVELOPER_MODE . get ( ) ) { this . unprocessedWaveHandler . manageUnprocessedWave ( NO_WAVE_LISTENER . getText ( wave . waveType ( ) . toString ( ) ) , wave ) ; } } }
Dispatch a standard wave which could be handled by a custom method of the component .
3,596
public static boolean checkMethodSignature ( final Method method , final List < WaveItem < ? > > wParams ) { boolean isCompliant = false ; final Type [ ] mParams = method . getGenericParameterTypes ( ) ; if ( wParams . isEmpty ( ) && Wave . class . isAssignableFrom ( ClassUtility . getClassFromType ( mParams [ 0 ] ) ) ) { isCompliant = true ; } else if ( mParams . length - 1 == wParams . size ( ) ) { boolean skipMethod = false ; for ( int i = 0 ; ! skipMethod && i < mParams . length - 1 && ! isCompliant ; i ++ ) { if ( ! ClassUtility . getClassFromType ( mParams [ i ] ) . isAssignableFrom ( ClassUtility . getClassFromType ( wParams . get ( i ) . type ( ) ) ) ) { skipMethod = true ; } if ( i == mParams . length - 2 && Wave . class . isAssignableFrom ( ClassUtility . getClassFromType ( mParams [ i + 1 ] ) ) ) { isCompliant = true ; } } } return isCompliant ; }
Compare method parameters with wave parameters .
3,597
public static ColorItem create ( final ColorParams colorParams ) { return ColorItemImpl . create ( ) . uid ( colorIdGenerator . incrementAndGet ( ) ) . set ( colorParams ) ; }
Build a color item .
3,598
public static FontItem create ( final FontParams fontParams ) { return FontItemImpl . create ( ) . uid ( fontIdGenerator . incrementAndGet ( ) ) . set ( fontParams ) ; }
Build a font item .
3,599
public static ImageItem create ( final ImageParams imageParams ) { return ImageItemImpl . create ( ) . uid ( imageIdGenerator . incrementAndGet ( ) ) . set ( imageParams ) ; }
Build an image item .