idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
42,700
private static Observable < Boolean > initiateFlush ( final ClusterFacade core , final String bucket , final String username , final String password ) { return deferAndWatch ( new Func1 < Subscriber , Observable < FlushResponse > > ( ) { @ Override public Observable < FlushResponse > call ( Subscriber subscriber ) { Fl...
Initiates a flush request against the server .
275
10
42,701
private static Observable < Boolean > pollMarkerDocuments ( final ClusterFacade core , final String bucket ) { return Observable . from ( FLUSH_MARKERS ) . flatMap ( new Func1 < String , Observable < GetResponse > > ( ) { @ Override public Observable < GetResponse > call ( final String id ) { return deferAndWatch ( new...
Helper method to poll the list of marker documents until all of them are gone .
446
16
42,702
private Observable < DocumentFragment < Lookup > > existsIn ( final String id , final LookupSpec spec , final long timeout , final TimeUnit timeUnit ) { return Observable . defer ( new Func0 < Observable < DocumentFragment < Lookup > > > ( ) { @ Override public Observable < DocumentFragment < Lookup > > call ( ) { fina...
Helper method to actually perform the subdoc exists operation .
579
11
42,703
private Observable < DocumentFragment < Lookup > > getCountIn ( final String id , final LookupSpec spec , final long timeout , final TimeUnit timeUnit ) { return Observable . defer ( new Func0 < Observable < DocumentFragment < Lookup > > > ( ) { @ Override public Observable < DocumentFragment < Lookup > > call ( ) { fi...
Helper method to actually perform the subdoc get count operation .
636
12
42,704
public static boolean checkType ( Object item ) { return item == null || item instanceof String || item instanceof Integer || item instanceof Long || item instanceof Double || item instanceof Boolean || item instanceof BigInteger || item instanceof BigDecimal || item instanceof JsonObject || item instanceof JsonArray ;...
Helper method to check if the given item is a supported JSON item .
68
14
42,705
private static List < Field > getAllDeclaredFields ( final Class < ? > sourceEntity ) { List < Field > fields = new ArrayList < Field > ( ) ; Class < ? > clazz = sourceEntity ; while ( clazz != null ) { Field [ ] f = clazz . getDeclaredFields ( ) ; fields . addAll ( Arrays . asList ( f ) ) ; clazz = clazz . getSupercla...
Helper method to grab all the declared fields from the given class but also from its inherited parents!
103
19
42,706
protected void enforcePrimitive ( Object t ) throws ClassCastException { if ( ! JsonValue . checkType ( t ) || t instanceof JsonValue ) { throw new ClassCastException ( "Only primitive types are supported in CouchbaseArraySet, got a " + t . getClass ( ) . getName ( ) ) ; } }
Verify that the type of object t is compatible with CouchbaseArraySet storage .
72
17
42,707
private static Expression infix ( String infix , String left , String right ) { return new Expression ( left + " " + infix + " " + right ) ; }
Helper method to infix a string .
36
8
42,708
private static String wrapWith ( char wrapper , String ... input ) { StringBuilder escaped = new StringBuilder ( ) ; for ( String i : input ) { escaped . append ( ", " ) ; escaped . append ( wrapper ) . append ( i ) . append ( wrapper ) ; } if ( escaped . length ( ) > 2 ) { escaped . delete ( 0 , 2 ) ; } return escaped...
Helper method to wrap varargs with the given character .
88
11
42,709
private static List < String > assembleSeedNodes ( ConnectionString connectionString , CouchbaseEnvironment environment ) { List < String > seedNodes = new ArrayList < String > ( ) ; if ( environment . dnsSrvEnabled ( ) ) { seedNodesViaDnsSrv ( connectionString , environment , seedNodes ) ; } else { for ( InetSocketAdd...
Helper method to assemble list of seed nodes depending on the given input .
172
14
42,710
private static void seedNodesViaDnsSrv ( ConnectionString connectionString , CouchbaseEnvironment environment , List < String > seedNodes ) { if ( connectionString . allHosts ( ) . size ( ) == 1 ) { InetSocketAddress lookupNode = connectionString . allHosts ( ) . get ( 0 ) ; LOGGER . debug ( "Attempting to load DNS SRV...
Helper method to assemble the list of seed nodes via DNS SRV .
391
14
42,711
public Observable < RestApiResponse > execute ( ) { return deferAndWatch ( new Func1 < Subscriber , Observable < ? extends RestApiResponse > > ( ) { @ Override public Observable < ? extends RestApiResponse > call ( Subscriber subscriber ) { RestApiRequest apiRequest = asRequest ( ) ; LOGGER . debug ( "Executing Cluster...
Executes the API request in an asynchronous fashion .
130
10
42,712
private EntityMetadata metadata ( final Class < ? > source ) { EntityMetadata metadata = metadataCache . get ( source ) ; if ( metadata == null ) { EntityMetadata generated = new ReflectionBasedEntityMetadata ( source ) ; metadataCache . put ( source , generated ) ; return generated ; } else { return metadata ; } }
Helper method to return and cache the entity metadata .
71
10
42,713
private static void verifyId ( final EntityMetadata entityMetadata ) { if ( ! entityMetadata . hasIdProperty ( ) ) { throw new RepositoryMappingException ( "No field annotated with @Id present." ) ; } if ( entityMetadata . idProperty ( ) . type ( ) != String . class ) { throw new RepositoryMappingException ( "The @Id F...
Helper method to check that the ID field is present and is of the desired types .
94
17
42,714
public static Expression regexpReplace ( Expression expression , String pattern , String repl ) { return x ( "REGEXP_REPLACE(" + expression . toString ( ) + ", \"" + pattern + "\", \"" + repl + "\")" ) ; }
Returned expression results in a new string with all occurrences of pattern replaced with repl .
56
17
42,715
public static Expression decodeJson ( JsonObject json ) { char [ ] encoded = JsonStringEncoder . getInstance ( ) . quoteAsString ( json . toString ( ) ) ; return x ( "DECODE_JSON(\"" + new String ( encoded ) + "\")" ) ; }
The returned Expression unmarshals the JSON constant into a N1QL value . The empty string results in MISSING .
65
24
42,716
public static Expression decodeJson ( String jsonString ) { try { JsonObject jsonObject = CouchbaseAsyncBucket . JSON_OBJECT_TRANSCODER . stringToJsonObject ( jsonString ) ; return decodeJson ( jsonObject ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( "String is not representing JSON object: " + jso...
The returned Expression unmarshals the JSON - encoded string into a N1QL value . The empty string results in MISSING .
86
26
42,717
public Object getAndDecrypt ( final String name , String providerName ) throws Exception { return decrypt ( ( JsonObject ) content . get ( ENCRYPTION_PREFIX + name ) , providerName ) ; }
Retrieve and decrypt content and not casting its type
48
10
42,718
public JsonObject putNullAndEncrypt ( String name , String providerName ) { addValueEncryptionInfo ( name , providerName , true ) ; content . put ( name , null ) ; return this ; }
Store a null value as encrypted identified by the field s name .
45
13
42,719
@ InterfaceAudience . Private private void addValueEncryptionInfo ( String path , String providerName , boolean escape ) { if ( escape ) { path = path . replaceAll ( "~" , "~0" ) . replaceAll ( "/" , "~1" ) ; } if ( this . encryptionPathInfo == null ) { this . encryptionPathInfo = new HashMap < String , String > ( ) ; ...
Adds to the encryption info with optional escape for json pointer syntax
104
12
42,720
protected static Observable < Tuple2 < Integer , Throwable > > errorsWithAttempts ( Observable < ? extends Throwable > errors , final int expectedAttempts ) { return errors . zipWith ( Observable . range ( 1 , expectedAttempts ) , new Func2 < Throwable , Integer , Tuple2 < Integer , Throwable > > ( ) { @ Override publi...
Internal utility method to combine errors in an observable with their attempt number .
114
14
42,721
public static Date parseDate ( String strdate ) { /* Return in case the string date is not set */ if ( strdate == null || strdate . length ( ) == 0 ) return null ; Date result = null ; strdate = strdate . trim ( ) ; if ( strdate . length ( ) > 10 ) { /* Open: deal with +4:00 (no zero before hour) */ if ( ( strdate . su...
Tries different date formats to parse against the given string representation to retrieve a valid Date object .
624
19
42,722
private static byte [ ] base64ToByteArray ( String s , boolean alternate ) { byte [ ] alphaToInt = ( alternate ? altBase64ToInt : base64ToInt ) ; int sLen = s . length ( ) ; int numGroups = sLen / 4 ; if ( 4 * numGroups != sLen ) { throw new IllegalArgumentException ( "String length must be a multiple of four." ) ; } i...
Translates the specified alternate representation Base64 string into a byte array .
611
15
42,723
private static int base64toInt ( char c , byte [ ] alphaToInt ) { int result = alphaToInt [ c ] ; if ( result < 0 ) { throw new IllegalArgumentException ( "Illegal character " + c ) ; } return result ; }
Translates the specified character which is assumed to be in the Base 64 Alphabet into its equivalent 6 - bit positive integer .
57
25
42,724
@ Nonnull public static < T > T ensureNonNull ( @ Nullable final T value , @ Nonnull final T defaultValue ) { return value == null ? Assertions . assertNotNull ( defaultValue ) : value ; }
Get value and ensure that the value is not null
49
10
42,725
@ Nonnull public static < T > T ensureNonNull ( @ Nonnull final T value ) { return Assertions . assertNotNull ( value ) ; }
Get value if it is not null .
34
8
42,726
@ SafeVarargs @ Nonnull public static < T > T findFirstNonNull ( @ Nonnull final T ... objects ) { for ( final T obj : ensureNonNull ( objects ) ) { if ( obj != null ) { return obj ; } } throw Assertions . fail ( "Can't find non-null item in array" ) ; }
Find the first non - null value in an array and return that .
74
14
42,727
@ Nonnull public static String ensureNonNullAndNonEmpty ( @ Nullable final String value , @ Nonnull @ Constraint ( "notEmpty(X)" ) final String dflt ) { String result = value ; if ( result == null || result . isEmpty ( ) ) { assertFalse ( "Default value must not be empty" , assertNotNull ( "Default value must not be nu...
Get non - null non - empty string .
105
9
42,728
@ Nonnull @ Weight ( Weight . Unit . VARIABLE ) public static byte [ ] packData ( @ Nonnull final byte [ ] data ) { final Deflater compressor = new Deflater ( Deflater . BEST_COMPRESSION ) ; compressor . setInput ( Assertions . assertNotNull ( data ) ) ; compressor . finish ( ) ; final ByteArrayOutputStream resultData ...
Pack some binary data .
148
5
42,729
@ Nonnull @ Weight ( Weight . Unit . VARIABLE ) public static byte [ ] unpackData ( @ Nonnull final byte [ ] data ) { final Inflater decompressor = new Inflater ( ) ; decompressor . setInput ( Assertions . assertNotNull ( data ) ) ; final ByteArrayOutputStream outStream = new ByteArrayOutputStream ( data . length * 2 )...
Unpack binary data packed by the packData method .
192
11
42,730
@ Weight ( Weight . Unit . VARIABLE ) public static boolean silentSleep ( final long milliseconds ) { boolean result = true ; try { Thread . sleep ( milliseconds ) ; } catch ( InterruptedException ex ) { result = false ; Thread . currentThread ( ) . interrupt ( ) ; } return result ; }
Just suspend the current thread for defined interval in milliseconds .
66
11
42,731
@ Weight ( Weight . Unit . VARIABLE ) @ Nonnull public static StackTraceElement stackElement ( ) { final StackTraceElement [ ] allElements = Thread . currentThread ( ) . getStackTrace ( ) ; return allElements [ 2 ] ; }
Get the stack element of the method caller .
60
9
42,732
@ Weight ( Weight . Unit . VARIABLE ) public static void fireError ( @ Nonnull final String text , @ Nonnull final Throwable error ) { for ( final MetaErrorListener p : ERROR_LISTENERS ) { p . onDetectedError ( text , error ) ; } }
Send notifications to all listeners .
63
6
42,733
@ Nonnull public ExpressionTreeElement addSubTree ( @ Nonnull final ExpressionTree tree ) { assertNotEmptySlot ( ) ; final ExpressionTreeElement root = tree . getRoot ( ) ; if ( ! root . isEmptySlot ( ) ) { root . makeMaxPriority ( ) ; addElementToNextFreeSlot ( root ) ; } return this ; }
Add a tree as new child and make the maximum priority for it
76
13
42,734
public boolean replaceElement ( @ Nonnull final ExpressionTreeElement oldOne , @ Nonnull final ExpressionTreeElement newOne ) { assertNotEmptySlot ( ) ; if ( oldOne == null ) { throw new PreprocessorException ( "[Expression]The old element is null" , this . sourceString , this . includeStack , null ) ; } if ( newOne ==...
It replaces a child element
191
5
42,735
@ Nullable public ExpressionTreeElement addTreeElement ( @ Nonnull final ExpressionTreeElement element ) { assertNotEmptySlot ( ) ; assertNotNull ( "The element is null" , element ) ; final int newElementPriority = element . getPriority ( ) ; ExpressionTreeElement result = this ; final ExpressionTreeElement parentTreeE...
Add tree element with sorting operation depends on priority of the elements
382
12
42,736
public void fillArguments ( @ Nonnull @ MustNotContainNull final List < ExpressionTree > arguments ) { assertNotEmptySlot ( ) ; if ( arguments == null ) { throw new PreprocessorException ( "[Expression]Argument list is null" , this . sourceString , this . includeStack , null ) ; } if ( childElements . length != argumen...
It fills children slots from a list containing expression trees
321
10
42,737
private void addElementToNextFreeSlot ( @ Nonnull final ExpressionTreeElement element ) { if ( element == null ) { throw new PreprocessorException ( "[Expression]Element is null" , this . sourceString , this . includeStack , null ) ; } if ( childElements . length == 0 ) { throw new PreprocessorException ( "[Expression]...
Add an expression element into the next free child slot
190
10
42,738
public void postProcess ( ) { if ( ! this . isEmptySlot ( ) ) { switch ( savedItem . getExpressionItemType ( ) ) { case OPERATOR : { if ( savedItem == OPERATOR_SUB ) { if ( ! childElements [ 0 ] . isEmptySlot ( ) && childElements [ 1 ] . isEmptySlot ( ) ) { final ExpressionTreeElement left = childElements [ 0 ] ; final...
Post - processing after the tree is formed the unary minus operation will be optimized
380
16
42,739
@ Nullable public static < E extends AbstractFunction > E findForClass ( @ Nonnull final Class < E > functionClass ) { E result = null ; for ( final AbstractFunction function : getAllFunctions ( ) ) { if ( function . getClass ( ) == functionClass ) { result = functionClass . cast ( function ) ; break ; } } return resul...
Allows to find a function handler instance for its class
79
10
42,740
public void registerSpecialVariableProcessor ( @ Nonnull final SpecialVariableProcessor processor ) { assertNotNull ( "Processor is null" , processor ) ; for ( final String varName : processor . getVariableNames ( ) ) { assertNotNull ( "A Special Var name is null" , varName ) ; if ( mapVariableNameToSpecialVarProcessor...
It allows to register a special variable processor which can process some special global variables
124
15
42,741
public void logInfo ( @ Nullable final String text ) { if ( text != null && this . preprocessorLogger != null ) { this . preprocessorLogger . info ( text ) ; } }
Print an information into the current log
43
7
42,742
public void logError ( @ Nullable final String text ) { if ( text != null && this . preprocessorLogger != null ) { this . preprocessorLogger . error ( text ) ; } }
Print an information about an error into the current log
43
10
42,743
public void logDebug ( @ Nullable final String text ) { if ( text != null && this . preprocessorLogger != null ) { this . preprocessorLogger . debug ( text ) ; } }
Print some debug info into the current log
43
8
42,744
public void logWarning ( @ Nullable final String text ) { if ( text != null || this . preprocessorLogger != null ) { this . preprocessorLogger . warning ( text ) ; } }
Print an information about a warning situation into the current log
43
11
42,745
public void setSharedResource ( @ Nonnull final String name , @ Nonnull final Object obj ) { assertNotNull ( "Name is null" , name ) ; assertNotNull ( "Object is null" , obj ) ; sharedResources . put ( name , obj ) ; }
Set a shared source it is an object saved into the inside map for a name
59
16
42,746
@ Nullable public Object getSharedResource ( @ Nonnull final String name ) { assertNotNull ( "Name is null" , name ) ; return sharedResources . get ( name ) ; }
Get a shared source from inside map
41
7
42,747
@ Nullable public Object removeSharedResource ( @ Nonnull final String name ) { assertNotNull ( "Name is null" , name ) ; return sharedResources . remove ( name ) ; }
Remove a shared object from the inside map for its name
41
11
42,748
@ Nonnull public PreprocessorContext setSources ( @ Nonnull @ MustNotContainNull final List < String > folderPaths ) { this . sources . clear ( ) ; this . sources . addAll ( assertDoesntContainNull ( folderPaths ) . stream ( ) . map ( x -> new SourceFolder ( this . baseDir , x ) ) . collect ( Collectors . toList ( ) ) ...
Set source directories
93
3
42,749
@ Nonnull public PreprocessorContext setExtensions ( @ Nonnull @ MustNotContainNull final List < String > extensions ) { this . extensions = new HashSet <> ( assertDoesntContainNull ( extensions ) ) ; return this ; }
Set file extensions of files to be preprocessed it is a comma separated list
53
16
42,750
public final boolean isFileAllowedForPreprocessing ( @ Nullable final File file ) { boolean result = false ; if ( file != null && file . isFile ( ) && file . length ( ) != 0L ) { result = this . extensions . contains ( PreprocessorUtils . getFileExtension ( file ) ) ; } return result ; }
Check that a file is allowed to be preprocessed fo its extension
74
14
42,751
public final boolean isFileExcludedByExtension ( @ Nullable final File file ) { return file == null || ! file . isFile ( ) || this . excludeExtensions . contains ( PreprocessorUtils . getFileExtension ( file ) ) ; }
Check that a file is excluded from preprocessing and coping actions
55
12
42,752
@ Nonnull public PreprocessorContext setExcludeExtensions ( @ Nonnull @ MustNotContainNull final List < String > extensions ) { this . excludeExtensions = new HashSet <> ( assertDoesntContainNull ( extensions ) ) ; return this ; }
Set comma separated list of file extensions to be excluded from preprocessing
57
13
42,753
@ Nonnull public PreprocessorContext setLocalVariable ( @ Nonnull final String name , @ Nonnull final Value value ) { assertNotNull ( "Variable name is null" , name ) ; assertNotNull ( "Value is null" , value ) ; final String normalized = assertNotNull ( PreprocessorUtils . normalizeVariableName ( name ) ) ; if ( norma...
Set a local variable value
175
5
42,754
@ Nonnull public PreprocessorContext removeLocalVariable ( @ Nonnull final String name ) { assertNotNull ( "Variable name is null" , name ) ; final String normalized = assertNotNull ( PreprocessorUtils . normalizeVariableName ( name ) ) ; if ( normalized . isEmpty ( ) ) { throw makeException ( "Empty variable name" , n...
Remove a local variable value from the context .
183
9
42,755
@ Nullable public Value getLocalVariable ( @ Nullable final String name ) { if ( name == null ) { return null ; } final String normalized = assertNotNull ( PreprocessorUtils . normalizeVariableName ( name ) ) ; if ( normalized . isEmpty ( ) ) { return null ; } return localVarTable . get ( normalized ) ; }
Get a local variable value
75
5
42,756
public boolean containsLocalVariable ( @ Nullable final String name ) { if ( name == null ) { return false ; } final String normalized = assertNotNull ( PreprocessorUtils . normalizeVariableName ( name ) ) ; if ( normalized . isEmpty ( ) ) { return false ; } return localVarTable . containsKey ( normalized ) ; }
Check that a local variable for a name is presented
73
10
42,757
@ Nonnull public PreprocessorContext setGlobalVariable ( @ Nonnull final String name , @ Nonnull final Value value ) { assertNotNull ( "Variable name is null" , name ) ; final String normalizedName = assertNotNull ( PreprocessorUtils . normalizeVariableName ( name ) ) ; if ( normalizedName . isEmpty ( ) ) { throw makeE...
Set a global variable value
263
5
42,758
public boolean containsGlobalVariable ( @ Nullable final String name ) { if ( name == null ) { return false ; } final String normalized = assertNotNull ( PreprocessorUtils . normalizeVariableName ( name ) ) ; if ( normalized . isEmpty ( ) ) { return false ; } return mapVariableNameToSpecialVarProcessor . containsKey ( ...
Check that there is a named global variable in the inside storage
88
12
42,759
public boolean isGlobalVariable ( @ Nullable final String variableName ) { boolean result = false ; if ( variableName != null ) { final String normalized = PreprocessorUtils . normalizeVariableName ( variableName ) ; result = this . globalVarTable . containsKey ( normalized ) || mapVariableNameToSpecialVarProcessor . c...
Check that there is a global variable with such name .
80
11
42,760
public boolean isLocalVariable ( @ Nullable final String variableName ) { boolean result = false ; if ( variableName != null ) { final String normalized = PreprocessorUtils . normalizeVariableName ( variableName ) ; result = this . localVarTable . containsKey ( normalized ) ; } return result ; }
Check that there is a local variable with such name .
65
11
42,761
@ Nonnull public File createDestinationFileForPath ( @ Nonnull final String path ) { assertNotNull ( "Path is null" , path ) ; if ( path . isEmpty ( ) ) { throw makeException ( "File name is empty" , null ) ; } return new File ( this . getTarget ( ) , path ) ; }
It allows to create a File object for its path subject to the destination directory path
73
16
42,762
@ Nonnull public File findFileInSources ( @ Nullable final String path ) throws IOException { if ( path == null ) { throw makeException ( "File path is null" , null ) ; } if ( path . trim ( ) . isEmpty ( ) ) { throw makeException ( "File path is empty" , null ) ; } File result = null ; final TextFileDataContainer theFi...
Finds file in source folders the file can be found only inside source folders and external placement is disabled for security purposes .
615
24
42,763
@ Nonnull public static Error fail ( @ Nullable final String message ) { final AssertionError error = new AssertionError ( GetUtils . ensureNonNull ( message , "failed" ) ) ; MetaErrorListeners . fireError ( "Asserion error" , error ) ; if ( true ) { throw error ; } return error ; }
Throw assertion error for some cause
75
6
42,764
@ Nonnull public static < T > T [ ] assertDoesntContainNull ( @ Nonnull final T [ ] array ) { assertNotNull ( array ) ; for ( final T obj : array ) { if ( obj == null ) { final AssertionError error = new AssertionError ( "Array must not contain NULL" ) ; MetaErrorListeners . fireError ( "Asserion error" , error ) ; thr...
Assert that array doesn t contain null value .
99
10
42,765
public static void assertTrue ( @ Nullable final String message , final boolean condition ) { if ( ! condition ) { final AssertionError error = new AssertionError ( GetUtils . ensureNonNull ( message , "Condition must be TRUE" ) ) ; MetaErrorListeners . fireError ( error . getMessage ( ) , error ) ; throw error ; } }
Assert condition flag is TRUE . GEL will be notified about error .
79
15
42,766
public static < T > T assertEquals ( @ Nullable final T etalon , @ Nullable final T value ) { if ( etalon == null ) { assertNull ( value ) ; } else { if ( ! ( etalon == value || etalon . equals ( value ) ) ) { final AssertionError error = new AssertionError ( "Value is not equal to etalon" ) ; MetaErrorListeners . fire...
Assert that value is equal to some etalon value .
113
12
42,767
@ Nonnull public static < T extends Collection < ? > > T assertDoesntContainNull ( @ Nonnull final T collection ) { assertNotNull ( collection ) ; for ( final Object obj : collection ) { assertNotNull ( obj ) ; } return collection ; }
Assert that collection doesn t contain null value .
57
10
42,768
@ Nonnull public static < T extends Disposable > T assertNotDisposed ( @ Nonnull final T disposable ) { if ( disposable . isDisposed ( ) ) { final AlreadyDisposedError error = new AlreadyDisposedError ( "Object already disposed" ) ; MetaErrorListeners . fireError ( "Asserion error" , error ) ; throw error ; } return di...
Assert that a disposable object is not disposed .
82
10
42,769
public void addItem ( @ Nonnull final ExpressionItem item ) { if ( item == null ) { throw new PreprocessorException ( "[Expression]Item is null" , this . sources , this . includeStack , null ) ; } if ( last . isEmptySlot ( ) ) { last = new ExpressionTreeElement ( item , this . includeStack , this . sources ) ; } else {...
Add new expression item into tree
110
6
42,770
public void addTree ( @ Nonnull final ExpressionTree tree ) { assertNotNull ( "Tree is null" , tree ) ; if ( last . isEmptySlot ( ) ) { final ExpressionTreeElement thatTreeRoot = tree . getRoot ( ) ; if ( ! thatTreeRoot . isEmptySlot ( ) ) { last = thatTreeRoot ; last . makeMaxPriority ( ) ; } } else { last = last . ad...
Add whole tree as a tree element also it sets the maximum priority to the new element
99
17
42,771
@ Nonnull public ExpressionTreeElement getRoot ( ) { if ( last . isEmptySlot ( ) ) { return this . last ; } else { ExpressionTreeElement element = last ; while ( ! Thread . currentThread ( ) . isInterrupted ( ) ) { final ExpressionTreeElement next = element . getParent ( ) ; if ( next == null ) { return element ; } els...
Get the root of the tree
100
6
42,772
@ Weight ( Weight . Unit . NORMAL ) public static Deferred defer ( @ Nonnull final Deferred deferred ) { REGISTRY . get ( ) . add ( assertNotNull ( deferred ) ) ; return deferred ; }
Defer some action .
47
5
42,773
@ Weight ( Weight . Unit . NORMAL ) public static Runnable defer ( @ Nonnull final Runnable runnable ) { assertNotNull ( runnable ) ; defer ( new Deferred ( ) { private static final long serialVersionUID = 2061489024868070733L ; private final Runnable value = runnable ; @ Override public void executeDeferred ( ) throws...
Defer execution of some runnable action .
106
10
42,774
@ Weight ( Weight . Unit . NORMAL ) public static Disposable defer ( @ Nonnull final Disposable disposable ) { assertNotNull ( disposable ) ; defer ( new Deferred ( ) { private static final long serialVersionUID = 7940162959962038010L ; private final Disposable value = disposable ; @ Override public void executeDeferre...
Defer execution of some disposable object .
98
8
42,775
@ Weight ( Weight . Unit . NORMAL ) public static void cancelAllDeferredActionsGlobally ( ) { final List < Deferred > list = REGISTRY . get ( ) ; list . clear ( ) ; REGISTRY . remove ( ) ; }
Cancel all defer actions globally .
56
7
42,776
@ Weight ( value = Weight . Unit . VARIABLE , comment = "Depends on the current call stack depth" ) public static void processDeferredActions ( ) { final int stackDepth = ThreadUtils . stackDepth ( ) ; final List < Deferred > list = REGISTRY . get ( ) ; final Iterator < Deferred > iterator = list . iterator ( ) ; while...
Process all defer actions for the current stack depth level .
211
11
42,777
@ Weight ( Weight . Unit . NORMAL ) public static boolean isEmpty ( ) { final boolean result = REGISTRY . get ( ) . isEmpty ( ) ; if ( result ) { REGISTRY . remove ( ) ; } return result ; }
Check that presented defer actions for the current thread .
53
10
42,778
@ Nonnull public ExpressionTree parse ( @ Nonnull final String expressionStr , @ Nonnull final PreprocessorContext context ) throws IOException { assertNotNull ( "Expression is null" , expressionStr ) ; final PushbackReader reader = new PushbackReader ( new StringReader ( expressionStr ) ) ; final ExpressionTree result...
To parse an expression represented as a string and get a tree
170
12
42,779
@ Nullable public ExpressionItem readExpression ( @ Nonnull final PushbackReader reader , @ Nonnull final ExpressionTree tree , @ Nonnull final PreprocessorContext context , final boolean insideBracket , final boolean argument ) throws IOException { boolean working = true ; ExpressionItem result = null ; final FilePosi...
It reads an expression from a reader and fill a tree
527
11
42,780
@ Nonnull private ExpressionTree readFunction ( @ Nonnull final AbstractFunction function , @ Nonnull final PushbackReader reader , @ Nonnull final PreprocessorContext context , @ Nullable @ MustNotContainNull final FilePositionInfo [ ] includeStack , @ Nullable final String sources ) throws IOException { final Express...
The auxiliary method allows to form a function and its arguments as a tree
593
14
42,781
@ Weight ( value = Weight . Unit . VARIABLE , comment = "Depends on the current call stack depth" ) // WARNING! Don't make a call from methods of the class to not break stack depth! public static void addPoint ( @ Nonnull final String timePointName , @ Nonnull final TimeAlertListener listener ) { final List < TimeData ...
Add a named time point .
122
6
42,782
@ Weight ( value = Weight . Unit . VARIABLE , comment = "Depends on the current call stack depth" ) public static void checkPoints ( ) { final long time = System . currentTimeMillis ( ) ; final int stackDepth = ThreadUtils . stackDepth ( ) ; final List < TimeData > list = REGISTRY . get ( ) ; final Iterator < TimeData ...
Process all time points for the current stack level .
256
10
42,783
@ Weight ( value = Weight . Unit . VARIABLE , comment = "Depends on the current call stack depth" ) public static void addGuard ( @ Nullable final String alertMessage , @ Constraint ( "X>0" ) final long maxAllowedDelayInMilliseconds , @ Nullable final TimeAlertListener timeAlertListener ) { final List < TimeData > list...
WARNING! Don t make a call from methods of the class to not break stack depth!
129
18
42,784
@ Weight ( Weight . Unit . NORMAL ) public static void cancelAll ( ) { final List < TimeData > list = REGISTRY . get ( ) ; list . clear ( ) ; REGISTRY . remove ( ) ; }
Cancel all time watchers and time points globally for the current thread .
49
15
42,785
@ Weight ( value = Weight . Unit . VARIABLE , comment = "Depends on the current call stack depth" ) public static void check ( ) { final long time = System . currentTimeMillis ( ) ; final int stackDepth = ThreadUtils . stackDepth ( ) ; final List < TimeData > list = REGISTRY . get ( ) ; final Iterator < TimeData > iter...
Check all registered time watchers for time bound violations .
456
11
42,786
@ Nullable public static < E extends AbstractOperator > E findForClass ( @ Nonnull final Class < E > operatorClass ) { for ( final AbstractOperator operator : getAllOperators ( ) ) { if ( operator . getClass ( ) == operatorClass ) { return operatorClass . cast ( operator ) ; } } return null ; }
Find an operator handler for its class
73
7
42,787
@ Nonnull public String restoreStackTrace ( ) { return "THREAD_ID : " + this . threadDescriptor + this . eol + new String ( this . packed ? IOUtils . unpackData ( this . stacktrace ) : this . stacktrace , UTF8 ) ; }
Restore stack trace as a string from inside data representation .
65
12
42,788
protected void assertNotDisposed ( ) { if ( this . disposedFlag . get ( ) ) { final AlreadyDisposedError error = new AlreadyDisposedError ( "Object already disposed" ) ; MetaErrorListeners . fireError ( "Detected call to disposed object" , error ) ; throw error ; } }
Auxiliary method to ensure that the object is not disposed .
66
13
42,789
@ Nonnull public static Value evalTree ( @ Nonnull final ExpressionTree tree , @ Nonnull final PreprocessorContext context ) { final Expression exp = new Expression ( context , tree ) ; return exp . eval ( context . getPreprocessingState ( ) ) ; }
Evaluate an expression tree
55
6
42,790
public void generateArchetypesFromGithubOrganisation ( String githubOrg , File outputDir , List < String > dirs ) throws IOException { GitHub github = GitHub . connectAnonymously ( ) ; GHOrganization organization = github . getOrganization ( githubOrg ) ; Objects . notNull ( organization , "No github organisation found...
Iterates through all projects in the given github organisation and generates an archetype for it
244
16
42,791
public void generateArchetypesFromGitRepoList ( File file , File outputDir , List < String > dirs ) throws IOException { File cloneParentDir = new File ( outputDir , "../git-clones" ) ; if ( cloneParentDir . exists ( ) ) { Files . recursiveDelete ( cloneParentDir ) ; } Properties properties = new Properties ( ) ; try (...
Iterates through all projects in the given properties file adn generate an archetype for it
238
17
42,792
public void generateArchetypes ( String containerType , File baseDir , File outputDir , boolean clean , List < String > dirs ) throws IOException { LOG . debug ( "Generating archetypes from {} to {}" , baseDir . getCanonicalPath ( ) , outputDir . getCanonicalPath ( ) ) ; File [ ] files = baseDir . listFiles ( ) ; if ( ...
Iterates through all nested directories and generates archetypes for all found non - pom Maven projects .
355
21
42,793
private static boolean skipImport ( File dir ) { String [ ] files = dir . list ( ) ; if ( files != null ) { for ( String name : files ) { if ( ".skipimport" . equals ( name ) ) { return true ; } } } return false ; }
We should skip importing some quickstarts and if so we should also not create an archetype for it
59
20
42,794
private boolean fileIncludesLine ( File file , String matches ) throws IOException { for ( String line : Files . readLines ( file ) ) { String trimmed = line . trim ( ) ; if ( trimmed . equals ( matches ) ) { return true ; } } return false ; }
Checks whether the file contains specific line . Partial matches do not count .
59
15
42,795
protected void copyOtherFiles ( File projectDir , File srcDir , File outDir , Replacement replaceFn , Set < String > extraIgnorefiles ) throws IOException { if ( archetypeUtils . isValidFileToCopy ( projectDir , srcDir , extraIgnorefiles ) ) { if ( srcDir . isFile ( ) ) { copyFile ( srcDir , outDir , replaceFn ) ; } el...
Copies all other source files which are not excluded
165
10
42,796
protected boolean isSourceFile ( File file ) { String name = file . getName ( ) ; String extension = Files . getExtension ( name ) . toLowerCase ( ) ; return sourceFileExtensions . contains ( extension ) || sourceFileNames . contains ( name ) ; }
Returns true if this file is a valid source file name
58
11
42,797
protected boolean isValidRequiredPropertyName ( String name ) { return ! name . equals ( "basedir" ) && ! name . startsWith ( "project." ) && ! name . startsWith ( "pom." ) && ! name . equals ( "package" ) ; }
Returns true if this is a valid archetype property name so excluding basedir and maven project . names
58
20
42,798
protected boolean isSpecialPropertyName ( String name ) { for ( String special : specialVersions ) { if ( special . equals ( name ) ) { return true ; } } return false ; }
Returns true if its a special property name such as Camel ActiveMQ etc .
39
15
42,799
private boolean addPropertyElement ( Element element , String elementName , String textContent ) { Document doc = element . getOwnerDocument ( ) ; Element newElement = doc . createElement ( elementName ) ; newElement . setTextContent ( textContent ) ; Text textNode = doc . createTextNode ( "\n " ) ; NodeList childNodes...
Lets add a child element at the right place
233
10