id
int32
0
165k
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
142,100
massfords/jaxb-visitor
src/main/java/com/massfords/jaxb/VisitorPlugin.java
VisitorPlugin.sortClasses
private Set<ClassOutline> sortClasses(Outline outline) { Set<ClassOutline> sorted = new TreeSet<>((aOne, aTwo) -> { String one = aOne.implClass.fullName(); String two = aTwo.implClass.fullName(); return one.compareTo(two); }); sorted.addAll(outline.getClasses()); return sorted; }
java
private Set<ClassOutline> sortClasses(Outline outline) { Set<ClassOutline> sorted = new TreeSet<>((aOne, aTwo) -> { String one = aOne.implClass.fullName(); String two = aTwo.implClass.fullName(); return one.compareTo(two); }); sorted.addAll(outline.getClasses()); return sorted; }
[ "private", "Set", "<", "ClassOutline", ">", "sortClasses", "(", "Outline", "outline", ")", "{", "Set", "<", "ClassOutline", ">", "sorted", "=", "new", "TreeSet", "<>", "(", "(", "aOne", ",", "aTwo", ")", "->", "{", "String", "one", "=", "aOne", ".", "implClass", ".", "fullName", "(", ")", ";", "String", "two", "=", "aTwo", ".", "implClass", ".", "fullName", "(", ")", ";", "return", "one", ".", "compareTo", "(", "two", ")", ";", "}", ")", ";", "sorted", ".", "addAll", "(", "outline", ".", "getClasses", "(", ")", ")", ";", "return", "sorted", ";", "}" ]
The classes are sorted for test purposes only. This gives us a predictable order for our assertions on the generated code. @param outline
[ "The", "classes", "are", "sorted", "for", "test", "purposes", "only", ".", "This", "gives", "us", "a", "predictable", "order", "for", "our", "assertions", "on", "the", "generated", "code", "." ]
0d66cd4d8b6700b5eb67c028a87b53792be895b8
https://github.com/massfords/jaxb-visitor/blob/0d66cd4d8b6700b5eb67c028a87b53792be895b8/src/main/java/com/massfords/jaxb/VisitorPlugin.java#L191-L199
142,101
beangle/beangle3
orm/hibernate/src/main/java/org/beangle/orm/hibernate/tool/HbmGenerator.java
HbmGenerator.findAnnotation
private <T extends Annotation> T findAnnotation(Class<?> cls, Class<T> annotationClass, String name) { Class<?> curr = cls; T ann = null; while (ann == null && curr != null && !curr.equals(Object.class)) { ann = findAnnotationLocal(curr, annotationClass, name); curr = curr.getSuperclass(); } return ann; }
java
private <T extends Annotation> T findAnnotation(Class<?> cls, Class<T> annotationClass, String name) { Class<?> curr = cls; T ann = null; while (ann == null && curr != null && !curr.equals(Object.class)) { ann = findAnnotationLocal(curr, annotationClass, name); curr = curr.getSuperclass(); } return ann; }
[ "private", "<", "T", "extends", "Annotation", ">", "T", "findAnnotation", "(", "Class", "<", "?", ">", "cls", ",", "Class", "<", "T", ">", "annotationClass", ",", "String", "name", ")", "{", "Class", "<", "?", ">", "curr", "=", "cls", ";", "T", "ann", "=", "null", ";", "while", "(", "ann", "==", "null", "&&", "curr", "!=", "null", "&&", "!", "curr", ".", "equals", "(", "Object", ".", "class", ")", ")", "{", "ann", "=", "findAnnotationLocal", "(", "curr", ",", "annotationClass", ",", "name", ")", ";", "curr", "=", "curr", ".", "getSuperclass", "(", ")", ";", "}", "return", "ann", ";", "}" ]
find annotation on specified member @param cls @param annotationClass @param name @return
[ "find", "annotation", "on", "specified", "member" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/orm/hibernate/src/main/java/org/beangle/orm/hibernate/tool/HbmGenerator.java#L106-L114
142,102
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/collection/MapConverter.java
MapConverter.getShort
public Short getShort(Map<String, Object> data, String name) { return get(data, name, Short.class); }
java
public Short getShort(Map<String, Object> data, String name) { return get(data, name, Short.class); }
[ "public", "Short", "getShort", "(", "Map", "<", "String", ",", "Object", ">", "data", ",", "String", "name", ")", "{", "return", "get", "(", "data", ",", "name", ",", "Short", ".", "class", ")", ";", "}" ]
Get Short.
[ "Get", "Short", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/collection/MapConverter.java#L260-L262
142,103
beangle/beangle3
orm/hibernate/src/main/java/org/beangle/orm/hibernate/dwr/H4BeanConverter.java
H4BeanConverter.findGetter
protected Method findGetter(Object data, String property) throws IntrospectionException { Class<?> clazz = getClass(data); String key = clazz.getName() + ":" + property; Method method = methods.get(key); if (method == null) { Method newMethod = null; PropertyDescriptor[] props = Introspector.getBeanInfo(clazz).getPropertyDescriptors(); for (PropertyDescriptor prop : props) { if (prop.getName().equalsIgnoreCase(property)) { newMethod = prop.getReadMethod(); } } method = methods.putIfAbsent(key, newMethod); if (method == null) { // put succeeded, use new value method = newMethod; } } return method; }
java
protected Method findGetter(Object data, String property) throws IntrospectionException { Class<?> clazz = getClass(data); String key = clazz.getName() + ":" + property; Method method = methods.get(key); if (method == null) { Method newMethod = null; PropertyDescriptor[] props = Introspector.getBeanInfo(clazz).getPropertyDescriptors(); for (PropertyDescriptor prop : props) { if (prop.getName().equalsIgnoreCase(property)) { newMethod = prop.getReadMethod(); } } method = methods.putIfAbsent(key, newMethod); if (method == null) { // put succeeded, use new value method = newMethod; } } return method; }
[ "protected", "Method", "findGetter", "(", "Object", "data", ",", "String", "property", ")", "throws", "IntrospectionException", "{", "Class", "<", "?", ">", "clazz", "=", "getClass", "(", "data", ")", ";", "String", "key", "=", "clazz", ".", "getName", "(", ")", "+", "\":\"", "+", "property", ";", "Method", "method", "=", "methods", ".", "get", "(", "key", ")", ";", "if", "(", "method", "==", "null", ")", "{", "Method", "newMethod", "=", "null", ";", "PropertyDescriptor", "[", "]", "props", "=", "Introspector", ".", "getBeanInfo", "(", "clazz", ")", ".", "getPropertyDescriptors", "(", ")", ";", "for", "(", "PropertyDescriptor", "prop", ":", "props", ")", "{", "if", "(", "prop", ".", "getName", "(", ")", ".", "equalsIgnoreCase", "(", "property", ")", ")", "{", "newMethod", "=", "prop", ".", "getReadMethod", "(", ")", ";", "}", "}", "method", "=", "methods", ".", "putIfAbsent", "(", "key", ",", "newMethod", ")", ";", "if", "(", "method", "==", "null", ")", "{", "// put succeeded, use new value", "method", "=", "newMethod", ";", "}", "}", "return", "method", ";", "}" ]
Cache the method if possible, using the classname and property name to allow for similar named methods. @param data The bean to introspect @param property The property to get the accessor for @return The getter method @throws IntrospectionException If Introspector.getBeanInfo() fails
[ "Cache", "the", "method", "if", "possible", "using", "the", "classname", "and", "property", "name", "to", "allow", "for", "similar", "named", "methods", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/orm/hibernate/src/main/java/org/beangle/orm/hibernate/dwr/H4BeanConverter.java#L168-L187
142,104
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/lang/reflect/ClassInfo.java
ClassInfo.getReadIndex
public final int getReadIndex(String property) { MethodInfo method = propertyReadMethods.get(property); return (null == method) ? -1 : method.index; }
java
public final int getReadIndex(String property) { MethodInfo method = propertyReadMethods.get(property); return (null == method) ? -1 : method.index; }
[ "public", "final", "int", "getReadIndex", "(", "String", "property", ")", "{", "MethodInfo", "method", "=", "propertyReadMethods", ".", "get", "(", "property", ")", ";", "return", "(", "null", "==", "method", ")", "?", "-", "1", ":", "method", ".", "index", ";", "}" ]
Return property read index,return -1 when not found.
[ "Return", "property", "read", "index", "return", "-", "1", "when", "not", "found", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/lang/reflect/ClassInfo.java#L91-L94
142,105
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/lang/reflect/ClassInfo.java
ClassInfo.getPropertyType
public final Class<?> getPropertyType(String property) { MethodInfo info = propertyWriteMethods.get(property); if (null == info) return null; else return info.parameterTypes[0]; }
java
public final Class<?> getPropertyType(String property) { MethodInfo info = propertyWriteMethods.get(property); if (null == info) return null; else return info.parameterTypes[0]; }
[ "public", "final", "Class", "<", "?", ">", "getPropertyType", "(", "String", "property", ")", "{", "MethodInfo", "info", "=", "propertyWriteMethods", ".", "get", "(", "property", ")", ";", "if", "(", "null", "==", "info", ")", "return", "null", ";", "else", "return", "info", ".", "parameterTypes", "[", "0", "]", ";", "}" ]
Return property type,return null when not found.
[ "Return", "property", "type", "return", "null", "when", "not", "found", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/lang/reflect/ClassInfo.java#L106-L110
142,106
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/lang/reflect/ClassInfo.java
ClassInfo.getWriteIndex
public final int getWriteIndex(String property) { MethodInfo method = propertyWriteMethods.get(property); return (null == method) ? -1 : method.index; }
java
public final int getWriteIndex(String property) { MethodInfo method = propertyWriteMethods.get(property); return (null == method) ? -1 : method.index; }
[ "public", "final", "int", "getWriteIndex", "(", "String", "property", ")", "{", "MethodInfo", "method", "=", "propertyWriteMethods", ".", "get", "(", "property", ")", ";", "return", "(", "null", "==", "method", ")", "?", "-", "1", ":", "method", ".", "index", ";", "}" ]
Return property write index,return -1 if not found.
[ "Return", "property", "write", "index", "return", "-", "1", "if", "not", "found", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/lang/reflect/ClassInfo.java#L115-L118
142,107
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/lang/reflect/ClassInfo.java
ClassInfo.getIndex
public final int getIndex(String name, Object... args) { Integer defaultIndex = methodIndexs.get(name); if (null != defaultIndex) return defaultIndex.intValue(); else { final List<MethodInfo> exists = methods.get(name); if (null != exists) { for (MethodInfo info : exists) if (info.matches(args)) return info.index; } return -1; } }
java
public final int getIndex(String name, Object... args) { Integer defaultIndex = methodIndexs.get(name); if (null != defaultIndex) return defaultIndex.intValue(); else { final List<MethodInfo> exists = methods.get(name); if (null != exists) { for (MethodInfo info : exists) if (info.matches(args)) return info.index; } return -1; } }
[ "public", "final", "int", "getIndex", "(", "String", "name", ",", "Object", "...", "args", ")", "{", "Integer", "defaultIndex", "=", "methodIndexs", ".", "get", "(", "name", ")", ";", "if", "(", "null", "!=", "defaultIndex", ")", "return", "defaultIndex", ".", "intValue", "(", ")", ";", "else", "{", "final", "List", "<", "MethodInfo", ">", "exists", "=", "methods", ".", "get", "(", "name", ")", ";", "if", "(", "null", "!=", "exists", ")", "{", "for", "(", "MethodInfo", "info", ":", "exists", ")", "if", "(", "info", ".", "matches", "(", "args", ")", ")", "return", "info", ".", "index", ";", "}", "return", "-", "1", ";", "}", "}" ]
Return method index,return -1 if not found.
[ "Return", "method", "index", "return", "-", "1", "if", "not", "found", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/lang/reflect/ClassInfo.java#L130-L141
142,108
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/lang/reflect/ClassInfo.java
ClassInfo.getMethods
public final List<MethodInfo> getMethods(String name) { List<MethodInfo> namedMethod = methods.get(name); if (null == namedMethod) return Collections.emptyList(); else return namedMethod; }
java
public final List<MethodInfo> getMethods(String name) { List<MethodInfo> namedMethod = methods.get(name); if (null == namedMethod) return Collections.emptyList(); else return namedMethod; }
[ "public", "final", "List", "<", "MethodInfo", ">", "getMethods", "(", "String", "name", ")", "{", "List", "<", "MethodInfo", ">", "namedMethod", "=", "methods", ".", "get", "(", "name", ")", ";", "if", "(", "null", "==", "namedMethod", ")", "return", "Collections", ".", "emptyList", "(", ")", ";", "else", "return", "namedMethod", ";", "}" ]
Return public metheds according to given name
[ "Return", "public", "metheds", "according", "to", "given", "name" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/lang/reflect/ClassInfo.java#L146-L150
142,109
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/lang/reflect/ClassInfo.java
ClassInfo.getMethods
public final List<MethodInfo> getMethods() { List<MethodInfo> methodInfos = CollectUtils.newArrayList(); for (Map.Entry<String, List<MethodInfo>> entry : methods.entrySet()) { for (MethodInfo info : entry.getValue()) methodInfos.add(info); } Collections.sort(methodInfos); return methodInfos; }
java
public final List<MethodInfo> getMethods() { List<MethodInfo> methodInfos = CollectUtils.newArrayList(); for (Map.Entry<String, List<MethodInfo>> entry : methods.entrySet()) { for (MethodInfo info : entry.getValue()) methodInfos.add(info); } Collections.sort(methodInfos); return methodInfos; }
[ "public", "final", "List", "<", "MethodInfo", ">", "getMethods", "(", ")", "{", "List", "<", "MethodInfo", ">", "methodInfos", "=", "CollectUtils", ".", "newArrayList", "(", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "List", "<", "MethodInfo", ">", ">", "entry", ":", "methods", ".", "entrySet", "(", ")", ")", "{", "for", "(", "MethodInfo", "info", ":", "entry", ".", "getValue", "(", ")", ")", "methodInfos", ".", "(", "info", ")", ";", "}", "Collections", ".", "sort", "(", "methodInfos", ")", ";", "return", "methodInfos", ";", "}" ]
Return all public methods.
[ "Return", "all", "public", "methods", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/lang/reflect/ClassInfo.java#L155-L163
142,110
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/lang/Option.java
Option.getAll
public static <T> List<T> getAll(Collection<Option<T>> values) { List<T> results = CollectUtils.newArrayList(values.size()); for (Option<T> op : values) { if (op.isDefined()) results.add(op.get()); } return results; }
java
public static <T> List<T> getAll(Collection<Option<T>> values) { List<T> results = CollectUtils.newArrayList(values.size()); for (Option<T> op : values) { if (op.isDefined()) results.add(op.get()); } return results; }
[ "public", "static", "<", "T", ">", "List", "<", "T", ">", "getAll", "(", "Collection", "<", "Option", "<", "T", ">", ">", "values", ")", "{", "List", "<", "T", ">", "results", "=", "CollectUtils", ".", "newArrayList", "(", "values", ".", "size", "(", ")", ")", ";", "for", "(", "Option", "<", "T", ">", "op", ":", "values", ")", "{", "if", "(", "op", ".", "isDefined", "(", ")", ")", "results", ".", "add", "(", "op", ".", "get", "(", ")", ")", ";", "}", "return", "results", ";", "}" ]
Return all value from Option Collection @param values
[ "Return", "all", "value", "from", "Option", "Collection" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/lang/Option.java#L118-L124
142,111
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/lang/reflect/Reflections.java
Reflections.getBeanSetters
public static List<Method> getBeanSetters(Class<?> clazz) { List<Method> methods = CollectUtils.newArrayList(); for (Method m : clazz.getMethods()) { if (m.getName().startsWith("set") && m.getName().length() > 3) { if (Modifier.isPublic(m.getModifiers()) && !Modifier.isStatic(m.getModifiers()) && m.getParameterTypes().length == 1) { methods.add(m); } } } return methods; }
java
public static List<Method> getBeanSetters(Class<?> clazz) { List<Method> methods = CollectUtils.newArrayList(); for (Method m : clazz.getMethods()) { if (m.getName().startsWith("set") && m.getName().length() > 3) { if (Modifier.isPublic(m.getModifiers()) && !Modifier.isStatic(m.getModifiers()) && m.getParameterTypes().length == 1) { methods.add(m); } } } return methods; }
[ "public", "static", "List", "<", "Method", ">", "getBeanSetters", "(", "Class", "<", "?", ">", "clazz", ")", "{", "List", "<", "Method", ">", "methods", "=", "CollectUtils", ".", "newArrayList", "(", ")", ";", "for", "(", "Method", "m", ":", "clazz", ".", "getMethods", "(", ")", ")", "{", "if", "(", "m", ".", "getName", "(", ")", ".", "startsWith", "(", "\"set\"", ")", "&&", "m", ".", "getName", "(", ")", ".", "length", "(", ")", ">", "3", ")", "{", "if", "(", "Modifier", ".", "isPublic", "(", "m", ".", "getModifiers", "(", ")", ")", "&&", "!", "Modifier", ".", "isStatic", "(", "m", ".", "getModifiers", "(", ")", ")", "&&", "m", ".", "getParameterTypes", "(", ")", ".", "length", "==", "1", ")", "{", "methods", ".", "add", "(", "m", ")", ";", "}", "}", "}", "return", "methods", ";", "}" ]
Return list of setters @param clazz
[ "Return", "list", "of", "setters" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/lang/reflect/Reflections.java#L46-L57
142,112
beangle/beangle3
struts/s2/src/main/java/org/beangle/struts2/convention/config/ConventionPackageProvider.java
ConventionPackageProvider.buildResultConfigs
protected List<ResultConfig> buildResultConfigs(Class<?> clazz, PackageConfig.Builder pcb) { List<ResultConfig> configs = CollectUtils.newArrayList(); // load annotation results Result[] results = new Result[0]; Results rs = clazz.getAnnotation(Results.class); if (null == rs) { org.beangle.struts2.annotation.Action an = clazz .getAnnotation(org.beangle.struts2.annotation.Action.class); if (null != an) results = an.results(); } else { results = rs.value(); } Set<String> annotationResults = CollectUtils.newHashSet(); if (null != results) { for (Result result : results) { String resultType = result.type(); if (Strings.isEmpty(resultType)) resultType = "dispatcher"; ResultTypeConfig rtc = pcb.getResultType(resultType); ResultConfig.Builder rcb = new ResultConfig.Builder(result.name(), rtc.getClassName()); if (null != rtc.getDefaultResultParam()) rcb.addParam(rtc.getDefaultResultParam(), result.location()); configs.add(rcb.build()); annotationResults.add(result.name()); } } // load ftl convension results if (!preloadftl || null == profileService) return configs; String extention = profileService.getProfile(clazz.getName()).getViewExtension(); if (!extention.equals("ftl")) return configs; ResultTypeConfig rtc = pcb.getResultType("freemarker"); for (Method m : clazz.getMethods()) { String methodName = m.getName(); if (!annotationResults.contains(methodName) && shouldGenerateResult(m)) { String path = templateFinder.find(clazz, methodName, methodName, extention); if (null != path) { configs.add(new ResultConfig.Builder(m.getName(), rtc.getClassName()) .addParam(rtc.getDefaultResultParam(), path).build()); } } } return configs; }
java
protected List<ResultConfig> buildResultConfigs(Class<?> clazz, PackageConfig.Builder pcb) { List<ResultConfig> configs = CollectUtils.newArrayList(); // load annotation results Result[] results = new Result[0]; Results rs = clazz.getAnnotation(Results.class); if (null == rs) { org.beangle.struts2.annotation.Action an = clazz .getAnnotation(org.beangle.struts2.annotation.Action.class); if (null != an) results = an.results(); } else { results = rs.value(); } Set<String> annotationResults = CollectUtils.newHashSet(); if (null != results) { for (Result result : results) { String resultType = result.type(); if (Strings.isEmpty(resultType)) resultType = "dispatcher"; ResultTypeConfig rtc = pcb.getResultType(resultType); ResultConfig.Builder rcb = new ResultConfig.Builder(result.name(), rtc.getClassName()); if (null != rtc.getDefaultResultParam()) rcb.addParam(rtc.getDefaultResultParam(), result.location()); configs.add(rcb.build()); annotationResults.add(result.name()); } } // load ftl convension results if (!preloadftl || null == profileService) return configs; String extention = profileService.getProfile(clazz.getName()).getViewExtension(); if (!extention.equals("ftl")) return configs; ResultTypeConfig rtc = pcb.getResultType("freemarker"); for (Method m : clazz.getMethods()) { String methodName = m.getName(); if (!annotationResults.contains(methodName) && shouldGenerateResult(m)) { String path = templateFinder.find(clazz, methodName, methodName, extention); if (null != path) { configs.add(new ResultConfig.Builder(m.getName(), rtc.getClassName()) .addParam(rtc.getDefaultResultParam(), path).build()); } } } return configs; }
[ "protected", "List", "<", "ResultConfig", ">", "buildResultConfigs", "(", "Class", "<", "?", ">", "clazz", ",", "PackageConfig", ".", "Builder", "pcb", ")", "{", "List", "<", "ResultConfig", ">", "configs", "=", "CollectUtils", ".", "newArrayList", "(", ")", ";", "// load annotation results", "Result", "[", "]", "results", "=", "new", "Result", "[", "0", "]", ";", "Results", "rs", "=", "clazz", ".", "getAnnotation", "(", "Results", ".", "class", ")", ";", "if", "(", "null", "==", "rs", ")", "{", "org", ".", "beangle", ".", "struts2", ".", "annotation", ".", "Action", "an", "=", "clazz", ".", "getAnnotation", "(", "org", ".", "beangle", ".", "struts2", ".", "annotation", ".", "Action", ".", "class", ")", ";", "if", "(", "null", "!=", "an", ")", "results", "=", "an", ".", "results", "(", ")", ";", "}", "else", "{", "results", "=", "rs", ".", "value", "(", ")", ";", "}", "Set", "<", "String", ">", "annotationResults", "=", "CollectUtils", ".", "newHashSet", "(", ")", ";", "if", "(", "null", "!=", "results", ")", "{", "for", "(", "Result", "result", ":", "results", ")", "{", "String", "resultType", "=", "result", ".", "type", "(", ")", ";", "if", "(", "Strings", ".", "isEmpty", "(", "resultType", ")", ")", "resultType", "=", "\"dispatcher\"", ";", "ResultTypeConfig", "rtc", "=", "pcb", ".", "getResultType", "(", "resultType", ")", ";", "ResultConfig", ".", "Builder", "rcb", "=", "new", "ResultConfig", ".", "Builder", "(", "result", ".", "name", "(", ")", ",", "rtc", ".", "getClassName", "(", ")", ")", ";", "if", "(", "null", "!=", "rtc", ".", "getDefaultResultParam", "(", ")", ")", "rcb", ".", "addParam", "(", "rtc", ".", "getDefaultResultParam", "(", ")", ",", "result", ".", "location", "(", ")", ")", ";", "configs", ".", "add", "(", "rcb", ".", "build", "(", ")", ")", ";", "annotationResults", ".", "add", "(", "result", ".", "name", "(", ")", ")", ";", "}", "}", "// load ftl convension results", "if", "(", "!", "preloadftl", "||", "null", "==", "profileService", ")", "return", "configs", ";", "String", "extention", "=", "profileService", ".", "getProfile", "(", "clazz", ".", "getName", "(", ")", ")", ".", "getViewExtension", "(", ")", ";", "if", "(", "!", "extention", ".", "equals", "(", "\"ftl\"", ")", ")", "return", "configs", ";", "ResultTypeConfig", "rtc", "=", "pcb", ".", "getResultType", "(", "\"freemarker\"", ")", ";", "for", "(", "Method", "m", ":", "clazz", ".", "getMethods", "(", ")", ")", "{", "String", "methodName", "=", "m", ".", "getName", "(", ")", ";", "if", "(", "!", "annotationResults", ".", "contains", "(", "methodName", ")", "&&", "shouldGenerateResult", "(", "m", ")", ")", "{", "String", "path", "=", "templateFinder", ".", "find", "(", "clazz", ",", "methodName", ",", "methodName", ",", "extention", ")", ";", "if", "(", "null", "!=", "path", ")", "{", "configs", ".", "add", "(", "new", "ResultConfig", ".", "Builder", "(", "m", ".", "getName", "(", ")", ",", "rtc", ".", "getClassName", "(", ")", ")", ".", "addParam", "(", "rtc", ".", "getDefaultResultParam", "(", ")", ",", "path", ")", ".", "build", "(", ")", ")", ";", "}", "}", "}", "return", "configs", ";", "}" ]
generator default results by method name @param clazz @return
[ "generator", "default", "results", "by", "method", "name" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/struts/s2/src/main/java/org/beangle/struts2/convention/config/ConventionPackageProvider.java#L280-L321
142,113
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/lang/time/Stopwatch.java
Stopwatch.start
public Stopwatch start() { Assert.isTrue(!isRunning); isRunning = true; startTick = ticker.read(); return this; }
java
public Stopwatch start() { Assert.isTrue(!isRunning); isRunning = true; startTick = ticker.read(); return this; }
[ "public", "Stopwatch", "start", "(", ")", "{", "Assert", ".", "isTrue", "(", "!", "isRunning", ")", ";", "isRunning", "=", "true", ";", "startTick", "=", "ticker", ".", "read", "(", ")", ";", "return", "this", ";", "}" ]
Starts the stopwatch. @return this {@code Stopwatch} instance @throws IllegalStateException if the stopwatch is already running.
[ "Starts", "the", "stopwatch", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/lang/time/Stopwatch.java#L77-L82
142,114
beangle/beangle3
commons/model/src/main/java/org/beangle/commons/transfer/importer/MultiEntityImporter.java
MultiEntityImporter.populateValue
protected void populateValue(Object entity, EntityType type, String attr, Object value) { // 当有深层次属性 if (Strings.contains(attr, '.')) { if (null != foreignerKeys) { boolean isForeigner = isForeigner(attr); // 如果是个外键,先根据parentPath生成新的外键实体。 // 因此导入的是外键,只能有一个属性导入. if (isForeigner) { String parentPath = Strings.substringBeforeLast(attr, "."); ObjectAndType propertyType = populator.initProperty(entity, type, parentPath); Object property = propertyType.getObj(); if (property instanceof Entity<?>) { if (((Entity<?>) property).isPersisted()) { populator.populateValue(entity, type, parentPath, null); populator.initProperty(entity, type, parentPath); } } } } } if (!populator.populateValue(entity, type, attr, value)) { transferResult.addFailure(descriptions.get(attr) + " data format error.", value); } }
java
protected void populateValue(Object entity, EntityType type, String attr, Object value) { // 当有深层次属性 if (Strings.contains(attr, '.')) { if (null != foreignerKeys) { boolean isForeigner = isForeigner(attr); // 如果是个外键,先根据parentPath生成新的外键实体。 // 因此导入的是外键,只能有一个属性导入. if (isForeigner) { String parentPath = Strings.substringBeforeLast(attr, "."); ObjectAndType propertyType = populator.initProperty(entity, type, parentPath); Object property = propertyType.getObj(); if (property instanceof Entity<?>) { if (((Entity<?>) property).isPersisted()) { populator.populateValue(entity, type, parentPath, null); populator.initProperty(entity, type, parentPath); } } } } } if (!populator.populateValue(entity, type, attr, value)) { transferResult.addFailure(descriptions.get(attr) + " data format error.", value); } }
[ "protected", "void", "populateValue", "(", "Object", "entity", ",", "EntityType", "type", ",", "String", "attr", ",", "Object", "value", ")", "{", "// 当有深层次属性", "if", "(", "Strings", ".", "contains", "(", "attr", ",", "'", "'", ")", ")", "{", "if", "(", "null", "!=", "foreignerKeys", ")", "{", "boolean", "isForeigner", "=", "isForeigner", "(", "attr", ")", ";", "// 如果是个外键,先根据parentPath生成新的外键实体。", "// 因此导入的是外键,只能有一个属性导入.", "if", "(", "isForeigner", ")", "{", "String", "parentPath", "=", "Strings", ".", "substringBeforeLast", "(", "attr", ",", "\".\"", ")", ";", "ObjectAndType", "propertyType", "=", "populator", ".", "initProperty", "(", "entity", ",", "type", ",", "parentPath", ")", ";", "Object", "property", "=", "propertyType", ".", "getObj", "(", ")", ";", "if", "(", "property", "instanceof", "Entity", "<", "?", ">", ")", "{", "if", "(", "(", "(", "Entity", "<", "?", ">", ")", "property", ")", ".", "isPersisted", "(", ")", ")", "{", "populator", ".", "populateValue", "(", "entity", ",", "type", ",", "parentPath", ",", "null", ")", ";", "populator", ".", "initProperty", "(", "entity", ",", "type", ",", "parentPath", ")", ";", "}", "}", "}", "}", "}", "if", "(", "!", "populator", ".", "populateValue", "(", "entity", ",", "type", ",", "attr", ",", "value", ")", ")", "{", "transferResult", ".", "addFailure", "(", "descriptions", ".", "get", "(", "attr", ")", "+", "\" data format error.\"", ",", "value", ")", ";", "}", "}" ]
Populate single attribute @param entity @param type @param attr @param value
[ "Populate", "single", "attribute" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/model/src/main/java/org/beangle/commons/transfer/importer/MultiEntityImporter.java#L105-L128
142,115
beangle/beangle3
struts/s2/src/main/java/org/beangle/struts2/freemarker/BeangleObjectWrapper.java
BeangleObjectWrapper.getModelFactory
@SuppressWarnings("rawtypes") protected ModelFactory getModelFactory(Class clazz) { if (altMapWrapper && Map.class.isAssignableFrom(clazz)) { return FriendlyMapModel.FACTORY; } return super.getModelFactory(clazz); }
java
@SuppressWarnings("rawtypes") protected ModelFactory getModelFactory(Class clazz) { if (altMapWrapper && Map.class.isAssignableFrom(clazz)) { return FriendlyMapModel.FACTORY; } return super.getModelFactory(clazz); }
[ "@", "SuppressWarnings", "(", "\"rawtypes\"", ")", "protected", "ModelFactory", "getModelFactory", "(", "Class", "clazz", ")", "{", "if", "(", "altMapWrapper", "&&", "Map", ".", "class", ".", "isAssignableFrom", "(", "clazz", ")", ")", "{", "return", "FriendlyMapModel", ".", "FACTORY", ";", "}", "return", "super", ".", "getModelFactory", "(", "clazz", ")", ";", "}" ]
of FM.
[ "of", "FM", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/struts/s2/src/main/java/org/beangle/struts2/freemarker/BeangleObjectWrapper.java#L74-L78
142,116
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/inject/bind/AbstractBindModule.java
AbstractBindModule.entry
protected final Pair<?, ?> entry(Object key, Object value) { return Pair.of(key, value); }
java
protected final Pair<?, ?> entry(Object key, Object value) { return Pair.of(key, value); }
[ "protected", "final", "Pair", "<", "?", ",", "?", ">", "entry", "(", "Object", "key", ",", "Object", "value", ")", "{", "return", "Pair", ".", "of", "(", "key", ",", "value", ")", ";", "}" ]
Return new map entry @param key @param value
[ "Return", "new", "map", "entry" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/inject/bind/AbstractBindModule.java#L97-L99
142,117
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/inject/bind/AbstractBindModule.java
AbstractBindModule.bean
protected final Definition bean(Class<?> clazz) { Definition def = new Definition(clazz.getName(), clazz, Scope.SINGLETON.toString()); def.beanName = clazz.getName() + "#" + Math.abs(System.identityHashCode(def)); return def; }
java
protected final Definition bean(Class<?> clazz) { Definition def = new Definition(clazz.getName(), clazz, Scope.SINGLETON.toString()); def.beanName = clazz.getName() + "#" + Math.abs(System.identityHashCode(def)); return def; }
[ "protected", "final", "Definition", "bean", "(", "Class", "<", "?", ">", "clazz", ")", "{", "Definition", "def", "=", "new", "Definition", "(", "clazz", ".", "getName", "(", ")", ",", "clazz", ",", "Scope", ".", "SINGLETON", ".", "toString", "(", ")", ")", ";", "def", ".", "beanName", "=", "clazz", ".", "getName", "(", ")", "+", "\"#\"", "+", "Math", ".", "abs", "(", "System", ".", "identityHashCode", "(", "def", ")", ")", ";", "return", "def", ";", "}" ]
Generate a inner bean definition @param clazz
[ "Generate", "a", "inner", "bean", "definition" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/inject/bind/AbstractBindModule.java#L106-L110
142,118
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/text/i18n/impl/DefaultTextBundleRegistry.java
DefaultTextBundleRegistry.loadJavaBundle
protected Option<TextBundle> loadJavaBundle(String bundleName, Locale locale) { Properties properties = new Properties(); String resource = toJavaResourceName(bundleName, locale); try { InputStream is = ClassLoaders.getResourceAsStream(resource, getClass()); if (null == is) return Option.none(); properties.load(is); is.close(); } catch (IOException e) { return Option.none(); } finally { } return Option.<TextBundle> from(new DefaultTextBundle(locale, resource, properties)); }
java
protected Option<TextBundle> loadJavaBundle(String bundleName, Locale locale) { Properties properties = new Properties(); String resource = toJavaResourceName(bundleName, locale); try { InputStream is = ClassLoaders.getResourceAsStream(resource, getClass()); if (null == is) return Option.none(); properties.load(is); is.close(); } catch (IOException e) { return Option.none(); } finally { } return Option.<TextBundle> from(new DefaultTextBundle(locale, resource, properties)); }
[ "protected", "Option", "<", "TextBundle", ">", "loadJavaBundle", "(", "String", "bundleName", ",", "Locale", "locale", ")", "{", "Properties", "properties", "=", "new", "Properties", "(", ")", ";", "String", "resource", "=", "toJavaResourceName", "(", "bundleName", ",", "locale", ")", ";", "try", "{", "InputStream", "is", "=", "ClassLoaders", ".", "getResourceAsStream", "(", "resource", ",", "getClass", "(", ")", ")", ";", "if", "(", "null", "==", "is", ")", "return", "Option", ".", "none", "(", ")", ";", "properties", ".", "load", "(", "is", ")", ";", "is", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "return", "Option", ".", "none", "(", ")", ";", "}", "finally", "{", "}", "return", "Option", ".", "<", "TextBundle", ">", "from", "(", "new", "DefaultTextBundle", "(", "locale", ",", "resource", ",", "properties", ")", ")", ";", "}" ]
Load java properties bundle with iso-8859-1 @param bundleName @param locale @return None or bundle corresponding bindleName.locale.properties
[ "Load", "java", "properties", "bundle", "with", "iso", "-", "8859", "-", "1" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/text/i18n/impl/DefaultTextBundleRegistry.java#L155-L168
142,119
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/text/i18n/impl/DefaultTextBundleRegistry.java
DefaultTextBundleRegistry.toJavaResourceName
protected final String toJavaResourceName(String bundleName, Locale locale) { String fullName = bundleName; final String localeName = toLocaleStr(locale); final String suffix = "properties"; if (!"".equals(localeName)) fullName = fullName + "_" + localeName; StringBuilder sb = new StringBuilder(fullName.length() + 1 + suffix.length()); sb.append(fullName.replace('.', '/')).append('.').append(suffix); return sb.toString(); }
java
protected final String toJavaResourceName(String bundleName, Locale locale) { String fullName = bundleName; final String localeName = toLocaleStr(locale); final String suffix = "properties"; if (!"".equals(localeName)) fullName = fullName + "_" + localeName; StringBuilder sb = new StringBuilder(fullName.length() + 1 + suffix.length()); sb.append(fullName.replace('.', '/')).append('.').append(suffix); return sb.toString(); }
[ "protected", "final", "String", "toJavaResourceName", "(", "String", "bundleName", ",", "Locale", "locale", ")", "{", "String", "fullName", "=", "bundleName", ";", "final", "String", "localeName", "=", "toLocaleStr", "(", "locale", ")", ";", "final", "String", "suffix", "=", "\"properties\"", ";", "if", "(", "!", "\"\"", ".", "equals", "(", "localeName", ")", ")", "fullName", "=", "fullName", "+", "\"_\"", "+", "localeName", ";", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "fullName", ".", "length", "(", ")", "+", "1", "+", "suffix", ".", "length", "(", ")", ")", ";", "sb", ".", "append", "(", "fullName", ".", "replace", "(", "'", "'", ",", "'", "'", ")", ")", ".", "append", "(", "'", "'", ")", ".", "append", "(", "suffix", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
java properties bundle name @param bundleName @param locale @return convented properties ended file path.
[ "java", "properties", "bundle", "name" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/text/i18n/impl/DefaultTextBundleRegistry.java#L177-L185
142,120
beangle/beangle3
struts/s2/src/main/java/org/beangle/struts2/view/component/Component.java
Component.getComponentName
private String getComponentName() { Class<?> c = getClass(); String name = c.getName(); int dot = name.lastIndexOf('.'); return name.substring(dot + 1).toLowerCase(); }
java
private String getComponentName() { Class<?> c = getClass(); String name = c.getName(); int dot = name.lastIndexOf('.'); return name.substring(dot + 1).toLowerCase(); }
[ "private", "String", "getComponentName", "(", ")", "{", "Class", "<", "?", ">", "c", "=", "getClass", "(", ")", ";", "String", "name", "=", "c", ".", "getName", "(", ")", ";", "int", "dot", "=", "name", ".", "lastIndexOf", "(", "'", "'", ")", ";", "return", "name", ".", "substring", "(", "dot", "+", "1", ")", ".", "toLowerCase", "(", ")", ";", "}" ]
Gets the name of this component. @return the name of this component.
[ "Gets", "the", "name", "of", "this", "component", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/struts/s2/src/main/java/org/beangle/struts2/view/component/Component.java#L62-L67
142,121
beangle/beangle3
struts/s2/src/main/java/org/beangle/struts2/view/component/Component.java
Component.getComponentStack
protected Stack<Component> getComponentStack() { @SuppressWarnings("unchecked") Stack<Component> componentStack = (Stack<Component>) stack.getContext().get(COMPONENT_STACK); if (componentStack == null) { componentStack = new Stack<Component>(); stack.getContext().put(COMPONENT_STACK, componentStack); } return componentStack; }
java
protected Stack<Component> getComponentStack() { @SuppressWarnings("unchecked") Stack<Component> componentStack = (Stack<Component>) stack.getContext().get(COMPONENT_STACK); if (componentStack == null) { componentStack = new Stack<Component>(); stack.getContext().put(COMPONENT_STACK, componentStack); } return componentStack; }
[ "protected", "Stack", "<", "Component", ">", "getComponentStack", "(", ")", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "Stack", "<", "Component", ">", "componentStack", "=", "(", "Stack", "<", "Component", ">", ")", "stack", ".", "getContext", "(", ")", ".", "get", "(", "COMPONENT_STACK", ")", ";", "if", "(", "componentStack", "==", "null", ")", "{", "componentStack", "=", "new", "Stack", "<", "Component", ">", "(", ")", ";", "stack", ".", "getContext", "(", ")", ".", "put", "(", "COMPONENT_STACK", ",", "componentStack", ")", ";", "}", "return", "componentStack", ";", "}" ]
Gets the component stack of this component. @return the component stack of this component, never <tt>null</tt>.
[ "Gets", "the", "component", "stack", "of", "this", "component", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/struts/s2/src/main/java/org/beangle/struts2/view/component/Component.java#L74-L82
142,122
beangle/beangle3
struts/s2/src/main/java/org/beangle/struts2/view/component/Component.java
Component.findAncestor
@SuppressWarnings("unchecked") protected <T extends Component> T findAncestor(Class<T> clazz) { Stack<? extends Component> componentStack = getComponentStack(); for (int i = componentStack.size() - 2; i >= 0; i--) { Component component = componentStack.get(i); if (clazz.equals(component.getClass())) return (T) component; } return null; }
java
@SuppressWarnings("unchecked") protected <T extends Component> T findAncestor(Class<T> clazz) { Stack<? extends Component> componentStack = getComponentStack(); for (int i = componentStack.size() - 2; i >= 0; i--) { Component component = componentStack.get(i); if (clazz.equals(component.getClass())) return (T) component; } return null; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "protected", "<", "T", "extends", "Component", ">", "T", "findAncestor", "(", "Class", "<", "T", ">", "clazz", ")", "{", "Stack", "<", "?", "extends", "Component", ">", "componentStack", "=", "getComponentStack", "(", ")", ";", "for", "(", "int", "i", "=", "componentStack", ".", "size", "(", ")", "-", "2", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "Component", "component", "=", "componentStack", ".", "get", "(", "i", ")", ";", "if", "(", "clazz", ".", "equals", "(", "component", ".", "getClass", "(", ")", ")", ")", "return", "(", "T", ")", "component", ";", "}", "return", "null", ";", "}" ]
Finds the nearest ancestor of this component stack. @param clazz the class to look for, or if assignable from. @return the component if found, <tt>null</tt> if not.
[ "Finds", "the", "nearest", "ancestor", "of", "this", "component", "stack", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/struts/s2/src/main/java/org/beangle/struts2/view/component/Component.java#L147-L155
142,123
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/io/Files.java
Files.readLines
public static List<String> readLines(File file, Charset charset) throws IOException { InputStream in = null; try { in = new FileInputStream(file); if (null == charset) { return IOs.readLines(new InputStreamReader(in)); } else { InputStreamReader reader = new InputStreamReader(in, charset.name()); return IOs.readLines(reader); } } finally { IOs.close(in); } }
java
public static List<String> readLines(File file, Charset charset) throws IOException { InputStream in = null; try { in = new FileInputStream(file); if (null == charset) { return IOs.readLines(new InputStreamReader(in)); } else { InputStreamReader reader = new InputStreamReader(in, charset.name()); return IOs.readLines(reader); } } finally { IOs.close(in); } }
[ "public", "static", "List", "<", "String", ">", "readLines", "(", "File", "file", ",", "Charset", "charset", ")", "throws", "IOException", "{", "InputStream", "in", "=", "null", ";", "try", "{", "in", "=", "new", "FileInputStream", "(", "file", ")", ";", "if", "(", "null", "==", "charset", ")", "{", "return", "IOs", ".", "readLines", "(", "new", "InputStreamReader", "(", "in", ")", ")", ";", "}", "else", "{", "InputStreamReader", "reader", "=", "new", "InputStreamReader", "(", "in", ",", "charset", ".", "name", "(", ")", ")", ";", "return", "IOs", ".", "readLines", "(", "reader", ")", ";", "}", "}", "finally", "{", "IOs", ".", "close", "(", "in", ")", ";", "}", "}" ]
Reads the contents of a file line by line to a List of Strings. The file is always closed.
[ "Reads", "the", "contents", "of", "a", "file", "line", "by", "line", "to", "a", "List", "of", "Strings", ".", "The", "file", "is", "always", "closed", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/io/Files.java#L76-L89
142,124
beangle/beangle3
struts/s2/src/main/java/org/beangle/struts2/view/tag/BeangleModels.java
BeangleModels.getParamstring
public String getParamstring() { StringWriter sw = new StringWriter(); Enumeration<?> em = req.getParameterNames(); while (em.hasMoreElements()) { String attr = (String) em.nextElement(); if (attr.equals("method")) continue; String value = req.getParameter(attr); if (attr.equals("x-requested-with")) continue; sw.write(attr); sw.write('='); sw.write(StringUtil.javaScriptStringEnc(value)); if (em.hasMoreElements()) sw.write('&'); } return sw.toString(); }
java
public String getParamstring() { StringWriter sw = new StringWriter(); Enumeration<?> em = req.getParameterNames(); while (em.hasMoreElements()) { String attr = (String) em.nextElement(); if (attr.equals("method")) continue; String value = req.getParameter(attr); if (attr.equals("x-requested-with")) continue; sw.write(attr); sw.write('='); sw.write(StringUtil.javaScriptStringEnc(value)); if (em.hasMoreElements()) sw.write('&'); } return sw.toString(); }
[ "public", "String", "getParamstring", "(", ")", "{", "StringWriter", "sw", "=", "new", "StringWriter", "(", ")", ";", "Enumeration", "<", "?", ">", "em", "=", "req", ".", "getParameterNames", "(", ")", ";", "while", "(", "em", ".", "hasMoreElements", "(", ")", ")", "{", "String", "attr", "=", "(", "String", ")", "em", ".", "nextElement", "(", ")", ";", "if", "(", "attr", ".", "equals", "(", "\"method\"", ")", ")", "continue", ";", "String", "value", "=", "req", ".", "getParameter", "(", "attr", ")", ";", "if", "(", "attr", ".", "equals", "(", "\"x-requested-with\"", ")", ")", "continue", ";", "sw", ".", "write", "(", "attr", ")", ";", "sw", ".", "write", "(", "'", "'", ")", ";", "sw", ".", "write", "(", "StringUtil", ".", "javaScriptStringEnc", "(", "value", ")", ")", ";", "if", "(", "em", ".", "hasMoreElements", "(", ")", ")", "sw", ".", "write", "(", "'", "'", ")", ";", "}", "return", "sw", ".", "toString", "(", ")", ";", "}" ]
query string and form control
[ "query", "string", "and", "form", "control" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/struts/s2/src/main/java/org/beangle/struts2/view/tag/BeangleModels.java#L116-L130
142,125
beangle/beangle3
ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java
BeanDefinitionParser.error
protected void error(String message, Element source, Throwable cause) { logger.error(message); }
java
protected void error(String message, Element source, Throwable cause) { logger.error(message); }
[ "protected", "void", "error", "(", "String", "message", ",", "Element", "source", ",", "Throwable", "cause", ")", "{", "logger", ".", "error", "(", "message", ")", ";", "}" ]
Report an error with the given message for the given source element. @param message a {@link java.lang.String} object. @param source a {@link org.w3c.dom.Element} object. @param cause a {@link java.lang.Throwable} object.
[ "Report", "an", "error", "with", "the", "given", "message", "for", "the", "given", "source", "element", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java#L111-L113
142,126
beangle/beangle3
ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java
BeanDefinitionParser.checkNameUniqueness
protected void checkNameUniqueness(String beanName, List<String> aliases, Element beanElement) { String foundName = null; if (StringUtils.hasText(beanName) && this.usedNames.contains(beanName)) foundName = beanName; if (foundName == null) foundName = (String) CollectionUtils.findFirstMatch(this.usedNames, aliases); if (foundName != null) error("Bean name '" + foundName + "' is already used in this file", beanElement); this.usedNames.add(beanName); this.usedNames.addAll(aliases); }
java
protected void checkNameUniqueness(String beanName, List<String> aliases, Element beanElement) { String foundName = null; if (StringUtils.hasText(beanName) && this.usedNames.contains(beanName)) foundName = beanName; if (foundName == null) foundName = (String) CollectionUtils.findFirstMatch(this.usedNames, aliases); if (foundName != null) error("Bean name '" + foundName + "' is already used in this file", beanElement); this.usedNames.add(beanName); this.usedNames.addAll(aliases); }
[ "protected", "void", "checkNameUniqueness", "(", "String", "beanName", ",", "List", "<", "String", ">", "aliases", ",", "Element", "beanElement", ")", "{", "String", "foundName", "=", "null", ";", "if", "(", "StringUtils", ".", "hasText", "(", "beanName", ")", "&&", "this", ".", "usedNames", ".", "contains", "(", "beanName", ")", ")", "foundName", "=", "beanName", ";", "if", "(", "foundName", "==", "null", ")", "foundName", "=", "(", "String", ")", "CollectionUtils", ".", "findFirstMatch", "(", "this", ".", "usedNames", ",", "aliases", ")", ";", "if", "(", "foundName", "!=", "null", ")", "error", "(", "\"Bean name '\"", "+", "foundName", "+", "\"' is already used in this file\"", ",", "beanElement", ")", ";", "this", ".", "usedNames", ".", "add", "(", "beanName", ")", ";", "this", ".", "usedNames", ".", "addAll", "(", "aliases", ")", ";", "}" ]
Validate that the specified bean name and aliases have not been used already. @param beanName a {@link java.lang.String} object. @param aliases a {@link java.util.List} object. @param beanElement a {@link org.w3c.dom.Element} object.
[ "Validate", "that", "the", "specified", "bean", "name", "and", "aliases", "have", "not", "been", "used", "already", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java#L179-L190
142,127
beangle/beangle3
ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java
BeanDefinitionParser.createBeanDefinition
protected AbstractBeanDefinition createBeanDefinition(String className, String parentName) throws ClassNotFoundException { return BeanDefinitionReaderUtils.createBeanDefinition(parentName, className, null); }
java
protected AbstractBeanDefinition createBeanDefinition(String className, String parentName) throws ClassNotFoundException { return BeanDefinitionReaderUtils.createBeanDefinition(parentName, className, null); }
[ "protected", "AbstractBeanDefinition", "createBeanDefinition", "(", "String", "className", ",", "String", "parentName", ")", "throws", "ClassNotFoundException", "{", "return", "BeanDefinitionReaderUtils", ".", "createBeanDefinition", "(", "parentName", ",", "className", ",", "null", ")", ";", "}" ]
Create a bean definition for the given class name and parent name. @param className the name of the bean class @param parentName the name of the bean's parent bean @return the newly created bean definition @throws java.lang.ClassNotFoundException if bean class resolution was attempted but failed
[ "Create", "a", "bean", "definition", "for", "the", "given", "class", "name", "and", "parent", "name", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java#L320-L323
142,128
beangle/beangle3
ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java
BeanDefinitionParser.parseConstructorArgElements
public void parseConstructorArgElements(Element beanEle, BeanDefinition bd) { NodeList nl = beanEle.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); if (node instanceof Element && nodeNameEquals(node, CONSTRUCTOR_ARG_ELEMENT)) parseConstructorArgElement((Element) node, bd); } }
java
public void parseConstructorArgElements(Element beanEle, BeanDefinition bd) { NodeList nl = beanEle.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); if (node instanceof Element && nodeNameEquals(node, CONSTRUCTOR_ARG_ELEMENT)) parseConstructorArgElement((Element) node, bd); } }
[ "public", "void", "parseConstructorArgElements", "(", "Element", "beanEle", ",", "BeanDefinition", "bd", ")", "{", "NodeList", "nl", "=", "beanEle", ".", "getChildNodes", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "nl", ".", "getLength", "(", ")", ";", "i", "++", ")", "{", "Node", "node", "=", "nl", ".", "item", "(", "i", ")", ";", "if", "(", "node", "instanceof", "Element", "&&", "nodeNameEquals", "(", "node", ",", "CONSTRUCTOR_ARG_ELEMENT", ")", ")", "parseConstructorArgElement", "(", "(", "Element", ")", "node", ",", "bd", ")", ";", "}", "}" ]
Parse constructor-arg sub-elements of the given bean element. @param beanEle a {@link org.w3c.dom.Element} object. @param bd a {@link org.springframework.beans.factory.config.BeanDefinition} object.
[ "Parse", "constructor", "-", "arg", "sub", "-", "elements", "of", "the", "given", "bean", "element", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java#L377-L384
142,129
beangle/beangle3
ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java
BeanDefinitionParser.parsePropertyElements
public void parsePropertyElements(Element beanEle, BeanDefinition bd) { NodeList nl = beanEle.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); if (node instanceof Element && nodeNameEquals(node, PROPERTY_ELEMENT)) parsePropertyElement((Element) node, bd); } }
java
public void parsePropertyElements(Element beanEle, BeanDefinition bd) { NodeList nl = beanEle.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); if (node instanceof Element && nodeNameEquals(node, PROPERTY_ELEMENT)) parsePropertyElement((Element) node, bd); } }
[ "public", "void", "parsePropertyElements", "(", "Element", "beanEle", ",", "BeanDefinition", "bd", ")", "{", "NodeList", "nl", "=", "beanEle", ".", "getChildNodes", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "nl", ".", "getLength", "(", ")", ";", "i", "++", ")", "{", "Node", "node", "=", "nl", ".", "item", "(", "i", ")", ";", "if", "(", "node", "instanceof", "Element", "&&", "nodeNameEquals", "(", "node", ",", "PROPERTY_ELEMENT", ")", ")", "parsePropertyElement", "(", "(", "Element", ")", "node", ",", "bd", ")", ";", "}", "}" ]
Parse property sub-elements of the given bean element. @param beanEle a {@link org.w3c.dom.Element} object. @param bd a {@link org.springframework.beans.factory.config.BeanDefinition} object.
[ "Parse", "property", "sub", "-", "elements", "of", "the", "given", "bean", "element", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java#L392-L399
142,130
beangle/beangle3
ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java
BeanDefinitionParser.parseQualifierElements
public void parseQualifierElements(Element beanEle, AbstractBeanDefinition bd) { NodeList nl = beanEle.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); if (node instanceof Element && nodeNameEquals(node, QUALIFIER_ELEMENT)) parseQualifierElement((Element) node, bd); } }
java
public void parseQualifierElements(Element beanEle, AbstractBeanDefinition bd) { NodeList nl = beanEle.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); if (node instanceof Element && nodeNameEquals(node, QUALIFIER_ELEMENT)) parseQualifierElement((Element) node, bd); } }
[ "public", "void", "parseQualifierElements", "(", "Element", "beanEle", ",", "AbstractBeanDefinition", "bd", ")", "{", "NodeList", "nl", "=", "beanEle", ".", "getChildNodes", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "nl", ".", "getLength", "(", ")", ";", "i", "++", ")", "{", "Node", "node", "=", "nl", ".", "item", "(", "i", ")", ";", "if", "(", "node", "instanceof", "Element", "&&", "nodeNameEquals", "(", "node", ",", "QUALIFIER_ELEMENT", ")", ")", "parseQualifierElement", "(", "(", "Element", ")", "node", ",", "bd", ")", ";", "}", "}" ]
Parse qualifier sub-elements of the given bean element. @param beanEle a {@link org.w3c.dom.Element} object. @param bd a {@link org.springframework.beans.factory.support.AbstractBeanDefinition} object.
[ "Parse", "qualifier", "sub", "-", "elements", "of", "the", "given", "bean", "element", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java#L407-L414
142,131
beangle/beangle3
ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java
BeanDefinitionParser.parseLookupOverrideSubElements
public void parseLookupOverrideSubElements(Element beanEle, MethodOverrides overrides) { NodeList nl = beanEle.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); if (node instanceof Element && nodeNameEquals(node, LOOKUP_METHOD_ELEMENT)) { Element ele = (Element) node; String methodName = ele.getAttribute(NAME_ATTRIBUTE); String beanRef = ele.getAttribute(BEAN_ELEMENT); LookupOverride override = new LookupOverride(methodName, beanRef); override.setSource(extractSource(ele)); overrides.addOverride(override); } } }
java
public void parseLookupOverrideSubElements(Element beanEle, MethodOverrides overrides) { NodeList nl = beanEle.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); if (node instanceof Element && nodeNameEquals(node, LOOKUP_METHOD_ELEMENT)) { Element ele = (Element) node; String methodName = ele.getAttribute(NAME_ATTRIBUTE); String beanRef = ele.getAttribute(BEAN_ELEMENT); LookupOverride override = new LookupOverride(methodName, beanRef); override.setSource(extractSource(ele)); overrides.addOverride(override); } } }
[ "public", "void", "parseLookupOverrideSubElements", "(", "Element", "beanEle", ",", "MethodOverrides", "overrides", ")", "{", "NodeList", "nl", "=", "beanEle", ".", "getChildNodes", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "nl", ".", "getLength", "(", ")", ";", "i", "++", ")", "{", "Node", "node", "=", "nl", ".", "item", "(", "i", ")", ";", "if", "(", "node", "instanceof", "Element", "&&", "nodeNameEquals", "(", "node", ",", "LOOKUP_METHOD_ELEMENT", ")", ")", "{", "Element", "ele", "=", "(", "Element", ")", "node", ";", "String", "methodName", "=", "ele", ".", "getAttribute", "(", "NAME_ATTRIBUTE", ")", ";", "String", "beanRef", "=", "ele", ".", "getAttribute", "(", "BEAN_ELEMENT", ")", ";", "LookupOverride", "override", "=", "new", "LookupOverride", "(", "methodName", ",", "beanRef", ")", ";", "override", ".", "setSource", "(", "extractSource", "(", "ele", ")", ")", ";", "overrides", ".", "addOverride", "(", "override", ")", ";", "}", "}", "}" ]
Parse lookup-override sub-elements of the given bean element. @param beanEle a {@link org.w3c.dom.Element} object. @param overrides a {@link org.springframework.beans.factory.support.MethodOverrides} object.
[ "Parse", "lookup", "-", "override", "sub", "-", "elements", "of", "the", "given", "bean", "element", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java#L422-L435
142,132
beangle/beangle3
ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java
BeanDefinitionParser.parseReplacedMethodSubElements
public void parseReplacedMethodSubElements(Element beanEle, MethodOverrides overrides) { NodeList nl = beanEle.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); if (node instanceof Element && nodeNameEquals(node, REPLACED_METHOD_ELEMENT)) { Element replacedMethodEle = (Element) node; String name = replacedMethodEle.getAttribute(NAME_ATTRIBUTE); String callback = replacedMethodEle.getAttribute(REPLACER_ATTRIBUTE); ReplaceOverride replaceOverride = new ReplaceOverride(name, callback); // Look for arg-type match elements. List<Element> argTypeEles = DomUtils.getChildElementsByTagName(replacedMethodEle, ARG_TYPE_ELEMENT); for (Element argTypeEle : argTypeEles) { replaceOverride.addTypeIdentifier(argTypeEle.getAttribute(ARG_TYPE_MATCH_ATTRIBUTE)); } replaceOverride.setSource(extractSource(replacedMethodEle)); overrides.addOverride(replaceOverride); } } }
java
public void parseReplacedMethodSubElements(Element beanEle, MethodOverrides overrides) { NodeList nl = beanEle.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); if (node instanceof Element && nodeNameEquals(node, REPLACED_METHOD_ELEMENT)) { Element replacedMethodEle = (Element) node; String name = replacedMethodEle.getAttribute(NAME_ATTRIBUTE); String callback = replacedMethodEle.getAttribute(REPLACER_ATTRIBUTE); ReplaceOverride replaceOverride = new ReplaceOverride(name, callback); // Look for arg-type match elements. List<Element> argTypeEles = DomUtils.getChildElementsByTagName(replacedMethodEle, ARG_TYPE_ELEMENT); for (Element argTypeEle : argTypeEles) { replaceOverride.addTypeIdentifier(argTypeEle.getAttribute(ARG_TYPE_MATCH_ATTRIBUTE)); } replaceOverride.setSource(extractSource(replacedMethodEle)); overrides.addOverride(replaceOverride); } } }
[ "public", "void", "parseReplacedMethodSubElements", "(", "Element", "beanEle", ",", "MethodOverrides", "overrides", ")", "{", "NodeList", "nl", "=", "beanEle", ".", "getChildNodes", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "nl", ".", "getLength", "(", ")", ";", "i", "++", ")", "{", "Node", "node", "=", "nl", ".", "item", "(", "i", ")", ";", "if", "(", "node", "instanceof", "Element", "&&", "nodeNameEquals", "(", "node", ",", "REPLACED_METHOD_ELEMENT", ")", ")", "{", "Element", "replacedMethodEle", "=", "(", "Element", ")", "node", ";", "String", "name", "=", "replacedMethodEle", ".", "getAttribute", "(", "NAME_ATTRIBUTE", ")", ";", "String", "callback", "=", "replacedMethodEle", ".", "getAttribute", "(", "REPLACER_ATTRIBUTE", ")", ";", "ReplaceOverride", "replaceOverride", "=", "new", "ReplaceOverride", "(", "name", ",", "callback", ")", ";", "// Look for arg-type match elements.", "List", "<", "Element", ">", "argTypeEles", "=", "DomUtils", ".", "getChildElementsByTagName", "(", "replacedMethodEle", ",", "ARG_TYPE_ELEMENT", ")", ";", "for", "(", "Element", "argTypeEle", ":", "argTypeEles", ")", "{", "replaceOverride", ".", "addTypeIdentifier", "(", "argTypeEle", ".", "getAttribute", "(", "ARG_TYPE_MATCH_ATTRIBUTE", ")", ")", ";", "}", "replaceOverride", ".", "setSource", "(", "extractSource", "(", "replacedMethodEle", ")", ")", ";", "overrides", ".", "addOverride", "(", "replaceOverride", ")", ";", "}", "}", "}" ]
Parse replaced-method sub-elements of the given bean element. @param beanEle a {@link org.w3c.dom.Element} object. @param overrides a {@link org.springframework.beans.factory.support.MethodOverrides} object.
[ "Parse", "replaced", "-", "method", "sub", "-", "elements", "of", "the", "given", "bean", "element", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java#L443-L461
142,133
beangle/beangle3
ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java
BeanDefinitionParser.parseConstructorArgElement
public void parseConstructorArgElement(Element ele, BeanDefinition bd) { String indexAttr = ele.getAttribute(INDEX_ATTRIBUTE); String typeAttr = ele.getAttribute(TYPE_ATTRIBUTE); String nameAttr = ele.getAttribute(NAME_ATTRIBUTE); if (StringUtils.hasLength(indexAttr)) { try { int index = Integer.parseInt(indexAttr); if (index < 0) { error("'index' cannot be lower than 0", ele); } else { try { this.parseState.push(new ConstructorArgumentEntry(index)); Object value = parsePropertyValue(ele, bd, null); ConstructorArgumentValues.ValueHolder valueHolder = new ConstructorArgumentValues.ValueHolder( value); if (StringUtils.hasLength(typeAttr)) valueHolder.setType(typeAttr); if (StringUtils.hasLength(nameAttr)) valueHolder.setName(nameAttr); valueHolder.setSource(extractSource(ele)); if (bd.getConstructorArgumentValues().hasIndexedArgumentValue(index)) { error("Ambiguous constructor-arg entries for index " + index, ele); } else { bd.getConstructorArgumentValues().addIndexedArgumentValue(index, valueHolder); } } finally { this.parseState.pop(); } } } catch (NumberFormatException ex) { error("Attribute 'index' of tag 'constructor-arg' must be an integer", ele); } } else { try { this.parseState.push(new ConstructorArgumentEntry()); Object value = parsePropertyValue(ele, bd, null); ConstructorArgumentValues.ValueHolder valueHolder = new ConstructorArgumentValues.ValueHolder(value); if (StringUtils.hasLength(typeAttr)) valueHolder.setType(typeAttr); if (StringUtils.hasLength(nameAttr)) valueHolder.setName(nameAttr); valueHolder.setSource(extractSource(ele)); bd.getConstructorArgumentValues().addGenericArgumentValue(valueHolder); } finally { this.parseState.pop(); } } }
java
public void parseConstructorArgElement(Element ele, BeanDefinition bd) { String indexAttr = ele.getAttribute(INDEX_ATTRIBUTE); String typeAttr = ele.getAttribute(TYPE_ATTRIBUTE); String nameAttr = ele.getAttribute(NAME_ATTRIBUTE); if (StringUtils.hasLength(indexAttr)) { try { int index = Integer.parseInt(indexAttr); if (index < 0) { error("'index' cannot be lower than 0", ele); } else { try { this.parseState.push(new ConstructorArgumentEntry(index)); Object value = parsePropertyValue(ele, bd, null); ConstructorArgumentValues.ValueHolder valueHolder = new ConstructorArgumentValues.ValueHolder( value); if (StringUtils.hasLength(typeAttr)) valueHolder.setType(typeAttr); if (StringUtils.hasLength(nameAttr)) valueHolder.setName(nameAttr); valueHolder.setSource(extractSource(ele)); if (bd.getConstructorArgumentValues().hasIndexedArgumentValue(index)) { error("Ambiguous constructor-arg entries for index " + index, ele); } else { bd.getConstructorArgumentValues().addIndexedArgumentValue(index, valueHolder); } } finally { this.parseState.pop(); } } } catch (NumberFormatException ex) { error("Attribute 'index' of tag 'constructor-arg' must be an integer", ele); } } else { try { this.parseState.push(new ConstructorArgumentEntry()); Object value = parsePropertyValue(ele, bd, null); ConstructorArgumentValues.ValueHolder valueHolder = new ConstructorArgumentValues.ValueHolder(value); if (StringUtils.hasLength(typeAttr)) valueHolder.setType(typeAttr); if (StringUtils.hasLength(nameAttr)) valueHolder.setName(nameAttr); valueHolder.setSource(extractSource(ele)); bd.getConstructorArgumentValues().addGenericArgumentValue(valueHolder); } finally { this.parseState.pop(); } } }
[ "public", "void", "parseConstructorArgElement", "(", "Element", "ele", ",", "BeanDefinition", "bd", ")", "{", "String", "indexAttr", "=", "ele", ".", "getAttribute", "(", "INDEX_ATTRIBUTE", ")", ";", "String", "typeAttr", "=", "ele", ".", "getAttribute", "(", "TYPE_ATTRIBUTE", ")", ";", "String", "nameAttr", "=", "ele", ".", "getAttribute", "(", "NAME_ATTRIBUTE", ")", ";", "if", "(", "StringUtils", ".", "hasLength", "(", "indexAttr", ")", ")", "{", "try", "{", "int", "index", "=", "Integer", ".", "parseInt", "(", "indexAttr", ")", ";", "if", "(", "index", "<", "0", ")", "{", "error", "(", "\"'index' cannot be lower than 0\"", ",", "ele", ")", ";", "}", "else", "{", "try", "{", "this", ".", "parseState", ".", "push", "(", "new", "ConstructorArgumentEntry", "(", "index", ")", ")", ";", "Object", "value", "=", "parsePropertyValue", "(", "ele", ",", "bd", ",", "null", ")", ";", "ConstructorArgumentValues", ".", "ValueHolder", "valueHolder", "=", "new", "ConstructorArgumentValues", ".", "ValueHolder", "(", "value", ")", ";", "if", "(", "StringUtils", ".", "hasLength", "(", "typeAttr", ")", ")", "valueHolder", ".", "setType", "(", "typeAttr", ")", ";", "if", "(", "StringUtils", ".", "hasLength", "(", "nameAttr", ")", ")", "valueHolder", ".", "setName", "(", "nameAttr", ")", ";", "valueHolder", ".", "setSource", "(", "extractSource", "(", "ele", ")", ")", ";", "if", "(", "bd", ".", "getConstructorArgumentValues", "(", ")", ".", "hasIndexedArgumentValue", "(", "index", ")", ")", "{", "error", "(", "\"Ambiguous constructor-arg entries for index \"", "+", "index", ",", "ele", ")", ";", "}", "else", "{", "bd", ".", "getConstructorArgumentValues", "(", ")", ".", "addIndexedArgumentValue", "(", "index", ",", "valueHolder", ")", ";", "}", "}", "finally", "{", "this", ".", "parseState", ".", "pop", "(", ")", ";", "}", "}", "}", "catch", "(", "NumberFormatException", "ex", ")", "{", "error", "(", "\"Attribute 'index' of tag 'constructor-arg' must be an integer\"", ",", "ele", ")", ";", "}", "}", "else", "{", "try", "{", "this", ".", "parseState", ".", "push", "(", "new", "ConstructorArgumentEntry", "(", ")", ")", ";", "Object", "value", "=", "parsePropertyValue", "(", "ele", ",", "bd", ",", "null", ")", ";", "ConstructorArgumentValues", ".", "ValueHolder", "valueHolder", "=", "new", "ConstructorArgumentValues", ".", "ValueHolder", "(", "value", ")", ";", "if", "(", "StringUtils", ".", "hasLength", "(", "typeAttr", ")", ")", "valueHolder", ".", "setType", "(", "typeAttr", ")", ";", "if", "(", "StringUtils", ".", "hasLength", "(", "nameAttr", ")", ")", "valueHolder", ".", "setName", "(", "nameAttr", ")", ";", "valueHolder", ".", "setSource", "(", "extractSource", "(", "ele", ")", ")", ";", "bd", ".", "getConstructorArgumentValues", "(", ")", ".", "addGenericArgumentValue", "(", "valueHolder", ")", ";", "}", "finally", "{", "this", ".", "parseState", ".", "pop", "(", ")", ";", "}", "}", "}" ]
Parse a constructor-arg element. @param ele a {@link org.w3c.dom.Element} object. @param bd a {@link org.springframework.beans.factory.config.BeanDefinition} object.
[ "Parse", "a", "constructor", "-", "arg", "element", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java#L469-L512
142,134
beangle/beangle3
ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java
BeanDefinitionParser.parsePropertyElement
public void parsePropertyElement(Element ele, BeanDefinition bd) { String propertyName = ele.getAttribute(NAME_ATTRIBUTE); if (!StringUtils.hasLength(propertyName)) { error("Tag 'property' must have a 'name' attribute", ele); return; } this.parseState.push(new PropertyEntry(propertyName)); try { if (bd.getPropertyValues().contains(propertyName)) { error("Multiple 'property' definitions for property '" + propertyName + "'", ele); return; } Object val = parsePropertyValue(ele, bd, propertyName); PropertyValue pv = new PropertyValue(propertyName, val); parseMetaElements(ele, pv); pv.setSource(extractSource(ele)); bd.getPropertyValues().addPropertyValue(pv); } finally { this.parseState.pop(); } }
java
public void parsePropertyElement(Element ele, BeanDefinition bd) { String propertyName = ele.getAttribute(NAME_ATTRIBUTE); if (!StringUtils.hasLength(propertyName)) { error("Tag 'property' must have a 'name' attribute", ele); return; } this.parseState.push(new PropertyEntry(propertyName)); try { if (bd.getPropertyValues().contains(propertyName)) { error("Multiple 'property' definitions for property '" + propertyName + "'", ele); return; } Object val = parsePropertyValue(ele, bd, propertyName); PropertyValue pv = new PropertyValue(propertyName, val); parseMetaElements(ele, pv); pv.setSource(extractSource(ele)); bd.getPropertyValues().addPropertyValue(pv); } finally { this.parseState.pop(); } }
[ "public", "void", "parsePropertyElement", "(", "Element", "ele", ",", "BeanDefinition", "bd", ")", "{", "String", "propertyName", "=", "ele", ".", "getAttribute", "(", "NAME_ATTRIBUTE", ")", ";", "if", "(", "!", "StringUtils", ".", "hasLength", "(", "propertyName", ")", ")", "{", "error", "(", "\"Tag 'property' must have a 'name' attribute\"", ",", "ele", ")", ";", "return", ";", "}", "this", ".", "parseState", ".", "push", "(", "new", "PropertyEntry", "(", "propertyName", ")", ")", ";", "try", "{", "if", "(", "bd", ".", "getPropertyValues", "(", ")", ".", "contains", "(", "propertyName", ")", ")", "{", "error", "(", "\"Multiple 'property' definitions for property '\"", "+", "propertyName", "+", "\"'\"", ",", "ele", ")", ";", "return", ";", "}", "Object", "val", "=", "parsePropertyValue", "(", "ele", ",", "bd", ",", "propertyName", ")", ";", "PropertyValue", "pv", "=", "new", "PropertyValue", "(", "propertyName", ",", "val", ")", ";", "parseMetaElements", "(", "ele", ",", "pv", ")", ";", "pv", ".", "setSource", "(", "extractSource", "(", "ele", ")", ")", ";", "bd", ".", "getPropertyValues", "(", ")", ".", "addPropertyValue", "(", "pv", ")", ";", "}", "finally", "{", "this", ".", "parseState", ".", "pop", "(", ")", ";", "}", "}" ]
Parse a property element. @param ele a {@link org.w3c.dom.Element} object. @param bd a {@link org.springframework.beans.factory.config.BeanDefinition} object.
[ "Parse", "a", "property", "element", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java#L520-L540
142,135
beangle/beangle3
ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java
BeanDefinitionParser.parseQualifierElement
public void parseQualifierElement(Element ele, AbstractBeanDefinition bd) { String typeName = ele.getAttribute(TYPE_ATTRIBUTE); if (!StringUtils.hasLength(typeName)) { error("Tag 'qualifier' must have a 'type' attribute", ele); return; } this.parseState.push(new QualifierEntry(typeName)); try { AutowireCandidateQualifier qualifier = new AutowireCandidateQualifier(typeName); qualifier.setSource(extractSource(ele)); String value = ele.getAttribute(VALUE_ATTRIBUTE); if (StringUtils.hasLength(value)) { qualifier.setAttribute(AutowireCandidateQualifier.VALUE_KEY, value); } NodeList nl = ele.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); if (node instanceof Element && nodeNameEquals(node, QUALIFIER_ATTRIBUTE_ELEMENT)) { Element attributeEle = (Element) node; String attributeName = attributeEle.getAttribute(KEY_ATTRIBUTE); String attributeValue = attributeEle.getAttribute(VALUE_ATTRIBUTE); if (StringUtils.hasLength(attributeName) && StringUtils.hasLength(attributeValue)) { BeanMetadataAttribute attribute = new BeanMetadataAttribute(attributeName, attributeValue); attribute.setSource(extractSource(attributeEle)); qualifier.addMetadataAttribute(attribute); } else { error("Qualifier 'attribute' tag must have a 'name' and 'value'", attributeEle); return; } } } bd.addQualifier(qualifier); } finally { this.parseState.pop(); } }
java
public void parseQualifierElement(Element ele, AbstractBeanDefinition bd) { String typeName = ele.getAttribute(TYPE_ATTRIBUTE); if (!StringUtils.hasLength(typeName)) { error("Tag 'qualifier' must have a 'type' attribute", ele); return; } this.parseState.push(new QualifierEntry(typeName)); try { AutowireCandidateQualifier qualifier = new AutowireCandidateQualifier(typeName); qualifier.setSource(extractSource(ele)); String value = ele.getAttribute(VALUE_ATTRIBUTE); if (StringUtils.hasLength(value)) { qualifier.setAttribute(AutowireCandidateQualifier.VALUE_KEY, value); } NodeList nl = ele.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); if (node instanceof Element && nodeNameEquals(node, QUALIFIER_ATTRIBUTE_ELEMENT)) { Element attributeEle = (Element) node; String attributeName = attributeEle.getAttribute(KEY_ATTRIBUTE); String attributeValue = attributeEle.getAttribute(VALUE_ATTRIBUTE); if (StringUtils.hasLength(attributeName) && StringUtils.hasLength(attributeValue)) { BeanMetadataAttribute attribute = new BeanMetadataAttribute(attributeName, attributeValue); attribute.setSource(extractSource(attributeEle)); qualifier.addMetadataAttribute(attribute); } else { error("Qualifier 'attribute' tag must have a 'name' and 'value'", attributeEle); return; } } } bd.addQualifier(qualifier); } finally { this.parseState.pop(); } }
[ "public", "void", "parseQualifierElement", "(", "Element", "ele", ",", "AbstractBeanDefinition", "bd", ")", "{", "String", "typeName", "=", "ele", ".", "getAttribute", "(", "TYPE_ATTRIBUTE", ")", ";", "if", "(", "!", "StringUtils", ".", "hasLength", "(", "typeName", ")", ")", "{", "error", "(", "\"Tag 'qualifier' must have a 'type' attribute\"", ",", "ele", ")", ";", "return", ";", "}", "this", ".", "parseState", ".", "push", "(", "new", "QualifierEntry", "(", "typeName", ")", ")", ";", "try", "{", "AutowireCandidateQualifier", "qualifier", "=", "new", "AutowireCandidateQualifier", "(", "typeName", ")", ";", "qualifier", ".", "setSource", "(", "extractSource", "(", "ele", ")", ")", ";", "String", "value", "=", "ele", ".", "getAttribute", "(", "VALUE_ATTRIBUTE", ")", ";", "if", "(", "StringUtils", ".", "hasLength", "(", "value", ")", ")", "{", "qualifier", ".", "setAttribute", "(", "AutowireCandidateQualifier", ".", "VALUE_KEY", ",", "value", ")", ";", "}", "NodeList", "nl", "=", "ele", ".", "getChildNodes", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "nl", ".", "getLength", "(", ")", ";", "i", "++", ")", "{", "Node", "node", "=", "nl", ".", "item", "(", "i", ")", ";", "if", "(", "node", "instanceof", "Element", "&&", "nodeNameEquals", "(", "node", ",", "QUALIFIER_ATTRIBUTE_ELEMENT", ")", ")", "{", "Element", "attributeEle", "=", "(", "Element", ")", "node", ";", "String", "attributeName", "=", "attributeEle", ".", "getAttribute", "(", "KEY_ATTRIBUTE", ")", ";", "String", "attributeValue", "=", "attributeEle", ".", "getAttribute", "(", "VALUE_ATTRIBUTE", ")", ";", "if", "(", "StringUtils", ".", "hasLength", "(", "attributeName", ")", "&&", "StringUtils", ".", "hasLength", "(", "attributeValue", ")", ")", "{", "BeanMetadataAttribute", "attribute", "=", "new", "BeanMetadataAttribute", "(", "attributeName", ",", "attributeValue", ")", ";", "attribute", ".", "setSource", "(", "extractSource", "(", "attributeEle", ")", ")", ";", "qualifier", ".", "addMetadataAttribute", "(", "attribute", ")", ";", "}", "else", "{", "error", "(", "\"Qualifier 'attribute' tag must have a 'name' and 'value'\"", ",", "attributeEle", ")", ";", "return", ";", "}", "}", "}", "bd", ".", "addQualifier", "(", "qualifier", ")", ";", "}", "finally", "{", "this", ".", "parseState", ".", "pop", "(", ")", ";", "}", "}" ]
Parse a qualifier element. @param ele a {@link org.w3c.dom.Element} object. @param bd a {@link org.springframework.beans.factory.support.AbstractBeanDefinition} object.
[ "Parse", "a", "qualifier", "element", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java#L548-L583
142,136
beangle/beangle3
ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java
BeanDefinitionParser.parsePropertyValue
public Object parsePropertyValue(Element ele, BeanDefinition bd, String propertyName) { String elementName = (propertyName != null) ? "<property> element for property '" + propertyName + "'" : "<constructor-arg> element"; // Should only have one child element: ref, value, list, etc. NodeList nl = ele.getChildNodes(); Element subElement = null; for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); if (node instanceof Element && !nodeNameEquals(node, DESCRIPTION_ELEMENT) && !nodeNameEquals(node, META_ELEMENT)) { // Child element is what we're looking for. if (subElement != null) error(elementName + " must not contain more than one sub-element", ele); else subElement = (Element) node; } } boolean hasRefAttribute = ele.hasAttribute(REF_ATTRIBUTE); boolean hasValueAttribute = ele.hasAttribute(VALUE_ATTRIBUTE); if ((hasRefAttribute && hasValueAttribute) || ((hasRefAttribute || hasValueAttribute) && subElement != null)) { error( elementName + " is only allowed to contain either 'ref' attribute OR 'value' attribute OR sub-element", ele); } if (hasRefAttribute) { String refName = ele.getAttribute(REF_ATTRIBUTE); if (!StringUtils.hasText(refName)) error(elementName + " contains empty 'ref' attribute", ele); RuntimeBeanReference ref = new RuntimeBeanReference(refName); ref.setSource(extractSource(ele)); return ref; } else if (hasValueAttribute) { TypedStringValue valueHolder = new TypedStringValue(ele.getAttribute(VALUE_ATTRIBUTE)); valueHolder.setSource(extractSource(ele)); return valueHolder; } else if (subElement != null) { return parsePropertySubElement(subElement, bd); } else { // Neither child element nor "ref" or "value" attribute found. error(elementName + " must specify a ref or value", ele); return null; } }
java
public Object parsePropertyValue(Element ele, BeanDefinition bd, String propertyName) { String elementName = (propertyName != null) ? "<property> element for property '" + propertyName + "'" : "<constructor-arg> element"; // Should only have one child element: ref, value, list, etc. NodeList nl = ele.getChildNodes(); Element subElement = null; for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); if (node instanceof Element && !nodeNameEquals(node, DESCRIPTION_ELEMENT) && !nodeNameEquals(node, META_ELEMENT)) { // Child element is what we're looking for. if (subElement != null) error(elementName + " must not contain more than one sub-element", ele); else subElement = (Element) node; } } boolean hasRefAttribute = ele.hasAttribute(REF_ATTRIBUTE); boolean hasValueAttribute = ele.hasAttribute(VALUE_ATTRIBUTE); if ((hasRefAttribute && hasValueAttribute) || ((hasRefAttribute || hasValueAttribute) && subElement != null)) { error( elementName + " is only allowed to contain either 'ref' attribute OR 'value' attribute OR sub-element", ele); } if (hasRefAttribute) { String refName = ele.getAttribute(REF_ATTRIBUTE); if (!StringUtils.hasText(refName)) error(elementName + " contains empty 'ref' attribute", ele); RuntimeBeanReference ref = new RuntimeBeanReference(refName); ref.setSource(extractSource(ele)); return ref; } else if (hasValueAttribute) { TypedStringValue valueHolder = new TypedStringValue(ele.getAttribute(VALUE_ATTRIBUTE)); valueHolder.setSource(extractSource(ele)); return valueHolder; } else if (subElement != null) { return parsePropertySubElement(subElement, bd); } else { // Neither child element nor "ref" or "value" attribute found. error(elementName + " must specify a ref or value", ele); return null; } }
[ "public", "Object", "parsePropertyValue", "(", "Element", "ele", ",", "BeanDefinition", "bd", ",", "String", "propertyName", ")", "{", "String", "elementName", "=", "(", "propertyName", "!=", "null", ")", "?", "\"<property> element for property '\"", "+", "propertyName", "+", "\"'\"", ":", "\"<constructor-arg> element\"", ";", "// Should only have one child element: ref, value, list, etc.", "NodeList", "nl", "=", "ele", ".", "getChildNodes", "(", ")", ";", "Element", "subElement", "=", "null", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "nl", ".", "getLength", "(", ")", ";", "i", "++", ")", "{", "Node", "node", "=", "nl", ".", "item", "(", "i", ")", ";", "if", "(", "node", "instanceof", "Element", "&&", "!", "nodeNameEquals", "(", "node", ",", "DESCRIPTION_ELEMENT", ")", "&&", "!", "nodeNameEquals", "(", "node", ",", "META_ELEMENT", ")", ")", "{", "// Child element is what we're looking for.", "if", "(", "subElement", "!=", "null", ")", "error", "(", "elementName", "+", "\" must not contain more than one sub-element\"", ",", "ele", ")", ";", "else", "subElement", "=", "(", "Element", ")", "node", ";", "}", "}", "boolean", "hasRefAttribute", "=", "ele", ".", "hasAttribute", "(", "REF_ATTRIBUTE", ")", ";", "boolean", "hasValueAttribute", "=", "ele", ".", "hasAttribute", "(", "VALUE_ATTRIBUTE", ")", ";", "if", "(", "(", "hasRefAttribute", "&&", "hasValueAttribute", ")", "||", "(", "(", "hasRefAttribute", "||", "hasValueAttribute", ")", "&&", "subElement", "!=", "null", ")", ")", "{", "error", "(", "elementName", "+", "\" is only allowed to contain either 'ref' attribute OR 'value' attribute OR sub-element\"", ",", "ele", ")", ";", "}", "if", "(", "hasRefAttribute", ")", "{", "String", "refName", "=", "ele", ".", "getAttribute", "(", "REF_ATTRIBUTE", ")", ";", "if", "(", "!", "StringUtils", ".", "hasText", "(", "refName", ")", ")", "error", "(", "elementName", "+", "\" contains empty 'ref' attribute\"", ",", "ele", ")", ";", "RuntimeBeanReference", "ref", "=", "new", "RuntimeBeanReference", "(", "refName", ")", ";", "ref", ".", "setSource", "(", "extractSource", "(", "ele", ")", ")", ";", "return", "ref", ";", "}", "else", "if", "(", "hasValueAttribute", ")", "{", "TypedStringValue", "valueHolder", "=", "new", "TypedStringValue", "(", "ele", ".", "getAttribute", "(", "VALUE_ATTRIBUTE", ")", ")", ";", "valueHolder", ".", "setSource", "(", "extractSource", "(", "ele", ")", ")", ";", "return", "valueHolder", ";", "}", "else", "if", "(", "subElement", "!=", "null", ")", "{", "return", "parsePropertySubElement", "(", "subElement", ",", "bd", ")", ";", "}", "else", "{", "// Neither child element nor \"ref\" or \"value\" attribute found.", "error", "(", "elementName", "+", "\" must specify a ref or value\"", ",", "ele", ")", ";", "return", "null", ";", "}", "}" ]
Get the value of a property element. May be a list etc. Also used for constructor arguments, "propertyName" being null in this case. @param ele a {@link org.w3c.dom.Element} object. @param bd a {@link org.springframework.beans.factory.config.BeanDefinition} object. @param propertyName a {@link java.lang.String} object. @return a {@link java.lang.Object} object.
[ "Get", "the", "value", "of", "a", "property", "element", ".", "May", "be", "a", "list", "etc", ".", "Also", "used", "for", "constructor", "arguments", "propertyName", "being", "null", "in", "this", "case", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java#L594-L639
142,137
beangle/beangle3
ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java
BeanDefinitionParser.parsePropertySubElement
public Object parsePropertySubElement(Element ele, BeanDefinition bd, String defaultValueType) { if (!isDefaultNamespace(getNamespaceURI(ele))) { error("Cannot support nested element .", ele); return null; } else if (nodeNameEquals(ele, BEAN_ELEMENT)) { BeanDefinitionHolder nestedBd = parseBeanDefinitionElement(ele, bd); if (nestedBd != null) nestedBd = decorateBeanDefinitionIfRequired(ele, nestedBd, bd); return nestedBd; } else if (nodeNameEquals(ele, REF_ELEMENT)) { // A generic reference to any name of any bean. String refName = ele.getAttribute(BEAN_REF_ATTRIBUTE); boolean toParent = false; if (!StringUtils.hasLength(refName)) { // A reference to the id of another bean in the same XML file. refName = ele.getAttribute(LOCAL_REF_ATTRIBUTE); if (!StringUtils.hasLength(refName)) { // A reference to the id of another bean in a parent context. refName = ele.getAttribute(PARENT_REF_ATTRIBUTE); toParent = true; if (!StringUtils.hasLength(refName)) { error("'bean', 'local' or 'parent' is required for <ref> element", ele); return null; } } } if (!StringUtils.hasText(refName)) { error("<ref> element contains empty target attribute", ele); return null; } RuntimeBeanReference ref = new RuntimeBeanReference(refName, toParent); ref.setSource(extractSource(ele)); return ref; } else if (nodeNameEquals(ele, IDREF_ELEMENT)) { return parseIdRefElement(ele); } else if (nodeNameEquals(ele, VALUE_ELEMENT)) { return parseValueElement(ele, defaultValueType); } else if (nodeNameEquals(ele, NULL_ELEMENT)) { // It's a distinguished null value. Let's wrap it in a // TypedStringValue // object in order to preserve the source location. TypedStringValue nullHolder = new TypedStringValue(null); nullHolder.setSource(extractSource(ele)); return nullHolder; } else if (nodeNameEquals(ele, ARRAY_ELEMENT)) { return parseArrayElement(ele, bd); } else if (nodeNameEquals(ele, LIST_ELEMENT)) { return parseListElement(ele, bd); } else if (nodeNameEquals(ele, SET_ELEMENT)) { return parseSetElement(ele, bd); } else if (nodeNameEquals(ele, MAP_ELEMENT)) { return parseMapElement(ele, bd); } else if (nodeNameEquals(ele, PROPS_ELEMENT)) { return parsePropsElement(ele); } else { error("Unknown property sub-element: [" + ele.getNodeName() + "]", ele); return null; } }
java
public Object parsePropertySubElement(Element ele, BeanDefinition bd, String defaultValueType) { if (!isDefaultNamespace(getNamespaceURI(ele))) { error("Cannot support nested element .", ele); return null; } else if (nodeNameEquals(ele, BEAN_ELEMENT)) { BeanDefinitionHolder nestedBd = parseBeanDefinitionElement(ele, bd); if (nestedBd != null) nestedBd = decorateBeanDefinitionIfRequired(ele, nestedBd, bd); return nestedBd; } else if (nodeNameEquals(ele, REF_ELEMENT)) { // A generic reference to any name of any bean. String refName = ele.getAttribute(BEAN_REF_ATTRIBUTE); boolean toParent = false; if (!StringUtils.hasLength(refName)) { // A reference to the id of another bean in the same XML file. refName = ele.getAttribute(LOCAL_REF_ATTRIBUTE); if (!StringUtils.hasLength(refName)) { // A reference to the id of another bean in a parent context. refName = ele.getAttribute(PARENT_REF_ATTRIBUTE); toParent = true; if (!StringUtils.hasLength(refName)) { error("'bean', 'local' or 'parent' is required for <ref> element", ele); return null; } } } if (!StringUtils.hasText(refName)) { error("<ref> element contains empty target attribute", ele); return null; } RuntimeBeanReference ref = new RuntimeBeanReference(refName, toParent); ref.setSource(extractSource(ele)); return ref; } else if (nodeNameEquals(ele, IDREF_ELEMENT)) { return parseIdRefElement(ele); } else if (nodeNameEquals(ele, VALUE_ELEMENT)) { return parseValueElement(ele, defaultValueType); } else if (nodeNameEquals(ele, NULL_ELEMENT)) { // It's a distinguished null value. Let's wrap it in a // TypedStringValue // object in order to preserve the source location. TypedStringValue nullHolder = new TypedStringValue(null); nullHolder.setSource(extractSource(ele)); return nullHolder; } else if (nodeNameEquals(ele, ARRAY_ELEMENT)) { return parseArrayElement(ele, bd); } else if (nodeNameEquals(ele, LIST_ELEMENT)) { return parseListElement(ele, bd); } else if (nodeNameEquals(ele, SET_ELEMENT)) { return parseSetElement(ele, bd); } else if (nodeNameEquals(ele, MAP_ELEMENT)) { return parseMapElement(ele, bd); } else if (nodeNameEquals(ele, PROPS_ELEMENT)) { return parsePropsElement(ele); } else { error("Unknown property sub-element: [" + ele.getNodeName() + "]", ele); return null; } }
[ "public", "Object", "parsePropertySubElement", "(", "Element", "ele", ",", "BeanDefinition", "bd", ",", "String", "defaultValueType", ")", "{", "if", "(", "!", "isDefaultNamespace", "(", "getNamespaceURI", "(", "ele", ")", ")", ")", "{", "error", "(", "\"Cannot support nested element .\"", ",", "ele", ")", ";", "return", "null", ";", "}", "else", "if", "(", "nodeNameEquals", "(", "ele", ",", "BEAN_ELEMENT", ")", ")", "{", "BeanDefinitionHolder", "nestedBd", "=", "parseBeanDefinitionElement", "(", "ele", ",", "bd", ")", ";", "if", "(", "nestedBd", "!=", "null", ")", "nestedBd", "=", "decorateBeanDefinitionIfRequired", "(", "ele", ",", "nestedBd", ",", "bd", ")", ";", "return", "nestedBd", ";", "}", "else", "if", "(", "nodeNameEquals", "(", "ele", ",", "REF_ELEMENT", ")", ")", "{", "// A generic reference to any name of any bean.", "String", "refName", "=", "ele", ".", "getAttribute", "(", "BEAN_REF_ATTRIBUTE", ")", ";", "boolean", "toParent", "=", "false", ";", "if", "(", "!", "StringUtils", ".", "hasLength", "(", "refName", ")", ")", "{", "// A reference to the id of another bean in the same XML file.", "refName", "=", "ele", ".", "getAttribute", "(", "LOCAL_REF_ATTRIBUTE", ")", ";", "if", "(", "!", "StringUtils", ".", "hasLength", "(", "refName", ")", ")", "{", "// A reference to the id of another bean in a parent context.", "refName", "=", "ele", ".", "getAttribute", "(", "PARENT_REF_ATTRIBUTE", ")", ";", "toParent", "=", "true", ";", "if", "(", "!", "StringUtils", ".", "hasLength", "(", "refName", ")", ")", "{", "error", "(", "\"'bean', 'local' or 'parent' is required for <ref> element\"", ",", "ele", ")", ";", "return", "null", ";", "}", "}", "}", "if", "(", "!", "StringUtils", ".", "hasText", "(", "refName", ")", ")", "{", "error", "(", "\"<ref> element contains empty target attribute\"", ",", "ele", ")", ";", "return", "null", ";", "}", "RuntimeBeanReference", "ref", "=", "new", "RuntimeBeanReference", "(", "refName", ",", "toParent", ")", ";", "ref", ".", "setSource", "(", "extractSource", "(", "ele", ")", ")", ";", "return", "ref", ";", "}", "else", "if", "(", "nodeNameEquals", "(", "ele", ",", "IDREF_ELEMENT", ")", ")", "{", "return", "parseIdRefElement", "(", "ele", ")", ";", "}", "else", "if", "(", "nodeNameEquals", "(", "ele", ",", "VALUE_ELEMENT", ")", ")", "{", "return", "parseValueElement", "(", "ele", ",", "defaultValueType", ")", ";", "}", "else", "if", "(", "nodeNameEquals", "(", "ele", ",", "NULL_ELEMENT", ")", ")", "{", "// It's a distinguished null value. Let's wrap it in a", "// TypedStringValue", "// object in order to preserve the source location.", "TypedStringValue", "nullHolder", "=", "new", "TypedStringValue", "(", "null", ")", ";", "nullHolder", ".", "setSource", "(", "extractSource", "(", "ele", ")", ")", ";", "return", "nullHolder", ";", "}", "else", "if", "(", "nodeNameEquals", "(", "ele", ",", "ARRAY_ELEMENT", ")", ")", "{", "return", "parseArrayElement", "(", "ele", ",", "bd", ")", ";", "}", "else", "if", "(", "nodeNameEquals", "(", "ele", ",", "LIST_ELEMENT", ")", ")", "{", "return", "parseListElement", "(", "ele", ",", "bd", ")", ";", "}", "else", "if", "(", "nodeNameEquals", "(", "ele", ",", "SET_ELEMENT", ")", ")", "{", "return", "parseSetElement", "(", "ele", ",", "bd", ")", ";", "}", "else", "if", "(", "nodeNameEquals", "(", "ele", ",", "MAP_ELEMENT", ")", ")", "{", "return", "parseMapElement", "(", "ele", ",", "bd", ")", ";", "}", "else", "if", "(", "nodeNameEquals", "(", "ele", ",", "PROPS_ELEMENT", ")", ")", "{", "return", "parsePropsElement", "(", "ele", ")", ";", "}", "else", "{", "error", "(", "\"Unknown property sub-element: [\"", "+", "ele", ".", "getNodeName", "(", ")", "+", "\"]\"", ",", "ele", ")", ";", "return", "null", ";", "}", "}" ]
Parse a value, ref or collection sub-element of a property or constructor-arg element. @param ele subelement of property element; we don't know which yet @param defaultValueType the default type (class name) for any <code>&lt;value&gt;</code> tag that might be created @param bd a {@link org.springframework.beans.factory.config.BeanDefinition} object. @return a {@link java.lang.Object} object.
[ "Parse", "a", "value", "ref", "or", "collection", "sub", "-", "element", "of", "a", "property", "or", "constructor", "-", "arg", "element", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java#L664-L721
142,138
beangle/beangle3
ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java
BeanDefinitionParser.parseIdRefElement
public Object parseIdRefElement(Element ele) { // A generic reference to any name of any bean. String refName = ele.getAttribute(BEAN_REF_ATTRIBUTE); if (!StringUtils.hasLength(refName)) { // A reference to the id of another bean in the same XML file. refName = ele.getAttribute(LOCAL_REF_ATTRIBUTE); if (!StringUtils.hasLength(refName)) { error("Either 'bean' or 'local' is required for <idref> element", ele); return null; } } if (!StringUtils.hasText(refName)) { error("<idref> element contains empty target attribute", ele); return null; } RuntimeBeanNameReference ref = new RuntimeBeanNameReference(refName); ref.setSource(extractSource(ele)); return ref; }
java
public Object parseIdRefElement(Element ele) { // A generic reference to any name of any bean. String refName = ele.getAttribute(BEAN_REF_ATTRIBUTE); if (!StringUtils.hasLength(refName)) { // A reference to the id of another bean in the same XML file. refName = ele.getAttribute(LOCAL_REF_ATTRIBUTE); if (!StringUtils.hasLength(refName)) { error("Either 'bean' or 'local' is required for <idref> element", ele); return null; } } if (!StringUtils.hasText(refName)) { error("<idref> element contains empty target attribute", ele); return null; } RuntimeBeanNameReference ref = new RuntimeBeanNameReference(refName); ref.setSource(extractSource(ele)); return ref; }
[ "public", "Object", "parseIdRefElement", "(", "Element", "ele", ")", "{", "// A generic reference to any name of any bean.", "String", "refName", "=", "ele", ".", "getAttribute", "(", "BEAN_REF_ATTRIBUTE", ")", ";", "if", "(", "!", "StringUtils", ".", "hasLength", "(", "refName", ")", ")", "{", "// A reference to the id of another bean in the same XML file.", "refName", "=", "ele", ".", "getAttribute", "(", "LOCAL_REF_ATTRIBUTE", ")", ";", "if", "(", "!", "StringUtils", ".", "hasLength", "(", "refName", ")", ")", "{", "error", "(", "\"Either 'bean' or 'local' is required for <idref> element\"", ",", "ele", ")", ";", "return", "null", ";", "}", "}", "if", "(", "!", "StringUtils", ".", "hasText", "(", "refName", ")", ")", "{", "error", "(", "\"<idref> element contains empty target attribute\"", ",", "ele", ")", ";", "return", "null", ";", "}", "RuntimeBeanNameReference", "ref", "=", "new", "RuntimeBeanNameReference", "(", "refName", ")", ";", "ref", ".", "setSource", "(", "extractSource", "(", "ele", ")", ")", ";", "return", "ref", ";", "}" ]
Return a typed String value Object for the given 'idref' element. @param ele a {@link org.w3c.dom.Element} object. @return a {@link java.lang.Object} object.
[ "Return", "a", "typed", "String", "value", "Object", "for", "the", "given", "idref", "element", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java#L729-L747
142,139
beangle/beangle3
ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java
BeanDefinitionParser.parseValueElement
public Object parseValueElement(Element ele, String defaultTypeName) { // It's a literal value. String value = DomUtils.getTextValue(ele); String specifiedTypeName = ele.getAttribute(TYPE_ATTRIBUTE); String typeName = specifiedTypeName; if (!StringUtils.hasText(typeName)) typeName = defaultTypeName; try { TypedStringValue typedValue = buildTypedStringValue(value, typeName); typedValue.setSource(extractSource(ele)); typedValue.setSpecifiedTypeName(specifiedTypeName); return typedValue; } catch (ClassNotFoundException ex) { error("Type class [" + typeName + "] not found for <value> element", ele, ex); return value; } }
java
public Object parseValueElement(Element ele, String defaultTypeName) { // It's a literal value. String value = DomUtils.getTextValue(ele); String specifiedTypeName = ele.getAttribute(TYPE_ATTRIBUTE); String typeName = specifiedTypeName; if (!StringUtils.hasText(typeName)) typeName = defaultTypeName; try { TypedStringValue typedValue = buildTypedStringValue(value, typeName); typedValue.setSource(extractSource(ele)); typedValue.setSpecifiedTypeName(specifiedTypeName); return typedValue; } catch (ClassNotFoundException ex) { error("Type class [" + typeName + "] not found for <value> element", ele, ex); return value; } }
[ "public", "Object", "parseValueElement", "(", "Element", "ele", ",", "String", "defaultTypeName", ")", "{", "// It's a literal value.", "String", "value", "=", "DomUtils", ".", "getTextValue", "(", "ele", ")", ";", "String", "specifiedTypeName", "=", "ele", ".", "getAttribute", "(", "TYPE_ATTRIBUTE", ")", ";", "String", "typeName", "=", "specifiedTypeName", ";", "if", "(", "!", "StringUtils", ".", "hasText", "(", "typeName", ")", ")", "typeName", "=", "defaultTypeName", ";", "try", "{", "TypedStringValue", "typedValue", "=", "buildTypedStringValue", "(", "value", ",", "typeName", ")", ";", "typedValue", ".", "setSource", "(", "extractSource", "(", "ele", ")", ")", ";", "typedValue", ".", "setSpecifiedTypeName", "(", "specifiedTypeName", ")", ";", "return", "typedValue", ";", "}", "catch", "(", "ClassNotFoundException", "ex", ")", "{", "error", "(", "\"Type class [\"", "+", "typeName", "+", "\"] not found for <value> element\"", ",", "ele", ",", "ex", ")", ";", "return", "value", ";", "}", "}" ]
Return a typed String value Object for the given value element. @param ele a {@link org.w3c.dom.Element} object. @param defaultTypeName a {@link java.lang.String} object. @return a {@link java.lang.Object} object.
[ "Return", "a", "typed", "String", "value", "Object", "for", "the", "given", "value", "element", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java#L756-L771
142,140
beangle/beangle3
ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java
BeanDefinitionParser.parseArrayElement
public Object parseArrayElement(Element arrayEle, BeanDefinition bd) { String elementType = arrayEle.getAttribute(VALUE_TYPE_ATTRIBUTE); NodeList nl = arrayEle.getChildNodes(); ManagedArray target = new ManagedArray(elementType, nl.getLength()); target.setSource(extractSource(arrayEle)); target.setElementTypeName(elementType); target.setMergeEnabled(parseMergeAttribute(arrayEle)); parseCollectionElements(nl, target, bd, elementType); return target; }
java
public Object parseArrayElement(Element arrayEle, BeanDefinition bd) { String elementType = arrayEle.getAttribute(VALUE_TYPE_ATTRIBUTE); NodeList nl = arrayEle.getChildNodes(); ManagedArray target = new ManagedArray(elementType, nl.getLength()); target.setSource(extractSource(arrayEle)); target.setElementTypeName(elementType); target.setMergeEnabled(parseMergeAttribute(arrayEle)); parseCollectionElements(nl, target, bd, elementType); return target; }
[ "public", "Object", "parseArrayElement", "(", "Element", "arrayEle", ",", "BeanDefinition", "bd", ")", "{", "String", "elementType", "=", "arrayEle", ".", "getAttribute", "(", "VALUE_TYPE_ATTRIBUTE", ")", ";", "NodeList", "nl", "=", "arrayEle", ".", "getChildNodes", "(", ")", ";", "ManagedArray", "target", "=", "new", "ManagedArray", "(", "elementType", ",", "nl", ".", "getLength", "(", ")", ")", ";", "target", ".", "setSource", "(", "extractSource", "(", "arrayEle", ")", ")", ";", "target", ".", "setElementTypeName", "(", "elementType", ")", ";", "target", ".", "setMergeEnabled", "(", "parseMergeAttribute", "(", "arrayEle", ")", ")", ";", "parseCollectionElements", "(", "nl", ",", "target", ",", "bd", ",", "elementType", ")", ";", "return", "target", ";", "}" ]
Parse an array element. @param arrayEle a {@link org.w3c.dom.Element} object. @param bd a {@link org.springframework.beans.factory.config.BeanDefinition} object. @return a {@link java.lang.Object} object.
[ "Parse", "an", "array", "element", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java#L797-L806
142,141
beangle/beangle3
ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java
BeanDefinitionParser.parseListElement
public List<Object> parseListElement(Element collectionEle, BeanDefinition bd) { String defaultElementType = collectionEle.getAttribute(VALUE_TYPE_ATTRIBUTE); NodeList nl = collectionEle.getChildNodes(); ManagedList<Object> target = new ManagedList<Object>(nl.getLength()); target.setSource(extractSource(collectionEle)); target.setElementTypeName(defaultElementType); target.setMergeEnabled(parseMergeAttribute(collectionEle)); parseCollectionElements(nl, target, bd, defaultElementType); return target; }
java
public List<Object> parseListElement(Element collectionEle, BeanDefinition bd) { String defaultElementType = collectionEle.getAttribute(VALUE_TYPE_ATTRIBUTE); NodeList nl = collectionEle.getChildNodes(); ManagedList<Object> target = new ManagedList<Object>(nl.getLength()); target.setSource(extractSource(collectionEle)); target.setElementTypeName(defaultElementType); target.setMergeEnabled(parseMergeAttribute(collectionEle)); parseCollectionElements(nl, target, bd, defaultElementType); return target; }
[ "public", "List", "<", "Object", ">", "parseListElement", "(", "Element", "collectionEle", ",", "BeanDefinition", "bd", ")", "{", "String", "defaultElementType", "=", "collectionEle", ".", "getAttribute", "(", "VALUE_TYPE_ATTRIBUTE", ")", ";", "NodeList", "nl", "=", "collectionEle", ".", "getChildNodes", "(", ")", ";", "ManagedList", "<", "Object", ">", "target", "=", "new", "ManagedList", "<", "Object", ">", "(", "nl", ".", "getLength", "(", ")", ")", ";", "target", ".", "setSource", "(", "extractSource", "(", "collectionEle", ")", ")", ";", "target", ".", "setElementTypeName", "(", "defaultElementType", ")", ";", "target", ".", "setMergeEnabled", "(", "parseMergeAttribute", "(", "collectionEle", ")", ")", ";", "parseCollectionElements", "(", "nl", ",", "target", ",", "bd", ",", "defaultElementType", ")", ";", "return", "target", ";", "}" ]
Parse a list element. @param collectionEle a {@link org.w3c.dom.Element} object. @param bd a {@link org.springframework.beans.factory.config.BeanDefinition} object. @return a {@link java.util.List} object.
[ "Parse", "a", "list", "element", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java#L815-L824
142,142
beangle/beangle3
ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java
BeanDefinitionParser.parseSetElement
public Set<Object> parseSetElement(Element collectionEle, BeanDefinition bd) { String defaultElementType = collectionEle.getAttribute(VALUE_TYPE_ATTRIBUTE); NodeList nl = collectionEle.getChildNodes(); ManagedSet<Object> target = new ManagedSet<Object>(nl.getLength()); target.setSource(extractSource(collectionEle)); target.setElementTypeName(defaultElementType); target.setMergeEnabled(parseMergeAttribute(collectionEle)); parseCollectionElements(nl, target, bd, defaultElementType); return target; }
java
public Set<Object> parseSetElement(Element collectionEle, BeanDefinition bd) { String defaultElementType = collectionEle.getAttribute(VALUE_TYPE_ATTRIBUTE); NodeList nl = collectionEle.getChildNodes(); ManagedSet<Object> target = new ManagedSet<Object>(nl.getLength()); target.setSource(extractSource(collectionEle)); target.setElementTypeName(defaultElementType); target.setMergeEnabled(parseMergeAttribute(collectionEle)); parseCollectionElements(nl, target, bd, defaultElementType); return target; }
[ "public", "Set", "<", "Object", ">", "parseSetElement", "(", "Element", "collectionEle", ",", "BeanDefinition", "bd", ")", "{", "String", "defaultElementType", "=", "collectionEle", ".", "getAttribute", "(", "VALUE_TYPE_ATTRIBUTE", ")", ";", "NodeList", "nl", "=", "collectionEle", ".", "getChildNodes", "(", ")", ";", "ManagedSet", "<", "Object", ">", "target", "=", "new", "ManagedSet", "<", "Object", ">", "(", "nl", ".", "getLength", "(", ")", ")", ";", "target", ".", "setSource", "(", "extractSource", "(", "collectionEle", ")", ")", ";", "target", ".", "setElementTypeName", "(", "defaultElementType", ")", ";", "target", ".", "setMergeEnabled", "(", "parseMergeAttribute", "(", "collectionEle", ")", ")", ";", "parseCollectionElements", "(", "nl", ",", "target", ",", "bd", ",", "defaultElementType", ")", ";", "return", "target", ";", "}" ]
Parse a set element. @param collectionEle a {@link org.w3c.dom.Element} object. @param bd a {@link org.springframework.beans.factory.config.BeanDefinition} object. @return a {@link java.util.Set} object.
[ "Parse", "a", "set", "element", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java#L833-L842
142,143
beangle/beangle3
ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java
BeanDefinitionParser.parseKeyElement
protected Object parseKeyElement(Element keyEle, BeanDefinition bd, String defaultKeyTypeName) { NodeList nl = keyEle.getChildNodes(); Element subElement = null; for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); if (node instanceof Element) { // Child element is what we're looking for. if (subElement != null) error("<key> element must not contain more than one value sub-element", keyEle); else subElement = (Element) node; } } return parsePropertySubElement(subElement, bd, defaultKeyTypeName); }
java
protected Object parseKeyElement(Element keyEle, BeanDefinition bd, String defaultKeyTypeName) { NodeList nl = keyEle.getChildNodes(); Element subElement = null; for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); if (node instanceof Element) { // Child element is what we're looking for. if (subElement != null) error("<key> element must not contain more than one value sub-element", keyEle); else subElement = (Element) node; } } return parsePropertySubElement(subElement, bd, defaultKeyTypeName); }
[ "protected", "Object", "parseKeyElement", "(", "Element", "keyEle", ",", "BeanDefinition", "bd", ",", "String", "defaultKeyTypeName", ")", "{", "NodeList", "nl", "=", "keyEle", ".", "getChildNodes", "(", ")", ";", "Element", "subElement", "=", "null", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "nl", ".", "getLength", "(", ")", ";", "i", "++", ")", "{", "Node", "node", "=", "nl", ".", "item", "(", "i", ")", ";", "if", "(", "node", "instanceof", "Element", ")", "{", "// Child element is what we're looking for.", "if", "(", "subElement", "!=", "null", ")", "error", "(", "\"<key> element must not contain more than one value sub-element\"", ",", "keyEle", ")", ";", "else", "subElement", "=", "(", "Element", ")", "node", ";", "}", "}", "return", "parsePropertySubElement", "(", "subElement", ",", "bd", ",", "defaultKeyTypeName", ")", ";", "}" ]
Parse a key sub-element of a map element. @param keyEle a {@link org.w3c.dom.Element} object. @param bd a {@link org.springframework.beans.factory.config.BeanDefinition} object. @param defaultKeyTypeName a {@link java.lang.String} object. @return a {@link java.lang.Object} object.
[ "Parse", "a", "key", "sub", "-", "element", "of", "a", "map", "element", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java#L990-L1003
142,144
beangle/beangle3
ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java
BeanDefinitionParser.parsePropsElement
public Properties parsePropsElement(Element propsEle) { ManagedProperties props = new ManagedProperties(); props.setSource(extractSource(propsEle)); props.setMergeEnabled(parseMergeAttribute(propsEle)); List<Element> propEles = DomUtils.getChildElementsByTagName(propsEle, PROP_ELEMENT); for (Element propEle : propEles) { String key = propEle.getAttribute(KEY_ATTRIBUTE); // Trim the text value to avoid unwanted whitespace // caused by typical XML formatting. String value = DomUtils.getTextValue(propEle).trim(); TypedStringValue keyHolder = new TypedStringValue(key); keyHolder.setSource(extractSource(propEle)); TypedStringValue valueHolder = new TypedStringValue(value); valueHolder.setSource(extractSource(propEle)); props.put(keyHolder, valueHolder); } return props; }
java
public Properties parsePropsElement(Element propsEle) { ManagedProperties props = new ManagedProperties(); props.setSource(extractSource(propsEle)); props.setMergeEnabled(parseMergeAttribute(propsEle)); List<Element> propEles = DomUtils.getChildElementsByTagName(propsEle, PROP_ELEMENT); for (Element propEle : propEles) { String key = propEle.getAttribute(KEY_ATTRIBUTE); // Trim the text value to avoid unwanted whitespace // caused by typical XML formatting. String value = DomUtils.getTextValue(propEle).trim(); TypedStringValue keyHolder = new TypedStringValue(key); keyHolder.setSource(extractSource(propEle)); TypedStringValue valueHolder = new TypedStringValue(value); valueHolder.setSource(extractSource(propEle)); props.put(keyHolder, valueHolder); } return props; }
[ "public", "Properties", "parsePropsElement", "(", "Element", "propsEle", ")", "{", "ManagedProperties", "props", "=", "new", "ManagedProperties", "(", ")", ";", "props", ".", "setSource", "(", "extractSource", "(", "propsEle", ")", ")", ";", "props", ".", "setMergeEnabled", "(", "parseMergeAttribute", "(", "propsEle", ")", ")", ";", "List", "<", "Element", ">", "propEles", "=", "DomUtils", ".", "getChildElementsByTagName", "(", "propsEle", ",", "PROP_ELEMENT", ")", ";", "for", "(", "Element", "propEle", ":", "propEles", ")", "{", "String", "key", "=", "propEle", ".", "getAttribute", "(", "KEY_ATTRIBUTE", ")", ";", "// Trim the text value to avoid unwanted whitespace", "// caused by typical XML formatting.", "String", "value", "=", "DomUtils", ".", "getTextValue", "(", "propEle", ")", ".", "trim", "(", ")", ";", "TypedStringValue", "keyHolder", "=", "new", "TypedStringValue", "(", "key", ")", ";", "keyHolder", ".", "setSource", "(", "extractSource", "(", "propEle", ")", ")", ";", "TypedStringValue", "valueHolder", "=", "new", "TypedStringValue", "(", "value", ")", ";", "valueHolder", ".", "setSource", "(", "extractSource", "(", "propEle", ")", ")", ";", "props", ".", "put", "(", "keyHolder", ",", "valueHolder", ")", ";", "}", "return", "props", ";", "}" ]
Parse a props element. @param propsEle a {@link org.w3c.dom.Element} object. @return a {@link java.util.Properties} object.
[ "Parse", "a", "props", "element", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java#L1011-L1030
142,145
beangle/beangle3
ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java
BeanDefinitionParser.parseMergeAttribute
public boolean parseMergeAttribute(Element collectionElement) { String value = collectionElement.getAttribute(MERGE_ATTRIBUTE); return TRUE_VALUE.equals(value); }
java
public boolean parseMergeAttribute(Element collectionElement) { String value = collectionElement.getAttribute(MERGE_ATTRIBUTE); return TRUE_VALUE.equals(value); }
[ "public", "boolean", "parseMergeAttribute", "(", "Element", "collectionElement", ")", "{", "String", "value", "=", "collectionElement", ".", "getAttribute", "(", "MERGE_ATTRIBUTE", ")", ";", "return", "TRUE_VALUE", ".", "equals", "(", "value", ")", ";", "}" ]
Parse the merge attribute of a collection element, if any. @param collectionElement a {@link org.w3c.dom.Element} object. @return a boolean.
[ "Parse", "the", "merge", "attribute", "of", "a", "collection", "element", "if", "any", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/ioc/spring/src/main/java/org/beangle/inject/spring/config/BeanDefinitionParser.java#L1038-L1041
142,146
beangle/beangle3
commons/web/src/main/java/org/beangle/commons/web/filter/GenericHttpFilter.java
GenericHttpFilter.init
public final void init(FilterConfig filterConfig) throws ServletException { Assert.notNull(filterConfig, "FilterConfig must not be null"); logger.debug("Initializing filter '{}'", filterConfig.getFilterName()); this.filterConfig = filterConfig; initParams(filterConfig); // Let subclasses do whatever initialization they like. initFilterBean(); logger.debug("Filter '{}' configured successfully", filterConfig.getFilterName()); }
java
public final void init(FilterConfig filterConfig) throws ServletException { Assert.notNull(filterConfig, "FilterConfig must not be null"); logger.debug("Initializing filter '{}'", filterConfig.getFilterName()); this.filterConfig = filterConfig; initParams(filterConfig); // Let subclasses do whatever initialization they like. initFilterBean(); logger.debug("Filter '{}' configured successfully", filterConfig.getFilterName()); }
[ "public", "final", "void", "init", "(", "FilterConfig", "filterConfig", ")", "throws", "ServletException", "{", "Assert", ".", "notNull", "(", "filterConfig", ",", "\"FilterConfig must not be null\"", ")", ";", "logger", ".", "debug", "(", "\"Initializing filter '{}'\"", ",", "filterConfig", ".", "getFilterName", "(", ")", ")", ";", "this", ".", "filterConfig", "=", "filterConfig", ";", "initParams", "(", "filterConfig", ")", ";", "// Let subclasses do whatever initialization they like.", "initFilterBean", "(", ")", ";", "logger", ".", "debug", "(", "\"Filter '{}' configured successfully\"", ",", "filterConfig", ".", "getFilterName", "(", ")", ")", ";", "}" ]
Standard way of initializing this filter. Map config parameters onto bean properties of this filter, and invoke subclass initialization. @param filterConfig the configuration for this filter @throws ServletException if bean properties are invalid (or required properties are missing), or if subclass initialization fails. @see #initFilterBean
[ "Standard", "way", "of", "initializing", "this", "filter", ".", "Map", "config", "parameters", "onto", "bean", "properties", "of", "this", "filter", "and", "invoke", "subclass", "initialization", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/web/src/main/java/org/beangle/commons/web/filter/GenericHttpFilter.java#L98-L107
142,147
beangle/beangle3
orm/hibernate/src/main/java/org/beangle/orm/hibernate/tool/DdlGenerator.java
DdlGenerator.getPropertyType
private Class<?> getPropertyType(PersistentClass pc, String propertyString) { String[] properties = split(propertyString, '.'); Property p = pc.getProperty(properties[0]); Component cp = ((Component) p.getValue()); int i = 1; for (; i < properties.length; i++) { p = cp.getProperty(properties[i]); cp = ((Component) p.getValue()); } return cp.getComponentClass(); }
java
private Class<?> getPropertyType(PersistentClass pc, String propertyString) { String[] properties = split(propertyString, '.'); Property p = pc.getProperty(properties[0]); Component cp = ((Component) p.getValue()); int i = 1; for (; i < properties.length; i++) { p = cp.getProperty(properties[i]); cp = ((Component) p.getValue()); } return cp.getComponentClass(); }
[ "private", "Class", "<", "?", ">", "getPropertyType", "(", "PersistentClass", "pc", ",", "String", "propertyString", ")", "{", "String", "[", "]", "properties", "=", "split", "(", "propertyString", ",", "'", "'", ")", ";", "Property", "p", "=", "pc", ".", "getProperty", "(", "properties", "[", "0", "]", ")", ";", "Component", "cp", "=", "(", "(", "Component", ")", "p", ".", "getValue", "(", ")", ")", ";", "int", "i", "=", "1", ";", "for", "(", ";", "i", "<", "properties", ".", "length", ";", "i", "++", ")", "{", "p", "=", "cp", ".", "getProperty", "(", "properties", "[", "i", "]", ")", ";", "cp", "=", "(", "(", "Component", ")", "p", ".", "getValue", "(", ")", ")", ";", "}", "return", "cp", ".", "getComponentClass", "(", ")", ";", "}" ]
get component class by component property string @param pc @param propertyString @return
[ "get", "component", "class", "by", "component", "property", "string" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/orm/hibernate/src/main/java/org/beangle/orm/hibernate/tool/DdlGenerator.java#L206-L216
142,148
beangle/beangle3
struts/s2/src/main/java/org/beangle/struts2/action/EntityActionSupport.java
EntityActionSupport.getId
protected final <T> T getId(String name, Class<T> clazz) { Object[] entityIds = getAll(name + ".id"); if (Arrays.isEmpty(entityIds)) entityIds = getAll(name + "Id"); if (Arrays.isEmpty(entityIds)) entityIds = getAll("id"); if (Arrays.isEmpty(entityIds)) return null; else { String entityId = entityIds[0].toString(); int commaIndex = entityId.indexOf(','); if (commaIndex != -1) entityId = entityId.substring(0, commaIndex); return Params.converter.convert(entityId, clazz); } }
java
protected final <T> T getId(String name, Class<T> clazz) { Object[] entityIds = getAll(name + ".id"); if (Arrays.isEmpty(entityIds)) entityIds = getAll(name + "Id"); if (Arrays.isEmpty(entityIds)) entityIds = getAll("id"); if (Arrays.isEmpty(entityIds)) return null; else { String entityId = entityIds[0].toString(); int commaIndex = entityId.indexOf(','); if (commaIndex != -1) entityId = entityId.substring(0, commaIndex); return Params.converter.convert(entityId, clazz); } }
[ "protected", "final", "<", "T", ">", "T", "getId", "(", "String", "name", ",", "Class", "<", "T", ">", "clazz", ")", "{", "Object", "[", "]", "entityIds", "=", "getAll", "(", "name", "+", "\".id\"", ")", ";", "if", "(", "Arrays", ".", "isEmpty", "(", "entityIds", ")", ")", "entityIds", "=", "getAll", "(", "name", "+", "\"Id\"", ")", ";", "if", "(", "Arrays", ".", "isEmpty", "(", "entityIds", ")", ")", "entityIds", "=", "getAll", "(", "\"id\"", ")", ";", "if", "(", "Arrays", ".", "isEmpty", "(", "entityIds", ")", ")", "return", "null", ";", "else", "{", "String", "entityId", "=", "entityIds", "[", "0", "]", ".", "toString", "(", ")", ";", "int", "commaIndex", "=", "entityId", ".", "indexOf", "(", "'", "'", ")", ";", "if", "(", "commaIndex", "!=", "-", "1", ")", "entityId", "=", "entityId", ".", "substring", "(", "0", ",", "commaIndex", ")", ";", "return", "Params", ".", "converter", ".", "convert", "(", "entityId", ",", "clazz", ")", ";", "}", "}" ]
Get entity's id from shortname.id,shortnameId,id @param name @param clazz
[ "Get", "entity", "s", "id", "from", "shortname", ".", "id", "shortnameId", "id" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/struts/s2/src/main/java/org/beangle/struts2/action/EntityActionSupport.java#L47-L58
142,149
beangle/beangle3
struts/s2/src/main/java/org/beangle/struts2/action/EntityActionSupport.java
EntityActionSupport.getIds
protected final <T> T[] getIds(String name, Class<T> clazz) { T[] datas = Params.getAll(name + ".id", clazz); if (null == datas) { String datastring = Params.get(name + ".ids"); if (null == datastring) datastring = Params.get(name + "Ids"); if (null == datastring) Array.newInstance(clazz, 0); else return Params.converter.convert(Strings.split(datastring, ","), clazz); } return datas; }
java
protected final <T> T[] getIds(String name, Class<T> clazz) { T[] datas = Params.getAll(name + ".id", clazz); if (null == datas) { String datastring = Params.get(name + ".ids"); if (null == datastring) datastring = Params.get(name + "Ids"); if (null == datastring) Array.newInstance(clazz, 0); else return Params.converter.convert(Strings.split(datastring, ","), clazz); } return datas; }
[ "protected", "final", "<", "T", ">", "T", "[", "]", "getIds", "(", "String", "name", ",", "Class", "<", "T", ">", "clazz", ")", "{", "T", "[", "]", "datas", "=", "Params", ".", "getAll", "(", "name", "+", "\".id\"", ",", "clazz", ")", ";", "if", "(", "null", "==", "datas", ")", "{", "String", "datastring", "=", "Params", ".", "get", "(", "name", "+", "\".ids\"", ")", ";", "if", "(", "null", "==", "datastring", ")", "datastring", "=", "Params", ".", "get", "(", "name", "+", "\"Ids\"", ")", ";", "if", "(", "null", "==", "datastring", ")", "Array", ".", "newInstance", "(", "clazz", ",", "0", ")", ";", "else", "return", "Params", ".", "converter", ".", "convert", "(", "Strings", ".", "split", "(", "datastring", ",", "\",\"", ")", ",", "clazz", ")", ";", "}", "return", "datas", ";", "}" ]
Get entity's id array from parameters shortname.id,shortname.ids,shortnameIds @param name @param clazz @return empty array if not found
[ "Get", "entity", "s", "id", "array", "from", "parameters", "shortname", ".", "id", "shortname", ".", "ids", "shortnameIds" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/struts/s2/src/main/java/org/beangle/struts2/action/EntityActionSupport.java#L93-L102
142,150
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/cache/caffeine/CaffeineCache.java
CaffeineCache.evict
@Override public void evict(K key) { Object existed = store.getIfPresent(key); if (null != existed) store.invalidate(key); }
java
@Override public void evict(K key) { Object existed = store.getIfPresent(key); if (null != existed) store.invalidate(key); }
[ "@", "Override", "public", "void", "evict", "(", "K", "key", ")", "{", "Object", "existed", "=", "store", ".", "getIfPresent", "(", "key", ")", ";", "if", "(", "null", "!=", "existed", ")", "store", ".", "invalidate", "(", "key", ")", ";", "}" ]
Evict specified key
[ "Evict", "specified", "key" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/cache/caffeine/CaffeineCache.java#L48-L52
142,151
beangle/beangle3
security/ids/src/main/java/org/beangle/security/ids/CasEntryPoint.java
CasEntryPoint.constructLocalLoginServiceUrl
public String constructLocalLoginServiceUrl(final HttpServletRequest request, final HttpServletResponse response, final String service, final String serverName, final String artifactParameterName, final boolean encode) { if (Strings.isNotBlank(service)) return encode ? response.encodeURL(service) : service; final StringBuilder buffer = new StringBuilder(); if (!serverName.startsWith("https://") && !serverName.startsWith("http://")) { buffer.append(request.isSecure() ? "https://" : "http://"); } buffer.append(serverName); buffer.append(request.getContextPath()); buffer.append(localLogin); final String returnValue = encode ? response.encodeURL(buffer.toString()) : buffer.toString(); return returnValue; }
java
public String constructLocalLoginServiceUrl(final HttpServletRequest request, final HttpServletResponse response, final String service, final String serverName, final String artifactParameterName, final boolean encode) { if (Strings.isNotBlank(service)) return encode ? response.encodeURL(service) : service; final StringBuilder buffer = new StringBuilder(); if (!serverName.startsWith("https://") && !serverName.startsWith("http://")) { buffer.append(request.isSecure() ? "https://" : "http://"); } buffer.append(serverName); buffer.append(request.getContextPath()); buffer.append(localLogin); final String returnValue = encode ? response.encodeURL(buffer.toString()) : buffer.toString(); return returnValue; }
[ "public", "String", "constructLocalLoginServiceUrl", "(", "final", "HttpServletRequest", "request", ",", "final", "HttpServletResponse", "response", ",", "final", "String", "service", ",", "final", "String", "serverName", ",", "final", "String", "artifactParameterName", ",", "final", "boolean", "encode", ")", "{", "if", "(", "Strings", ".", "isNotBlank", "(", "service", ")", ")", "return", "encode", "?", "response", ".", "encodeURL", "(", "service", ")", ":", "service", ";", "final", "StringBuilder", "buffer", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "!", "serverName", ".", "startsWith", "(", "\"https://\"", ")", "&&", "!", "serverName", ".", "startsWith", "(", "\"http://\"", ")", ")", "{", "buffer", ".", "append", "(", "request", ".", "isSecure", "(", ")", "?", "\"https://\"", ":", "\"http://\"", ")", ";", "}", "buffer", ".", "append", "(", "serverName", ")", ";", "buffer", ".", "append", "(", "request", ".", "getContextPath", "(", ")", ")", ";", "buffer", ".", "append", "(", "localLogin", ")", ";", "final", "String", "returnValue", "=", "encode", "?", "response", ".", "encodeURL", "(", "buffer", ".", "toString", "(", ")", ")", ":", "buffer", ".", "toString", "(", ")", ";", "return", "returnValue", ";", "}" ]
Construct local login Service Url @param request @param response @param service @param serverName @param artifactParameterName @param encode
[ "Construct", "local", "login", "Service", "Url" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/security/ids/src/main/java/org/beangle/security/ids/CasEntryPoint.java#L116-L130
142,152
beangle/beangle3
security/ids/src/main/java/org/beangle/security/ids/CasEntryPoint.java
CasEntryPoint.constructServiceUrl
public String constructServiceUrl(final HttpServletRequest request, final HttpServletResponse response, final String service, final String serverName) { if (Strings.isNotBlank(service)) { return response.encodeURL(service); } final StringBuilder buffer = new StringBuilder(); if (!serverName.startsWith("https://") && !serverName.startsWith("http://")) { buffer.append(request.isSecure() ? "https://" : "http://"); } buffer.append(serverName); buffer.append(request.getRequestURI()); Set<String> reservedKeys = CollectUtils.newHashSet(); reservedKeys.add(config.getArtifactName()); if (null != sessionIdReader) { reservedKeys.add(sessionIdReader.idName()); } String queryString = request.getQueryString(); if (Strings.isNotBlank(queryString)) { String[] parts = Strings.split(queryString, "&"); Arrays.sort(parts); StringBuilder paramBuf = new StringBuilder(); for (String part : parts) { int equIdx = part.indexOf('='); if (equIdx > 0) { String key = part.substring(0, equIdx); if (!reservedKeys.contains(key)) { paramBuf.append('&').append(key).append(part.substring(equIdx)); } } } if (paramBuf.length() > 0) { paramBuf.setCharAt(0, '?'); buffer.append(paramBuf); } } return response.encodeURL(buffer.toString()); }
java
public String constructServiceUrl(final HttpServletRequest request, final HttpServletResponse response, final String service, final String serverName) { if (Strings.isNotBlank(service)) { return response.encodeURL(service); } final StringBuilder buffer = new StringBuilder(); if (!serverName.startsWith("https://") && !serverName.startsWith("http://")) { buffer.append(request.isSecure() ? "https://" : "http://"); } buffer.append(serverName); buffer.append(request.getRequestURI()); Set<String> reservedKeys = CollectUtils.newHashSet(); reservedKeys.add(config.getArtifactName()); if (null != sessionIdReader) { reservedKeys.add(sessionIdReader.idName()); } String queryString = request.getQueryString(); if (Strings.isNotBlank(queryString)) { String[] parts = Strings.split(queryString, "&"); Arrays.sort(parts); StringBuilder paramBuf = new StringBuilder(); for (String part : parts) { int equIdx = part.indexOf('='); if (equIdx > 0) { String key = part.substring(0, equIdx); if (!reservedKeys.contains(key)) { paramBuf.append('&').append(key).append(part.substring(equIdx)); } } } if (paramBuf.length() > 0) { paramBuf.setCharAt(0, '?'); buffer.append(paramBuf); } } return response.encodeURL(buffer.toString()); }
[ "public", "String", "constructServiceUrl", "(", "final", "HttpServletRequest", "request", ",", "final", "HttpServletResponse", "response", ",", "final", "String", "service", ",", "final", "String", "serverName", ")", "{", "if", "(", "Strings", ".", "isNotBlank", "(", "service", ")", ")", "{", "return", "response", ".", "encodeURL", "(", "service", ")", ";", "}", "final", "StringBuilder", "buffer", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "!", "serverName", ".", "startsWith", "(", "\"https://\"", ")", "&&", "!", "serverName", ".", "startsWith", "(", "\"http://\"", ")", ")", "{", "buffer", ".", "append", "(", "request", ".", "isSecure", "(", ")", "?", "\"https://\"", ":", "\"http://\"", ")", ";", "}", "buffer", ".", "append", "(", "serverName", ")", ";", "buffer", ".", "append", "(", "request", ".", "getRequestURI", "(", ")", ")", ";", "Set", "<", "String", ">", "reservedKeys", "=", "CollectUtils", ".", "newHashSet", "(", ")", ";", "reservedKeys", ".", "add", "(", "config", ".", "getArtifactName", "(", ")", ")", ";", "if", "(", "null", "!=", "sessionIdReader", ")", "{", "reservedKeys", ".", "add", "(", "sessionIdReader", ".", "idName", "(", ")", ")", ";", "}", "String", "queryString", "=", "request", ".", "getQueryString", "(", ")", ";", "if", "(", "Strings", ".", "isNotBlank", "(", "queryString", ")", ")", "{", "String", "[", "]", "parts", "=", "Strings", ".", "split", "(", "queryString", ",", "\"&\"", ")", ";", "Arrays", ".", "sort", "(", "parts", ")", ";", "StringBuilder", "paramBuf", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "String", "part", ":", "parts", ")", "{", "int", "equIdx", "=", "part", ".", "indexOf", "(", "'", "'", ")", ";", "if", "(", "equIdx", ">", "0", ")", "{", "String", "key", "=", "part", ".", "substring", "(", "0", ",", "equIdx", ")", ";", "if", "(", "!", "reservedKeys", ".", "contains", "(", "key", ")", ")", "{", "paramBuf", ".", "append", "(", "'", "'", ")", ".", "append", "(", "key", ")", ".", "append", "(", "part", ".", "substring", "(", "equIdx", ")", ")", ";", "}", "}", "}", "if", "(", "paramBuf", ".", "length", "(", ")", ">", "0", ")", "{", "paramBuf", ".", "setCharAt", "(", "0", ",", "'", "'", ")", ";", "buffer", ".", "append", "(", "paramBuf", ")", ";", "}", "}", "return", "response", ".", "encodeURL", "(", "buffer", ".", "toString", "(", ")", ")", ";", "}" ]
Constructs a service url from the HttpServletRequest or from the given serviceUrl. Prefers the serviceUrl provided if both a serviceUrl and a serviceName. @param request the HttpServletRequest @param response the HttpServletResponse @param service the configured service url (this will be used if not null) @param serverName the server name to use to constuct the service url if service param is empty @param artifactParameterName the artifact parameter name to remove (i.e. ticket) @param encode whether to encode the url or not (i.e. Jsession). @return the service url to use.
[ "Constructs", "a", "service", "url", "from", "the", "HttpServletRequest", "or", "from", "the", "given", "serviceUrl", ".", "Prefers", "the", "serviceUrl", "provided", "if", "both", "a", "serviceUrl", "and", "a", "serviceName", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/security/ids/src/main/java/org/beangle/security/ids/CasEntryPoint.java#L145-L183
142,153
beangle/beangle3
security/ids/src/main/java/org/beangle/security/ids/CasEntryPoint.java
CasEntryPoint.constructRedirectUrl
public String constructRedirectUrl(final String casServerLoginUrl, final String serviceParameterName, final String serviceUrl, final boolean renew, final boolean gateway) { try { return casServerLoginUrl + (casServerLoginUrl.indexOf("?") != -1 ? "&" : "?") + serviceParameterName + "=" + URLEncoder.encode(serviceUrl, "UTF-8") + (renew ? "&renew=true" : "") + (gateway ? "&gateway=true" : "") + "&" + SessionIdReader.SessionIdName + "=" + sessionIdReader.idName(); } catch (final UnsupportedEncodingException e) { throw new RuntimeException(e); } }
java
public String constructRedirectUrl(final String casServerLoginUrl, final String serviceParameterName, final String serviceUrl, final boolean renew, final boolean gateway) { try { return casServerLoginUrl + (casServerLoginUrl.indexOf("?") != -1 ? "&" : "?") + serviceParameterName + "=" + URLEncoder.encode(serviceUrl, "UTF-8") + (renew ? "&renew=true" : "") + (gateway ? "&gateway=true" : "") + "&" + SessionIdReader.SessionIdName + "=" + sessionIdReader.idName(); } catch (final UnsupportedEncodingException e) { throw new RuntimeException(e); } }
[ "public", "String", "constructRedirectUrl", "(", "final", "String", "casServerLoginUrl", ",", "final", "String", "serviceParameterName", ",", "final", "String", "serviceUrl", ",", "final", "boolean", "renew", ",", "final", "boolean", "gateway", ")", "{", "try", "{", "return", "casServerLoginUrl", "+", "(", "casServerLoginUrl", ".", "indexOf", "(", "\"?\"", ")", "!=", "-", "1", "?", "\"&\"", ":", "\"?\"", ")", "+", "serviceParameterName", "+", "\"=\"", "+", "URLEncoder", ".", "encode", "(", "serviceUrl", ",", "\"UTF-8\"", ")", "+", "(", "renew", "?", "\"&renew=true\"", ":", "\"\"", ")", "+", "(", "gateway", "?", "\"&gateway=true\"", ":", "\"\"", ")", "+", "\"&\"", "+", "SessionIdReader", ".", "SessionIdName", "+", "\"=\"", "+", "sessionIdReader", ".", "idName", "(", ")", ";", "}", "catch", "(", "final", "UnsupportedEncodingException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}" ]
Constructs the URL to use to redirect to the CAS server. @param casServerLoginUrl the CAS Server login url. @param serviceParameterName the name of the parameter that defines the service. @param serviceUrl the actual service's url. @param renew whether we should send renew or not. @param gateway where we should send gateway or not. @return the fully constructed redirect url.
[ "Constructs", "the", "URL", "to", "use", "to", "redirect", "to", "the", "CAS", "server", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/security/ids/src/main/java/org/beangle/security/ids/CasEntryPoint.java#L195-L205
142,154
beangle/beangle3
ioc/spring/src/main/java/org/beangle/inject/spring/web/ServletContextResource.java
ServletContextResource.createRelative
@Override public Resource createRelative(String relativePath) { String pathToUse = StringUtils.applyRelativePath(this.path, relativePath); return new ServletContextResource(this.servletContext, pathToUse); }
java
@Override public Resource createRelative(String relativePath) { String pathToUse = StringUtils.applyRelativePath(this.path, relativePath); return new ServletContextResource(this.servletContext, pathToUse); }
[ "@", "Override", "public", "Resource", "createRelative", "(", "String", "relativePath", ")", "{", "String", "pathToUse", "=", "StringUtils", ".", "applyRelativePath", "(", "this", ".", "path", ",", "relativePath", ")", ";", "return", "new", "ServletContextResource", "(", "this", ".", "servletContext", ",", "pathToUse", ")", ";", "}" ]
This implementation creates a ServletContextResource, applying the given path relative to the path of the underlying file of this resource descriptor.
[ "This", "implementation", "creates", "a", "ServletContextResource", "applying", "the", "given", "path", "relative", "to", "the", "path", "of", "the", "underlying", "file", "of", "this", "resource", "descriptor", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/ioc/spring/src/main/java/org/beangle/inject/spring/web/ServletContextResource.java#L143-L147
142,155
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/lang/Arrays.java
Arrays.join
public static byte[] join(List<byte[]> arrays) { int maxlength = 0; for (byte[] array : arrays) { maxlength += array.length; } byte[] rs = new byte[maxlength]; int pos = 0; for (byte[] array : arrays) { System.arraycopy(array, 0, rs, pos, array.length); pos += array.length; } return rs; }
java
public static byte[] join(List<byte[]> arrays) { int maxlength = 0; for (byte[] array : arrays) { maxlength += array.length; } byte[] rs = new byte[maxlength]; int pos = 0; for (byte[] array : arrays) { System.arraycopy(array, 0, rs, pos, array.length); pos += array.length; } return rs; }
[ "public", "static", "byte", "[", "]", "join", "(", "List", "<", "byte", "[", "]", ">", "arrays", ")", "{", "int", "maxlength", "=", "0", ";", "for", "(", "byte", "[", "]", "array", ":", "arrays", ")", "{", "maxlength", "+=", "array", ".", "length", ";", "}", "byte", "[", "]", "rs", "=", "new", "byte", "[", "maxlength", "]", ";", "int", "pos", "=", "0", ";", "for", "(", "byte", "[", "]", "array", ":", "arrays", ")", "{", "System", ".", "arraycopy", "(", "array", ",", "0", ",", "rs", ",", "pos", ",", "array", ".", "length", ")", ";", "pos", "+=", "array", ".", "length", ";", "}", "return", "rs", ";", "}" ]
join multi array @param arrays @return
[ "join", "multi", "array" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/lang/Arrays.java#L108-L120
142,156
beangle/beangle3
struts/s2/src/main/java/org/beangle/struts2/convention/mapper/ConventionActionMapper.java
ConventionActionMapper.getMapping
public ActionMapping getMapping(HttpServletRequest request, ConfigurationManager configManager) { ActionMapping mapping = new ActionMapping(); parseNameAndNamespace(RequestUtils.getServletPath(request), mapping); String method = request.getParameter(MethodParam); if (Strings.isNotEmpty(method)) mapping.setMethod(method); return mapping; }
java
public ActionMapping getMapping(HttpServletRequest request, ConfigurationManager configManager) { ActionMapping mapping = new ActionMapping(); parseNameAndNamespace(RequestUtils.getServletPath(request), mapping); String method = request.getParameter(MethodParam); if (Strings.isNotEmpty(method)) mapping.setMethod(method); return mapping; }
[ "public", "ActionMapping", "getMapping", "(", "HttpServletRequest", "request", ",", "ConfigurationManager", "configManager", ")", "{", "ActionMapping", "mapping", "=", "new", "ActionMapping", "(", ")", ";", "parseNameAndNamespace", "(", "RequestUtils", ".", "getServletPath", "(", "request", ")", ",", "mapping", ")", ";", "String", "method", "=", "request", ".", "getParameter", "(", "MethodParam", ")", ";", "if", "(", "Strings", ".", "isNotEmpty", "(", "method", ")", ")", "mapping", ".", "setMethod", "(", "method", ")", ";", "return", "mapping", ";", "}" ]
reserved method parameter
[ "reserved", "method", "parameter" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/struts/s2/src/main/java/org/beangle/struts2/convention/mapper/ConventionActionMapper.java#L95-L102
142,157
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/codec/net/BCoder.java
BCoder.encode
public String encode(String value) { if (value == null) { return null; } StringBuilder buffer = new StringBuilder(); buffer.append(Prefix); buffer.append(charset); buffer.append(Sep); buffer.append(getEncoding()); buffer.append(Sep); buffer.append(new String(Base64.encode(value.getBytes(charset)))); buffer.append(Postfix); return buffer.toString(); }
java
public String encode(String value) { if (value == null) { return null; } StringBuilder buffer = new StringBuilder(); buffer.append(Prefix); buffer.append(charset); buffer.append(Sep); buffer.append(getEncoding()); buffer.append(Sep); buffer.append(new String(Base64.encode(value.getBytes(charset)))); buffer.append(Postfix); return buffer.toString(); }
[ "public", "String", "encode", "(", "String", "value", ")", "{", "if", "(", "value", "==", "null", ")", "{", "return", "null", ";", "}", "StringBuilder", "buffer", "=", "new", "StringBuilder", "(", ")", ";", "buffer", ".", "append", "(", "Prefix", ")", ";", "buffer", ".", "append", "(", "charset", ")", ";", "buffer", ".", "append", "(", "Sep", ")", ";", "buffer", ".", "append", "(", "getEncoding", "(", ")", ")", ";", "buffer", ".", "append", "(", "Sep", ")", ";", "buffer", ".", "append", "(", "new", "String", "(", "Base64", ".", "encode", "(", "value", ".", "getBytes", "(", "charset", ")", ")", ")", ")", ";", "buffer", ".", "append", "(", "Postfix", ")", ";", "return", "buffer", ".", "toString", "(", ")", ";", "}" ]
Encodes a string into its Base64 form using the default charset. Unsafe characters are escaped. @param value string to convert to Base64 form @return Base64 string
[ "Encodes", "a", "string", "into", "its", "Base64", "form", "using", "the", "default", "charset", ".", "Unsafe", "characters", "are", "escaped", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/codec/net/BCoder.java#L92-L103
142,158
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/codec/net/BCoder.java
BCoder.decode
public String decode(String text) { if (text == null) { return null; } if ((!text.startsWith(Prefix)) || (!text.endsWith(Postfix))) throw new IllegalArgumentException("RFC 1522 violation: malformed encoded content"); int terminator = text.length() - 2; int from = 2; int to = text.indexOf(Sep, from); if (to == terminator) throw new IllegalArgumentException("RFC 1522 violation: charset token not found"); String charset = text.substring(from, to); if (charset.equals("")) throw new IllegalArgumentException("RFC 1522 violation: charset not specified"); from = to + 1; to = text.indexOf(Sep, from); if (to == terminator) throw new IllegalArgumentException("RFC 1522 violation: encoding token not found"); String encoding = text.substring(from, to); if (!getEncoding().equalsIgnoreCase(encoding)) throw new IllegalArgumentException("This codec cannot decode " + encoding + " encoded content"); from = to + 1; to = text.indexOf(Sep, from); return new String(Base64.decode(text.substring(from, to).toCharArray()), Charset.forName(charset)); }
java
public String decode(String text) { if (text == null) { return null; } if ((!text.startsWith(Prefix)) || (!text.endsWith(Postfix))) throw new IllegalArgumentException("RFC 1522 violation: malformed encoded content"); int terminator = text.length() - 2; int from = 2; int to = text.indexOf(Sep, from); if (to == terminator) throw new IllegalArgumentException("RFC 1522 violation: charset token not found"); String charset = text.substring(from, to); if (charset.equals("")) throw new IllegalArgumentException("RFC 1522 violation: charset not specified"); from = to + 1; to = text.indexOf(Sep, from); if (to == terminator) throw new IllegalArgumentException("RFC 1522 violation: encoding token not found"); String encoding = text.substring(from, to); if (!getEncoding().equalsIgnoreCase(encoding)) throw new IllegalArgumentException("This codec cannot decode " + encoding + " encoded content"); from = to + 1; to = text.indexOf(Sep, from); return new String(Base64.decode(text.substring(from, to).toCharArray()), Charset.forName(charset)); }
[ "public", "String", "decode", "(", "String", "text", ")", "{", "if", "(", "text", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "(", "!", "text", ".", "startsWith", "(", "Prefix", ")", ")", "||", "(", "!", "text", ".", "endsWith", "(", "Postfix", ")", ")", ")", "throw", "new", "IllegalArgumentException", "(", "\"RFC 1522 violation: malformed encoded content\"", ")", ";", "int", "terminator", "=", "text", ".", "length", "(", ")", "-", "2", ";", "int", "from", "=", "2", ";", "int", "to", "=", "text", ".", "indexOf", "(", "Sep", ",", "from", ")", ";", "if", "(", "to", "==", "terminator", ")", "throw", "new", "IllegalArgumentException", "(", "\"RFC 1522 violation: charset token not found\"", ")", ";", "String", "charset", "=", "text", ".", "substring", "(", "from", ",", "to", ")", ";", "if", "(", "charset", ".", "equals", "(", "\"\"", ")", ")", "throw", "new", "IllegalArgumentException", "(", "\"RFC 1522 violation: charset not specified\"", ")", ";", "from", "=", "to", "+", "1", ";", "to", "=", "text", ".", "indexOf", "(", "Sep", ",", "from", ")", ";", "if", "(", "to", "==", "terminator", ")", "throw", "new", "IllegalArgumentException", "(", "\"RFC 1522 violation: encoding token not found\"", ")", ";", "String", "encoding", "=", "text", ".", "substring", "(", "from", ",", "to", ")", ";", "if", "(", "!", "getEncoding", "(", ")", ".", "equalsIgnoreCase", "(", "encoding", ")", ")", "throw", "new", "IllegalArgumentException", "(", "\"This codec cannot decode \"", "+", "encoding", "+", "\" encoded content\"", ")", ";", "from", "=", "to", "+", "1", ";", "to", "=", "text", ".", "indexOf", "(", "Sep", ",", "from", ")", ";", "return", "new", "String", "(", "Base64", ".", "decode", "(", "text", ".", "substring", "(", "from", ",", "to", ")", ".", "toCharArray", "(", ")", ")", ",", "Charset", ".", "forName", "(", "charset", ")", ")", ";", "}" ]
Decodes a Base64 string into its original form. Escaped characters are converted back to their original representation. @param value Base64 string to convert into its original form @return original string
[ "Decodes", "a", "Base64", "string", "into", "its", "original", "form", ".", "Escaped", "characters", "are", "converted", "back", "to", "their", "original", "representation", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/codec/net/BCoder.java#L113-L132
142,159
beangle/beangle3
commons/web/src/main/java/org/beangle/commons/web/util/CookieUtils.java
CookieUtils.getCookie
public static Cookie getCookie(HttpServletRequest request, String name) { Cookie[] cookies = request.getCookies(); Cookie returnCookie = null; if (cookies == null) { return returnCookie; } for (int i = 0; i < cookies.length; i++) { Cookie thisCookie = cookies[i]; if (thisCookie.getName().equals(name) && !thisCookie.getValue().equals("")) { returnCookie = thisCookie; break; } } return returnCookie; }
java
public static Cookie getCookie(HttpServletRequest request, String name) { Cookie[] cookies = request.getCookies(); Cookie returnCookie = null; if (cookies == null) { return returnCookie; } for (int i = 0; i < cookies.length; i++) { Cookie thisCookie = cookies[i]; if (thisCookie.getName().equals(name) && !thisCookie.getValue().equals("")) { returnCookie = thisCookie; break; } } return returnCookie; }
[ "public", "static", "Cookie", "getCookie", "(", "HttpServletRequest", "request", ",", "String", "name", ")", "{", "Cookie", "[", "]", "cookies", "=", "request", ".", "getCookies", "(", ")", ";", "Cookie", "returnCookie", "=", "null", ";", "if", "(", "cookies", "==", "null", ")", "{", "return", "returnCookie", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "cookies", ".", "length", ";", "i", "++", ")", "{", "Cookie", "thisCookie", "=", "cookies", "[", "i", "]", ";", "if", "(", "thisCookie", ".", "getName", "(", ")", ".", "equals", "(", "name", ")", "&&", "!", "thisCookie", ".", "getValue", "(", ")", ".", "equals", "(", "\"\"", ")", ")", "{", "returnCookie", "=", "thisCookie", ";", "break", ";", "}", "}", "return", "returnCookie", ";", "}" ]
Convenience method to get a cookie by name @param request the current request @param name the name of the cookie to find @return the cookie (if found), null if not found
[ "Convenience", "method", "to", "get", "a", "cookie", "by", "name" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/web/src/main/java/org/beangle/commons/web/util/CookieUtils.java#L83-L96
142,160
beangle/beangle3
commons/web/src/main/java/org/beangle/commons/web/util/CookieUtils.java
CookieUtils.deleteCookie
public static void deleteCookie(HttpServletResponse response, Cookie cookie, String path) { if (cookie != null) { // Delete the cookie by setting its maximum age to zero cookie.setMaxAge(0); cookie.setPath(path); response.addCookie(cookie); } }
java
public static void deleteCookie(HttpServletResponse response, Cookie cookie, String path) { if (cookie != null) { // Delete the cookie by setting its maximum age to zero cookie.setMaxAge(0); cookie.setPath(path); response.addCookie(cookie); } }
[ "public", "static", "void", "deleteCookie", "(", "HttpServletResponse", "response", ",", "Cookie", "cookie", ",", "String", "path", ")", "{", "if", "(", "cookie", "!=", "null", ")", "{", "// Delete the cookie by setting its maximum age to zero", "cookie", ".", "setMaxAge", "(", "0", ")", ";", "cookie", ".", "setPath", "(", "path", ")", ";", "response", ".", "addCookie", "(", "cookie", ")", ";", "}", "}" ]
Convenience method for deleting a cookie by name @param response the current web response @param cookie the cookie to delete @param path the path on which the cookie was set (i.e. /appfuse)
[ "Convenience", "method", "for", "deleting", "a", "cookie", "by", "name" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/web/src/main/java/org/beangle/commons/web/util/CookieUtils.java#L156-L163
142,161
beangle/beangle3
commons/web/src/main/java/org/beangle/commons/web/resource/filter/HeaderFilter.java
HeaderFilter.lastModified
private long lastModified(URL url) { if (url.getProtocol().equals("file")) { return new File(url.getFile()).lastModified(); } else { try { URLConnection conn = url.openConnection(); if (conn instanceof JarURLConnection) { URL jarURL = ((JarURLConnection) conn).getJarFileURL(); if (jarURL.getProtocol().equals("file")) { return new File(jarURL.getFile()).lastModified(); } } } catch (IOException e1) { return -1; } return -1; } }
java
private long lastModified(URL url) { if (url.getProtocol().equals("file")) { return new File(url.getFile()).lastModified(); } else { try { URLConnection conn = url.openConnection(); if (conn instanceof JarURLConnection) { URL jarURL = ((JarURLConnection) conn).getJarFileURL(); if (jarURL.getProtocol().equals("file")) { return new File(jarURL.getFile()).lastModified(); } } } catch (IOException e1) { return -1; } return -1; } }
[ "private", "long", "lastModified", "(", "URL", "url", ")", "{", "if", "(", "url", ".", "getProtocol", "(", ")", ".", "equals", "(", "\"file\"", ")", ")", "{", "return", "new", "File", "(", "url", ".", "getFile", "(", ")", ")", ".", "lastModified", "(", ")", ";", "}", "else", "{", "try", "{", "URLConnection", "conn", "=", "url", ".", "openConnection", "(", ")", ";", "if", "(", "conn", "instanceof", "JarURLConnection", ")", "{", "URL", "jarURL", "=", "(", "(", "JarURLConnection", ")", "conn", ")", ".", "getJarFileURL", "(", ")", ";", "if", "(", "jarURL", ".", "getProtocol", "(", ")", ".", "equals", "(", "\"file\"", ")", ")", "{", "return", "new", "File", "(", "jarURL", ".", "getFile", "(", ")", ")", ".", "lastModified", "(", ")", ";", "}", "}", "}", "catch", "(", "IOException", "e1", ")", "{", "return", "-", "1", ";", "}", "return", "-", "1", ";", "}", "}" ]
Return url's last modified date time. saves some opening and closing
[ "Return", "url", "s", "last", "modified", "date", "time", ".", "saves", "some", "opening", "and", "closing" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/web/src/main/java/org/beangle/commons/web/resource/filter/HeaderFilter.java#L76-L91
142,162
beangle/beangle3
struts/s2/src/main/java/org/beangle/struts2/view/component/UIBean.java
UIBean.processLabel
protected String processLabel(String label, String name) { if (null != label) { if (Strings.isEmpty(label)) return null; else return getText(label); } else return getText(name); }
java
protected String processLabel(String label, String name) { if (null != label) { if (Strings.isEmpty(label)) return null; else return getText(label); } else return getText(name); }
[ "protected", "String", "processLabel", "(", "String", "label", ",", "String", "name", ")", "{", "if", "(", "null", "!=", "label", ")", "{", "if", "(", "Strings", ".", "isEmpty", "(", "label", ")", ")", "return", "null", ";", "else", "return", "getText", "(", "label", ")", ";", "}", "else", "return", "getText", "(", "name", ")", ";", "}" ]
Process label,convert empty to null @param label @param name @return
[ "Process", "label", "convert", "empty", "to", "null" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/struts/s2/src/main/java/org/beangle/struts2/view/component/UIBean.java#L191-L196
142,163
beangle/beangle3
struts/s2/src/main/java/org/beangle/struts2/action/EntityDrivenAction.java
EntityDrivenAction.edit
public String edit() { Entity<?> entity = getEntity(); put(getShortName(), entity); editSetting(entity); return forward(); }
java
public String edit() { Entity<?> entity = getEntity(); put(getShortName(), entity); editSetting(entity); return forward(); }
[ "public", "String", "edit", "(", ")", "{", "Entity", "<", "?", ">", "entity", "=", "getEntity", "(", ")", ";", "put", "(", "getShortName", "(", ")", ",", "entity", ")", ";", "editSetting", "(", "entity", ")", ";", "return", "forward", "(", ")", ";", "}" ]
Edit by entity.id or id
[ "Edit", "by", "entity", ".", "id", "or", "id" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/struts/s2/src/main/java/org/beangle/struts2/action/EntityDrivenAction.java#L144-L149
142,164
beangle/beangle3
commons/model/src/main/java/org/beangle/commons/dao/query/builder/OqlBuilder.java
OqlBuilder.findIndexOfFrom
private int findIndexOfFrom(String query) { if (query.startsWith("from")) return 0; int fromIdx = query.indexOf(" from "); if (-1 == fromIdx) return -1; final int first = query.substring(0, fromIdx).indexOf("("); if (first > 0) { int leftCnt = 1; int i = first + 1; while (leftCnt != 0 && i < query.length()) { if (query.charAt(i) == '(') leftCnt++; else if (query.charAt(i) == ')') leftCnt--; i++; } if (leftCnt > 0) return -1; else { fromIdx = query.indexOf(" from ", i); return (fromIdx == -1) ? -1 : fromIdx + 1; } } else { return fromIdx + 1; } }
java
private int findIndexOfFrom(String query) { if (query.startsWith("from")) return 0; int fromIdx = query.indexOf(" from "); if (-1 == fromIdx) return -1; final int first = query.substring(0, fromIdx).indexOf("("); if (first > 0) { int leftCnt = 1; int i = first + 1; while (leftCnt != 0 && i < query.length()) { if (query.charAt(i) == '(') leftCnt++; else if (query.charAt(i) == ')') leftCnt--; i++; } if (leftCnt > 0) return -1; else { fromIdx = query.indexOf(" from ", i); return (fromIdx == -1) ? -1 : fromIdx + 1; } } else { return fromIdx + 1; } }
[ "private", "int", "findIndexOfFrom", "(", "String", "query", ")", "{", "if", "(", "query", ".", "startsWith", "(", "\"from\"", ")", ")", "return", "0", ";", "int", "fromIdx", "=", "query", ".", "indexOf", "(", "\" from \"", ")", ";", "if", "(", "-", "1", "==", "fromIdx", ")", "return", "-", "1", ";", "final", "int", "first", "=", "query", ".", "substring", "(", "0", ",", "fromIdx", ")", ".", "indexOf", "(", "\"(\"", ")", ";", "if", "(", "first", ">", "0", ")", "{", "int", "leftCnt", "=", "1", ";", "int", "i", "=", "first", "+", "1", ";", "while", "(", "leftCnt", "!=", "0", "&&", "i", "<", "query", ".", "length", "(", ")", ")", "{", "if", "(", "query", ".", "charAt", "(", "i", ")", "==", "'", "'", ")", "leftCnt", "++", ";", "else", "if", "(", "query", ".", "charAt", "(", "i", ")", "==", "'", "'", ")", "leftCnt", "--", ";", "i", "++", ";", "}", "if", "(", "leftCnt", ">", "0", ")", "return", "-", "1", ";", "else", "{", "fromIdx", "=", "query", ".", "indexOf", "(", "\" from \"", ",", "i", ")", ";", "return", "(", "fromIdx", "==", "-", "1", ")", "?", "-", "1", ":", "fromIdx", "+", "1", ";", "}", "}", "else", "{", "return", "fromIdx", "+", "1", ";", "}", "}" ]
Find index of from @param query @return -1 or from index
[ "Find", "index", "of", "from" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/model/src/main/java/org/beangle/commons/dao/query/builder/OqlBuilder.java#L466-L487
142,165
massfords/jaxb-visitor
src/main/java/com/massfords/jaxb/CreateDepthFirstTraverserClass.java
CreateDepthFirstTraverserClass.getTraversableStrategy
private TraversableCodeGenStrategy getTraversableStrategy(JType rawType, Map<String,JClass> directClasses) { if (rawType.isPrimitive()) { // primitive types are never traversable return TraversableCodeGenStrategy.NO; } JClass clazz = (JClass) rawType; if (clazz.isParameterized()) { // if it's a parameterized type, then we should use the parameter clazz = clazz.getTypeParameters().get(0); if (clazz.name().startsWith("?")) { // when we have a wildcard we should use the bounding class. clazz = clazz._extends(); } } String name = clazz.fullName(); if (name.equals("java.lang.Object")) { // it could be anything so we'll test with an instanceof in the generated code return TraversableCodeGenStrategy.MAYBE; } else if (clazz.isInterface()) { // if it is an interface (like Serializable) it could also be anything // handle it like java.lang.Object return TraversableCodeGenStrategy.MAYBE; } else if (visitable.isAssignableFrom(clazz)) { // it's a real type. if it's one of ours, then it'll be assignable from Visitable return TraversableCodeGenStrategy.VISITABLE; } else if (directClasses.containsKey(name)) { return TraversableCodeGenStrategy.DIRECT; } else { return TraversableCodeGenStrategy.NO; } }
java
private TraversableCodeGenStrategy getTraversableStrategy(JType rawType, Map<String,JClass> directClasses) { if (rawType.isPrimitive()) { // primitive types are never traversable return TraversableCodeGenStrategy.NO; } JClass clazz = (JClass) rawType; if (clazz.isParameterized()) { // if it's a parameterized type, then we should use the parameter clazz = clazz.getTypeParameters().get(0); if (clazz.name().startsWith("?")) { // when we have a wildcard we should use the bounding class. clazz = clazz._extends(); } } String name = clazz.fullName(); if (name.equals("java.lang.Object")) { // it could be anything so we'll test with an instanceof in the generated code return TraversableCodeGenStrategy.MAYBE; } else if (clazz.isInterface()) { // if it is an interface (like Serializable) it could also be anything // handle it like java.lang.Object return TraversableCodeGenStrategy.MAYBE; } else if (visitable.isAssignableFrom(clazz)) { // it's a real type. if it's one of ours, then it'll be assignable from Visitable return TraversableCodeGenStrategy.VISITABLE; } else if (directClasses.containsKey(name)) { return TraversableCodeGenStrategy.DIRECT; } else { return TraversableCodeGenStrategy.NO; } }
[ "private", "TraversableCodeGenStrategy", "getTraversableStrategy", "(", "JType", "rawType", ",", "Map", "<", "String", ",", "JClass", ">", "directClasses", ")", "{", "if", "(", "rawType", ".", "isPrimitive", "(", ")", ")", "{", "// primitive types are never traversable", "return", "TraversableCodeGenStrategy", ".", "NO", ";", "}", "JClass", "clazz", "=", "(", "JClass", ")", "rawType", ";", "if", "(", "clazz", ".", "isParameterized", "(", ")", ")", "{", "// if it's a parameterized type, then we should use the parameter", "clazz", "=", "clazz", ".", "getTypeParameters", "(", ")", ".", "get", "(", "0", ")", ";", "if", "(", "clazz", ".", "name", "(", ")", ".", "startsWith", "(", "\"?\"", ")", ")", "{", "// when we have a wildcard we should use the bounding class.", "clazz", "=", "clazz", ".", "_extends", "(", ")", ";", "}", "}", "String", "name", "=", "clazz", ".", "fullName", "(", ")", ";", "if", "(", "name", ".", "equals", "(", "\"java.lang.Object\"", ")", ")", "{", "// it could be anything so we'll test with an instanceof in the generated code", "return", "TraversableCodeGenStrategy", ".", "MAYBE", ";", "}", "else", "if", "(", "clazz", ".", "isInterface", "(", ")", ")", "{", "// if it is an interface (like Serializable) it could also be anything", "// handle it like java.lang.Object", "return", "TraversableCodeGenStrategy", ".", "MAYBE", ";", "}", "else", "if", "(", "visitable", ".", "isAssignableFrom", "(", "clazz", ")", ")", "{", "// it's a real type. if it's one of ours, then it'll be assignable from Visitable", "return", "TraversableCodeGenStrategy", ".", "VISITABLE", ";", "}", "else", "if", "(", "directClasses", ".", "containsKey", "(", "name", ")", ")", "{", "return", "TraversableCodeGenStrategy", ".", "DIRECT", ";", "}", "else", "{", "return", "TraversableCodeGenStrategy", ".", "NO", ";", "}", "}" ]
Tests to see if the rawType is traversable @return TraversableCodeGenStrategy VISITABLE, NO, MAYBE, DIRECT @param rawType
[ "Tests", "to", "see", "if", "the", "rawType", "is", "traversable" ]
0d66cd4d8b6700b5eb67c028a87b53792be895b8
https://github.com/massfords/jaxb-visitor/blob/0d66cd4d8b6700b5eb67c028a87b53792be895b8/src/main/java/com/massfords/jaxb/CreateDepthFirstTraverserClass.java#L149-L180
142,166
beangle/beangle3
commons/web/src/main/java/org/beangle/commons/http/agent/Os.java
Os.parse
public static Os parse(String agentString) { if (Strings.isEmpty(agentString)) { return Os.UNKNOWN; } for (OsCategory category : OsCategory.values()) { String version = category.match(agentString); if (version != null) { String key = category.getName() + "/" + version; Os os = osMap.get(key); if (null == os) { os = new Os(category, version); osMap.put(key, os); } return os; } } return Os.UNKNOWN; }
java
public static Os parse(String agentString) { if (Strings.isEmpty(agentString)) { return Os.UNKNOWN; } for (OsCategory category : OsCategory.values()) { String version = category.match(agentString); if (version != null) { String key = category.getName() + "/" + version; Os os = osMap.get(key); if (null == os) { os = new Os(category, version); osMap.put(key, os); } return os; } } return Os.UNKNOWN; }
[ "public", "static", "Os", "parse", "(", "String", "agentString", ")", "{", "if", "(", "Strings", ".", "isEmpty", "(", "agentString", ")", ")", "{", "return", "Os", ".", "UNKNOWN", ";", "}", "for", "(", "OsCategory", "category", ":", "OsCategory", ".", "values", "(", ")", ")", "{", "String", "version", "=", "category", ".", "match", "(", "agentString", ")", ";", "if", "(", "version", "!=", "null", ")", "{", "String", "key", "=", "category", ".", "getName", "(", ")", "+", "\"/\"", "+", "version", ";", "Os", "os", "=", "osMap", ".", "get", "(", "key", ")", ";", "if", "(", "null", "==", "os", ")", "{", "os", "=", "new", "Os", "(", "category", ",", "version", ")", ";", "osMap", ".", "put", "(", "key", ",", "os", ")", ";", "}", "return", "os", ";", "}", "}", "return", "Os", ".", "UNKNOWN", ";", "}" ]
Parses user agent string and returns the best match. Returns Os.UNKNOWN if there is no match. @param agentString @return Os
[ "Parses", "user", "agent", "string", "and", "returns", "the", "best", "match", ".", "Returns", "Os", ".", "UNKNOWN", "if", "there", "is", "no", "match", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/web/src/main/java/org/beangle/commons/http/agent/Os.java#L55-L70
142,167
beangle/beangle3
struts/s2/src/main/java/org/beangle/struts2/view/template/FreemarkerTemplateEngine.java
FreemarkerTemplateEngine.getTemplate
private Template getTemplate(String templateName) throws ParseException { try { return config.getTemplate(templateName, "UTF-8"); } catch (ParseException e) { throw e; } catch (IOException e) { logger.error("Couldn't load template '{}',loader is {}", templateName, config.getTemplateLoader().getClass()); throw Throwables.propagate(e); } }
java
private Template getTemplate(String templateName) throws ParseException { try { return config.getTemplate(templateName, "UTF-8"); } catch (ParseException e) { throw e; } catch (IOException e) { logger.error("Couldn't load template '{}',loader is {}", templateName, config.getTemplateLoader().getClass()); throw Throwables.propagate(e); } }
[ "private", "Template", "getTemplate", "(", "String", "templateName", ")", "throws", "ParseException", "{", "try", "{", "return", "config", ".", "getTemplate", "(", "templateName", ",", "\"UTF-8\"", ")", ";", "}", "catch", "(", "ParseException", "e", ")", "{", "throw", "e", ";", "}", "catch", "(", "IOException", "e", ")", "{", "logger", ".", "error", "(", "\"Couldn't load template '{}',loader is {}\"", ",", "templateName", ",", "config", ".", "getTemplateLoader", "(", ")", ".", "getClass", "(", ")", ")", ";", "throw", "Throwables", ".", "propagate", "(", "e", ")", ";", "}", "}" ]
Load template in hierarchical path @param templateName @throws Exception
[ "Load", "template", "in", "hierarchical", "path" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/struts/s2/src/main/java/org/beangle/struts2/view/template/FreemarkerTemplateEngine.java#L113-L123
142,168
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/conversion/impl/ConverterFactory.java
ConverterFactory.getConverter
@SuppressWarnings("unchecked") public <T extends R> Converter<S, T> getConverter(Class<T> targetType) { return (Converter<S, T>) converters.get(targetType); }
java
@SuppressWarnings("unchecked") public <T extends R> Converter<S, T> getConverter(Class<T> targetType) { return (Converter<S, T>) converters.get(targetType); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", "extends", "R", ">", "Converter", "<", "S", ",", "T", ">", "getConverter", "(", "Class", "<", "T", ">", "targetType", ")", "{", "return", "(", "Converter", "<", "S", ",", "T", ">", ")", "converters", ".", "get", "(", "targetType", ")", ";", "}" ]
Return convert from S to T
[ "Return", "convert", "from", "S", "to", "T" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/conversion/impl/ConverterFactory.java#L43-L46
142,169
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/bean/PropertyNameResolver.java
PropertyNameResolver.getIndex
public int getIndex(String expression) { if (expression == null || expression.length() == 0) { return -1; } for (int i = 0; i < expression.length(); i++) { char c = expression.charAt(i); if (c == Nested || c == MappedStart) { return -1; } else if (c == IndexedStart) { int end = expression.indexOf(IndexedEnd, i); if (end < 0) { throw new IllegalArgumentException("Missing End Delimiter"); } String value = expression.substring(i + 1, end); if (value.length() == 0) { throw new IllegalArgumentException("No Index Value"); } int index = 0; try { index = Integer.parseInt(value, 10); } catch (Exception e) { throw new IllegalArgumentException("Invalid index value '" + value + "'"); } return index; } } return -1; }
java
public int getIndex(String expression) { if (expression == null || expression.length() == 0) { return -1; } for (int i = 0; i < expression.length(); i++) { char c = expression.charAt(i); if (c == Nested || c == MappedStart) { return -1; } else if (c == IndexedStart) { int end = expression.indexOf(IndexedEnd, i); if (end < 0) { throw new IllegalArgumentException("Missing End Delimiter"); } String value = expression.substring(i + 1, end); if (value.length() == 0) { throw new IllegalArgumentException("No Index Value"); } int index = 0; try { index = Integer.parseInt(value, 10); } catch (Exception e) { throw new IllegalArgumentException("Invalid index value '" + value + "'"); } return index; } } return -1; }
[ "public", "int", "getIndex", "(", "String", "expression", ")", "{", "if", "(", "expression", "==", "null", "||", "expression", ".", "length", "(", ")", "==", "0", ")", "{", "return", "-", "1", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "expression", ".", "length", "(", ")", ";", "i", "++", ")", "{", "char", "c", "=", "expression", ".", "charAt", "(", "i", ")", ";", "if", "(", "c", "==", "Nested", "||", "c", "==", "MappedStart", ")", "{", "return", "-", "1", ";", "}", "else", "if", "(", "c", "==", "IndexedStart", ")", "{", "int", "end", "=", "expression", ".", "indexOf", "(", "IndexedEnd", ",", "i", ")", ";", "if", "(", "end", "<", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Missing End Delimiter\"", ")", ";", "}", "String", "value", "=", "expression", ".", "substring", "(", "i", "+", "1", ",", "end", ")", ";", "if", "(", "value", ".", "length", "(", ")", "==", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"No Index Value\"", ")", ";", "}", "int", "index", "=", "0", ";", "try", "{", "index", "=", "Integer", ".", "parseInt", "(", "value", ",", "10", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Invalid index value '\"", "+", "value", "+", "\"'\"", ")", ";", "}", "return", "index", ";", "}", "}", "return", "-", "1", ";", "}" ]
Return the index value from the property expression or -1. @param expression The property expression @return The index value or -1 if the property is not indexed @throws IllegalArgumentException If the indexed property is illegally formed or has an invalid (non-numeric) value.
[ "Return", "the", "index", "value", "from", "the", "property", "expression", "or", "-", "1", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/bean/PropertyNameResolver.java#L61-L82
142,170
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/bean/PropertyNameResolver.java
PropertyNameResolver.getProperty
public String getProperty(String expression) { if (expression == null || expression.length() == 0) { return expression; } for (int i = 0; i < expression.length(); i++) { char c = expression.charAt(i); if (c == Nested) { return expression.substring(0, i); } else if (c == MappedStart || c == IndexedStart) { return expression.substring(0, i); } } return expression; }
java
public String getProperty(String expression) { if (expression == null || expression.length() == 0) { return expression; } for (int i = 0; i < expression.length(); i++) { char c = expression.charAt(i); if (c == Nested) { return expression.substring(0, i); } else if (c == MappedStart || c == IndexedStart) { return expression.substring(0, i); } } return expression; }
[ "public", "String", "getProperty", "(", "String", "expression", ")", "{", "if", "(", "expression", "==", "null", "||", "expression", ".", "length", "(", ")", "==", "0", ")", "{", "return", "expression", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "expression", ".", "length", "(", ")", ";", "i", "++", ")", "{", "char", "c", "=", "expression", ".", "charAt", "(", "i", ")", ";", "if", "(", "c", "==", "Nested", ")", "{", "return", "expression", ".", "substring", "(", "0", ",", "i", ")", ";", "}", "else", "if", "(", "c", "==", "MappedStart", "||", "c", "==", "IndexedStart", ")", "{", "return", "expression", ".", "substring", "(", "0", ",", "i", ")", ";", "}", "}", "return", "expression", ";", "}" ]
Return the property name from the property expression. @param expression The property expression @return The property name
[ "Return", "the", "property", "name", "from", "the", "property", "expression", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/bean/PropertyNameResolver.java#L112-L121
142,171
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/bean/PropertyNameResolver.java
PropertyNameResolver.hasNested
public boolean hasNested(String expression) { if (expression == null || expression.length() == 0) return false; else return remove(expression) != null; }
java
public boolean hasNested(String expression) { if (expression == null || expression.length() == 0) return false; else return remove(expression) != null; }
[ "public", "boolean", "hasNested", "(", "String", "expression", ")", "{", "if", "(", "expression", "==", "null", "||", "expression", ".", "length", "(", ")", "==", "0", ")", "return", "false", ";", "else", "return", "remove", "(", "expression", ")", "!=", "null", ";", "}" ]
Indicates whether or not the expression contains nested property expressions or not. @param expression The property expression @return The next property expression
[ "Indicates", "whether", "or", "not", "the", "expression", "contains", "nested", "property", "expressions", "or", "not", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/bean/PropertyNameResolver.java#L129-L133
142,172
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/bean/PropertyNameResolver.java
PropertyNameResolver.isIndexed
public boolean isIndexed(String expression) { if (expression == null || expression.length() == 0) { return false; } for (int i = 0; i < expression.length(); i++) { char c = expression.charAt(i); if (c == Nested || c == MappedStart) { return false; } else if (c == IndexedStart) { return true; } } return false; }
java
public boolean isIndexed(String expression) { if (expression == null || expression.length() == 0) { return false; } for (int i = 0; i < expression.length(); i++) { char c = expression.charAt(i); if (c == Nested || c == MappedStart) { return false; } else if (c == IndexedStart) { return true; } } return false; }
[ "public", "boolean", "isIndexed", "(", "String", "expression", ")", "{", "if", "(", "expression", "==", "null", "||", "expression", ".", "length", "(", ")", "==", "0", ")", "{", "return", "false", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "expression", ".", "length", "(", ")", ";", "i", "++", ")", "{", "char", "c", "=", "expression", ".", "charAt", "(", "i", ")", ";", "if", "(", "c", "==", "Nested", "||", "c", "==", "MappedStart", ")", "{", "return", "false", ";", "}", "else", "if", "(", "c", "==", "IndexedStart", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Indicate whether the expression is for an indexed property or not. @param expression The property expression @return <code>true</code> if the expresion is indexed, otherwise <code>false</code>
[ "Indicate", "whether", "the", "expression", "is", "for", "an", "indexed", "property", "or", "not", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/bean/PropertyNameResolver.java#L142-L151
142,173
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/bean/PropertyNameResolver.java
PropertyNameResolver.next
public String next(String expression) { if (expression == null || expression.length() == 0) { return null; } boolean indexed = false; boolean mapped = false; for (int i = 0; i < expression.length(); i++) { char c = expression.charAt(i); if (indexed) { if (c == IndexedEnd) { return expression.substring(0, i + 1); } } else if (mapped) { if (c == MappedEnd) { return expression.substring(0, i + 1); } } else { if (c == Nested) { return expression.substring(0, i); } else if (c == MappedStart) { mapped = true; } else if (c == IndexedStart) { indexed = true; } } } return expression; }
java
public String next(String expression) { if (expression == null || expression.length() == 0) { return null; } boolean indexed = false; boolean mapped = false; for (int i = 0; i < expression.length(); i++) { char c = expression.charAt(i); if (indexed) { if (c == IndexedEnd) { return expression.substring(0, i + 1); } } else if (mapped) { if (c == MappedEnd) { return expression.substring(0, i + 1); } } else { if (c == Nested) { return expression.substring(0, i); } else if (c == MappedStart) { mapped = true; } else if (c == IndexedStart) { indexed = true; } } } return expression; }
[ "public", "String", "next", "(", "String", "expression", ")", "{", "if", "(", "expression", "==", "null", "||", "expression", ".", "length", "(", ")", "==", "0", ")", "{", "return", "null", ";", "}", "boolean", "indexed", "=", "false", ";", "boolean", "mapped", "=", "false", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "expression", ".", "length", "(", ")", ";", "i", "++", ")", "{", "char", "c", "=", "expression", ".", "charAt", "(", "i", ")", ";", "if", "(", "indexed", ")", "{", "if", "(", "c", "==", "IndexedEnd", ")", "{", "return", "expression", ".", "substring", "(", "0", ",", "i", "+", "1", ")", ";", "}", "}", "else", "if", "(", "mapped", ")", "{", "if", "(", "c", "==", "MappedEnd", ")", "{", "return", "expression", ".", "substring", "(", "0", ",", "i", "+", "1", ")", ";", "}", "}", "else", "{", "if", "(", "c", "==", "Nested", ")", "{", "return", "expression", ".", "substring", "(", "0", ",", "i", ")", ";", "}", "else", "if", "(", "c", "==", "MappedStart", ")", "{", "mapped", "=", "true", ";", "}", "else", "if", "(", "c", "==", "IndexedStart", ")", "{", "indexed", "=", "true", ";", "}", "}", "}", "return", "expression", ";", "}" ]
Extract the next property expression from the current expression. @param expression The property expression @return The next property expression
[ "Extract", "the", "next", "property", "expression", "from", "the", "current", "expression", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/bean/PropertyNameResolver.java#L177-L198
142,174
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/bean/PropertyNameResolver.java
PropertyNameResolver.remove
public String remove(String expression) { if (expression == null || expression.length() == 0) { return null; } String property = next(expression); if (expression.length() == property.length()) { return null; } int start = property.length(); if (expression.charAt(start) == Nested) start++; return expression.substring(start); }
java
public String remove(String expression) { if (expression == null || expression.length() == 0) { return null; } String property = next(expression); if (expression.length() == property.length()) { return null; } int start = property.length(); if (expression.charAt(start) == Nested) start++; return expression.substring(start); }
[ "public", "String", "remove", "(", "String", "expression", ")", "{", "if", "(", "expression", "==", "null", "||", "expression", ".", "length", "(", ")", "==", "0", ")", "{", "return", "null", ";", "}", "String", "property", "=", "next", "(", "expression", ")", ";", "if", "(", "expression", ".", "length", "(", ")", "==", "property", ".", "length", "(", ")", ")", "{", "return", "null", ";", "}", "int", "start", "=", "property", ".", "length", "(", ")", ";", "if", "(", "expression", ".", "charAt", "(", "start", ")", "==", "Nested", ")", "start", "++", ";", "return", "expression", ".", "substring", "(", "start", ")", ";", "}" ]
Remove the last property expresson from the current expression. @param expression The property expression @return The new expression value, with first property expression removed - null if there are no more expressions
[ "Remove", "the", "last", "property", "expresson", "from", "the", "current", "expression", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/bean/PropertyNameResolver.java#L207-L214
142,175
beangle/beangle3
orm/hibernate/src/main/java/org/beangle/orm/hibernate/internal/HibernateEntityContext.java
HibernateEntityContext.initFrom
public void initFrom(SessionFactory sessionFactory) { Assert.notNull(sessionFactory); Stopwatch watch = new Stopwatch().start(); Map<String, ClassMetadata> classMetadatas = sessionFactory.getAllClassMetadata(); int entityCount = entityTypes.size(); int collectionCount = collectionTypes.size(); for (Iterator<ClassMetadata> iter = classMetadatas.values().iterator(); iter.hasNext();) { ClassMetadata cm = (ClassMetadata) iter.next(); buildEntityType(sessionFactory, cm.getEntityName()); } logger.info("Find {} entities,{} collections from hibernate in {}", new Object[] { entityTypes.size() - entityCount, collectionTypes.size() - collectionCount, watch }); if (logger.isDebugEnabled()) loggerTypeInfo(); collectionTypes.clear(); }
java
public void initFrom(SessionFactory sessionFactory) { Assert.notNull(sessionFactory); Stopwatch watch = new Stopwatch().start(); Map<String, ClassMetadata> classMetadatas = sessionFactory.getAllClassMetadata(); int entityCount = entityTypes.size(); int collectionCount = collectionTypes.size(); for (Iterator<ClassMetadata> iter = classMetadatas.values().iterator(); iter.hasNext();) { ClassMetadata cm = (ClassMetadata) iter.next(); buildEntityType(sessionFactory, cm.getEntityName()); } logger.info("Find {} entities,{} collections from hibernate in {}", new Object[] { entityTypes.size() - entityCount, collectionTypes.size() - collectionCount, watch }); if (logger.isDebugEnabled()) loggerTypeInfo(); collectionTypes.clear(); }
[ "public", "void", "initFrom", "(", "SessionFactory", "sessionFactory", ")", "{", "Assert", ".", "notNull", "(", "sessionFactory", ")", ";", "Stopwatch", "watch", "=", "new", "Stopwatch", "(", ")", ".", "start", "(", ")", ";", "Map", "<", "String", ",", "ClassMetadata", ">", "classMetadatas", "=", "sessionFactory", ".", "getAllClassMetadata", "(", ")", ";", "int", "entityCount", "=", "entityTypes", ".", "size", "(", ")", ";", "int", "collectionCount", "=", "collectionTypes", ".", "size", "(", ")", ";", "for", "(", "Iterator", "<", "ClassMetadata", ">", "iter", "=", "classMetadatas", ".", "values", "(", ")", ".", "iterator", "(", ")", ";", "iter", ".", "hasNext", "(", ")", ";", ")", "{", "ClassMetadata", "cm", "=", "(", "ClassMetadata", ")", "iter", ".", "next", "(", ")", ";", "buildEntityType", "(", "sessionFactory", ",", "cm", ".", "getEntityName", "(", ")", ")", ";", "}", "logger", ".", "info", "(", "\"Find {} entities,{} collections from hibernate in {}\"", ",", "new", "Object", "[", "]", "{", "entityTypes", ".", "size", "(", ")", "-", "entityCount", ",", "collectionTypes", ".", "size", "(", ")", "-", "collectionCount", ",", "watch", "}", ")", ";", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "loggerTypeInfo", "(", ")", ";", "collectionTypes", ".", "clear", "(", ")", ";", "}" ]
Build context from session factory
[ "Build", "context", "from", "session", "factory" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/orm/hibernate/src/main/java/org/beangle/orm/hibernate/internal/HibernateEntityContext.java#L57-L71
142,176
beangle/beangle3
struts/s2/src/main/java/org/beangle/struts2/convention/Flash.java
Flash.put
public Object put(Object key, Object value) { return next.put(key, value); }
java
public Object put(Object key, Object value) { return next.put(key, value); }
[ "public", "Object", "put", "(", "Object", "key", ",", "Object", "value", ")", "{", "return", "next", ".", "put", "(", "key", ",", "value", ")", ";", "}" ]
put value to next @param key @param value
[ "put", "value", "to", "next" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/struts/s2/src/main/java/org/beangle/struts2/convention/Flash.java#L65-L67
142,177
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/lang/Strings.java
Strings.count
public static int count(final String host, final char charactor) { int count = 0; for (int i = 0; i < host.length(); i++) { if (host.charAt(i) == charactor) { count++; } } return count; }
java
public static int count(final String host, final char charactor) { int count = 0; for (int i = 0; i < host.length(); i++) { if (host.charAt(i) == charactor) { count++; } } return count; }
[ "public", "static", "int", "count", "(", "final", "String", "host", ",", "final", "char", "charactor", ")", "{", "int", "count", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "host", ".", "length", "(", ")", ";", "i", "++", ")", "{", "if", "(", "host", ".", "charAt", "(", "i", ")", "==", "charactor", ")", "{", "count", "++", ";", "}", "}", "return", "count", ";", "}" ]
count char in host string @param host a {@link java.lang.String} object. @param charactor a char. @return a int.
[ "count", "char", "in", "host", "string" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/lang/Strings.java#L163-L171
142,178
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/lang/Strings.java
Strings.count
public static int count(final String host, final String searchStr) { int count = 0; for (int startIndex = 0; startIndex < host.length(); startIndex++) { int findLoc = host.indexOf(searchStr, startIndex); if (findLoc == -1) { break; } else { count++; startIndex = findLoc + searchStr.length() - 1; } } return count; }
java
public static int count(final String host, final String searchStr) { int count = 0; for (int startIndex = 0; startIndex < host.length(); startIndex++) { int findLoc = host.indexOf(searchStr, startIndex); if (findLoc == -1) { break; } else { count++; startIndex = findLoc + searchStr.length() - 1; } } return count; }
[ "public", "static", "int", "count", "(", "final", "String", "host", ",", "final", "String", "searchStr", ")", "{", "int", "count", "=", "0", ";", "for", "(", "int", "startIndex", "=", "0", ";", "startIndex", "<", "host", ".", "length", "(", ")", ";", "startIndex", "++", ")", "{", "int", "findLoc", "=", "host", ".", "indexOf", "(", "searchStr", ",", "startIndex", ")", ";", "if", "(", "findLoc", "==", "-", "1", ")", "{", "break", ";", "}", "else", "{", "count", "++", ";", "startIndex", "=", "findLoc", "+", "searchStr", ".", "length", "(", ")", "-", "1", ";", "}", "}", "return", "count", ";", "}" ]
count inner string in host string @param host a {@link java.lang.String} object. @param searchStr a {@link java.lang.String} object. @return a int.
[ "count", "inner", "string", "in", "host", "string" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/lang/Strings.java#L182-L194
142,179
beangle/beangle3
commons/web/src/main/java/org/beangle/commons/web/io/DefaultStreamDownloader.java
DefaultStreamDownloader.getFileName
protected static String getFileName(String file_name) { if (file_name == null) return ""; file_name = file_name.trim(); int iPos = 0; iPos = file_name.lastIndexOf("\\"); if (iPos > -1) file_name = file_name.substring(iPos + 1); iPos = file_name.lastIndexOf("/"); if (iPos > -1) file_name = file_name.substring(iPos + 1); iPos = file_name.lastIndexOf(File.separator); if (iPos > -1) file_name = file_name.substring(iPos + 1); return file_name; }
java
protected static String getFileName(String file_name) { if (file_name == null) return ""; file_name = file_name.trim(); int iPos = 0; iPos = file_name.lastIndexOf("\\"); if (iPos > -1) file_name = file_name.substring(iPos + 1); iPos = file_name.lastIndexOf("/"); if (iPos > -1) file_name = file_name.substring(iPos + 1); iPos = file_name.lastIndexOf(File.separator); if (iPos > -1) file_name = file_name.substring(iPos + 1); return file_name; }
[ "protected", "static", "String", "getFileName", "(", "String", "file_name", ")", "{", "if", "(", "file_name", "==", "null", ")", "return", "\"\"", ";", "file_name", "=", "file_name", ".", "trim", "(", ")", ";", "int", "iPos", "=", "0", ";", "iPos", "=", "file_name", ".", "lastIndexOf", "(", "\"\\\\\"", ")", ";", "if", "(", "iPos", ">", "-", "1", ")", "file_name", "=", "file_name", ".", "substring", "(", "iPos", "+", "1", ")", ";", "iPos", "=", "file_name", ".", "lastIndexOf", "(", "\"/\"", ")", ";", "if", "(", "iPos", ">", "-", "1", ")", "file_name", "=", "file_name", ".", "substring", "(", "iPos", "+", "1", ")", ";", "iPos", "=", "file_name", ".", "lastIndexOf", "(", "File", ".", "separator", ")", ";", "if", "(", "iPos", ">", "-", "1", ")", "file_name", "=", "file_name", ".", "substring", "(", "iPos", "+", "1", ")", ";", "return", "file_name", ";", "}" ]
Returns the file name by path. @param file_name
[ "Returns", "the", "file", "name", "by", "path", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/web/src/main/java/org/beangle/commons/web/io/DefaultStreamDownloader.java#L132-L146
142,180
beangle/beangle3
orm/hibernate/src/main/java/org/beangle/orm/hibernate/DefaultTableNamingStrategy.java
DefaultTableNamingStrategy.isMultiSchema
public boolean isMultiSchema() { Set<String> schemas = CollectUtils.newHashSet(); for (TableNamePattern pattern : patterns) { schemas.add((null == pattern.getSchema()) ? "" : pattern.getSchema()); } return schemas.size() > 1; }
java
public boolean isMultiSchema() { Set<String> schemas = CollectUtils.newHashSet(); for (TableNamePattern pattern : patterns) { schemas.add((null == pattern.getSchema()) ? "" : pattern.getSchema()); } return schemas.size() > 1; }
[ "public", "boolean", "isMultiSchema", "(", ")", "{", "Set", "<", "String", ">", "schemas", "=", "CollectUtils", ".", "newHashSet", "(", ")", ";", "for", "(", "TableNamePattern", "pattern", ":", "patterns", ")", "{", "schemas", ".", "add", "(", "(", "null", "==", "pattern", ".", "getSchema", "(", ")", ")", "?", "\"\"", ":", "pattern", ".", "getSchema", "(", ")", ")", ";", "}", "return", "schemas", ".", "size", "(", ")", ">", "1", ";", "}" ]
is Multiple schema for entity
[ "is", "Multiple", "schema", "for", "entity" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/orm/hibernate/src/main/java/org/beangle/orm/hibernate/DefaultTableNamingStrategy.java#L164-L170
142,181
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/lang/time/TimerTrace.java
TimerTrace.setActive
public static void setActive(boolean active) { if (active) System.setProperty(ACTIVATE_PROPERTY, "true"); else System.clearProperty(ACTIVATE_PROPERTY); TimerTrace.active = active; }
java
public static void setActive(boolean active) { if (active) System.setProperty(ACTIVATE_PROPERTY, "true"); else System.clearProperty(ACTIVATE_PROPERTY); TimerTrace.active = active; }
[ "public", "static", "void", "setActive", "(", "boolean", "active", ")", "{", "if", "(", "active", ")", "System", ".", "setProperty", "(", "ACTIVATE_PROPERTY", ",", "\"true\"", ")", ";", "else", "System", ".", "clearProperty", "(", "ACTIVATE_PROPERTY", ")", ";", "TimerTrace", ".", "active", "=", "active", ";", "}" ]
Turn profiling on or off. @param active
[ "Turn", "profiling", "on", "or", "off", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/lang/time/TimerTrace.java#L155-L159
142,182
beangle/beangle3
struts/s2/src/main/java/org/beangle/struts2/util/BeangleStaticContentLoader.java
BeangleStaticContentLoader.findStaticResource
public void findStaticResource(String path, HttpServletRequest request, HttpServletResponse response) throws IOException { processor.process(cleanupPath(path), request, response); }
java
public void findStaticResource(String path, HttpServletRequest request, HttpServletResponse response) throws IOException { processor.process(cleanupPath(path), request, response); }
[ "public", "void", "findStaticResource", "(", "String", "path", ",", "HttpServletRequest", "request", ",", "HttpServletResponse", "response", ")", "throws", "IOException", "{", "processor", ".", "process", "(", "cleanupPath", "(", "path", ")", ",", "request", ",", "response", ")", ";", "}" ]
Locate a static resource and copy directly to the response, setting the appropriate caching headers.
[ "Locate", "a", "static", "resource", "and", "copy", "directly", "to", "the", "response", "setting", "the", "appropriate", "caching", "headers", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/struts/s2/src/main/java/org/beangle/struts2/util/BeangleStaticContentLoader.java#L55-L58
142,183
beangle/beangle3
ioc/spring/src/main/java/org/beangle/inject/spring/config/SpringBindRegistry.java
SpringBindRegistry.getBeanNames
public List<String> getBeanNames(Class<?> type) { if (typeNames.containsKey(type)) { return typeNames.get(type); } List<String> names = CollectUtils.newArrayList(); for (Map.Entry<String, Class<?>> entry : nameTypes.entrySet()) { if (type.isAssignableFrom(entry.getValue())) { names.add(entry.getKey()); } } typeNames.put(type, names); return names; }
java
public List<String> getBeanNames(Class<?> type) { if (typeNames.containsKey(type)) { return typeNames.get(type); } List<String> names = CollectUtils.newArrayList(); for (Map.Entry<String, Class<?>> entry : nameTypes.entrySet()) { if (type.isAssignableFrom(entry.getValue())) { names.add(entry.getKey()); } } typeNames.put(type, names); return names; }
[ "public", "List", "<", "String", ">", "getBeanNames", "(", "Class", "<", "?", ">", "type", ")", "{", "if", "(", "typeNames", ".", "containsKey", "(", "type", ")", ")", "{", "return", "typeNames", ".", "get", "(", "type", ")", ";", "}", "List", "<", "String", ">", "names", "=", "CollectUtils", ".", "newArrayList", "(", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "Class", "<", "?", ">", ">", "entry", ":", "nameTypes", ".", "entrySet", "(", ")", ")", "{", "if", "(", "type", ".", "isAssignableFrom", "(", "entry", ".", "getValue", "(", ")", ")", ")", "{", "names", ".", "add", "(", "entry", ".", "getKey", "(", ")", ")", ";", "}", "}", "typeNames", ".", "put", "(", "type", ",", "names", ")", ";", "return", "names", ";", "}" ]
Get bean name list according given type
[ "Get", "bean", "name", "list", "according", "given", "type" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/ioc/spring/src/main/java/org/beangle/inject/spring/config/SpringBindRegistry.java#L124-L134
142,184
beangle/beangle3
commons/model/src/main/java/org/beangle/commons/entity/metadata/impl/ConvertPopulatorBean.java
ConvertPopulatorBean.initProperty
public ObjectAndType initProperty(final Object target, Type type, final String attr) { Object propObj = target; Object property = null; int index = 0; String[] attrs = Strings.split(attr, "."); while (index < attrs.length) { try { property = getProperty(propObj, attrs[index]); Type propertyType = null; if (attrs[index].contains("[") && null != property) { propertyType = new IdentifierType(property.getClass()); } else { propertyType = type.getPropertyType(attrs[index]); if (null == propertyType) { logger.error("Cannot find property type [{}] of {}", attrs[index], propObj.getClass()); throw new RuntimeException( "Cannot find property type " + attrs[index] + " of " + propObj.getClass().getName()); } } if (null == property) { property = propertyType.newInstance(); setProperty(propObj, attrs[index], property); } index++; propObj = property; type = propertyType; } catch (Exception e) { throw new RuntimeException(e); } } return new ObjectAndType(property, type); }
java
public ObjectAndType initProperty(final Object target, Type type, final String attr) { Object propObj = target; Object property = null; int index = 0; String[] attrs = Strings.split(attr, "."); while (index < attrs.length) { try { property = getProperty(propObj, attrs[index]); Type propertyType = null; if (attrs[index].contains("[") && null != property) { propertyType = new IdentifierType(property.getClass()); } else { propertyType = type.getPropertyType(attrs[index]); if (null == propertyType) { logger.error("Cannot find property type [{}] of {}", attrs[index], propObj.getClass()); throw new RuntimeException( "Cannot find property type " + attrs[index] + " of " + propObj.getClass().getName()); } } if (null == property) { property = propertyType.newInstance(); setProperty(propObj, attrs[index], property); } index++; propObj = property; type = propertyType; } catch (Exception e) { throw new RuntimeException(e); } } return new ObjectAndType(property, type); }
[ "public", "ObjectAndType", "initProperty", "(", "final", "Object", "target", ",", "Type", "type", ",", "final", "String", "attr", ")", "{", "Object", "propObj", "=", "target", ";", "Object", "property", "=", "null", ";", "int", "index", "=", "0", ";", "String", "[", "]", "attrs", "=", "Strings", ".", "split", "(", "attr", ",", "\".\"", ")", ";", "while", "(", "index", "<", "attrs", ".", "length", ")", "{", "try", "{", "property", "=", "getProperty", "(", "propObj", ",", "attrs", "[", "index", "]", ")", ";", "Type", "propertyType", "=", "null", ";", "if", "(", "attrs", "[", "index", "]", ".", "contains", "(", "\"[\"", ")", "&&", "null", "!=", "property", ")", "{", "propertyType", "=", "new", "IdentifierType", "(", "property", ".", "getClass", "(", ")", ")", ";", "}", "else", "{", "propertyType", "=", "type", ".", "getPropertyType", "(", "attrs", "[", "index", "]", ")", ";", "if", "(", "null", "==", "propertyType", ")", "{", "logger", ".", "error", "(", "\"Cannot find property type [{}] of {}\"", ",", "attrs", "[", "index", "]", ",", "propObj", ".", "getClass", "(", ")", ")", ";", "throw", "new", "RuntimeException", "(", "\"Cannot find property type \"", "+", "attrs", "[", "index", "]", "+", "\" of \"", "+", "propObj", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "}", "if", "(", "null", "==", "property", ")", "{", "property", "=", "propertyType", ".", "newInstance", "(", ")", ";", "setProperty", "(", "propObj", ",", "attrs", "[", "index", "]", ",", "property", ")", ";", "}", "index", "++", ";", "propObj", "=", "property", ";", "type", "=", "propertyType", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}", "return", "new", "ObjectAndType", "(", "property", ",", "type", ")", ";", "}" ]
Initialize target's attribuate path,Return the last property value and type.
[ "Initialize", "target", "s", "attribuate", "path", "Return", "the", "last", "property", "value", "and", "type", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/model/src/main/java/org/beangle/commons/entity/metadata/impl/ConvertPopulatorBean.java#L78-L110
142,185
beangle/beangle3
commons/web/src/main/java/org/beangle/commons/http/agent/Browser.java
Browser.parse
public static Browser parse(final String agentString) { if (Strings.isEmpty(agentString)) { return Browser.UNKNOWN; } // first consider engine for (Engine engine : Engine.values()) { String egineName = engine.name; if (agentString.contains(egineName)) { for (BrowserCategory category : engine.browserCategories) { String version = category.match(agentString); if (version != null) { String key = category.getName() + "/" + version; Browser browser = browsers.get(key); if (null == browser) { browser = new Browser(category, version); browsers.put(key, browser); } return browser; } } } } // for some usagent without suitable enginename; for (BrowserCategory category : BrowserCategory.values()) { String version = category.match(agentString); if (version != null) { String key = category.getName() + "/" + version; Browser browser = browsers.get(key); if (null == browser) { browser = new Browser(category, version); browsers.put(key, browser); } return browser; } } return Browser.UNKNOWN; }
java
public static Browser parse(final String agentString) { if (Strings.isEmpty(agentString)) { return Browser.UNKNOWN; } // first consider engine for (Engine engine : Engine.values()) { String egineName = engine.name; if (agentString.contains(egineName)) { for (BrowserCategory category : engine.browserCategories) { String version = category.match(agentString); if (version != null) { String key = category.getName() + "/" + version; Browser browser = browsers.get(key); if (null == browser) { browser = new Browser(category, version); browsers.put(key, browser); } return browser; } } } } // for some usagent without suitable enginename; for (BrowserCategory category : BrowserCategory.values()) { String version = category.match(agentString); if (version != null) { String key = category.getName() + "/" + version; Browser browser = browsers.get(key); if (null == browser) { browser = new Browser(category, version); browsers.put(key, browser); } return browser; } } return Browser.UNKNOWN; }
[ "public", "static", "Browser", "parse", "(", "final", "String", "agentString", ")", "{", "if", "(", "Strings", ".", "isEmpty", "(", "agentString", ")", ")", "{", "return", "Browser", ".", "UNKNOWN", ";", "}", "// first consider engine", "for", "(", "Engine", "engine", ":", "Engine", ".", "values", "(", ")", ")", "{", "String", "egineName", "=", "engine", ".", "name", ";", "if", "(", "agentString", ".", "contains", "(", "egineName", ")", ")", "{", "for", "(", "BrowserCategory", "category", ":", "engine", ".", "browserCategories", ")", "{", "String", "version", "=", "category", ".", "match", "(", "agentString", ")", ";", "if", "(", "version", "!=", "null", ")", "{", "String", "key", "=", "category", ".", "getName", "(", ")", "+", "\"/\"", "+", "version", ";", "Browser", "browser", "=", "browsers", ".", "get", "(", "key", ")", ";", "if", "(", "null", "==", "browser", ")", "{", "browser", "=", "new", "Browser", "(", "category", ",", "version", ")", ";", "browsers", ".", "put", "(", "key", ",", "browser", ")", ";", "}", "return", "browser", ";", "}", "}", "}", "}", "// for some usagent without suitable enginename;", "for", "(", "BrowserCategory", "category", ":", "BrowserCategory", ".", "values", "(", ")", ")", "{", "String", "version", "=", "category", ".", "match", "(", "agentString", ")", ";", "if", "(", "version", "!=", "null", ")", "{", "String", "key", "=", "category", ".", "getName", "(", ")", "+", "\"/\"", "+", "version", ";", "Browser", "browser", "=", "browsers", ".", "get", "(", "key", ")", ";", "if", "(", "null", "==", "browser", ")", "{", "browser", "=", "new", "Browser", "(", "category", ",", "version", ")", ";", "browsers", ".", "put", "(", "key", ",", "browser", ")", ";", "}", "return", "browser", ";", "}", "}", "return", "Browser", ".", "UNKNOWN", ";", "}" ]
Iterates over all Browsers to compare the browser signature with the user agent string. If no match can be found Browser.UNKNOWN will be returned. @param agentString @return Browser
[ "Iterates", "over", "all", "Browsers", "to", "compare", "the", "browser", "signature", "with", "the", "user", "agent", "string", ".", "If", "no", "match", "can", "be", "found", "Browser", ".", "UNKNOWN", "will", "be", "returned", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/web/src/main/java/org/beangle/commons/http/agent/Browser.java#L55-L89
142,186
xebia/Xebium
src/main/java/com/xebia/incubator/xebium/ScreenCapture.java
ScreenCapture.requireScreenshot
public boolean requireScreenshot(final ExtendedSeleniumCommand command, boolean result) { return (!command.isAssertCommand() && !command.isVerifyCommand() && !command.isWaitForCommand() && screenshotPolicy == ScreenshotPolicy.STEP) || (!result && (screenshotPolicy == ScreenshotPolicy.FAILURE || (command.isAssertCommand() && screenshotPolicy == ScreenshotPolicy.ASSERTION))); }
java
public boolean requireScreenshot(final ExtendedSeleniumCommand command, boolean result) { return (!command.isAssertCommand() && !command.isVerifyCommand() && !command.isWaitForCommand() && screenshotPolicy == ScreenshotPolicy.STEP) || (!result && (screenshotPolicy == ScreenshotPolicy.FAILURE || (command.isAssertCommand() && screenshotPolicy == ScreenshotPolicy.ASSERTION))); }
[ "public", "boolean", "requireScreenshot", "(", "final", "ExtendedSeleniumCommand", "command", ",", "boolean", "result", ")", "{", "return", "(", "!", "command", ".", "isAssertCommand", "(", ")", "&&", "!", "command", ".", "isVerifyCommand", "(", ")", "&&", "!", "command", ".", "isWaitForCommand", "(", ")", "&&", "screenshotPolicy", "==", "ScreenshotPolicy", ".", "STEP", ")", "||", "(", "!", "result", "&&", "(", "screenshotPolicy", "==", "ScreenshotPolicy", ".", "FAILURE", "||", "(", "command", ".", "isAssertCommand", "(", ")", "&&", "screenshotPolicy", "==", "ScreenshotPolicy", ".", "ASSERTION", ")", ")", ")", ";", "}" ]
Is a screenshot desired, based on the command and the test result.
[ "Is", "a", "screenshot", "desired", "based", "on", "the", "command", "and", "the", "test", "result", "." ]
594f6d9e65622acdbd03dba0700b17645981da1f
https://github.com/xebia/Xebium/blob/594f6d9e65622acdbd03dba0700b17645981da1f/src/main/java/com/xebia/incubator/xebium/ScreenCapture.java#L90-L100
142,187
xebia/Xebium
src/main/java/com/xebia/incubator/xebium/SeleniumDriverFixture.java
SeleniumDriverFixture.setTimeoutOnSelenium
private void setTimeoutOnSelenium() { executeCommand("setTimeout", new String[] { "" + this.timeout }); WebDriver.Timeouts timeouts = getWebDriver().manage().timeouts(); timeouts.setScriptTimeout(this.timeout, TimeUnit.MILLISECONDS); timeouts.pageLoadTimeout(this.timeout, TimeUnit.MILLISECONDS); }
java
private void setTimeoutOnSelenium() { executeCommand("setTimeout", new String[] { "" + this.timeout }); WebDriver.Timeouts timeouts = getWebDriver().manage().timeouts(); timeouts.setScriptTimeout(this.timeout, TimeUnit.MILLISECONDS); timeouts.pageLoadTimeout(this.timeout, TimeUnit.MILLISECONDS); }
[ "private", "void", "setTimeoutOnSelenium", "(", ")", "{", "executeCommand", "(", "\"setTimeout\"", ",", "new", "String", "[", "]", "{", "\"\"", "+", "this", ".", "timeout", "}", ")", ";", "WebDriver", ".", "Timeouts", "timeouts", "=", "getWebDriver", "(", ")", ".", "manage", "(", ")", ".", "timeouts", "(", ")", ";", "timeouts", ".", "setScriptTimeout", "(", "this", ".", "timeout", ",", "TimeUnit", ".", "MILLISECONDS", ")", ";", "timeouts", ".", "pageLoadTimeout", "(", "this", ".", "timeout", ",", "TimeUnit", ".", "MILLISECONDS", ")", ";", "}" ]
Set the default timeout on the selenium instance.
[ "Set", "the", "default", "timeout", "on", "the", "selenium", "instance", "." ]
594f6d9e65622acdbd03dba0700b17645981da1f
https://github.com/xebia/Xebium/blob/594f6d9e65622acdbd03dba0700b17645981da1f/src/main/java/com/xebia/incubator/xebium/SeleniumDriverFixture.java#L275-L280
142,188
xebia/Xebium
src/main/java/com/xebia/incubator/xebium/SeleniumDriverFixture.java
SeleniumDriverFixture.addAliasForLocator
public void addAliasForLocator(String alias, String locator) { LOG.info("Add alias: '" + alias + "' for '" + locator + "'"); aliases.put(alias, locator); }
java
public void addAliasForLocator(String alias, String locator) { LOG.info("Add alias: '" + alias + "' for '" + locator + "'"); aliases.put(alias, locator); }
[ "public", "void", "addAliasForLocator", "(", "String", "alias", ",", "String", "locator", ")", "{", "LOG", ".", "info", "(", "\"Add alias: '\"", "+", "alias", "+", "\"' for '\"", "+", "locator", "+", "\"'\"", ")", ";", "aliases", ".", "put", "(", "alias", ",", "locator", ")", ";", "}" ]
Add a new locator alias to the fixture. @param alias @param locator
[ "Add", "a", "new", "locator", "alias", "to", "the", "fixture", "." ]
594f6d9e65622acdbd03dba0700b17645981da1f
https://github.com/xebia/Xebium/blob/594f6d9e65622acdbd03dba0700b17645981da1f/src/main/java/com/xebia/incubator/xebium/SeleniumDriverFixture.java#L446-L449
142,189
xebia/Xebium
src/main/java/com/xebia/incubator/xebium/SeleniumServerFixture.java
SeleniumServerFixture.startSeleniumServer
public void startSeleniumServer(final String args) { if (seleniumProxy != null) { throw new IllegalStateException("There is already a Selenium remote server running"); } try { final RemoteControlConfiguration configuration; LOG.info("Starting server with arguments: '" + args + "'"); //String[] argv = StringUtils.isNotBlank(args) ? StringUtils.split(args) : new String[] {}; String[] argv = StringUtils.split(args); configuration = SeleniumServer.parseLauncherOptions(argv); //checkArgsSanity(configuration); System.setProperty("org.openqa.jetty.http.HttpRequest.maxFormContentSize", "0"); // default max is 200k; zero is infinite seleniumProxy = new SeleniumServer(isSlowConnection(), configuration); seleniumProxy.start(); } catch (Exception e) { //server.stop(); LOG.info("Server stopped"); } }
java
public void startSeleniumServer(final String args) { if (seleniumProxy != null) { throw new IllegalStateException("There is already a Selenium remote server running"); } try { final RemoteControlConfiguration configuration; LOG.info("Starting server with arguments: '" + args + "'"); //String[] argv = StringUtils.isNotBlank(args) ? StringUtils.split(args) : new String[] {}; String[] argv = StringUtils.split(args); configuration = SeleniumServer.parseLauncherOptions(argv); //checkArgsSanity(configuration); System.setProperty("org.openqa.jetty.http.HttpRequest.maxFormContentSize", "0"); // default max is 200k; zero is infinite seleniumProxy = new SeleniumServer(isSlowConnection(), configuration); seleniumProxy.start(); } catch (Exception e) { //server.stop(); LOG.info("Server stopped"); } }
[ "public", "void", "startSeleniumServer", "(", "final", "String", "args", ")", "{", "if", "(", "seleniumProxy", "!=", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"There is already a Selenium remote server running\"", ")", ";", "}", "try", "{", "final", "RemoteControlConfiguration", "configuration", ";", "LOG", ".", "info", "(", "\"Starting server with arguments: '\"", "+", "args", "+", "\"'\"", ")", ";", "//String[] argv = StringUtils.isNotBlank(args) ? StringUtils.split(args) : new String[] {};\r", "String", "[", "]", "argv", "=", "StringUtils", ".", "split", "(", "args", ")", ";", "configuration", "=", "SeleniumServer", ".", "parseLauncherOptions", "(", "argv", ")", ";", "//checkArgsSanity(configuration);\r", "System", ".", "setProperty", "(", "\"org.openqa.jetty.http.HttpRequest.maxFormContentSize\"", ",", "\"0\"", ")", ";", "// default max is 200k; zero is infinite\r", "seleniumProxy", "=", "new", "SeleniumServer", "(", "isSlowConnection", "(", ")", ",", "configuration", ")", ";", "seleniumProxy", ".", "start", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "//server.stop();\r", "LOG", ".", "info", "(", "\"Server stopped\"", ")", ";", "}", "}" ]
Start server with arguments. @param args Arguments, same as when started from command line
[ "Start", "server", "with", "arguments", "." ]
594f6d9e65622acdbd03dba0700b17645981da1f
https://github.com/xebia/Xebium/blob/594f6d9e65622acdbd03dba0700b17645981da1f/src/main/java/com/xebia/incubator/xebium/SeleniumServerFixture.java#L49-L72
142,190
petergeneric/stdlib
guice/hibernate/src/main/java/com/peterphi/std/guice/hibernate/module/TransactionMethodInterceptor.java
TransactionMethodInterceptor.readAnnotation
private Transactional readAnnotation(MethodInvocation invocation) { final Method method = invocation.getMethod(); if (method.isAnnotationPresent(Transactional.class)) { return method.getAnnotation(Transactional.class); } else { throw new RuntimeException("Could not find Transactional annotation"); } }
java
private Transactional readAnnotation(MethodInvocation invocation) { final Method method = invocation.getMethod(); if (method.isAnnotationPresent(Transactional.class)) { return method.getAnnotation(Transactional.class); } else { throw new RuntimeException("Could not find Transactional annotation"); } }
[ "private", "Transactional", "readAnnotation", "(", "MethodInvocation", "invocation", ")", "{", "final", "Method", "method", "=", "invocation", ".", "getMethod", "(", ")", ";", "if", "(", "method", ".", "isAnnotationPresent", "(", "Transactional", ".", "class", ")", ")", "{", "return", "method", ".", "getAnnotation", "(", "Transactional", ".", "class", ")", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "\"Could not find Transactional annotation\"", ")", ";", "}", "}" ]
Read the Transactional annotation for a given method invocation @param invocation @return
[ "Read", "the", "Transactional", "annotation", "for", "a", "given", "method", "invocation" ]
d4025d2f881bc0542b1e004c5f65a1ccaf895836
https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/hibernate/src/main/java/com/peterphi/std/guice/hibernate/module/TransactionMethodInterceptor.java#L367-L379
142,191
petergeneric/stdlib
guice/hibernate/src/main/java/com/peterphi/std/guice/hibernate/module/TransactionMethodInterceptor.java
TransactionMethodInterceptor.complete
private final void complete(Transaction tx, boolean readOnly) { if (log.isTraceEnabled()) log.trace("Complete " + tx); if (!readOnly) tx.commit(); else tx.rollback(); }
java
private final void complete(Transaction tx, boolean readOnly) { if (log.isTraceEnabled()) log.trace("Complete " + tx); if (!readOnly) tx.commit(); else tx.rollback(); }
[ "private", "final", "void", "complete", "(", "Transaction", "tx", ",", "boolean", "readOnly", ")", "{", "if", "(", "log", ".", "isTraceEnabled", "(", ")", ")", "log", ".", "trace", "(", "\"Complete \"", "+", "tx", ")", ";", "if", "(", "!", "readOnly", ")", "tx", ".", "commit", "(", ")", ";", "else", "tx", ".", "rollback", "(", ")", ";", "}" ]
Complete the transaction @param tx @param readOnly the read-only flag on the transaction (if true, the transaction will be rolled back, otherwise the transaction will be
[ "Complete", "the", "transaction" ]
d4025d2f881bc0542b1e004c5f65a1ccaf895836
https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/hibernate/src/main/java/com/peterphi/std/guice/hibernate/module/TransactionMethodInterceptor.java#L554-L563
142,192
ziccardi/jnrpe
jnrpe-plugins/src/main/java/it/jnrpe/plugin/CheckPgsql.java
CheckPgsql.getConnection
private Connection getConnection(final ICommandLine cl) throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException { String database = DEFAULT_TABLE; if (cl.hasOption("database")) { database = cl.getOptionValue("database"); } String hostname = DEFAULT_HOSTNAME; if (cl.hasOption("hostname") && !"".equals(cl.getOptionValue("hostname"))) { hostname = cl.getOptionValue("hostname"); } String port = DEFAULT_PORT; if (cl.hasOption("port") && !"".equals(cl.getOptionValue("port"))) { port = cl.getOptionValue("port"); } String password = ""; if (cl.hasOption("password")) { password = cl.getOptionValue("password"); } String username = ""; if (cl.hasOption("logname")) { username = cl.getOptionValue("logname"); } String timeout = DEFAULT_TIMEOUT; if (cl.getOptionValue("timeout") != null) { timeout = cl.getOptionValue("timeout"); } Properties props = new Properties(); props.setProperty("user", username); props.setProperty("password", password); props.setProperty("timeout", timeout); String url = "jdbc:postgresql://" + hostname + ":" + port + "/" + database; DriverManager.registerDriver((Driver) Class.forName("org.postgresql.Driver").newInstance()); return DriverManager.getConnection(url, props); }
java
private Connection getConnection(final ICommandLine cl) throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException { String database = DEFAULT_TABLE; if (cl.hasOption("database")) { database = cl.getOptionValue("database"); } String hostname = DEFAULT_HOSTNAME; if (cl.hasOption("hostname") && !"".equals(cl.getOptionValue("hostname"))) { hostname = cl.getOptionValue("hostname"); } String port = DEFAULT_PORT; if (cl.hasOption("port") && !"".equals(cl.getOptionValue("port"))) { port = cl.getOptionValue("port"); } String password = ""; if (cl.hasOption("password")) { password = cl.getOptionValue("password"); } String username = ""; if (cl.hasOption("logname")) { username = cl.getOptionValue("logname"); } String timeout = DEFAULT_TIMEOUT; if (cl.getOptionValue("timeout") != null) { timeout = cl.getOptionValue("timeout"); } Properties props = new Properties(); props.setProperty("user", username); props.setProperty("password", password); props.setProperty("timeout", timeout); String url = "jdbc:postgresql://" + hostname + ":" + port + "/" + database; DriverManager.registerDriver((Driver) Class.forName("org.postgresql.Driver").newInstance()); return DriverManager.getConnection(url, props); }
[ "private", "Connection", "getConnection", "(", "final", "ICommandLine", "cl", ")", "throws", "SQLException", ",", "InstantiationException", ",", "IllegalAccessException", ",", "ClassNotFoundException", "{", "String", "database", "=", "DEFAULT_TABLE", ";", "if", "(", "cl", ".", "hasOption", "(", "\"database\"", ")", ")", "{", "database", "=", "cl", ".", "getOptionValue", "(", "\"database\"", ")", ";", "}", "String", "hostname", "=", "DEFAULT_HOSTNAME", ";", "if", "(", "cl", ".", "hasOption", "(", "\"hostname\"", ")", "&&", "!", "\"\"", ".", "equals", "(", "cl", ".", "getOptionValue", "(", "\"hostname\"", ")", ")", ")", "{", "hostname", "=", "cl", ".", "getOptionValue", "(", "\"hostname\"", ")", ";", "}", "String", "port", "=", "DEFAULT_PORT", ";", "if", "(", "cl", ".", "hasOption", "(", "\"port\"", ")", "&&", "!", "\"\"", ".", "equals", "(", "cl", ".", "getOptionValue", "(", "\"port\"", ")", ")", ")", "{", "port", "=", "cl", ".", "getOptionValue", "(", "\"port\"", ")", ";", "}", "String", "password", "=", "\"\"", ";", "if", "(", "cl", ".", "hasOption", "(", "\"password\"", ")", ")", "{", "password", "=", "cl", ".", "getOptionValue", "(", "\"password\"", ")", ";", "}", "String", "username", "=", "\"\"", ";", "if", "(", "cl", ".", "hasOption", "(", "\"logname\"", ")", ")", "{", "username", "=", "cl", ".", "getOptionValue", "(", "\"logname\"", ")", ";", "}", "String", "timeout", "=", "DEFAULT_TIMEOUT", ";", "if", "(", "cl", ".", "getOptionValue", "(", "\"timeout\"", ")", "!=", "null", ")", "{", "timeout", "=", "cl", ".", "getOptionValue", "(", "\"timeout\"", ")", ";", "}", "Properties", "props", "=", "new", "Properties", "(", ")", ";", "props", ".", "setProperty", "(", "\"user\"", ",", "username", ")", ";", "props", ".", "setProperty", "(", "\"password\"", ",", "password", ")", ";", "props", ".", "setProperty", "(", "\"timeout\"", ",", "timeout", ")", ";", "String", "url", "=", "\"jdbc:postgresql://\"", "+", "hostname", "+", "\":\"", "+", "port", "+", "\"/\"", "+", "database", ";", "DriverManager", ".", "registerDriver", "(", "(", "Driver", ")", "Class", ".", "forName", "(", "\"org.postgresql.Driver\"", ")", ".", "newInstance", "(", ")", ")", ";", "return", "DriverManager", ".", "getConnection", "(", "url", ",", "props", ")", ";", "}" ]
Connect to the server. @param cl The command line @return The connection @throws SQLException - @throws InstantiationException - @throws IllegalAccessException - @throws ClassNotFoundException -
[ "Connect", "to", "the", "server", "." ]
ac9046355851136994388442b01ba4063305f9c4
https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-plugins/src/main/java/it/jnrpe/plugin/CheckPgsql.java#L119-L152
142,193
ziccardi/jnrpe
jnrpe-lib/src/main/java/it/jnrpe/plugins/PluginBase.java
PluginBase.configureThresholdEvaluatorBuilder
protected void configureThresholdEvaluatorBuilder(final ThresholdsEvaluatorBuilder thrb, final ICommandLine cl) throws BadThresholdException { if (cl.hasOption("th")) { for (Object obj : cl.getOptionValues("th")) { thrb.withThreshold(obj.toString()); } } }
java
protected void configureThresholdEvaluatorBuilder(final ThresholdsEvaluatorBuilder thrb, final ICommandLine cl) throws BadThresholdException { if (cl.hasOption("th")) { for (Object obj : cl.getOptionValues("th")) { thrb.withThreshold(obj.toString()); } } }
[ "protected", "void", "configureThresholdEvaluatorBuilder", "(", "final", "ThresholdsEvaluatorBuilder", "thrb", ",", "final", "ICommandLine", "cl", ")", "throws", "BadThresholdException", "{", "if", "(", "cl", ".", "hasOption", "(", "\"th\"", ")", ")", "{", "for", "(", "Object", "obj", ":", "cl", ".", "getOptionValues", "(", "\"th\"", ")", ")", "{", "thrb", ".", "withThreshold", "(", "obj", ".", "toString", "(", ")", ")", ";", "}", "}", "}" ]
Override this method if you don't use the new threshold syntax. Here you must tell the threshold evaluator all the threshold it must be able to evaluate. Give a look at the source of the CheckOracle plugin for an example of a plugin that supports both old and new syntax. @param thrb The {@link ThresholdsEvaluatorBuilder} object to be configured @param cl The command line @throws BadThresholdException -
[ "Override", "this", "method", "if", "you", "don", "t", "use", "the", "new", "threshold", "syntax", ".", "Here", "you", "must", "tell", "the", "threshold", "evaluator", "all", "the", "threshold", "it", "must", "be", "able", "to", "evaluate", ".", "Give", "a", "look", "at", "the", "source", "of", "the", "CheckOracle", "plugin", "for", "an", "example", "of", "a", "plugin", "that", "supports", "both", "old", "and", "new", "syntax", "." ]
ac9046355851136994388442b01ba4063305f9c4
https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/plugins/PluginBase.java#L81-L87
142,194
ziccardi/jnrpe
jnrpe-lib/src/main/java/it/jnrpe/utils/thresholds/Range.java
Range.evaluate
private boolean evaluate(final Metric metric, final Prefixes prefix) { if (metric == null || metric.getMetricValue() == null) { throw new NullPointerException("Value can't be null"); } BigDecimal value = metric.getMetricValue(prefix); if (!isNegativeInfinity()) { switch (value.compareTo(getLeftBoundary())) { case 0: if (!isLeftInclusive()) { return false; } break; case -1: return false; default: } } if (!isPositiveInfinity()) { switch (value.compareTo(getRightBoundary())) { case 0: if (!isRightInclusive()) { return false; } break; case 1: return false; default: } } return true; }
java
private boolean evaluate(final Metric metric, final Prefixes prefix) { if (metric == null || metric.getMetricValue() == null) { throw new NullPointerException("Value can't be null"); } BigDecimal value = metric.getMetricValue(prefix); if (!isNegativeInfinity()) { switch (value.compareTo(getLeftBoundary())) { case 0: if (!isLeftInclusive()) { return false; } break; case -1: return false; default: } } if (!isPositiveInfinity()) { switch (value.compareTo(getRightBoundary())) { case 0: if (!isRightInclusive()) { return false; } break; case 1: return false; default: } } return true; }
[ "private", "boolean", "evaluate", "(", "final", "Metric", "metric", ",", "final", "Prefixes", "prefix", ")", "{", "if", "(", "metric", "==", "null", "||", "metric", ".", "getMetricValue", "(", ")", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"Value can't be null\"", ")", ";", "}", "BigDecimal", "value", "=", "metric", ".", "getMetricValue", "(", "prefix", ")", ";", "if", "(", "!", "isNegativeInfinity", "(", ")", ")", "{", "switch", "(", "value", ".", "compareTo", "(", "getLeftBoundary", "(", ")", ")", ")", "{", "case", "0", ":", "if", "(", "!", "isLeftInclusive", "(", ")", ")", "{", "return", "false", ";", "}", "break", ";", "case", "-", "1", ":", "return", "false", ";", "default", ":", "}", "}", "if", "(", "!", "isPositiveInfinity", "(", ")", ")", "{", "switch", "(", "value", ".", "compareTo", "(", "getRightBoundary", "(", ")", ")", ")", "{", "case", "0", ":", "if", "(", "!", "isRightInclusive", "(", ")", ")", "{", "return", "false", ";", "}", "break", ";", "case", "1", ":", "return", "false", ";", "default", ":", "}", "}", "return", "true", ";", "}" ]
Evaluates if the passed in value falls inside the range. The negation is ignored. @param metric The metric to evaluate @param prefix Used to interpret the values of the range boundaries. @return <code>true</code> if the metric value falls inside the range. The negation ('^') is ignored.
[ "Evaluates", "if", "the", "passed", "in", "value", "falls", "inside", "the", "range", ".", "The", "negation", "is", "ignored", "." ]
ac9046355851136994388442b01ba4063305f9c4
https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/utils/thresholds/Range.java#L92-L126
142,195
ziccardi/jnrpe
jnrpe-plugins/src/main/java/it/jnrpe/plugin/CNativePlugin.java
CNativePlugin.execute
public final ReturnValue execute(final ICommandLine cl) { File fProcessFile = new File(cl.getOptionValue("executable")); StreamManager streamMgr = new StreamManager(); if (!fProcessFile.exists()) { return new ReturnValue(Status.UNKNOWN, "Could not exec executable : " + fProcessFile.getAbsolutePath()); } try { String[] vsParams = StringUtils.split(cl.getOptionValue("args", ""), false); String[] vCommand = new String[vsParams.length + 1]; vCommand[0] = cl.getOptionValue("executable"); System.arraycopy(vsParams, 0, vCommand, 1, vsParams.length); Process p = Runtime.getRuntime().exec(vCommand); BufferedReader br = (BufferedReader) streamMgr.handle(new BufferedReader(new InputStreamReader(p.getInputStream()))); StringBuilder msg = new StringBuilder(); for (String line = br.readLine(); line != null; line = br.readLine()) { if (msg.length() != 0) { msg.append(System.lineSeparator()); } msg.append(line); } int iReturnCode = p.waitFor(); return new ReturnValue(Status.fromIntValue(iReturnCode), msg.toString()); } catch (Exception e) { String message = e.getMessage(); LOG.warn(getContext(), "Error executing the native plugin : " + message, e); return new ReturnValue(Status.UNKNOWN, "Could not exec executable : " + fProcessFile.getName() + " - ERROR : " + message); } finally { streamMgr.closeAll(); } }
java
public final ReturnValue execute(final ICommandLine cl) { File fProcessFile = new File(cl.getOptionValue("executable")); StreamManager streamMgr = new StreamManager(); if (!fProcessFile.exists()) { return new ReturnValue(Status.UNKNOWN, "Could not exec executable : " + fProcessFile.getAbsolutePath()); } try { String[] vsParams = StringUtils.split(cl.getOptionValue("args", ""), false); String[] vCommand = new String[vsParams.length + 1]; vCommand[0] = cl.getOptionValue("executable"); System.arraycopy(vsParams, 0, vCommand, 1, vsParams.length); Process p = Runtime.getRuntime().exec(vCommand); BufferedReader br = (BufferedReader) streamMgr.handle(new BufferedReader(new InputStreamReader(p.getInputStream()))); StringBuilder msg = new StringBuilder(); for (String line = br.readLine(); line != null; line = br.readLine()) { if (msg.length() != 0) { msg.append(System.lineSeparator()); } msg.append(line); } int iReturnCode = p.waitFor(); return new ReturnValue(Status.fromIntValue(iReturnCode), msg.toString()); } catch (Exception e) { String message = e.getMessage(); LOG.warn(getContext(), "Error executing the native plugin : " + message, e); return new ReturnValue(Status.UNKNOWN, "Could not exec executable : " + fProcessFile.getName() + " - ERROR : " + message); } finally { streamMgr.closeAll(); } }
[ "public", "final", "ReturnValue", "execute", "(", "final", "ICommandLine", "cl", ")", "{", "File", "fProcessFile", "=", "new", "File", "(", "cl", ".", "getOptionValue", "(", "\"executable\"", ")", ")", ";", "StreamManager", "streamMgr", "=", "new", "StreamManager", "(", ")", ";", "if", "(", "!", "fProcessFile", ".", "exists", "(", ")", ")", "{", "return", "new", "ReturnValue", "(", "Status", ".", "UNKNOWN", ",", "\"Could not exec executable : \"", "+", "fProcessFile", ".", "getAbsolutePath", "(", ")", ")", ";", "}", "try", "{", "String", "[", "]", "vsParams", "=", "StringUtils", ".", "split", "(", "cl", ".", "getOptionValue", "(", "\"args\"", ",", "\"\"", ")", ",", "false", ")", ";", "String", "[", "]", "vCommand", "=", "new", "String", "[", "vsParams", ".", "length", "+", "1", "]", ";", "vCommand", "[", "0", "]", "=", "cl", ".", "getOptionValue", "(", "\"executable\"", ")", ";", "System", ".", "arraycopy", "(", "vsParams", ",", "0", ",", "vCommand", ",", "1", ",", "vsParams", ".", "length", ")", ";", "Process", "p", "=", "Runtime", ".", "getRuntime", "(", ")", ".", "exec", "(", "vCommand", ")", ";", "BufferedReader", "br", "=", "(", "BufferedReader", ")", "streamMgr", ".", "handle", "(", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "p", ".", "getInputStream", "(", ")", ")", ")", ")", ";", "StringBuilder", "msg", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "String", "line", "=", "br", ".", "readLine", "(", ")", ";", "line", "!=", "null", ";", "line", "=", "br", ".", "readLine", "(", ")", ")", "{", "if", "(", "msg", ".", "length", "(", ")", "!=", "0", ")", "{", "msg", ".", "append", "(", "System", ".", "lineSeparator", "(", ")", ")", ";", "}", "msg", ".", "append", "(", "line", ")", ";", "}", "int", "iReturnCode", "=", "p", ".", "waitFor", "(", ")", ";", "return", "new", "ReturnValue", "(", "Status", ".", "fromIntValue", "(", "iReturnCode", ")", ",", "msg", ".", "toString", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "String", "message", "=", "e", ".", "getMessage", "(", ")", ";", "LOG", ".", "warn", "(", "getContext", "(", ")", ",", "\"Error executing the native plugin : \"", "+", "message", ",", "e", ")", ";", "return", "new", "ReturnValue", "(", "Status", ".", "UNKNOWN", ",", "\"Could not exec executable : \"", "+", "fProcessFile", ".", "getName", "(", ")", "+", "\" - ERROR : \"", "+", "message", ")", ";", "}", "finally", "{", "streamMgr", ".", "closeAll", "(", ")", ";", "}", "}" ]
The first parameter must be the full path to the executable. The rest of the array is sent to the executable as commands parameters @param cl The parsed command line @return The return value of the plugin
[ "The", "first", "parameter", "must", "be", "the", "full", "path", "to", "the", "executable", "." ]
ac9046355851136994388442b01ba4063305f9c4
https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-plugins/src/main/java/it/jnrpe/plugin/CNativePlugin.java#L45-L80
142,196
petergeneric/stdlib
stdlib/src/main/java/com/peterphi/std/util/Logging.java
Logging.configureFiles
public static void configureFiles(Iterable<File> files) { for (File file : files) { if (file != null && file.exists() && file.canRead()) { setup(file); return; } } System.out.println("(No suitable log config file found)"); }
java
public static void configureFiles(Iterable<File> files) { for (File file : files) { if (file != null && file.exists() && file.canRead()) { setup(file); return; } } System.out.println("(No suitable log config file found)"); }
[ "public", "static", "void", "configureFiles", "(", "Iterable", "<", "File", ">", "files", ")", "{", "for", "(", "File", "file", ":", "files", ")", "{", "if", "(", "file", "!=", "null", "&&", "file", ".", "exists", "(", ")", "&&", "file", ".", "canRead", "(", ")", ")", "{", "setup", "(", "file", ")", ";", "return", ";", "}", "}", "System", ".", "out", ".", "println", "(", "\"(No suitable log config file found)\"", ")", ";", "}" ]
Configures the logging environment to use the first available config file in the list, printing an error if none of the files are suitable @param files
[ "Configures", "the", "logging", "environment", "to", "use", "the", "first", "available", "config", "file", "in", "the", "list", "printing", "an", "error", "if", "none", "of", "the", "files", "are", "suitable" ]
d4025d2f881bc0542b1e004c5f65a1ccaf895836
https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/util/Logging.java#L33-L45
142,197
ziccardi/jnrpe
jnrpe-lib/src/main/java/it/jnrpe/commands/CommandRepository.java
CommandRepository.getAllCommandDefinition
public Set<CommandDefinition> getAllCommandDefinition(final String pluginName) { Set<CommandDefinition> res = new HashSet<CommandDefinition>(); for (CommandDefinition cd : commandDefinitionsMap.values()) { if (cd.getPluginName().equals(pluginName)) { res.add(cd); } } return res; }
java
public Set<CommandDefinition> getAllCommandDefinition(final String pluginName) { Set<CommandDefinition> res = new HashSet<CommandDefinition>(); for (CommandDefinition cd : commandDefinitionsMap.values()) { if (cd.getPluginName().equals(pluginName)) { res.add(cd); } } return res; }
[ "public", "Set", "<", "CommandDefinition", ">", "getAllCommandDefinition", "(", "final", "String", "pluginName", ")", "{", "Set", "<", "CommandDefinition", ">", "res", "=", "new", "HashSet", "<", "CommandDefinition", ">", "(", ")", ";", "for", "(", "CommandDefinition", "cd", ":", "commandDefinitionsMap", ".", "values", "(", ")", ")", "{", "if", "(", "cd", ".", "getPluginName", "(", ")", ".", "equals", "(", "pluginName", ")", ")", "{", "res", ".", "add", "(", "cd", ")", ";", "}", "}", "return", "res", ";", "}" ]
Returns all the command definition that involves the given plugin. @param pluginName the name of the plugin we are interested in @return all the command definition that involves the given plugin
[ "Returns", "all", "the", "command", "definition", "that", "involves", "the", "given", "plugin", "." ]
ac9046355851136994388442b01ba4063305f9c4
https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/commands/CommandRepository.java#L64-L75
142,198
petergeneric/stdlib
guice/webapp/src/main/java/com/peterphi/std/guice/web/rest/auth/oauth2/OAuth2SessionRef.java
OAuth2SessionRef.initialiseFromAPIToken
public synchronized void initialiseFromAPIToken(final String token) { final String responseStr = authService.getToken(UserManagerOAuthService.GRANT_TYPE_TOKEN_EXCHANGE, null, getOwnCallbackUri().toString(), clientId, clientSecret, null, null, null, token); loadAuthResponse(responseStr); }
java
public synchronized void initialiseFromAPIToken(final String token) { final String responseStr = authService.getToken(UserManagerOAuthService.GRANT_TYPE_TOKEN_EXCHANGE, null, getOwnCallbackUri().toString(), clientId, clientSecret, null, null, null, token); loadAuthResponse(responseStr); }
[ "public", "synchronized", "void", "initialiseFromAPIToken", "(", "final", "String", "token", ")", "{", "final", "String", "responseStr", "=", "authService", ".", "getToken", "(", "UserManagerOAuthService", ".", "GRANT_TYPE_TOKEN_EXCHANGE", ",", "null", ",", "getOwnCallbackUri", "(", ")", ".", "toString", "(", ")", ",", "clientId", ",", "clientSecret", ",", "null", ",", "null", ",", "null", ",", "token", ")", ";", "loadAuthResponse", "(", "responseStr", ")", ";", "}" ]
Initialise this session reference by exchanging an API token for an access_token and refresh_token @param token
[ "Initialise", "this", "session", "reference", "by", "exchanging", "an", "API", "token", "for", "an", "access_token", "and", "refresh_token" ]
d4025d2f881bc0542b1e004c5f65a1ccaf895836
https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/webapp/src/main/java/com/peterphi/std/guice/web/rest/auth/oauth2/OAuth2SessionRef.java#L84-L97
142,199
petergeneric/stdlib
guice/webapp/src/main/java/com/peterphi/std/guice/web/rest/auth/oauth2/OAuth2SessionRef.java
OAuth2SessionRef.getOwnCallbackUri
public URI getOwnCallbackUri() { String localEndpointStr = (oauthSelfEndpoint != null) ? oauthSelfEndpoint : localEndpoint.toString(); if (!localEndpointStr.endsWith("/")) localEndpointStr += "/"; return URI.create(localEndpointStr + "oauth2/client/cb"); }
java
public URI getOwnCallbackUri() { String localEndpointStr = (oauthSelfEndpoint != null) ? oauthSelfEndpoint : localEndpoint.toString(); if (!localEndpointStr.endsWith("/")) localEndpointStr += "/"; return URI.create(localEndpointStr + "oauth2/client/cb"); }
[ "public", "URI", "getOwnCallbackUri", "(", ")", "{", "String", "localEndpointStr", "=", "(", "oauthSelfEndpoint", "!=", "null", ")", "?", "oauthSelfEndpoint", ":", "localEndpoint", ".", "toString", "(", ")", ";", "if", "(", "!", "localEndpointStr", ".", "endsWith", "(", "\"/\"", ")", ")", "localEndpointStr", "+=", "\"/\"", ";", "return", "URI", ".", "create", "(", "localEndpointStr", "+", "\"oauth2/client/cb\"", ")", ";", "}" ]
Return the URI for this service's callback resource @return
[ "Return", "the", "URI", "for", "this", "service", "s", "callback", "resource" ]
d4025d2f881bc0542b1e004c5f65a1ccaf895836
https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/webapp/src/main/java/com/peterphi/std/guice/web/rest/auth/oauth2/OAuth2SessionRef.java#L120-L128