repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
ModeShape/modeshape | modeshape-common/src/main/java/org/modeshape/common/util/Reflection.java | Reflection.convertArgumentClassesToPrimitives | public static List<Class<?>> convertArgumentClassesToPrimitives( Class<?>... arguments ) {
if (arguments == null || arguments.length == 0) return Collections.emptyList();
List<Class<?>> result = new ArrayList<Class<?>>(arguments.length);
for (Class<?> clazz : arguments) {
if (clazz == Boolean.class) clazz = Boolean.TYPE;
else if (clazz == Character.class) clazz = Character.TYPE;
else if (clazz == Byte.class) clazz = Byte.TYPE;
else if (clazz == Short.class) clazz = Short.TYPE;
else if (clazz == Integer.class) clazz = Integer.TYPE;
else if (clazz == Long.class) clazz = Long.TYPE;
else if (clazz == Float.class) clazz = Float.TYPE;
else if (clazz == Double.class) clazz = Double.TYPE;
else if (clazz == Void.class) clazz = Void.TYPE;
result.add(clazz);
}
return result;
} | java | public static List<Class<?>> convertArgumentClassesToPrimitives( Class<?>... arguments ) {
if (arguments == null || arguments.length == 0) return Collections.emptyList();
List<Class<?>> result = new ArrayList<Class<?>>(arguments.length);
for (Class<?> clazz : arguments) {
if (clazz == Boolean.class) clazz = Boolean.TYPE;
else if (clazz == Character.class) clazz = Character.TYPE;
else if (clazz == Byte.class) clazz = Byte.TYPE;
else if (clazz == Short.class) clazz = Short.TYPE;
else if (clazz == Integer.class) clazz = Integer.TYPE;
else if (clazz == Long.class) clazz = Long.TYPE;
else if (clazz == Float.class) clazz = Float.TYPE;
else if (clazz == Double.class) clazz = Double.TYPE;
else if (clazz == Void.class) clazz = Void.TYPE;
result.add(clazz);
}
return result;
} | [
"public",
"static",
"List",
"<",
"Class",
"<",
"?",
">",
">",
"convertArgumentClassesToPrimitives",
"(",
"Class",
"<",
"?",
">",
"...",
"arguments",
")",
"{",
"if",
"(",
"arguments",
"==",
"null",
"||",
"arguments",
".",
"length",
"==",
"0",
")",
"return... | Convert any argument classes to primitives.
@param arguments the list of argument classes.
@return the list of Class instances in which any classes that could be represented by primitives (e.g., Boolean) were
replaced with the primitive classes (e.g., Boolean.TYPE). | [
"Convert",
"any",
"argument",
"classes",
"to",
"primitives",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/Reflection.java#L102-L119 | train |
ModeShape/modeshape | modeshape-common/src/main/java/org/modeshape/common/util/Reflection.java | Reflection.getClassName | public static String getClassName( final Class<?> clazz ) {
final String fullName = clazz.getName();
final int fullNameLength = fullName.length();
// Check for array ('[') or the class/interface marker ('L') ...
int numArrayDimensions = 0;
while (numArrayDimensions < fullNameLength) {
final char c = fullName.charAt(numArrayDimensions);
if (c != '[') {
String name = null;
// Not an array, so it must be one of the other markers ...
switch (c) {
case 'L': {
name = fullName.subSequence(numArrayDimensions + 1, fullNameLength).toString();
break;
}
case 'B': {
name = "byte";
break;
}
case 'C': {
name = "char";
break;
}
case 'D': {
name = "double";
break;
}
case 'F': {
name = "float";
break;
}
case 'I': {
name = "int";
break;
}
case 'J': {
name = "long";
break;
}
case 'S': {
name = "short";
break;
}
case 'Z': {
name = "boolean";
break;
}
case 'V': {
name = "void";
break;
}
default: {
name = fullName.subSequence(numArrayDimensions, fullNameLength).toString();
}
}
if (numArrayDimensions == 0) {
// No array markers, so just return the name ...
return name;
}
// Otherwise, add the array markers and the name ...
if (numArrayDimensions < BRACKETS_PAIR.length) {
name = name + BRACKETS_PAIR[numArrayDimensions];
} else {
for (int i = 0; i < numArrayDimensions; i++) {
name = name + BRACKETS_PAIR[1];
}
}
return name;
}
++numArrayDimensions;
}
return fullName;
} | java | public static String getClassName( final Class<?> clazz ) {
final String fullName = clazz.getName();
final int fullNameLength = fullName.length();
// Check for array ('[') or the class/interface marker ('L') ...
int numArrayDimensions = 0;
while (numArrayDimensions < fullNameLength) {
final char c = fullName.charAt(numArrayDimensions);
if (c != '[') {
String name = null;
// Not an array, so it must be one of the other markers ...
switch (c) {
case 'L': {
name = fullName.subSequence(numArrayDimensions + 1, fullNameLength).toString();
break;
}
case 'B': {
name = "byte";
break;
}
case 'C': {
name = "char";
break;
}
case 'D': {
name = "double";
break;
}
case 'F': {
name = "float";
break;
}
case 'I': {
name = "int";
break;
}
case 'J': {
name = "long";
break;
}
case 'S': {
name = "short";
break;
}
case 'Z': {
name = "boolean";
break;
}
case 'V': {
name = "void";
break;
}
default: {
name = fullName.subSequence(numArrayDimensions, fullNameLength).toString();
}
}
if (numArrayDimensions == 0) {
// No array markers, so just return the name ...
return name;
}
// Otherwise, add the array markers and the name ...
if (numArrayDimensions < BRACKETS_PAIR.length) {
name = name + BRACKETS_PAIR[numArrayDimensions];
} else {
for (int i = 0; i < numArrayDimensions; i++) {
name = name + BRACKETS_PAIR[1];
}
}
return name;
}
++numArrayDimensions;
}
return fullName;
} | [
"public",
"static",
"String",
"getClassName",
"(",
"final",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"final",
"String",
"fullName",
"=",
"clazz",
".",
"getName",
"(",
")",
";",
"final",
"int",
"fullNameLength",
"=",
"fullName",
".",
"length",
"(",
")",... | Returns the name of the class. The result will be the fully-qualified class name, or the readable form for arrays and
primitive types.
@param clazz the class for which the class name is to be returned.
@return the readable name of the class. | [
"Returns",
"the",
"name",
"of",
"the",
"class",
".",
"The",
"result",
"will",
"be",
"the",
"fully",
"-",
"qualified",
"class",
"name",
"or",
"the",
"readable",
"form",
"for",
"arrays",
"and",
"primitive",
"types",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/Reflection.java#L128-L202 | train |
ModeShape/modeshape | modeshape-common/src/main/java/org/modeshape/common/util/Reflection.java | Reflection.setValue | public static void setValue(Object instance, String fieldName, Object value) {
try {
Field f = findFieldRecursively(instance.getClass(), fieldName);
if (f == null)
throw new NoSuchMethodException("Cannot find field " + fieldName + " on " + instance.getClass() + " or superclasses");
f.setAccessible(true);
f.set(instance, value);
} catch (Exception e) {
throw new RuntimeException(e);
}
} | java | public static void setValue(Object instance, String fieldName, Object value) {
try {
Field f = findFieldRecursively(instance.getClass(), fieldName);
if (f == null)
throw new NoSuchMethodException("Cannot find field " + fieldName + " on " + instance.getClass() + " or superclasses");
f.setAccessible(true);
f.set(instance, value);
} catch (Exception e) {
throw new RuntimeException(e);
}
} | [
"public",
"static",
"void",
"setValue",
"(",
"Object",
"instance",
",",
"String",
"fieldName",
",",
"Object",
"value",
")",
"{",
"try",
"{",
"Field",
"f",
"=",
"findFieldRecursively",
"(",
"instance",
".",
"getClass",
"(",
")",
",",
"fieldName",
")",
";",
... | Sets the value of a field of an object instance via reflection
@param instance to inspect
@param fieldName name of field to set
@param value the value to set | [
"Sets",
"the",
"value",
"of",
"a",
"field",
"of",
"an",
"object",
"instance",
"via",
"reflection"
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/Reflection.java#L211-L221 | train |
ModeShape/modeshape | modeshape-common/src/main/java/org/modeshape/common/util/Reflection.java | Reflection.findMethod | public static Method findMethod(Class<?> type, String methodName) {
try {
return type.getDeclaredMethod(methodName);
} catch (NoSuchMethodException e) {
if (type.equals(Object.class) || type.isInterface()) {
throw new RuntimeException(e);
}
return findMethod(type.getSuperclass(), methodName);
}
} | java | public static Method findMethod(Class<?> type, String methodName) {
try {
return type.getDeclaredMethod(methodName);
} catch (NoSuchMethodException e) {
if (type.equals(Object.class) || type.isInterface()) {
throw new RuntimeException(e);
}
return findMethod(type.getSuperclass(), methodName);
}
} | [
"public",
"static",
"Method",
"findMethod",
"(",
"Class",
"<",
"?",
">",
"type",
",",
"String",
"methodName",
")",
"{",
"try",
"{",
"return",
"type",
".",
"getDeclaredMethod",
"(",
"methodName",
")",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"e",
")... | Searches for a method with a given name in a class.
@param type a {@link Class} instance; never null
@param methodName the name of the method to search for; never null
@return a {@link Method} instance if the method is found | [
"Searches",
"for",
"a",
"method",
"with",
"a",
"given",
"name",
"in",
"a",
"class",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/Reflection.java#L249-L258 | train |
ModeShape/modeshape | modeshape-common/src/main/java/org/modeshape/common/util/Reflection.java | Reflection.findMethods | public Method[] findMethods( Pattern methodNamePattern ) {
final Method[] allMethods = this.targetClass.getMethods();
final List<Method> result = new ArrayList<Method>();
for (int i = 0; i < allMethods.length; i++) {
final Method m = allMethods[i];
if (methodNamePattern.matcher(m.getName()).matches()) {
result.add(m);
}
}
return result.toArray(new Method[result.size()]);
} | java | public Method[] findMethods( Pattern methodNamePattern ) {
final Method[] allMethods = this.targetClass.getMethods();
final List<Method> result = new ArrayList<Method>();
for (int i = 0; i < allMethods.length; i++) {
final Method m = allMethods[i];
if (methodNamePattern.matcher(m.getName()).matches()) {
result.add(m);
}
}
return result.toArray(new Method[result.size()]);
} | [
"public",
"Method",
"[",
"]",
"findMethods",
"(",
"Pattern",
"methodNamePattern",
")",
"{",
"final",
"Method",
"[",
"]",
"allMethods",
"=",
"this",
".",
"targetClass",
".",
"getMethods",
"(",
")",
";",
"final",
"List",
"<",
"Method",
">",
"result",
"=",
... | Find the methods on the target class that matches the supplied method name.
@param methodNamePattern the regular expression pattern for the name of the method that is to be found.
@return the Method objects that have a matching name, or an empty array if there are no methods that have a matching name. | [
"Find",
"the",
"methods",
"on",
"the",
"target",
"class",
"that",
"matches",
"the",
"supplied",
"method",
"name",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/Reflection.java#L384-L394 | train |
ModeShape/modeshape | modeshape-common/src/main/java/org/modeshape/common/util/Reflection.java | Reflection.invokeGetterMethodOnTarget | public Object invokeGetterMethodOnTarget( String javaPropertyName,
Object target )
throws NoSuchMethodException, SecurityException, IllegalArgumentException, IllegalAccessException,
InvocationTargetException {
String[] methodNamesArray = findMethodNames("get" + javaPropertyName);
if (methodNamesArray.length <= 0) {
// Try 'is' getter ...
methodNamesArray = findMethodNames("is" + javaPropertyName);
}
if (methodNamesArray.length <= 0) {
// Try 'are' getter ...
methodNamesArray = findMethodNames("are" + javaPropertyName);
}
return invokeBestMethodOnTarget(methodNamesArray, target);
} | java | public Object invokeGetterMethodOnTarget( String javaPropertyName,
Object target )
throws NoSuchMethodException, SecurityException, IllegalArgumentException, IllegalAccessException,
InvocationTargetException {
String[] methodNamesArray = findMethodNames("get" + javaPropertyName);
if (methodNamesArray.length <= 0) {
// Try 'is' getter ...
methodNamesArray = findMethodNames("is" + javaPropertyName);
}
if (methodNamesArray.length <= 0) {
// Try 'are' getter ...
methodNamesArray = findMethodNames("are" + javaPropertyName);
}
return invokeBestMethodOnTarget(methodNamesArray, target);
} | [
"public",
"Object",
"invokeGetterMethodOnTarget",
"(",
"String",
"javaPropertyName",
",",
"Object",
"target",
")",
"throws",
"NoSuchMethodException",
",",
"SecurityException",
",",
"IllegalArgumentException",
",",
"IllegalAccessException",
",",
"InvocationTargetException",
"{... | Find and execute the getter method on the target class for the supplied property name. If no such method is found, a
NoSuchMethodException is thrown.
@param javaPropertyName the name of the property whose getter is to be invoked, in the order they are to be tried
@param target the object on which the method is to be invoked
@return the property value (the result of the getter method call)
@throws NoSuchMethodException if a matching method is not found.
@throws SecurityException if access to the information is denied.
@throws InvocationTargetException
@throws IllegalAccessException
@throws IllegalArgumentException | [
"Find",
"and",
"execute",
"the",
"getter",
"method",
"on",
"the",
"target",
"class",
"for",
"the",
"supplied",
"property",
"name",
".",
"If",
"no",
"such",
"method",
"is",
"found",
"a",
"NoSuchMethodException",
"is",
"thrown",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/Reflection.java#L633-L647 | train |
ModeShape/modeshape | modeshape-common/src/main/java/org/modeshape/common/util/Reflection.java | Reflection.setProperty | public void setProperty( Object target,
Property property,
Object value )
throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException,
InvocationTargetException {
CheckArg.isNotNull(target, "target");
CheckArg.isNotNull(property, "property");
CheckArg.isNotNull(property.getName(), "property.getName()");
invokeSetterMethodOnTarget(property.getName(), target, value);
} | java | public void setProperty( Object target,
Property property,
Object value )
throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException,
InvocationTargetException {
CheckArg.isNotNull(target, "target");
CheckArg.isNotNull(property, "property");
CheckArg.isNotNull(property.getName(), "property.getName()");
invokeSetterMethodOnTarget(property.getName(), target, value);
} | [
"public",
"void",
"setProperty",
"(",
"Object",
"target",
",",
"Property",
"property",
",",
"Object",
"value",
")",
"throws",
"SecurityException",
",",
"IllegalArgumentException",
",",
"NoSuchMethodException",
",",
"IllegalAccessException",
",",
"InvocationTargetException... | Set the property on the supplied target object to the specified value.
@param target the target on which the setter is to be called; may not be null
@param property the property that is to be set on the target
@param value the new value for the property
@throws NoSuchMethodException if a matching method is not found.
@throws SecurityException if access to the information is denied.
@throws IllegalAccessException if the setter method could not be accessed
@throws InvocationTargetException if there was an error invoking the setter method on the target
@throws IllegalArgumentException if 'target' is null, 'property' is null, or 'property.getName()' is null | [
"Set",
"the",
"property",
"on",
"the",
"supplied",
"target",
"object",
"to",
"the",
"specified",
"value",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/Reflection.java#L1105-L1114 | train |
ModeShape/modeshape | modeshape-common/src/main/java/org/modeshape/common/util/Reflection.java | Reflection.getProperty | public Object getProperty( Object target,
Property property )
throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException,
InvocationTargetException {
CheckArg.isNotNull(target, "target");
CheckArg.isNotNull(property, "property");
CheckArg.isNotNull(property.getName(), "property.getName()");
return invokeGetterMethodOnTarget(property.getName(), target);
} | java | public Object getProperty( Object target,
Property property )
throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException,
InvocationTargetException {
CheckArg.isNotNull(target, "target");
CheckArg.isNotNull(property, "property");
CheckArg.isNotNull(property.getName(), "property.getName()");
return invokeGetterMethodOnTarget(property.getName(), target);
} | [
"public",
"Object",
"getProperty",
"(",
"Object",
"target",
",",
"Property",
"property",
")",
"throws",
"SecurityException",
",",
"IllegalArgumentException",
",",
"NoSuchMethodException",
",",
"IllegalAccessException",
",",
"InvocationTargetException",
"{",
"CheckArg",
".... | Get current value for the property on the supplied target object.
@param target the target on which the setter is to be called; may not be null
@param property the property that is to be set on the target
@return the current value for the property; may be null
@throws NoSuchMethodException if a matching method is not found.
@throws SecurityException if access to the information is denied.
@throws IllegalAccessException if the setter method could not be accessed
@throws InvocationTargetException if there was an error invoking the setter method on the target
@throws IllegalArgumentException if 'target' is null, 'property' is null, or 'property.getName()' is null | [
"Get",
"current",
"value",
"for",
"the",
"property",
"on",
"the",
"supplied",
"target",
"object",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/Reflection.java#L1128-L1136 | train |
ModeShape/modeshape | modeshape-common/src/main/java/org/modeshape/common/util/Reflection.java | Reflection.getPropertyAsString | public String getPropertyAsString( Object target,
Property property )
throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException,
InvocationTargetException {
Object value = getProperty(target, property);
StringBuilder sb = new StringBuilder();
writeObjectAsString(value, sb, false);
return sb.toString();
} | java | public String getPropertyAsString( Object target,
Property property )
throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException,
InvocationTargetException {
Object value = getProperty(target, property);
StringBuilder sb = new StringBuilder();
writeObjectAsString(value, sb, false);
return sb.toString();
} | [
"public",
"String",
"getPropertyAsString",
"(",
"Object",
"target",
",",
"Property",
"property",
")",
"throws",
"SecurityException",
",",
"IllegalArgumentException",
",",
"NoSuchMethodException",
",",
"IllegalAccessException",
",",
"InvocationTargetException",
"{",
"Object"... | Get current value represented as a string for the property on the supplied target object.
@param target the target on which the setter is to be called; may not be null
@param property the property that is to be set on the target
@return the current value for the property; may be null
@throws NoSuchMethodException if a matching method is not found.
@throws SecurityException if access to the information is denied.
@throws IllegalAccessException if the setter method could not be accessed
@throws InvocationTargetException if there was an error invoking the setter method on the target
@throws IllegalArgumentException if 'target' is null, 'property' is null, or 'property.getName()' is null | [
"Get",
"current",
"value",
"represented",
"as",
"a",
"string",
"for",
"the",
"property",
"on",
"the",
"supplied",
"target",
"object",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/Reflection.java#L1150-L1158 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/cache/NodeKey.java | NodeKey.getSourceKey | public String getSourceKey() {
if (sourceKey == null) {
// Value is idempotent, so it's okay to do this without synchronizing ...
sourceKey = key.substring(SOURCE_START_INDEX, SOURCE_END_INDEX);
}
return sourceKey;
} | java | public String getSourceKey() {
if (sourceKey == null) {
// Value is idempotent, so it's okay to do this without synchronizing ...
sourceKey = key.substring(SOURCE_START_INDEX, SOURCE_END_INDEX);
}
return sourceKey;
} | [
"public",
"String",
"getSourceKey",
"(",
")",
"{",
"if",
"(",
"sourceKey",
"==",
"null",
")",
"{",
"// Value is idempotent, so it's okay to do this without synchronizing ...",
"sourceKey",
"=",
"key",
".",
"substring",
"(",
"SOURCE_START_INDEX",
",",
"SOURCE_END_INDEX",
... | Get the multi-character key uniquely identifying the repository's storage source in which this node appears.
@return the source key; never null and always contains at least one character | [
"Get",
"the",
"multi",
"-",
"character",
"key",
"uniquely",
"identifying",
"the",
"repository",
"s",
"storage",
"source",
"in",
"which",
"this",
"node",
"appears",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/cache/NodeKey.java#L151-L157 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/cache/NodeKey.java | NodeKey.getWorkspaceKey | public String getWorkspaceKey() {
if (workspaceKey == null) {
// Value is idempotent, so it's okay to do this without synchronizing ...
workspaceKey = key.substring(WORKSPACE_START_INDEX, WORKSPACE_END_INDEX);
}
return workspaceKey;
} | java | public String getWorkspaceKey() {
if (workspaceKey == null) {
// Value is idempotent, so it's okay to do this without synchronizing ...
workspaceKey = key.substring(WORKSPACE_START_INDEX, WORKSPACE_END_INDEX);
}
return workspaceKey;
} | [
"public",
"String",
"getWorkspaceKey",
"(",
")",
"{",
"if",
"(",
"workspaceKey",
"==",
"null",
")",
"{",
"// Value is idempotent, so it's okay to do this without synchronizing ...",
"workspaceKey",
"=",
"key",
".",
"substring",
"(",
"WORKSPACE_START_INDEX",
",",
"WORKSPAC... | Get the multi-character key uniquely identifying the workspace in which the node appears.
@return the workspace key; never null and always contains at least one character | [
"Get",
"the",
"multi",
"-",
"character",
"key",
"uniquely",
"identifying",
"the",
"workspace",
"in",
"which",
"the",
"node",
"appears",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/cache/NodeKey.java#L164-L170 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/QueryBuilder.java | QueryBuilder.union | public QueryBuilder union() {
this.firstQuery = query();
this.firstQuerySetOperation = Operation.UNION;
this.firstQueryAll = false;
clear(false);
return this;
} | java | public QueryBuilder union() {
this.firstQuery = query();
this.firstQuerySetOperation = Operation.UNION;
this.firstQueryAll = false;
clear(false);
return this;
} | [
"public",
"QueryBuilder",
"union",
"(",
")",
"{",
"this",
".",
"firstQuery",
"=",
"query",
"(",
")",
";",
"this",
".",
"firstQuerySetOperation",
"=",
"Operation",
".",
"UNION",
";",
"this",
".",
"firstQueryAll",
"=",
"false",
";",
"clear",
"(",
"false",
... | Perform a UNION between the query as defined prior to this method and the query that will be defined following this method.
@return this builder object, for convenience in method chaining | [
"Perform",
"a",
"UNION",
"between",
"the",
"query",
"as",
"defined",
"prior",
"to",
"this",
"method",
"and",
"the",
"query",
"that",
"will",
"be",
"defined",
"following",
"this",
"method",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/QueryBuilder.java#L621-L627 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/QueryBuilder.java | QueryBuilder.unionAll | public QueryBuilder unionAll() {
this.firstQuery = query();
this.firstQuerySetOperation = Operation.UNION;
this.firstQueryAll = true;
clear(false);
return this;
} | java | public QueryBuilder unionAll() {
this.firstQuery = query();
this.firstQuerySetOperation = Operation.UNION;
this.firstQueryAll = true;
clear(false);
return this;
} | [
"public",
"QueryBuilder",
"unionAll",
"(",
")",
"{",
"this",
".",
"firstQuery",
"=",
"query",
"(",
")",
";",
"this",
".",
"firstQuerySetOperation",
"=",
"Operation",
".",
"UNION",
";",
"this",
".",
"firstQueryAll",
"=",
"true",
";",
"clear",
"(",
"false",
... | Perform a UNION ALL between the query as defined prior to this method and the query that will be defined following this
method.
@return this builder object, for convenience in method chaining | [
"Perform",
"a",
"UNION",
"ALL",
"between",
"the",
"query",
"as",
"defined",
"prior",
"to",
"this",
"method",
"and",
"the",
"query",
"that",
"will",
"be",
"defined",
"following",
"this",
"method",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/QueryBuilder.java#L635-L641 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/QueryBuilder.java | QueryBuilder.intersect | public QueryBuilder intersect() {
this.firstQuery = query();
this.firstQuerySetOperation = Operation.INTERSECT;
this.firstQueryAll = false;
clear(false);
return this;
} | java | public QueryBuilder intersect() {
this.firstQuery = query();
this.firstQuerySetOperation = Operation.INTERSECT;
this.firstQueryAll = false;
clear(false);
return this;
} | [
"public",
"QueryBuilder",
"intersect",
"(",
")",
"{",
"this",
".",
"firstQuery",
"=",
"query",
"(",
")",
";",
"this",
".",
"firstQuerySetOperation",
"=",
"Operation",
".",
"INTERSECT",
";",
"this",
".",
"firstQueryAll",
"=",
"false",
";",
"clear",
"(",
"fa... | Perform an INTERSECT between the query as defined prior to this method and the query that will be defined following this
method.
@return this builder object, for convenience in method chaining | [
"Perform",
"an",
"INTERSECT",
"between",
"the",
"query",
"as",
"defined",
"prior",
"to",
"this",
"method",
"and",
"the",
"query",
"that",
"will",
"be",
"defined",
"following",
"this",
"method",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/QueryBuilder.java#L649-L655 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/QueryBuilder.java | QueryBuilder.intersectAll | public QueryBuilder intersectAll() {
this.firstQuery = query();
this.firstQuerySetOperation = Operation.INTERSECT;
this.firstQueryAll = true;
clear(false);
return this;
} | java | public QueryBuilder intersectAll() {
this.firstQuery = query();
this.firstQuerySetOperation = Operation.INTERSECT;
this.firstQueryAll = true;
clear(false);
return this;
} | [
"public",
"QueryBuilder",
"intersectAll",
"(",
")",
"{",
"this",
".",
"firstQuery",
"=",
"query",
"(",
")",
";",
"this",
".",
"firstQuerySetOperation",
"=",
"Operation",
".",
"INTERSECT",
";",
"this",
".",
"firstQueryAll",
"=",
"true",
";",
"clear",
"(",
"... | Perform an INTERSECT ALL between the query as defined prior to this method and the query that will be defined following
this method.
@return this builder object, for convenience in method chaining | [
"Perform",
"an",
"INTERSECT",
"ALL",
"between",
"the",
"query",
"as",
"defined",
"prior",
"to",
"this",
"method",
"and",
"the",
"query",
"that",
"will",
"be",
"defined",
"following",
"this",
"method",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/QueryBuilder.java#L663-L669 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/QueryBuilder.java | QueryBuilder.except | public QueryBuilder except() {
this.firstQuery = query();
this.firstQuerySetOperation = Operation.EXCEPT;
this.firstQueryAll = false;
clear(false);
return this;
} | java | public QueryBuilder except() {
this.firstQuery = query();
this.firstQuerySetOperation = Operation.EXCEPT;
this.firstQueryAll = false;
clear(false);
return this;
} | [
"public",
"QueryBuilder",
"except",
"(",
")",
"{",
"this",
".",
"firstQuery",
"=",
"query",
"(",
")",
";",
"this",
".",
"firstQuerySetOperation",
"=",
"Operation",
".",
"EXCEPT",
";",
"this",
".",
"firstQueryAll",
"=",
"false",
";",
"clear",
"(",
"false",
... | Perform an EXCEPT between the query as defined prior to this method and the query that will be defined following this
method.
@return this builder object, for convenience in method chaining | [
"Perform",
"an",
"EXCEPT",
"between",
"the",
"query",
"as",
"defined",
"prior",
"to",
"this",
"method",
"and",
"the",
"query",
"that",
"will",
"be",
"defined",
"following",
"this",
"method",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/QueryBuilder.java#L677-L683 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/QueryBuilder.java | QueryBuilder.exceptAll | public QueryBuilder exceptAll() {
this.firstQuery = query();
this.firstQuerySetOperation = Operation.EXCEPT;
this.firstQueryAll = true;
clear(false);
return this;
} | java | public QueryBuilder exceptAll() {
this.firstQuery = query();
this.firstQuerySetOperation = Operation.EXCEPT;
this.firstQueryAll = true;
clear(false);
return this;
} | [
"public",
"QueryBuilder",
"exceptAll",
"(",
")",
"{",
"this",
".",
"firstQuery",
"=",
"query",
"(",
")",
";",
"this",
".",
"firstQuerySetOperation",
"=",
"Operation",
".",
"EXCEPT",
";",
"this",
".",
"firstQueryAll",
"=",
"true",
";",
"clear",
"(",
"false"... | Perform an EXCEPT ALL between the query as defined prior to this method and the query that will be defined following this
method.
@return this builder object, for convenience in method chaining | [
"Perform",
"an",
"EXCEPT",
"ALL",
"between",
"the",
"query",
"as",
"defined",
"prior",
"to",
"this",
"method",
"and",
"the",
"query",
"that",
"will",
"be",
"defined",
"following",
"this",
"method",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/QueryBuilder.java#L691-L697 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/spi/index/provider/IndexChangeAdapters.java | IndexChangeAdapters.forMultipleColumns | public static IndexChangeAdapter forMultipleColumns( ExecutionContext context,
NodeTypePredicate matcher,
String workspaceName,
ProvidedIndex<?> index,
Iterable<IndexChangeAdapter> adapters ) {
return new MultiColumnChangeAdapter(context ,workspaceName, matcher, index, adapters);
} | java | public static IndexChangeAdapter forMultipleColumns( ExecutionContext context,
NodeTypePredicate matcher,
String workspaceName,
ProvidedIndex<?> index,
Iterable<IndexChangeAdapter> adapters ) {
return new MultiColumnChangeAdapter(context ,workspaceName, matcher, index, adapters);
} | [
"public",
"static",
"IndexChangeAdapter",
"forMultipleColumns",
"(",
"ExecutionContext",
"context",
",",
"NodeTypePredicate",
"matcher",
",",
"String",
"workspaceName",
",",
"ProvidedIndex",
"<",
"?",
">",
"index",
",",
"Iterable",
"<",
"IndexChangeAdapter",
">",
"ada... | Creates a composite change adapter which handles the case when an index has multiple columns.
@param context the execution context; may not be null
@param matcher the node type matcher used to determine which nodes should be included in the index; may not be null
@param workspaceName the name of the workspace; may not be null
@param index the index that should be used; may not be null
@param adapters an {@link Iterable} of existing "discrete" adapters.
@return the new {@link IndexChangeAdapter}; never null | [
"Creates",
"a",
"composite",
"change",
"adapter",
"which",
"handles",
"the",
"case",
"when",
"an",
"index",
"has",
"multiple",
"columns",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/spi/index/provider/IndexChangeAdapters.java#L63-L69 | train |
ModeShape/modeshape | sequencers/modeshape-sequencer-audio/src/main/java/org/modeshape/sequencer/audio/AudioMetadata.java | AudioMetadata.checkSupportedAudio | private boolean checkSupportedAudio() {
AudioHeader header = audioFile.getAudioHeader();
bitrate = header.getBitRateAsNumber();
sampleRate = header.getSampleRateAsNumber();
channels = header.getChannels();
if (header.getChannels().toLowerCase().contains("stereo")) {
channels = "2";
}
if (header instanceof MP3AudioHeader) {
duration = ((MP3AudioHeader) header).getPreciseTrackLength();
} else if (header instanceof Mp4AudioHeader) {
duration = (double) ((Mp4AudioHeader) header).getPreciseLength();
} else {
duration = (double) header.getTrackLength();
}
// generic frames
Tag tag = audioFile.getTag();
artist = tag.getFirst(FieldKey.ARTIST);
album = tag.getFirst(FieldKey.ALBUM);
title = tag.getFirst(FieldKey.TITLE);
comment = tag.getFirst(FieldKey.COMMENT);
year = tag.getFirst(FieldKey.YEAR);
track = tag.getFirst(FieldKey.TRACK);
genre = tag.getFirst(FieldKey.GENRE);
artwork = new ArrayList<>();
for (Artwork a : tag.getArtworkList()) {
AudioMetadataArtwork ama = new AudioMetadataArtwork();
ama.setMimeType(a.getMimeType());
if (a.getPictureType() >= 0) {
ama.setType(a.getPictureType());
}
ama.setData(a.getBinaryData());
artwork.add(ama);
}
return true;
} | java | private boolean checkSupportedAudio() {
AudioHeader header = audioFile.getAudioHeader();
bitrate = header.getBitRateAsNumber();
sampleRate = header.getSampleRateAsNumber();
channels = header.getChannels();
if (header.getChannels().toLowerCase().contains("stereo")) {
channels = "2";
}
if (header instanceof MP3AudioHeader) {
duration = ((MP3AudioHeader) header).getPreciseTrackLength();
} else if (header instanceof Mp4AudioHeader) {
duration = (double) ((Mp4AudioHeader) header).getPreciseLength();
} else {
duration = (double) header.getTrackLength();
}
// generic frames
Tag tag = audioFile.getTag();
artist = tag.getFirst(FieldKey.ARTIST);
album = tag.getFirst(FieldKey.ALBUM);
title = tag.getFirst(FieldKey.TITLE);
comment = tag.getFirst(FieldKey.COMMENT);
year = tag.getFirst(FieldKey.YEAR);
track = tag.getFirst(FieldKey.TRACK);
genre = tag.getFirst(FieldKey.GENRE);
artwork = new ArrayList<>();
for (Artwork a : tag.getArtworkList()) {
AudioMetadataArtwork ama = new AudioMetadataArtwork();
ama.setMimeType(a.getMimeType());
if (a.getPictureType() >= 0) {
ama.setType(a.getPictureType());
}
ama.setData(a.getBinaryData());
artwork.add(ama);
}
return true;
} | [
"private",
"boolean",
"checkSupportedAudio",
"(",
")",
"{",
"AudioHeader",
"header",
"=",
"audioFile",
".",
"getAudioHeader",
"(",
")",
";",
"bitrate",
"=",
"header",
".",
"getBitRateAsNumber",
"(",
")",
";",
"sampleRate",
"=",
"header",
".",
"getSampleRateAsNum... | Parse tags common for all audio files. | [
"Parse",
"tags",
"common",
"for",
"all",
"audio",
"files",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-audio/src/main/java/org/modeshape/sequencer/audio/AudioMetadata.java#L175-L215 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/index/local/LocalUniqueIndex.java | LocalUniqueIndex.create | static <T> LocalUniqueIndex<T> create( String name,
String workspaceName,
DB db,
Converter<T> converter,
BTreeKeySerializer<T> valueSerializer,
Serializer<T> rawSerializer ) {
return new LocalUniqueIndex<>(name, workspaceName, db, converter, valueSerializer, rawSerializer);
} | java | static <T> LocalUniqueIndex<T> create( String name,
String workspaceName,
DB db,
Converter<T> converter,
BTreeKeySerializer<T> valueSerializer,
Serializer<T> rawSerializer ) {
return new LocalUniqueIndex<>(name, workspaceName, db, converter, valueSerializer, rawSerializer);
} | [
"static",
"<",
"T",
">",
"LocalUniqueIndex",
"<",
"T",
">",
"create",
"(",
"String",
"name",
",",
"String",
"workspaceName",
",",
"DB",
"db",
",",
"Converter",
"<",
"T",
">",
"converter",
",",
"BTreeKeySerializer",
"<",
"T",
">",
"valueSerializer",
",",
... | Create a new index that allows only a single value for each unique key.
@param name the name of the index; may not be null or empty
@param workspaceName the name of the workspace; may not be null
@param db the database in which the index information is to be stored; may not be null
@param converter the converter from {@link StaticOperand} to values being indexed; may not be null
@param valueSerializer the serializer for the type of value being indexed; may not be null
@param rawSerializer the raw value serializer for the type of value being indexed; may not be null
@return the new index; never null | [
"Create",
"a",
"new",
"index",
"that",
"allows",
"only",
"a",
"single",
"value",
"for",
"each",
"unique",
"key",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/index/local/LocalUniqueIndex.java#L48-L55 | train |
ModeShape/modeshape | index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/EsIndexColumn.java | EsIndexColumn.columnValue | protected Object columnValue(Object value) {
switch (type) {
case PATH:
case NAME:
case STRING:
case REFERENCE:
case SIMPLEREFERENCE:
case WEAKREFERENCE:
case URI:
return valueFactories.getStringFactory().create(value);
case DATE :
return ((DateTime) value).getMilliseconds();
default :
return value;
}
} | java | protected Object columnValue(Object value) {
switch (type) {
case PATH:
case NAME:
case STRING:
case REFERENCE:
case SIMPLEREFERENCE:
case WEAKREFERENCE:
case URI:
return valueFactories.getStringFactory().create(value);
case DATE :
return ((DateTime) value).getMilliseconds();
default :
return value;
}
} | [
"protected",
"Object",
"columnValue",
"(",
"Object",
"value",
")",
"{",
"switch",
"(",
"type",
")",
"{",
"case",
"PATH",
":",
"case",
"NAME",
":",
"case",
"STRING",
":",
"case",
"REFERENCE",
":",
"case",
"SIMPLEREFERENCE",
":",
"case",
"WEAKREFERENCE",
":"... | Converts representation of the given value using type conversation rules
between JCR type of this column and Elasticsearch core type of this column.
@param value value to be converted.
@return converted value. | [
"Converts",
"representation",
"of",
"the",
"given",
"value",
"using",
"type",
"conversation",
"rules",
"between",
"JCR",
"type",
"of",
"this",
"column",
"and",
"Elasticsearch",
"core",
"type",
"of",
"this",
"column",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/EsIndexColumn.java#L114-L129 | train |
ModeShape/modeshape | index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/EsIndexColumn.java | EsIndexColumn.cast | protected Object cast(Object value) {
switch (type) {
case STRING :
return valueFactories.getStringFactory().create(value);
case LONG :
return valueFactories.getLongFactory().create(value);
case NAME :
return valueFactories.getNameFactory().create(value);
case PATH :
return valueFactories.getPathFactory().create(value);
case DATE :
return valueFactories.getDateFactory().create(value);
case BOOLEAN :
return valueFactories.getBooleanFactory().create(value);
case URI :
return valueFactories.getUriFactory().create(value);
case REFERENCE :
return valueFactories.getReferenceFactory().create(value);
case SIMPLEREFERENCE :
return valueFactories.getSimpleReferenceFactory().create(value);
case WEAKREFERENCE :
return valueFactories.getWeakReferenceFactory().create(value);
default :
return value;
}
} | java | protected Object cast(Object value) {
switch (type) {
case STRING :
return valueFactories.getStringFactory().create(value);
case LONG :
return valueFactories.getLongFactory().create(value);
case NAME :
return valueFactories.getNameFactory().create(value);
case PATH :
return valueFactories.getPathFactory().create(value);
case DATE :
return valueFactories.getDateFactory().create(value);
case BOOLEAN :
return valueFactories.getBooleanFactory().create(value);
case URI :
return valueFactories.getUriFactory().create(value);
case REFERENCE :
return valueFactories.getReferenceFactory().create(value);
case SIMPLEREFERENCE :
return valueFactories.getSimpleReferenceFactory().create(value);
case WEAKREFERENCE :
return valueFactories.getWeakReferenceFactory().create(value);
default :
return value;
}
} | [
"protected",
"Object",
"cast",
"(",
"Object",
"value",
")",
"{",
"switch",
"(",
"type",
")",
"{",
"case",
"STRING",
":",
"return",
"valueFactories",
".",
"getStringFactory",
"(",
")",
".",
"create",
"(",
"value",
")",
";",
"case",
"LONG",
":",
"return",
... | Converts given value to the value of JCR type of this column.
@param value value to be converted.
@return converted value. | [
"Converts",
"given",
"value",
"to",
"the",
"value",
"of",
"JCR",
"type",
"of",
"this",
"column",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/EsIndexColumn.java#L154-L179 | train |
ModeShape/modeshape | index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/client/EsClient.java | EsClient.indexExists | public boolean indexExists(String name) throws IOException {
CloseableHttpClient client = HttpClients.createDefault();
HttpHead head = new HttpHead(String.format("http://%s:%d/%s", host, port, name));
try {
CloseableHttpResponse response = client.execute(head);
return response.getStatusLine().getStatusCode() == HttpStatus.SC_OK;
} finally {
head.releaseConnection();
}
} | java | public boolean indexExists(String name) throws IOException {
CloseableHttpClient client = HttpClients.createDefault();
HttpHead head = new HttpHead(String.format("http://%s:%d/%s", host, port, name));
try {
CloseableHttpResponse response = client.execute(head);
return response.getStatusLine().getStatusCode() == HttpStatus.SC_OK;
} finally {
head.releaseConnection();
}
} | [
"public",
"boolean",
"indexExists",
"(",
"String",
"name",
")",
"throws",
"IOException",
"{",
"CloseableHttpClient",
"client",
"=",
"HttpClients",
".",
"createDefault",
"(",
")",
";",
"HttpHead",
"head",
"=",
"new",
"HttpHead",
"(",
"String",
".",
"format",
"(... | Tests for the index existence with specified name.
@param name the name of the index to test.
@return true if index with given name exists and false otherwise.
@throws IOException communication exception. | [
"Tests",
"for",
"the",
"index",
"existence",
"with",
"specified",
"name",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/client/EsClient.java#L60-L69 | train |
ModeShape/modeshape | index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/client/EsClient.java | EsClient.createIndex | public boolean createIndex(String name, String type, EsRequest mappings) throws IOException {
if (indexExists(name)) {
return true;
}
CloseableHttpClient client = HttpClients.createDefault();
HttpPost method = new HttpPost(String.format("http://%s:%d/%s", host, port, name));
try {
StringEntity requestEntity = new StringEntity(mappings.toString(), ContentType.APPLICATION_JSON);
method.setEntity(requestEntity);
CloseableHttpResponse resp = client.execute(method);
return resp.getStatusLine().getStatusCode() == HttpStatus.SC_OK;
} finally {
method.releaseConnection();
}
} | java | public boolean createIndex(String name, String type, EsRequest mappings) throws IOException {
if (indexExists(name)) {
return true;
}
CloseableHttpClient client = HttpClients.createDefault();
HttpPost method = new HttpPost(String.format("http://%s:%d/%s", host, port, name));
try {
StringEntity requestEntity = new StringEntity(mappings.toString(), ContentType.APPLICATION_JSON);
method.setEntity(requestEntity);
CloseableHttpResponse resp = client.execute(method);
return resp.getStatusLine().getStatusCode() == HttpStatus.SC_OK;
} finally {
method.releaseConnection();
}
} | [
"public",
"boolean",
"createIndex",
"(",
"String",
"name",
",",
"String",
"type",
",",
"EsRequest",
"mappings",
")",
"throws",
"IOException",
"{",
"if",
"(",
"indexExists",
"(",
"name",
")",
")",
"{",
"return",
"true",
";",
"}",
"CloseableHttpClient",
"clien... | Creates new index.
@param name the name of the index to test.
@param type index type
@param mappings field mapping definition.
@return true if index was created.
@throws IOException communication exception. | [
"Creates",
"new",
"index",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/client/EsClient.java#L80-L95 | train |
ModeShape/modeshape | index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/client/EsClient.java | EsClient.deleteIndex | public boolean deleteIndex(String name) throws IOException {
CloseableHttpClient client = HttpClients.createDefault();
HttpDelete delete = new HttpDelete(String.format("http://%s:%d/%s", host, port, name));
try {
CloseableHttpResponse resp = client.execute(delete);
return resp.getStatusLine().getStatusCode() == HttpStatus.SC_OK;
} finally {
delete.releaseConnection();
}
} | java | public boolean deleteIndex(String name) throws IOException {
CloseableHttpClient client = HttpClients.createDefault();
HttpDelete delete = new HttpDelete(String.format("http://%s:%d/%s", host, port, name));
try {
CloseableHttpResponse resp = client.execute(delete);
return resp.getStatusLine().getStatusCode() == HttpStatus.SC_OK;
} finally {
delete.releaseConnection();
}
} | [
"public",
"boolean",
"deleteIndex",
"(",
"String",
"name",
")",
"throws",
"IOException",
"{",
"CloseableHttpClient",
"client",
"=",
"HttpClients",
".",
"createDefault",
"(",
")",
";",
"HttpDelete",
"delete",
"=",
"new",
"HttpDelete",
"(",
"String",
".",
"format"... | Deletes index.
@param name the name of the index to be deleted.
@return true if index was deleted.
@throws IOException | [
"Deletes",
"index",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/client/EsClient.java#L104-L113 | train |
ModeShape/modeshape | index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/client/EsClient.java | EsClient.storeDocument | public boolean storeDocument(String name, String type, String id,
EsRequest doc) throws IOException {
CloseableHttpClient client = HttpClients.createDefault();
HttpPost method = new HttpPost(String.format("http://%s:%d/%s/%s/%s", host, port, name, type, id));
try {
StringEntity requestEntity = new StringEntity(doc.toString(), ContentType.APPLICATION_JSON);
method.setEntity(requestEntity);
CloseableHttpResponse resp = client.execute(method);
int statusCode = resp.getStatusLine().getStatusCode();
return statusCode == HttpStatus.SC_CREATED || statusCode == HttpStatus.SC_OK;
} finally {
method.releaseConnection();
}
} | java | public boolean storeDocument(String name, String type, String id,
EsRequest doc) throws IOException {
CloseableHttpClient client = HttpClients.createDefault();
HttpPost method = new HttpPost(String.format("http://%s:%d/%s/%s/%s", host, port, name, type, id));
try {
StringEntity requestEntity = new StringEntity(doc.toString(), ContentType.APPLICATION_JSON);
method.setEntity(requestEntity);
CloseableHttpResponse resp = client.execute(method);
int statusCode = resp.getStatusLine().getStatusCode();
return statusCode == HttpStatus.SC_CREATED || statusCode == HttpStatus.SC_OK;
} finally {
method.releaseConnection();
}
} | [
"public",
"boolean",
"storeDocument",
"(",
"String",
"name",
",",
"String",
"type",
",",
"String",
"id",
",",
"EsRequest",
"doc",
")",
"throws",
"IOException",
"{",
"CloseableHttpClient",
"client",
"=",
"HttpClients",
".",
"createDefault",
"(",
")",
";",
"Http... | Indexes document.
@param name the name of the index.
@param type index type
@param id document id
@param doc document
@return true if document was indexed.
@throws IOException | [
"Indexes",
"document",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/client/EsClient.java#L125-L138 | train |
ModeShape/modeshape | index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/client/EsClient.java | EsClient.getDocument | public EsRequest getDocument(String name, String type, String id) throws IOException {
CloseableHttpClient client = HttpClients.createDefault();
HttpGet method = new HttpGet(String.format("http://%s:%d/%s/%s/%s", host, port, name, type, id));
try {
CloseableHttpResponse resp = client.execute(method);
int status = resp.getStatusLine().getStatusCode();
switch (status) {
case HttpStatus.SC_OK :
EsResponse doc = EsResponse.read(resp.getEntity().getContent());
return new EsRequest((Document) doc.get("_source"));
case HttpStatus.SC_NOT_ACCEPTABLE:
case HttpStatus.SC_NOT_FOUND:
return null;
default:
throw new IOException(resp.getStatusLine().getReasonPhrase());
}
} finally {
method.releaseConnection();
}
} | java | public EsRequest getDocument(String name, String type, String id) throws IOException {
CloseableHttpClient client = HttpClients.createDefault();
HttpGet method = new HttpGet(String.format("http://%s:%d/%s/%s/%s", host, port, name, type, id));
try {
CloseableHttpResponse resp = client.execute(method);
int status = resp.getStatusLine().getStatusCode();
switch (status) {
case HttpStatus.SC_OK :
EsResponse doc = EsResponse.read(resp.getEntity().getContent());
return new EsRequest((Document) doc.get("_source"));
case HttpStatus.SC_NOT_ACCEPTABLE:
case HttpStatus.SC_NOT_FOUND:
return null;
default:
throw new IOException(resp.getStatusLine().getReasonPhrase());
}
} finally {
method.releaseConnection();
}
} | [
"public",
"EsRequest",
"getDocument",
"(",
"String",
"name",
",",
"String",
"type",
",",
"String",
"id",
")",
"throws",
"IOException",
"{",
"CloseableHttpClient",
"client",
"=",
"HttpClients",
".",
"createDefault",
"(",
")",
";",
"HttpGet",
"method",
"=",
"new... | Searches indexed document.
@param name index name.
@param type index type.
@param id document identifier.
@return document if it was found or null.
@throws IOException | [
"Searches",
"indexed",
"document",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/client/EsClient.java#L149-L168 | train |
ModeShape/modeshape | index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/client/EsClient.java | EsClient.deleteDocument | public boolean deleteDocument(String name, String type, String id) throws IOException {
CloseableHttpClient client = HttpClients.createDefault();
HttpDelete delete = new HttpDelete(String.format("http://%s:%d/%s/%s/%s", host, port, name, type, id));
try {
return client.execute(delete).getStatusLine().getStatusCode() == HttpStatus.SC_OK;
} finally {
delete.releaseConnection();
}
} | java | public boolean deleteDocument(String name, String type, String id) throws IOException {
CloseableHttpClient client = HttpClients.createDefault();
HttpDelete delete = new HttpDelete(String.format("http://%s:%d/%s/%s/%s", host, port, name, type, id));
try {
return client.execute(delete).getStatusLine().getStatusCode() == HttpStatus.SC_OK;
} finally {
delete.releaseConnection();
}
} | [
"public",
"boolean",
"deleteDocument",
"(",
"String",
"name",
",",
"String",
"type",
",",
"String",
"id",
")",
"throws",
"IOException",
"{",
"CloseableHttpClient",
"client",
"=",
"HttpClients",
".",
"createDefault",
"(",
")",
";",
"HttpDelete",
"delete",
"=",
... | Deletes document.
@param name index name.
@param type index type.
@param id document id
@return true if it was deleted.
@throws IOException | [
"Deletes",
"document",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/client/EsClient.java#L179-L187 | train |
ModeShape/modeshape | index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/client/EsClient.java | EsClient.deleteAll | public void deleteAll(String name, String type) throws IOException {
CloseableHttpClient client = HttpClients.createDefault();
HttpPost method = new HttpPost(String.format("http://%s:%d/%s/%s", host, port, name, type));
try {
EsRequest query = new EsRequest();
query.put("query", new MatchAllQuery().build());
StringEntity requestEntity = new StringEntity(query.toString(), ContentType.APPLICATION_JSON);
method.setEntity(requestEntity);
method.setHeader(" X-HTTP-Method-Override", "DELETE");
CloseableHttpResponse resp = client.execute(method);
int status = resp.getStatusLine().getStatusCode();
if (status != HttpStatus.SC_OK) {
throw new IOException(resp.getStatusLine().getReasonPhrase());
}
} finally {
method.releaseConnection();
}
} | java | public void deleteAll(String name, String type) throws IOException {
CloseableHttpClient client = HttpClients.createDefault();
HttpPost method = new HttpPost(String.format("http://%s:%d/%s/%s", host, port, name, type));
try {
EsRequest query = new EsRequest();
query.put("query", new MatchAllQuery().build());
StringEntity requestEntity = new StringEntity(query.toString(), ContentType.APPLICATION_JSON);
method.setEntity(requestEntity);
method.setHeader(" X-HTTP-Method-Override", "DELETE");
CloseableHttpResponse resp = client.execute(method);
int status = resp.getStatusLine().getStatusCode();
if (status != HttpStatus.SC_OK) {
throw new IOException(resp.getStatusLine().getReasonPhrase());
}
} finally {
method.releaseConnection();
}
} | [
"public",
"void",
"deleteAll",
"(",
"String",
"name",
",",
"String",
"type",
")",
"throws",
"IOException",
"{",
"CloseableHttpClient",
"client",
"=",
"HttpClients",
".",
"createDefault",
"(",
")",
";",
"HttpPost",
"method",
"=",
"new",
"HttpPost",
"(",
"String... | Deletes all documents.
@param name index name
@param type index type.
@throws IOException | [
"Deletes",
"all",
"documents",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/client/EsClient.java#L196-L213 | train |
ModeShape/modeshape | index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/client/EsClient.java | EsClient.flush | public void flush(String name) throws IOException {
CloseableHttpClient client = HttpClients.createDefault();
HttpPost method = new HttpPost(String.format("http://%s:%d/%s/_flush", host, port, name));
try {
CloseableHttpResponse resp = client.execute(method);
int status = resp.getStatusLine().getStatusCode();
if (status != HttpStatus.SC_OK) {
throw new IOException(resp.getStatusLine().getReasonPhrase());
}
} finally {
method.releaseConnection();
}
} | java | public void flush(String name) throws IOException {
CloseableHttpClient client = HttpClients.createDefault();
HttpPost method = new HttpPost(String.format("http://%s:%d/%s/_flush", host, port, name));
try {
CloseableHttpResponse resp = client.execute(method);
int status = resp.getStatusLine().getStatusCode();
if (status != HttpStatus.SC_OK) {
throw new IOException(resp.getStatusLine().getReasonPhrase());
}
} finally {
method.releaseConnection();
}
} | [
"public",
"void",
"flush",
"(",
"String",
"name",
")",
"throws",
"IOException",
"{",
"CloseableHttpClient",
"client",
"=",
"HttpClients",
".",
"createDefault",
"(",
")",
";",
"HttpPost",
"method",
"=",
"new",
"HttpPost",
"(",
"String",
".",
"format",
"(",
"\... | Flushes index data.
@param name index name.
@throws IOException | [
"Flushes",
"index",
"data",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/client/EsClient.java#L221-L233 | train |
ModeShape/modeshape | index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/client/EsClient.java | EsClient.search | public EsResponse search(String name, String type, EsRequest query) throws IOException {
CloseableHttpClient client = HttpClients.createDefault();
HttpPost method = new HttpPost(String.format("http://%s:%d/%s/%s/_search", host, port, name, type));
try {
StringEntity requestEntity = new StringEntity(query.toString(), ContentType.APPLICATION_JSON);
method.setEntity(requestEntity);
CloseableHttpResponse resp = client.execute(method);
int status = resp.getStatusLine().getStatusCode();
if (status != HttpStatus.SC_OK) {
throw new IOException(resp.getStatusLine().getReasonPhrase());
}
return EsResponse.read(resp.getEntity().getContent());
} finally {
method.releaseConnection();
}
} | java | public EsResponse search(String name, String type, EsRequest query) throws IOException {
CloseableHttpClient client = HttpClients.createDefault();
HttpPost method = new HttpPost(String.format("http://%s:%d/%s/%s/_search", host, port, name, type));
try {
StringEntity requestEntity = new StringEntity(query.toString(), ContentType.APPLICATION_JSON);
method.setEntity(requestEntity);
CloseableHttpResponse resp = client.execute(method);
int status = resp.getStatusLine().getStatusCode();
if (status != HttpStatus.SC_OK) {
throw new IOException(resp.getStatusLine().getReasonPhrase());
}
return EsResponse.read(resp.getEntity().getContent());
} finally {
method.releaseConnection();
}
} | [
"public",
"EsResponse",
"search",
"(",
"String",
"name",
",",
"String",
"type",
",",
"EsRequest",
"query",
")",
"throws",
"IOException",
"{",
"CloseableHttpClient",
"client",
"=",
"HttpClients",
".",
"createDefault",
"(",
")",
";",
"HttpPost",
"method",
"=",
"... | Executes query.
@param name index name.
@param type index type.
@param query query to be executed
@return search results in json format.
@throws IOException | [
"Executes",
"query",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/index-providers/modeshape-elasticsearch-index-provider/src/main/java/org/modeshape/jcr/index/elasticsearch/client/EsClient.java#L264-L280 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/value/basic/AbstractPath.java | AbstractPath.doGetString | protected String doGetString( NamespaceRegistry namespaceRegistry,
TextEncoder encoder,
TextEncoder delimiterEncoder ) {
if (encoder == null) encoder = DEFAULT_ENCODER;
final String delimiter = delimiterEncoder != null ? delimiterEncoder.encode(DELIMITER_STR) : DELIMITER_STR;
// Since the segments are immutable, this code need not be synchronized because concurrent threads
// may just compute the same value (with no harm done)
StringBuilder sb = new StringBuilder();
if (this.isAbsolute()) sb.append(delimiter);
boolean first = true;
for (Segment segment : this) {
if (first) {
first = false;
} else {
sb.append(delimiter);
}
assert segment != null;
sb.append(segment.getString(namespaceRegistry, encoder, delimiterEncoder));
}
String result = sb.toString();
// Save the result to the internal string if this the default encoder is used.
// This is not synchronized, but it's okay
return result;
} | java | protected String doGetString( NamespaceRegistry namespaceRegistry,
TextEncoder encoder,
TextEncoder delimiterEncoder ) {
if (encoder == null) encoder = DEFAULT_ENCODER;
final String delimiter = delimiterEncoder != null ? delimiterEncoder.encode(DELIMITER_STR) : DELIMITER_STR;
// Since the segments are immutable, this code need not be synchronized because concurrent threads
// may just compute the same value (with no harm done)
StringBuilder sb = new StringBuilder();
if (this.isAbsolute()) sb.append(delimiter);
boolean first = true;
for (Segment segment : this) {
if (first) {
first = false;
} else {
sb.append(delimiter);
}
assert segment != null;
sb.append(segment.getString(namespaceRegistry, encoder, delimiterEncoder));
}
String result = sb.toString();
// Save the result to the internal string if this the default encoder is used.
// This is not synchronized, but it's okay
return result;
} | [
"protected",
"String",
"doGetString",
"(",
"NamespaceRegistry",
"namespaceRegistry",
",",
"TextEncoder",
"encoder",
",",
"TextEncoder",
"delimiterEncoder",
")",
"{",
"if",
"(",
"encoder",
"==",
"null",
")",
"encoder",
"=",
"DEFAULT_ENCODER",
";",
"final",
"String",
... | Method that creates the string representation. This method works two different ways depending upon whether the namespace
registry is provided.
@param namespaceRegistry
@param encoder
@param delimiterEncoder
@return this path as a string | [
"Method",
"that",
"creates",
"the",
"string",
"representation",
".",
"This",
"method",
"works",
"two",
"different",
"ways",
"depending",
"upon",
"whether",
"the",
"namespace",
"registry",
"is",
"provided",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/value/basic/AbstractPath.java#L227-L251 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/JcrLockManager.java | JcrLockManager.lock | public Lock lock( AbstractJcrNode node,
boolean isDeep,
boolean isSessionScoped,
long timeoutHint,
String ownerInfo )
throws LockException, AccessDeniedException, InvalidItemStateException, RepositoryException {
if (!node.isLockable()) {
throw new LockException(JcrI18n.nodeNotLockable.text(node.location()));
}
if (node.isLocked()) {
throw new LockException(JcrI18n.alreadyLocked.text(node.location()));
}
if (node.isNew()|| node.isModified()) {
throw new InvalidItemStateException(JcrI18n.changedNodeCannotBeLocked.text(node.location()));
}
// Try to obtain the lock ...
ModeShapeLock lock = lockManager.lock(session, node.node(), isDeep, isSessionScoped, timeoutHint, ownerInfo);
String token = lock.getLockToken();
lockTokens.add(token);
return lock.lockFor(session);
} | java | public Lock lock( AbstractJcrNode node,
boolean isDeep,
boolean isSessionScoped,
long timeoutHint,
String ownerInfo )
throws LockException, AccessDeniedException, InvalidItemStateException, RepositoryException {
if (!node.isLockable()) {
throw new LockException(JcrI18n.nodeNotLockable.text(node.location()));
}
if (node.isLocked()) {
throw new LockException(JcrI18n.alreadyLocked.text(node.location()));
}
if (node.isNew()|| node.isModified()) {
throw new InvalidItemStateException(JcrI18n.changedNodeCannotBeLocked.text(node.location()));
}
// Try to obtain the lock ...
ModeShapeLock lock = lockManager.lock(session, node.node(), isDeep, isSessionScoped, timeoutHint, ownerInfo);
String token = lock.getLockToken();
lockTokens.add(token);
return lock.lockFor(session);
} | [
"public",
"Lock",
"lock",
"(",
"AbstractJcrNode",
"node",
",",
"boolean",
"isDeep",
",",
"boolean",
"isSessionScoped",
",",
"long",
"timeoutHint",
",",
"String",
"ownerInfo",
")",
"throws",
"LockException",
",",
"AccessDeniedException",
",",
"InvalidItemStateException... | Attempt to obtain a lock on the supplied node.
@param node the node; may not be null
@param isDeep true if the lock should be a deep lock
@param isSessionScoped true if the lock should be scoped to the session
@param timeoutHint desired lock timeout in seconds (servers are free to ignore this value); specify {@link Long#MAX_VALUE}
for no timeout.
@param ownerInfo a string containing owner information supplied by the client, and recorded on the lock; if null, then the
session's user ID will be used
@return the lock; never null
@throws AccessDeniedException if the caller does not have privilege to lock the node
@throws InvalidItemStateException if the node has been modified and cannot be locked
@throws LockException if the lock could not be obtained
@throws RepositoryException if an error occurs updating the graph state | [
"Attempt",
"to",
"obtain",
"a",
"lock",
"on",
"the",
"supplied",
"node",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/JcrLockManager.java#L256-L277 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/xpath/XPathParser.java | XPathParser.removeQuotes | protected String removeQuotes( String text ) {
assert text != null;
if (text.length() > 2) {
char first = text.charAt(0);
// Need to remove these only if they are paired ...
if (first == '"' || first == '\'') {
int indexOfLast = text.length() - 1;
char last = text.charAt(indexOfLast);
if (last == first) {
text = text.substring(1, indexOfLast);
}
}
}
return text;
} | java | protected String removeQuotes( String text ) {
assert text != null;
if (text.length() > 2) {
char first = text.charAt(0);
// Need to remove these only if they are paired ...
if (first == '"' || first == '\'') {
int indexOfLast = text.length() - 1;
char last = text.charAt(indexOfLast);
if (last == first) {
text = text.substring(1, indexOfLast);
}
}
}
return text;
} | [
"protected",
"String",
"removeQuotes",
"(",
"String",
"text",
")",
"{",
"assert",
"text",
"!=",
"null",
";",
"if",
"(",
"text",
".",
"length",
"(",
")",
">",
"2",
")",
"{",
"char",
"first",
"=",
"text",
".",
"charAt",
"(",
"0",
")",
";",
"// Need t... | Remove any leading and trailing single-quotes or double-quotes from the supplied text.
@param text the input text; may not be null
@return the text without leading and trailing quotes, or <code>text</code> if there were no square brackets or quotes | [
"Remove",
"any",
"leading",
"and",
"trailing",
"single",
"-",
"quotes",
"or",
"double",
"-",
"quotes",
"from",
"the",
"supplied",
"text",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/xpath/XPathParser.java#L747-L761 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/BackupDocumentWriter.java | BackupDocumentWriter.write | public void write( Document document ) {
assert document != null;
++count;
++totalCount;
if (count > maxDocumentsPerFile) {
// Close the stream (we'll open a new one later in the method) ...
close();
count = 1;
}
try {
if (stream == null) {
// Open the stream to the next file ...
++fileCount;
String suffix = StringUtil.justifyRight(Long.toString(fileCount), BackupService.NUM_CHARS_IN_FILENAME_SUFFIX, '0');
String filename = filenamePrefix + "_" + suffix + DOCUMENTS_EXTENSION;
if (compress) filename = filename + GZIP_EXTENSION;
currentFile = new File(parentDirectory, filename);
OutputStream fileStream = new FileOutputStream(currentFile);
if (compress) fileStream = new GZIPOutputStream(fileStream);
stream = new BufferedOutputStream(fileStream);
}
Json.write(document, stream);
// Need to append a non-consumable character so that we can read multiple JSON documents per file
stream.write((byte)'\n');
} catch (IOException e) {
problems.addError(JcrI18n.problemsWritingDocumentToBackup, currentFile.getAbsolutePath(), e.getMessage());
}
} | java | public void write( Document document ) {
assert document != null;
++count;
++totalCount;
if (count > maxDocumentsPerFile) {
// Close the stream (we'll open a new one later in the method) ...
close();
count = 1;
}
try {
if (stream == null) {
// Open the stream to the next file ...
++fileCount;
String suffix = StringUtil.justifyRight(Long.toString(fileCount), BackupService.NUM_CHARS_IN_FILENAME_SUFFIX, '0');
String filename = filenamePrefix + "_" + suffix + DOCUMENTS_EXTENSION;
if (compress) filename = filename + GZIP_EXTENSION;
currentFile = new File(parentDirectory, filename);
OutputStream fileStream = new FileOutputStream(currentFile);
if (compress) fileStream = new GZIPOutputStream(fileStream);
stream = new BufferedOutputStream(fileStream);
}
Json.write(document, stream);
// Need to append a non-consumable character so that we can read multiple JSON documents per file
stream.write((byte)'\n');
} catch (IOException e) {
problems.addError(JcrI18n.problemsWritingDocumentToBackup, currentFile.getAbsolutePath(), e.getMessage());
}
} | [
"public",
"void",
"write",
"(",
"Document",
"document",
")",
"{",
"assert",
"document",
"!=",
"null",
";",
"++",
"count",
";",
"++",
"totalCount",
";",
"if",
"(",
"count",
">",
"maxDocumentsPerFile",
")",
"{",
"// Close the stream (we'll open a new one later in th... | Append the supplied document to the files.
@param document the document to be written; may not be null | [
"Append",
"the",
"supplied",
"document",
"to",
"the",
"files",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/BackupDocumentWriter.java#L71-L98 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/model/Query.java | Query.constrainedBy | public Query constrainedBy( Constraint constraint ) {
return new Query(source, constraint, orderings(), columns, getLimits(), distinct);
} | java | public Query constrainedBy( Constraint constraint ) {
return new Query(source, constraint, orderings(), columns, getLimits(), distinct);
} | [
"public",
"Query",
"constrainedBy",
"(",
"Constraint",
"constraint",
")",
"{",
"return",
"new",
"Query",
"(",
"source",
",",
"constraint",
",",
"orderings",
"(",
")",
",",
"columns",
",",
"getLimits",
"(",
")",
",",
"distinct",
")",
";",
"}"
] | Create a copy of this query, but one that uses the supplied constraint.
@param constraint the constraint that should be used; never null
@return the copy of the query that uses the supplied constraint; never null | [
"Create",
"a",
"copy",
"of",
"this",
"query",
"but",
"one",
"that",
"uses",
"the",
"supplied",
"constraint",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/model/Query.java#L177-L179 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/model/Query.java | Query.orderedBy | public Query orderedBy( List<Ordering> orderings ) {
return new Query(source, constraint, orderings, columns, getLimits(), distinct);
} | java | public Query orderedBy( List<Ordering> orderings ) {
return new Query(source, constraint, orderings, columns, getLimits(), distinct);
} | [
"public",
"Query",
"orderedBy",
"(",
"List",
"<",
"Ordering",
">",
"orderings",
")",
"{",
"return",
"new",
"Query",
"(",
"source",
",",
"constraint",
",",
"orderings",
",",
"columns",
",",
"getLimits",
"(",
")",
",",
"distinct",
")",
";",
"}"
] | Create a copy of this query, but one whose results should be ordered by the supplied orderings.
@param orderings the result ordering specification that should be used; never null
@return the copy of the query that uses the supplied ordering; never null | [
"Create",
"a",
"copy",
"of",
"this",
"query",
"but",
"one",
"whose",
"results",
"should",
"be",
"ordered",
"by",
"the",
"supplied",
"orderings",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/model/Query.java#L187-L189 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/model/Query.java | Query.returning | public Query returning( List<Column> columns ) {
return new Query(source, constraint, orderings(), columns, getLimits(), distinct);
} | java | public Query returning( List<Column> columns ) {
return new Query(source, constraint, orderings(), columns, getLimits(), distinct);
} | [
"public",
"Query",
"returning",
"(",
"List",
"<",
"Column",
">",
"columns",
")",
"{",
"return",
"new",
"Query",
"(",
"source",
",",
"constraint",
",",
"orderings",
"(",
")",
",",
"columns",
",",
"getLimits",
"(",
")",
",",
"distinct",
")",
";",
"}"
] | Create a copy of this query, but that returns results with the supplied columns.
@param columns the columns of the results; may not be null
@return the copy of the query returning the supplied result columns; never null | [
"Create",
"a",
"copy",
"of",
"this",
"query",
"but",
"that",
"returns",
"results",
"with",
"the",
"supplied",
"columns",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/model/Query.java#L209-L211 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/model/Query.java | Query.adding | public Query adding( Column... columns ) {
List<Column> newColumns = null;
if (this.columns != null) {
newColumns = new ArrayList<Column>(this.columns);
for (Column column : columns) {
newColumns.add(column);
}
} else {
newColumns = Arrays.asList(columns);
}
return new Query(source, constraint, orderings(), newColumns, getLimits(), distinct);
} | java | public Query adding( Column... columns ) {
List<Column> newColumns = null;
if (this.columns != null) {
newColumns = new ArrayList<Column>(this.columns);
for (Column column : columns) {
newColumns.add(column);
}
} else {
newColumns = Arrays.asList(columns);
}
return new Query(source, constraint, orderings(), newColumns, getLimits(), distinct);
} | [
"public",
"Query",
"adding",
"(",
"Column",
"...",
"columns",
")",
"{",
"List",
"<",
"Column",
">",
"newColumns",
"=",
"null",
";",
"if",
"(",
"this",
".",
"columns",
"!=",
"null",
")",
"{",
"newColumns",
"=",
"new",
"ArrayList",
"<",
"Column",
">",
... | Create a copy of this query, but that returns results that include the columns specified by this query as well as the
supplied columns.
@param columns the additional columns that should be included in the the results; may not be null
@return the copy of the query returning the supplied result columns; never null | [
"Create",
"a",
"copy",
"of",
"this",
"query",
"but",
"that",
"returns",
"results",
"that",
"include",
"the",
"columns",
"specified",
"by",
"this",
"query",
"as",
"well",
"as",
"the",
"supplied",
"columns",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/model/Query.java#L240-L251 | train |
ModeShape/modeshape | web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/Console.java | Console.getCredentials | private void getCredentials() {
jcrService.getUserName(new BaseCallback<String>() {
@Override
public void onSuccess(String name) {
showMainForm(name);
}
});
} | java | private void getCredentials() {
jcrService.getUserName(new BaseCallback<String>() {
@Override
public void onSuccess(String name) {
showMainForm(name);
}
});
} | [
"private",
"void",
"getCredentials",
"(",
")",
"{",
"jcrService",
".",
"getUserName",
"(",
"new",
"BaseCallback",
"<",
"String",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onSuccess",
"(",
"String",
"name",
")",
"{",
"showMainForm",
"(",
"name... | Checks user's credentials. | [
"Checks",
"user",
"s",
"credentials",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/Console.java#L94-L101 | train |
ModeShape/modeshape | web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/Console.java | Console.loadNodeSpecifiedByURL | public void loadNodeSpecifiedByURL() {
repositoriesList.select(jcrURL.getRepository(), jcrURL.getWorkspace(), jcrURL.getPath(), true);
} | java | public void loadNodeSpecifiedByURL() {
repositoriesList.select(jcrURL.getRepository(), jcrURL.getWorkspace(), jcrURL.getPath(), true);
} | [
"public",
"void",
"loadNodeSpecifiedByURL",
"(",
")",
"{",
"repositoriesList",
".",
"select",
"(",
"jcrURL",
".",
"getRepository",
"(",
")",
",",
"jcrURL",
".",
"getWorkspace",
"(",
")",
",",
"jcrURL",
".",
"getPath",
"(",
")",
",",
"true",
")",
";",
"}"... | Reconstructs URL and points browser to the requested node path. | [
"Reconstructs",
"URL",
"and",
"points",
"browser",
"to",
"the",
"requested",
"node",
"path",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/Console.java#L106-L108 | train |
ModeShape/modeshape | web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/Console.java | Console.showMainForm | public void showMainForm(String userName) {
align();
changeUserName(userName);
mainForm.addMember(header);
mainForm.addMember(repositoryHeader);
mainForm.addMember(viewPort);
mainForm.addMember(strut(30));
mainForm.addMember(footer);
setLayoutWidth(LAYOUT_WIDTH);
loadData();
//init HTML history
htmlHistory.addValueChangeHandler(this);
mainForm.draw();
} | java | public void showMainForm(String userName) {
align();
changeUserName(userName);
mainForm.addMember(header);
mainForm.addMember(repositoryHeader);
mainForm.addMember(viewPort);
mainForm.addMember(strut(30));
mainForm.addMember(footer);
setLayoutWidth(LAYOUT_WIDTH);
loadData();
//init HTML history
htmlHistory.addValueChangeHandler(this);
mainForm.draw();
} | [
"public",
"void",
"showMainForm",
"(",
"String",
"userName",
")",
"{",
"align",
"(",
")",
";",
"changeUserName",
"(",
"userName",
")",
";",
"mainForm",
".",
"addMember",
"(",
"header",
")",
";",
"mainForm",
".",
"addMember",
"(",
"repositoryHeader",
")",
"... | Shows main page for the logged in user.
@param userName the name of the user. | [
"Shows",
"main",
"page",
"for",
"the",
"logged",
"in",
"user",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/Console.java#L133-L149 | train |
ModeShape/modeshape | web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/Console.java | Console.changeRepositoryInURL | public void changeRepositoryInURL(String name, boolean changeHistory) {
jcrURL.setRepository(name);
if (changeHistory) {
htmlHistory.newItem(jcrURL.toString(), false);
}
} | java | public void changeRepositoryInURL(String name, boolean changeHistory) {
jcrURL.setRepository(name);
if (changeHistory) {
htmlHistory.newItem(jcrURL.toString(), false);
}
} | [
"public",
"void",
"changeRepositoryInURL",
"(",
"String",
"name",
",",
"boolean",
"changeHistory",
")",
"{",
"jcrURL",
".",
"setRepository",
"(",
"name",
")",
";",
"if",
"(",
"changeHistory",
")",
"{",
"htmlHistory",
".",
"newItem",
"(",
"jcrURL",
".",
"toSt... | Changes repository name in URL displayed by browser.
@param name the name of the repository.
@param changeHistory if true store URL changes in history. | [
"Changes",
"repository",
"name",
"in",
"URL",
"displayed",
"by",
"browser",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/Console.java#L250-L255 | train |
ModeShape/modeshape | web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/Console.java | Console.changeWorkspaceInURL | public void changeWorkspaceInURL(String name, boolean changeHistory) {
jcrURL.setWorkspace(name);
if (changeHistory) {
htmlHistory.newItem(jcrURL.toString(), false);
}
} | java | public void changeWorkspaceInURL(String name, boolean changeHistory) {
jcrURL.setWorkspace(name);
if (changeHistory) {
htmlHistory.newItem(jcrURL.toString(), false);
}
} | [
"public",
"void",
"changeWorkspaceInURL",
"(",
"String",
"name",
",",
"boolean",
"changeHistory",
")",
"{",
"jcrURL",
".",
"setWorkspace",
"(",
"name",
")",
";",
"if",
"(",
"changeHistory",
")",
"{",
"htmlHistory",
".",
"newItem",
"(",
"jcrURL",
".",
"toStri... | Changes workspace in the URL displayed by browser.
@param name the name of the repository.
@param changeHistory if true store URL changes in browser's history. | [
"Changes",
"workspace",
"in",
"the",
"URL",
"displayed",
"by",
"browser",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/Console.java#L263-L268 | train |
ModeShape/modeshape | web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/Console.java | Console.changePathInURL | public void changePathInURL(String path, boolean changeHistory) {
jcrURL.setPath(path);
if (changeHistory) {
htmlHistory.newItem(jcrURL.toString(), false);
}
} | java | public void changePathInURL(String path, boolean changeHistory) {
jcrURL.setPath(path);
if (changeHistory) {
htmlHistory.newItem(jcrURL.toString(), false);
}
} | [
"public",
"void",
"changePathInURL",
"(",
"String",
"path",
",",
"boolean",
"changeHistory",
")",
"{",
"jcrURL",
".",
"setPath",
"(",
"path",
")",
";",
"if",
"(",
"changeHistory",
")",
"{",
"htmlHistory",
".",
"newItem",
"(",
"jcrURL",
".",
"toString",
"("... | Changes node path in the URL displayed by browser.
@param path the path to the node.
@param changeHistory if true store URL changes in browser's history. | [
"Changes",
"node",
"path",
"in",
"the",
"URL",
"displayed",
"by",
"browser",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/Console.java#L276-L281 | train |
ModeShape/modeshape | web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/Console.java | Console.showRepositories | public void showRepositories(Collection<RepositoryName> names) {
repositoriesList.show(names);
display(repositoriesList);
this.hideRepository();
} | java | public void showRepositories(Collection<RepositoryName> names) {
repositoriesList.show(names);
display(repositoriesList);
this.hideRepository();
} | [
"public",
"void",
"showRepositories",
"(",
"Collection",
"<",
"RepositoryName",
">",
"names",
")",
"{",
"repositoriesList",
".",
"show",
"(",
"names",
")",
";",
"display",
"(",
"repositoriesList",
")",
";",
"this",
".",
"hideRepository",
"(",
")",
";",
"}"
] | Displays list of availables repositories.
@param names names of repositories. | [
"Displays",
"list",
"of",
"availables",
"repositories",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/Console.java#L294-L298 | train |
ModeShape/modeshape | web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/Console.java | Console.displayContent | public void displayContent(String repository, String workspace, String path,
boolean changeHistory) {
contents.show(repository, workspace, path, changeHistory);
displayRepository(repository);
display(contents);
changeRepositoryInURL(repository, changeHistory);
} | java | public void displayContent(String repository, String workspace, String path,
boolean changeHistory) {
contents.show(repository, workspace, path, changeHistory);
displayRepository(repository);
display(contents);
changeRepositoryInURL(repository, changeHistory);
} | [
"public",
"void",
"displayContent",
"(",
"String",
"repository",
",",
"String",
"workspace",
",",
"String",
"path",
",",
"boolean",
"changeHistory",
")",
"{",
"contents",
".",
"show",
"(",
"repository",
",",
"workspace",
",",
"path",
",",
"changeHistory",
")",... | Displays node for the given repository, workspace and path.
@param repository the name of the repository.
@param workspace the name of workspace.
@param path the path to the node.
@param changeHistory store changes in browser history. | [
"Displays",
"node",
"for",
"the",
"given",
"repository",
"workspace",
"and",
"path",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/Console.java#L308-L314 | train |
ModeShape/modeshape | modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/JcrTools.java | JcrTools.removeAllChildren | public int removeAllChildren( Node node ) throws RepositoryException {
isNotNull(node, "node");
int childrenRemoved = 0;
NodeIterator iter = node.getNodes();
while (iter.hasNext()) {
Node child = iter.nextNode();
child.remove();
++childrenRemoved;
}
return childrenRemoved;
} | java | public int removeAllChildren( Node node ) throws RepositoryException {
isNotNull(node, "node");
int childrenRemoved = 0;
NodeIterator iter = node.getNodes();
while (iter.hasNext()) {
Node child = iter.nextNode();
child.remove();
++childrenRemoved;
}
return childrenRemoved;
} | [
"public",
"int",
"removeAllChildren",
"(",
"Node",
"node",
")",
"throws",
"RepositoryException",
"{",
"isNotNull",
"(",
"node",
",",
"\"node\"",
")",
";",
"int",
"childrenRemoved",
"=",
"0",
";",
"NodeIterator",
"iter",
"=",
"node",
".",
"getNodes",
"(",
")"... | Remove all children from the specified node
@param node
@return the number of children removed.
@throws RepositoryException
@throws IllegalArgumentException if the node argument is null | [
"Remove",
"all",
"children",
"from",
"the",
"specified",
"node"
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/JcrTools.java#L77-L87 | train |
ModeShape/modeshape | modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/JcrTools.java | JcrTools.getNode | public Node getNode( Node node,
String relativePath,
boolean required ) throws RepositoryException {
isNotNull(node, "node");
isNotNull(relativePath, "relativePath");
Node result = null;
try {
result = node.getNode(relativePath);
} catch (PathNotFoundException e) {
if (required) {
throw e;
}
}
return result;
} | java | public Node getNode( Node node,
String relativePath,
boolean required ) throws RepositoryException {
isNotNull(node, "node");
isNotNull(relativePath, "relativePath");
Node result = null;
try {
result = node.getNode(relativePath);
} catch (PathNotFoundException e) {
if (required) {
throw e;
}
}
return result;
} | [
"public",
"Node",
"getNode",
"(",
"Node",
"node",
",",
"String",
"relativePath",
",",
"boolean",
"required",
")",
"throws",
"RepositoryException",
"{",
"isNotNull",
"(",
"node",
",",
"\"node\"",
")",
";",
"isNotNull",
"(",
"relativePath",
",",
"\"relativePath\""... | Get the node under a specified node at a location defined by the specified relative path. If node is required, then a
problem is created and added to the Problems list.
@param node a parent node from which to obtain a node relative to. may not be null
@param relativePath the path of the desired node. may not be null
@param required true if node is required to exist under the given node.
@return the node located relative the the input node
@throws RepositoryException
@throws IllegalArgumentException if the node, relativePath or problems argument is null | [
"Get",
"the",
"node",
"under",
"a",
"specified",
"node",
"at",
"a",
"location",
"defined",
"by",
"the",
"specified",
"relative",
"path",
".",
"If",
"node",
"is",
"required",
"then",
"a",
"problem",
"is",
"created",
"and",
"added",
"to",
"the",
"Problems",
... | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/JcrTools.java#L111-L126 | train |
ModeShape/modeshape | modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/JcrTools.java | JcrTools.getReadable | public String getReadable( Node node ) {
if (node == null) return "";
try {
return node.getPath();
} catch (RepositoryException err) {
return node.toString();
}
} | java | public String getReadable( Node node ) {
if (node == null) return "";
try {
return node.getPath();
} catch (RepositoryException err) {
return node.toString();
}
} | [
"public",
"String",
"getReadable",
"(",
"Node",
"node",
")",
"{",
"if",
"(",
"node",
"==",
"null",
")",
"return",
"\"\"",
";",
"try",
"{",
"return",
"node",
".",
"getPath",
"(",
")",
";",
"}",
"catch",
"(",
"RepositoryException",
"err",
")",
"{",
"re... | Get the readable string form for a specified node.
@param node the node to obtain the readable string form. may be null
@return the readable string form for a specified node. | [
"Get",
"the",
"readable",
"string",
"form",
"for",
"a",
"specified",
"node",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/JcrTools.java#L134-L141 | train |
ModeShape/modeshape | modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/JcrTools.java | JcrTools.findOrCreateNode | public Node findOrCreateNode( Session session,
String path,
String nodeType ) throws RepositoryException {
return findOrCreateNode(session, path, nodeType, nodeType);
} | java | public Node findOrCreateNode( Session session,
String path,
String nodeType ) throws RepositoryException {
return findOrCreateNode(session, path, nodeType, nodeType);
} | [
"public",
"Node",
"findOrCreateNode",
"(",
"Session",
"session",
",",
"String",
"path",
",",
"String",
"nodeType",
")",
"throws",
"RepositoryException",
"{",
"return",
"findOrCreateNode",
"(",
"session",
",",
"path",
",",
"nodeType",
",",
"nodeType",
")",
";",
... | Get or create a node at the specified path and node type.
@param session the JCR session. may not be null
@param path the path of the desired node to be found or created. may not be null
@param nodeType the node type. may be null
@return the existing or newly created node
@throws RepositoryException
@throws IllegalArgumentException if either the session or path argument is null | [
"Get",
"or",
"create",
"a",
"node",
"at",
"the",
"specified",
"path",
"and",
"node",
"type",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/JcrTools.java#L354-L358 | train |
ModeShape/modeshape | modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/JcrTools.java | JcrTools.findOrCreateChild | public Node findOrCreateChild( Node parent,
String name ) throws RepositoryException {
return findOrCreateChild(parent, name, null);
} | java | public Node findOrCreateChild( Node parent,
String name ) throws RepositoryException {
return findOrCreateChild(parent, name, null);
} | [
"public",
"Node",
"findOrCreateChild",
"(",
"Node",
"parent",
",",
"String",
"name",
")",
"throws",
"RepositoryException",
"{",
"return",
"findOrCreateChild",
"(",
"parent",
",",
"name",
",",
"null",
")",
";",
"}"
] | Get or create a node with the specified node under the specified parent node.
@param parent the parent node. may not be null
@param name the name of the child node. may not be null
@return the existing or newly created child node
@throws RepositoryException
@throws IllegalArgumentException if either the parent or name argument is null | [
"Get",
"or",
"create",
"a",
"node",
"with",
"the",
"specified",
"node",
"under",
"the",
"specified",
"parent",
"node",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/JcrTools.java#L460-L463 | train |
ModeShape/modeshape | modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/JcrTools.java | JcrTools.findOrCreateChild | public Node findOrCreateChild( Node parent,
String name,
String nodeType ) throws RepositoryException {
return findOrCreateNode(parent, name, nodeType, nodeType);
} | java | public Node findOrCreateChild( Node parent,
String name,
String nodeType ) throws RepositoryException {
return findOrCreateNode(parent, name, nodeType, nodeType);
} | [
"public",
"Node",
"findOrCreateChild",
"(",
"Node",
"parent",
",",
"String",
"name",
",",
"String",
"nodeType",
")",
"throws",
"RepositoryException",
"{",
"return",
"findOrCreateNode",
"(",
"parent",
",",
"name",
",",
"nodeType",
",",
"nodeType",
")",
";",
"}"... | Get or create a node with the specified node and node type under the specified parent node.
@param parent the parent node. may not be null
@param name the name of the child node. may not be null
@param nodeType the node type. may be null
@return the existing or newly created child node
@throws RepositoryException | [
"Get",
"or",
"create",
"a",
"node",
"with",
"the",
"specified",
"node",
"and",
"node",
"type",
"under",
"the",
"specified",
"parent",
"node",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/JcrTools.java#L474-L478 | train |
ModeShape/modeshape | modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/JcrTools.java | JcrTools.onEachNode | public void onEachNode( Session session,
boolean includeSystemNodes,
NodeOperation operation ) throws Exception {
Node node = session.getRootNode();
operation.run(node);
NodeIterator iter = node.getNodes();
while (iter.hasNext()) {
Node child = iter.nextNode();
if (!includeSystemNodes && child.getName().equals("jcr:system")) continue;
operation.run(child);
onEachNodeBelow(child, operation);
}
} | java | public void onEachNode( Session session,
boolean includeSystemNodes,
NodeOperation operation ) throws Exception {
Node node = session.getRootNode();
operation.run(node);
NodeIterator iter = node.getNodes();
while (iter.hasNext()) {
Node child = iter.nextNode();
if (!includeSystemNodes && child.getName().equals("jcr:system")) continue;
operation.run(child);
onEachNodeBelow(child, operation);
}
} | [
"public",
"void",
"onEachNode",
"(",
"Session",
"session",
",",
"boolean",
"includeSystemNodes",
",",
"NodeOperation",
"operation",
")",
"throws",
"Exception",
"{",
"Node",
"node",
"=",
"session",
".",
"getRootNode",
"(",
")",
";",
"operation",
".",
"run",
"("... | Execute the supplied operation on each node in the workspace accessible by the supplied session.
@param session the session
@param includeSystemNodes true if all nodes under "/jcr:system" should be included, or false if the system nodes should be
excluded
@param operation the operation
@throws Exception the exception thrown by the repository or the operation | [
"Execute",
"the",
"supplied",
"operation",
"on",
"each",
"node",
"in",
"the",
"workspace",
"accessible",
"by",
"the",
"supplied",
"session",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/JcrTools.java#L865-L877 | train |
ModeShape/modeshape | sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/node/AstNodeFactory.java | AstNodeFactory.getChildrenForType | public List<AstNode> getChildrenForType( AstNode astNode,
String nodeType ) {
CheckArg.isNotNull(astNode, "astNode");
CheckArg.isNotNull(nodeType, "nodeType");
List<AstNode> childrenOfType = new ArrayList<AstNode>();
for (AstNode child : astNode.getChildren()) {
if (hasMixinType(child, nodeType)) {
childrenOfType.add(child);
}
List<AstNode> subChildrenOfType = getChildrenForType(child, nodeType);
childrenOfType.addAll(subChildrenOfType);
}
return childrenOfType;
} | java | public List<AstNode> getChildrenForType( AstNode astNode,
String nodeType ) {
CheckArg.isNotNull(astNode, "astNode");
CheckArg.isNotNull(nodeType, "nodeType");
List<AstNode> childrenOfType = new ArrayList<AstNode>();
for (AstNode child : astNode.getChildren()) {
if (hasMixinType(child, nodeType)) {
childrenOfType.add(child);
}
List<AstNode> subChildrenOfType = getChildrenForType(child, nodeType);
childrenOfType.addAll(subChildrenOfType);
}
return childrenOfType;
} | [
"public",
"List",
"<",
"AstNode",
">",
"getChildrenForType",
"(",
"AstNode",
"astNode",
",",
"String",
"nodeType",
")",
"{",
"CheckArg",
".",
"isNotNull",
"(",
"astNode",
",",
"\"astNode\"",
")",
";",
"CheckArg",
".",
"isNotNull",
"(",
"nodeType",
",",
"\"no... | Utility method to obtain the children of a given node that match the given type
@param astNode the parent node; may not be null
@param nodeType the type property of the target child node; may not be null
@return the list of typed nodes (may be empty) | [
"Utility",
"method",
"to",
"obtain",
"the",
"children",
"of",
"a",
"given",
"node",
"that",
"match",
"the",
"given",
"type"
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/node/AstNodeFactory.java#L105-L120 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/SequencingRunner.java | SequencingRunner.findOutputNodes | private List<AbstractJcrNode> findOutputNodes( AbstractJcrNode rootOutputNode ) throws RepositoryException {
if (rootOutputNode.isNew()) {
return Arrays.asList(rootOutputNode);
}
// if the node was not new, we need to find the new sequenced nodes
List<AbstractJcrNode> nodes = new ArrayList<AbstractJcrNode>();
NodeIterator childrenIt = rootOutputNode.getNodesInternal();
while (childrenIt.hasNext()) {
Node child = childrenIt.nextNode();
if (child.isNew()) {
nodes.add((AbstractJcrNode)child);
}
}
return nodes;
} | java | private List<AbstractJcrNode> findOutputNodes( AbstractJcrNode rootOutputNode ) throws RepositoryException {
if (rootOutputNode.isNew()) {
return Arrays.asList(rootOutputNode);
}
// if the node was not new, we need to find the new sequenced nodes
List<AbstractJcrNode> nodes = new ArrayList<AbstractJcrNode>();
NodeIterator childrenIt = rootOutputNode.getNodesInternal();
while (childrenIt.hasNext()) {
Node child = childrenIt.nextNode();
if (child.isNew()) {
nodes.add((AbstractJcrNode)child);
}
}
return nodes;
} | [
"private",
"List",
"<",
"AbstractJcrNode",
">",
"findOutputNodes",
"(",
"AbstractJcrNode",
"rootOutputNode",
")",
"throws",
"RepositoryException",
"{",
"if",
"(",
"rootOutputNode",
".",
"isNew",
"(",
")",
")",
"{",
"return",
"Arrays",
".",
"asList",
"(",
"rootOu... | Finds the top nodes which have been created during the sequencing process, based on the original output node. It is
important that this is called before the session is saved, because it uses the new flag.
@param rootOutputNode the node under which the output of the sequencing process was written to.
@return the first level of output nodes that were created during the sequencing process; never null
@throws RepositoryException if there is a problem finding the output nodes | [
"Finds",
"the",
"top",
"nodes",
"which",
"have",
"been",
"created",
"during",
"the",
"sequencing",
"process",
"based",
"on",
"the",
"original",
"output",
"node",
".",
"It",
"is",
"important",
"that",
"this",
"is",
"called",
"before",
"the",
"session",
"is",
... | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/SequencingRunner.java#L365-L380 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/SequencingRunner.java | SequencingRunner.removeExistingOutputNodes | private void removeExistingOutputNodes( AbstractJcrNode parentOfOutput,
String outputNodeName,
String selectedPath,
String logMsg ) throws RepositoryException {
// Determine if there is an existing output node ...
if (TRACE) {
LOGGER.trace("Looking under '{0}' for existing output to be removed for {1}", parentOfOutput.getPath(), logMsg);
}
NodeIterator outputIter = parentOfOutput.getNodesInternal(outputNodeName);
while (outputIter.hasNext()) {
Node outputNode = outputIter.nextNode();
// See if this is indeed the output, which should have the 'mode:derived' mixin ...
if (outputNode.isNodeType(DERIVED_NODE_TYPE_NAME) && outputNode.hasProperty(DERIVED_FROM_PROPERTY_NAME)) {
// See if it was an output for the same input node ...
String derivedFrom = outputNode.getProperty(DERIVED_FROM_PROPERTY_NAME).getString();
if (selectedPath.equals(derivedFrom)) {
// Delete it ...
if (DEBUG) {
LOGGER.debug("Removing existing output node '{0}' for {1}", outputNode.getPath(), logMsg);
}
outputNode.remove();
}
}
}
} | java | private void removeExistingOutputNodes( AbstractJcrNode parentOfOutput,
String outputNodeName,
String selectedPath,
String logMsg ) throws RepositoryException {
// Determine if there is an existing output node ...
if (TRACE) {
LOGGER.trace("Looking under '{0}' for existing output to be removed for {1}", parentOfOutput.getPath(), logMsg);
}
NodeIterator outputIter = parentOfOutput.getNodesInternal(outputNodeName);
while (outputIter.hasNext()) {
Node outputNode = outputIter.nextNode();
// See if this is indeed the output, which should have the 'mode:derived' mixin ...
if (outputNode.isNodeType(DERIVED_NODE_TYPE_NAME) && outputNode.hasProperty(DERIVED_FROM_PROPERTY_NAME)) {
// See if it was an output for the same input node ...
String derivedFrom = outputNode.getProperty(DERIVED_FROM_PROPERTY_NAME).getString();
if (selectedPath.equals(derivedFrom)) {
// Delete it ...
if (DEBUG) {
LOGGER.debug("Removing existing output node '{0}' for {1}", outputNode.getPath(), logMsg);
}
outputNode.remove();
}
}
}
} | [
"private",
"void",
"removeExistingOutputNodes",
"(",
"AbstractJcrNode",
"parentOfOutput",
",",
"String",
"outputNodeName",
",",
"String",
"selectedPath",
",",
"String",
"logMsg",
")",
"throws",
"RepositoryException",
"{",
"// Determine if there is an existing output node ...",
... | Remove any existing nodes that were generated by previous sequencing operations of the node at the selected path.
@param parentOfOutput the parent of the output; may not be null
@param outputNodeName the name of the output node; may not be null or empty
@param selectedPath the path of the node that was selected for sequencing
@param logMsg the log message, or null if trace/debug logging is not being used (this is passed in for efficiency reasons)
@throws RepositoryException if there is a problem accessing the repository content | [
"Remove",
"any",
"existing",
"nodes",
"that",
"were",
"generated",
"by",
"previous",
"sequencing",
"operations",
"of",
"the",
"node",
"at",
"the",
"selected",
"path",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/SequencingRunner.java#L412-L437 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/value/binary/CassandraBinaryStore.java | CassandraBinaryStore.contentExists | private boolean contentExists( BinaryKey key,
boolean alive ) throws BinaryStoreException {
try {
String query = "SELECT payload from modeshape.binary where cid='" + key.toString() + "'";
query = alive ? query + " and usage=1;" : query + " and usage = 0;";
ResultSet rs = session.execute(query);
return rs.iterator().hasNext();
} catch (RuntimeException e) {
throw new BinaryStoreException(e);
}
} | java | private boolean contentExists( BinaryKey key,
boolean alive ) throws BinaryStoreException {
try {
String query = "SELECT payload from modeshape.binary where cid='" + key.toString() + "'";
query = alive ? query + " and usage=1;" : query + " and usage = 0;";
ResultSet rs = session.execute(query);
return rs.iterator().hasNext();
} catch (RuntimeException e) {
throw new BinaryStoreException(e);
}
} | [
"private",
"boolean",
"contentExists",
"(",
"BinaryKey",
"key",
",",
"boolean",
"alive",
")",
"throws",
"BinaryStoreException",
"{",
"try",
"{",
"String",
"query",
"=",
"\"SELECT payload from modeshape.binary where cid='\"",
"+",
"key",
".",
"toString",
"(",
")",
"+... | Test content for existence.
@param key content identifier
@param alive true inside used content and false for checking within content marked as unused.
@return true if content found
@throws BinaryStoreException | [
"Test",
"content",
"for",
"existence",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/value/binary/CassandraBinaryStore.java#L298-L308 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/value/binary/CassandraBinaryStore.java | CassandraBinaryStore.buffer | private ByteBuffer buffer( InputStream stream ) throws IOException {
stream.reset();
ByteArrayOutputStream bout = new ByteArrayOutputStream();
IoUtil.write(stream, bout);
return ByteBuffer.wrap(bout.toByteArray());
} | java | private ByteBuffer buffer( InputStream stream ) throws IOException {
stream.reset();
ByteArrayOutputStream bout = new ByteArrayOutputStream();
IoUtil.write(stream, bout);
return ByteBuffer.wrap(bout.toByteArray());
} | [
"private",
"ByteBuffer",
"buffer",
"(",
"InputStream",
"stream",
")",
"throws",
"IOException",
"{",
"stream",
".",
"reset",
"(",
")",
";",
"ByteArrayOutputStream",
"bout",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"IoUtil",
".",
"write",
"(",
"stream... | Converts input stream into ByteBuffer.
@param stream
@return the byte buffer
@throws IOException | [
"Converts",
"input",
"stream",
"into",
"ByteBuffer",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/value/binary/CassandraBinaryStore.java#L317-L322 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/model/Visitors.java | Visitors.getSelectorAliasesByName | public static Map<SelectorName, SelectorName> getSelectorAliasesByName( Visitable visitable ) {
// Find all of the selectors that have aliases ...
final Map<SelectorName, SelectorName> result = new HashMap<SelectorName, SelectorName>();
Visitors.visitAll(visitable, new Visitors.AbstractVisitor() {
@Override
public void visit( AllNodes allNodes ) {
if (allNodes.hasAlias()) {
result.put(allNodes.name(), allNodes.aliasOrName());
}
}
@Override
public void visit( NamedSelector selector ) {
if (selector.hasAlias()) {
result.put(selector.name(), selector.aliasOrName());
}
}
});
return result;
} | java | public static Map<SelectorName, SelectorName> getSelectorAliasesByName( Visitable visitable ) {
// Find all of the selectors that have aliases ...
final Map<SelectorName, SelectorName> result = new HashMap<SelectorName, SelectorName>();
Visitors.visitAll(visitable, new Visitors.AbstractVisitor() {
@Override
public void visit( AllNodes allNodes ) {
if (allNodes.hasAlias()) {
result.put(allNodes.name(), allNodes.aliasOrName());
}
}
@Override
public void visit( NamedSelector selector ) {
if (selector.hasAlias()) {
result.put(selector.name(), selector.aliasOrName());
}
}
});
return result;
} | [
"public",
"static",
"Map",
"<",
"SelectorName",
",",
"SelectorName",
">",
"getSelectorAliasesByName",
"(",
"Visitable",
"visitable",
")",
"{",
"// Find all of the selectors that have aliases ...",
"final",
"Map",
"<",
"SelectorName",
",",
"SelectorName",
">",
"result",
... | Get a map of the selector aliases keyed by their names.
@param visitable the object to be visited
@return the map from the selector names to their alias (or name if there is no alias); never null but possibly empty | [
"Get",
"a",
"map",
"of",
"the",
"selector",
"aliases",
"keyed",
"by",
"their",
"names",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/model/Visitors.java#L222-L241 | train |
ModeShape/modeshape | sequencers/modeshape-sequencer-images/src/main/java/org/modeshape/sequencer/image/ImageMetadata.java | ImageMetadata.getComment | public String getComment( int index ) {
if (comments == null || index < 0 || index >= comments.size()) {
throw new IllegalArgumentException("Not a valid comment index: " + index);
}
return comments.elementAt(index);
} | java | public String getComment( int index ) {
if (comments == null || index < 0 || index >= comments.size()) {
throw new IllegalArgumentException("Not a valid comment index: " + index);
}
return comments.elementAt(index);
} | [
"public",
"String",
"getComment",
"(",
"int",
"index",
")",
"{",
"if",
"(",
"comments",
"==",
"null",
"||",
"index",
"<",
"0",
"||",
"index",
">=",
"comments",
".",
"size",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Not a val... | Returns the index'th comment retrieved from the file.
@param index int index of comment to return
@return the comment at the supplied index
@throws IllegalArgumentException if index is smaller than 0 or larger than or equal to the number of comments retrieved
@see #getNumberOfComments | [
"Returns",
"the",
"index",
"th",
"comment",
"retrieved",
"from",
"the",
"file",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-images/src/main/java/org/modeshape/sequencer/image/ImageMetadata.java#L717-L722 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/security/acl/AccessControlEntryImpl.java | AccessControlEntryImpl.hasPrivileges | protected boolean hasPrivileges( Privilege[] privileges ) {
for (Privilege p : privileges) {
if (!contains(this.privileges, p)) {
return false;
}
}
return true;
} | java | protected boolean hasPrivileges( Privilege[] privileges ) {
for (Privilege p : privileges) {
if (!contains(this.privileges, p)) {
return false;
}
}
return true;
} | [
"protected",
"boolean",
"hasPrivileges",
"(",
"Privilege",
"[",
"]",
"privileges",
")",
"{",
"for",
"(",
"Privilege",
"p",
":",
"privileges",
")",
"{",
"if",
"(",
"!",
"contains",
"(",
"this",
".",
"privileges",
",",
"p",
")",
")",
"{",
"return",
"fals... | Tests given privileges.
@param privileges privileges for testing.
@return true if this entry contains all given privileges | [
"Tests",
"given",
"privileges",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/security/acl/AccessControlEntryImpl.java#L72-L79 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/security/acl/AccessControlEntryImpl.java | AccessControlEntryImpl.addIfNotPresent | protected boolean addIfNotPresent( Privilege[] privileges ) {
ArrayList<Privilege> list = new ArrayList<Privilege>();
Collections.addAll(list, privileges);
boolean res = combineRecursively(list, privileges);
this.privileges.addAll(list);
return res;
} | java | protected boolean addIfNotPresent( Privilege[] privileges ) {
ArrayList<Privilege> list = new ArrayList<Privilege>();
Collections.addAll(list, privileges);
boolean res = combineRecursively(list, privileges);
this.privileges.addAll(list);
return res;
} | [
"protected",
"boolean",
"addIfNotPresent",
"(",
"Privilege",
"[",
"]",
"privileges",
")",
"{",
"ArrayList",
"<",
"Privilege",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"Privilege",
">",
"(",
")",
";",
"Collections",
".",
"addAll",
"(",
"list",
",",
"privi... | Adds specified privileges to this entry.
@param privileges privileges to add.
@return true if at least one of privileges was added. | [
"Adds",
"specified",
"privileges",
"to",
"this",
"entry",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/security/acl/AccessControlEntryImpl.java#L97-L105 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/security/acl/AccessControlEntryImpl.java | AccessControlEntryImpl.combineRecursively | protected boolean combineRecursively( List<Privilege> list,
Privilege[] privileges ) {
boolean res = false;
for (Privilege p : privileges) {
if (p.isAggregate()) {
res = combineRecursively(list, p.getAggregatePrivileges());
} else if (!contains(list, p)) {
list.add(p);
res = true;
}
}
return res;
} | java | protected boolean combineRecursively( List<Privilege> list,
Privilege[] privileges ) {
boolean res = false;
for (Privilege p : privileges) {
if (p.isAggregate()) {
res = combineRecursively(list, p.getAggregatePrivileges());
} else if (!contains(list, p)) {
list.add(p);
res = true;
}
}
return res;
} | [
"protected",
"boolean",
"combineRecursively",
"(",
"List",
"<",
"Privilege",
">",
"list",
",",
"Privilege",
"[",
"]",
"privileges",
")",
"{",
"boolean",
"res",
"=",
"false",
";",
"for",
"(",
"Privilege",
"p",
":",
"privileges",
")",
"{",
"if",
"(",
"p",
... | Adds specified privileges to the given list.
@param list the result list of combined privileges.
@param privileges privileges to add.
@return true if at least one of privileges was added. | [
"Adds",
"specified",
"privileges",
"to",
"the",
"given",
"list",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/security/acl/AccessControlEntryImpl.java#L114-L127 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/engine/ScanningQueryEngine.java | ScanningQueryEngine.createNodeSequenceForSource | protected NodeSequence createNodeSequenceForSource( QueryCommand originalQuery,
QueryContext context,
PlanNode sourceNode,
Columns columns,
QuerySources sources ) {
// The indexes should already be in the correct order, from lowest cost to highest cost ...
for (PlanNode indexNode : sourceNode.getChildren()) {
if (indexNode.getType() != Type.INDEX) continue;
IndexPlan index = indexNode.getProperty(Property.INDEX_SPECIFICATION, IndexPlan.class);
NodeSequence sequence = createNodeSequenceForSource(originalQuery, context, sourceNode, index, columns, sources);
if (sequence != null) {
// Mark the index as being used ...
indexNode.setProperty(Property.INDEX_USED, Boolean.TRUE);
return sequence;
}
// Otherwise, keep looking for an index ...
LOGGER.debug("Skipping disabled index '{0}' from provider '{1}' in workspace(s) {2} for query: {3}", index.getName(),
index.getProviderName(), context.getWorkspaceNames(), originalQuery);
}
// Grab all of the nodes ...
return sources.allNodes(1.0f, -1);
} | java | protected NodeSequence createNodeSequenceForSource( QueryCommand originalQuery,
QueryContext context,
PlanNode sourceNode,
Columns columns,
QuerySources sources ) {
// The indexes should already be in the correct order, from lowest cost to highest cost ...
for (PlanNode indexNode : sourceNode.getChildren()) {
if (indexNode.getType() != Type.INDEX) continue;
IndexPlan index = indexNode.getProperty(Property.INDEX_SPECIFICATION, IndexPlan.class);
NodeSequence sequence = createNodeSequenceForSource(originalQuery, context, sourceNode, index, columns, sources);
if (sequence != null) {
// Mark the index as being used ...
indexNode.setProperty(Property.INDEX_USED, Boolean.TRUE);
return sequence;
}
// Otherwise, keep looking for an index ...
LOGGER.debug("Skipping disabled index '{0}' from provider '{1}' in workspace(s) {2} for query: {3}", index.getName(),
index.getProviderName(), context.getWorkspaceNames(), originalQuery);
}
// Grab all of the nodes ...
return sources.allNodes(1.0f, -1);
} | [
"protected",
"NodeSequence",
"createNodeSequenceForSource",
"(",
"QueryCommand",
"originalQuery",
",",
"QueryContext",
"context",
",",
"PlanNode",
"sourceNode",
",",
"Columns",
"columns",
",",
"QuerySources",
"sources",
")",
"{",
"// The indexes should already be in the corre... | Create a node sequence for the given source.
@param originalQuery the original query command; may not be null
@param context the context in which the query is to be executed; may not be null
@param sourceNode the {@link Type#SOURCE} plan node for one part of a query; may not be null
@param columns the result column definition; may not be null
@param sources the query sources for the repository; may not be null
@return the sequence of results; null only if the type of plan is not understood | [
"Create",
"a",
"node",
"sequence",
"for",
"the",
"given",
"source",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/engine/ScanningQueryEngine.java#L951-L973 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/engine/ScanningQueryEngine.java | ScanningQueryEngine.createNodeSequenceForSource | protected NodeSequence createNodeSequenceForSource( QueryCommand originalQuery,
QueryContext context,
PlanNode sourceNode,
IndexPlan index,
Columns columns,
QuerySources sources ) {
if (index.getProviderName() == null) {
String name = index.getName();
String pathStr = (String)index.getParameters().get(IndexPlanners.PATH_PARAMETER);
if (pathStr != null) {
if (IndexPlanners.NODE_BY_PATH_INDEX_NAME.equals(name)) {
PathFactory paths = context.getExecutionContext().getValueFactories().getPathFactory();
Path path = paths.create(pathStr);
return sources.singleNode(path, 1.0f);
}
if (IndexPlanners.CHILDREN_BY_PATH_INDEX_NAME.equals(name)) {
PathFactory paths = context.getExecutionContext().getValueFactories().getPathFactory();
Path path = paths.create(pathStr);
return sources.childNodes(path, 1.0f);
}
if (IndexPlanners.DESCENDANTS_BY_PATH_INDEX_NAME.equals(name)) {
PathFactory paths = context.getExecutionContext().getValueFactories().getPathFactory();
Path path = paths.create(pathStr);
return sources.descendantNodes(path, 1.0f);
}
}
String idStr = (String)index.getParameters().get(IndexPlanners.ID_PARAMETER);
if (idStr != null) {
if (IndexPlanners.NODE_BY_ID_INDEX_NAME.equals(name)) {
StringFactory string = context.getExecutionContext().getValueFactories().getStringFactory();
String id = string.create(idStr);
final String workspaceName = context.getWorkspaceNames().iterator().next();
return sources.singleNode(workspaceName, id, 1.0f);
}
}
}
return null;
} | java | protected NodeSequence createNodeSequenceForSource( QueryCommand originalQuery,
QueryContext context,
PlanNode sourceNode,
IndexPlan index,
Columns columns,
QuerySources sources ) {
if (index.getProviderName() == null) {
String name = index.getName();
String pathStr = (String)index.getParameters().get(IndexPlanners.PATH_PARAMETER);
if (pathStr != null) {
if (IndexPlanners.NODE_BY_PATH_INDEX_NAME.equals(name)) {
PathFactory paths = context.getExecutionContext().getValueFactories().getPathFactory();
Path path = paths.create(pathStr);
return sources.singleNode(path, 1.0f);
}
if (IndexPlanners.CHILDREN_BY_PATH_INDEX_NAME.equals(name)) {
PathFactory paths = context.getExecutionContext().getValueFactories().getPathFactory();
Path path = paths.create(pathStr);
return sources.childNodes(path, 1.0f);
}
if (IndexPlanners.DESCENDANTS_BY_PATH_INDEX_NAME.equals(name)) {
PathFactory paths = context.getExecutionContext().getValueFactories().getPathFactory();
Path path = paths.create(pathStr);
return sources.descendantNodes(path, 1.0f);
}
}
String idStr = (String)index.getParameters().get(IndexPlanners.ID_PARAMETER);
if (idStr != null) {
if (IndexPlanners.NODE_BY_ID_INDEX_NAME.equals(name)) {
StringFactory string = context.getExecutionContext().getValueFactories().getStringFactory();
String id = string.create(idStr);
final String workspaceName = context.getWorkspaceNames().iterator().next();
return sources.singleNode(workspaceName, id, 1.0f);
}
}
}
return null;
} | [
"protected",
"NodeSequence",
"createNodeSequenceForSource",
"(",
"QueryCommand",
"originalQuery",
",",
"QueryContext",
"context",
",",
"PlanNode",
"sourceNode",
",",
"IndexPlan",
"index",
",",
"Columns",
"columns",
",",
"QuerySources",
"sources",
")",
"{",
"if",
"(",
... | Create a node sequence for the given index
@param originalQuery the original query command; may not be null
@param context the context in which the query is to be executed; may not be null
@param sourceNode the {@link Type#SOURCE} plan node for one part of a query; may not be null
@param index the {@link IndexPlan} specification; may not be null
@param columns the result column definition; may not be null
@param sources the query sources for the repository; may not be null
@return the sequence of results; null only if the type of index is not understood | [
"Create",
"a",
"node",
"sequence",
"for",
"the",
"given",
"index"
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/engine/ScanningQueryEngine.java#L986-L1023 | train |
ModeShape/modeshape | web/modeshape-web-cmis/src/main/java/org/modeshape/cmis/JcrMsVersion.java | JcrMsVersion.getHash | private String getHash() {
try {
Node contentNode = getContextNode();
Property data = contentNode.getProperty(Property.JCR_DATA);
Binary bin = (Binary) data.getBinary();
return String.format("{%s}%s", HASH_ALGORITHM, bin.getHexHash());
} catch (RepositoryException e) {
return "";
}
} | java | private String getHash() {
try {
Node contentNode = getContextNode();
Property data = contentNode.getProperty(Property.JCR_DATA);
Binary bin = (Binary) data.getBinary();
return String.format("{%s}%s", HASH_ALGORITHM, bin.getHexHash());
} catch (RepositoryException e) {
return "";
}
} | [
"private",
"String",
"getHash",
"(",
")",
"{",
"try",
"{",
"Node",
"contentNode",
"=",
"getContextNode",
"(",
")",
";",
"Property",
"data",
"=",
"contentNode",
".",
"getProperty",
"(",
"Property",
".",
"JCR_DATA",
")",
";",
"Binary",
"bin",
"=",
"(",
"Bi... | Get the hexadecimal form of the SHA-1 hash of the contents.
@return the hexadecimal form of hash, or a null string if the hash could not be computed or is not known | [
"Get",
"the",
"hexadecimal",
"form",
"of",
"the",
"SHA",
"-",
"1",
"hash",
"of",
"the",
"contents",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-cmis/src/main/java/org/modeshape/cmis/JcrMsVersion.java#L110-L119 | train |
ModeShape/modeshape | web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/contents/WorkspacePanel.java | WorkspacePanel.setWorkspaceNames | public void setWorkspaceNames(String[] values) {
col2.combo.setValueMap(values);
if (values.length > 0) {
col2.combo.setValue(values[0]);
}
} | java | public void setWorkspaceNames(String[] values) {
col2.combo.setValueMap(values);
if (values.length > 0) {
col2.combo.setValue(values[0]);
}
} | [
"public",
"void",
"setWorkspaceNames",
"(",
"String",
"[",
"]",
"values",
")",
"{",
"col2",
".",
"combo",
".",
"setValueMap",
"(",
"values",
")",
";",
"if",
"(",
"values",
".",
"length",
">",
"0",
")",
"{",
"col2",
".",
"combo",
".",
"setValue",
"(",... | Assigns workspace names to the combo box into column 2.
@param values | [
"Assigns",
"workspace",
"names",
"to",
"the",
"combo",
"box",
"into",
"column",
"2",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/contents/WorkspacePanel.java#L85-L90 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/JcrVersionHistoryNode.java | JcrVersionHistoryNode.versionLabelsFor | private Set<String> versionLabelsFor( Version version ) throws RepositoryException {
if (!version.getParent().equals(this)) {
throw new VersionException(JcrI18n.invalidVersion.text(version.getPath(), getPath()));
}
String versionId = version.getIdentifier();
PropertyIterator iter = versionLabels().getProperties();
if (iter.getSize() == 0) return Collections.emptySet();
Set<String> labels = new HashSet<String>();
while (iter.hasNext()) {
javax.jcr.Property prop = iter.nextProperty();
if (versionId.equals(prop.getString())) {
labels.add(prop.getName());
}
}
return labels;
} | java | private Set<String> versionLabelsFor( Version version ) throws RepositoryException {
if (!version.getParent().equals(this)) {
throw new VersionException(JcrI18n.invalidVersion.text(version.getPath(), getPath()));
}
String versionId = version.getIdentifier();
PropertyIterator iter = versionLabels().getProperties();
if (iter.getSize() == 0) return Collections.emptySet();
Set<String> labels = new HashSet<String>();
while (iter.hasNext()) {
javax.jcr.Property prop = iter.nextProperty();
if (versionId.equals(prop.getString())) {
labels.add(prop.getName());
}
}
return labels;
} | [
"private",
"Set",
"<",
"String",
">",
"versionLabelsFor",
"(",
"Version",
"version",
")",
"throws",
"RepositoryException",
"{",
"if",
"(",
"!",
"version",
".",
"getParent",
"(",
")",
".",
"equals",
"(",
"this",
")",
")",
"{",
"throw",
"new",
"VersionExcept... | Returns the version labels that point to the given version
@param version the version for which the labels should be retrieved
@return the set of version labels for that version; never null
@throws RepositoryException if an error occurs accessing the repository | [
"Returns",
"the",
"version",
"labels",
"that",
"point",
"to",
"the",
"given",
"version"
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/JcrVersionHistoryNode.java#L136-L153 | train |
ModeShape/modeshape | modeshape-jca/src/main/java/org/modeshape/jca/JcrConnectionRequestInfo.java | JcrConnectionRequestInfo.computeCredsHashCode | private int computeCredsHashCode( Credentials c ) {
if (c instanceof SimpleCredentials) {
return computeSimpleCredsHashCode((SimpleCredentials)c);
}
return c.hashCode();
} | java | private int computeCredsHashCode( Credentials c ) {
if (c instanceof SimpleCredentials) {
return computeSimpleCredsHashCode((SimpleCredentials)c);
}
return c.hashCode();
} | [
"private",
"int",
"computeCredsHashCode",
"(",
"Credentials",
"c",
")",
"{",
"if",
"(",
"c",
"instanceof",
"SimpleCredentials",
")",
"{",
"return",
"computeSimpleCredsHashCode",
"(",
"(",
"SimpleCredentials",
")",
"c",
")",
";",
"}",
"return",
"c",
".",
"hashC... | Returns Credentials instance hash code. Handles instances of SimpleCredentials in a special way.
@param c the credentials
@return the hash code | [
"Returns",
"Credentials",
"instance",
"hash",
"code",
".",
"Handles",
"instances",
"of",
"SimpleCredentials",
"in",
"a",
"special",
"way",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jca/src/main/java/org/modeshape/jca/JcrConnectionRequestInfo.java#L197-L202 | train |
ModeShape/modeshape | sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/node/AstNode.java | AstNode.getSameNameSiblingIndex | public int getSameNameSiblingIndex() {
int snsIndex = 1;
if (this.parent == null) {
return snsIndex;
}
// Go through all the children ...
for (AstNode sibling : this.parent.getChildren()) {
if (sibling == this) {
break;
}
if (sibling.getName().equals(this.name)) {
++snsIndex;
}
}
return snsIndex;
} | java | public int getSameNameSiblingIndex() {
int snsIndex = 1;
if (this.parent == null) {
return snsIndex;
}
// Go through all the children ...
for (AstNode sibling : this.parent.getChildren()) {
if (sibling == this) {
break;
}
if (sibling.getName().equals(this.name)) {
++snsIndex;
}
}
return snsIndex;
} | [
"public",
"int",
"getSameNameSiblingIndex",
"(",
")",
"{",
"int",
"snsIndex",
"=",
"1",
";",
"if",
"(",
"this",
".",
"parent",
"==",
"null",
")",
"{",
"return",
"snsIndex",
";",
"}",
"// Go through all the children ...",
"for",
"(",
"AstNode",
"sibling",
":"... | Get the current same-name-sibling index.
@return the SNS index, or 1 if this is the first sibling with the same name | [
"Get",
"the",
"current",
"same",
"-",
"name",
"-",
"sibling",
"index",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/node/AstNode.java#L114-L129 | train |
ModeShape/modeshape | sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/node/AstNode.java | AstNode.getAbsolutePath | public String getAbsolutePath() {
StringBuilder pathBuilder = new StringBuilder("/").append(this.getName());
AstNode parent = this.getParent();
while (parent != null) {
pathBuilder.insert(0, "/" + parent.getName());
parent = parent.getParent();
}
return pathBuilder.toString();
} | java | public String getAbsolutePath() {
StringBuilder pathBuilder = new StringBuilder("/").append(this.getName());
AstNode parent = this.getParent();
while (parent != null) {
pathBuilder.insert(0, "/" + parent.getName());
parent = parent.getParent();
}
return pathBuilder.toString();
} | [
"public",
"String",
"getAbsolutePath",
"(",
")",
"{",
"StringBuilder",
"pathBuilder",
"=",
"new",
"StringBuilder",
"(",
"\"/\"",
")",
".",
"append",
"(",
"this",
".",
"getName",
"(",
")",
")",
";",
"AstNode",
"parent",
"=",
"this",
".",
"getParent",
"(",
... | Get the current path of this node
@return the path of this node; never null | [
"Get",
"the",
"current",
"path",
"of",
"this",
"node"
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/node/AstNode.java#L136-L144 | train |
ModeShape/modeshape | sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/node/AstNode.java | AstNode.setProperty | public AstNode setProperty( String name,
Object value ) {
CheckArg.isNotNull(name, "name");
CheckArg.isNotNull(value, "value");
properties.put(name, value);
return this;
} | java | public AstNode setProperty( String name,
Object value ) {
CheckArg.isNotNull(name, "name");
CheckArg.isNotNull(value, "value");
properties.put(name, value);
return this;
} | [
"public",
"AstNode",
"setProperty",
"(",
"String",
"name",
",",
"Object",
"value",
")",
"{",
"CheckArg",
".",
"isNotNull",
"(",
"name",
",",
"\"name\"",
")",
";",
"CheckArg",
".",
"isNotNull",
"(",
"value",
",",
"\"value\"",
")",
";",
"properties",
".",
... | Set the property with the given name to the supplied value. Any existing property with the same name will be replaced.
@param name the name of the property; may not be null
@param value the value of the property; may not be null
@return this node, for method chaining purposes | [
"Set",
"the",
"property",
"with",
"the",
"given",
"name",
"to",
"the",
"supplied",
"value",
".",
"Any",
"existing",
"property",
"with",
"the",
"same",
"name",
"will",
"be",
"replaced",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/node/AstNode.java#L163-L169 | train |
ModeShape/modeshape | sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/node/AstNode.java | AstNode.setProperty | public AstNode setProperty( String name,
Object... values ) {
CheckArg.isNotNull(name, "name");
CheckArg.isNotNull(values, "value");
if (values.length != 0) {
properties.put(name, Arrays.asList(values));
}
return this;
} | java | public AstNode setProperty( String name,
Object... values ) {
CheckArg.isNotNull(name, "name");
CheckArg.isNotNull(values, "value");
if (values.length != 0) {
properties.put(name, Arrays.asList(values));
}
return this;
} | [
"public",
"AstNode",
"setProperty",
"(",
"String",
"name",
",",
"Object",
"...",
"values",
")",
"{",
"CheckArg",
".",
"isNotNull",
"(",
"name",
",",
"\"name\"",
")",
";",
"CheckArg",
".",
"isNotNull",
"(",
"values",
",",
"\"value\"",
")",
";",
"if",
"(",... | Set the property with the given name to the supplied values. If there is at least one value, the new property will replace
any existing property with the same name. This method does nothing if zero values are supplied.
@param name the name of the property; may not be null
@param values the values of the property
@return this node, for method chaining purposes | [
"Set",
"the",
"property",
"with",
"the",
"given",
"name",
"to",
"the",
"supplied",
"values",
".",
"If",
"there",
"is",
"at",
"least",
"one",
"value",
"the",
"new",
"property",
"will",
"replace",
"any",
"existing",
"property",
"with",
"the",
"same",
"name",... | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/sequencers/modeshape-sequencer-ddl/src/main/java/org/modeshape/sequencer/ddl/node/AstNode.java#L179-L187 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/parse/BasicSqlQueryParser.java | BasicSqlQueryParser.removeBracketsAndQuotes | protected String removeBracketsAndQuotes( String text,
Position position ) {
return removeBracketsAndQuotes(text, true, position);
} | java | protected String removeBracketsAndQuotes( String text,
Position position ) {
return removeBracketsAndQuotes(text, true, position);
} | [
"protected",
"String",
"removeBracketsAndQuotes",
"(",
"String",
"text",
",",
"Position",
"position",
")",
"{",
"return",
"removeBracketsAndQuotes",
"(",
"text",
",",
"true",
",",
"position",
")",
";",
"}"
] | Remove all leading and trailing single-quotes, double-quotes, or square brackets from the supplied text. If multiple,
properly-paired quotes or brackets are found, they will all be removed.
@param text the input text; may not be null
@param position the position of the text; may not be null
@return the text without leading and trailing brackets and quotes, or <code>text</code> if there were no square brackets or
quotes | [
"Remove",
"all",
"leading",
"and",
"trailing",
"single",
"-",
"quotes",
"double",
"-",
"quotes",
"or",
"square",
"brackets",
"from",
"the",
"supplied",
"text",
".",
"If",
"multiple",
"properly",
"-",
"paired",
"quotes",
"or",
"brackets",
"are",
"found",
"the... | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/parse/BasicSqlQueryParser.java#L1353-L1356 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/parse/BasicSqlQueryParser.java | BasicSqlQueryParser.removeBracketsAndQuotes | protected String removeBracketsAndQuotes( String text,
boolean recursive,
Position position ) {
if (text.length() > 0) {
char firstChar = text.charAt(0);
switch (firstChar) {
case '\'':
case '"':
if (text.charAt(text.length() - 1) != firstChar) {
String msg = GraphI18n.expectingValidName.text(text, position.getLine(), position.getColumn());
throw new ParsingException(position, msg);
}
String removed = text.substring(1, text.length() - 1);
return recursive ? removeBracketsAndQuotes(removed, recursive, position) : removed;
case '[':
if (text.charAt(text.length() - 1) != ']') {
String msg = GraphI18n.expectingValidName.text(text, position.getLine(), position.getColumn());
throw new ParsingException(position, msg);
}
removed = text.substring(1, text.length() - 1);
return recursive ? removeBracketsAndQuotes(removed, recursive, position) : removed;
}
}
return text;
} | java | protected String removeBracketsAndQuotes( String text,
boolean recursive,
Position position ) {
if (text.length() > 0) {
char firstChar = text.charAt(0);
switch (firstChar) {
case '\'':
case '"':
if (text.charAt(text.length() - 1) != firstChar) {
String msg = GraphI18n.expectingValidName.text(text, position.getLine(), position.getColumn());
throw new ParsingException(position, msg);
}
String removed = text.substring(1, text.length() - 1);
return recursive ? removeBracketsAndQuotes(removed, recursive, position) : removed;
case '[':
if (text.charAt(text.length() - 1) != ']') {
String msg = GraphI18n.expectingValidName.text(text, position.getLine(), position.getColumn());
throw new ParsingException(position, msg);
}
removed = text.substring(1, text.length() - 1);
return recursive ? removeBracketsAndQuotes(removed, recursive, position) : removed;
}
}
return text;
} | [
"protected",
"String",
"removeBracketsAndQuotes",
"(",
"String",
"text",
",",
"boolean",
"recursive",
",",
"Position",
"position",
")",
"{",
"if",
"(",
"text",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"char",
"firstChar",
"=",
"text",
".",
"charAt",
... | Remove any leading and trailing single-quotes, double-quotes, or square brackets from the supplied text.
@param text the input text; may not be null
@param recursive true if more than one pair of quotes, double-quotes, or square brackets should be removed, or false if
just the first pair should be removed
@param position the position of the text; may not be null
@return the text without leading and trailing brackets and quotes, or <code>text</code> if there were no square brackets or
quotes | [
"Remove",
"any",
"leading",
"and",
"trailing",
"single",
"-",
"quotes",
"double",
"-",
"quotes",
"or",
"square",
"brackets",
"from",
"the",
"supplied",
"text",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/parse/BasicSqlQueryParser.java#L1368-L1392 | train |
ModeShape/modeshape | web/modeshape-web-explorer/src/main/java/org/modeshape/web/server/JcrServiceImpl.java | JcrServiceImpl.propertyDefs | private String[] propertyDefs( Node node ) throws RepositoryException {
ArrayList<String> list = new ArrayList<>();
NodeType primaryType = node.getPrimaryNodeType();
PropertyDefinition[] defs = primaryType.getPropertyDefinitions();
for (PropertyDefinition def : defs) {
if (!def.isProtected()) {
list.add(def.getName());
}
}
NodeType[] mixinType = node.getMixinNodeTypes();
for (NodeType type : mixinType) {
defs = type.getPropertyDefinitions();
for (PropertyDefinition def : defs) {
if (!def.isProtected()) {
list.add(def.getName());
}
}
}
String[] res = new String[list.size()];
list.toArray(res);
return res;
} | java | private String[] propertyDefs( Node node ) throws RepositoryException {
ArrayList<String> list = new ArrayList<>();
NodeType primaryType = node.getPrimaryNodeType();
PropertyDefinition[] defs = primaryType.getPropertyDefinitions();
for (PropertyDefinition def : defs) {
if (!def.isProtected()) {
list.add(def.getName());
}
}
NodeType[] mixinType = node.getMixinNodeTypes();
for (NodeType type : mixinType) {
defs = type.getPropertyDefinitions();
for (PropertyDefinition def : defs) {
if (!def.isProtected()) {
list.add(def.getName());
}
}
}
String[] res = new String[list.size()];
list.toArray(res);
return res;
} | [
"private",
"String",
"[",
"]",
"propertyDefs",
"(",
"Node",
"node",
")",
"throws",
"RepositoryException",
"{",
"ArrayList",
"<",
"String",
">",
"list",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"NodeType",
"primaryType",
"=",
"node",
".",
"getPrimaryNode... | Gets the list of properties available to the given node.
@param node the node instance.
@return list of property names.
@throws RepositoryException | [
"Gets",
"the",
"list",
"of",
"properties",
"available",
"to",
"the",
"given",
"node",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/server/JcrServiceImpl.java#L272-L298 | train |
ModeShape/modeshape | web/modeshape-web-explorer/src/main/java/org/modeshape/web/server/JcrServiceImpl.java | JcrServiceImpl.findAccessList | private AccessControlList findAccessList( AccessControlManager acm,
String path ) throws RepositoryException {
AccessControlPolicy[] policy = acm.getPolicies(path);
if (policy != null && policy.length > 0) {
return (AccessControlList)policy[0];
}
policy = acm.getEffectivePolicies(path);
if (policy != null && policy.length > 0) {
return (AccessControlList)policy[0];
}
return null;
} | java | private AccessControlList findAccessList( AccessControlManager acm,
String path ) throws RepositoryException {
AccessControlPolicy[] policy = acm.getPolicies(path);
if (policy != null && policy.length > 0) {
return (AccessControlList)policy[0];
}
policy = acm.getEffectivePolicies(path);
if (policy != null && policy.length > 0) {
return (AccessControlList)policy[0];
}
return null;
} | [
"private",
"AccessControlList",
"findAccessList",
"(",
"AccessControlManager",
"acm",
",",
"String",
"path",
")",
"throws",
"RepositoryException",
"{",
"AccessControlPolicy",
"[",
"]",
"policy",
"=",
"acm",
".",
"getPolicies",
"(",
"path",
")",
";",
"if",
"(",
"... | Searches access list for the given node.
@param acm access manager
@param path the path to the node
@return access list representation.
@throws RepositoryException | [
"Searches",
"access",
"list",
"for",
"the",
"given",
"node",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/server/JcrServiceImpl.java#L335-L349 | train |
ModeShape/modeshape | web/modeshape-web-explorer/src/main/java/org/modeshape/web/server/JcrServiceImpl.java | JcrServiceImpl.getProperties | private Collection<JcrProperty> getProperties( String repository, String workspace, String path, Node node ) throws RepositoryException {
ArrayList<PropertyDefinition> names = new ArrayList<>();
NodeType primaryType = node.getPrimaryNodeType();
PropertyDefinition[] defs = primaryType.getPropertyDefinitions();
names.addAll(Arrays.asList(defs));
NodeType[] mixinType = node.getMixinNodeTypes();
for (NodeType type : mixinType) {
defs = type.getPropertyDefinitions();
names.addAll(Arrays.asList(defs));
}
ArrayList<JcrProperty> list = new ArrayList<>();
for (PropertyDefinition def : names) {
String name = def.getName();
String type = PropertyType.nameFromValue(def.getRequiredType());
Property p = null;
try {
p = node.getProperty(def.getName());
} catch (PathNotFoundException e) {
}
String display = values(def, p);
String value = def.isMultiple() ? multiValue(p)
: singleValue(p, def, repository, workspace, path);
list.add(new JcrProperty(name, type, value, display));
}
return list;
} | java | private Collection<JcrProperty> getProperties( String repository, String workspace, String path, Node node ) throws RepositoryException {
ArrayList<PropertyDefinition> names = new ArrayList<>();
NodeType primaryType = node.getPrimaryNodeType();
PropertyDefinition[] defs = primaryType.getPropertyDefinitions();
names.addAll(Arrays.asList(defs));
NodeType[] mixinType = node.getMixinNodeTypes();
for (NodeType type : mixinType) {
defs = type.getPropertyDefinitions();
names.addAll(Arrays.asList(defs));
}
ArrayList<JcrProperty> list = new ArrayList<>();
for (PropertyDefinition def : names) {
String name = def.getName();
String type = PropertyType.nameFromValue(def.getRequiredType());
Property p = null;
try {
p = node.getProperty(def.getName());
} catch (PathNotFoundException e) {
}
String display = values(def, p);
String value = def.isMultiple() ? multiValue(p)
: singleValue(p, def, repository, workspace, path);
list.add(new JcrProperty(name, type, value, display));
}
return list;
} | [
"private",
"Collection",
"<",
"JcrProperty",
">",
"getProperties",
"(",
"String",
"repository",
",",
"String",
"workspace",
",",
"String",
"path",
",",
"Node",
"node",
")",
"throws",
"RepositoryException",
"{",
"ArrayList",
"<",
"PropertyDefinition",
">",
"names",... | Reads properties of the given node.
@param repository the repository name
@param workspace the workspace name
@param path the path to the node
@param node the node instance
@return list of node's properties.
@throws RepositoryException | [
"Reads",
"properties",
"of",
"the",
"given",
"node",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/server/JcrServiceImpl.java#L361-L394 | train |
ModeShape/modeshape | web/modeshape-web-explorer/src/main/java/org/modeshape/web/server/JcrServiceImpl.java | JcrServiceImpl.values | private String values( PropertyDefinition pd, Property p ) throws RepositoryException {
if (p == null) {
return "N/A";
}
if (pd.getRequiredType() == PropertyType.BINARY) {
return "BINARY";
}
if (!p.isMultiple()) {
return p.getString();
}
return multiValue(p);
} | java | private String values( PropertyDefinition pd, Property p ) throws RepositoryException {
if (p == null) {
return "N/A";
}
if (pd.getRequiredType() == PropertyType.BINARY) {
return "BINARY";
}
if (!p.isMultiple()) {
return p.getString();
}
return multiValue(p);
} | [
"private",
"String",
"values",
"(",
"PropertyDefinition",
"pd",
",",
"Property",
"p",
")",
"throws",
"RepositoryException",
"{",
"if",
"(",
"p",
"==",
"null",
")",
"{",
"return",
"\"N/A\"",
";",
"}",
"if",
"(",
"pd",
".",
"getRequiredType",
"(",
")",
"==... | Displays property value as string
@param pd the property definition
@param p the property to display
@return property value as text string
@throws RepositoryException | [
"Displays",
"property",
"value",
"as",
"string"
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/server/JcrServiceImpl.java#L440-L454 | train |
ModeShape/modeshape | web/modeshape-web-explorer/src/main/java/org/modeshape/web/server/JcrServiceImpl.java | JcrServiceImpl.pick | private AccessControlEntry pick( AccessControlList acl,
String principal ) throws RepositoryException {
for (AccessControlEntry entry : acl.getAccessControlEntries()) {
if (entry.getPrincipal().getName().equals(principal)) {
return entry;
}
}
return null;
} | java | private AccessControlEntry pick( AccessControlList acl,
String principal ) throws RepositoryException {
for (AccessControlEntry entry : acl.getAccessControlEntries()) {
if (entry.getPrincipal().getName().equals(principal)) {
return entry;
}
}
return null;
} | [
"private",
"AccessControlEntry",
"pick",
"(",
"AccessControlList",
"acl",
",",
"String",
"principal",
")",
"throws",
"RepositoryException",
"{",
"for",
"(",
"AccessControlEntry",
"entry",
":",
"acl",
".",
"getAccessControlEntries",
"(",
")",
")",
"{",
"if",
"(",
... | Picks access entry for the given principal.
@param acl
@param principal
@return the ACL entry
@throws RepositoryException | [
"Picks",
"access",
"entry",
"for",
"the",
"given",
"principal",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/server/JcrServiceImpl.java#L852-L860 | train |
ModeShape/modeshape | web/modeshape-web-explorer/src/main/java/org/modeshape/web/server/JcrServiceImpl.java | JcrServiceImpl.excludePrivilege | private Privilege[] excludePrivilege( Privilege[] privileges,
JcrPermission permission ) {
ArrayList<Privilege> list = new ArrayList<>();
for (Privilege privilege : privileges) {
if (!privilege.getName().equalsIgnoreCase(permission.getName())) {
list.add(privilege);
}
}
Privilege[] res = new Privilege[list.size()];
list.toArray(res);
return res;
} | java | private Privilege[] excludePrivilege( Privilege[] privileges,
JcrPermission permission ) {
ArrayList<Privilege> list = new ArrayList<>();
for (Privilege privilege : privileges) {
if (!privilege.getName().equalsIgnoreCase(permission.getName())) {
list.add(privilege);
}
}
Privilege[] res = new Privilege[list.size()];
list.toArray(res);
return res;
} | [
"private",
"Privilege",
"[",
"]",
"excludePrivilege",
"(",
"Privilege",
"[",
"]",
"privileges",
",",
"JcrPermission",
"permission",
")",
"{",
"ArrayList",
"<",
"Privilege",
">",
"list",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"Privilege",
... | Excludes given privilege.
@param privileges
@param permission
@return the privileges | [
"Excludes",
"given",
"privilege",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/server/JcrServiceImpl.java#L869-L882 | train |
ModeShape/modeshape | web/modeshape-web-explorer/src/main/java/org/modeshape/web/server/JcrServiceImpl.java | JcrServiceImpl.includePrivilege | private Privilege[] includePrivilege( AccessControlManager acm,
Privilege[] privileges,
JcrPermission permission ) throws RepositoryException {
ArrayList<Privilege> list = new ArrayList<>();
for (Privilege privilege : privileges) {
if (!privilege.getName().equalsIgnoreCase(permission.getName())) {
list.add(privilege);
}
}
list.add(acm.privilegeFromName(permission.getJcrName()));
Privilege[] res = new Privilege[list.size()];
list.toArray(res);
return res;
} | java | private Privilege[] includePrivilege( AccessControlManager acm,
Privilege[] privileges,
JcrPermission permission ) throws RepositoryException {
ArrayList<Privilege> list = new ArrayList<>();
for (Privilege privilege : privileges) {
if (!privilege.getName().equalsIgnoreCase(permission.getName())) {
list.add(privilege);
}
}
list.add(acm.privilegeFromName(permission.getJcrName()));
Privilege[] res = new Privilege[list.size()];
list.toArray(res);
return res;
} | [
"private",
"Privilege",
"[",
"]",
"includePrivilege",
"(",
"AccessControlManager",
"acm",
",",
"Privilege",
"[",
"]",
"privileges",
",",
"JcrPermission",
"permission",
")",
"throws",
"RepositoryException",
"{",
"ArrayList",
"<",
"Privilege",
">",
"list",
"=",
"new... | Includes given privilege.
@param acm the access control manager
@param privileges
@param permission
@return the privileges
@throws RepositoryException | [
"Includes",
"given",
"privilege",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/server/JcrServiceImpl.java#L893-L908 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/value/binary/FileSystemBinaryStore.java | FileSystemBinaryStore.create | public static FileSystemBinaryStore create( File directory, File trash ) {
String key = directory.getAbsolutePath();
FileSystemBinaryStore store = INSTANCES.get(key);
if (store == null) {
store = trash != null ? new FileSystemBinaryStore(directory, trash) : new FileSystemBinaryStore(directory);
FileSystemBinaryStore existing = INSTANCES.putIfAbsent(key, store);
if (existing != null) {
store = existing;
}
}
return store;
} | java | public static FileSystemBinaryStore create( File directory, File trash ) {
String key = directory.getAbsolutePath();
FileSystemBinaryStore store = INSTANCES.get(key);
if (store == null) {
store = trash != null ? new FileSystemBinaryStore(directory, trash) : new FileSystemBinaryStore(directory);
FileSystemBinaryStore existing = INSTANCES.putIfAbsent(key, store);
if (existing != null) {
store = existing;
}
}
return store;
} | [
"public",
"static",
"FileSystemBinaryStore",
"create",
"(",
"File",
"directory",
",",
"File",
"trash",
")",
"{",
"String",
"key",
"=",
"directory",
".",
"getAbsolutePath",
"(",
")",
";",
"FileSystemBinaryStore",
"store",
"=",
"INSTANCES",
".",
"get",
"(",
"key... | Creates a new FS binary store instance
@param directory a {@link File} instance where the binary data will be stored; may not be {@code null}
@param trash a {@link File} instance where unused binary data is transferred to, until completely being removed from disk;
may be {@code null} in which case a default location will be used.
@return a {@link FileSystemBinaryStore} instance | [
"Creates",
"a",
"new",
"FS",
"binary",
"store",
"instance"
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/value/binary/FileSystemBinaryStore.java#L70-L81 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/engine/process/RestartableSequence.java | RestartableSequence.loadRemaining | protected void loadRemaining() {
if (!loadedAll) {
// Put all of the batches from the sequence into the buffer
assert targetNumRowsInMemory >= 0L;
assert batchSize != null;
Batch batch = original.nextBatch();
boolean loadIntoMemory = inMemoryBatches != null && actualNumRowsInMemory < targetNumRowsInMemory;
while (batch != null) {
long rows = loadBatch(batch, loadIntoMemory, null);
if (batchSize.get() == 0L) batchSize.set(rows);
if (loadIntoMemory) {
assert inMemoryBatches != null;
if (actualNumRowsInMemory >= targetNumRowsInMemory) loadIntoMemory = false;
}
batch = original.nextBatch();
}
long numInMemory = inMemoryBatches != null ? actualNumRowsInMemory : 0L;
totalSize = offHeapBatchesSupplier.size() + numInMemory;
loadedAll = true;
restartBatches();
}
} | java | protected void loadRemaining() {
if (!loadedAll) {
// Put all of the batches from the sequence into the buffer
assert targetNumRowsInMemory >= 0L;
assert batchSize != null;
Batch batch = original.nextBatch();
boolean loadIntoMemory = inMemoryBatches != null && actualNumRowsInMemory < targetNumRowsInMemory;
while (batch != null) {
long rows = loadBatch(batch, loadIntoMemory, null);
if (batchSize.get() == 0L) batchSize.set(rows);
if (loadIntoMemory) {
assert inMemoryBatches != null;
if (actualNumRowsInMemory >= targetNumRowsInMemory) loadIntoMemory = false;
}
batch = original.nextBatch();
}
long numInMemory = inMemoryBatches != null ? actualNumRowsInMemory : 0L;
totalSize = offHeapBatchesSupplier.size() + numInMemory;
loadedAll = true;
restartBatches();
}
} | [
"protected",
"void",
"loadRemaining",
"(",
")",
"{",
"if",
"(",
"!",
"loadedAll",
")",
"{",
"// Put all of the batches from the sequence into the buffer",
"assert",
"targetNumRowsInMemory",
">=",
"0L",
";",
"assert",
"batchSize",
"!=",
"null",
";",
"Batch",
"batch",
... | Load all of the remaining rows from the supplied sequence into the buffer. | [
"Load",
"all",
"of",
"the",
"remaining",
"rows",
"from",
"the",
"supplied",
"sequence",
"into",
"the",
"buffer",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/engine/process/RestartableSequence.java#L180-L201 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/value/binary/CompositeBinaryStore.java | CompositeBinaryStore.moveValue | public BinaryKey moveValue( BinaryKey key,
String source,
String destination ) throws BinaryStoreException {
final BinaryStore sourceStore;
if (source == null) {
sourceStore = findBinaryStoreContainingKey(key);
} else {
sourceStore = selectBinaryStore(source);
}
// could not find source store, or
if (sourceStore == null || !sourceStore.hasBinary(key)) {
throw new BinaryStoreException(JcrI18n.unableToFindBinaryValue.text(key, sourceStore));
}
BinaryStore destinationStore = selectBinaryStore(destination);
// key is already in the destination store
if (sourceStore.equals(destinationStore)) {
return key;
}
final BinaryValue binaryValue = storeValue(sourceStore.getInputStream(key), destination, false);
sourceStore.markAsUnused(java.util.Collections.singleton(key));
return binaryValue.getKey();
} | java | public BinaryKey moveValue( BinaryKey key,
String source,
String destination ) throws BinaryStoreException {
final BinaryStore sourceStore;
if (source == null) {
sourceStore = findBinaryStoreContainingKey(key);
} else {
sourceStore = selectBinaryStore(source);
}
// could not find source store, or
if (sourceStore == null || !sourceStore.hasBinary(key)) {
throw new BinaryStoreException(JcrI18n.unableToFindBinaryValue.text(key, sourceStore));
}
BinaryStore destinationStore = selectBinaryStore(destination);
// key is already in the destination store
if (sourceStore.equals(destinationStore)) {
return key;
}
final BinaryValue binaryValue = storeValue(sourceStore.getInputStream(key), destination, false);
sourceStore.markAsUnused(java.util.Collections.singleton(key));
return binaryValue.getKey();
} | [
"public",
"BinaryKey",
"moveValue",
"(",
"BinaryKey",
"key",
",",
"String",
"source",
",",
"String",
"destination",
")",
"throws",
"BinaryStoreException",
"{",
"final",
"BinaryStore",
"sourceStore",
";",
"if",
"(",
"source",
"==",
"null",
")",
"{",
"sourceStore"... | Move a value from one named store to another store
@param key Binary key to transfer from the source store to the destination store
@param source a hint for discovering the source repository; may be null
@param destination a hint for discovering the destination repository
@return the {@link BinaryKey} value of the moved binary, never {@code null}
@throws BinaryStoreException if a source store cannot be found or the source store does not contain the binary key | [
"Move",
"a",
"value",
"from",
"one",
"named",
"store",
"to",
"another",
"store"
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/value/binary/CompositeBinaryStore.java#L165-L192 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/value/binary/CompositeBinaryStore.java | CompositeBinaryStore.moveValue | public void moveValue( BinaryKey key,
String destination ) throws BinaryStoreException {
moveValue(key, null, destination);
} | java | public void moveValue( BinaryKey key,
String destination ) throws BinaryStoreException {
moveValue(key, null, destination);
} | [
"public",
"void",
"moveValue",
"(",
"BinaryKey",
"key",
",",
"String",
"destination",
")",
"throws",
"BinaryStoreException",
"{",
"moveValue",
"(",
"key",
",",
"null",
",",
"destination",
")",
";",
"}"
] | Move a BinaryKey to a named store
@param key Binary key to transfer from the source store to the destination store
@param destination a hint for discovering the destination repository
@throws BinaryStoreException if anything unexpected fails | [
"Move",
"a",
"BinaryKey",
"to",
"a",
"named",
"store"
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/value/binary/CompositeBinaryStore.java#L201-L204 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/value/binary/CompositeBinaryStore.java | CompositeBinaryStore.findBinaryStoreContainingKey | public BinaryStore findBinaryStoreContainingKey( BinaryKey key ) {
Iterator<Map.Entry<String, BinaryStore>> binaryStoreIterator = getNamedStoreIterator();
while (binaryStoreIterator.hasNext()) {
BinaryStore bs = binaryStoreIterator.next().getValue();
if (bs.hasBinary(key)) {
return bs;
}
}
return null;
} | java | public BinaryStore findBinaryStoreContainingKey( BinaryKey key ) {
Iterator<Map.Entry<String, BinaryStore>> binaryStoreIterator = getNamedStoreIterator();
while (binaryStoreIterator.hasNext()) {
BinaryStore bs = binaryStoreIterator.next().getValue();
if (bs.hasBinary(key)) {
return bs;
}
}
return null;
} | [
"public",
"BinaryStore",
"findBinaryStoreContainingKey",
"(",
"BinaryKey",
"key",
")",
"{",
"Iterator",
"<",
"Map",
".",
"Entry",
"<",
"String",
",",
"BinaryStore",
">",
">",
"binaryStoreIterator",
"=",
"getNamedStoreIterator",
"(",
")",
";",
"while",
"(",
"bina... | Get the named binary store that contains the key
@param key the key to the binary content; never null
@return the BinaryStore that contains the given key | [
"Get",
"the",
"named",
"binary",
"store",
"that",
"contains",
"the",
"key"
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/value/binary/CompositeBinaryStore.java#L398-L409 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/value/binary/CompositeBinaryStore.java | CompositeBinaryStore.selectBinaryStore | private BinaryStore selectBinaryStore( String hint ) {
BinaryStore namedBinaryStore = null;
if (hint != null) {
logger.trace("Selecting named binary store for hint: " + hint);
namedBinaryStore = namedStores.get(hint);
}
if (namedBinaryStore == null) {
namedBinaryStore = getDefaultBinaryStore();
}
logger.trace("Selected binary store: " + namedBinaryStore.toString());
return namedBinaryStore;
} | java | private BinaryStore selectBinaryStore( String hint ) {
BinaryStore namedBinaryStore = null;
if (hint != null) {
logger.trace("Selecting named binary store for hint: " + hint);
namedBinaryStore = namedStores.get(hint);
}
if (namedBinaryStore == null) {
namedBinaryStore = getDefaultBinaryStore();
}
logger.trace("Selected binary store: " + namedBinaryStore.toString());
return namedBinaryStore;
} | [
"private",
"BinaryStore",
"selectBinaryStore",
"(",
"String",
"hint",
")",
"{",
"BinaryStore",
"namedBinaryStore",
"=",
"null",
";",
"if",
"(",
"hint",
"!=",
"null",
")",
"{",
"logger",
".",
"trace",
"(",
"\"Selecting named binary store for hint: \"",
"+",
"hint",... | Select a named binary store for the given hint
@param hint a hint to a binary store; possibly null
@return a named BinaryStore from the hint, or the default store | [
"Select",
"a",
"named",
"binary",
"store",
"for",
"the",
"given",
"hint"
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/value/binary/CompositeBinaryStore.java#L417-L433 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/ModeShapeEngine.java | ModeShapeEngine.start | public void start() {
if (state == State.RUNNING) return;
final Lock lock = this.lock.writeLock();
try {
lock.lock();
this.state = State.STARTING;
// Create an executor service that we'll use to start the repositories ...
ThreadFactory threadFactory = new NamedThreadFactory("modeshape-start-repo");
repositoryStarterService = Executors.newCachedThreadPool(threadFactory);
state = State.RUNNING;
} catch (RuntimeException e) {
state = State.NOT_RUNNING;
throw e;
} finally {
lock.unlock();
}
} | java | public void start() {
if (state == State.RUNNING) return;
final Lock lock = this.lock.writeLock();
try {
lock.lock();
this.state = State.STARTING;
// Create an executor service that we'll use to start the repositories ...
ThreadFactory threadFactory = new NamedThreadFactory("modeshape-start-repo");
repositoryStarterService = Executors.newCachedThreadPool(threadFactory);
state = State.RUNNING;
} catch (RuntimeException e) {
state = State.NOT_RUNNING;
throw e;
} finally {
lock.unlock();
}
} | [
"public",
"void",
"start",
"(",
")",
"{",
"if",
"(",
"state",
"==",
"State",
".",
"RUNNING",
")",
"return",
";",
"final",
"Lock",
"lock",
"=",
"this",
".",
"lock",
".",
"writeLock",
"(",
")",
";",
"try",
"{",
"lock",
".",
"lock",
"(",
")",
";",
... | Start this engine to make it available for use. This method does nothing if the engine is already running.
@see #shutdown() | [
"Start",
"this",
"engine",
"to",
"make",
"it",
"available",
"for",
"use",
".",
"This",
"method",
"does",
"nothing",
"if",
"the",
"engine",
"is",
"already",
"running",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/ModeShapeEngine.java#L92-L110 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/ModeShapeEngine.java | ModeShapeEngine.shutdown | public Future<Boolean> shutdown( boolean forceShutdownOfAllRepositories ) {
if (!forceShutdownOfAllRepositories) {
// Check to see if there are any still running ...
final Lock lock = this.lock.readLock();
try {
lock.lock();
for (JcrRepository repository : repositories.values()) {
switch (repository.getState()) {
case NOT_RUNNING:
case STOPPING:
break;
case RESTORING:
case RUNNING:
case STARTING:
// This repository is still running, so fail
return ImmediateFuture.create(Boolean.FALSE);
}
}
// If we got to here, there are no more running repositories ...
} finally {
lock.unlock();
}
}
// Create a simple executor that will do the backgrounding for us ...
final ExecutorService executor = Executors.newSingleThreadExecutor();
try {
// Submit a runnable to shutdown the repositories ...
return executor.submit(this::doShutdown);
} finally {
// Now shutdown the executor and return the future ...
executor.shutdown();
}
} | java | public Future<Boolean> shutdown( boolean forceShutdownOfAllRepositories ) {
if (!forceShutdownOfAllRepositories) {
// Check to see if there are any still running ...
final Lock lock = this.lock.readLock();
try {
lock.lock();
for (JcrRepository repository : repositories.values()) {
switch (repository.getState()) {
case NOT_RUNNING:
case STOPPING:
break;
case RESTORING:
case RUNNING:
case STARTING:
// This repository is still running, so fail
return ImmediateFuture.create(Boolean.FALSE);
}
}
// If we got to here, there are no more running repositories ...
} finally {
lock.unlock();
}
}
// Create a simple executor that will do the backgrounding for us ...
final ExecutorService executor = Executors.newSingleThreadExecutor();
try {
// Submit a runnable to shutdown the repositories ...
return executor.submit(this::doShutdown);
} finally {
// Now shutdown the executor and return the future ...
executor.shutdown();
}
} | [
"public",
"Future",
"<",
"Boolean",
">",
"shutdown",
"(",
"boolean",
"forceShutdownOfAllRepositories",
")",
"{",
"if",
"(",
"!",
"forceShutdownOfAllRepositories",
")",
"{",
"// Check to see if there are any still running ...",
"final",
"Lock",
"lock",
"=",
"this",
".",
... | Shutdown this engine, optionally stopping all still-running repositories.
@param forceShutdownOfAllRepositories true if the engine should be shutdown even if there are currently-running
repositories, or false if the engine should not be shutdown if at least one repository is still running.
@return a future that allows the caller to block until the engine is shutdown; any error during shutdown will be thrown
when {@link Future#get() getting} the repository from the future, where the exception is wrapped in a
{@link ExecutionException}. The value returned from the future will always be true if the engine shutdown (or was
not running), or false if the engine is still running.
@see #start() | [
"Shutdown",
"this",
"engine",
"optionally",
"stopping",
"all",
"still",
"-",
"running",
"repositories",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/ModeShapeEngine.java#L140-L173 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/ModeShapeEngine.java | ModeShapeEngine.doShutdown | protected boolean doShutdown() {
if (state == State.NOT_RUNNING) {
LOGGER.debug("Engine already shut down.");
return true;
}
LOGGER.debug("Shutting down engine...");
final Lock lock = this.lock.writeLock();
try {
lock.lock();
state = State.STOPPING;
if (!repositories.isEmpty()) {
// Now go through all of the repositories and request they all be shutdown ...
Queue<Future<Boolean>> repoFutures = new LinkedList<Future<Boolean>>();
Queue<String> repoNames = new LinkedList<String>();
for (JcrRepository repository : repositories.values()) {
if (repository != null) {
repoNames.add(repository.getName());
repoFutures.add(repository.shutdown());
}
}
// Now block while each is shutdown ...
while (repoFutures.peek() != null) {
String repoName = repoNames.poll();
try {
// Get the results from the future (this will return only when the shutdown has completed) ...
repoFutures.poll().get();
// We've successfully shut down, so remove it from the map ...
repositories.remove(repoName);
} catch (ExecutionException | InterruptedException e) {
Logger.getLogger(getClass()).error(e, JcrI18n.failedToShutdownDeployedRepository, repoName);
}
}
}
if (repositories.isEmpty()) {
// All repositories were properly shutdown, so now stop the service for starting and shutting down the repos ...
repositoryStarterService.shutdown();
repositoryStarterService = null;
// Do not clear the set of repositories, so that restarting will work just fine ...
this.state = State.NOT_RUNNING;
} else {
// Could not shut down all repositories, so keep running ..
this.state = State.RUNNING;
}
} catch (RuntimeException e) {
this.state = State.RUNNING;
throw e;
} finally {
lock.unlock();
}
return this.state != State.RUNNING;
} | java | protected boolean doShutdown() {
if (state == State.NOT_RUNNING) {
LOGGER.debug("Engine already shut down.");
return true;
}
LOGGER.debug("Shutting down engine...");
final Lock lock = this.lock.writeLock();
try {
lock.lock();
state = State.STOPPING;
if (!repositories.isEmpty()) {
// Now go through all of the repositories and request they all be shutdown ...
Queue<Future<Boolean>> repoFutures = new LinkedList<Future<Boolean>>();
Queue<String> repoNames = new LinkedList<String>();
for (JcrRepository repository : repositories.values()) {
if (repository != null) {
repoNames.add(repository.getName());
repoFutures.add(repository.shutdown());
}
}
// Now block while each is shutdown ...
while (repoFutures.peek() != null) {
String repoName = repoNames.poll();
try {
// Get the results from the future (this will return only when the shutdown has completed) ...
repoFutures.poll().get();
// We've successfully shut down, so remove it from the map ...
repositories.remove(repoName);
} catch (ExecutionException | InterruptedException e) {
Logger.getLogger(getClass()).error(e, JcrI18n.failedToShutdownDeployedRepository, repoName);
}
}
}
if (repositories.isEmpty()) {
// All repositories were properly shutdown, so now stop the service for starting and shutting down the repos ...
repositoryStarterService.shutdown();
repositoryStarterService = null;
// Do not clear the set of repositories, so that restarting will work just fine ...
this.state = State.NOT_RUNNING;
} else {
// Could not shut down all repositories, so keep running ..
this.state = State.RUNNING;
}
} catch (RuntimeException e) {
this.state = State.RUNNING;
throw e;
} finally {
lock.unlock();
}
return this.state != State.RUNNING;
} | [
"protected",
"boolean",
"doShutdown",
"(",
")",
"{",
"if",
"(",
"state",
"==",
"State",
".",
"NOT_RUNNING",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Engine already shut down.\"",
")",
";",
"return",
"true",
";",
"}",
"LOGGER",
".",
"debug",
"(",
"\"Shutti... | Do the work of shutting down this engine and its repositories.
@return true if the engine was shutdown (or was not running), and false if the engine is still running and could not be
shutdown | [
"Do",
"the",
"work",
"of",
"shutting",
"down",
"this",
"engine",
"and",
"its",
"repositories",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/ModeShapeEngine.java#L181-L236 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/ModeShapeEngine.java | ModeShapeEngine.getRepositories | public Map<String, State> getRepositories() {
checkRunning();
Map<String, State> results = new HashMap<String, State>();
final Lock lock = this.lock.readLock();
try {
lock.lock();
for (JcrRepository repository : repositories.values()) {
results.put(repository.getName(), repository.getState());
}
} finally {
lock.unlock();
}
return Collections.unmodifiableMap(results);
} | java | public Map<String, State> getRepositories() {
checkRunning();
Map<String, State> results = new HashMap<String, State>();
final Lock lock = this.lock.readLock();
try {
lock.lock();
for (JcrRepository repository : repositories.values()) {
results.put(repository.getName(), repository.getState());
}
} finally {
lock.unlock();
}
return Collections.unmodifiableMap(results);
} | [
"public",
"Map",
"<",
"String",
",",
"State",
">",
"getRepositories",
"(",
")",
"{",
"checkRunning",
"(",
")",
";",
"Map",
"<",
"String",
",",
"State",
">",
"results",
"=",
"new",
"HashMap",
"<",
"String",
",",
"State",
">",
"(",
")",
";",
"final",
... | Get an instantaneous snapshot of the JCR repositories and their state. Note that the results are accurate only when this
methods returns.
@return the immutable map of repository states keyed by repository names; never null | [
"Get",
"an",
"instantaneous",
"snapshot",
"of",
"the",
"JCR",
"repositories",
"and",
"their",
"state",
".",
"Note",
"that",
"the",
"results",
"are",
"accurate",
"only",
"when",
"this",
"methods",
"returns",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/ModeShapeEngine.java#L391-L404 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/ModeShapeEngine.java | ModeShapeEngine.repositories | protected Collection<JcrRepository> repositories() {
if (this.state == State.RUNNING) {
final Lock lock = this.lock.readLock();
try {
lock.lock();
return new ArrayList<JcrRepository>(repositories.values());
} finally {
lock.unlock();
}
}
return Collections.emptyList();
} | java | protected Collection<JcrRepository> repositories() {
if (this.state == State.RUNNING) {
final Lock lock = this.lock.readLock();
try {
lock.lock();
return new ArrayList<JcrRepository>(repositories.values());
} finally {
lock.unlock();
}
}
return Collections.emptyList();
} | [
"protected",
"Collection",
"<",
"JcrRepository",
">",
"repositories",
"(",
")",
"{",
"if",
"(",
"this",
".",
"state",
"==",
"State",
".",
"RUNNING",
")",
"{",
"final",
"Lock",
"lock",
"=",
"this",
".",
"lock",
".",
"readLock",
"(",
")",
";",
"try",
"... | Returns a copy of the repositories. Note that when returned, not all repositories may be active.
@return a copy of the repositories; never null | [
"Returns",
"a",
"copy",
"of",
"the",
"repositories",
".",
"Note",
"that",
"when",
"returned",
"not",
"all",
"repositories",
"may",
"be",
"active",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/ModeShapeEngine.java#L411-L422 | train |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/ModeShapeEngine.java | ModeShapeEngine.deploy | protected JcrRepository deploy( final RepositoryConfiguration repositoryConfiguration,
final String repositoryKey ) throws ConfigurationException, RepositoryException {
CheckArg.isNotNull(repositoryConfiguration, "repositoryConfiguration");
checkRunning();
final String repoName = repositoryKey != null ? repositoryKey : repositoryConfiguration.getName();
Problems problems = repositoryConfiguration.validate();
if (problems.hasErrors()) {
throw new ConfigurationException(problems, JcrI18n.repositoryConfigurationIsNotValid.text(repoName,
problems.toString()));
}
// Now try to deploy the repository ...
JcrRepository repository = null;
final Lock lock = this.lock.writeLock();
try {
lock.lock();
if (this.repositories.containsKey(repoName)) {
throw new RepositoryException(JcrI18n.repositoryIsAlreadyDeployed.text(repoName));
}
// Instantiate (but do not start!) the repository, store it in our map, and return it ...
repository = new JcrRepository(repositoryConfiguration);
this.repositories.put(repoName, repository);
} finally {
lock.unlock();
}
return repository;
} | java | protected JcrRepository deploy( final RepositoryConfiguration repositoryConfiguration,
final String repositoryKey ) throws ConfigurationException, RepositoryException {
CheckArg.isNotNull(repositoryConfiguration, "repositoryConfiguration");
checkRunning();
final String repoName = repositoryKey != null ? repositoryKey : repositoryConfiguration.getName();
Problems problems = repositoryConfiguration.validate();
if (problems.hasErrors()) {
throw new ConfigurationException(problems, JcrI18n.repositoryConfigurationIsNotValid.text(repoName,
problems.toString()));
}
// Now try to deploy the repository ...
JcrRepository repository = null;
final Lock lock = this.lock.writeLock();
try {
lock.lock();
if (this.repositories.containsKey(repoName)) {
throw new RepositoryException(JcrI18n.repositoryIsAlreadyDeployed.text(repoName));
}
// Instantiate (but do not start!) the repository, store it in our map, and return it ...
repository = new JcrRepository(repositoryConfiguration);
this.repositories.put(repoName, repository);
} finally {
lock.unlock();
}
return repository;
} | [
"protected",
"JcrRepository",
"deploy",
"(",
"final",
"RepositoryConfiguration",
"repositoryConfiguration",
",",
"final",
"String",
"repositoryKey",
")",
"throws",
"ConfigurationException",
",",
"RepositoryException",
"{",
"CheckArg",
".",
"isNotNull",
"(",
"repositoryConfi... | Deploy a new repository with the given configuration. This method will fail if this engine already contains a repository
with the specified name.
@param repositoryConfiguration the configuration for the repository
@param repositoryKey the key by which this repository is known to this engine; may be null if the
{@link RepositoryConfiguration#getName() repository's name} should be used
@return the deployed repository instance, which must be {@link #startRepository(String) started} before it can be used;
never null
@throws ConfigurationException if the configuration is not valid
@throws RepositoryException if there is already a deployed repository with the specified name, or if there is a problem
deploying the repository
@throws IllegalArgumentException if the configuration is null
@see #deploy(RepositoryConfiguration)
@see #update(String, Changes)
@see #undeploy(String) | [
"Deploy",
"a",
"new",
"repository",
"with",
"the",
"given",
"configuration",
".",
"This",
"method",
"will",
"fail",
"if",
"this",
"engine",
"already",
"contains",
"a",
"repository",
"with",
"the",
"specified",
"name",
"."
] | 794cfdabb67a90f24629c4fff0424a6125f8f95b | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/ModeShapeEngine.java#L461-L489 | train |
networknt/light-rest-4j | openapi-validator/src/main/java/com/networknt/openapi/RequestValidator.java | RequestValidator.validateRequest | public Status validateRequest(final NormalisedPath requestPath, HttpServerExchange exchange, OpenApiOperation openApiOperation) {
requireNonNull(requestPath, "A request path is required");
requireNonNull(exchange, "An exchange is required");
requireNonNull(openApiOperation, "An OpenAPI operation is required");
Status status = validatePathParameters(requestPath, openApiOperation);
if(status != null) return status;
status = validateQueryParameters(exchange, openApiOperation);
if(status != null) return status;
status = validateHeader(exchange, openApiOperation);
if(status != null) return status;
Object body = exchange.getAttachment(BodyHandler.REQUEST_BODY);
// skip the body validation if body parser is not in the request chain.
if(body == null && ValidatorHandler.config.skipBodyValidation) return null;
status = validateRequestBody(body, openApiOperation);
return status;
} | java | public Status validateRequest(final NormalisedPath requestPath, HttpServerExchange exchange, OpenApiOperation openApiOperation) {
requireNonNull(requestPath, "A request path is required");
requireNonNull(exchange, "An exchange is required");
requireNonNull(openApiOperation, "An OpenAPI operation is required");
Status status = validatePathParameters(requestPath, openApiOperation);
if(status != null) return status;
status = validateQueryParameters(exchange, openApiOperation);
if(status != null) return status;
status = validateHeader(exchange, openApiOperation);
if(status != null) return status;
Object body = exchange.getAttachment(BodyHandler.REQUEST_BODY);
// skip the body validation if body parser is not in the request chain.
if(body == null && ValidatorHandler.config.skipBodyValidation) return null;
status = validateRequestBody(body, openApiOperation);
return status;
} | [
"public",
"Status",
"validateRequest",
"(",
"final",
"NormalisedPath",
"requestPath",
",",
"HttpServerExchange",
"exchange",
",",
"OpenApiOperation",
"openApiOperation",
")",
"{",
"requireNonNull",
"(",
"requestPath",
",",
"\"A request path is required\"",
")",
";",
"requ... | Validate the request against the given API operation
@param requestPath normalised path
@param exchange The HttpServerExchange to validate
@param openApiOperation OpenAPI operation
@return A validation report containing validation errors | [
"Validate",
"the",
"request",
"against",
"the",
"given",
"API",
"operation"
] | 06b15128e6101351e617284a636ef5d632e6b1fe | https://github.com/networknt/light-rest-4j/blob/06b15128e6101351e617284a636ef5d632e6b1fe/openapi-validator/src/main/java/com/networknt/openapi/RequestValidator.java#L70-L90 | train |
networknt/light-rest-4j | swagger-validator/src/main/java/com/networknt/validator/ResponseValidator.java | ResponseValidator.validateResponse | public Status validateResponse(final HttpServerExchange exchange, final SwaggerOperation swaggerOperation) {
requireNonNull(exchange, "An exchange is required");
requireNonNull(swaggerOperation, "A swagger operation is required");
io.swagger.models.Response swaggerResponse = swaggerOperation.getOperation().getResponses().get(Integer.toString(exchange.getStatusCode()));
if (swaggerResponse == null) {
swaggerResponse = swaggerOperation.getOperation().getResponses().get("default"); // try the default response
}
if (swaggerResponse == null) {
return new Status("ERR11015", exchange.getStatusCode(), swaggerOperation.getPathString().original());
}
if (swaggerResponse.getSchema() == null) {
return null;
}
String body = exchange.getOutputStream().toString();
if (body == null || body.length() == 0) {
return new Status("ERR11016", swaggerOperation.getMethod(), swaggerOperation.getPathString().original());
}
return schemaValidator.validate(body, swaggerResponse.getSchema());
} | java | public Status validateResponse(final HttpServerExchange exchange, final SwaggerOperation swaggerOperation) {
requireNonNull(exchange, "An exchange is required");
requireNonNull(swaggerOperation, "A swagger operation is required");
io.swagger.models.Response swaggerResponse = swaggerOperation.getOperation().getResponses().get(Integer.toString(exchange.getStatusCode()));
if (swaggerResponse == null) {
swaggerResponse = swaggerOperation.getOperation().getResponses().get("default"); // try the default response
}
if (swaggerResponse == null) {
return new Status("ERR11015", exchange.getStatusCode(), swaggerOperation.getPathString().original());
}
if (swaggerResponse.getSchema() == null) {
return null;
}
String body = exchange.getOutputStream().toString();
if (body == null || body.length() == 0) {
return new Status("ERR11016", swaggerOperation.getMethod(), swaggerOperation.getPathString().original());
}
return schemaValidator.validate(body, swaggerResponse.getSchema());
} | [
"public",
"Status",
"validateResponse",
"(",
"final",
"HttpServerExchange",
"exchange",
",",
"final",
"SwaggerOperation",
"swaggerOperation",
")",
"{",
"requireNonNull",
"(",
"exchange",
",",
"\"An exchange is required\"",
")",
";",
"requireNonNull",
"(",
"swaggerOperatio... | Validate the given response against the API operation.
@param exchange The exchange to validate
@param swaggerOperation The API operation to validate the response against
@return A status containing validation error | [
"Validate",
"the",
"given",
"response",
"against",
"the",
"API",
"operation",
"."
] | 06b15128e6101351e617284a636ef5d632e6b1fe | https://github.com/networknt/light-rest-4j/blob/06b15128e6101351e617284a636ef5d632e6b1fe/swagger-validator/src/main/java/com/networknt/validator/ResponseValidator.java#L50-L72 | train |
networknt/light-rest-4j | swagger-validator/src/main/java/com/networknt/validator/SchemaValidator.java | SchemaValidator.validate | public Status validate(final Object value, final Property schema) {
return doValidate(value, schema, null);
} | java | public Status validate(final Object value, final Property schema) {
return doValidate(value, schema, null);
} | [
"public",
"Status",
"validate",
"(",
"final",
"Object",
"value",
",",
"final",
"Property",
"schema",
")",
"{",
"return",
"doValidate",
"(",
"value",
",",
"schema",
",",
"null",
")",
";",
"}"
] | Validate the given value against the given property schema.
@param value The value to validate
@param schema The property schema to validate the value against
@return A status containing error code and description | [
"Validate",
"the",
"given",
"value",
"against",
"the",
"given",
"property",
"schema",
"."
] | 06b15128e6101351e617284a636ef5d632e6b1fe | https://github.com/networknt/light-rest-4j/blob/06b15128e6101351e617284a636ef5d632e6b1fe/swagger-validator/src/main/java/com/networknt/validator/SchemaValidator.java#L81-L83 | train |
networknt/light-rest-4j | swagger-validator/src/main/java/com/networknt/validator/SchemaValidator.java | SchemaValidator.validate | public Status validate(final Object value, final Model schema, SchemaValidatorsConfig config) {
return doValidate(value, schema, config);
} | java | public Status validate(final Object value, final Model schema, SchemaValidatorsConfig config) {
return doValidate(value, schema, config);
} | [
"public",
"Status",
"validate",
"(",
"final",
"Object",
"value",
",",
"final",
"Model",
"schema",
",",
"SchemaValidatorsConfig",
"config",
")",
"{",
"return",
"doValidate",
"(",
"value",
",",
"schema",
",",
"config",
")",
";",
"}"
] | Validate the given value against the given model schema.
@param value The value to validate
@param schema The model schema to validate the value against
@param config The config model for some validator
@return A status containing error code and description | [
"Validate",
"the",
"given",
"value",
"against",
"the",
"given",
"model",
"schema",
"."
] | 06b15128e6101351e617284a636ef5d632e6b1fe | https://github.com/networknt/light-rest-4j/blob/06b15128e6101351e617284a636ef5d632e6b1fe/swagger-validator/src/main/java/com/networknt/validator/SchemaValidator.java#L94-L96 | train |
networknt/light-rest-4j | openapi-validator/src/main/java/com/networknt/openapi/ResponseValidator.java | ResponseValidator.validateResponseContent | public Status validateResponseContent(Object responseContent, OpenApiOperation openApiOperation, String statusCode, String mediaTypeName) {
//try to convert json string to structured object
if(responseContent instanceof String) {
responseContent = convertStrToObjTree((String)responseContent);
}
JsonNode schema = getContentSchema(openApiOperation, statusCode, mediaTypeName);
//if cannot find schema based on status code, try to get from "default"
if(schema == null || schema.isMissingNode()) {
// if corresponding response exist but also does not contain any schema, pass validation
if (openApiOperation.getOperation().getResponses().containsKey(String.valueOf(statusCode))) {
return null;
}
schema = getContentSchema(openApiOperation, DEFAULT_STATUS_CODE, mediaTypeName);
// if default also does not contain any schema, pass validation
if (schema == null || schema.isMissingNode()) return null;
}
if ((responseContent != null && schema == null) ||
(responseContent == null && schema != null)) {
return new Status(VALIDATOR_RESPONSE_CONTENT_UNEXPECTED, openApiOperation.getMethod(), openApiOperation.getPathString().original());
}
config.setTypeLoose(false);
return schemaValidator.validate(responseContent, schema, config);
} | java | public Status validateResponseContent(Object responseContent, OpenApiOperation openApiOperation, String statusCode, String mediaTypeName) {
//try to convert json string to structured object
if(responseContent instanceof String) {
responseContent = convertStrToObjTree((String)responseContent);
}
JsonNode schema = getContentSchema(openApiOperation, statusCode, mediaTypeName);
//if cannot find schema based on status code, try to get from "default"
if(schema == null || schema.isMissingNode()) {
// if corresponding response exist but also does not contain any schema, pass validation
if (openApiOperation.getOperation().getResponses().containsKey(String.valueOf(statusCode))) {
return null;
}
schema = getContentSchema(openApiOperation, DEFAULT_STATUS_CODE, mediaTypeName);
// if default also does not contain any schema, pass validation
if (schema == null || schema.isMissingNode()) return null;
}
if ((responseContent != null && schema == null) ||
(responseContent == null && schema != null)) {
return new Status(VALIDATOR_RESPONSE_CONTENT_UNEXPECTED, openApiOperation.getMethod(), openApiOperation.getPathString().original());
}
config.setTypeLoose(false);
return schemaValidator.validate(responseContent, schema, config);
} | [
"public",
"Status",
"validateResponseContent",
"(",
"Object",
"responseContent",
",",
"OpenApiOperation",
"openApiOperation",
",",
"String",
"statusCode",
",",
"String",
"mediaTypeName",
")",
"{",
"//try to convert json string to structured object",
"if",
"(",
"responseConten... | validate a given response content object
@param responseContent response content needs to be validated
@param openApiOperation OpenApi Operation which is located by uri and httpMethod
@param statusCode eg. 200, 400
@param mediaTypeName eg. "application/json"
@return Status | [
"validate",
"a",
"given",
"response",
"content",
"object"
] | 06b15128e6101351e617284a636ef5d632e6b1fe | https://github.com/networknt/light-rest-4j/blob/06b15128e6101351e617284a636ef5d632e6b1fe/openapi-validator/src/main/java/com/networknt/openapi/ResponseValidator.java#L116-L138 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.