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 ( Interleavin... | 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... | 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... | 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 < ... | 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 ) jsonDo... | 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 ( (... | 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 :... | 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 ... | 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 ... | 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 ... | 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 = fal... | 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 , ... | 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... | 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 ... | 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 ( ) ) { en... | 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 = " " ; }... | 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... | 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 ,... | 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 ... | 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 . l... | 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 ( ) ; } el... | 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 = '\\' ; ... | 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 .... | 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 (... | 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 . CONNEC... | 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 ( ) && ! ... | 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 . exceptionDu... | 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 . ... | 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 ... | 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 ( ) ... | 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... | 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 ... | 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 ) ... | 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... | 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 ... | 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 ) ; } c... | 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 (... | 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 ... | 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 , setAsStri... | 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 t... | 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 r... | 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 ( Instantiation... | 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... | 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 '"' ... | 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 ( ) ; v... | 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 (... | 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 ( ) ) ) ; } ... | 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 . get... | 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 ... | 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 bun... | 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 ) {... | 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.