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
web/modeshape-web-jcr-rest/src/main/java/org/modeshape/web/jcr/rest/RestHelper.java
RestHelper.urlFrom
public static String urlFrom( String baseUrl, String... pathSegments ) { StringBuilder urlBuilder = new StringBuilder(baseUrl); if (urlBuilder.charAt(urlBuilder.length() - 1) == '/') { urlBuilder.deleteCharAt(urlBuilder.length() - 1); } for (String pathSegment : pathSegments) { if (pathSegment.equalsIgnoreCase("..")) { urlBuilder.delete(urlBuilder.lastIndexOf("/"), urlBuilder.length()); } else { if (!pathSegment.startsWith("/")) { urlBuilder.append("/"); } urlBuilder.append(pathSegment); } } return urlBuilder.toString(); }
java
public static String urlFrom( String baseUrl, String... pathSegments ) { StringBuilder urlBuilder = new StringBuilder(baseUrl); if (urlBuilder.charAt(urlBuilder.length() - 1) == '/') { urlBuilder.deleteCharAt(urlBuilder.length() - 1); } for (String pathSegment : pathSegments) { if (pathSegment.equalsIgnoreCase("..")) { urlBuilder.delete(urlBuilder.lastIndexOf("/"), urlBuilder.length()); } else { if (!pathSegment.startsWith("/")) { urlBuilder.append("/"); } urlBuilder.append(pathSegment); } } return urlBuilder.toString(); }
[ "public", "static", "String", "urlFrom", "(", "String", "baseUrl", ",", "String", "...", "pathSegments", ")", "{", "StringBuilder", "urlBuilder", "=", "new", "StringBuilder", "(", "baseUrl", ")", ";", "if", "(", "urlBuilder", ".", "charAt", "(", "urlBuilder", ...
Creates an url using base url and appending optional segments. @param baseUrl a {@code non-null} string which will act as a base. @param pathSegments an option array of segments @return a string representing an absolute-url
[ "Creates", "an", "url", "using", "base", "url", "and", "appending", "optional", "segments", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-jcr-rest/src/main/java/org/modeshape/web/jcr/rest/RestHelper.java#L101-L118
train
ModeShape/modeshape
web/modeshape-web-jcr-rest/src/main/java/org/modeshape/web/jcr/rest/RestHelper.java
RestHelper.jsonValueToJCRValue
public static Value jsonValueToJCRValue( Object value, ValueFactory valueFactory ) { if (value == null) { return null; } // try the datatypes that can be handled by Jettison if (value instanceof Integer || value instanceof Long) { return valueFactory.createValue(((Number)value).longValue()); } else if (value instanceof Double || value instanceof Float) { return valueFactory.createValue(((Number)value).doubleValue()); } else if (value instanceof Boolean) { return valueFactory.createValue((Boolean)value); } // try to convert to a date String valueString = value.toString(); for (DateFormat dateFormat : ISO8601_DATE_PARSERS) { try { Date date = dateFormat.parse(valueString); return valueFactory.createValue(date); } catch (ParseException e) { // ignore } catch (ValueFormatException e) { // ignore } } // default to a string return valueFactory.createValue(valueString); }
java
public static Value jsonValueToJCRValue( Object value, ValueFactory valueFactory ) { if (value == null) { return null; } // try the datatypes that can be handled by Jettison if (value instanceof Integer || value instanceof Long) { return valueFactory.createValue(((Number)value).longValue()); } else if (value instanceof Double || value instanceof Float) { return valueFactory.createValue(((Number)value).doubleValue()); } else if (value instanceof Boolean) { return valueFactory.createValue((Boolean)value); } // try to convert to a date String valueString = value.toString(); for (DateFormat dateFormat : ISO8601_DATE_PARSERS) { try { Date date = dateFormat.parse(valueString); return valueFactory.createValue(date); } catch (ParseException e) { // ignore } catch (ValueFormatException e) { // ignore } } // default to a string return valueFactory.createValue(valueString); }
[ "public", "static", "Value", "jsonValueToJCRValue", "(", "Object", "value", ",", "ValueFactory", "valueFactory", ")", "{", "if", "(", "value", "==", "null", ")", "{", "return", "null", ";", "}", "// try the datatypes that can be handled by Jettison", "if", "(", "v...
Converts an object value coming from a JSON object, to a JCR value by attempting to convert it to a valid data type. @param value a generic value, may be {@code null} @param valueFactory a {@link ValueFactory} instance which is used to perform the conversion @return either a {@link Value} or {@code null} if the object value is {@code null}.
[ "Converts", "an", "object", "value", "coming", "from", "a", "JSON", "object", "to", "a", "JCR", "value", "by", "attempting", "to", "convert", "it", "to", "a", "valid", "data", "type", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-jcr-rest/src/main/java/org/modeshape/web/jcr/rest/RestHelper.java#L127-L157
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/value/BinaryKey.java
BinaryKey.isProperlyFormattedKey
public static boolean isProperlyFormattedKey( String hexadecimalStr ) { if (hexadecimalStr == null) return false; // Length is expected to be the same as the digest ... final int length = hexadecimalStr.length(); if (length != ALGORITHM.getHexadecimalStringLength()) return false; // The characters all must be hexadecimal digits ... return StringUtil.isHexString(hexadecimalStr); }
java
public static boolean isProperlyFormattedKey( String hexadecimalStr ) { if (hexadecimalStr == null) return false; // Length is expected to be the same as the digest ... final int length = hexadecimalStr.length(); if (length != ALGORITHM.getHexadecimalStringLength()) return false; // The characters all must be hexadecimal digits ... return StringUtil.isHexString(hexadecimalStr); }
[ "public", "static", "boolean", "isProperlyFormattedKey", "(", "String", "hexadecimalStr", ")", "{", "if", "(", "hexadecimalStr", "==", "null", ")", "return", "false", ";", "// Length is expected to be the same as the digest ...", "final", "int", "length", "=", "hexadeci...
Determine if the supplied hexadecimal string is potentially a binary key by checking the format of the string. @param hexadecimalStr the hexadecimal string; may be null @return true if the supplied string is a properly formatted hexadecimal representation of a binary key, or false otherwise
[ "Determine", "if", "the", "supplied", "hexadecimal", "string", "is", "potentially", "a", "binary", "key", "by", "checking", "the", "format", "of", "the", "string", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/value/BinaryKey.java#L48-L55
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/JcrRepository.java
JcrRepository.shutdown
Future<Boolean> shutdown() { // Create a simple executor that will do the backgrounding for us ... final ExecutorService executor = Executors.newSingleThreadExecutor(new NamedThreadFactory("modeshape-repository-stop")); try { // Submit a runnable to terminate all sessions ... return executor.submit(() -> doShutdown(false)); } finally { // Now shutdown the executor and return the future ... executor.shutdown(); } }
java
Future<Boolean> shutdown() { // Create a simple executor that will do the backgrounding for us ... final ExecutorService executor = Executors.newSingleThreadExecutor(new NamedThreadFactory("modeshape-repository-stop")); try { // Submit a runnable to terminate all sessions ... return executor.submit(() -> doShutdown(false)); } finally { // Now shutdown the executor and return the future ... executor.shutdown(); } }
[ "Future", "<", "Boolean", ">", "shutdown", "(", ")", "{", "// Create a simple executor that will do the backgrounding for us ...", "final", "ExecutorService", "executor", "=", "Executors", ".", "newSingleThreadExecutor", "(", "new", "NamedThreadFactory", "(", "\"modeshape-rep...
Terminate all active sessions. @return a future representing the asynchronous session termination process.
[ "Terminate", "all", "active", "sessions", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/JcrRepository.java#L310-L320
train
ModeShape/modeshape
web/modeshape-web-explorer/src/main/java/org/modeshape/web/BackupUploadServlet.java
BackupUploadServlet.getParameter
private String getParameter(List<FileItem> items, String name) { for (FileItem i : items) { if (i.isFormField() && i.getFieldName().equals(name)) { return i.getString(); } } return null; }
java
private String getParameter(List<FileItem> items, String name) { for (FileItem i : items) { if (i.isFormField() && i.getFieldName().equals(name)) { return i.getString(); } } return null; }
[ "private", "String", "getParameter", "(", "List", "<", "FileItem", ">", "items", ",", "String", "name", ")", "{", "for", "(", "FileItem", "i", ":", "items", ")", "{", "if", "(", "i", ".", "isFormField", "(", ")", "&&", "i", ".", "getFieldName", "(", ...
Extracts value of the parameter with given name. @param items @param name @return parameter value or null.
[ "Extracts", "value", "of", "the", "parameter", "with", "given", "name", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/BackupUploadServlet.java#L105-L112
train
ModeShape/modeshape
web/modeshape-web-explorer/src/main/java/org/modeshape/web/BackupUploadServlet.java
BackupUploadServlet.getStream
private InputStream getStream(List<FileItem> items) throws IOException { for (FileItem i : items) { if (!i.isFormField() && i.getFieldName().equals(CONTENT_PARAMETER)) { return i.getInputStream(); } } return null; }
java
private InputStream getStream(List<FileItem> items) throws IOException { for (FileItem i : items) { if (!i.isFormField() && i.getFieldName().equals(CONTENT_PARAMETER)) { return i.getInputStream(); } } return null; }
[ "private", "InputStream", "getStream", "(", "List", "<", "FileItem", ">", "items", ")", "throws", "IOException", "{", "for", "(", "FileItem", "i", ":", "items", ")", "{", "if", "(", "!", "i", ".", "isFormField", "(", ")", "&&", "i", ".", "getFieldName"...
Gets uploaded file as stream. @param items @return the stream @throws IOException
[ "Gets", "uploaded", "file", "as", "stream", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/BackupUploadServlet.java#L121-L128
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java
CheckArg.isNotLessThan
public static void isNotLessThan( int argument, int notLessThanValue, String name ) { if (argument < notLessThanValue) { throw new IllegalArgumentException(CommonI18n.argumentMayNotBeLessThan.text(name, argument, notLessThanValue)); } }
java
public static void isNotLessThan( int argument, int notLessThanValue, String name ) { if (argument < notLessThanValue) { throw new IllegalArgumentException(CommonI18n.argumentMayNotBeLessThan.text(name, argument, notLessThanValue)); } }
[ "public", "static", "void", "isNotLessThan", "(", "int", "argument", ",", "int", "notLessThanValue", ",", "String", "name", ")", "{", "if", "(", "argument", "<", "notLessThanValue", ")", "{", "throw", "new", "IllegalArgumentException", "(", "CommonI18n", ".", ...
Check that the argument is not less than the supplied value @param argument The argument @param notLessThanValue the value that is to be used to check the value @param name The name of the argument @throws IllegalArgumentException If argument greater than or equal to the supplied vlaue
[ "Check", "that", "the", "argument", "is", "not", "less", "than", "the", "supplied", "value" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java#L41-L47
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java
CheckArg.isNotGreaterThan
public static void isNotGreaterThan( int argument, int notGreaterThanValue, String name ) { if (argument > notGreaterThanValue) { throw new IllegalArgumentException(CommonI18n.argumentMayNotBeGreaterThan.text(name, argument, notGreaterThanValue)); } }
java
public static void isNotGreaterThan( int argument, int notGreaterThanValue, String name ) { if (argument > notGreaterThanValue) { throw new IllegalArgumentException(CommonI18n.argumentMayNotBeGreaterThan.text(name, argument, notGreaterThanValue)); } }
[ "public", "static", "void", "isNotGreaterThan", "(", "int", "argument", ",", "int", "notGreaterThanValue", ",", "String", "name", ")", "{", "if", "(", "argument", ">", "notGreaterThanValue", ")", "{", "throw", "new", "IllegalArgumentException", "(", "CommonI18n", ...
Check that the argument is not greater than the supplied value @param argument The argument @param notGreaterThanValue the value that is to be used to check the value @param name The name of the argument @throws IllegalArgumentException If argument is less than or equal to the supplied value
[ "Check", "that", "the", "argument", "is", "not", "greater", "than", "the", "supplied", "value" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java#L57-L63
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java
CheckArg.isGreaterThan
public static void isGreaterThan( int argument, int greaterThanValue, String name ) { if (argument <= greaterThanValue) { throw new IllegalArgumentException(CommonI18n.argumentMustBeGreaterThan.text(name, argument, greaterThanValue)); } }
java
public static void isGreaterThan( int argument, int greaterThanValue, String name ) { if (argument <= greaterThanValue) { throw new IllegalArgumentException(CommonI18n.argumentMustBeGreaterThan.text(name, argument, greaterThanValue)); } }
[ "public", "static", "void", "isGreaterThan", "(", "int", "argument", ",", "int", "greaterThanValue", ",", "String", "name", ")", "{", "if", "(", "argument", "<=", "greaterThanValue", ")", "{", "throw", "new", "IllegalArgumentException", "(", "CommonI18n", ".", ...
Check that the argument is greater than the supplied value @param argument The argument @param greaterThanValue the value that is to be used to check the value @param name The name of the argument @throws IllegalArgumentException If argument is not greater than the supplied value
[ "Check", "that", "the", "argument", "is", "greater", "than", "the", "supplied", "value" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java#L73-L79
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java
CheckArg.isLessThan
public static void isLessThan( int argument, int lessThanValue, String name ) { if (argument >= lessThanValue) { throw new IllegalArgumentException(CommonI18n.argumentMustBeLessThan.text(name, argument, lessThanValue)); } }
java
public static void isLessThan( int argument, int lessThanValue, String name ) { if (argument >= lessThanValue) { throw new IllegalArgumentException(CommonI18n.argumentMustBeLessThan.text(name, argument, lessThanValue)); } }
[ "public", "static", "void", "isLessThan", "(", "int", "argument", ",", "int", "lessThanValue", ",", "String", "name", ")", "{", "if", "(", "argument", ">=", "lessThanValue", ")", "{", "throw", "new", "IllegalArgumentException", "(", "CommonI18n", ".", "argumen...
Check that the argument is less than the supplied value @param argument The argument @param lessThanValue the value that is to be used to check the value @param name The name of the argument @throws IllegalArgumentException If argument is not less than the supplied value
[ "Check", "that", "the", "argument", "is", "less", "than", "the", "supplied", "value" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java#L105-L111
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java
CheckArg.isGreaterThanOrEqualTo
public static void isGreaterThanOrEqualTo( int argument, int greaterThanOrEqualToValue, String name ) { if (argument < greaterThanOrEqualToValue) { throw new IllegalArgumentException(CommonI18n.argumentMustBeGreaterThanOrEqualTo.text(name, argument, greaterThanOrEqualToValue)); } }
java
public static void isGreaterThanOrEqualTo( int argument, int greaterThanOrEqualToValue, String name ) { if (argument < greaterThanOrEqualToValue) { throw new IllegalArgumentException(CommonI18n.argumentMustBeGreaterThanOrEqualTo.text(name, argument, greaterThanOrEqualToValue)); } }
[ "public", "static", "void", "isGreaterThanOrEqualTo", "(", "int", "argument", ",", "int", "greaterThanOrEqualToValue", ",", "String", "name", ")", "{", "if", "(", "argument", "<", "greaterThanOrEqualToValue", ")", "{", "throw", "new", "IllegalArgumentException", "("...
Check that the argument is greater than or equal to the supplied value @param argument The argument @param greaterThanOrEqualToValue the value that is to be used to check the value @param name The name of the argument @throws IllegalArgumentException If argument is not greater than or equal to the supplied value
[ "Check", "that", "the", "argument", "is", "greater", "than", "or", "equal", "to", "the", "supplied", "value" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java#L121-L128
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java
CheckArg.isLessThanOrEqualTo
public static void isLessThanOrEqualTo( int argument, int lessThanOrEqualToValue, String name ) { if (argument > lessThanOrEqualToValue) { throw new IllegalArgumentException(CommonI18n.argumentMustBeLessThanOrEqualTo.text(name, argument, lessThanOrEqualToValue)); } }
java
public static void isLessThanOrEqualTo( int argument, int lessThanOrEqualToValue, String name ) { if (argument > lessThanOrEqualToValue) { throw new IllegalArgumentException(CommonI18n.argumentMustBeLessThanOrEqualTo.text(name, argument, lessThanOrEqualToValue)); } }
[ "public", "static", "void", "isLessThanOrEqualTo", "(", "int", "argument", ",", "int", "lessThanOrEqualToValue", ",", "String", "name", ")", "{", "if", "(", "argument", ">", "lessThanOrEqualToValue", ")", "{", "throw", "new", "IllegalArgumentException", "(", "Comm...
Check that the argument is less than or equal to the supplied value @param argument The argument @param lessThanOrEqualToValue the value that is to be used to check the value @param name The name of the argument @throws IllegalArgumentException If argument is not less than or equal to the supplied value
[ "Check", "that", "the", "argument", "is", "less", "than", "or", "equal", "to", "the", "supplied", "value" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java#L138-L145
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java
CheckArg.isPowerOfTwo
public static void isPowerOfTwo( int argument, String name ) { if (Integer.bitCount(argument) != 1) { throw new IllegalArgumentException(CommonI18n.argumentMustBePowerOfTwo.text(name, argument)); } }
java
public static void isPowerOfTwo( int argument, String name ) { if (Integer.bitCount(argument) != 1) { throw new IllegalArgumentException(CommonI18n.argumentMustBePowerOfTwo.text(name, argument)); } }
[ "public", "static", "void", "isPowerOfTwo", "(", "int", "argument", ",", "String", "name", ")", "{", "if", "(", "Integer", ".", "bitCount", "(", "argument", ")", "!=", "1", ")", "{", "throw", "new", "IllegalArgumentException", "(", "CommonI18n", ".", "argu...
Check that the argument is a power of 2. @param argument The argument @param name The name of the argument @throws IllegalArgumentException If argument is not a power of 2
[ "Check", "that", "the", "argument", "is", "a", "power", "of", "2", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java#L210-L215
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java
CheckArg.isNotNan
public static void isNotNan( double argument, String name ) { if (Double.isNaN(argument)) { throw new IllegalArgumentException(CommonI18n.argumentMustBeNumber.text(name)); } }
java
public static void isNotNan( double argument, String name ) { if (Double.isNaN(argument)) { throw new IllegalArgumentException(CommonI18n.argumentMustBeNumber.text(name)); } }
[ "public", "static", "void", "isNotNan", "(", "double", "argument", ",", "String", "name", ")", "{", "if", "(", "Double", ".", "isNaN", "(", "argument", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "CommonI18n", ".", "argumentMustBeNumber", ...
Check that the argument is not NaN. @param argument The argument @param name The name of the argument @throws IllegalArgumentException If argument is NaN
[ "Check", "that", "the", "argument", "is", "not", "NaN", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java#L340-L345
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java
CheckArg.isNotZeroLength
public static void isNotZeroLength( String argument, String name ) { isNotNull(argument, name); if (argument.length() <= 0) { throw new IllegalArgumentException(CommonI18n.argumentMayNotBeNullOrZeroLength.text(name)); } }
java
public static void isNotZeroLength( String argument, String name ) { isNotNull(argument, name); if (argument.length() <= 0) { throw new IllegalArgumentException(CommonI18n.argumentMayNotBeNullOrZeroLength.text(name)); } }
[ "public", "static", "void", "isNotZeroLength", "(", "String", "argument", ",", "String", "name", ")", "{", "isNotNull", "(", "argument", ",", "name", ")", ";", "if", "(", "argument", ".", "length", "(", ")", "<=", "0", ")", "{", "throw", "new", "Illega...
Check that the string is non-null and has length > 0 @param argument The argument @param name The name of the argument @throws IllegalArgumentException If value is null or length == 0
[ "Check", "that", "the", "string", "is", "non", "-", "null", "and", "has", "length", ">", "0" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java#L356-L362
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java
CheckArg.isNotEmpty
public static void isNotEmpty( String argument, String name ) { isNotZeroLength(argument, name); if (argument != null && argument.trim().length() == 0) { throw new IllegalArgumentException(CommonI18n.argumentMayNotBeNullOrZeroLengthOrEmpty.text(name)); } }
java
public static void isNotEmpty( String argument, String name ) { isNotZeroLength(argument, name); if (argument != null && argument.trim().length() == 0) { throw new IllegalArgumentException(CommonI18n.argumentMayNotBeNullOrZeroLengthOrEmpty.text(name)); } }
[ "public", "static", "void", "isNotEmpty", "(", "String", "argument", ",", "String", "name", ")", "{", "isNotZeroLength", "(", "argument", ",", "name", ")", ";", "if", "(", "argument", "!=", "null", "&&", "argument", ".", "trim", "(", ")", ".", "length", ...
Check that the string is not empty, is not null, and does not contain only whitespace. @param argument String @param name The name of the argument @throws IllegalArgumentException If string is null or empty
[ "Check", "that", "the", "string", "is", "not", "empty", "is", "not", "null", "and", "does", "not", "contain", "only", "whitespace", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java#L371-L377
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java
CheckArg.isNotNull
public static void isNotNull( Object argument, String name ) { if (argument == null) { throw new IllegalArgumentException(CommonI18n.argumentMayNotBeNull.text(name)); } }
java
public static void isNotNull( Object argument, String name ) { if (argument == null) { throw new IllegalArgumentException(CommonI18n.argumentMayNotBeNull.text(name)); } }
[ "public", "static", "void", "isNotNull", "(", "Object", "argument", ",", "String", "name", ")", "{", "if", "(", "argument", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "CommonI18n", ".", "argumentMayNotBeNull", ".", "text", "(", ...
Check that the specified argument is non-null @param argument The argument @param name The name of the argument @throws IllegalArgumentException If argument is null
[ "Check", "that", "the", "specified", "argument", "is", "non", "-", "null" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java#L388-L393
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java
CheckArg.isNull
public static void isNull( Object argument, String name ) { if (argument != null) { throw new IllegalArgumentException(CommonI18n.argumentMustBeNull.text(name)); } }
java
public static void isNull( Object argument, String name ) { if (argument != null) { throw new IllegalArgumentException(CommonI18n.argumentMustBeNull.text(name)); } }
[ "public", "static", "void", "isNull", "(", "Object", "argument", ",", "String", "name", ")", "{", "if", "(", "argument", "!=", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "CommonI18n", ".", "argumentMustBeNull", ".", "text", "(", "name...
Check that the argument is null @param argument The argument @param name The name of the argument @throws IllegalArgumentException If value is non-null
[ "Check", "that", "the", "argument", "is", "null" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java#L417-L422
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java
CheckArg.isInstanceOf
public static void isInstanceOf( Object argument, Class<?> expectedClass, String name ) { isNotNull(argument, name); if (!expectedClass.isInstance(argument)) { throw new IllegalArgumentException(CommonI18n.argumentMustBeInstanceOf.text(name, argument.getClass(), expectedClass.getName())); } }
java
public static void isInstanceOf( Object argument, Class<?> expectedClass, String name ) { isNotNull(argument, name); if (!expectedClass.isInstance(argument)) { throw new IllegalArgumentException(CommonI18n.argumentMustBeInstanceOf.text(name, argument.getClass(), expectedClass.getName())); } }
[ "public", "static", "void", "isInstanceOf", "(", "Object", "argument", ",", "Class", "<", "?", ">", "expectedClass", ",", "String", "name", ")", "{", "isNotNull", "(", "argument", ",", "name", ")", ";", "if", "(", "!", "expectedClass", ".", "isInstance", ...
Check that the object is an instance of the specified Class @param argument Value @param expectedClass Class @param name The name of the argument @throws IllegalArgumentException If value is null
[ "Check", "that", "the", "object", "is", "an", "instance", "of", "the", "specified", "Class" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java#L432-L440
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java
CheckArg.getInstanceOf
public static <C> C getInstanceOf( Object argument, Class<C> expectedClass, String name ) { isInstanceOf(argument, expectedClass, name); return expectedClass.cast(argument); }
java
public static <C> C getInstanceOf( Object argument, Class<C> expectedClass, String name ) { isInstanceOf(argument, expectedClass, name); return expectedClass.cast(argument); }
[ "public", "static", "<", "C", ">", "C", "getInstanceOf", "(", "Object", "argument", ",", "Class", "<", "C", ">", "expectedClass", ",", "String", "name", ")", "{", "isInstanceOf", "(", "argument", ",", "expectedClass", ",", "name", ")", ";", "return", "ex...
due to cast in return
[ "due", "to", "cast", "in", "return" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java#L453-L458
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java
CheckArg.isNotEmpty
public static void isNotEmpty( Iterator<?> argument, String name ) { isNotNull(argument, name); if (!argument.hasNext()) { throw new IllegalArgumentException(CommonI18n.argumentMayNotBeEmpty.text(name)); } }
java
public static void isNotEmpty( Iterator<?> argument, String name ) { isNotNull(argument, name); if (!argument.hasNext()) { throw new IllegalArgumentException(CommonI18n.argumentMayNotBeEmpty.text(name)); } }
[ "public", "static", "void", "isNotEmpty", "(", "Iterator", "<", "?", ">", "argument", ",", "String", "name", ")", "{", "isNotNull", "(", "argument", ",", "name", ")", ";", "if", "(", "!", "argument", ".", "hasNext", "(", ")", ")", "{", "throw", "new"...
Checks that the iterator is not empty, and throws an exception if it is. @param argument the iterator to check @param name The name of the argument @throws IllegalArgumentException If iterator is empty (i.e., iterator.hasNext() returns false)
[ "Checks", "that", "the", "iterator", "is", "not", "empty", "and", "throws", "an", "exception", "if", "it", "is", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java#L569-L575
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java
CheckArg.isNotEmpty
public static void isNotEmpty( Collection<?> argument, String name ) { isNotNull(argument, name); if (argument.isEmpty()) { throw new IllegalArgumentException(CommonI18n.argumentMayNotBeEmpty.text(name)); } }
java
public static void isNotEmpty( Collection<?> argument, String name ) { isNotNull(argument, name); if (argument.isEmpty()) { throw new IllegalArgumentException(CommonI18n.argumentMayNotBeEmpty.text(name)); } }
[ "public", "static", "void", "isNotEmpty", "(", "Collection", "<", "?", ">", "argument", ",", "String", "name", ")", "{", "isNotNull", "(", "argument", ",", "name", ")", ";", "if", "(", "argument", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "...
Check that the collection is not empty @param argument Collection @param name The name of the argument @throws IllegalArgumentException If collection is null or empty
[ "Check", "that", "the", "collection", "is", "not", "empty" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java#L586-L592
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java
CheckArg.isEmpty
public static void isEmpty( Object[] argument, String name ) { isNotNull(argument, name); if (argument.length > 0) { throw new IllegalArgumentException(CommonI18n.argumentMustBeEmpty.text(name)); } }
java
public static void isEmpty( Object[] argument, String name ) { isNotNull(argument, name); if (argument.length > 0) { throw new IllegalArgumentException(CommonI18n.argumentMustBeEmpty.text(name)); } }
[ "public", "static", "void", "isEmpty", "(", "Object", "[", "]", "argument", ",", "String", "name", ")", "{", "isNotNull", "(", "argument", ",", "name", ")", ";", "if", "(", "argument", ".", "length", ">", "0", ")", "{", "throw", "new", "IllegalArgument...
Check that the array is empty @param argument Array @param name The name of the argument @throws IllegalArgumentException If array is not empty
[ "Check", "that", "the", "array", "is", "empty" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java#L616-L622
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java
CheckArg.isNotEmpty
public static void isNotEmpty( Object[] argument, String name ) { isNotNull(argument, name); if (argument.length == 0) { throw new IllegalArgumentException(CommonI18n.argumentMayNotBeEmpty.text(name)); } }
java
public static void isNotEmpty( Object[] argument, String name ) { isNotNull(argument, name); if (argument.length == 0) { throw new IllegalArgumentException(CommonI18n.argumentMayNotBeEmpty.text(name)); } }
[ "public", "static", "void", "isNotEmpty", "(", "Object", "[", "]", "argument", ",", "String", "name", ")", "{", "isNotNull", "(", "argument", ",", "name", ")", ";", "if", "(", "argument", ".", "length", "==", "0", ")", "{", "throw", "new", "IllegalArgu...
Check that the array is not empty @param argument Array @param name The name of the argument @throws IllegalArgumentException If array is null or empty
[ "Check", "that", "the", "array", "is", "not", "empty" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java#L631-L637
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java
CheckArg.contains
public static void contains( Collection<?> argument, Object value, String name ) { isNotNull(argument, name); if (!argument.contains(value)) { throw new IllegalArgumentException(CommonI18n.argumentDidNotContainObject.text(name, getObjectName(value))); } }
java
public static void contains( Collection<?> argument, Object value, String name ) { isNotNull(argument, name); if (!argument.contains(value)) { throw new IllegalArgumentException(CommonI18n.argumentDidNotContainObject.text(name, getObjectName(value))); } }
[ "public", "static", "void", "contains", "(", "Collection", "<", "?", ">", "argument", ",", "Object", "value", ",", "String", "name", ")", "{", "isNotNull", "(", "argument", ",", "name", ")", ";", "if", "(", "!", "argument", ".", "contains", "(", "value...
Check that the collection contains the value @param argument Collection to check @param value Value to check for, may be null @param name The name of the argument @throws IllegalArgumentException If collection is null or doesn't contain value
[ "Check", "that", "the", "collection", "contains", "the", "value" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java#L651-L658
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java
CheckArg.containsKey
public static void containsKey( Map<?, ?> argument, Object key, String name ) { isNotNull(argument, name); if (!argument.containsKey(key)) { throw new IllegalArgumentException(CommonI18n.argumentDidNotContainKey.text(name, getObjectName(key))); } }
java
public static void containsKey( Map<?, ?> argument, Object key, String name ) { isNotNull(argument, name); if (!argument.containsKey(key)) { throw new IllegalArgumentException(CommonI18n.argumentDidNotContainKey.text(name, getObjectName(key))); } }
[ "public", "static", "void", "containsKey", "(", "Map", "<", "?", ",", "?", ">", "argument", ",", "Object", "key", ",", "String", "name", ")", "{", "isNotNull", "(", "argument", ",", "name", ")", ";", "if", "(", "!", "argument", ".", "containsKey", "(...
Check that the map contains the key @param argument Map to check @param key Key to check for, may be null @param name The name of the argument @throws IllegalArgumentException If map is null or doesn't contain key
[ "Check", "that", "the", "map", "contains", "the", "key" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java#L668-L675
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java
CheckArg.containsNoNulls
public static void containsNoNulls( Iterable<?> argument, String name ) { isNotNull(argument, name); int i = 0; for (Object object : argument) { if (object == null) { throw new IllegalArgumentException(CommonI18n.argumentMayNotContainNullValue.text(name, i)); } ++i; } }
java
public static void containsNoNulls( Iterable<?> argument, String name ) { isNotNull(argument, name); int i = 0; for (Object object : argument) { if (object == null) { throw new IllegalArgumentException(CommonI18n.argumentMayNotContainNullValue.text(name, i)); } ++i; } }
[ "public", "static", "void", "containsNoNulls", "(", "Iterable", "<", "?", ">", "argument", ",", "String", "name", ")", "{", "isNotNull", "(", "argument", ",", "name", ")", ";", "int", "i", "=", "0", ";", "for", "(", "Object", "object", ":", "argument",...
Check that the collection is not null and contains no nulls @param argument Array @param name The name of the argument @throws IllegalArgumentException If array is null or has null values
[ "Check", "that", "the", "collection", "is", "not", "null", "and", "contains", "no", "nulls" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java#L684-L694
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java
CheckArg.hasSizeOfAtLeast
public static void hasSizeOfAtLeast( Collection<?> argument, int minimumSize, String name ) { isNotNull(argument, name); if (argument.size() < minimumSize) { throw new IllegalArgumentException(CommonI18n.argumentMustBeOfMinimumSize.text(name, Collection.class.getSimpleName(), argument.size(), minimumSize)); } }
java
public static void hasSizeOfAtLeast( Collection<?> argument, int minimumSize, String name ) { isNotNull(argument, name); if (argument.size() < minimumSize) { throw new IllegalArgumentException(CommonI18n.argumentMustBeOfMinimumSize.text(name, Collection.class.getSimpleName(), argument.size(), minimumSize)); } }
[ "public", "static", "void", "hasSizeOfAtLeast", "(", "Collection", "<", "?", ">", "argument", ",", "int", "minimumSize", ",", "String", "name", ")", "{", "isNotNull", "(", "argument", ",", "name", ")", ";", "if", "(", "argument", ".", "size", "(", ")", ...
Check that the collection contains at least the supplied number of elements @param argument Collection @param minimumSize the minimum size @param name The name of the argument @throws IllegalArgumentException If collection has a size smaller than the supplied value
[ "Check", "that", "the", "collection", "contains", "at", "least", "the", "supplied", "number", "of", "elements" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java#L723-L732
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java
CheckArg.hasSizeOfAtMost
public static void hasSizeOfAtMost( Collection<?> argument, int maximumSize, String name ) { isNotNull(argument, name); if (argument.size() > maximumSize) { throw new IllegalArgumentException(CommonI18n.argumentMustBeOfMinimumSize.text(name, Collection.class.getSimpleName(), argument.size(), maximumSize)); } }
java
public static void hasSizeOfAtMost( Collection<?> argument, int maximumSize, String name ) { isNotNull(argument, name); if (argument.size() > maximumSize) { throw new IllegalArgumentException(CommonI18n.argumentMustBeOfMinimumSize.text(name, Collection.class.getSimpleName(), argument.size(), maximumSize)); } }
[ "public", "static", "void", "hasSizeOfAtMost", "(", "Collection", "<", "?", ">", "argument", ",", "int", "maximumSize", ",", "String", "name", ")", "{", "isNotNull", "(", "argument", ",", "name", ")", ";", "if", "(", "argument", ".", "size", "(", ")", ...
Check that the collection contains no more than the supplied number of elements @param argument Collection @param maximumSize the maximum size @param name The name of the argument @throws IllegalArgumentException If collection has a size smaller than the supplied value
[ "Check", "that", "the", "collection", "contains", "no", "more", "than", "the", "supplied", "number", "of", "elements" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java#L742-L751
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java
CheckArg.hasSizeOfAtLeast
public static void hasSizeOfAtLeast( Object[] argument, int minimumSize, String name ) { isNotNull(argument, name); if (argument.length < minimumSize) { throw new IllegalArgumentException(CommonI18n.argumentMustBeOfMinimumSize.text(name, Object[].class.getSimpleName(), argument.length, minimumSize)); } }
java
public static void hasSizeOfAtLeast( Object[] argument, int minimumSize, String name ) { isNotNull(argument, name); if (argument.length < minimumSize) { throw new IllegalArgumentException(CommonI18n.argumentMustBeOfMinimumSize.text(name, Object[].class.getSimpleName(), argument.length, minimumSize)); } }
[ "public", "static", "void", "hasSizeOfAtLeast", "(", "Object", "[", "]", "argument", ",", "int", "minimumSize", ",", "String", "name", ")", "{", "isNotNull", "(", "argument", ",", "name", ")", ";", "if", "(", "argument", ".", "length", "<", "minimumSize", ...
Check that the array contains at least the supplied number of elements @param argument the array @param minimumSize the minimum size @param name The name of the argument @throws IllegalArgumentException If the array has a size smaller than the supplied value
[ "Check", "that", "the", "array", "contains", "at", "least", "the", "supplied", "number", "of", "elements" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java#L797-L805
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java
CheckArg.hasSizeOfAtMost
public static void hasSizeOfAtMost( Object[] argument, int maximumSize, String name ) { isNotNull(argument, name); if (argument.length > maximumSize) { throw new IllegalArgumentException(CommonI18n.argumentMustBeOfMinimumSize.text(name, Object[].class.getSimpleName(), argument.length, maximumSize)); } }
java
public static void hasSizeOfAtMost( Object[] argument, int maximumSize, String name ) { isNotNull(argument, name); if (argument.length > maximumSize) { throw new IllegalArgumentException(CommonI18n.argumentMustBeOfMinimumSize.text(name, Object[].class.getSimpleName(), argument.length, maximumSize)); } }
[ "public", "static", "void", "hasSizeOfAtMost", "(", "Object", "[", "]", "argument", ",", "int", "maximumSize", ",", "String", "name", ")", "{", "isNotNull", "(", "argument", ",", "name", ")", ";", "if", "(", "argument", ".", "length", ">", "maximumSize", ...
Check that the array contains no more than the supplied number of elements @param argument the array @param maximumSize the maximum size @param name The name of the argument @throws IllegalArgumentException If the array has a size smaller than the supplied value
[ "Check", "that", "the", "array", "contains", "no", "more", "than", "the", "supplied", "number", "of", "elements" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java#L815-L823
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/DateTimeUtil.java
DateTimeUtil.jodaFormat
public static String jodaFormat( ZonedDateTime dateTime ) { CheckArg.isNotNull(dateTime, "dateTime"); return dateTime.format(JODA_ISO8601_FORMATTER); }
java
public static String jodaFormat( ZonedDateTime dateTime ) { CheckArg.isNotNull(dateTime, "dateTime"); return dateTime.format(JODA_ISO8601_FORMATTER); }
[ "public", "static", "String", "jodaFormat", "(", "ZonedDateTime", "dateTime", ")", "{", "CheckArg", ".", "isNotNull", "(", "dateTime", ",", "\"dateTime\"", ")", ";", "return", "dateTime", ".", "format", "(", "JODA_ISO8601_FORMATTER", ")", ";", "}" ]
Returns the ISO8601 string of a given date-time instance with timezone information, trying to be as closed as possible to what the JODA date-time library would return. @param dateTime a {@link ZonedDateTime} instance, may not be null @return a {@link String} representation of the date instance according to the ISO8601 standard
[ "Returns", "the", "ISO8601", "string", "of", "a", "given", "date", "-", "time", "instance", "with", "timezone", "information", "trying", "to", "be", "as", "closed", "as", "possible", "to", "what", "the", "JODA", "date", "-", "time", "library", "would", "re...
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/DateTimeUtil.java#L93-L96
train
ModeShape/modeshape
modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/text/TextExtractor.java
TextExtractor.processStream
protected final <T> T processStream( Binary binary, BinaryOperation<T> operation ) throws Exception { InputStream stream = binary.getStream(); if (stream == null) { throw new IllegalArgumentException("The binary value is empty"); } try { return operation.execute(stream); } finally { stream.close(); } }
java
protected final <T> T processStream( Binary binary, BinaryOperation<T> operation ) throws Exception { InputStream stream = binary.getStream(); if (stream == null) { throw new IllegalArgumentException("The binary value is empty"); } try { return operation.execute(stream); } finally { stream.close(); } }
[ "protected", "final", "<", "T", ">", "T", "processStream", "(", "Binary", "binary", ",", "BinaryOperation", "<", "T", ">", "operation", ")", "throws", "Exception", "{", "InputStream", "stream", "=", "binary", ".", "getStream", "(", ")", ";", "if", "(", "...
Allows subclasses to process the stream of binary value property in "safe" fashion, making sure the stream is closed at the end of the operation. @param binary a {@link org.modeshape.jcr.api.Binary} who is expected to contain a non-null binary value. @param operation a {@link org.modeshape.jcr.api.text.TextExtractor.BinaryOperation} which should work with the stream @param <T> the return type of the binary operation @return whatever type of result the stream operation returns @throws Exception if there is an error processing the stream
[ "Allows", "subclasses", "to", "process", "the", "stream", "of", "binary", "value", "property", "in", "safe", "fashion", "making", "sure", "the", "stream", "is", "closed", "at", "the", "end", "of", "the", "operation", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/text/TextExtractor.java#L81-L93
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/parse/QueryParsers.java
QueryParsers.addLanguage
public void addLanguage( QueryParser languageParser ) { CheckArg.isNotNull(languageParser, "languageParser"); this.parsers.put(languageParser.getLanguage().trim().toLowerCase(), languageParser); }
java
public void addLanguage( QueryParser languageParser ) { CheckArg.isNotNull(languageParser, "languageParser"); this.parsers.put(languageParser.getLanguage().trim().toLowerCase(), languageParser); }
[ "public", "void", "addLanguage", "(", "QueryParser", "languageParser", ")", "{", "CheckArg", ".", "isNotNull", "(", "languageParser", ",", "\"languageParser\"", ")", ";", "this", ".", "parsers", ".", "put", "(", "languageParser", ".", "getLanguage", "(", ")", ...
Add a language to this engine by supplying its parser. @param languageParser the query parser for the language @throws IllegalArgumentException if the language parser is null
[ "Add", "a", "language", "to", "this", "engine", "by", "supplying", "its", "parser", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/parse/QueryParsers.java#L67-L70
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/parse/QueryParsers.java
QueryParsers.getLanguages
public Set<String> getLanguages() { Set<String> result = new HashSet<String>(); for (QueryParser parser : parsers.values()) { result.add(parser.getLanguage()); } return Collections.unmodifiableSet(result); }
java
public Set<String> getLanguages() { Set<String> result = new HashSet<String>(); for (QueryParser parser : parsers.values()) { result.add(parser.getLanguage()); } return Collections.unmodifiableSet(result); }
[ "public", "Set", "<", "String", ">", "getLanguages", "(", ")", "{", "Set", "<", "String", ">", "result", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "for", "(", "QueryParser", "parser", ":", "parsers", ".", "values", "(", ")", ")", "{...
Get the set of languages that this engine is capable of parsing. @return the unmodifiable copy of the set of languages; never null but possibly empty
[ "Get", "the", "set", "of", "languages", "that", "this", "engine", "is", "capable", "of", "parsing", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/parse/QueryParsers.java#L139-L145
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/parse/QueryParsers.java
QueryParsers.getParserFor
public QueryParser getParserFor( String language ) { CheckArg.isNotNull(language, "language"); return parsers.get(language.trim().toLowerCase()); }
java
public QueryParser getParserFor( String language ) { CheckArg.isNotNull(language, "language"); return parsers.get(language.trim().toLowerCase()); }
[ "public", "QueryParser", "getParserFor", "(", "String", "language", ")", "{", "CheckArg", ".", "isNotNull", "(", "language", ",", "\"language\"", ")", ";", "return", "parsers", ".", "get", "(", "language", ".", "trim", "(", ")", ".", "toLowerCase", "(", ")...
Get the parser for the supplied language. @param language the language in which the query is expressed; must case-insensitively match one of the supported {@link #getLanguages() languages} @return the query parser, or null if the supplied language is not supported @throws IllegalArgumentException if the language is null
[ "Get", "the", "parser", "for", "the", "supplied", "language", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/parse/QueryParsers.java#L155-L158
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/validate/ImmutableSchemata.java
ImmutableSchemata.createBuilder
public static Builder createBuilder( ExecutionContext context, NodeTypes nodeTypes ) { CheckArg.isNotNull(context, "context"); CheckArg.isNotNull(nodeTypes, "nodeTypes"); return new Builder(context, nodeTypes); }
java
public static Builder createBuilder( ExecutionContext context, NodeTypes nodeTypes ) { CheckArg.isNotNull(context, "context"); CheckArg.isNotNull(nodeTypes, "nodeTypes"); return new Builder(context, nodeTypes); }
[ "public", "static", "Builder", "createBuilder", "(", "ExecutionContext", "context", ",", "NodeTypes", "nodeTypes", ")", "{", "CheckArg", ".", "isNotNull", "(", "context", ",", "\"context\"", ")", ";", "CheckArg", ".", "isNotNull", "(", "nodeTypes", ",", "\"nodeT...
Obtain a new instance for building Schemata objects. @param context the execution context that this schemata should use @param nodeTypes the node types that this schemata should use @return the new builder; never null @throws IllegalArgumentException if the context is null
[ "Obtain", "a", "new", "instance", "for", "building", "Schemata", "objects", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/validate/ImmutableSchemata.java#L65-L70
train
ModeShape/modeshape
web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/contents/PermissionsEditor.java
PermissionsEditor.show
public void show(JcrNode node) { this.node = node; if (node.getAcl() == null) { this.displayDisabledEditor(); } else if (this.isAclDefined(node)) { this.selectFirstPrincipalAndDisplayPermissions(node); } else { this.displayEveryonePermissions(); } }
java
public void show(JcrNode node) { this.node = node; if (node.getAcl() == null) { this.displayDisabledEditor(); } else if (this.isAclDefined(node)) { this.selectFirstPrincipalAndDisplayPermissions(node); } else { this.displayEveryonePermissions(); } }
[ "public", "void", "show", "(", "JcrNode", "node", ")", "{", "this", ".", "node", "=", "node", ";", "if", "(", "node", ".", "getAcl", "(", ")", "==", "null", ")", "{", "this", ".", "displayDisabledEditor", "(", ")", ";", "}", "else", "if", "(", "t...
Displays permissions for the given node. @param node
[ "Displays", "permissions", "for", "the", "given", "node", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/contents/PermissionsEditor.java#L75-L84
train
ModeShape/modeshape
sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/dialect/oracle/OracleDdlParser.java
OracleDdlParser.parseMaterializedViewStatement
protected AstNode parseMaterializedViewStatement( DdlTokenStream tokens, AstNode parentNode ) throws ParsingException { assert tokens != null; assert parentNode != null; markStartOfStatement(tokens); /* ---------------------------------------------------------------------- CREATE MATERIALIZED VIEW [ schema. ]materialized_view [ column_alias [, column_alias]... ] [ OF [ schema. ]object_type ] .................... (MORE...) EXAMPLES: CREATE MATERIALIZED VIEW LOG ON products WITH ROWID, SEQUENCE (prod_id) INCLUDING NEW VALUES; CREATE MATERIALIZED VIEW sales_mv BUILD IMMEDIATE REFRESH FAST ON COMMIT AS SELECT t.calendar_year, p.prod_id, SUM(s.amount_sold) AS sum_sales FROM times t, products p, sales s WHERE t.time_id = s.time_id AND p.prod_id = s.prod_id GROUP BY t.calendar_year, p.prod_id; ---------------------------------------------------------------------- */ boolean isLog = tokens.canConsume(STMT_CREATE_MATERIALIZED_VEIW_LOG); tokens.canConsume(STMT_CREATE_MATERIALIZED_VIEW); String name = parseName(tokens); AstNode node = null; if (isLog) { node = nodeFactory().node(name, parentNode, TYPE_CREATE_MATERIALIZED_VIEW_LOG_STATEMENT); } else { node = nodeFactory().node(name, parentNode, TYPE_CREATE_MATERIALIZED_VIEW_STATEMENT); } parseUntilTerminator(tokens); markEndOfStatement(tokens, node); return node; }
java
protected AstNode parseMaterializedViewStatement( DdlTokenStream tokens, AstNode parentNode ) throws ParsingException { assert tokens != null; assert parentNode != null; markStartOfStatement(tokens); /* ---------------------------------------------------------------------- CREATE MATERIALIZED VIEW [ schema. ]materialized_view [ column_alias [, column_alias]... ] [ OF [ schema. ]object_type ] .................... (MORE...) EXAMPLES: CREATE MATERIALIZED VIEW LOG ON products WITH ROWID, SEQUENCE (prod_id) INCLUDING NEW VALUES; CREATE MATERIALIZED VIEW sales_mv BUILD IMMEDIATE REFRESH FAST ON COMMIT AS SELECT t.calendar_year, p.prod_id, SUM(s.amount_sold) AS sum_sales FROM times t, products p, sales s WHERE t.time_id = s.time_id AND p.prod_id = s.prod_id GROUP BY t.calendar_year, p.prod_id; ---------------------------------------------------------------------- */ boolean isLog = tokens.canConsume(STMT_CREATE_MATERIALIZED_VEIW_LOG); tokens.canConsume(STMT_CREATE_MATERIALIZED_VIEW); String name = parseName(tokens); AstNode node = null; if (isLog) { node = nodeFactory().node(name, parentNode, TYPE_CREATE_MATERIALIZED_VIEW_LOG_STATEMENT); } else { node = nodeFactory().node(name, parentNode, TYPE_CREATE_MATERIALIZED_VIEW_STATEMENT); } parseUntilTerminator(tokens); markEndOfStatement(tokens, node); return node; }
[ "protected", "AstNode", "parseMaterializedViewStatement", "(", "DdlTokenStream", "tokens", ",", "AstNode", "parentNode", ")", "throws", "ParsingException", "{", "assert", "tokens", "!=", "null", ";", "assert", "parentNode", "!=", "null", ";", "markStartOfStatement", "...
Parses DDL CREATE MATERIALIZED VIEW statement This could either be a standard view or a VIEW LOG ON statement. @param tokens the tokenized {@link DdlTokenStream} of the DDL input content; may not be null @param parentNode the parent {@link AstNode} node; may not be null @return the parsed CREATE MATERIALIZED VIEW statement node @throws ParsingException
[ "Parses", "DDL", "CREATE", "MATERIALIZED", "VIEW", "statement", "This", "could", "either", "be", "a", "standard", "view", "or", "a", "VIEW", "LOG", "ON", "statement", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/dialect/oracle/OracleDdlParser.java#L800-L848
train
ModeShape/modeshape
sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/dialect/oracle/OracleDdlParser.java
OracleDdlParser.parseContentBetweenParens
private String parseContentBetweenParens( final DdlTokenStream tokens ) throws ParsingException { tokens.consume(L_PAREN); // don't include first paren in expression int numLeft = 1; int numRight = 0; final StringBuilder text = new StringBuilder(); while (tokens.hasNext()) { if (tokens.matches(L_PAREN)) { ++numLeft; } else if (tokens.matches(R_PAREN)) { if (numLeft == ++numRight) { tokens.consume(R_PAREN); // don't include last paren in expression break; } } final String token = tokens.consume(); // don't add space if empty or if this token or previous token is a period if (!PERIOD.equals(token) && (text.length() != 0) && (PERIOD.charAt(0) != (text.charAt(text.length() - 1)))) { text.append(SPACE); } text.append(token); } if ((numLeft != numRight) || (text.length() == 0)) { throw new ParsingException(tokens.nextPosition()); } return text.toString(); }
java
private String parseContentBetweenParens( final DdlTokenStream tokens ) throws ParsingException { tokens.consume(L_PAREN); // don't include first paren in expression int numLeft = 1; int numRight = 0; final StringBuilder text = new StringBuilder(); while (tokens.hasNext()) { if (tokens.matches(L_PAREN)) { ++numLeft; } else if (tokens.matches(R_PAREN)) { if (numLeft == ++numRight) { tokens.consume(R_PAREN); // don't include last paren in expression break; } } final String token = tokens.consume(); // don't add space if empty or if this token or previous token is a period if (!PERIOD.equals(token) && (text.length() != 0) && (PERIOD.charAt(0) != (text.charAt(text.length() - 1)))) { text.append(SPACE); } text.append(token); } if ((numLeft != numRight) || (text.length() == 0)) { throw new ParsingException(tokens.nextPosition()); } return text.toString(); }
[ "private", "String", "parseContentBetweenParens", "(", "final", "DdlTokenStream", "tokens", ")", "throws", "ParsingException", "{", "tokens", ".", "consume", "(", "L_PAREN", ")", ";", "// don't include first paren in expression", "int", "numLeft", "=", "1", ";", "int"...
The tokens must start with a left paren, end with a right paren, and have content between. Any parens in the content must have matching parens. @param tokens the tokens being processed (cannot be <code>null</code> but or empty) @return the content (never <code>null</code> or empty. @throws ParsingException if there is a problem parsing the query expression
[ "The", "tokens", "must", "start", "with", "a", "left", "paren", "end", "with", "a", "right", "paren", "and", "have", "content", "between", ".", "Any", "parens", "in", "the", "content", "must", "have", "matching", "parens", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/dialect/oracle/OracleDdlParser.java#L1356-L1389
train
ModeShape/modeshape
sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/dialect/oracle/OracleDdlParser.java
OracleDdlParser.isColumnDefinitionStart
protected boolean isColumnDefinitionStart( DdlTokenStream tokens, String columnMixinType ) throws ParsingException { boolean result = isColumnDefinitionStart(tokens); if (!result && TYPE_ALTER_COLUMN_DEFINITION.equals(columnMixinType)) { for (String start : INLINE_COLUMN_PROPERTY_START) { if (tokens.matches(TokenStream.ANY_VALUE, start)) return true; } } return result; }
java
protected boolean isColumnDefinitionStart( DdlTokenStream tokens, String columnMixinType ) throws ParsingException { boolean result = isColumnDefinitionStart(tokens); if (!result && TYPE_ALTER_COLUMN_DEFINITION.equals(columnMixinType)) { for (String start : INLINE_COLUMN_PROPERTY_START) { if (tokens.matches(TokenStream.ANY_VALUE, start)) return true; } } return result; }
[ "protected", "boolean", "isColumnDefinitionStart", "(", "DdlTokenStream", "tokens", ",", "String", "columnMixinType", ")", "throws", "ParsingException", "{", "boolean", "result", "=", "isColumnDefinitionStart", "(", "tokens", ")", ";", "if", "(", "!", "result", "&&"...
Utility method to additionally check if MODIFY definition without datatype @param tokens a {@link DdlTokenStream} instance; may not be null @param columnMixinType a {@link String}; may not be null @return {@code true} if the given stream si at the start of the column defintion, {@code false} otherwise. @throws ParsingException
[ "Utility", "method", "to", "additionally", "check", "if", "MODIFY", "definition", "without", "datatype" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/dialect/oracle/OracleDdlParser.java#L1927-L1936
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/RowExtractors.java
RowExtractors.extractPath
public static ExtractFromRow extractPath( final int indexInRow, final NodeCache cache, TypeSystem types ) { final TypeFactory<Path> type = types.getPathFactory(); final boolean trace = NodeSequence.LOGGER.isTraceEnabled(); return new ExtractFromRow() { @Override public TypeFactory<Path> getType() { return type; } @Override public Object getValueInRow( RowAccessor row ) { CachedNode node = row.getNode(indexInRow); if (node == null) return null; Path path = node.getPath(cache); if (trace) NodeSequence.LOGGER.trace("Extracting path from {0}", path); return path; } @Override public String toString() { return "(extract-path)"; } }; }
java
public static ExtractFromRow extractPath( final int indexInRow, final NodeCache cache, TypeSystem types ) { final TypeFactory<Path> type = types.getPathFactory(); final boolean trace = NodeSequence.LOGGER.isTraceEnabled(); return new ExtractFromRow() { @Override public TypeFactory<Path> getType() { return type; } @Override public Object getValueInRow( RowAccessor row ) { CachedNode node = row.getNode(indexInRow); if (node == null) return null; Path path = node.getPath(cache); if (trace) NodeSequence.LOGGER.trace("Extracting path from {0}", path); return path; } @Override public String toString() { return "(extract-path)"; } }; }
[ "public", "static", "ExtractFromRow", "extractPath", "(", "final", "int", "indexInRow", ",", "final", "NodeCache", "cache", ",", "TypeSystem", "types", ")", "{", "final", "TypeFactory", "<", "Path", ">", "type", "=", "types", ".", "getPathFactory", "(", ")", ...
Create an extractor that extracts the path from the node at the given position in the row. @param indexInRow the index of the node in the rows; must be valid @param cache the cache containing the nodes; may not be null @param types the type system; may not be null @return the path extractor; never null
[ "Create", "an", "extractor", "that", "extracts", "the", "path", "from", "the", "node", "at", "the", "given", "position", "in", "the", "row", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/RowExtractors.java#L297-L322
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/RowExtractors.java
RowExtractors.extractParentPath
public static ExtractFromRow extractParentPath( final int indexInRow, final NodeCache cache, TypeSystem types ) { final TypeFactory<Path> type = types.getPathFactory(); final boolean trace = NodeSequence.LOGGER.isTraceEnabled(); return new ExtractFromRow() { @Override public TypeFactory<Path> getType() { return type; } @Override public Object getValueInRow( RowAccessor row ) { CachedNode node = row.getNode(indexInRow); if (node == null) return null; NodeKey parentKey = node.getParentKey(cache); if (parentKey == null) return null; CachedNode parent = cache.getNode(parentKey); if (parent == null) return null; Path parentPath = parent.getPath(cache); if (trace) NodeSequence.LOGGER.trace("Extracting parent path from {0}: {1}", node.getPath(cache), parentPath); return parentPath; } @Override public String toString() { return "(extract-parent-path)"; } }; }
java
public static ExtractFromRow extractParentPath( final int indexInRow, final NodeCache cache, TypeSystem types ) { final TypeFactory<Path> type = types.getPathFactory(); final boolean trace = NodeSequence.LOGGER.isTraceEnabled(); return new ExtractFromRow() { @Override public TypeFactory<Path> getType() { return type; } @Override public Object getValueInRow( RowAccessor row ) { CachedNode node = row.getNode(indexInRow); if (node == null) return null; NodeKey parentKey = node.getParentKey(cache); if (parentKey == null) return null; CachedNode parent = cache.getNode(parentKey); if (parent == null) return null; Path parentPath = parent.getPath(cache); if (trace) NodeSequence.LOGGER.trace("Extracting parent path from {0}: {1}", node.getPath(cache), parentPath); return parentPath; } @Override public String toString() { return "(extract-parent-path)"; } }; }
[ "public", "static", "ExtractFromRow", "extractParentPath", "(", "final", "int", "indexInRow", ",", "final", "NodeCache", "cache", ",", "TypeSystem", "types", ")", "{", "final", "TypeFactory", "<", "Path", ">", "type", "=", "types", ".", "getPathFactory", "(", ...
Create an extractor that extracts the parent path from the node at the given position in the row. @param indexInRow the index of the node in the rows; must be valid @param cache the cache containing the nodes; may not be null @param types the type system; may not be null @return the path extractor; never null
[ "Create", "an", "extractor", "that", "extracts", "the", "parent", "path", "from", "the", "node", "at", "the", "given", "position", "in", "the", "row", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/RowExtractors.java#L332-L361
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/RowExtractors.java
RowExtractors.extractRelativePath
public static ExtractFromRow extractRelativePath( final int indexInRow, final Path relativePath, final NodeCache cache, TypeSystem types ) { CheckArg.isNotNull(relativePath, "relativePath"); final TypeFactory<Path> type = types.getPathFactory(); final boolean trace = NodeSequence.LOGGER.isTraceEnabled(); return new ExtractFromRow() { @Override public TypeFactory<Path> getType() { return type; } @Override public Object getValueInRow( RowAccessor row ) { CachedNode node = row.getNode(indexInRow); if (node == null) return null; Path nodePath = node.getPath(cache); try { Path path = nodePath.resolve(relativePath); if (trace) NodeSequence.LOGGER.trace("Extracting relative path {2} from {0}: {2}", node.getPath(cache), relativePath, path); return path; } catch (InvalidPathException e) { return null; } } @Override public String toString() { return "(extract-relative-path)"; } }; }
java
public static ExtractFromRow extractRelativePath( final int indexInRow, final Path relativePath, final NodeCache cache, TypeSystem types ) { CheckArg.isNotNull(relativePath, "relativePath"); final TypeFactory<Path> type = types.getPathFactory(); final boolean trace = NodeSequence.LOGGER.isTraceEnabled(); return new ExtractFromRow() { @Override public TypeFactory<Path> getType() { return type; } @Override public Object getValueInRow( RowAccessor row ) { CachedNode node = row.getNode(indexInRow); if (node == null) return null; Path nodePath = node.getPath(cache); try { Path path = nodePath.resolve(relativePath); if (trace) NodeSequence.LOGGER.trace("Extracting relative path {2} from {0}: {2}", node.getPath(cache), relativePath, path); return path; } catch (InvalidPathException e) { return null; } } @Override public String toString() { return "(extract-relative-path)"; } }; }
[ "public", "static", "ExtractFromRow", "extractRelativePath", "(", "final", "int", "indexInRow", ",", "final", "Path", "relativePath", ",", "final", "NodeCache", "cache", ",", "TypeSystem", "types", ")", "{", "CheckArg", ".", "isNotNull", "(", "relativePath", ",", ...
Create an extractor that extracts the path from the node at the given position in the row and applies the relative path. @param indexInRow the index of the node in the rows; must be valid @param relativePath the relative path that should be applied to the nodes' path; may not be null and must be a valid relative path @param cache the cache containing the nodes; may not be null @param types the type system; may not be null @return the path extractor; never null
[ "Create", "an", "extractor", "that", "extracts", "the", "path", "from", "the", "node", "at", "the", "given", "position", "in", "the", "row", "and", "applies", "the", "relative", "path", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/RowExtractors.java#L373-L406
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/RowExtractors.java
RowExtractors.extractPropertyValue
public static ExtractFromRow extractPropertyValue( final Name propertyName, final int indexInRow, final NodeCache cache, final TypeFactory<?> desiredType ) { return new ExtractFromRow() { @Override public Object getValueInRow( RowAccessor row ) { CachedNode node = row.getNode(indexInRow); if (node == null) return null; org.modeshape.jcr.value.Property prop = node.getProperty(propertyName, cache); return prop == null ? null : desiredType.create(prop.getFirstValue()); } @Override public TypeFactory<?> getType() { return desiredType; } }; }
java
public static ExtractFromRow extractPropertyValue( final Name propertyName, final int indexInRow, final NodeCache cache, final TypeFactory<?> desiredType ) { return new ExtractFromRow() { @Override public Object getValueInRow( RowAccessor row ) { CachedNode node = row.getNode(indexInRow); if (node == null) return null; org.modeshape.jcr.value.Property prop = node.getProperty(propertyName, cache); return prop == null ? null : desiredType.create(prop.getFirstValue()); } @Override public TypeFactory<?> getType() { return desiredType; } }; }
[ "public", "static", "ExtractFromRow", "extractPropertyValue", "(", "final", "Name", "propertyName", ",", "final", "int", "indexInRow", ",", "final", "NodeCache", "cache", ",", "final", "TypeFactory", "<", "?", ">", "desiredType", ")", "{", "return", "new", "Extr...
Create an extractor that extracts the property value from the node at the given position in the row. @param propertyName the name of the property; may not be null @param indexInRow the index of the node in the rows; must be valid @param cache the cache containing the nodes; may not be null @param desiredType the desired type, which should be converted from the actual value; may not be null @return the path extractor; never null
[ "Create", "an", "extractor", "that", "extracts", "the", "property", "value", "from", "the", "node", "at", "the", "given", "position", "in", "the", "row", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/RowExtractors.java#L599-L617
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/spi/index/provider/IndexChangeAdapter.java
IndexChangeAdapter.reindex
protected final boolean reindex( String workspaceName, NodeKey key, Path path, Name primaryType, Set<Name> mixinTypes, Properties properties, boolean queryable ) { if (predicate.matchesType(primaryType, mixinTypes)) { reindexNode(workspaceName, key, path, primaryType, mixinTypes, properties, queryable); return true; } return false; }
java
protected final boolean reindex( String workspaceName, NodeKey key, Path path, Name primaryType, Set<Name> mixinTypes, Properties properties, boolean queryable ) { if (predicate.matchesType(primaryType, mixinTypes)) { reindexNode(workspaceName, key, path, primaryType, mixinTypes, properties, queryable); return true; } return false; }
[ "protected", "final", "boolean", "reindex", "(", "String", "workspaceName", ",", "NodeKey", "key", ",", "Path", "path", ",", "Name", "primaryType", ",", "Set", "<", "Name", ">", "mixinTypes", ",", "Properties", "properties", ",", "boolean", "queryable", ")", ...
Reindex the specific node. @param workspaceName the workspace in which the node information should be available; may not be null @param key the unique key for the node; may not be null @param path the path of the node; may not be null @param primaryType the primary type of the node; may not be null @param mixinTypes the mixin types for the node; may not be null but may be empty @param properties the properties of the node; may not be null but may be empty @param queryable true if the node is queryable, false otherwise @return {@code true} if the reindexing operation took place, or {@code false} if no reindexing was performed because the {@link #predicate} failed.
[ "Reindex", "the", "specific", "node", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/spi/index/provider/IndexChangeAdapter.java#L70-L82
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/engine/QuerySources.java
QuerySources.nodes
protected NodeCacheIterator nodes( String workspaceName, Path path ) { // Determine which filter we should use based upon the workspace name. For the system workspace, // all queryable nodes are included. For all other workspaces, all queryable nodes are included except // for those that are actually stored in the system workspace (e.g., the "/jcr:system" nodes). NodeFilter nodeFilterForWorkspace = nodeFilterForWorkspace(workspaceName); if (nodeFilterForWorkspace == null) return null; // always append a shared nodes filter to the end of the workspace filter, // JCR #14.16 -If a query matches a descendant node of a shared set, it appears in query results only once. NodeFilter compositeFilter = new CompositeNodeFilter(nodeFilterForWorkspace, sharedNodesFilter()); // Then create an iterator over that workspace ... NodeCache cache = repo.getWorkspaceCache(workspaceName); NodeKey startingNode = null; if (path != null) { CachedNode node = getNodeAtPath(path, cache); if (node != null) startingNode = node.getKey(); } else { startingNode = cache.getRootKey(); } if (startingNode != null) { return new NodeCacheIterator(cache, startingNode, compositeFilter); } return null; }
java
protected NodeCacheIterator nodes( String workspaceName, Path path ) { // Determine which filter we should use based upon the workspace name. For the system workspace, // all queryable nodes are included. For all other workspaces, all queryable nodes are included except // for those that are actually stored in the system workspace (e.g., the "/jcr:system" nodes). NodeFilter nodeFilterForWorkspace = nodeFilterForWorkspace(workspaceName); if (nodeFilterForWorkspace == null) return null; // always append a shared nodes filter to the end of the workspace filter, // JCR #14.16 -If a query matches a descendant node of a shared set, it appears in query results only once. NodeFilter compositeFilter = new CompositeNodeFilter(nodeFilterForWorkspace, sharedNodesFilter()); // Then create an iterator over that workspace ... NodeCache cache = repo.getWorkspaceCache(workspaceName); NodeKey startingNode = null; if (path != null) { CachedNode node = getNodeAtPath(path, cache); if (node != null) startingNode = node.getKey(); } else { startingNode = cache.getRootKey(); } if (startingNode != null) { return new NodeCacheIterator(cache, startingNode, compositeFilter); } return null; }
[ "protected", "NodeCacheIterator", "nodes", "(", "String", "workspaceName", ",", "Path", "path", ")", "{", "// Determine which filter we should use based upon the workspace name. For the system workspace,", "// all queryable nodes are included. For all other workspaces, all queryable nodes ar...
Return an iterator over all nodes at or below the specified path in the named workspace, using the supplied filter. @param workspaceName the name of the workspace @param path the path of the root node of the subgraph, or null if all nodes in the workspace are to be included @return the iterator, or null if this workspace will return no nodes
[ "Return", "an", "iterator", "over", "all", "nodes", "at", "or", "below", "the", "specified", "path", "in", "the", "named", "workspace", "using", "the", "supplied", "filter", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/engine/QuerySources.java#L516-L540
train
ModeShape/modeshape
web/modeshape-web-jcr-rest/src/main/java/org/modeshape/web/jcr/rest/model/RestNode.java
RestNode.addCustomProperty
public RestNode addCustomProperty( String name, String value ) { customProperties.put(name, value); return this; }
java
public RestNode addCustomProperty( String name, String value ) { customProperties.put(name, value); return this; }
[ "public", "RestNode", "addCustomProperty", "(", "String", "name", ",", "String", "value", ")", "{", "customProperties", ".", "put", "(", "name", ",", "value", ")", ";", "return", "this", ";", "}" ]
Adds a custom property to this node, meaning a property which is not among the standard JCR properties @param name a {@code non-null} String, representing the name of the custom property @param value a {@code non-null} String, representing the value of the custom property @return this instance, with the custom property added
[ "Adds", "a", "custom", "property", "to", "this", "node", "meaning", "a", "property", "which", "is", "not", "among", "the", "standard", "JCR", "properties" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-jcr-rest/src/main/java/org/modeshape/web/jcr/rest/model/RestNode.java#L98-L102
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/AbstractJcrProperty.java
AbstractJcrProperty.checkForCheckedOut
protected final void checkForCheckedOut() throws VersionException, RepositoryException { if (!node.isCheckedOut()) { // Node is not checked out, so changing property is only allowed if OPV of property is 'ignore' ... JcrPropertyDefinition defn = getDefinition(); if (defn.getOnParentVersion() != OnParentVersionAction.IGNORE) { // Can't change this property ... String path = getParent().getPath(); throw new VersionException(JcrI18n.nodeIsCheckedIn.text(path)); } } }
java
protected final void checkForCheckedOut() throws VersionException, RepositoryException { if (!node.isCheckedOut()) { // Node is not checked out, so changing property is only allowed if OPV of property is 'ignore' ... JcrPropertyDefinition defn = getDefinition(); if (defn.getOnParentVersion() != OnParentVersionAction.IGNORE) { // Can't change this property ... String path = getParent().getPath(); throw new VersionException(JcrI18n.nodeIsCheckedIn.text(path)); } } }
[ "protected", "final", "void", "checkForCheckedOut", "(", ")", "throws", "VersionException", ",", "RepositoryException", "{", "if", "(", "!", "node", ".", "isCheckedOut", "(", ")", ")", "{", "// Node is not checked out, so changing property is only allowed if OPV of property...
Verifies that this node is either not versionable or that it is versionable but checked out. @throws VersionException if the node is versionable but is checked in and cannot be modified @throws RepositoryException if there is an error accessing the repository
[ "Verifies", "that", "this", "node", "is", "either", "not", "versionable", "or", "that", "it", "is", "versionable", "but", "checked", "out", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/AbstractJcrProperty.java#L209-L219
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/AbstractJcrNode.java
AbstractJcrNode.node
protected final CachedNode node() throws ItemNotFoundException, InvalidItemStateException { CachedNode node = sessionCache().getNode(key); if (node == null) { if (sessionCache().isDestroyed(key)) { throw new InvalidItemStateException("The node with key " + key + " has been removed in this session."); } throw new ItemNotFoundException("The node with key " + key + " no longer exists."); } return node; }
java
protected final CachedNode node() throws ItemNotFoundException, InvalidItemStateException { CachedNode node = sessionCache().getNode(key); if (node == null) { if (sessionCache().isDestroyed(key)) { throw new InvalidItemStateException("The node with key " + key + " has been removed in this session."); } throw new ItemNotFoundException("The node with key " + key + " no longer exists."); } return node; }
[ "protected", "final", "CachedNode", "node", "(", ")", "throws", "ItemNotFoundException", ",", "InvalidItemStateException", "{", "CachedNode", "node", "=", "sessionCache", "(", ")", ".", "getNode", "(", "key", ")", ";", "if", "(", "node", "==", "null", ")", "...
Get the cached node. @return the cached node @throws InvalidItemStateException if the node has been removed in this session's transient state @throws ItemNotFoundException if the node does not exist
[ "Get", "the", "cached", "node", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/AbstractJcrNode.java#L202-L211
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/AbstractJcrNode.java
AbstractJcrNode.propertyDefinitionFor
final JcrPropertyDefinition propertyDefinitionFor( org.modeshape.jcr.value.Property property, Name primaryType, Set<Name> mixinTypes, NodeTypes nodeTypes ) throws ConstraintViolationException { // Figure out the JCR property type ... boolean single = property.isSingle(); boolean skipProtected = false; JcrPropertyDefinition defn = findBestPropertyDefinition(primaryType, mixinTypes, property, single, skipProtected, false, nodeTypes); if (defn != null) return defn; // See if there is a definition that has constraints that were violated ... defn = findBestPropertyDefinition(primaryType, mixinTypes, property, single, skipProtected, true, nodeTypes); String pName = readable(property.getName()); String loc = location(); if (defn != null) { I18n msg = JcrI18n.propertyNoLongerSatisfiesConstraints; throw new ConstraintViolationException(msg.text(pName, loc, defn.getName(), defn.getDeclaringNodeType().getName())); } CachedNode node = sessionCache().getNode(key); String ptype = readable(node.getPrimaryType(sessionCache())); String mixins = readable(node.getMixinTypes(sessionCache())); String pstr = property.getString(session.namespaces()); throw new ConstraintViolationException(JcrI18n.propertyNoLongerHasValidDefinition.text(pstr, loc, ptype, mixins)); }
java
final JcrPropertyDefinition propertyDefinitionFor( org.modeshape.jcr.value.Property property, Name primaryType, Set<Name> mixinTypes, NodeTypes nodeTypes ) throws ConstraintViolationException { // Figure out the JCR property type ... boolean single = property.isSingle(); boolean skipProtected = false; JcrPropertyDefinition defn = findBestPropertyDefinition(primaryType, mixinTypes, property, single, skipProtected, false, nodeTypes); if (defn != null) return defn; // See if there is a definition that has constraints that were violated ... defn = findBestPropertyDefinition(primaryType, mixinTypes, property, single, skipProtected, true, nodeTypes); String pName = readable(property.getName()); String loc = location(); if (defn != null) { I18n msg = JcrI18n.propertyNoLongerSatisfiesConstraints; throw new ConstraintViolationException(msg.text(pName, loc, defn.getName(), defn.getDeclaringNodeType().getName())); } CachedNode node = sessionCache().getNode(key); String ptype = readable(node.getPrimaryType(sessionCache())); String mixins = readable(node.getMixinTypes(sessionCache())); String pstr = property.getString(session.namespaces()); throw new ConstraintViolationException(JcrI18n.propertyNoLongerHasValidDefinition.text(pstr, loc, ptype, mixins)); }
[ "final", "JcrPropertyDefinition", "propertyDefinitionFor", "(", "org", ".", "modeshape", ".", "jcr", ".", "value", ".", "Property", "property", ",", "Name", "primaryType", ",", "Set", "<", "Name", ">", "mixinTypes", ",", "NodeTypes", "nodeTypes", ")", "throws", ...
Find the property definition for the property, given this node's primary type and mixin types. @param property the property owned by this node; may not be null @param primaryType the name of the node's primary type; may not be null @param mixinTypes the names of the node's mixin types; may be null or empty @param nodeTypes the node types cache to use; may not be null @return the property definition; never null @throws ConstraintViolationException if the property has no valid property definition
[ "Find", "the", "property", "definition", "for", "the", "property", "given", "this", "node", "s", "primary", "type", "and", "mixin", "types", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/AbstractJcrNode.java#L452-L477
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/AbstractJcrNode.java
AbstractJcrNode.findBestPropertyDefinition
final JcrPropertyDefinition findBestPropertyDefinition( Name primaryTypeNameOfParent, Collection<Name> mixinTypeNamesOfParent, org.modeshape.jcr.value.Property property, boolean isSingle, boolean skipProtected, boolean skipConstraints, NodeTypes nodeTypes ) { JcrPropertyDefinition definition = null; int propertyType = PropertyTypeUtil.jcrPropertyTypeFor(property); // If single-valued ... ValueFactories factories = context().getValueFactories(); if (isSingle) { // Create a value for the ModeShape property value ... Object value = property.getFirstValue(); Value jcrValue = new JcrValue(factories, propertyType, value); definition = nodeTypes.findPropertyDefinition(session, primaryTypeNameOfParent, mixinTypeNamesOfParent, property.getName(), jcrValue, true, skipProtected); } else { // Create values for the ModeShape property value ... Value[] jcrValues = new Value[property.size()]; int index = 0; for (Object value : property) { jcrValues[index++] = new JcrValue(factories, propertyType, value); } definition = nodeTypes.findPropertyDefinition(session, primaryTypeNameOfParent, mixinTypeNamesOfParent, property.getName(), jcrValues, skipProtected); } if (definition != null) return definition; // No definition that allowed the values ... return null; }
java
final JcrPropertyDefinition findBestPropertyDefinition( Name primaryTypeNameOfParent, Collection<Name> mixinTypeNamesOfParent, org.modeshape.jcr.value.Property property, boolean isSingle, boolean skipProtected, boolean skipConstraints, NodeTypes nodeTypes ) { JcrPropertyDefinition definition = null; int propertyType = PropertyTypeUtil.jcrPropertyTypeFor(property); // If single-valued ... ValueFactories factories = context().getValueFactories(); if (isSingle) { // Create a value for the ModeShape property value ... Object value = property.getFirstValue(); Value jcrValue = new JcrValue(factories, propertyType, value); definition = nodeTypes.findPropertyDefinition(session, primaryTypeNameOfParent, mixinTypeNamesOfParent, property.getName(), jcrValue, true, skipProtected); } else { // Create values for the ModeShape property value ... Value[] jcrValues = new Value[property.size()]; int index = 0; for (Object value : property) { jcrValues[index++] = new JcrValue(factories, propertyType, value); } definition = nodeTypes.findPropertyDefinition(session, primaryTypeNameOfParent, mixinTypeNamesOfParent, property.getName(), jcrValues, skipProtected); } if (definition != null) return definition; // No definition that allowed the values ... return null; }
[ "final", "JcrPropertyDefinition", "findBestPropertyDefinition", "(", "Name", "primaryTypeNameOfParent", ",", "Collection", "<", "Name", ">", "mixinTypeNamesOfParent", ",", "org", ".", "modeshape", ".", "jcr", ".", "value", ".", "Property", "property", ",", "boolean", ...
Find the best property definition in this node's primary type and mixin types. @param primaryTypeNameOfParent the name of the primary type for the parent node; may not be null @param mixinTypeNamesOfParent the names of the mixin types for the parent node; may be null or empty if there are no mixins to include in the search @param property the property @param isSingle true if the property definition should be single-valued, or false if the property definition should allow multiple values @param skipProtected true if this operation is being done from within the public JCR node and property API, or false if this operation is being done from within internal implementations @param skipConstraints true if any constraints on the potential property definitions should be skipped; usually this is true for the first attempt but then 'false' for a subsequent attempt when figuring out an appropriate error message @param nodeTypes the node types cache to use; may not be null @return the property definition that allows setting this property, or null if there is no such definition
[ "Find", "the", "best", "property", "definition", "in", "this", "node", "s", "primary", "type", "and", "mixin", "types", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/AbstractJcrNode.java#L495-L528
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/AbstractJcrNode.java
AbstractJcrNode.childNode
protected final AbstractJcrNode childNode( Name name, Type expectedType ) throws PathNotFoundException, ItemNotFoundException, InvalidItemStateException { ChildReference ref = node().getChildReferences(sessionCache()).getChild(name); if (ref == null) { String msg = JcrI18n.childNotFoundUnderNode.text(readable(name), location(), session.workspaceName()); throw new PathNotFoundException(msg); } return session().node(ref.getKey(), expectedType, key()); }
java
protected final AbstractJcrNode childNode( Name name, Type expectedType ) throws PathNotFoundException, ItemNotFoundException, InvalidItemStateException { ChildReference ref = node().getChildReferences(sessionCache()).getChild(name); if (ref == null) { String msg = JcrI18n.childNotFoundUnderNode.text(readable(name), location(), session.workspaceName()); throw new PathNotFoundException(msg); } return session().node(ref.getKey(), expectedType, key()); }
[ "protected", "final", "AbstractJcrNode", "childNode", "(", "Name", "name", ",", "Type", "expectedType", ")", "throws", "PathNotFoundException", ",", "ItemNotFoundException", ",", "InvalidItemStateException", "{", "ChildReference", "ref", "=", "node", "(", ")", ".", ...
Get the JCR node for the named child. @param name the child name; may not be null @param expectedType the expected implementation type for the node, or null if it is not known @return the JCR node; never null @throws PathNotFoundException if there is no child with the supplied name @throws ItemNotFoundException if this node or the referenced child no longer exist or cannot be found @throws InvalidItemStateException if this node has been removed in this session's transient state
[ "Get", "the", "JCR", "node", "for", "the", "named", "child", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/AbstractJcrNode.java#L684-L693
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/AbstractJcrNode.java
AbstractJcrNode.autoCreatePropertiesFor
protected LinkedList<Property> autoCreatePropertiesFor( Name nodeName, Name primaryType, PropertyFactory propertyFactory, NodeTypes capabilities ) { Collection<JcrPropertyDefinition> autoPropDefns = capabilities.getAutoCreatedPropertyDefinitions(primaryType); if (autoPropDefns.isEmpty()) { return null; } // There is at least one auto-created property on this node ... LinkedList<Property> props = new LinkedList<Property>(); for (JcrPropertyDefinition defn : autoPropDefns) { Name propName = defn.getInternalName(); if (defn.hasDefaultValues()) { // This may or may not be auto-created; we don't care ... Object[] defaultValues = defn.getRawDefaultValues(); Property prop = null; if (defn.isMultiple()) { prop = propertyFactory.create(propName, defaultValues); } else { prop = propertyFactory.create(propName, defaultValues[0]); } props.add(prop); } } return props; }
java
protected LinkedList<Property> autoCreatePropertiesFor( Name nodeName, Name primaryType, PropertyFactory propertyFactory, NodeTypes capabilities ) { Collection<JcrPropertyDefinition> autoPropDefns = capabilities.getAutoCreatedPropertyDefinitions(primaryType); if (autoPropDefns.isEmpty()) { return null; } // There is at least one auto-created property on this node ... LinkedList<Property> props = new LinkedList<Property>(); for (JcrPropertyDefinition defn : autoPropDefns) { Name propName = defn.getInternalName(); if (defn.hasDefaultValues()) { // This may or may not be auto-created; we don't care ... Object[] defaultValues = defn.getRawDefaultValues(); Property prop = null; if (defn.isMultiple()) { prop = propertyFactory.create(propName, defaultValues); } else { prop = propertyFactory.create(propName, defaultValues[0]); } props.add(prop); } } return props; }
[ "protected", "LinkedList", "<", "Property", ">", "autoCreatePropertiesFor", "(", "Name", "nodeName", ",", "Name", "primaryType", ",", "PropertyFactory", "propertyFactory", ",", "NodeTypes", "capabilities", ")", "{", "Collection", "<", "JcrPropertyDefinition", ">", "au...
If there are any auto-created properties, create them and return them in a list. @param nodeName the name of the node; may not be null @param primaryType the name of the primary type; may not be null @param propertyFactory the factory for properties; may not be null @param capabilities the node type capabilities cache; may not be null @return the list of auto-created properties, or null if there are none
[ "If", "there", "are", "any", "auto", "-", "created", "properties", "create", "them", "and", "return", "them", "in", "a", "list", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/AbstractJcrNode.java#L1299-L1324
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/AbstractJcrNode.java
AbstractJcrNode.autoCreateChildren
protected void autoCreateChildren( Name primaryType, NodeTypes capabilities ) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, RepositoryException { Collection<JcrNodeDefinition> autoChildDefns = capabilities.getAutoCreatedChildNodeDefinitions(primaryType); if (!autoChildDefns.isEmpty()) { // There is at least one auto-created child under this node ... Set<Name> childNames = new HashSet<Name>(); for (JcrNodeDefinition defn : autoChildDefns) { // Residual definitions cannot be both auto-created and residual; // see Section 3.7.2.3.4 of the JCR 2.0 specfication" assert !defn.isResidual(); if (defn.isProtected()) { // Protected items are created by the implementation, so we'll not do these ... continue; } Name childName = defn.getInternalName(); if (!childNames.contains(childName)) { // We've not already created a child with this name ... JcrNodeType childPrimaryType = defn.getDefaultPrimaryType(); addChildNode(childName, childPrimaryType.getInternalName(), null, false, false); } } } }
java
protected void autoCreateChildren( Name primaryType, NodeTypes capabilities ) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, RepositoryException { Collection<JcrNodeDefinition> autoChildDefns = capabilities.getAutoCreatedChildNodeDefinitions(primaryType); if (!autoChildDefns.isEmpty()) { // There is at least one auto-created child under this node ... Set<Name> childNames = new HashSet<Name>(); for (JcrNodeDefinition defn : autoChildDefns) { // Residual definitions cannot be both auto-created and residual; // see Section 3.7.2.3.4 of the JCR 2.0 specfication" assert !defn.isResidual(); if (defn.isProtected()) { // Protected items are created by the implementation, so we'll not do these ... continue; } Name childName = defn.getInternalName(); if (!childNames.contains(childName)) { // We've not already created a child with this name ... JcrNodeType childPrimaryType = defn.getDefaultPrimaryType(); addChildNode(childName, childPrimaryType.getInternalName(), null, false, false); } } } }
[ "protected", "void", "autoCreateChildren", "(", "Name", "primaryType", ",", "NodeTypes", "capabilities", ")", "throws", "ItemExistsException", ",", "PathNotFoundException", ",", "VersionException", ",", "ConstraintViolationException", ",", "LockException", ",", "RepositoryE...
Create in this node any auto-created child nodes. @param primaryType the desired primary type for the new node; null value indicates that the default primary type from the appropriate definition for this node should be used @param capabilities the node type capabilities cache; may not be null @throws ItemExistsException if an item at the specified path already exists and same-name siblings are not allowed. @throws PathNotFoundException if the specified path implies intermediary nodes that do not exist. @throws VersionException not thrown at this time, but included for compatibility with the specification @throws ConstraintViolationException if the change would violate a node type or implementation-specific constraint. @throws LockException not thrown at this time, but included for compatibility with the specification @throws RepositoryException if another error occurs
[ "Create", "in", "this", "node", "any", "auto", "-", "created", "child", "nodes", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/AbstractJcrNode.java#L1339-L1363
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/AbstractJcrNode.java
AbstractJcrNode.removeExistingProperty
final AbstractJcrProperty removeExistingProperty( Name name ) throws VersionException, LockException, RepositoryException { AbstractJcrProperty existing = getProperty(name); if (existing != null) { existing.remove(); return existing; } // Return without throwing an exception to match behavior of the reference implementation. // This is also in conformance with the spec. See MODE-956 for details. return null; }
java
final AbstractJcrProperty removeExistingProperty( Name name ) throws VersionException, LockException, RepositoryException { AbstractJcrProperty existing = getProperty(name); if (existing != null) { existing.remove(); return existing; } // Return without throwing an exception to match behavior of the reference implementation. // This is also in conformance with the spec. See MODE-956 for details. return null; }
[ "final", "AbstractJcrProperty", "removeExistingProperty", "(", "Name", "name", ")", "throws", "VersionException", ",", "LockException", ",", "RepositoryException", "{", "AbstractJcrProperty", "existing", "=", "getProperty", "(", "name", ")", ";", "if", "(", "existing"...
Removes an existing property with the supplied name. Note that if a property with the given name does not exist, then this method returns null and does not throw an exception. @param name the name of the property; may not be null @return the property that was removed @throws VersionException if the node is checked out @throws LockException if the node is locked @throws RepositoryException if some other error occurred
[ "Removes", "an", "existing", "property", "with", "the", "supplied", "name", ".", "Note", "that", "if", "a", "property", "with", "the", "given", "name", "does", "not", "exist", "then", "this", "method", "returns", "null", "and", "does", "not", "throw", "an"...
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/AbstractJcrNode.java#L1653-L1662
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/AbstractJcrNode.java
AbstractJcrNode.setProperty
final AbstractJcrProperty setProperty( Name name, Value[] values, int jcrPropertyType, boolean skipReferenceValidation ) throws VersionException, LockException, ConstraintViolationException, RepositoryException { return setProperty(name, values, jcrPropertyType, false, skipReferenceValidation, false, false); }
java
final AbstractJcrProperty setProperty( Name name, Value[] values, int jcrPropertyType, boolean skipReferenceValidation ) throws VersionException, LockException, ConstraintViolationException, RepositoryException { return setProperty(name, values, jcrPropertyType, false, skipReferenceValidation, false, false); }
[ "final", "AbstractJcrProperty", "setProperty", "(", "Name", "name", ",", "Value", "[", "]", "values", ",", "int", "jcrPropertyType", ",", "boolean", "skipReferenceValidation", ")", "throws", "VersionException", ",", "LockException", ",", "ConstraintViolationException", ...
Sets a multi valued property, skipping over protected ones. @param name the name of the property; may not be null @param values the values of the property; may not be null @param jcrPropertyType the expected property type; may be {@link PropertyType#UNDEFINED} if the values should not be converted @param skipReferenceValidation indicates whether constraints on REFERENCE properties should be enforced @return the new JCR property object @throws VersionException if the node is checked out @throws LockException if the node is locked @throws ConstraintViolationException if the new value would violate the constraints on the property definition @throws RepositoryException if the named property does not exist, or if some other error occurred
[ "Sets", "a", "multi", "valued", "property", "skipping", "over", "protected", "ones", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/AbstractJcrNode.java#L1823-L1829
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/AbstractJcrNode.java
AbstractJcrNode.referringNodes
protected final NodeIterator referringNodes( ReferenceType referenceType ) throws RepositoryException { if (!this.isReferenceable()) { return JcrEmptyNodeIterator.INSTANCE; } // Get all of the nodes that are referring to this node ... Set<NodeKey> keys = node().getReferrers(sessionCache(), referenceType); if (keys.isEmpty()) return JcrEmptyNodeIterator.INSTANCE; return new JcrNodeIterator(session(), keys.iterator(), keys.size(), null); }
java
protected final NodeIterator referringNodes( ReferenceType referenceType ) throws RepositoryException { if (!this.isReferenceable()) { return JcrEmptyNodeIterator.INSTANCE; } // Get all of the nodes that are referring to this node ... Set<NodeKey> keys = node().getReferrers(sessionCache(), referenceType); if (keys.isEmpty()) return JcrEmptyNodeIterator.INSTANCE; return new JcrNodeIterator(session(), keys.iterator(), keys.size(), null); }
[ "protected", "final", "NodeIterator", "referringNodes", "(", "ReferenceType", "referenceType", ")", "throws", "RepositoryException", "{", "if", "(", "!", "this", ".", "isReferenceable", "(", ")", ")", "{", "return", "JcrEmptyNodeIterator", ".", "INSTANCE", ";", "}...
Obtain an iterator over the nodes that reference this node. @param referenceType specification of the type of references to include; may not be null @return the iterator over the referencing nodes; never null @throws RepositoryException if an error occurs while obtaining the information
[ "Obtain", "an", "iterator", "over", "the", "nodes", "that", "reference", "this", "node", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/AbstractJcrNode.java#L2233-L2242
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/AbstractJcrNode.java
AbstractJcrNode.containsChangesWithExternalDependencies
protected boolean containsChangesWithExternalDependencies( AtomicReference<Set<NodeKey>> affectedNodeKeys ) throws RepositoryException { Set<NodeKey> allChanges = sessionCache().getChangedNodeKeys(); Set<NodeKey> changesAtOrBelowThis = sessionCache().getChangedNodeKeysAtOrBelow(this.node()); removeReferrerChanges(allChanges, changesAtOrBelowThis); if (affectedNodeKeys != null) affectedNodeKeys.set(changesAtOrBelowThis); return !changesAtOrBelowThis.containsAll(allChanges); }
java
protected boolean containsChangesWithExternalDependencies( AtomicReference<Set<NodeKey>> affectedNodeKeys ) throws RepositoryException { Set<NodeKey> allChanges = sessionCache().getChangedNodeKeys(); Set<NodeKey> changesAtOrBelowThis = sessionCache().getChangedNodeKeysAtOrBelow(this.node()); removeReferrerChanges(allChanges, changesAtOrBelowThis); if (affectedNodeKeys != null) affectedNodeKeys.set(changesAtOrBelowThis); return !changesAtOrBelowThis.containsAll(allChanges); }
[ "protected", "boolean", "containsChangesWithExternalDependencies", "(", "AtomicReference", "<", "Set", "<", "NodeKey", ">", ">", "affectedNodeKeys", ")", "throws", "RepositoryException", "{", "Set", "<", "NodeKey", ">", "allChanges", "=", "sessionCache", "(", ")", "...
Determines whether this node, or any nodes below it, contain changes that depend on nodes that are outside of this node's hierarchy. @param affectedNodeKeys the reference that should be assigned to the set of node keys that are at or below this node; may be null if not needed @return true if this node's hierarchy has nodes with changes dependent on nodes from outside the hierarchy @throws InvalidItemStateException @throws ItemNotFoundException @throws RepositoryException
[ "Determines", "whether", "this", "node", "or", "any", "nodes", "below", "it", "contain", "changes", "that", "depend", "on", "nodes", "that", "are", "outside", "of", "this", "node", "s", "hierarchy", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/AbstractJcrNode.java#L3560-L3568
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/AbstractJcrNode.java
AbstractJcrNode.removeReferrerChanges
private void removeReferrerChanges( Set<NodeKey> allChanges, Set<NodeKey> changesAtOrBelowThis ) throws RepositoryException { // check if there are any nodes in the overall list of changes (and outside the branch) due to reference changes for (Iterator<NodeKey> allChangesIt = allChanges.iterator(); allChangesIt.hasNext();) { NodeKey changedNodeKey = allChangesIt.next(); if (changesAtOrBelowThis.contains(changedNodeKey)) { continue; } MutableCachedNode changedNodeOutsideBranch = session().cache().mutable(changedNodeKey); AbstractJcrNode changedNode = null; try { changedNode = session().node(changedNodeKey, null); } catch (ItemNotFoundException e) { // node was deleted allChangesIt.remove(); continue; } boolean isShareable = changedNode.isShareable(); if (isShareable /* && changedNodeOutsideBranch.hasOnlyChangesToAdditionalParents() */) { // assume that a shared node was added/removed and is to be included ... allChangesIt.remove(); continue; } boolean isReferenceable = changedNode.isReferenceable(); if (!isReferenceable) { continue; } Set<NodeKey> changedReferrers = changedNodeOutsideBranch.getChangedReferrerNodes(); for (NodeKey changedNodeInBranchKey : changesAtOrBelowThis) { if (changedReferrers.contains(changedNodeInBranchKey)) { // one of the changes in the branch is a referrer of the node outside the branch so we won't take the outside // node into account allChangesIt.remove(); } } } }
java
private void removeReferrerChanges( Set<NodeKey> allChanges, Set<NodeKey> changesAtOrBelowThis ) throws RepositoryException { // check if there are any nodes in the overall list of changes (and outside the branch) due to reference changes for (Iterator<NodeKey> allChangesIt = allChanges.iterator(); allChangesIt.hasNext();) { NodeKey changedNodeKey = allChangesIt.next(); if (changesAtOrBelowThis.contains(changedNodeKey)) { continue; } MutableCachedNode changedNodeOutsideBranch = session().cache().mutable(changedNodeKey); AbstractJcrNode changedNode = null; try { changedNode = session().node(changedNodeKey, null); } catch (ItemNotFoundException e) { // node was deleted allChangesIt.remove(); continue; } boolean isShareable = changedNode.isShareable(); if (isShareable /* && changedNodeOutsideBranch.hasOnlyChangesToAdditionalParents() */) { // assume that a shared node was added/removed and is to be included ... allChangesIt.remove(); continue; } boolean isReferenceable = changedNode.isReferenceable(); if (!isReferenceable) { continue; } Set<NodeKey> changedReferrers = changedNodeOutsideBranch.getChangedReferrerNodes(); for (NodeKey changedNodeInBranchKey : changesAtOrBelowThis) { if (changedReferrers.contains(changedNodeInBranchKey)) { // one of the changes in the branch is a referrer of the node outside the branch so we won't take the outside // node into account allChangesIt.remove(); } } } }
[ "private", "void", "removeReferrerChanges", "(", "Set", "<", "NodeKey", ">", "allChanges", ",", "Set", "<", "NodeKey", ">", "changesAtOrBelowThis", ")", "throws", "RepositoryException", "{", "// check if there are any nodes in the overall list of changes (and outside the branch...
Removes all the keys from the first set which represent referrer node keys to any of the nodes in the second set. @param allChanges the set of keys to the referrer nodes @param changesAtOrBelowThis the set of referrers that were changed at or below this node @throws RepositoryException if there is a problem
[ "Removes", "all", "the", "keys", "from", "the", "first", "set", "which", "represent", "referrer", "node", "keys", "to", "any", "of", "the", "nodes", "in", "the", "second", "set", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/AbstractJcrNode.java#L3577-L3613
train
ModeShape/modeshape
modeshape-jdbc-local/src/main/java/org/modeshape/jdbc/delegate/ConnectionInfo.java
ConnectionInfo.getPassword
public char[] getPassword() { String result = properties.getProperty(LocalJcrDriver.PASSWORD_PROPERTY_NAME); return result != null ? result.toCharArray() : null; }
java
public char[] getPassword() { String result = properties.getProperty(LocalJcrDriver.PASSWORD_PROPERTY_NAME); return result != null ? result.toCharArray() : null; }
[ "public", "char", "[", "]", "getPassword", "(", ")", "{", "String", "result", "=", "properties", ".", "getProperty", "(", "LocalJcrDriver", ".", "PASSWORD_PROPERTY_NAME", ")", ";", "return", "result", "!=", "null", "?", "result", ".", "toCharArray", "(", ")"...
Get the JCR password. This is not required. @return the JCR password, or null if no password was specified
[ "Get", "the", "JCR", "password", ".", "This", "is", "not", "required", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jdbc-local/src/main/java/org/modeshape/jdbc/delegate/ConnectionInfo.java#L161-L164
train
ModeShape/modeshape
modeshape-jdbc-local/src/main/java/org/modeshape/jdbc/delegate/ConnectionInfo.java
ConnectionInfo.isTeiidSupport
public boolean isTeiidSupport() { String result = properties.getProperty(LocalJcrDriver.TEIID_SUPPORT_PROPERTY_NAME); if (result == null) { return false; } return result.equalsIgnoreCase(Boolean.TRUE.toString()); }
java
public boolean isTeiidSupport() { String result = properties.getProperty(LocalJcrDriver.TEIID_SUPPORT_PROPERTY_NAME); if (result == null) { return false; } return result.equalsIgnoreCase(Boolean.TRUE.toString()); }
[ "public", "boolean", "isTeiidSupport", "(", ")", "{", "String", "result", "=", "properties", ".", "getProperty", "(", "LocalJcrDriver", ".", "TEIID_SUPPORT_PROPERTY_NAME", ")", ";", "if", "(", "result", "==", "null", ")", "{", "return", "false", ";", "}", "r...
Return true of Teiid support is required for this connection. @return true if Teiid support is required.
[ "Return", "true", "of", "Teiid", "support", "is", "required", "for", "this", "connection", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jdbc-local/src/main/java/org/modeshape/jdbc/delegate/ConnectionInfo.java#L171-L177
train
ModeShape/modeshape
modeshape-jdbc-local/src/main/java/org/modeshape/jdbc/delegate/ConnectionInfo.java
ConnectionInfo.getCredentials
public Credentials getCredentials() { String username = getUsername(); char[] password = getPassword(); if (username != null) { return new SimpleCredentials(username, password); } return null; }
java
public Credentials getCredentials() { String username = getUsername(); char[] password = getPassword(); if (username != null) { return new SimpleCredentials(username, password); } return null; }
[ "public", "Credentials", "getCredentials", "(", ")", "{", "String", "username", "=", "getUsername", "(", ")", ";", "char", "[", "]", "password", "=", "getPassword", "(", ")", ";", "if", "(", "username", "!=", "null", ")", "{", "return", "new", "SimpleCre...
Return the credentials based on the user name and password. @return Credentials
[ "Return", "the", "credentials", "based", "on", "the", "user", "name", "and", "password", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jdbc-local/src/main/java/org/modeshape/jdbc/delegate/ConnectionInfo.java#L310-L317
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/SecureHash.java
SecureHash.getHash
public static byte[] getHash( String digestName, InputStream stream ) throws NoSuchAlgorithmException, IOException { CheckArg.isNotNull(stream, "stream"); MessageDigest digest = MessageDigest.getInstance(digestName); assert digest != null; int bufSize = 1024; byte[] buffer = new byte[bufSize]; int n = stream.read(buffer, 0, bufSize); while (n != -1) { digest.update(buffer, 0, n); n = stream.read(buffer, 0, bufSize); } return digest.digest(); }
java
public static byte[] getHash( String digestName, InputStream stream ) throws NoSuchAlgorithmException, IOException { CheckArg.isNotNull(stream, "stream"); MessageDigest digest = MessageDigest.getInstance(digestName); assert digest != null; int bufSize = 1024; byte[] buffer = new byte[bufSize]; int n = stream.read(buffer, 0, bufSize); while (n != -1) { digest.update(buffer, 0, n); n = stream.read(buffer, 0, bufSize); } return digest.digest(); }
[ "public", "static", "byte", "[", "]", "getHash", "(", "String", "digestName", ",", "InputStream", "stream", ")", "throws", "NoSuchAlgorithmException", ",", "IOException", "{", "CheckArg", ".", "isNotNull", "(", "stream", ",", "\"stream\"", ")", ";", "MessageDige...
Get the hash of the supplied content, using the digest identified by the supplied name. Note that this method never closes the supplied stream. @param digestName the name of the hashing function (or {@link MessageDigest message digest}) that should be used @param stream the stream containing the content to be hashed; may not be null @return the hash of the contents as a byte array @throws NoSuchAlgorithmException if the supplied algorithm could not be found @throws IOException if there is an error reading the stream
[ "Get", "the", "hash", "of", "the", "supplied", "content", "using", "the", "digest", "identified", "by", "the", "supplied", "name", ".", "Note", "that", "this", "method", "never", "closes", "the", "supplied", "stream", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/SecureHash.java#L240-L253
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/SecureHash.java
SecureHash.sha1
public static String sha1( String string ) { try { byte[] sha1 = SecureHash.getHash(SecureHash.Algorithm.SHA_1, string.getBytes()); return SecureHash.asHexString(sha1); } catch (NoSuchAlgorithmException e) { throw new SystemFailureException(e); } }
java
public static String sha1( String string ) { try { byte[] sha1 = SecureHash.getHash(SecureHash.Algorithm.SHA_1, string.getBytes()); return SecureHash.asHexString(sha1); } catch (NoSuchAlgorithmException e) { throw new SystemFailureException(e); } }
[ "public", "static", "String", "sha1", "(", "String", "string", ")", "{", "try", "{", "byte", "[", "]", "sha1", "=", "SecureHash", ".", "getHash", "(", "SecureHash", ".", "Algorithm", ".", "SHA_1", ",", "string", ".", "getBytes", "(", ")", ")", ";", "...
Computes the sha1 value for the given string. @param string a non-null string @return the SHA1 value for the given string.
[ "Computes", "the", "sha1", "value", "for", "the", "given", "string", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/SecureHash.java#L337-L344
train
ModeShape/modeshape
modeshape-jdbc-local/src/main/java/org/modeshape/jdbc/delegate/RepositoryDelegateFactory.java
RepositoryDelegateFactory.createRepositoryDelegate
public RepositoryDelegate createRepositoryDelegate( String url, Properties info, JcrContextFactory contextFactory ) throws SQLException { if (!acceptUrl(url)) { throw new SQLException(JdbcLocalI18n.invalidUrlPrefix.text(LocalJcrDriver.JNDI_URL_PREFIX)); } return create(determineProtocol(url), url, info, contextFactory); }
java
public RepositoryDelegate createRepositoryDelegate( String url, Properties info, JcrContextFactory contextFactory ) throws SQLException { if (!acceptUrl(url)) { throw new SQLException(JdbcLocalI18n.invalidUrlPrefix.text(LocalJcrDriver.JNDI_URL_PREFIX)); } return create(determineProtocol(url), url, info, contextFactory); }
[ "public", "RepositoryDelegate", "createRepositoryDelegate", "(", "String", "url", ",", "Properties", "info", ",", "JcrContextFactory", "contextFactory", ")", "throws", "SQLException", "{", "if", "(", "!", "acceptUrl", "(", "url", ")", ")", "{", "throw", "new", "...
Create a RepositoryDelegate instance, given the connection information. @param url the JDBC URL; may be null @param info the connection properties @param contextFactory the factory for a JCR context; may not be null @return the RepositoryDelegate for the supplied connection information @throws SQLException if the URL is unknown
[ "Create", "a", "RepositoryDelegate", "instance", "given", "the", "connection", "information", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jdbc-local/src/main/java/org/modeshape/jdbc/delegate/RepositoryDelegateFactory.java#L46-L53
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/model/SelectorName.java
SelectorName.nameSetFrom
public static Set<SelectorName> nameSetFrom( Set<SelectorName> firstSet, Set<SelectorName> secondSet ) { if ((firstSet == null || firstSet.isEmpty()) && (secondSet == null || secondSet.isEmpty())) { return Collections.emptySet(); } Set<SelectorName> result = new LinkedHashSet<SelectorName>(); result.addAll(firstSet); if (secondSet != null) result.addAll(secondSet); return Collections.unmodifiableSet(result); }
java
public static Set<SelectorName> nameSetFrom( Set<SelectorName> firstSet, Set<SelectorName> secondSet ) { if ((firstSet == null || firstSet.isEmpty()) && (secondSet == null || secondSet.isEmpty())) { return Collections.emptySet(); } Set<SelectorName> result = new LinkedHashSet<SelectorName>(); result.addAll(firstSet); if (secondSet != null) result.addAll(secondSet); return Collections.unmodifiableSet(result); }
[ "public", "static", "Set", "<", "SelectorName", ">", "nameSetFrom", "(", "Set", "<", "SelectorName", ">", "firstSet", ",", "Set", "<", "SelectorName", ">", "secondSet", ")", "{", "if", "(", "(", "firstSet", "==", "null", "||", "firstSet", ".", "isEmpty", ...
Create a set that contains the SelectName objects in the supplied sets. @param firstSet the first set of names; may be null or empty @param secondSet the second set of names; may be null or empty @return the set; never null
[ "Create", "a", "set", "that", "contains", "the", "SelectName", "objects", "in", "the", "supplied", "sets", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/model/SelectorName.java#L127-L136
train
ModeShape/modeshape
sequencers/modeshape-sequencer-text/src/main/java/org/modeshape/sequencer/text/DelimitedTextSequencer.java
DelimitedTextSequencer.setSplitPattern
public void setSplitPattern( String regularExpression ) throws PatternSyntaxException { CheckArg.isNotNull(regularExpression, "regularExpression"); Pattern.compile(splitPattern); splitPattern = regularExpression; }
java
public void setSplitPattern( String regularExpression ) throws PatternSyntaxException { CheckArg.isNotNull(regularExpression, "regularExpression"); Pattern.compile(splitPattern); splitPattern = regularExpression; }
[ "public", "void", "setSplitPattern", "(", "String", "regularExpression", ")", "throws", "PatternSyntaxException", "{", "CheckArg", ".", "isNotNull", "(", "regularExpression", ",", "\"regularExpression\"", ")", ";", "Pattern", ".", "compile", "(", "splitPattern", ")", ...
Sets the regular expression to use to split incoming rows. @param regularExpression the regular expression to use to split incoming rows; may not be null. @throws java.util.regex.PatternSyntaxException if {@code regularExpression} does not represent a valid regular expression that can be {@link java.util.regex.Pattern#compile(String) compiled into a pattern}.
[ "Sets", "the", "regular", "expression", "to", "use", "to", "split", "incoming", "rows", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-text/src/main/java/org/modeshape/sequencer/text/DelimitedTextSequencer.java#L40-L44
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/BackupDocumentReader.java
BackupDocumentReader.read
public Document read() { try { do { if (stream == null) { // Open the stream to the next file ... stream = openNextFile(); if (stream == null) { // No more files to read ... return null; } documents = Json.readMultiple(stream, false); } try { Document doc = documents.nextDocument(); if (doc != null) return doc; } catch (IOException e) { // We'll just continue ... } // Close the stream and try opening the next stream ... close(stream); stream = null; } while (true); } catch (IOException e) { problems.addError(JcrI18n.problemsWritingDocumentToBackup, currentFile.getAbsolutePath(), e.getMessage()); return null; } }
java
public Document read() { try { do { if (stream == null) { // Open the stream to the next file ... stream = openNextFile(); if (stream == null) { // No more files to read ... return null; } documents = Json.readMultiple(stream, false); } try { Document doc = documents.nextDocument(); if (doc != null) return doc; } catch (IOException e) { // We'll just continue ... } // Close the stream and try opening the next stream ... close(stream); stream = null; } while (true); } catch (IOException e) { problems.addError(JcrI18n.problemsWritingDocumentToBackup, currentFile.getAbsolutePath(), e.getMessage()); return null; } }
[ "public", "Document", "read", "(", ")", "{", "try", "{", "do", "{", "if", "(", "stream", "==", "null", ")", "{", "// Open the stream to the next file ...", "stream", "=", "openNextFile", "(", ")", ";", "if", "(", "stream", "==", "null", ")", "{", "// No ...
Read the next document from the files. @return the document, or null if there are no more documents
[ "Read", "the", "next", "document", "from", "the", "files", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/BackupDocumentReader.java#L64-L90
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/math/Duration.java
Duration.add
public Duration add( long duration, TimeUnit unit ) { long durationInNanos = TimeUnit.NANOSECONDS.convert(duration, unit); return new Duration(this.durationInNanos + durationInNanos); }
java
public Duration add( long duration, TimeUnit unit ) { long durationInNanos = TimeUnit.NANOSECONDS.convert(duration, unit); return new Duration(this.durationInNanos + durationInNanos); }
[ "public", "Duration", "add", "(", "long", "duration", ",", "TimeUnit", "unit", ")", "{", "long", "durationInNanos", "=", "TimeUnit", ".", "NANOSECONDS", ".", "convert", "(", "duration", ",", "unit", ")", ";", "return", "new", "Duration", "(", "this", ".", ...
Add the supplied duration to this duration, and return the result. @param duration the duration to add to this object @param unit the unit of the duration being added; may not be null @return the total duration
[ "Add", "the", "supplied", "duration", "to", "this", "duration", "and", "return", "the", "result", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/math/Duration.java#L86-L90
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/math/Duration.java
Duration.subtract
public Duration subtract( long duration, TimeUnit unit ) { long durationInNanos = TimeUnit.NANOSECONDS.convert(duration, unit); return new Duration(this.durationInNanos - durationInNanos); }
java
public Duration subtract( long duration, TimeUnit unit ) { long durationInNanos = TimeUnit.NANOSECONDS.convert(duration, unit); return new Duration(this.durationInNanos - durationInNanos); }
[ "public", "Duration", "subtract", "(", "long", "duration", ",", "TimeUnit", "unit", ")", "{", "long", "durationInNanos", "=", "TimeUnit", ".", "NANOSECONDS", ".", "convert", "(", "duration", ",", "unit", ")", ";", "return", "new", "Duration", "(", "this", ...
Subtract the supplied duration from this duration, and return the result. @param duration the duration to subtract from this object @param unit the unit of the duration being subtracted; may not be null @return the total duration
[ "Subtract", "the", "supplied", "duration", "from", "this", "duration", "and", "return", "the", "result", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/math/Duration.java#L99-L103
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/math/Duration.java
Duration.add
public Duration add( Duration duration ) { return new Duration(this.durationInNanos + (duration == null ? 0l : duration.longValue())); }
java
public Duration add( Duration duration ) { return new Duration(this.durationInNanos + (duration == null ? 0l : duration.longValue())); }
[ "public", "Duration", "add", "(", "Duration", "duration", ")", "{", "return", "new", "Duration", "(", "this", ".", "durationInNanos", "+", "(", "duration", "==", "null", "?", "0l", ":", "duration", ".", "longValue", "(", ")", ")", ")", ";", "}" ]
Add the supplied duration to this duration, and return the result. A null value is treated as a duration of 0 nanoseconds. @param duration the duration to add to this object @return the total duration
[ "Add", "the", "supplied", "duration", "to", "this", "duration", "and", "return", "the", "result", ".", "A", "null", "value", "is", "treated", "as", "a", "duration", "of", "0", "nanoseconds", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/math/Duration.java#L111-L113
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/math/Duration.java
Duration.subtract
public Duration subtract( Duration duration ) { return new Duration(this.durationInNanos - (duration == null ? 0l : duration.longValue())); }
java
public Duration subtract( Duration duration ) { return new Duration(this.durationInNanos - (duration == null ? 0l : duration.longValue())); }
[ "public", "Duration", "subtract", "(", "Duration", "duration", ")", "{", "return", "new", "Duration", "(", "this", ".", "durationInNanos", "-", "(", "duration", "==", "null", "?", "0l", ":", "duration", ".", "longValue", "(", ")", ")", ")", ";", "}" ]
Subtract the supplied duration from this duration, and return the result. A null value is treated as a duration of 0 nanoseconds. @param duration the duration to subtract from this object @return the resulting duration
[ "Subtract", "the", "supplied", "duration", "from", "this", "duration", "and", "return", "the", "result", ".", "A", "null", "value", "is", "treated", "as", "a", "duration", "of", "0", "nanoseconds", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/math/Duration.java#L122-L124
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/math/Duration.java
Duration.getComponents
public Components getComponents() { if (this.components == null) { // This is idempotent, so no need to synchronize ... // Calculate how many seconds, and don't lose any information ... BigDecimal bigSeconds = new BigDecimal(this.durationInNanos).divide(new BigDecimal(1000000000)); // Calculate the minutes, and round to lose the seconds int minutes = bigSeconds.intValue() / 60; // Remove the minutes from the seconds, to just have the remainder of seconds double dMinutes = minutes; double seconds = bigSeconds.doubleValue() - dMinutes * 60; // Now compute the number of full hours, and change 'minutes' to hold the remainding minutes int hours = minutes / 60; minutes = minutes - (hours * 60); this.components = new Components(hours, minutes, seconds); } return this.components; }
java
public Components getComponents() { if (this.components == null) { // This is idempotent, so no need to synchronize ... // Calculate how many seconds, and don't lose any information ... BigDecimal bigSeconds = new BigDecimal(this.durationInNanos).divide(new BigDecimal(1000000000)); // Calculate the minutes, and round to lose the seconds int minutes = bigSeconds.intValue() / 60; // Remove the minutes from the seconds, to just have the remainder of seconds double dMinutes = minutes; double seconds = bigSeconds.doubleValue() - dMinutes * 60; // Now compute the number of full hours, and change 'minutes' to hold the remainding minutes int hours = minutes / 60; minutes = minutes - (hours * 60); this.components = new Components(hours, minutes, seconds); } return this.components; }
[ "public", "Components", "getComponents", "(", ")", "{", "if", "(", "this", ".", "components", "==", "null", ")", "{", "// This is idempotent, so no need to synchronize ...", "// Calculate how many seconds, and don't lose any information ...", "BigDecimal", "bigSeconds", "=", ...
Return the duration components. @return the individual time components of this duration
[ "Return", "the", "duration", "components", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/math/Duration.java#L203-L220
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/math/Duration.java
Duration.getDuration
public long getDuration( TimeUnit unit ) { if (unit == null) throw new IllegalArgumentException(); return unit.convert(durationInNanos, TimeUnit.NANOSECONDS); }
java
public long getDuration( TimeUnit unit ) { if (unit == null) throw new IllegalArgumentException(); return unit.convert(durationInNanos, TimeUnit.NANOSECONDS); }
[ "public", "long", "getDuration", "(", "TimeUnit", "unit", ")", "{", "if", "(", "unit", "==", "null", ")", "throw", "new", "IllegalArgumentException", "(", ")", ";", "return", "unit", ".", "convert", "(", "durationInNanos", ",", "TimeUnit", ".", "NANOSECONDS"...
Get the duration value in the supplied unit of time. @param unit the unit of time for the returned value; may not be null @return the value of this duration in the supplied unit of time
[ "Get", "the", "duration", "value", "in", "the", "supplied", "unit", "of", "time", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/math/Duration.java#L228-L231
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/cache/document/WorkspaceCache.java
WorkspaceCache.changed
public void changed( ChangeSet changes ) { checkNotClosed(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Cache for workspace '{0}' received {1} changes from local sessions: {2}", workspaceName, changes.size(), changes); } // Clear this workspace's cached nodes (iteratively is okay since it's a ConcurrentMap) ... for (NodeKey key : changes.changedNodes()) { if (closed) break; nodesByKey.remove(key); } // Send the changes to the change bus so that others can see them ... if (changeBus != null) changeBus.notify(changes); }
java
public void changed( ChangeSet changes ) { checkNotClosed(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Cache for workspace '{0}' received {1} changes from local sessions: {2}", workspaceName, changes.size(), changes); } // Clear this workspace's cached nodes (iteratively is okay since it's a ConcurrentMap) ... for (NodeKey key : changes.changedNodes()) { if (closed) break; nodesByKey.remove(key); } // Send the changes to the change bus so that others can see them ... if (changeBus != null) changeBus.notify(changes); }
[ "public", "void", "changed", "(", "ChangeSet", "changes", ")", "{", "checkNotClosed", "(", ")", ";", "if", "(", "LOGGER", ".", "isTraceEnabled", "(", ")", ")", "{", "LOGGER", ".", "trace", "(", "\"Cache for workspace '{0}' received {1} changes from local sessions: {...
Signal that changes have been made to the persisted data. Related information in the cache is cleared, and this workspace's listener is notified of the changes. @param changes the changes to be made; may not be null
[ "Signal", "that", "changes", "have", "been", "made", "to", "the", "persisted", "data", ".", "Related", "information", "in", "the", "cache", "is", "cleared", "and", "this", "workspace", "s", "listener", "is", "notified", "of", "the", "changes", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/cache/document/WorkspaceCache.java#L307-L321
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/JndiRepositoryFactory.java
JndiRepositoryFactory.getRepository
private static synchronized JcrRepository getRepository( String configFileName, String repositoryName, final Context nameCtx, final Name jndiName ) throws IOException, RepositoryException, NamingException { if (!StringUtil.isBlank(repositoryName)) { // Make sure the engine is running ... ENGINE.start(); // See if we can shortcut the process by using the name ... try { JcrRepository repository = ENGINE.getRepository(repositoryName); switch (repository.getState()) { case STARTING: case RUNNING: return repository; default: LOG.error(JcrI18n.repositoryIsNotRunningOrHasBeenShutDown, repositoryName); return null; } } catch (NoSuchRepositoryException e) { if (configFileName == null) { // No configuration file given, so we can't do anything ... throw e; } // Nothing found, so continue ... } } RepositoryConfiguration config = RepositoryConfiguration.read(configFileName); if (repositoryName == null) { repositoryName = config.getName(); } else if (!repositoryName.equals(config.getName())) { LOG.warn(JcrI18n.repositoryNameDoesNotMatchConfigurationName, repositoryName, config.getName(), configFileName); } // Try to deploy and start the repository ... ENGINE.start(); JcrRepository repository = ENGINE.deploy(config); try { ENGINE.startRepository(repository.getName()).get(); } catch (InterruptedException e) { Thread.interrupted(); throw new RepositoryException(e); } catch (ExecutionException e) { throw new RepositoryException(e.getCause()); } // Register the JNDI listener, to shut down the repository when removed from JNDI ... if (nameCtx instanceof EventContext) { registerNamingListener((EventContext)nameCtx, jndiName); } return repository; }
java
private static synchronized JcrRepository getRepository( String configFileName, String repositoryName, final Context nameCtx, final Name jndiName ) throws IOException, RepositoryException, NamingException { if (!StringUtil.isBlank(repositoryName)) { // Make sure the engine is running ... ENGINE.start(); // See if we can shortcut the process by using the name ... try { JcrRepository repository = ENGINE.getRepository(repositoryName); switch (repository.getState()) { case STARTING: case RUNNING: return repository; default: LOG.error(JcrI18n.repositoryIsNotRunningOrHasBeenShutDown, repositoryName); return null; } } catch (NoSuchRepositoryException e) { if (configFileName == null) { // No configuration file given, so we can't do anything ... throw e; } // Nothing found, so continue ... } } RepositoryConfiguration config = RepositoryConfiguration.read(configFileName); if (repositoryName == null) { repositoryName = config.getName(); } else if (!repositoryName.equals(config.getName())) { LOG.warn(JcrI18n.repositoryNameDoesNotMatchConfigurationName, repositoryName, config.getName(), configFileName); } // Try to deploy and start the repository ... ENGINE.start(); JcrRepository repository = ENGINE.deploy(config); try { ENGINE.startRepository(repository.getName()).get(); } catch (InterruptedException e) { Thread.interrupted(); throw new RepositoryException(e); } catch (ExecutionException e) { throw new RepositoryException(e.getCause()); } // Register the JNDI listener, to shut down the repository when removed from JNDI ... if (nameCtx instanceof EventContext) { registerNamingListener((EventContext)nameCtx, jndiName); } return repository; }
[ "private", "static", "synchronized", "JcrRepository", "getRepository", "(", "String", "configFileName", ",", "String", "repositoryName", ",", "final", "Context", "nameCtx", ",", "final", "Name", "jndiName", ")", "throws", "IOException", ",", "RepositoryException", ","...
Get or initialize the JCR Repository instance as described by the supplied configuration file and repository name. @param configFileName the name of the file containing the configuration information for the {@code ModeShapeEngine}; may not be null. This method will first attempt to load this file as a resource from the classpath. If no resource with the given name exists, the name will be treated as a file name and loaded from the file system. May be null if the repository should already exist. @param repositoryName the name of the repository; may be null if the repository name is to be read from the configuration file (note that this does require parsing the configuration file) @param nameCtx the naming context used to register a removal listener to shut down the repository when removed from JNDI; may be null @param jndiName the name in JNDI where the repository is to be found @return the JCR repository instance @throws IOException if there is an error or problem reading the configuration resource at the supplied path @throws RepositoryException if the repository could not be started @throws NamingException if there is an error registering the namespace listener
[ "Get", "or", "initialize", "the", "JCR", "Repository", "instance", "as", "described", "by", "the", "supplied", "configuration", "file", "and", "repository", "name", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/JndiRepositoryFactory.java#L110-L165
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/TimeBasedKeys.java
TimeBasedKeys.create
public static TimeBasedKeys create( int bitsUsedInCounter ) { CheckArg.isPositive(bitsUsedInCounter, "bitsUsedInCounter"); int maxAvailableBitsToShift = Long.numberOfLeadingZeros(System.currentTimeMillis()); CheckArg.isLessThan(bitsUsedInCounter, maxAvailableBitsToShift, "bitsUsedInCounter"); return new TimeBasedKeys((short)bitsUsedInCounter); }
java
public static TimeBasedKeys create( int bitsUsedInCounter ) { CheckArg.isPositive(bitsUsedInCounter, "bitsUsedInCounter"); int maxAvailableBitsToShift = Long.numberOfLeadingZeros(System.currentTimeMillis()); CheckArg.isLessThan(bitsUsedInCounter, maxAvailableBitsToShift, "bitsUsedInCounter"); return new TimeBasedKeys((short)bitsUsedInCounter); }
[ "public", "static", "TimeBasedKeys", "create", "(", "int", "bitsUsedInCounter", ")", "{", "CheckArg", ".", "isPositive", "(", "bitsUsedInCounter", ",", "\"bitsUsedInCounter\"", ")", ";", "int", "maxAvailableBitsToShift", "=", "Long", ".", "numberOfLeadingZeros", "(", ...
Create a new generator that uses the specified number of bits for the counter portion of the keys. @param bitsUsedInCounter the number of bits in the counter portion of the keys; must be a positive number for which theere is enough space to left shift without overflowing. @return the generator instance; never null
[ "Create", "a", "new", "generator", "that", "uses", "the", "specified", "number", "of", "bits", "for", "the", "counter", "portion", "of", "the", "keys", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/TimeBasedKeys.java#L99-L104
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/TimeBasedKeys.java
TimeBasedKeys.nextKey
public long nextKey() { // Note that per Oracle the currentTimeMillis is the current number of seconds past the epoch // in UTC (not in local time). Therefore, processes with exactly synchronized clocks will // always get the same value regardless of their timezone ... final long timestamp = System.currentTimeMillis(); final int increment = counterFor(timestamp); if (increment <= maximumCounterValue) { return (timestamp << counterBits) + increment; } // The counter is surprisingly too high, so try again (repeatedly) until we get to the next millisecond ... return this.nextKey(); }
java
public long nextKey() { // Note that per Oracle the currentTimeMillis is the current number of seconds past the epoch // in UTC (not in local time). Therefore, processes with exactly synchronized clocks will // always get the same value regardless of their timezone ... final long timestamp = System.currentTimeMillis(); final int increment = counterFor(timestamp); if (increment <= maximumCounterValue) { return (timestamp << counterBits) + increment; } // The counter is surprisingly too high, so try again (repeatedly) until we get to the next millisecond ... return this.nextKey(); }
[ "public", "long", "nextKey", "(", ")", "{", "// Note that per Oracle the currentTimeMillis is the current number of seconds past the epoch", "// in UTC (not in local time). Therefore, processes with exactly synchronized clocks will", "// always get the same value regardless of their timezone ...", ...
Get the next key for the current time in UTC. @return a long that is determined by the current time in UTC and a unique counter value for the current time.
[ "Get", "the", "next", "key", "for", "the", "current", "time", "in", "UTC", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/TimeBasedKeys.java#L145-L156
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/optimize/RewriteAsRangeCriteria.java
RewriteAsRangeCriteria.nullReference
protected void nullReference( List<Comparison> comparisons, Comparison comparisonToNull ) { if (comparisonToNull != null) { for (int i = 0; i != comparisons.size(); ++i) { if (comparisons.get(i) == comparisonToNull) comparisons.set(i, null); } } }
java
protected void nullReference( List<Comparison> comparisons, Comparison comparisonToNull ) { if (comparisonToNull != null) { for (int i = 0; i != comparisons.size(); ++i) { if (comparisons.get(i) == comparisonToNull) comparisons.set(i, null); } } }
[ "protected", "void", "nullReference", "(", "List", "<", "Comparison", ">", "comparisons", ",", "Comparison", "comparisonToNull", ")", "{", "if", "(", "comparisonToNull", "!=", "null", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "!=", "comparisons...
Find all occurrences of the comparison object in the supplied list and null the list's reference to it. @param comparisons the collection in which null references are to be placed @param comparisonToNull the comparison that is to be found and nulled in the collection
[ "Find", "all", "occurrences", "of", "the", "comparison", "object", "in", "the", "supplied", "list", "and", "null", "the", "list", "s", "reference", "to", "it", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/optimize/RewriteAsRangeCriteria.java#L252-L259
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/optimize/RewriteAsRangeCriteria.java
RewriteAsRangeCriteria.nullReference
protected void nullReference( List<Comparison> comparisons, Iterable<Comparison> comparisonsToNull ) { for (Comparison comparisonToNull : comparisonsToNull) { nullReference(comparisons, comparisonToNull); } }
java
protected void nullReference( List<Comparison> comparisons, Iterable<Comparison> comparisonsToNull ) { for (Comparison comparisonToNull : comparisonsToNull) { nullReference(comparisons, comparisonToNull); } }
[ "protected", "void", "nullReference", "(", "List", "<", "Comparison", ">", "comparisons", ",", "Iterable", "<", "Comparison", ">", "comparisonsToNull", ")", "{", "for", "(", "Comparison", "comparisonToNull", ":", "comparisonsToNull", ")", "{", "nullReference", "("...
Find all references in the supplied list that match those supplied and set them to null. @param comparisons the collection in which null references are to be placed @param comparisonsToNull the comparisons that are to be found and nulled in the collection
[ "Find", "all", "references", "in", "the", "supplied", "list", "that", "match", "those", "supplied", "and", "set", "them", "to", "null", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/optimize/RewriteAsRangeCriteria.java#L267-L272
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/query/optimize/RewriteAsRangeCriteria.java
RewriteAsRangeCriteria.compareStaticOperands
protected int compareStaticOperands( QueryContext context, Comparison comparison1, Comparison comparison2 ) { Object value1 = getValue(context, comparison1.getOperand2()); Object value2 = getValue(context, comparison2.getOperand2()); return ValueComparators.OBJECT_COMPARATOR.compare(value1, value2); }
java
protected int compareStaticOperands( QueryContext context, Comparison comparison1, Comparison comparison2 ) { Object value1 = getValue(context, comparison1.getOperand2()); Object value2 = getValue(context, comparison2.getOperand2()); return ValueComparators.OBJECT_COMPARATOR.compare(value1, value2); }
[ "protected", "int", "compareStaticOperands", "(", "QueryContext", "context", ",", "Comparison", "comparison1", ",", "Comparison", "comparison2", ")", "{", "Object", "value1", "=", "getValue", "(", "context", ",", "comparison1", ".", "getOperand2", "(", ")", ")", ...
Compare the values used in the two comparisons @param context the query context; may not be null @param comparison1 the first comparison object; may not be null @param comparison2 the second comparison object; may not be null @return 0 if the values are the same, less than 0 if the first comparison's value is less than the second's, or greater than 0 if the first comparison's value is greater than the second's
[ "Compare", "the", "values", "used", "in", "the", "two", "comparisons" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/optimize/RewriteAsRangeCriteria.java#L283-L289
train
ModeShape/modeshape
web/modeshape-web-explorer/src/main/java/org/modeshape/web/BinaryContentUploadServlet.java
BinaryContentUploadServlet.getContentType
private String getContentType(List<FileItem> items) { for (FileItem i : items) { if (!i.isFormField() && i.getFieldName().equals(CONTENT_PARAMETER)) { return i.getContentType(); } } return null; }
java
private String getContentType(List<FileItem> items) { for (FileItem i : items) { if (!i.isFormField() && i.getFieldName().equals(CONTENT_PARAMETER)) { return i.getContentType(); } } return null; }
[ "private", "String", "getContentType", "(", "List", "<", "FileItem", ">", "items", ")", "{", "for", "(", "FileItem", "i", ":", "items", ")", "{", "if", "(", "!", "i", ".", "isFormField", "(", ")", "&&", "i", ".", "getFieldName", "(", ")", ".", "equ...
Determines content-type of the uploaded file. @param items @return the content type
[ "Determines", "content", "-", "type", "of", "the", "uploaded", "file", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/BinaryContentUploadServlet.java#L148-L155
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/collection/ring/SingleProducerCursor.java
SingleProducerCursor.claimUpTo
protected long claimUpTo( int number ) { assert number > 0; long nextPosition = this.nextPosition; long maxPosition = nextPosition + number; long wrapPoint = maxPosition - bufferSize; long cachedSlowestConsumerPosition = this.slowestConsumerPosition; if (wrapPoint > cachedSlowestConsumerPosition || cachedSlowestConsumerPosition > nextPosition) { long minPosition; while (wrapPoint > (minPosition = positionOfSlowestPointer(nextPosition))) { // This takes on the order of tens of nanoseconds, so it's a useful activity to pause a bit. LockSupport.parkNanos(1L); waitStrategy.signalAllWhenBlocking(); } this.slowestConsumerPosition = minPosition; } this.nextPosition = maxPosition; return maxPosition; }
java
protected long claimUpTo( int number ) { assert number > 0; long nextPosition = this.nextPosition; long maxPosition = nextPosition + number; long wrapPoint = maxPosition - bufferSize; long cachedSlowestConsumerPosition = this.slowestConsumerPosition; if (wrapPoint > cachedSlowestConsumerPosition || cachedSlowestConsumerPosition > nextPosition) { long minPosition; while (wrapPoint > (minPosition = positionOfSlowestPointer(nextPosition))) { // This takes on the order of tens of nanoseconds, so it's a useful activity to pause a bit. LockSupport.parkNanos(1L); waitStrategy.signalAllWhenBlocking(); } this.slowestConsumerPosition = minPosition; } this.nextPosition = maxPosition; return maxPosition; }
[ "protected", "long", "claimUpTo", "(", "int", "number", ")", "{", "assert", "number", ">", "0", ";", "long", "nextPosition", "=", "this", ".", "nextPosition", ";", "long", "maxPosition", "=", "nextPosition", "+", "number", ";", "long", "wrapPoint", "=", "m...
Claim up to the supplied number of positions. @param number the maximum number of positions to claim for writing; must be positive @return the highest position that were claimed
[ "Claim", "up", "to", "the", "supplied", "number", "of", "positions", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/collection/ring/SingleProducerCursor.java#L81-L101
train
ModeShape/modeshape
sequencers/modeshape-sequencer-epub/src/main/java/org/modeshape/sequencer/epub/EpubMetadata.java
EpubMetadata.getRootfiles
private List<String> getRootfiles( ZipInputStream zipStream ) throws Exception { List<String> rootfiles = new ArrayList<>(); ZipEntry entry = null; while ((entry = zipStream.getNextEntry()) != null) { String entryName = entry.getName(); if (entryName.endsWith("META-INF/container.xml")) { ByteArrayOutputStream content = getZipEntryContent(zipStream, entry); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.parse(new ByteArrayInputStream(content.toByteArray())); XPathFactory xPathfactory = XPathFactory.newInstance(); XPath xpath = xPathfactory.newXPath(); XPathExpression expr = xpath.compile("/container/rootfiles/rootfile"); NodeList rootfileNodes = (NodeList) expr.evaluate(doc, XPathConstants.NODESET); for (int i = 0; i < rootfileNodes.getLength(); i++) { Node node = rootfileNodes.item(i); rootfiles.add(node.getAttributes().getNamedItem("full-path").getNodeValue()); } break; } } return rootfiles; }
java
private List<String> getRootfiles( ZipInputStream zipStream ) throws Exception { List<String> rootfiles = new ArrayList<>(); ZipEntry entry = null; while ((entry = zipStream.getNextEntry()) != null) { String entryName = entry.getName(); if (entryName.endsWith("META-INF/container.xml")) { ByteArrayOutputStream content = getZipEntryContent(zipStream, entry); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.parse(new ByteArrayInputStream(content.toByteArray())); XPathFactory xPathfactory = XPathFactory.newInstance(); XPath xpath = xPathfactory.newXPath(); XPathExpression expr = xpath.compile("/container/rootfiles/rootfile"); NodeList rootfileNodes = (NodeList) expr.evaluate(doc, XPathConstants.NODESET); for (int i = 0; i < rootfileNodes.getLength(); i++) { Node node = rootfileNodes.item(i); rootfiles.add(node.getAttributes().getNamedItem("full-path").getNodeValue()); } break; } } return rootfiles; }
[ "private", "List", "<", "String", ">", "getRootfiles", "(", "ZipInputStream", "zipStream", ")", "throws", "Exception", "{", "List", "<", "String", ">", "rootfiles", "=", "new", "ArrayList", "<>", "(", ")", ";", "ZipEntry", "entry", "=", "null", ";", "while...
Parse the container file to get the list of all rootfile packages.
[ "Parse", "the", "container", "file", "to", "get", "the", "list", "of", "all", "rootfile", "packages", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-epub/src/main/java/org/modeshape/sequencer/epub/EpubMetadata.java#L233-L258
train
ModeShape/modeshape
sequencers/modeshape-sequencer-epub/src/main/java/org/modeshape/sequencer/epub/EpubMetadata.java
EpubMetadata.getZipEntryContent
private ByteArrayOutputStream getZipEntryContent( ZipInputStream zipStream, ZipEntry entry ) throws IOException { try (ByteArrayOutputStream content = new ByteArrayOutputStream()) { byte[] bytes = new byte[(int) entry.getSize()]; int read; while ((read = zipStream.read(bytes, 0, bytes.length)) != -1) { content.write(bytes, 0, read); } return content; } }
java
private ByteArrayOutputStream getZipEntryContent( ZipInputStream zipStream, ZipEntry entry ) throws IOException { try (ByteArrayOutputStream content = new ByteArrayOutputStream()) { byte[] bytes = new byte[(int) entry.getSize()]; int read; while ((read = zipStream.read(bytes, 0, bytes.length)) != -1) { content.write(bytes, 0, read); } return content; } }
[ "private", "ByteArrayOutputStream", "getZipEntryContent", "(", "ZipInputStream", "zipStream", ",", "ZipEntry", "entry", ")", "throws", "IOException", "{", "try", "(", "ByteArrayOutputStream", "content", "=", "new", "ByteArrayOutputStream", "(", ")", ")", "{", "byte", ...
Read the content of the ZipEntry without closing the stream.
[ "Read", "the", "content", "of", "the", "ZipEntry", "without", "closing", "the", "stream", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-epub/src/main/java/org/modeshape/sequencer/epub/EpubMetadata.java#L263-L275
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/cache/document/DocumentTranslator.java
DocumentTranslator.incrementBinaryReferenceCount
protected void incrementBinaryReferenceCount( BinaryKey binaryKey, Set<BinaryKey> unusedBinaryKeys, Set<BinaryKey> usedBinaryKeys ) { // Find the document metadata and increment the usage count ... String sha1 = binaryKey.toString(); String key = keyForBinaryReferenceDocument(sha1); // don't acquire a lock since we've already done this at the beginning of the #save EditableDocument entry = documentStore.edit(key, false); if (entry == null) { // The document doesn't yet exist, so create it ... Document content = Schematic.newDocument(SHA1, sha1, REFERENCE_COUNT, 1L); documentStore.localStore().put(key, content); } else { Long countValue = entry.getLong(REFERENCE_COUNT); entry.setNumber(REFERENCE_COUNT, countValue != null ? countValue + 1 : 1L); } // We're using the sha1, so remove it if its in the set of unused binary keys ... if (unusedBinaryKeys != null) { unusedBinaryKeys.remove(binaryKey); } if (usedBinaryKeys != null) { usedBinaryKeys.add(binaryKey); } }
java
protected void incrementBinaryReferenceCount( BinaryKey binaryKey, Set<BinaryKey> unusedBinaryKeys, Set<BinaryKey> usedBinaryKeys ) { // Find the document metadata and increment the usage count ... String sha1 = binaryKey.toString(); String key = keyForBinaryReferenceDocument(sha1); // don't acquire a lock since we've already done this at the beginning of the #save EditableDocument entry = documentStore.edit(key, false); if (entry == null) { // The document doesn't yet exist, so create it ... Document content = Schematic.newDocument(SHA1, sha1, REFERENCE_COUNT, 1L); documentStore.localStore().put(key, content); } else { Long countValue = entry.getLong(REFERENCE_COUNT); entry.setNumber(REFERENCE_COUNT, countValue != null ? countValue + 1 : 1L); } // We're using the sha1, so remove it if its in the set of unused binary keys ... if (unusedBinaryKeys != null) { unusedBinaryKeys.remove(binaryKey); } if (usedBinaryKeys != null) { usedBinaryKeys.add(binaryKey); } }
[ "protected", "void", "incrementBinaryReferenceCount", "(", "BinaryKey", "binaryKey", ",", "Set", "<", "BinaryKey", ">", "unusedBinaryKeys", ",", "Set", "<", "BinaryKey", ">", "usedBinaryKeys", ")", "{", "// Find the document metadata and increment the usage count ...", "Str...
Increment the reference count for the stored binary value with the supplied SHA-1 hash. @param binaryKey the key for the binary value; never null @param unusedBinaryKeys the set of binary keys that are considered unused; may be null @param usedBinaryKeys the set of binary keys that are considered used; may be null
[ "Increment", "the", "reference", "count", "for", "the", "stored", "binary", "value", "with", "the", "supplied", "SHA", "-", "1", "hash", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/cache/document/DocumentTranslator.java#L1242-L1265
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/cache/document/DocumentTranslator.java
DocumentTranslator.decrementBinaryReferenceCount
protected void decrementBinaryReferenceCount( Object fieldValue, Set<BinaryKey> unusedBinaryKeys, Set<BinaryKey> usedBinaryKeys) { if (fieldValue instanceof List<?>) { for (Object value : (List<?>)fieldValue) { decrementBinaryReferenceCount(value, unusedBinaryKeys, usedBinaryKeys); } } else if (fieldValue instanceof Object[]) { for (Object value : (Object[])fieldValue) { decrementBinaryReferenceCount(value, unusedBinaryKeys, usedBinaryKeys); } } else { String sha1 = null; if (fieldValue instanceof Document) { Document docValue = (Document)fieldValue; sha1 = docValue.getString(SHA1_FIELD); } else if (fieldValue instanceof BinaryKey) { sha1 = fieldValue.toString(); } else if (fieldValue instanceof org.modeshape.jcr.api.Binary && !(fieldValue instanceof InMemoryBinaryValue)) { sha1 = ((org.modeshape.jcr.api.Binary)fieldValue).getHexHash(); } if (sha1 != null) { BinaryKey binaryKey = new BinaryKey(sha1); // Find the document metadata and decrement the usage count ... // Don't acquire a lock since we should've done so at the beginning of the #save method EditableDocument sha1Usage = documentStore.edit(keyForBinaryReferenceDocument(sha1), false); if (sha1Usage != null) { Long countValue = sha1Usage.getLong(REFERENCE_COUNT); assert countValue != null; long count = countValue - 1; assert count >= 0; if (count == 0) { // We're not using the binary value anymore ... if (unusedBinaryKeys != null) { unusedBinaryKeys.add(binaryKey); } if (usedBinaryKeys != null) { usedBinaryKeys.remove(binaryKey); } } sha1Usage.setNumber(REFERENCE_COUNT, count); } else { // The documentStore doesn't contain the binary ref count doc, so we're no longer using the binary value ... if (unusedBinaryKeys != null) { unusedBinaryKeys.add(binaryKey); } if (usedBinaryKeys != null) { usedBinaryKeys.remove(binaryKey); } } } } }
java
protected void decrementBinaryReferenceCount( Object fieldValue, Set<BinaryKey> unusedBinaryKeys, Set<BinaryKey> usedBinaryKeys) { if (fieldValue instanceof List<?>) { for (Object value : (List<?>)fieldValue) { decrementBinaryReferenceCount(value, unusedBinaryKeys, usedBinaryKeys); } } else if (fieldValue instanceof Object[]) { for (Object value : (Object[])fieldValue) { decrementBinaryReferenceCount(value, unusedBinaryKeys, usedBinaryKeys); } } else { String sha1 = null; if (fieldValue instanceof Document) { Document docValue = (Document)fieldValue; sha1 = docValue.getString(SHA1_FIELD); } else if (fieldValue instanceof BinaryKey) { sha1 = fieldValue.toString(); } else if (fieldValue instanceof org.modeshape.jcr.api.Binary && !(fieldValue instanceof InMemoryBinaryValue)) { sha1 = ((org.modeshape.jcr.api.Binary)fieldValue).getHexHash(); } if (sha1 != null) { BinaryKey binaryKey = new BinaryKey(sha1); // Find the document metadata and decrement the usage count ... // Don't acquire a lock since we should've done so at the beginning of the #save method EditableDocument sha1Usage = documentStore.edit(keyForBinaryReferenceDocument(sha1), false); if (sha1Usage != null) { Long countValue = sha1Usage.getLong(REFERENCE_COUNT); assert countValue != null; long count = countValue - 1; assert count >= 0; if (count == 0) { // We're not using the binary value anymore ... if (unusedBinaryKeys != null) { unusedBinaryKeys.add(binaryKey); } if (usedBinaryKeys != null) { usedBinaryKeys.remove(binaryKey); } } sha1Usage.setNumber(REFERENCE_COUNT, count); } else { // The documentStore doesn't contain the binary ref count doc, so we're no longer using the binary value ... if (unusedBinaryKeys != null) { unusedBinaryKeys.add(binaryKey); } if (usedBinaryKeys != null) { usedBinaryKeys.remove(binaryKey); } } } } }
[ "protected", "void", "decrementBinaryReferenceCount", "(", "Object", "fieldValue", ",", "Set", "<", "BinaryKey", ">", "unusedBinaryKeys", ",", "Set", "<", "BinaryKey", ">", "usedBinaryKeys", ")", "{", "if", "(", "fieldValue", "instanceof", "List", "<", "?", ">",...
Decrement the reference count for the binary value. @param fieldValue the value in the document that may contain a binary value reference; may be null @param unusedBinaryKeys the set of binary keys that are considered unused; may be null @param usedBinaryKeys the set of binary keys that are considered used; may be null
[ "Decrement", "the", "reference", "count", "for", "the", "binary", "value", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/cache/document/DocumentTranslator.java#L1274-L1329
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/cache/document/DocumentTranslator.java
DocumentTranslator.isLocked
protected boolean isLocked( EditableDocument doc ) { return hasProperty(doc, JcrLexicon.LOCK_OWNER) || hasProperty(doc, JcrLexicon.LOCK_IS_DEEP); }
java
protected boolean isLocked( EditableDocument doc ) { return hasProperty(doc, JcrLexicon.LOCK_OWNER) || hasProperty(doc, JcrLexicon.LOCK_IS_DEEP); }
[ "protected", "boolean", "isLocked", "(", "EditableDocument", "doc", ")", "{", "return", "hasProperty", "(", "doc", ",", "JcrLexicon", ".", "LOCK_OWNER", ")", "||", "hasProperty", "(", "doc", ",", "JcrLexicon", ".", "LOCK_IS_DEEP", ")", ";", "}" ]
Checks if the given document is already locked @param doc the document @return true if the change was made successfully, or false otherwise
[ "Checks", "if", "the", "given", "document", "is", "already", "locked" ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/cache/document/DocumentTranslator.java#L1449-L1451
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/ResourceLookup.java
ResourceLookup.read
public static InputStream read( String path, ClassLoader classLoader, boolean useTLCL ) { if (useTLCL) { InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(path); if (stream != null) { return stream; } } return classLoader != null ? classLoader.getResourceAsStream(path) : ResourceLookup.class.getResourceAsStream(path); }
java
public static InputStream read( String path, ClassLoader classLoader, boolean useTLCL ) { if (useTLCL) { InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(path); if (stream != null) { return stream; } } return classLoader != null ? classLoader.getResourceAsStream(path) : ResourceLookup.class.getResourceAsStream(path); }
[ "public", "static", "InputStream", "read", "(", "String", "path", ",", "ClassLoader", "classLoader", ",", "boolean", "useTLCL", ")", "{", "if", "(", "useTLCL", ")", "{", "InputStream", "stream", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContext...
Returns the stream of a resource at a given path, using some optional class loaders. @param path the path to search @param classLoader a {@link java.lang.ClassLoader} instance to use when searching; may be null. @param useTLCL {@code true} if the thread local class loader should be used as well, in addition to {@code classLoader} @return a {@link java.io.InputStream} if the resource was found, or {@code null} otherwise
[ "Returns", "the", "stream", "of", "a", "resource", "at", "a", "given", "path", "using", "some", "optional", "class", "loaders", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/ResourceLookup.java#L38-L46
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/util/ResourceLookup.java
ResourceLookup.read
public static InputStream read( String path, Class<?> clazz, boolean useTLCL ) { return read(path, clazz.getClassLoader(), useTLCL); }
java
public static InputStream read( String path, Class<?> clazz, boolean useTLCL ) { return read(path, clazz.getClassLoader(), useTLCL); }
[ "public", "static", "InputStream", "read", "(", "String", "path", ",", "Class", "<", "?", ">", "clazz", ",", "boolean", "useTLCL", ")", "{", "return", "read", "(", "path", ",", "clazz", ".", "getClassLoader", "(", ")", ",", "useTLCL", ")", ";", "}" ]
Returns the stream of a resource at a given path, using the CL of a class. @param path the path to search @param clazz a {@link java.lang.Class} instance which class loader should be used when doing the lookup. @param useTLCL {@code true} if the thread local class loader should be used as well, in addition to {@code classLoader} @return a {@link java.io.InputStream} if the resource was found, or {@code null} otherwise @see org.modeshape.common.util.ResourceLookup#read(String, ClassLoader, boolean)
[ "Returns", "the", "stream", "of", "a", "resource", "at", "a", "given", "path", "using", "the", "CL", "of", "a", "class", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/ResourceLookup.java#L57-L59
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/value/binary/S3BinaryStore.java
S3BinaryStore.setS3ObjectTag
private void setS3ObjectTag(String objectKey, String tagKey, String tagValue) throws BinaryStoreException { try { GetObjectTaggingRequest getTaggingRequest = new GetObjectTaggingRequest(bucketName, objectKey); GetObjectTaggingResult getTaggingResult = s3Client.getObjectTagging(getTaggingRequest); List<Tag> initialTagSet = getTaggingResult.getTagSet(); List<Tag> mergedTagSet = mergeS3TagSet(initialTagSet, new Tag(tagKey, tagValue)); if (initialTagSet.size() == mergedTagSet.size() && initialTagSet.containsAll(mergedTagSet)) { return; } SetObjectTaggingRequest setObjectTaggingRequest = new SetObjectTaggingRequest(bucketName, objectKey, new ObjectTagging(mergedTagSet)); s3Client.setObjectTagging(setObjectTaggingRequest); } catch (AmazonClientException e) { throw new BinaryStoreException(e); } }
java
private void setS3ObjectTag(String objectKey, String tagKey, String tagValue) throws BinaryStoreException { try { GetObjectTaggingRequest getTaggingRequest = new GetObjectTaggingRequest(bucketName, objectKey); GetObjectTaggingResult getTaggingResult = s3Client.getObjectTagging(getTaggingRequest); List<Tag> initialTagSet = getTaggingResult.getTagSet(); List<Tag> mergedTagSet = mergeS3TagSet(initialTagSet, new Tag(tagKey, tagValue)); if (initialTagSet.size() == mergedTagSet.size() && initialTagSet.containsAll(mergedTagSet)) { return; } SetObjectTaggingRequest setObjectTaggingRequest = new SetObjectTaggingRequest(bucketName, objectKey, new ObjectTagging(mergedTagSet)); s3Client.setObjectTagging(setObjectTaggingRequest); } catch (AmazonClientException e) { throw new BinaryStoreException(e); } }
[ "private", "void", "setS3ObjectTag", "(", "String", "objectKey", ",", "String", "tagKey", ",", "String", "tagValue", ")", "throws", "BinaryStoreException", "{", "try", "{", "GetObjectTaggingRequest", "getTaggingRequest", "=", "new", "GetObjectTaggingRequest", "(", "bu...
Sets a tag on a S3 object, potentially overwriting the existing value. @param objectKey @param tagKey @param tagValue @throws BinaryStoreException
[ "Sets", "a", "tag", "on", "a", "S3", "object", "potentially", "overwriting", "the", "existing", "value", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/value/binary/S3BinaryStore.java#L338-L357
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/value/binary/S3BinaryStore.java
S3BinaryStore.mergeS3TagSet
private List<Tag> mergeS3TagSet(List<Tag> initialTags, Tag changeTag) { Map<String, String> mergedTags = initialTags.stream().collect(Collectors.toMap(Tag::getKey, Tag::getValue)); mergedTags.put(changeTag.getKey(), changeTag.getValue()); return mergedTags.entrySet().stream().map( entry -> new Tag(entry.getKey(), entry.getValue())).collect(Collectors.toList()); }
java
private List<Tag> mergeS3TagSet(List<Tag> initialTags, Tag changeTag) { Map<String, String> mergedTags = initialTags.stream().collect(Collectors.toMap(Tag::getKey, Tag::getValue)); mergedTags.put(changeTag.getKey(), changeTag.getValue()); return mergedTags.entrySet().stream().map( entry -> new Tag(entry.getKey(), entry.getValue())).collect(Collectors.toList()); }
[ "private", "List", "<", "Tag", ">", "mergeS3TagSet", "(", "List", "<", "Tag", ">", "initialTags", ",", "Tag", "changeTag", ")", "{", "Map", "<", "String", ",", "String", ">", "mergedTags", "=", "initialTags", ".", "stream", "(", ")", ".", "collect", "(...
Merges a new tag into an existing list of tags. It will be either appended to the list or overwrite the value of an existing tag with the same key. @param initialTags @param changeTag @return {@link List} of merged {@link Tag}s
[ "Merges", "a", "new", "tag", "into", "an", "existing", "list", "of", "tags", ".", "It", "will", "be", "either", "appended", "to", "the", "list", "or", "overwrite", "the", "value", "of", "an", "existing", "tag", "with", "the", "same", "key", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/value/binary/S3BinaryStore.java#L366-L371
train
ModeShape/modeshape
sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/datatype/DataTypeParser.java
DataTypeParser.parseLong
protected long parseLong( DdlTokenStream tokens, DataType dataType ) { String value = consume(tokens, dataType, false); return parseLong(value); }
java
protected long parseLong( DdlTokenStream tokens, DataType dataType ) { String value = consume(tokens, dataType, false); return parseLong(value); }
[ "protected", "long", "parseLong", "(", "DdlTokenStream", "tokens", ",", "DataType", "dataType", ")", "{", "String", "value", "=", "consume", "(", "tokens", ",", "dataType", ",", "false", ")", ";", "return", "parseLong", "(", "value", ")", ";", "}" ]
Returns a long value from the input token stream assuming the long is not bracketed with parenthesis. @param tokens @param dataType @return the long value
[ "Returns", "a", "long", "value", "from", "the", "input", "token", "stream", "assuming", "the", "long", "is", "not", "bracketed", "with", "parenthesis", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/datatype/DataTypeParser.java#L690-L694
train
ModeShape/modeshape
sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/datatype/DataTypeParser.java
DataTypeParser.parseBracketedLong
protected long parseBracketedLong( DdlTokenStream tokens, DataType dataType ) { consume(tokens, dataType, false, L_PAREN); String value = consume(tokens, dataType, false); consume(tokens, dataType, false, R_PAREN); return parseLong(value); }
java
protected long parseBracketedLong( DdlTokenStream tokens, DataType dataType ) { consume(tokens, dataType, false, L_PAREN); String value = consume(tokens, dataType, false); consume(tokens, dataType, false, R_PAREN); return parseLong(value); }
[ "protected", "long", "parseBracketedLong", "(", "DdlTokenStream", "tokens", ",", "DataType", "dataType", ")", "{", "consume", "(", "tokens", ",", "dataType", ",", "false", ",", "L_PAREN", ")", ";", "String", "value", "=", "consume", "(", "tokens", ",", "data...
Returns a long value from the input token stream assuming the long is bracketed with parenthesis. @param tokens @param dataType @return the long value
[ "Returns", "a", "long", "value", "from", "the", "input", "token", "stream", "assuming", "the", "long", "is", "bracketed", "with", "parenthesis", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/datatype/DataTypeParser.java#L703-L709
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/sequencer/SequencerPathExpression.java
SequencerPathExpression.compile
public static final SequencerPathExpression compile( String expression ) throws InvalidSequencerPathExpression { CheckArg.isNotNull(expression, "sequencer path expression"); expression = expression.trim(); if (expression.length() == 0) { throw new InvalidSequencerPathExpression(RepositoryI18n.pathExpressionMayNotBeBlank.text()); } java.util.regex.Matcher matcher = TWO_PART_PATTERN.matcher(expression); if (!matcher.matches()) { throw new InvalidSequencerPathExpression(RepositoryI18n.pathExpressionIsInvalid.text(expression)); } String selectExpression = matcher.group(1); String outputExpression = matcher.group(2); return new SequencerPathExpression(PathExpression.compile(selectExpression), outputExpression); }
java
public static final SequencerPathExpression compile( String expression ) throws InvalidSequencerPathExpression { CheckArg.isNotNull(expression, "sequencer path expression"); expression = expression.trim(); if (expression.length() == 0) { throw new InvalidSequencerPathExpression(RepositoryI18n.pathExpressionMayNotBeBlank.text()); } java.util.regex.Matcher matcher = TWO_PART_PATTERN.matcher(expression); if (!matcher.matches()) { throw new InvalidSequencerPathExpression(RepositoryI18n.pathExpressionIsInvalid.text(expression)); } String selectExpression = matcher.group(1); String outputExpression = matcher.group(2); return new SequencerPathExpression(PathExpression.compile(selectExpression), outputExpression); }
[ "public", "static", "final", "SequencerPathExpression", "compile", "(", "String", "expression", ")", "throws", "InvalidSequencerPathExpression", "{", "CheckArg", ".", "isNotNull", "(", "expression", ",", "\"sequencer path expression\"", ")", ";", "expression", "=", "exp...
Compile the supplied expression and return the resulting SequencerPathExpression instance. @param expression the expression @return the path expression; never null @throws IllegalArgumentException if the expression is null @throws InvalidSequencerPathExpression if the expression is blank or is not a valid expression
[ "Compile", "the", "supplied", "expression", "and", "return", "the", "resulting", "SequencerPathExpression", "instance", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/sequencer/SequencerPathExpression.java#L74-L87
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/sequencer/SequencerPathExpression.java
SequencerPathExpression.matcher
public Matcher matcher( String absolutePath ) { PathExpression.Matcher inputMatcher = selectExpression.matcher(absolutePath); String outputPath = null; WorkspacePath wsPath = null; if (inputMatcher.matches()) { // Grab the named groups ... Map<Integer, String> replacements = new HashMap<Integer, String>(); for (int i = 0, count = inputMatcher.groupCount(); i <= count; ++i) { replacements.put(i, inputMatcher.group(i)); } // Grab the selected path ... String selectedPath = inputMatcher.getSelectedNodePath(); // Find the output path using the groups from the match pattern ... wsPath = PathExpression.parsePathInWorkspace(this.outputExpression); if (wsPath != null) { if (wsPath.workspaceName == null) wsPath = wsPath.withWorkspaceName(inputMatcher.getSelectedWorkspaceName()); outputPath = wsPath.path; if (!DEFAULT_OUTPUT_EXPRESSION.equals(outputPath)) { java.util.regex.Matcher replacementMatcher = REPLACEMENT_VARIABLE_PATTERN.matcher(outputPath); // CHECKSTYLE IGNORE check FOR NEXT 1 LINES StringBuffer sb = new StringBuffer(); if (replacementMatcher.find()) { do { String variable = replacementMatcher.group(1); String replacement = replacements.get(Integer.valueOf(variable)); if (replacement == null) replacement = replacementMatcher.group(0); replacementMatcher.appendReplacement(sb, replacement); } while (replacementMatcher.find()); replacementMatcher.appendTail(sb); outputPath = sb.toString(); } // Make sure there is a trailing '/' ... if (!outputPath.endsWith("/")) outputPath = outputPath + "/"; // Replace all references to "/./" with "/" ... outputPath = outputPath.replaceAll("/\\./", "/"); // Remove any path segment followed by a parent reference ... java.util.regex.Matcher parentMatcher = PARENT_PATTERN.matcher(outputPath); while (parentMatcher.find()) { outputPath = parentMatcher.replaceAll(""); // Make sure there is a trailing '/' ... if (!outputPath.endsWith("/")) outputPath = outputPath + "/"; parentMatcher = PARENT_PATTERN.matcher(outputPath); } // Remove all multiple occurrences of '/' ... outputPath = outputPath.replaceAll("/{2,}", "/"); // Remove the trailing '/@property' ... outputPath = outputPath.replaceAll("/@[^/\\[\\]]+$", ""); // Remove a trailing '/' ... outputPath = outputPath.replaceAll("/$", ""); // If the output path is blank, then use the default output expression ... if (outputPath.length() == 0) outputPath = DEFAULT_OUTPUT_EXPRESSION; } if (DEFAULT_OUTPUT_EXPRESSION.equals(outputPath)) { // The output path is the default expression, so use the selected path ... outputPath = selectedPath; } wsPath = wsPath.withPath(outputPath); } } return new Matcher(inputMatcher, wsPath); }
java
public Matcher matcher( String absolutePath ) { PathExpression.Matcher inputMatcher = selectExpression.matcher(absolutePath); String outputPath = null; WorkspacePath wsPath = null; if (inputMatcher.matches()) { // Grab the named groups ... Map<Integer, String> replacements = new HashMap<Integer, String>(); for (int i = 0, count = inputMatcher.groupCount(); i <= count; ++i) { replacements.put(i, inputMatcher.group(i)); } // Grab the selected path ... String selectedPath = inputMatcher.getSelectedNodePath(); // Find the output path using the groups from the match pattern ... wsPath = PathExpression.parsePathInWorkspace(this.outputExpression); if (wsPath != null) { if (wsPath.workspaceName == null) wsPath = wsPath.withWorkspaceName(inputMatcher.getSelectedWorkspaceName()); outputPath = wsPath.path; if (!DEFAULT_OUTPUT_EXPRESSION.equals(outputPath)) { java.util.regex.Matcher replacementMatcher = REPLACEMENT_VARIABLE_PATTERN.matcher(outputPath); // CHECKSTYLE IGNORE check FOR NEXT 1 LINES StringBuffer sb = new StringBuffer(); if (replacementMatcher.find()) { do { String variable = replacementMatcher.group(1); String replacement = replacements.get(Integer.valueOf(variable)); if (replacement == null) replacement = replacementMatcher.group(0); replacementMatcher.appendReplacement(sb, replacement); } while (replacementMatcher.find()); replacementMatcher.appendTail(sb); outputPath = sb.toString(); } // Make sure there is a trailing '/' ... if (!outputPath.endsWith("/")) outputPath = outputPath + "/"; // Replace all references to "/./" with "/" ... outputPath = outputPath.replaceAll("/\\./", "/"); // Remove any path segment followed by a parent reference ... java.util.regex.Matcher parentMatcher = PARENT_PATTERN.matcher(outputPath); while (parentMatcher.find()) { outputPath = parentMatcher.replaceAll(""); // Make sure there is a trailing '/' ... if (!outputPath.endsWith("/")) outputPath = outputPath + "/"; parentMatcher = PARENT_PATTERN.matcher(outputPath); } // Remove all multiple occurrences of '/' ... outputPath = outputPath.replaceAll("/{2,}", "/"); // Remove the trailing '/@property' ... outputPath = outputPath.replaceAll("/@[^/\\[\\]]+$", ""); // Remove a trailing '/' ... outputPath = outputPath.replaceAll("/$", ""); // If the output path is blank, then use the default output expression ... if (outputPath.length() == 0) outputPath = DEFAULT_OUTPUT_EXPRESSION; } if (DEFAULT_OUTPUT_EXPRESSION.equals(outputPath)) { // The output path is the default expression, so use the selected path ... outputPath = selectedPath; } wsPath = wsPath.withPath(outputPath); } } return new Matcher(inputMatcher, wsPath); }
[ "public", "Matcher", "matcher", "(", "String", "absolutePath", ")", "{", "PathExpression", ".", "Matcher", "inputMatcher", "=", "selectExpression", ".", "matcher", "(", "absolutePath", ")", ";", "String", "outputPath", "=", "null", ";", "WorkspacePath", "wsPath", ...
Obtain a Matcher that can be used to convert the supplied workspace key and absolute path into an output workspace name and and output path. @param absolutePath the path in the workspace; may not be null @return the matcher; never null
[ "Obtain", "a", "Matcher", "that", "can", "be", "used", "to", "convert", "the", "supplied", "workspace", "key", "and", "absolute", "path", "into", "an", "output", "workspace", "name", "and", "and", "output", "path", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/sequencer/SequencerPathExpression.java#L154-L224
train
ModeShape/modeshape
modeshape-schematic/src/main/java/org/modeshape/schematic/DocumentFactory.java
DocumentFactory.newDocument
public static EditableDocument newDocument( Document original ) { BasicDocument newDoc = new BasicDocument(); newDoc.putAll(original); return new DocumentEditor(newDoc, DEFAULT_FACTORY); }
java
public static EditableDocument newDocument( Document original ) { BasicDocument newDoc = new BasicDocument(); newDoc.putAll(original); return new DocumentEditor(newDoc, DEFAULT_FACTORY); }
[ "public", "static", "EditableDocument", "newDocument", "(", "Document", "original", ")", "{", "BasicDocument", "newDoc", "=", "new", "BasicDocument", "(", ")", ";", "newDoc", ".", "putAll", "(", "original", ")", ";", "return", "new", "DocumentEditor", "(", "ne...
Create a new editable document that is a copy of the supplied document. @param original the original document @return the editable document; never null
[ "Create", "a", "new", "editable", "document", "that", "is", "a", "copy", "of", "the", "supplied", "document", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-schematic/src/main/java/org/modeshape/schematic/DocumentFactory.java#L44-L48
train
ModeShape/modeshape
modeshape-schematic/src/main/java/org/modeshape/schematic/DocumentFactory.java
DocumentFactory.newDocument
public static EditableDocument newDocument( String name, Object value ) { return new DocumentEditor(new BasicDocument(name, value), DEFAULT_FACTORY); }
java
public static EditableDocument newDocument( String name, Object value ) { return new DocumentEditor(new BasicDocument(name, value), DEFAULT_FACTORY); }
[ "public", "static", "EditableDocument", "newDocument", "(", "String", "name", ",", "Object", "value", ")", "{", "return", "new", "DocumentEditor", "(", "new", "BasicDocument", "(", "name", ",", "value", ")", ",", "DEFAULT_FACTORY", ")", ";", "}" ]
Create a new editable document, initialized with a single field, that can be used as a new document entry in a SchematicDb or as nested documents for other documents. @param name the name of the initial field in the resulting document; if null, the field will not be added to the returned document @param value the value of the initial field in the resulting document @return the editable document; never null
[ "Create", "a", "new", "editable", "document", "initialized", "with", "a", "single", "field", "that", "can", "be", "used", "as", "a", "new", "document", "entry", "in", "a", "SchematicDb", "or", "as", "nested", "documents", "for", "other", "documents", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-schematic/src/main/java/org/modeshape/schematic/DocumentFactory.java#L69-L72
train
ModeShape/modeshape
modeshape-schematic/src/main/java/org/modeshape/schematic/DocumentFactory.java
DocumentFactory.newDocument
public static EditableDocument newDocument( String name1, Object value1, String name2, Object value2 ) { return new DocumentEditor(new BasicDocument(name1, value1, name2, value2), DEFAULT_FACTORY); }
java
public static EditableDocument newDocument( String name1, Object value1, String name2, Object value2 ) { return new DocumentEditor(new BasicDocument(name1, value1, name2, value2), DEFAULT_FACTORY); }
[ "public", "static", "EditableDocument", "newDocument", "(", "String", "name1", ",", "Object", "value1", ",", "String", "name2", ",", "Object", "value2", ")", "{", "return", "new", "DocumentEditor", "(", "new", "BasicDocument", "(", "name1", ",", "value1", ",",...
Create a new editable document, initialized with two fields, that can be used as a new document entry in a SchematicDb or as nested documents for other documents. @param name1 the name of the first field in the resulting document; if null, the field will not be added to the returned document @param value1 the value of the first field in the resulting document @param name2 the name of the second field in the resulting document; if null, the field will not be added to the returned document @param value2 the value of the second field in the resulting document @return the editable document; never null
[ "Create", "a", "new", "editable", "document", "initialized", "with", "two", "fields", "that", "can", "be", "used", "as", "a", "new", "document", "entry", "in", "a", "SchematicDb", "or", "as", "nested", "documents", "for", "other", "documents", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-schematic/src/main/java/org/modeshape/schematic/DocumentFactory.java#L86-L91
train