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,700
dhemery/hartley
src/main/java/com/dhemery/expressing/ImmediateExpressions.java
ImmediateExpressions.not
public static <S> Feature<S,Boolean> not(Feature<? super S, Boolean> feature) { return FeatureExpressions.not(feature); }
java
public static <S> Feature<S,Boolean> not(Feature<? super S, Boolean> feature) { return FeatureExpressions.not(feature); }
[ "public", "static", "<", "S", ">", "Feature", "<", "S", ",", "Boolean", ">", "not", "(", "Feature", "<", "?", "super", "S", ",", "Boolean", ">", "feature", ")", "{", "return", "FeatureExpressions", ".", "not", "(", "feature", ")", ";", "}" ]
Decorate a boolean feature to yield its logical negation.
[ "Decorate", "a", "boolean", "feature", "to", "yield", "its", "logical", "negation", "." ]
7754bd6bc12695f2249601b8890da530a61fcf33
https://github.com/dhemery/hartley/blob/7754bd6bc12695f2249601b8890da530a61fcf33/src/main/java/com/dhemery/expressing/ImmediateExpressions.java#L145-L147
149,701
dhemery/hartley
src/main/java/com/dhemery/expressing/ImmediateExpressions.java
ImmediateExpressions.the
public static <V> boolean the(Sampler<V> variable, Matcher<? super V> criteria) { variable.takeSample(); return criteria.matches(variable.sampledValue()); }
java
public static <V> boolean the(Sampler<V> variable, Matcher<? super V> criteria) { variable.takeSample(); return criteria.matches(variable.sampledValue()); }
[ "public", "static", "<", "V", ">", "boolean", "the", "(", "Sampler", "<", "V", ">", "variable", ",", "Matcher", "<", "?", "super", "V", ">", "criteria", ")", "{", "variable", ".", "takeSample", "(", ")", ";", "return", "criteria", ".", "matches", "(", "variable", ".", "sampledValue", "(", ")", ")", ";", "}" ]
Report whether a sample of the variable satisfies the criteria.
[ "Report", "whether", "a", "sample", "of", "the", "variable", "satisfies", "the", "criteria", "." ]
7754bd6bc12695f2249601b8890da530a61fcf33
https://github.com/dhemery/hartley/blob/7754bd6bc12695f2249601b8890da530a61fcf33/src/main/java/com/dhemery/expressing/ImmediateExpressions.java#L173-L176
149,702
dhemery/hartley
src/main/java/com/dhemery/expressing/ImmediateExpressions.java
ImmediateExpressions.the
public static <S> boolean the(S subject, Matcher<? super S> criteria) { return criteria.matches(subject); }
java
public static <S> boolean the(S subject, Matcher<? super S> criteria) { return criteria.matches(subject); }
[ "public", "static", "<", "S", ">", "boolean", "the", "(", "S", "subject", ",", "Matcher", "<", "?", "super", "S", ">", "criteria", ")", "{", "return", "criteria", ".", "matches", "(", "subject", ")", ";", "}" ]
Report whether the subject satisfies the criteria.
[ "Report", "whether", "the", "subject", "satisfies", "the", "criteria", "." ]
7754bd6bc12695f2249601b8890da530a61fcf33
https://github.com/dhemery/hartley/blob/7754bd6bc12695f2249601b8890da530a61fcf33/src/main/java/com/dhemery/expressing/ImmediateExpressions.java#L188-L190
149,703
dhemery/hartley
src/main/java/com/dhemery/expressing/ImmediateExpressions.java
ImmediateExpressions.the
public static <S,V> boolean the(S subject, Feature<? super S,V> feature, Matcher<? super V> criteria) { return criteria.matches(feature.of(subject)); }
java
public static <S,V> boolean the(S subject, Feature<? super S,V> feature, Matcher<? super V> criteria) { return criteria.matches(feature.of(subject)); }
[ "public", "static", "<", "S", ",", "V", ">", "boolean", "the", "(", "S", "subject", ",", "Feature", "<", "?", "super", "S", ",", "V", ">", "feature", ",", "Matcher", "<", "?", "super", "V", ">", "criteria", ")", "{", "return", "criteria", ".", "matches", "(", "feature", ".", "of", "(", "subject", ")", ")", ";", "}" ]
Report whether a sample of the feature satisfies the criteria.
[ "Report", "whether", "a", "sample", "of", "the", "feature", "satisfies", "the", "criteria", "." ]
7754bd6bc12695f2249601b8890da530a61fcf33
https://github.com/dhemery/hartley/blob/7754bd6bc12695f2249601b8890da530a61fcf33/src/main/java/com/dhemery/expressing/ImmediateExpressions.java#L195-L197
149,704
mlhartme/mork
src/main/java/net/oneandone/mork/reflect/Constant.java
Constant.fillParas
public static Function fillParas(Function func, int ofs, Object[] paras) { int i; if (func == null) { throw new NullPointerException(); } for (i = 0; i < paras.length; i++) { // ofs is not changed! func = Composition.create(func, ofs, new Constant(paras[i].getClass(), "arg"+i, paras[i])); if (func == null) { throw new RuntimeException(); } } return func; }
java
public static Function fillParas(Function func, int ofs, Object[] paras) { int i; if (func == null) { throw new NullPointerException(); } for (i = 0; i < paras.length; i++) { // ofs is not changed! func = Composition.create(func, ofs, new Constant(paras[i].getClass(), "arg"+i, paras[i])); if (func == null) { throw new RuntimeException(); } } return func; }
[ "public", "static", "Function", "fillParas", "(", "Function", "func", ",", "int", "ofs", ",", "Object", "[", "]", "paras", ")", "{", "int", "i", ";", "if", "(", "func", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", ")", ";", "}", "for", "(", "i", "=", "0", ";", "i", "<", "paras", ".", "length", ";", "i", "++", ")", "{", "// ofs is not changed!", "func", "=", "Composition", ".", "create", "(", "func", ",", "ofs", ",", "new", "Constant", "(", "paras", "[", "i", "]", ".", "getClass", "(", ")", ",", "\"arg\"", "+", "i", ",", "paras", "[", "i", "]", ")", ")", ";", "if", "(", "func", "==", "null", ")", "{", "throw", "new", "RuntimeException", "(", ")", ";", "}", "}", "return", "func", ";", "}" ]
Replaces arguments to Functions by Constant Functions. Results in Functions with fewer arguments. @param func Functions whose arguments are filled in @param ofs first argument to be filled @param paras Values for Constants used to fill arguments @return Function with filled arguments.
[ "Replaces", "arguments", "to", "Functions", "by", "Constant", "Functions", ".", "Results", "in", "Functions", "with", "fewer", "arguments", "." ]
a069b087750c4133bfeebaf1f599c3bc96762113
https://github.com/mlhartme/mork/blob/a069b087750c4133bfeebaf1f599c3bc96762113/src/main/java/net/oneandone/mork/reflect/Constant.java#L66-L84
149,705
eurekaclinical/javautil
src/main/java/org/arp/javautil/sql/DataSourceInitialContextBinder.java
DataSourceInitialContextBinder.unbind
public void unbind(DataSource dataSource) throws NamingException { if (dataSource == null) { throw new IllegalArgumentException("dataSource cannot be null"); } String jndiUrl = this.dataSourceBindings.get(dataSource); if (jndiUrl == null) { throw new NamingException("No such binding"); } this.initialContext.unbind(jndiUrl); this.dataSourceBindings.remove(dataSource); }
java
public void unbind(DataSource dataSource) throws NamingException { if (dataSource == null) { throw new IllegalArgumentException("dataSource cannot be null"); } String jndiUrl = this.dataSourceBindings.get(dataSource); if (jndiUrl == null) { throw new NamingException("No such binding"); } this.initialContext.unbind(jndiUrl); this.dataSourceBindings.remove(dataSource); }
[ "public", "void", "unbind", "(", "DataSource", "dataSource", ")", "throws", "NamingException", "{", "if", "(", "dataSource", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"dataSource cannot be null\"", ")", ";", "}", "String", "jndiUrl", "=", "this", ".", "dataSourceBindings", ".", "get", "(", "dataSource", ")", ";", "if", "(", "jndiUrl", "==", "null", ")", "{", "throw", "new", "NamingException", "(", "\"No such binding\"", ")", ";", "}", "this", ".", "initialContext", ".", "unbind", "(", "jndiUrl", ")", ";", "this", ".", "dataSourceBindings", ".", "remove", "(", "dataSource", ")", ";", "}" ]
Unbinds a data source. @param dataSource the {@link DataSource} to unbind. @throws NamingException if an error occurs during unbinding.
[ "Unbinds", "a", "data", "source", "." ]
779bbc5bf096c75f8eed4f99ca45b99c1d44df43
https://github.com/eurekaclinical/javautil/blob/779bbc5bf096c75f8eed4f99ca45b99c1d44df43/src/main/java/org/arp/javautil/sql/DataSourceInitialContextBinder.java#L91-L101
149,706
trustathsh/ifmapj
src/main/java/util/DomHelpers.java
DomHelpers.prepareExtendedIdentifier
public static String prepareExtendedIdentifier(Document doc) throws MarshalException { Transformer tf = null; String res = null; try { tf = TRANSFORMER_FACTORY.newTransformer(); } catch (TransformerConfigurationException e) { IfmapJLog.error("Oh oh.... [" + e.getMessage() + "]"); throw new MarshalException(e.getMessage()); } fixupNamespace(doc); ByteArrayOutputStream baos = new ByteArrayOutputStream(); DOMSource domSource = new DOMSource(doc.getFirstChild()); Result result = new StreamResult(baos); tf.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); tf.setOutputProperty(OutputKeys.INDENT, "no"); tf.setOutputProperty(OutputKeys.METHOD, "xml"); try { tf.transform(domSource, result); } catch (TransformerException e) { IfmapJLog.error("Oh oh.... [" + e.getMessage() + "]"); throw new MarshalException(e.getMessage()); } ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); InputSource inputSource = new InputSource(bais); CanonicalXML cxml = new CanonicalXML(); XMLReader reader = null; try { reader = XMLReaderFactory.createXMLReader(); } catch (SAXException e) { IfmapJLog.error("Oh oh.... [" + e.getMessage() + "]"); throw new MarshalException(e.getMessage()); } try { res = cxml.toCanonicalXml2(reader, inputSource, true); } catch (Exception e) { // hmm... toCanonicalXML throws Exception... IfmapJLog.error("Oh oh.... [" + e.getMessage() + "]"); throw new MarshalException(e.getMessage()); } return escapeXml(res); }
java
public static String prepareExtendedIdentifier(Document doc) throws MarshalException { Transformer tf = null; String res = null; try { tf = TRANSFORMER_FACTORY.newTransformer(); } catch (TransformerConfigurationException e) { IfmapJLog.error("Oh oh.... [" + e.getMessage() + "]"); throw new MarshalException(e.getMessage()); } fixupNamespace(doc); ByteArrayOutputStream baos = new ByteArrayOutputStream(); DOMSource domSource = new DOMSource(doc.getFirstChild()); Result result = new StreamResult(baos); tf.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); tf.setOutputProperty(OutputKeys.INDENT, "no"); tf.setOutputProperty(OutputKeys.METHOD, "xml"); try { tf.transform(domSource, result); } catch (TransformerException e) { IfmapJLog.error("Oh oh.... [" + e.getMessage() + "]"); throw new MarshalException(e.getMessage()); } ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); InputSource inputSource = new InputSource(bais); CanonicalXML cxml = new CanonicalXML(); XMLReader reader = null; try { reader = XMLReaderFactory.createXMLReader(); } catch (SAXException e) { IfmapJLog.error("Oh oh.... [" + e.getMessage() + "]"); throw new MarshalException(e.getMessage()); } try { res = cxml.toCanonicalXml2(reader, inputSource, true); } catch (Exception e) { // hmm... toCanonicalXML throws Exception... IfmapJLog.error("Oh oh.... [" + e.getMessage() + "]"); throw new MarshalException(e.getMessage()); } return escapeXml(res); }
[ "public", "static", "String", "prepareExtendedIdentifier", "(", "Document", "doc", ")", "throws", "MarshalException", "{", "Transformer", "tf", "=", "null", ";", "String", "res", "=", "null", ";", "try", "{", "tf", "=", "TRANSFORMER_FACTORY", ".", "newTransformer", "(", ")", ";", "}", "catch", "(", "TransformerConfigurationException", "e", ")", "{", "IfmapJLog", ".", "error", "(", "\"Oh oh.... [\"", "+", "e", ".", "getMessage", "(", ")", "+", "\"]\"", ")", ";", "throw", "new", "MarshalException", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "fixupNamespace", "(", "doc", ")", ";", "ByteArrayOutputStream", "baos", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "DOMSource", "domSource", "=", "new", "DOMSource", "(", "doc", ".", "getFirstChild", "(", ")", ")", ";", "Result", "result", "=", "new", "StreamResult", "(", "baos", ")", ";", "tf", ".", "setOutputProperty", "(", "OutputKeys", ".", "OMIT_XML_DECLARATION", ",", "\"yes\"", ")", ";", "tf", ".", "setOutputProperty", "(", "OutputKeys", ".", "INDENT", ",", "\"no\"", ")", ";", "tf", ".", "setOutputProperty", "(", "OutputKeys", ".", "METHOD", ",", "\"xml\"", ")", ";", "try", "{", "tf", ".", "transform", "(", "domSource", ",", "result", ")", ";", "}", "catch", "(", "TransformerException", "e", ")", "{", "IfmapJLog", ".", "error", "(", "\"Oh oh.... [\"", "+", "e", ".", "getMessage", "(", ")", "+", "\"]\"", ")", ";", "throw", "new", "MarshalException", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "ByteArrayInputStream", "bais", "=", "new", "ByteArrayInputStream", "(", "baos", ".", "toByteArray", "(", ")", ")", ";", "InputSource", "inputSource", "=", "new", "InputSource", "(", "bais", ")", ";", "CanonicalXML", "cxml", "=", "new", "CanonicalXML", "(", ")", ";", "XMLReader", "reader", "=", "null", ";", "try", "{", "reader", "=", "XMLReaderFactory", ".", "createXMLReader", "(", ")", ";", "}", "catch", "(", "SAXException", "e", ")", "{", "IfmapJLog", ".", "error", "(", "\"Oh oh.... [\"", "+", "e", ".", "getMessage", "(", ")", "+", "\"]\"", ")", ";", "throw", "new", "MarshalException", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "try", "{", "res", "=", "cxml", ".", "toCanonicalXml2", "(", "reader", ",", "inputSource", ",", "true", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "// hmm... toCanonicalXML throws Exception...", "IfmapJLog", ".", "error", "(", "\"Oh oh.... [\"", "+", "e", ".", "getMessage", "(", ")", "+", "\"]\"", ")", ";", "throw", "new", "MarshalException", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "return", "escapeXml", "(", "res", ")", ";", "}" ]
Prepare an extended identifier for publish by removing namespace added by XSL transformation and encoding all relevant XML entities. @since 0.1.5 @param str @return namespace ns0 stripped and encoded XML string @throws MarshalException
[ "Prepare", "an", "extended", "identifier", "for", "publish", "by", "removing", "namespace", "added", "by", "XSL", "transformation", "and", "encoding", "all", "relevant", "XML", "entities", "." ]
44ece9e95a3d2a1b7019573ba6178598a6cbdaa3
https://github.com/trustathsh/ifmapj/blob/44ece9e95a3d2a1b7019573ba6178598a6cbdaa3/src/main/java/util/DomHelpers.java#L257-L307
149,707
trustathsh/ifmapj
src/main/java/util/DomHelpers.java
DomHelpers.removePrefixFromChildren
private static void removePrefixFromChildren(Element el, String prefix) throws MarshalException { NodeList nl = el.getChildNodes(); String localPrefix = null; for (int i = 0; i < nl.getLength(); i++) { Node n = nl.item(i); if (n.getNodeType() != Node.ELEMENT_NODE) { continue; } localPrefix = n.getPrefix(); if (localPrefix != null && localPrefix.length() > 0) { if (!localPrefix.equals(prefix)) { IfmapJLog.warn("Extended Identifier: Multiple namespaces in extended identifer used." + "IfmapJ thinks this is not a wise idea. Sorry!"); throw new MarshalException("Extended Identifier: Multiple namespaces in extended identifer used." + "IfmapJ thinks this is not a wise idea. Sorry!"); } n.setPrefix(null); } removePrefixFromChildren((Element) n, prefix); dropNamespaceDecls((Element) n); } }
java
private static void removePrefixFromChildren(Element el, String prefix) throws MarshalException { NodeList nl = el.getChildNodes(); String localPrefix = null; for (int i = 0; i < nl.getLength(); i++) { Node n = nl.item(i); if (n.getNodeType() != Node.ELEMENT_NODE) { continue; } localPrefix = n.getPrefix(); if (localPrefix != null && localPrefix.length() > 0) { if (!localPrefix.equals(prefix)) { IfmapJLog.warn("Extended Identifier: Multiple namespaces in extended identifer used." + "IfmapJ thinks this is not a wise idea. Sorry!"); throw new MarshalException("Extended Identifier: Multiple namespaces in extended identifer used." + "IfmapJ thinks this is not a wise idea. Sorry!"); } n.setPrefix(null); } removePrefixFromChildren((Element) n, prefix); dropNamespaceDecls((Element) n); } }
[ "private", "static", "void", "removePrefixFromChildren", "(", "Element", "el", ",", "String", "prefix", ")", "throws", "MarshalException", "{", "NodeList", "nl", "=", "el", ".", "getChildNodes", "(", ")", ";", "String", "localPrefix", "=", "null", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "nl", ".", "getLength", "(", ")", ";", "i", "++", ")", "{", "Node", "n", "=", "nl", ".", "item", "(", "i", ")", ";", "if", "(", "n", ".", "getNodeType", "(", ")", "!=", "Node", ".", "ELEMENT_NODE", ")", "{", "continue", ";", "}", "localPrefix", "=", "n", ".", "getPrefix", "(", ")", ";", "if", "(", "localPrefix", "!=", "null", "&&", "localPrefix", ".", "length", "(", ")", ">", "0", ")", "{", "if", "(", "!", "localPrefix", ".", "equals", "(", "prefix", ")", ")", "{", "IfmapJLog", ".", "warn", "(", "\"Extended Identifier: Multiple namespaces in extended identifer used.\"", "+", "\"IfmapJ thinks this is not a wise idea. Sorry!\"", ")", ";", "throw", "new", "MarshalException", "(", "\"Extended Identifier: Multiple namespaces in extended identifer used.\"", "+", "\"IfmapJ thinks this is not a wise idea. Sorry!\"", ")", ";", "}", "n", ".", "setPrefix", "(", "null", ")", ";", "}", "removePrefixFromChildren", "(", "(", "Element", ")", "n", ",", "prefix", ")", ";", "dropNamespaceDecls", "(", "(", "Element", ")", "n", ")", ";", "}", "}" ]
If any child of el has prefix as prefix, remove it. drop all namespace decls on the way. If we find an element with a different prefix, go crazy. @param el @param prefix @throws MarshalException
[ "If", "any", "child", "of", "el", "has", "prefix", "as", "prefix", "remove", "it", ".", "drop", "all", "namespace", "decls", "on", "the", "way", ".", "If", "we", "find", "an", "element", "with", "a", "different", "prefix", "go", "crazy", "." ]
44ece9e95a3d2a1b7019573ba6178598a6cbdaa3
https://github.com/trustathsh/ifmapj/blob/44ece9e95a3d2a1b7019573ba6178598a6cbdaa3/src/main/java/util/DomHelpers.java#L410-L440
149,708
trustathsh/ifmapj
src/main/java/util/DomHelpers.java
DomHelpers.compare
public static boolean compare(Document d1, Document d2) throws MarshalException { d1.normalize(); d2.normalize(); return d1.isEqualNode(d2); }
java
public static boolean compare(Document d1, Document d2) throws MarshalException { d1.normalize(); d2.normalize(); return d1.isEqualNode(d2); }
[ "public", "static", "boolean", "compare", "(", "Document", "d1", ",", "Document", "d2", ")", "throws", "MarshalException", "{", "d1", ".", "normalize", "(", ")", ";", "d2", ".", "normalize", "(", ")", ";", "return", "d1", ".", "isEqualNode", "(", "d2", ")", ";", "}" ]
Compare two DOM documents @param d1 First DOM document @param d2 Second DOM document @return true if both are equal @throws MarshalException
[ "Compare", "two", "DOM", "documents" ]
44ece9e95a3d2a1b7019573ba6178598a6cbdaa3
https://github.com/trustathsh/ifmapj/blob/44ece9e95a3d2a1b7019573ba6178598a6cbdaa3/src/main/java/util/DomHelpers.java#L486-L490
149,709
seedstack/audit-addon
core/src/main/java/org/seedstack/audit/internal/AuditConfigurer.java
AuditConfigurer.findTrailWriters
Set<Class<? extends TrailWriter>> findTrailWriters() { Set<Class<? extends TrailWriter>> trailWriters = auditConfig.getWriters(); if (trailWriters.isEmpty()) { LOGGER.info("No TrailWriter specified"); } return trailWriters; }
java
Set<Class<? extends TrailWriter>> findTrailWriters() { Set<Class<? extends TrailWriter>> trailWriters = auditConfig.getWriters(); if (trailWriters.isEmpty()) { LOGGER.info("No TrailWriter specified"); } return trailWriters; }
[ "Set", "<", "Class", "<", "?", "extends", "TrailWriter", ">", ">", "findTrailWriters", "(", ")", "{", "Set", "<", "Class", "<", "?", "extends", "TrailWriter", ">", ">", "trailWriters", "=", "auditConfig", ".", "getWriters", "(", ")", ";", "if", "(", "trailWriters", ".", "isEmpty", "(", ")", ")", "{", "LOGGER", ".", "info", "(", "\"No TrailWriter specified\"", ")", ";", "}", "return", "trailWriters", ";", "}" ]
Finds the trail writers as configured in the props. @return a collection of trail writer classes.
[ "Finds", "the", "trail", "writers", "as", "configured", "in", "the", "props", "." ]
a2a91da236727eecd9fcc3df328ae2081cfe115b
https://github.com/seedstack/audit-addon/blob/a2a91da236727eecd9fcc3df328ae2081cfe115b/core/src/main/java/org/seedstack/audit/internal/AuditConfigurer.java#L45-L51
149,710
seedstack/audit-addon
core/src/main/java/org/seedstack/audit/internal/AuditConfigurer.java
AuditConfigurer.findTrailExceptionHandlers
@SuppressWarnings({"unchecked"}) Set<Class<? extends TrailExceptionHandler<?>>> findTrailExceptionHandlers() { Set<Class<? extends TrailExceptionHandler<?>>> trailExceptionHandlers = auditConfig.getExceptionHandlers(); if (trailExceptionHandlers.isEmpty()) { Collection<Class<?>> scannedTrailExceptionHandlers = auditClasses.get(TrailExceptionHandler.class); LOGGER.info("No audit TrailExceptionHandler specified, using every handler found"); Set<Class<? extends TrailExceptionHandler<?>>> foundExceptionHandlers = new HashSet<>(); for (Class<?> scannedTrailExceptionHandler : scannedTrailExceptionHandlers) { foundExceptionHandlers.add((Class<? extends TrailExceptionHandler<?>>) scannedTrailExceptionHandler); LOGGER.info("Registered audit exception handler {}", scannedTrailExceptionHandler); } return foundExceptionHandlers; } else { return trailExceptionHandlers; } }
java
@SuppressWarnings({"unchecked"}) Set<Class<? extends TrailExceptionHandler<?>>> findTrailExceptionHandlers() { Set<Class<? extends TrailExceptionHandler<?>>> trailExceptionHandlers = auditConfig.getExceptionHandlers(); if (trailExceptionHandlers.isEmpty()) { Collection<Class<?>> scannedTrailExceptionHandlers = auditClasses.get(TrailExceptionHandler.class); LOGGER.info("No audit TrailExceptionHandler specified, using every handler found"); Set<Class<? extends TrailExceptionHandler<?>>> foundExceptionHandlers = new HashSet<>(); for (Class<?> scannedTrailExceptionHandler : scannedTrailExceptionHandlers) { foundExceptionHandlers.add((Class<? extends TrailExceptionHandler<?>>) scannedTrailExceptionHandler); LOGGER.info("Registered audit exception handler {}", scannedTrailExceptionHandler); } return foundExceptionHandlers; } else { return trailExceptionHandlers; } }
[ "@", "SuppressWarnings", "(", "{", "\"unchecked\"", "}", ")", "Set", "<", "Class", "<", "?", "extends", "TrailExceptionHandler", "<", "?", ">", ">", ">", "findTrailExceptionHandlers", "(", ")", "{", "Set", "<", "Class", "<", "?", "extends", "TrailExceptionHandler", "<", "?", ">", ">", ">", "trailExceptionHandlers", "=", "auditConfig", ".", "getExceptionHandlers", "(", ")", ";", "if", "(", "trailExceptionHandlers", ".", "isEmpty", "(", ")", ")", "{", "Collection", "<", "Class", "<", "?", ">", ">", "scannedTrailExceptionHandlers", "=", "auditClasses", ".", "get", "(", "TrailExceptionHandler", ".", "class", ")", ";", "LOGGER", ".", "info", "(", "\"No audit TrailExceptionHandler specified, using every handler found\"", ")", ";", "Set", "<", "Class", "<", "?", "extends", "TrailExceptionHandler", "<", "?", ">", ">", ">", "foundExceptionHandlers", "=", "new", "HashSet", "<>", "(", ")", ";", "for", "(", "Class", "<", "?", ">", "scannedTrailExceptionHandler", ":", "scannedTrailExceptionHandlers", ")", "{", "foundExceptionHandlers", ".", "add", "(", "(", "Class", "<", "?", "extends", "TrailExceptionHandler", "<", "?", ">", ">", ")", "scannedTrailExceptionHandler", ")", ";", "LOGGER", ".", "info", "(", "\"Registered audit exception handler {}\"", ",", "scannedTrailExceptionHandler", ")", ";", "}", "return", "foundExceptionHandlers", ";", "}", "else", "{", "return", "trailExceptionHandlers", ";", "}", "}" ]
Finds the exception handlers as configured in the props. @return a collection of exception handler classes.
[ "Finds", "the", "exception", "handlers", "as", "configured", "in", "the", "props", "." ]
a2a91da236727eecd9fcc3df328ae2081cfe115b
https://github.com/seedstack/audit-addon/blob/a2a91da236727eecd9fcc3df328ae2081cfe115b/core/src/main/java/org/seedstack/audit/internal/AuditConfigurer.java#L58-L73
149,711
mlhartme/mork
src/main/java/net/oneandone/mork/compiler/MapperCompiler.java
MapperCompiler.outputDir
public File outputDir(File src, File explicitOutputDir, String mapperName) throws IOException { File outputDir; int prev; int idx; File subDir; if (explicitOutputDir == null) { outputDir = src.getParentFile(); } else { outputDir = explicitOutputDir; idx = mapperName.indexOf('.'); prev = 0; while (idx != -1) { subDir = new File(outputDir, mapperName.substring(prev, idx)); if (!subDir.isDirectory()) { if (!subDir.mkdir()) { throw new IOException("cannot create directory: " + subDir); } } prev = idx + 1; idx = mapperName.indexOf('.', prev); outputDir = subDir; } } return outputDir; }
java
public File outputDir(File src, File explicitOutputDir, String mapperName) throws IOException { File outputDir; int prev; int idx; File subDir; if (explicitOutputDir == null) { outputDir = src.getParentFile(); } else { outputDir = explicitOutputDir; idx = mapperName.indexOf('.'); prev = 0; while (idx != -1) { subDir = new File(outputDir, mapperName.substring(prev, idx)); if (!subDir.isDirectory()) { if (!subDir.mkdir()) { throw new IOException("cannot create directory: " + subDir); } } prev = idx + 1; idx = mapperName.indexOf('.', prev); outputDir = subDir; } } return outputDir; }
[ "public", "File", "outputDir", "(", "File", "src", ",", "File", "explicitOutputDir", ",", "String", "mapperName", ")", "throws", "IOException", "{", "File", "outputDir", ";", "int", "prev", ";", "int", "idx", ";", "File", "subDir", ";", "if", "(", "explicitOutputDir", "==", "null", ")", "{", "outputDir", "=", "src", ".", "getParentFile", "(", ")", ";", "}", "else", "{", "outputDir", "=", "explicitOutputDir", ";", "idx", "=", "mapperName", ".", "indexOf", "(", "'", "'", ")", ";", "prev", "=", "0", ";", "while", "(", "idx", "!=", "-", "1", ")", "{", "subDir", "=", "new", "File", "(", "outputDir", ",", "mapperName", ".", "substring", "(", "prev", ",", "idx", ")", ")", ";", "if", "(", "!", "subDir", ".", "isDirectory", "(", ")", ")", "{", "if", "(", "!", "subDir", ".", "mkdir", "(", ")", ")", "{", "throw", "new", "IOException", "(", "\"cannot create directory: \"", "+", "subDir", ")", ";", "}", "}", "prev", "=", "idx", "+", "1", ";", "idx", "=", "mapperName", ".", "indexOf", "(", "'", "'", ",", "prev", ")", ";", "outputDir", "=", "subDir", ";", "}", "}", "return", "outputDir", ";", "}" ]
creates new directory if necessary.
[ "creates", "new", "directory", "if", "necessary", "." ]
a069b087750c4133bfeebaf1f599c3bc96762113
https://github.com/mlhartme/mork/blob/a069b087750c4133bfeebaf1f599c3bc96762113/src/main/java/net/oneandone/mork/compiler/MapperCompiler.java#L86-L111
149,712
mlhartme/mork
src/main/java/net/oneandone/mork/compiler/ObjectCompiler.java
ObjectCompiler.run
private void run(Class<?> type, Object val, int limit) { int initial; initial = dest.getSize(); if (val == null) { if (type.isPrimitive()) { throw new IllegalArgumentException("primitive null"); } // null is not a string, but otherwise it is ambiguous dest.emit(LDC, (String) null); } else if (val instanceof String) { dest.emit(LDC, (String) val); } else if (type.isPrimitive()) { primitive(ClassRef.findComponent(type).id, val); } else if (type.isArray()) { array(type, val, limit); } else { object(type, val, limit); } if (dest.getSize() - initial > limit) { throw new IllegalStateException( "limit:" + limit + " used:" + (dest.getSize() - initial) + " val:" + val); } }
java
private void run(Class<?> type, Object val, int limit) { int initial; initial = dest.getSize(); if (val == null) { if (type.isPrimitive()) { throw new IllegalArgumentException("primitive null"); } // null is not a string, but otherwise it is ambiguous dest.emit(LDC, (String) null); } else if (val instanceof String) { dest.emit(LDC, (String) val); } else if (type.isPrimitive()) { primitive(ClassRef.findComponent(type).id, val); } else if (type.isArray()) { array(type, val, limit); } else { object(type, val, limit); } if (dest.getSize() - initial > limit) { throw new IllegalStateException( "limit:" + limit + " used:" + (dest.getSize() - initial) + " val:" + val); } }
[ "private", "void", "run", "(", "Class", "<", "?", ">", "type", ",", "Object", "val", ",", "int", "limit", ")", "{", "int", "initial", ";", "initial", "=", "dest", ".", "getSize", "(", ")", ";", "if", "(", "val", "==", "null", ")", "{", "if", "(", "type", ".", "isPrimitive", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"primitive null\"", ")", ";", "}", "// null is not a string, but otherwise it is ambiguous", "dest", ".", "emit", "(", "LDC", ",", "(", "String", ")", "null", ")", ";", "}", "else", "if", "(", "val", "instanceof", "String", ")", "{", "dest", ".", "emit", "(", "LDC", ",", "(", "String", ")", "val", ")", ";", "}", "else", "if", "(", "type", ".", "isPrimitive", "(", ")", ")", "{", "primitive", "(", "ClassRef", ".", "findComponent", "(", "type", ")", ".", "id", ",", "val", ")", ";", "}", "else", "if", "(", "type", ".", "isArray", "(", ")", ")", "{", "array", "(", "type", ",", "val", ",", "limit", ")", ";", "}", "else", "{", "object", "(", "type", ",", "val", ",", "limit", ")", ";", "}", "if", "(", "dest", ".", "getSize", "(", ")", "-", "initial", ">", "limit", ")", "{", "throw", "new", "IllegalStateException", "(", "\"limit:\"", "+", "limit", "+", "\" used:\"", "+", "(", "dest", ".", "getSize", "(", ")", "-", "initial", ")", "+", "\" val:\"", "+", "val", ")", ";", "}", "}" ]
type is the static type. If type is primitive, the primitive object wrapped by val is compiled. @param limit max number of instactions the value may be compiled to. >= 1.
[ "type", "is", "the", "static", "type", ".", "If", "type", "is", "primitive", "the", "primitive", "object", "wrapped", "by", "val", "is", "compiled", "." ]
a069b087750c4133bfeebaf1f599c3bc96762113
https://github.com/mlhartme/mork/blob/a069b087750c4133bfeebaf1f599c3bc96762113/src/main/java/net/oneandone/mork/compiler/ObjectCompiler.java#L80-L105
149,713
mlhartme/mork
src/main/java/net/oneandone/mork/compiler/ObjectCompiler.java
ObjectCompiler.primitive
private void primitive(int typeCode, Object obj) { switch (typeCode) { case T_BOOLEAN: dest.emit(LDC, ((Boolean) obj).booleanValue()? 1 : 0); break; case T_CHAR: dest.emit(LDC, ((Character) obj).charValue()); break; case T_BYTE: case T_SHORT: dest.emit(LDC, ((Number) obj).intValue()); break; case T_INT: case T_FLOAT: case T_LONG: case T_DOUBLE: dest.emitGeneric(LDC, new Object[] { obj }); break; default: throw new IllegalArgumentException("not supported: " + typeCode); } }
java
private void primitive(int typeCode, Object obj) { switch (typeCode) { case T_BOOLEAN: dest.emit(LDC, ((Boolean) obj).booleanValue()? 1 : 0); break; case T_CHAR: dest.emit(LDC, ((Character) obj).charValue()); break; case T_BYTE: case T_SHORT: dest.emit(LDC, ((Number) obj).intValue()); break; case T_INT: case T_FLOAT: case T_LONG: case T_DOUBLE: dest.emitGeneric(LDC, new Object[] { obj }); break; default: throw new IllegalArgumentException("not supported: " + typeCode); } }
[ "private", "void", "primitive", "(", "int", "typeCode", ",", "Object", "obj", ")", "{", "switch", "(", "typeCode", ")", "{", "case", "T_BOOLEAN", ":", "dest", ".", "emit", "(", "LDC", ",", "(", "(", "Boolean", ")", "obj", ")", ".", "booleanValue", "(", ")", "?", "1", ":", "0", ")", ";", "break", ";", "case", "T_CHAR", ":", "dest", ".", "emit", "(", "LDC", ",", "(", "(", "Character", ")", "obj", ")", ".", "charValue", "(", ")", ")", ";", "break", ";", "case", "T_BYTE", ":", "case", "T_SHORT", ":", "dest", ".", "emit", "(", "LDC", ",", "(", "(", "Number", ")", "obj", ")", ".", "intValue", "(", ")", ")", ";", "break", ";", "case", "T_INT", ":", "case", "T_FLOAT", ":", "case", "T_LONG", ":", "case", "T_DOUBLE", ":", "dest", ".", "emitGeneric", "(", "LDC", ",", "new", "Object", "[", "]", "{", "obj", "}", ")", ";", "break", ";", "default", ":", "throw", "new", "IllegalArgumentException", "(", "\"not supported: \"", "+", "typeCode", ")", ";", "}", "}" ]
generates exactly 1 instruction.
[ "generates", "exactly", "1", "instruction", "." ]
a069b087750c4133bfeebaf1f599c3bc96762113
https://github.com/mlhartme/mork/blob/a069b087750c4133bfeebaf1f599c3bc96762113/src/main/java/net/oneandone/mork/compiler/ObjectCompiler.java#L110-L131
149,714
mlhartme/mork
src/main/java/net/oneandone/mork/compiler/ObjectCompiler.java
ObjectCompiler.charArray
private void charArray(char[] vals, int limit) { int len; char c; int left, right; String str; int instrsPerChunk = 6; int maxLen; int used; left = 0; len = vals.length; // len/CHUNK + 1 is conservative because len % CHUNK may be 0 maxLen = 3 + (len / CHUNK + 1) * instrsPerChunk + 1; if (limit < maxLen) { pushMethod(char.class); if (limit < maxLen) { throw new IllegalStateException("array size ..."); } charArray(vals, MAX_INSTRUCTIONS); popMethod(); return; } dest.emit(LDC, len); ClassRef.CHAR.emitArrayNew(dest); dest.emit(ASTORE, buffer); // store array reference while (left < len) { c = vals[left]; if (c != 0) { right = Math.min(len, left + CHUNK); used = right - left; while (used > 0 && vals[left + used - 1] == 0) { used--; } if (used > 0) { str = String.copyValueOf(vals, left, used); dest.emit(LDC, str); dest.emit(LDC, 0); dest.emit(LDC, used); dest.emit(ALOAD, buffer); dest.emit(LDC, left); dest.emit(INVOKEVIRTUAL, GET_CHARS); left = right; } else { // empty chunk, don't save it } } else { left++; } } dest.emit(ALOAD, buffer); }
java
private void charArray(char[] vals, int limit) { int len; char c; int left, right; String str; int instrsPerChunk = 6; int maxLen; int used; left = 0; len = vals.length; // len/CHUNK + 1 is conservative because len % CHUNK may be 0 maxLen = 3 + (len / CHUNK + 1) * instrsPerChunk + 1; if (limit < maxLen) { pushMethod(char.class); if (limit < maxLen) { throw new IllegalStateException("array size ..."); } charArray(vals, MAX_INSTRUCTIONS); popMethod(); return; } dest.emit(LDC, len); ClassRef.CHAR.emitArrayNew(dest); dest.emit(ASTORE, buffer); // store array reference while (left < len) { c = vals[left]; if (c != 0) { right = Math.min(len, left + CHUNK); used = right - left; while (used > 0 && vals[left + used - 1] == 0) { used--; } if (used > 0) { str = String.copyValueOf(vals, left, used); dest.emit(LDC, str); dest.emit(LDC, 0); dest.emit(LDC, used); dest.emit(ALOAD, buffer); dest.emit(LDC, left); dest.emit(INVOKEVIRTUAL, GET_CHARS); left = right; } else { // empty chunk, don't save it } } else { left++; } } dest.emit(ALOAD, buffer); }
[ "private", "void", "charArray", "(", "char", "[", "]", "vals", ",", "int", "limit", ")", "{", "int", "len", ";", "char", "c", ";", "int", "left", ",", "right", ";", "String", "str", ";", "int", "instrsPerChunk", "=", "6", ";", "int", "maxLen", ";", "int", "used", ";", "left", "=", "0", ";", "len", "=", "vals", ".", "length", ";", "// len/CHUNK + 1 is conservative because len % CHUNK may be 0", "maxLen", "=", "3", "+", "(", "len", "/", "CHUNK", "+", "1", ")", "*", "instrsPerChunk", "+", "1", ";", "if", "(", "limit", "<", "maxLen", ")", "{", "pushMethod", "(", "char", ".", "class", ")", ";", "if", "(", "limit", "<", "maxLen", ")", "{", "throw", "new", "IllegalStateException", "(", "\"array size ...\"", ")", ";", "}", "charArray", "(", "vals", ",", "MAX_INSTRUCTIONS", ")", ";", "popMethod", "(", ")", ";", "return", ";", "}", "dest", ".", "emit", "(", "LDC", ",", "len", ")", ";", "ClassRef", ".", "CHAR", ".", "emitArrayNew", "(", "dest", ")", ";", "dest", ".", "emit", "(", "ASTORE", ",", "buffer", ")", ";", "// store array reference", "while", "(", "left", "<", "len", ")", "{", "c", "=", "vals", "[", "left", "]", ";", "if", "(", "c", "!=", "0", ")", "{", "right", "=", "Math", ".", "min", "(", "len", ",", "left", "+", "CHUNK", ")", ";", "used", "=", "right", "-", "left", ";", "while", "(", "used", ">", "0", "&&", "vals", "[", "left", "+", "used", "-", "1", "]", "==", "0", ")", "{", "used", "--", ";", "}", "if", "(", "used", ">", "0", ")", "{", "str", "=", "String", ".", "copyValueOf", "(", "vals", ",", "left", ",", "used", ")", ";", "dest", ".", "emit", "(", "LDC", ",", "str", ")", ";", "dest", ".", "emit", "(", "LDC", ",", "0", ")", ";", "dest", ".", "emit", "(", "LDC", ",", "used", ")", ";", "dest", ".", "emit", "(", "ALOAD", ",", "buffer", ")", ";", "dest", ".", "emit", "(", "LDC", ",", "left", ")", ";", "dest", ".", "emit", "(", "INVOKEVIRTUAL", ",", "GET_CHARS", ")", ";", "left", "=", "right", ";", "}", "else", "{", "// empty chunk, don't save it", "}", "}", "else", "{", "left", "++", ";", "}", "}", "dest", ".", "emit", "(", "ALOAD", ",", "buffer", ")", ";", "}" ]
reference on the operand stack
[ "reference", "on", "the", "operand", "stack" ]
a069b087750c4133bfeebaf1f599c3bc96762113
https://github.com/mlhartme/mork/blob/a069b087750c4133bfeebaf1f599c3bc96762113/src/main/java/net/oneandone/mork/compiler/ObjectCompiler.java#L235-L286
149,715
seedstack/jms-addon
src/it/java/org/seedstack/jms/JmsBaseIT.java
JmsBaseIT.managed_send_and_receive_is_working
@Test public void managed_send_and_receive_is_working() throws JMSException { testSender1.send("MANAGED"); try { managed.await(1, TimeUnit.SECONDS); Assertions.assertThat(textManaged).isEqualTo("MANAGED"); } catch (InterruptedException e) { fail("Thread interrupted"); } }
java
@Test public void managed_send_and_receive_is_working() throws JMSException { testSender1.send("MANAGED"); try { managed.await(1, TimeUnit.SECONDS); Assertions.assertThat(textManaged).isEqualTo("MANAGED"); } catch (InterruptedException e) { fail("Thread interrupted"); } }
[ "@", "Test", "public", "void", "managed_send_and_receive_is_working", "(", ")", "throws", "JMSException", "{", "testSender1", ".", "send", "(", "\"MANAGED\"", ")", ";", "try", "{", "managed", ".", "await", "(", "1", ",", "TimeUnit", ".", "SECONDS", ")", ";", "Assertions", ".", "assertThat", "(", "textManaged", ")", ".", "isEqualTo", "(", "\"MANAGED\"", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "fail", "(", "\"Thread interrupted\"", ")", ";", "}", "}" ]
TestSender1 and TestMessageListener1.
[ "TestSender1", "and", "TestMessageListener1", "." ]
d6014811daaac29f591b32bfd2358500fb25d804
https://github.com/seedstack/jms-addon/blob/d6014811daaac29f591b32bfd2358500fb25d804/src/it/java/org/seedstack/jms/JmsBaseIT.java#L48-L59
149,716
seedstack/jms-addon
src/it/java/org/seedstack/jms/JmsBaseIT.java
JmsBaseIT.unmanaged_send_and_receive_is_working
@Test public void unmanaged_send_and_receive_is_working() throws JMSException { testSender2.send("UNMANAGED"); try { unmanaged.await(1, TimeUnit.SECONDS); Assertions.assertThat(textUnmanaged).isEqualTo("UNMANAGED"); } catch (InterruptedException e) { fail("Thread interrupted"); } }
java
@Test public void unmanaged_send_and_receive_is_working() throws JMSException { testSender2.send("UNMANAGED"); try { unmanaged.await(1, TimeUnit.SECONDS); Assertions.assertThat(textUnmanaged).isEqualTo("UNMANAGED"); } catch (InterruptedException e) { fail("Thread interrupted"); } }
[ "@", "Test", "public", "void", "unmanaged_send_and_receive_is_working", "(", ")", "throws", "JMSException", "{", "testSender2", ".", "send", "(", "\"UNMANAGED\"", ")", ";", "try", "{", "unmanaged", ".", "await", "(", "1", ",", "TimeUnit", ".", "SECONDS", ")", ";", "Assertions", ".", "assertThat", "(", "textUnmanaged", ")", ".", "isEqualTo", "(", "\"UNMANAGED\"", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "fail", "(", "\"Thread interrupted\"", ")", ";", "}", "}" ]
TestSender2 and TestMessageListener2.
[ "TestSender2", "and", "TestMessageListener2", "." ]
d6014811daaac29f591b32bfd2358500fb25d804
https://github.com/seedstack/jms-addon/blob/d6014811daaac29f591b32bfd2358500fb25d804/src/it/java/org/seedstack/jms/JmsBaseIT.java#L64-L76
149,717
icoloma/simpleds
src/main/java/org/simpleds/metadata/ClassMetadata.java
ClassMetadata.datastoreToJava
public <T> T datastoreToJava(Entity entity) { try { if (entity == null) { return null; } T result = (T) persistentClass.newInstance(); populate(entity, result); return result; } catch (InstantiationException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } }
java
public <T> T datastoreToJava(Entity entity) { try { if (entity == null) { return null; } T result = (T) persistentClass.newInstance(); populate(entity, result); return result; } catch (InstantiationException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } }
[ "public", "<", "T", ">", "T", "datastoreToJava", "(", "Entity", "entity", ")", "{", "try", "{", "if", "(", "entity", "==", "null", ")", "{", "return", "null", ";", "}", "T", "result", "=", "(", "T", ")", "persistentClass", ".", "newInstance", "(", ")", ";", "populate", "(", "entity", ",", "result", ")", ";", "return", "result", ";", "}", "catch", "(", "InstantiationException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "catch", "(", "IllegalAccessException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}" ]
Convert a value from Google representation to a Java value @param entity the persistent {@link Entity} from the google datastore
[ "Convert", "a", "value", "from", "Google", "representation", "to", "a", "Java", "value" ]
b07763df98b9375b764e625f617a6c78df4b068d
https://github.com/icoloma/simpleds/blob/b07763df98b9375b764e625f617a6c78df4b068d/src/main/java/org/simpleds/metadata/ClassMetadata.java#L63-L76
149,718
icoloma/simpleds
src/main/java/org/simpleds/metadata/ClassMetadata.java
ClassMetadata.populate
public void populate(Entity from, Object to) { for (Entry<String, Object> property : from.getProperties().entrySet()) { PropertyMetadata metadata = properties.get(property.getKey()); if (metadata != null) { Object value = metadata.getConverter().datastoreToJava(property.getValue()); metadata.setValue(to, value); } else { if (log.isDebugEnabled()) { log.debug("Unmapped attribute found in DataStore entry. Ignoring: " + from.getKind() + "." + property.getKey()); } } } keyProperty.setValue(to, from.getKey()); }
java
public void populate(Entity from, Object to) { for (Entry<String, Object> property : from.getProperties().entrySet()) { PropertyMetadata metadata = properties.get(property.getKey()); if (metadata != null) { Object value = metadata.getConverter().datastoreToJava(property.getValue()); metadata.setValue(to, value); } else { if (log.isDebugEnabled()) { log.debug("Unmapped attribute found in DataStore entry. Ignoring: " + from.getKind() + "." + property.getKey()); } } } keyProperty.setValue(to, from.getKey()); }
[ "public", "void", "populate", "(", "Entity", "from", ",", "Object", "to", ")", "{", "for", "(", "Entry", "<", "String", ",", "Object", ">", "property", ":", "from", ".", "getProperties", "(", ")", ".", "entrySet", "(", ")", ")", "{", "PropertyMetadata", "metadata", "=", "properties", ".", "get", "(", "property", ".", "getKey", "(", ")", ")", ";", "if", "(", "metadata", "!=", "null", ")", "{", "Object", "value", "=", "metadata", ".", "getConverter", "(", ")", ".", "datastoreToJava", "(", "property", ".", "getValue", "(", ")", ")", ";", "metadata", ".", "setValue", "(", "to", ",", "value", ")", ";", "}", "else", "{", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Unmapped attribute found in DataStore entry. Ignoring: \"", "+", "from", ".", "getKind", "(", ")", "+", "\".\"", "+", "property", ".", "getKey", "(", ")", ")", ";", "}", "}", "}", "keyProperty", ".", "setValue", "(", "to", ",", "from", ".", "getKey", "(", ")", ")", ";", "}" ]
Copy all properties from the datastore entity into the persistent class instance passed as an attribute. @param from the entity read from the datastore @param to the java object to populate. Cannot be null.
[ "Copy", "all", "properties", "from", "the", "datastore", "entity", "into", "the", "persistent", "class", "instance", "passed", "as", "an", "attribute", "." ]
b07763df98b9375b764e625f617a6c78df4b068d
https://github.com/icoloma/simpleds/blob/b07763df98b9375b764e625f617a6c78df4b068d/src/main/java/org/simpleds/metadata/ClassMetadata.java#L83-L96
149,719
icoloma/simpleds
src/main/java/org/simpleds/metadata/ClassMetadata.java
ClassMetadata.validateConstraints
public void validateConstraints(Entity entity) { for (String propertyName : requiredProperties) { Object value = entity.getProperty(propertyName); if (value == null || (value instanceof String && ((String) value).length() == 0)) { throw new RequiredFieldException("Required property '" + this.persistentClass.getSimpleName() + "." + propertyName + "' is not set"); } } }
java
public void validateConstraints(Entity entity) { for (String propertyName : requiredProperties) { Object value = entity.getProperty(propertyName); if (value == null || (value instanceof String && ((String) value).length() == 0)) { throw new RequiredFieldException("Required property '" + this.persistentClass.getSimpleName() + "." + propertyName + "' is not set"); } } }
[ "public", "void", "validateConstraints", "(", "Entity", "entity", ")", "{", "for", "(", "String", "propertyName", ":", "requiredProperties", ")", "{", "Object", "value", "=", "entity", ".", "getProperty", "(", "propertyName", ")", ";", "if", "(", "value", "==", "null", "||", "(", "value", "instanceof", "String", "&&", "(", "(", "String", ")", "value", ")", ".", "length", "(", ")", "==", "0", ")", ")", "{", "throw", "new", "RequiredFieldException", "(", "\"Required property '\"", "+", "this", ".", "persistentClass", ".", "getSimpleName", "(", ")", "+", "\".\"", "+", "propertyName", "+", "\"' is not set\"", ")", ";", "}", "}", "}" ]
Validate the schema constraints on the provided Entity instance @param entity the entity to validate
[ "Validate", "the", "schema", "constraints", "on", "the", "provided", "Entity", "instance" ]
b07763df98b9375b764e625f617a6c78df4b068d
https://github.com/icoloma/simpleds/blob/b07763df98b9375b764e625f617a6c78df4b068d/src/main/java/org/simpleds/metadata/ClassMetadata.java#L102-L109
149,720
icoloma/simpleds
src/main/java/org/simpleds/metadata/ClassMetadata.java
ClassMetadata.validateParentKey
public void validateParentKey(Key parentKey) { if (parents.isEmpty()) { if (parentKey != null) { throw new IllegalArgumentException("Specified parent key " + parentKey + ", but entity " + this.persistentClass.getSimpleName() + " is configured as a root class (missing @Id(parent)?)"); } } else { if (parentKey == null) { throw new IllegalArgumentException("Missing parent key for entity " + this.persistentClass.getSimpleName() + ". Expected: " + Joiner.on(", ").join(parents)); } if (!parents.contains(parentKey.getKind())) { throw new IllegalArgumentException("Specified parent key " + parentKey + ", but entity " + this.persistentClass.getSimpleName() + " expects parents with type " + Joiner.on(", ").join(parents)); } } }
java
public void validateParentKey(Key parentKey) { if (parents.isEmpty()) { if (parentKey != null) { throw new IllegalArgumentException("Specified parent key " + parentKey + ", but entity " + this.persistentClass.getSimpleName() + " is configured as a root class (missing @Id(parent)?)"); } } else { if (parentKey == null) { throw new IllegalArgumentException("Missing parent key for entity " + this.persistentClass.getSimpleName() + ". Expected: " + Joiner.on(", ").join(parents)); } if (!parents.contains(parentKey.getKind())) { throw new IllegalArgumentException("Specified parent key " + parentKey + ", but entity " + this.persistentClass.getSimpleName() + " expects parents with type " + Joiner.on(", ").join(parents)); } } }
[ "public", "void", "validateParentKey", "(", "Key", "parentKey", ")", "{", "if", "(", "parents", ".", "isEmpty", "(", ")", ")", "{", "if", "(", "parentKey", "!=", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Specified parent key \"", "+", "parentKey", "+", "\", but entity \"", "+", "this", ".", "persistentClass", ".", "getSimpleName", "(", ")", "+", "\" is configured as a root class (missing @Id(parent)?)\"", ")", ";", "}", "}", "else", "{", "if", "(", "parentKey", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Missing parent key for entity \"", "+", "this", ".", "persistentClass", ".", "getSimpleName", "(", ")", "+", "\". Expected: \"", "+", "Joiner", ".", "on", "(", "\", \"", ")", ".", "join", "(", "parents", ")", ")", ";", "}", "if", "(", "!", "parents", ".", "contains", "(", "parentKey", ".", "getKind", "(", ")", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Specified parent key \"", "+", "parentKey", "+", "\", but entity \"", "+", "this", ".", "persistentClass", ".", "getSimpleName", "(", ")", "+", "\" expects parents with type \"", "+", "Joiner", ".", "on", "(", "\", \"", ")", ".", "join", "(", "parents", ")", ")", ";", "}", "}", "}" ]
Validates the parent key when inserting
[ "Validates", "the", "parent", "key", "when", "inserting" ]
b07763df98b9375b764e625f617a6c78df4b068d
https://github.com/icoloma/simpleds/blob/b07763df98b9375b764e625f617a6c78df4b068d/src/main/java/org/simpleds/metadata/ClassMetadata.java#L183-L196
149,721
eurekaclinical/javautil
src/main/java/org/arp/javautil/collections/Collections.java
Collections.putSetAll
public static <K, V> void putSetAll(Map<K, Set<V>> map, Map<K, Set<V>> other) { for (Map.Entry<K, Set<V>> me : other.entrySet()) { putSetMult(map, me.getKey(), me.getValue()); } }
java
public static <K, V> void putSetAll(Map<K, Set<V>> map, Map<K, Set<V>> other) { for (Map.Entry<K, Set<V>> me : other.entrySet()) { putSetMult(map, me.getKey(), me.getValue()); } }
[ "public", "static", "<", "K", ",", "V", ">", "void", "putSetAll", "(", "Map", "<", "K", ",", "Set", "<", "V", ">", ">", "map", ",", "Map", "<", "K", ",", "Set", "<", "V", ">", ">", "other", ")", "{", "for", "(", "Map", ".", "Entry", "<", "K", ",", "Set", "<", "V", ">", ">", "me", ":", "other", ".", "entrySet", "(", ")", ")", "{", "putSetMult", "(", "map", ",", "me", ".", "getKey", "(", ")", ",", "me", ".", "getValue", "(", ")", ")", ";", "}", "}" ]
Copies all of the mappings from the second map to the first. The value for each key is the union of the first and second maps' values for that key. @param <K> @param <V> @param map the first {@link Map}. @param other the second {@link Map}.
[ "Copies", "all", "of", "the", "mappings", "from", "the", "second", "map", "to", "the", "first", ".", "The", "value", "for", "each", "key", "is", "the", "union", "of", "the", "first", "and", "second", "maps", "values", "for", "that", "key", "." ]
779bbc5bf096c75f8eed4f99ca45b99c1d44df43
https://github.com/eurekaclinical/javautil/blob/779bbc5bf096c75f8eed4f99ca45b99c1d44df43/src/main/java/org/arp/javautil/collections/Collections.java#L117-L121
149,722
eurekaclinical/javautil
src/main/java/org/arp/javautil/collections/Collections.java
Collections.containsAny
public static <K> boolean containsAny(Set<K> aSet, K[] arr) { for (K obj : arr) { if (aSet.contains(obj)) { return true; } } return false; }
java
public static <K> boolean containsAny(Set<K> aSet, K[] arr) { for (K obj : arr) { if (aSet.contains(obj)) { return true; } } return false; }
[ "public", "static", "<", "K", ">", "boolean", "containsAny", "(", "Set", "<", "K", ">", "aSet", ",", "K", "[", "]", "arr", ")", "{", "for", "(", "K", "obj", ":", "arr", ")", "{", "if", "(", "aSet", ".", "contains", "(", "obj", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks whether any of an array's elements are also in the provided set. @param aSet a {@link Set}. @param arr an array. @return <code>true</code> or <code>false</code>.
[ "Checks", "whether", "any", "of", "an", "array", "s", "elements", "are", "also", "in", "the", "provided", "set", "." ]
779bbc5bf096c75f8eed4f99ca45b99c1d44df43
https://github.com/eurekaclinical/javautil/blob/779bbc5bf096c75f8eed4f99ca45b99c1d44df43/src/main/java/org/arp/javautil/collections/Collections.java#L130-L137
149,723
qmetric/halreader
src/main/java/com/qmetric/hal/reader/HalReader.java
HalReader.read
public HalResource read(final Reader reader) { final ContentRepresentation readableRepresentation = representationFactory.readRepresentation(RepresentationFactory.HAL_JSON, reader); return new HalResource(objectMapper, readableRepresentation); }
java
public HalResource read(final Reader reader) { final ContentRepresentation readableRepresentation = representationFactory.readRepresentation(RepresentationFactory.HAL_JSON, reader); return new HalResource(objectMapper, readableRepresentation); }
[ "public", "HalResource", "read", "(", "final", "Reader", "reader", ")", "{", "final", "ContentRepresentation", "readableRepresentation", "=", "representationFactory", ".", "readRepresentation", "(", "RepresentationFactory", ".", "HAL_JSON", ",", "reader", ")", ";", "return", "new", "HalResource", "(", "objectMapper", ",", "readableRepresentation", ")", ";", "}" ]
Read and return HalResource @param reader Reader @return Hal resource
[ "Read", "and", "return", "HalResource" ]
584167b25ac7ae0559c6e3cdd300b8a02e59b00b
https://github.com/qmetric/halreader/blob/584167b25ac7ae0559c6e3cdd300b8a02e59b00b/src/main/java/com/qmetric/hal/reader/HalReader.java#L41-L46
149,724
dhemery/hartley
src/main/java/com/dhemery/publishing/SubscriberInspector.java
SubscriberInspector.subscriptionsOn
public Set<Method> subscriptionsOn(Object subscriber) { SubscriptionMethodFilter filter = new SubscriptionMethodFilter(); Class<?> subscriberClass = subscriber.getClass(); List<Method> methods = Arrays.asList(subscriberClass.getMethods()); Set<Method> subscriptions = new HashSet<Method>(); for (Method method : methods) { if (filter.accepts(method)) { subscriptions.add(method); } } return subscriptions; }
java
public Set<Method> subscriptionsOn(Object subscriber) { SubscriptionMethodFilter filter = new SubscriptionMethodFilter(); Class<?> subscriberClass = subscriber.getClass(); List<Method> methods = Arrays.asList(subscriberClass.getMethods()); Set<Method> subscriptions = new HashSet<Method>(); for (Method method : methods) { if (filter.accepts(method)) { subscriptions.add(method); } } return subscriptions; }
[ "public", "Set", "<", "Method", ">", "subscriptionsOn", "(", "Object", "subscriber", ")", "{", "SubscriptionMethodFilter", "filter", "=", "new", "SubscriptionMethodFilter", "(", ")", ";", "Class", "<", "?", ">", "subscriberClass", "=", "subscriber", ".", "getClass", "(", ")", ";", "List", "<", "Method", ">", "methods", "=", "Arrays", ".", "asList", "(", "subscriberClass", ".", "getMethods", "(", ")", ")", ";", "Set", "<", "Method", ">", "subscriptions", "=", "new", "HashSet", "<", "Method", ">", "(", ")", ";", "for", "(", "Method", "method", ":", "methods", ")", "{", "if", "(", "filter", ".", "accepts", "(", "method", ")", ")", "{", "subscriptions", ".", "add", "(", "method", ")", ";", "}", "}", "return", "subscriptions", ";", "}" ]
Report the subscription methods declared on the subscriber.
[ "Report", "the", "subscription", "methods", "declared", "on", "the", "subscriber", "." ]
7754bd6bc12695f2249601b8890da530a61fcf33
https://github.com/dhemery/hartley/blob/7754bd6bc12695f2249601b8890da530a61fcf33/src/main/java/com/dhemery/publishing/SubscriberInspector.java#L16-L27
149,725
trustathsh/ifmapj
src/main/java/de/hshannover/f4/trust/ifmapj/identifier/Identifiers.java
Identifiers.getExtendedIdentifierHandlerFor
private static IdentifierHandler<? extends Identifier> getExtendedIdentifierHandlerFor(Element element) { if (!checkExtendedIdentityElement(element)) { return null; } String name = element.getAttribute(IfmapStrings.IDENTITY_ATTR_NAME); Document extendedDocument; try { extendedDocument = DomHelpers.parseEscapedXmlString(name); } catch (UnmarshalException e) { return null; } Element extendedElement = extendedDocument.getDocumentElement(); String nodeName = extendedElement.getLocalName(); // try to find the most specific handler for (Entry<Class<? extends Identifier>, IdentifierHandler<? extends Identifier>> entry : sIdentifierHandlers .entrySet()) { String simpleClassName = entry.getKey().getSimpleName(); if (simpleClassName.equalsIgnoreCase(nodeName)) { return entry.getValue(); } } return null; }
java
private static IdentifierHandler<? extends Identifier> getExtendedIdentifierHandlerFor(Element element) { if (!checkExtendedIdentityElement(element)) { return null; } String name = element.getAttribute(IfmapStrings.IDENTITY_ATTR_NAME); Document extendedDocument; try { extendedDocument = DomHelpers.parseEscapedXmlString(name); } catch (UnmarshalException e) { return null; } Element extendedElement = extendedDocument.getDocumentElement(); String nodeName = extendedElement.getLocalName(); // try to find the most specific handler for (Entry<Class<? extends Identifier>, IdentifierHandler<? extends Identifier>> entry : sIdentifierHandlers .entrySet()) { String simpleClassName = entry.getKey().getSimpleName(); if (simpleClassName.equalsIgnoreCase(nodeName)) { return entry.getValue(); } } return null; }
[ "private", "static", "IdentifierHandler", "<", "?", "extends", "Identifier", ">", "getExtendedIdentifierHandlerFor", "(", "Element", "element", ")", "{", "if", "(", "!", "checkExtendedIdentityElement", "(", "element", ")", ")", "{", "return", "null", ";", "}", "String", "name", "=", "element", ".", "getAttribute", "(", "IfmapStrings", ".", "IDENTITY_ATTR_NAME", ")", ";", "Document", "extendedDocument", ";", "try", "{", "extendedDocument", "=", "DomHelpers", ".", "parseEscapedXmlString", "(", "name", ")", ";", "}", "catch", "(", "UnmarshalException", "e", ")", "{", "return", "null", ";", "}", "Element", "extendedElement", "=", "extendedDocument", ".", "getDocumentElement", "(", ")", ";", "String", "nodeName", "=", "extendedElement", ".", "getLocalName", "(", ")", ";", "// try to find the most specific handler", "for", "(", "Entry", "<", "Class", "<", "?", "extends", "Identifier", ">", ",", "IdentifierHandler", "<", "?", "extends", "Identifier", ">", ">", "entry", ":", "sIdentifierHandlers", ".", "entrySet", "(", ")", ")", "{", "String", "simpleClassName", "=", "entry", ".", "getKey", "(", ")", ".", "getSimpleName", "(", ")", ";", "if", "(", "simpleClassName", ".", "equalsIgnoreCase", "(", "nodeName", ")", ")", "{", "return", "entry", ".", "getValue", "(", ")", ";", "}", "}", "return", "null", ";", "}" ]
If the element argument is an extended identity Identifier then try to find the most specific handler for this element. Used the Element-LocalName to find the right handler. @param element @return The {@link IdentifierHandler} for the element or null.
[ "If", "the", "element", "argument", "is", "an", "extended", "identity", "Identifier", "then", "try", "to", "find", "the", "most", "specific", "handler", "for", "this", "element", ".", "Used", "the", "Element", "-", "LocalName", "to", "find", "the", "right", "handler", "." ]
44ece9e95a3d2a1b7019573ba6178598a6cbdaa3
https://github.com/trustathsh/ifmapj/blob/44ece9e95a3d2a1b7019573ba6178598a6cbdaa3/src/main/java/de/hshannover/f4/trust/ifmapj/identifier/Identifiers.java#L213-L241
149,726
trustathsh/ifmapj
src/main/java/de/hshannover/f4/trust/ifmapj/identifier/Identifiers.java
Identifiers.createArRandomUuid
public static AccessRequest createArRandomUuid(String admDom) { return new AccessRequest(java.util.UUID.randomUUID().toString(), admDom); }
java
public static AccessRequest createArRandomUuid(String admDom) { return new AccessRequest(java.util.UUID.randomUUID().toString(), admDom); }
[ "public", "static", "AccessRequest", "createArRandomUuid", "(", "String", "admDom", ")", "{", "return", "new", "AccessRequest", "(", "java", ".", "util", ".", "UUID", ".", "randomUUID", "(", ")", ".", "toString", "(", ")", ",", "admDom", ")", ";", "}" ]
Create an access-request identifier with an random UUID as name and administrative-domain as given. @return the new {@link AccessRequest} instance.
[ "Create", "an", "access", "-", "request", "identifier", "with", "an", "random", "UUID", "as", "name", "and", "administrative", "-", "domain", "as", "given", "." ]
44ece9e95a3d2a1b7019573ba6178598a6cbdaa3
https://github.com/trustathsh/ifmapj/blob/44ece9e95a3d2a1b7019573ba6178598a6cbdaa3/src/main/java/de/hshannover/f4/trust/ifmapj/identifier/Identifiers.java#L361-L363
149,727
trustathsh/ifmapj
src/main/java/de/hshannover/f4/trust/ifmapj/identifier/Identifiers.java
Identifiers.createOtherIdentity
public static Identity createOtherIdentity(String name, String admDom, String otherTypeDef) { return createIdentity(IdentityType.other, name, admDom, otherTypeDef); }
java
public static Identity createOtherIdentity(String name, String admDom, String otherTypeDef) { return createIdentity(IdentityType.other, name, admDom, otherTypeDef); }
[ "public", "static", "Identity", "createOtherIdentity", "(", "String", "name", ",", "String", "admDom", ",", "String", "otherTypeDef", ")", "{", "return", "createIdentity", "(", "IdentityType", ".", "other", ",", "name", ",", "admDom", ",", "otherTypeDef", ")", ";", "}" ]
Create an other identity identifier. <b>Note: The type is set to {@link IdentityType#other} by default.</b> @param name the name of the identity identifier @param admDom the administrative-domain of the identity identifier @param otherTypeDef vendor specific {@link String} @return the new {@link Identity} instance
[ "Create", "an", "other", "identity", "identifier", "." ]
44ece9e95a3d2a1b7019573ba6178598a6cbdaa3
https://github.com/trustathsh/ifmapj/blob/44ece9e95a3d2a1b7019573ba6178598a6cbdaa3/src/main/java/de/hshannover/f4/trust/ifmapj/identifier/Identifiers.java#L508-L511
149,728
trustathsh/ifmapj
src/main/java/de/hshannover/f4/trust/ifmapj/identifier/Identifiers.java
Identifiers.createIp4
public static IpAddress createIp4(String value, String admDom) { return createIp(IpAddressType.IPv4, value, admDom); }
java
public static IpAddress createIp4(String value, String admDom) { return createIp(IpAddressType.IPv4, value, admDom); }
[ "public", "static", "IpAddress", "createIp4", "(", "String", "value", ",", "String", "admDom", ")", "{", "return", "createIp", "(", "IpAddressType", ".", "IPv4", ",", "value", ",", "admDom", ")", ";", "}" ]
Create an ip-address identifier for IPv4 with the given value and the given administrative-domain. @param value a {@link String} that represents a valid IPv4 address @param admDom the administrative-domain @return the new ip-address identifier
[ "Create", "an", "ip", "-", "address", "identifier", "for", "IPv4", "with", "the", "given", "value", "and", "the", "given", "administrative", "-", "domain", "." ]
44ece9e95a3d2a1b7019573ba6178598a6cbdaa3
https://github.com/trustathsh/ifmapj/blob/44ece9e95a3d2a1b7019573ba6178598a6cbdaa3/src/main/java/de/hshannover/f4/trust/ifmapj/identifier/Identifiers.java#L616-L618
149,729
trustathsh/ifmapj
src/main/java/de/hshannover/f4/trust/ifmapj/identifier/Identifiers.java
Identifiers.createIp6
public static IpAddress createIp6(String value, String admDom) { return createIp(IpAddressType.IPv6, value, admDom); }
java
public static IpAddress createIp6(String value, String admDom) { return createIp(IpAddressType.IPv6, value, admDom); }
[ "public", "static", "IpAddress", "createIp6", "(", "String", "value", ",", "String", "admDom", ")", "{", "return", "createIp", "(", "IpAddressType", ".", "IPv6", ",", "value", ",", "admDom", ")", ";", "}" ]
Create an ip-address identifier for IPv6 with the given parameters. @param value a {@link String} that represents a valid IPv4 address @param admDom the administrative-domain @return the new ip-address identifier
[ "Create", "an", "ip", "-", "address", "identifier", "for", "IPv6", "with", "the", "given", "parameters", "." ]
44ece9e95a3d2a1b7019573ba6178598a6cbdaa3
https://github.com/trustathsh/ifmapj/blob/44ece9e95a3d2a1b7019573ba6178598a6cbdaa3/src/main/java/de/hshannover/f4/trust/ifmapj/identifier/Identifiers.java#L637-L639
149,730
trustathsh/ifmapj
src/main/java/de/hshannover/f4/trust/ifmapj/identifier/Identifiers.java
Identifiers.createIp
public static IpAddress createIp(IpAddressType type, String value, String admDom) { return new IpAddress(type, value, admDom); }
java
public static IpAddress createIp(IpAddressType type, String value, String admDom) { return new IpAddress(type, value, admDom); }
[ "public", "static", "IpAddress", "createIp", "(", "IpAddressType", "type", ",", "String", "value", ",", "String", "admDom", ")", "{", "return", "new", "IpAddress", "(", "type", ",", "value", ",", "admDom", ")", ";", "}" ]
Create an ip-address identifier with the given parameters. @param type the type of the ip-address identifier @param value a {@link String} that represents a valid IPv4/6 address @param admDom the administrative-domain @return the new ip-address identifier
[ "Create", "an", "ip", "-", "address", "identifier", "with", "the", "given", "parameters", "." ]
44ece9e95a3d2a1b7019573ba6178598a6cbdaa3
https://github.com/trustathsh/ifmapj/blob/44ece9e95a3d2a1b7019573ba6178598a6cbdaa3/src/main/java/de/hshannover/f4/trust/ifmapj/identifier/Identifiers.java#L649-L651
149,731
eurekaclinical/eurekaclinical-standard-apis
src/main/java/org/eurekaclinical/standardapis/dao/DatabaseSupport.java
DatabaseSupport.getAll
@SuppressWarnings("unchecked") public <T> List<T> getAll(Class<T> entityCls) { if (entityCls == null) { throw new IllegalArgumentException("entityCls cannot be null"); } EntityManager entityManager = this.entityManagerProvider.get(); CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery<T> criteriaQuery = builder.createQuery(entityCls); criteriaQuery.from(entityCls); TypedQuery<T> typedQuery = entityManager.createQuery(criteriaQuery); List<T> results = typedQuery.getResultList(); return results; }
java
@SuppressWarnings("unchecked") public <T> List<T> getAll(Class<T> entityCls) { if (entityCls == null) { throw new IllegalArgumentException("entityCls cannot be null"); } EntityManager entityManager = this.entityManagerProvider.get(); CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery<T> criteriaQuery = builder.createQuery(entityCls); criteriaQuery.from(entityCls); TypedQuery<T> typedQuery = entityManager.createQuery(criteriaQuery); List<T> results = typedQuery.getResultList(); return results; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", ">", "List", "<", "T", ">", "getAll", "(", "Class", "<", "T", ">", "entityCls", ")", "{", "if", "(", "entityCls", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"entityCls cannot be null\"", ")", ";", "}", "EntityManager", "entityManager", "=", "this", ".", "entityManagerProvider", ".", "get", "(", ")", ";", "CriteriaBuilder", "builder", "=", "entityManager", ".", "getCriteriaBuilder", "(", ")", ";", "CriteriaQuery", "<", "T", ">", "criteriaQuery", "=", "builder", ".", "createQuery", "(", "entityCls", ")", ";", "criteriaQuery", ".", "from", "(", "entityCls", ")", ";", "TypedQuery", "<", "T", ">", "typedQuery", "=", "entityManager", ".", "createQuery", "(", "criteriaQuery", ")", ";", "List", "<", "T", ">", "results", "=", "typedQuery", ".", "getResultList", "(", ")", ";", "return", "results", ";", "}" ]
Gets every instance of the specified entity in the database. @param <T> the type of the entity. @param entityCls the class of the specified entity. Cannot be <code>null</code>. @return the instances requested. Guaranteed not <code>null</code>.
[ "Gets", "every", "instance", "of", "the", "specified", "entity", "in", "the", "database", "." ]
690036dde82a4f2c2106d32403cdf1c713429377
https://github.com/eurekaclinical/eurekaclinical-standard-apis/blob/690036dde82a4f2c2106d32403cdf1c713429377/src/main/java/org/eurekaclinical/standardapis/dao/DatabaseSupport.java#L129-L143
149,732
eurekaclinical/eurekaclinical-standard-apis
src/main/java/org/eurekaclinical/standardapis/dao/DatabaseSupport.java
DatabaseSupport.getCurrent
public <T extends HistoricalEntity<?>> List<T> getCurrent(Class<T> historicalEntityCls) { EntityManager entityManager = this.entityManagerProvider.get(); CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery<T> criteriaQuery = builder.createQuery(historicalEntityCls); Root<T> root = criteriaQuery.from(historicalEntityCls); criteriaQuery.where(expiredAt(root, builder)); TypedQuery<T> typedQuery = entityManager.createQuery(criteriaQuery); return typedQuery.getResultList(); }
java
public <T extends HistoricalEntity<?>> List<T> getCurrent(Class<T> historicalEntityCls) { EntityManager entityManager = this.entityManagerProvider.get(); CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery<T> criteriaQuery = builder.createQuery(historicalEntityCls); Root<T> root = criteriaQuery.from(historicalEntityCls); criteriaQuery.where(expiredAt(root, builder)); TypedQuery<T> typedQuery = entityManager.createQuery(criteriaQuery); return typedQuery.getResultList(); }
[ "public", "<", "T", "extends", "HistoricalEntity", "<", "?", ">", ">", "List", "<", "T", ">", "getCurrent", "(", "Class", "<", "T", ">", "historicalEntityCls", ")", "{", "EntityManager", "entityManager", "=", "this", ".", "entityManagerProvider", ".", "get", "(", ")", ";", "CriteriaBuilder", "builder", "=", "entityManager", ".", "getCriteriaBuilder", "(", ")", ";", "CriteriaQuery", "<", "T", ">", "criteriaQuery", "=", "builder", ".", "createQuery", "(", "historicalEntityCls", ")", ";", "Root", "<", "T", ">", "root", "=", "criteriaQuery", ".", "from", "(", "historicalEntityCls", ")", ";", "criteriaQuery", ".", "where", "(", "expiredAt", "(", "root", ",", "builder", ")", ")", ";", "TypedQuery", "<", "T", ">", "typedQuery", "=", "entityManager", ".", "createQuery", "(", "criteriaQuery", ")", ";", "return", "typedQuery", ".", "getResultList", "(", ")", ";", "}" ]
Gets every instance of the specified historical entity in the database. @param <T> the type of the entity. @param historicalEntityCls the class of the specified historical entity. The entity must be a subtype of {@link HistoricalEntity}. Cannot be <code>null</code>. @return the instances requested. Guaranteed not <code>null</code>.
[ "Gets", "every", "instance", "of", "the", "specified", "historical", "entity", "in", "the", "database", "." ]
690036dde82a4f2c2106d32403cdf1c713429377
https://github.com/eurekaclinical/eurekaclinical-standard-apis/blob/690036dde82a4f2c2106d32403cdf1c713429377/src/main/java/org/eurekaclinical/standardapis/dao/DatabaseSupport.java#L182-L190
149,733
eurekaclinical/eurekaclinical-standard-apis
src/main/java/org/eurekaclinical/standardapis/dao/DatabaseSupport.java
DatabaseSupport.getCurrentUniqueByAttribute
public <T extends HistoricalEntity<?>, Y> T getCurrentUniqueByAttribute( Class<T> historicalEntityCls, SingularAttribute<T, Y> attribute, Y value) { EntityManager entityManager = this.entityManagerProvider.get(); CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery<T> criteriaQuery = builder.createQuery(historicalEntityCls); Root<T> root = criteriaQuery.from(historicalEntityCls); Predicate whereClause = builder.and( builder.equal(root.get(attribute), value), expiredAt(root, builder)); criteriaQuery.where(whereClause); TypedQuery<T> query = entityManager.createQuery(criteriaQuery); T result = null; try { result = query.getSingleResult(); } catch (NonUniqueResultException nure) { LOGGER.warn("Result not unique for {}: {} = {}", historicalEntityCls.getName(), attribute.getName(), value); result = query.getResultList().get(0); } catch (NoResultException nre) { LOGGER.debug("Result not existant for {}: {} = {}", historicalEntityCls.getName(), attribute.getName(), value); } return result; }
java
public <T extends HistoricalEntity<?>, Y> T getCurrentUniqueByAttribute( Class<T> historicalEntityCls, SingularAttribute<T, Y> attribute, Y value) { EntityManager entityManager = this.entityManagerProvider.get(); CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery<T> criteriaQuery = builder.createQuery(historicalEntityCls); Root<T> root = criteriaQuery.from(historicalEntityCls); Predicate whereClause = builder.and( builder.equal(root.get(attribute), value), expiredAt(root, builder)); criteriaQuery.where(whereClause); TypedQuery<T> query = entityManager.createQuery(criteriaQuery); T result = null; try { result = query.getSingleResult(); } catch (NonUniqueResultException nure) { LOGGER.warn("Result not unique for {}: {} = {}", historicalEntityCls.getName(), attribute.getName(), value); result = query.getResultList().get(0); } catch (NoResultException nre) { LOGGER.debug("Result not existant for {}: {} = {}", historicalEntityCls.getName(), attribute.getName(), value); } return result; }
[ "public", "<", "T", "extends", "HistoricalEntity", "<", "?", ">", ",", "Y", ">", "T", "getCurrentUniqueByAttribute", "(", "Class", "<", "T", ">", "historicalEntityCls", ",", "SingularAttribute", "<", "T", ",", "Y", ">", "attribute", ",", "Y", "value", ")", "{", "EntityManager", "entityManager", "=", "this", ".", "entityManagerProvider", ".", "get", "(", ")", ";", "CriteriaBuilder", "builder", "=", "entityManager", ".", "getCriteriaBuilder", "(", ")", ";", "CriteriaQuery", "<", "T", ">", "criteriaQuery", "=", "builder", ".", "createQuery", "(", "historicalEntityCls", ")", ";", "Root", "<", "T", ">", "root", "=", "criteriaQuery", ".", "from", "(", "historicalEntityCls", ")", ";", "Predicate", "whereClause", "=", "builder", ".", "and", "(", "builder", ".", "equal", "(", "root", ".", "get", "(", "attribute", ")", ",", "value", ")", ",", "expiredAt", "(", "root", ",", "builder", ")", ")", ";", "criteriaQuery", ".", "where", "(", "whereClause", ")", ";", "TypedQuery", "<", "T", ">", "query", "=", "entityManager", ".", "createQuery", "(", "criteriaQuery", ")", ";", "T", "result", "=", "null", ";", "try", "{", "result", "=", "query", ".", "getSingleResult", "(", ")", ";", "}", "catch", "(", "NonUniqueResultException", "nure", ")", "{", "LOGGER", ".", "warn", "(", "\"Result not unique for {}: {} = {}\"", ",", "historicalEntityCls", ".", "getName", "(", ")", ",", "attribute", ".", "getName", "(", ")", ",", "value", ")", ";", "result", "=", "query", ".", "getResultList", "(", ")", ".", "get", "(", "0", ")", ";", "}", "catch", "(", "NoResultException", "nre", ")", "{", "LOGGER", ".", "debug", "(", "\"Result not existant for {}: {} = {}\"", ",", "historicalEntityCls", ".", "getName", "(", ")", ",", "attribute", ".", "getName", "(", ")", ",", "value", ")", ";", "}", "return", "result", ";", "}" ]
Gets the instance of the specified historical entity in the database that has the given value of the given attribute. @param <T> the type of the entity.The entity must be a subtype of {@link HistoricalEntity}. Cannot be <code>null</code>. @param <Y> the attribute's type. @param historicalEntityCls the class of the specified historical entity. @param attribute the attribute. Cannot be <code>null</code>. @param value the value. Cannot be <code>null</code>. @return the instance requested. Guaranteed not <code>null</code>.
[ "Gets", "the", "instance", "of", "the", "specified", "historical", "entity", "in", "the", "database", "that", "has", "the", "given", "value", "of", "the", "given", "attribute", "." ]
690036dde82a4f2c2106d32403cdf1c713429377
https://github.com/eurekaclinical/eurekaclinical-standard-apis/blob/690036dde82a4f2c2106d32403cdf1c713429377/src/main/java/org/eurekaclinical/standardapis/dao/DatabaseSupport.java#L205-L229
149,734
eurekaclinical/eurekaclinical-standard-apis
src/main/java/org/eurekaclinical/standardapis/dao/DatabaseSupport.java
DatabaseSupport.getCurrentListByAttribute
public <T extends HistoricalEntity<?>, Y> List<T> getCurrentListByAttribute( Class<T> historicalEntityCls, SingularAttribute<T, Y> attribute, Y value) { EntityManager entityManager = this.entityManagerProvider.get(); CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery<T> criteriaQuery = builder.createQuery(historicalEntityCls); Root<T> root = criteriaQuery.from(historicalEntityCls); Predicate whereClause = builder.and( builder.equal(root.get(attribute), value), expiredAt(root, builder)); criteriaQuery.where(whereClause); TypedQuery<T> typedQuery = entityManager.createQuery(criteriaQuery); return typedQuery.getResultList(); }
java
public <T extends HistoricalEntity<?>, Y> List<T> getCurrentListByAttribute( Class<T> historicalEntityCls, SingularAttribute<T, Y> attribute, Y value) { EntityManager entityManager = this.entityManagerProvider.get(); CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery<T> criteriaQuery = builder.createQuery(historicalEntityCls); Root<T> root = criteriaQuery.from(historicalEntityCls); Predicate whereClause = builder.and( builder.equal(root.get(attribute), value), expiredAt(root, builder)); criteriaQuery.where(whereClause); TypedQuery<T> typedQuery = entityManager.createQuery(criteriaQuery); return typedQuery.getResultList(); }
[ "public", "<", "T", "extends", "HistoricalEntity", "<", "?", ">", ",", "Y", ">", "List", "<", "T", ">", "getCurrentListByAttribute", "(", "Class", "<", "T", ">", "historicalEntityCls", ",", "SingularAttribute", "<", "T", ",", "Y", ">", "attribute", ",", "Y", "value", ")", "{", "EntityManager", "entityManager", "=", "this", ".", "entityManagerProvider", ".", "get", "(", ")", ";", "CriteriaBuilder", "builder", "=", "entityManager", ".", "getCriteriaBuilder", "(", ")", ";", "CriteriaQuery", "<", "T", ">", "criteriaQuery", "=", "builder", ".", "createQuery", "(", "historicalEntityCls", ")", ";", "Root", "<", "T", ">", "root", "=", "criteriaQuery", ".", "from", "(", "historicalEntityCls", ")", ";", "Predicate", "whereClause", "=", "builder", ".", "and", "(", "builder", ".", "equal", "(", "root", ".", "get", "(", "attribute", ")", ",", "value", ")", ",", "expiredAt", "(", "root", ",", "builder", ")", ")", ";", "criteriaQuery", ".", "where", "(", "whereClause", ")", ";", "TypedQuery", "<", "T", ">", "typedQuery", "=", "entityManager", ".", "createQuery", "(", "criteriaQuery", ")", ";", "return", "typedQuery", ".", "getResultList", "(", ")", ";", "}" ]
Gets every instance of the specified historical entity in the database that has the given value of the given attribute. @param <T> the type of the entity.The entity must be a subtype of {@link HistoricalEntity}. Cannot be <code>null</code>. @param <Y> the attribute's type. @param historicalEntityCls the class of the specified historical entity. @param attribute the attribute. Cannot be <code>null</code>. @param value the value. Cannot be <code>null</code>. @return the instance requested. Guaranteed not <code>null</code>.
[ "Gets", "every", "instance", "of", "the", "specified", "historical", "entity", "in", "the", "database", "that", "has", "the", "given", "value", "of", "the", "given", "attribute", "." ]
690036dde82a4f2c2106d32403cdf1c713429377
https://github.com/eurekaclinical/eurekaclinical-standard-apis/blob/690036dde82a4f2c2106d32403cdf1c713429377/src/main/java/org/eurekaclinical/standardapis/dao/DatabaseSupport.java#L244-L257
149,735
eurekaclinical/eurekaclinical-standard-apis
src/main/java/org/eurekaclinical/standardapis/dao/DatabaseSupport.java
DatabaseSupport.getUniqueByAttribute
public <T, Y> T getUniqueByAttribute(Class<T> entityCls, String attributeName, Y value) { if (entityCls == null) { throw new IllegalArgumentException("entityCls cannot be null"); } if (attributeName == null) { throw new IllegalArgumentException("attributeName cannot be null"); } TypedQuery<T> query = createTypedQuery(entityCls, attributeName, value); T result = null; try { result = query.getSingleResult(); } catch (NonUniqueResultException nure) { LOGGER.warn("Result not unique for {}: {} = {}", entityCls.getName(), attributeName, value); result = query.getResultList().get(0); } catch (NoResultException nre) { LOGGER.debug("Result not existant for {}: {} = {}", entityCls.getName(), attributeName, value); } return result; }
java
public <T, Y> T getUniqueByAttribute(Class<T> entityCls, String attributeName, Y value) { if (entityCls == null) { throw new IllegalArgumentException("entityCls cannot be null"); } if (attributeName == null) { throw new IllegalArgumentException("attributeName cannot be null"); } TypedQuery<T> query = createTypedQuery(entityCls, attributeName, value); T result = null; try { result = query.getSingleResult(); } catch (NonUniqueResultException nure) { LOGGER.warn("Result not unique for {}: {} = {}", entityCls.getName(), attributeName, value); result = query.getResultList().get(0); } catch (NoResultException nre) { LOGGER.debug("Result not existant for {}: {} = {}", entityCls.getName(), attributeName, value); } return result; }
[ "public", "<", "T", ",", "Y", ">", "T", "getUniqueByAttribute", "(", "Class", "<", "T", ">", "entityCls", ",", "String", "attributeName", ",", "Y", "value", ")", "{", "if", "(", "entityCls", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"entityCls cannot be null\"", ")", ";", "}", "if", "(", "attributeName", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"attributeName cannot be null\"", ")", ";", "}", "TypedQuery", "<", "T", ">", "query", "=", "createTypedQuery", "(", "entityCls", ",", "attributeName", ",", "value", ")", ";", "T", "result", "=", "null", ";", "try", "{", "result", "=", "query", ".", "getSingleResult", "(", ")", ";", "}", "catch", "(", "NonUniqueResultException", "nure", ")", "{", "LOGGER", ".", "warn", "(", "\"Result not unique for {}: {} = {}\"", ",", "entityCls", ".", "getName", "(", ")", ",", "attributeName", ",", "value", ")", ";", "result", "=", "query", ".", "getResultList", "(", ")", ".", "get", "(", "0", ")", ";", "}", "catch", "(", "NoResultException", "nre", ")", "{", "LOGGER", ".", "debug", "(", "\"Result not existant for {}: {} = {}\"", ",", "entityCls", ".", "getName", "(", ")", ",", "attributeName", ",", "value", ")", ";", "}", "return", "result", ";", "}" ]
Executes a query for the entity with the given attribute value. This method assumes that at most one instance of the given entity will be a match. This typically is used with attributes with a uniqueness constraint. @param <T> the type of the entity. @param <Y> the type of the attribute. @param entityCls the entity class. Cannot be <code>null</code>. @param attributeName the name of the attribute. Cannot be <code>null</code>. @param value the value. If there is more than one matching instance, only the first will be returned, and a warning will be logged. @return the matching instance, or <code>null</code> if there is none.
[ "Executes", "a", "query", "for", "the", "entity", "with", "the", "given", "attribute", "value", ".", "This", "method", "assumes", "that", "at", "most", "one", "instance", "of", "the", "given", "entity", "will", "be", "a", "match", ".", "This", "typically", "is", "used", "with", "attributes", "with", "a", "uniqueness", "constraint", "." ]
690036dde82a4f2c2106d32403cdf1c713429377
https://github.com/eurekaclinical/eurekaclinical-standard-apis/blob/690036dde82a4f2c2106d32403cdf1c713429377/src/main/java/org/eurekaclinical/standardapis/dao/DatabaseSupport.java#L319-L340
149,736
eurekaclinical/eurekaclinical-standard-apis
src/main/java/org/eurekaclinical/standardapis/dao/DatabaseSupport.java
DatabaseSupport.getListByAttribute
public <T, Y> List<T> getListByAttribute( Class<T> entityCls, SingularAttribute<T, Y> attribute, Y value) { if (entityCls == null) { throw new IllegalArgumentException("entityCls cannot be null"); } if (attribute == null) { throw new IllegalArgumentException("attribute cannot be null"); } TypedQuery<T> query = createTypedQuery(entityCls, attribute, value); return query.getResultList(); }
java
public <T, Y> List<T> getListByAttribute( Class<T> entityCls, SingularAttribute<T, Y> attribute, Y value) { if (entityCls == null) { throw new IllegalArgumentException("entityCls cannot be null"); } if (attribute == null) { throw new IllegalArgumentException("attribute cannot be null"); } TypedQuery<T> query = createTypedQuery(entityCls, attribute, value); return query.getResultList(); }
[ "public", "<", "T", ",", "Y", ">", "List", "<", "T", ">", "getListByAttribute", "(", "Class", "<", "T", ">", "entityCls", ",", "SingularAttribute", "<", "T", ",", "Y", ">", "attribute", ",", "Y", "value", ")", "{", "if", "(", "entityCls", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"entityCls cannot be null\"", ")", ";", "}", "if", "(", "attribute", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"attribute cannot be null\"", ")", ";", "}", "TypedQuery", "<", "T", ">", "query", "=", "createTypedQuery", "(", "entityCls", ",", "attribute", ",", "value", ")", ";", "return", "query", ".", "getResultList", "(", ")", ";", "}" ]
Executes a query for the entities that have the specified value of the given attribute. @param <T> the type of the entity. @param <Y> the type of the attribute. @param entityCls the entity class. Cannot be <code>null</code>. @param attribute the attribute. Cannot be <code>null</code>. @param value the value. @return the matching entities. Guaranteed not <code>null</code>.
[ "Executes", "a", "query", "for", "the", "entities", "that", "have", "the", "specified", "value", "of", "the", "given", "attribute", "." ]
690036dde82a4f2c2106d32403cdf1c713429377
https://github.com/eurekaclinical/eurekaclinical-standard-apis/blob/690036dde82a4f2c2106d32403cdf1c713429377/src/main/java/org/eurekaclinical/standardapis/dao/DatabaseSupport.java#L354-L364
149,737
eurekaclinical/eurekaclinical-standard-apis
src/main/java/org/eurekaclinical/standardapis/dao/DatabaseSupport.java
DatabaseSupport.getListByAttributeIn
public <T, Y> List<T> getListByAttributeIn(Class<T> entityCls, SingularAttribute<T, Y> attribute, List<Y> values) { if (entityCls == null) { throw new IllegalArgumentException("entityCls cannot be null"); } if (attribute == null) { throw new IllegalArgumentException("attribute cannot be null"); } TypedQuery<T> query = createTypedQueryIn(entityCls, attribute, values); return query.getResultList(); }
java
public <T, Y> List<T> getListByAttributeIn(Class<T> entityCls, SingularAttribute<T, Y> attribute, List<Y> values) { if (entityCls == null) { throw new IllegalArgumentException("entityCls cannot be null"); } if (attribute == null) { throw new IllegalArgumentException("attribute cannot be null"); } TypedQuery<T> query = createTypedQueryIn(entityCls, attribute, values); return query.getResultList(); }
[ "public", "<", "T", ",", "Y", ">", "List", "<", "T", ">", "getListByAttributeIn", "(", "Class", "<", "T", ">", "entityCls", ",", "SingularAttribute", "<", "T", ",", "Y", ">", "attribute", ",", "List", "<", "Y", ">", "values", ")", "{", "if", "(", "entityCls", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"entityCls cannot be null\"", ")", ";", "}", "if", "(", "attribute", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"attribute cannot be null\"", ")", ";", "}", "TypedQuery", "<", "T", ">", "query", "=", "createTypedQueryIn", "(", "entityCls", ",", "attribute", ",", "values", ")", ";", "return", "query", ".", "getResultList", "(", ")", ";", "}" ]
Executes a query for entities that have any of the given attribute values. @param <T> the type of the entity. @param <Y> the type of the attribute. @param entityCls the entity class. Cannot be <code>null</code>. @param attribute the attribute. Cannot be <code>null</code>. @param values the values. @return the matching entities. Guaranteed not <code>null</code>.
[ "Executes", "a", "query", "for", "entities", "that", "have", "any", "of", "the", "given", "attribute", "values", "." ]
690036dde82a4f2c2106d32403cdf1c713429377
https://github.com/eurekaclinical/eurekaclinical-standard-apis/blob/690036dde82a4f2c2106d32403cdf1c713429377/src/main/java/org/eurekaclinical/standardapis/dao/DatabaseSupport.java#L408-L419
149,738
eurekaclinical/eurekaclinical-standard-apis
src/main/java/org/eurekaclinical/standardapis/dao/DatabaseSupport.java
DatabaseSupport.createTypedQueryIn
private <T, Y> TypedQuery<T> createTypedQueryIn(Class<T> entityCls, SingularAttribute<T, Y> attribute, List<Y> values) { EntityManager entityManager = this.entityManagerProvider.get(); CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery<T> criteriaQuery = builder.createQuery(entityCls); Root<T> root = criteriaQuery.from(entityCls); Path<Y> path = root.get(attribute); CriteriaBuilder.In<Y> in = builder.in(path); if (values != null) { for (Y val : values) { in.value(val); } } return entityManager.createQuery(criteriaQuery.where(in)); }
java
private <T, Y> TypedQuery<T> createTypedQueryIn(Class<T> entityCls, SingularAttribute<T, Y> attribute, List<Y> values) { EntityManager entityManager = this.entityManagerProvider.get(); CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery<T> criteriaQuery = builder.createQuery(entityCls); Root<T> root = criteriaQuery.from(entityCls); Path<Y> path = root.get(attribute); CriteriaBuilder.In<Y> in = builder.in(path); if (values != null) { for (Y val : values) { in.value(val); } } return entityManager.createQuery(criteriaQuery.where(in)); }
[ "private", "<", "T", ",", "Y", ">", "TypedQuery", "<", "T", ">", "createTypedQueryIn", "(", "Class", "<", "T", ">", "entityCls", ",", "SingularAttribute", "<", "T", ",", "Y", ">", "attribute", ",", "List", "<", "Y", ">", "values", ")", "{", "EntityManager", "entityManager", "=", "this", ".", "entityManagerProvider", ".", "get", "(", ")", ";", "CriteriaBuilder", "builder", "=", "entityManager", ".", "getCriteriaBuilder", "(", ")", ";", "CriteriaQuery", "<", "T", ">", "criteriaQuery", "=", "builder", ".", "createQuery", "(", "entityCls", ")", ";", "Root", "<", "T", ">", "root", "=", "criteriaQuery", ".", "from", "(", "entityCls", ")", ";", "Path", "<", "Y", ">", "path", "=", "root", ".", "get", "(", "attribute", ")", ";", "CriteriaBuilder", ".", "In", "<", "Y", ">", "in", "=", "builder", ".", "in", "(", "path", ")", ";", "if", "(", "values", "!=", "null", ")", "{", "for", "(", "Y", "val", ":", "values", ")", "{", "in", ".", "value", "(", "val", ")", ";", "}", "}", "return", "entityManager", ".", "createQuery", "(", "criteriaQuery", ".", "where", "(", "in", ")", ")", ";", "}" ]
Creates a typed query for entities that match any of the specified values of the given attribute. @param <T> the type of the entity class. @param <Y> @param entityCls @param attribute @param values @return
[ "Creates", "a", "typed", "query", "for", "entities", "that", "match", "any", "of", "the", "specified", "values", "of", "the", "given", "attribute", "." ]
690036dde82a4f2c2106d32403cdf1c713429377
https://github.com/eurekaclinical/eurekaclinical-standard-apis/blob/690036dde82a4f2c2106d32403cdf1c713429377/src/main/java/org/eurekaclinical/standardapis/dao/DatabaseSupport.java#L542-L556
149,739
eurekaclinical/eurekaclinical-standard-apis
src/main/java/org/eurekaclinical/standardapis/dao/DatabaseSupport.java
DatabaseSupport.createTypedQuery
private <T, Y> TypedQuery<T> createTypedQuery(Class<T> entityCls, SingularAttribute<T, Y> attribute, Y value) { EntityManager entityManager = this.entityManagerProvider.get(); CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery<T> criteriaQuery = builder.createQuery(entityCls); Root<T> root = criteriaQuery.from(entityCls); Path<Y> path = root.get(attribute); return entityManager.createQuery(criteriaQuery.where( builder.equal(path, value))); }
java
private <T, Y> TypedQuery<T> createTypedQuery(Class<T> entityCls, SingularAttribute<T, Y> attribute, Y value) { EntityManager entityManager = this.entityManagerProvider.get(); CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery<T> criteriaQuery = builder.createQuery(entityCls); Root<T> root = criteriaQuery.from(entityCls); Path<Y> path = root.get(attribute); return entityManager.createQuery(criteriaQuery.where( builder.equal(path, value))); }
[ "private", "<", "T", ",", "Y", ">", "TypedQuery", "<", "T", ">", "createTypedQuery", "(", "Class", "<", "T", ">", "entityCls", ",", "SingularAttribute", "<", "T", ",", "Y", ">", "attribute", ",", "Y", "value", ")", "{", "EntityManager", "entityManager", "=", "this", ".", "entityManagerProvider", ".", "get", "(", ")", ";", "CriteriaBuilder", "builder", "=", "entityManager", ".", "getCriteriaBuilder", "(", ")", ";", "CriteriaQuery", "<", "T", ">", "criteriaQuery", "=", "builder", ".", "createQuery", "(", "entityCls", ")", ";", "Root", "<", "T", ">", "root", "=", "criteriaQuery", ".", "from", "(", "entityCls", ")", ";", "Path", "<", "Y", ">", "path", "=", "root", ".", "get", "(", "attribute", ")", ";", "return", "entityManager", ".", "createQuery", "(", "criteriaQuery", ".", "where", "(", "builder", ".", "equal", "(", "path", ",", "value", ")", ")", ")", ";", "}" ]
Creates a typed query for entities that have the given attribute value. @param <T> the type of the entity class. @param <Y> the type of the target attribute and target value. @param attribute the attribute to compare. @param value the target value for the given attribute. @return a typed query that contains the given criteria.
[ "Creates", "a", "typed", "query", "for", "entities", "that", "have", "the", "given", "attribute", "value", "." ]
690036dde82a4f2c2106d32403cdf1c713429377
https://github.com/eurekaclinical/eurekaclinical-standard-apis/blob/690036dde82a4f2c2106d32403cdf1c713429377/src/main/java/org/eurekaclinical/standardapis/dao/DatabaseSupport.java#L567-L576
149,740
eurekaclinical/eurekaclinical-standard-apis
src/main/java/org/eurekaclinical/standardapis/dao/DatabaseSupport.java
DatabaseSupport.createTypedQuery
private <T, Y extends Number> TypedQuery<T> createTypedQuery( Class<T> entityCls, SingularAttribute<T, Y> attribute, SqlComparator comparator, Y value) { EntityManager entityManager = this.entityManagerProvider.get(); CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery<T> criteriaQuery = builder.createQuery(entityCls); Root<T> root = criteriaQuery.from(entityCls); Path<Y> path = root.get(attribute); Predicate pred; switch (comparator) { case LESS_THAN: pred = builder.lt(path, value); break; case LESS_THAN_OR_EQUAL_TO: pred = builder.le(path, value); break; case EQUAL_TO: pred = builder.equal(path, value); break; case NOT_EQUAL_TO: pred = builder.notEqual(path, value); break; case GREATER_THAN_OR_EQUAL_TO: pred = builder.ge(path, value); break; case GREATER_THAN: pred = builder.gt(path, value); break; default: throw new AssertionError("Invalid SQLComparator: " + comparator); } return entityManager.createQuery(criteriaQuery.where(pred)); }
java
private <T, Y extends Number> TypedQuery<T> createTypedQuery( Class<T> entityCls, SingularAttribute<T, Y> attribute, SqlComparator comparator, Y value) { EntityManager entityManager = this.entityManagerProvider.get(); CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery<T> criteriaQuery = builder.createQuery(entityCls); Root<T> root = criteriaQuery.from(entityCls); Path<Y> path = root.get(attribute); Predicate pred; switch (comparator) { case LESS_THAN: pred = builder.lt(path, value); break; case LESS_THAN_OR_EQUAL_TO: pred = builder.le(path, value); break; case EQUAL_TO: pred = builder.equal(path, value); break; case NOT_EQUAL_TO: pred = builder.notEqual(path, value); break; case GREATER_THAN_OR_EQUAL_TO: pred = builder.ge(path, value); break; case GREATER_THAN: pred = builder.gt(path, value); break; default: throw new AssertionError("Invalid SQLComparator: " + comparator); } return entityManager.createQuery(criteriaQuery.where(pred)); }
[ "private", "<", "T", ",", "Y", "extends", "Number", ">", "TypedQuery", "<", "T", ">", "createTypedQuery", "(", "Class", "<", "T", ">", "entityCls", ",", "SingularAttribute", "<", "T", ",", "Y", ">", "attribute", ",", "SqlComparator", "comparator", ",", "Y", "value", ")", "{", "EntityManager", "entityManager", "=", "this", ".", "entityManagerProvider", ".", "get", "(", ")", ";", "CriteriaBuilder", "builder", "=", "entityManager", ".", "getCriteriaBuilder", "(", ")", ";", "CriteriaQuery", "<", "T", ">", "criteriaQuery", "=", "builder", ".", "createQuery", "(", "entityCls", ")", ";", "Root", "<", "T", ">", "root", "=", "criteriaQuery", ".", "from", "(", "entityCls", ")", ";", "Path", "<", "Y", ">", "path", "=", "root", ".", "get", "(", "attribute", ")", ";", "Predicate", "pred", ";", "switch", "(", "comparator", ")", "{", "case", "LESS_THAN", ":", "pred", "=", "builder", ".", "lt", "(", "path", ",", "value", ")", ";", "break", ";", "case", "LESS_THAN_OR_EQUAL_TO", ":", "pred", "=", "builder", ".", "le", "(", "path", ",", "value", ")", ";", "break", ";", "case", "EQUAL_TO", ":", "pred", "=", "builder", ".", "equal", "(", "path", ",", "value", ")", ";", "break", ";", "case", "NOT_EQUAL_TO", ":", "pred", "=", "builder", ".", "notEqual", "(", "path", ",", "value", ")", ";", "break", ";", "case", "GREATER_THAN_OR_EQUAL_TO", ":", "pred", "=", "builder", ".", "ge", "(", "path", ",", "value", ")", ";", "break", ";", "case", "GREATER_THAN", ":", "pred", "=", "builder", ".", "gt", "(", "path", ",", "value", ")", ";", "break", ";", "default", ":", "throw", "new", "AssertionError", "(", "\"Invalid SQLComparator: \"", "+", "comparator", ")", ";", "}", "return", "entityManager", ".", "createQuery", "(", "criteriaQuery", ".", "where", "(", "pred", ")", ")", ";", "}" ]
Creates a typed query for entities with the given numerical attribute value. @param <T> the type of the entity to return. @param <Y> the type of the attribute. @param entityCls the entity's class. @param attribute the attribute. @param comparator the comparator. @param value the value or value threshold. @return a typed query with the given criteria.
[ "Creates", "a", "typed", "query", "for", "entities", "with", "the", "given", "numerical", "attribute", "value", "." ]
690036dde82a4f2c2106d32403cdf1c713429377
https://github.com/eurekaclinical/eurekaclinical-standard-apis/blob/690036dde82a4f2c2106d32403cdf1c713429377/src/main/java/org/eurekaclinical/standardapis/dao/DatabaseSupport.java#L610-L643
149,741
datoin/http-requests
src/main/java/org/datoin/net/http/Request.java
Request.get
protected Response get() { RequestBuilder getRequest = RequestBuilder.get().setUri(url); return executeHttpRequest(getRequest); }
java
protected Response get() { RequestBuilder getRequest = RequestBuilder.get().setUri(url); return executeHttpRequest(getRequest); }
[ "protected", "Response", "get", "(", ")", "{", "RequestBuilder", "getRequest", "=", "RequestBuilder", ".", "get", "(", ")", ".", "setUri", "(", "url", ")", ";", "return", "executeHttpRequest", "(", "getRequest", ")", ";", "}" ]
execute a get request from the Request object configuration @return : a formatted Response object
[ "execute", "a", "get", "request", "from", "the", "Request", "object", "configuration" ]
660a4bc516c594f321019df94451fead4dea19b6
https://github.com/datoin/http-requests/blob/660a4bc516c594f321019df94451fead4dea19b6/src/main/java/org/datoin/net/http/Request.java#L105-L108
149,742
datoin/http-requests
src/main/java/org/datoin/net/http/Request.java
Request.post
protected Response post() { RequestBuilder builder = RequestBuilder.post().setUri(url); return getResponseAfterDetectingType(builder); }
java
protected Response post() { RequestBuilder builder = RequestBuilder.post().setUri(url); return getResponseAfterDetectingType(builder); }
[ "protected", "Response", "post", "(", ")", "{", "RequestBuilder", "builder", "=", "RequestBuilder", ".", "post", "(", ")", ".", "setUri", "(", "url", ")", ";", "return", "getResponseAfterDetectingType", "(", "builder", ")", ";", "}" ]
execute a post request for this Request object @return : Response object built from the http resposne
[ "execute", "a", "post", "request", "for", "this", "Request", "object" ]
660a4bc516c594f321019df94451fead4dea19b6
https://github.com/datoin/http-requests/blob/660a4bc516c594f321019df94451fead4dea19b6/src/main/java/org/datoin/net/http/Request.java#L124-L127
149,743
datoin/http-requests
src/main/java/org/datoin/net/http/Request.java
Request.setHeader
public Request setHeader(String name, String value) { this.headers.put(name, value); return this; }
java
public Request setHeader(String name, String value) { this.headers.put(name, value); return this; }
[ "public", "Request", "setHeader", "(", "String", "name", ",", "String", "value", ")", "{", "this", ".", "headers", ".", "put", "(", "name", ",", "value", ")", ";", "return", "this", ";", "}" ]
seat a header and return modified request @param name : header name @param value : header value @return : Request Object with header value set
[ "seat", "a", "header", "and", "return", "modified", "request" ]
660a4bc516c594f321019df94451fead4dea19b6
https://github.com/datoin/http-requests/blob/660a4bc516c594f321019df94451fead4dea19b6/src/main/java/org/datoin/net/http/Request.java#L183-L186
149,744
datoin/http-requests
src/main/java/org/datoin/net/http/Request.java
Request.accept
public Request accept(String headerValue){ final String accept = RequestHeaderFields.ACCEPT.getName(); String acceptValue = headers.get(accept); if (acceptValue == null){ acceptValue = headerValue; } else { acceptValue = acceptValue + ", " + headerValue; } return this.setHeader(accept, acceptValue); }
java
public Request accept(String headerValue){ final String accept = RequestHeaderFields.ACCEPT.getName(); String acceptValue = headers.get(accept); if (acceptValue == null){ acceptValue = headerValue; } else { acceptValue = acceptValue + ", " + headerValue; } return this.setHeader(accept, acceptValue); }
[ "public", "Request", "accept", "(", "String", "headerValue", ")", "{", "final", "String", "accept", "=", "RequestHeaderFields", ".", "ACCEPT", ".", "getName", "(", ")", ";", "String", "acceptValue", "=", "headers", ".", "get", "(", "accept", ")", ";", "if", "(", "acceptValue", "==", "null", ")", "{", "acceptValue", "=", "headerValue", ";", "}", "else", "{", "acceptValue", "=", "acceptValue", "+", "\", \"", "+", "headerValue", ";", "}", "return", "this", ".", "setHeader", "(", "accept", ",", "acceptValue", ")", ";", "}" ]
sets the accept header for the request, if exists then appends @param headerValue : header field value to add @return : Request Object with accept header value set
[ "sets", "the", "accept", "header", "for", "the", "request", "if", "exists", "then", "appends" ]
660a4bc516c594f321019df94451fead4dea19b6
https://github.com/datoin/http-requests/blob/660a4bc516c594f321019df94451fead4dea19b6/src/main/java/org/datoin/net/http/Request.java#L193-L202
149,745
datoin/http-requests
src/main/java/org/datoin/net/http/Request.java
Request.acceptEncoding
public Request acceptEncoding(String encoding){ final String acceptEncoding = RequestHeaderFields.ACCEPT_ENCODING.getName(); String encodingValue = headers.get(acceptEncoding); if (encodingValue == null){ encodingValue = encoding; } else { encodingValue = encodingValue + ", " + encoding; } return this.setHeader(acceptEncoding, encodingValue); }
java
public Request acceptEncoding(String encoding){ final String acceptEncoding = RequestHeaderFields.ACCEPT_ENCODING.getName(); String encodingValue = headers.get(acceptEncoding); if (encodingValue == null){ encodingValue = encoding; } else { encodingValue = encodingValue + ", " + encoding; } return this.setHeader(acceptEncoding, encodingValue); }
[ "public", "Request", "acceptEncoding", "(", "String", "encoding", ")", "{", "final", "String", "acceptEncoding", "=", "RequestHeaderFields", ".", "ACCEPT_ENCODING", ".", "getName", "(", ")", ";", "String", "encodingValue", "=", "headers", ".", "get", "(", "acceptEncoding", ")", ";", "if", "(", "encodingValue", "==", "null", ")", "{", "encodingValue", "=", "encoding", ";", "}", "else", "{", "encodingValue", "=", "encodingValue", "+", "\", \"", "+", "encoding", ";", "}", "return", "this", ".", "setHeader", "(", "acceptEncoding", ",", "encodingValue", ")", ";", "}" ]
sets the accept encoding header for the request, if exists then appends @param encoding : header field value to add @return : Request Object with accept encoding header value set
[ "sets", "the", "accept", "encoding", "header", "for", "the", "request", "if", "exists", "then", "appends" ]
660a4bc516c594f321019df94451fead4dea19b6
https://github.com/datoin/http-requests/blob/660a4bc516c594f321019df94451fead4dea19b6/src/main/java/org/datoin/net/http/Request.java#L209-L218
149,746
datoin/http-requests
src/main/java/org/datoin/net/http/Request.java
Request.acceptLanguage
public Request acceptLanguage(String language){ final String acceptLanguage = RequestHeaderFields.ACCEPT_LANGUAGE.getName(); String languageValue = headers.get(acceptLanguage); if (languageValue == null){ languageValue = language; } else { languageValue = languageValue + ", " + language; } return this.setHeader(acceptLanguage, languageValue); }
java
public Request acceptLanguage(String language){ final String acceptLanguage = RequestHeaderFields.ACCEPT_LANGUAGE.getName(); String languageValue = headers.get(acceptLanguage); if (languageValue == null){ languageValue = language; } else { languageValue = languageValue + ", " + language; } return this.setHeader(acceptLanguage, languageValue); }
[ "public", "Request", "acceptLanguage", "(", "String", "language", ")", "{", "final", "String", "acceptLanguage", "=", "RequestHeaderFields", ".", "ACCEPT_LANGUAGE", ".", "getName", "(", ")", ";", "String", "languageValue", "=", "headers", ".", "get", "(", "acceptLanguage", ")", ";", "if", "(", "languageValue", "==", "null", ")", "{", "languageValue", "=", "language", ";", "}", "else", "{", "languageValue", "=", "languageValue", "+", "\", \"", "+", "language", ";", "}", "return", "this", ".", "setHeader", "(", "acceptLanguage", ",", "languageValue", ")", ";", "}" ]
sets the accept language header for the request, if exists then appends @param language : header field value to add @return : Request Object with accept language header value set
[ "sets", "the", "accept", "language", "header", "for", "the", "request", "if", "exists", "then", "appends" ]
660a4bc516c594f321019df94451fead4dea19b6
https://github.com/datoin/http-requests/blob/660a4bc516c594f321019df94451fead4dea19b6/src/main/java/org/datoin/net/http/Request.java#L225-L234
149,747
datoin/http-requests
src/main/java/org/datoin/net/http/Request.java
Request.userAgent
public Request userAgent(String userAgentValue){ final String userAgent = RequestHeaderFields.USER_AGENT.getName(); String agent = headers.get(userAgent); if (agent == null){ agent = userAgentValue; } else { agent = agent + " " + userAgentValue; } return this.setHeader(userAgent, agent); }
java
public Request userAgent(String userAgentValue){ final String userAgent = RequestHeaderFields.USER_AGENT.getName(); String agent = headers.get(userAgent); if (agent == null){ agent = userAgentValue; } else { agent = agent + " " + userAgentValue; } return this.setHeader(userAgent, agent); }
[ "public", "Request", "userAgent", "(", "String", "userAgentValue", ")", "{", "final", "String", "userAgent", "=", "RequestHeaderFields", ".", "USER_AGENT", ".", "getName", "(", ")", ";", "String", "agent", "=", "headers", ".", "get", "(", "userAgent", ")", ";", "if", "(", "agent", "==", "null", ")", "{", "agent", "=", "userAgentValue", ";", "}", "else", "{", "agent", "=", "agent", "+", "\" \"", "+", "userAgentValue", ";", "}", "return", "this", ".", "setHeader", "(", "userAgent", ",", "agent", ")", ";", "}" ]
sets the user agent header for the request, if exists then appends @param userAgentValue : header field value to add @return : Request Object with userAgent header value set
[ "sets", "the", "user", "agent", "header", "for", "the", "request", "if", "exists", "then", "appends" ]
660a4bc516c594f321019df94451fead4dea19b6
https://github.com/datoin/http-requests/blob/660a4bc516c594f321019df94451fead4dea19b6/src/main/java/org/datoin/net/http/Request.java#L241-L250
149,748
datoin/http-requests
src/main/java/org/datoin/net/http/Request.java
Request.referer
public Request referer(String refererValue){ final String referer = RequestHeaderFields.REFERER.getName(); return this.setHeader(referer, refererValue); }
java
public Request referer(String refererValue){ final String referer = RequestHeaderFields.REFERER.getName(); return this.setHeader(referer, refererValue); }
[ "public", "Request", "referer", "(", "String", "refererValue", ")", "{", "final", "String", "referer", "=", "RequestHeaderFields", ".", "REFERER", ".", "getName", "(", ")", ";", "return", "this", ".", "setHeader", "(", "referer", ",", "refererValue", ")", ";", "}" ]
sets the Referer header for the request @param refererValue : header field value to add @return : Request Object with referer header value set
[ "sets", "the", "Referer", "header", "for", "the", "request" ]
660a4bc516c594f321019df94451fead4dea19b6
https://github.com/datoin/http-requests/blob/660a4bc516c594f321019df94451fead4dea19b6/src/main/java/org/datoin/net/http/Request.java#L257-L260
149,749
datoin/http-requests
src/main/java/org/datoin/net/http/Request.java
Request.authorization
public Request authorization(String authorizationValue){ final String authorization = RequestHeaderFields.AUTHORIZATION.getName(); return this.setHeader(authorization, authorizationValue); }
java
public Request authorization(String authorizationValue){ final String authorization = RequestHeaderFields.AUTHORIZATION.getName(); return this.setHeader(authorization, authorizationValue); }
[ "public", "Request", "authorization", "(", "String", "authorizationValue", ")", "{", "final", "String", "authorization", "=", "RequestHeaderFields", ".", "AUTHORIZATION", ".", "getName", "(", ")", ";", "return", "this", ".", "setHeader", "(", "authorization", ",", "authorizationValue", ")", ";", "}" ]
sets the Authorization header for the request @param authorizationValue : header field value to add @return : Request Object with authorization header value set
[ "sets", "the", "Authorization", "header", "for", "the", "request" ]
660a4bc516c594f321019df94451fead4dea19b6
https://github.com/datoin/http-requests/blob/660a4bc516c594f321019df94451fead4dea19b6/src/main/java/org/datoin/net/http/Request.java#L267-L270
149,750
datoin/http-requests
src/main/java/org/datoin/net/http/Request.java
Request.authorize
public Request authorize(String name, String password){ String authString = name + ":" + password; System.out.println("auth string: " + authString); byte[] authEncBytes = Base64.encodeBase64(authString.getBytes()); String authStringEnc = new String(authEncBytes); System.out.println("Base64 encoded auth string: " + authStringEnc); return this.authorization("Basic " + authStringEnc); }
java
public Request authorize(String name, String password){ String authString = name + ":" + password; System.out.println("auth string: " + authString); byte[] authEncBytes = Base64.encodeBase64(authString.getBytes()); String authStringEnc = new String(authEncBytes); System.out.println("Base64 encoded auth string: " + authStringEnc); return this.authorization("Basic " + authStringEnc); }
[ "public", "Request", "authorize", "(", "String", "name", ",", "String", "password", ")", "{", "String", "authString", "=", "name", "+", "\":\"", "+", "password", ";", "System", ".", "out", ".", "println", "(", "\"auth string: \"", "+", "authString", ")", ";", "byte", "[", "]", "authEncBytes", "=", "Base64", ".", "encodeBase64", "(", "authString", ".", "getBytes", "(", ")", ")", ";", "String", "authStringEnc", "=", "new", "String", "(", "authEncBytes", ")", ";", "System", ".", "out", ".", "println", "(", "\"Base64 encoded auth string: \"", "+", "authStringEnc", ")", ";", "return", "this", ".", "authorization", "(", "\"Basic \"", "+", "authStringEnc", ")", ";", "}" ]
method to set authorization header after computing digest from user and pasword @param name : username @param password : password @return : Request Object with authorization header value set
[ "method", "to", "set", "authorization", "header", "after", "computing", "digest", "from", "user", "and", "pasword" ]
660a4bc516c594f321019df94451fead4dea19b6
https://github.com/datoin/http-requests/blob/660a4bc516c594f321019df94451fead4dea19b6/src/main/java/org/datoin/net/http/Request.java#L278-L286
149,751
datoin/http-requests
src/main/java/org/datoin/net/http/Request.java
Request.addInputStream
public Request addInputStream(String name , File file) throws FileNotFoundException { this.postStreams.put(name, new FileInputStream(file)); return this; }
java
public Request addInputStream(String name , File file) throws FileNotFoundException { this.postStreams.put(name, new FileInputStream(file)); return this; }
[ "public", "Request", "addInputStream", "(", "String", "name", ",", "File", "file", ")", "throws", "FileNotFoundException", "{", "this", ".", "postStreams", ".", "put", "(", "name", ",", "new", "FileInputStream", "(", "file", ")", ")", ";", "return", "this", ";", "}" ]
for post only
[ "for", "post", "only" ]
660a4bc516c594f321019df94451fead4dea19b6
https://github.com/datoin/http-requests/blob/660a4bc516c594f321019df94451fead4dea19b6/src/main/java/org/datoin/net/http/Request.java#L360-L363
149,752
datoin/http-requests
src/main/java/org/datoin/net/http/Request.java
Request.setContent
public Request setContent(String text, ContentType contentType) { entity = new StringEntity(text, contentType); return this; }
java
public Request setContent(String text, ContentType contentType) { entity = new StringEntity(text, contentType); return this; }
[ "public", "Request", "setContent", "(", "String", "text", ",", "ContentType", "contentType", ")", "{", "entity", "=", "new", "StringEntity", "(", "text", ",", "contentType", ")", ";", "return", "this", ";", "}" ]
set request content from input text string with given content type @param text : text to be sent as http content @param contentType : type of content set in header @return : Request Object with content type header and conetnt entity value set
[ "set", "request", "content", "from", "input", "text", "string", "with", "given", "content", "type" ]
660a4bc516c594f321019df94451fead4dea19b6
https://github.com/datoin/http-requests/blob/660a4bc516c594f321019df94451fead4dea19b6/src/main/java/org/datoin/net/http/Request.java#L400-L403
149,753
datoin/http-requests
src/main/java/org/datoin/net/http/Request.java
Request.setContent
public Request setContent(InputStream stream, ContentType contentType) { entity = new InputStreamEntity(stream, contentType); return this; }
java
public Request setContent(InputStream stream, ContentType contentType) { entity = new InputStreamEntity(stream, contentType); return this; }
[ "public", "Request", "setContent", "(", "InputStream", "stream", ",", "ContentType", "contentType", ")", "{", "entity", "=", "new", "InputStreamEntity", "(", "stream", ",", "contentType", ")", ";", "return", "this", ";", "}" ]
set request content from input stream with given content type @param stream : teh input stream to be used as http content @param contentType : type of content set in header @return modified Request object with http content entity set
[ "set", "request", "content", "from", "input", "stream", "with", "given", "content", "type" ]
660a4bc516c594f321019df94451fead4dea19b6
https://github.com/datoin/http-requests/blob/660a4bc516c594f321019df94451fead4dea19b6/src/main/java/org/datoin/net/http/Request.java#L411-L414
149,754
datoin/http-requests
src/main/java/org/datoin/net/http/Request.java
Request.getFirstParam
public String getFirstParam(String paramName) { Collection<String> values = this.params.get(paramName); if(values == null || values.isEmpty()) { return null; } else { return values.iterator().next(); } }
java
public String getFirstParam(String paramName) { Collection<String> values = this.params.get(paramName); if(values == null || values.isEmpty()) { return null; } else { return values.iterator().next(); } }
[ "public", "String", "getFirstParam", "(", "String", "paramName", ")", "{", "Collection", "<", "String", ">", "values", "=", "this", ".", "params", ".", "get", "(", "paramName", ")", ";", "if", "(", "values", "==", "null", "||", "values", ".", "isEmpty", "(", ")", ")", "{", "return", "null", ";", "}", "else", "{", "return", "values", ".", "iterator", "(", ")", ".", "next", "(", ")", ";", "}", "}" ]
gets first value of specific param. @param paramName : name of the param to fetch value for @return : first value in the collection corresponding param name if found, otherwise <code>null</code>
[ "gets", "first", "value", "of", "specific", "param", "." ]
660a4bc516c594f321019df94451fead4dea19b6
https://github.com/datoin/http-requests/blob/660a4bc516c594f321019df94451fead4dea19b6/src/main/java/org/datoin/net/http/Request.java#L431-L438
149,755
datoin/http-requests
src/main/java/org/datoin/net/http/Request.java
Request.getParam
public java.util.Collection<String> getParam(String paramName) { return this.params.get(paramName); }
java
public java.util.Collection<String> getParam(String paramName) { return this.params.get(paramName); }
[ "public", "java", ".", "util", ".", "Collection", "<", "String", ">", "getParam", "(", "String", "paramName", ")", "{", "return", "this", ".", "params", ".", "get", "(", "paramName", ")", ";", "}" ]
get specific param value @param paramName : name of the param to fetch value for @return : value of corresponding param name
[ "get", "specific", "param", "value" ]
660a4bc516c594f321019df94451fead4dea19b6
https://github.com/datoin/http-requests/blob/660a4bc516c594f321019df94451fead4dea19b6/src/main/java/org/datoin/net/http/Request.java#L445-L447
149,756
datoin/http-requests
src/main/java/org/datoin/net/http/Request.java
Request.getResponse
protected Response getResponse(HttpEntity entity, RequestBuilder req) { CloseableHttpClient client = getClient(); initHeaders(req); req.setEntity(entity); CloseableHttpResponse resp = null; Response response = null; try { final HttpUriRequest uriRequest = req.build(); resp = client.execute(uriRequest); response = new Response(resp); response.setMethod(Methods.POST.getMethod()); response.setRequestLine(uriRequest.getRequestLine().toString()); } catch (Exception e) { // TODO: log the error e.printStackTrace(); } finally { try { client.close(); } catch (IOException e) { e.printStackTrace(); } } return response; }
java
protected Response getResponse(HttpEntity entity, RequestBuilder req) { CloseableHttpClient client = getClient(); initHeaders(req); req.setEntity(entity); CloseableHttpResponse resp = null; Response response = null; try { final HttpUriRequest uriRequest = req.build(); resp = client.execute(uriRequest); response = new Response(resp); response.setMethod(Methods.POST.getMethod()); response.setRequestLine(uriRequest.getRequestLine().toString()); } catch (Exception e) { // TODO: log the error e.printStackTrace(); } finally { try { client.close(); } catch (IOException e) { e.printStackTrace(); } } return response; }
[ "protected", "Response", "getResponse", "(", "HttpEntity", "entity", ",", "RequestBuilder", "req", ")", "{", "CloseableHttpClient", "client", "=", "getClient", "(", ")", ";", "initHeaders", "(", "req", ")", ";", "req", ".", "setEntity", "(", "entity", ")", ";", "CloseableHttpResponse", "resp", "=", "null", ";", "Response", "response", "=", "null", ";", "try", "{", "final", "HttpUriRequest", "uriRequest", "=", "req", ".", "build", "(", ")", ";", "resp", "=", "client", ".", "execute", "(", "uriRequest", ")", ";", "response", "=", "new", "Response", "(", "resp", ")", ";", "response", ".", "setMethod", "(", "Methods", ".", "POST", ".", "getMethod", "(", ")", ")", ";", "response", ".", "setRequestLine", "(", "uriRequest", ".", "getRequestLine", "(", ")", ".", "toString", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "// TODO: log the error", "e", ".", "printStackTrace", "(", ")", ";", "}", "finally", "{", "try", "{", "client", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "return", "response", ";", "}" ]
get response from preconfigured http entity and request builder @param entity : http entity to be used in request @param req : request builder object to build the http request @return : Response object prepared after executing the request
[ "get", "response", "from", "preconfigured", "http", "entity", "and", "request", "builder" ]
660a4bc516c594f321019df94451fead4dea19b6
https://github.com/datoin/http-requests/blob/660a4bc516c594f321019df94451fead4dea19b6/src/main/java/org/datoin/net/http/Request.java#L455-L478
149,757
likethecolor/Alchemy-API
src/main/java/com/likethecolor/alchemy/api/parser/json/AbstractParser.java
AbstractParser.getBoolean
protected Boolean getBoolean(final String key, final JSONObject jsonObject) { Boolean value = null; if(hasKey(key, jsonObject)) { try { value = jsonObject.getBoolean(key); } catch(JSONException e) { LOGGER.debug("Could not get boolean from JSONObject for key: " + key, e); LOGGER.debug("Trying to get the truthy value"); value = getNonStandardBoolean(key, jsonObject); } } return value; }
java
protected Boolean getBoolean(final String key, final JSONObject jsonObject) { Boolean value = null; if(hasKey(key, jsonObject)) { try { value = jsonObject.getBoolean(key); } catch(JSONException e) { LOGGER.debug("Could not get boolean from JSONObject for key: " + key, e); LOGGER.debug("Trying to get the truthy value"); value = getNonStandardBoolean(key, jsonObject); } } return value; }
[ "protected", "Boolean", "getBoolean", "(", "final", "String", "key", ",", "final", "JSONObject", "jsonObject", ")", "{", "Boolean", "value", "=", "null", ";", "if", "(", "hasKey", "(", "key", ",", "jsonObject", ")", ")", "{", "try", "{", "value", "=", "jsonObject", ".", "getBoolean", "(", "key", ")", ";", "}", "catch", "(", "JSONException", "e", ")", "{", "LOGGER", ".", "debug", "(", "\"Could not get boolean from JSONObject for key: \"", "+", "key", ",", "e", ")", ";", "LOGGER", ".", "debug", "(", "\"Trying to get the truthy value\"", ")", ";", "value", "=", "getNonStandardBoolean", "(", "key", ",", "jsonObject", ")", ";", "}", "}", "return", "value", ";", "}" ]
Check to make sure the JSONObject has the specified key and if so return the value as a boolean. If no key is found null is returned. If the value is not JSON boolean (true/false) then {@link #getNonStandardBoolean(String, JSONObject)} is called. @param key name of the field to fetch from the json object @param jsonObject object from which to fetch the value @return boolean value corresponding to the key or null if key not found @see #getNonStandardBoolean(String, JSONObject)
[ "Check", "to", "make", "sure", "the", "JSONObject", "has", "the", "specified", "key", "and", "if", "so", "return", "the", "value", "as", "a", "boolean", ".", "If", "no", "key", "is", "found", "null", "is", "returned", "." ]
5208cfc92a878ceeaff052787af29da92d98db7e
https://github.com/likethecolor/Alchemy-API/blob/5208cfc92a878ceeaff052787af29da92d98db7e/src/main/java/com/likethecolor/alchemy/api/parser/json/AbstractParser.java#L80-L93
149,758
likethecolor/Alchemy-API
src/main/java/com/likethecolor/alchemy/api/parser/json/AbstractParser.java
AbstractParser.getDouble
protected Double getDouble(final String key, final JSONObject jsonObject) { Double value = null; if(hasKey(key, jsonObject)) { try { value = jsonObject.getDouble(key); } catch(JSONException e) { LOGGER.error("Could not get Double from JSONObject for key: " + key, e); } } return value; }
java
protected Double getDouble(final String key, final JSONObject jsonObject) { Double value = null; if(hasKey(key, jsonObject)) { try { value = jsonObject.getDouble(key); } catch(JSONException e) { LOGGER.error("Could not get Double from JSONObject for key: " + key, e); } } return value; }
[ "protected", "Double", "getDouble", "(", "final", "String", "key", ",", "final", "JSONObject", "jsonObject", ")", "{", "Double", "value", "=", "null", ";", "if", "(", "hasKey", "(", "key", ",", "jsonObject", ")", ")", "{", "try", "{", "value", "=", "jsonObject", ".", "getDouble", "(", "key", ")", ";", "}", "catch", "(", "JSONException", "e", ")", "{", "LOGGER", ".", "error", "(", "\"Could not get Double from JSONObject for key: \"", "+", "key", ",", "e", ")", ";", "}", "}", "return", "value", ";", "}" ]
Check to make sure the JSONObject has the specified key and if so return the value as a double. If no key is found null is returned. @param key name of the field to fetch from the json object @param jsonObject object from which to fetch the value @return double value corresponding to the key or null if key not found
[ "Check", "to", "make", "sure", "the", "JSONObject", "has", "the", "specified", "key", "and", "if", "so", "return", "the", "value", "as", "a", "double", ".", "If", "no", "key", "is", "found", "null", "is", "returned", "." ]
5208cfc92a878ceeaff052787af29da92d98db7e
https://github.com/likethecolor/Alchemy-API/blob/5208cfc92a878ceeaff052787af29da92d98db7e/src/main/java/com/likethecolor/alchemy/api/parser/json/AbstractParser.java#L142-L153
149,759
likethecolor/Alchemy-API
src/main/java/com/likethecolor/alchemy/api/parser/json/AbstractParser.java
AbstractParser.getInteger
protected Integer getInteger(final String key, final JSONObject jsonObject) { Integer value = null; if(hasKey(key, jsonObject)) { try { value = jsonObject.getInt(key); } catch(JSONException e) { LOGGER.error("Could not get Integer from JSONObject for key: " + key, e); } } return value; }
java
protected Integer getInteger(final String key, final JSONObject jsonObject) { Integer value = null; if(hasKey(key, jsonObject)) { try { value = jsonObject.getInt(key); } catch(JSONException e) { LOGGER.error("Could not get Integer from JSONObject for key: " + key, e); } } return value; }
[ "protected", "Integer", "getInteger", "(", "final", "String", "key", ",", "final", "JSONObject", "jsonObject", ")", "{", "Integer", "value", "=", "null", ";", "if", "(", "hasKey", "(", "key", ",", "jsonObject", ")", ")", "{", "try", "{", "value", "=", "jsonObject", ".", "getInt", "(", "key", ")", ";", "}", "catch", "(", "JSONException", "e", ")", "{", "LOGGER", ".", "error", "(", "\"Could not get Integer from JSONObject for key: \"", "+", "key", ",", "e", ")", ";", "}", "}", "return", "value", ";", "}" ]
Check to make sure the JSONObject has the specified key and if so return the value as a integer. If no key is found null is returned. @param key name of the field to fetch from the json object @param jsonObject object from which to fetch the value @return integer value corresponding to the key or null if key not found
[ "Check", "to", "make", "sure", "the", "JSONObject", "has", "the", "specified", "key", "and", "if", "so", "return", "the", "value", "as", "a", "integer", ".", "If", "no", "key", "is", "found", "null", "is", "returned", "." ]
5208cfc92a878ceeaff052787af29da92d98db7e
https://github.com/likethecolor/Alchemy-API/blob/5208cfc92a878ceeaff052787af29da92d98db7e/src/main/java/com/likethecolor/alchemy/api/parser/json/AbstractParser.java#L164-L175
149,760
likethecolor/Alchemy-API
src/main/java/com/likethecolor/alchemy/api/parser/json/AbstractParser.java
AbstractParser.getLong
protected Long getLong(final String key, final JSONObject jsonObject) { Long value = null; if(hasKey(key, jsonObject)) { try { value = jsonObject.getLong(key); } catch(JSONException e) { LOGGER.error("Could not get Long from JSONObject for key: " + key, e); } } return value; }
java
protected Long getLong(final String key, final JSONObject jsonObject) { Long value = null; if(hasKey(key, jsonObject)) { try { value = jsonObject.getLong(key); } catch(JSONException e) { LOGGER.error("Could not get Long from JSONObject for key: " + key, e); } } return value; }
[ "protected", "Long", "getLong", "(", "final", "String", "key", ",", "final", "JSONObject", "jsonObject", ")", "{", "Long", "value", "=", "null", ";", "if", "(", "hasKey", "(", "key", ",", "jsonObject", ")", ")", "{", "try", "{", "value", "=", "jsonObject", ".", "getLong", "(", "key", ")", ";", "}", "catch", "(", "JSONException", "e", ")", "{", "LOGGER", ".", "error", "(", "\"Could not get Long from JSONObject for key: \"", "+", "key", ",", "e", ")", ";", "}", "}", "return", "value", ";", "}" ]
Check to make sure the JSONObject has the specified key and if so return the value as a long. If no key is found null is returned. @param key name of the field to fetch from the json object @param jsonObject object from which to fetch the value @return long value corresponding to the key or null if key not found
[ "Check", "to", "make", "sure", "the", "JSONObject", "has", "the", "specified", "key", "and", "if", "so", "return", "the", "value", "as", "a", "long", ".", "If", "no", "key", "is", "found", "null", "is", "returned", "." ]
5208cfc92a878ceeaff052787af29da92d98db7e
https://github.com/likethecolor/Alchemy-API/blob/5208cfc92a878ceeaff052787af29da92d98db7e/src/main/java/com/likethecolor/alchemy/api/parser/json/AbstractParser.java#L186-L197
149,761
likethecolor/Alchemy-API
src/main/java/com/likethecolor/alchemy/api/parser/json/AbstractParser.java
AbstractParser.getJSONArray
protected JSONArray getJSONArray(final String key, final JSONObject jsonObject) { JSONArray value = new JSONArray(); if(hasKey(key, jsonObject)) { try { value = jsonObject.getJSONArray(key); } catch(JSONException e) { LOGGER.error("Could not get JSONArray from JSONObject for key: " + key, e); } } return value; }
java
protected JSONArray getJSONArray(final String key, final JSONObject jsonObject) { JSONArray value = new JSONArray(); if(hasKey(key, jsonObject)) { try { value = jsonObject.getJSONArray(key); } catch(JSONException e) { LOGGER.error("Could not get JSONArray from JSONObject for key: " + key, e); } } return value; }
[ "protected", "JSONArray", "getJSONArray", "(", "final", "String", "key", ",", "final", "JSONObject", "jsonObject", ")", "{", "JSONArray", "value", "=", "new", "JSONArray", "(", ")", ";", "if", "(", "hasKey", "(", "key", ",", "jsonObject", ")", ")", "{", "try", "{", "value", "=", "jsonObject", ".", "getJSONArray", "(", "key", ")", ";", "}", "catch", "(", "JSONException", "e", ")", "{", "LOGGER", ".", "error", "(", "\"Could not get JSONArray from JSONObject for key: \"", "+", "key", ",", "e", ")", ";", "}", "}", "return", "value", ";", "}" ]
Check to make sure the JSONObject has the specified key and if so return the value as a JSONArray. If no key is found an empty JSONArray is returned. @param key name of the field to fetch from the json object @param jsonObject object from which to fetch the value @return json array value corresponding to the key or "" if key not found
[ "Check", "to", "make", "sure", "the", "JSONObject", "has", "the", "specified", "key", "and", "if", "so", "return", "the", "value", "as", "a", "JSONArray", ".", "If", "no", "key", "is", "found", "an", "empty", "JSONArray", "is", "returned", "." ]
5208cfc92a878ceeaff052787af29da92d98db7e
https://github.com/likethecolor/Alchemy-API/blob/5208cfc92a878ceeaff052787af29da92d98db7e/src/main/java/com/likethecolor/alchemy/api/parser/json/AbstractParser.java#L256-L267
149,762
likethecolor/Alchemy-API
src/main/java/com/likethecolor/alchemy/api/parser/json/AbstractParser.java
AbstractParser.getJSONObject
protected JSONObject getJSONObject(final String key, final JSONObject jsonObject) { JSONObject json = null; try { if(hasKey(key, jsonObject)) { json = jsonObject.getJSONObject(key); } } catch(JSONException e) { LOGGER.error("Could not get JSONObject from JSONObject for key: " + key, e); } return json; }
java
protected JSONObject getJSONObject(final String key, final JSONObject jsonObject) { JSONObject json = null; try { if(hasKey(key, jsonObject)) { json = jsonObject.getJSONObject(key); } } catch(JSONException e) { LOGGER.error("Could not get JSONObject from JSONObject for key: " + key, e); } return json; }
[ "protected", "JSONObject", "getJSONObject", "(", "final", "String", "key", ",", "final", "JSONObject", "jsonObject", ")", "{", "JSONObject", "json", "=", "null", ";", "try", "{", "if", "(", "hasKey", "(", "key", ",", "jsonObject", ")", ")", "{", "json", "=", "jsonObject", ".", "getJSONObject", "(", "key", ")", ";", "}", "}", "catch", "(", "JSONException", "e", ")", "{", "LOGGER", ".", "error", "(", "\"Could not get JSONObject from JSONObject for key: \"", "+", "key", ",", "e", ")", ";", "}", "return", "json", ";", "}" ]
Check to make sure the JSONObject has the specified key and if so return the value as a JSONObject. If no key is found null is returned. @param key name of the field to fetch from the json object @param jsonObject object from which to fetch the value @return json object value corresponding to the key or null if key not found
[ "Check", "to", "make", "sure", "the", "JSONObject", "has", "the", "specified", "key", "and", "if", "so", "return", "the", "value", "as", "a", "JSONObject", ".", "If", "no", "key", "is", "found", "null", "is", "returned", "." ]
5208cfc92a878ceeaff052787af29da92d98db7e
https://github.com/likethecolor/Alchemy-API/blob/5208cfc92a878ceeaff052787af29da92d98db7e/src/main/java/com/likethecolor/alchemy/api/parser/json/AbstractParser.java#L278-L289
149,763
likethecolor/Alchemy-API
src/main/java/com/likethecolor/alchemy/api/parser/json/AbstractParser.java
AbstractParser.getJSONObject
protected JSONObject getJSONObject(final JSONArray jsonArray, final int index) { JSONObject object = new JSONObject(); try { object = (JSONObject) jsonArray.get(index); } catch(JSONException e) { e.printStackTrace(); } return object; }
java
protected JSONObject getJSONObject(final JSONArray jsonArray, final int index) { JSONObject object = new JSONObject(); try { object = (JSONObject) jsonArray.get(index); } catch(JSONException e) { e.printStackTrace(); } return object; }
[ "protected", "JSONObject", "getJSONObject", "(", "final", "JSONArray", "jsonArray", ",", "final", "int", "index", ")", "{", "JSONObject", "object", "=", "new", "JSONObject", "(", ")", ";", "try", "{", "object", "=", "(", "JSONObject", ")", "jsonArray", ".", "get", "(", "index", ")", ";", "}", "catch", "(", "JSONException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "return", "object", ";", "}" ]
Return a json object from the provided array. Return an empty object if there is any problems fetching the named entity data. @param jsonArray array of data @param index of the object to fetch @return json object from the provided array
[ "Return", "a", "json", "object", "from", "the", "provided", "array", ".", "Return", "an", "empty", "object", "if", "there", "is", "any", "problems", "fetching", "the", "named", "entity", "data", "." ]
5208cfc92a878ceeaff052787af29da92d98db7e
https://github.com/likethecolor/Alchemy-API/blob/5208cfc92a878ceeaff052787af29da92d98db7e/src/main/java/com/likethecolor/alchemy/api/parser/json/AbstractParser.java#L300-L309
149,764
likethecolor/Alchemy-API
src/main/java/com/likethecolor/alchemy/api/parser/json/AbstractParser.java
AbstractParser.getJSONObject
protected JSONObject getJSONObject(final String jsonString) { JSONObject json = new JSONObject(); try { json = new JSONObject(jsonString); } catch(NullPointerException e) { LOGGER.error("JSON string cannot be null.", e); } catch(JSONException e) { LOGGER.error("Could not parse string into JSONObject.", e); } return json; }
java
protected JSONObject getJSONObject(final String jsonString) { JSONObject json = new JSONObject(); try { json = new JSONObject(jsonString); } catch(NullPointerException e) { LOGGER.error("JSON string cannot be null.", e); } catch(JSONException e) { LOGGER.error("Could not parse string into JSONObject.", e); } return json; }
[ "protected", "JSONObject", "getJSONObject", "(", "final", "String", "jsonString", ")", "{", "JSONObject", "json", "=", "new", "JSONObject", "(", ")", ";", "try", "{", "json", "=", "new", "JSONObject", "(", "jsonString", ")", ";", "}", "catch", "(", "NullPointerException", "e", ")", "{", "LOGGER", ".", "error", "(", "\"JSON string cannot be null.\"", ",", "e", ")", ";", "}", "catch", "(", "JSONException", "e", ")", "{", "LOGGER", ".", "error", "(", "\"Could not parse string into JSONObject.\"", ",", "e", ")", ";", "}", "return", "json", ";", "}" ]
Fetch a JSONObject from the provided string. @param jsonString json string @return json object representing the string or null if there is an exception
[ "Fetch", "a", "JSONObject", "from", "the", "provided", "string", "." ]
5208cfc92a878ceeaff052787af29da92d98db7e
https://github.com/likethecolor/Alchemy-API/blob/5208cfc92a878ceeaff052787af29da92d98db7e/src/main/java/com/likethecolor/alchemy/api/parser/json/AbstractParser.java#L318-L330
149,765
likethecolor/Alchemy-API
src/main/java/com/likethecolor/alchemy/api/parser/json/AbstractParser.java
AbstractParser.hasKey
protected boolean hasKey(final String key, final JSONObject jsonObject) { return jsonObject != null && jsonObject.has(key); }
java
protected boolean hasKey(final String key, final JSONObject jsonObject) { return jsonObject != null && jsonObject.has(key); }
[ "protected", "boolean", "hasKey", "(", "final", "String", "key", ",", "final", "JSONObject", "jsonObject", ")", "{", "return", "jsonObject", "!=", "null", "&&", "jsonObject", ".", "has", "(", "key", ")", ";", "}" ]
Does the JSONObject have a specified key? @param key key to check @param jsonObject object to check @return true if the key exists
[ "Does", "the", "JSONObject", "have", "a", "specified", "key?" ]
5208cfc92a878ceeaff052787af29da92d98db7e
https://github.com/likethecolor/Alchemy-API/blob/5208cfc92a878ceeaff052787af29da92d98db7e/src/main/java/com/likethecolor/alchemy/api/parser/json/AbstractParser.java#L340-L343
149,766
likethecolor/Alchemy-API
src/main/java/com/likethecolor/alchemy/api/entity/ConceptAlchemyEntity.java
ConceptAlchemyEntity.setConcept
public void setConcept(String concept) { if(concept != null) { concept = concept.trim(); } this.concept = concept; }
java
public void setConcept(String concept) { if(concept != null) { concept = concept.trim(); } this.concept = concept; }
[ "public", "void", "setConcept", "(", "String", "concept", ")", "{", "if", "(", "concept", "!=", "null", ")", "{", "concept", "=", "concept", ".", "trim", "(", ")", ";", "}", "this", ".", "concept", "=", "concept", ";", "}" ]
Set the detected concept tag. @param concept detected concept tag
[ "Set", "the", "detected", "concept", "tag", "." ]
5208cfc92a878ceeaff052787af29da92d98db7e
https://github.com/likethecolor/Alchemy-API/blob/5208cfc92a878ceeaff052787af29da92d98db7e/src/main/java/com/likethecolor/alchemy/api/entity/ConceptAlchemyEntity.java#L86-L91
149,767
gondor/kbop
src/main/java/org/pacesys/kbop/internal/AbstractKeyedObjectPool.java
AbstractKeyedObjectPool.createFuture
protected PoolWaitFuture<E> createFuture(final PoolKey<K> key) { return new PoolWaitFuture<E>(lock) { protected E getPoolObject(long timeout, TimeUnit unit) throws IOException, InterruptedException, TimeoutException { return getBlockingUntilAvailableOrTimeout(key, timeout, unit, this); } }; }
java
protected PoolWaitFuture<E> createFuture(final PoolKey<K> key) { return new PoolWaitFuture<E>(lock) { protected E getPoolObject(long timeout, TimeUnit unit) throws IOException, InterruptedException, TimeoutException { return getBlockingUntilAvailableOrTimeout(key, timeout, unit, this); } }; }
[ "protected", "PoolWaitFuture", "<", "E", ">", "createFuture", "(", "final", "PoolKey", "<", "K", ">", "key", ")", "{", "return", "new", "PoolWaitFuture", "<", "E", ">", "(", "lock", ")", "{", "protected", "E", "getPoolObject", "(", "long", "timeout", ",", "TimeUnit", "unit", ")", "throws", "IOException", ",", "InterruptedException", ",", "TimeoutException", "{", "return", "getBlockingUntilAvailableOrTimeout", "(", "key", ",", "timeout", ",", "unit", ",", "this", ")", ";", "}", "}", ";", "}" ]
Creates a Future which will wait for the Keyed Object to become available or timeout @param key the Pool Key @return PoolWaitFuture
[ "Creates", "a", "Future", "which", "will", "wait", "for", "the", "Keyed", "Object", "to", "become", "available", "or", "timeout" ]
a176fd845f1e146610f03a1cb3cb0d661ebf4faa
https://github.com/gondor/kbop/blob/a176fd845f1e146610f03a1cb3cb0d661ebf4faa/src/main/java/org/pacesys/kbop/internal/AbstractKeyedObjectPool.java#L89-L95
149,768
gondor/kbop
src/main/java/org/pacesys/kbop/internal/AbstractKeyedObjectPool.java
AbstractKeyedObjectPool.createOrAttemptToBorrow
protected E createOrAttemptToBorrow(final PoolKey<K> key) { E entry = null; if (!pool.containsKey(key)) { entry = create(key).initialize(key, this); pool.put(key, entry); borrowed.add(entry); return entry; } entry = pool.get(key); if (borrowed.add(entry)) { factory.activate(entry.get()); return entry; } return entry.isCurrentOwner() ? entry : null; }
java
protected E createOrAttemptToBorrow(final PoolKey<K> key) { E entry = null; if (!pool.containsKey(key)) { entry = create(key).initialize(key, this); pool.put(key, entry); borrowed.add(entry); return entry; } entry = pool.get(key); if (borrowed.add(entry)) { factory.activate(entry.get()); return entry; } return entry.isCurrentOwner() ? entry : null; }
[ "protected", "E", "createOrAttemptToBorrow", "(", "final", "PoolKey", "<", "K", ">", "key", ")", "{", "E", "entry", "=", "null", ";", "if", "(", "!", "pool", ".", "containsKey", "(", "key", ")", ")", "{", "entry", "=", "create", "(", "key", ")", ".", "initialize", "(", "key", ",", "this", ")", ";", "pool", ".", "put", "(", "key", ",", "entry", ")", ";", "borrowed", ".", "add", "(", "entry", ")", ";", "return", "entry", ";", "}", "entry", "=", "pool", ".", "get", "(", "key", ")", ";", "if", "(", "borrowed", ".", "add", "(", "entry", ")", ")", "{", "factory", ".", "activate", "(", "entry", ".", "get", "(", ")", ")", ";", "return", "entry", ";", "}", "return", "entry", ".", "isCurrentOwner", "(", ")", "?", "entry", ":", "null", ";", "}" ]
Default Single Key to Single Object implementation. Advanced Pools extending this class can override this behavior. If the key does not exist then an entry should be created and returned. If the key exists and is not borrowed then the entry should be returned. If the key exists and is already borrowed then null should be returned. It is up to the implementation of this method to update the borrowed queue @param key the Pool lookup key @return Entry if available
[ "Default", "Single", "Key", "to", "Single", "Object", "implementation", ".", "Advanced", "Pools", "extending", "this", "class", "can", "override", "this", "behavior", ".", "If", "the", "key", "does", "not", "exist", "then", "an", "entry", "should", "be", "created", "and", "returned", ".", "If", "the", "key", "exists", "and", "is", "not", "borrowed", "then", "the", "entry", "should", "be", "returned", "." ]
a176fd845f1e146610f03a1cb3cb0d661ebf4faa
https://github.com/gondor/kbop/blob/a176fd845f1e146610f03a1cb3cb0d661ebf4faa/src/main/java/org/pacesys/kbop/internal/AbstractKeyedObjectPool.java#L185-L204
149,769
gondor/kbop
src/main/java/org/pacesys/kbop/internal/AbstractKeyedObjectPool.java
AbstractKeyedObjectPool.await
protected boolean await(final PoolWaitFuture<E> future, final PoolKey<K> key, Date deadline) throws InterruptedException { try { waiting.add(future); return future.await(deadline); } finally { waiting.remove(future); } }
java
protected boolean await(final PoolWaitFuture<E> future, final PoolKey<K> key, Date deadline) throws InterruptedException { try { waiting.add(future); return future.await(deadline); } finally { waiting.remove(future); } }
[ "protected", "boolean", "await", "(", "final", "PoolWaitFuture", "<", "E", ">", "future", ",", "final", "PoolKey", "<", "K", ">", "key", ",", "Date", "deadline", ")", "throws", "InterruptedException", "{", "try", "{", "waiting", ".", "add", "(", "future", ")", ";", "return", "future", ".", "await", "(", "deadline", ")", ";", "}", "finally", "{", "waiting", ".", "remove", "(", "future", ")", ";", "}", "}" ]
Adds the current PoolWaitFuture into the waiting list. The future will wait up until the specified deadline. If the future is woken up before the specified deadline then true is returned otherwise false. The future will always be removed from the wait list regardless of the outcome. @param future the PoolWaitFuture who is waiting for an object @param key the Pool Key associated with this wait @param deadline the max timeout to wait for @return true if @throws InterruptedException the interrupted exception
[ "Adds", "the", "current", "PoolWaitFuture", "into", "the", "waiting", "list", ".", "The", "future", "will", "wait", "up", "until", "the", "specified", "deadline", ".", "If", "the", "future", "is", "woken", "up", "before", "the", "specified", "deadline", "then", "true", "is", "returned", "otherwise", "false", ".", "The", "future", "will", "always", "be", "removed", "from", "the", "wait", "list", "regardless", "of", "the", "outcome", "." ]
a176fd845f1e146610f03a1cb3cb0d661ebf4faa
https://github.com/gondor/kbop/blob/a176fd845f1e146610f03a1cb3cb0d661ebf4faa/src/main/java/org/pacesys/kbop/internal/AbstractKeyedObjectPool.java#L217-L226
149,770
dhemery/hartley
src/main/java/com/dhemery/core/Lazily.java
Lazily.get
public static <T> Lazy<T> get(Supplier<? extends T> supplier) { return new SuppliedLazy<T>(supplier); }
java
public static <T> Lazy<T> get(Supplier<? extends T> supplier) { return new SuppliedLazy<T>(supplier); }
[ "public", "static", "<", "T", ">", "Lazy", "<", "T", ">", "get", "(", "Supplier", "<", "?", "extends", "T", ">", "supplier", ")", "{", "return", "new", "SuppliedLazy", "<", "T", ">", "(", "supplier", ")", ";", "}" ]
Create a lazy supplier that will obtain its value from another supplier. @param supplier the supplier from which to obtain the value @param <T> the type of value to supply @return a lazy supplier that will obtain its value from the given supplier
[ "Create", "a", "lazy", "supplier", "that", "will", "obtain", "its", "value", "from", "another", "supplier", "." ]
7754bd6bc12695f2249601b8890da530a61fcf33
https://github.com/dhemery/hartley/blob/7754bd6bc12695f2249601b8890da530a61fcf33/src/main/java/com/dhemery/core/Lazily.java#L15-L17
149,771
dhemery/hartley
src/main/java/com/dhemery/core/Lazily.java
Lazily.build
public static <T> Lazy<T> build(final Builder<? extends T> builder) { return new SuppliedLazy<T>(new Supplier<T>() { @Override public T get() { return builder.build(); } }); }
java
public static <T> Lazy<T> build(final Builder<? extends T> builder) { return new SuppliedLazy<T>(new Supplier<T>() { @Override public T get() { return builder.build(); } }); }
[ "public", "static", "<", "T", ">", "Lazy", "<", "T", ">", "build", "(", "final", "Builder", "<", "?", "extends", "T", ">", "builder", ")", "{", "return", "new", "SuppliedLazy", "<", "T", ">", "(", "new", "Supplier", "<", "T", ">", "(", ")", "{", "@", "Override", "public", "T", "get", "(", ")", "{", "return", "builder", ".", "build", "(", ")", ";", "}", "}", ")", ";", "}" ]
Create a lazy supplier that will obtain its value from a builder. @param builder the builder from which to obtain the value @param <T> the type of value to supply @return a lazy supplier that will obtain its value from the given builder
[ "Create", "a", "lazy", "supplier", "that", "will", "obtain", "its", "value", "from", "a", "builder", "." ]
7754bd6bc12695f2249601b8890da530a61fcf33
https://github.com/dhemery/hartley/blob/7754bd6bc12695f2249601b8890da530a61fcf33/src/main/java/com/dhemery/core/Lazily.java#L25-L32
149,772
nhurion/vaadin-for-heroku
src/main/java/eu/hurion/vaadin/heroku/VaadinForHeroku.java
VaadinForHeroku.localServer
public static VaadinForHeroku localServer(final VaadinForHeroku server) { return server.withHttpPort(VaadinForHeroku.DEFAULT_PORT) .withProductionMode(false) .openBrowser(true); }
java
public static VaadinForHeroku localServer(final VaadinForHeroku server) { return server.withHttpPort(VaadinForHeroku.DEFAULT_PORT) .withProductionMode(false) .openBrowser(true); }
[ "public", "static", "VaadinForHeroku", "localServer", "(", "final", "VaadinForHeroku", "server", ")", "{", "return", "server", ".", "withHttpPort", "(", "VaadinForHeroku", ".", "DEFAULT_PORT", ")", ".", "withProductionMode", "(", "false", ")", ".", "openBrowser", "(", "true", ")", ";", "}" ]
Configures the given server for local development @param server the server to be configured for local development @since 0.3
[ "Configures", "the", "given", "server", "for", "local", "development" ]
51b1c22827934eb6105b0cfb0254cc15df23e991
https://github.com/nhurion/vaadin-for-heroku/blob/51b1c22827934eb6105b0cfb0254cc15df23e991/src/main/java/eu/hurion/vaadin/heroku/VaadinForHeroku.java#L69-L74
149,773
nhurion/vaadin-for-heroku
src/main/java/eu/hurion/vaadin/heroku/VaadinForHeroku.java
VaadinForHeroku.herokuServer
public static VaadinForHeroku herokuServer(final VaadinForHeroku server) { return server .withMemcachedSessionManager(MemcachedManagerBuilder.memcacheAddOn()) .withHttpPort(Integer.parseInt(System.getenv(VaadinForHeroku.PORT))) .withProductionMode(true) .openBrowser(false); }
java
public static VaadinForHeroku herokuServer(final VaadinForHeroku server) { return server .withMemcachedSessionManager(MemcachedManagerBuilder.memcacheAddOn()) .withHttpPort(Integer.parseInt(System.getenv(VaadinForHeroku.PORT))) .withProductionMode(true) .openBrowser(false); }
[ "public", "static", "VaadinForHeroku", "herokuServer", "(", "final", "VaadinForHeroku", "server", ")", "{", "return", "server", ".", "withMemcachedSessionManager", "(", "MemcachedManagerBuilder", ".", "memcacheAddOn", "(", ")", ")", ".", "withHttpPort", "(", "Integer", ".", "parseInt", "(", "System", ".", "getenv", "(", "VaadinForHeroku", ".", "PORT", ")", ")", ")", ".", "withProductionMode", "(", "true", ")", ".", "openBrowser", "(", "false", ")", ";", "}" ]
Configures the given server for Heroku @param server the server to be configured for heroku environment @since 0.3
[ "Configures", "the", "given", "server", "for", "Heroku" ]
51b1c22827934eb6105b0cfb0254cc15df23e991
https://github.com/nhurion/vaadin-for-heroku/blob/51b1c22827934eb6105b0cfb0254cc15df23e991/src/main/java/eu/hurion/vaadin/heroku/VaadinForHeroku.java#L82-L89
149,774
nhurion/vaadin-for-heroku
src/main/java/eu/hurion/vaadin/heroku/VaadinForHeroku.java
VaadinForHeroku.withFilterDefinition
public VaadinForHeroku withFilterDefinition(final FilterDefinitionBuilder... filterDefs){ checkVarArgsArguments(filterDefs); this.filterDefinitions.addAll(Arrays.asList(filterDefs)); return self(); }
java
public VaadinForHeroku withFilterDefinition(final FilterDefinitionBuilder... filterDefs){ checkVarArgsArguments(filterDefs); this.filterDefinitions.addAll(Arrays.asList(filterDefs)); return self(); }
[ "public", "VaadinForHeroku", "withFilterDefinition", "(", "final", "FilterDefinitionBuilder", "...", "filterDefs", ")", "{", "checkVarArgsArguments", "(", "filterDefs", ")", ";", "this", ".", "filterDefinitions", ".", "addAll", "(", "Arrays", ".", "asList", "(", "filterDefs", ")", ")", ";", "return", "self", "(", ")", ";", "}" ]
Add filter definitions to the server configuration. @param filterDefs the filter definition(s) to add. @since 0.3
[ "Add", "filter", "definitions", "to", "the", "server", "configuration", "." ]
51b1c22827934eb6105b0cfb0254cc15df23e991
https://github.com/nhurion/vaadin-for-heroku/blob/51b1c22827934eb6105b0cfb0254cc15df23e991/src/main/java/eu/hurion/vaadin/heroku/VaadinForHeroku.java#L163-L167
149,775
nhurion/vaadin-for-heroku
src/main/java/eu/hurion/vaadin/heroku/VaadinForHeroku.java
VaadinForHeroku.withApplicationListener
public VaadinForHeroku withApplicationListener(final String... listeners){ checkVarArgsArguments(listeners); this.applicationListeners.addAll(Arrays.asList(listeners)); return self(); }
java
public VaadinForHeroku withApplicationListener(final String... listeners){ checkVarArgsArguments(listeners); this.applicationListeners.addAll(Arrays.asList(listeners)); return self(); }
[ "public", "VaadinForHeroku", "withApplicationListener", "(", "final", "String", "...", "listeners", ")", "{", "checkVarArgsArguments", "(", "listeners", ")", ";", "this", ".", "applicationListeners", ".", "addAll", "(", "Arrays", ".", "asList", "(", "listeners", ")", ")", ";", "return", "self", "(", ")", ";", "}" ]
Add an application listener to the configuration of the server. @param listeners the application listener(s) to add to the server configuration. @since 0.3
[ "Add", "an", "application", "listener", "to", "the", "configuration", "of", "the", "server", "." ]
51b1c22827934eb6105b0cfb0254cc15df23e991
https://github.com/nhurion/vaadin-for-heroku/blob/51b1c22827934eb6105b0cfb0254cc15df23e991/src/main/java/eu/hurion/vaadin/heroku/VaadinForHeroku.java#L189-L193
149,776
Terradue/jcatalogue-client
core/src/main/java/com/terradue/jcatalogue/client/CatalogueClient.java
CatalogueClient.invoke
<CE extends CatalogueEntity> CE invoke( final DigesterLoader digesterLoader, String uri, Parameter...parameters ) { uri = checkNotNull( uri, "Input URI cannot be null" ); try { return invoke( digesterLoader, new URI( uri ), parameters ); } catch ( URISyntaxException e ) { throw new RuntimeException( uri + " is not a valid URI", e ); } }
java
<CE extends CatalogueEntity> CE invoke( final DigesterLoader digesterLoader, String uri, Parameter...parameters ) { uri = checkNotNull( uri, "Input URI cannot be null" ); try { return invoke( digesterLoader, new URI( uri ), parameters ); } catch ( URISyntaxException e ) { throw new RuntimeException( uri + " is not a valid URI", e ); } }
[ "<", "CE", "extends", "CatalogueEntity", ">", "CE", "invoke", "(", "final", "DigesterLoader", "digesterLoader", ",", "String", "uri", ",", "Parameter", "...", "parameters", ")", "{", "uri", "=", "checkNotNull", "(", "uri", ",", "\"Input URI cannot be null\"", ")", ";", "try", "{", "return", "invoke", "(", "digesterLoader", ",", "new", "URI", "(", "uri", ")", ",", "parameters", ")", ";", "}", "catch", "(", "URISyntaxException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "uri", "+", "\" is not a valid URI\"", ",", "e", ")", ";", "}", "}" ]
generic internal methods
[ "generic", "internal", "methods" ]
1f24c4da952d8ad2373c4fa97eed48b0b8a88d21
https://github.com/Terradue/jcatalogue-client/blob/1f24c4da952d8ad2373c4fa97eed48b0b8a88d21/core/src/main/java/com/terradue/jcatalogue/client/CatalogueClient.java#L180-L192
149,777
mlhartme/mork
src/main/java/net/oneandone/mork/semantics/Alternative.java
Alternative.compare
public int compare(Alternative ab) { if (production != ab.production) { throw new IllegalArgumentException(); } // TODO: compare two ups if (resultOfs != -1 || ab.resultOfs != -1) { return NE; } if (argsOfs.size() == 0 && ab.argsOfs.size() == 0) { return EQ; } if (argsOfs.size() == 0 || ab.argsOfs.size() == 0) { return ALT; } if (max(argsOfs) < min(ab.argsOfs)) { return LT; } if (min(argsOfs) > max(ab.argsOfs)) { return GT; } if (argsOfs.size() != 1 || ab.argsOfs.size() != 1) { return NE; } else { if (argsOfs.get(0) != ab.argsOfs.get(0)) { throw new IllegalStateException(); } return EQ; } }
java
public int compare(Alternative ab) { if (production != ab.production) { throw new IllegalArgumentException(); } // TODO: compare two ups if (resultOfs != -1 || ab.resultOfs != -1) { return NE; } if (argsOfs.size() == 0 && ab.argsOfs.size() == 0) { return EQ; } if (argsOfs.size() == 0 || ab.argsOfs.size() == 0) { return ALT; } if (max(argsOfs) < min(ab.argsOfs)) { return LT; } if (min(argsOfs) > max(ab.argsOfs)) { return GT; } if (argsOfs.size() != 1 || ab.argsOfs.size() != 1) { return NE; } else { if (argsOfs.get(0) != ab.argsOfs.get(0)) { throw new IllegalStateException(); } return EQ; } }
[ "public", "int", "compare", "(", "Alternative", "ab", ")", "{", "if", "(", "production", "!=", "ab", ".", "production", ")", "{", "throw", "new", "IllegalArgumentException", "(", ")", ";", "}", "// TODO: compare two ups", "if", "(", "resultOfs", "!=", "-", "1", "||", "ab", ".", "resultOfs", "!=", "-", "1", ")", "{", "return", "NE", ";", "}", "if", "(", "argsOfs", ".", "size", "(", ")", "==", "0", "&&", "ab", ".", "argsOfs", ".", "size", "(", ")", "==", "0", ")", "{", "return", "EQ", ";", "}", "if", "(", "argsOfs", ".", "size", "(", ")", "==", "0", "||", "ab", ".", "argsOfs", ".", "size", "(", ")", "==", "0", ")", "{", "return", "ALT", ";", "}", "if", "(", "max", "(", "argsOfs", ")", "<", "min", "(", "ab", ".", "argsOfs", ")", ")", "{", "return", "LT", ";", "}", "if", "(", "min", "(", "argsOfs", ")", ">", "max", "(", "ab", ".", "argsOfs", ")", ")", "{", "return", "GT", ";", "}", "if", "(", "argsOfs", ".", "size", "(", ")", "!=", "1", "||", "ab", ".", "argsOfs", ".", "size", "(", ")", "!=", "1", ")", "{", "return", "NE", ";", "}", "else", "{", "if", "(", "argsOfs", ".", "get", "(", "0", ")", "!=", "ab", ".", "argsOfs", ".", "get", "(", "0", ")", ")", "{", "throw", "new", "IllegalStateException", "(", ")", ";", "}", "return", "EQ", ";", "}", "}" ]
Compares functions. @return NE: neither LT nor GT. EQ: maybe. ALT: equal, but don't add follow states
[ "Compares", "functions", "." ]
a069b087750c4133bfeebaf1f599c3bc96762113
https://github.com/mlhartme/mork/blob/a069b087750c4133bfeebaf1f599c3bc96762113/src/main/java/net/oneandone/mork/semantics/Alternative.java#L72-L100
149,778
likethecolor/Alchemy-API
src/main/java/com/likethecolor/alchemy/api/entity/AlchemyVerb.java
AlchemyVerb.setIsNegated
public void setIsNegated(final Integer isNegated) { if(isNegated != null) { if(isNegated == 1) { setIsNegated(true); } if(isNegated == 0) { setIsNegated(false); } } }
java
public void setIsNegated(final Integer isNegated) { if(isNegated != null) { if(isNegated == 1) { setIsNegated(true); } if(isNegated == 0) { setIsNegated(false); } } }
[ "public", "void", "setIsNegated", "(", "final", "Integer", "isNegated", ")", "{", "if", "(", "isNegated", "!=", "null", ")", "{", "if", "(", "isNegated", "==", "1", ")", "{", "setIsNegated", "(", "true", ")", ";", "}", "if", "(", "isNegated", "==", "0", ")", "{", "setIsNegated", "(", "false", ")", ";", "}", "}", "}" ]
Set whether this action verb was negated. @param isNegated whether this action verb was negated
[ "Set", "whether", "this", "action", "verb", "was", "negated", "." ]
5208cfc92a878ceeaff052787af29da92d98db7e
https://github.com/likethecolor/Alchemy-API/blob/5208cfc92a878ceeaff052787af29da92d98db7e/src/main/java/com/likethecolor/alchemy/api/entity/AlchemyVerb.java#L65-L74
149,779
cnery/cgateinterface
src/com/daveoxley/cbus/CGateInterface.java
CGateInterface.connect
public static CGateSession connect(InetAddress cgate_server, int command_port, int event_port, int status_change_port) { return new CGateSession(cgate_server, command_port, event_port, status_change_port); }
java
public static CGateSession connect(InetAddress cgate_server, int command_port, int event_port, int status_change_port) { return new CGateSession(cgate_server, command_port, event_port, status_change_port); }
[ "public", "static", "CGateSession", "connect", "(", "InetAddress", "cgate_server", ",", "int", "command_port", ",", "int", "event_port", ",", "int", "status_change_port", ")", "{", "return", "new", "CGateSession", "(", "cgate_server", ",", "command_port", ",", "event_port", ",", "status_change_port", ")", ";", "}" ]
Connect to a C-Gate server using the supplied cgate_server and cgate_port. @param cgate_server The <code>InetAddress</code> of the C-Gate server @param command_port The command port for the C-Gate server @param event_port The event port for the C-Gate server @param status_change_port The status change port for the C-Gate server @return CGateSession The C-Gate session
[ "Connect", "to", "a", "C", "-", "Gate", "server", "using", "the", "supplied", "cgate_server", "and", "cgate_port", "." ]
faef84f60b31601240ab4cbf026670822a782b0b
https://github.com/cnery/cgateinterface/blob/faef84f60b31601240ab4cbf026670822a782b0b/src/com/daveoxley/cbus/CGateInterface.java#L65-L68
149,780
bi-geek/flink-connector-ethereum
src/main/java/com/bigeek/flink/utils/EthereumUtils.java
EthereumUtils.createOkHttpClient
private static OkHttpClient createOkHttpClient(Long timeoutSeconds) { OkHttpClient.Builder builder = new OkHttpClient.Builder(); if (timeoutSeconds != null) { builder.connectTimeout(timeoutSeconds, TimeUnit.SECONDS); builder.readTimeout(timeoutSeconds, TimeUnit.SECONDS); builder.writeTimeout(timeoutSeconds, TimeUnit.SECONDS); } return builder.build(); }
java
private static OkHttpClient createOkHttpClient(Long timeoutSeconds) { OkHttpClient.Builder builder = new OkHttpClient.Builder(); if (timeoutSeconds != null) { builder.connectTimeout(timeoutSeconds, TimeUnit.SECONDS); builder.readTimeout(timeoutSeconds, TimeUnit.SECONDS); builder.writeTimeout(timeoutSeconds, TimeUnit.SECONDS); } return builder.build(); }
[ "private", "static", "OkHttpClient", "createOkHttpClient", "(", "Long", "timeoutSeconds", ")", "{", "OkHttpClient", ".", "Builder", "builder", "=", "new", "OkHttpClient", ".", "Builder", "(", ")", ";", "if", "(", "timeoutSeconds", "!=", "null", ")", "{", "builder", ".", "connectTimeout", "(", "timeoutSeconds", ",", "TimeUnit", ".", "SECONDS", ")", ";", "builder", ".", "readTimeout", "(", "timeoutSeconds", ",", "TimeUnit", ".", "SECONDS", ")", ";", "builder", ".", "writeTimeout", "(", "timeoutSeconds", ",", "TimeUnit", ".", "SECONDS", ")", ";", "}", "return", "builder", ".", "build", "(", ")", ";", "}" ]
Create OkHttpClient client for Web3j. @param timeoutSeconds, can be null @return OkHttpClient.
[ "Create", "OkHttpClient", "client", "for", "Web3j", "." ]
9ecedbf999fc410e50225c3f69b5041df4c61a33
https://github.com/bi-geek/flink-connector-ethereum/blob/9ecedbf999fc410e50225c3f69b5041df4c61a33/src/main/java/com/bigeek/flink/utils/EthereumUtils.java#L29-L37
149,781
bi-geek/flink-connector-ethereum
src/main/java/com/bigeek/flink/utils/EthereumUtils.java
EthereumUtils.generateClient
public static Web3j generateClient(String clientAddress, Long timeoutSeconds) { if (isEmpty(clientAddress)) { throw new IllegalArgumentException("You have to define client address, use constructor or environment variable 'web3j.clientAddress'"); } Web3jService web3jService; if (clientAddress.startsWith("http")) { web3jService = new HttpService(clientAddress, createOkHttpClient(timeoutSeconds), false); } else if (clientAddress.startsWith("wss")) { try { web3jService = new WebSocketService(clientAddress, true); ((WebSocketService) web3jService).connect(); } catch (Exception ex) { throw new RuntimeException(ex); } } else if (System.getProperty("os.name").toLowerCase().startsWith("win")) { web3jService = new WindowsIpcService(clientAddress); } else { web3jService = new UnixIpcService(clientAddress); } return Web3j.build(web3jService); }
java
public static Web3j generateClient(String clientAddress, Long timeoutSeconds) { if (isEmpty(clientAddress)) { throw new IllegalArgumentException("You have to define client address, use constructor or environment variable 'web3j.clientAddress'"); } Web3jService web3jService; if (clientAddress.startsWith("http")) { web3jService = new HttpService(clientAddress, createOkHttpClient(timeoutSeconds), false); } else if (clientAddress.startsWith("wss")) { try { web3jService = new WebSocketService(clientAddress, true); ((WebSocketService) web3jService).connect(); } catch (Exception ex) { throw new RuntimeException(ex); } } else if (System.getProperty("os.name").toLowerCase().startsWith("win")) { web3jService = new WindowsIpcService(clientAddress); } else { web3jService = new UnixIpcService(clientAddress); } return Web3j.build(web3jService); }
[ "public", "static", "Web3j", "generateClient", "(", "String", "clientAddress", ",", "Long", "timeoutSeconds", ")", "{", "if", "(", "isEmpty", "(", "clientAddress", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"You have to define client address, use constructor or environment variable 'web3j.clientAddress'\"", ")", ";", "}", "Web3jService", "web3jService", ";", "if", "(", "clientAddress", ".", "startsWith", "(", "\"http\"", ")", ")", "{", "web3jService", "=", "new", "HttpService", "(", "clientAddress", ",", "createOkHttpClient", "(", "timeoutSeconds", ")", ",", "false", ")", ";", "}", "else", "if", "(", "clientAddress", ".", "startsWith", "(", "\"wss\"", ")", ")", "{", "try", "{", "web3jService", "=", "new", "WebSocketService", "(", "clientAddress", ",", "true", ")", ";", "(", "(", "WebSocketService", ")", "web3jService", ")", ".", "connect", "(", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "throw", "new", "RuntimeException", "(", "ex", ")", ";", "}", "}", "else", "if", "(", "System", ".", "getProperty", "(", "\"os.name\"", ")", ".", "toLowerCase", "(", ")", ".", "startsWith", "(", "\"win\"", ")", ")", "{", "web3jService", "=", "new", "WindowsIpcService", "(", "clientAddress", ")", ";", "}", "else", "{", "web3jService", "=", "new", "UnixIpcService", "(", "clientAddress", ")", ";", "}", "return", "Web3j", ".", "build", "(", "web3jService", ")", ";", "}" ]
Generate Ethereum client. @param clientAddress @param timeoutSeconds @return Web3j client
[ "Generate", "Ethereum", "client", "." ]
9ecedbf999fc410e50225c3f69b5041df4c61a33
https://github.com/bi-geek/flink-connector-ethereum/blob/9ecedbf999fc410e50225c3f69b5041df4c61a33/src/main/java/com/bigeek/flink/utils/EthereumUtils.java#L46-L68
149,782
bwkimmel/jdcp
jdcp-worker-app/src/main/java/ca/eandb/jdcp/worker/ConnectionDialog.java
ConnectionDialog.getMainPanel
private JPanel getMainPanel() { if (mainPanel == null) { mainPanel = new JPanel(); mainPanel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(5, 5, 5, 5); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy = 0; c.weightx = 0.0D; mainPanel.add(new JLabel("Host"), c); c.gridx = 1; c.weightx = 1.0D; mainPanel.add(getHostField(), c); c.gridx = 0; c.gridy = 1; c.weightx = 0.0D; mainPanel.add(new JLabel("User"), c); c.gridx = 1; c.weightx = 1.0D; mainPanel.add(getUserField(), c); c.gridx = 0; c.gridy = 2; c.weightx = 0.0D; mainPanel.add(new JLabel("Password"), c); c.gridx = 1; c.weightx = 1.0D; mainPanel.add(getPasswordField(), c); c.gridx = 0; c.gridy = 3; c.weightx = 1.0D; c.gridwidth = 2; mainPanel.add(getRememberPasswordCheckBox(), c); c.gridx = 0; c.gridy = 4; c.weightx = 1.0D; c.weighty = 1.0D; c.gridwidth = 2; mainPanel.add(new JPanel(), c); } return mainPanel; }
java
private JPanel getMainPanel() { if (mainPanel == null) { mainPanel = new JPanel(); mainPanel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(5, 5, 5, 5); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy = 0; c.weightx = 0.0D; mainPanel.add(new JLabel("Host"), c); c.gridx = 1; c.weightx = 1.0D; mainPanel.add(getHostField(), c); c.gridx = 0; c.gridy = 1; c.weightx = 0.0D; mainPanel.add(new JLabel("User"), c); c.gridx = 1; c.weightx = 1.0D; mainPanel.add(getUserField(), c); c.gridx = 0; c.gridy = 2; c.weightx = 0.0D; mainPanel.add(new JLabel("Password"), c); c.gridx = 1; c.weightx = 1.0D; mainPanel.add(getPasswordField(), c); c.gridx = 0; c.gridy = 3; c.weightx = 1.0D; c.gridwidth = 2; mainPanel.add(getRememberPasswordCheckBox(), c); c.gridx = 0; c.gridy = 4; c.weightx = 1.0D; c.weighty = 1.0D; c.gridwidth = 2; mainPanel.add(new JPanel(), c); } return mainPanel; }
[ "private", "JPanel", "getMainPanel", "(", ")", "{", "if", "(", "mainPanel", "==", "null", ")", "{", "mainPanel", "=", "new", "JPanel", "(", ")", ";", "mainPanel", ".", "setLayout", "(", "new", "GridBagLayout", "(", ")", ")", ";", "GridBagConstraints", "c", "=", "new", "GridBagConstraints", "(", ")", ";", "c", ".", "insets", "=", "new", "Insets", "(", "5", ",", "5", ",", "5", ",", "5", ")", ";", "c", ".", "fill", "=", "GridBagConstraints", ".", "HORIZONTAL", ";", "c", ".", "gridx", "=", "0", ";", "c", ".", "gridy", "=", "0", ";", "c", ".", "weightx", "=", "0.0D", ";", "mainPanel", ".", "add", "(", "new", "JLabel", "(", "\"Host\"", ")", ",", "c", ")", ";", "c", ".", "gridx", "=", "1", ";", "c", ".", "weightx", "=", "1.0D", ";", "mainPanel", ".", "add", "(", "getHostField", "(", ")", ",", "c", ")", ";", "c", ".", "gridx", "=", "0", ";", "c", ".", "gridy", "=", "1", ";", "c", ".", "weightx", "=", "0.0D", ";", "mainPanel", ".", "add", "(", "new", "JLabel", "(", "\"User\"", ")", ",", "c", ")", ";", "c", ".", "gridx", "=", "1", ";", "c", ".", "weightx", "=", "1.0D", ";", "mainPanel", ".", "add", "(", "getUserField", "(", ")", ",", "c", ")", ";", "c", ".", "gridx", "=", "0", ";", "c", ".", "gridy", "=", "2", ";", "c", ".", "weightx", "=", "0.0D", ";", "mainPanel", ".", "add", "(", "new", "JLabel", "(", "\"Password\"", ")", ",", "c", ")", ";", "c", ".", "gridx", "=", "1", ";", "c", ".", "weightx", "=", "1.0D", ";", "mainPanel", ".", "add", "(", "getPasswordField", "(", ")", ",", "c", ")", ";", "c", ".", "gridx", "=", "0", ";", "c", ".", "gridy", "=", "3", ";", "c", ".", "weightx", "=", "1.0D", ";", "c", ".", "gridwidth", "=", "2", ";", "mainPanel", ".", "add", "(", "getRememberPasswordCheckBox", "(", ")", ",", "c", ")", ";", "c", ".", "gridx", "=", "0", ";", "c", ".", "gridy", "=", "4", ";", "c", ".", "weightx", "=", "1.0D", ";", "c", ".", "weighty", "=", "1.0D", ";", "c", ".", "gridwidth", "=", "2", ";", "mainPanel", ".", "add", "(", "new", "JPanel", "(", ")", ",", "c", ")", ";", "}", "return", "mainPanel", ";", "}" ]
This method initializes mainPanel @return javax.swing.JPanel
[ "This", "method", "initializes", "mainPanel" ]
630c5150c245054e2556ff370f4bad2ec793dfb7
https://github.com/bwkimmel/jdcp/blob/630c5150c245054e2556ff370f4bad2ec793dfb7/jdcp-worker-app/src/main/java/ca/eandb/jdcp/worker/ConnectionDialog.java#L162-L212
149,783
bwkimmel/jdcp
jdcp-worker-app/src/main/java/ca/eandb/jdcp/worker/ConnectionDialog.java
ConnectionDialog.getButtonPanel
private JPanel getButtonPanel() { if (buttonPanel == null) { buttonPanel = new JPanel(); buttonPanel.setLayout(new GridBagLayout()); GridBagConstraints c1 = new GridBagConstraints(); c1.anchor = GridBagConstraints.EAST; c1.gridx = 0; c1.gridy = 0; c1.weightx = 1.0D; c1.insets = new Insets(5, 5, 5, 5); buttonPanel.add(getOkButton(), c1); GridBagConstraints c2 = new GridBagConstraints(); c2.gridx = 1; c2.gridy = 0; c2.weightx = 0.0D; c2.insets = new Insets(5, 5, 5, 5); buttonPanel.add(getCancelButton(), c2); } return buttonPanel; }
java
private JPanel getButtonPanel() { if (buttonPanel == null) { buttonPanel = new JPanel(); buttonPanel.setLayout(new GridBagLayout()); GridBagConstraints c1 = new GridBagConstraints(); c1.anchor = GridBagConstraints.EAST; c1.gridx = 0; c1.gridy = 0; c1.weightx = 1.0D; c1.insets = new Insets(5, 5, 5, 5); buttonPanel.add(getOkButton(), c1); GridBagConstraints c2 = new GridBagConstraints(); c2.gridx = 1; c2.gridy = 0; c2.weightx = 0.0D; c2.insets = new Insets(5, 5, 5, 5); buttonPanel.add(getCancelButton(), c2); } return buttonPanel; }
[ "private", "JPanel", "getButtonPanel", "(", ")", "{", "if", "(", "buttonPanel", "==", "null", ")", "{", "buttonPanel", "=", "new", "JPanel", "(", ")", ";", "buttonPanel", ".", "setLayout", "(", "new", "GridBagLayout", "(", ")", ")", ";", "GridBagConstraints", "c1", "=", "new", "GridBagConstraints", "(", ")", ";", "c1", ".", "anchor", "=", "GridBagConstraints", ".", "EAST", ";", "c1", ".", "gridx", "=", "0", ";", "c1", ".", "gridy", "=", "0", ";", "c1", ".", "weightx", "=", "1.0D", ";", "c1", ".", "insets", "=", "new", "Insets", "(", "5", ",", "5", ",", "5", ",", "5", ")", ";", "buttonPanel", ".", "add", "(", "getOkButton", "(", ")", ",", "c1", ")", ";", "GridBagConstraints", "c2", "=", "new", "GridBagConstraints", "(", ")", ";", "c2", ".", "gridx", "=", "1", ";", "c2", ".", "gridy", "=", "0", ";", "c2", ".", "weightx", "=", "0.0D", ";", "c2", ".", "insets", "=", "new", "Insets", "(", "5", ",", "5", ",", "5", ",", "5", ")", ";", "buttonPanel", ".", "add", "(", "getCancelButton", "(", ")", ",", "c2", ")", ";", "}", "return", "buttonPanel", ";", "}" ]
This method initializes buttonPanel @return javax.swing.JPanel
[ "This", "method", "initializes", "buttonPanel" ]
630c5150c245054e2556ff370f4bad2ec793dfb7
https://github.com/bwkimmel/jdcp/blob/630c5150c245054e2556ff370f4bad2ec793dfb7/jdcp-worker-app/src/main/java/ca/eandb/jdcp/worker/ConnectionDialog.java#L219-L240
149,784
bwkimmel/jdcp
jdcp-worker-app/src/main/java/ca/eandb/jdcp/worker/ConnectionDialog.java
ConnectionDialog.getCancelButton
private JButton getCancelButton() { if (cancelButton == null) { cancelButton = new JButton(); cancelButton.setText("Cancel"); cancelButton.setMnemonic('C'); cancelButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { cancelled = true; timedOut = false; restore(); setVisible(false); } }); } return cancelButton; }
java
private JButton getCancelButton() { if (cancelButton == null) { cancelButton = new JButton(); cancelButton.setText("Cancel"); cancelButton.setMnemonic('C'); cancelButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { cancelled = true; timedOut = false; restore(); setVisible(false); } }); } return cancelButton; }
[ "private", "JButton", "getCancelButton", "(", ")", "{", "if", "(", "cancelButton", "==", "null", ")", "{", "cancelButton", "=", "new", "JButton", "(", ")", ";", "cancelButton", ".", "setText", "(", "\"Cancel\"", ")", ";", "cancelButton", ".", "setMnemonic", "(", "'", "'", ")", ";", "cancelButton", ".", "addActionListener", "(", "new", "java", ".", "awt", ".", "event", ".", "ActionListener", "(", ")", "{", "public", "void", "actionPerformed", "(", "java", ".", "awt", ".", "event", ".", "ActionEvent", "e", ")", "{", "cancelled", "=", "true", ";", "timedOut", "=", "false", ";", "restore", "(", ")", ";", "setVisible", "(", "false", ")", ";", "}", "}", ")", ";", "}", "return", "cancelButton", ";", "}" ]
This method initializes cancelButton @return javax.swing.JButton
[ "This", "method", "initializes", "cancelButton" ]
630c5150c245054e2556ff370f4bad2ec793dfb7
https://github.com/bwkimmel/jdcp/blob/630c5150c245054e2556ff370f4bad2ec793dfb7/jdcp-worker-app/src/main/java/ca/eandb/jdcp/worker/ConnectionDialog.java#L269-L284
149,785
bwkimmel/jdcp
jdcp-worker-app/src/main/java/ca/eandb/jdcp/worker/ConnectionDialog.java
ConnectionDialog.save
private void save() { Preferences pref = Preferences .userNodeForPackage(ConnectionDialog.class); pref.put("host", getHost()); pref.put("user", getUser()); boolean remember = getRememberPasswordCheckBox().isSelected(); if (remember) { try { Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); KeyGenerator keygen = KeyGenerator.getInstance("AES"); SecureRandom random = SecureRandom.getInstance("SHA1PRNG"); random.setSeed(new byte[]{ 0x60, (byte) 0xFD, 0x28, 0x07, 0x35, 0x4A, 0x0D, 0x3B }); byte[] iv = new byte[16]; random.nextBytes(iv); IvParameterSpec spec = new IvParameterSpec(iv); keygen.init(128, random); cipher.init(Cipher.ENCRYPT_MODE, keygen.generateKey(), spec); byte[] clearText = getPassword().getBytes(); byte[] cipherText = cipher.doFinal(clearText); pref.putByteArray("password", cipherText); pref.putBoolean("remember", true); } catch (Exception e) { logger.error("Could not encrypt password", e); pref.remove("password"); pref.putBoolean("remember", false); } } else { pref.remove("password"); pref.putBoolean("remember", false); } }
java
private void save() { Preferences pref = Preferences .userNodeForPackage(ConnectionDialog.class); pref.put("host", getHost()); pref.put("user", getUser()); boolean remember = getRememberPasswordCheckBox().isSelected(); if (remember) { try { Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); KeyGenerator keygen = KeyGenerator.getInstance("AES"); SecureRandom random = SecureRandom.getInstance("SHA1PRNG"); random.setSeed(new byte[]{ 0x60, (byte) 0xFD, 0x28, 0x07, 0x35, 0x4A, 0x0D, 0x3B }); byte[] iv = new byte[16]; random.nextBytes(iv); IvParameterSpec spec = new IvParameterSpec(iv); keygen.init(128, random); cipher.init(Cipher.ENCRYPT_MODE, keygen.generateKey(), spec); byte[] clearText = getPassword().getBytes(); byte[] cipherText = cipher.doFinal(clearText); pref.putByteArray("password", cipherText); pref.putBoolean("remember", true); } catch (Exception e) { logger.error("Could not encrypt password", e); pref.remove("password"); pref.putBoolean("remember", false); } } else { pref.remove("password"); pref.putBoolean("remember", false); } }
[ "private", "void", "save", "(", ")", "{", "Preferences", "pref", "=", "Preferences", ".", "userNodeForPackage", "(", "ConnectionDialog", ".", "class", ")", ";", "pref", ".", "put", "(", "\"host\"", ",", "getHost", "(", ")", ")", ";", "pref", ".", "put", "(", "\"user\"", ",", "getUser", "(", ")", ")", ";", "boolean", "remember", "=", "getRememberPasswordCheckBox", "(", ")", ".", "isSelected", "(", ")", ";", "if", "(", "remember", ")", "{", "try", "{", "Cipher", "cipher", "=", "Cipher", ".", "getInstance", "(", "\"AES/CBC/PKCS5Padding\"", ")", ";", "KeyGenerator", "keygen", "=", "KeyGenerator", ".", "getInstance", "(", "\"AES\"", ")", ";", "SecureRandom", "random", "=", "SecureRandom", ".", "getInstance", "(", "\"SHA1PRNG\"", ")", ";", "random", ".", "setSeed", "(", "new", "byte", "[", "]", "{", "0x60", ",", "(", "byte", ")", "0xFD", ",", "0x28", ",", "0x07", ",", "0x35", ",", "0x4A", ",", "0x0D", ",", "0x3B", "}", ")", ";", "byte", "[", "]", "iv", "=", "new", "byte", "[", "16", "]", ";", "random", ".", "nextBytes", "(", "iv", ")", ";", "IvParameterSpec", "spec", "=", "new", "IvParameterSpec", "(", "iv", ")", ";", "keygen", ".", "init", "(", "128", ",", "random", ")", ";", "cipher", ".", "init", "(", "Cipher", ".", "ENCRYPT_MODE", ",", "keygen", ".", "generateKey", "(", ")", ",", "spec", ")", ";", "byte", "[", "]", "clearText", "=", "getPassword", "(", ")", ".", "getBytes", "(", ")", ";", "byte", "[", "]", "cipherText", "=", "cipher", ".", "doFinal", "(", "clearText", ")", ";", "pref", ".", "putByteArray", "(", "\"password\"", ",", "cipherText", ")", ";", "pref", ".", "putBoolean", "(", "\"remember\"", ",", "true", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "error", "(", "\"Could not encrypt password\"", ",", "e", ")", ";", "pref", ".", "remove", "(", "\"password\"", ")", ";", "pref", ".", "putBoolean", "(", "\"remember\"", ",", "false", ")", ";", "}", "}", "else", "{", "pref", ".", "remove", "(", "\"password\"", ")", ";", "pref", ".", "putBoolean", "(", "\"remember\"", ",", "false", ")", ";", "}", "}" ]
Saves field values to preferences.
[ "Saves", "field", "values", "to", "preferences", "." ]
630c5150c245054e2556ff370f4bad2ec793dfb7
https://github.com/bwkimmel/jdcp/blob/630c5150c245054e2556ff370f4bad2ec793dfb7/jdcp-worker-app/src/main/java/ca/eandb/jdcp/worker/ConnectionDialog.java#L405-L439
149,786
bwkimmel/jdcp
jdcp-worker-app/src/main/java/ca/eandb/jdcp/worker/ConnectionDialog.java
ConnectionDialog.restore
private void restore() { Preferences pref = Preferences .userNodeForPackage(ConnectionDialog.class); getHostField().setText(pref.get("host", "localhost")); getUserField().setText(pref.get("user", "guest")); boolean remember = pref.getBoolean("remember", false); boolean passwordSet = false; getRememberPasswordCheckBox().setSelected(remember); if (remember) { byte[] cipherText = pref.getByteArray("password", null); if (cipherText != null) { try { Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); KeyGenerator keygen = KeyGenerator.getInstance("AES"); SecureRandom random = SecureRandom.getInstance("SHA1PRNG"); random.setSeed(new byte[]{ 0x60, (byte) 0xFD, 0x28, 0x07, 0x35, 0x4A, 0x0D, 0x3B }); byte[] iv = new byte[16]; random.nextBytes(iv); IvParameterSpec spec = new IvParameterSpec(iv); keygen.init(128, random); cipher.init(Cipher.DECRYPT_MODE, keygen.generateKey(), spec); byte[] clearText = cipher.doFinal(cipherText); String password = new String(clearText); getPasswordField().setText(password); passwordSet = true; } catch (Exception e) { logger.error("Could not decrypt password", e); } } } if (!passwordSet) { getPasswordField().setText(""); } }
java
private void restore() { Preferences pref = Preferences .userNodeForPackage(ConnectionDialog.class); getHostField().setText(pref.get("host", "localhost")); getUserField().setText(pref.get("user", "guest")); boolean remember = pref.getBoolean("remember", false); boolean passwordSet = false; getRememberPasswordCheckBox().setSelected(remember); if (remember) { byte[] cipherText = pref.getByteArray("password", null); if (cipherText != null) { try { Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); KeyGenerator keygen = KeyGenerator.getInstance("AES"); SecureRandom random = SecureRandom.getInstance("SHA1PRNG"); random.setSeed(new byte[]{ 0x60, (byte) 0xFD, 0x28, 0x07, 0x35, 0x4A, 0x0D, 0x3B }); byte[] iv = new byte[16]; random.nextBytes(iv); IvParameterSpec spec = new IvParameterSpec(iv); keygen.init(128, random); cipher.init(Cipher.DECRYPT_MODE, keygen.generateKey(), spec); byte[] clearText = cipher.doFinal(cipherText); String password = new String(clearText); getPasswordField().setText(password); passwordSet = true; } catch (Exception e) { logger.error("Could not decrypt password", e); } } } if (!passwordSet) { getPasswordField().setText(""); } }
[ "private", "void", "restore", "(", ")", "{", "Preferences", "pref", "=", "Preferences", ".", "userNodeForPackage", "(", "ConnectionDialog", ".", "class", ")", ";", "getHostField", "(", ")", ".", "setText", "(", "pref", ".", "get", "(", "\"host\"", ",", "\"localhost\"", ")", ")", ";", "getUserField", "(", ")", ".", "setText", "(", "pref", ".", "get", "(", "\"user\"", ",", "\"guest\"", ")", ")", ";", "boolean", "remember", "=", "pref", ".", "getBoolean", "(", "\"remember\"", ",", "false", ")", ";", "boolean", "passwordSet", "=", "false", ";", "getRememberPasswordCheckBox", "(", ")", ".", "setSelected", "(", "remember", ")", ";", "if", "(", "remember", ")", "{", "byte", "[", "]", "cipherText", "=", "pref", ".", "getByteArray", "(", "\"password\"", ",", "null", ")", ";", "if", "(", "cipherText", "!=", "null", ")", "{", "try", "{", "Cipher", "cipher", "=", "Cipher", ".", "getInstance", "(", "\"AES/CBC/PKCS5Padding\"", ")", ";", "KeyGenerator", "keygen", "=", "KeyGenerator", ".", "getInstance", "(", "\"AES\"", ")", ";", "SecureRandom", "random", "=", "SecureRandom", ".", "getInstance", "(", "\"SHA1PRNG\"", ")", ";", "random", ".", "setSeed", "(", "new", "byte", "[", "]", "{", "0x60", ",", "(", "byte", ")", "0xFD", ",", "0x28", ",", "0x07", ",", "0x35", ",", "0x4A", ",", "0x0D", ",", "0x3B", "}", ")", ";", "byte", "[", "]", "iv", "=", "new", "byte", "[", "16", "]", ";", "random", ".", "nextBytes", "(", "iv", ")", ";", "IvParameterSpec", "spec", "=", "new", "IvParameterSpec", "(", "iv", ")", ";", "keygen", ".", "init", "(", "128", ",", "random", ")", ";", "cipher", ".", "init", "(", "Cipher", ".", "DECRYPT_MODE", ",", "keygen", ".", "generateKey", "(", ")", ",", "spec", ")", ";", "byte", "[", "]", "clearText", "=", "cipher", ".", "doFinal", "(", "cipherText", ")", ";", "String", "password", "=", "new", "String", "(", "clearText", ")", ";", "getPasswordField", "(", ")", ".", "setText", "(", "password", ")", ";", "passwordSet", "=", "true", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "error", "(", "\"Could not decrypt password\"", ",", "e", ")", ";", "}", "}", "}", "if", "(", "!", "passwordSet", ")", "{", "getPasswordField", "(", ")", ".", "setText", "(", "\"\"", ")", ";", "}", "}" ]
Restores persisted field values from preferences.
[ "Restores", "persisted", "field", "values", "from", "preferences", "." ]
630c5150c245054e2556ff370f4bad2ec793dfb7
https://github.com/bwkimmel/jdcp/blob/630c5150c245054e2556ff370f4bad2ec793dfb7/jdcp-worker-app/src/main/java/ca/eandb/jdcp/worker/ConnectionDialog.java#L444-L481
149,787
Metrink/croquet
croquet-core/src/main/java/com/metrink/croquet/CroquetRestBuilder.java
CroquetRestBuilder.addJpaEntity
public CroquetRestBuilder<T> addJpaEntity(final Class<? extends Serializable> entity) { // check to ensure the class has the @Entity annotation if(entity.getAnnotation(Entity.class) == null) { throw new IllegalArgumentException("Only classes marked with @Entity can be added"); } settings.getDatabaseSettings().addEntity(entity); return this; }
java
public CroquetRestBuilder<T> addJpaEntity(final Class<? extends Serializable> entity) { // check to ensure the class has the @Entity annotation if(entity.getAnnotation(Entity.class) == null) { throw new IllegalArgumentException("Only classes marked with @Entity can be added"); } settings.getDatabaseSettings().addEntity(entity); return this; }
[ "public", "CroquetRestBuilder", "<", "T", ">", "addJpaEntity", "(", "final", "Class", "<", "?", "extends", "Serializable", ">", "entity", ")", "{", "// check to ensure the class has the @Entity annotation", "if", "(", "entity", ".", "getAnnotation", "(", "Entity", ".", "class", ")", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Only classes marked with @Entity can be added\"", ")", ";", "}", "settings", ".", "getDatabaseSettings", "(", ")", ".", "addEntity", "(", "entity", ")", ";", "return", "this", ";", "}" ]
Adds a JPA entity to Croquet. @param entity the entity to add. @return the {@link CroquetRestBuilder}.
[ "Adds", "a", "JPA", "entity", "to", "Croquet", "." ]
1b0ed1327a104cf1f809ce4c3c5bf30a3d95384b
https://github.com/Metrink/croquet/blob/1b0ed1327a104cf1f809ce4c3c5bf30a3d95384b/croquet-core/src/main/java/com/metrink/croquet/CroquetRestBuilder.java#L168-L176
149,788
Metrink/croquet
croquet-core/src/main/java/com/metrink/croquet/CroquetRestBuilder.java
CroquetRestBuilder.addDbProperty
public CroquetRestBuilder<T> addDbProperty(final String property, final Object value) { settings.getDatabaseSettings().addProperty(property, value); return this; }
java
public CroquetRestBuilder<T> addDbProperty(final String property, final Object value) { settings.getDatabaseSettings().addProperty(property, value); return this; }
[ "public", "CroquetRestBuilder", "<", "T", ">", "addDbProperty", "(", "final", "String", "property", ",", "final", "Object", "value", ")", "{", "settings", ".", "getDatabaseSettings", "(", ")", ".", "addProperty", "(", "property", ",", "value", ")", ";", "return", "this", ";", "}" ]
Adds a property to the database configuration. <b>Only used when configuring the DB via the YAML file.</b> @param property the DB property to set. @param value the value of the property. @return the {@link CroquetRestBuilder}.
[ "Adds", "a", "property", "to", "the", "database", "configuration", "." ]
1b0ed1327a104cf1f809ce4c3c5bf30a3d95384b
https://github.com/Metrink/croquet/blob/1b0ed1327a104cf1f809ce4c3c5bf30a3d95384b/croquet-core/src/main/java/com/metrink/croquet/CroquetRestBuilder.java#L186-L189
149,789
Metrink/croquet
croquet-core/src/main/java/com/metrink/croquet/CroquetRestBuilder.java
CroquetRestBuilder.setSqlDialect
public CroquetRestBuilder<T> setSqlDialect(final Class<? extends Dialect> dialectClass) { settings.getDatabaseSettings().setDialectClass(dialectClass); return this; }
java
public CroquetRestBuilder<T> setSqlDialect(final Class<? extends Dialect> dialectClass) { settings.getDatabaseSettings().setDialectClass(dialectClass); return this; }
[ "public", "CroquetRestBuilder", "<", "T", ">", "setSqlDialect", "(", "final", "Class", "<", "?", "extends", "Dialect", ">", "dialectClass", ")", "{", "settings", ".", "getDatabaseSettings", "(", ")", ".", "setDialectClass", "(", "dialectClass", ")", ";", "return", "this", ";", "}" ]
Sets the hibernate.dialect class. @param dialectClass the dialect class to use. @return the {@link CroquetRestBuilder}.
[ "Sets", "the", "hibernate", ".", "dialect", "class", "." ]
1b0ed1327a104cf1f809ce4c3c5bf30a3d95384b
https://github.com/Metrink/croquet/blob/1b0ed1327a104cf1f809ce4c3c5bf30a3d95384b/croquet-core/src/main/java/com/metrink/croquet/CroquetRestBuilder.java#L196-L199
149,790
craterdog/java-general-utilities
src/main/java/craterdog/utils/ByteUtils.java
ByteUtils.shortToBytes
static public int shortToBytes(short s, byte[] buffer, int index) { int length = 2; for (int i = 0; i < length; i++) { buffer[index + length - i - 1] = (byte) (s >> (i * 8)); } return length; }
java
static public int shortToBytes(short s, byte[] buffer, int index) { int length = 2; for (int i = 0; i < length; i++) { buffer[index + length - i - 1] = (byte) (s >> (i * 8)); } return length; }
[ "static", "public", "int", "shortToBytes", "(", "short", "s", ",", "byte", "[", "]", "buffer", ",", "int", "index", ")", "{", "int", "length", "=", "2", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "{", "buffer", "[", "index", "+", "length", "-", "i", "-", "1", "]", "=", "(", "byte", ")", "(", "s", ">>", "(", "i", "*", "8", ")", ")", ";", "}", "return", "length", ";", "}" ]
This function converts a short into its corresponding byte format and inserts it into the specified buffer at the specified index. @param s The short to be converted. @param buffer The byte array. @param index The index in the array to begin inserting bytes. @return The number of bytes inserted.
[ "This", "function", "converts", "a", "short", "into", "its", "corresponding", "byte", "format", "and", "inserts", "it", "into", "the", "specified", "buffer", "at", "the", "specified", "index", "." ]
a3ff45eaa00c2b8ed5c53efe9fe5166065fc1f57
https://github.com/craterdog/java-general-utilities/blob/a3ff45eaa00c2b8ed5c53efe9fe5166065fc1f57/src/main/java/craterdog/utils/ByteUtils.java#L128-L134
149,791
craterdog/java-general-utilities
src/main/java/craterdog/utils/ByteUtils.java
ByteUtils.bytesToShort
static public short bytesToShort(byte[] buffer, int index) { int length = 2; short integer = 0; for (int i = 0; i < length; i++) { integer |= ((buffer[index + length - i - 1] & 0xFF) << (i * 8)); } return integer; }
java
static public short bytesToShort(byte[] buffer, int index) { int length = 2; short integer = 0; for (int i = 0; i < length; i++) { integer |= ((buffer[index + length - i - 1] & 0xFF) << (i * 8)); } return integer; }
[ "static", "public", "short", "bytesToShort", "(", "byte", "[", "]", "buffer", ",", "int", "index", ")", "{", "int", "length", "=", "2", ";", "short", "integer", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "{", "integer", "|=", "(", "(", "buffer", "[", "index", "+", "length", "-", "i", "-", "1", "]", "&", "0xFF", ")", "<<", "(", "i", "*", "8", ")", ")", ";", "}", "return", "integer", ";", "}" ]
This function converts the bytes in a byte array at the specified index to its corresponding short value. @param buffer The byte array containing the short. @param index The index for the first byte in the byte array. @return The corresponding short value.
[ "This", "function", "converts", "the", "bytes", "in", "a", "byte", "array", "at", "the", "specified", "index", "to", "its", "corresponding", "short", "value", "." ]
a3ff45eaa00c2b8ed5c53efe9fe5166065fc1f57
https://github.com/craterdog/java-general-utilities/blob/a3ff45eaa00c2b8ed5c53efe9fe5166065fc1f57/src/main/java/craterdog/utils/ByteUtils.java#L156-L163
149,792
craterdog/java-general-utilities
src/main/java/craterdog/utils/ByteUtils.java
ByteUtils.intToBytes
static public int intToBytes(int i, byte[] buffer, int index) { int length = buffer.length - index; if (length > 4) length = 4; for (int j = 0; j < length; j++) { buffer[index + length - j - 1] = (byte) (i >> (j * 8)); } return length; }
java
static public int intToBytes(int i, byte[] buffer, int index) { int length = buffer.length - index; if (length > 4) length = 4; for (int j = 0; j < length; j++) { buffer[index + length - j - 1] = (byte) (i >> (j * 8)); } return length; }
[ "static", "public", "int", "intToBytes", "(", "int", "i", ",", "byte", "[", "]", "buffer", ",", "int", "index", ")", "{", "int", "length", "=", "buffer", ".", "length", "-", "index", ";", "if", "(", "length", ">", "4", ")", "length", "=", "4", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "length", ";", "j", "++", ")", "{", "buffer", "[", "index", "+", "length", "-", "j", "-", "1", "]", "=", "(", "byte", ")", "(", "i", ">>", "(", "j", "*", "8", ")", ")", ";", "}", "return", "length", ";", "}" ]
This function converts a integer into its corresponding byte format and inserts it into the specified buffer at the specified index. @param i The integer to be converted. @param buffer The byte array. @param index The index in the array to begin inserting bytes. @return The number of bytes inserted.
[ "This", "function", "converts", "a", "integer", "into", "its", "corresponding", "byte", "format", "and", "inserts", "it", "into", "the", "specified", "buffer", "at", "the", "specified", "index", "." ]
a3ff45eaa00c2b8ed5c53efe9fe5166065fc1f57
https://github.com/craterdog/java-general-utilities/blob/a3ff45eaa00c2b8ed5c53efe9fe5166065fc1f57/src/main/java/craterdog/utils/ByteUtils.java#L203-L210
149,793
craterdog/java-general-utilities
src/main/java/craterdog/utils/ByteUtils.java
ByteUtils.bytesToInt
static public int bytesToInt(byte[] buffer, int index) { int length = buffer.length - index; if (length > 4) length = 4; int integer = 0; for (int i = 0; i < length; i++) { integer |= ((buffer[index + length - i - 1] & 0xFF) << (i * 8)); } return integer; }
java
static public int bytesToInt(byte[] buffer, int index) { int length = buffer.length - index; if (length > 4) length = 4; int integer = 0; for (int i = 0; i < length; i++) { integer |= ((buffer[index + length - i - 1] & 0xFF) << (i * 8)); } return integer; }
[ "static", "public", "int", "bytesToInt", "(", "byte", "[", "]", "buffer", ",", "int", "index", ")", "{", "int", "length", "=", "buffer", ".", "length", "-", "index", ";", "if", "(", "length", ">", "4", ")", "length", "=", "4", ";", "int", "integer", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "{", "integer", "|=", "(", "(", "buffer", "[", "index", "+", "length", "-", "i", "-", "1", "]", "&", "0xFF", ")", "<<", "(", "i", "*", "8", ")", ")", ";", "}", "return", "integer", ";", "}" ]
This function converts the bytes in a byte array at the specified index to its corresponding integer value. @param buffer The byte array containing the integer. @param index The index for the first byte in the byte array. @return The corresponding integer value.
[ "This", "function", "converts", "the", "bytes", "in", "a", "byte", "array", "at", "the", "specified", "index", "to", "its", "corresponding", "integer", "value", "." ]
a3ff45eaa00c2b8ed5c53efe9fe5166065fc1f57
https://github.com/craterdog/java-general-utilities/blob/a3ff45eaa00c2b8ed5c53efe9fe5166065fc1f57/src/main/java/craterdog/utils/ByteUtils.java#L232-L240
149,794
craterdog/java-general-utilities
src/main/java/craterdog/utils/ByteUtils.java
ByteUtils.longToBytes
static public int longToBytes(long l, byte[] buffer, int index) { int length = buffer.length - index; if (length > 8) length = 8; for (int i = 0; i < length; i++) { buffer[index + length - i - 1] = (byte) (l >> (i * 8)); } return length; }
java
static public int longToBytes(long l, byte[] buffer, int index) { int length = buffer.length - index; if (length > 8) length = 8; for (int i = 0; i < length; i++) { buffer[index + length - i - 1] = (byte) (l >> (i * 8)); } return length; }
[ "static", "public", "int", "longToBytes", "(", "long", "l", ",", "byte", "[", "]", "buffer", ",", "int", "index", ")", "{", "int", "length", "=", "buffer", ".", "length", "-", "index", ";", "if", "(", "length", ">", "8", ")", "length", "=", "8", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "{", "buffer", "[", "index", "+", "length", "-", "i", "-", "1", "]", "=", "(", "byte", ")", "(", "l", ">>", "(", "i", "*", "8", ")", ")", ";", "}", "return", "length", ";", "}" ]
This function converts a long into its corresponding byte format and inserts it into the specified buffer at the specified index. @param l The long to be converted. @param buffer The byte array. @param index The index in the array to begin inserting bytes. @return The number of bytes inserted.
[ "This", "function", "converts", "a", "long", "into", "its", "corresponding", "byte", "format", "and", "inserts", "it", "into", "the", "specified", "buffer", "at", "the", "specified", "index", "." ]
a3ff45eaa00c2b8ed5c53efe9fe5166065fc1f57
https://github.com/craterdog/java-general-utilities/blob/a3ff45eaa00c2b8ed5c53efe9fe5166065fc1f57/src/main/java/craterdog/utils/ByteUtils.java#L280-L287
149,795
craterdog/java-general-utilities
src/main/java/craterdog/utils/ByteUtils.java
ByteUtils.bytesToLong
static public long bytesToLong(byte[] buffer, int index) { int length = buffer.length - index; if (length > 8) length = 8; long l = 0; for (int i = 0; i < length; i++) { l |= ((buffer[index + length - i - 1] & 0xFFL) << (i * 8)); } return l; }
java
static public long bytesToLong(byte[] buffer, int index) { int length = buffer.length - index; if (length > 8) length = 8; long l = 0; for (int i = 0; i < length; i++) { l |= ((buffer[index + length - i - 1] & 0xFFL) << (i * 8)); } return l; }
[ "static", "public", "long", "bytesToLong", "(", "byte", "[", "]", "buffer", ",", "int", "index", ")", "{", "int", "length", "=", "buffer", ".", "length", "-", "index", ";", "if", "(", "length", ">", "8", ")", "length", "=", "8", ";", "long", "l", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "{", "l", "|=", "(", "(", "buffer", "[", "index", "+", "length", "-", "i", "-", "1", "]", "&", "0xFF", "L", ")", "<<", "(", "i", "*", "8", ")", ")", ";", "}", "return", "l", ";", "}" ]
This function converts the bytes in a byte array at the specified index to its corresponding long value. @param buffer The byte array containing the long. @param index The index for the first byte in the byte array. @return The corresponding long value.
[ "This", "function", "converts", "the", "bytes", "in", "a", "byte", "array", "at", "the", "specified", "index", "to", "its", "corresponding", "long", "value", "." ]
a3ff45eaa00c2b8ed5c53efe9fe5166065fc1f57
https://github.com/craterdog/java-general-utilities/blob/a3ff45eaa00c2b8ed5c53efe9fe5166065fc1f57/src/main/java/craterdog/utils/ByteUtils.java#L309-L317
149,796
craterdog/java-general-utilities
src/main/java/craterdog/utils/ByteUtils.java
ByteUtils.bigIntegerToBytes
static public int bigIntegerToBytes(BigInteger integer, byte[] buffer, int index) { int length = 4 + (integer.bitLength() + 8) / 8; System.arraycopy(intToBytes(length), 0, buffer, index, 4); // copy in the length index += 4; System.arraycopy(integer.toByteArray(), 0, buffer, index, length - 4); // copy in the big integer return length; }
java
static public int bigIntegerToBytes(BigInteger integer, byte[] buffer, int index) { int length = 4 + (integer.bitLength() + 8) / 8; System.arraycopy(intToBytes(length), 0, buffer, index, 4); // copy in the length index += 4; System.arraycopy(integer.toByteArray(), 0, buffer, index, length - 4); // copy in the big integer return length; }
[ "static", "public", "int", "bigIntegerToBytes", "(", "BigInteger", "integer", ",", "byte", "[", "]", "buffer", ",", "int", "index", ")", "{", "int", "length", "=", "4", "+", "(", "integer", ".", "bitLength", "(", ")", "+", "8", ")", "/", "8", ";", "System", ".", "arraycopy", "(", "intToBytes", "(", "length", ")", ",", "0", ",", "buffer", ",", "index", ",", "4", ")", ";", "// copy in the length", "index", "+=", "4", ";", "System", ".", "arraycopy", "(", "integer", ".", "toByteArray", "(", ")", ",", "0", ",", "buffer", ",", "index", ",", "length", "-", "4", ")", ";", "// copy in the big integer", "return", "length", ";", "}" ]
This function converts a big integer into its corresponding byte format and inserts it into the specified buffer at the specified index. @param integer The big integer to be converted. @param buffer The byte array. @param index The index in the array to begin inserting bytes. @return The number of bytes inserted.
[ "This", "function", "converts", "a", "big", "integer", "into", "its", "corresponding", "byte", "format", "and", "inserts", "it", "into", "the", "specified", "buffer", "at", "the", "specified", "index", "." ]
a3ff45eaa00c2b8ed5c53efe9fe5166065fc1f57
https://github.com/craterdog/java-general-utilities/blob/a3ff45eaa00c2b8ed5c53efe9fe5166065fc1f57/src/main/java/craterdog/utils/ByteUtils.java#L355-L361
149,797
craterdog/java-general-utilities
src/main/java/craterdog/utils/ByteUtils.java
ByteUtils.bytesToBigInteger
static public BigInteger bytesToBigInteger(byte[] buffer, int index) { int length = bytesToInt(buffer, index); // pull out the length of the big integer index += 4; byte[] bytes = new byte[length]; System.arraycopy(buffer, index, bytes, 0, length); // pull out the bytes for the big integer return new BigInteger(bytes); }
java
static public BigInteger bytesToBigInteger(byte[] buffer, int index) { int length = bytesToInt(buffer, index); // pull out the length of the big integer index += 4; byte[] bytes = new byte[length]; System.arraycopy(buffer, index, bytes, 0, length); // pull out the bytes for the big integer return new BigInteger(bytes); }
[ "static", "public", "BigInteger", "bytesToBigInteger", "(", "byte", "[", "]", "buffer", ",", "int", "index", ")", "{", "int", "length", "=", "bytesToInt", "(", "buffer", ",", "index", ")", ";", "// pull out the length of the big integer", "index", "+=", "4", ";", "byte", "[", "]", "bytes", "=", "new", "byte", "[", "length", "]", ";", "System", ".", "arraycopy", "(", "buffer", ",", "index", ",", "bytes", ",", "0", ",", "length", ")", ";", "// pull out the bytes for the big integer", "return", "new", "BigInteger", "(", "bytes", ")", ";", "}" ]
This function converts the bytes in a byte array at the specified index to its corresponding big integer value. @param buffer The byte array containing the big integer. @param index The index for the first byte in the byte array. @return The corresponding big integer value.
[ "This", "function", "converts", "the", "bytes", "in", "a", "byte", "array", "at", "the", "specified", "index", "to", "its", "corresponding", "big", "integer", "value", "." ]
a3ff45eaa00c2b8ed5c53efe9fe5166065fc1f57
https://github.com/craterdog/java-general-utilities/blob/a3ff45eaa00c2b8ed5c53efe9fe5166065fc1f57/src/main/java/craterdog/utils/ByteUtils.java#L383-L389
149,798
craterdog/java-general-utilities
src/main/java/craterdog/utils/ByteUtils.java
ByteUtils.doubleToBytes
static public int doubleToBytes(double s, byte[] buffer, int index) { long bits = Double.doubleToRawLongBits(s); int length = longToBytes(bits, buffer, index); return length; }
java
static public int doubleToBytes(double s, byte[] buffer, int index) { long bits = Double.doubleToRawLongBits(s); int length = longToBytes(bits, buffer, index); return length; }
[ "static", "public", "int", "doubleToBytes", "(", "double", "s", ",", "byte", "[", "]", "buffer", ",", "int", "index", ")", "{", "long", "bits", "=", "Double", ".", "doubleToRawLongBits", "(", "s", ")", ";", "int", "length", "=", "longToBytes", "(", "bits", ",", "buffer", ",", "index", ")", ";", "return", "length", ";", "}" ]
This function converts a double into its corresponding byte format and inserts it into the specified buffer at the specified index. @param s The double to be converted. @param buffer The byte array. @param index The index in the array to begin inserting bytes. @return The number of bytes inserted.
[ "This", "function", "converts", "a", "double", "into", "its", "corresponding", "byte", "format", "and", "inserts", "it", "into", "the", "specified", "buffer", "at", "the", "specified", "index", "." ]
a3ff45eaa00c2b8ed5c53efe9fe5166065fc1f57
https://github.com/craterdog/java-general-utilities/blob/a3ff45eaa00c2b8ed5c53efe9fe5166065fc1f57/src/main/java/craterdog/utils/ByteUtils.java#L429-L433
149,799
craterdog/java-general-utilities
src/main/java/craterdog/utils/ByteUtils.java
ByteUtils.bytesToDouble
static public double bytesToDouble(byte[] buffer, int index) { double real; long bits = bytesToLong(buffer, index); real = Double.longBitsToDouble(bits); return real; }
java
static public double bytesToDouble(byte[] buffer, int index) { double real; long bits = bytesToLong(buffer, index); real = Double.longBitsToDouble(bits); return real; }
[ "static", "public", "double", "bytesToDouble", "(", "byte", "[", "]", "buffer", ",", "int", "index", ")", "{", "double", "real", ";", "long", "bits", "=", "bytesToLong", "(", "buffer", ",", "index", ")", ";", "real", "=", "Double", ".", "longBitsToDouble", "(", "bits", ")", ";", "return", "real", ";", "}" ]
This function converts the bytes in a byte array at the specified index to its corresponding double value. @param buffer The byte array containing the double. @param index The index for the first byte in the byte array. @return The corresponding double value.
[ "This", "function", "converts", "the", "bytes", "in", "a", "byte", "array", "at", "the", "specified", "index", "to", "its", "corresponding", "double", "value", "." ]
a3ff45eaa00c2b8ed5c53efe9fe5166065fc1f57
https://github.com/craterdog/java-general-utilities/blob/a3ff45eaa00c2b8ed5c53efe9fe5166065fc1f57/src/main/java/craterdog/utils/ByteUtils.java#L455-L460