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
149,100
kevoree/kevoree-library
mqttServer/src/main/java/org/dna/mqtt/moquette/parser/netty/Utils.java
Utils.numBytesToEncode
static int numBytesToEncode(int len) { if (0 <= len && len <= 127) return 1; if (128 <= len && len <= 16383) return 2; if (16384 <= len && len <= 2097151) return 3; if (2097152 <= len && len <= 268435455) return 4; throw new IllegalArgumentException("value shoul be in the range [0..268435455]"); }
java
static int numBytesToEncode(int len) { if (0 <= len && len <= 127) return 1; if (128 <= len && len <= 16383) return 2; if (16384 <= len && len <= 2097151) return 3; if (2097152 <= len && len <= 268435455) return 4; throw new IllegalArgumentException("value shoul be in the range [0..268435455]"); }
[ "static", "int", "numBytesToEncode", "(", "int", "len", ")", "{", "if", "(", "0", "<=", "len", "&&", "len", "<=", "127", ")", "return", "1", ";", "if", "(", "128", "<=", "len", "&&", "len", "<=", "16383", ")", "return", "2", ";", "if", "(", "16384", "<=", "len", "&&", "len", "<=", "2097151", ")", "return", "3", ";", "if", "(", "2097152", "<=", "len", "&&", "len", "<=", "268435455", ")", "return", "4", ";", "throw", "new", "IllegalArgumentException", "(", "\"value shoul be in the range [0..268435455]\"", ")", ";", "}" ]
Return the number of bytes to encode the given remaining length value
[ "Return", "the", "number", "of", "bytes", "to", "encode", "the", "given", "remaining", "length", "value" ]
617460e6c5881902ebc488a31ecdea179024d8f1
https://github.com/kevoree/kevoree-library/blob/617460e6c5881902ebc488a31ecdea179024d8f1/mqttServer/src/main/java/org/dna/mqtt/moquette/parser/netty/Utils.java#L155-L161
149,101
ebean-orm/querybean-agent-now-merged-into-ebean-agent-
src/main/java/io/ebean/typequery/agent/ClassInfo.java
ClassInfo.checkTypeQueryAnnotation
public void checkTypeQueryAnnotation(String desc) { if (isEntityBeanAnnotation(desc)) { throw new NoEnhancementRequiredException("Not enhancing entity bean"); } if (isTypeQueryBeanAnnotation(desc)) { typeQueryBean = true; } else if (isAlreadyEnhancedAnnotation(desc)) { alreadyEnhanced = true; } }
java
public void checkTypeQueryAnnotation(String desc) { if (isEntityBeanAnnotation(desc)) { throw new NoEnhancementRequiredException("Not enhancing entity bean"); } if (isTypeQueryBeanAnnotation(desc)) { typeQueryBean = true; } else if (isAlreadyEnhancedAnnotation(desc)) { alreadyEnhanced = true; } }
[ "public", "void", "checkTypeQueryAnnotation", "(", "String", "desc", ")", "{", "if", "(", "isEntityBeanAnnotation", "(", "desc", ")", ")", "{", "throw", "new", "NoEnhancementRequiredException", "(", "\"Not enhancing entity bean\"", ")", ";", "}", "if", "(", "isTypeQueryBeanAnnotation", "(", "desc", ")", ")", "{", "typeQueryBean", "=", "true", ";", "}", "else", "if", "(", "isAlreadyEnhancedAnnotation", "(", "desc", ")", ")", "{", "alreadyEnhanced", "=", "true", ";", "}", "}" ]
Check for the type query bean and type query user annotations.
[ "Check", "for", "the", "type", "query", "bean", "and", "type", "query", "user", "annotations", "." ]
a063554fabdbed15ff5e10ad0a0b53b67e039006
https://github.com/ebean-orm/querybean-agent-now-merged-into-ebean-agent-/blob/a063554fabdbed15ff5e10ad0a0b53b67e039006/src/main/java/io/ebean/typequery/agent/ClassInfo.java#L89-L98
149,102
ebean-orm/querybean-agent-now-merged-into-ebean-agent-
src/main/java/io/ebean/typequery/agent/ClassInfo.java
ClassInfo.addField
public void addField(int access, String name, String desc, String signature) { if (((access & Opcodes.ACC_PUBLIC) != 0)) { if (fields == null) { fields = new ArrayList<>(); } if ((access & Opcodes.ACC_STATIC) == 0) { fields.add(new FieldInfo(this, name, desc, signature)); } } }
java
public void addField(int access, String name, String desc, String signature) { if (((access & Opcodes.ACC_PUBLIC) != 0)) { if (fields == null) { fields = new ArrayList<>(); } if ((access & Opcodes.ACC_STATIC) == 0) { fields.add(new FieldInfo(this, name, desc, signature)); } } }
[ "public", "void", "addField", "(", "int", "access", ",", "String", "name", ",", "String", "desc", ",", "String", "signature", ")", "{", "if", "(", "(", "(", "access", "&", "Opcodes", ".", "ACC_PUBLIC", ")", "!=", "0", ")", ")", "{", "if", "(", "fields", "==", "null", ")", "{", "fields", "=", "new", "ArrayList", "<>", "(", ")", ";", "}", "if", "(", "(", "access", "&", "Opcodes", ".", "ACC_STATIC", ")", "==", "0", ")", "{", "fields", ".", "add", "(", "new", "FieldInfo", "(", "this", ",", "name", ",", "desc", ",", "signature", ")", ")", ";", "}", "}", "}" ]
Add the type query bean field. We will create a 'property access' method for each field.
[ "Add", "the", "type", "query", "bean", "field", ".", "We", "will", "create", "a", "property", "access", "method", "for", "each", "field", "." ]
a063554fabdbed15ff5e10ad0a0b53b67e039006
https://github.com/ebean-orm/querybean-agent-now-merged-into-ebean-agent-/blob/a063554fabdbed15ff5e10ad0a0b53b67e039006/src/main/java/io/ebean/typequery/agent/ClassInfo.java#L103-L113
149,103
ebean-orm/querybean-agent-now-merged-into-ebean-agent-
src/main/java/io/ebean/typequery/agent/ClassInfo.java
ClassInfo.addGetFieldIntercept
public void addGetFieldIntercept(String owner, String name) { if (isLog(4)) { log("change getfield " + owner + " name:" + name); } typeQueryUser = true; }
java
public void addGetFieldIntercept(String owner, String name) { if (isLog(4)) { log("change getfield " + owner + " name:" + name); } typeQueryUser = true; }
[ "public", "void", "addGetFieldIntercept", "(", "String", "owner", ",", "String", "name", ")", "{", "if", "(", "isLog", "(", "4", ")", ")", "{", "log", "(", "\"change getfield \"", "+", "owner", "+", "\" name:\"", "+", "name", ")", ";", "}", "typeQueryUser", "=", "true", ";", "}" ]
Note that a GETFIELD call has been replaced to method call.
[ "Note", "that", "a", "GETFIELD", "call", "has", "been", "replaced", "to", "method", "call", "." ]
a063554fabdbed15ff5e10ad0a0b53b67e039006
https://github.com/ebean-orm/querybean-agent-now-merged-into-ebean-agent-/blob/a063554fabdbed15ff5e10ad0a0b53b67e039006/src/main/java/io/ebean/typequery/agent/ClassInfo.java#L146-L152
149,104
ebean-orm/querybean-agent-now-merged-into-ebean-agent-
src/main/java/io/ebean/typequery/agent/ClassInfo.java
ClassInfo.addAssocBeanExtras
public void addAssocBeanExtras(ClassVisitor cv) { if (isLog(3)) { String msg = "... add fields"; if (!hasBasicConstructor) { msg += ", basic constructor"; } if (!hasMainConstructor) { msg += ", main constructor"; } log(msg); } if (!hasBasicConstructor) { // add the assoc bean basic constructor new TypeQueryAssocBasicConstructor(this, cv, ASSOC_BEAN_BASIC_CONSTRUCTOR_DESC, ASSOC_BEAN_BASIC_SIG).visitCode(); } if (!hasMainConstructor) { // add the assoc bean main constructor new TypeQueryAssocMainConstructor(this, cv, ASSOC_BEAN_MAIN_CONSTRUCTOR_DESC, ASSOC_BEAN_MAIN_SIG).visitCode(); } }
java
public void addAssocBeanExtras(ClassVisitor cv) { if (isLog(3)) { String msg = "... add fields"; if (!hasBasicConstructor) { msg += ", basic constructor"; } if (!hasMainConstructor) { msg += ", main constructor"; } log(msg); } if (!hasBasicConstructor) { // add the assoc bean basic constructor new TypeQueryAssocBasicConstructor(this, cv, ASSOC_BEAN_BASIC_CONSTRUCTOR_DESC, ASSOC_BEAN_BASIC_SIG).visitCode(); } if (!hasMainConstructor) { // add the assoc bean main constructor new TypeQueryAssocMainConstructor(this, cv, ASSOC_BEAN_MAIN_CONSTRUCTOR_DESC, ASSOC_BEAN_MAIN_SIG).visitCode(); } }
[ "public", "void", "addAssocBeanExtras", "(", "ClassVisitor", "cv", ")", "{", "if", "(", "isLog", "(", "3", ")", ")", "{", "String", "msg", "=", "\"... add fields\"", ";", "if", "(", "!", "hasBasicConstructor", ")", "{", "msg", "+=", "\", basic constructor\"", ";", "}", "if", "(", "!", "hasMainConstructor", ")", "{", "msg", "+=", "\", main constructor\"", ";", "}", "log", "(", "msg", ")", ";", "}", "if", "(", "!", "hasBasicConstructor", ")", "{", "// add the assoc bean basic constructor", "new", "TypeQueryAssocBasicConstructor", "(", "this", ",", "cv", ",", "ASSOC_BEAN_BASIC_CONSTRUCTOR_DESC", ",", "ASSOC_BEAN_BASIC_SIG", ")", ".", "visitCode", "(", ")", ";", "}", "if", "(", "!", "hasMainConstructor", ")", "{", "// add the assoc bean main constructor", "new", "TypeQueryAssocMainConstructor", "(", "this", ",", "cv", ",", "ASSOC_BEAN_MAIN_CONSTRUCTOR_DESC", ",", "ASSOC_BEAN_MAIN_SIG", ")", ".", "visitCode", "(", ")", ";", "}", "}" ]
Add fields and constructors to assoc type query beans as necessary.
[ "Add", "fields", "and", "constructors", "to", "assoc", "type", "query", "beans", "as", "necessary", "." ]
a063554fabdbed15ff5e10ad0a0b53b67e039006
https://github.com/ebean-orm/querybean-agent-now-merged-into-ebean-agent-/blob/a063554fabdbed15ff5e10ad0a0b53b67e039006/src/main/java/io/ebean/typequery/agent/ClassInfo.java#L185-L207
149,105
dmfs/xmlobjects
src/org/dmfs/xmlobjects/serializer/XmlObjectSerializer.java
XmlObjectSerializer.useNamespace
public void useNamespace(SerializerContext serializerContext, String namespace) { if (namespace != null && namespace.length() > 0) { if (serializerContext.knownNamespaces == null) { serializerContext.knownNamespaces = new HashSet<String>(8); } serializerContext.knownNamespaces.add(namespace); } }
java
public void useNamespace(SerializerContext serializerContext, String namespace) { if (namespace != null && namespace.length() > 0) { if (serializerContext.knownNamespaces == null) { serializerContext.knownNamespaces = new HashSet<String>(8); } serializerContext.knownNamespaces.add(namespace); } }
[ "public", "void", "useNamespace", "(", "SerializerContext", "serializerContext", ",", "String", "namespace", ")", "{", "if", "(", "namespace", "!=", "null", "&&", "namespace", ".", "length", "(", ")", ">", "0", ")", "{", "if", "(", "serializerContext", ".", "knownNamespaces", "==", "null", ")", "{", "serializerContext", ".", "knownNamespaces", "=", "new", "HashSet", "<", "String", ">", "(", "8", ")", ";", "}", "serializerContext", ".", "knownNamespaces", ".", "add", "(", "namespace", ")", ";", "}", "}" ]
Inform the serializer that the given namespace will be used. This allows the serializer to bind a prefix early. @param namespace The namespace that will be used.
[ "Inform", "the", "serializer", "that", "the", "given", "namespace", "will", "be", "used", ".", "This", "allows", "the", "serializer", "to", "bind", "a", "prefix", "early", "." ]
b68ddd0ce994d804fc2ec6da1096bf0d883b37f9
https://github.com/dmfs/xmlobjects/blob/b68ddd0ce994d804fc2ec6da1096bf0d883b37f9/src/org/dmfs/xmlobjects/serializer/XmlObjectSerializer.java#L245-L255
149,106
dmfs/xmlobjects
src/org/dmfs/xmlobjects/serializer/XmlObjectSerializer.java
XmlObjectSerializer.bindNamespaces
private void bindNamespaces(SerializerContext serializerContext) throws IOException { if (serializerContext.knownNamespaces == null) { return; } StringBuilder nsBuilder = new StringBuilder(8); int count = 0; for (String ns : serializerContext.knownNamespaces) { int num = count; do { nsBuilder.append(PREFIX_CHARS[num % PREFIX_CHARS.length]); num /= PREFIX_CHARS.length; } while (num > 0); serializerContext.serializer.setPrefix(nsBuilder.toString(), ns); nsBuilder.setLength(0); ++count; } }
java
private void bindNamespaces(SerializerContext serializerContext) throws IOException { if (serializerContext.knownNamespaces == null) { return; } StringBuilder nsBuilder = new StringBuilder(8); int count = 0; for (String ns : serializerContext.knownNamespaces) { int num = count; do { nsBuilder.append(PREFIX_CHARS[num % PREFIX_CHARS.length]); num /= PREFIX_CHARS.length; } while (num > 0); serializerContext.serializer.setPrefix(nsBuilder.toString(), ns); nsBuilder.setLength(0); ++count; } }
[ "private", "void", "bindNamespaces", "(", "SerializerContext", "serializerContext", ")", "throws", "IOException", "{", "if", "(", "serializerContext", ".", "knownNamespaces", "==", "null", ")", "{", "return", ";", "}", "StringBuilder", "nsBuilder", "=", "new", "StringBuilder", "(", "8", ")", ";", "int", "count", "=", "0", ";", "for", "(", "String", "ns", ":", "serializerContext", ".", "knownNamespaces", ")", "{", "int", "num", "=", "count", ";", "do", "{", "nsBuilder", ".", "append", "(", "PREFIX_CHARS", "[", "num", "%", "PREFIX_CHARS", ".", "length", "]", ")", ";", "num", "/=", "PREFIX_CHARS", ".", "length", ";", "}", "while", "(", "num", ">", "0", ")", ";", "serializerContext", ".", "serializer", ".", "setPrefix", "(", "nsBuilder", ".", "toString", "(", ")", ",", "ns", ")", ";", "nsBuilder", ".", "setLength", "(", "0", ")", ";", "++", "count", ";", "}", "}" ]
Ensure all known namespaces have been bound to a prefix. @throws IOException
[ "Ensure", "all", "known", "namespaces", "have", "been", "bound", "to", "a", "prefix", "." ]
b68ddd0ce994d804fc2ec6da1096bf0d883b37f9
https://github.com/dmfs/xmlobjects/blob/b68ddd0ce994d804fc2ec6da1096bf0d883b37f9/src/org/dmfs/xmlobjects/serializer/XmlObjectSerializer.java#L307-L330
149,107
openbase/jul
schedule/src/main/java/org/openbase/jul/schedule/AbstractSynchronizationFuture.java
AbstractSynchronizationFuture.init
protected void init() { // create a synchronisation task which makes sure that the change requested by // the internal future has at one time been synchronized to the remote synchronisationFuture = GlobalCachedExecutorService.submit(() -> { dataProvider.addDataObserver(notifyChangeObserver); try { dataProvider.waitForData(); T result = internalFuture.get(); waitForSynchronization(result); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory("Could not sync with internal future!", ex, logger); } finally { dataProvider.removeDataObserver(notifyChangeObserver); } return null; }); }
java
protected void init() { // create a synchronisation task which makes sure that the change requested by // the internal future has at one time been synchronized to the remote synchronisationFuture = GlobalCachedExecutorService.submit(() -> { dataProvider.addDataObserver(notifyChangeObserver); try { dataProvider.waitForData(); T result = internalFuture.get(); waitForSynchronization(result); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory("Could not sync with internal future!", ex, logger); } finally { dataProvider.removeDataObserver(notifyChangeObserver); } return null; }); }
[ "protected", "void", "init", "(", ")", "{", "// create a synchronisation task which makes sure that the change requested by", "// the internal future has at one time been synchronized to the remote", "synchronisationFuture", "=", "GlobalCachedExecutorService", ".", "submit", "(", "(", ")", "->", "{", "dataProvider", ".", "addDataObserver", "(", "notifyChangeObserver", ")", ";", "try", "{", "dataProvider", ".", "waitForData", "(", ")", ";", "T", "result", "=", "internalFuture", ".", "get", "(", ")", ";", "waitForSynchronization", "(", "result", ")", ";", "}", "catch", "(", "CouldNotPerformException", "ex", ")", "{", "ExceptionPrinter", ".", "printHistory", "(", "\"Could not sync with internal future!\"", ",", "ex", ",", "logger", ")", ";", "}", "finally", "{", "dataProvider", ".", "removeDataObserver", "(", "notifyChangeObserver", ")", ";", "}", "return", "null", ";", "}", ")", ";", "}" ]
Start the internal synchronization task.
[ "Start", "the", "internal", "synchronization", "task", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/schedule/src/main/java/org/openbase/jul/schedule/AbstractSynchronizationFuture.java#L92-L108
149,108
jboss/jboss-common-beans
src/main/java/org/jboss/common/beans/property/XMLEditorSupport.java
XMLEditorSupport.getAsText
@Override public String getAsText() { if (getValue() == null) { return null; } return DOMWriter.printNode((Node) getValue(), false); }
java
@Override public String getAsText() { if (getValue() == null) { return null; } return DOMWriter.printNode((Node) getValue(), false); }
[ "@", "Override", "public", "String", "getAsText", "(", ")", "{", "if", "(", "getValue", "(", ")", "==", "null", ")", "{", "return", "null", ";", "}", "return", "DOMWriter", ".", "printNode", "(", "(", "Node", ")", "getValue", "(", ")", ",", "false", ")", ";", "}" ]
Returns the property as a String.
[ "Returns", "the", "property", "as", "a", "String", "." ]
ffb48b1719762534bf92d762eadf91d1815f6748
https://github.com/jboss/jboss-common-beans/blob/ffb48b1719762534bf92d762eadf91d1815f6748/src/main/java/org/jboss/common/beans/property/XMLEditorSupport.java#L55-L61
149,109
openbase/jul
extension/rsb/com/src/main/java/org/openbase/jul/extension/rsb/com/exception/RSBResolvedException.java
RSBResolvedException.resolveRSBException
public static Exception resolveRSBException(final RSBException rsbException) { Exception exception = null; // build stacktrace array where each line is stored as entry. entry is extract each line stacktrace into arr final String[] stacktrace = ("Caused by: " + rsbException.getMessage()).split("\n"); // iterate in reverse order to build exception chain. for (int i = stacktrace.length - 1; i >= 0; i--) { try { // only parse cause lines containing the exception class and message. if (stacktrace[i].startsWith("Caused by:")) { final String[] causes = stacktrace[i].split(":"); final String exceptionClassName = causes[1].substring(1); // System.out.println("parse: " + stacktrace[i]); // System.out.println("match: " + causes.length); final String message = causes.length <= 2 ? "" : stacktrace[i].substring(stacktrace[i].lastIndexOf(exceptionClassName) + exceptionClassName.length() + 2).trim(); // detect exception class final Class<Exception> exceptionClass; try { exceptionClass = (Class<Exception>) Class.forName(exceptionClassName); // build exception try { // try default constructor exception = exceptionClass.getConstructor(String.class, Throwable.class).newInstance(message, exception); } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | ClassCastException ex) { try { // try to handle missing fields if (exception == null && message.isEmpty()) { exception = exceptionClass.getConstructor().newInstance(); } else if (exception == null && !message.isEmpty()) { exception = exceptionClass.getConstructor(String.class).newInstance(message); } else if (exception != null && message.isEmpty()) { exception = exceptionClass.getConstructor(Throwable.class).newInstance(exception); } else { throw ex; } } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException exx) { throw new CouldNotPerformException("No compatible constructor found!", exx); } } //System.out.println("create "+ exception.getClass().getSimpleName() + ":" + exception.getMessage()); } catch (ClassNotFoundException | ClassCastException | CouldNotPerformException ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Exception[" + exceptionClassName + "] could not be recovered because no compatible Constructor(String, Throwable) was available!", ex), LOGGER, LogLevel.WARN); // apply fallback solution exception = new CouldNotPerformException(message, exception); } } } catch (IndexOutOfBoundsException | NullPointerException ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Could not extract exception cause or message out of Line[" + stacktrace[i] + "]!", ex), LOGGER, LogLevel.WARN); } } return exception; }
java
public static Exception resolveRSBException(final RSBException rsbException) { Exception exception = null; // build stacktrace array where each line is stored as entry. entry is extract each line stacktrace into arr final String[] stacktrace = ("Caused by: " + rsbException.getMessage()).split("\n"); // iterate in reverse order to build exception chain. for (int i = stacktrace.length - 1; i >= 0; i--) { try { // only parse cause lines containing the exception class and message. if (stacktrace[i].startsWith("Caused by:")) { final String[] causes = stacktrace[i].split(":"); final String exceptionClassName = causes[1].substring(1); // System.out.println("parse: " + stacktrace[i]); // System.out.println("match: " + causes.length); final String message = causes.length <= 2 ? "" : stacktrace[i].substring(stacktrace[i].lastIndexOf(exceptionClassName) + exceptionClassName.length() + 2).trim(); // detect exception class final Class<Exception> exceptionClass; try { exceptionClass = (Class<Exception>) Class.forName(exceptionClassName); // build exception try { // try default constructor exception = exceptionClass.getConstructor(String.class, Throwable.class).newInstance(message, exception); } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | ClassCastException ex) { try { // try to handle missing fields if (exception == null && message.isEmpty()) { exception = exceptionClass.getConstructor().newInstance(); } else if (exception == null && !message.isEmpty()) { exception = exceptionClass.getConstructor(String.class).newInstance(message); } else if (exception != null && message.isEmpty()) { exception = exceptionClass.getConstructor(Throwable.class).newInstance(exception); } else { throw ex; } } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException exx) { throw new CouldNotPerformException("No compatible constructor found!", exx); } } //System.out.println("create "+ exception.getClass().getSimpleName() + ":" + exception.getMessage()); } catch (ClassNotFoundException | ClassCastException | CouldNotPerformException ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Exception[" + exceptionClassName + "] could not be recovered because no compatible Constructor(String, Throwable) was available!", ex), LOGGER, LogLevel.WARN); // apply fallback solution exception = new CouldNotPerformException(message, exception); } } } catch (IndexOutOfBoundsException | NullPointerException ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Could not extract exception cause or message out of Line[" + stacktrace[i] + "]!", ex), LOGGER, LogLevel.WARN); } } return exception; }
[ "public", "static", "Exception", "resolveRSBException", "(", "final", "RSBException", "rsbException", ")", "{", "Exception", "exception", "=", "null", ";", "// build stacktrace array where each line is stored as entry. entry is extract each line stacktrace into arr", "final", "String", "[", "]", "stacktrace", "=", "(", "\"Caused by: \"", "+", "rsbException", ".", "getMessage", "(", ")", ")", ".", "split", "(", "\"\\n\"", ")", ";", "// iterate in reverse order to build exception chain.", "for", "(", "int", "i", "=", "stacktrace", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "try", "{", "// only parse cause lines containing the exception class and message.", "if", "(", "stacktrace", "[", "i", "]", ".", "startsWith", "(", "\"Caused by:\"", ")", ")", "{", "final", "String", "[", "]", "causes", "=", "stacktrace", "[", "i", "]", ".", "split", "(", "\":\"", ")", ";", "final", "String", "exceptionClassName", "=", "causes", "[", "1", "]", ".", "substring", "(", "1", ")", ";", "// System.out.println(\"parse: \" + stacktrace[i]);", "// System.out.println(\"match: \" + causes.length);", "final", "String", "message", "=", "causes", ".", "length", "<=", "2", "?", "\"\"", ":", "stacktrace", "[", "i", "]", ".", "substring", "(", "stacktrace", "[", "i", "]", ".", "lastIndexOf", "(", "exceptionClassName", ")", "+", "exceptionClassName", ".", "length", "(", ")", "+", "2", ")", ".", "trim", "(", ")", ";", "// detect exception class", "final", "Class", "<", "Exception", ">", "exceptionClass", ";", "try", "{", "exceptionClass", "=", "(", "Class", "<", "Exception", ">", ")", "Class", ".", "forName", "(", "exceptionClassName", ")", ";", "// build exception", "try", "{", "// try default constructor", "exception", "=", "exceptionClass", ".", "getConstructor", "(", "String", ".", "class", ",", "Throwable", ".", "class", ")", ".", "newInstance", "(", "message", ",", "exception", ")", ";", "}", "catch", "(", "InstantiationException", "|", "IllegalAccessException", "|", "InvocationTargetException", "|", "NoSuchMethodException", "|", "ClassCastException", "ex", ")", "{", "try", "{", "// try to handle missing fields", "if", "(", "exception", "==", "null", "&&", "message", ".", "isEmpty", "(", ")", ")", "{", "exception", "=", "exceptionClass", ".", "getConstructor", "(", ")", ".", "newInstance", "(", ")", ";", "}", "else", "if", "(", "exception", "==", "null", "&&", "!", "message", ".", "isEmpty", "(", ")", ")", "{", "exception", "=", "exceptionClass", ".", "getConstructor", "(", "String", ".", "class", ")", ".", "newInstance", "(", "message", ")", ";", "}", "else", "if", "(", "exception", "!=", "null", "&&", "message", ".", "isEmpty", "(", ")", ")", "{", "exception", "=", "exceptionClass", ".", "getConstructor", "(", "Throwable", ".", "class", ")", ".", "newInstance", "(", "exception", ")", ";", "}", "else", "{", "throw", "ex", ";", "}", "}", "catch", "(", "InstantiationException", "|", "IllegalAccessException", "|", "InvocationTargetException", "|", "NoSuchMethodException", "exx", ")", "{", "throw", "new", "CouldNotPerformException", "(", "\"No compatible constructor found!\"", ",", "exx", ")", ";", "}", "}", "//System.out.println(\"create \"+ exception.getClass().getSimpleName() + \":\" + exception.getMessage());", "}", "catch", "(", "ClassNotFoundException", "|", "ClassCastException", "|", "CouldNotPerformException", "ex", ")", "{", "ExceptionPrinter", ".", "printHistory", "(", "new", "CouldNotPerformException", "(", "\"Exception[\"", "+", "exceptionClassName", "+", "\"] could not be recovered because no compatible Constructor(String, Throwable) was available!\"", ",", "ex", ")", ",", "LOGGER", ",", "LogLevel", ".", "WARN", ")", ";", "// apply fallback solution", "exception", "=", "new", "CouldNotPerformException", "(", "message", ",", "exception", ")", ";", "}", "}", "}", "catch", "(", "IndexOutOfBoundsException", "|", "NullPointerException", "ex", ")", "{", "ExceptionPrinter", ".", "printHistory", "(", "new", "CouldNotPerformException", "(", "\"Could not extract exception cause or message out of Line[\"", "+", "stacktrace", "[", "i", "]", "+", "\"]!\"", ",", "ex", ")", ",", "LOGGER", ",", "LogLevel", ".", "WARN", ")", ";", "}", "}", "return", "exception", ";", "}" ]
Method parses the RSBException message and resolves the causes and messagen and use those to reconstruct the exception chain. @param rsbException the origin RSBException @return the reconstruced excetion cause chain.
[ "Method", "parses", "the", "RSBException", "message", "and", "resolves", "the", "causes", "and", "messagen", "and", "use", "those", "to", "reconstruct", "the", "exception", "chain", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/extension/rsb/com/src/main/java/org/openbase/jul/extension/rsb/com/exception/RSBResolvedException.java#L81-L138
149,110
ops4j/org.ops4j.pax.wicket
service/src/main/java/org/ops4j/pax/wicket/internal/servlet/ServletDescriptor.java
ServletDescriptor.unregister
public synchronized void unregister() { if (this.service != null) { LOG.info("unregister servlet on mountpoint {} with contextParams {}", getAlias(), contextParams); this.service.unregister(getAlias()); this.service = null; } }
java
public synchronized void unregister() { if (this.service != null) { LOG.info("unregister servlet on mountpoint {} with contextParams {}", getAlias(), contextParams); this.service.unregister(getAlias()); this.service = null; } }
[ "public", "synchronized", "void", "unregister", "(", ")", "{", "if", "(", "this", ".", "service", "!=", "null", ")", "{", "LOG", ".", "info", "(", "\"unregister servlet on mountpoint {} with contextParams {}\"", ",", "getAlias", "(", ")", ",", "contextParams", ")", ";", "this", ".", "service", ".", "unregister", "(", "getAlias", "(", ")", ")", ";", "this", ".", "service", "=", "null", ";", "}", "}" ]
Unregister a servlet if already registered. After this call it is save to register the servlet again
[ "Unregister", "a", "servlet", "if", "already", "registered", ".", "After", "this", "call", "it", "is", "save", "to", "register", "the", "servlet", "again" ]
ef7cb4bdf918e9e61ec69789b9c690567616faa9
https://github.com/ops4j/org.ops4j.pax.wicket/blob/ef7cb4bdf918e9e61ec69789b9c690567616faa9/service/src/main/java/org/ops4j/pax/wicket/internal/servlet/ServletDescriptor.java#L350-L357
149,111
ops4j/org.ops4j.pax.wicket
service/src/main/java/org/ops4j/pax/wicket/internal/HttpTracker.java
HttpTracker.unregisterServletDescriptor
private void unregisterServletDescriptor(ServletDescriptor servletDescriptor) { try { servletDescriptor.unregister(); } catch (RuntimeException e) { LOG.error( "Unregistration of ServletDescriptor under mountpoint {} fails with unexpected RuntimeException!", servletDescriptor.getAlias(), e); } }
java
private void unregisterServletDescriptor(ServletDescriptor servletDescriptor) { try { servletDescriptor.unregister(); } catch (RuntimeException e) { LOG.error( "Unregistration of ServletDescriptor under mountpoint {} fails with unexpected RuntimeException!", servletDescriptor.getAlias(), e); } }
[ "private", "void", "unregisterServletDescriptor", "(", "ServletDescriptor", "servletDescriptor", ")", "{", "try", "{", "servletDescriptor", ".", "unregister", "(", ")", ";", "}", "catch", "(", "RuntimeException", "e", ")", "{", "LOG", ".", "error", "(", "\"Unregistration of ServletDescriptor under mountpoint {} fails with unexpected RuntimeException!\"", ",", "servletDescriptor", ".", "getAlias", "(", ")", ",", "e", ")", ";", "}", "}" ]
Unregister a servlet descriptor handling runtime exceptions
[ "Unregister", "a", "servlet", "descriptor", "handling", "runtime", "exceptions" ]
ef7cb4bdf918e9e61ec69789b9c690567616faa9
https://github.com/ops4j/org.ops4j.pax.wicket/blob/ef7cb4bdf918e9e61ec69789b9c690567616faa9/service/src/main/java/org/ops4j/pax/wicket/internal/HttpTracker.java#L81-L89
149,112
kevoree/kevoree-library
mqttServer/src/main/java/org/dna/mqtt/moquette/proto/Utils.java
Utils.msgType2String
public static String msgType2String(int type) { switch (type) { case AbstractMessage.CONNECT: return "CONNECT"; case AbstractMessage.CONNACK: return "CONNACK"; case AbstractMessage.PUBLISH: return "PUBLISH"; case AbstractMessage.PUBACK: return "PUBACK"; case AbstractMessage.PUBREC: return "PUBREC"; case AbstractMessage.PUBREL: return "PUBREL"; case AbstractMessage.PUBCOMP: return "PUBCOMP"; case AbstractMessage.SUBSCRIBE: return "SUBSCRIBE"; case AbstractMessage.SUBACK: return "SUBACK"; case AbstractMessage.UNSUBSCRIBE: return "UNSUBSCRIBE"; case AbstractMessage.UNSUBACK: return "UNSUBACK"; case AbstractMessage.PINGREQ: return "PINGREQ"; case AbstractMessage.PINGRESP: return "PINGRESP"; case AbstractMessage.DISCONNECT: return "DISCONNECT"; default: throw new RuntimeException("Can't decode message type " + type); } }
java
public static String msgType2String(int type) { switch (type) { case AbstractMessage.CONNECT: return "CONNECT"; case AbstractMessage.CONNACK: return "CONNACK"; case AbstractMessage.PUBLISH: return "PUBLISH"; case AbstractMessage.PUBACK: return "PUBACK"; case AbstractMessage.PUBREC: return "PUBREC"; case AbstractMessage.PUBREL: return "PUBREL"; case AbstractMessage.PUBCOMP: return "PUBCOMP"; case AbstractMessage.SUBSCRIBE: return "SUBSCRIBE"; case AbstractMessage.SUBACK: return "SUBACK"; case AbstractMessage.UNSUBSCRIBE: return "UNSUBSCRIBE"; case AbstractMessage.UNSUBACK: return "UNSUBACK"; case AbstractMessage.PINGREQ: return "PINGREQ"; case AbstractMessage.PINGRESP: return "PINGRESP"; case AbstractMessage.DISCONNECT: return "DISCONNECT"; default: throw new RuntimeException("Can't decode message type " + type); } }
[ "public", "static", "String", "msgType2String", "(", "int", "type", ")", "{", "switch", "(", "type", ")", "{", "case", "AbstractMessage", ".", "CONNECT", ":", "return", "\"CONNECT\"", ";", "case", "AbstractMessage", ".", "CONNACK", ":", "return", "\"CONNACK\"", ";", "case", "AbstractMessage", ".", "PUBLISH", ":", "return", "\"PUBLISH\"", ";", "case", "AbstractMessage", ".", "PUBACK", ":", "return", "\"PUBACK\"", ";", "case", "AbstractMessage", ".", "PUBREC", ":", "return", "\"PUBREC\"", ";", "case", "AbstractMessage", ".", "PUBREL", ":", "return", "\"PUBREL\"", ";", "case", "AbstractMessage", ".", "PUBCOMP", ":", "return", "\"PUBCOMP\"", ";", "case", "AbstractMessage", ".", "SUBSCRIBE", ":", "return", "\"SUBSCRIBE\"", ";", "case", "AbstractMessage", ".", "SUBACK", ":", "return", "\"SUBACK\"", ";", "case", "AbstractMessage", ".", "UNSUBSCRIBE", ":", "return", "\"UNSUBSCRIBE\"", ";", "case", "AbstractMessage", ".", "UNSUBACK", ":", "return", "\"UNSUBACK\"", ";", "case", "AbstractMessage", ".", "PINGREQ", ":", "return", "\"PINGREQ\"", ";", "case", "AbstractMessage", ".", "PINGRESP", ":", "return", "\"PINGRESP\"", ";", "case", "AbstractMessage", ".", "DISCONNECT", ":", "return", "\"DISCONNECT\"", ";", "default", ":", "throw", "new", "RuntimeException", "(", "\"Can't decode message type \"", "+", "type", ")", ";", "}", "}" ]
Converts MQTT message type to a textual description.
[ "Converts", "MQTT", "message", "type", "to", "a", "textual", "description", "." ]
617460e6c5881902ebc488a31ecdea179024d8f1
https://github.com/kevoree/kevoree-library/blob/617460e6c5881902ebc488a31ecdea179024d8f1/mqttServer/src/main/java/org/dna/mqtt/moquette/proto/Utils.java#L183-L201
149,113
googolmo/OkVolley
okvolley/src/main/java/im/amomo/volley/OkRequest.java
OkRequest.partHeader
public OkRequest<T> partHeader(final String name, final String value) throws IOException { return send(name).send(": ").send(value).send(CRLF); }
java
public OkRequest<T> partHeader(final String name, final String value) throws IOException { return send(name).send(": ").send(value).send(CRLF); }
[ "public", "OkRequest", "<", "T", ">", "partHeader", "(", "final", "String", "name", ",", "final", "String", "value", ")", "throws", "IOException", "{", "return", "send", "(", "name", ")", ".", "send", "(", "\": \"", ")", ".", "send", "(", "value", ")", ".", "send", "(", "CRLF", ")", ";", "}" ]
Write a multipart header to the response body @param name @param value @return this request
[ "Write", "a", "multipart", "header", "to", "the", "response", "body" ]
5c41df7cf1a8156c85e179a3c4af8a1c1485ffec
https://github.com/googolmo/OkVolley/blob/5c41df7cf1a8156c85e179a3c4af8a1c1485ffec/okvolley/src/main/java/im/amomo/volley/OkRequest.java#L389-L391
149,114
googolmo/OkVolley
okvolley/src/main/java/im/amomo/volley/OkRequest.java
OkRequest.send
public OkRequest<T> send(final File input) throws IOException { final InputStream stream; stream = new BufferedInputStream(new FileInputStream(input)); return send(stream); }
java
public OkRequest<T> send(final File input) throws IOException { final InputStream stream; stream = new BufferedInputStream(new FileInputStream(input)); return send(stream); }
[ "public", "OkRequest", "<", "T", ">", "send", "(", "final", "File", "input", ")", "throws", "IOException", "{", "final", "InputStream", "stream", ";", "stream", "=", "new", "BufferedInputStream", "(", "new", "FileInputStream", "(", "input", ")", ")", ";", "return", "send", "(", "stream", ")", ";", "}" ]
Write contents of file to request body @param input @return this request
[ "Write", "contents", "of", "file", "to", "request", "body" ]
5c41df7cf1a8156c85e179a3c4af8a1c1485ffec
https://github.com/googolmo/OkVolley/blob/5c41df7cf1a8156c85e179a3c4af8a1c1485ffec/okvolley/src/main/java/im/amomo/volley/OkRequest.java#L399-L404
149,115
googolmo/OkVolley
okvolley/src/main/java/im/amomo/volley/OkRequest.java
OkRequest.form
public OkRequest<T> form(final Map<String, String> values, final String charset) { if (!values.isEmpty()) { for (Map.Entry<String, String> entry : values.entrySet()) { form(entry, charset); } } return this; }
java
public OkRequest<T> form(final Map<String, String> values, final String charset) { if (!values.isEmpty()) { for (Map.Entry<String, String> entry : values.entrySet()) { form(entry, charset); } } return this; }
[ "public", "OkRequest", "<", "T", ">", "form", "(", "final", "Map", "<", "String", ",", "String", ">", "values", ",", "final", "String", "charset", ")", "{", "if", "(", "!", "values", ".", "isEmpty", "(", ")", ")", "{", "for", "(", "Map", ".", "Entry", "<", "String", ",", "String", ">", "entry", ":", "values", ".", "entrySet", "(", ")", ")", "{", "form", "(", "entry", ",", "charset", ")", ";", "}", "}", "return", "this", ";", "}" ]
Write the values in the map as encoded form data to the request body @param values @param charset @return this request
[ "Write", "the", "values", "in", "the", "map", "as", "encoded", "form", "data", "to", "the", "request", "body" ]
5c41df7cf1a8156c85e179a3c4af8a1c1485ffec
https://github.com/googolmo/OkVolley/blob/5c41df7cf1a8156c85e179a3c4af8a1c1485ffec/okvolley/src/main/java/im/amomo/volley/OkRequest.java#L556-L563
149,116
googolmo/OkVolley
okvolley/src/main/java/im/amomo/volley/OkRequest.java
OkRequest.param
public OkRequest<T> param(final String key, final String value) { StringBuilder urlBuilder = new StringBuilder(getUrl()); if (getUrl().contains("?")) { urlBuilder.append("&"); } else { urlBuilder.append("?"); } urlBuilder.append(key); urlBuilder.append("="); urlBuilder.append(value); mRequestUrl = urlBuilder.toString(); return this; }
java
public OkRequest<T> param(final String key, final String value) { StringBuilder urlBuilder = new StringBuilder(getUrl()); if (getUrl().contains("?")) { urlBuilder.append("&"); } else { urlBuilder.append("?"); } urlBuilder.append(key); urlBuilder.append("="); urlBuilder.append(value); mRequestUrl = urlBuilder.toString(); return this; }
[ "public", "OkRequest", "<", "T", ">", "param", "(", "final", "String", "key", ",", "final", "String", "value", ")", "{", "StringBuilder", "urlBuilder", "=", "new", "StringBuilder", "(", "getUrl", "(", ")", ")", ";", "if", "(", "getUrl", "(", ")", ".", "contains", "(", "\"?\"", ")", ")", "{", "urlBuilder", ".", "append", "(", "\"&\"", ")", ";", "}", "else", "{", "urlBuilder", ".", "append", "(", "\"?\"", ")", ";", "}", "urlBuilder", ".", "append", "(", "key", ")", ";", "urlBuilder", ".", "append", "(", "\"=\"", ")", ";", "urlBuilder", ".", "append", "(", "value", ")", ";", "mRequestUrl", "=", "urlBuilder", ".", "toString", "(", ")", ";", "return", "this", ";", "}" ]
Write the value to url params @param key key @param value value @return this request
[ "Write", "the", "value", "to", "url", "params" ]
5c41df7cf1a8156c85e179a3c4af8a1c1485ffec
https://github.com/googolmo/OkVolley/blob/5c41df7cf1a8156c85e179a3c4af8a1c1485ffec/okvolley/src/main/java/im/amomo/volley/OkRequest.java#L572-L584
149,117
googolmo/OkVolley
okvolley/src/main/java/im/amomo/volley/OkRequest.java
OkRequest.param
public OkRequest<T> param(final Map.Entry<String, String> entry) { return param(entry.getKey(), entry.getValue()); }
java
public OkRequest<T> param(final Map.Entry<String, String> entry) { return param(entry.getKey(), entry.getValue()); }
[ "public", "OkRequest", "<", "T", ">", "param", "(", "final", "Map", ".", "Entry", "<", "String", ",", "String", ">", "entry", ")", "{", "return", "param", "(", "entry", ".", "getKey", "(", ")", ",", "entry", ".", "getValue", "(", ")", ")", ";", "}" ]
Write the map entry to url params @param entry map entry @return this request
[ "Write", "the", "map", "entry", "to", "url", "params" ]
5c41df7cf1a8156c85e179a3c4af8a1c1485ffec
https://github.com/googolmo/OkVolley/blob/5c41df7cf1a8156c85e179a3c4af8a1c1485ffec/okvolley/src/main/java/im/amomo/volley/OkRequest.java#L592-L594
149,118
googolmo/OkVolley
okvolley/src/main/java/im/amomo/volley/OkRequest.java
OkRequest.params
public OkRequest<T> params(final Map<String, String> values) { if (!values.isEmpty()) { for (Map.Entry<String, String> entry : values.entrySet()) { param(entry); } } return this; }
java
public OkRequest<T> params(final Map<String, String> values) { if (!values.isEmpty()) { for (Map.Entry<String, String> entry : values.entrySet()) { param(entry); } } return this; }
[ "public", "OkRequest", "<", "T", ">", "params", "(", "final", "Map", "<", "String", ",", "String", ">", "values", ")", "{", "if", "(", "!", "values", ".", "isEmpty", "(", ")", ")", "{", "for", "(", "Map", ".", "Entry", "<", "String", ",", "String", ">", "entry", ":", "values", ".", "entrySet", "(", ")", ")", "{", "param", "(", "entry", ")", ";", "}", "}", "return", "this", ";", "}" ]
Write the map to url params @param values map @return this request
[ "Write", "the", "map", "to", "url", "params" ]
5c41df7cf1a8156c85e179a3c4af8a1c1485ffec
https://github.com/googolmo/OkVolley/blob/5c41df7cf1a8156c85e179a3c4af8a1c1485ffec/okvolley/src/main/java/im/amomo/volley/OkRequest.java#L602-L609
149,119
googolmo/OkVolley
okvolley/src/main/java/im/amomo/volley/OkRequest.java
OkRequest.headers
public OkRequest<T> headers(final Map<String, String> headers) { if (!headers.isEmpty()) for (Map.Entry<String, String> header : headers.entrySet()) header(header); return this; }
java
public OkRequest<T> headers(final Map<String, String> headers) { if (!headers.isEmpty()) for (Map.Entry<String, String> header : headers.entrySet()) header(header); return this; }
[ "public", "OkRequest", "<", "T", ">", "headers", "(", "final", "Map", "<", "String", ",", "String", ">", "headers", ")", "{", "if", "(", "!", "headers", ".", "isEmpty", "(", ")", ")", "for", "(", "Map", ".", "Entry", "<", "String", ",", "String", ">", "header", ":", "headers", ".", "entrySet", "(", ")", ")", "header", "(", "header", ")", ";", "return", "this", ";", "}" ]
Set all headers found in given map where the keys are the header names and the values are the header values @param headers @return this request
[ "Set", "all", "headers", "found", "in", "given", "map", "where", "the", "keys", "are", "the", "header", "names", "and", "the", "values", "are", "the", "header", "values" ]
5c41df7cf1a8156c85e179a3c4af8a1c1485ffec
https://github.com/googolmo/OkVolley/blob/5c41df7cf1a8156c85e179a3c4af8a1c1485ffec/okvolley/src/main/java/im/amomo/volley/OkRequest.java#L641-L646
149,120
googolmo/OkVolley
okvolley/src/main/java/im/amomo/volley/OkRequest.java
OkRequest.header
public OkRequest<T> header(final Map.Entry<String, String> header) { return header(header.getKey(), header.getValue()); }
java
public OkRequest<T> header(final Map.Entry<String, String> header) { return header(header.getKey(), header.getValue()); }
[ "public", "OkRequest", "<", "T", ">", "header", "(", "final", "Map", ".", "Entry", "<", "String", ",", "String", ">", "header", ")", "{", "return", "header", "(", "header", ".", "getKey", "(", ")", ",", "header", ".", "getValue", "(", ")", ")", ";", "}" ]
Set header to have given entry's key as the name and value as the value @param header @return this request
[ "Set", "header", "to", "have", "given", "entry", "s", "key", "as", "the", "name", "and", "value", "as", "the", "value" ]
5c41df7cf1a8156c85e179a3c4af8a1c1485ffec
https://github.com/googolmo/OkVolley/blob/5c41df7cf1a8156c85e179a3c4af8a1c1485ffec/okvolley/src/main/java/im/amomo/volley/OkRequest.java#L654-L656
149,121
googolmo/OkVolley
okvolley/src/main/java/im/amomo/volley/OkRequest.java
OkRequest.getHeaders
@Override public Map<String, String> getHeaders() throws AuthFailureError { Map<String, String> headers = super.getHeaders(); if (!mRequestHeaders.isEmpty()) { if (headers.isEmpty()) { return mRequestHeaders; } else { headers.putAll(mRequestHeaders); } } return headers; }
java
@Override public Map<String, String> getHeaders() throws AuthFailureError { Map<String, String> headers = super.getHeaders(); if (!mRequestHeaders.isEmpty()) { if (headers.isEmpty()) { return mRequestHeaders; } else { headers.putAll(mRequestHeaders); } } return headers; }
[ "@", "Override", "public", "Map", "<", "String", ",", "String", ">", "getHeaders", "(", ")", "throws", "AuthFailureError", "{", "Map", "<", "String", ",", "String", ">", "headers", "=", "super", ".", "getHeaders", "(", ")", ";", "if", "(", "!", "mRequestHeaders", ".", "isEmpty", "(", ")", ")", "{", "if", "(", "headers", ".", "isEmpty", "(", ")", ")", "{", "return", "mRequestHeaders", ";", "}", "else", "{", "headers", ".", "putAll", "(", "mRequestHeaders", ")", ";", "}", "}", "return", "headers", ";", "}" ]
get request header
[ "get", "request", "header" ]
5c41df7cf1a8156c85e179a3c4af8a1c1485ffec
https://github.com/googolmo/OkVolley/blob/5c41df7cf1a8156c85e179a3c4af8a1c1485ffec/okvolley/src/main/java/im/amomo/volley/OkRequest.java#L780-L791
149,122
googolmo/OkVolley
okvolley/src/main/java/im/amomo/volley/OkRequest.java
OkRequest.getBody
@Override public byte[] getBody() throws AuthFailureError { if (mOutput == null) { openOutput(); } try { if (mMultipart) { mOutput.write(CRLF + "--" + BOUNDARY + "--" + CRLF); } return mOutput.toByteArray(); } catch (IOException e) { e.printStackTrace(); return mOutput.toByteArray(); } finally { try { mOutput.close(); } catch (IOException e) { e.printStackTrace(); } mOutput = null; } }
java
@Override public byte[] getBody() throws AuthFailureError { if (mOutput == null) { openOutput(); } try { if (mMultipart) { mOutput.write(CRLF + "--" + BOUNDARY + "--" + CRLF); } return mOutput.toByteArray(); } catch (IOException e) { e.printStackTrace(); return mOutput.toByteArray(); } finally { try { mOutput.close(); } catch (IOException e) { e.printStackTrace(); } mOutput = null; } }
[ "@", "Override", "public", "byte", "[", "]", "getBody", "(", ")", "throws", "AuthFailureError", "{", "if", "(", "mOutput", "==", "null", ")", "{", "openOutput", "(", ")", ";", "}", "try", "{", "if", "(", "mMultipart", ")", "{", "mOutput", ".", "write", "(", "CRLF", "+", "\"--\"", "+", "BOUNDARY", "+", "\"--\"", "+", "CRLF", ")", ";", "}", "return", "mOutput", ".", "toByteArray", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "return", "mOutput", ".", "toByteArray", "(", ")", ";", "}", "finally", "{", "try", "{", "mOutput", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "mOutput", "=", "null", ";", "}", "}" ]
get request body
[ "get", "request", "body" ]
5c41df7cf1a8156c85e179a3c4af8a1c1485ffec
https://github.com/googolmo/OkVolley/blob/5c41df7cf1a8156c85e179a3c4af8a1c1485ffec/okvolley/src/main/java/im/amomo/volley/OkRequest.java#L841-L864
149,123
socialsensor/socialsensor-framework-client
src/main/java/eu/socialsensor/framework/client/search/visual/VisualIndexHandler.java
VisualIndexHandler.getSimilarImages
public JsonResultSet getSimilarImages(String imageId, double threshold) { JsonResultSet similar = new JsonResultSet(); PostMethod queryMethod = null; String response = null; try { Part[] parts = { new StringPart("id", imageId), new StringPart("threshold", String.valueOf(threshold)) }; queryMethod = new PostMethod(webServiceHost + "/rest/visual/query_id/" + collectionName); queryMethod.setRequestEntity(new MultipartRequestEntity(parts, queryMethod.getParams())); int code = httpClient.executeMethod(queryMethod); if (code == 200) { InputStream inputStream = queryMethod.getResponseBodyAsStream(); StringWriter writer = new StringWriter(); IOUtils.copy(inputStream, writer); response = writer.toString(); queryMethod.releaseConnection(); similar = parseResponse(response); } else { _logger.error("Http returned code: " + code); } } catch (Exception e) { _logger.error("Exception for ID: " + imageId, e); response = null; } finally { if (queryMethod != null) { queryMethod.releaseConnection(); } } return similar; }
java
public JsonResultSet getSimilarImages(String imageId, double threshold) { JsonResultSet similar = new JsonResultSet(); PostMethod queryMethod = null; String response = null; try { Part[] parts = { new StringPart("id", imageId), new StringPart("threshold", String.valueOf(threshold)) }; queryMethod = new PostMethod(webServiceHost + "/rest/visual/query_id/" + collectionName); queryMethod.setRequestEntity(new MultipartRequestEntity(parts, queryMethod.getParams())); int code = httpClient.executeMethod(queryMethod); if (code == 200) { InputStream inputStream = queryMethod.getResponseBodyAsStream(); StringWriter writer = new StringWriter(); IOUtils.copy(inputStream, writer); response = writer.toString(); queryMethod.releaseConnection(); similar = parseResponse(response); } else { _logger.error("Http returned code: " + code); } } catch (Exception e) { _logger.error("Exception for ID: " + imageId, e); response = null; } finally { if (queryMethod != null) { queryMethod.releaseConnection(); } } return similar; }
[ "public", "JsonResultSet", "getSimilarImages", "(", "String", "imageId", ",", "double", "threshold", ")", "{", "JsonResultSet", "similar", "=", "new", "JsonResultSet", "(", ")", ";", "PostMethod", "queryMethod", "=", "null", ";", "String", "response", "=", "null", ";", "try", "{", "Part", "[", "]", "parts", "=", "{", "new", "StringPart", "(", "\"id\"", ",", "imageId", ")", ",", "new", "StringPart", "(", "\"threshold\"", ",", "String", ".", "valueOf", "(", "threshold", ")", ")", "}", ";", "queryMethod", "=", "new", "PostMethod", "(", "webServiceHost", "+", "\"/rest/visual/query_id/\"", "+", "collectionName", ")", ";", "queryMethod", ".", "setRequestEntity", "(", "new", "MultipartRequestEntity", "(", "parts", ",", "queryMethod", ".", "getParams", "(", ")", ")", ")", ";", "int", "code", "=", "httpClient", ".", "executeMethod", "(", "queryMethod", ")", ";", "if", "(", "code", "==", "200", ")", "{", "InputStream", "inputStream", "=", "queryMethod", ".", "getResponseBodyAsStream", "(", ")", ";", "StringWriter", "writer", "=", "new", "StringWriter", "(", ")", ";", "IOUtils", ".", "copy", "(", "inputStream", ",", "writer", ")", ";", "response", "=", "writer", ".", "toString", "(", ")", ";", "queryMethod", ".", "releaseConnection", "(", ")", ";", "similar", "=", "parseResponse", "(", "response", ")", ";", "}", "else", "{", "_logger", ".", "error", "(", "\"Http returned code: \"", "+", "code", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "_logger", ".", "error", "(", "\"Exception for ID: \"", "+", "imageId", ",", "e", ")", ";", "response", "=", "null", ";", "}", "finally", "{", "if", "(", "queryMethod", "!=", "null", ")", "{", "queryMethod", ".", "releaseConnection", "(", ")", ";", "}", "}", "return", "similar", ";", "}" ]
Get similar images for a specific media item @param imageId @param threshold @return
[ "Get", "similar", "images", "for", "a", "specific", "media", "item" ]
67cd45c5d8e096d5f76ace49f453ff6438920473
https://github.com/socialsensor/socialsensor-framework-client/blob/67cd45c5d8e096d5f76ace49f453ff6438920473/src/main/java/eu/socialsensor/framework/client/search/visual/VisualIndexHandler.java#L74-L111
149,124
socialsensor/socialsensor-framework-client
src/main/java/eu/socialsensor/framework/client/search/visual/VisualIndexHandler.java
VisualIndexHandler.getSimilarImagesAndIndex
public JsonResultSet getSimilarImagesAndIndex(String id, double[] vector, double threshold) { JsonResultSet similar = new JsonResultSet(); byte[] vectorInBytes = new byte[8 * vector.length]; ByteBuffer bbuf = ByteBuffer.wrap(vectorInBytes); for (double value : vector) { bbuf.putDouble(value); } PostMethod queryMethod = null; String response = null; try { ByteArrayPartSource source = new ByteArrayPartSource("bytes", vectorInBytes); Part[] parts = { new StringPart("id", id), new FilePart("vector", source), new StringPart("threshold", String.valueOf(threshold)) }; queryMethod = new PostMethod(webServiceHost + "/rest/visual/qindex/" + collectionName); queryMethod.setRequestEntity(new MultipartRequestEntity(parts, queryMethod.getParams())); int code = httpClient.executeMethod(queryMethod); if (code == 200) { InputStream inputStream = queryMethod.getResponseBodyAsStream(); StringWriter writer = new StringWriter(); IOUtils.copy(inputStream, writer); response = writer.toString(); queryMethod.releaseConnection(); similar = parseResponse(response); } } catch (Exception e) { _logger.error("Exception for vector of length " + vector.length, e); response = null; } finally { if (queryMethod != null) { queryMethod.releaseConnection(); } } return similar; }
java
public JsonResultSet getSimilarImagesAndIndex(String id, double[] vector, double threshold) { JsonResultSet similar = new JsonResultSet(); byte[] vectorInBytes = new byte[8 * vector.length]; ByteBuffer bbuf = ByteBuffer.wrap(vectorInBytes); for (double value : vector) { bbuf.putDouble(value); } PostMethod queryMethod = null; String response = null; try { ByteArrayPartSource source = new ByteArrayPartSource("bytes", vectorInBytes); Part[] parts = { new StringPart("id", id), new FilePart("vector", source), new StringPart("threshold", String.valueOf(threshold)) }; queryMethod = new PostMethod(webServiceHost + "/rest/visual/qindex/" + collectionName); queryMethod.setRequestEntity(new MultipartRequestEntity(parts, queryMethod.getParams())); int code = httpClient.executeMethod(queryMethod); if (code == 200) { InputStream inputStream = queryMethod.getResponseBodyAsStream(); StringWriter writer = new StringWriter(); IOUtils.copy(inputStream, writer); response = writer.toString(); queryMethod.releaseConnection(); similar = parseResponse(response); } } catch (Exception e) { _logger.error("Exception for vector of length " + vector.length, e); response = null; } finally { if (queryMethod != null) { queryMethod.releaseConnection(); } } return similar; }
[ "public", "JsonResultSet", "getSimilarImagesAndIndex", "(", "String", "id", ",", "double", "[", "]", "vector", ",", "double", "threshold", ")", "{", "JsonResultSet", "similar", "=", "new", "JsonResultSet", "(", ")", ";", "byte", "[", "]", "vectorInBytes", "=", "new", "byte", "[", "8", "*", "vector", ".", "length", "]", ";", "ByteBuffer", "bbuf", "=", "ByteBuffer", ".", "wrap", "(", "vectorInBytes", ")", ";", "for", "(", "double", "value", ":", "vector", ")", "{", "bbuf", ".", "putDouble", "(", "value", ")", ";", "}", "PostMethod", "queryMethod", "=", "null", ";", "String", "response", "=", "null", ";", "try", "{", "ByteArrayPartSource", "source", "=", "new", "ByteArrayPartSource", "(", "\"bytes\"", ",", "vectorInBytes", ")", ";", "Part", "[", "]", "parts", "=", "{", "new", "StringPart", "(", "\"id\"", ",", "id", ")", ",", "new", "FilePart", "(", "\"vector\"", ",", "source", ")", ",", "new", "StringPart", "(", "\"threshold\"", ",", "String", ".", "valueOf", "(", "threshold", ")", ")", "}", ";", "queryMethod", "=", "new", "PostMethod", "(", "webServiceHost", "+", "\"/rest/visual/qindex/\"", "+", "collectionName", ")", ";", "queryMethod", ".", "setRequestEntity", "(", "new", "MultipartRequestEntity", "(", "parts", ",", "queryMethod", ".", "getParams", "(", ")", ")", ")", ";", "int", "code", "=", "httpClient", ".", "executeMethod", "(", "queryMethod", ")", ";", "if", "(", "code", "==", "200", ")", "{", "InputStream", "inputStream", "=", "queryMethod", ".", "getResponseBodyAsStream", "(", ")", ";", "StringWriter", "writer", "=", "new", "StringWriter", "(", ")", ";", "IOUtils", ".", "copy", "(", "inputStream", ",", "writer", ")", ";", "response", "=", "writer", ".", "toString", "(", ")", ";", "queryMethod", ".", "releaseConnection", "(", ")", ";", "similar", "=", "parseResponse", "(", "response", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "_logger", ".", "error", "(", "\"Exception for vector of length \"", "+", "vector", ".", "length", ",", "e", ")", ";", "response", "=", "null", ";", "}", "finally", "{", "if", "(", "queryMethod", "!=", "null", ")", "{", "queryMethod", ".", "releaseConnection", "(", ")", ";", "}", "}", "return", "similar", ";", "}" ]
Get similar images by vector @param vector @param threshold @return
[ "Get", "similar", "images", "by", "vector" ]
67cd45c5d8e096d5f76ace49f453ff6438920473
https://github.com/socialsensor/socialsensor-framework-client/blob/67cd45c5d8e096d5f76ace49f453ff6438920473/src/main/java/eu/socialsensor/framework/client/search/visual/VisualIndexHandler.java#L267-L308
149,125
foundation-runtime/configuration
configuration-lib/src/main/java/com/cisco/oss/foundation/configuration/ConfigResourcesLoader.java
ConfigResourcesLoader.afterPropertiesSet
@Override public void afterPropertiesSet() throws Exception { // NOPMD final boolean isQCEnabld = isQCEnabled(); // iterator over the list of possible external resources // only one of the resources should exist // this is to support special locations on special modules such as: Web // etc. Resource customerPropertyResource = null; // Resource customerXmlResource = null; Resource deploymentResource = null; Resource qcResource = null; if (isQCEnabld) { LOGGER.info("Found the ConfigurationTest class indicating that QC config is to be used instead of deployment and customer config files!"); qcResource = validateQCResource(); } else { customerPropertyResource = validateCustomerPropertyConfig(); deploymentResource = validateDeploymentConfig(); if (!printedToLog) { StringBuffer logMessageBuffer = new StringBuffer("The customer resources loaded are:"); printResourcesLoaded(logMessageBuffer, customerPropertyResource); if(applicationState != null){ applicationState.setState(FoundationLevel.INFO, logMessageBuffer.toString()); } if (deploymentResource != null) { logMessageBuffer = new StringBuffer("The deployment resources loaded are:"); printResourcesLoaded(logMessageBuffer, deploymentResource); if(applicationState != null) { applicationState.setState(FoundationLevel.INFO, logMessageBuffer.toString()); } } } } // get all the resources of the internal property config files. final Resource[] internalPropertyResources = context.getResources(internalPropertyConfig); final List<Resource> internalPropertyResourcesList = Arrays.asList(internalPropertyResources); // get all the resources of the internal xml config files. // xml resources take precedence over the properties loaded. final Resource[] internalXmlResources = context.getResources(internalXmlConfig); final List<Resource> internalXmlResourcesList = Arrays.asList(internalXmlResources); if (!printedToLog) { final StringBuffer logMessageBuffer = new StringBuffer("The default resources loaded are:"); printResourcesLoaded(logMessageBuffer, internalXmlResourcesList); printResourcesLoaded(logMessageBuffer, internalPropertyResourcesList); if(applicationState != null) { applicationState.setState(FoundationLevel.INFO, logMessageBuffer.toString()); } printedToLog = true; } // order of the resources is important to maintain properly the // hierarchy of the configuration. resourcesList.addAll(internalPropertyResourcesList); // xml resources take precedence over the properties loaded. resourcesList.addAll(internalXmlResourcesList); if (deploymentResource != null) { resourcesList.add(deploymentResource); } if (customerPropertyResource != null) { resourcesList.add(customerPropertyResource); } // xml customer resource take precedence over the properties loaded. // if (customerXmlResource != null) { // resourcesList.add(customerXmlResource); // } if (qcResource != null) { resourcesList.add(qcResource); } }
java
@Override public void afterPropertiesSet() throws Exception { // NOPMD final boolean isQCEnabld = isQCEnabled(); // iterator over the list of possible external resources // only one of the resources should exist // this is to support special locations on special modules such as: Web // etc. Resource customerPropertyResource = null; // Resource customerXmlResource = null; Resource deploymentResource = null; Resource qcResource = null; if (isQCEnabld) { LOGGER.info("Found the ConfigurationTest class indicating that QC config is to be used instead of deployment and customer config files!"); qcResource = validateQCResource(); } else { customerPropertyResource = validateCustomerPropertyConfig(); deploymentResource = validateDeploymentConfig(); if (!printedToLog) { StringBuffer logMessageBuffer = new StringBuffer("The customer resources loaded are:"); printResourcesLoaded(logMessageBuffer, customerPropertyResource); if(applicationState != null){ applicationState.setState(FoundationLevel.INFO, logMessageBuffer.toString()); } if (deploymentResource != null) { logMessageBuffer = new StringBuffer("The deployment resources loaded are:"); printResourcesLoaded(logMessageBuffer, deploymentResource); if(applicationState != null) { applicationState.setState(FoundationLevel.INFO, logMessageBuffer.toString()); } } } } // get all the resources of the internal property config files. final Resource[] internalPropertyResources = context.getResources(internalPropertyConfig); final List<Resource> internalPropertyResourcesList = Arrays.asList(internalPropertyResources); // get all the resources of the internal xml config files. // xml resources take precedence over the properties loaded. final Resource[] internalXmlResources = context.getResources(internalXmlConfig); final List<Resource> internalXmlResourcesList = Arrays.asList(internalXmlResources); if (!printedToLog) { final StringBuffer logMessageBuffer = new StringBuffer("The default resources loaded are:"); printResourcesLoaded(logMessageBuffer, internalXmlResourcesList); printResourcesLoaded(logMessageBuffer, internalPropertyResourcesList); if(applicationState != null) { applicationState.setState(FoundationLevel.INFO, logMessageBuffer.toString()); } printedToLog = true; } // order of the resources is important to maintain properly the // hierarchy of the configuration. resourcesList.addAll(internalPropertyResourcesList); // xml resources take precedence over the properties loaded. resourcesList.addAll(internalXmlResourcesList); if (deploymentResource != null) { resourcesList.add(deploymentResource); } if (customerPropertyResource != null) { resourcesList.add(customerPropertyResource); } // xml customer resource take precedence over the properties loaded. // if (customerXmlResource != null) { // resourcesList.add(customerXmlResource); // } if (qcResource != null) { resourcesList.add(qcResource); } }
[ "@", "Override", "public", "void", "afterPropertiesSet", "(", ")", "throws", "Exception", "{", "// NOPMD", "final", "boolean", "isQCEnabld", "=", "isQCEnabled", "(", ")", ";", "// iterator over the list of possible external resources", "// only one of the resources should exist", "// this is to support special locations on special modules such as: Web", "// etc.", "Resource", "customerPropertyResource", "=", "null", ";", "// Resource customerXmlResource = null;", "Resource", "deploymentResource", "=", "null", ";", "Resource", "qcResource", "=", "null", ";", "if", "(", "isQCEnabld", ")", "{", "LOGGER", ".", "info", "(", "\"Found the ConfigurationTest class indicating that QC config is to be used instead of deployment and customer config files!\"", ")", ";", "qcResource", "=", "validateQCResource", "(", ")", ";", "}", "else", "{", "customerPropertyResource", "=", "validateCustomerPropertyConfig", "(", ")", ";", "deploymentResource", "=", "validateDeploymentConfig", "(", ")", ";", "if", "(", "!", "printedToLog", ")", "{", "StringBuffer", "logMessageBuffer", "=", "new", "StringBuffer", "(", "\"The customer resources loaded are:\"", ")", ";", "printResourcesLoaded", "(", "logMessageBuffer", ",", "customerPropertyResource", ")", ";", "if", "(", "applicationState", "!=", "null", ")", "{", "applicationState", ".", "setState", "(", "FoundationLevel", ".", "INFO", ",", "logMessageBuffer", ".", "toString", "(", ")", ")", ";", "}", "if", "(", "deploymentResource", "!=", "null", ")", "{", "logMessageBuffer", "=", "new", "StringBuffer", "(", "\"The deployment resources loaded are:\"", ")", ";", "printResourcesLoaded", "(", "logMessageBuffer", ",", "deploymentResource", ")", ";", "if", "(", "applicationState", "!=", "null", ")", "{", "applicationState", ".", "setState", "(", "FoundationLevel", ".", "INFO", ",", "logMessageBuffer", ".", "toString", "(", ")", ")", ";", "}", "}", "}", "}", "// get all the resources of the internal property config files.", "final", "Resource", "[", "]", "internalPropertyResources", "=", "context", ".", "getResources", "(", "internalPropertyConfig", ")", ";", "final", "List", "<", "Resource", ">", "internalPropertyResourcesList", "=", "Arrays", ".", "asList", "(", "internalPropertyResources", ")", ";", "// get all the resources of the internal xml config files.", "// xml resources take precedence over the properties loaded.", "final", "Resource", "[", "]", "internalXmlResources", "=", "context", ".", "getResources", "(", "internalXmlConfig", ")", ";", "final", "List", "<", "Resource", ">", "internalXmlResourcesList", "=", "Arrays", ".", "asList", "(", "internalXmlResources", ")", ";", "if", "(", "!", "printedToLog", ")", "{", "final", "StringBuffer", "logMessageBuffer", "=", "new", "StringBuffer", "(", "\"The default resources loaded are:\"", ")", ";", "printResourcesLoaded", "(", "logMessageBuffer", ",", "internalXmlResourcesList", ")", ";", "printResourcesLoaded", "(", "logMessageBuffer", ",", "internalPropertyResourcesList", ")", ";", "if", "(", "applicationState", "!=", "null", ")", "{", "applicationState", ".", "setState", "(", "FoundationLevel", ".", "INFO", ",", "logMessageBuffer", ".", "toString", "(", ")", ")", ";", "}", "printedToLog", "=", "true", ";", "}", "// order of the resources is important to maintain properly the", "// hierarchy of the configuration.", "resourcesList", ".", "addAll", "(", "internalPropertyResourcesList", ")", ";", "// xml resources take precedence over the properties loaded.", "resourcesList", ".", "addAll", "(", "internalXmlResourcesList", ")", ";", "if", "(", "deploymentResource", "!=", "null", ")", "{", "resourcesList", ".", "add", "(", "deploymentResource", ")", ";", "}", "if", "(", "customerPropertyResource", "!=", "null", ")", "{", "resourcesList", ".", "add", "(", "customerPropertyResource", ")", ";", "}", "// xml customer resource take precedence over the properties loaded.", "// if (customerXmlResource != null) {", "// resourcesList.add(customerXmlResource);", "// }", "if", "(", "qcResource", "!=", "null", ")", "{", "resourcesList", ".", "add", "(", "qcResource", ")", ";", "}", "}" ]
fill the resourcesList only once. return it in the getObject method.
[ "fill", "the", "resourcesList", "only", "once", ".", "return", "it", "in", "the", "getObject", "method", "." ]
c5bd171a2cca0dc1c8d568f987843ca47c6d1eed
https://github.com/foundation-runtime/configuration/blob/c5bd171a2cca0dc1c8d568f987843ca47c6d1eed/configuration-lib/src/main/java/com/cisco/oss/foundation/configuration/ConfigResourcesLoader.java#L173-L257
149,126
hypfvieh/java-utils
src/main/java/com/github/hypfvieh/util/StringUtil.java
StringUtil.abbreviate
public static String abbreviate(String _str, int _length) { if (_str == null) { return null; } if (_str.length() <= _length) { return _str; } String abbr = _str.substring(0, _length -3) + "..."; return abbr; }
java
public static String abbreviate(String _str, int _length) { if (_str == null) { return null; } if (_str.length() <= _length) { return _str; } String abbr = _str.substring(0, _length -3) + "..."; return abbr; }
[ "public", "static", "String", "abbreviate", "(", "String", "_str", ",", "int", "_length", ")", "{", "if", "(", "_str", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "_str", ".", "length", "(", ")", "<=", "_length", ")", "{", "return", "_str", ";", "}", "String", "abbr", "=", "_str", ".", "substring", "(", "0", ",", "_length", "-", "3", ")", "+", "\"...\"", ";", "return", "abbr", ";", "}" ]
Abbreviates a String using ellipses. @param _str string to abbrivate @param _length max length @return abbreviated string, original string if string length is lower or equal then desired length or null if input was null
[ "Abbreviates", "a", "String", "using", "ellipses", "." ]
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/StringUtil.java#L43-L54
149,127
hypfvieh/java-utils
src/main/java/com/github/hypfvieh/util/StringUtil.java
StringUtil.strAppender
private static int strAppender(String[] _text, StringBuilder _sbResult, int _beginIdx, int _len) { if (_text == null || _sbResult == null) { return -1; } if (_beginIdx > _text.length) { return _text.length; } int i = _beginIdx; for (i = _beginIdx; i < _text.length; i++) { // current token length + current buffer length if (_sbResult.length() < _len) { int condition = _text[i].length() + _sbResult.length(); boolean firstOrLastToken = true; if (i <= _text.length -1 && _sbResult.length() > 0) { // add one char (for trailing space) if result is not empty and we are not on the first token condition += 1; // + 1 (for space) firstOrLastToken = false; } if (condition <= _len) { if (!firstOrLastToken) { // append a space if result is not empty and we are not on the first token _sbResult.append(" "); } _sbResult.append(_text[i]); } else { i-=1; break; } } else { if (i > _beginIdx) { i-=1; } break; } } return i; }
java
private static int strAppender(String[] _text, StringBuilder _sbResult, int _beginIdx, int _len) { if (_text == null || _sbResult == null) { return -1; } if (_beginIdx > _text.length) { return _text.length; } int i = _beginIdx; for (i = _beginIdx; i < _text.length; i++) { // current token length + current buffer length if (_sbResult.length() < _len) { int condition = _text[i].length() + _sbResult.length(); boolean firstOrLastToken = true; if (i <= _text.length -1 && _sbResult.length() > 0) { // add one char (for trailing space) if result is not empty and we are not on the first token condition += 1; // + 1 (for space) firstOrLastToken = false; } if (condition <= _len) { if (!firstOrLastToken) { // append a space if result is not empty and we are not on the first token _sbResult.append(" "); } _sbResult.append(_text[i]); } else { i-=1; break; } } else { if (i > _beginIdx) { i-=1; } break; } } return i; }
[ "private", "static", "int", "strAppender", "(", "String", "[", "]", "_text", ",", "StringBuilder", "_sbResult", ",", "int", "_beginIdx", ",", "int", "_len", ")", "{", "if", "(", "_text", "==", "null", "||", "_sbResult", "==", "null", ")", "{", "return", "-", "1", ";", "}", "if", "(", "_beginIdx", ">", "_text", ".", "length", ")", "{", "return", "_text", ".", "length", ";", "}", "int", "i", "=", "_beginIdx", ";", "for", "(", "i", "=", "_beginIdx", ";", "i", "<", "_text", ".", "length", ";", "i", "++", ")", "{", "// current token length + current buffer length", "if", "(", "_sbResult", ".", "length", "(", ")", "<", "_len", ")", "{", "int", "condition", "=", "_text", "[", "i", "]", ".", "length", "(", ")", "+", "_sbResult", ".", "length", "(", ")", ";", "boolean", "firstOrLastToken", "=", "true", ";", "if", "(", "i", "<=", "_text", ".", "length", "-", "1", "&&", "_sbResult", ".", "length", "(", ")", ">", "0", ")", "{", "// add one char (for trailing space) if result is not empty and we are not on the first token", "condition", "+=", "1", ";", "// + 1 (for space)", "firstOrLastToken", "=", "false", ";", "}", "if", "(", "condition", "<=", "_len", ")", "{", "if", "(", "!", "firstOrLastToken", ")", "{", "// append a space if result is not empty and we are not on the first token", "_sbResult", ".", "append", "(", "\" \"", ")", ";", "}", "_sbResult", ".", "append", "(", "_text", "[", "i", "]", ")", ";", "}", "else", "{", "i", "-=", "1", ";", "break", ";", "}", "}", "else", "{", "if", "(", "i", ">", "_beginIdx", ")", "{", "i", "-=", "1", ";", "}", "break", ";", "}", "}", "return", "i", ";", "}" ]
Internally used by smartStringSplit to recombine the string until the expected length is reached. @param _text string array to process @param _sbResult resulting line @param _beginIdx start index of string array @param _len line length @return last position in string array or -1 if _text or _sbResult is null
[ "Internally", "used", "by", "smartStringSplit", "to", "recombine", "the", "string", "until", "the", "expected", "length", "is", "reached", "." ]
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/StringUtil.java#L105-L139
149,128
hypfvieh/java-utils
src/main/java/com/github/hypfvieh/util/StringUtil.java
StringUtil.splitEqually
public static List<String> splitEqually(String _text, int _len) { if (_text == null) { return null; } List<String> ret = new ArrayList<String>((_text.length() + _len - 1) / _len); for (int start = 0; start < _text.length(); start += _len) { ret.add(_text.substring(start, Math.min(_text.length(), start + _len))); } return ret; }
java
public static List<String> splitEqually(String _text, int _len) { if (_text == null) { return null; } List<String> ret = new ArrayList<String>((_text.length() + _len - 1) / _len); for (int start = 0; start < _text.length(); start += _len) { ret.add(_text.substring(start, Math.min(_text.length(), start + _len))); } return ret; }
[ "public", "static", "List", "<", "String", ">", "splitEqually", "(", "String", "_text", ",", "int", "_len", ")", "{", "if", "(", "_text", "==", "null", ")", "{", "return", "null", ";", "}", "List", "<", "String", ">", "ret", "=", "new", "ArrayList", "<", "String", ">", "(", "(", "_text", ".", "length", "(", ")", "+", "_len", "-", "1", ")", "/", "_len", ")", ";", "for", "(", "int", "start", "=", "0", ";", "start", "<", "_text", ".", "length", "(", ")", ";", "start", "+=", "_len", ")", "{", "ret", ".", "add", "(", "_text", ".", "substring", "(", "start", ",", "Math", ".", "min", "(", "_text", ".", "length", "(", ")", ",", "start", "+", "_len", ")", ")", ")", ";", "}", "return", "ret", ";", "}" ]
Splits a Text to equal parts. There is no detection of words, everything will be cut to the same length. @param _text text to split @param _len max length per line @return list of string splitted to _len or null if _text was null
[ "Splits", "a", "Text", "to", "equal", "parts", ".", "There", "is", "no", "detection", "of", "words", "everything", "will", "be", "cut", "to", "the", "same", "length", "." ]
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/StringUtil.java#L149-L159
149,129
hypfvieh/java-utils
src/main/java/com/github/hypfvieh/util/StringUtil.java
StringUtil.replaceByMap
public static String replaceByMap(String _searchStr, Map<String, String> _replacements) { if (_searchStr == null) { return null; } if (_replacements == null || _replacements.isEmpty()) { return _searchStr; } String str = _searchStr; for (Entry<String, String> entry : _replacements.entrySet()) { str = str.replace(entry.getKey(), entry.getValue()); } return str; }
java
public static String replaceByMap(String _searchStr, Map<String, String> _replacements) { if (_searchStr == null) { return null; } if (_replacements == null || _replacements.isEmpty()) { return _searchStr; } String str = _searchStr; for (Entry<String, String> entry : _replacements.entrySet()) { str = str.replace(entry.getKey(), entry.getValue()); } return str; }
[ "public", "static", "String", "replaceByMap", "(", "String", "_searchStr", ",", "Map", "<", "String", ",", "String", ">", "_replacements", ")", "{", "if", "(", "_searchStr", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "_replacements", "==", "null", "||", "_replacements", ".", "isEmpty", "(", ")", ")", "{", "return", "_searchStr", ";", "}", "String", "str", "=", "_searchStr", ";", "for", "(", "Entry", "<", "String", ",", "String", ">", "entry", ":", "_replacements", ".", "entrySet", "(", ")", ")", "{", "str", "=", "str", ".", "replace", "(", "entry", ".", "getKey", "(", ")", ",", "entry", ".", "getValue", "(", ")", ")", ";", "}", "return", "str", ";", "}" ]
Replace all placeholders in given string by value of the corresponding key in given Map. @param _searchStr search string @param _replacements replacement @return String or null if _searchStr was null
[ "Replace", "all", "placeholders", "in", "given", "string", "by", "value", "of", "the", "corresponding", "key", "in", "given", "Map", "." ]
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/StringUtil.java#L168-L183
149,130
hypfvieh/java-utils
src/main/java/com/github/hypfvieh/util/StringUtil.java
StringUtil.lowerCaseFirstChar
public static String lowerCaseFirstChar(String _str) { if (_str == null) { return null; } if (_str.isEmpty()) { return _str; } return _str.substring(0, 1).toLowerCase() + _str.substring(1); }
java
public static String lowerCaseFirstChar(String _str) { if (_str == null) { return null; } if (_str.isEmpty()) { return _str; } return _str.substring(0, 1).toLowerCase() + _str.substring(1); }
[ "public", "static", "String", "lowerCaseFirstChar", "(", "String", "_str", ")", "{", "if", "(", "_str", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "_str", ".", "isEmpty", "(", ")", ")", "{", "return", "_str", ";", "}", "return", "_str", ".", "substring", "(", "0", ",", "1", ")", ".", "toLowerCase", "(", ")", "+", "_str", ".", "substring", "(", "1", ")", ";", "}" ]
Lower case the first letter of the given string. @param _str string @return lowercased string
[ "Lower", "case", "the", "first", "letter", "of", "the", "given", "string", "." ]
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/StringUtil.java#L191-L200
149,131
hypfvieh/java-utils
src/main/java/com/github/hypfvieh/util/StringUtil.java
StringUtil.upperCaseFirstChar
public static String upperCaseFirstChar(String _str) { if (_str == null) { return null; } if (_str.isEmpty()) { return _str; } return _str.substring(0, 1).toUpperCase() + _str.substring(1); }
java
public static String upperCaseFirstChar(String _str) { if (_str == null) { return null; } if (_str.isEmpty()) { return _str; } return _str.substring(0, 1).toUpperCase() + _str.substring(1); }
[ "public", "static", "String", "upperCaseFirstChar", "(", "String", "_str", ")", "{", "if", "(", "_str", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "_str", ".", "isEmpty", "(", ")", ")", "{", "return", "_str", ";", "}", "return", "_str", ".", "substring", "(", "0", ",", "1", ")", ".", "toUpperCase", "(", ")", "+", "_str", ".", "substring", "(", "1", ")", ";", "}" ]
Upper case the first letter of the given string. @param _str string @return uppercased string
[ "Upper", "case", "the", "first", "letter", "of", "the", "given", "string", "." ]
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/StringUtil.java#L208-L216
149,132
hypfvieh/java-utils
src/main/java/com/github/hypfvieh/util/StringUtil.java
StringUtil.rot13
public static String rot13(String _input) { if (_input == null) { return null; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < _input.length(); i++) { char c = _input.charAt(i); if (c >= 'a' && c <= 'm') { c += 13; } else if (c >= 'A' && c <= 'M') { c += 13; } else if (c >= 'n' && c <= 'z') { c -= 13; } else if (c >= 'N' && c <= 'Z') { c -= 13; } sb.append(c); } return sb.toString(); }
java
public static String rot13(String _input) { if (_input == null) { return null; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < _input.length(); i++) { char c = _input.charAt(i); if (c >= 'a' && c <= 'm') { c += 13; } else if (c >= 'A' && c <= 'M') { c += 13; } else if (c >= 'n' && c <= 'z') { c -= 13; } else if (c >= 'N' && c <= 'Z') { c -= 13; } sb.append(c); } return sb.toString(); }
[ "public", "static", "String", "rot13", "(", "String", "_input", ")", "{", "if", "(", "_input", "==", "null", ")", "{", "return", "null", ";", "}", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "_input", ".", "length", "(", ")", ";", "i", "++", ")", "{", "char", "c", "=", "_input", ".", "charAt", "(", "i", ")", ";", "if", "(", "c", ">=", "'", "'", "&&", "c", "<=", "'", "'", ")", "{", "c", "+=", "13", ";", "}", "else", "if", "(", "c", ">=", "'", "'", "&&", "c", "<=", "'", "'", ")", "{", "c", "+=", "13", ";", "}", "else", "if", "(", "c", ">=", "'", "'", "&&", "c", "<=", "'", "'", ")", "{", "c", "-=", "13", ";", "}", "else", "if", "(", "c", ">=", "'", "'", "&&", "c", "<=", "'", "'", ")", "{", "c", "-=", "13", ";", "}", "sb", ".", "append", "(", "c", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Simple rot13 implementation. @param _input input to scramble @return scrambled input (null if input was null)
[ "Simple", "rot13", "implementation", "." ]
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/StringUtil.java#L224-L243
149,133
hypfvieh/java-utils
src/main/java/com/github/hypfvieh/util/StringUtil.java
StringUtil.convertUpperToCamelCase
public static String convertUpperToCamelCase(String _str) { if (_str == null || isBlank(_str)) { return _str; } else if (!_str.contains("_")) { return (_str.charAt(0) + "").toUpperCase() + _str.substring(1); } StringBuffer sb = new StringBuffer(String.valueOf(_str.charAt(0)).toUpperCase()); for (int i = 1; i < _str.length(); i++) { char c = _str.charAt(i); if (c == '_') { i++; // get next character and convert to upper case c = String.valueOf(_str.charAt(i)).toUpperCase().charAt(0); } else { c = String.valueOf(c).toLowerCase().charAt(0); } sb.append(c); } return sb.toString(); }
java
public static String convertUpperToCamelCase(String _str) { if (_str == null || isBlank(_str)) { return _str; } else if (!_str.contains("_")) { return (_str.charAt(0) + "").toUpperCase() + _str.substring(1); } StringBuffer sb = new StringBuffer(String.valueOf(_str.charAt(0)).toUpperCase()); for (int i = 1; i < _str.length(); i++) { char c = _str.charAt(i); if (c == '_') { i++; // get next character and convert to upper case c = String.valueOf(_str.charAt(i)).toUpperCase().charAt(0); } else { c = String.valueOf(c).toLowerCase().charAt(0); } sb.append(c); } return sb.toString(); }
[ "public", "static", "String", "convertUpperToCamelCase", "(", "String", "_str", ")", "{", "if", "(", "_str", "==", "null", "||", "isBlank", "(", "_str", ")", ")", "{", "return", "_str", ";", "}", "else", "if", "(", "!", "_str", ".", "contains", "(", "\"_\"", ")", ")", "{", "return", "(", "_str", ".", "charAt", "(", "0", ")", "+", "\"\"", ")", ".", "toUpperCase", "(", ")", "+", "_str", ".", "substring", "(", "1", ")", ";", "}", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", "String", ".", "valueOf", "(", "_str", ".", "charAt", "(", "0", ")", ")", ".", "toUpperCase", "(", ")", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "_str", ".", "length", "(", ")", ";", "i", "++", ")", "{", "char", "c", "=", "_str", ".", "charAt", "(", "i", ")", ";", "if", "(", "c", "==", "'", "'", ")", "{", "i", "++", ";", "// get next character and convert to upper case", "c", "=", "String", ".", "valueOf", "(", "_str", ".", "charAt", "(", "i", ")", ")", ".", "toUpperCase", "(", ")", ".", "charAt", "(", "0", ")", ";", "}", "else", "{", "c", "=", "String", ".", "valueOf", "(", "c", ")", ".", "toLowerCase", "(", ")", ".", "charAt", "(", "0", ")", ";", "}", "sb", ".", "append", "(", "c", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Tries to convert upper-case string to camel-case. The given string will be analyzed and all string parts preceded by an underline character will be converted to upper-case, all other following characters to lower-case. @param _str string to convert @return converted string or original string if there was nothing to do
[ "Tries", "to", "convert", "upper", "-", "case", "string", "to", "camel", "-", "case", ".", "The", "given", "string", "will", "be", "analyzed", "and", "all", "string", "parts", "preceded", "by", "an", "underline", "character", "will", "be", "converted", "to", "upper", "-", "case", "all", "other", "following", "characters", "to", "lower", "-", "case", "." ]
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/StringUtil.java#L437-L456
149,134
hypfvieh/java-utils
src/main/java/com/github/hypfvieh/util/StringUtil.java
StringUtil.containsAny
public static boolean containsAny(boolean _ignoreCase, String _str, String... _args) { if (_str == null || _args == null || _args.length == 0) { return false; } String heystack = _str; if (_ignoreCase) { heystack = _str.toLowerCase(); } for (String s : _args) { String needle = _ignoreCase ? s.toLowerCase() : s; if (heystack.contains(needle)) { return true; } } return false; }
java
public static boolean containsAny(boolean _ignoreCase, String _str, String... _args) { if (_str == null || _args == null || _args.length == 0) { return false; } String heystack = _str; if (_ignoreCase) { heystack = _str.toLowerCase(); } for (String s : _args) { String needle = _ignoreCase ? s.toLowerCase() : s; if (heystack.contains(needle)) { return true; } } return false; }
[ "public", "static", "boolean", "containsAny", "(", "boolean", "_ignoreCase", ",", "String", "_str", ",", "String", "...", "_args", ")", "{", "if", "(", "_str", "==", "null", "||", "_args", "==", "null", "||", "_args", ".", "length", "==", "0", ")", "{", "return", "false", ";", "}", "String", "heystack", "=", "_str", ";", "if", "(", "_ignoreCase", ")", "{", "heystack", "=", "_str", ".", "toLowerCase", "(", ")", ";", "}", "for", "(", "String", "s", ":", "_args", ")", "{", "String", "needle", "=", "_ignoreCase", "?", "s", ".", "toLowerCase", "(", ")", ":", "s", ";", "if", "(", "heystack", ".", "contains", "(", "needle", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks if any of the given strings in _args is contained in _str. @param _ignoreCase true to ignore case, false to be case sensitive @param _str string to check @param _args patterns to find @return true if any string in _args is found in _str, false if not or _str/_args is null
[ "Checks", "if", "any", "of", "the", "given", "strings", "in", "_args", "is", "contained", "in", "_str", "." ]
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/StringUtil.java#L495-L512
149,135
hypfvieh/java-utils
src/main/java/com/github/hypfvieh/util/StringUtil.java
StringUtil.endsWithAny
public static boolean endsWithAny(boolean _ignoreCase, String _str, String... _args) { if (_str == null || _args == null || _args.length == 0) { return false; } String heystack = _str; if (_ignoreCase) { heystack = _str.toLowerCase(); } for (String s : _args) { String needle = _ignoreCase ? s.toLowerCase() : s; if (heystack.endsWith(needle)) { return true; } } return false; }
java
public static boolean endsWithAny(boolean _ignoreCase, String _str, String... _args) { if (_str == null || _args == null || _args.length == 0) { return false; } String heystack = _str; if (_ignoreCase) { heystack = _str.toLowerCase(); } for (String s : _args) { String needle = _ignoreCase ? s.toLowerCase() : s; if (heystack.endsWith(needle)) { return true; } } return false; }
[ "public", "static", "boolean", "endsWithAny", "(", "boolean", "_ignoreCase", ",", "String", "_str", ",", "String", "...", "_args", ")", "{", "if", "(", "_str", "==", "null", "||", "_args", "==", "null", "||", "_args", ".", "length", "==", "0", ")", "{", "return", "false", ";", "}", "String", "heystack", "=", "_str", ";", "if", "(", "_ignoreCase", ")", "{", "heystack", "=", "_str", ".", "toLowerCase", "(", ")", ";", "}", "for", "(", "String", "s", ":", "_args", ")", "{", "String", "needle", "=", "_ignoreCase", "?", "s", ".", "toLowerCase", "(", ")", ":", "s", ";", "if", "(", "heystack", ".", "endsWith", "(", "needle", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks if given string in _str ends with any of the given strings in _args. @param _ignoreCase true to ignore case, false to be case sensitive @param _str string to check @param _args patterns to find @return true if given string in _str ends with any of the given strings in _args, false if not or _str/_args is null
[ "Checks", "if", "given", "string", "in", "_str", "ends", "with", "any", "of", "the", "given", "strings", "in", "_args", "." ]
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/StringUtil.java#L521-L538
149,136
hypfvieh/java-utils
src/main/java/com/github/hypfvieh/util/StringUtil.java
StringUtil.startsWithAny
public static boolean startsWithAny(boolean _ignoreCase, String _str, String... _args) { if (_str == null || _args == null || _args.length == 0) { return false; } String heystack = _str; if (_ignoreCase) { heystack = _str.toLowerCase(); } for (String s : _args) { String needle = _ignoreCase ? s.toLowerCase() : s; if (heystack.startsWith(needle)) { return true; } } return false; }
java
public static boolean startsWithAny(boolean _ignoreCase, String _str, String... _args) { if (_str == null || _args == null || _args.length == 0) { return false; } String heystack = _str; if (_ignoreCase) { heystack = _str.toLowerCase(); } for (String s : _args) { String needle = _ignoreCase ? s.toLowerCase() : s; if (heystack.startsWith(needle)) { return true; } } return false; }
[ "public", "static", "boolean", "startsWithAny", "(", "boolean", "_ignoreCase", ",", "String", "_str", ",", "String", "...", "_args", ")", "{", "if", "(", "_str", "==", "null", "||", "_args", "==", "null", "||", "_args", ".", "length", "==", "0", ")", "{", "return", "false", ";", "}", "String", "heystack", "=", "_str", ";", "if", "(", "_ignoreCase", ")", "{", "heystack", "=", "_str", ".", "toLowerCase", "(", ")", ";", "}", "for", "(", "String", "s", ":", "_args", ")", "{", "String", "needle", "=", "_ignoreCase", "?", "s", ".", "toLowerCase", "(", ")", ":", "s", ";", "if", "(", "heystack", ".", "startsWith", "(", "needle", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks if given string in _str starts with any of the given strings in _args. @param _ignoreCase true to ignore case, false to be case sensitive @param _str string to check @param _args patterns to find @return true if given string in _str starts with any of the given strings in _args, false if not or _str/_args is null
[ "Checks", "if", "given", "string", "in", "_str", "starts", "with", "any", "of", "the", "given", "strings", "in", "_args", "." ]
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/StringUtil.java#L547-L564
149,137
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/PROTEMPAConflictResolver.java
PROTEMPAConflictResolver.compare
@Override public int compare(Activation a1, Activation a2) { //Salience-based conflict resolution. final int s1 = a1.getSalience(); final int s2 = a2.getSalience(); if (s1 > s2) { return -1; } else if (s1 < s2) { return 1; } //Propagation-based conflict resolution. final long p1 = a1.getPropagationContext().getPropagationNumber(); final long p2 = a2.getPropagationContext().getPropagationNumber(); if (p1 != p2) { return (int) (p2 - p1); } //Recency-based conflict resolution. final long r1 = a1.getTuple().getRecency(); final long r2 = a2.getTuple().getRecency(); if (r1 != r2) { return (int) (r2 - r1); } //Topological-sort-based conflict resolution. final Rule rule1 = a1.getRule(); final Rule rule2 = a2.getRule(); if (rule1 != rule2) { TemporalPropositionDefinition def1 = this.ruleToTPD.get(rule1); TemporalPropositionDefinition def2 = this.ruleToTPD.get(rule2); /* * If def1 is null, then rule1 does not correspond to an * abstraction or context definition. If def2 is null, then rule2 * does not correspond to an abstraction or context definition. In * either case, topological sort-based conflict resolution does not * apply, so skip to the next conflict resolution strategy. */ if (def1 != null && def2 != null) { return this.topSortComp.compare(def1, def2); } } //Load order-based conflict resolution. final long l1 = rule1.getLoadOrder(); final long l2 = rule2.getLoadOrder(); return (int) (l2 - l1); }
java
@Override public int compare(Activation a1, Activation a2) { //Salience-based conflict resolution. final int s1 = a1.getSalience(); final int s2 = a2.getSalience(); if (s1 > s2) { return -1; } else if (s1 < s2) { return 1; } //Propagation-based conflict resolution. final long p1 = a1.getPropagationContext().getPropagationNumber(); final long p2 = a2.getPropagationContext().getPropagationNumber(); if (p1 != p2) { return (int) (p2 - p1); } //Recency-based conflict resolution. final long r1 = a1.getTuple().getRecency(); final long r2 = a2.getTuple().getRecency(); if (r1 != r2) { return (int) (r2 - r1); } //Topological-sort-based conflict resolution. final Rule rule1 = a1.getRule(); final Rule rule2 = a2.getRule(); if (rule1 != rule2) { TemporalPropositionDefinition def1 = this.ruleToTPD.get(rule1); TemporalPropositionDefinition def2 = this.ruleToTPD.get(rule2); /* * If def1 is null, then rule1 does not correspond to an * abstraction or context definition. If def2 is null, then rule2 * does not correspond to an abstraction or context definition. In * either case, topological sort-based conflict resolution does not * apply, so skip to the next conflict resolution strategy. */ if (def1 != null && def2 != null) { return this.topSortComp.compare(def1, def2); } } //Load order-based conflict resolution. final long l1 = rule1.getLoadOrder(); final long l2 = rule2.getLoadOrder(); return (int) (l2 - l1); }
[ "@", "Override", "public", "int", "compare", "(", "Activation", "a1", ",", "Activation", "a2", ")", "{", "//Salience-based conflict resolution.", "final", "int", "s1", "=", "a1", ".", "getSalience", "(", ")", ";", "final", "int", "s2", "=", "a2", ".", "getSalience", "(", ")", ";", "if", "(", "s1", ">", "s2", ")", "{", "return", "-", "1", ";", "}", "else", "if", "(", "s1", "<", "s2", ")", "{", "return", "1", ";", "}", "//Propagation-based conflict resolution.", "final", "long", "p1", "=", "a1", ".", "getPropagationContext", "(", ")", ".", "getPropagationNumber", "(", ")", ";", "final", "long", "p2", "=", "a2", ".", "getPropagationContext", "(", ")", ".", "getPropagationNumber", "(", ")", ";", "if", "(", "p1", "!=", "p2", ")", "{", "return", "(", "int", ")", "(", "p2", "-", "p1", ")", ";", "}", "//Recency-based conflict resolution.", "final", "long", "r1", "=", "a1", ".", "getTuple", "(", ")", ".", "getRecency", "(", ")", ";", "final", "long", "r2", "=", "a2", ".", "getTuple", "(", ")", ".", "getRecency", "(", ")", ";", "if", "(", "r1", "!=", "r2", ")", "{", "return", "(", "int", ")", "(", "r2", "-", "r1", ")", ";", "}", "//Topological-sort-based conflict resolution.", "final", "Rule", "rule1", "=", "a1", ".", "getRule", "(", ")", ";", "final", "Rule", "rule2", "=", "a2", ".", "getRule", "(", ")", ";", "if", "(", "rule1", "!=", "rule2", ")", "{", "TemporalPropositionDefinition", "def1", "=", "this", ".", "ruleToTPD", ".", "get", "(", "rule1", ")", ";", "TemporalPropositionDefinition", "def2", "=", "this", ".", "ruleToTPD", ".", "get", "(", "rule2", ")", ";", "/*\n * If def1 is null, then rule1 does not correspond to an\n * abstraction or context definition. If def2 is null, then rule2 \n * does not correspond to an abstraction or context definition. In \n * either case, topological sort-based conflict resolution does not \n * apply, so skip to the next conflict resolution strategy.\n */", "if", "(", "def1", "!=", "null", "&&", "def2", "!=", "null", ")", "{", "return", "this", ".", "topSortComp", ".", "compare", "(", "def1", ",", "def2", ")", ";", "}", "}", "//Load order-based conflict resolution.", "final", "long", "l1", "=", "rule1", ".", "getLoadOrder", "(", ")", ";", "final", "long", "l2", "=", "rule2", ".", "getLoadOrder", "(", ")", ";", "return", "(", "int", ")", "(", "l2", "-", "l1", ")", ";", "}" ]
Compares two activations for order. Sequentially tries salience-, propagation-, recency-, topological- and load order-based conflict resolution. The first of these conflict resolution attempts that successfully finds a non-equal ordering of the two activations immediately returns the ordering found. @param a1 an {@link Activation}. @param a2 another {@link Activation}. @return a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
[ "Compares", "two", "activations", "for", "order", ".", "Sequentially", "tries", "salience", "-", "propagation", "-", "recency", "-", "topological", "-", "and", "load", "order", "-", "based", "conflict", "resolution", ".", "The", "first", "of", "these", "conflict", "resolution", "attempts", "that", "successfully", "finds", "a", "non", "-", "equal", "ordering", "of", "the", "two", "activations", "immediately", "returns", "the", "ordering", "found", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/PROTEMPAConflictResolver.java#L89-L136
149,138
hypfvieh/java-utils
src/main/java/com/github/hypfvieh/util/TimeMeasure.java
TimeMeasure.getElapsedFormatted
String getElapsedFormatted(DateFormat _dateFormat, long _elapsedTime) { Date elapsedTime = new Date(_elapsedTime); DateFormat sdf = _dateFormat; if (_dateFormat == null) { sdf = new SimpleDateFormat("HH:mm:ss.SSS"); } sdf.setTimeZone(TimeZone.getTimeZone("UTC")); // always use UTC so we get the correct time without timezone offset on it return sdf.format(elapsedTime); }
java
String getElapsedFormatted(DateFormat _dateFormat, long _elapsedTime) { Date elapsedTime = new Date(_elapsedTime); DateFormat sdf = _dateFormat; if (_dateFormat == null) { sdf = new SimpleDateFormat("HH:mm:ss.SSS"); } sdf.setTimeZone(TimeZone.getTimeZone("UTC")); // always use UTC so we get the correct time without timezone offset on it return sdf.format(elapsedTime); }
[ "String", "getElapsedFormatted", "(", "DateFormat", "_dateFormat", ",", "long", "_elapsedTime", ")", "{", "Date", "elapsedTime", "=", "new", "Date", "(", "_elapsedTime", ")", ";", "DateFormat", "sdf", "=", "_dateFormat", ";", "if", "(", "_dateFormat", "==", "null", ")", "{", "sdf", "=", "new", "SimpleDateFormat", "(", "\"HH:mm:ss.SSS\"", ")", ";", "}", "sdf", ".", "setTimeZone", "(", "TimeZone", ".", "getTimeZone", "(", "\"UTC\"", ")", ")", ";", "// always use UTC so we get the correct time without timezone offset on it", "return", "sdf", ".", "format", "(", "elapsedTime", ")", ";", "}" ]
Same as above, used for proper unit testing. @param _dateFormat @param _elapsedTime @return formatted string
[ "Same", "as", "above", "used", "for", "proper", "unit", "testing", "." ]
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/TimeMeasure.java#L89-L99
149,139
rolfl/MicroBench
src/main/java/net/tuis/ubench/TaskRunner.java
TaskRunner.expandTo
private static int expandTo(int length) { // add 25% + 100 - limit to Integer.Max int toAdd = 100 + (length >> 2); toAdd = Math.min(UBench.MAX_RESULTS - length, toAdd); return toAdd == 0 ? -1 : toAdd + length; }
java
private static int expandTo(int length) { // add 25% + 100 - limit to Integer.Max int toAdd = 100 + (length >> 2); toAdd = Math.min(UBench.MAX_RESULTS - length, toAdd); return toAdd == 0 ? -1 : toAdd + length; }
[ "private", "static", "int", "expandTo", "(", "int", "length", ")", "{", "// add 25% + 100 - limit to Integer.Max", "int", "toAdd", "=", "100", "+", "(", "length", ">>", "2", ")", ";", "toAdd", "=", "Math", ".", "min", "(", "UBench", ".", "MAX_RESULTS", "-", "length", ",", "toAdd", ")", ";", "return", "toAdd", "==", "0", "?", "-", "1", ":", "toAdd", "+", "length", ";", "}" ]
Compute the length of the results array with some space for growth @param length the current length @return the desired length
[ "Compute", "the", "length", "of", "the", "results", "array", "with", "some", "space", "for", "growth" ]
f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce
https://github.com/rolfl/MicroBench/blob/f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce/src/main/java/net/tuis/ubench/TaskRunner.java#L22-L27
149,140
rolfl/MicroBench
src/main/java/net/tuis/ubench/TaskRunner.java
TaskRunner.inBounds
private static final boolean inBounds(final long[] times, final double bound) { long min = times[0]; long max = times[0]; long limit = (long) (min * bound); for (int i = 1; i < times.length; i++) { if (times[i] < min) { min = times[i]; limit = (long) (min * bound); if (max > limit) { return false; } } if (times[i] > max) { max = times[i]; // new max, is it slower than the worst allowed? if (max > limit) { return false; } } } return true; }
java
private static final boolean inBounds(final long[] times, final double bound) { long min = times[0]; long max = times[0]; long limit = (long) (min * bound); for (int i = 1; i < times.length; i++) { if (times[i] < min) { min = times[i]; limit = (long) (min * bound); if (max > limit) { return false; } } if (times[i] > max) { max = times[i]; // new max, is it slower than the worst allowed? if (max > limit) { return false; } } } return true; }
[ "private", "static", "final", "boolean", "inBounds", "(", "final", "long", "[", "]", "times", ",", "final", "double", "bound", ")", "{", "long", "min", "=", "times", "[", "0", "]", ";", "long", "max", "=", "times", "[", "0", "]", ";", "long", "limit", "=", "(", "long", ")", "(", "min", "*", "bound", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "times", ".", "length", ";", "i", "++", ")", "{", "if", "(", "times", "[", "i", "]", "<", "min", ")", "{", "min", "=", "times", "[", "i", "]", ";", "limit", "=", "(", "long", ")", "(", "min", "*", "bound", ")", ";", "if", "(", "max", ">", "limit", ")", "{", "return", "false", ";", "}", "}", "if", "(", "times", "[", "i", "]", ">", "max", ")", "{", "max", "=", "times", "[", "i", "]", ";", "// new max, is it slower than the worst allowed?", "if", "(", "max", ">", "limit", ")", "{", "return", "false", ";", "}", "}", "}", "return", "true", ";", "}" ]
Compute whether any of the values in times exceed the given bound, relative to the minimum value in times. @param times the times to compute the bounds on @param bound the bound is represented as a value like 1.10 for 10% greater than the minimum @return true if all values are in bounds.
[ "Compute", "whether", "any", "of", "the", "values", "in", "times", "exceed", "the", "given", "bound", "relative", "to", "the", "minimum", "value", "in", "times", "." ]
f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce
https://github.com/rolfl/MicroBench/blob/f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce/src/main/java/net/tuis/ubench/TaskRunner.java#L40-L61
149,141
rolfl/MicroBench
src/main/java/net/tuis/ubench/TaskRunner.java
TaskRunner.invoke
boolean invoke() { if (complete) { return complete; } if (iterations >= results.length) { int newlen = expandTo(results.length); if (newlen < 0) { complete = true; return complete; } results = Arrays.copyOf(results, newlen); } long res = Math.max(task.time(), 1); results[iterations] = res; if (stable.length > 0) { stable[iterations % stable.length] = res; if (iterations > stable.length && inBounds(stable, stableLimit)) { complete = true; } } remainingTime -= res; iterations++; if (iterations >= limit || remainingTime < 0) { complete = true; } return complete; }
java
boolean invoke() { if (complete) { return complete; } if (iterations >= results.length) { int newlen = expandTo(results.length); if (newlen < 0) { complete = true; return complete; } results = Arrays.copyOf(results, newlen); } long res = Math.max(task.time(), 1); results[iterations] = res; if (stable.length > 0) { stable[iterations % stable.length] = res; if (iterations > stable.length && inBounds(stable, stableLimit)) { complete = true; } } remainingTime -= res; iterations++; if (iterations >= limit || remainingTime < 0) { complete = true; } return complete; }
[ "boolean", "invoke", "(", ")", "{", "if", "(", "complete", ")", "{", "return", "complete", ";", "}", "if", "(", "iterations", ">=", "results", ".", "length", ")", "{", "int", "newlen", "=", "expandTo", "(", "results", ".", "length", ")", ";", "if", "(", "newlen", "<", "0", ")", "{", "complete", "=", "true", ";", "return", "complete", ";", "}", "results", "=", "Arrays", ".", "copyOf", "(", "results", ",", "newlen", ")", ";", "}", "long", "res", "=", "Math", ".", "max", "(", "task", ".", "time", "(", ")", ",", "1", ")", ";", "results", "[", "iterations", "]", "=", "res", ";", "if", "(", "stable", ".", "length", ">", "0", ")", "{", "stable", "[", "iterations", "%", "stable", ".", "length", "]", "=", "res", ";", "if", "(", "iterations", ">", "stable", ".", "length", "&&", "inBounds", "(", "stable", ",", "stableLimit", ")", ")", "{", "complete", "=", "true", ";", "}", "}", "remainingTime", "-=", "res", ";", "iterations", "++", ";", "if", "(", "iterations", ">=", "limit", "||", "remainingTime", "<", "0", ")", "{", "complete", "=", "true", ";", "}", "return", "complete", ";", "}" ]
Perform a single additional iteration of the task. @return true if this task is now complete.
[ "Perform", "a", "single", "additional", "iteration", "of", "the", "task", "." ]
f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce
https://github.com/rolfl/MicroBench/blob/f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce/src/main/java/net/tuis/ubench/TaskRunner.java#L92-L122
149,142
rolfl/MicroBench
src/main/java/net/tuis/ubench/TaskRunner.java
TaskRunner.collect
UStats collect(String suite) { return new UStats(suite, name, index, Arrays.copyOf(results, iterations)); }
java
UStats collect(String suite) { return new UStats(suite, name, index, Arrays.copyOf(results, iterations)); }
[ "UStats", "collect", "(", "String", "suite", ")", "{", "return", "new", "UStats", "(", "suite", ",", "name", ",", "index", ",", "Arrays", ".", "copyOf", "(", "results", ",", "iterations", ")", ")", ";", "}" ]
Collect all statistics in to a single public UStats instance. @param suite the name of the test suite this task is part of. @return the UStats instance containing the data for statistical analysis
[ "Collect", "all", "statistics", "in", "to", "a", "single", "public", "UStats", "instance", "." ]
f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce
https://github.com/rolfl/MicroBench/blob/f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce/src/main/java/net/tuis/ubench/TaskRunner.java#L131-L133
149,143
foundation-runtime/configuration
configuration-api/src/main/java/com/cisco/oss/foundation/configuration/xml/NamespaceDefinitionMessage.java
NamespaceDefinitionMessage.sortByDependencies
public List<NamespaceDefinition> sortByDependencies() throws XmlException { ArrayList<NamespaceDefinition> sorted = new ArrayList<NamespaceDefinition>(); Map<Namespace, List<String>> namespaceMap = createNamespaceMap(jaxb.getNamespaceDefinitions()); NamespaceDefinition def = null; do { def = extractNamespaceWithLeastDependencies(namespaceMap); if(def != null) { sorted.add(def); } } while(def != null); return(sorted); }
java
public List<NamespaceDefinition> sortByDependencies() throws XmlException { ArrayList<NamespaceDefinition> sorted = new ArrayList<NamespaceDefinition>(); Map<Namespace, List<String>> namespaceMap = createNamespaceMap(jaxb.getNamespaceDefinitions()); NamespaceDefinition def = null; do { def = extractNamespaceWithLeastDependencies(namespaceMap); if(def != null) { sorted.add(def); } } while(def != null); return(sorted); }
[ "public", "List", "<", "NamespaceDefinition", ">", "sortByDependencies", "(", ")", "throws", "XmlException", "{", "ArrayList", "<", "NamespaceDefinition", ">", "sorted", "=", "new", "ArrayList", "<", "NamespaceDefinition", ">", "(", ")", ";", "Map", "<", "Namespace", ",", "List", "<", "String", ">", ">", "namespaceMap", "=", "createNamespaceMap", "(", "jaxb", ".", "getNamespaceDefinitions", "(", ")", ")", ";", "NamespaceDefinition", "def", "=", "null", ";", "do", "{", "def", "=", "extractNamespaceWithLeastDependencies", "(", "namespaceMap", ")", ";", "if", "(", "def", "!=", "null", ")", "{", "sorted", ".", "add", "(", "def", ")", ";", "}", "}", "while", "(", "def", "!=", "null", ")", ";", "return", "(", "sorted", ")", ";", "}" ]
A NamespaceDefinition cannot be injected into the DB unless it's dependencies are injected first. This method will sort the given list of NamespaceDefinitions by dependency. If dependencies are missing, or circular dependencies exist such that there aren't any NamespaceDefinitions without dependencies a XmlException will be thrown. @return The list of NamespaceDefinition Object, sorted by dependencies @throws XmlException if dependencies are missing or circular dependencies exist such that there aren't any NamespaceDefinitions without dependencies
[ "A", "NamespaceDefinition", "cannot", "be", "injected", "into", "the", "DB", "unless", "it", "s", "dependencies", "are", "injected", "first", ".", "This", "method", "will", "sort", "the", "given", "list", "of", "NamespaceDefinitions", "by", "dependency", "." ]
c5bd171a2cca0dc1c8d568f987843ca47c6d1eed
https://github.com/foundation-runtime/configuration/blob/c5bd171a2cca0dc1c8d568f987843ca47c6d1eed/configuration-api/src/main/java/com/cisco/oss/foundation/configuration/xml/NamespaceDefinitionMessage.java#L83-L98
149,144
foundation-runtime/configuration
configuration-api/src/main/java/com/cisco/oss/foundation/configuration/xml/NamespaceDefinitionMessage.java
NamespaceDefinitionMessage.createNamespaceMap
protected Map<Namespace, List<String>> createNamespaceMap(List<NamespaceDefinition> namespaceDefs) throws XmlException { ArrayList<Namespace> namespaces = new ArrayList<Namespace>(); // add all root namespaces for(NamespaceDefinition namespaceDef: namespaceDefs) { Namespace node = new Namespace(namespaceDef); if(namespaces.contains(node)) { throw new XmlException("duplicate NamespaceDefinitions found: " + node.getId()); } namespaces.add(node); } // go through each namespace's dependencies to see if any are missing for(Namespace namespace: namespaces) { List<String> dependencyIds = namespace.getDirectDependencyIds(); for(String id: dependencyIds) { if(find(namespaces, id) == null) { throw new XmlException("Found missing dependency: " + id); } } } HashMap<Namespace, List<String>> namespaceFullDependencyMap = new HashMap<Namespace, List<String>>(); for(Namespace namespace: namespaces) { ArrayList<String> fullDependencies = new ArrayList<String>(); for(String directDependencyId: namespace.getDirectDependencyIds()) { addDependenciesRecursively(namespace, namespaces, directDependencyId, fullDependencies); } namespaceFullDependencyMap.put(namespace, fullDependencies); } return(namespaceFullDependencyMap); }
java
protected Map<Namespace, List<String>> createNamespaceMap(List<NamespaceDefinition> namespaceDefs) throws XmlException { ArrayList<Namespace> namespaces = new ArrayList<Namespace>(); // add all root namespaces for(NamespaceDefinition namespaceDef: namespaceDefs) { Namespace node = new Namespace(namespaceDef); if(namespaces.contains(node)) { throw new XmlException("duplicate NamespaceDefinitions found: " + node.getId()); } namespaces.add(node); } // go through each namespace's dependencies to see if any are missing for(Namespace namespace: namespaces) { List<String> dependencyIds = namespace.getDirectDependencyIds(); for(String id: dependencyIds) { if(find(namespaces, id) == null) { throw new XmlException("Found missing dependency: " + id); } } } HashMap<Namespace, List<String>> namespaceFullDependencyMap = new HashMap<Namespace, List<String>>(); for(Namespace namespace: namespaces) { ArrayList<String> fullDependencies = new ArrayList<String>(); for(String directDependencyId: namespace.getDirectDependencyIds()) { addDependenciesRecursively(namespace, namespaces, directDependencyId, fullDependencies); } namespaceFullDependencyMap.put(namespace, fullDependencies); } return(namespaceFullDependencyMap); }
[ "protected", "Map", "<", "Namespace", ",", "List", "<", "String", ">", ">", "createNamespaceMap", "(", "List", "<", "NamespaceDefinition", ">", "namespaceDefs", ")", "throws", "XmlException", "{", "ArrayList", "<", "Namespace", ">", "namespaces", "=", "new", "ArrayList", "<", "Namespace", ">", "(", ")", ";", "// add all root namespaces", "for", "(", "NamespaceDefinition", "namespaceDef", ":", "namespaceDefs", ")", "{", "Namespace", "node", "=", "new", "Namespace", "(", "namespaceDef", ")", ";", "if", "(", "namespaces", ".", "contains", "(", "node", ")", ")", "{", "throw", "new", "XmlException", "(", "\"duplicate NamespaceDefinitions found: \"", "+", "node", ".", "getId", "(", ")", ")", ";", "}", "namespaces", ".", "add", "(", "node", ")", ";", "}", "// go through each namespace's dependencies to see if any are missing", "for", "(", "Namespace", "namespace", ":", "namespaces", ")", "{", "List", "<", "String", ">", "dependencyIds", "=", "namespace", ".", "getDirectDependencyIds", "(", ")", ";", "for", "(", "String", "id", ":", "dependencyIds", ")", "{", "if", "(", "find", "(", "namespaces", ",", "id", ")", "==", "null", ")", "{", "throw", "new", "XmlException", "(", "\"Found missing dependency: \"", "+", "id", ")", ";", "}", "}", "}", "HashMap", "<", "Namespace", ",", "List", "<", "String", ">", ">", "namespaceFullDependencyMap", "=", "new", "HashMap", "<", "Namespace", ",", "List", "<", "String", ">", ">", "(", ")", ";", "for", "(", "Namespace", "namespace", ":", "namespaces", ")", "{", "ArrayList", "<", "String", ">", "fullDependencies", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "String", "directDependencyId", ":", "namespace", ".", "getDirectDependencyIds", "(", ")", ")", "{", "addDependenciesRecursively", "(", "namespace", ",", "namespaces", ",", "directDependencyId", ",", "fullDependencies", ")", ";", "}", "namespaceFullDependencyMap", ".", "put", "(", "namespace", ",", "fullDependencies", ")", ";", "}", "return", "(", "namespaceFullDependencyMap", ")", ";", "}" ]
Checks that there aren't namespaces that depend on namespaces that don't exist in the list, and creates a list of all Namespace Objects in the list. @throws XmlException if there are any dependencies missing.
[ "Checks", "that", "there", "aren", "t", "namespaces", "that", "depend", "on", "namespaces", "that", "don", "t", "exist", "in", "the", "list", "and", "creates", "a", "list", "of", "all", "Namespace", "Objects", "in", "the", "list", "." ]
c5bd171a2cca0dc1c8d568f987843ca47c6d1eed
https://github.com/foundation-runtime/configuration/blob/c5bd171a2cca0dc1c8d568f987843ca47c6d1eed/configuration-api/src/main/java/com/cisco/oss/foundation/configuration/xml/NamespaceDefinitionMessage.java#L129-L163
149,145
foundation-runtime/configuration
configuration-api/src/main/java/com/cisco/oss/foundation/configuration/xml/NamespaceDefinitionMessage.java
NamespaceDefinitionMessage.addDependenciesRecursively
protected void addDependenciesRecursively(Namespace namespace, List<Namespace> namespaceList, String dependencyId, List<String> extendedDependencies) throws XmlException { if(extendedDependencies.contains(dependencyId)) { return; } if(namespace.getId().equals(dependencyId)) { throw new XmlException("Circular dependency found in " + namespace.getId()); } Namespace dependency = find(namespaceList, dependencyId); extendedDependencies.add(dependency.getId()); for(String indirectDependencyId: dependency.getDirectDependencyIds()) { addDependenciesRecursively(namespace, namespaceList, indirectDependencyId, extendedDependencies); } }
java
protected void addDependenciesRecursively(Namespace namespace, List<Namespace> namespaceList, String dependencyId, List<String> extendedDependencies) throws XmlException { if(extendedDependencies.contains(dependencyId)) { return; } if(namespace.getId().equals(dependencyId)) { throw new XmlException("Circular dependency found in " + namespace.getId()); } Namespace dependency = find(namespaceList, dependencyId); extendedDependencies.add(dependency.getId()); for(String indirectDependencyId: dependency.getDirectDependencyIds()) { addDependenciesRecursively(namespace, namespaceList, indirectDependencyId, extendedDependencies); } }
[ "protected", "void", "addDependenciesRecursively", "(", "Namespace", "namespace", ",", "List", "<", "Namespace", ">", "namespaceList", ",", "String", "dependencyId", ",", "List", "<", "String", ">", "extendedDependencies", ")", "throws", "XmlException", "{", "if", "(", "extendedDependencies", ".", "contains", "(", "dependencyId", ")", ")", "{", "return", ";", "}", "if", "(", "namespace", ".", "getId", "(", ")", ".", "equals", "(", "dependencyId", ")", ")", "{", "throw", "new", "XmlException", "(", "\"Circular dependency found in \"", "+", "namespace", ".", "getId", "(", ")", ")", ";", "}", "Namespace", "dependency", "=", "find", "(", "namespaceList", ",", "dependencyId", ")", ";", "extendedDependencies", ".", "add", "(", "dependency", ".", "getId", "(", ")", ")", ";", "for", "(", "String", "indirectDependencyId", ":", "dependency", ".", "getDirectDependencyIds", "(", ")", ")", "{", "addDependenciesRecursively", "(", "namespace", ",", "namespaceList", ",", "indirectDependencyId", ",", "extendedDependencies", ")", ";", "}", "}" ]
Adds dependencyId, and all of it's depdencies recursively using namespaceList, to extendedDependencies for namespace. @throws XmlException
[ "Adds", "dependencyId", "and", "all", "of", "it", "s", "depdencies", "recursively", "using", "namespaceList", "to", "extendedDependencies", "for", "namespace", "." ]
c5bd171a2cca0dc1c8d568f987843ca47c6d1eed
https://github.com/foundation-runtime/configuration/blob/c5bd171a2cca0dc1c8d568f987843ca47c6d1eed/configuration-api/src/main/java/com/cisco/oss/foundation/configuration/xml/NamespaceDefinitionMessage.java#L169-L182
149,146
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/CompoundLowLevelAbstractionDefinition.java
CompoundLowLevelAbstractionDefinition.addValueClassification
public void addValueClassification( ValueClassification valueClassification) { if (valueClassification == null) { throw new IllegalArgumentException( "valueClassification cannot be null"); } if (!classificationMatrix.containsKey(valueClassification.value)) { classificationMatrix.put(valueClassification.value, new ArrayList<>()); } lowLevelIds.add(valueClassification.lladId); classificationMatrix.get(valueClassification.value).add( new ClassificationMatrixValue(valueClassification.lladId, NominalValue.getInstance(valueClassification.lladValue))); this.valueClassifications.add(valueClassification); recalculateChildren(); }
java
public void addValueClassification( ValueClassification valueClassification) { if (valueClassification == null) { throw new IllegalArgumentException( "valueClassification cannot be null"); } if (!classificationMatrix.containsKey(valueClassification.value)) { classificationMatrix.put(valueClassification.value, new ArrayList<>()); } lowLevelIds.add(valueClassification.lladId); classificationMatrix.get(valueClassification.value).add( new ClassificationMatrixValue(valueClassification.lladId, NominalValue.getInstance(valueClassification.lladValue))); this.valueClassifications.add(valueClassification); recalculateChildren(); }
[ "public", "void", "addValueClassification", "(", "ValueClassification", "valueClassification", ")", "{", "if", "(", "valueClassification", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"valueClassification cannot be null\"", ")", ";", "}", "if", "(", "!", "classificationMatrix", ".", "containsKey", "(", "valueClassification", ".", "value", ")", ")", "{", "classificationMatrix", ".", "put", "(", "valueClassification", ".", "value", ",", "new", "ArrayList", "<>", "(", ")", ")", ";", "}", "lowLevelIds", ".", "add", "(", "valueClassification", ".", "lladId", ")", ";", "classificationMatrix", ".", "get", "(", "valueClassification", ".", "value", ")", ".", "add", "(", "new", "ClassificationMatrixValue", "(", "valueClassification", ".", "lladId", ",", "NominalValue", ".", "getInstance", "(", "valueClassification", ".", "lladValue", ")", ")", ")", ";", "this", ".", "valueClassifications", ".", "add", "(", "valueClassification", ")", ";", "recalculateChildren", "(", ")", ";", "}" ]
Adds a value classification for the abstraction. If a classification of the provided name doesn't exist, then it is created. The value definition name must be one of the values applicable to the low-level abstraction whose ID is also passed in. @param id the name of the value definition @param lowLevelAbstractionId the name of the low-level abstraction to add to the classification @param lowLevelValueDefName the name of the low-level abstraction's value
[ "Adds", "a", "value", "classification", "for", "the", "abstraction", ".", "If", "a", "classification", "of", "the", "provided", "name", "doesn", "t", "exist", "then", "it", "is", "created", ".", "The", "value", "definition", "name", "must", "be", "one", "of", "the", "values", "applicable", "to", "the", "low", "-", "level", "abstraction", "whose", "ID", "is", "also", "passed", "in", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/CompoundLowLevelAbstractionDefinition.java#L242-L257
149,147
openbase/jul
exception/src/main/java/org/openbase/jul/exception/printer/ExceptionPrinter.java
ExceptionPrinter.getHistory
public static String getHistory(final Throwable th) { VariablePrinter printer = new VariablePrinter(); printHistory(th, printer); return printer.getMessages(); }
java
public static String getHistory(final Throwable th) { VariablePrinter printer = new VariablePrinter(); printHistory(th, printer); return printer.getMessages(); }
[ "public", "static", "String", "getHistory", "(", "final", "Throwable", "th", ")", "{", "VariablePrinter", "printer", "=", "new", "VariablePrinter", "(", ")", ";", "printHistory", "(", "th", ",", "printer", ")", ";", "return", "printer", ".", "getMessages", "(", ")", ";", "}" ]
Generates a human readable Exception cause chain of the given Exception as String representation. @param th the Throwable to process the StackTrace. @return A History description as String.
[ "Generates", "a", "human", "readable", "Exception", "cause", "chain", "of", "the", "given", "Exception", "as", "String", "representation", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/exception/src/main/java/org/openbase/jul/exception/printer/ExceptionPrinter.java#L323-L327
149,148
openbase/jul
exception/src/main/java/org/openbase/jul/exception/printer/ExceptionPrinter.java
ExceptionPrinter.printVerboseMessage
public static void printVerboseMessage(final String message, final Logger logger) { try { if (JPService.getProperty(JPVerbose.class).getValue()) { logger.info(message); } else { logger.debug(message); } } catch (final JPServiceException ex) { logger.info(message); ExceptionPrinter.printHistory("Could not access verbose java property!", ex, logger); } }
java
public static void printVerboseMessage(final String message, final Logger logger) { try { if (JPService.getProperty(JPVerbose.class).getValue()) { logger.info(message); } else { logger.debug(message); } } catch (final JPServiceException ex) { logger.info(message); ExceptionPrinter.printHistory("Could not access verbose java property!", ex, logger); } }
[ "public", "static", "void", "printVerboseMessage", "(", "final", "String", "message", ",", "final", "Logger", "logger", ")", "{", "try", "{", "if", "(", "JPService", ".", "getProperty", "(", "JPVerbose", ".", "class", ")", ".", "getValue", "(", ")", ")", "{", "logger", ".", "info", "(", "message", ")", ";", "}", "else", "{", "logger", ".", "debug", "(", "message", ")", ";", "}", "}", "catch", "(", "final", "JPServiceException", "ex", ")", "{", "logger", ".", "info", "(", "message", ")", ";", "ExceptionPrinter", ".", "printHistory", "(", "\"Could not access verbose java property!\"", ",", "ex", ",", "logger", ")", ";", "}", "}" ]
Method prints the given message only in verbose mode on the INFO channel, otherwise the DEBUG channel is used for printing. @param message the message to print @param logger the logger which is used for the message logging.
[ "Method", "prints", "the", "given", "message", "only", "in", "verbose", "mode", "on", "the", "INFO", "channel", "otherwise", "the", "DEBUG", "channel", "is", "used", "for", "printing", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/exception/src/main/java/org/openbase/jul/exception/printer/ExceptionPrinter.java#L438-L449
149,149
vtatai/srec
core/src/main/java/com/github/srec/jemmy/JemmyDSL.java
JemmyDSL.find
public static Component find(String locator, String id, String componentType, boolean required) { java.awt.Component component = findComponent(locator, currentWindow().getComponent() .getSource()); if (component == null) { if (!required) { componentMap.putComponent(id, null); return null; } else { throw new JemmyDSLException("Component not found"); } } JComponentOperator operator = convertFind(component); componentMap.putComponent(id, operator); final Component finalComponent = convertFind(operator); if (finalComponent instanceof Window) { currentWindow = (Window) finalComponent; } return finalComponent; }
java
public static Component find(String locator, String id, String componentType, boolean required) { java.awt.Component component = findComponent(locator, currentWindow().getComponent() .getSource()); if (component == null) { if (!required) { componentMap.putComponent(id, null); return null; } else { throw new JemmyDSLException("Component not found"); } } JComponentOperator operator = convertFind(component); componentMap.putComponent(id, operator); final Component finalComponent = convertFind(operator); if (finalComponent instanceof Window) { currentWindow = (Window) finalComponent; } return finalComponent; }
[ "public", "static", "Component", "find", "(", "String", "locator", ",", "String", "id", ",", "String", "componentType", ",", "boolean", "required", ")", "{", "java", ".", "awt", ".", "Component", "component", "=", "findComponent", "(", "locator", ",", "currentWindow", "(", ")", ".", "getComponent", "(", ")", ".", "getSource", "(", ")", ")", ";", "if", "(", "component", "==", "null", ")", "{", "if", "(", "!", "required", ")", "{", "componentMap", ".", "putComponent", "(", "id", ",", "null", ")", ";", "return", "null", ";", "}", "else", "{", "throw", "new", "JemmyDSLException", "(", "\"Component not found\"", ")", ";", "}", "}", "JComponentOperator", "operator", "=", "convertFind", "(", "component", ")", ";", "componentMap", ".", "putComponent", "(", "id", ",", "operator", ")", ";", "final", "Component", "finalComponent", "=", "convertFind", "(", "operator", ")", ";", "if", "(", "finalComponent", "instanceof", "Window", ")", "{", "currentWindow", "=", "(", "Window", ")", "finalComponent", ";", "}", "return", "finalComponent", ";", "}" ]
Finds a component and stores it under the given id. The component can later be used on other commands using the locator "id=ID_ASSIGNED". This method searches both VISIBLE and INVISIBLE components. @param locator The locator (accepted are name (default), title, text, label) @param id The id @param componentType The component type @return The component found
[ "Finds", "a", "component", "and", "stores", "it", "under", "the", "given", "id", ".", "The", "component", "can", "later", "be", "used", "on", "other", "commands", "using", "the", "locator", "id", "=", "ID_ASSIGNED", ".", "This", "method", "searches", "both", "VISIBLE", "and", "INVISIBLE", "components", "." ]
87fa6754a6a5f8569ef628db4d149eea04062568
https://github.com/vtatai/srec/blob/87fa6754a6a5f8569ef628db4d149eea04062568/core/src/main/java/com/github/srec/jemmy/JemmyDSL.java#L296-L314
149,150
vtatai/srec
core/src/main/java/com/github/srec/jemmy/JemmyDSL.java
JemmyDSL.findByComponentType
@SuppressWarnings({"unchecked"}) public static Component findByComponentType(String id, String containerId, String componentType, int index, boolean required) { java.awt.Container container = null; if (isBlank(containerId)) { container = (java.awt.Container) currentWindow().getComponent().getSource(); } else { ComponentOperator op = componentMap.getComponent(containerId); if (op != null && op.getSource() instanceof java.awt.Container) { container = (java.awt.Container) op.getSource(); } else { container = (java.awt.Container) findComponent(containerId, currentWindow().getComponent().getSource()); if (container == null) { container = (java.awt.Container) currentWindow().getComponent().getSource(); } } } List<java.awt.Component> list = findComponents(container, translateFindType(componentType)); if (logger.isDebugEnabled()) { logger.debug("findComponents returned list :"); for (java.awt.Component c : list) { logger.debug(" " + c.getName()); } logger.debug(" index = " + index); } if (index < 0 || index >= list.size()) { if (required) { throw new JemmyDSLException("Component " + id + " not found"); } else { componentMap.putComponent(id, null); logger.debug("findByComponentType returned null"); return null; } } java.awt.Component component = list.get(index); if (component == null) { if (!required) { componentMap.putComponent(id, null); logger.debug("findByComponentType returned null"); return null; } else { throw new JemmyDSLException("Component " + id + " not found"); } } JComponentOperator operator = convertFind(component); componentMap.putComponent(id, operator); if (logger.isDebugEnabled()) { logger.debug("findByComponentType returned " + component); } return convertFind(operator); }
java
@SuppressWarnings({"unchecked"}) public static Component findByComponentType(String id, String containerId, String componentType, int index, boolean required) { java.awt.Container container = null; if (isBlank(containerId)) { container = (java.awt.Container) currentWindow().getComponent().getSource(); } else { ComponentOperator op = componentMap.getComponent(containerId); if (op != null && op.getSource() instanceof java.awt.Container) { container = (java.awt.Container) op.getSource(); } else { container = (java.awt.Container) findComponent(containerId, currentWindow().getComponent().getSource()); if (container == null) { container = (java.awt.Container) currentWindow().getComponent().getSource(); } } } List<java.awt.Component> list = findComponents(container, translateFindType(componentType)); if (logger.isDebugEnabled()) { logger.debug("findComponents returned list :"); for (java.awt.Component c : list) { logger.debug(" " + c.getName()); } logger.debug(" index = " + index); } if (index < 0 || index >= list.size()) { if (required) { throw new JemmyDSLException("Component " + id + " not found"); } else { componentMap.putComponent(id, null); logger.debug("findByComponentType returned null"); return null; } } java.awt.Component component = list.get(index); if (component == null) { if (!required) { componentMap.putComponent(id, null); logger.debug("findByComponentType returned null"); return null; } else { throw new JemmyDSLException("Component " + id + " not found"); } } JComponentOperator operator = convertFind(component); componentMap.putComponent(id, operator); if (logger.isDebugEnabled()) { logger.debug("findByComponentType returned " + component); } return convertFind(operator); }
[ "@", "SuppressWarnings", "(", "{", "\"unchecked\"", "}", ")", "public", "static", "Component", "findByComponentType", "(", "String", "id", ",", "String", "containerId", ",", "String", "componentType", ",", "int", "index", ",", "boolean", "required", ")", "{", "java", ".", "awt", ".", "Container", "container", "=", "null", ";", "if", "(", "isBlank", "(", "containerId", ")", ")", "{", "container", "=", "(", "java", ".", "awt", ".", "Container", ")", "currentWindow", "(", ")", ".", "getComponent", "(", ")", ".", "getSource", "(", ")", ";", "}", "else", "{", "ComponentOperator", "op", "=", "componentMap", ".", "getComponent", "(", "containerId", ")", ";", "if", "(", "op", "!=", "null", "&&", "op", ".", "getSource", "(", ")", "instanceof", "java", ".", "awt", ".", "Container", ")", "{", "container", "=", "(", "java", ".", "awt", ".", "Container", ")", "op", ".", "getSource", "(", ")", ";", "}", "else", "{", "container", "=", "(", "java", ".", "awt", ".", "Container", ")", "findComponent", "(", "containerId", ",", "currentWindow", "(", ")", ".", "getComponent", "(", ")", ".", "getSource", "(", ")", ")", ";", "if", "(", "container", "==", "null", ")", "{", "container", "=", "(", "java", ".", "awt", ".", "Container", ")", "currentWindow", "(", ")", ".", "getComponent", "(", ")", ".", "getSource", "(", ")", ";", "}", "}", "}", "List", "<", "java", ".", "awt", ".", "Component", ">", "list", "=", "findComponents", "(", "container", ",", "translateFindType", "(", "componentType", ")", ")", ";", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"findComponents returned list :\"", ")", ";", "for", "(", "java", ".", "awt", ".", "Component", "c", ":", "list", ")", "{", "logger", ".", "debug", "(", "\" \"", "+", "c", ".", "getName", "(", ")", ")", ";", "}", "logger", ".", "debug", "(", "\" index = \"", "+", "index", ")", ";", "}", "if", "(", "index", "<", "0", "||", "index", ">=", "list", ".", "size", "(", ")", ")", "{", "if", "(", "required", ")", "{", "throw", "new", "JemmyDSLException", "(", "\"Component \"", "+", "id", "+", "\" not found\"", ")", ";", "}", "else", "{", "componentMap", ".", "putComponent", "(", "id", ",", "null", ")", ";", "logger", ".", "debug", "(", "\"findByComponentType returned null\"", ")", ";", "return", "null", ";", "}", "}", "java", ".", "awt", ".", "Component", "component", "=", "list", ".", "get", "(", "index", ")", ";", "if", "(", "component", "==", "null", ")", "{", "if", "(", "!", "required", ")", "{", "componentMap", ".", "putComponent", "(", "id", ",", "null", ")", ";", "logger", ".", "debug", "(", "\"findByComponentType returned null\"", ")", ";", "return", "null", ";", "}", "else", "{", "throw", "new", "JemmyDSLException", "(", "\"Component \"", "+", "id", "+", "\" not found\"", ")", ";", "}", "}", "JComponentOperator", "operator", "=", "convertFind", "(", "component", ")", ";", "componentMap", ".", "putComponent", "(", "id", ",", "operator", ")", ";", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"findByComponentType returned \"", "+", "component", ")", ";", "}", "return", "convertFind", "(", "operator", ")", ";", "}" ]
Finds the first component with the given component type and stores it under the given id. The component can later be used on other commands using the locator "id=ID_ASSIGNED". This method searches both VISIBLE and INVISIBLE components. @param id The id @param componentType The component type @return The component found
[ "Finds", "the", "first", "component", "with", "the", "given", "component", "type", "and", "stores", "it", "under", "the", "given", "id", ".", "The", "component", "can", "later", "be", "used", "on", "other", "commands", "using", "the", "locator", "id", "=", "ID_ASSIGNED", ".", "This", "method", "searches", "both", "VISIBLE", "and", "INVISIBLE", "components", "." ]
87fa6754a6a5f8569ef628db4d149eea04062568
https://github.com/vtatai/srec/blob/87fa6754a6a5f8569ef628db4d149eea04062568/core/src/main/java/com/github/srec/jemmy/JemmyDSL.java#L523-L579
149,151
openbase/jul
pattern/default/src/main/java/org/openbase/jul/pattern/ChangeHandler.java
ChangeHandler.addlistener
public void addlistener(final ChangeListener listener) { synchronized (LISTENER_LOCK) { if (listeners.contains(listener)) { LOGGER.warn("Skip listener registration. listener[" + listener + "] is already registered!"); return; } listeners.add(listener); } }
java
public void addlistener(final ChangeListener listener) { synchronized (LISTENER_LOCK) { if (listeners.contains(listener)) { LOGGER.warn("Skip listener registration. listener[" + listener + "] is already registered!"); return; } listeners.add(listener); } }
[ "public", "void", "addlistener", "(", "final", "ChangeListener", "listener", ")", "{", "synchronized", "(", "LISTENER_LOCK", ")", "{", "if", "(", "listeners", ".", "contains", "(", "listener", ")", ")", "{", "LOGGER", ".", "warn", "(", "\"Skip listener registration. listener[\"", "+", "listener", "+", "\"] is already registered!\"", ")", ";", "return", ";", "}", "listeners", ".", "add", "(", "listener", ")", ";", "}", "}" ]
Registers the given listener to get informed about changes. @param listener the listener to register.
[ "Registers", "the", "given", "listener", "to", "get", "informed", "about", "changes", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/pattern/default/src/main/java/org/openbase/jul/pattern/ChangeHandler.java#L64-L72
149,152
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/DataStreamerIterator.java
DataStreamerIterator.hasNext
boolean hasNext() throws DataSourceReadException { if (!hasNextComputed) { boolean stayInLoop; do { stayInLoop = false; /* * Prior to reading the first iterator, we loop through all of * the iterators to determine the minimum keyId. The minimum * keyId, stored in currentMin, is used for data retrieval. The * value of currentMin will be null if there is no data to * retrieve. */ if (i == 0) { this.currentMin = null; for (DataStreamingEvent<E> elt : this.currentElt) { currentMin = min(elt); } } /* * If there is no data to retrieve, we'll return false. If there * is data to retrieve, we'll loop through the iterators and * pull data for the current keyId, which is the keyId field of * currentMin. If there's no data for the current keyId, this * should loop through all of the iterators until their ends, * and set hasNext to false. */ if (currentMin == null) { this.hasNext = false; } else { int n = this.currentElt.size(); for (; i < n; i++) { DataStreamingEvent<E> elt = this.currentElt.get(i); if (elt != null && elt.getKeyId().equals( this.currentMin != null ? this.currentMin.getKeyId() : null)) { this.result = elt; this.nextKeyId = elt.getKeyId(); advance(i); i++; break; } } if (this.i == n && this.result == null) { this.i = 0; stayInLoop = true; } } } while (this.hasNext && stayInLoop); this.hasNextComputed = true; } return hasNext; }
java
boolean hasNext() throws DataSourceReadException { if (!hasNextComputed) { boolean stayInLoop; do { stayInLoop = false; /* * Prior to reading the first iterator, we loop through all of * the iterators to determine the minimum keyId. The minimum * keyId, stored in currentMin, is used for data retrieval. The * value of currentMin will be null if there is no data to * retrieve. */ if (i == 0) { this.currentMin = null; for (DataStreamingEvent<E> elt : this.currentElt) { currentMin = min(elt); } } /* * If there is no data to retrieve, we'll return false. If there * is data to retrieve, we'll loop through the iterators and * pull data for the current keyId, which is the keyId field of * currentMin. If there's no data for the current keyId, this * should loop through all of the iterators until their ends, * and set hasNext to false. */ if (currentMin == null) { this.hasNext = false; } else { int n = this.currentElt.size(); for (; i < n; i++) { DataStreamingEvent<E> elt = this.currentElt.get(i); if (elt != null && elt.getKeyId().equals( this.currentMin != null ? this.currentMin.getKeyId() : null)) { this.result = elt; this.nextKeyId = elt.getKeyId(); advance(i); i++; break; } } if (this.i == n && this.result == null) { this.i = 0; stayInLoop = true; } } } while (this.hasNext && stayInLoop); this.hasNextComputed = true; } return hasNext; }
[ "boolean", "hasNext", "(", ")", "throws", "DataSourceReadException", "{", "if", "(", "!", "hasNextComputed", ")", "{", "boolean", "stayInLoop", ";", "do", "{", "stayInLoop", "=", "false", ";", "/*\n * Prior to reading the first iterator, we loop through all of\n * the iterators to determine the minimum keyId. The minimum\n * keyId, stored in currentMin, is used for data retrieval. The\n * value of currentMin will be null if there is no data to\n * retrieve.\n */", "if", "(", "i", "==", "0", ")", "{", "this", ".", "currentMin", "=", "null", ";", "for", "(", "DataStreamingEvent", "<", "E", ">", "elt", ":", "this", ".", "currentElt", ")", "{", "currentMin", "=", "min", "(", "elt", ")", ";", "}", "}", "/*\n * If there is no data to retrieve, we'll return false. If there\n * is data to retrieve, we'll loop through the iterators and\n * pull data for the current keyId, which is the keyId field of\n * currentMin. If there's no data for the current keyId, this\n * should loop through all of the iterators until their ends,\n * and set hasNext to false.\n */", "if", "(", "currentMin", "==", "null", ")", "{", "this", ".", "hasNext", "=", "false", ";", "}", "else", "{", "int", "n", "=", "this", ".", "currentElt", ".", "size", "(", ")", ";", "for", "(", ";", "i", "<", "n", ";", "i", "++", ")", "{", "DataStreamingEvent", "<", "E", ">", "elt", "=", "this", ".", "currentElt", ".", "get", "(", "i", ")", ";", "if", "(", "elt", "!=", "null", "&&", "elt", ".", "getKeyId", "(", ")", ".", "equals", "(", "this", ".", "currentMin", "!=", "null", "?", "this", ".", "currentMin", ".", "getKeyId", "(", ")", ":", "null", ")", ")", "{", "this", ".", "result", "=", "elt", ";", "this", ".", "nextKeyId", "=", "elt", ".", "getKeyId", "(", ")", ";", "advance", "(", "i", ")", ";", "i", "++", ";", "break", ";", "}", "}", "if", "(", "this", ".", "i", "==", "n", "&&", "this", ".", "result", "==", "null", ")", "{", "this", ".", "i", "=", "0", ";", "stayInLoop", "=", "true", ";", "}", "}", "}", "while", "(", "this", ".", "hasNext", "&&", "stayInLoop", ")", ";", "this", ".", "hasNextComputed", "=", "true", ";", "}", "return", "hasNext", ";", "}" ]
We loop through the iterators passed into the constructor and return whether the the next item in at least one iterator is for the right keyId. @return <code>true</code> or <code>false</code>.
[ "We", "loop", "through", "the", "iterators", "passed", "into", "the", "constructor", "and", "return", "whether", "the", "the", "next", "item", "in", "at", "least", "one", "iterator", "is", "for", "the", "right", "keyId", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/DataStreamerIterator.java#L100-L151
149,153
googolmo/OkVolley
okvolley/src/main/java/im/amomo/volley/toolbox/OkVolley.java
OkVolley.init
public OkVolley init(Context context) { this.mContext = context; InstanceRequestQueue = newRequestQueue(context); mUserAgent = generateUserAgent(context); mRequestHeaders = new HashMap<>(); mRequestHeaders.put(OkRequest.HEADER_USER_AGENT, mUserAgent); mRequestHeaders.put(OkRequest.HEADER_ACCEPT_CHARSET, OkRequest.CHARSET_UTF8); return this; }
java
public OkVolley init(Context context) { this.mContext = context; InstanceRequestQueue = newRequestQueue(context); mUserAgent = generateUserAgent(context); mRequestHeaders = new HashMap<>(); mRequestHeaders.put(OkRequest.HEADER_USER_AGENT, mUserAgent); mRequestHeaders.put(OkRequest.HEADER_ACCEPT_CHARSET, OkRequest.CHARSET_UTF8); return this; }
[ "public", "OkVolley", "init", "(", "Context", "context", ")", "{", "this", ".", "mContext", "=", "context", ";", "InstanceRequestQueue", "=", "newRequestQueue", "(", "context", ")", ";", "mUserAgent", "=", "generateUserAgent", "(", "context", ")", ";", "mRequestHeaders", "=", "new", "HashMap", "<>", "(", ")", ";", "mRequestHeaders", ".", "put", "(", "OkRequest", ".", "HEADER_USER_AGENT", ",", "mUserAgent", ")", ";", "mRequestHeaders", ".", "put", "(", "OkRequest", ".", "HEADER_ACCEPT_CHARSET", ",", "OkRequest", ".", "CHARSET_UTF8", ")", ";", "return", "this", ";", "}" ]
init method please call this method in Application @param context ApplicationContext @return this Volley Object
[ "init", "method", "please", "call", "this", "method", "in", "Application" ]
5c41df7cf1a8156c85e179a3c4af8a1c1485ffec
https://github.com/googolmo/OkVolley/blob/5c41df7cf1a8156c85e179a3c4af8a1c1485ffec/okvolley/src/main/java/im/amomo/volley/toolbox/OkVolley.java#L66-L74
149,154
googolmo/OkVolley
okvolley/src/main/java/im/amomo/volley/toolbox/OkVolley.java
OkVolley.generateUserAgent
public static String generateUserAgent(Context context) { StringBuilder ua = new StringBuilder("api-client/"); ua.append(VERSION); String packageName = context.getApplicationContext().getPackageName(); ua.append(" "); ua.append(packageName); PackageInfo pi = null; try { pi = context.getPackageManager().getPackageInfo(packageName, 0); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } if (pi != null) { ua.append("/"); ua.append(pi.versionName); ua.append("("); ua.append(pi.versionCode); ua.append(")"); } ua.append(" Android/"); ua.append(Build.VERSION.SDK_INT); try { ua.append(" "); ua.append(Build.PRODUCT); } catch (Exception e) { e.printStackTrace(); } try { ua.append(" "); ua.append(Build.MANUFACTURER); } catch (Exception e) { e.printStackTrace(); } try { ua.append(" "); ua.append(Build.MODEL); } catch (Exception e) { e.printStackTrace(); } return ua.toString(); }
java
public static String generateUserAgent(Context context) { StringBuilder ua = new StringBuilder("api-client/"); ua.append(VERSION); String packageName = context.getApplicationContext().getPackageName(); ua.append(" "); ua.append(packageName); PackageInfo pi = null; try { pi = context.getPackageManager().getPackageInfo(packageName, 0); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } if (pi != null) { ua.append("/"); ua.append(pi.versionName); ua.append("("); ua.append(pi.versionCode); ua.append(")"); } ua.append(" Android/"); ua.append(Build.VERSION.SDK_INT); try { ua.append(" "); ua.append(Build.PRODUCT); } catch (Exception e) { e.printStackTrace(); } try { ua.append(" "); ua.append(Build.MANUFACTURER); } catch (Exception e) { e.printStackTrace(); } try { ua.append(" "); ua.append(Build.MODEL); } catch (Exception e) { e.printStackTrace(); } return ua.toString(); }
[ "public", "static", "String", "generateUserAgent", "(", "Context", "context", ")", "{", "StringBuilder", "ua", "=", "new", "StringBuilder", "(", "\"api-client/\"", ")", ";", "ua", ".", "append", "(", "VERSION", ")", ";", "String", "packageName", "=", "context", ".", "getApplicationContext", "(", ")", ".", "getPackageName", "(", ")", ";", "ua", ".", "append", "(", "\" \"", ")", ";", "ua", ".", "append", "(", "packageName", ")", ";", "PackageInfo", "pi", "=", "null", ";", "try", "{", "pi", "=", "context", ".", "getPackageManager", "(", ")", ".", "getPackageInfo", "(", "packageName", ",", "0", ")", ";", "}", "catch", "(", "PackageManager", ".", "NameNotFoundException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "if", "(", "pi", "!=", "null", ")", "{", "ua", ".", "append", "(", "\"/\"", ")", ";", "ua", ".", "append", "(", "pi", ".", "versionName", ")", ";", "ua", ".", "append", "(", "\"(\"", ")", ";", "ua", ".", "append", "(", "pi", ".", "versionCode", ")", ";", "ua", ".", "append", "(", "\")\"", ")", ";", "}", "ua", ".", "append", "(", "\" Android/\"", ")", ";", "ua", ".", "append", "(", "Build", ".", "VERSION", ".", "SDK_INT", ")", ";", "try", "{", "ua", ".", "append", "(", "\" \"", ")", ";", "ua", ".", "append", "(", "Build", ".", "PRODUCT", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "try", "{", "ua", ".", "append", "(", "\" \"", ")", ";", "ua", ".", "append", "(", "Build", ".", "MANUFACTURER", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "try", "{", "ua", ".", "append", "(", "\" \"", ")", ";", "ua", ".", "append", "(", "Build", ".", "MODEL", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "return", "ua", ".", "toString", "(", ")", ";", "}" ]
build the default User-Agent @param context @return
[ "build", "the", "default", "User", "-", "Agent" ]
5c41df7cf1a8156c85e179a3c4af8a1c1485ffec
https://github.com/googolmo/OkVolley/blob/5c41df7cf1a8156c85e179a3c4af8a1c1485ffec/okvolley/src/main/java/im/amomo/volley/toolbox/OkVolley.java#L93-L140
149,155
googolmo/OkVolley
okvolley/src/main/java/im/amomo/volley/toolbox/OkVolley.java
OkVolley.getRequestQueue
@Deprecated public static RequestQueue getRequestQueue(Context context) { if (InstanceRequestQueue == null) { InstanceRequestQueue = newRequestQueue(context); } return InstanceRequestQueue; }
java
@Deprecated public static RequestQueue getRequestQueue(Context context) { if (InstanceRequestQueue == null) { InstanceRequestQueue = newRequestQueue(context); } return InstanceRequestQueue; }
[ "@", "Deprecated", "public", "static", "RequestQueue", "getRequestQueue", "(", "Context", "context", ")", "{", "if", "(", "InstanceRequestQueue", "==", "null", ")", "{", "InstanceRequestQueue", "=", "newRequestQueue", "(", "context", ")", ";", "}", "return", "InstanceRequestQueue", ";", "}" ]
getRquest queue static @param context @return {@link com.android.volley.RequestQueue}
[ "getRquest", "queue", "static" ]
5c41df7cf1a8156c85e179a3c4af8a1c1485ffec
https://github.com/googolmo/OkVolley/blob/5c41df7cf1a8156c85e179a3c4af8a1c1485ffec/okvolley/src/main/java/im/amomo/volley/toolbox/OkVolley.java#L190-L196
149,156
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/ValidateAlgorithmCheckedVisitor.java
ValidateAlgorithmCheckedVisitor.visit
@Override public void visit(LowLevelAbstractionDefinition lowLevelAbstractionDefinition) throws NoSuchAlgorithmException, AlgorithmSourceReadException { String algorithmId = lowLevelAbstractionDefinition.getAlgorithmId(); Algorithm algorithm = this.algorithmSource.readAlgorithm(algorithmId); if (algorithm == null && algorithmId != null) { throw new NoSuchAlgorithmException("Low level abstraction definition " + lowLevelAbstractionDefinition.getId() + " wants the algorithm " + algorithmId + ", but no such algorithm is available."); } this.algorithms.put(lowLevelAbstractionDefinition, algorithm); }
java
@Override public void visit(LowLevelAbstractionDefinition lowLevelAbstractionDefinition) throws NoSuchAlgorithmException, AlgorithmSourceReadException { String algorithmId = lowLevelAbstractionDefinition.getAlgorithmId(); Algorithm algorithm = this.algorithmSource.readAlgorithm(algorithmId); if (algorithm == null && algorithmId != null) { throw new NoSuchAlgorithmException("Low level abstraction definition " + lowLevelAbstractionDefinition.getId() + " wants the algorithm " + algorithmId + ", but no such algorithm is available."); } this.algorithms.put(lowLevelAbstractionDefinition, algorithm); }
[ "@", "Override", "public", "void", "visit", "(", "LowLevelAbstractionDefinition", "lowLevelAbstractionDefinition", ")", "throws", "NoSuchAlgorithmException", ",", "AlgorithmSourceReadException", "{", "String", "algorithmId", "=", "lowLevelAbstractionDefinition", ".", "getAlgorithmId", "(", ")", ";", "Algorithm", "algorithm", "=", "this", ".", "algorithmSource", ".", "readAlgorithm", "(", "algorithmId", ")", ";", "if", "(", "algorithm", "==", "null", "&&", "algorithmId", "!=", "null", ")", "{", "throw", "new", "NoSuchAlgorithmException", "(", "\"Low level abstraction definition \"", "+", "lowLevelAbstractionDefinition", ".", "getId", "(", ")", "+", "\" wants the algorithm \"", "+", "algorithmId", "+", "\", but no such algorithm is available.\"", ")", ";", "}", "this", ".", "algorithms", ".", "put", "(", "lowLevelAbstractionDefinition", ",", "algorithm", ")", ";", "}" ]
Throws an exception if no algorithm was found for the given low level abstraction definition. @param lowLevelAbstractionDefinition the low level abstraction definition to check. @throws NoSuchAlgorithmException if no algorithm was found in the algorithm source. @throws AlgorithmSourceReadException if an error occurred while reading from the algorithm source.
[ "Throws", "an", "exception", "if", "no", "algorithm", "was", "found", "for", "the", "given", "low", "level", "abstraction", "definition", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/ValidateAlgorithmCheckedVisitor.java#L70-L78
149,157
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/DeletedWorkingMemoryEventListener.java
DeletedWorkingMemoryEventListener.objectRetracted
@Override public void objectRetracted(ObjectRetractedEvent ore) { String name = ore.getPropagationContext().getRuleOrigin().getName(); if (name.equals("DELETE_PROPOSITION")) { Proposition prop = (Proposition) ore.getOldObject(); LOGGER.log(Level.FINEST, "Deleted proposition {0}", prop); prop.accept(this.setDeleteDatePropVisitor); this.propsToDelete.add(this.setDeleteDatePropVisitor.getDeleted()); } }
java
@Override public void objectRetracted(ObjectRetractedEvent ore) { String name = ore.getPropagationContext().getRuleOrigin().getName(); if (name.equals("DELETE_PROPOSITION")) { Proposition prop = (Proposition) ore.getOldObject(); LOGGER.log(Level.FINEST, "Deleted proposition {0}", prop); prop.accept(this.setDeleteDatePropVisitor); this.propsToDelete.add(this.setDeleteDatePropVisitor.getDeleted()); } }
[ "@", "Override", "public", "void", "objectRetracted", "(", "ObjectRetractedEvent", "ore", ")", "{", "String", "name", "=", "ore", ".", "getPropagationContext", "(", ")", ".", "getRuleOrigin", "(", ")", ".", "getName", "(", ")", ";", "if", "(", "name", ".", "equals", "(", "\"DELETE_PROPOSITION\"", ")", ")", "{", "Proposition", "prop", "=", "(", "Proposition", ")", "ore", ".", "getOldObject", "(", ")", ";", "LOGGER", ".", "log", "(", "Level", ".", "FINEST", ",", "\"Deleted proposition {0}\"", ",", "prop", ")", ";", "prop", ".", "accept", "(", "this", ".", "setDeleteDatePropVisitor", ")", ";", "this", ".", "propsToDelete", ".", "add", "(", "this", ".", "setDeleteDatePropVisitor", ".", "getDeleted", "(", ")", ")", ";", "}", "}" ]
Listens for retracted propositions that were retracted as a result of another proposition coming from a data source backend with a non-null delete date. Adds them to a list that will be passed to the query results handler along with propositions that remain in working memory. @param ore an object retracted event containing the retracted object and other metadata.
[ "Listens", "for", "retracted", "propositions", "that", "were", "retracted", "as", "a", "result", "of", "another", "proposition", "coming", "from", "a", "data", "source", "backend", "with", "a", "non", "-", "null", "delete", "date", ".", "Adds", "them", "to", "a", "list", "that", "will", "be", "passed", "to", "the", "query", "results", "handler", "along", "with", "propositions", "that", "remain", "in", "working", "memory", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/DeletedWorkingMemoryEventListener.java#L60-L69
149,158
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/proposition/interval/DirectionalPathConsistency.java
DirectionalPathConsistency.getConsistent
static boolean getConsistent(DirectedGraph g) { Object[] vertexOrdering = new Object[g.size()]; int voa = 0; for (Iterator<?> itr = g.iterator(); itr.hasNext(); voa++) { vertexOrdering[voa] = itr.next(); } int vol = vertexOrdering.length; Weight[][] updatedEdges = new Weight[vol][vol]; for (int k = vol - 1; k > 1; k--) { Object vk = vertexOrdering[k]; for (int i = 0; i < k; i++) { Object vi = vertexOrdering[i]; Weight wik = getWeight(i, k, vi, vk, g, updatedEdges); if (wik != null) { /* * wki may be different from wik, so we can't just get the * inverse of wik. */ Weight wki = getWeight(k, i, vk, vi, g, updatedEdges); // i > j because we evaluate the vertices in order. for (int j = i + 1; j < k; j++) { Object vj = vertexOrdering[j]; Weight wjk = getWeight(j, k, vj, vk, g, updatedEdges); if (wjk != null) { Weight wkj = getWeight(k, j, vk, vj, g, updatedEdges); Weight wikj = wik.add(wkj); Weight wjki = wjk.add(wki); Weight wij = getWeight(i, j, vi, vj, g, updatedEdges); Weight wji = getWeight(j, i, vj, vi, g, updatedEdges); Weight iwjki = wjki.invertSign(); Weight iwji = null; if (wji != null) { iwji = wji.invertSign(); } if (wij != null) { Weight intersectionMin = Weight.max(iwji, iwjki); Weight intersectionMax = Weight.min(wij, wikj); if (intersectionMin.compareTo(intersectionMax) > 0) { return false; } updatedEdges[i][j] = intersectionMax; updatedEdges[j][i] = intersectionMin.invertSign(); } else { updatedEdges[i][j] = wikj; updatedEdges[j][i] = wjki; } } } } } } return true; }
java
static boolean getConsistent(DirectedGraph g) { Object[] vertexOrdering = new Object[g.size()]; int voa = 0; for (Iterator<?> itr = g.iterator(); itr.hasNext(); voa++) { vertexOrdering[voa] = itr.next(); } int vol = vertexOrdering.length; Weight[][] updatedEdges = new Weight[vol][vol]; for (int k = vol - 1; k > 1; k--) { Object vk = vertexOrdering[k]; for (int i = 0; i < k; i++) { Object vi = vertexOrdering[i]; Weight wik = getWeight(i, k, vi, vk, g, updatedEdges); if (wik != null) { /* * wki may be different from wik, so we can't just get the * inverse of wik. */ Weight wki = getWeight(k, i, vk, vi, g, updatedEdges); // i > j because we evaluate the vertices in order. for (int j = i + 1; j < k; j++) { Object vj = vertexOrdering[j]; Weight wjk = getWeight(j, k, vj, vk, g, updatedEdges); if (wjk != null) { Weight wkj = getWeight(k, j, vk, vj, g, updatedEdges); Weight wikj = wik.add(wkj); Weight wjki = wjk.add(wki); Weight wij = getWeight(i, j, vi, vj, g, updatedEdges); Weight wji = getWeight(j, i, vj, vi, g, updatedEdges); Weight iwjki = wjki.invertSign(); Weight iwji = null; if (wji != null) { iwji = wji.invertSign(); } if (wij != null) { Weight intersectionMin = Weight.max(iwji, iwjki); Weight intersectionMax = Weight.min(wij, wikj); if (intersectionMin.compareTo(intersectionMax) > 0) { return false; } updatedEdges[i][j] = intersectionMax; updatedEdges[j][i] = intersectionMin.invertSign(); } else { updatedEdges[i][j] = wikj; updatedEdges[j][i] = wjki; } } } } } } return true; }
[ "static", "boolean", "getConsistent", "(", "DirectedGraph", "g", ")", "{", "Object", "[", "]", "vertexOrdering", "=", "new", "Object", "[", "g", ".", "size", "(", ")", "]", ";", "int", "voa", "=", "0", ";", "for", "(", "Iterator", "<", "?", ">", "itr", "=", "g", ".", "iterator", "(", ")", ";", "itr", ".", "hasNext", "(", ")", ";", "voa", "++", ")", "{", "vertexOrdering", "[", "voa", "]", "=", "itr", ".", "next", "(", ")", ";", "}", "int", "vol", "=", "vertexOrdering", ".", "length", ";", "Weight", "[", "]", "[", "]", "updatedEdges", "=", "new", "Weight", "[", "vol", "]", "[", "vol", "]", ";", "for", "(", "int", "k", "=", "vol", "-", "1", ";", "k", ">", "1", ";", "k", "--", ")", "{", "Object", "vk", "=", "vertexOrdering", "[", "k", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "k", ";", "i", "++", ")", "{", "Object", "vi", "=", "vertexOrdering", "[", "i", "]", ";", "Weight", "wik", "=", "getWeight", "(", "i", ",", "k", ",", "vi", ",", "vk", ",", "g", ",", "updatedEdges", ")", ";", "if", "(", "wik", "!=", "null", ")", "{", "/*\n * wki may be different from wik, so we can't just get the\n * inverse of wik.\n */", "Weight", "wki", "=", "getWeight", "(", "k", ",", "i", ",", "vk", ",", "vi", ",", "g", ",", "updatedEdges", ")", ";", "// i > j because we evaluate the vertices in order.", "for", "(", "int", "j", "=", "i", "+", "1", ";", "j", "<", "k", ";", "j", "++", ")", "{", "Object", "vj", "=", "vertexOrdering", "[", "j", "]", ";", "Weight", "wjk", "=", "getWeight", "(", "j", ",", "k", ",", "vj", ",", "vk", ",", "g", ",", "updatedEdges", ")", ";", "if", "(", "wjk", "!=", "null", ")", "{", "Weight", "wkj", "=", "getWeight", "(", "k", ",", "j", ",", "vk", ",", "vj", ",", "g", ",", "updatedEdges", ")", ";", "Weight", "wikj", "=", "wik", ".", "add", "(", "wkj", ")", ";", "Weight", "wjki", "=", "wjk", ".", "add", "(", "wki", ")", ";", "Weight", "wij", "=", "getWeight", "(", "i", ",", "j", ",", "vi", ",", "vj", ",", "g", ",", "updatedEdges", ")", ";", "Weight", "wji", "=", "getWeight", "(", "j", ",", "i", ",", "vj", ",", "vi", ",", "g", ",", "updatedEdges", ")", ";", "Weight", "iwjki", "=", "wjki", ".", "invertSign", "(", ")", ";", "Weight", "iwji", "=", "null", ";", "if", "(", "wji", "!=", "null", ")", "{", "iwji", "=", "wji", ".", "invertSign", "(", ")", ";", "}", "if", "(", "wij", "!=", "null", ")", "{", "Weight", "intersectionMin", "=", "Weight", ".", "max", "(", "iwji", ",", "iwjki", ")", ";", "Weight", "intersectionMax", "=", "Weight", ".", "min", "(", "wij", ",", "wikj", ")", ";", "if", "(", "intersectionMin", ".", "compareTo", "(", "intersectionMax", ")", ">", "0", ")", "{", "return", "false", ";", "}", "updatedEdges", "[", "i", "]", "[", "j", "]", "=", "intersectionMax", ";", "updatedEdges", "[", "j", "]", "[", "i", "]", "=", "intersectionMin", ".", "invertSign", "(", ")", ";", "}", "else", "{", "updatedEdges", "[", "i", "]", "[", "j", "]", "=", "wikj", ";", "updatedEdges", "[", "j", "]", "[", "i", "]", "=", "wjki", ";", "}", "}", "}", "}", "}", "}", "return", "true", ";", "}" ]
Returns whether a directed graph is consistent. @param g a <code>DirectedGraph</code>. @return <code>true</code> if the given graph is consistent, <code>false</code> otherwise.
[ "Returns", "whether", "a", "directed", "graph", "is", "consistent", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/proposition/interval/DirectionalPathConsistency.java#L88-L144
149,159
hypfvieh/java-utils
src/main/java/com/github/hypfvieh/util/SslTlsUtil.java
SslTlsUtil.initializeTrustManagers
public static TrustManager[] initializeTrustManagers(File _trustStoreFile, String _trustStorePassword) throws IOException { if (_trustStoreFile == null) { return null; } String storeType = getStoreTypeByFileName(_trustStoreFile); boolean derEncoded = storeType == STORETYPE_DER_ENCODED; if (derEncoded) { storeType = STORETYPE_JKS; } String trustStorePwd = StringUtil.defaultIfBlank(_trustStorePassword, System.getProperty("javax.net.ssl.trustStorePassword")); LOGGER.debug("Creating trust store of type '" + storeType + "' from " + (derEncoded ? "DER-encoded" : "") + " file '" + _trustStoreFile + "'"); try { TrustManagerFactory trustMgrFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); KeyStore trustStore = KeyStore.getInstance(storeType); if (derEncoded) { FileInputStream fis = new FileInputStream(_trustStoreFile); X509Certificate certificate = (X509Certificate) CertificateFactory.getInstance("X.509").generateCertificate(fis); trustStore.load(null, null); trustStore.setCertificateEntry("[der_cert_alias]", certificate); } else { trustStore.load(new FileInputStream(_trustStoreFile), trustStorePwd != null ? trustStorePwd.toCharArray() : null); } trustMgrFactory.init(trustStore); return trustMgrFactory.getTrustManagers(); } catch (GeneralSecurityException _ex) { throw new IOException("Error while setting up trustStore", _ex); } }
java
public static TrustManager[] initializeTrustManagers(File _trustStoreFile, String _trustStorePassword) throws IOException { if (_trustStoreFile == null) { return null; } String storeType = getStoreTypeByFileName(_trustStoreFile); boolean derEncoded = storeType == STORETYPE_DER_ENCODED; if (derEncoded) { storeType = STORETYPE_JKS; } String trustStorePwd = StringUtil.defaultIfBlank(_trustStorePassword, System.getProperty("javax.net.ssl.trustStorePassword")); LOGGER.debug("Creating trust store of type '" + storeType + "' from " + (derEncoded ? "DER-encoded" : "") + " file '" + _trustStoreFile + "'"); try { TrustManagerFactory trustMgrFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); KeyStore trustStore = KeyStore.getInstance(storeType); if (derEncoded) { FileInputStream fis = new FileInputStream(_trustStoreFile); X509Certificate certificate = (X509Certificate) CertificateFactory.getInstance("X.509").generateCertificate(fis); trustStore.load(null, null); trustStore.setCertificateEntry("[der_cert_alias]", certificate); } else { trustStore.load(new FileInputStream(_trustStoreFile), trustStorePwd != null ? trustStorePwd.toCharArray() : null); } trustMgrFactory.init(trustStore); return trustMgrFactory.getTrustManagers(); } catch (GeneralSecurityException _ex) { throw new IOException("Error while setting up trustStore", _ex); } }
[ "public", "static", "TrustManager", "[", "]", "initializeTrustManagers", "(", "File", "_trustStoreFile", ",", "String", "_trustStorePassword", ")", "throws", "IOException", "{", "if", "(", "_trustStoreFile", "==", "null", ")", "{", "return", "null", ";", "}", "String", "storeType", "=", "getStoreTypeByFileName", "(", "_trustStoreFile", ")", ";", "boolean", "derEncoded", "=", "storeType", "==", "STORETYPE_DER_ENCODED", ";", "if", "(", "derEncoded", ")", "{", "storeType", "=", "STORETYPE_JKS", ";", "}", "String", "trustStorePwd", "=", "StringUtil", ".", "defaultIfBlank", "(", "_trustStorePassword", ",", "System", ".", "getProperty", "(", "\"javax.net.ssl.trustStorePassword\"", ")", ")", ";", "LOGGER", ".", "debug", "(", "\"Creating trust store of type '\"", "+", "storeType", "+", "\"' from \"", "+", "(", "derEncoded", "?", "\"DER-encoded\"", ":", "\"\"", ")", "+", "\" file '\"", "+", "_trustStoreFile", "+", "\"'\"", ")", ";", "try", "{", "TrustManagerFactory", "trustMgrFactory", "=", "TrustManagerFactory", ".", "getInstance", "(", "TrustManagerFactory", ".", "getDefaultAlgorithm", "(", ")", ")", ";", "KeyStore", "trustStore", "=", "KeyStore", ".", "getInstance", "(", "storeType", ")", ";", "if", "(", "derEncoded", ")", "{", "FileInputStream", "fis", "=", "new", "FileInputStream", "(", "_trustStoreFile", ")", ";", "X509Certificate", "certificate", "=", "(", "X509Certificate", ")", "CertificateFactory", ".", "getInstance", "(", "\"X.509\"", ")", ".", "generateCertificate", "(", "fis", ")", ";", "trustStore", ".", "load", "(", "null", ",", "null", ")", ";", "trustStore", ".", "setCertificateEntry", "(", "\"[der_cert_alias]\"", ",", "certificate", ")", ";", "}", "else", "{", "trustStore", ".", "load", "(", "new", "FileInputStream", "(", "_trustStoreFile", ")", ",", "trustStorePwd", "!=", "null", "?", "trustStorePwd", ".", "toCharArray", "(", ")", ":", "null", ")", ";", "}", "trustMgrFactory", ".", "init", "(", "trustStore", ")", ";", "return", "trustMgrFactory", ".", "getTrustManagers", "(", ")", ";", "}", "catch", "(", "GeneralSecurityException", "_ex", ")", "{", "throw", "new", "IOException", "(", "\"Error while setting up trustStore\"", ",", "_ex", ")", ";", "}", "}" ]
Initialization of trustStoreManager used to provide access to the configured trustStore. @param _trustStoreFile trust store file @param _trustStorePassword trust store password @return TrustManager array or null @throws IOException on error
[ "Initialization", "of", "trustStoreManager", "used", "to", "provide", "access", "to", "the", "configured", "trustStore", "." ]
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/SslTlsUtil.java#L47-L80
149,160
hypfvieh/java-utils
src/main/java/com/github/hypfvieh/util/SslTlsUtil.java
SslTlsUtil.initializeKeyManagers
public static KeyManager[] initializeKeyManagers(File _keyStoreFile, String _keyStorePassword, String _keyPassword) throws IOException { if (_keyStoreFile == null) { return null; } String keyStorePwd = StringUtil.defaultIfBlank(_keyStorePassword, System.getProperty("javax.net.ssl.keyStorePassword")); if (StringUtil.isBlank(keyStorePwd)) { keyStorePwd = "changeit"; } String keyPwd = StringUtil.defaultIfBlank(_keyPassword, System.getProperty("javax.net.ssl.keyStorePassword")); if (StringUtil.isBlank(keyPwd)) { keyPwd = "changeit"; } String storeType = getStoreTypeByFileName(_keyStoreFile); LOGGER.debug("Creating key store of type '" + storeType + "' from file '" + _keyStoreFile + "'"); try { KeyManagerFactory keyMgrFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); KeyStore keyStore = KeyStore.getInstance(storeType); try (FileInputStream fis = new FileInputStream(_keyStoreFile)) { keyStore.load(fis, keyStorePwd.toCharArray()); } keyMgrFactory.init(keyStore, keyPwd.toCharArray()); return keyMgrFactory.getKeyManagers(); } catch (Exception _ex) { throw new IOException("Error while setting up keyStore", _ex); } }
java
public static KeyManager[] initializeKeyManagers(File _keyStoreFile, String _keyStorePassword, String _keyPassword) throws IOException { if (_keyStoreFile == null) { return null; } String keyStorePwd = StringUtil.defaultIfBlank(_keyStorePassword, System.getProperty("javax.net.ssl.keyStorePassword")); if (StringUtil.isBlank(keyStorePwd)) { keyStorePwd = "changeit"; } String keyPwd = StringUtil.defaultIfBlank(_keyPassword, System.getProperty("javax.net.ssl.keyStorePassword")); if (StringUtil.isBlank(keyPwd)) { keyPwd = "changeit"; } String storeType = getStoreTypeByFileName(_keyStoreFile); LOGGER.debug("Creating key store of type '" + storeType + "' from file '" + _keyStoreFile + "'"); try { KeyManagerFactory keyMgrFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); KeyStore keyStore = KeyStore.getInstance(storeType); try (FileInputStream fis = new FileInputStream(_keyStoreFile)) { keyStore.load(fis, keyStorePwd.toCharArray()); } keyMgrFactory.init(keyStore, keyPwd.toCharArray()); return keyMgrFactory.getKeyManagers(); } catch (Exception _ex) { throw new IOException("Error while setting up keyStore", _ex); } }
[ "public", "static", "KeyManager", "[", "]", "initializeKeyManagers", "(", "File", "_keyStoreFile", ",", "String", "_keyStorePassword", ",", "String", "_keyPassword", ")", "throws", "IOException", "{", "if", "(", "_keyStoreFile", "==", "null", ")", "{", "return", "null", ";", "}", "String", "keyStorePwd", "=", "StringUtil", ".", "defaultIfBlank", "(", "_keyStorePassword", ",", "System", ".", "getProperty", "(", "\"javax.net.ssl.keyStorePassword\"", ")", ")", ";", "if", "(", "StringUtil", ".", "isBlank", "(", "keyStorePwd", ")", ")", "{", "keyStorePwd", "=", "\"changeit\"", ";", "}", "String", "keyPwd", "=", "StringUtil", ".", "defaultIfBlank", "(", "_keyPassword", ",", "System", ".", "getProperty", "(", "\"javax.net.ssl.keyStorePassword\"", ")", ")", ";", "if", "(", "StringUtil", ".", "isBlank", "(", "keyPwd", ")", ")", "{", "keyPwd", "=", "\"changeit\"", ";", "}", "String", "storeType", "=", "getStoreTypeByFileName", "(", "_keyStoreFile", ")", ";", "LOGGER", ".", "debug", "(", "\"Creating key store of type '\"", "+", "storeType", "+", "\"' from file '\"", "+", "_keyStoreFile", "+", "\"'\"", ")", ";", "try", "{", "KeyManagerFactory", "keyMgrFactory", "=", "KeyManagerFactory", ".", "getInstance", "(", "KeyManagerFactory", ".", "getDefaultAlgorithm", "(", ")", ")", ";", "KeyStore", "keyStore", "=", "KeyStore", ".", "getInstance", "(", "storeType", ")", ";", "try", "(", "FileInputStream", "fis", "=", "new", "FileInputStream", "(", "_keyStoreFile", ")", ")", "{", "keyStore", ".", "load", "(", "fis", ",", "keyStorePwd", ".", "toCharArray", "(", ")", ")", ";", "}", "keyMgrFactory", ".", "init", "(", "keyStore", ",", "keyPwd", ".", "toCharArray", "(", ")", ")", ";", "return", "keyMgrFactory", ".", "getKeyManagers", "(", ")", ";", "}", "catch", "(", "Exception", "_ex", ")", "{", "throw", "new", "IOException", "(", "\"Error while setting up keyStore\"", ",", "_ex", ")", ";", "}", "}" ]
Initialization of keyStoreManager used to provide access to the configured keyStore. @param _keyStoreFile key store file @param _keyStorePassword key store password @param _keyPassword key password @return KeyManager array or null @throws IOException on error
[ "Initialization", "of", "keyStoreManager", "used", "to", "provide", "access", "to", "the", "configured", "keyStore", "." ]
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/SslTlsUtil.java#L91-L123
149,161
vtatai/srec
core/src/main/java/com/github/srec/command/base/BaseCommand.java
BaseCommand.findObjectSymbol
protected Object findObjectSymbol(String name, ExecutionContext context) { CommandSymbol s = context.findSymbol(name); if (s == null) throw new CommandExecutionException("Symbol cannot be null"); if (!(s instanceof VarCommand)) throw new CommandExecutionException("Symbol must be a variable"); Value value = ((VarCommand) s).getValue(null); if (value == null) throw new CommandExecutionException("Symbol cannot be null"); if (value.getType() != Type.OBJECT) throw new CommandExecutionException( "Symbol must refer to a Java object"); Object obj = value.get(); if (obj instanceof JComponentOperator) { // In case it was found by Jemmy, we want to get the source // TODO make this Jemmy independent obj = ((JComponentOperator) obj).getSource(); } return obj; }
java
protected Object findObjectSymbol(String name, ExecutionContext context) { CommandSymbol s = context.findSymbol(name); if (s == null) throw new CommandExecutionException("Symbol cannot be null"); if (!(s instanceof VarCommand)) throw new CommandExecutionException("Symbol must be a variable"); Value value = ((VarCommand) s).getValue(null); if (value == null) throw new CommandExecutionException("Symbol cannot be null"); if (value.getType() != Type.OBJECT) throw new CommandExecutionException( "Symbol must refer to a Java object"); Object obj = value.get(); if (obj instanceof JComponentOperator) { // In case it was found by Jemmy, we want to get the source // TODO make this Jemmy independent obj = ((JComponentOperator) obj).getSource(); } return obj; }
[ "protected", "Object", "findObjectSymbol", "(", "String", "name", ",", "ExecutionContext", "context", ")", "{", "CommandSymbol", "s", "=", "context", ".", "findSymbol", "(", "name", ")", ";", "if", "(", "s", "==", "null", ")", "throw", "new", "CommandExecutionException", "(", "\"Symbol cannot be null\"", ")", ";", "if", "(", "!", "(", "s", "instanceof", "VarCommand", ")", ")", "throw", "new", "CommandExecutionException", "(", "\"Symbol must be a variable\"", ")", ";", "Value", "value", "=", "(", "(", "VarCommand", ")", "s", ")", ".", "getValue", "(", "null", ")", ";", "if", "(", "value", "==", "null", ")", "throw", "new", "CommandExecutionException", "(", "\"Symbol cannot be null\"", ")", ";", "if", "(", "value", ".", "getType", "(", ")", "!=", "Type", ".", "OBJECT", ")", "throw", "new", "CommandExecutionException", "(", "\"Symbol must refer to a Java object\"", ")", ";", "Object", "obj", "=", "value", ".", "get", "(", ")", ";", "if", "(", "obj", "instanceof", "JComponentOperator", ")", "{", "// In case it was found by Jemmy, we want to get the source", "// TODO make this Jemmy independent", "obj", "=", "(", "(", "JComponentOperator", ")", "obj", ")", ".", "getSource", "(", ")", ";", "}", "return", "obj", ";", "}" ]
Finds a symbol which should wrap a Java object. @param name The symbol name @param context The EC @return The object, if it was found by Jemmy returns the source
[ "Finds", "a", "symbol", "which", "should", "wrap", "a", "Java", "object", "." ]
87fa6754a6a5f8569ef628db4d149eea04062568
https://github.com/vtatai/srec/blob/87fa6754a6a5f8569ef628db4d149eea04062568/core/src/main/java/com/github/srec/command/base/BaseCommand.java#L120-L139
149,162
openbase/jul
extension/type/storage/src/main/java/org/openbase/jul/extension/type/storage/registry/consistency/TransformationFrameConsistencyHandler.java
TransformationFrameConsistencyHandler.verifyAndUpdatePlacement
protected PlacementConfig verifyAndUpdatePlacement(final String alias, final PlacementConfig placementConfig) throws CouldNotPerformException, EntryModification { try { if (alias == null || alias.isEmpty()) { throw new NotAvailableException("label"); } if (placementConfig == null) { throw new NotAvailableException("placementconfig"); } String frameId = generateFrameId(alias, placementConfig); // verify and update frame id if (placementConfig.getTransformationFrameId().equals(frameId)) { return null; } return placementConfig.toBuilder().setTransformationFrameId(frameId).build(); } catch (CouldNotPerformException ex) { throw new CouldNotPerformException("Could not verify and update placement!", ex); } }
java
protected PlacementConfig verifyAndUpdatePlacement(final String alias, final PlacementConfig placementConfig) throws CouldNotPerformException, EntryModification { try { if (alias == null || alias.isEmpty()) { throw new NotAvailableException("label"); } if (placementConfig == null) { throw new NotAvailableException("placementconfig"); } String frameId = generateFrameId(alias, placementConfig); // verify and update frame id if (placementConfig.getTransformationFrameId().equals(frameId)) { return null; } return placementConfig.toBuilder().setTransformationFrameId(frameId).build(); } catch (CouldNotPerformException ex) { throw new CouldNotPerformException("Could not verify and update placement!", ex); } }
[ "protected", "PlacementConfig", "verifyAndUpdatePlacement", "(", "final", "String", "alias", ",", "final", "PlacementConfig", "placementConfig", ")", "throws", "CouldNotPerformException", ",", "EntryModification", "{", "try", "{", "if", "(", "alias", "==", "null", "||", "alias", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "NotAvailableException", "(", "\"label\"", ")", ";", "}", "if", "(", "placementConfig", "==", "null", ")", "{", "throw", "new", "NotAvailableException", "(", "\"placementconfig\"", ")", ";", "}", "String", "frameId", "=", "generateFrameId", "(", "alias", ",", "placementConfig", ")", ";", "// verify and update frame id", "if", "(", "placementConfig", ".", "getTransformationFrameId", "(", ")", ".", "equals", "(", "frameId", ")", ")", "{", "return", "null", ";", "}", "return", "placementConfig", ".", "toBuilder", "(", ")", ".", "setTransformationFrameId", "(", "frameId", ")", ".", "build", "(", ")", ";", "}", "catch", "(", "CouldNotPerformException", "ex", ")", "{", "throw", "new", "CouldNotPerformException", "(", "\"Could not verify and update placement!\"", ",", "ex", ")", ";", "}", "}" ]
Methods verifies and updates the transformation frame id for the given placement configuration. If the given placement configuration is up to date this the method returns null. @param alias @param placementConfig @return @throws CouldNotPerformException @throws EntryModification
[ "Methods", "verifies", "and", "updates", "the", "transformation", "frame", "id", "for", "the", "given", "placement", "configuration", ".", "If", "the", "given", "placement", "configuration", "is", "up", "to", "date", "this", "the", "method", "returns", "null", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/extension/type/storage/src/main/java/org/openbase/jul/extension/type/storage/registry/consistency/TransformationFrameConsistencyHandler.java#L64-L85
149,163
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/proposition/CopyPropositionVisitor.java
CopyPropositionVisitor.setProperties
public void setProperties(Map<String, Value> properties) { if (properties != null) { this.properties = new HashMap<>(properties); } else { this.properties = null; } }
java
public void setProperties(Map<String, Value> properties) { if (properties != null) { this.properties = new HashMap<>(properties); } else { this.properties = null; } }
[ "public", "void", "setProperties", "(", "Map", "<", "String", ",", "Value", ">", "properties", ")", "{", "if", "(", "properties", "!=", "null", ")", "{", "this", ".", "properties", "=", "new", "HashMap", "<>", "(", "properties", ")", ";", "}", "else", "{", "this", ".", "properties", "=", "null", ";", "}", "}" ]
Overrides the properties for copies made with this visitor. @param properties a map of property name to value pairs, or <code>null</code> to use the original proposition's value for this field.
[ "Overrides", "the", "properties", "for", "copies", "made", "with", "this", "visitor", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/proposition/CopyPropositionVisitor.java#L73-L79
149,164
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/proposition/CopyPropositionVisitor.java
CopyPropositionVisitor.setReferences
public void setReferences(Map<String, List<UniqueId>> references) { if (references != null) { this.references = new HashMap<>(references); } else { this.references = null; } }
java
public void setReferences(Map<String, List<UniqueId>> references) { if (references != null) { this.references = new HashMap<>(references); } else { this.references = null; } }
[ "public", "void", "setReferences", "(", "Map", "<", "String", ",", "List", "<", "UniqueId", ">", ">", "references", ")", "{", "if", "(", "references", "!=", "null", ")", "{", "this", ".", "references", "=", "new", "HashMap", "<>", "(", "references", ")", ";", "}", "else", "{", "this", ".", "references", "=", "null", ";", "}", "}" ]
Overrides the references for copies made with this visitor. @param references a map of reference name to reference pairs, or <code>null</code> to use the original proposition's value for this field.
[ "Overrides", "the", "references", "for", "copies", "made", "with", "this", "visitor", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/proposition/CopyPropositionVisitor.java#L98-L104
149,165
openbase/jul
pattern/default/src/main/java/org/openbase/jul/pattern/AbstractFilter.java
AbstractFilter.filter
@Override public List<T> filter(final List<T> list) throws CouldNotPerformException { beforeFilter(); return ListFilter.super.filter(list); }
java
@Override public List<T> filter(final List<T> list) throws CouldNotPerformException { beforeFilter(); return ListFilter.super.filter(list); }
[ "@", "Override", "public", "List", "<", "T", ">", "filter", "(", "final", "List", "<", "T", ">", "list", ")", "throws", "CouldNotPerformException", "{", "beforeFilter", "(", ")", ";", "return", "ListFilter", ".", "super", ".", "filter", "(", "list", ")", ";", "}" ]
Filter object from the list for which the verification fails. @param list the list which is filtered @return a filtered list @throws CouldNotPerformException if an error occurs while filtering
[ "Filter", "object", "from", "the", "list", "for", "which", "the", "verification", "fails", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/pattern/default/src/main/java/org/openbase/jul/pattern/AbstractFilter.java#L44-L48
149,166
ebean-orm/querybean-agent-now-merged-into-ebean-agent-
src/main/java/io/ebean/typequery/agent/EnhanceContext.java
EnhanceContext.log
public void log(int level, String msg, String extra) { if (logLevel >= level) { messageListener.debug(msg + extra); } }
java
public void log(int level, String msg, String extra) { if (logLevel >= level) { messageListener.debug(msg + extra); } }
[ "public", "void", "log", "(", "int", "level", ",", "String", "msg", ",", "String", "extra", ")", "{", "if", "(", "logLevel", ">=", "level", ")", "{", "messageListener", ".", "debug", "(", "msg", "+", "extra", ")", ";", "}", "}" ]
Log some debug output.
[ "Log", "some", "debug", "output", "." ]
a063554fabdbed15ff5e10ad0a0b53b67e039006
https://github.com/ebean-orm/querybean-agent-now-merged-into-ebean-agent-/blob/a063554fabdbed15ff5e10ad0a0b53b67e039006/src/main/java/io/ebean/typequery/agent/EnhanceContext.java#L88-L92
149,167
ebean-orm/querybean-agent-now-merged-into-ebean-agent-
src/main/java/io/ebean/typequery/agent/QueryBeanTransformer.java
QueryBeanTransformer.enhancement
private byte[] enhancement(ClassLoader classLoader, byte[] classfileBuffer) { ClassReader cr = new ClassReader(classfileBuffer); CLAwareClassWriter cw = new CLAwareClassWriter(FLAGS, classLoader); TypeQueryClassAdapter ca = new TypeQueryClassAdapter(cw, enhanceContext); try { cr.accept(ca, ClassReader.EXPAND_FRAMES); if (ca.isLog(9)) { ca.log("... completed"); } return cw.toByteArray(); } catch (AlreadyEnhancedException e) { if (ca.isLog(1)) { ca.log("already enhanced"); } return null; } catch (NoEnhancementRequiredException e) { if (ca.isLog(9)) { ca.log("... skipping, no enhancement required"); } return null; } }
java
private byte[] enhancement(ClassLoader classLoader, byte[] classfileBuffer) { ClassReader cr = new ClassReader(classfileBuffer); CLAwareClassWriter cw = new CLAwareClassWriter(FLAGS, classLoader); TypeQueryClassAdapter ca = new TypeQueryClassAdapter(cw, enhanceContext); try { cr.accept(ca, ClassReader.EXPAND_FRAMES); if (ca.isLog(9)) { ca.log("... completed"); } return cw.toByteArray(); } catch (AlreadyEnhancedException e) { if (ca.isLog(1)) { ca.log("already enhanced"); } return null; } catch (NoEnhancementRequiredException e) { if (ca.isLog(9)) { ca.log("... skipping, no enhancement required"); } return null; } }
[ "private", "byte", "[", "]", "enhancement", "(", "ClassLoader", "classLoader", ",", "byte", "[", "]", "classfileBuffer", ")", "{", "ClassReader", "cr", "=", "new", "ClassReader", "(", "classfileBuffer", ")", ";", "CLAwareClassWriter", "cw", "=", "new", "CLAwareClassWriter", "(", "FLAGS", ",", "classLoader", ")", ";", "TypeQueryClassAdapter", "ca", "=", "new", "TypeQueryClassAdapter", "(", "cw", ",", "enhanceContext", ")", ";", "try", "{", "cr", ".", "accept", "(", "ca", ",", "ClassReader", ".", "EXPAND_FRAMES", ")", ";", "if", "(", "ca", ".", "isLog", "(", "9", ")", ")", "{", "ca", ".", "log", "(", "\"... completed\"", ")", ";", "}", "return", "cw", ".", "toByteArray", "(", ")", ";", "}", "catch", "(", "AlreadyEnhancedException", "e", ")", "{", "if", "(", "ca", ".", "isLog", "(", "1", ")", ")", "{", "ca", ".", "log", "(", "\"already enhanced\"", ")", ";", "}", "return", "null", ";", "}", "catch", "(", "NoEnhancementRequiredException", "e", ")", "{", "if", "(", "ca", ".", "isLog", "(", "9", ")", ")", "{", "ca", ".", "log", "(", "\"... skipping, no enhancement required\"", ")", ";", "}", "return", "null", ";", "}", "}" ]
Perform enhancement.
[ "Perform", "enhancement", "." ]
a063554fabdbed15ff5e10ad0a0b53b67e039006
https://github.com/ebean-orm/querybean-agent-now-merged-into-ebean-agent-/blob/a063554fabdbed15ff5e10ad0a0b53b67e039006/src/main/java/io/ebean/typequery/agent/QueryBeanTransformer.java#L91-L117
149,168
openbase/jul
extension/type/processing/src/main/java/org/openbase/jul/extension/type/processing/LabelProcessor.java
LabelProcessor.contains
public static boolean contains(final Label label, final String labelString) { final String withoutWhite = StringProcessor.removeWhiteSpaces(labelString); for (final Label.MapFieldEntry entry : label.getEntryList()) { for (final String value : entry.getValueList()) { if (StringProcessor.removeWhiteSpaces(value).equalsIgnoreCase(withoutWhite)) { return true; } } } return false; }
java
public static boolean contains(final Label label, final String labelString) { final String withoutWhite = StringProcessor.removeWhiteSpaces(labelString); for (final Label.MapFieldEntry entry : label.getEntryList()) { for (final String value : entry.getValueList()) { if (StringProcessor.removeWhiteSpaces(value).equalsIgnoreCase(withoutWhite)) { return true; } } } return false; }
[ "public", "static", "boolean", "contains", "(", "final", "Label", "label", ",", "final", "String", "labelString", ")", "{", "final", "String", "withoutWhite", "=", "StringProcessor", ".", "removeWhiteSpaces", "(", "labelString", ")", ";", "for", "(", "final", "Label", ".", "MapFieldEntry", "entry", ":", "label", ".", "getEntryList", "(", ")", ")", "{", "for", "(", "final", "String", "value", ":", "entry", ".", "getValueList", "(", ")", ")", "{", "if", "(", "StringProcessor", ".", "removeWhiteSpaces", "(", "value", ")", ".", "equalsIgnoreCase", "(", "withoutWhite", ")", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Test if a label contains a label string. This test iterates over all languages and all label strings for the language and check if one equals the label string. The test is done ignoring the case of the label string and ignoring white spaces. @param label the label type which is checked @param labelString the label string that is tested if it is contained in the label type @return if the labelString is contained in the label type
[ "Test", "if", "a", "label", "contains", "a", "label", "string", ".", "This", "test", "iterates", "over", "all", "languages", "and", "all", "label", "strings", "for", "the", "language", "and", "check", "if", "one", "equals", "the", "label", "string", ".", "The", "test", "is", "done", "ignoring", "the", "case", "of", "the", "label", "string", "and", "ignoring", "white", "spaces", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/extension/type/processing/src/main/java/org/openbase/jul/extension/type/processing/LabelProcessor.java#L58-L68
149,169
openbase/jul
extension/type/processing/src/main/java/org/openbase/jul/extension/type/processing/LabelProcessor.java
LabelProcessor.isEmpty
public static boolean isEmpty(final Label label) { for (Label.MapFieldEntry entry : label.getEntryList()) { for (String value : entry.getValueList()) { if (!value.isEmpty()) { return false; } } } return true; }
java
public static boolean isEmpty(final Label label) { for (Label.MapFieldEntry entry : label.getEntryList()) { for (String value : entry.getValueList()) { if (!value.isEmpty()) { return false; } } } return true; }
[ "public", "static", "boolean", "isEmpty", "(", "final", "Label", "label", ")", "{", "for", "(", "Label", ".", "MapFieldEntry", "entry", ":", "label", ".", "getEntryList", "(", ")", ")", "{", "for", "(", "String", "value", ":", "entry", ".", "getValueList", "(", ")", ")", "{", "if", "(", "!", "value", ".", "isEmpty", "(", ")", ")", "{", "return", "false", ";", "}", "}", "}", "return", "true", ";", "}" ]
Test if the label is empty. This means that every label list for every languageCode is empty or that it only contains empty string. @param label the label type which is tested @return if the label type is empty as explained above
[ "Test", "if", "the", "label", "is", "empty", ".", "This", "means", "that", "every", "label", "list", "for", "every", "languageCode", "is", "empty", "or", "that", "it", "only", "contains", "empty", "string", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/extension/type/processing/src/main/java/org/openbase/jul/extension/type/processing/LabelProcessor.java#L78-L87
149,170
openbase/jul
extension/type/processing/src/main/java/org/openbase/jul/extension/type/processing/LabelProcessor.java
LabelProcessor.addLabel
public static Label.Builder addLabel(final Label.Builder labelBuilder, final String languageCode, final String label) { for (int i = 0; i < labelBuilder.getEntryCount(); i++) { // found labels for the entry key if (labelBuilder.getEntry(i).getKey().equals(languageCode)) { // check if the new value is not already contained for (String value : labelBuilder.getEntryBuilder(i).getValueList()) { if (value.equalsIgnoreCase(label)) { // return because label is already in there return labelBuilder; } } // add new label labelBuilder.getEntryBuilder(i).addValue(label); return labelBuilder; } } // language code not present yet labelBuilder.addEntryBuilder().setKey(languageCode).addValue(label); return labelBuilder; }
java
public static Label.Builder addLabel(final Label.Builder labelBuilder, final String languageCode, final String label) { for (int i = 0; i < labelBuilder.getEntryCount(); i++) { // found labels for the entry key if (labelBuilder.getEntry(i).getKey().equals(languageCode)) { // check if the new value is not already contained for (String value : labelBuilder.getEntryBuilder(i).getValueList()) { if (value.equalsIgnoreCase(label)) { // return because label is already in there return labelBuilder; } } // add new label labelBuilder.getEntryBuilder(i).addValue(label); return labelBuilder; } } // language code not present yet labelBuilder.addEntryBuilder().setKey(languageCode).addValue(label); return labelBuilder; }
[ "public", "static", "Label", ".", "Builder", "addLabel", "(", "final", "Label", ".", "Builder", "labelBuilder", ",", "final", "String", "languageCode", ",", "final", "String", "label", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "labelBuilder", ".", "getEntryCount", "(", ")", ";", "i", "++", ")", "{", "// found labels for the entry key", "if", "(", "labelBuilder", ".", "getEntry", "(", "i", ")", ".", "getKey", "(", ")", ".", "equals", "(", "languageCode", ")", ")", "{", "// check if the new value is not already contained", "for", "(", "String", "value", ":", "labelBuilder", ".", "getEntryBuilder", "(", "i", ")", ".", "getValueList", "(", ")", ")", "{", "if", "(", "value", ".", "equalsIgnoreCase", "(", "label", ")", ")", "{", "// return because label is already in there", "return", "labelBuilder", ";", "}", "}", "// add new label", "labelBuilder", ".", "getEntryBuilder", "(", "i", ")", ".", "addValue", "(", "label", ")", ";", "return", "labelBuilder", ";", "}", "}", "// language code not present yet", "labelBuilder", ".", "addEntryBuilder", "(", ")", ".", "setKey", "(", "languageCode", ")", ".", "addValue", "(", "label", ")", ";", "return", "labelBuilder", ";", "}" ]
Add a label to a labelBuilder by languageCode. If the label is already contained for the language code nothing will be done. If the languageCode already exists and the label is not contained it will be added to the end of the label list by this language code. If no entry for the languageCode exists a new entry will be added and the label added as its first value. @param labelBuilder the label builder to be updated @param languageCode the languageCode for which the label is added @param label the label to be added @return the updated label builder
[ "Add", "a", "label", "to", "a", "labelBuilder", "by", "languageCode", ".", "If", "the", "label", "is", "already", "contained", "for", "the", "language", "code", "nothing", "will", "be", "done", ".", "If", "the", "languageCode", "already", "exists", "and", "the", "label", "is", "not", "contained", "it", "will", "be", "added", "to", "the", "end", "of", "the", "label", "list", "by", "this", "language", "code", ".", "If", "no", "entry", "for", "the", "languageCode", "exists", "a", "new", "entry", "will", "be", "added", "and", "the", "label", "added", "as", "its", "first", "value", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/extension/type/processing/src/main/java/org/openbase/jul/extension/type/processing/LabelProcessor.java#L162-L183
149,171
openbase/jul
extension/type/processing/src/main/java/org/openbase/jul/extension/type/processing/LabelProcessor.java
LabelProcessor.getFirstLabel
public static String getFirstLabel(final LabelOrBuilder label) throws NotAvailableException { for (Label.MapFieldEntry entry : label.getEntryList()) { for (String value : entry.getValueList()) { return value; } } throw new NotAvailableException("Label"); }
java
public static String getFirstLabel(final LabelOrBuilder label) throws NotAvailableException { for (Label.MapFieldEntry entry : label.getEntryList()) { for (String value : entry.getValueList()) { return value; } } throw new NotAvailableException("Label"); }
[ "public", "static", "String", "getFirstLabel", "(", "final", "LabelOrBuilder", "label", ")", "throws", "NotAvailableException", "{", "for", "(", "Label", ".", "MapFieldEntry", "entry", ":", "label", ".", "getEntryList", "(", ")", ")", "{", "for", "(", "String", "value", ":", "entry", ".", "getValueList", "(", ")", ")", "{", "return", "value", ";", "}", "}", "throw", "new", "NotAvailableException", "(", "\"Label\"", ")", ";", "}" ]
Get the first label found in the label type. This is independent of the language of the label. @param label the label type which is searched for the first label @return the first label found @throws NotAvailableException if now label is contained in the label type.
[ "Get", "the", "first", "label", "found", "in", "the", "label", "type", ".", "This", "is", "independent", "of", "the", "language", "of", "the", "label", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/extension/type/processing/src/main/java/org/openbase/jul/extension/type/processing/LabelProcessor.java#L194-L201
149,172
openbase/jul
extension/type/processing/src/main/java/org/openbase/jul/extension/type/processing/LabelProcessor.java
LabelProcessor.getLabelListByLanguage
public static List<String> getLabelListByLanguage(final String languageCode, final LabelOrBuilder label) throws NotAvailableException { for (Label.MapFieldEntry entry : label.getEntryList()) { if (entry.getKey().equalsIgnoreCase(languageCode)) { return entry.getValueList(); } } throw new NotAvailableException("LabelList of Language[" + languageCode + "] in labelType[" + label + "]"); }
java
public static List<String> getLabelListByLanguage(final String languageCode, final LabelOrBuilder label) throws NotAvailableException { for (Label.MapFieldEntry entry : label.getEntryList()) { if (entry.getKey().equalsIgnoreCase(languageCode)) { return entry.getValueList(); } } throw new NotAvailableException("LabelList of Language[" + languageCode + "] in labelType[" + label + "]"); }
[ "public", "static", "List", "<", "String", ">", "getLabelListByLanguage", "(", "final", "String", "languageCode", ",", "final", "LabelOrBuilder", "label", ")", "throws", "NotAvailableException", "{", "for", "(", "Label", ".", "MapFieldEntry", "entry", ":", "label", ".", "getEntryList", "(", ")", ")", "{", "if", "(", "entry", ".", "getKey", "(", ")", ".", "equalsIgnoreCase", "(", "languageCode", ")", ")", "{", "return", "entry", ".", "getValueList", "(", ")", ";", "}", "}", "throw", "new", "NotAvailableException", "(", "\"LabelList of Language[\"", "+", "languageCode", "+", "\"] in labelType[\"", "+", "label", "+", "\"]\"", ")", ";", "}" ]
Get a list of all labels for a languageCode in a label type. This is done by iterating over all entries in the label type and checking if the key matches the languageCode. If it matches the value list is returned. Thus the returned list can be empty depending on the label. @param languageCode the languageCode which is checked @param label the label type that is searched for a label list @return a list of all labels for the languageCode in the language type @throws NotAvailableException if no entry for the languageCode exist in the label type
[ "Get", "a", "list", "of", "all", "labels", "for", "a", "languageCode", "in", "a", "label", "type", ".", "This", "is", "done", "by", "iterating", "over", "all", "entries", "in", "the", "label", "type", "and", "checking", "if", "the", "key", "matches", "the", "languageCode", ".", "If", "it", "matches", "the", "value", "list", "is", "returned", ".", "Thus", "the", "returned", "list", "can", "be", "empty", "depending", "on", "the", "label", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/extension/type/processing/src/main/java/org/openbase/jul/extension/type/processing/LabelProcessor.java#L327-L334
149,173
openbase/jul
extension/type/processing/src/main/java/org/openbase/jul/extension/type/processing/LabelProcessor.java
LabelProcessor.replace
public static Label.Builder replace(final Label.Builder label, final String oldLabel, final String newLabel) { for (final MapFieldEntry.Builder entryBuilder : label.getEntryBuilderList()) { final List<String> valueList = new ArrayList<>(entryBuilder.getValueList()); entryBuilder.clearValue(); for (String value : valueList) { if (StringProcessor.removeWhiteSpaces(value).equalsIgnoreCase(StringProcessor.removeWhiteSpaces(oldLabel))) { entryBuilder.addValue(newLabel); } else { entryBuilder.addValue(value); } } } return label; }
java
public static Label.Builder replace(final Label.Builder label, final String oldLabel, final String newLabel) { for (final MapFieldEntry.Builder entryBuilder : label.getEntryBuilderList()) { final List<String> valueList = new ArrayList<>(entryBuilder.getValueList()); entryBuilder.clearValue(); for (String value : valueList) { if (StringProcessor.removeWhiteSpaces(value).equalsIgnoreCase(StringProcessor.removeWhiteSpaces(oldLabel))) { entryBuilder.addValue(newLabel); } else { entryBuilder.addValue(value); } } } return label; }
[ "public", "static", "Label", ".", "Builder", "replace", "(", "final", "Label", ".", "Builder", "label", ",", "final", "String", "oldLabel", ",", "final", "String", "newLabel", ")", "{", "for", "(", "final", "MapFieldEntry", ".", "Builder", "entryBuilder", ":", "label", ".", "getEntryBuilderList", "(", ")", ")", "{", "final", "List", "<", "String", ">", "valueList", "=", "new", "ArrayList", "<>", "(", "entryBuilder", ".", "getValueList", "(", ")", ")", ";", "entryBuilder", ".", "clearValue", "(", ")", ";", "for", "(", "String", "value", ":", "valueList", ")", "{", "if", "(", "StringProcessor", ".", "removeWhiteSpaces", "(", "value", ")", ".", "equalsIgnoreCase", "(", "StringProcessor", ".", "removeWhiteSpaces", "(", "oldLabel", ")", ")", ")", "{", "entryBuilder", ".", "addValue", "(", "newLabel", ")", ";", "}", "else", "{", "entryBuilder", ".", "addValue", "(", "value", ")", ";", "}", "}", "}", "return", "label", ";", "}" ]
Replace all instances of a label string in a label builder. The check for the label string which should be replaced is done ignoring the case. @param label the label builder in which label string will be replaced @param oldLabel the label string which is replaced @param newLabel the label string replacement @return the updated label builder
[ "Replace", "all", "instances", "of", "a", "label", "string", "in", "a", "label", "builder", ".", "The", "check", "for", "the", "label", "string", "which", "should", "be", "replaced", "is", "done", "ignoring", "the", "case", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/extension/type/processing/src/main/java/org/openbase/jul/extension/type/processing/LabelProcessor.java#L346-L359
149,174
openbase/jul
extension/type/processing/src/main/java/org/openbase/jul/extension/type/processing/LabelProcessor.java
LabelProcessor.format
public static Label.Builder format(final Label.Builder label) { for (final MapFieldEntry.Builder entryBuilder : label.getEntryBuilderList()) { final List<String> valueList = new ArrayList<>(entryBuilder.getValueList()); entryBuilder.clearValue(); for (String value : valueList) { entryBuilder.addValue(format(value)); } } return label; }
java
public static Label.Builder format(final Label.Builder label) { for (final MapFieldEntry.Builder entryBuilder : label.getEntryBuilderList()) { final List<String> valueList = new ArrayList<>(entryBuilder.getValueList()); entryBuilder.clearValue(); for (String value : valueList) { entryBuilder.addValue(format(value)); } } return label; }
[ "public", "static", "Label", ".", "Builder", "format", "(", "final", "Label", ".", "Builder", "label", ")", "{", "for", "(", "final", "MapFieldEntry", ".", "Builder", "entryBuilder", ":", "label", ".", "getEntryBuilderList", "(", ")", ")", "{", "final", "List", "<", "String", ">", "valueList", "=", "new", "ArrayList", "<>", "(", "entryBuilder", ".", "getValueList", "(", ")", ")", ";", "entryBuilder", ".", "clearValue", "(", ")", ";", "for", "(", "String", "value", ":", "valueList", ")", "{", "entryBuilder", ".", "addValue", "(", "format", "(", "value", ")", ")", ";", "}", "}", "return", "label", ";", "}" ]
Format the given label by removing duplicated white spaces, underscores and camel cases in all entries. @param label the label to format. @return the formatted label.
[ "Format", "the", "given", "label", "by", "removing", "duplicated", "white", "spaces", "underscores", "and", "camel", "cases", "in", "all", "entries", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/extension/type/processing/src/main/java/org/openbase/jul/extension/type/processing/LabelProcessor.java#L368-L377
149,175
openbase/jul
extension/type/processing/src/main/java/org/openbase/jul/extension/type/processing/LabelProcessor.java
LabelProcessor.format
public static String format(String label) { if (label.isEmpty()) { return label; } if(Character.isDigit(label.charAt(label.length()-1))) { for (int i = label.length(); i > 0; i--) { if(!Character.isDigit(label.charAt(i-1))) { if(!Character.isLowerCase(label.charAt(i-1))) { break; } label = label.substring(0, i) + " " + label.substring(i); break; } } } return StringProcessor.formatHumanReadable(label); }
java
public static String format(String label) { if (label.isEmpty()) { return label; } if(Character.isDigit(label.charAt(label.length()-1))) { for (int i = label.length(); i > 0; i--) { if(!Character.isDigit(label.charAt(i-1))) { if(!Character.isLowerCase(label.charAt(i-1))) { break; } label = label.substring(0, i) + " " + label.substring(i); break; } } } return StringProcessor.formatHumanReadable(label); }
[ "public", "static", "String", "format", "(", "String", "label", ")", "{", "if", "(", "label", ".", "isEmpty", "(", ")", ")", "{", "return", "label", ";", "}", "if", "(", "Character", ".", "isDigit", "(", "label", ".", "charAt", "(", "label", ".", "length", "(", ")", "-", "1", ")", ")", ")", "{", "for", "(", "int", "i", "=", "label", ".", "length", "(", ")", ";", "i", ">", "0", ";", "i", "--", ")", "{", "if", "(", "!", "Character", ".", "isDigit", "(", "label", ".", "charAt", "(", "i", "-", "1", ")", ")", ")", "{", "if", "(", "!", "Character", ".", "isLowerCase", "(", "label", ".", "charAt", "(", "i", "-", "1", ")", ")", ")", "{", "break", ";", "}", "label", "=", "label", ".", "substring", "(", "0", ",", "i", ")", "+", "\" \"", "+", "label", ".", "substring", "(", "i", ")", ";", "break", ";", "}", "}", "}", "return", "StringProcessor", ".", "formatHumanReadable", "(", "label", ")", ";", "}" ]
Format the given label by removing duplicated white spaces, underscores and camel cases. @param label the label to format. @return the formatted label.
[ "Format", "the", "given", "label", "by", "removing", "duplicated", "white", "spaces", "underscores", "and", "camel", "cases", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/extension/type/processing/src/main/java/org/openbase/jul/extension/type/processing/LabelProcessor.java#L386-L402
149,176
eurekaclinical/protempa
protempa-dsb-file/src/main/java/org/protempa/backend/dsb/file/CloseableIteratorChain.java
CloseableIteratorChain.addIterator
void addIterator(final DataStreamingEventIterator<E> iterator) { checkLocked(); if (iterator == null) { throw new NullPointerException("Iterator must not be null"); } iteratorChain.add(iterator); }
java
void addIterator(final DataStreamingEventIterator<E> iterator) { checkLocked(); if (iterator == null) { throw new NullPointerException("Iterator must not be null"); } iteratorChain.add(iterator); }
[ "void", "addIterator", "(", "final", "DataStreamingEventIterator", "<", "E", ">", "iterator", ")", "{", "checkLocked", "(", ")", ";", "if", "(", "iterator", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"Iterator must not be null\"", ")", ";", "}", "iteratorChain", ".", "add", "(", "iterator", ")", ";", "}" ]
Add an Iterator to the end of the chain @param iterator Iterator to add @throws IllegalStateException if I've already started iterating @throws NullPointerException if the iterator is null
[ "Add", "an", "Iterator", "to", "the", "end", "of", "the", "chain" ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-dsb-file/src/main/java/org/protempa/backend/dsb/file/CloseableIteratorChain.java#L142-L148
149,177
eurekaclinical/protempa
protempa-dsb-file/src/main/java/org/protempa/backend/dsb/file/CloseableIteratorChain.java
CloseableIteratorChain.updateCurrentIterator
protected void updateCurrentIterator() throws DataSourceReadException { if (currentIterator == null) { if (iteratorChain.isEmpty()) { currentIterator = new EmptyDataStreamingEventIterator(); } else { currentIterator = iteratorChain.remove(); } // set last used iterator here, in case the user calls remove // before calling hasNext() or next() (although they shouldn't) lastUsedIterator = currentIterator; } while (currentIterator.hasNext() == false && !iteratorChain.isEmpty()) { currentIterator.close(); currentIterator = iteratorChain.remove(); } }
java
protected void updateCurrentIterator() throws DataSourceReadException { if (currentIterator == null) { if (iteratorChain.isEmpty()) { currentIterator = new EmptyDataStreamingEventIterator(); } else { currentIterator = iteratorChain.remove(); } // set last used iterator here, in case the user calls remove // before calling hasNext() or next() (although they shouldn't) lastUsedIterator = currentIterator; } while (currentIterator.hasNext() == false && !iteratorChain.isEmpty()) { currentIterator.close(); currentIterator = iteratorChain.remove(); } }
[ "protected", "void", "updateCurrentIterator", "(", ")", "throws", "DataSourceReadException", "{", "if", "(", "currentIterator", "==", "null", ")", "{", "if", "(", "iteratorChain", ".", "isEmpty", "(", ")", ")", "{", "currentIterator", "=", "new", "EmptyDataStreamingEventIterator", "(", ")", ";", "}", "else", "{", "currentIterator", "=", "iteratorChain", ".", "remove", "(", ")", ";", "}", "// set last used iterator here, in case the user calls remove", "// before calling hasNext() or next() (although they shouldn't)", "lastUsedIterator", "=", "currentIterator", ";", "}", "while", "(", "currentIterator", ".", "hasNext", "(", ")", "==", "false", "&&", "!", "iteratorChain", ".", "isEmpty", "(", ")", ")", "{", "currentIterator", ".", "close", "(", ")", ";", "currentIterator", "=", "iteratorChain", ".", "remove", "(", ")", ";", "}", "}" ]
Updates the current iterator field to ensure that the current Iterator is not exhausted
[ "Updates", "the", "current", "iterator", "field", "to", "ensure", "that", "the", "current", "Iterator", "is", "not", "exhausted" ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-dsb-file/src/main/java/org/protempa/backend/dsb/file/CloseableIteratorChain.java#L194-L210
149,178
eurekaclinical/protempa
protempa-dsb-file/src/main/java/org/protempa/backend/dsb/file/CloseableIteratorChain.java
CloseableIteratorChain.next
@Override public DataStreamingEvent<E> next() throws DataSourceReadException { lockChain(); updateCurrentIterator(); lastUsedIterator = currentIterator; return currentIterator.next(); }
java
@Override public DataStreamingEvent<E> next() throws DataSourceReadException { lockChain(); updateCurrentIterator(); lastUsedIterator = currentIterator; return currentIterator.next(); }
[ "@", "Override", "public", "DataStreamingEvent", "<", "E", ">", "next", "(", ")", "throws", "DataSourceReadException", "{", "lockChain", "(", ")", ";", "updateCurrentIterator", "(", ")", ";", "lastUsedIterator", "=", "currentIterator", ";", "return", "currentIterator", ".", "next", "(", ")", ";", "}" ]
Returns the next Object of the current Iterator @return Object from the current Iterator @throws java.util.NoSuchElementException if all the Iterators are exhausted
[ "Returns", "the", "next", "Object", "of", "the", "current", "Iterator" ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-dsb-file/src/main/java/org/protempa/backend/dsb/file/CloseableIteratorChain.java#L234-L240
149,179
znerd/xmlenc
src/main/java/org/znerd/xmlenc/XMLEncoder.java
XMLEncoder.declaration
public void declaration(Writer out, char quotationMark) throws IllegalArgumentException, NullPointerException, IOException { if (quotationMark == '"') { out.write(_declarationDoubleQuotes); } else if (quotationMark == '\'') { out.write(_declarationSingleQuotes); } }
java
public void declaration(Writer out, char quotationMark) throws IllegalArgumentException, NullPointerException, IOException { if (quotationMark == '"') { out.write(_declarationDoubleQuotes); } else if (quotationMark == '\'') { out.write(_declarationSingleQuotes); } }
[ "public", "void", "declaration", "(", "Writer", "out", ",", "char", "quotationMark", ")", "throws", "IllegalArgumentException", ",", "NullPointerException", ",", "IOException", "{", "if", "(", "quotationMark", "==", "'", "'", ")", "{", "out", ".", "write", "(", "_declarationDoubleQuotes", ")", ";", "}", "else", "if", "(", "quotationMark", "==", "'", "'", ")", "{", "out", ".", "write", "(", "_declarationSingleQuotes", ")", ";", "}", "}" ]
Writes an XML declaration with double quotes. @param out the character stream to write to, not <code>null</code>. @param quotationMark the quotationMark to use, either <code>'\''</code> or <code>'"'</code>. @throws IllegalArgumentException if <code>quotationMark != '\'' &amp;&amp; quotationMark != '"'</code> @throws NullPointerException if <code>out == null</code>. @throws IOException if an I/O error occurs. @since XMLenc 0.54
[ "Writes", "an", "XML", "declaration", "with", "double", "quotes", "." ]
6ff483777d9467db9990b7c7ae0158f21a243c31
https://github.com/znerd/xmlenc/blob/6ff483777d9467db9990b7c7ae0158f21a243c31/src/main/java/org/znerd/xmlenc/XMLEncoder.java#L167-L173
149,180
znerd/xmlenc
src/main/java/org/znerd/xmlenc/XMLEncoder.java
XMLEncoder.whitespace
public void whitespace(Writer out, String s) throws NullPointerException, InvalidXMLException, IOException { char[] ch = s.toCharArray(); int length = ch.length; whitespace(out, ch, 0, length); }
java
public void whitespace(Writer out, String s) throws NullPointerException, InvalidXMLException, IOException { char[] ch = s.toCharArray(); int length = ch.length; whitespace(out, ch, 0, length); }
[ "public", "void", "whitespace", "(", "Writer", "out", ",", "String", "s", ")", "throws", "NullPointerException", ",", "InvalidXMLException", ",", "IOException", "{", "char", "[", "]", "ch", "=", "s", ".", "toCharArray", "(", ")", ";", "int", "length", "=", "ch", ".", "length", ";", "whitespace", "(", "out", ",", "ch", ",", "0", ",", "length", ")", ";", "}" ]
Writes the specified whitespace string. @param out the character stream to write to, not <code>null</code>. @param s the character string to be written, not <code>null</code>. @throws NullPointerException if <code>out == null || s == null</code>. @throws InvalidXMLException if the specified character string contains a character that is invalid as whitespace. @throws IOException if an I/O error occurs.
[ "Writes", "the", "specified", "whitespace", "string", "." ]
6ff483777d9467db9990b7c7ae0158f21a243c31
https://github.com/znerd/xmlenc/blob/6ff483777d9467db9990b7c7ae0158f21a243c31/src/main/java/org/znerd/xmlenc/XMLEncoder.java#L325-L330
149,181
znerd/xmlenc
src/main/java/org/znerd/xmlenc/XMLEncoder.java
XMLEncoder.whitespace
public void whitespace(Writer out, char[] ch, int start, int length) throws NullPointerException, IndexOutOfBoundsException, InvalidXMLException, IOException { // Check the string XMLChecker.checkS(ch, start, length); // Write the complete character string at once out.write(ch, start, length); }
java
public void whitespace(Writer out, char[] ch, int start, int length) throws NullPointerException, IndexOutOfBoundsException, InvalidXMLException, IOException { // Check the string XMLChecker.checkS(ch, start, length); // Write the complete character string at once out.write(ch, start, length); }
[ "public", "void", "whitespace", "(", "Writer", "out", ",", "char", "[", "]", "ch", ",", "int", "start", ",", "int", "length", ")", "throws", "NullPointerException", ",", "IndexOutOfBoundsException", ",", "InvalidXMLException", ",", "IOException", "{", "// Check the string", "XMLChecker", ".", "checkS", "(", "ch", ",", "start", ",", "length", ")", ";", "// Write the complete character string at once", "out", ".", "write", "(", "ch", ",", "start", ",", "length", ")", ";", "}" ]
Writes whitespace from the specified character array. @param out the character stream to write to, not <code>null</code>. @param ch the character array from which to retrieve the text to be written, not <code>null</code>. @param start the start index into <code>ch</code>, must be &gt;= 0. @param length the number of characters to take from <code>ch</code>, starting at the <code>start</code> index. @throws NullPointerException if <code>out == null || ch == null</code>. @throws IndexOutOfBoundsException if <code>start &lt; 0 || start + length &gt; ch.length</code>; this may not be checked before the character stream is written to, so this may cause a <em>partial</em> failure. @throws InvalidXMLException if the specified character array contains a character that is invalid as whitespace. @throws IOException if an I/O error occurs.
[ "Writes", "whitespace", "from", "the", "specified", "character", "array", "." ]
6ff483777d9467db9990b7c7ae0158f21a243c31
https://github.com/znerd/xmlenc/blob/6ff483777d9467db9990b7c7ae0158f21a243c31/src/main/java/org/znerd/xmlenc/XMLEncoder.java#L350-L357
149,182
znerd/xmlenc
src/main/java/org/znerd/xmlenc/XMLEncoder.java
XMLEncoder.attribute
public void attribute(Writer out, String name, String value, char quotationMark, boolean escapeAmpersands) throws NullPointerException, IOException { char[] ch = value.toCharArray(); int length = ch.length; int start = 0; int end = start + length; // TODO: Call overloaded attribute method that accepts char[] // The position after the last escaped character int lastEscaped = 0; boolean useQuote; if (quotationMark == '"') { useQuote = true; } else if (quotationMark == '\'') { useQuote = false; } else { String error = "Character 0x" + Integer.toHexString(quotationMark) + " ('" + quotationMark + "') is not a valid quotation mark."; throw new IllegalArgumentException(error); } out.write(' '); out.write(name); if (useQuote) { out.write(EQUALS_QUOTE, 0, 2); } else { out.write(EQUALS_APOSTROPHE, 0, 2); } for (int i = start; i < end; i++) { int c = ch[i]; if (c >= 63 && c <= 127 || c >= 40 && c <= 59 || c >= 32 && c <= 37 && c != 34 || c == 38 && !escapeAmpersands || c > 127 && !_sevenBitEncoding || !useQuote && c == 34 || useQuote && c == 39 || c == 10 || c == 13 || c == 61 || c == 9) { continue; } else { out.write(ch, lastEscaped, i - lastEscaped); if (c == 60) { out.write(ESC_LESS_THAN, 0, 4); } else if (c == 62) { out.write(ESC_GREATER_THAN, 0, 4); } else if (c == 34) { out.write(ESC_QUOTE, 0, 6); } else if (c == 39) { out.write(ESC_APOSTROPHE, 0, 6); } else if (c == 38) { out.write(ESC_AMPERSAND, 0, 5); } else if (c > 127) { out.write(AMPERSAND_HASH, 0, 2); out.write(Integer.toString(c)); out.write(';'); } else { throw new InvalidXMLException("The character 0x" + Integer.toHexString(c) + " is not valid."); } lastEscaped = i + 1; } } out.write(ch, lastEscaped, length - lastEscaped); out.write(quotationMark); }
java
public void attribute(Writer out, String name, String value, char quotationMark, boolean escapeAmpersands) throws NullPointerException, IOException { char[] ch = value.toCharArray(); int length = ch.length; int start = 0; int end = start + length; // TODO: Call overloaded attribute method that accepts char[] // The position after the last escaped character int lastEscaped = 0; boolean useQuote; if (quotationMark == '"') { useQuote = true; } else if (quotationMark == '\'') { useQuote = false; } else { String error = "Character 0x" + Integer.toHexString(quotationMark) + " ('" + quotationMark + "') is not a valid quotation mark."; throw new IllegalArgumentException(error); } out.write(' '); out.write(name); if (useQuote) { out.write(EQUALS_QUOTE, 0, 2); } else { out.write(EQUALS_APOSTROPHE, 0, 2); } for (int i = start; i < end; i++) { int c = ch[i]; if (c >= 63 && c <= 127 || c >= 40 && c <= 59 || c >= 32 && c <= 37 && c != 34 || c == 38 && !escapeAmpersands || c > 127 && !_sevenBitEncoding || !useQuote && c == 34 || useQuote && c == 39 || c == 10 || c == 13 || c == 61 || c == 9) { continue; } else { out.write(ch, lastEscaped, i - lastEscaped); if (c == 60) { out.write(ESC_LESS_THAN, 0, 4); } else if (c == 62) { out.write(ESC_GREATER_THAN, 0, 4); } else if (c == 34) { out.write(ESC_QUOTE, 0, 6); } else if (c == 39) { out.write(ESC_APOSTROPHE, 0, 6); } else if (c == 38) { out.write(ESC_AMPERSAND, 0, 5); } else if (c > 127) { out.write(AMPERSAND_HASH, 0, 2); out.write(Integer.toString(c)); out.write(';'); } else { throw new InvalidXMLException("The character 0x" + Integer.toHexString(c) + " is not valid."); } lastEscaped = i + 1; } } out.write(ch, lastEscaped, length - lastEscaped); out.write(quotationMark); }
[ "public", "void", "attribute", "(", "Writer", "out", ",", "String", "name", ",", "String", "value", ",", "char", "quotationMark", ",", "boolean", "escapeAmpersands", ")", "throws", "NullPointerException", ",", "IOException", "{", "char", "[", "]", "ch", "=", "value", ".", "toCharArray", "(", ")", ";", "int", "length", "=", "ch", ".", "length", ";", "int", "start", "=", "0", ";", "int", "end", "=", "start", "+", "length", ";", "// TODO: Call overloaded attribute method that accepts char[]", "// The position after the last escaped character", "int", "lastEscaped", "=", "0", ";", "boolean", "useQuote", ";", "if", "(", "quotationMark", "==", "'", "'", ")", "{", "useQuote", "=", "true", ";", "}", "else", "if", "(", "quotationMark", "==", "'", "'", ")", "{", "useQuote", "=", "false", ";", "}", "else", "{", "String", "error", "=", "\"Character 0x\"", "+", "Integer", ".", "toHexString", "(", "quotationMark", ")", "+", "\" ('\"", "+", "quotationMark", "+", "\"') is not a valid quotation mark.\"", ";", "throw", "new", "IllegalArgumentException", "(", "error", ")", ";", "}", "out", ".", "write", "(", "'", "'", ")", ";", "out", ".", "write", "(", "name", ")", ";", "if", "(", "useQuote", ")", "{", "out", ".", "write", "(", "EQUALS_QUOTE", ",", "0", ",", "2", ")", ";", "}", "else", "{", "out", ".", "write", "(", "EQUALS_APOSTROPHE", ",", "0", ",", "2", ")", ";", "}", "for", "(", "int", "i", "=", "start", ";", "i", "<", "end", ";", "i", "++", ")", "{", "int", "c", "=", "ch", "[", "i", "]", ";", "if", "(", "c", ">=", "63", "&&", "c", "<=", "127", "||", "c", ">=", "40", "&&", "c", "<=", "59", "||", "c", ">=", "32", "&&", "c", "<=", "37", "&&", "c", "!=", "34", "||", "c", "==", "38", "&&", "!", "escapeAmpersands", "||", "c", ">", "127", "&&", "!", "_sevenBitEncoding", "||", "!", "useQuote", "&&", "c", "==", "34", "||", "useQuote", "&&", "c", "==", "39", "||", "c", "==", "10", "||", "c", "==", "13", "||", "c", "==", "61", "||", "c", "==", "9", ")", "{", "continue", ";", "}", "else", "{", "out", ".", "write", "(", "ch", ",", "lastEscaped", ",", "i", "-", "lastEscaped", ")", ";", "if", "(", "c", "==", "60", ")", "{", "out", ".", "write", "(", "ESC_LESS_THAN", ",", "0", ",", "4", ")", ";", "}", "else", "if", "(", "c", "==", "62", ")", "{", "out", ".", "write", "(", "ESC_GREATER_THAN", ",", "0", ",", "4", ")", ";", "}", "else", "if", "(", "c", "==", "34", ")", "{", "out", ".", "write", "(", "ESC_QUOTE", ",", "0", ",", "6", ")", ";", "}", "else", "if", "(", "c", "==", "39", ")", "{", "out", ".", "write", "(", "ESC_APOSTROPHE", ",", "0", ",", "6", ")", ";", "}", "else", "if", "(", "c", "==", "38", ")", "{", "out", ".", "write", "(", "ESC_AMPERSAND", ",", "0", ",", "5", ")", ";", "}", "else", "if", "(", "c", ">", "127", ")", "{", "out", ".", "write", "(", "AMPERSAND_HASH", ",", "0", ",", "2", ")", ";", "out", ".", "write", "(", "Integer", ".", "toString", "(", "c", ")", ")", ";", "out", ".", "write", "(", "'", "'", ")", ";", "}", "else", "{", "throw", "new", "InvalidXMLException", "(", "\"The character 0x\"", "+", "Integer", ".", "toHexString", "(", "c", ")", "+", "\" is not valid.\"", ")", ";", "}", "lastEscaped", "=", "i", "+", "1", ";", "}", "}", "out", ".", "write", "(", "ch", ",", "lastEscaped", ",", "length", "-", "lastEscaped", ")", ";", "out", ".", "write", "(", "quotationMark", ")", ";", "}" ]
Writes an attribute assignment. @param out the character stream to write to, not <code>null</code>. @param name the name of the attribute, not <code>null</code>. @param value the value of the attribute, not <code>null</code>. @param quotationMark the quotation mark, must be either the apostrophe (<code>'\''</code>) or the quote character (<code>'"'</code>). @throws NullPointerException if <code>out == null || value == null</code>. @throws IllegalArgumentException if <code>quotationMark != '\'' &amp;&amp; quotationMark != '"'</code>. @throws IOException if an I/O error occurs.
[ "Writes", "an", "attribute", "assignment", "." ]
6ff483777d9467db9990b7c7ae0158f21a243c31
https://github.com/znerd/xmlenc/blob/6ff483777d9467db9990b7c7ae0158f21a243c31/src/main/java/org/znerd/xmlenc/XMLEncoder.java#L371-L432
149,183
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/HighLevelAbstractionDefinition.java
HighLevelAbstractionDefinition.setRelation
public boolean setRelation(TemporalExtendedPropositionDefinition lhsDef, TemporalExtendedPropositionDefinition rhsDef, Relation relation) { if (lhsDef == null || rhsDef == null || relation == null) { return false; } if (!defs.contains(lhsDef) || !defs.contains(rhsDef)) { return false; } List<TemporalExtendedPropositionDefinition> rulePair = Arrays.asList( lhsDef, rhsDef); defPairsMap.put(rulePair, relation); return true; }
java
public boolean setRelation(TemporalExtendedPropositionDefinition lhsDef, TemporalExtendedPropositionDefinition rhsDef, Relation relation) { if (lhsDef == null || rhsDef == null || relation == null) { return false; } if (!defs.contains(lhsDef) || !defs.contains(rhsDef)) { return false; } List<TemporalExtendedPropositionDefinition> rulePair = Arrays.asList( lhsDef, rhsDef); defPairsMap.put(rulePair, relation); return true; }
[ "public", "boolean", "setRelation", "(", "TemporalExtendedPropositionDefinition", "lhsDef", ",", "TemporalExtendedPropositionDefinition", "rhsDef", ",", "Relation", "relation", ")", "{", "if", "(", "lhsDef", "==", "null", "||", "rhsDef", "==", "null", "||", "relation", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(", "!", "defs", ".", "contains", "(", "lhsDef", ")", "||", "!", "defs", ".", "contains", "(", "rhsDef", ")", ")", "{", "return", "false", ";", "}", "List", "<", "TemporalExtendedPropositionDefinition", ">", "rulePair", "=", "Arrays", ".", "asList", "(", "lhsDef", ",", "rhsDef", ")", ";", "defPairsMap", ".", "put", "(", "rulePair", ",", "relation", ")", ";", "return", "true", ";", "}" ]
Sets the relation between the two temporal extended proposition definitions. @param lhsDef a {@link TemporalExtendedPropositionDefinition}. @param rhsDef a {@link TemporalExtendedPropositionDefinition}. @param relation a {@link Relation}. @return <code>true</code> if setting the relation was successful, <code>false</code> otherwise (e.g., if one or both of the temporal extended proposition definitions is not already part of this abstraction definition, or if any of the arguments are <code>null</code>).
[ "Sets", "the", "relation", "between", "the", "two", "temporal", "extended", "proposition", "definitions", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/HighLevelAbstractionDefinition.java#L101-L116
149,184
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/HighLevelAbstractionDefinition.java
HighLevelAbstractionDefinition.removeRelation
public boolean removeRelation( TemporalExtendedPropositionDefinition lhsRule, TemporalExtendedPropositionDefinition rhsRule) { List<TemporalExtendedPropositionDefinition> key = Arrays.asList( lhsRule, rhsRule); if (defPairsMap.remove(key) != null) { return true; } else { return false; } }
java
public boolean removeRelation( TemporalExtendedPropositionDefinition lhsRule, TemporalExtendedPropositionDefinition rhsRule) { List<TemporalExtendedPropositionDefinition> key = Arrays.asList( lhsRule, rhsRule); if (defPairsMap.remove(key) != null) { return true; } else { return false; } }
[ "public", "boolean", "removeRelation", "(", "TemporalExtendedPropositionDefinition", "lhsRule", ",", "TemporalExtendedPropositionDefinition", "rhsRule", ")", "{", "List", "<", "TemporalExtendedPropositionDefinition", ">", "key", "=", "Arrays", ".", "asList", "(", "lhsRule", ",", "rhsRule", ")", ";", "if", "(", "defPairsMap", ".", "remove", "(", "key", ")", "!=", "null", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Removes a relation between two temporal extended proposition definitions. @param lhsRule a {@link TemporalExtendedPropositionDefinition}. @param rhsRule a {@link TemporalExtendedPropositionDefinition}. @return <code>true</code> if removing the relation was successful, <code>false</code> otherwise (e.g., if either argument is <code>null</code>, the arguments are not part of this abstraction definition, or if no relation was set for them).
[ "Removes", "a", "relation", "between", "two", "temporal", "extended", "proposition", "definitions", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/HighLevelAbstractionDefinition.java#L130-L140
149,185
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/HighLevelAbstractionDefinition.java
HighLevelAbstractionDefinition.add
public boolean add(ExtendedPropositionDefinition def) { if (def != null && this.defs.add(def)) { this.defsAsListOutdated = true; recalculateChildren(); return true; } else { return false; } }
java
public boolean add(ExtendedPropositionDefinition def) { if (def != null && this.defs.add(def)) { this.defsAsListOutdated = true; recalculateChildren(); return true; } else { return false; } }
[ "public", "boolean", "add", "(", "ExtendedPropositionDefinition", "def", ")", "{", "if", "(", "def", "!=", "null", "&&", "this", ".", "defs", ".", "add", "(", "def", ")", ")", "{", "this", ".", "defsAsListOutdated", "=", "true", ";", "recalculateChildren", "(", ")", ";", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Adds an extended proposition definition. @param def an {@link ExtendedPropositionDefinition}. @return <code>true</code> if successfully added, <code>false</code> otherwise (e.g., the {@link ExtendedPropositionDefinition} is <code>null</code> or is already part of this abstraction definition.
[ "Adds", "an", "extended", "proposition", "definition", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/HighLevelAbstractionDefinition.java#L174-L182
149,186
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/HighLevelAbstractionDefinition.java
HighLevelAbstractionDefinition.getRelation
public Relation getRelation(TemporalExtendedPropositionDefinition lhsDef, TemporalExtendedPropositionDefinition rhsDef) { return this.defPairsMap.get(Arrays.asList(lhsDef, rhsDef)); }
java
public Relation getRelation(TemporalExtendedPropositionDefinition lhsDef, TemporalExtendedPropositionDefinition rhsDef) { return this.defPairsMap.get(Arrays.asList(lhsDef, rhsDef)); }
[ "public", "Relation", "getRelation", "(", "TemporalExtendedPropositionDefinition", "lhsDef", ",", "TemporalExtendedPropositionDefinition", "rhsDef", ")", "{", "return", "this", ".", "defPairsMap", ".", "get", "(", "Arrays", ".", "asList", "(", "lhsDef", ",", "rhsDef", ")", ")", ";", "}" ]
Gets the relation between two temporal extended proposition definitions. @param lhsDef a {@link TemporalExtendedPropositionDefinition}. @param rhsDef a {@link TemporalExtendedPropositionDefinition}. @return a <code>Relation</code>, or <code>null</code> if none was found.
[ "Gets", "the", "relation", "between", "two", "temporal", "extended", "proposition", "definitions", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/HighLevelAbstractionDefinition.java#L194-L197
149,187
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/HighLevelAbstractionDefinition.java
HighLevelAbstractionDefinition.removeAllRelations
public boolean removeAllRelations(TemporalExtendedPropositionDefinition def) { for (Iterator<List<TemporalExtendedPropositionDefinition>> itr = this.defPairsMap.keySet().iterator(); itr.hasNext();) { List<TemporalExtendedPropositionDefinition> pair = itr.next(); if (pair.get(0) == def || pair.get(1) == def) { itr.remove(); } } return true; }
java
public boolean removeAllRelations(TemporalExtendedPropositionDefinition def) { for (Iterator<List<TemporalExtendedPropositionDefinition>> itr = this.defPairsMap.keySet().iterator(); itr.hasNext();) { List<TemporalExtendedPropositionDefinition> pair = itr.next(); if (pair.get(0) == def || pair.get(1) == def) { itr.remove(); } } return true; }
[ "public", "boolean", "removeAllRelations", "(", "TemporalExtendedPropositionDefinition", "def", ")", "{", "for", "(", "Iterator", "<", "List", "<", "TemporalExtendedPropositionDefinition", ">", ">", "itr", "=", "this", ".", "defPairsMap", ".", "keySet", "(", ")", ".", "iterator", "(", ")", ";", "itr", ".", "hasNext", "(", ")", ";", ")", "{", "List", "<", "TemporalExtendedPropositionDefinition", ">", "pair", "=", "itr", ".", "next", "(", ")", ";", "if", "(", "pair", ".", "get", "(", "0", ")", "==", "def", "||", "pair", ".", "get", "(", "1", ")", "==", "def", ")", "{", "itr", ".", "remove", "(", ")", ";", "}", "}", "return", "true", ";", "}" ]
Removes all relations involving a temporal extended proposition definition. @param def a {@link TemporalExtendedPropositionDefinition}. @return <code>true</code> if all such relations were removed, <code>false</code> otherwise.
[ "Removes", "all", "relations", "involving", "a", "temporal", "extended", "proposition", "definition", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/HighLevelAbstractionDefinition.java#L213-L221
149,188
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/HighLevelAbstractionDefinition.java
HighLevelAbstractionDefinition.remove
public boolean remove(ExtendedPropositionDefinition def) { if (def instanceof TemporalExtendedPropositionDefinition) { if (removeAllRelations((TemporalExtendedPropositionDefinition) def)) { return true; } else { return false; } } boolean result = defs.remove(def); if (result) { recalculateChildren(); this.defsAsListOutdated = true; } return result; }
java
public boolean remove(ExtendedPropositionDefinition def) { if (def instanceof TemporalExtendedPropositionDefinition) { if (removeAllRelations((TemporalExtendedPropositionDefinition) def)) { return true; } else { return false; } } boolean result = defs.remove(def); if (result) { recalculateChildren(); this.defsAsListOutdated = true; } return result; }
[ "public", "boolean", "remove", "(", "ExtendedPropositionDefinition", "def", ")", "{", "if", "(", "def", "instanceof", "TemporalExtendedPropositionDefinition", ")", "{", "if", "(", "removeAllRelations", "(", "(", "TemporalExtendedPropositionDefinition", ")", "def", ")", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}", "boolean", "result", "=", "defs", ".", "remove", "(", "def", ")", ";", "if", "(", "result", ")", "{", "recalculateChildren", "(", ")", ";", "this", ".", "defsAsListOutdated", "=", "true", ";", "}", "return", "result", ";", "}" ]
Removes an extended proposition definition, and all relations involving it. @param def an {@link ExtendedPropositionDefinition}. @return <code>true</code> if successful, <code>false</code> otherwise.
[ "Removes", "an", "extended", "proposition", "definition", "and", "all", "relations", "involving", "it", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/HighLevelAbstractionDefinition.java#L232-L246
149,189
weblicht/wlfxb
src/main/java/eu/clarin/weblicht/wlfxb/io/XmlReaderWriter.java
XmlReaderWriter.readWriteElement
public void readWriteElement(String tagName) throws WLFormatException { try { while (xmlEventReader.hasNext()) { XMLEvent event = xmlEventReader.nextEvent(); switch (event.getEventType()) { case XMLStreamConstants.END_ELEMENT: add(event); if (event.asEndElement().getName().getLocalPart().equals(tagName)) { return; } break; default: add(event); break; } } } catch (XMLStreamException e) { throw new WLFormatException(e.getMessage(), e); } catch (NoSuchElementException e) { throw new WLFormatException(e.getMessage(), e); } }
java
public void readWriteElement(String tagName) throws WLFormatException { try { while (xmlEventReader.hasNext()) { XMLEvent event = xmlEventReader.nextEvent(); switch (event.getEventType()) { case XMLStreamConstants.END_ELEMENT: add(event); if (event.asEndElement().getName().getLocalPart().equals(tagName)) { return; } break; default: add(event); break; } } } catch (XMLStreamException e) { throw new WLFormatException(e.getMessage(), e); } catch (NoSuchElementException e) { throw new WLFormatException(e.getMessage(), e); } }
[ "public", "void", "readWriteElement", "(", "String", "tagName", ")", "throws", "WLFormatException", "{", "try", "{", "while", "(", "xmlEventReader", ".", "hasNext", "(", ")", ")", "{", "XMLEvent", "event", "=", "xmlEventReader", ".", "nextEvent", "(", ")", ";", "switch", "(", "event", ".", "getEventType", "(", ")", ")", "{", "case", "XMLStreamConstants", ".", "END_ELEMENT", ":", "add", "(", "event", ")", ";", "if", "(", "event", ".", "asEndElement", "(", ")", ".", "getName", "(", ")", ".", "getLocalPart", "(", ")", ".", "equals", "(", "tagName", ")", ")", "{", "return", ";", "}", "break", ";", "default", ":", "add", "(", "event", ")", ";", "break", ";", "}", "}", "}", "catch", "(", "XMLStreamException", "e", ")", "{", "throw", "new", "WLFormatException", "(", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "catch", "(", "NoSuchElementException", "e", ")", "{", "throw", "new", "WLFormatException", "(", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "}" ]
postcondition read pointer is just after the end of the tag with the local name tagName
[ "postcondition", "read", "pointer", "is", "just", "after", "the", "end", "of", "the", "tag", "with", "the", "local", "name", "tagName" ]
a50f3c31062a3d617ed9018aabcc1180a8ceb464
https://github.com/weblicht/wlfxb/blob/a50f3c31062a3d617ed9018aabcc1180a8ceb464/src/main/java/eu/clarin/weblicht/wlfxb/io/XmlReaderWriter.java#L232-L255
149,190
weblicht/wlfxb
src/main/java/eu/clarin/weblicht/wlfxb/io/XmlReaderWriter.java
XmlReaderWriter.readWriteUpToStartElement
public void readWriteUpToStartElement(String startTag) throws XMLStreamException { boolean startTagIsNext = false; while (xmlEventReader.hasNext() && !startTagIsNext) { XMLEvent peekedEvent = xmlEventReader.peek(); switch (peekedEvent.getEventType()) { case XMLStreamConstants.START_ELEMENT: String elementName = peekedEvent.asStartElement().getName().getLocalPart(); if (elementName.equals(startTag)) { startTagIsNext = true; } else { XMLEvent readEvent = xmlEventReader.nextEvent(); add(readEvent); } break; default: XMLEvent readEvent = xmlEventReader.nextEvent(); add(readEvent); break; } } }
java
public void readWriteUpToStartElement(String startTag) throws XMLStreamException { boolean startTagIsNext = false; while (xmlEventReader.hasNext() && !startTagIsNext) { XMLEvent peekedEvent = xmlEventReader.peek(); switch (peekedEvent.getEventType()) { case XMLStreamConstants.START_ELEMENT: String elementName = peekedEvent.asStartElement().getName().getLocalPart(); if (elementName.equals(startTag)) { startTagIsNext = true; } else { XMLEvent readEvent = xmlEventReader.nextEvent(); add(readEvent); } break; default: XMLEvent readEvent = xmlEventReader.nextEvent(); add(readEvent); break; } } }
[ "public", "void", "readWriteUpToStartElement", "(", "String", "startTag", ")", "throws", "XMLStreamException", "{", "boolean", "startTagIsNext", "=", "false", ";", "while", "(", "xmlEventReader", ".", "hasNext", "(", ")", "&&", "!", "startTagIsNext", ")", "{", "XMLEvent", "peekedEvent", "=", "xmlEventReader", ".", "peek", "(", ")", ";", "switch", "(", "peekedEvent", ".", "getEventType", "(", ")", ")", "{", "case", "XMLStreamConstants", ".", "START_ELEMENT", ":", "String", "elementName", "=", "peekedEvent", ".", "asStartElement", "(", ")", ".", "getName", "(", ")", ".", "getLocalPart", "(", ")", ";", "if", "(", "elementName", ".", "equals", "(", "startTag", ")", ")", "{", "startTagIsNext", "=", "true", ";", "}", "else", "{", "XMLEvent", "readEvent", "=", "xmlEventReader", ".", "nextEvent", "(", ")", ";", "add", "(", "readEvent", ")", ";", "}", "break", ";", "default", ":", "XMLEvent", "readEvent", "=", "xmlEventReader", ".", "nextEvent", "(", ")", ";", "add", "(", "readEvent", ")", ";", "break", ";", "}", "}", "}" ]
postcondition read pointer is just before the start of the tag with the local name startTag
[ "postcondition", "read", "pointer", "is", "just", "before", "the", "start", "of", "the", "tag", "with", "the", "local", "name", "startTag" ]
a50f3c31062a3d617ed9018aabcc1180a8ceb464
https://github.com/weblicht/wlfxb/blob/a50f3c31062a3d617ed9018aabcc1180a8ceb464/src/main/java/eu/clarin/weblicht/wlfxb/io/XmlReaderWriter.java#L259-L279
149,191
openbase/jul
pattern/default/src/main/java/org/openbase/jul/pattern/statemachine/StateRunner.java
StateRunner.init
@Override public void init(final Class<? extends State> stateClass) throws InitializationException { try { currentState = getState(stateClass); change.firePropertyChange(STATE_CHANGE, null, currentState.getClass()); } catch (NotAvailableException ex) { throw new InitializationException(this, ex); } }
java
@Override public void init(final Class<? extends State> stateClass) throws InitializationException { try { currentState = getState(stateClass); change.firePropertyChange(STATE_CHANGE, null, currentState.getClass()); } catch (NotAvailableException ex) { throw new InitializationException(this, ex); } }
[ "@", "Override", "public", "void", "init", "(", "final", "Class", "<", "?", "extends", "State", ">", "stateClass", ")", "throws", "InitializationException", "{", "try", "{", "currentState", "=", "getState", "(", "stateClass", ")", ";", "change", ".", "firePropertyChange", "(", "STATE_CHANGE", ",", "null", ",", "currentState", ".", "getClass", "(", ")", ")", ";", "}", "catch", "(", "NotAvailableException", "ex", ")", "{", "throw", "new", "InitializationException", "(", "this", ",", "ex", ")", ";", "}", "}" ]
Defines the initial state of the state machine. @param stateClass @throws InitializationException
[ "Defines", "the", "initial", "state", "of", "the", "state", "machine", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/pattern/default/src/main/java/org/openbase/jul/pattern/statemachine/StateRunner.java#L72-L80
149,192
openbase/jul
pattern/default/src/main/java/org/openbase/jul/pattern/statemachine/StateRunner.java
StateRunner.run
@Override public synchronized void run() { LOGGER.info("run " + currentState.getClass().getSimpleName() + "..."); if (currentState == null) { throw new IllegalStateException("No initial state defined."); } while (currentState != null) { LOGGER.debug("execute " + currentState); final Class<? extends State> nextStateClass; try { nextStateClass = currentState.call(); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory("Something went wrong during state execution!", ex, LOGGER); if (Thread.currentThread().isInterrupted()) { return; } continue; } catch (Throwable t) { ExceptionPrinter.printHistory("State failed: ", t, LOGGER); change.firePropertyChange(STATE_ERROR, currentState.getClass(), t.getMessage()); return; } change.firePropertyChange(STATE_CHANGE, currentState.getClass(), nextStateClass); if (nextStateClass != null) { LOGGER.info("StateChange: " + currentState.getClass().getSimpleName() + " -> " + nextStateClass.getSimpleName()); try { currentState = getState(nextStateClass); } catch (NotAvailableException ex) { ExceptionPrinter.printHistory("State change failed!", ex, LOGGER); } } } LOGGER.info("finished execution."); }
java
@Override public synchronized void run() { LOGGER.info("run " + currentState.getClass().getSimpleName() + "..."); if (currentState == null) { throw new IllegalStateException("No initial state defined."); } while (currentState != null) { LOGGER.debug("execute " + currentState); final Class<? extends State> nextStateClass; try { nextStateClass = currentState.call(); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory("Something went wrong during state execution!", ex, LOGGER); if (Thread.currentThread().isInterrupted()) { return; } continue; } catch (Throwable t) { ExceptionPrinter.printHistory("State failed: ", t, LOGGER); change.firePropertyChange(STATE_ERROR, currentState.getClass(), t.getMessage()); return; } change.firePropertyChange(STATE_CHANGE, currentState.getClass(), nextStateClass); if (nextStateClass != null) { LOGGER.info("StateChange: " + currentState.getClass().getSimpleName() + " -> " + nextStateClass.getSimpleName()); try { currentState = getState(nextStateClass); } catch (NotAvailableException ex) { ExceptionPrinter.printHistory("State change failed!", ex, LOGGER); } } } LOGGER.info("finished execution."); }
[ "@", "Override", "public", "synchronized", "void", "run", "(", ")", "{", "LOGGER", ".", "info", "(", "\"run \"", "+", "currentState", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", "+", "\"...\"", ")", ";", "if", "(", "currentState", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"No initial state defined.\"", ")", ";", "}", "while", "(", "currentState", "!=", "null", ")", "{", "LOGGER", ".", "debug", "(", "\"execute \"", "+", "currentState", ")", ";", "final", "Class", "<", "?", "extends", "State", ">", "nextStateClass", ";", "try", "{", "nextStateClass", "=", "currentState", ".", "call", "(", ")", ";", "}", "catch", "(", "CouldNotPerformException", "ex", ")", "{", "ExceptionPrinter", ".", "printHistory", "(", "\"Something went wrong during state execution!\"", ",", "ex", ",", "LOGGER", ")", ";", "if", "(", "Thread", ".", "currentThread", "(", ")", ".", "isInterrupted", "(", ")", ")", "{", "return", ";", "}", "continue", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "ExceptionPrinter", ".", "printHistory", "(", "\"State failed: \"", ",", "t", ",", "LOGGER", ")", ";", "change", ".", "firePropertyChange", "(", "STATE_ERROR", ",", "currentState", ".", "getClass", "(", ")", ",", "t", ".", "getMessage", "(", ")", ")", ";", "return", ";", "}", "change", ".", "firePropertyChange", "(", "STATE_CHANGE", ",", "currentState", ".", "getClass", "(", ")", ",", "nextStateClass", ")", ";", "if", "(", "nextStateClass", "!=", "null", ")", "{", "LOGGER", ".", "info", "(", "\"StateChange: \"", "+", "currentState", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", "+", "\" -> \"", "+", "nextStateClass", ".", "getSimpleName", "(", ")", ")", ";", "try", "{", "currentState", "=", "getState", "(", "nextStateClass", ")", ";", "}", "catch", "(", "NotAvailableException", "ex", ")", "{", "ExceptionPrinter", ".", "printHistory", "(", "\"State change failed!\"", ",", "ex", ",", "LOGGER", ")", ";", "}", "}", "}", "LOGGER", ".", "info", "(", "\"finished execution.\"", ")", ";", "}" ]
Method starts the state machine. Because this class is implementing the runnable interface its not recommended to call this method manually. Start the state machine via the global executor service. e.g. GlobalCachedExecutorService.submit(stateMachineInstance)
[ "Method", "starts", "the", "state", "machine", ".", "Because", "this", "class", "is", "implementing", "the", "runnable", "interface", "its", "not", "recommended", "to", "call", "this", "method", "manually", ".", "Start", "the", "state", "machine", "via", "the", "global", "executor", "service", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/pattern/default/src/main/java/org/openbase/jul/pattern/statemachine/StateRunner.java#L89-L124
149,193
openbase/jul
pattern/default/src/main/java/org/openbase/jul/pattern/statemachine/StateRunner.java
StateRunner.getState
private State getState(final Class<? extends State> stateClass) throws NotAvailableException { if (!stateMap.containsKey(stateClass)) { try { final State state; try { state = stateClass.getConstructor().newInstance(); } catch (IllegalAccessException | IllegalArgumentException | InstantiationException | NoSuchMethodException | SecurityException | InvocationTargetException ex) { throw new CouldNotPerformException("Could not create instance of " + stateClass.getName(), ex); } stateMap.put(stateClass, state); return state; } catch (CouldNotPerformException ex) { throw new NotAvailableException(stateClass, ex); } } return stateMap.get(stateClass); }
java
private State getState(final Class<? extends State> stateClass) throws NotAvailableException { if (!stateMap.containsKey(stateClass)) { try { final State state; try { state = stateClass.getConstructor().newInstance(); } catch (IllegalAccessException | IllegalArgumentException | InstantiationException | NoSuchMethodException | SecurityException | InvocationTargetException ex) { throw new CouldNotPerformException("Could not create instance of " + stateClass.getName(), ex); } stateMap.put(stateClass, state); return state; } catch (CouldNotPerformException ex) { throw new NotAvailableException(stateClass, ex); } } return stateMap.get(stateClass); }
[ "private", "State", "getState", "(", "final", "Class", "<", "?", "extends", "State", ">", "stateClass", ")", "throws", "NotAvailableException", "{", "if", "(", "!", "stateMap", ".", "containsKey", "(", "stateClass", ")", ")", "{", "try", "{", "final", "State", "state", ";", "try", "{", "state", "=", "stateClass", ".", "getConstructor", "(", ")", ".", "newInstance", "(", ")", ";", "}", "catch", "(", "IllegalAccessException", "|", "IllegalArgumentException", "|", "InstantiationException", "|", "NoSuchMethodException", "|", "SecurityException", "|", "InvocationTargetException", "ex", ")", "{", "throw", "new", "CouldNotPerformException", "(", "\"Could not create instance of \"", "+", "stateClass", ".", "getName", "(", ")", ",", "ex", ")", ";", "}", "stateMap", ".", "put", "(", "stateClass", ",", "state", ")", ";", "return", "state", ";", "}", "catch", "(", "CouldNotPerformException", "ex", ")", "{", "throw", "new", "NotAvailableException", "(", "stateClass", ",", "ex", ")", ";", "}", "}", "return", "stateMap", ".", "get", "(", "stateClass", ")", ";", "}" ]
Method loads the state referred by the state class. Once the state is loaded it will be cached and next time the state is requested the cached instance will be returned out of performance reasons. @param stateClass the class defining the state to load. @return an new or cached instance of the state.. @throws NotAvailableException is thrown if the state could not be loaded.
[ "Method", "loads", "the", "state", "referred", "by", "the", "state", "class", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/pattern/default/src/main/java/org/openbase/jul/pattern/statemachine/StateRunner.java#L153-L169
149,194
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/proposition/value/InequalityNumberValue.java
InequalityNumberValue.compare
@Override public ValueComparator compare(Value d2) { if (d2 == null) { return ValueComparator.NOT_EQUAL_TO; } switch (d2.getType()) { case NUMBERVALUE: NumberValue otherVal = (NumberValue) d2; int valComp = val.compareTo(otherVal); switch (this.comp) { case EQUAL_TO: return valComp > 0 ? ValueComparator.GREATER_THAN : (valComp < 0 ? ValueComparator.LESS_THAN : ValueComparator.EQUAL_TO); case LESS_THAN: return valComp <= 0 ? ValueComparator.LESS_THAN : ValueComparator.UNKNOWN; default: return valComp >= 0 ? ValueComparator.GREATER_THAN : ValueComparator.UNKNOWN; } case INEQUALITYNUMBERVALUE: InequalityNumberValue other = (InequalityNumberValue) d2; ValueComparator d2Comp = other.comp; int valComp2 = this.val.compareTo(other.val); if (this.comp == d2Comp) { if (this.comp == ValueComparator.EQUAL_TO) { return valComp2 > 0 ? ValueComparator.GREATER_THAN : (valComp2 < 0 ? ValueComparator.LESS_THAN : ValueComparator.EQUAL_TO); } else { return ValueComparator.UNKNOWN; } } else if (this.comp == ValueComparator.GREATER_THAN && d2Comp == ValueComparator.LESS_THAN) { if (valComp2 >= 0) { return ValueComparator.GREATER_THAN; } else { return ValueComparator.UNKNOWN; } } else { if (valComp2 <= 0) { return ValueComparator.LESS_THAN; } else { return ValueComparator.UNKNOWN; } } case VALUELIST: ValueList<?> vl = (ValueList<?>) d2; return vl.contains(this) ? ValueComparator.IN : ValueComparator.NOT_IN; default: return ValueComparator.NOT_EQUAL_TO; } }
java
@Override public ValueComparator compare(Value d2) { if (d2 == null) { return ValueComparator.NOT_EQUAL_TO; } switch (d2.getType()) { case NUMBERVALUE: NumberValue otherVal = (NumberValue) d2; int valComp = val.compareTo(otherVal); switch (this.comp) { case EQUAL_TO: return valComp > 0 ? ValueComparator.GREATER_THAN : (valComp < 0 ? ValueComparator.LESS_THAN : ValueComparator.EQUAL_TO); case LESS_THAN: return valComp <= 0 ? ValueComparator.LESS_THAN : ValueComparator.UNKNOWN; default: return valComp >= 0 ? ValueComparator.GREATER_THAN : ValueComparator.UNKNOWN; } case INEQUALITYNUMBERVALUE: InequalityNumberValue other = (InequalityNumberValue) d2; ValueComparator d2Comp = other.comp; int valComp2 = this.val.compareTo(other.val); if (this.comp == d2Comp) { if (this.comp == ValueComparator.EQUAL_TO) { return valComp2 > 0 ? ValueComparator.GREATER_THAN : (valComp2 < 0 ? ValueComparator.LESS_THAN : ValueComparator.EQUAL_TO); } else { return ValueComparator.UNKNOWN; } } else if (this.comp == ValueComparator.GREATER_THAN && d2Comp == ValueComparator.LESS_THAN) { if (valComp2 >= 0) { return ValueComparator.GREATER_THAN; } else { return ValueComparator.UNKNOWN; } } else { if (valComp2 <= 0) { return ValueComparator.LESS_THAN; } else { return ValueComparator.UNKNOWN; } } case VALUELIST: ValueList<?> vl = (ValueList<?>) d2; return vl.contains(this) ? ValueComparator.IN : ValueComparator.NOT_IN; default: return ValueComparator.NOT_EQUAL_TO; } }
[ "@", "Override", "public", "ValueComparator", "compare", "(", "Value", "d2", ")", "{", "if", "(", "d2", "==", "null", ")", "{", "return", "ValueComparator", ".", "NOT_EQUAL_TO", ";", "}", "switch", "(", "d2", ".", "getType", "(", ")", ")", "{", "case", "NUMBERVALUE", ":", "NumberValue", "otherVal", "=", "(", "NumberValue", ")", "d2", ";", "int", "valComp", "=", "val", ".", "compareTo", "(", "otherVal", ")", ";", "switch", "(", "this", ".", "comp", ")", "{", "case", "EQUAL_TO", ":", "return", "valComp", ">", "0", "?", "ValueComparator", ".", "GREATER_THAN", ":", "(", "valComp", "<", "0", "?", "ValueComparator", ".", "LESS_THAN", ":", "ValueComparator", ".", "EQUAL_TO", ")", ";", "case", "LESS_THAN", ":", "return", "valComp", "<=", "0", "?", "ValueComparator", ".", "LESS_THAN", ":", "ValueComparator", ".", "UNKNOWN", ";", "default", ":", "return", "valComp", ">=", "0", "?", "ValueComparator", ".", "GREATER_THAN", ":", "ValueComparator", ".", "UNKNOWN", ";", "}", "case", "INEQUALITYNUMBERVALUE", ":", "InequalityNumberValue", "other", "=", "(", "InequalityNumberValue", ")", "d2", ";", "ValueComparator", "d2Comp", "=", "other", ".", "comp", ";", "int", "valComp2", "=", "this", ".", "val", ".", "compareTo", "(", "other", ".", "val", ")", ";", "if", "(", "this", ".", "comp", "==", "d2Comp", ")", "{", "if", "(", "this", ".", "comp", "==", "ValueComparator", ".", "EQUAL_TO", ")", "{", "return", "valComp2", ">", "0", "?", "ValueComparator", ".", "GREATER_THAN", ":", "(", "valComp2", "<", "0", "?", "ValueComparator", ".", "LESS_THAN", ":", "ValueComparator", ".", "EQUAL_TO", ")", ";", "}", "else", "{", "return", "ValueComparator", ".", "UNKNOWN", ";", "}", "}", "else", "if", "(", "this", ".", "comp", "==", "ValueComparator", ".", "GREATER_THAN", "&&", "d2Comp", "==", "ValueComparator", ".", "LESS_THAN", ")", "{", "if", "(", "valComp2", ">=", "0", ")", "{", "return", "ValueComparator", ".", "GREATER_THAN", ";", "}", "else", "{", "return", "ValueComparator", ".", "UNKNOWN", ";", "}", "}", "else", "{", "if", "(", "valComp2", "<=", "0", ")", "{", "return", "ValueComparator", ".", "LESS_THAN", ";", "}", "else", "{", "return", "ValueComparator", ".", "UNKNOWN", ";", "}", "}", "case", "VALUELIST", ":", "ValueList", "<", "?", ">", "vl", "=", "(", "ValueList", "<", "?", ">", ")", "d2", ";", "return", "vl", ".", "contains", "(", "this", ")", "?", "ValueComparator", ".", "IN", ":", "ValueComparator", ".", "NOT_IN", ";", "default", ":", "return", "ValueComparator", ".", "NOT_EQUAL_TO", ";", "}", "}" ]
Compares this value and another numerically, or checks this value for membership in a value list. @param o a {@link Value}. @return If the provided value is a {@link NumericalValue}, returns {@link ValueComparator#GREATER_THAN}, {@link ValueComparator#LESS_THAN} or {@link ValueComparator#EQUAL_TO} depending on whether this value is numerically greater than, less than or equal to the value provided as argument. IF the provided value is a {@link ValueList}, returns {@link ValueComparator#IN} if this object is a member of the value list, or {@link ValueComparator#NOT_IN} if this object is not a member. Otherwise, returns {@link ValueComparator#UNKNOWN}.
[ "Compares", "this", "value", "and", "another", "numerically", "or", "checks", "this", "value", "for", "membership", "in", "a", "value", "list", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/proposition/value/InequalityNumberValue.java#L203-L257
149,195
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/graph/DirectedGraph.java
DirectedGraph.clear
public void clear() { vertices.clear(); vertexModCount++; Arrays.matrixFill(edges, null); edgeCount = 0; edgesArr = null; edgeModCount++; freeList.clear(); for (int row = capacity - 1; row >= 0; row--) { freeList.add(row); } }
java
public void clear() { vertices.clear(); vertexModCount++; Arrays.matrixFill(edges, null); edgeCount = 0; edgesArr = null; edgeModCount++; freeList.clear(); for (int row = capacity - 1; row >= 0; row--) { freeList.add(row); } }
[ "public", "void", "clear", "(", ")", "{", "vertices", ".", "clear", "(", ")", ";", "vertexModCount", "++", ";", "Arrays", ".", "matrixFill", "(", "edges", ",", "null", ")", ";", "edgeCount", "=", "0", ";", "edgesArr", "=", "null", ";", "edgeModCount", "++", ";", "freeList", ".", "clear", "(", ")", ";", "for", "(", "int", "row", "=", "capacity", "-", "1", ";", "row", ">=", "0", ";", "row", "--", ")", "{", "freeList", ".", "add", "(", "row", ")", ";", "}", "}" ]
Remove all vertices and edges.
[ "Remove", "all", "vertices", "and", "edges", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/graph/DirectedGraph.java#L141-L152
149,196
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/graph/DirectedGraph.java
DirectedGraph.add
public void add(Object vertex) { if (vertex == null || vertices.containsKey(vertex)) { return; } checkGraphSize(); vertices.put(vertex, new VertexMetadata(freeList.removeFirst())); vertexModCount++; }
java
public void add(Object vertex) { if (vertex == null || vertices.containsKey(vertex)) { return; } checkGraphSize(); vertices.put(vertex, new VertexMetadata(freeList.removeFirst())); vertexModCount++; }
[ "public", "void", "add", "(", "Object", "vertex", ")", "{", "if", "(", "vertex", "==", "null", "||", "vertices", ".", "containsKey", "(", "vertex", ")", ")", "{", "return", ";", "}", "checkGraphSize", "(", ")", ";", "vertices", ".", "put", "(", "vertex", ",", "new", "VertexMetadata", "(", "freeList", ".", "removeFirst", "(", ")", ")", ")", ";", "vertexModCount", "++", ";", "}" ]
Adds a vertex. @param vertex a vertex.
[ "Adds", "a", "vertex", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/graph/DirectedGraph.java#L160-L169
149,197
eurekaclinical/protempa
protempa-framework/src/main/java/org/protempa/graph/DirectedGraph.java
DirectedGraph.remove
public Object remove(Object vertex) { VertexMetadata vm = (VertexMetadata) vertices.get(vertex); if (vm == null) { return null; } vertices.remove(vertex); vertexModCount++; int index = vm.index; for (int row = 0; row < capacity; row++) { edges[row][index] = null; edges[index][row] = null; edgeModCount++; } edgesArr = null; freeList.add(index); return vertex; }
java
public Object remove(Object vertex) { VertexMetadata vm = (VertexMetadata) vertices.get(vertex); if (vm == null) { return null; } vertices.remove(vertex); vertexModCount++; int index = vm.index; for (int row = 0; row < capacity; row++) { edges[row][index] = null; edges[index][row] = null; edgeModCount++; } edgesArr = null; freeList.add(index); return vertex; }
[ "public", "Object", "remove", "(", "Object", "vertex", ")", "{", "VertexMetadata", "vm", "=", "(", "VertexMetadata", ")", "vertices", ".", "get", "(", "vertex", ")", ";", "if", "(", "vm", "==", "null", ")", "{", "return", "null", ";", "}", "vertices", ".", "remove", "(", "vertex", ")", ";", "vertexModCount", "++", ";", "int", "index", "=", "vm", ".", "index", ";", "for", "(", "int", "row", "=", "0", ";", "row", "<", "capacity", ";", "row", "++", ")", "{", "edges", "[", "row", "]", "[", "index", "]", "=", "null", ";", "edges", "[", "index", "]", "[", "row", "]", "=", "null", ";", "edgeModCount", "++", ";", "}", "edgesArr", "=", "null", ";", "freeList", ".", "add", "(", "index", ")", ";", "return", "vertex", ";", "}" ]
Remove a vertex and all edges between the vertex and other vertices. @param vertex a vertex. @return the value of the vertex, if it existed.
[ "Remove", "a", "vertex", "and", "all", "edges", "between", "the", "vertex", "and", "other", "vertices", "." ]
5a620d1a407c7a5426d1cf17d47b97717cf71634
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/graph/DirectedGraph.java#L178-L194
149,198
openbase/jul
extension/type/processing/src/main/java/org/openbase/jul/extension/type/processing/MultiLanguageTextProcessor.java
MultiLanguageTextProcessor.isEmpty
public static boolean isEmpty(final MultiLanguageText multiLanguageText) { for (MultiLanguageText.MapFieldEntry entry : multiLanguageText.getEntryList()) { if (!entry.getValue().isEmpty()) { return false; } } return true; }
java
public static boolean isEmpty(final MultiLanguageText multiLanguageText) { for (MultiLanguageText.MapFieldEntry entry : multiLanguageText.getEntryList()) { if (!entry.getValue().isEmpty()) { return false; } } return true; }
[ "public", "static", "boolean", "isEmpty", "(", "final", "MultiLanguageText", "multiLanguageText", ")", "{", "for", "(", "MultiLanguageText", ".", "MapFieldEntry", "entry", ":", "multiLanguageText", ".", "getEntryList", "(", ")", ")", "{", "if", "(", "!", "entry", ".", "getValue", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Test if the multiLanguageText is empty. This means that every multiLanguageText list for every languageCode is empty or that it only contains empty string. @param multiLanguageText the multiLanguageText type which is tested @return if the multiLanguageText type is empty as explained above
[ "Test", "if", "the", "multiLanguageText", "is", "empty", ".", "This", "means", "that", "every", "multiLanguageText", "list", "for", "every", "languageCode", "is", "empty", "or", "that", "it", "only", "contains", "empty", "string", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/extension/type/processing/src/main/java/org/openbase/jul/extension/type/processing/MultiLanguageTextProcessor.java#L54-L61
149,199
openbase/jul
extension/type/processing/src/main/java/org/openbase/jul/extension/type/processing/MultiLanguageTextProcessor.java
MultiLanguageTextProcessor.addMultiLanguageText
public static MultiLanguageText.Builder addMultiLanguageText(final MultiLanguageText.Builder multiLanguageTextBuilder, final String languageCode, final String multiLanguageText) { for (int i = 0; i < multiLanguageTextBuilder.getEntryCount(); i++) { // found multiLanguageTexts for the entry key if (multiLanguageTextBuilder.getEntry(i).getKey().equals(languageCode)) { // check if the new value is not already contained if (multiLanguageTextBuilder.getEntryBuilder(i).getValue().equalsIgnoreCase(multiLanguageText)) { // return because multiLanguageText is already in there return multiLanguageTextBuilder; } // add new multiLanguageText multiLanguageTextBuilder.getEntryBuilder(i).setValue(multiLanguageText); return multiLanguageTextBuilder; } } // language code not present yet multiLanguageTextBuilder.addEntryBuilder().setKey(languageCode).setValue(multiLanguageText); return multiLanguageTextBuilder; }
java
public static MultiLanguageText.Builder addMultiLanguageText(final MultiLanguageText.Builder multiLanguageTextBuilder, final String languageCode, final String multiLanguageText) { for (int i = 0; i < multiLanguageTextBuilder.getEntryCount(); i++) { // found multiLanguageTexts for the entry key if (multiLanguageTextBuilder.getEntry(i).getKey().equals(languageCode)) { // check if the new value is not already contained if (multiLanguageTextBuilder.getEntryBuilder(i).getValue().equalsIgnoreCase(multiLanguageText)) { // return because multiLanguageText is already in there return multiLanguageTextBuilder; } // add new multiLanguageText multiLanguageTextBuilder.getEntryBuilder(i).setValue(multiLanguageText); return multiLanguageTextBuilder; } } // language code not present yet multiLanguageTextBuilder.addEntryBuilder().setKey(languageCode).setValue(multiLanguageText); return multiLanguageTextBuilder; }
[ "public", "static", "MultiLanguageText", ".", "Builder", "addMultiLanguageText", "(", "final", "MultiLanguageText", ".", "Builder", "multiLanguageTextBuilder", ",", "final", "String", "languageCode", ",", "final", "String", "multiLanguageText", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "multiLanguageTextBuilder", ".", "getEntryCount", "(", ")", ";", "i", "++", ")", "{", "// found multiLanguageTexts for the entry key", "if", "(", "multiLanguageTextBuilder", ".", "getEntry", "(", "i", ")", ".", "getKey", "(", ")", ".", "equals", "(", "languageCode", ")", ")", "{", "// check if the new value is not already contained", "if", "(", "multiLanguageTextBuilder", ".", "getEntryBuilder", "(", "i", ")", ".", "getValue", "(", ")", ".", "equalsIgnoreCase", "(", "multiLanguageText", ")", ")", "{", "// return because multiLanguageText is already in there", "return", "multiLanguageTextBuilder", ";", "}", "// add new multiLanguageText", "multiLanguageTextBuilder", ".", "getEntryBuilder", "(", "i", ")", ".", "setValue", "(", "multiLanguageText", ")", ";", "return", "multiLanguageTextBuilder", ";", "}", "}", "// language code not present yet", "multiLanguageTextBuilder", ".", "addEntryBuilder", "(", ")", ".", "setKey", "(", "languageCode", ")", ".", "setValue", "(", "multiLanguageText", ")", ";", "return", "multiLanguageTextBuilder", ";", "}" ]
Add a multiLanguageText to a multiLanguageTextBuilder by languageCode. If the multiLanguageText is already contained for the language code nothing will be done. If the languageCode already exists and the multiLanguageText is not contained it will be added to the end of the multiLanguageText list by this language code. If no entry for the languageCode exists a new entry will be added and the multiLanguageText added as its first value. @param multiLanguageTextBuilder the multiLanguageText builder to be updated @param languageCode the languageCode for which the multiLanguageText is added @param multiLanguageText the multiLanguageText to be added @return the updated multiLanguageText builder
[ "Add", "a", "multiLanguageText", "to", "a", "multiLanguageTextBuilder", "by", "languageCode", ".", "If", "the", "multiLanguageText", "is", "already", "contained", "for", "the", "language", "code", "nothing", "will", "be", "done", ".", "If", "the", "languageCode", "already", "exists", "and", "the", "multiLanguageText", "is", "not", "contained", "it", "will", "be", "added", "to", "the", "end", "of", "the", "multiLanguageText", "list", "by", "this", "language", "code", ".", "If", "no", "entry", "for", "the", "languageCode", "exists", "a", "new", "entry", "will", "be", "added", "and", "the", "multiLanguageText", "added", "as", "its", "first", "value", "." ]
662e98c3a853085e475be54c3be3deb72193c72d
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/extension/type/processing/src/main/java/org/openbase/jul/extension/type/processing/MultiLanguageTextProcessor.java#L136-L154