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
156,300
chrisruffalo/ee-config
src/main/java/com/github/chrisruffalo/eeconfig/resources/BeanResolver.java
BeanResolver.resolveBeanWithDefaultClass
@SuppressWarnings("unchecked") public <B, T extends B, D extends B> B resolveBeanWithDefaultClass(Class<T> typeToResolve, Class<D> defaultType) { // if type to resolve is null, do nothing, not even the default if(typeToResolve == null) { return null; } // get candidate resolve types Set<Bean<?>> candidates = this.manager.getBeans(typeToResolve); // if no candidates are available, resolve // using next class up if(!candidates.iterator().hasNext()) { this.logger.trace("No candidates for: {}", typeToResolve.getName()); // try and resolve only the default type return resolveBeanWithDefaultClass(defaultType, null); } this.logger.trace("Requesting resolution on: {}", typeToResolve.getName()); // get candidate Bean<?> bean = candidates.iterator().next(); CreationalContext<?> context = this.manager.createCreationalContext(bean); Type type = (Type) bean.getTypes().iterator().next(); B result = (B)this.manager.getReference(bean, type, context); this.logger.trace("Resolved to: {}", result.getClass().getName()); return result; }
java
@SuppressWarnings("unchecked") public <B, T extends B, D extends B> B resolveBeanWithDefaultClass(Class<T> typeToResolve, Class<D> defaultType) { // if type to resolve is null, do nothing, not even the default if(typeToResolve == null) { return null; } // get candidate resolve types Set<Bean<?>> candidates = this.manager.getBeans(typeToResolve); // if no candidates are available, resolve // using next class up if(!candidates.iterator().hasNext()) { this.logger.trace("No candidates for: {}", typeToResolve.getName()); // try and resolve only the default type return resolveBeanWithDefaultClass(defaultType, null); } this.logger.trace("Requesting resolution on: {}", typeToResolve.getName()); // get candidate Bean<?> bean = candidates.iterator().next(); CreationalContext<?> context = this.manager.createCreationalContext(bean); Type type = (Type) bean.getTypes().iterator().next(); B result = (B)this.manager.getReference(bean, type, context); this.logger.trace("Resolved to: {}", result.getClass().getName()); return result; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "B", ",", "T", "extends", "B", ",", "D", "extends", "B", ">", "B", "resolveBeanWithDefaultClass", "(", "Class", "<", "T", ">", "typeToResolve", ",", "Class", "<", "D", ">", "defaultType", ")", "{", "// if type to resolve is null, do nothing, not even the default", "if", "(", "typeToResolve", "==", "null", ")", "{", "return", "null", ";", "}", "// get candidate resolve types", "Set", "<", "Bean", "<", "?", ">", ">", "candidates", "=", "this", ".", "manager", ".", "getBeans", "(", "typeToResolve", ")", ";", "// if no candidates are available, resolve", "// using next class up", "if", "(", "!", "candidates", ".", "iterator", "(", ")", ".", "hasNext", "(", ")", ")", "{", "this", ".", "logger", ".", "trace", "(", "\"No candidates for: {}\"", ",", "typeToResolve", ".", "getName", "(", ")", ")", ";", "// try and resolve only the default type", "return", "resolveBeanWithDefaultClass", "(", "defaultType", ",", "null", ")", ";", "}", "this", ".", "logger", ".", "trace", "(", "\"Requesting resolution on: {}\"", ",", "typeToResolve", ".", "getName", "(", ")", ")", ";", "// get candidate", "Bean", "<", "?", ">", "bean", "=", "candidates", ".", "iterator", "(", ")", ".", "next", "(", ")", ";", "CreationalContext", "<", "?", ">", "context", "=", "this", ".", "manager", ".", "createCreationalContext", "(", "bean", ")", ";", "Type", "type", "=", "(", "Type", ")", "bean", ".", "getTypes", "(", ")", ".", "iterator", "(", ")", ".", "next", "(", ")", ";", "B", "result", "=", "(", "B", ")", "this", ".", "manager", ".", "getReference", "(", "bean", ",", "type", ",", "context", ")", ";", "this", ".", "logger", ".", "trace", "(", "\"Resolved to: {}\"", ",", "result", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "return", "result", ";", "}" ]
Resolve managed bean for given type @param typeToResolve @param defaultType @return
[ "Resolve", "managed", "bean", "for", "given", "type" ]
6cdc59e2117e97c1997b79a19cbfaa284027e60c
https://github.com/chrisruffalo/ee-config/blob/6cdc59e2117e97c1997b79a19cbfaa284027e60c/src/main/java/com/github/chrisruffalo/eeconfig/resources/BeanResolver.java#L33-L63
156,301
riversun/d6
src/main/java/org/riversun/d6/core/D6CrudDeleteHelper.java
D6CrudDeleteHelper.createDeleteAllPreparedSQLStatement
String createDeleteAllPreparedSQLStatement() { final StringGrabber sgSQL = new StringGrabber(); // Get the table name final DBTable table = mModelClazz.getAnnotation(DBTable.class); final String tableName = table.tableName(); sgSQL.append("DELETE FROM " + tableName); return sgSQL.toString(); }
java
String createDeleteAllPreparedSQLStatement() { final StringGrabber sgSQL = new StringGrabber(); // Get the table name final DBTable table = mModelClazz.getAnnotation(DBTable.class); final String tableName = table.tableName(); sgSQL.append("DELETE FROM " + tableName); return sgSQL.toString(); }
[ "String", "createDeleteAllPreparedSQLStatement", "(", ")", "{", "final", "StringGrabber", "sgSQL", "=", "new", "StringGrabber", "(", ")", ";", "// Get the table name\r", "final", "DBTable", "table", "=", "mModelClazz", ".", "getAnnotation", "(", "DBTable", ".", "class", ")", ";", "final", "String", "tableName", "=", "table", ".", "tableName", "(", ")", ";", "sgSQL", ".", "append", "(", "\"DELETE FROM \"", "+", "tableName", ")", ";", "return", "sgSQL", ".", "toString", "(", ")", ";", "}" ]
Create the all-delete statement @return
[ "Create", "the", "all", "-", "delete", "statement" ]
2798bd876b9380dbfea8182d11ad306cb1b0e114
https://github.com/riversun/d6/blob/2798bd876b9380dbfea8182d11ad306cb1b0e114/src/main/java/org/riversun/d6/core/D6CrudDeleteHelper.java#L58-L69
156,302
s1-platform/s1
s1-core/src/java/org/s1/cluster/Session.java
Session.start
public static String start(String id) { if(idLocal.get()!=null){ return null; }else{ MDC.put("sessionId", id); if(LOG.isDebugEnabled()) LOG.debug("Initialize session id = "+id); idLocal.set(id); return id; } }
java
public static String start(String id) { if(idLocal.get()!=null){ return null; }else{ MDC.put("sessionId", id); if(LOG.isDebugEnabled()) LOG.debug("Initialize session id = "+id); idLocal.set(id); return id; } }
[ "public", "static", "String", "start", "(", "String", "id", ")", "{", "if", "(", "idLocal", ".", "get", "(", ")", "!=", "null", ")", "{", "return", "null", ";", "}", "else", "{", "MDC", ".", "put", "(", "\"sessionId\"", ",", "id", ")", ";", "if", "(", "LOG", ".", "isDebugEnabled", "(", ")", ")", "LOG", ".", "debug", "(", "\"Initialize session id = \"", "+", "id", ")", ";", "idLocal", ".", "set", "(", "id", ")", ";", "return", "id", ";", "}", "}" ]
Run some code in session @param id session id @return
[ "Run", "some", "code", "in", "session" ]
370101c13fef01af524bc171bcc1a97e5acc76e8
https://github.com/s1-platform/s1/blob/370101c13fef01af524bc171bcc1a97e5acc76e8/s1-core/src/java/org/s1/cluster/Session.java#L75-L85
156,303
s1-platform/s1
s1-core/src/java/org/s1/cluster/Session.java
Session.getSessionBean
public static SessionBean getSessionBean(){ String id = idLocal.get(); if(id==null) return null; SessionBean s = getSessionMap().get(id); //check TTL if(s!=null && (System.currentTimeMillis()-s.lastUsed)>TTL){ if(LOG.isDebugEnabled()) LOG.debug("Discarding session "+id+" with livetime="+(System.currentTimeMillis()-s.lastUsed)+"ms"); s = null; } //new session if(s==null) s = new SessionBean(); s.lastUsed = System.currentTimeMillis(); updateSessionBean(s); s.id = id; return s; }
java
public static SessionBean getSessionBean(){ String id = idLocal.get(); if(id==null) return null; SessionBean s = getSessionMap().get(id); //check TTL if(s!=null && (System.currentTimeMillis()-s.lastUsed)>TTL){ if(LOG.isDebugEnabled()) LOG.debug("Discarding session "+id+" with livetime="+(System.currentTimeMillis()-s.lastUsed)+"ms"); s = null; } //new session if(s==null) s = new SessionBean(); s.lastUsed = System.currentTimeMillis(); updateSessionBean(s); s.id = id; return s; }
[ "public", "static", "SessionBean", "getSessionBean", "(", ")", "{", "String", "id", "=", "idLocal", ".", "get", "(", ")", ";", "if", "(", "id", "==", "null", ")", "return", "null", ";", "SessionBean", "s", "=", "getSessionMap", "(", ")", ".", "get", "(", "id", ")", ";", "//check TTL", "if", "(", "s", "!=", "null", "&&", "(", "System", ".", "currentTimeMillis", "(", ")", "-", "s", ".", "lastUsed", ")", ">", "TTL", ")", "{", "if", "(", "LOG", ".", "isDebugEnabled", "(", ")", ")", "LOG", ".", "debug", "(", "\"Discarding session \"", "+", "id", "+", "\" with livetime=\"", "+", "(", "System", ".", "currentTimeMillis", "(", ")", "-", "s", ".", "lastUsed", ")", "+", "\"ms\"", ")", ";", "s", "=", "null", ";", "}", "//new session", "if", "(", "s", "==", "null", ")", "s", "=", "new", "SessionBean", "(", ")", ";", "s", ".", "lastUsed", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "updateSessionBean", "(", "s", ")", ";", "s", ".", "id", "=", "id", ";", "return", "s", ";", "}" ]
Return current session data @return
[ "Return", "current", "session", "data" ]
370101c13fef01af524bc171bcc1a97e5acc76e8
https://github.com/s1-platform/s1/blob/370101c13fef01af524bc171bcc1a97e5acc76e8/s1-core/src/java/org/s1/cluster/Session.java#L103-L124
156,304
vizotov/JDoubleDispatch
src/main/java/su/izotov/java/ddispatch/Dispatch.java
Dispatch.resultFunction
public ResultFunction<M, G, R> resultFunction() throws MethodAmbiguouslyDefinedException { final MasterClass masterClass = new MasterClass(this.master.getClass()); final GuestClass guestClass = new GuestClass(this.guest.getClass()); final GenericsContext context = GenericsResolver.resolve(this.getClass()) .type(Dispatch.class); // final Class<?> masterClassRestriction = context.generics().get(0); // Class M for right method searching // final Class<?> guestClassRestriction = context.generics().get(1); // Class G for right method searching final ReturnClass returnClass = new ReturnClass(context.generics() .get(2)); // Class R for right method searching ResultFunction<M, G, R> method; final Set<Method> methods = new ByParameterClass(masterClass, guestClass, this.methodName, returnClass, new ByParameterInterfaces(masterClass, guestClass, this.methodName, returnClass, new ByParameterSuperClass(masterClass, guestClass, this.methodName, returnClass, new EmptyMethods()))).findMethods(); if (methods.isEmpty()) { method = new ResultFunction<M, G, R>() { @Override public String toString() { return "default method"; } @Override public R apply(final M m, final G g) { return Dispatch.this.defaultMethod.apply(m, g); } }; } else { final Iterator<Method> iterator = methods.iterator(); MethodRepresentation currentMethod = new OneMethod(iterator.next()); while (iterator.hasNext()) { final MethodRepresentation nextMethod = new OneMethod(iterator.next()); currentMethod = new OneOfTwoMethods(currentMethod, nextMethod); } final Method finalMethod = currentMethod.toMethod(); method = new MethodFunction<>(finalMethod); } return method; }
java
public ResultFunction<M, G, R> resultFunction() throws MethodAmbiguouslyDefinedException { final MasterClass masterClass = new MasterClass(this.master.getClass()); final GuestClass guestClass = new GuestClass(this.guest.getClass()); final GenericsContext context = GenericsResolver.resolve(this.getClass()) .type(Dispatch.class); // final Class<?> masterClassRestriction = context.generics().get(0); // Class M for right method searching // final Class<?> guestClassRestriction = context.generics().get(1); // Class G for right method searching final ReturnClass returnClass = new ReturnClass(context.generics() .get(2)); // Class R for right method searching ResultFunction<M, G, R> method; final Set<Method> methods = new ByParameterClass(masterClass, guestClass, this.methodName, returnClass, new ByParameterInterfaces(masterClass, guestClass, this.methodName, returnClass, new ByParameterSuperClass(masterClass, guestClass, this.methodName, returnClass, new EmptyMethods()))).findMethods(); if (methods.isEmpty()) { method = new ResultFunction<M, G, R>() { @Override public String toString() { return "default method"; } @Override public R apply(final M m, final G g) { return Dispatch.this.defaultMethod.apply(m, g); } }; } else { final Iterator<Method> iterator = methods.iterator(); MethodRepresentation currentMethod = new OneMethod(iterator.next()); while (iterator.hasNext()) { final MethodRepresentation nextMethod = new OneMethod(iterator.next()); currentMethod = new OneOfTwoMethods(currentMethod, nextMethod); } final Method finalMethod = currentMethod.toMethod(); method = new MethodFunction<>(finalMethod); } return method; }
[ "public", "ResultFunction", "<", "M", ",", "G", ",", "R", ">", "resultFunction", "(", ")", "throws", "MethodAmbiguouslyDefinedException", "{", "final", "MasterClass", "masterClass", "=", "new", "MasterClass", "(", "this", ".", "master", ".", "getClass", "(", ")", ")", ";", "final", "GuestClass", "guestClass", "=", "new", "GuestClass", "(", "this", ".", "guest", ".", "getClass", "(", ")", ")", ";", "final", "GenericsContext", "context", "=", "GenericsResolver", ".", "resolve", "(", "this", ".", "getClass", "(", ")", ")", ".", "type", "(", "Dispatch", ".", "class", ")", ";", "// final Class<?> masterClassRestriction = context.generics().get(0); // Class M for right method searching", "// final Class<?> guestClassRestriction = context.generics().get(1); // Class G for right method searching", "final", "ReturnClass", "returnClass", "=", "new", "ReturnClass", "(", "context", ".", "generics", "(", ")", ".", "get", "(", "2", ")", ")", ";", "// Class R for right method searching", "ResultFunction", "<", "M", ",", "G", ",", "R", ">", "method", ";", "final", "Set", "<", "Method", ">", "methods", "=", "new", "ByParameterClass", "(", "masterClass", ",", "guestClass", ",", "this", ".", "methodName", ",", "returnClass", ",", "new", "ByParameterInterfaces", "(", "masterClass", ",", "guestClass", ",", "this", ".", "methodName", ",", "returnClass", ",", "new", "ByParameterSuperClass", "(", "masterClass", ",", "guestClass", ",", "this", ".", "methodName", ",", "returnClass", ",", "new", "EmptyMethods", "(", ")", ")", ")", ")", ".", "findMethods", "(", ")", ";", "if", "(", "methods", ".", "isEmpty", "(", ")", ")", "{", "method", "=", "new", "ResultFunction", "<", "M", ",", "G", ",", "R", ">", "(", ")", "{", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"default method\"", ";", "}", "@", "Override", "public", "R", "apply", "(", "final", "M", "m", ",", "final", "G", "g", ")", "{", "return", "Dispatch", ".", "this", ".", "defaultMethod", ".", "apply", "(", "m", ",", "g", ")", ";", "}", "}", ";", "}", "else", "{", "final", "Iterator", "<", "Method", ">", "iterator", "=", "methods", ".", "iterator", "(", ")", ";", "MethodRepresentation", "currentMethod", "=", "new", "OneMethod", "(", "iterator", ".", "next", "(", ")", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "final", "MethodRepresentation", "nextMethod", "=", "new", "OneMethod", "(", "iterator", ".", "next", "(", ")", ")", ";", "currentMethod", "=", "new", "OneOfTwoMethods", "(", "currentMethod", ",", "nextMethod", ")", ";", "}", "final", "Method", "finalMethod", "=", "currentMethod", ".", "toMethod", "(", ")", ";", "method", "=", "new", "MethodFunction", "<>", "(", "finalMethod", ")", ";", "}", "return", "method", ";", "}" ]
the result function @return the function @throws MethodAmbiguouslyDefinedException more than one method is found
[ "the", "result", "function" ]
5d40b63266c36a7ace565697701bb1ede4910519
https://github.com/vizotov/JDoubleDispatch/blob/5d40b63266c36a7ace565697701bb1ede4910519/src/main/java/su/izotov/java/ddispatch/Dispatch.java#L87-L137
156,305
csc19601128/Phynixx
phynixx/phynixx-watchdog/src/main/java/org/csc/phynixx/watchdog/WatchdogRegistry.java
WatchdogRegistry.registerWatchdog
private synchronized void registerWatchdog(Long key, Watchdog wd) { if (wd == null) { throw new NullPointerException("Thread"); } if (wd.getThread() == null) { wd.restart(); } registeredWachdogs.put(key, wd); }
java
private synchronized void registerWatchdog(Long key, Watchdog wd) { if (wd == null) { throw new NullPointerException("Thread"); } if (wd.getThread() == null) { wd.restart(); } registeredWachdogs.put(key, wd); }
[ "private", "synchronized", "void", "registerWatchdog", "(", "Long", "key", ",", "Watchdog", "wd", ")", "{", "if", "(", "wd", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"Thread\"", ")", ";", "}", "if", "(", "wd", ".", "getThread", "(", ")", "==", "null", ")", "{", "wd", ".", "restart", "(", ")", ";", "}", "registeredWachdogs", ".", "put", "(", "key", ",", "wd", ")", ";", "}" ]
Fuegt einen Thread hinzu @param key String Schluessel unter dem der Thread gespeichert wird @param wd Watchdog @throws IllegalStateException falls Thread NICHT zur aktuellen ThreadGroup( ==this) geh�rt;
[ "Fuegt", "einen", "Thread", "hinzu" ]
a26c03bc229a8882c647799834115bec6bdc0ac8
https://github.com/csc19601128/Phynixx/blob/a26c03bc229a8882c647799834115bec6bdc0ac8/phynixx/phynixx-watchdog/src/main/java/org/csc/phynixx/watchdog/WatchdogRegistry.java#L230-L238
156,306
csc19601128/Phynixx
phynixx/phynixx-watchdog/src/main/java/org/csc/phynixx/watchdog/WatchdogRegistry.java
WatchdogRegistry.kill
private void kill() { Set copy = new HashSet(registeredWachdogs.values()); Iterator iter = copy.iterator(); while (iter.hasNext()) { Watchdog th = (Watchdog) iter.next(); if (th.isAlive()) { if (log.isInfoEnabled()) { log.info(". . . Killing Watchdog " + th.getId()); } th.kill(); } } this.joinAllThreads(); // remove all Watchdogs frim the registry .... iter = copy.iterator(); while (iter.hasNext()) { this.deregisterWatchdog((IWatchdog) iter.next()); } }
java
private void kill() { Set copy = new HashSet(registeredWachdogs.values()); Iterator iter = copy.iterator(); while (iter.hasNext()) { Watchdog th = (Watchdog) iter.next(); if (th.isAlive()) { if (log.isInfoEnabled()) { log.info(". . . Killing Watchdog " + th.getId()); } th.kill(); } } this.joinAllThreads(); // remove all Watchdogs frim the registry .... iter = copy.iterator(); while (iter.hasNext()) { this.deregisterWatchdog((IWatchdog) iter.next()); } }
[ "private", "void", "kill", "(", ")", "{", "Set", "copy", "=", "new", "HashSet", "(", "registeredWachdogs", ".", "values", "(", ")", ")", ";", "Iterator", "iter", "=", "copy", ".", "iterator", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "Watchdog", "th", "=", "(", "Watchdog", ")", "iter", ".", "next", "(", ")", ";", "if", "(", "th", ".", "isAlive", "(", ")", ")", "{", "if", "(", "log", ".", "isInfoEnabled", "(", ")", ")", "{", "log", ".", "info", "(", "\". . . Killing Watchdog \"", "+", "th", ".", "getId", "(", ")", ")", ";", "}", "th", ".", "kill", "(", ")", ";", "}", "}", "this", ".", "joinAllThreads", "(", ")", ";", "// remove all Watchdogs frim the registry ....", "iter", "=", "copy", ".", "iterator", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "this", ".", "deregisterWatchdog", "(", "(", "IWatchdog", ")", "iter", ".", "next", "(", ")", ")", ";", "}", "}" ]
killt alle Threads der Gruppe
[ "killt", "alle", "Threads", "der", "Gruppe" ]
a26c03bc229a8882c647799834115bec6bdc0ac8
https://github.com/csc19601128/Phynixx/blob/a26c03bc229a8882c647799834115bec6bdc0ac8/phynixx/phynixx-watchdog/src/main/java/org/csc/phynixx/watchdog/WatchdogRegistry.java#L374-L395
156,307
csc19601128/Phynixx
phynixx/phynixx-watchdog/src/main/java/org/csc/phynixx/watchdog/WatchdogRegistry.java
WatchdogRegistry.shutdown
public synchronized void shutdown() { this.shutdownManagementWatchdogs(); // deactivate all Watchdogs .... Iterator iter = registeredWachdogs.values().iterator(); while (iter.hasNext()) { IWatchdog th = (IWatchdog) iter.next(); th.deactivate(); if (log.isInfoEnabled()) { log.info(". . . Deactivating Watchdog " + th.getId()); } } this.kill(); }
java
public synchronized void shutdown() { this.shutdownManagementWatchdogs(); // deactivate all Watchdogs .... Iterator iter = registeredWachdogs.values().iterator(); while (iter.hasNext()) { IWatchdog th = (IWatchdog) iter.next(); th.deactivate(); if (log.isInfoEnabled()) { log.info(". . . Deactivating Watchdog " + th.getId()); } } this.kill(); }
[ "public", "synchronized", "void", "shutdown", "(", ")", "{", "this", ".", "shutdownManagementWatchdogs", "(", ")", ";", "// deactivate all Watchdogs ....", "Iterator", "iter", "=", "registeredWachdogs", ".", "values", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "IWatchdog", "th", "=", "(", "IWatchdog", ")", "iter", ".", "next", "(", ")", ";", "th", ".", "deactivate", "(", ")", ";", "if", "(", "log", ".", "isInfoEnabled", "(", ")", ")", "{", "log", ".", "info", "(", "\". . . Deactivating Watchdog \"", "+", "th", ".", "getId", "(", ")", ")", ";", "}", "}", "this", ".", "kill", "(", ")", ";", "}" ]
killt alle Threads der Gruppe und wartet bis auch der letzte beendet ist. Es wird der evtl. Exceptionhandler geschlossen.
[ "killt", "alle", "Threads", "der", "Gruppe", "und", "wartet", "bis", "auch", "der", "letzte", "beendet", "ist", ".", "Es", "wird", "der", "evtl", ".", "Exceptionhandler", "geschlossen", "." ]
a26c03bc229a8882c647799834115bec6bdc0ac8
https://github.com/csc19601128/Phynixx/blob/a26c03bc229a8882c647799834115bec6bdc0ac8/phynixx/phynixx-watchdog/src/main/java/org/csc/phynixx/watchdog/WatchdogRegistry.java#L402-L417
156,308
csc19601128/Phynixx
phynixx/phynixx-watchdog/src/main/java/org/csc/phynixx/watchdog/WatchdogRegistry.java
WatchdogRegistry.joinAllThreads
private void joinAllThreads() { Iterator iter = registeredWachdogs.values().iterator(); while (iter.hasNext()) { Watchdog th = (Watchdog) iter.next(); boolean isJoining = true; if (!th.isAlive() && log.isDebugEnabled()) { log.debug("Thread " + th + " finished"); } while (th.isAlive() && isJoining) { try { th.getThread().join(); isJoining = false; if (log.isDebugEnabled()) { log.debug("Thread " + th + " joined and finished"); } } catch (InterruptedException e) { } } } }
java
private void joinAllThreads() { Iterator iter = registeredWachdogs.values().iterator(); while (iter.hasNext()) { Watchdog th = (Watchdog) iter.next(); boolean isJoining = true; if (!th.isAlive() && log.isDebugEnabled()) { log.debug("Thread " + th + " finished"); } while (th.isAlive() && isJoining) { try { th.getThread().join(); isJoining = false; if (log.isDebugEnabled()) { log.debug("Thread " + th + " joined and finished"); } } catch (InterruptedException e) { } } } }
[ "private", "void", "joinAllThreads", "(", ")", "{", "Iterator", "iter", "=", "registeredWachdogs", ".", "values", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "Watchdog", "th", "=", "(", "Watchdog", ")", "iter", ".", "next", "(", ")", ";", "boolean", "isJoining", "=", "true", ";", "if", "(", "!", "th", ".", "isAlive", "(", ")", "&&", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Thread \"", "+", "th", "+", "\" finished\"", ")", ";", "}", "while", "(", "th", ".", "isAlive", "(", ")", "&&", "isJoining", ")", "{", "try", "{", "th", ".", "getThread", "(", ")", ".", "join", "(", ")", ";", "isJoining", "=", "false", ";", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Thread \"", "+", "th", "+", "\" joined and finished\"", ")", ";", "}", "}", "catch", "(", "InterruptedException", "e", ")", "{", "}", "}", "}", "}" ]
wartet bis auch der letzte Thread beendet ist
[ "wartet", "bis", "auch", "der", "letzte", "Thread", "beendet", "ist" ]
a26c03bc229a8882c647799834115bec6bdc0ac8
https://github.com/csc19601128/Phynixx/blob/a26c03bc229a8882c647799834115bec6bdc0ac8/phynixx/phynixx-watchdog/src/main/java/org/csc/phynixx/watchdog/WatchdogRegistry.java#L422-L441
156,309
csc19601128/Phynixx
phynixx/phynixx-watchdog/src/main/java/org/csc/phynixx/watchdog/WatchdogRegistry.java
WatchdogRegistry.shutdown
public void shutdown(Long id) { Watchdog wd = (Watchdog) this.registeredWachdogs.get(id); if (wd == null) { throw new IllegalStateException("Watchdog " + id + " ist not registered"); } wd.kill(); this.deregisterWatchdog(id); }
java
public void shutdown(Long id) { Watchdog wd = (Watchdog) this.registeredWachdogs.get(id); if (wd == null) { throw new IllegalStateException("Watchdog " + id + " ist not registered"); } wd.kill(); this.deregisterWatchdog(id); }
[ "public", "void", "shutdown", "(", "Long", "id", ")", "{", "Watchdog", "wd", "=", "(", "Watchdog", ")", "this", ".", "registeredWachdogs", ".", "get", "(", "id", ")", ";", "if", "(", "wd", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Watchdog \"", "+", "id", "+", "\" ist not registered\"", ")", ";", "}", "wd", ".", "kill", "(", ")", ";", "this", ".", "deregisterWatchdog", "(", "id", ")", ";", "}" ]
stops the the Watchdog with the given id The executing thread of the watchdog is stopped and the watchdog is removed from the registry. It can nor be restarted @throws IllegalStateException Watchdog does not exist, check existence with {@link #findWatchdog(Long)} @see #restart(Long) @see #stop(Long)
[ "stops", "the", "the", "Watchdog", "with", "the", "given", "id", "The", "executing", "thread", "of", "the", "watchdog", "is", "stopped", "and", "the", "watchdog", "is", "removed", "from", "the", "registry", ".", "It", "can", "nor", "be", "restarted" ]
a26c03bc229a8882c647799834115bec6bdc0ac8
https://github.com/csc19601128/Phynixx/blob/a26c03bc229a8882c647799834115bec6bdc0ac8/phynixx/phynixx-watchdog/src/main/java/org/csc/phynixx/watchdog/WatchdogRegistry.java#L524-L532
156,310
csc19601128/Phynixx
phynixx/phynixx-watchdog/src/main/java/org/csc/phynixx/watchdog/WatchdogRegistry.java
WatchdogRegistry.restart
public void restart(Long id) { Watchdog wd = (Watchdog) this.registeredWachdogs.get(id); if (wd == null) { throw new IllegalStateException("Watchdog " + id + " ist not registered"); } wd.restart(); }
java
public void restart(Long id) { Watchdog wd = (Watchdog) this.registeredWachdogs.get(id); if (wd == null) { throw new IllegalStateException("Watchdog " + id + " ist not registered"); } wd.restart(); }
[ "public", "void", "restart", "(", "Long", "id", ")", "{", "Watchdog", "wd", "=", "(", "Watchdog", ")", "this", ".", "registeredWachdogs", ".", "get", "(", "id", ")", ";", "if", "(", "wd", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Watchdog \"", "+", "id", "+", "\" ist not registered\"", ")", ";", "}", "wd", ".", "restart", "(", ")", ";", "}" ]
restart the Watchdog with the given id @throws IllegalStateException Watchdog does not exist, check existence with {@link #findWatchdog(Long)}
[ "restart", "the", "Watchdog", "with", "the", "given", "id" ]
a26c03bc229a8882c647799834115bec6bdc0ac8
https://github.com/csc19601128/Phynixx/blob/a26c03bc229a8882c647799834115bec6bdc0ac8/phynixx/phynixx-watchdog/src/main/java/org/csc/phynixx/watchdog/WatchdogRegistry.java#L541-L548
156,311
intellimate/Izou
src/main/java/org/intellimate/izou/security/SecurityFunctions.java
SecurityFunctions.generateKey
public SecretKey generateKey() { SecretKey key = null; try { KeyGenerator generator = KeyGenerator.getInstance("AES"); generator.init(128); key = generator.generateKey(); } catch (NoSuchAlgorithmException e) { logger.error("Unable to generate AES key", e); } return key; }
java
public SecretKey generateKey() { SecretKey key = null; try { KeyGenerator generator = KeyGenerator.getInstance("AES"); generator.init(128); key = generator.generateKey(); } catch (NoSuchAlgorithmException e) { logger.error("Unable to generate AES key", e); } return key; }
[ "public", "SecretKey", "generateKey", "(", ")", "{", "SecretKey", "key", "=", "null", ";", "try", "{", "KeyGenerator", "generator", "=", "KeyGenerator", ".", "getInstance", "(", "\"AES\"", ")", ";", "generator", ".", "init", "(", "128", ")", ";", "key", "=", "generator", ".", "generateKey", "(", ")", ";", "}", "catch", "(", "NoSuchAlgorithmException", "e", ")", "{", "logger", ".", "error", "(", "\"Unable to generate AES key\"", ",", "e", ")", ";", "}", "return", "key", ";", "}" ]
Generates a key for the AES encryption @return a new key for the AES encryption
[ "Generates", "a", "key", "for", "the", "AES", "encryption" ]
40a808b97998e17655c4a78e30ce7326148aed27
https://github.com/intellimate/Izou/blob/40a808b97998e17655c4a78e30ce7326148aed27/src/main/java/org/intellimate/izou/security/SecurityFunctions.java#L94-L105
156,312
aicer/hibiscus-http-client
src/main/java/org/aicer/hibiscus/http/client/Response.java
Response.setStatusLine
public final Response setStatusLine(final String statusLine) { this.statusLine = statusLine; final String[] statusPieces = statusLine.split(" "); if (statusPieces.length > 1) { responseCode = Integer.parseInt(statusPieces[1]); } return this; }
java
public final Response setStatusLine(final String statusLine) { this.statusLine = statusLine; final String[] statusPieces = statusLine.split(" "); if (statusPieces.length > 1) { responseCode = Integer.parseInt(statusPieces[1]); } return this; }
[ "public", "final", "Response", "setStatusLine", "(", "final", "String", "statusLine", ")", "{", "this", ".", "statusLine", "=", "statusLine", ";", "final", "String", "[", "]", "statusPieces", "=", "statusLine", ".", "split", "(", "\" \"", ")", ";", "if", "(", "statusPieces", ".", "length", ">", "1", ")", "{", "responseCode", "=", "Integer", ".", "parseInt", "(", "statusPieces", "[", "1", "]", ")", ";", "}", "return", "this", ";", "}" ]
Specifies the HTTP status line @param statusLine @return
[ "Specifies", "the", "HTTP", "status", "line" ]
a037e3cf8d4bb862d38a55a090778736a48d67cc
https://github.com/aicer/hibiscus-http-client/blob/a037e3cf8d4bb862d38a55a090778736a48d67cc/src/main/java/org/aicer/hibiscus/http/client/Response.java#L63-L74
156,313
janus-project/guava.janusproject.io
guava/src/com/google/common/collect/ImmutableBiMap.java
ImmutableBiMap.copyOf
@Beta public static <K, V> ImmutableBiMap<K, V> copyOf( Iterable<? extends Entry<? extends K, ? extends V>> entries) { Entry<?, ?>[] entryArray = Iterables.toArray(entries, EMPTY_ENTRY_ARRAY); switch (entryArray.length) { case 0: return of(); case 1: @SuppressWarnings("unchecked") // safe covariant cast in this context Entry<K, V> entry = (Entry<K, V>) entryArray[0]; return of(entry.getKey(), entry.getValue()); default: return new RegularImmutableBiMap<K, V>(entryArray); } }
java
@Beta public static <K, V> ImmutableBiMap<K, V> copyOf( Iterable<? extends Entry<? extends K, ? extends V>> entries) { Entry<?, ?>[] entryArray = Iterables.toArray(entries, EMPTY_ENTRY_ARRAY); switch (entryArray.length) { case 0: return of(); case 1: @SuppressWarnings("unchecked") // safe covariant cast in this context Entry<K, V> entry = (Entry<K, V>) entryArray[0]; return of(entry.getKey(), entry.getValue()); default: return new RegularImmutableBiMap<K, V>(entryArray); } }
[ "@", "Beta", "public", "static", "<", "K", ",", "V", ">", "ImmutableBiMap", "<", "K", ",", "V", ">", "copyOf", "(", "Iterable", "<", "?", "extends", "Entry", "<", "?", "extends", "K", ",", "?", "extends", "V", ">", ">", "entries", ")", "{", "Entry", "<", "?", ",", "?", ">", "[", "]", "entryArray", "=", "Iterables", ".", "toArray", "(", "entries", ",", "EMPTY_ENTRY_ARRAY", ")", ";", "switch", "(", "entryArray", ".", "length", ")", "{", "case", "0", ":", "return", "of", "(", ")", ";", "case", "1", ":", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "// safe covariant cast in this context", "Entry", "<", "K", ",", "V", ">", "entry", "=", "(", "Entry", "<", "K", ",", "V", ">", ")", "entryArray", "[", "0", "]", ";", "return", "of", "(", "entry", ".", "getKey", "(", ")", ",", "entry", ".", "getValue", "(", ")", ")", ";", "default", ":", "return", "new", "RegularImmutableBiMap", "<", "K", ",", "V", ">", "(", "entryArray", ")", ";", "}", "}" ]
Returns an immutable bimap containing the given entries. @throws IllegalArgumentException if two keys have the same value or two values have the same key @throws NullPointerException if any key, value, or entry is null @since 19.0
[ "Returns", "an", "immutable", "bimap", "containing", "the", "given", "entries", "." ]
1c48fb672c9fdfddf276970570f703fa1115f588
https://github.com/janus-project/guava.janusproject.io/blob/1c48fb672c9fdfddf276970570f703fa1115f588/guava/src/com/google/common/collect/ImmutableBiMap.java#L240-L254
156,314
intellimate/Izou
src/main/java/org/intellimate/izou/activator/ActivatorManager.java
ActivatorManager.addActivator
public void addActivator(ActivatorModel activatorModel) throws IllegalIDException { activatorModels.add(activatorModel); crashCounter.put(activatorModel, new AtomicInteger(0)); permissionDeniedCounter.put(activatorModel, new AtomicInteger(0)); submitActivator(activatorModel); }
java
public void addActivator(ActivatorModel activatorModel) throws IllegalIDException { activatorModels.add(activatorModel); crashCounter.put(activatorModel, new AtomicInteger(0)); permissionDeniedCounter.put(activatorModel, new AtomicInteger(0)); submitActivator(activatorModel); }
[ "public", "void", "addActivator", "(", "ActivatorModel", "activatorModel", ")", "throws", "IllegalIDException", "{", "activatorModels", ".", "add", "(", "activatorModel", ")", ";", "crashCounter", ".", "put", "(", "activatorModel", ",", "new", "AtomicInteger", "(", "0", ")", ")", ";", "permissionDeniedCounter", ".", "put", "(", "activatorModel", ",", "new", "AtomicInteger", "(", "0", ")", ")", ";", "submitActivator", "(", "activatorModel", ")", ";", "}" ]
adds an activator and automatically submits it to the Thread-Pool @param activatorModel the activator to add @throws IllegalIDException not yet implemented
[ "adds", "an", "activator", "and", "automatically", "submits", "it", "to", "the", "Thread", "-", "Pool" ]
40a808b97998e17655c4a78e30ce7326148aed27
https://github.com/intellimate/Izou/blob/40a808b97998e17655c4a78e30ce7326148aed27/src/main/java/org/intellimate/izou/activator/ActivatorManager.java#L41-L46
156,315
intellimate/Izou
src/main/java/org/intellimate/izou/activator/ActivatorManager.java
ActivatorManager.removeActivator
public void removeActivator(ActivatorModel activatorModel) { activatorModels.remove(activatorModel); CompletableFuture remove = futures.remove(activatorModel); if (remove != null) { remove.cancel(true); } crashCounter.remove(activatorModel); permissionDeniedCounter.remove(activatorModel); }
java
public void removeActivator(ActivatorModel activatorModel) { activatorModels.remove(activatorModel); CompletableFuture remove = futures.remove(activatorModel); if (remove != null) { remove.cancel(true); } crashCounter.remove(activatorModel); permissionDeniedCounter.remove(activatorModel); }
[ "public", "void", "removeActivator", "(", "ActivatorModel", "activatorModel", ")", "{", "activatorModels", ".", "remove", "(", "activatorModel", ")", ";", "CompletableFuture", "remove", "=", "futures", ".", "remove", "(", "activatorModel", ")", ";", "if", "(", "remove", "!=", "null", ")", "{", "remove", ".", "cancel", "(", "true", ")", ";", "}", "crashCounter", ".", "remove", "(", "activatorModel", ")", ";", "permissionDeniedCounter", ".", "remove", "(", "activatorModel", ")", ";", "}" ]
removes the activator and stops the Thread @param activatorModel the activator to remove
[ "removes", "the", "activator", "and", "stops", "the", "Thread" ]
40a808b97998e17655c4a78e30ce7326148aed27
https://github.com/intellimate/Izou/blob/40a808b97998e17655c4a78e30ce7326148aed27/src/main/java/org/intellimate/izou/activator/ActivatorManager.java#L52-L60
156,316
intellimate/Izou
src/main/java/org/intellimate/izou/activator/ActivatorManager.java
ActivatorManager.submitActivator
private void submitActivator(ActivatorModel activatorModel) { CompletableFuture<Void> future = submit(() -> { try { return activatorModel.call(); } catch (Throwable e) { if (e instanceof IzouPermissionException) { error("Activator: " + activatorModel.getID() + " was denied permission.", e); // Return null if permission was denied by a permission module, in this case restart 2 times return null; } else if (e instanceof SecurityException) { error("Activator: " + activatorModel.getID() + " was denied access.", e); // Return false if access was denied by the security manager, in this case, do not restart return false; } error("Activator: " + activatorModel.getID() + " crashed", e); // Return true if the addOn did not crash because of security reasons, restart 100 times return true; } }).thenAccept(restart -> { if (restart != null && restart.equals(false)) { debug("Activator: " + activatorModel.getID() + " returned false, will not restart"); } else if (restart == null) { error("Activator: " + activatorModel.getID() + " returned not true"); if (permissionDeniedCounter.get(activatorModel).get() < MAX_PERMISSION_DENIED) { error("Until now activator: " + activatorModel.getID() + " was restarted: " + permissionDeniedCounter.get(activatorModel).get() + " times, attempting restart."); permissionDeniedCounter.get(activatorModel).incrementAndGet(); submitActivator(activatorModel); } else { error("Activator: " + activatorModel.getID() + " reached permission based restarting limit with " + permissionDeniedCounter.get(activatorModel).get() + " restarts."); } } else { if (crashCounter.get(activatorModel).get() < MAX_CRASH) { error("Until now activator: " + activatorModel.getID() + " was restarted: " + crashCounter.get(activatorModel).get() + " times, attempting restart."); crashCounter.get(activatorModel).incrementAndGet(); submitActivator(activatorModel); } else { error("Activator: " + activatorModel.getID() + " reached crash based restarting limit with " + crashCounter.get(activatorModel).get() + " restarts."); } } }); CompletableFuture existing = futures.put(activatorModel, future); if (existing != null && !existing.isDone()) existing.cancel(true); }
java
private void submitActivator(ActivatorModel activatorModel) { CompletableFuture<Void> future = submit(() -> { try { return activatorModel.call(); } catch (Throwable e) { if (e instanceof IzouPermissionException) { error("Activator: " + activatorModel.getID() + " was denied permission.", e); // Return null if permission was denied by a permission module, in this case restart 2 times return null; } else if (e instanceof SecurityException) { error("Activator: " + activatorModel.getID() + " was denied access.", e); // Return false if access was denied by the security manager, in this case, do not restart return false; } error("Activator: " + activatorModel.getID() + " crashed", e); // Return true if the addOn did not crash because of security reasons, restart 100 times return true; } }).thenAccept(restart -> { if (restart != null && restart.equals(false)) { debug("Activator: " + activatorModel.getID() + " returned false, will not restart"); } else if (restart == null) { error("Activator: " + activatorModel.getID() + " returned not true"); if (permissionDeniedCounter.get(activatorModel).get() < MAX_PERMISSION_DENIED) { error("Until now activator: " + activatorModel.getID() + " was restarted: " + permissionDeniedCounter.get(activatorModel).get() + " times, attempting restart."); permissionDeniedCounter.get(activatorModel).incrementAndGet(); submitActivator(activatorModel); } else { error("Activator: " + activatorModel.getID() + " reached permission based restarting limit with " + permissionDeniedCounter.get(activatorModel).get() + " restarts."); } } else { if (crashCounter.get(activatorModel).get() < MAX_CRASH) { error("Until now activator: " + activatorModel.getID() + " was restarted: " + crashCounter.get(activatorModel).get() + " times, attempting restart."); crashCounter.get(activatorModel).incrementAndGet(); submitActivator(activatorModel); } else { error("Activator: " + activatorModel.getID() + " reached crash based restarting limit with " + crashCounter.get(activatorModel).get() + " restarts."); } } }); CompletableFuture existing = futures.put(activatorModel, future); if (existing != null && !existing.isDone()) existing.cancel(true); }
[ "private", "void", "submitActivator", "(", "ActivatorModel", "activatorModel", ")", "{", "CompletableFuture", "<", "Void", ">", "future", "=", "submit", "(", "(", ")", "->", "{", "try", "{", "return", "activatorModel", ".", "call", "(", ")", ";", "}", "catch", "(", "Throwable", "e", ")", "{", "if", "(", "e", "instanceof", "IzouPermissionException", ")", "{", "error", "(", "\"Activator: \"", "+", "activatorModel", ".", "getID", "(", ")", "+", "\" was denied permission.\"", ",", "e", ")", ";", "// Return null if permission was denied by a permission module, in this case restart 2 times", "return", "null", ";", "}", "else", "if", "(", "e", "instanceof", "SecurityException", ")", "{", "error", "(", "\"Activator: \"", "+", "activatorModel", ".", "getID", "(", ")", "+", "\" was denied access.\"", ",", "e", ")", ";", "// Return false if access was denied by the security manager, in this case, do not restart", "return", "false", ";", "}", "error", "(", "\"Activator: \"", "+", "activatorModel", ".", "getID", "(", ")", "+", "\" crashed\"", ",", "e", ")", ";", "// Return true if the addOn did not crash because of security reasons, restart 100 times", "return", "true", ";", "}", "}", ")", ".", "thenAccept", "(", "restart", "->", "{", "if", "(", "restart", "!=", "null", "&&", "restart", ".", "equals", "(", "false", ")", ")", "{", "debug", "(", "\"Activator: \"", "+", "activatorModel", ".", "getID", "(", ")", "+", "\" returned false, will not restart\"", ")", ";", "}", "else", "if", "(", "restart", "==", "null", ")", "{", "error", "(", "\"Activator: \"", "+", "activatorModel", ".", "getID", "(", ")", "+", "\" returned not true\"", ")", ";", "if", "(", "permissionDeniedCounter", ".", "get", "(", "activatorModel", ")", ".", "get", "(", ")", "<", "MAX_PERMISSION_DENIED", ")", "{", "error", "(", "\"Until now activator: \"", "+", "activatorModel", ".", "getID", "(", ")", "+", "\" was restarted: \"", "+", "permissionDeniedCounter", ".", "get", "(", "activatorModel", ")", ".", "get", "(", ")", "+", "\" times, attempting restart.\"", ")", ";", "permissionDeniedCounter", ".", "get", "(", "activatorModel", ")", ".", "incrementAndGet", "(", ")", ";", "submitActivator", "(", "activatorModel", ")", ";", "}", "else", "{", "error", "(", "\"Activator: \"", "+", "activatorModel", ".", "getID", "(", ")", "+", "\" reached permission based restarting limit with \"", "+", "permissionDeniedCounter", ".", "get", "(", "activatorModel", ")", ".", "get", "(", ")", "+", "\" restarts.\"", ")", ";", "}", "}", "else", "{", "if", "(", "crashCounter", ".", "get", "(", "activatorModel", ")", ".", "get", "(", ")", "<", "MAX_CRASH", ")", "{", "error", "(", "\"Until now activator: \"", "+", "activatorModel", ".", "getID", "(", ")", "+", "\" was restarted: \"", "+", "crashCounter", ".", "get", "(", "activatorModel", ")", ".", "get", "(", ")", "+", "\" times, attempting restart.\"", ")", ";", "crashCounter", ".", "get", "(", "activatorModel", ")", ".", "incrementAndGet", "(", ")", ";", "submitActivator", "(", "activatorModel", ")", ";", "}", "else", "{", "error", "(", "\"Activator: \"", "+", "activatorModel", ".", "getID", "(", ")", "+", "\" reached crash based restarting limit with \"", "+", "crashCounter", ".", "get", "(", "activatorModel", ")", ".", "get", "(", ")", "+", "\" restarts.\"", ")", ";", "}", "}", "}", ")", ";", "CompletableFuture", "existing", "=", "futures", ".", "put", "(", "activatorModel", ",", "future", ")", ";", "if", "(", "existing", "!=", "null", "&&", "!", "existing", ".", "isDone", "(", ")", ")", "existing", ".", "cancel", "(", "true", ")", ";", "}" ]
submits the activator to the ThreadPool @param activatorModel teh activator to submit
[ "submits", "the", "activator", "to", "the", "ThreadPool" ]
40a808b97998e17655c4a78e30ce7326148aed27
https://github.com/intellimate/Izou/blob/40a808b97998e17655c4a78e30ce7326148aed27/src/main/java/org/intellimate/izou/activator/ActivatorManager.java#L66-L116
156,317
chrisruffalo/ee-config
src/main/java/com/github/chrisruffalo/eeconfig/source/impl/ResourceSource.java
ResourceSource.getUrl
private URL getUrl() { ClassLoader loader = Thread.currentThread().getContextClassLoader(); URL url = loader.getResource(this.getPath()); return url; }
java
private URL getUrl() { ClassLoader loader = Thread.currentThread().getContextClassLoader(); URL url = loader.getResource(this.getPath()); return url; }
[ "private", "URL", "getUrl", "(", ")", "{", "ClassLoader", "loader", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ";", "URL", "url", "=", "loader", ".", "getResource", "(", "this", ".", "getPath", "(", ")", ")", ";", "return", "url", ";", "}" ]
Get the url to find out if the resource is available @return URL of the resource
[ "Get", "the", "url", "to", "find", "out", "if", "the", "resource", "is", "available" ]
6cdc59e2117e97c1997b79a19cbfaa284027e60c
https://github.com/chrisruffalo/ee-config/blob/6cdc59e2117e97c1997b79a19cbfaa284027e60c/src/main/java/com/github/chrisruffalo/eeconfig/source/impl/ResourceSource.java#L48-L52
156,318
ecclesia/kipeto
kipeto-tools/src/main/java/de/ecclesia/kipeto/tools/blueprint/BlueprintFactory.java
BlueprintFactory.processDir
private Directory processDir(File dirFile) { List<Item> items = new ArrayList<Item>(); File[] files = dirFile.listFiles(); logger.info("processing directory {} with {} entries", dirFile, files.length); for (File file : files) { if (file.getName().equals(UpdateJob.LOCK_FILE)) { logger.info("skipping lockfile {}", file); } else if (file.isDirectory()) { logger.debug("adding directory {}", file); items.add(new DirectoryItem(file.getName(), processDir(file))); } else { // LastModified nur sekundengenau speichern, da Windows zwar // millisekundengenau speichern kann, Linux Dateisysteme (ext3, // ReiserFS, etc.) aber nur sekundengenau. Es kommst sonst zu // Problemen, wenn der Blueprint auf einem Linux-System gebaut // und auf ein Windows-System deployd wird: long lastModified = (file.lastModified() / 1000) * 1000; logger.debug("adding blob {}, lastModified: ", file, lastModified); items.add(new FileItem(file.getName(), processBlob(file), lastModified)); } } Directory dir = new Directory(items.toArray(new Item[items.size()])); try { String id = writingRepository.store(dir); logger.info("added directory {} -> {}", dirFile, id); } catch (IOException e) { throw new RuntimeException(e); } return dir; }
java
private Directory processDir(File dirFile) { List<Item> items = new ArrayList<Item>(); File[] files = dirFile.listFiles(); logger.info("processing directory {} with {} entries", dirFile, files.length); for (File file : files) { if (file.getName().equals(UpdateJob.LOCK_FILE)) { logger.info("skipping lockfile {}", file); } else if (file.isDirectory()) { logger.debug("adding directory {}", file); items.add(new DirectoryItem(file.getName(), processDir(file))); } else { // LastModified nur sekundengenau speichern, da Windows zwar // millisekundengenau speichern kann, Linux Dateisysteme (ext3, // ReiserFS, etc.) aber nur sekundengenau. Es kommst sonst zu // Problemen, wenn der Blueprint auf einem Linux-System gebaut // und auf ein Windows-System deployd wird: long lastModified = (file.lastModified() / 1000) * 1000; logger.debug("adding blob {}, lastModified: ", file, lastModified); items.add(new FileItem(file.getName(), processBlob(file), lastModified)); } } Directory dir = new Directory(items.toArray(new Item[items.size()])); try { String id = writingRepository.store(dir); logger.info("added directory {} -> {}", dirFile, id); } catch (IOException e) { throw new RuntimeException(e); } return dir; }
[ "private", "Directory", "processDir", "(", "File", "dirFile", ")", "{", "List", "<", "Item", ">", "items", "=", "new", "ArrayList", "<", "Item", ">", "(", ")", ";", "File", "[", "]", "files", "=", "dirFile", ".", "listFiles", "(", ")", ";", "logger", ".", "info", "(", "\"processing directory {} with {} entries\"", ",", "dirFile", ",", "files", ".", "length", ")", ";", "for", "(", "File", "file", ":", "files", ")", "{", "if", "(", "file", ".", "getName", "(", ")", ".", "equals", "(", "UpdateJob", ".", "LOCK_FILE", ")", ")", "{", "logger", ".", "info", "(", "\"skipping lockfile {}\"", ",", "file", ")", ";", "}", "else", "if", "(", "file", ".", "isDirectory", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"adding directory {}\"", ",", "file", ")", ";", "items", ".", "add", "(", "new", "DirectoryItem", "(", "file", ".", "getName", "(", ")", ",", "processDir", "(", "file", ")", ")", ")", ";", "}", "else", "{", "// LastModified nur sekundengenau speichern, da Windows zwar", "// millisekundengenau speichern kann, Linux Dateisysteme (ext3,", "// ReiserFS, etc.) aber nur sekundengenau. Es kommst sonst zu", "// Problemen, wenn der Blueprint auf einem Linux-System gebaut", "// und auf ein Windows-System deployd wird:", "long", "lastModified", "=", "(", "file", ".", "lastModified", "(", ")", "/", "1000", ")", "*", "1000", ";", "logger", ".", "debug", "(", "\"adding blob {}, lastModified: \"", ",", "file", ",", "lastModified", ")", ";", "items", ".", "add", "(", "new", "FileItem", "(", "file", ".", "getName", "(", ")", ",", "processBlob", "(", "file", ")", ",", "lastModified", ")", ")", ";", "}", "}", "Directory", "dir", "=", "new", "Directory", "(", "items", ".", "toArray", "(", "new", "Item", "[", "items", ".", "size", "(", ")", "]", ")", ")", ";", "try", "{", "String", "id", "=", "writingRepository", ".", "store", "(", "dir", ")", ";", "logger", ".", "info", "(", "\"added directory {} -> {}\"", ",", "dirFile", ",", "id", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "return", "dir", ";", "}" ]
Verarbeitet ein Verzeichnis @param dirFile @return
[ "Verarbeitet", "ein", "Verzeichnis" ]
ea39a10ae4eaa550f71a856ab2f2845270a64913
https://github.com/ecclesia/kipeto/blob/ea39a10ae4eaa550f71a856ab2f2845270a64913/kipeto-tools/src/main/java/de/ecclesia/kipeto/tools/blueprint/BlueprintFactory.java#L101-L135
156,319
jmeetsma/Iglu-Common
src/main/java/org/ijsberg/iglu/scheduling/module/StandardScheduler.java
StandardScheduler.start
public void start() { if ((schedulerThread == null || !schedulerThread.isAlive()) && interval > 0) { schedulerThread = new Thread(this); //act as internal request to be able to bind internal process // Request currentRequest = application.getCurrentRequest(); // currentRequest.startRepresentingRequest(initialRequest); // application.bindInternalProcess(schedulerThread, "scheduler"); // currentRequest.stopRepresentingRequest(); schedulerThread.start(); System.out.println(new LogEntry("scheduler thread started...")); } }
java
public void start() { if ((schedulerThread == null || !schedulerThread.isAlive()) && interval > 0) { schedulerThread = new Thread(this); //act as internal request to be able to bind internal process // Request currentRequest = application.getCurrentRequest(); // currentRequest.startRepresentingRequest(initialRequest); // application.bindInternalProcess(schedulerThread, "scheduler"); // currentRequest.stopRepresentingRequest(); schedulerThread.start(); System.out.println(new LogEntry("scheduler thread started...")); } }
[ "public", "void", "start", "(", ")", "{", "if", "(", "(", "schedulerThread", "==", "null", "||", "!", "schedulerThread", ".", "isAlive", "(", ")", ")", "&&", "interval", ">", "0", ")", "{", "schedulerThread", "=", "new", "Thread", "(", "this", ")", ";", "//act as internal request to be able to bind internal process\r", "//\t\t\tRequest currentRequest = application.getCurrentRequest();\r", "//\t\t\tcurrentRequest.startRepresentingRequest(initialRequest);\r", "//\t\t\tapplication.bindInternalProcess(schedulerThread, \"scheduler\");\r", "//\t\t\tcurrentRequest.stopRepresentingRequest();\r", "schedulerThread", ".", "start", "(", ")", ";", "System", ".", "out", ".", "println", "(", "new", "LogEntry", "(", "\"scheduler thread started...\"", ")", ")", ";", "}", "}" ]
Starts scheduler thread that pages pageables.
[ "Starts", "scheduler", "thread", "that", "pages", "pageables", "." ]
0fb0885775b576209ff1b5a0f67e3c25a99a6420
https://github.com/jmeetsma/Iglu-Common/blob/0fb0885775b576209ff1b5a0f67e3c25a99a6420/src/main/java/org/ijsberg/iglu/scheduling/module/StandardScheduler.java#L91-L102
156,320
jmeetsma/Iglu-Common
src/main/java/org/ijsberg/iglu/scheduling/module/StandardScheduler.java
StandardScheduler.stop
public void stop() { if (schedulerThread != null) { schedulerThread.interrupt(); try { schedulerThread.join(1000); } catch (InterruptedException ie) { } // application.releaseRequest(schedulerThread); schedulerThread = null; System.out.println(new LogEntry("scheduler thread stopped...")); } }
java
public void stop() { if (schedulerThread != null) { schedulerThread.interrupt(); try { schedulerThread.join(1000); } catch (InterruptedException ie) { } // application.releaseRequest(schedulerThread); schedulerThread = null; System.out.println(new LogEntry("scheduler thread stopped...")); } }
[ "public", "void", "stop", "(", ")", "{", "if", "(", "schedulerThread", "!=", "null", ")", "{", "schedulerThread", ".", "interrupt", "(", ")", ";", "try", "{", "schedulerThread", ".", "join", "(", "1000", ")", ";", "}", "catch", "(", "InterruptedException", "ie", ")", "{", "}", "//\t\t\tapplication.releaseRequest(schedulerThread);\r", "schedulerThread", "=", "null", ";", "System", ".", "out", ".", "println", "(", "new", "LogEntry", "(", "\"scheduler thread stopped...\"", ")", ")", ";", "}", "}" ]
Stops scheduler thread.
[ "Stops", "scheduler", "thread", "." ]
0fb0885775b576209ff1b5a0f67e3c25a99a6420
https://github.com/jmeetsma/Iglu-Common/blob/0fb0885775b576209ff1b5a0f67e3c25a99a6420/src/main/java/org/ijsberg/iglu/scheduling/module/StandardScheduler.java#L107-L119
156,321
jmeetsma/Iglu-Common
src/main/java/org/ijsberg/iglu/scheduling/module/StandardScheduler.java
StandardScheduler.register
public void register(Pageable pageable) { System.out.println(pagedSystemObjectNames); if (!pagedSystemObjectNames.contains(pageable.toString())) { if (pageable.getPageIntervalInMinutes() <= 0) { System.out.println(new LogEntry(Level.VERBOSE, "scheduler will not page " + StringSupport.trim(pageable.toString() + "'", 80, "...") + ": interval in minutes (" + pageable.getPageIntervalInMinutes() + ") is not valid")); } else { System.out.println(new LogEntry(Level.VERBOSE, "scheduler will page " + StringSupport.trim(pageable.toString() + "'", 80, "...") + " every " + pageable.getPageIntervalInMinutes() + " minute(s)")); } synchronized (pagedSystems) { pagedSystems.add(pageable); pagedSystemObjectNames.add(pageable.toString()); } } else { System.out.println(new LogEntry("pageable " + pageable + " already registered in scheduler")); } }
java
public void register(Pageable pageable) { System.out.println(pagedSystemObjectNames); if (!pagedSystemObjectNames.contains(pageable.toString())) { if (pageable.getPageIntervalInMinutes() <= 0) { System.out.println(new LogEntry(Level.VERBOSE, "scheduler will not page " + StringSupport.trim(pageable.toString() + "'", 80, "...") + ": interval in minutes (" + pageable.getPageIntervalInMinutes() + ") is not valid")); } else { System.out.println(new LogEntry(Level.VERBOSE, "scheduler will page " + StringSupport.trim(pageable.toString() + "'", 80, "...") + " every " + pageable.getPageIntervalInMinutes() + " minute(s)")); } synchronized (pagedSystems) { pagedSystems.add(pageable); pagedSystemObjectNames.add(pageable.toString()); } } else { System.out.println(new LogEntry("pageable " + pageable + " already registered in scheduler")); } }
[ "public", "void", "register", "(", "Pageable", "pageable", ")", "{", "System", ".", "out", ".", "println", "(", "pagedSystemObjectNames", ")", ";", "if", "(", "!", "pagedSystemObjectNames", ".", "contains", "(", "pageable", ".", "toString", "(", ")", ")", ")", "{", "if", "(", "pageable", ".", "getPageIntervalInMinutes", "(", ")", "<=", "0", ")", "{", "System", ".", "out", ".", "println", "(", "new", "LogEntry", "(", "Level", ".", "VERBOSE", ",", "\"scheduler will not page \"", "+", "StringSupport", ".", "trim", "(", "pageable", ".", "toString", "(", ")", "+", "\"'\"", ",", "80", ",", "\"...\"", ")", "+", "\": interval in minutes (\"", "+", "pageable", ".", "getPageIntervalInMinutes", "(", ")", "+", "\") is not valid\"", ")", ")", ";", "}", "else", "{", "System", ".", "out", ".", "println", "(", "new", "LogEntry", "(", "Level", ".", "VERBOSE", ",", "\"scheduler will page \"", "+", "StringSupport", ".", "trim", "(", "pageable", ".", "toString", "(", ")", "+", "\"'\"", ",", "80", ",", "\"...\"", ")", "+", "\" every \"", "+", "pageable", ".", "getPageIntervalInMinutes", "(", ")", "+", "\" minute(s)\"", ")", ")", ";", "}", "synchronized", "(", "pagedSystems", ")", "{", "pagedSystems", ".", "add", "(", "pageable", ")", ";", "pagedSystemObjectNames", ".", "add", "(", "pageable", ".", "toString", "(", ")", ")", ";", "}", "}", "else", "{", "System", ".", "out", ".", "println", "(", "new", "LogEntry", "(", "\"pageable \"", "+", "pageable", "+", "\" already registered in scheduler\"", ")", ")", ";", "}", "}" ]
Registers pageables. If the pageable has specified a page interval > 0, it will be paged regularly. @param pageable
[ "Registers", "pageables", ".", "If", "the", "pageable", "has", "specified", "a", "page", "interval", ">", "0", "it", "will", "be", "paged", "regularly", "." ]
0fb0885775b576209ff1b5a0f67e3c25a99a6420
https://github.com/jmeetsma/Iglu-Common/blob/0fb0885775b576209ff1b5a0f67e3c25a99a6420/src/main/java/org/ijsberg/iglu/scheduling/module/StandardScheduler.java#L139-L154
156,322
jmeetsma/Iglu-Common
src/main/java/org/ijsberg/iglu/scheduling/module/StandardScheduler.java
StandardScheduler.run
public void run() { //register the current application for this thread // in case a subsystem logs to the environment // Environment.setCurrentApplication(application); currentState = SCHEDULER_WAIT; long currentTime = System.currentTimeMillis(); //long officialTime = TimeSupport.roundToMinute(currentTime);// + totalOffsetInMillis; while (currentState == SCHEDULER_WAIT) { try { long interval2 = SchedulingSupport.getTimeTillIntervalStart(System.currentTimeMillis(), interval); //prevent having two runs in one heartbeat if (interval2 < TimeSupport.SECOND_IN_MS) { interval2 += interval * TimeSupport.MINUTE_IN_MS; } Thread.sleep(interval2); } catch (InterruptedException ie) { System.out.println(new LogEntry(Level.CRITICAL, ("scheduler interrupted..."))); currentState = SCHEDULER_HALT; } if (currentState == SCHEDULER_WAIT) { currentState = SCHEDULER_BUSY; //do work (async in future) currentTime = System.currentTimeMillis(); final long officialTime = TimeSupport.roundToMinute(currentTime);// + totalOffsetInMillis; synchronized (pagedSystems) { Iterator i = pagedSystems.iterator(); while (i.hasNext()) { final Pageable pageable = (Pageable) i.next(); //check if intervals within limits if (pageable.getPageIntervalInMinutes() <= 0) { //log("scheduler can not page " + StringSupport.trim(pageable.toString() + "'", 50, "...") + ": interval in minutes (" + pageable.getPageIntervalInMinutes() + ") is not valid"); } else if (SchedulingSupport.isWithinMinuteOfIntervalStart(officialTime, pageable.getPageIntervalInMinutes(), pageable.getPageOffsetInMinutes()) && pageable.isStarted()) { System.out.println(new LogEntry("scheduler about to page " + StringSupport.trim(pageable.toString() + "'", 80, "..."))); //the page method is invoked by a system session // so a developer may try to use it to outflank the security system //another risk is that the invoked method consumes too much time if(runAsync) { new Executable() { public Object execute() { try { pageable.onPageEvent(officialTime); } catch (Exception e) {//pageable is not a trusted component //TODO keep history System.out.println(new LogEntry(Level.CRITICAL, "exception while paging pageable '" + StringSupport.trim(pageable.toString() + "'", 80, "..."), e)); } return null; } }.executeAsync(); } else { try { pageable.onPageEvent(officialTime); } catch (UndeclaredThrowableException e) { System.out.println(new LogEntry(Level.CRITICAL, "undeclared exception while paging pageable '" + StringSupport.trim(pageable.toString() + "'", 80, "..."), e.getCause())); } catch (Exception e) {//pageable is not a trusted component System.out.println(new LogEntry(Level.CRITICAL, "exception while paging pageable '" + StringSupport.trim(pageable.toString() + "'", 80, "..."), e)); } } } } lastCall = officialTime; } currentState = SCHEDULER_WAIT; } } currentState = SCHEDULER_HALT; }
java
public void run() { //register the current application for this thread // in case a subsystem logs to the environment // Environment.setCurrentApplication(application); currentState = SCHEDULER_WAIT; long currentTime = System.currentTimeMillis(); //long officialTime = TimeSupport.roundToMinute(currentTime);// + totalOffsetInMillis; while (currentState == SCHEDULER_WAIT) { try { long interval2 = SchedulingSupport.getTimeTillIntervalStart(System.currentTimeMillis(), interval); //prevent having two runs in one heartbeat if (interval2 < TimeSupport.SECOND_IN_MS) { interval2 += interval * TimeSupport.MINUTE_IN_MS; } Thread.sleep(interval2); } catch (InterruptedException ie) { System.out.println(new LogEntry(Level.CRITICAL, ("scheduler interrupted..."))); currentState = SCHEDULER_HALT; } if (currentState == SCHEDULER_WAIT) { currentState = SCHEDULER_BUSY; //do work (async in future) currentTime = System.currentTimeMillis(); final long officialTime = TimeSupport.roundToMinute(currentTime);// + totalOffsetInMillis; synchronized (pagedSystems) { Iterator i = pagedSystems.iterator(); while (i.hasNext()) { final Pageable pageable = (Pageable) i.next(); //check if intervals within limits if (pageable.getPageIntervalInMinutes() <= 0) { //log("scheduler can not page " + StringSupport.trim(pageable.toString() + "'", 50, "...") + ": interval in minutes (" + pageable.getPageIntervalInMinutes() + ") is not valid"); } else if (SchedulingSupport.isWithinMinuteOfIntervalStart(officialTime, pageable.getPageIntervalInMinutes(), pageable.getPageOffsetInMinutes()) && pageable.isStarted()) { System.out.println(new LogEntry("scheduler about to page " + StringSupport.trim(pageable.toString() + "'", 80, "..."))); //the page method is invoked by a system session // so a developer may try to use it to outflank the security system //another risk is that the invoked method consumes too much time if(runAsync) { new Executable() { public Object execute() { try { pageable.onPageEvent(officialTime); } catch (Exception e) {//pageable is not a trusted component //TODO keep history System.out.println(new LogEntry(Level.CRITICAL, "exception while paging pageable '" + StringSupport.trim(pageable.toString() + "'", 80, "..."), e)); } return null; } }.executeAsync(); } else { try { pageable.onPageEvent(officialTime); } catch (UndeclaredThrowableException e) { System.out.println(new LogEntry(Level.CRITICAL, "undeclared exception while paging pageable '" + StringSupport.trim(pageable.toString() + "'", 80, "..."), e.getCause())); } catch (Exception e) {//pageable is not a trusted component System.out.println(new LogEntry(Level.CRITICAL, "exception while paging pageable '" + StringSupport.trim(pageable.toString() + "'", 80, "..."), e)); } } } } lastCall = officialTime; } currentState = SCHEDULER_WAIT; } } currentState = SCHEDULER_HALT; }
[ "public", "void", "run", "(", ")", "{", "//register the current application for this thread\r", "// in case a subsystem logs to the environment\r", "//\t\tEnvironment.setCurrentApplication(application);\r", "currentState", "=", "SCHEDULER_WAIT", ";", "long", "currentTime", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "//long officialTime = TimeSupport.roundToMinute(currentTime);// + totalOffsetInMillis;\r", "while", "(", "currentState", "==", "SCHEDULER_WAIT", ")", "{", "try", "{", "long", "interval2", "=", "SchedulingSupport", ".", "getTimeTillIntervalStart", "(", "System", ".", "currentTimeMillis", "(", ")", ",", "interval", ")", ";", "//prevent having two runs in one heartbeat\r", "if", "(", "interval2", "<", "TimeSupport", ".", "SECOND_IN_MS", ")", "{", "interval2", "+=", "interval", "*", "TimeSupport", ".", "MINUTE_IN_MS", ";", "}", "Thread", ".", "sleep", "(", "interval2", ")", ";", "}", "catch", "(", "InterruptedException", "ie", ")", "{", "System", ".", "out", ".", "println", "(", "new", "LogEntry", "(", "Level", ".", "CRITICAL", ",", "(", "\"scheduler interrupted...\"", ")", ")", ")", ";", "currentState", "=", "SCHEDULER_HALT", ";", "}", "if", "(", "currentState", "==", "SCHEDULER_WAIT", ")", "{", "currentState", "=", "SCHEDULER_BUSY", ";", "//do work (async in future)\r", "currentTime", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "final", "long", "officialTime", "=", "TimeSupport", ".", "roundToMinute", "(", "currentTime", ")", ";", "// + totalOffsetInMillis;\r", "synchronized", "(", "pagedSystems", ")", "{", "Iterator", "i", "=", "pagedSystems", ".", "iterator", "(", ")", ";", "while", "(", "i", ".", "hasNext", "(", ")", ")", "{", "final", "Pageable", "pageable", "=", "(", "Pageable", ")", "i", ".", "next", "(", ")", ";", "//check if intervals within limits\r", "if", "(", "pageable", ".", "getPageIntervalInMinutes", "(", ")", "<=", "0", ")", "{", "//log(\"scheduler can not page \" + StringSupport.trim(pageable.toString() + \"'\", 50, \"...\") + \": interval in minutes (\" + pageable.getPageIntervalInMinutes() + \") is not valid\");\r", "}", "else", "if", "(", "SchedulingSupport", ".", "isWithinMinuteOfIntervalStart", "(", "officialTime", ",", "pageable", ".", "getPageIntervalInMinutes", "(", ")", ",", "pageable", ".", "getPageOffsetInMinutes", "(", ")", ")", "&&", "pageable", ".", "isStarted", "(", ")", ")", "{", "System", ".", "out", ".", "println", "(", "new", "LogEntry", "(", "\"scheduler about to page \"", "+", "StringSupport", ".", "trim", "(", "pageable", ".", "toString", "(", ")", "+", "\"'\"", ",", "80", ",", "\"...\"", ")", ")", ")", ";", "//the page method is invoked by a system session\r", "// so a developer may try to use it to outflank the security system\r", "//another risk is that the invoked method consumes too much time\r", "if", "(", "runAsync", ")", "{", "new", "Executable", "(", ")", "{", "public", "Object", "execute", "(", ")", "{", "try", "{", "pageable", ".", "onPageEvent", "(", "officialTime", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "//pageable is not a trusted component\r", "//TODO keep history\r", "System", ".", "out", ".", "println", "(", "new", "LogEntry", "(", "Level", ".", "CRITICAL", ",", "\"exception while paging pageable '\"", "+", "StringSupport", ".", "trim", "(", "pageable", ".", "toString", "(", ")", "+", "\"'\"", ",", "80", ",", "\"...\"", ")", ",", "e", ")", ")", ";", "}", "return", "null", ";", "}", "}", ".", "executeAsync", "(", ")", ";", "}", "else", "{", "try", "{", "pageable", ".", "onPageEvent", "(", "officialTime", ")", ";", "}", "catch", "(", "UndeclaredThrowableException", "e", ")", "{", "System", ".", "out", ".", "println", "(", "new", "LogEntry", "(", "Level", ".", "CRITICAL", ",", "\"undeclared exception while paging pageable '\"", "+", "StringSupport", ".", "trim", "(", "pageable", ".", "toString", "(", ")", "+", "\"'\"", ",", "80", ",", "\"...\"", ")", ",", "e", ".", "getCause", "(", ")", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "//pageable is not a trusted component\r", "System", ".", "out", ".", "println", "(", "new", "LogEntry", "(", "Level", ".", "CRITICAL", ",", "\"exception while paging pageable '\"", "+", "StringSupport", ".", "trim", "(", "pageable", ".", "toString", "(", ")", "+", "\"'\"", ",", "80", ",", "\"...\"", ")", ",", "e", ")", ")", ";", "}", "}", "}", "}", "lastCall", "=", "officialTime", ";", "}", "currentState", "=", "SCHEDULER_WAIT", ";", "}", "}", "currentState", "=", "SCHEDULER_HALT", ";", "}" ]
Code executed by scheduler thread.
[ "Code", "executed", "by", "scheduler", "thread", "." ]
0fb0885775b576209ff1b5a0f67e3c25a99a6420
https://github.com/jmeetsma/Iglu-Common/blob/0fb0885775b576209ff1b5a0f67e3c25a99a6420/src/main/java/org/ijsberg/iglu/scheduling/module/StandardScheduler.java#L160-L229
156,323
intellimate/Izou
src/main/java/org/intellimate/izou/system/SystemInitializer.java
SystemInitializer.initSystem
public void initSystem() { createIzouPropertiesFile(); setSystemProperties(); reloadFile(null); try { if (System.getProperty(IZOU_CONFIGURED).equals("false")) { fatal("Izou not completely configured, please configure Izou and launch again."); System.exit(0); } } catch (NullPointerException e) { fatal("Izou not completely configured, please configure Izou by editing izou.properties in the " + "properties folder and launch again."); System.exit(0); } }
java
public void initSystem() { createIzouPropertiesFile(); setSystemProperties(); reloadFile(null); try { if (System.getProperty(IZOU_CONFIGURED).equals("false")) { fatal("Izou not completely configured, please configure Izou and launch again."); System.exit(0); } } catch (NullPointerException e) { fatal("Izou not completely configured, please configure Izou by editing izou.properties in the " + "properties folder and launch again."); System.exit(0); } }
[ "public", "void", "initSystem", "(", ")", "{", "createIzouPropertiesFile", "(", ")", ";", "setSystemProperties", "(", ")", ";", "reloadFile", "(", "null", ")", ";", "try", "{", "if", "(", "System", ".", "getProperty", "(", "IZOU_CONFIGURED", ")", ".", "equals", "(", "\"false\"", ")", ")", "{", "fatal", "(", "\"Izou not completely configured, please configure Izou and launch again.\"", ")", ";", "System", ".", "exit", "(", "0", ")", ";", "}", "}", "catch", "(", "NullPointerException", "e", ")", "{", "fatal", "(", "\"Izou not completely configured, please configure Izou by editing izou.properties in the \"", "+", "\"properties folder and launch again.\"", ")", ";", "System", ".", "exit", "(", "0", ")", ";", "}", "}" ]
Initializes the system by calling all init methods
[ "Initializes", "the", "system", "by", "calling", "all", "init", "methods" ]
40a808b97998e17655c4a78e30ce7326148aed27
https://github.com/intellimate/Izou/blob/40a808b97998e17655c4a78e30ce7326148aed27/src/main/java/org/intellimate/izou/system/SystemInitializer.java#L39-L54
156,324
intellimate/Izou
src/main/java/org/intellimate/izou/system/SystemInitializer.java
SystemInitializer.registerWithPropertiesManager
public void registerWithPropertiesManager() { try { main.getFileManager().registerFileDir(propertiesFile.getParentFile().toPath(), propertiesFile.getName(), this); } catch (IOException e) { error("Unable to register "); } }
java
public void registerWithPropertiesManager() { try { main.getFileManager().registerFileDir(propertiesFile.getParentFile().toPath(), propertiesFile.getName(), this); } catch (IOException e) { error("Unable to register "); } }
[ "public", "void", "registerWithPropertiesManager", "(", ")", "{", "try", "{", "main", ".", "getFileManager", "(", ")", ".", "registerFileDir", "(", "propertiesFile", ".", "getParentFile", "(", ")", ".", "toPath", "(", ")", ",", "propertiesFile", ".", "getName", "(", ")", ",", "this", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "error", "(", "\"Unable to register \"", ")", ";", "}", "}" ]
This method registers the SystemInitializer with the Properties manager, but this can only be done once the properties manager has been created, thus this method is called later.
[ "This", "method", "registers", "the", "SystemInitializer", "with", "the", "Properties", "manager", "but", "this", "can", "only", "be", "done", "once", "the", "properties", "manager", "has", "been", "created", "thus", "this", "method", "is", "called", "later", "." ]
40a808b97998e17655c4a78e30ce7326148aed27
https://github.com/intellimate/Izou/blob/40a808b97998e17655c4a78e30ce7326148aed27/src/main/java/org/intellimate/izou/system/SystemInitializer.java#L60-L67
156,325
intellimate/Izou
src/main/java/org/intellimate/izou/system/SystemInitializer.java
SystemInitializer.createIzouPropertiesFile
private void createIzouPropertiesFile() { String propertiesPath = getMain().getFileSystemManager().getPropertiesLocation() + File.separator + IZOU_PROPERTIES_FILE_NAME; propertiesFile = new File(propertiesPath); if (!propertiesFile.exists()) try (PrintWriter writer = new PrintWriter(propertiesFile.getAbsolutePath(), "UTF-8")) { propertiesFile.createNewFile(); writer.println("# --------------------"); writer.println("# Izou Properties File"); writer.println("# --------------------"); writer.println("#"); writer.println("# This file has some general configuration options that have to be configured before"); writer.println("# Izou can run successfully."); } catch (IOException e) { error("Error while trying to create the new Properties file", e); } }
java
private void createIzouPropertiesFile() { String propertiesPath = getMain().getFileSystemManager().getPropertiesLocation() + File.separator + IZOU_PROPERTIES_FILE_NAME; propertiesFile = new File(propertiesPath); if (!propertiesFile.exists()) try (PrintWriter writer = new PrintWriter(propertiesFile.getAbsolutePath(), "UTF-8")) { propertiesFile.createNewFile(); writer.println("# --------------------"); writer.println("# Izou Properties File"); writer.println("# --------------------"); writer.println("#"); writer.println("# This file has some general configuration options that have to be configured before"); writer.println("# Izou can run successfully."); } catch (IOException e) { error("Error while trying to create the new Properties file", e); } }
[ "private", "void", "createIzouPropertiesFile", "(", ")", "{", "String", "propertiesPath", "=", "getMain", "(", ")", ".", "getFileSystemManager", "(", ")", ".", "getPropertiesLocation", "(", ")", "+", "File", ".", "separator", "+", "IZOU_PROPERTIES_FILE_NAME", ";", "propertiesFile", "=", "new", "File", "(", "propertiesPath", ")", ";", "if", "(", "!", "propertiesFile", ".", "exists", "(", ")", ")", "try", "(", "PrintWriter", "writer", "=", "new", "PrintWriter", "(", "propertiesFile", ".", "getAbsolutePath", "(", ")", ",", "\"UTF-8\"", ")", ")", "{", "propertiesFile", ".", "createNewFile", "(", ")", ";", "writer", ".", "println", "(", "\"# --------------------\"", ")", ";", "writer", ".", "println", "(", "\"# Izou Properties File\"", ")", ";", "writer", ".", "println", "(", "\"# --------------------\"", ")", ";", "writer", ".", "println", "(", "\"#\"", ")", ";", "writer", ".", "println", "(", "\"# This file has some general configuration options that have to be configured before\"", ")", ";", "writer", ".", "println", "(", "\"# Izou can run successfully.\"", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "error", "(", "\"Error while trying to create the new Properties file\"", ",", "e", ")", ";", "}", "}" ]
Creates the propreties file for Izou. This is the file that has to be configured before Izou can run and it contains some basic configuartion for Izou.
[ "Creates", "the", "propreties", "file", "for", "Izou", ".", "This", "is", "the", "file", "that", "has", "to", "be", "configured", "before", "Izou", "can", "run", "and", "it", "contains", "some", "basic", "configuartion", "for", "Izou", "." ]
40a808b97998e17655c4a78e30ce7326148aed27
https://github.com/intellimate/Izou/blob/40a808b97998e17655c4a78e30ce7326148aed27/src/main/java/org/intellimate/izou/system/SystemInitializer.java#L73-L90
156,326
intellimate/Izou
src/main/java/org/intellimate/izou/system/SystemInitializer.java
SystemInitializer.setLocalHostProperty
private void setLocalHostProperty() { String hostName = "unkown"; try { hostName = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { error("Unable to resolve hostname, setting hostname as 'unkown'"); } System.setProperty("host.name", hostName); }
java
private void setLocalHostProperty() { String hostName = "unkown"; try { hostName = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { error("Unable to resolve hostname, setting hostname as 'unkown'"); } System.setProperty("host.name", hostName); }
[ "private", "void", "setLocalHostProperty", "(", ")", "{", "String", "hostName", "=", "\"unkown\"", ";", "try", "{", "hostName", "=", "InetAddress", ".", "getLocalHost", "(", ")", ".", "getHostName", "(", ")", ";", "}", "catch", "(", "UnknownHostException", "e", ")", "{", "error", "(", "\"Unable to resolve hostname, setting hostname as 'unkown'\"", ")", ";", "}", "System", ".", "setProperty", "(", "\"host.name\"", ",", "hostName", ")", ";", "}" ]
Gets the local host if it can, and sets it as a system property
[ "Gets", "the", "local", "host", "if", "it", "can", "and", "sets", "it", "as", "a", "system", "property" ]
40a808b97998e17655c4a78e30ce7326148aed27
https://github.com/intellimate/Izou/blob/40a808b97998e17655c4a78e30ce7326148aed27/src/main/java/org/intellimate/izou/system/SystemInitializer.java#L102-L111
156,327
intellimate/Izou
src/main/java/org/intellimate/izou/system/SystemInitializer.java
SystemInitializer.reloadProperties
private void reloadProperties() { Properties temp = new Properties(); BufferedReader bufferedReader = null; try { bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(propertiesFile), "UTF8")); temp.load(bufferedReader); this.properties = temp; } catch (IOException e) { error("Error while trying to load the Properties-File: " + propertiesFile.getAbsolutePath(), e); } finally { if (bufferedReader != null) { try { bufferedReader.close(); } catch (IOException e) { error("Unable to close input stream", e); } } } }
java
private void reloadProperties() { Properties temp = new Properties(); BufferedReader bufferedReader = null; try { bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(propertiesFile), "UTF8")); temp.load(bufferedReader); this.properties = temp; } catch (IOException e) { error("Error while trying to load the Properties-File: " + propertiesFile.getAbsolutePath(), e); } finally { if (bufferedReader != null) { try { bufferedReader.close(); } catch (IOException e) { error("Unable to close input stream", e); } } } }
[ "private", "void", "reloadProperties", "(", ")", "{", "Properties", "temp", "=", "new", "Properties", "(", ")", ";", "BufferedReader", "bufferedReader", "=", "null", ";", "try", "{", "bufferedReader", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "new", "FileInputStream", "(", "propertiesFile", ")", ",", "\"UTF8\"", ")", ")", ";", "temp", ".", "load", "(", "bufferedReader", ")", ";", "this", ".", "properties", "=", "temp", ";", "}", "catch", "(", "IOException", "e", ")", "{", "error", "(", "\"Error while trying to load the Properties-File: \"", "+", "propertiesFile", ".", "getAbsolutePath", "(", ")", ",", "e", ")", ";", "}", "finally", "{", "if", "(", "bufferedReader", "!=", "null", ")", "{", "try", "{", "bufferedReader", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "error", "(", "\"Unable to close input stream\"", ",", "e", ")", ";", "}", "}", "}", "}" ]
Reload the properties from the properties file into the system properties
[ "Reload", "the", "properties", "from", "the", "properties", "file", "into", "the", "system", "properties" ]
40a808b97998e17655c4a78e30ce7326148aed27
https://github.com/intellimate/Izou/blob/40a808b97998e17655c4a78e30ce7326148aed27/src/main/java/org/intellimate/izou/system/SystemInitializer.java#L116-L135
156,328
adamfisk/littleshoot-util
src/main/java/org/littleshoot/util/BitUtils.java
BitUtils.toByteArray
public static byte[] toByteArray(final long l) { final byte[] bytes = new byte[8]; bytes[0] = (byte) ((l >>> 56) & 0xff); bytes[1] = (byte) ((l >>> 48) & 0xff); bytes[2] = (byte) ((l >>> 40) & 0xff); bytes[3] = (byte) ((l >>> 32) & 0xff); bytes[4] = (byte) ((l >>> 24) & 0xff); bytes[5] = (byte) ((l >>> 16) & 0xff); bytes[6] = (byte) ((l >>> 8) & 0xff); bytes[7] = (byte) ((l >>> 0) & 0xff); return bytes; }
java
public static byte[] toByteArray(final long l) { final byte[] bytes = new byte[8]; bytes[0] = (byte) ((l >>> 56) & 0xff); bytes[1] = (byte) ((l >>> 48) & 0xff); bytes[2] = (byte) ((l >>> 40) & 0xff); bytes[3] = (byte) ((l >>> 32) & 0xff); bytes[4] = (byte) ((l >>> 24) & 0xff); bytes[5] = (byte) ((l >>> 16) & 0xff); bytes[6] = (byte) ((l >>> 8) & 0xff); bytes[7] = (byte) ((l >>> 0) & 0xff); return bytes; }
[ "public", "static", "byte", "[", "]", "toByteArray", "(", "final", "long", "l", ")", "{", "final", "byte", "[", "]", "bytes", "=", "new", "byte", "[", "8", "]", ";", "bytes", "[", "0", "]", "=", "(", "byte", ")", "(", "(", "l", ">>>", "56", ")", "&", "0xff", ")", ";", "bytes", "[", "1", "]", "=", "(", "byte", ")", "(", "(", "l", ">>>", "48", ")", "&", "0xff", ")", ";", "bytes", "[", "2", "]", "=", "(", "byte", ")", "(", "(", "l", ">>>", "40", ")", "&", "0xff", ")", ";", "bytes", "[", "3", "]", "=", "(", "byte", ")", "(", "(", "l", ">>>", "32", ")", "&", "0xff", ")", ";", "bytes", "[", "4", "]", "=", "(", "byte", ")", "(", "(", "l", ">>>", "24", ")", "&", "0xff", ")", ";", "bytes", "[", "5", "]", "=", "(", "byte", ")", "(", "(", "l", ">>>", "16", ")", "&", "0xff", ")", ";", "bytes", "[", "6", "]", "=", "(", "byte", ")", "(", "(", "l", ">>>", "8", ")", "&", "0xff", ")", ";", "bytes", "[", "7", "]", "=", "(", "byte", ")", "(", "(", "l", ">>>", "0", ")", "&", "0xff", ")", ";", "return", "bytes", ";", "}" ]
Converts the specified long to an array of bytes. @param l The long to convert. @return The array of bytes with the most significant byte first.
[ "Converts", "the", "specified", "long", "to", "an", "array", "of", "bytes", "." ]
3c0dc4955116b3382d6b0575d2f164b7508a4f73
https://github.com/adamfisk/littleshoot-util/blob/3c0dc4955116b3382d6b0575d2f164b7508a4f73/src/main/java/org/littleshoot/util/BitUtils.java#L35-L47
156,329
kristiankime/FCollections
src/main/java/com/artclod/common/collect/ArrayFList.java
ArrayFList.mkString
public String mkString(String start, String sep, String end) { StringBuilder ret = new StringBuilder(start); for (int i = 0; i < inner.size(); i++) { ret.append(inner.get(i)); if (i != (inner.size() - 1)) { ret.append(sep); } } return ret.append(end).toString(); }
java
public String mkString(String start, String sep, String end) { StringBuilder ret = new StringBuilder(start); for (int i = 0; i < inner.size(); i++) { ret.append(inner.get(i)); if (i != (inner.size() - 1)) { ret.append(sep); } } return ret.append(end).toString(); }
[ "public", "String", "mkString", "(", "String", "start", ",", "String", "sep", ",", "String", "end", ")", "{", "StringBuilder", "ret", "=", "new", "StringBuilder", "(", "start", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "inner", ".", "size", "(", ")", ";", "i", "++", ")", "{", "ret", ".", "append", "(", "inner", ".", "get", "(", "i", ")", ")", ";", "if", "(", "i", "!=", "(", "inner", ".", "size", "(", ")", "-", "1", ")", ")", "{", "ret", ".", "append", "(", "sep", ")", ";", "}", "}", "return", "ret", ".", "append", "(", "end", ")", ".", "toString", "(", ")", ";", "}" ]
Looping without creating in iterator is faster so we reimplement some methods for speed
[ "Looping", "without", "creating", "in", "iterator", "is", "faster", "so", "we", "reimplement", "some", "methods", "for", "speed" ]
a72eccf3c91ab855b72bedb2f6c1c9ad1499710a
https://github.com/kristiankime/FCollections/blob/a72eccf3c91ab855b72bedb2f6c1c9ad1499710a/src/main/java/com/artclod/common/collect/ArrayFList.java#L109-L118
156,330
maestrano/maestrano-java
src/main/java/com/maestrano/sso/Session.java
Session.loadFromHttpSession
public static Session loadFromHttpSession(Preset preset, HttpSession httpSession) { String mnoSessEntry = (String) httpSession.getAttribute(MAESTRANO_SESSION_ID); if (mnoSessEntry == null) { return new Session(preset); } Map<String, String> sessionObj; try { Gson gson = new Gson(); String decryptedSession = new String(DatatypeConverter.parseBase64Binary(mnoSessEntry), "UTF-8"); Type type = new TypeToken<Map<String, String>>() { }.getType(); sessionObj = gson.fromJson(decryptedSession, type); } catch (Exception e) { logger.error("could not deserialized maestrano session: " + mnoSessEntry, e); throw new RuntimeException("could not deserialized maestrano session: " + mnoSessEntry, e); } // Assign attributes String uid = sessionObj.get("uid"); String groupUid = sessionObj.get("group_uid"); String sessionToken = sessionObj.get("session"); Date recheck; // Session Recheck try { recheck = MnoDateHelper.fromIso8601(sessionObj.get("session_recheck")); } catch (Exception e) { recheck = new Date((new Date()).getTime() - 1 * 60 * 1000); } return new Session(preset, uid, groupUid, recheck, sessionToken); }
java
public static Session loadFromHttpSession(Preset preset, HttpSession httpSession) { String mnoSessEntry = (String) httpSession.getAttribute(MAESTRANO_SESSION_ID); if (mnoSessEntry == null) { return new Session(preset); } Map<String, String> sessionObj; try { Gson gson = new Gson(); String decryptedSession = new String(DatatypeConverter.parseBase64Binary(mnoSessEntry), "UTF-8"); Type type = new TypeToken<Map<String, String>>() { }.getType(); sessionObj = gson.fromJson(decryptedSession, type); } catch (Exception e) { logger.error("could not deserialized maestrano session: " + mnoSessEntry, e); throw new RuntimeException("could not deserialized maestrano session: " + mnoSessEntry, e); } // Assign attributes String uid = sessionObj.get("uid"); String groupUid = sessionObj.get("group_uid"); String sessionToken = sessionObj.get("session"); Date recheck; // Session Recheck try { recheck = MnoDateHelper.fromIso8601(sessionObj.get("session_recheck")); } catch (Exception e) { recheck = new Date((new Date()).getTime() - 1 * 60 * 1000); } return new Session(preset, uid, groupUid, recheck, sessionToken); }
[ "public", "static", "Session", "loadFromHttpSession", "(", "Preset", "preset", ",", "HttpSession", "httpSession", ")", "{", "String", "mnoSessEntry", "=", "(", "String", ")", "httpSession", ".", "getAttribute", "(", "MAESTRANO_SESSION_ID", ")", ";", "if", "(", "mnoSessEntry", "==", "null", ")", "{", "return", "new", "Session", "(", "preset", ")", ";", "}", "Map", "<", "String", ",", "String", ">", "sessionObj", ";", "try", "{", "Gson", "gson", "=", "new", "Gson", "(", ")", ";", "String", "decryptedSession", "=", "new", "String", "(", "DatatypeConverter", ".", "parseBase64Binary", "(", "mnoSessEntry", ")", ",", "\"UTF-8\"", ")", ";", "Type", "type", "=", "new", "TypeToken", "<", "Map", "<", "String", ",", "String", ">", ">", "(", ")", "{", "}", ".", "getType", "(", ")", ";", "sessionObj", "=", "gson", ".", "fromJson", "(", "decryptedSession", ",", "type", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "error", "(", "\"could not deserialized maestrano session: \"", "+", "mnoSessEntry", ",", "e", ")", ";", "throw", "new", "RuntimeException", "(", "\"could not deserialized maestrano session: \"", "+", "mnoSessEntry", ",", "e", ")", ";", "}", "// Assign attributes", "String", "uid", "=", "sessionObj", ".", "get", "(", "\"uid\"", ")", ";", "String", "groupUid", "=", "sessionObj", ".", "get", "(", "\"group_uid\"", ")", ";", "String", "sessionToken", "=", "sessionObj", ".", "get", "(", "\"session\"", ")", ";", "Date", "recheck", ";", "// Session Recheck", "try", "{", "recheck", "=", "MnoDateHelper", ".", "fromIso8601", "(", "sessionObj", ".", "get", "(", "\"session_recheck\"", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "recheck", "=", "new", "Date", "(", "(", "new", "Date", "(", ")", ")", ".", "getTime", "(", ")", "-", "1", "*", "60", "*", "1000", ")", ";", "}", "return", "new", "Session", "(", "preset", ",", "uid", ",", "groupUid", ",", "recheck", ",", "sessionToken", ")", ";", "}" ]
Retrieving Maestrano session from httpSession, returns an empty Session if there is no Session @param marketplace marketplace previously configured @param HttpSession httpSession
[ "Retrieving", "Maestrano", "session", "from", "httpSession", "returns", "an", "empty", "Session", "if", "there", "is", "no", "Session" ]
e71c6d3172d7645529d678d1cb3ea9e0a59de314
https://github.com/maestrano/maestrano-java/blob/e71c6d3172d7645529d678d1cb3ea9e0a59de314/src/main/java/com/maestrano/sso/Session.java#L82-L113
156,331
maestrano/maestrano-java
src/main/java/com/maestrano/sso/Session.java
Session.isValid
public boolean isValid(MnoHttpClient httpClient) { if (uid == null) { return false; } if (isRemoteCheckRequired()) { if (this.performRemoteCheck(httpClient)) { return true; } else { return false; } } return true; }
java
public boolean isValid(MnoHttpClient httpClient) { if (uid == null) { return false; } if (isRemoteCheckRequired()) { if (this.performRemoteCheck(httpClient)) { return true; } else { return false; } } return true; }
[ "public", "boolean", "isValid", "(", "MnoHttpClient", "httpClient", ")", "{", "if", "(", "uid", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(", "isRemoteCheckRequired", "(", ")", ")", "{", "if", "(", "this", ".", "performRemoteCheck", "(", "httpClient", ")", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Return whether the session is valid or not. Perform remote check to maestrano if recheck is overdue. @param MnoHttpClient http client @return boolean session valid
[ "Return", "whether", "the", "session", "is", "valid", "or", "not", ".", "Perform", "remote", "check", "to", "maestrano", "if", "recheck", "is", "overdue", "." ]
e71c6d3172d7645529d678d1cb3ea9e0a59de314
https://github.com/maestrano/maestrano-java/blob/e71c6d3172d7645529d678d1cb3ea9e0a59de314/src/main/java/com/maestrano/sso/Session.java#L131-L143
156,332
maestrano/maestrano-java
src/main/java/com/maestrano/sso/Session.java
Session.save
public void save(HttpSession httpSession) { String sessionSerialized = serializeSession(); // Finally store the maestrano session httpSession.setAttribute(MAESTRANO_SESSION_ID, sessionSerialized); }
java
public void save(HttpSession httpSession) { String sessionSerialized = serializeSession(); // Finally store the maestrano session httpSession.setAttribute(MAESTRANO_SESSION_ID, sessionSerialized); }
[ "public", "void", "save", "(", "HttpSession", "httpSession", ")", "{", "String", "sessionSerialized", "=", "serializeSession", "(", ")", ";", "// Finally store the maestrano session", "httpSession", ".", "setAttribute", "(", "MAESTRANO_SESSION_ID", ",", "sessionSerialized", ")", ";", "}" ]
Save the Maestrano session in HTTP Session
[ "Save", "the", "Maestrano", "session", "in", "HTTP", "Session" ]
e71c6d3172d7645529d678d1cb3ea9e0a59de314
https://github.com/maestrano/maestrano-java/blob/e71c6d3172d7645529d678d1cb3ea9e0a59de314/src/main/java/com/maestrano/sso/Session.java#L148-L152
156,333
maestrano/maestrano-java
src/main/java/com/maestrano/sso/Session.java
Session.performRemoteCheck
boolean performRemoteCheck(MnoHttpClient httpClient) { // Prepare request String url = sso.getSessionCheckUrl(this.uid, this.sessionToken); String respStr; try { respStr = httpClient.get(url); } catch (AuthenticationException e1) { // TODO log error e1.printStackTrace(); return false; } catch (ApiException e1) { // TODO log error e1.printStackTrace(); return false; } // Parse response Gson gson = new Gson(); Type type = new TypeToken<Map<String, String>>() { }.getType(); Map<String, String> respObj = gson.fromJson(respStr, type); Boolean isValid = (respObj.get("valid") != null && respObj.get("valid").equals("true")); if (isValid) { try { this.recheck = MnoDateHelper.fromIso8601(respObj.get("recheck")); } catch (Exception e) { return false; } return true; } return false; }
java
boolean performRemoteCheck(MnoHttpClient httpClient) { // Prepare request String url = sso.getSessionCheckUrl(this.uid, this.sessionToken); String respStr; try { respStr = httpClient.get(url); } catch (AuthenticationException e1) { // TODO log error e1.printStackTrace(); return false; } catch (ApiException e1) { // TODO log error e1.printStackTrace(); return false; } // Parse response Gson gson = new Gson(); Type type = new TypeToken<Map<String, String>>() { }.getType(); Map<String, String> respObj = gson.fromJson(respStr, type); Boolean isValid = (respObj.get("valid") != null && respObj.get("valid").equals("true")); if (isValid) { try { this.recheck = MnoDateHelper.fromIso8601(respObj.get("recheck")); } catch (Exception e) { return false; } return true; } return false; }
[ "boolean", "performRemoteCheck", "(", "MnoHttpClient", "httpClient", ")", "{", "// Prepare request", "String", "url", "=", "sso", ".", "getSessionCheckUrl", "(", "this", ".", "uid", ",", "this", ".", "sessionToken", ")", ";", "String", "respStr", ";", "try", "{", "respStr", "=", "httpClient", ".", "get", "(", "url", ")", ";", "}", "catch", "(", "AuthenticationException", "e1", ")", "{", "// TODO log error", "e1", ".", "printStackTrace", "(", ")", ";", "return", "false", ";", "}", "catch", "(", "ApiException", "e1", ")", "{", "// TODO log error", "e1", ".", "printStackTrace", "(", ")", ";", "return", "false", ";", "}", "// Parse response", "Gson", "gson", "=", "new", "Gson", "(", ")", ";", "Type", "type", "=", "new", "TypeToken", "<", "Map", "<", "String", ",", "String", ">", ">", "(", ")", "{", "}", ".", "getType", "(", ")", ";", "Map", "<", "String", ",", "String", ">", "respObj", "=", "gson", ".", "fromJson", "(", "respStr", ",", "type", ")", ";", "Boolean", "isValid", "=", "(", "respObj", ".", "get", "(", "\"valid\"", ")", "!=", "null", "&&", "respObj", ".", "get", "(", "\"valid\"", ")", ".", "equals", "(", "\"true\"", ")", ")", ";", "if", "(", "isValid", ")", "{", "try", "{", "this", ".", "recheck", "=", "MnoDateHelper", ".", "fromIso8601", "(", "respObj", ".", "get", "(", "\"recheck\"", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}" ]
Check whether the remote maestrano session is still valid package private for testing
[ "Check", "whether", "the", "remote", "maestrano", "session", "is", "still", "valid" ]
e71c6d3172d7645529d678d1cb3ea9e0a59de314
https://github.com/maestrano/maestrano-java/blob/e71c6d3172d7645529d678d1cb3ea9e0a59de314/src/main/java/com/maestrano/sso/Session.java#L170-L203
156,334
frtu/SimpleToolbox
SimpleScanner/src/main/java/com/github/frtu/simple/scan/DirectoryScanner.java
DirectoryScanner.dealWithFile
private void dealWithFile(File file) { // Browse thru Map SelectiveFileScannerObserver specificFileScanner = selectiveFileScannerMap.get(file.getName()); if (specificFileScanner != null) { logger.debug("Launching fileScanner={} for file={}", specificFileScanner.getClass(), file.getAbsoluteFile()); specificFileScanner.scanFile(file); } // Browse thru List for (FileScannerObserver fileScanner : fileScanners) { logger.debug("Launching fileScanner={} for file={}", fileScanner.getClass(), file.getAbsoluteFile()); fileScanner.scanFile(file); } }
java
private void dealWithFile(File file) { // Browse thru Map SelectiveFileScannerObserver specificFileScanner = selectiveFileScannerMap.get(file.getName()); if (specificFileScanner != null) { logger.debug("Launching fileScanner={} for file={}", specificFileScanner.getClass(), file.getAbsoluteFile()); specificFileScanner.scanFile(file); } // Browse thru List for (FileScannerObserver fileScanner : fileScanners) { logger.debug("Launching fileScanner={} for file={}", fileScanner.getClass(), file.getAbsoluteFile()); fileScanner.scanFile(file); } }
[ "private", "void", "dealWithFile", "(", "File", "file", ")", "{", "// Browse thru Map", "SelectiveFileScannerObserver", "specificFileScanner", "=", "selectiveFileScannerMap", ".", "get", "(", "file", ".", "getName", "(", ")", ")", ";", "if", "(", "specificFileScanner", "!=", "null", ")", "{", "logger", ".", "debug", "(", "\"Launching fileScanner={} for file={}\"", ",", "specificFileScanner", ".", "getClass", "(", ")", ",", "file", ".", "getAbsoluteFile", "(", ")", ")", ";", "specificFileScanner", ".", "scanFile", "(", "file", ")", ";", "}", "// Browse thru List", "for", "(", "FileScannerObserver", "fileScanner", ":", "fileScanners", ")", "{", "logger", ".", "debug", "(", "\"Launching fileScanner={} for file={}\"", ",", "fileScanner", ".", "getClass", "(", ")", ",", "file", ".", "getAbsoluteFile", "(", ")", ")", ";", "fileScanner", ".", "scanFile", "(", "file", ")", ";", "}", "}" ]
deal with the file that need to be parsed specific @param file
[ "deal", "with", "the", "file", "that", "need", "to", "be", "parsed", "specific" ]
097321efc8bf082a1a2d5bf1bf1453f805a17092
https://github.com/frtu/SimpleToolbox/blob/097321efc8bf082a1a2d5bf1bf1453f805a17092/SimpleScanner/src/main/java/com/github/frtu/simple/scan/DirectoryScanner.java#L140-L153
156,335
matthewhorridge/mdock
src/main/java/org/coode/mdock/SplitterNode.java
SplitterNode.getSplits
public List<Double> getSplits() { List<Double> splits = new ArrayList<Double>(); for (Node curNode : getVisibleChildren()) { splits.add(nodeSplits.get(curNode)); } return splits; }
java
public List<Double> getSplits() { List<Double> splits = new ArrayList<Double>(); for (Node curNode : getVisibleChildren()) { splits.add(nodeSplits.get(curNode)); } return splits; }
[ "public", "List", "<", "Double", ">", "getSplits", "(", ")", "{", "List", "<", "Double", ">", "splits", "=", "new", "ArrayList", "<", "Double", ">", "(", ")", ";", "for", "(", "Node", "curNode", ":", "getVisibleChildren", "(", ")", ")", "{", "splits", ".", "add", "(", "nodeSplits", ".", "get", "(", "curNode", ")", ")", ";", "}", "return", "splits", ";", "}" ]
Gets the child node splits. @return A list of child node splits
[ "Gets", "the", "child", "node", "splits", "." ]
37839a56f30bdb73d56d82c4d1afe548d66b404b
https://github.com/matthewhorridge/mdock/blob/37839a56f30bdb73d56d82c4d1afe548d66b404b/src/main/java/org/coode/mdock/SplitterNode.java#L103-L109
156,336
matthewhorridge/mdock
src/main/java/org/coode/mdock/SplitterNode.java
SplitterNode.getChildSpan
public double getChildSpan() { double span = 0.0; for (Node node : getVisibleChildren()) { span += nodeSplits.get(node); } return span; }
java
public double getChildSpan() { double span = 0.0; for (Node node : getVisibleChildren()) { span += nodeSplits.get(node); } return span; }
[ "public", "double", "getChildSpan", "(", ")", "{", "double", "span", "=", "0.0", ";", "for", "(", "Node", "node", ":", "getVisibleChildren", "(", ")", ")", "{", "span", "+=", "nodeSplits", ".", "get", "(", "node", ")", ";", "}", "return", "span", ";", "}" ]
Gets the sum of the visible child node splits. @return The sum of the splits
[ "Gets", "the", "sum", "of", "the", "visible", "child", "node", "splits", "." ]
37839a56f30bdb73d56d82c4d1afe548d66b404b
https://github.com/matthewhorridge/mdock/blob/37839a56f30bdb73d56d82c4d1afe548d66b404b/src/main/java/org/coode/mdock/SplitterNode.java#L139-L145
156,337
matthewhorridge/mdock
src/main/java/org/coode/mdock/SplitterNode.java
SplitterNode.getVisibleChildren
public List<Node> getVisibleChildren() { List<Node> visibleChildren = new ArrayList<Node>(); for (Node curChild : children) { if (curChild.isVisible()) { visibleChildren.add(curChild); } } return visibleChildren; }
java
public List<Node> getVisibleChildren() { List<Node> visibleChildren = new ArrayList<Node>(); for (Node curChild : children) { if (curChild.isVisible()) { visibleChildren.add(curChild); } } return visibleChildren; }
[ "public", "List", "<", "Node", ">", "getVisibleChildren", "(", ")", "{", "List", "<", "Node", ">", "visibleChildren", "=", "new", "ArrayList", "<", "Node", ">", "(", ")", ";", "for", "(", "Node", "curChild", ":", "children", ")", "{", "if", "(", "curChild", ".", "isVisible", "(", ")", ")", "{", "visibleChildren", ".", "add", "(", "curChild", ")", ";", "}", "}", "return", "visibleChildren", ";", "}" ]
Gets a list of visible child nodes. @return The list of children.
[ "Gets", "a", "list", "of", "visible", "child", "nodes", "." ]
37839a56f30bdb73d56d82c4d1afe548d66b404b
https://github.com/matthewhorridge/mdock/blob/37839a56f30bdb73d56d82c4d1afe548d66b404b/src/main/java/org/coode/mdock/SplitterNode.java#L152-L160
156,338
matthewhorridge/mdock
src/main/java/org/coode/mdock/SplitterNode.java
SplitterNode.addChild
protected void addChild(Node child, int index, double split) { children.add(index, child); nodeSplits.put(child, split); child.setParent(this); }
java
protected void addChild(Node child, int index, double split) { children.add(index, child); nodeSplits.put(child, split); child.setParent(this); }
[ "protected", "void", "addChild", "(", "Node", "child", ",", "int", "index", ",", "double", "split", ")", "{", "children", ".", "add", "(", "index", ",", "child", ")", ";", "nodeSplits", ".", "put", "(", "child", ",", "split", ")", ";", "child", ".", "setParent", "(", "this", ")", ";", "}" ]
Adds a child of this node. @param child The child node to be added @param index The position of the child node. @param split The amount/weighting of parent node that the child node should receive
[ "Adds", "a", "child", "of", "this", "node", "." ]
37839a56f30bdb73d56d82c4d1afe548d66b404b
https://github.com/matthewhorridge/mdock/blob/37839a56f30bdb73d56d82c4d1afe548d66b404b/src/main/java/org/coode/mdock/SplitterNode.java#L217-L221
156,339
matthewhorridge/mdock
src/main/java/org/coode/mdock/SplitterNode.java
SplitterNode.replaceChild
public void replaceChild(Node current, Node with) { double currentSplit = nodeSplits.get(current); int index = children.indexOf(current); children.remove(current); addChild(with, index, currentSplit); notifyStateChange(); }
java
public void replaceChild(Node current, Node with) { double currentSplit = nodeSplits.get(current); int index = children.indexOf(current); children.remove(current); addChild(with, index, currentSplit); notifyStateChange(); }
[ "public", "void", "replaceChild", "(", "Node", "current", ",", "Node", "with", ")", "{", "double", "currentSplit", "=", "nodeSplits", ".", "get", "(", "current", ")", ";", "int", "index", "=", "children", ".", "indexOf", "(", "current", ")", ";", "children", ".", "remove", "(", "current", ")", ";", "addChild", "(", "with", ",", "index", ",", "currentSplit", ")", ";", "notifyStateChange", "(", ")", ";", "}" ]
Replaces a child node with another node @param current The child node which should be replaced @param with The node that the child node should be replaced with
[ "Replaces", "a", "child", "node", "with", "another", "node" ]
37839a56f30bdb73d56d82c4d1afe548d66b404b
https://github.com/matthewhorridge/mdock/blob/37839a56f30bdb73d56d82c4d1afe548d66b404b/src/main/java/org/coode/mdock/SplitterNode.java#L318-L324
156,340
dihedron/dihedron-commons
src/main/java/org/dihedron/Commons.java
Commons.valueOf
public static String valueOf(Traits trait) { synchronized(Commons.class) { if(singleton == null) { singleton = new Commons(); } } return singleton.get(trait); }
java
public static String valueOf(Traits trait) { synchronized(Commons.class) { if(singleton == null) { singleton = new Commons(); } } return singleton.get(trait); }
[ "public", "static", "String", "valueOf", "(", "Traits", "trait", ")", "{", "synchronized", "(", "Commons", ".", "class", ")", "{", "if", "(", "singleton", "==", "null", ")", "{", "singleton", "=", "new", "Commons", "(", ")", ";", "}", "}", "return", "singleton", ".", "get", "(", "trait", ")", ";", "}" ]
Returns the value of the give trait. @param trait the trait to retrieve. @return the value of the trait.
[ "Returns", "the", "value", "of", "the", "give", "trait", "." ]
a5194cdaa0d6417ef4aade6ea407a1cad6e8458e
https://github.com/dihedron/dihedron-commons/blob/a5194cdaa0d6417ef4aade6ea407a1cad6e8458e/src/main/java/org/dihedron/Commons.java#L42-L49
156,341
trellis-ldp-archive/trellis-http
src/main/java/org/trellisldp/http/impl/BaseLdpHandler.java
BaseLdpHandler.checkDeleted
protected static void checkDeleted(final Resource res, final String identifier) { if (RdfUtils.isDeleted(res)) { throw new WebApplicationException(status(GONE) .links(MementoResource.getMementoLinks(identifier, res.getMementos()) .toArray(Link[]::new)).build()); } }
java
protected static void checkDeleted(final Resource res, final String identifier) { if (RdfUtils.isDeleted(res)) { throw new WebApplicationException(status(GONE) .links(MementoResource.getMementoLinks(identifier, res.getMementos()) .toArray(Link[]::new)).build()); } }
[ "protected", "static", "void", "checkDeleted", "(", "final", "Resource", "res", ",", "final", "String", "identifier", ")", "{", "if", "(", "RdfUtils", ".", "isDeleted", "(", "res", ")", ")", "{", "throw", "new", "WebApplicationException", "(", "status", "(", "GONE", ")", ".", "links", "(", "MementoResource", ".", "getMementoLinks", "(", "identifier", ",", "res", ".", "getMementos", "(", ")", ")", ".", "toArray", "(", "Link", "[", "]", "::", "new", ")", ")", ".", "build", "(", ")", ")", ";", "}", "}" ]
Check if this is a deleted resource, and if so return an appropriate response @param res the resource @param identifier the identifier @throws WebApplicationException a 410 Gone exception
[ "Check", "if", "this", "is", "a", "deleted", "resource", "and", "if", "so", "return", "an", "appropriate", "response" ]
bc762f88602c49c2b137a7adf68d576666e55fff
https://github.com/trellis-ldp-archive/trellis-http/blob/bc762f88602c49c2b137a7adf68d576666e55fff/src/main/java/org/trellisldp/http/impl/BaseLdpHandler.java#L89-L95
156,342
trellis-ldp-archive/trellis-http
src/main/java/org/trellisldp/http/impl/BaseLdpHandler.java
BaseLdpHandler.checkCache
protected static void checkCache(final Request request, final Instant modified, final EntityTag etag) { final ResponseBuilder builder = request.evaluatePreconditions(from(modified), etag); if (nonNull(builder)) { throw new WebApplicationException(builder.build()); } }
java
protected static void checkCache(final Request request, final Instant modified, final EntityTag etag) { final ResponseBuilder builder = request.evaluatePreconditions(from(modified), etag); if (nonNull(builder)) { throw new WebApplicationException(builder.build()); } }
[ "protected", "static", "void", "checkCache", "(", "final", "Request", "request", ",", "final", "Instant", "modified", ",", "final", "EntityTag", "etag", ")", "{", "final", "ResponseBuilder", "builder", "=", "request", ".", "evaluatePreconditions", "(", "from", "(", "modified", ")", ",", "etag", ")", ";", "if", "(", "nonNull", "(", "builder", ")", ")", "{", "throw", "new", "WebApplicationException", "(", "builder", ".", "build", "(", ")", ")", ";", "}", "}" ]
Check the request for a cache-related response @param request the request @param modified the modified time @param etag the etag @throws WebApplicationException either a 412 Precondition Failed or a 304 Not Modified, depending on the context.
[ "Check", "the", "request", "for", "a", "cache", "-", "related", "response" ]
bc762f88602c49c2b137a7adf68d576666e55fff
https://github.com/trellis-ldp-archive/trellis-http/blob/bc762f88602c49c2b137a7adf68d576666e55fff/src/main/java/org/trellisldp/http/impl/BaseLdpHandler.java#L112-L117
156,343
bwkimmel/java-util
src/main/java/ca/eandb/util/args/ArgumentProcessor.java
ArgumentProcessor.createOption
private Command<? super T> createOption(String fieldName, Class<?> type) { if (type == Integer.class || type == int.class) { return new IntegerFieldOption<T>(fieldName); } else if (type == Long.class || type == long.class) { return new LongFieldOption<T>(fieldName); } else if (type == Boolean.class || type == boolean.class) { return new BooleanFieldOption<T>(fieldName); } else if (type == String.class) { return new StringFieldOption<T>(fieldName); } else if (type == Double.class || type == double.class) { return new DoubleFieldOption<T>(fieldName); } else if (type == Float.class || type == float.class) { return new FloatFieldOption<T>(fieldName); } else if (type == File.class) { return new FileFieldOption<T>(fieldName); } throw new IllegalArgumentException("Cannot create option for parameter of type `" + type.getName() + "'"); }
java
private Command<? super T> createOption(String fieldName, Class<?> type) { if (type == Integer.class || type == int.class) { return new IntegerFieldOption<T>(fieldName); } else if (type == Long.class || type == long.class) { return new LongFieldOption<T>(fieldName); } else if (type == Boolean.class || type == boolean.class) { return new BooleanFieldOption<T>(fieldName); } else if (type == String.class) { return new StringFieldOption<T>(fieldName); } else if (type == Double.class || type == double.class) { return new DoubleFieldOption<T>(fieldName); } else if (type == Float.class || type == float.class) { return new FloatFieldOption<T>(fieldName); } else if (type == File.class) { return new FileFieldOption<T>(fieldName); } throw new IllegalArgumentException("Cannot create option for parameter of type `" + type.getName() + "'"); }
[ "private", "Command", "<", "?", "super", "T", ">", "createOption", "(", "String", "fieldName", ",", "Class", "<", "?", ">", "type", ")", "{", "if", "(", "type", "==", "Integer", ".", "class", "||", "type", "==", "int", ".", "class", ")", "{", "return", "new", "IntegerFieldOption", "<", "T", ">", "(", "fieldName", ")", ";", "}", "else", "if", "(", "type", "==", "Long", ".", "class", "||", "type", "==", "long", ".", "class", ")", "{", "return", "new", "LongFieldOption", "<", "T", ">", "(", "fieldName", ")", ";", "}", "else", "if", "(", "type", "==", "Boolean", ".", "class", "||", "type", "==", "boolean", ".", "class", ")", "{", "return", "new", "BooleanFieldOption", "<", "T", ">", "(", "fieldName", ")", ";", "}", "else", "if", "(", "type", "==", "String", ".", "class", ")", "{", "return", "new", "StringFieldOption", "<", "T", ">", "(", "fieldName", ")", ";", "}", "else", "if", "(", "type", "==", "Double", ".", "class", "||", "type", "==", "double", ".", "class", ")", "{", "return", "new", "DoubleFieldOption", "<", "T", ">", "(", "fieldName", ")", ";", "}", "else", "if", "(", "type", "==", "Float", ".", "class", "||", "type", "==", "float", ".", "class", ")", "{", "return", "new", "FloatFieldOption", "<", "T", ">", "(", "fieldName", ")", ";", "}", "else", "if", "(", "type", "==", "File", ".", "class", ")", "{", "return", "new", "FileFieldOption", "<", "T", ">", "(", "fieldName", ")", ";", "}", "throw", "new", "IllegalArgumentException", "(", "\"Cannot create option for parameter of type `\"", "+", "type", ".", "getName", "(", ")", "+", "\"'\"", ")", ";", "}" ]
Creates an option for the specified field and type. @param fieldName The name of the field to create the option handler for. @param type The type of the field to create the option handler for. @return The <code>Command</code> to process the option.
[ "Creates", "an", "option", "for", "the", "specified", "field", "and", "type", "." ]
0c03664d42f0e6b111f64447f222aa73c2819e5c
https://github.com/bwkimmel/java-util/blob/0c03664d42f0e6b111f64447f222aa73c2819e5c/src/main/java/ca/eandb/util/args/ArgumentProcessor.java#L228-L245
156,344
bwkimmel/java-util
src/main/java/ca/eandb/util/args/ArgumentProcessor.java
ArgumentProcessor.processCommandField
private void processCommandField(final Field field, String key, String prompt) { String name = field.getName(); Class<?> type = field.getType(); if (key.equals("")) { key = name; } if (prompt != null && prompt.equals("")) { prompt = key; } final ArgumentProcessor<Object> argProcessor = new ArgumentProcessor<Object>(prompt); argProcessor.setDefaultCommand(UnrecognizedCommand.getInstance()); argProcessor.processAnnotations(type); addCommand(key, new Command<T>() { public void process(Queue<String> argq, T state) { try { Object value = field.get(state); argProcessor.process(argq, value); } catch (IllegalArgumentException e) { throw new UnexpectedException(e); } catch (IllegalAccessException e) { throw new UnexpectedException(e); } } }); }
java
private void processCommandField(final Field field, String key, String prompt) { String name = field.getName(); Class<?> type = field.getType(); if (key.equals("")) { key = name; } if (prompt != null && prompt.equals("")) { prompt = key; } final ArgumentProcessor<Object> argProcessor = new ArgumentProcessor<Object>(prompt); argProcessor.setDefaultCommand(UnrecognizedCommand.getInstance()); argProcessor.processAnnotations(type); addCommand(key, new Command<T>() { public void process(Queue<String> argq, T state) { try { Object value = field.get(state); argProcessor.process(argq, value); } catch (IllegalArgumentException e) { throw new UnexpectedException(e); } catch (IllegalAccessException e) { throw new UnexpectedException(e); } } }); }
[ "private", "void", "processCommandField", "(", "final", "Field", "field", ",", "String", "key", ",", "String", "prompt", ")", "{", "String", "name", "=", "field", ".", "getName", "(", ")", ";", "Class", "<", "?", ">", "type", "=", "field", ".", "getType", "(", ")", ";", "if", "(", "key", ".", "equals", "(", "\"\"", ")", ")", "{", "key", "=", "name", ";", "}", "if", "(", "prompt", "!=", "null", "&&", "prompt", ".", "equals", "(", "\"\"", ")", ")", "{", "prompt", "=", "key", ";", "}", "final", "ArgumentProcessor", "<", "Object", ">", "argProcessor", "=", "new", "ArgumentProcessor", "<", "Object", ">", "(", "prompt", ")", ";", "argProcessor", ".", "setDefaultCommand", "(", "UnrecognizedCommand", ".", "getInstance", "(", ")", ")", ";", "argProcessor", ".", "processAnnotations", "(", "type", ")", ";", "addCommand", "(", "key", ",", "new", "Command", "<", "T", ">", "(", ")", "{", "public", "void", "process", "(", "Queue", "<", "String", ">", "argq", ",", "T", "state", ")", "{", "try", "{", "Object", "value", "=", "field", ".", "get", "(", "state", ")", ";", "argProcessor", ".", "process", "(", "argq", ",", "value", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "throw", "new", "UnexpectedException", "(", "e", ")", ";", "}", "catch", "(", "IllegalAccessException", "e", ")", "{", "throw", "new", "UnexpectedException", "(", "e", ")", ";", "}", "}", "}", ")", ";", "}" ]
Adds a command that passes control to the specified field. @param field The <code>Field</code> to pass control to. @param key The key that triggers the command. @param prompt The <code>String</code> to use to prompt the user for input, or <code>null</code> if no shell should be used.
[ "Adds", "a", "command", "that", "passes", "control", "to", "the", "specified", "field", "." ]
0c03664d42f0e6b111f64447f222aa73c2819e5c
https://github.com/bwkimmel/java-util/blob/0c03664d42f0e6b111f64447f222aa73c2819e5c/src/main/java/ca/eandb/util/args/ArgumentProcessor.java#L277-L305
156,345
bwkimmel/java-util
src/main/java/ca/eandb/util/args/ArgumentProcessor.java
ArgumentProcessor.processField
private void processField(Field field) { OptionArgument optAnnotation = field.getAnnotation(OptionArgument.class); if (optAnnotation != null) { processOptionField(field, optAnnotation.value(), optAnnotation.shortKey()); } else { CommandArgument cmdAnnotation = field.getAnnotation(CommandArgument.class); if (cmdAnnotation != null) { processCommandField(field, cmdAnnotation.value(), null); } else { ShellArgument shellAnnotation = field.getAnnotation(ShellArgument.class); if (shellAnnotation != null) { processCommandField(field, shellAnnotation.value(), shellAnnotation.prompt()); } } } }
java
private void processField(Field field) { OptionArgument optAnnotation = field.getAnnotation(OptionArgument.class); if (optAnnotation != null) { processOptionField(field, optAnnotation.value(), optAnnotation.shortKey()); } else { CommandArgument cmdAnnotation = field.getAnnotation(CommandArgument.class); if (cmdAnnotation != null) { processCommandField(field, cmdAnnotation.value(), null); } else { ShellArgument shellAnnotation = field.getAnnotation(ShellArgument.class); if (shellAnnotation != null) { processCommandField(field, shellAnnotation.value(), shellAnnotation.prompt()); } } } }
[ "private", "void", "processField", "(", "Field", "field", ")", "{", "OptionArgument", "optAnnotation", "=", "field", ".", "getAnnotation", "(", "OptionArgument", ".", "class", ")", ";", "if", "(", "optAnnotation", "!=", "null", ")", "{", "processOptionField", "(", "field", ",", "optAnnotation", ".", "value", "(", ")", ",", "optAnnotation", ".", "shortKey", "(", ")", ")", ";", "}", "else", "{", "CommandArgument", "cmdAnnotation", "=", "field", ".", "getAnnotation", "(", "CommandArgument", ".", "class", ")", ";", "if", "(", "cmdAnnotation", "!=", "null", ")", "{", "processCommandField", "(", "field", ",", "cmdAnnotation", ".", "value", "(", ")", ",", "null", ")", ";", "}", "else", "{", "ShellArgument", "shellAnnotation", "=", "field", ".", "getAnnotation", "(", "ShellArgument", ".", "class", ")", ";", "if", "(", "shellAnnotation", "!=", "null", ")", "{", "processCommandField", "(", "field", ",", "shellAnnotation", ".", "value", "(", ")", ",", "shellAnnotation", ".", "prompt", "(", ")", ")", ";", "}", "}", "}", "}" ]
Processes the relevant annotations on the given field and adds the required options or commands. @param field The <code>Field</code> to process.
[ "Processes", "the", "relevant", "annotations", "on", "the", "given", "field", "and", "adds", "the", "required", "options", "or", "commands", "." ]
0c03664d42f0e6b111f64447f222aa73c2819e5c
https://github.com/bwkimmel/java-util/blob/0c03664d42f0e6b111f64447f222aa73c2819e5c/src/main/java/ca/eandb/util/args/ArgumentProcessor.java#L312-L327
156,346
bwkimmel/java-util
src/main/java/ca/eandb/util/args/ArgumentProcessor.java
ArgumentProcessor.addOption
public void addOption(String key, char shortKey, Command<? super T> handler) { options.put(key, handler); shortcuts.put(shortKey, key); }
java
public void addOption(String key, char shortKey, Command<? super T> handler) { options.put(key, handler); shortcuts.put(shortKey, key); }
[ "public", "void", "addOption", "(", "String", "key", ",", "char", "shortKey", ",", "Command", "<", "?", "super", "T", ">", "handler", ")", "{", "options", ".", "put", "(", "key", ",", "handler", ")", ";", "shortcuts", ".", "put", "(", "shortKey", ",", "key", ")", ";", "}" ]
Add a command line option handler. @param key The <code>String</code> that identifies this option. The option may be triggered by specifying <code>--&lt;key&gt;</code> on the command line. @param shortKey The <code>char</code> that serves as a shortcut to the option. The option may be triggered by specifying <code>-&lt;shortKey&gt;</code> on the command line. @param handler The <code>Command</code> that is used to process the option.
[ "Add", "a", "command", "line", "option", "handler", "." ]
0c03664d42f0e6b111f64447f222aa73c2819e5c
https://github.com/bwkimmel/java-util/blob/0c03664d42f0e6b111f64447f222aa73c2819e5c/src/main/java/ca/eandb/util/args/ArgumentProcessor.java#L525-L529
156,347
bwkimmel/java-util
src/main/java/ca/eandb/util/args/ArgumentProcessor.java
ArgumentProcessor.addCommand
public void addCommand(String key, Command<? super T> handler) { commands.put(key, handler); }
java
public void addCommand(String key, Command<? super T> handler) { commands.put(key, handler); }
[ "public", "void", "addCommand", "(", "String", "key", ",", "Command", "<", "?", "super", "T", ">", "handler", ")", "{", "commands", ".", "put", "(", "key", ",", "handler", ")", ";", "}" ]
Adds a new command handler. @param key The <code>String</code> that identifies this command. The command may be triggered by a command line argument with this value. @param handler The <code>Command</code> that is used to process the command.
[ "Adds", "a", "new", "command", "handler", "." ]
0c03664d42f0e6b111f64447f222aa73c2819e5c
https://github.com/bwkimmel/java-util/blob/0c03664d42f0e6b111f64447f222aa73c2819e5c/src/main/java/ca/eandb/util/args/ArgumentProcessor.java#L539-L541
156,348
nilsreiter/uima-util
src/main/java/de/unistuttgart/ims/uimautil/AnnotationUtil.java
AnnotationUtil.trimEnd
public static <T extends Annotation> T trimEnd(T annotation, char... ws) { char[] s = annotation.getCoveredText().toCharArray(); if (s.length == 0) return annotation; int e = 0; while (ArrayUtils.contains(ws, s[(s.length - 1) - e])) { e++; } annotation.setEnd(annotation.getEnd() - e); return annotation; }
java
public static <T extends Annotation> T trimEnd(T annotation, char... ws) { char[] s = annotation.getCoveredText().toCharArray(); if (s.length == 0) return annotation; int e = 0; while (ArrayUtils.contains(ws, s[(s.length - 1) - e])) { e++; } annotation.setEnd(annotation.getEnd() - e); return annotation; }
[ "public", "static", "<", "T", "extends", "Annotation", ">", "T", "trimEnd", "(", "T", "annotation", ",", "char", "...", "ws", ")", "{", "char", "[", "]", "s", "=", "annotation", ".", "getCoveredText", "(", ")", ".", "toCharArray", "(", ")", ";", "if", "(", "s", ".", "length", "==", "0", ")", "return", "annotation", ";", "int", "e", "=", "0", ";", "while", "(", "ArrayUtils", ".", "contains", "(", "ws", ",", "s", "[", "(", "s", ".", "length", "-", "1", ")", "-", "e", "]", ")", ")", "{", "e", "++", ";", "}", "annotation", ".", "setEnd", "(", "annotation", ".", "getEnd", "(", ")", "-", "e", ")", ";", "return", "annotation", ";", "}" ]
Moves the end-index as long a character that is contained in the array is at the end. @param annotation The annotation to be trimmed. @param ws An array of characters which are considered whitespace @return The trimmed annotation @since 0.4.2
[ "Moves", "the", "end", "-", "index", "as", "long", "a", "character", "that", "is", "contained", "in", "the", "array", "is", "at", "the", "end", "." ]
6f3bc3b8785702fe4ab9b670b87eaa215006f593
https://github.com/nilsreiter/uima-util/blob/6f3bc3b8785702fe4ab9b670b87eaa215006f593/src/main/java/de/unistuttgart/ims/uimautil/AnnotationUtil.java#L172-L183
156,349
s1-platform/s1
s1-core/src/java/org/s1/cluster/dds/FileExchange.java
FileExchange.stop
synchronized void stop(){ if(status.equals("stopped")) return; long t = System.currentTimeMillis(); run = false; try { serverSocket.close(); } catch (IOException e) { throw S1SystemError.wrap(e); } executor.shutdown(); while (!executor.isTerminated()) { } status = "stopped"; LOG.info("Node "+nodeId+" file server stopped ("+(System.currentTimeMillis()-t)+" ms.)"); }
java
synchronized void stop(){ if(status.equals("stopped")) return; long t = System.currentTimeMillis(); run = false; try { serverSocket.close(); } catch (IOException e) { throw S1SystemError.wrap(e); } executor.shutdown(); while (!executor.isTerminated()) { } status = "stopped"; LOG.info("Node "+nodeId+" file server stopped ("+(System.currentTimeMillis()-t)+" ms.)"); }
[ "synchronized", "void", "stop", "(", ")", "{", "if", "(", "status", ".", "equals", "(", "\"stopped\"", ")", ")", "return", ";", "long", "t", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "run", "=", "false", ";", "try", "{", "serverSocket", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "S1SystemError", ".", "wrap", "(", "e", ")", ";", "}", "executor", ".", "shutdown", "(", ")", ";", "while", "(", "!", "executor", ".", "isTerminated", "(", ")", ")", "{", "}", "status", "=", "\"stopped\"", ";", "LOG", ".", "info", "(", "\"Node \"", "+", "nodeId", "+", "\" file server stopped (\"", "+", "(", "System", ".", "currentTimeMillis", "(", ")", "-", "t", ")", "+", "\" ms.)\"", ")", ";", "}" ]
Stop file server
[ "Stop", "file", "server" ]
370101c13fef01af524bc171bcc1a97e5acc76e8
https://github.com/s1-platform/s1/blob/370101c13fef01af524bc171bcc1a97e5acc76e8/s1-core/src/java/org/s1/cluster/dds/FileExchange.java#L161-L179
156,350
greese/dasein-persist
src/main/java/org/dasein/persist/PersistentFactory.java
PersistentFactory.addCounter
public void addCounter(String field, Class<? extends Execution> cls) { counters.put(field, cls); }
java
public void addCounter(String field, Class<? extends Execution> cls) { counters.put(field, cls); }
[ "public", "void", "addCounter", "(", "String", "field", ",", "Class", "<", "?", "extends", "Execution", ">", "cls", ")", "{", "counters", ".", "put", "(", "field", ",", "cls", ")", ";", "}" ]
Adds a query for counts on a specified field. @param field the field to count matches on @param cls the class of the query that performs the count
[ "Adds", "a", "query", "for", "counts", "on", "a", "specified", "field", "." ]
1104621ad1670a45488b093b984ec1db4c7be781
https://github.com/greese/dasein-persist/blob/1104621ad1670a45488b093b984ec1db4c7be781/src/main/java/org/dasein/persist/PersistentFactory.java#L298-L300
156,351
greese/dasein-persist
src/main/java/org/dasein/persist/PersistentFactory.java
PersistentFactory.addSearch
public void addSearch(String field, Class<? extends Execution> cls) { searches.put(field, cls); }
java
public void addSearch(String field, Class<? extends Execution> cls) { searches.put(field, cls); }
[ "public", "void", "addSearch", "(", "String", "field", ",", "Class", "<", "?", "extends", "Execution", ">", "cls", ")", "{", "searches", ".", "put", "(", "field", ",", "cls", ")", ";", "}" ]
Adds a query for searches on a specified field. @param field the field to search on @param cls the class of the query that performs the search
[ "Adds", "a", "query", "for", "searches", "on", "a", "specified", "field", "." ]
1104621ad1670a45488b093b984ec1db4c7be781
https://github.com/greese/dasein-persist/blob/1104621ad1670a45488b093b984ec1db4c7be781/src/main/java/org/dasein/persist/PersistentFactory.java#L307-L309
156,352
greese/dasein-persist
src/main/java/org/dasein/persist/PersistentFactory.java
PersistentFactory.addSingleton
public void addSingleton(String field, Class<? extends Execution> cls) { singletons.put(field, cls); }
java
public void addSingleton(String field, Class<? extends Execution> cls) { singletons.put(field, cls); }
[ "public", "void", "addSingleton", "(", "String", "field", ",", "Class", "<", "?", "extends", "Execution", ">", "cls", ")", "{", "singletons", ".", "put", "(", "field", ",", "cls", ")", ";", "}" ]
Adds a query for searches on a specified field. These searches return unique values. @param field the field to search on @param cls the class of the query that performs the search
[ "Adds", "a", "query", "for", "searches", "on", "a", "specified", "field", ".", "These", "searches", "return", "unique", "values", "." ]
1104621ad1670a45488b093b984ec1db4c7be781
https://github.com/greese/dasein-persist/blob/1104621ad1670a45488b093b984ec1db4c7be781/src/main/java/org/dasein/persist/PersistentFactory.java#L316-L318
156,353
greese/dasein-persist
src/main/java/org/dasein/persist/PersistentFactory.java
PersistentFactory.count
public long count(String field, Object val) throws PersistenceException { logger.debug("enter - count(String,Object)"); try { if( logger.isDebugEnabled() ) { logger.debug("For: " + cache.getTarget().getName() + "/" + field + "/" + val); } Class<? extends Execution> cls; SearchTerm[] terms = new SearchTerm[field == null ? 0 : 1]; if( field != null ) { terms[0] = new SearchTerm(field, Operator.EQUALS, val); } String key = getExecKey(terms, false); Map<String,Object> params = toParams(terms); synchronized( this ) { while( !counters.containsKey(key) ) { compileCounter(terms, counters); try { wait(1000L); } catch( InterruptedException ignore ) { /* ignore this */ } } cls = counters.get(key); } if( cls == null ) { throw new PersistenceException("Unable to compile a default counter for field: " + field); } return count(cls, params); } finally { logger.debug("exit - count(String,Object)"); } }
java
public long count(String field, Object val) throws PersistenceException { logger.debug("enter - count(String,Object)"); try { if( logger.isDebugEnabled() ) { logger.debug("For: " + cache.getTarget().getName() + "/" + field + "/" + val); } Class<? extends Execution> cls; SearchTerm[] terms = new SearchTerm[field == null ? 0 : 1]; if( field != null ) { terms[0] = new SearchTerm(field, Operator.EQUALS, val); } String key = getExecKey(terms, false); Map<String,Object> params = toParams(terms); synchronized( this ) { while( !counters.containsKey(key) ) { compileCounter(terms, counters); try { wait(1000L); } catch( InterruptedException ignore ) { /* ignore this */ } } cls = counters.get(key); } if( cls == null ) { throw new PersistenceException("Unable to compile a default counter for field: " + field); } return count(cls, params); } finally { logger.debug("exit - count(String,Object)"); } }
[ "public", "long", "count", "(", "String", "field", ",", "Object", "val", ")", "throws", "PersistenceException", "{", "logger", ".", "debug", "(", "\"enter - count(String,Object)\"", ")", ";", "try", "{", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"For: \"", "+", "cache", ".", "getTarget", "(", ")", ".", "getName", "(", ")", "+", "\"/\"", "+", "field", "+", "\"/\"", "+", "val", ")", ";", "}", "Class", "<", "?", "extends", "Execution", ">", "cls", ";", "SearchTerm", "[", "]", "terms", "=", "new", "SearchTerm", "[", "field", "==", "null", "?", "0", ":", "1", "]", ";", "if", "(", "field", "!=", "null", ")", "{", "terms", "[", "0", "]", "=", "new", "SearchTerm", "(", "field", ",", "Operator", ".", "EQUALS", ",", "val", ")", ";", "}", "String", "key", "=", "getExecKey", "(", "terms", ",", "false", ")", ";", "Map", "<", "String", ",", "Object", ">", "params", "=", "toParams", "(", "terms", ")", ";", "synchronized", "(", "this", ")", "{", "while", "(", "!", "counters", ".", "containsKey", "(", "key", ")", ")", "{", "compileCounter", "(", "terms", ",", "counters", ")", ";", "try", "{", "wait", "(", "1000L", ")", ";", "}", "catch", "(", "InterruptedException", "ignore", ")", "{", "/* ignore this */", "}", "}", "cls", "=", "counters", ".", "get", "(", "key", ")", ";", "}", "if", "(", "cls", "==", "null", ")", "{", "throw", "new", "PersistenceException", "(", "\"Unable to compile a default counter for field: \"", "+", "field", ")", ";", "}", "return", "count", "(", "cls", ",", "params", ")", ";", "}", "finally", "{", "logger", ".", "debug", "(", "\"exit - count(String,Object)\"", ")", ";", "}", "}" ]
Counts the total number of objects in the database matching the specified criteria. @param field the field to match on @param val the value to match against @return the number of matching objects @throws PersistenceException an error occurred counting the elements in the database
[ "Counts", "the", "total", "number", "of", "objects", "in", "the", "database", "matching", "the", "specified", "criteria", "." ]
1104621ad1670a45488b093b984ec1db4c7be781
https://github.com/greese/dasein-persist/blob/1104621ad1670a45488b093b984ec1db4c7be781/src/main/java/org/dasein/persist/PersistentFactory.java#L1203-L1238
156,354
greese/dasein-persist
src/main/java/org/dasein/persist/PersistentFactory.java
PersistentFactory.count
public long count(Class<? extends Execution> cls, Map<String,Object> criteria) throws PersistenceException { logger.debug("enter - count(Class,Map)"); if( logger.isDebugEnabled() ) { logger.debug("For: " + cache.getTarget().getName() + "/" + cls + "/" + criteria); } try { Transaction xaction = Transaction.getInstance(true); try { long count = 0L; criteria = xaction.execute(cls, criteria); count = ((Number)criteria.get("count")).longValue(); xaction.commit(); return count; } finally { xaction.rollback(); } } finally { logger.debug("exit - count(Class,Map)"); } }
java
public long count(Class<? extends Execution> cls, Map<String,Object> criteria) throws PersistenceException { logger.debug("enter - count(Class,Map)"); if( logger.isDebugEnabled() ) { logger.debug("For: " + cache.getTarget().getName() + "/" + cls + "/" + criteria); } try { Transaction xaction = Transaction.getInstance(true); try { long count = 0L; criteria = xaction.execute(cls, criteria); count = ((Number)criteria.get("count")).longValue(); xaction.commit(); return count; } finally { xaction.rollback(); } } finally { logger.debug("exit - count(Class,Map)"); } }
[ "public", "long", "count", "(", "Class", "<", "?", "extends", "Execution", ">", "cls", ",", "Map", "<", "String", ",", "Object", ">", "criteria", ")", "throws", "PersistenceException", "{", "logger", ".", "debug", "(", "\"enter - count(Class,Map)\"", ")", ";", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"For: \"", "+", "cache", ".", "getTarget", "(", ")", ".", "getName", "(", ")", "+", "\"/\"", "+", "cls", "+", "\"/\"", "+", "criteria", ")", ";", "}", "try", "{", "Transaction", "xaction", "=", "Transaction", ".", "getInstance", "(", "true", ")", ";", "try", "{", "long", "count", "=", "0L", ";", "criteria", "=", "xaction", ".", "execute", "(", "cls", ",", "criteria", ")", ";", "count", "=", "(", "(", "Number", ")", "criteria", ".", "get", "(", "\"count\"", ")", ")", ".", "longValue", "(", ")", ";", "xaction", ".", "commit", "(", ")", ";", "return", "count", ";", "}", "finally", "{", "xaction", ".", "rollback", "(", ")", ";", "}", "}", "finally", "{", "logger", ".", "debug", "(", "\"exit - count(Class,Map)\"", ")", ";", "}", "}" ]
Counts the number of items matching an arbitrary query. This method expects the passed in query to have one field called 'count' in the map it returns. Anything else is ignored @param cls the execution class for the arbitrary query @param criteria the criteria to match against for the query @return the number of matches (essentially, the number returned from the arbitrary query in the 'count' field) @throws PersistenceException an error occurred executing the query.
[ "Counts", "the", "number", "of", "items", "matching", "an", "arbitrary", "query", ".", "This", "method", "expects", "the", "passed", "in", "query", "to", "have", "one", "field", "called", "count", "in", "the", "map", "it", "returns", ".", "Anything", "else", "is", "ignored" ]
1104621ad1670a45488b093b984ec1db4c7be781
https://github.com/greese/dasein-persist/blob/1104621ad1670a45488b093b984ec1db4c7be781/src/main/java/org/dasein/persist/PersistentFactory.java#L1274-L1297
156,355
greese/dasein-persist
src/main/java/org/dasein/persist/PersistentFactory.java
PersistentFactory.find
public Collection<T> find(String field, Object val) throws PersistenceException { logger.debug("enter - find(String,Object"); try { return find(field, val, null); } finally { logger.debug("exit - find(String,Object)"); } }
java
public Collection<T> find(String field, Object val) throws PersistenceException { logger.debug("enter - find(String,Object"); try { return find(field, val, null); } finally { logger.debug("exit - find(String,Object)"); } }
[ "public", "Collection", "<", "T", ">", "find", "(", "String", "field", ",", "Object", "val", ")", "throws", "PersistenceException", "{", "logger", ".", "debug", "(", "\"enter - find(String,Object\"", ")", ";", "try", "{", "return", "find", "(", "field", ",", "val", ",", "null", ")", ";", "}", "finally", "{", "logger", ".", "debug", "(", "\"exit - find(String,Object)\"", ")", ";", "}", "}" ]
Executes a search that may return multiple values. The specified field must have been set up by a call to @{link #addSearch(String,Class)}. @param field the field being searched on @param val the value being searched against @return a list of objects that match the criteria @throws PersistenceException an error occurred talking to the data store
[ "Executes", "a", "search", "that", "may", "return", "multiple", "values", ".", "The", "specified", "field", "must", "have", "been", "set", "up", "by", "a", "call", "to" ]
1104621ad1670a45488b093b984ec1db4c7be781
https://github.com/greese/dasein-persist/blob/1104621ad1670a45488b093b984ec1db4c7be781/src/main/java/org/dasein/persist/PersistentFactory.java#L1355-L1363
156,356
greese/dasein-persist
src/main/java/org/dasein/persist/PersistentFactory.java
PersistentFactory.find
public Collection<T> find(Class<? extends Execution> cls, Map<String,Object> criteria) throws PersistenceException { logger.debug("enter - find(Class,Map)"); try { Collection<String> keys = criteria.keySet(); SearchTerm[] terms = new SearchTerm[keys.size()]; int i = 0; for( String key : keys ) { terms[i++] = new SearchTerm(key, Operator.EQUALS, criteria.get(key)); } return load(cls, null, terms); } finally { logger.debug("exit - find(Class,Map)"); } }
java
public Collection<T> find(Class<? extends Execution> cls, Map<String,Object> criteria) throws PersistenceException { logger.debug("enter - find(Class,Map)"); try { Collection<String> keys = criteria.keySet(); SearchTerm[] terms = new SearchTerm[keys.size()]; int i = 0; for( String key : keys ) { terms[i++] = new SearchTerm(key, Operator.EQUALS, criteria.get(key)); } return load(cls, null, terms); } finally { logger.debug("exit - find(Class,Map)"); } }
[ "public", "Collection", "<", "T", ">", "find", "(", "Class", "<", "?", "extends", "Execution", ">", "cls", ",", "Map", "<", "String", ",", "Object", ">", "criteria", ")", "throws", "PersistenceException", "{", "logger", ".", "debug", "(", "\"enter - find(Class,Map)\"", ")", ";", "try", "{", "Collection", "<", "String", ">", "keys", "=", "criteria", ".", "keySet", "(", ")", ";", "SearchTerm", "[", "]", "terms", "=", "new", "SearchTerm", "[", "keys", ".", "size", "(", ")", "]", ";", "int", "i", "=", "0", ";", "for", "(", "String", "key", ":", "keys", ")", "{", "terms", "[", "i", "++", "]", "=", "new", "SearchTerm", "(", "key", ",", "Operator", ".", "EQUALS", ",", "criteria", ".", "get", "(", "key", ")", ")", ";", "}", "return", "load", "(", "cls", ",", "null", ",", "terms", ")", ";", "}", "finally", "{", "logger", ".", "debug", "(", "\"exit - find(Class,Map)\"", ")", ";", "}", "}" ]
Executes an arbitrary search using the passed in search class and criteria. This is useful for searches that simply do not fit well into the rest of the API. @param cls the class to perform the search @param criteria the search criteria @return the results of the search @throws PersistenceException an error occurred performing the search
[ "Executes", "an", "arbitrary", "search", "using", "the", "passed", "in", "search", "class", "and", "criteria", ".", "This", "is", "useful", "for", "searches", "that", "simply", "do", "not", "fit", "well", "into", "the", "rest", "of", "the", "API", "." ]
1104621ad1670a45488b093b984ec1db4c7be781
https://github.com/greese/dasein-persist/blob/1104621ad1670a45488b093b984ec1db4c7be781/src/main/java/org/dasein/persist/PersistentFactory.java#L1456-L1471
156,357
dasein-cloud/dasein-cloud-azure
src/main/java/org/dasein/cloud/azure/network/AzureLoadBalancerCapabilities.java
AzureLoadBalancerCapabilities.listSupportedEndpointTypes
@Nonnull @Override public Iterable<LbEndpointType> listSupportedEndpointTypes() throws CloudException, InternalException { return Collections.unmodifiableList(Arrays.asList(LbEndpointType.VM)); }
java
@Nonnull @Override public Iterable<LbEndpointType> listSupportedEndpointTypes() throws CloudException, InternalException { return Collections.unmodifiableList(Arrays.asList(LbEndpointType.VM)); }
[ "@", "Nonnull", "@", "Override", "public", "Iterable", "<", "LbEndpointType", ">", "listSupportedEndpointTypes", "(", ")", "throws", "CloudException", ",", "InternalException", "{", "return", "Collections", ".", "unmodifiableList", "(", "Arrays", ".", "asList", "(", "LbEndpointType", ".", "VM", ")", ")", ";", "}" ]
Describes what kind of endpoints may be added to a load balancer. @return a list of one or more supported endpoint types @throws org.dasein.cloud.CloudException an error occurred while communicating with the cloud provider @throws org.dasein.cloud.InternalException an error occurred within the Dasein Cloud implementation
[ "Describes", "what", "kind", "of", "endpoints", "may", "be", "added", "to", "a", "load", "balancer", "." ]
e2abb775c0f23f0d0f2509fba31128c7b2027d7c
https://github.com/dasein-cloud/dasein-cloud-azure/blob/e2abb775c0f23f0d0f2509fba31128c7b2027d7c/src/main/java/org/dasein/cloud/azure/network/AzureLoadBalancerCapabilities.java#L224-L228
156,358
dasein-cloud/dasein-cloud-azure
src/main/java/org/dasein/cloud/azure/network/AzureLoadBalancerCapabilities.java
AzureLoadBalancerCapabilities.listSupportedProtocols
@Nonnull @Override public Iterable<LbProtocol> listSupportedProtocols() throws CloudException, InternalException { return Collections.unmodifiableList(Arrays.asList(LbProtocol.HTTP, LbProtocol.HTTPS)); }
java
@Nonnull @Override public Iterable<LbProtocol> listSupportedProtocols() throws CloudException, InternalException { return Collections.unmodifiableList(Arrays.asList(LbProtocol.HTTP, LbProtocol.HTTPS)); }
[ "@", "Nonnull", "@", "Override", "public", "Iterable", "<", "LbProtocol", ">", "listSupportedProtocols", "(", ")", "throws", "CloudException", ",", "InternalException", "{", "return", "Collections", ".", "unmodifiableList", "(", "Arrays", ".", "asList", "(", "LbProtocol", ".", "HTTP", ",", "LbProtocol", ".", "HTTPS", ")", ")", ";", "}" ]
Lists the network protocols supported for load balancer listeners. @return a list of one or more supported network protocols for load balancing @throws org.dasein.cloud.CloudException an error occurred while communicating with the cloud provider @throws org.dasein.cloud.InternalException an error occurred within the Dasein Cloud implementation
[ "Lists", "the", "network", "protocols", "supported", "for", "load", "balancer", "listeners", "." ]
e2abb775c0f23f0d0f2509fba31128c7b2027d7c
https://github.com/dasein-cloud/dasein-cloud-azure/blob/e2abb775c0f23f0d0f2509fba31128c7b2027d7c/src/main/java/org/dasein/cloud/azure/network/AzureLoadBalancerCapabilities.java#L263-L267
156,359
riversun/d6
src/main/java/org/riversun/d6/predev/D6JavaModelGen4MySQL.java
D6JavaModelGen4MySQL.getCamelCaseFromUnderscoreSeparated
private String getCamelCaseFromUnderscoreSeparated(String underScoreSeparatedStr) { final StringGrabber underScoreSeparatedSg = new StringGrabber(underScoreSeparatedStr); final StringGrabberList wordBlockList = underScoreSeparatedSg.split("_"); final StringGrabber resultSg = new StringGrabber(); for (int i = 0; i < wordBlockList.size(); i++) { final StringGrabber word = wordBlockList.get(i); if (i == 0) { // first element not to upper case resultSg.append(word.toString()); } else { resultSg.append(word.replaceFirstToUpperCase().toString()); } } return resultSg.toString(); }
java
private String getCamelCaseFromUnderscoreSeparated(String underScoreSeparatedStr) { final StringGrabber underScoreSeparatedSg = new StringGrabber(underScoreSeparatedStr); final StringGrabberList wordBlockList = underScoreSeparatedSg.split("_"); final StringGrabber resultSg = new StringGrabber(); for (int i = 0; i < wordBlockList.size(); i++) { final StringGrabber word = wordBlockList.get(i); if (i == 0) { // first element not to upper case resultSg.append(word.toString()); } else { resultSg.append(word.replaceFirstToUpperCase().toString()); } } return resultSg.toString(); }
[ "private", "String", "getCamelCaseFromUnderscoreSeparated", "(", "String", "underScoreSeparatedStr", ")", "{", "final", "StringGrabber", "underScoreSeparatedSg", "=", "new", "StringGrabber", "(", "underScoreSeparatedStr", ")", ";", "final", "StringGrabberList", "wordBlockList", "=", "underScoreSeparatedSg", ".", "split", "(", "\"_\"", ")", ";", "final", "StringGrabber", "resultSg", "=", "new", "StringGrabber", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "wordBlockList", ".", "size", "(", ")", ";", "i", "++", ")", "{", "final", "StringGrabber", "word", "=", "wordBlockList", ".", "get", "(", "i", ")", ";", "if", "(", "i", "==", "0", ")", "{", "// first element not to upper case", "resultSg", ".", "append", "(", "word", ".", "toString", "(", ")", ")", ";", "}", "else", "{", "resultSg", ".", "append", "(", "word", ".", "replaceFirstToUpperCase", "(", ")", ".", "toString", "(", ")", ")", ";", "}", "}", "return", "resultSg", ".", "toString", "(", ")", ";", "}" ]
Convert underscore separated text into camel case text @param underScoreSeparatedStr @return
[ "Convert", "underscore", "separated", "text", "into", "camel", "case", "text" ]
2798bd876b9380dbfea8182d11ad306cb1b0e114
https://github.com/riversun/d6/blob/2798bd876b9380dbfea8182d11ad306cb1b0e114/src/main/java/org/riversun/d6/predev/D6JavaModelGen4MySQL.java#L334-L354
156,360
intellimate/Izou
src/main/java/org/intellimate/izou/security/PermissionModule.java
PermissionModule.registerOrThrow
protected <X extends IzouPermissionException> void registerOrThrow(AddOnModel addOn, Supplier<X> exceptionSupplier, Function<PluginDescriptor, Boolean> checkPermission) { getMain().getAddOnManager().getPluginWrapper(addOn) .map(PluginWrapper::getDescriptor) .map(checkPermission) .ifPresent(allowedToRun -> { if (allowedToRun) { registerAddOn(addOn); } else { throw exceptionSupplier.get(); } }); }
java
protected <X extends IzouPermissionException> void registerOrThrow(AddOnModel addOn, Supplier<X> exceptionSupplier, Function<PluginDescriptor, Boolean> checkPermission) { getMain().getAddOnManager().getPluginWrapper(addOn) .map(PluginWrapper::getDescriptor) .map(checkPermission) .ifPresent(allowedToRun -> { if (allowedToRun) { registerAddOn(addOn); } else { throw exceptionSupplier.get(); } }); }
[ "protected", "<", "X", "extends", "IzouPermissionException", ">", "void", "registerOrThrow", "(", "AddOnModel", "addOn", ",", "Supplier", "<", "X", ">", "exceptionSupplier", ",", "Function", "<", "PluginDescriptor", ",", "Boolean", ">", "checkPermission", ")", "{", "getMain", "(", ")", ".", "getAddOnManager", "(", ")", ".", "getPluginWrapper", "(", "addOn", ")", ".", "map", "(", "PluginWrapper", "::", "getDescriptor", ")", ".", "map", "(", "checkPermission", ")", ".", "ifPresent", "(", "allowedToRun", "->", "{", "if", "(", "allowedToRun", ")", "{", "registerAddOn", "(", "addOn", ")", ";", "}", "else", "{", "throw", "exceptionSupplier", ".", "get", "(", ")", ";", "}", "}", ")", ";", "}" ]
registers the addon if checkPermission returns true, else throws the exception provided by the exceptionSupplier. If the Addon was not added through PF4J it gets ignored @param addOn the addon to check @param checkPermission returns true if eligible for registering
[ "registers", "the", "addon", "if", "checkPermission", "returns", "true", "else", "throws", "the", "exception", "provided", "by", "the", "exceptionSupplier", ".", "If", "the", "Addon", "was", "not", "added", "through", "PF4J", "it", "gets", "ignored" ]
40a808b97998e17655c4a78e30ce7326148aed27
https://github.com/intellimate/Izou/blob/40a808b97998e17655c4a78e30ce7326148aed27/src/main/java/org/intellimate/izou/security/PermissionModule.java#L98-L110
156,361
js-lib-com/dom
src/main/java/js/dom/w3c/EntityResolverImpl.java
EntityResolverImpl.resolveEntity
@Override public InputSource resolveEntity(String publicId, String systemId) { String r = map.get(publicId); return r == null ? null : new InputSource(Resources.stream(r)); }
java
@Override public InputSource resolveEntity(String publicId, String systemId) { String r = map.get(publicId); return r == null ? null : new InputSource(Resources.stream(r)); }
[ "@", "Override", "public", "InputSource", "resolveEntity", "(", "String", "publicId", ",", "String", "systemId", ")", "{", "String", "r", "=", "map", ".", "get", "(", "publicId", ")", ";", "return", "r", "==", "null", "?", "null", ":", "new", "InputSource", "(", "Resources", ".", "stream", "(", "r", ")", ")", ";", "}" ]
Get input source for entity definition file identified by public and system ID.
[ "Get", "input", "source", "for", "entity", "definition", "file", "identified", "by", "public", "and", "system", "ID", "." ]
8c7cd7c802977f210674dec7c2a8f61e8de05b63
https://github.com/js-lib-com/dom/blob/8c7cd7c802977f210674dec7c2a8f61e8de05b63/src/main/java/js/dom/w3c/EntityResolverImpl.java#L40-L45
156,362
foundation-runtime/common
commons/src/main/java/com/cisco/oss/foundation/flowcontext/FlowContextImpl.java
FlowContextImpl.serializeNativeFlowContext
synchronized String serializeNativeFlowContext() { //NOPMD StringBuilder result = new StringBuilder(uniqueId); if (showTxCounter) { if (innerTxCounter.get() != 0) { result = result.append(TX_DELIM).append(innerTxCounter); } } return result.toString(); }
java
synchronized String serializeNativeFlowContext() { //NOPMD StringBuilder result = new StringBuilder(uniqueId); if (showTxCounter) { if (innerTxCounter.get() != 0) { result = result.append(TX_DELIM).append(innerTxCounter); } } return result.toString(); }
[ "synchronized", "String", "serializeNativeFlowContext", "(", ")", "{", "//NOPMD", "StringBuilder", "result", "=", "new", "StringBuilder", "(", "uniqueId", ")", ";", "if", "(", "showTxCounter", ")", "{", "if", "(", "innerTxCounter", ".", "get", "(", ")", "!=", "0", ")", "{", "result", "=", "result", ".", "append", "(", "TX_DELIM", ")", ".", "append", "(", "innerTxCounter", ")", ";", "}", "}", "return", "result", ".", "toString", "(", ")", ";", "}" ]
Get String represent FlowContextImpl @return String that present the flowContextImpl.
[ "Get", "String", "represent", "FlowContextImpl" ]
8d243111f68dc620bdea0659f9fff75fe05f0447
https://github.com/foundation-runtime/common/blob/8d243111f68dc620bdea0659f9fff75fe05f0447/commons/src/main/java/com/cisco/oss/foundation/flowcontext/FlowContextImpl.java#L97-L105
156,363
adamfisk/littleshoot-util
src/main/java/org/littleshoot/util/StringUtils.java
StringUtils.toAsciiBytes
public static final byte[] toAsciiBytes(final String value) { byte[] result = new byte[value.length()]; for (int i = 0; i < value.length(); i++) { result[i] = (byte) value.charAt(i); } return result; }
java
public static final byte[] toAsciiBytes(final String value) { byte[] result = new byte[value.length()]; for (int i = 0; i < value.length(); i++) { result[i] = (byte) value.charAt(i); } return result; }
[ "public", "static", "final", "byte", "[", "]", "toAsciiBytes", "(", "final", "String", "value", ")", "{", "byte", "[", "]", "result", "=", "new", "byte", "[", "value", ".", "length", "(", ")", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "value", ".", "length", "(", ")", ";", "i", "++", ")", "{", "result", "[", "i", "]", "=", "(", "byte", ")", "value", ".", "charAt", "(", "i", ")", ";", "}", "return", "result", ";", "}" ]
Convert specified String to a byte array. @param value to convert to byte array @return the byte array value
[ "Convert", "specified", "String", "to", "a", "byte", "array", "." ]
3c0dc4955116b3382d6b0575d2f164b7508a4f73
https://github.com/adamfisk/littleshoot-util/blob/3c0dc4955116b3382d6b0575d2f164b7508a4f73/src/main/java/org/littleshoot/util/StringUtils.java#L15-L23
156,364
agmip/agmip-common-functions
src/main/java/org/agmip/common/Event.java
Event.setTemplate
public final void setTemplate() { template = new HashMap(); if (isEventExist()) { template.putAll(events.get(next)); } template.put("event", eventType); }
java
public final void setTemplate() { template = new HashMap(); if (isEventExist()) { template.putAll(events.get(next)); } template.put("event", eventType); }
[ "public", "final", "void", "setTemplate", "(", ")", "{", "template", "=", "new", "HashMap", "(", ")", ";", "if", "(", "isEventExist", "(", ")", ")", "{", "template", ".", "putAll", "(", "events", ".", "get", "(", "next", ")", ")", ";", "}", "template", ".", "put", "(", "\"event\"", ",", "eventType", ")", ";", "}" ]
Set template with selected event type
[ "Set", "template", "with", "selected", "event", "type" ]
4efa3042178841b026ca6fba9c96da02fbfb9a8e
https://github.com/agmip/agmip-common-functions/blob/4efa3042178841b026ca6fba9c96da02fbfb9a8e/src/main/java/org/agmip/common/Event.java#L47-L53
156,365
agmip/agmip-common-functions
src/main/java/org/agmip/common/Event.java
Event.addEvent
public HashMap addEvent(String date, boolean useTemp) { HashMap ret = new HashMap(); if (useTemp) { ret.putAll(template); } else { ret.put("event", eventType); } ret.put("date", date); getInertIndex(ret); events.add(next, ret); return ret; }
java
public HashMap addEvent(String date, boolean useTemp) { HashMap ret = new HashMap(); if (useTemp) { ret.putAll(template); } else { ret.put("event", eventType); } ret.put("date", date); getInertIndex(ret); events.add(next, ret); return ret; }
[ "public", "HashMap", "addEvent", "(", "String", "date", ",", "boolean", "useTemp", ")", "{", "HashMap", "ret", "=", "new", "HashMap", "(", ")", ";", "if", "(", "useTemp", ")", "{", "ret", ".", "putAll", "(", "template", ")", ";", "}", "else", "{", "ret", ".", "put", "(", "\"event\"", ",", "eventType", ")", ";", "}", "ret", ".", "put", "(", "\"date\"", ",", "date", ")", ";", "getInertIndex", "(", "ret", ")", ";", "events", ".", "add", "(", "next", ",", "ret", ")", ";", "return", "ret", ";", "}" ]
Add a new event into array with selected event type and input date. @param date The event date @param useTemp True for using template to create new data @return The generated event data map
[ "Add", "a", "new", "event", "into", "array", "with", "selected", "event", "type", "and", "input", "date", "." ]
4efa3042178841b026ca6fba9c96da02fbfb9a8e
https://github.com/agmip/agmip-common-functions/blob/4efa3042178841b026ca6fba9c96da02fbfb9a8e/src/main/java/org/agmip/common/Event.java#L123-L134
156,366
agmip/agmip-common-functions
src/main/java/org/agmip/common/Event.java
Event.getNextEventIndex
private void getNextEventIndex() { for (int i = next + 1; i < events.size(); i++) { String evName = getValueOr(events.get(i), "event", ""); if (evName.equals(eventType)) { next = i; return; } } next = events.size(); }
java
private void getNextEventIndex() { for (int i = next + 1; i < events.size(); i++) { String evName = getValueOr(events.get(i), "event", ""); if (evName.equals(eventType)) { next = i; return; } } next = events.size(); }
[ "private", "void", "getNextEventIndex", "(", ")", "{", "for", "(", "int", "i", "=", "next", "+", "1", ";", "i", "<", "events", ".", "size", "(", ")", ";", "i", "++", ")", "{", "String", "evName", "=", "getValueOr", "(", "events", ".", "get", "(", "i", ")", ",", "\"event\"", ",", "\"\"", ")", ";", "if", "(", "evName", ".", "equals", "(", "eventType", ")", ")", "{", "next", "=", "i", ";", "return", ";", "}", "}", "next", "=", "events", ".", "size", "(", ")", ";", "}" ]
Move index to the next planting event
[ "Move", "index", "to", "the", "next", "planting", "event" ]
4efa3042178841b026ca6fba9c96da02fbfb9a8e
https://github.com/agmip/agmip-common-functions/blob/4efa3042178841b026ca6fba9c96da02fbfb9a8e/src/main/java/org/agmip/common/Event.java#L139-L148
156,367
agmip/agmip-common-functions
src/main/java/org/agmip/common/Event.java
Event.getInertIndex
private void getInertIndex(HashMap event) { int iDate; try { iDate = Integer.parseInt(getValueOr(event, "date", "")); } catch (Exception e) { next = events.size(); return; } for (int i = isEventExist() ? next : 0; i < events.size(); i++) { try { if (iDate < Integer.parseInt(getValueOr(events.get(i), "date", "0"))) { next = i; return; } } catch (Exception e) { } } next = events.size(); }
java
private void getInertIndex(HashMap event) { int iDate; try { iDate = Integer.parseInt(getValueOr(event, "date", "")); } catch (Exception e) { next = events.size(); return; } for (int i = isEventExist() ? next : 0; i < events.size(); i++) { try { if (iDate < Integer.parseInt(getValueOr(events.get(i), "date", "0"))) { next = i; return; } } catch (Exception e) { } } next = events.size(); }
[ "private", "void", "getInertIndex", "(", "HashMap", "event", ")", "{", "int", "iDate", ";", "try", "{", "iDate", "=", "Integer", ".", "parseInt", "(", "getValueOr", "(", "event", ",", "\"date\"", ",", "\"\"", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "next", "=", "events", ".", "size", "(", ")", ";", "return", ";", "}", "for", "(", "int", "i", "=", "isEventExist", "(", ")", "?", "next", ":", "0", ";", "i", "<", "events", ".", "size", "(", ")", ";", "i", "++", ")", "{", "try", "{", "if", "(", "iDate", "<", "Integer", ".", "parseInt", "(", "getValueOr", "(", "events", ".", "get", "(", "i", ")", ",", "\"date\"", ",", "\"0\"", ")", ")", ")", "{", "next", "=", "i", ";", "return", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "}", "}", "next", "=", "events", ".", "size", "(", ")", ";", "}" ]
Find out the insert position for the new event. If date is not available for the new event, will return the last position of array @param event The new event data
[ "Find", "out", "the", "insert", "position", "for", "the", "new", "event", ".", "If", "date", "is", "not", "available", "for", "the", "new", "event", "will", "return", "the", "last", "position", "of", "array" ]
4efa3042178841b026ca6fba9c96da02fbfb9a8e
https://github.com/agmip/agmip-common-functions/blob/4efa3042178841b026ca6fba9c96da02fbfb9a8e/src/main/java/org/agmip/common/Event.java#L188-L207
156,368
javagl/ND
nd-distance/src/main/java/de/javagl/nd/distance/tuples/i/MathUtils.java
MathUtils.wrap
static int wrap(int value, int max) { int result = value % max; if (result < 0) { return result + (max > 0 ? max : - max); } return result; }
java
static int wrap(int value, int max) { int result = value % max; if (result < 0) { return result + (max > 0 ? max : - max); } return result; }
[ "static", "int", "wrap", "(", "int", "value", ",", "int", "max", ")", "{", "int", "result", "=", "value", "%", "max", ";", "if", "(", "result", "<", "0", ")", "{", "return", "result", "+", "(", "max", ">", "0", "?", "max", ":", "-", "max", ")", ";", "}", "return", "result", ";", "}" ]
Wrap the given value to be in [0,|max|) @param value The value @param max The maximum value @return The wrapped value @throws ArithmeticException If the given maximum value is 0
[ "Wrap", "the", "given", "value", "to", "be", "in", "[", "0", "|max|", ")" ]
bcb655aaf5fc88af6194f73a27cca079186ff559
https://github.com/javagl/ND/blob/bcb655aaf5fc88af6194f73a27cca079186ff559/nd-distance/src/main/java/de/javagl/nd/distance/tuples/i/MathUtils.java#L42-L50
156,369
javagl/ND
nd-tuples/src/main/java/de/javagl/nd/tuples/j/LongTuples.java
LongTuples.areElementsLessThanOrEqual
public static boolean areElementsLessThanOrEqual( LongTuple t, long value) { for (int i=0; i<t.getSize(); i++) { if (t.get(i) > value) { return false; } } return true; }
java
public static boolean areElementsLessThanOrEqual( LongTuple t, long value) { for (int i=0; i<t.getSize(); i++) { if (t.get(i) > value) { return false; } } return true; }
[ "public", "static", "boolean", "areElementsLessThanOrEqual", "(", "LongTuple", "t", ",", "long", "value", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "t", ".", "getSize", "(", ")", ";", "i", "++", ")", "{", "if", "(", "t", ".", "get", "(", "i", ")", ">", "value", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Returns whether all elements of the given tuple are less than or equal to the given value. @param t The tuple @param value The value to compare to @return Whether each element of the tuple is less than or equal to the given value
[ "Returns", "whether", "all", "elements", "of", "the", "given", "tuple", "are", "less", "than", "or", "equal", "to", "the", "given", "value", "." ]
bcb655aaf5fc88af6194f73a27cca079186ff559
https://github.com/javagl/ND/blob/bcb655aaf5fc88af6194f73a27cca079186ff559/nd-tuples/src/main/java/de/javagl/nd/tuples/j/LongTuples.java#L1151-L1162
156,370
adamfisk/littleshoot-util
src/main/java/org/littleshoot/util/Sha1.java
Sha1.engineReset
protected void engineReset() { int i = 60; do { pad[i ] = (byte)0x00; pad[i + 1] = (byte)0x00; pad[i + 2] = (byte)0x00; pad[i + 3] = (byte)0x00; } while ((i -= 4) >= 0); padding = 0; bytes = 0; init(); }
java
protected void engineReset() { int i = 60; do { pad[i ] = (byte)0x00; pad[i + 1] = (byte)0x00; pad[i + 2] = (byte)0x00; pad[i + 3] = (byte)0x00; } while ((i -= 4) >= 0); padding = 0; bytes = 0; init(); }
[ "protected", "void", "engineReset", "(", ")", "{", "int", "i", "=", "60", ";", "do", "{", "pad", "[", "i", "]", "=", "(", "byte", ")", "0x00", ";", "pad", "[", "i", "+", "1", "]", "=", "(", "byte", ")", "0x00", ";", "pad", "[", "i", "+", "2", "]", "=", "(", "byte", ")", "0x00", ";", "pad", "[", "i", "+", "3", "]", "=", "(", "byte", ")", "0x00", ";", "}", "while", "(", "(", "i", "-=", "4", ")", ">=", "0", ")", ";", "padding", "=", "0", ";", "bytes", "=", "0", ";", "init", "(", ")", ";", "}" ]
Reset athen initialize the digest context. Overrides the protected abstract method of <code>java.security.MessageDigestSpi</code>.
[ "Reset", "athen", "initialize", "the", "digest", "context", "." ]
3c0dc4955116b3382d6b0575d2f164b7508a4f73
https://github.com/adamfisk/littleshoot-util/blob/3c0dc4955116b3382d6b0575d2f164b7508a4f73/src/main/java/org/littleshoot/util/Sha1.java#L111-L122
156,371
adamfisk/littleshoot-util
src/main/java/org/littleshoot/util/Sha1.java
Sha1.engineUpdate
public void engineUpdate(byte input) { bytes++; if (padding < 63) { pad[padding++] = input; return; } pad[63] = input; computeBlock(pad, 0); padding = 0; }
java
public void engineUpdate(byte input) { bytes++; if (padding < 63) { pad[padding++] = input; return; } pad[63] = input; computeBlock(pad, 0); padding = 0; }
[ "public", "void", "engineUpdate", "(", "byte", "input", ")", "{", "bytes", "++", ";", "if", "(", "padding", "<", "63", ")", "{", "pad", "[", "padding", "++", "]", "=", "input", ";", "return", ";", "}", "pad", "[", "63", "]", "=", "input", ";", "computeBlock", "(", "pad", ",", "0", ")", ";", "padding", "=", "0", ";", "}" ]
Updates the digest using the specified byte. Requires internal buffering, and may be slow. Overrides the protected abstract method of java.security.MessageDigestSpi. @param input the byte to use for the update.
[ "Updates", "the", "digest", "using", "the", "specified", "byte", ".", "Requires", "internal", "buffering", "and", "may", "be", "slow", "." ]
3c0dc4955116b3382d6b0575d2f164b7508a4f73
https://github.com/adamfisk/littleshoot-util/blob/3c0dc4955116b3382d6b0575d2f164b7508a4f73/src/main/java/org/littleshoot/util/Sha1.java#L143-L152
156,372
d-sauer/JCalcAPI
src/main/java/org/jdice/calc/Properties.java
Properties.saveGlobalProperties
public void saveGlobalProperties() throws IOException { File propFile = new File(getGlobalPropertiesFile()); if (propFile.createNewFile() || propFile.isFile()) { java.util.Properties prop = new java.util.Properties(); if (getRoundingMode() != null) prop.put("roundingMode", getRoundingMode().name()); if (getScale() != null) prop.put("scale", getScale()); prop.put("stripTrailingZeros", Boolean.toString(hasStripTrailingZeros())); prop.put("decimalSeparator.in", "'" + getInputDecimalSeparator() + "'"); prop.put("decimalSeparator.out", "'" + getOutputDecimalSeparator() + "'"); if (getGroupingSeparator() != null) prop.put("groupingSeparator", getGroupingSeparator()); if (getOutputFormat() != null) prop.put("outputFormat", getOutputFormat()); // // Global NumConverter // HashMap<Class, NumConverter> cncs = CacheExtension.getAllNumConverter(); int count = 0; for (Entry<Class, NumConverter> cnc : cncs.entrySet()) { prop.put("numconverter[" + count++ + "]", cnc.getKey().getName() + " > " + cnc.getValue().getClass().getName()); } // // Global Operator // HashMap<Class<? extends Operator>, Operator> cops = CacheExtension.getOperators(); count = 0; for (Entry<Class<? extends Operator>, Operator> cop : cops.entrySet()) { prop.put("operator[" + count++ + "]", cop.getKey().getName()); } // // Global Function // HashMap<Class<? extends Function>, Function> cfns = CacheExtension.getFunctions(); count = 0; for (Entry<Class<? extends Function>, Function> cfn : cfns.entrySet()) { prop.put("function[" + count++ + "]", cfn.getKey().getName()); } FileOutputStream fos = new FileOutputStream(propFile); prop.store(fos, "Global properties for jCalc"); fos.close(); fos.flush(); } }
java
public void saveGlobalProperties() throws IOException { File propFile = new File(getGlobalPropertiesFile()); if (propFile.createNewFile() || propFile.isFile()) { java.util.Properties prop = new java.util.Properties(); if (getRoundingMode() != null) prop.put("roundingMode", getRoundingMode().name()); if (getScale() != null) prop.put("scale", getScale()); prop.put("stripTrailingZeros", Boolean.toString(hasStripTrailingZeros())); prop.put("decimalSeparator.in", "'" + getInputDecimalSeparator() + "'"); prop.put("decimalSeparator.out", "'" + getOutputDecimalSeparator() + "'"); if (getGroupingSeparator() != null) prop.put("groupingSeparator", getGroupingSeparator()); if (getOutputFormat() != null) prop.put("outputFormat", getOutputFormat()); // // Global NumConverter // HashMap<Class, NumConverter> cncs = CacheExtension.getAllNumConverter(); int count = 0; for (Entry<Class, NumConverter> cnc : cncs.entrySet()) { prop.put("numconverter[" + count++ + "]", cnc.getKey().getName() + " > " + cnc.getValue().getClass().getName()); } // // Global Operator // HashMap<Class<? extends Operator>, Operator> cops = CacheExtension.getOperators(); count = 0; for (Entry<Class<? extends Operator>, Operator> cop : cops.entrySet()) { prop.put("operator[" + count++ + "]", cop.getKey().getName()); } // // Global Function // HashMap<Class<? extends Function>, Function> cfns = CacheExtension.getFunctions(); count = 0; for (Entry<Class<? extends Function>, Function> cfn : cfns.entrySet()) { prop.put("function[" + count++ + "]", cfn.getKey().getName()); } FileOutputStream fos = new FileOutputStream(propFile); prop.store(fos, "Global properties for jCalc"); fos.close(); fos.flush(); } }
[ "public", "void", "saveGlobalProperties", "(", ")", "throws", "IOException", "{", "File", "propFile", "=", "new", "File", "(", "getGlobalPropertiesFile", "(", ")", ")", ";", "if", "(", "propFile", ".", "createNewFile", "(", ")", "||", "propFile", ".", "isFile", "(", ")", ")", "{", "java", ".", "util", ".", "Properties", "prop", "=", "new", "java", ".", "util", ".", "Properties", "(", ")", ";", "if", "(", "getRoundingMode", "(", ")", "!=", "null", ")", "prop", ".", "put", "(", "\"roundingMode\"", ",", "getRoundingMode", "(", ")", ".", "name", "(", ")", ")", ";", "if", "(", "getScale", "(", ")", "!=", "null", ")", "prop", ".", "put", "(", "\"scale\"", ",", "getScale", "(", ")", ")", ";", "prop", ".", "put", "(", "\"stripTrailingZeros\"", ",", "Boolean", ".", "toString", "(", "hasStripTrailingZeros", "(", ")", ")", ")", ";", "prop", ".", "put", "(", "\"decimalSeparator.in\"", ",", "\"'\"", "+", "getInputDecimalSeparator", "(", ")", "+", "\"'\"", ")", ";", "prop", ".", "put", "(", "\"decimalSeparator.out\"", ",", "\"'\"", "+", "getOutputDecimalSeparator", "(", ")", "+", "\"'\"", ")", ";", "if", "(", "getGroupingSeparator", "(", ")", "!=", "null", ")", "prop", ".", "put", "(", "\"groupingSeparator\"", ",", "getGroupingSeparator", "(", ")", ")", ";", "if", "(", "getOutputFormat", "(", ")", "!=", "null", ")", "prop", ".", "put", "(", "\"outputFormat\"", ",", "getOutputFormat", "(", ")", ")", ";", "//\r", "// Global NumConverter\r", "//\r", "HashMap", "<", "Class", ",", "NumConverter", ">", "cncs", "=", "CacheExtension", ".", "getAllNumConverter", "(", ")", ";", "int", "count", "=", "0", ";", "for", "(", "Entry", "<", "Class", ",", "NumConverter", ">", "cnc", ":", "cncs", ".", "entrySet", "(", ")", ")", "{", "prop", ".", "put", "(", "\"numconverter[\"", "+", "count", "++", "+", "\"]\"", ",", "cnc", ".", "getKey", "(", ")", ".", "getName", "(", ")", "+", "\" > \"", "+", "cnc", ".", "getValue", "(", ")", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "//\r", "// Global Operator\r", "//\r", "HashMap", "<", "Class", "<", "?", "extends", "Operator", ">", ",", "Operator", ">", "cops", "=", "CacheExtension", ".", "getOperators", "(", ")", ";", "count", "=", "0", ";", "for", "(", "Entry", "<", "Class", "<", "?", "extends", "Operator", ">", ",", "Operator", ">", "cop", ":", "cops", ".", "entrySet", "(", ")", ")", "{", "prop", ".", "put", "(", "\"operator[\"", "+", "count", "++", "+", "\"]\"", ",", "cop", ".", "getKey", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "//\r", "// Global Function\r", "//\r", "HashMap", "<", "Class", "<", "?", "extends", "Function", ">", ",", "Function", ">", "cfns", "=", "CacheExtension", ".", "getFunctions", "(", ")", ";", "count", "=", "0", ";", "for", "(", "Entry", "<", "Class", "<", "?", "extends", "Function", ">", ",", "Function", ">", "cfn", ":", "cfns", ".", "entrySet", "(", ")", ")", "{", "prop", ".", "put", "(", "\"function[\"", "+", "count", "++", "+", "\"]\"", ",", "cfn", ".", "getKey", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "FileOutputStream", "fos", "=", "new", "FileOutputStream", "(", "propFile", ")", ";", "prop", ".", "store", "(", "fos", ",", "\"Global properties for jCalc\"", ")", ";", "fos", ".", "close", "(", ")", ";", "fos", ".", "flush", "(", ")", ";", "}", "}" ]
File location ..\bin\org.jdice.calc.properties File content: roundingMode=HALF_UP stripTrailingZeros=true decimalSeparator.out='.' decimalSeparator.in='.' numconverter[0]=org.jdice.calc.test.NumTest$CustomObject > org.jdice.calc.test.NumTest$CustomObjectNumConverter operator[0]=org.jdice.calc.test.CustomOperatorFunctionTest$QuestionOperator function[0]=org.jdice.calc.test.CustomOperatorFunctionTest$SumFunction @throws IOException
[ "File", "location", "..", "\\", "bin", "\\", "org", ".", "jdice", ".", "calc", ".", "properties" ]
36ae1f9adfe611a6f1bd8ef87cf1dc0ec88ac035
https://github.com/d-sauer/JCalcAPI/blob/36ae1f9adfe611a6f1bd8ef87cf1dc0ec88ac035/src/main/java/org/jdice/calc/Properties.java#L344-L399
156,373
intellimate/Izou
src/main/java/org/intellimate/izou/events/EventDistributor.java
EventDistributor.checkEventsControllers
private boolean checkEventsControllers(EventModel event) { List<CompletableFuture<Boolean>> collect = eventsControllers.stream() .map(controller -> submit(() -> controller.controlEventDispatcher(event)).thenApply(result -> { if (!result) debug("Event: " + event + " is canceled by " + controller.getID()); return result; })) .collect(Collectors.toList()); try { collect = timeOut(collect, 1000); } catch (InterruptedException e) { debug("interrupted"); } return collect.stream() .map(future -> { try { return future.get(); } catch (InterruptedException | ExecutionException e) { return null; } }) .filter(Objects::nonNull) .noneMatch(bool -> !bool); }
java
private boolean checkEventsControllers(EventModel event) { List<CompletableFuture<Boolean>> collect = eventsControllers.stream() .map(controller -> submit(() -> controller.controlEventDispatcher(event)).thenApply(result -> { if (!result) debug("Event: " + event + " is canceled by " + controller.getID()); return result; })) .collect(Collectors.toList()); try { collect = timeOut(collect, 1000); } catch (InterruptedException e) { debug("interrupted"); } return collect.stream() .map(future -> { try { return future.get(); } catch (InterruptedException | ExecutionException e) { return null; } }) .filter(Objects::nonNull) .noneMatch(bool -> !bool); }
[ "private", "boolean", "checkEventsControllers", "(", "EventModel", "event", ")", "{", "List", "<", "CompletableFuture", "<", "Boolean", ">>", "collect", "=", "eventsControllers", ".", "stream", "(", ")", ".", "map", "(", "controller", "->", "submit", "(", "(", ")", "->", "controller", ".", "controlEventDispatcher", "(", "event", ")", ")", ".", "thenApply", "(", "result", "->", "{", "if", "(", "!", "result", ")", "debug", "(", "\"Event: \"", "+", "event", "+", "\" is canceled by \"", "+", "controller", ".", "getID", "(", ")", ")", ";", "return", "result", ";", "}", ")", ")", ".", "collect", "(", "Collectors", ".", "toList", "(", ")", ")", ";", "try", "{", "collect", "=", "timeOut", "(", "collect", ",", "1000", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "debug", "(", "\"interrupted\"", ")", ";", "}", "return", "collect", ".", "stream", "(", ")", ".", "map", "(", "future", "->", "{", "try", "{", "return", "future", ".", "get", "(", ")", ";", "}", "catch", "(", "InterruptedException", "|", "ExecutionException", "e", ")", "{", "return", "null", ";", "}", "}", ")", ".", "filter", "(", "Objects", "::", "nonNull", ")", ".", "noneMatch", "(", "bool", "->", "!", "bool", ")", ";", "}" ]
Checks whether to dispatch an event @param event the fired Event @return true if the event should be fired
[ "Checks", "whether", "to", "dispatch", "an", "event" ]
40a808b97998e17655c4a78e30ce7326148aed27
https://github.com/intellimate/Izou/blob/40a808b97998e17655c4a78e30ce7326148aed27/src/main/java/org/intellimate/izou/events/EventDistributor.java#L285-L308
156,374
intellimate/Izou
src/main/java/org/intellimate/izou/events/EventDistributor.java
EventDistributor.processEvent
private void processEvent(EventModel<?> event) { if (!event.getSource().isCreatedFromInstance()) { error("event: " + event + "has invalid source"); return; } debug("EventFired: " + event.toString() + " from " + event.getSource().getID()); submit(() -> event.lifecycleCallback(EventLifeCycle.START)); if (checkEventsControllers(event)) { submit(() -> event.lifecycleCallback(EventLifeCycle.APPROVED)); submit(() -> event.lifecycleCallback(EventLifeCycle.RESOURCE)); List<ResourceModel> resourceList = getMain().getResourceManager().generateResources(event); event.addResources(resourceList); submit(() -> event.lifecycleCallback(EventLifeCycle.LISTENERS)); List<EventListenerModel> listenersTemp = event.getAllInformations().parallelStream() .map(listeners::get) .filter(Objects::nonNull) .flatMap(Collection::stream) .distinct() .collect(Collectors.toList()); List<CompletableFuture> futures = listenersTemp.stream() .map(eventListener -> submit(() -> eventListener.eventFired(event))) .collect(Collectors.toList()); try { timeOut(futures, 1000); } catch (InterruptedException e) { error("interrupted", e); } submit(() -> event.lifecycleCallback(EventLifeCycle.OUTPUT)); getMain().getOutputManager().passDataToOutputPlugins(event); submit(() -> event.lifecycleCallback(EventLifeCycle.ENDED)); List<EventListenerModel> finishListenersTemp = event.getAllInformations().parallelStream() .map(finishListeners::get) .filter(Objects::nonNull) .flatMap(Collection::stream) .distinct() .collect(Collectors.toList()); futures = finishListenersTemp.stream() .map(eventListener -> submit(() -> eventListener.eventFired(event))) .collect(Collectors.toList()); try { timeOut(futures, 1000); } catch (InterruptedException e) { error("interrupted", e); } } else { debug("canceling: " + event.toString() + " from " + event.getSource().getID()); submit(() -> event.lifecycleCallback(EventLifeCycle.CANCELED)); } }
java
private void processEvent(EventModel<?> event) { if (!event.getSource().isCreatedFromInstance()) { error("event: " + event + "has invalid source"); return; } debug("EventFired: " + event.toString() + " from " + event.getSource().getID()); submit(() -> event.lifecycleCallback(EventLifeCycle.START)); if (checkEventsControllers(event)) { submit(() -> event.lifecycleCallback(EventLifeCycle.APPROVED)); submit(() -> event.lifecycleCallback(EventLifeCycle.RESOURCE)); List<ResourceModel> resourceList = getMain().getResourceManager().generateResources(event); event.addResources(resourceList); submit(() -> event.lifecycleCallback(EventLifeCycle.LISTENERS)); List<EventListenerModel> listenersTemp = event.getAllInformations().parallelStream() .map(listeners::get) .filter(Objects::nonNull) .flatMap(Collection::stream) .distinct() .collect(Collectors.toList()); List<CompletableFuture> futures = listenersTemp.stream() .map(eventListener -> submit(() -> eventListener.eventFired(event))) .collect(Collectors.toList()); try { timeOut(futures, 1000); } catch (InterruptedException e) { error("interrupted", e); } submit(() -> event.lifecycleCallback(EventLifeCycle.OUTPUT)); getMain().getOutputManager().passDataToOutputPlugins(event); submit(() -> event.lifecycleCallback(EventLifeCycle.ENDED)); List<EventListenerModel> finishListenersTemp = event.getAllInformations().parallelStream() .map(finishListeners::get) .filter(Objects::nonNull) .flatMap(Collection::stream) .distinct() .collect(Collectors.toList()); futures = finishListenersTemp.stream() .map(eventListener -> submit(() -> eventListener.eventFired(event))) .collect(Collectors.toList()); try { timeOut(futures, 1000); } catch (InterruptedException e) { error("interrupted", e); } } else { debug("canceling: " + event.toString() + " from " + event.getSource().getID()); submit(() -> event.lifecycleCallback(EventLifeCycle.CANCELED)); } }
[ "private", "void", "processEvent", "(", "EventModel", "<", "?", ">", "event", ")", "{", "if", "(", "!", "event", ".", "getSource", "(", ")", ".", "isCreatedFromInstance", "(", ")", ")", "{", "error", "(", "\"event: \"", "+", "event", "+", "\"has invalid source\"", ")", ";", "return", ";", "}", "debug", "(", "\"EventFired: \"", "+", "event", ".", "toString", "(", ")", "+", "\" from \"", "+", "event", ".", "getSource", "(", ")", ".", "getID", "(", ")", ")", ";", "submit", "(", "(", ")", "->", "event", ".", "lifecycleCallback", "(", "EventLifeCycle", ".", "START", ")", ")", ";", "if", "(", "checkEventsControllers", "(", "event", ")", ")", "{", "submit", "(", "(", ")", "->", "event", ".", "lifecycleCallback", "(", "EventLifeCycle", ".", "APPROVED", ")", ")", ";", "submit", "(", "(", ")", "->", "event", ".", "lifecycleCallback", "(", "EventLifeCycle", ".", "RESOURCE", ")", ")", ";", "List", "<", "ResourceModel", ">", "resourceList", "=", "getMain", "(", ")", ".", "getResourceManager", "(", ")", ".", "generateResources", "(", "event", ")", ";", "event", ".", "addResources", "(", "resourceList", ")", ";", "submit", "(", "(", ")", "->", "event", ".", "lifecycleCallback", "(", "EventLifeCycle", ".", "LISTENERS", ")", ")", ";", "List", "<", "EventListenerModel", ">", "listenersTemp", "=", "event", ".", "getAllInformations", "(", ")", ".", "parallelStream", "(", ")", ".", "map", "(", "listeners", "::", "get", ")", ".", "filter", "(", "Objects", "::", "nonNull", ")", ".", "flatMap", "(", "Collection", "::", "stream", ")", ".", "distinct", "(", ")", ".", "collect", "(", "Collectors", ".", "toList", "(", ")", ")", ";", "List", "<", "CompletableFuture", ">", "futures", "=", "listenersTemp", ".", "stream", "(", ")", ".", "map", "(", "eventListener", "->", "submit", "(", "(", ")", "->", "eventListener", ".", "eventFired", "(", "event", ")", ")", ")", ".", "collect", "(", "Collectors", ".", "toList", "(", ")", ")", ";", "try", "{", "timeOut", "(", "futures", ",", "1000", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "error", "(", "\"interrupted\"", ",", "e", ")", ";", "}", "submit", "(", "(", ")", "->", "event", ".", "lifecycleCallback", "(", "EventLifeCycle", ".", "OUTPUT", ")", ")", ";", "getMain", "(", ")", ".", "getOutputManager", "(", ")", ".", "passDataToOutputPlugins", "(", "event", ")", ";", "submit", "(", "(", ")", "->", "event", ".", "lifecycleCallback", "(", "EventLifeCycle", ".", "ENDED", ")", ")", ";", "List", "<", "EventListenerModel", ">", "finishListenersTemp", "=", "event", ".", "getAllInformations", "(", ")", ".", "parallelStream", "(", ")", ".", "map", "(", "finishListeners", "::", "get", ")", ".", "filter", "(", "Objects", "::", "nonNull", ")", ".", "flatMap", "(", "Collection", "::", "stream", ")", ".", "distinct", "(", ")", ".", "collect", "(", "Collectors", ".", "toList", "(", ")", ")", ";", "futures", "=", "finishListenersTemp", ".", "stream", "(", ")", ".", "map", "(", "eventListener", "->", "submit", "(", "(", ")", "->", "eventListener", ".", "eventFired", "(", "event", ")", ")", ")", ".", "collect", "(", "Collectors", ".", "toList", "(", ")", ")", ";", "try", "{", "timeOut", "(", "futures", ",", "1000", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "error", "(", "\"interrupted\"", ",", "e", ")", ";", "}", "}", "else", "{", "debug", "(", "\"canceling: \"", "+", "event", ".", "toString", "(", ")", "+", "\" from \"", "+", "event", ".", "getSource", "(", ")", ".", "getID", "(", ")", ")", ";", "submit", "(", "(", ")", "->", "event", ".", "lifecycleCallback", "(", "EventLifeCycle", ".", "CANCELED", ")", ")", ";", "}", "}" ]
process the Event @param event the event to process
[ "process", "the", "Event" ]
40a808b97998e17655c4a78e30ce7326148aed27
https://github.com/intellimate/Izou/blob/40a808b97998e17655c4a78e30ce7326148aed27/src/main/java/org/intellimate/izou/events/EventDistributor.java#L341-L393
156,375
clanie/clanie-core
src/main/java/dk/clanie/collections/Tuple.java
Tuple.compareTo
@Override public int compareTo(Tuple other) { int temp = compareItems(other); if (temp != 0) return temp; // All compared elements were equal. // If 'other' is of another class than 'this', it must have // more elements, and therefore it is considered greatest; // otherwise the tuples are equal. return getClass() == other.getClass() ? 0 : -1; }
java
@Override public int compareTo(Tuple other) { int temp = compareItems(other); if (temp != 0) return temp; // All compared elements were equal. // If 'other' is of another class than 'this', it must have // more elements, and therefore it is considered greatest; // otherwise the tuples are equal. return getClass() == other.getClass() ? 0 : -1; }
[ "@", "Override", "public", "int", "compareTo", "(", "Tuple", "other", ")", "{", "int", "temp", "=", "compareItems", "(", "other", ")", ";", "if", "(", "temp", "!=", "0", ")", "return", "temp", ";", "// All compared elements were equal.", "// If 'other' is of another class than 'this', it must have", "// more elements, and therefore it is considered greatest;", "// otherwise the tuples are equal.", "return", "getClass", "(", ")", "==", "other", ".", "getClass", "(", ")", "?", "0", ":", "-", "1", ";", "}" ]
Compares this Tuple with another Tuple for order. Tuples are compared by comparing each of their elements. Tuples with more elements are considered greater than Tuples with fewer, but otherwise equal, elements. @see java.lang.Comparable#compareTo(java.lang.Object) @return A negative integer, zero or a positive integer as this Tuple is less than, equal to or greater than the specified Tuple. @throws ClassCastException if the items in this and the other Tuple aren't compatible, if they don't implement {@link Comparable}.
[ "Compares", "this", "Tuple", "with", "another", "Tuple", "for", "order", "." ]
ac8a655b93127f0e281b741c4d53f429be2816ad
https://github.com/clanie/clanie-core/blob/ac8a655b93127f0e281b741c4d53f429be2816ad/src/main/java/dk/clanie/collections/Tuple.java#L320-L329
156,376
clanie/clanie-core
src/main/java/dk/clanie/collections/Tuple.java
Tuple.elementsEquals
protected static boolean elementsEquals(Object e1, Object e2) { return (e1 == null && e2 == null) || e1.equals(e2); }
java
protected static boolean elementsEquals(Object e1, Object e2) { return (e1 == null && e2 == null) || e1.equals(e2); }
[ "protected", "static", "boolean", "elementsEquals", "(", "Object", "e1", ",", "Object", "e2", ")", "{", "return", "(", "e1", "==", "null", "&&", "e2", "==", "null", ")", "||", "e1", ".", "equals", "(", "e2", ")", ";", "}" ]
Helper-method to check if two elements are equal. @param e1 @param e2 @return true if both e1 and e2 are null or if e1.equals(e2).
[ "Helper", "-", "method", "to", "check", "if", "two", "elements", "are", "equal", "." ]
ac8a655b93127f0e281b741c4d53f429be2816ad
https://github.com/clanie/clanie-core/blob/ac8a655b93127f0e281b741c4d53f429be2816ad/src/main/java/dk/clanie/collections/Tuple.java#L348-L350
156,377
dbracewell/hermes
hermes-core/src/main/java/com/davidbracewell/hermes/Document.java
Document.setId
public void setId(String id) { if (StringUtils.isNullOrBlank(id)) { this.id = UUID.randomUUID().toString(); } else { this.id = id; } }
java
public void setId(String id) { if (StringUtils.isNullOrBlank(id)) { this.id = UUID.randomUUID().toString(); } else { this.id = id; } }
[ "public", "void", "setId", "(", "String", "id", ")", "{", "if", "(", "StringUtils", ".", "isNullOrBlank", "(", "id", ")", ")", "{", "this", ".", "id", "=", "UUID", ".", "randomUUID", "(", ")", ".", "toString", "(", ")", ";", "}", "else", "{", "this", ".", "id", "=", "id", ";", "}", "}" ]
Sets the id of the document. If a null or blank id is given a random id will generated. @param id The new id of the document
[ "Sets", "the", "id", "of", "the", "document", ".", "If", "a", "null", "or", "blank", "id", "is", "given", "a", "random", "id", "will", "generated", "." ]
9ebefe7ad5dea1b731ae6931a30771eb75325ea3
https://github.com/dbracewell/hermes/blob/9ebefe7ad5dea1b731ae6931a30771eb75325ea3/hermes-core/src/main/java/com/davidbracewell/hermes/Document.java#L459-L465
156,378
dbracewell/hermes
hermes-core/src/main/java/com/davidbracewell/hermes/Document.java
Document.toJson
public String toJson() { try { Resource stringResource = Resources.fromString(); write(stringResource); return stringResource.readToString().trim(); } catch (IOException e) { throw Throwables.propagate(e); } }
java
public String toJson() { try { Resource stringResource = Resources.fromString(); write(stringResource); return stringResource.readToString().trim(); } catch (IOException e) { throw Throwables.propagate(e); } }
[ "public", "String", "toJson", "(", ")", "{", "try", "{", "Resource", "stringResource", "=", "Resources", ".", "fromString", "(", ")", ";", "write", "(", "stringResource", ")", ";", "return", "stringResource", ".", "readToString", "(", ")", ".", "trim", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "Throwables", ".", "propagate", "(", "e", ")", ";", "}", "}" ]
Converts the document to json @return JSON representation of the document
[ "Converts", "the", "document", "to", "json" ]
9ebefe7ad5dea1b731ae6931a30771eb75325ea3
https://github.com/dbracewell/hermes/blob/9ebefe7ad5dea1b731ae6931a30771eb75325ea3/hermes-core/src/main/java/com/davidbracewell/hermes/Document.java#L539-L547
156,379
PureSolTechnologies/versioning
versioning/src/main/java/com/puresoltechnologies/versioning/VersionRange.java
VersionRange.includes
public final boolean includes(Version version) { if (minimum != null) { int minimumComparison = minimum.compareTo(version); if (minimumComparison > 0) { return false; } if ((!minimumIncluded) && (minimumComparison == 0)) { return false; } } if (maximum != null) { int maximumComparison = maximum.compareTo(version); if (maximumComparison < 0) { return false; } if ((!maximumIncluded) && (maximumComparison == 0)) { return false; } } return true; }
java
public final boolean includes(Version version) { if (minimum != null) { int minimumComparison = minimum.compareTo(version); if (minimumComparison > 0) { return false; } if ((!minimumIncluded) && (minimumComparison == 0)) { return false; } } if (maximum != null) { int maximumComparison = maximum.compareTo(version); if (maximumComparison < 0) { return false; } if ((!maximumIncluded) && (maximumComparison == 0)) { return false; } } return true; }
[ "public", "final", "boolean", "includes", "(", "Version", "version", ")", "{", "if", "(", "minimum", "!=", "null", ")", "{", "int", "minimumComparison", "=", "minimum", ".", "compareTo", "(", "version", ")", ";", "if", "(", "minimumComparison", ">", "0", ")", "{", "return", "false", ";", "}", "if", "(", "(", "!", "minimumIncluded", ")", "&&", "(", "minimumComparison", "==", "0", ")", ")", "{", "return", "false", ";", "}", "}", "if", "(", "maximum", "!=", "null", ")", "{", "int", "maximumComparison", "=", "maximum", ".", "compareTo", "(", "version", ")", ";", "if", "(", "maximumComparison", "<", "0", ")", "{", "return", "false", ";", "}", "if", "(", "(", "!", "maximumIncluded", ")", "&&", "(", "maximumComparison", "==", "0", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Checks whether a specified version is included in the version range or not. @param version is the {@link Version} to be tested agains this range. @return <code>true</code> is returned in case the version is within the current range. <code>false</code> is returned otherwise.
[ "Checks", "whether", "a", "specified", "version", "is", "included", "in", "the", "version", "range", "or", "not", "." ]
7e0d8022ba391938f1b419e353de6e99a27db19f
https://github.com/PureSolTechnologies/versioning/blob/7e0d8022ba391938f1b419e353de6e99a27db19f/versioning/src/main/java/com/puresoltechnologies/versioning/VersionRange.java#L138-L158
156,380
Skullabs/powerlib
src/main/java/power/io/ZipExtractor.java
ZipExtractor.into
public ZipExtractor into( File directory ) throws IOException { try { ensureThatDirectoryExists( directory ); writeEntriesIntoDirectory(directory); return this; } catch ( IOException cause ) { close(); throw cause; } }
java
public ZipExtractor into( File directory ) throws IOException { try { ensureThatDirectoryExists( directory ); writeEntriesIntoDirectory(directory); return this; } catch ( IOException cause ) { close(); throw cause; } }
[ "public", "ZipExtractor", "into", "(", "File", "directory", ")", "throws", "IOException", "{", "try", "{", "ensureThatDirectoryExists", "(", "directory", ")", ";", "writeEntriesIntoDirectory", "(", "directory", ")", ";", "return", "this", ";", "}", "catch", "(", "IOException", "cause", ")", "{", "close", "(", ")", ";", "throw", "cause", ";", "}", "}" ]
Extracts the zip content into a file. It only automatically closes the stream when an exception is thrown. @param directory @throws IOException
[ "Extracts", "the", "zip", "content", "into", "a", "file", ".", "It", "only", "automatically", "closes", "the", "stream", "when", "an", "exception", "is", "thrown", "." ]
55d4b6684908113a2d5b9d5666bb686fa172097a
https://github.com/Skullabs/powerlib/blob/55d4b6684908113a2d5b9d5666bb686fa172097a/src/main/java/power/io/ZipExtractor.java#L54-L63
156,381
pip-services3-java/pip-services3-components-java
src/org/pipservices3/components/config/JsonConfigReader.java
JsonConfigReader.readConfig
@Override public ConfigParams readConfig(String correlationId, ConfigParams parameters) throws ApplicationException { Object value = readObject(correlationId, parameters); return ConfigParams.fromValue(value); }
java
@Override public ConfigParams readConfig(String correlationId, ConfigParams parameters) throws ApplicationException { Object value = readObject(correlationId, parameters); return ConfigParams.fromValue(value); }
[ "@", "Override", "public", "ConfigParams", "readConfig", "(", "String", "correlationId", ",", "ConfigParams", "parameters", ")", "throws", "ApplicationException", "{", "Object", "value", "=", "readObject", "(", "correlationId", ",", "parameters", ")", ";", "return", "ConfigParams", ".", "fromValue", "(", "value", ")", ";", "}" ]
Reads configuration and parameterize it with given values. @param correlationId (optional) transaction id to trace execution through call chain. @param parameters values to parameters the configuration @return ConfigParams configuration. @throws ApplicationException when error occured.
[ "Reads", "configuration", "and", "parameterize", "it", "with", "given", "values", "." ]
122352fbf9b208f6417376da7b8ad725bc85ee58
https://github.com/pip-services3-java/pip-services3-components-java/blob/122352fbf9b208f6417376da7b8ad725bc85ee58/src/org/pipservices3/components/config/JsonConfigReader.java#L98-L102
156,382
d-sauer/JCalcAPI
src/main/java/org/jdice/calc/AbstractCalculator.java
AbstractCalculator.detectImplmentedExtension
private void detectImplmentedExtension() { if (isImplExtRegistered == false) { Object o = getThis(); Class thisClass = o.getClass(); // superclass interfaces Class[] declared = thisClass.getSuperclass().getInterfaces(); for (Class declare : declared) { detectImplmentedExtension(declare); } // subclass interfaces declared = thisClass.getInterfaces(); for (Class declare : declared) { detectImplmentedExtension(declare); } isImplExtRegistered = true; } }
java
private void detectImplmentedExtension() { if (isImplExtRegistered == false) { Object o = getThis(); Class thisClass = o.getClass(); // superclass interfaces Class[] declared = thisClass.getSuperclass().getInterfaces(); for (Class declare : declared) { detectImplmentedExtension(declare); } // subclass interfaces declared = thisClass.getInterfaces(); for (Class declare : declared) { detectImplmentedExtension(declare); } isImplExtRegistered = true; } }
[ "private", "void", "detectImplmentedExtension", "(", ")", "{", "if", "(", "isImplExtRegistered", "==", "false", ")", "{", "Object", "o", "=", "getThis", "(", ")", ";", "Class", "thisClass", "=", "o", ".", "getClass", "(", ")", ";", "// superclass interfaces\r", "Class", "[", "]", "declared", "=", "thisClass", ".", "getSuperclass", "(", ")", ".", "getInterfaces", "(", ")", ";", "for", "(", "Class", "declare", ":", "declared", ")", "{", "detectImplmentedExtension", "(", "declare", ")", ";", "}", "// subclass interfaces\r", "declared", "=", "thisClass", ".", "getInterfaces", "(", ")", ";", "for", "(", "Class", "declare", ":", "declared", ")", "{", "detectImplmentedExtension", "(", "declare", ")", ";", "}", "isImplExtRegistered", "=", "true", ";", "}", "}" ]
Read implemented extensions by subclass
[ "Read", "implemented", "extensions", "by", "subclass" ]
36ae1f9adfe611a6f1bd8ef87cf1dc0ec88ac035
https://github.com/d-sauer/JCalcAPI/blob/36ae1f9adfe611a6f1bd8ef87cf1dc0ec88ac035/src/main/java/org/jdice/calc/AbstractCalculator.java#L78-L96
156,383
d-sauer/JCalcAPI
src/main/java/org/jdice/calc/AbstractCalculator.java
AbstractCalculator.detectImplmentedExtension
private void detectImplmentedExtension(Class declare) { Class c = BindExtensionProvider.getExtension(declare); if (c == null && declare.isAnnotationPresent(BindExtension.class)) { BindExtension impl = (BindExtension) declare.getAnnotation(BindExtension.class); if (impl != null) c = impl.implementation(); BindExtensionProvider.bind(declare, c); } if (c != null) { if (Operator.class.isAssignableFrom(c)) CacheExtension.setOperator(c); if (Function.class.isAssignableFrom(c)) CacheExtension.setFunction(c); } }
java
private void detectImplmentedExtension(Class declare) { Class c = BindExtensionProvider.getExtension(declare); if (c == null && declare.isAnnotationPresent(BindExtension.class)) { BindExtension impl = (BindExtension) declare.getAnnotation(BindExtension.class); if (impl != null) c = impl.implementation(); BindExtensionProvider.bind(declare, c); } if (c != null) { if (Operator.class.isAssignableFrom(c)) CacheExtension.setOperator(c); if (Function.class.isAssignableFrom(c)) CacheExtension.setFunction(c); } }
[ "private", "void", "detectImplmentedExtension", "(", "Class", "declare", ")", "{", "Class", "c", "=", "BindExtensionProvider", ".", "getExtension", "(", "declare", ")", ";", "if", "(", "c", "==", "null", "&&", "declare", ".", "isAnnotationPresent", "(", "BindExtension", ".", "class", ")", ")", "{", "BindExtension", "impl", "=", "(", "BindExtension", ")", "declare", ".", "getAnnotation", "(", "BindExtension", ".", "class", ")", ";", "if", "(", "impl", "!=", "null", ")", "c", "=", "impl", ".", "implementation", "(", ")", ";", "BindExtensionProvider", ".", "bind", "(", "declare", ",", "c", ")", ";", "}", "if", "(", "c", "!=", "null", ")", "{", "if", "(", "Operator", ".", "class", ".", "isAssignableFrom", "(", "c", ")", ")", "CacheExtension", ".", "setOperator", "(", "c", ")", ";", "if", "(", "Function", ".", "class", ".", "isAssignableFrom", "(", "c", ")", ")", "CacheExtension", ".", "setFunction", "(", "c", ")", ";", "}", "}" ]
Register defined operation or function class to global cache @param declare
[ "Register", "defined", "operation", "or", "function", "class", "to", "global", "cache" ]
36ae1f9adfe611a6f1bd8ef87cf1dc0ec88ac035
https://github.com/d-sauer/JCalcAPI/blob/36ae1f9adfe611a6f1bd8ef87cf1dc0ec88ac035/src/main/java/org/jdice/calc/AbstractCalculator.java#L103-L118
156,384
d-sauer/JCalcAPI
src/main/java/org/jdice/calc/AbstractCalculator.java
AbstractCalculator.operator
protected final CALC operator(Class<? extends Operator> operator, Object value) { Num tmp = null; if (value instanceof Num) tmp = (Num)value; else tmp = new Num(value); infix.add(CacheExtension.getOperator(operator)); infix.add(tmp); return getThis(); }
java
protected final CALC operator(Class<? extends Operator> operator, Object value) { Num tmp = null; if (value instanceof Num) tmp = (Num)value; else tmp = new Num(value); infix.add(CacheExtension.getOperator(operator)); infix.add(tmp); return getThis(); }
[ "protected", "final", "CALC", "operator", "(", "Class", "<", "?", "extends", "Operator", ">", "operator", ",", "Object", "value", ")", "{", "Num", "tmp", "=", "null", ";", "if", "(", "value", "instanceof", "Num", ")", "tmp", "=", "(", "Num", ")", "value", ";", "else", "tmp", "=", "new", "Num", "(", "value", ")", ";", "infix", ".", "add", "(", "CacheExtension", ".", "getOperator", "(", "operator", ")", ")", ";", "infix", ".", "add", "(", "tmp", ")", ";", "return", "getThis", "(", ")", ";", "}" ]
Append operator and number to expression @param operator @param value @return
[ "Append", "operator", "and", "number", "to", "expression" ]
36ae1f9adfe611a6f1bd8ef87cf1dc0ec88ac035
https://github.com/d-sauer/JCalcAPI/blob/36ae1f9adfe611a6f1bd8ef87cf1dc0ec88ac035/src/main/java/org/jdice/calc/AbstractCalculator.java#L213-L223
156,385
d-sauer/JCalcAPI
src/main/java/org/jdice/calc/AbstractCalculator.java
AbstractCalculator.operator
protected final CALC operator(Class<? extends Operator> operator, String value, char decimalSeparator) { return operator(operator, new Num(value, decimalSeparator)); }
java
protected final CALC operator(Class<? extends Operator> operator, String value, char decimalSeparator) { return operator(operator, new Num(value, decimalSeparator)); }
[ "protected", "final", "CALC", "operator", "(", "Class", "<", "?", "extends", "Operator", ">", "operator", ",", "String", "value", ",", "char", "decimalSeparator", ")", "{", "return", "operator", "(", "operator", ",", "new", "Num", "(", "value", ",", "decimalSeparator", ")", ")", ";", "}" ]
Append operator and parsed String value with custom decimal separator used in String representation of value @param operator @param value @param decimalSeparator @return
[ "Append", "operator", "and", "parsed", "String", "value", "with", "custom", "decimal", "separator", "used", "in", "String", "representation", "of", "value" ]
36ae1f9adfe611a6f1bd8ef87cf1dc0ec88ac035
https://github.com/d-sauer/JCalcAPI/blob/36ae1f9adfe611a6f1bd8ef87cf1dc0ec88ac035/src/main/java/org/jdice/calc/AbstractCalculator.java#L232-L234
156,386
d-sauer/JCalcAPI
src/main/java/org/jdice/calc/AbstractCalculator.java
AbstractCalculator.function
public final CALC function(Class<? extends Function> function, Object... values) { Function fn = CacheExtension.getFunction(function); FunctionData fd = new FunctionData(fn, values); this.infix.addFunction(fd); return getThis(); }
java
public final CALC function(Class<? extends Function> function, Object... values) { Function fn = CacheExtension.getFunction(function); FunctionData fd = new FunctionData(fn, values); this.infix.addFunction(fd); return getThis(); }
[ "public", "final", "CALC", "function", "(", "Class", "<", "?", "extends", "Function", ">", "function", ",", "Object", "...", "values", ")", "{", "Function", "fn", "=", "CacheExtension", ".", "getFunction", "(", "function", ")", ";", "FunctionData", "fd", "=", "new", "FunctionData", "(", "fn", ",", "values", ")", ";", "this", ".", "infix", ".", "addFunction", "(", "fd", ")", ";", "return", "getThis", "(", ")", ";", "}" ]
Append function with value to expression. <br/> e.g. Abs.class, -5 => abs(-5) @param function @param values can accept any object that {@link Num} can work with @return @see {@link Function}
[ "Append", "function", "with", "value", "to", "expression", "." ]
36ae1f9adfe611a6f1bd8ef87cf1dc0ec88ac035
https://github.com/d-sauer/JCalcAPI/blob/36ae1f9adfe611a6f1bd8ef87cf1dc0ec88ac035/src/main/java/org/jdice/calc/AbstractCalculator.java#L247-L253
156,387
d-sauer/JCalcAPI
src/main/java/org/jdice/calc/AbstractCalculator.java
AbstractCalculator.expression
public final CALC expression(String expression) throws ParseException { detectImplmentedExtension(); if (infixParser == null) infixParser = new InfixParser(); CList infix = infixParser.parse(useExtensions, getProperties(), expression); expression(infix, false); return getThis(); }
java
public final CALC expression(String expression) throws ParseException { detectImplmentedExtension(); if (infixParser == null) infixParser = new InfixParser(); CList infix = infixParser.parse(useExtensions, getProperties(), expression); expression(infix, false); return getThis(); }
[ "public", "final", "CALC", "expression", "(", "String", "expression", ")", "throws", "ParseException", "{", "detectImplmentedExtension", "(", ")", ";", "if", "(", "infixParser", "==", "null", ")", "infixParser", "=", "new", "InfixParser", "(", ")", ";", "CList", "infix", "=", "infixParser", ".", "parse", "(", "useExtensions", ",", "getProperties", "(", ")", ",", "expression", ")", ";", "expression", "(", "infix", ",", "false", ")", ";", "return", "getThis", "(", ")", ";", "}" ]
Parse and append given expression to existing expression @param expression @return @throws ParseException
[ "Parse", "and", "append", "given", "expression", "to", "existing", "expression" ]
36ae1f9adfe611a6f1bd8ef87cf1dc0ec88ac035
https://github.com/d-sauer/JCalcAPI/blob/36ae1f9adfe611a6f1bd8ef87cf1dc0ec88ac035/src/main/java/org/jdice/calc/AbstractCalculator.java#L262-L271
156,388
d-sauer/JCalcAPI
src/main/java/org/jdice/calc/AbstractCalculator.java
AbstractCalculator.setDecimalSeparator
public CALC setDecimalSeparator(char decimalSeparator) { getProperties().setInputDecimalSeparator(decimalSeparator); getProperties().setOutputDecimalSeparator(decimalSeparator); return getThis(); }
java
public CALC setDecimalSeparator(char decimalSeparator) { getProperties().setInputDecimalSeparator(decimalSeparator); getProperties().setOutputDecimalSeparator(decimalSeparator); return getThis(); }
[ "public", "CALC", "setDecimalSeparator", "(", "char", "decimalSeparator", ")", "{", "getProperties", "(", ")", ".", "setInputDecimalSeparator", "(", "decimalSeparator", ")", ";", "getProperties", "(", ")", ".", "setOutputDecimalSeparator", "(", "decimalSeparator", ")", ";", "return", "getThis", "(", ")", ";", "}" ]
Set decimal separator for entire expression @param decimalSeparator @return
[ "Set", "decimal", "separator", "for", "entire", "expression" ]
36ae1f9adfe611a6f1bd8ef87cf1dc0ec88ac035
https://github.com/d-sauer/JCalcAPI/blob/36ae1f9adfe611a6f1bd8ef87cf1dc0ec88ac035/src/main/java/org/jdice/calc/AbstractCalculator.java#L430-L434
156,389
d-sauer/JCalcAPI
src/main/java/org/jdice/calc/AbstractCalculator.java
AbstractCalculator.calculate
public Num calculate() { unbind(); prepareForNewCalculation(); PostfixCalculator pc = convertToPostfix(); Num cv = pc.calculate(this, postfix, trackSteps); lastCalculatedValue = cv.clone(); return cv; }
java
public Num calculate() { unbind(); prepareForNewCalculation(); PostfixCalculator pc = convertToPostfix(); Num cv = pc.calculate(this, postfix, trackSteps); lastCalculatedValue = cv.clone(); return cv; }
[ "public", "Num", "calculate", "(", ")", "{", "unbind", "(", ")", ";", "prepareForNewCalculation", "(", ")", ";", "PostfixCalculator", "pc", "=", "convertToPostfix", "(", ")", ";", "Num", "cv", "=", "pc", ".", "calculate", "(", "this", ",", "postfix", ",", "trackSteps", ")", ";", "lastCalculatedValue", "=", "cv", ".", "clone", "(", ")", ";", "return", "cv", ";", "}" ]
Calculate prepared expression. For tracking calculation @return @see {@link #calculate()} @see {@link #getCalculatedValue()}
[ "Calculate", "prepared", "expression", "." ]
36ae1f9adfe611a6f1bd8ef87cf1dc0ec88ac035
https://github.com/d-sauer/JCalcAPI/blob/36ae1f9adfe611a6f1bd8ef87cf1dc0ec88ac035/src/main/java/org/jdice/calc/AbstractCalculator.java#L511-L521
156,390
d-sauer/JCalcAPI
src/main/java/org/jdice/calc/AbstractCalculator.java
AbstractCalculator.bind
public <T extends AbstractCalculator> T bind(Class<T> clazz) { T childCalc = null; try { childCalc = clazz.newInstance(); } catch (Exception e) { throw new CalculatorException(e); } if (childCalc instanceof AbstractCalculator) { // find last child from root AbstractCalculator<CALC> bParent = this; while (bParent != null) { if (bParent.childCalculator != null) bParent = bParent.childCalculator; else break; } ((AbstractCalculator) childCalc).parentCalculator = bParent; ((AbstractCalculator) childCalc).isBind = true; bParent.childCalculator = childCalc; } else { throw new CalculatorException("Use calculator which is type of AbstractCalculator", new IllegalArgumentException()); } return childCalc; }
java
public <T extends AbstractCalculator> T bind(Class<T> clazz) { T childCalc = null; try { childCalc = clazz.newInstance(); } catch (Exception e) { throw new CalculatorException(e); } if (childCalc instanceof AbstractCalculator) { // find last child from root AbstractCalculator<CALC> bParent = this; while (bParent != null) { if (bParent.childCalculator != null) bParent = bParent.childCalculator; else break; } ((AbstractCalculator) childCalc).parentCalculator = bParent; ((AbstractCalculator) childCalc).isBind = true; bParent.childCalculator = childCalc; } else { throw new CalculatorException("Use calculator which is type of AbstractCalculator", new IllegalArgumentException()); } return childCalc; }
[ "public", "<", "T", "extends", "AbstractCalculator", ">", "T", "bind", "(", "Class", "<", "T", ">", "clazz", ")", "{", "T", "childCalc", "=", "null", ";", "try", "{", "childCalc", "=", "clazz", ".", "newInstance", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "CalculatorException", "(", "e", ")", ";", "}", "if", "(", "childCalc", "instanceof", "AbstractCalculator", ")", "{", "// find last child from root\r", "AbstractCalculator", "<", "CALC", ">", "bParent", "=", "this", ";", "while", "(", "bParent", "!=", "null", ")", "{", "if", "(", "bParent", ".", "childCalculator", "!=", "null", ")", "bParent", "=", "bParent", ".", "childCalculator", ";", "else", "break", ";", "}", "(", "(", "AbstractCalculator", ")", "childCalc", ")", ".", "parentCalculator", "=", "bParent", ";", "(", "(", "AbstractCalculator", ")", "childCalc", ")", ".", "isBind", "=", "true", ";", "bParent", ".", "childCalculator", "=", "childCalc", ";", "}", "else", "{", "throw", "new", "CalculatorException", "(", "\"Use calculator which is type of AbstractCalculator\"", ",", "new", "IllegalArgumentException", "(", ")", ")", ";", "}", "return", "childCalc", ";", "}" ]
Bind another Calculator class functionalities to expression. Way to combine two different implementation of calculators @param clazz @return
[ "Bind", "another", "Calculator", "class", "functionalities", "to", "expression", "." ]
36ae1f9adfe611a6f1bd8ef87cf1dc0ec88ac035
https://github.com/d-sauer/JCalcAPI/blob/36ae1f9adfe611a6f1bd8ef87cf1dc0ec88ac035/src/main/java/org/jdice/calc/AbstractCalculator.java#L532-L560
156,391
d-sauer/JCalcAPI
src/main/java/org/jdice/calc/AbstractCalculator.java
AbstractCalculator.unbindAll
private CALC unbindAll(AbstractCalculator<CALC> undbindFrom) { // find root and first child AbstractCalculator root = undbindFrom.parentCalculator != null ? undbindFrom.parentCalculator : undbindFrom; AbstractCalculator child = root.childCalculator; while (root != null) { AbstractCalculator tmpParent = root.parentCalculator; if (tmpParent == null) break; else root = tmpParent; child = root.childCalculator; } // undbind all from root to last child while (child != null) { if (child.isUnbind == false) root.expression(child, false); child.isUnbind = true; child = child.childCalculator; // new unbind child } return (CALC) undbindFrom; }
java
private CALC unbindAll(AbstractCalculator<CALC> undbindFrom) { // find root and first child AbstractCalculator root = undbindFrom.parentCalculator != null ? undbindFrom.parentCalculator : undbindFrom; AbstractCalculator child = root.childCalculator; while (root != null) { AbstractCalculator tmpParent = root.parentCalculator; if (tmpParent == null) break; else root = tmpParent; child = root.childCalculator; } // undbind all from root to last child while (child != null) { if (child.isUnbind == false) root.expression(child, false); child.isUnbind = true; child = child.childCalculator; // new unbind child } return (CALC) undbindFrom; }
[ "private", "CALC", "unbindAll", "(", "AbstractCalculator", "<", "CALC", ">", "undbindFrom", ")", "{", "// find root and first child\r", "AbstractCalculator", "root", "=", "undbindFrom", ".", "parentCalculator", "!=", "null", "?", "undbindFrom", ".", "parentCalculator", ":", "undbindFrom", ";", "AbstractCalculator", "child", "=", "root", ".", "childCalculator", ";", "while", "(", "root", "!=", "null", ")", "{", "AbstractCalculator", "tmpParent", "=", "root", ".", "parentCalculator", ";", "if", "(", "tmpParent", "==", "null", ")", "break", ";", "else", "root", "=", "tmpParent", ";", "child", "=", "root", ".", "childCalculator", ";", "}", "// undbind all from root to last child\r", "while", "(", "child", "!=", "null", ")", "{", "if", "(", "child", ".", "isUnbind", "==", "false", ")", "root", ".", "expression", "(", "child", ",", "false", ")", ";", "child", ".", "isUnbind", "=", "true", ";", "child", "=", "child", ".", "childCalculator", ";", "// new unbind child\r", "}", "return", "(", "CALC", ")", "undbindFrom", ";", "}" ]
Unbind all binded calculators @param undbindFrom @return
[ "Unbind", "all", "binded", "calculators" ]
36ae1f9adfe611a6f1bd8ef87cf1dc0ec88ac035
https://github.com/d-sauer/JCalcAPI/blob/36ae1f9adfe611a6f1bd8ef87cf1dc0ec88ac035/src/main/java/org/jdice/calc/AbstractCalculator.java#L578-L602
156,392
d-sauer/JCalcAPI
src/main/java/org/jdice/calc/AbstractCalculator.java
AbstractCalculator.convertToPostfix
private PostfixCalculator convertToPostfix() { if (postfix == null || postfix.size() == 0 || isInfixChanged) { postfixCalculator.toPostfix(infix); postfix = postfixCalculator.getPostfix(); isInfixChanged = false; } return postfixCalculator; }
java
private PostfixCalculator convertToPostfix() { if (postfix == null || postfix.size() == 0 || isInfixChanged) { postfixCalculator.toPostfix(infix); postfix = postfixCalculator.getPostfix(); isInfixChanged = false; } return postfixCalculator; }
[ "private", "PostfixCalculator", "convertToPostfix", "(", ")", "{", "if", "(", "postfix", "==", "null", "||", "postfix", ".", "size", "(", ")", "==", "0", "||", "isInfixChanged", ")", "{", "postfixCalculator", ".", "toPostfix", "(", "infix", ")", ";", "postfix", "=", "postfixCalculator", ".", "getPostfix", "(", ")", ";", "isInfixChanged", "=", "false", ";", "}", "return", "postfixCalculator", ";", "}" ]
Convert infix to postfix Conversion is made only first time or after any change in structure of infix expression @return
[ "Convert", "infix", "to", "postfix", "Conversion", "is", "made", "only", "first", "time", "or", "after", "any", "change", "in", "structure", "of", "infix", "expression" ]
36ae1f9adfe611a6f1bd8ef87cf1dc0ec88ac035
https://github.com/d-sauer/JCalcAPI/blob/36ae1f9adfe611a6f1bd8ef87cf1dc0ec88ac035/src/main/java/org/jdice/calc/AbstractCalculator.java#L620-L628
156,393
craterdog/java-primitive-types
src/main/java/craterdog/primitives/Angle.java
Angle.sum
static public Angle sum(Angle angle1, Angle angle2) { return new Angle(angle1.value + angle2.value); }
java
static public Angle sum(Angle angle1, Angle angle2) { return new Angle(angle1.value + angle2.value); }
[ "static", "public", "Angle", "sum", "(", "Angle", "angle1", ",", "Angle", "angle2", ")", "{", "return", "new", "Angle", "(", "angle1", ".", "value", "+", "angle2", ".", "value", ")", ";", "}" ]
This function returns the normalized sum of two angles. @param angle1 The first angle. @param angle2 The second angle. @return The sum of the two angles.
[ "This", "function", "returns", "the", "normalized", "sum", "of", "two", "angles", "." ]
730f9bceacfac69f99b094464a7da5747c07a59e
https://github.com/craterdog/java-primitive-types/blob/730f9bceacfac69f99b094464a7da5747c07a59e/src/main/java/craterdog/primitives/Angle.java#L132-L134
156,394
craterdog/java-primitive-types
src/main/java/craterdog/primitives/Angle.java
Angle.difference
static public Angle difference(Angle angle1, Angle angle2) { return new Angle(angle1.value - angle2.value); }
java
static public Angle difference(Angle angle1, Angle angle2) { return new Angle(angle1.value - angle2.value); }
[ "static", "public", "Angle", "difference", "(", "Angle", "angle1", ",", "Angle", "angle2", ")", "{", "return", "new", "Angle", "(", "angle1", ".", "value", "-", "angle2", ".", "value", ")", ";", "}" ]
This function returns the normalized difference of two angles. @param angle1 The first angle. @param angle2 The second angle. @return The difference of the two angles.
[ "This", "function", "returns", "the", "normalized", "difference", "of", "two", "angles", "." ]
730f9bceacfac69f99b094464a7da5747c07a59e
https://github.com/craterdog/java-primitive-types/blob/730f9bceacfac69f99b094464a7da5747c07a59e/src/main/java/craterdog/primitives/Angle.java#L144-L146
156,395
craterdog/java-primitive-types
src/main/java/craterdog/primitives/Angle.java
Angle.sine
static public double sine(Angle angle) { double result = lock(Math.sin(angle.value)); return result; }
java
static public double sine(Angle angle) { double result = lock(Math.sin(angle.value)); return result; }
[ "static", "public", "double", "sine", "(", "Angle", "angle", ")", "{", "double", "result", "=", "lock", "(", "Math", ".", "sin", "(", "angle", ".", "value", ")", ")", ";", "return", "result", ";", "}" ]
This function returns the sine of the specified angle. @param angle The angle. @return The sine of the angle.
[ "This", "function", "returns", "the", "sine", "of", "the", "specified", "angle", "." ]
730f9bceacfac69f99b094464a7da5747c07a59e
https://github.com/craterdog/java-primitive-types/blob/730f9bceacfac69f99b094464a7da5747c07a59e/src/main/java/craterdog/primitives/Angle.java#L179-L182
156,396
craterdog/java-primitive-types
src/main/java/craterdog/primitives/Angle.java
Angle.cosine
static public double cosine(Angle angle) { double result = lock(Math.cos(angle.value)); return result; }
java
static public double cosine(Angle angle) { double result = lock(Math.cos(angle.value)); return result; }
[ "static", "public", "double", "cosine", "(", "Angle", "angle", ")", "{", "double", "result", "=", "lock", "(", "Math", ".", "cos", "(", "angle", ".", "value", ")", ")", ";", "return", "result", ";", "}" ]
This function returns the cosine of the specified angle. @param angle The angle. @return The cosine of the angle.
[ "This", "function", "returns", "the", "cosine", "of", "the", "specified", "angle", "." ]
730f9bceacfac69f99b094464a7da5747c07a59e
https://github.com/craterdog/java-primitive-types/blob/730f9bceacfac69f99b094464a7da5747c07a59e/src/main/java/craterdog/primitives/Angle.java#L202-L205
156,397
craterdog/java-primitive-types
src/main/java/craterdog/primitives/Angle.java
Angle.tangent
static public double tangent(Angle angle) { double result = lock(Math.tan(angle.value)); return result; }
java
static public double tangent(Angle angle) { double result = lock(Math.tan(angle.value)); return result; }
[ "static", "public", "double", "tangent", "(", "Angle", "angle", ")", "{", "double", "result", "=", "lock", "(", "Math", ".", "tan", "(", "angle", ".", "value", ")", ")", ";", "return", "result", ";", "}" ]
This function returns the tangent of the specified angle. @param angle The angle. @return The tangent of the angle.
[ "This", "function", "returns", "the", "tangent", "of", "the", "specified", "angle", "." ]
730f9bceacfac69f99b094464a7da5747c07a59e
https://github.com/craterdog/java-primitive-types/blob/730f9bceacfac69f99b094464a7da5747c07a59e/src/main/java/craterdog/primitives/Angle.java#L225-L228
156,398
pip-services3-java/pip-services3-components-java
src/org/pipservices3/components/connect/ConnectionResolver.java
ConnectionResolver.register
public void register(String correlationId, ConnectionParams connection) throws ApplicationException { boolean result = registerInDiscovery(correlationId, connection); if (result) _connections.add(connection); }
java
public void register(String correlationId, ConnectionParams connection) throws ApplicationException { boolean result = registerInDiscovery(correlationId, connection); if (result) _connections.add(connection); }
[ "public", "void", "register", "(", "String", "correlationId", ",", "ConnectionParams", "connection", ")", "throws", "ApplicationException", "{", "boolean", "result", "=", "registerInDiscovery", "(", "correlationId", ",", "connection", ")", ";", "if", "(", "result", ")", "_connections", ".", "add", "(", "connection", ")", ";", "}" ]
Registers the given connection in all referenced discovery services. This method can be used for dynamic service discovery. @param correlationId (optional) transaction id to trace execution through call chain. @param connection a connection to register. @throws ApplicationException when error occured. @see IDiscovery
[ "Registers", "the", "given", "connection", "in", "all", "referenced", "discovery", "services", ".", "This", "method", "can", "be", "used", "for", "dynamic", "service", "discovery", "." ]
122352fbf9b208f6417376da7b8ad725bc85ee58
https://github.com/pip-services3-java/pip-services3-components-java/blob/122352fbf9b208f6417376da7b8ad725bc85ee58/src/org/pipservices3/components/connect/ConnectionResolver.java#L167-L172
156,399
pip-services3-java/pip-services3-components-java
src/org/pipservices3/components/connect/ConnectionResolver.java
ConnectionResolver.resolve
public ConnectionParams resolve(String correlationId) throws ApplicationException { if (_connections.size() == 0) return null; // Return connection that doesn't require discovery for (ConnectionParams connection : _connections) { if (!connection.useDiscovery()) return connection; } // Return connection that require discovery for (ConnectionParams connection : _connections) { if (connection.useDiscovery()) { ConnectionParams resolvedConnection = resolveInDiscovery(correlationId, connection); if (resolvedConnection != null) { // Merge configured and new parameters resolvedConnection = new ConnectionParams( ConfigParams.mergeConfigs(connection, resolvedConnection)); return resolvedConnection; } } } return null; }
java
public ConnectionParams resolve(String correlationId) throws ApplicationException { if (_connections.size() == 0) return null; // Return connection that doesn't require discovery for (ConnectionParams connection : _connections) { if (!connection.useDiscovery()) return connection; } // Return connection that require discovery for (ConnectionParams connection : _connections) { if (connection.useDiscovery()) { ConnectionParams resolvedConnection = resolveInDiscovery(correlationId, connection); if (resolvedConnection != null) { // Merge configured and new parameters resolvedConnection = new ConnectionParams( ConfigParams.mergeConfigs(connection, resolvedConnection)); return resolvedConnection; } } } return null; }
[ "public", "ConnectionParams", "resolve", "(", "String", "correlationId", ")", "throws", "ApplicationException", "{", "if", "(", "_connections", ".", "size", "(", ")", "==", "0", ")", "return", "null", ";", "// Return connection that doesn't require discovery", "for", "(", "ConnectionParams", "connection", ":", "_connections", ")", "{", "if", "(", "!", "connection", ".", "useDiscovery", "(", ")", ")", "return", "connection", ";", "}", "// Return connection that require discovery", "for", "(", "ConnectionParams", "connection", ":", "_connections", ")", "{", "if", "(", "connection", ".", "useDiscovery", "(", ")", ")", "{", "ConnectionParams", "resolvedConnection", "=", "resolveInDiscovery", "(", "correlationId", ",", "connection", ")", ";", "if", "(", "resolvedConnection", "!=", "null", ")", "{", "// Merge configured and new parameters", "resolvedConnection", "=", "new", "ConnectionParams", "(", "ConfigParams", ".", "mergeConfigs", "(", "connection", ",", "resolvedConnection", ")", ")", ";", "return", "resolvedConnection", ";", "}", "}", "}", "return", "null", ";", "}" ]
Resolves a single component connection. If connections are configured to be retrieved from Discovery service it finds a IDiscovery and resolves the connection there. @param correlationId (optional) transaction id to trace execution through call chain. @return resolved connection parameters or null if nothing was found. @throws ApplicationException when error occured. @see IDiscovery
[ "Resolves", "a", "single", "component", "connection", ".", "If", "connections", "are", "configured", "to", "be", "retrieved", "from", "Discovery", "service", "it", "finds", "a", "IDiscovery", "and", "resolves", "the", "connection", "there", "." ]
122352fbf9b208f6417376da7b8ad725bc85ee58
https://github.com/pip-services3-java/pip-services3-components-java/blob/122352fbf9b208f6417376da7b8ad725bc85ee58/src/org/pipservices3/components/connect/ConnectionResolver.java#L211-L235