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 ( name ) ) { merged = true ; } this . addValues ( name , values ) ; } return merged ; }
|
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 ( ) ) LOG . debug ( "already closed" ) ; return ; } if ( initialState == ConnectionState . CONNECTED ) { if ( LOG . isDebugEnabled ( ) ) LOG . debug ( "FastClose in CONNECTED detected" ) ; open = true ; } } if ( open ) openAndCloseLocal ( closeInfo ) ; else closeLocal ( closeInfo ) ; }
|
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={}, output={}" , inputAvailable , outputAvailable ) ; this . closeInfo = closeInfo ; inputAvailable = false ; if ( closeHandshakeSource == CloseHandshakeSource . NONE ) { closeHandshakeSource = CloseHandshakeSource . REMOTE ; } if ( ! outputAvailable ) { LOG . debug ( "Close Handshake satisfied, disconnecting" ) ; cleanClose = true ; state = ConnectionState . CLOSED ; finalClose . compareAndSet ( null , closeInfo ) ; event = this . state ; } else if ( this . state == ConnectionState . OPEN ) { this . state = ConnectionState . CLOSING ; event = this . state ; } } if ( event != null ) { notifyStateListeners ( event ) ; } }
|
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: {}" , this . state ) ; return ; } this . state = ConnectionState . OPEN ; this . inputAvailable = true ; this . outputAvailable = true ; event = this . state ; } notifyStateListeners ( event ) ; }
|
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 , 4 ) , 16 ) ) ; sb . append ( token . substring ( 4 ) ) ; } else { sb . append ( ( char ) Integer . parseInt ( token , 16 ) ) ; } } return sb . toString ( ) ; }
|
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' ) ; started = true ; } else if ( b == '-' && ! started ) { minus = true ; } else break ; } if ( started ) return minus ? ( - val ) : val ; throw new NumberFormatException ( string ) ; }
|
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 ; case "https" : if ( port != 443 ) url . append ( ':' ) . append ( port ) ; break ; default : url . append ( ':' ) . append ( port ) ; } } }
|
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 ( bytesAvailable , bytesExpected ) ; int limit = buffer . limit ( ) ; buffer . limit ( buffer . position ( ) + windowBytes ) ; ByteBuffer window = buffer . slice ( ) ; buffer . limit ( limit ) ; buffer . position ( buffer . position ( ) + window . remaining ( ) ) ; if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "{} Window: {}" , policy . getBehavior ( ) , BufferUtils . toDetailString ( window ) ) ; } maskProcessor . process ( window ) ; if ( window . remaining ( ) == payloadLength ) { frame . setPayload ( window ) ; return true ; } else { if ( payload == null ) { payload = BufferUtils . allocate ( payloadLength ) ; BufferUtils . clearToFill ( payload ) ; } payload . put ( window ) ; if ( payload . position ( ) == payloadLength ) { BufferUtils . flipToFlush ( payload , 0 ) ; frame . setPayload ( payload ) ; return true ; } } } return false ; }
|
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 (" + out . length + '<' + off + slen / 2 + ')' ) ; } byte b1 , b2 ; for ( int i = 0 ; i < slen ; i += 2 ) { b1 = ( byte ) Character . digit ( s . charAt ( i ) , 16 ) ; b2 = ( byte ) Character . digit ( s . charAt ( i + 1 ) , 16 ) ; if ( ( b1 < 0 ) || ( b2 < 0 ) ) { throw new NumberFormatException ( ) ; } out [ off + i / 2 ] = ( byte ) ( b1 << 4 | b2 ) ; } }
|
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 ] ) { return i ; } } return - 1 ; }
|
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 ) Object . class ) , size ) ; Iterator < ? > iterator = collection . iterator ( ) ; for ( int i = 0 ; i < size ; i ++ ) { Object element = iterator . next ( ) ; try { ReflectUtils . arraySet ( newArray , i , element ) ; } catch ( Throwable e ) { System . err . println ( "set element to array exception, " + e . getMessage ( ) ) ; } } return newArray ; }
|
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 ( clazz . isAssignableFrom ( Queue . class ) ) return new ArrayDeque < > ( ) ; else if ( clazz . isAssignableFrom ( SortedSet . class ) ) return new TreeSet < > ( ) ; else if ( clazz . isAssignableFrom ( BlockingQueue . class ) ) return new LinkedBlockingDeque < > ( ) ; else return null ; } else { Collection < Object > collection = null ; try { collection = ( Collection < Object > ) clazz . newInstance ( ) ; } catch ( Exception e ) { System . err . println ( "new collection instance exception, " + e . getMessage ( ) ) ; } return collection ; } }
|
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 ( asList ) ; } return parts ; }
|
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 ) err = new MultiException ( ) ; err . add ( e ) ; } } _parts . clear ( ) ; if ( err != null ) err . ifExceptionThrowRuntime ( ) ; }
|
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 . addAll ( asList ) ; } return parts ; }
|
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 ( ) ) ) _tmpDir = _contextTmpDir ; else { File f = new File ( _config . getLocation ( ) ) ; if ( f . isAbsolute ( ) ) _tmpDir = f ; else _tmpDir = new File ( _contextTmpDir , _config . getLocation ( ) ) ; } if ( ! _tmpDir . exists ( ) ) _tmpDir . mkdirs ( ) ; String contentTypeBoundary = "" ; int bstart = _contentType . indexOf ( "boundary=" ) ; if ( bstart >= 0 ) { int bend = _contentType . indexOf ( ";" , bstart ) ; bend = ( bend < 0 ? _contentType . length ( ) : bend ) ; contentTypeBoundary = QuotedStringTokenizer . unquote ( value ( _contentType . substring ( bstart , bend ) ) . trim ( ) ) ; } Handler handler = new Handler ( ) ; MultiPartParser parser = new MultiPartParser ( handler , contentTypeBoundary ) ; byte [ ] data = new byte [ _bufferSize ] ; int len ; long total = 0 ; while ( true ) { len = _in . read ( data ) ; if ( len > 0 ) { total += len ; if ( _config . getMaxRequestSize ( ) > 0 && total > _config . getMaxRequestSize ( ) ) { _err = new IllegalStateException ( "Request exceeds maxRequestSize (" + _config . getMaxRequestSize ( ) + ")" ) ; return ; } ByteBuffer buffer = BufferUtils . toBuffer ( data ) ; buffer . limit ( len ) ; if ( parser . parse ( buffer , false ) ) break ; if ( buffer . hasRemaining ( ) ) throw new IllegalStateException ( "Buffer did not fully consume" ) ; } else if ( len == - 1 ) { parser . parse ( BufferUtils . EMPTY_BUFFER , true ) ; break ; } } if ( _err != null ) { return ; } if ( parser . getState ( ) != MultiPartParser . State . END ) { if ( parser . getState ( ) == MultiPartParser . State . PREAMBLE ) _err = new IOException ( "Missing initial multi part boundary" ) ; else _err = new IOException ( "Incomplete Multipart" ) ; } if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Parsing Complete {} err={}" , parser , _err ) ; } } catch ( Throwable e ) { _err = e ; } }
|
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 initialHSComplete ; } case NEED_UNWRAP : doHandshakeReceive ( receiveBuffer ) ; if ( initialHSStatus != SSLEngineResult . HandshakeStatus . NEED_WRAP ) break ; case NEED_WRAP : doHandshakeResponse ( ) ; break ; default : throw new SecureNetException ( "Invalid Handshaking State" + initialHSStatus ) ; } return initialHSComplete ; }
|
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 -> {}, initialHSComplete -> {}" , session . getSessionId ( ) , session . isOpen ( ) , initialHSComplete ) ; } merge ( receiveBuffer ) ; if ( ! receivedPacketBuf . hasRemaining ( ) ) { return null ; } needIO : while ( true ) { SSLEngineResult result = unwrap ( ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Session {} read data result -> {}, receivedPacketBuf -> {}, appBufSize -> {}" , session . getSessionId ( ) , result . toString ( ) . replace ( '\n' , ' ' ) , receivedPacketBuf . remaining ( ) , receivedAppBuf . remaining ( ) ) ; } switch ( result . getStatus ( ) ) { case BUFFER_OVERFLOW : { resizeAppBuffer ( ) ; } break ; case BUFFER_UNDERFLOW : { int packetBufferSize = sslEngine . getSession ( ) . getPacketBufferSize ( ) ; if ( receivedPacketBuf . remaining ( ) >= packetBufferSize ) { break ; } else { break needIO ; } } case OK : { if ( result . getHandshakeStatus ( ) == SSLEngineResult . HandshakeStatus . NEED_TASK ) { doTasks ( ) ; } if ( receivedPacketBuf . hasRemaining ( ) ) { break ; } else { break needIO ; } } case CLOSED : { log . info ( "Session {} read data failure. SSLEngine will close inbound" , session . getSessionId ( ) ) ; closeInbound ( ) ; } break needIO ; default : throw new SecureNetException ( StringUtils . replace ( "Session {} SSLEngine read data exception. status -> {}" , session . getSessionId ( ) , result . getStatus ( ) ) ) ; } } return getReceivedAppBuf ( ) ; }
|
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 . succeeded ( ) ; return ret ; } final int remain = outAppBuf . remaining ( ) ; int packetBufferSize = sslEngine . getSession ( ) . getPacketBufferSize ( ) ; List < ByteBuffer > pocketBuffers = new ArrayList < > ( ) ; boolean closeOutput = false ; outer : while ( ret < remain ) { ByteBuffer packetBuffer = newBuffer ( packetBufferSize ) ; wrap : while ( true ) { SSLEngineResult result = wrap ( outAppBuf , packetBuffer ) ; ret += result . bytesConsumed ( ) ; switch ( result . getStatus ( ) ) { case OK : { if ( result . getHandshakeStatus ( ) == SSLEngineResult . HandshakeStatus . NEED_TASK ) { doTasks ( ) ; } packetBuffer . flip ( ) ; if ( packetBuffer . hasRemaining ( ) ) { pocketBuffers . add ( packetBuffer ) ; } } break wrap ; case BUFFER_OVERFLOW : { packetBufferSize = sslEngine . getSession ( ) . getPacketBufferSize ( ) ; ByteBuffer b = newBuffer ( packetBuffer . position ( ) + packetBufferSize ) ; packetBuffer . flip ( ) ; b . put ( packetBuffer ) ; packetBuffer = b ; } break ; case CLOSED : { log . info ( "Session {} SSLEngine will close" , session . getSessionId ( ) ) ; packetBuffer . flip ( ) ; if ( packetBuffer . hasRemaining ( ) ) { pocketBuffers . add ( packetBuffer ) ; } closeOutput = true ; } break outer ; default : { SecureNetException ex = new SecureNetException ( StringUtils . replace ( "Session {} SSLEngine writes data exception. status -> {}" , session . getSessionId ( ) , result . getStatus ( ) ) ) ; callback . failed ( ex ) ; throw ex ; } } } } session . write ( pocketBuffers , callback ) ; if ( closeOutput ) { closeOutbound ( ) ; } return ret ; }
|
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 ( ) ) && VerifyUtils . isNotEmpty ( b2 . getId ( ) ) && b1 . getId ( ) . equals ( b2 . getId ( ) ) ) { error ( "Duplicated bean ID of " + b1 . getClassName ( ) + " and " + b2 . getClassName ( ) ) ; } if ( b1 . getClassName ( ) . equals ( b2 . getClassName ( ) ) ) { if ( VerifyUtils . isEmpty ( b1 . getId ( ) ) || VerifyUtils . isEmpty ( b2 . getId ( ) ) ) { error ( "Duplicated class definition. Please set a ID for " + b1 . getClassName ( ) ) ; } else { errorMemo . add ( b1 . getClassName ( ) ) ; } } for ( String iname1 : b1 . getInterfaceNames ( ) ) { for ( String iname2 : b2 . getInterfaceNames ( ) ) { if ( iname1 . equals ( iname2 ) ) { if ( VerifyUtils . isEmpty ( b1 . getId ( ) ) || VerifyUtils . isEmpty ( b2 . getId ( ) ) ) { error ( "Duplicated class definition. Please set a ID for " + b1 . getClassName ( ) ) ; } else { errorMemo . add ( iname1 ) ; } } } } } } }
|
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 ] == START_SKIP [ i ] . charAt ( j ) ) ) { match = false ; break ; } } if ( match ) { int offset = START_SKIP [ i ] . length ( ) ; for ( int m = position + offset ; m < statement . length ; m ++ ) { if ( statement [ m ] == STOP_SKIP [ i ] . charAt ( 0 ) ) { boolean endMatch = true ; int endPos = m ; for ( int n = 1 ; n < STOP_SKIP [ i ] . length ( ) ; n ++ ) { if ( m + n >= statement . length ) { return statement . length ; } if ( ! ( statement [ m + n ] == STOP_SKIP [ i ] . charAt ( n ) ) ) { endMatch = false ; break ; } endPos = m + n ; } if ( endMatch ) { return endPos + 1 ; } } } return statement . length ; } } } return position ; }
|
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 ) ; return false ; }
|
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 . nextDoc ( ) ) != PostingsEnum . NO_MORE_DOCS ) { if ( liveDocs != null && ! liveDocs . get ( postingsEnum . docID ( ) ) ) { continue ; } docIds . ints [ docIds . length ++ ] = docId ; } if ( docIds . length == 0 ) docIds = EMPTY_INTSREF ; if ( docIdsCache != null ) { ensureBufIsACopy ( ) ; docIdsCache . put ( prefixBuf . clone ( ) , docIds ) ; } return docIds ; }
|
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 ( i ) , val . toString ( ) ) ; } if ( map . isEmpty ( ) ) return ; SolrParams topInvariants = new MapSolrParams ( map ) ; req . setParams ( SolrParams . wrapDefaults ( topInvariants , req . getParams ( ) ) ) ; }
|
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 ( ) ; } ZipInputStream zin = new ZipInputStream ( new BufferedInputStream ( new FileInputStream ( zipFile ) , BUFFER_SIZE ) ) ; try { ZipEntry ze = null ; while ( ( ze = zin . getNextEntry ( ) ) != null ) { String path = location + ze . getName ( ) ; File unzipFile = new File ( path ) ; if ( ze . isDirectory ( ) ) { if ( ! unzipFile . isDirectory ( ) ) { unzipFile . mkdirs ( ) ; } } else { File parentDir = unzipFile . getParentFile ( ) ; if ( null != parentDir ) { if ( ! parentDir . isDirectory ( ) ) { parentDir . mkdirs ( ) ; } } FileOutputStream out = new FileOutputStream ( unzipFile , false ) ; BufferedOutputStream fout = new BufferedOutputStream ( out , BUFFER_SIZE ) ; try { while ( ( size = zin . read ( buffer , 0 , BUFFER_SIZE ) ) != - 1 ) { fout . write ( buffer , 0 , size ) ; } zin . closeEntry ( ) ; } finally { fout . flush ( ) ; fout . close ( ) ; } } } } finally { zin . close ( ) ; } } catch ( Exception e ) { Log . e ( TAG , "Unzip exception" , e ) ; } }
|
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 . getInputStream ( ) ; int copyIndex = 0 ; int readResult ; do { readResult = inputStream . read ( b , copyIndex , Math . max ( b . length - copyIndex , 0 ) ) ; copyIndex += readResult ; } while ( readResult > 0 ) ; return Arrays . equals ( b , asBytes ( "PONG" ) ) ; } }
|
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 . toByteArray ( ) ; }
|
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 . setVisibility ( View . VISIBLE ) ; } if ( mPlayButton != null ) { mPlayButton . setVisibility ( View . VISIBLE ) ; } if ( mPauseButton != null ) { mPauseButton . setVisibility ( View . VISIBLE ) ; } }
|
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 DefaultIntervalLoggerController ( ) ; ic = new IntervalLoggerControllerWrapper ( instance ) ; } } return ic ; }
|
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 ( buff . toString ( ) . endsWith ( "," ) ) buff . setLength ( buff . length ( ) - 1 ) ; return buff . toString ( ) ; }
|
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 ( params == null || params . length == 0 ) { return source ; } Log4jMarker eventMarker = new Log4jMarker ( sourceMarker ) ; if ( ! eventMarker . contains ( SecurityMarkers . CONFIDENTIAL ) ) { return source ; } for ( int i = 0 ; i < params . length ; i ++ ) { params [ i ] = MASKED_PASSWORD ; } Message outMessage = new ParameterizedMessage ( msg . getFormat ( ) , params , msg . getThrowable ( ) ) ; LogEvent output = new Log4jLogEvent . Builder ( source ) . setMessage ( outMessage ) . build ( ) ; return output ; }
|
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 . toString ( ) . trim ( ) ) ; } }
|
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" . charAt ( exp - 1 ) + "" ; String ov = String . format ( "%.1f%sB" , bytes / Math . pow ( unit , exp ) , pre ) ; buff . append ( ov ) ; } return buff . toString ( ) ; }
|
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 . put ( PRODUCTNAME , productName ) ; } MDC . put ( "locale" , servletRequest . getLocale ( ) . getDisplayName ( ) ) ; for ( IPlugin plugin : plugins . values ( ) ) { plugin . execute ( request ) ; } filterChain . doFilter ( servletRequest , servletResponse ) ; MDC . clear ( ) ; }
|
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 , failure ( input , false ) ) ; int beginIndex = 0 ; for ( int i = 0 ; i < matchers . length ; i ++ ) { Result result = matchers [ i ] . matches ( input . substring ( beginIndex ) , isEof ) ; if ( result . isSuccessful ( ) ) { beginIndex += result . end ( ) ; results [ i ] = result ; if ( ++ matchCount == matchers . length ) { String group = result . group ( ) ; Result finalResult = new SimpleResult ( true , input , input . substring ( 0 , beginIndex - group . length ( ) ) , group , result . canStopMatching ( ) ) ; return new MultiResultImpl ( finalResult , Arrays . asList ( results ) ) ; } } else { break ; } } final List < Result > resultList = Arrays . asList ( results ) ; boolean canStopMatching = MultiResultImpl . canStopMatching ( resultList ) ; return new MultiResultImpl ( failure ( input , canStopMatching ) , resultList ) ; } public String toString ( ) { return String . format ( "sequence(%s)" , MultiMatcher . matchersToString ( matchers ) ) ; } } ; }
|
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 . key ) ; preferencesToFlush . add ( preferencesFile ) ; preference . value . save ( preference . key , preferencesFile ) ; } for ( final Preferences preferencesFile : preferencesToFlush ) { preferencesFile . flush ( ) ; } }
|
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 ( ) ) ) . first ( ) ; if ( actionContainer != null ) { parser . getData ( ) . removeActionContainer ( getId ( ) ) ; } }
|
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 preference with @I18nBundle and pass a corrent path to the preferences." ) ; } final Preferences preferences = ApplicationPreferences . getPreferences ( preferencesPath ) ; preferences . putString ( preferenceName , fromLocale ( currentLocale . get ( ) ) ) ; preferences . flush ( ) ; }
|
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 ) . getContentTable ( ) ; } return table ; } } ) ; StandardTableTarget . BUTTON . setTableExtractor ( new TableExtractor ( ) { public Table extract ( final Table table ) { if ( table instanceof Dialog ) { return ( ( Dialog ) table ) . getButtonTable ( ) ; } else if ( table instanceof VisDialog ) { return ( ( VisDialog ) table ) . getButtonsTable ( ) ; } return 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 ( ) ; registerLinkLabelAttributes ( ) ; registerListViewAttributes ( ) ; registerSpinnerAttributes ( ) ; registerTabbedPaneAttributes ( ) ; registerValidatableTextFieldAttributes ( ) ; registerValidatorAttributes ( ) ; }
|
Registers attributes of VisUI - specific actors .
|
899
|
protected void registerColorPickerAttributes ( ) { addAttributeProcessor ( new CloseAfterPickingLmlAttribute ( ) , "closeAfterPickingFinished" , "closeAfter" ) ; addAttributeProcessor ( new ColorPickerListenerLmlAttribute ( ) , "listener" ) ; addAttributeProcessor ( new ColorPickerResponsiveListenerLmlAttribute ( ) , "responsiveListener" ) ; addAttributeProcessor ( new AllowAlphaEditLmlAttribute ( ) , "allowAlphaEdit" , "allowAlpha" ) ; addAttributeProcessor ( new BasicColorPickerListenerLmlAttribute ( ) , "listener" ) ; addAttributeProcessor ( new ShowHexFieldLmlAttribute ( ) , "showHex" , "showHexField" ) ; }
|
ColorPicker attributes .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.