idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
32,900
private JcrSession openSession ( ) throws ResourceException { try { Repository repo = mcf . getRepository ( ) ; Session s = repo . login ( cri . getCredentials ( ) , cri . getWorkspace ( ) ) ; return ( JcrSession ) s ; } catch ( RepositoryException e ) { throw new ResourceException ( "Failed to create session: " + e . getMessage ( ) , e ) ; } }
Create a new session .
97
5
32,901
@ Override public void destroy ( ) throws ResourceException { LOGGER . debug ( "Shutting down connection to repo '{0}'" , mcf . getRepositoryURL ( ) ) ; this . session . logout ( ) ; this . handles . clear ( ) ; }
Destroys the physical connection to the underlying resource manager .
59
12
32,902
@ Override public ManagedConnectionMetaData getMetaData ( ) throws ResourceException { try { return new JcrManagedConnectionMetaData ( mcf . getRepository ( ) , session ) ; } catch ( Exception e ) { throw new ResourceException ( e ) ; } }
Gets the metadata information for this connection s underlying EIS resource manager instance .
59
16
32,903
public Session getSession ( JcrSessionHandle handle ) { if ( ( handles . size ( ) > 0 ) && ( handles . get ( 0 ) == handle ) ) { return session ; } throw new java . lang . IllegalStateException ( "Inactive logical session handle called" ) ; }
Searches session object using handle .
61
8
32,904
public static String combineLines ( String [ ] lines , char separator ) { if ( lines == null || lines . length == 0 ) return "" ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i != lines . length ; ++ i ) { String line = lines [ i ] ; if ( i != 0 ) sb . append ( separator ) ; sb . append ( line ) ; } return sb . toString ( ) ; }
Combine the lines into a single string using the supplied separator as the delimiter .
102
18
32,905
public static List < String > splitLines ( final String content ) { if ( content == null || content . length ( ) == 0 ) return Collections . emptyList ( ) ; String [ ] lines = content . split ( "[\\r]?\\n" ) ; return Arrays . asList ( lines ) ; }
Split the supplied content into lines returning each line as an element in the returned list .
67
17
32,906
public static String createString ( final char charToRepeat , int numberOfRepeats ) { assert numberOfRepeats >= 0 ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < numberOfRepeats ; ++ i ) { sb . append ( charToRepeat ) ; } return sb . toString ( ) ; }
Create a new string containing the specified character repeated a specific number of times .
77
15
32,907
public static String justify ( Justify justify , String str , final int width , char padWithChar ) { switch ( justify ) { case LEFT : return justifyLeft ( str , width , padWithChar ) ; case RIGHT : return justifyRight ( str , width , padWithChar ) ; case CENTER : return justifyCenter ( str , width , padWithChar ) ; } assert false ; return null ; }
Justify the contents of the string .
85
8
32,908
public static String justifyRight ( String str , final int width , char padWithChar ) { assert width > 0 ; // Trim the leading and trailing whitespace ... str = str != null ? str . trim ( ) : "" ; final int length = str . length ( ) ; int addChars = width - length ; if ( addChars < 0 ) { // truncate the first characters, keep the last return str . subSequence ( length - width , length ) . toString ( ) ; } // Prepend the whitespace ... final StringBuilder sb = new StringBuilder ( ) ; while ( addChars > 0 ) { sb . append ( padWithChar ) ; -- addChars ; } // Write the content ... sb . append ( str ) ; return sb . toString ( ) ; }
Right justify the contents of the string ensuring that the string ends at the last character . If the supplied string is longer than the desired width the leading characters are removed so that the last character in the supplied string at the last position . If the supplied string is shorter than the desired width the padding character is inserted one or more times such that the last character in the supplied string appears as the last character in the resulting string and that the length matches that specified .
173
91
32,909
public static String justifyLeft ( String str , final int width , char padWithChar ) { return justifyLeft ( str , width , padWithChar , true ) ; }
Left justify the contents of the string ensuring that the supplied string begins at the first character and that the resulting string is of the desired length . If the supplied string is longer than the desired width it is truncated to the specified length . If the supplied string is shorter than the desired width the padding character is added to the end of the string one or more times such that the length is that specified . All leading and trailing whitespace is removed .
35
89
32,910
public static String justifyCenter ( String str , final int width , char padWithChar ) { // Trim the leading and trailing whitespace ... str = str != null ? str . trim ( ) : "" ; int addChars = width - str . length ( ) ; if ( addChars < 0 ) { // truncate return str . subSequence ( 0 , width ) . toString ( ) ; } // Write the content ... int prependNumber = addChars / 2 ; int appendNumber = prependNumber ; if ( ( prependNumber + appendNumber ) != addChars ) { ++ prependNumber ; } final StringBuilder sb = new StringBuilder ( ) ; // Prepend the pad character(s) ... while ( prependNumber > 0 ) { sb . append ( padWithChar ) ; -- prependNumber ; } // Add the actual content sb . append ( str ) ; // Append the pad character(s) ... while ( appendNumber > 0 ) { sb . append ( padWithChar ) ; -- appendNumber ; } return sb . toString ( ) ; }
Center the contents of the string . If the supplied string is longer than the desired width it is truncated to the specified length . If the supplied string is shorter than the desired width padding characters are added to the beginning and end of the string such that the length is that specified ; one additional padding character is prepended if required . All leading and trailing whitespace is removed before centering .
235
78
32,911
public static String truncate ( Object obj , int maxLength , String suffix ) { CheckArg . isNonNegative ( maxLength , "maxLength" ) ; if ( obj == null || maxLength == 0 ) { return "" ; } String str = obj . toString ( ) ; if ( str . length ( ) <= maxLength ) return str ; if ( suffix == null ) suffix = "..." ; int maxNumChars = maxLength - suffix . length ( ) ; if ( maxNumChars < 0 ) { // Then the max length is actually shorter than the suffix ... str = suffix . substring ( 0 , maxLength ) ; } else if ( str . length ( ) > maxNumChars ) { str = str . substring ( 0 , maxNumChars ) + suffix ; } return str ; }
Truncate the supplied string to be no more than the specified length . This method returns an empty string if the supplied object is null .
173
28
32,912
public static String getStackTrace ( Throwable throwable ) { if ( throwable == null ) return null ; final ByteArrayOutputStream bas = new ByteArrayOutputStream ( ) ; final PrintWriter pw = new PrintWriter ( bas ) ; throwable . printStackTrace ( pw ) ; pw . close ( ) ; return bas . toString ( ) ; }
Get the stack trace of the supplied exception .
80
9
32,913
public static String normalize ( String text ) { CheckArg . isNotNull ( text , "text" ) ; // This could be much more efficient. return NORMALIZE_PATTERN . matcher ( text ) . replaceAll ( " " ) . trim ( ) ; }
Removes leading and trailing whitespace from the supplied text and reduces other consecutive whitespace characters to a single space . Whitespace includes line - feeds .
59
30
32,914
public static String getHexString ( byte [ ] bytes ) { try { byte [ ] hex = new byte [ 2 * bytes . length ] ; int index = 0 ; for ( byte b : bytes ) { int v = b & 0xFF ; hex [ index ++ ] = HEX_CHAR_TABLE [ v >>> 4 ] ; hex [ index ++ ] = HEX_CHAR_TABLE [ v & 0xF ] ; } return new String ( hex , "ASCII" ) ; } catch ( UnsupportedEncodingException e ) { BigInteger bi = new BigInteger ( 1 , bytes ) ; return String . format ( "%0" + ( bytes . length << 1 ) + "x" , bi ) ; } }
Get the hexadecimal string representation of the supplied byte array .
154
14
32,915
public static boolean containsAnyOf ( String str , char ... chars ) { CharacterIterator iter = new StringCharacterIterator ( str ) ; for ( char c = iter . first ( ) ; c != CharacterIterator . DONE ; c = iter . next ( ) ) { for ( char match : chars ) { if ( c == match ) return true ; } } return false ; }
Return whether the supplied string contains any of the supplied characters .
78
12
32,916
protected void refreshFromSystem ( ) { try { // Re-read and re-register all of the namespaces ... SessionCache systemCache = repository . createSystemSession ( repository . context ( ) , false ) ; SystemContent system = new SystemContent ( systemCache ) ; CachedNode locks = system . locksNode ( ) ; MutableCachedNode mutableLocks = null ; Set < NodeKey > corruptedLocks = new HashSet <> ( ) ; for ( ChildReference ref : locks . getChildReferences ( systemCache ) ) { CachedNode node = systemCache . getNode ( ref ) ; if ( node == null ) { if ( mutableLocks == null ) { mutableLocks = system . mutableLocksNode ( ) ; } NodeKey lockKey = ref . getKey ( ) ; logger . warn ( JcrI18n . lockNotFound , lockKey ) ; mutableLocks . removeChild ( systemCache , lockKey ) ; corruptedLocks . add ( lockKey ) ; continue ; } ModeShapeLock lock = new ModeShapeLock ( node , systemCache ) ; locksByNodeKey . put ( lock . getLockedNodeKey ( ) , lock ) ; } if ( mutableLocks != null ) { system . save ( ) ; for ( Iterator < Map . Entry < NodeKey , ModeShapeLock > > locksIterator = locksByNodeKey . entrySet ( ) . iterator ( ) ; locksIterator . hasNext ( ) ; ) { NodeKey lockKey = locksIterator . next ( ) . getValue ( ) . getLockKey ( ) ; if ( corruptedLocks . contains ( lockKey ) ) { locksIterator . remove ( ) ; } } } } catch ( Throwable e ) { logger . error ( e , JcrI18n . errorRefreshingLocks , repository . name ( ) ) ; } }
Refresh the locks from the stored representation .
398
9
32,917
protected void record ( final Sequencer . Context context , final char [ ] sourceCode , final Node outputNode ) throws Exception { if ( ( sourceCode == null ) || ( sourceCode . length == 0 ) ) { LOGGER . debug ( "No source code was found for output node {0}" , outputNode . getName ( ) ) ; return ; } this . context = context ; this . sourceCode = new String ( sourceCode ) ; this . compilationUnit = ( CompilationUnit ) CompilationUnitParser . runJLS3Conversion ( sourceCode , true ) ; outputNode . addMixin ( ClassFileSequencerLexicon . COMPILATION_UNIT ) ; record ( this . compilationUnit , outputNode ) ; }
Convert the compilation unit into JCR nodes .
155
10
32,918
private String getTypeName ( Type type ) { CheckArg . isNotNull ( type , "type" ) ; if ( type . isPrimitiveType ( ) ) { PrimitiveType primitiveType = ( PrimitiveType ) type ; return primitiveType . getPrimitiveTypeCode ( ) . toString ( ) ; } if ( type . isSimpleType ( ) ) { SimpleType simpleType = ( SimpleType ) type ; return JavaMetadataUtil . getName ( simpleType . getName ( ) ) ; } if ( type . isParameterizedType ( ) ) { ParameterizedType parameterizedType = ( ParameterizedType ) type ; return getTypeName ( parameterizedType . getType ( ) ) ; } if ( type . isArrayType ( ) ) { ArrayType arrayType = ( ArrayType ) type ; // the element type is never an array type Type elementType = arrayType . getElementType ( ) ; if ( elementType . isPrimitiveType ( ) ) { return ( ( PrimitiveType ) elementType ) . getPrimitiveTypeCode ( ) . toString ( ) ; } // can't be an array type if ( elementType . isSimpleType ( ) ) { return JavaMetadataUtil . getName ( ( ( SimpleType ) elementType ) . getName ( ) ) ; } } return null ; }
Extract the type name
285
5
32,919
public static DatabaseType determineType ( DatabaseMetaData metaData ) throws SQLException { metaData = Objects . requireNonNull ( metaData , "metaData cannot be null" ) ; int majorVersion = metaData . getDatabaseMajorVersion ( ) ; int minorVersion = metaData . getDatabaseMinorVersion ( ) ; String name = metaData . getDatabaseProductName ( ) . toLowerCase ( ) ; if ( name . contains ( "mysql" ) ) { return new DatabaseType ( DatabaseType . Name . MYSQL , majorVersion , minorVersion ) ; } else if ( name . contains ( "postgres" ) ) { return new DatabaseType ( DatabaseType . Name . POSTGRES , majorVersion , minorVersion ) ; } else if ( name . contains ( "derby" ) ) { return new DatabaseType ( DatabaseType . Name . DERBY , majorVersion , minorVersion ) ; } else if ( name . contains ( "hsql" ) || name . toLowerCase ( ) . contains ( "hypersonic" ) ) { return new DatabaseType ( DatabaseType . Name . HSQL , majorVersion , minorVersion ) ; } else if ( name . contains ( "h2" ) ) { return new DatabaseType ( DatabaseType . Name . H2 , majorVersion , minorVersion ) ; } else if ( name . contains ( "sqlite" ) ) { return new DatabaseType ( DatabaseType . Name . SQLITE , majorVersion , minorVersion ) ; } else if ( name . contains ( "db2" ) ) { return new DatabaseType ( DatabaseType . Name . DB2 , majorVersion , minorVersion ) ; } else if ( name . contains ( "informix" ) ) { return new DatabaseType ( DatabaseType . Name . INFORMIX , majorVersion , minorVersion ) ; } else if ( name . contains ( "interbase" ) ) { return new DatabaseType ( DatabaseType . Name . INTERBASE , majorVersion , minorVersion ) ; } else if ( name . contains ( "firebird" ) ) { return new DatabaseType ( DatabaseType . Name . FIREBIRD , majorVersion , minorVersion ) ; } else if ( name . contains ( "sqlserver" ) || name . toLowerCase ( ) . contains ( "microsoft" ) ) { return new DatabaseType ( DatabaseType . Name . SQLSERVER , majorVersion , minorVersion ) ; } else if ( name . contains ( "access" ) ) { return new DatabaseType ( DatabaseType . Name . ACCESS , majorVersion , minorVersion ) ; } else if ( name . contains ( "oracle" ) ) { return new DatabaseType ( DatabaseType . Name . ORACLE , majorVersion , minorVersion ) ; } else if ( name . contains ( "adaptive" ) ) { return new DatabaseType ( DatabaseType . Name . SYBASE , majorVersion , minorVersion ) ; } else if ( name . contains ( "cassandra" ) ) { return new DatabaseType ( DatabaseType . Name . CASSANDRA , majorVersion , minorVersion ) ; } return DatabaseType . UNKNOWN ; }
Determine the type of a database based on the metadata information from the DB metadata .
665
18
32,920
@ SuppressWarnings ( "unchecked" ) public synchronized void addConsumer ( MessageConsumer < ? extends Serializable > consumer ) { consumers . add ( ( MessageConsumer < Serializable > ) consumer ) ; }
Adds a new message consumer to this service .
45
9
32,921
public synchronized boolean shutdown ( ) { if ( channel == null ) { return false ; } Address address = channel . getAddress ( ) ; LOGGER . debug ( "{0} shutting down clustering service..." , address ) ; consumers . clear ( ) ; // Mark this as not accepting any more ... isOpen . set ( false ) ; try { // Disconnect from the channel and close it ... channel . disconnect ( ) ; channel . removeChannelListener ( listener ) ; channel . setReceiver ( null ) ; channel . close ( ) ; LOGGER . debug ( "{0} successfully closed main channel" , address ) ; } finally { channel = null ; } membersInCluster . set ( 1 ) ; return true ; }
Shuts down and clears resources held by this service .
150
11
32,922
public boolean sendMessage ( Serializable payload ) { if ( ! isOpen ( ) || ! multipleMembersInCluster ( ) ) { return false ; } if ( LOGGER . isDebugEnabled ( ) ) { LOGGER . debug ( "{0} SENDING {1} " , toString ( ) , payload ) ; } try { byte [ ] messageData = toByteArray ( payload ) ; Message jgMessage = new Message ( null , channel . getAddress ( ) , messageData ) ; channel . send ( jgMessage ) ; return true ; } catch ( Exception e ) { // Something went wrong here throw new SystemFailureException ( ClusteringI18n . errorSendingMessage . text ( clusterName ( ) ) , e ) ; } }
Sends a message of a given type across a cluster .
160
12
32,923
public static ClusteringService startStandalone ( String clusterName , String jgroupsConfig ) { ClusteringService clusteringService = new StandaloneClusteringService ( clusterName , jgroupsConfig ) ; clusteringService . init ( ) ; return clusteringService ; }
Starts a standalone clustering service which in turn will start & connect its own JGroup channel .
59
20
32,924
public static ClusteringService startStandalone ( String clusterName , Channel channel ) { ClusteringService clusteringService = new StandaloneClusteringService ( clusterName , channel ) ; clusteringService . init ( ) ; return clusteringService ; }
Starts a standalone clustering service which uses the supplied channel .
55
13
32,925
public static ClusteringService startForked ( Channel mainChannel ) { if ( ! mainChannel . isConnected ( ) ) { throw new IllegalStateException ( ClusteringI18n . channelNotConnected . text ( ) ) ; } ClusteringService clusteringService = new ForkedClusteringService ( mainChannel ) ; clusteringService . init ( ) ; return clusteringService ; }
Starts a new clustering service by forking a channel of an existing JGroups channel .
87
20
32,926
public boolean isNotOneOf ( Type first , Type ... rest ) { return isNotOneOf ( EnumSet . of ( first , rest ) ) ; }
Return true if this node s type does not match any of the supplied types
34
15
32,927
public boolean isOneOf ( Type first , Type ... rest ) { return isOneOf ( EnumSet . of ( first , rest ) ) ; }
Return true if this node s type matches one of the supplied types
32
13
32,928
public boolean isBelow ( PlanNode possibleAncestor ) { PlanNode node = this ; while ( node != null ) { if ( node == possibleAncestor ) return true ; node = node . getParent ( ) ; } return false ; }
Determine if the supplied node is an ancestor of this node .
52
14
32,929
public boolean replaceChild ( PlanNode child , PlanNode replacement ) { assert child != null ; assert replacement != null ; if ( child . parent == this ) { int i = this . children . indexOf ( child ) ; if ( replacement . parent == this ) { // Swapping the positions ... int j = this . children . indexOf ( replacement ) ; this . children . set ( i , replacement ) ; this . children . set ( j , child ) ; return true ; } // The replacement is not yet a child ... this . children . set ( i , replacement ) ; replacement . removeFromParent ( ) ; replacement . parent = this ; child . parent = null ; return true ; } return false ; }
Replace the supplied child with another node . If the replacement is already a child of this node this method effectively swaps the position of the child and replacement nodes .
148
32
32,930
public Set < Property > getPropertyKeys ( ) { return nodeProperties != null ? nodeProperties . keySet ( ) : Collections . < Property > emptySet ( ) ; }
Get the keys for the property values that are set on this node .
38
14
32,931
public Object getProperty ( Property propertyId ) { return nodeProperties != null ? nodeProperties . get ( propertyId ) : null ; }
Get the node s value for this supplied property .
30
10
32,932
public < ValueType > ValueType getProperty ( Property propertyId , Class < ValueType > type ) { return nodeProperties != null ? type . cast ( nodeProperties . get ( propertyId ) ) : null ; }
Get the node s value for this supplied property casting the result to the supplied type .
47
17
32,933
public Object setProperty ( Property propertyId , Object value ) { if ( value == null ) { // Removing this property ... return nodeProperties != null ? nodeProperties . remove ( propertyId ) : null ; } // Otherwise, we're adding the property if ( nodeProperties == null ) nodeProperties = new TreeMap < Property , Object > ( ) ; return nodeProperties . put ( propertyId , value ) ; }
Set the node s value for the supplied property .
91
10
32,934
public Object removeProperty ( Object propertyId ) { return nodeProperties != null ? nodeProperties . remove ( propertyId ) : null ; }
Remove the node s value for this supplied property .
30
10
32,935
public boolean hasCollectionProperty ( Property propertyId ) { Object value = getProperty ( propertyId ) ; return ( value instanceof Collection < ? > && ! ( ( Collection < ? > ) value ) . isEmpty ( ) ) ; }
Indicates if there is a non - null and non - empty Collection value for the property .
49
19
32,936
public boolean replaceSelector ( SelectorName original , SelectorName replacement ) { if ( original != null && replacement != null ) { if ( selectors . remove ( original ) ) { selectors . add ( replacement ) ; return true ; } } return false ; }
Replace this plan s use of the named selector with the replacement . to this plan node . This method does nothing if either of the supplied selector names is null or if the supplied original selector name is not found .
56
43
32,937
public List < PlanNode > findAllFirstNodesAtOrBelow ( Type typeToFind ) { List < PlanNode > results = new LinkedList < PlanNode > ( ) ; LinkedList < PlanNode > queue = new LinkedList < PlanNode > ( ) ; queue . add ( this ) ; while ( ! queue . isEmpty ( ) ) { PlanNode aNode = queue . poll ( ) ; if ( aNode . getType ( ) == Type . PROJECT ) { results . add ( aNode ) ; } else { queue . addAll ( 0 , aNode . getChildren ( ) ) ; } } return results ; }
Look at nodes below this node searching for nodes that have the supplied type . As soon as a node with a matching type is found then no other nodes below it are searched .
137
35
32,938
public void apply ( Traversal order , final Operation operation , final Type type ) { apply ( order , new Operation ( ) { @ Override public void apply ( PlanNode node ) { if ( node . getType ( ) == type ) operation . apply ( node ) ; } } ) ; }
Walk the plan tree starting in the specified traversal order and apply the supplied operation to every plan node with a type that matches the given type .
62
29
32,939
public void apply ( Traversal order , Operation operation ) { assert order != null ; switch ( order ) { case LEVEL_ORDER : operation . apply ( this ) ; applyLevelOrder ( order , operation ) ; break ; case PRE_ORDER : operation . apply ( this ) ; for ( PlanNode child : this ) { child . apply ( order , operation ) ; } break ; case POST_ORDER : for ( PlanNode child : this ) { child . apply ( order , operation ) ; } operation . apply ( this ) ; break ; } }
Walk the plan tree starting in the specified traversal order and apply the supplied operation to every plan node .
117
21
32,940
public void applyToAncestorsUpTo ( Type stopType , Operation operation ) { PlanNode ancestor = getParent ( ) ; while ( ancestor != null ) { if ( ancestor . getType ( ) == stopType ) return ; operation . apply ( ancestor ) ; ancestor = ancestor . getParent ( ) ; } }
Apply the operation to all ancestor nodes below a node of the given type .
66
15
32,941
public void applyToAncestors ( Operation operation ) { PlanNode ancestor = getParent ( ) ; while ( ancestor != null ) { operation . apply ( ancestor ) ; ancestor = ancestor . getParent ( ) ; } }
Apply the operation to all ancestor nodes .
46
8
32,942
public List < PlanNode > findAllAtOrBelow ( Traversal order ) { assert order != null ; LinkedList < PlanNode > results = new LinkedList < PlanNode > ( ) ; LinkedList < PlanNode > queue = new LinkedList < PlanNode > ( ) ; queue . add ( this ) ; while ( ! queue . isEmpty ( ) ) { PlanNode aNode = queue . poll ( ) ; switch ( order ) { case LEVEL_ORDER : results . add ( aNode ) ; queue . addAll ( aNode . getChildren ( ) ) ; break ; case PRE_ORDER : results . add ( aNode ) ; queue . addAll ( 0 , aNode . getChildren ( ) ) ; break ; case POST_ORDER : queue . addAll ( 0 , aNode . getChildren ( ) ) ; results . addFirst ( aNode ) ; break ; } } return results ; }
Find all of the nodes that are at or below this node .
198
13
32,943
public List < PlanNode > findAllAtOrBelow ( Traversal order , Type typeToFind ) { return findAllAtOrBelow ( order , EnumSet . of ( typeToFind ) ) ; }
Find all of the nodes of the specified type that are at or below this node .
45
17
32,944
public PlanNode findAtOrBelow ( Traversal order , Type typeToFind ) { return findAtOrBelow ( order , EnumSet . of ( typeToFind ) ) ; }
Find the first node with the specified type that are at or below this node .
40
16
32,945
public String findJcrName ( String cmisName ) { for ( Relation aList : list ) { if ( aList . cmisName . equals ( cmisName ) ) { return aList . jcrName ; } } return cmisName ; }
Gets the name of the given property in JCR domain .
56
13
32,946
public String findCmisName ( String jcrName ) { for ( Relation aList : list ) { if ( aList . jcrName . equals ( jcrName ) ) { return aList . cmisName ; } } return jcrName ; }
Gets the name of the given property in CMIS domain .
56
13
32,947
public Term parse ( String fullTextSearchExpression ) { CheckArg . isNotNull ( fullTextSearchExpression , "fullTextSearchExpression" ) ; Tokenizer tokenizer = new TermTokenizer ( ) ; TokenStream stream = new TokenStream ( fullTextSearchExpression , tokenizer , false ) ; return parse ( stream . start ( ) ) ; }
Parse the full - text search criteria given in the supplied string .
77
14
32,948
public Term parse ( TokenStream tokens ) { CheckArg . isNotNull ( tokens , "tokens" ) ; List < Term > terms = new ArrayList < Term > ( ) ; do { Term term = parseDisjunctedTerms ( tokens ) ; if ( term == null ) break ; terms . add ( term ) ; } while ( tokens . canConsume ( "OR" ) ) ; if ( terms . isEmpty ( ) ) return null ; return terms . size ( ) > 1 ? new Disjunction ( terms ) : terms . iterator ( ) . next ( ) ; }
Parse the full - text search criteria from the supplied token stream . This method is useful when the full - text search expression is included in other content .
126
31
32,949
protected static String requireActiveTransaction ( ) { return Optional . ofNullable ( ACTIVE_TX_ID . get ( ) ) . orElseThrow ( ( ) -> new RelationalProviderException ( RelationalProviderI18n . threadNotAssociatedWithTransaction , Thread . currentThread ( ) . getName ( ) ) ) ; }
Requires that an active transaction exists for the current calling thread .
69
12
32,950
public static NodeSequence emptySequence ( final int width ) { assert width >= 0 ; return new NodeSequence ( ) { @ Override public int width ( ) { return width ; } @ Override public Batch nextBatch ( ) { return null ; } @ Override public long getRowCount ( ) { return 0 ; } @ Override public boolean isEmpty ( ) { return true ; } @ Override public void close ( ) { } @ Override public String toString ( ) { return "(empty-sequence width=" + width ( ) + ")" ; } } ; }
Get an empty node sequence .
124
6
32,951
public static Batch emptyBatch ( final String workspaceName , final int width ) { assert width > 0 ; return new Batch ( ) { @ Override public boolean hasNext ( ) { return false ; } @ Override public String getWorkspaceName ( ) { return workspaceName ; } @ Override public int width ( ) { return width ; } @ Override public long rowCount ( ) { return 0 ; } @ Override public boolean isEmpty ( ) { return true ; } @ Override public void nextRow ( ) { throw new NoSuchElementException ( ) ; } @ Override public CachedNode getNode ( ) { throw new NoSuchElementException ( ) ; } @ Override public CachedNode getNode ( int index ) { throw new NoSuchElementException ( ) ; } @ Override public float getScore ( ) { throw new NoSuchElementException ( ) ; } @ Override public float getScore ( int index ) { throw new NoSuchElementException ( ) ; } @ Override public String toString ( ) { return "(empty-batch width=" + width ( ) + ")" ; } } ; }
Get a batch of nodes that is empty .
239
9
32,952
public static NodeSequence withBatch ( final Batch sequence ) { if ( sequence == null ) return emptySequence ( 1 ) ; return new NodeSequence ( ) { private boolean done = false ; @ Override public int width ( ) { return sequence . width ( ) ; } @ Override public long getRowCount ( ) { return sequence . rowCount ( ) ; } @ Override public boolean isEmpty ( ) { return sequence . isEmpty ( ) ; } @ Override public Batch nextBatch ( ) { if ( done ) return null ; done = true ; return sequence ; } @ Override public void close ( ) { } @ Override public String toString ( ) { return "(sequence-with-batch width=" + width ( ) + " " + sequence + " )" ; } } ; }
Create a sequence of nodes that returns the supplied single batch of nodes .
173
14
32,953
public static NodeSequence limit ( NodeSequence sequence , Limit limitAndOffset ) { if ( sequence == null ) return emptySequence ( 0 ) ; if ( limitAndOffset != null && ! limitAndOffset . isUnlimited ( ) ) { final int limit = limitAndOffset . getRowLimit ( ) ; // Perform the skip first ... if ( limitAndOffset . isOffset ( ) ) { sequence = skip ( sequence , limitAndOffset . getOffset ( ) ) ; } // And then the offset ... if ( limit != Integer . MAX_VALUE ) { sequence = limit ( sequence , limit ) ; } } return sequence ; }
Create a sequence of nodes that skips a specified number of nodes before returning any nodes and that limits the number of nodes returned .
133
26
32,954
public static NodeSequence limit ( final NodeSequence sequence , final long maxRows ) { if ( sequence == null ) return emptySequence ( 0 ) ; if ( maxRows <= 0 ) return emptySequence ( sequence . width ( ) ) ; if ( sequence . isEmpty ( ) ) return sequence ; return new NodeSequence ( ) { private LimitBatch lastLimitBatch = null ; protected long rowsRemaining = maxRows ; @ Override public long getRowCount ( ) { long count = sequence . getRowCount ( ) ; if ( count < 0L ) return - 1 ; return count < maxRows ? count : maxRows ; } @ Override public int width ( ) { return sequence . width ( ) ; } @ Override public boolean isEmpty ( ) { return false ; } @ Override public Batch nextBatch ( ) { if ( rowsRemaining <= 0 ) return null ; if ( lastLimitBatch != null ) { long rowsUsed = lastLimitBatch . rowsUsed ( ) ; if ( rowsUsed < rowsRemaining ) { rowsRemaining -= rowsUsed ; } else { return null ; } } final Batch next = sequence . nextBatch ( ) ; if ( next == null ) return null ; long size = next . rowCount ( ) ; boolean sizeKnown = false ; if ( size >= 0 ) { // The size is known ... sizeKnown = true ; if ( size <= rowsRemaining ) { // The whole batch can be returned ... rowsRemaining -= size ; return next ; } // Only the first part of this batch is okay ... assert size > rowsRemaining ; // just continue ... } // The size is not known or larger than rowsRemaining, so we return a batch that exposes only the number we need long limit = rowsRemaining ; lastLimitBatch = new LimitBatch ( next , limit , sizeKnown ) ; return lastLimitBatch ; } @ Override public void close ( ) { sequence . close ( ) ; } @ Override public String toString ( ) { return "(limit " + maxRows + " " + sequence + " )" ; } } ; }
Create a sequence of nodes that returns at most the supplied number of rows .
456
15
32,955
public static NodeSequence skip ( final NodeSequence sequence , final int skip ) { if ( sequence == null ) return emptySequence ( 0 ) ; if ( skip <= 0 || sequence . isEmpty ( ) ) return sequence ; return new NodeSequence ( ) { private int rowsToSkip = skip ; @ Override public long getRowCount ( ) { long count = sequence . getRowCount ( ) ; if ( count < skip ) return - 1 ; return count == skip ? 0 : count - skip ; } @ Override public int width ( ) { return sequence . width ( ) ; } @ Override public boolean isEmpty ( ) { return false ; } @ Override public Batch nextBatch ( ) { Batch next = sequence . nextBatch ( ) ; while ( next != null ) { if ( rowsToSkip <= 0 ) return next ; long size = next . rowCount ( ) ; if ( size >= 0 ) { // The size of this batch is known ... if ( size == 0 ) { // but it is empty, so just skip this batch altogether ... next = sequence . nextBatch ( ) ; continue ; } if ( size <= rowsToSkip ) { // The entire batch is smaller than the number of rows we're skipping, so skip the whole batch ... rowsToSkip -= size ; next = sequence . nextBatch ( ) ; continue ; } // Otherwise, we have to skip the first `rowsToSkip` rows in the batch ... for ( int i = 0 ; i != rowsToSkip ; ++ i ) { if ( ! next . hasNext ( ) ) return null ; next . nextRow ( ) ; -- size ; } rowsToSkip = 0 ; return new AlternateSizeBatch ( next , size ) ; } // Otherwise the size of the batch is not known, so we need to skip the rows individually ... while ( rowsToSkip > 0 && next . hasNext ( ) ) { next . nextRow ( ) ; -- rowsToSkip ; } if ( next . hasNext ( ) ) return next ; // Otherwise, we've used up all of this batch so just continue to the next ... next = sequence . nextBatch ( ) ; } return next ; } @ Override public void close ( ) { sequence . close ( ) ; } @ Override public String toString ( ) { return "(skip " + skip + " " + sequence + " )" ; } } ; }
Create a sequence of nodes that skips a specified number of rows before returning any rows .
508
18
32,956
public static NodeSequence filter ( final NodeSequence sequence , final RowFilter filter ) { if ( sequence == null ) return emptySequence ( 0 ) ; if ( filter == null || sequence . isEmpty ( ) ) return sequence ; return new NodeSequence ( ) { @ Override public long getRowCount ( ) { // we don't know how the filter affects the row count ... return - 1 ; } @ Override public int width ( ) { return sequence . width ( ) ; } @ Override public boolean isEmpty ( ) { // not known to be empty, so always return false ... return false ; } @ Override public Batch nextBatch ( ) { Batch next = sequence . nextBatch ( ) ; return batchFilteredWith ( next , filter ) ; } @ Override public void close ( ) { sequence . close ( ) ; } @ Override public String toString ( ) { return "(filtered width=" + width ( ) + " " + filter + " " + sequence + ")" ; } } ; }
Create a sequence of nodes that all satisfy the supplied filter .
219
12
32,957
public static NodeSequence append ( final NodeSequence first , final NodeSequence second ) { if ( first == null ) { return second != null ? second : emptySequence ( 0 ) ; } if ( second == null ) return first ; int firstWidth = first . width ( ) ; final int secondWidth = second . width ( ) ; if ( firstWidth > 0 && secondWidth > 0 && firstWidth != secondWidth ) { throw new IllegalArgumentException ( "The sequences must have the same width: " + first + " and " + second ) ; } if ( first . isEmpty ( ) ) return second ; if ( second . isEmpty ( ) ) return first ; long firstCount = first . getRowCount ( ) ; long secondCount = second . getRowCount ( ) ; final long count = firstCount < 0 ? - 1 : ( secondCount < 0 ? - 1 : firstCount + secondCount ) ; return new NodeSequence ( ) { private NodeSequence current = first ; @ Override public int width ( ) { return secondWidth ; } @ Override public long getRowCount ( ) { return count ; } @ Override public boolean isEmpty ( ) { return false ; } @ Override public Batch nextBatch ( ) { Batch batch = current . nextBatch ( ) ; while ( batch == null && current == first ) { current = second ; batch = current . nextBatch ( ) ; } return batch ; } @ Override public void close ( ) { try { first . close ( ) ; } finally { second . close ( ) ; } } @ Override public String toString ( ) { return "(append width=" + width ( ) + " " + first + "," + second + " )" ; } } ; }
Create a sequence of nodes that contains the nodes from the first sequence followed by the second sequence .
374
19
32,958
public static NodeSequence slice ( final NodeSequence original , Columns columns ) { final int newWidth = columns . getSelectorNames ( ) . size ( ) ; if ( original . width ( ) == newWidth ) { return original ; } // We need to return a NodeSequence that includes only the specified selectors. // Step 1: figure out which selector indexes we'll use ... final int [ ] selectorIndexes = new int [ newWidth ] ; int i = 0 ; for ( String selectorName : columns . getSelectorNames ( ) ) { selectorIndexes [ i ++ ] = columns . getSelectorIndex ( selectorName ) ; } // Step 2: create a NodeSequence that delegates to the original but that returns Batch instances that // return the desired indexes ... return new NodeSequence ( ) { @ Override public int width ( ) { return 1 ; } @ Override public long getRowCount ( ) { return original . getRowCount ( ) ; } @ Override public boolean isEmpty ( ) { return original . isEmpty ( ) ; } @ Override public Batch nextBatch ( ) { return slicingBatch ( original . nextBatch ( ) , selectorIndexes ) ; } @ Override public void close ( ) { original . close ( ) ; } @ Override public String toString ( ) { return "(slice width=" + newWidth + " indexes=" + selectorIndexes + " " + original + " )" ; } } ; }
Create a sequence of nodes that include only those selectors defined by the given columns .
313
17
32,959
public static NodeSequence merging ( final NodeSequence first , final NodeSequence second , final int totalWidth ) { if ( first == null ) { if ( second == null ) return emptySequence ( totalWidth ) ; final int firstWidth = totalWidth - second . width ( ) ; return new NodeSequence ( ) { @ Override public int width ( ) { return totalWidth ; } @ Override public long getRowCount ( ) { return second . getRowCount ( ) ; } @ Override public boolean isEmpty ( ) { return second . isEmpty ( ) ; } @ Override public Batch nextBatch ( ) { return batchOf ( null , second . nextBatch ( ) , firstWidth , second . width ( ) ) ; } @ Override public void close ( ) { second . close ( ) ; } @ Override public String toString ( ) { return "(merge width=" + width ( ) + " (null-sequence)," + second + " )" ; } } ; } if ( second == null ) { final int secondWidth = totalWidth - first . width ( ) ; return new NodeSequence ( ) { @ Override public int width ( ) { return totalWidth ; } @ Override public long getRowCount ( ) { return first . getRowCount ( ) ; } @ Override public boolean isEmpty ( ) { return first . isEmpty ( ) ; } @ Override public Batch nextBatch ( ) { return batchOf ( first . nextBatch ( ) , null , first . width ( ) , secondWidth ) ; } @ Override public void close ( ) { first . close ( ) ; } @ Override public String toString ( ) { return "(merge width=" + width ( ) + " " + first + ",(null-sequence) )" ; } } ; } final int firstWidth = first . width ( ) ; final int secondWidth = second . width ( ) ; final long rowCount = Math . max ( - 1 , first . getRowCount ( ) + second . getRowCount ( ) ) ; return new NodeSequence ( ) { @ Override public int width ( ) { return totalWidth ; } @ Override public long getRowCount ( ) { return rowCount ; } @ Override public boolean isEmpty ( ) { return rowCount == 0 ; } @ Override public Batch nextBatch ( ) { Batch nextA = first . nextBatch ( ) ; Batch nextB = second . nextBatch ( ) ; if ( nextA == null ) { if ( nextB == null ) return null ; return batchOf ( null , nextB , firstWidth , secondWidth ) ; } return batchOf ( nextA , nextB , firstWidth , secondWidth ) ; } @ Override public void close ( ) { // always do both ... try { first . close ( ) ; } finally { second . close ( ) ; } } @ Override public String toString ( ) { return "(merge width=" + width ( ) + " " + first + "," + second + " )" ; } } ; }
Create a sequence of nodes that merges the two supplied sequences .
658
13
32,960
public synchronized final void initialize ( ) throws RepositoryException { if ( ! initialized ) { try { doInitialize ( ) ; initialized = true ; } catch ( RuntimeException e ) { throw new RepositoryException ( e ) ; } } }
Initialize the provider . This is called automatically by ModeShape once for each provider instance and should not be called by the provider itself .
50
27
32,961
public synchronized final void shutdown ( ) throws RepositoryException { preShutdown ( ) ; delegateWriter = NoOpQueryIndexWriter . INSTANCE ; try { // Shutdown each of the provided indexes ... for ( Map < String , AtomicIndex > byWorkspaceName : providedIndexesByWorkspaceNameByIndexName . values ( ) ) { for ( AtomicIndex provided : byWorkspaceName . values ( ) ) { provided . shutdown ( false ) ; } } } finally { providedIndexesByWorkspaceNameByIndexName . clear ( ) ; providedIndexesByIndexNameByWorkspaceName . clear ( ) ; postShutdown ( ) ; } }
Signal this provider that it is no longer needed and can release any resources that are being held .
136
20
32,962
public void validateDefaultColumnTypes ( ExecutionContext context , IndexDefinition defn , Problems problems ) { assert defn != null ; for ( int i = 0 ; i < defn . size ( ) ; i ++ ) { validateDefaultColumnDefinitionType ( context , defn , defn . getColumnDefinition ( i ) , problems ) ; } }
Validates that if certain default columns are present in the index definition they have a required type .
72
19
32,963
public final Index getIndex ( String indexName , String workspaceName ) { logger ( ) . trace ( "Looking for index '{0}' in '{1}' provider for query in workspace '{2}'" , indexName , getName ( ) , workspaceName ) ; Map < String , AtomicIndex > byWorkspaceNames = providedIndexesByWorkspaceNameByIndexName . get ( indexName ) ; return byWorkspaceNames == null ? null : byWorkspaceNames . get ( workspaceName ) ; }
Get the queryable index with the given name and applicable for the given workspace .
110
16
32,964
public final ManagedIndex getManagedIndex ( String indexName , String workspaceName ) { logger ( ) . trace ( "Looking for managed index '{0}' in '{1}' provider in workspace '{2}'" , indexName , getName ( ) , workspaceName ) ; Map < String , AtomicIndex > byWorkspaceNames = providedIndexesByWorkspaceNameByIndexName . get ( indexName ) ; if ( byWorkspaceNames == null ) { return null ; } AtomicIndex atomicIndex = byWorkspaceNames . get ( workspaceName ) ; return atomicIndex == null ? null : atomicIndex . managed ( ) ; }
Get the managed index with the given name and applicable for the given workspace .
137
15
32,965
private final void onEachIndex ( ProvidedIndexOperation op ) { for ( String workspaceName : workspaceNames ( ) ) { Collection < AtomicIndex > indexes = providedIndexesFor ( workspaceName ) ; if ( indexes != null ) { for ( AtomicIndex atomicIndex : indexes ) { assert atomicIndex . managed ( ) != null ; assert atomicIndex . indexDefinition ( ) != null ; op . apply ( workspaceName , atomicIndex ) ; } } } }
Perform the specified operation on each of the managed indexes .
94
12
32,966
public final void onEachIndexInWorkspace ( String workspaceName , ManagedIndexOperation op ) { assert workspaceName != null ; Collection < AtomicIndex > indexes = providedIndexesFor ( workspaceName ) ; if ( indexes != null ) { for ( AtomicIndex atomicIndex : indexes ) { assert atomicIndex . managed ( ) != null ; assert atomicIndex . indexDefinition ( ) != null ; op . apply ( workspaceName , atomicIndex . managed ( ) , atomicIndex . indexDefinition ( ) ) ; } } }
Perform the specified operation on each of the managed indexes in the named workspace .
107
16
32,967
protected ManagedIndex updateIndex ( IndexDefinition oldDefn , IndexDefinition updatedDefn , ManagedIndex existingIndex , String workspaceName , NodeTypes . Supplier nodeTypesSupplier , NodeTypePredicate matcher , IndexFeedback feedback ) { ManagedIndexBuilder builder = getIndexBuilder ( updatedDefn , workspaceName , nodeTypesSupplier , matcher ) ; if ( builder == null ) { throw new UnsupportedOperationException ( "Index providers should either override this method or the #getIndexBuilder method" ) ; } logger ( ) . debug ( "Index provider '{0}' is updating index in workspace '{1}': {2}" , getName ( ) , workspaceName , updatedDefn ) ; existingIndex . shutdown ( true ) ; ManagedIndex index = builder . build ( ) ; if ( index . requiresReindexing ( ) ) { scanWorkspace ( feedback , updatedDefn , workspaceName , index , nodeTypesSupplier ) ; } return index ; }
Method called when this provider needs to update an existing index given the unique pair of workspace name and index definition . An index definition can apply to multiple workspaces and when it is changed this method will be called once for each applicable workspace .
209
47
32,968
public List < NodeTypeDefinition > readAllNodeTypes ( ) { CachedNode nodeTypes = nodeTypesNode ( ) ; List < NodeTypeDefinition > defns = new ArrayList < NodeTypeDefinition > ( ) ; for ( ChildReference ref : nodeTypes . getChildReferences ( system ) ) { CachedNode nodeType = system . getNode ( ref ) ; defns . add ( readNodeTypeDefinition ( nodeType ) ) ; } return defns ; }
Read from system storage all of the node type definitions .
98
11
32,969
public Position add ( Position position ) { if ( this . getIndexInContent ( ) < 0 ) { return position . getIndexInContent ( ) < 0 ? EMPTY_CONTENT_POSITION : position ; } if ( position . getIndexInContent ( ) < 0 ) { return this ; } int index = this . getIndexInContent ( ) + position . getIndexInContent ( ) ; int line = position . getLine ( ) + this . getLine ( ) - 1 ; int column = this . getLine ( ) == 1 ? this . getColumn ( ) + position . getColumn ( ) : this . getColumn ( ) ; return new Position ( index , line , column ) ; }
Return a new position that is the addition of this position and that supplied .
149
15
32,970
public static ObjectId valueOf ( String uuid ) { int p = uuid . indexOf ( "/" ) ; if ( p < 0 ) { return new ObjectId ( Type . OBJECT , uuid ) ; } int p1 = p ; while ( p > 0 ) { p1 = p ; p = uuid . indexOf ( "/" , p + 1 ) ; } p = p1 ; String ident = uuid . substring ( 0 , p ) ; String type = uuid . substring ( p + 1 ) ; return new ObjectId ( Type . valueOf ( type . toUpperCase ( ) ) , ident ) ; }
Constructs instance of this class from its textual representation .
139
11
32,971
protected static Document replaceSystemPropertyVariables ( Document doc ) { if ( doc . isEmpty ( ) ) return doc ; Document modified = doc . withVariablesReplacedWithSystemProperties ( ) ; if ( modified == doc ) return doc ; // Otherwise, we changed some values. Note that the system properties can only be used in // string values, whereas the schema may expect non-string values. Therefore, we need to validate // the document against the schema and possibly perform some conversions of values ... return SCHEMA_LIBRARY . convertValues ( modified , JSON_SCHEMA_URI ) ; }
Utility method to replace all system property variables found within the specified document .
126
15
32,972
public static RepositoryConfiguration read ( String resourcePathOrJsonContentString ) throws ParsingException , FileNotFoundException { CheckArg . isNotNull ( resourcePathOrJsonContentString , "resourcePathOrJsonContentString" ) ; InputStream stream = ResourceLookup . read ( resourcePathOrJsonContentString , RepositoryConfiguration . class , true ) ; if ( stream != null ) { Document doc = Json . read ( stream ) ; return new RepositoryConfiguration ( doc , withoutExtension ( resourcePathOrJsonContentString ) ) ; } // Try a file ... File file = new File ( resourcePathOrJsonContentString ) ; if ( file . exists ( ) && file . isFile ( ) ) { return read ( file ) ; } String content = resourcePathOrJsonContentString . trim ( ) ; if ( content . startsWith ( "{" ) ) { // Try to parse the document ... Document doc = Json . read ( content ) ; return new RepositoryConfiguration ( doc , null ) ; } throw new FileNotFoundException ( resourcePathOrJsonContentString ) ; }
Read the repository configuration given by the supplied path to a file on the file system the path a classpath resource file or a string containg the actual JSON content .
237
34
32,973
public List < String > getNodeTypes ( ) { List < String > result = new ArrayList < String > ( ) ; List < ? > configuredNodeTypes = doc . getArray ( FieldName . NODE_TYPES ) ; if ( configuredNodeTypes != null ) { for ( Object configuredNodeType : configuredNodeTypes ) { result . add ( configuredNodeType . toString ( ) ) ; } } return result ; }
Returns a list with the cnd files which should be loaded at startup .
91
15
32,974
public String getDefaultWorkspaceName ( ) { Document workspaces = doc . getDocument ( FieldName . WORKSPACES ) ; if ( workspaces != null ) { return workspaces . getString ( FieldName . DEFAULT , Default . DEFAULT ) ; } return Default . DEFAULT ; }
Get the name of the workspace that should be used for sessions where the client does not specify the name of the workspace .
63
24
32,975
public List < Component > getIndexProviders ( ) { Problems problems = new SimpleProblems ( ) ; List < Component > components = readComponents ( doc , FieldName . INDEX_PROVIDERS , FieldName . CLASSNAME , INDEX_PROVIDER_ALIASES , problems ) ; assert ! problems . hasErrors ( ) ; return components ; }
Get the ordered list of index providers defined in the configuration .
77
12
32,976
public DocumentOptimization getDocumentOptimization ( ) { Document storage = doc . getDocument ( FieldName . STORAGE ) ; if ( storage == null ) { storage = Schematic . newDocument ( ) ; } return new DocumentOptimization ( storage . getDocument ( FieldName . DOCUMENT_OPTIMIZATION ) ) ; }
Get the configuration for the document optimization for this repository .
74
11
32,977
public void writeTo ( WritableByteChannel channel ) throws IOException { int numberOfBytesToWrite = size ; for ( ByteBuffer buffer : buffers ) { if ( buffer == null ) { // already flushed continue ; } int numBytesInBuffer = Math . min ( numberOfBytesToWrite , bufferSize ) ; buffer . position ( numBytesInBuffer ) ; buffer . flip ( ) ; channel . write ( buffer ) ; numberOfBytesToWrite -= numBytesInBuffer ; } buffers . clear ( ) ; }
Write all content to the supplied channel .
108
8
32,978
public final int applyUpgradesSince ( int lastId , Context resources ) { int lastUpgradeId = lastId ; for ( UpgradeOperation op : operations ) { if ( op . getId ( ) <= lastId ) continue ; LOGGER . debug ( "Upgrade {0}: starting" , op ) ; op . apply ( resources ) ; LOGGER . debug ( "Upgrade {0}: complete" , op ) ; lastUpgradeId = op . getId ( ) ; } return lastUpgradeId ; }
Apply any upgrades that are more recent than identified by the last upgraded identifier .
104
15
32,979
public static org . modeshape . jcr . api . Logger getLogger ( Class < ? > clazz ) { return new ExtensionLogger ( Logger . getLogger ( clazz ) ) ; }
Creates a new logger instance for the underlying class .
46
11
32,980
private void createIndex ( ) { try { client . createIndex ( name ( ) , workspace , columns . mappings ( workspace ) ) ; client . flush ( name ( ) ) ; } catch ( IOException e ) { throw new EsIndexException ( e ) ; } }
Executes create index action .
57
6
32,981
private EsRequest find ( String nodeKey ) throws IOException { return client . getDocument ( name ( ) , workspace , nodeKey ) ; }
Searches indexed node s properties by node key .
30
11
32,982
private EsRequest findOrCreateDoc ( String nodeKey ) throws IOException { EsRequest doc = client . getDocument ( name ( ) , workspace , nodeKey ) ; return doc != null ? doc : new EsRequest ( ) ; }
Searches indexed node s properties by node key or creates new empty list .
49
16
32,983
private void putValue ( EsRequest doc , EsIndexColumn column , Object value ) { Object columnValue = column . columnValue ( value ) ; String stringValue = column . stringValue ( value ) ; doc . put ( column . getName ( ) , columnValue ) ; if ( ! ( value instanceof ModeShapeDateTime || value instanceof Long || value instanceof Boolean ) ) { doc . put ( column . getLowerCaseFieldName ( ) , stringValue . toLowerCase ( ) ) ; doc . put ( column . getUpperCaseFieldName ( ) , stringValue . toUpperCase ( ) ) ; } doc . put ( column . getLengthFieldName ( ) , stringValue . length ( ) ) ; }
Appends specified value for the given column and related pseudo columns into list of properties .
154
17
32,984
private void putValues ( EsRequest doc , EsIndexColumn column , Object [ ] value ) { Object [ ] columnValue = column . columnValues ( value ) ; int [ ] ln = new int [ columnValue . length ] ; String [ ] lc = new String [ columnValue . length ] ; String [ ] uc = new String [ columnValue . length ] ; for ( int i = 0 ; i < columnValue . length ; i ++ ) { String stringValue = column . stringValue ( columnValue [ i ] ) ; lc [ i ] = stringValue . toLowerCase ( ) ; uc [ i ] = stringValue . toUpperCase ( ) ; ln [ i ] = stringValue . length ( ) ; } doc . put ( column . getName ( ) , columnValue ) ; doc . put ( column . getLowerCaseFieldName ( ) , lc ) ; doc . put ( column . getUpperCaseFieldName ( ) , uc ) ; doc . put ( column . getLengthFieldName ( ) , ln ) ; }
Appends specified values for the given column and related pseudo columns into list of properties .
228
17
32,985
protected void processIdent ( DetailAST aAST ) { final int parentType = aAST . getParent ( ) . getType ( ) ; if ( ( ( parentType != TokenTypes . DOT ) && ( parentType != TokenTypes . METHOD_DEF ) ) || ( ( parentType == TokenTypes . DOT ) && ( aAST . getNextSibling ( ) != null ) ) ) { referenced . add ( aAST . getText ( ) ) ; } }
Collects references made by IDENT .
98
8
32,986
private void processImport ( DetailAST aAST ) { final FullIdent name = FullIdent . createFullIdentBelow ( aAST ) ; if ( ( name != null ) && ! name . getText ( ) . endsWith ( ".*" ) ) { imports . add ( name ) ; } }
Collects the details of imports .
62
7
32,987
private void processStaticImport ( DetailAST aAST ) { final FullIdent name = FullIdent . createFullIdent ( aAST . getFirstChild ( ) . getNextSibling ( ) ) ; if ( ( name != null ) && ! name . getText ( ) . endsWith ( ".*" ) ) { imports . add ( name ) ; } }
Collects the details of static imports .
75
8
32,988
public PrivilegeImpl forName ( String name ) { if ( name . contains ( "}" ) ) { String localName = name . substring ( name . indexOf ( ' ' ) + 1 ) ; return privileges . get ( localName ) ; } if ( name . contains ( ":" ) ) { String localName = name . substring ( name . indexOf ( ' ' ) + 1 ) ; PrivilegeImpl p = privileges . get ( localName ) ; return p . getName ( ) . equals ( name ) ? p : null ; } return null ; }
Searches privilege object for the privilege with the given name .
120
13
32,989
public void setChangedNodes ( Set < NodeKey > keys ) { if ( keys != null ) { this . nodeKeys = Collections . unmodifiableSet ( new HashSet < NodeKey > ( keys ) ) ; } }
Sets the list of node keys involved in this change set .
48
13
32,990
public static boolean hasWildcardCharacters ( String expression ) { Objects . requireNonNull ( expression ) ; CharacterIterator iter = new StringCharacterIterator ( expression ) ; boolean skipNext = false ; for ( char c = iter . first ( ) ; c != CharacterIterator . DONE ; c = iter . next ( ) ) { if ( skipNext ) { skipNext = false ; continue ; } if ( c == ' ' || c == ' ' || c == ' ' || c == ' ' ) return true ; if ( c == ' ' ) skipNext = true ; } return false ; }
Checks if the given expression has any wildcard characters
123
11
32,991
public static String toRegularExpression ( String likeExpression ) { // Replace all '\x' with 'x' ... String result = likeExpression . replaceAll ( "\\\\(.)" , "$1" ) ; // Escape characters used as metacharacters in regular expressions, including // '[', '^', '\', '$', '.', '|', '+', '(', and ')' // But leave '?' and '*' result = result . replaceAll ( "([$.|+()\\[\\\\^\\\\\\\\])" , "\\\\$1" ) ; // Replace '%'->'[.]*' and '_'->'[.] // (order of these calls is important!) result = result . replace ( "*" , ".*" ) . replace ( "?" , "." ) ; result = result . replace ( "%" , ".*" ) . replace ( "_" , "." ) ; // Replace all wildcards between square bracket literals with digit wildcards ... result = result . replace ( "\\[.*]" , "\\[\\d+]" ) ; return result ; }
Convert the JCR like expression to a regular expression . The JCR like expression uses % to match 0 or more characters _ to match any single character \ x to match the x character and all other characters to match themselves . Note that if any regex metacharacters appear in the like expression they will be escaped within the resulting regular expression .
239
70
32,992
public String [ ] getAttributeNames ( ) { synchronized ( attributes ) { return attributes . keySet ( ) . toArray ( new String [ attributes . keySet ( ) . size ( ) ] ) ; } }
Returns the names of the attributes available to this credentials instance . This method returns an empty array if the credentials instance has no attributes available to it .
44
29
32,993
protected boolean appliesToPathConstraint ( List < Component > predicates ) { if ( predicates . isEmpty ( ) ) return true ; if ( predicates . size ( ) > 1 ) return false ; assert predicates . size ( ) == 1 ; Component predicate = predicates . get ( 0 ) ; if ( predicate instanceof Literal && ( ( Literal ) predicate ) . isInteger ( ) ) return true ; if ( predicate instanceof NameTest && ( ( NameTest ) predicate ) . isWildcard ( ) ) return true ; return false ; }
Determine if the predicates contain any expressions that cannot be put into a LIKE constraint on the path .
118
22
32,994
static BinaryStorage defaultConfig ( ) { // By default binaries are not stored on disk EditableDocument binaries = Schematic . newDocument ( ) ; binaries . set ( RepositoryConfiguration . FieldName . TYPE , RepositoryConfiguration . FieldValue . BINARY_STORAGE_TYPE_TRANSIENT ) ; return new BinaryStorage ( binaries ) ; }
Creates a default storage configuration which will be used whenever no specific binary store is configured .
75
18
32,995
@ Override public String text ( Locale locale , Object ... arguments ) { try { String rawText = rawText ( locale == null ? Locale . getDefault ( ) : locale ) ; return StringUtil . createString ( rawText , arguments ) ; } catch ( IllegalArgumentException err ) { throw new IllegalArgumentException ( CommonI18n . i18nRequiredToSuppliedParameterMismatch . text ( id , i18nClass , err . getMessage ( ) ) ) ; } catch ( SystemFailureException err ) { return ' ' + err . getMessage ( ) + ' ' ; } }
Get the localized text for the supplied locale replacing the parameters in the text with those supplied .
131
18
32,996
protected DocumentBuilder getDocumentBuilder ( ) throws ServletException { DocumentBuilder documentBuilder = null ; DocumentBuilderFactory documentBuilderFactory = null ; try { documentBuilderFactory = DocumentBuilderFactory . newInstance ( ) ; documentBuilderFactory . setNamespaceAware ( true ) ; documentBuilder = documentBuilderFactory . newDocumentBuilder ( ) ; } catch ( ParserConfigurationException e ) { throw new ServletException ( "jaxp failed" ) ; } return documentBuilder ; }
Return JAXP document builder instance .
100
8
32,997
public boolean indexAppliesTo ( JoinCondition condition ) { if ( condition instanceof ChildNodeJoinCondition ) { return indexAppliesTo ( ( ChildNodeJoinCondition ) condition ) ; } if ( condition instanceof DescendantNodeJoinCondition ) { return indexAppliesTo ( ( DescendantNodeJoinCondition ) condition ) ; } if ( condition instanceof EquiJoinCondition ) { return indexAppliesTo ( ( EquiJoinCondition ) condition ) ; } if ( condition instanceof SameNodeJoinCondition ) { return indexAppliesTo ( ( SameNodeJoinCondition ) condition ) ; } return false ; }
Determine if this index can be used to evaluate the given join condition .
128
16
32,998
public boolean indexAppliesTo ( Constraint constraint ) { if ( constraint instanceof Comparison ) { return indexAppliesTo ( ( Comparison ) constraint ) ; } if ( constraint instanceof And ) { return indexAppliesTo ( ( And ) constraint ) ; } if ( constraint instanceof Or ) { return indexAppliesTo ( ( Or ) constraint ) ; } if ( constraint instanceof Not ) { return indexAppliesTo ( ( Not ) constraint ) ; } if ( constraint instanceof Between ) { return indexAppliesTo ( ( Between ) constraint ) ; } if ( constraint instanceof SetCriteria ) { return indexAppliesTo ( ( SetCriteria ) constraint ) ; } if ( constraint instanceof Relike ) { return indexAppliesTo ( ( Relike ) constraint ) ; } if ( constraint instanceof PropertyExistence ) { return indexAppliesTo ( ( PropertyExistence ) constraint ) ; } if ( constraint instanceof FullTextSearch ) { return applies ( ( FullTextSearch ) constraint ) ; } return false ; }
Determine if this index can be used to evaluate the given constraint .
217
15
32,999
private void aggregate ( ArrayList < Privilege > list , Privilege p ) { list . add ( p ) ; if ( p . isAggregate ( ) ) { for ( Privilege ap : p . getDeclaredAggregatePrivileges ( ) ) { aggregate ( list , ap ) ; } } }
Recursively aggregates privileges for the given privilege .
65
11