idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
29,300 | public boolean process ( Set < ? extends TypeElement > elements , RoundEnvironment environment ) { Messager messager = processingEnv . getMessager ( ) ; for ( TypeElement element : elements ) { Set < ? extends Element > elementsAnnotatedWith = environment . getElementsAnnotatedWith ( element ) ; for ( Element elementAnnotatedWith : elementsAnnotatedWith ) { TypeElement typeElement = ( TypeElement ) elementAnnotatedWith ; EntityValidator validator = new EntityValidator ( processingEnv . getTypeUtils ( ) ) ; List < Problem > problems = validator . validate ( typeElement ) ; boolean error = false ; for ( Problem problem : problems ) { if ( problem . kind ( ) == Kind . ERROR ) { error = true ; } messager . printMessage ( problem . kind ( ) , problem . message ( ) , problem . element ( ) ) ; } if ( ! error ) { MetamodelSource source = new MetamodelSource ( typeElement , processingEnv ) ; try { source . save ( ) ; } catch ( Exception e ) { messager . printMessage ( Kind . ERROR , "Metamodel [" + source . toMetamodelName ( typeElement . getQualifiedName ( ) . toString ( ) ) + "] cannot be saved due to [" + e + "]" , typeElement ) ; e . printStackTrace ( ) ; } } } } return true ; } | Generates metamodel Java source file of the specified Acid House entity class representations . |
29,301 | protected URLConnection openConnection ( URL url ) throws IOException { logger . trace ( "opening connection to resource '{}' (protocol: '{}')" , url . getPath ( ) , url . getProtocol ( ) ) ; URL resource = classloader . getResource ( url . getPath ( ) ) ; return resource . openConnection ( ) ; } | Opens a connection to the given resource if found in the classpath . |
29,302 | public static < T > Pair < T , IterableIterator < T > > takeOneFromTopN ( Iterator < T > iterator , int n ) { if ( ! iterator . hasNext ( ) || n < 1 ) { return new Pair < T , IterableIterator < T > > ( null , iterable ( iterator ) ) ; } List < T > firstN = new ArrayList < > ( n ) ; int i = 0 ; while ( i < n && iterator . hasNext ( ) ) { firstN . add ( iterator . next ( ) ) ; i ++ ; } return new Pair < > ( firstN . remove ( ThreadLocalRandom . current ( ) . nextInt ( 0 , firstN . size ( ) ) ) , iterable ( com . google . common . collect . Iterators . concat ( com . google . common . collect . Iterators . unmodifiableIterator ( firstN . iterator ( ) ) , iterator ) ) ) ; } | Takes one of the first n items of the iterator returning that item an a new Iterator which excludes that item . Remove operation is not supported on the first n items of the returned iterator . For the remaining items remove delegates to the original Iterator . |
29,303 | public static Prefer valueOf ( final String value ) { if ( nonNull ( value ) ) { final Map < String , String > data = new HashMap < > ( ) ; final Set < String > params = new HashSet < > ( ) ; stream ( value . split ( ";" ) ) . map ( String :: trim ) . map ( pref -> pref . split ( "=" , 2 ) ) . forEach ( x -> { if ( x . length == 2 ) { data . put ( x [ 0 ] . trim ( ) , x [ 1 ] . trim ( ) ) ; } else { params . add ( x [ 0 ] . trim ( ) ) ; } } ) ; final String waitValue = data . get ( PREFER_WAIT ) ; try { Integer wait = null ; if ( nonNull ( waitValue ) ) { wait = parseInt ( waitValue ) ; } return new Prefer ( data . get ( PREFER_RETURN ) , parseParameter ( data . get ( PREFER_INCLUDE ) ) , parseParameter ( data . get ( PREFER_OMIT ) ) , params , data . get ( PREFER_HANDLING ) , wait ) ; } catch ( final NumberFormatException ex ) { LOGGER . error ( "Cannot parse wait parameter value {}: {}" , waitValue , ex . getMessage ( ) ) ; } } return null ; } | Create a Prefer header representation from a header string |
29,304 | public CredentialParams lookup ( String correlationId ) throws ApplicationException { if ( _credentials . size ( ) == 0 ) return null ; for ( CredentialParams credential : _credentials ) { if ( ! credential . useCredentialStore ( ) ) return credential ; } for ( CredentialParams credential : _credentials ) { if ( credential . useCredentialStore ( ) ) { CredentialParams resolvedConnection = lookupInStores ( correlationId , credential ) ; if ( resolvedConnection != null ) return resolvedConnection ; } } return null ; } | Looks up component credential parameters . If credentials are configured to be retrieved from Credential store it finds a ICredentialStore and lookups credentials there . |
29,305 | public static Response loadFromBase64XML ( Sso ssoService , String base64xml ) throws CertificateException , ParserConfigurationException , SAXException , IOException { return loadFromBase64XML ( ssoService . getSamlSettings ( ) . getIdpCertificate ( ) , base64xml ) ; } | Load the response with the provided base64 encoded XML string |
29,306 | public boolean isValid ( ) { NodeList nodes = xmlDoc . getElementsByTagNameNS ( XMLSignature . XMLNS , "Signature" ) ; if ( nodes == null || nodes . getLength ( ) == 0 ) { logger . debug ( "Can't find signature in document" ) ; return false ; } if ( setIdAttributeExists ( ) ) { tagIdAttributes ( xmlDoc ) ; } X509Certificate cert = certificate . getX509Cert ( ) ; DOMValidateContext ctx = new DOMValidateContext ( cert . getPublicKey ( ) , nodes . item ( 0 ) ) ; XMLSignatureFactory sigF = XMLSignatureFactory . getInstance ( "DOM" ) ; XMLSignature xmlSignature ; try { xmlSignature = sigF . unmarshalXMLSignature ( ctx ) ; } catch ( Exception e ) { logger . debug ( "Could not unmarshalXMLSignature" , e ) ; xmlSignature = null ; } if ( xmlSignature == null ) { return false ; } try { return xmlSignature . validate ( ctx ) ; } catch ( XMLSignatureException e ) { logger . debug ( "Could not validate signature" , e ) ; } return false ; } | Check if the XML response provided by the IDP is valid or not |
29,307 | private String surroundFields ( String csvData ) { StringBuilder surroundedCSV = null ; StringTokenizer currTokenizer = null ; surroundedCSV = new StringBuilder ( ) ; for ( String currLine : csvData . split ( BREAK ) ) { currTokenizer = new StringTokenizer ( currLine , SEP ) ; while ( currTokenizer . hasMoreTokens ( ) ) { surroundedCSV . append ( QUOTATION ) . append ( currTokenizer . nextToken ( ) ) . append ( QUOTATION ) ; if ( currTokenizer . hasMoreTokens ( ) ) surroundedCSV . append ( SEP ) ; } surroundedCSV . append ( BREAK ) ; } return surroundedCSV . toString ( ) ; } | Surround the given CSV data with quotations for every field . |
29,308 | private void writeFile ( File file , String csvData ) throws IOException { LOG . debug ( "Will try to write CSV data to file: " + file . getAbsolutePath ( ) ) ; FileUtils . writeStringToFile ( file , csvData , Charset . forName ( ENCODING ) , false ) ; LOG . debug ( "Finished writing CSV data to file: " + file . getAbsolutePath ( ) ) ; } | Write the given string to the file provided . |
29,309 | public void close ( ) throws Exception { BufferedWriter writer = null ; try { FileWriter fw = new FileWriter ( file . getAbsoluteFile ( ) ) ; writer = new BufferedWriter ( fw ) ; String header = layout . getFileHeader ( ) ; if ( header != null ) { writer . append ( header ) ; } String presentationHeader = layout . getPresentationHeader ( ) ; if ( presentationHeader != null ) { writer . append ( presentationHeader ) ; } int len = buffer . length ( ) ; for ( int i = 0 ; i < len ; i ++ ) { ILoggingEvent event = buffer . get ( ) ; writer . append ( layout . doLayout ( event ) ) ; } String presentationFooter = layout . getPresentationFooter ( ) ; if ( presentationFooter != null ) { writer . append ( presentationFooter ) ; } String footer = layout . getFileFooter ( ) ; if ( footer != null ) { writer . append ( footer ) ; } } finally { if ( writer != null ) { writer . flush ( ) ; writer . close ( ) ; } } } | Close the trace and write the file |
29,310 | public Context createChild ( ) { Context c = new Context ( ) ; c . memoryHeap = memoryHeap ; c . parent = this ; this . children . add ( c ) ; return c ; } | Create child context |
29,311 | public void set ( String name , Object o ) { Map < String , Object > m = getMap ( name ) ; if ( m != null ) { memoryHeap . release ( m . get ( name ) ) ; m . put ( name , o ) ; memoryHeap . take ( m . get ( name ) ) ; } } | Find and set parameter from this context and upwards |
29,312 | public void remove ( String name ) { Map < String , Object > m = getMap ( name ) ; if ( m != null ) { memoryHeap . release ( m . get ( name ) ) ; m . remove ( name ) ; } } | Find and remove parameter from this context and upwards |
29,313 | public Map < String , Object > getMap ( String name ) { if ( variables . containsKey ( name ) ) return variables ; else if ( parent != null ) return parent . getMap ( name ) ; return null ; } | Find map containing parameter from this context and upwards |
29,314 | public Object convertUponGet ( final Object value ) { if ( value == null ) { return null ; } return _formatter . format ( ( Date ) value ) ; } | from Date to String |
29,315 | public Object convertUponSet ( final Object value ) { Date date = null ; if ( value != null ) { try { date = _formatter . parse ( ( String ) value ) ; } catch ( ParseException p_ex ) { throw new IllegalArgumentException ( p_ex . getMessage ( ) ) ; } } return date ; } | from String to Date |
29,316 | public void createTables ( ) { Validate . notNull ( connector , "connector must not be null" ) ; Validate . notNull ( tableOperations , "tableOperations must not be null" ) ; Value defaultFieldDelimiter = new Value ( "\t" . getBytes ( charset ) ) ; Value defaultFactDelimiter = new Value ( "|" . getBytes ( charset ) ) ; int isEdgePresent = tableOperations . exists ( getEdgeTable ( ) ) ? 1 : 0 ; int isTransposePresent = tableOperations . exists ( getTransposeTable ( ) ) ? 1 : 0 ; int isDegreePresent = tableOperations . exists ( getDegreeTable ( ) ) ? 1 : 0 ; int isMetatablePresent = tableOperations . exists ( getMetadataTable ( ) ) ? 1 : 0 ; int isTextPresent = tableOperations . exists ( getTextTable ( ) ) ? 1 : 0 ; int tableCount = isEdgePresent + isTransposePresent + isDegreePresent + isMetatablePresent + isTextPresent ; if ( tableCount > 0 && tableCount < 5 ) { throw new D4MException ( "D4M: RootName[" + getRootName ( ) + "] Inconsistent state - one or more D4M tables is missing." ) ; } if ( tableCount == 5 ) { return ; } try { tableOperations . create ( getEdgeTable ( ) ) ; tableOperations . create ( getTransposeTable ( ) ) ; tableOperations . create ( getDegreeTable ( ) ) ; tableOperations . create ( getMetadataTable ( ) ) ; tableOperations . create ( getTextTable ( ) ) ; IteratorSetting degreeIteratorSetting = new IteratorSetting ( 7 , SummingCombiner . class ) ; SummingCombiner . setEncodingType ( degreeIteratorSetting , LongCombiner . Type . STRING ) ; SummingCombiner . setColumns ( degreeIteratorSetting , Collections . singletonList ( new IteratorSetting . Column ( "" , "degree" ) ) ) ; tableOperations . attachIterator ( getDegreeTable ( ) , degreeIteratorSetting ) ; IteratorSetting fieldIteratorSetting = new IteratorSetting ( 7 , SummingCombiner . class ) ; SummingCombiner . setEncodingType ( fieldIteratorSetting , LongCombiner . Type . STRING ) ; SummingCombiner . setColumns ( fieldIteratorSetting , Collections . singletonList ( new IteratorSetting . Column ( "field" , "" ) ) ) ; tableOperations . attachIterator ( getMetadataTable ( ) , fieldIteratorSetting ) ; Mutation mutation = new Mutation ( PROPERTY ) ; mutation . put ( FIELD_DELIMITER_PROPERTY_NAME , EMPTY_CQ , defaultFieldDelimiter ) ; mutation . put ( FACT_DELIMITER_PROPERTY_NAME , EMPTY_CQ , defaultFactDelimiter ) ; BatchWriterConfig bwConfig = new BatchWriterConfig ( ) ; bwConfig . setMaxLatency ( 10000 , TimeUnit . MINUTES ) ; bwConfig . setMaxMemory ( 10000000 ) ; bwConfig . setMaxWriteThreads ( 5 ) ; bwConfig . setTimeout ( 5 , TimeUnit . MINUTES ) ; BatchWriter writer = connector . createBatchWriter ( getMetadataTable ( ) , bwConfig ) ; writer . addMutation ( mutation ) ; writer . close ( ) ; } catch ( AccumuloException | AccumuloSecurityException | TableExistsException | TableNotFoundException e ) { throw new D4MException ( "Error creating tables." , e ) ; } } | Create D4M tables . |
29,317 | private void executeCommand ( File newFile , List < String > processParams ) throws IOException { long startTime = System . currentTimeMillis ( ) ; if ( newFile . exists ( ) ) { LOG . debug ( "{} already exists. Trying to delete." , newFile ) ; newFile . delete ( ) ; } if ( ! newFile . getParentFile ( ) . exists ( ) ) { boolean dirsCreated = newFile . getParentFile ( ) . mkdirs ( ) ; if ( ! dirsCreated ) { String errorMessage = String . format ( "Could not create all dirs for %s" , newFile ) ; LOG . error ( errorMessage ) ; throw new IOException ( errorMessage ) ; } } ProcessBuilder pb = new ProcessBuilder ( processParams ) ; Process pr = null ; Thread currentThread = Thread . currentThread ( ) ; try { LOG . debug ( "Adding current thread: {}" , currentThread ) ; registerThread ( currentThread ) ; if ( StringUtils . isNotBlank ( externalProcessErrorLogFile ) ) { LOG . debug ( "Will log external process error output to {}" , externalProcessErrorLogFile ) ; pb . redirectError ( ProcessBuilder . Redirect . appendTo ( new File ( externalProcessErrorLogFile ) ) ) ; } else { pb . redirectError ( ProcessBuilder . Redirect . DISCARD ) ; } pb . redirectOutput ( ProcessBuilder . Redirect . DISCARD ) ; pr = pb . start ( ) ; boolean waitResult = pr . waitFor ( maxWaitTimeSeconds , TimeUnit . SECONDS ) ; if ( ! waitResult ) { String errorMessage = String . format ( "Waiting for video conversion exceeded maximum threshold of %s seconds" , maxWaitTimeSeconds ) ; LOG . error ( errorMessage ) ; cleanupFailure ( pr , newFile ) ; throw new IOException ( errorMessage ) ; } if ( pr . exitValue ( ) != 0 ) { String errorMessage = String . format ( "Error when generating new file %s. Cleaning up." , newFile . getCanonicalPath ( ) ) ; LOG . error ( errorMessage ) ; cleanupFailure ( pr , newFile ) ; throw new IOException ( errorMessage ) ; } long duration = System . currentTimeMillis ( ) - startTime ; LOG . debug ( "Time in milliseconds to generate {}: {}" , newFile . toString ( ) , duration ) ; } catch ( InterruptedException ie ) { cleanupFailure ( pr , newFile ) ; LOG . error ( "Was interrupted while waiting for conversion. Throwing IOException" ) ; throw new IOException ( ie ) ; } finally { unregisterThread ( currentThread ) ; } } | Executes a command . The actual command has already been configured and is passed via the processParams parameter . These will be passed to a |
29,318 | public static ToIntFunction < IntTuple > lexicographicalIndexer ( IntTuple size ) { Objects . requireNonNull ( size , "The size is null" ) ; IntTuple reversedProducts = IntTupleFunctions . exclusiveScan ( IntTuples . reversed ( size ) , 1 , ( a , b ) -> a * b , null ) ; IntTuple sizeProducts = IntTuples . reverse ( reversedProducts , null ) ; return indices -> IntTuples . dot ( indices , sizeProducts ) ; } | Creates a function that maps multidimensional indices to 1D indices . The function will create consecutive 1D indices for indices that are given in lexicographical order . |
29,319 | public static ToIntFunction < IntTuple > colexicographicalIndexer ( IntTuple size ) { Objects . requireNonNull ( size , "The size is null" ) ; IntTuple sizeProducts = IntTupleFunctions . exclusiveScan ( size , 1 , ( a , b ) -> a * b , null ) ; return indices -> IntTuples . dot ( indices , sizeProducts ) ; } | Creates a function that maps multidimensional indices to 1D indices . The function will create consecutive 1D indices for indices that are given in colexicographical order . |
29,320 | public Simulation create ( ) { if ( tickCount == null ) throw new IllegalStateException ( "tick count not set" ) ; return new SimulationImpl ( tickCount , phases , members , series , services ) ; } | Creates a simulation with the defined parameters . |
29,321 | private static Class < ? > findClass ( String name ) throws LauncherException { for ( ClassLoader clsLoader : new ClassLoader [ ] { Thread . currentThread ( ) . getContextClassLoader ( ) , CLASS . getClassLoader ( ) } ) try { return clsLoader . loadClass ( name ) ; } catch ( ClassNotFoundException ignored ) { logger . debug ( "Ignoring ClassNotFound exception looking for class." , ignored ) ; } throw new LauncherException ( "Unable to find class " + name + " via either the thread context class loader nor our own class loader." ) ; } | Tries to find a class by name using the thread context class loader and this class s class loader . |
29,322 | public static Process getProcess ( String mainClass , String ... args ) throws LauncherException , IOException { return getProcessBuilder ( mainClass , args ) . start ( ) ; } | Get a process for a JVM . The class path for the JVM is computed based on the class loaders for the main class . |
29,323 | public String toJSON ( ) { StringBuilder buffer = new StringBuilder ( ) ; buffer . append ( "{\n" ) ; buffer . append ( "\tfile: \'" ) . append ( file . getAbsolutePath ( ) ) . append ( "',\n" ) ; buffer . append ( "\tformat: \'" ) . append ( format ) . append ( "',\n" ) ; buffer . append ( "\taddressing: \'" ) . append ( addressing ) . append ( "',\n" ) ; buffer . append ( "\tendianness: \'" ) . append ( endianness ) . append ( "',\n" ) ; buffer . append ( "\toperatingSystem: \'" ) . append ( operatingSystem ) . append ( "',\n" ) ; buffer . append ( "\ttype: \'" ) . append ( type ) . append ( "',\n" ) ; buffer . append ( "\tinstructionSet: \'" ) . append ( instructionSet ) . append ( "'\n" ) ; buffer . append ( "}" ) ; return buffer . toString ( ) ; } | Returns a JSON representation of the object . |
29,324 | public static boolean isPublicAddress ( final InetAddress ia ) { return ! ia . isSiteLocalAddress ( ) && ! ia . isLinkLocalAddress ( ) && ! ia . isAnyLocalAddress ( ) && ! ia . isLoopbackAddress ( ) && ! ia . isMulticastAddress ( ) ; } | Returns whether or not the specified address represents an address on the public Internet . |
29,325 | public static Collection < InetAddress > getNetworkInterfaces ( ) throws SocketException { final Collection < InetAddress > addresses = new ArrayList < InetAddress > ( ) ; final Enumeration < NetworkInterface > e = NetworkInterface . getNetworkInterfaces ( ) ; while ( e . hasMoreElements ( ) ) { final NetworkInterface ni = e . nextElement ( ) ; final Enumeration < InetAddress > niAddresses = ni . getInetAddresses ( ) ; while ( niAddresses . hasMoreElements ( ) ) { addresses . add ( niAddresses . nextElement ( ) ) ; } } return addresses ; } | Utility method for accessing public interfaces . |
29,326 | public AttributeType getTagAttribute ( ) { if ( tagAttributeType == null ) { synchronized ( this ) { if ( tagAttributeType == null ) { String attribute = Config . get ( typeName , name ( ) , "tag" ) . asString ( ) ; if ( StringUtils . isNullOrBlank ( attribute ) && ! AnnotationType . ROOT . equals ( getParent ( ) ) ) { tagAttributeType = getParent ( ) . getTagAttribute ( ) ; } else if ( StringUtils . isNullOrBlank ( attribute ) ) { tagAttributeType = Types . TAG ; } else { tagAttributeType = AttributeType . create ( attribute ) ; } } } } return tagAttributeType ; } | Gets the attribute associated with the tag of this annotation . |
29,327 | public Annotation floor ( Annotation annotation , AnnotationType type ) { if ( annotation == null || type == null ) { return Fragments . detachedEmptyAnnotation ( ) ; } for ( Annotation a : Collect . asIterable ( new NodeIterator ( root , - 1 , annotation . start ( ) , type , false ) ) ) { if ( a . isInstance ( type ) && a != annotation ) { return a ; } } return Fragments . detachedEmptyAnnotation ( ) ; } | Floor annotation . |
29,328 | public Annotation ceiling ( Annotation annotation , AnnotationType type ) { if ( annotation == null || type == null ) { return Fragments . detachedEmptyAnnotation ( ) ; } for ( Annotation a : Collect . asIterable ( new NodeIterator ( root , annotation . end ( ) , Integer . MAX_VALUE , type , true ) ) ) { if ( a . isInstance ( type ) && a != annotation ) { return a ; } } return Fragments . detachedEmptyAnnotation ( ) ; } | Ceiling annotation . |
29,329 | public static void clear ( ) { lock . writeLock ( ) . lock ( ) ; try { allStrings = new EfficientStringBiMap ( HASH_MODULO ) ; indexCounter . set ( 0 ) ; } finally { lock . writeLock ( ) . unlock ( ) ; } } | Clears the registry of existing Strings and resets the index to 0 . Use this to free up memory . |
29,330 | public static void setDefaultEnvironment ( String environment ) { System . setProperty ( "pelzer.environment" , environment ) ; Logging . getLogger ( EnvironmentManager . class ) ; PropertyManager . setDefaultEnvironment ( environment ) ; } | Overrides and resets the PropertyManager to a new environment . |
29,331 | public void handleNotification ( Notification notification , Object handback ) { try { method . invoke ( target , notification , handback ) ; } catch ( Exception e ) { LOG . error ( "Could not invoke MessageListener method " + method + " on " + target , e ) ; } } | Invokes the registered method on the target object . |
29,332 | public static < T > Function < T , Void > addTo ( final Collection < T > collection ) { return new Function < T , Void > ( ) { public Void apply ( T arg ) { collection . add ( arg ) ; return null ; } } ; } | Returns a function that adds its argument to the given collection . |
29,333 | public static < T , K > Function < T , Void > addTo ( final Map < K , T > map , final Function < ? super T , ? extends K > keyMaker ) { return new Function < T , Void > ( ) { public Void apply ( T arg ) { map . put ( keyMaker . apply ( arg ) , arg ) ; return null ; } } ; } | Returns a function that adds its argument to a map using a supplied function to determine the key . |
29,334 | protected static String parameterize ( String config , ConfigParams parameters ) throws IOException { if ( parameters == null ) { return config ; } Handlebars handlebars = new Handlebars ( ) ; Template template = handlebars . compileInline ( config ) ; return template . apply ( parameters ) ; } | Parameterized configuration template given as string with dynamic parameters . |
29,335 | @ SuppressWarnings ( "unchecked" ) public static DataProviderFactory create ( final Object ... args ) { final Class < ? extends DataProviderFactory > dataProviderClass = findDataProviderImpl ( ) ; final DataProviderFactory factory ; try { Constructor < ? extends DataProviderFactory > dataProviderConstructor = null ; final Constructor [ ] constructors = dataProviderClass . getDeclaredConstructors ( ) ; for ( final Constructor constructor : constructors ) { final Class < ? > [ ] params = constructor . getParameterTypes ( ) ; boolean matches = false ; if ( args . length == params . length ) { matches = true ; for ( int i = 0 ; i < params . length ; i ++ ) { if ( ! params [ i ] . isAssignableFrom ( args [ i ] . getClass ( ) ) ) { matches = false ; } } } if ( matches ) { dataProviderConstructor = constructor ; break ; } } if ( dataProviderConstructor != null ) { factory = dataProviderConstructor . newInstance ( args ) ; } else { factory = null ; } } catch ( Exception e ) { throw new RuntimeException ( e ) ; } return factory ; } | Initialise the Data Provider Factory with the required data . |
29,336 | public void put ( DajlabModelInterface model ) { if ( model != null ) { String name = model . getClass ( ) . getName ( ) ; dajlab . put ( name , model ) ; } } | Add a model to the map . |
29,337 | public < T extends DajlabModelInterface > T get ( Class < T > clazz ) { T ret = null ; try { ret = ( T ) dajlab . get ( clazz . getName ( ) ) ; } catch ( ClassCastException e ) { e . printStackTrace ( ) ; } return ret ; } | Get a model from the map using the class . |
29,338 | public void registerFileDir ( Path dir , String fileType , ReloadableFile reloadableFile ) throws IOException { WatchKey key = dir . register ( watcher , ENTRY_MODIFY ) ; List < FileInfo > fileInfos = addOnMap . get ( key ) ; if ( fileInfos != null ) { fileInfos . add ( new FileInfo ( dir , fileType , reloadableFile ) ) ; } else { fileInfos = new ArrayList < > ( ) ; fileInfos . add ( new FileInfo ( dir , fileType , reloadableFile ) ) ; addOnMap . put ( key , fileInfos ) ; } } | Use this method to register a file with the watcherService |
29,339 | private boolean isFileType ( WatchEvent event , String fileType ) { return event . context ( ) . toString ( ) . contains ( fileType ) ; } | Checks if an event belongs to the desired file type |
29,340 | public void run ( ) { while ( true ) { WatchKey key ; try { key = watcher . take ( ) ; } catch ( InterruptedException e ) { log . warn ( e ) ; continue ; } List < FileInfo > fileInfos = addOnMap . get ( key ) ; checkAndProcessFileInfo ( key , fileInfos ) ; boolean valid = key . reset ( ) ; if ( ! valid ) { addOnMap . remove ( key ) ; if ( addOnMap . isEmpty ( ) ) { break ; } } } } | Main method of fileManager it constantly waits for new events and then processes them |
29,341 | public static < F , S > Failure < F , S > failure ( final F x ) { return new Failure < F , S > ( x ) ; } | Produce a new failure value . |
29,342 | public CommunicationServiceBuilder limit ( String socketName , Integer uplinkRate , Integer downlinkRate ) { checkUncreated ( ) ; this . uplink . put ( socketName , uplinkRate ) ; this . downlink . put ( socketName , downlinkRate ) ; return this ; } | Limits the given socket name to the given uplink and downlink byte rates . |
29,343 | public CommunicationServiceBuilder limit ( String socketName , Integer rate ) { return limit ( socketName , rate , rate ) ; } | Limits the given socket name to the given byte rates both uplink and downlink . |
29,344 | public CommunicationServiceBuilder delay ( String socketName , Long updelay , Long downdelay ) { checkUncreated ( ) ; this . updelay . put ( socketName , updelay ) ; this . downdelay . put ( socketName , downdelay ) ; return this ; } | Adds a delay to the given socket . |
29,345 | public CommunicationServiceBuilder delay ( String socketName , Long delay ) { return delay ( socketName , delay , delay ) ; } | Adds a delay to the given socket both uplink and downlink . |
29,346 | public FulltextMatch setProperties ( final Collection < String > properties ) { if ( properties == null || properties . size ( ) == 0 ) { clearProperties ( ) ; return this ; } synchronized ( properties ) { for ( String binding : properties ) { if ( binding == null ) { throw new IllegalArgumentException ( "null element" ) ; } } clearProperties ( ) ; for ( String property : properties ) { addProperty ( property ) ; } } return this ; } | Sets the properties . First the previous elements are cleared and all of the specified properties are appended . The properties are appended in the array order . |
29,347 | public FulltextMatch addProperty ( final String property ) { if ( property == null ) { throw new IllegalArgumentException ( "no property specified" ) ; } _properties . add ( property ) ; return this ; } | Appends the specified property . |
29,348 | public FulltextMatch setPatterns ( final Collection < String > patterns ) { if ( patterns == null || patterns . size ( ) == 0 ) { clearPatterns ( ) ; return this ; } synchronized ( patterns ) { for ( String pattern : patterns ) { if ( pattern == null || pattern . length ( ) == 0 ) { throw new IllegalArgumentException ( "null element" ) ; } } clearPatterns ( ) ; for ( String pattern : patterns ) { addPattern ( pattern ) ; } } return this ; } | Sets the matching patterns . |
29,349 | public FulltextMatch addPattern ( final String pattern ) { if ( pattern == null || pattern . length ( ) == 0 ) { throw new IllegalArgumentException ( "no pattern specified" ) ; } _patterns . add ( pattern ) ; return this ; } | Appends the specified matching pattern . |
29,350 | public boolean isEmpty ( ) throws IOException { Closer closer = Closer . create ( ) ; try { Reader reader = closer . register ( openStream ( ) ) ; return reader . read ( ) == - 1 ; } catch ( Throwable e ) { throw closer . rethrow ( e ) ; } finally { closer . close ( ) ; } } | Returns whether the source has zero chars . The default implementation is to open a stream and check for EOF . |
29,351 | public void destroySession ( ) { if ( entryPoint != null ) { entryPoint . onSessionDestruction ( this , session ) ; } if ( accessManager != null ) { accessManager . destroyCurrentSession ( ) ; } session = null ; } | Destroys current session . |
29,352 | public void setAttribute ( Object key , Object value ) { if ( attributes == null ) { attributes = new HashMap ( 5 ) ; } attributes . put ( key , value ) ; } | Stores object during the lifespan of the request . Use with care . |
29,353 | public User login ( Credentials credentials ) throws AuthenticationException { User user = getSession ( true ) . login ( credentials ) ; entryPoint . onSessionUpdate ( this , session ) ; return user ; } | Tries to perform login on entry realm . Creates session if necessary . |
29,354 | public Session resolveSession ( String sessionToken , String userId ) { this . sessionToken = sessionToken ; this . userId = userId ; if ( accessManager != null ) { this . session = accessManager . getSessionByToken ( sessionToken ) ; } return session ; } | Tries to get a reference to the session identified by sessionToken |
29,355 | static SecurityBreachHandler createBreachHandler ( Main main , SystemMail systemMail , String toAddress ) throws IllegalAccessException { if ( ! exists ) { SecurityBreachHandler breachHandler = new SecurityBreachHandler ( main , systemMail , toAddress ) ; exists = true ; return breachHandler ; } throw new IllegalAccessException ( "Cannot create more than one instance of SecurityBreachHandler" ) ; } | Creates a SecurityBreachHandler . There can only be one single SecurityBreachHandler so calling this method twice will cause an illegal access exception . |
29,356 | public JmxTree filterTree ( JmxTree tree , String filter , boolean includeChildren ) { String nameFilter = filter . trim ( ) . toLowerCase ( ) ; Set < DomainNode > domainNodes = new TreeSet < DomainNode > ( ) ; for ( JmxTreeNode domain : tree . getRoot ( ) . getChildren ( ) ) { Set < ObjectNode > objectNodes = new TreeSet < ObjectNode > ( ) ; for ( JmxTreeNode object : domain . getChildren ( ) ) { ObjectNode objectNode = ( ObjectNode ) object ; if ( objectNode . getObjectName ( ) . getCanonicalName ( ) . toLowerCase ( ) . contains ( nameFilter ) ) { if ( includeChildren ) { Set < JmxTreeNode > objectChildren = getMatchingChildren ( nameFilter , objectNode ) ; ObjectNode newNode = new ObjectNode ( objectNode , replaceMatch ( objectNode . getLabel ( ) , nameFilter ) , objectChildren ) ; newNode . setExpand ( true ) ; objectNodes . add ( newNode ) ; } else { objectNodes . add ( new ObjectNode ( objectNode , replaceMatch ( objectNode . getLabel ( ) , nameFilter ) ) ) ; } } else if ( includeChildren ) { addObjectNodeChildMatch ( nameFilter , objectNode , objectNodes ) ; } } if ( ! objectNodes . isEmpty ( ) ) { DomainNode domainNode = new DomainNode ( domain . getLabel ( ) , objectNodes ) ; domainNode . setExpand ( true ) ; domainNodes . add ( domainNode ) ; } } RootNode root = new RootNode ( LABEL_DOMAINS , domainNodes ) ; JmxTree jmxTree = new JmxTree ( root ) ; return jmxTree ; } | Returns a filtered tree from the supplied tree . |
29,357 | private Set < JmxTreeNode > getMatchingChildren ( String nameFilter , ObjectNode objectNode ) { AttributesNode attributesNode = null ; OperationsNode operationsNode = null ; NotificationsNode notificationsNode = null ; Set < JmxTreeNode > objectChildren = new TreeSet < JmxTreeNode > ( ) ; for ( JmxTreeNode child : objectNode . getChildren ( ) ) { if ( child instanceof AttributesNode ) { Set < AttributeNode > attributes = getMatchingAttributes ( ( AttributesNode ) child , nameFilter ) ; if ( ! attributes . isEmpty ( ) ) { attributesNode = new AttributesNode ( ObjectNode . LABEL_ATTRIBUTES , attributes ) ; } } else if ( child instanceof OperationsNode ) { Set < OperationNode > operations = getMatchingOperations ( ( OperationsNode ) child , nameFilter ) ; if ( ! operations . isEmpty ( ) ) { operationsNode = new OperationsNode ( ObjectNode . LABEL_OPERATIONS , operations ) ; } } else if ( child instanceof NotificationsNode ) { Set < NotificationNode > notifications = getMatchingNotifications ( ( NotificationsNode ) child , nameFilter ) ; if ( ! notifications . isEmpty ( ) ) { notificationsNode = new NotificationsNode ( ObjectNode . LABEL_NOTIFICATIONS , notifications ) ; } } } if ( attributesNode != null ) { objectChildren . add ( attributesNode ) ; } if ( operationsNode != null ) { objectChildren . add ( operationsNode ) ; } if ( notificationsNode != null ) { objectChildren . add ( notificationsNode ) ; } return objectChildren ; } | Returns the matching child nodes of a ManagedObject . |
29,358 | private static void logHeader ( Status original ) { long id = original . getId ( ) ; String user = original . getUser ( ) . getScreenName ( ) ; String message = String . format ( MESSAGE_HEADER , id , user ) ; System . out . println ( message ) ; } | Prints a message header |
29,359 | private static void logOriginal ( Status original ) { String text = original . getText ( ) ; String message = String . format ( MESSAGE_ORIGINAL , text ) ; System . out . println ( message ) ; } | Prints an original tweet |
29,360 | private static void logResponse ( StatusUpdate response ) { String text = response . getStatus ( ) ; String message = String . format ( MESSAGE_RESPONSE , text ) ; System . out . println ( message ) ; } | Prints a response tweet |
29,361 | public JSONObject invokeJson ( ) throws InternalException , CloudException { ClientAndResponse clientAndResponse = null ; String content ; try { clientAndResponse = invokeInternal ( ) ; Header contentType = clientAndResponse . response . getFirstHeader ( "content-type" ) ; if ( ! "application/json" . equalsIgnoreCase ( contentType . getValue ( ) ) ) { throw new CloudException ( "Invalid Glacier response: expected JSON" ) ; } final HttpEntity entity = clientAndResponse . response . getEntity ( ) ; content = EntityUtils . toString ( entity ) ; if ( content == null ) { return null ; } return new JSONObject ( content ) ; } catch ( IOException e ) { throw new CloudException ( e ) ; } catch ( JSONException e ) { throw new CloudException ( e ) ; } finally { if ( clientAndResponse != null ) { clientAndResponse . client . getConnectionManager ( ) . shutdown ( ) ; } } } | Invokes the method and returns the response body as a JSON object |
29,362 | public Map < String , String > invokeHeaders ( ) throws InternalException , CloudException { ClientAndResponse clientAndResponse = invokeInternal ( ) ; try { Map < String , String > headers = new HashMap < String , String > ( ) ; for ( Header header : clientAndResponse . response . getAllHeaders ( ) ) { headers . put ( header . getName ( ) . toLowerCase ( ) , header . getValue ( ) ) ; } return headers ; } finally { clientAndResponse . client . getConnectionManager ( ) . shutdown ( ) ; } } | Invokes the method and returns the response headers |
29,363 | public void invoke ( ) throws InternalException , CloudException { final ClientAndResponse clientAndResponse = invokeInternal ( ) ; clientAndResponse . client . getConnectionManager ( ) . shutdown ( ) ; } | Invokes the method and returns nothing |
29,364 | public Object getRoot ( ) { Chain current = this ; while ( current . hasParent ( ) ) { current = current . getParent ( ) ; } return current . getValue ( ) ; } | Returns the root object of this chain . |
29,365 | public void notifyStart ( String projectName , String projectVersion , String category ) { try { if ( isStarted ( ) ) { JSONObject startNotification = new JSONObject ( ) . put ( "project" , new JSONObject ( ) . put ( "name" , projectName ) . put ( "version" , projectVersion ) ) . put ( "category" , category ) ; socket . emit ( "run:start" , startNotification ) ; } else { LOGGER . warn ( "Minirox is not available to send the start notification" ) ; } } catch ( Exception e ) { LOGGER . info ( "Unable to send the start notification to MINI ROX. Cause: {}" , e . getMessage ( ) ) ; if ( LOGGER . isDebugEnabled ( ) ) { LOGGER . debug ( "Exception: " , e ) ; } } } | Send a starting notification to Mini ROX |
29,366 | public void notifyEnd ( String projectName , String projectVersion , String category , long duration ) { try { if ( isStarted ( ) ) { JSONObject endNotification = new JSONObject ( ) . put ( "project" , new JSONObject ( ) . put ( "name" , projectName ) . put ( "version" , projectVersion ) ) . put ( "category" , category ) . put ( "duration" , duration ) ; socket . emit ( "run:end" , endNotification ) ; } else { LOGGER . warn ( "Minirox is not available to send the end notification" ) ; } } catch ( Exception e ) { LOGGER . info ( "Unable to send the end notification to MINI ROX. Cause: {}" , e . getMessage ( ) ) ; if ( LOGGER . isDebugEnabled ( ) ) { LOGGER . debug ( "Exception: " , e ) ; } } } | Send a ending notification to Mini ROX |
29,367 | public void send ( RoxPayload payload ) { try { if ( isStarted ( ) ) { ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; new JsonSerializer ( ) . serializePayload ( new OutputStreamWriter ( baos ) , payload , false ) ; socket . emit ( "payload" , new String ( baos . toByteArray ( ) ) ) ; } else { LOGGER . warn ( "Minirox is not available to send the test results" ) ; } } catch ( Exception e ) { LOGGER . warn ( "Unable to send the result to MINI ROX. Cause: {}" , e . getMessage ( ) ) ; if ( LOGGER . isDebugEnabled ( ) ) { LOGGER . debug ( "Exception: " , e ) ; } } } | Send a payload to the MINI ROX . This is a best effort and when the request failed there is no crash |
29,368 | public String [ ] getFilters ( ) { try { if ( isStarted ( ) ) { final MiniRoxFilterAcknowledger acknowledger = new MiniRoxFilterAcknowledger ( ) ; new Thread ( new Runnable ( ) { public void run ( ) { try { LOGGER . trace ( "Retrieve filters" ) ; socket . emit ( "filters:get" , acknowledger ) ; } catch ( Exception e ) { LOGGER . warn ( "Unable to get the filters: {}" , e . getMessage ( ) ) ; synchronized ( acknowledger ) { acknowledger . notify ( ) ; } } } } ) . start ( ) ; synchronized ( acknowledger ) { acknowledger . wait ( ) ; } if ( ! acknowledger . isFilters ( ) ) { for ( String filter : acknowledger . getFilters ( ) ) { LOGGER . info ( "Filter element: {}" , filter ) ; } } return acknowledger . getFilters ( ) ; } } catch ( Exception e ) { LOGGER . warn ( "Unable to retrieve the filters from MINI ROX. Cause: {}" , e . getMessage ( ) ) ; if ( LOGGER . isDebugEnabled ( ) ) { LOGGER . debug ( "Exception: " , e ) ; } } return null ; } | Try to get a filter list from MINI ROX |
29,369 | private Socket createConnectedSocket ( final String miniRoxUrl ) { try { final Socket initSocket = IO . socket ( miniRoxUrl ) ; final MiniRoxCallback callback = new MiniRoxCallback ( ) ; initSocket . on ( Socket . EVENT_CONNECT , callback ) ; initSocket . on ( Socket . EVENT_CONNECT_ERROR , callback ) ; initSocket . on ( Socket . EVENT_CONNECT_TIMEOUT , callback ) ; initSocket . on ( Socket . EVENT_CONNECT_ERROR , callback ) ; initSocket . on ( Socket . EVENT_DISCONNECT , callback ) ; initSocket . on ( Socket . EVENT_ERROR , callback ) ; LOGGER . trace ( "Connection to minirox" ) ; new Thread ( new Runnable ( ) { public void run ( ) { initSocket . connect ( ) ; } } ) . start ( ) ; synchronized ( callback ) { callback . wait ( ) ; } if ( ! initSocket . connected ( ) ) { LOGGER . warn ( "Minirox is not available" ) ; return null ; } return initSocket ; } catch ( URISyntaxException | InterruptedException e ) { LOGGER . warn ( "Unknown error" , e ) ; } return null ; } | Create a new connection to MiniROX |
29,370 | public static Map < String , Object > get ( CollectionId c , Map < String , Object > search ) throws NotFoundException , MoreThanOneFoundException { ensureOnlyOne ( c , search ) ; DBCollection coll = MongoDBConnectionHelper . getConnection ( c . getDatabase ( ) ) . getCollection ( c . getCollection ( ) ) ; Map < String , Object > m = MongoDBFormat . toMap ( coll . findOne ( MongoDBFormat . fromMap ( search ) ) ) ; if ( LOG . isDebugEnabled ( ) ) LOG . debug ( "MongoDB get result (" + c + ", search:" + search + "\n\t> " + m ) ; return m ; } | Select exactly one record from collection |
29,371 | protected Violation createViolation ( HtmlElement htmlElement , Page page , String message ) { if ( htmlElement == null ) htmlElement = page . findHtmlTag ( ) ; return new Violation ( this , htmlElement , message ) ; } | Creates a new violation for that rule with the line number of the violating element in the given page and a message that describes the violation in detail . |
29,372 | String getWhereClause ( ) { final StringGrabber sgWhere = new StringGrabber ( ) ; List < Field > primaryKeyFieldList = getPrimaryKeyFieldList ( ) ; if ( primaryKeyFieldList . size ( ) > 0 ) { sgWhere . append ( "WHERE " ) ; for ( Field field : primaryKeyFieldList ) { DBColumn dbColumn = field . getAnnotation ( DBColumn . class ) ; sgWhere . append ( dbColumn . columnName ( ) ) ; sgWhere . append ( " = ? AND " ) ; } sgWhere . removeTail ( 5 ) ; } return sgWhere . toString ( ) ; } | generate where clause of current model class |
29,373 | public void attach ( ElementHandler < T > handler ) { NodeState < T > state = buildState ( ) ; context . addElementHandler ( state , handler ) ; } | Attach an ElementHandler to this selector or chain of selectors . The attached handler will receive notifications for every selected element . |
29,374 | public static < I , O > Iterable < O > map ( Iterable < I > it , Processor < I , O > processor ) { return new ProcessingIterable < I , O > ( it . iterator ( ) , processor ) ; } | Implement a map operation that applies a processor to each element in the wrapped iterator and iterates over the resulting output . |
29,375 | public static < I , S , O > Processor < I , O > compose ( final Processor < I , S > first , final Processor < S , O > last , final Processor < O , O > ... extraSteps ) { return new Processor < I , O > ( ) { public O process ( I input ) { O result = last . process ( first . process ( input ) ) ; for ( Processor < O , O > processor : extraSteps ) { result = processor . process ( result ) ; } return result ; } } ; } | Compose two or more processors into one . |
29,376 | public static < T > Iterable < T > compose ( final Iterable < Iterable < T > > iterables ) { return toIterable ( new Iterator < T > ( ) { Iterator < Iterable < T > > it = iterables . iterator ( ) ; Iterator < T > current = null ; T next = null ; public boolean hasNext ( ) { if ( next != null ) { return true ; } else { if ( ( current == null || ! current . hasNext ( ) ) && it . hasNext ( ) ) { while ( it . hasNext ( ) && ( current == null || ! current . hasNext ( ) ) ) { Iterable < T > nextIt = it . next ( ) ; if ( nextIt != null ) { current = nextIt . iterator ( ) ; } } } if ( current != null && current . hasNext ( ) ) { next = current . next ( ) ; return true ; } } return false ; } public T next ( ) { if ( hasNext ( ) ) { T result = next ; next = null ; return result ; } else { throw new NoSuchElementException ( ) ; } } public void remove ( ) { throw new UnsupportedOperationException ( "Remove is not supported" ) ; } } ) ; } | Given a number of iterables construct a iterable that iterates all of the iterables . |
29,377 | public static < I , O > Iterable < O > castingIterable ( Iterable < I > it , Class < O > clazz ) { return map ( it , new Processor < I , O > ( ) { @ SuppressWarnings ( "unchecked" ) public O process ( I input ) { return ( O ) input ; } } ) ; } | Allows you to iterate over objects and cast them to the appropriate type on the fly . |
29,378 | public static < T > T copy ( T orig ) { if ( orig == null ) return null ; try { ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; ObjectOutputStream oos = new ObjectOutputStream ( bos ) ; oos . writeObject ( orig ) ; oos . flush ( ) ; ByteArrayInputStream bin = new ByteArrayInputStream ( bos . toByteArray ( ) ) ; ObjectInputStream ois = new ObjectInputStream ( bin ) ; return ( T ) ois . readObject ( ) ; } catch ( Exception e ) { throw S1SystemError . wrap ( e ) ; } } | Copy object deeply |
29,379 | public static boolean isNullOrEmpty ( Object obj ) { if ( obj == null ) return true ; if ( obj instanceof String ) { return ( ( ( String ) obj ) . isEmpty ( ) ) ; } if ( obj instanceof Map ) { return ( ( Map ) obj ) . isEmpty ( ) ; } if ( obj instanceof List ) { return ( ( List ) obj ) . isEmpty ( ) ; } if ( obj instanceof Set ) { return ( ( Set ) obj ) . isEmpty ( ) ; } return false ; } | Returns true if object is null or empty |
29,380 | public static < T > T cast ( Object obj , String type ) { return ( T ) cast ( obj , resolveType ( type ) ) ; } | Resolves type and returns casted object |
29,381 | RuleReturnScope invoke ( Parser parser ) throws Exception { assert parser != null ; return ( RuleReturnScope ) method . invoke ( parser , arguments ) ; } | Invoke the selected parser method with its arguments |
29,382 | RuleReturnScope invoke ( TreeParser treeParser ) throws Exception { assert treeParser != null ; return ( RuleReturnScope ) method . invoke ( treeParser , arguments ) ; } | Invoke the selected tree parser method with its arguments |
29,383 | public ArchiveService createArchiveService ( final String endpointUrl ) { return new RestAdapter . Builder ( ) . setEndpoint ( endpointUrl ) . setErrorHandler ( errorHandler ) . setConverter ( new JacksonArchivedSequenceConverter ( jsonFactory ) ) . build ( ) . create ( ArchiveService . class ) ; } | Create and return a new archive service with the specified endpoint URL . |
29,384 | public VariationService createVariationService ( final String endpointUrl ) { return new RestAdapter . Builder ( ) . setEndpoint ( endpointUrl ) . setErrorHandler ( errorHandler ) . setConverter ( new JacksonVariationConverter ( jsonFactory ) ) . build ( ) . create ( VariationService . class ) ; } | Create and return a new variation service with the specified endpoint URL . |
29,385 | public SequenceService createSequenceService ( final String endpointUrl ) { return new RestAdapter . Builder ( ) . setEndpoint ( endpointUrl ) . setErrorHandler ( errorHandler ) . setConverter ( new JacksonSequenceConverter ( jsonFactory ) ) . build ( ) . create ( SequenceService . class ) ; } | Create and return a new sequence service with the specified endpoint URL . |
29,386 | public static String crypt ( String strpw , String strsalt ) { char [ ] pw = strpw . toCharArray ( ) ; char [ ] salt = strsalt . toCharArray ( ) ; byte [ ] pwb = new byte [ 66 ] ; char [ ] result = new char [ 13 ] ; byte [ ] new_etr = new byte [ etr . length ] ; int n = 0 ; int m = 0 ; while ( m < pw . length && n < 64 ) { for ( int j = 6 ; j >= 0 ; j -- ) { pwb [ n ++ ] = ( byte ) ( ( pw [ m ] >> j ) & 1 ) ; } m ++ ; pwb [ n ++ ] = 0 ; } while ( n < 64 ) { pwb [ n ++ ] = 0 ; } definekey ( pwb ) ; for ( n = 0 ; n < 66 ; n ++ ) { pwb [ n ] = 0 ; } System . arraycopy ( etr , 0 , new_etr , 0 , new_etr . length ) ; EP = new_etr ; for ( int i = 0 ; i < 2 ; i ++ ) { char c = salt [ i ] ; result [ i ] = c ; if ( c > 'Z' ) { c -= 6 + 7 + '.' ; } else if ( c > '9' ) { c -= 7 + '.' ; } else { c -= '.' ; } for ( int j = 0 ; j < 6 ; j ++ ) { if ( ( ( c >> j ) & 1 ) == 1 ) { byte t = ( byte ) ( 6 * i + j ) ; byte temp = new_etr [ t ] ; new_etr [ t ] = new_etr [ t + 24 ] ; new_etr [ t + 24 ] = temp ; } } } if ( result [ 1 ] == 0 ) { result [ 1 ] = result [ 0 ] ; } for ( int i = 0 ; i < 25 ; i ++ ) { encrypt ( pwb , 0 ) ; } EP = etr ; m = 2 ; n = 0 ; while ( n < 66 ) { int c = 0 ; for ( int j = 6 ; j > 0 ; j -- ) { c <<= 1 ; c |= pwb [ n ++ ] ; } c += '.' ; if ( c > '9' ) { c += 7 ; } if ( c > 'Z' ) { c += 6 ; } result [ m ++ ] = ( char ) c ; } return ( new String ( result ) ) ; } | Returns a String containing the encrypted passwd |
29,387 | public void setValue ( int value ) { if ( value < min || value > max ) { throw new IllegalArgumentException ( "The value " + value + " is out of the admitted range [" + min + ", " + max + "]." ) ; } if ( value != min && value != max ) { if ( timer == null ) { logger . trace ( "creating timer" ) ; timer = new Timer ( 50 , this ) ; } if ( ! timer . isRunning ( ) ) { logger . trace ( "starting timer" ) ; timer . start ( ) ; } } else { logger . trace ( "value is '{}' (in range [{}, {}]" , value , min , max ) ; if ( timer != null && timer . isRunning ( ) ) { logger . trace ( "stopping timer" ) ; timer . stop ( ) ; repaint ( ) ; } } this . value = value ; } | Sets the current progress arc value . |
29,388 | public static PrefixedProperties createCascadingPrefixProperties ( final List < PrefixConfig > configs ) { PrefixedProperties properties = null ; for ( final PrefixConfig config : configs ) { if ( properties == null ) { properties = new PrefixedProperties ( ( config == null ) ? new DynamicPrefixConfig ( ) : config ) ; } else { properties = new PrefixedProperties ( properties , ( config == null ) ? new DynamicPrefixConfig ( ) : config ) ; } } return properties ; } | Creates the cascading prefix properties . |
29,389 | public static PrefixedProperties createCascadingPrefixProperties ( final String prefixString ) { return prefixString . indexOf ( PrefixConfig . PREFIXDELIMITER ) != - 1 ? createCascadingPrefixProperties ( prefixString . split ( "\\" + PrefixConfig . PREFIXDELIMITER ) ) : createCascadingPrefixProperties ( new String [ ] { prefixString } ) ; } | Creates the cascading prefix properties . This method parses the given prefixString and creates for each delimiter part a PrefixedProperties . |
29,390 | public static PrefixedProperties createCascadingPrefixProperties ( final String [ ] prefixes ) { PrefixedProperties properties = null ; for ( final String aPrefix : prefixes ) { if ( properties == null ) { properties = new PrefixedProperties ( aPrefix ) ; } else { properties = new PrefixedProperties ( properties , aPrefix ) ; } } return properties ; } | Creates the cascading prefix properties by using the given Prefixes . |
29,391 | public boolean getBoolean ( final String key , final boolean def ) { final String value = getProperty ( key ) ; return value != null ? Boolean . valueOf ( value ) . booleanValue ( ) : def ; } | Gets the prefixed key and parse it to an boolean - value . |
29,392 | public double getDouble ( final String key ) { final String value = getProperty ( key ) ; if ( value == null ) { throw new NumberFormatException ( "Couldn't parse property to double." ) ; } return Double . parseDouble ( value ) ; } | Gets the prefixed key and parse it to an double - value . |
29,393 | public String getEffectivePrefix ( ) { lock . readLock ( ) . lock ( ) ; try { final boolean useLocalPrefixes = ! mixDefaultAndLocalPrefixes && hasLocalPrefixConfigurations ( ) ; return getPrefix ( new StringBuilder ( ) , useLocalPrefixes ) . toString ( ) ; } finally { lock . readLock ( ) . unlock ( ) ; } } | Gets the effective prefix . |
29,394 | public float getFloat ( final String key ) { final String value = getProperty ( key ) ; if ( value == null ) { throw new NumberFormatException ( "Couldn't parse property to float." ) ; } return Float . parseFloat ( value ) ; } | Gets the prefixed key and parse it to an float - value . |
29,395 | public int getInt ( final String key ) { final String value = getProperty ( key ) ; if ( value == null ) { throw new NumberFormatException ( "Couldn't parse property to int." ) ; } return Integer . parseInt ( value ) ; } | Gets the prefixed key and parse it to an int - value . |
29,396 | public long getLong ( final String key ) { final String value = getProperty ( key ) ; if ( value == null ) { throw new NumberFormatException ( "Couldn't parse property to long." ) ; } return Long . parseLong ( value ) ; } | Gets the prefixed key and parse it to an long - value . |
29,397 | public void setDefaultPrefix ( final String prefix ) { lock . writeLock ( ) . lock ( ) ; try { final String myPrefix = checkAndConvertPrefix ( prefix ) ; final List < String > prefixList = split ( myPrefix ) ; setDefaultPrefixes ( prefixList ) ; } finally { lock . writeLock ( ) . unlock ( ) ; } } | Sets the default prefix . |
29,398 | public void setLocalPrefix ( final String configuredPrefix ) { lock . writeLock ( ) . lock ( ) ; try { final String myPrefix = checkAndConvertPrefix ( configuredPrefix ) ; final List < String > prefixList = split ( myPrefix ) ; setPrefixes ( prefixList ) ; } finally { lock . writeLock ( ) . unlock ( ) ; } } | Sets the local Prefix . The local Prefix is Thread depended and will only affect the current thread . You can have a combination of default and local prefix . |
29,399 | public void setMixDefaultAndLocalPrefixSettings ( final boolean value ) { this . mixDefaultAndLocalPrefixes = value ; if ( properties instanceof PrefixedProperties ) { ( ( PrefixedProperties ) properties ) . setMixDefaultAndLocalPrefixSettings ( value ) ; } } | Setting to define if default prefixes should be mixed with local prefixes if local prefixes are not present . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.