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 | modeshape-jcr/src/main/java/org/modeshape/jcr/query/parse/FullTextSearchParser.java | FullTextSearchParser.parse | public Term parse( String fullTextSearchExpression ) {
CheckArg.isNotNull(fullTextSearchExpression, "fullTextSearchExpression");
Tokenizer tokenizer = new TermTokenizer();
TokenStream stream = new TokenStream(fullTextSearchExpression, tokenizer, false);
return parse(stream.start());
} | java | public Term parse( String fullTextSearchExpression ) {
CheckArg.isNotNull(fullTextSearchExpression, "fullTextSearchExpression");
Tokenizer tokenizer = new TermTokenizer();
TokenStream stream = new TokenStream(fullTextSearchExpression, tokenizer, false);
return parse(stream.start());
} | [
"public",
"Term",
"parse",
"(",
"String",
"fullTextSearchExpression",
")",
"{",
"CheckArg",
".",
"isNotNull",
"(",
"fullTextSearchExpression",
",",
"\"fullTextSearchExpression\"",
")",
";",
"Tokenizer",
"tokenizer",
"=",
"new",
"TermTokenizer",
"(",
")",
";",
"Token... | Parse the full-text search criteria given in the supplied string.
@param fullTextSearchExpression the full-text search expression; may not be null
@return the term representation of the full-text search, or null if there are no terms
@throws ParsingException if there is an error parsing the supplied string
@throws IllegalArgumentException if the expression is null | [
"Parse",
"the",
"full",
"-",
"text",
"search",
"criteria",
"given",
"in",
"the",
"supplied",
"string",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/parse/FullTextSearchParser.java#L121-L126 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/parse/FullTextSearchParser.java | FullTextSearchParser.parse | public Term parse( TokenStream tokens ) {
CheckArg.isNotNull(tokens, "tokens");
List<Term> terms = new ArrayList<Term>();
do {
Term term = parseDisjunctedTerms(tokens);
if (term == null) break;
terms.add(term);
} while (tokens.canConsume("OR"));
if (terms.isEmpty()) return null;
return terms.size() > 1 ? new Disjunction(terms) : terms.iterator().next();
} | java | public Term parse( TokenStream tokens ) {
CheckArg.isNotNull(tokens, "tokens");
List<Term> terms = new ArrayList<Term>();
do {
Term term = parseDisjunctedTerms(tokens);
if (term == null) break;
terms.add(term);
} while (tokens.canConsume("OR"));
if (terms.isEmpty()) return null;
return terms.size() > 1 ? new Disjunction(terms) : terms.iterator().next();
} | [
"public",
"Term",
"parse",
"(",
"TokenStream",
"tokens",
")",
"{",
"CheckArg",
".",
"isNotNull",
"(",
"tokens",
",",
"\"tokens\"",
")",
";",
"List",
"<",
"Term",
">",
"terms",
"=",
"new",
"ArrayList",
"<",
"Term",
">",
"(",
")",
";",
"do",
"{",
"Term... | Parse the full-text search criteria from the supplied token stream. This method is useful when the full-text search
expression is included in other content.
@param tokens the token stream containing the full-text search starting on the next token
@return the term representation of the full-text search, or null if there are no terms
@throws ParsingException if there is an error parsing the supplied string
@throws IllegalArgumentException if the token stream is null | [
"Parse",
"the",
"full",
"-",
"text",
"search",
"criteria",
"from",
"the",
"supplied",
"token",
"stream",
".",
"This",
"method",
"is",
"useful",
"when",
"the",
"full",
"-",
"text",
"search",
"expression",
"is",
"included",
"in",
"other",
"content",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/parse/FullTextSearchParser.java#L137-L147 | train |
ModeShape/modeshape | persistence/modeshape-persistence-relational/src/main/java/org/modeshape/persistence/relational/TransactionsHolder.java | TransactionsHolder.requireActiveTransaction | protected static String requireActiveTransaction() {
return Optional.ofNullable(ACTIVE_TX_ID.get()).orElseThrow(() -> new RelationalProviderException(
RelationalProviderI18n.threadNotAssociatedWithTransaction,
Thread.currentThread().getName()));
} | java | protected static String requireActiveTransaction() {
return Optional.ofNullable(ACTIVE_TX_ID.get()).orElseThrow(() -> new RelationalProviderException(
RelationalProviderI18n.threadNotAssociatedWithTransaction,
Thread.currentThread().getName()));
} | [
"protected",
"static",
"String",
"requireActiveTransaction",
"(",
")",
"{",
"return",
"Optional",
".",
"ofNullable",
"(",
"ACTIVE_TX_ID",
".",
"get",
"(",
")",
")",
".",
"orElseThrow",
"(",
"(",
")",
"->",
"new",
"RelationalProviderException",
"(",
"RelationalPr... | Requires that an active transaction exists for the current calling thread.
@return the ID of the active transaction, never {@code null}
@throws RelationalProviderException if the current thread is not associated with a transaction. | [
"Requires",
"that",
"an",
"active",
"transaction",
"exists",
"for",
"the",
"current",
"calling",
"thread",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/persistence/modeshape-persistence-relational/src/main/java/org/modeshape/persistence/relational/TransactionsHolder.java#L45-L49 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/NodeSequence.java | NodeSequence.emptySequence | public static NodeSequence emptySequence( final int width ) {
assert width >= 0;
return new NodeSequence() {
@Override
public int width() {
return width;
}
@Override
public Batch nextBatch() {
return null;
}
@Override
public long getRowCount() {
return 0;
}
@Override
public boolean isEmpty() {
return true;
}
@Override
public void close() {
}
@Override
public String toString() {
return "(empty-sequence width=" + width() + ")";
}
};
} | java | public static NodeSequence emptySequence( final int width ) {
assert width >= 0;
return new NodeSequence() {
@Override
public int width() {
return width;
}
@Override
public Batch nextBatch() {
return null;
}
@Override
public long getRowCount() {
return 0;
}
@Override
public boolean isEmpty() {
return true;
}
@Override
public void close() {
}
@Override
public String toString() {
return "(empty-sequence width=" + width() + ")";
}
};
} | [
"public",
"static",
"NodeSequence",
"emptySequence",
"(",
"final",
"int",
"width",
")",
"{",
"assert",
"width",
">=",
"0",
";",
"return",
"new",
"NodeSequence",
"(",
")",
"{",
"@",
"Override",
"public",
"int",
"width",
"(",
")",
"{",
"return",
"width",
"... | Get an empty node sequence.
@param width the width of the batches; must be positive
@return the empty node sequence; never null | [
"Get",
"an",
"empty",
"node",
"sequence",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/NodeSequence.java#L184-L216 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/NodeSequence.java | NodeSequence.emptyBatch | public static Batch emptyBatch( final String workspaceName,
final int width ) {
assert width > 0;
return new Batch() {
@Override
public boolean hasNext() {
return false;
}
@Override
public String getWorkspaceName() {
return workspaceName;
}
@Override
public int width() {
return width;
}
@Override
public long rowCount() {
return 0;
}
@Override
public boolean isEmpty() {
return true;
}
@Override
public void nextRow() {
throw new NoSuchElementException();
}
@Override
public CachedNode getNode() {
throw new NoSuchElementException();
}
@Override
public CachedNode getNode( int index ) {
throw new NoSuchElementException();
}
@Override
public float getScore() {
throw new NoSuchElementException();
}
@Override
public float getScore( int index ) {
throw new NoSuchElementException();
}
@Override
public String toString() {
return "(empty-batch width=" + width() + ")";
}
};
} | java | public static Batch emptyBatch( final String workspaceName,
final int width ) {
assert width > 0;
return new Batch() {
@Override
public boolean hasNext() {
return false;
}
@Override
public String getWorkspaceName() {
return workspaceName;
}
@Override
public int width() {
return width;
}
@Override
public long rowCount() {
return 0;
}
@Override
public boolean isEmpty() {
return true;
}
@Override
public void nextRow() {
throw new NoSuchElementException();
}
@Override
public CachedNode getNode() {
throw new NoSuchElementException();
}
@Override
public CachedNode getNode( int index ) {
throw new NoSuchElementException();
}
@Override
public float getScore() {
throw new NoSuchElementException();
}
@Override
public float getScore( int index ) {
throw new NoSuchElementException();
}
@Override
public String toString() {
return "(empty-batch width=" + width() + ")";
}
};
} | [
"public",
"static",
"Batch",
"emptyBatch",
"(",
"final",
"String",
"workspaceName",
",",
"final",
"int",
"width",
")",
"{",
"assert",
"width",
">",
"0",
";",
"return",
"new",
"Batch",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"hasNext",
"(",
"... | Get a batch of nodes that is empty.
@param workspaceName the name of the workspace
@param width the width of the batch; must be positive
@return the empty node batch; never null | [
"Get",
"a",
"batch",
"of",
"nodes",
"that",
"is",
"empty",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/NodeSequence.java#L225-L284 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/NodeSequence.java | NodeSequence.withBatch | public static NodeSequence withBatch( final Batch sequence ) {
if (sequence == null) return emptySequence(1);
return new NodeSequence() {
private boolean done = false;
@Override
public int width() {
return sequence.width();
}
@Override
public long getRowCount() {
return sequence.rowCount();
}
@Override
public boolean isEmpty() {
return sequence.isEmpty();
}
@Override
public Batch nextBatch() {
if (done) return null;
done = true;
return sequence;
}
@Override
public void close() {
}
@Override
public String toString() {
return "(sequence-with-batch width=" + width() + " " + sequence + " )";
}
};
} | java | public static NodeSequence withBatch( final Batch sequence ) {
if (sequence == null) return emptySequence(1);
return new NodeSequence() {
private boolean done = false;
@Override
public int width() {
return sequence.width();
}
@Override
public long getRowCount() {
return sequence.rowCount();
}
@Override
public boolean isEmpty() {
return sequence.isEmpty();
}
@Override
public Batch nextBatch() {
if (done) return null;
done = true;
return sequence;
}
@Override
public void close() {
}
@Override
public String toString() {
return "(sequence-with-batch width=" + width() + " " + sequence + " )";
}
};
} | [
"public",
"static",
"NodeSequence",
"withBatch",
"(",
"final",
"Batch",
"sequence",
")",
"{",
"if",
"(",
"sequence",
"==",
"null",
")",
"return",
"emptySequence",
"(",
"1",
")",
";",
"return",
"new",
"NodeSequence",
"(",
")",
"{",
"private",
"boolean",
"do... | Create a sequence of nodes that returns the supplied single batch of nodes.
@param sequence the node keys to be returned; if null, an {@link #emptySequence empty instance} is returned
@return the sequence of nodes; never null | [
"Create",
"a",
"sequence",
"of",
"nodes",
"that",
"returns",
"the",
"supplied",
"single",
"batch",
"of",
"nodes",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/NodeSequence.java#L292-L328 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/NodeSequence.java | NodeSequence.limit | public static NodeSequence limit( NodeSequence sequence,
Limit limitAndOffset ) {
if (sequence == null) return emptySequence(0);
if (limitAndOffset != null && !limitAndOffset.isUnlimited()) {
final int limit = limitAndOffset.getRowLimit();
// Perform the skip first ...
if (limitAndOffset.isOffset()) {
sequence = skip(sequence, limitAndOffset.getOffset());
}
// And then the offset ...
if (limit != Integer.MAX_VALUE) {
sequence = limit(sequence, limit);
}
}
return sequence;
} | java | public static NodeSequence limit( NodeSequence sequence,
Limit limitAndOffset ) {
if (sequence == null) return emptySequence(0);
if (limitAndOffset != null && !limitAndOffset.isUnlimited()) {
final int limit = limitAndOffset.getRowLimit();
// Perform the skip first ...
if (limitAndOffset.isOffset()) {
sequence = skip(sequence, limitAndOffset.getOffset());
}
// And then the offset ...
if (limit != Integer.MAX_VALUE) {
sequence = limit(sequence, limit);
}
}
return sequence;
} | [
"public",
"static",
"NodeSequence",
"limit",
"(",
"NodeSequence",
"sequence",
",",
"Limit",
"limitAndOffset",
")",
"{",
"if",
"(",
"sequence",
"==",
"null",
")",
"return",
"emptySequence",
"(",
"0",
")",
";",
"if",
"(",
"limitAndOffset",
"!=",
"null",
"&&",
... | Create a sequence of nodes that skips a specified number of nodes before returning any nodes and that limits the number of
nodes returned.
@param sequence the original sequence that is to be limited; may be null
@param limitAndOffset the specification of the offset and limit; if null this method simply returns <code>sequence</code>
@return the limitd sequence of nodes; never null | [
"Create",
"a",
"sequence",
"of",
"nodes",
"that",
"skips",
"a",
"specified",
"number",
"of",
"nodes",
"before",
"returning",
"any",
"nodes",
"and",
"that",
"limits",
"the",
"number",
"of",
"nodes",
"returned",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/NodeSequence.java#L619-L634 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/NodeSequence.java | NodeSequence.limit | public static NodeSequence limit( final NodeSequence sequence,
final long maxRows ) {
if (sequence == null) return emptySequence(0);
if (maxRows <= 0) return emptySequence(sequence.width());
if (sequence.isEmpty()) return sequence;
return new NodeSequence() {
private LimitBatch lastLimitBatch = null;
protected long rowsRemaining = maxRows;
@Override
public long getRowCount() {
long count = sequence.getRowCount();
if (count < 0L) return -1;
return count < maxRows ? count : maxRows;
}
@Override
public int width() {
return sequence.width();
}
@Override
public boolean isEmpty() {
return false;
}
@Override
public Batch nextBatch() {
if (rowsRemaining <= 0) return null;
if (lastLimitBatch != null) {
long rowsUsed = lastLimitBatch.rowsUsed();
if (rowsUsed < rowsRemaining) {
rowsRemaining -= rowsUsed;
} else {
return null;
}
}
final Batch next = sequence.nextBatch();
if (next == null) return null;
long size = next.rowCount();
boolean sizeKnown = false;
if (size >= 0) {
// The size is known ...
sizeKnown = true;
if (size <= rowsRemaining) {
// The whole batch can be returned ...
rowsRemaining -= size;
return next;
}
// Only the first part of this batch is okay ...
assert size > rowsRemaining;
// just continue ...
}
// The size is not known or larger than rowsRemaining, so we return a batch that exposes only the number we need
long limit = rowsRemaining;
lastLimitBatch = new LimitBatch(next, limit, sizeKnown);
return lastLimitBatch;
}
@Override
public void close() {
sequence.close();
}
@Override
public String toString() {
return "(limit " + maxRows + " " + sequence + " )";
}
};
} | java | public static NodeSequence limit( final NodeSequence sequence,
final long maxRows ) {
if (sequence == null) return emptySequence(0);
if (maxRows <= 0) return emptySequence(sequence.width());
if (sequence.isEmpty()) return sequence;
return new NodeSequence() {
private LimitBatch lastLimitBatch = null;
protected long rowsRemaining = maxRows;
@Override
public long getRowCount() {
long count = sequence.getRowCount();
if (count < 0L) return -1;
return count < maxRows ? count : maxRows;
}
@Override
public int width() {
return sequence.width();
}
@Override
public boolean isEmpty() {
return false;
}
@Override
public Batch nextBatch() {
if (rowsRemaining <= 0) return null;
if (lastLimitBatch != null) {
long rowsUsed = lastLimitBatch.rowsUsed();
if (rowsUsed < rowsRemaining) {
rowsRemaining -= rowsUsed;
} else {
return null;
}
}
final Batch next = sequence.nextBatch();
if (next == null) return null;
long size = next.rowCount();
boolean sizeKnown = false;
if (size >= 0) {
// The size is known ...
sizeKnown = true;
if (size <= rowsRemaining) {
// The whole batch can be returned ...
rowsRemaining -= size;
return next;
}
// Only the first part of this batch is okay ...
assert size > rowsRemaining;
// just continue ...
}
// The size is not known or larger than rowsRemaining, so we return a batch that exposes only the number we need
long limit = rowsRemaining;
lastLimitBatch = new LimitBatch(next, limit, sizeKnown);
return lastLimitBatch;
}
@Override
public void close() {
sequence.close();
}
@Override
public String toString() {
return "(limit " + maxRows + " " + sequence + " )";
}
};
} | [
"public",
"static",
"NodeSequence",
"limit",
"(",
"final",
"NodeSequence",
"sequence",
",",
"final",
"long",
"maxRows",
")",
"{",
"if",
"(",
"sequence",
"==",
"null",
")",
"return",
"emptySequence",
"(",
"0",
")",
";",
"if",
"(",
"maxRows",
"<=",
"0",
")... | Create a sequence of nodes that returns at most the supplied number of rows.
@param sequence the original sequence that is to be limited; may be null
@param maxRows the maximum number of rows that are to be returned by the sequence; should be positive or this method simply
returns <code>sequence</code>
@return the sequence of 'maxRows' nodes; never null | [
"Create",
"a",
"sequence",
"of",
"nodes",
"that",
"returns",
"at",
"most",
"the",
"supplied",
"number",
"of",
"rows",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/NodeSequence.java#L644-L713 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/NodeSequence.java | NodeSequence.skip | public static NodeSequence skip( final NodeSequence sequence,
final int skip ) {
if (sequence == null) return emptySequence(0);
if (skip <= 0 || sequence.isEmpty()) return sequence;
return new NodeSequence() {
private int rowsToSkip = skip;
@Override
public long getRowCount() {
long count = sequence.getRowCount();
if (count < skip) return -1;
return count == skip ? 0 : count - skip;
}
@Override
public int width() {
return sequence.width();
}
@Override
public boolean isEmpty() {
return false;
}
@Override
public Batch nextBatch() {
Batch next = sequence.nextBatch();
while (next != null) {
if (rowsToSkip <= 0) return next;
long size = next.rowCount();
if (size >= 0) {
// The size of this batch is known ...
if (size == 0) {
// but it is empty, so just skip this batch altogether ...
next = sequence.nextBatch();
continue;
}
if (size <= rowsToSkip) {
// The entire batch is smaller than the number of rows we're skipping, so skip the whole batch ...
rowsToSkip -= size;
next = sequence.nextBatch();
continue;
}
// Otherwise, we have to skip the first `rowsToSkip` rows in the batch ...
for (int i = 0; i != rowsToSkip; ++i) {
if (!next.hasNext()) return null;
next.nextRow();
--size;
}
rowsToSkip = 0;
return new AlternateSizeBatch(next, size);
}
// Otherwise the size of the batch is not known, so we need to skip the rows individually ...
while (rowsToSkip > 0 && next.hasNext()) {
next.nextRow();
--rowsToSkip;
}
if (next.hasNext()) return next;
// Otherwise, we've used up all of this batch so just continue to the next ...
next = sequence.nextBatch();
}
return next;
}
@Override
public void close() {
sequence.close();
}
@Override
public String toString() {
return "(skip " + skip + " " + sequence + " )";
}
};
} | java | public static NodeSequence skip( final NodeSequence sequence,
final int skip ) {
if (sequence == null) return emptySequence(0);
if (skip <= 0 || sequence.isEmpty()) return sequence;
return new NodeSequence() {
private int rowsToSkip = skip;
@Override
public long getRowCount() {
long count = sequence.getRowCount();
if (count < skip) return -1;
return count == skip ? 0 : count - skip;
}
@Override
public int width() {
return sequence.width();
}
@Override
public boolean isEmpty() {
return false;
}
@Override
public Batch nextBatch() {
Batch next = sequence.nextBatch();
while (next != null) {
if (rowsToSkip <= 0) return next;
long size = next.rowCount();
if (size >= 0) {
// The size of this batch is known ...
if (size == 0) {
// but it is empty, so just skip this batch altogether ...
next = sequence.nextBatch();
continue;
}
if (size <= rowsToSkip) {
// The entire batch is smaller than the number of rows we're skipping, so skip the whole batch ...
rowsToSkip -= size;
next = sequence.nextBatch();
continue;
}
// Otherwise, we have to skip the first `rowsToSkip` rows in the batch ...
for (int i = 0; i != rowsToSkip; ++i) {
if (!next.hasNext()) return null;
next.nextRow();
--size;
}
rowsToSkip = 0;
return new AlternateSizeBatch(next, size);
}
// Otherwise the size of the batch is not known, so we need to skip the rows individually ...
while (rowsToSkip > 0 && next.hasNext()) {
next.nextRow();
--rowsToSkip;
}
if (next.hasNext()) return next;
// Otherwise, we've used up all of this batch so just continue to the next ...
next = sequence.nextBatch();
}
return next;
}
@Override
public void close() {
sequence.close();
}
@Override
public String toString() {
return "(skip " + skip + " " + sequence + " )";
}
};
} | [
"public",
"static",
"NodeSequence",
"skip",
"(",
"final",
"NodeSequence",
"sequence",
",",
"final",
"int",
"skip",
")",
"{",
"if",
"(",
"sequence",
"==",
"null",
")",
"return",
"emptySequence",
"(",
"0",
")",
";",
"if",
"(",
"skip",
"<=",
"0",
"||",
"s... | Create a sequence of nodes that skips a specified number of rows before returning any rows.
@param sequence the original sequence that is to be limited; may be null
@param skip the number of initial rows that should be skipped; should be positive or this method simply returns
<code>sequence</code>
@return the sequence of nodes after the first <code>skip</code> nodes are skipped; never null | [
"Create",
"a",
"sequence",
"of",
"nodes",
"that",
"skips",
"a",
"specified",
"number",
"of",
"rows",
"before",
"returning",
"any",
"rows",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/NodeSequence.java#L723-L797 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/NodeSequence.java | NodeSequence.filter | public static NodeSequence filter( final NodeSequence sequence,
final RowFilter filter ) {
if (sequence == null) return emptySequence(0);
if (filter == null || sequence.isEmpty()) return sequence;
return new NodeSequence() {
@Override
public long getRowCount() {
// we don't know how the filter affects the row count ...
return -1;
}
@Override
public int width() {
return sequence.width();
}
@Override
public boolean isEmpty() {
// not known to be empty, so always return false ...
return false;
}
@Override
public Batch nextBatch() {
Batch next = sequence.nextBatch();
return batchFilteredWith(next, filter);
}
@Override
public void close() {
sequence.close();
}
@Override
public String toString() {
return "(filtered width=" + width() + " " + filter + " " + sequence + ")";
}
};
} | java | public static NodeSequence filter( final NodeSequence sequence,
final RowFilter filter ) {
if (sequence == null) return emptySequence(0);
if (filter == null || sequence.isEmpty()) return sequence;
return new NodeSequence() {
@Override
public long getRowCount() {
// we don't know how the filter affects the row count ...
return -1;
}
@Override
public int width() {
return sequence.width();
}
@Override
public boolean isEmpty() {
// not known to be empty, so always return false ...
return false;
}
@Override
public Batch nextBatch() {
Batch next = sequence.nextBatch();
return batchFilteredWith(next, filter);
}
@Override
public void close() {
sequence.close();
}
@Override
public String toString() {
return "(filtered width=" + width() + " " + filter + " " + sequence + ")";
}
};
} | [
"public",
"static",
"NodeSequence",
"filter",
"(",
"final",
"NodeSequence",
"sequence",
",",
"final",
"RowFilter",
"filter",
")",
"{",
"if",
"(",
"sequence",
"==",
"null",
")",
"return",
"emptySequence",
"(",
"0",
")",
";",
"if",
"(",
"filter",
"==",
"null... | Create a sequence of nodes that all satisfy the supplied filter.
@param sequence the original sequence that is to be limited; may be null
@param filter the filter to apply to the nodes; if null this method simply returns <code>sequence</code>
@return the sequence of filtered nodes; never null | [
"Create",
"a",
"sequence",
"of",
"nodes",
"that",
"all",
"satisfy",
"the",
"supplied",
"filter",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/NodeSequence.java#L947-L986 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/NodeSequence.java | NodeSequence.append | public static NodeSequence append( final NodeSequence first,
final NodeSequence second ) {
if (first == null) {
return second != null ? second : emptySequence(0);
}
if (second == null) return first;
int firstWidth = first.width();
final int secondWidth = second.width();
if (firstWidth > 0 && secondWidth > 0 && firstWidth != secondWidth) {
throw new IllegalArgumentException("The sequences must have the same width: " + first + " and " + second);
}
if (first.isEmpty()) return second;
if (second.isEmpty()) return first;
long firstCount = first.getRowCount();
long secondCount = second.getRowCount();
final long count = firstCount < 0 ? -1 : (secondCount < 0 ? -1 : firstCount + secondCount);
return new NodeSequence() {
private NodeSequence current = first;
@Override
public int width() {
return secondWidth;
}
@Override
public long getRowCount() {
return count;
}
@Override
public boolean isEmpty() {
return false;
}
@Override
public Batch nextBatch() {
Batch batch = current.nextBatch();
while (batch == null && current == first) {
current = second;
batch = current.nextBatch();
}
return batch;
}
@Override
public void close() {
try {
first.close();
} finally {
second.close();
}
}
@Override
public String toString() {
return "(append width=" + width() + " " + first + "," + second + " )";
}
};
} | java | public static NodeSequence append( final NodeSequence first,
final NodeSequence second ) {
if (first == null) {
return second != null ? second : emptySequence(0);
}
if (second == null) return first;
int firstWidth = first.width();
final int secondWidth = second.width();
if (firstWidth > 0 && secondWidth > 0 && firstWidth != secondWidth) {
throw new IllegalArgumentException("The sequences must have the same width: " + first + " and " + second);
}
if (first.isEmpty()) return second;
if (second.isEmpty()) return first;
long firstCount = first.getRowCount();
long secondCount = second.getRowCount();
final long count = firstCount < 0 ? -1 : (secondCount < 0 ? -1 : firstCount + secondCount);
return new NodeSequence() {
private NodeSequence current = first;
@Override
public int width() {
return secondWidth;
}
@Override
public long getRowCount() {
return count;
}
@Override
public boolean isEmpty() {
return false;
}
@Override
public Batch nextBatch() {
Batch batch = current.nextBatch();
while (batch == null && current == first) {
current = second;
batch = current.nextBatch();
}
return batch;
}
@Override
public void close() {
try {
first.close();
} finally {
second.close();
}
}
@Override
public String toString() {
return "(append width=" + width() + " " + first + "," + second + " )";
}
};
} | [
"public",
"static",
"NodeSequence",
"append",
"(",
"final",
"NodeSequence",
"first",
",",
"final",
"NodeSequence",
"second",
")",
"{",
"if",
"(",
"first",
"==",
"null",
")",
"{",
"return",
"second",
"!=",
"null",
"?",
"second",
":",
"emptySequence",
"(",
"... | Create a sequence of nodes that contains the nodes from the first sequence followed by the second sequence.
@param first the first sequence; may be null
@param second the second sequence; may be null
@return the new combined sequence; never null
@throws IllegalArgumentException if the sequences have different widths | [
"Create",
"a",
"sequence",
"of",
"nodes",
"that",
"contains",
"the",
"nodes",
"from",
"the",
"first",
"sequence",
"followed",
"by",
"the",
"second",
"sequence",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/NodeSequence.java#L996-L1054 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/NodeSequence.java | NodeSequence.slice | public static NodeSequence slice( final NodeSequence original,
Columns columns ) {
final int newWidth = columns.getSelectorNames().size();
if (original.width() == newWidth) {
return original;
}
// We need to return a NodeSequence that includes only the specified selectors.
// Step 1: figure out which selector indexes we'll use ...
final int[] selectorIndexes = new int[newWidth];
int i = 0;
for (String selectorName : columns.getSelectorNames()) {
selectorIndexes[i++] = columns.getSelectorIndex(selectorName);
}
// Step 2: create a NodeSequence that delegates to the original but that returns Batch instances that
// return the desired indexes ...
return new NodeSequence() {
@Override
public int width() {
return 1;
}
@Override
public long getRowCount() {
return original.getRowCount();
}
@Override
public boolean isEmpty() {
return original.isEmpty();
}
@Override
public Batch nextBatch() {
return slicingBatch(original.nextBatch(), selectorIndexes);
}
@Override
public void close() {
original.close();
}
@Override
public String toString() {
return "(slice width=" + newWidth + " indexes=" + selectorIndexes + " " + original + " )";
}
};
} | java | public static NodeSequence slice( final NodeSequence original,
Columns columns ) {
final int newWidth = columns.getSelectorNames().size();
if (original.width() == newWidth) {
return original;
}
// We need to return a NodeSequence that includes only the specified selectors.
// Step 1: figure out which selector indexes we'll use ...
final int[] selectorIndexes = new int[newWidth];
int i = 0;
for (String selectorName : columns.getSelectorNames()) {
selectorIndexes[i++] = columns.getSelectorIndex(selectorName);
}
// Step 2: create a NodeSequence that delegates to the original but that returns Batch instances that
// return the desired indexes ...
return new NodeSequence() {
@Override
public int width() {
return 1;
}
@Override
public long getRowCount() {
return original.getRowCount();
}
@Override
public boolean isEmpty() {
return original.isEmpty();
}
@Override
public Batch nextBatch() {
return slicingBatch(original.nextBatch(), selectorIndexes);
}
@Override
public void close() {
original.close();
}
@Override
public String toString() {
return "(slice width=" + newWidth + " indexes=" + selectorIndexes + " " + original + " )";
}
};
} | [
"public",
"static",
"NodeSequence",
"slice",
"(",
"final",
"NodeSequence",
"original",
",",
"Columns",
"columns",
")",
"{",
"final",
"int",
"newWidth",
"=",
"columns",
".",
"getSelectorNames",
"(",
")",
".",
"size",
"(",
")",
";",
"if",
"(",
"original",
".... | Create a sequence of nodes that include only those selectors defined by the given columns.
@param original the original node sequence that might have more selectors than specified by the columns
@param columns the columns defining the selectors that are to be exposed
@return the node sequence; never null but possibly the original if it has exactly the selectors described by the columns | [
"Create",
"a",
"sequence",
"of",
"nodes",
"that",
"include",
"only",
"those",
"selectors",
"defined",
"by",
"the",
"given",
"columns",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/NodeSequence.java#L1063-L1111 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/NodeSequence.java | NodeSequence.merging | public static NodeSequence merging( final NodeSequence first,
final NodeSequence second,
final int totalWidth ) {
if (first == null) {
if (second == null) return emptySequence(totalWidth);
final int firstWidth = totalWidth - second.width();
return new NodeSequence() {
@Override
public int width() {
return totalWidth;
}
@Override
public long getRowCount() {
return second.getRowCount();
}
@Override
public boolean isEmpty() {
return second.isEmpty();
}
@Override
public Batch nextBatch() {
return batchOf(null, second.nextBatch(), firstWidth, second.width());
}
@Override
public void close() {
second.close();
}
@Override
public String toString() {
return "(merge width=" + width() + " (null-sequence)," + second + " )";
}
};
}
if (second == null) {
final int secondWidth = totalWidth - first.width();
return new NodeSequence() {
@Override
public int width() {
return totalWidth;
}
@Override
public long getRowCount() {
return first.getRowCount();
}
@Override
public boolean isEmpty() {
return first.isEmpty();
}
@Override
public Batch nextBatch() {
return batchOf(first.nextBatch(), null, first.width(), secondWidth);
}
@Override
public void close() {
first.close();
}
@Override
public String toString() {
return "(merge width=" + width() + " " + first + ",(null-sequence) )";
}
};
}
final int firstWidth = first.width();
final int secondWidth = second.width();
final long rowCount = Math.max(-1, first.getRowCount() + second.getRowCount());
return new NodeSequence() {
@Override
public int width() {
return totalWidth;
}
@Override
public long getRowCount() {
return rowCount;
}
@Override
public boolean isEmpty() {
return rowCount == 0;
}
@Override
public Batch nextBatch() {
Batch nextA = first.nextBatch();
Batch nextB = second.nextBatch();
if (nextA == null) {
if (nextB == null) return null;
return batchOf(null, nextB, firstWidth, secondWidth);
}
return batchOf(nextA, nextB, firstWidth, secondWidth);
}
@Override
public void close() {
// always do both ...
try {
first.close();
} finally {
second.close();
}
}
@Override
public String toString() {
return "(merge width=" + width() + " " + first + "," + second + " )";
}
};
} | java | public static NodeSequence merging( final NodeSequence first,
final NodeSequence second,
final int totalWidth ) {
if (first == null) {
if (second == null) return emptySequence(totalWidth);
final int firstWidth = totalWidth - second.width();
return new NodeSequence() {
@Override
public int width() {
return totalWidth;
}
@Override
public long getRowCount() {
return second.getRowCount();
}
@Override
public boolean isEmpty() {
return second.isEmpty();
}
@Override
public Batch nextBatch() {
return batchOf(null, second.nextBatch(), firstWidth, second.width());
}
@Override
public void close() {
second.close();
}
@Override
public String toString() {
return "(merge width=" + width() + " (null-sequence)," + second + " )";
}
};
}
if (second == null) {
final int secondWidth = totalWidth - first.width();
return new NodeSequence() {
@Override
public int width() {
return totalWidth;
}
@Override
public long getRowCount() {
return first.getRowCount();
}
@Override
public boolean isEmpty() {
return first.isEmpty();
}
@Override
public Batch nextBatch() {
return batchOf(first.nextBatch(), null, first.width(), secondWidth);
}
@Override
public void close() {
first.close();
}
@Override
public String toString() {
return "(merge width=" + width() + " " + first + ",(null-sequence) )";
}
};
}
final int firstWidth = first.width();
final int secondWidth = second.width();
final long rowCount = Math.max(-1, first.getRowCount() + second.getRowCount());
return new NodeSequence() {
@Override
public int width() {
return totalWidth;
}
@Override
public long getRowCount() {
return rowCount;
}
@Override
public boolean isEmpty() {
return rowCount == 0;
}
@Override
public Batch nextBatch() {
Batch nextA = first.nextBatch();
Batch nextB = second.nextBatch();
if (nextA == null) {
if (nextB == null) return null;
return batchOf(null, nextB, firstWidth, secondWidth);
}
return batchOf(nextA, nextB, firstWidth, secondWidth);
}
@Override
public void close() {
// always do both ...
try {
first.close();
} finally {
second.close();
}
}
@Override
public String toString() {
return "(merge width=" + width() + " " + first + "," + second + " )";
}
};
} | [
"public",
"static",
"NodeSequence",
"merging",
"(",
"final",
"NodeSequence",
"first",
",",
"final",
"NodeSequence",
"second",
",",
"final",
"int",
"totalWidth",
")",
"{",
"if",
"(",
"first",
"==",
"null",
")",
"{",
"if",
"(",
"second",
"==",
"null",
")",
... | Create a sequence of nodes that merges the two supplied sequences.
@param first the first sequence; may be null
@param second the second sequence; may be null
@param totalWidth the total width of the sequences; should be equal to <code>first.getWidth() + second.getWidth()</code>
@return the new merged sequence; never null | [
"Create",
"a",
"sequence",
"of",
"nodes",
"that",
"merges",
"the",
"two",
"supplied",
"sequences",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/NodeSequence.java#L1184-L1301 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/spi/index/provider/IndexProvider.java | IndexProvider.initialize | public synchronized final void initialize() throws RepositoryException {
if (!initialized) {
try {
doInitialize();
initialized = true;
} catch (RuntimeException e) {
throw new RepositoryException(e);
}
}
} | java | public synchronized final void initialize() throws RepositoryException {
if (!initialized) {
try {
doInitialize();
initialized = true;
} catch (RuntimeException e) {
throw new RepositoryException(e);
}
}
} | [
"public",
"synchronized",
"final",
"void",
"initialize",
"(",
")",
"throws",
"RepositoryException",
"{",
"if",
"(",
"!",
"initialized",
")",
"{",
"try",
"{",
"doInitialize",
"(",
")",
";",
"initialized",
"=",
"true",
";",
"}",
"catch",
"(",
"RuntimeException... | Initialize the provider. This is called automatically by ModeShape once for each provider instance, and should not be
called by the provider itself.
@throws RepositoryException if there is a problem initializing the provider | [
"Initialize",
"the",
"provider",
".",
"This",
"is",
"called",
"automatically",
"by",
"ModeShape",
"once",
"for",
"each",
"provider",
"instance",
"and",
"should",
"not",
"be",
"called",
"by",
"the",
"provider",
"itself",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/spi/index/provider/IndexProvider.java#L301-L310 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/spi/index/provider/IndexProvider.java | IndexProvider.shutdown | public synchronized final void shutdown() throws RepositoryException {
preShutdown();
delegateWriter = NoOpQueryIndexWriter.INSTANCE;
try {
// Shutdown each of the provided indexes ...
for (Map<String, AtomicIndex> byWorkspaceName : providedIndexesByWorkspaceNameByIndexName.values()) {
for (AtomicIndex provided : byWorkspaceName.values()) {
provided.shutdown(false);
}
}
} finally {
providedIndexesByWorkspaceNameByIndexName.clear();
providedIndexesByIndexNameByWorkspaceName.clear();
postShutdown();
}
} | java | public synchronized final void shutdown() throws RepositoryException {
preShutdown();
delegateWriter = NoOpQueryIndexWriter.INSTANCE;
try {
// Shutdown each of the provided indexes ...
for (Map<String, AtomicIndex> byWorkspaceName : providedIndexesByWorkspaceNameByIndexName.values()) {
for (AtomicIndex provided : byWorkspaceName.values()) {
provided.shutdown(false);
}
}
} finally {
providedIndexesByWorkspaceNameByIndexName.clear();
providedIndexesByIndexNameByWorkspaceName.clear();
postShutdown();
}
} | [
"public",
"synchronized",
"final",
"void",
"shutdown",
"(",
")",
"throws",
"RepositoryException",
"{",
"preShutdown",
"(",
")",
";",
"delegateWriter",
"=",
"NoOpQueryIndexWriter",
".",
"INSTANCE",
";",
"try",
"{",
"// Shutdown each of the provided indexes ...",
"for",
... | Signal this provider that it is no longer needed and can release any resources that are being held.
@throws RepositoryException if there is a problem shutting down the provider | [
"Signal",
"this",
"provider",
"that",
"it",
"is",
"no",
"longer",
"needed",
"and",
"can",
"release",
"any",
"resources",
"that",
"are",
"being",
"held",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/spi/index/provider/IndexProvider.java#L348-L364 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/spi/index/provider/IndexProvider.java | IndexProvider.validateDefaultColumnTypes | public void validateDefaultColumnTypes( ExecutionContext context,
IndexDefinition defn,
Problems problems ) {
assert defn != null;
for (int i = 0; i < defn.size(); i++) {
validateDefaultColumnDefinitionType(context, defn, defn.getColumnDefinition(i), problems);
}
} | java | public void validateDefaultColumnTypes( ExecutionContext context,
IndexDefinition defn,
Problems problems ) {
assert defn != null;
for (int i = 0; i < defn.size(); i++) {
validateDefaultColumnDefinitionType(context, defn, defn.getColumnDefinition(i), problems);
}
} | [
"public",
"void",
"validateDefaultColumnTypes",
"(",
"ExecutionContext",
"context",
",",
"IndexDefinition",
"defn",
",",
"Problems",
"problems",
")",
"{",
"assert",
"defn",
"!=",
"null",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"defn",
".",
"s... | Validates that if certain default columns are present in the index definition, they have a required type.
@param context the execution context in which to perform the validation; never null
@param defn the proposed index definition; never null
@param problems the component to record any problems, errors, or warnings; may not be null | [
"Validates",
"that",
"if",
"certain",
"default",
"columns",
"are",
"present",
"in",
"the",
"index",
"definition",
"they",
"have",
"a",
"required",
"type",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/spi/index/provider/IndexProvider.java#L434-L441 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/spi/index/provider/IndexProvider.java | IndexProvider.getIndex | public final Index getIndex( String indexName,
String workspaceName ) {
logger().trace("Looking for index '{0}' in '{1}' provider for query in workspace '{2}'", indexName, getName(),
workspaceName);
Map<String, AtomicIndex> byWorkspaceNames = providedIndexesByWorkspaceNameByIndexName.get(indexName);
return byWorkspaceNames == null ? null : byWorkspaceNames.get(workspaceName);
} | java | public final Index getIndex( String indexName,
String workspaceName ) {
logger().trace("Looking for index '{0}' in '{1}' provider for query in workspace '{2}'", indexName, getName(),
workspaceName);
Map<String, AtomicIndex> byWorkspaceNames = providedIndexesByWorkspaceNameByIndexName.get(indexName);
return byWorkspaceNames == null ? null : byWorkspaceNames.get(workspaceName);
} | [
"public",
"final",
"Index",
"getIndex",
"(",
"String",
"indexName",
",",
"String",
"workspaceName",
")",
"{",
"logger",
"(",
")",
".",
"trace",
"(",
"\"Looking for index '{0}' in '{1}' provider for query in workspace '{2}'\"",
",",
"indexName",
",",
"getName",
"(",
")... | Get the queryable index with the given name and applicable for the given workspace.
@param indexName the name of the index in this provider; never null
@param workspaceName the name of the workspace; never null
@return the queryable index, or null if there is no such index | [
"Get",
"the",
"queryable",
"index",
"with",
"the",
"given",
"name",
"and",
"applicable",
"for",
"the",
"given",
"workspace",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/spi/index/provider/IndexProvider.java#L525-L531 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/spi/index/provider/IndexProvider.java | IndexProvider.getManagedIndex | public final ManagedIndex getManagedIndex( String indexName,
String workspaceName ) {
logger().trace("Looking for managed index '{0}' in '{1}' provider in workspace '{2}'", indexName, getName(),
workspaceName);
Map<String, AtomicIndex> byWorkspaceNames = providedIndexesByWorkspaceNameByIndexName.get(indexName);
if (byWorkspaceNames == null) {
return null;
}
AtomicIndex atomicIndex = byWorkspaceNames.get(workspaceName);
return atomicIndex == null ? null : atomicIndex.managed();
} | java | public final ManagedIndex getManagedIndex( String indexName,
String workspaceName ) {
logger().trace("Looking for managed index '{0}' in '{1}' provider in workspace '{2}'", indexName, getName(),
workspaceName);
Map<String, AtomicIndex> byWorkspaceNames = providedIndexesByWorkspaceNameByIndexName.get(indexName);
if (byWorkspaceNames == null) {
return null;
}
AtomicIndex atomicIndex = byWorkspaceNames.get(workspaceName);
return atomicIndex == null ? null : atomicIndex.managed();
} | [
"public",
"final",
"ManagedIndex",
"getManagedIndex",
"(",
"String",
"indexName",
",",
"String",
"workspaceName",
")",
"{",
"logger",
"(",
")",
".",
"trace",
"(",
"\"Looking for managed index '{0}' in '{1}' provider in workspace '{2}'\"",
",",
"indexName",
",",
"getName",... | Get the managed index with the given name and applicable for the given workspace.
@param indexName the name of the index in this provider; never null
@param workspaceName the name of the workspace; never null
@return the managed index, or null if there is no such index | [
"Get",
"the",
"managed",
"index",
"with",
"the",
"given",
"name",
"and",
"applicable",
"for",
"the",
"given",
"workspace",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/spi/index/provider/IndexProvider.java#L540-L550 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/spi/index/provider/IndexProvider.java | IndexProvider.onEachIndex | private final void onEachIndex( ProvidedIndexOperation op ) {
for (String workspaceName : workspaceNames()) {
Collection<AtomicIndex> indexes = providedIndexesFor(workspaceName);
if (indexes != null) {
for (AtomicIndex atomicIndex : indexes) {
assert atomicIndex.managed() != null;
assert atomicIndex.indexDefinition() != null;
op.apply(workspaceName, atomicIndex);
}
}
}
} | java | private final void onEachIndex( ProvidedIndexOperation op ) {
for (String workspaceName : workspaceNames()) {
Collection<AtomicIndex> indexes = providedIndexesFor(workspaceName);
if (indexes != null) {
for (AtomicIndex atomicIndex : indexes) {
assert atomicIndex.managed() != null;
assert atomicIndex.indexDefinition() != null;
op.apply(workspaceName, atomicIndex);
}
}
}
} | [
"private",
"final",
"void",
"onEachIndex",
"(",
"ProvidedIndexOperation",
"op",
")",
"{",
"for",
"(",
"String",
"workspaceName",
":",
"workspaceNames",
"(",
")",
")",
"{",
"Collection",
"<",
"AtomicIndex",
">",
"indexes",
"=",
"providedIndexesFor",
"(",
"workspa... | Perform the specified operation on each of the managed indexes.
@param op the operation; may not be null | [
"Perform",
"the",
"specified",
"operation",
"on",
"each",
"of",
"the",
"managed",
"indexes",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/spi/index/provider/IndexProvider.java#L597-L608 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/spi/index/provider/IndexProvider.java | IndexProvider.onEachIndexInWorkspace | public final void onEachIndexInWorkspace( String workspaceName,
ManagedIndexOperation op ) {
assert workspaceName != null;
Collection<AtomicIndex> indexes = providedIndexesFor(workspaceName);
if (indexes != null) {
for (AtomicIndex atomicIndex : indexes) {
assert atomicIndex.managed() != null;
assert atomicIndex.indexDefinition() != null;
op.apply(workspaceName, atomicIndex.managed(), atomicIndex.indexDefinition());
}
}
} | java | public final void onEachIndexInWorkspace( String workspaceName,
ManagedIndexOperation op ) {
assert workspaceName != null;
Collection<AtomicIndex> indexes = providedIndexesFor(workspaceName);
if (indexes != null) {
for (AtomicIndex atomicIndex : indexes) {
assert atomicIndex.managed() != null;
assert atomicIndex.indexDefinition() != null;
op.apply(workspaceName, atomicIndex.managed(), atomicIndex.indexDefinition());
}
}
} | [
"public",
"final",
"void",
"onEachIndexInWorkspace",
"(",
"String",
"workspaceName",
",",
"ManagedIndexOperation",
"op",
")",
"{",
"assert",
"workspaceName",
"!=",
"null",
";",
"Collection",
"<",
"AtomicIndex",
">",
"indexes",
"=",
"providedIndexesFor",
"(",
"worksp... | Perform the specified operation on each of the managed indexes in the named workspace.
@param workspaceName the name of the workspace; may not be null
@param op the operation; may not be null | [
"Perform",
"the",
"specified",
"operation",
"on",
"each",
"of",
"the",
"managed",
"indexes",
"in",
"the",
"named",
"workspace",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/spi/index/provider/IndexProvider.java#L628-L639 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/spi/index/provider/IndexProvider.java | IndexProvider.updateIndex | protected ManagedIndex updateIndex( IndexDefinition oldDefn,
IndexDefinition updatedDefn,
ManagedIndex existingIndex,
String workspaceName,
NodeTypes.Supplier nodeTypesSupplier,
NodeTypePredicate matcher,
IndexFeedback feedback ) {
ManagedIndexBuilder builder = getIndexBuilder(updatedDefn, workspaceName, nodeTypesSupplier, matcher);
if (builder == null) {
throw new UnsupportedOperationException("Index providers should either override this method or the #getIndexBuilder method");
}
logger().debug("Index provider '{0}' is updating index in workspace '{1}': {2}", getName(), workspaceName, updatedDefn);
existingIndex.shutdown(true);
ManagedIndex index = builder.build();
if (index.requiresReindexing()) {
scanWorkspace(feedback, updatedDefn, workspaceName, index, nodeTypesSupplier);
}
return index;
} | java | protected ManagedIndex updateIndex( IndexDefinition oldDefn,
IndexDefinition updatedDefn,
ManagedIndex existingIndex,
String workspaceName,
NodeTypes.Supplier nodeTypesSupplier,
NodeTypePredicate matcher,
IndexFeedback feedback ) {
ManagedIndexBuilder builder = getIndexBuilder(updatedDefn, workspaceName, nodeTypesSupplier, matcher);
if (builder == null) {
throw new UnsupportedOperationException("Index providers should either override this method or the #getIndexBuilder method");
}
logger().debug("Index provider '{0}' is updating index in workspace '{1}': {2}", getName(), workspaceName, updatedDefn);
existingIndex.shutdown(true);
ManagedIndex index = builder.build();
if (index.requiresReindexing()) {
scanWorkspace(feedback, updatedDefn, workspaceName, index, nodeTypesSupplier);
}
return index;
} | [
"protected",
"ManagedIndex",
"updateIndex",
"(",
"IndexDefinition",
"oldDefn",
",",
"IndexDefinition",
"updatedDefn",
",",
"ManagedIndex",
"existingIndex",
",",
"String",
"workspaceName",
",",
"NodeTypes",
".",
"Supplier",
"nodeTypesSupplier",
",",
"NodeTypePredicate",
"m... | Method called when this provider needs to update an existing index given the unique pair of workspace name and index
definition. An index definition can apply to multiple workspaces, and when it is changed this method will be called once
for each applicable workspace.
<p>
Providers may either choose to implement this method and therefore have full control over the logic of updating managed indexes
or simply implement the {@link #getIndexBuilder(IndexDefinition, String, NodeTypes.Supplier, NodeTypePredicate)}
method which is the easier route and provides a built-in logic which will first destroy the existing (old) index and then
create and register a new one via the builder.
</p>
@param oldDefn the previous definition of the index; never null
@param updatedDefn the updated definition of the index; never null
@param existingIndex the existing index prior to this update, as returned from {@link #createIndex} or {@link #updateIndex}
; never null
@param workspaceName the name of the actual workspace to which the new index applies; never null
@param nodeTypesSupplier the supplier for the current node types cache; never null
@param matcher the node type matcher used to determine which nodes should be included in the index, and which automatically
updates when node types are changed in the repository; may not be null
@param feedback the feedback mechanism for this provider to signal to ModeShape that portions of the repository content
must be scanned to rebuild/repopulate the updated index; never null
@return the operations and provider-specific state for this index; never null | [
"Method",
"called",
"when",
"this",
"provider",
"needs",
"to",
"update",
"an",
"existing",
"index",
"given",
"the",
"unique",
"pair",
"of",
"workspace",
"name",
"and",
"index",
"definition",
".",
"An",
"index",
"definition",
"can",
"apply",
"to",
"multiple",
... | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/spi/index/provider/IndexProvider.java#L1309-L1327 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/SystemContent.java | SystemContent.readAllNodeTypes | public List<NodeTypeDefinition> readAllNodeTypes() {
CachedNode nodeTypes = nodeTypesNode();
List<NodeTypeDefinition> defns = new ArrayList<NodeTypeDefinition>();
for (ChildReference ref : nodeTypes.getChildReferences(system)) {
CachedNode nodeType = system.getNode(ref);
defns.add(readNodeTypeDefinition(nodeType));
}
return defns;
} | java | public List<NodeTypeDefinition> readAllNodeTypes() {
CachedNode nodeTypes = nodeTypesNode();
List<NodeTypeDefinition> defns = new ArrayList<NodeTypeDefinition>();
for (ChildReference ref : nodeTypes.getChildReferences(system)) {
CachedNode nodeType = system.getNode(ref);
defns.add(readNodeTypeDefinition(nodeType));
}
return defns;
} | [
"public",
"List",
"<",
"NodeTypeDefinition",
">",
"readAllNodeTypes",
"(",
")",
"{",
"CachedNode",
"nodeTypes",
"=",
"nodeTypesNode",
"(",
")",
";",
"List",
"<",
"NodeTypeDefinition",
">",
"defns",
"=",
"new",
"ArrayList",
"<",
"NodeTypeDefinition",
">",
"(",
... | Read from system storage all of the node type definitions.
@return the node types as read from the system storage | [
"Read",
"from",
"system",
"storage",
"all",
"of",
"the",
"node",
"type",
"definitions",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/SystemContent.java#L788-L796 | train |
ModeShape/modeshape | modeshape-common/src/main/java/org/modeshape/common/text/Position.java | Position.add | public Position add( Position position ) {
if (this.getIndexInContent() < 0) {
return position.getIndexInContent() < 0 ? EMPTY_CONTENT_POSITION : position;
}
if (position.getIndexInContent() < 0) {
return this;
}
int index = this.getIndexInContent() + position.getIndexInContent();
int line = position.getLine() + this.getLine() - 1;
int column = this.getLine() == 1 ? this.getColumn() + position.getColumn() : this.getColumn();
return new Position(index, line, column);
} | java | public Position add( Position position ) {
if (this.getIndexInContent() < 0) {
return position.getIndexInContent() < 0 ? EMPTY_CONTENT_POSITION : position;
}
if (position.getIndexInContent() < 0) {
return this;
}
int index = this.getIndexInContent() + position.getIndexInContent();
int line = position.getLine() + this.getLine() - 1;
int column = this.getLine() == 1 ? this.getColumn() + position.getColumn() : this.getColumn();
return new Position(index, line, column);
} | [
"public",
"Position",
"add",
"(",
"Position",
"position",
")",
"{",
"if",
"(",
"this",
".",
"getIndexInContent",
"(",
")",
"<",
"0",
")",
"{",
"return",
"position",
".",
"getIndexInContent",
"(",
")",
"<",
"0",
"?",
"EMPTY_CONTENT_POSITION",
":",
"position... | Return a new position that is the addition of this position and that supplied.
@param position the position to add to this object; may not be null
@return the combined position | [
"Return",
"a",
"new",
"position",
"that",
"is",
"the",
"addition",
"of",
"this",
"position",
"and",
"that",
"supplied",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/text/Position.java#L92-L106 | train |
ModeShape/modeshape | connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/ObjectId.java | ObjectId.valueOf | public static ObjectId valueOf( String uuid ) {
int p = uuid.indexOf("/");
if (p < 0) {
return new ObjectId(Type.OBJECT, uuid);
}
int p1 = p;
while (p > 0) {
p1 = p;
p = uuid.indexOf("/", p + 1);
}
p = p1;
String ident = uuid.substring(0, p);
String type = uuid.substring(p + 1);
return new ObjectId(Type.valueOf(type.toUpperCase()), ident);
} | java | public static ObjectId valueOf( String uuid ) {
int p = uuid.indexOf("/");
if (p < 0) {
return new ObjectId(Type.OBJECT, uuid);
}
int p1 = p;
while (p > 0) {
p1 = p;
p = uuid.indexOf("/", p + 1);
}
p = p1;
String ident = uuid.substring(0, p);
String type = uuid.substring(p + 1);
return new ObjectId(Type.valueOf(type.toUpperCase()), ident);
} | [
"public",
"static",
"ObjectId",
"valueOf",
"(",
"String",
"uuid",
")",
"{",
"int",
"p",
"=",
"uuid",
".",
"indexOf",
"(",
"\"/\"",
")",
";",
"if",
"(",
"p",
"<",
"0",
")",
"{",
"return",
"new",
"ObjectId",
"(",
"Type",
".",
"OBJECT",
",",
"uuid",
... | Constructs instance of this class from its textual representation.
@param uuid the textual representation of this object.
@return object instance. | [
"Constructs",
"instance",
"of",
"this",
"class",
"from",
"its",
"textual",
"representation",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/connectors/modeshape-connector-cmis/src/main/java/org/modeshape/connector/cmis/ObjectId.java#L77-L94 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryConfiguration.java | RepositoryConfiguration.replaceSystemPropertyVariables | protected static Document replaceSystemPropertyVariables( Document doc ) {
if (doc.isEmpty()) return doc;
Document modified = doc.withVariablesReplacedWithSystemProperties();
if (modified == doc) return doc;
// Otherwise, we changed some values. Note that the system properties can only be used in
// string values, whereas the schema may expect non-string values. Therefore, we need to validate
// the document against the schema and possibly perform some conversions of values ...
return SCHEMA_LIBRARY.convertValues(modified, JSON_SCHEMA_URI);
} | java | protected static Document replaceSystemPropertyVariables( Document doc ) {
if (doc.isEmpty()) return doc;
Document modified = doc.withVariablesReplacedWithSystemProperties();
if (modified == doc) return doc;
// Otherwise, we changed some values. Note that the system properties can only be used in
// string values, whereas the schema may expect non-string values. Therefore, we need to validate
// the document against the schema and possibly perform some conversions of values ...
return SCHEMA_LIBRARY.convertValues(modified, JSON_SCHEMA_URI);
} | [
"protected",
"static",
"Document",
"replaceSystemPropertyVariables",
"(",
"Document",
"doc",
")",
"{",
"if",
"(",
"doc",
".",
"isEmpty",
"(",
")",
")",
"return",
"doc",
";",
"Document",
"modified",
"=",
"doc",
".",
"withVariablesReplacedWithSystemProperties",
"(",... | Utility method to replace all system property variables found within the specified document.
@param doc the document; may not be null
@return the modified document if system property variables were found, or the <code>doc</code> instance if no such
variables were found | [
"Utility",
"method",
"to",
"replace",
"all",
"system",
"property",
"variables",
"found",
"within",
"the",
"specified",
"document",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryConfiguration.java#L753-L762 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryConfiguration.java | RepositoryConfiguration.read | public static RepositoryConfiguration read( String resourcePathOrJsonContentString )
throws ParsingException, FileNotFoundException {
CheckArg.isNotNull(resourcePathOrJsonContentString, "resourcePathOrJsonContentString");
InputStream stream = ResourceLookup.read(resourcePathOrJsonContentString, RepositoryConfiguration.class, true);
if (stream != null) {
Document doc = Json.read(stream);
return new RepositoryConfiguration(doc, withoutExtension(resourcePathOrJsonContentString));
}
// Try a file ...
File file = new File(resourcePathOrJsonContentString);
if (file.exists() && file.isFile()) {
return read(file);
}
String content = resourcePathOrJsonContentString.trim();
if (content.startsWith("{")) {
// Try to parse the document ...
Document doc = Json.read(content);
return new RepositoryConfiguration(doc, null);
}
throw new FileNotFoundException(resourcePathOrJsonContentString);
} | java | public static RepositoryConfiguration read( String resourcePathOrJsonContentString )
throws ParsingException, FileNotFoundException {
CheckArg.isNotNull(resourcePathOrJsonContentString, "resourcePathOrJsonContentString");
InputStream stream = ResourceLookup.read(resourcePathOrJsonContentString, RepositoryConfiguration.class, true);
if (stream != null) {
Document doc = Json.read(stream);
return new RepositoryConfiguration(doc, withoutExtension(resourcePathOrJsonContentString));
}
// Try a file ...
File file = new File(resourcePathOrJsonContentString);
if (file.exists() && file.isFile()) {
return read(file);
}
String content = resourcePathOrJsonContentString.trim();
if (content.startsWith("{")) {
// Try to parse the document ...
Document doc = Json.read(content);
return new RepositoryConfiguration(doc, null);
}
throw new FileNotFoundException(resourcePathOrJsonContentString);
} | [
"public",
"static",
"RepositoryConfiguration",
"read",
"(",
"String",
"resourcePathOrJsonContentString",
")",
"throws",
"ParsingException",
",",
"FileNotFoundException",
"{",
"CheckArg",
".",
"isNotNull",
"(",
"resourcePathOrJsonContentString",
",",
"\"resourcePathOrJsonContent... | Read the repository configuration given by the supplied path to a file on the file system, the path a classpath resource
file, or a string containg the actual JSON content.
@param resourcePathOrJsonContentString the path to a file on the file system, the path to a classpath resource file or the
JSON content string; may not be null
@return the parsed repository configuration; never null
@throws ParsingException if the content could not be parsed as a valid JSON document
@throws FileNotFoundException if the file could not be found | [
"Read",
"the",
"repository",
"configuration",
"given",
"by",
"the",
"supplied",
"path",
"to",
"a",
"file",
"on",
"the",
"file",
"system",
"the",
"path",
"a",
"classpath",
"resource",
"file",
"or",
"a",
"string",
"containg",
"the",
"actual",
"JSON",
"content"... | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryConfiguration.java#L818-L839 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryConfiguration.java | RepositoryConfiguration.getNodeTypes | public List<String> getNodeTypes() {
List<String> result = new ArrayList<String>();
List<?> configuredNodeTypes = doc.getArray(FieldName.NODE_TYPES);
if (configuredNodeTypes != null) {
for (Object configuredNodeType : configuredNodeTypes) {
result.add(configuredNodeType.toString());
}
}
return result;
} | java | public List<String> getNodeTypes() {
List<String> result = new ArrayList<String>();
List<?> configuredNodeTypes = doc.getArray(FieldName.NODE_TYPES);
if (configuredNodeTypes != null) {
for (Object configuredNodeType : configuredNodeTypes) {
result.add(configuredNodeType.toString());
}
}
return result;
} | [
"public",
"List",
"<",
"String",
">",
"getNodeTypes",
"(",
")",
"{",
"List",
"<",
"String",
">",
"result",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"List",
"<",
"?",
">",
"configuredNodeTypes",
"=",
"doc",
".",
"getArray",
"(",
"Fi... | Returns a list with the cnd files which should be loaded at startup.
@return a {@code non-null} string list | [
"Returns",
"a",
"list",
"with",
"the",
"cnd",
"files",
"which",
"should",
"be",
"loaded",
"at",
"startup",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryConfiguration.java#L997-L1008 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryConfiguration.java | RepositoryConfiguration.getDefaultWorkspaceName | public String getDefaultWorkspaceName() {
Document workspaces = doc.getDocument(FieldName.WORKSPACES);
if (workspaces != null) {
return workspaces.getString(FieldName.DEFAULT, Default.DEFAULT);
}
return Default.DEFAULT;
} | java | public String getDefaultWorkspaceName() {
Document workspaces = doc.getDocument(FieldName.WORKSPACES);
if (workspaces != null) {
return workspaces.getString(FieldName.DEFAULT, Default.DEFAULT);
}
return Default.DEFAULT;
} | [
"public",
"String",
"getDefaultWorkspaceName",
"(",
")",
"{",
"Document",
"workspaces",
"=",
"doc",
".",
"getDocument",
"(",
"FieldName",
".",
"WORKSPACES",
")",
";",
"if",
"(",
"workspaces",
"!=",
"null",
")",
"{",
"return",
"workspaces",
".",
"getString",
... | Get the name of the workspace that should be used for sessions where the client does not specify the name of the workspace.
@return the default workspace name; never null | [
"Get",
"the",
"name",
"of",
"the",
"workspace",
"that",
"should",
"be",
"used",
"for",
"sessions",
"where",
"the",
"client",
"does",
"not",
"specify",
"the",
"name",
"of",
"the",
"workspace",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryConfiguration.java#L1299-L1305 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryConfiguration.java | RepositoryConfiguration.getIndexProviders | public List<Component> getIndexProviders() {
Problems problems = new SimpleProblems();
List<Component> components = readComponents(doc, FieldName.INDEX_PROVIDERS, FieldName.CLASSNAME, INDEX_PROVIDER_ALIASES,
problems);
assert !problems.hasErrors();
return components;
} | java | public List<Component> getIndexProviders() {
Problems problems = new SimpleProblems();
List<Component> components = readComponents(doc, FieldName.INDEX_PROVIDERS, FieldName.CLASSNAME, INDEX_PROVIDER_ALIASES,
problems);
assert !problems.hasErrors();
return components;
} | [
"public",
"List",
"<",
"Component",
">",
"getIndexProviders",
"(",
")",
"{",
"Problems",
"problems",
"=",
"new",
"SimpleProblems",
"(",
")",
";",
"List",
"<",
"Component",
">",
"components",
"=",
"readComponents",
"(",
"doc",
",",
"FieldName",
".",
"INDEX_PR... | Get the ordered list of index providers defined in the configuration.
@return the immutable list of provider components; never null but possibly empty | [
"Get",
"the",
"ordered",
"list",
"of",
"index",
"providers",
"defined",
"in",
"the",
"configuration",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryConfiguration.java#L1539-L1545 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryConfiguration.java | RepositoryConfiguration.getDocumentOptimization | public DocumentOptimization getDocumentOptimization() {
Document storage = doc.getDocument(FieldName.STORAGE);
if (storage == null) {
storage = Schematic.newDocument();
}
return new DocumentOptimization(storage.getDocument(FieldName.DOCUMENT_OPTIMIZATION));
} | java | public DocumentOptimization getDocumentOptimization() {
Document storage = doc.getDocument(FieldName.STORAGE);
if (storage == null) {
storage = Schematic.newDocument();
}
return new DocumentOptimization(storage.getDocument(FieldName.DOCUMENT_OPTIMIZATION));
} | [
"public",
"DocumentOptimization",
"getDocumentOptimization",
"(",
")",
"{",
"Document",
"storage",
"=",
"doc",
".",
"getDocument",
"(",
"FieldName",
".",
"STORAGE",
")",
";",
"if",
"(",
"storage",
"==",
"null",
")",
"{",
"storage",
"=",
"Schematic",
".",
"ne... | Get the configuration for the document optimization for this repository.
@return the document optimization configuration; never null | [
"Get",
"the",
"configuration",
"for",
"the",
"document",
"optimization",
"for",
"this",
"repository",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryConfiguration.java#L1940-L1946 | train |
ModeShape/modeshape | modeshape-schematic/src/main/java/org/modeshape/schematic/internal/io/BsonDataOutput.java | BsonDataOutput.writeTo | public void writeTo( WritableByteChannel channel ) throws IOException {
int numberOfBytesToWrite = size;
for (ByteBuffer buffer : buffers) {
if (buffer == null) {
// already flushed
continue;
}
int numBytesInBuffer = Math.min(numberOfBytesToWrite, bufferSize);
buffer.position(numBytesInBuffer);
buffer.flip();
channel.write(buffer);
numberOfBytesToWrite -= numBytesInBuffer;
}
buffers.clear();
} | java | public void writeTo( WritableByteChannel channel ) throws IOException {
int numberOfBytesToWrite = size;
for (ByteBuffer buffer : buffers) {
if (buffer == null) {
// already flushed
continue;
}
int numBytesInBuffer = Math.min(numberOfBytesToWrite, bufferSize);
buffer.position(numBytesInBuffer);
buffer.flip();
channel.write(buffer);
numberOfBytesToWrite -= numBytesInBuffer;
}
buffers.clear();
} | [
"public",
"void",
"writeTo",
"(",
"WritableByteChannel",
"channel",
")",
"throws",
"IOException",
"{",
"int",
"numberOfBytesToWrite",
"=",
"size",
";",
"for",
"(",
"ByteBuffer",
"buffer",
":",
"buffers",
")",
"{",
"if",
"(",
"buffer",
"==",
"null",
")",
"{",... | Write all content to the supplied channel.
@param channel the channel to which the content is to be written.
@throws IOException if there is a problem writing to the supplied stream | [
"Write",
"all",
"content",
"to",
"the",
"supplied",
"channel",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-schematic/src/main/java/org/modeshape/schematic/internal/io/BsonDataOutput.java#L441-L455 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/Upgrades.java | Upgrades.applyUpgradesSince | public final int applyUpgradesSince( int lastId,
Context resources ) {
int lastUpgradeId = lastId;
for (UpgradeOperation op : operations) {
if (op.getId() <= lastId) continue;
LOGGER.debug("Upgrade {0}: starting", op);
op.apply(resources);
LOGGER.debug("Upgrade {0}: complete", op);
lastUpgradeId = op.getId();
}
return lastUpgradeId;
} | java | public final int applyUpgradesSince( int lastId,
Context resources ) {
int lastUpgradeId = lastId;
for (UpgradeOperation op : operations) {
if (op.getId() <= lastId) continue;
LOGGER.debug("Upgrade {0}: starting", op);
op.apply(resources);
LOGGER.debug("Upgrade {0}: complete", op);
lastUpgradeId = op.getId();
}
return lastUpgradeId;
} | [
"public",
"final",
"int",
"applyUpgradesSince",
"(",
"int",
"lastId",
",",
"Context",
"resources",
")",
"{",
"int",
"lastUpgradeId",
"=",
"lastId",
";",
"for",
"(",
"UpgradeOperation",
"op",
":",
"operations",
")",
"{",
"if",
"(",
"op",
".",
"getId",
"(",
... | Apply any upgrades that are more recent than identified by the last upgraded identifier.
@param lastId the identifier of the last upgrade that was successfully run against the repository
@param resources the resources for the repository
@return the identifier of the last upgrade applied to the repository; may be the same or greater than {@code lastId} | [
"Apply",
"any",
"upgrades",
"that",
"are",
"more",
"recent",
"than",
"identified",
"by",
"the",
"last",
"upgraded",
"identifier",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/Upgrades.java#L94-L105 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/ExtensionLogger.java | ExtensionLogger.getLogger | public static org.modeshape.jcr.api.Logger getLogger(Class<?> clazz) {
return new ExtensionLogger(Logger.getLogger(clazz));
} | java | public static org.modeshape.jcr.api.Logger getLogger(Class<?> clazz) {
return new ExtensionLogger(Logger.getLogger(clazz));
} | [
"public",
"static",
"org",
".",
"modeshape",
".",
"jcr",
".",
"api",
".",
"Logger",
"getLogger",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"return",
"new",
"ExtensionLogger",
"(",
"Logger",
".",
"getLogger",
"(",
"clazz",
")",
")",
";",
"}"
] | Creates a new logger instance for the underlying class.
@param clazz a {@link Class} instance; never null
@return a {@link org.modeshape.jcr.api.Logger} implementation | [
"Creates",
"a",
"new",
"logger",
"instance",
"for",
"the",
"underlying",
"class",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/ExtensionLogger.java#L43-L45 | train |
ModeShape/modeshape | index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/EsIndex.java | EsIndex.createIndex | private void createIndex() {
try {
client.createIndex(name(), workspace, columns.mappings(workspace));
client.flush(name());
} catch (IOException e) {
throw new EsIndexException(e);
}
} | java | private void createIndex() {
try {
client.createIndex(name(), workspace, columns.mappings(workspace));
client.flush(name());
} catch (IOException e) {
throw new EsIndexException(e);
}
} | [
"private",
"void",
"createIndex",
"(",
")",
"{",
"try",
"{",
"client",
".",
"createIndex",
"(",
"name",
"(",
")",
",",
"workspace",
",",
"columns",
".",
"mappings",
"(",
"workspace",
")",
")",
";",
"client",
".",
"flush",
"(",
"name",
"(",
")",
")",
... | Executes create index action. | [
"Executes",
"create",
"index",
"action",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/EsIndex.java#L91-L98 | train |
ModeShape/modeshape | index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/EsIndex.java | EsIndex.find | private EsRequest find(String nodeKey) throws IOException {
return client.getDocument(name(), workspace, nodeKey);
} | java | private EsRequest find(String nodeKey) throws IOException {
return client.getDocument(name(), workspace, nodeKey);
} | [
"private",
"EsRequest",
"find",
"(",
"String",
"nodeKey",
")",
"throws",
"IOException",
"{",
"return",
"client",
".",
"getDocument",
"(",
"name",
"(",
")",
",",
"workspace",
",",
"nodeKey",
")",
";",
"}"
] | Searches indexed node's properties by node key.
@param nodeKey node key being indexed.
@return list of stored properties as json document.
@throws IOException | [
"Searches",
"indexed",
"node",
"s",
"properties",
"by",
"node",
"key",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/EsIndex.java#L184-L186 | train |
ModeShape/modeshape | index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/EsIndex.java | EsIndex.findOrCreateDoc | private EsRequest findOrCreateDoc(String nodeKey) throws IOException {
EsRequest doc = client.getDocument(name(), workspace, nodeKey);
return doc != null ? doc : new EsRequest();
} | java | private EsRequest findOrCreateDoc(String nodeKey) throws IOException {
EsRequest doc = client.getDocument(name(), workspace, nodeKey);
return doc != null ? doc : new EsRequest();
} | [
"private",
"EsRequest",
"findOrCreateDoc",
"(",
"String",
"nodeKey",
")",
"throws",
"IOException",
"{",
"EsRequest",
"doc",
"=",
"client",
".",
"getDocument",
"(",
"name",
"(",
")",
",",
"workspace",
",",
"nodeKey",
")",
";",
"return",
"doc",
"!=",
"null",
... | Searches indexed node's properties by node key or creates new empty list.
@param nodeKey node key being indexed.
@return list of stored properties as json document or empty document
if not found.
@throws IOException | [
"Searches",
"indexed",
"node",
"s",
"properties",
"by",
"node",
"key",
"or",
"creates",
"new",
"empty",
"list",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/EsIndex.java#L196-L199 | train |
ModeShape/modeshape | index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/EsIndex.java | EsIndex.putValue | private void putValue(EsRequest doc, EsIndexColumn column, Object value) {
Object columnValue = column.columnValue(value);
String stringValue = column.stringValue(value);
doc.put(column.getName(), columnValue);
if (!(value instanceof ModeShapeDateTime || value instanceof Long || value instanceof Boolean)) {
doc.put(column.getLowerCaseFieldName(), stringValue.toLowerCase());
doc.put(column.getUpperCaseFieldName(), stringValue.toUpperCase());
}
doc.put(column.getLengthFieldName(), stringValue.length());
} | java | private void putValue(EsRequest doc, EsIndexColumn column, Object value) {
Object columnValue = column.columnValue(value);
String stringValue = column.stringValue(value);
doc.put(column.getName(), columnValue);
if (!(value instanceof ModeShapeDateTime || value instanceof Long || value instanceof Boolean)) {
doc.put(column.getLowerCaseFieldName(), stringValue.toLowerCase());
doc.put(column.getUpperCaseFieldName(), stringValue.toUpperCase());
}
doc.put(column.getLengthFieldName(), stringValue.length());
} | [
"private",
"void",
"putValue",
"(",
"EsRequest",
"doc",
",",
"EsIndexColumn",
"column",
",",
"Object",
"value",
")",
"{",
"Object",
"columnValue",
"=",
"column",
".",
"columnValue",
"(",
"value",
")",
";",
"String",
"stringValue",
"=",
"column",
".",
"string... | Appends specified value for the given column and related pseudo columns
into list of properties.
@param doc list of properties in json format
@param column colum definition
@param value column's value. | [
"Appends",
"specified",
"value",
"for",
"the",
"given",
"column",
"and",
"related",
"pseudo",
"columns",
"into",
"list",
"of",
"properties",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/EsIndex.java#L209-L218 | train |
ModeShape/modeshape | index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/EsIndex.java | EsIndex.putValues | private void putValues(EsRequest doc, EsIndexColumn column, Object[] value) {
Object[] columnValue = column.columnValues(value);
int[] ln = new int[columnValue.length];
String[] lc = new String[columnValue.length];
String[] uc = new String[columnValue.length];
for (int i = 0; i < columnValue.length; i++) {
String stringValue = column.stringValue(columnValue[i]);
lc[i] = stringValue.toLowerCase();
uc[i] = stringValue.toUpperCase();
ln[i] = stringValue.length();
}
doc.put(column.getName(), columnValue);
doc.put(column.getLowerCaseFieldName(), lc);
doc.put(column.getUpperCaseFieldName(), uc);
doc.put(column.getLengthFieldName(), ln);
} | java | private void putValues(EsRequest doc, EsIndexColumn column, Object[] value) {
Object[] columnValue = column.columnValues(value);
int[] ln = new int[columnValue.length];
String[] lc = new String[columnValue.length];
String[] uc = new String[columnValue.length];
for (int i = 0; i < columnValue.length; i++) {
String stringValue = column.stringValue(columnValue[i]);
lc[i] = stringValue.toLowerCase();
uc[i] = stringValue.toUpperCase();
ln[i] = stringValue.length();
}
doc.put(column.getName(), columnValue);
doc.put(column.getLowerCaseFieldName(), lc);
doc.put(column.getUpperCaseFieldName(), uc);
doc.put(column.getLengthFieldName(), ln);
} | [
"private",
"void",
"putValues",
"(",
"EsRequest",
"doc",
",",
"EsIndexColumn",
"column",
",",
"Object",
"[",
"]",
"value",
")",
"{",
"Object",
"[",
"]",
"columnValue",
"=",
"column",
".",
"columnValues",
"(",
"value",
")",
";",
"int",
"[",
"]",
"ln",
"... | Appends specified values for the given column and related pseudo columns
into list of properties.
@param doc list of properties in json format
@param column colum definition
@param value column's value. | [
"Appends",
"specified",
"values",
"for",
"the",
"given",
"column",
"and",
"related",
"pseudo",
"columns",
"into",
"list",
"of",
"properties",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/EsIndex.java#L228-L245 | train |
ModeShape/modeshape | checkstyle/src/main/java/org/modeshape/checkstyle/UnusedImports.java | UnusedImports.processIdent | protected void processIdent( DetailAST aAST ) {
final int parentType = aAST.getParent().getType();
if (((parentType != TokenTypes.DOT) && (parentType != TokenTypes.METHOD_DEF))
|| ((parentType == TokenTypes.DOT) && (aAST.getNextSibling() != null))) {
referenced.add(aAST.getText());
}
} | java | protected void processIdent( DetailAST aAST ) {
final int parentType = aAST.getParent().getType();
if (((parentType != TokenTypes.DOT) && (parentType != TokenTypes.METHOD_DEF))
|| ((parentType == TokenTypes.DOT) && (aAST.getNextSibling() != null))) {
referenced.add(aAST.getText());
}
} | [
"protected",
"void",
"processIdent",
"(",
"DetailAST",
"aAST",
")",
"{",
"final",
"int",
"parentType",
"=",
"aAST",
".",
"getParent",
"(",
")",
".",
"getType",
"(",
")",
";",
"if",
"(",
"(",
"(",
"parentType",
"!=",
"TokenTypes",
".",
"DOT",
")",
"&&",... | Collects references made by IDENT.
@param aAST the IDENT node to process {@link ArrayList stuff} | [
"Collects",
"references",
"made",
"by",
"IDENT",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/checkstyle/src/main/java/org/modeshape/checkstyle/UnusedImports.java#L131-L137 | train |
ModeShape/modeshape | checkstyle/src/main/java/org/modeshape/checkstyle/UnusedImports.java | UnusedImports.processImport | private void processImport( DetailAST aAST ) {
final FullIdent name = FullIdent.createFullIdentBelow(aAST);
if ((name != null) && !name.getText().endsWith(".*")) {
imports.add(name);
}
} | java | private void processImport( DetailAST aAST ) {
final FullIdent name = FullIdent.createFullIdentBelow(aAST);
if ((name != null) && !name.getText().endsWith(".*")) {
imports.add(name);
}
} | [
"private",
"void",
"processImport",
"(",
"DetailAST",
"aAST",
")",
"{",
"final",
"FullIdent",
"name",
"=",
"FullIdent",
".",
"createFullIdentBelow",
"(",
"aAST",
")",
";",
"if",
"(",
"(",
"name",
"!=",
"null",
")",
"&&",
"!",
"name",
".",
"getText",
"(",... | Collects the details of imports.
@param aAST node containing the import details | [
"Collects",
"the",
"details",
"of",
"imports",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/checkstyle/src/main/java/org/modeshape/checkstyle/UnusedImports.java#L225-L230 | train |
ModeShape/modeshape | checkstyle/src/main/java/org/modeshape/checkstyle/UnusedImports.java | UnusedImports.processStaticImport | private void processStaticImport( DetailAST aAST ) {
final FullIdent name = FullIdent.createFullIdent(aAST.getFirstChild().getNextSibling());
if ((name != null) && !name.getText().endsWith(".*")) {
imports.add(name);
}
} | java | private void processStaticImport( DetailAST aAST ) {
final FullIdent name = FullIdent.createFullIdent(aAST.getFirstChild().getNextSibling());
if ((name != null) && !name.getText().endsWith(".*")) {
imports.add(name);
}
} | [
"private",
"void",
"processStaticImport",
"(",
"DetailAST",
"aAST",
")",
"{",
"final",
"FullIdent",
"name",
"=",
"FullIdent",
".",
"createFullIdent",
"(",
"aAST",
".",
"getFirstChild",
"(",
")",
".",
"getNextSibling",
"(",
")",
")",
";",
"if",
"(",
"(",
"n... | Collects the details of static imports.
@param aAST node containing the static import details | [
"Collects",
"the",
"details",
"of",
"static",
"imports",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/checkstyle/src/main/java/org/modeshape/checkstyle/UnusedImports.java#L237-L242 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/security/acl/Privileges.java | Privileges.forName | public PrivilegeImpl forName(String name) {
if (name.contains("}")) {
String localName = name.substring(name.indexOf('}') + 1);
return privileges.get(localName);
}
if (name.contains(":")) {
String localName = name.substring(name.indexOf(':') + 1);
PrivilegeImpl p = privileges.get(localName);
return p.getName().equals(name) ? p : null;
}
return null;
} | java | public PrivilegeImpl forName(String name) {
if (name.contains("}")) {
String localName = name.substring(name.indexOf('}') + 1);
return privileges.get(localName);
}
if (name.contains(":")) {
String localName = name.substring(name.indexOf(':') + 1);
PrivilegeImpl p = privileges.get(localName);
return p.getName().equals(name) ? p : null;
}
return null;
} | [
"public",
"PrivilegeImpl",
"forName",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"name",
".",
"contains",
"(",
"\"}\"",
")",
")",
"{",
"String",
"localName",
"=",
"name",
".",
"substring",
"(",
"name",
".",
"indexOf",
"(",
"'",
"'",
")",
"+",
"1",
... | Searches privilege object for the privilege with the given name.
@param name the name of privilege to find.
@return the privilege object or null if not found. | [
"Searches",
"privilege",
"object",
"for",
"the",
"privilege",
"with",
"the",
"given",
"name",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/security/acl/Privileges.java#L174-L187 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/cache/change/RecordingChanges.java | RecordingChanges.setChangedNodes | public void setChangedNodes( Set<NodeKey> keys ) {
if (keys != null) {
this.nodeKeys = Collections.unmodifiableSet(new HashSet<NodeKey>(keys));
}
} | java | public void setChangedNodes( Set<NodeKey> keys ) {
if (keys != null) {
this.nodeKeys = Collections.unmodifiableSet(new HashSet<NodeKey>(keys));
}
} | [
"public",
"void",
"setChangedNodes",
"(",
"Set",
"<",
"NodeKey",
">",
"keys",
")",
"{",
"if",
"(",
"keys",
"!=",
"null",
")",
"{",
"this",
".",
"nodeKeys",
"=",
"Collections",
".",
"unmodifiableSet",
"(",
"new",
"HashSet",
"<",
"NodeKey",
">",
"(",
"ke... | Sets the list of node keys involved in this change set.
@param keys a Set<NodeKey>; may not be null | [
"Sets",
"the",
"list",
"of",
"node",
"keys",
"involved",
"in",
"this",
"change",
"set",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/cache/change/RecordingChanges.java#L297-L301 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/engine/QueryUtil.java | QueryUtil.hasWildcardCharacters | public static boolean hasWildcardCharacters( String expression ) {
Objects.requireNonNull(expression);
CharacterIterator iter = new StringCharacterIterator(expression);
boolean skipNext = false;
for (char c = iter.first(); c != CharacterIterator.DONE; c = iter.next()) {
if (skipNext) {
skipNext = false;
continue;
}
if (c == '*' || c == '?' || c == '%' || c == '_') return true;
if (c == '\\') skipNext = true;
}
return false;
} | java | public static boolean hasWildcardCharacters( String expression ) {
Objects.requireNonNull(expression);
CharacterIterator iter = new StringCharacterIterator(expression);
boolean skipNext = false;
for (char c = iter.first(); c != CharacterIterator.DONE; c = iter.next()) {
if (skipNext) {
skipNext = false;
continue;
}
if (c == '*' || c == '?' || c == '%' || c == '_') return true;
if (c == '\\') skipNext = true;
}
return false;
} | [
"public",
"static",
"boolean",
"hasWildcardCharacters",
"(",
"String",
"expression",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"expression",
")",
";",
"CharacterIterator",
"iter",
"=",
"new",
"StringCharacterIterator",
"(",
"expression",
")",
";",
"boolean",
... | Checks if the given expression has any wildcard characters
@param expression a {@code String} value, never {@code null}
@return true if the expression has wildcard characters, false otherwise | [
"Checks",
"if",
"the",
"given",
"expression",
"has",
"any",
"wildcard",
"characters"
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/engine/QueryUtil.java#L38-L51 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/engine/QueryUtil.java | QueryUtil.toRegularExpression | public static String toRegularExpression( String likeExpression ) {
// Replace all '\x' with 'x' ...
String result = likeExpression.replaceAll("\\\\(.)", "$1");
// Escape characters used as metacharacters in regular expressions, including
// '[', '^', '\', '$', '.', '|', '+', '(', and ')'
// But leave '?' and '*'
result = result.replaceAll("([$.|+()\\[\\\\^\\\\\\\\])", "\\\\$1");
// Replace '%'->'[.]*' and '_'->'[.]
// (order of these calls is important!)
result = result.replace("*", ".*").replace("?", ".");
result = result.replace("%", ".*").replace("_", ".");
// Replace all wildcards between square bracket literals with digit wildcards ...
result = result.replace("\\[.*]", "\\[\\d+]");
return result;
} | java | public static String toRegularExpression( String likeExpression ) {
// Replace all '\x' with 'x' ...
String result = likeExpression.replaceAll("\\\\(.)", "$1");
// Escape characters used as metacharacters in regular expressions, including
// '[', '^', '\', '$', '.', '|', '+', '(', and ')'
// But leave '?' and '*'
result = result.replaceAll("([$.|+()\\[\\\\^\\\\\\\\])", "\\\\$1");
// Replace '%'->'[.]*' and '_'->'[.]
// (order of these calls is important!)
result = result.replace("*", ".*").replace("?", ".");
result = result.replace("%", ".*").replace("_", ".");
// Replace all wildcards between square bracket literals with digit wildcards ...
result = result.replace("\\[.*]", "\\[\\d+]");
return result;
} | [
"public",
"static",
"String",
"toRegularExpression",
"(",
"String",
"likeExpression",
")",
"{",
"// Replace all '\\x' with 'x' ...",
"String",
"result",
"=",
"likeExpression",
".",
"replaceAll",
"(",
"\"\\\\\\\\(.)\"",
",",
"\"$1\"",
")",
";",
"// Escape characters used a... | Convert the JCR like expression to a regular expression. The JCR like expression uses '%' to match 0 or more characters,
'_' to match any single character, '\x' to match the 'x' character, and all other characters to match themselves. Note that
if any regex metacharacters appear in the like expression, they will be escaped within the resulting regular expression.
@param likeExpression the like expression; may not be null
@return the expression that can be used with a WildcardQuery; never null | [
"Convert",
"the",
"JCR",
"like",
"expression",
"to",
"a",
"regular",
"expression",
".",
"The",
"JCR",
"like",
"expression",
"uses",
"%",
"to",
"match",
"0",
"or",
"more",
"characters",
"_",
"to",
"match",
"any",
"single",
"character",
"\\",
"x",
"to",
"m... | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/engine/QueryUtil.java#L84-L98 | train |
ModeShape/modeshape | modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/AnonymousCredentials.java | AnonymousCredentials.getAttributeNames | public String[] getAttributeNames() {
synchronized (attributes) {
return attributes.keySet().toArray(new String[attributes.keySet().size()]);
}
} | java | public String[] getAttributeNames() {
synchronized (attributes) {
return attributes.keySet().toArray(new String[attributes.keySet().size()]);
}
} | [
"public",
"String",
"[",
"]",
"getAttributeNames",
"(",
")",
"{",
"synchronized",
"(",
"attributes",
")",
"{",
"return",
"attributes",
".",
"keySet",
"(",
")",
".",
"toArray",
"(",
"new",
"String",
"[",
"attributes",
".",
"keySet",
"(",
")",
".",
"size",... | Returns the names of the attributes available to this credentials instance. This method returns an empty array if the
credentials instance has no attributes available to it.
@return a string array containing the names of the stored attributes | [
"Returns",
"the",
"names",
"of",
"the",
"attributes",
"available",
"to",
"this",
"credentials",
"instance",
".",
"This",
"method",
"returns",
"an",
"empty",
"array",
"if",
"the",
"credentials",
"instance",
"has",
"no",
"attributes",
"available",
"to",
"it",
".... | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/AnonymousCredentials.java#L142-L146 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/xpath/XPathToQueryTranslator.java | XPathToQueryTranslator.appliesToPathConstraint | protected boolean appliesToPathConstraint( List<Component> predicates ) {
if (predicates.isEmpty()) return true;
if (predicates.size() > 1) return false;
assert predicates.size() == 1;
Component predicate = predicates.get(0);
if (predicate instanceof Literal && ((Literal)predicate).isInteger()) return true;
if (predicate instanceof NameTest && ((NameTest)predicate).isWildcard()) return true;
return false;
} | java | protected boolean appliesToPathConstraint( List<Component> predicates ) {
if (predicates.isEmpty()) return true;
if (predicates.size() > 1) return false;
assert predicates.size() == 1;
Component predicate = predicates.get(0);
if (predicate instanceof Literal && ((Literal)predicate).isInteger()) return true;
if (predicate instanceof NameTest && ((NameTest)predicate).isWildcard()) return true;
return false;
} | [
"protected",
"boolean",
"appliesToPathConstraint",
"(",
"List",
"<",
"Component",
">",
"predicates",
")",
"{",
"if",
"(",
"predicates",
".",
"isEmpty",
"(",
")",
")",
"return",
"true",
";",
"if",
"(",
"predicates",
".",
"size",
"(",
")",
">",
"1",
")",
... | Determine if the predicates contain any expressions that cannot be put into a LIKE constraint on the path.
@param predicates the predicates
@return true if the supplied predicates can be handled entirely in the LIKE constraint on the path, or false if they have
to be handled as other criteria | [
"Determine",
"if",
"the",
"predicates",
"contain",
"any",
"expressions",
"that",
"cannot",
"be",
"put",
"into",
"a",
"LIKE",
"constraint",
"on",
"the",
"path",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/xpath/XPathToQueryTranslator.java#L725-L733 | train |
ModeShape/modeshape | deploy/jbossas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/service/BinaryStorage.java | BinaryStorage.defaultConfig | static BinaryStorage defaultConfig() {
// By default binaries are not stored on disk
EditableDocument binaries = Schematic.newDocument();
binaries.set(RepositoryConfiguration.FieldName.TYPE, RepositoryConfiguration.FieldValue.BINARY_STORAGE_TYPE_TRANSIENT);
return new BinaryStorage(binaries);
} | java | static BinaryStorage defaultConfig() {
// By default binaries are not stored on disk
EditableDocument binaries = Schematic.newDocument();
binaries.set(RepositoryConfiguration.FieldName.TYPE, RepositoryConfiguration.FieldValue.BINARY_STORAGE_TYPE_TRANSIENT);
return new BinaryStorage(binaries);
} | [
"static",
"BinaryStorage",
"defaultConfig",
"(",
")",
"{",
"// By default binaries are not stored on disk",
"EditableDocument",
"binaries",
"=",
"Schematic",
".",
"newDocument",
"(",
")",
";",
"binaries",
".",
"set",
"(",
"RepositoryConfiguration",
".",
"FieldName",
"."... | Creates a default storage configuration, which will be used whenever no specific binary store is configured.
@return a {@link org.modeshape.jboss.service.BinaryStorage} instance, never {@code null} | [
"Creates",
"a",
"default",
"storage",
"configuration",
"which",
"will",
"be",
"used",
"whenever",
"no",
"specific",
"binary",
"store",
"is",
"configured",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/deploy/jbossas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/service/BinaryStorage.java#L41-L46 | train |
ModeShape/modeshape | modeshape-common/src/main/java/org/modeshape/common/i18n/I18n.java | I18n.localize | private static void localize( final Class<?> i18nClass,
final Locale locale ) {
assert i18nClass != null;
assert locale != null;
// Create a class-to-problem map for this locale if one doesn't exist, else get the existing one.
Map<Class<?>, Set<String>> classToProblemsMap = new ConcurrentHashMap<Class<?>, Set<String>>();
Map<Class<?>, Set<String>> existingClassToProblemsMap = LOCALE_TO_CLASS_TO_PROBLEMS_MAP.putIfAbsent(locale,
classToProblemsMap);
if (existingClassToProblemsMap != null) {
classToProblemsMap = existingClassToProblemsMap;
}
// Check if already localized outside of synchronization block for 99% use-case
if (classToProblemsMap.get(i18nClass) != null) {
return;
}
synchronized (i18nClass) {
// Return if the supplied i18n class has already been localized to the supplied locale, despite the check outside of
// the synchronization block (1% use-case), else create a class-to-problems map for the class.
Set<String> problems = classToProblemsMap.get(i18nClass);
if (problems == null) {
problems = new CopyOnWriteArraySet<String>();
classToProblemsMap.put(i18nClass, problems);
} else {
return;
}
// Get the URL to the localization properties file ...
final String localizationBaseName = i18nClass.getName();
URL bundleUrl = ClasspathLocalizationRepository.getLocalizationBundle(i18nClass.getClassLoader(), localizationBaseName, locale);
if (bundleUrl == null && i18nClass == CommonI18n.class) {
throw new SystemFailureException("CommonI18n.properties file not found in classpath !");
}
if (bundleUrl == null) {
LOGGER.warn(CommonI18n.i18nBundleNotFoundInClasspath,
ClasspathLocalizationRepository.getPathsToSearchForBundle(localizationBaseName, locale));
// Nothing was found, so try the default locale
Locale defaultLocale = Locale.getDefault();
if (!defaultLocale.equals(locale)) {
bundleUrl = ClasspathLocalizationRepository.getLocalizationBundle(i18nClass.getClassLoader(), localizationBaseName, defaultLocale);
}
// Return if no applicable localization file could be found
if (bundleUrl == null) {
LOGGER.error(CommonI18n.i18nBundleNotFoundInClasspath,
ClasspathLocalizationRepository.getPathsToSearchForBundle(localizationBaseName, defaultLocale));
LOGGER.error(CommonI18n.i18nLocalizationFileNotFound, localizationBaseName);
problems.add(CommonI18n.i18nLocalizationFileNotFound.text(localizationBaseName));
return;
}
}
// Initialize i18n map
Properties props = prepareBundleLoading(i18nClass, locale, bundleUrl, problems);
try {
InputStream propStream = bundleUrl.openStream();
try {
props.load(propStream);
// Check for uninitialized fields
for (Field fld : i18nClass.getDeclaredFields()) {
if (fld.getType() == I18n.class) {
try {
I18n i18n = (I18n)fld.get(null);
if (i18n.localeToTextMap.get(locale) == null) {
i18n.localeToProblemMap.put(locale,
CommonI18n.i18nPropertyMissing.text(fld.getName(), bundleUrl));
}
} catch (IllegalAccessException notPossible) {
// Would have already occurred in initialize method, but allowing for the impossible...
problems.add(notPossible.getMessage());
}
}
}
} finally {
propStream.close();
}
} catch (IOException err) {
problems.add(err.getMessage());
}
}
} | java | private static void localize( final Class<?> i18nClass,
final Locale locale ) {
assert i18nClass != null;
assert locale != null;
// Create a class-to-problem map for this locale if one doesn't exist, else get the existing one.
Map<Class<?>, Set<String>> classToProblemsMap = new ConcurrentHashMap<Class<?>, Set<String>>();
Map<Class<?>, Set<String>> existingClassToProblemsMap = LOCALE_TO_CLASS_TO_PROBLEMS_MAP.putIfAbsent(locale,
classToProblemsMap);
if (existingClassToProblemsMap != null) {
classToProblemsMap = existingClassToProblemsMap;
}
// Check if already localized outside of synchronization block for 99% use-case
if (classToProblemsMap.get(i18nClass) != null) {
return;
}
synchronized (i18nClass) {
// Return if the supplied i18n class has already been localized to the supplied locale, despite the check outside of
// the synchronization block (1% use-case), else create a class-to-problems map for the class.
Set<String> problems = classToProblemsMap.get(i18nClass);
if (problems == null) {
problems = new CopyOnWriteArraySet<String>();
classToProblemsMap.put(i18nClass, problems);
} else {
return;
}
// Get the URL to the localization properties file ...
final String localizationBaseName = i18nClass.getName();
URL bundleUrl = ClasspathLocalizationRepository.getLocalizationBundle(i18nClass.getClassLoader(), localizationBaseName, locale);
if (bundleUrl == null && i18nClass == CommonI18n.class) {
throw new SystemFailureException("CommonI18n.properties file not found in classpath !");
}
if (bundleUrl == null) {
LOGGER.warn(CommonI18n.i18nBundleNotFoundInClasspath,
ClasspathLocalizationRepository.getPathsToSearchForBundle(localizationBaseName, locale));
// Nothing was found, so try the default locale
Locale defaultLocale = Locale.getDefault();
if (!defaultLocale.equals(locale)) {
bundleUrl = ClasspathLocalizationRepository.getLocalizationBundle(i18nClass.getClassLoader(), localizationBaseName, defaultLocale);
}
// Return if no applicable localization file could be found
if (bundleUrl == null) {
LOGGER.error(CommonI18n.i18nBundleNotFoundInClasspath,
ClasspathLocalizationRepository.getPathsToSearchForBundle(localizationBaseName, defaultLocale));
LOGGER.error(CommonI18n.i18nLocalizationFileNotFound, localizationBaseName);
problems.add(CommonI18n.i18nLocalizationFileNotFound.text(localizationBaseName));
return;
}
}
// Initialize i18n map
Properties props = prepareBundleLoading(i18nClass, locale, bundleUrl, problems);
try {
InputStream propStream = bundleUrl.openStream();
try {
props.load(propStream);
// Check for uninitialized fields
for (Field fld : i18nClass.getDeclaredFields()) {
if (fld.getType() == I18n.class) {
try {
I18n i18n = (I18n)fld.get(null);
if (i18n.localeToTextMap.get(locale) == null) {
i18n.localeToProblemMap.put(locale,
CommonI18n.i18nPropertyMissing.text(fld.getName(), bundleUrl));
}
} catch (IllegalAccessException notPossible) {
// Would have already occurred in initialize method, but allowing for the impossible...
problems.add(notPossible.getMessage());
}
}
}
} finally {
propStream.close();
}
} catch (IOException err) {
problems.add(err.getMessage());
}
}
} | [
"private",
"static",
"void",
"localize",
"(",
"final",
"Class",
"<",
"?",
">",
"i18nClass",
",",
"final",
"Locale",
"locale",
")",
"{",
"assert",
"i18nClass",
"!=",
"null",
";",
"assert",
"locale",
"!=",
"null",
";",
"// Create a class-to-problem map for this lo... | Synchronized on the supplied internalization class.
@param i18nClass The internalization class being localized
@param locale The locale to which the supplied internationalization class should be localized. | [
"Synchronized",
"on",
"the",
"supplied",
"internalization",
"class",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/i18n/I18n.java#L184-L261 | train |
ModeShape/modeshape | modeshape-common/src/main/java/org/modeshape/common/i18n/I18n.java | I18n.text | @Override
public String text( Locale locale,
Object... arguments ) {
try {
String rawText = rawText(locale == null ? Locale.getDefault() : locale);
return StringUtil.createString(rawText, arguments);
} catch (IllegalArgumentException err) {
throw new IllegalArgumentException(CommonI18n.i18nRequiredToSuppliedParameterMismatch.text(id,
i18nClass,
err.getMessage()));
} catch (SystemFailureException err) {
return '<' + err.getMessage() + '>';
}
} | java | @Override
public String text( Locale locale,
Object... arguments ) {
try {
String rawText = rawText(locale == null ? Locale.getDefault() : locale);
return StringUtil.createString(rawText, arguments);
} catch (IllegalArgumentException err) {
throw new IllegalArgumentException(CommonI18n.i18nRequiredToSuppliedParameterMismatch.text(id,
i18nClass,
err.getMessage()));
} catch (SystemFailureException err) {
return '<' + err.getMessage() + '>';
}
} | [
"@",
"Override",
"public",
"String",
"text",
"(",
"Locale",
"locale",
",",
"Object",
"...",
"arguments",
")",
"{",
"try",
"{",
"String",
"rawText",
"=",
"rawText",
"(",
"locale",
"==",
"null",
"?",
"Locale",
".",
"getDefault",
"(",
")",
":",
"locale",
... | Get the localized text for the supplied locale, replacing the parameters in the text with those supplied.
@param locale the locale, or <code>null</code> if the {@link Locale#getDefault() current (default) locale} should be used
@param arguments the arguments for the parameter replacement; may be <code>null</code> or empty
@return the localized text | [
"Get",
"the",
"localized",
"text",
"for",
"the",
"supplied",
"locale",
"replacing",
"the",
"parameters",
"in",
"the",
"text",
"with",
"those",
"supplied",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/i18n/I18n.java#L407-L420 | train |
ModeShape/modeshape | web/modeshape-webdav/src/main/java/org/modeshape/webdav/methods/AbstractMethod.java | AbstractMethod.getDocumentBuilder | protected DocumentBuilder getDocumentBuilder() throws ServletException {
DocumentBuilder documentBuilder = null;
DocumentBuilderFactory documentBuilderFactory = null;
try {
documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
documentBuilder = documentBuilderFactory.newDocumentBuilder();
} catch (ParserConfigurationException e) {
throw new ServletException("jaxp failed");
}
return documentBuilder;
} | java | protected DocumentBuilder getDocumentBuilder() throws ServletException {
DocumentBuilder documentBuilder = null;
DocumentBuilderFactory documentBuilderFactory = null;
try {
documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
documentBuilder = documentBuilderFactory.newDocumentBuilder();
} catch (ParserConfigurationException e) {
throw new ServletException("jaxp failed");
}
return documentBuilder;
} | [
"protected",
"DocumentBuilder",
"getDocumentBuilder",
"(",
")",
"throws",
"ServletException",
"{",
"DocumentBuilder",
"documentBuilder",
"=",
"null",
";",
"DocumentBuilderFactory",
"documentBuilderFactory",
"=",
"null",
";",
"try",
"{",
"documentBuilderFactory",
"=",
"Doc... | Return JAXP document builder instance.
@return the builder
@throws ServletException | [
"Return",
"JAXP",
"document",
"builder",
"instance",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-webdav/src/main/java/org/modeshape/webdav/methods/AbstractMethod.java#L191-L202 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/spi/index/provider/IndexUsage.java | IndexUsage.indexAppliesTo | public boolean indexAppliesTo( JoinCondition condition ) {
if (condition instanceof ChildNodeJoinCondition) {
return indexAppliesTo((ChildNodeJoinCondition)condition);
}
if (condition instanceof DescendantNodeJoinCondition) {
return indexAppliesTo((DescendantNodeJoinCondition)condition);
}
if (condition instanceof EquiJoinCondition) {
return indexAppliesTo((EquiJoinCondition)condition);
}
if (condition instanceof SameNodeJoinCondition) {
return indexAppliesTo((SameNodeJoinCondition)condition);
}
return false;
} | java | public boolean indexAppliesTo( JoinCondition condition ) {
if (condition instanceof ChildNodeJoinCondition) {
return indexAppliesTo((ChildNodeJoinCondition)condition);
}
if (condition instanceof DescendantNodeJoinCondition) {
return indexAppliesTo((DescendantNodeJoinCondition)condition);
}
if (condition instanceof EquiJoinCondition) {
return indexAppliesTo((EquiJoinCondition)condition);
}
if (condition instanceof SameNodeJoinCondition) {
return indexAppliesTo((SameNodeJoinCondition)condition);
}
return false;
} | [
"public",
"boolean",
"indexAppliesTo",
"(",
"JoinCondition",
"condition",
")",
"{",
"if",
"(",
"condition",
"instanceof",
"ChildNodeJoinCondition",
")",
"{",
"return",
"indexAppliesTo",
"(",
"(",
"ChildNodeJoinCondition",
")",
"condition",
")",
";",
"}",
"if",
"("... | Determine if this index can be used to evaluate the given join condition.
@param condition the condition; may not be null
@return true if it can be used to evaluate the join condition, or false otherwise | [
"Determine",
"if",
"this",
"index",
"can",
"be",
"used",
"to",
"evaluate",
"the",
"given",
"join",
"condition",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/spi/index/provider/IndexUsage.java#L87-L101 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/spi/index/provider/IndexUsage.java | IndexUsage.indexAppliesTo | public boolean indexAppliesTo( Constraint constraint ) {
if (constraint instanceof Comparison) {
return indexAppliesTo((Comparison)constraint);
}
if (constraint instanceof And) {
return indexAppliesTo((And)constraint);
}
if (constraint instanceof Or) {
return indexAppliesTo((Or)constraint);
}
if (constraint instanceof Not) {
return indexAppliesTo((Not)constraint);
}
if (constraint instanceof Between) {
return indexAppliesTo((Between)constraint);
}
if (constraint instanceof SetCriteria) {
return indexAppliesTo((SetCriteria)constraint);
}
if (constraint instanceof Relike) {
return indexAppliesTo((Relike)constraint);
}
if (constraint instanceof PropertyExistence) {
return indexAppliesTo((PropertyExistence)constraint);
}
if (constraint instanceof FullTextSearch) {
return applies((FullTextSearch)constraint);
}
return false;
} | java | public boolean indexAppliesTo( Constraint constraint ) {
if (constraint instanceof Comparison) {
return indexAppliesTo((Comparison)constraint);
}
if (constraint instanceof And) {
return indexAppliesTo((And)constraint);
}
if (constraint instanceof Or) {
return indexAppliesTo((Or)constraint);
}
if (constraint instanceof Not) {
return indexAppliesTo((Not)constraint);
}
if (constraint instanceof Between) {
return indexAppliesTo((Between)constraint);
}
if (constraint instanceof SetCriteria) {
return indexAppliesTo((SetCriteria)constraint);
}
if (constraint instanceof Relike) {
return indexAppliesTo((Relike)constraint);
}
if (constraint instanceof PropertyExistence) {
return indexAppliesTo((PropertyExistence)constraint);
}
if (constraint instanceof FullTextSearch) {
return applies((FullTextSearch)constraint);
}
return false;
} | [
"public",
"boolean",
"indexAppliesTo",
"(",
"Constraint",
"constraint",
")",
"{",
"if",
"(",
"constraint",
"instanceof",
"Comparison",
")",
"{",
"return",
"indexAppliesTo",
"(",
"(",
"Comparison",
")",
"constraint",
")",
";",
"}",
"if",
"(",
"constraint",
"ins... | Determine if this index can be used to evaluate the given constraint.
@param constraint the constraint; may not be null
@return true if it can be used to evaluate the constraint, or false otherwise | [
"Determine",
"if",
"this",
"index",
"can",
"be",
"used",
"to",
"evaluate",
"the",
"given",
"constraint",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/spi/index/provider/IndexUsage.java#L133-L162 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/security/acl/PrivilegeImpl.java | PrivilegeImpl.aggregate | private void aggregate(ArrayList<Privilege> list, Privilege p) {
list.add(p);
if (p.isAggregate()) {
for (Privilege ap : p.getDeclaredAggregatePrivileges()) {
aggregate(list, ap);
}
}
} | java | private void aggregate(ArrayList<Privilege> list, Privilege p) {
list.add(p);
if (p.isAggregate()) {
for (Privilege ap : p.getDeclaredAggregatePrivileges()) {
aggregate(list, ap);
}
}
} | [
"private",
"void",
"aggregate",
"(",
"ArrayList",
"<",
"Privilege",
">",
"list",
",",
"Privilege",
"p",
")",
"{",
"list",
".",
"add",
"(",
"p",
")",
";",
"if",
"(",
"p",
".",
"isAggregate",
"(",
")",
")",
"{",
"for",
"(",
"Privilege",
"ap",
":",
... | Recursively aggregates privileges for the given privilege.
@param list list which holds all aggregate privileges.
@param p the given privilege | [
"Recursively",
"aggregates",
"privileges",
"for",
"the",
"given",
"privilege",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/security/acl/PrivilegeImpl.java#L125-L132 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/security/acl/PrivilegeImpl.java | PrivilegeImpl.contains | public boolean contains(Privilege p) {
if (p.getName().equalsIgnoreCase(this.getName())) {
return true;
}
Privilege[] list = getAggregatePrivileges();
for (Privilege privilege : list) {
if (privilege.getName().equalsIgnoreCase(p.getName())) {
return true;
}
}
return false;
} | java | public boolean contains(Privilege p) {
if (p.getName().equalsIgnoreCase(this.getName())) {
return true;
}
Privilege[] list = getAggregatePrivileges();
for (Privilege privilege : list) {
if (privilege.getName().equalsIgnoreCase(p.getName())) {
return true;
}
}
return false;
} | [
"public",
"boolean",
"contains",
"(",
"Privilege",
"p",
")",
"{",
"if",
"(",
"p",
".",
"getName",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"this",
".",
"getName",
"(",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"Privilege",
"[",
"]",
"list",
"=... | Tests given privilege.
@param p the given privilege.
@return true if this privilege equals or aggregates given privilege. | [
"Tests",
"given",
"privilege",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/security/acl/PrivilegeImpl.java#L141-L154 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/JcrSession.java | JcrSession.save | void save( AbstractJcrNode node ) throws RepositoryException {
// first check the node is valid from a cache perspective
Set<NodeKey> keysToBeSaved = null;
try {
if (node.isNew()) {
// expected by TCK
throw new RepositoryException(JcrI18n.unableToSaveNodeThatWasCreatedSincePreviousSave.text(node.getPath(),
workspaceName()));
}
AtomicReference<Set<NodeKey>> refToKeys = new AtomicReference<Set<NodeKey>>();
if (node.containsChangesWithExternalDependencies(refToKeys)) {
// expected by TCK
I18n msg = JcrI18n.unableToSaveBranchBecauseChangesDependOnChangesToNodesOutsideOfBranch;
throw new ConstraintViolationException(msg.text(node.path(), workspaceName()));
}
keysToBeSaved = refToKeys.get();
} catch (ItemNotFoundException e) {
throw new InvalidItemStateException(e);
} catch (NodeNotFoundException e) {
throw new InvalidItemStateException(e);
}
assert keysToBeSaved != null;
SessionCache sessionCache = cache();
if (sessionCache.getChangedNodeKeys().size() == keysToBeSaved.size()) {
// The node is above all the other changes, so go ahead and save the whole session ...
save();
return;
}
// Perform the save, using 'JcrPreSave' operations ...
SessionCache systemCache = createSystemCache(false);
SystemContent systemContent = new SystemContent(systemCache);
Map<NodeKey, NodeKey> baseVersionKeys = this.baseVersionKeys.get();
Map<NodeKey, NodeKey> originalVersionKeys = this.originalVersionKeys.get();
try {
sessionCache.save(keysToBeSaved, systemContent.cache(), new JcrPreSave(systemContent, baseVersionKeys,
originalVersionKeys, aclChangesCount()));
} catch (WrappedException e) {
Throwable cause = e.getCause();
throw (cause instanceof RepositoryException) ? (RepositoryException)cause : new RepositoryException(e.getCause());
} catch (DocumentNotFoundException e) {
throw new InvalidItemStateException(JcrI18n.nodeModifiedBySessionWasRemovedByAnotherSession.text(e.getKey()), e);
} catch (DocumentAlreadyExistsException e) {
// Try to figure out which node in this transient state was the problem ...
NodeKey key = new NodeKey(e.getKey());
AbstractJcrNode problemNode = node(key, null);
String path = problemNode.getPath();
throw new InvalidItemStateException(JcrI18n.nodeCreatedBySessionUsedExistingKey.text(path, key), e);
} catch (org.modeshape.jcr.cache.ReferentialIntegrityException e) {
throw new ReferentialIntegrityException(e);
} catch (Throwable t) {
throw new RepositoryException(t);
}
try {
// Record the save operation ...
repository().statistics().increment(ValueMetric.SESSION_SAVES);
} catch (IllegalStateException e) {
// The repository has been shutdown ...
}
} | java | void save( AbstractJcrNode node ) throws RepositoryException {
// first check the node is valid from a cache perspective
Set<NodeKey> keysToBeSaved = null;
try {
if (node.isNew()) {
// expected by TCK
throw new RepositoryException(JcrI18n.unableToSaveNodeThatWasCreatedSincePreviousSave.text(node.getPath(),
workspaceName()));
}
AtomicReference<Set<NodeKey>> refToKeys = new AtomicReference<Set<NodeKey>>();
if (node.containsChangesWithExternalDependencies(refToKeys)) {
// expected by TCK
I18n msg = JcrI18n.unableToSaveBranchBecauseChangesDependOnChangesToNodesOutsideOfBranch;
throw new ConstraintViolationException(msg.text(node.path(), workspaceName()));
}
keysToBeSaved = refToKeys.get();
} catch (ItemNotFoundException e) {
throw new InvalidItemStateException(e);
} catch (NodeNotFoundException e) {
throw new InvalidItemStateException(e);
}
assert keysToBeSaved != null;
SessionCache sessionCache = cache();
if (sessionCache.getChangedNodeKeys().size() == keysToBeSaved.size()) {
// The node is above all the other changes, so go ahead and save the whole session ...
save();
return;
}
// Perform the save, using 'JcrPreSave' operations ...
SessionCache systemCache = createSystemCache(false);
SystemContent systemContent = new SystemContent(systemCache);
Map<NodeKey, NodeKey> baseVersionKeys = this.baseVersionKeys.get();
Map<NodeKey, NodeKey> originalVersionKeys = this.originalVersionKeys.get();
try {
sessionCache.save(keysToBeSaved, systemContent.cache(), new JcrPreSave(systemContent, baseVersionKeys,
originalVersionKeys, aclChangesCount()));
} catch (WrappedException e) {
Throwable cause = e.getCause();
throw (cause instanceof RepositoryException) ? (RepositoryException)cause : new RepositoryException(e.getCause());
} catch (DocumentNotFoundException e) {
throw new InvalidItemStateException(JcrI18n.nodeModifiedBySessionWasRemovedByAnotherSession.text(e.getKey()), e);
} catch (DocumentAlreadyExistsException e) {
// Try to figure out which node in this transient state was the problem ...
NodeKey key = new NodeKey(e.getKey());
AbstractJcrNode problemNode = node(key, null);
String path = problemNode.getPath();
throw new InvalidItemStateException(JcrI18n.nodeCreatedBySessionUsedExistingKey.text(path, key), e);
} catch (org.modeshape.jcr.cache.ReferentialIntegrityException e) {
throw new ReferentialIntegrityException(e);
} catch (Throwable t) {
throw new RepositoryException(t);
}
try {
// Record the save operation ...
repository().statistics().increment(ValueMetric.SESSION_SAVES);
} catch (IllegalStateException e) {
// The repository has been shutdown ...
}
} | [
"void",
"save",
"(",
"AbstractJcrNode",
"node",
")",
"throws",
"RepositoryException",
"{",
"// first check the node is valid from a cache perspective",
"Set",
"<",
"NodeKey",
">",
"keysToBeSaved",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"node",
".",
"isNew",
"(",
... | Save a subset of the changes made within this session.
@param node the node at or below which the changes are to be saved; may not be null
@throws RepositoryException if there is a problem saving the changes
@see AbstractJcrNode#save() | [
"Save",
"a",
"subset",
"of",
"the",
"changes",
"made",
"within",
"this",
"session",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/JcrSession.java#L1231-L1293 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/JcrSession.java | JcrSession.hasRole | static boolean hasRole( SecurityContext context,
String roleName,
String repositoryName,
String workspaceName ) {
if (context.hasRole(roleName)) return true;
roleName = roleName + "." + repositoryName;
if (context.hasRole(roleName)) return true;
roleName = roleName + "." + workspaceName;
return context.hasRole(roleName);
} | java | static boolean hasRole( SecurityContext context,
String roleName,
String repositoryName,
String workspaceName ) {
if (context.hasRole(roleName)) return true;
roleName = roleName + "." + repositoryName;
if (context.hasRole(roleName)) return true;
roleName = roleName + "." + workspaceName;
return context.hasRole(roleName);
} | [
"static",
"boolean",
"hasRole",
"(",
"SecurityContext",
"context",
",",
"String",
"roleName",
",",
"String",
"repositoryName",
",",
"String",
"workspaceName",
")",
"{",
"if",
"(",
"context",
".",
"hasRole",
"(",
"roleName",
")",
")",
"return",
"true",
";",
"... | Returns whether the authenticated user has the given role.
@param context the security context
@param roleName the name of the role to check
@param repositoryName the name of the repository
@param workspaceName the workspace under which the user must have the role. This may be different from the current
workspace.
@return true if the user has the role and is logged in; false otherwise | [
"Returns",
"whether",
"the",
"authenticated",
"user",
"has",
"the",
"given",
"role",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/JcrSession.java#L1503-L1512 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/JcrSession.java | JcrSession.isForeignKey | public static boolean isForeignKey( NodeKey key,
NodeKey rootKey ) {
if (key == null) {
return false;
}
String nodeWorkspaceKey = key.getWorkspaceKey();
boolean sameWorkspace = rootKey.getWorkspaceKey().equals(nodeWorkspaceKey);
boolean sameSource = rootKey.getSourceKey().equalsIgnoreCase(key.getSourceKey());
return !sameWorkspace || !sameSource;
} | java | public static boolean isForeignKey( NodeKey key,
NodeKey rootKey ) {
if (key == null) {
return false;
}
String nodeWorkspaceKey = key.getWorkspaceKey();
boolean sameWorkspace = rootKey.getWorkspaceKey().equals(nodeWorkspaceKey);
boolean sameSource = rootKey.getSourceKey().equalsIgnoreCase(key.getSourceKey());
return !sameWorkspace || !sameSource;
} | [
"public",
"static",
"boolean",
"isForeignKey",
"(",
"NodeKey",
"key",
",",
"NodeKey",
"rootKey",
")",
"{",
"if",
"(",
"key",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"String",
"nodeWorkspaceKey",
"=",
"key",
".",
"getWorkspaceKey",
"(",
")",
... | Checks if the node given key is foreign by comparing the source key & workspace key against the same keys from this
session's root. This method is used for reference resolving.
@param key the node key; may be null
@param rootKey the key of the root node in the workspace; may not be null
@return true if the node key is considered foreign, false otherwise. | [
"Checks",
"if",
"the",
"node",
"given",
"key",
"is",
"foreign",
"by",
"comparing",
"the",
"source",
"key",
"&",
"workspace",
"key",
"against",
"the",
"same",
"keys",
"from",
"this",
"session",
"s",
"root",
".",
"This",
"method",
"is",
"used",
"for",
"ref... | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/JcrSession.java#L1982-L1992 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/JcrSession.java | JcrSession.nodeIdentifier | public static String nodeIdentifier( NodeKey key,
NodeKey rootKey ) {
return isForeignKey(key, rootKey) ? key.toString() : key.getIdentifier();
} | java | public static String nodeIdentifier( NodeKey key,
NodeKey rootKey ) {
return isForeignKey(key, rootKey) ? key.toString() : key.getIdentifier();
} | [
"public",
"static",
"String",
"nodeIdentifier",
"(",
"NodeKey",
"key",
",",
"NodeKey",
"rootKey",
")",
"{",
"return",
"isForeignKey",
"(",
"key",
",",
"rootKey",
")",
"?",
"key",
".",
"toString",
"(",
")",
":",
"key",
".",
"getIdentifier",
"(",
")",
";",... | Returns a string representing a node's identifier, based on whether the node is foreign or not.
@param key the node key; may be null
@param rootKey the key of the root node in the workspace; may not be null
@return the identifier for the node; never null
@see javax.jcr.Node#getIdentifier() | [
"Returns",
"a",
"string",
"representing",
"a",
"node",
"s",
"identifier",
"based",
"on",
"whether",
"the",
"node",
"is",
"foreign",
"or",
"not",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/JcrSession.java#L2002-L2005 | train |
ModeShape/modeshape | sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/DdlTokenStream.java | DdlTokenStream.computeNextStatementStartKeywordCount | public int computeNextStatementStartKeywordCount() {
int result = 0;
if (isNextKeyWord()) {
for (String[] nextStmtStart : registeredStatementStartPhrases) {
if (this.matches(nextStmtStart)) {
return nextStmtStart.length;
}
}
}
return result;
} | java | public int computeNextStatementStartKeywordCount() {
int result = 0;
if (isNextKeyWord()) {
for (String[] nextStmtStart : registeredStatementStartPhrases) {
if (this.matches(nextStmtStart)) {
return nextStmtStart.length;
}
}
}
return result;
} | [
"public",
"int",
"computeNextStatementStartKeywordCount",
"(",
")",
"{",
"int",
"result",
"=",
"0",
";",
"if",
"(",
"isNextKeyWord",
"(",
")",
")",
"{",
"for",
"(",
"String",
"[",
"]",
"nextStmtStart",
":",
"registeredStatementStartPhrases",
")",
"{",
"if",
... | Method to determine if next tokens match a registered statement start phrase.
@return number of keywords in matched registered statement start phrase or zero if not matched | [
"Method",
"to",
"determine",
"if",
"next",
"tokens",
"match",
"a",
"registered",
"statement",
"start",
"phrase",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/DdlTokenStream.java#L189-L201 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java | CndImporter.parse | protected void parse( String content ) {
Tokenizer tokenizer = new CndTokenizer(false, true);
TokenStream tokens = new TokenStream(content, tokenizer, false);
tokens.start();
while (tokens.hasNext()) {
// Keep reading while we can recognize one of the two types of statements ...
if (tokens.matches("<", ANY_VALUE, "=", ANY_VALUE, ">")) {
parseNamespaceMapping(tokens);
} else if (tokens.matches("[", ANY_VALUE, "]")) {
parseNodeTypeDefinition(tokens);
} else {
Position position = tokens.previousPosition();
throw new ParsingException(position, CndI18n.expectedNamespaceOrNodeDefinition.text(tokens.consume(),
position.getLine(),
position.getColumn()));
}
}
} | java | protected void parse( String content ) {
Tokenizer tokenizer = new CndTokenizer(false, true);
TokenStream tokens = new TokenStream(content, tokenizer, false);
tokens.start();
while (tokens.hasNext()) {
// Keep reading while we can recognize one of the two types of statements ...
if (tokens.matches("<", ANY_VALUE, "=", ANY_VALUE, ">")) {
parseNamespaceMapping(tokens);
} else if (tokens.matches("[", ANY_VALUE, "]")) {
parseNodeTypeDefinition(tokens);
} else {
Position position = tokens.previousPosition();
throw new ParsingException(position, CndI18n.expectedNamespaceOrNodeDefinition.text(tokens.consume(),
position.getLine(),
position.getColumn()));
}
}
} | [
"protected",
"void",
"parse",
"(",
"String",
"content",
")",
"{",
"Tokenizer",
"tokenizer",
"=",
"new",
"CndTokenizer",
"(",
"false",
",",
"true",
")",
";",
"TokenStream",
"tokens",
"=",
"new",
"TokenStream",
"(",
"content",
",",
"tokenizer",
",",
"false",
... | Parse the CND content.
@param content the content
@throws ParsingException if there is a problem parsing the content | [
"Parse",
"the",
"CND",
"content",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java#L196-L213 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java | CndImporter.parseNamespaceMapping | protected void parseNamespaceMapping( TokenStream tokens ) {
tokens.consume('<');
String prefix = removeQuotes(tokens.consume());
tokens.consume('=');
String uri = removeQuotes(tokens.consume());
tokens.consume('>');
// Register the namespace ...
context.getNamespaceRegistry().register(prefix, uri);
} | java | protected void parseNamespaceMapping( TokenStream tokens ) {
tokens.consume('<');
String prefix = removeQuotes(tokens.consume());
tokens.consume('=');
String uri = removeQuotes(tokens.consume());
tokens.consume('>');
// Register the namespace ...
context.getNamespaceRegistry().register(prefix, uri);
} | [
"protected",
"void",
"parseNamespaceMapping",
"(",
"TokenStream",
"tokens",
")",
"{",
"tokens",
".",
"consume",
"(",
"'",
"'",
")",
";",
"String",
"prefix",
"=",
"removeQuotes",
"(",
"tokens",
".",
"consume",
"(",
")",
")",
";",
"tokens",
".",
"consume",
... | Parse the namespace mapping statement that is next on the token stream.
@param tokens the tokens containing the namespace statement; never null
@throws ParsingException if there is a problem parsing the content | [
"Parse",
"the",
"namespace",
"mapping",
"statement",
"that",
"is",
"next",
"on",
"the",
"token",
"stream",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java#L221-L229 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java | CndImporter.parseNodeTypeDefinition | protected void parseNodeTypeDefinition( TokenStream tokens ) {
// Parse the name, and create the path and a property for the name ...
Name name = parseNodeTypeName(tokens);
JcrNodeTypeTemplate nodeType = new JcrNodeTypeTemplate(context);
try {
nodeType.setName(string(name));
} catch (ConstraintViolationException e) {
assert false : "Names should always be syntactically valid";
}
// Read the (optional) supertypes ...
List<Name> supertypes = parseSupertypes(tokens);
try {
nodeType.setDeclaredSuperTypeNames(names(supertypes));
// Read the node type options (and vendor extensions) ...
parseNodeTypeOptions(tokens, nodeType);
// Parse property and child node definitions ...
parsePropertyOrChildNodeDefinitions(tokens, nodeType);
} catch (ConstraintViolationException e) {
assert false : "Names should always be syntactically valid";
}
this.nodeTypes.add(nodeType);
} | java | protected void parseNodeTypeDefinition( TokenStream tokens ) {
// Parse the name, and create the path and a property for the name ...
Name name = parseNodeTypeName(tokens);
JcrNodeTypeTemplate nodeType = new JcrNodeTypeTemplate(context);
try {
nodeType.setName(string(name));
} catch (ConstraintViolationException e) {
assert false : "Names should always be syntactically valid";
}
// Read the (optional) supertypes ...
List<Name> supertypes = parseSupertypes(tokens);
try {
nodeType.setDeclaredSuperTypeNames(names(supertypes));
// Read the node type options (and vendor extensions) ...
parseNodeTypeOptions(tokens, nodeType);
// Parse property and child node definitions ...
parsePropertyOrChildNodeDefinitions(tokens, nodeType);
} catch (ConstraintViolationException e) {
assert false : "Names should always be syntactically valid";
}
this.nodeTypes.add(nodeType);
} | [
"protected",
"void",
"parseNodeTypeDefinition",
"(",
"TokenStream",
"tokens",
")",
"{",
"// Parse the name, and create the path and a property for the name ...",
"Name",
"name",
"=",
"parseNodeTypeName",
"(",
"tokens",
")",
";",
"JcrNodeTypeTemplate",
"nodeType",
"=",
"new",
... | Parse the node type definition that is next on the token stream.
@param tokens the tokens containing the node type definition; never null
@throws ParsingException if there is a problem parsing the content | [
"Parse",
"the",
"node",
"type",
"definition",
"that",
"is",
"next",
"on",
"the",
"token",
"stream",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java#L237-L262 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java | CndImporter.parseNodeTypeName | protected Name parseNodeTypeName( TokenStream tokens ) {
tokens.consume('[');
Name name = parseName(tokens);
tokens.consume(']');
return name;
} | java | protected Name parseNodeTypeName( TokenStream tokens ) {
tokens.consume('[');
Name name = parseName(tokens);
tokens.consume(']');
return name;
} | [
"protected",
"Name",
"parseNodeTypeName",
"(",
"TokenStream",
"tokens",
")",
"{",
"tokens",
".",
"consume",
"(",
"'",
"'",
")",
";",
"Name",
"name",
"=",
"parseName",
"(",
"tokens",
")",
";",
"tokens",
".",
"consume",
"(",
"'",
"'",
")",
";",
"return",... | Parse a node type name that appears next on the token stream.
@param tokens the tokens containing the node type name; never null
@return the node type name
@throws ParsingException if there is a problem parsing the content | [
"Parse",
"a",
"node",
"type",
"name",
"that",
"appears",
"next",
"on",
"the",
"token",
"stream",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java#L271-L276 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java | CndImporter.parseSupertypes | protected List<Name> parseSupertypes( TokenStream tokens ) {
if (tokens.canConsume('>')) {
// There is at least one supertype ...
return parseNameList(tokens);
}
return Collections.emptyList();
} | java | protected List<Name> parseSupertypes( TokenStream tokens ) {
if (tokens.canConsume('>')) {
// There is at least one supertype ...
return parseNameList(tokens);
}
return Collections.emptyList();
} | [
"protected",
"List",
"<",
"Name",
">",
"parseSupertypes",
"(",
"TokenStream",
"tokens",
")",
"{",
"if",
"(",
"tokens",
".",
"canConsume",
"(",
"'",
"'",
")",
")",
"{",
"// There is at least one supertype ...",
"return",
"parseNameList",
"(",
"tokens",
")",
";"... | Parse an optional list of supertypes if they appear next on the token stream.
@param tokens the tokens containing the supertype names; never null
@return the list of supertype names; never null, but possibly empty
@throws ParsingException if there is a problem parsing the content | [
"Parse",
"an",
"optional",
"list",
"of",
"supertypes",
"if",
"they",
"appear",
"next",
"on",
"the",
"token",
"stream",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java#L285-L291 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java | CndImporter.parseStringList | protected List<String> parseStringList( TokenStream tokens ) {
List<String> strings = new ArrayList<String>();
if (tokens.canConsume('?')) {
// This list is variant ...
strings.add("?");
} else {
// Read names until we see a ','
do {
strings.add(removeQuotes(tokens.consume()));
} while (tokens.canConsume(','));
}
return strings;
} | java | protected List<String> parseStringList( TokenStream tokens ) {
List<String> strings = new ArrayList<String>();
if (tokens.canConsume('?')) {
// This list is variant ...
strings.add("?");
} else {
// Read names until we see a ','
do {
strings.add(removeQuotes(tokens.consume()));
} while (tokens.canConsume(','));
}
return strings;
} | [
"protected",
"List",
"<",
"String",
">",
"parseStringList",
"(",
"TokenStream",
"tokens",
")",
"{",
"List",
"<",
"String",
">",
"strings",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"if",
"(",
"tokens",
".",
"canConsume",
"(",
"'",
"'"... | Parse a list of strings, separated by commas. Any quotes surrounding the strings are removed.
@param tokens the tokens containing the comma-separated strings; never null
@return the list of string values; never null, but possibly empty
@throws ParsingException if there is a problem parsing the content | [
"Parse",
"a",
"list",
"of",
"strings",
"separated",
"by",
"commas",
".",
"Any",
"quotes",
"surrounding",
"the",
"strings",
"are",
"removed",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java#L300-L312 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java | CndImporter.parseNameList | protected List<Name> parseNameList( TokenStream tokens ) {
List<Name> names = new ArrayList<Name>();
if (!tokens.canConsume('?')) {
// Read names until we see a ','
do {
names.add(parseName(tokens));
} while (tokens.canConsume(','));
}
return names;
} | java | protected List<Name> parseNameList( TokenStream tokens ) {
List<Name> names = new ArrayList<Name>();
if (!tokens.canConsume('?')) {
// Read names until we see a ','
do {
names.add(parseName(tokens));
} while (tokens.canConsume(','));
}
return names;
} | [
"protected",
"List",
"<",
"Name",
">",
"parseNameList",
"(",
"TokenStream",
"tokens",
")",
"{",
"List",
"<",
"Name",
">",
"names",
"=",
"new",
"ArrayList",
"<",
"Name",
">",
"(",
")",
";",
"if",
"(",
"!",
"tokens",
".",
"canConsume",
"(",
"'",
"'",
... | Parse a list of names, separated by commas. Any quotes surrounding the names are removed.
@param tokens the tokens containing the comma-separated strings; never null
@return the list of string values; never null, but possibly empty
@throws ParsingException if there is a problem parsing the content | [
"Parse",
"a",
"list",
"of",
"names",
"separated",
"by",
"commas",
".",
"Any",
"quotes",
"surrounding",
"the",
"names",
"are",
"removed",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java#L321-L330 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java | CndImporter.parsePropertyOrChildNodeDefinitions | protected void parsePropertyOrChildNodeDefinitions( TokenStream tokens,
JcrNodeTypeTemplate nodeType ) throws ConstraintViolationException {
while (true) {
// Keep reading while we see a property definition or child node definition ...
if (tokens.matches('-')) {
parsePropertyDefinition(tokens, nodeType);
} else if (tokens.matches('+')) {
parseChildNodeDefinition(tokens, nodeType);
} else {
// The next token does not signal either one of these, so stop ...
break;
}
}
} | java | protected void parsePropertyOrChildNodeDefinitions( TokenStream tokens,
JcrNodeTypeTemplate nodeType ) throws ConstraintViolationException {
while (true) {
// Keep reading while we see a property definition or child node definition ...
if (tokens.matches('-')) {
parsePropertyDefinition(tokens, nodeType);
} else if (tokens.matches('+')) {
parseChildNodeDefinition(tokens, nodeType);
} else {
// The next token does not signal either one of these, so stop ...
break;
}
}
} | [
"protected",
"void",
"parsePropertyOrChildNodeDefinitions",
"(",
"TokenStream",
"tokens",
",",
"JcrNodeTypeTemplate",
"nodeType",
")",
"throws",
"ConstraintViolationException",
"{",
"while",
"(",
"true",
")",
"{",
"// Keep reading while we see a property definition or child node ... | Parse a node type's property or child node definitions that appear next on the token stream.
@param tokens the tokens containing the definitions; never null
@param nodeType the node type being created; never null
@throws ParsingException if there is a problem parsing the content
@throws ConstraintViolationException not expected | [
"Parse",
"a",
"node",
"type",
"s",
"property",
"or",
"child",
"node",
"definitions",
"that",
"appear",
"next",
"on",
"the",
"token",
"stream",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java#L396-L409 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java | CndImporter.parsePropertyDefinition | protected void parsePropertyDefinition( TokenStream tokens,
JcrNodeTypeTemplate nodeType ) throws ConstraintViolationException {
tokens.consume('-');
Name name = parseName(tokens);
JcrPropertyDefinitionTemplate propDefn = new JcrPropertyDefinitionTemplate(context);
propDefn.setName(string(name));
// Parse the (optional) required type ...
parsePropertyType(tokens, propDefn, PropertyType.STRING.getName());
// Parse the default values ...
parseDefaultValues(tokens, propDefn);
// Parse the property attributes (and vendor extensions) ...
parsePropertyAttributes(tokens, propDefn, nodeType);
// Parse the property constraints ...
parseValueConstraints(tokens, propDefn);
// Parse the vendor extensions (appearing after the constraints) ...
List<Property> properties = new LinkedList<Property>();
parseVendorExtensions(tokens, properties);
applyVendorExtensions(nodeType, properties);
nodeType.getPropertyDefinitionTemplates().add(propDefn);
} | java | protected void parsePropertyDefinition( TokenStream tokens,
JcrNodeTypeTemplate nodeType ) throws ConstraintViolationException {
tokens.consume('-');
Name name = parseName(tokens);
JcrPropertyDefinitionTemplate propDefn = new JcrPropertyDefinitionTemplate(context);
propDefn.setName(string(name));
// Parse the (optional) required type ...
parsePropertyType(tokens, propDefn, PropertyType.STRING.getName());
// Parse the default values ...
parseDefaultValues(tokens, propDefn);
// Parse the property attributes (and vendor extensions) ...
parsePropertyAttributes(tokens, propDefn, nodeType);
// Parse the property constraints ...
parseValueConstraints(tokens, propDefn);
// Parse the vendor extensions (appearing after the constraints) ...
List<Property> properties = new LinkedList<Property>();
parseVendorExtensions(tokens, properties);
applyVendorExtensions(nodeType, properties);
nodeType.getPropertyDefinitionTemplates().add(propDefn);
} | [
"protected",
"void",
"parsePropertyDefinition",
"(",
"TokenStream",
"tokens",
",",
"JcrNodeTypeTemplate",
"nodeType",
")",
"throws",
"ConstraintViolationException",
"{",
"tokens",
".",
"consume",
"(",
"'",
"'",
")",
";",
"Name",
"name",
"=",
"parseName",
"(",
"tok... | Parse a node type's property definition from the next tokens on the stream.
@param tokens the tokens containing the definition; never null
@param nodeType the node type definition; never null
@throws ParsingException if there is a problem parsing the content
@throws ConstraintViolationException not expected | [
"Parse",
"a",
"node",
"type",
"s",
"property",
"definition",
"from",
"the",
"next",
"tokens",
"on",
"the",
"stream",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java#L419-L444 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java | CndImporter.parsePropertyType | protected void parsePropertyType( TokenStream tokens,
JcrPropertyDefinitionTemplate propDefn,
String defaultPropertyType ) {
if (tokens.canConsume('(')) {
// Parse the (optional) property type ...
String propertyType = defaultPropertyType;
if (tokens.matchesAnyOf(VALID_PROPERTY_TYPES)) {
propertyType = tokens.consume();
if ("*".equals(propertyType)) propertyType = "UNDEFINED";
}
tokens.consume(')');
PropertyType type = PropertyType.valueFor(propertyType.toLowerCase());
int jcrType = PropertyTypeUtil.jcrPropertyTypeFor(type);
propDefn.setRequiredType(jcrType);
}
} | java | protected void parsePropertyType( TokenStream tokens,
JcrPropertyDefinitionTemplate propDefn,
String defaultPropertyType ) {
if (tokens.canConsume('(')) {
// Parse the (optional) property type ...
String propertyType = defaultPropertyType;
if (tokens.matchesAnyOf(VALID_PROPERTY_TYPES)) {
propertyType = tokens.consume();
if ("*".equals(propertyType)) propertyType = "UNDEFINED";
}
tokens.consume(')');
PropertyType type = PropertyType.valueFor(propertyType.toLowerCase());
int jcrType = PropertyTypeUtil.jcrPropertyTypeFor(type);
propDefn.setRequiredType(jcrType);
}
} | [
"protected",
"void",
"parsePropertyType",
"(",
"TokenStream",
"tokens",
",",
"JcrPropertyDefinitionTemplate",
"propDefn",
",",
"String",
"defaultPropertyType",
")",
"{",
"if",
"(",
"tokens",
".",
"canConsume",
"(",
"'",
"'",
")",
")",
"{",
"// Parse the (optional) p... | Parse the property type, if a valid one appears next on the token stream.
@param tokens the tokens containing the definition; never null
@param propDefn the property definition; never null
@param defaultPropertyType the default property type if none is actually found
@throws ParsingException if there is a problem parsing the content | [
"Parse",
"the",
"property",
"type",
"if",
"a",
"valid",
"one",
"appears",
"next",
"on",
"the",
"token",
"stream",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java#L454-L469 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java | CndImporter.parseDefaultValues | protected void parseDefaultValues( TokenStream tokens,
JcrPropertyDefinitionTemplate propDefn ) {
if (tokens.canConsume('=')) {
List<String> defaultValues = parseStringList(tokens);
if (!defaultValues.isEmpty()) {
propDefn.setDefaultValues(values(defaultValues));
}
}
} | java | protected void parseDefaultValues( TokenStream tokens,
JcrPropertyDefinitionTemplate propDefn ) {
if (tokens.canConsume('=')) {
List<String> defaultValues = parseStringList(tokens);
if (!defaultValues.isEmpty()) {
propDefn.setDefaultValues(values(defaultValues));
}
}
} | [
"protected",
"void",
"parseDefaultValues",
"(",
"TokenStream",
"tokens",
",",
"JcrPropertyDefinitionTemplate",
"propDefn",
")",
"{",
"if",
"(",
"tokens",
".",
"canConsume",
"(",
"'",
"'",
")",
")",
"{",
"List",
"<",
"String",
">",
"defaultValues",
"=",
"parseS... | Parse the property definition's default value, if they appear next on the token stream.
@param tokens the tokens containing the definition; never null
@param propDefn the property definition; never null
@throws ParsingException if there is a problem parsing the content | [
"Parse",
"the",
"property",
"definition",
"s",
"default",
"value",
"if",
"they",
"appear",
"next",
"on",
"the",
"token",
"stream",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java#L478-L486 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java | CndImporter.parseValueConstraints | protected void parseValueConstraints( TokenStream tokens,
JcrPropertyDefinitionTemplate propDefn ) {
if (tokens.canConsume('<')) {
List<String> defaultValues = parseStringList(tokens);
if (!defaultValues.isEmpty()) {
propDefn.setValueConstraints(strings(defaultValues));
}
}
} | java | protected void parseValueConstraints( TokenStream tokens,
JcrPropertyDefinitionTemplate propDefn ) {
if (tokens.canConsume('<')) {
List<String> defaultValues = parseStringList(tokens);
if (!defaultValues.isEmpty()) {
propDefn.setValueConstraints(strings(defaultValues));
}
}
} | [
"protected",
"void",
"parseValueConstraints",
"(",
"TokenStream",
"tokens",
",",
"JcrPropertyDefinitionTemplate",
"propDefn",
")",
"{",
"if",
"(",
"tokens",
".",
"canConsume",
"(",
"'",
"'",
")",
")",
"{",
"List",
"<",
"String",
">",
"defaultValues",
"=",
"par... | Parse the property definition's value constraints, if they appear next on the token stream.
@param tokens the tokens containing the definition; never null
@param propDefn the property definition; never null
@throws ParsingException if there is a problem parsing the content | [
"Parse",
"the",
"property",
"definition",
"s",
"value",
"constraints",
"if",
"they",
"appear",
"next",
"on",
"the",
"token",
"stream",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java#L495-L503 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java | CndImporter.parsePropertyAttributes | protected void parsePropertyAttributes( TokenStream tokens,
JcrPropertyDefinitionTemplate propDefn,
JcrNodeTypeTemplate nodeType ) throws ConstraintViolationException {
boolean autoCreated = false;
boolean mandatory = false;
boolean isProtected = false;
boolean multiple = false;
boolean isFullTextSearchable = true;
boolean isQueryOrderable = true;
String onParentVersion = "COPY";
while (true) {
if (tokens.canConsumeAnyOf("AUTOCREATED", "AUT", "A")) {
tokens.canConsume('?');
autoCreated = true;
} else if (tokens.canConsumeAnyOf("MANDATORY", "MAN", "M")) {
tokens.canConsume('?');
mandatory = true;
} else if (tokens.canConsumeAnyOf("PROTECTED", "PRO", "P")) {
tokens.canConsume('?');
isProtected = true;
} else if (tokens.canConsumeAnyOf("MULTIPLE", "MUL", "*")) {
tokens.canConsume('?');
multiple = true;
} else if (tokens.matchesAnyOf(VALID_ON_PARENT_VERSION)) {
onParentVersion = tokens.consume();
tokens.canConsume('?');
} else if (tokens.matches("OPV")) {
// variant on-parent-version
onParentVersion = tokens.consume();
tokens.canConsume('?');
} else if (tokens.canConsumeAnyOf("NOFULLTEXT", "NOF")) {
tokens.canConsume('?');
isFullTextSearchable = false;
} else if (tokens.canConsumeAnyOf("NOQUERYORDER", "NQORD")) {
tokens.canConsume('?');
isQueryOrderable = false;
} else if (tokens.canConsumeAnyOf("QUERYOPS", "QOP")) {
parseQueryOperators(tokens, propDefn);
} else if (tokens.canConsumeAnyOf("PRIMARYITEM", "PRIMARY", "PRI", "!")) {
Position pos = tokens.previousPosition();
int line = pos.getLine();
int column = pos.getColumn();
throw new ParsingException(tokens.previousPosition(),
CndI18n.primaryKeywordNotValidInJcr2CndFormat.text(line, column));
} else if (tokens.matches(CndTokenizer.VENDOR_EXTENSION)) {
List<Property> properties = new LinkedList<Property>();
parseVendorExtensions(tokens, properties);
applyVendorExtensions(propDefn, properties);
} else {
break;
}
}
propDefn.setAutoCreated(autoCreated);
propDefn.setMandatory(mandatory);
propDefn.setProtected(isProtected);
propDefn.setOnParentVersion(OnParentVersionAction.valueFromName(onParentVersion.toUpperCase(Locale.ROOT)));
propDefn.setMultiple(multiple);
propDefn.setFullTextSearchable(isFullTextSearchable);
propDefn.setQueryOrderable(isQueryOrderable);
} | java | protected void parsePropertyAttributes( TokenStream tokens,
JcrPropertyDefinitionTemplate propDefn,
JcrNodeTypeTemplate nodeType ) throws ConstraintViolationException {
boolean autoCreated = false;
boolean mandatory = false;
boolean isProtected = false;
boolean multiple = false;
boolean isFullTextSearchable = true;
boolean isQueryOrderable = true;
String onParentVersion = "COPY";
while (true) {
if (tokens.canConsumeAnyOf("AUTOCREATED", "AUT", "A")) {
tokens.canConsume('?');
autoCreated = true;
} else if (tokens.canConsumeAnyOf("MANDATORY", "MAN", "M")) {
tokens.canConsume('?');
mandatory = true;
} else if (tokens.canConsumeAnyOf("PROTECTED", "PRO", "P")) {
tokens.canConsume('?');
isProtected = true;
} else if (tokens.canConsumeAnyOf("MULTIPLE", "MUL", "*")) {
tokens.canConsume('?');
multiple = true;
} else if (tokens.matchesAnyOf(VALID_ON_PARENT_VERSION)) {
onParentVersion = tokens.consume();
tokens.canConsume('?');
} else if (tokens.matches("OPV")) {
// variant on-parent-version
onParentVersion = tokens.consume();
tokens.canConsume('?');
} else if (tokens.canConsumeAnyOf("NOFULLTEXT", "NOF")) {
tokens.canConsume('?');
isFullTextSearchable = false;
} else if (tokens.canConsumeAnyOf("NOQUERYORDER", "NQORD")) {
tokens.canConsume('?');
isQueryOrderable = false;
} else if (tokens.canConsumeAnyOf("QUERYOPS", "QOP")) {
parseQueryOperators(tokens, propDefn);
} else if (tokens.canConsumeAnyOf("PRIMARYITEM", "PRIMARY", "PRI", "!")) {
Position pos = tokens.previousPosition();
int line = pos.getLine();
int column = pos.getColumn();
throw new ParsingException(tokens.previousPosition(),
CndI18n.primaryKeywordNotValidInJcr2CndFormat.text(line, column));
} else if (tokens.matches(CndTokenizer.VENDOR_EXTENSION)) {
List<Property> properties = new LinkedList<Property>();
parseVendorExtensions(tokens, properties);
applyVendorExtensions(propDefn, properties);
} else {
break;
}
}
propDefn.setAutoCreated(autoCreated);
propDefn.setMandatory(mandatory);
propDefn.setProtected(isProtected);
propDefn.setOnParentVersion(OnParentVersionAction.valueFromName(onParentVersion.toUpperCase(Locale.ROOT)));
propDefn.setMultiple(multiple);
propDefn.setFullTextSearchable(isFullTextSearchable);
propDefn.setQueryOrderable(isQueryOrderable);
} | [
"protected",
"void",
"parsePropertyAttributes",
"(",
"TokenStream",
"tokens",
",",
"JcrPropertyDefinitionTemplate",
"propDefn",
",",
"JcrNodeTypeTemplate",
"nodeType",
")",
"throws",
"ConstraintViolationException",
"{",
"boolean",
"autoCreated",
"=",
"false",
";",
"boolean"... | Parse the property definition's attributes, if they appear next on the token stream.
@param tokens the tokens containing the attributes; never null
@param propDefn the property definition; never null
@param nodeType the node type; never null
@throws ParsingException if there is a problem parsing the content
@throws ConstraintViolationException not expected | [
"Parse",
"the",
"property",
"definition",
"s",
"attributes",
"if",
"they",
"appear",
"next",
"on",
"the",
"token",
"stream",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java#L514-L573 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java | CndImporter.parseQueryOperators | protected void parseQueryOperators( TokenStream tokens,
JcrPropertyDefinitionTemplate propDefn ) {
if (tokens.canConsume('?')) {
return;
}
// The query operators are expected to be enclosed in a single quote, so therefore will be a single token ...
List<String> operators = new ArrayList<String>();
String operatorList = removeQuotes(tokens.consume());
// Now split this string on ',' ...
for (String operatorValue : operatorList.split(",")) {
String operator = operatorValue.trim();
if (!VALID_QUERY_OPERATORS.contains(operator)) {
throw new ParsingException(tokens.previousPosition(), CndI18n.expectedValidQueryOperator.text(operator));
}
operators.add(operator);
}
if (operators.isEmpty()) {
operators.addAll(VALID_QUERY_OPERATORS);
}
propDefn.setAvailableQueryOperators(strings(operators));
} | java | protected void parseQueryOperators( TokenStream tokens,
JcrPropertyDefinitionTemplate propDefn ) {
if (tokens.canConsume('?')) {
return;
}
// The query operators are expected to be enclosed in a single quote, so therefore will be a single token ...
List<String> operators = new ArrayList<String>();
String operatorList = removeQuotes(tokens.consume());
// Now split this string on ',' ...
for (String operatorValue : operatorList.split(",")) {
String operator = operatorValue.trim();
if (!VALID_QUERY_OPERATORS.contains(operator)) {
throw new ParsingException(tokens.previousPosition(), CndI18n.expectedValidQueryOperator.text(operator));
}
operators.add(operator);
}
if (operators.isEmpty()) {
operators.addAll(VALID_QUERY_OPERATORS);
}
propDefn.setAvailableQueryOperators(strings(operators));
} | [
"protected",
"void",
"parseQueryOperators",
"(",
"TokenStream",
"tokens",
",",
"JcrPropertyDefinitionTemplate",
"propDefn",
")",
"{",
"if",
"(",
"tokens",
".",
"canConsume",
"(",
"'",
"'",
")",
")",
"{",
"return",
";",
"}",
"// The query operators are expected to be... | Parse the property definition's query operators, if they appear next on the token stream.
@param tokens the tokens containing the definition; never null
@param propDefn the property definition; never null
@throws ParsingException if there is a problem parsing the content | [
"Parse",
"the",
"property",
"definition",
"s",
"query",
"operators",
"if",
"they",
"appear",
"next",
"on",
"the",
"token",
"stream",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java#L582-L602 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java | CndImporter.parseChildNodeDefinition | protected void parseChildNodeDefinition( TokenStream tokens,
JcrNodeTypeTemplate nodeType ) throws ConstraintViolationException {
tokens.consume('+');
Name name = parseName(tokens);
JcrNodeDefinitionTemplate childDefn = new JcrNodeDefinitionTemplate(context);
childDefn.setName(string(name));
parseRequiredPrimaryTypes(tokens, childDefn);
parseDefaultType(tokens, childDefn);
parseNodeAttributes(tokens, childDefn, nodeType);
nodeType.getNodeDefinitionTemplates().add(childDefn);
} | java | protected void parseChildNodeDefinition( TokenStream tokens,
JcrNodeTypeTemplate nodeType ) throws ConstraintViolationException {
tokens.consume('+');
Name name = parseName(tokens);
JcrNodeDefinitionTemplate childDefn = new JcrNodeDefinitionTemplate(context);
childDefn.setName(string(name));
parseRequiredPrimaryTypes(tokens, childDefn);
parseDefaultType(tokens, childDefn);
parseNodeAttributes(tokens, childDefn, nodeType);
nodeType.getNodeDefinitionTemplates().add(childDefn);
} | [
"protected",
"void",
"parseChildNodeDefinition",
"(",
"TokenStream",
"tokens",
",",
"JcrNodeTypeTemplate",
"nodeType",
")",
"throws",
"ConstraintViolationException",
"{",
"tokens",
".",
"consume",
"(",
"'",
"'",
")",
";",
"Name",
"name",
"=",
"parseName",
"(",
"to... | Parse a node type's child node definition from the next tokens on the stream.
@param tokens the tokens containing the definition; never null
@param nodeType the node type being created; never null
@throws ParsingException if there is a problem parsing the content
@throws ConstraintViolationException not expected | [
"Parse",
"a",
"node",
"type",
"s",
"child",
"node",
"definition",
"from",
"the",
"next",
"tokens",
"on",
"the",
"stream",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java#L612-L626 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java | CndImporter.parseRequiredPrimaryTypes | protected void parseRequiredPrimaryTypes( TokenStream tokens,
JcrNodeDefinitionTemplate childDefn ) throws ConstraintViolationException {
if (tokens.canConsume('(')) {
List<Name> requiredTypes = parseNameList(tokens);
if (requiredTypes.isEmpty()) {
requiredTypes.add(JcrNtLexicon.BASE);
}
childDefn.setRequiredPrimaryTypeNames(names(requiredTypes));
tokens.consume(')');
}
} | java | protected void parseRequiredPrimaryTypes( TokenStream tokens,
JcrNodeDefinitionTemplate childDefn ) throws ConstraintViolationException {
if (tokens.canConsume('(')) {
List<Name> requiredTypes = parseNameList(tokens);
if (requiredTypes.isEmpty()) {
requiredTypes.add(JcrNtLexicon.BASE);
}
childDefn.setRequiredPrimaryTypeNames(names(requiredTypes));
tokens.consume(')');
}
} | [
"protected",
"void",
"parseRequiredPrimaryTypes",
"(",
"TokenStream",
"tokens",
",",
"JcrNodeDefinitionTemplate",
"childDefn",
")",
"throws",
"ConstraintViolationException",
"{",
"if",
"(",
"tokens",
".",
"canConsume",
"(",
"'",
"'",
")",
")",
"{",
"List",
"<",
"N... | Parse the child node definition's list of required primary types, if they appear next on the token stream.
@param tokens the tokens containing the definition; never null
@param childDefn the child node definition; never null
@throws ParsingException if there is a problem parsing the content
@throws ConstraintViolationException not expected | [
"Parse",
"the",
"child",
"node",
"definition",
"s",
"list",
"of",
"required",
"primary",
"types",
"if",
"they",
"appear",
"next",
"on",
"the",
"token",
"stream",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java#L636-L646 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java | CndImporter.parseDefaultType | protected void parseDefaultType( TokenStream tokens,
JcrNodeDefinitionTemplate childDefn ) throws ConstraintViolationException {
if (tokens.canConsume('=')) {
if (!tokens.canConsume('?')) {
Name defaultType = parseName(tokens);
childDefn.setDefaultPrimaryTypeName(string(defaultType));
}
}
} | java | protected void parseDefaultType( TokenStream tokens,
JcrNodeDefinitionTemplate childDefn ) throws ConstraintViolationException {
if (tokens.canConsume('=')) {
if (!tokens.canConsume('?')) {
Name defaultType = parseName(tokens);
childDefn.setDefaultPrimaryTypeName(string(defaultType));
}
}
} | [
"protected",
"void",
"parseDefaultType",
"(",
"TokenStream",
"tokens",
",",
"JcrNodeDefinitionTemplate",
"childDefn",
")",
"throws",
"ConstraintViolationException",
"{",
"if",
"(",
"tokens",
".",
"canConsume",
"(",
"'",
"'",
")",
")",
"{",
"if",
"(",
"!",
"token... | Parse the child node definition's default type, if they appear next on the token stream.
@param tokens the tokens containing the definition; never null
@param childDefn the child node definition; never null
@throws ParsingException if there is a problem parsing the content
@throws ConstraintViolationException not expected | [
"Parse",
"the",
"child",
"node",
"definition",
"s",
"default",
"type",
"if",
"they",
"appear",
"next",
"on",
"the",
"token",
"stream",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java#L656-L664 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java | CndImporter.parseNodeAttributes | protected void parseNodeAttributes( TokenStream tokens,
JcrNodeDefinitionTemplate childDefn,
JcrNodeTypeTemplate nodeType ) throws ConstraintViolationException {
boolean autoCreated = false;
boolean mandatory = false;
boolean isProtected = false;
boolean sns = false;
String onParentVersion = "COPY";
while (true) {
if (tokens.canConsumeAnyOf("AUTOCREATED", "AUT", "A")) {
tokens.canConsume('?');
autoCreated = true;
} else if (tokens.canConsumeAnyOf("MANDATORY", "MAN", "M")) {
tokens.canConsume('?');
mandatory = true;
} else if (tokens.canConsumeAnyOf("PROTECTED", "PRO", "P")) {
tokens.canConsume('?');
isProtected = true;
} else if (tokens.canConsumeAnyOf("SNS", "*")) { // standard JCR 2.0 keywords for SNS ...
tokens.canConsume('?');
sns = true;
} else if (tokens.canConsumeAnyOf("MULTIPLE", "MUL", "*")) { // from pre-JCR 2.0 ref impl
Position pos = tokens.previousPosition();
int line = pos.getLine();
int column = pos.getColumn();
throw new ParsingException(tokens.previousPosition(),
CndI18n.multipleKeywordNotValidInJcr2CndFormat.text(line, column));
} else if (tokens.matchesAnyOf(VALID_ON_PARENT_VERSION)) {
onParentVersion = tokens.consume();
tokens.canConsume('?');
} else if (tokens.matches("OPV")) {
// variant on-parent-version
onParentVersion = tokens.consume();
tokens.canConsume('?');
} else if (tokens.canConsumeAnyOf("PRIMARYITEM", "PRIMARY", "PRI", "!")) {
Position pos = tokens.previousPosition();
int line = pos.getLine();
int column = pos.getColumn();
throw new ParsingException(tokens.previousPosition(),
CndI18n.primaryKeywordNotValidInJcr2CndFormat.text(line, column));
} else if (tokens.matches(CndTokenizer.VENDOR_EXTENSION)) {
List<Property> properties = new LinkedList<Property>();
parseVendorExtensions(tokens, properties);
applyVendorExtensions(childDefn, properties);
} else {
break;
}
}
childDefn.setAutoCreated(autoCreated);
childDefn.setMandatory(mandatory);
childDefn.setProtected(isProtected);
childDefn.setOnParentVersion(OnParentVersionAction.valueFromName(onParentVersion.toUpperCase(Locale.ROOT)));
childDefn.setSameNameSiblings(sns);
} | java | protected void parseNodeAttributes( TokenStream tokens,
JcrNodeDefinitionTemplate childDefn,
JcrNodeTypeTemplate nodeType ) throws ConstraintViolationException {
boolean autoCreated = false;
boolean mandatory = false;
boolean isProtected = false;
boolean sns = false;
String onParentVersion = "COPY";
while (true) {
if (tokens.canConsumeAnyOf("AUTOCREATED", "AUT", "A")) {
tokens.canConsume('?');
autoCreated = true;
} else if (tokens.canConsumeAnyOf("MANDATORY", "MAN", "M")) {
tokens.canConsume('?');
mandatory = true;
} else if (tokens.canConsumeAnyOf("PROTECTED", "PRO", "P")) {
tokens.canConsume('?');
isProtected = true;
} else if (tokens.canConsumeAnyOf("SNS", "*")) { // standard JCR 2.0 keywords for SNS ...
tokens.canConsume('?');
sns = true;
} else if (tokens.canConsumeAnyOf("MULTIPLE", "MUL", "*")) { // from pre-JCR 2.0 ref impl
Position pos = tokens.previousPosition();
int line = pos.getLine();
int column = pos.getColumn();
throw new ParsingException(tokens.previousPosition(),
CndI18n.multipleKeywordNotValidInJcr2CndFormat.text(line, column));
} else if (tokens.matchesAnyOf(VALID_ON_PARENT_VERSION)) {
onParentVersion = tokens.consume();
tokens.canConsume('?');
} else if (tokens.matches("OPV")) {
// variant on-parent-version
onParentVersion = tokens.consume();
tokens.canConsume('?');
} else if (tokens.canConsumeAnyOf("PRIMARYITEM", "PRIMARY", "PRI", "!")) {
Position pos = tokens.previousPosition();
int line = pos.getLine();
int column = pos.getColumn();
throw new ParsingException(tokens.previousPosition(),
CndI18n.primaryKeywordNotValidInJcr2CndFormat.text(line, column));
} else if (tokens.matches(CndTokenizer.VENDOR_EXTENSION)) {
List<Property> properties = new LinkedList<Property>();
parseVendorExtensions(tokens, properties);
applyVendorExtensions(childDefn, properties);
} else {
break;
}
}
childDefn.setAutoCreated(autoCreated);
childDefn.setMandatory(mandatory);
childDefn.setProtected(isProtected);
childDefn.setOnParentVersion(OnParentVersionAction.valueFromName(onParentVersion.toUpperCase(Locale.ROOT)));
childDefn.setSameNameSiblings(sns);
} | [
"protected",
"void",
"parseNodeAttributes",
"(",
"TokenStream",
"tokens",
",",
"JcrNodeDefinitionTemplate",
"childDefn",
",",
"JcrNodeTypeTemplate",
"nodeType",
")",
"throws",
"ConstraintViolationException",
"{",
"boolean",
"autoCreated",
"=",
"false",
";",
"boolean",
"ma... | Parse the child node definition's attributes, if they appear next on the token stream.
@param tokens the tokens containing the attributes; never null
@param childDefn the child node definition; never null
@param nodeType the node type being created; never null
@throws ParsingException if there is a problem parsing the content
@throws ConstraintViolationException not expected | [
"Parse",
"the",
"child",
"node",
"definition",
"s",
"attributes",
"if",
"they",
"appear",
"next",
"on",
"the",
"token",
"stream",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java#L675-L728 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java | CndImporter.parseName | protected Name parseName( TokenStream tokens ) {
String value = tokens.consume();
try {
return nameFactory.create(removeQuotes(value));
} catch (ValueFormatException e) {
if (e.getCause() instanceof NamespaceException) {
throw (NamespaceException)e.getCause();
}
throw new ParsingException(tokens.previousPosition(), CndI18n.expectedValidNameLiteral.text(value));
}
} | java | protected Name parseName( TokenStream tokens ) {
String value = tokens.consume();
try {
return nameFactory.create(removeQuotes(value));
} catch (ValueFormatException e) {
if (e.getCause() instanceof NamespaceException) {
throw (NamespaceException)e.getCause();
}
throw new ParsingException(tokens.previousPosition(), CndI18n.expectedValidNameLiteral.text(value));
}
} | [
"protected",
"Name",
"parseName",
"(",
"TokenStream",
"tokens",
")",
"{",
"String",
"value",
"=",
"tokens",
".",
"consume",
"(",
")",
";",
"try",
"{",
"return",
"nameFactory",
".",
"create",
"(",
"removeQuotes",
"(",
"value",
")",
")",
";",
"}",
"catch",... | Parse the name that is expected to be next on the token stream.
@param tokens the tokens containing the name; never null
@return the name; never null
@throws ParsingException if there is a problem parsing the content | [
"Parse",
"the",
"name",
"that",
"is",
"expected",
"to",
"be",
"next",
"on",
"the",
"token",
"stream",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java#L737-L747 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java | CndImporter.parseVendorExtensions | protected final void parseVendorExtensions( TokenStream tokens,
List<Property> properties ) {
while (tokens.matches(CndTokenizer.VENDOR_EXTENSION)) {
Property extension = parseVendorExtension(tokens.consume());
if (extension != null) properties.add(extension);
}
} | java | protected final void parseVendorExtensions( TokenStream tokens,
List<Property> properties ) {
while (tokens.matches(CndTokenizer.VENDOR_EXTENSION)) {
Property extension = parseVendorExtension(tokens.consume());
if (extension != null) properties.add(extension);
}
} | [
"protected",
"final",
"void",
"parseVendorExtensions",
"(",
"TokenStream",
"tokens",
",",
"List",
"<",
"Property",
">",
"properties",
")",
"{",
"while",
"(",
"tokens",
".",
"matches",
"(",
"CndTokenizer",
".",
"VENDOR_EXTENSION",
")",
")",
"{",
"Property",
"ex... | Parse the vendor extensions that may appear next on the tokenzied stream.
@param tokens token stream; may not be null
@param properties the list of properties to which any vendor extension properties should be added | [
"Parse",
"the",
"vendor",
"extensions",
"that",
"may",
"appear",
"next",
"on",
"the",
"tokenzied",
"stream",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java#L760-L766 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java | CndImporter.parseVendorExtension | protected final Property parseVendorExtension( String vendorExtension ) {
if (vendorExtension == null) return null;
// Remove the curly braces ...
String extension = vendorExtension.replaceFirst("^[{]", "").replaceAll("[}]$", "");
if (extension.trim().length() == 0) return null;
return parseVendorExtensionContent(extension);
} | java | protected final Property parseVendorExtension( String vendorExtension ) {
if (vendorExtension == null) return null;
// Remove the curly braces ...
String extension = vendorExtension.replaceFirst("^[{]", "").replaceAll("[}]$", "");
if (extension.trim().length() == 0) return null;
return parseVendorExtensionContent(extension);
} | [
"protected",
"final",
"Property",
"parseVendorExtension",
"(",
"String",
"vendorExtension",
")",
"{",
"if",
"(",
"vendorExtension",
"==",
"null",
")",
"return",
"null",
";",
"// Remove the curly braces ...",
"String",
"extension",
"=",
"vendorExtension",
".",
"replace... | Parse the vendor extension, including the curly braces in the CND content.
@param vendorExtension the vendor extension string
@return the property representing the vendor extension, or null if the vendor extension is incomplete | [
"Parse",
"the",
"vendor",
"extension",
"including",
"the",
"curly",
"braces",
"in",
"the",
"CND",
"content",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java#L774-L780 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java | CndImporter.parseVendorExtensionContent | protected final Property parseVendorExtensionContent( String vendorExtension ) {
Matcher matcher = VENDOR_PATTERN.matcher(vendorExtension);
if (!matcher.find()) return null;
String vendorName = removeQuotes(matcher.group(1));
String vendorValue = removeQuotes(matcher.group(3));
assert vendorName != null;
assert vendorValue != null;
assert vendorName.length() != 0;
assert vendorValue.length() != 0;
return context.getPropertyFactory().create(nameFactory.create(vendorName), vendorValue);
} | java | protected final Property parseVendorExtensionContent( String vendorExtension ) {
Matcher matcher = VENDOR_PATTERN.matcher(vendorExtension);
if (!matcher.find()) return null;
String vendorName = removeQuotes(matcher.group(1));
String vendorValue = removeQuotes(matcher.group(3));
assert vendorName != null;
assert vendorValue != null;
assert vendorName.length() != 0;
assert vendorValue.length() != 0;
return context.getPropertyFactory().create(nameFactory.create(vendorName), vendorValue);
} | [
"protected",
"final",
"Property",
"parseVendorExtensionContent",
"(",
"String",
"vendorExtension",
")",
"{",
"Matcher",
"matcher",
"=",
"VENDOR_PATTERN",
".",
"matcher",
"(",
"vendorExtension",
")",
";",
"if",
"(",
"!",
"matcher",
".",
"find",
"(",
")",
")",
"... | Parse the content of the vendor extension excluding the curly braces in the CND content.
@param vendorExtension the vendor extension string; never null
@return the property representing the vendor extension, or null if the vendor extension is incomplete | [
"Parse",
"the",
"content",
"of",
"the",
"vendor",
"extension",
"excluding",
"the",
"curly",
"braces",
"in",
"the",
"CND",
"content",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/CndImporter.java#L788-L798 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/cache/RepositoryCache.java | RepositoryCache.createWorkspace | public WorkspaceCache createWorkspace( String name ) {
if (!workspaceNames.contains(name)) {
if (!configuration.isCreatingWorkspacesAllowed()) {
throw new UnsupportedOperationException(JcrI18n.creatingWorkspacesIsNotAllowedInRepository.text(getName()));
}
// Otherwise, create the workspace and persist it ...
this.workspaceNames.add(name);
refreshRepositoryMetadata(true);
// Now make sure that the "/jcr:system" node is a child of the root node ...
SessionCache session = createSession(context, name, false);
MutableCachedNode root = session.mutable(session.getRootKey());
ChildReference ref = root.getChildReferences(session).getChild(JcrLexicon.SYSTEM);
if (ref == null) {
root.linkChild(session, systemKey, JcrLexicon.SYSTEM);
session.save();
}
// And notify the others ...
String userId = context.getSecurityContext().getUserName();
Map<String, String> userData = context.getData();
DateTime timestamp = context.getValueFactories().getDateFactory().create();
RecordingChanges changes = new RecordingChanges(context.getId(), context.getProcessId(), this.getKey(), null,
repositoryEnvironment.journalId());
changes.workspaceAdded(name);
changes.freeze(userId, userData, timestamp);
this.changeBus.notify(changes);
}
return workspace(name);
} | java | public WorkspaceCache createWorkspace( String name ) {
if (!workspaceNames.contains(name)) {
if (!configuration.isCreatingWorkspacesAllowed()) {
throw new UnsupportedOperationException(JcrI18n.creatingWorkspacesIsNotAllowedInRepository.text(getName()));
}
// Otherwise, create the workspace and persist it ...
this.workspaceNames.add(name);
refreshRepositoryMetadata(true);
// Now make sure that the "/jcr:system" node is a child of the root node ...
SessionCache session = createSession(context, name, false);
MutableCachedNode root = session.mutable(session.getRootKey());
ChildReference ref = root.getChildReferences(session).getChild(JcrLexicon.SYSTEM);
if (ref == null) {
root.linkChild(session, systemKey, JcrLexicon.SYSTEM);
session.save();
}
// And notify the others ...
String userId = context.getSecurityContext().getUserName();
Map<String, String> userData = context.getData();
DateTime timestamp = context.getValueFactories().getDateFactory().create();
RecordingChanges changes = new RecordingChanges(context.getId(), context.getProcessId(), this.getKey(), null,
repositoryEnvironment.journalId());
changes.workspaceAdded(name);
changes.freeze(userId, userData, timestamp);
this.changeBus.notify(changes);
}
return workspace(name);
} | [
"public",
"WorkspaceCache",
"createWorkspace",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"!",
"workspaceNames",
".",
"contains",
"(",
"name",
")",
")",
"{",
"if",
"(",
"!",
"configuration",
".",
"isCreatingWorkspacesAllowed",
"(",
")",
")",
"{",
"throw",
... | Create a new workspace in this repository, if the repository is appropriately configured. If the repository already
contains a workspace with the supplied name, then this method simply returns that workspace. Otherwise, this method
attempts to create the named workspace and will return a cache for this newly-created workspace.
@param name the workspace name
@return the workspace cache for the new (or existing) workspace; never null
@throws UnsupportedOperationException if this repository was not configured to allow
{@link RepositoryConfiguration#isCreatingWorkspacesAllowed() creation of workspaces}. | [
"Create",
"a",
"new",
"workspace",
"in",
"this",
"repository",
"if",
"the",
"repository",
"is",
"appropriately",
"configured",
".",
"If",
"the",
"repository",
"already",
"contains",
"a",
"workspace",
"with",
"the",
"supplied",
"name",
"then",
"this",
"method",
... | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/cache/RepositoryCache.java#L779-L808 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/cache/RepositoryCache.java | RepositoryCache.createExternalWorkspace | public WorkspaceCache createExternalWorkspace(String name, Connectors connectors) {
String[] tokens = name.split(":");
String sourceName = tokens[0];
String workspaceName = tokens[1];
this.workspaceNames.add(workspaceName);
refreshRepositoryMetadata(true);
ConcurrentMap<NodeKey, CachedNode> nodeCache = cacheForWorkspace().asMap();
ExecutionContext context = context();
//the name of the external connector is used for source name and workspace name
String sourceKey = NodeKey.keyForSourceName(sourceName);
String workspaceKey = NodeKey.keyForWorkspaceName(workspaceName);
//ask external system to determine root identifier.
Connector connector = connectors.getConnectorForSourceName(sourceName);
if (connector == null) {
throw new IllegalArgumentException(JcrI18n.connectorNotFound.text(sourceName));
}
FederatedDocumentStore documentStore = new FederatedDocumentStore(connectors, this.documentStore().localStore());
String rootId = connector.getRootDocumentId();
// Compute the root key for this workspace ...
NodeKey rootKey = new NodeKey(sourceKey, workspaceKey, rootId);
// We know that this workspace is not the system workspace, so find it ...
final WorkspaceCache systemWorkspaceCache = workspaceCachesByName.get(systemWorkspaceName);
WorkspaceCache workspaceCache = new WorkspaceCache(context, getKey(),
workspaceName, systemWorkspaceCache, documentStore, translator, rootKey, nodeCache, changeBus, repositoryEnvironment());
workspaceCachesByName.put(workspaceName, workspaceCache);
return workspace(workspaceName);
} | java | public WorkspaceCache createExternalWorkspace(String name, Connectors connectors) {
String[] tokens = name.split(":");
String sourceName = tokens[0];
String workspaceName = tokens[1];
this.workspaceNames.add(workspaceName);
refreshRepositoryMetadata(true);
ConcurrentMap<NodeKey, CachedNode> nodeCache = cacheForWorkspace().asMap();
ExecutionContext context = context();
//the name of the external connector is used for source name and workspace name
String sourceKey = NodeKey.keyForSourceName(sourceName);
String workspaceKey = NodeKey.keyForWorkspaceName(workspaceName);
//ask external system to determine root identifier.
Connector connector = connectors.getConnectorForSourceName(sourceName);
if (connector == null) {
throw new IllegalArgumentException(JcrI18n.connectorNotFound.text(sourceName));
}
FederatedDocumentStore documentStore = new FederatedDocumentStore(connectors, this.documentStore().localStore());
String rootId = connector.getRootDocumentId();
// Compute the root key for this workspace ...
NodeKey rootKey = new NodeKey(sourceKey, workspaceKey, rootId);
// We know that this workspace is not the system workspace, so find it ...
final WorkspaceCache systemWorkspaceCache = workspaceCachesByName.get(systemWorkspaceName);
WorkspaceCache workspaceCache = new WorkspaceCache(context, getKey(),
workspaceName, systemWorkspaceCache, documentStore, translator, rootKey, nodeCache, changeBus, repositoryEnvironment());
workspaceCachesByName.put(workspaceName, workspaceCache);
return workspace(workspaceName);
} | [
"public",
"WorkspaceCache",
"createExternalWorkspace",
"(",
"String",
"name",
",",
"Connectors",
"connectors",
")",
"{",
"String",
"[",
"]",
"tokens",
"=",
"name",
".",
"split",
"(",
"\":\"",
")",
";",
"String",
"sourceName",
"=",
"tokens",
"[",
"0",
"]",
... | Creates a new workspace in the repository coupled with external document
store.
@param name the name of the repository
@param connectors connectors to the external systems.
@return workspace cache for the new workspace. | [
"Creates",
"a",
"new",
"workspace",
"in",
"the",
"repository",
"coupled",
"with",
"external",
"document",
"store",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/cache/RepositoryCache.java#L891-L927 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/cache/RepositoryCache.java | RepositoryCache.createSession | public SessionCache createSession(ExecutionContext context,
String workspaceName,
boolean readOnly) {
WorkspaceCache workspaceCache = workspace(workspaceName);
if (readOnly) {
return new ReadOnlySessionCache(context, workspaceCache);
}
return new WritableSessionCache(context, workspaceCache, txWorkspaceCaches, repositoryEnvironment);
} | java | public SessionCache createSession(ExecutionContext context,
String workspaceName,
boolean readOnly) {
WorkspaceCache workspaceCache = workspace(workspaceName);
if (readOnly) {
return new ReadOnlySessionCache(context, workspaceCache);
}
return new WritableSessionCache(context, workspaceCache, txWorkspaceCaches, repositoryEnvironment);
} | [
"public",
"SessionCache",
"createSession",
"(",
"ExecutionContext",
"context",
",",
"String",
"workspaceName",
",",
"boolean",
"readOnly",
")",
"{",
"WorkspaceCache",
"workspaceCache",
"=",
"workspace",
"(",
"workspaceName",
")",
";",
"if",
"(",
"readOnly",
")",
"... | Create a session for the workspace with the given name, using the supplied ExecutionContext for the session.
@param context the context for the new session; may not be null
@param workspaceName the name of the workspace; may not be null
@param readOnly true if the session is to be read-only
@return the new session that supports writes; never null
@throws WorkspaceNotFoundException if no such workspace exists | [
"Create",
"a",
"session",
"for",
"the",
"workspace",
"with",
"the",
"given",
"name",
"using",
"the",
"supplied",
"ExecutionContext",
"for",
"the",
"session",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/cache/RepositoryCache.java#L938-L946 | train |
ModeShape/modeshape | sequencers/modeshape-sequencer-text/src/main/java/org/modeshape/sequencer/text/FixedWidthTextSequencer.java | FixedWidthTextSequencer.setColumnStartPositions | public void setColumnStartPositions( String commaDelimitedColumnStartPositions ) {
CheckArg.isNotNull(commaDelimitedColumnStartPositions, "commaDelimitedColumnStartPositions");
String[] stringStartPositions = commaDelimitedColumnStartPositions.split(",");
int[] columnStartPositions = new int[stringStartPositions.length];
for (int i = 0; i < stringStartPositions.length; i++) {
columnStartPositions[i] = Integer.valueOf(stringStartPositions[i]);
}
setColumnStartPositions(columnStartPositions);
} | java | public void setColumnStartPositions( String commaDelimitedColumnStartPositions ) {
CheckArg.isNotNull(commaDelimitedColumnStartPositions, "commaDelimitedColumnStartPositions");
String[] stringStartPositions = commaDelimitedColumnStartPositions.split(",");
int[] columnStartPositions = new int[stringStartPositions.length];
for (int i = 0; i < stringStartPositions.length; i++) {
columnStartPositions[i] = Integer.valueOf(stringStartPositions[i]);
}
setColumnStartPositions(columnStartPositions);
} | [
"public",
"void",
"setColumnStartPositions",
"(",
"String",
"commaDelimitedColumnStartPositions",
")",
"{",
"CheckArg",
".",
"isNotNull",
"(",
"commaDelimitedColumnStartPositions",
",",
"\"commaDelimitedColumnStartPositions\"",
")",
";",
"String",
"[",
"]",
"stringStartPositi... | Set the column start positions from a list of column start positions concatenated into a single, comma-delimited string.
@param commaDelimitedColumnStartPositions a list of column start positions concatenated into a single, comma-delimited
string; may not be null
@see #setColumnStartPositions(int[]) | [
"Set",
"the",
"column",
"start",
"positions",
"from",
"a",
"list",
"of",
"column",
"start",
"positions",
"concatenated",
"into",
"a",
"single",
"comma",
"-",
"delimited",
"string",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-text/src/main/java/org/modeshape/sequencer/text/FixedWidthTextSequencer.java#L70-L81 | train |
ModeShape/modeshape | web/modeshape-web-jcr-webdav/src/main/java/org/modeshape/web/jcr/webdav/DefaultContentMapper.java | DefaultContentMapper.setFor | private static Set<String> setFor( String... elements ) {
Set<String> set = new HashSet<String>(elements.length);
set.addAll(Arrays.asList(elements));
return set;
} | java | private static Set<String> setFor( String... elements ) {
Set<String> set = new HashSet<String>(elements.length);
set.addAll(Arrays.asList(elements));
return set;
} | [
"private",
"static",
"Set",
"<",
"String",
">",
"setFor",
"(",
"String",
"...",
"elements",
")",
"{",
"Set",
"<",
"String",
">",
"set",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
"elements",
".",
"length",
")",
";",
"set",
".",
"addAll",
"(",
... | Returns an unmodifiable set containing the elements passed in to this method
@param elements a set of elements; may not be null
@return an unmodifiable set containing all of the elements in {@code elements}; never null | [
"Returns",
"an",
"unmodifiable",
"set",
"containing",
"the",
"elements",
"passed",
"in",
"to",
"this",
"method"
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-jcr-webdav/src/main/java/org/modeshape/web/jcr/webdav/DefaultContentMapper.java#L95-L100 | train |
ModeShape/modeshape | deploy/jbossas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/service/RepositoryService.java | RepositoryService.changeField | public void changeField( MappedAttributeDefinition defn,
ModelNode newValue ) throws RepositoryException, OperationFailedException {
ModeShapeEngine engine = getEngine();
String repositoryName = repositoryName();
// Get a snapshot of the current configuration ...
RepositoryConfiguration config = engine.getRepositoryConfiguration(repositoryName);
// Now start to make changes ...
Editor editor = config.edit();
// Find the Document containing the field ...
EditableDocument fieldContainer = editor;
for (String fieldName : defn.getPathToContainerOfField()) {
fieldContainer = editor.getOrCreateDocument(fieldName);
}
// Get the raw value from the model node ...
Object rawValue = defn.getTypedValue(newValue);
// Change the field ...
String fieldName = defn.getFieldName();
fieldContainer.set(fieldName, rawValue);
// Apply the changes to the current configuration ...
Changes changes = editor.getChanges();
engine.update(repositoryName, changes);
} | java | public void changeField( MappedAttributeDefinition defn,
ModelNode newValue ) throws RepositoryException, OperationFailedException {
ModeShapeEngine engine = getEngine();
String repositoryName = repositoryName();
// Get a snapshot of the current configuration ...
RepositoryConfiguration config = engine.getRepositoryConfiguration(repositoryName);
// Now start to make changes ...
Editor editor = config.edit();
// Find the Document containing the field ...
EditableDocument fieldContainer = editor;
for (String fieldName : defn.getPathToContainerOfField()) {
fieldContainer = editor.getOrCreateDocument(fieldName);
}
// Get the raw value from the model node ...
Object rawValue = defn.getTypedValue(newValue);
// Change the field ...
String fieldName = defn.getFieldName();
fieldContainer.set(fieldName, rawValue);
// Apply the changes to the current configuration ...
Changes changes = editor.getChanges();
engine.update(repositoryName, changes);
} | [
"public",
"void",
"changeField",
"(",
"MappedAttributeDefinition",
"defn",
",",
"ModelNode",
"newValue",
")",
"throws",
"RepositoryException",
",",
"OperationFailedException",
"{",
"ModeShapeEngine",
"engine",
"=",
"getEngine",
"(",
")",
";",
"String",
"repositoryName",... | Immediately change and apply the specified field in the current repository configuration to the new value.
@param defn the attribute definition for the value; may not be null
@param newValue the new string value
@throws RepositoryException if there is a problem obtaining the repository configuration or applying the change
@throws OperationFailedException if there is a problem obtaining the raw value from the supplied model node | [
"Immediately",
"change",
"and",
"apply",
"the",
"specified",
"field",
"in",
"the",
"current",
"repository",
"configuration",
"to",
"the",
"new",
"value",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/deploy/jbossas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/service/RepositoryService.java#L249-L276 | train |
ModeShape/modeshape | deploy/jbossas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/service/RepositoryService.java | RepositoryService.changeIndexProviderField | public void changeIndexProviderField( MappedAttributeDefinition defn,
ModelNode newValue,
String indexProviderName ) throws RepositoryException, OperationFailedException {
ModeShapeEngine engine = getEngine();
String repositoryName = repositoryName();
// Get a snapshot of the current configuration ...
RepositoryConfiguration config = engine.getRepositoryConfiguration(repositoryName);
// Now start to make changes ...
Editor editor = config.edit();
// Find the array of sequencer documents ...
List<String> pathToContainer = defn.getPathToContainerOfField();
EditableDocument providers = editor.getOrCreateDocument(pathToContainer.get(0));
// The container should be an array ...
for (String configuredProviderName : providers.keySet()) {
// Look for the entry with a name that matches our sequencer name ...
if (indexProviderName.equals(configuredProviderName)) {
// All these entries should be nested documents ...
EditableDocument provider = (EditableDocument)providers.get(configuredProviderName);
// Change the field ...
String fieldName = defn.getFieldName();
// Get the raw value from the model node ...
Object rawValue = defn.getTypedValue(newValue);
// And update the field ...
provider.set(fieldName, rawValue);
break;
}
}
// Get and apply the changes to the current configuration. Note that the 'update' call asynchronously
// updates the configuration, and returns a Future<JcrRepository> that we could use if we wanted to
// wait for the changes to take place. But we don't want/need to wait, so we'll not use the Future ...
Changes changes = editor.getChanges();
engine.update(repositoryName, changes);
} | java | public void changeIndexProviderField( MappedAttributeDefinition defn,
ModelNode newValue,
String indexProviderName ) throws RepositoryException, OperationFailedException {
ModeShapeEngine engine = getEngine();
String repositoryName = repositoryName();
// Get a snapshot of the current configuration ...
RepositoryConfiguration config = engine.getRepositoryConfiguration(repositoryName);
// Now start to make changes ...
Editor editor = config.edit();
// Find the array of sequencer documents ...
List<String> pathToContainer = defn.getPathToContainerOfField();
EditableDocument providers = editor.getOrCreateDocument(pathToContainer.get(0));
// The container should be an array ...
for (String configuredProviderName : providers.keySet()) {
// Look for the entry with a name that matches our sequencer name ...
if (indexProviderName.equals(configuredProviderName)) {
// All these entries should be nested documents ...
EditableDocument provider = (EditableDocument)providers.get(configuredProviderName);
// Change the field ...
String fieldName = defn.getFieldName();
// Get the raw value from the model node ...
Object rawValue = defn.getTypedValue(newValue);
// And update the field ...
provider.set(fieldName, rawValue);
break;
}
}
// Get and apply the changes to the current configuration. Note that the 'update' call asynchronously
// updates the configuration, and returns a Future<JcrRepository> that we could use if we wanted to
// wait for the changes to take place. But we don't want/need to wait, so we'll not use the Future ...
Changes changes = editor.getChanges();
engine.update(repositoryName, changes);
} | [
"public",
"void",
"changeIndexProviderField",
"(",
"MappedAttributeDefinition",
"defn",
",",
"ModelNode",
"newValue",
",",
"String",
"indexProviderName",
")",
"throws",
"RepositoryException",
",",
"OperationFailedException",
"{",
"ModeShapeEngine",
"engine",
"=",
"getEngine... | Immediately change and apply the specified index provider field in the current repository configuration to the new value.
@param defn the attribute definition for the value; may not be null
@param newValue the new string value
@param indexProviderName the name of the index provider
@throws RepositoryException if there is a problem obtaining the repository configuration or applying the change
@throws OperationFailedException if there is a problem obtaining the raw value from the supplied model node | [
"Immediately",
"change",
"and",
"apply",
"the",
"specified",
"index",
"provider",
"field",
"in",
"the",
"current",
"repository",
"configuration",
"to",
"the",
"new",
"value",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/deploy/jbossas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/service/RepositoryService.java#L287-L325 | train |
ModeShape/modeshape | deploy/jbossas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/service/RepositoryService.java | RepositoryService.changeSequencerField | public void changeSequencerField( MappedAttributeDefinition defn,
ModelNode newValue,
String sequencerName ) throws RepositoryException, OperationFailedException {
ModeShapeEngine engine = getEngine();
String repositoryName = repositoryName();
// Get a snapshot of the current configuration ...
RepositoryConfiguration config = engine.getRepositoryConfiguration(repositoryName);
// Now start to make changes ...
Editor editor = config.edit();
// Find the array of sequencer documents ...
List<String> pathToContainer = defn.getPathToContainerOfField();
EditableDocument sequencing = editor.getOrCreateDocument(pathToContainer.get(0));
EditableDocument sequencers = sequencing.getOrCreateArray(pathToContainer.get(1));
// The container should be an array ...
for (String configuredSequencerName : sequencers.keySet()) {
// Look for the entry with a name that matches our sequencer name ...
if (sequencerName.equals(configuredSequencerName)) {
// All these entries should be nested documents ...
EditableDocument sequencer = (EditableDocument)sequencers.get(configuredSequencerName);
// Change the field ...
String fieldName = defn.getFieldName();
// Get the raw value from the model node ...
Object rawValue = defn.getTypedValue(newValue);
// And update the field ...
sequencer.set(fieldName, rawValue);
break;
}
}
// Get and apply the changes to the current configuration. Note that the 'update' call asynchronously
// updates the configuration, and returns a Future<JcrRepository> that we could use if we wanted to
// wait for the changes to take place. But we don't want/need to wait, so we'll not use the Future ...
Changes changes = editor.getChanges();
engine.update(repositoryName, changes);
} | java | public void changeSequencerField( MappedAttributeDefinition defn,
ModelNode newValue,
String sequencerName ) throws RepositoryException, OperationFailedException {
ModeShapeEngine engine = getEngine();
String repositoryName = repositoryName();
// Get a snapshot of the current configuration ...
RepositoryConfiguration config = engine.getRepositoryConfiguration(repositoryName);
// Now start to make changes ...
Editor editor = config.edit();
// Find the array of sequencer documents ...
List<String> pathToContainer = defn.getPathToContainerOfField();
EditableDocument sequencing = editor.getOrCreateDocument(pathToContainer.get(0));
EditableDocument sequencers = sequencing.getOrCreateArray(pathToContainer.get(1));
// The container should be an array ...
for (String configuredSequencerName : sequencers.keySet()) {
// Look for the entry with a name that matches our sequencer name ...
if (sequencerName.equals(configuredSequencerName)) {
// All these entries should be nested documents ...
EditableDocument sequencer = (EditableDocument)sequencers.get(configuredSequencerName);
// Change the field ...
String fieldName = defn.getFieldName();
// Get the raw value from the model node ...
Object rawValue = defn.getTypedValue(newValue);
// And update the field ...
sequencer.set(fieldName, rawValue);
break;
}
}
// Get and apply the changes to the current configuration. Note that the 'update' call asynchronously
// updates the configuration, and returns a Future<JcrRepository> that we could use if we wanted to
// wait for the changes to take place. But we don't want/need to wait, so we'll not use the Future ...
Changes changes = editor.getChanges();
engine.update(repositoryName, changes);
} | [
"public",
"void",
"changeSequencerField",
"(",
"MappedAttributeDefinition",
"defn",
",",
"ModelNode",
"newValue",
",",
"String",
"sequencerName",
")",
"throws",
"RepositoryException",
",",
"OperationFailedException",
"{",
"ModeShapeEngine",
"engine",
"=",
"getEngine",
"("... | Immediately change and apply the specified sequencer field in the current repository configuration to the new value.
@param defn the attribute definition for the value; may not be null
@param newValue the new string value
@param sequencerName the name of the sequencer
@throws RepositoryException if there is a problem obtaining the repository configuration or applying the change
@throws OperationFailedException if there is a problem obtaining the raw value from the supplied model node | [
"Immediately",
"change",
"and",
"apply",
"the",
"specified",
"sequencer",
"field",
"in",
"the",
"current",
"repository",
"configuration",
"to",
"the",
"new",
"value",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/deploy/jbossas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/service/RepositoryService.java#L385-L424 | train |
ModeShape/modeshape | deploy/jbossas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/service/RepositoryService.java | RepositoryService.changePersistenceField | public void changePersistenceField(MappedAttributeDefinition defn,
ModelNode newValue) throws RepositoryException, OperationFailedException {
ModeShapeEngine engine = getEngine();
String repositoryName = repositoryName();
// Get a snapshot of the current configuration ...
RepositoryConfiguration config = engine.getRepositoryConfiguration(repositoryName);
// Now start to make changes ...
Editor editor = config.edit();
EditableDocument persistence = editor.getOrCreateDocument(FieldName.STORAGE).getOrCreateDocument(FieldName.PERSISTENCE);
// Change the field ...
String fieldName = defn.getFieldName();
// Get the raw value from the model node ...
Object rawValue = defn.getTypedValue(newValue);
// And update the field ...
persistence.set(fieldName, rawValue);
// Get and apply the changes to the current configuration. Note that the 'update' call asynchronously
// updates the configuration, and returns a Future<JcrRepository> that we could use if we wanted to
// wait for the changes to take place. But we don't want/need to wait, so we'll not use the Future ...
Changes changes = editor.getChanges();
engine.update(repositoryName, changes);
} | java | public void changePersistenceField(MappedAttributeDefinition defn,
ModelNode newValue) throws RepositoryException, OperationFailedException {
ModeShapeEngine engine = getEngine();
String repositoryName = repositoryName();
// Get a snapshot of the current configuration ...
RepositoryConfiguration config = engine.getRepositoryConfiguration(repositoryName);
// Now start to make changes ...
Editor editor = config.edit();
EditableDocument persistence = editor.getOrCreateDocument(FieldName.STORAGE).getOrCreateDocument(FieldName.PERSISTENCE);
// Change the field ...
String fieldName = defn.getFieldName();
// Get the raw value from the model node ...
Object rawValue = defn.getTypedValue(newValue);
// And update the field ...
persistence.set(fieldName, rawValue);
// Get and apply the changes to the current configuration. Note that the 'update' call asynchronously
// updates the configuration, and returns a Future<JcrRepository> that we could use if we wanted to
// wait for the changes to take place. But we don't want/need to wait, so we'll not use the Future ...
Changes changes = editor.getChanges();
engine.update(repositoryName, changes);
} | [
"public",
"void",
"changePersistenceField",
"(",
"MappedAttributeDefinition",
"defn",
",",
"ModelNode",
"newValue",
")",
"throws",
"RepositoryException",
",",
"OperationFailedException",
"{",
"ModeShapeEngine",
"engine",
"=",
"getEngine",
"(",
")",
";",
"String",
"repos... | Immediately change and apply the specified persistence field to the repository configuration
@param defn the attribute definition for the value; may not be null
@param newValue the new string value
@throws RepositoryException if there is a problem obtaining the repository configuration or applying the change
@throws OperationFailedException if there is a problem obtaining the raw value from the supplied model node | [
"Immediately",
"change",
"and",
"apply",
"the",
"specified",
"persistence",
"field",
"to",
"the",
"repository",
"configuration"
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/deploy/jbossas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/service/RepositoryService.java#L434-L458 | train |
ModeShape/modeshape | deploy/jbossas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/service/RepositoryService.java | RepositoryService.changeSourceField | public void changeSourceField( MappedAttributeDefinition defn,
ModelNode newValue,
String sourceName ) throws RepositoryException, OperationFailedException {
ModeShapeEngine engine = getEngine();
String repositoryName = repositoryName();
// Get a snapshot of the current configuration ...
RepositoryConfiguration config = engine.getRepositoryConfiguration(repositoryName);
// Now start to make changes ...
Editor editor = config.edit();
// Find the array of sequencer documents ...
EditableDocument externalSources = editor.getOrCreateDocument(FieldName.EXTERNAL_SOURCES);
EditableDocument externalSource = externalSources.getDocument(sourceName);
assert externalSource != null;
// Change the field ...
String fieldName = defn.getFieldName();
// Get the raw value from the model node ...
Object rawValue = defn.getTypedValue(newValue);
// And update the field ...
externalSource.set(fieldName, rawValue);
// Get and apply the changes to the current configuration. Note that the 'update' call asynchronously
// updates the configuration, and returns a Future<JcrRepository> that we could use if we wanted to
// wait for the changes to take place. But we don't want/need to wait, so we'll not use the Future ...
Changes changes = editor.getChanges();
engine.update(repositoryName, changes);
} | java | public void changeSourceField( MappedAttributeDefinition defn,
ModelNode newValue,
String sourceName ) throws RepositoryException, OperationFailedException {
ModeShapeEngine engine = getEngine();
String repositoryName = repositoryName();
// Get a snapshot of the current configuration ...
RepositoryConfiguration config = engine.getRepositoryConfiguration(repositoryName);
// Now start to make changes ...
Editor editor = config.edit();
// Find the array of sequencer documents ...
EditableDocument externalSources = editor.getOrCreateDocument(FieldName.EXTERNAL_SOURCES);
EditableDocument externalSource = externalSources.getDocument(sourceName);
assert externalSource != null;
// Change the field ...
String fieldName = defn.getFieldName();
// Get the raw value from the model node ...
Object rawValue = defn.getTypedValue(newValue);
// And update the field ...
externalSource.set(fieldName, rawValue);
// Get and apply the changes to the current configuration. Note that the 'update' call asynchronously
// updates the configuration, and returns a Future<JcrRepository> that we could use if we wanted to
// wait for the changes to take place. But we don't want/need to wait, so we'll not use the Future ...
Changes changes = editor.getChanges();
engine.update(repositoryName, changes);
} | [
"public",
"void",
"changeSourceField",
"(",
"MappedAttributeDefinition",
"defn",
",",
"ModelNode",
"newValue",
",",
"String",
"sourceName",
")",
"throws",
"RepositoryException",
",",
"OperationFailedException",
"{",
"ModeShapeEngine",
"engine",
"=",
"getEngine",
"(",
")... | Immediately change and apply the specified external source field in the current repository configuration to the new value.
@param defn the attribute definition for the value; may not be null
@param newValue the new string value
@param sourceName the name of the source
@throws RepositoryException if there is a problem obtaining the repository configuration or applying the change
@throws OperationFailedException if there is a problem obtaining the raw value from the supplied model node | [
"Immediately",
"change",
"and",
"apply",
"the",
"specified",
"external",
"source",
"field",
"in",
"the",
"current",
"repository",
"configuration",
"to",
"the",
"new",
"value",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/deploy/jbossas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/service/RepositoryService.java#L469-L498 | train |
ModeShape/modeshape | deploy/jbossas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/service/RepositoryService.java | RepositoryService.changeTextExtractorField | public void changeTextExtractorField( MappedAttributeDefinition defn,
ModelNode newValue,
String extractorName ) throws RepositoryException, OperationFailedException {
ModeShapeEngine engine = getEngine();
String repositoryName = repositoryName();
// Get a snapshot of the current configuration ...
RepositoryConfiguration config = engine.getRepositoryConfiguration(repositoryName);
// Now start to make changes ...
Editor editor = config.edit();
// Find the array of sequencer documents ...
List<String> pathToContainer = defn.getPathToContainerOfField();
EditableDocument textExtracting = editor.getOrCreateDocument(pathToContainer.get(1));
EditableDocument extractors = textExtracting.getOrCreateDocument(pathToContainer.get(2));
// The container should be an array ...
for (String configuredExtractorName : extractors.keySet()) {
// Look for the entry with a name that matches our extractor name ...
if (extractorName.equals(configuredExtractorName)) {
// All these entries should be nested documents ...
EditableDocument extractor = (EditableDocument)extractors.get(configuredExtractorName);
// Change the field ...
String fieldName = defn.getFieldName();
// Get the raw value from the model node ...
Object rawValue = defn.getTypedValue(newValue);
// And update the field ...
extractor.set(fieldName, rawValue);
break;
}
}
Changes changes = editor.getChanges();
engine.update(repositoryName, changes);
} | java | public void changeTextExtractorField( MappedAttributeDefinition defn,
ModelNode newValue,
String extractorName ) throws RepositoryException, OperationFailedException {
ModeShapeEngine engine = getEngine();
String repositoryName = repositoryName();
// Get a snapshot of the current configuration ...
RepositoryConfiguration config = engine.getRepositoryConfiguration(repositoryName);
// Now start to make changes ...
Editor editor = config.edit();
// Find the array of sequencer documents ...
List<String> pathToContainer = defn.getPathToContainerOfField();
EditableDocument textExtracting = editor.getOrCreateDocument(pathToContainer.get(1));
EditableDocument extractors = textExtracting.getOrCreateDocument(pathToContainer.get(2));
// The container should be an array ...
for (String configuredExtractorName : extractors.keySet()) {
// Look for the entry with a name that matches our extractor name ...
if (extractorName.equals(configuredExtractorName)) {
// All these entries should be nested documents ...
EditableDocument extractor = (EditableDocument)extractors.get(configuredExtractorName);
// Change the field ...
String fieldName = defn.getFieldName();
// Get the raw value from the model node ...
Object rawValue = defn.getTypedValue(newValue);
// And update the field ...
extractor.set(fieldName, rawValue);
break;
}
}
Changes changes = editor.getChanges();
engine.update(repositoryName, changes);
} | [
"public",
"void",
"changeTextExtractorField",
"(",
"MappedAttributeDefinition",
"defn",
",",
"ModelNode",
"newValue",
",",
"String",
"extractorName",
")",
"throws",
"RepositoryException",
",",
"OperationFailedException",
"{",
"ModeShapeEngine",
"engine",
"=",
"getEngine",
... | Immediately change and apply the specified extractor field in the current repository configuration to the new value.
@param defn the attribute definition for the value; may not be null
@param newValue the new string value
@param extractorName the name of the sequencer
@throws RepositoryException if there is a problem obtaining the repository configuration or applying the change
@throws OperationFailedException if there is a problem obtaining the raw value from the supplied model node | [
"Immediately",
"change",
"and",
"apply",
"the",
"specified",
"extractor",
"field",
"in",
"the",
"current",
"repository",
"configuration",
"to",
"the",
"new",
"value",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/deploy/jbossas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/service/RepositoryService.java#L509-L544 | train |
ModeShape/modeshape | deploy/jbossas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/service/RepositoryService.java | RepositoryService.changeAuthenticatorField | public void changeAuthenticatorField( MappedAttributeDefinition defn,
ModelNode newValue,
String authenticatorName ) throws RepositoryException, OperationFailedException {
ModeShapeEngine engine = getEngine();
String repositoryName = repositoryName();
// Get a snapshot of the current configuration ...
RepositoryConfiguration config = engine.getRepositoryConfiguration(repositoryName);
// Now start to make changes ...
Editor editor = config.edit();
// Find the array of sequencer documents ...
EditableDocument security = editor.getOrCreateDocument(FieldName.SECURITY);
EditableArray providers = security.getOrCreateArray(FieldName.PROVIDERS);
// The container should be an array ...
for (String configuredAuthenticatorName : providers.keySet()) {
// Look for the entry with a name that matches our authenticator name ...
if (authenticatorName.equals(configuredAuthenticatorName)) {
// Find the document in the array with the name field value that matches ...
boolean found = false;
for (Object nested : providers) {
if (nested instanceof EditableDocument) {
EditableDocument doc = (EditableDocument)nested;
if (doc.getString(FieldName.NAME).equals(configuredAuthenticatorName)) {
// Change the field ...
String fieldName = defn.getFieldName();
// Get the raw value from the model node ...
Object rawValue = defn.getTypedValue(newValue);
// And update the field ...
doc.set(fieldName, rawValue);
found = true;
break;
}
}
}
if (!found) {
// Add the nested document ...
EditableDocument doc = Schematic.newDocument();
doc.set(FieldName.NAME, configuredAuthenticatorName);
// Set the field ...
String fieldName = defn.getFieldName();
// Get the raw value from the model node ...
Object rawValue = defn.getTypedValue(newValue);
// And update the field ...
doc.set(fieldName, rawValue);
providers.add(doc);
}
break;
}
}
Changes changes = editor.getChanges();
engine.update(repositoryName, changes);
} | java | public void changeAuthenticatorField( MappedAttributeDefinition defn,
ModelNode newValue,
String authenticatorName ) throws RepositoryException, OperationFailedException {
ModeShapeEngine engine = getEngine();
String repositoryName = repositoryName();
// Get a snapshot of the current configuration ...
RepositoryConfiguration config = engine.getRepositoryConfiguration(repositoryName);
// Now start to make changes ...
Editor editor = config.edit();
// Find the array of sequencer documents ...
EditableDocument security = editor.getOrCreateDocument(FieldName.SECURITY);
EditableArray providers = security.getOrCreateArray(FieldName.PROVIDERS);
// The container should be an array ...
for (String configuredAuthenticatorName : providers.keySet()) {
// Look for the entry with a name that matches our authenticator name ...
if (authenticatorName.equals(configuredAuthenticatorName)) {
// Find the document in the array with the name field value that matches ...
boolean found = false;
for (Object nested : providers) {
if (nested instanceof EditableDocument) {
EditableDocument doc = (EditableDocument)nested;
if (doc.getString(FieldName.NAME).equals(configuredAuthenticatorName)) {
// Change the field ...
String fieldName = defn.getFieldName();
// Get the raw value from the model node ...
Object rawValue = defn.getTypedValue(newValue);
// And update the field ...
doc.set(fieldName, rawValue);
found = true;
break;
}
}
}
if (!found) {
// Add the nested document ...
EditableDocument doc = Schematic.newDocument();
doc.set(FieldName.NAME, configuredAuthenticatorName);
// Set the field ...
String fieldName = defn.getFieldName();
// Get the raw value from the model node ...
Object rawValue = defn.getTypedValue(newValue);
// And update the field ...
doc.set(fieldName, rawValue);
providers.add(doc);
}
break;
}
}
Changes changes = editor.getChanges();
engine.update(repositoryName, changes);
} | [
"public",
"void",
"changeAuthenticatorField",
"(",
"MappedAttributeDefinition",
"defn",
",",
"ModelNode",
"newValue",
",",
"String",
"authenticatorName",
")",
"throws",
"RepositoryException",
",",
"OperationFailedException",
"{",
"ModeShapeEngine",
"engine",
"=",
"getEngine... | Immediately change and apply the specified authenticator field in the current repository configuration to the new value.
@param defn the attribute definition for the value; may not be null
@param newValue the new string value
@param authenticatorName the name of the authenticator
@throws RepositoryException if there is a problem obtaining the repository configuration or applying the change
@throws OperationFailedException if there is a problem obtaining the raw value from the supplied model node | [
"Immediately",
"change",
"and",
"apply",
"the",
"specified",
"authenticator",
"field",
"in",
"the",
"current",
"repository",
"configuration",
"to",
"the",
"new",
"value",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/deploy/jbossas/modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/service/RepositoryService.java#L555-L610 | train |
ModeShape/modeshape | web/modeshape-webdav/src/main/java/org/modeshape/webdav/locking/LockedObject.java | LockedObject.checkLocks | public boolean checkLocks( boolean exclusive,
int depth ) {
if (checkParents(exclusive) && checkChildren(exclusive, depth)) {
return true;
}
return false;
} | java | public boolean checkLocks( boolean exclusive,
int depth ) {
if (checkParents(exclusive) && checkChildren(exclusive, depth)) {
return true;
}
return false;
} | [
"public",
"boolean",
"checkLocks",
"(",
"boolean",
"exclusive",
",",
"int",
"depth",
")",
"{",
"if",
"(",
"checkParents",
"(",
"exclusive",
")",
"&&",
"checkChildren",
"(",
"exclusive",
",",
"depth",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"... | checks if a lock of the given exclusivity can be placed, only considering children up to "depth"
@param exclusive wheather the new lock should be exclusive
@param depth the depth to which should be checked
@return true if the lock can be placed | [
"checks",
"if",
"a",
"lock",
"of",
"the",
"given",
"exclusivity",
"can",
"be",
"placed",
"only",
"considering",
"children",
"up",
"to",
"depth"
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-webdav/src/main/java/org/modeshape/webdav/locking/LockedObject.java#L251-L257 | train |
ModeShape/modeshape | modeshape-common/src/main/java/org/modeshape/common/function/Predicate.java | Predicate.and | public Predicate<T> and( final Predicate<T> other ) {
if (other == null || other == this) return this;
return new Predicate<T>() {
@Override
public boolean test( T input ) {
return Predicate.this.test(input) && other.test(input);
}
};
} | java | public Predicate<T> and( final Predicate<T> other ) {
if (other == null || other == this) return this;
return new Predicate<T>() {
@Override
public boolean test( T input ) {
return Predicate.this.test(input) && other.test(input);
}
};
} | [
"public",
"Predicate",
"<",
"T",
">",
"and",
"(",
"final",
"Predicate",
"<",
"T",
">",
"other",
")",
"{",
"if",
"(",
"other",
"==",
"null",
"||",
"other",
"==",
"this",
")",
"return",
"this",
";",
"return",
"new",
"Predicate",
"<",
"T",
">",
"(",
... | Obtain a new predicate that performs the logical AND of this predicate and the supplied predicate.
@param other the other predicate
@return the composed predicate; never null | [
"Obtain",
"a",
"new",
"predicate",
"that",
"performs",
"the",
"logical",
"AND",
"of",
"this",
"predicate",
"and",
"the",
"supplied",
"predicate",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/function/Predicate.java#L37-L45 | train |
ModeShape/modeshape | modeshape-common/src/main/java/org/modeshape/common/function/Predicate.java | Predicate.or | public Predicate<T> or( final Predicate<T> other ) {
if (other == null || other == this) return this;
return new Predicate<T>() {
@Override
public boolean test( T input ) {
return Predicate.this.test(input) || other.test(input);
}
};
} | java | public Predicate<T> or( final Predicate<T> other ) {
if (other == null || other == this) return this;
return new Predicate<T>() {
@Override
public boolean test( T input ) {
return Predicate.this.test(input) || other.test(input);
}
};
} | [
"public",
"Predicate",
"<",
"T",
">",
"or",
"(",
"final",
"Predicate",
"<",
"T",
">",
"other",
")",
"{",
"if",
"(",
"other",
"==",
"null",
"||",
"other",
"==",
"this",
")",
"return",
"this",
";",
"return",
"new",
"Predicate",
"<",
"T",
">",
"(",
... | Obtain a new predicate that performs the logical OR of this predicate and the supplied predicate.
@param other the other predicate
@return the composed predicate; never null | [
"Obtain",
"a",
"new",
"predicate",
"that",
"performs",
"the",
"logical",
"OR",
"of",
"this",
"predicate",
"and",
"the",
"supplied",
"predicate",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/function/Predicate.java#L53-L61 | train |
ModeShape/modeshape | modeshape-common/src/main/java/org/modeshape/common/function/Predicate.java | Predicate.negate | public Predicate<T> negate() {
return new Predicate<T>() {
@Override
public boolean test( T input ) {
return !Predicate.this.test(input);
}
@Override
public Predicate<T> negate() {
return Predicate.this;
}
};
} | java | public Predicate<T> negate() {
return new Predicate<T>() {
@Override
public boolean test( T input ) {
return !Predicate.this.test(input);
}
@Override
public Predicate<T> negate() {
return Predicate.this;
}
};
} | [
"public",
"Predicate",
"<",
"T",
">",
"negate",
"(",
")",
"{",
"return",
"new",
"Predicate",
"<",
"T",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"test",
"(",
"T",
"input",
")",
"{",
"return",
"!",
"Predicate",
".",
"this",
".",
"tes... | Obtain a new predicate that performs the logical NOT of this predicate.
@return the composed predicate; never null | [
"Obtain",
"a",
"new",
"predicate",
"that",
"performs",
"the",
"logical",
"NOT",
"of",
"this",
"predicate",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/function/Predicate.java#L68-L80 | train |
ModeShape/modeshape | modeshape-common/src/main/java/org/modeshape/common/function/Predicate.java | Predicate.never | public static <T> Predicate<T> never() {
return new Predicate<T>() {
@Override
public boolean test( T input ) {
return false;
}
};
} | java | public static <T> Predicate<T> never() {
return new Predicate<T>() {
@Override
public boolean test( T input ) {
return false;
}
};
} | [
"public",
"static",
"<",
"T",
">",
"Predicate",
"<",
"T",
">",
"never",
"(",
")",
"{",
"return",
"new",
"Predicate",
"<",
"T",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"test",
"(",
"T",
"input",
")",
"{",
"return",
"false",
";",
... | Return a predicate that is never satisfied.
@return the predicate; never null | [
"Return",
"a",
"predicate",
"that",
"is",
"never",
"satisfied",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/function/Predicate.java#L87-L94 | train |
ModeShape/modeshape | modeshape-common/src/main/java/org/modeshape/common/function/Predicate.java | Predicate.always | public static <T> Predicate<T> always() {
return new Predicate<T>() {
@Override
public boolean test( T input ) {
return true;
}
};
} | java | public static <T> Predicate<T> always() {
return new Predicate<T>() {
@Override
public boolean test( T input ) {
return true;
}
};
} | [
"public",
"static",
"<",
"T",
">",
"Predicate",
"<",
"T",
">",
"always",
"(",
")",
"{",
"return",
"new",
"Predicate",
"<",
"T",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"test",
"(",
"T",
"input",
")",
"{",
"return",
"true",
";",
... | Return a predicate that is always satisfied.
@return the predicate; never null | [
"Return",
"a",
"predicate",
"that",
"is",
"always",
"satisfied",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/function/Predicate.java#L101-L108 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.