repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
ModeShape/modeshape
sequencers/modeshape-sequencer-xml/src/main/java/org/modeshape/sequencer/xml/XmlSequencer.java
XmlSequencer.setFeature
void setFeature( XMLReader reader, String featureName, boolean value ) { try { if (reader.getFeature(featureName) != value) { reader.setFeature(featureName, value); } } catch (SAXException e) { getLogger().warn(e, "Cannot set feature " + featureName); } }
java
void setFeature( XMLReader reader, String featureName, boolean value ) { try { if (reader.getFeature(featureName) != value) { reader.setFeature(featureName, value); } } catch (SAXException e) { getLogger().warn(e, "Cannot set feature " + featureName); } }
[ "void", "setFeature", "(", "XMLReader", "reader", ",", "String", "featureName", ",", "boolean", "value", ")", "{", "try", "{", "if", "(", "reader", ".", "getFeature", "(", "featureName", ")", "!=", "value", ")", "{", "reader", ".", "setFeature", "(", "fe...
Sets the reader's named feature to the supplied value, only if the feature is not already set to that value. This method does nothing if the feature is not known to the reader. @param reader the reader; may not be null @param featureName the name of the feature; may not be null @param value the value for the feature
[ "Sets", "the", "reader", "s", "named", "feature", "to", "the", "supplied", "value", "only", "if", "the", "feature", "is", "not", "already", "set", "to", "that", "value", ".", "This", "method", "does", "nothing", "if", "the", "feature", "is", "not", "know...
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-xml/src/main/java/org/modeshape/sequencer/xml/XmlSequencer.java#L137-L147
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/text/TokenStream.java
TokenStream.consumeLong
public long consumeLong() throws ParsingException, IllegalStateException { if (completed) throwNoMoreContent(); // Get the value from the current token ... String value = currentToken().value(); try { long result = Long.parseLong(value); moveToNextToken(); return result; } catch (NumberFormatException e) { Position position = currentToken().position(); String msg = CommonI18n.expectingValidLongAtLineAndColumn.text(value, position.getLine(), position.getColumn()); throw new ParsingException(position, msg); } }
java
public long consumeLong() throws ParsingException, IllegalStateException { if (completed) throwNoMoreContent(); // Get the value from the current token ... String value = currentToken().value(); try { long result = Long.parseLong(value); moveToNextToken(); return result; } catch (NumberFormatException e) { Position position = currentToken().position(); String msg = CommonI18n.expectingValidLongAtLineAndColumn.text(value, position.getLine(), position.getColumn()); throw new ParsingException(position, msg); } }
[ "public", "long", "consumeLong", "(", ")", "throws", "ParsingException", ",", "IllegalStateException", "{", "if", "(", "completed", ")", "throwNoMoreContent", "(", ")", ";", "// Get the value from the current token ...", "String", "value", "=", "currentToken", "(", ")...
Convert the value of this token to a long, return it, and move to the next token. @return the current token's value, converted to an integer @throws ParsingException if there is no such token to consume, or if the token cannot be converted to a long @throws IllegalStateException if this method was called before the stream was {@link #start() started}
[ "Convert", "the", "value", "of", "this", "token", "to", "a", "long", "return", "it", "and", "move", "to", "the", "next", "token", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/text/TokenStream.java#L502-L515
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/text/TokenStream.java
TokenStream.consume
public String consume() throws ParsingException, IllegalStateException { if (completed) throwNoMoreContent(); // Get the value from the current token ... String result = currentToken().value(); moveToNextToken(); return result; }
java
public String consume() throws ParsingException, IllegalStateException { if (completed) throwNoMoreContent(); // Get the value from the current token ... String result = currentToken().value(); moveToNextToken(); return result; }
[ "public", "String", "consume", "(", ")", "throws", "ParsingException", ",", "IllegalStateException", "{", "if", "(", "completed", ")", "throwNoMoreContent", "(", ")", ";", "// Get the value from the current token ...", "String", "result", "=", "currentToken", "(", ")"...
Return the value of this token and move to the next token. @return the value of the current token @throws ParsingException if there is no such token to consume @throws IllegalStateException if this method was called before the stream was {@link #start() started}
[ "Return", "the", "value", "of", "this", "token", "and", "move", "to", "the", "next", "token", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/text/TokenStream.java#L546-L552
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/text/TokenStream.java
TokenStream.currentToken
final Token currentToken() throws IllegalStateException, NoSuchElementException { if (currentToken == null) { if (completed) { throw new NoSuchElementException(CommonI18n.noMoreContent.text()); } throw new IllegalStateException(CommonI18n.startMethodMustBeCalledBeforeConsumingOrMatching.text()); } assert currentToken != null; return currentToken; }
java
final Token currentToken() throws IllegalStateException, NoSuchElementException { if (currentToken == null) { if (completed) { throw new NoSuchElementException(CommonI18n.noMoreContent.text()); } throw new IllegalStateException(CommonI18n.startMethodMustBeCalledBeforeConsumingOrMatching.text()); } assert currentToken != null; return currentToken; }
[ "final", "Token", "currentToken", "(", ")", "throws", "IllegalStateException", ",", "NoSuchElementException", "{", "if", "(", "currentToken", "==", "null", ")", "{", "if", "(", "completed", ")", "{", "throw", "new", "NoSuchElementException", "(", "CommonI18n", "...
Get the current token. @return the current token; never null @throws IllegalStateException if this method was called before the stream was {@link #start() started} @throws NoSuchElementException if there are no more tokens
[ "Get", "the", "current", "token", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/text/TokenStream.java#L1255-L1264
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/text/TokenStream.java
TokenStream.previousToken
final Token previousToken() throws IllegalStateException, NoSuchElementException { if (currentToken == null) { if (completed) { if (tokens.isEmpty()) { throw new NoSuchElementException(CommonI18n.noMoreContent.text()); } return tokens.get(tokens.size() - 1); } throw new IllegalStateException(CommonI18n.startMethodMustBeCalledBeforeConsumingOrMatching.text()); } if (tokenIterator.previousIndex() == 0) { throw new NoSuchElementException(CommonI18n.noMoreContent.text()); } return tokens.get(tokenIterator.previousIndex() - 1); }
java
final Token previousToken() throws IllegalStateException, NoSuchElementException { if (currentToken == null) { if (completed) { if (tokens.isEmpty()) { throw new NoSuchElementException(CommonI18n.noMoreContent.text()); } return tokens.get(tokens.size() - 1); } throw new IllegalStateException(CommonI18n.startMethodMustBeCalledBeforeConsumingOrMatching.text()); } if (tokenIterator.previousIndex() == 0) { throw new NoSuchElementException(CommonI18n.noMoreContent.text()); } return tokens.get(tokenIterator.previousIndex() - 1); }
[ "final", "Token", "previousToken", "(", ")", "throws", "IllegalStateException", ",", "NoSuchElementException", "{", "if", "(", "currentToken", "==", "null", ")", "{", "if", "(", "completed", ")", "{", "if", "(", "tokens", ".", "isEmpty", "(", ")", ")", "{"...
Get the previous token. This does not modify the state. @return the previous token; never null @throws IllegalStateException if this method was called before the stream was {@link #start() started} @throws NoSuchElementException if there is no previous token
[ "Get", "the", "previous", "token", ".", "This", "does", "not", "modify", "the", "state", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/text/TokenStream.java#L1297-L1311
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/text/TokenStream.java
TokenStream.generateFragment
static String generateFragment( String content, int indexOfProblem, int charactersToIncludeBeforeAndAfter, String highlightText ) { assert content != null; assert indexOfProblem < content.length(); // Find the substring that immediately precedes the current position ... int beforeStart = Math.max(0, indexOfProblem - charactersToIncludeBeforeAndAfter); String before = content.substring(beforeStart, indexOfProblem); // Find the substring that immediately follows the current position ... int afterEnd = Math.min(indexOfProblem + charactersToIncludeBeforeAndAfter, content.length()); String after = content.substring(indexOfProblem, afterEnd); return before + (highlightText != null ? highlightText : "") + after; }
java
static String generateFragment( String content, int indexOfProblem, int charactersToIncludeBeforeAndAfter, String highlightText ) { assert content != null; assert indexOfProblem < content.length(); // Find the substring that immediately precedes the current position ... int beforeStart = Math.max(0, indexOfProblem - charactersToIncludeBeforeAndAfter); String before = content.substring(beforeStart, indexOfProblem); // Find the substring that immediately follows the current position ... int afterEnd = Math.min(indexOfProblem + charactersToIncludeBeforeAndAfter, content.length()); String after = content.substring(indexOfProblem, afterEnd); return before + (highlightText != null ? highlightText : "") + after; }
[ "static", "String", "generateFragment", "(", "String", "content", ",", "int", "indexOfProblem", ",", "int", "charactersToIncludeBeforeAndAfter", ",", "String", "highlightText", ")", "{", "assert", "content", "!=", "null", ";", "assert", "indexOfProblem", "<", "conte...
Utility method to generate a highlighted fragment of a particular point in the stream. @param content the content from which the fragment should be taken; may not be null @param indexOfProblem the index of the problem point that should be highlighted; must be a valid index in the content @param charactersToIncludeBeforeAndAfter the maximum number of characters before and after the problem point to include in the fragment @param highlightText the text that should be included in the fragment at the problem point to highlight the location, or an empty string if there should be no highlighting @return the highlighted fragment; never null
[ "Utility", "method", "to", "generate", "a", "highlighted", "fragment", "of", "a", "particular", "point", "in", "the", "stream", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/text/TokenStream.java#L1331-L1346
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/plan/CanonicalPlanner.java
CanonicalPlanner.createCanonicalPlan
protected PlanNode createCanonicalPlan( QueryContext context, Query query ) { PlanNode plan = null; // Process the source of the query ... Map<SelectorName, Table> usedSources = new HashMap<SelectorName, Table>(); plan = createPlanNode(context, query.source(), usedSources); // Attach criteria (on top) ... Map<String, Subquery> subqueriesByVariableName = new HashMap<String, Subquery>(); plan = attachCriteria(context, plan, query.constraint(), query.columns(), subqueriesByVariableName); // Attach groupbys (on top) ... // plan = attachGrouping(context,plan,query.getGroupBy()); // Attach the project ... plan = attachProject(context, plan, query.columns(), usedSources); // Attach duplicate removal ... if (query.isDistinct()) { plan = attachDuplicateRemoval(context, plan); } // Process the orderings and limits ... plan = attachSorting(context, plan, query.orderings()); plan = attachLimits(context, plan, query.getLimits()); // Capture if we're limiting the results to 1 row and no offset and no sorting ... if (query.getLimits().isLimitedToSingleRowWithNoOffset() && query.orderings().isEmpty()) { context.getHints().isExistsQuery = true; } // Now add in the subqueries as dependent joins, in reverse order ... plan = attachSubqueries(context, plan, subqueriesByVariableName); // Validate that all the parts of the query are resolvable ... validate(context, query, usedSources); // Now we need to validate all of the subqueries ... for (Subquery subquery : Visitors.subqueries(query, false)) { // Just do it by creating a plan, even though we aren't doing anything with these plans ... createPlan(context, subquery.getQuery()); } return plan; }
java
protected PlanNode createCanonicalPlan( QueryContext context, Query query ) { PlanNode plan = null; // Process the source of the query ... Map<SelectorName, Table> usedSources = new HashMap<SelectorName, Table>(); plan = createPlanNode(context, query.source(), usedSources); // Attach criteria (on top) ... Map<String, Subquery> subqueriesByVariableName = new HashMap<String, Subquery>(); plan = attachCriteria(context, plan, query.constraint(), query.columns(), subqueriesByVariableName); // Attach groupbys (on top) ... // plan = attachGrouping(context,plan,query.getGroupBy()); // Attach the project ... plan = attachProject(context, plan, query.columns(), usedSources); // Attach duplicate removal ... if (query.isDistinct()) { plan = attachDuplicateRemoval(context, plan); } // Process the orderings and limits ... plan = attachSorting(context, plan, query.orderings()); plan = attachLimits(context, plan, query.getLimits()); // Capture if we're limiting the results to 1 row and no offset and no sorting ... if (query.getLimits().isLimitedToSingleRowWithNoOffset() && query.orderings().isEmpty()) { context.getHints().isExistsQuery = true; } // Now add in the subqueries as dependent joins, in reverse order ... plan = attachSubqueries(context, plan, subqueriesByVariableName); // Validate that all the parts of the query are resolvable ... validate(context, query, usedSources); // Now we need to validate all of the subqueries ... for (Subquery subquery : Visitors.subqueries(query, false)) { // Just do it by creating a plan, even though we aren't doing anything with these plans ... createPlan(context, subquery.getQuery()); } return plan; }
[ "protected", "PlanNode", "createCanonicalPlan", "(", "QueryContext", "context", ",", "Query", "query", ")", "{", "PlanNode", "plan", "=", "null", ";", "// Process the source of the query ...", "Map", "<", "SelectorName", ",", "Table", ">", "usedSources", "=", "new",...
Create a canonical query plan for the given query. @param context the context in which the query is being planned @param query the query to be planned @return the root node of the plan tree representing the canonical plan
[ "Create", "a", "canonical", "query", "plan", "for", "the", "given", "query", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/plan/CanonicalPlanner.java#L114-L159
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/plan/CanonicalPlanner.java
CanonicalPlanner.validate
protected void validate( QueryContext context, QueryCommand query, Map<SelectorName, Table> usedSelectors ) { // // Resolve everything ... // Visitors.visitAll(query, new Validator(context, usedSelectors)); // Resolve everything (except subqueries) ... Validator validator = new Validator(context, usedSelectors); query.accept(new WalkAllVisitor(validator) { @Override protected void enqueue( Visitable objectToBeVisited ) { if (objectToBeVisited instanceof Subquery) return; super.enqueue(objectToBeVisited); } }); }
java
protected void validate( QueryContext context, QueryCommand query, Map<SelectorName, Table> usedSelectors ) { // // Resolve everything ... // Visitors.visitAll(query, new Validator(context, usedSelectors)); // Resolve everything (except subqueries) ... Validator validator = new Validator(context, usedSelectors); query.accept(new WalkAllVisitor(validator) { @Override protected void enqueue( Visitable objectToBeVisited ) { if (objectToBeVisited instanceof Subquery) return; super.enqueue(objectToBeVisited); } }); }
[ "protected", "void", "validate", "(", "QueryContext", "context", ",", "QueryCommand", "query", ",", "Map", "<", "SelectorName", ",", "Table", ">", "usedSelectors", ")", "{", "// // Resolve everything ...", "// Visitors.visitAll(query, new Validator(context, usedSelectors));",...
Validate the supplied query. @param context the context in which the query is being planned @param query the set query to be planned @param usedSelectors the map of {@link SelectorName}s (aliases or names) used in the query.
[ "Validate", "the", "supplied", "query", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/plan/CanonicalPlanner.java#L168-L182
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/plan/CanonicalPlanner.java
CanonicalPlanner.createCanonicalPlan
protected PlanNode createCanonicalPlan( QueryContext context, SetQuery query ) { // Process the left and right parts of the query ... PlanNode left = createPlan(context, query.getLeft()); PlanNode right = createPlan(context, query.getRight()); // Wrap in a set operation node ... PlanNode plan = new PlanNode(Type.SET_OPERATION); plan.addChildren(left, right); plan.setProperty(Property.SET_OPERATION, query.operation()); plan.setProperty(Property.SET_USE_ALL, query.isAll()); // Process the orderings and limits ... plan = attachSorting(context, plan, query.orderings()); plan = attachLimits(context, plan, query.getLimits()); // Capture if we're limiting the results to 1 row and no offset and no sorting ... if (query.getLimits().isLimitedToSingleRowWithNoOffset() && query.orderings().isEmpty()) { context.getHints().isExistsQuery = true; } return plan; }
java
protected PlanNode createCanonicalPlan( QueryContext context, SetQuery query ) { // Process the left and right parts of the query ... PlanNode left = createPlan(context, query.getLeft()); PlanNode right = createPlan(context, query.getRight()); // Wrap in a set operation node ... PlanNode plan = new PlanNode(Type.SET_OPERATION); plan.addChildren(left, right); plan.setProperty(Property.SET_OPERATION, query.operation()); plan.setProperty(Property.SET_USE_ALL, query.isAll()); // Process the orderings and limits ... plan = attachSorting(context, plan, query.orderings()); plan = attachLimits(context, plan, query.getLimits()); // Capture if we're limiting the results to 1 row and no offset and no sorting ... if (query.getLimits().isLimitedToSingleRowWithNoOffset() && query.orderings().isEmpty()) { context.getHints().isExistsQuery = true; } return plan; }
[ "protected", "PlanNode", "createCanonicalPlan", "(", "QueryContext", "context", ",", "SetQuery", "query", ")", "{", "// Process the left and right parts of the query ...", "PlanNode", "left", "=", "createPlan", "(", "context", ",", "query", ".", "getLeft", "(", ")", "...
Create a canonical query plan for the given set query. @param context the context in which the query is being planned @param query the set query to be planned @return the root node of the plan tree representing the canonical plan
[ "Create", "a", "canonical", "query", "plan", "for", "the", "given", "set", "query", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/plan/CanonicalPlanner.java#L191-L212
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/plan/CanonicalPlanner.java
CanonicalPlanner.createPlanNode
protected PlanNode createPlanNode( QueryContext context, Source source, Map<SelectorName, Table> usedSelectors ) { if (source instanceof Selector) { // No join required ... assert source instanceof AllNodes || source instanceof NamedSelector; Selector selector = (Selector)source; PlanNode node = new PlanNode(Type.SOURCE); if (selector.hasAlias()) { node.addSelector(selector.alias()); node.setProperty(Property.SOURCE_ALIAS, selector.alias()); node.setProperty(Property.SOURCE_NAME, selector.name()); } else { node.addSelector(selector.name()); node.setProperty(Property.SOURCE_NAME, selector.name()); } // Validate the source name and set the available columns ... NameFactory nameFactory = context.getExecutionContext().getValueFactories().getNameFactory(); // Always use the qualified form when searching for tables Table table = context.getSchemata().getTable(selector.name().qualifiedForm(nameFactory)); if (table != null) { if (table instanceof View) context.getHints().hasView = true; if (usedSelectors.put(selector.aliasOrName(), table) != null) { // There was already a table with this alias or name ... I18n msg = GraphI18n.selectorNamesMayNotBeUsedMoreThanOnce; context.getProblems().addError(msg, selector.aliasOrName().getString()); } node.setProperty(Property.SOURCE_COLUMNS, table.getColumns()); } else { context.getProblems().addError(GraphI18n.tableDoesNotExist, selector.name()); } return node; } if (source instanceof Join) { Join join = (Join)source; JoinCondition joinCondition = join.getJoinCondition(); // Set up new join node corresponding to this join predicate PlanNode node = new PlanNode(Type.JOIN); node.setProperty(Property.JOIN_TYPE, join.type()); node.setProperty(Property.JOIN_ALGORITHM, JoinAlgorithm.NESTED_LOOP); node.setProperty(Property.JOIN_CONDITION, joinCondition); context.getHints().hasJoin = true; if (join.type() == JoinType.LEFT_OUTER) { context.getHints().hasOptionalJoin = true; } // Handle each child Source[] clauses = new Source[] {join.getLeft(), join.getRight()}; for (int i = 0; i < 2; i++) { PlanNode sourceNode = createPlanNode(context, clauses[i], usedSelectors); node.addLastChild(sourceNode); } // Add selectors to the joinNode for (PlanNode child : node.getChildren()) { node.addSelectors(child.getSelectors()); } return node; } // should not get here; if we do, somebody added a new type of source assert false; return null; }
java
protected PlanNode createPlanNode( QueryContext context, Source source, Map<SelectorName, Table> usedSelectors ) { if (source instanceof Selector) { // No join required ... assert source instanceof AllNodes || source instanceof NamedSelector; Selector selector = (Selector)source; PlanNode node = new PlanNode(Type.SOURCE); if (selector.hasAlias()) { node.addSelector(selector.alias()); node.setProperty(Property.SOURCE_ALIAS, selector.alias()); node.setProperty(Property.SOURCE_NAME, selector.name()); } else { node.addSelector(selector.name()); node.setProperty(Property.SOURCE_NAME, selector.name()); } // Validate the source name and set the available columns ... NameFactory nameFactory = context.getExecutionContext().getValueFactories().getNameFactory(); // Always use the qualified form when searching for tables Table table = context.getSchemata().getTable(selector.name().qualifiedForm(nameFactory)); if (table != null) { if (table instanceof View) context.getHints().hasView = true; if (usedSelectors.put(selector.aliasOrName(), table) != null) { // There was already a table with this alias or name ... I18n msg = GraphI18n.selectorNamesMayNotBeUsedMoreThanOnce; context.getProblems().addError(msg, selector.aliasOrName().getString()); } node.setProperty(Property.SOURCE_COLUMNS, table.getColumns()); } else { context.getProblems().addError(GraphI18n.tableDoesNotExist, selector.name()); } return node; } if (source instanceof Join) { Join join = (Join)source; JoinCondition joinCondition = join.getJoinCondition(); // Set up new join node corresponding to this join predicate PlanNode node = new PlanNode(Type.JOIN); node.setProperty(Property.JOIN_TYPE, join.type()); node.setProperty(Property.JOIN_ALGORITHM, JoinAlgorithm.NESTED_LOOP); node.setProperty(Property.JOIN_CONDITION, joinCondition); context.getHints().hasJoin = true; if (join.type() == JoinType.LEFT_OUTER) { context.getHints().hasOptionalJoin = true; } // Handle each child Source[] clauses = new Source[] {join.getLeft(), join.getRight()}; for (int i = 0; i < 2; i++) { PlanNode sourceNode = createPlanNode(context, clauses[i], usedSelectors); node.addLastChild(sourceNode); } // Add selectors to the joinNode for (PlanNode child : node.getChildren()) { node.addSelectors(child.getSelectors()); } return node; } // should not get here; if we do, somebody added a new type of source assert false; return null; }
[ "protected", "PlanNode", "createPlanNode", "(", "QueryContext", "context", ",", "Source", "source", ",", "Map", "<", "SelectorName", ",", "Table", ">", "usedSelectors", ")", "{", "if", "(", "source", "instanceof", "Selector", ")", "{", "// No join required ...", ...
Create a JOIN or SOURCE node that contain the source information. @param context the execution context @param source the source to be processed; may not be null @param usedSelectors the map of {@link SelectorName}s (aliases or names) used in the query. @return the new plan; never null
[ "Create", "a", "JOIN", "or", "SOURCE", "node", "that", "contain", "the", "source", "information", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/plan/CanonicalPlanner.java#L222-L285
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/plan/CanonicalPlanner.java
CanonicalPlanner.attachCriteria
protected PlanNode attachCriteria( final QueryContext context, PlanNode plan, Constraint constraint, List<? extends Column> columns, Map<String, Subquery> subqueriesByVariableName ) { if (constraint == null) return plan; context.getHints().hasCriteria = true; // Extract the list of Constraint objects that all must be satisfied ... LinkedList<Constraint> andableConstraints = new LinkedList<Constraint>(); separateAndConstraints(constraint, andableConstraints); assert !andableConstraints.isEmpty(); // Build up the map of aliases for the properties used in the criteria ... Map<String, String> propertyNameByAlias = new HashMap<String, String>(); for (Column column : columns) { if (column.getColumnName() != null && !column.getColumnName().equals(column.getPropertyName())) { propertyNameByAlias.put(column.getColumnName(), column.getPropertyName()); } } // For each of these constraints, create a criteria (SELECT) node above the supplied (JOIN or SOURCE) node. // Do this in reverse order so that the top-most SELECT node corresponds to the first constraint. while (!andableConstraints.isEmpty()) { Constraint criteria = andableConstraints.removeLast(); // Replace any subqueries with bind variables ... criteria = PlanUtil.replaceSubqueriesWithBindVariables(context, criteria, subqueriesByVariableName); // Replace any use of aliases with the actual properties ... criteria = PlanUtil.replaceAliasesWithProperties(context, criteria, propertyNameByAlias); // Create the select node ... PlanNode criteriaNode = new PlanNode(Type.SELECT); criteriaNode.setProperty(Property.SELECT_CRITERIA, criteria); // Add selectors to the criteria node ... criteriaNode.addSelectors(Visitors.getSelectorsReferencedBy(criteria)); // Is there at least one full-text search or subquery ... Visitors.visitAll(criteria, new Visitors.AbstractVisitor() { @Override public void visit( FullTextSearch obj ) { context.getHints().hasFullTextSearch = true; } }); criteriaNode.addFirstChild(plan); plan = criteriaNode; } if (!subqueriesByVariableName.isEmpty()) { context.getHints().hasSubqueries = true; } return plan; }
java
protected PlanNode attachCriteria( final QueryContext context, PlanNode plan, Constraint constraint, List<? extends Column> columns, Map<String, Subquery> subqueriesByVariableName ) { if (constraint == null) return plan; context.getHints().hasCriteria = true; // Extract the list of Constraint objects that all must be satisfied ... LinkedList<Constraint> andableConstraints = new LinkedList<Constraint>(); separateAndConstraints(constraint, andableConstraints); assert !andableConstraints.isEmpty(); // Build up the map of aliases for the properties used in the criteria ... Map<String, String> propertyNameByAlias = new HashMap<String, String>(); for (Column column : columns) { if (column.getColumnName() != null && !column.getColumnName().equals(column.getPropertyName())) { propertyNameByAlias.put(column.getColumnName(), column.getPropertyName()); } } // For each of these constraints, create a criteria (SELECT) node above the supplied (JOIN or SOURCE) node. // Do this in reverse order so that the top-most SELECT node corresponds to the first constraint. while (!andableConstraints.isEmpty()) { Constraint criteria = andableConstraints.removeLast(); // Replace any subqueries with bind variables ... criteria = PlanUtil.replaceSubqueriesWithBindVariables(context, criteria, subqueriesByVariableName); // Replace any use of aliases with the actual properties ... criteria = PlanUtil.replaceAliasesWithProperties(context, criteria, propertyNameByAlias); // Create the select node ... PlanNode criteriaNode = new PlanNode(Type.SELECT); criteriaNode.setProperty(Property.SELECT_CRITERIA, criteria); // Add selectors to the criteria node ... criteriaNode.addSelectors(Visitors.getSelectorsReferencedBy(criteria)); // Is there at least one full-text search or subquery ... Visitors.visitAll(criteria, new Visitors.AbstractVisitor() { @Override public void visit( FullTextSearch obj ) { context.getHints().hasFullTextSearch = true; } }); criteriaNode.addFirstChild(plan); plan = criteriaNode; } if (!subqueriesByVariableName.isEmpty()) { context.getHints().hasSubqueries = true; } return plan; }
[ "protected", "PlanNode", "attachCriteria", "(", "final", "QueryContext", "context", ",", "PlanNode", "plan", ",", "Constraint", "constraint", ",", "List", "<", "?", "extends", "Column", ">", "columns", ",", "Map", "<", "String", ",", "Subquery", ">", "subqueri...
Attach all criteria above the join nodes. The optimizer will push these criteria down to the appropriate source. @param context the context in which the query is being planned @param plan the existing plan, which joins all source groups @param constraint the criteria or constraint from the query @param columns the columns in the select (that may have aliases) @param subqueriesByVariableName the subqueries by variable name @return the updated plan, or the existing plan if there were no constraints; never null
[ "Attach", "all", "criteria", "above", "the", "join", "nodes", ".", "The", "optimizer", "will", "push", "these", "criteria", "down", "to", "the", "appropriate", "source", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/plan/CanonicalPlanner.java#L297-L353
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/plan/CanonicalPlanner.java
CanonicalPlanner.attachLimits
protected PlanNode attachLimits( QueryContext context, PlanNode plan, Limit limit ) { if (limit.isUnlimited()) return plan; context.getHints().hasLimit = true; PlanNode limitNode = new PlanNode(Type.LIMIT); boolean attach = false; if (limit.getOffset() != 0) { limitNode.setProperty(Property.LIMIT_OFFSET, limit.getOffset()); attach = true; } if (!limit.isUnlimited()) { limitNode.setProperty(Property.LIMIT_COUNT, limit.getRowLimit()); attach = true; } if (attach) { limitNode.addLastChild(plan); plan = limitNode; } return plan; }
java
protected PlanNode attachLimits( QueryContext context, PlanNode plan, Limit limit ) { if (limit.isUnlimited()) return plan; context.getHints().hasLimit = true; PlanNode limitNode = new PlanNode(Type.LIMIT); boolean attach = false; if (limit.getOffset() != 0) { limitNode.setProperty(Property.LIMIT_OFFSET, limit.getOffset()); attach = true; } if (!limit.isUnlimited()) { limitNode.setProperty(Property.LIMIT_COUNT, limit.getRowLimit()); attach = true; } if (attach) { limitNode.addLastChild(plan); plan = limitNode; } return plan; }
[ "protected", "PlanNode", "attachLimits", "(", "QueryContext", "context", ",", "PlanNode", "plan", ",", "Limit", "limit", ")", "{", "if", "(", "limit", ".", "isUnlimited", "(", ")", ")", "return", "plan", ";", "context", ".", "getHints", "(", ")", ".", "h...
Attach a LIMIT node at the top of the plan tree. @param context the context in which the query is being planned @param plan the existing plan @param limit the limit definition; may be null @return the updated plan, or the existing plan if there were no limits
[ "Attach", "a", "LIMIT", "node", "at", "the", "top", "of", "the", "plan", "tree", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/plan/CanonicalPlanner.java#L410-L431
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/plan/CanonicalPlanner.java
CanonicalPlanner.attachProject
protected PlanNode attachProject( QueryContext context, PlanNode plan, List<? extends Column> columns, Map<SelectorName, Table> selectors ) { PlanNode projectNode = new PlanNode(Type.PROJECT); List<Column> newColumns = new LinkedList<Column>(); List<String> newTypes = new ArrayList<String>(); final boolean multipleSelectors = selectors.size() > 1; final boolean qualifyExpandedColumns = context.getHints().qualifyExpandedColumnNames; if (columns == null || columns.isEmpty()) { // SELECT *, so find all of the columns that are available from all the sources ... for (Map.Entry<SelectorName, Table> entry : selectors.entrySet()) { SelectorName tableName = entry.getKey(); Table table = entry.getValue(); // Add the selector that is being used ... projectNode.addSelector(tableName); // Compute the columns from this selector ... allColumnsFor(table, tableName, newColumns, newTypes, qualifyExpandedColumns); } } else { // Add the selector used by each column ... for (Column column : columns) { SelectorName tableName = column.selectorName(); // Add the selector that is being used ... projectNode.addSelector(tableName); // Verify that each column is available in the appropriate source ... Table table = selectors.get(tableName); if (table == null) { context.getProblems().addError(GraphI18n.tableDoesNotExist, tableName); } else { // Make sure that the column is in the table ... String columnName = column.getPropertyName(); if ("*".equals(columnName) || columnName == null) { // This is a 'SELECT *' on this source, but this source is one of multiple sources ... // See https://issues.apache.org/jira/browse/JCR-3313; TCK test expects 'true' for last param allColumnsFor(table, tableName, newColumns, newTypes, qualifyExpandedColumns); } else { // This is a particular column, so add it ... if (!newColumns.contains(column)) { if (multipleSelectors && column.getPropertyName().equals(column.getColumnName())) { column = column.withColumnName(column.getSelectorName() + "." + column.getColumnName()); } newColumns.add(column); org.modeshape.jcr.query.validate.Schemata.Column schemaColumn = table.getColumn(columnName); if (schemaColumn != null) { newTypes.add(schemaColumn.getPropertyTypeName()); } else { newTypes.add(context.getTypeSystem().getDefaultType()); } } } boolean validateColumnExistance = context.getHints().validateColumnExistance && !table.hasExtraColumns(); boolean columnNameIsWildcard = columnName == null || "*".equals(columnName); if (!columnNameIsWildcard && table.getColumn(columnName) == null && validateColumnExistance) { context.getProblems().addError(GraphI18n.columnDoesNotExistOnTable, columnName, tableName); } } } } projectNode.setProperty(Property.PROJECT_COLUMNS, newColumns); projectNode.setProperty(Property.PROJECT_COLUMN_TYPES, newTypes); projectNode.addLastChild(plan); return projectNode; }
java
protected PlanNode attachProject( QueryContext context, PlanNode plan, List<? extends Column> columns, Map<SelectorName, Table> selectors ) { PlanNode projectNode = new PlanNode(Type.PROJECT); List<Column> newColumns = new LinkedList<Column>(); List<String> newTypes = new ArrayList<String>(); final boolean multipleSelectors = selectors.size() > 1; final boolean qualifyExpandedColumns = context.getHints().qualifyExpandedColumnNames; if (columns == null || columns.isEmpty()) { // SELECT *, so find all of the columns that are available from all the sources ... for (Map.Entry<SelectorName, Table> entry : selectors.entrySet()) { SelectorName tableName = entry.getKey(); Table table = entry.getValue(); // Add the selector that is being used ... projectNode.addSelector(tableName); // Compute the columns from this selector ... allColumnsFor(table, tableName, newColumns, newTypes, qualifyExpandedColumns); } } else { // Add the selector used by each column ... for (Column column : columns) { SelectorName tableName = column.selectorName(); // Add the selector that is being used ... projectNode.addSelector(tableName); // Verify that each column is available in the appropriate source ... Table table = selectors.get(tableName); if (table == null) { context.getProblems().addError(GraphI18n.tableDoesNotExist, tableName); } else { // Make sure that the column is in the table ... String columnName = column.getPropertyName(); if ("*".equals(columnName) || columnName == null) { // This is a 'SELECT *' on this source, but this source is one of multiple sources ... // See https://issues.apache.org/jira/browse/JCR-3313; TCK test expects 'true' for last param allColumnsFor(table, tableName, newColumns, newTypes, qualifyExpandedColumns); } else { // This is a particular column, so add it ... if (!newColumns.contains(column)) { if (multipleSelectors && column.getPropertyName().equals(column.getColumnName())) { column = column.withColumnName(column.getSelectorName() + "." + column.getColumnName()); } newColumns.add(column); org.modeshape.jcr.query.validate.Schemata.Column schemaColumn = table.getColumn(columnName); if (schemaColumn != null) { newTypes.add(schemaColumn.getPropertyTypeName()); } else { newTypes.add(context.getTypeSystem().getDefaultType()); } } } boolean validateColumnExistance = context.getHints().validateColumnExistance && !table.hasExtraColumns(); boolean columnNameIsWildcard = columnName == null || "*".equals(columnName); if (!columnNameIsWildcard && table.getColumn(columnName) == null && validateColumnExistance) { context.getProblems().addError(GraphI18n.columnDoesNotExistOnTable, columnName, tableName); } } } } projectNode.setProperty(Property.PROJECT_COLUMNS, newColumns); projectNode.setProperty(Property.PROJECT_COLUMN_TYPES, newTypes); projectNode.addLastChild(plan); return projectNode; }
[ "protected", "PlanNode", "attachProject", "(", "QueryContext", "context", ",", "PlanNode", "plan", ",", "List", "<", "?", "extends", "Column", ">", "columns", ",", "Map", "<", "SelectorName", ",", "Table", ">", "selectors", ")", "{", "PlanNode", "projectNode",...
Attach a PROJECT node at the top of the plan tree. @param context the context in which the query is being planned @param plan the existing plan @param columns the columns being projected; may be null @param selectors the selectors keyed by their alias or name @return the updated plan
[ "Attach", "a", "PROJECT", "node", "at", "the", "top", "of", "the", "plan", "tree", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/plan/CanonicalPlanner.java#L442-L507
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/plan/CanonicalPlanner.java
CanonicalPlanner.attachSubqueries
protected PlanNode attachSubqueries( QueryContext context, PlanNode plan, Map<String, Subquery> subqueriesByVariableName ) { // Order the variable names in reverse order ... List<String> varNames = new ArrayList<String>(subqueriesByVariableName.keySet()); Collections.sort(varNames); Collections.reverse(varNames); for (String varName : varNames) { Subquery subquery = subqueriesByVariableName.get(varName); // Plan out the subquery ... PlanNode subqueryNode = createPlan(context, subquery.getQuery()); setSubqueryVariableName(subqueryNode, varName); // Create a DEPENDENT_QUERY node, with the subquery on the LHS (so it is executed first) ... PlanNode depQuery = new PlanNode(Type.DEPENDENT_QUERY); depQuery.addChildren(subqueryNode, plan); depQuery.addSelectors(subqueryNode.getSelectors()); depQuery.addSelectors(plan.getSelectors()); plan = depQuery; } return plan; }
java
protected PlanNode attachSubqueries( QueryContext context, PlanNode plan, Map<String, Subquery> subqueriesByVariableName ) { // Order the variable names in reverse order ... List<String> varNames = new ArrayList<String>(subqueriesByVariableName.keySet()); Collections.sort(varNames); Collections.reverse(varNames); for (String varName : varNames) { Subquery subquery = subqueriesByVariableName.get(varName); // Plan out the subquery ... PlanNode subqueryNode = createPlan(context, subquery.getQuery()); setSubqueryVariableName(subqueryNode, varName); // Create a DEPENDENT_QUERY node, with the subquery on the LHS (so it is executed first) ... PlanNode depQuery = new PlanNode(Type.DEPENDENT_QUERY); depQuery.addChildren(subqueryNode, plan); depQuery.addSelectors(subqueryNode.getSelectors()); depQuery.addSelectors(plan.getSelectors()); plan = depQuery; } return plan; }
[ "protected", "PlanNode", "attachSubqueries", "(", "QueryContext", "context", ",", "PlanNode", "plan", ",", "Map", "<", "String", ",", "Subquery", ">", "subqueriesByVariableName", ")", "{", "// Order the variable names in reverse order ...", "List", "<", "String", ">", ...
Attach plan nodes for each subquery, resulting with the first subquery at the top of the plan tree. @param context the context in which the query is being planned @param plan the existing plan @param subqueriesByVariableName the queries by the variable name used in substitution @return the updated plan, or the existing plan if there were no limits
[ "Attach", "plan", "nodes", "for", "each", "subquery", "resulting", "with", "the", "first", "subquery", "at", "the", "top", "of", "the", "plan", "tree", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/plan/CanonicalPlanner.java#L552-L574
train
ModeShape/modeshape
modeshape-jca/src/main/java/org/modeshape/jca/JcrManagedConnectionFactory.java
JcrManagedConnectionFactory.getRepository
public synchronized Repository getRepository() throws ResourceException { if (this.repository == null) { LOGGER.debug("Deploying repository URL [{0}]", repositoryURL); this.repository = deployRepository(repositoryURL); } return this.repository; }
java
public synchronized Repository getRepository() throws ResourceException { if (this.repository == null) { LOGGER.debug("Deploying repository URL [{0}]", repositoryURL); this.repository = deployRepository(repositoryURL); } return this.repository; }
[ "public", "synchronized", "Repository", "getRepository", "(", ")", "throws", "ResourceException", "{", "if", "(", "this", ".", "repository", "==", "null", ")", "{", "LOGGER", ".", "debug", "(", "\"Deploying repository URL [{0}]\"", ",", "repositoryURL", ")", ";", ...
Provides access to the configured repository. @return repository specified by resource adapter configuration. @throws ResourceException if there is an error getting the repository
[ "Provides", "access", "to", "the", "configured", "repository", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jca/src/main/java/org/modeshape/jca/JcrManagedConnectionFactory.java#L138-L144
train
ModeShape/modeshape
modeshape-jca/src/main/java/org/modeshape/jca/JcrManagedConnectionFactory.java
JcrManagedConnectionFactory.createConnectionFactory
@Override public Object createConnectionFactory( ConnectionManager cxManager ) throws ResourceException { JcrRepositoryHandle handle = new JcrRepositoryHandle(this, cxManager); return handle; }
java
@Override public Object createConnectionFactory( ConnectionManager cxManager ) throws ResourceException { JcrRepositoryHandle handle = new JcrRepositoryHandle(this, cxManager); return handle; }
[ "@", "Override", "public", "Object", "createConnectionFactory", "(", "ConnectionManager", "cxManager", ")", "throws", "ResourceException", "{", "JcrRepositoryHandle", "handle", "=", "new", "JcrRepositoryHandle", "(", "this", ",", "cxManager", ")", ";", "return", "hand...
Creates a Connection Factory instance. @param cxManager ConnectionManager to be associated with created EIS connection factory instance @return EIS-specific Connection Factory instance or javax.resource.cci.ConnectionFactory instance @throws ResourceException Generic exception
[ "Creates", "a", "Connection", "Factory", "instance", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jca/src/main/java/org/modeshape/jca/JcrManagedConnectionFactory.java#L153-L157
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/index/local/LocalIndexBuilder.java
LocalIndexBuilder.validate
protected static void validate( IndexDefinition defn, Problems problems ) { if (!defn.hasSingleColumn()) { problems.addError(JcrI18n.localIndexProviderDoesNotSupportMultiColumnIndexes, defn.getName(), defn.getProviderName()); } switch (defn.getKind()) { case TEXT: // This is not valid ... problems.addError(JcrI18n.localIndexProviderDoesNotSupportTextIndexes, defn.getName(),defn.getProviderName()); } }
java
protected static void validate( IndexDefinition defn, Problems problems ) { if (!defn.hasSingleColumn()) { problems.addError(JcrI18n.localIndexProviderDoesNotSupportMultiColumnIndexes, defn.getName(), defn.getProviderName()); } switch (defn.getKind()) { case TEXT: // This is not valid ... problems.addError(JcrI18n.localIndexProviderDoesNotSupportTextIndexes, defn.getName(),defn.getProviderName()); } }
[ "protected", "static", "void", "validate", "(", "IndexDefinition", "defn", ",", "Problems", "problems", ")", "{", "if", "(", "!", "defn", ".", "hasSingleColumn", "(", ")", ")", "{", "problems", ".", "addError", "(", "JcrI18n", ".", "localIndexProviderDoesNotSu...
Validate whether the index definition is acceptable for this provider. @param defn the definition to validate; may not be {@code null} @param problems the component to record any problems, errors, or warnings; may not be null
[ "Validate", "whether", "the", "index", "definition", "is", "acceptable", "for", "this", "provider", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/index/local/LocalIndexBuilder.java#L91-L100
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/collection/ring/RingBuffer.java
RingBuffer.add
public boolean add( T entry ) { assert entry != null; if (!addEntries.get()) return false; try { producerLock.lock(); long position = cursor.claim(); // blocks; if this fails, we will not have successfully claimed and nothing to do ... int index = (int)(position & mask); buffer[index] = entry; return cursor.publish(position); } finally { producerLock.unlock(); } }
java
public boolean add( T entry ) { assert entry != null; if (!addEntries.get()) return false; try { producerLock.lock(); long position = cursor.claim(); // blocks; if this fails, we will not have successfully claimed and nothing to do ... int index = (int)(position & mask); buffer[index] = entry; return cursor.publish(position); } finally { producerLock.unlock(); } }
[ "public", "boolean", "add", "(", "T", "entry", ")", "{", "assert", "entry", "!=", "null", ";", "if", "(", "!", "addEntries", ".", "get", "(", ")", ")", "return", "false", ";", "try", "{", "producerLock", ".", "lock", "(", ")", ";", "long", "positio...
Add to this buffer a single entry. This method blocks if there is no room in the ring buffer, providing back pressure on the caller in such cases. Note that if this method blocks for any length of time, that means at least one consumer has yet to process all of the entries that are currently in the ring buffer. In such cases, consider whether a larger ring buffer is warranted. @param entry the entry to be added; may not be null @return true if the entry was added, or false if the buffer has been {@link #shutdown()}
[ "Add", "to", "this", "buffer", "a", "single", "entry", ".", "This", "method", "blocks", "if", "there", "is", "no", "room", "in", "the", "ring", "buffer", "providing", "back", "pressure", "on", "the", "caller", "in", "such", "cases", ".", "Note", "that", ...
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/collection/ring/RingBuffer.java#L149-L161
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/collection/ring/RingBuffer.java
RingBuffer.add
public boolean add( T[] entries ) { assert entries != null; if (entries.length == 0 || !addEntries.get()) return false; try { producerLock.lock(); long position = cursor.claim(entries.length); // blocks for (int i = 0; i != entries.length; ++i) { int index = (int)(position & mask); buffer[index] = entries[i]; } return cursor.publish(position); } finally { producerLock.unlock(); } }
java
public boolean add( T[] entries ) { assert entries != null; if (entries.length == 0 || !addEntries.get()) return false; try { producerLock.lock(); long position = cursor.claim(entries.length); // blocks for (int i = 0; i != entries.length; ++i) { int index = (int)(position & mask); buffer[index] = entries[i]; } return cursor.publish(position); } finally { producerLock.unlock(); } }
[ "public", "boolean", "add", "(", "T", "[", "]", "entries", ")", "{", "assert", "entries", "!=", "null", ";", "if", "(", "entries", ".", "length", "==", "0", "||", "!", "addEntries", ".", "get", "(", ")", ")", "return", "false", ";", "try", "{", "...
Add to this buffer multiple entries. This method blocks until it is added. @param entries the entries that are to be added; may not be null @return true if all of the entries were added, or false if the buffer has been {@link #shutdown()} and none of the entries were added
[ "Add", "to", "this", "buffer", "multiple", "entries", ".", "This", "method", "blocks", "until", "it", "is", "added", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/collection/ring/RingBuffer.java#L170-L184
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/collection/ring/RingBuffer.java
RingBuffer.remove
public boolean remove( C consumer ) { if (consumer != null) { // Iterate through the map to find the runner that owns this consumer ... ConsumerRunner match = null; for (ConsumerRunner runner : consumers) { if (runner.getConsumer().equals(consumer)) { match = runner; break; } } // Try to remove the matching runner (if we found one) from our list ... if (match != null) { // Tell the thread to stop and wait for it, after which it will have been removed from our map ... match.close(); return true; } } // We either didn't find it, or we found it but something else remove it while we searched ... return false; }
java
public boolean remove( C consumer ) { if (consumer != null) { // Iterate through the map to find the runner that owns this consumer ... ConsumerRunner match = null; for (ConsumerRunner runner : consumers) { if (runner.getConsumer().equals(consumer)) { match = runner; break; } } // Try to remove the matching runner (if we found one) from our list ... if (match != null) { // Tell the thread to stop and wait for it, after which it will have been removed from our map ... match.close(); return true; } } // We either didn't find it, or we found it but something else remove it while we searched ... return false; }
[ "public", "boolean", "remove", "(", "C", "consumer", ")", "{", "if", "(", "consumer", "!=", "null", ")", "{", "// Iterate through the map to find the runner that owns this consumer ...", "ConsumerRunner", "match", "=", "null", ";", "for", "(", "ConsumerRunner", "runne...
Remove the supplied consumer, and block until it stops running and is closed and removed from this buffer. The consumer is removed at the earliest conevenient point, and will stop seeing entries as soon as it is removed. @param consumer the consumer component to be removed entry; retries will not be attempted if the value is less than 1 @return true if the consumer was removed, stopped, and closed, or false if the supplied consumer was not actually registered with this buffer (it may have completed) @throws IllegalStateException if the ring buffer has already been {@link #shutdown()}
[ "Remove", "the", "supplied", "consumer", "and", "block", "until", "it", "stops", "running", "and", "is", "closed", "and", "removed", "from", "this", "buffer", ".", "The", "consumer", "is", "removed", "at", "the", "earliest", "conevenient", "point", "and", "w...
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/collection/ring/RingBuffer.java#L261-L280
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/collection/ring/RingBuffer.java
RingBuffer.shutdown
public void shutdown() { // Prevent new entries from being added ... this.addEntries.set(false); // Mark the cursor as being finished; this will stop all consumers from waiting for a batch ... this.cursor.complete(); // Each of the consumer threads will complete the batch they're working on, but will then terminate ... // Stop the garbage collection thread (if running) ... if (this.gcConsumer != null) this.gcConsumer.close(); // Now, block until all the runners have completed ... for (ConsumerRunner runner : new HashSet<>(consumers)) { // use a copy of the runners; they're removed when they close runner.waitForCompletion(); } assert consumers.isEmpty(); }
java
public void shutdown() { // Prevent new entries from being added ... this.addEntries.set(false); // Mark the cursor as being finished; this will stop all consumers from waiting for a batch ... this.cursor.complete(); // Each of the consumer threads will complete the batch they're working on, but will then terminate ... // Stop the garbage collection thread (if running) ... if (this.gcConsumer != null) this.gcConsumer.close(); // Now, block until all the runners have completed ... for (ConsumerRunner runner : new HashSet<>(consumers)) { // use a copy of the runners; they're removed when they close runner.waitForCompletion(); } assert consumers.isEmpty(); }
[ "public", "void", "shutdown", "(", ")", "{", "// Prevent new entries from being added ...", "this", ".", "addEntries", ".", "set", "(", "false", ")", ";", "// Mark the cursor as being finished; this will stop all consumers from waiting for a batch ...", "this", ".", "cursor", ...
Shutdown this ring buffer by preventing any further entries, but allowing all existing entries to be processed by all consumers.
[ "Shutdown", "this", "ring", "buffer", "by", "preventing", "any", "further", "entries", "but", "allowing", "all", "existing", "entries", "to", "be", "processed", "by", "all", "consumers", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/collection/ring/RingBuffer.java#L310-L327
train
ModeShape/modeshape
index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/client/EsRequest.java
EsRequest.put
public void put(String name, Object value) { if (value instanceof EsRequest) { document.setDocument(name, ((EsRequest)value).document); } else { document.set(name, value); } }
java
public void put(String name, Object value) { if (value instanceof EsRequest) { document.setDocument(name, ((EsRequest)value).document); } else { document.set(name, value); } }
[ "public", "void", "put", "(", "String", "name", ",", "Object", "value", ")", "{", "if", "(", "value", "instanceof", "EsRequest", ")", "{", "document", ".", "setDocument", "(", "name", ",", "(", "(", "EsRequest", ")", "value", ")", ".", "document", ")",...
Adds single property value. @param name property name. @param value property value.
[ "Adds", "single", "property", "value", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/client/EsRequest.java#L56-L62
train
ModeShape/modeshape
index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/client/EsRequest.java
EsRequest.put
public void put(String name, Object[] values) { if (values instanceof EsRequest[]) { Object[] docs = new Object[values.length]; for (int i = 0; i < docs.length; i++) { docs[i] = ((EsRequest)values[i]).document; } document.setArray(name, docs); } else { document.setArray(name, values); } }
java
public void put(String name, Object[] values) { if (values instanceof EsRequest[]) { Object[] docs = new Object[values.length]; for (int i = 0; i < docs.length; i++) { docs[i] = ((EsRequest)values[i]).document; } document.setArray(name, docs); } else { document.setArray(name, values); } }
[ "public", "void", "put", "(", "String", "name", ",", "Object", "[", "]", "values", ")", "{", "if", "(", "values", "instanceof", "EsRequest", "[", "]", ")", "{", "Object", "[", "]", "docs", "=", "new", "Object", "[", "values", ".", "length", "]", ";...
Adds multivalued property value. @param name property name. @param value property values.
[ "Adds", "multivalued", "property", "value", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/client/EsRequest.java#L70-L80
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/xml/XmlCharacters.java
XmlCharacters.isValidName
public static boolean isValidName( String name ) { if (name == null || name.length() == 0) return false; CharacterIterator iter = new StringCharacterIterator(name); char c = iter.first(); if (!isValidNameStart(c)) return false; while (c != CharacterIterator.DONE) { if (!isValidName(c)) return false; c = iter.next(); } return true; }
java
public static boolean isValidName( String name ) { if (name == null || name.length() == 0) return false; CharacterIterator iter = new StringCharacterIterator(name); char c = iter.first(); if (!isValidNameStart(c)) return false; while (c != CharacterIterator.DONE) { if (!isValidName(c)) return false; c = iter.next(); } return true; }
[ "public", "static", "boolean", "isValidName", "(", "String", "name", ")", "{", "if", "(", "name", "==", "null", "||", "name", ".", "length", "(", ")", "==", "0", ")", "return", "false", ";", "CharacterIterator", "iter", "=", "new", "StringCharacterIterator...
Determine if the supplied name is a valid XML Name. @param name the string being checked @return true if the supplied name is indeed a valid XML Name, or false otherwise
[ "Determine", "if", "the", "supplied", "name", "is", "a", "valid", "XML", "Name", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/xml/XmlCharacters.java#L278-L288
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/xml/XmlCharacters.java
XmlCharacters.isValidNcName
public static boolean isValidNcName( String name ) { if (name == null || name.length() == 0) return false; CharacterIterator iter = new StringCharacterIterator(name); char c = iter.first(); if (!isValidNcNameStart(c)) return false; while (c != CharacterIterator.DONE) { if (!isValidNcName(c)) return false; c = iter.next(); } return true; }
java
public static boolean isValidNcName( String name ) { if (name == null || name.length() == 0) return false; CharacterIterator iter = new StringCharacterIterator(name); char c = iter.first(); if (!isValidNcNameStart(c)) return false; while (c != CharacterIterator.DONE) { if (!isValidNcName(c)) return false; c = iter.next(); } return true; }
[ "public", "static", "boolean", "isValidNcName", "(", "String", "name", ")", "{", "if", "(", "name", "==", "null", "||", "name", ".", "length", "(", ")", "==", "0", ")", "return", "false", ";", "CharacterIterator", "iter", "=", "new", "StringCharacterIterat...
Determine if the supplied name is a valid XML NCName. @param name the string being checked @return true if the supplied name is indeed a valid XML NCName, or false otherwise
[ "Determine", "if", "the", "supplied", "name", "is", "a", "valid", "XML", "NCName", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/xml/XmlCharacters.java#L296-L306
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryQueryManager.java
RepositoryQueryManager.queryEngine
protected final QueryEngine queryEngine() { if (queryEngine == null) { try { engineInitLock.lock(); if (queryEngine == null) { QueryEngineBuilder builder = null; if (!repoConfig.getIndexProviders().isEmpty()) { // There is at least one index provider ... builder = IndexQueryEngine.builder(); logger.debug("Queries with indexes are enabled for the '{0}' repository. Executing queries may require scanning the repository contents when the query cannot use the defined indexes.", repoConfig.getName()); } else { // There are no indexes ... builder = ScanningQueryEngine.builder(); logger.debug("Queries with no indexes are enabled for the '{0}' repository. Executing queries will always scan the repository contents.", repoConfig.getName()); } queryEngine = builder.using(repoConfig, indexManager, runningState.context()).build(); } } finally { engineInitLock.unlock(); } } return queryEngine; }
java
protected final QueryEngine queryEngine() { if (queryEngine == null) { try { engineInitLock.lock(); if (queryEngine == null) { QueryEngineBuilder builder = null; if (!repoConfig.getIndexProviders().isEmpty()) { // There is at least one index provider ... builder = IndexQueryEngine.builder(); logger.debug("Queries with indexes are enabled for the '{0}' repository. Executing queries may require scanning the repository contents when the query cannot use the defined indexes.", repoConfig.getName()); } else { // There are no indexes ... builder = ScanningQueryEngine.builder(); logger.debug("Queries with no indexes are enabled for the '{0}' repository. Executing queries will always scan the repository contents.", repoConfig.getName()); } queryEngine = builder.using(repoConfig, indexManager, runningState.context()).build(); } } finally { engineInitLock.unlock(); } } return queryEngine; }
[ "protected", "final", "QueryEngine", "queryEngine", "(", ")", "{", "if", "(", "queryEngine", "==", "null", ")", "{", "try", "{", "engineInitLock", ".", "lock", "(", ")", ";", "if", "(", "queryEngine", "==", "null", ")", "{", "QueryEngineBuilder", "builder"...
Obtain the query engine, which is created lazily and in a thread-safe manner. @return the query engine; never null
[ "Obtain", "the", "query", "engine", "which", "is", "created", "lazily", "and", "in", "a", "thread", "-", "safe", "manner", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryQueryManager.java#L238-L262
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryQueryManager.java
RepositoryQueryManager.reindexIfNeeded
protected void reindexIfNeeded( boolean async, final boolean includeSystemContent ) { final ScanningRequest request = toBeScanned.drain(); if (!request.isEmpty()) { final RepositoryCache repoCache = runningState.repositoryCache(); scan(async, () -> { // Scan each of the workspace-path pairs ... ScanOperation op = (workspaceName, path, writer) -> { NodeCache workspaceCache = repoCache.getWorkspaceCache(workspaceName); if (workspaceCache != null) { // The workspace is still valid ... CachedNode node = workspaceCache.getNode(workspaceCache.getRootKey()); if (!path.isRoot()) { for (Segment segment : path) { ChildReference child = node.getChildReferences(workspaceCache).getChild(segment); if (child == null) { // The child no longer exists, so ignore this pair ... node = null; break; } node = workspaceCache.getNode(child); if (node == null) break; } } if (node != null) { if (logger.isDebugEnabled()) { logger.debug("Performing full reindexing for repository '{0}' and workspace '{1}'", repoCache.getName(), workspaceName); } // If we find a node to start at, then scan the content ... // in certain cases (e.g. at startup) we have to index the system content (if it applies to // any of the indexes) boolean scanSystemContent = includeSystemContent || repoCache.getSystemWorkspaceName().equals(workspaceName); updateIndexesStatus(workspaceName, IndexManager.IndexStatus.ENABLED, IndexManager.IndexStatus.REINDEXING); if (reindexContent(workspaceName, workspaceCache, node, Integer.MAX_VALUE, scanSystemContent, writer)) { commitChanges(workspaceName); } updateIndexesStatus(workspaceName, IndexManager.IndexStatus.REINDEXING, IndexManager.IndexStatus.ENABLED); } } }; request.onEachPathInWorkspace(op); return null; }); } }
java
protected void reindexIfNeeded( boolean async, final boolean includeSystemContent ) { final ScanningRequest request = toBeScanned.drain(); if (!request.isEmpty()) { final RepositoryCache repoCache = runningState.repositoryCache(); scan(async, () -> { // Scan each of the workspace-path pairs ... ScanOperation op = (workspaceName, path, writer) -> { NodeCache workspaceCache = repoCache.getWorkspaceCache(workspaceName); if (workspaceCache != null) { // The workspace is still valid ... CachedNode node = workspaceCache.getNode(workspaceCache.getRootKey()); if (!path.isRoot()) { for (Segment segment : path) { ChildReference child = node.getChildReferences(workspaceCache).getChild(segment); if (child == null) { // The child no longer exists, so ignore this pair ... node = null; break; } node = workspaceCache.getNode(child); if (node == null) break; } } if (node != null) { if (logger.isDebugEnabled()) { logger.debug("Performing full reindexing for repository '{0}' and workspace '{1}'", repoCache.getName(), workspaceName); } // If we find a node to start at, then scan the content ... // in certain cases (e.g. at startup) we have to index the system content (if it applies to // any of the indexes) boolean scanSystemContent = includeSystemContent || repoCache.getSystemWorkspaceName().equals(workspaceName); updateIndexesStatus(workspaceName, IndexManager.IndexStatus.ENABLED, IndexManager.IndexStatus.REINDEXING); if (reindexContent(workspaceName, workspaceCache, node, Integer.MAX_VALUE, scanSystemContent, writer)) { commitChanges(workspaceName); } updateIndexesStatus(workspaceName, IndexManager.IndexStatus.REINDEXING, IndexManager.IndexStatus.ENABLED); } } }; request.onEachPathInWorkspace(op); return null; }); } }
[ "protected", "void", "reindexIfNeeded", "(", "boolean", "async", ",", "final", "boolean", "includeSystemContent", ")", "{", "final", "ScanningRequest", "request", "=", "toBeScanned", ".", "drain", "(", ")", ";", "if", "(", "!", "request", ".", "isEmpty", "(", ...
Reindex the repository only if there is at least one provider that required scanning and reindexing. @param async whether the reindexing should be performed asynchronously or not @param includeSystemContent whether the /jcr:system area should be indexed or not
[ "Reindex", "the", "repository", "only", "if", "there", "is", "at", "least", "one", "provider", "that", "required", "scanning", "and", "reindexing", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryQueryManager.java#L343-L390
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryQueryManager.java
RepositoryQueryManager.cleanAndReindex
protected void cleanAndReindex( boolean async ) { final IndexWriter writer = getIndexWriter(); scan(async, getIndexWriter(), new Callable<Void>() { @SuppressWarnings( "synthetic-access" ) @Override public Void call() throws Exception { writer.clearAllIndexes(); reindexContent(true, writer); return null; } }); }
java
protected void cleanAndReindex( boolean async ) { final IndexWriter writer = getIndexWriter(); scan(async, getIndexWriter(), new Callable<Void>() { @SuppressWarnings( "synthetic-access" ) @Override public Void call() throws Exception { writer.clearAllIndexes(); reindexContent(true, writer); return null; } }); }
[ "protected", "void", "cleanAndReindex", "(", "boolean", "async", ")", "{", "final", "IndexWriter", "writer", "=", "getIndexWriter", "(", ")", ";", "scan", "(", "async", ",", "getIndexWriter", "(", ")", ",", "new", "Callable", "<", "Void", ">", "(", ")", ...
Clean all indexes and reindex all content. @param async true if the reindexing should be done in the background, or false if it should be done using this thread
[ "Clean", "all", "indexes", "and", "reindex", "all", "content", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryQueryManager.java#L397-L408
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryQueryManager.java
RepositoryQueryManager.reindexContent
private void reindexContent( boolean includeSystemContent, IndexWriter indexes ) { if (indexes.canBeSkipped()) return; // The node type schemata changes every time a node type is (un)registered, so get the snapshot that we'll use throughout RepositoryCache repoCache = runningState.repositoryCache(); logger.debug(JcrI18n.reindexAll.text(runningState.name())); if (includeSystemContent) { String systemWorkspaceName = repoCache.getSystemWorkspaceName(); updateIndexesStatus(systemWorkspaceName, IndexManager.IndexStatus.ENABLED, IndexManager.IndexStatus.REINDEXING); NodeCache systemWorkspaceCache = repoCache.getWorkspaceCache(systemWorkspaceName); CachedNode rootNode = systemWorkspaceCache.getNode(repoCache.getSystemKey()); // Index the system content ... logger.debug("Starting reindex of system content in '{0}' repository.", runningState.name()); if (reindexSystemContent(rootNode, Integer.MAX_VALUE, indexes)) { commitChanges(systemWorkspaceName); } logger.debug("Completed reindex of system content in '{0}' repository.", runningState.name()); updateIndexesStatus(systemWorkspaceName, IndexManager.IndexStatus.REINDEXING, IndexManager.IndexStatus.ENABLED); } // Index the non-system workspaces ... for (String workspaceName : repoCache.getWorkspaceNames()) { // change the status of the indexes to reindexing updateIndexesStatus(workspaceName, IndexManager.IndexStatus.ENABLED, IndexManager.IndexStatus.REINDEXING); NodeCache workspaceCache = repoCache.getWorkspaceCache(workspaceName); CachedNode rootNode = workspaceCache.getNode(workspaceCache.getRootKey()); logger.debug("Starting reindex of workspace '{0}' content in '{1}' repository.", runningState.name(), workspaceName); if (reindexContent(workspaceName, workspaceCache, rootNode, Integer.MAX_VALUE, false, indexes)) { commitChanges(workspaceName); } logger.debug("Completed reindex of workspace '{0}' content in '{1}' repository.", runningState.name(), workspaceName); updateIndexesStatus(workspaceName, IndexManager.IndexStatus.REINDEXING, IndexManager.IndexStatus.ENABLED); } }
java
private void reindexContent( boolean includeSystemContent, IndexWriter indexes ) { if (indexes.canBeSkipped()) return; // The node type schemata changes every time a node type is (un)registered, so get the snapshot that we'll use throughout RepositoryCache repoCache = runningState.repositoryCache(); logger.debug(JcrI18n.reindexAll.text(runningState.name())); if (includeSystemContent) { String systemWorkspaceName = repoCache.getSystemWorkspaceName(); updateIndexesStatus(systemWorkspaceName, IndexManager.IndexStatus.ENABLED, IndexManager.IndexStatus.REINDEXING); NodeCache systemWorkspaceCache = repoCache.getWorkspaceCache(systemWorkspaceName); CachedNode rootNode = systemWorkspaceCache.getNode(repoCache.getSystemKey()); // Index the system content ... logger.debug("Starting reindex of system content in '{0}' repository.", runningState.name()); if (reindexSystemContent(rootNode, Integer.MAX_VALUE, indexes)) { commitChanges(systemWorkspaceName); } logger.debug("Completed reindex of system content in '{0}' repository.", runningState.name()); updateIndexesStatus(systemWorkspaceName, IndexManager.IndexStatus.REINDEXING, IndexManager.IndexStatus.ENABLED); } // Index the non-system workspaces ... for (String workspaceName : repoCache.getWorkspaceNames()) { // change the status of the indexes to reindexing updateIndexesStatus(workspaceName, IndexManager.IndexStatus.ENABLED, IndexManager.IndexStatus.REINDEXING); NodeCache workspaceCache = repoCache.getWorkspaceCache(workspaceName); CachedNode rootNode = workspaceCache.getNode(workspaceCache.getRootKey()); logger.debug("Starting reindex of workspace '{0}' content in '{1}' repository.", runningState.name(), workspaceName); if (reindexContent(workspaceName, workspaceCache, rootNode, Integer.MAX_VALUE, false, indexes)) { commitChanges(workspaceName); } logger.debug("Completed reindex of workspace '{0}' content in '{1}' repository.", runningState.name(), workspaceName); updateIndexesStatus(workspaceName, IndexManager.IndexStatus.REINDEXING, IndexManager.IndexStatus.ENABLED); } }
[ "private", "void", "reindexContent", "(", "boolean", "includeSystemContent", ",", "IndexWriter", "indexes", ")", "{", "if", "(", "indexes", ".", "canBeSkipped", "(", ")", ")", "return", ";", "// The node type schemata changes every time a node type is (un)registered, so get...
Crawl and index all of the repository content. @param includeSystemContent true if the system content should also be indexed @param indexes the index writer that should be use; may not be null
[ "Crawl", "and", "index", "all", "of", "the", "repository", "content", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryQueryManager.java#L449-L484
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryQueryManager.java
RepositoryQueryManager.reindexContent
public void reindexContent( JcrWorkspace workspace, Path path, int depth ) { if (getIndexWriter().canBeSkipped()) { // There's no indexes that require updating ... return; } CheckArg.isPositive(depth, "depth"); JcrSession session = workspace.getSession(); NodeCache cache = session.cache().getWorkspace(); String workspaceName = workspace.getName(); // Look for the node ... CachedNode node = cache.getNode(cache.getRootKey()); for (Segment segment : path) { // Look for the child by name ... ChildReference ref = node.getChildReferences(cache).getChild(segment); if (ref == null) return; node = cache.getNode(ref); } updateIndexesStatus(workspaceName, IndexManager.IndexStatus.ENABLED, IndexManager.IndexStatus.REINDEXING); // If the node is in the system workspace ... RepositoryCache repoCache = runningState.repositoryCache(); String systemWorkspaceName = repoCache.getSystemWorkspaceName(); String systemWorkspaceKey = repoCache.getSystemWorkspaceKey(); if (node.getKey().getWorkspaceKey().equals(systemWorkspaceKey)) { if (reindexSystemContent(node, depth, getIndexWriter())) { commitChanges(systemWorkspaceName); } } else { // It's just a regular node in the workspace ... if (reindexContent(workspaceName, cache, node, depth, path.isRoot(), getIndexWriter())) { commitChanges(workspaceName); } } updateIndexesStatus(workspaceName, IndexManager.IndexStatus.REINDEXING, IndexManager.IndexStatus.ENABLED); }
java
public void reindexContent( JcrWorkspace workspace, Path path, int depth ) { if (getIndexWriter().canBeSkipped()) { // There's no indexes that require updating ... return; } CheckArg.isPositive(depth, "depth"); JcrSession session = workspace.getSession(); NodeCache cache = session.cache().getWorkspace(); String workspaceName = workspace.getName(); // Look for the node ... CachedNode node = cache.getNode(cache.getRootKey()); for (Segment segment : path) { // Look for the child by name ... ChildReference ref = node.getChildReferences(cache).getChild(segment); if (ref == null) return; node = cache.getNode(ref); } updateIndexesStatus(workspaceName, IndexManager.IndexStatus.ENABLED, IndexManager.IndexStatus.REINDEXING); // If the node is in the system workspace ... RepositoryCache repoCache = runningState.repositoryCache(); String systemWorkspaceName = repoCache.getSystemWorkspaceName(); String systemWorkspaceKey = repoCache.getSystemWorkspaceKey(); if (node.getKey().getWorkspaceKey().equals(systemWorkspaceKey)) { if (reindexSystemContent(node, depth, getIndexWriter())) { commitChanges(systemWorkspaceName); } } else { // It's just a regular node in the workspace ... if (reindexContent(workspaceName, cache, node, depth, path.isRoot(), getIndexWriter())) { commitChanges(workspaceName); } } updateIndexesStatus(workspaceName, IndexManager.IndexStatus.REINDEXING, IndexManager.IndexStatus.ENABLED); }
[ "public", "void", "reindexContent", "(", "JcrWorkspace", "workspace", ",", "Path", "path", ",", "int", "depth", ")", "{", "if", "(", "getIndexWriter", "(", ")", ".", "canBeSkipped", "(", ")", ")", "{", "// There's no indexes that require updating ...", "return", ...
Crawl and index the content starting at the supplied path in the named workspace, to the designated depth. @param workspace the workspace @param path the path of the content to be indexed @param depth the depth of the content to be indexed @throws IllegalArgumentException if the workspace or path are null, or if the depth is less than 1
[ "Crawl", "and", "index", "the", "content", "starting", "at", "the", "supplied", "path", "in", "the", "named", "workspace", "to", "the", "designated", "depth", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryQueryManager.java#L504-L540
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryQueryManager.java
RepositoryQueryManager.reindexContentAsync
public Future<Boolean> reindexContentAsync( final JcrWorkspace workspace ) { return indexingExecutorService.submit(() -> { reindexContent(workspace); return Boolean.TRUE; }); }
java
public Future<Boolean> reindexContentAsync( final JcrWorkspace workspace ) { return indexingExecutorService.submit(() -> { reindexContent(workspace); return Boolean.TRUE; }); }
[ "public", "Future", "<", "Boolean", ">", "reindexContentAsync", "(", "final", "JcrWorkspace", "workspace", ")", "{", "return", "indexingExecutorService", ".", "submit", "(", "(", ")", "->", "{", "reindexContent", "(", "workspace", ")", ";", "return", "Boolean", ...
Asynchronously crawl and index the content in the named workspace. @param workspace the workspace @return the future for the asynchronous operation; never null @throws IllegalArgumentException if the workspace is null
[ "Asynchronously", "crawl", "and", "index", "the", "content", "in", "the", "named", "workspace", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryQueryManager.java#L750-L755
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryQueryManager.java
RepositoryQueryManager.reindexContentAsync
public Future<Boolean> reindexContentAsync( final JcrWorkspace workspace, final Path path, final int depth ) { return indexingExecutorService.submit(() -> { reindexContent(workspace, path, depth); return Boolean.TRUE; }); }
java
public Future<Boolean> reindexContentAsync( final JcrWorkspace workspace, final Path path, final int depth ) { return indexingExecutorService.submit(() -> { reindexContent(workspace, path, depth); return Boolean.TRUE; }); }
[ "public", "Future", "<", "Boolean", ">", "reindexContentAsync", "(", "final", "JcrWorkspace", "workspace", ",", "final", "Path", "path", ",", "final", "int", "depth", ")", "{", "return", "indexingExecutorService", ".", "submit", "(", "(", ")", "->", "{", "re...
Asynchronously crawl and index the content starting at the supplied path in the named workspace, to the designated depth. @param workspace the workspace @param path the path of the content to be indexed @param depth the depth of the content to be indexed @return the future for the asynchronous operation; never null @throws IllegalArgumentException if the workspace or path are null, or if the depth is less than 1
[ "Asynchronously", "crawl", "and", "index", "the", "content", "starting", "at", "the", "supplied", "path", "in", "the", "named", "workspace", "to", "the", "designated", "depth", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryQueryManager.java#L766-L773
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/SystemNamespaceRegistry.java
SystemNamespaceRegistry.register
public void register( Map<String, String> namespaceUrisByPrefix ) { if (namespaceUrisByPrefix == null || namespaceUrisByPrefix.isEmpty()) return; final Lock lock = this.namespacesLock.writeLock(); try { lock.lock(); SystemContent systemContent = systemContent(false); systemContent.registerNamespaces(namespaceUrisByPrefix); systemContent.save(); for (Map.Entry<String, String> entry : namespaceUrisByPrefix.entrySet()) { String prefix = entry.getKey().trim(); String uri = entry.getValue().trim(); if (prefix.length() == 0) continue; this.cache.register(prefix, uri); } } finally { lock.unlock(); } }
java
public void register( Map<String, String> namespaceUrisByPrefix ) { if (namespaceUrisByPrefix == null || namespaceUrisByPrefix.isEmpty()) return; final Lock lock = this.namespacesLock.writeLock(); try { lock.lock(); SystemContent systemContent = systemContent(false); systemContent.registerNamespaces(namespaceUrisByPrefix); systemContent.save(); for (Map.Entry<String, String> entry : namespaceUrisByPrefix.entrySet()) { String prefix = entry.getKey().trim(); String uri = entry.getValue().trim(); if (prefix.length() == 0) continue; this.cache.register(prefix, uri); } } finally { lock.unlock(); } }
[ "public", "void", "register", "(", "Map", "<", "String", ",", "String", ">", "namespaceUrisByPrefix", ")", "{", "if", "(", "namespaceUrisByPrefix", "==", "null", "||", "namespaceUrisByPrefix", ".", "isEmpty", "(", ")", ")", "return", ";", "final", "Lock", "l...
Register a set of namespaces. @param namespaceUrisByPrefix the map of new namespace URIs by their prefix
[ "Register", "a", "set", "of", "namespaces", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/SystemNamespaceRegistry.java#L164-L181
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/cache/ReferrerCounts.java
ReferrerCounts.create
public static ReferrerCounts create( Map<NodeKey, Integer> strongCountsByReferrerKey, Map<NodeKey, Integer> weakCountsByReferrerKey ) { if (strongCountsByReferrerKey == null) strongCountsByReferrerKey = EMPTY_COUNTS; if (weakCountsByReferrerKey == null) weakCountsByReferrerKey = EMPTY_COUNTS; if (strongCountsByReferrerKey.isEmpty() && weakCountsByReferrerKey.isEmpty()) return null; return new ReferrerCounts(strongCountsByReferrerKey, weakCountsByReferrerKey); }
java
public static ReferrerCounts create( Map<NodeKey, Integer> strongCountsByReferrerKey, Map<NodeKey, Integer> weakCountsByReferrerKey ) { if (strongCountsByReferrerKey == null) strongCountsByReferrerKey = EMPTY_COUNTS; if (weakCountsByReferrerKey == null) weakCountsByReferrerKey = EMPTY_COUNTS; if (strongCountsByReferrerKey.isEmpty() && weakCountsByReferrerKey.isEmpty()) return null; return new ReferrerCounts(strongCountsByReferrerKey, weakCountsByReferrerKey); }
[ "public", "static", "ReferrerCounts", "create", "(", "Map", "<", "NodeKey", ",", "Integer", ">", "strongCountsByReferrerKey", ",", "Map", "<", "NodeKey", ",", "Integer", ">", "weakCountsByReferrerKey", ")", "{", "if", "(", "strongCountsByReferrerKey", "==", "null"...
Create a new instance of the snapshot. @param strongCountsByReferrerKey the map of weak reference counts keyed by referrer's node keys; may be null or empty @param weakCountsByReferrerKey the map of weak reference counts keyed by referrer's node keys; may be null or empty @return the counts snapshot; null if there are no referrers
[ "Create", "a", "new", "instance", "of", "the", "snapshot", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/cache/ReferrerCounts.java#L42-L48
train
ModeShape/modeshape
sequencers/modeshape-sequencer-xsd/src/main/java/org/modeshape/sequencer/xsd/XsdReader.java
XsdReader.process
protected void process( XSDSchema schema, String encoding, long contentSize, Node rootNode ) throws Exception { assert schema != null; logger.debug("Target namespace: '{0}'", schema.getTargetNamespace()); rootNode.setProperty(SrampLexicon.CONTENT_TYPE, MimeTypeConstants.APPLICATION_XML); if (encoding != null) { rootNode.setProperty(SrampLexicon.CONTENT_ENCODING, encoding); } rootNode.setProperty(SrampLexicon.CONTENT_SIZE, contentSize); // Parse the annotations first to aggregate them all into a single 'sramp:description' property ... @SuppressWarnings( "unchecked" ) List<XSDAnnotation> annotations = schema.getAnnotations(); processAnnotations(annotations, rootNode); processNonSchemaAttributes(schema, rootNode, Collections.<String>emptySet()); // Parse the objects ... for (EObject obj : schema.eContents()) { if (obj instanceof XSDSimpleTypeDefinition) { processSimpleTypeDefinition((XSDSimpleTypeDefinition)obj, rootNode); } else if (obj instanceof XSDComplexTypeDefinition) { processComplexTypeDefinition((XSDComplexTypeDefinition)obj, rootNode); } else if (obj instanceof XSDElementDeclaration) { processElementDeclaration((XSDElementDeclaration)obj, rootNode); } else if (obj instanceof XSDAttributeDeclaration) { processAttributeDeclaration((XSDAttributeDeclaration)obj, rootNode, false); } else if (obj instanceof XSDImport) { processImport((XSDImport)obj, rootNode); } else if (obj instanceof XSDInclude) { processInclude((XSDInclude)obj, rootNode); } else if (obj instanceof XSDRedefine) { processRedefine((XSDRedefine)obj, rootNode); } else if (obj instanceof XSDAttributeGroupDefinition) { processAttributeGroupDefinition((XSDAttributeGroupDefinition)obj, rootNode); } else if (obj instanceof XSDAnnotation) { // already processed above ... } } // Resolve any outstanding, unresolved references ... resolveReferences(); }
java
protected void process( XSDSchema schema, String encoding, long contentSize, Node rootNode ) throws Exception { assert schema != null; logger.debug("Target namespace: '{0}'", schema.getTargetNamespace()); rootNode.setProperty(SrampLexicon.CONTENT_TYPE, MimeTypeConstants.APPLICATION_XML); if (encoding != null) { rootNode.setProperty(SrampLexicon.CONTENT_ENCODING, encoding); } rootNode.setProperty(SrampLexicon.CONTENT_SIZE, contentSize); // Parse the annotations first to aggregate them all into a single 'sramp:description' property ... @SuppressWarnings( "unchecked" ) List<XSDAnnotation> annotations = schema.getAnnotations(); processAnnotations(annotations, rootNode); processNonSchemaAttributes(schema, rootNode, Collections.<String>emptySet()); // Parse the objects ... for (EObject obj : schema.eContents()) { if (obj instanceof XSDSimpleTypeDefinition) { processSimpleTypeDefinition((XSDSimpleTypeDefinition)obj, rootNode); } else if (obj instanceof XSDComplexTypeDefinition) { processComplexTypeDefinition((XSDComplexTypeDefinition)obj, rootNode); } else if (obj instanceof XSDElementDeclaration) { processElementDeclaration((XSDElementDeclaration)obj, rootNode); } else if (obj instanceof XSDAttributeDeclaration) { processAttributeDeclaration((XSDAttributeDeclaration)obj, rootNode, false); } else if (obj instanceof XSDImport) { processImport((XSDImport)obj, rootNode); } else if (obj instanceof XSDInclude) { processInclude((XSDInclude)obj, rootNode); } else if (obj instanceof XSDRedefine) { processRedefine((XSDRedefine)obj, rootNode); } else if (obj instanceof XSDAttributeGroupDefinition) { processAttributeGroupDefinition((XSDAttributeGroupDefinition)obj, rootNode); } else if (obj instanceof XSDAnnotation) { // already processed above ... } } // Resolve any outstanding, unresolved references ... resolveReferences(); }
[ "protected", "void", "process", "(", "XSDSchema", "schema", ",", "String", "encoding", ",", "long", "contentSize", ",", "Node", "rootNode", ")", "throws", "Exception", "{", "assert", "schema", "!=", "null", ";", "logger", ".", "debug", "(", "\"Target namespace...
Read an XSDSchema instance and create the node hierarchy under the given root node. @param schema the schema object; may not be null @param encoding the encoding for the XSD; may be null if the encoding is not specified @param contentSize the size of the XML Schema Document content; may not be negative @param rootNode the root node that will be populated with the XML Schema Document information @throws Exception if there is a probelm reading the XSD content
[ "Read", "an", "XSDSchema", "instance", "and", "create", "the", "node", "hierarchy", "under", "the", "given", "root", "node", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-xsd/src/main/java/org/modeshape/sequencer/xsd/XsdReader.java#L180-L224
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/Connectors.java
Connectors.externalNodeRemoved
public void externalNodeRemoved( String externalNodeKey ) { if (this.snapshot.get().containsProjectionForExternalNode(externalNodeKey)) { // the external node was the root of a projection, so we need to remove that projection synchronized (this) { Snapshot current = this.snapshot.get(); Snapshot updated = current.withoutProjection(externalNodeKey); if (current != updated) { this.snapshot.compareAndSet(current, updated); } } } }
java
public void externalNodeRemoved( String externalNodeKey ) { if (this.snapshot.get().containsProjectionForExternalNode(externalNodeKey)) { // the external node was the root of a projection, so we need to remove that projection synchronized (this) { Snapshot current = this.snapshot.get(); Snapshot updated = current.withoutProjection(externalNodeKey); if (current != updated) { this.snapshot.compareAndSet(current, updated); } } } }
[ "public", "void", "externalNodeRemoved", "(", "String", "externalNodeKey", ")", "{", "if", "(", "this", ".", "snapshot", ".", "get", "(", ")", ".", "containsProjectionForExternalNode", "(", "externalNodeKey", ")", ")", "{", "// the external node was the root of a proj...
Signals that an external node with the given key has been removed. @param externalNodeKey a {@code non-null} String
[ "Signals", "that", "an", "external", "node", "with", "the", "given", "key", "has", "been", "removed", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/Connectors.java#L395-L406
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/Connectors.java
Connectors.internalNodeRemoved
public void internalNodeRemoved( String internalNodeKey ) { if (this.snapshot.get().containsProjectionForInternalNode(internalNodeKey)) { // identify all the projections which from this internal (aka. federated node) and remove them synchronized (this) { Snapshot current = this.snapshot.get(); Snapshot updated = current; for (Projection projection : current.getProjections()) { if (internalNodeKey.equalsIgnoreCase(projection.getProjectedNodeKey())) { String externalNodeKey = projection.getExternalNodeKey(); removeStoredProjection(externalNodeKey); updated = updated.withoutProjection(externalNodeKey); } } if (current != updated) { this.snapshot.compareAndSet(current, updated); } } } }
java
public void internalNodeRemoved( String internalNodeKey ) { if (this.snapshot.get().containsProjectionForInternalNode(internalNodeKey)) { // identify all the projections which from this internal (aka. federated node) and remove them synchronized (this) { Snapshot current = this.snapshot.get(); Snapshot updated = current; for (Projection projection : current.getProjections()) { if (internalNodeKey.equalsIgnoreCase(projection.getProjectedNodeKey())) { String externalNodeKey = projection.getExternalNodeKey(); removeStoredProjection(externalNodeKey); updated = updated.withoutProjection(externalNodeKey); } } if (current != updated) { this.snapshot.compareAndSet(current, updated); } } } }
[ "public", "void", "internalNodeRemoved", "(", "String", "internalNodeKey", ")", "{", "if", "(", "this", ".", "snapshot", ".", "get", "(", ")", ".", "containsProjectionForInternalNode", "(", "internalNodeKey", ")", ")", "{", "// identify all the projections which from ...
Signals that an internal node with the given key has been removed. @param internalNodeKey a {@code non-null} String
[ "Signals", "that", "an", "internal", "node", "with", "the", "given", "key", "has", "been", "removed", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/Connectors.java#L413-L431
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/Connectors.java
Connectors.getConnectorForSourceName
public Connector getConnectorForSourceName( String sourceName ) { assert sourceName != null; return this.snapshot.get().getConnectorWithSourceKey(NodeKey.keyForSourceName(sourceName)); }
java
public Connector getConnectorForSourceName( String sourceName ) { assert sourceName != null; return this.snapshot.get().getConnectorWithSourceKey(NodeKey.keyForSourceName(sourceName)); }
[ "public", "Connector", "getConnectorForSourceName", "(", "String", "sourceName", ")", "{", "assert", "sourceName", "!=", "null", ";", "return", "this", ".", "snapshot", ".", "get", "(", ")", ".", "getConnectorWithSourceKey", "(", "NodeKey", ".", "keyForSourceName"...
Returns a connector which was registered for the given source name. @param sourceName a {@code non-null} String; the name of a source @return either a {@link Connector} instance or {@code null}
[ "Returns", "a", "connector", "which", "was", "registered", "for", "the", "given", "source", "name", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/Connectors.java#L613-L616
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/Connectors.java
Connectors.getDocumentTranslator
public DocumentTranslator getDocumentTranslator() { if (translator == null) { // We don't want the connectors to use a translator that converts large strings to binary values that are // managed within ModeShape's binary store. Instead, all of the connector-created string property values // should be kept as strings ... translator = repository.repositoryCache().getDocumentTranslator().withLargeStringSize(Long.MAX_VALUE); } return translator; }
java
public DocumentTranslator getDocumentTranslator() { if (translator == null) { // We don't want the connectors to use a translator that converts large strings to binary values that are // managed within ModeShape's binary store. Instead, all of the connector-created string property values // should be kept as strings ... translator = repository.repositoryCache().getDocumentTranslator().withLargeStringSize(Long.MAX_VALUE); } return translator; }
[ "public", "DocumentTranslator", "getDocumentTranslator", "(", ")", "{", "if", "(", "translator", "==", "null", ")", "{", "// We don't want the connectors to use a translator that converts large strings to binary values that are", "// managed within ModeShape's binary store. Instead, all ...
Returns the repository's document translator. @return a {@link DocumentTranslator} instance.
[ "Returns", "the", "repository", "s", "document", "translator", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/Connectors.java#L632-L640
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryStatistics.java
RepositoryStatistics.start
void start( ScheduledExecutorService service ) { if (rollupFuture.get() != null) { // already started ... return; } // Pre-populate the metrics (overwriting any existing history object) ... durations.put(DurationMetric.QUERY_EXECUTION_TIME, new DurationHistory(TimeUnit.MILLISECONDS, MAXIMUM_LONG_RUNNING_QUERY_COUNT)); durations.put(DurationMetric.SEQUENCER_EXECUTION_TIME, new DurationHistory(TimeUnit.MILLISECONDS, MAXIMUM_LONG_RUNNING_SEQUENCING_COUNT)); durations.put(DurationMetric.SESSION_LIFETIME, new DurationHistory(TimeUnit.MILLISECONDS, MAXIMUM_LONG_RUNNING_SESSION_COUNT)); for (ValueMetric metric : EnumSet.allOf(ValueMetric.class)) { boolean resetUponRollup = !metric.isContinuous(); values.put(metric, new ValueHistory(resetUponRollup)); } // Initialize the start times in a threadsafe manner ... DateTime now = timeFactory.create(); this.weeksStartTime.compareAndSet(null, now); this.daysStartTime.compareAndSet(null, now); this.hoursStartTime.compareAndSet(null, now); this.minutesStartTime.compareAndSet(null, now); this.secondsStartTime.compareAndSet(null, now); rollup(); // Then schedule the rollup to be done at a fixed rate ... this.rollupFuture.set(service.scheduleAtFixedRate(new Runnable() { @SuppressWarnings( "synthetic-access" ) @Override public void run() { rollup(); } }, CAPTURE_DELAY_IN_SECONDS, CAPTURE_INTERVAL_IN_SECONDS, TimeUnit.SECONDS)); }
java
void start( ScheduledExecutorService service ) { if (rollupFuture.get() != null) { // already started ... return; } // Pre-populate the metrics (overwriting any existing history object) ... durations.put(DurationMetric.QUERY_EXECUTION_TIME, new DurationHistory(TimeUnit.MILLISECONDS, MAXIMUM_LONG_RUNNING_QUERY_COUNT)); durations.put(DurationMetric.SEQUENCER_EXECUTION_TIME, new DurationHistory(TimeUnit.MILLISECONDS, MAXIMUM_LONG_RUNNING_SEQUENCING_COUNT)); durations.put(DurationMetric.SESSION_LIFETIME, new DurationHistory(TimeUnit.MILLISECONDS, MAXIMUM_LONG_RUNNING_SESSION_COUNT)); for (ValueMetric metric : EnumSet.allOf(ValueMetric.class)) { boolean resetUponRollup = !metric.isContinuous(); values.put(metric, new ValueHistory(resetUponRollup)); } // Initialize the start times in a threadsafe manner ... DateTime now = timeFactory.create(); this.weeksStartTime.compareAndSet(null, now); this.daysStartTime.compareAndSet(null, now); this.hoursStartTime.compareAndSet(null, now); this.minutesStartTime.compareAndSet(null, now); this.secondsStartTime.compareAndSet(null, now); rollup(); // Then schedule the rollup to be done at a fixed rate ... this.rollupFuture.set(service.scheduleAtFixedRate(new Runnable() { @SuppressWarnings( "synthetic-access" ) @Override public void run() { rollup(); } }, CAPTURE_DELAY_IN_SECONDS, CAPTURE_INTERVAL_IN_SECONDS, TimeUnit.SECONDS)); }
[ "void", "start", "(", "ScheduledExecutorService", "service", ")", "{", "if", "(", "rollupFuture", ".", "get", "(", ")", "!=", "null", ")", "{", "// already started ...", "return", ";", "}", "// Pre-populate the metrics (overwriting any existing history object) ...", "du...
Start recording statistics. @param service the executor service that should be used to capture the statistics; may not be null
[ "Start", "recording", "statistics", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryStatistics.java#L155-L191
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryStatistics.java
RepositoryStatistics.stop
void stop() { ScheduledFuture<?> future = this.rollupFuture.getAndSet(null); if (future != null && !future.isDone() && !future.isCancelled()) { // Stop running the scheduled job, letting any currently running rollup finish ... future.cancel(false); } }
java
void stop() { ScheduledFuture<?> future = this.rollupFuture.getAndSet(null); if (future != null && !future.isDone() && !future.isCancelled()) { // Stop running the scheduled job, letting any currently running rollup finish ... future.cancel(false); } }
[ "void", "stop", "(", ")", "{", "ScheduledFuture", "<", "?", ">", "future", "=", "this", ".", "rollupFuture", ".", "getAndSet", "(", "null", ")", ";", "if", "(", "future", "!=", "null", "&&", "!", "future", ".", "isDone", "(", ")", "&&", "!", "futur...
Stop recording statistics.
[ "Stop", "recording", "statistics", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryStatistics.java#L196-L202
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryStatistics.java
RepositoryStatistics.rollup
@SuppressWarnings( "fallthrough" ) private void rollup() { DateTime now = timeFactory.create(); Window largest = null; for (DurationHistory history : durations.values()) { largest = history.rollup(); } for (ValueHistory history : values.values()) { largest = history.rollup(); } if ( largest == null ) return; // Note that we do expect to fall through, as the 'largest' represents the largest window that was changed, // while all smaller windows were also changed ... switch (largest) { case PREVIOUS_52_WEEKS: this.weeksStartTime.set(now); // fall through!! case PREVIOUS_7_DAYS: this.daysStartTime.set(now); // fall through!! case PREVIOUS_24_HOURS: this.hoursStartTime.set(now); // fall through!! case PREVIOUS_60_MINUTES: this.minutesStartTime.set(now); // fall through!! case PREVIOUS_60_SECONDS: this.secondsStartTime.set(now); } }
java
@SuppressWarnings( "fallthrough" ) private void rollup() { DateTime now = timeFactory.create(); Window largest = null; for (DurationHistory history : durations.values()) { largest = history.rollup(); } for (ValueHistory history : values.values()) { largest = history.rollup(); } if ( largest == null ) return; // Note that we do expect to fall through, as the 'largest' represents the largest window that was changed, // while all smaller windows were also changed ... switch (largest) { case PREVIOUS_52_WEEKS: this.weeksStartTime.set(now); // fall through!! case PREVIOUS_7_DAYS: this.daysStartTime.set(now); // fall through!! case PREVIOUS_24_HOURS: this.hoursStartTime.set(now); // fall through!! case PREVIOUS_60_MINUTES: this.minutesStartTime.set(now); // fall through!! case PREVIOUS_60_SECONDS: this.secondsStartTime.set(now); } }
[ "@", "SuppressWarnings", "(", "\"fallthrough\"", ")", "private", "void", "rollup", "(", ")", "{", "DateTime", "now", "=", "timeFactory", ".", "create", "(", ")", ";", "Window", "largest", "=", "null", ";", "for", "(", "DurationHistory", "history", ":", "du...
Method called once every second by the scheduled job. @see #start(ScheduledExecutorService)
[ "Method", "called", "once", "every", "second", "by", "the", "scheduled", "job", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryStatistics.java#L209-L238
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryStatistics.java
RepositoryStatistics.increment
public void increment( ValueMetric metric, long incrementalValue ) { assert metric != null; ValueHistory history = values.get(metric); if (history != null) history.recordIncrement(incrementalValue); }
java
public void increment( ValueMetric metric, long incrementalValue ) { assert metric != null; ValueHistory history = values.get(metric); if (history != null) history.recordIncrement(incrementalValue); }
[ "public", "void", "increment", "(", "ValueMetric", "metric", ",", "long", "incrementalValue", ")", "{", "assert", "metric", "!=", "null", ";", "ValueHistory", "history", "=", "values", ".", "get", "(", "metric", ")", ";", "if", "(", "history", "!=", "null"...
Record an incremental change to a value, called by the code that knows when and how the metric changes. @param metric the metric; may not be null @param incrementalValue the positive or negative increment @see #increment(ValueMetric) @see #decrement(ValueMetric) @see #recordDuration(DurationMetric, long, TimeUnit, Map)
[ "Record", "an", "incremental", "change", "to", "a", "value", "called", "by", "the", "code", "that", "knows", "when", "and", "how", "the", "metric", "changes", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryStatistics.java#L307-L312
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryStatistics.java
RepositoryStatistics.set
public void set( ValueMetric metric, long value ) { assert metric != null; ValueHistory history = values.get(metric); if (history != null) history.recordNewValue(value); }
java
public void set( ValueMetric metric, long value ) { assert metric != null; ValueHistory history = values.get(metric); if (history != null) history.recordNewValue(value); }
[ "public", "void", "set", "(", "ValueMetric", "metric", ",", "long", "value", ")", "{", "assert", "metric", "!=", "null", ";", "ValueHistory", "history", "=", "values", ".", "get", "(", "metric", ")", ";", "if", "(", "history", "!=", "null", ")", "histo...
Record a specific value for a metric, called by the code that knows when and how the metric changes. @param metric the metric; may not be null @param value the value for the metric @see #increment(ValueMetric, long) @see #decrement(ValueMetric) @see #recordDuration(DurationMetric, long, TimeUnit, Map)
[ "Record", "a", "specific", "value", "for", "a", "metric", "called", "by", "the", "code", "that", "knows", "when", "and", "how", "the", "metric", "changes", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryStatistics.java#L337-L342
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryStatistics.java
RepositoryStatistics.recordDuration
void recordDuration( DurationMetric metric, long duration, TimeUnit timeUnit, Map<String, String> payload ) { assert metric != null; DurationHistory history = durations.get(metric); if (history != null) history.recordDuration(duration, timeUnit, payload); }
java
void recordDuration( DurationMetric metric, long duration, TimeUnit timeUnit, Map<String, String> payload ) { assert metric != null; DurationHistory history = durations.get(metric); if (history != null) history.recordDuration(duration, timeUnit, payload); }
[ "void", "recordDuration", "(", "DurationMetric", "metric", ",", "long", "duration", ",", "TimeUnit", "timeUnit", ",", "Map", "<", "String", ",", "String", ">", "payload", ")", "{", "assert", "metric", "!=", "null", ";", "DurationHistory", "history", "=", "du...
Record a new duration for the given metric, called by the code that knows about the duration. @param metric the metric; may not be null @param duration the duration @param timeUnit the time unit of the duration @param payload the payload; may be null or a lightweight representation of the activity described by the duration @see #increment(ValueMetric) @see #increment(ValueMetric, long) @see #decrement(ValueMetric)
[ "Record", "a", "new", "duration", "for", "the", "given", "metric", "called", "by", "the", "code", "that", "knows", "about", "the", "duration", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryStatistics.java#L369-L376
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryStatistics.java
RepositoryStatistics.statisticsFor
public static Statistics statisticsFor( long[] values ) { int length = values.length; if (length == 0) return EMPTY_STATISTICS; if (length == 1) return statisticsFor(values[0]); long total = 0L; long max = Long.MIN_VALUE; long min = Long.MAX_VALUE; for (long value : values) { total += value; max = Math.max(max, value); min = Math.min(min, value); } double mean = ((double)total) / length; double varianceSquared = 0.0d; double distance = 0.0d; for (long value : values) { distance = mean - value; varianceSquared = varianceSquared + (distance * distance); } return new StatisticsImpl(length, min, max, mean, Math.sqrt(varianceSquared)); }
java
public static Statistics statisticsFor( long[] values ) { int length = values.length; if (length == 0) return EMPTY_STATISTICS; if (length == 1) return statisticsFor(values[0]); long total = 0L; long max = Long.MIN_VALUE; long min = Long.MAX_VALUE; for (long value : values) { total += value; max = Math.max(max, value); min = Math.min(min, value); } double mean = ((double)total) / length; double varianceSquared = 0.0d; double distance = 0.0d; for (long value : values) { distance = mean - value; varianceSquared = varianceSquared + (distance * distance); } return new StatisticsImpl(length, min, max, mean, Math.sqrt(varianceSquared)); }
[ "public", "static", "Statistics", "statisticsFor", "(", "long", "[", "]", "values", ")", "{", "int", "length", "=", "values", ".", "length", ";", "if", "(", "length", "==", "0", ")", "return", "EMPTY_STATISTICS", ";", "if", "(", "length", "==", "1", ")...
Utility method to construct the statistics for a series of values. @param values the values; the array reference may not be null but the array may be empty @return the core statistics; never null
[ "Utility", "method", "to", "construct", "the", "statistics", "for", "a", "series", "of", "values", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryStatistics.java#L693-L713
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryStatistics.java
RepositoryStatistics.statisticsFor
public static Statistics statisticsFor( Statistics[] statistics ) { int length = statistics.length; if (length == 0) return EMPTY_STATISTICS; if (length == 1) return statistics[0] != null ? statistics[0] : EMPTY_STATISTICS; int count = 0; long max = Long.MIN_VALUE; long min = Long.MAX_VALUE; double mean = 0.0d; double variance = 0.0d; // Compute the min, max, and mean ... for (Statistics stat : statistics) { if (stat == null) continue; count += stat.getCount(); max = Math.max(max, stat.getMaximum()); min = Math.min(min, stat.getMinimum()); mean = mean + (stat.getMean() * stat.getCount()); } mean = mean / count; // Compute the new variance using the new mean ... double meanDelta = 0.0d; for (Statistics stat : statistics) { if (stat == null) continue; meanDelta = stat.getMean() - mean; variance = variance + (stat.getCount() * (stat.getVariance() + (meanDelta * meanDelta))); } return new StatisticsImpl(count, min, max, mean, variance); }
java
public static Statistics statisticsFor( Statistics[] statistics ) { int length = statistics.length; if (length == 0) return EMPTY_STATISTICS; if (length == 1) return statistics[0] != null ? statistics[0] : EMPTY_STATISTICS; int count = 0; long max = Long.MIN_VALUE; long min = Long.MAX_VALUE; double mean = 0.0d; double variance = 0.0d; // Compute the min, max, and mean ... for (Statistics stat : statistics) { if (stat == null) continue; count += stat.getCount(); max = Math.max(max, stat.getMaximum()); min = Math.min(min, stat.getMinimum()); mean = mean + (stat.getMean() * stat.getCount()); } mean = mean / count; // Compute the new variance using the new mean ... double meanDelta = 0.0d; for (Statistics stat : statistics) { if (stat == null) continue; meanDelta = stat.getMean() - mean; variance = variance + (stat.getCount() * (stat.getVariance() + (meanDelta * meanDelta))); } return new StatisticsImpl(count, min, max, mean, variance); }
[ "public", "static", "Statistics", "statisticsFor", "(", "Statistics", "[", "]", "statistics", ")", "{", "int", "length", "=", "statistics", ".", "length", ";", "if", "(", "length", "==", "0", ")", "return", "EMPTY_STATISTICS", ";", "if", "(", "length", "==...
Utility method to construct the composite statistics for a series of sampled statistics. @param statistics the sample statistics that are to be combined; the array reference may not be null but the array may be empty @return the composite statistics; never null
[ "Utility", "method", "to", "construct", "the", "composite", "statistics", "for", "a", "series", "of", "sampled", "statistics", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryStatistics.java#L722-L749
train
ModeShape/modeshape
web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/grid/Pager.java
Pager.setRecordsAmount
public void setRecordsAmount(int amount) { int ipp = Integer.parseInt(itemsPerPageEditor.getValueAsString()); pageTotal = amount % ipp == 0? amount / ipp : amount / ipp + 1; draw(0); }
java
public void setRecordsAmount(int amount) { int ipp = Integer.parseInt(itemsPerPageEditor.getValueAsString()); pageTotal = amount % ipp == 0? amount / ipp : amount / ipp + 1; draw(0); }
[ "public", "void", "setRecordsAmount", "(", "int", "amount", ")", "{", "int", "ipp", "=", "Integer", ".", "parseInt", "(", "itemsPerPageEditor", ".", "getValueAsString", "(", ")", ")", ";", "pageTotal", "=", "amount", "%", "ipp", "==", "0", "?", "amount", ...
Assigns total number of records. @param amount
[ "Assigns", "total", "number", "of", "records", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/grid/Pager.java#L90-L94
train
ModeShape/modeshape
sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/DdlParsers.java
DdlParsers.parseUsing
public List<ParsingResult> parseUsing( final String ddl, final String firstParserId, final String secondParserId, final String... additionalParserIds ) throws ParsingException { CheckArg.isNotEmpty(firstParserId, "firstParserId"); CheckArg.isNotEmpty(secondParserId, "secondParserId"); if (additionalParserIds != null) { CheckArg.containsNoNulls(additionalParserIds, "additionalParserIds"); } final int numParsers = ((additionalParserIds == null) ? 2 : (additionalParserIds.length + 2)); final List<DdlParser> selectedParsers = new ArrayList<DdlParser>(numParsers); { // add first parser final DdlParser parser = getParser(firstParserId); if (parser == null) { throw new ParsingException(Position.EMPTY_CONTENT_POSITION, DdlSequencerI18n.unknownParser.text(firstParserId)); } selectedParsers.add(parser); } { // add second parser final DdlParser parser = getParser(secondParserId); if (parser == null) { throw new ParsingException(Position.EMPTY_CONTENT_POSITION, DdlSequencerI18n.unknownParser.text(secondParserId)); } selectedParsers.add(parser); } // add remaining parsers if ((additionalParserIds != null) && (additionalParserIds.length != 0)) { for (final String id : additionalParserIds) { final DdlParser parser = getParser(id); if (parser == null) { throw new ParsingException(Position.EMPTY_CONTENT_POSITION, DdlSequencerI18n.unknownParser.text(id)); } selectedParsers.add(parser); } } return parseUsing(ddl, selectedParsers); }
java
public List<ParsingResult> parseUsing( final String ddl, final String firstParserId, final String secondParserId, final String... additionalParserIds ) throws ParsingException { CheckArg.isNotEmpty(firstParserId, "firstParserId"); CheckArg.isNotEmpty(secondParserId, "secondParserId"); if (additionalParserIds != null) { CheckArg.containsNoNulls(additionalParserIds, "additionalParserIds"); } final int numParsers = ((additionalParserIds == null) ? 2 : (additionalParserIds.length + 2)); final List<DdlParser> selectedParsers = new ArrayList<DdlParser>(numParsers); { // add first parser final DdlParser parser = getParser(firstParserId); if (parser == null) { throw new ParsingException(Position.EMPTY_CONTENT_POSITION, DdlSequencerI18n.unknownParser.text(firstParserId)); } selectedParsers.add(parser); } { // add second parser final DdlParser parser = getParser(secondParserId); if (parser == null) { throw new ParsingException(Position.EMPTY_CONTENT_POSITION, DdlSequencerI18n.unknownParser.text(secondParserId)); } selectedParsers.add(parser); } // add remaining parsers if ((additionalParserIds != null) && (additionalParserIds.length != 0)) { for (final String id : additionalParserIds) { final DdlParser parser = getParser(id); if (parser == null) { throw new ParsingException(Position.EMPTY_CONTENT_POSITION, DdlSequencerI18n.unknownParser.text(id)); } selectedParsers.add(parser); } } return parseUsing(ddl, selectedParsers); }
[ "public", "List", "<", "ParsingResult", ">", "parseUsing", "(", "final", "String", "ddl", ",", "final", "String", "firstParserId", ",", "final", "String", "secondParserId", ",", "final", "String", "...", "additionalParserIds", ")", "throws", "ParsingException", "{...
Parse the supplied DDL using multiple parsers, returning the result of each parser with its score in the order of highest scoring to lowest scoring. @param ddl the DDL being parsed (cannot be <code>null</code> or empty) @param firstParserId the identifier of the first parser to use (cannot be <code>null</code> or empty) @param secondParserId the identifier of the second parser to use (cannot be <code>null</code> or empty) @param additionalParserIds the identifiers of additional parsers that should be used; may be empty but not contain a null identifier value @return the list of {@link ParsingResult} instances, one for each parser, ordered from highest score to lowest score (never <code>null</code> or empty) @throws ParsingException if there is an error parsing the supplied DDL content @throws IllegalArgumentException if a parser with the specified identifier cannot be found
[ "Parse", "the", "supplied", "DDL", "using", "multiple", "parsers", "returning", "the", "result", "of", "each", "parser", "with", "its", "score", "in", "the", "order", "of", "highest", "scoring", "to", "lowest", "scoring", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/DdlParsers.java#L183-L231
train
ModeShape/modeshape
web/modeshape-web-jcr-webdav/src/main/java/org/modeshape/web/jcr/webdav/ResolvedRequest.java
ResolvedRequest.withPath
public ResolvedRequest withPath( String path ) { assert repositoryName != null; assert workspaceName != null; return new ResolvedRequest(request, repositoryName, workspaceName, path); }
java
public ResolvedRequest withPath( String path ) { assert repositoryName != null; assert workspaceName != null; return new ResolvedRequest(request, repositoryName, workspaceName, path); }
[ "public", "ResolvedRequest", "withPath", "(", "String", "path", ")", "{", "assert", "repositoryName", "!=", "null", ";", "assert", "workspaceName", "!=", "null", ";", "return", "new", "ResolvedRequest", "(", "request", ",", "repositoryName", ",", "workspaceName", ...
Create a new request that is similar to this request except with the supplied path. This can only be done if the repository name and workspace name are non-null @param path the new path @return the new request; never null
[ "Create", "a", "new", "request", "that", "is", "similar", "to", "this", "request", "except", "with", "the", "supplied", "path", ".", "This", "can", "only", "be", "done", "if", "the", "repository", "name", "and", "workspace", "name", "are", "non", "-", "n...
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-jcr-webdav/src/main/java/org/modeshape/web/jcr/webdav/ResolvedRequest.java#L84-L88
train
ModeShape/modeshape
connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/Properties.java
Properties.findJcrName
public String findJcrName( String cmisName ) { for (int i = 0; i < list.size(); i++) { if (list.get(i).cmisName != null && list.get(i).cmisName.equals(cmisName)) { return list.get(i).jcrName; } } return cmisName; }
java
public String findJcrName( String cmisName ) { for (int i = 0; i < list.size(); i++) { if (list.get(i).cmisName != null && list.get(i).cmisName.equals(cmisName)) { return list.get(i).jcrName; } } return cmisName; }
[ "public", "String", "findJcrName", "(", "String", "cmisName", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "list", ".", "size", "(", ")", ";", "i", "++", ")", "{", "if", "(", "list", ".", "get", "(", "i", ")", ".", "cmisName", "...
Determines the name of the given property from cmis domain in jcr domain. @param cmisName the name of property in cmis domain. @return the name of the same property in jcr domain.
[ "Determines", "the", "name", "of", "the", "given", "property", "from", "cmis", "domain", "in", "jcr", "domain", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/Properties.java#L82-L89
train
ModeShape/modeshape
connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/Properties.java
Properties.findCmisName
public String findCmisName( String jcrName ) { for (int i = 0; i < list.size(); i++) { if (list.get(i).jcrName != null && list.get(i).jcrName.equals(jcrName)) { return list.get(i).cmisName; } } return jcrName; }
java
public String findCmisName( String jcrName ) { for (int i = 0; i < list.size(); i++) { if (list.get(i).jcrName != null && list.get(i).jcrName.equals(jcrName)) { return list.get(i).cmisName; } } return jcrName; }
[ "public", "String", "findCmisName", "(", "String", "jcrName", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "list", ".", "size", "(", ")", ";", "i", "++", ")", "{", "if", "(", "list", ".", "get", "(", "i", ")", ".", "jcrName", "!...
Determines the name of the given property from jcr domain in cmis domain. @param jcrName the name of property in jcr domain. @return the name of the same property in cmis domain.
[ "Determines", "the", "name", "of", "the", "given", "property", "from", "jcr", "domain", "in", "cmis", "domain", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/Properties.java#L97-L104
train
ModeShape/modeshape
connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/Properties.java
Properties.getJcrType
public int getJcrType( PropertyType propertyType ) { switch (propertyType) { case BOOLEAN: return javax.jcr.PropertyType.BOOLEAN; case DATETIME: return javax.jcr.PropertyType.DATE; case DECIMAL: return javax.jcr.PropertyType.DECIMAL; case HTML: return javax.jcr.PropertyType.STRING; case INTEGER: return javax.jcr.PropertyType.LONG; case URI: return javax.jcr.PropertyType.URI; case ID: return javax.jcr.PropertyType.STRING; default: return javax.jcr.PropertyType.UNDEFINED; } }
java
public int getJcrType( PropertyType propertyType ) { switch (propertyType) { case BOOLEAN: return javax.jcr.PropertyType.BOOLEAN; case DATETIME: return javax.jcr.PropertyType.DATE; case DECIMAL: return javax.jcr.PropertyType.DECIMAL; case HTML: return javax.jcr.PropertyType.STRING; case INTEGER: return javax.jcr.PropertyType.LONG; case URI: return javax.jcr.PropertyType.URI; case ID: return javax.jcr.PropertyType.STRING; default: return javax.jcr.PropertyType.UNDEFINED; } }
[ "public", "int", "getJcrType", "(", "PropertyType", "propertyType", ")", "{", "switch", "(", "propertyType", ")", "{", "case", "BOOLEAN", ":", "return", "javax", ".", "jcr", ".", "PropertyType", ".", "BOOLEAN", ";", "case", "DATETIME", ":", "return", "javax"...
Converts type of property. @param propertyType the type of the property in cmis domain. @return the type of the property in jcr domain.
[ "Converts", "type", "of", "property", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/Properties.java#L112-L131
train
ModeShape/modeshape
connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/Properties.java
Properties.jcrValues
public Object[] jcrValues( Property<?> property ) { @SuppressWarnings( "unchecked" ) List<Object> values = (List<Object>)property.getValues(); // convert CMIS values to JCR values switch (property.getType()) { case STRING: return asStrings(values); case BOOLEAN: return asBooleans(values); case DECIMAL: return asDecimals(values); case INTEGER: return asIntegers(values); case DATETIME: return asDateTime(values); case URI: return asURI(values); case ID: return asIDs(values); case HTML: return asHTMLs(values); default: return null; } }
java
public Object[] jcrValues( Property<?> property ) { @SuppressWarnings( "unchecked" ) List<Object> values = (List<Object>)property.getValues(); // convert CMIS values to JCR values switch (property.getType()) { case STRING: return asStrings(values); case BOOLEAN: return asBooleans(values); case DECIMAL: return asDecimals(values); case INTEGER: return asIntegers(values); case DATETIME: return asDateTime(values); case URI: return asURI(values); case ID: return asIDs(values); case HTML: return asHTMLs(values); default: return null; } }
[ "public", "Object", "[", "]", "jcrValues", "(", "Property", "<", "?", ">", "property", ")", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "List", "<", "Object", ">", "values", "=", "(", "List", "<", "Object", ">", ")", "property", ".", "getV...
Converts value of the property for the jcr domain. @param property property in cmis domain @return value of the given property in jcr domain.
[ "Converts", "value", "of", "the", "property", "for", "the", "jcr", "domain", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/Properties.java#L213-L238
train
ModeShape/modeshape
connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/Properties.java
Properties.asBooleans
private Boolean[] asBooleans( List<Object> values ) { ValueFactory<Boolean> factory = valueFactories.getBooleanFactory(); Boolean[] res = new Boolean[values.size()]; for (int i = 0; i < res.length; i++) { res[i] = factory.create(values.get(i)); } return res; }
java
private Boolean[] asBooleans( List<Object> values ) { ValueFactory<Boolean> factory = valueFactories.getBooleanFactory(); Boolean[] res = new Boolean[values.size()]; for (int i = 0; i < res.length; i++) { res[i] = factory.create(values.get(i)); } return res; }
[ "private", "Boolean", "[", "]", "asBooleans", "(", "List", "<", "Object", ">", "values", ")", "{", "ValueFactory", "<", "Boolean", ">", "factory", "=", "valueFactories", ".", "getBooleanFactory", "(", ")", ";", "Boolean", "[", "]", "res", "=", "new", "Bo...
Converts CMIS value of boolean type into JCR value of boolean type. @param values CMIS values of boolean type @return JCR values of boolean type
[ "Converts", "CMIS", "value", "of", "boolean", "type", "into", "JCR", "value", "of", "boolean", "type", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/Properties.java#L246-L253
train
ModeShape/modeshape
connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/Properties.java
Properties.asIntegers
private Long[] asIntegers( List<Object> values ) { ValueFactory<Long> factory = valueFactories.getLongFactory(); Long[] res = new Long[values.size()]; for (int i = 0; i < res.length; i++) { res[i] = factory.create(values.get(i)); } return res; }
java
private Long[] asIntegers( List<Object> values ) { ValueFactory<Long> factory = valueFactories.getLongFactory(); Long[] res = new Long[values.size()]; for (int i = 0; i < res.length; i++) { res[i] = factory.create(values.get(i)); } return res; }
[ "private", "Long", "[", "]", "asIntegers", "(", "List", "<", "Object", ">", "values", ")", "{", "ValueFactory", "<", "Long", ">", "factory", "=", "valueFactories", ".", "getLongFactory", "(", ")", ";", "Long", "[", "]", "res", "=", "new", "Long", "[", ...
Converts CMIS value of integer type into JCR value of boolean type. @param values CMIS values of integer type @return JCR values of integer type
[ "Converts", "CMIS", "value", "of", "integer", "type", "into", "JCR", "value", "of", "boolean", "type", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/Properties.java#L276-L283
train
ModeShape/modeshape
connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/Properties.java
Properties.asDecimals
private BigDecimal[] asDecimals( List<Object> values ) { ValueFactory<BigDecimal> factory = valueFactories.getDecimalFactory(); BigDecimal[] res = new BigDecimal[values.size()]; for (int i = 0; i < res.length; i++) { res[i] = factory.create(values.get(i)); } return res; }
java
private BigDecimal[] asDecimals( List<Object> values ) { ValueFactory<BigDecimal> factory = valueFactories.getDecimalFactory(); BigDecimal[] res = new BigDecimal[values.size()]; for (int i = 0; i < res.length; i++) { res[i] = factory.create(values.get(i)); } return res; }
[ "private", "BigDecimal", "[", "]", "asDecimals", "(", "List", "<", "Object", ">", "values", ")", "{", "ValueFactory", "<", "BigDecimal", ">", "factory", "=", "valueFactories", ".", "getDecimalFactory", "(", ")", ";", "BigDecimal", "[", "]", "res", "=", "ne...
Converts CMIS value of decimal type into JCR value of boolean type. @param values CMIS values of decimal type @return JCR values of decimal type
[ "Converts", "CMIS", "value", "of", "decimal", "type", "into", "JCR", "value", "of", "boolean", "type", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/Properties.java#L291-L298
train
ModeShape/modeshape
connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/Properties.java
Properties.asURI
private URI[] asURI( List<Object> values ) { ValueFactory<URI> factory = valueFactories.getUriFactory(); URI[] res = new URI[values.size()]; for (int i = 0; i < res.length; i++) { res[i] = factory.create(((GregorianCalendar)values.get(i)).getTime()); } return res; }
java
private URI[] asURI( List<Object> values ) { ValueFactory<URI> factory = valueFactories.getUriFactory(); URI[] res = new URI[values.size()]; for (int i = 0; i < res.length; i++) { res[i] = factory.create(((GregorianCalendar)values.get(i)).getTime()); } return res; }
[ "private", "URI", "[", "]", "asURI", "(", "List", "<", "Object", ">", "values", ")", "{", "ValueFactory", "<", "URI", ">", "factory", "=", "valueFactories", ".", "getUriFactory", "(", ")", ";", "URI", "[", "]", "res", "=", "new", "URI", "[", "values"...
Converts CMIS value of URI type into JCR value of URI type. @param values CMIS values of URI type @return JCR values of URI type
[ "Converts", "CMIS", "value", "of", "URI", "type", "into", "JCR", "value", "of", "URI", "type", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/Properties.java#L321-L328
train
ModeShape/modeshape
connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/Properties.java
Properties.asIDs
private String[] asIDs( List<Object> values ) { ValueFactory<String> factory = valueFactories.getStringFactory(); String[] res = new String[values.size()]; for (int i = 0; i < res.length; i++) { res[i] = factory.create(values.get(i)); } return res; }
java
private String[] asIDs( List<Object> values ) { ValueFactory<String> factory = valueFactories.getStringFactory(); String[] res = new String[values.size()]; for (int i = 0; i < res.length; i++) { res[i] = factory.create(values.get(i)); } return res; }
[ "private", "String", "[", "]", "asIDs", "(", "List", "<", "Object", ">", "values", ")", "{", "ValueFactory", "<", "String", ">", "factory", "=", "valueFactories", ".", "getStringFactory", "(", ")", ";", "String", "[", "]", "res", "=", "new", "String", ...
Converts CMIS value of ID type into JCR value of String type. @param values CMIS values of Id type @return JCR values of String type
[ "Converts", "CMIS", "value", "of", "ID", "type", "into", "JCR", "value", "of", "String", "type", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/Properties.java#L336-L343
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/Sequencers.java
Sequencers.workspaceAdded
protected void workspaceAdded( String workspaceName ) { String workspaceKey = NodeKey.keyForWorkspaceName(workspaceName); if (systemWorkspaceKey.equals(workspaceKey)) { // No sequencers for the system workspace! return; } Collection<SequencingConfiguration> configs = new LinkedList<SequencingConfiguration>(); // Go through the sequencers to see which apply to this workspace ... for (Sequencer sequencer : sequencersById.values()) { boolean updated = false; for (SequencerPathExpression expression : pathExpressionsBySequencerId.get(sequencer.getUniqueId())) { if (expression.appliesToWorkspace(workspaceName)) { updated = true; configs.add(new SequencingConfiguration(expression, sequencer)); } } if (DEBUG && updated) { LOGGER.debug("Updated sequencer '{0}' (id={1}) configuration due to new workspace '{2}' in repository '{3}'", sequencer.getName(), sequencer.getUniqueId(), workspaceName, repository.name()); } } if (configs.isEmpty()) return; // Otherwise, update the configs by workspace key ... try { configChangeLock.lock(); // Make a copy of the existing map ... Map<String, Collection<SequencingConfiguration>> configByWorkspaceName = new HashMap<String, Collection<SequencingConfiguration>>( this.configByWorkspaceName); // Insert the new information ... configByWorkspaceName.put(workspaceName, configs); // Replace the exisiting map (which is used without a lock) ... this.configByWorkspaceName = configByWorkspaceName; } finally { configChangeLock.unlock(); } }
java
protected void workspaceAdded( String workspaceName ) { String workspaceKey = NodeKey.keyForWorkspaceName(workspaceName); if (systemWorkspaceKey.equals(workspaceKey)) { // No sequencers for the system workspace! return; } Collection<SequencingConfiguration> configs = new LinkedList<SequencingConfiguration>(); // Go through the sequencers to see which apply to this workspace ... for (Sequencer sequencer : sequencersById.values()) { boolean updated = false; for (SequencerPathExpression expression : pathExpressionsBySequencerId.get(sequencer.getUniqueId())) { if (expression.appliesToWorkspace(workspaceName)) { updated = true; configs.add(new SequencingConfiguration(expression, sequencer)); } } if (DEBUG && updated) { LOGGER.debug("Updated sequencer '{0}' (id={1}) configuration due to new workspace '{2}' in repository '{3}'", sequencer.getName(), sequencer.getUniqueId(), workspaceName, repository.name()); } } if (configs.isEmpty()) return; // Otherwise, update the configs by workspace key ... try { configChangeLock.lock(); // Make a copy of the existing map ... Map<String, Collection<SequencingConfiguration>> configByWorkspaceName = new HashMap<String, Collection<SequencingConfiguration>>( this.configByWorkspaceName); // Insert the new information ... configByWorkspaceName.put(workspaceName, configs); // Replace the exisiting map (which is used without a lock) ... this.configByWorkspaceName = configByWorkspaceName; } finally { configChangeLock.unlock(); } }
[ "protected", "void", "workspaceAdded", "(", "String", "workspaceName", ")", "{", "String", "workspaceKey", "=", "NodeKey", ".", "keyForWorkspaceName", "(", "workspaceName", ")", ";", "if", "(", "systemWorkspaceKey", ".", "equals", "(", "workspaceKey", ")", ")", ...
Signal that a new workspace was added. @param workspaceName the workspace name; may not be null
[ "Signal", "that", "a", "new", "workspace", "was", "added", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/Sequencers.java#L272-L307
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/Sequencers.java
Sequencers.workspaceRemoved
protected void workspaceRemoved( String workspaceName ) { // Otherwise, update the configs by workspace key ... try { configChangeLock.lock(); // Make a copy of the existing map ... Map<String, Collection<SequencingConfiguration>> configByWorkspaceName = new HashMap<String, Collection<SequencingConfiguration>>( this.configByWorkspaceName); // Insert the new information ... if (configByWorkspaceName.remove(workspaceName) != null) { // Replace the exisiting map (which is used without a lock) ... this.configByWorkspaceName = configByWorkspaceName; } } finally { configChangeLock.unlock(); } }
java
protected void workspaceRemoved( String workspaceName ) { // Otherwise, update the configs by workspace key ... try { configChangeLock.lock(); // Make a copy of the existing map ... Map<String, Collection<SequencingConfiguration>> configByWorkspaceName = new HashMap<String, Collection<SequencingConfiguration>>( this.configByWorkspaceName); // Insert the new information ... if (configByWorkspaceName.remove(workspaceName) != null) { // Replace the exisiting map (which is used without a lock) ... this.configByWorkspaceName = configByWorkspaceName; } } finally { configChangeLock.unlock(); } }
[ "protected", "void", "workspaceRemoved", "(", "String", "workspaceName", ")", "{", "// Otherwise, update the configs by workspace key ...", "try", "{", "configChangeLock", ".", "lock", "(", ")", ";", "// Make a copy of the existing map ...", "Map", "<", "String", ",", "Co...
Signal that a new workspace was removed. @param workspaceName the workspace name; may not be null
[ "Signal", "that", "a", "new", "workspace", "was", "removed", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/Sequencers.java#L314-L329
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/naming/SingletonInitialContext.java
SingletonInitialContext.register
public static void register( String name, Object obj ) { register(name, obj, null, null, null, null); }
java
public static void register( String name, Object obj ) { register(name, obj, null, null, null, null); }
[ "public", "static", "void", "register", "(", "String", "name", ",", "Object", "obj", ")", "{", "register", "(", "name", ",", "obj", ",", "null", ",", "null", ",", "null", ",", "null", ")", ";", "}" ]
A convenience method that registers the supplied object with the supplied name. @param name the JNDI name @param obj the object to be registered
[ "A", "convenience", "method", "that", "registers", "the", "supplied", "object", "with", "the", "supplied", "name", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/naming/SingletonInitialContext.java#L68-L71
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/cache/change/AbstractNodeChange.java
AbstractNodeChange.getMixinTypes
public Set<Name> getMixinTypes() { if (types.length == 1) { return Collections.emptySet(); } return new HashSet<Name>(Arrays.asList(Arrays.copyOfRange(types, 1, types.length))); }
java
public Set<Name> getMixinTypes() { if (types.length == 1) { return Collections.emptySet(); } return new HashSet<Name>(Arrays.asList(Arrays.copyOfRange(types, 1, types.length))); }
[ "public", "Set", "<", "Name", ">", "getMixinTypes", "(", ")", "{", "if", "(", "types", ".", "length", "==", "1", ")", "{", "return", "Collections", ".", "emptySet", "(", ")", ";", "}", "return", "new", "HashSet", "<", "Name", ">", "(", "Arrays", "....
Returns the mixins for this node. @return a {@link Set}; never {@code null} but possibly empty.
[ "Returns", "the", "mixins", "for", "this", "node", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/cache/change/AbstractNodeChange.java#L91-L96
train
ModeShape/modeshape
sequencers/modeshape-sequencer-java/src/main/java/org/modeshape/sequencer/javafile/metadata/AbstractMetadata.java
AbstractMetadata.hasModifierNamed
private boolean hasModifierNamed( String modifierName ) { for (ModifierMetadata modifier : modifiers) { if (modifierName.equalsIgnoreCase(modifier.getName())) { return true; } } return false; }
java
private boolean hasModifierNamed( String modifierName ) { for (ModifierMetadata modifier : modifiers) { if (modifierName.equalsIgnoreCase(modifier.getName())) { return true; } } return false; }
[ "private", "boolean", "hasModifierNamed", "(", "String", "modifierName", ")", "{", "for", "(", "ModifierMetadata", "modifier", ":", "modifiers", ")", "{", "if", "(", "modifierName", ".", "equalsIgnoreCase", "(", "modifier", ".", "getName", "(", ")", ")", ")", ...
Checks if a modifier with the given name is found among this method's identifiers. @param modifierName the name of the modifier to check for @return true if the type has a modifier of that name, otherwise false
[ "Checks", "if", "a", "modifier", "with", "the", "given", "name", "is", "found", "among", "this", "method", "s", "identifiers", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-java/src/main/java/org/modeshape/sequencer/javafile/metadata/AbstractMetadata.java#L113-L122
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/statistic/DetailedStatistics.java
DetailedStatistics.getMedianValue
public double getMedianValue() { Lock lock = this.getLock().writeLock(); try { lock.lock(); int count = this.values.size(); if (count == 0) { return 0.0d; } if (this.medianValue == null) { // Sort the values in numerical order.. Comparator<T> comparator = this.math.getComparator(); Collections.sort(this.values, comparator); this.medianValue = 0.0d; // If there is only one value, then the median is that value ... if (count == 1) { this.medianValue = this.values.get(0).doubleValue(); } // If there is an odd number of values, find value that is in the middle .. else if (count % 2 != 0) { this.medianValue = this.values.get(((count + 1) / 2) - 1).doubleValue(); } // Otherwise, there is an even number of values, so find the average of the middle two values ... else { int upperMiddleValueIndex = count / 2; int lowerMiddleValueIndex = upperMiddleValueIndex - 1; double lowerValue = this.values.get(lowerMiddleValueIndex).doubleValue(); double upperValue = this.values.get(upperMiddleValueIndex).doubleValue(); this.medianValue = (lowerValue + upperValue) / 2.0d; } this.median = this.math.create(this.medianValue); this.histogram = null; } } finally { lock.unlock(); } return this.medianValue; }
java
public double getMedianValue() { Lock lock = this.getLock().writeLock(); try { lock.lock(); int count = this.values.size(); if (count == 0) { return 0.0d; } if (this.medianValue == null) { // Sort the values in numerical order.. Comparator<T> comparator = this.math.getComparator(); Collections.sort(this.values, comparator); this.medianValue = 0.0d; // If there is only one value, then the median is that value ... if (count == 1) { this.medianValue = this.values.get(0).doubleValue(); } // If there is an odd number of values, find value that is in the middle .. else if (count % 2 != 0) { this.medianValue = this.values.get(((count + 1) / 2) - 1).doubleValue(); } // Otherwise, there is an even number of values, so find the average of the middle two values ... else { int upperMiddleValueIndex = count / 2; int lowerMiddleValueIndex = upperMiddleValueIndex - 1; double lowerValue = this.values.get(lowerMiddleValueIndex).doubleValue(); double upperValue = this.values.get(upperMiddleValueIndex).doubleValue(); this.medianValue = (lowerValue + upperValue) / 2.0d; } this.median = this.math.create(this.medianValue); this.histogram = null; } } finally { lock.unlock(); } return this.medianValue; }
[ "public", "double", "getMedianValue", "(", ")", "{", "Lock", "lock", "=", "this", ".", "getLock", "(", ")", ".", "writeLock", "(", ")", ";", "try", "{", "lock", ".", "lock", "(", ")", ";", "int", "count", "=", "this", ".", "values", ".", "size", ...
Return the median value. @return the median value, or 0.0 if the {@link #getCount() count} is 0 @see #getMedian()
[ "Return", "the", "median", "value", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/statistic/DetailedStatistics.java#L129-L165
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/statistic/DetailedStatistics.java
DetailedStatistics.getStandardDeviation
public double getStandardDeviation() { Lock lock = this.getLock().readLock(); lock.lock(); try { return this.sigma; } finally { lock.unlock(); } }
java
public double getStandardDeviation() { Lock lock = this.getLock().readLock(); lock.lock(); try { return this.sigma; } finally { lock.unlock(); } }
[ "public", "double", "getStandardDeviation", "(", ")", "{", "Lock", "lock", "=", "this", ".", "getLock", "(", ")", ".", "readLock", "(", ")", ";", "lock", ".", "lock", "(", ")", ";", "try", "{", "return", "this", ".", "sigma", ";", "}", "finally", "...
Return the standard deviation. The standard deviation is a measure of the variation in a series of values. Values with a lower standard deviation has less variance in the values than a series of values with a higher standard deviation. @return the standard deviation, or 0.0 if the {@link #getCount() count} is 0 or if all of the values are the same.
[ "Return", "the", "standard", "deviation", ".", "The", "standard", "deviation", "is", "a", "measure", "of", "the", "variation", "in", "a", "series", "of", "values", ".", "Values", "with", "a", "lower", "standard", "deviation", "has", "less", "variance", "in",...
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/statistic/DetailedStatistics.java#L172-L180
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/BackupService.java
BackupService.backupRepository
public org.modeshape.jcr.api.Problems backupRepository( File backupDirectory, BackupOptions options ) throws RepositoryException { // Create the activity ... final BackupActivity backupActivity = createBackupActivity(backupDirectory, options); //suspend any existing transactions try { if (runningState.suspendExistingUserTransaction()) { LOGGER.debug("Suspended existing active user transaction before the backup operation starts"); } try { // Run the backup and return the problems ... return new JcrProblems(backupActivity.execute()); } finally { runningState.resumeExistingUserTransaction(); } } catch (SystemException e) { throw new RuntimeException(e); } }
java
public org.modeshape.jcr.api.Problems backupRepository( File backupDirectory, BackupOptions options ) throws RepositoryException { // Create the activity ... final BackupActivity backupActivity = createBackupActivity(backupDirectory, options); //suspend any existing transactions try { if (runningState.suspendExistingUserTransaction()) { LOGGER.debug("Suspended existing active user transaction before the backup operation starts"); } try { // Run the backup and return the problems ... return new JcrProblems(backupActivity.execute()); } finally { runningState.resumeExistingUserTransaction(); } } catch (SystemException e) { throw new RuntimeException(e); } }
[ "public", "org", ".", "modeshape", ".", "jcr", ".", "api", ".", "Problems", "backupRepository", "(", "File", "backupDirectory", ",", "BackupOptions", "options", ")", "throws", "RepositoryException", "{", "// Create the activity ...", "final", "BackupActivity", "backup...
Start backing up the repository. @param backupDirectory the directory on the file system into which the backup should be placed; this directory should typically not exist @param options a {@link org.modeshape.jcr.api.BackupOptions} instance controlling the behavior of the backup; may not be {@code null} @return the problems that occurred during the backup process @throws RepositoryException if the backup operation cannot be run
[ "Start", "backing", "up", "the", "repository", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/BackupService.java#L118-L136
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/BackupService.java
BackupService.restoreRepository
public org.modeshape.jcr.api.Problems restoreRepository( final JcrRepository repository, final File backupDirectory, final RestoreOptions options) throws RepositoryException { final String backupLocString = backupDirectory.getAbsolutePath(); LOGGER.debug("Beginning restore of '{0}' repository from {1} with options {2}", repository.getName(), backupLocString, options); // Put the repository into the 'restoring' state ... repository.prepareToRestore(); // Create the activity ... final RestoreActivity restoreActivity = createRestoreActivity(backupDirectory, options); org.modeshape.jcr.api.Problems problems = null; try { if (runningState.suspendExistingUserTransaction()) { LOGGER.debug("Suspended existing active user transaction before the restore operation starts"); } problems = new JcrProblems(restoreActivity.execute()); if (!problems.hasProblems()) { // restart the repository ... try { repository.completeRestore(options); } catch (Throwable t) { restoreActivity.problems.addError(t, JcrI18n.repositoryCannotBeRestartedAfterRestore, repository.getName(), t.getMessage()); } finally { runningState.resumeExistingUserTransaction(); } } } catch (SystemException e) { throw new RuntimeException(e); } LOGGER.debug("Completed restore of '{0}' repository from {1}", repository.getName(), backupLocString); return problems; }
java
public org.modeshape.jcr.api.Problems restoreRepository( final JcrRepository repository, final File backupDirectory, final RestoreOptions options) throws RepositoryException { final String backupLocString = backupDirectory.getAbsolutePath(); LOGGER.debug("Beginning restore of '{0}' repository from {1} with options {2}", repository.getName(), backupLocString, options); // Put the repository into the 'restoring' state ... repository.prepareToRestore(); // Create the activity ... final RestoreActivity restoreActivity = createRestoreActivity(backupDirectory, options); org.modeshape.jcr.api.Problems problems = null; try { if (runningState.suspendExistingUserTransaction()) { LOGGER.debug("Suspended existing active user transaction before the restore operation starts"); } problems = new JcrProblems(restoreActivity.execute()); if (!problems.hasProblems()) { // restart the repository ... try { repository.completeRestore(options); } catch (Throwable t) { restoreActivity.problems.addError(t, JcrI18n.repositoryCannotBeRestartedAfterRestore, repository.getName(), t.getMessage()); } finally { runningState.resumeExistingUserTransaction(); } } } catch (SystemException e) { throw new RuntimeException(e); } LOGGER.debug("Completed restore of '{0}' repository from {1}", repository.getName(), backupLocString); return problems; }
[ "public", "org", ".", "modeshape", ".", "jcr", ".", "api", ".", "Problems", "restoreRepository", "(", "final", "JcrRepository", "repository", ",", "final", "File", "backupDirectory", ",", "final", "RestoreOptions", "options", ")", "throws", "RepositoryException", ...
Start asynchronously backing up the repository. @param repository the JCR repository to be backed up; may not be null @param backupDirectory the directory on the file system that contains the backup; this directory obviously must exist @param options a {@link org.modeshape.jcr.api.RestoreOptions} instance which controls the restore behavior; may not be null @return the problems that occurred during the restore process @throws RepositoryException if the restoration operation cannot be run
[ "Start", "asynchronously", "backing", "up", "the", "repository", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/BackupService.java#L147-L182
train
ModeShape/modeshape
extractors/modeshape-extractor-tika/src/main/java/org/modeshape/extractor/tika/TikaTextExtractor.java
TikaTextExtractor.prepareMetadata
protected final Metadata prepareMetadata( final Binary binary, final Context context ) throws IOException, RepositoryException { Metadata metadata = new Metadata(); String mimeType = binary.getMimeType(); if (StringUtil.isBlank(mimeType)) { // Call the detector (we don't know the name) ... mimeType = context.mimeTypeOf(null, binary); } if (!StringUtil.isBlank(mimeType)) { metadata.set(Metadata.CONTENT_TYPE, mimeType); } return metadata; }
java
protected final Metadata prepareMetadata( final Binary binary, final Context context ) throws IOException, RepositoryException { Metadata metadata = new Metadata(); String mimeType = binary.getMimeType(); if (StringUtil.isBlank(mimeType)) { // Call the detector (we don't know the name) ... mimeType = context.mimeTypeOf(null, binary); } if (!StringUtil.isBlank(mimeType)) { metadata.set(Metadata.CONTENT_TYPE, mimeType); } return metadata; }
[ "protected", "final", "Metadata", "prepareMetadata", "(", "final", "Binary", "binary", ",", "final", "Context", "context", ")", "throws", "IOException", ",", "RepositoryException", "{", "Metadata", "metadata", "=", "new", "Metadata", "(", ")", ";", "String", "mi...
Creates a new tika metadata object used by the parser. This will contain the mime-type of the content being parsed, if this is available to the underlying context. If not, Tika's autodetection mechanism is used to try and get the mime-type. @param binary a <code>org.modeshape.jcr.api.Binary</code> instance of the content being parsed @param context the extraction context; may not be null @return a <code>Metadata</code> instance. @throws java.io.IOException if auto-detecting the mime-type via Tika fails @throws RepositoryException if error obtaining MIME-type of the binary parameter
[ "Creates", "a", "new", "tika", "metadata", "object", "used", "by", "the", "parser", ".", "This", "will", "contain", "the", "mime", "-", "type", "of", "the", "content", "being", "parsed", "if", "this", "is", "available", "to", "the", "underlying", "context"...
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/extractors/modeshape-extractor-tika/src/main/java/org/modeshape/extractor/tika/TikaTextExtractor.java#L170-L183
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/value/binary/MongodbBinaryStore.java
MongodbBinaryStore.convertToServerAddresses
private List<ServerAddress> convertToServerAddresses(Set<String> addresses) { return addresses.stream() .map(this::stringToServerAddress) .filter(Objects::nonNull) .collect(Collectors.toList()); }
java
private List<ServerAddress> convertToServerAddresses(Set<String> addresses) { return addresses.stream() .map(this::stringToServerAddress) .filter(Objects::nonNull) .collect(Collectors.toList()); }
[ "private", "List", "<", "ServerAddress", ">", "convertToServerAddresses", "(", "Set", "<", "String", ">", "addresses", ")", "{", "return", "addresses", ".", "stream", "(", ")", ".", "map", "(", "this", "::", "stringToServerAddress", ")", ".", "filter", "(", ...
Converts list of addresses specified in text format to mongodb specific address. @param addresses list of addresses in text format @return list of mongodb addresses @throws IllegalArgumentException if address has bad format or is not valid
[ "Converts", "list", "of", "addresses", "specified", "in", "text", "format", "to", "mongodb", "specific", "address", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/value/binary/MongodbBinaryStore.java#L132-L137
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/value/binary/MongodbBinaryStore.java
MongodbBinaryStore.setAttribute
private void setAttribute( DBCollection content, String fieldName, Object value ) { DBObject header = content.findOne(HEADER_QUERY); BasicDBObject newHeader = new BasicDBObject(); // clone header newHeader.put(FIELD_CHUNK_TYPE, header.get(FIELD_CHUNK_TYPE)); newHeader.put(FIELD_MIME_TYPE, header.get(FIELD_MIME_TYPE)); newHeader.put(FIELD_EXTRACTED_TEXT, header.get(FIELD_EXTRACTED_TEXT)); newHeader.put(FIELD_UNUSED, header.get(FIELD_UNUSED)); newHeader.put(FIELD_UNUSED_SINCE, header.get(FIELD_UNUSED_SINCE)); // modify specified field and update record newHeader.put(fieldName, value); content.update(HEADER_QUERY, newHeader); }
java
private void setAttribute( DBCollection content, String fieldName, Object value ) { DBObject header = content.findOne(HEADER_QUERY); BasicDBObject newHeader = new BasicDBObject(); // clone header newHeader.put(FIELD_CHUNK_TYPE, header.get(FIELD_CHUNK_TYPE)); newHeader.put(FIELD_MIME_TYPE, header.get(FIELD_MIME_TYPE)); newHeader.put(FIELD_EXTRACTED_TEXT, header.get(FIELD_EXTRACTED_TEXT)); newHeader.put(FIELD_UNUSED, header.get(FIELD_UNUSED)); newHeader.put(FIELD_UNUSED_SINCE, header.get(FIELD_UNUSED_SINCE)); // modify specified field and update record newHeader.put(fieldName, value); content.update(HEADER_QUERY, newHeader); }
[ "private", "void", "setAttribute", "(", "DBCollection", "content", ",", "String", "fieldName", ",", "Object", "value", ")", "{", "DBObject", "header", "=", "content", ".", "findOne", "(", "HEADER_QUERY", ")", ";", "BasicDBObject", "newHeader", "=", "new", "Bas...
Modifies content header. @param content stored content @param fieldName attribute name @param value new value for the attribute
[ "Modifies", "content", "header", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/value/binary/MongodbBinaryStore.java#L361-L377
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/value/binary/MongodbBinaryStore.java
MongodbBinaryStore.getAttribute
private Object getAttribute( DBCollection content, String fieldName ) { return content.findOne(HEADER_QUERY).get(fieldName); }
java
private Object getAttribute( DBCollection content, String fieldName ) { return content.findOne(HEADER_QUERY).get(fieldName); }
[ "private", "Object", "getAttribute", "(", "DBCollection", "content", ",", "String", "fieldName", ")", "{", "return", "content", ".", "findOne", "(", "HEADER_QUERY", ")", ".", "get", "(", "fieldName", ")", ";", "}" ]
Gets attribute's value. @param content stored content @param fieldName attribute name @return attributes value
[ "Gets", "attribute", "s", "value", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/value/binary/MongodbBinaryStore.java#L386-L389
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/value/binary/MongodbBinaryStore.java
MongodbBinaryStore.isExpired
private boolean isExpired( DBCollection content, long deadline ) { Long unusedSince = (Long)getAttribute(content, FIELD_UNUSED_SINCE); return unusedSince != null && unusedSince < deadline; }
java
private boolean isExpired( DBCollection content, long deadline ) { Long unusedSince = (Long)getAttribute(content, FIELD_UNUSED_SINCE); return unusedSince != null && unusedSince < deadline; }
[ "private", "boolean", "isExpired", "(", "DBCollection", "content", ",", "long", "deadline", ")", "{", "Long", "unusedSince", "=", "(", "Long", ")", "getAttribute", "(", "content", ",", "FIELD_UNUSED_SINCE", ")", ";", "return", "unusedSince", "!=", "null", "&&"...
Checks status of unused content. @param content content to check status @param deadline moment of time in past @return true if content is marked as unused before the deadline
[ "Checks", "status", "of", "unused", "content", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/value/binary/MongodbBinaryStore.java#L398-L402
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/optimize/PushSelectCriteria.java
PushSelectCriteria.pushDownJoinCriteria
protected boolean pushDownJoinCriteria( PlanNode criteriaNode, PlanNode joinNode ) { JoinType joinType = (JoinType)joinNode.getProperty(Property.JOIN_TYPE); switch (joinType) { case CROSS: joinNode.setProperty(Property.JOIN_TYPE, JoinType.INNER); moveCriteriaIntoOnClause(criteriaNode, joinNode); break; case INNER: moveCriteriaIntoOnClause(criteriaNode, joinNode); break; default: // This is where we could attempt to optimize the join type ... // if (optimizeJoinType(criteriaNode, joinNode) == JoinType.INNER) { // // The join type has changed ... // moveCriteriaIntoOnClause(criteriaNode, joinNode); // return true; // since the join type has changed ... // } } return false; }
java
protected boolean pushDownJoinCriteria( PlanNode criteriaNode, PlanNode joinNode ) { JoinType joinType = (JoinType)joinNode.getProperty(Property.JOIN_TYPE); switch (joinType) { case CROSS: joinNode.setProperty(Property.JOIN_TYPE, JoinType.INNER); moveCriteriaIntoOnClause(criteriaNode, joinNode); break; case INNER: moveCriteriaIntoOnClause(criteriaNode, joinNode); break; default: // This is where we could attempt to optimize the join type ... // if (optimizeJoinType(criteriaNode, joinNode) == JoinType.INNER) { // // The join type has changed ... // moveCriteriaIntoOnClause(criteriaNode, joinNode); // return true; // since the join type has changed ... // } } return false; }
[ "protected", "boolean", "pushDownJoinCriteria", "(", "PlanNode", "criteriaNode", ",", "PlanNode", "joinNode", ")", "{", "JoinType", "joinType", "=", "(", "JoinType", ")", "joinNode", ".", "getProperty", "(", "Property", ".", "JOIN_TYPE", ")", ";", "switch", "(",...
Attempt to push down criteria that applies to the JOIN as additional constraints on the JOIN itself. @param criteriaNode the SELECT node; may not be null @param joinNode the JOIN node; may not be null @return true if the criteria was pushed down, or false otherwise
[ "Attempt", "to", "push", "down", "criteria", "that", "applies", "to", "the", "JOIN", "as", "additional", "constraints", "on", "the", "JOIN", "itself", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/optimize/PushSelectCriteria.java#L223-L244
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/optimize/PushSelectCriteria.java
PushSelectCriteria.moveCriteriaIntoOnClause
private void moveCriteriaIntoOnClause( PlanNode criteriaNode, PlanNode joinNode ) { List<Constraint> constraints = joinNode.getPropertyAsList(Property.JOIN_CONSTRAINTS, Constraint.class); Constraint criteria = criteriaNode.getProperty(Property.SELECT_CRITERIA, Constraint.class); // since the parser uses EMPTY_LIST, check for size 0 also if (constraints == null || constraints.isEmpty()) { constraints = new LinkedList<Constraint>(); joinNode.setProperty(Property.JOIN_CONSTRAINTS, constraints); } if (!constraints.contains(criteria)) { constraints.add(criteria); if (criteriaNode.hasBooleanProperty(Property.IS_DEPENDENT)) { joinNode.setProperty(Property.IS_DEPENDENT, Boolean.TRUE); } } criteriaNode.extractFromParent(); }
java
private void moveCriteriaIntoOnClause( PlanNode criteriaNode, PlanNode joinNode ) { List<Constraint> constraints = joinNode.getPropertyAsList(Property.JOIN_CONSTRAINTS, Constraint.class); Constraint criteria = criteriaNode.getProperty(Property.SELECT_CRITERIA, Constraint.class); // since the parser uses EMPTY_LIST, check for size 0 also if (constraints == null || constraints.isEmpty()) { constraints = new LinkedList<Constraint>(); joinNode.setProperty(Property.JOIN_CONSTRAINTS, constraints); } if (!constraints.contains(criteria)) { constraints.add(criteria); if (criteriaNode.hasBooleanProperty(Property.IS_DEPENDENT)) { joinNode.setProperty(Property.IS_DEPENDENT, Boolean.TRUE); } } criteriaNode.extractFromParent(); }
[ "private", "void", "moveCriteriaIntoOnClause", "(", "PlanNode", "criteriaNode", ",", "PlanNode", "joinNode", ")", "{", "List", "<", "Constraint", ">", "constraints", "=", "joinNode", ".", "getPropertyAsList", "(", "Property", ".", "JOIN_CONSTRAINTS", ",", "Constrain...
Move the criteria that applies to the join to be included in the actual join criteria. @param criteriaNode the SELECT node; may not be null @param joinNode the JOIN node; may not be null
[ "Move", "the", "criteria", "that", "applies", "to", "the", "join", "to", "be", "included", "in", "the", "actual", "join", "criteria", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/optimize/PushSelectCriteria.java#L252-L270
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/spi/federation/Connector.java
Connector.moveExtraProperties
protected void moveExtraProperties( String oldNodeId, String newNodeId ) { ExtraPropertiesStore extraPropertiesStore = extraPropertiesStore(); if (extraPropertiesStore == null || !extraPropertiesStore.contains(oldNodeId)) { return; } Map<Name, Property> existingExtraProps = extraPropertiesStore.getProperties(oldNodeId); extraPropertiesStore.removeProperties(oldNodeId); extraPropertiesStore.storeProperties(newNodeId, existingExtraProps); }
java
protected void moveExtraProperties( String oldNodeId, String newNodeId ) { ExtraPropertiesStore extraPropertiesStore = extraPropertiesStore(); if (extraPropertiesStore == null || !extraPropertiesStore.contains(oldNodeId)) { return; } Map<Name, Property> existingExtraProps = extraPropertiesStore.getProperties(oldNodeId); extraPropertiesStore.removeProperties(oldNodeId); extraPropertiesStore.storeProperties(newNodeId, existingExtraProps); }
[ "protected", "void", "moveExtraProperties", "(", "String", "oldNodeId", ",", "String", "newNodeId", ")", "{", "ExtraPropertiesStore", "extraPropertiesStore", "=", "extraPropertiesStore", "(", ")", ";", "if", "(", "extraPropertiesStore", "==", "null", "||", "!", "ext...
Moves a set of extra properties from an old to a new node after their IDs have changed. @param oldNodeId the old identifier for the node; may not be null @param newNodeId the new identifier for the node; may not be null
[ "Moves", "a", "set", "of", "extra", "properties", "from", "an", "old", "to", "a", "new", "node", "after", "their", "IDs", "have", "changed", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/spi/federation/Connector.java#L298-L307
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/spi/federation/Connector.java
Connector.checkFieldNotNull
protected void checkFieldNotNull( Object fieldValue, String fieldName ) throws RepositoryException { if (fieldValue == null) { throw new RepositoryException(JcrI18n.requiredFieldNotSetInConnector.text(getSourceName(), getClass(), fieldName)); } }
java
protected void checkFieldNotNull( Object fieldValue, String fieldName ) throws RepositoryException { if (fieldValue == null) { throw new RepositoryException(JcrI18n.requiredFieldNotSetInConnector.text(getSourceName(), getClass(), fieldName)); } }
[ "protected", "void", "checkFieldNotNull", "(", "Object", "fieldValue", ",", "String", "fieldName", ")", "throws", "RepositoryException", "{", "if", "(", "fieldValue", "==", "null", ")", "{", "throw", "new", "RepositoryException", "(", "JcrI18n", ".", "requiredFiel...
Utility method that checks whether the field with the supplied name is set. @param fieldValue the value of the field @param fieldName the name of the field @throws RepositoryException if the field value is null
[ "Utility", "method", "that", "checks", "whether", "the", "field", "with", "the", "supplied", "name", "is", "set", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/spi/federation/Connector.java#L515-L520
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/optimize/RuleBasedOptimizer.java
RuleBasedOptimizer.populateRuleStack
protected void populateRuleStack( LinkedList<OptimizerRule> ruleStack, PlanHints hints ) { ruleStack.addFirst(ReorderSortAndRemoveDuplicates.INSTANCE); ruleStack.addFirst(RewritePathAndNameCriteria.INSTANCE); if (hints.hasSubqueries) { ruleStack.addFirst(RaiseVariableName.INSTANCE); } ruleStack.addFirst(RewriteAsRangeCriteria.INSTANCE); if (hints.hasJoin) { ruleStack.addFirst(AddJoinConditionColumnsToSources.INSTANCE); ruleStack.addFirst(ChooseJoinAlgorithm.USE_ONLY_NESTED_JOIN_ALGORITHM); ruleStack.addFirst(RewriteIdentityJoins.INSTANCE); } ruleStack.addFirst(AddOrderingColumnsToSources.INSTANCE); ruleStack.addFirst(PushProjects.INSTANCE); ruleStack.addFirst(PushSelectCriteria.INSTANCE); ruleStack.addFirst(AddAccessNodes.INSTANCE); ruleStack.addFirst(JoinOrder.INSTANCE); ruleStack.addFirst(RightOuterToLeftOuterJoins.INSTANCE); ruleStack.addFirst(CopyCriteria.INSTANCE); if (hints.hasView) { ruleStack.addFirst(ReplaceViews.INSTANCE); } ruleStack.addFirst(RewritePseudoColumns.INSTANCE); // Add indexes determination last ... populateIndexingRules(ruleStack, hints); ruleStack.addLast(OrderIndexesByCost.INSTANCE); }
java
protected void populateRuleStack( LinkedList<OptimizerRule> ruleStack, PlanHints hints ) { ruleStack.addFirst(ReorderSortAndRemoveDuplicates.INSTANCE); ruleStack.addFirst(RewritePathAndNameCriteria.INSTANCE); if (hints.hasSubqueries) { ruleStack.addFirst(RaiseVariableName.INSTANCE); } ruleStack.addFirst(RewriteAsRangeCriteria.INSTANCE); if (hints.hasJoin) { ruleStack.addFirst(AddJoinConditionColumnsToSources.INSTANCE); ruleStack.addFirst(ChooseJoinAlgorithm.USE_ONLY_NESTED_JOIN_ALGORITHM); ruleStack.addFirst(RewriteIdentityJoins.INSTANCE); } ruleStack.addFirst(AddOrderingColumnsToSources.INSTANCE); ruleStack.addFirst(PushProjects.INSTANCE); ruleStack.addFirst(PushSelectCriteria.INSTANCE); ruleStack.addFirst(AddAccessNodes.INSTANCE); ruleStack.addFirst(JoinOrder.INSTANCE); ruleStack.addFirst(RightOuterToLeftOuterJoins.INSTANCE); ruleStack.addFirst(CopyCriteria.INSTANCE); if (hints.hasView) { ruleStack.addFirst(ReplaceViews.INSTANCE); } ruleStack.addFirst(RewritePseudoColumns.INSTANCE); // Add indexes determination last ... populateIndexingRules(ruleStack, hints); ruleStack.addLast(OrderIndexesByCost.INSTANCE); }
[ "protected", "void", "populateRuleStack", "(", "LinkedList", "<", "OptimizerRule", ">", "ruleStack", ",", "PlanHints", "hints", ")", "{", "ruleStack", ".", "addFirst", "(", "ReorderSortAndRemoveDuplicates", ".", "INSTANCE", ")", ";", "ruleStack", ".", "addFirst", ...
Method that is used to create the initial rule stack. This method can be overridden by subclasses @param ruleStack the stack where the rules should be placed; never null @param hints the plan hints
[ "Method", "that", "is", "used", "to", "create", "the", "initial", "rule", "stack", ".", "This", "method", "can", "be", "overridden", "by", "subclasses" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/optimize/RuleBasedOptimizer.java#L59-L86
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/NodeTypeSchemata.java
NodeTypeSchemata.getSchemataForSession
public Schemata getSchemataForSession( JcrSession session ) { assert session != null; // If the session does not override any namespace mappings used in this schemata ... if (!overridesNamespaceMappings(session)) { // Then we can just use this schemata instance ... return this; } // Otherwise, the session has some custom namespace mappings, so we need to return a session-specific instance... return new SessionSchemata(session); }
java
public Schemata getSchemataForSession( JcrSession session ) { assert session != null; // If the session does not override any namespace mappings used in this schemata ... if (!overridesNamespaceMappings(session)) { // Then we can just use this schemata instance ... return this; } // Otherwise, the session has some custom namespace mappings, so we need to return a session-specific instance... return new SessionSchemata(session); }
[ "public", "Schemata", "getSchemataForSession", "(", "JcrSession", "session", ")", "{", "assert", "session", "!=", "null", ";", "// If the session does not override any namespace mappings used in this schemata ...", "if", "(", "!", "overridesNamespaceMappings", "(", "session", ...
Get a schemata instance that works with the supplied session and that uses the session-specific namespace mappings. Note that the resulting instance does not change as the session's namespace mappings are changed, so when that happens the JcrSession must call this method again to obtain a new schemata. @param session the session; may not be null @return the schemata that can be used for the session; never null
[ "Get", "a", "schemata", "instance", "that", "works", "with", "the", "supplied", "session", "and", "that", "uses", "the", "session", "-", "specific", "namespace", "mappings", ".", "Note", "that", "the", "resulting", "instance", "does", "not", "change", "as", ...
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/NodeTypeSchemata.java#L372-L382
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/NodeTypeSchemata.java
NodeTypeSchemata.overridesNamespaceMappings
private boolean overridesNamespaceMappings( JcrSession session ) { NamespaceRegistry registry = session.context().getNamespaceRegistry(); if (registry instanceof LocalNamespaceRegistry) { Set<Namespace> localNamespaces = ((LocalNamespaceRegistry)registry).getLocalNamespaces(); if (localNamespaces.isEmpty()) { // There are no local mappings ... return false; } for (Namespace namespace : localNamespaces) { if (prefixesByUris.containsKey(namespace.getNamespaceUri())) return true; } // None of the local namespace mappings overrode any namespaces used by this schemata ... return false; } // We can't find the local mappings, so brute-force it ... for (Namespace namespace : registry.getNamespaces()) { String expectedPrefix = prefixesByUris.get(namespace.getNamespaceUri()); if (expectedPrefix == null) { // This namespace is not used by this schemata ... continue; } if (!namespace.getPrefix().equals(expectedPrefix)) return true; } return false; }
java
private boolean overridesNamespaceMappings( JcrSession session ) { NamespaceRegistry registry = session.context().getNamespaceRegistry(); if (registry instanceof LocalNamespaceRegistry) { Set<Namespace> localNamespaces = ((LocalNamespaceRegistry)registry).getLocalNamespaces(); if (localNamespaces.isEmpty()) { // There are no local mappings ... return false; } for (Namespace namespace : localNamespaces) { if (prefixesByUris.containsKey(namespace.getNamespaceUri())) return true; } // None of the local namespace mappings overrode any namespaces used by this schemata ... return false; } // We can't find the local mappings, so brute-force it ... for (Namespace namespace : registry.getNamespaces()) { String expectedPrefix = prefixesByUris.get(namespace.getNamespaceUri()); if (expectedPrefix == null) { // This namespace is not used by this schemata ... continue; } if (!namespace.getPrefix().equals(expectedPrefix)) return true; } return false; }
[ "private", "boolean", "overridesNamespaceMappings", "(", "JcrSession", "session", ")", "{", "NamespaceRegistry", "registry", "=", "session", ".", "context", "(", ")", ".", "getNamespaceRegistry", "(", ")", ";", "if", "(", "registry", "instanceof", "LocalNamespaceReg...
Determine if the session overrides any namespace mappings used by this schemata. @param session the session; may not be null @return true if the session overrides one or more namespace mappings used in this schemata, or false otherwise
[ "Determine", "if", "the", "session", "overrides", "any", "namespace", "mappings", "used", "by", "this", "schemata", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/NodeTypeSchemata.java#L390-L414
train
ModeShape/modeshape
modeshape-schematic/src/main/java/org/modeshape/schematic/internal/document/BasicArray.java
BasicArray.removeValues
private List<Entry> removeValues( Collection<?> values, boolean ifMatch ) { LinkedList<Entry> results = null; // Record the list of entries that are removed, but start at the end of the values (so the indexes are correct) ListIterator<?> iter = this.values.listIterator(size()); while (iter.hasPrevious()) { int index = iter.previousIndex(); Object value = iter.previous(); if (ifMatch == values.contains(value)) { iter.remove(); if (results == null) { results = new LinkedList<>(); } results.addFirst(new BasicEntry(index, value)); } } return results != null ? results : Collections.<Entry>emptyList(); }
java
private List<Entry> removeValues( Collection<?> values, boolean ifMatch ) { LinkedList<Entry> results = null; // Record the list of entries that are removed, but start at the end of the values (so the indexes are correct) ListIterator<?> iter = this.values.listIterator(size()); while (iter.hasPrevious()) { int index = iter.previousIndex(); Object value = iter.previous(); if (ifMatch == values.contains(value)) { iter.remove(); if (results == null) { results = new LinkedList<>(); } results.addFirst(new BasicEntry(index, value)); } } return results != null ? results : Collections.<Entry>emptyList(); }
[ "private", "List", "<", "Entry", ">", "removeValues", "(", "Collection", "<", "?", ">", "values", ",", "boolean", "ifMatch", ")", "{", "LinkedList", "<", "Entry", ">", "results", "=", "null", ";", "// Record the list of entries that are removed, but start at the end...
Remove some of the values in this array. @param values the values to be compared to this array's values @param ifMatch true if this method should retain all values that match the supplied values, or false if this method should remove all values that match the supplied values @return the entries that were removed; never null
[ "Remove", "some", "of", "the", "values", "in", "this", "array", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-schematic/src/main/java/org/modeshape/schematic/internal/document/BasicArray.java#L721-L740
train
ModeShape/modeshape
connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/CmisConnector.java
CmisConnector.isExistCmisObject
private boolean isExistCmisObject(String path) { try { session.getObjectByPath(path); return true; } catch (CmisObjectNotFoundException e) { return false; } }
java
private boolean isExistCmisObject(String path) { try { session.getObjectByPath(path); return true; } catch (CmisObjectNotFoundException e) { return false; } }
[ "private", "boolean", "isExistCmisObject", "(", "String", "path", ")", "{", "try", "{", "session", ".", "getObjectByPath", "(", "path", ")", ";", "return", "true", ";", "}", "catch", "(", "CmisObjectNotFoundException", "e", ")", "{", "return", "false", ";", ...
Utility method for checking if CMIS object exists at defined path @param path path for object @return <code>true</code> if exists, <code>false</code> otherwise
[ "Utility", "method", "for", "checking", "if", "CMIS", "object", "exists", "at", "defined", "path" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/CmisConnector.java#L629-L637
train
ModeShape/modeshape
connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/CmisConnector.java
CmisConnector.rename
private void rename(CmisObject object, String name){ Map<String, Object> newName = new HashMap<String, Object>(); newName.put("cmis:name", name); object.updateProperties(newName); }
java
private void rename(CmisObject object, String name){ Map<String, Object> newName = new HashMap<String, Object>(); newName.put("cmis:name", name); object.updateProperties(newName); }
[ "private", "void", "rename", "(", "CmisObject", "object", ",", "String", "name", ")", "{", "Map", "<", "String", ",", "Object", ">", "newName", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "newName", ".", "put", "(", "\"cm...
Utility method for renaming CMIS object @param object CMIS object to rename @param name new name
[ "Utility", "method", "for", "renaming", "CMIS", "object" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/CmisConnector.java#L644-L649
train
ModeShape/modeshape
connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/CmisConnector.java
CmisConnector.cmisObject
private Document cmisObject( String id ) { CmisObject cmisObject; try { cmisObject = session.getObject(id); } catch (CmisObjectNotFoundException e) { return null; } // object does not exist? return null if (cmisObject == null) { return null; } // converting CMIS object to JCR node switch (cmisObject.getBaseTypeId()) { case CMIS_FOLDER: return cmisFolder(cmisObject); case CMIS_DOCUMENT: return cmisDocument(cmisObject); case CMIS_POLICY: case CMIS_RELATIONSHIP: case CMIS_SECONDARY: case CMIS_ITEM: } // unexpected object type return null; }
java
private Document cmisObject( String id ) { CmisObject cmisObject; try { cmisObject = session.getObject(id); } catch (CmisObjectNotFoundException e) { return null; } // object does not exist? return null if (cmisObject == null) { return null; } // converting CMIS object to JCR node switch (cmisObject.getBaseTypeId()) { case CMIS_FOLDER: return cmisFolder(cmisObject); case CMIS_DOCUMENT: return cmisDocument(cmisObject); case CMIS_POLICY: case CMIS_RELATIONSHIP: case CMIS_SECONDARY: case CMIS_ITEM: } // unexpected object type return null; }
[ "private", "Document", "cmisObject", "(", "String", "id", ")", "{", "CmisObject", "cmisObject", ";", "try", "{", "cmisObject", "=", "session", ".", "getObject", "(", "id", ")", ";", "}", "catch", "(", "CmisObjectNotFoundException", "e", ")", "{", "return", ...
Converts CMIS object to JCR node. @param id the identifier of the CMIS object @return JCR node document.
[ "Converts", "CMIS", "object", "to", "JCR", "node", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/CmisConnector.java#L711-L738
train
ModeShape/modeshape
connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/CmisConnector.java
CmisConnector.cmisFolder
private Document cmisFolder( CmisObject cmisObject ) { Folder folder = (Folder)cmisObject; DocumentWriter writer = newDocument(ObjectId.toString(ObjectId.Type.OBJECT, folder.getId())); ObjectType objectType = cmisObject.getType(); if (objectType.isBaseType()) { writer.setPrimaryType(NodeType.NT_FOLDER); } else { writer.setPrimaryType(objectType.getId()); } writer.setParent(folder.getParentId()); writer.addMixinType(NodeType.MIX_REFERENCEABLE); writer.addMixinType(NodeType.MIX_LAST_MODIFIED); cmisProperties(folder, writer); cmisChildren(folder, writer); writer.addMixinType("mode:accessControllable"); writer.addChild(ObjectId.toString(ObjectId.Type.ACL, folder.getId()), "mode:acl"); // append repository information to the root node if (folder.isRootFolder()) { writer.addChild(ObjectId.toString(ObjectId.Type.REPOSITORY_INFO, ""), REPOSITORY_INFO_NODE_NAME); } return writer.document(); }
java
private Document cmisFolder( CmisObject cmisObject ) { Folder folder = (Folder)cmisObject; DocumentWriter writer = newDocument(ObjectId.toString(ObjectId.Type.OBJECT, folder.getId())); ObjectType objectType = cmisObject.getType(); if (objectType.isBaseType()) { writer.setPrimaryType(NodeType.NT_FOLDER); } else { writer.setPrimaryType(objectType.getId()); } writer.setParent(folder.getParentId()); writer.addMixinType(NodeType.MIX_REFERENCEABLE); writer.addMixinType(NodeType.MIX_LAST_MODIFIED); cmisProperties(folder, writer); cmisChildren(folder, writer); writer.addMixinType("mode:accessControllable"); writer.addChild(ObjectId.toString(ObjectId.Type.ACL, folder.getId()), "mode:acl"); // append repository information to the root node if (folder.isRootFolder()) { writer.addChild(ObjectId.toString(ObjectId.Type.REPOSITORY_INFO, ""), REPOSITORY_INFO_NODE_NAME); } return writer.document(); }
[ "private", "Document", "cmisFolder", "(", "CmisObject", "cmisObject", ")", "{", "Folder", "folder", "=", "(", "Folder", ")", "cmisObject", ";", "DocumentWriter", "writer", "=", "newDocument", "(", "ObjectId", ".", "toString", "(", "ObjectId", ".", "Type", ".",...
Translates CMIS folder object to JCR node @param cmisObject CMIS folder object @return JCR node document.
[ "Translates", "CMIS", "folder", "object", "to", "JCR", "node" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/CmisConnector.java#L746-L772
train
ModeShape/modeshape
connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/CmisConnector.java
CmisConnector.cmisDocument
public Document cmisDocument( CmisObject cmisObject ) { org.apache.chemistry.opencmis.client.api.Document doc = (org.apache.chemistry.opencmis.client.api.Document)cmisObject; DocumentWriter writer = newDocument(ObjectId.toString(ObjectId.Type.OBJECT, doc.getId())); ObjectType objectType = cmisObject.getType(); if (objectType.isBaseType()) { writer.setPrimaryType(NodeType.NT_FILE); } else { writer.setPrimaryType(objectType.getId()); } List<Folder> parents = doc.getParents(); ArrayList<String> parentIds = new ArrayList<String>(); for (Folder f : parents) { parentIds.add(ObjectId.toString(ObjectId.Type.OBJECT, f.getId())); } writer.setParents(parentIds); writer.addMixinType(NodeType.MIX_REFERENCEABLE); writer.addMixinType(NodeType.MIX_LAST_MODIFIED); // document specific property conversation cmisProperties(doc, writer); writer.addChild(ObjectId.toString(ObjectId.Type.CONTENT, doc.getId()), JcrConstants.JCR_CONTENT); writer.addMixinType("mode:accessControllable"); writer.addChild(ObjectId.toString(ObjectId.Type.ACL, cmisObject.getId()), "mode:acl"); return writer.document(); }
java
public Document cmisDocument( CmisObject cmisObject ) { org.apache.chemistry.opencmis.client.api.Document doc = (org.apache.chemistry.opencmis.client.api.Document)cmisObject; DocumentWriter writer = newDocument(ObjectId.toString(ObjectId.Type.OBJECT, doc.getId())); ObjectType objectType = cmisObject.getType(); if (objectType.isBaseType()) { writer.setPrimaryType(NodeType.NT_FILE); } else { writer.setPrimaryType(objectType.getId()); } List<Folder> parents = doc.getParents(); ArrayList<String> parentIds = new ArrayList<String>(); for (Folder f : parents) { parentIds.add(ObjectId.toString(ObjectId.Type.OBJECT, f.getId())); } writer.setParents(parentIds); writer.addMixinType(NodeType.MIX_REFERENCEABLE); writer.addMixinType(NodeType.MIX_LAST_MODIFIED); // document specific property conversation cmisProperties(doc, writer); writer.addChild(ObjectId.toString(ObjectId.Type.CONTENT, doc.getId()), JcrConstants.JCR_CONTENT); writer.addMixinType("mode:accessControllable"); writer.addChild(ObjectId.toString(ObjectId.Type.ACL, cmisObject.getId()), "mode:acl"); return writer.document(); }
[ "public", "Document", "cmisDocument", "(", "CmisObject", "cmisObject", ")", "{", "org", ".", "apache", ".", "chemistry", ".", "opencmis", ".", "client", ".", "api", ".", "Document", "doc", "=", "(", "org", ".", "apache", ".", "chemistry", ".", "opencmis", ...
Translates cmis document object to JCR node. @param cmisObject cmis document node @return JCR node document.
[ "Translates", "cmis", "document", "object", "to", "JCR", "node", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/CmisConnector.java#L780-L809
train
ModeShape/modeshape
connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/CmisConnector.java
CmisConnector.cmisContent
private Document cmisContent( String id ) { DocumentWriter writer = newDocument(ObjectId.toString(ObjectId.Type.CONTENT, id)); org.apache.chemistry.opencmis.client.api.Document doc = (org.apache.chemistry.opencmis.client.api.Document)session.getObject(id); writer.setPrimaryType(NodeType.NT_RESOURCE); writer.setParent(id); ContentStream contentStream = doc.getContentStream(); if (contentStream != null) { BinaryValue content = new CmisConnectorBinary(contentStream, getSourceName(), id, getMimeTypeDetector()); writer.addProperty(JcrConstants.JCR_DATA, content); writer.addProperty(JcrConstants.JCR_MIME_TYPE, contentStream.getMimeType()); } Property<Object> lastModified = doc.getProperty(PropertyIds.LAST_MODIFICATION_DATE); Property<Object> lastModifiedBy = doc.getProperty(PropertyIds.LAST_MODIFIED_BY); writer.addProperty(JcrLexicon.LAST_MODIFIED, properties.jcrValues(lastModified)); writer.addProperty(JcrLexicon.LAST_MODIFIED_BY, properties.jcrValues(lastModifiedBy)); return writer.document(); }
java
private Document cmisContent( String id ) { DocumentWriter writer = newDocument(ObjectId.toString(ObjectId.Type.CONTENT, id)); org.apache.chemistry.opencmis.client.api.Document doc = (org.apache.chemistry.opencmis.client.api.Document)session.getObject(id); writer.setPrimaryType(NodeType.NT_RESOURCE); writer.setParent(id); ContentStream contentStream = doc.getContentStream(); if (contentStream != null) { BinaryValue content = new CmisConnectorBinary(contentStream, getSourceName(), id, getMimeTypeDetector()); writer.addProperty(JcrConstants.JCR_DATA, content); writer.addProperty(JcrConstants.JCR_MIME_TYPE, contentStream.getMimeType()); } Property<Object> lastModified = doc.getProperty(PropertyIds.LAST_MODIFICATION_DATE); Property<Object> lastModifiedBy = doc.getProperty(PropertyIds.LAST_MODIFIED_BY); writer.addProperty(JcrLexicon.LAST_MODIFIED, properties.jcrValues(lastModified)); writer.addProperty(JcrLexicon.LAST_MODIFIED_BY, properties.jcrValues(lastModifiedBy)); return writer.document(); }
[ "private", "Document", "cmisContent", "(", "String", "id", ")", "{", "DocumentWriter", "writer", "=", "newDocument", "(", "ObjectId", ".", "toString", "(", "ObjectId", ".", "Type", ".", "CONTENT", ",", "id", ")", ")", ";", "org", ".", "apache", ".", "che...
Converts binary content into JCR node. @param id the id of the CMIS document. @return JCR node representation.
[ "Converts", "binary", "content", "into", "JCR", "node", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/CmisConnector.java#L817-L838
train
ModeShape/modeshape
connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/CmisConnector.java
CmisConnector.cmisProperties
private void cmisProperties( CmisObject object, DocumentWriter writer ) { // convert properties List<Property<?>> list = object.getProperties(); for (Property<?> property : list) { String pname = properties.findJcrName(property.getId()); if (pname != null) { writer.addProperty(pname, properties.jcrValues(property)); } } }
java
private void cmisProperties( CmisObject object, DocumentWriter writer ) { // convert properties List<Property<?>> list = object.getProperties(); for (Property<?> property : list) { String pname = properties.findJcrName(property.getId()); if (pname != null) { writer.addProperty(pname, properties.jcrValues(property)); } } }
[ "private", "void", "cmisProperties", "(", "CmisObject", "object", ",", "DocumentWriter", "writer", ")", "{", "// convert properties", "List", "<", "Property", "<", "?", ">", ">", "list", "=", "object", ".", "getProperties", "(", ")", ";", "for", "(", "Proper...
Converts CMIS object's properties to JCR node properties. @param object CMIS object @param writer JCR node representation.
[ "Converts", "CMIS", "object", "s", "properties", "to", "JCR", "node", "properties", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/CmisConnector.java#L859-L869
train
ModeShape/modeshape
connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/CmisConnector.java
CmisConnector.cmisChildren
private void cmisChildren( Folder folder, DocumentWriter writer ) { ItemIterable<CmisObject> it = folder.getChildren(); for (CmisObject obj : it) { writer.addChild(obj.getId(), obj.getName()); } }
java
private void cmisChildren( Folder folder, DocumentWriter writer ) { ItemIterable<CmisObject> it = folder.getChildren(); for (CmisObject obj : it) { writer.addChild(obj.getId(), obj.getName()); } }
[ "private", "void", "cmisChildren", "(", "Folder", "folder", ",", "DocumentWriter", "writer", ")", "{", "ItemIterable", "<", "CmisObject", ">", "it", "=", "folder", ".", "getChildren", "(", ")", ";", "for", "(", "CmisObject", "obj", ":", "it", ")", "{", "...
Converts CMIS folder children to JCR node children @param folder CMIS folder @param writer JCR node representation
[ "Converts", "CMIS", "folder", "children", "to", "JCR", "node", "children" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/CmisConnector.java#L877-L883
train
ModeShape/modeshape
connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/CmisConnector.java
CmisConnector.cmisRepository
private Document cmisRepository() { RepositoryInfo info = session.getRepositoryInfo(); DocumentWriter writer = newDocument(ObjectId.toString(ObjectId.Type.REPOSITORY_INFO, "")); writer.setPrimaryType(CmisLexicon.REPOSITORY); writer.setId(REPOSITORY_INFO_ID); // product name/vendor/version writer.addProperty(CmisLexicon.VENDOR_NAME, info.getVendorName()); writer.addProperty(CmisLexicon.PRODUCT_NAME, info.getProductName()); writer.addProperty(CmisLexicon.PRODUCT_VERSION, info.getProductVersion()); return writer.document(); }
java
private Document cmisRepository() { RepositoryInfo info = session.getRepositoryInfo(); DocumentWriter writer = newDocument(ObjectId.toString(ObjectId.Type.REPOSITORY_INFO, "")); writer.setPrimaryType(CmisLexicon.REPOSITORY); writer.setId(REPOSITORY_INFO_ID); // product name/vendor/version writer.addProperty(CmisLexicon.VENDOR_NAME, info.getVendorName()); writer.addProperty(CmisLexicon.PRODUCT_NAME, info.getProductName()); writer.addProperty(CmisLexicon.PRODUCT_VERSION, info.getProductVersion()); return writer.document(); }
[ "private", "Document", "cmisRepository", "(", ")", "{", "RepositoryInfo", "info", "=", "session", ".", "getRepositoryInfo", "(", ")", ";", "DocumentWriter", "writer", "=", "newDocument", "(", "ObjectId", ".", "toString", "(", "ObjectId", ".", "Type", ".", "REP...
Translates CMIS repository information into Node. @return node document.
[ "Translates", "CMIS", "repository", "information", "into", "Node", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/CmisConnector.java#L890-L903
train
ModeShape/modeshape
connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/CmisConnector.java
CmisConnector.jcrBinaryContent
private ContentStream jcrBinaryContent( Document document ) { // pickup node properties Document props = document.getDocument("properties").getDocument(JcrLexicon.Namespace.URI); // extract binary value and content Binary value = props.getBinary("data"); if (value == null) { return null; } byte[] content = value.getBytes(); String fileName = props.getString("fileName"); String mimeType = props.getString("mimeType"); // wrap with input stream ByteArrayInputStream bin = new ByteArrayInputStream(content); bin.reset(); // create content stream return new ContentStreamImpl(fileName, BigInteger.valueOf(content.length), mimeType, bin); }
java
private ContentStream jcrBinaryContent( Document document ) { // pickup node properties Document props = document.getDocument("properties").getDocument(JcrLexicon.Namespace.URI); // extract binary value and content Binary value = props.getBinary("data"); if (value == null) { return null; } byte[] content = value.getBytes(); String fileName = props.getString("fileName"); String mimeType = props.getString("mimeType"); // wrap with input stream ByteArrayInputStream bin = new ByteArrayInputStream(content); bin.reset(); // create content stream return new ContentStreamImpl(fileName, BigInteger.valueOf(content.length), mimeType, bin); }
[ "private", "ContentStream", "jcrBinaryContent", "(", "Document", "document", ")", "{", "// pickup node properties", "Document", "props", "=", "document", ".", "getDocument", "(", "\"properties\"", ")", ".", "getDocument", "(", "JcrLexicon", ".", "Namespace", ".", "U...
Creates content stream using JCR node. @param document JCR node representation @return CMIS content stream object
[ "Creates", "content", "stream", "using", "JCR", "node", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/CmisConnector.java#L952-L973
train
ModeShape/modeshape
connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/CmisConnector.java
CmisConnector.importTypes
private void importTypes( List<Tree<ObjectType>> types, NodeTypeManager typeManager, NamespaceRegistry registry ) throws RepositoryException { for (Tree<ObjectType> tree : types) { importType(tree.getItem(), typeManager, registry); importTypes(tree.getChildren(), typeManager, registry); } }
java
private void importTypes( List<Tree<ObjectType>> types, NodeTypeManager typeManager, NamespaceRegistry registry ) throws RepositoryException { for (Tree<ObjectType> tree : types) { importType(tree.getItem(), typeManager, registry); importTypes(tree.getChildren(), typeManager, registry); } }
[ "private", "void", "importTypes", "(", "List", "<", "Tree", "<", "ObjectType", ">", ">", "types", ",", "NodeTypeManager", "typeManager", ",", "NamespaceRegistry", "registry", ")", "throws", "RepositoryException", "{", "for", "(", "Tree", "<", "ObjectType", ">", ...
Import CMIS types to JCR repository. @param types CMIS types @param typeManager JCR type manager @param registry @throws RepositoryException if there is a problem importing the types
[ "Import", "CMIS", "types", "to", "JCR", "repository", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/CmisConnector.java#L983-L990
train
ModeShape/modeshape
connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/CmisConnector.java
CmisConnector.importType
@SuppressWarnings( "unchecked" ) public void importType( ObjectType cmisType, NodeTypeManager typeManager, NamespaceRegistry registry ) throws RepositoryException { // TODO: get namespace information and register // registry.registerNamespace(cmisType.getLocalNamespace(), cmisType.getLocalNamespace()); // create node type template NodeTypeTemplate type = typeManager.createNodeTypeTemplate(); // convert CMIS type's attributes to node type template we have just created type.setName(cmisType.getId()); type.setAbstract(false); type.setMixin(false); type.setOrderableChildNodes(true); type.setQueryable(true); if (!cmisType.isBaseType()) { type.setDeclaredSuperTypeNames(superTypes(cmisType)); } Map<String, PropertyDefinition<?>> props = cmisType.getPropertyDefinitions(); Set<String> names = props.keySet(); // properties for (String name : names) { PropertyDefinition<?> pd = props.get(name); PropertyDefinitionTemplate pt = typeManager.createPropertyDefinitionTemplate(); pt.setRequiredType(properties.getJcrType(pd.getPropertyType())); pt.setAutoCreated(false); pt.setAvailableQueryOperators(new String[] {}); pt.setName(name); pt.setMandatory(pd.isRequired()); type.getPropertyDefinitionTemplates().add(pt); } // register type NodeTypeDefinition[] nodeDefs = new NodeTypeDefinition[] {type}; typeManager.registerNodeTypes(nodeDefs, true); }
java
@SuppressWarnings( "unchecked" ) public void importType( ObjectType cmisType, NodeTypeManager typeManager, NamespaceRegistry registry ) throws RepositoryException { // TODO: get namespace information and register // registry.registerNamespace(cmisType.getLocalNamespace(), cmisType.getLocalNamespace()); // create node type template NodeTypeTemplate type = typeManager.createNodeTypeTemplate(); // convert CMIS type's attributes to node type template we have just created type.setName(cmisType.getId()); type.setAbstract(false); type.setMixin(false); type.setOrderableChildNodes(true); type.setQueryable(true); if (!cmisType.isBaseType()) { type.setDeclaredSuperTypeNames(superTypes(cmisType)); } Map<String, PropertyDefinition<?>> props = cmisType.getPropertyDefinitions(); Set<String> names = props.keySet(); // properties for (String name : names) { PropertyDefinition<?> pd = props.get(name); PropertyDefinitionTemplate pt = typeManager.createPropertyDefinitionTemplate(); pt.setRequiredType(properties.getJcrType(pd.getPropertyType())); pt.setAutoCreated(false); pt.setAvailableQueryOperators(new String[] {}); pt.setName(name); pt.setMandatory(pd.isRequired()); type.getPropertyDefinitionTemplates().add(pt); } // register type NodeTypeDefinition[] nodeDefs = new NodeTypeDefinition[] {type}; typeManager.registerNodeTypes(nodeDefs, true); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "importType", "(", "ObjectType", "cmisType", ",", "NodeTypeManager", "typeManager", ",", "NamespaceRegistry", "registry", ")", "throws", "RepositoryException", "{", "// TODO: get namespace information and...
Import given CMIS type to the JCR repository. @param cmisType cmis object type @param typeManager JCR type manager/ @param registry @throws RepositoryException if there is a problem importing the types
[ "Import", "given", "CMIS", "type", "to", "the", "JCR", "repository", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/CmisConnector.java#L1000-L1037
train
ModeShape/modeshape
connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/CmisConnector.java
CmisConnector.superTypes
private String[] superTypes( ObjectType cmisType ) { if (cmisType.getBaseTypeId() == BaseTypeId.CMIS_FOLDER) { return new String[] {JcrConstants.NT_FOLDER}; } if (cmisType.getBaseTypeId() == BaseTypeId.CMIS_DOCUMENT) { return new String[] {JcrConstants.NT_FILE}; } return new String[] {cmisType.getParentType().getId()}; }
java
private String[] superTypes( ObjectType cmisType ) { if (cmisType.getBaseTypeId() == BaseTypeId.CMIS_FOLDER) { return new String[] {JcrConstants.NT_FOLDER}; } if (cmisType.getBaseTypeId() == BaseTypeId.CMIS_DOCUMENT) { return new String[] {JcrConstants.NT_FILE}; } return new String[] {cmisType.getParentType().getId()}; }
[ "private", "String", "[", "]", "superTypes", "(", "ObjectType", "cmisType", ")", "{", "if", "(", "cmisType", ".", "getBaseTypeId", "(", ")", "==", "BaseTypeId", ".", "CMIS_FOLDER", ")", "{", "return", "new", "String", "[", "]", "{", "JcrConstants", ".", ...
Determines supertypes for the given CMIS type in terms of JCR. @param cmisType given CMIS type @return supertypes in JCR lexicon.
[ "Determines", "supertypes", "for", "the", "given", "CMIS", "type", "in", "terms", "of", "JCR", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/CmisConnector.java#L1045-L1055
train
ModeShape/modeshape
connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/CmisConnector.java
CmisConnector.registerRepositoryInfoType
@SuppressWarnings( "unchecked" ) private void registerRepositoryInfoType( NodeTypeManager typeManager ) throws RepositoryException { // create node type template NodeTypeTemplate type = typeManager.createNodeTypeTemplate(); // convert CMIS type's attributes to node type template we have just created type.setName("cmis:repository"); type.setAbstract(false); type.setMixin(false); type.setOrderableChildNodes(true); type.setQueryable(true); type.setDeclaredSuperTypeNames(new String[] {JcrConstants.NT_FOLDER}); PropertyDefinitionTemplate vendorName = typeManager.createPropertyDefinitionTemplate(); vendorName.setAutoCreated(false); vendorName.setName("cmis:vendorName"); vendorName.setMandatory(false); type.getPropertyDefinitionTemplates().add(vendorName); PropertyDefinitionTemplate productName = typeManager.createPropertyDefinitionTemplate(); productName.setAutoCreated(false); productName.setName("cmis:productName"); productName.setMandatory(false); type.getPropertyDefinitionTemplates().add(productName); PropertyDefinitionTemplate productVersion = typeManager.createPropertyDefinitionTemplate(); productVersion.setAutoCreated(false); productVersion.setName("cmis:productVersion"); productVersion.setMandatory(false); type.getPropertyDefinitionTemplates().add(productVersion); // register type NodeTypeDefinition[] nodeDefs = new NodeTypeDefinition[] {type}; typeManager.registerNodeTypes(nodeDefs, true); }
java
@SuppressWarnings( "unchecked" ) private void registerRepositoryInfoType( NodeTypeManager typeManager ) throws RepositoryException { // create node type template NodeTypeTemplate type = typeManager.createNodeTypeTemplate(); // convert CMIS type's attributes to node type template we have just created type.setName("cmis:repository"); type.setAbstract(false); type.setMixin(false); type.setOrderableChildNodes(true); type.setQueryable(true); type.setDeclaredSuperTypeNames(new String[] {JcrConstants.NT_FOLDER}); PropertyDefinitionTemplate vendorName = typeManager.createPropertyDefinitionTemplate(); vendorName.setAutoCreated(false); vendorName.setName("cmis:vendorName"); vendorName.setMandatory(false); type.getPropertyDefinitionTemplates().add(vendorName); PropertyDefinitionTemplate productName = typeManager.createPropertyDefinitionTemplate(); productName.setAutoCreated(false); productName.setName("cmis:productName"); productName.setMandatory(false); type.getPropertyDefinitionTemplates().add(productName); PropertyDefinitionTemplate productVersion = typeManager.createPropertyDefinitionTemplate(); productVersion.setAutoCreated(false); productVersion.setName("cmis:productVersion"); productVersion.setMandatory(false); type.getPropertyDefinitionTemplates().add(productVersion); // register type NodeTypeDefinition[] nodeDefs = new NodeTypeDefinition[] {type}; typeManager.registerNodeTypes(nodeDefs, true); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "void", "registerRepositoryInfoType", "(", "NodeTypeManager", "typeManager", ")", "throws", "RepositoryException", "{", "// create node type template", "NodeTypeTemplate", "type", "=", "typeManager", ".", "creat...
Defines node type for the repository info. @param typeManager JCR node type manager. @throws RepositoryException
[ "Defines", "node", "type", "for", "the", "repository", "info", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/CmisConnector.java#L1063-L1100
train
ModeShape/modeshape
modeshape-jdbc-local/src/main/java/org/modeshape/jdbc/delegate/LocalRepositoryDelegate.java
LocalRepositoryDelegate.execute
@Override public QueryResult execute( String query, String language ) throws RepositoryException { logger.trace("Executing query: {0}", query); // Create the query ... final Query jcrQuery = getLocalSession().getSession().getWorkspace().getQueryManager().createQuery(query, language); return jcrQuery.execute(); }
java
@Override public QueryResult execute( String query, String language ) throws RepositoryException { logger.trace("Executing query: {0}", query); // Create the query ... final Query jcrQuery = getLocalSession().getSession().getWorkspace().getQueryManager().createQuery(query, language); return jcrQuery.execute(); }
[ "@", "Override", "public", "QueryResult", "execute", "(", "String", "query", ",", "String", "language", ")", "throws", "RepositoryException", "{", "logger", ".", "trace", "(", "\"Executing query: {0}\"", ",", "query", ")", ";", "// Create the query ...", "final", ...
This execute method is used for redirection so that the JNDI implementation can control calling execute. @see java.sql.Statement#execute(java.lang.String)
[ "This", "execute", "method", "is", "used", "for", "redirection", "so", "that", "the", "JNDI", "implementation", "can", "control", "calling", "execute", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jdbc-local/src/main/java/org/modeshape/jdbc/delegate/LocalRepositoryDelegate.java#L120-L129
train
ModeShape/modeshape
modeshape-jdbc/src/main/java/org/modeshape/jdbc/rest/ModeShapeRestClient.java
ModeShapeRestClient.getRepositories
public Repositories getRepositories() { JSONRestClient.Response response = jsonRestClient.doGet(); if (!response.isOK()) { throw new RuntimeException(JdbcI18n.invalidServerResponse.text(jsonRestClient.url(), response.asString())); } return new Repositories(response.json()); }
java
public Repositories getRepositories() { JSONRestClient.Response response = jsonRestClient.doGet(); if (!response.isOK()) { throw new RuntimeException(JdbcI18n.invalidServerResponse.text(jsonRestClient.url(), response.asString())); } return new Repositories(response.json()); }
[ "public", "Repositories", "getRepositories", "(", ")", "{", "JSONRestClient", ".", "Response", "response", "=", "jsonRestClient", ".", "doGet", "(", ")", ";", "if", "(", "!", "response", ".", "isOK", "(", ")", ")", "{", "throw", "new", "RuntimeException", ...
Returns a list with all the available repositories. @return a {@link Repositories} instance, never {@code null}
[ "Returns", "a", "list", "with", "all", "the", "available", "repositories", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jdbc/src/main/java/org/modeshape/jdbc/rest/ModeShapeRestClient.java#L68-L74
train
ModeShape/modeshape
modeshape-jdbc/src/main/java/org/modeshape/jdbc/rest/ModeShapeRestClient.java
ModeShapeRestClient.getWorkspaces
public Workspaces getWorkspaces( String repositoryName ) { String url = jsonRestClient.appendToBaseURL(repositoryName); JSONRestClient.Response response = jsonRestClient.doGet(url); if (!response.isOK()) { throw new RuntimeException(JdbcI18n.invalidServerResponse.text(url, response.asString())); } return new Workspaces(response.json()); }
java
public Workspaces getWorkspaces( String repositoryName ) { String url = jsonRestClient.appendToBaseURL(repositoryName); JSONRestClient.Response response = jsonRestClient.doGet(url); if (!response.isOK()) { throw new RuntimeException(JdbcI18n.invalidServerResponse.text(url, response.asString())); } return new Workspaces(response.json()); }
[ "public", "Workspaces", "getWorkspaces", "(", "String", "repositoryName", ")", "{", "String", "url", "=", "jsonRestClient", ".", "appendToBaseURL", "(", "repositoryName", ")", ";", "JSONRestClient", ".", "Response", "response", "=", "jsonRestClient", ".", "doGet", ...
Returns all the workspaces for the named repository. @param repositoryName a {@code String} the name of a repository; may not be {@code null} @return a {@link Workspaces} instance; never {@code null}
[ "Returns", "all", "the", "workspaces", "for", "the", "named", "repository", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jdbc/src/main/java/org/modeshape/jdbc/rest/ModeShapeRestClient.java#L96-L103
train
ModeShape/modeshape
modeshape-jdbc/src/main/java/org/modeshape/jdbc/rest/ModeShapeRestClient.java
ModeShapeRestClient.queryPlan
public String queryPlan( String query, String queryLanguage ) { String url = jsonRestClient.appendToURL(QUERY_PLAN_METHOD); String contentType = contentTypeForQueryLanguage(queryLanguage); JSONRestClient.Response response = jsonRestClient.postStreamTextPlain(new ByteArrayInputStream(query.getBytes()), url, contentType); if (!response.isOK()) { throw new RuntimeException(JdbcI18n.invalidServerResponse.text(url, response.asString())); } return response.asString(); }
java
public String queryPlan( String query, String queryLanguage ) { String url = jsonRestClient.appendToURL(QUERY_PLAN_METHOD); String contentType = contentTypeForQueryLanguage(queryLanguage); JSONRestClient.Response response = jsonRestClient.postStreamTextPlain(new ByteArrayInputStream(query.getBytes()), url, contentType); if (!response.isOK()) { throw new RuntimeException(JdbcI18n.invalidServerResponse.text(url, response.asString())); } return response.asString(); }
[ "public", "String", "queryPlan", "(", "String", "query", ",", "String", "queryLanguage", ")", "{", "String", "url", "=", "jsonRestClient", ".", "appendToURL", "(", "QUERY_PLAN_METHOD", ")", ";", "String", "contentType", "=", "contentTypeForQueryLanguage", "(", "qu...
Returns a string representation of a query plan in a given language. @param query a {@code String}, never {@code null} @param queryLanguage the language of the query, never {@code null} @return a {@code String} description of the plan, never {@code null}
[ "Returns", "a", "string", "representation", "of", "a", "query", "plan", "in", "a", "given", "language", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jdbc/src/main/java/org/modeshape/jdbc/rest/ModeShapeRestClient.java#L145-L155
train
ModeShape/modeshape
index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/SearchResults.java
SearchResults.getCardinality
public long getCardinality() { if (pos > 0) { return totalHits; } try { EsResponse res = client.search(index, type, query); Document hits = (Document) res.get("hits"); totalHits = hits.getInteger("total"); return totalHits; } catch (Exception e) { throw new EsIndexException(e); } }
java
public long getCardinality() { if (pos > 0) { return totalHits; } try { EsResponse res = client.search(index, type, query); Document hits = (Document) res.get("hits"); totalHits = hits.getInteger("total"); return totalHits; } catch (Exception e) { throw new EsIndexException(e); } }
[ "public", "long", "getCardinality", "(", ")", "{", "if", "(", "pos", ">", "0", ")", "{", "return", "totalHits", ";", "}", "try", "{", "EsResponse", "res", "=", "client", ".", "search", "(", "index", ",", "type", ",", "query", ")", ";", "Document", ...
Gets cardinality for this search request. @return total hits matching search request.
[ "Gets", "cardinality", "for", "this", "search", "request", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/SearchResults.java#L108-L120
train