idx int64 0 41.2k | question stringlengths 74 4.04k | target stringlengths 7 750 |
|---|---|---|
33,100 | public static String urlFrom ( String baseUrl , String ... pathSegments ) { StringBuilder urlBuilder = new StringBuilder ( baseUrl ) ; if ( urlBuilder . charAt ( urlBuilder . length ( ) - 1 ) == '/' ) { urlBuilder . deleteCharAt ( urlBuilder . length ( ) - 1 ) ; } for ( String pathSegment : pathSegments ) { if ( pathSegment . equalsIgnoreCase ( ".." ) ) { urlBuilder . delete ( urlBuilder . lastIndexOf ( "/" ) , urlBuilder . length ( ) ) ; } else { if ( ! pathSegment . startsWith ( "/" ) ) { urlBuilder . append ( "/" ) ; } urlBuilder . append ( pathSegment ) ; } } return urlBuilder . toString ( ) ; } | Creates an url using base url and appending optional segments . |
33,101 | public static Value jsonValueToJCRValue ( Object value , ValueFactory valueFactory ) { if ( value == null ) { return null ; } if ( value instanceof Integer || value instanceof Long ) { return valueFactory . createValue ( ( ( Number ) value ) . longValue ( ) ) ; } else if ( value instanceof Double || value instanceof Float ) { return valueFactory . createValue ( ( ( Number ) value ) . doubleValue ( ) ) ; } else if ( value instanceof Boolean ) { return valueFactory . createValue ( ( Boolean ) value ) ; } String valueString = value . toString ( ) ; for ( DateFormat dateFormat : ISO8601_DATE_PARSERS ) { try { Date date = dateFormat . parse ( valueString ) ; return valueFactory . createValue ( date ) ; } catch ( ParseException e ) { } catch ( ValueFormatException e ) { } } return valueFactory . createValue ( valueString ) ; } | Converts an object value coming from a JSON object to a JCR value by attempting to convert it to a valid data type . |
33,102 | public static boolean isProperlyFormattedKey ( String hexadecimalStr ) { if ( hexadecimalStr == null ) return false ; final int length = hexadecimalStr . length ( ) ; if ( length != ALGORITHM . getHexadecimalStringLength ( ) ) return false ; return StringUtil . isHexString ( hexadecimalStr ) ; } | Determine if the supplied hexadecimal string is potentially a binary key by checking the format of the string . |
33,103 | Future < Boolean > shutdown ( ) { final ExecutorService executor = Executors . newSingleThreadExecutor ( new NamedThreadFactory ( "modeshape-repository-stop" ) ) ; try { return executor . submit ( ( ) -> doShutdown ( false ) ) ; } finally { executor . shutdown ( ) ; } } | Terminate all active sessions . |
33,104 | private String getParameter ( List < FileItem > items , String name ) { for ( FileItem i : items ) { if ( i . isFormField ( ) && i . getFieldName ( ) . equals ( name ) ) { return i . getString ( ) ; } } return null ; } | Extracts value of the parameter with given name . |
33,105 | private InputStream getStream ( List < FileItem > items ) throws IOException { for ( FileItem i : items ) { if ( ! i . isFormField ( ) && i . getFieldName ( ) . equals ( CONTENT_PARAMETER ) ) { return i . getInputStream ( ) ; } } return null ; } | Gets uploaded file as stream . |
33,106 | public static void isNotLessThan ( int argument , int notLessThanValue , String name ) { if ( argument < notLessThanValue ) { throw new IllegalArgumentException ( CommonI18n . argumentMayNotBeLessThan . text ( name , argument , notLessThanValue ) ) ; } } | Check that the argument is not less than the supplied value |
33,107 | public static void isNotGreaterThan ( int argument , int notGreaterThanValue , String name ) { if ( argument > notGreaterThanValue ) { throw new IllegalArgumentException ( CommonI18n . argumentMayNotBeGreaterThan . text ( name , argument , notGreaterThanValue ) ) ; } } | Check that the argument is not greater than the supplied value |
33,108 | public static void isGreaterThan ( int argument , int greaterThanValue , String name ) { if ( argument <= greaterThanValue ) { throw new IllegalArgumentException ( CommonI18n . argumentMustBeGreaterThan . text ( name , argument , greaterThanValue ) ) ; } } | Check that the argument is greater than the supplied value |
33,109 | public static void isLessThan ( int argument , int lessThanValue , String name ) { if ( argument >= lessThanValue ) { throw new IllegalArgumentException ( CommonI18n . argumentMustBeLessThan . text ( name , argument , lessThanValue ) ) ; } } | Check that the argument is less than the supplied value |
33,110 | public static void isGreaterThanOrEqualTo ( int argument , int greaterThanOrEqualToValue , String name ) { if ( argument < greaterThanOrEqualToValue ) { throw new IllegalArgumentException ( CommonI18n . argumentMustBeGreaterThanOrEqualTo . text ( name , argument , greaterThanOrEqualToValue ) ) ; } } | Check that the argument is greater than or equal to the supplied value |
33,111 | public static void isLessThanOrEqualTo ( int argument , int lessThanOrEqualToValue , String name ) { if ( argument > lessThanOrEqualToValue ) { throw new IllegalArgumentException ( CommonI18n . argumentMustBeLessThanOrEqualTo . text ( name , argument , lessThanOrEqualToValue ) ) ; } } | Check that the argument is less than or equal to the supplied value |
33,112 | public static void isPowerOfTwo ( int argument , String name ) { if ( Integer . bitCount ( argument ) != 1 ) { throw new IllegalArgumentException ( CommonI18n . argumentMustBePowerOfTwo . text ( name , argument ) ) ; } } | Check that the argument is a power of 2 . |
33,113 | public static void isNotNan ( double argument , String name ) { if ( Double . isNaN ( argument ) ) { throw new IllegalArgumentException ( CommonI18n . argumentMustBeNumber . text ( name ) ) ; } } | Check that the argument is not NaN . |
33,114 | public static void isNotZeroLength ( String argument , String name ) { isNotNull ( argument , name ) ; if ( argument . length ( ) <= 0 ) { throw new IllegalArgumentException ( CommonI18n . argumentMayNotBeNullOrZeroLength . text ( name ) ) ; } } | Check that the string is non - null and has length > 0 |
33,115 | public static void isNotEmpty ( String argument , String name ) { isNotZeroLength ( argument , name ) ; if ( argument != null && argument . trim ( ) . length ( ) == 0 ) { throw new IllegalArgumentException ( CommonI18n . argumentMayNotBeNullOrZeroLengthOrEmpty . text ( name ) ) ; } } | Check that the string is not empty is not null and does not contain only whitespace . |
33,116 | public static void isNotNull ( Object argument , String name ) { if ( argument == null ) { throw new IllegalArgumentException ( CommonI18n . argumentMayNotBeNull . text ( name ) ) ; } } | Check that the specified argument is non - null |
33,117 | public static void isNull ( Object argument , String name ) { if ( argument != null ) { throw new IllegalArgumentException ( CommonI18n . argumentMustBeNull . text ( name ) ) ; } } | Check that the argument is null |
33,118 | public static void isInstanceOf ( Object argument , Class < ? > expectedClass , String name ) { isNotNull ( argument , name ) ; if ( ! expectedClass . isInstance ( argument ) ) { throw new IllegalArgumentException ( CommonI18n . argumentMustBeInstanceOf . text ( name , argument . getClass ( ) , expectedClass . getName ( ) ) ) ; } } | Check that the object is an instance of the specified Class |
33,119 | public static < C > C getInstanceOf ( Object argument , Class < C > expectedClass , String name ) { isInstanceOf ( argument , expectedClass , name ) ; return expectedClass . cast ( argument ) ; } | due to cast in return |
33,120 | public static void isNotEmpty ( Iterator < ? > argument , String name ) { isNotNull ( argument , name ) ; if ( ! argument . hasNext ( ) ) { throw new IllegalArgumentException ( CommonI18n . argumentMayNotBeEmpty . text ( name ) ) ; } } | Checks that the iterator is not empty and throws an exception if it is . |
33,121 | public static void isNotEmpty ( Collection < ? > argument , String name ) { isNotNull ( argument , name ) ; if ( argument . isEmpty ( ) ) { throw new IllegalArgumentException ( CommonI18n . argumentMayNotBeEmpty . text ( name ) ) ; } } | Check that the collection is not empty |
33,122 | public static void isEmpty ( Object [ ] argument , String name ) { isNotNull ( argument , name ) ; if ( argument . length > 0 ) { throw new IllegalArgumentException ( CommonI18n . argumentMustBeEmpty . text ( name ) ) ; } } | Check that the array is empty |
33,123 | public static void isNotEmpty ( Object [ ] argument , String name ) { isNotNull ( argument , name ) ; if ( argument . length == 0 ) { throw new IllegalArgumentException ( CommonI18n . argumentMayNotBeEmpty . text ( name ) ) ; } } | Check that the array is not empty |
33,124 | public static void contains ( Collection < ? > argument , Object value , String name ) { isNotNull ( argument , name ) ; if ( ! argument . contains ( value ) ) { throw new IllegalArgumentException ( CommonI18n . argumentDidNotContainObject . text ( name , getObjectName ( value ) ) ) ; } } | Check that the collection contains the value |
33,125 | public static void containsKey ( Map < ? , ? > argument , Object key , String name ) { isNotNull ( argument , name ) ; if ( ! argument . containsKey ( key ) ) { throw new IllegalArgumentException ( CommonI18n . argumentDidNotContainKey . text ( name , getObjectName ( key ) ) ) ; } } | Check that the map contains the key |
33,126 | public static void containsNoNulls ( Iterable < ? > argument , String name ) { isNotNull ( argument , name ) ; int i = 0 ; for ( Object object : argument ) { if ( object == null ) { throw new IllegalArgumentException ( CommonI18n . argumentMayNotContainNullValue . text ( name , i ) ) ; } ++ i ; } } | Check that the collection is not null and contains no nulls |
33,127 | public static void hasSizeOfAtLeast ( Collection < ? > argument , int minimumSize , String name ) { isNotNull ( argument , name ) ; if ( argument . size ( ) < minimumSize ) { throw new IllegalArgumentException ( CommonI18n . argumentMustBeOfMinimumSize . text ( name , Collection . class . getSimpleName ( ) , argument . size ( ) , minimumSize ) ) ; } } | Check that the collection contains at least the supplied number of elements |
33,128 | public static void hasSizeOfAtMost ( Collection < ? > argument , int maximumSize , String name ) { isNotNull ( argument , name ) ; if ( argument . size ( ) > maximumSize ) { throw new IllegalArgumentException ( CommonI18n . argumentMustBeOfMinimumSize . text ( name , Collection . class . getSimpleName ( ) , argument . size ( ) , maximumSize ) ) ; } } | Check that the collection contains no more than the supplied number of elements |
33,129 | public static void hasSizeOfAtLeast ( Object [ ] argument , int minimumSize , String name ) { isNotNull ( argument , name ) ; if ( argument . length < minimumSize ) { throw new IllegalArgumentException ( CommonI18n . argumentMustBeOfMinimumSize . text ( name , Object [ ] . class . getSimpleName ( ) , argument . length , minimumSize ) ) ; } } | Check that the array contains at least the supplied number of elements |
33,130 | public static void hasSizeOfAtMost ( Object [ ] argument , int maximumSize , String name ) { isNotNull ( argument , name ) ; if ( argument . length > maximumSize ) { throw new IllegalArgumentException ( CommonI18n . argumentMustBeOfMinimumSize . text ( name , Object [ ] . class . getSimpleName ( ) , argument . length , maximumSize ) ) ; } } | Check that the array contains no more than the supplied number of elements |
33,131 | public static String jodaFormat ( ZonedDateTime dateTime ) { CheckArg . isNotNull ( dateTime , "dateTime" ) ; return dateTime . format ( JODA_ISO8601_FORMATTER ) ; } | Returns the ISO8601 string of a given date - time instance with timezone information trying to be as closed as possible to what the JODA date - time library would return . |
33,132 | protected final < T > T processStream ( Binary binary , BinaryOperation < T > operation ) throws Exception { InputStream stream = binary . getStream ( ) ; if ( stream == null ) { throw new IllegalArgumentException ( "The binary value is empty" ) ; } try { return operation . execute ( stream ) ; } finally { stream . close ( ) ; } } | Allows subclasses to process the stream of binary value property in safe fashion making sure the stream is closed at the end of the operation . |
33,133 | public void addLanguage ( QueryParser languageParser ) { CheckArg . isNotNull ( languageParser , "languageParser" ) ; this . parsers . put ( languageParser . getLanguage ( ) . trim ( ) . toLowerCase ( ) , languageParser ) ; } | Add a language to this engine by supplying its parser . |
33,134 | public Set < String > getLanguages ( ) { Set < String > result = new HashSet < String > ( ) ; for ( QueryParser parser : parsers . values ( ) ) { result . add ( parser . getLanguage ( ) ) ; } return Collections . unmodifiableSet ( result ) ; } | Get the set of languages that this engine is capable of parsing . |
33,135 | public QueryParser getParserFor ( String language ) { CheckArg . isNotNull ( language , "language" ) ; return parsers . get ( language . trim ( ) . toLowerCase ( ) ) ; } | Get the parser for the supplied language . |
33,136 | public static Builder createBuilder ( ExecutionContext context , NodeTypes nodeTypes ) { CheckArg . isNotNull ( context , "context" ) ; CheckArg . isNotNull ( nodeTypes , "nodeTypes" ) ; return new Builder ( context , nodeTypes ) ; } | Obtain a new instance for building Schemata objects . |
33,137 | public void show ( JcrNode node ) { this . node = node ; if ( node . getAcl ( ) == null ) { this . displayDisabledEditor ( ) ; } else if ( this . isAclDefined ( node ) ) { this . selectFirstPrincipalAndDisplayPermissions ( node ) ; } else { this . displayEveryonePermissions ( ) ; } } | Displays permissions for the given node . |
33,138 | protected AstNode parseMaterializedViewStatement ( DdlTokenStream tokens , AstNode parentNode ) throws ParsingException { assert tokens != null ; assert parentNode != null ; markStartOfStatement ( tokens ) ; boolean isLog = tokens . canConsume ( STMT_CREATE_MATERIALIZED_VEIW_LOG ) ; tokens . canConsume ( STMT_CREATE_MATERIALIZED_VIEW ) ; String name = parseName ( tokens ) ; AstNode node = null ; if ( isLog ) { node = nodeFactory ( ) . node ( name , parentNode , TYPE_CREATE_MATERIALIZED_VIEW_LOG_STATEMENT ) ; } else { node = nodeFactory ( ) . node ( name , parentNode , TYPE_CREATE_MATERIALIZED_VIEW_STATEMENT ) ; } parseUntilTerminator ( tokens ) ; markEndOfStatement ( tokens , node ) ; return node ; } | Parses DDL CREATE MATERIALIZED VIEW statement This could either be a standard view or a VIEW LOG ON statement . |
33,139 | private String parseContentBetweenParens ( final DdlTokenStream tokens ) throws ParsingException { tokens . consume ( L_PAREN ) ; int numLeft = 1 ; int numRight = 0 ; final StringBuilder text = new StringBuilder ( ) ; while ( tokens . hasNext ( ) ) { if ( tokens . matches ( L_PAREN ) ) { ++ numLeft ; } else if ( tokens . matches ( R_PAREN ) ) { if ( numLeft == ++ numRight ) { tokens . consume ( R_PAREN ) ; break ; } } final String token = tokens . consume ( ) ; if ( ! PERIOD . equals ( token ) && ( text . length ( ) != 0 ) && ( PERIOD . charAt ( 0 ) != ( text . charAt ( text . length ( ) - 1 ) ) ) ) { text . append ( SPACE ) ; } text . append ( token ) ; } if ( ( numLeft != numRight ) || ( text . length ( ) == 0 ) ) { throw new ParsingException ( tokens . nextPosition ( ) ) ; } return text . toString ( ) ; } | The tokens must start with a left paren end with a right paren and have content between . Any parens in the content must have matching parens . |
33,140 | protected boolean isColumnDefinitionStart ( DdlTokenStream tokens , String columnMixinType ) throws ParsingException { boolean result = isColumnDefinitionStart ( tokens ) ; if ( ! result && TYPE_ALTER_COLUMN_DEFINITION . equals ( columnMixinType ) ) { for ( String start : INLINE_COLUMN_PROPERTY_START ) { if ( tokens . matches ( TokenStream . ANY_VALUE , start ) ) return true ; } } return result ; } | Utility method to additionally check if MODIFY definition without datatype |
33,141 | public static ExtractFromRow extractPath ( final int indexInRow , final NodeCache cache , TypeSystem types ) { final TypeFactory < Path > type = types . getPathFactory ( ) ; final boolean trace = NodeSequence . LOGGER . isTraceEnabled ( ) ; return new ExtractFromRow ( ) { public TypeFactory < Path > getType ( ) { return type ; } public Object getValueInRow ( RowAccessor row ) { CachedNode node = row . getNode ( indexInRow ) ; if ( node == null ) return null ; Path path = node . getPath ( cache ) ; if ( trace ) NodeSequence . LOGGER . trace ( "Extracting path from {0}" , path ) ; return path ; } public String toString ( ) { return "(extract-path)" ; } } ; } | Create an extractor that extracts the path from the node at the given position in the row . |
33,142 | public static ExtractFromRow extractParentPath ( final int indexInRow , final NodeCache cache , TypeSystem types ) { final TypeFactory < Path > type = types . getPathFactory ( ) ; final boolean trace = NodeSequence . LOGGER . isTraceEnabled ( ) ; return new ExtractFromRow ( ) { public TypeFactory < Path > getType ( ) { return type ; } public Object getValueInRow ( RowAccessor row ) { CachedNode node = row . getNode ( indexInRow ) ; if ( node == null ) return null ; NodeKey parentKey = node . getParentKey ( cache ) ; if ( parentKey == null ) return null ; CachedNode parent = cache . getNode ( parentKey ) ; if ( parent == null ) return null ; Path parentPath = parent . getPath ( cache ) ; if ( trace ) NodeSequence . LOGGER . trace ( "Extracting parent path from {0}: {1}" , node . getPath ( cache ) , parentPath ) ; return parentPath ; } public String toString ( ) { return "(extract-parent-path)" ; } } ; } | Create an extractor that extracts the parent path from the node at the given position in the row . |
33,143 | public static ExtractFromRow extractRelativePath ( final int indexInRow , final Path relativePath , final NodeCache cache , TypeSystem types ) { CheckArg . isNotNull ( relativePath , "relativePath" ) ; final TypeFactory < Path > type = types . getPathFactory ( ) ; final boolean trace = NodeSequence . LOGGER . isTraceEnabled ( ) ; return new ExtractFromRow ( ) { public TypeFactory < Path > getType ( ) { return type ; } public Object getValueInRow ( RowAccessor row ) { CachedNode node = row . getNode ( indexInRow ) ; if ( node == null ) return null ; Path nodePath = node . getPath ( cache ) ; try { Path path = nodePath . resolve ( relativePath ) ; if ( trace ) NodeSequence . LOGGER . trace ( "Extracting relative path {2} from {0}: {2}" , node . getPath ( cache ) , relativePath , path ) ; return path ; } catch ( InvalidPathException e ) { return null ; } } public String toString ( ) { return "(extract-relative-path)" ; } } ; } | Create an extractor that extracts the path from the node at the given position in the row and applies the relative path . |
33,144 | public static ExtractFromRow extractPropertyValue ( final Name propertyName , final int indexInRow , final NodeCache cache , final TypeFactory < ? > desiredType ) { return new ExtractFromRow ( ) { public Object getValueInRow ( RowAccessor row ) { CachedNode node = row . getNode ( indexInRow ) ; if ( node == null ) return null ; org . modeshape . jcr . value . Property prop = node . getProperty ( propertyName , cache ) ; return prop == null ? null : desiredType . create ( prop . getFirstValue ( ) ) ; } public TypeFactory < ? > getType ( ) { return desiredType ; } } ; } | Create an extractor that extracts the property value from the node at the given position in the row . |
33,145 | protected final boolean reindex ( String workspaceName , NodeKey key , Path path , Name primaryType , Set < Name > mixinTypes , Properties properties , boolean queryable ) { if ( predicate . matchesType ( primaryType , mixinTypes ) ) { reindexNode ( workspaceName , key , path , primaryType , mixinTypes , properties , queryable ) ; return true ; } return false ; } | Reindex the specific node . |
33,146 | protected NodeCacheIterator nodes ( String workspaceName , Path path ) { NodeFilter nodeFilterForWorkspace = nodeFilterForWorkspace ( workspaceName ) ; if ( nodeFilterForWorkspace == null ) return null ; NodeFilter compositeFilter = new CompositeNodeFilter ( nodeFilterForWorkspace , sharedNodesFilter ( ) ) ; NodeCache cache = repo . getWorkspaceCache ( workspaceName ) ; NodeKey startingNode = null ; if ( path != null ) { CachedNode node = getNodeAtPath ( path , cache ) ; if ( node != null ) startingNode = node . getKey ( ) ; } else { startingNode = cache . getRootKey ( ) ; } if ( startingNode != null ) { return new NodeCacheIterator ( cache , startingNode , compositeFilter ) ; } return null ; } | Return an iterator over all nodes at or below the specified path in the named workspace using the supplied filter . |
33,147 | public RestNode addCustomProperty ( String name , String value ) { customProperties . put ( name , value ) ; return this ; } | Adds a custom property to this node meaning a property which is not among the standard JCR properties |
33,148 | protected final void checkForCheckedOut ( ) throws VersionException , RepositoryException { if ( ! node . isCheckedOut ( ) ) { JcrPropertyDefinition defn = getDefinition ( ) ; if ( defn . getOnParentVersion ( ) != OnParentVersionAction . IGNORE ) { String path = getParent ( ) . getPath ( ) ; throw new VersionException ( JcrI18n . nodeIsCheckedIn . text ( path ) ) ; } } } | Verifies that this node is either not versionable or that it is versionable but checked out . |
33,149 | protected final CachedNode node ( ) throws ItemNotFoundException , InvalidItemStateException { CachedNode node = sessionCache ( ) . getNode ( key ) ; if ( node == null ) { if ( sessionCache ( ) . isDestroyed ( key ) ) { throw new InvalidItemStateException ( "The node with key " + key + " has been removed in this session." ) ; } throw new ItemNotFoundException ( "The node with key " + key + " no longer exists." ) ; } return node ; } | Get the cached node . |
33,150 | final JcrPropertyDefinition propertyDefinitionFor ( org . modeshape . jcr . value . Property property , Name primaryType , Set < Name > mixinTypes , NodeTypes nodeTypes ) throws ConstraintViolationException { boolean single = property . isSingle ( ) ; boolean skipProtected = false ; JcrPropertyDefinition defn = findBestPropertyDefinition ( primaryType , mixinTypes , property , single , skipProtected , false , nodeTypes ) ; if ( defn != null ) return defn ; defn = findBestPropertyDefinition ( primaryType , mixinTypes , property , single , skipProtected , true , nodeTypes ) ; String pName = readable ( property . getName ( ) ) ; String loc = location ( ) ; if ( defn != null ) { I18n msg = JcrI18n . propertyNoLongerSatisfiesConstraints ; throw new ConstraintViolationException ( msg . text ( pName , loc , defn . getName ( ) , defn . getDeclaringNodeType ( ) . getName ( ) ) ) ; } CachedNode node = sessionCache ( ) . getNode ( key ) ; String ptype = readable ( node . getPrimaryType ( sessionCache ( ) ) ) ; String mixins = readable ( node . getMixinTypes ( sessionCache ( ) ) ) ; String pstr = property . getString ( session . namespaces ( ) ) ; throw new ConstraintViolationException ( JcrI18n . propertyNoLongerHasValidDefinition . text ( pstr , loc , ptype , mixins ) ) ; } | Find the property definition for the property given this node s primary type and mixin types . |
33,151 | final JcrPropertyDefinition findBestPropertyDefinition ( Name primaryTypeNameOfParent , Collection < Name > mixinTypeNamesOfParent , org . modeshape . jcr . value . Property property , boolean isSingle , boolean skipProtected , boolean skipConstraints , NodeTypes nodeTypes ) { JcrPropertyDefinition definition = null ; int propertyType = PropertyTypeUtil . jcrPropertyTypeFor ( property ) ; ValueFactories factories = context ( ) . getValueFactories ( ) ; if ( isSingle ) { Object value = property . getFirstValue ( ) ; Value jcrValue = new JcrValue ( factories , propertyType , value ) ; definition = nodeTypes . findPropertyDefinition ( session , primaryTypeNameOfParent , mixinTypeNamesOfParent , property . getName ( ) , jcrValue , true , skipProtected ) ; } else { Value [ ] jcrValues = new Value [ property . size ( ) ] ; int index = 0 ; for ( Object value : property ) { jcrValues [ index ++ ] = new JcrValue ( factories , propertyType , value ) ; } definition = nodeTypes . findPropertyDefinition ( session , primaryTypeNameOfParent , mixinTypeNamesOfParent , property . getName ( ) , jcrValues , skipProtected ) ; } if ( definition != null ) return definition ; return null ; } | Find the best property definition in this node s primary type and mixin types . |
33,152 | protected final AbstractJcrNode childNode ( Name name , Type expectedType ) throws PathNotFoundException , ItemNotFoundException , InvalidItemStateException { ChildReference ref = node ( ) . getChildReferences ( sessionCache ( ) ) . getChild ( name ) ; if ( ref == null ) { String msg = JcrI18n . childNotFoundUnderNode . text ( readable ( name ) , location ( ) , session . workspaceName ( ) ) ; throw new PathNotFoundException ( msg ) ; } return session ( ) . node ( ref . getKey ( ) , expectedType , key ( ) ) ; } | Get the JCR node for the named child . |
33,153 | protected LinkedList < Property > autoCreatePropertiesFor ( Name nodeName , Name primaryType , PropertyFactory propertyFactory , NodeTypes capabilities ) { Collection < JcrPropertyDefinition > autoPropDefns = capabilities . getAutoCreatedPropertyDefinitions ( primaryType ) ; if ( autoPropDefns . isEmpty ( ) ) { return null ; } LinkedList < Property > props = new LinkedList < Property > ( ) ; for ( JcrPropertyDefinition defn : autoPropDefns ) { Name propName = defn . getInternalName ( ) ; if ( defn . hasDefaultValues ( ) ) { Object [ ] defaultValues = defn . getRawDefaultValues ( ) ; Property prop = null ; if ( defn . isMultiple ( ) ) { prop = propertyFactory . create ( propName , defaultValues ) ; } else { prop = propertyFactory . create ( propName , defaultValues [ 0 ] ) ; } props . add ( prop ) ; } } return props ; } | If there are any auto - created properties create them and return them in a list . |
33,154 | protected void autoCreateChildren ( Name primaryType , NodeTypes capabilities ) throws ItemExistsException , PathNotFoundException , VersionException , ConstraintViolationException , LockException , RepositoryException { Collection < JcrNodeDefinition > autoChildDefns = capabilities . getAutoCreatedChildNodeDefinitions ( primaryType ) ; if ( ! autoChildDefns . isEmpty ( ) ) { Set < Name > childNames = new HashSet < Name > ( ) ; for ( JcrNodeDefinition defn : autoChildDefns ) { assert ! defn . isResidual ( ) ; if ( defn . isProtected ( ) ) { continue ; } Name childName = defn . getInternalName ( ) ; if ( ! childNames . contains ( childName ) ) { JcrNodeType childPrimaryType = defn . getDefaultPrimaryType ( ) ; addChildNode ( childName , childPrimaryType . getInternalName ( ) , null , false , false ) ; } } } } | Create in this node any auto - created child nodes . |
33,155 | final AbstractJcrProperty removeExistingProperty ( Name name ) throws VersionException , LockException , RepositoryException { AbstractJcrProperty existing = getProperty ( name ) ; if ( existing != null ) { existing . remove ( ) ; return existing ; } return null ; } | Removes an existing property with the supplied name . Note that if a property with the given name does not exist then this method returns null and does not throw an exception . |
33,156 | final AbstractJcrProperty setProperty ( Name name , Value [ ] values , int jcrPropertyType , boolean skipReferenceValidation ) throws VersionException , LockException , ConstraintViolationException , RepositoryException { return setProperty ( name , values , jcrPropertyType , false , skipReferenceValidation , false , false ) ; } | Sets a multi valued property skipping over protected ones . |
33,157 | protected final NodeIterator referringNodes ( ReferenceType referenceType ) throws RepositoryException { if ( ! this . isReferenceable ( ) ) { return JcrEmptyNodeIterator . INSTANCE ; } Set < NodeKey > keys = node ( ) . getReferrers ( sessionCache ( ) , referenceType ) ; if ( keys . isEmpty ( ) ) return JcrEmptyNodeIterator . INSTANCE ; return new JcrNodeIterator ( session ( ) , keys . iterator ( ) , keys . size ( ) , null ) ; } | Obtain an iterator over the nodes that reference this node . |
33,158 | protected boolean containsChangesWithExternalDependencies ( AtomicReference < Set < NodeKey > > affectedNodeKeys ) throws RepositoryException { Set < NodeKey > allChanges = sessionCache ( ) . getChangedNodeKeys ( ) ; Set < NodeKey > changesAtOrBelowThis = sessionCache ( ) . getChangedNodeKeysAtOrBelow ( this . node ( ) ) ; removeReferrerChanges ( allChanges , changesAtOrBelowThis ) ; if ( affectedNodeKeys != null ) affectedNodeKeys . set ( changesAtOrBelowThis ) ; return ! changesAtOrBelowThis . containsAll ( allChanges ) ; } | Determines whether this node or any nodes below it contain changes that depend on nodes that are outside of this node s hierarchy . |
33,159 | private void removeReferrerChanges ( Set < NodeKey > allChanges , Set < NodeKey > changesAtOrBelowThis ) throws RepositoryException { for ( Iterator < NodeKey > allChangesIt = allChanges . iterator ( ) ; allChangesIt . hasNext ( ) ; ) { NodeKey changedNodeKey = allChangesIt . next ( ) ; if ( changesAtOrBelowThis . contains ( changedNodeKey ) ) { continue ; } MutableCachedNode changedNodeOutsideBranch = session ( ) . cache ( ) . mutable ( changedNodeKey ) ; AbstractJcrNode changedNode = null ; try { changedNode = session ( ) . node ( changedNodeKey , null ) ; } catch ( ItemNotFoundException e ) { allChangesIt . remove ( ) ; continue ; } boolean isShareable = changedNode . isShareable ( ) ; if ( isShareable ) { allChangesIt . remove ( ) ; continue ; } boolean isReferenceable = changedNode . isReferenceable ( ) ; if ( ! isReferenceable ) { continue ; } Set < NodeKey > changedReferrers = changedNodeOutsideBranch . getChangedReferrerNodes ( ) ; for ( NodeKey changedNodeInBranchKey : changesAtOrBelowThis ) { if ( changedReferrers . contains ( changedNodeInBranchKey ) ) { allChangesIt . remove ( ) ; } } } } | Removes all the keys from the first set which represent referrer node keys to any of the nodes in the second set . |
33,160 | public char [ ] getPassword ( ) { String result = properties . getProperty ( LocalJcrDriver . PASSWORD_PROPERTY_NAME ) ; return result != null ? result . toCharArray ( ) : null ; } | Get the JCR password . This is not required . |
33,161 | public boolean isTeiidSupport ( ) { String result = properties . getProperty ( LocalJcrDriver . TEIID_SUPPORT_PROPERTY_NAME ) ; if ( result == null ) { return false ; } return result . equalsIgnoreCase ( Boolean . TRUE . toString ( ) ) ; } | Return true of Teiid support is required for this connection . |
33,162 | public Credentials getCredentials ( ) { String username = getUsername ( ) ; char [ ] password = getPassword ( ) ; if ( username != null ) { return new SimpleCredentials ( username , password ) ; } return null ; } | Return the credentials based on the user name and password . |
33,163 | public static byte [ ] getHash ( String digestName , InputStream stream ) throws NoSuchAlgorithmException , IOException { CheckArg . isNotNull ( stream , "stream" ) ; MessageDigest digest = MessageDigest . getInstance ( digestName ) ; assert digest != null ; int bufSize = 1024 ; byte [ ] buffer = new byte [ bufSize ] ; int n = stream . read ( buffer , 0 , bufSize ) ; while ( n != - 1 ) { digest . update ( buffer , 0 , n ) ; n = stream . read ( buffer , 0 , bufSize ) ; } return digest . digest ( ) ; } | Get the hash of the supplied content using the digest identified by the supplied name . Note that this method never closes the supplied stream . |
33,164 | public static String sha1 ( String string ) { try { byte [ ] sha1 = SecureHash . getHash ( SecureHash . Algorithm . SHA_1 , string . getBytes ( ) ) ; return SecureHash . asHexString ( sha1 ) ; } catch ( NoSuchAlgorithmException e ) { throw new SystemFailureException ( e ) ; } } | Computes the sha1 value for the given string . |
33,165 | public RepositoryDelegate createRepositoryDelegate ( String url , Properties info , JcrContextFactory contextFactory ) throws SQLException { if ( ! acceptUrl ( url ) ) { throw new SQLException ( JdbcLocalI18n . invalidUrlPrefix . text ( LocalJcrDriver . JNDI_URL_PREFIX ) ) ; } return create ( determineProtocol ( url ) , url , info , contextFactory ) ; } | Create a RepositoryDelegate instance given the connection information . |
33,166 | public static Set < SelectorName > nameSetFrom ( Set < SelectorName > firstSet , Set < SelectorName > secondSet ) { if ( ( firstSet == null || firstSet . isEmpty ( ) ) && ( secondSet == null || secondSet . isEmpty ( ) ) ) { return Collections . emptySet ( ) ; } Set < SelectorName > result = new LinkedHashSet < SelectorName > ( ) ; result . addAll ( firstSet ) ; if ( secondSet != null ) result . addAll ( secondSet ) ; return Collections . unmodifiableSet ( result ) ; } | Create a set that contains the SelectName objects in the supplied sets . |
33,167 | public void setSplitPattern ( String regularExpression ) throws PatternSyntaxException { CheckArg . isNotNull ( regularExpression , "regularExpression" ) ; Pattern . compile ( splitPattern ) ; splitPattern = regularExpression ; } | Sets the regular expression to use to split incoming rows . |
33,168 | public Document read ( ) { try { do { if ( stream == null ) { stream = openNextFile ( ) ; if ( stream == null ) { return null ; } documents = Json . readMultiple ( stream , false ) ; } try { Document doc = documents . nextDocument ( ) ; if ( doc != null ) return doc ; } catch ( IOException e ) { } close ( stream ) ; stream = null ; } while ( true ) ; } catch ( IOException e ) { problems . addError ( JcrI18n . problemsWritingDocumentToBackup , currentFile . getAbsolutePath ( ) , e . getMessage ( ) ) ; return null ; } } | Read the next document from the files . |
33,169 | public Duration add ( long duration , TimeUnit unit ) { long durationInNanos = TimeUnit . NANOSECONDS . convert ( duration , unit ) ; return new Duration ( this . durationInNanos + durationInNanos ) ; } | Add the supplied duration to this duration and return the result . |
33,170 | public Duration subtract ( long duration , TimeUnit unit ) { long durationInNanos = TimeUnit . NANOSECONDS . convert ( duration , unit ) ; return new Duration ( this . durationInNanos - durationInNanos ) ; } | Subtract the supplied duration from this duration and return the result . |
33,171 | public Duration add ( Duration duration ) { return new Duration ( this . durationInNanos + ( duration == null ? 0l : duration . longValue ( ) ) ) ; } | Add the supplied duration to this duration and return the result . A null value is treated as a duration of 0 nanoseconds . |
33,172 | public Duration subtract ( Duration duration ) { return new Duration ( this . durationInNanos - ( duration == null ? 0l : duration . longValue ( ) ) ) ; } | Subtract the supplied duration from this duration and return the result . A null value is treated as a duration of 0 nanoseconds . |
33,173 | public Components getComponents ( ) { if ( this . components == null ) { BigDecimal bigSeconds = new BigDecimal ( this . durationInNanos ) . divide ( new BigDecimal ( 1000000000 ) ) ; int minutes = bigSeconds . intValue ( ) / 60 ; double dMinutes = minutes ; double seconds = bigSeconds . doubleValue ( ) - dMinutes * 60 ; int hours = minutes / 60 ; minutes = minutes - ( hours * 60 ) ; this . components = new Components ( hours , minutes , seconds ) ; } return this . components ; } | Return the duration components . |
33,174 | public long getDuration ( TimeUnit unit ) { if ( unit == null ) throw new IllegalArgumentException ( ) ; return unit . convert ( durationInNanos , TimeUnit . NANOSECONDS ) ; } | Get the duration value in the supplied unit of time . |
33,175 | public void changed ( ChangeSet changes ) { checkNotClosed ( ) ; if ( LOGGER . isTraceEnabled ( ) ) { LOGGER . trace ( "Cache for workspace '{0}' received {1} changes from local sessions: {2}" , workspaceName , changes . size ( ) , changes ) ; } for ( NodeKey key : changes . changedNodes ( ) ) { if ( closed ) break ; nodesByKey . remove ( key ) ; } if ( changeBus != null ) changeBus . notify ( changes ) ; } | Signal that changes have been made to the persisted data . Related information in the cache is cleared and this workspace s listener is notified of the changes . |
33,176 | private static synchronized JcrRepository getRepository ( String configFileName , String repositoryName , final Context nameCtx , final Name jndiName ) throws IOException , RepositoryException , NamingException { if ( ! StringUtil . isBlank ( repositoryName ) ) { ENGINE . start ( ) ; try { JcrRepository repository = ENGINE . getRepository ( repositoryName ) ; switch ( repository . getState ( ) ) { case STARTING : case RUNNING : return repository ; default : LOG . error ( JcrI18n . repositoryIsNotRunningOrHasBeenShutDown , repositoryName ) ; return null ; } } catch ( NoSuchRepositoryException e ) { if ( configFileName == null ) { throw e ; } } } RepositoryConfiguration config = RepositoryConfiguration . read ( configFileName ) ; if ( repositoryName == null ) { repositoryName = config . getName ( ) ; } else if ( ! repositoryName . equals ( config . getName ( ) ) ) { LOG . warn ( JcrI18n . repositoryNameDoesNotMatchConfigurationName , repositoryName , config . getName ( ) , configFileName ) ; } ENGINE . start ( ) ; JcrRepository repository = ENGINE . deploy ( config ) ; try { ENGINE . startRepository ( repository . getName ( ) ) . get ( ) ; } catch ( InterruptedException e ) { Thread . interrupted ( ) ; throw new RepositoryException ( e ) ; } catch ( ExecutionException e ) { throw new RepositoryException ( e . getCause ( ) ) ; } if ( nameCtx instanceof EventContext ) { registerNamingListener ( ( EventContext ) nameCtx , jndiName ) ; } return repository ; } | Get or initialize the JCR Repository instance as described by the supplied configuration file and repository name . |
33,177 | public static TimeBasedKeys create ( int bitsUsedInCounter ) { CheckArg . isPositive ( bitsUsedInCounter , "bitsUsedInCounter" ) ; int maxAvailableBitsToShift = Long . numberOfLeadingZeros ( System . currentTimeMillis ( ) ) ; CheckArg . isLessThan ( bitsUsedInCounter , maxAvailableBitsToShift , "bitsUsedInCounter" ) ; return new TimeBasedKeys ( ( short ) bitsUsedInCounter ) ; } | Create a new generator that uses the specified number of bits for the counter portion of the keys . |
33,178 | public long nextKey ( ) { final long timestamp = System . currentTimeMillis ( ) ; final int increment = counterFor ( timestamp ) ; if ( increment <= maximumCounterValue ) { return ( timestamp << counterBits ) + increment ; } return this . nextKey ( ) ; } | Get the next key for the current time in UTC . |
33,179 | protected void nullReference ( List < Comparison > comparisons , Comparison comparisonToNull ) { if ( comparisonToNull != null ) { for ( int i = 0 ; i != comparisons . size ( ) ; ++ i ) { if ( comparisons . get ( i ) == comparisonToNull ) comparisons . set ( i , null ) ; } } } | Find all occurrences of the comparison object in the supplied list and null the list s reference to it . |
33,180 | protected void nullReference ( List < Comparison > comparisons , Iterable < Comparison > comparisonsToNull ) { for ( Comparison comparisonToNull : comparisonsToNull ) { nullReference ( comparisons , comparisonToNull ) ; } } | Find all references in the supplied list that match those supplied and set them to null . |
33,181 | protected int compareStaticOperands ( QueryContext context , Comparison comparison1 , Comparison comparison2 ) { Object value1 = getValue ( context , comparison1 . getOperand2 ( ) ) ; Object value2 = getValue ( context , comparison2 . getOperand2 ( ) ) ; return ValueComparators . OBJECT_COMPARATOR . compare ( value1 , value2 ) ; } | Compare the values used in the two comparisons |
33,182 | private String getContentType ( List < FileItem > items ) { for ( FileItem i : items ) { if ( ! i . isFormField ( ) && i . getFieldName ( ) . equals ( CONTENT_PARAMETER ) ) { return i . getContentType ( ) ; } } return null ; } | Determines content - type of the uploaded file . |
33,183 | protected long claimUpTo ( int number ) { assert number > 0 ; long nextPosition = this . nextPosition ; long maxPosition = nextPosition + number ; long wrapPoint = maxPosition - bufferSize ; long cachedSlowestConsumerPosition = this . slowestConsumerPosition ; if ( wrapPoint > cachedSlowestConsumerPosition || cachedSlowestConsumerPosition > nextPosition ) { long minPosition ; while ( wrapPoint > ( minPosition = positionOfSlowestPointer ( nextPosition ) ) ) { LockSupport . parkNanos ( 1L ) ; waitStrategy . signalAllWhenBlocking ( ) ; } this . slowestConsumerPosition = minPosition ; } this . nextPosition = maxPosition ; return maxPosition ; } | Claim up to the supplied number of positions . |
33,184 | private List < String > getRootfiles ( ZipInputStream zipStream ) throws Exception { List < String > rootfiles = new ArrayList < > ( ) ; ZipEntry entry = null ; while ( ( entry = zipStream . getNextEntry ( ) ) != null ) { String entryName = entry . getName ( ) ; if ( entryName . endsWith ( "META-INF/container.xml" ) ) { ByteArrayOutputStream content = getZipEntryContent ( zipStream , entry ) ; DocumentBuilderFactory factory = DocumentBuilderFactory . newInstance ( ) ; DocumentBuilder builder = factory . newDocumentBuilder ( ) ; Document doc = builder . parse ( new ByteArrayInputStream ( content . toByteArray ( ) ) ) ; XPathFactory xPathfactory = XPathFactory . newInstance ( ) ; XPath xpath = xPathfactory . newXPath ( ) ; XPathExpression expr = xpath . compile ( "/container/rootfiles/rootfile" ) ; NodeList rootfileNodes = ( NodeList ) expr . evaluate ( doc , XPathConstants . NODESET ) ; for ( int i = 0 ; i < rootfileNodes . getLength ( ) ; i ++ ) { Node node = rootfileNodes . item ( i ) ; rootfiles . add ( node . getAttributes ( ) . getNamedItem ( "full-path" ) . getNodeValue ( ) ) ; } break ; } } return rootfiles ; } | Parse the container file to get the list of all rootfile packages . |
33,185 | private ByteArrayOutputStream getZipEntryContent ( ZipInputStream zipStream , ZipEntry entry ) throws IOException { try ( ByteArrayOutputStream content = new ByteArrayOutputStream ( ) ) { byte [ ] bytes = new byte [ ( int ) entry . getSize ( ) ] ; int read ; while ( ( read = zipStream . read ( bytes , 0 , bytes . length ) ) != - 1 ) { content . write ( bytes , 0 , read ) ; } return content ; } } | Read the content of the ZipEntry without closing the stream . |
33,186 | protected void incrementBinaryReferenceCount ( BinaryKey binaryKey , Set < BinaryKey > unusedBinaryKeys , Set < BinaryKey > usedBinaryKeys ) { String sha1 = binaryKey . toString ( ) ; String key = keyForBinaryReferenceDocument ( sha1 ) ; EditableDocument entry = documentStore . edit ( key , false ) ; if ( entry == null ) { Document content = Schematic . newDocument ( SHA1 , sha1 , REFERENCE_COUNT , 1L ) ; documentStore . localStore ( ) . put ( key , content ) ; } else { Long countValue = entry . getLong ( REFERENCE_COUNT ) ; entry . setNumber ( REFERENCE_COUNT , countValue != null ? countValue + 1 : 1L ) ; } if ( unusedBinaryKeys != null ) { unusedBinaryKeys . remove ( binaryKey ) ; } if ( usedBinaryKeys != null ) { usedBinaryKeys . add ( binaryKey ) ; } } | Increment the reference count for the stored binary value with the supplied SHA - 1 hash . |
33,187 | protected void decrementBinaryReferenceCount ( Object fieldValue , Set < BinaryKey > unusedBinaryKeys , Set < BinaryKey > usedBinaryKeys ) { if ( fieldValue instanceof List < ? > ) { for ( Object value : ( List < ? > ) fieldValue ) { decrementBinaryReferenceCount ( value , unusedBinaryKeys , usedBinaryKeys ) ; } } else if ( fieldValue instanceof Object [ ] ) { for ( Object value : ( Object [ ] ) fieldValue ) { decrementBinaryReferenceCount ( value , unusedBinaryKeys , usedBinaryKeys ) ; } } else { String sha1 = null ; if ( fieldValue instanceof Document ) { Document docValue = ( Document ) fieldValue ; sha1 = docValue . getString ( SHA1_FIELD ) ; } else if ( fieldValue instanceof BinaryKey ) { sha1 = fieldValue . toString ( ) ; } else if ( fieldValue instanceof org . modeshape . jcr . api . Binary && ! ( fieldValue instanceof InMemoryBinaryValue ) ) { sha1 = ( ( org . modeshape . jcr . api . Binary ) fieldValue ) . getHexHash ( ) ; } if ( sha1 != null ) { BinaryKey binaryKey = new BinaryKey ( sha1 ) ; EditableDocument sha1Usage = documentStore . edit ( keyForBinaryReferenceDocument ( sha1 ) , false ) ; if ( sha1Usage != null ) { Long countValue = sha1Usage . getLong ( REFERENCE_COUNT ) ; assert countValue != null ; long count = countValue - 1 ; assert count >= 0 ; if ( count == 0 ) { if ( unusedBinaryKeys != null ) { unusedBinaryKeys . add ( binaryKey ) ; } if ( usedBinaryKeys != null ) { usedBinaryKeys . remove ( binaryKey ) ; } } sha1Usage . setNumber ( REFERENCE_COUNT , count ) ; } else { if ( unusedBinaryKeys != null ) { unusedBinaryKeys . add ( binaryKey ) ; } if ( usedBinaryKeys != null ) { usedBinaryKeys . remove ( binaryKey ) ; } } } } } | Decrement the reference count for the binary value . |
33,188 | protected boolean isLocked ( EditableDocument doc ) { return hasProperty ( doc , JcrLexicon . LOCK_OWNER ) || hasProperty ( doc , JcrLexicon . LOCK_IS_DEEP ) ; } | Checks if the given document is already locked |
33,189 | public static InputStream read ( String path , ClassLoader classLoader , boolean useTLCL ) { if ( useTLCL ) { InputStream stream = Thread . currentThread ( ) . getContextClassLoader ( ) . getResourceAsStream ( path ) ; if ( stream != null ) { return stream ; } } return classLoader != null ? classLoader . getResourceAsStream ( path ) : ResourceLookup . class . getResourceAsStream ( path ) ; } | Returns the stream of a resource at a given path using some optional class loaders . |
33,190 | public static InputStream read ( String path , Class < ? > clazz , boolean useTLCL ) { return read ( path , clazz . getClassLoader ( ) , useTLCL ) ; } | Returns the stream of a resource at a given path using the CL of a class . |
33,191 | private void setS3ObjectTag ( String objectKey , String tagKey , String tagValue ) throws BinaryStoreException { try { GetObjectTaggingRequest getTaggingRequest = new GetObjectTaggingRequest ( bucketName , objectKey ) ; GetObjectTaggingResult getTaggingResult = s3Client . getObjectTagging ( getTaggingRequest ) ; List < Tag > initialTagSet = getTaggingResult . getTagSet ( ) ; List < Tag > mergedTagSet = mergeS3TagSet ( initialTagSet , new Tag ( tagKey , tagValue ) ) ; if ( initialTagSet . size ( ) == mergedTagSet . size ( ) && initialTagSet . containsAll ( mergedTagSet ) ) { return ; } SetObjectTaggingRequest setObjectTaggingRequest = new SetObjectTaggingRequest ( bucketName , objectKey , new ObjectTagging ( mergedTagSet ) ) ; s3Client . setObjectTagging ( setObjectTaggingRequest ) ; } catch ( AmazonClientException e ) { throw new BinaryStoreException ( e ) ; } } | Sets a tag on a S3 object potentially overwriting the existing value . |
33,192 | private List < Tag > mergeS3TagSet ( List < Tag > initialTags , Tag changeTag ) { Map < String , String > mergedTags = initialTags . stream ( ) . collect ( Collectors . toMap ( Tag :: getKey , Tag :: getValue ) ) ; mergedTags . put ( changeTag . getKey ( ) , changeTag . getValue ( ) ) ; return mergedTags . entrySet ( ) . stream ( ) . map ( entry -> new Tag ( entry . getKey ( ) , entry . getValue ( ) ) ) . collect ( Collectors . toList ( ) ) ; } | Merges a new tag into an existing list of tags . It will be either appended to the list or overwrite the value of an existing tag with the same key . |
33,193 | protected long parseLong ( DdlTokenStream tokens , DataType dataType ) { String value = consume ( tokens , dataType , false ) ; return parseLong ( value ) ; } | Returns a long value from the input token stream assuming the long is not bracketed with parenthesis . |
33,194 | protected long parseBracketedLong ( DdlTokenStream tokens , DataType dataType ) { consume ( tokens , dataType , false , L_PAREN ) ; String value = consume ( tokens , dataType , false ) ; consume ( tokens , dataType , false , R_PAREN ) ; return parseLong ( value ) ; } | Returns a long value from the input token stream assuming the long is bracketed with parenthesis . |
33,195 | public static final SequencerPathExpression compile ( String expression ) throws InvalidSequencerPathExpression { CheckArg . isNotNull ( expression , "sequencer path expression" ) ; expression = expression . trim ( ) ; if ( expression . length ( ) == 0 ) { throw new InvalidSequencerPathExpression ( RepositoryI18n . pathExpressionMayNotBeBlank . text ( ) ) ; } java . util . regex . Matcher matcher = TWO_PART_PATTERN . matcher ( expression ) ; if ( ! matcher . matches ( ) ) { throw new InvalidSequencerPathExpression ( RepositoryI18n . pathExpressionIsInvalid . text ( expression ) ) ; } String selectExpression = matcher . group ( 1 ) ; String outputExpression = matcher . group ( 2 ) ; return new SequencerPathExpression ( PathExpression . compile ( selectExpression ) , outputExpression ) ; } | Compile the supplied expression and return the resulting SequencerPathExpression instance . |
33,196 | public Matcher matcher ( String absolutePath ) { PathExpression . Matcher inputMatcher = selectExpression . matcher ( absolutePath ) ; String outputPath = null ; WorkspacePath wsPath = null ; if ( inputMatcher . matches ( ) ) { Map < Integer , String > replacements = new HashMap < Integer , String > ( ) ; for ( int i = 0 , count = inputMatcher . groupCount ( ) ; i <= count ; ++ i ) { replacements . put ( i , inputMatcher . group ( i ) ) ; } String selectedPath = inputMatcher . getSelectedNodePath ( ) ; wsPath = PathExpression . parsePathInWorkspace ( this . outputExpression ) ; if ( wsPath != null ) { if ( wsPath . workspaceName == null ) wsPath = wsPath . withWorkspaceName ( inputMatcher . getSelectedWorkspaceName ( ) ) ; outputPath = wsPath . path ; if ( ! DEFAULT_OUTPUT_EXPRESSION . equals ( outputPath ) ) { java . util . regex . Matcher replacementMatcher = REPLACEMENT_VARIABLE_PATTERN . matcher ( outputPath ) ; StringBuffer sb = new StringBuffer ( ) ; if ( replacementMatcher . find ( ) ) { do { String variable = replacementMatcher . group ( 1 ) ; String replacement = replacements . get ( Integer . valueOf ( variable ) ) ; if ( replacement == null ) replacement = replacementMatcher . group ( 0 ) ; replacementMatcher . appendReplacement ( sb , replacement ) ; } while ( replacementMatcher . find ( ) ) ; replacementMatcher . appendTail ( sb ) ; outputPath = sb . toString ( ) ; } if ( ! outputPath . endsWith ( "/" ) ) outputPath = outputPath + "/" ; outputPath = outputPath . replaceAll ( "/\\./" , "/" ) ; java . util . regex . Matcher parentMatcher = PARENT_PATTERN . matcher ( outputPath ) ; while ( parentMatcher . find ( ) ) { outputPath = parentMatcher . replaceAll ( "" ) ; if ( ! outputPath . endsWith ( "/" ) ) outputPath = outputPath + "/" ; parentMatcher = PARENT_PATTERN . matcher ( outputPath ) ; } outputPath = outputPath . replaceAll ( "/{2,}" , "/" ) ; outputPath = outputPath . replaceAll ( "/@[^/\\[\\]]+$" , "" ) ; outputPath = outputPath . replaceAll ( "/$" , "" ) ; if ( outputPath . length ( ) == 0 ) outputPath = DEFAULT_OUTPUT_EXPRESSION ; } if ( DEFAULT_OUTPUT_EXPRESSION . equals ( outputPath ) ) { outputPath = selectedPath ; } wsPath = wsPath . withPath ( outputPath ) ; } } return new Matcher ( inputMatcher , wsPath ) ; } | Obtain a Matcher that can be used to convert the supplied workspace key and absolute path into an output workspace name and and output path . |
33,197 | public static EditableDocument newDocument ( Document original ) { BasicDocument newDoc = new BasicDocument ( ) ; newDoc . putAll ( original ) ; return new DocumentEditor ( newDoc , DEFAULT_FACTORY ) ; } | Create a new editable document that is a copy of the supplied document . |
33,198 | public static EditableDocument newDocument ( String name , Object value ) { return new DocumentEditor ( new BasicDocument ( name , value ) , DEFAULT_FACTORY ) ; } | Create a new editable document initialized with a single field that can be used as a new document entry in a SchematicDb or as nested documents for other documents . |
33,199 | public static EditableDocument newDocument ( String name1 , Object value1 , String name2 , Object value2 ) { return new DocumentEditor ( new BasicDocument ( name1 , value1 , name2 , value2 ) , DEFAULT_FACTORY ) ; } | Create a new editable document initialized with two fields that can be used as a new document entry in a SchematicDb or as nested documents for other documents . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.