idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
28,900
public NegateMultiPos < S , String , String > lookup ( String lookups ) { return new NegateMultiPos < S , String , String > ( lookups , null ) { protected S result ( ) { return aQueue ( 'U' , left , right , pos , position , null , plusminus , filltgt ) ; } } ; }
Sets the given lookups string as the search string
28,901
public S setBetn ( int leftIndex , int rightIndex ) { return set ( Indexer . of ( delegate . get ( ) ) . between ( leftIndex , rightIndex ) ) ; }
Sets the substring in given left index and right index as the delegate string
28,902
public S setBefore ( int rightIndex ) { return set ( Indexer . of ( delegate . get ( ) ) . before ( rightIndex ) ) ; }
Sets the substring in beginning and the given right index as the delegate string
28,903
public S setAfter ( int leftIndex ) { return set ( Indexer . of ( delegate . get ( ) ) . after ( leftIndex ) ) ; }
Sets the substring in given left index and ending as the delegate string
28,904
@ SuppressWarnings ( "unchecked" ) private void setCookie ( NativeObject result , HttpServletResponse response ) { Map < String , String > cookieMap = ScriptableObject . getTypedProperty ( result , "cookie" , Map . class ) ; if ( cookieMap == null ) { return ; } Iterator < Entry < String , String > > iterator = cookieMap . entrySet ( ) . iterator ( ) ; while ( iterator . hasNext ( ) ) { String name = iterator . next ( ) . getKey ( ) ; Cookie cookie = new Cookie ( name , cookieMap . get ( name ) ) ; response . addCookie ( cookie ) ; } }
set cookie from result of handler to HttpServletResponse
28,905
public void handle ( Object event ) throws EventException { try { this . handler . invoke ( listener , event ) ; } catch ( IllegalAccessException e ) { throw new Error ( "Access level changed, method " + handler + " is no longer accessible!" , e ) ; } catch ( IllegalArgumentException e ) { throw new Error ( "Method " + handler + " rejected event " + event , e ) ; } catch ( InvocationTargetException e ) { if ( e . getCause ( ) instanceof Error ) throw ( Error ) e . getCause ( ) ; throw new EventException ( this , event , e ) ; } }
Handles the event calling the handler method in the listener object .
28,906
public static int queryInt ( PreparedStatement stmt , int def ) throws SQLException { ResultSet rs = null ; try { rs = stmt . executeQuery ( ) ; if ( rs . next ( ) ) { int value = rs . getInt ( 1 ) ; if ( ! rs . wasNull ( ) ) { return value ; } } return def ; } finally { close ( rs ) ; } }
Runs a SQL query that returns a single integer value .
28,907
public static int update ( Connection con , String query , Object ... param ) throws SQLException { PreparedStatement stmt = null ; try { stmt = con . prepareStatement ( query ) ; for ( int i = 0 ; i < param . length ; i ++ ) { stmt . setObject ( i + 1 , param [ i ] ) ; } return stmt . executeUpdate ( ) ; } finally { close ( stmt ) ; } }
Runs a SQL query that inserts updates or deletes rows .
28,908
public void run ( ) { try { while ( -- expires >= 0 ) { sleep ( sysInterval ) ; synchronized ( ThreadClockImpl . class ) { currentTimeMillis += sysInterval ; } } } catch ( InterruptedException e ) { System . out . println ( "Clock thread interrupted" ) ; } }
Threads run method that increments the clock and resets the generated nano seconds counter .
28,909
private synchronized long getTimeSynchronized ( ) throws OverClockedException { long current = 0 ; synchronized ( ThreadClockImpl . class ) { current = currentTimeMillis ; } if ( current != lastTimeMs ) { generatedThisInterval = 0 ; lastTimeMs = current ; } if ( generatedThisInterval + 1 >= ( INTERVALS_PER_MILLI * sysInterval ) ) { throw new OverClockedException ( ) ; } return ( ( current + GREGORIAN_CHANGE_OFFSET ) * INTERVALS_PER_MILLI ) + generatedThisInterval ++ ; }
Returns the current time as described in the clock resolution and timestamp sections of the uuid specification .
28,910
public long getUUIDTime ( ) throws OverClockedException { if ( ! worker . isAlive ( ) ) { synchronized ( SystemClockImpl . class ) { currentTimeMillis = System . currentTimeMillis ( ) ; worker . start ( ) ; } generatedThisInterval = 0 ; } return getTimeSynchronized ( ) ; }
Method returns the clocks current time in 100 - nanosecond intervals since the Gregorian calander change . Calendar . GREGORIAN_OFFSET
28,911
public static String fileKeyToPathName ( final ByteBuffer fileKey , final String digestAlgorithm , final int tokenLength , final String tokenDelimiter ) throws NoSuchAlgorithmException { if ( fileKey == null ) { throw new NullPointerException ( "null fileKey" ) ; } if ( fileKey . remaining ( ) == 0 ) { throw new IllegalArgumentException ( "keyBuffer.remaining == 0" ) ; } if ( digestAlgorithm == null ) { throw new NullPointerException ( "null digestAlgorithm" ) ; } if ( tokenLength <= 0 ) { throw new IllegalArgumentException ( "tokenLength(" + tokenLength + ") <= 0" ) ; } if ( tokenDelimiter == null ) { throw new NullPointerException ( "null tokenDelimiter" ) ; } final MessageDigest digest = MessageDigest . getInstance ( digestAlgorithm ) ; digest . update ( fileKey . asReadOnlyBuffer ( ) ) ; final byte [ ] digested = digest . digest ( ) ; final String hexed = IntStream . range ( 0 , digested . length ) . collect ( ( ) -> new StringBuilder ( digested . length * 2 ) , ( b , i ) -> new Formatter ( b ) . format ( "%02x" , digested [ i ] & 0xFF ) , StringBuilder :: append ) . toString ( ) ; final String joined = Stream . of ( hexed . split ( "(?<=\\G.{" + tokenLength + "})" ) ) . collect ( Collectors . joining ( tokenDelimiter ) ) ; return joined ; }
Converts given file key to a path name .
28,912
protected < E > void journalize ( Character l , Collection < E > collection , Decision < E > decision ) { journalize ( collection , decision , l , isLogEnabled ( l ) , null , - 1 ) ; }
Log a collection with special level
28,913
public boolean notifyMeasurementEnding ( Iterable < Measurement > measurements ) throws IOException { println ( controlLogMessageRenderer . render ( new StopMeasurementLogMessage ( measurements ) ) ) ; for ( Measurement measurement : measurements ) { println ( String . format ( "I got a result! %s: %f%s%n" , measurement . description ( ) , measurement . value ( ) . magnitude ( ) / measurement . weight ( ) , measurement . value ( ) . unit ( ) ) ) ; } writer . flush ( ) ; return shouldKeepMeasuring ( ) ; }
Report the measurements and wait for it to be ack d by the runner . Returns true if we should keep measuring false otherwise .
28,914
public static long next ( final String name ) { String id = null ; try { id = Locks . lockEntityQuite ( new StorageId ( NumberSequence . class , null , null , name ) , 30 , TimeUnit . SECONDS ) ; long l = getLocalStorage ( ) . read ( name ) ; l ++ ; DDSCluster . call ( new MessageBean ( NumberSequence . class , null , null , name , "set" , Objects . newHashMap ( String . class , Object . class , "value" , l ) ) ) ; return l ; } finally { Locks . releaseLock ( id ) ; } }
Get next number from sequence if sequence is empty 0L will be returned and sequence will be created
28,915
public static < WorkingType > WorkingType fromBagAsType ( Bag bag , Class type ) { return ( bag != null ) ? ( WorkingType ) deserialize ( type . getName ( ) , bag ) : null ; }
Reconstitute the given BagObject representation back to the object it represents using a best - effort approach to matching the fields of the BagObject to the class being initialized .
28,916
public final void registerTaskExecutor ( TaskExecutor taskExecutor ) { if ( taskExecutor == null ) { throw new TaskExeception ( TaskExecutor . class . getSimpleName ( ) + " NULL" ) ; } this . taskExecutor = taskExecutor ; }
Registers the task executor . DO NOT USE THIS METHOD UNLESS YOU ARE DEVELOPING A NEW TASK EXECUTOR .
28,917
public static AcceptDatetime valueOf ( final String value ) { final Optional < Instant > datetime = parseDatetime ( value ) ; if ( datetime . isPresent ( ) ) { return new AcceptDatetime ( datetime . get ( ) ) ; } return null ; }
Create an Accept - Datetime header object from a string
28,918
@ SuppressWarnings ( "unchecked" ) public static < K , E extends Number > NumberMap < K , E > newNumberMap ( Class < E > elementType ) { if ( elementType == BigDecimal . class ) return ( NumberMap < K , E > ) newBigDecimalMap ( ) ; if ( elementType == BigInteger . class ) return ( NumberMap < K , E > ) newBigIntegerMap ( ) ; if ( elementType == Byte . class ) return ( NumberMap < K , E > ) newByteMap ( ) ; if ( elementType == Long . class ) return ( NumberMap < K , E > ) newLongMap ( ) ; if ( elementType == Double . class ) return ( NumberMap < K , E > ) newDoubleMap ( ) ; if ( elementType == Float . class ) return ( NumberMap < K , E > ) newFloatMap ( ) ; if ( elementType == Integer . class ) return ( NumberMap < K , E > ) newIntegerMap ( ) ; if ( elementType == Short . class ) return ( NumberMap < K , E > ) newShortMap ( ) ; else throw new UnsupportedOperationException ( ) ; }
Creates a NumberMap for instances of a concrete subclass of Number .
28,919
public static < K > NumberMap < K , BigDecimal > newBigDecimalMap ( ) { return new NumberMap < K , BigDecimal > ( ) { public void add ( K key , BigDecimal addend ) { put ( key , containsKey ( key ) ? get ( key ) . add ( addend ) : addend ) ; } public void sub ( K key , BigDecimal subtrahend ) { put ( key , ( containsKey ( key ) ? get ( key ) : BigDecimal . ZERO ) . subtract ( subtrahend ) ) ; } } ; }
Creates a NumberMap for BigDecimals .
28,920
public static < K > NumberMap < K , BigInteger > newBigIntegerMap ( ) { return new NumberMap < K , BigInteger > ( ) { public void add ( K key , BigInteger addend ) { put ( key , containsKey ( key ) ? get ( key ) . add ( addend ) : addend ) ; } public void sub ( K key , BigInteger subtrahend ) { put ( key , ( containsKey ( key ) ? get ( key ) : BigInteger . ZERO ) . subtract ( subtrahend ) ) ; } } ; }
Creates a NumberMap for BigIntegers .
28,921
public static < K > NumberMap < K , Byte > newByteMap ( ) { return new NumberMap < K , Byte > ( ) { public void add ( K key , Byte addend ) { put ( key , ( byte ) ( containsKey ( key ) ? get ( key ) + addend : addend ) ) ; } public void sub ( K key , Byte subtrahend ) { put ( key , ( byte ) ( ( containsKey ( key ) ? get ( key ) : 0 ) - subtrahend ) ) ; } } ; }
Creates a NumberMap for Bytes .
28,922
public static < K > NumberMap < K , Double > newDoubleMap ( ) { return new NumberMap < K , Double > ( ) { public void add ( K key , Double addend ) { put ( key , containsKey ( key ) ? ( get ( key ) + addend ) : addend ) ; } public void sub ( K key , Double subtrahend ) { put ( key , ( containsKey ( key ) ? get ( key ) : 0d ) - subtrahend ) ; } } ; }
Creates a NumberMap for Doubles .
28,923
public static < K > NumberMap < K , Float > newFloatMap ( ) { return new NumberMap < K , Float > ( ) { public void add ( K key , Float addend ) { put ( key , containsKey ( key ) ? ( get ( key ) + addend ) : addend ) ; } public void sub ( K key , Float subtrahend ) { put ( key , ( containsKey ( key ) ? get ( key ) : 0f ) - subtrahend ) ; } } ; }
Creates a NumberMap for Floats .
28,924
public static < K > NumberMap < K , Integer > newIntegerMap ( ) { return new NumberMap < K , Integer > ( ) { public void add ( K key , Integer addend ) { put ( key , containsKey ( key ) ? ( get ( key ) + addend ) : addend ) ; } public void sub ( K key , Integer subtrahend ) { put ( key , ( containsKey ( key ) ? get ( key ) : 0 ) - subtrahend ) ; } } ; }
Creates a NumberMap for Integers .
28,925
public static < K > NumberMap < K , Long > newLongMap ( ) { return new NumberMap < K , Long > ( ) { public void add ( K key , Long addend ) { put ( key , containsKey ( key ) ? ( get ( key ) + addend ) : addend ) ; } public void sub ( K key , Long subtrahend ) { put ( key , ( containsKey ( key ) ? get ( key ) : 0l ) - subtrahend ) ; } } ; }
Creates a NumberMap for Longs .
28,926
public static < K > NumberMap < K , Short > newShortMap ( ) { return new NumberMap < K , Short > ( ) { public void add ( K key , Short addend ) { put ( key , containsKey ( key ) ? ( short ) ( get ( key ) + addend ) : addend ) ; } public void sub ( K key , Short subtrahend ) { put ( key , ( short ) ( ( containsKey ( key ) ? get ( key ) : 0 ) - subtrahend ) ) ; } } ; }
Creates a NumberMap for Shorts .
28,927
public void addNetwork ( String country , String networkName ) { if ( ! isValidString ( country ) || ! isValidString ( networkName ) ) { return ; } this . network . add ( new CountryDetail ( country , networkName ) ) ; }
Add a single network to the list
28,928
@ SuppressWarnings ( "unchecked" ) public T get ( Object entity ) { Object value = entity ; for ( String name : path ( ) ) { try { Field field = value . getClass ( ) . getDeclaredField ( name ) ; field . setAccessible ( true ) ; value = field . get ( value ) ; } catch ( Exception e ) { throw new UncheckedException ( e ) ; } } return ( T ) value ; }
Returns the property value which this metamodel property instance represents from the specified entity instance .
28,929
public void set ( E entity , Object value ) { Object object = entity ; for ( int i = 0 ; i < path ( ) . size ( ) - 1 ; i ++ ) { try { Field field = object . getClass ( ) . getDeclaredField ( path ( ) . get ( i ) ) ; field . setAccessible ( true ) ; object = field . get ( object ) ; } catch ( Exception e ) { throw new UncheckedException ( e ) ; } } try { Field field = object . getClass ( ) . getDeclaredField ( name ) ; field . setAccessible ( true ) ; field . set ( object , value ) ; } catch ( Exception e ) { throw new UncheckedException ( e ) ; } }
Sets the property value which this metamodel property instance represents to the specified entity instance .
28,930
private void cleanup ( ) { CacheEntry oldest = null ; _count = 0 ; for ( Map . Entry < String , CacheEntry > e : _cache . entrySet ( ) ) { String key = e . getKey ( ) ; CacheEntry entry = e . getValue ( ) ; if ( entry . isExpired ( ) ) { _cache . remove ( key ) ; } else { _count ++ ; if ( oldest == null || oldest . getExpiration ( ) > entry . getExpiration ( ) ) oldest = entry ; } } if ( _count > _maxSize && oldest != null ) { _cache . remove ( oldest . getKey ( ) ) ; _count -- ; } }
Clears component state .
28,931
public Object retrieve ( String correlationId , String key ) { synchronized ( _lock ) { CacheEntry entry = _cache . get ( key ) ; if ( entry == null ) { return null ; } if ( entry . isExpired ( ) ) { _cache . remove ( key ) ; _count -- ; return null ; } return entry . getValue ( ) ; } }
Retrieves cached value from the cache using its key . If value is missing in the cache or expired it returns null .
28,932
public void remove ( String correlationId , String key ) { synchronized ( _lock ) { CacheEntry entry = _cache . get ( key ) ; if ( entry != null ) { _cache . remove ( key ) ; _count -- ; } } }
Removes a value from the cache by its key .
28,933
public void add ( int index , E element ) { int idx = getRealIndex ( index ) ; super . add ( idx , element ) ; }
Inserts the specified element at the specified position in this Vector .
28,934
public boolean addAll ( int index , Collection < ? extends E > collection ) { int idx = getRealIndex ( index ) ; return super . addAll ( idx , collection ) ; }
Inserts all of the elements in the specified Collection into this Vector at the specified position .
28,935
public int indexOf ( Object o , int index ) { int idx = getRealIndex ( index ) ; return super . indexOf ( o , idx ) ; }
Returns the index of the first occurrence of the specified element in this vector searching forwards from index or returns - 1 if the element is not found .
28,936
public void insertElementAt ( E obj , int index ) { int idx = getRealIndex ( index ) ; super . insertElementAt ( obj , idx ) ; }
Inserts the specified object as a component in this vector at the specified index .
28,937
public int lastIndexOf ( Object o , int index ) { int idx = getRealIndex ( index ) ; return super . lastIndexOf ( o , idx ) ; }
Returns the index of the last occurrence of the specified element in this vector searching backwards from index or returns - 1 if the element is not found .
28,938
public void setElementAt ( E obj , int index ) { int idx = getRealIndex ( index ) ; super . setElementAt ( obj , idx ) ; }
Sets the component at the specified index of this vector to be the specified object .
28,939
private int getRealIndex ( int index ) { int idx = index ; if ( idx < 0 ) { if ( Math . abs ( idx ) <= this . size ( ) ) { idx = this . size ( ) + idx ; } else { logger . error ( "negative number {} is too large: results size is {}, maximum admitted value is {}" , index , this . size ( ) , - 1 * this . size ( ) + 1 ) ; throw new IndexOutOfBoundsException ( "Negative index is too large" ) ; } } return idx ; }
Returns the positive value corresponding to the given positive or negative index value .
28,940
public boolean has ( final K key ) { if ( this . services . containsKey ( key ) ) { final Collection < S > collection = this . services . get ( key ) ; if ( collection == null ) { return false ; } if ( collection . isEmpty ( ) ) { return false ; } return true ; } return false ; }
Determines whether there are any current services that have the given key .
28,941
public Collection < ScalingGroup > listScalingGroups ( AutoScalingGroupFilterOptions options ) throws CloudException , InternalException { APITrace . begin ( getProvider ( ) , "AutoScaling.listScalingGroups" ) ; try { ProviderContext ctx = getProvider ( ) . getContext ( ) ; if ( ctx == null ) { throw new CloudException ( "No context has been set for this request" ) ; } ArrayList < ScalingGroup > list = new ArrayList < ScalingGroup > ( ) ; Map < String , String > parameters = getAutoScalingParameters ( getProvider ( ) . getContext ( ) , EC2Method . DESCRIBE_AUTO_SCALING_GROUPS ) ; EC2Method method ; NodeList blocks ; Document doc ; method = new EC2Method ( SERVICE_ID , getProvider ( ) , parameters ) ; try { doc = method . invoke ( ) ; } catch ( EC2Exception e ) { logger . error ( e . getSummary ( ) ) ; throw new CloudException ( e ) ; } blocks = doc . getElementsByTagName ( "AutoScalingGroups" ) ; for ( int i = 0 ; i < blocks . getLength ( ) ; i ++ ) { NodeList items = blocks . item ( i ) . getChildNodes ( ) ; for ( int j = 0 ; j < items . getLength ( ) ; j ++ ) { Node item = items . item ( j ) ; if ( item . getNodeName ( ) . equals ( "member" ) ) { ScalingGroup group = toScalingGroup ( ctx , item ) ; if ( ( group != null && ( options != null && ! options . hasCriteria ( ) ) ) || ( group != null && ( options != null && options . hasCriteria ( ) && options . matches ( group ) ) ) ) { list . add ( group ) ; } } } } return list ; } finally { APITrace . end ( ) ; } }
Returns filtered list of auto scaling groups .
28,942
static Map < String , Object > toWire ( Map < String , Object > json ) { return ( Map < String , Object > ) ObjectIterator . iterate ( json , new Closure < ObjectIterator . IterateBean , Object > ( ) { public Object call ( ObjectIterator . IterateBean i ) { try { if ( i . getValue ( ) instanceof Date ) { SimpleDateFormat sdf = new SimpleDateFormat ( "yyy-MM-dd HH:mm:ss.SSS" ) ; return "/Date(" + sdf . format ( ( Date ) i . getValue ( ) ) + ")/" ; } } catch ( Exception e ) { } return i . getValue ( ) ; } } ) ; }
Format Java Classes into strings version
28,943
static Map < String , Object > fromWire ( Map < String , Object > json ) { return ( Map < String , Object > ) ObjectIterator . iterate ( json , new Closure < ObjectIterator . IterateBean , Object > ( ) { public Object call ( ObjectIterator . IterateBean i ) { if ( i . getValue ( ) instanceof String ) { String s = ( String ) i . getValue ( ) ; try { if ( s . startsWith ( "/" ) && s . endsWith ( "/" ) ) { s = s . substring ( 1 , s . length ( ) - 1 ) ; String type = s . substring ( 0 , s . indexOf ( "(" ) ) ; String value = s . substring ( s . indexOf ( "(" ) + 1 , s . lastIndexOf ( ")" ) ) ; if ( "Date" . equalsIgnoreCase ( type ) ) { return ObjectType . cast ( value , Date . class ) ; } } } catch ( Throwable e ) { } } return i . getValue ( ) ; } } ) ; }
Parse simple types into Java Classes
28,944
public static < E > void removeMatcing ( Collection < E > collection , Matcher < ? super E > matcher ) { Iterator < E > iter = collection . iterator ( ) ; while ( iter . hasNext ( ) ) { E item = iter . next ( ) ; if ( matcher . matches ( item ) ) iter . remove ( ) ; } }
Removes matching elements from the supplied Collection .
28,945
final Document createDocument ( List < String > row , DocumentFactory documentFactory ) { String id = StringUtils . EMPTY ; String content = StringUtils . EMPTY ; Language language = documentFactory . getDefaultLanguage ( ) ; Map < AttributeType , Object > attributeMap = new HashMap < > ( ) ; String idField = Config . get ( configProperty , "idField" ) . asString ( "ID" ) . toUpperCase ( ) ; String contentField = Config . get ( configProperty , "contentField" ) . asString ( "CONTENT" ) . toUpperCase ( ) ; String languageField = Config . get ( configProperty , "languageField" ) . asString ( "LANGUAGE" ) . toUpperCase ( ) ; Index < String > fields = getFieldNames ( ) ; for ( int i = 0 ; i < row . size ( ) && i < fieldNames . size ( ) ; i ++ ) { String field = row . get ( i ) ; String fieldName = fields . get ( i ) ; if ( idField . equalsIgnoreCase ( fieldName ) ) { id = field ; } else if ( contentField . equalsIgnoreCase ( fieldName ) ) { content = field ; } else if ( languageField . equalsIgnoreCase ( fieldName ) ) { language = Language . fromString ( field ) ; } else { AttributeType attributeType = AttributeType . create ( fieldName ) ; attributeMap . put ( attributeType , attributeType . getValueType ( ) . decode ( field ) ) ; } } return documentFactory . create ( id , content , language , attributeMap ) ; }
Create document document .
28,946
public static String getName ( String name , String path ) { logger . trace ( "getting OGNL name for node '{}' at path '{}'" , name , path ) ; StringBuilder buffer = new StringBuilder ( ) ; if ( path != null ) { buffer . append ( path ) ; } if ( buffer . length ( ) != 0 && name != null && ! name . startsWith ( "[" ) ) { buffer . append ( "." ) ; } buffer . append ( name ) ; logger . trace ( "OGNL path of node is '{}'" , buffer . toString ( ) ) ; return buffer . toString ( ) ; }
Returns the OGNL name of the node .
28,947
public static Object getValue ( Object object , Field field ) throws VisitorException { boolean reprotect = false ; if ( object == null ) { return null ; } try { if ( ! field . isAccessible ( ) ) { field . setAccessible ( true ) ; reprotect = true ; } Object value = field . get ( object ) ; logger . trace ( "field '{}' has value '{}'" , field . getName ( ) , value ) ; return value ; } catch ( IllegalArgumentException e ) { logger . error ( "Trying to access field '{}' on invalid object of class '{}'" , field . getName ( ) , object . getClass ( ) . getSimpleName ( ) ) ; throw new VisitorException ( "Trying to access field on invalid object" , e ) ; } catch ( IllegalAccessException e ) { logger . error ( "Illegal access to class '{}'" , object . getClass ( ) . getSimpleName ( ) ) ; throw new VisitorException ( "Illegal access to class" , e ) ; } finally { if ( reprotect ) { field . setAccessible ( false ) ; } } }
Returns the value of the given field on the given object .
28,948
private void insanityCheck ( Element element , Meta meta , Opcode . Type type ) { if ( meta != null ) { throw new TemplateException ( "Invalid operators list on element |%s|. Only one %s operator is allowed." , element , type ) ; } }
Throws template exception if operator of given type is already declared .
28,949
static int toInt ( String input , int offset , int length ) { if ( length == 1 ) { return input . charAt ( offset ) - '0' ; } int out = 0 ; for ( int i = offset + length - 1 , factor = 1 ; i >= offset ; -- i , factor *= 10 ) { out += ( input . charAt ( i ) - '0' ) * factor ; } return out ; }
Converts the given string into an integer using Horner s method . No validation isOneOf done on the input . This method will produce numbers even if the input isOneOf not a valid decimal number .
28,950
public void commit ( ) throws IndoubtException { session . transaction . remove ( ) ; if ( logs . size ( ) == 0 ) { return ; } try { for ( Log log : logs ) { if ( log . operation ( ) != Operation . GET ) { if ( transaction . isActive ( ) ) { transaction . commit ( ) ; } log . state ( State . COMMITTED ) ; } } } catch ( Exception e ) { throw new UncheckedException ( e ) ; } logger . fine ( "Transaction [" + id + "] committed" ) ; }
Commits this transaction with loose commitment protocol .
28,951
protected Object doExec ( Element element , Object scope , String format , Object ... arguments ) throws IOException { Stack < Index > indexes = this . serializer . getIndexes ( ) ; if ( indexes . size ( ) == 0 ) { throw new TemplateException ( "Required ordered collection index is missing. Numbering operator cancel execution." ) ; } this . serializer . writeTextContent ( getNumbering ( this . serializer . getIndexes ( ) , format ) ) ; return null ; }
Insert formatted numbering as element text content . If serializer indexes stack is empty throws templates exception ; anyway validation tool running on build catches numbering operator without surrounding ordered list .
28,952
private static String getNumbering ( Stack < Index > indexes , String format ) { StringBuilder sb = new StringBuilder ( ) ; int i = format . length ( ) ; int j = i ; int indexPosition = indexes . size ( ) - 1 ; for ( ; ; ) { i = format . lastIndexOf ( '%' , i ) ; if ( i == - 1 && j > 0 ) { sb . insert ( 0 , format . substring ( 0 , j ) ) ; break ; } if ( i + 2 < format . length ( ) ) sb . insert ( 0 , format . substring ( i + 2 , j ) ) ; if ( i + 1 == format . length ( ) ) continue ; NumberingFormat numberingFormat = getNumberingFormat ( format . charAt ( i + 1 ) ) ; sb . insert ( 0 , numberingFormat . format ( indexes . get ( indexPosition -- ) . value ) ) ; if ( i == 0 ) break ; j = i ; i -- ; } return sb . toString ( ) ; }
Parse numbering format and inject index values . First argument the stack of indexes is global per serializer and format is the operand literal value . For nested numbering format may contain more than one single format code ; this is the reason first argument is the entire indexes stack not only current index . Given a stack with four indexes those values are 1 2 3 and 4 and %S - %I . %n - %s ) the format resulting formatted string is A - II . 3 - d ) .
28,953
public M sequence ( String sequenceKey , Long initialValue , Boolean increment ) { SequenceConfig cfg = defaultSequenceConfig ( ) ; if ( null != initialValue ) { cfg . setInitialValue ( initialValue ) ; } if ( null != increment ) { cfg . setDecrement ( ! increment ) ; } getSequence ( sequenceKey , cfg ) ; return THIS ( ) ; }
Configuration a Sequence instance with frequently - used property
28,954
public M sequence ( String sequenceKey , SequenceConfig sequenceConfig ) { getSequence ( sequenceKey , firstNonNull ( sequenceConfig , defaultSequenceConfig ( ) ) ) ; return THIS ( ) ; }
Configuration a Sequence instance
28,955
protected void paintTabBorder ( Graphics g , int tabPlacement , int tabIndex , int x , int y , int w , int h , boolean isSelected ) { if ( isSelected ) { g . setColor ( Color . GRAY ) ; } else { g . setColor ( Color . LIGHT_GRAY ) ; } g . drawRect ( x + 1 , y + 1 , w - 2 , h - 2 ) ; }
this function draws the border around each tab note that this function does now draw the background of the tab . that is done elsewhere
28,956
public void load ( @ OptionArgument ( "filename" ) String filename ) { users . clear ( ) ; try { BufferedReader reader = new BufferedReader ( new FileReader ( filename ) ) ; while ( reader . ready ( ) ) { User user = User . fromString ( reader . readLine ( ) ) ; users . put ( user . username , user ) ; } } catch ( FileNotFoundException e ) { System . err . println ( String . format ( "File not found: '%s'" , filename ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } }
Loads a users file .
28,957
public void save ( @ OptionArgument ( "filename" ) String filename ) { try { PrintStream out = new PrintStream ( new FileOutputStream ( filename ) ) ; for ( User user : users . values ( ) ) { out . println ( user ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } }
Saves a users file .
28,958
public void adduser ( @ OptionArgument ( "username" ) String username , @ OptionArgument ( "password" ) String password , @ OptionArgument ( "roles" ) String roles ) { if ( users . containsKey ( username ) ) { System . err . println ( String . format ( "User '%s' already exists" , username ) ) ; } else { User user = new User ( username ) ; user . salt = passwd . generateSalt ( ) ; user . hash = passwd . getEncryptedPassword ( password , user . salt ) ; user . roles . addAll ( Arrays . asList ( roles . split ( "," ) ) ) ; users . put ( username , user ) ; } }
Adds a new user .
28,959
public void passwd ( @ OptionArgument ( "username" ) String username , @ OptionArgument ( "password" ) String password ) { User user = users . get ( username ) ; if ( user != null ) { user . salt = passwd . generateSalt ( ) ; user . hash = passwd . getEncryptedPassword ( password , user . salt ) ; } else { System . err . println ( String . format ( "User '%s' does not exist" , username ) ) ; } }
Resets the password of a user .
28,960
public void addroles ( @ OptionArgument ( "username" ) String username , @ OptionArgument ( "roles" ) String roles ) { User user = users . get ( username ) ; if ( user != null ) { user . roles . addAll ( Arrays . asList ( roles . split ( "," ) ) ) ; } else { System . err . println ( String . format ( "User '%s' does not exist" , username ) ) ; } }
Add roles for a user .
28,961
public static WordNetRelation create ( String name , String code , String reciprocal , double weight ) { Preconditions . checkArgument ( ! Strings . isNullOrEmpty ( name ) ) ; Preconditions . checkArgument ( weight >= 0 , "Weight must be >= 0" ) ; name = name . toUpperCase ( ) . trim ( ) . replaceAll ( "\\p{Z}+" , "_" ) ; if ( ! index . containsKey ( name ) ) { index . put ( name , new WordNetRelation ( name , reciprocal , weight , code ) ) ; } return index . get ( name ) ; }
Creates or gets a Metadata with the given name
28,962
@ SuppressWarnings ( { "unchecked" , "rawtypes" } ) public void setParameter ( String name , Enum value ) { conf . setEnum ( name , value ) ; }
parameter setting .
28,963
public void setValues ( final Collection < ? > values ) { if ( values != _values ) { clear ( ) ; if ( values == null || values . size ( ) == 0 ) { return ; } for ( Object value : values ) { addValue ( value ) ; } } }
Sets the specified values as the matching value list . First the previous list are cleared and all of the specified values are appended to the list .
28,964
public void addValue ( final Object value ) { if ( value == null ) { setNullContained ( true ) ; } else { _values . add ( String . valueOf ( value ) ) ; } }
Appends the value to the matching value list .
28,965
public void runScript ( ) { if ( script . trim ( ) . length ( ) > 0 ) { BufferedReader reader = new BufferedReader ( new StringReader ( script ) ) ; try { List results = runScript ( reader ) ; System . out . println ( new LogEntry ( Level . CRITICAL , "completed run of script in device '\" + this.deviceId + \"'\"" ) ) ; } catch ( Throwable t ) { throw new ConfigurationException ( "failed to complete run of script" , t ) ; } } }
Runs Iglu - style script .
28,966
public void setProperties ( Properties properties ) { script = properties . getProperty ( "script" , script ) ; pageIntervalInMinutes = Integer . parseInt ( properties . getProperty ( "page_interval_in_minutes" , "" + pageIntervalInMinutes ) ) ; pageOffsetInMinutes = Integer . parseInt ( properties . getProperty ( "page_offset_in_minutes" , "" + pageOffsetInMinutes ) ) ; }
Expects a property script containing the actual script to be run . Specify page_interval_in_minutes and page_offset_in_minutes to have script run periodically .
28,967
public List < SearchResult > search ( String query ) throws MovieMeterException { String url = buildSearchUrl ( query ) ; try { return mapper . readValue ( requestWebPage ( url ) , new TypeReference < List < SearchResult > > ( ) { } ) ; } catch ( IOException ex ) { throw new MovieMeterException ( ApiExceptionType . MAPPING_FAILED , "Failed to map search results" , url , ex ) ; } }
Search for a movie
28,968
private String buildIdUrl ( String id ) { StringBuilder url = new StringBuilder ( MM_URL ) . append ( id ) . append ( MM_PARAM_QST ) . append ( MM_API ) . append ( apiKey ) ; LOG . trace ( "MovieMeter URL: {}" , url ) ; return url . toString ( ) ; }
Build the ID URL
28,969
private String buildSearchUrl ( String query ) { StringBuilder url = new StringBuilder ( MM_URL ) . append ( MM_PARAM_QST ) . append ( MM_QUERY ) . append ( encoder ( query ) ) . append ( MM_PARAM_AMP ) . append ( MM_API ) . append ( apiKey ) ; LOG . trace ( "MovieMeter URL: {}" , url ) ; return url . toString ( ) ; }
Build the Query URL
28,970
private static String encoder ( final String toEncode ) { try { return URLEncoder . encode ( toEncode , URL_ENCODING ) ; } catch ( UnsupportedEncodingException ex ) { LOG . warn ( "Failed to encode: {}" , ex . getMessage ( ) , ex ) ; return "" ; } }
Encode a string for use in the URL
28,971
private < T > T readJsonObject ( final String url , final Class < T > object ) throws MovieMeterException { final String page = requestWebPage ( url ) ; if ( StringUtils . isNotBlank ( page ) ) { try { return mapper . readValue ( page , object ) ; } catch ( IOException ex ) { throw new MovieMeterException ( ApiExceptionType . MAPPING_FAILED , "Failed to read JSON object" , url , ex ) ; } } throw new MovieMeterException ( ApiExceptionType . MAPPING_FAILED , "Failed to read JSON object" , url ) ; }
Get the information for a URL and process into an object
28,972
public static LogLevel toLogLevel ( Object value ) { if ( value == null ) return LogLevel . Info ; value = value . toString ( ) . toUpperCase ( ) ; if ( "0" . equals ( value ) || "NOTHING" . equals ( value ) || "NONE" . equals ( value ) ) return LogLevel . None ; else if ( "1" . equals ( value ) || "FATAL" . equals ( value ) ) return LogLevel . Fatal ; else if ( "2" . equals ( value ) || "ERROR" . equals ( value ) ) return LogLevel . Error ; else if ( "3" . equals ( value ) || "WARN" . equals ( value ) || "WARNING" . equals ( value ) ) return LogLevel . Warn ; else if ( "4" . equals ( value ) || "INFO" . equals ( value ) ) return LogLevel . Info ; else if ( "5" . equals ( value ) || "DEBUG" . equals ( value ) ) return LogLevel . Debug ; else if ( "6" . equals ( value ) || "TRACE" . equals ( value ) ) return LogLevel . Trace ; else return LogLevel . Info ; }
Converts numbers and strings to standard log level values .
28,973
public static int toInteger ( LogLevel level ) { if ( level == LogLevel . Fatal ) return 1 ; if ( level == LogLevel . Error ) return 2 ; if ( level == LogLevel . Warn ) return 3 ; if ( level == LogLevel . Info ) return 4 ; if ( level == LogLevel . Debug ) return 5 ; if ( level == LogLevel . Trace ) return 6 ; return 0 ; }
Converts log level to a number .
28,974
private LoadBalancerHealthCheck toLoadBalancerHealthCheck ( JSONObject ob ) throws JSONException , InternalException , CloudException { LoadBalancerHealthCheck . HCProtocol protocol = fromOSProtocol ( ob . getString ( "type" ) ) ; int count = ob . getInt ( "max_retries" ) ; int port = - 1 ; String path = ob . optString ( "url_path" , null ) ; JSONArray pools = ob . optJSONArray ( "pools" ) ; for ( int i = 0 ; i < pools . length ( ) ; i ++ ) { String lbId = pools . getJSONObject ( i ) . getString ( "pool_id" ) ; LoadBalancer lb = getLoadBalancer ( lbId ) ; if ( lb != null ) { LbListener [ ] listeners = lb . getListeners ( ) ; if ( listeners != null && listeners . length > 0 ) { port = listeners [ 0 ] . getPrivatePort ( ) ; break ; } } } String id = ob . getString ( "id" ) ; int timeout = ob . getInt ( "timeout" ) ; int interval = ob . getInt ( "delay" ) ; LoadBalancerHealthCheck lbhc = LoadBalancerHealthCheck . getInstance ( id , protocol , port , path , interval , timeout , count , count ) ; for ( int i = 0 ; i < pools . length ( ) ; i ++ ) { lbhc . addProviderLoadBalancerId ( pools . getJSONObject ( i ) . getString ( "pool_id" ) ) ; } return lbhc ; }
Convert OpenStack health_monitor object to Dasein LoadBalancerHealthCheck
28,975
public static final void assertProcessActive ( final String processInstanceId ) { Validate . notNull ( processInstanceId ) ; apiCallback . debug ( LogMessage . PROCESS_1 , processInstanceId ) ; try { getProcessInstanceAssertable ( ) . processIsActive ( processInstanceId ) ; } catch ( final AssertionError ae ) { apiCallback . fail ( ae , LogMessage . ERROR_PROCESS_1 , processInstanceId ) ; } }
Asserts the process instance with the provided id is active i . e . the process instance is not ended .
28,976
public static final void assertProcessEnded ( final String processInstanceId ) { Validate . notNull ( processInstanceId ) ; apiCallback . debug ( LogMessage . PROCESS_5 , processInstanceId ) ; try { getProcessInstanceAssertable ( ) . processIsEnded ( processInstanceId ) ; } catch ( final AssertionError ae ) { apiCallback . fail ( ae , LogMessage . ERROR_PROCESS_2 , processInstanceId ) ; } }
Asserts the process instance with the provided id is ended .
28,977
public static final void assertTaskUncompleted ( final String taskId ) { Validate . notNull ( taskId ) ; apiCallback . debug ( LogMessage . TASK_2 , taskId ) ; try { getTaskInstanceAssertable ( ) . taskIsUncompleted ( taskId ) ; } catch ( final AssertionError ae ) { apiCallback . fail ( ae , LogMessage . ERROR_TASK_2 , taskId ) ; } }
Asserts the task with the provided id is pending completion .
28,978
public static final void assertTaskUncompleted ( final String processInstanceId , final String taskDefinitionKey ) { Validate . notNull ( processInstanceId ) ; Validate . notNull ( taskDefinitionKey ) ; apiCallback . debug ( LogMessage . TASK_1 , taskDefinitionKey , processInstanceId ) ; try { getTaskInstanceAssertable ( ) . taskIsUncompleted ( processInstanceId , taskDefinitionKey ) ; } catch ( final AssertionError ae ) { apiCallback . fail ( ae , LogMessage . ERROR_TASK_1 , taskDefinitionKey , processInstanceId ) ; } }
Asserts a task with the provided taskDefinitionKey is pending completion in the process instance with the provided processInstanceId .
28,979
protected < T > T _executeTx ( final String operation , final Class < ? extends Persistable < ? > > type , final TransactionCallback < T > action ) { return _executeTx ( operation , type , null , action ) ; }
Executes the specified action in a new transaction .
28,980
private static String unsignedToString ( int value ) { if ( value >= 0 ) { return Integer . toString ( value ) ; } else { return Long . toString ( ( value ) & 0x00000000FFFFFFFFL ) ; } }
Convert an unsigned 32 - bit integer to a string .
28,981
private static StringBuilder toStringBuilder ( Readable input ) throws IOException { StringBuilder text = new StringBuilder ( ) ; CharBuffer buffer = CharBuffer . allocate ( BUFFER_SIZE ) ; while ( true ) { int n = input . read ( buffer ) ; if ( n == - 1 ) { break ; } buffer . flip ( ) ; text . append ( buffer , 0 , n ) ; } return text ; }
overhead is worthwhile
28,982
public RESTAssignedPropertyTagCollectionV1 getRESTPropertyTagInTopicRevisions ( int id , final Integer revision , final RESTBaseTopicV1 < ? , ? , ? > topic ) { final RESTAssignedPropertyTagCollectionV1 propertyTagRevisions ; if ( topic instanceof RESTTranslatedTopicV1 ) { propertyTagRevisions = getRESTTranslatedTopicPropertyRevisions ( id , revision , topic ) ; } else { propertyTagRevisions = getRESTTopicPropertyRevisions ( id , revision , topic ) ; } return propertyTagRevisions ; }
Get the REST Property Tag Revision Collection for a specific Property Tag defined by ID and Revision .
28,983
public CollectionWrapper < PropertyTagInTopicWrapper > getPropertyTagInTopicRevisions ( int id , final Integer revision , final RESTBaseTopicV1 < ? , ? , ? > topic ) { return RESTCollectionWrapperBuilder . < PropertyTagInTopicWrapper > newBuilder ( ) . providerFactory ( getProviderFactory ( ) ) . collection ( getRESTPropertyTagInTopicRevisions ( id , revision , topic ) ) . isRevisionCollection ( ) . parent ( topic ) . expandedEntityMethods ( Arrays . asList ( "getRevisions" ) ) . entityWrapperInterface ( PropertyTagInTopicWrapper . class ) . build ( ) ; }
Get the Wrapped Property Tag Revision Collection for a specific Property Tag defined by ID and Revision .
28,984
public static Message fromString ( String messageFrame ) throws InvalidMessageException { String prefix = null ; String trailing = null ; messageFrame = messageFrame . trim ( ) ; if ( messageFrame . startsWith ( ":" ) ) { int splitPoint = messageFrame . indexOf ( ' ' ) ; prefix = messageFrame . substring ( 1 , splitPoint ) ; messageFrame = messageFrame . substring ( splitPoint + 1 ) . trim ( ) ; } int trailingPoint = messageFrame . indexOf ( ':' ) ; if ( trailingPoint != - 1 ) { trailing = messageFrame . substring ( trailingPoint + 1 ) ; messageFrame = messageFrame . substring ( 0 , trailingPoint ) . trim ( ) ; } int endTypePoint = messageFrame . indexOf ( ' ' ) ; String typeString ; if ( endTypePoint == - 1 ) { typeString = messageFrame ; messageFrame = "" ; } else { typeString = messageFrame . substring ( 0 , endTypePoint ) ; messageFrame = messageFrame . substring ( endTypePoint + 1 ) . trim ( ) ; } MessageType type = MessageType . fromString ( typeString ) ; if ( type == null ) { throw new InvalidMessageException ( "invalid type: " + typeString ) ; } LinkedList < String > argsList = new LinkedList < String > ( ) ; while ( messageFrame . length ( ) > 0 ) { int nextSpace = messageFrame . indexOf ( ' ' ) ; if ( nextSpace == - 1 ) { argsList . add ( messageFrame ) ; break ; } else { argsList . add ( messageFrame . substring ( 0 , nextSpace ) ) ; messageFrame = messageFrame . substring ( nextSpace + 1 ) . trim ( ) ; } } if ( trailing != null ) { argsList . add ( trailing ) ; } String [ ] args = new String [ argsList . size ( ) ] ; return new Message ( prefix , type , argsList . toArray ( args ) ) ; }
Decode the given IRC message a string into an IRCMessage object
28,985
public static int processResponses ( PushNotificationManager notificationManager ) { List < ResponsePacket > responses = readResponses ( notificationManager . getActiveSocket ( ) ) ; handleResponses ( responses , notificationManager ) ; return responses . size ( ) ; }
Read response packets from the current APNS connection and process them .
28,986
private static List < ResponsePacket > readResponses ( Socket socket ) { List < ResponsePacket > responses = new Vector < ResponsePacket > ( ) ; int previousTimeout = 0 ; try { try { previousTimeout = socket . getSoTimeout ( ) ; socket . setSoTimeout ( TIMEOUT ) ; } catch ( Exception e ) { } InputStream input = socket . getInputStream ( ) ; while ( true ) { ResponsePacket packet = readResponsePacketData ( input ) ; if ( packet != null ) responses . add ( packet ) ; else break ; } } catch ( Exception e ) { } try { socket . setSoTimeout ( previousTimeout ) ; } catch ( Exception e ) { } return responses ; }
Read raw response packets from the provided socket .
28,987
public Set < ClassModel > getAllClassDependencies ( ) { HashSet < ClassModel > result = new HashSet < > ( ) ; ClassModel . getAllClassDependencies ( result , this ) ; return result ; }
All classes this class depends upon . Includes all transitive dependencies of this class even if the dependencies are not in a module themselves .
28,988
public void initializeConnection ( AppleNotificationServer server ) throws CommunicationException , KeystoreException { try { this . connectionToAppleServer = new ConnectionToNotificationServer ( server ) ; this . socket = connectionToAppleServer . getSSLSocket ( ) ; if ( heavyDebugMode ) { dumpCertificateChainDescription ( ) ; } logger . debug ( "Initialized Connection to Host: [" + server . getNotificationServerHost ( ) + "] Port: [" + server . getNotificationServerPort ( ) + "]: " + socket ) ; } catch ( KeystoreException e ) { throw e ; } catch ( CommunicationException e ) { throw e ; } catch ( Exception e ) { throw new CommunicationException ( "Error creating connection with Apple server" , e ) ; } }
Initialize a connection and create a SSLSocket
28,989
private void restartPreviousConnection ( ) throws CommunicationException , KeystoreException { try { logger . debug ( "Closing connection to restart previous one" ) ; this . socket . close ( ) ; } catch ( Exception e ) { } initializePreviousConnection ( ) ; }
Stop and restart the current connection to the Apple server using server settings from the previous connection .
28,990
public void stopConnection ( ) throws CommunicationException , KeystoreException { processedFailedNotifications ( ) ; try { logger . debug ( "Closing connection" ) ; this . socket . close ( ) ; } catch ( Exception e ) { } }
Read and process any pending error - responses and then close the connection .
28,991
private int processedFailedNotifications ( ) throws CommunicationException , KeystoreException { if ( useEnhancedNotificationFormat ) { logger . debug ( "Reading responses" ) ; int responsesReceived = ResponsePacketReader . processResponses ( this ) ; while ( responsesReceived > 0 ) { PushedNotification skippedNotification = null ; List < PushedNotification > notificationsToResend = new ArrayList < PushedNotification > ( ) ; boolean foundFirstFail = false ; for ( PushedNotification notification : pushedNotifications . values ( ) ) { if ( foundFirstFail || ! notification . isSuccessful ( ) ) { if ( foundFirstFail ) notificationsToResend . add ( notification ) ; else { foundFirstFail = true ; skippedNotification = notification ; } } } pushedNotifications . clear ( ) ; int toResend = notificationsToResend . size ( ) ; logger . debug ( "Found " + toResend + " notifications that must be re-sent" ) ; if ( toResend > 0 ) { logger . debug ( "Restarting connection to resend notifications" ) ; restartPreviousConnection ( ) ; for ( PushedNotification pushedNotification : notificationsToResend ) { sendNotification ( pushedNotification , false ) ; } } int remaining = responsesReceived = ResponsePacketReader . processResponses ( this ) ; if ( remaining == 0 ) { logger . debug ( "No notifications remaining to be resent" ) ; return 0 ; } } return responsesReceived ; } else { logger . debug ( "Not reading responses because using simple notification format" ) ; return 0 ; } }
Read and process any pending error - responses .
28,992
public PushedNotification sendNotification ( Device device , Payload payload ) throws CommunicationException { return sendNotification ( device , payload , true ) ; }
Send a notification to a single device and close the connection .
28,993
public OutputStream getStreamAt ( int index ) { if ( index < streams . size ( ) ) { int i = 0 ; for ( Entry < OutputStream , Boolean > entry : streams . entrySet ( ) ) { if ( i ++ == index ) { return entry . getKey ( ) ; } } } return null ; }
Returns the stream at the given index .
28,994
public static ArrayList < HashMap < String , String > > computeSoilLayerSize ( ArrayList < HashMap < String , String > > soilsData ) { float deep = 0.0f ; ArrayList < HashMap < String , String > > newSoilsData ; newSoilsData = new ArrayList < HashMap < String , String > > ( ) ; for ( HashMap < String , String > currentSoil : soilsData ) { HashMap < String , String > newCurrentSoil = new HashMap < String , String > ( currentSoil ) ; newCurrentSoil . put ( LayerReducer . SLLB , new Float ( parseFloat ( currentSoil . get ( LayerReducer . SLLB ) ) - deep ) . toString ( ) ) ; deep = parseFloat ( currentSoil . get ( LayerReducer . SLLB ) ) ; newSoilsData . add ( newCurrentSoil ) ; } return newSoilsData ; }
Compute soil layer thickness
28,995
private static synchronized String getFile ( String name ) { if ( Objects . isNullOrEmpty ( baseDirectory ) ) { baseDirectory = Options . getStorage ( ) . getSystem ( "numberSequence.home" , System . getProperty ( "user.home" ) + File . separator + ".s1-sequences" ) ; } File dir = new File ( baseDirectory ) ; if ( ! dir . exists ( ) ) dir . mkdirs ( ) ; if ( ! dir . isDirectory ( ) ) throw new S1SystemError ( "Directory error: " + baseDirectory ) ; return dir . getAbsolutePath ( ) + File . separator + name ; }
Get file and ensure dir exists cache directory
28,996
public Betner reset ( String target ) { this . rebuild = ! target4Betn . equals ( target ) ; this . target4Betn = target ; return this ; }
Reset the given target String as delegate String
28,997
public int countMatches ( ) { if ( null != this . positions && this . positions . isPresent ( ) ) { return this . positions . get ( ) . size ( ) ; } if ( Strs . isEmpty ( target4Betn ) ) { return 0 ; } if ( ! region . isPresent ( ) ) { return 0 ; } if ( isEqual ( region . get ( ) [ 0 ] , region . get ( ) [ 1 ] ) ) { int matchCount = count ( target4Betn , region . get ( ) [ 1 ] ) ; if ( this . matchWay . get ( ) == 'R' || this . matchWay . get ( ) == 'L' ) { return matchCount ; } matchCount = ( matchCount % 2 == 0 ) ? matchCount : ( matchCount - 1 ) ; return matchCount / 2 ; } return Math . min ( count ( target4Betn , region . get ( ) [ 0 ] ) , count ( target4Betn , region . get ( ) [ 1 ] ) ) ; }
Returns the number of matching string found in delegate string
28,998
public String result ( int positionNum ) { Pair < Integer , Integer > kv = null ; if ( null != ( kv = position ( positionNum , false ) ) ) { return doSubstring ( kv ) ; } return EMPTY ; }
Returns the substring in given range with given left position number
28,999
public Map < Integer , String > asMap ( ) { initializePosition ( ) ; final Map < Integer , String > results = Maps . newHashMap ( ) ; Mapper . from ( positions . get ( ) ) . entryLoop ( new Decisional < Map . Entry < Integer , Pair < Integer , Integer > > > ( ) { protected void decision ( Entry < Integer , Pair < Integer , Integer > > input ) { results . put ( input . getKey ( ) , doSubstring ( input . getValue ( ) ) ) ; } } ) ; return results ; }
Returns the substring results in given range as a map left position number as key substring as value