idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
800 | public List < V > getValues ( String name ) { List < V > vals = super . get ( name ) ; if ( ( vals == null ) || vals . isEmpty ( ) ) { return null ; } return vals ; } | Get multiple values . Single valued entries are converted to singleton lists . |
801 | public void putAllValues ( Map < String , V > input ) { for ( Map . Entry < String , V > entry : input . entrySet ( ) ) { put ( entry . getKey ( ) , entry . getValue ( ) ) ; } } | Shorthand version of putAll |
802 | public boolean addAllValues ( MultiMap < V > map ) { boolean merged = false ; if ( ( map == null ) || ( map . isEmpty ( ) ) ) { return merged ; } for ( Map . Entry < String , List < V > > entry : map . entrySet ( ) ) { String name = entry . getKey ( ) ; List < V > values = entry . getValue ( ) ; if ( this . containsKey... | Merge values . |
803 | public PhantomReference < T > register ( T object , Action0 leakCallback ) { PhantomReference < T > ref = new PhantomReference < > ( object , referenceQueue ) ; registeredMap . put ( ref , leakCallback ) ; return ref ; } | Register a tracked object . When the tracked object is released you must call the clear method of the LeakDetector . |
804 | public void clear ( PhantomReference < T > reference ) { Optional . ofNullable ( registeredMap . remove ( reference ) ) . ifPresent ( a -> reference . clear ( ) ) ; } | Clear tracked object |
805 | public void onCloseLocal ( CloseInfo closeInfo ) { boolean open = false ; synchronized ( this ) { ConnectionState initialState = this . state ; if ( LOG . isDebugEnabled ( ) ) LOG . debug ( "onCloseLocal({}) : {}" , closeInfo , initialState ) ; if ( initialState == ConnectionState . CLOSED ) { if ( LOG . isDebugEnabled... | A close handshake has been issued from the local endpoint |
806 | public void onCloseRemote ( CloseInfo closeInfo ) { if ( LOG . isDebugEnabled ( ) ) LOG . debug ( "onCloseRemote({})" , closeInfo ) ; ConnectionState event = null ; synchronized ( this ) { if ( this . state == ConnectionState . CLOSED ) { return ; } if ( LOG . isDebugEnabled ( ) ) LOG . debug ( "onCloseRemote(), input=... | A close handshake has been received from the remote endpoint |
807 | public void onFailedUpgrade ( ) { assert ( this . state == ConnectionState . CONNECTING ) ; ConnectionState event = null ; synchronized ( this ) { this . state = ConnectionState . CLOSED ; cleanClose = false ; inputAvailable = false ; outputAvailable = false ; event = this . state ; } notifyStateListeners ( event ) ; } | A websocket connection has failed its upgrade handshake and is now closed . |
808 | public void onOpened ( ) { if ( LOG . isDebugEnabled ( ) ) LOG . debug ( "onOpened()" ) ; ConnectionState event = null ; synchronized ( this ) { if ( this . state == ConnectionState . OPEN ) { return ; } if ( this . state != ConnectionState . CONNECTED ) { LOG . debug ( "Unable to open, not in CONNECTED state: {}" , th... | A websocket connection has finished its upgrade handshake and is now open . |
809 | public static String hashKey ( String key ) { try { MessageDigest md = MessageDigest . getInstance ( "SHA1" ) ; md . update ( key . getBytes ( StandardCharsets . UTF_8 ) ) ; md . update ( MAGIC ) ; return new String ( B64Code . encode ( md . digest ( ) ) ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; ... | Concatenate the provided key with the Magic GUID and return the Base64 encoded form . |
810 | 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 . |
811 | 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 |
812 | 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 |
813 | 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 |
814 | 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 . |
815 | 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 . |
816 | 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 |
817 | 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 |
818 | 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 |
819 | 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 |
820 | 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 . |
821 | 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 . |
822 | 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 . |
823 | public static void quote ( StringBuilder buf , String str ) { buf . append ( '"' ) ; escape ( buf , str ) ; buf . append ( '"' ) ; } | Simple quote of a string escaping where needed . |
824 | 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 . |
825 | 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 . |
826 | 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 . |
827 | 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 |
828 | 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 |
829 | 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 . |
830 | 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 . |
831 | 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 |
832 | 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 |
833 | 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 |
834 | @ 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 . |
835 | @ 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 |
836 | 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 . |
837 | 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 . |
838 | public Pair < Integer , List < ByteBuffer > > data ( DataFrame frame , int maxLength ) { return dataGenerator . generate ( frame , maxLength ) ; } | Encode data frame to binary codes |
839 | 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 . |
840 | 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 . |
841 | 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 . |
842 | public Part getPart ( String name ) throws IOException { if ( ! _parsed ) parse ( ) ; throwIfError ( ) ; return _parts . getValue ( name , 0 ) ; } | Get the named Part . |
843 | 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 . |
844 | 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 . |
845 | 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 . |
846 | 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 . |
847 | 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 |
848 | 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 |
849 | 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 |
850 | public void registerHealthCheck ( Task task ) { Optional . ofNullable ( config . getHealthCheck ( ) ) . ifPresent ( healthCheck -> healthCheck . register ( task ) ) ; } | Register an health check task . |
851 | public void clearHealthCheck ( String name ) { Optional . ofNullable ( config . getHealthCheck ( ) ) . ifPresent ( healthCheck -> healthCheck . clear ( name ) ) ; } | Clear the health check task . |
852 | 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 |
853 | 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 . |
854 | 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 |
855 | public void setSubProtocols ( String ... protocols ) { subProtocols . clear ( ) ; Collections . addAll ( subProtocols , protocols ) ; } | Set Sub Protocol request list . |
856 | 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 . |
857 | 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 . |
858 | public void putLongField ( HttpHeader name , long value ) { String v = Long . toString ( value ) ; put ( name , v ) ; } | Sets the value of an long field . |
859 | 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 . |
860 | 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 . |
861 | 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 . |
862 | 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 . |
863 | 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 . |
864 | 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 . |
865 | 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 |
866 | 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 |
867 | 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 . |
868 | 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 . |
869 | 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 . |
870 | 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 . |
871 | 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 . |
872 | 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 . |
873 | 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 . |
874 | 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 . |
875 | public synchronized void refresh ( ) { IntervalProperty [ ] properties = getProperties ( ) ; for ( IntervalProperty p : properties ) { p . refresh ( ) ; } } | Signal properties to update themselves . |
876 | 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 . |
877 | 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 . |
878 | 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 . |
879 | 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 . |
880 | 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 . |
881 | 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 . |
882 | 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 . |
883 | 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 . |
884 | 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 . |
885 | 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 . |
886 | 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 . |
887 | public static Result failure ( String input , boolean canStopMatching ) { return new SimpleResult ( false , input , null , null , canStopMatching ) ; } | Creates an instance of an unsuccessful match . |
888 | @ 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 . |
889 | 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 . |
890 | 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 . |
891 | 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 . |
892 | 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 . |
893 | 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 . |
894 | 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 . |
895 | 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 . |
896 | 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 . |
897 | 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 . |
898 | protected void registerVisAttributes ( ) { registerCollapsibleWidgetAttributes ( ) ; registerColorPickerAttributes ( ) ; registerDraggableAttributes ( ) ; registerDragPaneAttributes ( ) ; registerFloatingGroupAttributes ( ) ; registerFlowGroupsAttributes ( ) ; registerGridGroupAttributes ( ) ; registerMenuAttributes ( ... | Registers attributes of VisUI - specific actors . |
899 | protected void registerColorPickerAttributes ( ) { addAttributeProcessor ( new CloseAfterPickingLmlAttribute ( ) , "closeAfterPickingFinished" , "closeAfter" ) ; addAttributeProcessor ( new ColorPickerListenerLmlAttribute ( ) , "listener" ) ; addAttributeProcessor ( new ColorPickerResponsiveListenerLmlAttribute ( ) , "... | ColorPicker attributes . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.