idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
124,500
public static String unicodeToString ( String s ) { StringBuilder sb = new StringBuilder ( ) ; StringTokenizer st = new StringTokenizer ( s , "\\u" ) ; while ( st . hasMoreTokens ( ) ) { String token = st . nextToken ( ) ; if ( token . length ( ) > 4 ) { sb . append ( ( char ) Integer . parseInt ( token . substring ( 0...
Convert a string that is unicode form to a normal string .
124,501
public static void append ( StringBuilder buf , String s , int offset , int length ) { synchronized ( buf ) { int end = offset + length ; for ( int i = offset ; i < end ; i ++ ) { if ( i >= s . length ( ) ) break ; buf . append ( s . charAt ( i ) ) ; } } }
Append substring to StringBuilder
124,502
public static void append ( StringBuilder buf , byte b , int base ) { int bi = 0xff & b ; int c = '0' + ( bi / base ) % base ; if ( c > '9' ) c = 'a' + ( c - '0' - 10 ) ; buf . append ( ( char ) c ) ; c = '0' + bi % base ; if ( c > '9' ) c = 'a' + ( c - '0' - 10 ) ; buf . append ( ( char ) c ) ; }
append hex digit
124,503
public static int toInt ( String string , int from ) { int val = 0 ; boolean started = false ; boolean minus = false ; for ( int i = from ; i < string . length ( ) ; i ++ ) { char b = string . charAt ( i ) ; if ( b <= ' ' ) { if ( started ) break ; } else if ( b >= '0' && b <= '9' ) { val = val * 10 + ( b - '0' ) ; sta...
Convert String to an integer . Parses up to the first non - numeric character . If no number is found an IllegalArgumentException is thrown
124,504
public static String truncate ( String str , int maxSize ) { if ( str == null ) { return null ; } if ( str . length ( ) <= maxSize ) { return str ; } return str . substring ( 0 , maxSize ) ; }
Truncate a string to a max size .
124,505
public static String parentPath ( String p ) { if ( p == null || URIUtils . SLASH . equals ( p ) ) return null ; int slash = p . lastIndexOf ( '/' , p . length ( ) - 2 ) ; if ( slash >= 0 ) return p . substring ( 0 , slash + 1 ) ; return null ; }
Return the parent Path . Treat a URI like a directory path and return the parent directory .
124,506
public static String newURI ( String scheme , String server , int port , String path , String query ) { StringBuilder builder = newURIBuilder ( scheme , server , port ) ; builder . append ( path ) ; if ( query != null && query . length ( ) > 0 ) builder . append ( '?' ) . append ( query ) ; return builder . toString ( ...
Create a new URI from the arguments handling IPv6 host encoding and default ports
124,507
public static StringBuilder newURIBuilder ( String scheme , String server , int port ) { StringBuilder builder = new StringBuilder ( ) ; appendSchemeHostPort ( builder , scheme , server , port ) ; return builder ; }
Create a new URI StringBuilder from the arguments handling IPv6 host encoding and default ports
124,508
public static void appendSchemeHostPort ( StringBuilder url , String scheme , String server , int port ) { url . append ( scheme ) . append ( "://" ) . append ( HostPort . normalizeHost ( server ) ) ; if ( port > 0 ) { switch ( scheme ) { case "http" : if ( port != 80 ) url . append ( ':' ) . append ( port ) ; break ; ...
Append scheme host and port URI prefix handling IPv6 address encoding and default ports
124,509
private boolean parsePayload ( ByteBuffer buffer ) { if ( payloadLength == 0 ) { return true ; } if ( buffer . hasRemaining ( ) ) { int bytesSoFar = payload == null ? 0 : payload . position ( ) ; int bytesExpected = payloadLength - bytesSoFar ; int bytesAvailable = buffer . remaining ( ) ; int windowBytes = Math . min ...
Implementation specific parsing of a payload
124,510
public static < V > Predicate < TaskContext < V > > ifException ( Predicate < ? super Exception > predicate ) { return ctx -> predicate . test ( ctx . getException ( ) ) ; }
If the task throws some exceptions the task will be retried .
124,511
public static < V > Predicate < TaskContext < V > > ifResult ( Predicate < V > predicate ) { return ctx -> predicate . test ( ctx . getResult ( ) ) ; }
If the task result satisfies condition the task will be retried .
124,512
public static String dequote ( String str ) { char start = str . charAt ( 0 ) ; if ( ( start == '\'' ) || ( start == '\"' ) ) { char end = str . charAt ( str . length ( ) - 1 ) ; if ( start == end ) { return str . substring ( 1 , str . length ( ) - 1 ) ; } } return str ; }
Remove quotes from a string only if the input string start with and end with the same quote character .
124,513
public static void quote ( StringBuilder buf , String str ) { buf . append ( '"' ) ; escape ( buf , str ) ; buf . append ( '"' ) ; }
Simple quote of a string escaping where needed .
124,514
public static Iterator < String > splitAt ( String str , String delims ) { return new DeQuotingStringIterator ( str . trim ( ) , delims ) ; }
Create an iterator of the input string breaking apart the string at the provided delimiters removing quotes and triming the parts of the string as needed .
124,515
public static final String bytesToHex ( byte [ ] bs , int off , int length ) { if ( bs . length <= off || bs . length < off + length ) throw new IllegalArgumentException ( ) ; StringBuilder sb = new StringBuilder ( length * 2 ) ; bytesToHexAppend ( bs , off , length , sb ) ; return sb . toString ( ) ; }
Converts a byte array into a string of lower case hex chars .
124,516
public static final void hexToBytes ( String s , byte [ ] out , int off ) throws NumberFormatException , IndexOutOfBoundsException { int slen = s . length ( ) ; if ( ( slen % 2 ) != 0 ) { s = '0' + s ; } if ( out . length < off + slen / 2 ) { throw new IndexOutOfBoundsException ( "Output buffer too small for input (" +...
Converts a String of hex characters into an array of bytes .
124,517
public static void hexToBits ( String s , BitSet ba , int length ) { byte [ ] b = hexToBytes ( s ) ; bytesToBits ( b , ba , length ) ; }
Read a hex string of bits and write it into a bitset
124,518
public static long random ( long min , long max ) { return Math . round ( ThreadLocalRandom . current ( ) . nextDouble ( ) * ( max - min ) + min ) ; }
Generates a random number from a specified range
124,519
public static int randomSegment ( int [ ] probability ) { int total = 0 ; for ( int i = 0 ; i < probability . length ; i ++ ) { total += probability [ i ] ; probability [ i ] = total ; } int rand = ( int ) random ( 0 , total - 1 ) ; for ( int i = 0 ; i < probability . length ; i ++ ) { if ( rand < probability [ i ] ) {...
Returns the index of array that specifies probability .
124,520
public static String randomString ( int length ) { StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < length ; i ++ ) { int index = ( int ) random ( 0 , ALL_CHAR . length ( ) - 1 ) ; sb . append ( ALL_CHAR . charAt ( index ) ) ; } return sb . toString ( ) ; }
Returns a random string .
124,521
public static void set ( Object obj , String property , Object value ) throws Throwable { getSetterMethod ( obj . getClass ( ) , property ) . invoke ( obj , value ) ; }
Invokes a object s setter method by property name
124,522
public static Object get ( Object obj , String property ) throws Throwable { return getGetterMethod ( obj . getClass ( ) , property ) . invoke ( obj ) ; }
Invokes a object s getter method by property name
124,523
public static String [ ] getInterfaceNames ( Class < ? > c ) { Class < ? > [ ] interfaces = c . getInterfaces ( ) ; List < String > names = new ArrayList < > ( ) ; for ( Class < ? > i : interfaces ) { names . add ( i . getName ( ) ) ; } return names . toArray ( new String [ 0 ] ) ; }
Gets the all interface names of this class
124,524
@ SuppressWarnings ( "unchecked" ) public static Object convert ( Collection < ? > collection , Class < ? > arrayType ) { int size = collection . size ( ) ; Object newArray = Array . newInstance ( Optional . ofNullable ( arrayType ) . filter ( Class :: isArray ) . map ( Class :: getComponentType ) . orElse ( ( Class ) ...
Returns an array object this method converts a collection object to an array object through the specified element type of the array .
124,525
@ SuppressWarnings ( "unchecked" ) public static Collection < Object > getCollectionObj ( Class < ? > clazz ) { if ( clazz . isInterface ( ) ) { if ( clazz . isAssignableFrom ( List . class ) ) return new ArrayList < > ( ) ; else if ( clazz . isAssignableFrom ( Set . class ) ) return new HashSet < > ( ) ; else if ( cla...
Returns a collection object instance by class
124,526
public static boolean isJarURL ( URL url ) { String protocol = url . getProtocol ( ) ; return ( URL_PROTOCOL_JAR . equals ( protocol ) || URL_PROTOCOL_ZIP . equals ( protocol ) || URL_PROTOCOL_VFSZIP . equals ( protocol ) || URL_PROTOCOL_WSJAR . equals ( protocol ) ) ; }
Determine whether the given URL points to a resource in a jar file that is has protocol jar zip vfszip or wsjar .
124,527
public static boolean isJarFileURL ( URL url ) { return ( URL_PROTOCOL_FILE . equals ( url . getProtocol ( ) ) && url . getPath ( ) . toLowerCase ( ) . endsWith ( JAR_FILE_EXTENSION ) ) ; }
Determine whether the given URL points to a jar file itself that is has protocol file and ends with the . jar extension .
124,528
public Pair < Integer , List < ByteBuffer > > data ( DataFrame frame , int maxLength ) { return dataGenerator . generate ( frame , maxLength ) ; }
Encode data frame to binary codes
124,529
public Collection < Part > getParsedParts ( ) { if ( _parts == null ) return Collections . emptyList ( ) ; Collection < List < Part > > values = _parts . values ( ) ; List < Part > parts = new ArrayList < > ( ) ; for ( List < Part > o : values ) { List < Part > asList = LazyList . getList ( o , false ) ; parts . addAll...
Get the already parsed parts .
124,530
public void deleteParts ( ) { if ( ! _parsed ) return ; Collection < Part > parts ; try { parts = getParts ( ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } MultiException err = null ; for ( Part p : parts ) { try { ( ( MultiPart ) p ) . cleanUp ( ) ; } catch ( Exception e ) { if ( err == null ) er...
Delete any tmp storage for parts and clear out the parts list .
124,531
public Collection < Part > getParts ( ) throws IOException { if ( ! _parsed ) parse ( ) ; throwIfError ( ) ; Collection < List < Part > > values = _parts . values ( ) ; List < Part > parts = new ArrayList < > ( ) ; for ( List < Part > o : values ) { List < Part > asList = LazyList . getList ( o , false ) ; parts . addA...
Parse if necessary the multipart data and return the list of Parts .
124,532
public Part getPart ( String name ) throws IOException { if ( ! _parsed ) parse ( ) ; throwIfError ( ) ; return _parts . getValue ( name , 0 ) ; }
Get the named Part .
124,533
protected void throwIfError ( ) throws IOException { if ( _err != null ) { _err . addSuppressed ( new Throwable ( ) ) ; if ( _err instanceof IOException ) throw ( IOException ) _err ; if ( _err instanceof IllegalStateException ) throw ( IllegalStateException ) _err ; throw new IllegalStateException ( _err ) ; } }
Throws an exception if one has been latched .
124,534
protected void parse ( ) { if ( _parsed ) return ; _parsed = true ; try { _parts = new MultiMap < > ( ) ; if ( _contentType == null || ! _contentType . startsWith ( "multipart/form-data" ) ) return ; if ( _config . getLocation ( ) == null ) _tmpDir = _contextTmpDir ; else if ( "" . equals ( _config . getLocation ( ) ) ...
Parse if necessary the multipart stream .
124,535
protected boolean doHandshake ( ByteBuffer receiveBuffer ) throws IOException { if ( ! session . isOpen ( ) ) { close ( ) ; return ( initialHSComplete = false ) ; } if ( initialHSComplete ) { return true ; } switch ( initialHSStatus ) { case NOT_HANDSHAKING : case FINISHED : { handshakeFinish ( ) ; return initialHSComp...
The initial handshake is a procedure by which the two peers exchange communication parameters until an SecureSession is established . Application data can not be sent during this phase .
124,536
protected SSLEngineResult . HandshakeStatus doTasks ( ) { Runnable runnable ; while ( ( runnable = sslEngine . getDelegatedTask ( ) ) != null ) { runnable . run ( ) ; } return sslEngine . getHandshakeStatus ( ) ; }
Do all the outstanding handshake tasks in the current Thread .
124,537
public ByteBuffer read ( ByteBuffer receiveBuffer ) throws IOException { if ( ! doHandshake ( receiveBuffer ) ) return null ; if ( ! initialHSComplete ) throw new IllegalStateException ( "The initial handshake is not complete." ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "session {} read data status -> {}, init...
This method is used to decrypt data it implied do handshake
124,538
public int write ( ByteBuffer outAppBuf , Callback callback ) throws IOException { if ( ! initialHSComplete ) { IllegalStateException ex = new IllegalStateException ( "The initial handshake is not complete." ) ; callback . failed ( ex ) ; throw ex ; } int ret = 0 ; if ( ! outAppBuf . hasRemaining ( ) ) { callback . suc...
This method is used to encrypt and flush to socket channel
124,539
protected void beanDefinitionCheck ( ) { for ( int i = 0 ; i < beanDefinitions . size ( ) ; i ++ ) { for ( int j = i + 1 ; j < beanDefinitions . size ( ) ; j ++ ) { BeanDefinition b1 = beanDefinitions . get ( i ) ; BeanDefinition b2 = beanDefinitions . get ( j ) ; if ( VerifyUtils . isNotEmpty ( b1 . getId ( ) ) && Ver...
Bean definition conflict check
124,540
public void registerHealthCheck ( Task task ) { Optional . ofNullable ( config . getHealthCheck ( ) ) . ifPresent ( healthCheck -> healthCheck . register ( task ) ) ; }
Register an health check task .
124,541
public void clearHealthCheck ( String name ) { Optional . ofNullable ( config . getHealthCheck ( ) ) . ifPresent ( healthCheck -> healthCheck . clear ( name ) ) ; }
Clear the health check task .
124,542
private static int skipCommentsAndQuotes ( char [ ] statement , int position ) { for ( int i = 0 ; i < START_SKIP . length ; i ++ ) { if ( statement [ position ] == START_SKIP [ i ] . charAt ( 0 ) ) { boolean match = true ; for ( int j = 1 ; j < START_SKIP [ i ] . length ( ) ; j ++ ) { if ( ! ( statement [ position + j...
Skip over comments and quoted names present in an SQL statement
124,543
private static boolean isParameterSeparator ( char c ) { if ( Character . isWhitespace ( c ) ) { return true ; } for ( char separator : PARAMETER_SEPARATORS ) { if ( c == separator ) { return true ; } } return false ; }
Determine whether a parameter name ends at the current position that is whether the given character qualifies as a separator .
124,544
protected boolean complianceViolation ( HttpComplianceSection violation , String reason ) { if ( _compliances . contains ( violation ) ) return true ; if ( reason == null ) reason = violation . description ; if ( _complianceHandler != null ) _complianceHandler . onComplianceViolation ( _compliance , violation , reason ...
Check RFC compliance violation
124,545
public void setSubProtocols ( String ... protocols ) { subProtocols . clear ( ) ; Collections . addAll ( subProtocols , protocols ) ; }
Set Sub Protocol request list .
124,546
public Set < String > getFieldNamesCollection ( ) { final Set < String > set = new HashSet < > ( _size ) ; for ( HttpField f : this ) { if ( f != null ) set . add ( f . getName ( ) ) ; } return set ; }
Get Collection of header names .
124,547
public long getLongField ( String name ) throws NumberFormatException { HttpField field = getField ( name ) ; return field == null ? - 1L : field . getLongValue ( ) ; }
Get a header as an long value . Returns the value of an integer field or - 1 if not found . The case of the field name is ignored .
124,548
public void putLongField ( HttpHeader name , long value ) { String v = Long . toString ( value ) ; put ( name , v ) ; }
Sets the value of an long field .
124,549
public static Set < Class < ? > > getAllInterfacesAsSet ( Object instance ) { Assert . notNull ( instance , "Instance must not be null" ) ; return getAllInterfacesForClassAsSet ( instance . getClass ( ) ) ; }
Return all interfaces that the given instance implements as Set including ones implemented by superclasses .
124,550
public void removeLL ( ) { if ( head [ 0 ] == this ) head [ 0 ] = nextTag ; if ( prevTag != null ) { prevTag . nextTag = nextTag ; } if ( nextTag != null ) { nextTag . prevTag = prevTag ; } }
Removes this tag from the chain connecting prevTag and nextTag . Does not modify this object s pointers so the caller can refer to nextTag after removing it .
124,551
private IntsRef postingsEnumToIntsRef ( PostingsEnum postingsEnum , Bits liveDocs ) throws IOException { if ( docIdsCache != null ) { docIds = docIdsCache . get ( prefixBuf ) ; if ( docIds != null ) { return docIds ; } } docIds = new IntsRef ( termsEnum . docFreq ( ) ) ; int docId ; while ( ( docId = postingsEnum . nex...
Returns an IntsRef either cached or reading postingsEnum . Not null .
124,552
private void setTopInitArgsAsInvariants ( SolrQueryRequest req ) { HashMap < String , String > map = new HashMap < > ( initArgs . size ( ) ) ; for ( int i = 0 ; i < initArgs . size ( ) ; i ++ ) { Object val = initArgs . getVal ( i ) ; if ( val != null && ! ( val instanceof NamedList ) ) map . put ( initArgs . getName (...
This request handler supports configuration options defined at the top level as well as those in typical Solr defaults appends and invariants . The top level ones are treated as invariants .
124,553
public void unzip ( String zipFile , String location ) throws IOException { final int BUFFER_SIZE = 10240 ; int size ; byte [ ] buffer = new byte [ BUFFER_SIZE ] ; try { if ( ! location . endsWith ( "/" ) ) { location += "/" ; } File f = new File ( location ) ; if ( ! f . isDirectory ( ) ) { f . mkdirs ( ) ; } ZipInput...
Unzip a zip file . Will overwrite existing files .
124,554
public boolean ping ( ) throws IOException { try ( Socket s = new Socket ( hostName , port ) ; OutputStream outs = s . getOutputStream ( ) ) { s . setSoTimeout ( timeout ) ; outs . write ( asBytes ( "zPING\0" ) ) ; outs . flush ( ) ; byte [ ] b = new byte [ PONG_REPLY_LEN ] ; InputStream inputStream = s . getInputStrea...
Run PING command to clamd to test it is responding .
124,555
public static boolean isCleanReply ( byte [ ] reply ) { String r = new String ( reply , StandardCharsets . US_ASCII ) ; return ( r . contains ( "OK" ) && ! r . contains ( "FOUND" ) ) ; }
Interpret the result from a ClamAV scan and determine if the result means the data is clean
124,556
private static byte [ ] readAll ( InputStream is ) throws IOException { ByteArrayOutputStream tmp = new ByteArrayOutputStream ( ) ; byte [ ] buf = new byte [ 2000 ] ; int read = 0 ; do { read = is . read ( buf ) ; tmp . write ( buf , 0 , read ) ; } while ( ( read > 0 ) && ( is . available ( ) > 0 ) ) ; return tmp . toB...
reads all available bytes from the stream
124,557
private void setViewsVisibility ( ) { if ( mSeekBar != null ) { mSeekBar . setVisibility ( View . VISIBLE ) ; } if ( mPlaybackTime != null ) { mPlaybackTime . setVisibility ( View . VISIBLE ) ; } if ( mRunTime != null ) { mRunTime . setVisibility ( View . VISIBLE ) ; } if ( mTotalTime != null ) { mTotalTime . setVisibi...
Ensure the views are visible before playing the audio .
124,558
public synchronized static final IntervalLoggerController getControllerInstance ( ) { IntervalLoggerController ic = null ; if ( instance == null ) { instance = new DefaultIntervalLoggerController ( ) ; ic = new IntervalLoggerControllerWrapper ( instance ) ; } else { if ( ! instance . isRunning ( ) ) { instance = new De...
Return a single instance of the IntervalLoggerController .
124,559
public static String toSHA ( byte [ ] input ) { try { MessageDigest md = MessageDigest . getInstance ( "SHA-256" ) ; return byteArray2Hex ( md . digest ( input ) ) ; } catch ( NoSuchAlgorithmException nsae ) { } return null ; }
Converts an input byte array to a SHA hash . The actual hash strength is hidden by the method name to allow for future - proofing this API but the current default is SHA - 256 .
124,560
private static String byteArray2Hex ( final byte [ ] hash ) { try ( Formatter formatter = new Formatter ( ) ; ) { for ( byte b : hash ) { formatter . format ( "%02x" , b ) ; } String hex = formatter . toString ( ) ; return hex ; } }
Converts an input byte array to a hex encoded String .
124,561
public String formatStatusMessage ( IntervalProperty [ ] properties ) { StringBuffer buff = new StringBuffer ( 500 ) ; buff . append ( "Watchdog: " ) ; for ( IntervalProperty p : properties ) { buff . append ( p . getName ( ) ) ; buff . append ( "=" ) ; buff . append ( p . getValue ( ) ) ; buff . append ( ", " ) ; } if...
Format the message to be logged .
124,562
public LogEvent rewrite ( LogEvent source ) { Marker sourceMarker = source . getMarker ( ) ; if ( sourceMarker == null ) { return source ; } final Message msg = source . getMessage ( ) ; if ( msg == null || ! ( msg instanceof ParameterizedMessage ) ) { return source ; } Object [ ] params = msg . getParameters ( ) ; if ...
Rewrite the event .
124,563
public static void logShellEnvironmentVariables ( ) { Map < String , String > env = System . getenv ( ) ; Iterator < String > keys = env . keySet ( ) . iterator ( ) ; while ( keys . hasNext ( ) ) { String key = keys . next ( ) ; String value = env . get ( key ) ; logMessage ( "Env, " + key + "=" + value . trim ( ) ) ; ...
Log shell environment variables associated with Java process .
124,564
public static void logJavaSystemProperties ( ) { Properties properties = System . getProperties ( ) ; Iterator < Object > keys = properties . keySet ( ) . iterator ( ) ; while ( keys . hasNext ( ) ) { Object key = keys . next ( ) ; Object value = properties . get ( key ) ; logMessage ( "SysProp, " + key + "=" + value ....
Log Java system properties .
124,565
public synchronized void refresh ( ) { IntervalProperty [ ] properties = getProperties ( ) ; for ( IntervalProperty p : properties ) { p . refresh ( ) ; } }
Signal properties to update themselves .
124,566
private int getThreadState ( Thread . State state ) { Thread [ ] threads = getAllThreads ( ) ; int ct = 0 ; for ( Thread thread : threads ) { if ( state . equals ( thread . getState ( ) ) ) ct ++ ; } return ct ; }
Utility method to retrieve the number of threads of a specified state .
124,567
private Thread [ ] getAllThreads ( ) { final ThreadGroup root = getRootThreadGroup ( ) ; int ct = Thread . activeCount ( ) ; int n = 0 ; Thread [ ] threads ; do { ct *= 2 ; threads = new Thread [ ct ] ; n = root . enumerate ( threads , true ) ; } while ( n == ct ) ; return java . util . Arrays . copyOf ( threads , n ) ...
Utility method to return all threads in system owned by the root ThreadGroup .
124,568
public String getValue ( ) { String results = super . getValue ( ) ; try { Long . parseLong ( super . getValue ( ) ) ; results = addUnits ( super . getValue ( ) ) ; } catch ( NumberFormatException e ) { } return results ; }
Return the value in bytes with SI unit name includes .
124,569
public String addUnits ( String value ) { StringBuffer buff = new StringBuffer ( 100 ) ; long bytes = Long . parseLong ( value ) ; if ( bytes < 1000000 ) { buff . append ( value ) ; buff . append ( "B" ) ; } else { int unit = 1000 ; int exp = ( int ) ( Math . log ( bytes ) / Math . log ( unit ) ) ; String pre = "kMGTPE...
Utility method to include the SI unit name .
124,570
public void doFilter ( ServletRequest servletRequest , ServletResponse servletResponse , FilterChain filterChain ) throws IOException , ServletException { HttpServletRequest request = ( HttpServletRequest ) servletRequest ; MDC . put ( HOSTNAME , servletRequest . getServerName ( ) ) ; if ( productName != null ) { MDC ....
Sample filter that populates the MDC on every request .
124,571
private static Result findResultWithMaxEnd ( List < Result > successResults ) { return Collections . max ( successResults , new Comparator < Result > ( ) { public int compare ( Result o1 , Result o2 ) { return Integer . valueOf ( o1 . end ( ) ) . compareTo ( o2 . end ( ) ) ; } } ) ; }
Find the result with the maximum end position and use it as delegate .
124,572
public static Matcher < MultiResult > sequence ( final Matcher < ? > ... matchers ) { checkNotEmpty ( matchers ) ; return new Matcher < MultiResult > ( ) { public MultiResult matches ( String input , boolean isEof ) { int matchCount = 0 ; Result [ ] results = new Result [ matchers . length ] ; Arrays . fill ( results ,...
Matches the given matchers one by one . Every successful matches updates the internal buffer . The consequent match operation is performed after the previous match has succeeded .
124,573
public final ExpectBuilder withTimeout ( long duration , TimeUnit unit ) { validateDuration ( duration ) ; this . timeout = unit . toMillis ( duration ) ; return this ; }
Sets the default timeout in the given unit for expect operations . Optional the default value is 30 seconds .
124,574
public void setInput ( int index , InputStream is ) { if ( index >= inputStreams . length ) { inputStreams = Arrays . copyOf ( inputStreams , index + 1 ) ; } this . inputStreams [ index ] = is ; }
Sets the input streams for the expect instance .
124,575
public Filter toFilter ( ) { Filter [ ] result = new Filter [ filters . size ( ) ] ; for ( int i = 0 ; i < result . length ; i ++ ) { result [ i ] = filters . get ( i ) . createFilter ( ) ; } return chain ( result ) ; }
Creates a filter from the list of the children filter elements .
124,576
protected Matcher < ? > [ ] getMatchers ( ) { Matcher < ? > [ ] matchers = new Matcher < ? > [ tasks . size ( ) ] ; for ( int i = 0 ; i < matchers . length ; i ++ ) { matchers [ i ] = tasks . get ( i ) . createMatcher ( ) ; } return matchers ; }
Creates and return all the children matchers .
124,577
public static Result failure ( String input , boolean canStopMatching ) { return new SimpleResult ( false , input , null , null , canStopMatching ) ; }
Creates an instance of an unsuccessful match .
124,578
@ Destroy ( priority = AutumnActionPriority . MIN_PRIORITY ) public void savePreferences ( ) { final ObjectSet < Preferences > preferencesToFlush = GdxSets . newSet ( ) ; for ( final Entry < String , Preference < ? > > preference : preferences ) { final Preferences preferencesFile = namesToFiles . get ( preference . ke...
Saves all current preferences . This is a reasonably heavy operation as it flushes all preferences files - by default this is done once before the application is closed .
124,579
public static void gracefullyDisposeOf ( final Disposable disposable ) { try { if ( disposable != null ) { disposable . dispose ( ) ; } } catch ( final Throwable exception ) { Gdx . app . error ( "WARN" , "Unable to dispose: " + disposable + ". Ignored." , exception ) ; } }
Performs null check and disposes of an asset . Ignores exceptions .
124,580
public static void saveSchema ( final LmlParser parser , final Appendable appendable ) { try { new Dtd ( ) . getDtdSchema ( parser , appendable ) ; } catch ( final IOException exception ) { throw new GdxRuntimeException ( "Unable to append to file." , exception ) ; } }
Saves DTD schema file containing all possible tags and their attributes . Any problems with the generation will be logged . This is a relatively heavy operation and should be done only during development .
124,581
public static void saveMinifiedSchema ( final LmlParser parser , final Appendable appendable ) { try { new Dtd ( ) . setAppendComments ( false ) . getDtdSchema ( parser , appendable ) ; } catch ( final IOException exception ) { throw new GdxRuntimeException ( "Unable to append to file." , exception ) ; } }
Saves DTD schema file containing all possible tags and their attributes . Any problems with the generation will be logged . This is a relatively heavy operation and should be done only during development . Comments will not be appended which will reduce the size of DTD file .
124,582
public void getDtdSchema ( final LmlParser parser , final Appendable builder ) throws IOException { appendActorTags ( builder , parser ) ; appendActorAttributes ( parser , builder ) ; appendMacroTags ( builder , parser ) ; appendMacroAttributes ( parser , builder ) ; }
Creates DTD schema file containing all possible tags and their attributes . Any problems with the generation will be logged . This is a relatively heavy operation and should be done only during development .
124,583
public void prepareDialogInstance ( ) { final LmlParser parser = interfaceService . getParser ( ) ; if ( actionContainer != null ) { parser . getData ( ) . addActionContainer ( getId ( ) , actionContainer ) ; } dialog = ( Window ) parser . createView ( wrappedObject , Gdx . files . internal ( dialogData . value ( ) ) )...
Creates instance of the managed dialog actor .
124,584
public void saveLocaleInPreferences ( final String preferencesPath , final String preferenceName ) { if ( Strings . isEmpty ( preferencesPath ) || Strings . isEmpty ( preferenceName ) ) { throw new GdxRuntimeException ( "Preference path and name cannot be empty! These are set automatically if you annotate a path to pre...
Saves current locale in the selected preferences .
124,585
public < Type > void load ( final String assetPath , final Class < Type > assetClass , final AssetLoaderParameters < Type > loadingParameters ) { if ( isAssetNotScheduled ( assetPath ) ) { assetManager . load ( assetPath , assetClass , loadingParameters ) ; } }
Schedules loading of the selected asset if it was not scheduled already .
124,586
public void unload ( final String assetPath ) { if ( assetManager . isLoaded ( assetPath ) || scheduledAssets . contains ( assetPath ) ) { assetManager . unload ( assetPath ) ; } else if ( eagerAssetManager . isLoaded ( assetPath ) ) { eagerAssetManager . unload ( assetPath ) ; } }
Schedules disposing of the selected asset .
124,587
protected void overrideTableExtractors ( ) { StandardTableTarget . MAIN . setTableExtractor ( new TableExtractor ( ) { public Table extract ( final Table table ) { if ( table instanceof Dialog ) { return ( ( Dialog ) table ) . getContentTable ( ) ; } else if ( table instanceof VisDialog ) { return ( ( VisDialog ) table...
Since some multi - table Vis widgets do not extend standard Scene2D widgets table extractors from multi - table actors need to be changed .
124,588
protected void registerVisAttributes ( ) { registerCollapsibleWidgetAttributes ( ) ; registerColorPickerAttributes ( ) ; registerDraggableAttributes ( ) ; registerDragPaneAttributes ( ) ; registerFloatingGroupAttributes ( ) ; registerFlowGroupsAttributes ( ) ; registerGridGroupAttributes ( ) ; registerMenuAttributes ( ...
Registers attributes of VisUI - specific actors .
124,589
protected void registerColorPickerAttributes ( ) { addAttributeProcessor ( new CloseAfterPickingLmlAttribute ( ) , "closeAfterPickingFinished" , "closeAfter" ) ; addAttributeProcessor ( new ColorPickerListenerLmlAttribute ( ) , "listener" ) ; addAttributeProcessor ( new ColorPickerResponsiveListenerLmlAttribute ( ) , "...
ColorPicker attributes .
124,590
protected void registerDraggableAttributes ( ) { addAttributeProcessor ( new BlockInputLmlAttribute ( ) , "blockInput" ) ; addAttributeProcessor ( new DeadzoneRadiusLmlAttribute ( ) , "deadzone" , "deadzoneRadius" ) ; addAttributeProcessor ( new DraggedAlphaLmlAttribute ( ) , "alpha" ) ; addAttributeProcessor ( new Dra...
Draggable listener attributes .
124,591
protected void registerGridGroupAttributes ( ) { addAttributeProcessor ( new GridSpacingLmlAttribute ( ) , "spacing" ) ; addAttributeProcessor ( new ItemHeightLmlAttribute ( ) , "itemHeight" ) ; addAttributeProcessor ( new ItemSizeLmlAttribute ( ) , "itemSize" ) ; addAttributeProcessor ( new ItemWidthLmlAttribute ( ) ,...
GridGroup attributes .
124,592
protected void registerSpinnerAttributes ( ) { addAttributeProcessor ( new SpinnerArrayLmlAttribute ( ) , "items" ) ; addAttributeProcessor ( new SpinnerDisabledLmlAttribute ( ) , "disabled" , "inputDisabled" ) ; addAttributeProcessor ( new SpinnerNameLmlAttribute ( ) , "selectorName" , "text" ) ; addAttributeProcessor...
Spinner attributes .
124,593
protected void registerValidatorAttributes ( ) { addAttributeProcessor ( new CustomValidatorLmlAttribute ( ) , "validator" , "validate" , "method" , "action" , "check" ) ; addAttributeProcessor ( new ErrorMessageLmlAttribute ( ) , "error" , "errorMsg" , "errorMessage" , "formError" ) ; addAttributeProcessor ( new HideO...
InputValidator implementations attributes .
124,594
@ Initiate ( priority = AutumnActionPriority . TOP_PRIORITY ) public void initiateSkin ( final SkinService skinService ) { VisUI . load ( VisUI . SkinScale . X2 ) ; skinService . addSkin ( "default" , VisUI . getSkin ( ) ) ; InterfaceService . DEFAULT_VIEW_RESIZER = new StandardViewResizer ( ) ; }
This action will be invoked when the application is being initialized . Actions are sorted by their priority and invoked in descending order ; by manipulating the priority values you can fully control the flow of your application s initiation .
124,595
public static String [ ] split ( final CharSequence charSequence , final char separator ) { if ( isEmpty ( charSequence ) ) { return EMPTY_ARRAY ; } final int originalSeparatorsCount = countSeparatedCharAppearances ( charSequence , separator ) ; int separatorsCount = originalSeparatorsCount ; if ( startsWith ( charSequ...
As opposed to string s split this method allows to split a char sequence without a regex provided that the separator is a single character . Since it does not require pattern compiling and is a simple iteration this method should be always preferred when it can be used .
124,596
public static < Key , Value > Value putIfAbsent ( final ObjectMap < Key , Value > map , final Key key , final Value value ) { if ( ! map . containsKey ( key ) ) { map . put ( key , value ) ; return value ; } return map . get ( key ) ; }
Puts a value with the given key in the passed map provided that the passed key isn t already present in the map .
124,597
protected String extractPackageName ( final Class < ? > root ) { return root . getName ( ) . substring ( 0 , root . getName ( ) . length ( ) - root . getSimpleName ( ) . length ( ) - 1 ) ; }
GWT - friendly method that extracts name of the package from class .
124,598
protected String getPackageName ( final Class < ? > root ) { return root . getName ( ) . substring ( 0 , root . getName ( ) . length ( ) - root . getSimpleName ( ) . length ( ) - 1 ) ; }
GWT - friendly way of extracting package name .
124,599
void ensureCapacity ( final int bytesAmount ) { if ( currentByteArrayIndex + bytesAmount >= serializedData . length ) { int newSerializedDataArrayLength = ( serializedData . length + 1 ) * 2 ; while ( currentByteArrayIndex + bytesAmount >= newSerializedDataArrayLength ) { newSerializedDataArrayLength = newSerializedDat...
Resizes original byte array if the object turns out to be bigger than expected .