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
148,000
mlhartme/sushi
src/main/java/net/oneandone/sushi/io/Buffer.java
Buffer.copy
public long copy(InputStream in, OutputStream out, long max) throws IOException { int chunk; long all; long remaining; remaining = max; all = 0; while (remaining > 0) { // cast is save because the buffer.length is an integer chunk = in.read(buffer, 0, (int) Math.min(remaining, buffer.length)); if (chunk < 0) { break; } out.write(buffer, 0, chunk); all += chunk; remaining -= chunk; } out.flush(); return all; }
java
public long copy(InputStream in, OutputStream out, long max) throws IOException { int chunk; long all; long remaining; remaining = max; all = 0; while (remaining > 0) { // cast is save because the buffer.length is an integer chunk = in.read(buffer, 0, (int) Math.min(remaining, buffer.length)); if (chunk < 0) { break; } out.write(buffer, 0, chunk); all += chunk; remaining -= chunk; } out.flush(); return all; }
[ "public", "long", "copy", "(", "InputStream", "in", ",", "OutputStream", "out", ",", "long", "max", ")", "throws", "IOException", "{", "int", "chunk", ";", "long", "all", ";", "long", "remaining", ";", "remaining", "=", "max", ";", "all", "=", "0", ";", "while", "(", "remaining", ">", "0", ")", "{", "// cast is save because the buffer.length is an integer", "chunk", "=", "in", ".", "read", "(", "buffer", ",", "0", ",", "(", "int", ")", "Math", ".", "min", "(", "remaining", ",", "buffer", ".", "length", ")", ")", ";", "if", "(", "chunk", "<", "0", ")", "{", "break", ";", "}", "out", ".", "write", "(", "buffer", ",", "0", ",", "chunk", ")", ";", "all", "+=", "chunk", ";", "remaining", "-=", "chunk", ";", "}", "out", ".", "flush", "(", ")", ";", "return", "all", ";", "}" ]
Copies up to max bytes. @return number of bytes actually copied
[ "Copies", "up", "to", "max", "bytes", "." ]
4af33414b04bd58584d4febe5cc63ef6c7346a75
https://github.com/mlhartme/sushi/blob/4af33414b04bd58584d4febe5cc63ef6c7346a75/src/main/java/net/oneandone/sushi/io/Buffer.java#L165-L184
148,001
mlhartme/sushi
src/main/java/net/oneandone/sushi/io/Buffer.java
Buffer.skip
public long skip(InputStream src, long n) throws IOException { long done; int chunk; if (n <= 0) { return 0; } done = 0; while (done < n) { chunk = src.read(buffer, 0, (int) Math.min(Integer.MAX_VALUE, n - done)); if (chunk == -1) { break; } done += chunk; } return done; }
java
public long skip(InputStream src, long n) throws IOException { long done; int chunk; if (n <= 0) { return 0; } done = 0; while (done < n) { chunk = src.read(buffer, 0, (int) Math.min(Integer.MAX_VALUE, n - done)); if (chunk == -1) { break; } done += chunk; } return done; }
[ "public", "long", "skip", "(", "InputStream", "src", ",", "long", "n", ")", "throws", "IOException", "{", "long", "done", ";", "int", "chunk", ";", "if", "(", "n", "<=", "0", ")", "{", "return", "0", ";", "}", "done", "=", "0", ";", "while", "(", "done", "<", "n", ")", "{", "chunk", "=", "src", ".", "read", "(", "buffer", ",", "0", ",", "(", "int", ")", "Math", ".", "min", "(", "Integer", ".", "MAX_VALUE", ",", "n", "-", "done", ")", ")", ";", "if", "(", "chunk", "==", "-", "1", ")", "{", "break", ";", "}", "done", "+=", "chunk", ";", "}", "return", "done", ";", "}" ]
skip the specified number of bytes - or less, if eof is reached
[ "skip", "the", "specified", "number", "of", "bytes", "-", "or", "less", "if", "eof", "is", "reached" ]
4af33414b04bd58584d4febe5cc63ef6c7346a75
https://github.com/mlhartme/sushi/blob/4af33414b04bd58584d4febe5cc63ef6c7346a75/src/main/java/net/oneandone/sushi/io/Buffer.java#L187-L203
148,002
mlhartme/sushi
src/main/java/net/oneandone/sushi/io/LineReader.java
LineReader.next
public String next() throws IOException { String result; int len; Matcher matcher; while (true) { matcher = format.separator.matcher(buffer); if (matcher.find()) { len = matcher.end(); if (buffer.start + len == buffer.end) { // make sure we match the longest separator possible if (buffer.isFull()) { buffer.grow(); } buffer.fill(reader); matcher = format.separator.matcher(buffer); if (!matcher.find()) { throw new IllegalStateException(); } len = matcher.end(); } result = new String(buffer.chars, buffer.start, format.trim == LineFormat.Trim.NOTHING ? len : matcher.start()); buffer.start += len; } else { if (buffer.isFull()) { buffer.grow(); } if (buffer.fill(reader)) { continue; } else { if (buffer.isEmpty()) { // EOF return null; } else { result = buffer.eat(); } } } // always bump, even if we don't return the line line++; if (format.trim == LineFormat.Trim.ALL) { result = result.trim(); } if (!format.excludes.matcher(result).matches()) { return result; } } }
java
public String next() throws IOException { String result; int len; Matcher matcher; while (true) { matcher = format.separator.matcher(buffer); if (matcher.find()) { len = matcher.end(); if (buffer.start + len == buffer.end) { // make sure we match the longest separator possible if (buffer.isFull()) { buffer.grow(); } buffer.fill(reader); matcher = format.separator.matcher(buffer); if (!matcher.find()) { throw new IllegalStateException(); } len = matcher.end(); } result = new String(buffer.chars, buffer.start, format.trim == LineFormat.Trim.NOTHING ? len : matcher.start()); buffer.start += len; } else { if (buffer.isFull()) { buffer.grow(); } if (buffer.fill(reader)) { continue; } else { if (buffer.isEmpty()) { // EOF return null; } else { result = buffer.eat(); } } } // always bump, even if we don't return the line line++; if (format.trim == LineFormat.Trim.ALL) { result = result.trim(); } if (!format.excludes.matcher(result).matches()) { return result; } } }
[ "public", "String", "next", "(", ")", "throws", "IOException", "{", "String", "result", ";", "int", "len", ";", "Matcher", "matcher", ";", "while", "(", "true", ")", "{", "matcher", "=", "format", ".", "separator", ".", "matcher", "(", "buffer", ")", ";", "if", "(", "matcher", ".", "find", "(", ")", ")", "{", "len", "=", "matcher", ".", "end", "(", ")", ";", "if", "(", "buffer", ".", "start", "+", "len", "==", "buffer", ".", "end", ")", "{", "// make sure we match the longest separator possible", "if", "(", "buffer", ".", "isFull", "(", ")", ")", "{", "buffer", ".", "grow", "(", ")", ";", "}", "buffer", ".", "fill", "(", "reader", ")", ";", "matcher", "=", "format", ".", "separator", ".", "matcher", "(", "buffer", ")", ";", "if", "(", "!", "matcher", ".", "find", "(", ")", ")", "{", "throw", "new", "IllegalStateException", "(", ")", ";", "}", "len", "=", "matcher", ".", "end", "(", ")", ";", "}", "result", "=", "new", "String", "(", "buffer", ".", "chars", ",", "buffer", ".", "start", ",", "format", ".", "trim", "==", "LineFormat", ".", "Trim", ".", "NOTHING", "?", "len", ":", "matcher", ".", "start", "(", ")", ")", ";", "buffer", ".", "start", "+=", "len", ";", "}", "else", "{", "if", "(", "buffer", ".", "isFull", "(", ")", ")", "{", "buffer", ".", "grow", "(", ")", ";", "}", "if", "(", "buffer", ".", "fill", "(", "reader", ")", ")", "{", "continue", ";", "}", "else", "{", "if", "(", "buffer", ".", "isEmpty", "(", ")", ")", "{", "// EOF", "return", "null", ";", "}", "else", "{", "result", "=", "buffer", ".", "eat", "(", ")", ";", "}", "}", "}", "// always bump, even if we don't return the line ", "line", "++", ";", "if", "(", "format", ".", "trim", "==", "LineFormat", ".", "Trim", ".", "ALL", ")", "{", "result", "=", "result", ".", "trim", "(", ")", ";", "}", "if", "(", "!", "format", ".", "excludes", ".", "matcher", "(", "result", ")", ".", "matches", "(", ")", ")", "{", "return", "result", ";", "}", "}", "}" ]
Never closes the underlying reader. @return next line of null for end of file
[ "Never", "closes", "the", "underlying", "reader", "." ]
4af33414b04bd58584d4febe5cc63ef6c7346a75
https://github.com/mlhartme/sushi/blob/4af33414b04bd58584d4febe5cc63ef6c7346a75/src/main/java/net/oneandone/sushi/io/LineReader.java#L77-L125
148,003
udoprog/ffwd-client-java
src/main/java/com/google/protobuf250/UninitializedMessageException.java
UninitializedMessageException.buildDescription
private static String buildDescription(final List<String> missingFields) { final StringBuilder description = new StringBuilder("Message missing required fields: "); boolean first = true; for (final String field : missingFields) { if (first) { first = false; } else { description.append(", "); } description.append(field); } return description.toString(); }
java
private static String buildDescription(final List<String> missingFields) { final StringBuilder description = new StringBuilder("Message missing required fields: "); boolean first = true; for (final String field : missingFields) { if (first) { first = false; } else { description.append(", "); } description.append(field); } return description.toString(); }
[ "private", "static", "String", "buildDescription", "(", "final", "List", "<", "String", ">", "missingFields", ")", "{", "final", "StringBuilder", "description", "=", "new", "StringBuilder", "(", "\"Message missing required fields: \"", ")", ";", "boolean", "first", "=", "true", ";", "for", "(", "final", "String", "field", ":", "missingFields", ")", "{", "if", "(", "first", ")", "{", "first", "=", "false", ";", "}", "else", "{", "description", ".", "append", "(", "\", \"", ")", ";", "}", "description", ".", "append", "(", "field", ")", ";", "}", "return", "description", ".", "toString", "(", ")", ";", "}" ]
Construct the description string for this exception.
[ "Construct", "the", "description", "string", "for", "this", "exception", "." ]
b4161d2b138e3edb8fa9420cc3cc653d5764cf5b
https://github.com/udoprog/ffwd-client-java/blob/b4161d2b138e3edb8fa9420cc3cc653d5764cf5b/src/main/java/com/google/protobuf250/UninitializedMessageException.java#L85-L98
148,004
yfpeng/pengyifan-bioc
src/main/java/com/pengyifan/bioc/io/BioCCollectionReader.java
BioCCollectionReader.readCollection
public BioCCollection readCollection() throws XMLStreamException { if (collection != null) { BioCCollection thisCollection = collection; collection = null; return thisCollection; } return null; }
java
public BioCCollection readCollection() throws XMLStreamException { if (collection != null) { BioCCollection thisCollection = collection; collection = null; return thisCollection; } return null; }
[ "public", "BioCCollection", "readCollection", "(", ")", "throws", "XMLStreamException", "{", "if", "(", "collection", "!=", "null", ")", "{", "BioCCollection", "thisCollection", "=", "collection", ";", "collection", "=", "null", ";", "return", "thisCollection", ";", "}", "return", "null", ";", "}" ]
Reads the collection of documents. @return the BioC collection @throws XMLStreamException if an unexpected processing error occurs
[ "Reads", "the", "collection", "of", "documents", "." ]
e09cce1969aa598ff89e7957237375715d7a1a3a
https://github.com/yfpeng/pengyifan-bioc/blob/e09cce1969aa598ff89e7957237375715d7a1a3a/src/main/java/com/pengyifan/bioc/io/BioCCollectionReader.java#L127-L135
148,005
synchronoss/cpo-api
cpo-core/src/main/java/org/synchronoss/cpo/BindableWhereBuilder.java
BindableWhereBuilder.visitBegin
@Override public boolean visitBegin(Node node) throws Exception { BindableCpoWhere jcw = (BindableCpoWhere) node; whereClause.append(jcw.toString(cpoClass)); if (jcw.hasParent() || jcw.getLogical() != CpoWhere.LOGIC_NONE) { whereClause.append(" ("); } else { whereClause.append(" "); } return true; }
java
@Override public boolean visitBegin(Node node) throws Exception { BindableCpoWhere jcw = (BindableCpoWhere) node; whereClause.append(jcw.toString(cpoClass)); if (jcw.hasParent() || jcw.getLogical() != CpoWhere.LOGIC_NONE) { whereClause.append(" ("); } else { whereClause.append(" "); } return true; }
[ "@", "Override", "public", "boolean", "visitBegin", "(", "Node", "node", ")", "throws", "Exception", "{", "BindableCpoWhere", "jcw", "=", "(", "BindableCpoWhere", ")", "node", ";", "whereClause", ".", "append", "(", "jcw", ".", "toString", "(", "cpoClass", ")", ")", ";", "if", "(", "jcw", ".", "hasParent", "(", ")", "||", "jcw", ".", "getLogical", "(", ")", "!=", "CpoWhere", ".", "LOGIC_NONE", ")", "{", "whereClause", ".", "append", "(", "\" (\"", ")", ";", "}", "else", "{", "whereClause", ".", "append", "(", "\" \"", ")", ";", "}", "return", "true", ";", "}" ]
This is called by composite nodes prior to visiting children @param node The node to be visited @return a boolean (false) to end visit or (true) to continue visiting
[ "This", "is", "called", "by", "composite", "nodes", "prior", "to", "visiting", "children" ]
dc745aca3b3206abf80b85d9689b0132f5baa694
https://github.com/synchronoss/cpo-api/blob/dc745aca3b3206abf80b85d9689b0132f5baa694/cpo-core/src/main/java/org/synchronoss/cpo/BindableWhereBuilder.java#L61-L72
148,006
synchronoss/cpo-api
cpo-core/src/main/java/org/synchronoss/cpo/BindableWhereBuilder.java
BindableWhereBuilder.visitEnd
@Override public boolean visitEnd(Node node) throws Exception { BindableCpoWhere bcw = (BindableCpoWhere) node; if (bcw.hasParent() || bcw.getLogical() != CpoWhere.LOGIC_NONE) { whereClause.append(")"); } return true; }
java
@Override public boolean visitEnd(Node node) throws Exception { BindableCpoWhere bcw = (BindableCpoWhere) node; if (bcw.hasParent() || bcw.getLogical() != CpoWhere.LOGIC_NONE) { whereClause.append(")"); } return true; }
[ "@", "Override", "public", "boolean", "visitEnd", "(", "Node", "node", ")", "throws", "Exception", "{", "BindableCpoWhere", "bcw", "=", "(", "BindableCpoWhere", ")", "node", ";", "if", "(", "bcw", ".", "hasParent", "(", ")", "||", "bcw", ".", "getLogical", "(", ")", "!=", "CpoWhere", ".", "LOGIC_NONE", ")", "{", "whereClause", ".", "append", "(", "\")\"", ")", ";", "}", "return", "true", ";", "}" ]
This is called by composite nodes after visiting children @param node The node to be visited @return a boolean (false) to end visit or (true) to continue visiting
[ "This", "is", "called", "by", "composite", "nodes", "after", "visiting", "children" ]
dc745aca3b3206abf80b85d9689b0132f5baa694
https://github.com/synchronoss/cpo-api/blob/dc745aca3b3206abf80b85d9689b0132f5baa694/cpo-core/src/main/java/org/synchronoss/cpo/BindableWhereBuilder.java#L91-L98
148,007
synchronoss/cpo-api
cpo-core/src/main/java/org/synchronoss/cpo/BindableWhereBuilder.java
BindableWhereBuilder.visit
@Override public boolean visit(Node node) throws Exception { BindableCpoWhere bcw = (BindableCpoWhere) node; CpoAttribute attribute; whereClause.append(bcw.toString(cpoClass)); if (bcw.getValue() != null) { attribute = cpoClass.getAttributeJava(bcw.getAttribute()); if (attribute == null) { attribute = cpoClass.getAttributeJava(bcw.getRightAttribute()); } if (attribute == null) { if (bcw.getComparison() == CpoWhere.COMP_IN && bcw.getValue() instanceof Collection) { for (Object obj : (Collection) bcw.getValue()) { bindValues.add(new BindAttribute(bcw.getAttribute() == null ? bcw.getRightAttribute() : bcw.getAttribute(), obj)); } } else { bindValues.add(new BindAttribute(bcw.getAttribute() == null ? bcw.getRightAttribute() : bcw.getAttribute(), bcw.getValue())); } } else { if (bcw.getComparison() == CpoWhere.COMP_IN && bcw.getValue() instanceof Collection) { for (Object obj : (Collection) bcw.getValue()) { bindValues.add(new BindAttribute(attribute, obj)); } } else { bindValues.add(new BindAttribute(attribute, bcw.getValue())); } } } return true; }
java
@Override public boolean visit(Node node) throws Exception { BindableCpoWhere bcw = (BindableCpoWhere) node; CpoAttribute attribute; whereClause.append(bcw.toString(cpoClass)); if (bcw.getValue() != null) { attribute = cpoClass.getAttributeJava(bcw.getAttribute()); if (attribute == null) { attribute = cpoClass.getAttributeJava(bcw.getRightAttribute()); } if (attribute == null) { if (bcw.getComparison() == CpoWhere.COMP_IN && bcw.getValue() instanceof Collection) { for (Object obj : (Collection) bcw.getValue()) { bindValues.add(new BindAttribute(bcw.getAttribute() == null ? bcw.getRightAttribute() : bcw.getAttribute(), obj)); } } else { bindValues.add(new BindAttribute(bcw.getAttribute() == null ? bcw.getRightAttribute() : bcw.getAttribute(), bcw.getValue())); } } else { if (bcw.getComparison() == CpoWhere.COMP_IN && bcw.getValue() instanceof Collection) { for (Object obj : (Collection) bcw.getValue()) { bindValues.add(new BindAttribute(attribute, obj)); } } else { bindValues.add(new BindAttribute(attribute, bcw.getValue())); } } } return true; }
[ "@", "Override", "public", "boolean", "visit", "(", "Node", "node", ")", "throws", "Exception", "{", "BindableCpoWhere", "bcw", "=", "(", "BindableCpoWhere", ")", "node", ";", "CpoAttribute", "attribute", ";", "whereClause", ".", "append", "(", "bcw", ".", "toString", "(", "cpoClass", ")", ")", ";", "if", "(", "bcw", ".", "getValue", "(", ")", "!=", "null", ")", "{", "attribute", "=", "cpoClass", ".", "getAttributeJava", "(", "bcw", ".", "getAttribute", "(", ")", ")", ";", "if", "(", "attribute", "==", "null", ")", "{", "attribute", "=", "cpoClass", ".", "getAttributeJava", "(", "bcw", ".", "getRightAttribute", "(", ")", ")", ";", "}", "if", "(", "attribute", "==", "null", ")", "{", "if", "(", "bcw", ".", "getComparison", "(", ")", "==", "CpoWhere", ".", "COMP_IN", "&&", "bcw", ".", "getValue", "(", ")", "instanceof", "Collection", ")", "{", "for", "(", "Object", "obj", ":", "(", "Collection", ")", "bcw", ".", "getValue", "(", ")", ")", "{", "bindValues", ".", "add", "(", "new", "BindAttribute", "(", "bcw", ".", "getAttribute", "(", ")", "==", "null", "?", "bcw", ".", "getRightAttribute", "(", ")", ":", "bcw", ".", "getAttribute", "(", ")", ",", "obj", ")", ")", ";", "}", "}", "else", "{", "bindValues", ".", "add", "(", "new", "BindAttribute", "(", "bcw", ".", "getAttribute", "(", ")", "==", "null", "?", "bcw", ".", "getRightAttribute", "(", ")", ":", "bcw", ".", "getAttribute", "(", ")", ",", "bcw", ".", "getValue", "(", ")", ")", ")", ";", "}", "}", "else", "{", "if", "(", "bcw", ".", "getComparison", "(", ")", "==", "CpoWhere", ".", "COMP_IN", "&&", "bcw", ".", "getValue", "(", ")", "instanceof", "Collection", ")", "{", "for", "(", "Object", "obj", ":", "(", "Collection", ")", "bcw", ".", "getValue", "(", ")", ")", "{", "bindValues", ".", "add", "(", "new", "BindAttribute", "(", "attribute", ",", "obj", ")", ")", ";", "}", "}", "else", "{", "bindValues", ".", "add", "(", "new", "BindAttribute", "(", "attribute", ",", "bcw", ".", "getValue", "(", ")", ")", ")", ";", "}", "}", "}", "return", "true", ";", "}" ]
This is called for component elements which have no children @param node The element to be visited @return a boolean (false) to end visit or (true) to continue visiting
[ "This", "is", "called", "for", "component", "elements", "which", "have", "no", "children" ]
dc745aca3b3206abf80b85d9689b0132f5baa694
https://github.com/synchronoss/cpo-api/blob/dc745aca3b3206abf80b85d9689b0132f5baa694/cpo-core/src/main/java/org/synchronoss/cpo/BindableWhereBuilder.java#L106-L135
148,008
gilberto-torrezan/gwt-views
src/main/java/com/github/gilbertotorrezan/gwtviews/client/analytics/UniversalAnalyticsTracker.java
UniversalAnalyticsTracker.sendPageView
public static void sendPageView(String pageWithParameters){ if (analytics == null){ return; } analytics.sendPageView().documentPath(pageWithParameters).go(); }
java
public static void sendPageView(String pageWithParameters){ if (analytics == null){ return; } analytics.sendPageView().documentPath(pageWithParameters).go(); }
[ "public", "static", "void", "sendPageView", "(", "String", "pageWithParameters", ")", "{", "if", "(", "analytics", "==", "null", ")", "{", "return", ";", "}", "analytics", ".", "sendPageView", "(", ")", ".", "documentPath", "(", "pageWithParameters", ")", ".", "go", "(", ")", ";", "}" ]
Tracks a page view. Do nothing if the UniversalAnalyticsTracker is not configured. @param pageWithParameters The current page for tracking, including query parameters. Can be obtained by calling {@link URLToken#toString()}. @see Analytics#sendPageView()
[ "Tracks", "a", "page", "view", ".", "Do", "nothing", "if", "the", "UniversalAnalyticsTracker", "is", "not", "configured", "." ]
c6511435d14b5aa93a722b0e861230d0ae2159e5
https://github.com/gilberto-torrezan/gwt-views/blob/c6511435d14b5aa93a722b0e861230d0ae2159e5/src/main/java/com/github/gilbertotorrezan/gwtviews/client/analytics/UniversalAnalyticsTracker.java#L106-L111
148,009
ZenHarbinger/l2fprod-properties-editor
src/main/java/com/l2fprod/common/propertysheet/PropertySheetTableModel.java
PropertySheetTableModel.setCategorySortingComparator
public void setCategorySortingComparator(Comparator comp) { Comparator old = categorySortingComparator; categorySortingComparator = comp; if (categorySortingComparator != old) { buildModel(); } }
java
public void setCategorySortingComparator(Comparator comp) { Comparator old = categorySortingComparator; categorySortingComparator = comp; if (categorySortingComparator != old) { buildModel(); } }
[ "public", "void", "setCategorySortingComparator", "(", "Comparator", "comp", ")", "{", "Comparator", "old", "=", "categorySortingComparator", ";", "categorySortingComparator", "=", "comp", ";", "if", "(", "categorySortingComparator", "!=", "old", ")", "{", "buildModel", "(", ")", ";", "}", "}" ]
Set the comparator used for sorting categories. If this changes the comparator, the model will be rebuilt. @param comp
[ "Set", "the", "comparator", "used", "for", "sorting", "categories", ".", "If", "this", "changes", "the", "comparator", "the", "model", "will", "be", "rebuilt", "." ]
d9b15c3f0b6ac1d9a2a9d315be073d2a4a419c32
https://github.com/ZenHarbinger/l2fprod-properties-editor/blob/d9b15c3f0b6ac1d9a2a9d315be073d2a4a419c32/src/main/java/com/l2fprod/common/propertysheet/PropertySheetTableModel.java#L266-L272
148,010
ZenHarbinger/l2fprod-properties-editor
src/main/java/com/l2fprod/common/propertysheet/PropertySheetTableModel.java
PropertySheetTableModel.setPropertySortingComparator
public void setPropertySortingComparator(Comparator comp) { Comparator old = propertySortingComparator; propertySortingComparator = comp; if (propertySortingComparator != old) { buildModel(); } }
java
public void setPropertySortingComparator(Comparator comp) { Comparator old = propertySortingComparator; propertySortingComparator = comp; if (propertySortingComparator != old) { buildModel(); } }
[ "public", "void", "setPropertySortingComparator", "(", "Comparator", "comp", ")", "{", "Comparator", "old", "=", "propertySortingComparator", ";", "propertySortingComparator", "=", "comp", ";", "if", "(", "propertySortingComparator", "!=", "old", ")", "{", "buildModel", "(", ")", ";", "}", "}" ]
Set the comparator used for sorting properties. If this changes the comparator, the model will be rebuilt. @param comp
[ "Set", "the", "comparator", "used", "for", "sorting", "properties", ".", "If", "this", "changes", "the", "comparator", "the", "model", "will", "be", "rebuilt", "." ]
d9b15c3f0b6ac1d9a2a9d315be073d2a4a419c32
https://github.com/ZenHarbinger/l2fprod-properties-editor/blob/d9b15c3f0b6ac1d9a2a9d315be073d2a4a419c32/src/main/java/com/l2fprod/common/propertysheet/PropertySheetTableModel.java#L280-L286
148,011
ZenHarbinger/l2fprod-properties-editor
src/main/java/com/l2fprod/common/propertysheet/PropertySheetTableModel.java
PropertySheetTableModel.addPropertiesToModel
private void addPropertiesToModel(List<Property> localProperties, Item parent) { for (Property property : localProperties) { Item propertyItem = new Item(property, parent); model.add(propertyItem); // add any sub-properties Property[] subProperties = property.getSubProperties(); if (subProperties != null && subProperties.length > 0) { addPropertiesToModel(Arrays.asList(subProperties), propertyItem); } } }
java
private void addPropertiesToModel(List<Property> localProperties, Item parent) { for (Property property : localProperties) { Item propertyItem = new Item(property, parent); model.add(propertyItem); // add any sub-properties Property[] subProperties = property.getSubProperties(); if (subProperties != null && subProperties.length > 0) { addPropertiesToModel(Arrays.asList(subProperties), propertyItem); } } }
[ "private", "void", "addPropertiesToModel", "(", "List", "<", "Property", ">", "localProperties", ",", "Item", "parent", ")", "{", "for", "(", "Property", "property", ":", "localProperties", ")", "{", "Item", "propertyItem", "=", "new", "Item", "(", "property", ",", "parent", ")", ";", "model", ".", "add", "(", "propertyItem", ")", ";", "// add any sub-properties", "Property", "[", "]", "subProperties", "=", "property", ".", "getSubProperties", "(", ")", ";", "if", "(", "subProperties", "!=", "null", "&&", "subProperties", ".", "length", ">", "0", ")", "{", "addPropertiesToModel", "(", "Arrays", ".", "asList", "(", "subProperties", ")", ",", "propertyItem", ")", ";", "}", "}", "}" ]
Add the specified properties to the model using the specified parent. @param localProperties the properties to add to the end of the model @param parent the {@link Item} parent of these properties, null if none
[ "Add", "the", "specified", "properties", "to", "the", "model", "using", "the", "specified", "parent", "." ]
d9b15c3f0b6ac1d9a2a9d315be073d2a4a419c32
https://github.com/ZenHarbinger/l2fprod-properties-editor/blob/d9b15c3f0b6ac1d9a2a9d315be073d2a4a419c32/src/main/java/com/l2fprod/common/propertysheet/PropertySheetTableModel.java#L516-L527
148,012
ZenHarbinger/l2fprod-properties-editor
src/main/java/com/l2fprod/common/propertysheet/PropertySheetTableModel.java
PropertySheetTableModel.getPropertiesForCategory
private List<Property> getPropertiesForCategory(List<Property> localProperties, String category) { List<Property> categoryProperties = new ArrayList<Property>(); for (Property property : localProperties) { if (property.getCategory() != null && property.getCategory().equals(category)) { categoryProperties.add(property); } } return categoryProperties; }
java
private List<Property> getPropertiesForCategory(List<Property> localProperties, String category) { List<Property> categoryProperties = new ArrayList<Property>(); for (Property property : localProperties) { if (property.getCategory() != null && property.getCategory().equals(category)) { categoryProperties.add(property); } } return categoryProperties; }
[ "private", "List", "<", "Property", ">", "getPropertiesForCategory", "(", "List", "<", "Property", ">", "localProperties", ",", "String", "category", ")", "{", "List", "<", "Property", ">", "categoryProperties", "=", "new", "ArrayList", "<", "Property", ">", "(", ")", ";", "for", "(", "Property", "property", ":", "localProperties", ")", "{", "if", "(", "property", ".", "getCategory", "(", ")", "!=", "null", "&&", "property", ".", "getCategory", "(", ")", ".", "equals", "(", "category", ")", ")", "{", "categoryProperties", ".", "add", "(", "property", ")", ";", "}", "}", "return", "categoryProperties", ";", "}" ]
Convenience method to get all the properties of one category.
[ "Convenience", "method", "to", "get", "all", "the", "properties", "of", "one", "category", "." ]
d9b15c3f0b6ac1d9a2a9d315be073d2a4a419c32
https://github.com/ZenHarbinger/l2fprod-properties-editor/blob/d9b15c3f0b6ac1d9a2a9d315be073d2a4a419c32/src/main/java/com/l2fprod/common/propertysheet/PropertySheetTableModel.java#L532-L540
148,013
opendatatrentino/s-match
src/main/java/it/unitn/disi/smatch/matchers/element/gloss/BasicGlossMatcher.java
BasicGlossMatcher.isWordMoreGeneral
public boolean isWordMoreGeneral(String source, String target) throws MatcherLibraryException { try { List<ISense> sSenses = linguisticOracle.getSenses(source); List<ISense> tSenses = linguisticOracle.getSenses(target); for (ISense sSense : sSenses) { for (ISense tSense : tSenses) { if (senseMatcher.isSourceMoreGeneralThanTarget(sSense, tSense)) return true; } } return false; } catch (LinguisticOracleException e) { final String errMessage = e.getClass().getSimpleName() + ": " + e.getMessage(); log.error(errMessage, e); throw new MatcherLibraryException(errMessage, e); } catch (SenseMatcherException e) { final String errMessage = e.getClass().getSimpleName() + ": " + e.getMessage(); log.error(errMessage, e); throw new MatcherLibraryException(errMessage, e); } }
java
public boolean isWordMoreGeneral(String source, String target) throws MatcherLibraryException { try { List<ISense> sSenses = linguisticOracle.getSenses(source); List<ISense> tSenses = linguisticOracle.getSenses(target); for (ISense sSense : sSenses) { for (ISense tSense : tSenses) { if (senseMatcher.isSourceMoreGeneralThanTarget(sSense, tSense)) return true; } } return false; } catch (LinguisticOracleException e) { final String errMessage = e.getClass().getSimpleName() + ": " + e.getMessage(); log.error(errMessage, e); throw new MatcherLibraryException(errMessage, e); } catch (SenseMatcherException e) { final String errMessage = e.getClass().getSimpleName() + ": " + e.getMessage(); log.error(errMessage, e); throw new MatcherLibraryException(errMessage, e); } }
[ "public", "boolean", "isWordMoreGeneral", "(", "String", "source", ",", "String", "target", ")", "throws", "MatcherLibraryException", "{", "try", "{", "List", "<", "ISense", ">", "sSenses", "=", "linguisticOracle", ".", "getSenses", "(", "source", ")", ";", "List", "<", "ISense", ">", "tSenses", "=", "linguisticOracle", ".", "getSenses", "(", "target", ")", ";", "for", "(", "ISense", "sSense", ":", "sSenses", ")", "{", "for", "(", "ISense", "tSense", ":", "tSenses", ")", "{", "if", "(", "senseMatcher", ".", "isSourceMoreGeneralThanTarget", "(", "sSense", ",", "tSense", ")", ")", "return", "true", ";", "}", "}", "return", "false", ";", "}", "catch", "(", "LinguisticOracleException", "e", ")", "{", "final", "String", "errMessage", "=", "e", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", "+", "\": \"", "+", "e", ".", "getMessage", "(", ")", ";", "log", ".", "error", "(", "errMessage", ",", "e", ")", ";", "throw", "new", "MatcherLibraryException", "(", "errMessage", ",", "e", ")", ";", "}", "catch", "(", "SenseMatcherException", "e", ")", "{", "final", "String", "errMessage", "=", "e", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", "+", "\": \"", "+", "e", ".", "getMessage", "(", ")", ";", "log", ".", "error", "(", "errMessage", ",", "e", ")", ";", "throw", "new", "MatcherLibraryException", "(", "errMessage", ",", "e", ")", ";", "}", "}" ]
Checks the source is more general than the target or not. @param source sense of source @param target sense of target @return true if the source is more general than target @throws MatcherLibraryException MatcherLibraryException
[ "Checks", "the", "source", "is", "more", "general", "than", "the", "target", "or", "not", "." ]
ba5982ef406b7010c2f92592e43887a485935aa1
https://github.com/opendatatrentino/s-match/blob/ba5982ef406b7010c2f92592e43887a485935aa1/src/main/java/it/unitn/disi/smatch/matchers/element/gloss/BasicGlossMatcher.java#L72-L92
148,014
yfpeng/pengyifan-bioc
src/main/java/com/pengyifan/bioc/io/BioCCollectionWriter.java
BioCCollectionWriter.writeCollection
public void writeCollection(BioCCollection collection) throws XMLStreamException { if (hasWritten) { throw new IllegalStateException( "writeCollection can only be invoked once."); } hasWritten = true; writer.writeStartDocument( collection.getEncoding(), collection.getVersion(), collection.isStandalone()) .writeBeginCollectionInfo(collection); for (BioCDocument doc : collection.getDocuments()) { writer.write(doc); } // end collection writer.writeEndCollection() .writeEndDocument(); }
java
public void writeCollection(BioCCollection collection) throws XMLStreamException { if (hasWritten) { throw new IllegalStateException( "writeCollection can only be invoked once."); } hasWritten = true; writer.writeStartDocument( collection.getEncoding(), collection.getVersion(), collection.isStandalone()) .writeBeginCollectionInfo(collection); for (BioCDocument doc : collection.getDocuments()) { writer.write(doc); } // end collection writer.writeEndCollection() .writeEndDocument(); }
[ "public", "void", "writeCollection", "(", "BioCCollection", "collection", ")", "throws", "XMLStreamException", "{", "if", "(", "hasWritten", ")", "{", "throw", "new", "IllegalStateException", "(", "\"writeCollection can only be invoked once.\"", ")", ";", "}", "hasWritten", "=", "true", ";", "writer", ".", "writeStartDocument", "(", "collection", ".", "getEncoding", "(", ")", ",", "collection", ".", "getVersion", "(", ")", ",", "collection", ".", "isStandalone", "(", ")", ")", ".", "writeBeginCollectionInfo", "(", "collection", ")", ";", "for", "(", "BioCDocument", "doc", ":", "collection", ".", "getDocuments", "(", ")", ")", "{", "writer", ".", "write", "(", "doc", ")", ";", "}", "// end collection", "writer", ".", "writeEndCollection", "(", ")", ".", "writeEndDocument", "(", ")", ";", "}" ]
Writes the whole BioC collection into the BioC file. This method can only be called once. @param collection the BioC collection @throws XMLStreamException if an unexpected processing error occurs
[ "Writes", "the", "whole", "BioC", "collection", "into", "the", "BioC", "file", ".", "This", "method", "can", "only", "be", "called", "once", "." ]
e09cce1969aa598ff89e7957237375715d7a1a3a
https://github.com/yfpeng/pengyifan-bioc/blob/e09cce1969aa598ff89e7957237375715d7a1a3a/src/main/java/com/pengyifan/bioc/io/BioCCollectionWriter.java#L135-L156
148,015
synchronoss/cpo-api
cpo-core/src/main/java/org/synchronoss/cpo/GUID.java
GUID.hexFormat
private static String hexFormat(int trgt) { String s = Integer.toHexString(trgt); int sz = s.length(); if (sz == 8) { return s; } int fill = 8 - sz; StringBuilder buf = new StringBuilder(); for (int i = 0; i < fill; ++i) { // add leading zeros buf.append('0'); } buf.append(s); return buf.toString(); }
java
private static String hexFormat(int trgt) { String s = Integer.toHexString(trgt); int sz = s.length(); if (sz == 8) { return s; } int fill = 8 - sz; StringBuilder buf = new StringBuilder(); for (int i = 0; i < fill; ++i) { // add leading zeros buf.append('0'); } buf.append(s); return buf.toString(); }
[ "private", "static", "String", "hexFormat", "(", "int", "trgt", ")", "{", "String", "s", "=", "Integer", ".", "toHexString", "(", "trgt", ")", ";", "int", "sz", "=", "s", ".", "length", "(", ")", ";", "if", "(", "sz", "==", "8", ")", "{", "return", "s", ";", "}", "int", "fill", "=", "8", "-", "sz", ";", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "fill", ";", "++", "i", ")", "{", "// add leading zeros", "buf", ".", "append", "(", "'", "'", ")", ";", "}", "buf", ".", "append", "(", "s", ")", ";", "return", "buf", ".", "toString", "(", ")", ";", "}" ]
Returns an 8 character hexidecimal representation of trgt. If the result is not equal to eight characters leading zeros are prefixed. @return 8 character hex representation of trgt
[ "Returns", "an", "8", "character", "hexidecimal", "representation", "of", "trgt", ".", "If", "the", "result", "is", "not", "equal", "to", "eight", "characters", "leading", "zeros", "are", "prefixed", "." ]
dc745aca3b3206abf80b85d9689b0132f5baa694
https://github.com/synchronoss/cpo-api/blob/dc745aca3b3206abf80b85d9689b0132f5baa694/cpo-core/src/main/java/org/synchronoss/cpo/GUID.java#L97-L113
148,016
mlhartme/sushi
src/main/java/net/oneandone/sushi/xml/Selector.java
Selector.longer
public long longer(Node element, String path) throws XmlException { String str; str = string(element, path); try { return Long.parseLong(str); } catch (NumberFormatException e) { throw new XmlException("number expected node " + path + ": " + str); } }
java
public long longer(Node element, String path) throws XmlException { String str; str = string(element, path); try { return Long.parseLong(str); } catch (NumberFormatException e) { throw new XmlException("number expected node " + path + ": " + str); } }
[ "public", "long", "longer", "(", "Node", "element", ",", "String", "path", ")", "throws", "XmlException", "{", "String", "str", ";", "str", "=", "string", "(", "element", ",", "path", ")", ";", "try", "{", "return", "Long", ".", "parseLong", "(", "str", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "throw", "new", "XmlException", "(", "\"number expected node \"", "+", "path", "+", "\": \"", "+", "str", ")", ";", "}", "}" ]
Checkstyle rejects method name long_
[ "Checkstyle", "rejects", "method", "name", "long_" ]
4af33414b04bd58584d4febe5cc63ef6c7346a75
https://github.com/mlhartme/sushi/blob/4af33414b04bd58584d4febe5cc63ef6c7346a75/src/main/java/net/oneandone/sushi/xml/Selector.java#L112-L121
148,017
wkgcass/Style
src/main/java/net/cassite/style/IfBlock.java
IfBlock.End
public T End() { if (procceed) if (initVal != null && !initVal.equals(false)) { return body.apply(initVal); } else { return null; } else return this.val; }
java
public T End() { if (procceed) if (initVal != null && !initVal.equals(false)) { return body.apply(initVal); } else { return null; } else return this.val; }
[ "public", "T", "End", "(", ")", "{", "if", "(", "procceed", ")", "if", "(", "initVal", "!=", "null", "&&", "!", "initVal", ".", "equals", "(", "false", ")", ")", "{", "return", "body", ".", "apply", "(", "initVal", ")", ";", "}", "else", "{", "return", "null", ";", "}", "else", "return", "this", ".", "val", ";", "}" ]
execute the if expression without an Else block @return if-expression result
[ "execute", "the", "if", "expression", "without", "an", "Else", "block" ]
db3ea64337251f46f734279480e365293bececbd
https://github.com/wkgcass/Style/blob/db3ea64337251f46f734279480e365293bececbd/src/main/java/net/cassite/style/IfBlock.java#L267-L276
148,018
DDTH/ddth-dao
ddth-dao-core/src/main/java/com/github/ddth/dao/utils/BoUtils.java
BoUtils.createObject
@SuppressWarnings("unchecked") public static <T> T createObject(String className, ClassLoader classLoader, Class<T> clazzToCast) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, ClassNotFoundException { Class<?> clazz = classLoader != null ? Class.forName(className, false, classLoader) : Class.forName(className); Constructor<?> constructor = clazz.getDeclaredConstructor(); constructor.setAccessible(true); Object result = constructor.newInstance(); return result != null && clazz.isAssignableFrom(result.getClass()) ? (T) result : null; }
java
@SuppressWarnings("unchecked") public static <T> T createObject(String className, ClassLoader classLoader, Class<T> clazzToCast) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, ClassNotFoundException { Class<?> clazz = classLoader != null ? Class.forName(className, false, classLoader) : Class.forName(className); Constructor<?> constructor = clazz.getDeclaredConstructor(); constructor.setAccessible(true); Object result = constructor.newInstance(); return result != null && clazz.isAssignableFrom(result.getClass()) ? (T) result : null; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "T", ">", "T", "createObject", "(", "String", "className", ",", "ClassLoader", "classLoader", ",", "Class", "<", "T", ">", "clazzToCast", ")", "throws", "InstantiationException", ",", "IllegalAccessException", ",", "IllegalArgumentException", ",", "InvocationTargetException", ",", "NoSuchMethodException", ",", "SecurityException", ",", "ClassNotFoundException", "{", "Class", "<", "?", ">", "clazz", "=", "classLoader", "!=", "null", "?", "Class", ".", "forName", "(", "className", ",", "false", ",", "classLoader", ")", ":", "Class", ".", "forName", "(", "className", ")", ";", "Constructor", "<", "?", ">", "constructor", "=", "clazz", ".", "getDeclaredConstructor", "(", ")", ";", "constructor", ".", "setAccessible", "(", "true", ")", ";", "Object", "result", "=", "constructor", ".", "newInstance", "(", ")", ";", "return", "result", "!=", "null", "&&", "clazz", ".", "isAssignableFrom", "(", "result", ".", "getClass", "(", ")", ")", "?", "(", "T", ")", "result", ":", "null", ";", "}" ]
Create a new object. @param className @param classLoader @param clazzToCast @return @throws InstantiationException @throws IllegalAccessException @throws IllegalArgumentException @throws InvocationTargetException @throws NoSuchMethodException @throws SecurityException @throws ClassNotFoundException
[ "Create", "a", "new", "object", "." ]
8d059ddf641a1629aa53851f9d1b41abf175a180
https://github.com/DDTH/ddth-dao/blob/8d059ddf641a1629aa53851f9d1b41abf175a180/ddth-dao-core/src/main/java/com/github/ddth/dao/utils/BoUtils.java#L42-L53
148,019
DDTH/ddth-dao
ddth-dao-core/src/main/java/com/github/ddth/dao/utils/BoUtils.java
BoUtils.toJson
public static String toJson(BaseBo bo) { if (bo == null) { return null; } String clazz = bo.getClass().getName(); Map<String, Object> data = new HashMap<>(); data.put(FIELD_CLASSNAME, clazz); data.put(FIELD_BODATA, bo.toJson()); return SerializationUtils.toJsonString(data); }
java
public static String toJson(BaseBo bo) { if (bo == null) { return null; } String clazz = bo.getClass().getName(); Map<String, Object> data = new HashMap<>(); data.put(FIELD_CLASSNAME, clazz); data.put(FIELD_BODATA, bo.toJson()); return SerializationUtils.toJsonString(data); }
[ "public", "static", "String", "toJson", "(", "BaseBo", "bo", ")", "{", "if", "(", "bo", "==", "null", ")", "{", "return", "null", ";", "}", "String", "clazz", "=", "bo", ".", "getClass", "(", ")", ".", "getName", "(", ")", ";", "Map", "<", "String", ",", "Object", ">", "data", "=", "new", "HashMap", "<>", "(", ")", ";", "data", ".", "put", "(", "FIELD_CLASSNAME", ",", "clazz", ")", ";", "data", ".", "put", "(", "FIELD_BODATA", ",", "bo", ".", "toJson", "(", ")", ")", ";", "return", "SerializationUtils", ".", "toJsonString", "(", "data", ")", ";", "}" ]
Serialize a BO to JSON string. @param bo @return
[ "Serialize", "a", "BO", "to", "JSON", "string", "." ]
8d059ddf641a1629aa53851f9d1b41abf175a180
https://github.com/DDTH/ddth-dao/blob/8d059ddf641a1629aa53851f9d1b41abf175a180/ddth-dao-core/src/main/java/com/github/ddth/dao/utils/BoUtils.java#L63-L72
148,020
DDTH/ddth-dao
ddth-dao-core/src/main/java/com/github/ddth/dao/utils/BoUtils.java
BoUtils.toBytes
public static byte[] toBytes(BaseBo bo) { if (bo == null) { return null; } String clazz = bo.getClass().getName(); Map<String, Object> data = new HashMap<>(); data.put(FIELD_CLASSNAME, clazz); data.put(FIELD_BODATA, bo.toBytes()); return SerializationUtils.toByteArray(data); }
java
public static byte[] toBytes(BaseBo bo) { if (bo == null) { return null; } String clazz = bo.getClass().getName(); Map<String, Object> data = new HashMap<>(); data.put(FIELD_CLASSNAME, clazz); data.put(FIELD_BODATA, bo.toBytes()); return SerializationUtils.toByteArray(data); }
[ "public", "static", "byte", "[", "]", "toBytes", "(", "BaseBo", "bo", ")", "{", "if", "(", "bo", "==", "null", ")", "{", "return", "null", ";", "}", "String", "clazz", "=", "bo", ".", "getClass", "(", ")", ".", "getName", "(", ")", ";", "Map", "<", "String", ",", "Object", ">", "data", "=", "new", "HashMap", "<>", "(", ")", ";", "data", ".", "put", "(", "FIELD_CLASSNAME", ",", "clazz", ")", ";", "data", ".", "put", "(", "FIELD_BODATA", ",", "bo", ".", "toBytes", "(", ")", ")", ";", "return", "SerializationUtils", ".", "toByteArray", "(", "data", ")", ";", "}" ]
Serialize a BO to a byte array. @param bo @return
[ "Serialize", "a", "BO", "to", "a", "byte", "array", "." ]
8d059ddf641a1629aa53851f9d1b41abf175a180
https://github.com/DDTH/ddth-dao/blob/8d059ddf641a1629aa53851f9d1b41abf175a180/ddth-dao-core/src/main/java/com/github/ddth/dao/utils/BoUtils.java#L151-L160
148,021
DDTH/ddth-dao
ddth-dao-core/src/main/java/com/github/ddth/dao/utils/BoUtils.java
BoUtils.bytesToDocument
@SuppressWarnings("unchecked") public static Map<String, Object> bytesToDocument(byte[] data) { return data != null && data.length > 0 ? SerializationUtils.fromByteArrayFst(data, Map.class) : null; }
java
@SuppressWarnings("unchecked") public static Map<String, Object> bytesToDocument(byte[] data) { return data != null && data.length > 0 ? SerializationUtils.fromByteArrayFst(data, Map.class) : null; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "Map", "<", "String", ",", "Object", ">", "bytesToDocument", "(", "byte", "[", "]", "data", ")", "{", "return", "data", "!=", "null", "&&", "data", ".", "length", ">", "0", "?", "SerializationUtils", ".", "fromByteArrayFst", "(", "data", ",", "Map", ".", "class", ")", ":", "null", ";", "}" ]
De-serialize byte array to "document". @param data @return @since 0.10.0
[ "De", "-", "serialize", "byte", "array", "to", "document", "." ]
8d059ddf641a1629aa53851f9d1b41abf175a180
https://github.com/DDTH/ddth-dao/blob/8d059ddf641a1629aa53851f9d1b41abf175a180/ddth-dao-core/src/main/java/com/github/ddth/dao/utils/BoUtils.java#L238-L243
148,022
DDTH/ddth-dao
ddth-dao-core/src/main/java/com/github/ddth/dao/utils/BoUtils.java
BoUtils.documentToBytes
public static byte[] documentToBytes(Map<String, Object> doc) { return doc != null ? SerializationUtils.toByteArrayFst(doc) : ArrayUtils.EMPTY_BYTE_ARRAY; }
java
public static byte[] documentToBytes(Map<String, Object> doc) { return doc != null ? SerializationUtils.toByteArrayFst(doc) : ArrayUtils.EMPTY_BYTE_ARRAY; }
[ "public", "static", "byte", "[", "]", "documentToBytes", "(", "Map", "<", "String", ",", "Object", ">", "doc", ")", "{", "return", "doc", "!=", "null", "?", "SerializationUtils", ".", "toByteArrayFst", "(", "doc", ")", ":", "ArrayUtils", ".", "EMPTY_BYTE_ARRAY", ";", "}" ]
Serialize "document" to byte array. @param doc @return @since 0.10.0
[ "Serialize", "document", "to", "byte", "array", "." ]
8d059ddf641a1629aa53851f9d1b41abf175a180
https://github.com/DDTH/ddth-dao/blob/8d059ddf641a1629aa53851f9d1b41abf175a180/ddth-dao-core/src/main/java/com/github/ddth/dao/utils/BoUtils.java#L252-L254
148,023
lisicnu/droidUtil
src/main/java/com/github/lisicnu/libDroid/helper/INIHelper.java
INIHelper.save
public void save() { FileWriter fw = null; BufferedWriter bw = null; try { fw = new FileWriter(file); bw = new BufferedWriter(fw); for (Iterator<Object> iterator = ini.keySet().iterator(); iterator.hasNext(); ) { String key = iterator.next().toString(); bw.write(key + "=" + getKey(key)); bw.newLine(); } bw.close(); bw = null; fw.close(); fw = null; } catch (Exception ex) { Log.e(TAG, "", ex); } finally { if (bw != null) { try { bw.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } bw = null; } if (fw != null) { try { fw.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } fw = null; } } }
java
public void save() { FileWriter fw = null; BufferedWriter bw = null; try { fw = new FileWriter(file); bw = new BufferedWriter(fw); for (Iterator<Object> iterator = ini.keySet().iterator(); iterator.hasNext(); ) { String key = iterator.next().toString(); bw.write(key + "=" + getKey(key)); bw.newLine(); } bw.close(); bw = null; fw.close(); fw = null; } catch (Exception ex) { Log.e(TAG, "", ex); } finally { if (bw != null) { try { bw.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } bw = null; } if (fw != null) { try { fw.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } fw = null; } } }
[ "public", "void", "save", "(", ")", "{", "FileWriter", "fw", "=", "null", ";", "BufferedWriter", "bw", "=", "null", ";", "try", "{", "fw", "=", "new", "FileWriter", "(", "file", ")", ";", "bw", "=", "new", "BufferedWriter", "(", "fw", ")", ";", "for", "(", "Iterator", "<", "Object", ">", "iterator", "=", "ini", ".", "keySet", "(", ")", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "String", "key", "=", "iterator", ".", "next", "(", ")", ".", "toString", "(", ")", ";", "bw", ".", "write", "(", "key", "+", "\"=\"", "+", "getKey", "(", "key", ")", ")", ";", "bw", ".", "newLine", "(", ")", ";", "}", "bw", ".", "close", "(", ")", ";", "bw", "=", "null", ";", "fw", ".", "close", "(", ")", ";", "fw", "=", "null", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "Log", ".", "e", "(", "TAG", ",", "\"\"", ",", "ex", ")", ";", "}", "finally", "{", "if", "(", "bw", "!=", "null", ")", "{", "try", "{", "bw", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "// TODO Auto-generated catch block", "e", ".", "printStackTrace", "(", ")", ";", "}", "bw", "=", "null", ";", "}", "if", "(", "fw", "!=", "null", ")", "{", "try", "{", "fw", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "// TODO Auto-generated catch block", "e", ".", "printStackTrace", "(", ")", ";", "}", "fw", "=", "null", ";", "}", "}", "}" ]
save the file.
[ "save", "the", "file", "." ]
e4d6cf3e3f60e5efb5a75672607ded94d1725519
https://github.com/lisicnu/droidUtil/blob/e4d6cf3e3f60e5efb5a75672607ded94d1725519/src/main/java/com/github/lisicnu/libDroid/helper/INIHelper.java#L65-L103
148,024
sematext/ActionGenerator
ag-player-es/src/main/java/com/sematext/ag/es/util/JSONUtils.java
JSONUtils.getElasticSearchAddDocument
public static String getElasticSearchAddDocument(Map<String, String> values) { StringBuilder builder = new StringBuilder(); builder.append("{"); boolean first = true; for (Map.Entry<String, String> pair : values.entrySet()) { if (!first) { builder.append(","); } JSONUtils.addElasticSearchField(builder, pair); first = false; } builder.append("}"); return builder.toString(); }
java
public static String getElasticSearchAddDocument(Map<String, String> values) { StringBuilder builder = new StringBuilder(); builder.append("{"); boolean first = true; for (Map.Entry<String, String> pair : values.entrySet()) { if (!first) { builder.append(","); } JSONUtils.addElasticSearchField(builder, pair); first = false; } builder.append("}"); return builder.toString(); }
[ "public", "static", "String", "getElasticSearchAddDocument", "(", "Map", "<", "String", ",", "String", ">", "values", ")", "{", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "builder", ".", "append", "(", "\"{\"", ")", ";", "boolean", "first", "=", "true", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "String", ">", "pair", ":", "values", ".", "entrySet", "(", ")", ")", "{", "if", "(", "!", "first", ")", "{", "builder", ".", "append", "(", "\",\"", ")", ";", "}", "JSONUtils", ".", "addElasticSearchField", "(", "builder", ",", "pair", ")", ";", "first", "=", "false", ";", "}", "builder", ".", "append", "(", "\"}\"", ")", ";", "return", "builder", ".", "toString", "(", ")", ";", "}" ]
Returns ElasticSearch add command. @param values values to include @return XML as String
[ "Returns", "ElasticSearch", "add", "command", "." ]
10f4a3e680f20d7d151f5d40e6758aeb072d474f
https://github.com/sematext/ActionGenerator/blob/10f4a3e680f20d7d151f5d40e6758aeb072d474f/ag-player-es/src/main/java/com/sematext/ag/es/util/JSONUtils.java#L39-L52
148,025
sematext/ActionGenerator
ag-player-es/src/main/java/com/sematext/ag/es/util/JSONUtils.java
JSONUtils.getElasticSearchBulkHeader
public static String getElasticSearchBulkHeader(SimpleDataEvent event, String index, String type) { StringBuilder builder = new StringBuilder(); builder.append("{\"index\":{\"_index\":\""); builder.append(index); builder.append("\",\"_type\":\""); builder.append(type); builder.append("\",\"_id\":\""); builder.append(event.getId()); builder.append("\"}}"); return builder.toString(); }
java
public static String getElasticSearchBulkHeader(SimpleDataEvent event, String index, String type) { StringBuilder builder = new StringBuilder(); builder.append("{\"index\":{\"_index\":\""); builder.append(index); builder.append("\",\"_type\":\""); builder.append(type); builder.append("\",\"_id\":\""); builder.append(event.getId()); builder.append("\"}}"); return builder.toString(); }
[ "public", "static", "String", "getElasticSearchBulkHeader", "(", "SimpleDataEvent", "event", ",", "String", "index", ",", "String", "type", ")", "{", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "builder", ".", "append", "(", "\"{\\\"index\\\":{\\\"_index\\\":\\\"\"", ")", ";", "builder", ".", "append", "(", "index", ")", ";", "builder", ".", "append", "(", "\"\\\",\\\"_type\\\":\\\"\"", ")", ";", "builder", ".", "append", "(", "type", ")", ";", "builder", ".", "append", "(", "\"\\\",\\\"_id\\\":\\\"\"", ")", ";", "builder", ".", "append", "(", "event", ".", "getId", "(", ")", ")", ";", "builder", ".", "append", "(", "\"\\\"}}\"", ")", ";", "return", "builder", ".", "toString", "(", ")", ";", "}" ]
Constructs ES bulk header for the document. @param event data event @param index index name @param type document type @return ES bulk header
[ "Constructs", "ES", "bulk", "header", "for", "the", "document", "." ]
10f4a3e680f20d7d151f5d40e6758aeb072d474f
https://github.com/sematext/ActionGenerator/blob/10f4a3e680f20d7d151f5d40e6758aeb072d474f/ag-player-es/src/main/java/com/sematext/ag/es/util/JSONUtils.java#L65-L75
148,026
globocom/GloboDNS-Client
src/main/java/com/globo/globodns/client/model/Record.java
Record.getId
public Long getId() { if (this.genericRecordAttributes.getId() != null) { return this.genericRecordAttributes.getId(); } else if (this.typeARecordAttributes.getId() != null) { return this.typeARecordAttributes.getId(); } else if (this.typeAAAARecordAttributes.getId() != null) { return this.typeAAAARecordAttributes.getId(); } else if (this.typeNSRecordAttributes.getId() != null) { return this.typeNSRecordAttributes.getId(); } else if (this.typeSOARecordAttributes.getId() != null) { return this.typeSOARecordAttributes.getId(); } else if (this.typeMXRecordAttributes.getId() != null) { return this.typeMXRecordAttributes.getId(); } else if (this.typePTRRecordAttributes.getId() != null) { return this.typePTRRecordAttributes.getId(); } else if (this.typeTXTRecordAttributes.getId() != null) { return this.typeTXTRecordAttributes.getId(); } else { return null; } }
java
public Long getId() { if (this.genericRecordAttributes.getId() != null) { return this.genericRecordAttributes.getId(); } else if (this.typeARecordAttributes.getId() != null) { return this.typeARecordAttributes.getId(); } else if (this.typeAAAARecordAttributes.getId() != null) { return this.typeAAAARecordAttributes.getId(); } else if (this.typeNSRecordAttributes.getId() != null) { return this.typeNSRecordAttributes.getId(); } else if (this.typeSOARecordAttributes.getId() != null) { return this.typeSOARecordAttributes.getId(); } else if (this.typeMXRecordAttributes.getId() != null) { return this.typeMXRecordAttributes.getId(); } else if (this.typePTRRecordAttributes.getId() != null) { return this.typePTRRecordAttributes.getId(); } else if (this.typeTXTRecordAttributes.getId() != null) { return this.typeTXTRecordAttributes.getId(); } else { return null; } }
[ "public", "Long", "getId", "(", ")", "{", "if", "(", "this", ".", "genericRecordAttributes", ".", "getId", "(", ")", "!=", "null", ")", "{", "return", "this", ".", "genericRecordAttributes", ".", "getId", "(", ")", ";", "}", "else", "if", "(", "this", ".", "typeARecordAttributes", ".", "getId", "(", ")", "!=", "null", ")", "{", "return", "this", ".", "typeARecordAttributes", ".", "getId", "(", ")", ";", "}", "else", "if", "(", "this", ".", "typeAAAARecordAttributes", ".", "getId", "(", ")", "!=", "null", ")", "{", "return", "this", ".", "typeAAAARecordAttributes", ".", "getId", "(", ")", ";", "}", "else", "if", "(", "this", ".", "typeNSRecordAttributes", ".", "getId", "(", ")", "!=", "null", ")", "{", "return", "this", ".", "typeNSRecordAttributes", ".", "getId", "(", ")", ";", "}", "else", "if", "(", "this", ".", "typeSOARecordAttributes", ".", "getId", "(", ")", "!=", "null", ")", "{", "return", "this", ".", "typeSOARecordAttributes", ".", "getId", "(", ")", ";", "}", "else", "if", "(", "this", ".", "typeMXRecordAttributes", ".", "getId", "(", ")", "!=", "null", ")", "{", "return", "this", ".", "typeMXRecordAttributes", ".", "getId", "(", ")", ";", "}", "else", "if", "(", "this", ".", "typePTRRecordAttributes", ".", "getId", "(", ")", "!=", "null", ")", "{", "return", "this", ".", "typePTRRecordAttributes", ".", "getId", "(", ")", ";", "}", "else", "if", "(", "this", ".", "typeTXTRecordAttributes", ".", "getId", "(", ")", "!=", "null", ")", "{", "return", "this", ".", "typeTXTRecordAttributes", ".", "getId", "(", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
FIXME Better way of accessing the variables?
[ "FIXME", "Better", "way", "of", "accessing", "the", "variables?" ]
4f9b742bdc598c41299fcf92e8443ce419709618
https://github.com/globocom/GloboDNS-Client/blob/4f9b742bdc598c41299fcf92e8443ce419709618/src/main/java/com/globo/globodns/client/model/Record.java#L125-L145
148,027
DDTH/ddth-dao
ddth-dao-core/src/main/java/com/github/ddth/dao/BaseDao.java
BaseDao.addProfiling
public static ProfilingRecord addProfiling(long execTimeMs, String command, long durationMs) { ProfilingRecord record = new ProfilingRecord(execTimeMs, command, durationMs); List<ProfilingRecord> records = profilingRecords.get(); records.add(record); while (records.size() > 100) { records.remove(0); } return record; }
java
public static ProfilingRecord addProfiling(long execTimeMs, String command, long durationMs) { ProfilingRecord record = new ProfilingRecord(execTimeMs, command, durationMs); List<ProfilingRecord> records = profilingRecords.get(); records.add(record); while (records.size() > 100) { records.remove(0); } return record; }
[ "public", "static", "ProfilingRecord", "addProfiling", "(", "long", "execTimeMs", ",", "String", "command", ",", "long", "durationMs", ")", "{", "ProfilingRecord", "record", "=", "new", "ProfilingRecord", "(", "execTimeMs", ",", "command", ",", "durationMs", ")", ";", "List", "<", "ProfilingRecord", ">", "records", "=", "profilingRecords", ".", "get", "(", ")", ";", "records", ".", "add", "(", "record", ")", ";", "while", "(", "records", ".", "size", "(", ")", ">", "100", ")", "{", "records", ".", "remove", "(", "0", ")", ";", "}", "return", "record", ";", "}" ]
Adds a new profiling record. @param execTimeMs @param command @return
[ "Adds", "a", "new", "profiling", "record", "." ]
8d059ddf641a1629aa53851f9d1b41abf175a180
https://github.com/DDTH/ddth-dao/blob/8d059ddf641a1629aa53851f9d1b41abf175a180/ddth-dao-core/src/main/java/com/github/ddth/dao/BaseDao.java#L63-L71
148,028
DDTH/ddth-dao
ddth-dao-core/src/main/java/com/github/ddth/dao/BaseDao.java
BaseDao.removeFromCache
protected void removeFromCache(String cacheName, String key) { try { ICache cache = getCache(cacheName); if (cache != null) { cache.delete(key); } } catch (CacheException e) { LOGGER.warn(e.getMessage(), e); } }
java
protected void removeFromCache(String cacheName, String key) { try { ICache cache = getCache(cacheName); if (cache != null) { cache.delete(key); } } catch (CacheException e) { LOGGER.warn(e.getMessage(), e); } }
[ "protected", "void", "removeFromCache", "(", "String", "cacheName", ",", "String", "key", ")", "{", "try", "{", "ICache", "cache", "=", "getCache", "(", "cacheName", ")", ";", "if", "(", "cache", "!=", "null", ")", "{", "cache", ".", "delete", "(", "key", ")", ";", "}", "}", "catch", "(", "CacheException", "e", ")", "{", "LOGGER", ".", "warn", "(", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "}" ]
Removes an entry from cache. @param cacheName @param key
[ "Removes", "an", "entry", "from", "cache", "." ]
8d059ddf641a1629aa53851f9d1b41abf175a180
https://github.com/DDTH/ddth-dao/blob/8d059ddf641a1629aa53851f9d1b41abf175a180/ddth-dao-core/src/main/java/com/github/ddth/dao/BaseDao.java#L144-L153
148,029
DDTH/ddth-dao
ddth-dao-core/src/main/java/com/github/ddth/dao/BaseDao.java
BaseDao.putToCache
protected void putToCache(String cacheName, String key, Object value) { putToCache(cacheName, key, value, 0); }
java
protected void putToCache(String cacheName, String key, Object value) { putToCache(cacheName, key, value, 0); }
[ "protected", "void", "putToCache", "(", "String", "cacheName", ",", "String", "key", ",", "Object", "value", ")", "{", "putToCache", "(", "cacheName", ",", "key", ",", "value", ",", "0", ")", ";", "}" ]
Puts an entry to cache, with default TTL. @param cacheName @param key @param value
[ "Puts", "an", "entry", "to", "cache", "with", "default", "TTL", "." ]
8d059ddf641a1629aa53851f9d1b41abf175a180
https://github.com/DDTH/ddth-dao/blob/8d059ddf641a1629aa53851f9d1b41abf175a180/ddth-dao-core/src/main/java/com/github/ddth/dao/BaseDao.java#L162-L164
148,030
DDTH/ddth-dao
ddth-dao-core/src/main/java/com/github/ddth/dao/BaseDao.java
BaseDao.putToCache
protected void putToCache(String cacheName, String key, Object value, long ttlSeconds) { if (cacheItemsExpireAfterWrite) { putToCache(cacheName, key, value, ttlSeconds, 0); } else { putToCache(cacheName, key, value, 0, ttlSeconds); } }
java
protected void putToCache(String cacheName, String key, Object value, long ttlSeconds) { if (cacheItemsExpireAfterWrite) { putToCache(cacheName, key, value, ttlSeconds, 0); } else { putToCache(cacheName, key, value, 0, ttlSeconds); } }
[ "protected", "void", "putToCache", "(", "String", "cacheName", ",", "String", "key", ",", "Object", "value", ",", "long", "ttlSeconds", ")", "{", "if", "(", "cacheItemsExpireAfterWrite", ")", "{", "putToCache", "(", "cacheName", ",", "key", ",", "value", ",", "ttlSeconds", ",", "0", ")", ";", "}", "else", "{", "putToCache", "(", "cacheName", ",", "key", ",", "value", ",", "0", ",", "ttlSeconds", ")", ";", "}", "}" ]
Puts an entry to cache, with specific TTL. @param cacheName @param key @param value @param ttlSeconds
[ "Puts", "an", "entry", "to", "cache", "with", "specific", "TTL", "." ]
8d059ddf641a1629aa53851f9d1b41abf175a180
https://github.com/DDTH/ddth-dao/blob/8d059ddf641a1629aa53851f9d1b41abf175a180/ddth-dao-core/src/main/java/com/github/ddth/dao/BaseDao.java#L174-L180
148,031
acromusashi/acromusashi-stream
src/main/java/acromusashi/stream/component/rabbitmq/CachingConnectionFactory.java
CachingConnectionFactory.reset
protected void reset() { this.active = false; synchronized (this.cachedChannelsNonTransactional) { for (ChannelProxy channel : this.cachedChannelsNonTransactional) { try { channel.getTargetChannel().close(); } catch (Throwable ex) { this.logger.trace("Could not close cached Rabbit Channel", ex); } } this.cachedChannelsNonTransactional.clear(); } synchronized (this.cachedChannelsTransactional) { for (ChannelProxy channel : this.cachedChannelsTransactional) { try { channel.getTargetChannel().close(); } catch (Throwable ex) { this.logger.trace("Could not close cached Rabbit Channel", ex); } } this.cachedChannelsTransactional.clear(); } this.active = true; }
java
protected void reset() { this.active = false; synchronized (this.cachedChannelsNonTransactional) { for (ChannelProxy channel : this.cachedChannelsNonTransactional) { try { channel.getTargetChannel().close(); } catch (Throwable ex) { this.logger.trace("Could not close cached Rabbit Channel", ex); } } this.cachedChannelsNonTransactional.clear(); } synchronized (this.cachedChannelsTransactional) { for (ChannelProxy channel : this.cachedChannelsTransactional) { try { channel.getTargetChannel().close(); } catch (Throwable ex) { this.logger.trace("Could not close cached Rabbit Channel", ex); } } this.cachedChannelsTransactional.clear(); } this.active = true; }
[ "protected", "void", "reset", "(", ")", "{", "this", ".", "active", "=", "false", ";", "synchronized", "(", "this", ".", "cachedChannelsNonTransactional", ")", "{", "for", "(", "ChannelProxy", "channel", ":", "this", ".", "cachedChannelsNonTransactional", ")", "{", "try", "{", "channel", ".", "getTargetChannel", "(", ")", ".", "close", "(", ")", ";", "}", "catch", "(", "Throwable", "ex", ")", "{", "this", ".", "logger", ".", "trace", "(", "\"Could not close cached Rabbit Channel\"", ",", "ex", ")", ";", "}", "}", "this", ".", "cachedChannelsNonTransactional", ".", "clear", "(", ")", ";", "}", "synchronized", "(", "this", ".", "cachedChannelsTransactional", ")", "{", "for", "(", "ChannelProxy", "channel", ":", "this", ".", "cachedChannelsTransactional", ")", "{", "try", "{", "channel", ".", "getTargetChannel", "(", ")", ".", "close", "(", ")", ";", "}", "catch", "(", "Throwable", "ex", ")", "{", "this", ".", "logger", ".", "trace", "(", "\"Could not close cached Rabbit Channel\"", ",", "ex", ")", ";", "}", "}", "this", ".", "cachedChannelsTransactional", ".", "clear", "(", ")", ";", "}", "this", ".", "active", "=", "true", ";", "}" ]
Reset the Channel cache and underlying shared Connection, to be reinitialized on next access.
[ "Reset", "the", "Channel", "cache", "and", "underlying", "shared", "Connection", "to", "be", "reinitialized", "on", "next", "access", "." ]
65b1f335d771d657c5640a2056ab5c8546eddec9
https://github.com/acromusashi/acromusashi-stream/blob/65b1f335d771d657c5640a2056ab5c8546eddec9/src/main/java/acromusashi/stream/component/rabbitmq/CachingConnectionFactory.java#L344-L378
148,032
acromusashi/acromusashi-stream
src/main/java/acromusashi/stream/bean/FieldExtractor.java
FieldExtractor.extractKeyHead
public static String extractKeyHead(String key, String delimeter) { int index = key.indexOf(delimeter); if (index == -1) { return key; } String result = key.substring(0, index); return result; }
java
public static String extractKeyHead(String key, String delimeter) { int index = key.indexOf(delimeter); if (index == -1) { return key; } String result = key.substring(0, index); return result; }
[ "public", "static", "String", "extractKeyHead", "(", "String", "key", ",", "String", "delimeter", ")", "{", "int", "index", "=", "key", ".", "indexOf", "(", "delimeter", ")", ";", "if", "(", "index", "==", "-", "1", ")", "{", "return", "key", ";", "}", "String", "result", "=", "key", ".", "substring", "(", "0", ",", "index", ")", ";", "return", "result", ";", "}" ]
Extract the value of keyHead. @param key is used to get string. @param delimeter key delimeter @return the value of keyHead .
[ "Extract", "the", "value", "of", "keyHead", "." ]
65b1f335d771d657c5640a2056ab5c8546eddec9
https://github.com/acromusashi/acromusashi-stream/blob/65b1f335d771d657c5640a2056ab5c8546eddec9/src/main/java/acromusashi/stream/bean/FieldExtractor.java#L87-L97
148,033
acromusashi/acromusashi-stream
src/main/java/acromusashi/stream/bean/FieldExtractor.java
FieldExtractor.extractKeyTail
public static String extractKeyTail(String key, String delimeter) { int index = key.indexOf(delimeter); if (index == -1) { return null; } String result = key.substring(index + delimeter.length()); return result; }
java
public static String extractKeyTail(String key, String delimeter) { int index = key.indexOf(delimeter); if (index == -1) { return null; } String result = key.substring(index + delimeter.length()); return result; }
[ "public", "static", "String", "extractKeyTail", "(", "String", "key", ",", "String", "delimeter", ")", "{", "int", "index", "=", "key", ".", "indexOf", "(", "delimeter", ")", ";", "if", "(", "index", "==", "-", "1", ")", "{", "return", "null", ";", "}", "String", "result", "=", "key", ".", "substring", "(", "index", "+", "delimeter", ".", "length", "(", ")", ")", ";", "return", "result", ";", "}" ]
Extract the value of keyTail. @param key is used to get string. @param delimeter key delimeter @return the value of keyTail .
[ "Extract", "the", "value", "of", "keyTail", "." ]
65b1f335d771d657c5640a2056ab5c8546eddec9
https://github.com/acromusashi/acromusashi-stream/blob/65b1f335d771d657c5640a2056ab5c8546eddec9/src/main/java/acromusashi/stream/bean/FieldExtractor.java#L106-L115
148,034
grycap/coreutils
coreutils-fiber/src/main/java/es/upv/grycap/coreutils/fiber/http/Http2Client.java
Http2Client.asyncPost
public void asyncPost(final String url, final String mediaType, final Supplier<String> supplier, final Callback callback) { requireNonNull(supplier, "A valid supplier expected"); asyncPostBytes(url, mediaType, () -> ofNullable(supplier.get()).orElse("").getBytes(), callback); }
java
public void asyncPost(final String url, final String mediaType, final Supplier<String> supplier, final Callback callback) { requireNonNull(supplier, "A valid supplier expected"); asyncPostBytes(url, mediaType, () -> ofNullable(supplier.get()).orElse("").getBytes(), callback); }
[ "public", "void", "asyncPost", "(", "final", "String", "url", ",", "final", "String", "mediaType", ",", "final", "Supplier", "<", "String", ">", "supplier", ",", "final", "Callback", "callback", ")", "{", "requireNonNull", "(", "supplier", ",", "\"A valid supplier expected\"", ")", ";", "asyncPostBytes", "(", "url", ",", "mediaType", ",", "(", ")", "->", "ofNullable", "(", "supplier", ".", "get", "(", ")", ")", ".", "orElse", "(", "\"\"", ")", ".", "getBytes", "(", ")", ",", "callback", ")", ";", "}" ]
Posts data to a server via a HTTP POST request. @param url - URL target of this request @param mediaType - Content-Type header for this request @param supplier - supplies the content of this request @param callback - is called back when the response is readable
[ "Posts", "data", "to", "a", "server", "via", "a", "HTTP", "POST", "request", "." ]
e6db61dc50b49ea7276c0c29c7401204681a10c2
https://github.com/grycap/coreutils/blob/e6db61dc50b49ea7276c0c29c7401204681a10c2/coreutils-fiber/src/main/java/es/upv/grycap/coreutils/fiber/http/Http2Client.java#L114-L117
148,035
grycap/coreutils
coreutils-fiber/src/main/java/es/upv/grycap/coreutils/fiber/http/Http2Client.java
Http2Client.asyncPostBytes
public void asyncPostBytes(final String url, final String mediaType, final Supplier<byte[]> supplier, final Callback callback) { final String url2 = requireNonNull(trimToNull(url), "A non-empty URL expected"); final String mediaType2 = requireNonNull(trimToNull(mediaType), "A non-empty media type expected"); requireNonNull(supplier, "A valid supplier expected"); requireNonNull(callback, "A valid callback expected"); // prepare request final Request request = new Request.Builder().url(url2).post(new RequestBody() { @Override public MediaType contentType() { return MediaType.parse(mediaType2 + "; charset=utf-8"); } @Override public void writeTo(final BufferedSink sink) throws IOException { sink.write(supplier.get()); } }).build(); // submit request client.newCall(request).enqueue(callback); }
java
public void asyncPostBytes(final String url, final String mediaType, final Supplier<byte[]> supplier, final Callback callback) { final String url2 = requireNonNull(trimToNull(url), "A non-empty URL expected"); final String mediaType2 = requireNonNull(trimToNull(mediaType), "A non-empty media type expected"); requireNonNull(supplier, "A valid supplier expected"); requireNonNull(callback, "A valid callback expected"); // prepare request final Request request = new Request.Builder().url(url2).post(new RequestBody() { @Override public MediaType contentType() { return MediaType.parse(mediaType2 + "; charset=utf-8"); } @Override public void writeTo(final BufferedSink sink) throws IOException { sink.write(supplier.get()); } }).build(); // submit request client.newCall(request).enqueue(callback); }
[ "public", "void", "asyncPostBytes", "(", "final", "String", "url", ",", "final", "String", "mediaType", ",", "final", "Supplier", "<", "byte", "[", "]", ">", "supplier", ",", "final", "Callback", "callback", ")", "{", "final", "String", "url2", "=", "requireNonNull", "(", "trimToNull", "(", "url", ")", ",", "\"A non-empty URL expected\"", ")", ";", "final", "String", "mediaType2", "=", "requireNonNull", "(", "trimToNull", "(", "mediaType", ")", ",", "\"A non-empty media type expected\"", ")", ";", "requireNonNull", "(", "supplier", ",", "\"A valid supplier expected\"", ")", ";", "requireNonNull", "(", "callback", ",", "\"A valid callback expected\"", ")", ";", "// prepare request", "final", "Request", "request", "=", "new", "Request", ".", "Builder", "(", ")", ".", "url", "(", "url2", ")", ".", "post", "(", "new", "RequestBody", "(", ")", "{", "@", "Override", "public", "MediaType", "contentType", "(", ")", "{", "return", "MediaType", ".", "parse", "(", "mediaType2", "+", "\"; charset=utf-8\"", ")", ";", "}", "@", "Override", "public", "void", "writeTo", "(", "final", "BufferedSink", "sink", ")", "throws", "IOException", "{", "sink", ".", "write", "(", "supplier", ".", "get", "(", ")", ")", ";", "}", "}", ")", ".", "build", "(", ")", ";", "// submit request", "client", ".", "newCall", "(", "request", ")", ".", "enqueue", "(", "callback", ")", ";", "}" ]
Posts the content of a buffer of bytes to a server via a HTTP POST request. @param url - URL target of this request @param mediaType - Content-Type header for this request @param supplier - supplies the content of this request @param callback - is called back when the response is readable
[ "Posts", "the", "content", "of", "a", "buffer", "of", "bytes", "to", "a", "server", "via", "a", "HTTP", "POST", "request", "." ]
e6db61dc50b49ea7276c0c29c7401204681a10c2
https://github.com/grycap/coreutils/blob/e6db61dc50b49ea7276c0c29c7401204681a10c2/coreutils-fiber/src/main/java/es/upv/grycap/coreutils/fiber/http/Http2Client.java#L126-L144
148,036
grycap/coreutils
coreutils-fiber/src/main/java/es/upv/grycap/coreutils/fiber/http/Http2Client.java
Http2Client.asyncPut
public void asyncPut(final String url, final String mediaType, final Supplier<String> supplier, final Callback callback) { requireNonNull(supplier, "A valid supplier expected"); asyncPutBytes(url, mediaType, () -> ofNullable(supplier.get()).orElse("").getBytes(), callback); }
java
public void asyncPut(final String url, final String mediaType, final Supplier<String> supplier, final Callback callback) { requireNonNull(supplier, "A valid supplier expected"); asyncPutBytes(url, mediaType, () -> ofNullable(supplier.get()).orElse("").getBytes(), callback); }
[ "public", "void", "asyncPut", "(", "final", "String", "url", ",", "final", "String", "mediaType", ",", "final", "Supplier", "<", "String", ">", "supplier", ",", "final", "Callback", "callback", ")", "{", "requireNonNull", "(", "supplier", ",", "\"A valid supplier expected\"", ")", ";", "asyncPutBytes", "(", "url", ",", "mediaType", ",", "(", ")", "->", "ofNullable", "(", "supplier", ".", "get", "(", ")", ")", ".", "orElse", "(", "\"\"", ")", ".", "getBytes", "(", ")", ",", "callback", ")", ";", "}" ]
Puts data to a server via a HTTP PUT request. @param url - URL target of this request @param mediaType - Content-Type header for this request @param supplier - supplies the content of this request @param callback - is called back when the response is readable
[ "Puts", "data", "to", "a", "server", "via", "a", "HTTP", "PUT", "request", "." ]
e6db61dc50b49ea7276c0c29c7401204681a10c2
https://github.com/grycap/coreutils/blob/e6db61dc50b49ea7276c0c29c7401204681a10c2/coreutils-fiber/src/main/java/es/upv/grycap/coreutils/fiber/http/Http2Client.java#L153-L156
148,037
grycap/coreutils
coreutils-fiber/src/main/java/es/upv/grycap/coreutils/fiber/http/Http2Client.java
Http2Client.asyncDelete
public void asyncDelete(final String url, final Callback callback) { final String url2 = requireNonNull(trimToNull(url), "A non-empty URL expected"); requireNonNull(callback, "A valid callback expected"); // prepare request final Request request = new Request.Builder().url(url2).delete().build(); // submit request client.newCall(request).enqueue(callback); }
java
public void asyncDelete(final String url, final Callback callback) { final String url2 = requireNonNull(trimToNull(url), "A non-empty URL expected"); requireNonNull(callback, "A valid callback expected"); // prepare request final Request request = new Request.Builder().url(url2).delete().build(); // submit request client.newCall(request).enqueue(callback); }
[ "public", "void", "asyncDelete", "(", "final", "String", "url", ",", "final", "Callback", "callback", ")", "{", "final", "String", "url2", "=", "requireNonNull", "(", "trimToNull", "(", "url", ")", ",", "\"A non-empty URL expected\"", ")", ";", "requireNonNull", "(", "callback", ",", "\"A valid callback expected\"", ")", ";", "// prepare request", "final", "Request", "request", "=", "new", "Request", ".", "Builder", "(", ")", ".", "url", "(", "url2", ")", ".", "delete", "(", ")", ".", "build", "(", ")", ";", "// submit request", "client", ".", "newCall", "(", "request", ")", ".", "enqueue", "(", "callback", ")", ";", "}" ]
Delete HTTP method. @param url - URL target of this request @param callback - is called back when the response is readable
[ "Delete", "HTTP", "method", "." ]
e6db61dc50b49ea7276c0c29c7401204681a10c2
https://github.com/grycap/coreutils/blob/e6db61dc50b49ea7276c0c29c7401204681a10c2/coreutils-fiber/src/main/java/es/upv/grycap/coreutils/fiber/http/Http2Client.java#L190-L197
148,038
fuinorg/objects4j
src/main/java/org/fuin/objects4j/vo/WeeklyOpeningHours.java
WeeklyOpeningHours.asRemovedChanges
public List<Change> asRemovedChanges() { final WeeklyOpeningHours normalized = this.normalize(); final List<Change> changes = new ArrayList<>(); for (final DayOpeningHours doh : normalized) { changes.addAll(doh.asRemovedChanges()); } return changes; }
java
public List<Change> asRemovedChanges() { final WeeklyOpeningHours normalized = this.normalize(); final List<Change> changes = new ArrayList<>(); for (final DayOpeningHours doh : normalized) { changes.addAll(doh.asRemovedChanges()); } return changes; }
[ "public", "List", "<", "Change", ">", "asRemovedChanges", "(", ")", "{", "final", "WeeklyOpeningHours", "normalized", "=", "this", ".", "normalize", "(", ")", ";", "final", "List", "<", "Change", ">", "changes", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "final", "DayOpeningHours", "doh", ":", "normalized", ")", "{", "changes", ".", "addAll", "(", "doh", ".", "asRemovedChanges", "(", ")", ")", ";", "}", "return", "changes", ";", "}" ]
Returns all days and hour ranges as if they were removed. @return Removed day changes.
[ "Returns", "all", "days", "and", "hour", "ranges", "as", "if", "they", "were", "removed", "." ]
e7f278b5bae073ebb6a76053650571c718f36246
https://github.com/fuinorg/objects4j/blob/e7f278b5bae073ebb6a76053650571c718f36246/src/main/java/org/fuin/objects4j/vo/WeeklyOpeningHours.java#L213-L220
148,039
acromusashi/acromusashi-stream
src/main/java/acromusashi/stream/entity/StreamMessageHeader.java
StreamMessageHeader.addHistory
public void addHistory(Object historyKey) { if (this.history == null) { this.history = new KeyHistory(); } this.history.addKey(historyKey.toString()); }
java
public void addHistory(Object historyKey) { if (this.history == null) { this.history = new KeyHistory(); } this.history.addKey(historyKey.toString()); }
[ "public", "void", "addHistory", "(", "Object", "historyKey", ")", "{", "if", "(", "this", ".", "history", "==", "null", ")", "{", "this", ".", "history", "=", "new", "KeyHistory", "(", ")", ";", "}", "this", ".", "history", ".", "addKey", "(", "historyKey", ".", "toString", "(", ")", ")", ";", "}" ]
Add key to history. @param historyKey history key
[ "Add", "key", "to", "history", "." ]
65b1f335d771d657c5640a2056ab5c8546eddec9
https://github.com/acromusashi/acromusashi-stream/blob/65b1f335d771d657c5640a2056ab5c8546eddec9/src/main/java/acromusashi/stream/entity/StreamMessageHeader.java#L121-L129
148,040
acromusashi/acromusashi-stream
src/main/java/acromusashi/stream/entity/StreamMessageHeader.java
StreamMessageHeader.addAdditionalHeader
public void addAdditionalHeader(String key, String value) { if (this.additionalHeader == null) { this.additionalHeader = Maps.newLinkedHashMap(); } this.additionalHeader.put(key, value); }
java
public void addAdditionalHeader(String key, String value) { if (this.additionalHeader == null) { this.additionalHeader = Maps.newLinkedHashMap(); } this.additionalHeader.put(key, value); }
[ "public", "void", "addAdditionalHeader", "(", "String", "key", ",", "String", "value", ")", "{", "if", "(", "this", ".", "additionalHeader", "==", "null", ")", "{", "this", ".", "additionalHeader", "=", "Maps", ".", "newLinkedHashMap", "(", ")", ";", "}", "this", ".", "additionalHeader", ".", "put", "(", "key", ",", "value", ")", ";", "}" ]
Add value to additional header. @param key key @param value value
[ "Add", "value", "to", "additional", "header", "." ]
65b1f335d771d657c5640a2056ab5c8546eddec9
https://github.com/acromusashi/acromusashi-stream/blob/65b1f335d771d657c5640a2056ab5c8546eddec9/src/main/java/acromusashi/stream/entity/StreamMessageHeader.java#L217-L225
148,041
fuinorg/objects4j
src/main/java/org/fuin/objects4j/vo/UserNameStrValidator.java
UserNameStrValidator.isValid
public static final boolean isValid(final String value) { if (value == null) { return true; } if ((value.length() < 3) || (value.length() > 20)) { return false; } return PATTERN.matcher(value.toString()).matches(); }
java
public static final boolean isValid(final String value) { if (value == null) { return true; } if ((value.length() < 3) || (value.length() > 20)) { return false; } return PATTERN.matcher(value.toString()).matches(); }
[ "public", "static", "final", "boolean", "isValid", "(", "final", "String", "value", ")", "{", "if", "(", "value", "==", "null", ")", "{", "return", "true", ";", "}", "if", "(", "(", "value", ".", "length", "(", ")", "<", "3", ")", "||", "(", "value", ".", "length", "(", ")", ">", "20", ")", ")", "{", "return", "false", ";", "}", "return", "PATTERN", ".", "matcher", "(", "value", ".", "toString", "(", ")", ")", ".", "matches", "(", ")", ";", "}" ]
Check that a given string is a well-formed user id. @param value Value to check. @return Returns <code>true</code> if it's a valid user id else <code>false</code> is returned.
[ "Check", "that", "a", "given", "string", "is", "a", "well", "-", "formed", "user", "id", "." ]
e7f278b5bae073ebb6a76053650571c718f36246
https://github.com/fuinorg/objects4j/blob/e7f278b5bae073ebb6a76053650571c718f36246/src/main/java/org/fuin/objects4j/vo/UserNameStrValidator.java#L52-L60
148,042
projectodd/wunderboss-release
core/src/main/java/org/projectodd/wunderboss/Options.java
Options.get
public Object get(Object key) { Object val = super.get(key); if (val == null && key instanceof Option) { val = ((Option)key).defaultValue; } return val; }
java
public Object get(Object key) { Object val = super.get(key); if (val == null && key instanceof Option) { val = ((Option)key).defaultValue; } return val; }
[ "public", "Object", "get", "(", "Object", "key", ")", "{", "Object", "val", "=", "super", ".", "get", "(", "key", ")", ";", "if", "(", "val", "==", "null", "&&", "key", "instanceof", "Option", ")", "{", "val", "=", "(", "(", "Option", ")", "key", ")", ".", "defaultValue", ";", "}", "return", "val", ";", "}" ]
Looks up key in the options. If key is an Option, its default value will be returned if the key isn't found. @param key @return
[ "Looks", "up", "key", "in", "the", "options", "." ]
f67c68e80c5798169e3a9b2015e278239dbf005d
https://github.com/projectodd/wunderboss-release/blob/f67c68e80c5798169e3a9b2015e278239dbf005d/core/src/main/java/org/projectodd/wunderboss/Options.java#L46-L53
148,043
fuinorg/objects4j
src/main/java/org/fuin/objects4j/common/Contract.java
Contract.validate
@NotNull public static <TYPE> Set<ConstraintViolation<TYPE>> validate(@NotNull final Validator validator, @Nullable final TYPE value, @Nullable final Class<?>... groups) { if (value == null) { return new HashSet<ConstraintViolation<TYPE>>(); } return validator.validate(value, groups); }
java
@NotNull public static <TYPE> Set<ConstraintViolation<TYPE>> validate(@NotNull final Validator validator, @Nullable final TYPE value, @Nullable final Class<?>... groups) { if (value == null) { return new HashSet<ConstraintViolation<TYPE>>(); } return validator.validate(value, groups); }
[ "@", "NotNull", "public", "static", "<", "TYPE", ">", "Set", "<", "ConstraintViolation", "<", "TYPE", ">", ">", "validate", "(", "@", "NotNull", "final", "Validator", "validator", ",", "@", "Nullable", "final", "TYPE", "value", ",", "@", "Nullable", "final", "Class", "<", "?", ">", "...", "groups", ")", "{", "if", "(", "value", "==", "null", ")", "{", "return", "new", "HashSet", "<", "ConstraintViolation", "<", "TYPE", ">", ">", "(", ")", ";", "}", "return", "validator", ".", "validate", "(", "value", ",", "groups", ")", ";", "}" ]
Validates the given object. @param validator Validator to use. @param value Value to validate. @param groups Group or list of groups targeted for validation (defaults to {@link Default}) @return List of constraint violations. @param <TYPE> Type of the validated object.
[ "Validates", "the", "given", "object", "." ]
e7f278b5bae073ebb6a76053650571c718f36246
https://github.com/fuinorg/objects4j/blob/e7f278b5bae073ebb6a76053650571c718f36246/src/main/java/org/fuin/objects4j/common/Contract.java#L261-L268
148,044
fuinorg/objects4j
src/main/java/org/fuin/objects4j/common/Contract.java
Contract.validate
@NotNull public static <TYPE> Set<ConstraintViolation<TYPE>> validate(@Nullable final TYPE value, @Nullable final Class<?>... groups) { return validate(getValidator(), value, groups); }
java
@NotNull public static <TYPE> Set<ConstraintViolation<TYPE>> validate(@Nullable final TYPE value, @Nullable final Class<?>... groups) { return validate(getValidator(), value, groups); }
[ "@", "NotNull", "public", "static", "<", "TYPE", ">", "Set", "<", "ConstraintViolation", "<", "TYPE", ">", ">", "validate", "(", "@", "Nullable", "final", "TYPE", "value", ",", "@", "Nullable", "final", "Class", "<", "?", ">", "...", "groups", ")", "{", "return", "validate", "(", "getValidator", "(", ")", ",", "value", ",", "groups", ")", ";", "}" ]
Validates the given object using a default validator. @param value Value to validate. @param groups Group or list of groups targeted for validation (defaults to {@link Default}) @return List of constraint violations. @param <TYPE> Type of the validated object.
[ "Validates", "the", "given", "object", "using", "a", "default", "validator", "." ]
e7f278b5bae073ebb6a76053650571c718f36246
https://github.com/fuinorg/objects4j/blob/e7f278b5bae073ebb6a76053650571c718f36246/src/main/java/org/fuin/objects4j/common/Contract.java#L283-L286
148,045
lisicnu/droidUtil
src/main/java/com/github/lisicnu/libDroid/util/HardwareUtils.java
HardwareUtils.getMacAddr
public static String getMacAddr(Context context) { String mac = ""; try { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); WifiInfo wifi = wifiManager.getConnectionInfo(); mac = wifi.getMacAddress(); } catch (Exception e) { mac = null; Log.e(TAG, "", e); } if (StringUtils.isNullOrEmpty(mac)) mac = getLocalMacAddressFromBusybox(); if (StringUtils.isNullOrEmpty(mac)) mac = MAC_EMPTY; return mac; }
java
public static String getMacAddr(Context context) { String mac = ""; try { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); WifiInfo wifi = wifiManager.getConnectionInfo(); mac = wifi.getMacAddress(); } catch (Exception e) { mac = null; Log.e(TAG, "", e); } if (StringUtils.isNullOrEmpty(mac)) mac = getLocalMacAddressFromBusybox(); if (StringUtils.isNullOrEmpty(mac)) mac = MAC_EMPTY; return mac; }
[ "public", "static", "String", "getMacAddr", "(", "Context", "context", ")", "{", "String", "mac", "=", "\"\"", ";", "try", "{", "WifiManager", "wifiManager", "=", "(", "WifiManager", ")", "context", ".", "getSystemService", "(", "Context", ".", "WIFI_SERVICE", ")", ";", "WifiInfo", "wifi", "=", "wifiManager", ".", "getConnectionInfo", "(", ")", ";", "mac", "=", "wifi", ".", "getMacAddress", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "mac", "=", "null", ";", "Log", ".", "e", "(", "TAG", ",", "\"\"", ",", "e", ")", ";", "}", "if", "(", "StringUtils", ".", "isNullOrEmpty", "(", "mac", ")", ")", "mac", "=", "getLocalMacAddressFromBusybox", "(", ")", ";", "if", "(", "StringUtils", ".", "isNullOrEmpty", "(", "mac", ")", ")", "mac", "=", "MAC_EMPTY", ";", "return", "mac", ";", "}" ]
get mac address. @param context @return if error, will return {@link #MAC_EMPTY}
[ "get", "mac", "address", "." ]
e4d6cf3e3f60e5efb5a75672607ded94d1725519
https://github.com/lisicnu/droidUtil/blob/e4d6cf3e3f60e5efb5a75672607ded94d1725519/src/main/java/com/github/lisicnu/libDroid/util/HardwareUtils.java#L97-L115
148,046
lisicnu/droidUtil
src/main/java/com/github/lisicnu/libDroid/util/HardwareUtils.java
HardwareUtils.getStatusBarHeight
public static int getStatusBarHeight(Context context) { if (context == null) return 0; Class<?> c = null; Object obj = null; int x = 0, statusBarHeight = 0; try { c = Class.forName("com.android.internal.R$dimen"); obj = c.newInstance(); Field field = c.getField("status_bar_height"); x = Integer.parseInt(field.get(obj).toString()); statusBarHeight = context.getResources().getDimensionPixelSize(x); } catch (Exception e1) { Log.e(TAG, "", e1); } return statusBarHeight; }
java
public static int getStatusBarHeight(Context context) { if (context == null) return 0; Class<?> c = null; Object obj = null; int x = 0, statusBarHeight = 0; try { c = Class.forName("com.android.internal.R$dimen"); obj = c.newInstance(); Field field = c.getField("status_bar_height"); x = Integer.parseInt(field.get(obj).toString()); statusBarHeight = context.getResources().getDimensionPixelSize(x); } catch (Exception e1) { Log.e(TAG, "", e1); } return statusBarHeight; }
[ "public", "static", "int", "getStatusBarHeight", "(", "Context", "context", ")", "{", "if", "(", "context", "==", "null", ")", "return", "0", ";", "Class", "<", "?", ">", "c", "=", "null", ";", "Object", "obj", "=", "null", ";", "int", "x", "=", "0", ",", "statusBarHeight", "=", "0", ";", "try", "{", "c", "=", "Class", ".", "forName", "(", "\"com.android.internal.R$dimen\"", ")", ";", "obj", "=", "c", ".", "newInstance", "(", ")", ";", "Field", "field", "=", "c", ".", "getField", "(", "\"status_bar_height\"", ")", ";", "x", "=", "Integer", ".", "parseInt", "(", "field", ".", "get", "(", "obj", ")", ".", "toString", "(", ")", ")", ";", "statusBarHeight", "=", "context", ".", "getResources", "(", ")", ".", "getDimensionPixelSize", "(", "x", ")", ";", "}", "catch", "(", "Exception", "e1", ")", "{", "Log", ".", "e", "(", "TAG", ",", "\"\"", ",", "e1", ")", ";", "}", "return", "statusBarHeight", ";", "}" ]
get status bar height in px. @param context @return
[ "get", "status", "bar", "height", "in", "px", "." ]
e4d6cf3e3f60e5efb5a75672607ded94d1725519
https://github.com/lisicnu/droidUtil/blob/e4d6cf3e3f60e5efb5a75672607ded94d1725519/src/main/java/com/github/lisicnu/libDroid/util/HardwareUtils.java#L128-L143
148,047
acromusashi/acromusashi-stream
src/main/java/acromusashi/stream/hook/AmLogServerEndPoint.java
AmLogServerEndPoint.onOpen
@OnOpen public void onOpen(Session session) { logger.info("WebSocket connected. : SessionId={}", session.getId()); AmLogServerAdapter.getInstance().onOpen(session); }
java
@OnOpen public void onOpen(Session session) { logger.info("WebSocket connected. : SessionId={}", session.getId()); AmLogServerAdapter.getInstance().onOpen(session); }
[ "@", "OnOpen", "public", "void", "onOpen", "(", "Session", "session", ")", "{", "logger", ".", "info", "(", "\"WebSocket connected. : SessionId={}\"", ",", "session", ".", "getId", "(", ")", ")", ";", "AmLogServerAdapter", ".", "getInstance", "(", ")", ".", "onOpen", "(", "session", ")", ";", "}" ]
Websocket connection open. @param session session
[ "Websocket", "connection", "open", "." ]
65b1f335d771d657c5640a2056ab5c8546eddec9
https://github.com/acromusashi/acromusashi-stream/blob/65b1f335d771d657c5640a2056ab5c8546eddec9/src/main/java/acromusashi/stream/hook/AmLogServerEndPoint.java#L46-L51
148,048
acromusashi/acromusashi-stream
src/main/java/acromusashi/stream/hook/AmLogServerEndPoint.java
AmLogServerEndPoint.onClose
@OnClose public void onClose(Session session, CloseReason closeReason) { logger.info("WebSocket closed. : SessionId={}, Reason={}", session.getId(), closeReason.toString()); AmLogServerAdapter.getInstance().onClose(session); }
java
@OnClose public void onClose(Session session, CloseReason closeReason) { logger.info("WebSocket closed. : SessionId={}, Reason={}", session.getId(), closeReason.toString()); AmLogServerAdapter.getInstance().onClose(session); }
[ "@", "OnClose", "public", "void", "onClose", "(", "Session", "session", ",", "CloseReason", "closeReason", ")", "{", "logger", ".", "info", "(", "\"WebSocket closed. : SessionId={}, Reason={}\"", ",", "session", ".", "getId", "(", ")", ",", "closeReason", ".", "toString", "(", ")", ")", ";", "AmLogServerAdapter", ".", "getInstance", "(", ")", ".", "onClose", "(", "session", ")", ";", "}" ]
Websocket connection close. @param session session @param closeReason closeReason
[ "Websocket", "connection", "close", "." ]
65b1f335d771d657c5640a2056ab5c8546eddec9
https://github.com/acromusashi/acromusashi-stream/blob/65b1f335d771d657c5640a2056ab5c8546eddec9/src/main/java/acromusashi/stream/hook/AmLogServerEndPoint.java#L59-L65
148,049
fuinorg/objects4j
src/main/java/org/fuin/objects4j/ui/AnnotationAnalyzer.java
AnnotationAnalyzer.createClassInfo
public final ClassTextInfo createClassInfo(@NotNull final Class<?> clasz, @NotNull final Locale locale, @NotNull final Class<? extends Annotation> annotationClasz) { Contract.requireArgNotNull("clasz", clasz); Contract.requireArgNotNull("locale", locale); Contract.requireArgNotNull("annotationClasz", annotationClasz); final Annotation annotation = clasz.getAnnotation(annotationClasz); if (annotation == null) { return null; } try { final ResourceBundle bundle = getResourceBundle(annotation, locale, clasz); final String text = getText(bundle, annotation, clasz.getSimpleName() + "." + annotationClasz.getSimpleName()); return new ClassTextInfo(clasz, text); } catch (final MissingResourceException ex) { if (getValue(annotation).equals("")) { return new ClassTextInfo(clasz, null); } return new ClassTextInfo(clasz, getValue(annotation)); } }
java
public final ClassTextInfo createClassInfo(@NotNull final Class<?> clasz, @NotNull final Locale locale, @NotNull final Class<? extends Annotation> annotationClasz) { Contract.requireArgNotNull("clasz", clasz); Contract.requireArgNotNull("locale", locale); Contract.requireArgNotNull("annotationClasz", annotationClasz); final Annotation annotation = clasz.getAnnotation(annotationClasz); if (annotation == null) { return null; } try { final ResourceBundle bundle = getResourceBundle(annotation, locale, clasz); final String text = getText(bundle, annotation, clasz.getSimpleName() + "." + annotationClasz.getSimpleName()); return new ClassTextInfo(clasz, text); } catch (final MissingResourceException ex) { if (getValue(annotation).equals("")) { return new ClassTextInfo(clasz, null); } return new ClassTextInfo(clasz, getValue(annotation)); } }
[ "public", "final", "ClassTextInfo", "createClassInfo", "(", "@", "NotNull", "final", "Class", "<", "?", ">", "clasz", ",", "@", "NotNull", "final", "Locale", "locale", ",", "@", "NotNull", "final", "Class", "<", "?", "extends", "Annotation", ">", "annotationClasz", ")", "{", "Contract", ".", "requireArgNotNull", "(", "\"clasz\"", ",", "clasz", ")", ";", "Contract", ".", "requireArgNotNull", "(", "\"locale\"", ",", "locale", ")", ";", "Contract", ".", "requireArgNotNull", "(", "\"annotationClasz\"", ",", "annotationClasz", ")", ";", "final", "Annotation", "annotation", "=", "clasz", ".", "getAnnotation", "(", "annotationClasz", ")", ";", "if", "(", "annotation", "==", "null", ")", "{", "return", "null", ";", "}", "try", "{", "final", "ResourceBundle", "bundle", "=", "getResourceBundle", "(", "annotation", ",", "locale", ",", "clasz", ")", ";", "final", "String", "text", "=", "getText", "(", "bundle", ",", "annotation", ",", "clasz", ".", "getSimpleName", "(", ")", "+", "\".\"", "+", "annotationClasz", ".", "getSimpleName", "(", ")", ")", ";", "return", "new", "ClassTextInfo", "(", "clasz", ",", "text", ")", ";", "}", "catch", "(", "final", "MissingResourceException", "ex", ")", "{", "if", "(", "getValue", "(", "annotation", ")", ".", "equals", "(", "\"\"", ")", ")", "{", "return", "new", "ClassTextInfo", "(", "clasz", ",", "null", ")", ";", "}", "return", "new", "ClassTextInfo", "(", "clasz", ",", "getValue", "(", "annotation", ")", ")", ";", "}", "}" ]
Returns the text information for a given class. @param clasz Class. @param locale Locale to use. @param annotationClasz Type of annotation to find. @return Label information - Never <code>null</code>.
[ "Returns", "the", "text", "information", "for", "a", "given", "class", "." ]
e7f278b5bae073ebb6a76053650571c718f36246
https://github.com/fuinorg/objects4j/blob/e7f278b5bae073ebb6a76053650571c718f36246/src/main/java/org/fuin/objects4j/ui/AnnotationAnalyzer.java#L69-L92
148,050
fuinorg/objects4j
src/main/java/org/fuin/objects4j/ui/AnnotationAnalyzer.java
AnnotationAnalyzer.createFieldInfo
public final FieldTextInfo createFieldInfo(@NotNull final Field field, @NotNull final Locale locale, @NotNull final Class<? extends Annotation> annotationClasz) { Contract.requireArgNotNull("field", field); Contract.requireArgNotNull("locale", locale); Contract.requireArgNotNull("annotationClasz", annotationClasz); final Annotation annotation = field.getAnnotation(annotationClasz); if (annotation == null) { return null; } try { final ResourceBundle bundle = getResourceBundle(annotation, locale, field.getDeclaringClass()); final String text = getText(bundle, annotation, field.getName() + "." + annotationClasz.getSimpleName()); return new FieldTextInfo(field, text); } catch (final MissingResourceException ex) { return new FieldTextInfo(field, toNullableString(getValue(annotation))); } }
java
public final FieldTextInfo createFieldInfo(@NotNull final Field field, @NotNull final Locale locale, @NotNull final Class<? extends Annotation> annotationClasz) { Contract.requireArgNotNull("field", field); Contract.requireArgNotNull("locale", locale); Contract.requireArgNotNull("annotationClasz", annotationClasz); final Annotation annotation = field.getAnnotation(annotationClasz); if (annotation == null) { return null; } try { final ResourceBundle bundle = getResourceBundle(annotation, locale, field.getDeclaringClass()); final String text = getText(bundle, annotation, field.getName() + "." + annotationClasz.getSimpleName()); return new FieldTextInfo(field, text); } catch (final MissingResourceException ex) { return new FieldTextInfo(field, toNullableString(getValue(annotation))); } }
[ "public", "final", "FieldTextInfo", "createFieldInfo", "(", "@", "NotNull", "final", "Field", "field", ",", "@", "NotNull", "final", "Locale", "locale", ",", "@", "NotNull", "final", "Class", "<", "?", "extends", "Annotation", ">", "annotationClasz", ")", "{", "Contract", ".", "requireArgNotNull", "(", "\"field\"", ",", "field", ")", ";", "Contract", ".", "requireArgNotNull", "(", "\"locale\"", ",", "locale", ")", ";", "Contract", ".", "requireArgNotNull", "(", "\"annotationClasz\"", ",", "annotationClasz", ")", ";", "final", "Annotation", "annotation", "=", "field", ".", "getAnnotation", "(", "annotationClasz", ")", ";", "if", "(", "annotation", "==", "null", ")", "{", "return", "null", ";", "}", "try", "{", "final", "ResourceBundle", "bundle", "=", "getResourceBundle", "(", "annotation", ",", "locale", ",", "field", ".", "getDeclaringClass", "(", ")", ")", ";", "final", "String", "text", "=", "getText", "(", "bundle", ",", "annotation", ",", "field", ".", "getName", "(", ")", "+", "\".\"", "+", "annotationClasz", ".", "getSimpleName", "(", ")", ")", ";", "return", "new", "FieldTextInfo", "(", "field", ",", "text", ")", ";", "}", "catch", "(", "final", "MissingResourceException", "ex", ")", "{", "return", "new", "FieldTextInfo", "(", "field", ",", "toNullableString", "(", "getValue", "(", "annotation", ")", ")", ")", ";", "}", "}" ]
Returns the text information for a given field of a class. @param field Field to inspect. @param locale Locale to use. @param annotationClasz Type of annotation to find. @return Label information - May be <code>null</code> in case the annotation was not found.
[ "Returns", "the", "text", "information", "for", "a", "given", "field", "of", "a", "class", "." ]
e7f278b5bae073ebb6a76053650571c718f36246
https://github.com/fuinorg/objects4j/blob/e7f278b5bae073ebb6a76053650571c718f36246/src/main/java/org/fuin/objects4j/ui/AnnotationAnalyzer.java#L152-L172
148,051
fuinorg/objects4j
src/main/java/org/fuin/objects4j/ui/AnnotationAnalyzer.java
AnnotationAnalyzer.invoke
@SuppressWarnings("unchecked") private static <T> T invoke(final Object obj, final String methodName) { return (T) invoke(obj, methodName, null, null); }
java
@SuppressWarnings("unchecked") private static <T> T invoke(final Object obj, final String methodName) { return (T) invoke(obj, methodName, null, null); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "static", "<", "T", ">", "T", "invoke", "(", "final", "Object", "obj", ",", "final", "String", "methodName", ")", "{", "return", "(", "T", ")", "invoke", "(", "obj", ",", "methodName", ",", "null", ",", "null", ")", ";", "}" ]
Calls a method with no arguments using reflection and maps all errors into a runtime exception. @param obj The object the underlying method is invoked from - Cannot be <code>null</code>. @param methodName Name of the Method - Cannot be <code>null</code>. @return The result of dispatching the method represented by this object on <code>obj</code> with parameters <code>args</code>. @param <T> Return type.
[ "Calls", "a", "method", "with", "no", "arguments", "using", "reflection", "and", "maps", "all", "errors", "into", "a", "runtime", "exception", "." ]
e7f278b5bae073ebb6a76053650571c718f36246
https://github.com/fuinorg/objects4j/blob/e7f278b5bae073ebb6a76053650571c718f36246/src/main/java/org/fuin/objects4j/ui/AnnotationAnalyzer.java#L275-L278
148,052
fuinorg/objects4j
src/main/java/org/fuin/objects4j/ui/AnnotationAnalyzer.java
AnnotationAnalyzer.invoke
private static Object invoke(@NotNull final Object obj, @NotEmpty final String methodName, @Nullable final Class<?>[] argTypes, @Nullable final Object[] args) { Contract.requireArgNotNull("obj", obj); Contract.requireArgNotNull("methodName", methodName); final Class<?>[] argTypesIntern; final Object[] argsIntern; if (argTypes == null) { argTypesIntern = new Class[] {}; if (args != null) { throw new IllegalArgumentException("The argument 'argTypes' is null but " + "'args' containes values!"); } argsIntern = new Object[] {}; } else { argTypesIntern = argTypes; if (args == null) { throw new IllegalArgumentException("The argument 'argTypes' contains classes " + "but 'args' is null!"); } argsIntern = args; } checkSameLength(argTypesIntern, argsIntern); Class<?> returnType = UNKNOWN_CLASS.class; try { final Method method = obj.getClass().getMethod(methodName, argTypesIntern); if (method.getReturnType() == null) { returnType = void.class; } else { returnType = method.getReturnType(); } return method.invoke(obj, argsIntern); } catch (final SecurityException ex) { throw new RuntimeException("Security problem with '" + getMethodSignature(returnType, methodName, argTypesIntern) + "'! [" + obj.getClass().getName() + "]", ex); } catch (final NoSuchMethodException ex) { throw new RuntimeException("Method '" + getMethodSignature(returnType, methodName, argTypesIntern) + "' not found! [" + obj.getClass().getName() + "]", ex); } catch (final IllegalArgumentException ex) { throw new RuntimeException("Argument problem with '" + getMethodSignature(returnType, methodName, argTypesIntern) + "'! [" + obj.getClass().getName() + "]", ex); } catch (final IllegalAccessException ex) { throw new RuntimeException("Access problem with '" + getMethodSignature(returnType, methodName, argTypesIntern) + "'! [" + obj.getClass().getName() + "]", ex); } catch (final InvocationTargetException ex) { throw new RuntimeException("Got an exception when calling '" + getMethodSignature(returnType, methodName, argTypesIntern) + "'! [" + obj.getClass().getName() + "]", ex); } }
java
private static Object invoke(@NotNull final Object obj, @NotEmpty final String methodName, @Nullable final Class<?>[] argTypes, @Nullable final Object[] args) { Contract.requireArgNotNull("obj", obj); Contract.requireArgNotNull("methodName", methodName); final Class<?>[] argTypesIntern; final Object[] argsIntern; if (argTypes == null) { argTypesIntern = new Class[] {}; if (args != null) { throw new IllegalArgumentException("The argument 'argTypes' is null but " + "'args' containes values!"); } argsIntern = new Object[] {}; } else { argTypesIntern = argTypes; if (args == null) { throw new IllegalArgumentException("The argument 'argTypes' contains classes " + "but 'args' is null!"); } argsIntern = args; } checkSameLength(argTypesIntern, argsIntern); Class<?> returnType = UNKNOWN_CLASS.class; try { final Method method = obj.getClass().getMethod(methodName, argTypesIntern); if (method.getReturnType() == null) { returnType = void.class; } else { returnType = method.getReturnType(); } return method.invoke(obj, argsIntern); } catch (final SecurityException ex) { throw new RuntimeException("Security problem with '" + getMethodSignature(returnType, methodName, argTypesIntern) + "'! [" + obj.getClass().getName() + "]", ex); } catch (final NoSuchMethodException ex) { throw new RuntimeException("Method '" + getMethodSignature(returnType, methodName, argTypesIntern) + "' not found! [" + obj.getClass().getName() + "]", ex); } catch (final IllegalArgumentException ex) { throw new RuntimeException("Argument problem with '" + getMethodSignature(returnType, methodName, argTypesIntern) + "'! [" + obj.getClass().getName() + "]", ex); } catch (final IllegalAccessException ex) { throw new RuntimeException("Access problem with '" + getMethodSignature(returnType, methodName, argTypesIntern) + "'! [" + obj.getClass().getName() + "]", ex); } catch (final InvocationTargetException ex) { throw new RuntimeException("Got an exception when calling '" + getMethodSignature(returnType, methodName, argTypesIntern) + "'! [" + obj.getClass().getName() + "]", ex); } }
[ "private", "static", "Object", "invoke", "(", "@", "NotNull", "final", "Object", "obj", ",", "@", "NotEmpty", "final", "String", "methodName", ",", "@", "Nullable", "final", "Class", "<", "?", ">", "[", "]", "argTypes", ",", "@", "Nullable", "final", "Object", "[", "]", "args", ")", "{", "Contract", ".", "requireArgNotNull", "(", "\"obj\"", ",", "obj", ")", ";", "Contract", ".", "requireArgNotNull", "(", "\"methodName\"", ",", "methodName", ")", ";", "final", "Class", "<", "?", ">", "[", "]", "argTypesIntern", ";", "final", "Object", "[", "]", "argsIntern", ";", "if", "(", "argTypes", "==", "null", ")", "{", "argTypesIntern", "=", "new", "Class", "[", "]", "{", "}", ";", "if", "(", "args", "!=", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"The argument 'argTypes' is null but \"", "+", "\"'args' containes values!\"", ")", ";", "}", "argsIntern", "=", "new", "Object", "[", "]", "{", "}", ";", "}", "else", "{", "argTypesIntern", "=", "argTypes", ";", "if", "(", "args", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"The argument 'argTypes' contains classes \"", "+", "\"but 'args' is null!\"", ")", ";", "}", "argsIntern", "=", "args", ";", "}", "checkSameLength", "(", "argTypesIntern", ",", "argsIntern", ")", ";", "Class", "<", "?", ">", "returnType", "=", "UNKNOWN_CLASS", ".", "class", ";", "try", "{", "final", "Method", "method", "=", "obj", ".", "getClass", "(", ")", ".", "getMethod", "(", "methodName", ",", "argTypesIntern", ")", ";", "if", "(", "method", ".", "getReturnType", "(", ")", "==", "null", ")", "{", "returnType", "=", "void", ".", "class", ";", "}", "else", "{", "returnType", "=", "method", ".", "getReturnType", "(", ")", ";", "}", "return", "method", ".", "invoke", "(", "obj", ",", "argsIntern", ")", ";", "}", "catch", "(", "final", "SecurityException", "ex", ")", "{", "throw", "new", "RuntimeException", "(", "\"Security problem with '\"", "+", "getMethodSignature", "(", "returnType", ",", "methodName", ",", "argTypesIntern", ")", "+", "\"'! [\"", "+", "obj", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\"]\"", ",", "ex", ")", ";", "}", "catch", "(", "final", "NoSuchMethodException", "ex", ")", "{", "throw", "new", "RuntimeException", "(", "\"Method '\"", "+", "getMethodSignature", "(", "returnType", ",", "methodName", ",", "argTypesIntern", ")", "+", "\"' not found! [\"", "+", "obj", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\"]\"", ",", "ex", ")", ";", "}", "catch", "(", "final", "IllegalArgumentException", "ex", ")", "{", "throw", "new", "RuntimeException", "(", "\"Argument problem with '\"", "+", "getMethodSignature", "(", "returnType", ",", "methodName", ",", "argTypesIntern", ")", "+", "\"'! [\"", "+", "obj", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\"]\"", ",", "ex", ")", ";", "}", "catch", "(", "final", "IllegalAccessException", "ex", ")", "{", "throw", "new", "RuntimeException", "(", "\"Access problem with '\"", "+", "getMethodSignature", "(", "returnType", ",", "methodName", ",", "argTypesIntern", ")", "+", "\"'! [\"", "+", "obj", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\"]\"", ",", "ex", ")", ";", "}", "catch", "(", "final", "InvocationTargetException", "ex", ")", "{", "throw", "new", "RuntimeException", "(", "\"Got an exception when calling '\"", "+", "getMethodSignature", "(", "returnType", ",", "methodName", ",", "argTypesIntern", ")", "+", "\"'! [\"", "+", "obj", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\"]\"", ",", "ex", ")", ";", "}", "}" ]
Calls a method with reflection and maps all errors into a runtime exception. @param obj The object the underlying method is invoked from - Cannot be <code>null</code>. @param methodName Name of the Method - Cannot be <code>null</code> or empty. @param argTypes The list of parameters - May be <code>null</code>. @param args Arguments the arguments used for the method call - May be <code>null</code> if "argTypes" is also <code>null</code>. @return The result of dispatching the method represented by this object on <code>obj</code> with parameters <code>args</code>.
[ "Calls", "a", "method", "with", "reflection", "and", "maps", "all", "errors", "into", "a", "runtime", "exception", "." ]
e7f278b5bae073ebb6a76053650571c718f36246
https://github.com/fuinorg/objects4j/blob/e7f278b5bae073ebb6a76053650571c718f36246/src/main/java/org/fuin/objects4j/ui/AnnotationAnalyzer.java#L294-L343
148,053
fuinorg/objects4j
src/main/java/org/fuin/objects4j/vo/DayOpeningHours.java
DayOpeningHours.diff
public final List<Change> diff(final DayOpeningHours toOther) { Contract.requireArgNotNull("toOther", toOther); if (dayOfTheWeek != toOther.dayOfTheWeek) { throw new ConstraintViolationException( "Expected same day (" + dayOfTheWeek + ") for argument 'toOther', but was: " + toOther.dayOfTheWeek); } final List<DayOpeningHours> fromDays = normalize(); final List<DayOpeningHours> toDays = toOther.normalize(); final List<Change> changes = new ArrayList<>(); if (fromDays.size() == 1) { if (toDays.size() == 1) { // Both only 1 day final DayOpeningHours from = fromDays.get(0); final DayOpeningHours to = toDays.get(0); changes.addAll(changes(this.dayOfTheWeek, from.hourRanges, to.hourRanges)); } else { // From 1 day / To 2 days final DayOpeningHours from = fromDays.get(0); final DayOpeningHours to1 = toDays.get(0); final DayOpeningHours to2 = toDays.get(1); changes.addAll(changes(this.dayOfTheWeek, from.hourRanges, to1.hourRanges)); changes.addAll(changes(ChangeType.ADDED, to2.dayOfTheWeek, to2.hourRanges)); } } else { if (toDays.size() == 1) { // From 2 days / To 1 day final DayOpeningHours from1 = fromDays.get(0); final DayOpeningHours from2 = fromDays.get(1); final DayOpeningHours to = toDays.get(0); changes.addAll(changes(this.dayOfTheWeek, from1.hourRanges, to.hourRanges)); changes.addAll(changes(ChangeType.REMOVED, from2.dayOfTheWeek, from2.hourRanges)); } else { // Both 2 days final DayOpeningHours from1 = fromDays.get(0); final DayOpeningHours from2 = fromDays.get(1); final DayOpeningHours to1 = toDays.get(0); final DayOpeningHours to2 = toDays.get(1); changes.addAll(changes(from1.dayOfTheWeek, from1.hourRanges, to1.hourRanges)); changes.addAll(changes(from2.dayOfTheWeek, from2.hourRanges, to2.hourRanges)); } } return changes; }
java
public final List<Change> diff(final DayOpeningHours toOther) { Contract.requireArgNotNull("toOther", toOther); if (dayOfTheWeek != toOther.dayOfTheWeek) { throw new ConstraintViolationException( "Expected same day (" + dayOfTheWeek + ") for argument 'toOther', but was: " + toOther.dayOfTheWeek); } final List<DayOpeningHours> fromDays = normalize(); final List<DayOpeningHours> toDays = toOther.normalize(); final List<Change> changes = new ArrayList<>(); if (fromDays.size() == 1) { if (toDays.size() == 1) { // Both only 1 day final DayOpeningHours from = fromDays.get(0); final DayOpeningHours to = toDays.get(0); changes.addAll(changes(this.dayOfTheWeek, from.hourRanges, to.hourRanges)); } else { // From 1 day / To 2 days final DayOpeningHours from = fromDays.get(0); final DayOpeningHours to1 = toDays.get(0); final DayOpeningHours to2 = toDays.get(1); changes.addAll(changes(this.dayOfTheWeek, from.hourRanges, to1.hourRanges)); changes.addAll(changes(ChangeType.ADDED, to2.dayOfTheWeek, to2.hourRanges)); } } else { if (toDays.size() == 1) { // From 2 days / To 1 day final DayOpeningHours from1 = fromDays.get(0); final DayOpeningHours from2 = fromDays.get(1); final DayOpeningHours to = toDays.get(0); changes.addAll(changes(this.dayOfTheWeek, from1.hourRanges, to.hourRanges)); changes.addAll(changes(ChangeType.REMOVED, from2.dayOfTheWeek, from2.hourRanges)); } else { // Both 2 days final DayOpeningHours from1 = fromDays.get(0); final DayOpeningHours from2 = fromDays.get(1); final DayOpeningHours to1 = toDays.get(0); final DayOpeningHours to2 = toDays.get(1); changes.addAll(changes(from1.dayOfTheWeek, from1.hourRanges, to1.hourRanges)); changes.addAll(changes(from2.dayOfTheWeek, from2.hourRanges, to2.hourRanges)); } } return changes; }
[ "public", "final", "List", "<", "Change", ">", "diff", "(", "final", "DayOpeningHours", "toOther", ")", "{", "Contract", ".", "requireArgNotNull", "(", "\"toOther\"", ",", "toOther", ")", ";", "if", "(", "dayOfTheWeek", "!=", "toOther", ".", "dayOfTheWeek", ")", "{", "throw", "new", "ConstraintViolationException", "(", "\"Expected same day (\"", "+", "dayOfTheWeek", "+", "\") for argument 'toOther', but was: \"", "+", "toOther", ".", "dayOfTheWeek", ")", ";", "}", "final", "List", "<", "DayOpeningHours", ">", "fromDays", "=", "normalize", "(", ")", ";", "final", "List", "<", "DayOpeningHours", ">", "toDays", "=", "toOther", ".", "normalize", "(", ")", ";", "final", "List", "<", "Change", ">", "changes", "=", "new", "ArrayList", "<>", "(", ")", ";", "if", "(", "fromDays", ".", "size", "(", ")", "==", "1", ")", "{", "if", "(", "toDays", ".", "size", "(", ")", "==", "1", ")", "{", "// Both only 1 day", "final", "DayOpeningHours", "from", "=", "fromDays", ".", "get", "(", "0", ")", ";", "final", "DayOpeningHours", "to", "=", "toDays", ".", "get", "(", "0", ")", ";", "changes", ".", "addAll", "(", "changes", "(", "this", ".", "dayOfTheWeek", ",", "from", ".", "hourRanges", ",", "to", ".", "hourRanges", ")", ")", ";", "}", "else", "{", "// From 1 day / To 2 days", "final", "DayOpeningHours", "from", "=", "fromDays", ".", "get", "(", "0", ")", ";", "final", "DayOpeningHours", "to1", "=", "toDays", ".", "get", "(", "0", ")", ";", "final", "DayOpeningHours", "to2", "=", "toDays", ".", "get", "(", "1", ")", ";", "changes", ".", "addAll", "(", "changes", "(", "this", ".", "dayOfTheWeek", ",", "from", ".", "hourRanges", ",", "to1", ".", "hourRanges", ")", ")", ";", "changes", ".", "addAll", "(", "changes", "(", "ChangeType", ".", "ADDED", ",", "to2", ".", "dayOfTheWeek", ",", "to2", ".", "hourRanges", ")", ")", ";", "}", "}", "else", "{", "if", "(", "toDays", ".", "size", "(", ")", "==", "1", ")", "{", "// From 2 days / To 1 day", "final", "DayOpeningHours", "from1", "=", "fromDays", ".", "get", "(", "0", ")", ";", "final", "DayOpeningHours", "from2", "=", "fromDays", ".", "get", "(", "1", ")", ";", "final", "DayOpeningHours", "to", "=", "toDays", ".", "get", "(", "0", ")", ";", "changes", ".", "addAll", "(", "changes", "(", "this", ".", "dayOfTheWeek", ",", "from1", ".", "hourRanges", ",", "to", ".", "hourRanges", ")", ")", ";", "changes", ".", "addAll", "(", "changes", "(", "ChangeType", ".", "REMOVED", ",", "from2", ".", "dayOfTheWeek", ",", "from2", ".", "hourRanges", ")", ")", ";", "}", "else", "{", "// Both 2 days", "final", "DayOpeningHours", "from1", "=", "fromDays", ".", "get", "(", "0", ")", ";", "final", "DayOpeningHours", "from2", "=", "fromDays", ".", "get", "(", "1", ")", ";", "final", "DayOpeningHours", "to1", "=", "toDays", ".", "get", "(", "0", ")", ";", "final", "DayOpeningHours", "to2", "=", "toDays", ".", "get", "(", "1", ")", ";", "changes", ".", "addAll", "(", "changes", "(", "from1", ".", "dayOfTheWeek", ",", "from1", ".", "hourRanges", ",", "to1", ".", "hourRanges", ")", ")", ";", "changes", ".", "addAll", "(", "changes", "(", "from2", ".", "dayOfTheWeek", ",", "from2", ".", "hourRanges", ",", "to2", ".", "hourRanges", ")", ")", ";", "}", "}", "return", "changes", ";", "}" ]
Returns the difference when changing this opening hours to the other one. The day of the week must be equal for both compared instances. @param toOther Opening hours to compare with. @return List of changes or an empty list if both are equal.
[ "Returns", "the", "difference", "when", "changing", "this", "opening", "hours", "to", "the", "other", "one", ".", "The", "day", "of", "the", "week", "must", "be", "equal", "for", "both", "compared", "instances", "." ]
e7f278b5bae073ebb6a76053650571c718f36246
https://github.com/fuinorg/objects4j/blob/e7f278b5bae073ebb6a76053650571c718f36246/src/main/java/org/fuin/objects4j/vo/DayOpeningHours.java#L206-L252
148,054
fuinorg/objects4j
src/main/java/org/fuin/objects4j/vo/DayOpeningHours.java
DayOpeningHours.asRemovedChanges
public List<Change> asRemovedChanges() { final List<Change> changes = new ArrayList<>(); for (final HourRange hr : hourRanges) { changes.add(new Change(ChangeType.REMOVED, dayOfTheWeek, hr)); } return changes; }
java
public List<Change> asRemovedChanges() { final List<Change> changes = new ArrayList<>(); for (final HourRange hr : hourRanges) { changes.add(new Change(ChangeType.REMOVED, dayOfTheWeek, hr)); } return changes; }
[ "public", "List", "<", "Change", ">", "asRemovedChanges", "(", ")", "{", "final", "List", "<", "Change", ">", "changes", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "final", "HourRange", "hr", ":", "hourRanges", ")", "{", "changes", ".", "add", "(", "new", "Change", "(", "ChangeType", ".", "REMOVED", ",", "dayOfTheWeek", ",", "hr", ")", ")", ";", "}", "return", "changes", ";", "}" ]
Returns all hour ranges of this day as if they were removed. @return Removed day changes.
[ "Returns", "all", "hour", "ranges", "of", "this", "day", "as", "if", "they", "were", "removed", "." ]
e7f278b5bae073ebb6a76053650571c718f36246
https://github.com/fuinorg/objects4j/blob/e7f278b5bae073ebb6a76053650571c718f36246/src/main/java/org/fuin/objects4j/vo/DayOpeningHours.java#L351-L357
148,055
fuinorg/objects4j
src/main/java/org/fuin/objects4j/vo/DayOpeningHours.java
DayOpeningHours.asAddedChanges
public List<Change> asAddedChanges() { final List<Change> changes = new ArrayList<>(); for (final HourRange hr : hourRanges) { changes.add(new Change(ChangeType.ADDED, dayOfTheWeek, hr)); } return changes; }
java
public List<Change> asAddedChanges() { final List<Change> changes = new ArrayList<>(); for (final HourRange hr : hourRanges) { changes.add(new Change(ChangeType.ADDED, dayOfTheWeek, hr)); } return changes; }
[ "public", "List", "<", "Change", ">", "asAddedChanges", "(", ")", "{", "final", "List", "<", "Change", ">", "changes", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "final", "HourRange", "hr", ":", "hourRanges", ")", "{", "changes", ".", "add", "(", "new", "Change", "(", "ChangeType", ".", "ADDED", ",", "dayOfTheWeek", ",", "hr", ")", ")", ";", "}", "return", "changes", ";", "}" ]
Returns all hour ranges of this day as if they were added. @return Added day changes.
[ "Returns", "all", "hour", "ranges", "of", "this", "day", "as", "if", "they", "were", "added", "." ]
e7f278b5bae073ebb6a76053650571c718f36246
https://github.com/fuinorg/objects4j/blob/e7f278b5bae073ebb6a76053650571c718f36246/src/main/java/org/fuin/objects4j/vo/DayOpeningHours.java#L364-L370
148,056
fuinorg/objects4j
src/main/java/org/fuin/objects4j/vo/DayOpeningHours.java
DayOpeningHours.isValid
public static boolean isValid(@Nullable final String dayOpeningHours) { if (dayOpeningHours == null) { return true; } final int p = dayOpeningHours.indexOf(' '); if (p < 0) { return false; } final String dayOfTheWeekStr = dayOpeningHours.substring(0, p); final String hourRangesStr = dayOpeningHours.substring(p + 1); return DayOfTheWeek.isValid(dayOfTheWeekStr) && HourRanges.isValid(hourRangesStr); }
java
public static boolean isValid(@Nullable final String dayOpeningHours) { if (dayOpeningHours == null) { return true; } final int p = dayOpeningHours.indexOf(' '); if (p < 0) { return false; } final String dayOfTheWeekStr = dayOpeningHours.substring(0, p); final String hourRangesStr = dayOpeningHours.substring(p + 1); return DayOfTheWeek.isValid(dayOfTheWeekStr) && HourRanges.isValid(hourRangesStr); }
[ "public", "static", "boolean", "isValid", "(", "@", "Nullable", "final", "String", "dayOpeningHours", ")", "{", "if", "(", "dayOpeningHours", "==", "null", ")", "{", "return", "true", ";", "}", "final", "int", "p", "=", "dayOpeningHours", ".", "indexOf", "(", "'", "'", ")", ";", "if", "(", "p", "<", "0", ")", "{", "return", "false", ";", "}", "final", "String", "dayOfTheWeekStr", "=", "dayOpeningHours", ".", "substring", "(", "0", ",", "p", ")", ";", "final", "String", "hourRangesStr", "=", "dayOpeningHours", ".", "substring", "(", "p", "+", "1", ")", ";", "return", "DayOfTheWeek", ".", "isValid", "(", "dayOfTheWeekStr", ")", "&&", "HourRanges", ".", "isValid", "(", "hourRangesStr", ")", ";", "}" ]
Verifies if the string can be converted into an instance of this class. @param dayOpeningHours String to test. @return {@literal true} if the string is valid, else {@literal false}.
[ "Verifies", "if", "the", "string", "can", "be", "converted", "into", "an", "instance", "of", "this", "class", "." ]
e7f278b5bae073ebb6a76053650571c718f36246
https://github.com/fuinorg/objects4j/blob/e7f278b5bae073ebb6a76053650571c718f36246/src/main/java/org/fuin/objects4j/vo/DayOpeningHours.java#L436-L447
148,057
Lucas3oo/jicunit
src/jicunit-framework/src/main/java/org/jicunit/framework/internal/JicUnitServletClient.java
JicUnitServletClient.runAtServer
public Document runAtServer(String containerUrl, String testClassName, String testDisplayName) { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder; try { String url = containerUrl + String.format("?%s=%s&%s=%s", TEST_CLASS_NAME_PARAM, testClassName, TEST_NAME_PARAM, URLEncoder.encode(testDisplayName, ENCODING)); builder = factory.newDocumentBuilder(); Document document = builder.parse(url); return document; } catch (FileNotFoundException fe) { throw new RuntimeException("Could not find the test WAR at the server. Make sure jicunit.url points to the correct context root.", fe); } catch (ConnectException ce) { throw new RuntimeException("Could not connect to the server. Make sure jicunit.url points to the correct host and port.", ce); } catch (ParserConfigurationException | SAXException | IOException e) { throw new RuntimeException("Could not run the test. Check the jicunit.url so it is correct.", e); } }
java
public Document runAtServer(String containerUrl, String testClassName, String testDisplayName) { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder; try { String url = containerUrl + String.format("?%s=%s&%s=%s", TEST_CLASS_NAME_PARAM, testClassName, TEST_NAME_PARAM, URLEncoder.encode(testDisplayName, ENCODING)); builder = factory.newDocumentBuilder(); Document document = builder.parse(url); return document; } catch (FileNotFoundException fe) { throw new RuntimeException("Could not find the test WAR at the server. Make sure jicunit.url points to the correct context root.", fe); } catch (ConnectException ce) { throw new RuntimeException("Could not connect to the server. Make sure jicunit.url points to the correct host and port.", ce); } catch (ParserConfigurationException | SAXException | IOException e) { throw new RuntimeException("Could not run the test. Check the jicunit.url so it is correct.", e); } }
[ "public", "Document", "runAtServer", "(", "String", "containerUrl", ",", "String", "testClassName", ",", "String", "testDisplayName", ")", "{", "DocumentBuilderFactory", "factory", "=", "DocumentBuilderFactory", ".", "newInstance", "(", ")", ";", "DocumentBuilder", "builder", ";", "try", "{", "String", "url", "=", "containerUrl", "+", "String", ".", "format", "(", "\"?%s=%s&%s=%s\"", ",", "TEST_CLASS_NAME_PARAM", ",", "testClassName", ",", "TEST_NAME_PARAM", ",", "URLEncoder", ".", "encode", "(", "testDisplayName", ",", "ENCODING", ")", ")", ";", "builder", "=", "factory", ".", "newDocumentBuilder", "(", ")", ";", "Document", "document", "=", "builder", ".", "parse", "(", "url", ")", ";", "return", "document", ";", "}", "catch", "(", "FileNotFoundException", "fe", ")", "{", "throw", "new", "RuntimeException", "(", "\"Could not find the test WAR at the server. Make sure jicunit.url points to the correct context root.\"", ",", "fe", ")", ";", "}", "catch", "(", "ConnectException", "ce", ")", "{", "throw", "new", "RuntimeException", "(", "\"Could not connect to the server. Make sure jicunit.url points to the correct host and port.\"", ",", "ce", ")", ";", "}", "catch", "(", "ParserConfigurationException", "|", "SAXException", "|", "IOException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Could not run the test. Check the jicunit.url so it is correct.\"", ",", "e", ")", ";", "}", "}" ]
Execute the test at the server @param containerUrl @param testClassName @param testDisplayName @return
[ "Execute", "the", "test", "at", "the", "server" ]
1ed41891ccf8e5c6068c6b544d214280bb93945b
https://github.com/Lucas3oo/jicunit/blob/1ed41891ccf8e5c6068c6b544d214280bb93945b/src/jicunit-framework/src/main/java/org/jicunit/framework/internal/JicUnitServletClient.java#L44-L61
148,058
Lucas3oo/jicunit
src/jicunit-framework/src/main/java/org/jicunit/framework/internal/JicUnitServletClient.java
JicUnitServletClient.processResults
public void processResults(Document document) throws Throwable { Element root = document.getDocumentElement(); root.normalize(); // top element should testcase which has attributes for the outcome of the test // e.g <testcase classname="TheClass" name="theName(TheClass)" status="Error"><exception message="message" type="type">some text</exception></testcase> NamedNodeMap attributes = root.getAttributes(); String statusAsStr = attributes.getNamedItem("status").getNodeValue(); Status status = Status.valueOf(statusAsStr); if (status.equals(Status.Error) || status.equals(Status.Failure)) { throw getException(root, status); } }
java
public void processResults(Document document) throws Throwable { Element root = document.getDocumentElement(); root.normalize(); // top element should testcase which has attributes for the outcome of the test // e.g <testcase classname="TheClass" name="theName(TheClass)" status="Error"><exception message="message" type="type">some text</exception></testcase> NamedNodeMap attributes = root.getAttributes(); String statusAsStr = attributes.getNamedItem("status").getNodeValue(); Status status = Status.valueOf(statusAsStr); if (status.equals(Status.Error) || status.equals(Status.Failure)) { throw getException(root, status); } }
[ "public", "void", "processResults", "(", "Document", "document", ")", "throws", "Throwable", "{", "Element", "root", "=", "document", ".", "getDocumentElement", "(", ")", ";", "root", ".", "normalize", "(", ")", ";", "// top element should testcase which has attributes for the outcome of the test", "// e.g <testcase classname=\"TheClass\" name=\"theName(TheClass)\" status=\"Error\"><exception message=\"message\" type=\"type\">some text</exception></testcase>", "NamedNodeMap", "attributes", "=", "root", ".", "getAttributes", "(", ")", ";", "String", "statusAsStr", "=", "attributes", ".", "getNamedItem", "(", "\"status\"", ")", ".", "getNodeValue", "(", ")", ";", "Status", "status", "=", "Status", ".", "valueOf", "(", "statusAsStr", ")", ";", "if", "(", "status", ".", "equals", "(", "Status", ".", "Error", ")", "||", "status", ".", "equals", "(", "Status", ".", "Failure", ")", ")", "{", "throw", "getException", "(", "root", ",", "status", ")", ";", "}", "}" ]
Processes the actual XML result and generate exceptions in case there was an issue on the server side. @param document @throws Throwable
[ "Processes", "the", "actual", "XML", "result", "and", "generate", "exceptions", "in", "case", "there", "was", "an", "issue", "on", "the", "server", "side", "." ]
1ed41891ccf8e5c6068c6b544d214280bb93945b
https://github.com/Lucas3oo/jicunit/blob/1ed41891ccf8e5c6068c6b544d214280bb93945b/src/jicunit-framework/src/main/java/org/jicunit/framework/internal/JicUnitServletClient.java#L70-L82
148,059
globocom/GloboDNS-Client
src/main/java/com/globo/globodns/client/AbstractAPI.java
AbstractAPI.buildHttpRequestFactory
protected HttpRequestFactory buildHttpRequestFactory() { HttpRequestFactory request = this.getGloboDns().getHttpTransport().createRequestFactory(new HttpRequestInitializer() { @Override public void initialize(HttpRequest request) throws IOException { request.setNumberOfRetries(AbstractAPI.this.globoDns.getNumberOfRetries()); request.setConnectTimeout(AbstractAPI.this.globoDns.getConnectionTimeout()); request.setReadTimeout(AbstractAPI.this.globoDns.getReadTimeout()); request.setThrowExceptionOnExecuteError(false); request.setParser(parser); request.setLoggingEnabled(true); request.getHeaders().setUserAgent("GloboDNS-Client"); request.setCurlLoggingEnabled(true); request.setUnsuccessfulResponseHandler(new HttpUnsuccessfulResponseHandler() { @Override public boolean handleResponse(HttpRequest request, HttpResponse response, boolean supportsRetry) throws IOException { if (response.getStatusCode() == 401) { getGloboDns().clearToken(); if (supportsRetry) { // only if supports retry I will prepare request with a new token, and ask to retry insertAuthenticationHeaders(request); return true; } } return false; } }); request.setResponseInterceptor(new HttpResponseInterceptor() { @Override public void interceptResponse(HttpResponse response) throws IOException { AbstractAPI.this.interceptResponse(response); } }); interceptRequest(request); } }); return request; }
java
protected HttpRequestFactory buildHttpRequestFactory() { HttpRequestFactory request = this.getGloboDns().getHttpTransport().createRequestFactory(new HttpRequestInitializer() { @Override public void initialize(HttpRequest request) throws IOException { request.setNumberOfRetries(AbstractAPI.this.globoDns.getNumberOfRetries()); request.setConnectTimeout(AbstractAPI.this.globoDns.getConnectionTimeout()); request.setReadTimeout(AbstractAPI.this.globoDns.getReadTimeout()); request.setThrowExceptionOnExecuteError(false); request.setParser(parser); request.setLoggingEnabled(true); request.getHeaders().setUserAgent("GloboDNS-Client"); request.setCurlLoggingEnabled(true); request.setUnsuccessfulResponseHandler(new HttpUnsuccessfulResponseHandler() { @Override public boolean handleResponse(HttpRequest request, HttpResponse response, boolean supportsRetry) throws IOException { if (response.getStatusCode() == 401) { getGloboDns().clearToken(); if (supportsRetry) { // only if supports retry I will prepare request with a new token, and ask to retry insertAuthenticationHeaders(request); return true; } } return false; } }); request.setResponseInterceptor(new HttpResponseInterceptor() { @Override public void interceptResponse(HttpResponse response) throws IOException { AbstractAPI.this.interceptResponse(response); } }); interceptRequest(request); } }); return request; }
[ "protected", "HttpRequestFactory", "buildHttpRequestFactory", "(", ")", "{", "HttpRequestFactory", "request", "=", "this", ".", "getGloboDns", "(", ")", ".", "getHttpTransport", "(", ")", ".", "createRequestFactory", "(", "new", "HttpRequestInitializer", "(", ")", "{", "@", "Override", "public", "void", "initialize", "(", "HttpRequest", "request", ")", "throws", "IOException", "{", "request", ".", "setNumberOfRetries", "(", "AbstractAPI", ".", "this", ".", "globoDns", ".", "getNumberOfRetries", "(", ")", ")", ";", "request", ".", "setConnectTimeout", "(", "AbstractAPI", ".", "this", ".", "globoDns", ".", "getConnectionTimeout", "(", ")", ")", ";", "request", ".", "setReadTimeout", "(", "AbstractAPI", ".", "this", ".", "globoDns", ".", "getReadTimeout", "(", ")", ")", ";", "request", ".", "setThrowExceptionOnExecuteError", "(", "false", ")", ";", "request", ".", "setParser", "(", "parser", ")", ";", "request", ".", "setLoggingEnabled", "(", "true", ")", ";", "request", ".", "getHeaders", "(", ")", ".", "setUserAgent", "(", "\"GloboDNS-Client\"", ")", ";", "request", ".", "setCurlLoggingEnabled", "(", "true", ")", ";", "request", ".", "setUnsuccessfulResponseHandler", "(", "new", "HttpUnsuccessfulResponseHandler", "(", ")", "{", "@", "Override", "public", "boolean", "handleResponse", "(", "HttpRequest", "request", ",", "HttpResponse", "response", ",", "boolean", "supportsRetry", ")", "throws", "IOException", "{", "if", "(", "response", ".", "getStatusCode", "(", ")", "==", "401", ")", "{", "getGloboDns", "(", ")", ".", "clearToken", "(", ")", ";", "if", "(", "supportsRetry", ")", "{", "// only if supports retry I will prepare request with a new token, and ask to retry", "insertAuthenticationHeaders", "(", "request", ")", ";", "return", "true", ";", "}", "}", "return", "false", ";", "}", "}", ")", ";", "request", ".", "setResponseInterceptor", "(", "new", "HttpResponseInterceptor", "(", ")", "{", "@", "Override", "public", "void", "interceptResponse", "(", "HttpResponse", "response", ")", "throws", "IOException", "{", "AbstractAPI", ".", "this", ".", "interceptResponse", "(", "response", ")", ";", "}", "}", ")", ";", "interceptRequest", "(", "request", ")", ";", "}", "}", ")", ";", "return", "request", ";", "}" ]
Customize HttpRequestFactory with authentication and error handling. @return new instance of HttpRequestFactory
[ "Customize", "HttpRequestFactory", "with", "authentication", "and", "error", "handling", "." ]
4f9b742bdc598c41299fcf92e8443ce419709618
https://github.com/globocom/GloboDNS-Client/blob/4f9b742bdc598c41299fcf92e8443ce419709618/src/main/java/com/globo/globodns/client/AbstractAPI.java#L80-L119
148,060
DDTH/ddth-dao
ddth-dao-core/src/main/java/com/github/ddth/dao/nosql/cassandra/CassandraKdWideColumnStorage.java
CassandraKdWideColumnStorage.bytesMapToDocument
protected Map<String, Object> bytesMapToDocument(Map<String, byte[]> data) { if (data == null || data.size() == 0) { return null; } Map<String, Object> doc = new HashMap<>(); data.forEach((k, v) -> { Object value = SerializationUtils.fromByteArrayFst(v); if (value != null) { doc.put(k, value); } }); return doc; }
java
protected Map<String, Object> bytesMapToDocument(Map<String, byte[]> data) { if (data == null || data.size() == 0) { return null; } Map<String, Object> doc = new HashMap<>(); data.forEach((k, v) -> { Object value = SerializationUtils.fromByteArrayFst(v); if (value != null) { doc.put(k, value); } }); return doc; }
[ "protected", "Map", "<", "String", ",", "Object", ">", "bytesMapToDocument", "(", "Map", "<", "String", ",", "byte", "[", "]", ">", "data", ")", "{", "if", "(", "data", "==", "null", "||", "data", ".", "size", "(", ")", "==", "0", ")", "{", "return", "null", ";", "}", "Map", "<", "String", ",", "Object", ">", "doc", "=", "new", "HashMap", "<>", "(", ")", ";", "data", ".", "forEach", "(", "(", "k", ",", "v", ")", "->", "{", "Object", "value", "=", "SerializationUtils", ".", "fromByteArrayFst", "(", "v", ")", ";", "if", "(", "value", "!=", "null", ")", "{", "doc", ".", "put", "(", "k", ",", "value", ")", ";", "}", "}", ")", ";", "return", "doc", ";", "}" ]
De-serialize byte-array map to "document". @param data @return
[ "De", "-", "serialize", "byte", "-", "array", "map", "to", "document", "." ]
8d059ddf641a1629aa53851f9d1b41abf175a180
https://github.com/DDTH/ddth-dao/blob/8d059ddf641a1629aa53851f9d1b41abf175a180/ddth-dao-core/src/main/java/com/github/ddth/dao/nosql/cassandra/CassandraKdWideColumnStorage.java#L342-L354
148,061
DDTH/ddth-dao
ddth-dao-core/src/main/java/com/github/ddth/dao/nosql/cassandra/CassandraKdWideColumnStorage.java
CassandraKdWideColumnStorage.documentToBytesMap
@SuppressWarnings("unchecked") protected Map<String, byte[]> documentToBytesMap(Map<String, Object> doc) { if (doc == null || doc.size() == 0) { return Collections.EMPTY_MAP; } Map<String, byte[]> data = new HashMap<>(); doc.forEach((k, v) -> { byte[] value = SerializationUtils.toByteArrayFst(v); if (value != null) { data.put(k, value); } }); return data; }
java
@SuppressWarnings("unchecked") protected Map<String, byte[]> documentToBytesMap(Map<String, Object> doc) { if (doc == null || doc.size() == 0) { return Collections.EMPTY_MAP; } Map<String, byte[]> data = new HashMap<>(); doc.forEach((k, v) -> { byte[] value = SerializationUtils.toByteArrayFst(v); if (value != null) { data.put(k, value); } }); return data; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "protected", "Map", "<", "String", ",", "byte", "[", "]", ">", "documentToBytesMap", "(", "Map", "<", "String", ",", "Object", ">", "doc", ")", "{", "if", "(", "doc", "==", "null", "||", "doc", ".", "size", "(", ")", "==", "0", ")", "{", "return", "Collections", ".", "EMPTY_MAP", ";", "}", "Map", "<", "String", ",", "byte", "[", "]", ">", "data", "=", "new", "HashMap", "<>", "(", ")", ";", "doc", ".", "forEach", "(", "(", "k", ",", "v", ")", "->", "{", "byte", "[", "]", "value", "=", "SerializationUtils", ".", "toByteArrayFst", "(", "v", ")", ";", "if", "(", "value", "!=", "null", ")", "{", "data", ".", "put", "(", "k", ",", "value", ")", ";", "}", "}", ")", ";", "return", "data", ";", "}" ]
Sereialize "document" to byte-array map. @param doc @return
[ "Sereialize", "document", "to", "byte", "-", "array", "map", "." ]
8d059ddf641a1629aa53851f9d1b41abf175a180
https://github.com/DDTH/ddth-dao/blob/8d059ddf641a1629aa53851f9d1b41abf175a180/ddth-dao-core/src/main/java/com/github/ddth/dao/nosql/cassandra/CassandraKdWideColumnStorage.java#L362-L375
148,062
fuinorg/objects4j
src/main/java/org/fuin/objects4j/ui/FontSize.java
FontSize.toPixel
public final int toPixel() { if (unit == FontSizeUnit.PIXEL) { return Math.round(size); } if (unit == FontSizeUnit.EM) { return Math.round(16 * size); } if (unit == FontSizeUnit.PERCENT) { return Math.round(size / 100 * 16); } if (unit == FontSizeUnit.POINT) { return Math.round(size / 3 * 4); } throw new IllegalStateException("Unknown unit: " + unit); }
java
public final int toPixel() { if (unit == FontSizeUnit.PIXEL) { return Math.round(size); } if (unit == FontSizeUnit.EM) { return Math.round(16 * size); } if (unit == FontSizeUnit.PERCENT) { return Math.round(size / 100 * 16); } if (unit == FontSizeUnit.POINT) { return Math.round(size / 3 * 4); } throw new IllegalStateException("Unknown unit: " + unit); }
[ "public", "final", "int", "toPixel", "(", ")", "{", "if", "(", "unit", "==", "FontSizeUnit", ".", "PIXEL", ")", "{", "return", "Math", ".", "round", "(", "size", ")", ";", "}", "if", "(", "unit", "==", "FontSizeUnit", ".", "EM", ")", "{", "return", "Math", ".", "round", "(", "16", "*", "size", ")", ";", "}", "if", "(", "unit", "==", "FontSizeUnit", ".", "PERCENT", ")", "{", "return", "Math", ".", "round", "(", "size", "/", "100", "*", "16", ")", ";", "}", "if", "(", "unit", "==", "FontSizeUnit", ".", "POINT", ")", "{", "return", "Math", ".", "round", "(", "size", "/", "3", "*", "4", ")", ";", "}", "throw", "new", "IllegalStateException", "(", "\"Unknown unit: \"", "+", "unit", ")", ";", "}" ]
Returns the font size expressed in pixels. @return Pixels.
[ "Returns", "the", "font", "size", "expressed", "in", "pixels", "." ]
e7f278b5bae073ebb6a76053650571c718f36246
https://github.com/fuinorg/objects4j/blob/e7f278b5bae073ebb6a76053650571c718f36246/src/main/java/org/fuin/objects4j/ui/FontSize.java#L79-L93
148,063
fuinorg/objects4j
src/main/java/org/fuin/objects4j/ui/FontSize.java
FontSize.toPoint
public final float toPoint() { if (unit == FontSizeUnit.PIXEL) { return (size / 4 * 3); } if (unit == FontSizeUnit.EM) { return (size * 12); } if (unit == FontSizeUnit.PERCENT) { return (size / 100 * 12); } if (unit == FontSizeUnit.POINT) { return size; } throw new IllegalStateException("Unknown unit: " + unit); }
java
public final float toPoint() { if (unit == FontSizeUnit.PIXEL) { return (size / 4 * 3); } if (unit == FontSizeUnit.EM) { return (size * 12); } if (unit == FontSizeUnit.PERCENT) { return (size / 100 * 12); } if (unit == FontSizeUnit.POINT) { return size; } throw new IllegalStateException("Unknown unit: " + unit); }
[ "public", "final", "float", "toPoint", "(", ")", "{", "if", "(", "unit", "==", "FontSizeUnit", ".", "PIXEL", ")", "{", "return", "(", "size", "/", "4", "*", "3", ")", ";", "}", "if", "(", "unit", "==", "FontSizeUnit", ".", "EM", ")", "{", "return", "(", "size", "*", "12", ")", ";", "}", "if", "(", "unit", "==", "FontSizeUnit", ".", "PERCENT", ")", "{", "return", "(", "size", "/", "100", "*", "12", ")", ";", "}", "if", "(", "unit", "==", "FontSizeUnit", ".", "POINT", ")", "{", "return", "size", ";", "}", "throw", "new", "IllegalStateException", "(", "\"Unknown unit: \"", "+", "unit", ")", ";", "}" ]
Returns the font size expressed in points. @return Points.
[ "Returns", "the", "font", "size", "expressed", "in", "points", "." ]
e7f278b5bae073ebb6a76053650571c718f36246
https://github.com/fuinorg/objects4j/blob/e7f278b5bae073ebb6a76053650571c718f36246/src/main/java/org/fuin/objects4j/ui/FontSize.java#L100-L114
148,064
Lucas3oo/jicunit
src/jicunit-framework/src/main/java/org/jicunit/framework/internal/ParameterizedProxyRunner.java
ParameterizedProxyRunner.getChildren
@Override protected List<Runner> getChildren() { // one runner for each parameter List<Runner> runners = super.getChildren(); List<Runner> proxyRunners = new ArrayList<>(runners.size()); for (Runner runner : runners) { // if the next line fails then the internal of Parameterized.class has been updated since this works with JUnit 4.11 BlockJUnit4ClassRunner blockJUnit4ClassRunner = (BlockJUnit4ClassRunner) runner; Description description = blockJUnit4ClassRunner.getDescription(); String name = description.getDisplayName(); try { proxyRunners .add(new ProxyTestClassRunnerForParameters(mTestClass, mContainerUrl, name)); } catch (InitializationError e) { throw new RuntimeException("Could not create runner for paramamter " + name, e); } } return proxyRunners; }
java
@Override protected List<Runner> getChildren() { // one runner for each parameter List<Runner> runners = super.getChildren(); List<Runner> proxyRunners = new ArrayList<>(runners.size()); for (Runner runner : runners) { // if the next line fails then the internal of Parameterized.class has been updated since this works with JUnit 4.11 BlockJUnit4ClassRunner blockJUnit4ClassRunner = (BlockJUnit4ClassRunner) runner; Description description = blockJUnit4ClassRunner.getDescription(); String name = description.getDisplayName(); try { proxyRunners .add(new ProxyTestClassRunnerForParameters(mTestClass, mContainerUrl, name)); } catch (InitializationError e) { throw new RuntimeException("Could not create runner for paramamter " + name, e); } } return proxyRunners; }
[ "@", "Override", "protected", "List", "<", "Runner", ">", "getChildren", "(", ")", "{", "// one runner for each parameter", "List", "<", "Runner", ">", "runners", "=", "super", ".", "getChildren", "(", ")", ";", "List", "<", "Runner", ">", "proxyRunners", "=", "new", "ArrayList", "<>", "(", "runners", ".", "size", "(", ")", ")", ";", "for", "(", "Runner", "runner", ":", "runners", ")", "{", "// if the next line fails then the internal of Parameterized.class has been updated since this works with JUnit 4.11", "BlockJUnit4ClassRunner", "blockJUnit4ClassRunner", "=", "(", "BlockJUnit4ClassRunner", ")", "runner", ";", "Description", "description", "=", "blockJUnit4ClassRunner", ".", "getDescription", "(", ")", ";", "String", "name", "=", "description", ".", "getDisplayName", "(", ")", ";", "try", "{", "proxyRunners", ".", "add", "(", "new", "ProxyTestClassRunnerForParameters", "(", "mTestClass", ",", "mContainerUrl", ",", "name", ")", ")", ";", "}", "catch", "(", "InitializationError", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Could not create runner for paramamter \"", "+", "name", ",", "e", ")", ";", "}", "}", "return", "proxyRunners", ";", "}" ]
replace the runners with slightly modified BasicProxyRunner
[ "replace", "the", "runners", "with", "slightly", "modified", "BasicProxyRunner" ]
1ed41891ccf8e5c6068c6b544d214280bb93945b
https://github.com/Lucas3oo/jicunit/blob/1ed41891ccf8e5c6068c6b544d214280bb93945b/src/jicunit-framework/src/main/java/org/jicunit/framework/internal/ParameterizedProxyRunner.java#L32-L50
148,065
DDTH/ddth-dao
ddth-dao-core/src/main/java/com/github/ddth/dao/utils/DbcHelper.java
DbcHelper.registerJdbcDataSource
public static boolean registerJdbcDataSource(String name, DataSource dataSource) { return jdbcDataSources.putIfAbsent(name, dataSource) == null; }
java
public static boolean registerJdbcDataSource(String name, DataSource dataSource) { return jdbcDataSources.putIfAbsent(name, dataSource) == null; }
[ "public", "static", "boolean", "registerJdbcDataSource", "(", "String", "name", ",", "DataSource", "dataSource", ")", "{", "return", "jdbcDataSources", ".", "putIfAbsent", "(", "name", ",", "dataSource", ")", "==", "null", ";", "}" ]
Registers a named JDBC datasource. @param name @param dataSource @return
[ "Registers", "a", "named", "JDBC", "datasource", "." ]
8d059ddf641a1629aa53851f9d1b41abf175a180
https://github.com/DDTH/ddth-dao/blob/8d059ddf641a1629aa53851f9d1b41abf175a180/ddth-dao-core/src/main/java/com/github/ddth/dao/utils/DbcHelper.java#L39-L41
148,066
DDTH/ddth-dao
ddth-dao-core/src/main/java/com/github/ddth/dao/utils/DbcHelper.java
DbcHelper.startTransaction
public static boolean startTransaction(Connection conn) throws SQLException { if (conn == null) { return false; } String dsName = openConnDsName.get().get(conn); OpenConnStats connStats = dsName != null ? openConnStats.get().get(dsName) : null; if (connStats != null && !connStats.inTransaction) { conn.setAutoCommit(false); connStats.inTransaction = true; return true; } return false; }
java
public static boolean startTransaction(Connection conn) throws SQLException { if (conn == null) { return false; } String dsName = openConnDsName.get().get(conn); OpenConnStats connStats = dsName != null ? openConnStats.get().get(dsName) : null; if (connStats != null && !connStats.inTransaction) { conn.setAutoCommit(false); connStats.inTransaction = true; return true; } return false; }
[ "public", "static", "boolean", "startTransaction", "(", "Connection", "conn", ")", "throws", "SQLException", "{", "if", "(", "conn", "==", "null", ")", "{", "return", "false", ";", "}", "String", "dsName", "=", "openConnDsName", ".", "get", "(", ")", ".", "get", "(", "conn", ")", ";", "OpenConnStats", "connStats", "=", "dsName", "!=", "null", "?", "openConnStats", ".", "get", "(", ")", ".", "get", "(", "dsName", ")", ":", "null", ";", "if", "(", "connStats", "!=", "null", "&&", "!", "connStats", ".", "inTransaction", ")", "{", "conn", ".", "setAutoCommit", "(", "false", ")", ";", "connStats", ".", "inTransaction", "=", "true", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Starts a transaction. Has no effect if already in a transaction. @param conn @throws SQLException @since 0.4.0
[ "Starts", "a", "transaction", ".", "Has", "no", "effect", "if", "already", "in", "a", "transaction", "." ]
8d059ddf641a1629aa53851f9d1b41abf175a180
https://github.com/DDTH/ddth-dao/blob/8d059ddf641a1629aa53851f9d1b41abf175a180/ddth-dao-core/src/main/java/com/github/ddth/dao/utils/DbcHelper.java#L160-L172
148,067
DDTH/ddth-dao
ddth-dao-core/src/main/java/com/github/ddth/dao/utils/DbcHelper.java
DbcHelper.detectDbVendor
public static DatabaseVendor detectDbVendor(Connection conn) throws SQLException { DatabaseMetaData dmd = conn.getMetaData(); String dpn = dmd.getDatabaseProductName(); if (StringUtils.equalsAnyIgnoreCase("MySQL", dpn)) { return DatabaseVendor.MYSQL; } if (StringUtils.equalsAnyIgnoreCase("PostgreSQL", dpn)) { return DatabaseVendor.POSTGRESQL; } if (StringUtils.equalsAnyIgnoreCase("Microsoft SQL Server", dpn)) { return DatabaseVendor.MSSQL; } return DatabaseVendor.UNKNOWN; }
java
public static DatabaseVendor detectDbVendor(Connection conn) throws SQLException { DatabaseMetaData dmd = conn.getMetaData(); String dpn = dmd.getDatabaseProductName(); if (StringUtils.equalsAnyIgnoreCase("MySQL", dpn)) { return DatabaseVendor.MYSQL; } if (StringUtils.equalsAnyIgnoreCase("PostgreSQL", dpn)) { return DatabaseVendor.POSTGRESQL; } if (StringUtils.equalsAnyIgnoreCase("Microsoft SQL Server", dpn)) { return DatabaseVendor.MSSQL; } return DatabaseVendor.UNKNOWN; }
[ "public", "static", "DatabaseVendor", "detectDbVendor", "(", "Connection", "conn", ")", "throws", "SQLException", "{", "DatabaseMetaData", "dmd", "=", "conn", ".", "getMetaData", "(", ")", ";", "String", "dpn", "=", "dmd", ".", "getDatabaseProductName", "(", ")", ";", "if", "(", "StringUtils", ".", "equalsAnyIgnoreCase", "(", "\"MySQL\"", ",", "dpn", ")", ")", "{", "return", "DatabaseVendor", ".", "MYSQL", ";", "}", "if", "(", "StringUtils", ".", "equalsAnyIgnoreCase", "(", "\"PostgreSQL\"", ",", "dpn", ")", ")", "{", "return", "DatabaseVendor", ".", "POSTGRESQL", ";", "}", "if", "(", "StringUtils", ".", "equalsAnyIgnoreCase", "(", "\"Microsoft SQL Server\"", ",", "dpn", ")", ")", "{", "return", "DatabaseVendor", ".", "MSSQL", ";", "}", "return", "DatabaseVendor", ".", "UNKNOWN", ";", "}" ]
Detect database vender info. @param conn @return @throws SQLException
[ "Detect", "database", "vender", "info", "." ]
8d059ddf641a1629aa53851f9d1b41abf175a180
https://github.com/DDTH/ddth-dao/blob/8d059ddf641a1629aa53851f9d1b41abf175a180/ddth-dao-core/src/main/java/com/github/ddth/dao/utils/DbcHelper.java#L298-L311
148,068
sematext/ActionGenerator
ag-player-solr/src/main/java/com/sematext/ag/solr/util/XMLUtils.java
XMLUtils.getSolrAddDocument
public static String getSolrAddDocument(Map<String, String> values) { StringBuilder builder = new StringBuilder(); builder.append("<add><doc>"); for (Map.Entry<String, String> pair : values.entrySet()) { XMLUtils.addSolrField(builder, pair); } builder.append("</doc></add>"); return builder.toString(); }
java
public static String getSolrAddDocument(Map<String, String> values) { StringBuilder builder = new StringBuilder(); builder.append("<add><doc>"); for (Map.Entry<String, String> pair : values.entrySet()) { XMLUtils.addSolrField(builder, pair); } builder.append("</doc></add>"); return builder.toString(); }
[ "public", "static", "String", "getSolrAddDocument", "(", "Map", "<", "String", ",", "String", ">", "values", ")", "{", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "builder", ".", "append", "(", "\"<add><doc>\"", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "String", ">", "pair", ":", "values", ".", "entrySet", "(", ")", ")", "{", "XMLUtils", ".", "addSolrField", "(", "builder", ",", "pair", ")", ";", "}", "builder", ".", "append", "(", "\"</doc></add>\"", ")", ";", "return", "builder", ".", "toString", "(", ")", ";", "}" ]
Returns Apache Solr add command. @param values values to include @return XML as String
[ "Returns", "Apache", "Solr", "add", "command", "." ]
10f4a3e680f20d7d151f5d40e6758aeb072d474f
https://github.com/sematext/ActionGenerator/blob/10f4a3e680f20d7d151f5d40e6758aeb072d474f/ag-player-solr/src/main/java/com/sematext/ag/solr/util/XMLUtils.java#L37-L45
148,069
Lucas3oo/jicunit
src/jicunit-framework/src/main/java/org/jicunit/framework/internal/ExceptionUtil.java
ExceptionUtil.filterdStackTrace
public static String filterdStackTrace(String stackTrace) { boolean skip = false; StringBuilder filteredStackTrace = new StringBuilder(); // read line by line until the reflective call to the test method is found String[] segments = stackTrace.split("\n"); for (int i = 0; i < segments.length; i++) { String segment = segments[i]; if (skip) { // check if Cause by appears then stop skip if (segment.startsWith("Caused by:")) { skip = false; filteredStackTrace.append(segment).append("\n"); } } else { if (segment.startsWith("\tat sun.reflect.NativeMethodAccessorImpl")) { // skip all lines until Caused by appears skip = true; } else if (segment.startsWith("\tat org.junit.") || segment.startsWith("\tat junit.framework.")) { // skip } else { filteredStackTrace.append(segment).append("\n"); } } } // remove last newline filteredStackTrace.delete(filteredStackTrace.length()-1, filteredStackTrace.length()); return filteredStackTrace.toString(); }
java
public static String filterdStackTrace(String stackTrace) { boolean skip = false; StringBuilder filteredStackTrace = new StringBuilder(); // read line by line until the reflective call to the test method is found String[] segments = stackTrace.split("\n"); for (int i = 0; i < segments.length; i++) { String segment = segments[i]; if (skip) { // check if Cause by appears then stop skip if (segment.startsWith("Caused by:")) { skip = false; filteredStackTrace.append(segment).append("\n"); } } else { if (segment.startsWith("\tat sun.reflect.NativeMethodAccessorImpl")) { // skip all lines until Caused by appears skip = true; } else if (segment.startsWith("\tat org.junit.") || segment.startsWith("\tat junit.framework.")) { // skip } else { filteredStackTrace.append(segment).append("\n"); } } } // remove last newline filteredStackTrace.delete(filteredStackTrace.length()-1, filteredStackTrace.length()); return filteredStackTrace.toString(); }
[ "public", "static", "String", "filterdStackTrace", "(", "String", "stackTrace", ")", "{", "boolean", "skip", "=", "false", ";", "StringBuilder", "filteredStackTrace", "=", "new", "StringBuilder", "(", ")", ";", "// read line by line until the reflective call to the test method is found", "String", "[", "]", "segments", "=", "stackTrace", ".", "split", "(", "\"\\n\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "segments", ".", "length", ";", "i", "++", ")", "{", "String", "segment", "=", "segments", "[", "i", "]", ";", "if", "(", "skip", ")", "{", "// check if Cause by appears then stop skip", "if", "(", "segment", ".", "startsWith", "(", "\"Caused by:\"", ")", ")", "{", "skip", "=", "false", ";", "filteredStackTrace", ".", "append", "(", "segment", ")", ".", "append", "(", "\"\\n\"", ")", ";", "}", "}", "else", "{", "if", "(", "segment", ".", "startsWith", "(", "\"\\tat sun.reflect.NativeMethodAccessorImpl\"", ")", ")", "{", "// skip all lines until Caused by appears", "skip", "=", "true", ";", "}", "else", "if", "(", "segment", ".", "startsWith", "(", "\"\\tat org.junit.\"", ")", "||", "segment", ".", "startsWith", "(", "\"\\tat junit.framework.\"", ")", ")", "{", "// skip", "}", "else", "{", "filteredStackTrace", ".", "append", "(", "segment", ")", ".", "append", "(", "\"\\n\"", ")", ";", "}", "}", "}", "// remove last newline", "filteredStackTrace", ".", "delete", "(", "filteredStackTrace", ".", "length", "(", ")", "-", "1", ",", "filteredStackTrace", ".", "length", "(", ")", ")", ";", "return", "filteredStackTrace", ".", "toString", "(", ")", ";", "}" ]
Removes all entries that has to do with the internal way of running the test method. @param stackTrace @return filtered stackTrace
[ "Removes", "all", "entries", "that", "has", "to", "do", "with", "the", "internal", "way", "of", "running", "the", "test", "method", "." ]
1ed41891ccf8e5c6068c6b544d214280bb93945b
https://github.com/Lucas3oo/jicunit/blob/1ed41891ccf8e5c6068c6b544d214280bb93945b/src/jicunit-framework/src/main/java/org/jicunit/framework/internal/ExceptionUtil.java#L69-L100
148,070
DDTH/ddth-dao
ddth-dao-core/src/main/java/com/github/ddth/dao/BaseBo.java
BaseBo.cloneData
@SuppressWarnings("unchecked") protected static <T> Map<String, T> cloneData(Map<String, T> data) { return SerializationUtils.fromByteArray(SerializationUtils.toByteArray(data), Map.class); }
java
@SuppressWarnings("unchecked") protected static <T> Map<String, T> cloneData(Map<String, T> data) { return SerializationUtils.fromByteArray(SerializationUtils.toByteArray(data), Map.class); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "protected", "static", "<", "T", ">", "Map", "<", "String", ",", "T", ">", "cloneData", "(", "Map", "<", "String", ",", "T", ">", "data", ")", "{", "return", "SerializationUtils", ".", "fromByteArray", "(", "SerializationUtils", ".", "toByteArray", "(", "data", ")", ",", "Map", ".", "class", ")", ";", "}" ]
Deep-clone data. @param data @return @since 0.10.0
[ "Deep", "-", "clone", "data", "." ]
8d059ddf641a1629aa53851f9d1b41abf175a180
https://github.com/DDTH/ddth-dao/blob/8d059ddf641a1629aa53851f9d1b41abf175a180/ddth-dao-core/src/main/java/com/github/ddth/dao/BaseBo.java#L44-L47
148,071
DDTH/ddth-dao
ddth-dao-core/src/main/java/com/github/ddth/dao/BaseBo.java
BaseBo.getAttributes
public Map<String, Object> getAttributes() { if (attributes == null) { return null; } Lock lock = lockForRead(); try { return cloneData(attributes); } finally { lock.unlock(); } }
java
public Map<String, Object> getAttributes() { if (attributes == null) { return null; } Lock lock = lockForRead(); try { return cloneData(attributes); } finally { lock.unlock(); } }
[ "public", "Map", "<", "String", ",", "Object", ">", "getAttributes", "(", ")", "{", "if", "(", "attributes", "==", "null", ")", "{", "return", "null", ";", "}", "Lock", "lock", "=", "lockForRead", "(", ")", ";", "try", "{", "return", "cloneData", "(", "attributes", ")", ";", "}", "finally", "{", "lock", ".", "unlock", "(", ")", ";", "}", "}" ]
Get all BO's attributes as a map. @return @since 0.8.2
[ "Get", "all", "BO", "s", "attributes", "as", "a", "map", "." ]
8d059ddf641a1629aa53851f9d1b41abf175a180
https://github.com/DDTH/ddth-dao/blob/8d059ddf641a1629aa53851f9d1b41abf175a180/ddth-dao-core/src/main/java/com/github/ddth/dao/BaseBo.java#L136-L146
148,072
DDTH/ddth-dao
ddth-dao-core/src/main/java/com/github/ddth/dao/BaseBo.java
BaseBo.getAttributesAsJsonString
public String getAttributesAsJsonString() { if (attributes == null) { return "null"; } Lock lock = lockForRead(); try { return SerializationUtils.toJsonString(attributes); } finally { lock.unlock(); } }
java
public String getAttributesAsJsonString() { if (attributes == null) { return "null"; } Lock lock = lockForRead(); try { return SerializationUtils.toJsonString(attributes); } finally { lock.unlock(); } }
[ "public", "String", "getAttributesAsJsonString", "(", ")", "{", "if", "(", "attributes", "==", "null", ")", "{", "return", "\"null\"", ";", "}", "Lock", "lock", "=", "lockForRead", "(", ")", ";", "try", "{", "return", "SerializationUtils", ".", "toJsonString", "(", "attributes", ")", ";", "}", "finally", "{", "lock", ".", "unlock", "(", ")", ";", "}", "}" ]
Get all BO's attributes as a JSON-string. @return @since 0.10.0
[ "Get", "all", "BO", "s", "attributes", "as", "a", "JSON", "-", "string", "." ]
8d059ddf641a1629aa53851f9d1b41abf175a180
https://github.com/DDTH/ddth-dao/blob/8d059ddf641a1629aa53851f9d1b41abf175a180/ddth-dao-core/src/main/java/com/github/ddth/dao/BaseBo.java#L209-L219
148,073
DDTH/ddth-dao
ddth-dao-core/src/main/java/com/github/ddth/dao/BaseBo.java
BaseBo.removeAttribute
protected BaseBo removeAttribute(String attrName, boolean triggerChange) { Lock lock = lockForWrite(); try { attributes.remove(attrName); if (triggerChange) { triggerChange(attrName); } markDirty(); return this; } finally { lock.unlock(); } }
java
protected BaseBo removeAttribute(String attrName, boolean triggerChange) { Lock lock = lockForWrite(); try { attributes.remove(attrName); if (triggerChange) { triggerChange(attrName); } markDirty(); return this; } finally { lock.unlock(); } }
[ "protected", "BaseBo", "removeAttribute", "(", "String", "attrName", ",", "boolean", "triggerChange", ")", "{", "Lock", "lock", "=", "lockForWrite", "(", ")", ";", "try", "{", "attributes", ".", "remove", "(", "attrName", ")", ";", "if", "(", "triggerChange", ")", "{", "triggerChange", "(", "attrName", ")", ";", "}", "markDirty", "(", ")", ";", "return", "this", ";", "}", "finally", "{", "lock", ".", "unlock", "(", ")", ";", "}", "}" ]
Remove a BO's attribute. @param attrName @param triggerChange if set to {@code true} {@link #triggerChange(String)} will be called @return @since 0.7.1
[ "Remove", "a", "BO", "s", "attribute", "." ]
8d059ddf641a1629aa53851f9d1b41abf175a180
https://github.com/DDTH/ddth-dao/blob/8d059ddf641a1629aa53851f9d1b41abf175a180/ddth-dao-core/src/main/java/com/github/ddth/dao/BaseBo.java#L360-L372
148,074
DDTH/ddth-dao
ddth-dao-core/src/main/java/com/github/ddth/dao/BaseBo.java
BaseBo.tryLockForRead
protected Lock tryLockForRead(long time, TimeUnit unit) throws InterruptedException { if (time < 0 || unit == null) { return tryLockForRead(); } Lock lock = readLock(); return lock.tryLock(time, unit) ? lock : null; }
java
protected Lock tryLockForRead(long time, TimeUnit unit) throws InterruptedException { if (time < 0 || unit == null) { return tryLockForRead(); } Lock lock = readLock(); return lock.tryLock(time, unit) ? lock : null; }
[ "protected", "Lock", "tryLockForRead", "(", "long", "time", ",", "TimeUnit", "unit", ")", "throws", "InterruptedException", "{", "if", "(", "time", "<", "0", "||", "unit", "==", "null", ")", "{", "return", "tryLockForRead", "(", ")", ";", "}", "Lock", "lock", "=", "readLock", "(", ")", ";", "return", "lock", ".", "tryLock", "(", "time", ",", "unit", ")", "?", "lock", ":", "null", ";", "}" ]
Try to lock the BO for read. @param time @param unit @return the "read"-lock in "lock" state if successful, {@code null} otherwise @throws InterruptedException @since 0.10.0
[ "Try", "to", "lock", "the", "BO", "for", "read", "." ]
8d059ddf641a1629aa53851f9d1b41abf175a180
https://github.com/DDTH/ddth-dao/blob/8d059ddf641a1629aa53851f9d1b41abf175a180/ddth-dao-core/src/main/java/com/github/ddth/dao/BaseBo.java#L487-L493
148,075
DDTH/ddth-dao
ddth-dao-core/src/main/java/com/github/ddth/dao/BaseBo.java
BaseBo.tryLockForWrite
protected Lock tryLockForWrite(long time, TimeUnit unit) throws InterruptedException { if (time < 0 || unit == null) { return tryLockForWrite(); } Lock lock = writeLock(); return lock.tryLock(time, unit) ? lock : null; }
java
protected Lock tryLockForWrite(long time, TimeUnit unit) throws InterruptedException { if (time < 0 || unit == null) { return tryLockForWrite(); } Lock lock = writeLock(); return lock.tryLock(time, unit) ? lock : null; }
[ "protected", "Lock", "tryLockForWrite", "(", "long", "time", ",", "TimeUnit", "unit", ")", "throws", "InterruptedException", "{", "if", "(", "time", "<", "0", "||", "unit", "==", "null", ")", "{", "return", "tryLockForWrite", "(", ")", ";", "}", "Lock", "lock", "=", "writeLock", "(", ")", ";", "return", "lock", ".", "tryLock", "(", "time", ",", "unit", ")", "?", "lock", ":", "null", ";", "}" ]
Try to lock the BO for write. @param time @param unit @return the "write"-lock in "lock" state if successful, {@code null} otherwise @throws InterruptedException @since 0.10.0
[ "Try", "to", "lock", "the", "BO", "for", "write", "." ]
8d059ddf641a1629aa53851f9d1b41abf175a180
https://github.com/DDTH/ddth-dao/blob/8d059ddf641a1629aa53851f9d1b41abf175a180/ddth-dao-core/src/main/java/com/github/ddth/dao/BaseBo.java#L536-L542
148,076
DDTH/ddth-dao
ddth-dao-core/src/main/java/com/github/ddth/dao/BaseBo.java
BaseBo.toMap
public Map<String, Object> toMap() { Lock lock = lockForWrite(); try { Map<String, Object> data = new HashMap<>(); data.put(SER_FIELD_DIRTY, dirty); data.put(SER_FIELD_ATTRS, attributes != null ? cloneData(attributes) : new HashMap<>()); return data; } finally { lock.unlock(); } }
java
public Map<String, Object> toMap() { Lock lock = lockForWrite(); try { Map<String, Object> data = new HashMap<>(); data.put(SER_FIELD_DIRTY, dirty); data.put(SER_FIELD_ATTRS, attributes != null ? cloneData(attributes) : new HashMap<>()); return data; } finally { lock.unlock(); } }
[ "public", "Map", "<", "String", ",", "Object", ">", "toMap", "(", ")", "{", "Lock", "lock", "=", "lockForWrite", "(", ")", ";", "try", "{", "Map", "<", "String", ",", "Object", ">", "data", "=", "new", "HashMap", "<>", "(", ")", ";", "data", ".", "put", "(", "SER_FIELD_DIRTY", ",", "dirty", ")", ";", "data", ".", "put", "(", "SER_FIELD_ATTRS", ",", "attributes", "!=", "null", "?", "cloneData", "(", "attributes", ")", ":", "new", "HashMap", "<>", "(", ")", ")", ";", "return", "data", ";", "}", "finally", "{", "lock", ".", "unlock", "(", ")", ";", "}", "}" ]
Serialize the BO to a Java map. @return BO's data as a Java map, can be used to de-serialize the BO via {@link #fromMap(Map)}
[ "Serialize", "the", "BO", "to", "a", "Java", "map", "." ]
8d059ddf641a1629aa53851f9d1b41abf175a180
https://github.com/DDTH/ddth-dao/blob/8d059ddf641a1629aa53851f9d1b41abf175a180/ddth-dao-core/src/main/java/com/github/ddth/dao/BaseBo.java#L592-L602
148,077
DDTH/ddth-dao
ddth-dao-core/src/main/java/com/github/ddth/dao/BaseBo.java
BaseBo.toJson
public String toJson() { Map<String, Object> data = toMap(); return SerializationUtils.toJsonString(data); }
java
public String toJson() { Map<String, Object> data = toMap(); return SerializationUtils.toJsonString(data); }
[ "public", "String", "toJson", "(", ")", "{", "Map", "<", "String", ",", "Object", ">", "data", "=", "toMap", "(", ")", ";", "return", "SerializationUtils", ".", "toJsonString", "(", "data", ")", ";", "}" ]
Serialize the BO to JSON string. @return BO's data as a JSON string, can be used to de-serialize the BO via {@link #fromJson(String)}
[ "Serialize", "the", "BO", "to", "JSON", "string", "." ]
8d059ddf641a1629aa53851f9d1b41abf175a180
https://github.com/DDTH/ddth-dao/blob/8d059ddf641a1629aa53851f9d1b41abf175a180/ddth-dao-core/src/main/java/com/github/ddth/dao/BaseBo.java#L630-L633
148,078
lisicnu/droidUtil
src/main/java/com/github/lisicnu/libDroid/util/LightUtils.java
LightUtils.acquireLock
public static boolean acquireLock(Context context) { if (wl != null && wl.isHeld()) { return true; } powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); wl = powerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, TAG); if (wl == null) { return false; } wl.acquire(); return wl.isHeld(); }
java
public static boolean acquireLock(Context context) { if (wl != null && wl.isHeld()) { return true; } powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); wl = powerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, TAG); if (wl == null) { return false; } wl.acquire(); return wl.isHeld(); }
[ "public", "static", "boolean", "acquireLock", "(", "Context", "context", ")", "{", "if", "(", "wl", "!=", "null", "&&", "wl", ".", "isHeld", "(", ")", ")", "{", "return", "true", ";", "}", "powerManager", "=", "(", "PowerManager", ")", "context", ".", "getSystemService", "(", "Context", ".", "POWER_SERVICE", ")", ";", "wl", "=", "powerManager", ".", "newWakeLock", "(", "PowerManager", ".", "SCREEN_BRIGHT_WAKE_LOCK", ",", "TAG", ")", ";", "if", "(", "wl", "==", "null", ")", "{", "return", "false", ";", "}", "wl", ".", "acquire", "(", ")", ";", "return", "wl", ".", "isHeld", "(", ")", ";", "}" ]
if the keep light has been opened, will default exit. @param context
[ "if", "the", "keep", "light", "has", "been", "opened", "will", "default", "exit", "." ]
e4d6cf3e3f60e5efb5a75672607ded94d1725519
https://github.com/lisicnu/droidUtil/blob/e4d6cf3e3f60e5efb5a75672607ded94d1725519/src/main/java/com/github/lisicnu/libDroid/util/LightUtils.java#L25-L40
148,079
sematext/ActionGenerator
ag-player/src/main/java/com/sematext/ag/PlayerConfig.java
PlayerConfig.get
public String get(String key) { if (properties.get(key) != null) { return properties.get(key); } else { return getConfigurationValue(key); } }
java
public String get(String key) { if (properties.get(key) != null) { return properties.get(key); } else { return getConfigurationValue(key); } }
[ "public", "String", "get", "(", "String", "key", ")", "{", "if", "(", "properties", ".", "get", "(", "key", ")", "!=", "null", ")", "{", "return", "properties", ".", "get", "(", "key", ")", ";", "}", "else", "{", "return", "getConfigurationValue", "(", "key", ")", ";", "}", "}" ]
Return property value for a given name. @param key property name @return property value
[ "Return", "property", "value", "for", "a", "given", "name", "." ]
10f4a3e680f20d7d151f5d40e6758aeb072d474f
https://github.com/sematext/ActionGenerator/blob/10f4a3e680f20d7d151f5d40e6758aeb072d474f/ag-player/src/main/java/com/sematext/ag/PlayerConfig.java#L104-L110
148,080
sematext/ActionGenerator
ag-player/src/main/java/com/sematext/ag/PlayerConfig.java
PlayerConfig.checkRequired
public void checkRequired(String key) throws InitializationFailedException { if (properties.get(key) == null && getConfigurationValue(key) == null) { throw new InitializationFailedException("Missing required property in config: " + key); } }
java
public void checkRequired(String key) throws InitializationFailedException { if (properties.get(key) == null && getConfigurationValue(key) == null) { throw new InitializationFailedException("Missing required property in config: " + key); } }
[ "public", "void", "checkRequired", "(", "String", "key", ")", "throws", "InitializationFailedException", "{", "if", "(", "properties", ".", "get", "(", "key", ")", "==", "null", "&&", "getConfigurationValue", "(", "key", ")", "==", "null", ")", "{", "throw", "new", "InitializationFailedException", "(", "\"Missing required property in config: \"", "+", "key", ")", ";", "}", "}" ]
Checks if a property value for a given key exists. @param key property name @throws InitializationFailedException throw when a given property is not defined
[ "Checks", "if", "a", "property", "value", "for", "a", "given", "key", "exists", "." ]
10f4a3e680f20d7d151f5d40e6758aeb072d474f
https://github.com/sematext/ActionGenerator/blob/10f4a3e680f20d7d151f5d40e6758aeb072d474f/ag-player/src/main/java/com/sematext/ag/PlayerConfig.java#L120-L124
148,081
fuinorg/objects4j
src/main/java/org/fuin/objects4j/common/ConstraintViolationException.java
ConstraintViolationException.getConstraintViolations
public final Set<ConstraintViolation<Object>> getConstraintViolations() { if (constraintViolations == null) { return null; } return Collections.unmodifiableSet(constraintViolations); }
java
public final Set<ConstraintViolation<Object>> getConstraintViolations() { if (constraintViolations == null) { return null; } return Collections.unmodifiableSet(constraintViolations); }
[ "public", "final", "Set", "<", "ConstraintViolation", "<", "Object", ">", ">", "getConstraintViolations", "(", ")", "{", "if", "(", "constraintViolations", "==", "null", ")", "{", "return", "null", ";", "}", "return", "Collections", ".", "unmodifiableSet", "(", "constraintViolations", ")", ";", "}" ]
Returns the constraint violations. @return Immutable set of constraint violations or <code>null</code> if only a message is available.
[ "Returns", "the", "constraint", "violations", "." ]
e7f278b5bae073ebb6a76053650571c718f36246
https://github.com/fuinorg/objects4j/blob/e7f278b5bae073ebb6a76053650571c718f36246/src/main/java/org/fuin/objects4j/common/ConstraintViolationException.java#L63-L68
148,082
projectodd/wunderboss-release
messaging-hornetq/src/main/java/org/projectodd/wunderboss/messaging/hornetq/HQMessaging.java
HQMessaging.invokeDestroy
private void invokeDestroy(String method, String name) { Class clazz = this.jmsServerManager().getClass(); Method destroy = null; for (Method each: clazz.getMethods()) { if (method.equals(each.getName())) { destroy = each; break; } } if (destroy == null) { throw new IllegalStateException(String.format("Class %s has no %s method", clazz, method)); } try { if (destroy.getParameterTypes().length == 1) { destroy.invoke(this.jmsServerManager(), name); } else { destroy.invoke(this.jmsServerManager(), name, true); } } catch (IllegalAccessException | InvocationTargetException e) { throw new RuntimeException("Failed to destroy destination " + name, e); } }
java
private void invokeDestroy(String method, String name) { Class clazz = this.jmsServerManager().getClass(); Method destroy = null; for (Method each: clazz.getMethods()) { if (method.equals(each.getName())) { destroy = each; break; } } if (destroy == null) { throw new IllegalStateException(String.format("Class %s has no %s method", clazz, method)); } try { if (destroy.getParameterTypes().length == 1) { destroy.invoke(this.jmsServerManager(), name); } else { destroy.invoke(this.jmsServerManager(), name, true); } } catch (IllegalAccessException | InvocationTargetException e) { throw new RuntimeException("Failed to destroy destination " + name, e); } }
[ "private", "void", "invokeDestroy", "(", "String", "method", ",", "String", "name", ")", "{", "Class", "clazz", "=", "this", ".", "jmsServerManager", "(", ")", ".", "getClass", "(", ")", ";", "Method", "destroy", "=", "null", ";", "for", "(", "Method", "each", ":", "clazz", ".", "getMethods", "(", ")", ")", "{", "if", "(", "method", ".", "equals", "(", "each", ".", "getName", "(", ")", ")", ")", "{", "destroy", "=", "each", ";", "break", ";", "}", "}", "if", "(", "destroy", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "String", ".", "format", "(", "\"Class %s has no %s method\"", ",", "clazz", ",", "method", ")", ")", ";", "}", "try", "{", "if", "(", "destroy", ".", "getParameterTypes", "(", ")", ".", "length", "==", "1", ")", "{", "destroy", ".", "invoke", "(", "this", ".", "jmsServerManager", "(", ")", ",", "name", ")", ";", "}", "else", "{", "destroy", ".", "invoke", "(", "this", ".", "jmsServerManager", "(", ")", ",", "name", ",", "true", ")", ";", "}", "}", "catch", "(", "IllegalAccessException", "|", "InvocationTargetException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Failed to destroy destination \"", "+", "name", ",", "e", ")", ";", "}", "}" ]
HornetQ 2.3 has single-arity destroy functions, 2.4 has double-arity
[ "HornetQ", "2", ".", "3", "has", "single", "-", "arity", "destroy", "functions", "2", ".", "4", "has", "double", "-", "arity" ]
f67c68e80c5798169e3a9b2015e278239dbf005d
https://github.com/projectodd/wunderboss-release/blob/f67c68e80c5798169e3a9b2015e278239dbf005d/messaging-hornetq/src/main/java/org/projectodd/wunderboss/messaging/hornetq/HQMessaging.java#L190-L213
148,083
lisicnu/droidUtil
src/main/java/com/github/lisicnu/libDroid/util/ContextUtils.java
ContextUtils.CopyAssets
public static int CopyAssets(Context context, String srcFile, String dstFile) { int result = COPY_SUCCESS; InputStream in = null; OutputStream out = null; try { File fi; if (dstFile.equals(FileUtils.getFileName(dstFile))) { fi = new File(context.getFilesDir(), dstFile); } else { fi = new File(dstFile); } in = context.getAssets().open(srcFile, AssetManager.ACCESS_STREAMING); if (fi.exists() && in.available() <= fi.length()) { result = COPY_DST_EXIST; } else { out = new FileOutputStream(fi); byte[] buffer = new byte[10240]; int read; while ((read = in.read(buffer)) != -1) { out.write(buffer, 0, read); } buffer = null; } } catch (IOException e) { Log.e(TAG, "", e); result = COPY_ERROR; } finally { if (in != null) try { in.close(); } catch (IOException e) { e.printStackTrace(); } in = null; if (out != null) { try { out.flush(); out.close(); } catch (IOException e) { e.printStackTrace(); } } out = null; } return result; }
java
public static int CopyAssets(Context context, String srcFile, String dstFile) { int result = COPY_SUCCESS; InputStream in = null; OutputStream out = null; try { File fi; if (dstFile.equals(FileUtils.getFileName(dstFile))) { fi = new File(context.getFilesDir(), dstFile); } else { fi = new File(dstFile); } in = context.getAssets().open(srcFile, AssetManager.ACCESS_STREAMING); if (fi.exists() && in.available() <= fi.length()) { result = COPY_DST_EXIST; } else { out = new FileOutputStream(fi); byte[] buffer = new byte[10240]; int read; while ((read = in.read(buffer)) != -1) { out.write(buffer, 0, read); } buffer = null; } } catch (IOException e) { Log.e(TAG, "", e); result = COPY_ERROR; } finally { if (in != null) try { in.close(); } catch (IOException e) { e.printStackTrace(); } in = null; if (out != null) { try { out.flush(); out.close(); } catch (IOException e) { e.printStackTrace(); } } out = null; } return result; }
[ "public", "static", "int", "CopyAssets", "(", "Context", "context", ",", "String", "srcFile", ",", "String", "dstFile", ")", "{", "int", "result", "=", "COPY_SUCCESS", ";", "InputStream", "in", "=", "null", ";", "OutputStream", "out", "=", "null", ";", "try", "{", "File", "fi", ";", "if", "(", "dstFile", ".", "equals", "(", "FileUtils", ".", "getFileName", "(", "dstFile", ")", ")", ")", "{", "fi", "=", "new", "File", "(", "context", ".", "getFilesDir", "(", ")", ",", "dstFile", ")", ";", "}", "else", "{", "fi", "=", "new", "File", "(", "dstFile", ")", ";", "}", "in", "=", "context", ".", "getAssets", "(", ")", ".", "open", "(", "srcFile", ",", "AssetManager", ".", "ACCESS_STREAMING", ")", ";", "if", "(", "fi", ".", "exists", "(", ")", "&&", "in", ".", "available", "(", ")", "<=", "fi", ".", "length", "(", ")", ")", "{", "result", "=", "COPY_DST_EXIST", ";", "}", "else", "{", "out", "=", "new", "FileOutputStream", "(", "fi", ")", ";", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "10240", "]", ";", "int", "read", ";", "while", "(", "(", "read", "=", "in", ".", "read", "(", "buffer", ")", ")", "!=", "-", "1", ")", "{", "out", ".", "write", "(", "buffer", ",", "0", ",", "read", ")", ";", "}", "buffer", "=", "null", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "Log", ".", "e", "(", "TAG", ",", "\"\"", ",", "e", ")", ";", "result", "=", "COPY_ERROR", ";", "}", "finally", "{", "if", "(", "in", "!=", "null", ")", "try", "{", "in", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "in", "=", "null", ";", "if", "(", "out", "!=", "null", ")", "{", "try", "{", "out", ".", "flush", "(", ")", ";", "out", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "out", "=", "null", ";", "}", "return", "result", ";", "}" ]
copy assets file to destinations. @param context @param srcFile source file in assets. @param dstFile destination files, full path with folder. if folder is empty, means copy to context's files folder. @return {@link #COPY_SUCCESS} means success.{@link #COPY_DST_EXIST}, {@link #COPY_ERROR}
[ "copy", "assets", "file", "to", "destinations", "." ]
e4d6cf3e3f60e5efb5a75672607ded94d1725519
https://github.com/lisicnu/droidUtil/blob/e4d6cf3e3f60e5efb5a75672607ded94d1725519/src/main/java/com/github/lisicnu/libDroid/util/ContextUtils.java#L40-L92
148,084
lisicnu/droidUtil
src/main/java/com/github/lisicnu/libDroid/util/ContextUtils.java
ContextUtils.isLauncherActivity
public static boolean isLauncherActivity(Intent intent) { if (intent == null) return false; if (StringUtils.isNullOrEmpty(intent.getAction())) { return false; } if (intent.getCategories() == null) return false; return Intent.ACTION_MAIN.equals(intent.getAction()) && intent.getCategories().contains(Intent.CATEGORY_LAUNCHER); }
java
public static boolean isLauncherActivity(Intent intent) { if (intent == null) return false; if (StringUtils.isNullOrEmpty(intent.getAction())) { return false; } if (intent.getCategories() == null) return false; return Intent.ACTION_MAIN.equals(intent.getAction()) && intent.getCategories().contains(Intent.CATEGORY_LAUNCHER); }
[ "public", "static", "boolean", "isLauncherActivity", "(", "Intent", "intent", ")", "{", "if", "(", "intent", "==", "null", ")", "return", "false", ";", "if", "(", "StringUtils", ".", "isNullOrEmpty", "(", "intent", ".", "getAction", "(", ")", ")", ")", "{", "return", "false", ";", "}", "if", "(", "intent", ".", "getCategories", "(", ")", "==", "null", ")", "return", "false", ";", "return", "Intent", ".", "ACTION_MAIN", ".", "equals", "(", "intent", ".", "getAction", "(", ")", ")", "&&", "intent", ".", "getCategories", "(", ")", ".", "contains", "(", "Intent", ".", "CATEGORY_LAUNCHER", ")", ";", "}" ]
check whether is launcher or not. @param intent @return
[ "check", "whether", "is", "launcher", "or", "not", "." ]
e4d6cf3e3f60e5efb5a75672607ded94d1725519
https://github.com/lisicnu/droidUtil/blob/e4d6cf3e3f60e5efb5a75672607ded94d1725519/src/main/java/com/github/lisicnu/libDroid/util/ContextUtils.java#L100-L113
148,085
fuinorg/objects4j
src/main/java/org/fuin/objects4j/vo/AbstractUuidValueObject.java
AbstractUuidValueObject.isValid
public static boolean isValid(final String value) { if (value == null) { return true; } final String uuidPattern = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-" + "[0-9a-f]{4}-[0-9a-f]{12}$"; return Pattern.matches(uuidPattern, value); }
java
public static boolean isValid(final String value) { if (value == null) { return true; } final String uuidPattern = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-" + "[0-9a-f]{4}-[0-9a-f]{12}$"; return Pattern.matches(uuidPattern, value); }
[ "public", "static", "boolean", "isValid", "(", "final", "String", "value", ")", "{", "if", "(", "value", "==", "null", ")", "{", "return", "true", ";", "}", "final", "String", "uuidPattern", "=", "\"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-\"", "+", "\"[0-9a-f]{4}-[0-9a-f]{12}$\"", ";", "return", "Pattern", ".", "matches", "(", "uuidPattern", ",", "value", ")", ";", "}" ]
Verifies that a given string is a valid UUID. @param value Value to check. A <code>null</code> value returns <code>true</code>. @return TRUE if it's a valid key, else FALSE.
[ "Verifies", "that", "a", "given", "string", "is", "a", "valid", "UUID", "." ]
e7f278b5bae073ebb6a76053650571c718f36246
https://github.com/fuinorg/objects4j/blob/e7f278b5bae073ebb6a76053650571c718f36246/src/main/java/org/fuin/objects4j/vo/AbstractUuidValueObject.java#L70-L76
148,086
acromusashi/acromusashi-stream
src/main/java/acromusashi/stream/spout/AmBaseSpout.java
AmBaseSpout.extractSpecificConfig
protected Object extractSpecificConfig(String key) { if (this.specificConfig == null) { return null; } Object result = this.specificConfig.get(key); return result; }
java
protected Object extractSpecificConfig(String key) { if (this.specificConfig == null) { return null; } Object result = this.specificConfig.get(key); return result; }
[ "protected", "Object", "extractSpecificConfig", "(", "String", "key", ")", "{", "if", "(", "this", ".", "specificConfig", "==", "null", ")", "{", "return", "null", ";", "}", "Object", "result", "=", "this", ".", "specificConfig", ".", "get", "(", "key", ")", ";", "return", "result", ";", "}" ]
Get config value from specific config. @param key Config key @return Specific Config value
[ "Get", "config", "value", "from", "specific", "config", "." ]
65b1f335d771d657c5640a2056ab5c8546eddec9
https://github.com/acromusashi/acromusashi-stream/blob/65b1f335d771d657c5640a2056ab5c8546eddec9/src/main/java/acromusashi/stream/spout/AmBaseSpout.java#L214-L223
148,087
acromusashi/acromusashi-stream
src/main/java/acromusashi/stream/spout/AmBaseSpout.java
AmBaseSpout.getSpecificConfig
protected Map<String, Object> getSpecificConfig() { if (this.specificConfig == null) { return null; } Map<String, Object> result = Collections.unmodifiableMap(this.specificConfig); return result; }
java
protected Map<String, Object> getSpecificConfig() { if (this.specificConfig == null) { return null; } Map<String, Object> result = Collections.unmodifiableMap(this.specificConfig); return result; }
[ "protected", "Map", "<", "String", ",", "Object", ">", "getSpecificConfig", "(", ")", "{", "if", "(", "this", ".", "specificConfig", "==", "null", ")", "{", "return", "null", ";", "}", "Map", "<", "String", ",", "Object", ">", "result", "=", "Collections", ".", "unmodifiableMap", "(", "this", ".", "specificConfig", ")", ";", "return", "result", ";", "}" ]
Get unmodifiable specific config. @return Unmodifiable specific config.
[ "Get", "unmodifiable", "specific", "config", "." ]
65b1f335d771d657c5640a2056ab5c8546eddec9
https://github.com/acromusashi/acromusashi-stream/blob/65b1f335d771d657c5640a2056ab5c8546eddec9/src/main/java/acromusashi/stream/spout/AmBaseSpout.java#L230-L239
148,088
jriecken/gae-java-mini-profiler
src/main/java/ca/jimr/gae/profiler/MiniProfiler.java
MiniProfiler.step
public static Step step(String stepName) { Root root = PROFILER_STEPS.get(); if (root != null) { Profile data = new Profile(root.nextId(), stepName); return new Step(root, data); } else { return new Step(null, null); } }
java
public static Step step(String stepName) { Root root = PROFILER_STEPS.get(); if (root != null) { Profile data = new Profile(root.nextId(), stepName); return new Step(root, data); } else { return new Step(null, null); } }
[ "public", "static", "Step", "step", "(", "String", "stepName", ")", "{", "Root", "root", "=", "PROFILER_STEPS", ".", "get", "(", ")", ";", "if", "(", "root", "!=", "null", ")", "{", "Profile", "data", "=", "new", "Profile", "(", "root", ".", "nextId", "(", ")", ",", "stepName", ")", ";", "return", "new", "Step", "(", "root", ",", "data", ")", ";", "}", "else", "{", "return", "new", "Step", "(", "null", ",", "null", ")", ";", "}", "}" ]
Start a profiling step. @param stepName The name of the step. @return A {@code Step} object whose {@link Step#close()} method should be called to finish the step.
[ "Start", "a", "profiling", "step", "." ]
184e3d2470104e066919960d6fbfe0cdc05921d5
https://github.com/jriecken/gae-java-mini-profiler/blob/184e3d2470104e066919960d6fbfe0cdc05921d5/src/main/java/ca/jimr/gae/profiler/MiniProfiler.java#L375-L386
148,089
projectodd/wunderboss-release
web/src/main/java/org/projectodd/wunderboss/web/async/WebsocketUtil.java
WebsocketUtil.createTextHandler
static public MessageHandler.Whole<String> createTextHandler(final MessageHandler.Whole proxy) { return new MessageHandler.Whole<String>() { public void onMessage(String msg) { proxy.onMessage(msg); }}; }
java
static public MessageHandler.Whole<String> createTextHandler(final MessageHandler.Whole proxy) { return new MessageHandler.Whole<String>() { public void onMessage(String msg) { proxy.onMessage(msg); }}; }
[ "static", "public", "MessageHandler", ".", "Whole", "<", "String", ">", "createTextHandler", "(", "final", "MessageHandler", ".", "Whole", "proxy", ")", "{", "return", "new", "MessageHandler", ".", "Whole", "<", "String", ">", "(", ")", "{", "public", "void", "onMessage", "(", "String", "msg", ")", "{", "proxy", ".", "onMessage", "(", "msg", ")", ";", "}", "}", ";", "}" ]
generics and Undertow's dependence on ParameterizedType
[ "generics", "and", "Undertow", "s", "dependence", "on", "ParameterizedType" ]
f67c68e80c5798169e3a9b2015e278239dbf005d
https://github.com/projectodd/wunderboss-release/blob/f67c68e80c5798169e3a9b2015e278239dbf005d/web/src/main/java/org/projectodd/wunderboss/web/async/WebsocketUtil.java#L25-L30
148,090
projectodd/wunderboss-release
web/src/main/java/org/projectodd/wunderboss/web/async/WebsocketUtil.java
WebsocketUtil.createBinaryHandler
static public MessageHandler.Whole<byte[]> createBinaryHandler(final MessageHandler.Whole proxy) { return new MessageHandler.Whole<byte[]>() { public void onMessage(byte[] msg) { proxy.onMessage(msg); }}; }
java
static public MessageHandler.Whole<byte[]> createBinaryHandler(final MessageHandler.Whole proxy) { return new MessageHandler.Whole<byte[]>() { public void onMessage(byte[] msg) { proxy.onMessage(msg); }}; }
[ "static", "public", "MessageHandler", ".", "Whole", "<", "byte", "[", "]", ">", "createBinaryHandler", "(", "final", "MessageHandler", ".", "Whole", "proxy", ")", "{", "return", "new", "MessageHandler", ".", "Whole", "<", "byte", "[", "]", ">", "(", ")", "{", "public", "void", "onMessage", "(", "byte", "[", "]", "msg", ")", "{", "proxy", ".", "onMessage", "(", "msg", ")", ";", "}", "}", ";", "}" ]
The binary version of createTextHandler
[ "The", "binary", "version", "of", "createTextHandler" ]
f67c68e80c5798169e3a9b2015e278239dbf005d
https://github.com/projectodd/wunderboss-release/blob/f67c68e80c5798169e3a9b2015e278239dbf005d/web/src/main/java/org/projectodd/wunderboss/web/async/WebsocketUtil.java#L33-L38
148,091
torakiki/event-studio
src/main/java/org/sejda/eventstudio/DefaultEventStudio.java
DefaultEventStudio.remove
public <T> boolean remove(Class<T> eventClass, Listener<T> listener) { return remove(eventClass, listener, HIDDEN_STATION); }
java
public <T> boolean remove(Class<T> eventClass, Listener<T> listener) { return remove(eventClass, listener, HIDDEN_STATION); }
[ "public", "<", "T", ">", "boolean", "remove", "(", "Class", "<", "T", ">", "eventClass", ",", "Listener", "<", "T", ">", "listener", ")", "{", "return", "remove", "(", "eventClass", ",", "listener", ",", "HIDDEN_STATION", ")", ";", "}" ]
Removes the given listener listening on the given event, from the hidden station, hiding the station abstraction. @return true if the listener was found and removed @see EventStudio#remove(Listener, String) @see DefaultEventStudio#HIDDEN_STATION
[ "Removes", "the", "given", "listener", "listening", "on", "the", "given", "event", "from", "the", "hidden", "station", "hiding", "the", "station", "abstraction", "." ]
2937b7ed28bb185a79b9cfb98c4de2eb37690a4a
https://github.com/torakiki/event-studio/blob/2937b7ed28bb185a79b9cfb98c4de2eb37690a4a/src/main/java/org/sejda/eventstudio/DefaultEventStudio.java#L179-L181
148,092
projectodd/wunderboss-release
core/src/main/java/org/projectodd/wunderboss/ec/ConcreteDaemonContext.java
ConcreteDaemonContext.setAction
@Override public void setAction(final Runnable action) { super.setAction(new Runnable() { @Override public void run() { if (!isRunning) { thread = new Thread(wrappedAction(action), "wunderboss-daemon-thread[" + name + "]"); thread.start(); isRunning = true; } } }); }
java
@Override public void setAction(final Runnable action) { super.setAction(new Runnable() { @Override public void run() { if (!isRunning) { thread = new Thread(wrappedAction(action), "wunderboss-daemon-thread[" + name + "]"); thread.start(); isRunning = true; } } }); }
[ "@", "Override", "public", "void", "setAction", "(", "final", "Runnable", "action", ")", "{", "super", ".", "setAction", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "if", "(", "!", "isRunning", ")", "{", "thread", "=", "new", "Thread", "(", "wrappedAction", "(", "action", ")", ",", "\"wunderboss-daemon-thread[\"", "+", "name", "+", "\"]\"", ")", ";", "thread", ".", "start", "(", ")", ";", "isRunning", "=", "true", ";", "}", "}", "}", ")", ";", "}" ]
Wraps the given action in a Runnable that starts a supervised thread.
[ "Wraps", "the", "given", "action", "in", "a", "Runnable", "that", "starts", "a", "supervised", "thread", "." ]
f67c68e80c5798169e3a9b2015e278239dbf005d
https://github.com/projectodd/wunderboss-release/blob/f67c68e80c5798169e3a9b2015e278239dbf005d/core/src/main/java/org/projectodd/wunderboss/ec/ConcreteDaemonContext.java#L38-L50
148,093
projectodd/wunderboss-release
web-undertow/src/main/java/org/projectodd/wunderboss/web/undertow/UndertowWeb.java
UndertowWeb.register
protected boolean register(String path, List<String> vhosts, HttpHandler handler) { return pathology.add(path, vhosts, handler); }
java
protected boolean register(String path, List<String> vhosts, HttpHandler handler) { return pathology.add(path, vhosts, handler); }
[ "protected", "boolean", "register", "(", "String", "path", ",", "List", "<", "String", ">", "vhosts", ",", "HttpHandler", "handler", ")", "{", "return", "pathology", ".", "add", "(", "path", ",", "vhosts", ",", "handler", ")", ";", "}" ]
For the WF subclass
[ "For", "the", "WF", "subclass" ]
f67c68e80c5798169e3a9b2015e278239dbf005d
https://github.com/projectodd/wunderboss-release/blob/f67c68e80c5798169e3a9b2015e278239dbf005d/web-undertow/src/main/java/org/projectodd/wunderboss/web/undertow/UndertowWeb.java#L228-L230
148,094
fuinorg/objects4j
src/main/java/org/fuin/objects4j/ui/TextFieldInfo.java
TextFieldInfo.create
public static TextFieldInfo create(@NotNull final Field field, @NotNull final Locale locale) { final TextField textField = field.getAnnotation(TextField.class); if (textField == null) { return null; } return new TextFieldInfo(field, textField.width()); }
java
public static TextFieldInfo create(@NotNull final Field field, @NotNull final Locale locale) { final TextField textField = field.getAnnotation(TextField.class); if (textField == null) { return null; } return new TextFieldInfo(field, textField.width()); }
[ "public", "static", "TextFieldInfo", "create", "(", "@", "NotNull", "final", "Field", "field", ",", "@", "NotNull", "final", "Locale", "locale", ")", "{", "final", "TextField", "textField", "=", "field", ".", "getAnnotation", "(", "TextField", ".", "class", ")", ";", "if", "(", "textField", "==", "null", ")", "{", "return", "null", ";", "}", "return", "new", "TextFieldInfo", "(", "field", ",", "textField", ".", "width", "(", ")", ")", ";", "}" ]
Return the text field information for a given field. @param field Field to check for <code>@TextField</code> annotation. @param locale Locale to use. @return Information or <code>null</code>.
[ "Return", "the", "text", "field", "information", "for", "a", "given", "field", "." ]
e7f278b5bae073ebb6a76053650571c718f36246
https://github.com/fuinorg/objects4j/blob/e7f278b5bae073ebb6a76053650571c718f36246/src/main/java/org/fuin/objects4j/ui/TextFieldInfo.java#L107-L115
148,095
Commonjava/webdav-handler
common/src/main/java/net/sf/webdav/methods/AbstractMethod.java
AbstractMethod.getDepth
protected int getDepth( final WebdavRequest req ) { int depth = INFINITY; final String depthStr = req.getHeader( "Depth" ); if ( depthStr != null ) { if ( depthStr.equals( "0" ) ) { depth = 0; } else if ( depthStr.equals( "1" ) ) { depth = 1; } } return depth; }
java
protected int getDepth( final WebdavRequest req ) { int depth = INFINITY; final String depthStr = req.getHeader( "Depth" ); if ( depthStr != null ) { if ( depthStr.equals( "0" ) ) { depth = 0; } else if ( depthStr.equals( "1" ) ) { depth = 1; } } return depth; }
[ "protected", "int", "getDepth", "(", "final", "WebdavRequest", "req", ")", "{", "int", "depth", "=", "INFINITY", ";", "final", "String", "depthStr", "=", "req", ".", "getHeader", "(", "\"Depth\"", ")", ";", "if", "(", "depthStr", "!=", "null", ")", "{", "if", "(", "depthStr", ".", "equals", "(", "\"0\"", ")", ")", "{", "depth", "=", "0", ";", "}", "else", "if", "(", "depthStr", ".", "equals", "(", "\"1\"", ")", ")", "{", "depth", "=", "1", ";", "}", "}", "return", "depth", ";", "}" ]
reads the depth header from the request and returns it as a int @param req @return the depth from the depth header
[ "reads", "the", "depth", "header", "from", "the", "request", "and", "returns", "it", "as", "a", "int" ]
39bb7032fc75c1b67d3f2440dd1c234ead96cb9d
https://github.com/Commonjava/webdav-handler/blob/39bb7032fc75c1b67d3f2440dd1c234ead96cb9d/common/src/main/java/net/sf/webdav/methods/AbstractMethod.java#L217-L233
148,096
Commonjava/webdav-handler
common/src/main/java/net/sf/webdav/methods/AbstractMethod.java
AbstractMethod.getETag
protected String getETag( final StoredObject so ) { String resourceLength = ""; String lastModified = ""; if ( so != null && so.isResource() ) { resourceLength = new Long( so.getResourceLength() ).toString(); lastModified = new Long( so.getLastModified() .getTime() ).toString(); } return "W/\"" + resourceLength + "-" + lastModified + "\""; }
java
protected String getETag( final StoredObject so ) { String resourceLength = ""; String lastModified = ""; if ( so != null && so.isResource() ) { resourceLength = new Long( so.getResourceLength() ).toString(); lastModified = new Long( so.getLastModified() .getTime() ).toString(); } return "W/\"" + resourceLength + "-" + lastModified + "\""; }
[ "protected", "String", "getETag", "(", "final", "StoredObject", "so", ")", "{", "String", "resourceLength", "=", "\"\"", ";", "String", "lastModified", "=", "\"\"", ";", "if", "(", "so", "!=", "null", "&&", "so", ".", "isResource", "(", ")", ")", "{", "resourceLength", "=", "new", "Long", "(", "so", ".", "getResourceLength", "(", ")", ")", ".", "toString", "(", ")", ";", "lastModified", "=", "new", "Long", "(", "so", ".", "getLastModified", "(", ")", ".", "getTime", "(", ")", ")", ".", "toString", "(", ")", ";", "}", "return", "\"W/\\\"\"", "+", "resourceLength", "+", "\"-\"", "+", "lastModified", "+", "\"\\\"\"", ";", "}" ]
Get the ETag associated with a file. @param so StoredObject to get resourceLength, lastModified and a hashCode of StoredObject @return the ETag
[ "Get", "the", "ETag", "associated", "with", "a", "file", "." ]
39bb7032fc75c1b67d3f2440dd1c234ead96cb9d
https://github.com/Commonjava/webdav-handler/blob/39bb7032fc75c1b67d3f2440dd1c234ead96cb9d/common/src/main/java/net/sf/webdav/methods/AbstractMethod.java#L255-L270
148,097
Commonjava/webdav-handler
common/src/main/java/net/sf/webdav/methods/AbstractMethod.java
AbstractMethod.sendReport
protected void sendReport( final WebdavRequest req, final WebdavResponse resp, final Hashtable<String, WebdavStatus> errorList ) throws IOException { resp.setStatus( WebdavStatus.SC_MULTI_STATUS ); final String absoluteUri = req.getRequestURI(); // String relativePath = getRelativePath(req); final HashMap<String, String> namespaces = new HashMap<String, String>(); namespaces.put( "DAV:", "D" ); final XMLWriter generatedXML = new XMLWriter( namespaces ); generatedXML.writeXMLHeader(); generatedXML.writeElement( "DAV::multistatus", XMLWriter.OPENING ); final Enumeration<String> pathList = errorList.keys(); while ( pathList.hasMoreElements() ) { final String errorPath = pathList.nextElement(); final int errorCode = errorList.get( errorPath ) .code(); generatedXML.writeElement( "DAV::response", XMLWriter.OPENING ); generatedXML.writeElement( "DAV::href", XMLWriter.OPENING ); String toAppend = null; if ( absoluteUri.endsWith( errorPath ) ) { toAppend = absoluteUri; } else if ( absoluteUri.contains( errorPath ) ) { final int endIndex = absoluteUri.indexOf( errorPath ) + errorPath.length(); toAppend = absoluteUri.substring( 0, endIndex ); } if ( !toAppend.startsWith( "/" ) && !toAppend.startsWith( "http:" ) ) { toAppend = "/" + toAppend; } generatedXML.writeText( errorPath ); generatedXML.writeElement( "DAV::href", XMLWriter.CLOSING ); generatedXML.writeElement( "DAV::status", XMLWriter.OPENING ); generatedXML.writeText( "HTTP/1.1 " + errorCode + " " + WebdavStatus.getStatusText( errorCode ) ); generatedXML.writeElement( "DAV::status", XMLWriter.CLOSING ); generatedXML.writeElement( "DAV::response", XMLWriter.CLOSING ); } generatedXML.writeElement( "DAV::multistatus", XMLWriter.CLOSING ); final Writer writer = resp.getWriter(); writer.write( generatedXML.toString() ); writer.close(); }
java
protected void sendReport( final WebdavRequest req, final WebdavResponse resp, final Hashtable<String, WebdavStatus> errorList ) throws IOException { resp.setStatus( WebdavStatus.SC_MULTI_STATUS ); final String absoluteUri = req.getRequestURI(); // String relativePath = getRelativePath(req); final HashMap<String, String> namespaces = new HashMap<String, String>(); namespaces.put( "DAV:", "D" ); final XMLWriter generatedXML = new XMLWriter( namespaces ); generatedXML.writeXMLHeader(); generatedXML.writeElement( "DAV::multistatus", XMLWriter.OPENING ); final Enumeration<String> pathList = errorList.keys(); while ( pathList.hasMoreElements() ) { final String errorPath = pathList.nextElement(); final int errorCode = errorList.get( errorPath ) .code(); generatedXML.writeElement( "DAV::response", XMLWriter.OPENING ); generatedXML.writeElement( "DAV::href", XMLWriter.OPENING ); String toAppend = null; if ( absoluteUri.endsWith( errorPath ) ) { toAppend = absoluteUri; } else if ( absoluteUri.contains( errorPath ) ) { final int endIndex = absoluteUri.indexOf( errorPath ) + errorPath.length(); toAppend = absoluteUri.substring( 0, endIndex ); } if ( !toAppend.startsWith( "/" ) && !toAppend.startsWith( "http:" ) ) { toAppend = "/" + toAppend; } generatedXML.writeText( errorPath ); generatedXML.writeElement( "DAV::href", XMLWriter.CLOSING ); generatedXML.writeElement( "DAV::status", XMLWriter.OPENING ); generatedXML.writeText( "HTTP/1.1 " + errorCode + " " + WebdavStatus.getStatusText( errorCode ) ); generatedXML.writeElement( "DAV::status", XMLWriter.CLOSING ); generatedXML.writeElement( "DAV::response", XMLWriter.CLOSING ); } generatedXML.writeElement( "DAV::multistatus", XMLWriter.CLOSING ); final Writer writer = resp.getWriter(); writer.write( generatedXML.toString() ); writer.close(); }
[ "protected", "void", "sendReport", "(", "final", "WebdavRequest", "req", ",", "final", "WebdavResponse", "resp", ",", "final", "Hashtable", "<", "String", ",", "WebdavStatus", ">", "errorList", ")", "throws", "IOException", "{", "resp", ".", "setStatus", "(", "WebdavStatus", ".", "SC_MULTI_STATUS", ")", ";", "final", "String", "absoluteUri", "=", "req", ".", "getRequestURI", "(", ")", ";", "// String relativePath = getRelativePath(req);", "final", "HashMap", "<", "String", ",", "String", ">", "namespaces", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "namespaces", ".", "put", "(", "\"DAV:\"", ",", "\"D\"", ")", ";", "final", "XMLWriter", "generatedXML", "=", "new", "XMLWriter", "(", "namespaces", ")", ";", "generatedXML", ".", "writeXMLHeader", "(", ")", ";", "generatedXML", ".", "writeElement", "(", "\"DAV::multistatus\"", ",", "XMLWriter", ".", "OPENING", ")", ";", "final", "Enumeration", "<", "String", ">", "pathList", "=", "errorList", ".", "keys", "(", ")", ";", "while", "(", "pathList", ".", "hasMoreElements", "(", ")", ")", "{", "final", "String", "errorPath", "=", "pathList", ".", "nextElement", "(", ")", ";", "final", "int", "errorCode", "=", "errorList", ".", "get", "(", "errorPath", ")", ".", "code", "(", ")", ";", "generatedXML", ".", "writeElement", "(", "\"DAV::response\"", ",", "XMLWriter", ".", "OPENING", ")", ";", "generatedXML", ".", "writeElement", "(", "\"DAV::href\"", ",", "XMLWriter", ".", "OPENING", ")", ";", "String", "toAppend", "=", "null", ";", "if", "(", "absoluteUri", ".", "endsWith", "(", "errorPath", ")", ")", "{", "toAppend", "=", "absoluteUri", ";", "}", "else", "if", "(", "absoluteUri", ".", "contains", "(", "errorPath", ")", ")", "{", "final", "int", "endIndex", "=", "absoluteUri", ".", "indexOf", "(", "errorPath", ")", "+", "errorPath", ".", "length", "(", ")", ";", "toAppend", "=", "absoluteUri", ".", "substring", "(", "0", ",", "endIndex", ")", ";", "}", "if", "(", "!", "toAppend", ".", "startsWith", "(", "\"/\"", ")", "&&", "!", "toAppend", ".", "startsWith", "(", "\"http:\"", ")", ")", "{", "toAppend", "=", "\"/\"", "+", "toAppend", ";", "}", "generatedXML", ".", "writeText", "(", "errorPath", ")", ";", "generatedXML", ".", "writeElement", "(", "\"DAV::href\"", ",", "XMLWriter", ".", "CLOSING", ")", ";", "generatedXML", ".", "writeElement", "(", "\"DAV::status\"", ",", "XMLWriter", ".", "OPENING", ")", ";", "generatedXML", ".", "writeText", "(", "\"HTTP/1.1 \"", "+", "errorCode", "+", "\" \"", "+", "WebdavStatus", ".", "getStatusText", "(", "errorCode", ")", ")", ";", "generatedXML", ".", "writeElement", "(", "\"DAV::status\"", ",", "XMLWriter", ".", "CLOSING", ")", ";", "generatedXML", ".", "writeElement", "(", "\"DAV::response\"", ",", "XMLWriter", ".", "CLOSING", ")", ";", "}", "generatedXML", ".", "writeElement", "(", "\"DAV::multistatus\"", ",", "XMLWriter", ".", "CLOSING", ")", ";", "final", "Writer", "writer", "=", "resp", ".", "getWriter", "(", ")", ";", "writer", ".", "write", "(", "generatedXML", ".", "toString", "(", ")", ")", ";", "writer", ".", "close", "(", ")", ";", "}" ]
Send a multistatus element containing a complete error report to the client. @param req Servlet request @param resp Servlet response @param errorList List of error to be displayed
[ "Send", "a", "multistatus", "element", "containing", "a", "complete", "error", "report", "to", "the", "client", "." ]
39bb7032fc75c1b67d3f2440dd1c234ead96cb9d
https://github.com/Commonjava/webdav-handler/blob/39bb7032fc75c1b67d3f2440dd1c234ead96cb9d/common/src/main/java/net/sf/webdav/methods/AbstractMethod.java#L402-L462
148,098
projectodd/wunderboss-release
ruby/src/main/java/org/projectodd/wunderboss/ruby/RubyHelper.java
RubyHelper.setIfPossible
public static boolean setIfPossible(final Ruby ruby, final Object target, final String name, final Object value) { boolean success = false; if (defined( ruby, target, name + "=" )) { JavaEmbedUtils.invokeMethod( ruby, target, name + "=", new Object[] { value }, void.class ); success = true; } return success; }
java
public static boolean setIfPossible(final Ruby ruby, final Object target, final String name, final Object value) { boolean success = false; if (defined( ruby, target, name + "=" )) { JavaEmbedUtils.invokeMethod( ruby, target, name + "=", new Object[] { value }, void.class ); success = true; } return success; }
[ "public", "static", "boolean", "setIfPossible", "(", "final", "Ruby", "ruby", ",", "final", "Object", "target", ",", "final", "String", "name", ",", "final", "Object", "value", ")", "{", "boolean", "success", "=", "false", ";", "if", "(", "defined", "(", "ruby", ",", "target", ",", "name", "+", "\"=\"", ")", ")", "{", "JavaEmbedUtils", ".", "invokeMethod", "(", "ruby", ",", "target", ",", "name", "+", "\"=\"", ",", "new", "Object", "[", "]", "{", "value", "}", ",", "void", ".", "class", ")", ";", "success", "=", "true", ";", "}", "return", "success", ";", "}" ]
Set a property on a Ruby object, if possible. <p> If the target responds to {@code name=}, the property will be set. Otherwise, not. </p> @param ruby The Ruby interpreter. @param target The target object. @param name The basic name of the property. @param value The value to attempt to set. @return {@code true} if successful, otherwise {@code false}
[ "Set", "a", "property", "on", "a", "Ruby", "object", "if", "possible", "." ]
f67c68e80c5798169e3a9b2015e278239dbf005d
https://github.com/projectodd/wunderboss-release/blob/f67c68e80c5798169e3a9b2015e278239dbf005d/ruby/src/main/java/org/projectodd/wunderboss/ruby/RubyHelper.java#L58-L65
148,099
projectodd/wunderboss-release
ruby/src/main/java/org/projectodd/wunderboss/ruby/RubyHelper.java
RubyHelper.requireIfAvailable
public static boolean requireIfAvailable(Ruby ruby, String requirement, boolean logErrors) { boolean success = false; try { StringBuilder script = new StringBuilder(); script.append("require %q("); script.append(requirement); script.append(")\n"); evalScriptlet( ruby, script.toString(), false ); success = true; } catch (Throwable t) { success = false; if (logErrors) { log.debug( "Error encountered. Unable to require file: " + requirement, t ); } } return success; }
java
public static boolean requireIfAvailable(Ruby ruby, String requirement, boolean logErrors) { boolean success = false; try { StringBuilder script = new StringBuilder(); script.append("require %q("); script.append(requirement); script.append(")\n"); evalScriptlet( ruby, script.toString(), false ); success = true; } catch (Throwable t) { success = false; if (logErrors) { log.debug( "Error encountered. Unable to require file: " + requirement, t ); } } return success; }
[ "public", "static", "boolean", "requireIfAvailable", "(", "Ruby", "ruby", ",", "String", "requirement", ",", "boolean", "logErrors", ")", "{", "boolean", "success", "=", "false", ";", "try", "{", "StringBuilder", "script", "=", "new", "StringBuilder", "(", ")", ";", "script", ".", "append", "(", "\"require %q(\"", ")", ";", "script", ".", "append", "(", "requirement", ")", ";", "script", ".", "append", "(", "\")\\n\"", ")", ";", "evalScriptlet", "(", "ruby", ",", "script", ".", "toString", "(", ")", ",", "false", ")", ";", "success", "=", "true", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "success", "=", "false", ";", "if", "(", "logErrors", ")", "{", "log", ".", "debug", "(", "\"Error encountered. Unable to require file: \"", "+", "requirement", ",", "t", ")", ";", "}", "}", "return", "success", ";", "}" ]
Calls "require 'requirement'" in the Ruby provided. @return boolean If successful, returns true, otherwise false.
[ "Calls", "require", "requirement", "in", "the", "Ruby", "provided", "." ]
f67c68e80c5798169e3a9b2015e278239dbf005d
https://github.com/projectodd/wunderboss-release/blob/f67c68e80c5798169e3a9b2015e278239dbf005d/ruby/src/main/java/org/projectodd/wunderboss/ruby/RubyHelper.java#L116-L132