id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
138,700
lastaflute/lastaflute
src/main/java/org/lastaflute/db/dbflute/classification/TypicalListedClassificationProvider.java
TypicalListedClassificationProvider.findMeta
protected OptionalThing<ClassificationMeta> findMeta(Class<?> defmetaType, String classificationName) { return LaClassificationUtil.findMeta(defmetaType, classificationName); }
java
protected OptionalThing<ClassificationMeta> findMeta(Class<?> defmetaType, String classificationName) { return LaClassificationUtil.findMeta(defmetaType, classificationName); }
[ "protected", "OptionalThing", "<", "ClassificationMeta", ">", "findMeta", "(", "Class", "<", "?", ">", "defmetaType", ",", "String", "classificationName", ")", "{", "return", "LaClassificationUtil", ".", "findMeta", "(", "defmetaType", ",", "classificationName", ")", ";", "}" ]
helper for sub class
[ "helper", "for", "sub", "class" ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/db/dbflute/classification/TypicalListedClassificationProvider.java#L104-L106
138,701
jboss/jboss-jsf-api_spec
src/main/java/javax/faces/component/UIInput.java
UIInput.executeValidate
private void executeValidate(FacesContext context) { try { validate(context); } catch (RuntimeException e) { context.renderResponse(); throw e; } if (!isValid()) { context.validationFailed(); context.renderResponse(); } }
java
private void executeValidate(FacesContext context) { try { validate(context); } catch (RuntimeException e) { context.renderResponse(); throw e; } if (!isValid()) { context.validationFailed(); context.renderResponse(); } }
[ "private", "void", "executeValidate", "(", "FacesContext", "context", ")", "{", "try", "{", "validate", "(", "context", ")", ";", "}", "catch", "(", "RuntimeException", "e", ")", "{", "context", ".", "renderResponse", "(", ")", ";", "throw", "e", ";", "}", "if", "(", "!", "isValid", "(", ")", ")", "{", "context", ".", "validationFailed", "(", ")", ";", "context", ".", "renderResponse", "(", ")", ";", "}", "}" ]
Executes validation logic.
[ "Executes", "validation", "logic", "." ]
cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3
https://github.com/jboss/jboss-jsf-api_spec/blob/cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3/src/main/java/javax/faces/component/UIInput.java#L1246-L1258
138,702
lastaflute/lastaflute
src/main/java/org/lastaflute/web/ruts/ActionRequestProcessor.java
ActionRequestProcessor.fire
protected void fire(ActionRuntime runtime) throws IOException, ServletException { final ActionResponseReflector reflector = createResponseReflector(runtime); ready(runtime, reflector); final OptionalThing<VirtualForm> form = prepareActionForm(runtime); populateParameter(runtime, form); final VirtualAction action = createAction(runtime, reflector); final NextJourney journey = performAction(action, form, runtime); // #to_action toNext(runtime, journey); }
java
protected void fire(ActionRuntime runtime) throws IOException, ServletException { final ActionResponseReflector reflector = createResponseReflector(runtime); ready(runtime, reflector); final OptionalThing<VirtualForm> form = prepareActionForm(runtime); populateParameter(runtime, form); final VirtualAction action = createAction(runtime, reflector); final NextJourney journey = performAction(action, form, runtime); // #to_action toNext(runtime, journey); }
[ "protected", "void", "fire", "(", "ActionRuntime", "runtime", ")", "throws", "IOException", ",", "ServletException", "{", "final", "ActionResponseReflector", "reflector", "=", "createResponseReflector", "(", "runtime", ")", ";", "ready", "(", "runtime", ",", "reflector", ")", ";", "final", "OptionalThing", "<", "VirtualForm", ">", "form", "=", "prepareActionForm", "(", "runtime", ")", ";", "populateParameter", "(", "runtime", ",", "form", ")", ";", "final", "VirtualAction", "action", "=", "createAction", "(", "runtime", ",", "reflector", ")", ";", "final", "NextJourney", "journey", "=", "performAction", "(", "action", ",", "form", ",", "runtime", ")", ";", "// #to_action", "toNext", "(", "runtime", ",", "journey", ")", ";", "}" ]
Fire the action, creating, populating, performing and to next. @param runtime The runtime meta of action execute, which has action execute, path parameter and states. (NotNull) @throws IOException When the action fails about the IO. @throws ServletException When the action fails about the Servlet.
[ "Fire", "the", "action", "creating", "populating", "performing", "and", "to", "next", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/web/ruts/ActionRequestProcessor.java#L177-L188
138,703
lastaflute/lastaflute
src/main/java/org/lastaflute/core/json/SimpleJsonManager.java
SimpleJsonManager.createGsonJsonEngine
protected GsonJsonEngine createGsonJsonEngine(JsonEngineResource resource) { final boolean serializeNulls = isGsonSerializeNulls(); final boolean prettyPrinting = isGsonPrettyPrinting(); final Consumer<GsonBuilder> builderSetupper = prepareGsonBuilderSetupper(serializeNulls, prettyPrinting); final Consumer<JsonMappingOption> optionSetupper = prepareMappingOptionSetupper(resource.getMappingOption()); return resource.getYourEngineCreator().map(creator -> { // rare option return createYourEngine(creator, builderSetupper, optionSetupper); }).orElseGet(() -> { // mainly here return newGsonJsonEngine(builderSetupper, optionSetupper); }); }
java
protected GsonJsonEngine createGsonJsonEngine(JsonEngineResource resource) { final boolean serializeNulls = isGsonSerializeNulls(); final boolean prettyPrinting = isGsonPrettyPrinting(); final Consumer<GsonBuilder> builderSetupper = prepareGsonBuilderSetupper(serializeNulls, prettyPrinting); final Consumer<JsonMappingOption> optionSetupper = prepareMappingOptionSetupper(resource.getMappingOption()); return resource.getYourEngineCreator().map(creator -> { // rare option return createYourEngine(creator, builderSetupper, optionSetupper); }).orElseGet(() -> { // mainly here return newGsonJsonEngine(builderSetupper, optionSetupper); }); }
[ "protected", "GsonJsonEngine", "createGsonJsonEngine", "(", "JsonEngineResource", "resource", ")", "{", "final", "boolean", "serializeNulls", "=", "isGsonSerializeNulls", "(", ")", ";", "final", "boolean", "prettyPrinting", "=", "isGsonPrettyPrinting", "(", ")", ";", "final", "Consumer", "<", "GsonBuilder", ">", "builderSetupper", "=", "prepareGsonBuilderSetupper", "(", "serializeNulls", ",", "prettyPrinting", ")", ";", "final", "Consumer", "<", "JsonMappingOption", ">", "optionSetupper", "=", "prepareMappingOptionSetupper", "(", "resource", ".", "getMappingOption", "(", ")", ")", ";", "return", "resource", ".", "getYourEngineCreator", "(", ")", ".", "map", "(", "creator", "->", "{", "// rare option", "return", "createYourEngine", "(", "creator", ",", "builderSetupper", ",", "optionSetupper", ")", ";", "}", ")", ".", "orElseGet", "(", "(", ")", "->", "{", "// mainly here", "return", "newGsonJsonEngine", "(", "builderSetupper", ",", "optionSetupper", ")", ";", "}", ")", ";", "}" ]
mappingOption is specified for another engine
[ "mappingOption", "is", "specified", "for", "another", "engine" ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/core/json/SimpleJsonManager.java#L213-L223
138,704
lastaflute/lastaflute
src/main/java/org/lastaflute/db/jta/stage/BegunTxContext.java
BegunTxContext.getBegunTxOnThread
public static BegunTx<?> getBegunTxOnThread() { final Stack<BegunTx<?>> stack = threadLocal.get(); return stack != null ? stack.peek() : null; }
java
public static BegunTx<?> getBegunTxOnThread() { final Stack<BegunTx<?>> stack = threadLocal.get(); return stack != null ? stack.peek() : null; }
[ "public", "static", "BegunTx", "<", "?", ">", "getBegunTxOnThread", "(", ")", "{", "final", "Stack", "<", "BegunTx", "<", "?", ">", ">", "stack", "=", "threadLocal", ".", "get", "(", ")", ";", "return", "stack", "!=", "null", "?", "stack", ".", "peek", "(", ")", ":", "null", ";", "}" ]
Get prepared begun-tx on thread. @return The context of DB access. (NullAllowed)
[ "Get", "prepared", "begun", "-", "tx", "on", "thread", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/db/jta/stage/BegunTxContext.java#L32-L35
138,705
lastaflute/lastaflute
src/main/java/org/lastaflute/db/jta/stage/BegunTxContext.java
BegunTxContext.setBegunTxOnThread
public static void setBegunTxOnThread(BegunTx<?> begunTx) { if (begunTx == null) { String msg = "The argument[begunTx] must not be null."; throw new IllegalArgumentException(msg); } Stack<BegunTx<?>> stack = threadLocal.get(); if (stack == null) { stack = new Stack<BegunTx<?>>(); threadLocal.set(stack); } stack.add(begunTx); }
java
public static void setBegunTxOnThread(BegunTx<?> begunTx) { if (begunTx == null) { String msg = "The argument[begunTx] must not be null."; throw new IllegalArgumentException(msg); } Stack<BegunTx<?>> stack = threadLocal.get(); if (stack == null) { stack = new Stack<BegunTx<?>>(); threadLocal.set(stack); } stack.add(begunTx); }
[ "public", "static", "void", "setBegunTxOnThread", "(", "BegunTx", "<", "?", ">", "begunTx", ")", "{", "if", "(", "begunTx", "==", "null", ")", "{", "String", "msg", "=", "\"The argument[begunTx] must not be null.\"", ";", "throw", "new", "IllegalArgumentException", "(", "msg", ")", ";", "}", "Stack", "<", "BegunTx", "<", "?", ">", ">", "stack", "=", "threadLocal", ".", "get", "(", ")", ";", "if", "(", "stack", "==", "null", ")", "{", "stack", "=", "new", "Stack", "<", "BegunTx", "<", "?", ">", ">", "(", ")", ";", "threadLocal", ".", "set", "(", "stack", ")", ";", "}", "stack", ".", "add", "(", "begunTx", ")", ";", "}" ]
Set prepared begun-tx on thread. @param begunTx The context of DB access. (NotNull)
[ "Set", "prepared", "begun", "-", "tx", "on", "thread", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/db/jta/stage/BegunTxContext.java#L41-L52
138,706
lastaflute/lastaflute
src/main/java/org/lastaflute/db/jta/stage/BegunTxContext.java
BegunTxContext.existsBegunTxOnThread
public static boolean existsBegunTxOnThread() { final Stack<BegunTx<?>> stack = threadLocal.get(); return stack != null ? !stack.isEmpty() : false; }
java
public static boolean existsBegunTxOnThread() { final Stack<BegunTx<?>> stack = threadLocal.get(); return stack != null ? !stack.isEmpty() : false; }
[ "public", "static", "boolean", "existsBegunTxOnThread", "(", ")", "{", "final", "Stack", "<", "BegunTx", "<", "?", ">", ">", "stack", "=", "threadLocal", ".", "get", "(", ")", ";", "return", "stack", "!=", "null", "?", "!", "stack", ".", "isEmpty", "(", ")", ":", "false", ";", "}" ]
Is existing prepared begun-tx on thread? @return The determination, true or false.
[ "Is", "existing", "prepared", "begun", "-", "tx", "on", "thread?" ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/db/jta/stage/BegunTxContext.java#L58-L61
138,707
lastaflute/lastaflute
src/main/java/org/lastaflute/db/jta/stage/BegunTxContext.java
BegunTxContext.clearBegunTxOnThread
public static void clearBegunTxOnThread() { final Stack<BegunTx<?>> stack = threadLocal.get(); if (stack != null) { stack.pop(); // remove latest if (stack.isEmpty()) { perfectlyClear(); } } }
java
public static void clearBegunTxOnThread() { final Stack<BegunTx<?>> stack = threadLocal.get(); if (stack != null) { stack.pop(); // remove latest if (stack.isEmpty()) { perfectlyClear(); } } }
[ "public", "static", "void", "clearBegunTxOnThread", "(", ")", "{", "final", "Stack", "<", "BegunTx", "<", "?", ">", ">", "stack", "=", "threadLocal", ".", "get", "(", ")", ";", "if", "(", "stack", "!=", "null", ")", "{", "stack", ".", "pop", "(", ")", ";", "// remove latest", "if", "(", "stack", ".", "isEmpty", "(", ")", ")", "{", "perfectlyClear", "(", ")", ";", "}", "}", "}" ]
Clear prepared begun-tx on thread.
[ "Clear", "prepared", "begun", "-", "tx", "on", "thread", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/db/jta/stage/BegunTxContext.java#L66-L74
138,708
lastaflute/lastaflute
src/main/java/org/lastaflute/db/jta/TransactionRomanticContext.java
TransactionRomanticContext.getRomanticTransaction
public static RomanticTransaction getRomanticTransaction() { final Stack<RomanticTransaction> stack = threadLocal.get(); return stack != null ? stack.peek() : null; }
java
public static RomanticTransaction getRomanticTransaction() { final Stack<RomanticTransaction> stack = threadLocal.get(); return stack != null ? stack.peek() : null; }
[ "public", "static", "RomanticTransaction", "getRomanticTransaction", "(", ")", "{", "final", "Stack", "<", "RomanticTransaction", ">", "stack", "=", "threadLocal", ".", "get", "(", ")", ";", "return", "stack", "!=", "null", "?", "stack", ".", "peek", "(", ")", ":", "null", ";", "}" ]
Get the value of the romantic transaction. @return The value of the transaction time. (NullAllowed)
[ "Get", "the", "value", "of", "the", "romantic", "transaction", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/db/jta/TransactionRomanticContext.java#L34-L37
138,709
lastaflute/lastaflute
src/main/java/org/lastaflute/db/jta/TransactionRomanticContext.java
TransactionRomanticContext.setRomanticTransaction
public static void setRomanticTransaction(RomanticTransaction romanticTransaction) { if (romanticTransaction == null) { String msg = "The argument 'romanticTransaction' should not be null."; throw new IllegalArgumentException(msg); } Stack<RomanticTransaction> stack = threadLocal.get(); if (stack == null) { stack = new Stack<RomanticTransaction>(); threadLocal.set(stack); } stack.push(romanticTransaction); }
java
public static void setRomanticTransaction(RomanticTransaction romanticTransaction) { if (romanticTransaction == null) { String msg = "The argument 'romanticTransaction' should not be null."; throw new IllegalArgumentException(msg); } Stack<RomanticTransaction> stack = threadLocal.get(); if (stack == null) { stack = new Stack<RomanticTransaction>(); threadLocal.set(stack); } stack.push(romanticTransaction); }
[ "public", "static", "void", "setRomanticTransaction", "(", "RomanticTransaction", "romanticTransaction", ")", "{", "if", "(", "romanticTransaction", "==", "null", ")", "{", "String", "msg", "=", "\"The argument 'romanticTransaction' should not be null.\"", ";", "throw", "new", "IllegalArgumentException", "(", "msg", ")", ";", "}", "Stack", "<", "RomanticTransaction", ">", "stack", "=", "threadLocal", ".", "get", "(", ")", ";", "if", "(", "stack", "==", "null", ")", "{", "stack", "=", "new", "Stack", "<", "RomanticTransaction", ">", "(", ")", ";", "threadLocal", ".", "set", "(", "stack", ")", ";", "}", "stack", ".", "push", "(", "romanticTransaction", ")", ";", "}" ]
Set the value of the romantic transaction. @param romanticTransaction The value of the romantic transaction. (NotNull)
[ "Set", "the", "value", "of", "the", "romantic", "transaction", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/db/jta/TransactionRomanticContext.java#L43-L54
138,710
jboss/jboss-jsf-api_spec
src/main/java/javax/faces/component/UIData.java
UIData.visitColumnsAndColumnFacets
private boolean visitColumnsAndColumnFacets(VisitContext context, VisitCallback callback, boolean visitRows) { if (visitRows) { setRowIndex(-1); } if (getChildCount() > 0) { for (UIComponent column : getChildren()) { if (column instanceof UIColumn) { VisitResult result = context.invokeVisitCallback(column, callback); // visit the column directly if (result == VisitResult.COMPLETE) { return true; } if (column.getFacetCount() > 0) { for (UIComponent columnFacet : column.getFacets().values()) { if (columnFacet.visitTree(context, callback)) { return true; } } } } } } return false; }
java
private boolean visitColumnsAndColumnFacets(VisitContext context, VisitCallback callback, boolean visitRows) { if (visitRows) { setRowIndex(-1); } if (getChildCount() > 0) { for (UIComponent column : getChildren()) { if (column instanceof UIColumn) { VisitResult result = context.invokeVisitCallback(column, callback); // visit the column directly if (result == VisitResult.COMPLETE) { return true; } if (column.getFacetCount() > 0) { for (UIComponent columnFacet : column.getFacets().values()) { if (columnFacet.visitTree(context, callback)) { return true; } } } } } } return false; }
[ "private", "boolean", "visitColumnsAndColumnFacets", "(", "VisitContext", "context", ",", "VisitCallback", "callback", ",", "boolean", "visitRows", ")", "{", "if", "(", "visitRows", ")", "{", "setRowIndex", "(", "-", "1", ")", ";", "}", "if", "(", "getChildCount", "(", ")", ">", "0", ")", "{", "for", "(", "UIComponent", "column", ":", "getChildren", "(", ")", ")", "{", "if", "(", "column", "instanceof", "UIColumn", ")", "{", "VisitResult", "result", "=", "context", ".", "invokeVisitCallback", "(", "column", ",", "callback", ")", ";", "// visit the column directly", "if", "(", "result", "==", "VisitResult", ".", "COMPLETE", ")", "{", "return", "true", ";", "}", "if", "(", "column", ".", "getFacetCount", "(", ")", ">", "0", ")", "{", "for", "(", "UIComponent", "columnFacet", ":", "column", ".", "getFacets", "(", ")", ".", "values", "(", ")", ")", "{", "if", "(", "columnFacet", ".", "visitTree", "(", "context", ",", "callback", ")", ")", "{", "return", "true", ";", "}", "}", "}", "}", "}", "}", "return", "false", ";", "}" ]
Visit each UIColumn and any facets it may have defined exactly once
[ "Visit", "each", "UIColumn", "and", "any", "facets", "it", "may", "have", "defined", "exactly", "once" ]
cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3
https://github.com/jboss/jboss-jsf-api_spec/blob/cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3/src/main/java/javax/faces/component/UIData.java#L2100-L2125
138,711
jboss/jboss-jsf-api_spec
src/main/java/javax/faces/component/UIData.java
UIData.visitRows
private boolean visitRows(VisitContext context, VisitCallback callback, boolean visitRows) { // Iterate over our UIColumn children, once per row int processed = 0; int rowIndex = 0; int rows = 0; if (visitRows) { rowIndex = getFirst() - 1; rows = getRows(); } while (true) { // Have we processed the requested number of rows? if (visitRows) { if ((rows > 0) && (++processed > rows)) { break; } // Expose the current row in the specified request attribute setRowIndex(++rowIndex); if (!isRowAvailable()) { break; // Scrolled past the last row } } // Visit as required on the *children* of the UIColumn // (facets have been done a single time with rowIndex=-1 already) if (getChildCount() > 0) { for (UIComponent kid : getChildren()) { if (!(kid instanceof UIColumn)) { continue; } if (kid.getChildCount() > 0) { for (UIComponent grandkid : kid.getChildren()) { if (grandkid.visitTree(context, callback)) { return true; } } } } } if (!visitRows) { break; } } return false; }
java
private boolean visitRows(VisitContext context, VisitCallback callback, boolean visitRows) { // Iterate over our UIColumn children, once per row int processed = 0; int rowIndex = 0; int rows = 0; if (visitRows) { rowIndex = getFirst() - 1; rows = getRows(); } while (true) { // Have we processed the requested number of rows? if (visitRows) { if ((rows > 0) && (++processed > rows)) { break; } // Expose the current row in the specified request attribute setRowIndex(++rowIndex); if (!isRowAvailable()) { break; // Scrolled past the last row } } // Visit as required on the *children* of the UIColumn // (facets have been done a single time with rowIndex=-1 already) if (getChildCount() > 0) { for (UIComponent kid : getChildren()) { if (!(kid instanceof UIColumn)) { continue; } if (kid.getChildCount() > 0) { for (UIComponent grandkid : kid.getChildren()) { if (grandkid.visitTree(context, callback)) { return true; } } } } } if (!visitRows) { break; } } return false; }
[ "private", "boolean", "visitRows", "(", "VisitContext", "context", ",", "VisitCallback", "callback", ",", "boolean", "visitRows", ")", "{", "// Iterate over our UIColumn children, once per row", "int", "processed", "=", "0", ";", "int", "rowIndex", "=", "0", ";", "int", "rows", "=", "0", ";", "if", "(", "visitRows", ")", "{", "rowIndex", "=", "getFirst", "(", ")", "-", "1", ";", "rows", "=", "getRows", "(", ")", ";", "}", "while", "(", "true", ")", "{", "// Have we processed the requested number of rows?", "if", "(", "visitRows", ")", "{", "if", "(", "(", "rows", ">", "0", ")", "&&", "(", "++", "processed", ">", "rows", ")", ")", "{", "break", ";", "}", "// Expose the current row in the specified request attribute", "setRowIndex", "(", "++", "rowIndex", ")", ";", "if", "(", "!", "isRowAvailable", "(", ")", ")", "{", "break", ";", "// Scrolled past the last row", "}", "}", "// Visit as required on the *children* of the UIColumn", "// (facets have been done a single time with rowIndex=-1 already)", "if", "(", "getChildCount", "(", ")", ">", "0", ")", "{", "for", "(", "UIComponent", "kid", ":", "getChildren", "(", ")", ")", "{", "if", "(", "!", "(", "kid", "instanceof", "UIColumn", ")", ")", "{", "continue", ";", "}", "if", "(", "kid", ".", "getChildCount", "(", ")", ">", "0", ")", "{", "for", "(", "UIComponent", "grandkid", ":", "kid", ".", "getChildren", "(", ")", ")", "{", "if", "(", "grandkid", ".", "visitTree", "(", "context", ",", "callback", ")", ")", "{", "return", "true", ";", "}", "}", "}", "}", "}", "if", "(", "!", "visitRows", ")", "{", "break", ";", "}", "}", "return", "false", ";", "}" ]
Visit each column and row
[ "Visit", "each", "column", "and", "row" ]
cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3
https://github.com/jboss/jboss-jsf-api_spec/blob/cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3/src/main/java/javax/faces/component/UIData.java#L2128-L2179
138,712
lastaflute/lastaflute
src/main/java/org/lastaflute/web/ruts/process/ActionRuntime.java
ActionRuntime.isForwardToHtml
public boolean isForwardToHtml() { if (!isHtmlResponse()) { // e.g. exception, AJAX return false; } final HtmlResponse htmlResponse = ((HtmlResponse) actionResponse); return !htmlResponse.isRedirectTo() && isHtmlTemplateResponse(htmlResponse); }
java
public boolean isForwardToHtml() { if (!isHtmlResponse()) { // e.g. exception, AJAX return false; } final HtmlResponse htmlResponse = ((HtmlResponse) actionResponse); return !htmlResponse.isRedirectTo() && isHtmlTemplateResponse(htmlResponse); }
[ "public", "boolean", "isForwardToHtml", "(", ")", "{", "if", "(", "!", "isHtmlResponse", "(", ")", ")", "{", "// e.g. exception, AJAX", "return", "false", ";", "}", "final", "HtmlResponse", "htmlResponse", "=", "(", "(", "HtmlResponse", ")", "actionResponse", ")", ";", "return", "!", "htmlResponse", ".", "isRedirectTo", "(", ")", "&&", "isHtmlTemplateResponse", "(", "htmlResponse", ")", ";", "}" ]
Is the result of the action execute, forward to HTML template? @return The determination, true or false.
[ "Is", "the", "result", "of", "the", "action", "execute", "forward", "to", "HTML", "template?" ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/web/ruts/process/ActionRuntime.java#L116-L122
138,713
lastaflute/lastaflute
src/main/java/org/lastaflute/web/path/ActionPathResolver.java
ActionPathResolver.handleActionPath
public boolean handleActionPath(String requestPath, ActionFoundPathHandler handler) throws Exception { assertArgumentNotNull("requestPath", requestPath); assertArgumentNotNull("handler", handler); final MappingPathResource pathResource = customizeActionMapping(requestPath); return mappingActionPath(pathResource, handler); }
java
public boolean handleActionPath(String requestPath, ActionFoundPathHandler handler) throws Exception { assertArgumentNotNull("requestPath", requestPath); assertArgumentNotNull("handler", handler); final MappingPathResource pathResource = customizeActionMapping(requestPath); return mappingActionPath(pathResource, handler); }
[ "public", "boolean", "handleActionPath", "(", "String", "requestPath", ",", "ActionFoundPathHandler", "handler", ")", "throws", "Exception", "{", "assertArgumentNotNull", "(", "\"requestPath\"", ",", "requestPath", ")", ";", "assertArgumentNotNull", "(", "\"handler\"", ",", "handler", ")", ";", "final", "MappingPathResource", "pathResource", "=", "customizeActionMapping", "(", "requestPath", ")", ";", "return", "mappingActionPath", "(", "pathResource", ",", "handler", ")", ";", "}" ]
Handle the action path from the specified request path. @param requestPath The request path to be analyzed. (NotNull) @param handler The handler of the action path when the action is found. (NotNull) @return Is it actually handled? (false if not found) @throws Exception When the handler throws or internal process throws.
[ "Handle", "the", "action", "path", "from", "the", "specified", "request", "path", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/web/path/ActionPathResolver.java#L109-L114
138,714
lastaflute/lastaflute
src/main/java/org/lastaflute/core/security/InvertibleCryptographer.java
InvertibleCryptographer.encrypt
public synchronized String encrypt(String plainText) { assertArgumentNotNull("plainText", plainText); if (encryptingCipher == null) { initialize(); } return new String(encodeHex(doEncrypt(plainText))); }
java
public synchronized String encrypt(String plainText) { assertArgumentNotNull("plainText", plainText); if (encryptingCipher == null) { initialize(); } return new String(encodeHex(doEncrypt(plainText))); }
[ "public", "synchronized", "String", "encrypt", "(", "String", "plainText", ")", "{", "assertArgumentNotNull", "(", "\"plainText\"", ",", "plainText", ")", ";", "if", "(", "encryptingCipher", "==", "null", ")", "{", "initialize", "(", ")", ";", "}", "return", "new", "String", "(", "encodeHex", "(", "doEncrypt", "(", "plainText", ")", ")", ")", ";", "}" ]
Encrypt the text as invertible. @param plainText The plain text to be encrypted. (NotNull, EmptyAllowed) @return The encrypted text from the plain text. (NotNull, EmptyAllowed: depends on algorithm) @throws CipherFailureException When the cipher fails.
[ "Encrypt", "the", "text", "as", "invertible", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/core/security/InvertibleCryptographer.java#L147-L153
138,715
lastaflute/lastaflute
src/main/java/org/lastaflute/web/UrlChain.java
UrlChain.moreUrl
public UrlChain moreUrl(Object... urlParts) { final String argTitle = "urlParts"; assertArgumentNotNull(argTitle, urlParts); checkWrongUrlChainUse(argTitle, urlParts); this.urlParts = urlParts; return this; }
java
public UrlChain moreUrl(Object... urlParts) { final String argTitle = "urlParts"; assertArgumentNotNull(argTitle, urlParts); checkWrongUrlChainUse(argTitle, urlParts); this.urlParts = urlParts; return this; }
[ "public", "UrlChain", "moreUrl", "(", "Object", "...", "urlParts", ")", "{", "final", "String", "argTitle", "=", "\"urlParts\"", ";", "assertArgumentNotNull", "(", "argTitle", ",", "urlParts", ")", ";", "checkWrongUrlChainUse", "(", "argTitle", ",", "urlParts", ")", ";", "this", ".", "urlParts", "=", "urlParts", ";", "return", "this", ";", "}" ]
Set up more URL parts as URL chain. @param urlParts The varying array of URL parts. (NotNull) @return The created instance of URL chain. (NotNull)
[ "Set", "up", "more", "URL", "parts", "as", "URL", "chain", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/web/UrlChain.java#L54-L60
138,716
lastaflute/lastaflute
src/main/java/org/lastaflute/web/UrlChain.java
UrlChain.params
public UrlChain params(Object... paramsOnGet) { final String argTitle = "paramsOnGet"; assertArgumentNotNull(argTitle, paramsOnGet); checkWrongUrlChainUse(argTitle, paramsOnGet); this.paramsOnGet = paramsOnGet; return this; }
java
public UrlChain params(Object... paramsOnGet) { final String argTitle = "paramsOnGet"; assertArgumentNotNull(argTitle, paramsOnGet); checkWrongUrlChainUse(argTitle, paramsOnGet); this.paramsOnGet = paramsOnGet; return this; }
[ "public", "UrlChain", "params", "(", "Object", "...", "paramsOnGet", ")", "{", "final", "String", "argTitle", "=", "\"paramsOnGet\"", ";", "assertArgumentNotNull", "(", "argTitle", ",", "paramsOnGet", ")", ";", "checkWrongUrlChainUse", "(", "argTitle", ",", "paramsOnGet", ")", ";", "this", ".", "paramsOnGet", "=", "paramsOnGet", ";", "return", "this", ";", "}" ]
Set up parameters on GET as URL chain. @param paramsOnGet The varying array of parameters on GET. (NotNull) @return The created instance of URL chain. (NotNull)
[ "Set", "up", "parameters", "on", "GET", "as", "URL", "chain", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/web/UrlChain.java#L67-L73
138,717
lastaflute/lastaflute
src/main/java/org/lastaflute/web/UrlChain.java
UrlChain.assertArgumentNotNull
protected void assertArgumentNotNull(String argumentName, Object value) { if (argumentName == null) { String msg = "The argument name should not be null: argName=null value=" + value; throw new IllegalArgumentException(msg); } if (value == null) { String msg = "The value should not be null: argName=" + argumentName; throw new IllegalArgumentException(msg); } }
java
protected void assertArgumentNotNull(String argumentName, Object value) { if (argumentName == null) { String msg = "The argument name should not be null: argName=null value=" + value; throw new IllegalArgumentException(msg); } if (value == null) { String msg = "The value should not be null: argName=" + argumentName; throw new IllegalArgumentException(msg); } }
[ "protected", "void", "assertArgumentNotNull", "(", "String", "argumentName", ",", "Object", "value", ")", "{", "if", "(", "argumentName", "==", "null", ")", "{", "String", "msg", "=", "\"The argument name should not be null: argName=null value=\"", "+", "value", ";", "throw", "new", "IllegalArgumentException", "(", "msg", ")", ";", "}", "if", "(", "value", "==", "null", ")", "{", "String", "msg", "=", "\"The value should not be null: argName=\"", "+", "argumentName", ";", "throw", "new", "IllegalArgumentException", "(", "msg", ")", ";", "}", "}" ]
Assert that the argument is not null. @param argumentName The name of assert-target argument. (NotNull) @param value The value of argument. (NotNull) @throws IllegalArgumentException When the value is null.
[ "Assert", "that", "the", "argument", "is", "not", "null", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/web/UrlChain.java#L134-L143
138,718
shevek/jcpp
src/main/java/org/anarres/cpp/NumericValue.java
NumericValue.toBigDecimal
@Nonnull public BigDecimal toBigDecimal() { int scale = 0; String text = getIntegerPart(); String t_fraction = getFractionalPart(); if (t_fraction != null) { text += getFractionalPart(); // XXX Wrong for anything but base 10. scale += t_fraction.length(); } String t_exponent = getExponent(); if (t_exponent != null) scale -= Integer.parseInt(t_exponent); BigInteger unscaled = new BigInteger(text, getBase()); return new BigDecimal(unscaled, scale); }
java
@Nonnull public BigDecimal toBigDecimal() { int scale = 0; String text = getIntegerPart(); String t_fraction = getFractionalPart(); if (t_fraction != null) { text += getFractionalPart(); // XXX Wrong for anything but base 10. scale += t_fraction.length(); } String t_exponent = getExponent(); if (t_exponent != null) scale -= Integer.parseInt(t_exponent); BigInteger unscaled = new BigInteger(text, getBase()); return new BigDecimal(unscaled, scale); }
[ "@", "Nonnull", "public", "BigDecimal", "toBigDecimal", "(", ")", "{", "int", "scale", "=", "0", ";", "String", "text", "=", "getIntegerPart", "(", ")", ";", "String", "t_fraction", "=", "getFractionalPart", "(", ")", ";", "if", "(", "t_fraction", "!=", "null", ")", "{", "text", "+=", "getFractionalPart", "(", ")", ";", "// XXX Wrong for anything but base 10.", "scale", "+=", "t_fraction", ".", "length", "(", ")", ";", "}", "String", "t_exponent", "=", "getExponent", "(", ")", ";", "if", "(", "t_exponent", "!=", "null", ")", "scale", "-=", "Integer", ".", "parseInt", "(", "t_exponent", ")", ";", "BigInteger", "unscaled", "=", "new", "BigInteger", "(", "text", ",", "getBase", "(", ")", ")", ";", "return", "new", "BigDecimal", "(", "unscaled", ",", "scale", ")", ";", "}" ]
So, it turns out that parsing arbitrary bases into arbitrary precision numbers is nontrivial, and this routine gets it wrong in many important cases.
[ "So", "it", "turns", "out", "that", "parsing", "arbitrary", "bases", "into", "arbitrary", "precision", "numbers", "is", "nontrivial", "and", "this", "routine", "gets", "it", "wrong", "in", "many", "important", "cases", "." ]
71462c702097cabf8304202c740f780285fc35a8
https://github.com/shevek/jcpp/blob/71462c702097cabf8304202c740f780285fc35a8/src/main/java/org/anarres/cpp/NumericValue.java#L96-L111
138,719
lastaflute/lastaflute
src/main/java/org/lastaflute/web/hook/GodHandEpilogue.java
GodHandEpilogue.handleSqlCount
protected void handleSqlCount(ActionRuntime runtime) { final CallbackContext context = CallbackContext.getCallbackContextOnThread(); if (context == null) { return; } final SqlStringFilter filter = context.getSqlStringFilter(); if (filter == null || !(filter instanceof ExecutedSqlCounter)) { return; } final ExecutedSqlCounter counter = ((ExecutedSqlCounter) filter); final int sqlExecutionCountLimit = getSqlExecutionCountLimit(runtime); if (sqlExecutionCountLimit >= 0 && counter.getTotalCountOfSql() > sqlExecutionCountLimit) { // minus means no check here, by-annotation cannot specify it, can only as default limit // if it needs to specify it by-annotation, enough to set large size handleTooManySqlExecution(runtime, counter, sqlExecutionCountLimit); } saveRequestedSqlCount(counter); }
java
protected void handleSqlCount(ActionRuntime runtime) { final CallbackContext context = CallbackContext.getCallbackContextOnThread(); if (context == null) { return; } final SqlStringFilter filter = context.getSqlStringFilter(); if (filter == null || !(filter instanceof ExecutedSqlCounter)) { return; } final ExecutedSqlCounter counter = ((ExecutedSqlCounter) filter); final int sqlExecutionCountLimit = getSqlExecutionCountLimit(runtime); if (sqlExecutionCountLimit >= 0 && counter.getTotalCountOfSql() > sqlExecutionCountLimit) { // minus means no check here, by-annotation cannot specify it, can only as default limit // if it needs to specify it by-annotation, enough to set large size handleTooManySqlExecution(runtime, counter, sqlExecutionCountLimit); } saveRequestedSqlCount(counter); }
[ "protected", "void", "handleSqlCount", "(", "ActionRuntime", "runtime", ")", "{", "final", "CallbackContext", "context", "=", "CallbackContext", ".", "getCallbackContextOnThread", "(", ")", ";", "if", "(", "context", "==", "null", ")", "{", "return", ";", "}", "final", "SqlStringFilter", "filter", "=", "context", ".", "getSqlStringFilter", "(", ")", ";", "if", "(", "filter", "==", "null", "||", "!", "(", "filter", "instanceof", "ExecutedSqlCounter", ")", ")", "{", "return", ";", "}", "final", "ExecutedSqlCounter", "counter", "=", "(", "(", "ExecutedSqlCounter", ")", "filter", ")", ";", "final", "int", "sqlExecutionCountLimit", "=", "getSqlExecutionCountLimit", "(", "runtime", ")", ";", "if", "(", "sqlExecutionCountLimit", ">=", "0", "&&", "counter", ".", "getTotalCountOfSql", "(", ")", ">", "sqlExecutionCountLimit", ")", "{", "// minus means no check here, by-annotation cannot specify it, can only as default limit", "// if it needs to specify it by-annotation, enough to set large size", "handleTooManySqlExecution", "(", "runtime", ",", "counter", ",", "sqlExecutionCountLimit", ")", ";", "}", "saveRequestedSqlCount", "(", "counter", ")", ";", "}" ]
Handle count of SQL execution in the request. @param runtime The runtime meta of action execute. (NotNull)
[ "Handle", "count", "of", "SQL", "execution", "in", "the", "request", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/web/hook/GodHandEpilogue.java#L89-L106
138,720
lastaflute/lastaflute
src/main/java/org/lastaflute/web/hook/GodHandEpilogue.java
GodHandEpilogue.handleTooManySqlExecution
protected void handleTooManySqlExecution(ActionRuntime runtime, ExecutedSqlCounter sqlCounter, int sqlExecutionCountLimit) { final int totalCountOfSql = sqlCounter.getTotalCountOfSql(); final String actionDisp = buildActionDisp(runtime); logger.warn("*Too many SQL executions: {}/{} in {}", totalCountOfSql, sqlExecutionCountLimit, actionDisp); }
java
protected void handleTooManySqlExecution(ActionRuntime runtime, ExecutedSqlCounter sqlCounter, int sqlExecutionCountLimit) { final int totalCountOfSql = sqlCounter.getTotalCountOfSql(); final String actionDisp = buildActionDisp(runtime); logger.warn("*Too many SQL executions: {}/{} in {}", totalCountOfSql, sqlExecutionCountLimit, actionDisp); }
[ "protected", "void", "handleTooManySqlExecution", "(", "ActionRuntime", "runtime", ",", "ExecutedSqlCounter", "sqlCounter", ",", "int", "sqlExecutionCountLimit", ")", "{", "final", "int", "totalCountOfSql", "=", "sqlCounter", ".", "getTotalCountOfSql", "(", ")", ";", "final", "String", "actionDisp", "=", "buildActionDisp", "(", "runtime", ")", ";", "logger", ".", "warn", "(", "\"*Too many SQL executions: {}/{} in {}\"", ",", "totalCountOfSql", ",", "sqlExecutionCountLimit", ",", "actionDisp", ")", ";", "}" ]
Handle too many SQL executions. @param runtime The runtime meta of action execute. (NotNull) @param sqlCounter The counter object for SQL executions. (NotNull) @param sqlExecutionCountLimit The limit of SQL execution count for the action execute. (NotMinus: already checked here)
[ "Handle", "too", "many", "SQL", "executions", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/web/hook/GodHandEpilogue.java#L114-L118
138,721
lastaflute/lastaflute
src/main/java/org/lastaflute/web/hook/GodHandEpilogue.java
GodHandEpilogue.handleMailCount
protected void handleMailCount(ActionRuntime runtime) { if (ThreadCacheContext.exists()) { final PostedMailCounter counter = ThreadCacheContext.findMailCounter(); if (counter != null) { saveRequestedMailCount(counter); } } }
java
protected void handleMailCount(ActionRuntime runtime) { if (ThreadCacheContext.exists()) { final PostedMailCounter counter = ThreadCacheContext.findMailCounter(); if (counter != null) { saveRequestedMailCount(counter); } } }
[ "protected", "void", "handleMailCount", "(", "ActionRuntime", "runtime", ")", "{", "if", "(", "ThreadCacheContext", ".", "exists", "(", ")", ")", "{", "final", "PostedMailCounter", "counter", "=", "ThreadCacheContext", ".", "findMailCounter", "(", ")", ";", "if", "(", "counter", "!=", "null", ")", "{", "saveRequestedMailCount", "(", "counter", ")", ";", "}", "}", "}" ]
Handle count of mail posting in the request. @param runtime The runtime meta of action execute. (NotNull)
[ "Handle", "count", "of", "mail", "posting", "in", "the", "request", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/web/hook/GodHandEpilogue.java#L149-L156
138,722
lastaflute/lastaflute
src/main/java/org/lastaflute/web/hook/GodHandEpilogue.java
GodHandEpilogue.handleRemoteApiCount
protected void handleRemoteApiCount(ActionRuntime runtime) { if (ThreadCacheContext.exists()) { final CalledRemoteApiCounter counter = ThreadCacheContext.findRemoteApiCounter(); if (counter != null) { saveRequestedRemoteApiCount(counter); } } }
java
protected void handleRemoteApiCount(ActionRuntime runtime) { if (ThreadCacheContext.exists()) { final CalledRemoteApiCounter counter = ThreadCacheContext.findRemoteApiCounter(); if (counter != null) { saveRequestedRemoteApiCount(counter); } } }
[ "protected", "void", "handleRemoteApiCount", "(", "ActionRuntime", "runtime", ")", "{", "if", "(", "ThreadCacheContext", ".", "exists", "(", ")", ")", "{", "final", "CalledRemoteApiCounter", "counter", "=", "ThreadCacheContext", ".", "findRemoteApiCounter", "(", ")", ";", "if", "(", "counter", "!=", "null", ")", "{", "saveRequestedRemoteApiCount", "(", "counter", ")", ";", "}", "}", "}" ]
Handle count of remoteApi calling in the request. @param runtime The runtime meta of action execute. (NotNull)
[ "Handle", "count", "of", "remoteApi", "calling", "in", "the", "request", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/web/hook/GodHandEpilogue.java#L173-L180
138,723
jboss/jboss-jsf-api_spec
src/main/java/javax/faces/component/UIComponentBase.java
UIComponentBase.getFacet
public UIComponent getFacet(String name) { if (facets != null) { return (facets.get(name)); } else { return (null); } }
java
public UIComponent getFacet(String name) { if (facets != null) { return (facets.get(name)); } else { return (null); } }
[ "public", "UIComponent", "getFacet", "(", "String", "name", ")", "{", "if", "(", "facets", "!=", "null", ")", "{", "return", "(", "facets", ".", "get", "(", "name", ")", ")", ";", "}", "else", "{", "return", "(", "null", ")", ";", "}", "}" ]
Do not allocate the facets Map to answer this question
[ "Do", "not", "allocate", "the", "facets", "Map", "to", "answer", "this", "question" ]
cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3
https://github.com/jboss/jboss-jsf-api_spec/blob/cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3/src/main/java/javax/faces/component/UIComponentBase.java#L749-L757
138,724
jboss/jboss-jsf-api_spec
src/main/java/javax/faces/component/UIComponentBase.java
UIComponentBase.saveBehaviorsState
private Object saveBehaviorsState(FacesContext context){ Object state = null; if (null != behaviors && behaviors.size() >0){ boolean stateWritten = false; Object[] attachedBehaviors = new Object[behaviors.size()]; int i = 0; for (List<ClientBehavior> eventBehaviors : behaviors.values()) { // we need to take different action depending on whether // or not markInitialState() was called. If it's not called, // assume JSF 1.2 style state saving and call through to // saveAttachedState(), otherwise, call saveState() on the // behaviors directly. Object[] attachedEventBehaviors = new Object[eventBehaviors.size()]; for (int j = 0; j < attachedEventBehaviors.length; j++) { attachedEventBehaviors[j] = ((initialStateMarked()) ? saveBehavior(context, eventBehaviors.get(j)) : saveAttachedState(context, eventBehaviors.get(j))); if (!stateWritten) { stateWritten = (attachedEventBehaviors[j] != null); } } attachedBehaviors[i++] = attachedEventBehaviors; } if (stateWritten) { state = new Object[]{behaviors.keySet().toArray(new String[behaviors.size()]),attachedBehaviors}; } } return state; }
java
private Object saveBehaviorsState(FacesContext context){ Object state = null; if (null != behaviors && behaviors.size() >0){ boolean stateWritten = false; Object[] attachedBehaviors = new Object[behaviors.size()]; int i = 0; for (List<ClientBehavior> eventBehaviors : behaviors.values()) { // we need to take different action depending on whether // or not markInitialState() was called. If it's not called, // assume JSF 1.2 style state saving and call through to // saveAttachedState(), otherwise, call saveState() on the // behaviors directly. Object[] attachedEventBehaviors = new Object[eventBehaviors.size()]; for (int j = 0; j < attachedEventBehaviors.length; j++) { attachedEventBehaviors[j] = ((initialStateMarked()) ? saveBehavior(context, eventBehaviors.get(j)) : saveAttachedState(context, eventBehaviors.get(j))); if (!stateWritten) { stateWritten = (attachedEventBehaviors[j] != null); } } attachedBehaviors[i++] = attachedEventBehaviors; } if (stateWritten) { state = new Object[]{behaviors.keySet().toArray(new String[behaviors.size()]),attachedBehaviors}; } } return state; }
[ "private", "Object", "saveBehaviorsState", "(", "FacesContext", "context", ")", "{", "Object", "state", "=", "null", ";", "if", "(", "null", "!=", "behaviors", "&&", "behaviors", ".", "size", "(", ")", ">", "0", ")", "{", "boolean", "stateWritten", "=", "false", ";", "Object", "[", "]", "attachedBehaviors", "=", "new", "Object", "[", "behaviors", ".", "size", "(", ")", "]", ";", "int", "i", "=", "0", ";", "for", "(", "List", "<", "ClientBehavior", ">", "eventBehaviors", ":", "behaviors", ".", "values", "(", ")", ")", "{", "// we need to take different action depending on whether", "// or not markInitialState() was called. If it's not called,", "// assume JSF 1.2 style state saving and call through to", "// saveAttachedState(), otherwise, call saveState() on the", "// behaviors directly.", "Object", "[", "]", "attachedEventBehaviors", "=", "new", "Object", "[", "eventBehaviors", ".", "size", "(", ")", "]", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "attachedEventBehaviors", ".", "length", ";", "j", "++", ")", "{", "attachedEventBehaviors", "[", "j", "]", "=", "(", "(", "initialStateMarked", "(", ")", ")", "?", "saveBehavior", "(", "context", ",", "eventBehaviors", ".", "get", "(", "j", ")", ")", ":", "saveAttachedState", "(", "context", ",", "eventBehaviors", ".", "get", "(", "j", ")", ")", ")", ";", "if", "(", "!", "stateWritten", ")", "{", "stateWritten", "=", "(", "attachedEventBehaviors", "[", "j", "]", "!=", "null", ")", ";", "}", "}", "attachedBehaviors", "[", "i", "++", "]", "=", "attachedEventBehaviors", ";", "}", "if", "(", "stateWritten", ")", "{", "state", "=", "new", "Object", "[", "]", "{", "behaviors", ".", "keySet", "(", ")", ".", "toArray", "(", "new", "String", "[", "behaviors", ".", "size", "(", ")", "]", ")", ",", "attachedBehaviors", "}", ";", "}", "}", "return", "state", ";", "}" ]
Save state of the behaviors map. @param context the {@link FacesContext} for this request. @return map converted to the array of <code>Object</code> or null if no behaviors have been set.
[ "Save", "state", "of", "the", "behaviors", "map", "." ]
cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3
https://github.com/jboss/jboss-jsf-api_spec/blob/cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3/src/main/java/javax/faces/component/UIComponentBase.java#L2133-L2161
138,725
lastaflute/lastaflute
src/main/java/org/lastaflute/core/magic/ThreadCacheContext.java
ThreadCacheContext.getObject
@SuppressWarnings("unchecked") public static <OBJ> OBJ getObject(String key) { if (!exists()) { throwThreadCacheNotInitializedException(key); } return (OBJ) threadLocal.get().get(key); }
java
@SuppressWarnings("unchecked") public static <OBJ> OBJ getObject(String key) { if (!exists()) { throwThreadCacheNotInitializedException(key); } return (OBJ) threadLocal.get().get(key); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "OBJ", ">", "OBJ", "getObject", "(", "String", "key", ")", "{", "if", "(", "!", "exists", "(", ")", ")", "{", "throwThreadCacheNotInitializedException", "(", "key", ")", ";", "}", "return", "(", "OBJ", ")", "threadLocal", ".", "get", "(", ")", ".", "get", "(", "key", ")", ";", "}" ]
Get the value of the object by the key. @param <OBJ> The type of cached object. @param key The key of the object. (NotNull) @return The value of the object. (NullAllowed)
[ "Get", "the", "value", "of", "the", "object", "by", "the", "key", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/core/magic/ThreadCacheContext.java#L133-L139
138,726
lastaflute/lastaflute
src/main/java/org/lastaflute/core/magic/ThreadCacheContext.java
ThreadCacheContext.setObject
public static void setObject(String key, Object value) { if (!exists()) { throwThreadCacheNotInitializedException(key); } threadLocal.get().put(key, value); }
java
public static void setObject(String key, Object value) { if (!exists()) { throwThreadCacheNotInitializedException(key); } threadLocal.get().put(key, value); }
[ "public", "static", "void", "setObject", "(", "String", "key", ",", "Object", "value", ")", "{", "if", "(", "!", "exists", "(", ")", ")", "{", "throwThreadCacheNotInitializedException", "(", "key", ")", ";", "}", "threadLocal", ".", "get", "(", ")", ".", "put", "(", "key", ",", "value", ")", ";", "}" ]
Set the value of the object. @param key The key of the object. (NotNull) @param value The value of the object. (NullAllowed)
[ "Set", "the", "value", "of", "the", "object", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/core/magic/ThreadCacheContext.java#L146-L151
138,727
lastaflute/lastaflute
src/main/java/org/lastaflute/core/magic/ThreadCacheContext.java
ThreadCacheContext.removeObject
@SuppressWarnings("unchecked") public static <OBJ> OBJ removeObject(String key) { if (!exists()) { throwThreadCacheNotInitializedException(key); } return (OBJ) threadLocal.get().remove(key); }
java
@SuppressWarnings("unchecked") public static <OBJ> OBJ removeObject(String key) { if (!exists()) { throwThreadCacheNotInitializedException(key); } return (OBJ) threadLocal.get().remove(key); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "OBJ", ">", "OBJ", "removeObject", "(", "String", "key", ")", "{", "if", "(", "!", "exists", "(", ")", ")", "{", "throwThreadCacheNotInitializedException", "(", "key", ")", ";", "}", "return", "(", "OBJ", ")", "threadLocal", ".", "get", "(", ")", ".", "remove", "(", "key", ")", ";", "}" ]
Remove the value of the object from the cache. @param <OBJ> The type of cached object. @param key The key of the object. (NotNull) @return The removed value. (NullAllowed)
[ "Remove", "the", "value", "of", "the", "object", "from", "the", "cache", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/core/magic/ThreadCacheContext.java#L159-L165
138,728
lastaflute/lastaflute
src/main/java/org/lastaflute/core/magic/ThreadCacheContext.java
ThreadCacheContext.determineObject
public static boolean determineObject(String key) { if (!exists()) { throwThreadCacheNotInitializedException(key); } final Object obj = threadLocal.get().get(key); return obj != null && (boolean) obj; }
java
public static boolean determineObject(String key) { if (!exists()) { throwThreadCacheNotInitializedException(key); } final Object obj = threadLocal.get().get(key); return obj != null && (boolean) obj; }
[ "public", "static", "boolean", "determineObject", "(", "String", "key", ")", "{", "if", "(", "!", "exists", "(", ")", ")", "{", "throwThreadCacheNotInitializedException", "(", "key", ")", ";", "}", "final", "Object", "obj", "=", "threadLocal", ".", "get", "(", ")", ".", "get", "(", "key", ")", ";", "return", "obj", "!=", "null", "&&", "(", "boolean", ")", "obj", ";", "}" ]
Determine the object as boolean. @param key The key of the object. (NotNull) @return The determination, true or false. (true if the object exists and true)
[ "Determine", "the", "object", "as", "boolean", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/core/magic/ThreadCacheContext.java#L172-L178
138,729
lastaflute/lastaflute
src/main/java/org/lastaflute/db/dbflute/accesscontext/PreparedAccessContext.java
PreparedAccessContext.clearAccessContextOnThread
public static void clearAccessContextOnThread() { final Stack<AccessContext> stack = threadLocal.get(); if (stack != null) { stack.pop(); // remove latest if (stack.isEmpty()) { perfectlyClear(); } } }
java
public static void clearAccessContextOnThread() { final Stack<AccessContext> stack = threadLocal.get(); if (stack != null) { stack.pop(); // remove latest if (stack.isEmpty()) { perfectlyClear(); } } }
[ "public", "static", "void", "clearAccessContextOnThread", "(", ")", "{", "final", "Stack", "<", "AccessContext", ">", "stack", "=", "threadLocal", ".", "get", "(", ")", ";", "if", "(", "stack", "!=", "null", ")", "{", "stack", ".", "pop", "(", ")", ";", "// remove latest", "if", "(", "stack", ".", "isEmpty", "(", ")", ")", "{", "perfectlyClear", "(", ")", ";", "}", "}", "}" ]
Clear prepared access-context on thread.
[ "Clear", "prepared", "access", "-", "context", "on", "thread", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/db/dbflute/accesscontext/PreparedAccessContext.java#L77-L85
138,730
lastaflute/lastaflute
src/main/java/org/lastaflute/db/dbflute/accesscontext/PreparedAccessContext.java
PreparedAccessContext.endAccessContext
public static void endAccessContext() { AccessContext.clearAccessContextOnThread(); final AccessContext accessContext = SuspendedAccessContext.getAccessContextOnThread(); if (accessContext != null) { // resume AccessContext.setAccessContextOnThread(accessContext); SuspendedAccessContext.clearAccessContextOnThread(); } }
java
public static void endAccessContext() { AccessContext.clearAccessContextOnThread(); final AccessContext accessContext = SuspendedAccessContext.getAccessContextOnThread(); if (accessContext != null) { // resume AccessContext.setAccessContextOnThread(accessContext); SuspendedAccessContext.clearAccessContextOnThread(); } }
[ "public", "static", "void", "endAccessContext", "(", ")", "{", "AccessContext", ".", "clearAccessContextOnThread", "(", ")", ";", "final", "AccessContext", "accessContext", "=", "SuspendedAccessContext", ".", "getAccessContextOnThread", "(", ")", ";", "if", "(", "accessContext", "!=", "null", ")", "{", "// resume", "AccessContext", ".", "setAccessContextOnThread", "(", "accessContext", ")", ";", "SuspendedAccessContext", ".", "clearAccessContextOnThread", "(", ")", ";", "}", "}" ]
End access-context use for DBFlute.
[ "End", "access", "-", "context", "use", "for", "DBFlute", "." ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/db/dbflute/accesscontext/PreparedAccessContext.java#L105-L112
138,731
lastaflute/lastaflute
src/main/java/org/lastaflute/web/validation/ActionValidator.java
ActionValidator.prepareOrderedMap
protected TreeMap<String, Object> prepareOrderedMap(Object form, Set<ConstraintViolation<Object>> vioSet) { final Map<String, Object> vioPropMap = new HashMap<>(vioSet.size()); for (ConstraintViolation<Object> vio : vioSet) { final String propertyPath = extractPropertyPath(vio); final boolean nested = propertyPath.contains("."); final String propertyName = nested ? Srl.substringFirstFront(propertyPath, ".") : propertyPath; Object holder = vioPropMap.get(propertyName); if (holder == null) { holder = nested ? new ArrayList<>(4) : vio; // direct holder for performance vioPropMap.put(propertyName, holder); } else if (holder instanceof ConstraintViolation<?>) { @SuppressWarnings("unchecked") final ConstraintViolation<Object> existing = ((ConstraintViolation<Object>) holder); final List<Object> listHolder = new ArrayList<>(4); listHolder.add(existing); listHolder.add(vio); vioPropMap.put(propertyName, listHolder); // override } if (holder instanceof List<?>) { @SuppressWarnings("unchecked") final List<Object> listHolder = (List<Object>) holder; listHolder.add(vio); } } final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(form.getClass()); final int pdSize = beanDesc.getPropertyDescSize(); final Map<String, Integer> priorityMap = new HashMap<>(vioPropMap.size()); for (int i = 0; i < pdSize; i++) { final PropertyDesc pd = beanDesc.getPropertyDesc(i); final String propertyName = pd.getPropertyName(); if (vioPropMap.containsKey(propertyName)) { priorityMap.put(propertyName, i); } } final TreeMap<String, Object> orderedMap = new TreeMap<String, Object>((key1, key2) -> { final String rootProperty1 = Srl.substringFirstFront(key1, "[", "."); final String rootProperty2 = Srl.substringFirstFront(key2, "[", "."); final Integer priority1 = priorityMap.getOrDefault(rootProperty1, Integer.MAX_VALUE); final Integer priority2 = priorityMap.getOrDefault(rootProperty2, Integer.MAX_VALUE); if (priority1 > priority2) { return 1; } else if (priority2 > priority1) { return -1; } else { /* same group */ return key1.compareTo(key2); } }); orderedMap.putAll(vioPropMap); return orderedMap; }
java
protected TreeMap<String, Object> prepareOrderedMap(Object form, Set<ConstraintViolation<Object>> vioSet) { final Map<String, Object> vioPropMap = new HashMap<>(vioSet.size()); for (ConstraintViolation<Object> vio : vioSet) { final String propertyPath = extractPropertyPath(vio); final boolean nested = propertyPath.contains("."); final String propertyName = nested ? Srl.substringFirstFront(propertyPath, ".") : propertyPath; Object holder = vioPropMap.get(propertyName); if (holder == null) { holder = nested ? new ArrayList<>(4) : vio; // direct holder for performance vioPropMap.put(propertyName, holder); } else if (holder instanceof ConstraintViolation<?>) { @SuppressWarnings("unchecked") final ConstraintViolation<Object> existing = ((ConstraintViolation<Object>) holder); final List<Object> listHolder = new ArrayList<>(4); listHolder.add(existing); listHolder.add(vio); vioPropMap.put(propertyName, listHolder); // override } if (holder instanceof List<?>) { @SuppressWarnings("unchecked") final List<Object> listHolder = (List<Object>) holder; listHolder.add(vio); } } final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(form.getClass()); final int pdSize = beanDesc.getPropertyDescSize(); final Map<String, Integer> priorityMap = new HashMap<>(vioPropMap.size()); for (int i = 0; i < pdSize; i++) { final PropertyDesc pd = beanDesc.getPropertyDesc(i); final String propertyName = pd.getPropertyName(); if (vioPropMap.containsKey(propertyName)) { priorityMap.put(propertyName, i); } } final TreeMap<String, Object> orderedMap = new TreeMap<String, Object>((key1, key2) -> { final String rootProperty1 = Srl.substringFirstFront(key1, "[", "."); final String rootProperty2 = Srl.substringFirstFront(key2, "[", "."); final Integer priority1 = priorityMap.getOrDefault(rootProperty1, Integer.MAX_VALUE); final Integer priority2 = priorityMap.getOrDefault(rootProperty2, Integer.MAX_VALUE); if (priority1 > priority2) { return 1; } else if (priority2 > priority1) { return -1; } else { /* same group */ return key1.compareTo(key2); } }); orderedMap.putAll(vioPropMap); return orderedMap; }
[ "protected", "TreeMap", "<", "String", ",", "Object", ">", "prepareOrderedMap", "(", "Object", "form", ",", "Set", "<", "ConstraintViolation", "<", "Object", ">", ">", "vioSet", ")", "{", "final", "Map", "<", "String", ",", "Object", ">", "vioPropMap", "=", "new", "HashMap", "<>", "(", "vioSet", ".", "size", "(", ")", ")", ";", "for", "(", "ConstraintViolation", "<", "Object", ">", "vio", ":", "vioSet", ")", "{", "final", "String", "propertyPath", "=", "extractPropertyPath", "(", "vio", ")", ";", "final", "boolean", "nested", "=", "propertyPath", ".", "contains", "(", "\".\"", ")", ";", "final", "String", "propertyName", "=", "nested", "?", "Srl", ".", "substringFirstFront", "(", "propertyPath", ",", "\".\"", ")", ":", "propertyPath", ";", "Object", "holder", "=", "vioPropMap", ".", "get", "(", "propertyName", ")", ";", "if", "(", "holder", "==", "null", ")", "{", "holder", "=", "nested", "?", "new", "ArrayList", "<>", "(", "4", ")", ":", "vio", ";", "// direct holder for performance", "vioPropMap", ".", "put", "(", "propertyName", ",", "holder", ")", ";", "}", "else", "if", "(", "holder", "instanceof", "ConstraintViolation", "<", "?", ">", ")", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "final", "ConstraintViolation", "<", "Object", ">", "existing", "=", "(", "(", "ConstraintViolation", "<", "Object", ">", ")", "holder", ")", ";", "final", "List", "<", "Object", ">", "listHolder", "=", "new", "ArrayList", "<>", "(", "4", ")", ";", "listHolder", ".", "add", "(", "existing", ")", ";", "listHolder", ".", "add", "(", "vio", ")", ";", "vioPropMap", ".", "put", "(", "propertyName", ",", "listHolder", ")", ";", "// override", "}", "if", "(", "holder", "instanceof", "List", "<", "?", ">", ")", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "final", "List", "<", "Object", ">", "listHolder", "=", "(", "List", "<", "Object", ">", ")", "holder", ";", "listHolder", ".", "add", "(", "vio", ")", ";", "}", "}", "final", "BeanDesc", "beanDesc", "=", "BeanDescFactory", ".", "getBeanDesc", "(", "form", ".", "getClass", "(", ")", ")", ";", "final", "int", "pdSize", "=", "beanDesc", ".", "getPropertyDescSize", "(", ")", ";", "final", "Map", "<", "String", ",", "Integer", ">", "priorityMap", "=", "new", "HashMap", "<>", "(", "vioPropMap", ".", "size", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "pdSize", ";", "i", "++", ")", "{", "final", "PropertyDesc", "pd", "=", "beanDesc", ".", "getPropertyDesc", "(", "i", ")", ";", "final", "String", "propertyName", "=", "pd", ".", "getPropertyName", "(", ")", ";", "if", "(", "vioPropMap", ".", "containsKey", "(", "propertyName", ")", ")", "{", "priorityMap", ".", "put", "(", "propertyName", ",", "i", ")", ";", "}", "}", "final", "TreeMap", "<", "String", ",", "Object", ">", "orderedMap", "=", "new", "TreeMap", "<", "String", ",", "Object", ">", "(", "(", "key1", ",", "key2", ")", "->", "{", "final", "String", "rootProperty1", "=", "Srl", ".", "substringFirstFront", "(", "key1", ",", "\"[\"", ",", "\".\"", ")", ";", "final", "String", "rootProperty2", "=", "Srl", ".", "substringFirstFront", "(", "key2", ",", "\"[\"", ",", "\".\"", ")", ";", "final", "Integer", "priority1", "=", "priorityMap", ".", "getOrDefault", "(", "rootProperty1", ",", "Integer", ".", "MAX_VALUE", ")", ";", "final", "Integer", "priority2", "=", "priorityMap", ".", "getOrDefault", "(", "rootProperty2", ",", "Integer", ".", "MAX_VALUE", ")", ";", "if", "(", "priority1", ">", "priority2", ")", "{", "return", "1", ";", "}", "else", "if", "(", "priority2", ">", "priority1", ")", "{", "return", "-", "1", ";", "}", "else", "{", "/* same group */", "return", "key1", ".", "compareTo", "(", "key2", ")", ";", "}", "}", ")", ";", "orderedMap", ".", "putAll", "(", "vioPropMap", ")", ";", "return", "orderedMap", ";", "}" ]
basically for batch display
[ "basically", "for", "batch", "display" ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/web/validation/ActionValidator.java#L503-L552
138,732
lastaflute/lastaflute
src/main/java/org/lastaflute/web/validation/ActionValidator.java
ActionValidator.cannotBeValidatable
public static boolean cannotBeValidatable(Object value) { // called by e.g. ResponseBeanValidator return value instanceof String // yes-yes-yes || value instanceof Number // e.g. Integer || DfTypeUtil.isAnyLocalDate(value) // e.g. LocalDate || value instanceof Boolean // of course || value instanceof Classification // e.g. CDef || value.getClass().isPrimitive() // probably no way, just in case ; }
java
public static boolean cannotBeValidatable(Object value) { // called by e.g. ResponseBeanValidator return value instanceof String // yes-yes-yes || value instanceof Number // e.g. Integer || DfTypeUtil.isAnyLocalDate(value) // e.g. LocalDate || value instanceof Boolean // of course || value instanceof Classification // e.g. CDef || value.getClass().isPrimitive() // probably no way, just in case ; }
[ "public", "static", "boolean", "cannotBeValidatable", "(", "Object", "value", ")", "{", "// called by e.g. ResponseBeanValidator", "return", "value", "instanceof", "String", "// yes-yes-yes ", "||", "value", "instanceof", "Number", "// e.g. Integer", "||", "DfTypeUtil", ".", "isAnyLocalDate", "(", "value", ")", "// e.g. LocalDate", "||", "value", "instanceof", "Boolean", "// of course", "||", "value", "instanceof", "Classification", "// e.g. CDef", "||", "value", ".", "getClass", "(", ")", ".", "isPrimitive", "(", ")", "// probably no way, just in case", ";", "}" ]
similar logic is on action response reflector
[ "similar", "logic", "is", "on", "action", "response", "reflector" ]
17b56dda8322e4c6d79043532c1dda917d6b60a8
https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/web/validation/ActionValidator.java#L904-L912
138,733
shevek/jcpp
src/main/java/org/anarres/cpp/Source.java
Source.getPath
@CheckForNull public String getPath() { Source parent = getParent(); if (parent != null) return parent.getPath(); return null; }
java
@CheckForNull public String getPath() { Source parent = getParent(); if (parent != null) return parent.getPath(); return null; }
[ "@", "CheckForNull", "public", "String", "getPath", "(", ")", "{", "Source", "parent", "=", "getParent", "(", ")", ";", "if", "(", "parent", "!=", "null", ")", "return", "parent", ".", "getPath", "(", ")", ";", "return", "null", ";", "}" ]
Returns the File currently being lexed. If this Source is not a {@link FileLexerSource}, then it will ask the parent Source, and so forth recursively. If no Source on the stack is a FileLexerSource, returns null.
[ "Returns", "the", "File", "currently", "being", "lexed", "." ]
71462c702097cabf8304202c740f780285fc35a8
https://github.com/shevek/jcpp/blob/71462c702097cabf8304202c740f780285fc35a8/src/main/java/org/anarres/cpp/Source.java#L136-L142
138,734
shevek/jcpp
src/main/java/org/anarres/cpp/Source.java
Source.getName
@CheckForNull public String getName() { Source parent = getParent(); if (parent != null) return parent.getName(); return null; }
java
@CheckForNull public String getName() { Source parent = getParent(); if (parent != null) return parent.getName(); return null; }
[ "@", "CheckForNull", "public", "String", "getName", "(", ")", "{", "Source", "parent", "=", "getParent", "(", ")", ";", "if", "(", "parent", "!=", "null", ")", "return", "parent", ".", "getName", "(", ")", ";", "return", "null", ";", "}" ]
Returns the human-readable name of the current Source.
[ "Returns", "the", "human", "-", "readable", "name", "of", "the", "current", "Source", "." ]
71462c702097cabf8304202c740f780285fc35a8
https://github.com/shevek/jcpp/blob/71462c702097cabf8304202c740f780285fc35a8/src/main/java/org/anarres/cpp/Source.java#L147-L153
138,735
shevek/jcpp
src/main/java/org/anarres/cpp/Source.java
Source.skipline
@Nonnull public Token skipline(boolean white) throws IOException, LexerException { for (;;) { Token tok = token(); switch (tok.getType()) { case EOF: /* There ought to be a newline before EOF. * At least, in any skipline context. */ /* XXX Are we sure about this? */ warning(tok.getLine(), tok.getColumn(), "No newline before end of file"); return new Token(NL, tok.getLine(), tok.getColumn(), "\n"); // return tok; case NL: /* This may contain one or more newlines. */ return tok; case CCOMMENT: case CPPCOMMENT: case WHITESPACE: break; default: /* XXX Check white, if required. */ if (white) warning(tok.getLine(), tok.getColumn(), "Unexpected nonwhite token"); break; } } }
java
@Nonnull public Token skipline(boolean white) throws IOException, LexerException { for (;;) { Token tok = token(); switch (tok.getType()) { case EOF: /* There ought to be a newline before EOF. * At least, in any skipline context. */ /* XXX Are we sure about this? */ warning(tok.getLine(), tok.getColumn(), "No newline before end of file"); return new Token(NL, tok.getLine(), tok.getColumn(), "\n"); // return tok; case NL: /* This may contain one or more newlines. */ return tok; case CCOMMENT: case CPPCOMMENT: case WHITESPACE: break; default: /* XXX Check white, if required. */ if (white) warning(tok.getLine(), tok.getColumn(), "Unexpected nonwhite token"); break; } } }
[ "@", "Nonnull", "public", "Token", "skipline", "(", "boolean", "white", ")", "throws", "IOException", ",", "LexerException", "{", "for", "(", ";", ";", ")", "{", "Token", "tok", "=", "token", "(", ")", ";", "switch", "(", "tok", ".", "getType", "(", ")", ")", "{", "case", "EOF", ":", "/* There ought to be a newline before EOF.\n * At least, in any skipline context. */", "/* XXX Are we sure about this? */", "warning", "(", "tok", ".", "getLine", "(", ")", ",", "tok", ".", "getColumn", "(", ")", ",", "\"No newline before end of file\"", ")", ";", "return", "new", "Token", "(", "NL", ",", "tok", ".", "getLine", "(", ")", ",", "tok", ".", "getColumn", "(", ")", ",", "\"\\n\"", ")", ";", "// return tok;", "case", "NL", ":", "/* This may contain one or more newlines. */", "return", "tok", ";", "case", "CCOMMENT", ":", "case", "CPPCOMMENT", ":", "case", "WHITESPACE", ":", "break", ";", "default", ":", "/* XXX Check white, if required. */", "if", "(", "white", ")", "warning", "(", "tok", ".", "getLine", "(", ")", ",", "tok", ".", "getColumn", "(", ")", ",", "\"Unexpected nonwhite token\"", ")", ";", "break", ";", "}", "}", "}" ]
Skips tokens until the end of line. @param white true if only whitespace is permitted on the remainder of the line. @return the NL token.
[ "Skips", "tokens", "until", "the", "end", "of", "line", "." ]
71462c702097cabf8304202c740f780285fc35a8
https://github.com/shevek/jcpp/blob/71462c702097cabf8304202c740f780285fc35a8/src/main/java/org/anarres/cpp/Source.java#L240-L272
138,736
awin/rabbiteasy
rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/SingleConnectionFactory.java
SingleConnectionFactory.notifyListenersOnStateChange
void notifyListenersOnStateChange() { LOGGER.debug("Notifying connection listeners about state change to {}", state); for (ConnectionListener listener : connectionListeners) { switch (state) { case CONNECTED: listener.onConnectionEstablished(connection); break; case CONNECTING: listener.onConnectionLost(connection); break; case CLOSED: listener.onConnectionClosed(connection); break; default: break; } } }
java
void notifyListenersOnStateChange() { LOGGER.debug("Notifying connection listeners about state change to {}", state); for (ConnectionListener listener : connectionListeners) { switch (state) { case CONNECTED: listener.onConnectionEstablished(connection); break; case CONNECTING: listener.onConnectionLost(connection); break; case CLOSED: listener.onConnectionClosed(connection); break; default: break; } } }
[ "void", "notifyListenersOnStateChange", "(", ")", "{", "LOGGER", ".", "debug", "(", "\"Notifying connection listeners about state change to {}\"", ",", "state", ")", ";", "for", "(", "ConnectionListener", "listener", ":", "connectionListeners", ")", "{", "switch", "(", "state", ")", "{", "case", "CONNECTED", ":", "listener", ".", "onConnectionEstablished", "(", "connection", ")", ";", "break", ";", "case", "CONNECTING", ":", "listener", ".", "onConnectionLost", "(", "connection", ")", ";", "break", ";", "case", "CLOSED", ":", "listener", ".", "onConnectionClosed", "(", "connection", ")", ";", "break", ";", "default", ":", "break", ";", "}", "}", "}" ]
Notifies all connection listener about a state change.
[ "Notifies", "all", "connection", "listener", "about", "a", "state", "change", "." ]
c161efda6c0f7ef319aedf09dfe40a4a90165510
https://github.com/awin/rabbiteasy/blob/c161efda6c0f7ef319aedf09dfe40a4a90165510/rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/SingleConnectionFactory.java#L196-L214
138,737
awin/rabbiteasy
rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/SingleConnectionFactory.java
SingleConnectionFactory.establishConnection
void establishConnection () throws IOException { synchronized (operationOnConnectionMonitor) { if (state == State.CLOSED) { throw new IOException("Attempt to establish a connection with a closed connection factory"); } else if (state == State.CONNECTED) { LOGGER.warn("Establishing new connection although a connection is already established"); } try { LOGGER.info("Trying to establish connection to {}:{}", getHost(), getPort()); connection = super.newConnection(executorService); connection.addShutdownListener(connectionShutdownListener); LOGGER.info("Established connection to {}:{}", getHost(), getPort()); changeState(State.CONNECTED); } catch (IOException e) { LOGGER.error("Failed to establish connection to {}:{}", getHost(), getPort()); throw e; } } }
java
void establishConnection () throws IOException { synchronized (operationOnConnectionMonitor) { if (state == State.CLOSED) { throw new IOException("Attempt to establish a connection with a closed connection factory"); } else if (state == State.CONNECTED) { LOGGER.warn("Establishing new connection although a connection is already established"); } try { LOGGER.info("Trying to establish connection to {}:{}", getHost(), getPort()); connection = super.newConnection(executorService); connection.addShutdownListener(connectionShutdownListener); LOGGER.info("Established connection to {}:{}", getHost(), getPort()); changeState(State.CONNECTED); } catch (IOException e) { LOGGER.error("Failed to establish connection to {}:{}", getHost(), getPort()); throw e; } } }
[ "void", "establishConnection", "(", ")", "throws", "IOException", "{", "synchronized", "(", "operationOnConnectionMonitor", ")", "{", "if", "(", "state", "==", "State", ".", "CLOSED", ")", "{", "throw", "new", "IOException", "(", "\"Attempt to establish a connection with a closed connection factory\"", ")", ";", "}", "else", "if", "(", "state", "==", "State", ".", "CONNECTED", ")", "{", "LOGGER", ".", "warn", "(", "\"Establishing new connection although a connection is already established\"", ")", ";", "}", "try", "{", "LOGGER", ".", "info", "(", "\"Trying to establish connection to {}:{}\"", ",", "getHost", "(", ")", ",", "getPort", "(", ")", ")", ";", "connection", "=", "super", ".", "newConnection", "(", "executorService", ")", ";", "connection", ".", "addShutdownListener", "(", "connectionShutdownListener", ")", ";", "LOGGER", ".", "info", "(", "\"Established connection to {}:{}\"", ",", "getHost", "(", ")", ",", "getPort", "(", ")", ")", ";", "changeState", "(", "State", ".", "CONNECTED", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "LOGGER", ".", "error", "(", "\"Failed to establish connection to {}:{}\"", ",", "getHost", "(", ")", ",", "getPort", "(", ")", ")", ";", "throw", "e", ";", "}", "}", "}" ]
Establishes a new connection. @throws IOException if establishing a new connection fails
[ "Establishes", "a", "new", "connection", "." ]
c161efda6c0f7ef319aedf09dfe40a4a90165510
https://github.com/awin/rabbiteasy/blob/c161efda6c0f7ef319aedf09dfe40a4a90165510/rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/SingleConnectionFactory.java#L221-L239
138,738
advantageous/boon
reflekt/src/main/java/io/advantageous/boon/core/Str.java
Str.sliceOf
public static String sliceOf( String str, int start, int end ) { return slc(str, start, end); }
java
public static String sliceOf( String str, int start, int end ) { return slc(str, start, end); }
[ "public", "static", "String", "sliceOf", "(", "String", "str", ",", "int", "start", ",", "int", "end", ")", "{", "return", "slc", "(", "str", ",", "start", ",", "end", ")", ";", "}" ]
Get slice of string @param str string @param start start index @param end end index @return new string
[ "Get", "slice", "of", "string" ]
12712d376761aa3b33223a9f1716720ddb67cb5e
https://github.com/advantageous/boon/blob/12712d376761aa3b33223a9f1716720ddb67cb5e/reflekt/src/main/java/io/advantageous/boon/core/Str.java#L85-L87
138,739
advantageous/boon
reflekt/src/main/java/io/advantageous/boon/core/Str.java
Str.slcEnd
public static String slcEnd( String str, int end ) { return FastStringUtils.noCopyStringFromChars( Chr.slcEnd( FastStringUtils.toCharArray(str), end ) ); }
java
public static String slcEnd( String str, int end ) { return FastStringUtils.noCopyStringFromChars( Chr.slcEnd( FastStringUtils.toCharArray(str), end ) ); }
[ "public", "static", "String", "slcEnd", "(", "String", "str", ",", "int", "end", ")", "{", "return", "FastStringUtils", ".", "noCopyStringFromChars", "(", "Chr", ".", "slcEnd", "(", "FastStringUtils", ".", "toCharArray", "(", "str", ")", ",", "end", ")", ")", ";", "}" ]
Gets end slice of a string. @param str string @param end end index of slice @return new string
[ "Gets", "end", "slice", "of", "a", "string", "." ]
12712d376761aa3b33223a9f1716720ddb67cb5e
https://github.com/advantageous/boon/blob/12712d376761aa3b33223a9f1716720ddb67cb5e/reflekt/src/main/java/io/advantageous/boon/core/Str.java#L172-L174
138,740
advantageous/boon
reflekt/src/main/java/io/advantageous/boon/core/Str.java
Str.idx
public static char idx( String str, int index ) { int i = calculateIndex( str.length(), index ); char c = str.charAt( i ); return c; }
java
public static char idx( String str, int index ) { int i = calculateIndex( str.length(), index ); char c = str.charAt( i ); return c; }
[ "public", "static", "char", "idx", "(", "String", "str", ",", "int", "index", ")", "{", "int", "i", "=", "calculateIndex", "(", "str", ".", "length", "(", ")", ",", "index", ")", ";", "char", "c", "=", "str", ".", "charAt", "(", "i", ")", ";", "return", "c", ";", "}" ]
Gets character at index @param str string @param index index @return char at
[ "Gets", "character", "at", "index" ]
12712d376761aa3b33223a9f1716720ddb67cb5e
https://github.com/advantageous/boon/blob/12712d376761aa3b33223a9f1716720ddb67cb5e/reflekt/src/main/java/io/advantageous/boon/core/Str.java#L185-L190
138,741
advantageous/boon
reflekt/src/main/java/io/advantageous/boon/core/Str.java
Str.idx
public static String idx( String str, int index, char c ) { char[] chars = str.toCharArray(); Chr.idx( chars, index, c ); return new String( chars ); }
java
public static String idx( String str, int index, char c ) { char[] chars = str.toCharArray(); Chr.idx( chars, index, c ); return new String( chars ); }
[ "public", "static", "String", "idx", "(", "String", "str", ",", "int", "index", ",", "char", "c", ")", "{", "char", "[", "]", "chars", "=", "str", ".", "toCharArray", "(", ")", ";", "Chr", ".", "idx", "(", "chars", ",", "index", ",", "c", ")", ";", "return", "new", "String", "(", "chars", ")", ";", "}" ]
Puts character at index @param str string @param index index @param c char to put in @return new string
[ "Puts", "character", "at", "index" ]
12712d376761aa3b33223a9f1716720ddb67cb5e
https://github.com/advantageous/boon/blob/12712d376761aa3b33223a9f1716720ddb67cb5e/reflekt/src/main/java/io/advantageous/boon/core/Str.java#L201-L206
138,742
advantageous/boon
reflekt/src/main/java/io/advantageous/boon/core/Str.java
Str.in
public static boolean in( char c, String str ) { return Chr.in ( c, FastStringUtils.toCharArray(str) ); }
java
public static boolean in( char c, String str ) { return Chr.in ( c, FastStringUtils.toCharArray(str) ); }
[ "public", "static", "boolean", "in", "(", "char", "c", ",", "String", "str", ")", "{", "return", "Chr", ".", "in", "(", "c", ",", "FastStringUtils", ".", "toCharArray", "(", "str", ")", ")", ";", "}" ]
See if a char is in another string @param c char @param str string @return true or false
[ "See", "if", "a", "char", "is", "in", "another", "string" ]
12712d376761aa3b33223a9f1716720ddb67cb5e
https://github.com/advantageous/boon/blob/12712d376761aa3b33223a9f1716720ddb67cb5e/reflekt/src/main/java/io/advantageous/boon/core/Str.java#L227-L229
138,743
advantageous/boon
reflekt/src/main/java/io/advantageous/boon/core/Str.java
Str.add
public static String add( String str, String str2 ) { return FastStringUtils.noCopyStringFromChars( Chr.add( FastStringUtils.toCharArray(str), FastStringUtils.toCharArray(str2) ) ); }
java
public static String add( String str, String str2 ) { return FastStringUtils.noCopyStringFromChars( Chr.add( FastStringUtils.toCharArray(str), FastStringUtils.toCharArray(str2) ) ); }
[ "public", "static", "String", "add", "(", "String", "str", ",", "String", "str2", ")", "{", "return", "FastStringUtils", ".", "noCopyStringFromChars", "(", "Chr", ".", "add", "(", "FastStringUtils", ".", "toCharArray", "(", "str", ")", ",", "FastStringUtils", ".", "toCharArray", "(", "str2", ")", ")", ")", ";", "}" ]
Add one string to another @param str string 1 @param str2 string 2 @return new string
[ "Add", "one", "string", "to", "another" ]
12712d376761aa3b33223a9f1716720ddb67cb5e
https://github.com/advantageous/boon/blob/12712d376761aa3b33223a9f1716720ddb67cb5e/reflekt/src/main/java/io/advantageous/boon/core/Str.java#L278-L284
138,744
advantageous/boon
reflekt/src/main/java/io/advantageous/boon/core/Str.java
Str.add
public static String add( String... strings ) { int length = 0; for ( String str : strings ) { if ( str == null ) { continue; } length += str.length(); } CharBuf builder = CharBuf.createExact( length ); for ( String str : strings ) { if ( str == null ) { continue; } builder.add( str ); } return builder.toString(); }
java
public static String add( String... strings ) { int length = 0; for ( String str : strings ) { if ( str == null ) { continue; } length += str.length(); } CharBuf builder = CharBuf.createExact( length ); for ( String str : strings ) { if ( str == null ) { continue; } builder.add( str ); } return builder.toString(); }
[ "public", "static", "String", "add", "(", "String", "...", "strings", ")", "{", "int", "length", "=", "0", ";", "for", "(", "String", "str", ":", "strings", ")", "{", "if", "(", "str", "==", "null", ")", "{", "continue", ";", "}", "length", "+=", "str", ".", "length", "(", ")", ";", "}", "CharBuf", "builder", "=", "CharBuf", ".", "createExact", "(", "length", ")", ";", "for", "(", "String", "str", ":", "strings", ")", "{", "if", "(", "str", "==", "null", ")", "{", "continue", ";", "}", "builder", ".", "add", "(", "str", ")", ";", "}", "return", "builder", ".", "toString", "(", ")", ";", "}" ]
Add many strings together to another @param strings strings @return new string
[ "Add", "many", "strings", "together", "to", "another" ]
12712d376761aa3b33223a9f1716720ddb67cb5e
https://github.com/advantageous/boon/blob/12712d376761aa3b33223a9f1716720ddb67cb5e/reflekt/src/main/java/io/advantageous/boon/core/Str.java#L293-L309
138,745
advantageous/boon
reflekt/src/main/java/io/advantageous/boon/core/Str.java
Str.sputl
public static String sputl(Object... messages) { CharBuf buf = CharBuf.create(100); return sputl(buf, messages).toString(); }
java
public static String sputl(Object... messages) { CharBuf buf = CharBuf.create(100); return sputl(buf, messages).toString(); }
[ "public", "static", "String", "sputl", "(", "Object", "...", "messages", ")", "{", "CharBuf", "buf", "=", "CharBuf", ".", "create", "(", "100", ")", ";", "return", "sputl", "(", "buf", ",", "messages", ")", ".", "toString", "(", ")", ";", "}" ]
like putl but writes to a string. @param messages the stuff you want to print out. @return string
[ "like", "putl", "but", "writes", "to", "a", "string", "." ]
12712d376761aa3b33223a9f1716720ddb67cb5e
https://github.com/advantageous/boon/blob/12712d376761aa3b33223a9f1716720ddb67cb5e/reflekt/src/main/java/io/advantageous/boon/core/Str.java#L917-L920
138,746
advantageous/boon
reflekt/src/main/java/io/advantageous/boon/core/Str.java
Str.sputs
public static String sputs(Object... messages) { CharBuf buf = CharBuf.create(80); return sputs(buf, messages).toString(); }
java
public static String sputs(Object... messages) { CharBuf buf = CharBuf.create(80); return sputs(buf, messages).toString(); }
[ "public", "static", "String", "sputs", "(", "Object", "...", "messages", ")", "{", "CharBuf", "buf", "=", "CharBuf", ".", "create", "(", "80", ")", ";", "return", "sputs", "(", "buf", ",", "messages", ")", ".", "toString", "(", ")", ";", "}" ]
Like puts but writes to a String. @param messages the stuff you want to print out. @return string
[ "Like", "puts", "but", "writes", "to", "a", "String", "." ]
12712d376761aa3b33223a9f1716720ddb67cb5e
https://github.com/advantageous/boon/blob/12712d376761aa3b33223a9f1716720ddb67cb5e/reflekt/src/main/java/io/advantageous/boon/core/Str.java#L928-L931
138,747
advantageous/boon
reflekt/src/main/java/io/advantageous/boon/core/Str.java
Str.sputl
public static CharBuf sputl(CharBuf buf, Object... messages) { for (Object message : messages) { if (message == null) { buf.add("<NULL>"); } else if (message.getClass().isArray()) { buf.add(toListOrSingletonList(message).toString()); } else { buf.add(message.toString()); } buf.add('\n'); } buf.add('\n'); return buf; }
java
public static CharBuf sputl(CharBuf buf, Object... messages) { for (Object message : messages) { if (message == null) { buf.add("<NULL>"); } else if (message.getClass().isArray()) { buf.add(toListOrSingletonList(message).toString()); } else { buf.add(message.toString()); } buf.add('\n'); } buf.add('\n'); return buf; }
[ "public", "static", "CharBuf", "sputl", "(", "CharBuf", "buf", ",", "Object", "...", "messages", ")", "{", "for", "(", "Object", "message", ":", "messages", ")", "{", "if", "(", "message", "==", "null", ")", "{", "buf", ".", "add", "(", "\"<NULL>\"", ")", ";", "}", "else", "if", "(", "message", ".", "getClass", "(", ")", ".", "isArray", "(", ")", ")", "{", "buf", ".", "add", "(", "toListOrSingletonList", "(", "message", ")", ".", "toString", "(", ")", ")", ";", "}", "else", "{", "buf", ".", "add", "(", "message", ".", "toString", "(", ")", ")", ";", "}", "buf", ".", "add", "(", "'", "'", ")", ";", "}", "buf", ".", "add", "(", "'", "'", ")", ";", "return", "buf", ";", "}" ]
Writes to a char buf. A char buf is like a StringBuilder. @param buf char buf @param messages messages @return charbuf
[ "Writes", "to", "a", "char", "buf", ".", "A", "char", "buf", "is", "like", "a", "StringBuilder", "." ]
12712d376761aa3b33223a9f1716720ddb67cb5e
https://github.com/advantageous/boon/blob/12712d376761aa3b33223a9f1716720ddb67cb5e/reflekt/src/main/java/io/advantageous/boon/core/Str.java#L940-L957
138,748
advantageous/boon
util/src/main/java/io/advantageous/boon/json/JsonSlurper.java
JsonSlurper.parseFile
private Object parseFile(File file, String scharset) { Charset charset = scharset==null || scharset.length ()==0 ? StandardCharsets.UTF_8 : Charset.forName ( scharset ); if (file.length() > 2_000_000) { try (Reader reader = Files.newBufferedReader( Classpaths.path(file.toString()), charset )) { return parse(reader); } catch(IOException ioe) { throw new JsonException("Unable to process file: " + file.getPath(), ioe); } } else { try { return JsonFactory.create().fromJson ( Files.newBufferedReader( Classpaths.path(file.toString()), charset ) ); } catch ( IOException e ) { throw new JsonException("Unable to process file: " + file.getPath(), e); } } }
java
private Object parseFile(File file, String scharset) { Charset charset = scharset==null || scharset.length ()==0 ? StandardCharsets.UTF_8 : Charset.forName ( scharset ); if (file.length() > 2_000_000) { try (Reader reader = Files.newBufferedReader( Classpaths.path(file.toString()), charset )) { return parse(reader); } catch(IOException ioe) { throw new JsonException("Unable to process file: " + file.getPath(), ioe); } } else { try { return JsonFactory.create().fromJson ( Files.newBufferedReader( Classpaths.path(file.toString()), charset ) ); } catch ( IOException e ) { throw new JsonException("Unable to process file: " + file.getPath(), e); } } }
[ "private", "Object", "parseFile", "(", "File", "file", ",", "String", "scharset", ")", "{", "Charset", "charset", "=", "scharset", "==", "null", "||", "scharset", ".", "length", "(", ")", "==", "0", "?", "StandardCharsets", ".", "UTF_8", ":", "Charset", ".", "forName", "(", "scharset", ")", ";", "if", "(", "file", ".", "length", "(", ")", ">", "2_000_000", ")", "{", "try", "(", "Reader", "reader", "=", "Files", ".", "newBufferedReader", "(", "Classpaths", ".", "path", "(", "file", ".", "toString", "(", ")", ")", ",", "charset", ")", ")", "{", "return", "parse", "(", "reader", ")", ";", "}", "catch", "(", "IOException", "ioe", ")", "{", "throw", "new", "JsonException", "(", "\"Unable to process file: \"", "+", "file", ".", "getPath", "(", ")", ",", "ioe", ")", ";", "}", "}", "else", "{", "try", "{", "return", "JsonFactory", ".", "create", "(", ")", ".", "fromJson", "(", "Files", ".", "newBufferedReader", "(", "Classpaths", ".", "path", "(", "file", ".", "toString", "(", ")", ")", ",", "charset", ")", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "JsonException", "(", "\"Unable to process file: \"", "+", "file", ".", "getPath", "(", ")", ",", "e", ")", ";", "}", "}", "}" ]
Slight changes to remove groovy dependencies .
[ "Slight", "changes", "to", "remove", "groovy", "dependencies", "." ]
12712d376761aa3b33223a9f1716720ddb67cb5e
https://github.com/advantageous/boon/blob/12712d376761aa3b33223a9f1716720ddb67cb5e/util/src/main/java/io/advantageous/boon/json/JsonSlurper.java#L116-L132
138,749
advantageous/boon
util/src/main/java/io/advantageous/boon/Terminal.java
Terminal.puts
public static void puts(Object... messages) { for (Object message : messages) { IO.print(message); if (!(message instanceof Terminal.Escape)) IO.print(' '); } IO.println(); }
java
public static void puts(Object... messages) { for (Object message : messages) { IO.print(message); if (!(message instanceof Terminal.Escape)) IO.print(' '); } IO.println(); }
[ "public", "static", "void", "puts", "(", "Object", "...", "messages", ")", "{", "for", "(", "Object", "message", ":", "messages", ")", "{", "IO", ".", "print", "(", "message", ")", ";", "if", "(", "!", "(", "message", "instanceof", "Terminal", ".", "Escape", ")", ")", "IO", ".", "print", "(", "'", "'", ")", ";", "}", "IO", ".", "println", "(", ")", ";", "}" ]
Like print, but prints out a whole slew of objects on the same line. @param messages objects you want to print on the same line.
[ "Like", "print", "but", "prints", "out", "a", "whole", "slew", "of", "objects", "on", "the", "same", "line", "." ]
12712d376761aa3b33223a9f1716720ddb67cb5e
https://github.com/advantageous/boon/blob/12712d376761aa3b33223a9f1716720ddb67cb5e/util/src/main/java/io/advantageous/boon/Terminal.java#L64-L72
138,750
advantageous/boon
util/src/main/java/io/advantageous/boon/cache/CacheEntry.java
CacheEntry.compareOrder
private int compareOrder( CacheEntry other ) { if ( order > other.order ) { //this order is lower so it has higher priority return 1; } else if ( order < other.order ) {//this order is higher so it has lower priority return -1; } else if ( order == other.order ) {//equal priority return 0; } die(); return 0; }
java
private int compareOrder( CacheEntry other ) { if ( order > other.order ) { //this order is lower so it has higher priority return 1; } else if ( order < other.order ) {//this order is higher so it has lower priority return -1; } else if ( order == other.order ) {//equal priority return 0; } die(); return 0; }
[ "private", "int", "compareOrder", "(", "CacheEntry", "other", ")", "{", "if", "(", "order", ">", "other", ".", "order", ")", "{", "//this order is lower so it has higher priority", "return", "1", ";", "}", "else", "if", "(", "order", "<", "other", ".", "order", ")", "{", "//this order is higher so it has lower priority", "return", "-", "1", ";", "}", "else", "if", "(", "order", "==", "other", ".", "order", ")", "{", "//equal priority", "return", "0", ";", "}", "die", "(", ")", ";", "return", "0", ";", "}" ]
Compare the order. @param other the other entry @return results
[ "Compare", "the", "order", "." ]
12712d376761aa3b33223a9f1716720ddb67cb5e
https://github.com/advantageous/boon/blob/12712d376761aa3b33223a9f1716720ddb67cb5e/util/src/main/java/io/advantageous/boon/cache/CacheEntry.java#L143-L154
138,751
advantageous/boon
util/src/main/java/io/advantageous/boon/cache/CacheEntry.java
CacheEntry.compareToLFU
private int compareToLFU( CacheEntry other ) { int cmp = compareReadCount( other ); if ( cmp != 0 ) { return cmp; } cmp = compareTime( other ); if ( cmp != 0 ) { return cmp; } return compareOrder( other ); }
java
private int compareToLFU( CacheEntry other ) { int cmp = compareReadCount( other ); if ( cmp != 0 ) { return cmp; } cmp = compareTime( other ); if ( cmp != 0 ) { return cmp; } return compareOrder( other ); }
[ "private", "int", "compareToLFU", "(", "CacheEntry", "other", ")", "{", "int", "cmp", "=", "compareReadCount", "(", "other", ")", ";", "if", "(", "cmp", "!=", "0", ")", "{", "return", "cmp", ";", "}", "cmp", "=", "compareTime", "(", "other", ")", ";", "if", "(", "cmp", "!=", "0", ")", "{", "return", "cmp", ";", "}", "return", "compareOrder", "(", "other", ")", ";", "}" ]
Compares the read counts. @param other read count @return results
[ "Compares", "the", "read", "counts", "." ]
12712d376761aa3b33223a9f1716720ddb67cb5e
https://github.com/advantageous/boon/blob/12712d376761aa3b33223a9f1716720ddb67cb5e/util/src/main/java/io/advantageous/boon/cache/CacheEntry.java#L161-L174
138,752
advantageous/boon
util/src/main/java/io/advantageous/boon/cache/CacheEntry.java
CacheEntry.compareToLRU
private int compareToLRU( CacheEntry other ) { int cmp = compareTime( other ); if ( cmp != 0 ) { return cmp; } cmp = compareOrder( other ); if ( cmp != 0 ) { return cmp; } return compareReadCount( other ); }
java
private int compareToLRU( CacheEntry other ) { int cmp = compareTime( other ); if ( cmp != 0 ) { return cmp; } cmp = compareOrder( other ); if ( cmp != 0 ) { return cmp; } return compareReadCount( other ); }
[ "private", "int", "compareToLRU", "(", "CacheEntry", "other", ")", "{", "int", "cmp", "=", "compareTime", "(", "other", ")", ";", "if", "(", "cmp", "!=", "0", ")", "{", "return", "cmp", ";", "}", "cmp", "=", "compareOrder", "(", "other", ")", ";", "if", "(", "cmp", "!=", "0", ")", "{", "return", "cmp", ";", "}", "return", "compareReadCount", "(", "other", ")", ";", "}" ]
Compare the time. @param other other entry to compare to @return results
[ "Compare", "the", "time", "." ]
12712d376761aa3b33223a9f1716720ddb67cb5e
https://github.com/advantageous/boon/blob/12712d376761aa3b33223a9f1716720ddb67cb5e/util/src/main/java/io/advantageous/boon/cache/CacheEntry.java#L182-L197
138,753
advantageous/boon
util/src/main/java/io/advantageous/boon/cache/CacheEntry.java
CacheEntry.compareToFIFO
private int compareToFIFO( CacheEntry other ) { int cmp = compareOrder( other ); if ( cmp != 0 ) { return cmp; } cmp = compareTime( other ); if ( cmp != 0 ) { return cmp; } return cmp = compareReadCount( other ); }
java
private int compareToFIFO( CacheEntry other ) { int cmp = compareOrder( other ); if ( cmp != 0 ) { return cmp; } cmp = compareTime( other ); if ( cmp != 0 ) { return cmp; } return cmp = compareReadCount( other ); }
[ "private", "int", "compareToFIFO", "(", "CacheEntry", "other", ")", "{", "int", "cmp", "=", "compareOrder", "(", "other", ")", ";", "if", "(", "cmp", "!=", "0", ")", "{", "return", "cmp", ";", "}", "cmp", "=", "compareTime", "(", "other", ")", ";", "if", "(", "cmp", "!=", "0", ")", "{", "return", "cmp", ";", "}", "return", "cmp", "=", "compareReadCount", "(", "other", ")", ";", "}" ]
Compare for FIFO @param other the other entry @return results
[ "Compare", "for", "FIFO" ]
12712d376761aa3b33223a9f1716720ddb67cb5e
https://github.com/advantageous/boon/blob/12712d376761aa3b33223a9f1716720ddb67cb5e/util/src/main/java/io/advantageous/boon/cache/CacheEntry.java#L205-L219
138,754
awin/rabbiteasy
rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/MessageReader.java
MessageReader.readBodyAs
@SuppressWarnings("unchecked") public <T> T readBodyAs(Class<T> type) { if (String.class.isAssignableFrom(type)) { return (T)readBodyAsString(); } else if (Number.class.isAssignableFrom(type)) { return (T)readBodyAsNumber((Class<Number>)type); } else if (Boolean.class.isAssignableFrom(type)) { return (T)readBodyAsBoolean(); } else if (Character.class.isAssignableFrom(type)) { return (T)readBodyAsChar(); } return readBodyAsObject(type); }
java
@SuppressWarnings("unchecked") public <T> T readBodyAs(Class<T> type) { if (String.class.isAssignableFrom(type)) { return (T)readBodyAsString(); } else if (Number.class.isAssignableFrom(type)) { return (T)readBodyAsNumber((Class<Number>)type); } else if (Boolean.class.isAssignableFrom(type)) { return (T)readBodyAsBoolean(); } else if (Character.class.isAssignableFrom(type)) { return (T)readBodyAsChar(); } return readBodyAsObject(type); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", ">", "T", "readBodyAs", "(", "Class", "<", "T", ">", "type", ")", "{", "if", "(", "String", ".", "class", ".", "isAssignableFrom", "(", "type", ")", ")", "{", "return", "(", "T", ")", "readBodyAsString", "(", ")", ";", "}", "else", "if", "(", "Number", ".", "class", ".", "isAssignableFrom", "(", "type", ")", ")", "{", "return", "(", "T", ")", "readBodyAsNumber", "(", "(", "Class", "<", "Number", ">", ")", "type", ")", ";", "}", "else", "if", "(", "Boolean", ".", "class", ".", "isAssignableFrom", "(", "type", ")", ")", "{", "return", "(", "T", ")", "readBodyAsBoolean", "(", ")", ";", "}", "else", "if", "(", "Character", ".", "class", ".", "isAssignableFrom", "(", "type", ")", ")", "{", "return", "(", "T", ")", "readBodyAsChar", "(", ")", ";", "}", "return", "readBodyAsObject", "(", "type", ")", ";", "}" ]
Extracts the message body and interprets it as the given Java type @param type The Java type @return The message body a the specified type
[ "Extracts", "the", "message", "body", "and", "interprets", "it", "as", "the", "given", "Java", "type" ]
c161efda6c0f7ef319aedf09dfe40a4a90165510
https://github.com/awin/rabbiteasy/blob/c161efda6c0f7ef319aedf09dfe40a4a90165510/rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/MessageReader.java#L60-L72
138,755
awin/rabbiteasy
rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/MessageReader.java
MessageReader.readBodyAsString
public String readBodyAsString() { Charset charset = readCharset(); byte[] bodyContent = message.getBodyContent(); return new String(bodyContent, charset); }
java
public String readBodyAsString() { Charset charset = readCharset(); byte[] bodyContent = message.getBodyContent(); return new String(bodyContent, charset); }
[ "public", "String", "readBodyAsString", "(", ")", "{", "Charset", "charset", "=", "readCharset", "(", ")", ";", "byte", "[", "]", "bodyContent", "=", "message", ".", "getBodyContent", "(", ")", ";", "return", "new", "String", "(", "bodyContent", ",", "charset", ")", ";", "}" ]
Extracts the message body and interprets it as a string. @return The message body as string
[ "Extracts", "the", "message", "body", "and", "interprets", "it", "as", "a", "string", "." ]
c161efda6c0f7ef319aedf09dfe40a4a90165510
https://github.com/awin/rabbiteasy/blob/c161efda6c0f7ef319aedf09dfe40a4a90165510/rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/MessageReader.java#L80-L84
138,756
awin/rabbiteasy
rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/MessageReader.java
MessageReader.readBodyAsObject
@SuppressWarnings("unchecked") public <T> T readBodyAsObject(Class<T> type) { Charset charset = readCharset(); InputStream inputStream = new ByteArrayInputStream(message.getBodyContent()); InputStreamReader inputReader = new InputStreamReader(inputStream, charset); StreamSource streamSource = new StreamSource(inputReader); try { Unmarshaller unmarshaller = JAXBContext.newInstance(type).createUnmarshaller(); if (type.isAnnotationPresent(XmlRootElement.class)) { return (T)unmarshaller.unmarshal(streamSource); } else { JAXBElement<T> element = unmarshaller.unmarshal(streamSource, type); return element.getValue(); } } catch (JAXBException e) { throw new RuntimeException(e); } }
java
@SuppressWarnings("unchecked") public <T> T readBodyAsObject(Class<T> type) { Charset charset = readCharset(); InputStream inputStream = new ByteArrayInputStream(message.getBodyContent()); InputStreamReader inputReader = new InputStreamReader(inputStream, charset); StreamSource streamSource = new StreamSource(inputReader); try { Unmarshaller unmarshaller = JAXBContext.newInstance(type).createUnmarshaller(); if (type.isAnnotationPresent(XmlRootElement.class)) { return (T)unmarshaller.unmarshal(streamSource); } else { JAXBElement<T> element = unmarshaller.unmarshal(streamSource, type); return element.getValue(); } } catch (JAXBException e) { throw new RuntimeException(e); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", ">", "T", "readBodyAsObject", "(", "Class", "<", "T", ">", "type", ")", "{", "Charset", "charset", "=", "readCharset", "(", ")", ";", "InputStream", "inputStream", "=", "new", "ByteArrayInputStream", "(", "message", ".", "getBodyContent", "(", ")", ")", ";", "InputStreamReader", "inputReader", "=", "new", "InputStreamReader", "(", "inputStream", ",", "charset", ")", ";", "StreamSource", "streamSource", "=", "new", "StreamSource", "(", "inputReader", ")", ";", "try", "{", "Unmarshaller", "unmarshaller", "=", "JAXBContext", ".", "newInstance", "(", "type", ")", ".", "createUnmarshaller", "(", ")", ";", "if", "(", "type", ".", "isAnnotationPresent", "(", "XmlRootElement", ".", "class", ")", ")", "{", "return", "(", "T", ")", "unmarshaller", ".", "unmarshal", "(", "streamSource", ")", ";", "}", "else", "{", "JAXBElement", "<", "T", ">", "element", "=", "unmarshaller", ".", "unmarshal", "(", "streamSource", ",", "type", ")", ";", "return", "element", ".", "getValue", "(", ")", ";", "}", "}", "catch", "(", "JAXBException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}" ]
Extracts the message body and interprets it as the XML representation of an object of the given type. @param type The type (class) of the object @return The message body as an object of the specified type
[ "Extracts", "the", "message", "body", "and", "interprets", "it", "as", "the", "XML", "representation", "of", "an", "object", "of", "the", "given", "type", "." ]
c161efda6c0f7ef319aedf09dfe40a4a90165510
https://github.com/awin/rabbiteasy/blob/c161efda6c0f7ef319aedf09dfe40a4a90165510/rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/MessageReader.java#L143-L160
138,757
awin/rabbiteasy
rabbiteasy-cdi/src/main/java/com/zanox/rabbiteasy/cdi/EventPublisher.java
EventPublisher.addEvent
public <T> void addEvent(Class<T> eventType, PublisherConfiguration configuration) { publisherConfigurations.put(eventType, configuration); }
java
public <T> void addEvent(Class<T> eventType, PublisherConfiguration configuration) { publisherConfigurations.put(eventType, configuration); }
[ "public", "<", "T", ">", "void", "addEvent", "(", "Class", "<", "T", ">", "eventType", ",", "PublisherConfiguration", "configuration", ")", "{", "publisherConfigurations", ".", "put", "(", "eventType", ",", "configuration", ")", ";", "}" ]
Adds events of the given type to the CDI events to which the event publisher listens in order to publish them. The publisher configuration is used to decide where to and how to publish messages. @param eventType The event type @param configuration The configuration used when publishing and event @param <T> The event type
[ "Adds", "events", "of", "the", "given", "type", "to", "the", "CDI", "events", "to", "which", "the", "event", "publisher", "listens", "in", "order", "to", "publish", "them", ".", "The", "publisher", "configuration", "is", "used", "to", "decide", "where", "to", "and", "how", "to", "publish", "messages", "." ]
c161efda6c0f7ef319aedf09dfe40a4a90165510
https://github.com/awin/rabbiteasy/blob/c161efda6c0f7ef319aedf09dfe40a4a90165510/rabbiteasy-cdi/src/main/java/com/zanox/rabbiteasy/cdi/EventPublisher.java#L50-L52
138,758
awin/rabbiteasy
rabbiteasy-cdi/src/main/java/com/zanox/rabbiteasy/cdi/EventPublisher.java
EventPublisher.providePublisher
MessagePublisher providePublisher(PublisherReliability reliability, Class<?> eventType) { Map<Class<?>, MessagePublisher> localPublishers = publishers.get(); if (localPublishers == null) { localPublishers = new HashMap<Class<?>, MessagePublisher>(); publishers.set(localPublishers); } MessagePublisher publisher = localPublishers.get(eventType); if (publisher == null) { publisher = new GenericPublisher(connectionFactory, reliability); localPublishers.put(eventType, publisher); } return publisher; }
java
MessagePublisher providePublisher(PublisherReliability reliability, Class<?> eventType) { Map<Class<?>, MessagePublisher> localPublishers = publishers.get(); if (localPublishers == null) { localPublishers = new HashMap<Class<?>, MessagePublisher>(); publishers.set(localPublishers); } MessagePublisher publisher = localPublishers.get(eventType); if (publisher == null) { publisher = new GenericPublisher(connectionFactory, reliability); localPublishers.put(eventType, publisher); } return publisher; }
[ "MessagePublisher", "providePublisher", "(", "PublisherReliability", "reliability", ",", "Class", "<", "?", ">", "eventType", ")", "{", "Map", "<", "Class", "<", "?", ">", ",", "MessagePublisher", ">", "localPublishers", "=", "publishers", ".", "get", "(", ")", ";", "if", "(", "localPublishers", "==", "null", ")", "{", "localPublishers", "=", "new", "HashMap", "<", "Class", "<", "?", ">", ",", "MessagePublisher", ">", "(", ")", ";", "publishers", ".", "set", "(", "localPublishers", ")", ";", "}", "MessagePublisher", "publisher", "=", "localPublishers", ".", "get", "(", "eventType", ")", ";", "if", "(", "publisher", "==", "null", ")", "{", "publisher", "=", "new", "GenericPublisher", "(", "connectionFactory", ",", "reliability", ")", ";", "localPublishers", ".", "put", "(", "eventType", ",", "publisher", ")", ";", "}", "return", "publisher", ";", "}" ]
Provides a publisher with the specified reliability. Within the same thread, the same producer instance is provided for the given event type. @param reliability The desired publisher reliability @param eventType The event type @return The provided publisher
[ "Provides", "a", "publisher", "with", "the", "specified", "reliability", ".", "Within", "the", "same", "thread", "the", "same", "producer", "instance", "is", "provided", "for", "the", "given", "event", "type", "." ]
c161efda6c0f7ef319aedf09dfe40a4a90165510
https://github.com/awin/rabbiteasy/blob/c161efda6c0f7ef319aedf09dfe40a4a90165510/rabbiteasy-cdi/src/main/java/com/zanox/rabbiteasy/cdi/EventPublisher.java#L89-L101
138,759
awin/rabbiteasy
rabbiteasy-cdi/src/main/java/com/zanox/rabbiteasy/cdi/EventPublisher.java
EventPublisher.buildMessage
static Message buildMessage(PublisherConfiguration publisherConfiguration, Object event) { Message message = new Message(publisherConfiguration.basicProperties) .exchange(publisherConfiguration.exchange) .routingKey(publisherConfiguration.routingKey); if (publisherConfiguration.persistent) { message.persistent(); } if (event instanceof ContainsData) { message.body(((ContainsData) event).getData()); } else if (event instanceof ContainsContent) { message.body(((ContainsContent) event).getContent()); } else if (event instanceof ContainsId) { message.body(((ContainsId) event).getId()); } return message; }
java
static Message buildMessage(PublisherConfiguration publisherConfiguration, Object event) { Message message = new Message(publisherConfiguration.basicProperties) .exchange(publisherConfiguration.exchange) .routingKey(publisherConfiguration.routingKey); if (publisherConfiguration.persistent) { message.persistent(); } if (event instanceof ContainsData) { message.body(((ContainsData) event).getData()); } else if (event instanceof ContainsContent) { message.body(((ContainsContent) event).getContent()); } else if (event instanceof ContainsId) { message.body(((ContainsId) event).getId()); } return message; }
[ "static", "Message", "buildMessage", "(", "PublisherConfiguration", "publisherConfiguration", ",", "Object", "event", ")", "{", "Message", "message", "=", "new", "Message", "(", "publisherConfiguration", ".", "basicProperties", ")", ".", "exchange", "(", "publisherConfiguration", ".", "exchange", ")", ".", "routingKey", "(", "publisherConfiguration", ".", "routingKey", ")", ";", "if", "(", "publisherConfiguration", ".", "persistent", ")", "{", "message", ".", "persistent", "(", ")", ";", "}", "if", "(", "event", "instanceof", "ContainsData", ")", "{", "message", ".", "body", "(", "(", "(", "ContainsData", ")", "event", ")", ".", "getData", "(", ")", ")", ";", "}", "else", "if", "(", "event", "instanceof", "ContainsContent", ")", "{", "message", ".", "body", "(", "(", "(", "ContainsContent", ")", "event", ")", ".", "getContent", "(", ")", ")", ";", "}", "else", "if", "(", "event", "instanceof", "ContainsId", ")", "{", "message", ".", "body", "(", "(", "(", "ContainsId", ")", "event", ")", ".", "getId", "(", ")", ")", ";", "}", "return", "message", ";", "}" ]
Builds a message based on a CDI event and its publisher configuration. @param publisherConfiguration The publisher configuration @param event The CDI event @return The message
[ "Builds", "a", "message", "based", "on", "a", "CDI", "event", "and", "its", "publisher", "configuration", "." ]
c161efda6c0f7ef319aedf09dfe40a4a90165510
https://github.com/awin/rabbiteasy/blob/c161efda6c0f7ef319aedf09dfe40a4a90165510/rabbiteasy-cdi/src/main/java/com/zanox/rabbiteasy/cdi/EventPublisher.java#L135-L150
138,760
awin/rabbiteasy
rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/Message.java
Message.body
public <T> Message body(T body, Charset charset) { messageWriter.writeBody(body, charset); return this; }
java
public <T> Message body(T body, Charset charset) { messageWriter.writeBody(body, charset); return this; }
[ "public", "<", "T", ">", "Message", "body", "(", "T", "body", ",", "Charset", "charset", ")", "{", "messageWriter", ".", "writeBody", "(", "body", ",", "charset", ")", ";", "return", "this", ";", "}" ]
Serializes and adds the given object as body to the message using the given charset for encoding. @see MessageWriter#writeBody(Object, Charset)
[ "Serializes", "and", "adds", "the", "given", "object", "as", "body", "to", "the", "message", "using", "the", "given", "charset", "for", "encoding", "." ]
c161efda6c0f7ef319aedf09dfe40a4a90165510
https://github.com/awin/rabbiteasy/blob/c161efda6c0f7ef319aedf09dfe40a4a90165510/rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/Message.java#L185-L188
138,761
awin/rabbiteasy
rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/Message.java
Message.contentEncoding
public Message contentEncoding(String charset) { basicProperties = basicProperties.builder() .contentEncoding(charset) .build(); return this; }
java
public Message contentEncoding(String charset) { basicProperties = basicProperties.builder() .contentEncoding(charset) .build(); return this; }
[ "public", "Message", "contentEncoding", "(", "String", "charset", ")", "{", "basicProperties", "=", "basicProperties", ".", "builder", "(", ")", ".", "contentEncoding", "(", "charset", ")", ".", "build", "(", ")", ";", "return", "this", ";", "}" ]
Sets the content charset encoding of this message. @param charset The charset encoding @return The modified message
[ "Sets", "the", "content", "charset", "encoding", "of", "this", "message", "." ]
c161efda6c0f7ef319aedf09dfe40a4a90165510
https://github.com/awin/rabbiteasy/blob/c161efda6c0f7ef319aedf09dfe40a4a90165510/rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/Message.java#L232-L237
138,762
awin/rabbiteasy
rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/Message.java
Message.contentType
public Message contentType(String contentType) { basicProperties = basicProperties.builder() .contentType(contentType) .build(); return this; }
java
public Message contentType(String contentType) { basicProperties = basicProperties.builder() .contentType(contentType) .build(); return this; }
[ "public", "Message", "contentType", "(", "String", "contentType", ")", "{", "basicProperties", "=", "basicProperties", ".", "builder", "(", ")", ".", "contentType", "(", "contentType", ")", ".", "build", "(", ")", ";", "return", "this", ";", "}" ]
Sets the content type of this message. @param contentType The content type @return The modified message
[ "Sets", "the", "content", "type", "of", "this", "message", "." ]
c161efda6c0f7ef319aedf09dfe40a4a90165510
https://github.com/awin/rabbiteasy/blob/c161efda6c0f7ef319aedf09dfe40a4a90165510/rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/Message.java#L245-L250
138,763
awin/rabbiteasy
rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/Message.java
Message.publish
public void publish(Channel channel, DeliveryOptions deliveryOptions) throws IOException { // Assure to have a timestamp if (basicProperties.getTimestamp() == null) { basicProperties.builder().timestamp(new Date()); } boolean mandatory = deliveryOptions == DeliveryOptions.MANDATORY; boolean immediate = deliveryOptions == DeliveryOptions.IMMEDIATE; LOGGER.info("Publishing message to exchange '{}' with routing key '{}' (deliveryOptions: {}, persistent: {})", new Object[] { exchange, routingKey, deliveryOptions, basicProperties.getDeliveryMode() == 2 }); channel.basicPublish(exchange, routingKey, mandatory, immediate, basicProperties, bodyContent); LOGGER.info("Successfully published message to exchange '{}' with routing key '{}'", exchange, routingKey); }
java
public void publish(Channel channel, DeliveryOptions deliveryOptions) throws IOException { // Assure to have a timestamp if (basicProperties.getTimestamp() == null) { basicProperties.builder().timestamp(new Date()); } boolean mandatory = deliveryOptions == DeliveryOptions.MANDATORY; boolean immediate = deliveryOptions == DeliveryOptions.IMMEDIATE; LOGGER.info("Publishing message to exchange '{}' with routing key '{}' (deliveryOptions: {}, persistent: {})", new Object[] { exchange, routingKey, deliveryOptions, basicProperties.getDeliveryMode() == 2 }); channel.basicPublish(exchange, routingKey, mandatory, immediate, basicProperties, bodyContent); LOGGER.info("Successfully published message to exchange '{}' with routing key '{}'", exchange, routingKey); }
[ "public", "void", "publish", "(", "Channel", "channel", ",", "DeliveryOptions", "deliveryOptions", ")", "throws", "IOException", "{", "// Assure to have a timestamp\r", "if", "(", "basicProperties", ".", "getTimestamp", "(", ")", "==", "null", ")", "{", "basicProperties", ".", "builder", "(", ")", ".", "timestamp", "(", "new", "Date", "(", ")", ")", ";", "}", "boolean", "mandatory", "=", "deliveryOptions", "==", "DeliveryOptions", ".", "MANDATORY", ";", "boolean", "immediate", "=", "deliveryOptions", "==", "DeliveryOptions", ".", "IMMEDIATE", ";", "LOGGER", ".", "info", "(", "\"Publishing message to exchange '{}' with routing key '{}' (deliveryOptions: {}, persistent: {})\"", ",", "new", "Object", "[", "]", "{", "exchange", ",", "routingKey", ",", "deliveryOptions", ",", "basicProperties", ".", "getDeliveryMode", "(", ")", "==", "2", "}", ")", ";", "channel", ".", "basicPublish", "(", "exchange", ",", "routingKey", ",", "mandatory", ",", "immediate", ",", "basicProperties", ",", "bodyContent", ")", ";", "LOGGER", ".", "info", "(", "\"Successfully published message to exchange '{}' with routing key '{}'\"", ",", "exchange", ",", "routingKey", ")", ";", "}" ]
Publishes a message via the given channel while using the specified delivery options. @param channel The channel used to publish the message on @param deliveryOptions The delivery options to use @throws IOException
[ "Publishes", "a", "message", "via", "the", "given", "channel", "while", "using", "the", "specified", "delivery", "options", "." ]
c161efda6c0f7ef319aedf09dfe40a4a90165510
https://github.com/awin/rabbiteasy/blob/c161efda6c0f7ef319aedf09dfe40a4a90165510/rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/Message.java#L269-L283
138,764
awin/rabbiteasy
rabbiteasy-cdi/src/main/java/com/zanox/rabbiteasy/cdi/EventConsumer.java
EventConsumer.buildEvent
@SuppressWarnings("unchecked") Object buildEvent(Message message) { Object event = eventPool.get(); if (event instanceof ContainsData) { ((ContainsData) event).setData(message.getBodyContent()); } else if (event instanceof ContainsContent) { Class<?> parameterType = getParameterType(event, ContainsContent.class); ((ContainsContent) event).setContent(message.getBodyAs(parameterType)); } else if (event instanceof ContainsId) { Class<?> parameterType = getParameterType(event, ContainsId.class); ((ContainsId) event).setId(message.getBodyAs(parameterType)); } return event; }
java
@SuppressWarnings("unchecked") Object buildEvent(Message message) { Object event = eventPool.get(); if (event instanceof ContainsData) { ((ContainsData) event).setData(message.getBodyContent()); } else if (event instanceof ContainsContent) { Class<?> parameterType = getParameterType(event, ContainsContent.class); ((ContainsContent) event).setContent(message.getBodyAs(parameterType)); } else if (event instanceof ContainsId) { Class<?> parameterType = getParameterType(event, ContainsId.class); ((ContainsId) event).setId(message.getBodyAs(parameterType)); } return event; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "Object", "buildEvent", "(", "Message", "message", ")", "{", "Object", "event", "=", "eventPool", ".", "get", "(", ")", ";", "if", "(", "event", "instanceof", "ContainsData", ")", "{", "(", "(", "ContainsData", ")", "event", ")", ".", "setData", "(", "message", ".", "getBodyContent", "(", ")", ")", ";", "}", "else", "if", "(", "event", "instanceof", "ContainsContent", ")", "{", "Class", "<", "?", ">", "parameterType", "=", "getParameterType", "(", "event", ",", "ContainsContent", ".", "class", ")", ";", "(", "(", "ContainsContent", ")", "event", ")", ".", "setContent", "(", "message", ".", "getBodyAs", "(", "parameterType", ")", ")", ";", "}", "else", "if", "(", "event", "instanceof", "ContainsId", ")", "{", "Class", "<", "?", ">", "parameterType", "=", "getParameterType", "(", "event", ",", "ContainsId", ".", "class", ")", ";", "(", "(", "ContainsId", ")", "event", ")", ".", "setId", "(", "message", ".", "getBodyAs", "(", "parameterType", ")", ")", ";", "}", "return", "event", ";", "}" ]
Builds a CDI event from a message. The CDI event instance is retrieved from the injection container. @param message The message @return The CDI event
[ "Builds", "a", "CDI", "event", "from", "a", "message", ".", "The", "CDI", "event", "instance", "is", "retrieved", "from", "the", "injection", "container", "." ]
c161efda6c0f7ef319aedf09dfe40a4a90165510
https://github.com/awin/rabbiteasy/blob/c161efda6c0f7ef319aedf09dfe40a4a90165510/rabbiteasy-cdi/src/main/java/com/zanox/rabbiteasy/cdi/EventConsumer.java#L40-L53
138,765
awin/rabbiteasy
rabbiteasy-cdi/src/main/java/com/zanox/rabbiteasy/cdi/EventConsumer.java
EventConsumer.getParameterType
@SuppressWarnings("unchecked") static Class<?> getParameterType(Object object, Class<?> expectedType) { Collection<Class<?>> extendedAndImplementedTypes = getExtendedAndImplementedTypes(object.getClass(), new LinkedList<Class<?>>()); for (Class<?> type : extendedAndImplementedTypes) { Type[] implementedInterfaces = type.getGenericInterfaces(); for (Type implementedInterface : implementedInterfaces) { if (implementedInterface instanceof ParameterizedType) { ParameterizedType parameterizedCandidateType = (ParameterizedType) implementedInterface; if (parameterizedCandidateType.getRawType().equals(expectedType)) { Type[] typeArguments = parameterizedCandidateType.getActualTypeArguments(); Type typeArgument; if (typeArguments.length == 0) { typeArgument = Object.class; } else { typeArgument = parameterizedCandidateType.getActualTypeArguments()[0]; } return (Class<?>) typeArgument; } } } } // This may never happen in case the caller checked if object instanceof expectedType throw new RuntimeException("Expected type " + expectedType + " is not in class hierarchy of " + object.getClass()); }
java
@SuppressWarnings("unchecked") static Class<?> getParameterType(Object object, Class<?> expectedType) { Collection<Class<?>> extendedAndImplementedTypes = getExtendedAndImplementedTypes(object.getClass(), new LinkedList<Class<?>>()); for (Class<?> type : extendedAndImplementedTypes) { Type[] implementedInterfaces = type.getGenericInterfaces(); for (Type implementedInterface : implementedInterfaces) { if (implementedInterface instanceof ParameterizedType) { ParameterizedType parameterizedCandidateType = (ParameterizedType) implementedInterface; if (parameterizedCandidateType.getRawType().equals(expectedType)) { Type[] typeArguments = parameterizedCandidateType.getActualTypeArguments(); Type typeArgument; if (typeArguments.length == 0) { typeArgument = Object.class; } else { typeArgument = parameterizedCandidateType.getActualTypeArguments()[0]; } return (Class<?>) typeArgument; } } } } // This may never happen in case the caller checked if object instanceof expectedType throw new RuntimeException("Expected type " + expectedType + " is not in class hierarchy of " + object.getClass()); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "static", "Class", "<", "?", ">", "getParameterType", "(", "Object", "object", ",", "Class", "<", "?", ">", "expectedType", ")", "{", "Collection", "<", "Class", "<", "?", ">", ">", "extendedAndImplementedTypes", "=", "getExtendedAndImplementedTypes", "(", "object", ".", "getClass", "(", ")", ",", "new", "LinkedList", "<", "Class", "<", "?", ">", ">", "(", ")", ")", ";", "for", "(", "Class", "<", "?", ">", "type", ":", "extendedAndImplementedTypes", ")", "{", "Type", "[", "]", "implementedInterfaces", "=", "type", ".", "getGenericInterfaces", "(", ")", ";", "for", "(", "Type", "implementedInterface", ":", "implementedInterfaces", ")", "{", "if", "(", "implementedInterface", "instanceof", "ParameterizedType", ")", "{", "ParameterizedType", "parameterizedCandidateType", "=", "(", "ParameterizedType", ")", "implementedInterface", ";", "if", "(", "parameterizedCandidateType", ".", "getRawType", "(", ")", ".", "equals", "(", "expectedType", ")", ")", "{", "Type", "[", "]", "typeArguments", "=", "parameterizedCandidateType", ".", "getActualTypeArguments", "(", ")", ";", "Type", "typeArgument", ";", "if", "(", "typeArguments", ".", "length", "==", "0", ")", "{", "typeArgument", "=", "Object", ".", "class", ";", "}", "else", "{", "typeArgument", "=", "parameterizedCandidateType", ".", "getActualTypeArguments", "(", ")", "[", "0", "]", ";", "}", "return", "(", "Class", "<", "?", ">", ")", "typeArgument", ";", "}", "}", "}", "}", "// This may never happen in case the caller checked if object instanceof expectedType\r", "throw", "new", "RuntimeException", "(", "\"Expected type \"", "+", "expectedType", "+", "\" is not in class hierarchy of \"", "+", "object", ".", "getClass", "(", ")", ")", ";", "}" ]
Gets the type parameter of the expected generic interface which is actually used by the class of the given object. The generic interface can be implemented by an class or interface in the object's class hierarchy, @param object The object @param expectedType The expected generic interface @return The actually used parameter of the expected generic interface
[ "Gets", "the", "type", "parameter", "of", "the", "expected", "generic", "interface", "which", "is", "actually", "used", "by", "the", "class", "of", "the", "given", "object", ".", "The", "generic", "interface", "can", "be", "implemented", "by", "an", "class", "or", "interface", "in", "the", "object", "s", "class", "hierarchy" ]
c161efda6c0f7ef319aedf09dfe40a4a90165510
https://github.com/awin/rabbiteasy/blob/c161efda6c0f7ef319aedf09dfe40a4a90165510/rabbiteasy-cdi/src/main/java/com/zanox/rabbiteasy/cdi/EventConsumer.java#L65-L91
138,766
awin/rabbiteasy
rabbiteasy-cdi/src/main/java/com/zanox/rabbiteasy/cdi/EventConsumer.java
EventConsumer.getExtendedAndImplementedTypes
static List<Class<?>> getExtendedAndImplementedTypes(Class<?> clazz, List<Class<?>> hierarchy) { hierarchy.add(clazz); Class<?> superClass = clazz.getSuperclass(); if (superClass != null) { hierarchy = getExtendedAndImplementedTypes(superClass, hierarchy); } for (Class<?> implementedInterface : clazz.getInterfaces()) { hierarchy = getExtendedAndImplementedTypes(implementedInterface, hierarchy); } return hierarchy; }
java
static List<Class<?>> getExtendedAndImplementedTypes(Class<?> clazz, List<Class<?>> hierarchy) { hierarchy.add(clazz); Class<?> superClass = clazz.getSuperclass(); if (superClass != null) { hierarchy = getExtendedAndImplementedTypes(superClass, hierarchy); } for (Class<?> implementedInterface : clazz.getInterfaces()) { hierarchy = getExtendedAndImplementedTypes(implementedInterface, hierarchy); } return hierarchy; }
[ "static", "List", "<", "Class", "<", "?", ">", ">", "getExtendedAndImplementedTypes", "(", "Class", "<", "?", ">", "clazz", ",", "List", "<", "Class", "<", "?", ">", ">", "hierarchy", ")", "{", "hierarchy", ".", "add", "(", "clazz", ")", ";", "Class", "<", "?", ">", "superClass", "=", "clazz", ".", "getSuperclass", "(", ")", ";", "if", "(", "superClass", "!=", "null", ")", "{", "hierarchy", "=", "getExtendedAndImplementedTypes", "(", "superClass", ",", "hierarchy", ")", ";", "}", "for", "(", "Class", "<", "?", ">", "implementedInterface", ":", "clazz", ".", "getInterfaces", "(", ")", ")", "{", "hierarchy", "=", "getExtendedAndImplementedTypes", "(", "implementedInterface", ",", "hierarchy", ")", ";", "}", "return", "hierarchy", ";", "}" ]
Gets all classes and interfaces in the class hierarchy of the given class including the class itself. @param clazz The class @param hierarchy The current list of all classes and interfaces found so far @return All classes and interfaces in the class's hierarchy
[ "Gets", "all", "classes", "and", "interfaces", "in", "the", "class", "hierarchy", "of", "the", "given", "class", "including", "the", "class", "itself", "." ]
c161efda6c0f7ef319aedf09dfe40a4a90165510
https://github.com/awin/rabbiteasy/blob/c161efda6c0f7ef319aedf09dfe40a4a90165510/rabbiteasy-cdi/src/main/java/com/zanox/rabbiteasy/cdi/EventConsumer.java#L101-L111
138,767
awin/rabbiteasy
rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/publisher/DiscretePublisher.java
DiscretePublisher.provideChannel
protected Channel provideChannel() throws IOException { if (channel == null || !channel.isOpen()) { Connection connection = connectionFactory.newConnection(); channel = connection.createChannel(); } return channel; }
java
protected Channel provideChannel() throws IOException { if (channel == null || !channel.isOpen()) { Connection connection = connectionFactory.newConnection(); channel = connection.createChannel(); } return channel; }
[ "protected", "Channel", "provideChannel", "(", ")", "throws", "IOException", "{", "if", "(", "channel", "==", "null", "||", "!", "channel", ".", "isOpen", "(", ")", ")", "{", "Connection", "connection", "=", "connectionFactory", ".", "newConnection", "(", ")", ";", "channel", "=", "connection", ".", "createChannel", "(", ")", ";", "}", "return", "channel", ";", "}" ]
Initializes a channel if there is not already an open channel. @return The initialized or already open channel. @throws IOException if the channel cannot be initialized
[ "Initializes", "a", "channel", "if", "there", "is", "not", "already", "an", "open", "channel", "." ]
c161efda6c0f7ef319aedf09dfe40a4a90165510
https://github.com/awin/rabbiteasy/blob/c161efda6c0f7ef319aedf09dfe40a4a90165510/rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/publisher/DiscretePublisher.java#L73-L79
138,768
awin/rabbiteasy
rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/publisher/DiscretePublisher.java
DiscretePublisher.handleIoException
protected void handleIoException(int attempt, IOException ioException) throws IOException { if (channel != null && channel.isOpen()) { try { channel.close(); } catch (IOException e) { LOGGER.warn("Failed to close channel after failed publish", e); } } channel = null; if (attempt == DEFAULT_RETRY_ATTEMPTS) { throw ioException; } try { Thread.sleep(DEFAULT_RETRY_INTERVAL); } catch (InterruptedException e) { LOGGER.warn("Sending message interrupted while waiting for retry attempt", e); } }
java
protected void handleIoException(int attempt, IOException ioException) throws IOException { if (channel != null && channel.isOpen()) { try { channel.close(); } catch (IOException e) { LOGGER.warn("Failed to close channel after failed publish", e); } } channel = null; if (attempt == DEFAULT_RETRY_ATTEMPTS) { throw ioException; } try { Thread.sleep(DEFAULT_RETRY_INTERVAL); } catch (InterruptedException e) { LOGGER.warn("Sending message interrupted while waiting for retry attempt", e); } }
[ "protected", "void", "handleIoException", "(", "int", "attempt", ",", "IOException", "ioException", ")", "throws", "IOException", "{", "if", "(", "channel", "!=", "null", "&&", "channel", ".", "isOpen", "(", ")", ")", "{", "try", "{", "channel", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "LOGGER", ".", "warn", "(", "\"Failed to close channel after failed publish\"", ",", "e", ")", ";", "}", "}", "channel", "=", "null", ";", "if", "(", "attempt", "==", "DEFAULT_RETRY_ATTEMPTS", ")", "{", "throw", "ioException", ";", "}", "try", "{", "Thread", ".", "sleep", "(", "DEFAULT_RETRY_INTERVAL", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "LOGGER", ".", "warn", "(", "\"Sending message interrupted while waiting for retry attempt\"", ",", "e", ")", ";", "}", "}" ]
Handles an IOException depending on the already used attempts to send a message. Also performs a soft reset of the currently used channel. @param attempt Current attempt count @param ioException The thrown exception @throws IOException if the maximum amount of attempts is exceeded
[ "Handles", "an", "IOException", "depending", "on", "the", "already", "used", "attempts", "to", "send", "a", "message", ".", "Also", "performs", "a", "soft", "reset", "of", "the", "currently", "used", "channel", "." ]
c161efda6c0f7ef319aedf09dfe40a4a90165510
https://github.com/awin/rabbiteasy/blob/c161efda6c0f7ef319aedf09dfe40a4a90165510/rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/publisher/DiscretePublisher.java#L89-L106
138,769
advantageous/boon
reflekt/src/main/java/io/advantageous/boon/core/reflection/Fields.java
Fields.getSortableFieldFromClass
public static String getSortableFieldFromClass( Class<?> clazz ) { /** See if the fieldName is in the field listStream already. * We keep a hash-map cache. * */ String fieldName = getSortableField( clazz ); /** * Not found in cache. */ if ( fieldName == null ) { /* See if we have this sortable field and look for string first. */ for ( String name : fieldSortNames ) { if ( classHasStringField( clazz, name ) ) { fieldName = name; break; } } /* Now see if we can find one of our predefined suffixes. */ if ( fieldName == null ) { for ( String name : fieldSortNamesSuffixes ) { fieldName = getFirstStringFieldNameEndsWithFromClass( clazz, name ); if ( fieldName != null ) { break; } } } /** * Ok. We still did not find it so give us the first comparable or * primitive that we can find. */ if ( fieldName == null ) { fieldName = getFirstComparableOrPrimitiveFromClass( clazz ); } /* We could not find a sortable field. */ if ( fieldName == null ) { setSortableField( clazz, "NOT FOUND" ); Exceptions.die("Could not find a sortable field for type " + clazz); } /* We found a sortable field. */ setSortableField( clazz, fieldName ); } return fieldName; }
java
public static String getSortableFieldFromClass( Class<?> clazz ) { /** See if the fieldName is in the field listStream already. * We keep a hash-map cache. * */ String fieldName = getSortableField( clazz ); /** * Not found in cache. */ if ( fieldName == null ) { /* See if we have this sortable field and look for string first. */ for ( String name : fieldSortNames ) { if ( classHasStringField( clazz, name ) ) { fieldName = name; break; } } /* Now see if we can find one of our predefined suffixes. */ if ( fieldName == null ) { for ( String name : fieldSortNamesSuffixes ) { fieldName = getFirstStringFieldNameEndsWithFromClass( clazz, name ); if ( fieldName != null ) { break; } } } /** * Ok. We still did not find it so give us the first comparable or * primitive that we can find. */ if ( fieldName == null ) { fieldName = getFirstComparableOrPrimitiveFromClass( clazz ); } /* We could not find a sortable field. */ if ( fieldName == null ) { setSortableField( clazz, "NOT FOUND" ); Exceptions.die("Could not find a sortable field for type " + clazz); } /* We found a sortable field. */ setSortableField( clazz, fieldName ); } return fieldName; }
[ "public", "static", "String", "getSortableFieldFromClass", "(", "Class", "<", "?", ">", "clazz", ")", "{", "/** See if the fieldName is in the field listStream already.\n * We keep a hash-map cache.\n * */", "String", "fieldName", "=", "getSortableField", "(", "clazz", ")", ";", "/**\n * Not found in cache.\n */", "if", "(", "fieldName", "==", "null", ")", "{", "/* See if we have this sortable field and look for string first. */", "for", "(", "String", "name", ":", "fieldSortNames", ")", "{", "if", "(", "classHasStringField", "(", "clazz", ",", "name", ")", ")", "{", "fieldName", "=", "name", ";", "break", ";", "}", "}", "/*\n Now see if we can find one of our predefined suffixes.\n */", "if", "(", "fieldName", "==", "null", ")", "{", "for", "(", "String", "name", ":", "fieldSortNamesSuffixes", ")", "{", "fieldName", "=", "getFirstStringFieldNameEndsWithFromClass", "(", "clazz", ",", "name", ")", ";", "if", "(", "fieldName", "!=", "null", ")", "{", "break", ";", "}", "}", "}", "/**\n * Ok. We still did not find it so give us the first comparable or\n * primitive that we can find.\n */", "if", "(", "fieldName", "==", "null", ")", "{", "fieldName", "=", "getFirstComparableOrPrimitiveFromClass", "(", "clazz", ")", ";", "}", "/* We could not find a sortable field. */", "if", "(", "fieldName", "==", "null", ")", "{", "setSortableField", "(", "clazz", ",", "\"NOT FOUND\"", ")", ";", "Exceptions", ".", "die", "(", "\"Could not find a sortable field for type \"", "+", "clazz", ")", ";", "}", "/* We found a sortable field. */", "setSortableField", "(", "clazz", ",", "fieldName", ")", ";", "}", "return", "fieldName", ";", "}" ]
Gets the first sortable field. @param clazz the class we are getting the sortable field from. @return sortable field
[ "Gets", "the", "first", "sortable", "field", "." ]
12712d376761aa3b33223a9f1716720ddb67cb5e
https://github.com/advantageous/boon/blob/12712d376761aa3b33223a9f1716720ddb67cb5e/reflekt/src/main/java/io/advantageous/boon/core/reflection/Fields.java#L254-L306
138,770
awin/rabbiteasy
rabbiteasy-cdi/src/main/java/com/zanox/rabbiteasy/cdi/ConnectionConfigurator.java
ConnectionConfigurator.configureFactory
public void configureFactory(Class<?> clazz) { ConnectionConfiguration connectionConfiguration = resolveConnectionConfiguration(clazz); if (connectionConfiguration == null) { return; } connectionFactory.setHost(connectionConfiguration.host()); connectionFactory.setVirtualHost(connectionConfiguration.virtualHost()); connectionFactory.setPort(connectionConfiguration.port()); connectionFactory.setConnectionTimeout(connectionConfiguration.timeout()); connectionFactory.setRequestedHeartbeat(connectionConfiguration.heartbeat()); connectionFactory.setUsername(connectionConfiguration.username()); connectionFactory.setPassword(connectionConfiguration.password()); connectionFactory.setRequestedFrameMax(connectionConfiguration.frameMax()); }
java
public void configureFactory(Class<?> clazz) { ConnectionConfiguration connectionConfiguration = resolveConnectionConfiguration(clazz); if (connectionConfiguration == null) { return; } connectionFactory.setHost(connectionConfiguration.host()); connectionFactory.setVirtualHost(connectionConfiguration.virtualHost()); connectionFactory.setPort(connectionConfiguration.port()); connectionFactory.setConnectionTimeout(connectionConfiguration.timeout()); connectionFactory.setRequestedHeartbeat(connectionConfiguration.heartbeat()); connectionFactory.setUsername(connectionConfiguration.username()); connectionFactory.setPassword(connectionConfiguration.password()); connectionFactory.setRequestedFrameMax(connectionConfiguration.frameMax()); }
[ "public", "void", "configureFactory", "(", "Class", "<", "?", ">", "clazz", ")", "{", "ConnectionConfiguration", "connectionConfiguration", "=", "resolveConnectionConfiguration", "(", "clazz", ")", ";", "if", "(", "connectionConfiguration", "==", "null", ")", "{", "return", ";", "}", "connectionFactory", ".", "setHost", "(", "connectionConfiguration", ".", "host", "(", ")", ")", ";", "connectionFactory", ".", "setVirtualHost", "(", "connectionConfiguration", ".", "virtualHost", "(", ")", ")", ";", "connectionFactory", ".", "setPort", "(", "connectionConfiguration", ".", "port", "(", ")", ")", ";", "connectionFactory", ".", "setConnectionTimeout", "(", "connectionConfiguration", ".", "timeout", "(", ")", ")", ";", "connectionFactory", ".", "setRequestedHeartbeat", "(", "connectionConfiguration", ".", "heartbeat", "(", ")", ")", ";", "connectionFactory", ".", "setUsername", "(", "connectionConfiguration", ".", "username", "(", ")", ")", ";", "connectionFactory", ".", "setPassword", "(", "connectionConfiguration", ".", "password", "(", ")", ")", ";", "connectionFactory", ".", "setRequestedFrameMax", "(", "connectionConfiguration", ".", "frameMax", "(", ")", ")", ";", "}" ]
Configures the connection factory supplied by dependency injection using the connection configuration annotated at the given class. @param clazz The class annotated with the connection configuration.
[ "Configures", "the", "connection", "factory", "supplied", "by", "dependency", "injection", "using", "the", "connection", "configuration", "annotated", "at", "the", "given", "class", "." ]
c161efda6c0f7ef319aedf09dfe40a4a90165510
https://github.com/awin/rabbiteasy/blob/c161efda6c0f7ef319aedf09dfe40a4a90165510/rabbiteasy-cdi/src/main/java/com/zanox/rabbiteasy/cdi/ConnectionConfigurator.java#L25-L38
138,771
advantageous/boon
reflekt/src/main/java/io/advantageous/boon/core/value/ValueMapImpl.java
ValueMapImpl.buildIfNeededMap
private final void buildIfNeededMap() { if ( map == null ) { map = new HashMap<>( items.length ); for ( Entry<String, Value> miv : items ) { if ( miv == null ) { break; } map.put( miv.getKey(), miv.getValue() ); } } }
java
private final void buildIfNeededMap() { if ( map == null ) { map = new HashMap<>( items.length ); for ( Entry<String, Value> miv : items ) { if ( miv == null ) { break; } map.put( miv.getKey(), miv.getValue() ); } } }
[ "private", "final", "void", "buildIfNeededMap", "(", ")", "{", "if", "(", "map", "==", "null", ")", "{", "map", "=", "new", "HashMap", "<>", "(", "items", ".", "length", ")", ";", "for", "(", "Entry", "<", "String", ",", "Value", ">", "miv", ":", "items", ")", "{", "if", "(", "miv", "==", "null", ")", "{", "break", ";", "}", "map", ".", "put", "(", "miv", ".", "getKey", "(", ")", ",", "miv", ".", "getValue", "(", ")", ")", ";", "}", "}", "}" ]
Build the map if requested to, it does this lazily.
[ "Build", "the", "map", "if", "requested", "to", "it", "does", "this", "lazily", "." ]
12712d376761aa3b33223a9f1716720ddb67cb5e
https://github.com/advantageous/boon/blob/12712d376761aa3b33223a9f1716720ddb67cb5e/reflekt/src/main/java/io/advantageous/boon/core/value/ValueMapImpl.java#L126-L137
138,772
advantageous/boon
reflekt/src/main/java/io/advantageous/boon/core/reflection/ClassMeta.java
ClassMeta.respondsTo
public static boolean respondsTo(Object object, String method) { if (object instanceof Class) { return Reflection.respondsTo((Class) object, method); } else { return Reflection.respondsTo(object, method); } }
java
public static boolean respondsTo(Object object, String method) { if (object instanceof Class) { return Reflection.respondsTo((Class) object, method); } else { return Reflection.respondsTo(object, method); } }
[ "public", "static", "boolean", "respondsTo", "(", "Object", "object", ",", "String", "method", ")", "{", "if", "(", "object", "instanceof", "Class", ")", "{", "return", "Reflection", ".", "respondsTo", "(", "(", "Class", ")", "object", ",", "method", ")", ";", "}", "else", "{", "return", "Reflection", ".", "respondsTo", "(", "object", ",", "method", ")", ";", "}", "}" ]
Checks to see if an object responds to a method. Helper facade over Reflection library. @param object object in question @param method method name in question. @return true or false
[ "Checks", "to", "see", "if", "an", "object", "responds", "to", "a", "method", ".", "Helper", "facade", "over", "Reflection", "library", "." ]
12712d376761aa3b33223a9f1716720ddb67cb5e
https://github.com/advantageous/boon/blob/12712d376761aa3b33223a9f1716720ddb67cb5e/reflekt/src/main/java/io/advantageous/boon/core/reflection/ClassMeta.java#L596-L602
138,773
awin/rabbiteasy
rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/MessageWriter.java
MessageWriter.writeBodyFromObject
public <T> void writeBodyFromObject(T bodyAsObject, Charset charset) { @SuppressWarnings("unchecked") Class<T> clazz = (Class<T>)bodyAsObject.getClass(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); Writer outputWriter = new OutputStreamWriter(outputStream, charset); try { Marshaller marshaller = JAXBContext.newInstance(clazz).createMarshaller(); if (clazz.isAnnotationPresent(XmlRootElement.class)) { marshaller.marshal(bodyAsObject, outputWriter); } else { String tagName = unCapitalizedClassName(clazz); JAXBElement<T> element = new JAXBElement<T>(new QName("", tagName), clazz, bodyAsObject); marshaller.marshal(element, outputWriter); } } catch (JAXBException e) { throw new RuntimeException(e); } byte[] bodyContent = outputStream.toByteArray(); message.contentType(Message.APPLICATION_XML) .contentEncoding(charset.name()); message.body(bodyContent); }
java
public <T> void writeBodyFromObject(T bodyAsObject, Charset charset) { @SuppressWarnings("unchecked") Class<T> clazz = (Class<T>)bodyAsObject.getClass(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); Writer outputWriter = new OutputStreamWriter(outputStream, charset); try { Marshaller marshaller = JAXBContext.newInstance(clazz).createMarshaller(); if (clazz.isAnnotationPresent(XmlRootElement.class)) { marshaller.marshal(bodyAsObject, outputWriter); } else { String tagName = unCapitalizedClassName(clazz); JAXBElement<T> element = new JAXBElement<T>(new QName("", tagName), clazz, bodyAsObject); marshaller.marshal(element, outputWriter); } } catch (JAXBException e) { throw new RuntimeException(e); } byte[] bodyContent = outputStream.toByteArray(); message.contentType(Message.APPLICATION_XML) .contentEncoding(charset.name()); message.body(bodyContent); }
[ "public", "<", "T", ">", "void", "writeBodyFromObject", "(", "T", "bodyAsObject", ",", "Charset", "charset", ")", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "Class", "<", "T", ">", "clazz", "=", "(", "Class", "<", "T", ">", ")", "bodyAsObject", ".", "getClass", "(", ")", ";", "ByteArrayOutputStream", "outputStream", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "Writer", "outputWriter", "=", "new", "OutputStreamWriter", "(", "outputStream", ",", "charset", ")", ";", "try", "{", "Marshaller", "marshaller", "=", "JAXBContext", ".", "newInstance", "(", "clazz", ")", ".", "createMarshaller", "(", ")", ";", "if", "(", "clazz", ".", "isAnnotationPresent", "(", "XmlRootElement", ".", "class", ")", ")", "{", "marshaller", ".", "marshal", "(", "bodyAsObject", ",", "outputWriter", ")", ";", "}", "else", "{", "String", "tagName", "=", "unCapitalizedClassName", "(", "clazz", ")", ";", "JAXBElement", "<", "T", ">", "element", "=", "new", "JAXBElement", "<", "T", ">", "(", "new", "QName", "(", "\"\"", ",", "tagName", ")", ",", "clazz", ",", "bodyAsObject", ")", ";", "marshaller", ".", "marshal", "(", "element", ",", "outputWriter", ")", ";", "}", "}", "catch", "(", "JAXBException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "byte", "[", "]", "bodyContent", "=", "outputStream", ".", "toByteArray", "(", ")", ";", "message", ".", "contentType", "(", "Message", ".", "APPLICATION_XML", ")", ".", "contentEncoding", "(", "charset", ".", "name", "(", ")", ")", ";", "message", ".", "body", "(", "bodyContent", ")", ";", "}" ]
Writes the body by serializing the given object to XML. @param bodyAsObject The body as object @param <T> The object type
[ "Writes", "the", "body", "by", "serializing", "the", "given", "object", "to", "XML", "." ]
c161efda6c0f7ef319aedf09dfe40a4a90165510
https://github.com/awin/rabbiteasy/blob/c161efda6c0f7ef319aedf09dfe40a4a90165510/rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/MessageWriter.java#L80-L103
138,774
advantageous/boon
reflekt/src/main/java/io/advantageous/boon/core/Conversions.java
Conversions.toBoolean
public static boolean toBoolean(Object obj, boolean defaultValue) { if (obj == null) { return defaultValue; } if (obj instanceof Boolean) { return ((Boolean) obj).booleanValue(); } else if (obj instanceof Number || obj.getClass().isPrimitive()) { int value = toInt(obj); return value != 0 ? true : false; } else if (obj instanceof Value) { return ((Value) obj).booleanValue(); } else if (obj instanceof String || obj instanceof CharSequence) { String str = Conversions.toString(obj); if (str.length() == 0) { return false; } if (str.equals("false")) { return false; } else { return true; } } else if (isArray(obj)) { return len(obj) > 0; } else if (obj instanceof Collection) { if (len(obj) > 0) { List list = Lists.list((Collection) obj); while (list.remove(null)) { } return Lists.len(list) > 0; } else { return false; } } else { return toBoolean(Conversions.toString(obj)); } }
java
public static boolean toBoolean(Object obj, boolean defaultValue) { if (obj == null) { return defaultValue; } if (obj instanceof Boolean) { return ((Boolean) obj).booleanValue(); } else if (obj instanceof Number || obj.getClass().isPrimitive()) { int value = toInt(obj); return value != 0 ? true : false; } else if (obj instanceof Value) { return ((Value) obj).booleanValue(); } else if (obj instanceof String || obj instanceof CharSequence) { String str = Conversions.toString(obj); if (str.length() == 0) { return false; } if (str.equals("false")) { return false; } else { return true; } } else if (isArray(obj)) { return len(obj) > 0; } else if (obj instanceof Collection) { if (len(obj) > 0) { List list = Lists.list((Collection) obj); while (list.remove(null)) { } return Lists.len(list) > 0; } else { return false; } } else { return toBoolean(Conversions.toString(obj)); } }
[ "public", "static", "boolean", "toBoolean", "(", "Object", "obj", ",", "boolean", "defaultValue", ")", "{", "if", "(", "obj", "==", "null", ")", "{", "return", "defaultValue", ";", "}", "if", "(", "obj", "instanceof", "Boolean", ")", "{", "return", "(", "(", "Boolean", ")", "obj", ")", ".", "booleanValue", "(", ")", ";", "}", "else", "if", "(", "obj", "instanceof", "Number", "||", "obj", ".", "getClass", "(", ")", ".", "isPrimitive", "(", ")", ")", "{", "int", "value", "=", "toInt", "(", "obj", ")", ";", "return", "value", "!=", "0", "?", "true", ":", "false", ";", "}", "else", "if", "(", "obj", "instanceof", "Value", ")", "{", "return", "(", "(", "Value", ")", "obj", ")", ".", "booleanValue", "(", ")", ";", "}", "else", "if", "(", "obj", "instanceof", "String", "||", "obj", "instanceof", "CharSequence", ")", "{", "String", "str", "=", "Conversions", ".", "toString", "(", "obj", ")", ";", "if", "(", "str", ".", "length", "(", ")", "==", "0", ")", "{", "return", "false", ";", "}", "if", "(", "str", ".", "equals", "(", "\"false\"", ")", ")", "{", "return", "false", ";", "}", "else", "{", "return", "true", ";", "}", "}", "else", "if", "(", "isArray", "(", "obj", ")", ")", "{", "return", "len", "(", "obj", ")", ">", "0", ";", "}", "else", "if", "(", "obj", "instanceof", "Collection", ")", "{", "if", "(", "len", "(", "obj", ")", ">", "0", ")", "{", "List", "list", "=", "Lists", ".", "list", "(", "(", "Collection", ")", "obj", ")", ";", "while", "(", "list", ".", "remove", "(", "null", ")", ")", "{", "}", "return", "Lists", ".", "len", "(", "list", ")", ">", "0", ";", "}", "else", "{", "return", "false", ";", "}", "}", "else", "{", "return", "toBoolean", "(", "Conversions", ".", "toString", "(", "obj", ")", ")", ";", "}", "}" ]
Converts the value to boolean, and if it is null, it uses the default value passed. @param obj value to convert to boolean @param defaultValue default value @return obj converted to boolean
[ "Converts", "the", "value", "to", "boolean", "and", "if", "it", "is", "null", "it", "uses", "the", "default", "value", "passed", "." ]
12712d376761aa3b33223a9f1716720ddb67cb5e
https://github.com/advantageous/boon/blob/12712d376761aa3b33223a9f1716720ddb67cb5e/reflekt/src/main/java/io/advantageous/boon/core/Conversions.java#L245-L284
138,775
awin/rabbiteasy
rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/consumer/ConsumerContainer.java
ConsumerContainer.addConsumer
public void addConsumer(Consumer consumer, String queue) { addConsumer(consumer, new ConsumerConfiguration(queue), DEFAULT_AMOUNT_OF_INSTANCES); }
java
public void addConsumer(Consumer consumer, String queue) { addConsumer(consumer, new ConsumerConfiguration(queue), DEFAULT_AMOUNT_OF_INSTANCES); }
[ "public", "void", "addConsumer", "(", "Consumer", "consumer", ",", "String", "queue", ")", "{", "addConsumer", "(", "consumer", ",", "new", "ConsumerConfiguration", "(", "queue", ")", ",", "DEFAULT_AMOUNT_OF_INSTANCES", ")", ";", "}" ]
Adds a consumer to the container and binds it to the given queue with auto acknowledge disabled. Does NOT enable the consumer to consume from the message broker until the container is started. @param consumer The consumer @param queue The queue to bind the consume to
[ "Adds", "a", "consumer", "to", "the", "container", "and", "binds", "it", "to", "the", "given", "queue", "with", "auto", "acknowledge", "disabled", ".", "Does", "NOT", "enable", "the", "consumer", "to", "consume", "from", "the", "message", "broker", "until", "the", "container", "is", "started", "." ]
c161efda6c0f7ef319aedf09dfe40a4a90165510
https://github.com/awin/rabbiteasy/blob/c161efda6c0f7ef319aedf09dfe40a4a90165510/rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/consumer/ConsumerContainer.java#L59-L61
138,776
awin/rabbiteasy
rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/consumer/ConsumerContainer.java
ConsumerContainer.addConsumer
public synchronized void addConsumer(Consumer consumer, ConsumerConfiguration configuration, int instances) { for (int i=0; i < instances; i++) { this.consumerHolders.add(new ConsumerHolder(consumer, configuration)); } }
java
public synchronized void addConsumer(Consumer consumer, ConsumerConfiguration configuration, int instances) { for (int i=0; i < instances; i++) { this.consumerHolders.add(new ConsumerHolder(consumer, configuration)); } }
[ "public", "synchronized", "void", "addConsumer", "(", "Consumer", "consumer", ",", "ConsumerConfiguration", "configuration", ",", "int", "instances", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "instances", ";", "i", "++", ")", "{", "this", ".", "consumerHolders", ".", "add", "(", "new", "ConsumerHolder", "(", "consumer", ",", "configuration", ")", ")", ";", "}", "}" ]
Adds a consumer to the container and configures it according to the consumer configuration. Does NOT enable the consumer to consume from the message broker until the container is started. <p>Registers the same consumer N times at the queue according to the number of specified instances. Use this for scaling your consumers locally. Be aware that the consumer implementation must be stateless or thread safe.</p> @param consumer The consumer @param configuration The consumer configuration @param instances the amount of consumer instances
[ "Adds", "a", "consumer", "to", "the", "container", "and", "configures", "it", "according", "to", "the", "consumer", "configuration", ".", "Does", "NOT", "enable", "the", "consumer", "to", "consume", "from", "the", "message", "broker", "until", "the", "container", "is", "started", "." ]
c161efda6c0f7ef319aedf09dfe40a4a90165510
https://github.com/awin/rabbiteasy/blob/c161efda6c0f7ef319aedf09dfe40a4a90165510/rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/consumer/ConsumerContainer.java#L155-L159
138,777
awin/rabbiteasy
rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/consumer/ConsumerContainer.java
ConsumerContainer.filterConsumersForClass
protected List<ConsumerHolder> filterConsumersForClass(Class<? extends Consumer> consumerClass) { List<ConsumerHolder> consumerHolderSubList = new LinkedList<ConsumerHolder>(); for (ConsumerHolder consumerHolder : consumerHolders) { if (consumerClass.isAssignableFrom(consumerHolder.getConsumer().getClass())) { consumerHolderSubList.add(consumerHolder); } } return consumerHolderSubList; }
java
protected List<ConsumerHolder> filterConsumersForClass(Class<? extends Consumer> consumerClass) { List<ConsumerHolder> consumerHolderSubList = new LinkedList<ConsumerHolder>(); for (ConsumerHolder consumerHolder : consumerHolders) { if (consumerClass.isAssignableFrom(consumerHolder.getConsumer().getClass())) { consumerHolderSubList.add(consumerHolder); } } return consumerHolderSubList; }
[ "protected", "List", "<", "ConsumerHolder", ">", "filterConsumersForClass", "(", "Class", "<", "?", "extends", "Consumer", ">", "consumerClass", ")", "{", "List", "<", "ConsumerHolder", ">", "consumerHolderSubList", "=", "new", "LinkedList", "<", "ConsumerHolder", ">", "(", ")", ";", "for", "(", "ConsumerHolder", "consumerHolder", ":", "consumerHolders", ")", "{", "if", "(", "consumerClass", ".", "isAssignableFrom", "(", "consumerHolder", ".", "getConsumer", "(", ")", ".", "getClass", "(", ")", ")", ")", "{", "consumerHolderSubList", ".", "add", "(", "consumerHolder", ")", ";", "}", "}", "return", "consumerHolderSubList", ";", "}" ]
Filters the consumers being an instance, extending or implementing the given class from the list of managed consumers. @param consumerClass The consumer class @return The filtered consumers
[ "Filters", "the", "consumers", "being", "an", "instance", "extending", "or", "implementing", "the", "given", "class", "from", "the", "list", "of", "managed", "consumers", "." ]
c161efda6c0f7ef319aedf09dfe40a4a90165510
https://github.com/awin/rabbiteasy/blob/c161efda6c0f7ef319aedf09dfe40a4a90165510/rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/consumer/ConsumerContainer.java#L290-L298
138,778
awin/rabbiteasy
rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/consumer/ConsumerContainer.java
ConsumerContainer.filterConsumersForEnabledFlag
protected List<ConsumerHolder> filterConsumersForEnabledFlag(boolean enabled) { List<ConsumerHolder> consumerHolderSubList = new LinkedList<ConsumerHolder>(); for (ConsumerHolder consumerHolder : consumerHolders) { if (consumerHolder.isEnabled() == enabled) { consumerHolderSubList.add(consumerHolder); } } return consumerHolderSubList; }
java
protected List<ConsumerHolder> filterConsumersForEnabledFlag(boolean enabled) { List<ConsumerHolder> consumerHolderSubList = new LinkedList<ConsumerHolder>(); for (ConsumerHolder consumerHolder : consumerHolders) { if (consumerHolder.isEnabled() == enabled) { consumerHolderSubList.add(consumerHolder); } } return consumerHolderSubList; }
[ "protected", "List", "<", "ConsumerHolder", ">", "filterConsumersForEnabledFlag", "(", "boolean", "enabled", ")", "{", "List", "<", "ConsumerHolder", ">", "consumerHolderSubList", "=", "new", "LinkedList", "<", "ConsumerHolder", ">", "(", ")", ";", "for", "(", "ConsumerHolder", "consumerHolder", ":", "consumerHolders", ")", "{", "if", "(", "consumerHolder", ".", "isEnabled", "(", ")", "==", "enabled", ")", "{", "consumerHolderSubList", ".", "add", "(", "consumerHolder", ")", ";", "}", "}", "return", "consumerHolderSubList", ";", "}" ]
Filters the consumers matching the given enabled flag from the list of managed consumers. @param enabled Whether to filter for enabled or disabled consumers @return The filtered consumers
[ "Filters", "the", "consumers", "matching", "the", "given", "enabled", "flag", "from", "the", "list", "of", "managed", "consumers", "." ]
c161efda6c0f7ef319aedf09dfe40a4a90165510
https://github.com/awin/rabbiteasy/blob/c161efda6c0f7ef319aedf09dfe40a4a90165510/rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/consumer/ConsumerContainer.java#L306-L314
138,779
awin/rabbiteasy
rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/consumer/ConsumerContainer.java
ConsumerContainer.filterConsumersForActiveFlag
protected List<ConsumerHolder> filterConsumersForActiveFlag(boolean active) { List<ConsumerHolder> consumerHolderSubList = new LinkedList<ConsumerHolder>(); for (ConsumerHolder consumerHolder : consumerHolders) { if (consumerHolder.isActive() == active) { consumerHolderSubList.add(consumerHolder); } } return consumerHolderSubList; }
java
protected List<ConsumerHolder> filterConsumersForActiveFlag(boolean active) { List<ConsumerHolder> consumerHolderSubList = new LinkedList<ConsumerHolder>(); for (ConsumerHolder consumerHolder : consumerHolders) { if (consumerHolder.isActive() == active) { consumerHolderSubList.add(consumerHolder); } } return consumerHolderSubList; }
[ "protected", "List", "<", "ConsumerHolder", ">", "filterConsumersForActiveFlag", "(", "boolean", "active", ")", "{", "List", "<", "ConsumerHolder", ">", "consumerHolderSubList", "=", "new", "LinkedList", "<", "ConsumerHolder", ">", "(", ")", ";", "for", "(", "ConsumerHolder", "consumerHolder", ":", "consumerHolders", ")", "{", "if", "(", "consumerHolder", ".", "isActive", "(", ")", "==", "active", ")", "{", "consumerHolderSubList", ".", "add", "(", "consumerHolder", ")", ";", "}", "}", "return", "consumerHolderSubList", ";", "}" ]
Filters the consumers matching the given active flag from the list of managed consumers. @param active Whether to filter for active or inactive consumers @return The filtered consumers
[ "Filters", "the", "consumers", "matching", "the", "given", "active", "flag", "from", "the", "list", "of", "managed", "consumers", "." ]
c161efda6c0f7ef319aedf09dfe40a4a90165510
https://github.com/awin/rabbiteasy/blob/c161efda6c0f7ef319aedf09dfe40a4a90165510/rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/consumer/ConsumerContainer.java#L322-L330
138,780
awin/rabbiteasy
rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/consumer/ConsumerContainer.java
ConsumerContainer.enableConsumers
protected void enableConsumers(List<ConsumerHolder> consumerHolders) throws IOException { checkPreconditions(consumerHolders); try { for (ConsumerHolder consumerHolder : consumerHolders) { consumerHolder.enable(); } } catch (IOException e) { LOGGER.error("Failed to enable consumers - disabling already enabled consumers"); disableConsumers(consumerHolders); throw e; } }
java
protected void enableConsumers(List<ConsumerHolder> consumerHolders) throws IOException { checkPreconditions(consumerHolders); try { for (ConsumerHolder consumerHolder : consumerHolders) { consumerHolder.enable(); } } catch (IOException e) { LOGGER.error("Failed to enable consumers - disabling already enabled consumers"); disableConsumers(consumerHolders); throw e; } }
[ "protected", "void", "enableConsumers", "(", "List", "<", "ConsumerHolder", ">", "consumerHolders", ")", "throws", "IOException", "{", "checkPreconditions", "(", "consumerHolders", ")", ";", "try", "{", "for", "(", "ConsumerHolder", "consumerHolder", ":", "consumerHolders", ")", "{", "consumerHolder", ".", "enable", "(", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "LOGGER", ".", "error", "(", "\"Failed to enable consumers - disabling already enabled consumers\"", ")", ";", "disableConsumers", "(", "consumerHolders", ")", ";", "throw", "e", ";", "}", "}" ]
Enables all consumers in the given list and hands them over for activation afterwards. @param consumerHolders The consumers to enable @throws IOException if the activation process fails for a consumer
[ "Enables", "all", "consumers", "in", "the", "given", "list", "and", "hands", "them", "over", "for", "activation", "afterwards", "." ]
c161efda6c0f7ef319aedf09dfe40a4a90165510
https://github.com/awin/rabbiteasy/blob/c161efda6c0f7ef319aedf09dfe40a4a90165510/rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/consumer/ConsumerContainer.java#L338-L349
138,781
awin/rabbiteasy
rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/consumer/ConsumerContainer.java
ConsumerContainer.activateConsumers
protected void activateConsumers(List<ConsumerHolder> consumerHolders) throws IOException { synchronized (activationMonitor) { for (ConsumerHolder consumerHolder : consumerHolders) { try { consumerHolder.activate(); } catch (IOException e) { LOGGER.error("Failed to activate consumer - deactivating already activated consumers"); deactivateConsumers(consumerHolders); throw e; } } } }
java
protected void activateConsumers(List<ConsumerHolder> consumerHolders) throws IOException { synchronized (activationMonitor) { for (ConsumerHolder consumerHolder : consumerHolders) { try { consumerHolder.activate(); } catch (IOException e) { LOGGER.error("Failed to activate consumer - deactivating already activated consumers"); deactivateConsumers(consumerHolders); throw e; } } } }
[ "protected", "void", "activateConsumers", "(", "List", "<", "ConsumerHolder", ">", "consumerHolders", ")", "throws", "IOException", "{", "synchronized", "(", "activationMonitor", ")", "{", "for", "(", "ConsumerHolder", "consumerHolder", ":", "consumerHolders", ")", "{", "try", "{", "consumerHolder", ".", "activate", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "LOGGER", ".", "error", "(", "\"Failed to activate consumer - deactivating already activated consumers\"", ")", ";", "deactivateConsumers", "(", "consumerHolders", ")", ";", "throw", "e", ";", "}", "}", "}", "}" ]
Activates all consumers in the given list. @param consumerHolders The list of consumers to activate @throws IOException if the activation process fails for a consumer
[ "Activates", "all", "consumers", "in", "the", "given", "list", "." ]
c161efda6c0f7ef319aedf09dfe40a4a90165510
https://github.com/awin/rabbiteasy/blob/c161efda6c0f7ef319aedf09dfe40a4a90165510/rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/consumer/ConsumerContainer.java#L368-L380
138,782
awin/rabbiteasy
rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/consumer/ConsumerContainer.java
ConsumerContainer.deactivateConsumers
protected void deactivateConsumers(List<ConsumerHolder> consumerHolders) { synchronized (activationMonitor) { for (ConsumerHolder consumerHolder : consumerHolders) { consumerHolder.deactivate(); } } }
java
protected void deactivateConsumers(List<ConsumerHolder> consumerHolders) { synchronized (activationMonitor) { for (ConsumerHolder consumerHolder : consumerHolders) { consumerHolder.deactivate(); } } }
[ "protected", "void", "deactivateConsumers", "(", "List", "<", "ConsumerHolder", ">", "consumerHolders", ")", "{", "synchronized", "(", "activationMonitor", ")", "{", "for", "(", "ConsumerHolder", "consumerHolder", ":", "consumerHolders", ")", "{", "consumerHolder", ".", "deactivate", "(", ")", ";", "}", "}", "}" ]
Deactivates all consumers in the given list. @param consumerHolders The list of consumers to deactivate.
[ "Deactivates", "all", "consumers", "in", "the", "given", "list", "." ]
c161efda6c0f7ef319aedf09dfe40a4a90165510
https://github.com/awin/rabbiteasy/blob/c161efda6c0f7ef319aedf09dfe40a4a90165510/rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/consumer/ConsumerContainer.java#L387-L393
138,783
awin/rabbiteasy
rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/consumer/ConsumerContainer.java
ConsumerContainer.checkPreconditions
protected void checkPreconditions(List<ConsumerHolder> consumerHolders) throws IOException { Channel channel = createChannel(); for (ConsumerHolder consumerHolder : consumerHolders) { String queue = consumerHolder.getConfiguration().getQueueName(); try { channel.queueDeclarePassive(queue); LOGGER.debug("Queue {} found on broker", queue); } catch (IOException e) { LOGGER.error("Queue {} not found on broker", queue); throw e; } } channel.close(); }
java
protected void checkPreconditions(List<ConsumerHolder> consumerHolders) throws IOException { Channel channel = createChannel(); for (ConsumerHolder consumerHolder : consumerHolders) { String queue = consumerHolder.getConfiguration().getQueueName(); try { channel.queueDeclarePassive(queue); LOGGER.debug("Queue {} found on broker", queue); } catch (IOException e) { LOGGER.error("Queue {} not found on broker", queue); throw e; } } channel.close(); }
[ "protected", "void", "checkPreconditions", "(", "List", "<", "ConsumerHolder", ">", "consumerHolders", ")", "throws", "IOException", "{", "Channel", "channel", "=", "createChannel", "(", ")", ";", "for", "(", "ConsumerHolder", "consumerHolder", ":", "consumerHolders", ")", "{", "String", "queue", "=", "consumerHolder", ".", "getConfiguration", "(", ")", ".", "getQueueName", "(", ")", ";", "try", "{", "channel", ".", "queueDeclarePassive", "(", "queue", ")", ";", "LOGGER", ".", "debug", "(", "\"Queue {} found on broker\"", ",", "queue", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "LOGGER", ".", "error", "(", "\"Queue {} not found on broker\"", ",", "queue", ")", ";", "throw", "e", ";", "}", "}", "channel", ".", "close", "(", ")", ";", "}" ]
Checks if all preconditions are fulfilled on the broker to successfully register a consumer there. One important precondition is the existence of the queue the consumer shall consume from. @param consumerHolders The consumer holders @throws IOException if the precondition check fails
[ "Checks", "if", "all", "preconditions", "are", "fulfilled", "on", "the", "broker", "to", "successfully", "register", "a", "consumer", "there", ".", "One", "important", "precondition", "is", "the", "existence", "of", "the", "queue", "the", "consumer", "shall", "consume", "from", "." ]
c161efda6c0f7ef319aedf09dfe40a4a90165510
https://github.com/awin/rabbiteasy/blob/c161efda6c0f7ef319aedf09dfe40a4a90165510/rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/consumer/ConsumerContainer.java#L403-L416
138,784
awin/rabbiteasy
rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/consumer/ConsumerContainer.java
ConsumerContainer.createChannel
protected Channel createChannel() throws IOException { LOGGER.debug("Creating channel"); Connection connection = connectionFactory.newConnection(); Channel channel = connection.createChannel(); LOGGER.debug("Created channel"); return channel; }
java
protected Channel createChannel() throws IOException { LOGGER.debug("Creating channel"); Connection connection = connectionFactory.newConnection(); Channel channel = connection.createChannel(); LOGGER.debug("Created channel"); return channel; }
[ "protected", "Channel", "createChannel", "(", ")", "throws", "IOException", "{", "LOGGER", ".", "debug", "(", "\"Creating channel\"", ")", ";", "Connection", "connection", "=", "connectionFactory", ".", "newConnection", "(", ")", ";", "Channel", "channel", "=", "connection", ".", "createChannel", "(", ")", ";", "LOGGER", ".", "debug", "(", "\"Created channel\"", ")", ";", "return", "channel", ";", "}" ]
Creates a channel to be used for consuming from the broker. @return The channel @throws IOException if the channel cannot be created due to a connection problem
[ "Creates", "a", "channel", "to", "be", "used", "for", "consuming", "from", "the", "broker", "." ]
c161efda6c0f7ef319aedf09dfe40a4a90165510
https://github.com/awin/rabbiteasy/blob/c161efda6c0f7ef319aedf09dfe40a4a90165510/rabbiteasy-core/src/main/java/com/zanox/rabbiteasy/consumer/ConsumerContainer.java#L425-L431
138,785
advantageous/boon
reflekt/src/main/java/io/advantageous/boon/primitive/ReaderCharacterSource.java
ReaderCharacterSource.findNextChar
public final char[] findNextChar( boolean inMiddleOfString, boolean wasEscapeChar, int match, int esc ) { try{ ensureBuffer(); //grow the buffer and read in if needed int idx = index; char[] _chars = readBuf; int length = this.length; int ch = this.ch; if ( !inMiddleOfString ) { foundEscape=false; if ( ch == match ) { //we can start with a match but we // ignore it if we are not in the middle of a string. } else if ( idx < length -1 ) { ch = _chars[idx]; if (ch == match ) { idx++; } } } if ( idx < length ) { ch = _chars[idx]; } /* Detect an empty string and then leave unless we came into this method in the escape state.. */ if (ch == '"' && !wasEscapeChar) { index = idx; index++; return EMPTY_CHARS; } int start = idx; if (wasEscapeChar) { idx++; } boolean foundEnd = false; //Have we actually found the end of the string? char [] results ; //The results so far might be the whole thing if we found the end. boolean _foundEscape = false; /* Iterate through the buffer looking for the match which is the close quote most likely. */ while (true) { ch = _chars[idx]; /* If we found the close quote " or the escape character \ */ if ( ch == match || ch == esc ) { if ( ch == match ) { foundEnd = true; break; } else if ( ch == esc ) { wasEscapeChar = true; _foundEscape = true; /** if we are dealing with an escape then see if the escaped char is a match * if so, skip it. */ if ( idx + 1 < length) { wasEscapeChar=false; //this denotes if we were able to skip because // if we were not then the next method in the recursion has to if we don't find the end. idx++; } } } if ( idx >= length) break; idx++; } foundEscape = _foundEscape; /* After all that, we still might have an empty string! */ if (idx == 0 ) { results = EMPTY_CHARS; } else { results = Arrays.copyOfRange ( _chars, start, idx ); } // At this point we have some results but it might not be all of the results if we did not // find the close '"' (match) index = idx; /* We found everthing so make like a tree and leave. */ if (foundEnd) { index++; if (index < length) { ch = _chars[index ]; this.ch = ch; } return results; /* We did not find everything so prepare for the next buffer read. */ } else { /* Detect if we have more buffers to read. */ if (index >= length && !done) { /*If we have more to read then read it. */ ensureBuffer(); /* Recursively call this method. */ char results2[] = findNextChar(true, wasEscapeChar, match, esc); return Chr.add(results, results2); } else { return Exceptions.die(char[].class, "Unable to find close char " + (char) match + " " + new String(results)); } } } catch (Exception ex ) { String str = CharScanner.errorDetails ( "findNextChar issue", readBuf, index, ch ); return Exceptions.handle ( char[].class, str, ex ); } }
java
public final char[] findNextChar( boolean inMiddleOfString, boolean wasEscapeChar, int match, int esc ) { try{ ensureBuffer(); //grow the buffer and read in if needed int idx = index; char[] _chars = readBuf; int length = this.length; int ch = this.ch; if ( !inMiddleOfString ) { foundEscape=false; if ( ch == match ) { //we can start with a match but we // ignore it if we are not in the middle of a string. } else if ( idx < length -1 ) { ch = _chars[idx]; if (ch == match ) { idx++; } } } if ( idx < length ) { ch = _chars[idx]; } /* Detect an empty string and then leave unless we came into this method in the escape state.. */ if (ch == '"' && !wasEscapeChar) { index = idx; index++; return EMPTY_CHARS; } int start = idx; if (wasEscapeChar) { idx++; } boolean foundEnd = false; //Have we actually found the end of the string? char [] results ; //The results so far might be the whole thing if we found the end. boolean _foundEscape = false; /* Iterate through the buffer looking for the match which is the close quote most likely. */ while (true) { ch = _chars[idx]; /* If we found the close quote " or the escape character \ */ if ( ch == match || ch == esc ) { if ( ch == match ) { foundEnd = true; break; } else if ( ch == esc ) { wasEscapeChar = true; _foundEscape = true; /** if we are dealing with an escape then see if the escaped char is a match * if so, skip it. */ if ( idx + 1 < length) { wasEscapeChar=false; //this denotes if we were able to skip because // if we were not then the next method in the recursion has to if we don't find the end. idx++; } } } if ( idx >= length) break; idx++; } foundEscape = _foundEscape; /* After all that, we still might have an empty string! */ if (idx == 0 ) { results = EMPTY_CHARS; } else { results = Arrays.copyOfRange ( _chars, start, idx ); } // At this point we have some results but it might not be all of the results if we did not // find the close '"' (match) index = idx; /* We found everthing so make like a tree and leave. */ if (foundEnd) { index++; if (index < length) { ch = _chars[index ]; this.ch = ch; } return results; /* We did not find everything so prepare for the next buffer read. */ } else { /* Detect if we have more buffers to read. */ if (index >= length && !done) { /*If we have more to read then read it. */ ensureBuffer(); /* Recursively call this method. */ char results2[] = findNextChar(true, wasEscapeChar, match, esc); return Chr.add(results, results2); } else { return Exceptions.die(char[].class, "Unable to find close char " + (char) match + " " + new String(results)); } } } catch (Exception ex ) { String str = CharScanner.errorDetails ( "findNextChar issue", readBuf, index, ch ); return Exceptions.handle ( char[].class, str, ex ); } }
[ "public", "final", "char", "[", "]", "findNextChar", "(", "boolean", "inMiddleOfString", ",", "boolean", "wasEscapeChar", ",", "int", "match", ",", "int", "esc", ")", "{", "try", "{", "ensureBuffer", "(", ")", ";", "//grow the buffer and read in if needed", "int", "idx", "=", "index", ";", "char", "[", "]", "_chars", "=", "readBuf", ";", "int", "length", "=", "this", ".", "length", ";", "int", "ch", "=", "this", ".", "ch", ";", "if", "(", "!", "inMiddleOfString", ")", "{", "foundEscape", "=", "false", ";", "if", "(", "ch", "==", "match", ")", "{", "//we can start with a match but we", "// ignore it if we are not in the middle of a string.", "}", "else", "if", "(", "idx", "<", "length", "-", "1", ")", "{", "ch", "=", "_chars", "[", "idx", "]", ";", "if", "(", "ch", "==", "match", ")", "{", "idx", "++", ";", "}", "}", "}", "if", "(", "idx", "<", "length", ")", "{", "ch", "=", "_chars", "[", "idx", "]", ";", "}", "/* Detect an empty string and then leave unless we came into this method in the escape state.. */", "if", "(", "ch", "==", "'", "'", "&&", "!", "wasEscapeChar", ")", "{", "index", "=", "idx", ";", "index", "++", ";", "return", "EMPTY_CHARS", ";", "}", "int", "start", "=", "idx", ";", "if", "(", "wasEscapeChar", ")", "{", "idx", "++", ";", "}", "boolean", "foundEnd", "=", "false", ";", "//Have we actually found the end of the string?", "char", "[", "]", "results", ";", "//The results so far might be the whole thing if we found the end.", "boolean", "_foundEscape", "=", "false", ";", "/* Iterate through the buffer looking for the match which is the close quote most likely. */", "while", "(", "true", ")", "{", "ch", "=", "_chars", "[", "idx", "]", ";", "/* If we found the close quote \" or the escape character \\ */", "if", "(", "ch", "==", "match", "||", "ch", "==", "esc", ")", "{", "if", "(", "ch", "==", "match", ")", "{", "foundEnd", "=", "true", ";", "break", ";", "}", "else", "if", "(", "ch", "==", "esc", ")", "{", "wasEscapeChar", "=", "true", ";", "_foundEscape", "=", "true", ";", "/** if we are dealing with an escape then see if the escaped char is a match\n * if so, skip it.\n */", "if", "(", "idx", "+", "1", "<", "length", ")", "{", "wasEscapeChar", "=", "false", ";", "//this denotes if we were able to skip because", "// if we were not then the next method in the recursion has to if we don't find the end.", "idx", "++", ";", "}", "}", "}", "if", "(", "idx", ">=", "length", ")", "break", ";", "idx", "++", ";", "}", "foundEscape", "=", "_foundEscape", ";", "/* After all that, we still might have an empty string! */", "if", "(", "idx", "==", "0", ")", "{", "results", "=", "EMPTY_CHARS", ";", "}", "else", "{", "results", "=", "Arrays", ".", "copyOfRange", "(", "_chars", ",", "start", ",", "idx", ")", ";", "}", "// At this point we have some results but it might not be all of the results if we did not", "// find the close '\"' (match)", "index", "=", "idx", ";", "/* We found everthing so make like a tree and leave. */", "if", "(", "foundEnd", ")", "{", "index", "++", ";", "if", "(", "index", "<", "length", ")", "{", "ch", "=", "_chars", "[", "index", "]", ";", "this", ".", "ch", "=", "ch", ";", "}", "return", "results", ";", "/* We did not find everything so prepare for the next buffer read. */", "}", "else", "{", "/* Detect if we have more buffers to read. */", "if", "(", "index", ">=", "length", "&&", "!", "done", ")", "{", "/*If we have more to read then read it. */", "ensureBuffer", "(", ")", ";", "/* Recursively call this method. */", "char", "results2", "[", "]", "=", "findNextChar", "(", "true", ",", "wasEscapeChar", ",", "match", ",", "esc", ")", ";", "return", "Chr", ".", "add", "(", "results", ",", "results2", ")", ";", "}", "else", "{", "return", "Exceptions", ".", "die", "(", "char", "[", "]", ".", "class", ",", "\"Unable to find close char \"", "+", "(", "char", ")", "match", "+", "\" \"", "+", "new", "String", "(", "results", ")", ")", ";", "}", "}", "}", "catch", "(", "Exception", "ex", ")", "{", "String", "str", "=", "CharScanner", ".", "errorDetails", "(", "\"findNextChar issue\"", ",", "readBuf", ",", "index", ",", "ch", ")", ";", "return", "Exceptions", ".", "handle", "(", "char", "[", "]", ".", "class", ",", "str", ",", "ex", ")", ";", "}", "}" ]
Remember that this must work past buffer reader boundaries so we need to keep track where we were in the nested run. If we start with match then we skip to the the next match. @param inMiddleOfString In the middle of a string. @param wasEscapeChar If we were called before (recursion), where we in the escape character state. @param match The match char is usually '"' @param esc The escape char is usually '\' @return the string from the next char.
[ "Remember", "that", "this", "must", "work", "past", "buffer", "reader", "boundaries", "so", "we", "need", "to", "keep", "track", "where", "we", "were", "in", "the", "nested", "run", "." ]
12712d376761aa3b33223a9f1716720ddb67cb5e
https://github.com/advantageous/boon/blob/12712d376761aa3b33223a9f1716720ddb67cb5e/reflekt/src/main/java/io/advantageous/boon/primitive/ReaderCharacterSource.java#L208-L332
138,786
advantageous/boon
util/src/main/java/io/advantageous/boon/collections/FloatList.java
FloatList.addArray
public boolean addArray(float... values) { if (end + values.length >= this.values.length) { this.values = grow(this.values, (this.values.length + values.length) * 2); } System.arraycopy(values, 0, this.values, end, values.length); end += values.length; return true; }
java
public boolean addArray(float... values) { if (end + values.length >= this.values.length) { this.values = grow(this.values, (this.values.length + values.length) * 2); } System.arraycopy(values, 0, this.values, end, values.length); end += values.length; return true; }
[ "public", "boolean", "addArray", "(", "float", "...", "values", ")", "{", "if", "(", "end", "+", "values", ".", "length", ">=", "this", ".", "values", ".", "length", ")", "{", "this", ".", "values", "=", "grow", "(", "this", ".", "values", ",", "(", "this", ".", "values", ".", "length", "+", "values", ".", "length", ")", "*", "2", ")", ";", "}", "System", ".", "arraycopy", "(", "values", ",", "0", ",", "this", ".", "values", ",", "end", ",", "values", ".", "length", ")", ";", "end", "+=", "values", ".", "length", ";", "return", "true", ";", "}" ]
Add a new array to the list. @param values values @return was able to add.
[ "Add", "a", "new", "array", "to", "the", "list", "." ]
12712d376761aa3b33223a9f1716720ddb67cb5e
https://github.com/advantageous/boon/blob/12712d376761aa3b33223a9f1716720ddb67cb5e/util/src/main/java/io/advantageous/boon/collections/FloatList.java#L221-L229
138,787
advantageous/boon
reflekt/src/main/java/io/advantageous/boon/core/reflection/Annotations.java
Annotations.getPropertyDescriptor
private static PropertyDescriptor getPropertyDescriptor( final Class<?> type, final String propertyName ) { Exceptions.requireNonNull(type); Exceptions.requireNonNull(propertyName); if ( !propertyName.contains( "." ) ) { return doGetPropertyDescriptor( type, propertyName ); } else { String[] propertyNames = propertyName.split( "[.]" ); Class<?> clazz = type; PropertyDescriptor propertyDescriptor = null; for ( String pName : propertyNames ) { propertyDescriptor = doGetPropertyDescriptor( clazz, pName ); if ( propertyDescriptor == null ) { return null; } clazz = propertyDescriptor.getPropertyType(); } return propertyDescriptor; } }
java
private static PropertyDescriptor getPropertyDescriptor( final Class<?> type, final String propertyName ) { Exceptions.requireNonNull(type); Exceptions.requireNonNull(propertyName); if ( !propertyName.contains( "." ) ) { return doGetPropertyDescriptor( type, propertyName ); } else { String[] propertyNames = propertyName.split( "[.]" ); Class<?> clazz = type; PropertyDescriptor propertyDescriptor = null; for ( String pName : propertyNames ) { propertyDescriptor = doGetPropertyDescriptor( clazz, pName ); if ( propertyDescriptor == null ) { return null; } clazz = propertyDescriptor.getPropertyType(); } return propertyDescriptor; } }
[ "private", "static", "PropertyDescriptor", "getPropertyDescriptor", "(", "final", "Class", "<", "?", ">", "type", ",", "final", "String", "propertyName", ")", "{", "Exceptions", ".", "requireNonNull", "(", "type", ")", ";", "Exceptions", ".", "requireNonNull", "(", "propertyName", ")", ";", "if", "(", "!", "propertyName", ".", "contains", "(", "\".\"", ")", ")", "{", "return", "doGetPropertyDescriptor", "(", "type", ",", "propertyName", ")", ";", "}", "else", "{", "String", "[", "]", "propertyNames", "=", "propertyName", ".", "split", "(", "\"[.]\"", ")", ";", "Class", "<", "?", ">", "clazz", "=", "type", ";", "PropertyDescriptor", "propertyDescriptor", "=", "null", ";", "for", "(", "String", "pName", ":", "propertyNames", ")", "{", "propertyDescriptor", "=", "doGetPropertyDescriptor", "(", "clazz", ",", "pName", ")", ";", "if", "(", "propertyDescriptor", "==", "null", ")", "{", "return", "null", ";", "}", "clazz", "=", "propertyDescriptor", ".", "getPropertyType", "(", ")", ";", "}", "return", "propertyDescriptor", ";", "}", "}" ]
This needs refactor and put into Refleciton.
[ "This", "needs", "refactor", "and", "put", "into", "Refleciton", "." ]
12712d376761aa3b33223a9f1716720ddb67cb5e
https://github.com/advantageous/boon/blob/12712d376761aa3b33223a9f1716720ddb67cb5e/reflekt/src/main/java/io/advantageous/boon/core/reflection/Annotations.java#L359-L379
138,788
caprica/vlcj-info
src/main/java/uk/co/caprica/vlcjinfo/MediaInfoFile.java
MediaInfoFile.open
public boolean open() { LibMediaInfo lib = LibMediaInfo.INSTANCE; handle = lib.MediaInfo_New(); if (handle != null) { int opened = lib.MediaInfo_Open(handle, new WString(filename)); if (opened == 1) { return true; } else { lib.MediaInfo_Delete(handle); } } return false; }
java
public boolean open() { LibMediaInfo lib = LibMediaInfo.INSTANCE; handle = lib.MediaInfo_New(); if (handle != null) { int opened = lib.MediaInfo_Open(handle, new WString(filename)); if (opened == 1) { return true; } else { lib.MediaInfo_Delete(handle); } } return false; }
[ "public", "boolean", "open", "(", ")", "{", "LibMediaInfo", "lib", "=", "LibMediaInfo", ".", "INSTANCE", ";", "handle", "=", "lib", ".", "MediaInfo_New", "(", ")", ";", "if", "(", "handle", "!=", "null", ")", "{", "int", "opened", "=", "lib", ".", "MediaInfo_Open", "(", "handle", ",", "new", "WString", "(", "filename", ")", ")", ";", "if", "(", "opened", "==", "1", ")", "{", "return", "true", ";", "}", "else", "{", "lib", ".", "MediaInfo_Delete", "(", "handle", ")", ";", "}", "}", "return", "false", ";", "}" ]
Open the media file. @return <code>true</code> if the file was opened successfully; <code>false</code> if it was not
[ "Open", "the", "media", "file", "." ]
a13c9242bcab4b98b66acc3969a05a95504451fa
https://github.com/caprica/vlcj-info/blob/a13c9242bcab4b98b66acc3969a05a95504451fa/src/main/java/uk/co/caprica/vlcjinfo/MediaInfoFile.java#L49-L61
138,789
caprica/vlcj-info
src/main/java/uk/co/caprica/vlcjinfo/MediaInfoFile.java
MediaInfoFile.close
public void close() { if (handle != null) { LibMediaInfo.INSTANCE.MediaInfo_Close(handle); LibMediaInfo.INSTANCE.MediaInfo_Delete(handle); } }
java
public void close() { if (handle != null) { LibMediaInfo.INSTANCE.MediaInfo_Close(handle); LibMediaInfo.INSTANCE.MediaInfo_Delete(handle); } }
[ "public", "void", "close", "(", ")", "{", "if", "(", "handle", "!=", "null", ")", "{", "LibMediaInfo", ".", "INSTANCE", ".", "MediaInfo_Close", "(", "handle", ")", ";", "LibMediaInfo", ".", "INSTANCE", ".", "MediaInfo_Delete", "(", "handle", ")", ";", "}", "}" ]
Close the media file.
[ "Close", "the", "media", "file", "." ]
a13c9242bcab4b98b66acc3969a05a95504451fa
https://github.com/caprica/vlcj-info/blob/a13c9242bcab4b98b66acc3969a05a95504451fa/src/main/java/uk/co/caprica/vlcjinfo/MediaInfoFile.java#L84-L89
138,790
caprica/vlcj-info
src/main/java/uk/co/caprica/vlcjinfo/Parser.java
Parser.parse
MediaInfo parse() { try { BufferedReader reader = new BufferedReader(new StringReader(data)); MediaInfo mediaInfo = new MediaInfo(); String sectionName; String line; Sections sections; Section section = null; while (parseState != ParseState.FINISHED) { switch (parseState) { case DEFAULT: parseState = ParseState.NEXT_SECTION; break; case NEXT_SECTION: sectionName = reader.readLine(); if (sectionName == null) { parseState = ParseState.FINISHED; } else if (sectionName.length() > 0) { parseState = ParseState.SECTION; sections = mediaInfo.sections(sectionName); section = sections.newSection(); } break; case SECTION: line = reader.readLine(); if (line == null) { parseState = ParseState.FINISHED; } else if (line.length() == 0) { parseState = ParseState.NEXT_SECTION; } else { String[] values = line.split(":", 2); section.put(values[0].trim(), values[1].trim()); } break; default: throw new IllegalStateException(); } } return mediaInfo; } catch (IOException e) { throw new MediaInfoParseException("Failed to parse media info", e); } }
java
MediaInfo parse() { try { BufferedReader reader = new BufferedReader(new StringReader(data)); MediaInfo mediaInfo = new MediaInfo(); String sectionName; String line; Sections sections; Section section = null; while (parseState != ParseState.FINISHED) { switch (parseState) { case DEFAULT: parseState = ParseState.NEXT_SECTION; break; case NEXT_SECTION: sectionName = reader.readLine(); if (sectionName == null) { parseState = ParseState.FINISHED; } else if (sectionName.length() > 0) { parseState = ParseState.SECTION; sections = mediaInfo.sections(sectionName); section = sections.newSection(); } break; case SECTION: line = reader.readLine(); if (line == null) { parseState = ParseState.FINISHED; } else if (line.length() == 0) { parseState = ParseState.NEXT_SECTION; } else { String[] values = line.split(":", 2); section.put(values[0].trim(), values[1].trim()); } break; default: throw new IllegalStateException(); } } return mediaInfo; } catch (IOException e) { throw new MediaInfoParseException("Failed to parse media info", e); } }
[ "MediaInfo", "parse", "(", ")", "{", "try", "{", "BufferedReader", "reader", "=", "new", "BufferedReader", "(", "new", "StringReader", "(", "data", ")", ")", ";", "MediaInfo", "mediaInfo", "=", "new", "MediaInfo", "(", ")", ";", "String", "sectionName", ";", "String", "line", ";", "Sections", "sections", ";", "Section", "section", "=", "null", ";", "while", "(", "parseState", "!=", "ParseState", ".", "FINISHED", ")", "{", "switch", "(", "parseState", ")", "{", "case", "DEFAULT", ":", "parseState", "=", "ParseState", ".", "NEXT_SECTION", ";", "break", ";", "case", "NEXT_SECTION", ":", "sectionName", "=", "reader", ".", "readLine", "(", ")", ";", "if", "(", "sectionName", "==", "null", ")", "{", "parseState", "=", "ParseState", ".", "FINISHED", ";", "}", "else", "if", "(", "sectionName", ".", "length", "(", ")", ">", "0", ")", "{", "parseState", "=", "ParseState", ".", "SECTION", ";", "sections", "=", "mediaInfo", ".", "sections", "(", "sectionName", ")", ";", "section", "=", "sections", ".", "newSection", "(", ")", ";", "}", "break", ";", "case", "SECTION", ":", "line", "=", "reader", ".", "readLine", "(", ")", ";", "if", "(", "line", "==", "null", ")", "{", "parseState", "=", "ParseState", ".", "FINISHED", ";", "}", "else", "if", "(", "line", ".", "length", "(", ")", "==", "0", ")", "{", "parseState", "=", "ParseState", ".", "NEXT_SECTION", ";", "}", "else", "{", "String", "[", "]", "values", "=", "line", ".", "split", "(", "\":\"", ",", "2", ")", ";", "section", ".", "put", "(", "values", "[", "0", "]", ".", "trim", "(", ")", ",", "values", "[", "1", "]", ".", "trim", "(", ")", ")", ";", "}", "break", ";", "default", ":", "throw", "new", "IllegalStateException", "(", ")", ";", "}", "}", "return", "mediaInfo", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "MediaInfoParseException", "(", "\"Failed to parse media info\"", ",", "e", ")", ";", "}", "}" ]
Parse the raw data. @return parsed media information
[ "Parse", "the", "raw", "data", "." ]
a13c9242bcab4b98b66acc3969a05a95504451fa
https://github.com/caprica/vlcj-info/blob/a13c9242bcab4b98b66acc3969a05a95504451fa/src/main/java/uk/co/caprica/vlcjinfo/Parser.java#L65-L111
138,791
JorgeCastilloPrz/ExpandablePanel
library/src/main/java/com/jorgecastilloprz/expandablepanel/ExpandablePanelView.java
ExpandablePanelView.checkChildrenCount
private void checkChildrenCount() { if (getChildCount() != 2) Log.e(getResources().getString(R.string.tag), getResources().getString(R.string.wrong_number_children_error)); }
java
private void checkChildrenCount() { if (getChildCount() != 2) Log.e(getResources().getString(R.string.tag), getResources().getString(R.string.wrong_number_children_error)); }
[ "private", "void", "checkChildrenCount", "(", ")", "{", "if", "(", "getChildCount", "(", ")", "!=", "2", ")", "Log", ".", "e", "(", "getResources", "(", ")", ".", "getString", "(", "R", ".", "string", ".", "tag", ")", ",", "getResources", "(", ")", ".", "getString", "(", "R", ".", "string", ".", "wrong_number_children_error", ")", ")", ";", "}" ]
Checks if children number is correct and logs an error if it is not
[ "Checks", "if", "children", "number", "is", "correct", "and", "logs", "an", "error", "if", "it", "is", "not" ]
12d7aca47599a80c2dadc6d0f56ff4dcd790926a
https://github.com/JorgeCastilloPrz/ExpandablePanel/blob/12d7aca47599a80c2dadc6d0f56ff4dcd790926a/library/src/main/java/com/jorgecastilloprz/expandablepanel/ExpandablePanelView.java#L141-L144
138,792
caprica/vlcj-info
src/main/java/uk/co/caprica/vlcjinfo/MediaInfo.java
MediaInfo.mediaInfo
public static MediaInfo mediaInfo(String filename) { MediaInfo result; LibMediaInfo lib = LibMediaInfo.INSTANCE; Pointer handle = lib.MediaInfo_New(); if (handle != null) { try { int opened = lib.MediaInfo_Open(handle, new WString(filename)); if (opened == 1) { WString data = lib.MediaInfo_Inform(handle); lib.MediaInfo_Close(handle); result = new Parser(data.toString()).parse(); } else { result = null; } } finally { lib.MediaInfo_Delete(handle); } } else { result = null; } return result; }
java
public static MediaInfo mediaInfo(String filename) { MediaInfo result; LibMediaInfo lib = LibMediaInfo.INSTANCE; Pointer handle = lib.MediaInfo_New(); if (handle != null) { try { int opened = lib.MediaInfo_Open(handle, new WString(filename)); if (opened == 1) { WString data = lib.MediaInfo_Inform(handle); lib.MediaInfo_Close(handle); result = new Parser(data.toString()).parse(); } else { result = null; } } finally { lib.MediaInfo_Delete(handle); } } else { result = null; } return result; }
[ "public", "static", "MediaInfo", "mediaInfo", "(", "String", "filename", ")", "{", "MediaInfo", "result", ";", "LibMediaInfo", "lib", "=", "LibMediaInfo", ".", "INSTANCE", ";", "Pointer", "handle", "=", "lib", ".", "MediaInfo_New", "(", ")", ";", "if", "(", "handle", "!=", "null", ")", "{", "try", "{", "int", "opened", "=", "lib", ".", "MediaInfo_Open", "(", "handle", ",", "new", "WString", "(", "filename", ")", ")", ";", "if", "(", "opened", "==", "1", ")", "{", "WString", "data", "=", "lib", ".", "MediaInfo_Inform", "(", "handle", ")", ";", "lib", ".", "MediaInfo_Close", "(", "handle", ")", ";", "result", "=", "new", "Parser", "(", "data", ".", "toString", "(", ")", ")", ".", "parse", "(", ")", ";", "}", "else", "{", "result", "=", "null", ";", "}", "}", "finally", "{", "lib", ".", "MediaInfo_Delete", "(", "handle", ")", ";", "}", "}", "else", "{", "result", "=", "null", ";", "}", "return", "result", ";", "}" ]
Extract media information for a particular file. @param filename name of the file @return media information @throws MediaInfoParseException if a parse error occurs
[ "Extract", "media", "information", "for", "a", "particular", "file", "." ]
a13c9242bcab4b98b66acc3969a05a95504451fa
https://github.com/caprica/vlcj-info/blob/a13c9242bcab4b98b66acc3969a05a95504451fa/src/main/java/uk/co/caprica/vlcjinfo/MediaInfo.java#L54-L78
138,793
caprica/vlcj-info
src/main/java/uk/co/caprica/vlcjinfo/MediaInfo.java
MediaInfo.sections
public Sections sections(String type) { Sections result = sectionsByType.get(type); if (result == null) { result = new Sections(); sectionsByType.put(type, result); } return result; }
java
public Sections sections(String type) { Sections result = sectionsByType.get(type); if (result == null) { result = new Sections(); sectionsByType.put(type, result); } return result; }
[ "public", "Sections", "sections", "(", "String", "type", ")", "{", "Sections", "result", "=", "sectionsByType", ".", "get", "(", "type", ")", ";", "if", "(", "result", "==", "null", ")", "{", "result", "=", "new", "Sections", "(", ")", ";", "sectionsByType", ".", "put", "(", "type", ",", "result", ")", ";", "}", "return", "result", ";", "}" ]
Get all of the sections of a particular type. @param type section type @return list of sections of the requested type, or <code>null</code> if there are no sections of that type
[ "Get", "all", "of", "the", "sections", "of", "a", "particular", "type", "." ]
a13c9242bcab4b98b66acc3969a05a95504451fa
https://github.com/caprica/vlcj-info/blob/a13c9242bcab4b98b66acc3969a05a95504451fa/src/main/java/uk/co/caprica/vlcjinfo/MediaInfo.java#L86-L93
138,794
caprica/vlcj-info
src/main/java/uk/co/caprica/vlcjinfo/MediaInfo.java
MediaInfo.first
public Section first(String type) { Section result; Sections sections = sections(type); if (sections != null) { result = sections.first(); } else { result = null; } return result; }
java
public Section first(String type) { Section result; Sections sections = sections(type); if (sections != null) { result = sections.first(); } else { result = null; } return result; }
[ "public", "Section", "first", "(", "String", "type", ")", "{", "Section", "result", ";", "Sections", "sections", "=", "sections", "(", "type", ")", ";", "if", "(", "sections", "!=", "null", ")", "{", "result", "=", "sections", ".", "first", "(", ")", ";", "}", "else", "{", "result", "=", "null", ";", "}", "return", "result", ";", "}" ]
Get the first section of a particular type. @param type section type @return first section of the requested type, or <code>null</code> if there are no sections of that type
[ "Get", "the", "first", "section", "of", "a", "particular", "type", "." ]
a13c9242bcab4b98b66acc3969a05a95504451fa
https://github.com/caprica/vlcj-info/blob/a13c9242bcab4b98b66acc3969a05a95504451fa/src/main/java/uk/co/caprica/vlcjinfo/MediaInfo.java#L101-L111
138,795
JorgeCastilloPrz/ExpandablePanel
library/src/main/java/com/jorgecastilloprz/expandablepanel/controllers/strategy/AbstractAnimationStrategy.java
AbstractAnimationStrategy.completeAnimationToFullHeight
public void completeAnimationToFullHeight(int completeExpandAnimationSpeed) { HeightAnimation heightAnim = new HeightAnimation(animableView, animableView.getMeasuredHeight(), displayHeight); heightAnim.setDuration(completeExpandAnimationSpeed); heightAnim.setInterpolator(new DecelerateInterpolator()); animableView.startAnimation(heightAnim); }
java
public void completeAnimationToFullHeight(int completeExpandAnimationSpeed) { HeightAnimation heightAnim = new HeightAnimation(animableView, animableView.getMeasuredHeight(), displayHeight); heightAnim.setDuration(completeExpandAnimationSpeed); heightAnim.setInterpolator(new DecelerateInterpolator()); animableView.startAnimation(heightAnim); }
[ "public", "void", "completeAnimationToFullHeight", "(", "int", "completeExpandAnimationSpeed", ")", "{", "HeightAnimation", "heightAnim", "=", "new", "HeightAnimation", "(", "animableView", ",", "animableView", ".", "getMeasuredHeight", "(", ")", ",", "displayHeight", ")", ";", "heightAnim", ".", "setDuration", "(", "completeExpandAnimationSpeed", ")", ";", "heightAnim", ".", "setInterpolator", "(", "new", "DecelerateInterpolator", "(", ")", ")", ";", "animableView", ".", "startAnimation", "(", "heightAnim", ")", ";", "}" ]
Animates animableView until it reaches full screen height
[ "Animates", "animableView", "until", "it", "reaches", "full", "screen", "height" ]
12d7aca47599a80c2dadc6d0f56ff4dcd790926a
https://github.com/JorgeCastilloPrz/ExpandablePanel/blob/12d7aca47599a80c2dadc6d0f56ff4dcd790926a/library/src/main/java/com/jorgecastilloprz/expandablepanel/controllers/strategy/AbstractAnimationStrategy.java#L29-L35
138,796
JorgeCastilloPrz/ExpandablePanel
library/src/main/java/com/jorgecastilloprz/expandablepanel/controllers/strategy/AbstractAnimationStrategy.java
AbstractAnimationStrategy.completeAnimationToInitialHeight
public void completeAnimationToInitialHeight(int completeShrinkAnimationSpeed, int initialAnimableLayoutHeight) { HeightAnimation heightAnim = new HeightAnimation(animableView, animableView.getMeasuredHeight(), initialAnimableLayoutHeight); heightAnim.setDuration(completeShrinkAnimationSpeed); heightAnim.setInterpolator(new DecelerateInterpolator()); animableView.startAnimation(heightAnim); }
java
public void completeAnimationToInitialHeight(int completeShrinkAnimationSpeed, int initialAnimableLayoutHeight) { HeightAnimation heightAnim = new HeightAnimation(animableView, animableView.getMeasuredHeight(), initialAnimableLayoutHeight); heightAnim.setDuration(completeShrinkAnimationSpeed); heightAnim.setInterpolator(new DecelerateInterpolator()); animableView.startAnimation(heightAnim); }
[ "public", "void", "completeAnimationToInitialHeight", "(", "int", "completeShrinkAnimationSpeed", ",", "int", "initialAnimableLayoutHeight", ")", "{", "HeightAnimation", "heightAnim", "=", "new", "HeightAnimation", "(", "animableView", ",", "animableView", ".", "getMeasuredHeight", "(", ")", ",", "initialAnimableLayoutHeight", ")", ";", "heightAnim", ".", "setDuration", "(", "completeShrinkAnimationSpeed", ")", ";", "heightAnim", ".", "setInterpolator", "(", "new", "DecelerateInterpolator", "(", ")", ")", ";", "animableView", ".", "startAnimation", "(", "heightAnim", ")", ";", "}" ]
Animates animableView to get its initial height back
[ "Animates", "animableView", "to", "get", "its", "initial", "height", "back" ]
12d7aca47599a80c2dadc6d0f56ff4dcd790926a
https://github.com/JorgeCastilloPrz/ExpandablePanel/blob/12d7aca47599a80c2dadc6d0f56ff4dcd790926a/library/src/main/java/com/jorgecastilloprz/expandablepanel/controllers/strategy/AbstractAnimationStrategy.java#L40-L46
138,797
caprica/vlcj-info
src/main/java/uk/co/caprica/vlcjinfo/Conversions.java
Conversions.integer
static Integer integer(String value) { Integer result; if (value != null) { value = value.trim(); Matcher matcher = INTEGER_PATTERN.matcher(value); if (matcher.matches()) { result = Integer.parseInt(matcher.group(1).replace(" ", "")); } else { throw new IllegalArgumentException("Unknown format for value: " + value); } } else { result = null; } return result; }
java
static Integer integer(String value) { Integer result; if (value != null) { value = value.trim(); Matcher matcher = INTEGER_PATTERN.matcher(value); if (matcher.matches()) { result = Integer.parseInt(matcher.group(1).replace(" ", "")); } else { throw new IllegalArgumentException("Unknown format for value: " + value); } } else { result = null; } return result; }
[ "static", "Integer", "integer", "(", "String", "value", ")", "{", "Integer", "result", ";", "if", "(", "value", "!=", "null", ")", "{", "value", "=", "value", ".", "trim", "(", ")", ";", "Matcher", "matcher", "=", "INTEGER_PATTERN", ".", "matcher", "(", "value", ")", ";", "if", "(", "matcher", ".", "matches", "(", ")", ")", "{", "result", "=", "Integer", ".", "parseInt", "(", "matcher", ".", "group", "(", "1", ")", ".", "replace", "(", "\" \"", ",", "\"\"", ")", ")", ";", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", "\"Unknown format for value: \"", "+", "value", ")", ";", "}", "}", "else", "{", "result", "=", "null", ";", "}", "return", "result", ";", "}" ]
Convert a string to an integer. @param value value to convert @return converted value, or <code>null</code> if the supplied value was <code>null</code> @throws IllegalArgumentException if the supplied value could not be parsed
[ "Convert", "a", "string", "to", "an", "integer", "." ]
a13c9242bcab4b98b66acc3969a05a95504451fa
https://github.com/caprica/vlcj-info/blob/a13c9242bcab4b98b66acc3969a05a95504451fa/src/main/java/uk/co/caprica/vlcjinfo/Conversions.java#L59-L73
138,798
caprica/vlcj-info
src/main/java/uk/co/caprica/vlcjinfo/Conversions.java
Conversions.decimal
static BigDecimal decimal(String value) { BigDecimal result; if (value != null) { value = value.trim(); Matcher matcher = DECIMAL_PATTERN.matcher(value); if (matcher.matches()) { result = new BigDecimal(matcher.group(1)); } else { throw new IllegalArgumentException("Unknown format for value: " + value); } } else { result = null; } return result; }
java
static BigDecimal decimal(String value) { BigDecimal result; if (value != null) { value = value.trim(); Matcher matcher = DECIMAL_PATTERN.matcher(value); if (matcher.matches()) { result = new BigDecimal(matcher.group(1)); } else { throw new IllegalArgumentException("Unknown format for value: " + value); } } else { result = null; } return result; }
[ "static", "BigDecimal", "decimal", "(", "String", "value", ")", "{", "BigDecimal", "result", ";", "if", "(", "value", "!=", "null", ")", "{", "value", "=", "value", ".", "trim", "(", ")", ";", "Matcher", "matcher", "=", "DECIMAL_PATTERN", ".", "matcher", "(", "value", ")", ";", "if", "(", "matcher", ".", "matches", "(", ")", ")", "{", "result", "=", "new", "BigDecimal", "(", "matcher", ".", "group", "(", "1", ")", ")", ";", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", "\"Unknown format for value: \"", "+", "value", ")", ";", "}", "}", "else", "{", "result", "=", "null", ";", "}", "return", "result", ";", "}" ]
Convert a string to a big decimal. @param value value to convert @return converted value, or <code>null</code> if the supplied value was <code>null</code> @throws IllegalArgumentException if the supplied value could not be parsed
[ "Convert", "a", "string", "to", "a", "big", "decimal", "." ]
a13c9242bcab4b98b66acc3969a05a95504451fa
https://github.com/caprica/vlcj-info/blob/a13c9242bcab4b98b66acc3969a05a95504451fa/src/main/java/uk/co/caprica/vlcjinfo/Conversions.java#L82-L96
138,799
caprica/vlcj-info
src/main/java/uk/co/caprica/vlcjinfo/Conversions.java
Conversions.duration
static Duration duration(String value) { Duration result; if (value != null) { value = value.trim(); Matcher matcher = DURATION_PATTERN.matcher(value); if (matcher.matches()) { int hours = matcher.group(1) != null ? Integer.parseInt(matcher.group(1)) : 0; int minutes = matcher.group(2) != null ? Integer.parseInt(matcher.group(2)) : 0; int seconds = matcher.group(3) != null ? Integer.parseInt(matcher.group(3)) : 0; int millis = matcher.group(4) != null ? Integer.parseInt(matcher.group(4)) : 0; result = new Duration(hours, minutes, seconds, millis); } else { throw new IllegalArgumentException("Unknown format for value: " + value); } } else { result = null; } return result; }
java
static Duration duration(String value) { Duration result; if (value != null) { value = value.trim(); Matcher matcher = DURATION_PATTERN.matcher(value); if (matcher.matches()) { int hours = matcher.group(1) != null ? Integer.parseInt(matcher.group(1)) : 0; int minutes = matcher.group(2) != null ? Integer.parseInt(matcher.group(2)) : 0; int seconds = matcher.group(3) != null ? Integer.parseInt(matcher.group(3)) : 0; int millis = matcher.group(4) != null ? Integer.parseInt(matcher.group(4)) : 0; result = new Duration(hours, minutes, seconds, millis); } else { throw new IllegalArgumentException("Unknown format for value: " + value); } } else { result = null; } return result; }
[ "static", "Duration", "duration", "(", "String", "value", ")", "{", "Duration", "result", ";", "if", "(", "value", "!=", "null", ")", "{", "value", "=", "value", ".", "trim", "(", ")", ";", "Matcher", "matcher", "=", "DURATION_PATTERN", ".", "matcher", "(", "value", ")", ";", "if", "(", "matcher", ".", "matches", "(", ")", ")", "{", "int", "hours", "=", "matcher", ".", "group", "(", "1", ")", "!=", "null", "?", "Integer", ".", "parseInt", "(", "matcher", ".", "group", "(", "1", ")", ")", ":", "0", ";", "int", "minutes", "=", "matcher", ".", "group", "(", "2", ")", "!=", "null", "?", "Integer", ".", "parseInt", "(", "matcher", ".", "group", "(", "2", ")", ")", ":", "0", ";", "int", "seconds", "=", "matcher", ".", "group", "(", "3", ")", "!=", "null", "?", "Integer", ".", "parseInt", "(", "matcher", ".", "group", "(", "3", ")", ")", ":", "0", ";", "int", "millis", "=", "matcher", ".", "group", "(", "4", ")", "!=", "null", "?", "Integer", ".", "parseInt", "(", "matcher", ".", "group", "(", "4", ")", ")", ":", "0", ";", "result", "=", "new", "Duration", "(", "hours", ",", "minutes", ",", "seconds", ",", "millis", ")", ";", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", "\"Unknown format for value: \"", "+", "value", ")", ";", "}", "}", "else", "{", "result", "=", "null", ";", "}", "return", "result", ";", "}" ]
Convert a string to a duration. @param value value to convert @return converted value, or <code>null</code> if the supplied value was <code>null</code> @throws IllegalArgumentException if the supplied value could not be parsed
[ "Convert", "a", "string", "to", "a", "duration", "." ]
a13c9242bcab4b98b66acc3969a05a95504451fa
https://github.com/caprica/vlcj-info/blob/a13c9242bcab4b98b66acc3969a05a95504451fa/src/main/java/uk/co/caprica/vlcjinfo/Conversions.java#L105-L123