idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
9,200
public static < T > Iterable < T > iterable ( T first , T second ) { return ArrayIterable . of ( first , second ) ; }
Creates an iterable from the passed values .
33
10
9,201
@ Override public R apply ( T1 first , T2 second ) { interceptor . before ( first , second ) ; try { return inner . apply ( first , second ) ; } finally { interceptor . after ( first , second ) ; } }
Executes a function in the nested interceptor context .
53
11
9,202
@ Deprecated public static String validate ( String blz ) { return VALIDATOR . validate ( PackedDecimal . of ( blz ) ) . toString ( ) ; }
Eine BLZ darf maximal 8 - stellig sein .
38
14
9,203
@ Override public WeightedIndexEvaluation evaluate ( SolutionType solution , DataType data ) { // initialize evaluation object WeightedIndexEvaluation eval = new WeightedIndexEvaluation ( ) ; // add evaluations produced by contained objectives weights . keySet ( ) . forEach ( obj -> { // evaluate solution using objective Evaluation objEval = obj . evaluate ( solution , data ) ; // flip weight sign if minimizing double w = weights . get ( obj ) ; if ( obj . isMinimizing ( ) ) { w = - w ; } // register in weighted index evaluation eval . addEvaluation ( obj , objEval , w ) ; } ) ; // return weighted index evaluation return eval ; }
Produces an evaluation object that reflects the weighted sum of evaluations of all underlying objectives .
150
17
9,204
@ Override public < ActualSolutionType extends SolutionType > WeightedIndexEvaluation evaluate ( Move < ? super ActualSolutionType > move , ActualSolutionType curSolution , Evaluation curEvaluation , DataType data ) { // cast current evaluation object WeightedIndexEvaluation curEval = ( WeightedIndexEvaluation ) curEvaluation ; // initialize new evaluation object WeightedIndexEvaluation newEval = new WeightedIndexEvaluation ( ) ; // compute delta evaluation for each contained objective weights . keySet ( ) . forEach ( obj -> { // extract current evaluation Evaluation objCurEval = curEval . getEvaluation ( obj ) ; // delta evaluation of contained objective Evaluation objNewEval = obj . evaluate ( move , curSolution , objCurEval , data ) ; // flip weight sign if minimizing double w = weights . get ( obj ) ; if ( obj . isMinimizing ( ) ) { w = - w ; } // register in new weighted index evaluation newEval . addEvaluation ( obj , objNewEval , w ) ; } ) ; // return new evaluation return newEval ; }
Delta evaluation . Computes a delta evaluation for each contained objective and wraps the obtained modified evaluations in a new weighted index evaluation .
245
25
9,205
@ Override public void serialize ( Fachwert fachwert , JsonGenerator jgen , SerializerProvider provider ) throws IOException { serialize ( fachwert . toMap ( ) , jgen , provider ) ; }
Fuer die Serialisierung wird der uebergebenen Fachwert nach seinen einzelnen Elementen aufgeteilt und serialisiert .
53
40
9,206
void configurePort ( String port ) { if ( StringUtils . isNotBlank ( port ) ) { try { this . port = Integer . parseInt ( port ) ; log . info ( "Using port {}" , this . port ) ; } catch ( NumberFormatException e ) { log . info ( "Unable to parse server PORT variable ({}). Defaulting to port {}" , port , this . port ) ; } } }
Configures the server port by attempting to parse the given parameter but failing gracefully if that doesn t work out .
94
23
9,207
void configureClasses ( String path ) { findClassesInClasspath ( ) ; if ( StringUtils . isNotBlank ( path ) ) { // If the path is set, set up class reloading: configureClassesReloadable ( path ) ; } packagePrefix = getValue ( PACKAGE_PREFIX ) ; classesReloadable = classesUrl != null && classesInClasspath == null ; // Communicate: showClassesConfiguration ( ) ; }
Sets up configuration for reloading classes .
101
9
9,208
private void configureAuthentication ( String username , String password , String realm ) { // If the username is set, set up authentication: if ( StringUtils . isNotBlank ( username ) ) { this . username = username ; this . password = password ; this . realm = StringUtils . defaultIfBlank ( realm , "restolino" ) ; authenticationEnabled = true ; } }
Sets up authentication .
83
5
9,209
void showFilesConfiguration ( ) { // Message to communicate the resolved configuration: String message ; if ( filesUrl != null ) { String reload = filesReloadable ? "reloadable" : "non-reloadable" ; message = "Files will be served from: " + filesUrl + " (" + reload + ")" ; } else { message = "No static files will be served." ; } log . info ( "Files: {}" , message ) ; }
Prints out a message confirming the static file serving configuration .
99
12
9,210
void showClassesConfiguration ( ) { // Warning about a classes folder present in the classpath: if ( classesInClasspath != null ) { log . warn ( "Dynamic class reloading is disabled because a classes URL is present in the classpath. P" + "lease launch without including your classes directory: {}" , classesInClasspath ) ; } // Message to communicate the resolved configuration: String message ; if ( classesReloadable ) { if ( StringUtils . isNotBlank ( packagePrefix ) ) { message = "Classes will be reloaded from: " + classesUrl ; } else { message = "Classes will be reloaded from package " + packagePrefix + " at: " + classesUrl ; } } else { message = "Classes will not be dynamically reloaded." ; } log . info ( "Classes: {}" , message ) ; }
Prints out a message confirming the class reloading configuration .
187
12
9,211
static String getValue ( String key ) { String result = StringUtils . defaultIfBlank ( System . getProperty ( key ) , StringUtils . EMPTY ) ; result = StringUtils . defaultIfBlank ( result , System . getenv ( key ) ) ; return result ; }
Gets a configured value for the given key from either the system properties or an environment variable .
63
19
9,212
@ Override public boolean isValid ( T wert ) { int length = Objects . toString ( wert , "" ) . length ( ) ; return ( length >= min ) && ( length <= max ) ; }
Liefert true zurueck wenn der uebergebene Wert innerhalb der erlaubten Laenge liegt .
45
32
9,213
public Analysis < SolutionType > setNumRuns ( String searchID , int n ) { if ( ! searches . containsKey ( searchID ) ) { throw new UnknownIDException ( "No search with ID " + searchID + " has been added." ) ; } if ( n <= 0 ) { throw new IllegalArgumentException ( "Number of runs should be strictly positive." ) ; } searchNumRuns . put ( searchID , n ) ; return this ; }
Set the number of runs to be performed for the given search . This does not affect the number of runs of the other searches . Returns a reference to the analysis object on which this method was called so that methods can be chained .
99
46
9,214
public Analysis < SolutionType > setNumBurnIn ( String searchID , int n ) { if ( ! searches . containsKey ( searchID ) ) { throw new UnknownIDException ( "No search with ID " + searchID + " has been added." ) ; } if ( n <= 0 ) { throw new IllegalArgumentException ( "Number of burn-in runs should be strictly positive." ) ; } searchNumBurnIn . put ( searchID , n ) ; return this ; }
Set the number of additional burn - in runs to be performed for the given search . This does not affect the number of burn - in runs of the other searches . Returns a reference to the analysis object on which this method was called so that methods can be chained .
102
53
9,215
public Analysis < SolutionType > addProblem ( String ID , Problem < SolutionType > problem ) { if ( problem == null ) { throw new NullPointerException ( "Problem can not be null." ) ; } if ( problems . containsKey ( ID ) ) { throw new DuplicateIDException ( "Duplicate problem ID: " + ID + "." ) ; } problems . put ( ID , problem ) ; return this ; }
Add a problem to be analyzed . Returns a reference to the analysis object on which this method was called so that methods can be chained .
91
27
9,216
public Analysis < SolutionType > addSearch ( String ID , SearchFactory < SolutionType > searchFactory ) { if ( searchFactory == null ) { throw new NullPointerException ( "Search factory can not be null." ) ; } if ( searches . containsKey ( ID ) ) { throw new DuplicateIDException ( "Duplicate search ID: " + ID + "." ) ; } searches . put ( ID , searchFactory ) ; return this ; }
Add a search to be applied to solve the analyzed problems . Requires a search factory instead of a plain search as a new instance of the search will be created for every run and for every analyzed problem . Returns a reference to the analysis object on which this method was called so that methods can be chained .
96
60
9,217
public AnalysisResults < SolutionType > run ( ) { // create results object AnalysisResults < SolutionType > results = new AnalysisResults <> ( ) ; // log LOGGER . info ( ANALYSIS_MARKER , "Started analysis of {} problems {} using {} searches {}." , problems . size ( ) , problems . keySet ( ) , searches . size ( ) , searches . keySet ( ) ) ; // analyze each problem problems . forEach ( ( problemID , problem ) -> { LOGGER . info ( ANALYSIS_MARKER , "Analyzing problem {}." , problemID ) ; // apply all searches searches . forEach ( ( searchID , searchFactory ) -> { // execute burn-in runs int nBurnIn = getNumBurnIn ( searchID ) ; for ( int burnIn = 0 ; burnIn < nBurnIn ; burnIn ++ ) { LOGGER . info ( ANALYSIS_MARKER , "Burn-in of search {} applied to problem {} (burn-in run {}/{})." , searchID , problemID , burnIn + 1 , nBurnIn ) ; // create search Search < SolutionType > search = searchFactory . create ( problem ) ; // run search search . start ( ) ; // dispose search search . dispose ( ) ; LOGGER . info ( ANALYSIS_MARKER , "Finished burn-in run {}/{} of search {} for problem {}." , burnIn + 1 , nBurnIn , searchID , problemID ) ; } // perform actual search runs and register results int nRuns = getNumRuns ( searchID ) ; for ( int run = 0 ; run < nRuns ; run ++ ) { LOGGER . info ( ANALYSIS_MARKER , "Applying search {} to problem {} (run {}/{})." , searchID , problemID , run + 1 , nRuns ) ; // create search Search < SolutionType > search = searchFactory . create ( problem ) ; // attach listener AnalysisListener listener = new AnalysisListener ( ) ; search . addSearchListener ( listener ) ; // run search search . start ( ) ; // dispose search search . dispose ( ) ; // register search run in results object results . registerSearchRun ( problemID , searchID , listener . getSearchRunResults ( ) ) ; LOGGER . info ( ANALYSIS_MARKER , "Finished run {}/{} of search {} for problem {}." , run + 1 , nRuns , searchID , problemID ) ; } } ) ; LOGGER . info ( ANALYSIS_MARKER , "Done analyzing problem {}." , problemID ) ; } ) ; // log LOGGER . info ( ANALYSIS_MARKER , "Analysis complete." ) ; return results ; }
Run the analysis . The returned results can be accessed directly or written to a JSON file to be loaded into R for analysis and visualization using the james - analysis R package . The analysis progress is logged at INFO level all log messages being tagged with a marker analysis .
600
53
9,218
public int run ( ) { try { if ( compile ) { compile ( ) ; } String separator = "/" ; String cpseperator = ":" ; if ( System . getProperty ( "os.name" ) . contains ( "indows" ) ) { separator = "\\" ; cpseperator = ";" ; } String s = fileName . replace ( separator , "." ) ; if ( ".java" . equals ( s . substring ( s . length ( ) - 5 ) ) ) { s = s . substring ( 0 , s . length ( ) - 5 ) ; // .java Entfernen } else { s = s . substring ( 0 , s . length ( ) - 6 ) ; // .class entfernen } String localClasspath = classpath ; if ( compileFolder != null ) localClasspath = localClasspath + cpseperator + compileFolder ; String command = "java -cp " + localClasspath ; if ( libraryPath != null && libraryPath != "" ) command += "-Djava.library.path=" + libraryPath ; command = command + " de.kopeme.testrunner.PerformanceTestRunner " + s ; // System.out.println(command); Process p = Runtime . getRuntime ( ) . exec ( command ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( p . getInputStream ( ) ) ) ; String line ; BufferedWriter bw = null ; // System.out.println("ExternalOutputFile: " + externalOutputFile); if ( externalOutputFile != null && externalOutputFile != "" ) { File output = new File ( externalOutputFile ) ; try { bw = new BufferedWriter ( new FileWriter ( output ) ) ; } catch ( IOException e1 ) { // TODO Automatisch generierter Erfassungsblock e1 . printStackTrace ( ) ; } } while ( ( line = br . readLine ( ) ) != null ) { if ( bw == null ) { System . out . println ( line ) ; } else { bw . write ( line + "\n" ) ; } } br = new BufferedReader ( new InputStreamReader ( p . getErrorStream ( ) ) ) ; while ( ( line = br . readLine ( ) ) != null ) { if ( bw == null ) { System . out . println ( line ) ; } else { bw . write ( line + "\n" ) ; } } if ( bw != null ) bw . close ( ) ; int returnValue = p . waitFor ( ) ; // System.out.println("Returnvalue: " + returnValue); return returnValue ; } catch ( IOException e ) { // TODO Automatisch generierter Erfassungsblock e . printStackTrace ( ) ; } catch ( InterruptedException e ) { // TODO Automatisch generierter Erfassungsblock e . printStackTrace ( ) ; } return 1 ; }
Runs KoPeMe and returns 0 if everything works allright
650
13
9,219
@ Override public void link ( NGScope scope , JQElement element , JSON attrs ) { ImageResource resource = scope . get ( getName ( ) ) ; if ( resource == null ) { LOG . log ( Level . WARNING , "Mandatory attribute " + getName ( ) + " value is mssing" ) ; return ; } Image image = new Image ( resource ) ; Element target = image . asWidget ( ) . getElement ( ) ; String className = element . attr ( "class" ) ; target . addClassName ( className ) ; String style = element . attr ( "style" ) ; target . setAttribute ( "style" , style ) ; element . replaceWith ( target ) ; }
Replaces the element body with the ImageResource passed via gwt - image - resource attribute .
155
19
9,220
@ Override public Map < String , Object > toMap ( ) { Map < String , Object > map = new HashMap <> ( ) ; map . put ( "kontoinhaber" , getKontoinhaber ( ) ) ; map . put ( "iban" , getIban ( ) ) ; getBic ( ) . ifPresent ( b -> map . put ( "bic" , b ) ) ; return map ; }
Liefert die einzelnen Attribute einer Bankverbindung als Map .
96
20
9,221
public static String repeat ( char source , int times ) { dbc . precondition ( times > - 1 , "times must be non negative" ) ; final char [ ] array = new char [ times ] ; Arrays . fill ( array , source ) ; return new String ( array ) ; }
Creates a String by repeating the source char .
63
10
9,222
public static String repeat ( String source , int times ) { dbc . precondition ( source != null , "cannot repeat a null source" ) ; dbc . precondition ( times > - 1 , "times must be non negative" ) ; final int srcLen = source . length ( ) ; final long longLen = times * ( long ) srcLen ; final int len = ( int ) longLen ; dbc . precondition ( longLen == len , "resulting String would be too long" ) ; final char [ ] array = new char [ len ] ; for ( int i = 0 ; i != times ; ++ i ) { source . getChars ( 0 , srcLen , array , i * srcLen ) ; } return new String ( array ) ; }
Creates a String by repeating the source string .
166
10
9,223
public static Nummer of ( long code ) { if ( ( code >= 0 ) && ( code < CACHE . length ) ) { return CACHE [ ( int ) code ] ; } else { return new Nummer ( code ) ; } }
Die of - Methode liefert fuer kleine Nummer immer dasselbe Objekt zurueck . Vor allem wenn man nur kleinere Nummern hat lohnt sich der Aufruf dieser Methode .
53
60
9,224
public static String validate ( String nummer ) { try { return new BigInteger ( nummer ) . toString ( ) ; } catch ( NumberFormatException nfe ) { throw new InvalidValueException ( nummer , "number" ) ; } }
Ueberprueft ob der uebergebene String auch tatsaechlich eine Zahl ist .
52
29
9,225
@ Override public Optional < E > next ( ) { if ( iterator . hasNext ( ) ) { return Optional . of ( iterator . next ( ) ) ; } return Optional . empty ( ) ; }
calling next over the boundary of the contained iterator leads Optional . empty indefinitely no matter how many times you try you can t shoot the dog
43
27
9,226
public LocalDate ersterArbeitstag ( ) { LocalDate tag = ersterTag ( ) ; switch ( tag . getDayOfWeek ( ) ) { case SATURDAY : return tag . plusDays ( 2 ) ; case SUNDAY : return tag . plusDays ( 1 ) ; default : return tag ; } }
Diese Methode liefert den ersten Arbeitstag eines Monats . Allerdings werden dabei keine Feiertag beruecksichtigt sondern nur die Wochenende die auf einen ersten des Monats fallen werden berucksichtigt .
68
70
9,227
public LocalDate letzterArbeitstag ( ) { LocalDate tag = letzterTag ( ) ; switch ( tag . getDayOfWeek ( ) ) { case SATURDAY : return tag . minusDays ( 1 ) ; case SUNDAY : return tag . minusDays ( 2 ) ; default : return tag ; } }
Diese Methode liefert den letzten Arbeitstag eines Monats . Allerdings werden dabei keine Feiertag beruecksichtigt sondern nur die Wochenende die auf einen letzten des Monats fallen werden berucksichtigt .
70
72
9,228
public static < T > Consumer < T > pipeline ( Consumer < T > consumer ) { return new PipelinedConsumer < T > ( Iterations . iterable ( consumer ) ) ; }
Creates a pipeline from an consumer .
39
8
9,229
public static < T > Consumer < T > pipeline ( Consumer < T > former , Consumer < T > latter ) { return new PipelinedConsumer < T > ( Iterations . iterable ( former , latter ) ) ; }
Creates a pipeline from two actions .
47
8
9,230
public static < T > Consumer < T > pipeline ( Consumer < T > first , Consumer < T > second , Consumer < T > third ) { return new PipelinedConsumer < T > ( Iterations . iterable ( first , second , third ) ) ; }
Creates a pipeline from three actions .
55
8
9,231
public static < T > Consumer < T > pipeline ( Consumer < T > ... actions ) { return new PipelinedConsumer < T > ( Iterations . iterable ( actions ) ) ; }
Creates a pipeline from an array of actions .
40
10
9,232
public static < T1 , T2 > BiConsumer < T1 , T2 > pipeline ( BiConsumer < T1 , T2 > consumer ) { return new PipelinedBinaryConsumer < T1 , T2 > ( Iterations . iterable ( consumer ) ) ; }
Creates a pipeline from a binary consumer .
59
9
9,233
public static < T1 , T2 > BiConsumer < T1 , T2 > pipeline ( BiConsumer < T1 , T2 > former , BiConsumer < T1 , T2 > latter ) { return new PipelinedBinaryConsumer < T1 , T2 > ( Iterations . iterable ( former , latter ) ) ; }
Creates a pipeline from two binary actions .
72
9
9,234
public static < T1 , T2 > BiConsumer < T1 , T2 > pipeline ( BiConsumer < T1 , T2 > first , BiConsumer < T1 , T2 > second , BiConsumer < T1 , T2 > third ) { return new PipelinedBinaryConsumer < T1 , T2 > ( Iterations . iterable ( first , second , third ) ) ; }
Creates a pipeline from three binary actions .
85
9
9,235
public static < T1 , T2 > BiConsumer < T1 , T2 > pipeline ( BiConsumer < T1 , T2 > ... actions ) { return new PipelinedBinaryConsumer < T1 , T2 > ( Iterations . iterable ( actions ) ) ; }
Creates a pipeline from an array of binary actions .
60
11
9,236
public static < T1 , T2 , T3 > TriConsumer < T1 , T2 , T3 > pipeline ( TriConsumer < T1 , T2 , T3 > consumer ) { return new PipelinedTernaryConsumer < T1 , T2 , T3 > ( Iterations . iterable ( consumer ) ) ; }
Creates a pipeline from a ternary consumer .
72
11
9,237
public static < T1 , T2 , T3 > TriConsumer < T1 , T2 , T3 > pipeline ( TriConsumer < T1 , T2 , T3 > former , TriConsumer < T1 , T2 , T3 > latter ) { return new PipelinedTernaryConsumer < T1 , T2 , T3 > ( Iterations . iterable ( former , latter ) ) ; }
Creates a pipeline from two ternary actions .
88
11
9,238
public static < T1 , T2 , T3 > TriConsumer < T1 , T2 , T3 > pipeline ( TriConsumer < T1 , T2 , T3 > first , TriConsumer < T1 , T2 , T3 > second , TriConsumer < T1 , T2 , T3 > third ) { return new PipelinedTernaryConsumer < T1 , T2 , T3 > ( Iterations . iterable ( first , second , third ) ) ; }
Creates a pipeline from three ternary actions .
104
11
9,239
public static void initialize ( ) { if ( ! initialized ) { String libraryBaseName = "JCusparse-" + JCuda . getJCudaVersion ( ) ; String libraryName = LibUtils . createPlatformLibraryName ( libraryBaseName ) ; LibUtils . loadLibrary ( libraryName ) ; initialized = true ; } }
Initializes the native library . Note that this method does not have to be called explicitly since it will be called automatically when this class is loaded .
69
29
9,240
private static int checkResult ( int result ) { if ( exceptionsEnabled && result != cusparseStatus . CUSPARSE_STATUS_SUCCESS ) { throw new CudaException ( cusparseStatus . stringFor ( result ) ) ; } return result ; }
If the given result is not cusparseStatus . CUSPARSE_STATUS_SUCCESS and exceptions have been enabled this method will throw a CudaException with an error message that corresponds to the given result code . Otherwise the given result is simply returned .
58
55
9,241
public static int cusparseCsrmvEx_bufferSize ( cusparseHandle handle , int alg , int transA , int m , int n , int nnz , Pointer alpha , int alphatype , cusparseMatDescr descrA , Pointer csrValA , int csrValAtype , Pointer csrRowPtrA , Pointer csrColIndA , Pointer x , int xtype , Pointer beta , int betatype , Pointer y , int ytype , int executiontype , long [ ] bufferSizeInBytes ) { return checkResult ( cusparseCsrmvEx_bufferSizeNative ( handle , alg , transA , m , n , nnz , alpha , alphatype , descrA , csrValA , csrValAtype , csrRowPtrA , csrColIndA , x , xtype , beta , betatype , y , ytype , executiontype , bufferSizeInBytes ) ) ; }
Returns number of bytes
220
4
9,242
public T add ( T addend ) { if ( addend == null ) { throw new IllegalArgumentException ( "invalid (null) addend" ) ; } BigDecimal sum = this . value . add ( addend . value ) ; return newInstance ( sum , sum . scale ( ) ) ; }
Wraps BigDecimal s add method to accept and return T instances instead of BigDecimals so that users of the class don t have to typecast the return value .
67
36
9,243
public T subtract ( T subtrahend ) { if ( subtrahend == null ) { throw new IllegalArgumentException ( "invalid (null) subtrahend" ) ; } BigDecimal difference = this . value . subtract ( subtrahend . value ) ; return newInstance ( difference , difference . scale ( ) ) ; }
Wraps BigDecimal s subtract method to accept and return T instances instead of BigDecimals so that users of the class don t have to typecast the return value .
71
36
9,244
public T multiply ( T multiplier ) { if ( multiplier == null ) { throw new IllegalArgumentException ( "invalid (null) multiplier" ) ; } BigDecimal product = this . value . multiply ( multiplier . value ) ; return newInstance ( product , this . value . scale ( ) ) ; }
Wraps BigDecimal s multiply method to accept and return T instances instead of BigDecimals so that users of the class don t have to typecast the return value .
65
36
9,245
public T mod ( T modulus ) { if ( modulus == null ) { throw new IllegalArgumentException ( "invalid (null) modulus" ) ; } double difference = this . value . doubleValue ( ) % modulus . doubleValue ( ) ; return newInstance ( BigDecimal . valueOf ( difference ) , this . value . scale ( ) ) ; }
This method calculates the mod between to T values by first casting to doubles and then by performing the % operation on the two primitives .
80
27
9,246
public T divide ( T divisor ) { if ( divisor == null ) { throw new IllegalArgumentException ( "invalid (null) divisor" ) ; } BigDecimal quotient = this . value . divide ( divisor . value , ROUND_BEHAVIOR ) ; return newInstance ( quotient , this . value . scale ( ) ) ; }
Wraps BigDecimal s divide method to enforce the default rounding behavior
83
14
9,247
private static List < DAType > computeExtendedInterfaces ( List < DAInterface > interfaces ) { Optional < DAType > functionInterface = from ( interfaces ) . filter ( DAInterfacePredicates . isGuavaFunction ( ) ) . transform ( toDAType ( ) ) . filter ( notNull ( ) ) . first ( ) ; if ( functionInterface . isPresent ( ) ) { return Collections . singletonList ( functionInterface . get ( ) ) ; } return Collections . emptyList ( ) ; }
The only interface that can be extended by the Mapper interface is Guava s Function interface .
109
19
9,248
public static void start ( String path ) { classMonitor = new ClassReloader ( path ) ; Thread thread = new Thread ( classMonitor , ClassReloader . class . getSimpleName ( ) ) ; thread . setDaemon ( true ) ; thread . start ( ) ; }
Sets up and starts a monitor for the given path .
60
12
9,249
public static Integer toInteger ( String parameterValue ) { Integer result = null ; if ( isDigits ( parameterValue ) ) result = Integer . valueOf ( parameterValue ) ; return result ; }
Parses a parameter as an Integer . This is useful for working with query string parameters and path segments as numbers .
41
24
9,250
public static int toInt ( String parameterValue ) { int result = - 1 ; if ( isDigits ( parameterValue ) ) result = Integer . parseInt ( parameterValue ) ; return result ; }
Parses a parameter as an int . This is useful for working with query string parameters and path segments as numbers .
42
24
9,251
public static void validate ( Ort ort , String strasse , String hausnummer ) { if ( StringUtils . isBlank ( strasse ) ) { throw new InvalidValueException ( strasse , "street" ) ; } validate ( ort , strasse , hausnummer , VALIDATOR ) ; }
Validiert die uebergebene Adresse auf moegliche Fehler .
69
22
9,252
public String getStrasseKurz ( ) { if ( PATTERN_STRASSE . matcher ( strasse ) . matches ( ) ) { return strasse . substring ( 0 , StringUtils . lastIndexOfIgnoreCase ( strasse , "stra" ) + 3 ) + ' ' ; } else { return strasse ; } }
Liefert die Strasse in einer abgekuerzten Schreibweise .
76
21
9,253
@ Override public Map < String , Object > toMap ( ) { Map < String , Object > map = new HashMap <> ( ) ; map . put ( "plz" , getPLZ ( ) ) ; map . put ( "ortsname" , getOrtsname ( ) ) ; map . put ( "strasse" , getStrasse ( ) ) ; map . put ( "hausnummer" , getHausnummer ( ) ) ; return map ; }
Liefert die einzelnen Attribute einer Adresse als Map .
104
19
9,254
public static Datamappingtype findDataMapping ( Object data , String id , Datamappingstype dataMappingConfig ) { if ( null != data ) { Class clazz = ( Class ) ( ( data instanceof Class ) ? data : data . getClass ( ) ) ; for ( Datamappingtype dt : dataMappingConfig . getDatamapping ( ) ) { if ( dt . isRegex ( ) && Pattern . compile ( dt . getClassname ( ) ) . matcher ( clazz . getName ( ) ) . find ( ) && idOK ( id , dt . getId ( ) ) ) { if ( logger . isLoggable ( Level . FINE ) ) { logger . fine ( String . format ( "Datamapping found: %s matches regex %s (requested id: %s)" , clazz . getName ( ) , dt . getClassname ( ) , id ) ) ; } return dt ; } else if ( clazz . getName ( ) . equals ( dt . getClassname ( ) ) && idOK ( id , dt . getId ( ) ) ) { if ( logger . isLoggable ( Level . FINE ) ) { logger . fine ( String . format ( "Datamapping found: %s matches %s (requested id: %s)" , clazz . getName ( ) , dt . getClassname ( ) , id ) ) ; } return dt ; } if ( logger . isLoggable ( Level . FINE ) ) { logger . fine ( String . format ( "%s does not match %s (regex: %s, requested id %s)" , dt . getClassname ( ) , clazz . getName ( ) , dt . isRegex ( ) , id ) ) ; } } } return null ; }
returns the first Datamapping found for an object or Class . A datamapping is valid for an object when either a regex is found in the classname of the object or the classname of the object equals the configured classname when an id is provided the id in the datamapping found must match this id when an id is not provided an id a datamapping with an id is not valid .
400
84
9,255
public static List < StartContainerConfig > getContainers ( Class clazz ) { if ( ! cacheSCC . containsKey ( clazz ) ) { cacheSCC . put ( clazz , new ArrayList <> ( 1 ) ) ; ContainerStart cs = ( ContainerStart ) clazz . getAnnotation ( ContainerStart . class ) ; if ( cs != null ) { cacheSCC . get ( clazz ) . add ( fromContainerStart ( cs ) ) ; } Containers c = ( Containers ) clazz . getAnnotation ( com . vectorprint . report . itext . annotations . Containers . class ) ; if ( c != null ) { for ( ContainerStart s : c . containers ( ) ) { cacheSCC . get ( clazz ) . add ( fromContainerStart ( s ) ) ; } } } return cacheSCC . get ( clazz ) ; }
Find a datamapping to start a container based on class annotation uses static cache .
188
17
9,256
public static List < ElementConfig > getElements ( Class clazz ) { if ( ! cacheEC . containsKey ( clazz ) ) { cacheEC . put ( clazz , new ArrayList <> ( 1 ) ) ; Element e = ( Element ) clazz . getAnnotation ( Element . class ) ; if ( e != null ) { cacheEC . get ( clazz ) . add ( fromAnnotation ( e ) ) ; } Elements es = ( Elements ) clazz . getAnnotation ( com . vectorprint . report . itext . annotations . Elements . class ) ; if ( es != null ) { for ( Element s : es . elements ( ) ) { cacheEC . get ( clazz ) . add ( fromAnnotation ( s ) ) ; } } } return cacheEC . get ( clazz ) ; }
Find a datamapping to create an element based on class annotation uses static cache .
175
17
9,257
public String getFormatted ( ) { String input = this . getUnformatted ( ) + " " ; StringBuilder buf = new StringBuilder ( ) ; for ( int i = 0 ; i < this . getUnformatted ( ) . length ( ) ; i += 4 ) { buf . append ( input , i , i + 4 ) ; buf . append ( ' ' ) ; } return buf . toString ( ) . trim ( ) ; }
Liefert die IBAN formattiert in der DIN - Form . Dies ist die uebliche Papierform in der die IBAN in 4er - Bloecke formattiert wird jeweils durch Leerzeichen getrennt .
95
59
9,258
@ SuppressWarnings ( { "squid:SwitchLastCaseIsDefaultCheck" , "squid:S1301" } ) public Locale getLand ( ) { String country = this . getUnformatted ( ) . substring ( 0 , 2 ) ; String language = country . toLowerCase ( ) ; switch ( country ) { case "AT" : case "CH" : language = "de" ; break ; } return new Locale ( language , country ) ; }
Liefert das Land zu dem die IBAN gehoert .
104
16
9,259
public Fachwert getFachwert ( Class < ? extends Fachwert > clazz , Object ... args ) { Class [ ] argTypes = toTypes ( args ) ; try { Constructor < ? extends Fachwert > ctor = clazz . getConstructor ( argTypes ) ; return ctor . newInstance ( args ) ; } catch ( ReflectiveOperationException ex ) { Throwable cause = ex . getCause ( ) ; if ( cause instanceof ValidationException ) { throw ( ValidationException ) cause ; } else if ( cause instanceof IllegalArgumentException ) { throw new LocalizedValidationException ( cause . getMessage ( ) , cause ) ; } else { throw new IllegalArgumentException ( "cannot create " + clazz + " with " + Arrays . toString ( args ) , ex ) ; } } }
Liefert einen Fachwert zur angegebenen Klasse .
184
19
9,260
@ Programmatic public WordprocessingMLPackage loadPackage ( final InputStream docxTemplate ) throws LoadTemplateException { final WordprocessingMLPackage docxPkg ; try { docxPkg = WordprocessingMLPackage . load ( docxTemplate ) ; } catch ( final Docx4JException ex ) { throw new LoadTemplateException ( "Unable to load docx template from input stream" , ex ) ; } return docxPkg ; }
Load and return an in - memory representation of a docx .
94
13
9,261
@ Override public PdfFormField makeField ( ) throws IOException , DocumentException , VectorPrintException { switch ( getFieldtype ( ) ) { case TEXT : return ( ( TextField ) bf ) . getTextField ( ) ; case COMBO : return ( ( TextField ) bf ) . getComboField ( ) ; case LIST : return ( ( TextField ) bf ) . getListField ( ) ; case BUTTON : return ( ( PushbuttonField ) bf ) . getField ( ) ; case CHECKBOX : return ( ( RadioCheckField ) bf ) . getCheckField ( ) ; case RADIO : return ( ( RadioCheckField ) bf ) . getRadioField ( ) ; } throw new VectorPrintException ( String . format ( "cannot create pdfformfield from %s and %s" , ( bf != null ) ? bf . getClass ( ) : null , String . valueOf ( getFieldtype ( ) ) ) ) ; }
Create the PdfFormField that will be used to add a form field to the pdf .
214
19
9,262
public static < P extends Parameterizable > Set < P > getParameterizables ( Package javaPackage , Class < P > clazz ) throws IOException , FileNotFoundException , ClassNotFoundException , InstantiationException , IllegalAccessException , NoSuchMethodException , InvocationTargetException { Set < P > parameterizables = new HashSet <> ( 50 ) ; for ( Class < ? > c : ClassHelper . fromPackage ( javaPackage ) ) { if ( clazz . isAssignableFrom ( c ) && ! Modifier . isAbstract ( c . getModifiers ( ) ) ) { P p = ( P ) c . newInstance ( ) ; ParamAnnotationProcessor . PAP . initParameters ( p ) ; parameterizables . add ( p ) ; } } return parameterizables ; }
Use this generic method in for example a gui that supports building a styling file .
173
16
9,263
@ Override public List < String > getDefaultProviderChain ( ) { List < String > list = new ArrayList <> ( getProviderNames ( ) ) ; return list ; }
Access a list of the currently registered default providers . The default providers are used when no provider names are passed by the caller .
38
25
9,264
@ Override public Set < CurrencyUnit > getCurrencies ( CurrencyQuery query ) { Set < CurrencyUnit > result = new HashSet <> ( ) ; for ( Locale locale : query . getCountries ( ) ) { try { result . add ( Waehrung . of ( Currency . getInstance ( locale ) ) ) ; } catch ( IllegalArgumentException ex ) { LOG . log ( Level . WARNING , "Cannot get currency for locale '" + locale + "':" , ex ) ; } } for ( String currencyCode : query . getCurrencyCodes ( ) ) { try { result . add ( Waehrung . of ( currencyCode ) ) ; } catch ( IllegalArgumentException ex ) { LOG . log ( Level . WARNING , "Cannot get currency '" + currencyCode + "':" , ex ) ; } } for ( CurrencyProviderSpi spi : Bootstrap . getServices ( CurrencyProviderSpi . class ) ) { result . addAll ( spi . getCurrencies ( query ) ) ; } return result ; }
Access all currencies matching the given query .
228
8
9,265
public static < E > List < E > all ( E [ ] array ) { final Function < Iterator < E > , ArrayList < E > > consumer = new ConsumeIntoCollection <> ( new ArrayListFactory < E > ( ) ) ; return consumer . apply ( new ArrayIterator <> ( array ) ) ; }
Yields all element of the array in a list .
70
12
9,266
public static < K , V > Map < K , V > dict ( Pair < K , V > ... array ) { final Function < Iterator < Pair < K , V > > , HashMap < K , V > > consumer = new ConsumeIntoMap <> ( new HashMapFactory < K , V > ( ) ) ; return consumer . apply ( new ArrayIterator <> ( array ) ) ; }
Yields all element of the array in a map .
87
12
9,267
public static < E > void pipe ( Iterator < E > iterator , OutputIterator < E > outputIterator ) { new ConsumeIntoOutputIterator <> ( outputIterator ) . apply ( iterator ) ; }
Consumes the input iterator to the output iterator .
44
10
9,268
public static < E > void pipe ( Iterable < E > iterable , OutputIterator < E > outputIterator ) { dbc . precondition ( iterable != null , "cannot call pipe with a null iterable" ) ; new ConsumeIntoOutputIterator <> ( outputIterator ) . apply ( iterable . iterator ( ) ) ; }
Consumes an iterable into the output iterator .
75
10
9,269
public static < E > void pipe ( E [ ] array , OutputIterator < E > outputIterator ) { new ConsumeIntoOutputIterator <> ( outputIterator ) . apply ( new ArrayIterator <> ( array ) ) ; }
Consumes the array into the output iterator .
49
9
9,270
public static < E > E first ( Iterator < E > iterator ) { return new FirstElement < E > ( ) . apply ( iterator ) ; }
Yields the first element of the iterator .
32
10
9,271
public static < E > E first ( Iterable < E > iterable ) { dbc . precondition ( iterable != null , "cannot call first with a null iterable" ) ; return new FirstElement < E > ( ) . apply ( iterable . iterator ( ) ) ; }
Yields the first element of the iterable .
63
11
9,272
public static < E > E first ( E [ ] array ) { return new FirstElement < E > ( ) . apply ( new ArrayIterator <> ( array ) ) ; }
Yields the first element of the array .
37
10
9,273
public < E extends Element > E createElementByStyler ( Collection < ? extends BaseStyler > stylers , Object data , Class < E > clazz ) throws VectorPrintException { // pdfptable, Section and others do not have a default constructor, a styler creates it E e = null ; return styleHelper . style ( e , data , stylers ) ; }
leaves object creation to the first styler in the list
79
12
9,274
public Phrase createPhrase ( Object data , Collection < ? extends BaseStyler > stylers ) throws VectorPrintException { return initTextElementArray ( styleHelper . style ( new Phrase ( Float . NaN ) , data , stylers ) , data , stylers ) ; }
Create a Phrase style it and add the data
60
10
9,275
public Paragraph createParagraph ( Object data , Collection < ? extends BaseStyler > stylers ) throws VectorPrintException { return initTextElementArray ( styleHelper . style ( new Paragraph ( Float . NaN ) , data , stylers ) , data , stylers ) ; }
Create a Paragraph style it and add the data
60
10
9,276
public Anchor createAnchor ( Object data , Collection < ? extends BaseStyler > stylers ) throws VectorPrintException { return initTextElementArray ( styleHelper . style ( new Anchor ( Float . NaN ) , data , stylers ) , data , stylers ) ; }
Create a Anchor style it and add the data
61
10
9,277
public ListItem createListItem ( Object data , Collection < ? extends BaseStyler > stylers ) throws VectorPrintException { return initTextElementArray ( styleHelper . style ( new ListItem ( Float . NaN ) , data , stylers ) , data , stylers ) ; }
Create a ListItem style it and add the data
60
10
9,278
public static BufferedImage makeImageTranslucent ( BufferedImage source , float opacity ) { if ( opacity == 1 ) { return source ; } BufferedImage translucent = new BufferedImage ( source . getWidth ( ) , source . getHeight ( ) , BufferedImage . TRANSLUCENT ) ; Graphics2D g = translucent . createGraphics ( ) ; g . setComposite ( AlphaComposite . getInstance ( AlphaComposite . SRC_OVER , opacity ) ) ; g . drawImage ( source , null , 0 , 0 ) ; g . dispose ( ) ; return translucent ; }
returns a transparent image when opacity &lt ; 1
129
11
9,279
@ Override public Section getIndex ( String title , int nesting , List < ? extends BaseStyler > stylers ) throws VectorPrintException , InstantiationException , IllegalAccessException { if ( nesting < 1 ) { throw new VectorPrintException ( "chapter numbering starts with 1, wrong number: " + nesting ) ; } if ( sections . get ( nesting ) == null ) { sections . put ( nesting , new ArrayList <> ( 10 ) ) ; } Section current ; if ( nesting == 1 ) { List < Section > chapters = sections . get ( 1 ) ; current = new Chapter ( createElement ( title , Paragraph . class , stylers ) , chapters . size ( ) + 1 ) ; chapters . add ( current ) ; } else { List < Section > parents = sections . get ( nesting - 1 ) ; Section parent = parents . get ( parents . size ( ) - 1 ) ; current = parent . addSection ( createParagraph ( title , stylers ) ) ; sections . get ( nesting ) . add ( current ) ; } return styleHelper . style ( current , null , stylers ) ; }
create the Section style the title style the section and return the styled section .
234
15
9,280
public void visit ( Visitable visitable ) { StreamSupport . stream ( this . spliterator ( ) , false ) . forEach ( visitor -> visitor . visit ( visitable ) ) ; }
Visits the given Visitable object in order to carryout some function or investigation of the targeted object .
40
21
9,281
public static br_broker reboot ( nitro_service client , br_broker resource ) throws Exception { return ( ( br_broker [ ] ) resource . perform_operation ( client , "reboot" ) ) [ 0 ] ; }
Use this operation to reboot Unified Repeater Instance .
52
11
9,282
public static br_broker stop ( nitro_service client , br_broker resource ) throws Exception { return ( ( br_broker [ ] ) resource . perform_operation ( client , "stop" ) ) [ 0 ] ; }
Use this operation to stop Unified Repeater Instance .
51
11
9,283
public static br_broker force_reboot ( nitro_service client , br_broker resource ) throws Exception { return ( ( br_broker [ ] ) resource . perform_operation ( client , "force_reboot" ) ) [ 0 ] ; }
Use this operation to force reboot Unified Repeater Instance .
57
12
9,284
public static br_broker force_stop ( nitro_service client , br_broker resource ) throws Exception { return ( ( br_broker [ ] ) resource . perform_operation ( client , "force_stop" ) ) [ 0 ] ; }
Use this operation to force stop Unified Repeater Instance .
55
12
9,285
public static br_broker start ( nitro_service client , br_broker resource ) throws Exception { return ( ( br_broker [ ] ) resource . perform_operation ( client , "start" ) ) [ 0 ] ; }
Use this operation to start Unified Repeater Instance .
51
11
9,286
@ Override public void visit ( Visitable visitable ) { if ( isCommitable ( visitable ) ) { ObjectUtils . setField ( visitable , "lastModifiedBy" , ( ( Auditable ) visitable ) . getModifiedBy ( ) ) ; ObjectUtils . setField ( visitable , "lastModifiedOn" , ( ( Auditable ) visitable ) . getModifiedOn ( ) ) ; ObjectUtils . setField ( visitable , "lastModifiedWith" , ( ( Auditable ) visitable ) . getModifiedWith ( ) ) ; } }
Visits all objects in an application domain object graph hierarchy targeting objects to be committed .
128
17
9,287
protected boolean isCommitable ( Object visitable ) { return ( visitable instanceof Auditable && ( target == null || identity ( visitable ) == identity ( target ) ) ) ; }
Determines whether the specified visitable object is commit - able . The object is commit - able if the object is Auditable and this Visitor is not targeting a specific object in the application domain object graph hierarchy .
39
44
9,288
@ TargetApi ( Build . VERSION_CODES . GINGERBREAD ) public void apply ( ) { if ( editing == null ) { return ; } try { editing . apply ( ) ; } catch ( Exception ex ) { editing . commit ( ) ; // Fallback in case low api lever. } editing = null ; }
Call to apply changes .
72
5
9,289
public boolean commit ( ) { if ( editing == null ) { return false ; } final boolean result = editing . commit ( ) ; editing = null ; return result ; }
Call to commit changes .
35
5
9,290
public static sdxtools_image [ ] get_filtered ( nitro_service service , filtervalue [ ] filter ) throws Exception { sdxtools_image obj = new sdxtools_image ( ) ; options option = new options ( ) ; option . set_filter ( filter ) ; sdxtools_image [ ] response = ( sdxtools_image [ ] ) obj . getfiltered ( service , option ) ; return response ; }
Use this API to fetch filtered set of sdxtools_image resources . set the filter parameter values in filtervalue object .
95
25
9,291
public static synchronized void set ( final ObjectFactory objectFactory ) { Assert . state ( objectFactoryReference == null , "The ObjectFactory reference is already set to ({0})" , objectFactoryReference ) ; objectFactoryReference = objectFactory ; }
Sets a reference to the ObjectFactory used by the application in this holder .
51
16
9,292
public static ns_ns_runningconfig get ( nitro_service client , ns_ns_runningconfig resource ) throws Exception { resource . validate ( "get" ) ; return ( ( ns_ns_runningconfig [ ] ) resource . get_resources ( client ) ) [ 0 ] ; }
Use this operation to get running configuration from NetScaler Instance .
62
14
9,293
protected void setUp ( ) throws SQLException { Connection connection = getConnection ( ) ; try { if ( ! isSetUp ( connection ) ) { Statement stmt = connection . createStatement ( ) ; stmt . execute ( Query . CREATE_TABLE_RECORDS ) ; stmt . execute ( Query . CREATE_TABLE_FILEHASHES ) ; stmt . execute ( Query . CREATE_TABLE_META ) ; stmt . execute ( Query . CREATE_TABLE_CVES ) ; stmt . close ( ) ; } } finally { connection . close ( ) ; } }
Initializes a database by created required tables .
130
9
9,294
protected PreparedStatement statement ( Connection connection , String query ) throws SQLException { return connection . prepareStatement ( query ) ; }
Wrapper to create a prepared statement .
28
8
9,295
protected PreparedStatement setObjects ( Connection connection , String query , Object ... objects ) throws SQLException { PreparedStatement ps = statement ( connection , query ) ; setObjects ( ps , objects ) ; return ps ; }
Give a query and list of objects to set a prepared statement is created cached and returned with the objects set in the order they are provided .
49
28
9,296
protected int selectRecordId ( String hash ) throws SQLException { int id = - 1 ; Connection connection = getConnection ( ) ; try { PreparedStatement ps = setObjects ( connection , Query . GET_RECORD_ID , hash ) ; ResultSet rs = ps . executeQuery ( ) ; try { while ( rs . next ( ) ) { id = rs . getInt ( "id" ) ; break ; } } finally { rs . close ( ) ; ps . close ( ) ; } } finally { connection . close ( ) ; } return id ; }
Given a hash get the first occurance s record id .
121
12
9,297
protected int insertRecord ( Connection connection , String hash ) throws SQLException { int id = - 1 ; PreparedStatement ps = setObjects ( connection , Query . INSERT_RECORD , hash ) ; ps . execute ( ) ; ResultSet rs = ps . getGeneratedKeys ( ) ; try { while ( rs . next ( ) ) { id = rs . getInt ( 1 ) ; break ; } } finally { rs . close ( ) ; ps . close ( ) ; } return id ; }
Insert a new record with the given hash and return the record id .
108
14
9,298
protected void deleteRecord ( Connection connection , String hash ) throws SQLException { int id = selectRecordId ( hash ) ; if ( id > 0 ) { String [ ] queries = new String [ ] { Query . DELETE_FILEHASHES , Query . DELETE_METAS , Query . DELETE_CVES , Query . DELETE_RECORD_ID } ; for ( String query : queries ) { PreparedStatement ps = setObjects ( connection , query , id ) ; ps . execute ( ) ; ps . close ( ) ; } } }
Remove records matching a given hash . This will cascade to all references .
124
14
9,299
protected VALUE withCaching ( KEY key , Supplier < VALUE > cacheLoader ) { return getCache ( ) . map ( CachingTemplate :: with ) . < VALUE > map ( template -> template . withCaching ( key , ( ) -> { setCacheMiss ( ) ; return cacheLoader . get ( ) ; } ) ) . orElseGet ( cacheLoader ) ; }
Enables an application service method to optionally apply and use caching to carry out its function .
82
18