idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
30,900 | public static < T > Stream < T > takeWhileInclusive ( Stream < T > source , Predicate < T > condition ) { return StreamSupport . stream ( TakeWhileSpliterator . overInclusive ( source . spliterator ( ) , condition ) , false ) . onClose ( source :: close ) ; } | Construct a stream which takes values from the source stream until but including the first value that is encountered which does not meet the condition . |
30,901 | public static < T > Stream < T > takeUntil ( Stream < T > source , Predicate < T > condition ) { return takeWhile ( source , condition . negate ( ) ) ; } | Construct a stream which takes values from the source stream until one of them meets the supplied condition and then stops . |
30,902 | public static < T > Stream < T > takeUntilInclusive ( Stream < T > source , Predicate < T > condition ) { return takeWhileInclusive ( source , condition . negate ( ) ) ; } | Construct a stream which takes values from the source stream until but including the first value that is encountered which meets the supplied condition . |
30,903 | public static < T > Stream < T > skipWhile ( Stream < T > source , Predicate < T > condition ) { return StreamSupport . stream ( SkipUntilSpliterator . over ( source . spliterator ( ) , condition . negate ( ) ) , false ) . onClose ( source :: close ) ; } | Construct a stream which skips values from the source stream for as long as they meet the supplied condition then streams every remaining value as soon as the first value is found which does not meet the condition . |
30,904 | public static < T > Stream < T > skipWhileInclusive ( Stream < T > source , Predicate < T > condition ) { return StreamSupport . stream ( SkipUntilSpliterator . overInclusive ( source . spliterator ( ) , condition . negate ( ) ) , false ) . onClose ( source :: close ) ; } | Construct a stream which skips values from the source stream up until but including the first value is found that does not meet the given condition . |
30,905 | public static < T > Stream < List < T > > windowed ( Stream < T > source , int windowSize ) { return windowed ( source , windowSize , 1 ) ; } | Constructs a stream that is a windowed view of the source stream of the size window size with a default overlap of one item |
30,906 | public static < T > Stream < T > interleave ( Function < T [ ] , Integer > selector , Stream < T > ... streams ) { Spliterator < T > [ ] spliterators = ( Spliterator < T > [ ] ) Stream . of ( streams ) . map ( BaseStream :: spliterator ) . toArray ( Spliterator [ ] :: new ) ; return StreamSupport . stream ( InterleavingSpliterator . interleaving ( spliterators , selector ) , false ) . onClose ( closerFor ( streams ) ) ; } | Construct a stream which interleaves the supplied streams picking items using the supplied selector function . |
30,907 | public static < T > Stream < T > reject ( Stream < T > source , Predicate < ? super T > predicate ) { return source . filter ( predicate . negate ( ) ) ; } | Filter with the condition negated . Will throw away any members of the source stream that match the condition . |
30,908 | public static < T > Stream < List < T > > aggregate ( Stream < T > source , BiPredicate < T , T > predicate ) { return StreamSupport . stream ( new AggregatingSpliterator < > ( source . spliterator ( ) , ( a , e ) -> a . isEmpty ( ) || predicate . test ( a . get ( a . size ( ) - 1 ) , e ) ) , false ) . onClose ( source :: close ) ; } | Aggregates items from source stream into list of items while supplied predicate is true when evaluated on previous and current item . Can by seen as streaming alternative to Collectors . groupingBy when source stream is sorted by key . |
30,909 | public static < T > Stream < List < T > > aggregate ( Stream < T > source , int size ) { if ( size <= 0 ) throw new IllegalArgumentException ( "Positive size expected, was: " + size ) ; return StreamSupport . stream ( new AggregatingSpliterator < > ( source . spliterator ( ) , ( a , e ) -> a . size ( ) < size ) , false ) . onClose ( source :: close ) ; } | Aggregates items from source stream into list of items with fixed size |
30,910 | public static < T > Stream < List < T > > aggregateOnListCondition ( Stream < T > source , BiPredicate < List < T > , T > predicate ) { return StreamSupport . stream ( new AggregatingSpliterator < > ( source . spliterator ( ) , predicate ) , false ) . onClose ( source :: close ) ; } | Aggregates items from source stream . Similar to |
30,911 | public static < T > Stream < T > ofSingleNullable ( T nullable ) { return null == nullable ? Stream . empty ( ) : Stream . of ( nullable ) ; } | Converts nulls into an empty stream and non - null values into a stream with one element . |
30,912 | public static < T > Stream < T > ofNullable ( Iterable < T > iterable ) { return null == iterable ? Stream . empty ( ) : stream ( iterable ) ; } | Converts a nullable Iterable into a Stream . |
30,913 | public static IntStream ofNullable ( int [ ] nullable ) { return null == nullable ? IntStream . empty ( ) : Arrays . stream ( nullable ) ; } | Converts nullable int array into an empty stream and non - null array into a stream . |
30,914 | public static LongStream ofNullable ( long [ ] nullable ) { return null == nullable ? LongStream . empty ( ) : Arrays . stream ( nullable ) ; } | Converts nullable long array into an empty stream and non - null array into a stream . |
30,915 | public static DoubleStream ofNullable ( double [ ] nullable ) { return null == nullable ? DoubleStream . empty ( ) : Arrays . stream ( nullable ) ; } | Converts nullable float array into an empty stream and non - null array into a stream . |
30,916 | public static < T > Stream < T > ofNullable ( T [ ] nullable ) { return null == nullable ? Stream . empty ( ) : Stream . of ( nullable ) ; } | Converts nullable array into an empty stream and non - null array into a stream . |
30,917 | public static < T > Stream < T > cycle ( T ... items ) { return IntStream . iterate ( 0 , i -> i == items . length - 1 ? 0 : i + 1 ) . mapToObj ( i -> items [ i ] ) ; } | Cycles through a set of items indefinitely . |
30,918 | public static < T > Collector < CompletableFuture < T > , ? , CompletableFuture < List < T > > > toFutureList ( ) { return Collectors . collectingAndThen ( Collectors . < CompletableFuture < T > > toList ( ) , futures -> { AtomicLong resultsRemaining = new AtomicLong ( futures . size ( ) ) ; CompletableFuture < List < T > > result = new CompletableFuture < > ( ) ; BiFunction < T , Throwable , Void > handler = ( success , failure ) -> { if ( failure == null ) { if ( resultsRemaining . decrementAndGet ( ) == 0 ) { result . complete ( futures . stream ( ) . map ( CompletableFutures :: safeGet ) . collect ( toList ( ) ) ) ; } } else { result . completeExceptionally ( failure ) ; } return null ; } ; futures . forEach ( future -> future . handle ( handler ) ) ; return result ; } ) ; } | Collector which converts a stream of CompletableFuture< ; T> ; into a CompletableFuture< ; List< ; T> ; > ; |
30,919 | @ SuppressWarnings ( "unchecked" ) private Map < String , Object > convertToMap ( Object jsonDocument ) { Map < String , Object > jsonMap = new LinkedHashMap < > ( ) ; if ( ! ( jsonDocument instanceof JSONObject ) ) { jsonMap . put ( "content" , jsonDocument ) ; return jsonMap ; } JSONObject obj = ( JSONObject ) jsonDocument ; for ( String key : obj . keySet ( ) ) { Object value = obj . get ( key ) ; if ( value instanceof JSONObject ) { value = convertToMap ( value ) ; } else if ( value instanceof JSONArray ) { ArrayList < Map < String , Object > > collection = new ArrayList < > ( ) ; for ( Object element : ( ( JSONArray ) value ) ) { collection . add ( convertToMap ( element ) ) ; } value = collection ; } jsonMap . put ( key , value ) ; } return jsonMap ; } | Convert given Json document to a multi - level map . |
30,920 | private static String convertToPropertiesKey ( String environmentVariableKey , String environmentContext ) { return environmentVariableKey . substring ( environmentContext . length ( ) ) . replace ( ENV_DELIMITER , PROPERTIES_DELIMITER ) ; } | Convert the Environment Variable Name to the expected Properties Key formatting |
30,921 | @ SuppressWarnings ( "unchecked" ) Map < String , Object > flatten ( Map < String , Object > source ) { Map < String , Object > result = new LinkedHashMap < > ( ) ; for ( String key : source . keySet ( ) ) { Object value = source . get ( key ) ; if ( value instanceof Map ) { Map < String , Object > subMap = flatten ( ( Map < String , Object > ) value ) ; for ( String subkey : subMap . keySet ( ) ) { result . put ( key + "." + subkey , subMap . get ( subkey ) ) ; } } else if ( value instanceof Collection ) { StringBuilder joiner = new StringBuilder ( ) ; String separator = "" ; for ( Object element : ( ( Collection ) value ) ) { Map < String , Object > subMap = flatten ( Collections . singletonMap ( key , element ) ) ; joiner . append ( separator ) . append ( subMap . entrySet ( ) . iterator ( ) . next ( ) . getValue ( ) . toString ( ) ) ; separator = "," ; } result . put ( key , joiner . toString ( ) ) ; } else { result . put ( key , value ) ; } } return result ; } | Flatten multi - level map . |
30,922 | @ SuppressWarnings ( "unchecked" ) private Map < String , Object > convertToMap ( Object yamlDocument ) { Map < String , Object > yamlMap = new LinkedHashMap < > ( ) ; if ( ! ( yamlDocument instanceof Map ) ) { yamlMap . put ( "content" , yamlDocument ) ; return yamlMap ; } for ( Map . Entry < Object , Object > entry : ( ( Map < Object , Object > ) yamlDocument ) . entrySet ( ) ) { Object value = entry . getValue ( ) ; if ( value instanceof Map ) { value = convertToMap ( value ) ; } else if ( value instanceof Collection ) { ArrayList < Map < String , Object > > collection = new ArrayList < > ( ) ; for ( Object element : ( ( Collection ) value ) ) { collection . add ( convertToMap ( element ) ) ; } value = collection ; } yamlMap . put ( entry . getKey ( ) . toString ( ) , value ) ; } return yamlMap ; } | Convert given Yaml document to a multi - level map . |
30,923 | public Properties getConfiguration ( Environment environment ) { Properties properties = new Properties ( ) ; Path pathPrefix = Paths . get ( environment . getName ( ) ) ; URL url = getClass ( ) . getClassLoader ( ) . getResource ( pathPrefix . toString ( ) ) ; if ( url == null && ! environment . getName ( ) . isEmpty ( ) ) { throw new MissingEnvironmentException ( "Directory doesn't exist: " + environment . getName ( ) ) ; } List < Path > paths = new ArrayList < > ( ) ; for ( Path path : configFilesProvider . getConfigFiles ( ) ) { paths . add ( pathPrefix . resolve ( path ) ) ; } for ( Path path : paths ) { try ( InputStream input = getClass ( ) . getClassLoader ( ) . getResourceAsStream ( path . toString ( ) ) ) { if ( input == null ) { throw new IllegalStateException ( "Unable to load properties from classpath: " + path ) ; } PropertiesProvider provider = propertiesProviderSelector . getProvider ( path . getFileName ( ) . toString ( ) ) ; properties . putAll ( provider . getProperties ( input ) ) ; } catch ( IOException e ) { throw new IllegalStateException ( "Unable to load properties from classpath: " + path , e ) ; } } return properties ; } | Get configuration from classpath . See the class - level javadoc for detail on environment resolution . |
30,924 | void gatherOp ( int maxPos ) throws IOException { try { while ( this . bufferPosition < maxPos ) { byte b = this . buffer [ this . bufferPosition ] ; this . bufferPosition ++ ; if ( gotCR ) { if ( b == NatsConnection . LF ) { this . op = opFor ( opArray , opPos ) ; this . gotCR = false ; this . opPos = 0 ; this . mode = Mode . PARSE_PROTO ; break ; } else { throw new IllegalStateException ( "Bad socket data, no LF after CR" ) ; } } else if ( b == SPACE || b == TAB ) { this . op = opFor ( opArray , opPos ) ; this . opPos = 0 ; if ( this . op == NatsConnection . OP_MSG ) { this . msgLinePosition = 0 ; this . mode = Mode . GATHER_MSG_PROTO ; } else { this . mode = Mode . GATHER_PROTO ; } break ; } else if ( b == NatsConnection . CR ) { this . gotCR = true ; } else { this . opArray [ opPos ] = ( char ) b ; this . opPos ++ ; } } } catch ( ArrayIndexOutOfBoundsException | IllegalStateException | NumberFormatException | NullPointerException ex ) { this . encounteredProtocolError ( ex ) ; } } | Gather the op either up to the first space or the first carraige return . |
30,925 | void gatherMessageProtocol ( int maxPos ) throws IOException { try { while ( this . bufferPosition < maxPos ) { byte b = this . buffer [ this . bufferPosition ] ; this . bufferPosition ++ ; if ( gotCR ) { if ( b == NatsConnection . LF ) { this . mode = Mode . PARSE_PROTO ; this . gotCR = false ; break ; } else { throw new IllegalStateException ( "Bad socket data, no LF after CR" ) ; } } else if ( b == NatsConnection . CR ) { this . gotCR = true ; } else { if ( this . msgLinePosition >= this . msgLineChars . length ) { throw new IllegalStateException ( "Protocol line is too long" ) ; } this . msgLineChars [ this . msgLinePosition ] = ( char ) b ; this . msgLinePosition ++ ; } } } catch ( IllegalStateException | NumberFormatException | NullPointerException ex ) { this . encounteredProtocolError ( ex ) ; } } | Stores the message protocol line in a char buffer that will be grepped for subject reply |
30,926 | void gatherProtocol ( int maxPos ) throws IOException { try { while ( this . bufferPosition < maxPos ) { byte b = this . buffer [ this . bufferPosition ] ; this . bufferPosition ++ ; if ( gotCR ) { if ( b == NatsConnection . LF ) { this . protocolBuffer . flip ( ) ; this . mode = Mode . PARSE_PROTO ; this . gotCR = false ; break ; } else { throw new IllegalStateException ( "Bad socket data, no LF after CR" ) ; } } else if ( b == NatsConnection . CR ) { this . gotCR = true ; } else { if ( ! protocolBuffer . hasRemaining ( ) ) { this . protocolBuffer = this . connection . enlargeBuffer ( this . protocolBuffer , 0 ) ; } this . protocolBuffer . put ( b ) ; } } } catch ( IllegalStateException | NumberFormatException | NullPointerException ex ) { this . encounteredProtocolError ( ex ) ; } } | Gather bytes for a protocol line |
30,927 | void gatherMessageData ( int maxPos ) throws IOException { try { while ( this . bufferPosition < maxPos ) { int possible = maxPos - this . bufferPosition ; int want = msgData . length - msgDataPosition ; if ( want > 0 && want <= possible ) { System . arraycopy ( this . buffer , this . bufferPosition , this . msgData , this . msgDataPosition , want ) ; msgDataPosition += want ; this . bufferPosition += want ; continue ; } else if ( want > 0 ) { System . arraycopy ( this . buffer , this . bufferPosition , this . msgData , this . msgDataPosition , possible ) ; msgDataPosition += possible ; this . bufferPosition += possible ; continue ; } byte b = this . buffer [ this . bufferPosition ] ; this . bufferPosition ++ ; if ( gotCR ) { if ( b == NatsConnection . LF ) { incoming . setData ( msgData ) ; this . connection . deliverMessage ( incoming ) ; msgData = null ; msgDataPosition = 0 ; incoming = null ; gotCR = false ; this . op = UNKNOWN_OP ; this . mode = Mode . GATHER_OP ; break ; } else { throw new IllegalStateException ( "Bad socket data, no LF after CR" ) ; } } else if ( b == NatsConnection . CR ) { gotCR = true ; } else { throw new IllegalStateException ( "Bad socket data, no CRLF after data" ) ; } } } catch ( IllegalStateException | NullPointerException ex ) { this . encounteredProtocolError ( ex ) ; } } | given to the message object |
30,928 | Future < Boolean > stop ( ) { this . startStopLock . lock ( ) ; try { this . running . set ( false ) ; this . outgoing . pause ( ) ; this . reconnectOutgoing . pause ( ) ; byte [ ] pingRequest = NatsConnection . OP_PING . getBytes ( StandardCharsets . UTF_8 ) ; byte [ ] pongRequest = NatsConnection . OP_PONG . getBytes ( StandardCharsets . UTF_8 ) ; this . outgoing . filter ( ( msg ) -> { return Arrays . equals ( pingRequest , msg . getProtocolBytes ( ) ) || Arrays . equals ( pongRequest , msg . getProtocolBytes ( ) ) ; } ) ; } finally { this . startStopLock . unlock ( ) ; } return this . stopped ; } | method does . |
30,929 | NatsMessage accumulate ( long maxSize , long maxMessages , Duration timeout ) throws InterruptedException { if ( ! this . singleThreadedReader ) { throw new IllegalStateException ( "Accumulate is only supported in single reader mode." ) ; } if ( ! this . isRunning ( ) ) { return null ; } NatsMessage msg = this . queue . poll ( ) ; if ( msg == null ) { msg = waitForTimeout ( timeout ) ; if ( ! this . isRunning ( ) || ( msg == null ) ) { return null ; } } long size = msg . getSizeInBytes ( ) ; if ( maxMessages <= 1 || size >= maxSize ) { this . sizeInBytes . addAndGet ( - size ) ; this . length . decrementAndGet ( ) ; signalIfNotEmpty ( ) ; return msg ; } long count = 1 ; NatsMessage cursor = msg ; while ( cursor != null ) { NatsMessage next = this . queue . peek ( ) ; if ( next != null ) { long s = next . getSizeInBytes ( ) ; if ( maxSize < 0 || ( size + s ) < maxSize ) { size += s ; count ++ ; cursor . next = this . queue . poll ( ) ; cursor = cursor . next ; if ( count == maxMessages ) { break ; } } else { break ; } } else { break ; } } this . sizeInBytes . addAndGet ( - size ) ; this . length . addAndGet ( - count ) ; signalIfNotEmpty ( ) ; return msg ; } | readers are present you could get out of order message delivery . |
30,930 | public final void close ( ) { while ( subChannel . size ( ) > 0 ) { subs . addSample ( subChannel . poll ( ) ) ; } while ( pubChannel . size ( ) > 0 ) { pubs . addSample ( pubChannel . poll ( ) ) ; } if ( subs . hasSamples ( ) ) { start = subs . getStart ( ) ; end = subs . getEnd ( ) ; if ( pubs . hasSamples ( ) ) { end = Math . min ( end , pubs . getEnd ( ) ) ; } } else { start = pubs . getStart ( ) ; end = pubs . getEnd ( ) ; } msgBytes = pubs . msgBytes + subs . msgBytes ; ioBytes = pubs . ioBytes + subs . ioBytes ; msgCnt = pubs . msgCnt + subs . msgCnt ; jobMsgCnt = pubs . jobMsgCnt + subs . jobMsgCnt ; } | Closes this benchmark and calculates totals and times . |
30,931 | public final String report ( ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( String . format ( "%s stats: %s\n" , name , this ) ) ; if ( pubs . hasSamples ( ) ) { String indent = " " ; if ( subs . hasSamples ( ) ) { sb . append ( String . format ( "%sPub stats: %s\n" , indent , pubs ) ) ; indent = " " ; } if ( pubs . getSamples ( ) . size ( ) > 1 ) { for ( Sample stat : pubs . getSamples ( ) ) { sb . append ( String . format ( "%s[%2d] %s (%d msgs)\n" , indent , pubs . getSamples ( ) . indexOf ( stat ) + 1 , stat , stat . jobMsgCnt ) ) ; } sb . append ( String . format ( "%s %s\n" , indent , pubs . statistics ( ) ) ) ; } } if ( subs . hasSamples ( ) ) { String indent = " " ; sb . append ( String . format ( "%sSub stats: %s\n" , indent , subs ) ) ; indent = " " ; if ( subs . getSamples ( ) . size ( ) > 1 ) { for ( Sample stat : subs . getSamples ( ) ) { sb . append ( String . format ( "%s[%2d] %s (%d msgs)\n" , indent , subs . getSamples ( ) . indexOf ( stat ) + 1 , stat , stat . jobMsgCnt ) ) ; } sb . append ( String . format ( "%s %s\n" , indent , subs . statistics ( ) ) ) ; } } return sb . toString ( ) ; } | Creates the output report . |
30,932 | public final String csv ( ) { StringBuilder sb = new StringBuilder ( ) ; String header = "#RunID, ClientID, MsgCount, MsgBytes, MsgsPerSec, BytesPerSec, DurationSecs" ; sb . append ( String . format ( "%s stats: %s\n" , name , this ) ) ; sb . append ( header ) ; sb . append ( "\n" ) ; sb . append ( csvLines ( subs , "S" ) ) ; sb . append ( csvLines ( pubs , "P" ) ) ; return sb . toString ( ) ; } | Returns a string containing the report as series of CSV lines . |
30,933 | public static NKey createAccount ( SecureRandom random ) throws IOException , NoSuchProviderException , NoSuchAlgorithmException { return createPair ( Type . ACCOUNT , random ) ; } | Create an Account NKey from the provided random number generator . |
30,934 | public static NKey createCluster ( SecureRandom random ) throws IOException , NoSuchProviderException , NoSuchAlgorithmException { return createPair ( Type . CLUSTER , random ) ; } | Create an Cluster NKey from the provided random number generator . |
30,935 | public static NKey createOperator ( SecureRandom random ) throws IOException , NoSuchProviderException , NoSuchAlgorithmException { return createPair ( Type . OPERATOR , random ) ; } | Create an Operator NKey from the provided random number generator . |
30,936 | public static NKey createServer ( SecureRandom random ) throws IOException , NoSuchProviderException , NoSuchAlgorithmException { return createPair ( Type . SERVER , random ) ; } | Create a Server NKey from the provided random number generator . |
30,937 | public static NKey createUser ( SecureRandom random ) throws IOException , NoSuchProviderException , NoSuchAlgorithmException { return createPair ( Type . USER , random ) ; } | Create a User NKey from the provided random number generator . |
30,938 | public static NKey fromPublicKey ( char [ ] publicKey ) { byte [ ] raw = decode ( publicKey ) ; int prefix = raw [ 0 ] & 0xFF ; if ( ! checkValidPublicPrefixByte ( prefix ) ) { throw new IllegalArgumentException ( "Not a valid public NKey" ) ; } Type type = NKey . Type . fromPrefix ( prefix ) ; return new NKey ( type , publicKey , null ) ; } | Create an NKey object from the encoded public key . This NKey can be used for verification but not for signing . |
30,939 | public static NKey fromSeed ( char [ ] seed ) { DecodedSeed decoded = decodeSeed ( seed ) ; if ( decoded . bytes . length == ED25519_PRIVATE_KEYSIZE ) { return new NKey ( Type . fromPrefix ( decoded . prefix ) , null , seed ) ; } else { try { return createPair ( Type . fromPrefix ( decoded . prefix ) , decoded . bytes ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Bad seed value" , e ) ; } } } | Creates an NKey object from a string encoded seed . This NKey can be used to sign or verify . |
30,940 | public void clear ( ) { Random r = new Random ( ) ; if ( privateKeyAsSeed != null ) { for ( int i = 0 ; i < privateKeyAsSeed . length ; i ++ ) { privateKeyAsSeed [ i ] = ( char ) ( r . nextInt ( 26 ) + 'a' ) ; } Arrays . fill ( privateKeyAsSeed , '\0' ) ; } if ( publicKey != null ) { for ( int i = 0 ; i < publicKey . length ; i ++ ) { publicKey [ i ] = ( char ) ( r . nextInt ( 26 ) + 'a' ) ; } Arrays . fill ( publicKey , '\0' ) ; } } | Clear the seed and public key char arrays by filling them with random bytes then zero - ing them out . |
30,941 | public byte [ ] sign ( byte [ ] input ) throws GeneralSecurityException , IOException { Signature sgr = new EdDSAEngine ( MessageDigest . getInstance ( NKey . ed25519 . getHashAlgorithm ( ) ) ) ; PrivateKey sKey = getKeyPair ( ) . getPrivate ( ) ; sgr . initSign ( sKey ) ; sgr . update ( input ) ; return sgr . sign ( ) ; } | Sign aribitrary binary input . |
30,942 | public boolean verify ( byte [ ] input , byte [ ] signature ) throws GeneralSecurityException , IOException { Signature sgr = new EdDSAEngine ( MessageDigest . getInstance ( NKey . ed25519 . getHashAlgorithm ( ) ) ) ; PublicKey sKey = null ; if ( privateKeyAsSeed != null ) { sKey = getKeyPair ( ) . getPublic ( ) ; } else { char [ ] encodedPublicKey = getPublicKey ( ) ; byte [ ] decodedPublicKey = decode ( this . type , encodedPublicKey , false ) ; EdDSAPublicKeySpec pubKeySpec = new EdDSAPublicKeySpec ( decodedPublicKey , NKey . ed25519 ) ; sKey = new EdDSAPublicKey ( pubKeySpec ) ; } sgr . initVerify ( sKey ) ; sgr . update ( input ) ; return sgr . verify ( signature ) ; } | Verify a signature . |
30,943 | String unescapeString ( String st ) { StringBuilder sb = new StringBuilder ( st . length ( ) ) ; for ( int i = 0 ; i < st . length ( ) ; i ++ ) { char ch = st . charAt ( i ) ; if ( ch == '\\' ) { char nextChar = ( i == st . length ( ) - 1 ) ? '\\' : st . charAt ( i + 1 ) ; switch ( nextChar ) { case '\\' : ch = '\\' ; break ; case 'b' : ch = '\b' ; break ; case 'f' : ch = '\f' ; break ; case 'n' : ch = '\n' ; break ; case 'r' : ch = '\r' ; break ; case 't' : ch = '\t' ; break ; case 'u' : if ( i >= st . length ( ) - 5 ) { ch = 'u' ; break ; } int code = Integer . parseInt ( "" + st . charAt ( i + 2 ) + st . charAt ( i + 3 ) + st . charAt ( i + 4 ) + st . charAt ( i + 5 ) , 16 ) ; sb . append ( Character . toChars ( code ) ) ; i += 5 ; continue ; } i ++ ; } sb . append ( ch ) ; } return sb . toString ( ) ; } | Removed octal support |
30,944 | public void addSample ( Sample stat ) { samples . add ( stat ) ; if ( samples . size ( ) == 1 ) { start = stat . start ; end = stat . end ; } this . ioBytes += stat . ioBytes ; this . jobMsgCnt += stat . jobMsgCnt ; this . msgCnt += stat . msgCnt ; this . msgBytes += stat . msgBytes ; this . start = Math . min ( this . start , stat . start ) ; this . end = Math . max ( this . end , stat . end ) ; } | Adds a sample to the group . |
30,945 | public long minRate ( ) { long min = ( samples . isEmpty ( ) ? 0L : samples . get ( 0 ) . rate ( ) ) ; for ( Sample s : samples ) { min = Math . min ( min , s . rate ( ) ) ; } return min ; } | Returns the minimum of the message rates in the SampleGroup . |
30,946 | public long maxRate ( ) { long max = ( samples . isEmpty ( ) ? 0L : samples . get ( 0 ) . rate ( ) ) ; for ( Sample s : samples ) { max = Math . max ( max , s . rate ( ) ) ; } return max ; } | Returns the maximum of the message rates in the SampleGroup . |
30,947 | public long avgRate ( ) { long sum = 0L ; for ( Sample s : samples ) { sum += s . rate ( ) ; } return sum / ( long ) samples . size ( ) ; } | Returns the average of the message rates in the SampleGroup . |
30,948 | public double stdDev ( ) { double avg = avgRate ( ) ; double sum = 0.0 ; for ( Sample s : samples ) { sum += Math . pow ( ( double ) s . rate ( ) - avg , 2 ) ; } double variance = sum / ( double ) samples . size ( ) ; return Math . sqrt ( variance ) ; } | Returns the standard deviation of the message rates in the SampleGroup . |
30,949 | public String statistics ( ) { DecimalFormat formatter = new DecimalFormat ( "#,###" ) ; DecimalFormat floatFormatter = new DecimalFormat ( "#,###.00" ) ; return String . format ( "min %s | avg %s | max %s | stddev %s msgs" , formatter . format ( minRate ( ) ) , formatter . format ( avgRate ( ) ) , formatter . format ( maxRate ( ) ) , floatFormatter . format ( stdDev ( ) ) ) ; } | Formats the statistics for this group in a human - readable format . |
30,950 | void connect ( boolean reconnectOnConnect ) throws InterruptedException , IOException { if ( options . getServers ( ) . size ( ) == 0 ) { throw new IllegalArgumentException ( "No servers provided in options" ) ; } for ( String serverURI : getServers ( ) ) { if ( isClosed ( ) ) { break ; } updateStatus ( Status . CONNECTING ) ; tryToConnect ( serverURI ) ; if ( isConnected ( ) ) { break ; } else { updateStatus ( Status . DISCONNECTED ) ; } } if ( ! isConnected ( ) && ! isClosed ( ) ) { if ( reconnectOnConnect ) { reconnect ( ) ; } else { close ( ) ; throw new IOException ( "Unable to connect to gnatsd server." ) ; } } } | Connect is only called after creation |
30,951 | void reconnect ( ) throws InterruptedException { long maxTries = options . getMaxReconnect ( ) ; long tries = 0 ; String lastServer = null ; if ( isClosed ( ) ) { return ; } if ( maxTries == 0 ) { this . close ( ) ; return ; } this . writer . setReconnectMode ( true ) ; while ( ! isConnected ( ) && ! isClosed ( ) && ! this . isClosing ( ) ) { Collection < String > serversToTry = buildReconnectList ( ) ; for ( String server : serversToTry ) { if ( isClosed ( ) ) { break ; } if ( server . equals ( lastServer ) ) { this . reconnectWaiter = new CompletableFuture < > ( ) ; waitForReconnectTimeout ( ) ; } if ( isDisconnectingOrClosed ( ) || this . isClosing ( ) ) { break ; } updateStatus ( Status . RECONNECTING ) ; tryToConnect ( server ) ; lastServer = server ; tries ++ ; if ( maxTries > 0 && tries >= maxTries ) { break ; } else if ( isConnected ( ) ) { this . statistics . incrementReconnects ( ) ; break ; } } if ( maxTries > 0 && tries >= maxTries ) { break ; } } if ( ! isConnected ( ) ) { this . close ( ) ; return ; } this . subscribers . forEach ( ( sid , sub ) -> { if ( sub . getDispatcher ( ) == null && ! sub . isDraining ( ) ) { sendSubscriptionMessage ( sub . getSID ( ) , sub . getSubject ( ) , sub . getQueueName ( ) , true ) ; } } ) ; this . dispatchers . forEach ( ( nuid , d ) -> { if ( ! d . isDraining ( ) ) { d . resendSubscriptions ( ) ; } } ) ; try { this . flush ( this . options . getConnectionTimeout ( ) ) ; } catch ( Exception exp ) { this . processException ( exp ) ; } this . writer . setReconnectMode ( false ) ; processConnectionEvent ( Events . RESUBSCRIBED ) ; } | Reconnect can only be called when the connection is disconnected |
30,952 | void closeSocket ( boolean tryReconnectIfConnected ) throws InterruptedException { boolean wasConnected = false ; statusLock . lock ( ) ; try { if ( isDisconnectingOrClosed ( ) ) { waitForDisconnectOrClose ( this . options . getConnectionTimeout ( ) ) ; return ; } else { this . disconnecting = true ; this . exceptionDuringConnectChange = null ; wasConnected = ( this . status == Status . CONNECTED ) ; statusChanged . signalAll ( ) ; } } finally { statusLock . unlock ( ) ; } closeSocketImpl ( ) ; statusLock . lock ( ) ; try { updateStatus ( Status . DISCONNECTED ) ; this . exceptionDuringConnectChange = null ; this . disconnecting = false ; statusChanged . signalAll ( ) ; } finally { statusLock . unlock ( ) ; } if ( isClosing ( ) ) { close ( ) ; } else if ( wasConnected && tryReconnectIfConnected ) { reconnect ( ) ; } } | Close is called when the connection should shutdown period |
30,953 | void closeSocketImpl ( ) { this . currentServerURI = null ; this . reader . stop ( ) ; this . writer . stop ( ) ; this . dataPortFuture . cancel ( true ) ; try { if ( this . dataPort != null ) { this . dataPort . close ( ) ; } } catch ( IOException ex ) { processException ( ex ) ; } cleanUpPongQueue ( ) ; try { this . reader . stop ( ) . get ( 10 , TimeUnit . SECONDS ) ; } catch ( Exception ex ) { processException ( ex ) ; } try { this . writer . stop ( ) . get ( 10 , TimeUnit . SECONDS ) ; } catch ( Exception ex ) { processException ( ex ) ; } } | Should only be called from closeSocket or close |
30,954 | public final synchronized String next ( ) { seq += inc ; if ( seq >= maxSeq ) { randomizePrefix ( ) ; resetSequential ( ) ; } char [ ] b = new char [ totalLen ] ; System . arraycopy ( pre , 0 , b , 0 , preLen ) ; int i = b . length ; for ( long l = seq ; i > preLen ; l /= base ) { i -- ; b [ i ] = digits [ ( int ) ( l % base ) ] ; } return new String ( b ) ; } | Generate the next NUID string from this instance . |
30,955 | void resetSequential ( ) { seq = nextLong ( prand , maxSeq ) ; inc = minInc + nextLong ( prand , maxInc - minInc ) ; } | Resets the sequntial portion of the NUID |
30,956 | public void unsubscribe ( ) { if ( this . dispatcher != null ) { throw new IllegalStateException ( "Subscriptions that belong to a dispatcher cannot respond to unsubscribe directly." ) ; } else if ( this . incoming == null ) { throw new IllegalStateException ( "This subscription is inactive." ) ; } if ( isDraining ( ) ) { return ; } this . connection . unsubscribe ( this , - 1 ) ; } | Unsubscribe this subscription and stop listening for messages . |
30,957 | public Subscription unsubscribe ( int after ) { if ( this . dispatcher != null ) { throw new IllegalStateException ( "Subscriptions that belong to a dispatcher cannot respond to unsubscribe directly." ) ; } else if ( this . incoming == null ) { throw new IllegalStateException ( "This subscription is inactive." ) ; } if ( isDraining ( ) ) { return this ; } this . connection . unsubscribe ( this , after ) ; return this ; } | Unsubscribe this subscription and stop listening for messages after the specified number of messages . |
30,958 | public static void connectAsynchronously ( Options options , boolean reconnectOnConnect ) throws InterruptedException { if ( options . getConnectionListener ( ) == null ) { throw new IllegalArgumentException ( "Connection Listener required in connectAsynchronously" ) ; } Thread t = new Thread ( ( ) -> { try { NatsImpl . createConnection ( options , reconnectOnConnect ) ; } catch ( Exception ex ) { if ( options . getErrorListener ( ) != null ) { options . getErrorListener ( ) . exceptionOccurred ( null , ex ) ; } } } ) ; t . setName ( "NATS - async connection" ) ; t . start ( ) ; } | Try to connect in another thread a connection listener is required to get the connection . |
30,959 | public static AuthHandler credentials ( String jwtFile , String nkeyFile ) { return NatsImpl . credentials ( jwtFile , nkeyFile ) ; } | Create an authhandler from a jwt file and an nkey file . The handler will read the files each time it needs to respond to a request and clear the memory after . This has a small price but will only be encountered during connect or reconnect . |
30,960 | public byte [ ] sign ( byte [ ] nonce ) { try { char [ ] keyChars = this . readKeyChars ( ) ; NKey nkey = NKey . fromSeed ( keyChars ) ; byte [ ] sig = nkey . sign ( nonce ) ; nkey . clear ( ) ; return sig ; } catch ( Exception exp ) { throw new IllegalStateException ( "problem signing nonce" , exp ) ; } } | Sign is called by the library when the server sends a nonce . The client s NKey should be used to sign the provided value . |
30,961 | public char [ ] getID ( ) { try { char [ ] keyChars = this . readKeyChars ( ) ; NKey nkey = NKey . fromSeed ( keyChars ) ; char [ ] pubKey = nkey . getPublicKey ( ) ; nkey . clear ( ) ; return pubKey ; } catch ( Exception exp ) { throw new IllegalStateException ( "problem getting public key" , exp ) ; } } | getID should return a public key associated with a client key known to the server . If the server is not in nonce - mode this array can be empty . |
30,962 | private boolean skipResource ( HttpServletRequest request , HttpServletResponse response ) { String path = request . getServletPath ( ) ; if ( path . contains ( "." ) ) { path = path . substring ( 0 , path . lastIndexOf ( "." ) ) ; } boolean skip = path . startsWith ( FACES_RESOURCES ) || shouldIgnoreResource ( path ) || response . getStatus ( ) == HttpServletResponse . SC_INTERNAL_SERVER_ERROR ; return skip ; } | skips faces - resources index error or logon pages |
30,963 | private boolean isValidRecoveryUrl ( StringBuilder recoveryUrl ) { String pageSuffix = adminConfig . getPageSufix ( ) ; return ! recoveryUrl . toString ( ) . contains ( Constants . DEFAULT_INDEX_PAGE . replace ( "xhtml" , pageSuffix ) ) && ! recoveryUrl . toString ( ) . contains ( Constants . DEFAULT_ACCESS_DENIED_PAGE . replace ( "xhtml" , adminConfig . getPageSufix ( ) ) ) && ! recoveryUrl . toString ( ) . contains ( Constants . DEFAULT_EXPIRED_PAGE . replace ( "xhtml" , pageSuffix ) ) && ! recoveryUrl . toString ( ) . contains ( Constants . DEFAULT_OPTIMISTIC_PAGE . replace ( "xhtml" , adminConfig . getPageSufix ( ) ) ) && ! recoveryUrl . toString ( ) . contains ( Constants . DEFAULT_LOGIN_PAGE . replace ( "xhtml" , adminConfig . getPageSufix ( ) ) ) ; } | Skip error pages login and index page as recovery url because it doesn t make sense redirecting user to such pages |
30,964 | private String getProperty ( String property ) { return has ( System . getProperty ( property ) ) ? System . getProperty ( property ) : has ( userConfigFile . getProperty ( property ) ) ? userConfigFile . getProperty ( property ) : adminConfigFile . getProperty ( property ) ; } | First tries to load the property from java system properties secondly looks for the property into user defined admin - config . properties then if not found load defaults from admin - config . properties provided within admin - template |
30,965 | public String getPageSufix ( ) { if ( has ( pageSuffix ) ) { return pageSuffix ; } if ( ! has ( indexPage ) && ! has ( loginPage ) ) { pageSuffix = Constants . DEFAULT_PAGE_FORMAT ; } if ( has ( indexPage ) ) { pageSuffix = indexPage . substring ( indexPage . lastIndexOf ( '.' ) + 1 ) ; } else { pageSuffix = indexPage . substring ( loginPage . lastIndexOf ( '.' ) + 1 ) ; } return pageSuffix ; } | infer page suffix from index and login page configured in admin - config . properties |
30,966 | private String findErrorPage ( Throwable exception ) { if ( exception instanceof EJBException && exception . getCause ( ) != null ) { exception = exception . getCause ( ) ; } String errorPage = WebXml . INSTANCE . findErrorPageLocation ( exception ) ; return errorPage ; } | Find error page in web . xml |
30,967 | private void validationFailed ( FacesContext context ) { Map < Object , Object > callbackParams = ( Map < Object , Object > ) context . getAttributes ( ) . get ( "CALLBACK_PARAMS" ) ; if ( callbackParams == null ) { callbackParams = new HashMap < > ( ) ; callbackParams . put ( "CALLBACK_PARAMS" , callbackParams ) ; } callbackParams . put ( "validationFailed" , true ) ; } | Set primefaces validationFailled callback param |
30,968 | private void findErrorMessages ( FacesContext context ) { if ( context . getMessageList ( ) . isEmpty ( ) || context . isValidationFailed ( ) ) { return ; } for ( FacesMessage msg : context . getMessageList ( ) ) { if ( msg . getSeverity ( ) . equals ( FacesMessage . SEVERITY_ERROR ) || msg . getSeverity ( ) . equals ( FacesMessage . SEVERITY_FATAL ) ) { validationFailed ( context ) ; break ; } } } | If there is any faces message queued add PrimeFaces validation failed |
30,969 | public ParameterBuilder matching ( String regex ) { Validate . notNull ( regex , "regex is required" ) ; this . pattern = Pattern . compile ( regex ) ; return this ; } | Sets a regular expression that must match for parameter values to be considered as valid . |
30,970 | public FeatureState copy ( ) { FeatureState copy = new FeatureState ( feature ) ; copy . setEnabled ( this . enabled ) ; copy . setStrategyId ( this . strategyId ) ; for ( Entry < String , String > entry : this . parameters . entrySet ( ) ) { copy . setParameter ( entry . getKey ( ) , entry . getValue ( ) ) ; } return copy ; } | Creates a copy of this state object |
30,971 | public List < String > getUsers ( ) { String value = getParameter ( UsernameActivationStrategy . PARAM_USERS ) ; if ( Strings . isNotBlank ( value ) ) { return Strings . splitAndTrim ( value , "," ) ; } return Collections . emptyList ( ) ; } | The list of users associated with the feature state . |
30,972 | public FeatureState addUsers ( Collection < String > users ) { Set < String > set = new LinkedHashSet < > ( ) ; set . addAll ( this . getUsers ( ) ) ; set . addAll ( users ) ; String setAsString = Strings . trimToNull ( Strings . join ( set , "," ) ) ; setParameter ( UsernameActivationStrategy . PARAM_USERS , setAsString ) ; return this ; } | Adds a single user to the list of users |
30,973 | public FeatureState setParameter ( String name , String value ) { if ( value != null ) { this . parameters . put ( name , value ) ; } else { this . parameters . remove ( name ) ; } return this ; } | Sets a new value for the given parameter . |
30,974 | public static void bind ( HttpServletRequest request ) { if ( request != null && threadLocal . get ( ) != null ) { throw new IllegalStateException ( "HttpServletRequestHolder.bind() called for a " + "thread that already has a request associated with it. It's likely that the request " + "was not correctly removed from the thread before it is put back into the thread pool." ) ; } threadLocal . set ( request ) ; } | Associate the request with the current thread . |
30,975 | @ Setup ( Level . Iteration ) public void toggleEnabledState ( ) { enabled = ! enabled ; manager . setFeatureState ( new FeatureState ( OverheadFeature . FEATURE , enabled ) ) ; } | toggle the state between iterations to keep the compiler honest |
30,976 | public Properties getFeatureProperties ( ) { Properties properties = new Properties ( ) ; for ( String name : features . keySet ( ) ) { properties . setProperty ( name , features . get ( name ) . spec ( ) ) ; } return properties ; } | The configured features in a format that can be consumed by a PropertyFeatureProvider . |
30,977 | public static < E > Collection < E > get ( Class < ? extends E > service ) { Iterator < ? extends E > implementations = ServiceLoader . load ( service ) . iterator ( ) ; Collection < E > result = new ArrayList < E > ( ) ; while ( implementations . hasNext ( ) ) { result . add ( implementations . next ( ) ) ; } return result ; } | Lookup implementations of the supplied SPI . Please note that the order in which the implementations will occur in the collection is not specified . |
30,978 | private void execute ( String sql ) throws SQLException { Statement statement = connection . createStatement ( ) ; try { statement . executeUpdate ( substitute ( sql ) ) ; } finally { DbUtils . closeQuietly ( statement ) ; } } | Executes the given statement . |
30,979 | protected Object createInstance ( String classname ) { ClassLoader classLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; if ( classLoader == null ) { classLoader = this . getClass ( ) . getClassLoader ( ) ; } try { return classLoader . loadClass ( classname ) . newInstance ( ) ; } catch ( InstantiationException e ) { throw new IllegalStateException ( e ) ; } catch ( IllegalAccessException e ) { throw new IllegalStateException ( e ) ; } catch ( ClassNotFoundException e ) { throw new IllegalStateException ( e ) ; } } | Creates an instance of the supplied class . |
30,980 | public String consumeToAny ( String ... seq ) { int start = pos ; while ( ! isEmpty ( ) && ! matchesAny ( seq ) ) { pos ++ ; } String data = queue . substring ( start , pos ) ; return data ; } | is is a case sensitive time ... |
30,981 | public static String unescape ( String in ) { StringBuilder out = new StringBuilder ( ) ; char last = 0 ; for ( char c : in . toCharArray ( ) ) { if ( c == ESC ) { if ( last != 0 && last == ESC ) out . append ( c ) ; } else out . append ( c ) ; last = c ; } return out . toString ( ) ; } | Unescaped a \ escaped string . |
30,982 | protected StringBuffer applyRules ( final Calendar calendar , final StringBuffer buf ) { return ( StringBuffer ) applyRules ( calendar , ( Appendable ) buf ) ; } | Performs the formatting by applying the rules to the specified calendar . |
30,983 | public static Headers of ( String ... namesAndValues ) { if ( namesAndValues == null ) throw new NullPointerException ( "namesAndValues == null" ) ; if ( namesAndValues . length % 2 != 0 ) { throw new IllegalArgumentException ( "Expected alternating header names and values" ) ; } namesAndValues = namesAndValues . clone ( ) ; for ( int i = 0 ; i < namesAndValues . length ; i ++ ) { if ( namesAndValues [ i ] == null ) throw new IllegalArgumentException ( "Headers cannot be null" ) ; namesAndValues [ i ] = namesAndValues [ i ] . trim ( ) ; } for ( int i = 0 ; i < namesAndValues . length ; i += 2 ) { String name = namesAndValues [ i ] ; String value = namesAndValues [ i + 1 ] ; if ( name . length ( ) == 0 || name . indexOf ( '\0' ) != - 1 || value . indexOf ( '\0' ) != - 1 ) { throw new IllegalArgumentException ( "Unexpected header: " + name + ": " + value ) ; } } return new Headers ( namesAndValues ) ; } | Returns headers for the alternating header names and values . There must be an even number of arguments and they must alternate between header names and values . |
30,984 | public Date getDate ( String name ) { String value = get ( name ) ; return value != null ? HttpDate . parse ( value ) : null ; } | Returns the last value corresponding to the specified field parsed as an HTTP date or null if either the field is absent or cannot be parsed as a date . |
30,985 | public Set < String > names ( ) { TreeSet < String > result = new TreeSet < > ( String . CASE_INSENSITIVE_ORDER ) ; for ( int i = 0 , size = size ( ) ; i < size ; i ++ ) { result . add ( name ( i ) ) ; } return Collections . unmodifiableSet ( result ) ; } | Returns an immutable case - insensitive set of header names . |
30,986 | static StringBuilder appendQuotedString ( StringBuilder target , String key ) { target . append ( '"' ) ; for ( int i = 0 , len = key . length ( ) ; i < len ; i ++ ) { char ch = key . charAt ( i ) ; switch ( ch ) { case '\n' : target . append ( "%0A" ) ; break ; case '\r' : target . append ( "%0D" ) ; break ; case '"' : target . append ( "%22" ) ; break ; default : target . append ( ch ) ; break ; } } target . append ( '"' ) ; return target ; } | Appends a quoted - string to a StringBuilder . |
30,987 | public Parent getParent ( ) { final ImageView imageView = new ImageView ( getClass ( ) . getResource ( getImagePath ( ) ) . toExternalForm ( ) ) ; final ProgressBar splashProgressBar = new ProgressBar ( ) ; splashProgressBar . setPrefWidth ( imageView . getImage ( ) . getWidth ( ) ) ; final VBox vbox = new VBox ( ) ; vbox . getChildren ( ) . addAll ( imageView , splashProgressBar ) ; return vbox ; } | Override this to create your own splash pane parent node . |
30,988 | private URL getURLResource ( final FXMLView annotation ) { if ( annotation != null && ! annotation . value ( ) . equals ( "" ) ) { return getClass ( ) . getResource ( annotation . value ( ) ) ; } else { return getClass ( ) . getResource ( getFxmlPath ( ) ) ; } } | Gets the URL resource . This will be derived from applied annotation value or from naming convention . |
30,989 | private FXMLLoader loadSynchronously ( final URL resource , final Optional < ResourceBundle > bundle ) throws IllegalStateException { final FXMLLoader loader = new FXMLLoader ( resource , bundle . orElse ( null ) ) ; loader . setControllerFactory ( this :: createControllerForType ) ; try { loader . load ( ) ; } catch ( final IOException | IllegalStateException e ) { throw new IllegalStateException ( "Cannot load " + getConventionalName ( ) , e ) ; } return loader ; } | Load synchronously . |
30,990 | private void ensureFxmlLoaderInitialized ( ) { if ( fxmlLoader != null ) { return ; } fxmlLoader = loadSynchronously ( resource , bundle ) ; presenterProperty . set ( fxmlLoader . getController ( ) ) ; } | Ensure fxml loader initialized . |
30,991 | public void getView ( final Consumer < Parent > consumer ) { CompletableFuture . supplyAsync ( this :: getView , Platform :: runLater ) . thenAccept ( consumer ) ; } | Initializes the view synchronously and invokes the consumer with the created parent Node within the FX UI thread . |
30,992 | void addCSSIfAvailable ( final Parent parent ) { final List < String > list = PropertyReaderHelper . get ( applicationContext . getEnvironment ( ) , "javafx.css" ) ; if ( ! list . isEmpty ( ) ) { list . forEach ( css -> parent . getStylesheets ( ) . add ( getClass ( ) . getResource ( css ) . toExternalForm ( ) ) ) ; } addCSSFromAnnotation ( parent ) ; final URL uri = getClass ( ) . getResource ( getStyleSheetName ( ) ) ; if ( uri == null ) { return ; } final String uriToCss = uri . toExternalForm ( ) ; parent . getStylesheets ( ) . add ( uriToCss ) ; } | Adds the CSS if available . |
30,993 | private void addCSSFromAnnotation ( final Parent parent ) { if ( annotation != null && annotation . css ( ) . length > 0 ) { for ( final String cssFile : annotation . css ( ) ) { final URL uri = getClass ( ) . getResource ( cssFile ) ; if ( uri != null ) { final String uriToCss = uri . toExternalForm ( ) ; parent . getStylesheets ( ) . add ( uriToCss ) ; LOGGER . debug ( "css file added to parent: {}" , cssFile ) ; } else { LOGGER . warn ( "referenced {} css file could not be located" , cssFile ) ; } } } } | Adds the CSS from annotation to parent . |
30,994 | private String getBundleName ( ) { if ( StringUtils . isEmpty ( annotation . bundle ( ) ) ) { final String lbundle = getClass ( ) . getPackage ( ) . getName ( ) + "." + getConventionalName ( ) ; LOGGER . debug ( "Bundle: {} based on conventional name." , lbundle ) ; return lbundle ; } final String lbundle = annotation . bundle ( ) ; LOGGER . debug ( "Annotated bundle: {}" , lbundle ) ; return lbundle ; } | Gets the bundle name . |
30,995 | private static String stripEnding ( final String clazz ) { if ( ! clazz . endsWith ( "view" ) ) { return clazz ; } return clazz . substring ( 0 , clazz . lastIndexOf ( "view" ) ) ; } | Strip ending . |
30,996 | final String getFxmlPath ( ) { final String fxmlPath = fxmlRoot + getConventionalName ( ".fxml" ) ; LOGGER . debug ( "Determined fxmlPath: " + fxmlPath ) ; return fxmlPath ; } | Gets the fxml file path . |
30,997 | private Optional < ResourceBundle > getResourceBundle ( final String name ) { try { LOGGER . debug ( "Resource bundle: " + name ) ; return Optional . of ( getBundle ( name , new ResourceBundleControl ( getResourceBundleCharset ( ) ) ) ) ; } catch ( final MissingResourceException ex ) { LOGGER . debug ( "No resource bundle could be determined: " + ex . getMessage ( ) ) ; return Optional . empty ( ) ; } } | Returns a resource bundle if available |
30,998 | public Observable < Void > execute ( final I request , final O response , C keyEvaluationContext ) { final ExecutionContext context = new ExecutionContext ( request , keyEvaluationContext ) ; InboundInterceptor < I , O > nextIn = context . nextIn ( request ) ; Observable < Void > startingPoint ; if ( null != nextIn ) { startingPoint = nextIn . in ( request , response ) ; } else if ( context . invokeRouter ( ) ) { startingPoint = router . handle ( request , response ) ; } else { return Observable . error ( new IllegalStateException ( "No router defined." ) ) ; } return startingPoint . lift ( new Observable . Operator < Void , Void > ( ) { public Subscriber < ? super Void > call ( Subscriber < ? super Void > child ) { SerialSubscription subscription = new SerialSubscription ( ) ; ChainSubscriber chainSubscriber = new ChainSubscriber ( subscription , context , request , response , child ) ; subscription . set ( chainSubscriber ) ; child . add ( subscription ) ; return chainSubscriber ; } } ) ; } | Executes the interceptor chain for the passed request and response . |
30,999 | public SimpleUriRouter < I , O > addUri ( String uri , RequestHandler < I , O > handler ) { routes . add ( new Route ( new ServletStyleUriConstraintKey < I > ( uri , "" ) , handler ) ) ; return this ; } | Add a new URI - < ; Handler route to this router . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.