idx int64 0 41.2k | question stringlengths 74 4.04k | target stringlengths 7 750 |
|---|---|---|
22,900 | private static HttpBuilder defaults ( HttpBuilder builder ) { if ( defaultTimeout != null ) { builder . timeout ( defaultTimeout ) ; } if ( defaultTimeoutConnection != null ) { builder . timeoutConnection ( defaultTimeoutConnection ) ; } if ( defaultTimeoutRead != null ) { builder . timeoutRead ( defaultTimeoutRead ) ;... | Setting the static defaults before returning the builder |
22,901 | public static void printBox ( String title , String message ) { printBox ( title , Splitter . on ( LINEBREAK ) . splitToList ( message ) ) ; } | Prints a box with the given title and message to the logger the title can be omitted . |
22,902 | public static void printBox ( String title , List < String > messageLines ) { Say . info ( "{message}" , generateBox ( title , messageLines ) ) ; } | Prints a box with the given title and message lines to the logger the title can be omitted . |
22,903 | public static void setUtc ( Date time ) { setClock ( Clock . fixed ( time . toInstant ( ) , ZoneId . of ( "UTC" ) ) ) ; } | Creates a fixed Clock . |
22,904 | public synchronized static void addShutdownHook ( Runnable task ) { if ( task != null ) { Runtime . getRuntime ( ) . addShutdownHook ( new Thread ( ( ) -> { try { task . run ( ) ; } catch ( RuntimeException rex ) { Say . warn ( "Exception while processing shutdown-hook" , rex ) ; } } ) ) ; } } | Null - safe shortcut to Runtime method catching RuntimeExceptions . |
22,905 | public void finish ( ) { if ( startMeasure == null ) { Say . info ( "No invokations are measured" ) ; } else { long total = System . currentTimeMillis ( ) - startMeasure ; double average = 1d * total / counter ; logFinished ( total , average ) ; } } | This method can be called to print the total amount of time taken until that point in time . |
22,906 | public void run ( ExceptionalRunnable runnable ) throws Exception { initStartTotal ( ) ; long startInvokation = System . currentTimeMillis ( ) ; runnable . run ( ) ; invoked ( System . currentTimeMillis ( ) - startInvokation ) ; } | Measure the invokation time of the given ExceptionalRunnable . |
22,907 | public < V > V call ( Callable < V > callable ) throws Exception { initStartTotal ( ) ; long startInvokation = System . currentTimeMillis ( ) ; V result = callable . call ( ) ; invoked ( System . currentTimeMillis ( ) - startInvokation ) ; return result ; } | Measure the invokation time of the given Callable . |
22,908 | public static void sleep ( long millis ) { try { Thread . sleep ( millis ) ; } catch ( InterruptedException ex ) { Thread . currentThread ( ) . interrupt ( ) ; } } | Sleep the given milliseconds swallowing the exception |
22,909 | public < T > T fallback ( T val , T fallback ) { return val != null ? val : fallback ; } | Returns the given value or the fallback if the value is null . |
22,910 | public Iterator < String > getMessages ( ) { Iterator < SmtpMessage > it = server . getReceivedEmail ( ) ; List < String > msgs = new ArrayList < > ( ) ; while ( it . hasNext ( ) ) { SmtpMessage msg = it . next ( ) ; msgs . add ( msg . toString ( ) ) ; } return msgs . iterator ( ) ; } | Returns an iterator of messages that were received by this server . |
22,911 | public static void registerMBean ( String packageName , String type , String name , Object mbean ) { try { String pkg = defaultString ( packageName , mbean . getClass ( ) . getPackage ( ) . getName ( ) ) ; MBeanServer server = ManagementFactory . getPlatformMBeanServer ( ) ; ObjectName on = new ObjectName ( pkg + ":typ... | Will register the given mbean using the given packageName type and name . If no packageName has been given the package of the mbean will be used . |
22,912 | public static Long dehumanize ( String time ) { Long result = getHumantimeCache ( ) . get ( time ) ; if ( result == null ) { if ( isNotBlank ( time ) ) { String input = time . trim ( ) ; if ( NumberUtils . isDigits ( input ) ) { result = NumberUtils . toLong ( input ) ; } else { Matcher matcher = PATTERN_HUMAN_TIME . m... | Converts a human readable duration in the format Xd Xh Xm Xs Xms to miliseconds . |
22,913 | public final V computeIfPresent ( K key , BiFunction < ? super K , ? super V , ? extends V > remappingFunction ) { if ( remappingFunction == null ) throw new NullPointerException ( ) ; long hash ; return segment ( segmentIndex ( hash = keyHashCode ( key ) ) ) . computeIfPresent ( this , hash , key , remappingFunction )... | If the value for the specified key is present and non - null attempts to compute a new mapping given the key and its current mapped value . |
22,914 | private long nextSegmentIndex ( long segmentIndex , Segment segment ) { long segmentsTier = this . segmentsTier ; segmentIndex <<= - segmentsTier ; segmentIndex = Long . reverse ( segmentIndex ) ; int numberOfArrayIndexesWithThisSegment = 1 << ( segmentsTier - segment . tier ) ; segmentIndex += numberOfArrayIndexesWith... | Extension rules make order of iteration of segments a little weird avoiding visiting the same segment twice |
22,915 | public final void replaceAll ( BiFunction < ? super K , ? super V , ? extends V > function ) { Objects . requireNonNull ( function ) ; int mc = this . modCount ; Segment < K , V > segment ; for ( long segmentIndex = 0 ; segmentIndex >= 0 ; segmentIndex = nextSegmentIndex ( segmentIndex , segment ) ) { ( segment = segme... | Replaces each entry s value with the result of invoking the given function on that entry until all entries have been processed or the function throws an exception . Exceptions thrown by the function are relayed to the caller . |
22,916 | public final boolean removeIf ( BiPredicate < ? super K , ? super V > filter ) { Objects . requireNonNull ( filter ) ; if ( isEmpty ( ) ) return false ; Segment < K , V > segment ; int mc = this . modCount ; int initialModCount = mc ; for ( long segmentIndex = 0 ; segmentIndex >= 0 ; segmentIndex = nextSegmentIndex ( s... | Removes all of the entries of this map that satisfy the given predicate . Errors or runtime exceptions thrown during iteration or by the predicate are relayed to the caller . |
22,917 | private String getJustifiedText ( String text ) { String [ ] words = text . split ( NORMAL_SPACE ) ; for ( String word : words ) { boolean containsNewLine = ( word . contains ( "\n" ) || word . contains ( "\r" ) ) ; if ( fitsInSentence ( word , currentSentence , true ) ) { addWord ( word , containsNewLine ) ; } else { ... | Retrieves a String with appropriate spaces to justify the text in the TextView . |
22,918 | private void addWord ( String word , boolean containsNewLine ) { currentSentence . add ( word ) ; if ( containsNewLine ) { sentences . add ( getSentenceFromListCheckingNewLines ( currentSentence ) ) ; currentSentence . clear ( ) ; } } | Adds a word into sentence and starts a new one if new line is part of the string . |
22,919 | private String getSentenceFromList ( List < String > strings , boolean addSpaces ) { StringBuilder stringBuilder = new StringBuilder ( ) ; for ( String string : strings ) { stringBuilder . append ( string ) ; if ( addSpaces ) { stringBuilder . append ( NORMAL_SPACE ) ; } } return stringBuilder . toString ( ) ; } | Creates a string using the words in the list and adds spaces between words if required . |
22,920 | private String getSentenceFromListCheckingNewLines ( List < String > strings ) { StringBuilder stringBuilder = new StringBuilder ( ) ; for ( String string : strings ) { stringBuilder . append ( string ) ; if ( ! string . contains ( "\n" ) && ! string . contains ( "\r" ) ) { stringBuilder . append ( NORMAL_SPACE ) ; } }... | Creates a string using the words in the list and adds spaces between words taking new lines in consideration . |
22,921 | private String fillSentenceWithSpaces ( List < String > sentence ) { sentenceWithSpaces . clear ( ) ; if ( sentence . size ( ) > 1 ) { for ( String word : sentence ) { sentenceWithSpaces . add ( word ) ; sentenceWithSpaces . add ( NORMAL_SPACE ) ; } while ( fitsInSentence ( HAIR_SPACE , sentenceWithSpaces , false ) ) {... | Fills sentence with appropriate amount of spaces . |
22,922 | private boolean fitsInSentence ( String word , List < String > sentence , boolean addSpaces ) { String stringSentence = getSentenceFromList ( sentence , addSpaces ) ; stringSentence += word ; float sentenceWidth = getPaint ( ) . measureText ( stringSentence ) ; return sentenceWidth < viewWidth ; } | Verifies if word to be added will fit into the sentence |
22,923 | final String writeManifest ( final TreeLogger logger , final Set < String > staticResources , final Map < String , String > fallbackResources , final Set < String > cacheResources ) throws UnableToCompleteException { final ManifestDescriptor descriptor = new ManifestDescriptor ( ) ; final List < String > cachedResource... | Write a manifest file for the given set of artifacts and return it as a string |
22,924 | final Permutation calculatePermutation ( final TreeLogger logger , final LinkerContext context , final ArtifactSet artifacts ) throws UnableToCompleteException { Permutation permutation = null ; for ( final SelectionInformation result : artifacts . find ( SelectionInformation . class ) ) { final String strongName = res... | Return the permutation for a single link step . |
22,925 | protected boolean handleUnmatchedRequest ( final HttpServletRequest request , final HttpServletResponse response , final String moduleName , final String baseUrl , final List < BindingProperty > computedBindings ) throws ServletException , IOException { return false ; } | Sub - classes can override this method to perform handle the inability to find a matching permutation . In which case the method should return true if the response has been handled . |
22,926 | protected final String loadAndMergeManifests ( final String baseUrl , final String moduleName , final String ... permutationNames ) throws ServletException { final String cacheKey = toCacheKey ( baseUrl , moduleName , permutationNames ) ; if ( isCacheEnabled ( ) ) { final String manifest = _cache . get ( cacheKey ) ; i... | Utility method that loads and merges the cache files for multiple permutations . This is useful when it is not possible to determine the exact permutation required for a client on the server . This defers the decision to the client but may result in extra files being downloaded . |
22,927 | protected final void reduceToMatchingDescriptors ( final List < BindingProperty > bindings , final List < SelectionDescriptor > descriptors ) { final Iterator < BindingProperty > iterator = bindings . iterator ( ) ; while ( iterator . hasNext ( ) ) { final BindingProperty property = iterator . next ( ) ; boolean matche... | This method will restrict the list of descriptors so that it only contains selections valid for specified bindings . Bindings will be removed from the list as they are matched . Unmatched bindings will remain in the bindings list after the method completes . |
22,928 | private BindingProperty findMatchingBindingProperty ( final List < BindingProperty > bindings , final BindingProperty requirement ) { for ( final BindingProperty candidate : bindings ) { if ( requirement . getName ( ) . equals ( candidate . getName ( ) ) ) { return candidate ; } } return null ; } | Return the binding property in the bindings list that matches specified requirement . |
22,929 | private BindingProperty findSatisfiesBindingProperty ( final List < BindingProperty > bindings , final BindingProperty requirement ) { final BindingProperty property = findMatchingBindingProperty ( bindings , requirement ) ; if ( null != property && property . matches ( requirement . getValue ( ) ) ) { return property ... | Return the binding property in the bindings list that satisfies specified requirement . Satisfies means that the property name matches and the value matches . |
22,930 | protected final String [ ] selectPermutations ( final String baseUrl , final String moduleName , final List < BindingProperty > computedBindings ) throws ServletException { try { final List < SelectionDescriptor > descriptors = new ArrayList < > ( ) ; descriptors . addAll ( getPermutationDescriptors ( baseUrl , moduleN... | Return an array of permutation names that are selected based on supplied properties . |
22,931 | public static < E > Collector < E , ? , Optional < E > > getOnly ( ) { return Collector . of ( AtomicReference < E > :: new , ( ref , e ) -> { if ( ! ref . compareAndSet ( null , e ) ) { throw new IllegalArgumentException ( "Multiple values" ) ; } } , ( ref1 , ref2 ) -> { if ( ref1 . get ( ) == null ) { return ref2 ; }... | Can be replaced with MoreCollectors . onlyElement as soon as we can upgrade to the newest Guava version . |
22,932 | public static Object getSingleResultOrNull ( Query query ) { List results = query . getResultList ( ) ; if ( results . isEmpty ( ) ) { return null ; } else if ( results . size ( ) == 1 ) { return results . get ( 0 ) ; } throw new NonUniqueResultException ( ) ; } | Executes the query and ensures that either a single result is returned or null . |
22,933 | public char [ ] hash ( char [ ] password , byte [ ] salt ) { checkNotNull ( password ) ; checkArgument ( password . length != 0 ) ; checkNotNull ( salt ) ; checkArgument ( salt . length != 0 ) ; try { SecretKeyFactory f = SecretKeyFactory . getInstance ( "PBKDF2WithHmacSHA1" ) ; SecretKey key = f . generateSecret ( new... | Hashes the password using pbkdf2 and the given salt . |
22,934 | public boolean check ( char [ ] plain , char [ ] database , byte [ ] salt ) { checkNotNull ( plain ) ; checkArgument ( plain . length != 0 , "Plain must not be empty." ) ; checkNotNull ( database ) ; checkArgument ( database . length != 0 , "Database must not be empty." ) ; checkNotNull ( salt ) ; checkArgument ( salt ... | Checks if the given plain password matches the given password hash |
22,935 | public static double mean ( double [ ] a ) { if ( a . length == 0 ) return Double . NaN ; double sum = sum ( a ) ; return sum / a . length ; } | Returns the average value in the specified array . |
22,936 | public static double stdDev ( double [ ] a ) { if ( a == null || a . length == 0 ) return - 1 ; return Math . sqrt ( varp ( a ) ) ; } | Returns the population standard deviation in the specified array . |
22,937 | public void writeFile ( String aFileName , String aData ) throws IOException { Object lock = retrieveLock ( aFileName ) ; synchronized ( lock ) { IO . writeFile ( aFileName , aData , IO . CHARSET ) ; } } | Write string file data |
22,938 | private Object retrieveLock ( String key ) { Object lock = this . lockMap . get ( key ) ; if ( lock == null ) { lock = key ; this . lockMap . put ( key , lock ) ; } return lock ; } | Retrieve the lock object for a given key |
22,939 | protected void formatMessage ( String aID , Map < Object , Object > aBindValues ) { Presenter presenter = Presenter . getPresenter ( this . getClass ( ) ) ; message = presenter . getText ( aID , aBindValues ) ; } | Format the exception message using the presenter getText method |
22,940 | @ SuppressWarnings ( { "rawtypes" , "unchecked" } ) protected DirContext setupKerberosContext ( Hashtable < String , Object > env ) throws NamingException { LoginContext lc = null ; try { lc = new LoginContext ( getClass ( ) . getName ( ) , new JXCallbackHandler ( ) ) ; lc . login ( ) ; } catch ( LoginException ex ) { ... | Initial LDAP for kerberos support |
22,941 | public Principal authenicate ( String uid , char [ ] password ) throws SecurityException { String rootDN = Config . getProperty ( ROOT_DN_PROP ) ; int timeout = Config . getPropertyInteger ( TIMEOUT_SECS_PROP ) . intValue ( ) ; Debugger . println ( LDAP . class , "timeout=" + timeout ) ; String uidAttributeName = Confi... | Authenticate user ID and password against the LDAP server |
22,942 | public GenericField [ ] getFields ( ) { Collection < GenericField > values = fieldMap . values ( ) ; if ( values == null || values . isEmpty ( ) ) return null ; GenericField [ ] fieldMirrors = new GenericField [ values . size ( ) ] ; values . toArray ( fieldMirrors ) ; return fieldMirrors ; } | List all fields |
22,943 | public void sortRows ( Comparator < List < String > > comparator ) { if ( data . isEmpty ( ) ) return ; Collections . sort ( data , comparator ) ; } | Sort the rows by comparator |
22,944 | public JavaBeanGeneratorCreator < T > randomizeProperty ( String property ) { if ( property == null || property . length ( ) == 0 ) return this ; this . randomizeProperties . add ( property ) ; return this ; } | Setup property to generate a random value |
22,945 | public JavaBeanGeneratorCreator < T > fixedProperties ( String ... fixedPropertyNames ) { if ( fixedPropertyNames == null || fixedPropertyNames . length == 0 ) { return this ; } HashSet < String > fixSet = new HashSet < > ( Arrays . asList ( fixedPropertyNames ) ) ; Map < Object , Object > map = null ; if ( this . prot... | Randomized to records that are not in fixed list |
22,946 | public void setPrimaryKey ( int primaryKey ) throws IllegalArgumentException { if ( primaryKey <= NULL ) { this . primaryKey = Data . NULL ; } else { this . primaryKey = primaryKey ; return ; } } | Set primary key |
22,947 | public T lookup ( String text ) { if ( text == null ) return null ; for ( Entry < String , T > entry : lookupMap . entrySet ( ) ) { if ( Text . matches ( text , entry . getKey ( ) ) ) return lookupMap . get ( entry . getKey ( ) ) ; } return null ; } | Lookup a value of the dictionary |
22,948 | @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) public static final < T > Collection < DataRow > constructDataRows ( Iterator < T > iterator , QuestCriteria questCriteria , DataRowCreator visitor ) { if ( iterator == null ) return null ; ArrayList < DataRow > dataRows = new ArrayList < DataRow > ( BATCH_SIZE ) ; bo... | Process results with support for paging |
22,949 | public void rebind ( Remote [ ] remotes ) { String rmiUrl = null ; for ( int i = 0 ; i < remotes . length ; i ++ ) { if ( remotes [ i ] instanceof Identifier && ! Text . isNull ( ( ( Identifier ) remotes [ i ] ) . getId ( ) ) ) { rmiUrl = ( ( Identifier ) remotes [ i ] ) . getId ( ) ; } else { rmiUrl = Config . getProp... | Bind all object . Note that the rmiUrl in located in the config . properties |
22,950 | public static Registry getRegistry ( ) throws RemoteException { return LocateRegistry . getRegistry ( Config . getProperty ( RMI . class , "host" ) , Config . getPropertyInteger ( RMI . class , "port" ) . intValue ( ) ) ; } | Create a new local registry on a local port |
22,951 | public Object restore ( String savePoint , Class < ? > objClass ) { String location = whereIs ( savePoint , objClass ) ; Object cacheObject = CacheFarm . getCache ( ) . get ( location ) ; if ( cacheObject != null ) return cacheObject ; cacheObject = IO . deserialize ( new File ( location ) ) ; CacheFarm . getCache ( ) ... | Retrieve the de - serialized object |
22,952 | public void store ( String savePoint , Object obj ) { if ( savePoint == null ) throw new RequiredException ( "savePoint" ) ; if ( obj == null ) throw new RequiredException ( "obj" ) ; String location = whereIs ( savePoint , obj . getClass ( ) ) ; Debugger . println ( this , "Storing in " + location ) ; IO . serializeTo... | Store the serialized object |
22,953 | static int requireValidExponent ( final int exponent ) { if ( exponent < MIN_EXPONENT ) { throw new IllegalArgumentException ( "exponent(" + exponent + ") < " + MIN_EXPONENT ) ; } if ( exponent > MAX_EXPONENT ) { throw new IllegalArgumentException ( "exponent(" + exponent + ") > " + MAX_EXPONENT ) ; } return exponent ;... | Validates given exponent . |
22,954 | public void setLookupTable ( Map < String , Map < K , V > > lookupTable ) { this . lookupTable = new TreeMap < String , Map < K , V > > ( lookupTable ) ; } | The key of the lookup table is a regular expression |
22,955 | @ SuppressWarnings ( "unchecked" ) public static < T > T getProperty ( Object bean , String name ) throws SystemException { try { return ( T ) getNestedProperty ( bean , name ) ; } catch ( Exception e ) { throw new SystemException ( "Get property \"" + name + "\" ERROR:" + e . getMessage ( ) , e ) ; } } | Retrieve the bean property |
22,956 | public static Collection < Object > getCollectionProperties ( Collection < ? > collection , String name ) throws Exception { if ( collection == null ) throw new IllegalArgumentException ( "collection, name" ) ; ArrayList < Object > list = new ArrayList < Object > ( collection . size ( ) ) ; for ( Object bean : collecti... | Retrieve the list of properties that exists in a given collection |
22,957 | public String getText ( ) { StringText stringText = new StringText ( ) ; stringText . setText ( this . target . getText ( ) ) ; TextDecorator < Textable > textDecorator = null ; for ( Iterator < TextDecorator < Textable > > i = textables . iterator ( ) ; i . hasNext ( ) ; ) { textDecorator = i . next ( ) ; textDecorato... | Get the target text and execute each text decorator on its results |
22,958 | public static < T > Collection < T > sortByCriteria ( Collection < T > aVOs ) { final List < T > list ; if ( aVOs instanceof List ) list = ( List < T > ) aVOs ; else list = new ArrayList < T > ( aVOs ) ; Collections . sort ( list , new CriteriaComparator ( ) ) ; return list ; } | Sort a list |
22,959 | public void bag ( Date unBaggedObject ) { if ( unBaggedObject == null ) this . time = 0 ; else this . time = unBaggedObject . getTime ( ) ; } | Wraps a given date in a format that can be easily unbagged |
22,960 | public static Method findMethod ( Class < ? > objClass , String methodName , Class < ? > [ ] parameterTypes ) throws NoSuchMethodException { try { return objClass . getDeclaredMethod ( methodName , parameterTypes ) ; } catch ( NoSuchMethodException e ) { if ( Object . class . equals ( objClass ) ) throw e ; try { retur... | Find the method for a target of its parent |
22,961 | public String getText ( ) { if ( this . target == null ) return null ; try { if ( ( this . template == null || this . template . length ( ) == 0 ) && this . templateName != null ) { try { this . template = Text . loadTemplate ( templateName ) ; } catch ( Exception e ) { throw new SetupException ( "Cannot load template:... | Converts the target fault into a formatted text . |
22,962 | public static void addCells ( StringBuilder builder , String ... cells ) { if ( builder == null || cells == null || cells . length == 0 ) return ; for ( String cell : cells ) { addCell ( builder , cell ) ; } } | Add formatted CSV cells to a builder |
22,963 | public static String toCSV ( String ... cells ) { if ( cells == null || cells . length == 0 ) return null ; StringBuilder builder = new StringBuilder ( ) ; addCells ( builder , cells ) ; return builder . toString ( ) ; } | Create a CSV line |
22,964 | public String encryptText ( String text ) throws Exception { return toByteText ( this . encrypt ( text . getBytes ( IO . CHARSET ) ) ) ; } | The text to encrypt |
22,965 | public static void main ( String [ ] args ) { try { if ( args . length == 0 ) { System . err . println ( "Usage java " + Cryption . class . getName ( ) + " <text>" ) ; return ; } final String decryptedPassword ; if ( args [ 0 ] . equals ( "-d" ) ) { if ( args . length > 2 ) { StringBuilder p = new StringBuilder ( ) ; f... | Encrypt a given values |
22,966 | public int compareTo ( Object object ) { if ( ! ( object instanceof User ) ) { return - 1 ; } User user = ( User ) object ; return getLastName ( ) . compareTo ( user . getLastName ( ) ) ; } | Compare user s by last name |
22,967 | public static Object executeMethod ( Object object , MethodCallFact methodCallFact ) throws Exception { if ( object == null ) throw new RequiredException ( "object" ) ; if ( methodCallFact == null ) throw new RequiredException ( "methodCallFact" ) ; return executeMethod ( object , methodCallFact . getMethodName ( ) , m... | Execute the method call on a object |
22,968 | public synchronized void setUp ( ) { if ( initialized ) return ; String className = null ; Map < Object , Object > properties = settings . getProperties ( ) ; String key = null ; Object serviceObject = null ; for ( Map . Entry < Object , Object > entry : properties . entrySet ( ) ) { key = String . valueOf ( entry . ge... | Setup the factory beans |
22,969 | private String getValidURL ( String url ) { if ( url != null && url . length ( ) > 0 ) { return url . replaceAll ( "[%]" , "%25" ) . replaceAll ( " " , "%20" ) . replaceAll ( "[<]" , "%3c" ) . replaceAll ( "[>]" , "%3e" ) . replaceAll ( "[\"]" , "%3f" ) . replaceAll ( "[#]" , "%23" ) . replaceAll ( "[{]" , "%7b" ) . re... | Returns valid LDAP URL for the specified URL . |
22,970 | private static void setupSimpleSecurityProperties ( Hashtable < String , Object > env , String userDn , char [ ] pwd ) { env . put ( Context . SECURITY_AUTHENTICATION , "simple" ) ; env . put ( Context . SECURITY_PRINCIPAL , userDn ) ; env . put ( Context . SECURITY_CREDENTIALS , new String ( pwd ) ) ; } | Sets the environment properties needed for a simple username + password authenticated jndi connection . |
22,971 | private Hashtable < ? , ? > setupBasicProperties ( Hashtable < String , Object > env ) throws NamingException { return setupBasicProperties ( env , this . fullUrl ) ; } | Sets basic LDAP connection properties in env . |
22,972 | public static String getProperty ( Class < ? > aClass , String key , ResourceBundle resourceBundle ) { return getSettings ( ) . getProperty ( aClass , key , resourceBundle ) ; } | Get the property |
22,973 | public static String getProperty ( String key , String aDefault ) { return getSettings ( ) . getProperty ( key , aDefault ) ; } | Retrieves a configuration property as a String object . |
22,974 | public static Integer getPropertyInteger ( Class < ? > aClass , String key , int defaultValue ) { return getSettings ( ) . getPropertyInteger ( key , defaultValue ) ; } | Get a configuration property as an Integer object . |
22,975 | public static Character getPropertyCharacter ( Class < ? > aClass , String key , char defaultValue ) { return getSettings ( ) . getPropertyCharacter ( aClass , key , defaultValue ) ; } | Get a configuration property as an c object . |
22,976 | public static char [ ] getPropertyPassword ( Class < ? > aClass , String key , char [ ] defaultPassword ) { return getSettings ( ) . getPropertyPassword ( aClass , key , defaultPassword ) ; } | Retrieve the password |
22,977 | public static < T > void addAll ( Collection < T > pagingResults , Collection < T > paging , BooleanExpression < T > filter ) { if ( pagingResults == null || paging == null ) return ; if ( filter != null ) { for ( T obj : paging ) { if ( filter . apply ( obj ) ) pagingResults . add ( obj ) ; } } else { for ( T obj : pa... | Add all collections |
22,978 | public static Object findMapValueByKey ( Object key , Map < ? , ? > map , Object defaultValue ) { if ( key == null || map == null ) return defaultValue ; Object value = map . get ( key ) ; if ( value == null ) return defaultValue ; return value ; } | Find the value with a given key in the map . |
22,979 | public static void addAll ( Collection < Object > list , Object [ ] objects ) { list . addAll ( Arrays . asList ( objects ) ) ; } | Add object to a list |
22,980 | public static void copyToArray ( Collection < Object > collection , Object [ ] objects ) { System . arraycopy ( collection . toArray ( ) , 0 , objects , 0 , objects . length ) ; } | Copy collection objects to a given array |
22,981 | public static < K , V > void addMappableCopiesToMap ( Collection < Mappable < K , V > > aMappables , Map < K , V > aMap ) { if ( aMappables == null || aMap == null ) return ; Mappable < K , V > mappable = null ; Copier previous = null ; for ( Iterator < Mappable < K , V > > i = aMappables . iterator ( ) ; i . hasNext (... | Add mappable to map |
22,982 | public static < T , K > Collection < T > findMapValuesByKey ( Collection < K > aKeys , Map < K , T > aMap ) { if ( aKeys == null || aMap == null ) return null ; Object key = null ; ArrayList < T > results = new ArrayList < T > ( aMap . size ( ) ) ; for ( Iterator < K > i = aKeys . iterator ( ) ; i . hasNext ( ) ; ) { k... | Find values in map that match a given key |
22,983 | public static < T > void addAll ( Collection < T > aFrom , Collection < T > aTo ) { if ( aFrom == null || aTo == null ) return ; T object = null ; for ( Iterator < T > i = aFrom . iterator ( ) ; i . hasNext ( ) ; ) { object = i . next ( ) ; if ( object != null ) { aTo . add ( object ) ; } } } | All object to a given collection |
22,984 | public static Map < String , Criteria > constructCriteriaMap ( Collection < Criteria > aCriterias ) { if ( aCriterias == null ) return null ; Map < String , Criteria > map = new HashMap < String , Criteria > ( aCriterias . size ( ) ) ; Criteria criteria = null ; for ( Iterator < Criteria > i = aCriterias . iterator ( )... | construct map for collection of criteria object wher the key is Criteria . getId |
22,985 | public static Map < Integer , PrimaryKey > constructPrimaryKeyMap ( Collection < PrimaryKey > aPrimaryKeys ) { if ( aPrimaryKeys == null ) return null ; Map < Integer , PrimaryKey > map = new HashMap < Integer , PrimaryKey > ( aPrimaryKeys . size ( ) ) ; PrimaryKey primaryKey = null ; for ( Iterator < PrimaryKey > i = ... | construct map for collection of criteria object where the key is Criteria . getId |
22,986 | public static < K > void makeAuditableCopies ( Map < K , Copier > aFormMap , Map < K , Copier > aToMap , Auditable aAuditable ) { if ( aFormMap == null || aToMap == null ) return ; K fromKey = null ; Copier to = null ; Copier from = null ; for ( Map . Entry < K , Copier > entry : aFormMap . entrySet ( ) ) { fromKey = e... | Copy value form one map to another |
22,987 | public static Object [ ] toArray ( Object obj ) { if ( obj instanceof Object [ ] ) return ( Object [ ] ) obj ; else { Object [ ] returnArray = { obj } ; return returnArray ; } } | Cast into an array of objects or create a array with a single entry |
22,988 | public static < StoredObjectType , ResultSetType > Pagination createPagination ( PageCriteria pageCriteria ) { String id = pageCriteria . getId ( ) ; if ( id == null || id . length ( ) == 0 ) { return null ; } Pagination pagination = ClassPath . newInstance ( paginationClassName , String . class , pageCriteria . getId ... | Create a pagination instance |
22,989 | public void loadJar ( File fileJar ) throws IOException { JarFile jar = null ; try { jar = new JarFile ( fileJar ) ; Enumeration < JarEntry > enumerations = jar . entries ( ) ; JarEntry entry = null ; byte [ ] classByte = null ; ByteArrayOutputStream byteStream = null ; String fileName = null ; String className = null ... | Load all classes in the fileJar |
22,990 | public Class < ? > findClass ( String className ) { Class < ? > result = null ; result = ( Class < ? > ) classes . get ( className ) ; if ( result != null ) { return result ; } try { return findSystemClass ( className ) ; } catch ( Exception e ) { Debugger . printWarn ( e ) ; } try { URL resourceURL = ClassLoader . get... | Find the class by it name |
22,991 | private byte [ ] loadClassBytes ( File classFile ) throws IOException { int size = ( int ) classFile . length ( ) ; byte buff [ ] = new byte [ size ] ; FileInputStream fis = new FileInputStream ( classFile ) ; DataInputStream dis = null ; try { dis = new DataInputStream ( fis ) ; dis . readFully ( buff ) ; } finally { ... | Load the class name |
22,992 | public int compareTo ( Day object ) { if ( object == null ) throw new IllegalArgumentException ( "day cannot be null" ) ; Day day = ( Day ) object ; return localDate . compareTo ( day . localDate ) ; } | Compare this day to the specified day . If object is not of type Day a ClassCastException is thrown . |
22,993 | public boolean isAfter ( Day day ) { if ( day == null ) throw new IllegalArgumentException ( "day cannot be null" ) ; return localDate . isAfter ( day . localDate ) ; } | Return true if this day is after the specified day . |
22,994 | public boolean isBefore ( Day day ) { if ( day == null ) throw new IllegalArgumentException ( "day cannot be null" ) ; return localDate . isBefore ( day . localDate ) ; } | Return true if this day is before the specified day . |
22,995 | public boolean isSameDay ( Day compared ) { if ( compared == null ) return false ; return this . getMonth ( ) == compared . getMonth ( ) && this . getDayOfMonth ( ) == compared . getDayOfMonth ( ) && this . getYear ( ) == compared . getYear ( ) ; } | Compare based on month day year |
22,996 | public synchronized String lookup ( String id ) { if ( this . properties == null ) this . setUp ( ) ; String associated = this . properties . getProperty ( id ) ; if ( associated == null ) { associated = this . next ( ) ; register ( id , associated ) ; } return associated ; } | Lookup the location of a key |
22,997 | public void manage ( int workersCount ) { this . workers . clear ( ) ; WorkerThread worker = null ; for ( int i = 0 ; i < workersCount ; i ++ ) { worker = new WorkerThread ( this ) ; this . manage ( worker ) ; } } | Manage a number of default worker threads |
22,998 | String getMatchingJavaEncoding ( String javaEncoding ) { if ( javaEncoding != null && this . javaEncodingsUc . contains ( javaEncoding . toUpperCase ( Locale . ENGLISH ) ) ) { return javaEncoding ; } return this . javaEncodingsUc . get ( 0 ) ; } | If javaEncoding parameter value is one of available java encodings for this charset then returns javaEncoding value as is . Otherwise returns first available java encoding name . |
22,999 | public UserProfile convert ( String text ) { if ( text == null || text . trim ( ) . length ( ) == 0 ) return null ; String [ ] lines = text . split ( "\\\n" ) ; BiConsumer < String , UserProfile > strategy = null ; UserProfile userProfile = null ; String lineUpper = null ; for ( String line : lines ) { int index = line... | Convert from text from user profile |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.