repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/LinkedMultiValueMap.java
LinkedMultiValueMap.deepCopy
public LinkedMultiValueMap<K, V> deepCopy() { LinkedMultiValueMap<K, V> copy = new LinkedMultiValueMap<>(this.size()); this.forEach((key, value) -> copy.put(key, new LinkedList<>(value))); return copy; }
java
public LinkedMultiValueMap<K, V> deepCopy() { LinkedMultiValueMap<K, V> copy = new LinkedMultiValueMap<>(this.size()); this.forEach((key, value) -> copy.put(key, new LinkedList<>(value))); return copy; }
[ "public", "LinkedMultiValueMap", "<", "K", ",", "V", ">", "deepCopy", "(", ")", "{", "LinkedMultiValueMap", "<", "K", ",", "V", ">", "copy", "=", "new", "LinkedMultiValueMap", "<>", "(", "this", ".", "size", "(", ")", ")", ";", "this", ".", "forEach", ...
Create a deep copy of this Map. @return a copy of this Map, including a copy of each value-holding List entry @see #clone()
[ "Create", "a", "deep", "copy", "of", "this", "Map", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/LinkedMultiValueMap.java#L126-L130
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/AdviceActivity.java
AdviceActivity.executeAdvice
protected void executeAdvice(Executable action) { if (log.isDebugEnabled()) { log.debug("Action " + action); } try { action.execute(this); } catch (Exception e) { setRaisedException(e); throw new ActionExecutionException("Failed to execute advice action " + action, e); } }
java
protected void executeAdvice(Executable action) { if (log.isDebugEnabled()) { log.debug("Action " + action); } try { action.execute(this); } catch (Exception e) { setRaisedException(e); throw new ActionExecutionException("Failed to execute advice action " + action, e); } }
[ "protected", "void", "executeAdvice", "(", "Executable", "action", ")", "{", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Action \"", "+", "action", ")", ";", "}", "try", "{", "action", ".", "execute", "(", ...
Executes advice action. @param action the executable action
[ "Executes", "advice", "action", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/AdviceActivity.java#L240-L251
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/AdviceActivity.java
AdviceActivity.getAspectAdviceBean
@SuppressWarnings("unchecked") public <T> T getAspectAdviceBean(String aspectId) { return (aspectAdviceResult != null ? (T)aspectAdviceResult.getAspectAdviceBean(aspectId) : null); }
java
@SuppressWarnings("unchecked") public <T> T getAspectAdviceBean(String aspectId) { return (aspectAdviceResult != null ? (T)aspectAdviceResult.getAspectAdviceBean(aspectId) : null); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", ">", "T", "getAspectAdviceBean", "(", "String", "aspectId", ")", "{", "return", "(", "aspectAdviceResult", "!=", "null", "?", "(", "T", ")", "aspectAdviceResult", ".", "getAspectAdviceBean",...
Gets the aspect advice bean. @param <T> the generic type @param aspectId the aspect id @return the aspect advice bean
[ "Gets", "the", "aspect", "advice", "bean", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/AdviceActivity.java#L450-L453
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/AdviceActivity.java
AdviceActivity.putAspectAdviceBean
protected void putAspectAdviceBean(String aspectId, Object adviceBean) { if (aspectAdviceResult == null) { aspectAdviceResult = new AspectAdviceResult(); } aspectAdviceResult.putAspectAdviceBean(aspectId, adviceBean); }
java
protected void putAspectAdviceBean(String aspectId, Object adviceBean) { if (aspectAdviceResult == null) { aspectAdviceResult = new AspectAdviceResult(); } aspectAdviceResult.putAspectAdviceBean(aspectId, adviceBean); }
[ "protected", "void", "putAspectAdviceBean", "(", "String", "aspectId", ",", "Object", "adviceBean", ")", "{", "if", "(", "aspectAdviceResult", "==", "null", ")", "{", "aspectAdviceResult", "=", "new", "AspectAdviceResult", "(", ")", ";", "}", "aspectAdviceResult",...
Puts the aspect advice bean. @param aspectId the aspect id @param adviceBean the advice bean
[ "Puts", "the", "aspect", "advice", "bean", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/AdviceActivity.java#L461-L466
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/AdviceActivity.java
AdviceActivity.getBeforeAdviceResult
@SuppressWarnings("unchecked") public <T> T getBeforeAdviceResult(String aspectId) { return (aspectAdviceResult != null ? (T)aspectAdviceResult.getBeforeAdviceResult(aspectId) : null); }
java
@SuppressWarnings("unchecked") public <T> T getBeforeAdviceResult(String aspectId) { return (aspectAdviceResult != null ? (T)aspectAdviceResult.getBeforeAdviceResult(aspectId) : null); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", ">", "T", "getBeforeAdviceResult", "(", "String", "aspectId", ")", "{", "return", "(", "aspectAdviceResult", "!=", "null", "?", "(", "T", ")", "aspectAdviceResult", ".", "getBeforeAdviceResu...
Gets the before advice result. @param <T> the generic type @param aspectId the aspect id @return the before advice result
[ "Gets", "the", "before", "advice", "result", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/AdviceActivity.java#L475-L478
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/AdviceActivity.java
AdviceActivity.getAfterAdviceResult
@SuppressWarnings("unchecked") public <T> T getAfterAdviceResult(String aspectId) { return (aspectAdviceResult != null ? (T)aspectAdviceResult.getAfterAdviceResult(aspectId) : null); }
java
@SuppressWarnings("unchecked") public <T> T getAfterAdviceResult(String aspectId) { return (aspectAdviceResult != null ? (T)aspectAdviceResult.getAfterAdviceResult(aspectId) : null); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", ">", "T", "getAfterAdviceResult", "(", "String", "aspectId", ")", "{", "return", "(", "aspectAdviceResult", "!=", "null", "?", "(", "T", ")", "aspectAdviceResult", ".", "getAfterAdviceResult...
Gets the after advice result. @param <T> the generic type @param aspectId the aspect id @return the after advice result
[ "Gets", "the", "after", "advice", "result", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/AdviceActivity.java#L487-L490
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/AdviceActivity.java
AdviceActivity.getAroundAdviceResult
@SuppressWarnings("unchecked") public <T> T getAroundAdviceResult(String aspectId) { return (aspectAdviceResult != null ? (T)aspectAdviceResult.getAroundAdviceResult(aspectId) : null); }
java
@SuppressWarnings("unchecked") public <T> T getAroundAdviceResult(String aspectId) { return (aspectAdviceResult != null ? (T)aspectAdviceResult.getAroundAdviceResult(aspectId) : null); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", ">", "T", "getAroundAdviceResult", "(", "String", "aspectId", ")", "{", "return", "(", "aspectAdviceResult", "!=", "null", "?", "(", "T", ")", "aspectAdviceResult", ".", "getAroundAdviceResu...
Gets the around advice result. @param <T> the generic type @param aspectId the aspect id @return the around advice result
[ "Gets", "the", "around", "advice", "result", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/AdviceActivity.java#L499-L502
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/AdviceActivity.java
AdviceActivity.getFinallyAdviceResult
@SuppressWarnings("unchecked") public <T> T getFinallyAdviceResult(String aspectId) { return (aspectAdviceResult != null ? (T)aspectAdviceResult.getFinallyAdviceResult(aspectId) : null); }
java
@SuppressWarnings("unchecked") public <T> T getFinallyAdviceResult(String aspectId) { return (aspectAdviceResult != null ? (T)aspectAdviceResult.getFinallyAdviceResult(aspectId) : null); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", ">", "T", "getFinallyAdviceResult", "(", "String", "aspectId", ")", "{", "return", "(", "aspectAdviceResult", "!=", "null", "?", "(", "T", ")", "aspectAdviceResult", ".", "getFinallyAdviceRe...
Gets the finally advice result. @param <T> the generic type @param aspectId the aspect id @return the finally advice result
[ "Gets", "the", "finally", "advice", "result", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/AdviceActivity.java#L511-L514
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/AdviceActivity.java
AdviceActivity.putAdviceResult
protected void putAdviceResult(AspectAdviceRule aspectAdviceRule, Object adviceActionResult) { if (aspectAdviceResult == null) { aspectAdviceResult = new AspectAdviceResult(); } aspectAdviceResult.putAdviceResult(aspectAdviceRule, adviceActionResult); }
java
protected void putAdviceResult(AspectAdviceRule aspectAdviceRule, Object adviceActionResult) { if (aspectAdviceResult == null) { aspectAdviceResult = new AspectAdviceResult(); } aspectAdviceResult.putAdviceResult(aspectAdviceRule, adviceActionResult); }
[ "protected", "void", "putAdviceResult", "(", "AspectAdviceRule", "aspectAdviceRule", ",", "Object", "adviceActionResult", ")", "{", "if", "(", "aspectAdviceResult", "==", "null", ")", "{", "aspectAdviceResult", "=", "new", "AspectAdviceResult", "(", ")", ";", "}", ...
Puts the result of the advice. @param aspectAdviceRule the aspect advice rule @param adviceActionResult the advice action result
[ "Puts", "the", "result", "of", "the", "advice", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/AdviceActivity.java#L522-L527
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/rule/TransletRule.java
TransletRule.touchActionList
private ActionList touchActionList() { if (contentList != null) { if (contentList.isExplicit() || contentList.size() != 1) { contentList = null; } else { ActionList actionList = contentList.get(0); if (actionList.isExplicit()) { contentList = null; } } } ActionList actionList; if (contentList == null) { contentList = new ContentList(false); actionList = new ActionList(false); contentList.add(actionList); } else { actionList = contentList.get(0); } return actionList; }
java
private ActionList touchActionList() { if (contentList != null) { if (contentList.isExplicit() || contentList.size() != 1) { contentList = null; } else { ActionList actionList = contentList.get(0); if (actionList.isExplicit()) { contentList = null; } } } ActionList actionList; if (contentList == null) { contentList = new ContentList(false); actionList = new ActionList(false); contentList.add(actionList); } else { actionList = contentList.get(0); } return actionList; }
[ "private", "ActionList", "touchActionList", "(", ")", "{", "if", "(", "contentList", "!=", "null", ")", "{", "if", "(", "contentList", ".", "isExplicit", "(", ")", "||", "contentList", ".", "size", "(", ")", "!=", "1", ")", "{", "contentList", "=", "nu...
Returns the action list. If not yet instantiated then create a new one. @return the action list
[ "Returns", "the", "action", "list", ".", "If", "not", "yet", "instantiated", "then", "create", "a", "new", "one", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/rule/TransletRule.java#L302-L322
train
aspectran/aspectran
web/src/main/java/com/aspectran/web/support/http/HttpStatusSetter.java
HttpStatusSetter.setStatus
public static void setStatus(HttpStatus httpStatus, Translet translet) { translet.getResponseAdapter().setStatus(httpStatus.value()); }
java
public static void setStatus(HttpStatus httpStatus, Translet translet) { translet.getResponseAdapter().setStatus(httpStatus.value()); }
[ "public", "static", "void", "setStatus", "(", "HttpStatus", "httpStatus", ",", "Translet", "translet", ")", "{", "translet", ".", "getResponseAdapter", "(", ")", ".", "setStatus", "(", "httpStatus", ".", "value", "(", ")", ")", ";", "}" ]
Sets the status code. @param httpStatus the http status code @param translet the Translet instance
[ "Sets", "the", "status", "code", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/web/src/main/java/com/aspectran/web/support/http/HttpStatusSetter.java#L31-L33
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/response/transform/xml/ContentsXMLReader.java
ContentsXMLReader.outputString
private void outputString(String s) throws SAXException { handler.characters(s.toCharArray(), 0, s.length()); }
java
private void outputString(String s) throws SAXException { handler.characters(s.toCharArray(), 0, s.length()); }
[ "private", "void", "outputString", "(", "String", "s", ")", "throws", "SAXException", "{", "handler", ".", "characters", "(", "s", ".", "toCharArray", "(", ")", ",", "0", ",", "s", ".", "length", "(", ")", ")", ";", "}" ]
Outputs a string. @param s the input string @throws SAXException the SAX exception
[ "Outputs", "a", "string", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/response/transform/xml/ContentsXMLReader.java#L267-L269
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/response/transform/TransformResponse.java
TransformResponse.getTemplateAsStream
protected InputStream getTemplateAsStream(URL url) throws IOException { URLConnection conn = url.openConnection(); return conn.getInputStream(); }
java
protected InputStream getTemplateAsStream(URL url) throws IOException { URLConnection conn = url.openConnection(); return conn.getInputStream(); }
[ "protected", "InputStream", "getTemplateAsStream", "(", "URL", "url", ")", "throws", "IOException", "{", "URLConnection", "conn", "=", "url", ".", "openConnection", "(", ")", ";", "return", "conn", ".", "getInputStream", "(", ")", ";", "}" ]
Gets the template as stream. @param url the url of the template @return the input stream of the template @throws IOException if an I/O error has occurred
[ "Gets", "the", "template", "as", "stream", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/response/transform/TransformResponse.java#L87-L90
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/StringUtils.java
StringUtils.search
public static int search(String str, String keyw) { int strLen = str.length(); int keywLen = keyw.length(); int pos = 0; int cnt = 0; if (keywLen == 0) { return 0; } while ((pos = str.indexOf(keyw, pos)) != -1) { pos += keywLen; cnt++; if (pos >= strLen) { break; } } return cnt; }
java
public static int search(String str, String keyw) { int strLen = str.length(); int keywLen = keyw.length(); int pos = 0; int cnt = 0; if (keywLen == 0) { return 0; } while ((pos = str.indexOf(keyw, pos)) != -1) { pos += keywLen; cnt++; if (pos >= strLen) { break; } } return cnt; }
[ "public", "static", "int", "search", "(", "String", "str", ",", "String", "keyw", ")", "{", "int", "strLen", "=", "str", ".", "length", "(", ")", ";", "int", "keywLen", "=", "keyw", ".", "length", "(", ")", ";", "int", "pos", "=", "0", ";", "int"...
Returns the number of times the specified string was found in the target string, or 0 if there is no specified string. @param str the target string @param keyw the string to find @return the number of times the specified string was found
[ "Returns", "the", "number", "of", "times", "the", "specified", "string", "was", "found", "in", "the", "target", "string", "or", "0", "if", "there", "is", "no", "specified", "string", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/StringUtils.java#L533-L549
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/StringUtils.java
StringUtils.searchIgnoreCase
public static int searchIgnoreCase(String str, String keyw) { return search(str.toLowerCase(), keyw.toLowerCase()); }
java
public static int searchIgnoreCase(String str, String keyw) { return search(str.toLowerCase(), keyw.toLowerCase()); }
[ "public", "static", "int", "searchIgnoreCase", "(", "String", "str", ",", "String", "keyw", ")", "{", "return", "search", "(", "str", ".", "toLowerCase", "(", ")", ",", "keyw", ".", "toLowerCase", "(", ")", ")", ";", "}" ]
Returns the number of times the specified string was found in the target string, or 0 if there is no specified string. When searching for the specified string, it is not case-sensitive. @param str the target string @param keyw the string to find @return the number of times the specified string was found
[ "Returns", "the", "number", "of", "times", "the", "specified", "string", "was", "found", "in", "the", "target", "string", "or", "0", "if", "there", "is", "no", "specified", "string", ".", "When", "searching", "for", "the", "specified", "string", "it", "is"...
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/StringUtils.java#L560-L562
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/StringUtils.java
StringUtils.search
public static int search(CharSequence chars, char c) { int count = 0; for (int i = 0; i < chars.length(); i++) { if (chars.charAt(i) == c) { count++; } } return count; }
java
public static int search(CharSequence chars, char c) { int count = 0; for (int i = 0; i < chars.length(); i++) { if (chars.charAt(i) == c) { count++; } } return count; }
[ "public", "static", "int", "search", "(", "CharSequence", "chars", ",", "char", "c", ")", "{", "int", "count", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "chars", ".", "length", "(", ")", ";", "i", "++", ")", "{", "if", "...
Returns the number of times the specified character was found in the target string, or 0 if there is no specified character. @param chars the target string @param c the character to find @return the number of times the specified character was found
[ "Returns", "the", "number", "of", "times", "the", "specified", "character", "was", "found", "in", "the", "target", "string", "or", "0", "if", "there", "is", "no", "specified", "character", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/StringUtils.java#L572-L580
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/StringUtils.java
StringUtils.searchIgnoreCase
public static int searchIgnoreCase(CharSequence chars, char c) { int count = 0; char cl = Character.toLowerCase(c); for (int i = 0; i < chars.length(); i++) { if (Character.toLowerCase(chars.charAt(i)) == cl) { count++; } } return count; }
java
public static int searchIgnoreCase(CharSequence chars, char c) { int count = 0; char cl = Character.toLowerCase(c); for (int i = 0; i < chars.length(); i++) { if (Character.toLowerCase(chars.charAt(i)) == cl) { count++; } } return count; }
[ "public", "static", "int", "searchIgnoreCase", "(", "CharSequence", "chars", ",", "char", "c", ")", "{", "int", "count", "=", "0", ";", "char", "cl", "=", "Character", ".", "toLowerCase", "(", "c", ")", ";", "for", "(", "int", "i", "=", "0", ";", "...
Returns the number of times the specified character was found in the target string, or 0 if there is no specified character. When searching for the specified character, it is not case-sensitive. @param chars the target string @param c the character to find @return the number of times the specified character was found
[ "Returns", "the", "number", "of", "times", "the", "specified", "character", "was", "found", "in", "the", "target", "string", "or", "0", "if", "there", "is", "no", "specified", "character", ".", "When", "searching", "for", "the", "specified", "character", "it...
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/StringUtils.java#L591-L600
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/StringUtils.java
StringUtils.toLanguageTag
public static String toLanguageTag(Locale locale) { return locale.getLanguage() + (hasText(locale.getCountry()) ? "-" + locale.getCountry() : EMPTY); }
java
public static String toLanguageTag(Locale locale) { return locale.getLanguage() + (hasText(locale.getCountry()) ? "-" + locale.getCountry() : EMPTY); }
[ "public", "static", "String", "toLanguageTag", "(", "Locale", "locale", ")", "{", "return", "locale", ".", "getLanguage", "(", ")", "+", "(", "hasText", "(", "locale", ".", "getCountry", "(", ")", ")", "?", "\"-\"", "+", "locale", ".", "getCountry", "(",...
Determine the RFC 3066 compliant language tag, as used for the HTTP "Accept-Language" header. @param locale the Locale to transform to a language tag @return the RFC 3066 compliant language tag as {@code String}
[ "Determine", "the", "RFC", "3066", "compliant", "language", "tag", "as", "used", "for", "the", "HTTP", "Accept", "-", "Language", "header", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/StringUtils.java#L783-L785
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/StringUtils.java
StringUtils.convertToHumanFriendlyByteSize
public static String convertToHumanFriendlyByteSize(long size) { if (size < 1024) { return size + " B"; } int z = (63 - Long.numberOfLeadingZeros(size)) / 10; double d = (double)size / (1L << (z * 10)); String format = (d % 1.0 == 0) ? "%.0f %sB" : "%.1f %sB"; return String.format(format, d, " KMGTPE".charAt(z)); }
java
public static String convertToHumanFriendlyByteSize(long size) { if (size < 1024) { return size + " B"; } int z = (63 - Long.numberOfLeadingZeros(size)) / 10; double d = (double)size / (1L << (z * 10)); String format = (d % 1.0 == 0) ? "%.0f %sB" : "%.1f %sB"; return String.format(format, d, " KMGTPE".charAt(z)); }
[ "public", "static", "String", "convertToHumanFriendlyByteSize", "(", "long", "size", ")", "{", "if", "(", "size", "<", "1024", ")", "{", "return", "size", "+", "\" B\"", ";", "}", "int", "z", "=", "(", "63", "-", "Long", ".", "numberOfLeadingZeros", "(",...
Convert byte size into human friendly format. @param size the number of bytes @return a human friendly byte size (includes units)
[ "Convert", "byte", "size", "into", "human", "friendly", "format", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/StringUtils.java#L809-L817
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/StringUtils.java
StringUtils.convertToMachineFriendlyByteSize
@SuppressWarnings("fallthrough") public static long convertToMachineFriendlyByteSize(String size) { double d; try { d = Double.parseDouble(size.replaceAll("[GMK]?[B]?$", "")); } catch (NumberFormatException e) { String msg = "Size must be specified as bytes (B), " + "kilobytes (KB), megabytes (MB), gigabytes (GB). " + "E.g. 1024, 1KB, 10M, 10MB, 100G, 100GB"; throw new NumberFormatException(msg + " " + e.getMessage()); } long l = Math.round(d * 1024 * 1024 * 1024L); int index = Math.max(0, size.length() - (size.endsWith("B") ? 2 : 1)); switch (size.charAt(index)) { default: l /= 1024; case 'K': l /= 1024; case 'M': l /= 1024; case 'G': return l; } }
java
@SuppressWarnings("fallthrough") public static long convertToMachineFriendlyByteSize(String size) { double d; try { d = Double.parseDouble(size.replaceAll("[GMK]?[B]?$", "")); } catch (NumberFormatException e) { String msg = "Size must be specified as bytes (B), " + "kilobytes (KB), megabytes (MB), gigabytes (GB). " + "E.g. 1024, 1KB, 10M, 10MB, 100G, 100GB"; throw new NumberFormatException(msg + " " + e.getMessage()); } long l = Math.round(d * 1024 * 1024 * 1024L); int index = Math.max(0, size.length() - (size.endsWith("B") ? 2 : 1)); switch (size.charAt(index)) { default: l /= 1024; case 'K': l /= 1024; case 'M': l /= 1024; case 'G': return l; } }
[ "@", "SuppressWarnings", "(", "\"fallthrough\"", ")", "public", "static", "long", "convertToMachineFriendlyByteSize", "(", "String", "size", ")", "{", "double", "d", ";", "try", "{", "d", "=", "Double", ".", "parseDouble", "(", "size", ".", "replaceAll", "(", ...
Convert byte size into machine friendly format. @param size the human friendly byte size (includes units) @return a number of bytes @throws NumberFormatException if failed parse given size
[ "Convert", "byte", "size", "into", "machine", "friendly", "format", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/StringUtils.java#L826-L845
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/ClassScanner.java
ClassScanner.scan
private void scan(final String targetPath, final String basePackageName, final String relativePackageName, final WildcardMatcher matcher, final SaveHandler saveHandler) { final File target = new File(targetPath); if (!target.exists()) { return; } target.listFiles(file -> { String fileName = file.getName(); if (file.isDirectory()) { String relativePackageName2; if (relativePackageName == null) { relativePackageName2 = fileName + ResourceUtils.REGULAR_FILE_SEPARATOR; } else { relativePackageName2 = relativePackageName + fileName + ResourceUtils.REGULAR_FILE_SEPARATOR; } String basePath2 = targetPath + fileName + ResourceUtils.REGULAR_FILE_SEPARATOR; scan(basePath2, basePackageName, relativePackageName2, matcher, saveHandler); } else if (fileName.endsWith(ClassUtils.CLASS_FILE_SUFFIX)) { String className; if (relativePackageName != null) { className = basePackageName + relativePackageName + fileName.substring(0, fileName.length() - ClassUtils.CLASS_FILE_SUFFIX.length()); } else { className = basePackageName + fileName.substring(0, fileName.length() - ClassUtils.CLASS_FILE_SUFFIX.length()); } String relativePath = className.substring(basePackageName.length()); if (matcher.matches(relativePath)) { String resourceName = targetPath + fileName; Class<?> targetClass = loadClass(className); saveHandler.save(resourceName, targetClass); } } return false; }); }
java
private void scan(final String targetPath, final String basePackageName, final String relativePackageName, final WildcardMatcher matcher, final SaveHandler saveHandler) { final File target = new File(targetPath); if (!target.exists()) { return; } target.listFiles(file -> { String fileName = file.getName(); if (file.isDirectory()) { String relativePackageName2; if (relativePackageName == null) { relativePackageName2 = fileName + ResourceUtils.REGULAR_FILE_SEPARATOR; } else { relativePackageName2 = relativePackageName + fileName + ResourceUtils.REGULAR_FILE_SEPARATOR; } String basePath2 = targetPath + fileName + ResourceUtils.REGULAR_FILE_SEPARATOR; scan(basePath2, basePackageName, relativePackageName2, matcher, saveHandler); } else if (fileName.endsWith(ClassUtils.CLASS_FILE_SUFFIX)) { String className; if (relativePackageName != null) { className = basePackageName + relativePackageName + fileName.substring(0, fileName.length() - ClassUtils.CLASS_FILE_SUFFIX.length()); } else { className = basePackageName + fileName.substring(0, fileName.length() - ClassUtils.CLASS_FILE_SUFFIX.length()); } String relativePath = className.substring(basePackageName.length()); if (matcher.matches(relativePath)) { String resourceName = targetPath + fileName; Class<?> targetClass = loadClass(className); saveHandler.save(resourceName, targetClass); } } return false; }); }
[ "private", "void", "scan", "(", "final", "String", "targetPath", ",", "final", "String", "basePackageName", ",", "final", "String", "relativePackageName", ",", "final", "WildcardMatcher", "matcher", ",", "final", "SaveHandler", "saveHandler", ")", "{", "final", "F...
Recursive method used to find all classes in a given directory and sub dirs. @param targetPath the target path @param basePackageName the base package name @param relativePackageName the relative package name @param matcher the matcher @param saveHandler the save handler
[ "Recursive", "method", "used", "to", "find", "all", "classes", "in", "a", "given", "directory", "and", "sub", "dirs", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/ClassScanner.java#L139-L175
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/TypeUtils.java
TypeUtils.isAssignableValue
public static boolean isAssignableValue(Class<?> type, Object value) { if (value == null) { return !type.isPrimitive(); } Class<?> valueType = value.getClass(); if (type.isArray() || valueType.isArray()) { if ((type.isArray() && valueType.isArray())) { int len = Array.getLength(value); if (len == 0) { return true; } else { Object first = Array.get(value, 0); return isAssignableValue(type.getComponentType(), first); } } } else { if (type.isInstance(value)) { return true; } if (valueType.isPrimitive() && !type.isPrimitive() && type.equals(getPrimitiveWrapper(valueType))) { return true; } if (type.isPrimitive() && !valueType.isPrimitive() && valueType.equals(getPrimitiveWrapper(type))) { return true; } } return false; }
java
public static boolean isAssignableValue(Class<?> type, Object value) { if (value == null) { return !type.isPrimitive(); } Class<?> valueType = value.getClass(); if (type.isArray() || valueType.isArray()) { if ((type.isArray() && valueType.isArray())) { int len = Array.getLength(value); if (len == 0) { return true; } else { Object first = Array.get(value, 0); return isAssignableValue(type.getComponentType(), first); } } } else { if (type.isInstance(value)) { return true; } if (valueType.isPrimitive() && !type.isPrimitive() && type.equals(getPrimitiveWrapper(valueType))) { return true; } if (type.isPrimitive() && !valueType.isPrimitive() && valueType.equals(getPrimitiveWrapper(type))) { return true; } } return false; }
[ "public", "static", "boolean", "isAssignableValue", "(", "Class", "<", "?", ">", "type", ",", "Object", "value", ")", "{", "if", "(", "value", "==", "null", ")", "{", "return", "!", "type", ".", "isPrimitive", "(", ")", ";", "}", "Class", "<", "?", ...
Determine if the given type is assignable from the given value, assuming setting by reflection. Considers primitive wrapper classes as assignable to the corresponding primitive types. @param type the target type @param value the value that should be assigned to the type @return if the type is assignable from the value
[ "Determine", "if", "the", "given", "type", "is", "assignable", "from", "the", "given", "value", "assuming", "setting", "by", "reflection", ".", "Considers", "primitive", "wrapper", "classes", "as", "assignable", "to", "the", "corresponding", "primitive", "types", ...
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/TypeUtils.java#L136-L163
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/ReflectionUtils.java
ReflectionUtils.toComponentTypeArray
public static Object toComponentTypeArray(Object val, Class<?> componentType) { if (val != null) { int len = Array.getLength(val); Object arr = Array.newInstance(componentType, len); for (int i = 0; i < len; i++) { Array.set(arr, i, Array.get(val, i)); } return arr; } else { return null; } }
java
public static Object toComponentTypeArray(Object val, Class<?> componentType) { if (val != null) { int len = Array.getLength(val); Object arr = Array.newInstance(componentType, len); for (int i = 0; i < len; i++) { Array.set(arr, i, Array.get(val, i)); } return arr; } else { return null; } }
[ "public", "static", "Object", "toComponentTypeArray", "(", "Object", "val", ",", "Class", "<", "?", ">", "componentType", ")", "{", "if", "(", "val", "!=", "null", ")", "{", "int", "len", "=", "Array", ".", "getLength", "(", "val", ")", ";", "Object", ...
Converts an array of objects to an array of the specified component type. @param val an array of objects to be converted @param componentType the {@code Class} object representing the component type of the new array @return an array of the objects with the specified component type
[ "Converts", "an", "array", "of", "objects", "to", "an", "array", "of", "the", "specified", "component", "type", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/ReflectionUtils.java#L275-L286
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/process/result/ContentResult.java
ContentResult.addActionResult
public void addActionResult(ActionResult actionResult) { ActionResult existActionResult = getActionResult(actionResult.getActionId()); if (existActionResult != null && existActionResult.getResultValue() instanceof ResultValueMap && actionResult.getResultValue() instanceof ResultValueMap) { ResultValueMap resultValueMap = (ResultValueMap)existActionResult.getResultValue(); resultValueMap.putAll((ResultValueMap)actionResult.getResultValue()); } else { add(actionResult); } }
java
public void addActionResult(ActionResult actionResult) { ActionResult existActionResult = getActionResult(actionResult.getActionId()); if (existActionResult != null && existActionResult.getResultValue() instanceof ResultValueMap && actionResult.getResultValue() instanceof ResultValueMap) { ResultValueMap resultValueMap = (ResultValueMap)existActionResult.getResultValue(); resultValueMap.putAll((ResultValueMap)actionResult.getResultValue()); } else { add(actionResult); } }
[ "public", "void", "addActionResult", "(", "ActionResult", "actionResult", ")", "{", "ActionResult", "existActionResult", "=", "getActionResult", "(", "actionResult", ".", "getActionId", "(", ")", ")", ";", "if", "(", "existActionResult", "!=", "null", "&&", "exist...
Adds the action result. @param actionResult the action result
[ "Adds", "the", "action", "result", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/process/result/ContentResult.java#L95-L105
train
aspectran/aspectran
shell/src/main/java/com/aspectran/shell/activity/ShellActivity.java
ShellActivity.readParameters
private void readParameters() { ItemRuleMap parameterItemRuleMap = getRequestRule().getParameterItemRuleMap(); if (parameterItemRuleMap != null && !parameterItemRuleMap.isEmpty()) { ItemRuleList parameterItemRuleList = new ItemRuleList(parameterItemRuleMap.values()); determineSimpleMode(parameterItemRuleList); if (procedural) { console.setStyle("GREEN"); console.writeLine("Required parameters:"); console.styleOff(); if (!simpleInputMode) { for (ItemRule itemRule : parameterItemRuleList) { Token[] tokens = itemRule.getAllTokens(); if (tokens == null) { Token t = new Token(TokenType.PARAMETER, itemRule.getName()); t.setDefaultValue(itemRule.getDefaultValue()); tokens = new Token[] {t}; } String mandatoryMarker = itemRule.isMandatory() ? " * " : " "; console.setStyle("YELLOW"); console.write(mandatoryMarker); console.styleOff(); console.setStyle("bold"); console.write(itemRule.getName()); console.styleOff(); console.write(": "); writeToken(tokens); console.writeLine(); } } } readRequiredParameters(parameterItemRuleList); } }
java
private void readParameters() { ItemRuleMap parameterItemRuleMap = getRequestRule().getParameterItemRuleMap(); if (parameterItemRuleMap != null && !parameterItemRuleMap.isEmpty()) { ItemRuleList parameterItemRuleList = new ItemRuleList(parameterItemRuleMap.values()); determineSimpleMode(parameterItemRuleList); if (procedural) { console.setStyle("GREEN"); console.writeLine("Required parameters:"); console.styleOff(); if (!simpleInputMode) { for (ItemRule itemRule : parameterItemRuleList) { Token[] tokens = itemRule.getAllTokens(); if (tokens == null) { Token t = new Token(TokenType.PARAMETER, itemRule.getName()); t.setDefaultValue(itemRule.getDefaultValue()); tokens = new Token[] {t}; } String mandatoryMarker = itemRule.isMandatory() ? " * " : " "; console.setStyle("YELLOW"); console.write(mandatoryMarker); console.styleOff(); console.setStyle("bold"); console.write(itemRule.getName()); console.styleOff(); console.write(": "); writeToken(tokens); console.writeLine(); } } } readRequiredParameters(parameterItemRuleList); } }
[ "private", "void", "readParameters", "(", ")", "{", "ItemRuleMap", "parameterItemRuleMap", "=", "getRequestRule", "(", ")", ".", "getParameterItemRuleMap", "(", ")", ";", "if", "(", "parameterItemRuleMap", "!=", "null", "&&", "!", "parameterItemRuleMap", ".", "isE...
Read required input parameters.
[ "Read", "required", "input", "parameters", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/shell/src/main/java/com/aspectran/shell/activity/ShellActivity.java#L174-L207
train
aspectran/aspectran
shell/src/main/java/com/aspectran/shell/activity/ShellActivity.java
ShellActivity.readAttributes
private void readAttributes() { ItemRuleMap attributeItemRuleMap = getRequestRule().getAttributeItemRuleMap(); if (attributeItemRuleMap != null && !attributeItemRuleMap.isEmpty()) { ItemRuleList attributeItemRuleList = new ItemRuleList(attributeItemRuleMap.values()); determineSimpleMode(attributeItemRuleList); if (procedural) { console.setStyle("GREEN"); console.writeLine("Required attributes:"); console.styleOff(); if (!simpleInputMode) { for (ItemRule itemRule : attributeItemRuleList) { Token[] tokens = itemRule.getAllTokens(); if (tokens == null) { Token t = new Token(TokenType.PARAMETER, itemRule.getName()); t.setDefaultValue(itemRule.getDefaultValue()); tokens = new Token[] {t}; } String mandatoryMarker = itemRule.isMandatory() ? " * " : " "; console.setStyle("YELLOW"); console.write(mandatoryMarker); console.styleOff(); console.setStyle("bold"); console.write(itemRule.getName()); console.styleOff(); console.write(": "); writeToken(tokens); console.writeLine(); } } } readRequiredAttributes(attributeItemRuleList); } }
java
private void readAttributes() { ItemRuleMap attributeItemRuleMap = getRequestRule().getAttributeItemRuleMap(); if (attributeItemRuleMap != null && !attributeItemRuleMap.isEmpty()) { ItemRuleList attributeItemRuleList = new ItemRuleList(attributeItemRuleMap.values()); determineSimpleMode(attributeItemRuleList); if (procedural) { console.setStyle("GREEN"); console.writeLine("Required attributes:"); console.styleOff(); if (!simpleInputMode) { for (ItemRule itemRule : attributeItemRuleList) { Token[] tokens = itemRule.getAllTokens(); if (tokens == null) { Token t = new Token(TokenType.PARAMETER, itemRule.getName()); t.setDefaultValue(itemRule.getDefaultValue()); tokens = new Token[] {t}; } String mandatoryMarker = itemRule.isMandatory() ? " * " : " "; console.setStyle("YELLOW"); console.write(mandatoryMarker); console.styleOff(); console.setStyle("bold"); console.write(itemRule.getName()); console.styleOff(); console.write(": "); writeToken(tokens); console.writeLine(); } } } readRequiredAttributes(attributeItemRuleList); } }
[ "private", "void", "readAttributes", "(", ")", "{", "ItemRuleMap", "attributeItemRuleMap", "=", "getRequestRule", "(", ")", ".", "getAttributeItemRuleMap", "(", ")", ";", "if", "(", "attributeItemRuleMap", "!=", "null", "&&", "!", "attributeItemRuleMap", ".", "isE...
Read required input attributes.
[ "Read", "required", "input", "attributes", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/shell/src/main/java/com/aspectran/shell/activity/ShellActivity.java#L248-L281
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/component/bean/AbstractBeanFactory.java
AbstractBeanFactory.destroySingletons
private void destroySingletons() { if (log.isDebugEnabled()) { log.debug("Destroying singletons in " + this); } int failedDestroyes = 0; for (BeanRule beanRule : beanRuleRegistry.getIdBasedBeanRules()) { failedDestroyes += doDestroySingleton(beanRule); } for (Set<BeanRule> beanRuleSet : beanRuleRegistry.getTypeBasedBeanRules()) { for (BeanRule beanRule : beanRuleSet) { failedDestroyes += doDestroySingleton(beanRule); } } for (BeanRule beanRule : beanRuleRegistry.getConfigurableBeanRules()) { failedDestroyes += doDestroySingleton(beanRule); } if (failedDestroyes > 0) { log.warn("Singletons has not been destroyed cleanly (Failure Count: " + failedDestroyes + ")"); } else { log.debug("Destroyed all cached singletons in " + this); } }
java
private void destroySingletons() { if (log.isDebugEnabled()) { log.debug("Destroying singletons in " + this); } int failedDestroyes = 0; for (BeanRule beanRule : beanRuleRegistry.getIdBasedBeanRules()) { failedDestroyes += doDestroySingleton(beanRule); } for (Set<BeanRule> beanRuleSet : beanRuleRegistry.getTypeBasedBeanRules()) { for (BeanRule beanRule : beanRuleSet) { failedDestroyes += doDestroySingleton(beanRule); } } for (BeanRule beanRule : beanRuleRegistry.getConfigurableBeanRules()) { failedDestroyes += doDestroySingleton(beanRule); } if (failedDestroyes > 0) { log.warn("Singletons has not been destroyed cleanly (Failure Count: " + failedDestroyes + ")"); } else { log.debug("Destroyed all cached singletons in " + this); } }
[ "private", "void", "destroySingletons", "(", ")", "{", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Destroying singletons in \"", "+", "this", ")", ";", "}", "int", "failedDestroyes", "=", "0", ";", "for", "("...
Destroy all cached singletons.
[ "Destroy", "all", "cached", "singletons", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/component/bean/AbstractBeanFactory.java#L445-L467
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/response/transform/TransformResponseFactory.java
TransformResponseFactory.createTransformResponse
public static Response createTransformResponse(TransformRule transformRule) { TransformType transformType = transformRule.getTransformType(); Response transformResponse; if (transformType == TransformType.XSL) { transformResponse = new XslTransformResponse(transformRule); } else if (transformType == TransformType.XML) { if (transformRule.getContentType() == null) { transformRule.setContentType(ContentType.TEXT_XML.toString()); } transformResponse = new XmlTransformResponse(transformRule); } else if (transformType == TransformType.TEXT) { transformResponse = new TextTransformResponse(transformRule); } else if (transformType == TransformType.JSON) { if (transformRule.getContentType() == null) { transformRule.setContentType(ContentType.TEXT_PLAIN.toString()); } transformResponse = new JsonTransformResponse(transformRule); } else if (transformType == TransformType.APON) { if (transformRule.getContentType() == null) { transformRule.setContentType(ContentType.TEXT_PLAIN.toString()); } transformResponse = new AponTransformResponse(transformRule); } else { transformResponse = new NoneTransformResponse(transformRule); } return transformResponse; }
java
public static Response createTransformResponse(TransformRule transformRule) { TransformType transformType = transformRule.getTransformType(); Response transformResponse; if (transformType == TransformType.XSL) { transformResponse = new XslTransformResponse(transformRule); } else if (transformType == TransformType.XML) { if (transformRule.getContentType() == null) { transformRule.setContentType(ContentType.TEXT_XML.toString()); } transformResponse = new XmlTransformResponse(transformRule); } else if (transformType == TransformType.TEXT) { transformResponse = new TextTransformResponse(transformRule); } else if (transformType == TransformType.JSON) { if (transformRule.getContentType() == null) { transformRule.setContentType(ContentType.TEXT_PLAIN.toString()); } transformResponse = new JsonTransformResponse(transformRule); } else if (transformType == TransformType.APON) { if (transformRule.getContentType() == null) { transformRule.setContentType(ContentType.TEXT_PLAIN.toString()); } transformResponse = new AponTransformResponse(transformRule); } else { transformResponse = new NoneTransformResponse(transformRule); } return transformResponse; }
[ "public", "static", "Response", "createTransformResponse", "(", "TransformRule", "transformRule", ")", "{", "TransformType", "transformType", "=", "transformRule", ".", "getTransformType", "(", ")", ";", "Response", "transformResponse", ";", "if", "(", "transformType", ...
Creates a new Transform object with specified TransformRule. @param transformRule the transform rule @return the transform response
[ "Creates", "a", "new", "Transform", "object", "with", "specified", "TransformRule", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/response/transform/TransformResponseFactory.java#L36-L62
train
aspectran/aspectran
shell/src/main/java/com/aspectran/shell/command/builtins/SysInfoCommand.java
SysInfoCommand.mem
private void mem(boolean gc, Console console) { long total = Runtime.getRuntime().totalMemory(); long before = Runtime.getRuntime().freeMemory(); console.writeLine("%-24s %12s", "Total memory", StringUtils.convertToHumanFriendlyByteSize(total)); console.writeLine("%-24s %12s", "Used memory", StringUtils.convertToHumanFriendlyByteSize(total - before)); if (gc) { // Let the finalizer finish its work and remove objects from its queue System.gc(); // asynchronous garbage collector might already run System.gc(); // to make sure it does a full gc call it twice System.runFinalization(); try { Thread.sleep(100); } catch (InterruptedException e) { // do nothing } long after = Runtime.getRuntime().freeMemory(); console.writeLine("%-24s %12s", "Free memory before GC", StringUtils.convertToHumanFriendlyByteSize(before)); console.writeLine("%-24s %12s", "Free memory after GC", StringUtils.convertToHumanFriendlyByteSize(after)); console.writeLine("%-24s %12s", "Memory gained with GC", StringUtils.convertToHumanFriendlyByteSize(after - before)); } else { console.writeLine("%-24s %12s", "Free memory", StringUtils.convertToHumanFriendlyByteSize(before)); } }
java
private void mem(boolean gc, Console console) { long total = Runtime.getRuntime().totalMemory(); long before = Runtime.getRuntime().freeMemory(); console.writeLine("%-24s %12s", "Total memory", StringUtils.convertToHumanFriendlyByteSize(total)); console.writeLine("%-24s %12s", "Used memory", StringUtils.convertToHumanFriendlyByteSize(total - before)); if (gc) { // Let the finalizer finish its work and remove objects from its queue System.gc(); // asynchronous garbage collector might already run System.gc(); // to make sure it does a full gc call it twice System.runFinalization(); try { Thread.sleep(100); } catch (InterruptedException e) { // do nothing } long after = Runtime.getRuntime().freeMemory(); console.writeLine("%-24s %12s", "Free memory before GC", StringUtils.convertToHumanFriendlyByteSize(before)); console.writeLine("%-24s %12s", "Free memory after GC", StringUtils.convertToHumanFriendlyByteSize(after)); console.writeLine("%-24s %12s", "Memory gained with GC", StringUtils.convertToHumanFriendlyByteSize(after - before)); } else { console.writeLine("%-24s %12s", "Free memory", StringUtils.convertToHumanFriendlyByteSize(before)); } }
[ "private", "void", "mem", "(", "boolean", "gc", ",", "Console", "console", ")", "{", "long", "total", "=", "Runtime", ".", "getRuntime", "(", ")", ".", "totalMemory", "(", ")", ";", "long", "before", "=", "Runtime", ".", "getRuntime", "(", ")", ".", ...
Displays memory usage. @param gc true if performing garbage collection; false otherwise
[ "Displays", "memory", "usage", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/shell/src/main/java/com/aspectran/shell/command/builtins/SysInfoCommand.java#L101-L127
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/AspectranActivityContext.java
AspectranActivityContext.initMessageSource
private void initMessageSource() { if (contextBeanRegistry.containsBean(MESSAGE_SOURCE_BEAN_ID)) { messageSource = contextBeanRegistry.getBean(MESSAGE_SOURCE_BEAN_ID, MessageSource.class); if (log.isDebugEnabled()) { log.debug("Using MessageSource [" + messageSource + "]"); } } else { // Use empty MessageSource to be able to accept getMessage calls. messageSource = new DelegatingMessageSource(); if (log.isDebugEnabled()) { log.debug("Unable to locate MessageSource with name '" + MESSAGE_SOURCE_BEAN_ID + "': using default [" + messageSource + "]"); } } }
java
private void initMessageSource() { if (contextBeanRegistry.containsBean(MESSAGE_SOURCE_BEAN_ID)) { messageSource = contextBeanRegistry.getBean(MESSAGE_SOURCE_BEAN_ID, MessageSource.class); if (log.isDebugEnabled()) { log.debug("Using MessageSource [" + messageSource + "]"); } } else { // Use empty MessageSource to be able to accept getMessage calls. messageSource = new DelegatingMessageSource(); if (log.isDebugEnabled()) { log.debug("Unable to locate MessageSource with name '" + MESSAGE_SOURCE_BEAN_ID + "': using default [" + messageSource + "]"); } } }
[ "private", "void", "initMessageSource", "(", ")", "{", "if", "(", "contextBeanRegistry", ".", "containsBean", "(", "MESSAGE_SOURCE_BEAN_ID", ")", ")", "{", "messageSource", "=", "contextBeanRegistry", ".", "getBean", "(", "MESSAGE_SOURCE_BEAN_ID", ",", "MessageSource"...
Initialize the MessageSource. Use parent's if none defined in this context.
[ "Initialize", "the", "MessageSource", ".", "Use", "parent", "s", "if", "none", "defined", "in", "this", "context", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/AspectranActivityContext.java#L197-L211
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/support/i18n/locale/AbstractLocaleResolver.java
AbstractLocaleResolver.resolveDefaultLocale
protected Locale resolveDefaultLocale(Translet translet) { Locale defaultLocale = getDefaultLocale(); if (defaultLocale != null) { translet.getRequestAdapter().setLocale(defaultLocale); return defaultLocale; } else { return translet.getRequestAdapter().getLocale(); } }
java
protected Locale resolveDefaultLocale(Translet translet) { Locale defaultLocale = getDefaultLocale(); if (defaultLocale != null) { translet.getRequestAdapter().setLocale(defaultLocale); return defaultLocale; } else { return translet.getRequestAdapter().getLocale(); } }
[ "protected", "Locale", "resolveDefaultLocale", "(", "Translet", "translet", ")", "{", "Locale", "defaultLocale", "=", "getDefaultLocale", "(", ")", ";", "if", "(", "defaultLocale", "!=", "null", ")", "{", "translet", ".", "getRequestAdapter", "(", ")", ".", "s...
Resolve the default locale for the given translet, Called if can not find specified Locale. @param translet the translet to resolve the locale for @return the default locale (never {@code null}) @see #setDefaultLocale
[ "Resolve", "the", "default", "locale", "for", "the", "given", "translet", "Called", "if", "can", "not", "find", "specified", "Locale", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/support/i18n/locale/AbstractLocaleResolver.java#L98-L106
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/support/i18n/locale/AbstractLocaleResolver.java
AbstractLocaleResolver.resolveDefaultTimeZone
protected TimeZone resolveDefaultTimeZone(Translet translet) { TimeZone defaultTimeZone = getDefaultTimeZone(); if (defaultTimeZone != null) { translet.getRequestAdapter().setTimeZone(defaultTimeZone); return defaultTimeZone; } else { return translet.getRequestAdapter().getTimeZone(); } }
java
protected TimeZone resolveDefaultTimeZone(Translet translet) { TimeZone defaultTimeZone = getDefaultTimeZone(); if (defaultTimeZone != null) { translet.getRequestAdapter().setTimeZone(defaultTimeZone); return defaultTimeZone; } else { return translet.getRequestAdapter().getTimeZone(); } }
[ "protected", "TimeZone", "resolveDefaultTimeZone", "(", "Translet", "translet", ")", "{", "TimeZone", "defaultTimeZone", "=", "getDefaultTimeZone", "(", ")", ";", "if", "(", "defaultTimeZone", "!=", "null", ")", "{", "translet", ".", "getRequestAdapter", "(", ")",...
Resolve the default time zone for the given translet, Called if can not find specified TimeZone. @param translet the translet to resolve the time zone for @return the default time zone (or {@code null} if none defined) @see #setDefaultTimeZone
[ "Resolve", "the", "default", "time", "zone", "for", "the", "given", "translet", "Called", "if", "can", "not", "find", "specified", "TimeZone", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/support/i18n/locale/AbstractLocaleResolver.java#L116-L124
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/apon/AponReader.java
AponReader.parse
public static Parameters parse(String text) throws AponParseException { Parameters parameters = new VariableParameters(); return parse(text, parameters); }
java
public static Parameters parse(String text) throws AponParseException { Parameters parameters = new VariableParameters(); return parse(text, parameters); }
[ "public", "static", "Parameters", "parse", "(", "String", "text", ")", "throws", "AponParseException", "{", "Parameters", "parameters", "=", "new", "VariableParameters", "(", ")", ";", "return", "parse", "(", "text", ",", "parameters", ")", ";", "}" ]
Converts an APON formatted string into a Parameters object. @param text the APON formatted string @return the Parameters object @throws AponParseException if reading APON format document fails
[ "Converts", "an", "APON", "formatted", "string", "into", "a", "Parameters", "object", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/apon/AponReader.java#L417-L420
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/apon/AponReader.java
AponReader.parse
public static <T extends Parameters> T parse(String text, T parameters) throws AponParseException { if (text == null) { throw new IllegalArgumentException("text must not be null"); } if (parameters == null) { throw new IllegalArgumentException("parameters must not be null"); } try { AponReader aponReader = new AponReader(text); aponReader.read(parameters); aponReader.close(); return parameters; } catch (AponParseException e) { throw e; } catch (Exception e) { throw new AponParseException("Failed to parse string with APON format", e); } }
java
public static <T extends Parameters> T parse(String text, T parameters) throws AponParseException { if (text == null) { throw new IllegalArgumentException("text must not be null"); } if (parameters == null) { throw new IllegalArgumentException("parameters must not be null"); } try { AponReader aponReader = new AponReader(text); aponReader.read(parameters); aponReader.close(); return parameters; } catch (AponParseException e) { throw e; } catch (Exception e) { throw new AponParseException("Failed to parse string with APON format", e); } }
[ "public", "static", "<", "T", "extends", "Parameters", ">", "T", "parse", "(", "String", "text", ",", "T", "parameters", ")", "throws", "AponParseException", "{", "if", "(", "text", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "...
Converts an APON formatted string into a given Parameters object. @param <T> the generic type @param text the APON formatted string @param parameters the Parameters object @return the Parameters object @throws AponParseException if reading APON format document fails
[ "Converts", "an", "APON", "formatted", "string", "into", "a", "given", "Parameters", "object", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/apon/AponReader.java#L431-L448
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/apon/AponReader.java
AponReader.parse
public static Parameters parse(File file, String encoding) throws AponParseException { if (file == null) { throw new IllegalArgumentException("file must not be null"); } Parameters parameters = new VariableParameters(); return parse(file, encoding, parameters); }
java
public static Parameters parse(File file, String encoding) throws AponParseException { if (file == null) { throw new IllegalArgumentException("file must not be null"); } Parameters parameters = new VariableParameters(); return parse(file, encoding, parameters); }
[ "public", "static", "Parameters", "parse", "(", "File", "file", ",", "String", "encoding", ")", "throws", "AponParseException", "{", "if", "(", "file", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"file must not be null\"", ")", ";"...
Converts to a Parameters object from a file. @param file the file to parse @param encoding the character encoding @return the Parameters object @throws AponParseException if reading APON format document fails
[ "Converts", "to", "a", "Parameters", "object", "from", "a", "file", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/apon/AponReader.java#L469-L475
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/apon/AponReader.java
AponReader.parse
public static Parameters parse(Reader reader) throws AponParseException { if (reader == null) { throw new IllegalArgumentException("reader must not be null"); } AponReader aponReader = new AponReader(reader); return aponReader.read(); }
java
public static Parameters parse(Reader reader) throws AponParseException { if (reader == null) { throw new IllegalArgumentException("reader must not be null"); } AponReader aponReader = new AponReader(reader); return aponReader.read(); }
[ "public", "static", "Parameters", "parse", "(", "Reader", "reader", ")", "throws", "AponParseException", "{", "if", "(", "reader", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"reader must not be null\"", ")", ";", "}", "AponReader", ...
Converts to a Parameters object from a character-input stream. @param reader the character-input stream @return the Parameters object @throws AponParseException if reading APON format document fails
[ "Converts", "to", "a", "Parameters", "object", "from", "a", "character", "-", "input", "stream", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/apon/AponReader.java#L536-L542
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/apon/AponReader.java
AponReader.parse
public static <T extends Parameters> T parse(Reader reader, T parameters) throws AponParseException { AponReader aponReader = new AponReader(reader); aponReader.read(parameters); return parameters; }
java
public static <T extends Parameters> T parse(Reader reader, T parameters) throws AponParseException { AponReader aponReader = new AponReader(reader); aponReader.read(parameters); return parameters; }
[ "public", "static", "<", "T", "extends", "Parameters", ">", "T", "parse", "(", "Reader", "reader", ",", "T", "parameters", ")", "throws", "AponParseException", "{", "AponReader", "aponReader", "=", "new", "AponReader", "(", "reader", ")", ";", "aponReader", ...
Converts into a given Parameters object from a character-input stream. @param <T> the generic type @param reader the character-input stream @param parameters the Parameters object @return the Parameters object @throws AponParseException if reading APON format document fails
[ "Converts", "into", "a", "given", "Parameters", "object", "from", "a", "character", "-", "input", "stream", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/apon/AponReader.java#L553-L557
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/rule/ExceptionRule.java
ExceptionRule.putExceptionThrownRule
public void putExceptionThrownRule(ExceptionThrownRule exceptionThrownRule) { exceptionThrownRuleList.add(exceptionThrownRule); String[] exceptionTypes = exceptionThrownRule.getExceptionTypes(); if (exceptionTypes != null) { for (String exceptionType : exceptionTypes) { if (exceptionType != null) { if (!exceptionThrownRuleMap.containsKey(exceptionType)) { exceptionThrownRuleMap.put(exceptionType, exceptionThrownRule); } } } } else { defaultExceptionThrownRule = exceptionThrownRule; } }
java
public void putExceptionThrownRule(ExceptionThrownRule exceptionThrownRule) { exceptionThrownRuleList.add(exceptionThrownRule); String[] exceptionTypes = exceptionThrownRule.getExceptionTypes(); if (exceptionTypes != null) { for (String exceptionType : exceptionTypes) { if (exceptionType != null) { if (!exceptionThrownRuleMap.containsKey(exceptionType)) { exceptionThrownRuleMap.put(exceptionType, exceptionThrownRule); } } } } else { defaultExceptionThrownRule = exceptionThrownRule; } }
[ "public", "void", "putExceptionThrownRule", "(", "ExceptionThrownRule", "exceptionThrownRule", ")", "{", "exceptionThrownRuleList", ".", "add", "(", "exceptionThrownRule", ")", ";", "String", "[", "]", "exceptionTypes", "=", "exceptionThrownRule", ".", "getExceptionTypes"...
Puts the exception thrown rule. @param exceptionThrownRule the exception thrown rule
[ "Puts", "the", "exception", "thrown", "rule", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/rule/ExceptionRule.java#L55-L70
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/rule/ExceptionRule.java
ExceptionRule.getExceptionThrownRule
public ExceptionThrownRule getExceptionThrownRule(Throwable ex) { ExceptionThrownRule exceptionThrownRule = null; int deepest = Integer.MAX_VALUE; for (Map.Entry<String, ExceptionThrownRule> entry : exceptionThrownRuleMap.entrySet()) { int depth = getMatchedDepth(entry.getKey(), ex); if (depth >= 0 && depth < deepest) { deepest = depth; exceptionThrownRule = entry.getValue(); } } return (exceptionThrownRule != null ? exceptionThrownRule : defaultExceptionThrownRule); }
java
public ExceptionThrownRule getExceptionThrownRule(Throwable ex) { ExceptionThrownRule exceptionThrownRule = null; int deepest = Integer.MAX_VALUE; for (Map.Entry<String, ExceptionThrownRule> entry : exceptionThrownRuleMap.entrySet()) { int depth = getMatchedDepth(entry.getKey(), ex); if (depth >= 0 && depth < deepest) { deepest = depth; exceptionThrownRule = entry.getValue(); } } return (exceptionThrownRule != null ? exceptionThrownRule : defaultExceptionThrownRule); }
[ "public", "ExceptionThrownRule", "getExceptionThrownRule", "(", "Throwable", "ex", ")", "{", "ExceptionThrownRule", "exceptionThrownRule", "=", "null", ";", "int", "deepest", "=", "Integer", ".", "MAX_VALUE", ";", "for", "(", "Map", ".", "Entry", "<", "String", ...
Gets the exception thrown rule as specified exception. @param ex the exception @return the exception thrown rule
[ "Gets", "the", "exception", "thrown", "rule", "as", "specified", "exception", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/rule/ExceptionRule.java#L78-L89
train
aspectran/aspectran
web/src/main/java/com/aspectran/web/service/DefaultServletHttpRequestHandler.java
DefaultServletHttpRequestHandler.lookupDefaultServletName
private void lookupDefaultServletName(ServletContext servletContext) { if (servletContext.getNamedDispatcher(COMMON_DEFAULT_SERVLET_NAME) != null) { defaultServletName = COMMON_DEFAULT_SERVLET_NAME; } else if (servletContext.getNamedDispatcher(RESIN_DEFAULT_SERVLET_NAME) != null) { defaultServletName = RESIN_DEFAULT_SERVLET_NAME; } else if (servletContext.getNamedDispatcher(WEBLOGIC_DEFAULT_SERVLET_NAME) != null) { defaultServletName = WEBLOGIC_DEFAULT_SERVLET_NAME; } else if (servletContext.getNamedDispatcher(WEBSPHERE_DEFAULT_SERVLET_NAME) != null) { defaultServletName = WEBSPHERE_DEFAULT_SERVLET_NAME; } else if (servletContext.getNamedDispatcher(GAE_DEFAULT_SERVLET_NAME) != null) { defaultServletName = GAE_DEFAULT_SERVLET_NAME; } else if (servletContext.getNamedDispatcher(JEUS_DEFAULT_SERVLET_NAME) != null) { defaultServletName = JEUS_DEFAULT_SERVLET_NAME; } else { if (log.isDebugEnabled()) { log.debug("Unable to locate the default servlet for serving static content. " + "Please set the 'web.defaultServletName'."); } } }
java
private void lookupDefaultServletName(ServletContext servletContext) { if (servletContext.getNamedDispatcher(COMMON_DEFAULT_SERVLET_NAME) != null) { defaultServletName = COMMON_DEFAULT_SERVLET_NAME; } else if (servletContext.getNamedDispatcher(RESIN_DEFAULT_SERVLET_NAME) != null) { defaultServletName = RESIN_DEFAULT_SERVLET_NAME; } else if (servletContext.getNamedDispatcher(WEBLOGIC_DEFAULT_SERVLET_NAME) != null) { defaultServletName = WEBLOGIC_DEFAULT_SERVLET_NAME; } else if (servletContext.getNamedDispatcher(WEBSPHERE_DEFAULT_SERVLET_NAME) != null) { defaultServletName = WEBSPHERE_DEFAULT_SERVLET_NAME; } else if (servletContext.getNamedDispatcher(GAE_DEFAULT_SERVLET_NAME) != null) { defaultServletName = GAE_DEFAULT_SERVLET_NAME; } else if (servletContext.getNamedDispatcher(JEUS_DEFAULT_SERVLET_NAME) != null) { defaultServletName = JEUS_DEFAULT_SERVLET_NAME; } else { if (log.isDebugEnabled()) { log.debug("Unable to locate the default servlet for serving static content. " + "Please set the 'web.defaultServletName'."); } } }
[ "private", "void", "lookupDefaultServletName", "(", "ServletContext", "servletContext", ")", "{", "if", "(", "servletContext", ".", "getNamedDispatcher", "(", "COMMON_DEFAULT_SERVLET_NAME", ")", "!=", "null", ")", "{", "defaultServletName", "=", "COMMON_DEFAULT_SERVLET_NA...
Lookup default servlet name. @param servletContext the servlet context
[ "Lookup", "default", "servlet", "name", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/web/src/main/java/com/aspectran/web/service/DefaultServletHttpRequestHandler.java#L86-L105
train
aspectran/aspectran
web/src/main/java/com/aspectran/web/service/DefaultServletHttpRequestHandler.java
DefaultServletHttpRequestHandler.handle
public boolean handle(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (defaultServletName != null) { RequestDispatcher rd = servletContext.getNamedDispatcher(defaultServletName); if (rd == null) { throw new IllegalStateException("A RequestDispatcher could not be located for the default servlet '" + defaultServletName + "'"); } rd.forward(request, response); return true; } else { return false; } }
java
public boolean handle(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (defaultServletName != null) { RequestDispatcher rd = servletContext.getNamedDispatcher(defaultServletName); if (rd == null) { throw new IllegalStateException("A RequestDispatcher could not be located for the default servlet '" + defaultServletName + "'"); } rd.forward(request, response); return true; } else { return false; } }
[ "public", "boolean", "handle", "(", "HttpServletRequest", "request", ",", "HttpServletResponse", "response", ")", "throws", "ServletException", ",", "IOException", "{", "if", "(", "defaultServletName", "!=", "null", ")", "{", "RequestDispatcher", "rd", "=", "servlet...
Process the actual dispatching. @param request current HTTP servlet request @param response current HTTP servlet response @return true, if successful @throws ServletException the servlet exception @throws IOException if an input or output error occurs while the servlet is handling the HTTP request
[ "Process", "the", "actual", "dispatching", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/web/src/main/java/com/aspectran/web/service/DefaultServletHttpRequestHandler.java#L116-L129
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/PBEncryptionUtils.java
PBEncryptionUtils.encrypt
public static String encrypt(String inputString, String encryptionPassword) { return getEncryptor(encryptionPassword).encrypt(inputString); }
java
public static String encrypt(String inputString, String encryptionPassword) { return getEncryptor(encryptionPassword).encrypt(inputString); }
[ "public", "static", "String", "encrypt", "(", "String", "inputString", ",", "String", "encryptionPassword", ")", "{", "return", "getEncryptor", "(", "encryptionPassword", ")", ".", "encrypt", "(", "inputString", ")", ";", "}" ]
Encrypts the inputString using the encryption password. @param inputString the string to encrypt @param encryptionPassword the password to be used for encryption @return the encrypted string
[ "Encrypts", "the", "inputString", "using", "the", "encryption", "password", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/PBEncryptionUtils.java#L74-L76
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/PBEncryptionUtils.java
PBEncryptionUtils.decrypt
public static String decrypt(String inputString, String encryptionPassword) { checkPassword(encryptionPassword); return getEncryptor(encryptionPassword).decrypt(inputString); }
java
public static String decrypt(String inputString, String encryptionPassword) { checkPassword(encryptionPassword); return getEncryptor(encryptionPassword).decrypt(inputString); }
[ "public", "static", "String", "decrypt", "(", "String", "inputString", ",", "String", "encryptionPassword", ")", "{", "checkPassword", "(", "encryptionPassword", ")", ";", "return", "getEncryptor", "(", "encryptionPassword", ")", ".", "decrypt", "(", "inputString", ...
Decrypts the inputString using the encryption password. @param inputString the key used to originally encrypt the string @param encryptionPassword the password to be used for encryption @return the decrypted version of inputString
[ "Decrypts", "the", "inputString", "using", "the", "encryption", "password", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/PBEncryptionUtils.java#L95-L98
train
aspectran/aspectran
web/src/main/java/com/aspectran/web/adapter/HttpSessionAdapter.java
HttpSessionAdapter.newHttpSessionScope
private void newHttpSessionScope() { SessionScopeAdvisor advisor = SessionScopeAdvisor.create(context); this.sessionScope = new HttpSessionScope(advisor); setAttribute(SESSION_SCOPE_ATTRIBUTE_NAME, this.sessionScope); }
java
private void newHttpSessionScope() { SessionScopeAdvisor advisor = SessionScopeAdvisor.create(context); this.sessionScope = new HttpSessionScope(advisor); setAttribute(SESSION_SCOPE_ATTRIBUTE_NAME, this.sessionScope); }
[ "private", "void", "newHttpSessionScope", "(", ")", "{", "SessionScopeAdvisor", "advisor", "=", "SessionScopeAdvisor", ".", "create", "(", "context", ")", ";", "this", ".", "sessionScope", "=", "new", "HttpSessionScope", "(", "advisor", ")", ";", "setAttribute", ...
Creates a new HTTP session scope.
[ "Creates", "a", "new", "HTTP", "session", "scope", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/web/src/main/java/com/aspectran/web/adapter/HttpSessionAdapter.java#L156-L160
train
aspectran/aspectran
shell/src/main/java/com/aspectran/shell/command/option/DefaultOptionParser.java
DefaultOptionParser.handleUnknownToken
private void handleUnknownToken(String token) throws OptionParserException { if (token.startsWith("-") && token.length() > 1 && !skipParsingAtNonOption) { throw new UnrecognizedOptionException("Unrecognized option: " + token, token); } parsedOptions.addArg(token); }
java
private void handleUnknownToken(String token) throws OptionParserException { if (token.startsWith("-") && token.length() > 1 && !skipParsingAtNonOption) { throw new UnrecognizedOptionException("Unrecognized option: " + token, token); } parsedOptions.addArg(token); }
[ "private", "void", "handleUnknownToken", "(", "String", "token", ")", "throws", "OptionParserException", "{", "if", "(", "token", ".", "startsWith", "(", "\"-\"", ")", "&&", "token", ".", "length", "(", ")", ">", "1", "&&", "!", "skipParsingAtNonOption", ")"...
Handles an unknown token. If the token starts with a dash an UnrecognizedOptionException is thrown. Otherwise the token is added to the arguments of the command line. If the skipParsingAtNonOption flag is set, this stops the parsing and the remaining tokens are added as-is in the arguments of the command line. @param token the command line token to handle @throws OptionParserException if option parsing fails
[ "Handles", "an", "unknown", "token", ".", "If", "the", "token", "starts", "with", "a", "dash", "an", "UnrecognizedOptionException", "is", "thrown", ".", "Otherwise", "the", "token", "is", "added", "to", "the", "arguments", "of", "the", "command", "line", "."...
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/shell/src/main/java/com/aspectran/shell/command/option/DefaultOptionParser.java#L392-L397
train
aspectran/aspectran
shell/src/main/java/com/aspectran/shell/command/option/DefaultOptionParser.java
DefaultOptionParser.getMatchingLongOptions
private List<String> getMatchingLongOptions(String token) { if (allowPartialMatching) { return options.getMatchingOptions(token); } else { List<String> matches = new ArrayList<>(1); if (options.hasLongOption(token)) { Option option = options.getOption(token); matches.add(option.getLongName()); } return matches; } }
java
private List<String> getMatchingLongOptions(String token) { if (allowPartialMatching) { return options.getMatchingOptions(token); } else { List<String> matches = new ArrayList<>(1); if (options.hasLongOption(token)) { Option option = options.getOption(token); matches.add(option.getLongName()); } return matches; } }
[ "private", "List", "<", "String", ">", "getMatchingLongOptions", "(", "String", "token", ")", "{", "if", "(", "allowPartialMatching", ")", "{", "return", "options", ".", "getMatchingOptions", "(", "token", ")", ";", "}", "else", "{", "List", "<", "String", ...
Returns a list of matching option strings for the given token, depending on the selected partial matching policy. @param token the token (may contain leading dashes) @return the list of matching option strings or an empty list if no matching option could be found
[ "Returns", "a", "list", "of", "matching", "option", "strings", "for", "the", "given", "token", "depending", "on", "the", "selected", "partial", "matching", "policy", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/shell/src/main/java/com/aspectran/shell/command/option/DefaultOptionParser.java#L538-L549
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/BeanDescriptor.java
BeanDescriptor.getAllMethods
private Method[] getAllMethods(Class<?> beanClass) { Map<String, Method> uniqueMethods = new HashMap<>(); Class<?> currentClass = beanClass; while (currentClass != null && currentClass != Object.class) { addUniqueMethods(uniqueMethods, currentClass.getDeclaredMethods()); // we also need to look for interface methods - // because the class may be abstract Class<?>[] interfaces = currentClass.getInterfaces(); for (Class<?> anInterface : interfaces) { addUniqueMethods(uniqueMethods, anInterface.getMethods()); } currentClass = currentClass.getSuperclass(); } Collection<Method> methods = uniqueMethods.values(); return methods.toArray(new Method[0]); }
java
private Method[] getAllMethods(Class<?> beanClass) { Map<String, Method> uniqueMethods = new HashMap<>(); Class<?> currentClass = beanClass; while (currentClass != null && currentClass != Object.class) { addUniqueMethods(uniqueMethods, currentClass.getDeclaredMethods()); // we also need to look for interface methods - // because the class may be abstract Class<?>[] interfaces = currentClass.getInterfaces(); for (Class<?> anInterface : interfaces) { addUniqueMethods(uniqueMethods, anInterface.getMethods()); } currentClass = currentClass.getSuperclass(); } Collection<Method> methods = uniqueMethods.values(); return methods.toArray(new Method[0]); }
[ "private", "Method", "[", "]", "getAllMethods", "(", "Class", "<", "?", ">", "beanClass", ")", "{", "Map", "<", "String", ",", "Method", ">", "uniqueMethods", "=", "new", "HashMap", "<>", "(", ")", ";", "Class", "<", "?", ">", "currentClass", "=", "b...
This method returns an array containing all methods exposed in this class and any superclass. In the future, Java is not pleased to have access to private or protected methods. @param beanClass the class @return an array containing all the public methods in this class
[ "This", "method", "returns", "an", "array", "containing", "all", "methods", "exposed", "in", "this", "class", "and", "any", "superclass", ".", "In", "the", "future", "Java", "is", "not", "pleased", "to", "have", "access", "to", "private", "or", "protected", ...
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/BeanDescriptor.java#L177-L193
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/BeanDescriptor.java
BeanDescriptor.getGetter
public Method getGetter(String name) throws NoSuchMethodException { Method method = getterMethods.get(name); if (method == null) { throw new NoSuchMethodException("There is no READABLE property named '" + name + "' in class '" + className + "'"); } return method; }
java
public Method getGetter(String name) throws NoSuchMethodException { Method method = getterMethods.get(name); if (method == null) { throw new NoSuchMethodException("There is no READABLE property named '" + name + "' in class '" + className + "'"); } return method; }
[ "public", "Method", "getGetter", "(", "String", "name", ")", "throws", "NoSuchMethodException", "{", "Method", "method", "=", "getterMethods", ".", "get", "(", "name", ")", ";", "if", "(", "method", "==", "null", ")", "{", "throw", "new", "NoSuchMethodExcept...
Gets the getter for a property as a Method object. @param name the name of the property @return the getter Method @throws NoSuchMethodException when a getter method cannot be found
[ "Gets", "the", "getter", "for", "a", "property", "as", "a", "Method", "object", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/BeanDescriptor.java#L245-L252
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/BeanDescriptor.java
BeanDescriptor.getSetter
public Method getSetter(String name) throws NoSuchMethodException { Method method = setterMethods.get(name); if (method == null) { throw new NoSuchMethodException("There is no WRITABLE property named '" + name + "' in class '" + className + "'"); } return method; }
java
public Method getSetter(String name) throws NoSuchMethodException { Method method = setterMethods.get(name); if (method == null) { throw new NoSuchMethodException("There is no WRITABLE property named '" + name + "' in class '" + className + "'"); } return method; }
[ "public", "Method", "getSetter", "(", "String", "name", ")", "throws", "NoSuchMethodException", "{", "Method", "method", "=", "setterMethods", ".", "get", "(", "name", ")", ";", "if", "(", "method", "==", "null", ")", "{", "throw", "new", "NoSuchMethodExcept...
Gets the setter for a property as a Method object. @param name the name of the property @return the setter method @throws NoSuchMethodException when a setter method cannot be found
[ "Gets", "the", "setter", "for", "a", "property", "as", "a", "Method", "object", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/BeanDescriptor.java#L261-L268
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/BeanDescriptor.java
BeanDescriptor.getGetterType
public Class<?> getGetterType(String name) throws NoSuchMethodException { Class<?> type = getterTypes.get(name); if (type == null) { throw new NoSuchMethodException("There is no READABLE property named '" + name + "' in class '" + className + "'"); } return type; }
java
public Class<?> getGetterType(String name) throws NoSuchMethodException { Class<?> type = getterTypes.get(name); if (type == null) { throw new NoSuchMethodException("There is no READABLE property named '" + name + "' in class '" + className + "'"); } return type; }
[ "public", "Class", "<", "?", ">", "getGetterType", "(", "String", "name", ")", "throws", "NoSuchMethodException", "{", "Class", "<", "?", ">", "type", "=", "getterTypes", ".", "get", "(", "name", ")", ";", "if", "(", "type", "==", "null", ")", "{", "...
Gets the type for a property getter. @param name the name of the property @return the Class of the property getter @throws NoSuchMethodException when a getter method cannot be found
[ "Gets", "the", "type", "for", "a", "property", "getter", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/BeanDescriptor.java#L277-L284
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/BeanDescriptor.java
BeanDescriptor.getSetterType
public Class<?> getSetterType(String name) throws NoSuchMethodException { Class<?> type = setterTypes.get(name); if (type == null) { throw new NoSuchMethodException("There is no WRITABLE property named '" + name + "' in class '" + className + "'"); } return type; }
java
public Class<?> getSetterType(String name) throws NoSuchMethodException { Class<?> type = setterTypes.get(name); if (type == null) { throw new NoSuchMethodException("There is no WRITABLE property named '" + name + "' in class '" + className + "'"); } return type; }
[ "public", "Class", "<", "?", ">", "getSetterType", "(", "String", "name", ")", "throws", "NoSuchMethodException", "{", "Class", "<", "?", ">", "type", "=", "setterTypes", ".", "get", "(", "name", ")", ";", "if", "(", "type", "==", "null", ")", "{", "...
Gets the type for a property setter. @param name the name of the property @return the Class of the property setter @throws NoSuchMethodException when a setter method cannot be found
[ "Gets", "the", "type", "for", "a", "property", "setter", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/BeanDescriptor.java#L293-L300
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/BeanDescriptor.java
BeanDescriptor.getInstance
public static BeanDescriptor getInstance(Class<?> type) { BeanDescriptor bd = cache.get(type); if (bd == null) { bd = new BeanDescriptor(type); BeanDescriptor existing = cache.putIfAbsent(type, bd); if (existing != null) { bd = existing; } } return bd; }
java
public static BeanDescriptor getInstance(Class<?> type) { BeanDescriptor bd = cache.get(type); if (bd == null) { bd = new BeanDescriptor(type); BeanDescriptor existing = cache.putIfAbsent(type, bd); if (existing != null) { bd = existing; } } return bd; }
[ "public", "static", "BeanDescriptor", "getInstance", "(", "Class", "<", "?", ">", "type", ")", "{", "BeanDescriptor", "bd", "=", "cache", ".", "get", "(", "type", ")", ";", "if", "(", "bd", "==", "null", ")", "{", "bd", "=", "new", "BeanDescriptor", ...
Gets an instance of ClassDescriptor for the specified class. @param type the class for which to lookup the method cache @return the method cache for the class
[ "Gets", "an", "instance", "of", "ClassDescriptor", "for", "the", "specified", "class", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/BeanDescriptor.java#L399-L409
train
aspectran/aspectran
shell/src/main/java/com/aspectran/shell/command/option/ParsedOptions.java
ParsedOptions.resolveOption
private Option resolveOption(String name) { name = OptionUtils.stripLeadingHyphens(name); for (Option option : options) { if (name.equals(option.getName())) { return option; } if (name.equals(option.getLongName())) { return option; } } return null; }
java
private Option resolveOption(String name) { name = OptionUtils.stripLeadingHyphens(name); for (Option option : options) { if (name.equals(option.getName())) { return option; } if (name.equals(option.getLongName())) { return option; } } return null; }
[ "private", "Option", "resolveOption", "(", "String", "name", ")", "{", "name", "=", "OptionUtils", ".", "stripLeadingHyphens", "(", "name", ")", ";", "for", "(", "Option", "option", ":", "options", ")", "{", "if", "(", "name", ".", "equals", "(", "option...
Retrieves the option object given the long or short option as a String. @param name the short or long name of the option @return the canonicalized option
[ "Retrieves", "the", "option", "object", "given", "the", "long", "or", "short", "option", "as", "a", "String", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/shell/src/main/java/com/aspectran/shell/command/option/ParsedOptions.java#L295-L306
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/rule/IncludeActionRule.java
IncludeActionRule.newInstance
public static IncludeActionRule newInstance(String id, String transletName, String method, Boolean hidden) throws IllegalRuleException { if (transletName == null) { throw new IllegalRuleException("The 'include' element requires a 'translet' attribute"); } MethodType methodType = MethodType.resolve(method); if (method != null && methodType == null) { throw new IllegalRuleException("No request method type for '" + method + "'"); } IncludeActionRule includeActionRule = new IncludeActionRule(); includeActionRule.setActionId(id); includeActionRule.setTransletName(transletName); includeActionRule.setMethodType(methodType); includeActionRule.setHidden(hidden); return includeActionRule; }
java
public static IncludeActionRule newInstance(String id, String transletName, String method, Boolean hidden) throws IllegalRuleException { if (transletName == null) { throw new IllegalRuleException("The 'include' element requires a 'translet' attribute"); } MethodType methodType = MethodType.resolve(method); if (method != null && methodType == null) { throw new IllegalRuleException("No request method type for '" + method + "'"); } IncludeActionRule includeActionRule = new IncludeActionRule(); includeActionRule.setActionId(id); includeActionRule.setTransletName(transletName); includeActionRule.setMethodType(methodType); includeActionRule.setHidden(hidden); return includeActionRule; }
[ "public", "static", "IncludeActionRule", "newInstance", "(", "String", "id", ",", "String", "transletName", ",", "String", "method", ",", "Boolean", "hidden", ")", "throws", "IllegalRuleException", "{", "if", "(", "transletName", "==", "null", ")", "{", "throw",...
Returns a new instance of IncludeActionRule. @param id the action id @param transletName the translet name @param method the request method type @param hidden whether to hide result of the action @return the include action rule @throws IllegalRuleException if an illegal rule is found
[ "Returns", "a", "new", "instance", "of", "IncludeActionRule", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/rule/IncludeActionRule.java#L223-L240
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/FileLocker.java
FileLocker.lock
public boolean lock() throws Exception { synchronized (this) { if (fileLock != null) { throw new Exception("The lock is already held"); } if (log.isDebugEnabled()) { log.debug("Acquiring lock on " + lockFile.getAbsolutePath()); } try { fileChannel = new RandomAccessFile(lockFile, "rw").getChannel(); fileLock = fileChannel.tryLock(); } catch (OverlappingFileLockException | IOException e) { throw new Exception("Exception occurred while trying to get a lock on file: " + lockFile.getAbsolutePath(), e); } if (fileLock == null) { if (fileChannel != null) { try { fileChannel.close(); } catch (IOException ie) { // ignore } fileChannel = null; } return false; } else { return true; } } }
java
public boolean lock() throws Exception { synchronized (this) { if (fileLock != null) { throw new Exception("The lock is already held"); } if (log.isDebugEnabled()) { log.debug("Acquiring lock on " + lockFile.getAbsolutePath()); } try { fileChannel = new RandomAccessFile(lockFile, "rw").getChannel(); fileLock = fileChannel.tryLock(); } catch (OverlappingFileLockException | IOException e) { throw new Exception("Exception occurred while trying to get a lock on file: " + lockFile.getAbsolutePath(), e); } if (fileLock == null) { if (fileChannel != null) { try { fileChannel.close(); } catch (IOException ie) { // ignore } fileChannel = null; } return false; } else { return true; } } }
[ "public", "boolean", "lock", "(", ")", "throws", "Exception", "{", "synchronized", "(", "this", ")", "{", "if", "(", "fileLock", "!=", "null", ")", "{", "throw", "new", "Exception", "(", "\"The lock is already held\"", ")", ";", "}", "if", "(", "log", "....
Try to lock the file and return true if the locking succeeds. @return true if the locking succeeds; false if the lock is already held @throws Exception if the lock could not be obtained for any reason
[ "Try", "to", "lock", "the", "file", "and", "return", "true", "if", "the", "locking", "succeeds", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/FileLocker.java#L62-L91
train
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/FileLocker.java
FileLocker.release
public void release() throws Exception { synchronized (this) { if (log.isDebugEnabled()) { log.debug("Releasing lock on " + lockFile.getAbsolutePath()); } if (fileLock != null) { try { fileLock.release(); fileLock = null; } catch (Exception e) { throw new Exception("Unable to release locked file: " + lockFile.getAbsolutePath(), e); } if (fileChannel != null) { try { fileChannel.close(); } catch (IOException e) { // ignore } fileChannel = null; } if (lockFile != null) { if (lockFile.exists()) { lockFile.delete(); } lockFile = null; } } } }
java
public void release() throws Exception { synchronized (this) { if (log.isDebugEnabled()) { log.debug("Releasing lock on " + lockFile.getAbsolutePath()); } if (fileLock != null) { try { fileLock.release(); fileLock = null; } catch (Exception e) { throw new Exception("Unable to release locked file: " + lockFile.getAbsolutePath(), e); } if (fileChannel != null) { try { fileChannel.close(); } catch (IOException e) { // ignore } fileChannel = null; } if (lockFile != null) { if (lockFile.exists()) { lockFile.delete(); } lockFile = null; } } } }
[ "public", "void", "release", "(", ")", "throws", "Exception", "{", "synchronized", "(", "this", ")", "{", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Releasing lock on \"", "+", "lockFile", ".", "getAbsolutePat...
Releases the lock. @throws Exception if the lock could not be released for any reason
[ "Releases", "the", "lock", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/FileLocker.java#L98-L126
train
meltmedia/cadmium
servlets/src/main/java/com/meltmedia/cadmium/servlets/jersey/ApiEndpointControllerService.java
ApiEndpointControllerService.get
@GET @Produces(MediaType.APPLICATION_JSON) public String[] get(@HeaderParam("Authorization") @DefaultValue("no token") String auth) throws Exception { if(!this.isAuth(auth)) { throw new Exception("Unauthorized!"); } return controller.getDisabled(); }
java
@GET @Produces(MediaType.APPLICATION_JSON) public String[] get(@HeaderParam("Authorization") @DefaultValue("no token") String auth) throws Exception { if(!this.isAuth(auth)) { throw new Exception("Unauthorized!"); } return controller.getDisabled(); }
[ "@", "GET", "@", "Produces", "(", "MediaType", ".", "APPLICATION_JSON", ")", "public", "String", "[", "]", "get", "(", "@", "HeaderParam", "(", "\"Authorization\"", ")", "@", "DefaultValue", "(", "\"no token\"", ")", "String", "auth", ")", "throws", "Excepti...
Retrieves a list of already disabled endpoints. @param auth @return @throws Exception
[ "Retrieves", "a", "list", "of", "already", "disabled", "endpoints", "." ]
bca585030e141803a73b58abb128d130157b6ddf
https://github.com/meltmedia/cadmium/blob/bca585030e141803a73b58abb128d130157b6ddf/servlets/src/main/java/com/meltmedia/cadmium/servlets/jersey/ApiEndpointControllerService.java#L64-L71
train
meltmedia/cadmium
servlets/src/main/java/com/meltmedia/cadmium/servlets/jersey/ApiEndpointControllerService.java
ApiEndpointControllerService.sendJGroupsMessage
private void sendJGroupsMessage(UpdateOpteration operation, String path, String auth) throws Exception { if(!this.isAuth(auth)) { throw new Exception("Unauthorized!"); } log.trace("Sending jGroups message with operation {} and path {}", operation, path); ApiEndpointAccessRequest messageBody = new ApiEndpointAccessRequest(); messageBody.setEndpoint(path); messageBody.setOperation(operation); Message<ApiEndpointAccessRequest> msg = new Message<ApiEndpointAccessRequest>(ProtocolMessage.API_ENDPOINT_ACCESS, messageBody); log.trace("Sending jgroups message: "+msg); sender.sendMessage(msg, null); }
java
private void sendJGroupsMessage(UpdateOpteration operation, String path, String auth) throws Exception { if(!this.isAuth(auth)) { throw new Exception("Unauthorized!"); } log.trace("Sending jGroups message with operation {} and path {}", operation, path); ApiEndpointAccessRequest messageBody = new ApiEndpointAccessRequest(); messageBody.setEndpoint(path); messageBody.setOperation(operation); Message<ApiEndpointAccessRequest> msg = new Message<ApiEndpointAccessRequest>(ProtocolMessage.API_ENDPOINT_ACCESS, messageBody); log.trace("Sending jgroups message: "+msg); sender.sendMessage(msg, null); }
[ "private", "void", "sendJGroupsMessage", "(", "UpdateOpteration", "operation", ",", "String", "path", ",", "String", "auth", ")", "throws", "Exception", "{", "if", "(", "!", "this", ".", "isAuth", "(", "auth", ")", ")", "{", "throw", "new", "Exception", "(...
Sends jgroups message to make sure that this operation is executed on all nodes in the cluster. @param operation @param paths @param auth @throws Exception
[ "Sends", "jgroups", "message", "to", "make", "sure", "that", "this", "operation", "is", "executed", "on", "all", "nodes", "in", "the", "cluster", "." ]
bca585030e141803a73b58abb128d130157b6ddf
https://github.com/meltmedia/cadmium/blob/bca585030e141803a73b58abb128d130157b6ddf/servlets/src/main/java/com/meltmedia/cadmium/servlets/jersey/ApiEndpointControllerService.java#L106-L118
train
datasalt/pangool
core/src/main/java/com/datasalt/pangool/tuplemr/TupleMRConfig.java
TupleMRConfig.getIntermediateSchema
public Schema getIntermediateSchema(String schemaName) { Integer id = getSchemaIdByName(schemaName); return (id == null) ? null : schemas.get(id); }
java
public Schema getIntermediateSchema(String schemaName) { Integer id = getSchemaIdByName(schemaName); return (id == null) ? null : schemas.get(id); }
[ "public", "Schema", "getIntermediateSchema", "(", "String", "schemaName", ")", "{", "Integer", "id", "=", "getSchemaIdByName", "(", "schemaName", ")", ";", "return", "(", "id", "==", "null", ")", "?", "null", ":", "schemas", ".", "get", "(", "id", ")", "...
Returns a defined intermediate schema with the specified name
[ "Returns", "a", "defined", "intermediate", "schema", "with", "the", "specified", "name" ]
bfd312dd78cba03febaf7988ae96a3d4bc585408
https://github.com/datasalt/pangool/blob/bfd312dd78cba03febaf7988ae96a3d4bc585408/core/src/main/java/com/datasalt/pangool/tuplemr/TupleMRConfig.java#L114-L117
train
datasalt/pangool
core/src/main/java/com/datasalt/pangool/tuplemr/TupleMRConfig.java
TupleMRConfig.calculateRollupBaseFields
public List<String> calculateRollupBaseFields() { if(rollupFrom == null) { return getGroupByFields(); } List<String> result = new ArrayList<String>(); for(SortElement element : commonCriteria.getElements()) { result.add(element.getName()); if(element.getName().equals(rollupFrom)) { break; } } return result; }
java
public List<String> calculateRollupBaseFields() { if(rollupFrom == null) { return getGroupByFields(); } List<String> result = new ArrayList<String>(); for(SortElement element : commonCriteria.getElements()) { result.add(element.getName()); if(element.getName().equals(rollupFrom)) { break; } } return result; }
[ "public", "List", "<", "String", ">", "calculateRollupBaseFields", "(", ")", "{", "if", "(", "rollupFrom", "==", "null", ")", "{", "return", "getGroupByFields", "(", ")", ";", "}", "List", "<", "String", ">", "result", "=", "new", "ArrayList", "<", "Stri...
Returns the fields that are a subset from the groupBy fields and will be used when rollup is needed. @see RollupReducer
[ "Returns", "the", "fields", "that", "are", "a", "subset", "from", "the", "groupBy", "fields", "and", "will", "be", "used", "when", "rollup", "is", "needed", "." ]
bfd312dd78cba03febaf7988ae96a3d4bc585408
https://github.com/datasalt/pangool/blob/bfd312dd78cba03febaf7988ae96a3d4bc585408/core/src/main/java/com/datasalt/pangool/tuplemr/TupleMRConfig.java#L239-L252
train
datasalt/pangool
core/src/main/java/com/datasalt/pangool/tuplemr/TupleMRConfig.java
TupleMRConfig.set
public static Set<String> set(TupleMRConfig mrConfig, Configuration conf) throws TupleMRException { conf.set(CONF_PANGOOL_CONF, mrConfig.toString()); return serializeComparators(mrConfig, conf); }
java
public static Set<String> set(TupleMRConfig mrConfig, Configuration conf) throws TupleMRException { conf.set(CONF_PANGOOL_CONF, mrConfig.toString()); return serializeComparators(mrConfig, conf); }
[ "public", "static", "Set", "<", "String", ">", "set", "(", "TupleMRConfig", "mrConfig", ",", "Configuration", "conf", ")", "throws", "TupleMRException", "{", "conf", ".", "set", "(", "CONF_PANGOOL_CONF", ",", "mrConfig", ".", "toString", "(", ")", ")", ";", ...
Returns the instance files generated.
[ "Returns", "the", "instance", "files", "generated", "." ]
bfd312dd78cba03febaf7988ae96a3d4bc585408
https://github.com/datasalt/pangool/blob/bfd312dd78cba03febaf7988ae96a3d4bc585408/core/src/main/java/com/datasalt/pangool/tuplemr/TupleMRConfig.java#L335-L339
train
datasalt/pangool
core/src/main/java/com/datasalt/pangool/tuplemr/TupleMRConfig.java
TupleMRConfig.serializeComparators
static Set<String> serializeComparators(Criteria criteria, Configuration conf, List<String> comparatorRefs, List<String> comparatorInstanceFiles, String prefix) throws TupleMRException { Set<String> instanceFiles = new HashSet<String>(); if(criteria == null) { return instanceFiles; } for(SortElement element : criteria.getElements()) { if(element.getCustomComparator() != null) { RawComparator<?> comparator = element.getCustomComparator(); if(!(comparator instanceof Serializable)) { throw new TupleMRException("The class '" + comparator.getClass().getName() + "' is not Serializable." + " The customs comparators must implement Serializable."); } String ref = prefix + "|" + element.getName(); String uniqueName = UUID.randomUUID().toString() + '.' + "comparator.dat"; try { InstancesDistributor.distribute(comparator, uniqueName, conf); instanceFiles.add(uniqueName); } catch(Exception e) { throw new TupleMRException("The class " + comparator.getClass().getName() + " can't be serialized" ,e); } comparatorRefs.add(ref); comparatorInstanceFiles.add(uniqueName); } } return instanceFiles; }
java
static Set<String> serializeComparators(Criteria criteria, Configuration conf, List<String> comparatorRefs, List<String> comparatorInstanceFiles, String prefix) throws TupleMRException { Set<String> instanceFiles = new HashSet<String>(); if(criteria == null) { return instanceFiles; } for(SortElement element : criteria.getElements()) { if(element.getCustomComparator() != null) { RawComparator<?> comparator = element.getCustomComparator(); if(!(comparator instanceof Serializable)) { throw new TupleMRException("The class '" + comparator.getClass().getName() + "' is not Serializable." + " The customs comparators must implement Serializable."); } String ref = prefix + "|" + element.getName(); String uniqueName = UUID.randomUUID().toString() + '.' + "comparator.dat"; try { InstancesDistributor.distribute(comparator, uniqueName, conf); instanceFiles.add(uniqueName); } catch(Exception e) { throw new TupleMRException("The class " + comparator.getClass().getName() + " can't be serialized" ,e); } comparatorRefs.add(ref); comparatorInstanceFiles.add(uniqueName); } } return instanceFiles; }
[ "static", "Set", "<", "String", ">", "serializeComparators", "(", "Criteria", "criteria", ",", "Configuration", "conf", ",", "List", "<", "String", ">", "comparatorRefs", ",", "List", "<", "String", ">", "comparatorInstanceFiles", ",", "String", "prefix", ")", ...
Returns the instance files created
[ "Returns", "the", "instance", "files", "created" ]
bfd312dd78cba03febaf7988ae96a3d4bc585408
https://github.com/datasalt/pangool/blob/bfd312dd78cba03febaf7988ae96a3d4bc585408/core/src/main/java/com/datasalt/pangool/tuplemr/TupleMRConfig.java#L390-L427
train
datasalt/pangool
core/src/main/java/com/datasalt/pangool/tuplemr/TupleMRConfig.java
TupleMRConfig.parse
public static TupleMRConfig parse(String s) throws IOException { return parse(FACTORY.createJsonParser(new StringReader(s))); }
java
public static TupleMRConfig parse(String s) throws IOException { return parse(FACTORY.createJsonParser(new StringReader(s))); }
[ "public", "static", "TupleMRConfig", "parse", "(", "String", "s", ")", "throws", "IOException", "{", "return", "parse", "(", "FACTORY", ".", "createJsonParser", "(", "new", "StringReader", "(", "s", ")", ")", ")", ";", "}" ]
Parse a schema from the provided string. If named, the schema is added to the names known to this parser.
[ "Parse", "a", "schema", "from", "the", "provided", "string", ".", "If", "named", "the", "schema", "is", "added", "to", "the", "names", "known", "to", "this", "parser", "." ]
bfd312dd78cba03febaf7988ae96a3d4bc585408
https://github.com/datasalt/pangool/blob/bfd312dd78cba03febaf7988ae96a3d4bc585408/core/src/main/java/com/datasalt/pangool/tuplemr/TupleMRConfig.java#L607-L609
train
EXIficient/exificient-core
src/main/java/com/siemens/ct/exi/core/FidelityOptions.java
FidelityOptions.setFidelity
public void setFidelity(String key, boolean decision) throws UnsupportedOption { if (key.equals(FEATURE_STRICT)) { if (decision) { // no other features allowed // (LEXICAL_VALUE is an exception) boolean prevContainedLexVal = options .contains(FEATURE_LEXICAL_VALUE); options.clear(); isComment = false; isPI = false; isDTD = false; isPrefix = false; isLexicalValue = false; isSC = false; if (prevContainedLexVal) { options.add(FEATURE_LEXICAL_VALUE); isLexicalValue = true; } options.add(FEATURE_STRICT); isStrict = true; } else { // remove strict (if present) options.remove(key); isStrict = false; } } else if (key.equals(FEATURE_LEXICAL_VALUE)) { // LEXICAL_VALUE is special --> does affect grammars if (decision) { options.add(key); isLexicalValue = true; } else { // remove option (if present) options.remove(key); isLexicalValue = false; } } else if (key.equals(FEATURE_COMMENT) || key.equals(FEATURE_PI) || key.equals(FEATURE_DTD) || key.equals(FEATURE_PREFIX) || key.equals(FEATURE_SC)) { if (decision) { if (isStrict()) { options.remove(FEATURE_STRICT); this.isStrict = false; // TODO inform user that STRICT mode is de-activated // throw new UnsupportedOption( // "StrictMode is exclusive and does not allow any other option."); } options.add(key); if (key.equals(FEATURE_COMMENT)) { isComment = true; } if (key.equals(FEATURE_PI)) { isPI = true; } if (key.equals(FEATURE_DTD)) { isDTD = true; } if (key.equals(FEATURE_PREFIX)) { isPrefix = true; } if (key.equals(FEATURE_SC)) { isSC = true; } } else { // remove option (if present) options.remove(key); if (key.equals(FEATURE_COMMENT)) { isComment = false; } if (key.equals(FEATURE_PI)) { isPI = false; } if (key.equals(FEATURE_DTD)) { isDTD = false; } if (key.equals(FEATURE_PREFIX)) { isPrefix = false; } if (key.equals(FEATURE_SC)) { isSC = false; } } } else { throw new UnsupportedOption("FidelityOption '" + key + "' is unknown!"); } }
java
public void setFidelity(String key, boolean decision) throws UnsupportedOption { if (key.equals(FEATURE_STRICT)) { if (decision) { // no other features allowed // (LEXICAL_VALUE is an exception) boolean prevContainedLexVal = options .contains(FEATURE_LEXICAL_VALUE); options.clear(); isComment = false; isPI = false; isDTD = false; isPrefix = false; isLexicalValue = false; isSC = false; if (prevContainedLexVal) { options.add(FEATURE_LEXICAL_VALUE); isLexicalValue = true; } options.add(FEATURE_STRICT); isStrict = true; } else { // remove strict (if present) options.remove(key); isStrict = false; } } else if (key.equals(FEATURE_LEXICAL_VALUE)) { // LEXICAL_VALUE is special --> does affect grammars if (decision) { options.add(key); isLexicalValue = true; } else { // remove option (if present) options.remove(key); isLexicalValue = false; } } else if (key.equals(FEATURE_COMMENT) || key.equals(FEATURE_PI) || key.equals(FEATURE_DTD) || key.equals(FEATURE_PREFIX) || key.equals(FEATURE_SC)) { if (decision) { if (isStrict()) { options.remove(FEATURE_STRICT); this.isStrict = false; // TODO inform user that STRICT mode is de-activated // throw new UnsupportedOption( // "StrictMode is exclusive and does not allow any other option."); } options.add(key); if (key.equals(FEATURE_COMMENT)) { isComment = true; } if (key.equals(FEATURE_PI)) { isPI = true; } if (key.equals(FEATURE_DTD)) { isDTD = true; } if (key.equals(FEATURE_PREFIX)) { isPrefix = true; } if (key.equals(FEATURE_SC)) { isSC = true; } } else { // remove option (if present) options.remove(key); if (key.equals(FEATURE_COMMENT)) { isComment = false; } if (key.equals(FEATURE_PI)) { isPI = false; } if (key.equals(FEATURE_DTD)) { isDTD = false; } if (key.equals(FEATURE_PREFIX)) { isPrefix = false; } if (key.equals(FEATURE_SC)) { isSC = false; } } } else { throw new UnsupportedOption("FidelityOption '" + key + "' is unknown!"); } }
[ "public", "void", "setFidelity", "(", "String", "key", ",", "boolean", "decision", ")", "throws", "UnsupportedOption", "{", "if", "(", "key", ".", "equals", "(", "FEATURE_STRICT", ")", ")", "{", "if", "(", "decision", ")", "{", "// no other features allowed", ...
Enables or disables the specified fidelity feature. @param key referring to a specific feature @param decision enabling or disabling feature @throws UnsupportedOption if option is not supported
[ "Enables", "or", "disables", "the", "specified", "fidelity", "feature", "." ]
b6026c5fd39e9cc3d7874caa20f084e264e0ddc7
https://github.com/EXIficient/exificient-core/blob/b6026c5fd39e9cc3d7874caa20f084e264e0ddc7/src/main/java/com/siemens/ct/exi/core/FidelityOptions.java#L153-L242
train
datasalt/pangool
core/src/main/java/org/apache/avro/mapreduce/lib/output/AvroOutputFormat.java
AvroOutputFormat.setDeflateLevel
public static void setDeflateLevel(Job job, int level) { FileOutputFormat.setCompressOutput(job, true); job.getConfiguration().setInt(DEFLATE_LEVEL_KEY, level); }
java
public static void setDeflateLevel(Job job, int level) { FileOutputFormat.setCompressOutput(job, true); job.getConfiguration().setInt(DEFLATE_LEVEL_KEY, level); }
[ "public", "static", "void", "setDeflateLevel", "(", "Job", "job", ",", "int", "level", ")", "{", "FileOutputFormat", ".", "setCompressOutput", "(", "job", ",", "true", ")", ";", "job", ".", "getConfiguration", "(", ")", ".", "setInt", "(", "DEFLATE_LEVEL_KEY...
Enable output compression using the deflate codec and specify its level.
[ "Enable", "output", "compression", "using", "the", "deflate", "codec", "and", "specify", "its", "level", "." ]
bfd312dd78cba03febaf7988ae96a3d4bc585408
https://github.com/datasalt/pangool/blob/bfd312dd78cba03febaf7988ae96a3d4bc585408/core/src/main/java/org/apache/avro/mapreduce/lib/output/AvroOutputFormat.java#L66-L69
train
opentable/otj-logging
core/src/main/java/com/opentable/logging/LogMetadata.java
LogMetadata.of
public static LogMetadata of(String key, Object value) { Map<String, Object> map = new HashMap<>(); map.put(key, value); return new LogMetadata(map); }
java
public static LogMetadata of(String key, Object value) { Map<String, Object> map = new HashMap<>(); map.put(key, value); return new LogMetadata(map); }
[ "public", "static", "LogMetadata", "of", "(", "String", "key", ",", "Object", "value", ")", "{", "Map", "<", "String", ",", "Object", ">", "map", "=", "new", "HashMap", "<>", "(", ")", ";", "map", ".", "put", "(", "key", ",", "value", ")", ";", "...
Create a new metadata marker with a single key-value pair. @param key the key to add @param value the value to add for that key
[ "Create", "a", "new", "metadata", "marker", "with", "a", "single", "key", "-", "value", "pair", "." ]
eaa74c877c4721ddb9af8eb7fe1612166f7ac14d
https://github.com/opentable/otj-logging/blob/eaa74c877c4721ddb9af8eb7fe1612166f7ac14d/core/src/main/java/com/opentable/logging/LogMetadata.java#L46-L50
train
opentable/otj-logging
core/src/main/java/com/opentable/logging/LogMetadata.java
LogMetadata.logOtl
public static <T extends OtlType> LogMetadata logOtl(T otl) { return new LogMetadata(Collections.emptyMap()).andInline(otl); }
java
public static <T extends OtlType> LogMetadata logOtl(T otl) { return new LogMetadata(Collections.emptyMap()).andInline(otl); }
[ "public", "static", "<", "T", "extends", "OtlType", ">", "LogMetadata", "logOtl", "(", "T", "otl", ")", "{", "return", "new", "LogMetadata", "(", "Collections", ".", "emptyMap", "(", ")", ")", ".", "andInline", "(", "otl", ")", ";", "}" ]
Add an OTL object to the log message @param otl the OTL item to log @return the metadata marker
[ "Add", "an", "OTL", "object", "to", "the", "log", "message" ]
eaa74c877c4721ddb9af8eb7fe1612166f7ac14d
https://github.com/opentable/otj-logging/blob/eaa74c877c4721ddb9af8eb7fe1612166f7ac14d/core/src/main/java/com/opentable/logging/LogMetadata.java#L57-L59
train
opentable/otj-logging
core/src/main/java/com/opentable/logging/LogMetadata.java
LogMetadata.and
public LogMetadata and(String key, Object value) { metadata.put(key, value); return this; }
java
public LogMetadata and(String key, Object value) { metadata.put(key, value); return this; }
[ "public", "LogMetadata", "and", "(", "String", "key", ",", "Object", "value", ")", "{", "metadata", ".", "put", "(", "key", ",", "value", ")", ";", "return", "this", ";", "}" ]
Extend a metadata marker with another key-value pair. @param key the key to add @param value the value for the key
[ "Extend", "a", "metadata", "marker", "with", "another", "key", "-", "value", "pair", "." ]
eaa74c877c4721ddb9af8eb7fe1612166f7ac14d
https://github.com/opentable/otj-logging/blob/eaa74c877c4721ddb9af8eb7fe1612166f7ac14d/core/src/main/java/com/opentable/logging/LogMetadata.java#L66-L69
train
meltmedia/cadmium
cli/src/main/java/com/meltmedia/cadmium/cli/AbstractAuthorizedOnly.java
AbstractAuthorizedOnly.compilePattern
private static Pattern compilePattern( String regex, Logger logger ) { try { return Pattern.compile(regex); } catch( PatternSyntaxException pse ) { logger.error("Could not compile regex "+regex, pse); } return null; }
java
private static Pattern compilePattern( String regex, Logger logger ) { try { return Pattern.compile(regex); } catch( PatternSyntaxException pse ) { logger.error("Could not compile regex "+regex, pse); } return null; }
[ "private", "static", "Pattern", "compilePattern", "(", "String", "regex", ",", "Logger", "logger", ")", "{", "try", "{", "return", "Pattern", ".", "compile", "(", "regex", ")", ";", "}", "catch", "(", "PatternSyntaxException", "pse", ")", "{", "logger", "....
Compiles the given regex. Returns null if the pattern could not be compiled and logs an error message to the specified logger. @param regex the regular expression to compile. @param logger the logger to notify of errors. @return The compiled regular expression, or null if it could not be compiled.
[ "Compiles", "the", "given", "regex", ".", "Returns", "null", "if", "the", "pattern", "could", "not", "be", "compiled", "and", "logs", "an", "error", "message", "to", "the", "specified", "logger", "." ]
bca585030e141803a73b58abb128d130157b6ddf
https://github.com/meltmedia/cadmium/blob/bca585030e141803a73b58abb128d130157b6ddf/cli/src/main/java/com/meltmedia/cadmium/cli/AbstractAuthorizedOnly.java#L55-L63
train
meltmedia/cadmium
cli/src/main/java/com/meltmedia/cadmium/cli/AbstractAuthorizedOnly.java
AbstractAuthorizedOnly.getSecureBaseUrl
protected String getSecureBaseUrl(String siteUrl) { if(!siteUrl.startsWith("http://") && !siteUrl.startsWith("https://")) { siteUrl = "http://" + siteUrl; } Matcher urlMatcher = URL_PATTERN.matcher(siteUrl); if(urlMatcher.matches()) { logger.debug("Url matches [{}]", siteUrl); boolean local = false; try { logger.debug("Checking if host [{}] is local", urlMatcher.group(1)); InetAddress hostAddr = InetAddress.getByName(urlMatcher.group(1)); local = hostAddr.isLoopbackAddress() || hostAddr.isSiteLocalAddress(); logger.debug("IpAddress [{}] local: {}", hostAddr.getHostAddress(), local); } catch(UnknownHostException e) { logger.warn("Hostname not found ["+siteUrl+"]", e); } if(!local) { return siteUrl.replaceFirst("http://", "https://"); } } return siteUrl; }
java
protected String getSecureBaseUrl(String siteUrl) { if(!siteUrl.startsWith("http://") && !siteUrl.startsWith("https://")) { siteUrl = "http://" + siteUrl; } Matcher urlMatcher = URL_PATTERN.matcher(siteUrl); if(urlMatcher.matches()) { logger.debug("Url matches [{}]", siteUrl); boolean local = false; try { logger.debug("Checking if host [{}] is local", urlMatcher.group(1)); InetAddress hostAddr = InetAddress.getByName(urlMatcher.group(1)); local = hostAddr.isLoopbackAddress() || hostAddr.isSiteLocalAddress(); logger.debug("IpAddress [{}] local: {}", hostAddr.getHostAddress(), local); } catch(UnknownHostException e) { logger.warn("Hostname not found ["+siteUrl+"]", e); } if(!local) { return siteUrl.replaceFirst("http://", "https://"); } } return siteUrl; }
[ "protected", "String", "getSecureBaseUrl", "(", "String", "siteUrl", ")", "{", "if", "(", "!", "siteUrl", ".", "startsWith", "(", "\"http://\"", ")", "&&", "!", "siteUrl", ".", "startsWith", "(", "\"https://\"", ")", ")", "{", "siteUrl", "=", "\"http://\"", ...
Converts the passed in siteUrl to be https if not already or not local. @param siteUrl The url of a cadmium site. @return The passed in siteUrl or the same url but converted to https.
[ "Converts", "the", "passed", "in", "siteUrl", "to", "be", "https", "if", "not", "already", "or", "not", "local", "." ]
bca585030e141803a73b58abb128d130157b6ddf
https://github.com/meltmedia/cadmium/blob/bca585030e141803a73b58abb128d130157b6ddf/cli/src/main/java/com/meltmedia/cadmium/cli/AbstractAuthorizedOnly.java#L110-L131
train
meltmedia/cadmium
cli/src/main/java/com/meltmedia/cadmium/cli/AbstractAuthorizedOnly.java
AbstractAuthorizedOnly.httpClient
protected static HttpClient httpClient() throws Exception { return HttpClients.custom() .setHostnameVerifier(new AllowAllHostnameVerifier()) .setSslcontext(SSLContexts.custom() .loadTrustMaterial(null, new TrustStrategy() { @Override public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { return true; } }) .build()) .build(); }
java
protected static HttpClient httpClient() throws Exception { return HttpClients.custom() .setHostnameVerifier(new AllowAllHostnameVerifier()) .setSslcontext(SSLContexts.custom() .loadTrustMaterial(null, new TrustStrategy() { @Override public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { return true; } }) .build()) .build(); }
[ "protected", "static", "HttpClient", "httpClient", "(", ")", "throws", "Exception", "{", "return", "HttpClients", ".", "custom", "(", ")", ".", "setHostnameVerifier", "(", "new", "AllowAllHostnameVerifier", "(", ")", ")", ".", "setSslcontext", "(", "SSLContexts", ...
Sets the Commons HttpComponents to accept all SSL Certificates. @throws Exception @return An instance of HttpClient that will accept all.
[ "Sets", "the", "Commons", "HttpComponents", "to", "accept", "all", "SSL", "Certificates", "." ]
bca585030e141803a73b58abb128d130157b6ddf
https://github.com/meltmedia/cadmium/blob/bca585030e141803a73b58abb128d130157b6ddf/cli/src/main/java/com/meltmedia/cadmium/cli/AbstractAuthorizedOnly.java#L149-L161
train
meltmedia/cadmium
cli/src/main/java/com/meltmedia/cadmium/cli/ValidateCommand.java
ValidateCommand.addCurrentDirFiles
private void addCurrentDirFiles(List<File> theFiles, List<File> theDirs, File currentDir) { File dirs[] = currentDir.listFiles(new FileFilter() { @Override public boolean accept(File file) { return file.isDirectory() && !file.getName().startsWith(".") && !file.getName().equals("META-INF"); } }); File htmlFiles[] = currentDir.listFiles(new FileFilter() { @Override public boolean accept(File file) { return !file.isDirectory() && file.isFile() && file.canRead() && !file.getName().startsWith(".") && (file.getName().endsWith(".html") || file.getName().endsWith(".htm")); } }); if(dirs != null && dirs.length > 0) { theDirs.addAll(Arrays.asList(dirs)); } if(htmlFiles != null && htmlFiles.length > 0) { theFiles.addAll(Arrays.asList(htmlFiles)); } }
java
private void addCurrentDirFiles(List<File> theFiles, List<File> theDirs, File currentDir) { File dirs[] = currentDir.listFiles(new FileFilter() { @Override public boolean accept(File file) { return file.isDirectory() && !file.getName().startsWith(".") && !file.getName().equals("META-INF"); } }); File htmlFiles[] = currentDir.listFiles(new FileFilter() { @Override public boolean accept(File file) { return !file.isDirectory() && file.isFile() && file.canRead() && !file.getName().startsWith(".") && (file.getName().endsWith(".html") || file.getName().endsWith(".htm")); } }); if(dirs != null && dirs.length > 0) { theDirs.addAll(Arrays.asList(dirs)); } if(htmlFiles != null && htmlFiles.length > 0) { theFiles.addAll(Arrays.asList(htmlFiles)); } }
[ "private", "void", "addCurrentDirFiles", "(", "List", "<", "File", ">", "theFiles", ",", "List", "<", "File", ">", "theDirs", ",", "File", "currentDir", ")", "{", "File", "dirs", "[", "]", "=", "currentDir", ".", "listFiles", "(", "new", "FileFilter", "(...
Adds all html files to the list passed in. @param theFiles The list to populate with the current directory's html files. @param theDirs The list to populate with the current directory's child directories. @param currentDir The current directory.
[ "Adds", "all", "html", "files", "to", "the", "list", "passed", "in", "." ]
bca585030e141803a73b58abb128d130157b6ddf
https://github.com/meltmedia/cadmium/blob/bca585030e141803a73b58abb128d130157b6ddf/cli/src/main/java/com/meltmedia/cadmium/cli/ValidateCommand.java#L116-L141
train
datasalt/pangool
core/src/main/java/com/datasalt/pangool/tuplemr/MapOnlyJobBuilder.java
MapOnlyJobBuilder.setDefaultNamedOutput
public void setDefaultNamedOutput(OutputFormat outputFormat, Class keyClass, Class valueClass) throws TupleMRException { setDefaultNamedOutput(outputFormat, keyClass, valueClass, null); }
java
public void setDefaultNamedOutput(OutputFormat outputFormat, Class keyClass, Class valueClass) throws TupleMRException { setDefaultNamedOutput(outputFormat, keyClass, valueClass, null); }
[ "public", "void", "setDefaultNamedOutput", "(", "OutputFormat", "outputFormat", ",", "Class", "keyClass", ",", "Class", "valueClass", ")", "throws", "TupleMRException", "{", "setDefaultNamedOutput", "(", "outputFormat", ",", "keyClass", ",", "valueClass", ",", "null",...
Sets the default named output specs. By using this method one can use an arbitrary number of named outputs without pre-defining them beforehand.
[ "Sets", "the", "default", "named", "output", "specs", ".", "By", "using", "this", "method", "one", "can", "use", "an", "arbitrary", "number", "of", "named", "outputs", "without", "pre", "-", "defining", "them", "beforehand", "." ]
bfd312dd78cba03febaf7988ae96a3d4bc585408
https://github.com/datasalt/pangool/blob/bfd312dd78cba03febaf7988ae96a3d4bc585408/core/src/main/java/com/datasalt/pangool/tuplemr/MapOnlyJobBuilder.java#L103-L105
train
meltmedia/cadmium
servlets/src/main/java/com/meltmedia/cadmium/servlets/shiro/PersistablePropertiesRealm.java
PersistablePropertiesRealm.getProperties
public Properties getProperties() { Properties props = new Properties(); for(String name : this.users.keySet()) { SimpleAccount acct = this.users.get(name); props.setProperty(USERNAME_PREFIX + name, acct.getCredentials().toString()); } return props; }
java
public Properties getProperties() { Properties props = new Properties(); for(String name : this.users.keySet()) { SimpleAccount acct = this.users.get(name); props.setProperty(USERNAME_PREFIX + name, acct.getCredentials().toString()); } return props; }
[ "public", "Properties", "getProperties", "(", ")", "{", "Properties", "props", "=", "new", "Properties", "(", ")", ";", "for", "(", "String", "name", ":", "this", ".", "users", ".", "keySet", "(", ")", ")", "{", "SimpleAccount", "acct", "=", "this", "....
Dump properties file backed with this Realms Users and roles. @return
[ "Dump", "properties", "file", "backed", "with", "this", "Realms", "Users", "and", "roles", "." ]
bca585030e141803a73b58abb128d130157b6ddf
https://github.com/meltmedia/cadmium/blob/bca585030e141803a73b58abb128d130157b6ddf/servlets/src/main/java/com/meltmedia/cadmium/servlets/shiro/PersistablePropertiesRealm.java#L56-L63
train
meltmedia/cadmium
servlets/src/main/java/com/meltmedia/cadmium/servlets/shiro/PersistablePropertiesRealm.java
PersistablePropertiesRealm.listUsers
public List<String> listUsers() { List<String> users = new ArrayList<String>(this.users.keySet()); Collections.sort(users); return users; }
java
public List<String> listUsers() { List<String> users = new ArrayList<String>(this.users.keySet()); Collections.sort(users); return users; }
[ "public", "List", "<", "String", ">", "listUsers", "(", ")", "{", "List", "<", "String", ">", "users", "=", "new", "ArrayList", "<", "String", ">", "(", "this", ".", "users", ".", "keySet", "(", ")", ")", ";", "Collections", ".", "sort", "(", "user...
Lists all existing user accounts. @return
[ "Lists", "all", "existing", "user", "accounts", "." ]
bca585030e141803a73b58abb128d130157b6ddf
https://github.com/meltmedia/cadmium/blob/bca585030e141803a73b58abb128d130157b6ddf/servlets/src/main/java/com/meltmedia/cadmium/servlets/shiro/PersistablePropertiesRealm.java#L79-L83
train
opentable/otj-logging
core/src/main/java/com/opentable/logging/CaptureAppender.java
CaptureAppender.capture
public static List<ILoggingEvent> capture(Logger logger) { CaptureAppender capture = new CaptureAppender(); ((ch.qos.logback.classic.Logger) logger).addAppender(capture); capture.start(); return capture.captured; }
java
public static List<ILoggingEvent> capture(Logger logger) { CaptureAppender capture = new CaptureAppender(); ((ch.qos.logback.classic.Logger) logger).addAppender(capture); capture.start(); return capture.captured; }
[ "public", "static", "List", "<", "ILoggingEvent", ">", "capture", "(", "Logger", "logger", ")", "{", "CaptureAppender", "capture", "=", "new", "CaptureAppender", "(", ")", ";", "(", "(", "ch", ".", "qos", ".", "logback", ".", "classic", ".", "Logger", ")...
Capture a Logger. @param logger the Logger to capture @return an updating list of logged events
[ "Capture", "a", "Logger", "." ]
eaa74c877c4721ddb9af8eb7fe1612166f7ac14d
https://github.com/opentable/otj-logging/blob/eaa74c877c4721ddb9af8eb7fe1612166f7ac14d/core/src/main/java/com/opentable/logging/CaptureAppender.java#L69-L74
train
meltmedia/cadmium
email/src/main/java/com/meltmedia/cadmium/email/InternetAddressSet.java
InternetAddressSet.add
public boolean add( Object o ) { boolean result = false; if( o == null ) { throw new IllegalArgumentException("Address sets do not support null."); } else if( o instanceof String ) { result = super.add(convertAddress((String)o)); } else if( o instanceof InternetAddress ) { result = super.add(o); } else { throw new IllegalArgumentException("Address sets cannot take objects of type '"+o.getClass().getName()+"'."); } return result; }
java
public boolean add( Object o ) { boolean result = false; if( o == null ) { throw new IllegalArgumentException("Address sets do not support null."); } else if( o instanceof String ) { result = super.add(convertAddress((String)o)); } else if( o instanceof InternetAddress ) { result = super.add(o); } else { throw new IllegalArgumentException("Address sets cannot take objects of type '"+o.getClass().getName()+"'."); } return result; }
[ "public", "boolean", "add", "(", "Object", "o", ")", "{", "boolean", "result", "=", "false", ";", "if", "(", "o", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Address sets do not support null.\"", ")", ";", "}", "else", "if", ...
Adds a specified address to this set. If o is an instance of String, then a new InternetAddress is created and that object is added to the set. If o is an instance of InternetAddress, then it is added to the set. All other values of o, including null, throw an IllegalArgumentException.
[ "Adds", "a", "specified", "address", "to", "this", "set", ".", "If", "o", "is", "an", "instance", "of", "String", "then", "a", "new", "InternetAddress", "is", "created", "and", "that", "object", "is", "added", "to", "the", "set", ".", "If", "o", "is", ...
bca585030e141803a73b58abb128d130157b6ddf
https://github.com/meltmedia/cadmium/blob/bca585030e141803a73b58abb128d130157b6ddf/email/src/main/java/com/meltmedia/cadmium/email/InternetAddressSet.java#L51-L67
train
datasalt/pangool
core/src/main/java/com/datasalt/pangool/serialization/ProtoStuffSerialization.java
ProtoStuffSerialization.enableProtoStuffSerialization
public static void enableProtoStuffSerialization(Configuration conf) { String ser = conf.get("io.serializations").trim(); if(ser.length() != 0) { ser += ","; } // Adding the ProtoStuff serialization ser += ProtoStuffSerialization.class.getName(); conf.set("io.serializations", ser); }
java
public static void enableProtoStuffSerialization(Configuration conf) { String ser = conf.get("io.serializations").trim(); if(ser.length() != 0) { ser += ","; } // Adding the ProtoStuff serialization ser += ProtoStuffSerialization.class.getName(); conf.set("io.serializations", ser); }
[ "public", "static", "void", "enableProtoStuffSerialization", "(", "Configuration", "conf", ")", "{", "String", "ser", "=", "conf", ".", "get", "(", "\"io.serializations\"", ")", ".", "trim", "(", ")", ";", "if", "(", "ser", ".", "length", "(", ")", "!=", ...
Enables ProtoStuff Serialization support in Hadoop.
[ "Enables", "ProtoStuff", "Serialization", "support", "in", "Hadoop", "." ]
bfd312dd78cba03febaf7988ae96a3d4bc585408
https://github.com/datasalt/pangool/blob/bfd312dd78cba03febaf7988ae96a3d4bc585408/core/src/main/java/com/datasalt/pangool/serialization/ProtoStuffSerialization.java#L128-L136
train
meltmedia/cadmium
cli/src/main/java/com/meltmedia/cadmium/cli/CloneCommand.java
CloneCommand.execute
public void execute() throws Exception { String site1 = getSecureBaseUrl(sites.get(0)); String site2 = getSecureBaseUrl(sites.get(1)); if(site1.equalsIgnoreCase(site2)) { System.err.println("Cannot clone a site into itself."); System.exit(1); } try{ System.out.println("Getting status of ["+site1+"]"); Status site1Status = StatusCommand.getSiteStatus(site1, token); System.out.println("Getting status of ["+site2+"]"); Status site2Status = StatusCommand.getSiteStatus(site2, token); if(site1Status != null && site2Status != null) { String repo = site1Status.getRepo(); String revision = site1Status.getRevision(); String branch = site1Status.getBranch(); if(site2Status.getRepo().equals(repo) && site2Status.getBranch().equals(branch) && site2Status.getRevision().equals(revision)) { System.err.println("Source [" + site1 + "] is on the same content repo, branch, and revision as the target [" + site2 + "]."); checkSendUpdateConfigMessage(site1, site2, site1Status, site2Status); System.exit(1); } System.out.println("Sending update message to ["+site2+"]"); UpdateCommand.sendUpdateMessage(site2, repo, branch, revision, "Cloned from ["+site1+"]: " + comment, token); checkSendUpdateConfigMessage(site1, site2, site1Status, site2Status); } else { System.err.println("Failed to get status from source and/or target."); System.exit(1); } } catch(Exception e) { e.printStackTrace(); System.err.println("Failed to clone ["+site1+"] to ["+site2+"]: "+e.getMessage()); } }
java
public void execute() throws Exception { String site1 = getSecureBaseUrl(sites.get(0)); String site2 = getSecureBaseUrl(sites.get(1)); if(site1.equalsIgnoreCase(site2)) { System.err.println("Cannot clone a site into itself."); System.exit(1); } try{ System.out.println("Getting status of ["+site1+"]"); Status site1Status = StatusCommand.getSiteStatus(site1, token); System.out.println("Getting status of ["+site2+"]"); Status site2Status = StatusCommand.getSiteStatus(site2, token); if(site1Status != null && site2Status != null) { String repo = site1Status.getRepo(); String revision = site1Status.getRevision(); String branch = site1Status.getBranch(); if(site2Status.getRepo().equals(repo) && site2Status.getBranch().equals(branch) && site2Status.getRevision().equals(revision)) { System.err.println("Source [" + site1 + "] is on the same content repo, branch, and revision as the target [" + site2 + "]."); checkSendUpdateConfigMessage(site1, site2, site1Status, site2Status); System.exit(1); } System.out.println("Sending update message to ["+site2+"]"); UpdateCommand.sendUpdateMessage(site2, repo, branch, revision, "Cloned from ["+site1+"]: " + comment, token); checkSendUpdateConfigMessage(site1, site2, site1Status, site2Status); } else { System.err.println("Failed to get status from source and/or target."); System.exit(1); } } catch(Exception e) { e.printStackTrace(); System.err.println("Failed to clone ["+site1+"] to ["+site2+"]: "+e.getMessage()); } }
[ "public", "void", "execute", "(", ")", "throws", "Exception", "{", "String", "site1", "=", "getSecureBaseUrl", "(", "sites", ".", "get", "(", "0", ")", ")", ";", "String", "site2", "=", "getSecureBaseUrl", "(", "sites", ".", "get", "(", "1", ")", ")", ...
Called to execute this command.
[ "Called", "to", "execute", "this", "command", "." ]
bca585030e141803a73b58abb128d130157b6ddf
https://github.com/meltmedia/cadmium/blob/bca585030e141803a73b58abb128d130157b6ddf/cli/src/main/java/com/meltmedia/cadmium/cli/CloneCommand.java#L70-L107
train
meltmedia/cadmium
cli/src/main/java/com/meltmedia/cadmium/cli/CloneCommand.java
CloneCommand.checkSendUpdateConfigMessage
private void checkSendUpdateConfigMessage(String site1, String site2, Status site1Status, Status site2Status) throws Exception { String repo; String revision; String branch; if(includeConfig) { repo = site1Status.getConfigRepo(); revision = site1Status.getConfigRevision(); branch = site1Status.getConfigBranch(); if(!StringUtils.isEmptyOrNull(repo) && !StringUtils.isEmptyOrNull(revision) && !StringUtils.isEmptyOrNull(branch)) { if(!repo.equals(site2Status.getConfigRepo()) || !revision.equals(site2Status.getConfigRevision()) || ! branch.equals(site2Status.getConfigBranch())) { System.out.println("Sending update/config message to ["+site2+"]"); UpdateCommand.sendUpdateMessage(site2, repo, branch, revision, "Cloned config from ["+site1+"]: " + comment, token, UpdateConfigCommand.UPDATE_CONFIG_ENDPOINT, UpdateRequest.CONFIG_BRANCH_PREFIX); } else { System.out.println("Source [" + site1 + "] is on the same configuration repo, branch, and revision as the target [" + site2 + "]."); } } else { System.out.println("Configuration status not available from source site [" + site1 + "]"); } } }
java
private void checkSendUpdateConfigMessage(String site1, String site2, Status site1Status, Status site2Status) throws Exception { String repo; String revision; String branch; if(includeConfig) { repo = site1Status.getConfigRepo(); revision = site1Status.getConfigRevision(); branch = site1Status.getConfigBranch(); if(!StringUtils.isEmptyOrNull(repo) && !StringUtils.isEmptyOrNull(revision) && !StringUtils.isEmptyOrNull(branch)) { if(!repo.equals(site2Status.getConfigRepo()) || !revision.equals(site2Status.getConfigRevision()) || ! branch.equals(site2Status.getConfigBranch())) { System.out.println("Sending update/config message to ["+site2+"]"); UpdateCommand.sendUpdateMessage(site2, repo, branch, revision, "Cloned config from ["+site1+"]: " + comment, token, UpdateConfigCommand.UPDATE_CONFIG_ENDPOINT, UpdateRequest.CONFIG_BRANCH_PREFIX); } else { System.out.println("Source [" + site1 + "] is on the same configuration repo, branch, and revision as the target [" + site2 + "]."); } } else { System.out.println("Configuration status not available from source site [" + site1 + "]"); } } }
[ "private", "void", "checkSendUpdateConfigMessage", "(", "String", "site1", ",", "String", "site2", ",", "Status", "site1Status", ",", "Status", "site2Status", ")", "throws", "Exception", "{", "String", "repo", ";", "String", "revision", ";", "String", "branch", ...
Checks if a config update message is necessary and sends it if it is. @param site1 The source site for the configuration. @param site2 The target site for the configuration. @param site1Status The status of the source site. @param site2Status The status of the target site. @throws Exception
[ "Checks", "if", "a", "config", "update", "message", "is", "necessary", "and", "sends", "it", "if", "it", "is", "." ]
bca585030e141803a73b58abb128d130157b6ddf
https://github.com/meltmedia/cadmium/blob/bca585030e141803a73b58abb128d130157b6ddf/cli/src/main/java/com/meltmedia/cadmium/cli/CloneCommand.java#L118-L138
train
meltmedia/cadmium
cli/src/main/java/com/meltmedia/cadmium/cli/CloneCommand.java
CloneCommand.cloneSiteRepo
public static GitService cloneSiteRepo(Status status) throws Exception { File tmpDir = File.createTempFile("site", "git"); GitService git = null; if(tmpDir.delete()) { try { git = GitService.cloneRepo(status.getRepo(), tmpDir.getAbsolutePath()); if(status.getBranch() != null && !git.getBranchName().equals(status.getBranch())) { git.switchBranch(status.getBranch()); } if(status.getRevision() != null && !git.getCurrentRevision().equals(status.getRevision())) { git.resetToRev(status.getRevision()); } } catch(Exception e) { System.err.println("Failed to clone repo "+status.getRepo()+" branch "+status.getBranch()+ "["+tmpDir+"]"); e.printStackTrace(); if(git != null) { git.close(); git = null; } } } return git; }
java
public static GitService cloneSiteRepo(Status status) throws Exception { File tmpDir = File.createTempFile("site", "git"); GitService git = null; if(tmpDir.delete()) { try { git = GitService.cloneRepo(status.getRepo(), tmpDir.getAbsolutePath()); if(status.getBranch() != null && !git.getBranchName().equals(status.getBranch())) { git.switchBranch(status.getBranch()); } if(status.getRevision() != null && !git.getCurrentRevision().equals(status.getRevision())) { git.resetToRev(status.getRevision()); } } catch(Exception e) { System.err.println("Failed to clone repo "+status.getRepo()+" branch "+status.getBranch()+ "["+tmpDir+"]"); e.printStackTrace(); if(git != null) { git.close(); git = null; } } } return git; }
[ "public", "static", "GitService", "cloneSiteRepo", "(", "Status", "status", ")", "throws", "Exception", "{", "File", "tmpDir", "=", "File", ".", "createTempFile", "(", "\"site\"", ",", "\"git\"", ")", ";", "GitService", "git", "=", "null", ";", "if", "(", ...
Clones a repository locally from a status response from a Cadmium site. @param status The status response to clone locally. @return The {@link GitService} object that points to the newly cloned remote repo. @throws Exception
[ "Clones", "a", "repository", "locally", "from", "a", "status", "response", "from", "a", "Cadmium", "site", "." ]
bca585030e141803a73b58abb128d130157b6ddf
https://github.com/meltmedia/cadmium/blob/bca585030e141803a73b58abb128d130157b6ddf/cli/src/main/java/com/meltmedia/cadmium/cli/CloneCommand.java#L161-L183
train
opentable/otj-logging
core/src/main/java/com/opentable/logging/CommonLogHolder.java
CommonLogHolder.setEnvironment
public static void setEnvironment(String otEnv, String otEnvType, String otEnvLocation, String otEnvFlavor) { OT_ENV = otEnv; OT_ENV_TYPE = otEnvType; OT_ENV_LOCATION = otEnvLocation; OT_ENV_FLAVOR = otEnvFlavor; }
java
public static void setEnvironment(String otEnv, String otEnvType, String otEnvLocation, String otEnvFlavor) { OT_ENV = otEnv; OT_ENV_TYPE = otEnvType; OT_ENV_LOCATION = otEnvLocation; OT_ENV_FLAVOR = otEnvFlavor; }
[ "public", "static", "void", "setEnvironment", "(", "String", "otEnv", ",", "String", "otEnvType", ",", "String", "otEnvLocation", ",", "String", "otEnvFlavor", ")", "{", "OT_ENV", "=", "otEnv", ";", "OT_ENV_TYPE", "=", "otEnvType", ";", "OT_ENV_LOCATION", "=", ...
Mock out the environment. You probably don't want to do this.
[ "Mock", "out", "the", "environment", ".", "You", "probably", "don", "t", "want", "to", "do", "this", "." ]
eaa74c877c4721ddb9af8eb7fe1612166f7ac14d
https://github.com/opentable/otj-logging/blob/eaa74c877c4721ddb9af8eb7fe1612166f7ac14d/core/src/main/java/com/opentable/logging/CommonLogHolder.java#L70-L75
train
opentable/otj-logging
core/src/main/java/com/opentable/logging/CommonLogHolder.java
CommonLogHolder.getServiceType
public static String getServiceType() { if (UNSET.equals(serviceType) && WARNED_UNSET.compareAndSet(false, true)) { LoggerFactory.getLogger(ApplicationLogEvent.class).error("The application name was not set! Sending 'UNSET' instead :("); } return serviceType; }
java
public static String getServiceType() { if (UNSET.equals(serviceType) && WARNED_UNSET.compareAndSet(false, true)) { LoggerFactory.getLogger(ApplicationLogEvent.class).error("The application name was not set! Sending 'UNSET' instead :("); } return serviceType; }
[ "public", "static", "String", "getServiceType", "(", ")", "{", "if", "(", "UNSET", ".", "equals", "(", "serviceType", ")", "&&", "WARNED_UNSET", ".", "compareAndSet", "(", "false", ",", "true", ")", ")", "{", "LoggerFactory", ".", "getLogger", "(", "Applic...
Get the service type @return the type of service
[ "Get", "the", "service", "type" ]
eaa74c877c4721ddb9af8eb7fe1612166f7ac14d
https://github.com/opentable/otj-logging/blob/eaa74c877c4721ddb9af8eb7fe1612166f7ac14d/core/src/main/java/com/opentable/logging/CommonLogHolder.java#L92-L97
train
meltmedia/cadmium
core/src/main/java/com/meltmedia/cadmium/core/commands/SyncCommandAction.java
SyncCommandAction.isEmptyOrNull
private static boolean isEmptyOrNull( GitLocation location ) { return location == null || (StringUtils.isEmptyOrNull(location.getRepository()) && StringUtils.isEmptyOrNull(location.getBranch()) && StringUtils.isEmptyOrNull(location.getRevision())); }
java
private static boolean isEmptyOrNull( GitLocation location ) { return location == null || (StringUtils.isEmptyOrNull(location.getRepository()) && StringUtils.isEmptyOrNull(location.getBranch()) && StringUtils.isEmptyOrNull(location.getRevision())); }
[ "private", "static", "boolean", "isEmptyOrNull", "(", "GitLocation", "location", ")", "{", "return", "location", "==", "null", "||", "(", "StringUtils", ".", "isEmptyOrNull", "(", "location", ".", "getRepository", "(", ")", ")", "&&", "StringUtils", ".", "isEm...
Returns true if a git location object is null or all of its values are empty or null. @param location the location object to test. @return true if the git location object is null or all of its values are empty or null, false otherwise.
[ "Returns", "true", "if", "a", "git", "location", "object", "is", "null", "or", "all", "of", "its", "values", "are", "empty", "or", "null", "." ]
bca585030e141803a73b58abb128d130157b6ddf
https://github.com/meltmedia/cadmium/blob/bca585030e141803a73b58abb128d130157b6ddf/core/src/main/java/com/meltmedia/cadmium/core/commands/SyncCommandAction.java#L300-L305
train
EXIficient/exificient-core
src/main/java/com/siemens/ct/exi/core/coder/EXIHeaderEncoder.java
EXIHeaderEncoder.write
public void write(BitEncoderChannel headerChannel, EXIFactory f) throws EXIException { try { EncodingOptions headerOptions = f.getEncodingOptions(); CodingMode codingMode = f.getCodingMode(); // EXI Cookie if (headerOptions.isOptionEnabled(EncodingOptions.INCLUDE_COOKIE)) { // four byte field consists of four characters " $ " , " E ", // " X " and " I " in that order headerChannel.encode('$'); headerChannel.encode('E'); headerChannel.encode('X'); headerChannel.encode('I'); } // Distinguishing Bits 10 headerChannel.encodeNBitUnsignedInteger(2, 2); // Presence Bit for EXI Options 0 boolean includeOptions = headerOptions .isOptionEnabled(EncodingOptions.INCLUDE_OPTIONS); headerChannel.encodeBoolean(includeOptions); // EXI Format Version 0-0000 headerChannel.encodeBoolean(false); // preview headerChannel.encodeNBitUnsignedInteger(0, 4); // EXI Header options and so forth if (includeOptions) { writeEXIOptions(f, headerChannel); } // other than bit-packed requires [Padding Bits] if (codingMode != CodingMode.BIT_PACKED) { headerChannel.align(); headerChannel.flush(); } } catch (IOException e) { throw new EXIException(e); } }
java
public void write(BitEncoderChannel headerChannel, EXIFactory f) throws EXIException { try { EncodingOptions headerOptions = f.getEncodingOptions(); CodingMode codingMode = f.getCodingMode(); // EXI Cookie if (headerOptions.isOptionEnabled(EncodingOptions.INCLUDE_COOKIE)) { // four byte field consists of four characters " $ " , " E ", // " X " and " I " in that order headerChannel.encode('$'); headerChannel.encode('E'); headerChannel.encode('X'); headerChannel.encode('I'); } // Distinguishing Bits 10 headerChannel.encodeNBitUnsignedInteger(2, 2); // Presence Bit for EXI Options 0 boolean includeOptions = headerOptions .isOptionEnabled(EncodingOptions.INCLUDE_OPTIONS); headerChannel.encodeBoolean(includeOptions); // EXI Format Version 0-0000 headerChannel.encodeBoolean(false); // preview headerChannel.encodeNBitUnsignedInteger(0, 4); // EXI Header options and so forth if (includeOptions) { writeEXIOptions(f, headerChannel); } // other than bit-packed requires [Padding Bits] if (codingMode != CodingMode.BIT_PACKED) { headerChannel.align(); headerChannel.flush(); } } catch (IOException e) { throw new EXIException(e); } }
[ "public", "void", "write", "(", "BitEncoderChannel", "headerChannel", ",", "EXIFactory", "f", ")", "throws", "EXIException", "{", "try", "{", "EncodingOptions", "headerOptions", "=", "f", ".", "getEncodingOptions", "(", ")", ";", "CodingMode", "codingMode", "=", ...
Writes the EXI header according to the header options with optional cookie, EXI options, .. @param headerChannel header channel @param f factory @throws EXIException EXI exception
[ "Writes", "the", "EXI", "header", "according", "to", "the", "header", "options", "with", "optional", "cookie", "EXI", "options", ".." ]
b6026c5fd39e9cc3d7874caa20f084e264e0ddc7
https://github.com/EXIficient/exificient-core/blob/b6026c5fd39e9cc3d7874caa20f084e264e0ddc7/src/main/java/com/siemens/ct/exi/core/coder/EXIHeaderEncoder.java#L74-L116
train
meltmedia/cadmium
core/src/main/java/com/meltmedia/cadmium/core/messaging/MessageConverter.java
MessageConverter.toJGroupsMessage
public org.jgroups.Message toJGroupsMessage(Message<?> cMessage) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); JsonGenerator generator = factory.createJsonGenerator(out); generator.writeStartObject(); generator.writeObjectField("header", cMessage.getHeader()); if( cMessage.getBody() != null ) { generator.writeObjectField("body", cMessage.getBody()); } generator.writeEndObject(); generator.close(); org.jgroups.Message jgMessage = new org.jgroups.Message(); jgMessage.setBuffer(out.toByteArray()); return jgMessage; }
java
public org.jgroups.Message toJGroupsMessage(Message<?> cMessage) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); JsonGenerator generator = factory.createJsonGenerator(out); generator.writeStartObject(); generator.writeObjectField("header", cMessage.getHeader()); if( cMessage.getBody() != null ) { generator.writeObjectField("body", cMessage.getBody()); } generator.writeEndObject(); generator.close(); org.jgroups.Message jgMessage = new org.jgroups.Message(); jgMessage.setBuffer(out.toByteArray()); return jgMessage; }
[ "public", "org", ".", "jgroups", ".", "Message", "toJGroupsMessage", "(", "Message", "<", "?", ">", "cMessage", ")", "throws", "IOException", "{", "ByteArrayOutputStream", "out", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "JsonGenerator", "generator", "...
Serialized the cadmium message object into JSON and returns it as a JGroups message. @param cMessage the cadmium message to convert. @return The JGroups message containing the JSON string of the cadmium message. @throws IOException if there is a problem serializing the message.
[ "Serialized", "the", "cadmium", "message", "object", "into", "JSON", "and", "returns", "it", "as", "a", "JGroups", "message", "." ]
bca585030e141803a73b58abb128d130157b6ddf
https://github.com/meltmedia/cadmium/blob/bca585030e141803a73b58abb128d130157b6ddf/core/src/main/java/com/meltmedia/cadmium/core/messaging/MessageConverter.java#L69-L83
train
meltmedia/cadmium
core/src/main/java/com/meltmedia/cadmium/core/messaging/MessageConverter.java
MessageConverter.toCadmiumMessage
public <B> Message<B> toCadmiumMessage(org.jgroups.Message jgMessage) throws JsonProcessingException, IOException { JsonParser parser = factory.createJsonParser(jgMessage.getBuffer()); parser.nextToken(); // parse the start token for the document. parser.nextToken(); // parse the field name parser.nextToken(); // parse the start token for header. Header header = parser.readValueAs(Header.class); Class<?> bodyClass = lookupBodyClass(header); parser.nextToken(); // parse the end token for header. Object body = null; if( bodyClass == Void.class ) { body = null; } else { parser.nextToken(); // parse the start token for body. try { body = parser.readValueAs(bodyClass); } catch(JsonProcessingException e) { log.error("Failed to parse body class as "+bodyClass+" for message "+header,e); throw e; } catch(IOException e) { log.error("Failed to parse body class as "+bodyClass+" for message "+header,e); throw e; } parser.nextToken(); // the end token for body. } parser.nextToken(); // the end token for the document. parser.close(); @SuppressWarnings("unchecked") Message<B> cMessage = new Message<B>(header, (B)body); return cMessage; }
java
public <B> Message<B> toCadmiumMessage(org.jgroups.Message jgMessage) throws JsonProcessingException, IOException { JsonParser parser = factory.createJsonParser(jgMessage.getBuffer()); parser.nextToken(); // parse the start token for the document. parser.nextToken(); // parse the field name parser.nextToken(); // parse the start token for header. Header header = parser.readValueAs(Header.class); Class<?> bodyClass = lookupBodyClass(header); parser.nextToken(); // parse the end token for header. Object body = null; if( bodyClass == Void.class ) { body = null; } else { parser.nextToken(); // parse the start token for body. try { body = parser.readValueAs(bodyClass); } catch(JsonProcessingException e) { log.error("Failed to parse body class as "+bodyClass+" for message "+header,e); throw e; } catch(IOException e) { log.error("Failed to parse body class as "+bodyClass+" for message "+header,e); throw e; } parser.nextToken(); // the end token for body. } parser.nextToken(); // the end token for the document. parser.close(); @SuppressWarnings("unchecked") Message<B> cMessage = new Message<B>(header, (B)body); return cMessage; }
[ "public", "<", "B", ">", "Message", "<", "B", ">", "toCadmiumMessage", "(", "org", ".", "jgroups", ".", "Message", "jgMessage", ")", "throws", "JsonProcessingException", ",", "IOException", "{", "JsonParser", "parser", "=", "factory", ".", "createJsonParser", ...
Deserializes the JSON content of a JGroups message into a cadmium message. @param jgMessage the JGroups message containing the JSON to deserialize. @return the deserialized cadmium message. @throws JsonProcessingException if the JSON was malformed. @throws IOException if an IO problem is encountered.
[ "Deserializes", "the", "JSON", "content", "of", "a", "JGroups", "message", "into", "a", "cadmium", "message", "." ]
bca585030e141803a73b58abb128d130157b6ddf
https://github.com/meltmedia/cadmium/blob/bca585030e141803a73b58abb128d130157b6ddf/core/src/main/java/com/meltmedia/cadmium/core/messaging/MessageConverter.java#L92-L124
train
meltmedia/cadmium
core/src/main/java/com/meltmedia/cadmium/core/messaging/MessageConverter.java
MessageConverter.lookupBodyClass
private Class<?> lookupBodyClass(Header header) throws IOException { if( header == null ) throw new IOException("Could not deserialize message body: no header."); if( header.getCommand() == null ) throw new IOException("Could not deserialize message body: no command declared."); Class<?> commandBodyClass = commandToBodyMapping.get(header.getCommand()); if( commandBodyClass == null ) throw new IOException("Could not deserialize message body: no body class defined for "+header.getCommand()+"."); return commandBodyClass; }
java
private Class<?> lookupBodyClass(Header header) throws IOException { if( header == null ) throw new IOException("Could not deserialize message body: no header."); if( header.getCommand() == null ) throw new IOException("Could not deserialize message body: no command declared."); Class<?> commandBodyClass = commandToBodyMapping.get(header.getCommand()); if( commandBodyClass == null ) throw new IOException("Could not deserialize message body: no body class defined for "+header.getCommand()+"."); return commandBodyClass; }
[ "private", "Class", "<", "?", ">", "lookupBodyClass", "(", "Header", "header", ")", "throws", "IOException", "{", "if", "(", "header", "==", "null", ")", "throw", "new", "IOException", "(", "\"Could not deserialize message body: no header.\"", ")", ";", "if", "(...
Looks up the body type for a message based on the command in the specified header object. @param header the header object for the message. @return the type of the body message. @throws IOException if there is a problem looking up the class.
[ "Looks", "up", "the", "body", "type", "for", "a", "message", "based", "on", "the", "command", "in", "the", "specified", "header", "object", "." ]
bca585030e141803a73b58abb128d130157b6ddf
https://github.com/meltmedia/cadmium/blob/bca585030e141803a73b58abb128d130157b6ddf/core/src/main/java/com/meltmedia/cadmium/core/messaging/MessageConverter.java#L133-L139
train
meltmedia/cadmium
cli/src/main/java/com/meltmedia/cadmium/cli/UpdateCommand.java
UpdateCommand.isValidBranchName
public static boolean isValidBranchName(String branch, String prefix) throws Exception { if(StringUtils.isNotBlank(prefix) && StringUtils.isNotBlank(branch)) { if(StringUtils.startsWithIgnoreCase(branch, prefix + "-")) { return true; } else { System.err.println("Branch name must start with prefix \""+prefix+"-\"."); } } else { return true; } return false; }
java
public static boolean isValidBranchName(String branch, String prefix) throws Exception { if(StringUtils.isNotBlank(prefix) && StringUtils.isNotBlank(branch)) { if(StringUtils.startsWithIgnoreCase(branch, prefix + "-")) { return true; } else { System.err.println("Branch name must start with prefix \""+prefix+"-\"."); } } else { return true; } return false; }
[ "public", "static", "boolean", "isValidBranchName", "(", "String", "branch", ",", "String", "prefix", ")", "throws", "Exception", "{", "if", "(", "StringUtils", ".", "isNotBlank", "(", "prefix", ")", "&&", "StringUtils", ".", "isNotBlank", "(", "branch", ")", ...
Validates the branch name that will be sent to the given prefix. @param branch @param prefix @return
[ "Validates", "the", "branch", "name", "that", "will", "be", "sent", "to", "the", "given", "prefix", "." ]
bca585030e141803a73b58abb128d130157b6ddf
https://github.com/meltmedia/cadmium/blob/bca585030e141803a73b58abb128d130157b6ddf/cli/src/main/java/com/meltmedia/cadmium/cli/UpdateCommand.java#L253-L264
train
meltmedia/cadmium
email/src/main/java/com/meltmedia/cadmium/email/internal/EmailServiceImpl.java
EmailServiceImpl.configurationUpdated
public void configurationUpdated(Object emailConfig) { EmailConfiguration config = (EmailConfiguration) emailConfig; if(config != null && (this.config == null || !config.equals(this.config))) { log.info("Updating configuration for email."); this.config = config; //Set the captcha validator up. if(!StringUtils.isEmptyOrNull(config.getCaptchaPrivateKey())) { log.info("Setting up captcha validation: "+config.getCaptchaPrivateKey()); captchaValidator = new CaptchaValidator(config.getCaptchaPrivateKey()); } else { log.info("Unsetting captcha validation."); captchaValidator = null; } // Need to get the Session Strategy and Transform class names out of the // Dictionary, and then use reflection to use them Dictionary<String,Object> props = new Hashtable<String,Object>(); if(!StringUtils.isEmptyOrNull(config.getJndiName())) { props.put("com.meltmedia.email.jndi",config.getJndiName()); log.debug("Using jndiName: "+config.getJndiName()); } log.debug("Using {} as the default from address.", config.getDefaultFromAddress()); if(StringUtils.isEmptyOrNull(config.getSessionStrategy())) { config.setSessionStrategy(null); } log.debug("Using mail session strategy: " + config.getSessionStrategy()); if(StringUtils.isEmptyOrNull(config.getMessageTransformer())) { config.setMessageTransformer(DEFAULT_MESSAGE_TRANSFORMER); } log.debug("Using message transformer: " + config.getMessageTransformer()); EmailSetup newSetup = new EmailSetup(); SessionStrategy strategy = null; MessageTransformer transformer = null; try { if(config.getSessionStrategy() != null) { strategy = setSessionStrategy(config, props, newSetup); } } catch (Exception e) { log.error("Error Registering Mail Session Strategy "+config.getSessionStrategy(), e); config.setSessionStrategy(null); } try { transformer = setMessageTransformer(config, newSetup); } catch(Exception e) { log.error("Error Registering Mail Session Strategy "+config.getSessionStrategy(), e); config.setMessageTransformer(DEFAULT_MESSAGE_TRANSFORMER); try { transformer = setMessageTransformer(config, newSetup); } catch(Exception e1) { log.error("Failed to fall back to default message transformer.", e1); } } this.setup = newSetup; log.debug("Using new config jndi {}, strategy {}, transformer {}", new Object[] {config.getJndiName(), strategy, transformer}); } }
java
public void configurationUpdated(Object emailConfig) { EmailConfiguration config = (EmailConfiguration) emailConfig; if(config != null && (this.config == null || !config.equals(this.config))) { log.info("Updating configuration for email."); this.config = config; //Set the captcha validator up. if(!StringUtils.isEmptyOrNull(config.getCaptchaPrivateKey())) { log.info("Setting up captcha validation: "+config.getCaptchaPrivateKey()); captchaValidator = new CaptchaValidator(config.getCaptchaPrivateKey()); } else { log.info("Unsetting captcha validation."); captchaValidator = null; } // Need to get the Session Strategy and Transform class names out of the // Dictionary, and then use reflection to use them Dictionary<String,Object> props = new Hashtable<String,Object>(); if(!StringUtils.isEmptyOrNull(config.getJndiName())) { props.put("com.meltmedia.email.jndi",config.getJndiName()); log.debug("Using jndiName: "+config.getJndiName()); } log.debug("Using {} as the default from address.", config.getDefaultFromAddress()); if(StringUtils.isEmptyOrNull(config.getSessionStrategy())) { config.setSessionStrategy(null); } log.debug("Using mail session strategy: " + config.getSessionStrategy()); if(StringUtils.isEmptyOrNull(config.getMessageTransformer())) { config.setMessageTransformer(DEFAULT_MESSAGE_TRANSFORMER); } log.debug("Using message transformer: " + config.getMessageTransformer()); EmailSetup newSetup = new EmailSetup(); SessionStrategy strategy = null; MessageTransformer transformer = null; try { if(config.getSessionStrategy() != null) { strategy = setSessionStrategy(config, props, newSetup); } } catch (Exception e) { log.error("Error Registering Mail Session Strategy "+config.getSessionStrategy(), e); config.setSessionStrategy(null); } try { transformer = setMessageTransformer(config, newSetup); } catch(Exception e) { log.error("Error Registering Mail Session Strategy "+config.getSessionStrategy(), e); config.setMessageTransformer(DEFAULT_MESSAGE_TRANSFORMER); try { transformer = setMessageTransformer(config, newSetup); } catch(Exception e1) { log.error("Failed to fall back to default message transformer.", e1); } } this.setup = newSetup; log.debug("Using new config jndi {}, strategy {}, transformer {}", new Object[] {config.getJndiName(), strategy, transformer}); } }
[ "public", "void", "configurationUpdated", "(", "Object", "emailConfig", ")", "{", "EmailConfiguration", "config", "=", "(", "EmailConfiguration", ")", "emailConfig", ";", "if", "(", "config", "!=", "null", "&&", "(", "this", ".", "config", "==", "null", "||", ...
Updates the Email Service component configuration.
[ "Updates", "the", "Email", "Service", "component", "configuration", "." ]
bca585030e141803a73b58abb128d130157b6ddf
https://github.com/meltmedia/cadmium/blob/bca585030e141803a73b58abb128d130157b6ddf/email/src/main/java/com/meltmedia/cadmium/email/internal/EmailServiceImpl.java#L69-L126
train
meltmedia/cadmium
email/src/main/java/com/meltmedia/cadmium/email/internal/EmailServiceImpl.java
EmailServiceImpl.send
public void send(Email email) throws EmailException { synchronized (this) { EmailConnection connection = openConnection(); connection.connect(); connection.send(email); connection.close(); } }
java
public void send(Email email) throws EmailException { synchronized (this) { EmailConnection connection = openConnection(); connection.connect(); connection.send(email); connection.close(); } }
[ "public", "void", "send", "(", "Email", "email", ")", "throws", "EmailException", "{", "synchronized", "(", "this", ")", "{", "EmailConnection", "connection", "=", "openConnection", "(", ")", ";", "connection", ".", "connect", "(", ")", ";", "connection", "....
Opens a connection, sends the email, then closes the connection @param email the email to send
[ "Opens", "a", "connection", "sends", "the", "email", "then", "closes", "the", "connection" ]
bca585030e141803a73b58abb128d130157b6ddf
https://github.com/meltmedia/cadmium/blob/bca585030e141803a73b58abb128d130157b6ddf/email/src/main/java/com/meltmedia/cadmium/email/internal/EmailServiceImpl.java#L191-L200
train
meltmedia/cadmium
cli/src/main/java/com/meltmedia/cadmium/cli/WarInfoCommand.java
WarInfoCommand.getDeployedWarInfo
public static WarInfo getDeployedWarInfo(String url, String warName, String token) throws Exception { HttpClient client = httpClient(); HttpGet get = new HttpGet(url + "/system/deployment/details/"+warName); addAuthHeader(token, get); HttpResponse resp = client.execute(get); if(resp.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { WarInfo info = new Gson().fromJson(EntityUtils.toString(resp.getEntity()), WarInfo.class); return info; } return null; }
java
public static WarInfo getDeployedWarInfo(String url, String warName, String token) throws Exception { HttpClient client = httpClient(); HttpGet get = new HttpGet(url + "/system/deployment/details/"+warName); addAuthHeader(token, get); HttpResponse resp = client.execute(get); if(resp.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { WarInfo info = new Gson().fromJson(EntityUtils.toString(resp.getEntity()), WarInfo.class); return info; } return null; }
[ "public", "static", "WarInfo", "getDeployedWarInfo", "(", "String", "url", ",", "String", "warName", ",", "String", "token", ")", "throws", "Exception", "{", "HttpClient", "client", "=", "httpClient", "(", ")", ";", "HttpGet", "get", "=", "new", "HttpGet", "...
Retrieves information about a deployed cadmium war. @param url The uri to a Cadmium deployer war. @param warName The name of a deployed war. @param token The Github API token used for authentication. @return @throws Exception
[ "Retrieves", "information", "about", "a", "deployed", "cadmium", "war", "." ]
bca585030e141803a73b58abb128d130157b6ddf
https://github.com/meltmedia/cadmium/blob/bca585030e141803a73b58abb128d130157b6ddf/cli/src/main/java/com/meltmedia/cadmium/cli/WarInfoCommand.java#L102-L116
train
meltmedia/cadmium
core/src/main/java/com/meltmedia/cadmium/core/config/impl/YamlConfigurationParser.java
YamlConfigurationParser.mergeConfigs
@SuppressWarnings("unchecked") private void mergeConfigs(Map<String, Map<String, ?>> configurationMap, Object parsed) { if(parsed instanceof Map) { Map<?, ?> parsedMap = (Map<?, ?>) parsed; for(Object key : parsedMap.keySet()) { if(key instanceof String) { Map<String, Object> existingValue = (Map<String, Object>) configurationMap.get((String) key); if(!configurationMap.containsKey((String) key)) { existingValue = new HashMap<String, Object>(); configurationMap.put((String) key, existingValue); } Object parsedValue = parsedMap.get(key); if(parsedValue instanceof Map) { Map<?, ?> parsedValueMap = (Map<?, ?>) parsedValue; for(Object parsedKey : parsedValueMap.keySet()) { if(parsedKey instanceof String) { existingValue.put((String) parsedKey, parsedValueMap.get(parsedKey)); } } } } } } }
java
@SuppressWarnings("unchecked") private void mergeConfigs(Map<String, Map<String, ?>> configurationMap, Object parsed) { if(parsed instanceof Map) { Map<?, ?> parsedMap = (Map<?, ?>) parsed; for(Object key : parsedMap.keySet()) { if(key instanceof String) { Map<String, Object> existingValue = (Map<String, Object>) configurationMap.get((String) key); if(!configurationMap.containsKey((String) key)) { existingValue = new HashMap<String, Object>(); configurationMap.put((String) key, existingValue); } Object parsedValue = parsedMap.get(key); if(parsedValue instanceof Map) { Map<?, ?> parsedValueMap = (Map<?, ?>) parsedValue; for(Object parsedKey : parsedValueMap.keySet()) { if(parsedKey instanceof String) { existingValue.put((String) parsedKey, parsedValueMap.get(parsedKey)); } } } } } } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "void", "mergeConfigs", "(", "Map", "<", "String", ",", "Map", "<", "String", ",", "?", ">", ">", "configurationMap", ",", "Object", "parsed", ")", "{", "if", "(", "parsed", "instanceof", "Map"...
Merges configurations from an Object into an existing Map. @param configurationMap @param parsed
[ "Merges", "configurations", "from", "an", "Object", "into", "an", "existing", "Map", "." ]
bca585030e141803a73b58abb128d130157b6ddf
https://github.com/meltmedia/cadmium/blob/bca585030e141803a73b58abb128d130157b6ddf/core/src/main/java/com/meltmedia/cadmium/core/config/impl/YamlConfigurationParser.java#L121-L145
train
meltmedia/cadmium
core/src/main/java/com/meltmedia/cadmium/core/config/impl/YamlConfigurationParser.java
YamlConfigurationParser.getEnvConfig
private <T> T getEnvConfig(Map<String, ?> configs, String key, Class<T> type) { if(configs.containsKey(key)) { Object config = configs.get(key); if(type.isAssignableFrom(config.getClass())) { return type.cast(config); } } return null; }
java
private <T> T getEnvConfig(Map<String, ?> configs, String key, Class<T> type) { if(configs.containsKey(key)) { Object config = configs.get(key); if(type.isAssignableFrom(config.getClass())) { return type.cast(config); } } return null; }
[ "private", "<", "T", ">", "T", "getEnvConfig", "(", "Map", "<", "String", ",", "?", ">", "configs", ",", "String", "key", ",", "Class", "<", "T", ">", "type", ")", "{", "if", "(", "configs", ".", "containsKey", "(", "key", ")", ")", "{", "Object"...
Helper method used to retrieve the value from a given map if it matches the type specified. @param configs The map to pull from. @param key The key to pull. @param type The expected type of the value. @return
[ "Helper", "method", "used", "to", "retrieve", "the", "value", "from", "a", "given", "map", "if", "it", "matches", "the", "type", "specified", "." ]
bca585030e141803a73b58abb128d130157b6ddf
https://github.com/meltmedia/cadmium/blob/bca585030e141803a73b58abb128d130157b6ddf/core/src/main/java/com/meltmedia/cadmium/core/config/impl/YamlConfigurationParser.java#L201-L209
train
meltmedia/cadmium
persistence/src/main/java/com/meltmedia/cadmium/persistence/CadmiumPersistenceProvider.java
CadmiumPersistenceProvider.createEntityManagerFactory
@SuppressWarnings("rawtypes") @Override public EntityManagerFactory createEntityManagerFactory(String emName, Map properties) { PersistenceUnitInfo pUnit = new CadmiumPersistenceUnitInfo() ; return createContainerEntityManagerFactory(pUnit, properties); }
java
@SuppressWarnings("rawtypes") @Override public EntityManagerFactory createEntityManagerFactory(String emName, Map properties) { PersistenceUnitInfo pUnit = new CadmiumPersistenceUnitInfo() ; return createContainerEntityManagerFactory(pUnit, properties); }
[ "@", "SuppressWarnings", "(", "\"rawtypes\"", ")", "@", "Override", "public", "EntityManagerFactory", "createEntityManagerFactory", "(", "String", "emName", ",", "Map", "properties", ")", "{", "PersistenceUnitInfo", "pUnit", "=", "new", "CadmiumPersistenceUnitInfo", "("...
Uses Hibernate's Reflections and the properties map to override defaults to create a EntityManagerFactory without the need of any persistence.xml file.
[ "Uses", "Hibernate", "s", "Reflections", "and", "the", "properties", "map", "to", "override", "defaults", "to", "create", "a", "EntityManagerFactory", "without", "the", "need", "of", "any", "persistence", ".", "xml", "file", "." ]
bca585030e141803a73b58abb128d130157b6ddf
https://github.com/meltmedia/cadmium/blob/bca585030e141803a73b58abb128d130157b6ddf/persistence/src/main/java/com/meltmedia/cadmium/persistence/CadmiumPersistenceProvider.java#L91-L96
train
meltmedia/cadmium
persistence/src/main/java/com/meltmedia/cadmium/persistence/CadmiumPersistenceProvider.java
CadmiumPersistenceProvider.createContainerEntityManagerFactory
@SuppressWarnings("rawtypes") @Override public EntityManagerFactory createContainerEntityManagerFactory( PersistenceUnitInfo info, Map properties) { EntityManagerFactory factory = wrappedPersistenceProvider.createContainerEntityManagerFactory(info, properties); return factory; }
java
@SuppressWarnings("rawtypes") @Override public EntityManagerFactory createContainerEntityManagerFactory( PersistenceUnitInfo info, Map properties) { EntityManagerFactory factory = wrappedPersistenceProvider.createContainerEntityManagerFactory(info, properties); return factory; }
[ "@", "SuppressWarnings", "(", "\"rawtypes\"", ")", "@", "Override", "public", "EntityManagerFactory", "createContainerEntityManagerFactory", "(", "PersistenceUnitInfo", "info", ",", "Map", "properties", ")", "{", "EntityManagerFactory", "factory", "=", "wrappedPersistencePr...
This just delegates to the HibernatePersistence method.
[ "This", "just", "delegates", "to", "the", "HibernatePersistence", "method", "." ]
bca585030e141803a73b58abb128d130157b6ddf
https://github.com/meltmedia/cadmium/blob/bca585030e141803a73b58abb128d130157b6ddf/persistence/src/main/java/com/meltmedia/cadmium/persistence/CadmiumPersistenceProvider.java#L101-L107
train
meltmedia/cadmium
servlets/src/main/java/com/meltmedia/cadmium/servlets/jersey/AuthenticationManagerService.java
AuthenticationManagerService.getConfigurableUsers
@GET public Response getConfigurableUsers(@HeaderParam("Authorization") @DefaultValue("no token") String auth) throws Exception { if(!this.isAuth(auth)) { throw new Exception("Unauthorized!"); } if( realm != null ) { List<String> usernames = new ArrayList<String>(); usernames = realm.listUsers(); return Response.ok(new Gson().toJson(usernames), MediaType.APPLICATION_JSON).build(); } return Response.status(Status.NOT_FOUND).build(); }
java
@GET public Response getConfigurableUsers(@HeaderParam("Authorization") @DefaultValue("no token") String auth) throws Exception { if(!this.isAuth(auth)) { throw new Exception("Unauthorized!"); } if( realm != null ) { List<String> usernames = new ArrayList<String>(); usernames = realm.listUsers(); return Response.ok(new Gson().toJson(usernames), MediaType.APPLICATION_JSON).build(); } return Response.status(Status.NOT_FOUND).build(); }
[ "@", "GET", "public", "Response", "getConfigurableUsers", "(", "@", "HeaderParam", "(", "\"Authorization\"", ")", "@", "DefaultValue", "(", "\"no token\"", ")", "String", "auth", ")", "throws", "Exception", "{", "if", "(", "!", "this", ".", "isAuth", "(", "a...
Returns a list of users specific to this site only. @param auth @return @throws Exception
[ "Returns", "a", "list", "of", "users", "specific", "to", "this", "site", "only", "." ]
bca585030e141803a73b58abb128d130157b6ddf
https://github.com/meltmedia/cadmium/blob/bca585030e141803a73b58abb128d130157b6ddf/servlets/src/main/java/com/meltmedia/cadmium/servlets/jersey/AuthenticationManagerService.java#L64-L75
train
meltmedia/cadmium
servlets/src/main/java/com/meltmedia/cadmium/servlets/jersey/AuthenticationManagerService.java
AuthenticationManagerService.addUser
@PUT @Path("{user}") @Consumes(MediaType.TEXT_PLAIN) public Response addUser(@PathParam("user") String username, @HeaderParam("Authorization") @DefaultValue("no token") String auth, String message) throws Exception { if(!this.isAuth(auth)) { throw new Exception("Unauthorized!"); } if( realm != null ){ AuthenticationManagerRequest req = new AuthenticationManagerRequest(); req.setAccountName(username); req.setPassword(message); req.setRequestType(RequestType.ADD); sendMessage(req); return Response.created(new URI("")).build(); } return Response.status(Status.NOT_FOUND).build(); }
java
@PUT @Path("{user}") @Consumes(MediaType.TEXT_PLAIN) public Response addUser(@PathParam("user") String username, @HeaderParam("Authorization") @DefaultValue("no token") String auth, String message) throws Exception { if(!this.isAuth(auth)) { throw new Exception("Unauthorized!"); } if( realm != null ){ AuthenticationManagerRequest req = new AuthenticationManagerRequest(); req.setAccountName(username); req.setPassword(message); req.setRequestType(RequestType.ADD); sendMessage(req); return Response.created(new URI("")).build(); } return Response.status(Status.NOT_FOUND).build(); }
[ "@", "PUT", "@", "Path", "(", "\"{user}\"", ")", "@", "Consumes", "(", "MediaType", ".", "TEXT_PLAIN", ")", "public", "Response", "addUser", "(", "@", "PathParam", "(", "\"user\"", ")", "String", "username", ",", "@", "HeaderParam", "(", "\"Authorization\"",...
Adds user credentials for access to this site only. @param username @param auth @param message @return @throws Exception
[ "Adds", "user", "credentials", "for", "access", "to", "this", "site", "only", "." ]
bca585030e141803a73b58abb128d130157b6ddf
https://github.com/meltmedia/cadmium/blob/bca585030e141803a73b58abb128d130157b6ddf/servlets/src/main/java/com/meltmedia/cadmium/servlets/jersey/AuthenticationManagerService.java#L86-L103
train
meltmedia/cadmium
servlets/src/main/java/com/meltmedia/cadmium/servlets/jersey/AuthenticationManagerService.java
AuthenticationManagerService.deleteUser
@DELETE @Path("{user}") public Response deleteUser(@PathParam("user") String username, @HeaderParam("Authorization") @DefaultValue("no token") String auth) throws Exception { if(!this.isAuth(auth)) { throw new Exception("Unauthorized!"); } if( realm != null ){ AuthenticationManagerRequest req = new AuthenticationManagerRequest(); req.setAccountName(username); req.setRequestType(RequestType.REMOVE); sendMessage(req); return Response.status(Status.GONE).build(); } return Response.status(Status.NOT_FOUND).build(); }
java
@DELETE @Path("{user}") public Response deleteUser(@PathParam("user") String username, @HeaderParam("Authorization") @DefaultValue("no token") String auth) throws Exception { if(!this.isAuth(auth)) { throw new Exception("Unauthorized!"); } if( realm != null ){ AuthenticationManagerRequest req = new AuthenticationManagerRequest(); req.setAccountName(username); req.setRequestType(RequestType.REMOVE); sendMessage(req); return Response.status(Status.GONE).build(); } return Response.status(Status.NOT_FOUND).build(); }
[ "@", "DELETE", "@", "Path", "(", "\"{user}\"", ")", "public", "Response", "deleteUser", "(", "@", "PathParam", "(", "\"user\"", ")", "String", "username", ",", "@", "HeaderParam", "(", "\"Authorization\"", ")", "@", "DefaultValue", "(", "\"no token\"", ")", ...
Deletes an user from the user acounts specific to this site only. @param username @param auth @return @throws Exception
[ "Deletes", "an", "user", "from", "the", "user", "acounts", "specific", "to", "this", "site", "only", "." ]
bca585030e141803a73b58abb128d130157b6ddf
https://github.com/meltmedia/cadmium/blob/bca585030e141803a73b58abb128d130157b6ddf/servlets/src/main/java/com/meltmedia/cadmium/servlets/jersey/AuthenticationManagerService.java#L112-L127
train
meltmedia/cadmium
servlets/src/main/java/com/meltmedia/cadmium/servlets/jersey/AuthenticationManagerService.java
AuthenticationManagerService.sendMessage
private void sendMessage(AuthenticationManagerRequest req) { Message<AuthenticationManagerRequest> msg = new Message<AuthenticationManagerRequest>(AuthenticationManagerCommandAction.COMMAND_NAME, req); try { sender.sendMessage(msg, null); } catch (Exception e) { log.error("Failed to update authentication.", e); } }
java
private void sendMessage(AuthenticationManagerRequest req) { Message<AuthenticationManagerRequest> msg = new Message<AuthenticationManagerRequest>(AuthenticationManagerCommandAction.COMMAND_NAME, req); try { sender.sendMessage(msg, null); } catch (Exception e) { log.error("Failed to update authentication.", e); } }
[ "private", "void", "sendMessage", "(", "AuthenticationManagerRequest", "req", ")", "{", "Message", "<", "AuthenticationManagerRequest", ">", "msg", "=", "new", "Message", "<", "AuthenticationManagerRequest", ">", "(", "AuthenticationManagerCommandAction", ".", "COMMAND_NA...
Generically send a JGroups message to the cluster. @param req
[ "Generically", "send", "a", "JGroups", "message", "to", "the", "cluster", "." ]
bca585030e141803a73b58abb128d130157b6ddf
https://github.com/meltmedia/cadmium/blob/bca585030e141803a73b58abb128d130157b6ddf/servlets/src/main/java/com/meltmedia/cadmium/servlets/jersey/AuthenticationManagerService.java#L134-L141
train