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
4,100
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/converter/CThreadContext.java
CThreadContext.getInstance
public static final CThreadContext getInstance() { SoftReference ref = (SoftReference)CThreadContext.contextLocal .get(Thread.currentThread()); CThreadContext context = null; if ((ref == null) || (ref.get() == null)) { context = new CThreadContext(); ref = new SoftReference(context); CThreadContext.contextLocal.put(Thread.currentThread(), ref); } else { context = (CThreadContext)ref.get(); } return context; }
java
public static final CThreadContext getInstance() { SoftReference ref = (SoftReference)CThreadContext.contextLocal .get(Thread.currentThread()); CThreadContext context = null; if ((ref == null) || (ref.get() == null)) { context = new CThreadContext(); ref = new SoftReference(context); CThreadContext.contextLocal.put(Thread.currentThread(), ref); } else { context = (CThreadContext)ref.get(); } return context; }
[ "public", "static", "final", "CThreadContext", "getInstance", "(", ")", "{", "SoftReference", "ref", "=", "(", "SoftReference", ")", "CThreadContext", ".", "contextLocal", ".", "get", "(", "Thread", ".", "currentThread", "(", ")", ")", ";", "CThreadContext", "context", "=", "null", ";", "if", "(", "(", "ref", "==", "null", ")", "||", "(", "ref", ".", "get", "(", ")", "==", "null", ")", ")", "{", "context", "=", "new", "CThreadContext", "(", ")", ";", "ref", "=", "new", "SoftReference", "(", "context", ")", ";", "CThreadContext", ".", "contextLocal", ".", "put", "(", "Thread", ".", "currentThread", "(", ")", ",", "ref", ")", ";", "}", "else", "{", "context", "=", "(", "CThreadContext", ")", "ref", ".", "get", "(", ")", ";", "}", "return", "context", ";", "}" ]
Return a thread context @return a thread context
[ "Return", "a", "thread", "context" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CThreadContext.java#L48-L60
4,101
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/converter/CThreadContext.java
CThreadContext.get
public final Object get(String key) { try { this.mutex.acquire(); return this.valueMap.get(key); } finally { try { this.mutex.release(); } catch (Exception ignore) { } } }
java
public final Object get(String key) { try { this.mutex.acquire(); return this.valueMap.get(key); } finally { try { this.mutex.release(); } catch (Exception ignore) { } } }
[ "public", "final", "Object", "get", "(", "String", "key", ")", "{", "try", "{", "this", ".", "mutex", ".", "acquire", "(", ")", ";", "return", "this", ".", "valueMap", ".", "get", "(", "key", ")", ";", "}", "finally", "{", "try", "{", "this", ".", "mutex", ".", "release", "(", ")", ";", "}", "catch", "(", "Exception", "ignore", ")", "{", "}", "}", "}" ]
Get the value with the given key from this context @param key the key to lookup @return the value with the given key from this context
[ "Get", "the", "value", "with", "the", "given", "key", "from", "this", "context" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CThreadContext.java#L74-L85
4,102
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/converter/CThreadContext.java
CThreadContext.set
public final void set(String key, Object value) { try { this.mutex.acquire(); if (value == null) { this.valueMap.remove(key); } else { this.valueMap.put(key, value); } } finally { try { this.mutex.release(); } catch (Exception ignore) { } } }
java
public final void set(String key, Object value) { try { this.mutex.acquire(); if (value == null) { this.valueMap.remove(key); } else { this.valueMap.put(key, value); } } finally { try { this.mutex.release(); } catch (Exception ignore) { } } }
[ "public", "final", "void", "set", "(", "String", "key", ",", "Object", "value", ")", "{", "try", "{", "this", ".", "mutex", ".", "acquire", "(", ")", ";", "if", "(", "value", "==", "null", ")", "{", "this", ".", "valueMap", ".", "remove", "(", "key", ")", ";", "}", "else", "{", "this", ".", "valueMap", ".", "put", "(", "key", ",", "value", ")", ";", "}", "}", "finally", "{", "try", "{", "this", ".", "mutex", ".", "release", "(", ")", ";", "}", "catch", "(", "Exception", "ignore", ")", "{", "}", "}", "}" ]
Set a value in this context @param key the key to save the value on @param value the value to set
[ "Set", "a", "value", "in", "this", "context" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CThreadContext.java#L95-L109
4,103
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/cl/converter/utils/CPadawan.java
CPadawan.replaceExpr
public final String replaceExpr( String message, String type ) { message = decode(message); List mapFilter = getFilter(type); if (mapFilter == null) return message; Iterator it = mapFilter.iterator(); while (it.hasNext()) { Object value[] = (Object[]) it.next(); String replacement = (String) value[0]; List vFilter = (List) value[1]; if ((vFilter.size() == 0) && (replacement.equals("[VALIDATE]"))) { message = validate( message, type ); continue; } for (int j = 0; j < vFilter.size(); j++) { Pattern filter = (Pattern) vFilter.get(j); Matcher match = filter.matcher(message); while (match.find()) { message = match.replaceAll(replacement); match = filter.matcher(message); } } } return message; }
java
public final String replaceExpr( String message, String type ) { message = decode(message); List mapFilter = getFilter(type); if (mapFilter == null) return message; Iterator it = mapFilter.iterator(); while (it.hasNext()) { Object value[] = (Object[]) it.next(); String replacement = (String) value[0]; List vFilter = (List) value[1]; if ((vFilter.size() == 0) && (replacement.equals("[VALIDATE]"))) { message = validate( message, type ); continue; } for (int j = 0; j < vFilter.size(); j++) { Pattern filter = (Pattern) vFilter.get(j); Matcher match = filter.matcher(message); while (match.find()) { message = match.replaceAll(replacement); match = filter.matcher(message); } } } return message; }
[ "public", "final", "String", "replaceExpr", "(", "String", "message", ",", "String", "type", ")", "{", "message", "=", "decode", "(", "message", ")", ";", "List", "mapFilter", "=", "getFilter", "(", "type", ")", ";", "if", "(", "mapFilter", "==", "null", ")", "return", "message", ";", "Iterator", "it", "=", "mapFilter", ".", "iterator", "(", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "Object", "value", "[", "]", "=", "(", "Object", "[", "]", ")", "it", ".", "next", "(", ")", ";", "String", "replacement", "=", "(", "String", ")", "value", "[", "0", "]", ";", "List", "vFilter", "=", "(", "List", ")", "value", "[", "1", "]", ";", "if", "(", "(", "vFilter", ".", "size", "(", ")", "==", "0", ")", "&&", "(", "replacement", ".", "equals", "(", "\"[VALIDATE]\"", ")", ")", ")", "{", "message", "=", "validate", "(", "message", ",", "type", ")", ";", "continue", ";", "}", "for", "(", "int", "j", "=", "0", ";", "j", "<", "vFilter", ".", "size", "(", ")", ";", "j", "++", ")", "{", "Pattern", "filter", "=", "(", "Pattern", ")", "vFilter", ".", "get", "(", "j", ")", ";", "Matcher", "match", "=", "filter", ".", "matcher", "(", "message", ")", ";", "while", "(", "match", ".", "find", "(", ")", ")", "{", "message", "=", "match", ".", "replaceAll", "(", "replacement", ")", ";", "match", "=", "filter", ".", "matcher", "(", "message", ")", ";", "}", "}", "}", "return", "message", ";", "}" ]
Replace the input message using the rules 'type' found in the xml configuration file @param message message to replace @param type rule type @return the replaced message
[ "Replace", "the", "input", "message", "using", "the", "rules", "type", "found", "in", "the", "xml", "configuration", "file" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/cl/converter/utils/CPadawan.java#L1109-L1148
4,104
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/cl/converter/utils/CPadawan.java
CPadawan.getInstance
public static final CPadawan getInstance() { try { mutex.acquire(); CPadawan toReturn = (handle == null) ? (handle = new CPadawan()) : handle; toReturn.init(); return toReturn; } finally { try { mutex.release(); } catch (Exception ignore) { } } }
java
public static final CPadawan getInstance() { try { mutex.acquire(); CPadawan toReturn = (handle == null) ? (handle = new CPadawan()) : handle; toReturn.init(); return toReturn; } finally { try { mutex.release(); } catch (Exception ignore) { } } }
[ "public", "static", "final", "CPadawan", "getInstance", "(", ")", "{", "try", "{", "mutex", ".", "acquire", "(", ")", ";", "CPadawan", "toReturn", "=", "(", "handle", "==", "null", ")", "?", "(", "handle", "=", "new", "CPadawan", "(", ")", ")", ":", "handle", ";", "toReturn", ".", "init", "(", ")", ";", "return", "toReturn", ";", "}", "finally", "{", "try", "{", "mutex", ".", "release", "(", ")", ";", "}", "catch", "(", "Exception", "ignore", ")", "{", "}", "}", "}" ]
Return an instance of the padawan @return may the force be with you !
[ "Return", "an", "instance", "of", "the", "padawan" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/cl/converter/utils/CPadawan.java#L1192-L1209
4,105
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/cl/converter/utils/CPadawan.java
CPadawan.getFilter
private final List getFilter(String type) { try { mutex.acquire(); return (List) mapFilter.get(type + ".filter"); } finally { try{mutex.release();}catch(Throwable ignore){} } }
java
private final List getFilter(String type) { try { mutex.acquire(); return (List) mapFilter.get(type + ".filter"); } finally { try{mutex.release();}catch(Throwable ignore){} } }
[ "private", "final", "List", "getFilter", "(", "String", "type", ")", "{", "try", "{", "mutex", ".", "acquire", "(", ")", ";", "return", "(", "List", ")", "mapFilter", ".", "get", "(", "type", "+", "\".filter\"", ")", ";", "}", "finally", "{", "try", "{", "mutex", ".", "release", "(", ")", ";", "}", "catch", "(", "Throwable", "ignore", ")", "{", "}", "}", "}" ]
return the filters of type 'type' @param type type of filters to get @return the filters of type 'type'
[ "return", "the", "filters", "of", "type", "type" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/cl/converter/utils/CPadawan.java#L1218-L1226
4,106
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/cl/converter/utils/CPadawan.java
CPadawan.validate
public final String validate( String in, String type ) { CShaniDomParser parser = new CShaniDomParser(); Document doc = parser.parse( new StringReader(in), getTags(type), getMerge(type) ); if (doc != null) return doc.toString(); else return in; }
java
public final String validate( String in, String type ) { CShaniDomParser parser = new CShaniDomParser(); Document doc = parser.parse( new StringReader(in), getTags(type), getMerge(type) ); if (doc != null) return doc.toString(); else return in; }
[ "public", "final", "String", "validate", "(", "String", "in", ",", "String", "type", ")", "{", "CShaniDomParser", "parser", "=", "new", "CShaniDomParser", "(", ")", ";", "Document", "doc", "=", "parser", ".", "parse", "(", "new", "StringReader", "(", "in", ")", ",", "getTags", "(", "type", ")", ",", "getMerge", "(", "type", ")", ")", ";", "if", "(", "doc", "!=", "null", ")", "return", "doc", ".", "toString", "(", ")", ";", "else", "return", "in", ";", "}" ]
validate for xml the string in using the rules type 'type' @param in the string to validate @param type rule type @return the validated string
[ "validate", "for", "xml", "the", "string", "in", "using", "the", "rules", "type", "type" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/cl/converter/utils/CPadawan.java#L1469-L1485
4,107
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/cl/converter/utils/CPadawan.java
CPadawan.createEntityDeclaration
public final String createEntityDeclaration() throws UnsupportedEncodingException { StringBuffer buffer = new StringBuffer(); buffer.append("<!DOCTYPE padawan [\n"); for (int i = 0; i < entity.length; i++) { buffer.append( "<!ENTITY " + entity[i][1] + " '" + entity[i][0] + "' >\n" ); } buffer.append("]>\n"); return buffer.toString(); }
java
public final String createEntityDeclaration() throws UnsupportedEncodingException { StringBuffer buffer = new StringBuffer(); buffer.append("<!DOCTYPE padawan [\n"); for (int i = 0; i < entity.length; i++) { buffer.append( "<!ENTITY " + entity[i][1] + " '" + entity[i][0] + "' >\n" ); } buffer.append("]>\n"); return buffer.toString(); }
[ "public", "final", "String", "createEntityDeclaration", "(", ")", "throws", "UnsupportedEncodingException", "{", "StringBuffer", "buffer", "=", "new", "StringBuffer", "(", ")", ";", "buffer", ".", "append", "(", "\"<!DOCTYPE padawan [\\n\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "entity", ".", "length", ";", "i", "++", ")", "{", "buffer", ".", "append", "(", "\"<!ENTITY \"", "+", "entity", "[", "i", "]", "[", "1", "]", "+", "\" '\"", "+", "entity", "[", "i", "]", "[", "0", "]", "+", "\"' >\\n\"", ")", ";", "}", "buffer", ".", "append", "(", "\"]>\\n\"", ")", ";", "return", "buffer", ".", "toString", "(", ")", ";", "}" ]
Create the padawan doctype @return the padawan doctype @throws UnsupportedEncodingException should not happen
[ "Create", "the", "padawan", "doctype" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/cl/converter/utils/CPadawan.java#L1494-L1508
4,108
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/cl/converter/utils/CPadawan.java
CPadawan.getEntityDeclaration
public final String getEntityDeclaration() { if (entityDecl == null) try { entityDecl = createEntityDeclaration(); } catch (Exception e) { entityDecl = null; } return entityDecl; }
java
public final String getEntityDeclaration() { if (entityDecl == null) try { entityDecl = createEntityDeclaration(); } catch (Exception e) { entityDecl = null; } return entityDecl; }
[ "public", "final", "String", "getEntityDeclaration", "(", ")", "{", "if", "(", "entityDecl", "==", "null", ")", "try", "{", "entityDecl", "=", "createEntityDeclaration", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "entityDecl", "=", "null", ";", "}", "return", "entityDecl", ";", "}" ]
return the padawan doctype @return the padawan doctype
[ "return", "the", "padawan", "doctype" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/cl/converter/utils/CPadawan.java#L1515-L1524
4,109
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/cl/converter/utils/CPadawan.java
CPadawan.decode
public final String decode(String toDecode) { CEntityCoDec codec = new CEntityCoDec(new HashMap()); return codec.decode(toDecode); }
java
public final String decode(String toDecode) { CEntityCoDec codec = new CEntityCoDec(new HashMap()); return codec.decode(toDecode); }
[ "public", "final", "String", "decode", "(", "String", "toDecode", ")", "{", "CEntityCoDec", "codec", "=", "new", "CEntityCoDec", "(", "new", "HashMap", "(", ")", ")", ";", "return", "codec", ".", "decode", "(", "toDecode", ")", ";", "}" ]
decode entity in the string @param toDecode the string to decode @return the decoded string
[ "decode", "entity", "in", "the", "string" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/cl/converter/utils/CPadawan.java#L1533-L1537
4,110
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/cl/converter/utils/CPadawan.java
CPadawan.stringReplace
public final String stringReplace( String toBeReplaced, String toReplace, String replacement ) { Pattern pattern = Pattern.compile(toReplace); Matcher match = pattern.matcher(toBeReplaced); while (match.find()) { toBeReplaced = match.replaceAll(replacement); match = pattern.matcher(toBeReplaced); } return toBeReplaced; }
java
public final String stringReplace( String toBeReplaced, String toReplace, String replacement ) { Pattern pattern = Pattern.compile(toReplace); Matcher match = pattern.matcher(toBeReplaced); while (match.find()) { toBeReplaced = match.replaceAll(replacement); match = pattern.matcher(toBeReplaced); } return toBeReplaced; }
[ "public", "final", "String", "stringReplace", "(", "String", "toBeReplaced", ",", "String", "toReplace", ",", "String", "replacement", ")", "{", "Pattern", "pattern", "=", "Pattern", ".", "compile", "(", "toReplace", ")", ";", "Matcher", "match", "=", "pattern", ".", "matcher", "(", "toBeReplaced", ")", ";", "while", "(", "match", ".", "find", "(", ")", ")", "{", "toBeReplaced", "=", "match", ".", "replaceAll", "(", "replacement", ")", ";", "match", "=", "pattern", ".", "matcher", "(", "toBeReplaced", ")", ";", "}", "return", "toBeReplaced", ";", "}" ]
A replace string method @param toBeReplaced string to replace @param toReplace regex to match @param replacement string replacement for each match @return the replaced string
[ "A", "replace", "string", "method" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/cl/converter/utils/CPadawan.java#L1559-L1573
4,111
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/cl/converter/utils/CPadawan.java
CPadawan.isAlone
private final boolean isAlone( String tagName, String aloneTags[] ) { if (aloneTags == null) return false; if (tagName == null) return false; for (int i = 0; i < aloneTags.length; i++) { if (tagName.equalsIgnoreCase(aloneTags[i])) return true; } return false; }
java
private final boolean isAlone( String tagName, String aloneTags[] ) { if (aloneTags == null) return false; if (tagName == null) return false; for (int i = 0; i < aloneTags.length; i++) { if (tagName.equalsIgnoreCase(aloneTags[i])) return true; } return false; }
[ "private", "final", "boolean", "isAlone", "(", "String", "tagName", ",", "String", "aloneTags", "[", "]", ")", "{", "if", "(", "aloneTags", "==", "null", ")", "return", "false", ";", "if", "(", "tagName", "==", "null", ")", "return", "false", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "aloneTags", ".", "length", ";", "i", "++", ")", "{", "if", "(", "tagName", ".", "equalsIgnoreCase", "(", "aloneTags", "[", "i", "]", ")", ")", "return", "true", ";", "}", "return", "false", ";", "}" ]
return true if the given tag name is an empty tag @param tagName tag name to lookup @param aloneTags a string array of empty tags @return true if the given tag name is an empty tag
[ "return", "true", "if", "the", "given", "tag", "name", "is", "an", "empty", "tag" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/cl/converter/utils/CPadawan.java#L1950-L1966
4,112
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/cl/converter/utils/CPadawan.java
CPadawan.escapeAttribute
public final String escapeAttribute(String in) { in = escape(in); in = in.replaceAll( "\"", "&quot;" ); return in; }
java
public final String escapeAttribute(String in) { in = escape(in); in = in.replaceAll( "\"", "&quot;" ); return in; }
[ "public", "final", "String", "escapeAttribute", "(", "String", "in", ")", "{", "in", "=", "escape", "(", "in", ")", ";", "in", "=", "in", ".", "replaceAll", "(", "\"\\\"\"", ",", "\"&quot;\"", ")", ";", "return", "in", ";", "}" ]
Escape the given string to be a valid content for an xml attribute @param in the string to escape @return the escaped string
[ "Escape", "the", "given", "string", "to", "be", "a", "valid", "content", "for", "an", "xml", "attribute" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/cl/converter/utils/CPadawan.java#L1975-L1983
4,113
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/cl/converter/utils/CPadawan.java
CPadawan.escape
public final String escape(String in) { if (in == null) return ""; if (in.trim() .equals("")) return in; if (in.trim() .length() == 0) return in; in = in.replaceAll( "&", "&amp;" ); in = in.replaceAll( "<", "&lt;" ); in = in.replaceAll( ">", "&gt;" ); StringBuffer result = new StringBuffer(); char chars[] = in.toCharArray(); for (int i = 0; i < chars.length; i++) { if ((chars[i] >= 127) && (chars[i] < 160)) { chars[i] = 32; result.append(chars[i]); } else if (chars[i] == 160) { result.append("&#160;"); } else if (chars[i] == 9) { result.append(" "); } else if ((chars[i] < 32) && (chars[i] != 9) && (chars[i] != 10) && (chars[i] != 13) ) { chars[i] = 32; result.append(chars[i]); } else { result.append(chars[i]); } } in = result.toString(); return in; }
java
public final String escape(String in) { if (in == null) return ""; if (in.trim() .equals("")) return in; if (in.trim() .length() == 0) return in; in = in.replaceAll( "&", "&amp;" ); in = in.replaceAll( "<", "&lt;" ); in = in.replaceAll( ">", "&gt;" ); StringBuffer result = new StringBuffer(); char chars[] = in.toCharArray(); for (int i = 0; i < chars.length; i++) { if ((chars[i] >= 127) && (chars[i] < 160)) { chars[i] = 32; result.append(chars[i]); } else if (chars[i] == 160) { result.append("&#160;"); } else if (chars[i] == 9) { result.append(" "); } else if ((chars[i] < 32) && (chars[i] != 9) && (chars[i] != 10) && (chars[i] != 13) ) { chars[i] = 32; result.append(chars[i]); } else { result.append(chars[i]); } } in = result.toString(); return in; }
[ "public", "final", "String", "escape", "(", "String", "in", ")", "{", "if", "(", "in", "==", "null", ")", "return", "\"\"", ";", "if", "(", "in", ".", "trim", "(", ")", ".", "equals", "(", "\"\"", ")", ")", "return", "in", ";", "if", "(", "in", ".", "trim", "(", ")", ".", "length", "(", ")", "==", "0", ")", "return", "in", ";", "in", "=", "in", ".", "replaceAll", "(", "\"&\"", ",", "\"&amp;\"", ")", ";", "in", "=", "in", ".", "replaceAll", "(", "\"<\"", ",", "\"&lt;\"", ")", ";", "in", "=", "in", ".", "replaceAll", "(", "\">\"", ",", "\"&gt;\"", ")", ";", "StringBuffer", "result", "=", "new", "StringBuffer", "(", ")", ";", "char", "chars", "[", "]", "=", "in", ".", "toCharArray", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "chars", ".", "length", ";", "i", "++", ")", "{", "if", "(", "(", "chars", "[", "i", "]", ">=", "127", ")", "&&", "(", "chars", "[", "i", "]", "<", "160", ")", ")", "{", "chars", "[", "i", "]", "=", "32", ";", "result", ".", "append", "(", "chars", "[", "i", "]", ")", ";", "}", "else", "if", "(", "chars", "[", "i", "]", "==", "160", ")", "{", "result", ".", "append", "(", "\"&#160;\"", ")", ";", "}", "else", "if", "(", "chars", "[", "i", "]", "==", "9", ")", "{", "result", ".", "append", "(", "\" \"", ")", ";", "}", "else", "if", "(", "(", "chars", "[", "i", "]", "<", "32", ")", "&&", "(", "chars", "[", "i", "]", "!=", "9", ")", "&&", "(", "chars", "[", "i", "]", "!=", "10", ")", "&&", "(", "chars", "[", "i", "]", "!=", "13", ")", ")", "{", "chars", "[", "i", "]", "=", "32", ";", "result", ".", "append", "(", "chars", "[", "i", "]", ")", ";", "}", "else", "{", "result", ".", "append", "(", "chars", "[", "i", "]", ")", ";", "}", "}", "in", "=", "result", ".", "toString", "(", ")", ";", "return", "in", ";", "}" ]
Escape the given string to be a valid content for an xml text node content @param in the string to escape @return the escaped string
[ "Escape", "the", "given", "string", "to", "be", "a", "valid", "content", "for", "an", "xml", "text", "node", "content" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/cl/converter/utils/CPadawan.java#L1993-L2042
4,114
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java
CClassLoader.createLoader
private static final CClassLoader createLoader(final ClassLoader parent, final String name) { try { return new CClassLoader(parent, name); } catch (final Exception ignore) { return null; } }
java
private static final CClassLoader createLoader(final ClassLoader parent, final String name) { try { return new CClassLoader(parent, name); } catch (final Exception ignore) { return null; } }
[ "private", "static", "final", "CClassLoader", "createLoader", "(", "final", "ClassLoader", "parent", ",", "final", "String", "name", ")", "{", "try", "{", "return", "new", "CClassLoader", "(", "parent", ",", "name", ")", ";", "}", "catch", "(", "final", "Exception", "ignore", ")", "{", "return", "null", ";", "}", "}" ]
Create a new loader @param parent a reference to the parent loader @param name loader name @return a new loader
[ "Create", "a", "new", "loader" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java#L125-L132
4,115
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java
CClassLoader.createMemoryURL
public static URL createMemoryURL(final String entryName, final byte[] entry) { try { final Class c = ClassLoader.getSystemClassLoader().loadClass( "org.allcolor.yahp.converter.CMemoryURLHandler"); final Method m = c.getDeclaredMethod("createMemoryURL", new Class[] { String.class, byte[].class }); m.setAccessible(true); return (URL) m.invoke(null, new Object[] { entryName, entry }); } catch (final Exception ignore) { ignore.printStackTrace(); return null; } }
java
public static URL createMemoryURL(final String entryName, final byte[] entry) { try { final Class c = ClassLoader.getSystemClassLoader().loadClass( "org.allcolor.yahp.converter.CMemoryURLHandler"); final Method m = c.getDeclaredMethod("createMemoryURL", new Class[] { String.class, byte[].class }); m.setAccessible(true); return (URL) m.invoke(null, new Object[] { entryName, entry }); } catch (final Exception ignore) { ignore.printStackTrace(); return null; } }
[ "public", "static", "URL", "createMemoryURL", "(", "final", "String", "entryName", ",", "final", "byte", "[", "]", "entry", ")", "{", "try", "{", "final", "Class", "c", "=", "ClassLoader", ".", "getSystemClassLoader", "(", ")", ".", "loadClass", "(", "\"org.allcolor.yahp.converter.CMemoryURLHandler\"", ")", ";", "final", "Method", "m", "=", "c", ".", "getDeclaredMethod", "(", "\"createMemoryURL\"", ",", "new", "Class", "[", "]", "{", "String", ".", "class", ",", "byte", "[", "]", ".", "class", "}", ")", ";", "m", ".", "setAccessible", "(", "true", ")", ";", "return", "(", "URL", ")", "m", ".", "invoke", "(", "null", ",", "new", "Object", "[", "]", "{", "entryName", ",", "entry", "}", ")", ";", "}", "catch", "(", "final", "Exception", "ignore", ")", "{", "ignore", ".", "printStackTrace", "(", ")", ";", "return", "null", ";", "}", "}" ]
Creates and allocates a memory URL @param entryName name of the entry @param entry byte array of the entry @return the created URL or null if an error occurs.
[ "Creates", "and", "allocates", "a", "memory", "URL" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java#L143-L155
4,116
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java
CClassLoader.getClasses
private static List getClasses(final File current, final List list) { if (current.isDirectory()) { try { list.add(current.toURI().toURL()); } catch (final Exception ignore) { } final File children[] = current.listFiles(); for (int i = 0; i < children.length; i++) { final File element = children[i]; CClassLoader.getClasses(element, list); } } else if (current.isFile()) { final String name = current.getName(); if (name.endsWith(".class")) { try { list.add(current.toURI().toURL()); } catch (final Exception ignore) { } } else if (name.endsWith(".jar")) { try { list.add(current.toURI().toURL()); } catch (final Exception ignore) { } } } return list; }
java
private static List getClasses(final File current, final List list) { if (current.isDirectory()) { try { list.add(current.toURI().toURL()); } catch (final Exception ignore) { } final File children[] = current.listFiles(); for (int i = 0; i < children.length; i++) { final File element = children[i]; CClassLoader.getClasses(element, list); } } else if (current.isFile()) { final String name = current.getName(); if (name.endsWith(".class")) { try { list.add(current.toURI().toURL()); } catch (final Exception ignore) { } } else if (name.endsWith(".jar")) { try { list.add(current.toURI().toURL()); } catch (final Exception ignore) { } } } return list; }
[ "private", "static", "List", "getClasses", "(", "final", "File", "current", ",", "final", "List", "list", ")", "{", "if", "(", "current", ".", "isDirectory", "(", ")", ")", "{", "try", "{", "list", ".", "add", "(", "current", ".", "toURI", "(", ")", ".", "toURL", "(", ")", ")", ";", "}", "catch", "(", "final", "Exception", "ignore", ")", "{", "}", "final", "File", "children", "[", "]", "=", "current", ".", "listFiles", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "children", ".", "length", ";", "i", "++", ")", "{", "final", "File", "element", "=", "children", "[", "i", "]", ";", "CClassLoader", ".", "getClasses", "(", "element", ",", "list", ")", ";", "}", "}", "else", "if", "(", "current", ".", "isFile", "(", ")", ")", "{", "final", "String", "name", "=", "current", ".", "getName", "(", ")", ";", "if", "(", "name", ".", "endsWith", "(", "\".class\"", ")", ")", "{", "try", "{", "list", ".", "add", "(", "current", ".", "toURI", "(", ")", ".", "toURL", "(", ")", ")", ";", "}", "catch", "(", "final", "Exception", "ignore", ")", "{", "}", "}", "else", "if", "(", "name", ".", "endsWith", "(", "\".jar\"", ")", ")", "{", "try", "{", "list", ".", "add", "(", "current", ".", "toURI", "(", ")", ".", "toURL", "(", ")", ")", ";", "}", "catch", "(", "final", "Exception", "ignore", ")", "{", "}", "}", "}", "return", "list", ";", "}" ]
Return a list of classes and jar files @param current currently inspected file @param list list of url to classes and jar files @return list of url to classes and jar files
[ "Return", "a", "list", "of", "classes", "and", "jar", "files" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java#L643-L673
4,117
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java
CClassLoader.getLoader
public static final CClassLoader getLoader(final String fpath) { String path = fpath; CClassLoader currentLoader = CClassLoader.rootLoader; if (path == null) { return CClassLoader.getRootLoader(); } if (path.startsWith(CClassLoader.ROOT_LOADER)) { path = path.substring(10); } final StringTokenizer tokenizer = new StringTokenizer(path, "/", false); while (tokenizer.hasMoreTokens()) { final String name = tokenizer.nextToken(); currentLoader = currentLoader.getLoaderByName(name); } return currentLoader; }
java
public static final CClassLoader getLoader(final String fpath) { String path = fpath; CClassLoader currentLoader = CClassLoader.rootLoader; if (path == null) { return CClassLoader.getRootLoader(); } if (path.startsWith(CClassLoader.ROOT_LOADER)) { path = path.substring(10); } final StringTokenizer tokenizer = new StringTokenizer(path, "/", false); while (tokenizer.hasMoreTokens()) { final String name = tokenizer.nextToken(); currentLoader = currentLoader.getLoaderByName(name); } return currentLoader; }
[ "public", "static", "final", "CClassLoader", "getLoader", "(", "final", "String", "fpath", ")", "{", "String", "path", "=", "fpath", ";", "CClassLoader", "currentLoader", "=", "CClassLoader", ".", "rootLoader", ";", "if", "(", "path", "==", "null", ")", "{", "return", "CClassLoader", ".", "getRootLoader", "(", ")", ";", "}", "if", "(", "path", ".", "startsWith", "(", "CClassLoader", ".", "ROOT_LOADER", ")", ")", "{", "path", "=", "path", ".", "substring", "(", "10", ")", ";", "}", "final", "StringTokenizer", "tokenizer", "=", "new", "StringTokenizer", "(", "path", ",", "\"/\"", ",", "false", ")", ";", "while", "(", "tokenizer", ".", "hasMoreTokens", "(", ")", ")", "{", "final", "String", "name", "=", "tokenizer", ".", "nextToken", "(", ")", ";", "currentLoader", "=", "currentLoader", ".", "getLoaderByName", "(", "name", ")", ";", "}", "return", "currentLoader", ";", "}" ]
return the loader with the given path @param fpath the path to lookup @return the loader with the given path
[ "return", "the", "loader", "with", "the", "given", "path" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java#L689-L709
4,118
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java
CClassLoader.getRootLoader
public static final CClassLoader getRootLoader() { if (CClassLoader.rootLoader == null) { CClassLoader.rootLoader = CClassLoader.createLoader( CClassLoader.class.getClassLoader(), CClassLoader.ROOT_LOADER); } return CClassLoader.rootLoader; }
java
public static final CClassLoader getRootLoader() { if (CClassLoader.rootLoader == null) { CClassLoader.rootLoader = CClassLoader.createLoader( CClassLoader.class.getClassLoader(), CClassLoader.ROOT_LOADER); } return CClassLoader.rootLoader; }
[ "public", "static", "final", "CClassLoader", "getRootLoader", "(", ")", "{", "if", "(", "CClassLoader", ".", "rootLoader", "==", "null", ")", "{", "CClassLoader", ".", "rootLoader", "=", "CClassLoader", ".", "createLoader", "(", "CClassLoader", ".", "class", ".", "getClassLoader", "(", ")", ",", "CClassLoader", ".", "ROOT_LOADER", ")", ";", "}", "return", "CClassLoader", ".", "rootLoader", ";", "}" ]
return the rootloader @return the rootloader
[ "return", "the", "rootloader" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java#L716-L723
4,119
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java
CClassLoader.getURLs
public static URL[] getURLs(final String path) { final File topDir = new File(path); final List list = new ArrayList(); CClassLoader.getClasses(topDir, list); final URL ret[] = new URL[list.size() + 1]; for (int i = 0; i < list.size(); i++) { ret[i] = (URL) list.get(i); } try { ret[list.size()] = topDir.toURI().toURL(); } catch (final Exception ignore) { } return ret; }
java
public static URL[] getURLs(final String path) { final File topDir = new File(path); final List list = new ArrayList(); CClassLoader.getClasses(topDir, list); final URL ret[] = new URL[list.size() + 1]; for (int i = 0; i < list.size(); i++) { ret[i] = (URL) list.get(i); } try { ret[list.size()] = topDir.toURI().toURL(); } catch (final Exception ignore) { } return ret; }
[ "public", "static", "URL", "[", "]", "getURLs", "(", "final", "String", "path", ")", "{", "final", "File", "topDir", "=", "new", "File", "(", "path", ")", ";", "final", "List", "list", "=", "new", "ArrayList", "(", ")", ";", "CClassLoader", ".", "getClasses", "(", "topDir", ",", "list", ")", ";", "final", "URL", "ret", "[", "]", "=", "new", "URL", "[", "list", ".", "size", "(", ")", "+", "1", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "list", ".", "size", "(", ")", ";", "i", "++", ")", "{", "ret", "[", "i", "]", "=", "(", "URL", ")", "list", ".", "get", "(", "i", ")", ";", "}", "try", "{", "ret", "[", "list", ".", "size", "(", ")", "]", "=", "topDir", ".", "toURI", "(", ")", ".", "toURL", "(", ")", ";", "}", "catch", "(", "final", "Exception", "ignore", ")", "{", "}", "return", "ret", ";", "}" ]
Return a list of jar and classes located in path @param path the path in which to search @return a list of jar and classes located in path
[ "Return", "a", "list", "of", "jar", "and", "classes", "located", "in", "path" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java#L750-L767
4,120
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java
CClassLoader.loadByteArray
public static final byte[] loadByteArray(final InputStream in) { try { final ByteArrayOutputStream bOut = new ByteArrayOutputStream(); final byte buffer[] = new byte[2048]; int iNbByteRead = -1; while ((iNbByteRead = in.read(buffer)) != -1) { bOut.write(buffer, 0, iNbByteRead); } return bOut.toByteArray(); } catch (final IOException ioe) { return null; } }
java
public static final byte[] loadByteArray(final InputStream in) { try { final ByteArrayOutputStream bOut = new ByteArrayOutputStream(); final byte buffer[] = new byte[2048]; int iNbByteRead = -1; while ((iNbByteRead = in.read(buffer)) != -1) { bOut.write(buffer, 0, iNbByteRead); } return bOut.toByteArray(); } catch (final IOException ioe) { return null; } }
[ "public", "static", "final", "byte", "[", "]", "loadByteArray", "(", "final", "InputStream", "in", ")", "{", "try", "{", "final", "ByteArrayOutputStream", "bOut", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "final", "byte", "buffer", "[", "]", "=", "new", "byte", "[", "2048", "]", ";", "int", "iNbByteRead", "=", "-", "1", ";", "while", "(", "(", "iNbByteRead", "=", "in", ".", "read", "(", "buffer", ")", ")", "!=", "-", "1", ")", "{", "bOut", ".", "write", "(", "buffer", ",", "0", ",", "iNbByteRead", ")", ";", "}", "return", "bOut", ".", "toByteArray", "(", ")", ";", "}", "catch", "(", "final", "IOException", "ioe", ")", "{", "return", "null", ";", "}", "}" ]
load the given inputstream in a byte array @param in the stream to load @return a byte array
[ "load", "the", "given", "inputstream", "in", "a", "byte", "array" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java#L1003-L1019
4,121
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java
CClassLoader.loadByteArray
public static final byte[] loadByteArray(final URL urlToResource) { InputStream in = null; try { final URLConnection uc = urlToResource.openConnection(); uc.setUseCaches(false); in = uc.getInputStream(); return CClassLoader.loadByteArray(in); } catch (final IOException ioe) { return null; } finally { try { in.close(); } catch (final Exception ignore) { } } }
java
public static final byte[] loadByteArray(final URL urlToResource) { InputStream in = null; try { final URLConnection uc = urlToResource.openConnection(); uc.setUseCaches(false); in = uc.getInputStream(); return CClassLoader.loadByteArray(in); } catch (final IOException ioe) { return null; } finally { try { in.close(); } catch (final Exception ignore) { } } }
[ "public", "static", "final", "byte", "[", "]", "loadByteArray", "(", "final", "URL", "urlToResource", ")", "{", "InputStream", "in", "=", "null", ";", "try", "{", "final", "URLConnection", "uc", "=", "urlToResource", ".", "openConnection", "(", ")", ";", "uc", ".", "setUseCaches", "(", "false", ")", ";", "in", "=", "uc", ".", "getInputStream", "(", ")", ";", "return", "CClassLoader", ".", "loadByteArray", "(", "in", ")", ";", "}", "catch", "(", "final", "IOException", "ioe", ")", "{", "return", "null", ";", "}", "finally", "{", "try", "{", "in", ".", "close", "(", ")", ";", "}", "catch", "(", "final", "Exception", "ignore", ")", "{", "}", "}", "}" ]
load the given url in a byte array @param urlToResource url to load @return a byte array
[ "load", "the", "given", "url", "in", "a", "byte", "array" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java#L1029-L1046
4,122
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java
CClassLoader.loadResources
private static final void loadResources(final CClassLoader loader, final List URLList, final String resourceName) { final List l = loader.getPrivateResource(resourceName); if (l != null) { URLList.addAll(l); } final List loaderList = new ArrayList(); for (final Iterator it = loader.childrenMap.entrySet().iterator(); it .hasNext();) { final Entry entry = (Entry) it.next(); loaderList.add(entry.getValue()); } for (int i = 0; i < loaderList.size(); i++) { final Object element = loaderList.get(i); final CClassLoader child = (CClassLoader) element; CClassLoader.loadResources(child, URLList, resourceName); } }
java
private static final void loadResources(final CClassLoader loader, final List URLList, final String resourceName) { final List l = loader.getPrivateResource(resourceName); if (l != null) { URLList.addAll(l); } final List loaderList = new ArrayList(); for (final Iterator it = loader.childrenMap.entrySet().iterator(); it .hasNext();) { final Entry entry = (Entry) it.next(); loaderList.add(entry.getValue()); } for (int i = 0; i < loaderList.size(); i++) { final Object element = loaderList.get(i); final CClassLoader child = (CClassLoader) element; CClassLoader.loadResources(child, URLList, resourceName); } }
[ "private", "static", "final", "void", "loadResources", "(", "final", "CClassLoader", "loader", ",", "final", "List", "URLList", ",", "final", "String", "resourceName", ")", "{", "final", "List", "l", "=", "loader", ".", "getPrivateResource", "(", "resourceName", ")", ";", "if", "(", "l", "!=", "null", ")", "{", "URLList", ".", "addAll", "(", "l", ")", ";", "}", "final", "List", "loaderList", "=", "new", "ArrayList", "(", ")", ";", "for", "(", "final", "Iterator", "it", "=", "loader", ".", "childrenMap", ".", "entrySet", "(", ")", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "final", "Entry", "entry", "=", "(", "Entry", ")", "it", ".", "next", "(", ")", ";", "loaderList", ".", "add", "(", "entry", ".", "getValue", "(", ")", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "loaderList", ".", "size", "(", ")", ";", "i", "++", ")", "{", "final", "Object", "element", "=", "loaderList", ".", "get", "(", "i", ")", ";", "final", "CClassLoader", "child", "=", "(", "CClassLoader", ")", "element", ";", "CClassLoader", ".", "loadResources", "(", "child", ",", "URLList", ",", "resourceName", ")", ";", "}", "}" ]
load multiple resources of same name @param loader current lookup loader @param URLList list of found resources @param resourceName name to match
[ "load", "multiple", "resources", "of", "same", "name" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java#L1058-L1079
4,123
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java
CClassLoader.log
private static final void log(final String Message, final int level) { if ((level == CClassLoader.INFO) && CClassLoader.log.isLoggable(Level.INFO)) { CClassLoader.log.info(Message); } else if ((level == CClassLoader.DEBUG) && CClassLoader.log.isLoggable(Level.FINE)) { CClassLoader.log.fine(Message); } else if ((level == CClassLoader.FATAL) && CClassLoader.log.isLoggable(Level.SEVERE)) { CClassLoader.log.severe(Message); } }
java
private static final void log(final String Message, final int level) { if ((level == CClassLoader.INFO) && CClassLoader.log.isLoggable(Level.INFO)) { CClassLoader.log.info(Message); } else if ((level == CClassLoader.DEBUG) && CClassLoader.log.isLoggable(Level.FINE)) { CClassLoader.log.fine(Message); } else if ((level == CClassLoader.FATAL) && CClassLoader.log.isLoggable(Level.SEVERE)) { CClassLoader.log.severe(Message); } }
[ "private", "static", "final", "void", "log", "(", "final", "String", "Message", ",", "final", "int", "level", ")", "{", "if", "(", "(", "level", "==", "CClassLoader", ".", "INFO", ")", "&&", "CClassLoader", ".", "log", ".", "isLoggable", "(", "Level", ".", "INFO", ")", ")", "{", "CClassLoader", ".", "log", ".", "info", "(", "Message", ")", ";", "}", "else", "if", "(", "(", "level", "==", "CClassLoader", ".", "DEBUG", ")", "&&", "CClassLoader", ".", "log", ".", "isLoggable", "(", "Level", ".", "FINE", ")", ")", "{", "CClassLoader", ".", "log", ".", "fine", "(", "Message", ")", ";", "}", "else", "if", "(", "(", "level", "==", "CClassLoader", ".", "FATAL", ")", "&&", "CClassLoader", ".", "log", ".", "isLoggable", "(", "Level", ".", "SEVERE", ")", ")", "{", "CClassLoader", ".", "log", ".", "severe", "(", "Message", ")", ";", "}", "}" ]
log the message @param Message message to log @param level log level (INFO,DEBUG,FATAL)
[ "log", "the", "message" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java#L1089-L1100
4,124
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java
CClassLoader.releaseMemoryURL
public static void releaseMemoryURL(final URL u) { try { final Class c = ClassLoader.getSystemClassLoader().loadClass( "org.allcolor.yahp.converter.CMemoryURLHandler"); final Method m = c.getDeclaredMethod("releaseMemoryURL", new Class[] { URL.class }); m.setAccessible(true); m.invoke(null, new Object[] { u }); } catch (final Exception ignore) { ignore.printStackTrace(); } }
java
public static void releaseMemoryURL(final URL u) { try { final Class c = ClassLoader.getSystemClassLoader().loadClass( "org.allcolor.yahp.converter.CMemoryURLHandler"); final Method m = c.getDeclaredMethod("releaseMemoryURL", new Class[] { URL.class }); m.setAccessible(true); m.invoke(null, new Object[] { u }); } catch (final Exception ignore) { ignore.printStackTrace(); } }
[ "public", "static", "void", "releaseMemoryURL", "(", "final", "URL", "u", ")", "{", "try", "{", "final", "Class", "c", "=", "ClassLoader", ".", "getSystemClassLoader", "(", ")", ".", "loadClass", "(", "\"org.allcolor.yahp.converter.CMemoryURLHandler\"", ")", ";", "final", "Method", "m", "=", "c", ".", "getDeclaredMethod", "(", "\"releaseMemoryURL\"", ",", "new", "Class", "[", "]", "{", "URL", ".", "class", "}", ")", ";", "m", ".", "setAccessible", "(", "true", ")", ";", "m", ".", "invoke", "(", "null", ",", "new", "Object", "[", "]", "{", "u", "}", ")", ";", "}", "catch", "(", "final", "Exception", "ignore", ")", "{", "ignore", ".", "printStackTrace", "(", ")", ";", "}", "}" ]
Release a previously allocated memory URL @param u the URL to release memory
[ "Release", "a", "previously", "allocated", "memory", "URL" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java#L1108-L1119
4,125
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java
CClassLoader.setInit
private static final void setInit(final CClassLoader loader) { loader.booInit = true; for (final Iterator it = loader.getChildLoader(); it.hasNext();) { final Map.Entry entry = (Map.Entry) it.next(); CClassLoader.setInit((CClassLoader) entry.getValue()); } }
java
private static final void setInit(final CClassLoader loader) { loader.booInit = true; for (final Iterator it = loader.getChildLoader(); it.hasNext();) { final Map.Entry entry = (Map.Entry) it.next(); CClassLoader.setInit((CClassLoader) entry.getValue()); } }
[ "private", "static", "final", "void", "setInit", "(", "final", "CClassLoader", "loader", ")", "{", "loader", ".", "booInit", "=", "true", ";", "for", "(", "final", "Iterator", "it", "=", "loader", ".", "getChildLoader", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "final", "Map", ".", "Entry", "entry", "=", "(", "Map", ".", "Entry", ")", "it", ".", "next", "(", ")", ";", "CClassLoader", ".", "setInit", "(", "(", "CClassLoader", ")", "entry", ".", "getValue", "(", ")", ")", ";", "}", "}" ]
set the init flag of all loaders @param loader the current loader
[ "set", "the", "init", "flag", "of", "all", "loaders" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java#L1131-L1138
4,126
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java
CClassLoader.sl
private static final boolean sl(final int level) { if ((level == CClassLoader.INFO) && CClassLoader.log.isLoggable(Level.INFO)) { return true; } else if ((level == CClassLoader.DEBUG) && CClassLoader.log.isLoggable(Level.FINE)) { return true; } else if ((level == CClassLoader.FATAL) && CClassLoader.log.isLoggable(Level.SEVERE)) { return true; } return false; }
java
private static final boolean sl(final int level) { if ((level == CClassLoader.INFO) && CClassLoader.log.isLoggable(Level.INFO)) { return true; } else if ((level == CClassLoader.DEBUG) && CClassLoader.log.isLoggable(Level.FINE)) { return true; } else if ((level == CClassLoader.FATAL) && CClassLoader.log.isLoggable(Level.SEVERE)) { return true; } return false; }
[ "private", "static", "final", "boolean", "sl", "(", "final", "int", "level", ")", "{", "if", "(", "(", "level", "==", "CClassLoader", ".", "INFO", ")", "&&", "CClassLoader", ".", "log", ".", "isLoggable", "(", "Level", ".", "INFO", ")", ")", "{", "return", "true", ";", "}", "else", "if", "(", "(", "level", "==", "CClassLoader", ".", "DEBUG", ")", "&&", "CClassLoader", ".", "log", ".", "isLoggable", "(", "Level", ".", "FINE", ")", ")", "{", "return", "true", ";", "}", "else", "if", "(", "(", "level", "==", "CClassLoader", ".", "FATAL", ")", "&&", "CClassLoader", ".", "log", ".", "isLoggable", "(", "Level", ".", "SEVERE", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
test if the logging level is enabled @param level the logging level to test @return true if enabled
[ "test", "if", "the", "logging", "level", "is", "enabled" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java#L1158-L1171
4,127
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java
CClassLoader._destroy
private final void _destroy(final Method logFactoryRelease) { for (final Iterator it = this.childrenMap.entrySet().iterator(); it .hasNext();) { final Map.Entry entry = (Map.Entry) it.next(); final CClassLoader loader = (CClassLoader) entry.getValue(); loader._destroy(logFactoryRelease); it.remove(); } try { // remove ref from commons logging logFactoryRelease.invoke(null, new Object[] { this }); } catch (final Exception e) { } try { // reset parent to system class loader final Field parent = ClassLoader.class.getDeclaredField("parent"); parent.setAccessible(true); parent.set(this, ClassLoader.getSystemClassLoader()); parent.setAccessible(false); } catch (final Throwable ignore) { } this.classesMap.clear(); for (final Iterator it = this.dllMap.entrySet().iterator(); it .hasNext();) { final Object element = it.next(); final Map.Entry entry = (Map.Entry) element; if (entry.getValue() instanceof File) { ((File) entry.getValue()).delete(); } } this.cacheMap.clear(); this.dllMap.clear(); this.resourcesMap.clear(); this.config = null; this.name = null; this.finalizepath = this.path; this.path = null; //classes System.runFinalization(); System.gc(); }
java
private final void _destroy(final Method logFactoryRelease) { for (final Iterator it = this.childrenMap.entrySet().iterator(); it .hasNext();) { final Map.Entry entry = (Map.Entry) it.next(); final CClassLoader loader = (CClassLoader) entry.getValue(); loader._destroy(logFactoryRelease); it.remove(); } try { // remove ref from commons logging logFactoryRelease.invoke(null, new Object[] { this }); } catch (final Exception e) { } try { // reset parent to system class loader final Field parent = ClassLoader.class.getDeclaredField("parent"); parent.setAccessible(true); parent.set(this, ClassLoader.getSystemClassLoader()); parent.setAccessible(false); } catch (final Throwable ignore) { } this.classesMap.clear(); for (final Iterator it = this.dllMap.entrySet().iterator(); it .hasNext();) { final Object element = it.next(); final Map.Entry entry = (Map.Entry) element; if (entry.getValue() instanceof File) { ((File) entry.getValue()).delete(); } } this.cacheMap.clear(); this.dllMap.clear(); this.resourcesMap.clear(); this.config = null; this.name = null; this.finalizepath = this.path; this.path = null; //classes System.runFinalization(); System.gc(); }
[ "private", "final", "void", "_destroy", "(", "final", "Method", "logFactoryRelease", ")", "{", "for", "(", "final", "Iterator", "it", "=", "this", ".", "childrenMap", ".", "entrySet", "(", ")", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "final", "Map", ".", "Entry", "entry", "=", "(", "Map", ".", "Entry", ")", "it", ".", "next", "(", ")", ";", "final", "CClassLoader", "loader", "=", "(", "CClassLoader", ")", "entry", ".", "getValue", "(", ")", ";", "loader", ".", "_destroy", "(", "logFactoryRelease", ")", ";", "it", ".", "remove", "(", ")", ";", "}", "try", "{", "// remove ref from commons logging", "logFactoryRelease", ".", "invoke", "(", "null", ",", "new", "Object", "[", "]", "{", "this", "}", ")", ";", "}", "catch", "(", "final", "Exception", "e", ")", "{", "}", "try", "{", "// reset parent to system class loader", "final", "Field", "parent", "=", "ClassLoader", ".", "class", ".", "getDeclaredField", "(", "\"parent\"", ")", ";", "parent", ".", "setAccessible", "(", "true", ")", ";", "parent", ".", "set", "(", "this", ",", "ClassLoader", ".", "getSystemClassLoader", "(", ")", ")", ";", "parent", ".", "setAccessible", "(", "false", ")", ";", "}", "catch", "(", "final", "Throwable", "ignore", ")", "{", "}", "this", ".", "classesMap", ".", "clear", "(", ")", ";", "for", "(", "final", "Iterator", "it", "=", "this", ".", "dllMap", ".", "entrySet", "(", ")", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "final", "Object", "element", "=", "it", ".", "next", "(", ")", ";", "final", "Map", ".", "Entry", "entry", "=", "(", "Map", ".", "Entry", ")", "element", ";", "if", "(", "entry", ".", "getValue", "(", ")", "instanceof", "File", ")", "{", "(", "(", "File", ")", "entry", ".", "getValue", "(", ")", ")", ".", "delete", "(", ")", ";", "}", "}", "this", ".", "cacheMap", ".", "clear", "(", ")", ";", "this", ".", "dllMap", ".", "clear", "(", ")", ";", "this", ".", "resourcesMap", ".", "clear", "(", ")", ";", "this", ".", "config", "=", "null", ";", "this", ".", "name", "=", "null", ";", "this", ".", "finalizepath", "=", "this", ".", "path", ";", "this", ".", "path", "=", "null", ";", "//classes", "System", ".", "runFinalization", "(", ")", ";", "System", ".", "gc", "(", ")", ";", "}" ]
Destroy instance variables. @param logFactoryRelease method to release commons logging
[ "Destroy", "instance", "variables", "." ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java#L1239-L1282
4,128
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java
CClassLoader.addClass
public final void addClass(final String className, final URL urlToClass) { if ((className == null) || (urlToClass == null)) { return; } if (!this.classesMap.containsKey(className)) { this.classesMap.put(className, urlToClass); } }
java
public final void addClass(final String className, final URL urlToClass) { if ((className == null) || (urlToClass == null)) { return; } if (!this.classesMap.containsKey(className)) { this.classesMap.put(className, urlToClass); } }
[ "public", "final", "void", "addClass", "(", "final", "String", "className", ",", "final", "URL", "urlToClass", ")", "{", "if", "(", "(", "className", "==", "null", ")", "||", "(", "urlToClass", "==", "null", ")", ")", "{", "return", ";", "}", "if", "(", "!", "this", ".", "classesMap", ".", "containsKey", "(", "className", ")", ")", "{", "this", ".", "classesMap", ".", "put", "(", "className", ",", "urlToClass", ")", ";", "}", "}" ]
add a class to known class @param className class name @param urlToClass url to class file
[ "add", "a", "class", "to", "known", "class" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java#L1292-L1300
4,129
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java
CClassLoader.addResource
public final void addResource(final String resouceName, final URL urlToResource) { if ((urlToResource == null) || (resouceName == null)) { return; } if (this.resourcesMap.containsKey(resouceName.replace('\\', '/'))) { final Object to = this.resourcesMap.get(resouceName.replace('\\', '/')); if (to instanceof URL) { final URL uo = (URL) to; final List l = new ArrayList(); l.add(uo); this.resourcesMap.put(resouceName.replace('\\', '/'), l); } else if (to instanceof List) { final List uo = (List) to; uo.add(urlToResource); this.resourcesMap.put(resouceName.replace('\\', '/'), uo); } } else { this.resourcesMap .put(resouceName.replace('\\', '/'), urlToResource); } }
java
public final void addResource(final String resouceName, final URL urlToResource) { if ((urlToResource == null) || (resouceName == null)) { return; } if (this.resourcesMap.containsKey(resouceName.replace('\\', '/'))) { final Object to = this.resourcesMap.get(resouceName.replace('\\', '/')); if (to instanceof URL) { final URL uo = (URL) to; final List l = new ArrayList(); l.add(uo); this.resourcesMap.put(resouceName.replace('\\', '/'), l); } else if (to instanceof List) { final List uo = (List) to; uo.add(urlToResource); this.resourcesMap.put(resouceName.replace('\\', '/'), uo); } } else { this.resourcesMap .put(resouceName.replace('\\', '/'), urlToResource); } }
[ "public", "final", "void", "addResource", "(", "final", "String", "resouceName", ",", "final", "URL", "urlToResource", ")", "{", "if", "(", "(", "urlToResource", "==", "null", ")", "||", "(", "resouceName", "==", "null", ")", ")", "{", "return", ";", "}", "if", "(", "this", ".", "resourcesMap", ".", "containsKey", "(", "resouceName", ".", "replace", "(", "'", "'", ",", "'", "'", ")", ")", ")", "{", "final", "Object", "to", "=", "this", ".", "resourcesMap", ".", "get", "(", "resouceName", ".", "replace", "(", "'", "'", ",", "'", "'", ")", ")", ";", "if", "(", "to", "instanceof", "URL", ")", "{", "final", "URL", "uo", "=", "(", "URL", ")", "to", ";", "final", "List", "l", "=", "new", "ArrayList", "(", ")", ";", "l", ".", "add", "(", "uo", ")", ";", "this", ".", "resourcesMap", ".", "put", "(", "resouceName", ".", "replace", "(", "'", "'", ",", "'", "'", ")", ",", "l", ")", ";", "}", "else", "if", "(", "to", "instanceof", "List", ")", "{", "final", "List", "uo", "=", "(", "List", ")", "to", ";", "uo", ".", "add", "(", "urlToResource", ")", ";", "this", ".", "resourcesMap", ".", "put", "(", "resouceName", ".", "replace", "(", "'", "'", ",", "'", "'", ")", ",", "uo", ")", ";", "}", "}", "else", "{", "this", ".", "resourcesMap", ".", "put", "(", "resouceName", ".", "replace", "(", "'", "'", ",", "'", "'", ")", ",", "urlToResource", ")", ";", "}", "}" ]
add a resource @param resouceName name of the resource to add @param urlToResource url to the resource
[ "add", "a", "resource" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java#L1310-L1332
4,130
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java
CClassLoader.getLoaderByName
private final CClassLoader getLoaderByName(final String name) { try { CClassLoader loader = (CClassLoader) this.childrenMap.get(name); if (loader == null) { loader = CClassLoader.createLoader(this, name); this.childrenMap.put(name, loader); } return loader; } finally { try { } catch (final Exception ignore) { } } }
java
private final CClassLoader getLoaderByName(final String name) { try { CClassLoader loader = (CClassLoader) this.childrenMap.get(name); if (loader == null) { loader = CClassLoader.createLoader(this, name); this.childrenMap.put(name, loader); } return loader; } finally { try { } catch (final Exception ignore) { } } }
[ "private", "final", "CClassLoader", "getLoaderByName", "(", "final", "String", "name", ")", "{", "try", "{", "CClassLoader", "loader", "=", "(", "CClassLoader", ")", "this", ".", "childrenMap", ".", "get", "(", "name", ")", ";", "if", "(", "loader", "==", "null", ")", "{", "loader", "=", "CClassLoader", ".", "createLoader", "(", "this", ",", "name", ")", ";", "this", ".", "childrenMap", ".", "put", "(", "name", ",", "loader", ")", ";", "}", "return", "loader", ";", "}", "finally", "{", "try", "{", "}", "catch", "(", "final", "Exception", "ignore", ")", "{", "}", "}", "}" ]
Return the child loader with the given name @param name name of the child to get @return the child loader with the given name
[ "Return", "the", "child", "loader", "with", "the", "given", "name" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java#L1857-L1874
4,131
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java
CClassLoader.getPrivateResource
private final List getPrivateResource(final String name) { try { final Object to = this.resourcesMap.get(name); final List list = new ArrayList(); if (to instanceof URL) { list.add((URL) to); return list; } else if (to instanceof List) { final List l = (List) to; for (int i = 0; i < l.size(); i++) { list.add((URL) l.get(i)); } return list; } else { return null; } } finally { try { } catch (final Exception ignore) { } } }
java
private final List getPrivateResource(final String name) { try { final Object to = this.resourcesMap.get(name); final List list = new ArrayList(); if (to instanceof URL) { list.add((URL) to); return list; } else if (to instanceof List) { final List l = (List) to; for (int i = 0; i < l.size(); i++) { list.add((URL) l.get(i)); } return list; } else { return null; } } finally { try { } catch (final Exception ignore) { } } }
[ "private", "final", "List", "getPrivateResource", "(", "final", "String", "name", ")", "{", "try", "{", "final", "Object", "to", "=", "this", ".", "resourcesMap", ".", "get", "(", "name", ")", ";", "final", "List", "list", "=", "new", "ArrayList", "(", ")", ";", "if", "(", "to", "instanceof", "URL", ")", "{", "list", ".", "add", "(", "(", "URL", ")", "to", ")", ";", "return", "list", ";", "}", "else", "if", "(", "to", "instanceof", "List", ")", "{", "final", "List", "l", "=", "(", "List", ")", "to", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "l", ".", "size", "(", ")", ";", "i", "++", ")", "{", "list", ".", "add", "(", "(", "URL", ")", "l", ".", "get", "(", "i", ")", ")", ";", "}", "return", "list", ";", "}", "else", "{", "return", "null", ";", "}", "}", "finally", "{", "try", "{", "}", "catch", "(", "final", "Exception", "ignore", ")", "{", "}", "}", "}" ]
get the resource with the given name @param name name of the resource to get @return the resource with the given name
[ "get", "the", "resource", "with", "the", "given", "name" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java#L1902-L1924
4,132
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java
CClassLoader.nGetLoaderPath
private final String nGetLoaderPath() { ClassLoader currentLoader = this; final StringBuffer buffer = new StringBuffer(); buffer.append(this.name); while ((currentLoader = currentLoader.getParent()) != null) { if (currentLoader.getClass() == CClassLoader.class) { buffer.insert(0, "/"); buffer.insert(0, ((CClassLoader) currentLoader).name); } else { break; } } return buffer.toString(); }
java
private final String nGetLoaderPath() { ClassLoader currentLoader = this; final StringBuffer buffer = new StringBuffer(); buffer.append(this.name); while ((currentLoader = currentLoader.getParent()) != null) { if (currentLoader.getClass() == CClassLoader.class) { buffer.insert(0, "/"); buffer.insert(0, ((CClassLoader) currentLoader).name); } else { break; } } return buffer.toString(); }
[ "private", "final", "String", "nGetLoaderPath", "(", ")", "{", "ClassLoader", "currentLoader", "=", "this", ";", "final", "StringBuffer", "buffer", "=", "new", "StringBuffer", "(", ")", ";", "buffer", ".", "append", "(", "this", ".", "name", ")", ";", "while", "(", "(", "currentLoader", "=", "currentLoader", ".", "getParent", "(", ")", ")", "!=", "null", ")", "{", "if", "(", "currentLoader", ".", "getClass", "(", ")", "==", "CClassLoader", ".", "class", ")", "{", "buffer", ".", "insert", "(", "0", ",", "\"/\"", ")", ";", "buffer", ".", "insert", "(", "0", ",", "(", "(", "CClassLoader", ")", "currentLoader", ")", ".", "name", ")", ";", "}", "else", "{", "break", ";", "}", "}", "return", "buffer", ".", "toString", "(", ")", ";", "}" ]
calculate the loader path @return the calculated path
[ "calculate", "the", "loader", "path" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java#L2079-L2094
4,133
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java
CClassLoader.reload
public final void reload(final CClassLoaderConfig config) { if (this == CClassLoader.getRootLoader()) { return; } if (config == null) { return; } final CClassLoader parent = ((CClassLoader) this.getParent()); parent.removeLoader(this.name); if (this.isMandatory()) { CClassLoader.mandatoryLoadersMap.remove(this.getPath()); } final CClassLoader newLoader = CClassLoader.getLoader(parent.getPath() + "/" + this.name); newLoader.config = this.config; newLoader.booAlone = this.booAlone; newLoader.booMandatory = this.booMandatory; newLoader.booResourceOnly = this.booResourceOnly; newLoader.booDoNotForwardToParent = this.booDoNotForwardToParent; final List list = (List) config.getFilesMap().get(this.path); for (final Iterator f = list.iterator(); f.hasNext();) { final URL file = (URL) f.next(); newLoader.readDirectories(file); } final Iterator it = this.childrenMap.keySet().iterator(); while (it.hasNext()) { final CClassLoader child = (CClassLoader) this.childrenMap.get(it .next()); child.reload(); } this._destroy(null); if (newLoader.isMandatory()) { CClassLoader.mandatoryLoadersMap .put(newLoader.getPath(), newLoader); } newLoader.booInit = true; }
java
public final void reload(final CClassLoaderConfig config) { if (this == CClassLoader.getRootLoader()) { return; } if (config == null) { return; } final CClassLoader parent = ((CClassLoader) this.getParent()); parent.removeLoader(this.name); if (this.isMandatory()) { CClassLoader.mandatoryLoadersMap.remove(this.getPath()); } final CClassLoader newLoader = CClassLoader.getLoader(parent.getPath() + "/" + this.name); newLoader.config = this.config; newLoader.booAlone = this.booAlone; newLoader.booMandatory = this.booMandatory; newLoader.booResourceOnly = this.booResourceOnly; newLoader.booDoNotForwardToParent = this.booDoNotForwardToParent; final List list = (List) config.getFilesMap().get(this.path); for (final Iterator f = list.iterator(); f.hasNext();) { final URL file = (URL) f.next(); newLoader.readDirectories(file); } final Iterator it = this.childrenMap.keySet().iterator(); while (it.hasNext()) { final CClassLoader child = (CClassLoader) this.childrenMap.get(it .next()); child.reload(); } this._destroy(null); if (newLoader.isMandatory()) { CClassLoader.mandatoryLoadersMap .put(newLoader.getPath(), newLoader); } newLoader.booInit = true; }
[ "public", "final", "void", "reload", "(", "final", "CClassLoaderConfig", "config", ")", "{", "if", "(", "this", "==", "CClassLoader", ".", "getRootLoader", "(", ")", ")", "{", "return", ";", "}", "if", "(", "config", "==", "null", ")", "{", "return", ";", "}", "final", "CClassLoader", "parent", "=", "(", "(", "CClassLoader", ")", "this", ".", "getParent", "(", ")", ")", ";", "parent", ".", "removeLoader", "(", "this", ".", "name", ")", ";", "if", "(", "this", ".", "isMandatory", "(", ")", ")", "{", "CClassLoader", ".", "mandatoryLoadersMap", ".", "remove", "(", "this", ".", "getPath", "(", ")", ")", ";", "}", "final", "CClassLoader", "newLoader", "=", "CClassLoader", ".", "getLoader", "(", "parent", ".", "getPath", "(", ")", "+", "\"/\"", "+", "this", ".", "name", ")", ";", "newLoader", ".", "config", "=", "this", ".", "config", ";", "newLoader", ".", "booAlone", "=", "this", ".", "booAlone", ";", "newLoader", ".", "booMandatory", "=", "this", ".", "booMandatory", ";", "newLoader", ".", "booResourceOnly", "=", "this", ".", "booResourceOnly", ";", "newLoader", ".", "booDoNotForwardToParent", "=", "this", ".", "booDoNotForwardToParent", ";", "final", "List", "list", "=", "(", "List", ")", "config", ".", "getFilesMap", "(", ")", ".", "get", "(", "this", ".", "path", ")", ";", "for", "(", "final", "Iterator", "f", "=", "list", ".", "iterator", "(", ")", ";", "f", ".", "hasNext", "(", ")", ";", ")", "{", "final", "URL", "file", "=", "(", "URL", ")", "f", ".", "next", "(", ")", ";", "newLoader", ".", "readDirectories", "(", "file", ")", ";", "}", "final", "Iterator", "it", "=", "this", ".", "childrenMap", ".", "keySet", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "final", "CClassLoader", "child", "=", "(", "CClassLoader", ")", "this", ".", "childrenMap", ".", "get", "(", "it", ".", "next", "(", ")", ")", ";", "child", ".", "reload", "(", ")", ";", "}", "this", ".", "_destroy", "(", "null", ")", ";", "if", "(", "newLoader", ".", "isMandatory", "(", ")", ")", "{", "CClassLoader", ".", "mandatoryLoadersMap", ".", "put", "(", "newLoader", ".", "getPath", "(", ")", ",", "newLoader", ")", ";", "}", "newLoader", ".", "booInit", "=", "true", ";", "}" ]
reload this loader @param config a loader config object
[ "reload", "this", "loader" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java#L2245-L2292
4,134
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java
CClassLoader.removeLoader
public final CClassLoader removeLoader(final String loaderToRemove) { if (loaderToRemove.trim().length() == 0) { throw new NullPointerException(); } return (CClassLoader) this.childrenMap.remove(loaderToRemove); }
java
public final CClassLoader removeLoader(final String loaderToRemove) { if (loaderToRemove.trim().length() == 0) { throw new NullPointerException(); } return (CClassLoader) this.childrenMap.remove(loaderToRemove); }
[ "public", "final", "CClassLoader", "removeLoader", "(", "final", "String", "loaderToRemove", ")", "{", "if", "(", "loaderToRemove", ".", "trim", "(", ")", ".", "length", "(", ")", "==", "0", ")", "{", "throw", "new", "NullPointerException", "(", ")", ";", "}", "return", "(", "CClassLoader", ")", "this", ".", "childrenMap", ".", "remove", "(", "loaderToRemove", ")", ";", "}" ]
remove the given loader from this loader @param loaderToRemove name of the loader to remove. NOT NULL. @return the removed loader or null. @throws NullPointerException if loaderToRemove is null or a zero length/blank string
[ "remove", "the", "given", "loader", "from", "this", "loader" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CClassLoader.java#L2305-L2311
4,135
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/cl/converter/CDocumentReconstructor.java
CDocumentReconstructor.getSecurityFlags
private static final int getSecurityFlags(final Map properties) { int securityType = 0; securityType = "true".equals(properties .get(IHtmlToPdfTransformer.PDF_ALLOW_PRINTING)) ? (securityType | PdfWriter.ALLOW_PRINTING) : securityType; securityType = "true".equals(properties .get(IHtmlToPdfTransformer.PDF_ALLOW_MODIFY_CONTENTS)) ? (securityType | PdfWriter.ALLOW_MODIFY_CONTENTS) : securityType; securityType = "true".equals(properties .get(IHtmlToPdfTransformer.PDF_ALLOW_COPY)) ? (securityType | PdfWriter.ALLOW_COPY) : securityType; securityType = "true".equals(properties .get(IHtmlToPdfTransformer.PDF_ALLOW_MODIFT_ANNOTATIONS)) ? (securityType | PdfWriter.ALLOW_MODIFY_ANNOTATIONS) : securityType; securityType = "true".equals(properties .get(IHtmlToPdfTransformer.PDF_ALLOW_FILLIN)) ? (securityType | PdfWriter.ALLOW_FILL_IN) : securityType; securityType = "true".equals(properties .get(IHtmlToPdfTransformer.PDF_ALLOW_SCREEN_READERS)) ? (securityType | PdfWriter.ALLOW_SCREENREADERS) : securityType; securityType = "true".equals(properties .get(IHtmlToPdfTransformer.PDF_ALLOW_ASSEMBLY)) ? (securityType | PdfWriter.ALLOW_ASSEMBLY) : securityType; securityType = "true".equals(properties .get(IHtmlToPdfTransformer.PDF_ALLOW_DEGRADED_PRINTING)) ? (securityType | PdfWriter.ALLOW_DEGRADED_PRINTING) : securityType; return securityType; }
java
private static final int getSecurityFlags(final Map properties) { int securityType = 0; securityType = "true".equals(properties .get(IHtmlToPdfTransformer.PDF_ALLOW_PRINTING)) ? (securityType | PdfWriter.ALLOW_PRINTING) : securityType; securityType = "true".equals(properties .get(IHtmlToPdfTransformer.PDF_ALLOW_MODIFY_CONTENTS)) ? (securityType | PdfWriter.ALLOW_MODIFY_CONTENTS) : securityType; securityType = "true".equals(properties .get(IHtmlToPdfTransformer.PDF_ALLOW_COPY)) ? (securityType | PdfWriter.ALLOW_COPY) : securityType; securityType = "true".equals(properties .get(IHtmlToPdfTransformer.PDF_ALLOW_MODIFT_ANNOTATIONS)) ? (securityType | PdfWriter.ALLOW_MODIFY_ANNOTATIONS) : securityType; securityType = "true".equals(properties .get(IHtmlToPdfTransformer.PDF_ALLOW_FILLIN)) ? (securityType | PdfWriter.ALLOW_FILL_IN) : securityType; securityType = "true".equals(properties .get(IHtmlToPdfTransformer.PDF_ALLOW_SCREEN_READERS)) ? (securityType | PdfWriter.ALLOW_SCREENREADERS) : securityType; securityType = "true".equals(properties .get(IHtmlToPdfTransformer.PDF_ALLOW_ASSEMBLY)) ? (securityType | PdfWriter.ALLOW_ASSEMBLY) : securityType; securityType = "true".equals(properties .get(IHtmlToPdfTransformer.PDF_ALLOW_DEGRADED_PRINTING)) ? (securityType | PdfWriter.ALLOW_DEGRADED_PRINTING) : securityType; return securityType; }
[ "private", "static", "final", "int", "getSecurityFlags", "(", "final", "Map", "properties", ")", "{", "int", "securityType", "=", "0", ";", "securityType", "=", "\"true\"", ".", "equals", "(", "properties", ".", "get", "(", "IHtmlToPdfTransformer", ".", "PDF_ALLOW_PRINTING", ")", ")", "?", "(", "securityType", "|", "PdfWriter", ".", "ALLOW_PRINTING", ")", ":", "securityType", ";", "securityType", "=", "\"true\"", ".", "equals", "(", "properties", ".", "get", "(", "IHtmlToPdfTransformer", ".", "PDF_ALLOW_MODIFY_CONTENTS", ")", ")", "?", "(", "securityType", "|", "PdfWriter", ".", "ALLOW_MODIFY_CONTENTS", ")", ":", "securityType", ";", "securityType", "=", "\"true\"", ".", "equals", "(", "properties", ".", "get", "(", "IHtmlToPdfTransformer", ".", "PDF_ALLOW_COPY", ")", ")", "?", "(", "securityType", "|", "PdfWriter", ".", "ALLOW_COPY", ")", ":", "securityType", ";", "securityType", "=", "\"true\"", ".", "equals", "(", "properties", ".", "get", "(", "IHtmlToPdfTransformer", ".", "PDF_ALLOW_MODIFT_ANNOTATIONS", ")", ")", "?", "(", "securityType", "|", "PdfWriter", ".", "ALLOW_MODIFY_ANNOTATIONS", ")", ":", "securityType", ";", "securityType", "=", "\"true\"", ".", "equals", "(", "properties", ".", "get", "(", "IHtmlToPdfTransformer", ".", "PDF_ALLOW_FILLIN", ")", ")", "?", "(", "securityType", "|", "PdfWriter", ".", "ALLOW_FILL_IN", ")", ":", "securityType", ";", "securityType", "=", "\"true\"", ".", "equals", "(", "properties", ".", "get", "(", "IHtmlToPdfTransformer", ".", "PDF_ALLOW_SCREEN_READERS", ")", ")", "?", "(", "securityType", "|", "PdfWriter", ".", "ALLOW_SCREENREADERS", ")", ":", "securityType", ";", "securityType", "=", "\"true\"", ".", "equals", "(", "properties", ".", "get", "(", "IHtmlToPdfTransformer", ".", "PDF_ALLOW_ASSEMBLY", ")", ")", "?", "(", "securityType", "|", "PdfWriter", ".", "ALLOW_ASSEMBLY", ")", ":", "securityType", ";", "securityType", "=", "\"true\"", ".", "equals", "(", "properties", ".", "get", "(", "IHtmlToPdfTransformer", ".", "PDF_ALLOW_DEGRADED_PRINTING", ")", ")", "?", "(", "securityType", "|", "PdfWriter", ".", "ALLOW_DEGRADED_PRINTING", ")", ":", "securityType", ";", "return", "securityType", ";", "}" ]
return the itext security flags for encryption @param properties the converter properties @return the itext security flags
[ "return", "the", "itext", "security", "flags", "for", "encryption" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/cl/converter/CDocumentReconstructor.java#L68-L96
4,136
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/converter/CYaHPConverter.java
CYaHPConverter.destroy
public static void destroy() { try { countMutex.acquire(); for (int i=0;i<fileToDeleteOnDestroy.size();i++) { File f = (File)fileToDeleteOnDestroy.get(i); if (f != null && f.exists()) try{f.delete();}catch(Exception ignore){} } CClassLoader.destroy(); } // end try finally { countInstance = 0; try { countMutex.release(); } // end try catch (final Exception e) {} } // end finally }
java
public static void destroy() { try { countMutex.acquire(); for (int i=0;i<fileToDeleteOnDestroy.size();i++) { File f = (File)fileToDeleteOnDestroy.get(i); if (f != null && f.exists()) try{f.delete();}catch(Exception ignore){} } CClassLoader.destroy(); } // end try finally { countInstance = 0; try { countMutex.release(); } // end try catch (final Exception e) {} } // end finally }
[ "public", "static", "void", "destroy", "(", ")", "{", "try", "{", "countMutex", ".", "acquire", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "fileToDeleteOnDestroy", ".", "size", "(", ")", ";", "i", "++", ")", "{", "File", "f", "=", "(", "File", ")", "fileToDeleteOnDestroy", ".", "get", "(", "i", ")", ";", "if", "(", "f", "!=", "null", "&&", "f", ".", "exists", "(", ")", ")", "try", "{", "f", ".", "delete", "(", ")", ";", "}", "catch", "(", "Exception", "ignore", ")", "{", "}", "}", "CClassLoader", ".", "destroy", "(", ")", ";", "}", "// end try", "finally", "{", "countInstance", "=", "0", ";", "try", "{", "countMutex", ".", "release", "(", ")", ";", "}", "// end try", "catch", "(", "final", "Exception", "e", ")", "{", "}", "}", "// end finally", "}" ]
Delete the jar file from the temp directory Destroy the classloader
[ "Delete", "the", "jar", "file", "from", "the", "temp", "directory", "Destroy", "the", "classloader" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CYaHPConverter.java#L93-L111
4,137
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/converter/CYaHPConverter.java
CYaHPConverter.convertToPdf
public final void convertToPdf( final URL url, final IHtmlToPdfTransformer.PageSize size, final List hf, final OutputStream out, final Map fproperties) throws CConvertException { Map properties = (fproperties != null) ? fproperties : new HashMap(); ClassLoader loader = Thread.currentThread() .getContextClassLoader(); int priority = Thread.currentThread().getPriority(); try { Thread.currentThread() .setContextClassLoader(new URLClassLoader(new URL[0],this.useClassLoader ? CClassLoader.getLoader( "/main") : this.getClass().getClassLoader())); Thread.currentThread().setPriority(Thread.MIN_PRIORITY); String uri = url.toExternalForm(); if (uri.indexOf("://") != -1) { String tmp = uri.substring(uri.indexOf("://")+3); if (tmp.indexOf('/') == -1) { uri += "/"; } } uri = uri.substring(0, uri.lastIndexOf("/") + 1); if (uri.startsWith("file:/")) { uri = uri.substring(6); while (uri.startsWith("/")) { uri = uri.substring(1); } // end while uri = "file:///" + uri; } // end if try { IHtmlToPdfTransformer transformer = getTransformer(properties); transformer.transform(url.openStream(), uri, size, hf, properties, out); } // end try catch (final CConvertException e) { throw e; } catch (final Exception e) { throw new CConvertException(e.getMessage(),e); } // end catch } // end try finally { Thread.currentThread().setContextClassLoader(loader); Thread.currentThread().setPriority(priority); } // end finally }
java
public final void convertToPdf( final URL url, final IHtmlToPdfTransformer.PageSize size, final List hf, final OutputStream out, final Map fproperties) throws CConvertException { Map properties = (fproperties != null) ? fproperties : new HashMap(); ClassLoader loader = Thread.currentThread() .getContextClassLoader(); int priority = Thread.currentThread().getPriority(); try { Thread.currentThread() .setContextClassLoader(new URLClassLoader(new URL[0],this.useClassLoader ? CClassLoader.getLoader( "/main") : this.getClass().getClassLoader())); Thread.currentThread().setPriority(Thread.MIN_PRIORITY); String uri = url.toExternalForm(); if (uri.indexOf("://") != -1) { String tmp = uri.substring(uri.indexOf("://")+3); if (tmp.indexOf('/') == -1) { uri += "/"; } } uri = uri.substring(0, uri.lastIndexOf("/") + 1); if (uri.startsWith("file:/")) { uri = uri.substring(6); while (uri.startsWith("/")) { uri = uri.substring(1); } // end while uri = "file:///" + uri; } // end if try { IHtmlToPdfTransformer transformer = getTransformer(properties); transformer.transform(url.openStream(), uri, size, hf, properties, out); } // end try catch (final CConvertException e) { throw e; } catch (final Exception e) { throw new CConvertException(e.getMessage(),e); } // end catch } // end try finally { Thread.currentThread().setContextClassLoader(loader); Thread.currentThread().setPriority(priority); } // end finally }
[ "public", "final", "void", "convertToPdf", "(", "final", "URL", "url", ",", "final", "IHtmlToPdfTransformer", ".", "PageSize", "size", ",", "final", "List", "hf", ",", "final", "OutputStream", "out", ",", "final", "Map", "fproperties", ")", "throws", "CConvertException", "{", "Map", "properties", "=", "(", "fproperties", "!=", "null", ")", "?", "fproperties", ":", "new", "HashMap", "(", ")", ";", "ClassLoader", "loader", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ";", "int", "priority", "=", "Thread", ".", "currentThread", "(", ")", ".", "getPriority", "(", ")", ";", "try", "{", "Thread", ".", "currentThread", "(", ")", ".", "setContextClassLoader", "(", "new", "URLClassLoader", "(", "new", "URL", "[", "0", "]", ",", "this", ".", "useClassLoader", "?", "CClassLoader", ".", "getLoader", "(", "\"/main\"", ")", ":", "this", ".", "getClass", "(", ")", ".", "getClassLoader", "(", ")", ")", ")", ";", "Thread", ".", "currentThread", "(", ")", ".", "setPriority", "(", "Thread", ".", "MIN_PRIORITY", ")", ";", "String", "uri", "=", "url", ".", "toExternalForm", "(", ")", ";", "if", "(", "uri", ".", "indexOf", "(", "\"://\"", ")", "!=", "-", "1", ")", "{", "String", "tmp", "=", "uri", ".", "substring", "(", "uri", ".", "indexOf", "(", "\"://\"", ")", "+", "3", ")", ";", "if", "(", "tmp", ".", "indexOf", "(", "'", "'", ")", "==", "-", "1", ")", "{", "uri", "+=", "\"/\"", ";", "}", "}", "uri", "=", "uri", ".", "substring", "(", "0", ",", "uri", ".", "lastIndexOf", "(", "\"/\"", ")", "+", "1", ")", ";", "if", "(", "uri", ".", "startsWith", "(", "\"file:/\"", ")", ")", "{", "uri", "=", "uri", ".", "substring", "(", "6", ")", ";", "while", "(", "uri", ".", "startsWith", "(", "\"/\"", ")", ")", "{", "uri", "=", "uri", ".", "substring", "(", "1", ")", ";", "}", "// end while", "uri", "=", "\"file:///\"", "+", "uri", ";", "}", "// end if", "try", "{", "IHtmlToPdfTransformer", "transformer", "=", "getTransformer", "(", "properties", ")", ";", "transformer", ".", "transform", "(", "url", ".", "openStream", "(", ")", ",", "uri", ",", "size", ",", "hf", ",", "properties", ",", "out", ")", ";", "}", "// end try", "catch", "(", "final", "CConvertException", "e", ")", "{", "throw", "e", ";", "}", "catch", "(", "final", "Exception", "e", ")", "{", "throw", "new", "CConvertException", "(", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "// end catch", "}", "// end try", "finally", "{", "Thread", ".", "currentThread", "(", ")", ".", "setContextClassLoader", "(", "loader", ")", ";", "Thread", ".", "currentThread", "(", ")", ".", "setPriority", "(", "priority", ")", ";", "}", "// end finally", "}" ]
Convert the document pointed by url in a PDF file. This method is thread safe. @param url Url to the document @param size PDF Page size @param hf header-footer list @param out outputstream to render into @param fproperties properties map @throws CConvertException if an unexpected error occurs.
[ "Convert", "the", "document", "pointed", "by", "url", "in", "a", "PDF", "file", ".", "This", "method", "is", "thread", "safe", "." ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CYaHPConverter.java#L131-L186
4,138
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/converter/CYaHPConverter.java
CYaHPConverter.convertToPdf
public final void convertToPdf( final String content, final IHtmlToPdfTransformer.PageSize size, final List hf, final String furlForBase, final OutputStream out, final Map fproperties) throws CConvertException { String urlForBase = furlForBase; Map properties = (fproperties != null) ? fproperties : new HashMap(); if (urlForBase != null) { try { URL url = new URL(urlForBase); if (url == null) { throw new CConvertException( "urlForBase must be a valid URI.",null); } // end if } // end try catch (final Exception e) { throw new CConvertException( "urlForBase must be a valid URI.",null); } // end catch if (urlForBase.indexOf("://") != -1) { String tmp = urlForBase.substring(urlForBase.indexOf("://")+3); if (tmp.indexOf('/') == -1) { urlForBase += "/"; } } } // end if ClassLoader loader = Thread.currentThread() .getContextClassLoader(); int priority = Thread.currentThread().getPriority(); try { Thread.currentThread() .setContextClassLoader(new URLClassLoader(new URL[0],this.useClassLoader ? CClassLoader.getLoader( "/main") : this.getClass().getClassLoader())); Thread.currentThread().setPriority(Thread.MIN_PRIORITY); try { IHtmlToPdfTransformer transformer = getTransformer(properties); transformer.transform(new ByteArrayInputStream( content.getBytes("utf-8")), urlForBase, size, hf, properties, out); } // end try catch (final CConvertException e) { throw e; } catch (final Exception e) { throw new CConvertException(e.getMessage(),e); } // end catch } // end try finally { Thread.currentThread().setContextClassLoader(loader); Thread.currentThread().setPriority(priority); } // end finally }
java
public final void convertToPdf( final String content, final IHtmlToPdfTransformer.PageSize size, final List hf, final String furlForBase, final OutputStream out, final Map fproperties) throws CConvertException { String urlForBase = furlForBase; Map properties = (fproperties != null) ? fproperties : new HashMap(); if (urlForBase != null) { try { URL url = new URL(urlForBase); if (url == null) { throw new CConvertException( "urlForBase must be a valid URI.",null); } // end if } // end try catch (final Exception e) { throw new CConvertException( "urlForBase must be a valid URI.",null); } // end catch if (urlForBase.indexOf("://") != -1) { String tmp = urlForBase.substring(urlForBase.indexOf("://")+3); if (tmp.indexOf('/') == -1) { urlForBase += "/"; } } } // end if ClassLoader loader = Thread.currentThread() .getContextClassLoader(); int priority = Thread.currentThread().getPriority(); try { Thread.currentThread() .setContextClassLoader(new URLClassLoader(new URL[0],this.useClassLoader ? CClassLoader.getLoader( "/main") : this.getClass().getClassLoader())); Thread.currentThread().setPriority(Thread.MIN_PRIORITY); try { IHtmlToPdfTransformer transformer = getTransformer(properties); transformer.transform(new ByteArrayInputStream( content.getBytes("utf-8")), urlForBase, size, hf, properties, out); } // end try catch (final CConvertException e) { throw e; } catch (final Exception e) { throw new CConvertException(e.getMessage(),e); } // end catch } // end try finally { Thread.currentThread().setContextClassLoader(loader); Thread.currentThread().setPriority(priority); } // end finally }
[ "public", "final", "void", "convertToPdf", "(", "final", "String", "content", ",", "final", "IHtmlToPdfTransformer", ".", "PageSize", "size", ",", "final", "List", "hf", ",", "final", "String", "furlForBase", ",", "final", "OutputStream", "out", ",", "final", "Map", "fproperties", ")", "throws", "CConvertException", "{", "String", "urlForBase", "=", "furlForBase", ";", "Map", "properties", "=", "(", "fproperties", "!=", "null", ")", "?", "fproperties", ":", "new", "HashMap", "(", ")", ";", "if", "(", "urlForBase", "!=", "null", ")", "{", "try", "{", "URL", "url", "=", "new", "URL", "(", "urlForBase", ")", ";", "if", "(", "url", "==", "null", ")", "{", "throw", "new", "CConvertException", "(", "\"urlForBase must be a valid URI.\"", ",", "null", ")", ";", "}", "// end if", "}", "// end try", "catch", "(", "final", "Exception", "e", ")", "{", "throw", "new", "CConvertException", "(", "\"urlForBase must be a valid URI.\"", ",", "null", ")", ";", "}", "// end catch", "if", "(", "urlForBase", ".", "indexOf", "(", "\"://\"", ")", "!=", "-", "1", ")", "{", "String", "tmp", "=", "urlForBase", ".", "substring", "(", "urlForBase", ".", "indexOf", "(", "\"://\"", ")", "+", "3", ")", ";", "if", "(", "tmp", ".", "indexOf", "(", "'", "'", ")", "==", "-", "1", ")", "{", "urlForBase", "+=", "\"/\"", ";", "}", "}", "}", "// end if", "ClassLoader", "loader", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ";", "int", "priority", "=", "Thread", ".", "currentThread", "(", ")", ".", "getPriority", "(", ")", ";", "try", "{", "Thread", ".", "currentThread", "(", ")", ".", "setContextClassLoader", "(", "new", "URLClassLoader", "(", "new", "URL", "[", "0", "]", ",", "this", ".", "useClassLoader", "?", "CClassLoader", ".", "getLoader", "(", "\"/main\"", ")", ":", "this", ".", "getClass", "(", ")", ".", "getClassLoader", "(", ")", ")", ")", ";", "Thread", ".", "currentThread", "(", ")", ".", "setPriority", "(", "Thread", ".", "MIN_PRIORITY", ")", ";", "try", "{", "IHtmlToPdfTransformer", "transformer", "=", "getTransformer", "(", "properties", ")", ";", "transformer", ".", "transform", "(", "new", "ByteArrayInputStream", "(", "content", ".", "getBytes", "(", "\"utf-8\"", ")", ")", ",", "urlForBase", ",", "size", ",", "hf", ",", "properties", ",", "out", ")", ";", "}", "// end try", "catch", "(", "final", "CConvertException", "e", ")", "{", "throw", "e", ";", "}", "catch", "(", "final", "Exception", "e", ")", "{", "throw", "new", "CConvertException", "(", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "// end catch", "}", "// end try", "finally", "{", "Thread", ".", "currentThread", "(", ")", ".", "setContextClassLoader", "(", "loader", ")", ";", "Thread", ".", "currentThread", "(", ")", ".", "setPriority", "(", "priority", ")", ";", "}", "// end finally", "}" ]
Convert the document in content in a PDF file. This method is thread safe. @param content the html document as a string @param size PDF Page size @param hf header-footer list @param furlForBase base url of the document, mandatory, must end with a '/' @param out outputstream to render into @param fproperties properties map @throws CConvertException if an unexpected error occurs
[ "Convert", "the", "document", "in", "content", "in", "a", "PDF", "file", ".", "This", "method", "is", "thread", "safe", "." ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CYaHPConverter.java#L202-L262
4,139
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/converter/CYaHPConverter.java
CYaHPConverter.init
private final void init(boolean useClassLoader) { final CYaHPConverter converter = this; System.out.println("Initializing..."); long time = System.currentTimeMillis(); if (!useClassLoader) { System.out.println("init time: "+(System.currentTimeMillis()-time)); return; } // if classloader is init return. if (CClassLoader.getRootLoader().isInit()) { return; } // end if // ensure the temporary files are delete on exit. Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { try { converter.finalize(); } // end try catch (final Throwable e) {} } // end run() } // end new ); ClassLoader loader = this.getClass().getClassLoader(); CClassLoaderConfig config = new CClassLoaderConfig(); config.addLoaderInfo("/main", new CClassLoaderConfig.CLoaderInfo(true, true, false, false)); config.addFile("/main", loader.getResource("itext-yahp.jar")); config.addFile("/main", loader.getResource("tidy-yahp.jar")); config.addFile("/main", loader.getResource("log4j-yahp.jar")); config.addFile("/main", loader.getResource("shanijar-yahp.jar")); config.addFile("/main", loader.getResource("xmlapi-yahp.jar")); config.addFile("/main", loader.getResource("yahp-internal.jar")); config.addFile("/main", loader.getResource("commonio-yahp.jar")); config.addFile("/main", loader.getResource("commonlog-yahp.jar")); config.addFile("/main", loader.getResource("core-renderer-yahp.jar")); config.addFile("/main", loader.getResource("jaxen-yahp.jar")); CClassLoader.init(config); try { URL url = CClassLoader.getRootLoader().getResource("log4j.properties"); if (url != null) { ClassLoader cx = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(CClassLoader.getRootLoader()); Class pc = CClassLoader.getRootLoader().loadClass("org.apache.log4j.PropertyConfigurator"); Method configure = pc.getDeclaredMethod("configure", new Class[]{URL.class}); configure.invoke(null, new Object[]{url}); } finally { Thread.currentThread().setContextClassLoader(cx); } } } catch(Exception ignore){} System.out.println("init time: "+(System.currentTimeMillis()-time)); }
java
private final void init(boolean useClassLoader) { final CYaHPConverter converter = this; System.out.println("Initializing..."); long time = System.currentTimeMillis(); if (!useClassLoader) { System.out.println("init time: "+(System.currentTimeMillis()-time)); return; } // if classloader is init return. if (CClassLoader.getRootLoader().isInit()) { return; } // end if // ensure the temporary files are delete on exit. Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { try { converter.finalize(); } // end try catch (final Throwable e) {} } // end run() } // end new ); ClassLoader loader = this.getClass().getClassLoader(); CClassLoaderConfig config = new CClassLoaderConfig(); config.addLoaderInfo("/main", new CClassLoaderConfig.CLoaderInfo(true, true, false, false)); config.addFile("/main", loader.getResource("itext-yahp.jar")); config.addFile("/main", loader.getResource("tidy-yahp.jar")); config.addFile("/main", loader.getResource("log4j-yahp.jar")); config.addFile("/main", loader.getResource("shanijar-yahp.jar")); config.addFile("/main", loader.getResource("xmlapi-yahp.jar")); config.addFile("/main", loader.getResource("yahp-internal.jar")); config.addFile("/main", loader.getResource("commonio-yahp.jar")); config.addFile("/main", loader.getResource("commonlog-yahp.jar")); config.addFile("/main", loader.getResource("core-renderer-yahp.jar")); config.addFile("/main", loader.getResource("jaxen-yahp.jar")); CClassLoader.init(config); try { URL url = CClassLoader.getRootLoader().getResource("log4j.properties"); if (url != null) { ClassLoader cx = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(CClassLoader.getRootLoader()); Class pc = CClassLoader.getRootLoader().loadClass("org.apache.log4j.PropertyConfigurator"); Method configure = pc.getDeclaredMethod("configure", new Class[]{URL.class}); configure.invoke(null, new Object[]{url}); } finally { Thread.currentThread().setContextClassLoader(cx); } } } catch(Exception ignore){} System.out.println("init time: "+(System.currentTimeMillis()-time)); }
[ "private", "final", "void", "init", "(", "boolean", "useClassLoader", ")", "{", "final", "CYaHPConverter", "converter", "=", "this", ";", "System", ".", "out", ".", "println", "(", "\"Initializing...\"", ")", ";", "long", "time", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "if", "(", "!", "useClassLoader", ")", "{", "System", ".", "out", ".", "println", "(", "\"init time: \"", "+", "(", "System", ".", "currentTimeMillis", "(", ")", "-", "time", ")", ")", ";", "return", ";", "}", "// if classloader is init return.", "if", "(", "CClassLoader", ".", "getRootLoader", "(", ")", ".", "isInit", "(", ")", ")", "{", "return", ";", "}", "// end if", "// ensure the temporary files are delete on exit.", "Runtime", ".", "getRuntime", "(", ")", ".", "addShutdownHook", "(", "new", "Thread", "(", ")", "{", "public", "void", "run", "(", ")", "{", "try", "{", "converter", ".", "finalize", "(", ")", ";", "}", "// end try", "catch", "(", "final", "Throwable", "e", ")", "{", "}", "}", "// end run()", "}", "// end new", ")", ";", "ClassLoader", "loader", "=", "this", ".", "getClass", "(", ")", ".", "getClassLoader", "(", ")", ";", "CClassLoaderConfig", "config", "=", "new", "CClassLoaderConfig", "(", ")", ";", "config", ".", "addLoaderInfo", "(", "\"/main\"", ",", "new", "CClassLoaderConfig", ".", "CLoaderInfo", "(", "true", ",", "true", ",", "false", ",", "false", ")", ")", ";", "config", ".", "addFile", "(", "\"/main\"", ",", "loader", ".", "getResource", "(", "\"itext-yahp.jar\"", ")", ")", ";", "config", ".", "addFile", "(", "\"/main\"", ",", "loader", ".", "getResource", "(", "\"tidy-yahp.jar\"", ")", ")", ";", "config", ".", "addFile", "(", "\"/main\"", ",", "loader", ".", "getResource", "(", "\"log4j-yahp.jar\"", ")", ")", ";", "config", ".", "addFile", "(", "\"/main\"", ",", "loader", ".", "getResource", "(", "\"shanijar-yahp.jar\"", ")", ")", ";", "config", ".", "addFile", "(", "\"/main\"", ",", "loader", ".", "getResource", "(", "\"xmlapi-yahp.jar\"", ")", ")", ";", "config", ".", "addFile", "(", "\"/main\"", ",", "loader", ".", "getResource", "(", "\"yahp-internal.jar\"", ")", ")", ";", "config", ".", "addFile", "(", "\"/main\"", ",", "loader", ".", "getResource", "(", "\"commonio-yahp.jar\"", ")", ")", ";", "config", ".", "addFile", "(", "\"/main\"", ",", "loader", ".", "getResource", "(", "\"commonlog-yahp.jar\"", ")", ")", ";", "config", ".", "addFile", "(", "\"/main\"", ",", "loader", ".", "getResource", "(", "\"core-renderer-yahp.jar\"", ")", ")", ";", "config", ".", "addFile", "(", "\"/main\"", ",", "loader", ".", "getResource", "(", "\"jaxen-yahp.jar\"", ")", ")", ";", "CClassLoader", ".", "init", "(", "config", ")", ";", "try", "{", "URL", "url", "=", "CClassLoader", ".", "getRootLoader", "(", ")", ".", "getResource", "(", "\"log4j.properties\"", ")", ";", "if", "(", "url", "!=", "null", ")", "{", "ClassLoader", "cx", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ";", "try", "{", "Thread", ".", "currentThread", "(", ")", ".", "setContextClassLoader", "(", "CClassLoader", ".", "getRootLoader", "(", ")", ")", ";", "Class", "pc", "=", "CClassLoader", ".", "getRootLoader", "(", ")", ".", "loadClass", "(", "\"org.apache.log4j.PropertyConfigurator\"", ")", ";", "Method", "configure", "=", "pc", ".", "getDeclaredMethod", "(", "\"configure\"", ",", "new", "Class", "[", "]", "{", "URL", ".", "class", "}", ")", ";", "configure", ".", "invoke", "(", "null", ",", "new", "Object", "[", "]", "{", "url", "}", ")", ";", "}", "finally", "{", "Thread", ".", "currentThread", "(", ")", ".", "setContextClassLoader", "(", "cx", ")", ";", "}", "}", "}", "catch", "(", "Exception", "ignore", ")", "{", "}", "System", ".", "out", ".", "println", "(", "\"init time: \"", "+", "(", "System", ".", "currentTimeMillis", "(", ")", "-", "time", ")", ")", ";", "}" ]
initialize the classloader, and the transformer
[ "initialize", "the", "classloader", "and", "the", "transformer" ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CYaHPConverter.java#L294-L351
4,140
allcolor/YaHP-Converter
YaHPConverter/src/org/allcolor/yahp/converter/CYaHPConverter.java
CYaHPConverter.getTransformer
private IHtmlToPdfTransformer getTransformer(final Map properties) { try { mutex.acquire(); IHtmlToPdfTransformer transformer = null; String rendererClassName = IHtmlToPdfTransformer.DEFAULT_PDF_RENDERER; if ((properties != null) && properties.containsKey( IHtmlToPdfTransformer.PDF_RENDERER_CLASS)) { rendererClassName = (String) properties.get(IHtmlToPdfTransformer.PDF_RENDERER_CLASS); } // end if if (transformers.containsKey(rendererClassName)) { transformer = (IHtmlToPdfTransformer) transformers.get(rendererClassName); } // end if else { ClassLoader bootStrap = this.useClassLoader ? CClassLoader.getLoader("/main") : this.getClass().getClassLoader(); try { ClassLoader cx = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(this.useClassLoader ? CClassLoader.getRootLoader() : this.getClass().getClassLoader()); transformer = (IHtmlToPdfTransformer) bootStrap.loadClass(rendererClassName) .newInstance(); transformers.put(rendererClassName, transformer); } finally { Thread.currentThread().setContextClassLoader(cx); } } // end try catch (final Exception e) { e.printStackTrace(); System.err.println( "SEVERE: Error while getting transformer '" + rendererClassName + "' ! : "+e.getMessage()); return null; } // end catch } // end else return transformer; } finally { try { mutex.release(); } // end try catch (final Exception e) {} } // end finally }
java
private IHtmlToPdfTransformer getTransformer(final Map properties) { try { mutex.acquire(); IHtmlToPdfTransformer transformer = null; String rendererClassName = IHtmlToPdfTransformer.DEFAULT_PDF_RENDERER; if ((properties != null) && properties.containsKey( IHtmlToPdfTransformer.PDF_RENDERER_CLASS)) { rendererClassName = (String) properties.get(IHtmlToPdfTransformer.PDF_RENDERER_CLASS); } // end if if (transformers.containsKey(rendererClassName)) { transformer = (IHtmlToPdfTransformer) transformers.get(rendererClassName); } // end if else { ClassLoader bootStrap = this.useClassLoader ? CClassLoader.getLoader("/main") : this.getClass().getClassLoader(); try { ClassLoader cx = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(this.useClassLoader ? CClassLoader.getRootLoader() : this.getClass().getClassLoader()); transformer = (IHtmlToPdfTransformer) bootStrap.loadClass(rendererClassName) .newInstance(); transformers.put(rendererClassName, transformer); } finally { Thread.currentThread().setContextClassLoader(cx); } } // end try catch (final Exception e) { e.printStackTrace(); System.err.println( "SEVERE: Error while getting transformer '" + rendererClassName + "' ! : "+e.getMessage()); return null; } // end catch } // end else return transformer; } finally { try { mutex.release(); } // end try catch (final Exception e) {} } // end finally }
[ "private", "IHtmlToPdfTransformer", "getTransformer", "(", "final", "Map", "properties", ")", "{", "try", "{", "mutex", ".", "acquire", "(", ")", ";", "IHtmlToPdfTransformer", "transformer", "=", "null", ";", "String", "rendererClassName", "=", "IHtmlToPdfTransformer", ".", "DEFAULT_PDF_RENDERER", ";", "if", "(", "(", "properties", "!=", "null", ")", "&&", "properties", ".", "containsKey", "(", "IHtmlToPdfTransformer", ".", "PDF_RENDERER_CLASS", ")", ")", "{", "rendererClassName", "=", "(", "String", ")", "properties", ".", "get", "(", "IHtmlToPdfTransformer", ".", "PDF_RENDERER_CLASS", ")", ";", "}", "// end if", "if", "(", "transformers", ".", "containsKey", "(", "rendererClassName", ")", ")", "{", "transformer", "=", "(", "IHtmlToPdfTransformer", ")", "transformers", ".", "get", "(", "rendererClassName", ")", ";", "}", "// end if", "else", "{", "ClassLoader", "bootStrap", "=", "this", ".", "useClassLoader", "?", "CClassLoader", ".", "getLoader", "(", "\"/main\"", ")", ":", "this", ".", "getClass", "(", ")", ".", "getClassLoader", "(", ")", ";", "try", "{", "ClassLoader", "cx", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ";", "try", "{", "Thread", ".", "currentThread", "(", ")", ".", "setContextClassLoader", "(", "this", ".", "useClassLoader", "?", "CClassLoader", ".", "getRootLoader", "(", ")", ":", "this", ".", "getClass", "(", ")", ".", "getClassLoader", "(", ")", ")", ";", "transformer", "=", "(", "IHtmlToPdfTransformer", ")", "bootStrap", ".", "loadClass", "(", "rendererClassName", ")", ".", "newInstance", "(", ")", ";", "transformers", ".", "put", "(", "rendererClassName", ",", "transformer", ")", ";", "}", "finally", "{", "Thread", ".", "currentThread", "(", ")", ".", "setContextClassLoader", "(", "cx", ")", ";", "}", "}", "// end try", "catch", "(", "final", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "System", ".", "err", ".", "println", "(", "\"SEVERE: Error while getting transformer '\"", "+", "rendererClassName", "+", "\"' ! : \"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "return", "null", ";", "}", "// end catch", "}", "// end else", "return", "transformer", ";", "}", "finally", "{", "try", "{", "mutex", ".", "release", "(", ")", ";", "}", "// end try", "catch", "(", "final", "Exception", "e", ")", "{", "}", "}", "// end finally", "}" ]
Get a transformer. @param properties The properties map. @return a transformer corresponding to the criterias found in the properties map.
[ "Get", "a", "transformer", "." ]
d72745281766a784a6b319f3787aa1d8de7cd0fe
https://github.com/allcolor/YaHP-Converter/blob/d72745281766a784a6b319f3787aa1d8de7cd0fe/YaHPConverter/src/org/allcolor/yahp/converter/CYaHPConverter.java#L361-L410
4,141
sinofool/alipay-java-sdk
src/main/java/net/sinofool/alipay/base/AbstractAlipay.java
AbstractAlipay.signRSAWithQuote
protected String signRSAWithQuote(final List<StringPair> p) { String param = join(p, false, true); String sign = rsaSign(param); return sign; }
java
protected String signRSAWithQuote(final List<StringPair> p) { String param = join(p, false, true); String sign = rsaSign(param); return sign; }
[ "protected", "String", "signRSAWithQuote", "(", "final", "List", "<", "StringPair", ">", "p", ")", "{", "String", "param", "=", "join", "(", "p", ",", "false", ",", "true", ")", ";", "String", "sign", "=", "rsaSign", "(", "param", ")", ";", "return", "sign", ";", "}" ]
Mobile SDK join the fields with quote, which is not documented at all. @param p @return
[ "Mobile", "SDK", "join", "the", "fields", "with", "quote", "which", "is", "not", "documented", "at", "all", "." ]
b8bd07915386c8abd005f3d647b82100d966070c
https://github.com/sinofool/alipay-java-sdk/blob/b8bd07915386c8abd005f3d647b82100d966070c/src/main/java/net/sinofool/alipay/base/AbstractAlipay.java#L95-L99
4,142
jdmp/java-data-mining-package
jdmp-core/src/main/java/org/jdmp/core/algorithm/AbstractAlgorithm.java
AbstractAlgorithm.calculateObjects
public Map<String, Object> calculateObjects(Map<String, Object> objects) { Map<String, Object> result = new HashMap<String, Object>(); return result; }
java
public Map<String, Object> calculateObjects(Map<String, Object> objects) { Map<String, Object> result = new HashMap<String, Object>(); return result; }
[ "public", "Map", "<", "String", ",", "Object", ">", "calculateObjects", "(", "Map", "<", "String", ",", "Object", ">", "objects", ")", "{", "Map", "<", "String", ",", "Object", ">", "result", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "return", "result", ";", "}" ]
this is not the best way
[ "this", "is", "not", "the", "best", "way" ]
74e4516b0b7ba8931b71d54d44332e120f675ca9
https://github.com/jdmp/java-data-mining-package/blob/74e4516b0b7ba8931b71d54d44332e120f675ca9/jdmp-core/src/main/java/org/jdmp/core/algorithm/AbstractAlgorithm.java#L210-L213
4,143
SiftScience/sift-android
sift/src/main/java/siftscience/android/DevicePropertiesCollector.java
DevicePropertiesCollector.existingRootFiles
private List<String> existingRootFiles() { List<String> filesFound = new ArrayList<>(); for (String path : SU_PATHS) { if (new File(path).exists()) { filesFound.add(path); } } return filesFound; }
java
private List<String> existingRootFiles() { List<String> filesFound = new ArrayList<>(); for (String path : SU_PATHS) { if (new File(path).exists()) { filesFound.add(path); } } return filesFound; }
[ "private", "List", "<", "String", ">", "existingRootFiles", "(", ")", "{", "List", "<", "String", ">", "filesFound", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "String", "path", ":", "SU_PATHS", ")", "{", "if", "(", "new", "File", "(", "path", ")", ".", "exists", "(", ")", ")", "{", "filesFound", ".", "add", "(", "path", ")", ";", "}", "}", "return", "filesFound", ";", "}" ]
Checks for files that are known to indicate root. @return - list of such files found
[ "Checks", "for", "files", "that", "are", "known", "to", "indicate", "root", "." ]
21d6f2144a88bd16fd8f5443adf730865cc8923b
https://github.com/SiftScience/sift-android/blob/21d6f2144a88bd16fd8f5443adf730865cc8923b/sift/src/main/java/siftscience/android/DevicePropertiesCollector.java#L160-L168
4,144
SiftScience/sift-android
sift/src/main/java/siftscience/android/DevicePropertiesCollector.java
DevicePropertiesCollector.existingRootPackages
private List<String> existingRootPackages() { ArrayList<String> packages = new ArrayList<>(); packages.addAll(Arrays.asList(KNOWN_ROOT_APPS_PACKAGES)); packages.addAll(Arrays.asList(KNOWN_DANGEROUS_APPS_PACKAGES)); packages.addAll(Arrays.asList(KNOWN_ROOT_CLOAKING_PACKAGES)); PackageManager pm = context.getPackageManager(); List<String> packagesFound = new ArrayList<>(); for (String packageName : packages) { try { // Root app detected pm.getPackageInfo(packageName, 0); packagesFound.add(packageName); } catch (PackageManager.NameNotFoundException e) { // Exception thrown, package is not installed into the system } } return packagesFound; }
java
private List<String> existingRootPackages() { ArrayList<String> packages = new ArrayList<>(); packages.addAll(Arrays.asList(KNOWN_ROOT_APPS_PACKAGES)); packages.addAll(Arrays.asList(KNOWN_DANGEROUS_APPS_PACKAGES)); packages.addAll(Arrays.asList(KNOWN_ROOT_CLOAKING_PACKAGES)); PackageManager pm = context.getPackageManager(); List<String> packagesFound = new ArrayList<>(); for (String packageName : packages) { try { // Root app detected pm.getPackageInfo(packageName, 0); packagesFound.add(packageName); } catch (PackageManager.NameNotFoundException e) { // Exception thrown, package is not installed into the system } } return packagesFound; }
[ "private", "List", "<", "String", ">", "existingRootPackages", "(", ")", "{", "ArrayList", "<", "String", ">", "packages", "=", "new", "ArrayList", "<>", "(", ")", ";", "packages", ".", "addAll", "(", "Arrays", ".", "asList", "(", "KNOWN_ROOT_APPS_PACKAGES", ")", ")", ";", "packages", ".", "addAll", "(", "Arrays", ".", "asList", "(", "KNOWN_DANGEROUS_APPS_PACKAGES", ")", ")", ";", "packages", ".", "addAll", "(", "Arrays", ".", "asList", "(", "KNOWN_ROOT_CLOAKING_PACKAGES", ")", ")", ";", "PackageManager", "pm", "=", "context", ".", "getPackageManager", "(", ")", ";", "List", "<", "String", ">", "packagesFound", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "String", "packageName", ":", "packages", ")", "{", "try", "{", "// Root app detected", "pm", ".", "getPackageInfo", "(", "packageName", ",", "0", ")", ";", "packagesFound", ".", "add", "(", "packageName", ")", ";", "}", "catch", "(", "PackageManager", ".", "NameNotFoundException", "e", ")", "{", "// Exception thrown, package is not installed into the system", "}", "}", "return", "packagesFound", ";", "}" ]
Checks for packages that are known to indicate root. @return - list of such packages found
[ "Checks", "for", "packages", "that", "are", "known", "to", "indicate", "root", "." ]
21d6f2144a88bd16fd8f5443adf730865cc8923b
https://github.com/SiftScience/sift-android/blob/21d6f2144a88bd16fd8f5443adf730865cc8923b/sift/src/main/java/siftscience/android/DevicePropertiesCollector.java#L174-L193
4,145
SiftScience/sift-android
sift/src/main/java/siftscience/android/DevicePropertiesCollector.java
DevicePropertiesCollector.existingDangerousProperties
private List<String> existingDangerousProperties() { String[] lines = propertiesReader(); List<String> propertiesFound = new ArrayList<>(); for (String line : lines) { for (String key : DANGEROUS_PROPERTIES.keySet()) { if (line.contains(key) && line.contains(DANGEROUS_PROPERTIES.get(key))) { propertiesFound.add(line); } } } return propertiesFound; }
java
private List<String> existingDangerousProperties() { String[] lines = propertiesReader(); List<String> propertiesFound = new ArrayList<>(); for (String line : lines) { for (String key : DANGEROUS_PROPERTIES.keySet()) { if (line.contains(key) && line.contains(DANGEROUS_PROPERTIES.get(key))) { propertiesFound.add(line); } } } return propertiesFound; }
[ "private", "List", "<", "String", ">", "existingDangerousProperties", "(", ")", "{", "String", "[", "]", "lines", "=", "propertiesReader", "(", ")", ";", "List", "<", "String", ">", "propertiesFound", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "String", "line", ":", "lines", ")", "{", "for", "(", "String", "key", ":", "DANGEROUS_PROPERTIES", ".", "keySet", "(", ")", ")", "{", "if", "(", "line", ".", "contains", "(", "key", ")", "&&", "line", ".", "contains", "(", "DANGEROUS_PROPERTIES", ".", "get", "(", "key", ")", ")", ")", "{", "propertiesFound", ".", "add", "(", "line", ")", ";", "}", "}", "}", "return", "propertiesFound", ";", "}" ]
Checks system properties for any dangerous properties that indicate root. @return - list of dangerous properties that indicate root
[ "Checks", "system", "properties", "for", "any", "dangerous", "properties", "that", "indicate", "root", "." ]
21d6f2144a88bd16fd8f5443adf730865cc8923b
https://github.com/SiftScience/sift-android/blob/21d6f2144a88bd16fd8f5443adf730865cc8923b/sift/src/main/java/siftscience/android/DevicePropertiesCollector.java#L199-L210
4,146
SiftScience/sift-android
sift/src/main/java/siftscience/android/DevicePropertiesCollector.java
DevicePropertiesCollector.existingRWPaths
private List<String> existingRWPaths() { String[] lines = mountReader(); List<String> pathsFound = new ArrayList<>(); for (String line : lines) { // Split lines into parts String[] args = line.split(" "); if (args.length < 4){ // If we don't have enough options per line, skip this and log an error Log.e(TAG, String.format("Error formatting mount: %s", line)); continue; } String mountPoint = args[1]; String mountOptions = args[3]; for (String pathToCheck : PATHS_THAT_SHOULD_NOT_BE_WRITABLE) { if (mountPoint.equalsIgnoreCase(pathToCheck)) { // Split options out and compare against "rw" to avoid false positives for (String option : mountOptions.split(",")){ if (option.equalsIgnoreCase("rw")){ pathsFound.add(pathToCheck); break; } } } } } return pathsFound; }
java
private List<String> existingRWPaths() { String[] lines = mountReader(); List<String> pathsFound = new ArrayList<>(); for (String line : lines) { // Split lines into parts String[] args = line.split(" "); if (args.length < 4){ // If we don't have enough options per line, skip this and log an error Log.e(TAG, String.format("Error formatting mount: %s", line)); continue; } String mountPoint = args[1]; String mountOptions = args[3]; for (String pathToCheck : PATHS_THAT_SHOULD_NOT_BE_WRITABLE) { if (mountPoint.equalsIgnoreCase(pathToCheck)) { // Split options out and compare against "rw" to avoid false positives for (String option : mountOptions.split(",")){ if (option.equalsIgnoreCase("rw")){ pathsFound.add(pathToCheck); break; } } } } } return pathsFound; }
[ "private", "List", "<", "String", ">", "existingRWPaths", "(", ")", "{", "String", "[", "]", "lines", "=", "mountReader", "(", ")", ";", "List", "<", "String", ">", "pathsFound", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "String", "line", ":", "lines", ")", "{", "// Split lines into parts", "String", "[", "]", "args", "=", "line", ".", "split", "(", "\" \"", ")", ";", "if", "(", "args", ".", "length", "<", "4", ")", "{", "// If we don't have enough options per line, skip this and log an error", "Log", ".", "e", "(", "TAG", ",", "String", ".", "format", "(", "\"Error formatting mount: %s\"", ",", "line", ")", ")", ";", "continue", ";", "}", "String", "mountPoint", "=", "args", "[", "1", "]", ";", "String", "mountOptions", "=", "args", "[", "3", "]", ";", "for", "(", "String", "pathToCheck", ":", "PATHS_THAT_SHOULD_NOT_BE_WRITABLE", ")", "{", "if", "(", "mountPoint", ".", "equalsIgnoreCase", "(", "pathToCheck", ")", ")", "{", "// Split options out and compare against \"rw\" to avoid false positives", "for", "(", "String", "option", ":", "mountOptions", ".", "split", "(", "\",\"", ")", ")", "{", "if", "(", "option", ".", "equalsIgnoreCase", "(", "\"rw\"", ")", ")", "{", "pathsFound", ".", "add", "(", "pathToCheck", ")", ";", "break", ";", "}", "}", "}", "}", "}", "return", "pathsFound", ";", "}" ]
When you're root you can change the write permissions on common system directories. This method checks if any of the paths in PATHS_THAT_SHOULD_NOT_BE_WRITABLE are writable. @return all paths that are writable
[ "When", "you", "re", "root", "you", "can", "change", "the", "write", "permissions", "on", "common", "system", "directories", ".", "This", "method", "checks", "if", "any", "of", "the", "paths", "in", "PATHS_THAT_SHOULD_NOT_BE_WRITABLE", "are", "writable", "." ]
21d6f2144a88bd16fd8f5443adf730865cc8923b
https://github.com/SiftScience/sift-android/blob/21d6f2144a88bd16fd8f5443adf730865cc8923b/sift/src/main/java/siftscience/android/DevicePropertiesCollector.java#L217-L244
4,147
SiftScience/sift-android
sift/src/main/java/siftscience/android/Uploader.java
Uploader.makeRequest
@Nullable private Request makeRequest(List<MobileEventJson> batch) throws IOException { if (batch.isEmpty()) { return null; } Sift.Config config = configProvider.getConfig(); if (config == null) { Log.d(TAG, "Missing Sift.Config object"); return null; } if (config.accountId == null || config.beaconKey == null || config.serverUrlFormat == null) { Log.d(TAG, "Missing account ID, beacon key, and/or server URL format"); return null; } if (batch.isEmpty()) { Log.d(TAG, "Batch is null or empty"); return null; } URL url = new URL(String.format(config.serverUrlFormat, config.accountId)); final String encodedBeaconKey = Base64.encodeToString( config.beaconKey.getBytes(US_ASCII), Base64.NO_WRAP); Map<String, String> headers = new HashMap<String, String>(); headers.put("Authorization", "Basic " + encodedBeaconKey); headers.put("Accept", "application/json"); headers.put("Content-Encoding", "gzip"); headers.put("Content-Type", "application/json"); ListRequestJson request = new ListRequestJson() .withData(Collections.<Object>unmodifiableList(batch)); ByteArrayOutputStream os = new ByteArrayOutputStream(); OutputStream gzip = new GZIPOutputStream(os); Writer writer = new OutputStreamWriter(gzip, UTF8); Sift.GSON.toJson(request, writer); writer.close(); Log.d(TAG, String.format("Built HTTP request for batch of size %d", batch.size())); return new Request.Builder() .withMethod("PUT") .withUrl(url) .withHeaders(headers) .withBody(os.toByteArray()) .build(); }
java
@Nullable private Request makeRequest(List<MobileEventJson> batch) throws IOException { if (batch.isEmpty()) { return null; } Sift.Config config = configProvider.getConfig(); if (config == null) { Log.d(TAG, "Missing Sift.Config object"); return null; } if (config.accountId == null || config.beaconKey == null || config.serverUrlFormat == null) { Log.d(TAG, "Missing account ID, beacon key, and/or server URL format"); return null; } if (batch.isEmpty()) { Log.d(TAG, "Batch is null or empty"); return null; } URL url = new URL(String.format(config.serverUrlFormat, config.accountId)); final String encodedBeaconKey = Base64.encodeToString( config.beaconKey.getBytes(US_ASCII), Base64.NO_WRAP); Map<String, String> headers = new HashMap<String, String>(); headers.put("Authorization", "Basic " + encodedBeaconKey); headers.put("Accept", "application/json"); headers.put("Content-Encoding", "gzip"); headers.put("Content-Type", "application/json"); ListRequestJson request = new ListRequestJson() .withData(Collections.<Object>unmodifiableList(batch)); ByteArrayOutputStream os = new ByteArrayOutputStream(); OutputStream gzip = new GZIPOutputStream(os); Writer writer = new OutputStreamWriter(gzip, UTF8); Sift.GSON.toJson(request, writer); writer.close(); Log.d(TAG, String.format("Built HTTP request for batch of size %d", batch.size())); return new Request.Builder() .withMethod("PUT") .withUrl(url) .withHeaders(headers) .withBody(os.toByteArray()) .build(); }
[ "@", "Nullable", "private", "Request", "makeRequest", "(", "List", "<", "MobileEventJson", ">", "batch", ")", "throws", "IOException", "{", "if", "(", "batch", ".", "isEmpty", "(", ")", ")", "{", "return", "null", ";", "}", "Sift", ".", "Config", "config", "=", "configProvider", ".", "getConfig", "(", ")", ";", "if", "(", "config", "==", "null", ")", "{", "Log", ".", "d", "(", "TAG", ",", "\"Missing Sift.Config object\"", ")", ";", "return", "null", ";", "}", "if", "(", "config", ".", "accountId", "==", "null", "||", "config", ".", "beaconKey", "==", "null", "||", "config", ".", "serverUrlFormat", "==", "null", ")", "{", "Log", ".", "d", "(", "TAG", ",", "\"Missing account ID, beacon key, and/or server URL format\"", ")", ";", "return", "null", ";", "}", "if", "(", "batch", ".", "isEmpty", "(", ")", ")", "{", "Log", ".", "d", "(", "TAG", ",", "\"Batch is null or empty\"", ")", ";", "return", "null", ";", "}", "URL", "url", "=", "new", "URL", "(", "String", ".", "format", "(", "config", ".", "serverUrlFormat", ",", "config", ".", "accountId", ")", ")", ";", "final", "String", "encodedBeaconKey", "=", "Base64", ".", "encodeToString", "(", "config", ".", "beaconKey", ".", "getBytes", "(", "US_ASCII", ")", ",", "Base64", ".", "NO_WRAP", ")", ";", "Map", "<", "String", ",", "String", ">", "headers", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "headers", ".", "put", "(", "\"Authorization\"", ",", "\"Basic \"", "+", "encodedBeaconKey", ")", ";", "headers", ".", "put", "(", "\"Accept\"", ",", "\"application/json\"", ")", ";", "headers", ".", "put", "(", "\"Content-Encoding\"", ",", "\"gzip\"", ")", ";", "headers", ".", "put", "(", "\"Content-Type\"", ",", "\"application/json\"", ")", ";", "ListRequestJson", "request", "=", "new", "ListRequestJson", "(", ")", ".", "withData", "(", "Collections", ".", "<", "Object", ">", "unmodifiableList", "(", "batch", ")", ")", ";", "ByteArrayOutputStream", "os", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "OutputStream", "gzip", "=", "new", "GZIPOutputStream", "(", "os", ")", ";", "Writer", "writer", "=", "new", "OutputStreamWriter", "(", "gzip", ",", "UTF8", ")", ";", "Sift", ".", "GSON", ".", "toJson", "(", "request", ",", "writer", ")", ";", "writer", ".", "close", "(", ")", ";", "Log", ".", "d", "(", "TAG", ",", "String", ".", "format", "(", "\"Built HTTP request for batch of size %d\"", ",", "batch", ".", "size", "(", ")", ")", ")", ";", "return", "new", "Request", ".", "Builder", "(", ")", ".", "withMethod", "(", "\"PUT\"", ")", ".", "withUrl", "(", "url", ")", ".", "withHeaders", "(", "headers", ")", ".", "withBody", "(", "os", ".", "toByteArray", "(", ")", ")", ".", "build", "(", ")", ";", "}" ]
Builds a Request for the specified event batch
[ "Builds", "a", "Request", "for", "the", "specified", "event", "batch" ]
21d6f2144a88bd16fd8f5443adf730865cc8923b
https://github.com/SiftScience/sift-android/blob/21d6f2144a88bd16fd8f5443adf730865cc8923b/sift/src/main/java/siftscience/android/Uploader.java#L129-L180
4,148
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/util/support/AbstractListHolder.java
AbstractListHolder.getList
@Override public List<T> getList() { if (isCacheEnabled) { if (cachedResult == null) { cachedResult = makeUnmodifiableUniqueList(); } return cachedResult; } else { return makeUnmodifiableUniqueList(); } }
java
@Override public List<T> getList() { if (isCacheEnabled) { if (cachedResult == null) { cachedResult = makeUnmodifiableUniqueList(); } return cachedResult; } else { return makeUnmodifiableUniqueList(); } }
[ "@", "Override", "public", "List", "<", "T", ">", "getList", "(", ")", "{", "if", "(", "isCacheEnabled", ")", "{", "if", "(", "cachedResult", "==", "null", ")", "{", "cachedResult", "=", "makeUnmodifiableUniqueList", "(", ")", ";", "}", "return", "cachedResult", ";", "}", "else", "{", "return", "makeUnmodifiableUniqueList", "(", ")", ";", "}", "}" ]
Returns the list that this ListHolder backs.
[ "Returns", "the", "list", "that", "this", "ListHolder", "backs", "." ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/util/support/AbstractListHolder.java#L80-L90
4,149
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/util/support/AbstractListHolder.java
AbstractListHolder.makeUnmodifiableUniqueList
private List<T> makeUnmodifiableUniqueList() { Set<T> tmp = newHashSet(); List<T> uniques = newArrayList(); for (T t : getIterable()) { if (tmp.add(t)) { uniques.add(t); } } sort(uniques); return unmodifiableList(uniques); }
java
private List<T> makeUnmodifiableUniqueList() { Set<T> tmp = newHashSet(); List<T> uniques = newArrayList(); for (T t : getIterable()) { if (tmp.add(t)) { uniques.add(t); } } sort(uniques); return unmodifiableList(uniques); }
[ "private", "List", "<", "T", ">", "makeUnmodifiableUniqueList", "(", ")", "{", "Set", "<", "T", ">", "tmp", "=", "newHashSet", "(", ")", ";", "List", "<", "T", ">", "uniques", "=", "newArrayList", "(", ")", ";", "for", "(", "T", "t", ":", "getIterable", "(", ")", ")", "{", "if", "(", "tmp", ".", "add", "(", "t", ")", ")", "{", "uniques", ".", "add", "(", "t", ")", ";", "}", "}", "sort", "(", "uniques", ")", ";", "return", "unmodifiableList", "(", "uniques", ")", ";", "}" ]
remove duplication if any
[ "remove", "duplication", "if", "any" ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/util/support/AbstractListHolder.java#L93-L104
4,150
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/util/support/AbstractListHolder.java
AbstractListHolder.getSubList
public List<T> getSubList(int maxSubListSize) { List<T> subList = newArrayList(); int counter = 0; for (T t : getList()) { if (counter++ < maxSubListSize) { subList.add(t); } else { break; } } return subList; }
java
public List<T> getSubList(int maxSubListSize) { List<T> subList = newArrayList(); int counter = 0; for (T t : getList()) { if (counter++ < maxSubListSize) { subList.add(t); } else { break; } } return subList; }
[ "public", "List", "<", "T", ">", "getSubList", "(", "int", "maxSubListSize", ")", "{", "List", "<", "T", ">", "subList", "=", "newArrayList", "(", ")", ";", "int", "counter", "=", "0", ";", "for", "(", "T", "t", ":", "getList", "(", ")", ")", "{", "if", "(", "counter", "++", "<", "maxSubListSize", ")", "{", "subList", ".", "add", "(", "t", ")", ";", "}", "else", "{", "break", ";", "}", "}", "return", "subList", ";", "}" ]
Returns at most the first maxSubListSize elements of this list.
[ "Returns", "at", "most", "the", "first", "maxSubListSize", "elements", "of", "this", "list", "." ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/util/support/AbstractListHolder.java#L136-L147
4,151
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/util/support/AbstractListHolder.java
AbstractListHolder.except
public SimpleListHolder<T> except(String... namesToExclude) { String key = "current" + getCacheKey(namesToExclude); SimpleListHolder<T> result = cache.get(key); if (result == null) { result = new SimpleListHolder<T>(getIterable(), asNameNotEqualsToPredicates(namesToExclude), getSortProperty()); cache.put(key, result); } return result; }
java
public SimpleListHolder<T> except(String... namesToExclude) { String key = "current" + getCacheKey(namesToExclude); SimpleListHolder<T> result = cache.get(key); if (result == null) { result = new SimpleListHolder<T>(getIterable(), asNameNotEqualsToPredicates(namesToExclude), getSortProperty()); cache.put(key, result); } return result; }
[ "public", "SimpleListHolder", "<", "T", ">", "except", "(", "String", "...", "namesToExclude", ")", "{", "String", "key", "=", "\"current\"", "+", "getCacheKey", "(", "namesToExclude", ")", ";", "SimpleListHolder", "<", "T", ">", "result", "=", "cache", ".", "get", "(", "key", ")", ";", "if", "(", "result", "==", "null", ")", "{", "result", "=", "new", "SimpleListHolder", "<", "T", ">", "(", "getIterable", "(", ")", ",", "asNameNotEqualsToPredicates", "(", "namesToExclude", ")", ",", "getSortProperty", "(", ")", ")", ";", "cache", ".", "put", "(", "key", ",", "result", ")", ";", "}", "return", "result", ";", "}" ]
Fork this list with extra predicates. @param namesToExclude the name of the elements to exclude from the list.
[ "Fork", "this", "list", "with", "extra", "predicates", "." ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/util/support/AbstractListHolder.java#L175-L183
4,152
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/util/IOUtil.java
IOUtil.inputStreamToOutputStream
public int inputStreamToOutputStream(InputStream is, OutputStream os) throws IOException { byte buffer[] = new byte[1024 * 100]; // 100kb int len = -1; int total = 0; while ((len = is.read(buffer)) >= 0) { os.write(buffer, 0, len); total += len; } return total; }
java
public int inputStreamToOutputStream(InputStream is, OutputStream os) throws IOException { byte buffer[] = new byte[1024 * 100]; // 100kb int len = -1; int total = 0; while ((len = is.read(buffer)) >= 0) { os.write(buffer, 0, len); total += len; } return total; }
[ "public", "int", "inputStreamToOutputStream", "(", "InputStream", "is", ",", "OutputStream", "os", ")", "throws", "IOException", "{", "byte", "buffer", "[", "]", "=", "new", "byte", "[", "1024", "*", "100", "]", ";", "// 100kb", "int", "len", "=", "-", "1", ";", "int", "total", "=", "0", ";", "while", "(", "(", "len", "=", "is", ".", "read", "(", "buffer", ")", ")", ">=", "0", ")", "{", "os", ".", "write", "(", "buffer", ",", "0", ",", "len", ")", ";", "total", "+=", "len", ";", "}", "return", "total", ";", "}" ]
Write to the outputstream the bytes read from the input stream.
[ "Write", "to", "the", "outputstream", "the", "bytes", "read", "from", "the", "input", "stream", "." ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/util/IOUtil.java#L45-L55
4,153
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/util/IOUtil.java
IOUtil.inputStreamToFile
public void inputStreamToFile(InputStream is, String filename) throws IOException { FileOutputStream fos = new FileOutputStream(filename); inputStreamToOutputStream(is, fos); fos.close(); }
java
public void inputStreamToFile(InputStream is, String filename) throws IOException { FileOutputStream fos = new FileOutputStream(filename); inputStreamToOutputStream(is, fos); fos.close(); }
[ "public", "void", "inputStreamToFile", "(", "InputStream", "is", ",", "String", "filename", ")", "throws", "IOException", "{", "FileOutputStream", "fos", "=", "new", "FileOutputStream", "(", "filename", ")", ";", "inputStreamToOutputStream", "(", "is", ",", "fos", ")", ";", "fos", ".", "close", "(", ")", ";", "}" ]
Write to a file the bytes read from an input stream. @param filename the full or relative path to the file.
[ "Write", "to", "a", "file", "the", "bytes", "read", "from", "an", "input", "stream", "." ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/util/IOUtil.java#L92-L96
4,154
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/util/IOUtil.java
IOUtil.inputStreamToString
public String inputStreamToString(InputStream is, String charset) throws IOException { InputStreamReader isr = null; if (null == charset) { isr = new InputStreamReader(is); } else { isr = new InputStreamReader(is, charset); } StringWriter sw = new StringWriter(); int c = -1; while ((c = isr.read()) != -1) { sw.write(c); } isr.close(); return sw.getBuffer().toString(); }
java
public String inputStreamToString(InputStream is, String charset) throws IOException { InputStreamReader isr = null; if (null == charset) { isr = new InputStreamReader(is); } else { isr = new InputStreamReader(is, charset); } StringWriter sw = new StringWriter(); int c = -1; while ((c = isr.read()) != -1) { sw.write(c); } isr.close(); return sw.getBuffer().toString(); }
[ "public", "String", "inputStreamToString", "(", "InputStream", "is", ",", "String", "charset", ")", "throws", "IOException", "{", "InputStreamReader", "isr", "=", "null", ";", "if", "(", "null", "==", "charset", ")", "{", "isr", "=", "new", "InputStreamReader", "(", "is", ")", ";", "}", "else", "{", "isr", "=", "new", "InputStreamReader", "(", "is", ",", "charset", ")", ";", "}", "StringWriter", "sw", "=", "new", "StringWriter", "(", ")", ";", "int", "c", "=", "-", "1", ";", "while", "(", "(", "c", "=", "isr", ".", "read", "(", ")", ")", "!=", "-", "1", ")", "{", "sw", ".", "write", "(", "c", ")", ";", "}", "isr", ".", "close", "(", ")", ";", "return", "sw", ".", "getBuffer", "(", ")", ".", "toString", "(", ")", ";", "}" ]
Write to a string the bytes read from an input stream. @param charset the charset used to read the input stream @return the inputstream as a string
[ "Write", "to", "a", "string", "the", "bytes", "read", "from", "an", "input", "stream", "." ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/util/IOUtil.java#L124-L138
4,155
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/util/IOUtil.java
IOUtil.isParentAnEmptyDirectory
public boolean isParentAnEmptyDirectory(File file) { File parent = file.getParentFile(); if (parent != null && parent.exists() && parent.isDirectory() && parent.list().length == 0) { return true; } return false; }
java
public boolean isParentAnEmptyDirectory(File file) { File parent = file.getParentFile(); if (parent != null && parent.exists() && parent.isDirectory() && parent.list().length == 0) { return true; } return false; }
[ "public", "boolean", "isParentAnEmptyDirectory", "(", "File", "file", ")", "{", "File", "parent", "=", "file", ".", "getParentFile", "(", ")", ";", "if", "(", "parent", "!=", "null", "&&", "parent", ".", "exists", "(", ")", "&&", "parent", ".", "isDirectory", "(", ")", "&&", "parent", ".", "list", "(", ")", ".", "length", "==", "0", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Determine if the directory where the passed file resides is empty. @param file the folder to remove @return true if the parent folder is empty, false otherwise
[ "Determine", "if", "the", "directory", "where", "the", "passed", "file", "resides", "is", "empty", "." ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/util/IOUtil.java#L169-L177
4,156
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/util/IOUtil.java
IOUtil.pruneEmptyDirs
public void pruneEmptyDirs(File targetFile) { while (isParentAnEmptyDirectory(targetFile)) { try { targetFile.getParentFile().delete(); targetFile = targetFile.getParentFile(); } catch (Exception e) { // } } }
java
public void pruneEmptyDirs(File targetFile) { while (isParentAnEmptyDirectory(targetFile)) { try { targetFile.getParentFile().delete(); targetFile = targetFile.getParentFile(); } catch (Exception e) { // } } }
[ "public", "void", "pruneEmptyDirs", "(", "File", "targetFile", ")", "{", "while", "(", "isParentAnEmptyDirectory", "(", "targetFile", ")", ")", "{", "try", "{", "targetFile", ".", "getParentFile", "(", ")", ".", "delete", "(", ")", ";", "targetFile", "=", "targetFile", ".", "getParentFile", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "//", "}", "}", "}" ]
prune empty dir @param targetFile the folder to remove
[ "prune", "empty", "dir" ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/util/IOUtil.java#L193-L202
4,157
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/util/IOUtil.java
IOUtil.listFolders
@SuppressWarnings("unchecked") public Collection<String> listFolders(File folder) { IOFileFilter ioFileFilter = FileFilterUtils.makeSVNAware(FileFilterUtils.makeCVSAware(FileFilterUtils.trueFileFilter())); Collection<File> files = FileUtils.listFiles(folder, FileFilterUtils.fileFileFilter(), ioFileFilter); Set<String> ret = newTreeSet(); for (File file : files) { ret.add(file.getParentFile().getAbsolutePath()); } return ret; }
java
@SuppressWarnings("unchecked") public Collection<String> listFolders(File folder) { IOFileFilter ioFileFilter = FileFilterUtils.makeSVNAware(FileFilterUtils.makeCVSAware(FileFilterUtils.trueFileFilter())); Collection<File> files = FileUtils.listFiles(folder, FileFilterUtils.fileFileFilter(), ioFileFilter); Set<String> ret = newTreeSet(); for (File file : files) { ret.add(file.getParentFile().getAbsolutePath()); } return ret; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "Collection", "<", "String", ">", "listFolders", "(", "File", "folder", ")", "{", "IOFileFilter", "ioFileFilter", "=", "FileFilterUtils", ".", "makeSVNAware", "(", "FileFilterUtils", ".", "makeCVSAware", "(", "FileFilterUtils", ".", "trueFileFilter", "(", ")", ")", ")", ";", "Collection", "<", "File", ">", "files", "=", "FileUtils", ".", "listFiles", "(", "folder", ",", "FileFilterUtils", ".", "fileFileFilter", "(", ")", ",", "ioFileFilter", ")", ";", "Set", "<", "String", ">", "ret", "=", "newTreeSet", "(", ")", ";", "for", "(", "File", "file", ":", "files", ")", "{", "ret", ".", "add", "(", "file", ".", "getParentFile", "(", ")", ".", "getAbsolutePath", "(", ")", ")", ";", "}", "return", "ret", ";", "}" ]
Recurse in the folder to get the list all files and folders of all non svn files @param folder the folder to parse
[ "Recurse", "in", "the", "folder", "to", "get", "the", "list", "all", "files", "and", "folders", "of", "all", "non", "svn", "files" ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/util/IOUtil.java#L250-L259
4,158
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/util/IOUtil.java
IOUtil.forceDelete
public void forceDelete(File tempFile) { try { if (tempFile != null && tempFile.exists()) { FileUtils.forceDelete(tempFile); } } catch (Throwable t) { t.printStackTrace(); } }
java
public void forceDelete(File tempFile) { try { if (tempFile != null && tempFile.exists()) { FileUtils.forceDelete(tempFile); } } catch (Throwable t) { t.printStackTrace(); } }
[ "public", "void", "forceDelete", "(", "File", "tempFile", ")", "{", "try", "{", "if", "(", "tempFile", "!=", "null", "&&", "tempFile", ".", "exists", "(", ")", ")", "{", "FileUtils", ".", "forceDelete", "(", "tempFile", ")", ";", "}", "}", "catch", "(", "Throwable", "t", ")", "{", "t", ".", "printStackTrace", "(", ")", ";", "}", "}" ]
force the deletion of a file
[ "force", "the", "deletion", "of", "a", "file" ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/util/IOUtil.java#L297-L305
4,159
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/model/support/validation/ValidationAttribute.java
ValidationAttribute.getAnnotations
public List<String> getAnnotations() { AnnotationBuilder result = new AnnotationBuilder(); result.add( // getFixedLengthAnnotation(), // getLengthAnnotation(), // getNotNullAnnotation(), // getNotEmptyAnnotation(), // getCharPaddingAnnotation(), // getEmailAnnotation(), // getDigitsAnnotation(), // getSafeHtmlAnnotation(), // getUrlAnnotation()); return result.getAnnotations(); }
java
public List<String> getAnnotations() { AnnotationBuilder result = new AnnotationBuilder(); result.add( // getFixedLengthAnnotation(), // getLengthAnnotation(), // getNotNullAnnotation(), // getNotEmptyAnnotation(), // getCharPaddingAnnotation(), // getEmailAnnotation(), // getDigitsAnnotation(), // getSafeHtmlAnnotation(), // getUrlAnnotation()); return result.getAnnotations(); }
[ "public", "List", "<", "String", ">", "getAnnotations", "(", ")", "{", "AnnotationBuilder", "result", "=", "new", "AnnotationBuilder", "(", ")", ";", "result", ".", "add", "(", "//", "getFixedLengthAnnotation", "(", ")", ",", "//", "getLengthAnnotation", "(", ")", ",", "//", "getNotNullAnnotation", "(", ")", ",", "//", "getNotEmptyAnnotation", "(", ")", ",", "//", "getCharPaddingAnnotation", "(", ")", ",", "//", "getEmailAnnotation", "(", ")", ",", "//", "getDigitsAnnotation", "(", ")", ",", "//", "getSafeHtmlAnnotation", "(", ")", ",", "//", "getUrlAnnotation", "(", ")", ")", ";", "return", "result", ".", "getAnnotations", "(", ")", ";", "}" ]
Returns all the validation annotations for the attribute. Imports are processed automatically.
[ "Returns", "all", "the", "validation", "annotations", "for", "the", "attribute", ".", "Imports", "are", "processed", "automatically", "." ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/model/support/validation/ValidationAttribute.java#L52-L65
4,160
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/template/PreviousEngine.java
PreviousEngine.convertFileNameToBaseClassName
private String convertFileNameToBaseClassName(String filename) { if (filename.endsWith("_.java")) { return substringBeforeLast(filename, "_.java") + BASE_SUFFIX_; } else { return substringBeforeLast(filename, ".java") + BASE_SUFFIX; } }
java
private String convertFileNameToBaseClassName(String filename) { if (filename.endsWith("_.java")) { return substringBeforeLast(filename, "_.java") + BASE_SUFFIX_; } else { return substringBeforeLast(filename, ".java") + BASE_SUFFIX; } }
[ "private", "String", "convertFileNameToBaseClassName", "(", "String", "filename", ")", "{", "if", "(", "filename", ".", "endsWith", "(", "\"_.java\"", ")", ")", "{", "return", "substringBeforeLast", "(", "filename", ",", "\"_.java\"", ")", "+", "BASE_SUFFIX_", ";", "}", "else", "{", "return", "substringBeforeLast", "(", "filename", ",", "\".java\"", ")", "+", "BASE_SUFFIX", ";", "}", "}" ]
add Base to a given java filename it is used for transparently subclassing generated classes
[ "add", "Base", "to", "a", "given", "java", "filename", "it", "is", "used", "for", "transparently", "subclassing", "generated", "classes" ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/template/PreviousEngine.java#L303-L309
4,161
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/template/ContentWriter.java
ContentWriter.getFullPathForLog
private String getFullPathForLog(OutputResult or, String targetFilename) { if (or.sameDirectory()) { return targetFilename; } else { return or.getGeneratedSource().getFullPath(targetFilename); } }
java
private String getFullPathForLog(OutputResult or, String targetFilename) { if (or.sameDirectory()) { return targetFilename; } else { return or.getGeneratedSource().getFullPath(targetFilename); } }
[ "private", "String", "getFullPathForLog", "(", "OutputResult", "or", ",", "String", "targetFilename", ")", "{", "if", "(", "or", ".", "sameDirectory", "(", ")", ")", "{", "return", "targetFilename", ";", "}", "else", "{", "return", "or", ".", "getGeneratedSource", "(", ")", ".", "getFullPath", "(", "targetFilename", ")", ";", "}", "}" ]
Use it only to display proper path in log @param targetFilename
[ "Use", "it", "only", "to", "display", "proper", "path", "in", "log" ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/template/ContentWriter.java#L109-L115
4,162
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/factory/EntityFactory.java
EntityFactory.buildSimpleEntity
private void buildSimpleEntity(EntityConfig entityConfig, Entity entity) { Table table = entity.getTable(); // 1st phase: process all column and look for corresponding columnConfig for (Column column : table.getColumns()) { boolean processed = processColumnUsingColumnConfigIfAny(entityConfig, entity, column); // no columnConfig, we just use defaults if (!processed) { entity.addAttribute(attributeFactory.build(entity, table, column)); } } // detect invalid column and jpa secondary case processInvalidColumnConfigAndJpaSecondaryTable(entityConfig, entity); }
java
private void buildSimpleEntity(EntityConfig entityConfig, Entity entity) { Table table = entity.getTable(); // 1st phase: process all column and look for corresponding columnConfig for (Column column : table.getColumns()) { boolean processed = processColumnUsingColumnConfigIfAny(entityConfig, entity, column); // no columnConfig, we just use defaults if (!processed) { entity.addAttribute(attributeFactory.build(entity, table, column)); } } // detect invalid column and jpa secondary case processInvalidColumnConfigAndJpaSecondaryTable(entityConfig, entity); }
[ "private", "void", "buildSimpleEntity", "(", "EntityConfig", "entityConfig", ",", "Entity", "entity", ")", "{", "Table", "table", "=", "entity", ".", "getTable", "(", ")", ";", "// 1st phase: process all column and look for corresponding columnConfig", "for", "(", "Column", "column", ":", "table", ".", "getColumns", "(", ")", ")", "{", "boolean", "processed", "=", "processColumnUsingColumnConfigIfAny", "(", "entityConfig", ",", "entity", ",", "column", ")", ";", "// no columnConfig, we just use defaults", "if", "(", "!", "processed", ")", "{", "entity", ".", "addAttribute", "(", "attributeFactory", ".", "build", "(", "entity", ",", "table", ",", "column", ")", ")", ";", "}", "}", "// detect invalid column and jpa secondary case", "processInvalidColumnConfigAndJpaSecondaryTable", "(", "entityConfig", ",", "entity", ")", ";", "}" ]
Build simple entity using user configuration
[ "Build", "simple", "entity", "using", "user", "configuration" ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/factory/EntityFactory.java#L103-L118
4,163
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/factory/EntityFactory.java
EntityFactory.namerDefault
private void namerDefault(Entity entity) { entity.put("searchForm", new ClassNamer2(entity, null, "web.domain", null, "SearchForm")); entity.put("editForm", new ClassNamer2(entity, null, "web.domain", null, "EditForm")); entity.put("graphLoader", new ClassNamer2(entity, null, "web.domain", null, "GraphLoader")); entity.put("controller", new ClassNamer2(entity, null, "web.domain", null, "Controller")); entity.put("excelExporter", new ClassNamer2(entity, null, "web.domain", null, "ExcelExporter")); entity.put("lazyDataModel", new ClassNamer2(entity, null, "web.domain", null, "LazyDataModel")); entity.put("fileUpload", new ClassNamer2(entity, null, "web.domain", null, "FileUpload")); entity.put("fileDownload", new ClassNamer2(entity, null, "web.domain", null, "FileDownload")); }
java
private void namerDefault(Entity entity) { entity.put("searchForm", new ClassNamer2(entity, null, "web.domain", null, "SearchForm")); entity.put("editForm", new ClassNamer2(entity, null, "web.domain", null, "EditForm")); entity.put("graphLoader", new ClassNamer2(entity, null, "web.domain", null, "GraphLoader")); entity.put("controller", new ClassNamer2(entity, null, "web.domain", null, "Controller")); entity.put("excelExporter", new ClassNamer2(entity, null, "web.domain", null, "ExcelExporter")); entity.put("lazyDataModel", new ClassNamer2(entity, null, "web.domain", null, "LazyDataModel")); entity.put("fileUpload", new ClassNamer2(entity, null, "web.domain", null, "FileUpload")); entity.put("fileDownload", new ClassNamer2(entity, null, "web.domain", null, "FileDownload")); }
[ "private", "void", "namerDefault", "(", "Entity", "entity", ")", "{", "entity", ".", "put", "(", "\"searchForm\"", ",", "new", "ClassNamer2", "(", "entity", ",", "null", ",", "\"web.domain\"", ",", "null", ",", "\"SearchForm\"", ")", ")", ";", "entity", ".", "put", "(", "\"editForm\"", ",", "new", "ClassNamer2", "(", "entity", ",", "null", ",", "\"web.domain\"", ",", "null", ",", "\"EditForm\"", ")", ")", ";", "entity", ".", "put", "(", "\"graphLoader\"", ",", "new", "ClassNamer2", "(", "entity", ",", "null", ",", "\"web.domain\"", ",", "null", ",", "\"GraphLoader\"", ")", ")", ";", "entity", ".", "put", "(", "\"controller\"", ",", "new", "ClassNamer2", "(", "entity", ",", "null", ",", "\"web.domain\"", ",", "null", ",", "\"Controller\"", ")", ")", ";", "entity", ".", "put", "(", "\"excelExporter\"", ",", "new", "ClassNamer2", "(", "entity", ",", "null", ",", "\"web.domain\"", ",", "null", ",", "\"ExcelExporter\"", ")", ")", ";", "entity", ".", "put", "(", "\"lazyDataModel\"", ",", "new", "ClassNamer2", "(", "entity", ",", "null", ",", "\"web.domain\"", ",", "null", ",", "\"LazyDataModel\"", ")", ")", ";", "entity", ".", "put", "(", "\"fileUpload\"", ",", "new", "ClassNamer2", "(", "entity", ",", "null", ",", "\"web.domain\"", ",", "null", ",", "\"FileUpload\"", ")", ")", ";", "entity", ".", "put", "(", "\"fileDownload\"", ",", "new", "ClassNamer2", "(", "entity", ",", "null", ",", "\"web.domain\"", ",", "null", ",", "\"FileDownload\"", ")", ")", ";", "}" ]
Namers declared here can be overridden easily through configuration. @param entity
[ "Namers", "declared", "here", "can", "be", "overridden", "easily", "through", "configuration", "." ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/factory/EntityFactory.java#L246-L255
4,164
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/util/MiscUtil.java
MiscUtil.toReadablePluralLabel
public static String toReadablePluralLabel(String value) { String label = toReadableLabel(value); return label.endsWith("ss") ? label.substring(0, label.length() - 1) : label; }
java
public static String toReadablePluralLabel(String value) { String label = toReadableLabel(value); return label.endsWith("ss") ? label.substring(0, label.length() - 1) : label; }
[ "public", "static", "String", "toReadablePluralLabel", "(", "String", "value", ")", "{", "String", "label", "=", "toReadableLabel", "(", "value", ")", ";", "return", "label", ".", "endsWith", "(", "\"ss\"", ")", "?", "label", ".", "substring", "(", "0", ",", "label", ".", "length", "(", ")", "-", "1", ")", ":", "label", ";", "}" ]
Convert strings such as "banquePayss" to "Banque Pays" it will remove trailing ss and replace them with s
[ "Convert", "strings", "such", "as", "banquePayss", "to", "Banque", "Pays", "it", "will", "remove", "trailing", "ss", "and", "replace", "them", "with", "s" ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/util/MiscUtil.java#L120-L123
4,165
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/util/MiscUtil.java
MiscUtil.toReadableLabel
public static String toReadableLabel(String value) { StringBuilder ret = new StringBuilder(); char lastChar = 'x'; for (int i = 0; i < value.length(); i++) { char currentChar = value.charAt(i); // we are the begining of the output // or the last char was a space // then uppercase if ((i == 0 || lastChar == ' ') && !(isSeparator(currentChar))) { currentChar = Character.toUpperCase(currentChar); } else if (Character.isLowerCase(lastChar) && Character.isUpperCase(currentChar)) { // we switched case --> add a space ret.append(' '); } else if (isSeparator(currentChar)) { // we are on a _, this is a space currentChar = ' '; } if (!(lastChar == ' ' && currentChar == ' ')) { ret.append(currentChar); lastChar = currentChar; } } if (ret.toString().startsWith("Is ") || ret.toString().startsWith("Has ")) { ret.append('?'); } return ret.toString(); }
java
public static String toReadableLabel(String value) { StringBuilder ret = new StringBuilder(); char lastChar = 'x'; for (int i = 0; i < value.length(); i++) { char currentChar = value.charAt(i); // we are the begining of the output // or the last char was a space // then uppercase if ((i == 0 || lastChar == ' ') && !(isSeparator(currentChar))) { currentChar = Character.toUpperCase(currentChar); } else if (Character.isLowerCase(lastChar) && Character.isUpperCase(currentChar)) { // we switched case --> add a space ret.append(' '); } else if (isSeparator(currentChar)) { // we are on a _, this is a space currentChar = ' '; } if (!(lastChar == ' ' && currentChar == ' ')) { ret.append(currentChar); lastChar = currentChar; } } if (ret.toString().startsWith("Is ") || ret.toString().startsWith("Has ")) { ret.append('?'); } return ret.toString(); }
[ "public", "static", "String", "toReadableLabel", "(", "String", "value", ")", "{", "StringBuilder", "ret", "=", "new", "StringBuilder", "(", ")", ";", "char", "lastChar", "=", "'", "'", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "value", ".", "length", "(", ")", ";", "i", "++", ")", "{", "char", "currentChar", "=", "value", ".", "charAt", "(", "i", ")", ";", "// we are the begining of the output", "// or the last char was a space", "// then uppercase", "if", "(", "(", "i", "==", "0", "||", "lastChar", "==", "'", "'", ")", "&&", "!", "(", "isSeparator", "(", "currentChar", ")", ")", ")", "{", "currentChar", "=", "Character", ".", "toUpperCase", "(", "currentChar", ")", ";", "}", "else", "if", "(", "Character", ".", "isLowerCase", "(", "lastChar", ")", "&&", "Character", ".", "isUpperCase", "(", "currentChar", ")", ")", "{", "// we switched case --> add a space", "ret", ".", "append", "(", "'", "'", ")", ";", "}", "else", "if", "(", "isSeparator", "(", "currentChar", ")", ")", "{", "// we are on a _, this is a space", "currentChar", "=", "'", "'", ";", "}", "if", "(", "!", "(", "lastChar", "==", "'", "'", "&&", "currentChar", "==", "'", "'", ")", ")", "{", "ret", ".", "append", "(", "currentChar", ")", ";", "lastChar", "=", "currentChar", ";", "}", "}", "if", "(", "ret", ".", "toString", "(", ")", ".", "startsWith", "(", "\"Is \"", ")", "||", "ret", ".", "toString", "(", ")", ".", "startsWith", "(", "\"Has \"", ")", ")", "{", "ret", ".", "append", "(", "'", "'", ")", ";", "}", "return", "ret", ".", "toString", "(", ")", ";", "}" ]
Convert strings such as bankAccountSummary to "Bank Account Summary"
[ "Convert", "strings", "such", "as", "bankAccountSummary", "to", "Bank", "Account", "Summary" ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/util/MiscUtil.java#L128-L157
4,166
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/util/MiscUtil.java
MiscUtil.endsWithIgnoreCase
public static boolean endsWithIgnoreCase(String name, Iterable<String> patterns) { String nameUpper = name.toUpperCase(); for (String pattern : patterns) { String patternUpper = pattern.toUpperCase(); if (nameUpper.equals(patternUpper) || nameUpper.endsWith(patternUpper)) { return true; } } return false; }
java
public static boolean endsWithIgnoreCase(String name, Iterable<String> patterns) { String nameUpper = name.toUpperCase(); for (String pattern : patterns) { String patternUpper = pattern.toUpperCase(); if (nameUpper.equals(patternUpper) || nameUpper.endsWith(patternUpper)) { return true; } } return false; }
[ "public", "static", "boolean", "endsWithIgnoreCase", "(", "String", "name", ",", "Iterable", "<", "String", ">", "patterns", ")", "{", "String", "nameUpper", "=", "name", ".", "toUpperCase", "(", ")", ";", "for", "(", "String", "pattern", ":", "patterns", ")", "{", "String", "patternUpper", "=", "pattern", ".", "toUpperCase", "(", ")", ";", "if", "(", "nameUpper", ".", "equals", "(", "patternUpper", ")", "||", "nameUpper", ".", "endsWith", "(", "patternUpper", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Does the given column name ends with one of pattern given in parameter. Not case sensitive
[ "Does", "the", "given", "column", "name", "ends", "with", "one", "of", "pattern", "given", "in", "parameter", ".", "Not", "case", "sensitive" ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/util/MiscUtil.java#L162-L172
4,167
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/util/MiscUtil.java
MiscUtil.startsWithIgnoreCase
public static boolean startsWithIgnoreCase(String name, Iterable<String> patterns) { String nameUpper = name.toUpperCase(); for (String pattern : patterns) { String patternUpper = pattern.toUpperCase(); if (nameUpper.equals(patternUpper) || nameUpper.startsWith(patternUpper)) { return true; } } return false; }
java
public static boolean startsWithIgnoreCase(String name, Iterable<String> patterns) { String nameUpper = name.toUpperCase(); for (String pattern : patterns) { String patternUpper = pattern.toUpperCase(); if (nameUpper.equals(patternUpper) || nameUpper.startsWith(patternUpper)) { return true; } } return false; }
[ "public", "static", "boolean", "startsWithIgnoreCase", "(", "String", "name", ",", "Iterable", "<", "String", ">", "patterns", ")", "{", "String", "nameUpper", "=", "name", ".", "toUpperCase", "(", ")", ";", "for", "(", "String", "pattern", ":", "patterns", ")", "{", "String", "patternUpper", "=", "pattern", ".", "toUpperCase", "(", ")", ";", "if", "(", "nameUpper", ".", "equals", "(", "patternUpper", ")", "||", "nameUpper", ".", "startsWith", "(", "patternUpper", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Does the given column name starts with one of pattern given in parameter Not case sensitive
[ "Does", "the", "given", "column", "name", "starts", "with", "one", "of", "pattern", "given", "in", "parameter", "Not", "case", "sensitive" ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/util/MiscUtil.java#L177-L187
4,168
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/util/MiscUtil.java
MiscUtil.contains
public static boolean contains(String name, Iterable<String> patterns) { String nameUpper = name.toUpperCase(); for (String pattern : patterns) { String patternUpper = pattern.toUpperCase(); if (nameUpper.equals(patternUpper) || nameUpper.contains(patternUpper)) { return true; } } return false; }
java
public static boolean contains(String name, Iterable<String> patterns) { String nameUpper = name.toUpperCase(); for (String pattern : patterns) { String patternUpper = pattern.toUpperCase(); if (nameUpper.equals(patternUpper) || nameUpper.contains(patternUpper)) { return true; } } return false; }
[ "public", "static", "boolean", "contains", "(", "String", "name", ",", "Iterable", "<", "String", ">", "patterns", ")", "{", "String", "nameUpper", "=", "name", ".", "toUpperCase", "(", ")", ";", "for", "(", "String", "pattern", ":", "patterns", ")", "{", "String", "patternUpper", "=", "pattern", ".", "toUpperCase", "(", ")", ";", "if", "(", "nameUpper", ".", "equals", "(", "patternUpper", ")", "||", "nameUpper", ".", "contains", "(", "patternUpper", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Does the given column name contains one of pattern given in parameter Not case sensitive
[ "Does", "the", "given", "column", "name", "contains", "one", "of", "pattern", "given", "in", "parameter", "Not", "case", "sensitive" ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/util/MiscUtil.java#L192-L202
4,169
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/util/MiscUtil.java
MiscUtil.equalsIgnoreCase
public static boolean equalsIgnoreCase(String name, Iterable<String> patterns) { for (String pattern : patterns) { if (name.equalsIgnoreCase(pattern)) { return true; } } return false; }
java
public static boolean equalsIgnoreCase(String name, Iterable<String> patterns) { for (String pattern : patterns) { if (name.equalsIgnoreCase(pattern)) { return true; } } return false; }
[ "public", "static", "boolean", "equalsIgnoreCase", "(", "String", "name", ",", "Iterable", "<", "String", ">", "patterns", ")", "{", "for", "(", "String", "pattern", ":", "patterns", ")", "{", "if", "(", "name", ".", "equalsIgnoreCase", "(", "pattern", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Does the given column name equals ignore case with one of pattern given in parameter @param name the column @param patterns table of patterns as strings @return true if the column name equals ignore case with one of the given patterns, false otherwise
[ "Does", "the", "given", "column", "name", "equals", "ignore", "case", "with", "one", "of", "pattern", "given", "in", "parameter" ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/util/MiscUtil.java#L211-L219
4,170
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/util/MiscUtil.java
MiscUtil.isUniCase
public static boolean isUniCase(String value) { if (value.toLowerCase().equals(value) || value.toUpperCase().equals(value)) { return true; } return false; }
java
public static boolean isUniCase(String value) { if (value.toLowerCase().equals(value) || value.toUpperCase().equals(value)) { return true; } return false; }
[ "public", "static", "boolean", "isUniCase", "(", "String", "value", ")", "{", "if", "(", "value", ".", "toLowerCase", "(", ")", ".", "equals", "(", "value", ")", "||", "value", ".", "toUpperCase", "(", ")", ".", "equals", "(", "value", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Return true if the passed value is all lower or all upper case.
[ "Return", "true", "if", "the", "passed", "value", "is", "all", "lower", "or", "all", "upper", "case", "." ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/util/MiscUtil.java#L224-L229
4,171
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/model/unique/CompositeUnique.java
CompositeUnique.getName
@Override public String getName() { if (name == null) { return null; } if (name.endsWith("_INDEX_2")) { return removeEnd(name, "_INDEX_2"); } return name; }
java
@Override public String getName() { if (name == null) { return null; } if (name.endsWith("_INDEX_2")) { return removeEnd(name, "_INDEX_2"); } return name; }
[ "@", "Override", "public", "String", "getName", "(", ")", "{", "if", "(", "name", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "name", ".", "endsWith", "(", "\"_INDEX_2\"", ")", ")", "{", "return", "removeEnd", "(", "name", ",", "\"_INDEX_2\"", ")", ";", "}", "return", "name", ";", "}" ]
H2 does append _INDEX_2 to unique constraints names
[ "H2", "does", "append", "_INDEX_2", "to", "unique", "constraints", "names" ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/model/unique/CompositeUnique.java#L63-L72
4,172
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/template/TemplateExecution.java
TemplateExecution.require
public void require(Namer packageNamer, Namer classNamer) { requireFirstTime(packageNamer.getPackageName() + "." + classNamer.getType()); }
java
public void require(Namer packageNamer, Namer classNamer) { requireFirstTime(packageNamer.getPackageName() + "." + classNamer.getType()); }
[ "public", "void", "require", "(", "Namer", "packageNamer", ",", "Namer", "classNamer", ")", "{", "requireFirstTime", "(", "packageNamer", ".", "getPackageName", "(", ")", "+", "\".\"", "+", "classNamer", ".", "getType", "(", ")", ")", ";", "}" ]
Import the passed classNamer's type present in the passed packageNamer's package name.
[ "Import", "the", "passed", "classNamer", "s", "type", "present", "in", "the", "passed", "packageNamer", "s", "package", "name", "." ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/template/TemplateExecution.java#L434-L436
4,173
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/template/TemplateExecution.java
TemplateExecution.requireFirstTime
public boolean requireFirstTime(Attribute attribute) { if (!attribute.isJavaBaseClass()) { return ImportsContext.getCurrentImportsHolder().add(attribute.getFullType()); } return false; }
java
public boolean requireFirstTime(Attribute attribute) { if (!attribute.isJavaBaseClass()) { return ImportsContext.getCurrentImportsHolder().add(attribute.getFullType()); } return false; }
[ "public", "boolean", "requireFirstTime", "(", "Attribute", "attribute", ")", "{", "if", "(", "!", "attribute", ".", "isJavaBaseClass", "(", ")", ")", "{", "return", "ImportsContext", ".", "getCurrentImportsHolder", "(", ")", ".", "add", "(", "attribute", ".", "getFullType", "(", ")", ")", ";", "}", "return", "false", ";", "}" ]
Import the passed attribute type. @return true if the passed attribute type is imported for the first time.
[ "Import", "the", "passed", "attribute", "type", "." ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/template/TemplateExecution.java#L489-L494
4,174
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/model/support/custom/CustomAttribute.java
CustomAttribute.getAnnotations
public List<String> getAnnotations() { if (attribute.getColumnConfig().getCustomAnnotations() == null) { return newArrayList(); } AnnotationBuilder builder = new AnnotationBuilder(); for (CustomAnnotation ca : attribute.getColumnConfig().getCustomAnnotations()) { addImport(ca.extractAnnotationImport()); builder.add(ca.getAnnotation()); } return builder.getAnnotations(); }
java
public List<String> getAnnotations() { if (attribute.getColumnConfig().getCustomAnnotations() == null) { return newArrayList(); } AnnotationBuilder builder = new AnnotationBuilder(); for (CustomAnnotation ca : attribute.getColumnConfig().getCustomAnnotations()) { addImport(ca.extractAnnotationImport()); builder.add(ca.getAnnotation()); } return builder.getAnnotations(); }
[ "public", "List", "<", "String", ">", "getAnnotations", "(", ")", "{", "if", "(", "attribute", ".", "getColumnConfig", "(", ")", ".", "getCustomAnnotations", "(", ")", "==", "null", ")", "{", "return", "newArrayList", "(", ")", ";", "}", "AnnotationBuilder", "builder", "=", "new", "AnnotationBuilder", "(", ")", ";", "for", "(", "CustomAnnotation", "ca", ":", "attribute", ".", "getColumnConfig", "(", ")", ".", "getCustomAnnotations", "(", ")", ")", "{", "addImport", "(", "ca", ".", "extractAnnotationImport", "(", ")", ")", ";", "builder", ".", "add", "(", "ca", ".", "getAnnotation", "(", ")", ")", ";", "}", "return", "builder", ".", "getAnnotations", "(", ")", ";", "}" ]
Return the custom annotations declared in the configuration.
[ "Return", "the", "custom", "annotations", "declared", "in", "the", "configuration", "." ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/model/support/custom/CustomAttribute.java#L44-L55
4,175
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/model/support/validation/ValidationRelation.java
ValidationRelation.getNotNullAnnotation
public String getNotNullAnnotation() { if (!relation.isManyToOne() && !relation.isOneToOne()) { return ""; } if (relation.isMandatory() && !relation.hasInverse()) { if (relation.getFromEntity().getName().equals(relation.getToEntity().getName())) { // TODO ?: mandatory relation on self is complicated to handled // in tests (model generator)... so we just ignore it. return ""; } if (relation.getFromAttribute().isInPk()) { // TODO: not sure why, but integration tests fail if we don't skip this case. return ""; } ImportsContext.addImport("javax.validation.constraints.NotNull"); return "@NotNull"; } else { return ""; } }
java
public String getNotNullAnnotation() { if (!relation.isManyToOne() && !relation.isOneToOne()) { return ""; } if (relation.isMandatory() && !relation.hasInverse()) { if (relation.getFromEntity().getName().equals(relation.getToEntity().getName())) { // TODO ?: mandatory relation on self is complicated to handled // in tests (model generator)... so we just ignore it. return ""; } if (relation.getFromAttribute().isInPk()) { // TODO: not sure why, but integration tests fail if we don't skip this case. return ""; } ImportsContext.addImport("javax.validation.constraints.NotNull"); return "@NotNull"; } else { return ""; } }
[ "public", "String", "getNotNullAnnotation", "(", ")", "{", "if", "(", "!", "relation", ".", "isManyToOne", "(", ")", "&&", "!", "relation", ".", "isOneToOne", "(", ")", ")", "{", "return", "\"\"", ";", "}", "if", "(", "relation", ".", "isMandatory", "(", ")", "&&", "!", "relation", ".", "hasInverse", "(", ")", ")", "{", "if", "(", "relation", ".", "getFromEntity", "(", ")", ".", "getName", "(", ")", ".", "equals", "(", "relation", ".", "getToEntity", "(", ")", ".", "getName", "(", ")", ")", ")", "{", "// TODO ?: mandatory relation on self is complicated to handled", "// in tests (model generator)... so we just ignore it.", "return", "\"\"", ";", "}", "if", "(", "relation", ".", "getFromAttribute", "(", ")", ".", "isInPk", "(", ")", ")", "{", "// TODO: not sure why, but integration tests fail if we don't skip this case.", "return", "\"\"", ";", "}", "ImportsContext", ".", "addImport", "(", "\"javax.validation.constraints.NotNull\"", ")", ";", "return", "\"@NotNull\"", ";", "}", "else", "{", "return", "\"\"", ";", "}", "}" ]
Applies only to ManyToOne or OneToOne. When x to one has an inverse relation, we never mark it as @NotNull as it would break navigation (indeed, the mandatory value is set transparently once the entity is added to the collection) However, in test (XxxGenerator), we must take mandatory into account...
[ "Applies", "only", "to", "ManyToOne", "or", "OneToOne", ".", "When", "x", "to", "one", "has", "an", "inverse", "relation", "we", "never", "mark", "it", "as" ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/model/support/validation/ValidationRelation.java#L69-L91
4,176
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/factory/RelationCollisionUtil.java
RelationCollisionUtil.removeVar
public void removeVar(String entityType, String attributeVar) { fullVars.remove(clashKey(entityType, attributeVar)); }
java
public void removeVar(String entityType, String attributeVar) { fullVars.remove(clashKey(entityType, attributeVar)); }
[ "public", "void", "removeVar", "(", "String", "entityType", ",", "String", "attributeVar", ")", "{", "fullVars", ".", "remove", "(", "clashKey", "(", "entityType", ",", "attributeVar", ")", ")", ";", "}" ]
During construction, we may free a var.
[ "During", "construction", "we", "may", "free", "a", "var", "." ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/factory/RelationCollisionUtil.java#L46-L48
4,177
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/factory/RelationCollisionUtil.java
RelationCollisionUtil.getManyToManyNamer
public Namer getManyToManyNamer(Namer fromEntityNamer, ColumnConfig pointsOnToEntity, Namer toEntityNamer) { // new configuration Namer result = getManyToManyNamerFromConf(pointsOnToEntity.getManyToManyConfig(), toEntityNamer); // fallback if (result == null) { result = getManyToManyNamerFallBack(fromEntityNamer, pointsOnToEntity, toEntityNamer); } return result; }
java
public Namer getManyToManyNamer(Namer fromEntityNamer, ColumnConfig pointsOnToEntity, Namer toEntityNamer) { // new configuration Namer result = getManyToManyNamerFromConf(pointsOnToEntity.getManyToManyConfig(), toEntityNamer); // fallback if (result == null) { result = getManyToManyNamerFallBack(fromEntityNamer, pointsOnToEntity, toEntityNamer); } return result; }
[ "public", "Namer", "getManyToManyNamer", "(", "Namer", "fromEntityNamer", ",", "ColumnConfig", "pointsOnToEntity", ",", "Namer", "toEntityNamer", ")", "{", "// new configuration", "Namer", "result", "=", "getManyToManyNamerFromConf", "(", "pointsOnToEntity", ".", "getManyToManyConfig", "(", ")", ",", "toEntityNamer", ")", ";", "// fallback", "if", "(", "result", "==", "null", ")", "{", "result", "=", "getManyToManyNamerFallBack", "(", "fromEntityNamer", ",", "pointsOnToEntity", ",", "toEntityNamer", ")", ";", "}", "return", "result", ";", "}" ]
Compute the appropriate namer for the Java field marked by @ManyToMany
[ "Compute", "the", "appropriate", "namer", "for", "the", "Java", "field", "marked", "by" ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/factory/RelationCollisionUtil.java#L89-L100
4,178
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/template/pack/LocalResourcePackFile.java
LocalResourcePackFile.getAsByteArray
private byte[] getAsByteArray(String template) throws IOException { if (isTemplateGivenAsAnAbsoluteFile(template)) { throw new IllegalArgumentException("Template " + template + " should not be given as an absolute file"); } if (!containsTemplate(template)) { throw new IllegalArgumentException("Template " + template + " is not a template"); } java.io.InputStream is = null; try { is = new FileInputStream(getAbsoluteTemplate(template)); return toByteArray(is); } finally { closeQuietly(is); } }
java
private byte[] getAsByteArray(String template) throws IOException { if (isTemplateGivenAsAnAbsoluteFile(template)) { throw new IllegalArgumentException("Template " + template + " should not be given as an absolute file"); } if (!containsTemplate(template)) { throw new IllegalArgumentException("Template " + template + " is not a template"); } java.io.InputStream is = null; try { is = new FileInputStream(getAbsoluteTemplate(template)); return toByteArray(is); } finally { closeQuietly(is); } }
[ "private", "byte", "[", "]", "getAsByteArray", "(", "String", "template", ")", "throws", "IOException", "{", "if", "(", "isTemplateGivenAsAnAbsoluteFile", "(", "template", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Template \"", "+", "template", "+", "\" should not be given as an absolute file\"", ")", ";", "}", "if", "(", "!", "containsTemplate", "(", "template", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Template \"", "+", "template", "+", "\" is not a template\"", ")", ";", "}", "java", ".", "io", ".", "InputStream", "is", "=", "null", ";", "try", "{", "is", "=", "new", "FileInputStream", "(", "getAbsoluteTemplate", "(", "template", ")", ")", ";", "return", "toByteArray", "(", "is", ")", ";", "}", "finally", "{", "closeQuietly", "(", "is", ")", ";", "}", "}" ]
Extract a template from the jar as a byte array
[ "Extract", "a", "template", "from", "the", "jar", "as", "a", "byte", "array" ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/template/pack/LocalResourcePackFile.java#L96-L110
4,179
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/model/support/jpa/JpaManyToManyRelation.java
JpaManyToManyRelation.getSpecificJoinFetchAnnotation
private String getSpecificJoinFetchAnnotation() { List<Relation> manyToManyRelations = relation.getToEntity().getManyToMany().getList(); // we have only on many-to-many ? No problem, move on if (manyToManyRelations.size() <= 1) { return null; } // we have many many to many relations ? and one requires eager, then we need to set the fetchmode for (Relation relation : manyToManyRelations) { if (relation.getFetchTypeGetter() != null && relation.getFetchTypeGetter().getFetch() != null && relation.getFetchTypeGetter().getFetch().isEager()) { addImport("org.hibernate.annotations.Fetch"); addImport("org.hibernate.annotations.FetchMode"); return "@Fetch(value = FetchMode.SUBSELECT)"; } } // no eager requested, move on return null; }
java
private String getSpecificJoinFetchAnnotation() { List<Relation> manyToManyRelations = relation.getToEntity().getManyToMany().getList(); // we have only on many-to-many ? No problem, move on if (manyToManyRelations.size() <= 1) { return null; } // we have many many to many relations ? and one requires eager, then we need to set the fetchmode for (Relation relation : manyToManyRelations) { if (relation.getFetchTypeGetter() != null && relation.getFetchTypeGetter().getFetch() != null && relation.getFetchTypeGetter().getFetch().isEager()) { addImport("org.hibernate.annotations.Fetch"); addImport("org.hibernate.annotations.FetchMode"); return "@Fetch(value = FetchMode.SUBSELECT)"; } } // no eager requested, move on return null; }
[ "private", "String", "getSpecificJoinFetchAnnotation", "(", ")", "{", "List", "<", "Relation", ">", "manyToManyRelations", "=", "relation", ".", "getToEntity", "(", ")", ".", "getManyToMany", "(", ")", ".", "getList", "(", ")", ";", "// we have only on many-to-many ? No problem, move on", "if", "(", "manyToManyRelations", ".", "size", "(", ")", "<=", "1", ")", "{", "return", "null", ";", "}", "// we have many many to many relations ? and one requires eager, then we need to set the fetchmode", "for", "(", "Relation", "relation", ":", "manyToManyRelations", ")", "{", "if", "(", "relation", ".", "getFetchTypeGetter", "(", ")", "!=", "null", "&&", "relation", ".", "getFetchTypeGetter", "(", ")", ".", "getFetch", "(", ")", "!=", "null", "&&", "relation", ".", "getFetchTypeGetter", "(", ")", ".", "getFetch", "(", ")", ".", "isEager", "(", ")", ")", "{", "addImport", "(", "\"org.hibernate.annotations.Fetch\"", ")", ";", "addImport", "(", "\"org.hibernate.annotations.FetchMode\"", ")", ";", "return", "\"@Fetch(value = FetchMode.SUBSELECT)\"", ";", "}", "}", "// no eager requested, move on", "return", "null", ";", "}" ]
When you have multiple eager bags you need to specify how you want to make them eager.
[ "When", "you", "have", "multiple", "eager", "bags", "you", "need", "to", "specify", "how", "you", "want", "to", "make", "them", "eager", "." ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/model/support/jpa/JpaManyToManyRelation.java#L138-L154
4,180
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/model/Project.java
Project.putEntity
public void putEntity(Entity entity) { Assert.isTrue(entity.hasTableName(), "Expecting a table name for the entity: " + entity.getName()); Assert.isTrue(!hasEntityBySchemaAndTableName(entity.getTable().getSchemaName(), entity.getTable().getName()), "Entity was already added!: " + entity.getTableName()); currentEntitiesByTableName.put(entity.getTable().getName().toUpperCase(), entity); currentEntitiesBySchemaAndTableName.put(entity.getTable().asKeyForMap(), entity); }
java
public void putEntity(Entity entity) { Assert.isTrue(entity.hasTableName(), "Expecting a table name for the entity: " + entity.getName()); Assert.isTrue(!hasEntityBySchemaAndTableName(entity.getTable().getSchemaName(), entity.getTable().getName()), "Entity was already added!: " + entity.getTableName()); currentEntitiesByTableName.put(entity.getTable().getName().toUpperCase(), entity); currentEntitiesBySchemaAndTableName.put(entity.getTable().asKeyForMap(), entity); }
[ "public", "void", "putEntity", "(", "Entity", "entity", ")", "{", "Assert", ".", "isTrue", "(", "entity", ".", "hasTableName", "(", ")", ",", "\"Expecting a table name for the entity: \"", "+", "entity", ".", "getName", "(", ")", ")", ";", "Assert", ".", "isTrue", "(", "!", "hasEntityBySchemaAndTableName", "(", "entity", ".", "getTable", "(", ")", ".", "getSchemaName", "(", ")", ",", "entity", ".", "getTable", "(", ")", ".", "getName", "(", ")", ")", ",", "\"Entity was already added!: \"", "+", "entity", ".", "getTableName", "(", ")", ")", ";", "currentEntitiesByTableName", ".", "put", "(", "entity", ".", "getTable", "(", ")", ".", "getName", "(", ")", ".", "toUpperCase", "(", ")", ",", "entity", ")", ";", "currentEntitiesBySchemaAndTableName", ".", "put", "(", "entity", ".", "getTable", "(", ")", ".", "asKeyForMap", "(", ")", ",", "entity", ")", ";", "}" ]
Store 1 entity per table name. In case of inheritance you must pass the root entity only.
[ "Store", "1", "entity", "per", "table", "name", ".", "In", "case", "of", "inheritance", "you", "must", "pass", "the", "root", "entity", "only", "." ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/model/Project.java#L130-L135
4,181
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/model/Project.java
Project.getEntityBySchemaAndTableName
public Entity getEntityBySchemaAndTableName(String schemaName, String tableName) { return currentEntitiesBySchemaAndTableName.get(Table.keyForMap(schemaName, tableName)); }
java
public Entity getEntityBySchemaAndTableName(String schemaName, String tableName) { return currentEntitiesBySchemaAndTableName.get(Table.keyForMap(schemaName, tableName)); }
[ "public", "Entity", "getEntityBySchemaAndTableName", "(", "String", "schemaName", ",", "String", "tableName", ")", "{", "return", "currentEntitiesBySchemaAndTableName", ".", "get", "(", "Table", ".", "keyForMap", "(", "schemaName", ",", "tableName", ")", ")", ";", "}" ]
Return the entity corresponding to the passed table. In case of inheritance, the root entity is returned.
[ "Return", "the", "entity", "corresponding", "to", "the", "passed", "table", ".", "In", "case", "of", "inheritance", "the", "root", "entity", "is", "returned", "." ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/model/Project.java#L151-L153
4,182
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/ConfigurationCheck.java
ConfigurationCheck.checkForeignKeyMapping
private void checkForeignKeyMapping(List<String> errors, Config config) { for (Entity entity : config.getProject().getEntities().getList()) { for (Relation relation : entity.getRelations().getList()) { if (relation.isInverse() || relation.isIntermediate()) { continue; } for (AttributePair attributePair : relation.getAttributePairs()) { if (attributePair.getFromAttribute().getMappedType() != attributePair.getToAttribute().getMappedType()) { String errorMsg = "Inconsistent types: Column " + attributePair.getFromAttribute().getFullColumnName() + "[" + attributePair.getFromAttribute().getJdbcType() + "] references column " + attributePair.getToAttribute().getFullColumnName() + "[" + attributePair.getToAttribute().getJdbcType() + "]. " + "You should really fix your SQL schema."; if (attributePair.getFromAttribute().isInCpk()) { // we may get compile failure as the property is mapped (inside the cpk) log.warn(errorMsg + ". To avoid this error you can force the mapped type using configuration."); } else { // we should not get compile failure as the property is not mapped. log.warn(errorMsg); } } } } } }
java
private void checkForeignKeyMapping(List<String> errors, Config config) { for (Entity entity : config.getProject().getEntities().getList()) { for (Relation relation : entity.getRelations().getList()) { if (relation.isInverse() || relation.isIntermediate()) { continue; } for (AttributePair attributePair : relation.getAttributePairs()) { if (attributePair.getFromAttribute().getMappedType() != attributePair.getToAttribute().getMappedType()) { String errorMsg = "Inconsistent types: Column " + attributePair.getFromAttribute().getFullColumnName() + "[" + attributePair.getFromAttribute().getJdbcType() + "] references column " + attributePair.getToAttribute().getFullColumnName() + "[" + attributePair.getToAttribute().getJdbcType() + "]. " + "You should really fix your SQL schema."; if (attributePair.getFromAttribute().isInCpk()) { // we may get compile failure as the property is mapped (inside the cpk) log.warn(errorMsg + ". To avoid this error you can force the mapped type using configuration."); } else { // we should not get compile failure as the property is not mapped. log.warn(errorMsg); } } } } } }
[ "private", "void", "checkForeignKeyMapping", "(", "List", "<", "String", ">", "errors", ",", "Config", "config", ")", "{", "for", "(", "Entity", "entity", ":", "config", ".", "getProject", "(", ")", ".", "getEntities", "(", ")", ".", "getList", "(", ")", ")", "{", "for", "(", "Relation", "relation", ":", "entity", ".", "getRelations", "(", ")", ".", "getList", "(", ")", ")", "{", "if", "(", "relation", ".", "isInverse", "(", ")", "||", "relation", ".", "isIntermediate", "(", ")", ")", "{", "continue", ";", "}", "for", "(", "AttributePair", "attributePair", ":", "relation", ".", "getAttributePairs", "(", ")", ")", "{", "if", "(", "attributePair", ".", "getFromAttribute", "(", ")", ".", "getMappedType", "(", ")", "!=", "attributePair", ".", "getToAttribute", "(", ")", ".", "getMappedType", "(", ")", ")", "{", "String", "errorMsg", "=", "\"Inconsistent types: Column \"", "+", "attributePair", ".", "getFromAttribute", "(", ")", ".", "getFullColumnName", "(", ")", "+", "\"[\"", "+", "attributePair", ".", "getFromAttribute", "(", ")", ".", "getJdbcType", "(", ")", "+", "\"] references column \"", "+", "attributePair", ".", "getToAttribute", "(", ")", ".", "getFullColumnName", "(", ")", "+", "\"[\"", "+", "attributePair", ".", "getToAttribute", "(", ")", ".", "getJdbcType", "(", ")", "+", "\"]. \"", "+", "\"You should really fix your SQL schema.\"", ";", "if", "(", "attributePair", ".", "getFromAttribute", "(", ")", ".", "isInCpk", "(", ")", ")", "{", "// we may get compile failure as the property is mapped (inside the cpk)", "log", ".", "warn", "(", "errorMsg", "+", "\". To avoid this error you can force the mapped type using configuration.\"", ")", ";", "}", "else", "{", "// we should not get compile failure as the property is not mapped.", "log", ".", "warn", "(", "errorMsg", ")", ";", "}", "}", "}", "}", "}", "}" ]
Check that foreign keys have the same mapped type as the target.
[ "Check", "that", "foreign", "keys", "have", "the", "same", "mapped", "type", "as", "the", "target", "." ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/ConfigurationCheck.java#L91-L114
4,183
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/ConfigurationCheck.java
ConfigurationCheck.checkVersionOnJoinedInheritance
private void checkVersionOnJoinedInheritance(List<String> errors, Config config) { for (Entity entity : config.getProject().getRootEntities().getList()) { if (entity.hasInheritance() && entity.getInheritance().is(JOINED)) { for (Entity child : entity.getAllChildrenRecursive()) { for (Attribute attribute : child.getAttributes().getList()) { if (attribute.isVersion()) { errors.add(attribute.getFullColumnName() + " is a version column, you should not have @Version in a child joined entity." + " Use ignore=true in columnConfig or remove it from your table."); } } } } } }
java
private void checkVersionOnJoinedInheritance(List<String> errors, Config config) { for (Entity entity : config.getProject().getRootEntities().getList()) { if (entity.hasInheritance() && entity.getInheritance().is(JOINED)) { for (Entity child : entity.getAllChildrenRecursive()) { for (Attribute attribute : child.getAttributes().getList()) { if (attribute.isVersion()) { errors.add(attribute.getFullColumnName() + " is a version column, you should not have @Version in a child joined entity." + " Use ignore=true in columnConfig or remove it from your table."); } } } } } }
[ "private", "void", "checkVersionOnJoinedInheritance", "(", "List", "<", "String", ">", "errors", ",", "Config", "config", ")", "{", "for", "(", "Entity", "entity", ":", "config", ".", "getProject", "(", ")", ".", "getRootEntities", "(", ")", ".", "getList", "(", ")", ")", "{", "if", "(", "entity", ".", "hasInheritance", "(", ")", "&&", "entity", ".", "getInheritance", "(", ")", ".", "is", "(", "JOINED", ")", ")", "{", "for", "(", "Entity", "child", ":", "entity", ".", "getAllChildrenRecursive", "(", ")", ")", "{", "for", "(", "Attribute", "attribute", ":", "child", ".", "getAttributes", "(", ")", ".", "getList", "(", ")", ")", "{", "if", "(", "attribute", ".", "isVersion", "(", ")", ")", "{", "errors", ".", "add", "(", "attribute", ".", "getFullColumnName", "(", ")", "+", "\" is a version column, you should not have @Version in a child joined entity.\"", "+", "\" Use ignore=true in columnConfig or remove it from your table.\"", ")", ";", "}", "}", "}", "}", "}", "}" ]
In case of JOINED inheritance we may have added some columns that are in the table but that are not in the entityConfigs. We check here that we have not added a version column in a child. @param errors @param config
[ "In", "case", "of", "JOINED", "inheritance", "we", "may", "have", "added", "some", "columns", "that", "are", "in", "the", "table", "but", "that", "are", "not", "in", "the", "entityConfigs", ".", "We", "check", "here", "that", "we", "have", "not", "added", "a", "version", "column", "in", "a", "child", "." ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/ConfigurationCheck.java#L123-L136
4,184
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/model/support/search/SearchAttribute.java
SearchAttribute.getAnnotations
public List<String> getAnnotations() { AnnotationBuilder annotations = new AnnotationBuilder(); annotations.add( // getFieldAnnotation(), // getFieldBridgeAnnotation(), // getTikaBridgeAnnotation()); return annotations.getAnnotations(); }
java
public List<String> getAnnotations() { AnnotationBuilder annotations = new AnnotationBuilder(); annotations.add( // getFieldAnnotation(), // getFieldBridgeAnnotation(), // getTikaBridgeAnnotation()); return annotations.getAnnotations(); }
[ "public", "List", "<", "String", ">", "getAnnotations", "(", ")", "{", "AnnotationBuilder", "annotations", "=", "new", "AnnotationBuilder", "(", ")", ";", "annotations", ".", "add", "(", "//", "getFieldAnnotation", "(", ")", ",", "//", "getFieldBridgeAnnotation", "(", ")", ",", "//", "getTikaBridgeAnnotation", "(", ")", ")", ";", "return", "annotations", ".", "getAnnotations", "(", ")", ";", "}" ]
Returns all the search annotations for the attribute. Imports are processed automatically.
[ "Returns", "all", "the", "search", "annotations", "for", "the", "attribute", ".", "Imports", "are", "processed", "automatically", "." ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/model/support/search/SearchAttribute.java#L57-L64
4,185
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/model/Entity.java
Entity.generateIdentifiableMethods
public boolean generateIdentifiableMethods() { Assert.isTrue(isRoot(), "generateIdentifiableMethods() can be invoked only on root entity. Please fix your template."); if (hasSimplePk() || hasCompositePk()) { String identifiableProperty = config.getCelerio().getConfiguration().getConventions().getIdentifiableProperty(); // keep it with equalsIgnoreCase as people tends to use 'Id' return !getPrimaryKey().getVar().equalsIgnoreCase(identifiableProperty); } return true; }
java
public boolean generateIdentifiableMethods() { Assert.isTrue(isRoot(), "generateIdentifiableMethods() can be invoked only on root entity. Please fix your template."); if (hasSimplePk() || hasCompositePk()) { String identifiableProperty = config.getCelerio().getConfiguration().getConventions().getIdentifiableProperty(); // keep it with equalsIgnoreCase as people tends to use 'Id' return !getPrimaryKey().getVar().equalsIgnoreCase(identifiableProperty); } return true; }
[ "public", "boolean", "generateIdentifiableMethods", "(", ")", "{", "Assert", ".", "isTrue", "(", "isRoot", "(", ")", ",", "\"generateIdentifiableMethods() can be invoked only on root entity. Please fix your template.\"", ")", ";", "if", "(", "hasSimplePk", "(", ")", "||", "hasCompositePk", "(", ")", ")", "{", "String", "identifiableProperty", "=", "config", ".", "getCelerio", "(", ")", ".", "getConfiguration", "(", ")", ".", "getConventions", "(", ")", ".", "getIdentifiableProperty", "(", ")", ";", "// keep it with equalsIgnoreCase as people tends to use 'Id'", "return", "!", "getPrimaryKey", "(", ")", ".", "getVar", "(", ")", ".", "equalsIgnoreCase", "(", "identifiableProperty", ")", ";", "}", "return", "true", ";", "}" ]
Tells whether we should generate identifiable methods. We do not need to generate them in the case where the identifiable property matches exactly the entity's PK field.
[ "Tells", "whether", "we", "should", "generate", "identifiable", "methods", ".", "We", "do", "not", "need", "to", "generate", "them", "in", "the", "case", "where", "the", "identifiable", "property", "matches", "exactly", "the", "entity", "s", "PK", "field", "." ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/model/Entity.java#L697-L707
4,186
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/model/Entity.java
Entity.getAttributeBundles
public List<AttributeBundle> getAttributeBundles() { if (attributeBundles != null) { return attributeBundles; } Map<String, AttributeBundle> bundlesMap = newHashMap(); for (Attribute attribute : getAttributes().getList()) { if (attribute.columnNameHasLanguageSuffix()) { String base = attribute.getColumnNameWithoutLanguage(); AttributeBundle bundle = bundlesMap.get(base); if (bundle == null) { bundle = new AttributeBundle(attribute); // add first attribute bundlesMap.put(base, bundle); } else { bundle.addAttribute(attribute); } } } // keep bundles with more than 1 attribute attributeBundles = newArrayList(); for (AttributeBundle bundle : bundlesMap.values()) { if (bundle.getAttributes().size() > 1) { attributeBundles.add(bundle); log.info("Found columns satisfying localization pattern: " + bundle.toString()); } } return attributeBundles; }
java
public List<AttributeBundle> getAttributeBundles() { if (attributeBundles != null) { return attributeBundles; } Map<String, AttributeBundle> bundlesMap = newHashMap(); for (Attribute attribute : getAttributes().getList()) { if (attribute.columnNameHasLanguageSuffix()) { String base = attribute.getColumnNameWithoutLanguage(); AttributeBundle bundle = bundlesMap.get(base); if (bundle == null) { bundle = new AttributeBundle(attribute); // add first attribute bundlesMap.put(base, bundle); } else { bundle.addAttribute(attribute); } } } // keep bundles with more than 1 attribute attributeBundles = newArrayList(); for (AttributeBundle bundle : bundlesMap.values()) { if (bundle.getAttributes().size() > 1) { attributeBundles.add(bundle); log.info("Found columns satisfying localization pattern: " + bundle.toString()); } } return attributeBundles; }
[ "public", "List", "<", "AttributeBundle", ">", "getAttributeBundles", "(", ")", "{", "if", "(", "attributeBundles", "!=", "null", ")", "{", "return", "attributeBundles", ";", "}", "Map", "<", "String", ",", "AttributeBundle", ">", "bundlesMap", "=", "newHashMap", "(", ")", ";", "for", "(", "Attribute", "attribute", ":", "getAttributes", "(", ")", ".", "getList", "(", ")", ")", "{", "if", "(", "attribute", ".", "columnNameHasLanguageSuffix", "(", ")", ")", "{", "String", "base", "=", "attribute", ".", "getColumnNameWithoutLanguage", "(", ")", ";", "AttributeBundle", "bundle", "=", "bundlesMap", ".", "get", "(", "base", ")", ";", "if", "(", "bundle", "==", "null", ")", "{", "bundle", "=", "new", "AttributeBundle", "(", "attribute", ")", ";", "// add first attribute", "bundlesMap", ".", "put", "(", "base", ",", "bundle", ")", ";", "}", "else", "{", "bundle", ".", "addAttribute", "(", "attribute", ")", ";", "}", "}", "}", "// keep bundles with more than 1 attribute", "attributeBundles", "=", "newArrayList", "(", ")", ";", "for", "(", "AttributeBundle", "bundle", ":", "bundlesMap", ".", "values", "(", ")", ")", "{", "if", "(", "bundle", ".", "getAttributes", "(", ")", ".", "size", "(", ")", ">", "1", ")", "{", "attributeBundles", ".", "add", "(", "bundle", ")", ";", "log", ".", "info", "(", "\"Found columns satisfying localization pattern: \"", "+", "bundle", ".", "toString", "(", ")", ")", ";", "}", "}", "return", "attributeBundles", ";", "}" ]
we should also check on types.
[ "we", "should", "also", "check", "on", "types", "." ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/model/Entity.java#L718-L748
4,187
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/factory/conventions/AccountConvention.java
AccountConvention.setupAccount
public boolean setupAccount(Entity e) { AccountAttributes accountAttributes = new AccountAttributes(); // 0- reject entity having a composite PK. if (e.hasCompositePk()) { return false; } // 1- detect mandatory username for (Attribute a : e.getAttributes().getList()) { if (a.isString() && match(a.getVar(), usernameCandidates) && a.isUnique()) { accountAttributes.setUsername(a); log.debug("'Username' candidate: " + a.getVar() + " found on " + e.getName()); break; } } if (!accountAttributes.isUsernameSet()) { return false; } // 2- detect mandatory password for (Attribute a : e.getAttributes().getList()) { if (a.isString() && match(a.getVar(), passwordCandidates)) { accountAttributes.setPassword(a); log.debug("'Password' candidate: " + a.getVar() + " found on " + e.getName()); break; } } if (!accountAttributes.isPasswordSet()) { return false; } // from here we have at least an account. e.setAccountAttributes(accountAttributes); // 3- detect optional email for (Attribute a : e.getAttributes().getList()) { if (a.isString() && match(a.getVar(), emailCandidates)) { accountAttributes.setEmail(a); log.debug("'Email' candidate: " + a.getVar() + " found on " + e.getName()); break; } } // 4- detect optional enabled for (Attribute a : e.getAttributes().getList()) { if (a.isBoolean() && match(a.getVar(), enabledCandidates)) { accountAttributes.setEnabled(a); log.debug("'Enabled' candidate: " + a.getVar() + " found on " + e.getName()); break; } } // 5- detect Role relation for (Relation relation : e.getXToMany().getList()) { RoleAttributes roleAttributes = getRoleEntity(relation.getToEntity()); if (roleAttributes != null) { relation.getToEntity().setRoleAttributes(roleAttributes); accountAttributes.setRoleRelation(relation); log.debug("'Role' relation detected: " + relation.toString()); break; } } return true; }
java
public boolean setupAccount(Entity e) { AccountAttributes accountAttributes = new AccountAttributes(); // 0- reject entity having a composite PK. if (e.hasCompositePk()) { return false; } // 1- detect mandatory username for (Attribute a : e.getAttributes().getList()) { if (a.isString() && match(a.getVar(), usernameCandidates) && a.isUnique()) { accountAttributes.setUsername(a); log.debug("'Username' candidate: " + a.getVar() + " found on " + e.getName()); break; } } if (!accountAttributes.isUsernameSet()) { return false; } // 2- detect mandatory password for (Attribute a : e.getAttributes().getList()) { if (a.isString() && match(a.getVar(), passwordCandidates)) { accountAttributes.setPassword(a); log.debug("'Password' candidate: " + a.getVar() + " found on " + e.getName()); break; } } if (!accountAttributes.isPasswordSet()) { return false; } // from here we have at least an account. e.setAccountAttributes(accountAttributes); // 3- detect optional email for (Attribute a : e.getAttributes().getList()) { if (a.isString() && match(a.getVar(), emailCandidates)) { accountAttributes.setEmail(a); log.debug("'Email' candidate: " + a.getVar() + " found on " + e.getName()); break; } } // 4- detect optional enabled for (Attribute a : e.getAttributes().getList()) { if (a.isBoolean() && match(a.getVar(), enabledCandidates)) { accountAttributes.setEnabled(a); log.debug("'Enabled' candidate: " + a.getVar() + " found on " + e.getName()); break; } } // 5- detect Role relation for (Relation relation : e.getXToMany().getList()) { RoleAttributes roleAttributes = getRoleEntity(relation.getToEntity()); if (roleAttributes != null) { relation.getToEntity().setRoleAttributes(roleAttributes); accountAttributes.setRoleRelation(relation); log.debug("'Role' relation detected: " + relation.toString()); break; } } return true; }
[ "public", "boolean", "setupAccount", "(", "Entity", "e", ")", "{", "AccountAttributes", "accountAttributes", "=", "new", "AccountAttributes", "(", ")", ";", "// 0- reject entity having a composite PK.", "if", "(", "e", ".", "hasCompositePk", "(", ")", ")", "{", "return", "false", ";", "}", "// 1- detect mandatory username", "for", "(", "Attribute", "a", ":", "e", ".", "getAttributes", "(", ")", ".", "getList", "(", ")", ")", "{", "if", "(", "a", ".", "isString", "(", ")", "&&", "match", "(", "a", ".", "getVar", "(", ")", ",", "usernameCandidates", ")", "&&", "a", ".", "isUnique", "(", ")", ")", "{", "accountAttributes", ".", "setUsername", "(", "a", ")", ";", "log", ".", "debug", "(", "\"'Username' candidate: \"", "+", "a", ".", "getVar", "(", ")", "+", "\" found on \"", "+", "e", ".", "getName", "(", ")", ")", ";", "break", ";", "}", "}", "if", "(", "!", "accountAttributes", ".", "isUsernameSet", "(", ")", ")", "{", "return", "false", ";", "}", "// 2- detect mandatory password", "for", "(", "Attribute", "a", ":", "e", ".", "getAttributes", "(", ")", ".", "getList", "(", ")", ")", "{", "if", "(", "a", ".", "isString", "(", ")", "&&", "match", "(", "a", ".", "getVar", "(", ")", ",", "passwordCandidates", ")", ")", "{", "accountAttributes", ".", "setPassword", "(", "a", ")", ";", "log", ".", "debug", "(", "\"'Password' candidate: \"", "+", "a", ".", "getVar", "(", ")", "+", "\" found on \"", "+", "e", ".", "getName", "(", ")", ")", ";", "break", ";", "}", "}", "if", "(", "!", "accountAttributes", ".", "isPasswordSet", "(", ")", ")", "{", "return", "false", ";", "}", "// from here we have at least an account.", "e", ".", "setAccountAttributes", "(", "accountAttributes", ")", ";", "// 3- detect optional email", "for", "(", "Attribute", "a", ":", "e", ".", "getAttributes", "(", ")", ".", "getList", "(", ")", ")", "{", "if", "(", "a", ".", "isString", "(", ")", "&&", "match", "(", "a", ".", "getVar", "(", ")", ",", "emailCandidates", ")", ")", "{", "accountAttributes", ".", "setEmail", "(", "a", ")", ";", "log", ".", "debug", "(", "\"'Email' candidate: \"", "+", "a", ".", "getVar", "(", ")", "+", "\" found on \"", "+", "e", ".", "getName", "(", ")", ")", ";", "break", ";", "}", "}", "// 4- detect optional enabled", "for", "(", "Attribute", "a", ":", "e", ".", "getAttributes", "(", ")", ".", "getList", "(", ")", ")", "{", "if", "(", "a", ".", "isBoolean", "(", ")", "&&", "match", "(", "a", ".", "getVar", "(", ")", ",", "enabledCandidates", ")", ")", "{", "accountAttributes", ".", "setEnabled", "(", "a", ")", ";", "log", ".", "debug", "(", "\"'Enabled' candidate: \"", "+", "a", ".", "getVar", "(", ")", "+", "\" found on \"", "+", "e", ".", "getName", "(", ")", ")", ";", "break", ";", "}", "}", "// 5- detect Role relation", "for", "(", "Relation", "relation", ":", "e", ".", "getXToMany", "(", ")", ".", "getList", "(", ")", ")", "{", "RoleAttributes", "roleAttributes", "=", "getRoleEntity", "(", "relation", ".", "getToEntity", "(", ")", ")", ";", "if", "(", "roleAttributes", "!=", "null", ")", "{", "relation", ".", "getToEntity", "(", ")", ".", "setRoleAttributes", "(", "roleAttributes", ")", ";", "accountAttributes", ".", "setRoleRelation", "(", "relation", ")", ";", "log", ".", "debug", "(", "\"'Role' relation detected: \"", "+", "relation", ".", "toString", "(", ")", ")", ";", "break", ";", "}", "}", "return", "true", ";", "}" ]
Is this entity the 'account' entity?
[ "Is", "this", "entity", "the", "account", "entity?" ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/factory/conventions/AccountConvention.java#L42-L110
4,188
jaxio/celerio
celerio-engine/src/main/java/com/jaxio/celerio/model/Attribute.java
Attribute.isMultiSelectable
public boolean isMultiSelectable() { return ((!isInPk() && !isInFk() && !isVersion()) || (isSimplePk() && jpa.isManuallyAssigned())) // && (isBoolean() || isEnum() || isString() || isNumeric()); }
java
public boolean isMultiSelectable() { return ((!isInPk() && !isInFk() && !isVersion()) || (isSimplePk() && jpa.isManuallyAssigned())) // && (isBoolean() || isEnum() || isString() || isNumeric()); }
[ "public", "boolean", "isMultiSelectable", "(", ")", "{", "return", "(", "(", "!", "isInPk", "(", ")", "&&", "!", "isInFk", "(", ")", "&&", "!", "isVersion", "(", ")", ")", "||", "(", "isSimplePk", "(", ")", "&&", "jpa", ".", "isManuallyAssigned", "(", ")", ")", ")", "//", "&&", "(", "isBoolean", "(", ")", "||", "isEnum", "(", ")", "||", "isString", "(", ")", "||", "isNumeric", "(", ")", ")", ";", "}" ]
Can we apply a search with a PropertySelector on this attribute?
[ "Can", "we", "apply", "a", "search", "with", "a", "PropertySelector", "on", "this", "attribute?" ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/model/Attribute.java#L782-L785
4,189
jaxio/celerio
celerio-maven/bootstrap-maven-plugin/src/main/java/com/jaxio/celerio/maven/plugin/bootstrap/BootstrapMojo.java
BootstrapMojo.execute
@Override public void execute() throws MojoExecutionException { try { if (getBootstrapPacksInfo().isEmpty()) { getLog().error("Could not find any Celerio Template Pack having a META-INF/celerio.txt file on the classpath!"); return; } celerioWelcomeBanner(); JdbcConnectivity jdbcConnectivity = null; if (useCommandLineParameters()) { jdbcConnectivity = setUpParamValuesAndReturnJdbcConnectivity(); TemplatePackInfo tpi = getBootstrapPackInfoByName(bootstrapPackName); packCommand = tpi.getCommand(); packCommandHelp = tpi.getCommandHelp(); } else { if (isInteractive()) { startInteractiveConfWizard(); } else { useDefaultConf(); } } runCelerioInBootstrapMode(jdbcConnectivity); copySqlConf(); copyCelerioXsd(); printInstructionsOnceBootstrapIsReady(); } catch (Exception e) { getLog().error(e.getMessage()); throw new MojoExecutionException(e.getLocalizedMessage(), e); } }
java
@Override public void execute() throws MojoExecutionException { try { if (getBootstrapPacksInfo().isEmpty()) { getLog().error("Could not find any Celerio Template Pack having a META-INF/celerio.txt file on the classpath!"); return; } celerioWelcomeBanner(); JdbcConnectivity jdbcConnectivity = null; if (useCommandLineParameters()) { jdbcConnectivity = setUpParamValuesAndReturnJdbcConnectivity(); TemplatePackInfo tpi = getBootstrapPackInfoByName(bootstrapPackName); packCommand = tpi.getCommand(); packCommandHelp = tpi.getCommandHelp(); } else { if (isInteractive()) { startInteractiveConfWizard(); } else { useDefaultConf(); } } runCelerioInBootstrapMode(jdbcConnectivity); copySqlConf(); copyCelerioXsd(); printInstructionsOnceBootstrapIsReady(); } catch (Exception e) { getLog().error(e.getMessage()); throw new MojoExecutionException(e.getLocalizedMessage(), e); } }
[ "@", "Override", "public", "void", "execute", "(", ")", "throws", "MojoExecutionException", "{", "try", "{", "if", "(", "getBootstrapPacksInfo", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "getLog", "(", ")", ".", "error", "(", "\"Could not find any Celerio Template Pack having a META-INF/celerio.txt file on the classpath!\"", ")", ";", "return", ";", "}", "celerioWelcomeBanner", "(", ")", ";", "JdbcConnectivity", "jdbcConnectivity", "=", "null", ";", "if", "(", "useCommandLineParameters", "(", ")", ")", "{", "jdbcConnectivity", "=", "setUpParamValuesAndReturnJdbcConnectivity", "(", ")", ";", "TemplatePackInfo", "tpi", "=", "getBootstrapPackInfoByName", "(", "bootstrapPackName", ")", ";", "packCommand", "=", "tpi", ".", "getCommand", "(", ")", ";", "packCommandHelp", "=", "tpi", ".", "getCommandHelp", "(", ")", ";", "}", "else", "{", "if", "(", "isInteractive", "(", ")", ")", "{", "startInteractiveConfWizard", "(", ")", ";", "}", "else", "{", "useDefaultConf", "(", ")", ";", "}", "}", "runCelerioInBootstrapMode", "(", "jdbcConnectivity", ")", ";", "copySqlConf", "(", ")", ";", "copyCelerioXsd", "(", ")", ";", "printInstructionsOnceBootstrapIsReady", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "getLog", "(", ")", ".", "error", "(", "e", ".", "getMessage", "(", ")", ")", ";", "throw", "new", "MojoExecutionException", "(", "e", ".", "getLocalizedMessage", "(", ")", ",", "e", ")", ";", "}", "}" ]
Mojo entry point.
[ "Mojo", "entry", "point", "." ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-maven/bootstrap-maven-plugin/src/main/java/com/jaxio/celerio/maven/plugin/bootstrap/BootstrapMojo.java#L160-L198
4,190
jaxio/celerio
celerio-maven/bootstrap-maven-plugin/src/main/java/com/jaxio/celerio/maven/plugin/bootstrap/BootstrapMojo.java
BootstrapMojo.startInteractiveConfWizard
private void startInteractiveConfWizard() throws IOException { BufferedReader br = null; try { br = new BufferedReader(new InputStreamReader(System.in)); System.out.println(""); chooseBootstrapPack(br); chooseSampleSqlAndConf(br); enterAppName(br); enterPackageName(br); } finally { br.close(); } }
java
private void startInteractiveConfWizard() throws IOException { BufferedReader br = null; try { br = new BufferedReader(new InputStreamReader(System.in)); System.out.println(""); chooseBootstrapPack(br); chooseSampleSqlAndConf(br); enterAppName(br); enterPackageName(br); } finally { br.close(); } }
[ "private", "void", "startInteractiveConfWizard", "(", ")", "throws", "IOException", "{", "BufferedReader", "br", "=", "null", ";", "try", "{", "br", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "System", ".", "in", ")", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "chooseBootstrapPack", "(", "br", ")", ";", "chooseSampleSqlAndConf", "(", "br", ")", ";", "enterAppName", "(", "br", ")", ";", "enterPackageName", "(", "br", ")", ";", "}", "finally", "{", "br", ".", "close", "(", ")", ";", "}", "}" ]
Ask the user all the info we need.
[ "Ask", "the", "user", "all", "the", "info", "we", "need", "." ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-maven/bootstrap-maven-plugin/src/main/java/com/jaxio/celerio/maven/plugin/bootstrap/BootstrapMojo.java#L247-L259
4,191
jaxio/celerio
celerio-maven/bootstrap-maven-plugin/src/main/java/com/jaxio/celerio/maven/plugin/bootstrap/BootstrapMojo.java
BootstrapMojo.chooseBootstrapPack
private void chooseBootstrapPack(BufferedReader br) throws IOException { while (true) { printInstruction("Choose the type of application you want to generate:"); for (int i = 0; i < getBootstrapPacksInfo().size(); i++) { TemplatePackInfo templatePackInfo = getBootstrapPacksInfo().get(i); System.out.println(" " + (i + 1) + ") " + templatePackInfo.getName()); System.out.println(" " + templatePackInfo.getProjectLink()); System.out.println(" " + templatePackInfo.getDescription()); if (templatePackInfo.getDescription2() != null) { System.out.println(" " + templatePackInfo.getDescription2()); } System.out.println(""); } String choice = br.readLine(); if (isBlank(choice)) { continue; } else { try { TemplatePackInfo chosenTemplatePackInfo = getBootstrapPacksInfo().get(Integer.parseInt(choice) - 1); bootstrapPackName = chosenTemplatePackInfo.getName(); System.out.println("OK, using: " + chosenTemplatePackInfo.getName()); packCommand = chosenTemplatePackInfo.getCommand(); packCommandHelp = chosenTemplatePackInfo.getCommandHelp(); } catch (Exception e) { System.out.println(""); continue; } } break; } }
java
private void chooseBootstrapPack(BufferedReader br) throws IOException { while (true) { printInstruction("Choose the type of application you want to generate:"); for (int i = 0; i < getBootstrapPacksInfo().size(); i++) { TemplatePackInfo templatePackInfo = getBootstrapPacksInfo().get(i); System.out.println(" " + (i + 1) + ") " + templatePackInfo.getName()); System.out.println(" " + templatePackInfo.getProjectLink()); System.out.println(" " + templatePackInfo.getDescription()); if (templatePackInfo.getDescription2() != null) { System.out.println(" " + templatePackInfo.getDescription2()); } System.out.println(""); } String choice = br.readLine(); if (isBlank(choice)) { continue; } else { try { TemplatePackInfo chosenTemplatePackInfo = getBootstrapPacksInfo().get(Integer.parseInt(choice) - 1); bootstrapPackName = chosenTemplatePackInfo.getName(); System.out.println("OK, using: " + chosenTemplatePackInfo.getName()); packCommand = chosenTemplatePackInfo.getCommand(); packCommandHelp = chosenTemplatePackInfo.getCommandHelp(); } catch (Exception e) { System.out.println(""); continue; } } break; } }
[ "private", "void", "chooseBootstrapPack", "(", "BufferedReader", "br", ")", "throws", "IOException", "{", "while", "(", "true", ")", "{", "printInstruction", "(", "\"Choose the type of application you want to generate:\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "getBootstrapPacksInfo", "(", ")", ".", "size", "(", ")", ";", "i", "++", ")", "{", "TemplatePackInfo", "templatePackInfo", "=", "getBootstrapPacksInfo", "(", ")", ".", "get", "(", "i", ")", ";", "System", ".", "out", ".", "println", "(", "\" \"", "+", "(", "i", "+", "1", ")", "+", "\") \"", "+", "templatePackInfo", ".", "getName", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", "\" \"", "+", "templatePackInfo", ".", "getProjectLink", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", "\" \"", "+", "templatePackInfo", ".", "getDescription", "(", ")", ")", ";", "if", "(", "templatePackInfo", ".", "getDescription2", "(", ")", "!=", "null", ")", "{", "System", ".", "out", ".", "println", "(", "\" \"", "+", "templatePackInfo", ".", "getDescription2", "(", ")", ")", ";", "}", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "}", "String", "choice", "=", "br", ".", "readLine", "(", ")", ";", "if", "(", "isBlank", "(", "choice", ")", ")", "{", "continue", ";", "}", "else", "{", "try", "{", "TemplatePackInfo", "chosenTemplatePackInfo", "=", "getBootstrapPacksInfo", "(", ")", ".", "get", "(", "Integer", ".", "parseInt", "(", "choice", ")", "-", "1", ")", ";", "bootstrapPackName", "=", "chosenTemplatePackInfo", ".", "getName", "(", ")", ";", "System", ".", "out", ".", "println", "(", "\"OK, using: \"", "+", "chosenTemplatePackInfo", ".", "getName", "(", ")", ")", ";", "packCommand", "=", "chosenTemplatePackInfo", ".", "getCommand", "(", ")", ";", "packCommandHelp", "=", "chosenTemplatePackInfo", ".", "getCommandHelp", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "continue", ";", "}", "}", "break", ";", "}", "}" ]
Interactively ask the user which pack should be used.
[ "Interactively", "ask", "the", "user", "which", "pack", "should", "be", "used", "." ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-maven/bootstrap-maven-plugin/src/main/java/com/jaxio/celerio/maven/plugin/bootstrap/BootstrapMojo.java#L275-L307
4,192
jaxio/celerio
celerio-maven/bootstrap-maven-plugin/src/main/java/com/jaxio/celerio/maven/plugin/bootstrap/BootstrapMojo.java
BootstrapMojo.getBootstrapPacksInfo
protected List<TemplatePackInfo> getBootstrapPacksInfo() { if (bootstrapPacksInfo == null) { bootstrapPacksInfo = getCelerioApplicationContext().getBean(ClasspathTemplatePackInfoLoader.class).resolveTopLevelPacks(); } return bootstrapPacksInfo; }
java
protected List<TemplatePackInfo> getBootstrapPacksInfo() { if (bootstrapPacksInfo == null) { bootstrapPacksInfo = getCelerioApplicationContext().getBean(ClasspathTemplatePackInfoLoader.class).resolveTopLevelPacks(); } return bootstrapPacksInfo; }
[ "protected", "List", "<", "TemplatePackInfo", ">", "getBootstrapPacksInfo", "(", ")", "{", "if", "(", "bootstrapPacksInfo", "==", "null", ")", "{", "bootstrapPacksInfo", "=", "getCelerioApplicationContext", "(", ")", ".", "getBean", "(", "ClasspathTemplatePackInfoLoader", ".", "class", ")", ".", "resolveTopLevelPacks", "(", ")", ";", "}", "return", "bootstrapPacksInfo", ";", "}" ]
Return the celerio template packs found on the classpath.
[ "Return", "the", "celerio", "template", "packs", "found", "on", "the", "classpath", "." ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-maven/bootstrap-maven-plugin/src/main/java/com/jaxio/celerio/maven/plugin/bootstrap/BootstrapMojo.java#L316-L321
4,193
jaxio/celerio
celerio-maven/bootstrap-maven-plugin/src/main/java/com/jaxio/celerio/maven/plugin/bootstrap/BootstrapMojo.java
BootstrapMojo.chooseSampleSqlAndConf
private void chooseSampleSqlAndConf(BufferedReader br) throws IOException { while (true) { printInstruction("Which sample SQL schema would you like to use?"); for (int i = 0; i < getSqlConfInfos().size(); i++) { System.out.println(" " + (i + 1) + ") " + getSqlConfInfos().get(i).getName()); System.out.println(" " + getSqlConfInfos().get(i).getDescription()); if (getSqlConfInfos().get(i).getDescription2() != null) { System.out.println(" " + getSqlConfInfos().get(i).getDescription2()); } System.out.println(""); } String choice = br.readLine(); if (isBlank(choice)) { continue; } else { try { sqlConfName = getSqlConfInfos().get(Integer.parseInt(choice) - 1).getName(); System.out.println("OK, using: " + sqlConfName); } catch (Exception e) { System.out.println(""); continue; } } break; } }
java
private void chooseSampleSqlAndConf(BufferedReader br) throws IOException { while (true) { printInstruction("Which sample SQL schema would you like to use?"); for (int i = 0; i < getSqlConfInfos().size(); i++) { System.out.println(" " + (i + 1) + ") " + getSqlConfInfos().get(i).getName()); System.out.println(" " + getSqlConfInfos().get(i).getDescription()); if (getSqlConfInfos().get(i).getDescription2() != null) { System.out.println(" " + getSqlConfInfos().get(i).getDescription2()); } System.out.println(""); } String choice = br.readLine(); if (isBlank(choice)) { continue; } else { try { sqlConfName = getSqlConfInfos().get(Integer.parseInt(choice) - 1).getName(); System.out.println("OK, using: " + sqlConfName); } catch (Exception e) { System.out.println(""); continue; } } break; } }
[ "private", "void", "chooseSampleSqlAndConf", "(", "BufferedReader", "br", ")", "throws", "IOException", "{", "while", "(", "true", ")", "{", "printInstruction", "(", "\"Which sample SQL schema would you like to use?\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "getSqlConfInfos", "(", ")", ".", "size", "(", ")", ";", "i", "++", ")", "{", "System", ".", "out", ".", "println", "(", "\" \"", "+", "(", "i", "+", "1", ")", "+", "\") \"", "+", "getSqlConfInfos", "(", ")", ".", "get", "(", "i", ")", ".", "getName", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", "\" \"", "+", "getSqlConfInfos", "(", ")", ".", "get", "(", "i", ")", ".", "getDescription", "(", ")", ")", ";", "if", "(", "getSqlConfInfos", "(", ")", ".", "get", "(", "i", ")", ".", "getDescription2", "(", ")", "!=", "null", ")", "{", "System", ".", "out", ".", "println", "(", "\" \"", "+", "getSqlConfInfos", "(", ")", ".", "get", "(", "i", ")", ".", "getDescription2", "(", ")", ")", ";", "}", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "}", "String", "choice", "=", "br", ".", "readLine", "(", ")", ";", "if", "(", "isBlank", "(", "choice", ")", ")", "{", "continue", ";", "}", "else", "{", "try", "{", "sqlConfName", "=", "getSqlConfInfos", "(", ")", ".", "get", "(", "Integer", ".", "parseInt", "(", "choice", ")", "-", "1", ")", ".", "getName", "(", ")", ";", "System", ".", "out", ".", "println", "(", "\"OK, using: \"", "+", "sqlConfName", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "continue", ";", "}", "}", "break", ";", "}", "}" ]
Interactively ask the user which sql conf should be used.
[ "Interactively", "ask", "the", "user", "which", "sql", "conf", "should", "be", "used", "." ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-maven/bootstrap-maven-plugin/src/main/java/com/jaxio/celerio/maven/plugin/bootstrap/BootstrapMojo.java#L336-L362
4,194
jaxio/celerio
celerio-maven/bootstrap-maven-plugin/src/main/java/com/jaxio/celerio/maven/plugin/bootstrap/BootstrapMojo.java
BootstrapMojo.getSqlConfInfos
protected List<SqlConfInfo> getSqlConfInfos() { List<SqlConfInfo> packInfos = newArrayList(); PathMatchingResourcePatternResolver o = new PathMatchingResourcePatternResolver(); try { Resource packInfosAsResource[] = o.getResources("classpath*:sqlconf/*/00-info.txt"); for (Resource r : packInfosAsResource) { packInfos.add(new SqlConfInfo(r)); } Collections.sort(packInfos); return packInfos; } catch (IOException ioe) { throw new RuntimeException("Error while searching for SQL CONF having a sqlconf/*/00-info.txt file!", ioe); } }
java
protected List<SqlConfInfo> getSqlConfInfos() { List<SqlConfInfo> packInfos = newArrayList(); PathMatchingResourcePatternResolver o = new PathMatchingResourcePatternResolver(); try { Resource packInfosAsResource[] = o.getResources("classpath*:sqlconf/*/00-info.txt"); for (Resource r : packInfosAsResource) { packInfos.add(new SqlConfInfo(r)); } Collections.sort(packInfos); return packInfos; } catch (IOException ioe) { throw new RuntimeException("Error while searching for SQL CONF having a sqlconf/*/00-info.txt file!", ioe); } }
[ "protected", "List", "<", "SqlConfInfo", ">", "getSqlConfInfos", "(", ")", "{", "List", "<", "SqlConfInfo", ">", "packInfos", "=", "newArrayList", "(", ")", ";", "PathMatchingResourcePatternResolver", "o", "=", "new", "PathMatchingResourcePatternResolver", "(", ")", ";", "try", "{", "Resource", "packInfosAsResource", "[", "]", "=", "o", ".", "getResources", "(", "\"classpath*:sqlconf/*/00-info.txt\"", ")", ";", "for", "(", "Resource", "r", ":", "packInfosAsResource", ")", "{", "packInfos", ".", "add", "(", "new", "SqlConfInfo", "(", "r", ")", ")", ";", "}", "Collections", ".", "sort", "(", "packInfos", ")", ";", "return", "packInfos", ";", "}", "catch", "(", "IOException", "ioe", ")", "{", "throw", "new", "RuntimeException", "(", "\"Error while searching for SQL CONF having a sqlconf/*/00-info.txt file!\"", ",", "ioe", ")", ";", "}", "}" ]
Scan the classpath for SQL configurations.
[ "Scan", "the", "classpath", "for", "SQL", "configurations", "." ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-maven/bootstrap-maven-plugin/src/main/java/com/jaxio/celerio/maven/plugin/bootstrap/BootstrapMojo.java#L367-L382
4,195
jaxio/celerio
celerio-maven/bootstrap-maven-plugin/src/main/java/com/jaxio/celerio/maven/plugin/bootstrap/BootstrapMojo.java
BootstrapMojo.enterPackageName
private void enterPackageName(BufferedReader br) throws IOException { String suggestedRootPackage = getDefaultRootPackage() + "." + appName; while (true) { printInstruction("Enter the Java root package of your application: [" + suggestedRootPackage + "]"); String packageNameCandidate = br.readLine(); if (isBlank(packageNameCandidate)) { rootPackage = suggestedRootPackage; break; } else { if (isPackageNameValid(packageNameCandidate)) { rootPackage = packageNameCandidate; break; } else { System.out.println("Oops! invalid Java package name."); System.out.println(""); continue; } } } }
java
private void enterPackageName(BufferedReader br) throws IOException { String suggestedRootPackage = getDefaultRootPackage() + "." + appName; while (true) { printInstruction("Enter the Java root package of your application: [" + suggestedRootPackage + "]"); String packageNameCandidate = br.readLine(); if (isBlank(packageNameCandidate)) { rootPackage = suggestedRootPackage; break; } else { if (isPackageNameValid(packageNameCandidate)) { rootPackage = packageNameCandidate; break; } else { System.out.println("Oops! invalid Java package name."); System.out.println(""); continue; } } } }
[ "private", "void", "enterPackageName", "(", "BufferedReader", "br", ")", "throws", "IOException", "{", "String", "suggestedRootPackage", "=", "getDefaultRootPackage", "(", ")", "+", "\".\"", "+", "appName", ";", "while", "(", "true", ")", "{", "printInstruction", "(", "\"Enter the Java root package of your application: [\"", "+", "suggestedRootPackage", "+", "\"]\"", ")", ";", "String", "packageNameCandidate", "=", "br", ".", "readLine", "(", ")", ";", "if", "(", "isBlank", "(", "packageNameCandidate", ")", ")", "{", "rootPackage", "=", "suggestedRootPackage", ";", "break", ";", "}", "else", "{", "if", "(", "isPackageNameValid", "(", "packageNameCandidate", ")", ")", "{", "rootPackage", "=", "packageNameCandidate", ";", "break", ";", "}", "else", "{", "System", ".", "out", ".", "println", "(", "\"Oops! invalid Java package name.\"", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "continue", ";", "}", "}", "}", "}" ]
Ask the user to enter the package name.
[ "Ask", "the", "user", "to", "enter", "the", "package", "name", "." ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-maven/bootstrap-maven-plugin/src/main/java/com/jaxio/celerio/maven/plugin/bootstrap/BootstrapMojo.java#L435-L455
4,196
jaxio/celerio
celerio-maven/bootstrap-maven-plugin/src/main/java/com/jaxio/celerio/maven/plugin/bootstrap/BootstrapMojo.java
BootstrapMojo.enterAppName
private void enterAppName(BufferedReader br) throws IOException { while (true) { printInstruction("Enter your application name: [" + getDefaultAppName() + "]"); String appNameCandidate = br.readLine(); if (isBlank(appNameCandidate)) { appName = getDefaultAppName(); break; } else { if (isPackageNameValid(getDefaultRootPackage() + "." + appNameCandidate)) { appName = appNameCandidate; break; } else { System.out.println("Oops! invalid application name. Keep it simple, no '-', etc..."); System.out.println(""); continue; } } } }
java
private void enterAppName(BufferedReader br) throws IOException { while (true) { printInstruction("Enter your application name: [" + getDefaultAppName() + "]"); String appNameCandidate = br.readLine(); if (isBlank(appNameCandidate)) { appName = getDefaultAppName(); break; } else { if (isPackageNameValid(getDefaultRootPackage() + "." + appNameCandidate)) { appName = appNameCandidate; break; } else { System.out.println("Oops! invalid application name. Keep it simple, no '-', etc..."); System.out.println(""); continue; } } } }
[ "private", "void", "enterAppName", "(", "BufferedReader", "br", ")", "throws", "IOException", "{", "while", "(", "true", ")", "{", "printInstruction", "(", "\"Enter your application name: [\"", "+", "getDefaultAppName", "(", ")", "+", "\"]\"", ")", ";", "String", "appNameCandidate", "=", "br", ".", "readLine", "(", ")", ";", "if", "(", "isBlank", "(", "appNameCandidate", ")", ")", "{", "appName", "=", "getDefaultAppName", "(", ")", ";", "break", ";", "}", "else", "{", "if", "(", "isPackageNameValid", "(", "getDefaultRootPackage", "(", ")", "+", "\".\"", "+", "appNameCandidate", ")", ")", "{", "appName", "=", "appNameCandidate", ";", "break", ";", "}", "else", "{", "System", ".", "out", ".", "println", "(", "\"Oops! invalid application name. Keep it simple, no '-', etc...\"", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "continue", ";", "}", "}", "}", "}" ]
Ask the user to enter the application name.
[ "Ask", "the", "user", "to", "enter", "the", "application", "name", "." ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-maven/bootstrap-maven-plugin/src/main/java/com/jaxio/celerio/maven/plugin/bootstrap/BootstrapMojo.java#L460-L479
4,197
jaxio/celerio
celerio-maven/bootstrap-maven-plugin/src/main/java/com/jaxio/celerio/maven/plugin/bootstrap/BootstrapMojo.java
BootstrapMojo.printInstruction
private void printInstruction(String instruction) { System.out.println(StringUtils.repeat("-", instruction.length())); System.out.println(instruction); System.out.println(StringUtils.repeat("-", instruction.length())); }
java
private void printInstruction(String instruction) { System.out.println(StringUtils.repeat("-", instruction.length())); System.out.println(instruction); System.out.println(StringUtils.repeat("-", instruction.length())); }
[ "private", "void", "printInstruction", "(", "String", "instruction", ")", "{", "System", ".", "out", ".", "println", "(", "StringUtils", ".", "repeat", "(", "\"-\"", ",", "instruction", ".", "length", "(", ")", ")", ")", ";", "System", ".", "out", ".", "println", "(", "instruction", ")", ";", "System", ".", "out", ".", "println", "(", "StringUtils", ".", "repeat", "(", "\"-\"", ",", "instruction", ".", "length", "(", ")", ")", ")", ";", "}" ]
Print the passed instruction in the console.
[ "Print", "the", "passed", "instruction", "in", "the", "console", "." ]
fbfacb639e286f9f3f3a18986f74ea275bebd887
https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-maven/bootstrap-maven-plugin/src/main/java/com/jaxio/celerio/maven/plugin/bootstrap/BootstrapMojo.java#L566-L570
4,198
protostuff/protostuff-compiler
protostuff-parser/src/main/java/io/protostuff/compiler/parser/LocalFileReader.java
LocalFileReader.checkDirectories
private List<Path> checkDirectories(List<Path> pathList) { List<Path> result = new ArrayList<>(); for (Path path : pathList) { if (!Files.exists(path)) { LOGGER.debug("'{}' does not exist", path); } else if (!Files.isDirectory(path)) { LOGGER.warn("'{}' is not directory", path); } // todo: should we use not existing paths? this behavior is copied from 'protoc' - it just shows warning result.add(path); } return result; }
java
private List<Path> checkDirectories(List<Path> pathList) { List<Path> result = new ArrayList<>(); for (Path path : pathList) { if (!Files.exists(path)) { LOGGER.debug("'{}' does not exist", path); } else if (!Files.isDirectory(path)) { LOGGER.warn("'{}' is not directory", path); } // todo: should we use not existing paths? this behavior is copied from 'protoc' - it just shows warning result.add(path); } return result; }
[ "private", "List", "<", "Path", ">", "checkDirectories", "(", "List", "<", "Path", ">", "pathList", ")", "{", "List", "<", "Path", ">", "result", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "Path", "path", ":", "pathList", ")", "{", "if", "(", "!", "Files", ".", "exists", "(", "path", ")", ")", "{", "LOGGER", ".", "debug", "(", "\"'{}' does not exist\"", ",", "path", ")", ";", "}", "else", "if", "(", "!", "Files", ".", "isDirectory", "(", "path", ")", ")", "{", "LOGGER", ".", "warn", "(", "\"'{}' is not directory\"", ",", "path", ")", ";", "}", "// todo: should we use not existing paths? this behavior is copied from 'protoc' - it just shows warning", "result", ".", "add", "(", "path", ")", ";", "}", "return", "result", ";", "}" ]
Check that all elements in the list exist and are directories. Log warning for each element that is not directory.
[ "Check", "that", "all", "elements", "in", "the", "list", "exist", "and", "are", "directories", ".", "Log", "warning", "for", "each", "element", "that", "is", "not", "directory", "." ]
665256c42cb41da849e8321ffcab088350ace171
https://github.com/protostuff/protostuff-compiler/blob/665256c42cb41da849e8321ffcab088350ace171/protostuff-parser/src/main/java/io/protostuff/compiler/parser/LocalFileReader.java#L39-L51
4,199
protostuff/protostuff-compiler
protostuff-parser/src/main/java/io/protostuff/compiler/model/Proto.java
Proto.getPublicImports
public List<Import> getPublicImports() { return getImports() .stream() .filter(Import::isPublic) .collect(Collectors.toList()); }
java
public List<Import> getPublicImports() { return getImports() .stream() .filter(Import::isPublic) .collect(Collectors.toList()); }
[ "public", "List", "<", "Import", ">", "getPublicImports", "(", ")", "{", "return", "getImports", "(", ")", ".", "stream", "(", ")", ".", "filter", "(", "Import", "::", "isPublic", ")", ".", "collect", "(", "Collectors", ".", "toList", "(", ")", ")", ";", "}" ]
Returns all public imports in this proto file.
[ "Returns", "all", "public", "imports", "in", "this", "proto", "file", "." ]
665256c42cb41da849e8321ffcab088350ace171
https://github.com/protostuff/protostuff-compiler/blob/665256c42cb41da849e8321ffcab088350ace171/protostuff-parser/src/main/java/io/protostuff/compiler/model/Proto.java#L80-L85