idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
1,500 | public static Expression power ( Expression expression1 , Expression expression2 ) { return x ( "POWER(" + expression1 . toString ( ) + ", " + expression2 . toString ( ) + ")" ) ; } | Returned expression results in expression1 to the power of expression2 . |
1,501 | public static Expression power ( Number value1 , Number value2 ) { return power ( x ( value1 ) , x ( value2 ) ) ; } | Returned expression results in value1 to the power of value2 . |
1,502 | static String formatTimeout ( final CouchbaseRequest request , final long timeout ) { Map < String , Object > fieldMap = new HashMap < String , Object > ( ) ; fieldMap . put ( "t" , timeout ) ; if ( request != null ) { fieldMap . put ( "s" , formatServiceType ( request ) ) ; putIfNotNull ( fieldMap , "i" , request . op... | This method take the given request and produces the correct additional timeout information according to the RFC . |
1,503 | private static String formatServiceType ( final CouchbaseRequest request ) { if ( request instanceof BinaryRequest ) { return ThresholdLogReporter . SERVICE_KV ; } else if ( request instanceof QueryRequest ) { return ThresholdLogReporter . SERVICE_N1QL ; } else if ( request instanceof ViewRequest ) { return ThresholdLo... | Helper method to turn the request into the proper string service type . |
1,504 | private Observable < BucketSettings > ensureBucketIsHealthy ( final Observable < BucketSettings > input ) { return input . flatMap ( new Func1 < BucketSettings , Observable < BucketSettings > > ( ) { public Observable < BucketSettings > call ( final BucketSettings bucketSettings ) { return info ( ) . delay ( 100 , Time... | Helper method to ensure that the state of a bucket on all nodes is healthy . |
1,505 | public MutateInBuilder withDurability ( PersistTo persistTo , ReplicateTo replicateTo ) { asyncBuilder . withDurability ( persistTo , replicateTo ) ; return this ; } | Set both a persistence and replication durability constraints for the whole mutation . |
1,506 | public static Func1 < DocumentFragment < Mutation > , Boolean > getMapResultFnForSubdocMutationToBoolean ( ) { return new Func1 < DocumentFragment < Mutation > , Boolean > ( ) { public Boolean call ( DocumentFragment < Mutation > documentFragment ) { ResponseStatus status = documentFragment . status ( 0 ) ; if ( status... | Creates anonymous function for mapping document fragment result to boolean |
1,507 | public static Func1 < JsonDocument , DocumentFragment < Mutation > > getMapFullDocResultToSubDocFn ( final Mutation mutation ) { return new Func1 < JsonDocument , DocumentFragment < Mutation > > ( ) { public DocumentFragment < Mutation > call ( JsonDocument document ) { return new DocumentFragment < Mutation > ( docume... | Creates anonymous function for mapping full JsonDocument insert result to document fragment result |
1,508 | public static < E > DocumentFragment < Mutation > convertToSubDocumentResult ( ResponseStatus status , Mutation mutation , E element ) { return new DocumentFragment < Mutation > ( null , 0 , null , Collections . singletonList ( SubdocOperationResult . createResult ( null , mutation , status , element ) ) ) ; } | Useful for mapping exceptions of Multimutation or to be silent by mapping success to a valid subdocument result |
1,509 | public N1qlParams consistency ( ScanConsistency consistency ) { this . consistency = consistency ; if ( consistency == ScanConsistency . NOT_BOUNDED ) { this . scanWait = null ; } return this ; } | Sets scan consistency . |
1,510 | public N1qlParams rawParam ( String name , Object value ) { if ( this . rawParams == null ) { this . rawParams = new HashMap < String , Object > ( ) ; } if ( ! JsonValue . checkType ( value ) ) { throw new IllegalArgumentException ( "Only JSON types are supported." ) ; } rawParams . put ( name , value ) ; return this ;... | Allows to specify an arbitrary raw N1QL param . |
1,511 | private static Observable < ViewQueryResponse > passThroughOrThrow ( final ViewQueryResponse response ) { final int responseCode = response . responseCode ( ) ; if ( responseCode == 200 ) { return Observable . just ( response ) ; } return response . error ( ) . map ( new Func1 < String , ViewQueryResponse > ( ) { publi... | Helper method which decides if the response is good to pass through or needs to be retried . |
1,512 | private static boolean shouldRetry ( final int status , final String content ) { switch ( status ) { case 200 : return false ; case 404 : return analyse404Response ( content ) ; case 500 : return analyse500Response ( content ) ; case 300 : case 301 : case 302 : case 303 : case 307 : case 401 : case 408 : case 409 : cas... | Analyses status codes and checks if a retry needs to happen . |
1,513 | private static boolean analyse404Response ( final String content ) { if ( content . contains ( "\"reason\":\"missing\"" ) ) { return true ; } LOGGER . debug ( "Design document not found, error is {}" , content ) ; return false ; } | Analyses the content of a 404 response to see if it is legible for retry . |
1,514 | private static boolean analyse500Response ( final String content ) { if ( content . contains ( "error" ) && content . contains ( "{not_found, missing_named_view}" ) ) { LOGGER . debug ( "Design document not found, error is {}" , content ) ; return false ; } if ( content . contains ( "error" ) && content . contains ( "\... | Analyses the content of a 500 response to see if it is legible for retry . |
1,515 | private Bucket getCachedBucket ( final String name ) { Bucket cachedBucket = bucketCache . get ( name ) ; if ( cachedBucket != null ) { if ( cachedBucket . isClosed ( ) ) { LOGGER . debug ( "Not returning cached bucket \"{}\", because it is closed." , name ) ; bucketCache . remove ( name ) ; } else { LOGGER . debug ( "... | Helper method to get a bucket instead of opening it if it is cached already . |
1,516 | protected void writeToSerializedStream ( ObjectOutputStream stream ) throws IOException { stream . writeLong ( cas ) ; stream . writeInt ( expiry ) ; stream . writeUTF ( id ) ; stream . writeObject ( content ) ; stream . writeObject ( mutationToken ) ; } | Helper method to write the current document state to the output stream for serialization purposes . |
1,517 | @ SuppressWarnings ( "unchecked" ) protected void readFromSerializedStream ( final ObjectInputStream stream ) throws IOException , ClassNotFoundException { cas = stream . readLong ( ) ; expiry = stream . readInt ( ) ; id = stream . readUTF ( ) ; content = ( T ) stream . readObject ( ) ; mutationToken = ( MutationToken ... | Helper method to create the document from an object input stream used for serialization purposes . |
1,518 | public static View create ( String name , String map , String reduce ) { return new DefaultView ( name , map , reduce ) ; } | Create a new representation of a regular non - spatial view . |
1,519 | public static View create ( String name , String map ) { return new DefaultView ( name , map , null ) ; } | Create a new representation of a regular non - spatial view without reduce function . |
1,520 | public SearchQuery highlight ( HighlightStyle style , String ... fields ) { this . highlightStyle = style ; if ( fields != null && fields . length > 0 ) { highlightFields = fields ; } return this ; } | Configures the highlighting of matches in the response . |
1,521 | public SearchQuery consistentWith ( Document ... docs ) { this . consistency = null ; this . mutationState = MutationState . from ( docs ) ; return this ; } | Sets the consistency to consider for this FTS query to AT_PLUS and uses the mutation information from the given documents to parameterize the consistency . This replaces any consistency tuning previously set . |
1,522 | public SearchQuery consistentWith ( DocumentFragment ... fragments ) { this . consistency = null ; this . mutationState = MutationState . from ( fragments ) ; return this ; } | Sets the consistency to consider for this FTS query to AT_PLUS and uses the mutation information from the given document fragments to parameterize the consistency . This replaces any consistency tuning previously set . |
1,523 | public static SatisfiesBuilder anyIn ( String variable , Expression expression ) { return new SatisfiesBuilder ( x ( "ANY" ) , variable , expression , true ) ; } | Create an ANY comprehension with a first IN range . |
1,524 | public static SatisfiesBuilder anyAndEveryIn ( String variable , Expression expression ) { return new SatisfiesBuilder ( x ( "ANY AND EVERY" ) , variable , expression , true ) ; } | Create an ANY AND EVERY comprehension with a first IN range . |
1,525 | public static SatisfiesBuilder anyWithin ( String variable , Expression expression ) { return new SatisfiesBuilder ( x ( "ANY" ) , variable , expression , false ) ; } | Create an ANY comprehension with a first WITHIN range . |
1,526 | public static SatisfiesBuilder everyIn ( String variable , Expression expression ) { return new SatisfiesBuilder ( x ( "EVERY" ) , variable , expression , true ) ; } | Create an EVERY comprehension with a first IN range . |
1,527 | public static SatisfiesBuilder everyWithin ( String variable , Expression expression ) { return new SatisfiesBuilder ( x ( "EVERY" ) , variable , expression , false ) ; } | Create an EVERY comprehension with a first WITHIN range . |
1,528 | public static WhenBuilder arrayIn ( Expression arrayExpression , String variable , Expression expression ) { return new WhenBuilder ( x ( "ARRAY " + arrayExpression . toString ( ) + " FOR" ) , variable , expression , true ) ; } | Create an ARRAY comprehension with a first IN range . |
1,529 | public static WhenBuilder arrayWithin ( Expression arrayExpression , String variable , Expression expression ) { return new WhenBuilder ( x ( "ARRAY " + arrayExpression . toString ( ) + " FOR" ) , variable , expression , false ) ; } | Create an ARRAY comprehension with a first WITHIN range . |
1,530 | public D newDocument ( String id , int expiry , T content , long cas , MutationToken mutationToken ) { LOGGER . warn ( "This transcoder ({}) does not support mutation tokens - this method is a " + "stub and needs to be implemented on custom transcoders." , this . getClass ( ) . getSimpleName ( ) ) ; return newDocument ... | Default implementation for backwards compatibility . |
1,531 | public static Serializable deserialize ( final ByteBuf content ) throws Exception { byte [ ] serialized = new byte [ content . readableBytes ( ) ] ; content . getBytes ( 0 , serialized ) ; ByteArrayInputStream bis = new ByteArrayInputStream ( serialized ) ; ObjectInputStream is = new ObjectInputStream ( bis ) ; Seriali... | Takes the input content and deserializes it . |
1,532 | public static ByteBuf serialize ( final Serializable serializable ) throws Exception { ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; ; ObjectOutputStream os = new ObjectOutputStream ( bos ) ; os . writeObject ( serializable ) ; byte [ ] serialized = bos . toByteArray ( ) ; os . close ( ) ; bos . close ( )... | Serializes the input into a ByteBuf . |
1,533 | public static ByteBuf encodeStringAsUtf8 ( String source ) { ByteBuf target = Unpooled . buffer ( source . length ( ) ) ; ByteBufUtil . writeUtf8 ( target , source ) ; return target ; } | Helper method to encode a String into UTF8 via fast - path methods . |
1,534 | public AsyncMutateInBuilder withDurability ( PersistTo persistTo , ReplicateTo replicateTo ) { this . persistTo = persistTo ; this . replicateTo = replicateTo ; return this ; } | Set both a persistence and a replication durability constraints for the whole mutation . |
1,535 | public AsyncMutateInBuilder insertDocument ( boolean insertDocument ) { if ( this . upsertDocument && insertDocument ) { throw new IllegalArgumentException ( "Cannot set both upsertDocument and insertDocument to true" ) ; } this . insertDocument = insertDocument ; return this ; } | Set insertDocument to true if the document has to be created only if it does not exist |
1,536 | public < T > AsyncMutateInBuilder insert ( String path , T fragment , SubdocOptionsBuilder optionsBuilder ) { if ( StringUtil . isNullOrEmpty ( path ) ) { throw new IllegalArgumentException ( "Path must not be empty for insert" ) ; } this . mutationSpecs . add ( new MutationSpec ( Mutation . DICT_ADD , path , fragment ... | Insert a fragment provided the last element of the path doesn t exist . |
1,537 | public AsyncMutateInBuilder upsert ( JsonObject content ) { this . mutationSpecs . add ( new MutationSpec ( Mutation . UPSERTDOC , "" , content ) ) ; return this ; } | Upsert a full JSON document . |
1,538 | protected Observable < DocumentFragment < Mutation > > doSingleMutate ( MutationSpec spec , long timeout , TimeUnit timeUnit ) { Observable < DocumentFragment < Mutation > > mutation ; switch ( spec . type ( ) ) { case DICT_UPSERT : mutation = doSingleMutate ( spec , DICT_UPSERT_FACTORY , DICT_UPSERT_EVALUATOR , timeou... | Single operation implementations |
1,539 | private < T > Observable < DocumentFragment < T > > subdocObserveMutation ( Observable < DocumentFragment < T > > mutation , final long timeout , final TimeUnit timeUnit ) { if ( persistTo == PersistTo . NONE && replicateTo == ReplicateTo . NONE ) { return mutation ; } return mutation . flatMap ( new Func1 < DocumentFr... | utility methods for mutations |
1,540 | private Span startTracing ( String spanName ) { if ( ! environment . operationTracingEnabled ( ) ) { return null ; } Scope scope = environment . tracer ( ) . buildSpan ( spanName ) . startActive ( false ) ; Span parent = scope . span ( ) ; scope . close ( ) ; return parent ; } | Helper method to start tracing and return the span . |
1,541 | private Action0 stopTracing ( final Span parent ) { return new Action0 ( ) { public void call ( ) { if ( parent != null ) { environment . tracer ( ) . scopeManager ( ) . activate ( parent , true ) . close ( ) ; } } } ; } | Helper method to stop tracing for the parent span given . |
1,542 | private static Observable < List < String > > createMarkerDocuments ( final ClusterFacade core , final String bucket ) { return Observable . from ( FLUSH_MARKERS ) . flatMap ( new Func1 < String , Observable < UpsertResponse > > ( ) { public Observable < UpsertResponse > call ( final String id ) { return deferAndWatch ... | Helper method to create marker documents for each partition . |
1,543 | private static Observable < Boolean > initiateFlush ( final ClusterFacade core , final String bucket , final String username , final String password ) { return deferAndWatch ( new Func1 < Subscriber , Observable < FlushResponse > > ( ) { public Observable < FlushResponse > call ( Subscriber subscriber ) { FlushRequest ... | Initiates a flush request against the server . |
1,544 | private static Observable < Boolean > pollMarkerDocuments ( final ClusterFacade core , final String bucket ) { return Observable . from ( FLUSH_MARKERS ) . flatMap ( new Func1 < String , Observable < GetResponse > > ( ) { public Observable < GetResponse > call ( final String id ) { return deferAndWatch ( new Func1 < Su... | Helper method to poll the list of marker documents until all of them are gone . |
1,545 | 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 > > > ( ) { public Observable < DocumentFragment < Lookup > > call ( ) { final SubExistR... | Helper method to actually perform the subdoc exists operation . |
1,546 | 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 > > > ( ) { public Observable < DocumentFragment < Lookup > > call ( ) { final SubGetC... | Helper method to actually perform the subdoc get count operation . |
1,547 | 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 . |
1,548 | 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! |
1,549 | 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 . |
1,550 | private static Expression infix ( String infix , String left , String right ) { return new Expression ( left + " " + infix + " " + right ) ; } | Helper method to infix a string . |
1,551 | 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 . |
1,552 | 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 . |
1,553 | 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 . |
1,554 | public Observable < RestApiResponse > execute ( ) { return deferAndWatch ( new Func1 < Subscriber , Observable < ? extends RestApiResponse > > ( ) { public Observable < ? extends RestApiResponse > call ( Subscriber subscriber ) { RestApiRequest apiRequest = asRequest ( ) ; LOGGER . debug ( "Executing Cluster API reques... | Executes the API request in an asynchronous fashion . |
1,555 | 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 . |
1,556 | 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 . |
1,557 | 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 . |
1,558 | 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 . |
1,559 | 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 . |
1,560 | 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 |
1,561 | 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 . |
1,562 | 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 > ( ) ; } this . encryptionPathInfo . ... | Adds to the encryption info with optional escape for json pointer syntax |
1,563 | 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 > > ( ) { public Tuple2 < ... | Internal utility method to combine errors in an observable with their attempt number . |
1,564 | public static Date parseDate ( String strdate ) { if ( strdate == null || strdate . length ( ) == 0 ) return null ; Date result = null ; strdate = strdate . trim ( ) ; if ( strdate . length ( ) > 10 ) { if ( ( strdate . substring ( strdate . length ( ) - 5 ) . indexOf ( "+" ) == 0 || strdate . substring ( strdate . len... | Tries different date formats to parse against the given string representation to retrieve a valid Date object . |
1,565 | 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 . |
1,566 | 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 . |
1,567 | public static < T > T ensureNonNull ( final T value , final T defaultValue ) { return value == null ? Assertions . assertNotNull ( defaultValue ) : value ; } | Get value and ensure that the value is not null |
1,568 | public static < T > T ensureNonNull ( final T value ) { return Assertions . assertNotNull ( value ) ; } | Get value if it is not null . |
1,569 | public static < T > T findFirstNonNull ( 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 . |
1,570 | public static String ensureNonNullAndNonEmpty ( final String value , @ 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 null" , dflt ) . isEmpty ( ) ) ; ... | Get non - null non - empty string . |
1,571 | @ Weight ( Weight . Unit . VARIABLE ) public static byte [ ] packData ( final byte [ ] data ) { final Deflater compressor = new Deflater ( Deflater . BEST_COMPRESSION ) ; compressor . setInput ( Assertions . assertNotNull ( data ) ) ; compressor . finish ( ) ; final ByteArrayOutputStream resultData = new ByteArrayOutpu... | Pack some binary data . |
1,572 | @ Weight ( Weight . Unit . VARIABLE ) public static byte [ ] unpackData ( final byte [ ] data ) { final Inflater decompressor = new Inflater ( ) ; decompressor . setInput ( Assertions . assertNotNull ( data ) ) ; final ByteArrayOutputStream outStream = new ByteArrayOutputStream ( data . length * 2 ) ; final byte [ ] bu... | Unpack binary data packed by the packData method . |
1,573 | @ 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 . |
1,574 | @ Weight ( Weight . Unit . VARIABLE ) public static StackTraceElement stackElement ( ) { final StackTraceElement [ ] allElements = Thread . currentThread ( ) . getStackTrace ( ) ; return allElements [ 2 ] ; } | Get the stack element of the method caller . |
1,575 | @ Weight ( Weight . Unit . VARIABLE ) public static void fireError ( final String text , final Throwable error ) { for ( final MetaErrorListener p : ERROR_LISTENERS ) { p . onDetectedError ( text , error ) ; } } | Send notifications to all listeners . |
1,576 | public ExpressionTreeElement addSubTree ( 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 |
1,577 | public boolean replaceElement ( final ExpressionTreeElement oldOne , final ExpressionTreeElement newOne ) { assertNotEmptySlot ( ) ; if ( oldOne == null ) { throw new PreprocessorException ( "[Expression]The old element is null" , this . sourceString , this . includeStack , null ) ; } if ( newOne == null ) { throw new ... | It replaces a child element |
1,578 | public ExpressionTreeElement addTreeElement ( final ExpressionTreeElement element ) { assertNotEmptySlot ( ) ; assertNotNull ( "The element is null" , element ) ; final int newElementPriority = element . getPriority ( ) ; ExpressionTreeElement result = this ; final ExpressionTreeElement parentTreeElement = this . paren... | Add tree element with sorting operation depends on priority of the elements |
1,579 | public void fillArguments ( final List < ExpressionTree > arguments ) { assertNotEmptySlot ( ) ; if ( arguments == null ) { throw new PreprocessorException ( "[Expression]Argument list is null" , this . sourceString , this . includeStack , null ) ; } if ( childElements . length != arguments . size ( ) ) { throw new Pre... | It fills children slots from a list containing expression trees |
1,580 | private void addElementToNextFreeSlot ( 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]Unexpected... | Add an expression element into the next free child slot |
1,581 | 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 |
1,582 | public static < E extends AbstractFunction > E findForClass ( final Class < E > functionClass ) { E result = null ; for ( final AbstractFunction function : getAllFunctions ( ) ) { if ( function . getClass ( ) == functionClass ) { result = functionClass . cast ( function ) ; break ; } } return result ; } | Allows to find a function handler instance for its class |
1,583 | public void registerSpecialVariableProcessor ( final SpecialVariableProcessor processor ) { assertNotNull ( "Processor is null" , processor ) ; for ( final String varName : processor . getVariableNames ( ) ) { assertNotNull ( "A Special Var name is null" , varName ) ; if ( mapVariableNameToSpecialVarProcessor . contain... | It allows to register a special variable processor which can process some special global variables |
1,584 | public void logInfo ( final String text ) { if ( text != null && this . preprocessorLogger != null ) { this . preprocessorLogger . info ( text ) ; } } | Print an information into the current log |
1,585 | public void logError ( final String text ) { if ( text != null && this . preprocessorLogger != null ) { this . preprocessorLogger . error ( text ) ; } } | Print an information about an error into the current log |
1,586 | public void logDebug ( final String text ) { if ( text != null && this . preprocessorLogger != null ) { this . preprocessorLogger . debug ( text ) ; } } | Print some debug info into the current log |
1,587 | public void logWarning ( final String text ) { if ( text != null || this . preprocessorLogger != null ) { this . preprocessorLogger . warning ( text ) ; } } | Print an information about a warning situation into the current log |
1,588 | public void setSharedResource ( final String name , 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 |
1,589 | public Object getSharedResource ( final String name ) { assertNotNull ( "Name is null" , name ) ; return sharedResources . get ( name ) ; } | Get a shared source from inside map |
1,590 | public Object removeSharedResource ( final String name ) { assertNotNull ( "Name is null" , name ) ; return sharedResources . remove ( name ) ; } | Remove a shared object from the inside map for its name |
1,591 | public PreprocessorContext setSources ( final List < String > folderPaths ) { this . sources . clear ( ) ; this . sources . addAll ( assertDoesntContainNull ( folderPaths ) . stream ( ) . map ( x -> new SourceFolder ( this . baseDir , x ) ) . collect ( Collectors . toList ( ) ) ) ; return this ; } | Set source directories |
1,592 | public PreprocessorContext setExtensions ( 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 |
1,593 | public final boolean isFileAllowedForPreprocessing ( 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 |
1,594 | public final boolean isFileExcludedByExtension ( 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 |
1,595 | public PreprocessorContext setExcludeExtensions ( final List < String > extensions ) { this . excludeExtensions = new HashSet < > ( assertDoesntContainNull ( extensions ) ) ; return this ; } | Set comma separated list of file extensions to be excluded from preprocessing |
1,596 | public PreprocessorContext setLocalVariable ( final String name , final Value value ) { assertNotNull ( "Variable name is null" , name ) ; assertNotNull ( "Value is null" , value ) ; final String normalized = assertNotNull ( PreprocessorUtils . normalizeVariableName ( name ) ) ; if ( normalized . isEmpty ( ) ) { throw ... | Set a local variable value |
1,597 | public PreprocessorContext removeLocalVariable ( final String name ) { assertNotNull ( "Variable name is null" , name ) ; final String normalized = assertNotNull ( PreprocessorUtils . normalizeVariableName ( name ) ) ; if ( normalized . isEmpty ( ) ) { throw makeException ( "Empty variable name" , null ) ; } if ( mapVa... | Remove a local variable value from the context . |
1,598 | public Value getLocalVariable ( 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 |
1,599 | public boolean containsLocalVariable ( 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.