repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
sequencelengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
sequencelengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
nmdp-bioinformatics/ngs | variant/src/main/java/org/nmdp/ngs/variant/vcf/VcfWriter.java | VcfWriter.writeColumnHeader | public static void writeColumnHeader(final List<VcfSample> samples, final PrintWriter writer) {
"""
Write VCF column header with the specified print writer.
@param samples zero or more VCF samples, must not be null
@param writer print writer to write VCF with, must not be null
"""
checkNotNull(samples);
checkNotNull(writer);
StringBuilder sb = new StringBuilder("#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO");
if (!samples.isEmpty()) {
sb.append("\tFORMAT");
}
for (VcfSample sample : samples) {
sb.append("\t");
sb.append(sample.getId());
}
writer.println(sb.toString());
} | java | public static void writeColumnHeader(final List<VcfSample> samples, final PrintWriter writer) {
checkNotNull(samples);
checkNotNull(writer);
StringBuilder sb = new StringBuilder("#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO");
if (!samples.isEmpty()) {
sb.append("\tFORMAT");
}
for (VcfSample sample : samples) {
sb.append("\t");
sb.append(sample.getId());
}
writer.println(sb.toString());
} | [
"public",
"static",
"void",
"writeColumnHeader",
"(",
"final",
"List",
"<",
"VcfSample",
">",
"samples",
",",
"final",
"PrintWriter",
"writer",
")",
"{",
"checkNotNull",
"(",
"samples",
")",
";",
"checkNotNull",
"(",
"writer",
")",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"\"#CHROM\\tPOS\\tID\\tREF\\tALT\\tQUAL\\tFILTER\\tINFO\"",
")",
";",
"if",
"(",
"!",
"samples",
".",
"isEmpty",
"(",
")",
")",
"{",
"sb",
".",
"append",
"(",
"\"\\tFORMAT\"",
")",
";",
"}",
"for",
"(",
"VcfSample",
"sample",
":",
"samples",
")",
"{",
"sb",
".",
"append",
"(",
"\"\\t\"",
")",
";",
"sb",
".",
"append",
"(",
"sample",
".",
"getId",
"(",
")",
")",
";",
"}",
"writer",
".",
"println",
"(",
"sb",
".",
"toString",
"(",
")",
")",
";",
"}"
] | Write VCF column header with the specified print writer.
@param samples zero or more VCF samples, must not be null
@param writer print writer to write VCF with, must not be null | [
"Write",
"VCF",
"column",
"header",
"with",
"the",
"specified",
"print",
"writer",
"."
] | train | https://github.com/nmdp-bioinformatics/ngs/blob/277627e4311313a80f5dc110b3185b0d7af32bd0/variant/src/main/java/org/nmdp/ngs/variant/vcf/VcfWriter.java#L86-L99 |
lucee/Lucee | core/src/main/java/lucee/runtime/text/xml/XMLCaster.java | XMLCaster.toNode | public static Node toNode(Document doc, Object o, short type) throws PageException {
"""
casts a value to a XML Object defined by type parameter
@param doc XML Document
@param o Object to cast
@param type type to cast to
@return XML Text Object
@throws PageException
"""
if (Node.TEXT_NODE == type) toText(doc, o);
else if (Node.ATTRIBUTE_NODE == type) toAttr(doc, o);
else if (Node.COMMENT_NODE == type) toComment(doc, o);
else if (Node.ELEMENT_NODE == type) toElement(doc, o);
throw new ExpressionException("invalid node type definition");
} | java | public static Node toNode(Document doc, Object o, short type) throws PageException {
if (Node.TEXT_NODE == type) toText(doc, o);
else if (Node.ATTRIBUTE_NODE == type) toAttr(doc, o);
else if (Node.COMMENT_NODE == type) toComment(doc, o);
else if (Node.ELEMENT_NODE == type) toElement(doc, o);
throw new ExpressionException("invalid node type definition");
} | [
"public",
"static",
"Node",
"toNode",
"(",
"Document",
"doc",
",",
"Object",
"o",
",",
"short",
"type",
")",
"throws",
"PageException",
"{",
"if",
"(",
"Node",
".",
"TEXT_NODE",
"==",
"type",
")",
"toText",
"(",
"doc",
",",
"o",
")",
";",
"else",
"if",
"(",
"Node",
".",
"ATTRIBUTE_NODE",
"==",
"type",
")",
"toAttr",
"(",
"doc",
",",
"o",
")",
";",
"else",
"if",
"(",
"Node",
".",
"COMMENT_NODE",
"==",
"type",
")",
"toComment",
"(",
"doc",
",",
"o",
")",
";",
"else",
"if",
"(",
"Node",
".",
"ELEMENT_NODE",
"==",
"type",
")",
"toElement",
"(",
"doc",
",",
"o",
")",
";",
"throw",
"new",
"ExpressionException",
"(",
"\"invalid node type definition\"",
")",
";",
"}"
] | casts a value to a XML Object defined by type parameter
@param doc XML Document
@param o Object to cast
@param type type to cast to
@return XML Text Object
@throws PageException | [
"casts",
"a",
"value",
"to",
"a",
"XML",
"Object",
"defined",
"by",
"type",
"parameter"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/runtime/text/xml/XMLCaster.java#L406-L414 |
QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/db/cql/CQLService.java | CQLService.getPreparedQuery | public PreparedStatement getPreparedQuery(Query query, String storeName) {
"""
Get the {@link PreparedStatement} for the given {@link CQLStatementCache.Query} to
the given table name. If needed, the query statement is compiled and cached.
@param query Query statement type.
@param storeName Store (ColumnFamily) name.
@return PreparedStatement for requested table/query.
"""
String tableName = storeToCQLName(storeName);
return m_statementCache.getPreparedQuery(tableName, query);
} | java | public PreparedStatement getPreparedQuery(Query query, String storeName) {
String tableName = storeToCQLName(storeName);
return m_statementCache.getPreparedQuery(tableName, query);
} | [
"public",
"PreparedStatement",
"getPreparedQuery",
"(",
"Query",
"query",
",",
"String",
"storeName",
")",
"{",
"String",
"tableName",
"=",
"storeToCQLName",
"(",
"storeName",
")",
";",
"return",
"m_statementCache",
".",
"getPreparedQuery",
"(",
"tableName",
",",
"query",
")",
";",
"}"
] | Get the {@link PreparedStatement} for the given {@link CQLStatementCache.Query} to
the given table name. If needed, the query statement is compiled and cached.
@param query Query statement type.
@param storeName Store (ColumnFamily) name.
@return PreparedStatement for requested table/query. | [
"Get",
"the",
"{",
"@link",
"PreparedStatement",
"}",
"for",
"the",
"given",
"{",
"@link",
"CQLStatementCache",
".",
"Query",
"}",
"to",
"the",
"given",
"table",
"name",
".",
"If",
"needed",
"the",
"query",
"statement",
"is",
"compiled",
"and",
"cached",
"."
] | train | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/cql/CQLService.java#L249-L252 |
jmeetsma/Iglu-Util | src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java | StringSupport.removeAll | public static String removeAll(String haystack, String ... needles) {
"""
removes all occurrences of needle in haystack
@param haystack input string
@param needles strings to remove
"""
return replaceAll(haystack, needles, ArraySupport.getFilledArray(new String[needles.length], ""));
} | java | public static String removeAll(String haystack, String ... needles) {
return replaceAll(haystack, needles, ArraySupport.getFilledArray(new String[needles.length], ""));
} | [
"public",
"static",
"String",
"removeAll",
"(",
"String",
"haystack",
",",
"String",
"...",
"needles",
")",
"{",
"return",
"replaceAll",
"(",
"haystack",
",",
"needles",
",",
"ArraySupport",
".",
"getFilledArray",
"(",
"new",
"String",
"[",
"needles",
".",
"length",
"]",
",",
"\"\"",
")",
")",
";",
"}"
] | removes all occurrences of needle in haystack
@param haystack input string
@param needles strings to remove | [
"removes",
"all",
"occurrences",
"of",
"needle",
"in",
"haystack"
] | train | https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java#L250-L252 |
ocelotds/ocelot | ocelot-processor/src/main/java/org/ocelotds/FileWriterServices.java | FileWriterServices.copyResourceToDir | public void copyResourceToDir(String path, String filename, String dir) {
"""
copy path/filename in dir
@param path
@param filename
@param dir
"""
String fullpath = path + ProcessorConstants.SEPARATORCHAR + filename;
messager.printMessage(Diagnostic.Kind.MANDATORY_WARNING, " javascript copy js : " + fullpath + " to : "+dir);
try (Writer writer = getFileObjectWriter(dir, "org.ocelotds."+filename)) {
bodyWriter.write(writer, OcelotProcessor.class.getResourceAsStream(fullpath));
} catch (IOException ex) {
messager.printMessage(Diagnostic.Kind.MANDATORY_WARNING, " FAILED TO CREATE : " + filename);
}
} | java | public void copyResourceToDir(String path, String filename, String dir) {
String fullpath = path + ProcessorConstants.SEPARATORCHAR + filename;
messager.printMessage(Diagnostic.Kind.MANDATORY_WARNING, " javascript copy js : " + fullpath + " to : "+dir);
try (Writer writer = getFileObjectWriter(dir, "org.ocelotds."+filename)) {
bodyWriter.write(writer, OcelotProcessor.class.getResourceAsStream(fullpath));
} catch (IOException ex) {
messager.printMessage(Diagnostic.Kind.MANDATORY_WARNING, " FAILED TO CREATE : " + filename);
}
} | [
"public",
"void",
"copyResourceToDir",
"(",
"String",
"path",
",",
"String",
"filename",
",",
"String",
"dir",
")",
"{",
"String",
"fullpath",
"=",
"path",
"+",
"ProcessorConstants",
".",
"SEPARATORCHAR",
"+",
"filename",
";",
"messager",
".",
"printMessage",
"(",
"Diagnostic",
".",
"Kind",
".",
"MANDATORY_WARNING",
",",
"\" javascript copy js : \"",
"+",
"fullpath",
"+",
"\" to : \"",
"+",
"dir",
")",
";",
"try",
"(",
"Writer",
"writer",
"=",
"getFileObjectWriter",
"(",
"dir",
",",
"\"org.ocelotds.\"",
"+",
"filename",
")",
")",
"{",
"bodyWriter",
".",
"write",
"(",
"writer",
",",
"OcelotProcessor",
".",
"class",
".",
"getResourceAsStream",
"(",
"fullpath",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"messager",
".",
"printMessage",
"(",
"Diagnostic",
".",
"Kind",
".",
"MANDATORY_WARNING",
",",
"\" FAILED TO CREATE : \"",
"+",
"filename",
")",
";",
"}",
"}"
] | copy path/filename in dir
@param path
@param filename
@param dir | [
"copy",
"path",
"/",
"filename",
"in",
"dir"
] | train | https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-processor/src/main/java/org/ocelotds/FileWriterServices.java#L56-L64 |
maven-nar/nar-maven-plugin | src/main/java/com/github/maven_nar/cpptasks/openwatcom/OpenWatcomCompiler.java | OpenWatcomCompiler.getDefineSwitch | @Override
protected final void getDefineSwitch(final StringBuffer buffer, final String define, final String value) {
"""
Get define switch.
@param buffer
StringBuffer buffer
@param define
String preprocessor macro
@param value
String value, may be null.
"""
OpenWatcomProcessor.getDefineSwitch(buffer, define, value);
} | java | @Override
protected final void getDefineSwitch(final StringBuffer buffer, final String define, final String value) {
OpenWatcomProcessor.getDefineSwitch(buffer, define, value);
} | [
"@",
"Override",
"protected",
"final",
"void",
"getDefineSwitch",
"(",
"final",
"StringBuffer",
"buffer",
",",
"final",
"String",
"define",
",",
"final",
"String",
"value",
")",
"{",
"OpenWatcomProcessor",
".",
"getDefineSwitch",
"(",
"buffer",
",",
"define",
",",
"value",
")",
";",
"}"
] | Get define switch.
@param buffer
StringBuffer buffer
@param define
String preprocessor macro
@param value
String value, may be null. | [
"Get",
"define",
"switch",
"."
] | train | https://github.com/maven-nar/nar-maven-plugin/blob/3c622e2024296b4203431bbae3bde290a01dac00/src/main/java/com/github/maven_nar/cpptasks/openwatcom/OpenWatcomCompiler.java#L145-L148 |
JCTools/JCTools | jctools-core/src/main/java/org/jctools/queues/atomic/BaseMpscLinkedAtomicArrayQueue.java | BaseMpscLinkedAtomicArrayQueue.offerSlowPath | private int offerSlowPath(long mask, long pIndex, long producerLimit) {
"""
We do not inline resize into this method because we do not resize on fill.
"""
final long cIndex = lvConsumerIndex();
long bufferCapacity = getCurrentBufferCapacity(mask);
if (cIndex + bufferCapacity > pIndex) {
if (!casProducerLimit(producerLimit, cIndex + bufferCapacity)) {
// retry from top
return RETRY;
} else {
// continue to pIndex CAS
return CONTINUE_TO_P_INDEX_CAS;
}
} else // full and cannot grow
if (availableInQueue(pIndex, cIndex) <= 0) {
// offer should return false;
return QUEUE_FULL;
} else // grab index for resize -> set lower bit
if (casProducerIndex(pIndex, pIndex + 1)) {
// trigger a resize
return QUEUE_RESIZE;
} else {
// failed resize attempt, retry from top
return RETRY;
}
} | java | private int offerSlowPath(long mask, long pIndex, long producerLimit) {
final long cIndex = lvConsumerIndex();
long bufferCapacity = getCurrentBufferCapacity(mask);
if (cIndex + bufferCapacity > pIndex) {
if (!casProducerLimit(producerLimit, cIndex + bufferCapacity)) {
// retry from top
return RETRY;
} else {
// continue to pIndex CAS
return CONTINUE_TO_P_INDEX_CAS;
}
} else // full and cannot grow
if (availableInQueue(pIndex, cIndex) <= 0) {
// offer should return false;
return QUEUE_FULL;
} else // grab index for resize -> set lower bit
if (casProducerIndex(pIndex, pIndex + 1)) {
// trigger a resize
return QUEUE_RESIZE;
} else {
// failed resize attempt, retry from top
return RETRY;
}
} | [
"private",
"int",
"offerSlowPath",
"(",
"long",
"mask",
",",
"long",
"pIndex",
",",
"long",
"producerLimit",
")",
"{",
"final",
"long",
"cIndex",
"=",
"lvConsumerIndex",
"(",
")",
";",
"long",
"bufferCapacity",
"=",
"getCurrentBufferCapacity",
"(",
"mask",
")",
";",
"if",
"(",
"cIndex",
"+",
"bufferCapacity",
">",
"pIndex",
")",
"{",
"if",
"(",
"!",
"casProducerLimit",
"(",
"producerLimit",
",",
"cIndex",
"+",
"bufferCapacity",
")",
")",
"{",
"// retry from top",
"return",
"RETRY",
";",
"}",
"else",
"{",
"// continue to pIndex CAS",
"return",
"CONTINUE_TO_P_INDEX_CAS",
";",
"}",
"}",
"else",
"// full and cannot grow",
"if",
"(",
"availableInQueue",
"(",
"pIndex",
",",
"cIndex",
")",
"<=",
"0",
")",
"{",
"// offer should return false;",
"return",
"QUEUE_FULL",
";",
"}",
"else",
"// grab index for resize -> set lower bit",
"if",
"(",
"casProducerIndex",
"(",
"pIndex",
",",
"pIndex",
"+",
"1",
")",
")",
"{",
"// trigger a resize",
"return",
"QUEUE_RESIZE",
";",
"}",
"else",
"{",
"// failed resize attempt, retry from top",
"return",
"RETRY",
";",
"}",
"}"
] | We do not inline resize into this method because we do not resize on fill. | [
"We",
"do",
"not",
"inline",
"resize",
"into",
"this",
"method",
"because",
"we",
"do",
"not",
"resize",
"on",
"fill",
"."
] | train | https://github.com/JCTools/JCTools/blob/9250fe316ec84209cbba0a41682f341256df781e/jctools-core/src/main/java/org/jctools/queues/atomic/BaseMpscLinkedAtomicArrayQueue.java#L339-L362 |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaDbBlob.java | MariaDbBlob.setBinaryStream | public OutputStream setBinaryStream(final long pos) throws SQLException {
"""
Retrieves a stream that can be used to write to the <code>BLOB</code> value that this
<code>Blob</code> object represents. The stream begins at position <code>pos</code>. The
bytes written to the stream will overwrite the existing bytes in the <code>Blob</code> object
starting at the position <code>pos</code>. If the end of the
<code>Blob</code> value is reached while writing to the stream, then the length of the
<code>Blob</code> value
will be increased to accommodate the extra bytes.
<p><b>Note:</b> If the value specified for <code>pos</code> is greater then the length+1 of the
<code>BLOB</code>
value then the behavior is undefined. Some JDBC drivers may throw a <code>SQLException</code>
while other drivers may support this operation.</p>
@param pos the position in the <code>BLOB</code> value at which to start writing; the first
position is 1
@return a <code>java.io.OutputStream</code> object to which data can be written
@throws SQLException if there is an error accessing the <code>BLOB</code> value or if pos is
less than 1
@see #getBinaryStream
@since 1.4
"""
if (pos < 1) {
throw ExceptionMapper.getSqlException("Invalid position in blob");
}
if (offset > 0) {
byte[] tmp = new byte[length];
System.arraycopy(data, offset, tmp, 0, length);
data = tmp;
offset = 0;
}
return new BlobOutputStream(this, (int) (pos - 1) + offset);
} | java | public OutputStream setBinaryStream(final long pos) throws SQLException {
if (pos < 1) {
throw ExceptionMapper.getSqlException("Invalid position in blob");
}
if (offset > 0) {
byte[] tmp = new byte[length];
System.arraycopy(data, offset, tmp, 0, length);
data = tmp;
offset = 0;
}
return new BlobOutputStream(this, (int) (pos - 1) + offset);
} | [
"public",
"OutputStream",
"setBinaryStream",
"(",
"final",
"long",
"pos",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"pos",
"<",
"1",
")",
"{",
"throw",
"ExceptionMapper",
".",
"getSqlException",
"(",
"\"Invalid position in blob\"",
")",
";",
"}",
"if",
"(",
"offset",
">",
"0",
")",
"{",
"byte",
"[",
"]",
"tmp",
"=",
"new",
"byte",
"[",
"length",
"]",
";",
"System",
".",
"arraycopy",
"(",
"data",
",",
"offset",
",",
"tmp",
",",
"0",
",",
"length",
")",
";",
"data",
"=",
"tmp",
";",
"offset",
"=",
"0",
";",
"}",
"return",
"new",
"BlobOutputStream",
"(",
"this",
",",
"(",
"int",
")",
"(",
"pos",
"-",
"1",
")",
"+",
"offset",
")",
";",
"}"
] | Retrieves a stream that can be used to write to the <code>BLOB</code> value that this
<code>Blob</code> object represents. The stream begins at position <code>pos</code>. The
bytes written to the stream will overwrite the existing bytes in the <code>Blob</code> object
starting at the position <code>pos</code>. If the end of the
<code>Blob</code> value is reached while writing to the stream, then the length of the
<code>Blob</code> value
will be increased to accommodate the extra bytes.
<p><b>Note:</b> If the value specified for <code>pos</code> is greater then the length+1 of the
<code>BLOB</code>
value then the behavior is undefined. Some JDBC drivers may throw a <code>SQLException</code>
while other drivers may support this operation.</p>
@param pos the position in the <code>BLOB</code> value at which to start writing; the first
position is 1
@return a <code>java.io.OutputStream</code> object to which data can be written
@throws SQLException if there is an error accessing the <code>BLOB</code> value or if pos is
less than 1
@see #getBinaryStream
@since 1.4 | [
"Retrieves",
"a",
"stream",
"that",
"can",
"be",
"used",
"to",
"write",
"to",
"the",
"<code",
">",
"BLOB<",
"/",
"code",
">",
"value",
"that",
"this",
"<code",
">",
"Blob<",
"/",
"code",
">",
"object",
"represents",
".",
"The",
"stream",
"begins",
"at",
"position",
"<code",
">",
"pos<",
"/",
"code",
">",
".",
"The",
"bytes",
"written",
"to",
"the",
"stream",
"will",
"overwrite",
"the",
"existing",
"bytes",
"in",
"the",
"<code",
">",
"Blob<",
"/",
"code",
">",
"object",
"starting",
"at",
"the",
"position",
"<code",
">",
"pos<",
"/",
"code",
">",
".",
"If",
"the",
"end",
"of",
"the",
"<code",
">",
"Blob<",
"/",
"code",
">",
"value",
"is",
"reached",
"while",
"writing",
"to",
"the",
"stream",
"then",
"the",
"length",
"of",
"the",
"<code",
">",
"Blob<",
"/",
"code",
">",
"value",
"will",
"be",
"increased",
"to",
"accommodate",
"the",
"extra",
"bytes",
"."
] | train | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbBlob.java#L388-L399 |
briandilley/jsonrpc4j | src/main/java/com/googlecode/jsonrpc4j/JsonRpcBasicServer.java | JsonRpcBasicServer.handleJsonNodeRequest | protected JsonError handleJsonNodeRequest(final JsonNode node, final OutputStream output) throws IOException {
"""
Handles the given {@link JsonNode} and writes the responses to the given {@link OutputStream}.
@param node the {@link JsonNode}
@param output the {@link OutputStream}
@return the error code, or {@code 0} if none
@throws IOException on error
"""
if (node.isArray()) {
return handleArray(ArrayNode.class.cast(node), output);
}
if (node.isObject()) {
return handleObject(ObjectNode.class.cast(node), output);
}
return this.writeAndFlushValueError(output, this.createResponseError(VERSION, NULL, JsonError.INVALID_REQUEST));
} | java | protected JsonError handleJsonNodeRequest(final JsonNode node, final OutputStream output) throws IOException {
if (node.isArray()) {
return handleArray(ArrayNode.class.cast(node), output);
}
if (node.isObject()) {
return handleObject(ObjectNode.class.cast(node), output);
}
return this.writeAndFlushValueError(output, this.createResponseError(VERSION, NULL, JsonError.INVALID_REQUEST));
} | [
"protected",
"JsonError",
"handleJsonNodeRequest",
"(",
"final",
"JsonNode",
"node",
",",
"final",
"OutputStream",
"output",
")",
"throws",
"IOException",
"{",
"if",
"(",
"node",
".",
"isArray",
"(",
")",
")",
"{",
"return",
"handleArray",
"(",
"ArrayNode",
".",
"class",
".",
"cast",
"(",
"node",
")",
",",
"output",
")",
";",
"}",
"if",
"(",
"node",
".",
"isObject",
"(",
")",
")",
"{",
"return",
"handleObject",
"(",
"ObjectNode",
".",
"class",
".",
"cast",
"(",
"node",
")",
",",
"output",
")",
";",
"}",
"return",
"this",
".",
"writeAndFlushValueError",
"(",
"output",
",",
"this",
".",
"createResponseError",
"(",
"VERSION",
",",
"NULL",
",",
"JsonError",
".",
"INVALID_REQUEST",
")",
")",
";",
"}"
] | Handles the given {@link JsonNode} and writes the responses to the given {@link OutputStream}.
@param node the {@link JsonNode}
@param output the {@link OutputStream}
@return the error code, or {@code 0} if none
@throws IOException on error | [
"Handles",
"the",
"given",
"{",
"@link",
"JsonNode",
"}",
"and",
"writes",
"the",
"responses",
"to",
"the",
"given",
"{",
"@link",
"OutputStream",
"}",
"."
] | train | https://github.com/briandilley/jsonrpc4j/blob/d749762c9295b92d893677a8c7be2a14dd43b3bb/src/main/java/com/googlecode/jsonrpc4j/JsonRpcBasicServer.java#L273-L281 |
jenkinsci/jenkins | core/src/main/java/hudson/model/AbstractProject.java | AbstractProject.scheduleBuild2 | @SuppressWarnings("deprecation")
@WithBridgeMethods(Future.class)
public QueueTaskFuture<R> scheduleBuild2(int quietPeriod) {
"""
Schedules a build, and returns a {@link Future} object
to wait for the completion of the build.
<p>
Production code shouldn't be using this, but for tests this is very convenient, so this isn't marked
as deprecated.
"""
return scheduleBuild2(quietPeriod, new LegacyCodeCause());
} | java | @SuppressWarnings("deprecation")
@WithBridgeMethods(Future.class)
public QueueTaskFuture<R> scheduleBuild2(int quietPeriod) {
return scheduleBuild2(quietPeriod, new LegacyCodeCause());
} | [
"@",
"SuppressWarnings",
"(",
"\"deprecation\"",
")",
"@",
"WithBridgeMethods",
"(",
"Future",
".",
"class",
")",
"public",
"QueueTaskFuture",
"<",
"R",
">",
"scheduleBuild2",
"(",
"int",
"quietPeriod",
")",
"{",
"return",
"scheduleBuild2",
"(",
"quietPeriod",
",",
"new",
"LegacyCodeCause",
"(",
")",
")",
";",
"}"
] | Schedules a build, and returns a {@link Future} object
to wait for the completion of the build.
<p>
Production code shouldn't be using this, but for tests this is very convenient, so this isn't marked
as deprecated. | [
"Schedules",
"a",
"build",
"and",
"returns",
"a",
"{",
"@link",
"Future",
"}",
"object",
"to",
"wait",
"for",
"the",
"completion",
"of",
"the",
"build",
"."
] | train | https://github.com/jenkinsci/jenkins/blob/44c4d3989232082c254d27ae360aa810669f44b7/core/src/main/java/hudson/model/AbstractProject.java#L836-L840 |
spring-projects/spring-android | spring-android-auth/src/main/java/org/springframework/security/crypto/encrypt/AndroidEncryptors.java | AndroidEncryptors.queryableText | public static TextEncryptor queryableText(CharSequence password, CharSequence salt) {
"""
Creates an encryptor for queryable text strings that uses standard password-based encryption. Uses a shared, or
constant 16 byte initialization vector so encrypting the same data results in the same encryption result. This is
done to allow encrypted data to be queried against. Encrypted text is hex-encoded.
@param password the password used to generate the encryptor's secret key; should not be shared
@param salt a hex-encoded, random, site-global salt value to use to generate the secret key
"""
return new HexEncodingTextEncryptor(new AndroidAesBytesEncryptor(password.toString(), salt, AndroidKeyGenerators.shared(16)));
} | java | public static TextEncryptor queryableText(CharSequence password, CharSequence salt) {
return new HexEncodingTextEncryptor(new AndroidAesBytesEncryptor(password.toString(), salt, AndroidKeyGenerators.shared(16)));
} | [
"public",
"static",
"TextEncryptor",
"queryableText",
"(",
"CharSequence",
"password",
",",
"CharSequence",
"salt",
")",
"{",
"return",
"new",
"HexEncodingTextEncryptor",
"(",
"new",
"AndroidAesBytesEncryptor",
"(",
"password",
".",
"toString",
"(",
")",
",",
"salt",
",",
"AndroidKeyGenerators",
".",
"shared",
"(",
"16",
")",
")",
")",
";",
"}"
] | Creates an encryptor for queryable text strings that uses standard password-based encryption. Uses a shared, or
constant 16 byte initialization vector so encrypting the same data results in the same encryption result. This is
done to allow encrypted data to be queried against. Encrypted text is hex-encoded.
@param password the password used to generate the encryptor's secret key; should not be shared
@param salt a hex-encoded, random, site-global salt value to use to generate the secret key | [
"Creates",
"an",
"encryptor",
"for",
"queryable",
"text",
"strings",
"that",
"uses",
"standard",
"password",
"-",
"based",
"encryption",
".",
"Uses",
"a",
"shared",
"or",
"constant",
"16",
"byte",
"initialization",
"vector",
"so",
"encrypting",
"the",
"same",
"data",
"results",
"in",
"the",
"same",
"encryption",
"result",
".",
"This",
"is",
"done",
"to",
"allow",
"encrypted",
"data",
"to",
"be",
"queried",
"against",
".",
"Encrypted",
"text",
"is",
"hex",
"-",
"encoded",
"."
] | train | https://github.com/spring-projects/spring-android/blob/941296e152d49a40e0745a3e81628a974f72b7e4/spring-android-auth/src/main/java/org/springframework/security/crypto/encrypt/AndroidEncryptors.java#L63-L65 |
alkacon/opencms-core | src-gwt/org/opencms/gwt/client/ui/input/colorpicker/CmsColorSelector.java | CmsColorSelector.setHSV | public void setHSV(int hue, int sat, int bri) throws Exception {
"""
Set the Hue, Saturation and Brightness variables.<p>
@param hue angle - valid range is 0-359
@param sat percent - valid range is 0-100
@param bri percent (Brightness) - valid range is 0-100
@throws java.lang.Exception if something goes wrong
"""
CmsColor color = new CmsColor();
color.setHSV(hue, sat, bri);
m_red = color.getRed();
m_green = color.getGreen();
m_blue = color.getBlue();
m_hue = hue;
m_saturation = sat;
m_brightness = bri;
m_tbRed.setText(Integer.toString(m_red));
m_tbGreen.setText(Integer.toString(m_green));
m_tbBlue.setText(Integer.toString(m_blue));
m_tbHue.setText(Integer.toString(m_hue));
m_tbSaturation.setText(Integer.toString(m_saturation));
m_tbBrightness.setText(Integer.toString(m_brightness));
m_tbHexColor.setText(color.getHex());
setPreview(color.getHex());
updateSliders();
} | java | public void setHSV(int hue, int sat, int bri) throws Exception {
CmsColor color = new CmsColor();
color.setHSV(hue, sat, bri);
m_red = color.getRed();
m_green = color.getGreen();
m_blue = color.getBlue();
m_hue = hue;
m_saturation = sat;
m_brightness = bri;
m_tbRed.setText(Integer.toString(m_red));
m_tbGreen.setText(Integer.toString(m_green));
m_tbBlue.setText(Integer.toString(m_blue));
m_tbHue.setText(Integer.toString(m_hue));
m_tbSaturation.setText(Integer.toString(m_saturation));
m_tbBrightness.setText(Integer.toString(m_brightness));
m_tbHexColor.setText(color.getHex());
setPreview(color.getHex());
updateSliders();
} | [
"public",
"void",
"setHSV",
"(",
"int",
"hue",
",",
"int",
"sat",
",",
"int",
"bri",
")",
"throws",
"Exception",
"{",
"CmsColor",
"color",
"=",
"new",
"CmsColor",
"(",
")",
";",
"color",
".",
"setHSV",
"(",
"hue",
",",
"sat",
",",
"bri",
")",
";",
"m_red",
"=",
"color",
".",
"getRed",
"(",
")",
";",
"m_green",
"=",
"color",
".",
"getGreen",
"(",
")",
";",
"m_blue",
"=",
"color",
".",
"getBlue",
"(",
")",
";",
"m_hue",
"=",
"hue",
";",
"m_saturation",
"=",
"sat",
";",
"m_brightness",
"=",
"bri",
";",
"m_tbRed",
".",
"setText",
"(",
"Integer",
".",
"toString",
"(",
"m_red",
")",
")",
";",
"m_tbGreen",
".",
"setText",
"(",
"Integer",
".",
"toString",
"(",
"m_green",
")",
")",
";",
"m_tbBlue",
".",
"setText",
"(",
"Integer",
".",
"toString",
"(",
"m_blue",
")",
")",
";",
"m_tbHue",
".",
"setText",
"(",
"Integer",
".",
"toString",
"(",
"m_hue",
")",
")",
";",
"m_tbSaturation",
".",
"setText",
"(",
"Integer",
".",
"toString",
"(",
"m_saturation",
")",
")",
";",
"m_tbBrightness",
".",
"setText",
"(",
"Integer",
".",
"toString",
"(",
"m_brightness",
")",
")",
";",
"m_tbHexColor",
".",
"setText",
"(",
"color",
".",
"getHex",
"(",
")",
")",
";",
"setPreview",
"(",
"color",
".",
"getHex",
"(",
")",
")",
";",
"updateSliders",
"(",
")",
";",
"}"
] | Set the Hue, Saturation and Brightness variables.<p>
@param hue angle - valid range is 0-359
@param sat percent - valid range is 0-100
@param bri percent (Brightness) - valid range is 0-100
@throws java.lang.Exception if something goes wrong | [
"Set",
"the",
"Hue",
"Saturation",
"and",
"Brightness",
"variables",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/gwt/client/ui/input/colorpicker/CmsColorSelector.java#L754-L776 |
Stratio/stratio-cassandra | src/java/org/apache/cassandra/utils/memory/MemoryUtil.java | MemoryUtil.setBytes | public static void setBytes(long address, byte[] buffer, int bufferOffset, int count) {
"""
Transfers count bytes from buffer to Memory
@param address start offset in the memory
@param buffer the data buffer
@param bufferOffset start offset of the buffer
@param count number of bytes to transfer
"""
assert buffer != null;
assert !(bufferOffset < 0 || count < 0 || bufferOffset + count > buffer.length);
setBytes(buffer, bufferOffset, address, count);
} | java | public static void setBytes(long address, byte[] buffer, int bufferOffset, int count)
{
assert buffer != null;
assert !(bufferOffset < 0 || count < 0 || bufferOffset + count > buffer.length);
setBytes(buffer, bufferOffset, address, count);
} | [
"public",
"static",
"void",
"setBytes",
"(",
"long",
"address",
",",
"byte",
"[",
"]",
"buffer",
",",
"int",
"bufferOffset",
",",
"int",
"count",
")",
"{",
"assert",
"buffer",
"!=",
"null",
";",
"assert",
"!",
"(",
"bufferOffset",
"<",
"0",
"||",
"count",
"<",
"0",
"||",
"bufferOffset",
"+",
"count",
">",
"buffer",
".",
"length",
")",
";",
"setBytes",
"(",
"buffer",
",",
"bufferOffset",
",",
"address",
",",
"count",
")",
";",
"}"
] | Transfers count bytes from buffer to Memory
@param address start offset in the memory
@param buffer the data buffer
@param bufferOffset start offset of the buffer
@param count number of bytes to transfer | [
"Transfers",
"count",
"bytes",
"from",
"buffer",
"to",
"Memory"
] | train | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/utils/memory/MemoryUtil.java#L257-L262 |
liferay/com-liferay-commerce | commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPDefinitionOptionRelPersistenceImpl.java | CPDefinitionOptionRelPersistenceImpl.findByC_SC | @Override
public List<CPDefinitionOptionRel> findByC_SC(long CPDefinitionId,
boolean skuContributor, int start, int end) {
"""
Returns a range of all the cp definition option rels where CPDefinitionId = ? and skuContributor = ?.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CPDefinitionOptionRelModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param CPDefinitionId the cp definition ID
@param skuContributor the sku contributor
@param start the lower bound of the range of cp definition option rels
@param end the upper bound of the range of cp definition option rels (not inclusive)
@return the range of matching cp definition option rels
"""
return findByC_SC(CPDefinitionId, skuContributor, start, end, null);
} | java | @Override
public List<CPDefinitionOptionRel> findByC_SC(long CPDefinitionId,
boolean skuContributor, int start, int end) {
return findByC_SC(CPDefinitionId, skuContributor, start, end, null);
} | [
"@",
"Override",
"public",
"List",
"<",
"CPDefinitionOptionRel",
">",
"findByC_SC",
"(",
"long",
"CPDefinitionId",
",",
"boolean",
"skuContributor",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"return",
"findByC_SC",
"(",
"CPDefinitionId",
",",
"skuContributor",
",",
"start",
",",
"end",
",",
"null",
")",
";",
"}"
] | Returns a range of all the cp definition option rels where CPDefinitionId = ? and skuContributor = ?.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CPDefinitionOptionRelModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param CPDefinitionId the cp definition ID
@param skuContributor the sku contributor
@param start the lower bound of the range of cp definition option rels
@param end the upper bound of the range of cp definition option rels (not inclusive)
@return the range of matching cp definition option rels | [
"Returns",
"a",
"range",
"of",
"all",
"the",
"cp",
"definition",
"option",
"rels",
"where",
"CPDefinitionId",
"=",
"?",
";",
"and",
"skuContributor",
"=",
"?",
";",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPDefinitionOptionRelPersistenceImpl.java#L3313-L3317 |
alibaba/canal | dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/event/RowsLogBuffer.java | RowsLogBuffer.nextOneRow | public final boolean nextOneRow(BitSet columns, boolean after) {
"""
Extracting next row from packed buffer.
@see mysql-5.1.60/sql/log_event.cc -
Rows_log_event::print_verbose_one_row
"""
final boolean hasOneRow = buffer.hasRemaining();
if (hasOneRow) {
int column = 0;
for (int i = 0; i < columnLen; i++)
if (columns.get(i)) {
column++;
}
if (after && partial) {
partialBits.clear();
long valueOptions = buffer.getPackedLong();
int PARTIAL_JSON_UPDATES = 1;
if ((valueOptions & PARTIAL_JSON_UPDATES) != 0) {
partialBits.set(1);
buffer.forward((jsonColumnCount + 7) / 8);
}
}
nullBitIndex = 0;
nullBits.clear();
buffer.fillBitmap(nullBits, column);
}
return hasOneRow;
} | java | public final boolean nextOneRow(BitSet columns, boolean after) {
final boolean hasOneRow = buffer.hasRemaining();
if (hasOneRow) {
int column = 0;
for (int i = 0; i < columnLen; i++)
if (columns.get(i)) {
column++;
}
if (after && partial) {
partialBits.clear();
long valueOptions = buffer.getPackedLong();
int PARTIAL_JSON_UPDATES = 1;
if ((valueOptions & PARTIAL_JSON_UPDATES) != 0) {
partialBits.set(1);
buffer.forward((jsonColumnCount + 7) / 8);
}
}
nullBitIndex = 0;
nullBits.clear();
buffer.fillBitmap(nullBits, column);
}
return hasOneRow;
} | [
"public",
"final",
"boolean",
"nextOneRow",
"(",
"BitSet",
"columns",
",",
"boolean",
"after",
")",
"{",
"final",
"boolean",
"hasOneRow",
"=",
"buffer",
".",
"hasRemaining",
"(",
")",
";",
"if",
"(",
"hasOneRow",
")",
"{",
"int",
"column",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"columnLen",
";",
"i",
"++",
")",
"if",
"(",
"columns",
".",
"get",
"(",
"i",
")",
")",
"{",
"column",
"++",
";",
"}",
"if",
"(",
"after",
"&&",
"partial",
")",
"{",
"partialBits",
".",
"clear",
"(",
")",
";",
"long",
"valueOptions",
"=",
"buffer",
".",
"getPackedLong",
"(",
")",
";",
"int",
"PARTIAL_JSON_UPDATES",
"=",
"1",
";",
"if",
"(",
"(",
"valueOptions",
"&",
"PARTIAL_JSON_UPDATES",
")",
"!=",
"0",
")",
"{",
"partialBits",
".",
"set",
"(",
"1",
")",
";",
"buffer",
".",
"forward",
"(",
"(",
"jsonColumnCount",
"+",
"7",
")",
"/",
"8",
")",
";",
"}",
"}",
"nullBitIndex",
"=",
"0",
";",
"nullBits",
".",
"clear",
"(",
")",
";",
"buffer",
".",
"fillBitmap",
"(",
"nullBits",
",",
"column",
")",
";",
"}",
"return",
"hasOneRow",
";",
"}"
] | Extracting next row from packed buffer.
@see mysql-5.1.60/sql/log_event.cc -
Rows_log_event::print_verbose_one_row | [
"Extracting",
"next",
"row",
"from",
"packed",
"buffer",
"."
] | train | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/event/RowsLogBuffer.java#L70-L96 |
kstateome/canvas-api | src/main/java/edu/ksu/canvas/CanvasApiFactory.java | CanvasApiFactory.getWriter | public <T extends CanvasWriter> T getWriter(Class<T> type, OauthToken oauthToken) {
"""
Get a writer implementation to push data into Canvas.
@param type Interface type you wish to get an implementation for
@param oauthToken An OAuth token to use for authentication when making API calls
@param <T> A writer implementation
@return A writer implementation class
"""
return getWriter(type, oauthToken, false);
} | java | public <T extends CanvasWriter> T getWriter(Class<T> type, OauthToken oauthToken) {
return getWriter(type, oauthToken, false);
} | [
"public",
"<",
"T",
"extends",
"CanvasWriter",
">",
"T",
"getWriter",
"(",
"Class",
"<",
"T",
">",
"type",
",",
"OauthToken",
"oauthToken",
")",
"{",
"return",
"getWriter",
"(",
"type",
",",
"oauthToken",
",",
"false",
")",
";",
"}"
] | Get a writer implementation to push data into Canvas.
@param type Interface type you wish to get an implementation for
@param oauthToken An OAuth token to use for authentication when making API calls
@param <T> A writer implementation
@return A writer implementation class | [
"Get",
"a",
"writer",
"implementation",
"to",
"push",
"data",
"into",
"Canvas",
"."
] | train | https://github.com/kstateome/canvas-api/blob/426bf403a8fd7aca3f170348005feda25b374e5a/src/main/java/edu/ksu/canvas/CanvasApiFactory.java#L112-L114 |
lightoze/gwt-i18n-server | src/main/java/net/lightoze/gwt/i18n/client/LocaleFactory.java | LocaleFactory.getEncoder | public static <T extends Messages> T getEncoder(Class<T> cls) {
"""
Get <em>encoding</em> localization object, which will encode all requests so that they can be decoded later by {@link net.lightoze.gwt.i18n.server.LocaleProxy#decode}.
<p>
The purpose is to separate complex (e.g. template-based) text generation and its localization for particular locale into two separate phases.
<p>
<strong>Supported only on server side.</strong>
@param cls localization interface class
@param <T> localization interface class
@return object implementing specified class
"""
return get(cls, ENCODER);
} | java | public static <T extends Messages> T getEncoder(Class<T> cls) {
return get(cls, ENCODER);
} | [
"public",
"static",
"<",
"T",
"extends",
"Messages",
">",
"T",
"getEncoder",
"(",
"Class",
"<",
"T",
">",
"cls",
")",
"{",
"return",
"get",
"(",
"cls",
",",
"ENCODER",
")",
";",
"}"
] | Get <em>encoding</em> localization object, which will encode all requests so that they can be decoded later by {@link net.lightoze.gwt.i18n.server.LocaleProxy#decode}.
<p>
The purpose is to separate complex (e.g. template-based) text generation and its localization for particular locale into two separate phases.
<p>
<strong>Supported only on server side.</strong>
@param cls localization interface class
@param <T> localization interface class
@return object implementing specified class | [
"Get",
"<em",
">",
"encoding<",
"/",
"em",
">",
"localization",
"object",
"which",
"will",
"encode",
"all",
"requests",
"so",
"that",
"they",
"can",
"be",
"decoded",
"later",
"by",
"{",
"@link",
"net",
".",
"lightoze",
".",
"gwt",
".",
"i18n",
".",
"server",
".",
"LocaleProxy#decode",
"}",
".",
"<p",
">",
"The",
"purpose",
"is",
"to",
"separate",
"complex",
"(",
"e",
".",
"g",
".",
"template",
"-",
"based",
")",
"text",
"generation",
"and",
"its",
"localization",
"for",
"particular",
"locale",
"into",
"two",
"separate",
"phases",
".",
"<p",
">",
"<strong",
">",
"Supported",
"only",
"on",
"server",
"side",
".",
"<",
"/",
"strong",
">"
] | train | https://github.com/lightoze/gwt-i18n-server/blob/96de53288e9bf31721d7b0e2a1d9f7b6ce1a7e83/src/main/java/net/lightoze/gwt/i18n/client/LocaleFactory.java#L46-L48 |
apache/incubator-gobblin | gobblin-api/src/main/java/org/apache/gobblin/source/workunit/WorkUnit.java | WorkUnit.getExpectedHighWatermark | public <T extends Watermark> T getExpectedHighWatermark(Class<T> watermarkClass) {
"""
Get the expected high {@link Watermark}. A default {@link Gson} object will be used to deserialize the watermark.
@param watermarkClass the watermark class for this {@code WorkUnit}.
@return the expected high watermark in this {@code WorkUnit}.
"""
return getExpectedHighWatermark(watermarkClass, GSON);
} | java | public <T extends Watermark> T getExpectedHighWatermark(Class<T> watermarkClass) {
return getExpectedHighWatermark(watermarkClass, GSON);
} | [
"public",
"<",
"T",
"extends",
"Watermark",
">",
"T",
"getExpectedHighWatermark",
"(",
"Class",
"<",
"T",
">",
"watermarkClass",
")",
"{",
"return",
"getExpectedHighWatermark",
"(",
"watermarkClass",
",",
"GSON",
")",
";",
"}"
] | Get the expected high {@link Watermark}. A default {@link Gson} object will be used to deserialize the watermark.
@param watermarkClass the watermark class for this {@code WorkUnit}.
@return the expected high watermark in this {@code WorkUnit}. | [
"Get",
"the",
"expected",
"high",
"{",
"@link",
"Watermark",
"}",
".",
"A",
"default",
"{",
"@link",
"Gson",
"}",
"object",
"will",
"be",
"used",
"to",
"deserialize",
"the",
"watermark",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-api/src/main/java/org/apache/gobblin/source/workunit/WorkUnit.java#L263-L265 |
aws/aws-sdk-java | aws-java-sdk-servicecatalog/src/main/java/com/amazonaws/services/servicecatalog/model/ServiceActionDetail.java | ServiceActionDetail.withDefinition | public ServiceActionDetail withDefinition(java.util.Map<String, String> definition) {
"""
<p>
A map that defines the self-service action.
</p>
@param definition
A map that defines the self-service action.
@return Returns a reference to this object so that method calls can be chained together.
"""
setDefinition(definition);
return this;
} | java | public ServiceActionDetail withDefinition(java.util.Map<String, String> definition) {
setDefinition(definition);
return this;
} | [
"public",
"ServiceActionDetail",
"withDefinition",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"definition",
")",
"{",
"setDefinition",
"(",
"definition",
")",
";",
"return",
"this",
";",
"}"
] | <p>
A map that defines the self-service action.
</p>
@param definition
A map that defines the self-service action.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"A",
"map",
"that",
"defines",
"the",
"self",
"-",
"service",
"action",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-servicecatalog/src/main/java/com/amazonaws/services/servicecatalog/model/ServiceActionDetail.java#L119-L122 |
lecho/hellocharts-android | hellocharts-library/src/lecho/lib/hellocharts/renderer/LineChartRenderer.java | LineChartRenderer.drawPath | private void drawPath(Canvas canvas, final Line line) {
"""
Draws lines, uses path for drawing filled area on software canvas. Line is drawn with canvas.drawLines() method.
"""
prepareLinePaint(line);
int valueIndex = 0;
for (PointValue pointValue : line.getValues()) {
final float rawX = computator.computeRawX(pointValue.getX());
final float rawY = computator.computeRawY(pointValue.getY());
if (valueIndex == 0) {
path.moveTo(rawX, rawY);
} else {
path.lineTo(rawX, rawY);
}
++valueIndex;
}
canvas.drawPath(path, linePaint);
if (line.isFilled()) {
drawArea(canvas, line);
}
path.reset();
} | java | private void drawPath(Canvas canvas, final Line line) {
prepareLinePaint(line);
int valueIndex = 0;
for (PointValue pointValue : line.getValues()) {
final float rawX = computator.computeRawX(pointValue.getX());
final float rawY = computator.computeRawY(pointValue.getY());
if (valueIndex == 0) {
path.moveTo(rawX, rawY);
} else {
path.lineTo(rawX, rawY);
}
++valueIndex;
}
canvas.drawPath(path, linePaint);
if (line.isFilled()) {
drawArea(canvas, line);
}
path.reset();
} | [
"private",
"void",
"drawPath",
"(",
"Canvas",
"canvas",
",",
"final",
"Line",
"line",
")",
"{",
"prepareLinePaint",
"(",
"line",
")",
";",
"int",
"valueIndex",
"=",
"0",
";",
"for",
"(",
"PointValue",
"pointValue",
":",
"line",
".",
"getValues",
"(",
")",
")",
"{",
"final",
"float",
"rawX",
"=",
"computator",
".",
"computeRawX",
"(",
"pointValue",
".",
"getX",
"(",
")",
")",
";",
"final",
"float",
"rawY",
"=",
"computator",
".",
"computeRawY",
"(",
"pointValue",
".",
"getY",
"(",
")",
")",
";",
"if",
"(",
"valueIndex",
"==",
"0",
")",
"{",
"path",
".",
"moveTo",
"(",
"rawX",
",",
"rawY",
")",
";",
"}",
"else",
"{",
"path",
".",
"lineTo",
"(",
"rawX",
",",
"rawY",
")",
";",
"}",
"++",
"valueIndex",
";",
"}",
"canvas",
".",
"drawPath",
"(",
"path",
",",
"linePaint",
")",
";",
"if",
"(",
"line",
".",
"isFilled",
"(",
")",
")",
"{",
"drawArea",
"(",
"canvas",
",",
"line",
")",
";",
"}",
"path",
".",
"reset",
"(",
")",
";",
"}"
] | Draws lines, uses path for drawing filled area on software canvas. Line is drawn with canvas.drawLines() method. | [
"Draws",
"lines",
"uses",
"path",
"for",
"drawing",
"filled",
"area",
"on",
"software",
"canvas",
".",
"Line",
"is",
"drawn",
"with",
"canvas",
".",
"drawLines",
"()",
"method",
"."
] | train | https://github.com/lecho/hellocharts-android/blob/c41419c9afa097452dee823c7eba0e5136aa96bd/hellocharts-library/src/lecho/lib/hellocharts/renderer/LineChartRenderer.java#L216-L242 |
gmessner/gitlab4j-api | src/main/java/org/gitlab4j/api/AbstractApi.java | AbstractApi.addFormParam | protected void addFormParam(Form formData, String name, Object value, boolean required) throws IllegalArgumentException {
"""
Convenience method for adding query and form parameters to a get() or post() call.
If required is true and value is null, will throw an IllegalArgumentException.
@param formData the Form containing the name/value pairs
@param name the name of the field/attribute to add
@param value the value of the field/attribute to add
@param required the field is required flag
@throws IllegalArgumentException if a required parameter is null or empty
"""
if (value == null) {
if (required) {
throw new IllegalArgumentException(name + " cannot be empty or null");
}
return;
}
String stringValue = value.toString();
if (required && stringValue.trim().length() == 0) {
throw new IllegalArgumentException(name + " cannot be empty or null");
}
formData.param(name, stringValue);
} | java | protected void addFormParam(Form formData, String name, Object value, boolean required) throws IllegalArgumentException {
if (value == null) {
if (required) {
throw new IllegalArgumentException(name + " cannot be empty or null");
}
return;
}
String stringValue = value.toString();
if (required && stringValue.trim().length() == 0) {
throw new IllegalArgumentException(name + " cannot be empty or null");
}
formData.param(name, stringValue);
} | [
"protected",
"void",
"addFormParam",
"(",
"Form",
"formData",
",",
"String",
"name",
",",
"Object",
"value",
",",
"boolean",
"required",
")",
"throws",
"IllegalArgumentException",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"if",
"(",
"required",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"name",
"+",
"\" cannot be empty or null\"",
")",
";",
"}",
"return",
";",
"}",
"String",
"stringValue",
"=",
"value",
".",
"toString",
"(",
")",
";",
"if",
"(",
"required",
"&&",
"stringValue",
".",
"trim",
"(",
")",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"name",
"+",
"\" cannot be empty or null\"",
")",
";",
"}",
"formData",
".",
"param",
"(",
"name",
",",
"stringValue",
")",
";",
"}"
] | Convenience method for adding query and form parameters to a get() or post() call.
If required is true and value is null, will throw an IllegalArgumentException.
@param formData the Form containing the name/value pairs
@param name the name of the field/attribute to add
@param value the value of the field/attribute to add
@param required the field is required flag
@throws IllegalArgumentException if a required parameter is null or empty | [
"Convenience",
"method",
"for",
"adding",
"query",
"and",
"form",
"parameters",
"to",
"a",
"get",
"()",
"or",
"post",
"()",
"call",
".",
"If",
"required",
"is",
"true",
"and",
"value",
"is",
"null",
"will",
"throw",
"an",
"IllegalArgumentException",
"."
] | train | https://github.com/gmessner/gitlab4j-api/blob/ab045070abac0a8f4ccbf17b5ed9bfdef5723eed/src/main/java/org/gitlab4j/api/AbstractApi.java#L555-L572 |
spotify/helios | helios-client/src/main/java/com/spotify/helios/client/HeliosClient.java | HeliosClient.listHosts | public ListenableFuture<List<String>> listHosts(final String namePattern) {
"""
Returns a list of all hosts registered in the Helios cluster whose name matches the given
pattern.
"""
return listHosts(ImmutableMultimap.of("namePattern", namePattern));
} | java | public ListenableFuture<List<String>> listHosts(final String namePattern) {
return listHosts(ImmutableMultimap.of("namePattern", namePattern));
} | [
"public",
"ListenableFuture",
"<",
"List",
"<",
"String",
">",
">",
"listHosts",
"(",
"final",
"String",
"namePattern",
")",
"{",
"return",
"listHosts",
"(",
"ImmutableMultimap",
".",
"of",
"(",
"\"namePattern\"",
",",
"namePattern",
")",
")",
";",
"}"
] | Returns a list of all hosts registered in the Helios cluster whose name matches the given
pattern. | [
"Returns",
"a",
"list",
"of",
"all",
"hosts",
"registered",
"in",
"the",
"Helios",
"cluster",
"whose",
"name",
"matches",
"the",
"given",
"pattern",
"."
] | train | https://github.com/spotify/helios/blob/c9000bc1d6908651570be8b057d4981bba4df5b4/helios-client/src/main/java/com/spotify/helios/client/HeliosClient.java#L374-L376 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/matchspace/selector/impl/TopicPattern.java | TopicPattern.topicSkipBackward | static boolean topicSkipBackward(char[] chars, int[] cursor) {
"""
Skip backward to the next separator character
@param chars the characters to be examined
@param cursor the int[2] { start, end } "cursor" describing the area to be examined
@return true if something was skipped, false if nothing could be skipped
"""
if (cursor[0] == cursor[1])
return false;
while (cursor[0] < cursor[1] &&
chars[cursor[1]-1] != MatchSpace.SUBTOPIC_SEPARATOR_CHAR)
cursor[1]--;
return true;
} | java | static boolean topicSkipBackward(char[] chars, int[] cursor) {
if (cursor[0] == cursor[1])
return false;
while (cursor[0] < cursor[1] &&
chars[cursor[1]-1] != MatchSpace.SUBTOPIC_SEPARATOR_CHAR)
cursor[1]--;
return true;
} | [
"static",
"boolean",
"topicSkipBackward",
"(",
"char",
"[",
"]",
"chars",
",",
"int",
"[",
"]",
"cursor",
")",
"{",
"if",
"(",
"cursor",
"[",
"0",
"]",
"==",
"cursor",
"[",
"1",
"]",
")",
"return",
"false",
";",
"while",
"(",
"cursor",
"[",
"0",
"]",
"<",
"cursor",
"[",
"1",
"]",
"&&",
"chars",
"[",
"cursor",
"[",
"1",
"]",
"-",
"1",
"]",
"!=",
"MatchSpace",
".",
"SUBTOPIC_SEPARATOR_CHAR",
")",
"cursor",
"[",
"1",
"]",
"--",
";",
"return",
"true",
";",
"}"
] | Skip backward to the next separator character
@param chars the characters to be examined
@param cursor the int[2] { start, end } "cursor" describing the area to be examined
@return true if something was skipped, false if nothing could be skipped | [
"Skip",
"backward",
"to",
"the",
"next",
"separator",
"character"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/matchspace/selector/impl/TopicPattern.java#L102-L109 |
netscaler/nitro | src/main/java/com/citrix/netscaler/nitro/resource/stat/appfw/appfwpolicylabel_stats.java | appfwpolicylabel_stats.get | public static appfwpolicylabel_stats get(nitro_service service, String labelname) throws Exception {
"""
Use this API to fetch statistics of appfwpolicylabel_stats resource of given name .
"""
appfwpolicylabel_stats obj = new appfwpolicylabel_stats();
obj.set_labelname(labelname);
appfwpolicylabel_stats response = (appfwpolicylabel_stats) obj.stat_resource(service);
return response;
} | java | public static appfwpolicylabel_stats get(nitro_service service, String labelname) throws Exception{
appfwpolicylabel_stats obj = new appfwpolicylabel_stats();
obj.set_labelname(labelname);
appfwpolicylabel_stats response = (appfwpolicylabel_stats) obj.stat_resource(service);
return response;
} | [
"public",
"static",
"appfwpolicylabel_stats",
"get",
"(",
"nitro_service",
"service",
",",
"String",
"labelname",
")",
"throws",
"Exception",
"{",
"appfwpolicylabel_stats",
"obj",
"=",
"new",
"appfwpolicylabel_stats",
"(",
")",
";",
"obj",
".",
"set_labelname",
"(",
"labelname",
")",
";",
"appfwpolicylabel_stats",
"response",
"=",
"(",
"appfwpolicylabel_stats",
")",
"obj",
".",
"stat_resource",
"(",
"service",
")",
";",
"return",
"response",
";",
"}"
] | Use this API to fetch statistics of appfwpolicylabel_stats resource of given name . | [
"Use",
"this",
"API",
"to",
"fetch",
"statistics",
"of",
"appfwpolicylabel_stats",
"resource",
"of",
"given",
"name",
"."
] | train | https://github.com/netscaler/nitro/blob/2a98692dcf4e4ec430c7d7baab8382e4ba5a35e4/src/main/java/com/citrix/netscaler/nitro/resource/stat/appfw/appfwpolicylabel_stats.java#L149-L154 |
line/armeria | core/src/main/java/com/linecorp/armeria/client/AbstractClientOptionsBuilder.java | AbstractClientOptionsBuilder.rpcDecorator | public <T extends Client<I, O>, R extends Client<I, O>, I extends RpcRequest, O extends RpcResponse>
B rpcDecorator(Function<T, R> decorator) {
"""
Adds the specified RPC-level {@code decorator}.
@param decorator the {@link Function} that transforms a {@link Client} to another
@param <T> the type of the {@link Client} being decorated
@param <R> the type of the {@link Client} produced by the {@code decorator}
@param <I> the {@link Request} type of the {@link Client} being decorated
@param <O> the {@link Response} type of the {@link Client} being decorated
"""
decoration.addRpc(decorator);
return self();
} | java | public <T extends Client<I, O>, R extends Client<I, O>, I extends RpcRequest, O extends RpcResponse>
B rpcDecorator(Function<T, R> decorator) {
decoration.addRpc(decorator);
return self();
} | [
"public",
"<",
"T",
"extends",
"Client",
"<",
"I",
",",
"O",
">",
",",
"R",
"extends",
"Client",
"<",
"I",
",",
"O",
">",
",",
"I",
"extends",
"RpcRequest",
",",
"O",
"extends",
"RpcResponse",
">",
"B",
"rpcDecorator",
"(",
"Function",
"<",
"T",
",",
"R",
">",
"decorator",
")",
"{",
"decoration",
".",
"addRpc",
"(",
"decorator",
")",
";",
"return",
"self",
"(",
")",
";",
"}"
] | Adds the specified RPC-level {@code decorator}.
@param decorator the {@link Function} that transforms a {@link Client} to another
@param <T> the type of the {@link Client} being decorated
@param <R> the type of the {@link Client} produced by the {@code decorator}
@param <I> the {@link Request} type of the {@link Client} being decorated
@param <O> the {@link Response} type of the {@link Client} being decorated | [
"Adds",
"the",
"specified",
"RPC",
"-",
"level",
"{",
"@code",
"decorator",
"}",
"."
] | train | https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/client/AbstractClientOptionsBuilder.java#L311-L315 |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java | DBAdapter.storeUserProfile | synchronized long storeUserProfile(String id, JSONObject obj) {
"""
Adds a JSON string representing to the DB.
@param obj the JSON to record
@return the number of rows in the table, or DB_OUT_OF_MEMORY_ERROR/DB_UPDATE_ERROR
"""
if (id == null) return DB_UPDATE_ERROR;
if (!this.belowMemThreshold()) {
getConfigLogger().verbose("There is not enough space left on the device to store data, data discarded");
return DB_OUT_OF_MEMORY_ERROR;
}
final String tableName = Table.USER_PROFILES.getName();
long ret = DB_UPDATE_ERROR;
try {
final SQLiteDatabase db = dbHelper.getWritableDatabase();
final ContentValues cv = new ContentValues();
cv.put(KEY_DATA, obj.toString());
cv.put("_id", id);
ret = db.insertWithOnConflict(tableName, null, cv, SQLiteDatabase.CONFLICT_REPLACE);
} catch (final SQLiteException e) {
getConfigLogger().verbose("Error adding data to table " + tableName + " Recreating DB");
dbHelper.deleteDatabase();
} finally {
dbHelper.close();
}
return ret;
} | java | synchronized long storeUserProfile(String id, JSONObject obj) {
if (id == null) return DB_UPDATE_ERROR;
if (!this.belowMemThreshold()) {
getConfigLogger().verbose("There is not enough space left on the device to store data, data discarded");
return DB_OUT_OF_MEMORY_ERROR;
}
final String tableName = Table.USER_PROFILES.getName();
long ret = DB_UPDATE_ERROR;
try {
final SQLiteDatabase db = dbHelper.getWritableDatabase();
final ContentValues cv = new ContentValues();
cv.put(KEY_DATA, obj.toString());
cv.put("_id", id);
ret = db.insertWithOnConflict(tableName, null, cv, SQLiteDatabase.CONFLICT_REPLACE);
} catch (final SQLiteException e) {
getConfigLogger().verbose("Error adding data to table " + tableName + " Recreating DB");
dbHelper.deleteDatabase();
} finally {
dbHelper.close();
}
return ret;
} | [
"synchronized",
"long",
"storeUserProfile",
"(",
"String",
"id",
",",
"JSONObject",
"obj",
")",
"{",
"if",
"(",
"id",
"==",
"null",
")",
"return",
"DB_UPDATE_ERROR",
";",
"if",
"(",
"!",
"this",
".",
"belowMemThreshold",
"(",
")",
")",
"{",
"getConfigLogger",
"(",
")",
".",
"verbose",
"(",
"\"There is not enough space left on the device to store data, data discarded\"",
")",
";",
"return",
"DB_OUT_OF_MEMORY_ERROR",
";",
"}",
"final",
"String",
"tableName",
"=",
"Table",
".",
"USER_PROFILES",
".",
"getName",
"(",
")",
";",
"long",
"ret",
"=",
"DB_UPDATE_ERROR",
";",
"try",
"{",
"final",
"SQLiteDatabase",
"db",
"=",
"dbHelper",
".",
"getWritableDatabase",
"(",
")",
";",
"final",
"ContentValues",
"cv",
"=",
"new",
"ContentValues",
"(",
")",
";",
"cv",
".",
"put",
"(",
"KEY_DATA",
",",
"obj",
".",
"toString",
"(",
")",
")",
";",
"cv",
".",
"put",
"(",
"\"_id\"",
",",
"id",
")",
";",
"ret",
"=",
"db",
".",
"insertWithOnConflict",
"(",
"tableName",
",",
"null",
",",
"cv",
",",
"SQLiteDatabase",
".",
"CONFLICT_REPLACE",
")",
";",
"}",
"catch",
"(",
"final",
"SQLiteException",
"e",
")",
"{",
"getConfigLogger",
"(",
")",
".",
"verbose",
"(",
"\"Error adding data to table \"",
"+",
"tableName",
"+",
"\" Recreating DB\"",
")",
";",
"dbHelper",
".",
"deleteDatabase",
"(",
")",
";",
"}",
"finally",
"{",
"dbHelper",
".",
"close",
"(",
")",
";",
"}",
"return",
"ret",
";",
"}"
] | Adds a JSON string representing to the DB.
@param obj the JSON to record
@return the number of rows in the table, or DB_OUT_OF_MEMORY_ERROR/DB_UPDATE_ERROR | [
"Adds",
"a",
"JSON",
"string",
"representing",
"to",
"the",
"DB",
"."
] | train | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java#L254-L280 |
biojava/biojava | biojava-structure-gui/src/main/java/demo/DemoShowLargeAssembly.java | DemoShowLargeAssembly.readStructure | public static Structure readStructure(String pdbId, int bioAssemblyId) {
"""
Load a specific biological assembly for a PDB entry
@param pdbId .. the PDB ID
@param bioAssemblyId .. the first assembly has the bioAssemblyId 1
@return a Structure object or null if something went wrong.
"""
// pre-computed files use lower case PDB IDs
pdbId = pdbId.toLowerCase();
// we just need this to track where to store PDB files
// this checks the PDB_DIR property (and uses a tmp location if not set)
AtomCache cache = new AtomCache();
cache.setUseMmCif(true);
FileParsingParameters p = cache.getFileParsingParams();
// some bio assemblies are large, we want an all atom representation and avoid
// switching to a Calpha-only representation for large molecules
// note, this requires several GB of memory for some of the largest assemblies, such a 1MX4
p.setAtomCaThreshold(Integer.MAX_VALUE);
// parse remark 350
p.setParseBioAssembly(true);
// download missing files
Structure structure = null;
try {
structure = StructureIO.getBiologicalAssembly(pdbId,bioAssemblyId);
} catch (Exception e){
e.printStackTrace();
return null;
}
return structure;
} | java | public static Structure readStructure(String pdbId, int bioAssemblyId) {
// pre-computed files use lower case PDB IDs
pdbId = pdbId.toLowerCase();
// we just need this to track where to store PDB files
// this checks the PDB_DIR property (and uses a tmp location if not set)
AtomCache cache = new AtomCache();
cache.setUseMmCif(true);
FileParsingParameters p = cache.getFileParsingParams();
// some bio assemblies are large, we want an all atom representation and avoid
// switching to a Calpha-only representation for large molecules
// note, this requires several GB of memory for some of the largest assemblies, such a 1MX4
p.setAtomCaThreshold(Integer.MAX_VALUE);
// parse remark 350
p.setParseBioAssembly(true);
// download missing files
Structure structure = null;
try {
structure = StructureIO.getBiologicalAssembly(pdbId,bioAssemblyId);
} catch (Exception e){
e.printStackTrace();
return null;
}
return structure;
} | [
"public",
"static",
"Structure",
"readStructure",
"(",
"String",
"pdbId",
",",
"int",
"bioAssemblyId",
")",
"{",
"// pre-computed files use lower case PDB IDs",
"pdbId",
"=",
"pdbId",
".",
"toLowerCase",
"(",
")",
";",
"// we just need this to track where to store PDB files",
"// this checks the PDB_DIR property (and uses a tmp location if not set)",
"AtomCache",
"cache",
"=",
"new",
"AtomCache",
"(",
")",
";",
"cache",
".",
"setUseMmCif",
"(",
"true",
")",
";",
"FileParsingParameters",
"p",
"=",
"cache",
".",
"getFileParsingParams",
"(",
")",
";",
"// some bio assemblies are large, we want an all atom representation and avoid",
"// switching to a Calpha-only representation for large molecules",
"// note, this requires several GB of memory for some of the largest assemblies, such a 1MX4",
"p",
".",
"setAtomCaThreshold",
"(",
"Integer",
".",
"MAX_VALUE",
")",
";",
"// parse remark 350",
"p",
".",
"setParseBioAssembly",
"(",
"true",
")",
";",
"// download missing files",
"Structure",
"structure",
"=",
"null",
";",
"try",
"{",
"structure",
"=",
"StructureIO",
".",
"getBiologicalAssembly",
"(",
"pdbId",
",",
"bioAssemblyId",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"return",
"null",
";",
"}",
"return",
"structure",
";",
"}"
] | Load a specific biological assembly for a PDB entry
@param pdbId .. the PDB ID
@param bioAssemblyId .. the first assembly has the bioAssemblyId 1
@return a Structure object or null if something went wrong. | [
"Load",
"a",
"specific",
"biological",
"assembly",
"for",
"a",
"PDB",
"entry"
] | train | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure-gui/src/main/java/demo/DemoShowLargeAssembly.java#L72-L101 |
PeterisP/LVTagger | src/main/java/edu/stanford/nlp/ling/Sentence.java | Sentence.extractNgram | public static <T> String extractNgram(List<T> list, int start, int end) {
"""
Returns the substring of the sentence from start (inclusive)
to end (exclusive).
@param start Leftmost index of the substring
@param end Rightmost index of the ngram
@return The ngram as a String
"""
if (start < 0 || end > list.size() || start >= end) return null;
final StringBuilder sb = new StringBuilder();
// TODO: iterator
for (int i = start; i < end; i++) {
T o = list.get(i);
if (sb.length() != 0) sb.append(" ");
sb.append((o instanceof HasWord) ? ((HasWord) o).word() : o.toString());
}
return sb.toString();
} | java | public static <T> String extractNgram(List<T> list, int start, int end) {
if (start < 0 || end > list.size() || start >= end) return null;
final StringBuilder sb = new StringBuilder();
// TODO: iterator
for (int i = start; i < end; i++) {
T o = list.get(i);
if (sb.length() != 0) sb.append(" ");
sb.append((o instanceof HasWord) ? ((HasWord) o).word() : o.toString());
}
return sb.toString();
} | [
"public",
"static",
"<",
"T",
">",
"String",
"extractNgram",
"(",
"List",
"<",
"T",
">",
"list",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"if",
"(",
"start",
"<",
"0",
"||",
"end",
">",
"list",
".",
"size",
"(",
")",
"||",
"start",
">=",
"end",
")",
"return",
"null",
";",
"final",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"// TODO: iterator\r",
"for",
"(",
"int",
"i",
"=",
"start",
";",
"i",
"<",
"end",
";",
"i",
"++",
")",
"{",
"T",
"o",
"=",
"list",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"sb",
".",
"length",
"(",
")",
"!=",
"0",
")",
"sb",
".",
"append",
"(",
"\" \"",
")",
";",
"sb",
".",
"append",
"(",
"(",
"o",
"instanceof",
"HasWord",
")",
"?",
"(",
"(",
"HasWord",
")",
"o",
")",
".",
"word",
"(",
")",
":",
"o",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] | Returns the substring of the sentence from start (inclusive)
to end (exclusive).
@param start Leftmost index of the substring
@param end Rightmost index of the ngram
@return The ngram as a String | [
"Returns",
"the",
"substring",
"of",
"the",
"sentence",
"from",
"start",
"(",
"inclusive",
")",
"to",
"end",
"(",
"exclusive",
")",
"."
] | train | https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/ling/Sentence.java#L222-L232 |
BioPAX/Paxtools | paxtools-core/src/main/java/org/biopax/paxtools/io/SimpleIOHandler.java | SimpleIOHandler.writeObject | public void writeObject(Writer out, BioPAXElement bean) throws IOException {
"""
Writes the XML representation of individual BioPAX element that
is BioPAX-like but only for display or debug purpose (incomplete).
Note: use {@link BioPAXIOHandler#convertToOWL(org.biopax.paxtools.model.Model, java.io.OutputStream)}
convertToOWL(org.biopax.paxtools.model.Model, Object)} instead
if you have a model and want to save and later restore it.
@param out output
@param bean BioPAX object
@throws IOException when the output writer throws
"""
String name = "bp:" + bean.getModelInterface().getSimpleName();
writeIDLine(out, bean, name);
Set<PropertyEditor> editors = editorMap.getEditorsOf(bean);
if (editors == null || editors.isEmpty())
{
log.info("no editors for " + bean.getUri() + " | " + bean.getModelInterface().getSimpleName());
out.write(newline + "</" + name + ">");
return;
}
for (PropertyEditor editor : editors)
{
Set value = editor.getValueFromBean(bean); //is never null
for (Object valueElement : value)
{
if (!editor.isUnknown(valueElement)) writeStatementFor(bean, editor, valueElement, out);
}
}
out.write(newline + "</" + name + ">");
} | java | public void writeObject(Writer out, BioPAXElement bean) throws IOException
{
String name = "bp:" + bean.getModelInterface().getSimpleName();
writeIDLine(out, bean, name);
Set<PropertyEditor> editors = editorMap.getEditorsOf(bean);
if (editors == null || editors.isEmpty())
{
log.info("no editors for " + bean.getUri() + " | " + bean.getModelInterface().getSimpleName());
out.write(newline + "</" + name + ">");
return;
}
for (PropertyEditor editor : editors)
{
Set value = editor.getValueFromBean(bean); //is never null
for (Object valueElement : value)
{
if (!editor.isUnknown(valueElement)) writeStatementFor(bean, editor, valueElement, out);
}
}
out.write(newline + "</" + name + ">");
} | [
"public",
"void",
"writeObject",
"(",
"Writer",
"out",
",",
"BioPAXElement",
"bean",
")",
"throws",
"IOException",
"{",
"String",
"name",
"=",
"\"bp:\"",
"+",
"bean",
".",
"getModelInterface",
"(",
")",
".",
"getSimpleName",
"(",
")",
";",
"writeIDLine",
"(",
"out",
",",
"bean",
",",
"name",
")",
";",
"Set",
"<",
"PropertyEditor",
">",
"editors",
"=",
"editorMap",
".",
"getEditorsOf",
"(",
"bean",
")",
";",
"if",
"(",
"editors",
"==",
"null",
"||",
"editors",
".",
"isEmpty",
"(",
")",
")",
"{",
"log",
".",
"info",
"(",
"\"no editors for \"",
"+",
"bean",
".",
"getUri",
"(",
")",
"+",
"\" | \"",
"+",
"bean",
".",
"getModelInterface",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
";",
"out",
".",
"write",
"(",
"newline",
"+",
"\"</\"",
"+",
"name",
"+",
"\">\"",
")",
";",
"return",
";",
"}",
"for",
"(",
"PropertyEditor",
"editor",
":",
"editors",
")",
"{",
"Set",
"value",
"=",
"editor",
".",
"getValueFromBean",
"(",
"bean",
")",
";",
"//is never null",
"for",
"(",
"Object",
"valueElement",
":",
"value",
")",
"{",
"if",
"(",
"!",
"editor",
".",
"isUnknown",
"(",
"valueElement",
")",
")",
"writeStatementFor",
"(",
"bean",
",",
"editor",
",",
"valueElement",
",",
"out",
")",
";",
"}",
"}",
"out",
".",
"write",
"(",
"newline",
"+",
"\"</\"",
"+",
"name",
"+",
"\">\"",
")",
";",
"}"
] | Writes the XML representation of individual BioPAX element that
is BioPAX-like but only for display or debug purpose (incomplete).
Note: use {@link BioPAXIOHandler#convertToOWL(org.biopax.paxtools.model.Model, java.io.OutputStream)}
convertToOWL(org.biopax.paxtools.model.Model, Object)} instead
if you have a model and want to save and later restore it.
@param out output
@param bean BioPAX object
@throws IOException when the output writer throws | [
"Writes",
"the",
"XML",
"representation",
"of",
"individual",
"BioPAX",
"element",
"that",
"is",
"BioPAX",
"-",
"like",
"but",
"only",
"for",
"display",
"or",
"debug",
"purpose",
"(",
"incomplete",
")",
"."
] | train | https://github.com/BioPAX/Paxtools/blob/2f93afa94426bf8b5afc2e0e61cd4b269a83288d/paxtools-core/src/main/java/org/biopax/paxtools/io/SimpleIOHandler.java#L589-L612 |
kiegroup/jbpm | jbpm-bpmn2-emfextmodel/src/main/java/org/omg/spec/bpmn/non/normative/color/impl/ColorPackageImpl.java | ColorPackageImpl.initializePackageContents | public void initializePackageContents() {
"""
Complete the initialization of the package and its meta-model. This
method is guarded to have no affect on any invocation but its first.
<!-- begin-user-doc -->
<!-- end-user-doc -->
@generated
"""
if (isInitialized) return;
isInitialized = true;
// Initialize package
setName(eNAME);
setNsPrefix(eNS_PREFIX);
setNsURI(eNS_URI);
// Create type parameters
// Set bounds for type parameters
// Add supertypes to classes
// Initialize classes and features; add operations and parameters
initEClass(documentRootEClass, DocumentRoot.class, "DocumentRoot", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEAttribute(getDocumentRoot_Mixed(), ecorePackage.getEFeatureMapEntry(), "mixed", null, 0, -1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getDocumentRoot_XMLNSPrefixMap(), ecorePackage.getEStringToStringMapEntry(), null, "xMLNSPrefixMap", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getDocumentRoot_XSISchemaLocation(), ecorePackage.getEStringToStringMapEntry(), null, "xSISchemaLocation", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEAttribute(getDocumentRoot_BackgroundColor(), this.getHexColor(), "backgroundColor", null, 0, 1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEAttribute(getDocumentRoot_BorderColor(), this.getHexColor(), "borderColor", null, 0, 1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEAttribute(getDocumentRoot_Color(), this.getHexColor(), "color", null, 0, 1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
// Initialize data types
initEDataType(hexColorEDataType, String.class, "HexColor", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
// Create resource
createResource(eNS_URI);
// Create annotations
// http:///org/eclipse/emf/ecore/util/ExtendedMetaData
createExtendedMetaDataAnnotations();
} | java | public void initializePackageContents() {
if (isInitialized) return;
isInitialized = true;
// Initialize package
setName(eNAME);
setNsPrefix(eNS_PREFIX);
setNsURI(eNS_URI);
// Create type parameters
// Set bounds for type parameters
// Add supertypes to classes
// Initialize classes and features; add operations and parameters
initEClass(documentRootEClass, DocumentRoot.class, "DocumentRoot", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEAttribute(getDocumentRoot_Mixed(), ecorePackage.getEFeatureMapEntry(), "mixed", null, 0, -1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getDocumentRoot_XMLNSPrefixMap(), ecorePackage.getEStringToStringMapEntry(), null, "xMLNSPrefixMap", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getDocumentRoot_XSISchemaLocation(), ecorePackage.getEStringToStringMapEntry(), null, "xSISchemaLocation", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEAttribute(getDocumentRoot_BackgroundColor(), this.getHexColor(), "backgroundColor", null, 0, 1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEAttribute(getDocumentRoot_BorderColor(), this.getHexColor(), "borderColor", null, 0, 1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEAttribute(getDocumentRoot_Color(), this.getHexColor(), "color", null, 0, 1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
// Initialize data types
initEDataType(hexColorEDataType, String.class, "HexColor", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
// Create resource
createResource(eNS_URI);
// Create annotations
// http:///org/eclipse/emf/ecore/util/ExtendedMetaData
createExtendedMetaDataAnnotations();
} | [
"public",
"void",
"initializePackageContents",
"(",
")",
"{",
"if",
"(",
"isInitialized",
")",
"return",
";",
"isInitialized",
"=",
"true",
";",
"// Initialize package",
"setName",
"(",
"eNAME",
")",
";",
"setNsPrefix",
"(",
"eNS_PREFIX",
")",
";",
"setNsURI",
"(",
"eNS_URI",
")",
";",
"// Create type parameters",
"// Set bounds for type parameters",
"// Add supertypes to classes",
"// Initialize classes and features; add operations and parameters",
"initEClass",
"(",
"documentRootEClass",
",",
"DocumentRoot",
".",
"class",
",",
"\"DocumentRoot\"",
",",
"!",
"IS_ABSTRACT",
",",
"!",
"IS_INTERFACE",
",",
"IS_GENERATED_INSTANCE_CLASS",
")",
";",
"initEAttribute",
"(",
"getDocumentRoot_Mixed",
"(",
")",
",",
"ecorePackage",
".",
"getEFeatureMapEntry",
"(",
")",
",",
"\"mixed\"",
",",
"null",
",",
"0",
",",
"-",
"1",
",",
"null",
",",
"!",
"IS_TRANSIENT",
",",
"!",
"IS_VOLATILE",
",",
"IS_CHANGEABLE",
",",
"!",
"IS_UNSETTABLE",
",",
"!",
"IS_ID",
",",
"!",
"IS_UNIQUE",
",",
"!",
"IS_DERIVED",
",",
"IS_ORDERED",
")",
";",
"initEReference",
"(",
"getDocumentRoot_XMLNSPrefixMap",
"(",
")",
",",
"ecorePackage",
".",
"getEStringToStringMapEntry",
"(",
")",
",",
"null",
",",
"\"xMLNSPrefixMap\"",
",",
"null",
",",
"0",
",",
"-",
"1",
",",
"null",
",",
"IS_TRANSIENT",
",",
"!",
"IS_VOLATILE",
",",
"IS_CHANGEABLE",
",",
"IS_COMPOSITE",
",",
"!",
"IS_RESOLVE_PROXIES",
",",
"!",
"IS_UNSETTABLE",
",",
"IS_UNIQUE",
",",
"!",
"IS_DERIVED",
",",
"IS_ORDERED",
")",
";",
"initEReference",
"(",
"getDocumentRoot_XSISchemaLocation",
"(",
")",
",",
"ecorePackage",
".",
"getEStringToStringMapEntry",
"(",
")",
",",
"null",
",",
"\"xSISchemaLocation\"",
",",
"null",
",",
"0",
",",
"-",
"1",
",",
"null",
",",
"IS_TRANSIENT",
",",
"!",
"IS_VOLATILE",
",",
"IS_CHANGEABLE",
",",
"IS_COMPOSITE",
",",
"!",
"IS_RESOLVE_PROXIES",
",",
"!",
"IS_UNSETTABLE",
",",
"IS_UNIQUE",
",",
"!",
"IS_DERIVED",
",",
"IS_ORDERED",
")",
";",
"initEAttribute",
"(",
"getDocumentRoot_BackgroundColor",
"(",
")",
",",
"this",
".",
"getHexColor",
"(",
")",
",",
"\"backgroundColor\"",
",",
"null",
",",
"0",
",",
"1",
",",
"null",
",",
"!",
"IS_TRANSIENT",
",",
"!",
"IS_VOLATILE",
",",
"IS_CHANGEABLE",
",",
"!",
"IS_UNSETTABLE",
",",
"!",
"IS_ID",
",",
"IS_UNIQUE",
",",
"!",
"IS_DERIVED",
",",
"IS_ORDERED",
")",
";",
"initEAttribute",
"(",
"getDocumentRoot_BorderColor",
"(",
")",
",",
"this",
".",
"getHexColor",
"(",
")",
",",
"\"borderColor\"",
",",
"null",
",",
"0",
",",
"1",
",",
"null",
",",
"!",
"IS_TRANSIENT",
",",
"!",
"IS_VOLATILE",
",",
"IS_CHANGEABLE",
",",
"!",
"IS_UNSETTABLE",
",",
"!",
"IS_ID",
",",
"IS_UNIQUE",
",",
"!",
"IS_DERIVED",
",",
"IS_ORDERED",
")",
";",
"initEAttribute",
"(",
"getDocumentRoot_Color",
"(",
")",
",",
"this",
".",
"getHexColor",
"(",
")",
",",
"\"color\"",
",",
"null",
",",
"0",
",",
"1",
",",
"null",
",",
"!",
"IS_TRANSIENT",
",",
"!",
"IS_VOLATILE",
",",
"IS_CHANGEABLE",
",",
"!",
"IS_UNSETTABLE",
",",
"!",
"IS_ID",
",",
"IS_UNIQUE",
",",
"!",
"IS_DERIVED",
",",
"IS_ORDERED",
")",
";",
"// Initialize data types",
"initEDataType",
"(",
"hexColorEDataType",
",",
"String",
".",
"class",
",",
"\"HexColor\"",
",",
"IS_SERIALIZABLE",
",",
"!",
"IS_GENERATED_INSTANCE_CLASS",
")",
";",
"// Create resource",
"createResource",
"(",
"eNS_URI",
")",
";",
"// Create annotations",
"// http:///org/eclipse/emf/ecore/util/ExtendedMetaData",
"createExtendedMetaDataAnnotations",
"(",
")",
";",
"}"
] | Complete the initialization of the package and its meta-model. This
method is guarded to have no affect on any invocation but its first.
<!-- begin-user-doc -->
<!-- end-user-doc -->
@generated | [
"Complete",
"the",
"initialization",
"of",
"the",
"package",
"and",
"its",
"meta",
"-",
"model",
".",
"This",
"method",
"is",
"guarded",
"to",
"have",
"no",
"affect",
"on",
"any",
"invocation",
"but",
"its",
"first",
".",
"<!",
"--",
"begin",
"-",
"user",
"-",
"doc",
"--",
">",
"<!",
"--",
"end",
"-",
"user",
"-",
"doc",
"--",
">"
] | train | https://github.com/kiegroup/jbpm/blob/c3473c728aa382ebbea01e380c5e754a96647b82/jbpm-bpmn2-emfextmodel/src/main/java/org/omg/spec/bpmn/non/normative/color/impl/ColorPackageImpl.java#L253-L286 |
UrielCh/ovh-java-sdk | ovh-java-sdk-dedicatedCloud/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedCloud.java | ApiOvhDedicatedCloud.serviceName_vmEncryption_kms_kmsId_changeProperties_POST | public OvhTask serviceName_vmEncryption_kms_kmsId_changeProperties_POST(String serviceName, Long kmsId, String description, String sslThumbprint) throws IOException {
"""
Change option user access properties
REST: POST /dedicatedCloud/{serviceName}/vmEncryption/kms/{kmsId}/changeProperties
@param sslThumbprint [required] SSL thumbprint of the remote service, e.g. A7:61:68:...:61:91:2F
@param description [required] Description of your option access network
@param serviceName [required] Domain of the service
@param kmsId [required] Id of the VM Encryption KMS
"""
String qPath = "/dedicatedCloud/{serviceName}/vmEncryption/kms/{kmsId}/changeProperties";
StringBuilder sb = path(qPath, serviceName, kmsId);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "description", description);
addBody(o, "sslThumbprint", sslThumbprint);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhTask.class);
} | java | public OvhTask serviceName_vmEncryption_kms_kmsId_changeProperties_POST(String serviceName, Long kmsId, String description, String sslThumbprint) throws IOException {
String qPath = "/dedicatedCloud/{serviceName}/vmEncryption/kms/{kmsId}/changeProperties";
StringBuilder sb = path(qPath, serviceName, kmsId);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "description", description);
addBody(o, "sslThumbprint", sslThumbprint);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhTask.class);
} | [
"public",
"OvhTask",
"serviceName_vmEncryption_kms_kmsId_changeProperties_POST",
"(",
"String",
"serviceName",
",",
"Long",
"kmsId",
",",
"String",
"description",
",",
"String",
"sslThumbprint",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/dedicatedCloud/{serviceName}/vmEncryption/kms/{kmsId}/changeProperties\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"kmsId",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"description\"",
",",
"description",
")",
";",
"addBody",
"(",
"o",
",",
"\"sslThumbprint\"",
",",
"sslThumbprint",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhTask",
".",
"class",
")",
";",
"}"
] | Change option user access properties
REST: POST /dedicatedCloud/{serviceName}/vmEncryption/kms/{kmsId}/changeProperties
@param sslThumbprint [required] SSL thumbprint of the remote service, e.g. A7:61:68:...:61:91:2F
@param description [required] Description of your option access network
@param serviceName [required] Domain of the service
@param kmsId [required] Id of the VM Encryption KMS | [
"Change",
"option",
"user",
"access",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-dedicatedCloud/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedCloud.java#L590-L598 |
mangstadt/biweekly | src/main/java/biweekly/util/com/google/ical/iter/Util.java | Util.invertWeekdayNum | static int invertWeekdayNum(ByDay weekdayNum, DayOfWeek dow0, int nDays) {
"""
<p>
Converts a relative week number (such as {@code -1SU}) to an absolute
week number.
</p>
<p>
For example, the week number {@code -1SU} refers to the last Sunday of
either the month or year (depending on how this method was called). So if
there are 5 Sundays in the given period, then given a week number of
{@code -1SU}, this method would return 5. Similarly, {@code -2SU} would
return 4.
</p>
@param weekdayNum the weekday number (must be a negative value, such as
{@code -1SU})
@param dow0 the day of the week of the first day of the week or month
@param nDays the number of days in the month or year
@return the absolute week number
"""
//how many are there of that week?
return countInPeriod(weekdayNum.getDay(), dow0, nDays) + weekdayNum.getNum() + 1;
} | java | static int invertWeekdayNum(ByDay weekdayNum, DayOfWeek dow0, int nDays) {
//how many are there of that week?
return countInPeriod(weekdayNum.getDay(), dow0, nDays) + weekdayNum.getNum() + 1;
} | [
"static",
"int",
"invertWeekdayNum",
"(",
"ByDay",
"weekdayNum",
",",
"DayOfWeek",
"dow0",
",",
"int",
"nDays",
")",
"{",
"//how many are there of that week?",
"return",
"countInPeriod",
"(",
"weekdayNum",
".",
"getDay",
"(",
")",
",",
"dow0",
",",
"nDays",
")",
"+",
"weekdayNum",
".",
"getNum",
"(",
")",
"+",
"1",
";",
"}"
] | <p>
Converts a relative week number (such as {@code -1SU}) to an absolute
week number.
</p>
<p>
For example, the week number {@code -1SU} refers to the last Sunday of
either the month or year (depending on how this method was called). So if
there are 5 Sundays in the given period, then given a week number of
{@code -1SU}, this method would return 5. Similarly, {@code -2SU} would
return 4.
</p>
@param weekdayNum the weekday number (must be a negative value, such as
{@code -1SU})
@param dow0 the day of the week of the first day of the week or month
@param nDays the number of days in the month or year
@return the absolute week number | [
"<p",
">",
"Converts",
"a",
"relative",
"week",
"number",
"(",
"such",
"as",
"{"
] | train | https://github.com/mangstadt/biweekly/blob/2e21350f85c13dfff52fdef98fdbebe2976fcf61/src/main/java/biweekly/util/com/google/ical/iter/Util.java#L138-L141 |
Azure/azure-sdk-for-java | policyinsights/resource-manager/v2018_04_04/src/main/java/com/microsoft/azure/management/policyinsights/v2018_04_04/implementation/PolicyStatesInner.java | PolicyStatesInner.listQueryResultsForResourceGroupLevelPolicyAssignment | public PolicyStatesQueryResultsInner listQueryResultsForResourceGroupLevelPolicyAssignment(PolicyStatesResource policyStatesResource, String subscriptionId, String resourceGroupName, String policyAssignmentName, QueryOptions queryOptions) {
"""
Queries policy states for the resource group level policy assignment.
@param policyStatesResource The virtual resource under PolicyStates resource type. In a given time range, 'latest' represents the latest policy state(s), whereas 'default' represents all policy state(s). Possible values include: 'default', 'latest'
@param subscriptionId Microsoft Azure subscription ID.
@param resourceGroupName Resource group name.
@param policyAssignmentName Policy assignment name.
@param queryOptions Additional parameters for the operation
@throws IllegalArgumentException thrown if parameters fail the validation
@throws QueryFailureException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the PolicyStatesQueryResultsInner object if successful.
"""
return listQueryResultsForResourceGroupLevelPolicyAssignmentWithServiceResponseAsync(policyStatesResource, subscriptionId, resourceGroupName, policyAssignmentName, queryOptions).toBlocking().single().body();
} | java | public PolicyStatesQueryResultsInner listQueryResultsForResourceGroupLevelPolicyAssignment(PolicyStatesResource policyStatesResource, String subscriptionId, String resourceGroupName, String policyAssignmentName, QueryOptions queryOptions) {
return listQueryResultsForResourceGroupLevelPolicyAssignmentWithServiceResponseAsync(policyStatesResource, subscriptionId, resourceGroupName, policyAssignmentName, queryOptions).toBlocking().single().body();
} | [
"public",
"PolicyStatesQueryResultsInner",
"listQueryResultsForResourceGroupLevelPolicyAssignment",
"(",
"PolicyStatesResource",
"policyStatesResource",
",",
"String",
"subscriptionId",
",",
"String",
"resourceGroupName",
",",
"String",
"policyAssignmentName",
",",
"QueryOptions",
"queryOptions",
")",
"{",
"return",
"listQueryResultsForResourceGroupLevelPolicyAssignmentWithServiceResponseAsync",
"(",
"policyStatesResource",
",",
"subscriptionId",
",",
"resourceGroupName",
",",
"policyAssignmentName",
",",
"queryOptions",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Queries policy states for the resource group level policy assignment.
@param policyStatesResource The virtual resource under PolicyStates resource type. In a given time range, 'latest' represents the latest policy state(s), whereas 'default' represents all policy state(s). Possible values include: 'default', 'latest'
@param subscriptionId Microsoft Azure subscription ID.
@param resourceGroupName Resource group name.
@param policyAssignmentName Policy assignment name.
@param queryOptions Additional parameters for the operation
@throws IllegalArgumentException thrown if parameters fail the validation
@throws QueryFailureException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the PolicyStatesQueryResultsInner object if successful. | [
"Queries",
"policy",
"states",
"for",
"the",
"resource",
"group",
"level",
"policy",
"assignment",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/policyinsights/resource-manager/v2018_04_04/src/main/java/com/microsoft/azure/management/policyinsights/v2018_04_04/implementation/PolicyStatesInner.java#L2980-L2982 |
QSFT/Doradus | doradus-client/src/main/java/com/dell/doradus/client/SSLTransportParameters.java | SSLTransportParameters.setTrustStore | public void setTrustStore(String trustStore, String trustPass, String trustManagerType, String trustStoreType) {
"""
Set the truststore, password, certificate type and the store type
@param trustStore Location of the Truststore on disk
@param trustPass Truststore password
@param trustManagerType The default is X509
@param trustStoreType The default is JKS
"""
if((trustStore == null) || (trustPass == null))
{
this.trustStore = System.getProperty("javax.net.ssl.trustStore");
this.trustPass = System.getProperty("javax.net.ssl.trustStorePassword");
}
else
{
this.trustStore = trustStore;
this.trustPass = trustPass;
}
if (trustManagerType != null) {
this.trustManagerType = trustManagerType;
}
if (trustStoreType != null) {
this.trustStoreType = trustStoreType;
}
isTrustStoreSet = (trustStore != null) && (trustPass != null);
} | java | public void setTrustStore(String trustStore, String trustPass, String trustManagerType, String trustStoreType)
{
if((trustStore == null) || (trustPass == null))
{
this.trustStore = System.getProperty("javax.net.ssl.trustStore");
this.trustPass = System.getProperty("javax.net.ssl.trustStorePassword");
}
else
{
this.trustStore = trustStore;
this.trustPass = trustPass;
}
if (trustManagerType != null) {
this.trustManagerType = trustManagerType;
}
if (trustStoreType != null) {
this.trustStoreType = trustStoreType;
}
isTrustStoreSet = (trustStore != null) && (trustPass != null);
} | [
"public",
"void",
"setTrustStore",
"(",
"String",
"trustStore",
",",
"String",
"trustPass",
",",
"String",
"trustManagerType",
",",
"String",
"trustStoreType",
")",
"{",
"if",
"(",
"(",
"trustStore",
"==",
"null",
")",
"||",
"(",
"trustPass",
"==",
"null",
")",
")",
"{",
"this",
".",
"trustStore",
"=",
"System",
".",
"getProperty",
"(",
"\"javax.net.ssl.trustStore\"",
")",
";",
"this",
".",
"trustPass",
"=",
"System",
".",
"getProperty",
"(",
"\"javax.net.ssl.trustStorePassword\"",
")",
";",
"}",
"else",
"{",
"this",
".",
"trustStore",
"=",
"trustStore",
";",
"this",
".",
"trustPass",
"=",
"trustPass",
";",
"}",
"if",
"(",
"trustManagerType",
"!=",
"null",
")",
"{",
"this",
".",
"trustManagerType",
"=",
"trustManagerType",
";",
"}",
"if",
"(",
"trustStoreType",
"!=",
"null",
")",
"{",
"this",
".",
"trustStoreType",
"=",
"trustStoreType",
";",
"}",
"isTrustStoreSet",
"=",
"(",
"trustStore",
"!=",
"null",
")",
"&&",
"(",
"trustPass",
"!=",
"null",
")",
";",
"}"
] | Set the truststore, password, certificate type and the store type
@param trustStore Location of the Truststore on disk
@param trustPass Truststore password
@param trustManagerType The default is X509
@param trustStoreType The default is JKS | [
"Set",
"the",
"truststore",
"password",
"certificate",
"type",
"and",
"the",
"store",
"type"
] | train | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/SSLTransportParameters.java#L226-L246 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/axes/WalkingIterator.java | WalkingIterator.fixupVariables | public void fixupVariables(java.util.Vector vars, int globalsSize) {
"""
This function is used to fixup variables from QNames to stack frame
indexes at stylesheet build time.
@param vars List of QNames that correspond to variables. This list
should be searched backwards for the first qualified name that
corresponds to the variable reference qname. The position of the
QName in the vector from the start of the vector will be its position
in the stack frame (but variables above the globalsTop value will need
to be offset to the current stack frame).
"""
m_predicateIndex = -1;
AxesWalker walker = m_firstWalker;
while (null != walker)
{
walker.fixupVariables(vars, globalsSize);
walker = walker.getNextWalker();
}
} | java | public void fixupVariables(java.util.Vector vars, int globalsSize)
{
m_predicateIndex = -1;
AxesWalker walker = m_firstWalker;
while (null != walker)
{
walker.fixupVariables(vars, globalsSize);
walker = walker.getNextWalker();
}
} | [
"public",
"void",
"fixupVariables",
"(",
"java",
".",
"util",
".",
"Vector",
"vars",
",",
"int",
"globalsSize",
")",
"{",
"m_predicateIndex",
"=",
"-",
"1",
";",
"AxesWalker",
"walker",
"=",
"m_firstWalker",
";",
"while",
"(",
"null",
"!=",
"walker",
")",
"{",
"walker",
".",
"fixupVariables",
"(",
"vars",
",",
"globalsSize",
")",
";",
"walker",
"=",
"walker",
".",
"getNextWalker",
"(",
")",
";",
"}",
"}"
] | This function is used to fixup variables from QNames to stack frame
indexes at stylesheet build time.
@param vars List of QNames that correspond to variables. This list
should be searched backwards for the first qualified name that
corresponds to the variable reference qname. The position of the
QName in the vector from the start of the vector will be its position
in the stack frame (but variables above the globalsTop value will need
to be offset to the current stack frame). | [
"This",
"function",
"is",
"used",
"to",
"fixup",
"variables",
"from",
"QNames",
"to",
"stack",
"frame",
"indexes",
"at",
"stylesheet",
"build",
"time",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/axes/WalkingIterator.java#L286-L297 |
google/closure-compiler | src/com/google/javascript/jscomp/parsing/TypeTransformationParser.java | TypeTransformationParser.validTemplateTypeExpression | private boolean validTemplateTypeExpression(Node expr) {
"""
A template type expression must be of the form type(typename, TTLExp,...)
or type(typevar, TTLExp...)
"""
// The expression must have at least three children the type keyword,
// a type name (or type variable) and a type expression
if (!checkParameterCount(expr, Keywords.TYPE)) {
return false;
}
int paramCount = getCallParamCount(expr);
// The first parameter must be a type variable or a type name
Node firstParam = getCallArgument(expr, 0);
if (!isTypeVar(firstParam) && !isTypeName(firstParam)) {
warnInvalid("type name or type variable", expr);
warnInvalidInside("template type operation", expr);
return false;
}
// The rest of the parameters must be valid type expressions
for (int i = 1; i < paramCount; i++) {
if (!validTypeTransformationExpression(getCallArgument(expr, i))) {
warnInvalidInside("template type operation", expr);
return false;
}
}
return true;
} | java | private boolean validTemplateTypeExpression(Node expr) {
// The expression must have at least three children the type keyword,
// a type name (or type variable) and a type expression
if (!checkParameterCount(expr, Keywords.TYPE)) {
return false;
}
int paramCount = getCallParamCount(expr);
// The first parameter must be a type variable or a type name
Node firstParam = getCallArgument(expr, 0);
if (!isTypeVar(firstParam) && !isTypeName(firstParam)) {
warnInvalid("type name or type variable", expr);
warnInvalidInside("template type operation", expr);
return false;
}
// The rest of the parameters must be valid type expressions
for (int i = 1; i < paramCount; i++) {
if (!validTypeTransformationExpression(getCallArgument(expr, i))) {
warnInvalidInside("template type operation", expr);
return false;
}
}
return true;
} | [
"private",
"boolean",
"validTemplateTypeExpression",
"(",
"Node",
"expr",
")",
"{",
"// The expression must have at least three children the type keyword,",
"// a type name (or type variable) and a type expression",
"if",
"(",
"!",
"checkParameterCount",
"(",
"expr",
",",
"Keywords",
".",
"TYPE",
")",
")",
"{",
"return",
"false",
";",
"}",
"int",
"paramCount",
"=",
"getCallParamCount",
"(",
"expr",
")",
";",
"// The first parameter must be a type variable or a type name",
"Node",
"firstParam",
"=",
"getCallArgument",
"(",
"expr",
",",
"0",
")",
";",
"if",
"(",
"!",
"isTypeVar",
"(",
"firstParam",
")",
"&&",
"!",
"isTypeName",
"(",
"firstParam",
")",
")",
"{",
"warnInvalid",
"(",
"\"type name or type variable\"",
",",
"expr",
")",
";",
"warnInvalidInside",
"(",
"\"template type operation\"",
",",
"expr",
")",
";",
"return",
"false",
";",
"}",
"// The rest of the parameters must be valid type expressions",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"paramCount",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"validTypeTransformationExpression",
"(",
"getCallArgument",
"(",
"expr",
",",
"i",
")",
")",
")",
"{",
"warnInvalidInside",
"(",
"\"template type operation\"",
",",
"expr",
")",
";",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | A template type expression must be of the form type(typename, TTLExp,...)
or type(typevar, TTLExp...) | [
"A",
"template",
"type",
"expression",
"must",
"be",
"of",
"the",
"form",
"type",
"(",
"typename",
"TTLExp",
"...",
")",
"or",
"type",
"(",
"typevar",
"TTLExp",
"...",
")"
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/parsing/TypeTransformationParser.java#L292-L314 |
amaembo/streamex | src/main/java/one/util/streamex/DoubleStreamEx.java | DoubleStreamEx.of | public static DoubleStreamEx of(DoubleStream stream) {
"""
Returns a {@code DoubleStreamEx} object which wraps given
{@link DoubleStream}.
<p>
The supplied stream must not be consumed or closed when this method is
called. No operation must be performed on the supplied stream after it's
wrapped.
@param stream original stream
@return the wrapped stream
@since 0.0.8
"""
return stream instanceof DoubleStreamEx ? (DoubleStreamEx) stream
: new DoubleStreamEx(stream, StreamContext.of(stream));
} | java | public static DoubleStreamEx of(DoubleStream stream) {
return stream instanceof DoubleStreamEx ? (DoubleStreamEx) stream
: new DoubleStreamEx(stream, StreamContext.of(stream));
} | [
"public",
"static",
"DoubleStreamEx",
"of",
"(",
"DoubleStream",
"stream",
")",
"{",
"return",
"stream",
"instanceof",
"DoubleStreamEx",
"?",
"(",
"DoubleStreamEx",
")",
"stream",
":",
"new",
"DoubleStreamEx",
"(",
"stream",
",",
"StreamContext",
".",
"of",
"(",
"stream",
")",
")",
";",
"}"
] | Returns a {@code DoubleStreamEx} object which wraps given
{@link DoubleStream}.
<p>
The supplied stream must not be consumed or closed when this method is
called. No operation must be performed on the supplied stream after it's
wrapped.
@param stream original stream
@return the wrapped stream
@since 0.0.8 | [
"Returns",
"a",
"{",
"@code",
"DoubleStreamEx",
"}",
"object",
"which",
"wraps",
"given",
"{",
"@link",
"DoubleStream",
"}",
"."
] | train | https://github.com/amaembo/streamex/blob/936bbd1b7dfbcf64a3b990682bfc848213441d14/src/main/java/one/util/streamex/DoubleStreamEx.java#L1607-L1610 |
io7m/jproperties | com.io7m.jproperties.core/src/main/java/com/io7m/jproperties/JProperties.java | JProperties.getBigDecimalOptional | public static BigDecimal getBigDecimalOptional(
final Properties properties,
final String key,
final BigDecimal other)
throws
JPropertyIncorrectType {
"""
<p> Returns the real value associated with {@code key} in the
properties referenced by {@code properties} if it exists, otherwise
returns the given default value. </p>
@param other The default value
@param properties The loaded properties.
@param key The requested key.
@return The value associated with the key, parsed as an real.
@throws JPropertyIncorrectType If the value associated with the key cannot
be parsed as a real.
"""
Objects.requireNonNull(properties, "Properties");
Objects.requireNonNull(key, "Key");
Objects.requireNonNull(other, "Default");
final String text = properties.getProperty(key);
if (text == null) {
return other;
}
return parseReal(key, text);
} | java | public static BigDecimal getBigDecimalOptional(
final Properties properties,
final String key,
final BigDecimal other)
throws
JPropertyIncorrectType
{
Objects.requireNonNull(properties, "Properties");
Objects.requireNonNull(key, "Key");
Objects.requireNonNull(other, "Default");
final String text = properties.getProperty(key);
if (text == null) {
return other;
}
return parseReal(key, text);
} | [
"public",
"static",
"BigDecimal",
"getBigDecimalOptional",
"(",
"final",
"Properties",
"properties",
",",
"final",
"String",
"key",
",",
"final",
"BigDecimal",
"other",
")",
"throws",
"JPropertyIncorrectType",
"{",
"Objects",
".",
"requireNonNull",
"(",
"properties",
",",
"\"Properties\"",
")",
";",
"Objects",
".",
"requireNonNull",
"(",
"key",
",",
"\"Key\"",
")",
";",
"Objects",
".",
"requireNonNull",
"(",
"other",
",",
"\"Default\"",
")",
";",
"final",
"String",
"text",
"=",
"properties",
".",
"getProperty",
"(",
"key",
")",
";",
"if",
"(",
"text",
"==",
"null",
")",
"{",
"return",
"other",
";",
"}",
"return",
"parseReal",
"(",
"key",
",",
"text",
")",
";",
"}"
] | <p> Returns the real value associated with {@code key} in the
properties referenced by {@code properties} if it exists, otherwise
returns the given default value. </p>
@param other The default value
@param properties The loaded properties.
@param key The requested key.
@return The value associated with the key, parsed as an real.
@throws JPropertyIncorrectType If the value associated with the key cannot
be parsed as a real. | [
"<p",
">",
"Returns",
"the",
"real",
"value",
"associated",
"with",
"{",
"@code",
"key",
"}",
"in",
"the",
"properties",
"referenced",
"by",
"{",
"@code",
"properties",
"}",
"if",
"it",
"exists",
"otherwise",
"returns",
"the",
"given",
"default",
"value",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/io7m/jproperties/blob/b188b8fd87b3b078f1e2b564a9ed5996db0becfd/com.io7m.jproperties.core/src/main/java/com/io7m/jproperties/JProperties.java#L107-L123 |
apache/incubator-heron | heron/packing/src/java/org/apache/heron/packing/roundrobin/RoundRobinPacking.java | RoundRobinPacking.repack | @Override
public PackingPlan repack(PackingPlan currentPackingPlan, int containers, Map<String, Integer>
componentChanges) throws PackingException {
"""
Read the current packing plan with update parallelism and number of containers
to calculate a new packing plan.
The packing algorithm packInternal() is shared with pack()
delegate to packInternal() with the new container count and component parallelism
@param currentPackingPlan Existing packing plan
@param containers < the new number of containers for the topology
specified by the user
@param componentChanges Map < componentName, new component parallelism >
that contains the parallelism for each component whose parallelism has changed.
@return new packing plan
@throws PackingException
"""
if (containers == currentPackingPlan.getContainers().size()) {
return repack(currentPackingPlan, componentChanges);
}
Map<String, Integer> newComponentParallelism = getNewComponentParallelism(currentPackingPlan,
componentChanges);
return packInternal(containers, newComponentParallelism);
} | java | @Override
public PackingPlan repack(PackingPlan currentPackingPlan, int containers, Map<String, Integer>
componentChanges) throws PackingException {
if (containers == currentPackingPlan.getContainers().size()) {
return repack(currentPackingPlan, componentChanges);
}
Map<String, Integer> newComponentParallelism = getNewComponentParallelism(currentPackingPlan,
componentChanges);
return packInternal(containers, newComponentParallelism);
} | [
"@",
"Override",
"public",
"PackingPlan",
"repack",
"(",
"PackingPlan",
"currentPackingPlan",
",",
"int",
"containers",
",",
"Map",
"<",
"String",
",",
"Integer",
">",
"componentChanges",
")",
"throws",
"PackingException",
"{",
"if",
"(",
"containers",
"==",
"currentPackingPlan",
".",
"getContainers",
"(",
")",
".",
"size",
"(",
")",
")",
"{",
"return",
"repack",
"(",
"currentPackingPlan",
",",
"componentChanges",
")",
";",
"}",
"Map",
"<",
"String",
",",
"Integer",
">",
"newComponentParallelism",
"=",
"getNewComponentParallelism",
"(",
"currentPackingPlan",
",",
"componentChanges",
")",
";",
"return",
"packInternal",
"(",
"containers",
",",
"newComponentParallelism",
")",
";",
"}"
] | Read the current packing plan with update parallelism and number of containers
to calculate a new packing plan.
The packing algorithm packInternal() is shared with pack()
delegate to packInternal() with the new container count and component parallelism
@param currentPackingPlan Existing packing plan
@param containers < the new number of containers for the topology
specified by the user
@param componentChanges Map < componentName, new component parallelism >
that contains the parallelism for each component whose parallelism has changed.
@return new packing plan
@throws PackingException | [
"Read",
"the",
"current",
"packing",
"plan",
"with",
"update",
"parallelism",
"and",
"number",
"of",
"containers",
"to",
"calculate",
"a",
"new",
"packing",
"plan",
".",
"The",
"packing",
"algorithm",
"packInternal",
"()",
"is",
"shared",
"with",
"pack",
"()",
"delegate",
"to",
"packInternal",
"()",
"with",
"the",
"new",
"container",
"count",
"and",
"component",
"parallelism"
] | train | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/packing/src/java/org/apache/heron/packing/roundrobin/RoundRobinPacking.java#L517-L526 |
sporniket/core | sporniket-core-lang/src/main/java/com/sporniket/libre/lang/DataTools.java | DataTools.appendByteAsPaddedHexString | @Deprecated
public static StringBuffer appendByteAsPaddedHexString(byte value, StringBuffer buffer) {
"""
Convert a byte into a padded hexadecimal string.
@param value
the value to convert.
@param buffer
the buffer to append the result into.
@return the updated buffer.
@deprecated use <code>buffer.append(javax.xml.bind.DatatypeConverter.printHexBinary(new byte[] {value}).toLowerCase())</code>
"""
return buffer.append(printHexBinary(new byte[] {value}).toLowerCase());
} | java | @Deprecated
public static StringBuffer appendByteAsPaddedHexString(byte value, StringBuffer buffer)
{
return buffer.append(printHexBinary(new byte[] {value}).toLowerCase());
} | [
"@",
"Deprecated",
"public",
"static",
"StringBuffer",
"appendByteAsPaddedHexString",
"(",
"byte",
"value",
",",
"StringBuffer",
"buffer",
")",
"{",
"return",
"buffer",
".",
"append",
"(",
"printHexBinary",
"(",
"new",
"byte",
"[",
"]",
"{",
"value",
"}",
")",
".",
"toLowerCase",
"(",
")",
")",
";",
"}"
] | Convert a byte into a padded hexadecimal string.
@param value
the value to convert.
@param buffer
the buffer to append the result into.
@return the updated buffer.
@deprecated use <code>buffer.append(javax.xml.bind.DatatypeConverter.printHexBinary(new byte[] {value}).toLowerCase())</code> | [
"Convert",
"a",
"byte",
"into",
"a",
"padded",
"hexadecimal",
"string",
"."
] | train | https://github.com/sporniket/core/blob/3480ebd72a07422fcc09971be2607ee25efb2c26/sporniket-core-lang/src/main/java/com/sporniket/libre/lang/DataTools.java#L128-L132 |
rhuss/jolokia | agent/core/src/main/java/org/jolokia/restrictor/policy/MBeanAccessChecker.java | MBeanAccessChecker.extractMbeanConfiguration | private void extractMbeanConfiguration(NodeList pNodes,MBeanPolicyConfig pConfig) throws MalformedObjectNameException {
"""
Extract configuration and put it into a given MBeanPolicyConfig
"""
for (int i = 0;i< pNodes.getLength();i++) {
Node node = pNodes.item(i);
if (node.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
extractPolicyConfig(pConfig, node.getChildNodes());
}
} | java | private void extractMbeanConfiguration(NodeList pNodes,MBeanPolicyConfig pConfig) throws MalformedObjectNameException {
for (int i = 0;i< pNodes.getLength();i++) {
Node node = pNodes.item(i);
if (node.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
extractPolicyConfig(pConfig, node.getChildNodes());
}
} | [
"private",
"void",
"extractMbeanConfiguration",
"(",
"NodeList",
"pNodes",
",",
"MBeanPolicyConfig",
"pConfig",
")",
"throws",
"MalformedObjectNameException",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"pNodes",
".",
"getLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"Node",
"node",
"=",
"pNodes",
".",
"item",
"(",
"i",
")",
";",
"if",
"(",
"node",
".",
"getNodeType",
"(",
")",
"!=",
"Node",
".",
"ELEMENT_NODE",
")",
"{",
"continue",
";",
"}",
"extractPolicyConfig",
"(",
"pConfig",
",",
"node",
".",
"getChildNodes",
"(",
")",
")",
";",
"}",
"}"
] | Extract configuration and put it into a given MBeanPolicyConfig | [
"Extract",
"configuration",
"and",
"put",
"it",
"into",
"a",
"given",
"MBeanPolicyConfig"
] | train | https://github.com/rhuss/jolokia/blob/dc95e7bef859b1829776c5a84c8f7738f5d7d9c3/agent/core/src/main/java/org/jolokia/restrictor/policy/MBeanAccessChecker.java#L103-L111 |
Stratio/deep-spark | deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java | Utils.getExtractorInstance | public static <T, S extends BaseConfig> IExtractor<T, S> getExtractorInstance(S config) {
"""
Gets extractor instance.
@param config the config
@return the extractor instance
"""
try {
Class<T> rdd = (Class<T>) config.getExtractorImplClass();
if (rdd == null) {
rdd = (Class<T>) Class.forName(config.getExtractorImplClassName());
}
Constructor<T> c;
if (config.getEntityClass().isAssignableFrom(Cells.class)) {
c = rdd.getConstructor();
return (IExtractor<T, S>) c.newInstance();
} else {
c = rdd.getConstructor(Class.class);
return (IExtractor<T, S>) c.newInstance(config.getEntityClass());
}
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException
| InvocationTargetException | NoSuchMethodException | SecurityException e) {
String message = "A exception happens and we wrap with DeepExtractorInitializationException" + e.getMessage();
LOG.error(message);
throw new DeepExtractorInitializationException(message,e);
}
} | java | public static <T, S extends BaseConfig> IExtractor<T, S> getExtractorInstance(S config) {
try {
Class<T> rdd = (Class<T>) config.getExtractorImplClass();
if (rdd == null) {
rdd = (Class<T>) Class.forName(config.getExtractorImplClassName());
}
Constructor<T> c;
if (config.getEntityClass().isAssignableFrom(Cells.class)) {
c = rdd.getConstructor();
return (IExtractor<T, S>) c.newInstance();
} else {
c = rdd.getConstructor(Class.class);
return (IExtractor<T, S>) c.newInstance(config.getEntityClass());
}
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException
| InvocationTargetException | NoSuchMethodException | SecurityException e) {
String message = "A exception happens and we wrap with DeepExtractorInitializationException" + e.getMessage();
LOG.error(message);
throw new DeepExtractorInitializationException(message,e);
}
} | [
"public",
"static",
"<",
"T",
",",
"S",
"extends",
"BaseConfig",
">",
"IExtractor",
"<",
"T",
",",
"S",
">",
"getExtractorInstance",
"(",
"S",
"config",
")",
"{",
"try",
"{",
"Class",
"<",
"T",
">",
"rdd",
"=",
"(",
"Class",
"<",
"T",
">",
")",
"config",
".",
"getExtractorImplClass",
"(",
")",
";",
"if",
"(",
"rdd",
"==",
"null",
")",
"{",
"rdd",
"=",
"(",
"Class",
"<",
"T",
">",
")",
"Class",
".",
"forName",
"(",
"config",
".",
"getExtractorImplClassName",
"(",
")",
")",
";",
"}",
"Constructor",
"<",
"T",
">",
"c",
";",
"if",
"(",
"config",
".",
"getEntityClass",
"(",
")",
".",
"isAssignableFrom",
"(",
"Cells",
".",
"class",
")",
")",
"{",
"c",
"=",
"rdd",
".",
"getConstructor",
"(",
")",
";",
"return",
"(",
"IExtractor",
"<",
"T",
",",
"S",
">",
")",
"c",
".",
"newInstance",
"(",
")",
";",
"}",
"else",
"{",
"c",
"=",
"rdd",
".",
"getConstructor",
"(",
"Class",
".",
"class",
")",
";",
"return",
"(",
"IExtractor",
"<",
"T",
",",
"S",
">",
")",
"c",
".",
"newInstance",
"(",
"config",
".",
"getEntityClass",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"ClassNotFoundException",
"|",
"InstantiationException",
"|",
"IllegalAccessException",
"|",
"IllegalArgumentException",
"|",
"InvocationTargetException",
"|",
"NoSuchMethodException",
"|",
"SecurityException",
"e",
")",
"{",
"String",
"message",
"=",
"\"A exception happens and we wrap with DeepExtractorInitializationException\"",
"+",
"e",
".",
"getMessage",
"(",
")",
";",
"LOG",
".",
"error",
"(",
"message",
")",
";",
"throw",
"new",
"DeepExtractorInitializationException",
"(",
"message",
",",
"e",
")",
";",
"}",
"}"
] | Gets extractor instance.
@param config the config
@return the extractor instance | [
"Gets",
"extractor",
"instance",
"."
] | train | https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/utils/Utils.java#L381-L403 |
fhussonnois/storm-trident-elasticsearch | src/main/java/com/github/fhuss/storm/elasticsearch/mapper/impl/DefaultTupleMapper.java | DefaultTupleMapper.newObjectDefaultTupleMapper | public static final DefaultTupleMapper newObjectDefaultTupleMapper( ) {
"""
Returns a new {@link DefaultTupleMapper} that accept Object as source field value.
"""
final ObjectMapper mapper = new ObjectMapper();
return new DefaultTupleMapper(new TupleMapper<String>() {
@Override
public String map(Tuple input) {
try {
return mapper.writeValueAsString(input.getValueByField(FIELD_SOURCE));
} catch (JsonProcessingException e) {
throw new MappingException("Error happen while processing json on object", e);
}
}
});
} | java | public static final DefaultTupleMapper newObjectDefaultTupleMapper( ) {
final ObjectMapper mapper = new ObjectMapper();
return new DefaultTupleMapper(new TupleMapper<String>() {
@Override
public String map(Tuple input) {
try {
return mapper.writeValueAsString(input.getValueByField(FIELD_SOURCE));
} catch (JsonProcessingException e) {
throw new MappingException("Error happen while processing json on object", e);
}
}
});
} | [
"public",
"static",
"final",
"DefaultTupleMapper",
"newObjectDefaultTupleMapper",
"(",
")",
"{",
"final",
"ObjectMapper",
"mapper",
"=",
"new",
"ObjectMapper",
"(",
")",
";",
"return",
"new",
"DefaultTupleMapper",
"(",
"new",
"TupleMapper",
"<",
"String",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"String",
"map",
"(",
"Tuple",
"input",
")",
"{",
"try",
"{",
"return",
"mapper",
".",
"writeValueAsString",
"(",
"input",
".",
"getValueByField",
"(",
"FIELD_SOURCE",
")",
")",
";",
"}",
"catch",
"(",
"JsonProcessingException",
"e",
")",
"{",
"throw",
"new",
"MappingException",
"(",
"\"Error happen while processing json on object\"",
",",
"e",
")",
";",
"}",
"}",
"}",
")",
";",
"}"
] | Returns a new {@link DefaultTupleMapper} that accept Object as source field value. | [
"Returns",
"a",
"new",
"{"
] | train | https://github.com/fhussonnois/storm-trident-elasticsearch/blob/1788157efff223800a92f17f79deb02c905230f7/src/main/java/com/github/fhuss/storm/elasticsearch/mapper/impl/DefaultTupleMapper.java#L79-L91 |
igniterealtime/Smack | smack-openpgp/src/main/java/org/jivesoftware/smackx/ox_im/OXInstantMessagingManager.java | OXInstantMessagingManager.sendOxMessage | public OpenPgpMetadata sendOxMessage(OpenPgpContact contact, CharSequence body)
throws InterruptedException, IOException,
SmackException.NotConnectedException, SmackException.NotLoggedInException, PGPException {
"""
Send an OX message to a {@link OpenPgpContact}. The message will be encrypted to all active keys of the contact,
as well as all of our active keys. The message is also signed with our key.
@param contact contact capable of OpenPGP for XMPP: Instant Messaging.
@param body message body.
@return {@link OpenPgpMetadata} about the messages encryption + signatures.
@throws InterruptedException if the thread is interrupted
@throws IOException IO is dangerous
@throws SmackException.NotConnectedException if we are not connected
@throws SmackException.NotLoggedInException if we are not logged in
@throws PGPException PGP is brittle
"""
Message message = new Message(contact.getJid());
Message.Body mBody = new Message.Body(null, body.toString());
OpenPgpMetadata metadata = addOxMessage(message, contact, Collections.<ExtensionElement>singletonList(mBody));
ChatManager.getInstanceFor(connection()).chatWith(contact.getJid().asEntityBareJidIfPossible()).send(message);
return metadata;
} | java | public OpenPgpMetadata sendOxMessage(OpenPgpContact contact, CharSequence body)
throws InterruptedException, IOException,
SmackException.NotConnectedException, SmackException.NotLoggedInException, PGPException {
Message message = new Message(contact.getJid());
Message.Body mBody = new Message.Body(null, body.toString());
OpenPgpMetadata metadata = addOxMessage(message, contact, Collections.<ExtensionElement>singletonList(mBody));
ChatManager.getInstanceFor(connection()).chatWith(contact.getJid().asEntityBareJidIfPossible()).send(message);
return metadata;
} | [
"public",
"OpenPgpMetadata",
"sendOxMessage",
"(",
"OpenPgpContact",
"contact",
",",
"CharSequence",
"body",
")",
"throws",
"InterruptedException",
",",
"IOException",
",",
"SmackException",
".",
"NotConnectedException",
",",
"SmackException",
".",
"NotLoggedInException",
",",
"PGPException",
"{",
"Message",
"message",
"=",
"new",
"Message",
"(",
"contact",
".",
"getJid",
"(",
")",
")",
";",
"Message",
".",
"Body",
"mBody",
"=",
"new",
"Message",
".",
"Body",
"(",
"null",
",",
"body",
".",
"toString",
"(",
")",
")",
";",
"OpenPgpMetadata",
"metadata",
"=",
"addOxMessage",
"(",
"message",
",",
"contact",
",",
"Collections",
".",
"<",
"ExtensionElement",
">",
"singletonList",
"(",
"mBody",
")",
")",
";",
"ChatManager",
".",
"getInstanceFor",
"(",
"connection",
"(",
")",
")",
".",
"chatWith",
"(",
"contact",
".",
"getJid",
"(",
")",
".",
"asEntityBareJidIfPossible",
"(",
")",
")",
".",
"send",
"(",
"message",
")",
";",
"return",
"metadata",
";",
"}"
] | Send an OX message to a {@link OpenPgpContact}. The message will be encrypted to all active keys of the contact,
as well as all of our active keys. The message is also signed with our key.
@param contact contact capable of OpenPGP for XMPP: Instant Messaging.
@param body message body.
@return {@link OpenPgpMetadata} about the messages encryption + signatures.
@throws InterruptedException if the thread is interrupted
@throws IOException IO is dangerous
@throws SmackException.NotConnectedException if we are not connected
@throws SmackException.NotLoggedInException if we are not logged in
@throws PGPException PGP is brittle | [
"Send",
"an",
"OX",
"message",
"to",
"a",
"{",
"@link",
"OpenPgpContact",
"}",
".",
"The",
"message",
"will",
"be",
"encrypted",
"to",
"all",
"active",
"keys",
"of",
"the",
"contact",
"as",
"well",
"as",
"all",
"of",
"our",
"active",
"keys",
".",
"The",
"message",
"is",
"also",
"signed",
"with",
"our",
"key",
"."
] | train | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-openpgp/src/main/java/org/jivesoftware/smackx/ox_im/OXInstantMessagingManager.java#L227-L238 |
dwdyer/uncommons-maths | demo/src/java/main/org/uncommons/swing/SwingBackgroundTask.java | SwingBackgroundTask.execute | public void execute() {
"""
Asynchronous call that begins execution of the task
and returns immediately.
"""
Runnable task = new Runnable()
{
public void run()
{
final V result = performTask();
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
postProcessing(result);
latch.countDown();
}
});
}
};
new Thread(task, "SwingBackgroundTask-" + id).start();
} | java | public void execute()
{
Runnable task = new Runnable()
{
public void run()
{
final V result = performTask();
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
postProcessing(result);
latch.countDown();
}
});
}
};
new Thread(task, "SwingBackgroundTask-" + id).start();
} | [
"public",
"void",
"execute",
"(",
")",
"{",
"Runnable",
"task",
"=",
"new",
"Runnable",
"(",
")",
"{",
"public",
"void",
"run",
"(",
")",
"{",
"final",
"V",
"result",
"=",
"performTask",
"(",
")",
";",
"SwingUtilities",
".",
"invokeLater",
"(",
"new",
"Runnable",
"(",
")",
"{",
"public",
"void",
"run",
"(",
")",
"{",
"postProcessing",
"(",
"result",
")",
";",
"latch",
".",
"countDown",
"(",
")",
";",
"}",
"}",
")",
";",
"}",
"}",
";",
"new",
"Thread",
"(",
"task",
",",
"\"SwingBackgroundTask-\"",
"+",
"id",
")",
".",
"start",
"(",
")",
";",
"}"
] | Asynchronous call that begins execution of the task
and returns immediately. | [
"Asynchronous",
"call",
"that",
"begins",
"execution",
"of",
"the",
"task",
"and",
"returns",
"immediately",
"."
] | train | https://github.com/dwdyer/uncommons-maths/blob/b7ba13aea70625bb7f37c856783a29e17e354964/demo/src/java/main/org/uncommons/swing/SwingBackgroundTask.java#L49-L67 |
mikepenz/FastAdapter | library/src/main/java/com/mikepenz/fastadapter/commons/utils/FastAdapterUIUtils.java | FastAdapterUIUtils.getRippleMask | private static Drawable getRippleMask(int color, int radius) {
"""
helper to create an ripple mask with the given color and radius
@param color the color
@param radius the radius
@return the mask drawable
"""
float[] outerRadius = new float[8];
Arrays.fill(outerRadius, radius);
RoundRectShape r = new RoundRectShape(outerRadius, null, null);
ShapeDrawable shapeDrawable = new ShapeDrawable(r);
shapeDrawable.getPaint().setColor(color);
return shapeDrawable;
} | java | private static Drawable getRippleMask(int color, int radius) {
float[] outerRadius = new float[8];
Arrays.fill(outerRadius, radius);
RoundRectShape r = new RoundRectShape(outerRadius, null, null);
ShapeDrawable shapeDrawable = new ShapeDrawable(r);
shapeDrawable.getPaint().setColor(color);
return shapeDrawable;
} | [
"private",
"static",
"Drawable",
"getRippleMask",
"(",
"int",
"color",
",",
"int",
"radius",
")",
"{",
"float",
"[",
"]",
"outerRadius",
"=",
"new",
"float",
"[",
"8",
"]",
";",
"Arrays",
".",
"fill",
"(",
"outerRadius",
",",
"radius",
")",
";",
"RoundRectShape",
"r",
"=",
"new",
"RoundRectShape",
"(",
"outerRadius",
",",
"null",
",",
"null",
")",
";",
"ShapeDrawable",
"shapeDrawable",
"=",
"new",
"ShapeDrawable",
"(",
"r",
")",
";",
"shapeDrawable",
".",
"getPaint",
"(",
")",
".",
"setColor",
"(",
"color",
")",
";",
"return",
"shapeDrawable",
";",
"}"
] | helper to create an ripple mask with the given color and radius
@param color the color
@param radius the radius
@return the mask drawable | [
"helper",
"to",
"create",
"an",
"ripple",
"mask",
"with",
"the",
"given",
"color",
"and",
"radius"
] | train | https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library/src/main/java/com/mikepenz/fastadapter/commons/utils/FastAdapterUIUtils.java#L117-L124 |
fuinorg/utils4j | src/main/java/org/fuin/utils4j/Utils4J.java | Utils4J.getResource | public static URL getResource(final Class<?> clasz, final String name) {
"""
Get the path to a resource located in the same package as a given class.
@param clasz
Class with the same package where the resource is located - Cannot be <code>null</code>.
@param name
Filename of the resource - Cannot be <code>null</code>.
@return Resource URL.
"""
checkNotNull("clasz", clasz);
checkNotNull("name", name);
final String nameAndPath = SLASH + getPackagePath(clasz) + SLASH + name;
return clasz.getResource(nameAndPath);
} | java | public static URL getResource(final Class<?> clasz, final String name) {
checkNotNull("clasz", clasz);
checkNotNull("name", name);
final String nameAndPath = SLASH + getPackagePath(clasz) + SLASH + name;
return clasz.getResource(nameAndPath);
} | [
"public",
"static",
"URL",
"getResource",
"(",
"final",
"Class",
"<",
"?",
">",
"clasz",
",",
"final",
"String",
"name",
")",
"{",
"checkNotNull",
"(",
"\"clasz\"",
",",
"clasz",
")",
";",
"checkNotNull",
"(",
"\"name\"",
",",
"name",
")",
";",
"final",
"String",
"nameAndPath",
"=",
"SLASH",
"+",
"getPackagePath",
"(",
"clasz",
")",
"+",
"SLASH",
"+",
"name",
";",
"return",
"clasz",
".",
"getResource",
"(",
"nameAndPath",
")",
";",
"}"
] | Get the path to a resource located in the same package as a given class.
@param clasz
Class with the same package where the resource is located - Cannot be <code>null</code>.
@param name
Filename of the resource - Cannot be <code>null</code>.
@return Resource URL. | [
"Get",
"the",
"path",
"to",
"a",
"resource",
"located",
"in",
"the",
"same",
"package",
"as",
"a",
"given",
"class",
"."
] | train | https://github.com/fuinorg/utils4j/blob/71cf88e0a8d8ed67bbac513bf3cab165cd7e3280/src/main/java/org/fuin/utils4j/Utils4J.java#L133-L138 |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/encryption/resolvers/KeyResolver18.java | KeyResolver18.loadSymmetricKey | private static @Nullable SecretKey loadSymmetricKey(Context context, KeyPair wrapperKey) throws NoSuchPaddingException,
NoSuchAlgorithmException,
InvalidKeyException {
"""
Attempts to load an existing symmetric key or return <code>null</code> if failed.
Multistep process:
1. Load and encrypted symmetric key data from the shared preferences.
2. Unwraps the key using <code>wrapperKey</code>
"""
String encryptedSymmetricKey = getKeyPrefs(context).getString(PREFS_KEY_SYMMETRIC_KEY, null);
if (StringUtils.isNullOrEmpty(encryptedSymmetricKey)) {
return null;
}
return unwrapSymmetricKey(wrapperKey, encryptedSymmetricKey);
} | java | private static @Nullable SecretKey loadSymmetricKey(Context context, KeyPair wrapperKey) throws NoSuchPaddingException,
NoSuchAlgorithmException,
InvalidKeyException {
String encryptedSymmetricKey = getKeyPrefs(context).getString(PREFS_KEY_SYMMETRIC_KEY, null);
if (StringUtils.isNullOrEmpty(encryptedSymmetricKey)) {
return null;
}
return unwrapSymmetricKey(wrapperKey, encryptedSymmetricKey);
} | [
"private",
"static",
"@",
"Nullable",
"SecretKey",
"loadSymmetricKey",
"(",
"Context",
"context",
",",
"KeyPair",
"wrapperKey",
")",
"throws",
"NoSuchPaddingException",
",",
"NoSuchAlgorithmException",
",",
"InvalidKeyException",
"{",
"String",
"encryptedSymmetricKey",
"=",
"getKeyPrefs",
"(",
"context",
")",
".",
"getString",
"(",
"PREFS_KEY_SYMMETRIC_KEY",
",",
"null",
")",
";",
"if",
"(",
"StringUtils",
".",
"isNullOrEmpty",
"(",
"encryptedSymmetricKey",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"unwrapSymmetricKey",
"(",
"wrapperKey",
",",
"encryptedSymmetricKey",
")",
";",
"}"
] | Attempts to load an existing symmetric key or return <code>null</code> if failed.
Multistep process:
1. Load and encrypted symmetric key data from the shared preferences.
2. Unwraps the key using <code>wrapperKey</code> | [
"Attempts",
"to",
"load",
"an",
"existing",
"symmetric",
"key",
"or",
"return",
"<code",
">",
"null<",
"/",
"code",
">",
"if",
"failed",
".",
"Multistep",
"process",
":",
"1",
".",
"Load",
"and",
"encrypted",
"symmetric",
"key",
"data",
"from",
"the",
"shared",
"preferences",
".",
"2",
".",
"Unwraps",
"the",
"key",
"using",
"<code",
">",
"wrapperKey<",
"/",
"code",
">"
] | train | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/encryption/resolvers/KeyResolver18.java#L125-L134 |
softindex/datakernel | core-bytebuf/src/main/java/io/datakernel/bytebuf/ByteBuf.java | ByteBuf.isContentEqual | @Contract(pure = true)
public boolean isContentEqual(@NotNull ByteBuf other) {
"""
Checks if provided {@code ByteBuf} readable bytes are equal to the
readable bytes of the {@link #array}.
@param other {@code ByteBuf} to be compared with the {@link #array}
@return {@code true} if the {@code ByteBuf} is equal to the array,
otherwise {@code false}
"""
return isContentEqual(other.array, other.head, other.readRemaining());
} | java | @Contract(pure = true)
public boolean isContentEqual(@NotNull ByteBuf other) {
return isContentEqual(other.array, other.head, other.readRemaining());
} | [
"@",
"Contract",
"(",
"pure",
"=",
"true",
")",
"public",
"boolean",
"isContentEqual",
"(",
"@",
"NotNull",
"ByteBuf",
"other",
")",
"{",
"return",
"isContentEqual",
"(",
"other",
".",
"array",
",",
"other",
".",
"head",
",",
"other",
".",
"readRemaining",
"(",
")",
")",
";",
"}"
] | Checks if provided {@code ByteBuf} readable bytes are equal to the
readable bytes of the {@link #array}.
@param other {@code ByteBuf} to be compared with the {@link #array}
@return {@code true} if the {@code ByteBuf} is equal to the array,
otherwise {@code false} | [
"Checks",
"if",
"provided",
"{",
"@code",
"ByteBuf",
"}",
"readable",
"bytes",
"are",
"equal",
"to",
"the",
"readable",
"bytes",
"of",
"the",
"{",
"@link",
"#array",
"}",
"."
] | train | https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-bytebuf/src/main/java/io/datakernel/bytebuf/ByteBuf.java#L748-L751 |
camunda/camunda-bpm-jbehave | camunda-bpm-jbehave/src/main/java/org/camunda/bpm/data/Guards.java | Guards.checkIsSetGlobal | public static void checkIsSetGlobal(final DelegateExecution execution, final String variableName) {
"""
Checks, if a global variable with specified name is set.
@param execution
process execution.
@param variableName
name of the variable to check.
"""
Preconditions.checkArgument(variableName != null, VARIABLE_SKIP_GUARDS);
final Object variable = execution.getVariable(variableName);
Preconditions.checkState(variable != null,
String.format("Condition of task '%s' is violated: Global variable '%s' is not set.", new Object[] { execution.getCurrentActivityId(), variableName }));
} | java | public static void checkIsSetGlobal(final DelegateExecution execution, final String variableName) {
Preconditions.checkArgument(variableName != null, VARIABLE_SKIP_GUARDS);
final Object variable = execution.getVariable(variableName);
Preconditions.checkState(variable != null,
String.format("Condition of task '%s' is violated: Global variable '%s' is not set.", new Object[] { execution.getCurrentActivityId(), variableName }));
} | [
"public",
"static",
"void",
"checkIsSetGlobal",
"(",
"final",
"DelegateExecution",
"execution",
",",
"final",
"String",
"variableName",
")",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"variableName",
"!=",
"null",
",",
"VARIABLE_SKIP_GUARDS",
")",
";",
"final",
"Object",
"variable",
"=",
"execution",
".",
"getVariable",
"(",
"variableName",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"variable",
"!=",
"null",
",",
"String",
".",
"format",
"(",
"\"Condition of task '%s' is violated: Global variable '%s' is not set.\"",
",",
"new",
"Object",
"[",
"]",
"{",
"execution",
".",
"getCurrentActivityId",
"(",
")",
",",
"variableName",
"}",
")",
")",
";",
"}"
] | Checks, if a global variable with specified name is set.
@param execution
process execution.
@param variableName
name of the variable to check. | [
"Checks",
"if",
"a",
"global",
"variable",
"with",
"specified",
"name",
"is",
"set",
"."
] | train | https://github.com/camunda/camunda-bpm-jbehave/blob/ffad22471418e2c7f161f8976ca8a042114138ab/camunda-bpm-jbehave/src/main/java/org/camunda/bpm/data/Guards.java#L96-L102 |
Stratio/stratio-connector-commons | connector-commons/src/main/java/com/stratio/connector/commons/metadata/CatalogMetadataBuilder.java | CatalogMetadataBuilder.withOptions | @TimerJ
public CatalogMetadataBuilder withOptions(Map<Selector, Selector> opts) {
"""
Set the options. Any options previously created are removed.
@param opts the opts
@return the catalog metadata builder
"""
options = new HashMap<Selector, Selector>(opts);
return this;
} | java | @TimerJ
public CatalogMetadataBuilder withOptions(Map<Selector, Selector> opts) {
options = new HashMap<Selector, Selector>(opts);
return this;
} | [
"@",
"TimerJ",
"public",
"CatalogMetadataBuilder",
"withOptions",
"(",
"Map",
"<",
"Selector",
",",
"Selector",
">",
"opts",
")",
"{",
"options",
"=",
"new",
"HashMap",
"<",
"Selector",
",",
"Selector",
">",
"(",
"opts",
")",
";",
"return",
"this",
";",
"}"
] | Set the options. Any options previously created are removed.
@param opts the opts
@return the catalog metadata builder | [
"Set",
"the",
"options",
".",
"Any",
"options",
"previously",
"created",
"are",
"removed",
"."
] | train | https://github.com/Stratio/stratio-connector-commons/blob/d7cc66cb9591344a13055962e87a91f01c3707d1/connector-commons/src/main/java/com/stratio/connector/commons/metadata/CatalogMetadataBuilder.java#L82-L86 |
sarl/sarl | main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/util/Jdt2Ecore.java | Jdt2Ecore.getAnnotation | public IAnnotation getAnnotation(IAnnotatable element, String qualifiedName) {
"""
Replies the annotation with the given qualified name.
@param element the annoted element.
@param qualifiedName the qualified name of the element.
@return the annotation, or <code>null</code> if the element is not annoted.
"""
if (element != null) {
try {
final int separator = qualifiedName.lastIndexOf('.');
final String simpleName;
if (separator >= 0 && separator < (qualifiedName.length() - 1)) {
simpleName = qualifiedName.substring(separator + 1, qualifiedName.length());
} else {
simpleName = qualifiedName;
}
for (final IAnnotation annotation : element.getAnnotations()) {
final String name = annotation.getElementName();
if (name.equals(simpleName) || name.equals(qualifiedName)) {
return annotation;
}
}
} catch (JavaModelException e) {
//
}
}
return null;
} | java | public IAnnotation getAnnotation(IAnnotatable element, String qualifiedName) {
if (element != null) {
try {
final int separator = qualifiedName.lastIndexOf('.');
final String simpleName;
if (separator >= 0 && separator < (qualifiedName.length() - 1)) {
simpleName = qualifiedName.substring(separator + 1, qualifiedName.length());
} else {
simpleName = qualifiedName;
}
for (final IAnnotation annotation : element.getAnnotations()) {
final String name = annotation.getElementName();
if (name.equals(simpleName) || name.equals(qualifiedName)) {
return annotation;
}
}
} catch (JavaModelException e) {
//
}
}
return null;
} | [
"public",
"IAnnotation",
"getAnnotation",
"(",
"IAnnotatable",
"element",
",",
"String",
"qualifiedName",
")",
"{",
"if",
"(",
"element",
"!=",
"null",
")",
"{",
"try",
"{",
"final",
"int",
"separator",
"=",
"qualifiedName",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"final",
"String",
"simpleName",
";",
"if",
"(",
"separator",
">=",
"0",
"&&",
"separator",
"<",
"(",
"qualifiedName",
".",
"length",
"(",
")",
"-",
"1",
")",
")",
"{",
"simpleName",
"=",
"qualifiedName",
".",
"substring",
"(",
"separator",
"+",
"1",
",",
"qualifiedName",
".",
"length",
"(",
")",
")",
";",
"}",
"else",
"{",
"simpleName",
"=",
"qualifiedName",
";",
"}",
"for",
"(",
"final",
"IAnnotation",
"annotation",
":",
"element",
".",
"getAnnotations",
"(",
")",
")",
"{",
"final",
"String",
"name",
"=",
"annotation",
".",
"getElementName",
"(",
")",
";",
"if",
"(",
"name",
".",
"equals",
"(",
"simpleName",
")",
"||",
"name",
".",
"equals",
"(",
"qualifiedName",
")",
")",
"{",
"return",
"annotation",
";",
"}",
"}",
"}",
"catch",
"(",
"JavaModelException",
"e",
")",
"{",
"//",
"}",
"}",
"return",
"null",
";",
"}"
] | Replies the annotation with the given qualified name.
@param element the annoted element.
@param qualifiedName the qualified name of the element.
@return the annotation, or <code>null</code> if the element is not annoted. | [
"Replies",
"the",
"annotation",
"with",
"the",
"given",
"qualified",
"name",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/util/Jdt2Ecore.java#L335-L356 |
hazelcast/hazelcast | hazelcast/src/main/java/com/hazelcast/config/cp/CPSubsystemConfig.java | CPSubsystemConfig.setLockConfigs | public CPSubsystemConfig setLockConfigs(Map<String, FencedLockConfig> lockConfigs) {
"""
Sets the map of {@link FencedLock} configurations, mapped by config
name. Names could optionally contain a {@link CPGroup} name, such as
"myLock@group1".
@param lockConfigs the {@link FencedLock} config map to set
@return this config instance
"""
this.lockConfigs.clear();
this.lockConfigs.putAll(lockConfigs);
for (Entry<String, FencedLockConfig> entry : this.lockConfigs.entrySet()) {
entry.getValue().setName(entry.getKey());
}
return this;
} | java | public CPSubsystemConfig setLockConfigs(Map<String, FencedLockConfig> lockConfigs) {
this.lockConfigs.clear();
this.lockConfigs.putAll(lockConfigs);
for (Entry<String, FencedLockConfig> entry : this.lockConfigs.entrySet()) {
entry.getValue().setName(entry.getKey());
}
return this;
} | [
"public",
"CPSubsystemConfig",
"setLockConfigs",
"(",
"Map",
"<",
"String",
",",
"FencedLockConfig",
">",
"lockConfigs",
")",
"{",
"this",
".",
"lockConfigs",
".",
"clear",
"(",
")",
";",
"this",
".",
"lockConfigs",
".",
"putAll",
"(",
"lockConfigs",
")",
";",
"for",
"(",
"Entry",
"<",
"String",
",",
"FencedLockConfig",
">",
"entry",
":",
"this",
".",
"lockConfigs",
".",
"entrySet",
"(",
")",
")",
"{",
"entry",
".",
"getValue",
"(",
")",
".",
"setName",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Sets the map of {@link FencedLock} configurations, mapped by config
name. Names could optionally contain a {@link CPGroup} name, such as
"myLock@group1".
@param lockConfigs the {@link FencedLock} config map to set
@return this config instance | [
"Sets",
"the",
"map",
"of",
"{",
"@link",
"FencedLock",
"}",
"configurations",
"mapped",
"by",
"config",
"name",
".",
"Names",
"could",
"optionally",
"contain",
"a",
"{",
"@link",
"CPGroup",
"}",
"name",
"such",
"as",
"myLock@group1",
"."
] | train | https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/config/cp/CPSubsystemConfig.java#L544-L551 |
js-lib-com/commons | src/main/java/js/converter/UrlConverter.java | UrlConverter.asObject | @Override
public <T> T asObject(String string, Class<T> valueType) throws ConverterException {
"""
Convert URL string representation into URL instance.
@throws ConverterException if given string is not a valid URL.
"""
// at this point value type is guaranteed to be URL
try {
return (T) new URL(string);
} catch (MalformedURLException e) {
throw new ConverterException(e.getMessage());
}
} | java | @Override
public <T> T asObject(String string, Class<T> valueType) throws ConverterException {
// at this point value type is guaranteed to be URL
try {
return (T) new URL(string);
} catch (MalformedURLException e) {
throw new ConverterException(e.getMessage());
}
} | [
"@",
"Override",
"public",
"<",
"T",
">",
"T",
"asObject",
"(",
"String",
"string",
",",
"Class",
"<",
"T",
">",
"valueType",
")",
"throws",
"ConverterException",
"{",
"// at this point value type is guaranteed to be URL\r",
"try",
"{",
"return",
"(",
"T",
")",
"new",
"URL",
"(",
"string",
")",
";",
"}",
"catch",
"(",
"MalformedURLException",
"e",
")",
"{",
"throw",
"new",
"ConverterException",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Convert URL string representation into URL instance.
@throws ConverterException if given string is not a valid URL. | [
"Convert",
"URL",
"string",
"representation",
"into",
"URL",
"instance",
"."
] | train | https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/converter/UrlConverter.java#L23-L31 |
Azure/azure-sdk-for-java | labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/EnvironmentSettingsInner.java | EnvironmentSettingsInner.getAsync | public Observable<EnvironmentSettingInner> getAsync(String resourceGroupName, String labAccountName, String labName, String environmentSettingName, String expand) {
"""
Get environment setting.
@param resourceGroupName The name of the resource group.
@param labAccountName The name of the lab Account.
@param labName The name of the lab.
@param environmentSettingName The name of the environment Setting.
@param expand Specify the $expand query. Example: 'properties($select=publishingState)'
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the EnvironmentSettingInner object
"""
return getWithServiceResponseAsync(resourceGroupName, labAccountName, labName, environmentSettingName, expand).map(new Func1<ServiceResponse<EnvironmentSettingInner>, EnvironmentSettingInner>() {
@Override
public EnvironmentSettingInner call(ServiceResponse<EnvironmentSettingInner> response) {
return response.body();
}
});
} | java | public Observable<EnvironmentSettingInner> getAsync(String resourceGroupName, String labAccountName, String labName, String environmentSettingName, String expand) {
return getWithServiceResponseAsync(resourceGroupName, labAccountName, labName, environmentSettingName, expand).map(new Func1<ServiceResponse<EnvironmentSettingInner>, EnvironmentSettingInner>() {
@Override
public EnvironmentSettingInner call(ServiceResponse<EnvironmentSettingInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"EnvironmentSettingInner",
">",
"getAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"labAccountName",
",",
"String",
"labName",
",",
"String",
"environmentSettingName",
",",
"String",
"expand",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"labAccountName",
",",
"labName",
",",
"environmentSettingName",
",",
"expand",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"EnvironmentSettingInner",
">",
",",
"EnvironmentSettingInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"EnvironmentSettingInner",
"call",
"(",
"ServiceResponse",
"<",
"EnvironmentSettingInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Get environment setting.
@param resourceGroupName The name of the resource group.
@param labAccountName The name of the lab Account.
@param labName The name of the lab.
@param environmentSettingName The name of the environment Setting.
@param expand Specify the $expand query. Example: 'properties($select=publishingState)'
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the EnvironmentSettingInner object | [
"Get",
"environment",
"setting",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/EnvironmentSettingsInner.java#L543-L550 |
OpenTSDB/opentsdb | src/tree/Tree.java | Tree.storeTree | public Deferred<Boolean> storeTree(final TSDB tsdb, final boolean overwrite) {
"""
Attempts to store the tree definition via a CompareAndSet call.
@param tsdb The TSDB to use for access
@param overwrite Whether or not tree data should be overwritten
@return True if the write was successful, false if an error occurred
@throws IllegalArgumentException if the tree ID is missing or invalid
@throws HBaseException if a storage exception occurred
"""
if (tree_id < 1 || tree_id > 65535) {
throw new IllegalArgumentException("Invalid Tree ID");
}
// if there aren't any changes, save time and bandwidth by not writing to
// storage
boolean has_changes = false;
for (Map.Entry<String, Boolean> entry : changed.entrySet()) {
if (entry.getValue()) {
has_changes = true;
break;
}
}
if (!has_changes) {
LOG.debug(this + " does not have changes, skipping sync to storage");
throw new IllegalStateException("No changes detected in the tree");
}
/**
* Callback executed after loading a tree from storage so that we can
* synchronize changes to the meta data and write them back to storage.
*/
final class StoreTreeCB implements Callback<Deferred<Boolean>, Tree> {
final private Tree local_tree;
public StoreTreeCB(final Tree local_tree) {
this.local_tree = local_tree;
}
/**
* Synchronizes the stored tree object (if found) with the local tree
* and issues a CAS call to write the update to storage.
* @return True if the CAS was successful, false if something changed
* in flight
*/
@Override
public Deferred<Boolean> call(final Tree fetched_tree) throws Exception {
Tree stored_tree = fetched_tree;
final byte[] original_tree = stored_tree == null ? new byte[0] :
stored_tree.toStorageJson();
// now copy changes
if (stored_tree == null) {
stored_tree = local_tree;
} else {
stored_tree.copyChanges(local_tree, overwrite);
}
// reset the change map so we don't keep writing
initializeChangedMap();
final PutRequest put = new PutRequest(tsdb.treeTable(),
Tree.idToBytes(tree_id), TREE_FAMILY, TREE_QUALIFIER,
stored_tree.toStorageJson());
return tsdb.getClient().compareAndSet(put, original_tree);
}
}
// initiate the sync by attempting to fetch an existing tree from storage
return fetchTree(tsdb, tree_id).addCallbackDeferring(new StoreTreeCB(this));
} | java | public Deferred<Boolean> storeTree(final TSDB tsdb, final boolean overwrite) {
if (tree_id < 1 || tree_id > 65535) {
throw new IllegalArgumentException("Invalid Tree ID");
}
// if there aren't any changes, save time and bandwidth by not writing to
// storage
boolean has_changes = false;
for (Map.Entry<String, Boolean> entry : changed.entrySet()) {
if (entry.getValue()) {
has_changes = true;
break;
}
}
if (!has_changes) {
LOG.debug(this + " does not have changes, skipping sync to storage");
throw new IllegalStateException("No changes detected in the tree");
}
/**
* Callback executed after loading a tree from storage so that we can
* synchronize changes to the meta data and write them back to storage.
*/
final class StoreTreeCB implements Callback<Deferred<Boolean>, Tree> {
final private Tree local_tree;
public StoreTreeCB(final Tree local_tree) {
this.local_tree = local_tree;
}
/**
* Synchronizes the stored tree object (if found) with the local tree
* and issues a CAS call to write the update to storage.
* @return True if the CAS was successful, false if something changed
* in flight
*/
@Override
public Deferred<Boolean> call(final Tree fetched_tree) throws Exception {
Tree stored_tree = fetched_tree;
final byte[] original_tree = stored_tree == null ? new byte[0] :
stored_tree.toStorageJson();
// now copy changes
if (stored_tree == null) {
stored_tree = local_tree;
} else {
stored_tree.copyChanges(local_tree, overwrite);
}
// reset the change map so we don't keep writing
initializeChangedMap();
final PutRequest put = new PutRequest(tsdb.treeTable(),
Tree.idToBytes(tree_id), TREE_FAMILY, TREE_QUALIFIER,
stored_tree.toStorageJson());
return tsdb.getClient().compareAndSet(put, original_tree);
}
}
// initiate the sync by attempting to fetch an existing tree from storage
return fetchTree(tsdb, tree_id).addCallbackDeferring(new StoreTreeCB(this));
} | [
"public",
"Deferred",
"<",
"Boolean",
">",
"storeTree",
"(",
"final",
"TSDB",
"tsdb",
",",
"final",
"boolean",
"overwrite",
")",
"{",
"if",
"(",
"tree_id",
"<",
"1",
"||",
"tree_id",
">",
"65535",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid Tree ID\"",
")",
";",
"}",
"// if there aren't any changes, save time and bandwidth by not writing to",
"// storage",
"boolean",
"has_changes",
"=",
"false",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Boolean",
">",
"entry",
":",
"changed",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
"{",
"has_changes",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"has_changes",
")",
"{",
"LOG",
".",
"debug",
"(",
"this",
"+",
"\" does not have changes, skipping sync to storage\"",
")",
";",
"throw",
"new",
"IllegalStateException",
"(",
"\"No changes detected in the tree\"",
")",
";",
"}",
"/**\n * Callback executed after loading a tree from storage so that we can\n * synchronize changes to the meta data and write them back to storage.\n */",
"final",
"class",
"StoreTreeCB",
"implements",
"Callback",
"<",
"Deferred",
"<",
"Boolean",
">",
",",
"Tree",
">",
"{",
"final",
"private",
"Tree",
"local_tree",
";",
"public",
"StoreTreeCB",
"(",
"final",
"Tree",
"local_tree",
")",
"{",
"this",
".",
"local_tree",
"=",
"local_tree",
";",
"}",
"/**\n * Synchronizes the stored tree object (if found) with the local tree \n * and issues a CAS call to write the update to storage.\n * @return True if the CAS was successful, false if something changed \n * in flight\n */",
"@",
"Override",
"public",
"Deferred",
"<",
"Boolean",
">",
"call",
"(",
"final",
"Tree",
"fetched_tree",
")",
"throws",
"Exception",
"{",
"Tree",
"stored_tree",
"=",
"fetched_tree",
";",
"final",
"byte",
"[",
"]",
"original_tree",
"=",
"stored_tree",
"==",
"null",
"?",
"new",
"byte",
"[",
"0",
"]",
":",
"stored_tree",
".",
"toStorageJson",
"(",
")",
";",
"// now copy changes",
"if",
"(",
"stored_tree",
"==",
"null",
")",
"{",
"stored_tree",
"=",
"local_tree",
";",
"}",
"else",
"{",
"stored_tree",
".",
"copyChanges",
"(",
"local_tree",
",",
"overwrite",
")",
";",
"}",
"// reset the change map so we don't keep writing",
"initializeChangedMap",
"(",
")",
";",
"final",
"PutRequest",
"put",
"=",
"new",
"PutRequest",
"(",
"tsdb",
".",
"treeTable",
"(",
")",
",",
"Tree",
".",
"idToBytes",
"(",
"tree_id",
")",
",",
"TREE_FAMILY",
",",
"TREE_QUALIFIER",
",",
"stored_tree",
".",
"toStorageJson",
"(",
")",
")",
";",
"return",
"tsdb",
".",
"getClient",
"(",
")",
".",
"compareAndSet",
"(",
"put",
",",
"original_tree",
")",
";",
"}",
"}",
"// initiate the sync by attempting to fetch an existing tree from storage",
"return",
"fetchTree",
"(",
"tsdb",
",",
"tree_id",
")",
".",
"addCallbackDeferring",
"(",
"new",
"StoreTreeCB",
"(",
"this",
")",
")",
";",
"}"
] | Attempts to store the tree definition via a CompareAndSet call.
@param tsdb The TSDB to use for access
@param overwrite Whether or not tree data should be overwritten
@return True if the write was successful, false if an error occurred
@throws IllegalArgumentException if the tree ID is missing or invalid
@throws HBaseException if a storage exception occurred | [
"Attempts",
"to",
"store",
"the",
"tree",
"definition",
"via",
"a",
"CompareAndSet",
"call",
"."
] | train | https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tree/Tree.java#L312-L375 |
linkedin/PalDB | paldb/src/main/java/com/linkedin/paldb/api/PalDB.java | PalDB.createReader | public static StoreReader createReader(File file, Configuration config) {
"""
Creates a store reader from the specified <code>file</code>.
<p>
The file must exists.
@param file a PalDB store file
@param config configuration
@return a store reader
"""
return StoreImpl.createReader(file, config);
} | java | public static StoreReader createReader(File file, Configuration config) {
return StoreImpl.createReader(file, config);
} | [
"public",
"static",
"StoreReader",
"createReader",
"(",
"File",
"file",
",",
"Configuration",
"config",
")",
"{",
"return",
"StoreImpl",
".",
"createReader",
"(",
"file",
",",
"config",
")",
";",
"}"
] | Creates a store reader from the specified <code>file</code>.
<p>
The file must exists.
@param file a PalDB store file
@param config configuration
@return a store reader | [
"Creates",
"a",
"store",
"reader",
"from",
"the",
"specified",
"<code",
">",
"file<",
"/",
"code",
">",
".",
"<p",
">",
"The",
"file",
"must",
"exists",
"."
] | train | https://github.com/linkedin/PalDB/blob/d05ccdd3f67855eb2675dbd82599f19aa7a9f650/paldb/src/main/java/com/linkedin/paldb/api/PalDB.java#L58-L60 |
yavijava/yavijava | src/main/java/com/vmware/vim25/mo/IoFilterManager.java | IoFilterManager.unInstallIoFilter_Task | public Task unInstallIoFilter_Task(String filterId, ComputeResource cluster) throws FilterInUse, InvalidArgument, InvalidState, NotFound, RuntimeFault, RemoteException {
"""
Uninstall an IO Filter on a compute resource. IO Filters can only be installed on a cluster.
@param filterId
- ID of the filter.
@param cluster
- The compute resource to install the IO Filter on. "compRes" must be a cluster.
@return - This method returns a Task object with which to monitor the operation. The task is set to success if
the filter is installed on all the hosts in the compute resource successfully. If the task fails, first
check error to see the error. If the error indicates that installation has failed on the hosts, use
QueryIoFilterIssues to get the detailed errors occured during installation on each host. The dynamic
privilege check ensures that the user must have Host.Config.Patch privilege for all the hosts in the
compute resource.
@throws FilterInUse
Thrown if the filter to be uninstalled is being used by a virtual disk.
@throws InvalidState
Thrown if "compRes" is a cluster and DRS is disabled on the cluster.
@throws NotFound
Thrown if the filter is not installed on the cluster. - Thrown if another VIB with the same name and
vendor has been installed.
@throws InvalidArgument
- Thrown if "compRes" is a standalone host.
@throws RuntimeFault
- Thrown if any type of runtime fault is thrown that is not covered by the other faults; for example,
a communication error.
@throws RemoteException
"""
return new Task(getServerConnection(), getVimService().uninstallIoFilter_Task(getMOR(), filterId, cluster.getMOR()));
} | java | public Task unInstallIoFilter_Task(String filterId, ComputeResource cluster) throws FilterInUse, InvalidArgument, InvalidState, NotFound, RuntimeFault, RemoteException {
return new Task(getServerConnection(), getVimService().uninstallIoFilter_Task(getMOR(), filterId, cluster.getMOR()));
} | [
"public",
"Task",
"unInstallIoFilter_Task",
"(",
"String",
"filterId",
",",
"ComputeResource",
"cluster",
")",
"throws",
"FilterInUse",
",",
"InvalidArgument",
",",
"InvalidState",
",",
"NotFound",
",",
"RuntimeFault",
",",
"RemoteException",
"{",
"return",
"new",
"Task",
"(",
"getServerConnection",
"(",
")",
",",
"getVimService",
"(",
")",
".",
"uninstallIoFilter_Task",
"(",
"getMOR",
"(",
")",
",",
"filterId",
",",
"cluster",
".",
"getMOR",
"(",
")",
")",
")",
";",
"}"
] | Uninstall an IO Filter on a compute resource. IO Filters can only be installed on a cluster.
@param filterId
- ID of the filter.
@param cluster
- The compute resource to install the IO Filter on. "compRes" must be a cluster.
@return - This method returns a Task object with which to monitor the operation. The task is set to success if
the filter is installed on all the hosts in the compute resource successfully. If the task fails, first
check error to see the error. If the error indicates that installation has failed on the hosts, use
QueryIoFilterIssues to get the detailed errors occured during installation on each host. The dynamic
privilege check ensures that the user must have Host.Config.Patch privilege for all the hosts in the
compute resource.
@throws FilterInUse
Thrown if the filter to be uninstalled is being used by a virtual disk.
@throws InvalidState
Thrown if "compRes" is a cluster and DRS is disabled on the cluster.
@throws NotFound
Thrown if the filter is not installed on the cluster. - Thrown if another VIB with the same name and
vendor has been installed.
@throws InvalidArgument
- Thrown if "compRes" is a standalone host.
@throws RuntimeFault
- Thrown if any type of runtime fault is thrown that is not covered by the other faults; for example,
a communication error.
@throws RemoteException | [
"Uninstall",
"an",
"IO",
"Filter",
"on",
"a",
"compute",
"resource",
".",
"IO",
"Filters",
"can",
"only",
"be",
"installed",
"on",
"a",
"cluster",
"."
] | train | https://github.com/yavijava/yavijava/blob/27fd2c5826115782d5eeb934f86e3e39240179cd/src/main/java/com/vmware/vim25/mo/IoFilterManager.java#L208-L210 |
albfernandez/itext2 | src/main/java/com/lowagie/text/pdf/PdfStamper.java | PdfStamper.setEncryption | public void setEncryption(Certificate[] certs, int[] permissions, int encryptionType) throws DocumentException {
"""
Sets the certificate encryption options for this document. An array of one or more public certificates
must be provided together with an array of the same size for the permissions for each certificate.
The open permissions for the document can be
AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations,
AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting.
The permissions can be combined by ORing them.
Optionally DO_NOT_ENCRYPT_METADATA can be ored to output the metadata in cleartext
@param certs the public certificates to be used for the encryption
@param permissions the user permissions for each of the certificates
@param encryptionType the type of encryption. It can be one of STANDARD_ENCRYPTION_40, STANDARD_ENCRYPTION_128 or ENCRYPTION_AES128.
@throws DocumentException if the encryption was set too late
"""
if (stamper.isAppend())
throw new DocumentException("Append mode does not support changing the encryption status.");
if (stamper.isContentWritten())
throw new DocumentException("Content was already written to the output.");
stamper.setEncryption(certs, permissions, encryptionType);
} | java | public void setEncryption(Certificate[] certs, int[] permissions, int encryptionType) throws DocumentException {
if (stamper.isAppend())
throw new DocumentException("Append mode does not support changing the encryption status.");
if (stamper.isContentWritten())
throw new DocumentException("Content was already written to the output.");
stamper.setEncryption(certs, permissions, encryptionType);
} | [
"public",
"void",
"setEncryption",
"(",
"Certificate",
"[",
"]",
"certs",
",",
"int",
"[",
"]",
"permissions",
",",
"int",
"encryptionType",
")",
"throws",
"DocumentException",
"{",
"if",
"(",
"stamper",
".",
"isAppend",
"(",
")",
")",
"throw",
"new",
"DocumentException",
"(",
"\"Append mode does not support changing the encryption status.\"",
")",
";",
"if",
"(",
"stamper",
".",
"isContentWritten",
"(",
")",
")",
"throw",
"new",
"DocumentException",
"(",
"\"Content was already written to the output.\"",
")",
";",
"stamper",
".",
"setEncryption",
"(",
"certs",
",",
"permissions",
",",
"encryptionType",
")",
";",
"}"
] | Sets the certificate encryption options for this document. An array of one or more public certificates
must be provided together with an array of the same size for the permissions for each certificate.
The open permissions for the document can be
AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations,
AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting.
The permissions can be combined by ORing them.
Optionally DO_NOT_ENCRYPT_METADATA can be ored to output the metadata in cleartext
@param certs the public certificates to be used for the encryption
@param permissions the user permissions for each of the certificates
@param encryptionType the type of encryption. It can be one of STANDARD_ENCRYPTION_40, STANDARD_ENCRYPTION_128 or ENCRYPTION_AES128.
@throws DocumentException if the encryption was set too late | [
"Sets",
"the",
"certificate",
"encryption",
"options",
"for",
"this",
"document",
".",
"An",
"array",
"of",
"one",
"or",
"more",
"public",
"certificates",
"must",
"be",
"provided",
"together",
"with",
"an",
"array",
"of",
"the",
"same",
"size",
"for",
"the",
"permissions",
"for",
"each",
"certificate",
".",
"The",
"open",
"permissions",
"for",
"the",
"document",
"can",
"be",
"AllowPrinting",
"AllowModifyContents",
"AllowCopy",
"AllowModifyAnnotations",
"AllowFillIn",
"AllowScreenReaders",
"AllowAssembly",
"and",
"AllowDegradedPrinting",
".",
"The",
"permissions",
"can",
"be",
"combined",
"by",
"ORing",
"them",
".",
"Optionally",
"DO_NOT_ENCRYPT_METADATA",
"can",
"be",
"ored",
"to",
"output",
"the",
"metadata",
"in",
"cleartext"
] | train | https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/pdf/PdfStamper.java#L346-L352 |
wwadge/bonecp | bonecp/src/main/java/com/jolbox/bonecp/PoolUtil.java | PoolUtil.fillLogParams | public static String fillLogParams(String sql, Map<Object, Object> logParams) {
"""
Returns sql statement used in this prepared statement together with the parameters.
@param sql base sql statement
@param logParams parameters to print out
@return returns printable statement
"""
StringBuilder result = new StringBuilder();
Map<Object, Object> tmpLogParam = (logParams == null ? new HashMap<Object, Object>() : logParams);
Iterator<Object> it = tmpLogParam.values().iterator();
boolean inQuote = false;
boolean inQuote2 = false;
char[] sqlChar = sql != null ? sql.toCharArray() : new char[]{};
for (int i=0; i < sqlChar.length; i++){
if (sqlChar[i] == '\''){
inQuote = !inQuote;
}
if (sqlChar[i] == '"'){
inQuote2 = !inQuote2;
}
if (sqlChar[i] == '?' && !(inQuote || inQuote2)){
if (it.hasNext()){
result.append(prettyPrint(it.next()));
} else {
result.append('?');
}
} else {
result.append(sqlChar[i]);
}
}
return result.toString();
} | java | public static String fillLogParams(String sql, Map<Object, Object> logParams) {
StringBuilder result = new StringBuilder();
Map<Object, Object> tmpLogParam = (logParams == null ? new HashMap<Object, Object>() : logParams);
Iterator<Object> it = tmpLogParam.values().iterator();
boolean inQuote = false;
boolean inQuote2 = false;
char[] sqlChar = sql != null ? sql.toCharArray() : new char[]{};
for (int i=0; i < sqlChar.length; i++){
if (sqlChar[i] == '\''){
inQuote = !inQuote;
}
if (sqlChar[i] == '"'){
inQuote2 = !inQuote2;
}
if (sqlChar[i] == '?' && !(inQuote || inQuote2)){
if (it.hasNext()){
result.append(prettyPrint(it.next()));
} else {
result.append('?');
}
} else {
result.append(sqlChar[i]);
}
}
return result.toString();
} | [
"public",
"static",
"String",
"fillLogParams",
"(",
"String",
"sql",
",",
"Map",
"<",
"Object",
",",
"Object",
">",
"logParams",
")",
"{",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"Map",
"<",
"Object",
",",
"Object",
">",
"tmpLogParam",
"=",
"(",
"logParams",
"==",
"null",
"?",
"new",
"HashMap",
"<",
"Object",
",",
"Object",
">",
"(",
")",
":",
"logParams",
")",
";",
"Iterator",
"<",
"Object",
">",
"it",
"=",
"tmpLogParam",
".",
"values",
"(",
")",
".",
"iterator",
"(",
")",
";",
"boolean",
"inQuote",
"=",
"false",
";",
"boolean",
"inQuote2",
"=",
"false",
";",
"char",
"[",
"]",
"sqlChar",
"=",
"sql",
"!=",
"null",
"?",
"sql",
".",
"toCharArray",
"(",
")",
":",
"new",
"char",
"[",
"]",
"{",
"}",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"sqlChar",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"sqlChar",
"[",
"i",
"]",
"==",
"'",
"'",
")",
"{",
"inQuote",
"=",
"!",
"inQuote",
";",
"}",
"if",
"(",
"sqlChar",
"[",
"i",
"]",
"==",
"'",
"'",
")",
"{",
"inQuote2",
"=",
"!",
"inQuote2",
";",
"}",
"if",
"(",
"sqlChar",
"[",
"i",
"]",
"==",
"'",
"'",
"&&",
"!",
"(",
"inQuote",
"||",
"inQuote2",
")",
")",
"{",
"if",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"result",
".",
"append",
"(",
"prettyPrint",
"(",
"it",
".",
"next",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"result",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"}",
"else",
"{",
"result",
".",
"append",
"(",
"sqlChar",
"[",
"i",
"]",
")",
";",
"}",
"}",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}"
] | Returns sql statement used in this prepared statement together with the parameters.
@param sql base sql statement
@param logParams parameters to print out
@return returns printable statement | [
"Returns",
"sql",
"statement",
"used",
"in",
"this",
"prepared",
"statement",
"together",
"with",
"the",
"parameters",
"."
] | train | https://github.com/wwadge/bonecp/blob/74bc3287025fc137ca28909f0f7693edae37a15d/bonecp/src/main/java/com/jolbox/bonecp/PoolUtil.java#L46-L76 |
igniterealtime/Smack | smack-experimental/src/main/java/org/jivesoftware/smackx/eme/element/ExplicitMessageEncryptionElement.java | ExplicitMessageEncryptionElement.hasProtocol | public static boolean hasProtocol(Message message, String protocolNamespace) {
"""
Return true, if the {@code message} already contains an EME element with the specified {@code protocolNamespace}.
@param message message
@param protocolNamespace namespace
@return true if message has EME element for that namespace, otherwise false
"""
List<ExtensionElement> extensionElements = message.getExtensions(
ExplicitMessageEncryptionElement.ELEMENT,
ExplicitMessageEncryptionElement.NAMESPACE);
for (ExtensionElement extensionElement : extensionElements) {
ExplicitMessageEncryptionElement e = (ExplicitMessageEncryptionElement) extensionElement;
if (e.getEncryptionNamespace().equals(protocolNamespace)) {
return true;
}
}
return false;
} | java | public static boolean hasProtocol(Message message, String protocolNamespace) {
List<ExtensionElement> extensionElements = message.getExtensions(
ExplicitMessageEncryptionElement.ELEMENT,
ExplicitMessageEncryptionElement.NAMESPACE);
for (ExtensionElement extensionElement : extensionElements) {
ExplicitMessageEncryptionElement e = (ExplicitMessageEncryptionElement) extensionElement;
if (e.getEncryptionNamespace().equals(protocolNamespace)) {
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"hasProtocol",
"(",
"Message",
"message",
",",
"String",
"protocolNamespace",
")",
"{",
"List",
"<",
"ExtensionElement",
">",
"extensionElements",
"=",
"message",
".",
"getExtensions",
"(",
"ExplicitMessageEncryptionElement",
".",
"ELEMENT",
",",
"ExplicitMessageEncryptionElement",
".",
"NAMESPACE",
")",
";",
"for",
"(",
"ExtensionElement",
"extensionElement",
":",
"extensionElements",
")",
"{",
"ExplicitMessageEncryptionElement",
"e",
"=",
"(",
"ExplicitMessageEncryptionElement",
")",
"extensionElement",
";",
"if",
"(",
"e",
".",
"getEncryptionNamespace",
"(",
")",
".",
"equals",
"(",
"protocolNamespace",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Return true, if the {@code message} already contains an EME element with the specified {@code protocolNamespace}.
@param message message
@param protocolNamespace namespace
@return true if message has EME element for that namespace, otherwise false | [
"Return",
"true",
"if",
"the",
"{",
"@code",
"message",
"}",
"already",
"contains",
"an",
"EME",
"element",
"with",
"the",
"specified",
"{",
"@code",
"protocolNamespace",
"}",
"."
] | train | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/eme/element/ExplicitMessageEncryptionElement.java#L157-L170 |
ixa-ehu/kaflib | src/main/java/ixa/kaflib/KAFDocument.java | KAFDocument.newCategory | public Feature newCategory(String id, String lemma, List<Span<Term>> references) {
"""
Creates a new category. It receives it's ID as an argument. The category is added to the document.
@param id the ID of the category.
@param lemma the lemma of the category.
@param references different mentions (list of targets) to the same category.
@return a new coreference.
"""
idManager.updateCounter(AnnotationType.CATEGORY, id);
Feature newCategory = new Feature(id, lemma, references);
annotationContainer.add(newCategory, Layer.CATEGORIES, AnnotationType.CATEGORY);
return newCategory;
} | java | public Feature newCategory(String id, String lemma, List<Span<Term>> references) {
idManager.updateCounter(AnnotationType.CATEGORY, id);
Feature newCategory = new Feature(id, lemma, references);
annotationContainer.add(newCategory, Layer.CATEGORIES, AnnotationType.CATEGORY);
return newCategory;
} | [
"public",
"Feature",
"newCategory",
"(",
"String",
"id",
",",
"String",
"lemma",
",",
"List",
"<",
"Span",
"<",
"Term",
">",
">",
"references",
")",
"{",
"idManager",
".",
"updateCounter",
"(",
"AnnotationType",
".",
"CATEGORY",
",",
"id",
")",
";",
"Feature",
"newCategory",
"=",
"new",
"Feature",
"(",
"id",
",",
"lemma",
",",
"references",
")",
";",
"annotationContainer",
".",
"add",
"(",
"newCategory",
",",
"Layer",
".",
"CATEGORIES",
",",
"AnnotationType",
".",
"CATEGORY",
")",
";",
"return",
"newCategory",
";",
"}"
] | Creates a new category. It receives it's ID as an argument. The category is added to the document.
@param id the ID of the category.
@param lemma the lemma of the category.
@param references different mentions (list of targets) to the same category.
@return a new coreference. | [
"Creates",
"a",
"new",
"category",
".",
"It",
"receives",
"it",
"s",
"ID",
"as",
"an",
"argument",
".",
"The",
"category",
"is",
"added",
"to",
"the",
"document",
"."
] | train | https://github.com/ixa-ehu/kaflib/blob/3921f55d9ae4621736a329418f6334fb721834b8/src/main/java/ixa/kaflib/KAFDocument.java#L927-L932 |
JOML-CI/JOML | src/org/joml/Vector2f.java | Vector2f.distanceSquared | public static float distanceSquared(float x1, float y1, float x2, float y2) {
"""
Return the squared distance between <code>(x1, y1)</code> and <code>(x2, y2)</code>.
@param x1
the x component of the first vector
@param y1
the y component of the first vector
@param x2
the x component of the second vector
@param y2
the y component of the second vector
@return the euclidean distance squared
"""
float dx = x1 - x2;
float dy = y1 - y2;
return dx * dx + dy * dy;
} | java | public static float distanceSquared(float x1, float y1, float x2, float y2) {
float dx = x1 - x2;
float dy = y1 - y2;
return dx * dx + dy * dy;
} | [
"public",
"static",
"float",
"distanceSquared",
"(",
"float",
"x1",
",",
"float",
"y1",
",",
"float",
"x2",
",",
"float",
"y2",
")",
"{",
"float",
"dx",
"=",
"x1",
"-",
"x2",
";",
"float",
"dy",
"=",
"y1",
"-",
"y2",
";",
"return",
"dx",
"*",
"dx",
"+",
"dy",
"*",
"dy",
";",
"}"
] | Return the squared distance between <code>(x1, y1)</code> and <code>(x2, y2)</code>.
@param x1
the x component of the first vector
@param y1
the y component of the first vector
@param x2
the x component of the second vector
@param y2
the y component of the second vector
@return the euclidean distance squared | [
"Return",
"the",
"squared",
"distance",
"between",
"<code",
">",
"(",
"x1",
"y1",
")",
"<",
"/",
"code",
">",
"and",
"<code",
">",
"(",
"x2",
"y2",
")",
"<",
"/",
"code",
">",
"."
] | train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Vector2f.java#L607-L611 |
sawano/java-commons | src/main/java/se/sawano/java/commons/lang/validate/AbstractValidate.java | AbstractValidate.isFalse | public void isFalse(final boolean expression, final String message, final long value) {
"""
<p>Validate that the argument condition is {@code false}; otherwise throwing an exception with the specified message. This method is useful when validating according to an arbitrary boolean
expression, such as validating a primitive number or using your own custom validation expression.</p>
<pre>
Validate.isFalse(age <= 20, "The age must be greater than 20: %d", age);
</pre>
<p>For performance reasons, the long value is passed as a separate parameter and appended to the exception message only in the case of an error.</p>
@param expression
the boolean expression to check
@param message
the {@link String#format(String, Object...)} exception message if invalid, not null
@param value
the value to append to the message when invalid
@throws IllegalArgumentValidationException
if expression is {@code true}
@see #isFalse(boolean)
@see #isFalse(boolean, String, double)
@see #isFalse(boolean, String, Object...)
"""
if (expression) {
fail(String.format(message, value));
}
} | java | public void isFalse(final boolean expression, final String message, final long value) {
if (expression) {
fail(String.format(message, value));
}
} | [
"public",
"void",
"isFalse",
"(",
"final",
"boolean",
"expression",
",",
"final",
"String",
"message",
",",
"final",
"long",
"value",
")",
"{",
"if",
"(",
"expression",
")",
"{",
"fail",
"(",
"String",
".",
"format",
"(",
"message",
",",
"value",
")",
")",
";",
"}",
"}"
] | <p>Validate that the argument condition is {@code false}; otherwise throwing an exception with the specified message. This method is useful when validating according to an arbitrary boolean
expression, such as validating a primitive number or using your own custom validation expression.</p>
<pre>
Validate.isFalse(age <= 20, "The age must be greater than 20: %d", age);
</pre>
<p>For performance reasons, the long value is passed as a separate parameter and appended to the exception message only in the case of an error.</p>
@param expression
the boolean expression to check
@param message
the {@link String#format(String, Object...)} exception message if invalid, not null
@param value
the value to append to the message when invalid
@throws IllegalArgumentValidationException
if expression is {@code true}
@see #isFalse(boolean)
@see #isFalse(boolean, String, double)
@see #isFalse(boolean, String, Object...) | [
"<p",
">",
"Validate",
"that",
"the",
"argument",
"condition",
"is",
"{",
"@code",
"false",
"}",
";",
"otherwise",
"throwing",
"an",
"exception",
"with",
"the",
"specified",
"message",
".",
"This",
"method",
"is",
"useful",
"when",
"validating",
"according",
"to",
"an",
"arbitrary",
"boolean",
"expression",
"such",
"as",
"validating",
"a",
"primitive",
"number",
"or",
"using",
"your",
"own",
"custom",
"validation",
"expression",
".",
"<",
"/",
"p",
">",
"<pre",
">",
"Validate",
".",
"isFalse",
"(",
"age",
"<",
";",
"=",
"20",
"The",
"age",
"must",
"be",
"greater",
"than",
"20",
":",
"%",
";",
"d",
"age",
")",
";",
"<",
"/",
"pre",
">",
"<p",
">",
"For",
"performance",
"reasons",
"the",
"long",
"value",
"is",
"passed",
"as",
"a",
"separate",
"parameter",
"and",
"appended",
"to",
"the",
"exception",
"message",
"only",
"in",
"the",
"case",
"of",
"an",
"error",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/sawano/java-commons/blob/6f219c9e8dec4401dbe528d17ae6ec1ef9c0d284/src/main/java/se/sawano/java/commons/lang/validate/AbstractValidate.java#L406-L410 |
apache/spark | sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/OffHeapColumnVector.java | OffHeapColumnVector.allocateColumns | public static OffHeapColumnVector[] allocateColumns(int capacity, StructField[] fields) {
"""
Allocates columns to store elements of each field off heap.
Capacity is the initial capacity of the vector and it will grow as necessary. Capacity is
in number of elements, not number of bytes.
"""
OffHeapColumnVector[] vectors = new OffHeapColumnVector[fields.length];
for (int i = 0; i < fields.length; i++) {
vectors[i] = new OffHeapColumnVector(capacity, fields[i].dataType());
}
return vectors;
} | java | public static OffHeapColumnVector[] allocateColumns(int capacity, StructField[] fields) {
OffHeapColumnVector[] vectors = new OffHeapColumnVector[fields.length];
for (int i = 0; i < fields.length; i++) {
vectors[i] = new OffHeapColumnVector(capacity, fields[i].dataType());
}
return vectors;
} | [
"public",
"static",
"OffHeapColumnVector",
"[",
"]",
"allocateColumns",
"(",
"int",
"capacity",
",",
"StructField",
"[",
"]",
"fields",
")",
"{",
"OffHeapColumnVector",
"[",
"]",
"vectors",
"=",
"new",
"OffHeapColumnVector",
"[",
"fields",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"fields",
".",
"length",
";",
"i",
"++",
")",
"{",
"vectors",
"[",
"i",
"]",
"=",
"new",
"OffHeapColumnVector",
"(",
"capacity",
",",
"fields",
"[",
"i",
"]",
".",
"dataType",
"(",
")",
")",
";",
"}",
"return",
"vectors",
";",
"}"
] | Allocates columns to store elements of each field off heap.
Capacity is the initial capacity of the vector and it will grow as necessary. Capacity is
in number of elements, not number of bytes. | [
"Allocates",
"columns",
"to",
"store",
"elements",
"of",
"each",
"field",
"off",
"heap",
".",
"Capacity",
"is",
"the",
"initial",
"capacity",
"of",
"the",
"vector",
"and",
"it",
"will",
"grow",
"as",
"necessary",
".",
"Capacity",
"is",
"in",
"number",
"of",
"elements",
"not",
"number",
"of",
"bytes",
"."
] | train | https://github.com/apache/spark/blob/25ee0474f47d9c30d6f553a7892d9549f91071cf/sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/OffHeapColumnVector.java#L50-L56 |
elki-project/elki | elki-gui-minigui/src/main/java/de/lmu/ifi/dbs/elki/gui/util/SavedSettingsFile.java | SavedSettingsFile.put | public void put(String key, ArrayList<String> value) {
"""
Add/Replace a saved setting
@param key Key
@param value (New) value.
"""
Iterator<Pair<String, ArrayList<String>>> it = store.iterator();
while (it.hasNext()) {
Pair<String, ArrayList<String>> pair = it.next();
if (key.equals(pair.first)) {
pair.second = value;
return;
}
}
store.add(new Pair<>(key, value));
} | java | public void put(String key, ArrayList<String> value) {
Iterator<Pair<String, ArrayList<String>>> it = store.iterator();
while (it.hasNext()) {
Pair<String, ArrayList<String>> pair = it.next();
if (key.equals(pair.first)) {
pair.second = value;
return;
}
}
store.add(new Pair<>(key, value));
} | [
"public",
"void",
"put",
"(",
"String",
"key",
",",
"ArrayList",
"<",
"String",
">",
"value",
")",
"{",
"Iterator",
"<",
"Pair",
"<",
"String",
",",
"ArrayList",
"<",
"String",
">",
">",
">",
"it",
"=",
"store",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"Pair",
"<",
"String",
",",
"ArrayList",
"<",
"String",
">",
">",
"pair",
"=",
"it",
".",
"next",
"(",
")",
";",
"if",
"(",
"key",
".",
"equals",
"(",
"pair",
".",
"first",
")",
")",
"{",
"pair",
".",
"second",
"=",
"value",
";",
"return",
";",
"}",
"}",
"store",
".",
"add",
"(",
"new",
"Pair",
"<>",
"(",
"key",
",",
"value",
")",
")",
";",
"}"
] | Add/Replace a saved setting
@param key Key
@param value (New) value. | [
"Add",
"/",
"Replace",
"a",
"saved",
"setting"
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-gui-minigui/src/main/java/de/lmu/ifi/dbs/elki/gui/util/SavedSettingsFile.java#L168-L178 |
vkostyukov/la4j | src/main/java/org/la4j/matrix/ColumnMajorSparseMatrix.java | ColumnMajorSparseMatrix.from1DArray | public static ColumnMajorSparseMatrix from1DArray(int rows, int columns, double[] array) {
"""
Creates a new {@link ColumnMajorSparseMatrix} from the given 1D {@code array} with
compressing (copying) the underlying array.
"""
return CCSMatrix.from1DArray(rows, columns, array);
} | java | public static ColumnMajorSparseMatrix from1DArray(int rows, int columns, double[] array) {
return CCSMatrix.from1DArray(rows, columns, array);
} | [
"public",
"static",
"ColumnMajorSparseMatrix",
"from1DArray",
"(",
"int",
"rows",
",",
"int",
"columns",
",",
"double",
"[",
"]",
"array",
")",
"{",
"return",
"CCSMatrix",
".",
"from1DArray",
"(",
"rows",
",",
"columns",
",",
"array",
")",
";",
"}"
] | Creates a new {@link ColumnMajorSparseMatrix} from the given 1D {@code array} with
compressing (copying) the underlying array. | [
"Creates",
"a",
"new",
"{"
] | train | https://github.com/vkostyukov/la4j/blob/dd1b917caf9606399a49afa6b0d738934cd3a7b3/src/main/java/org/la4j/matrix/ColumnMajorSparseMatrix.java#L99-L101 |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/MariaDbDatabaseMetaData.java | MariaDbDatabaseMetaData.getSuperTables | public ResultSet getSuperTables(String catalog, String schemaPattern, String tableNamePattern)
throws SQLException {
"""
Retrieves a description of the table hierarchies defined in a particular schema in this
database.
<P>Only supertable information for tables matching the catalog, schema and table name are
returned. The table name parameter may be a fully-qualified name, in which case, the catalog
and schemaPattern parameters are ignored. If a table does not have a super table, it is not
listed here. Supertables have to be defined in the same catalog and schema as the sub tables.
Therefore, the type description does not need to include this information for the
supertable.</p>
<P>Each type description has the following columns:</p>
<OL> <li><B>TABLE_CAT</B> String {@code
=>} the type's catalog (may be <code>null</code>)
<li><B>TABLE_SCHEM</B> String {@code =>} type's schema (may be <code>null</code>)
<li><B>TABLE_NAME</B> String
{@code =>} type name
<li><B>SUPERTABLE_NAME</B> String {@code =>} the direct super type's name </OL>
<P><B>Note:</B> If the driver does not support type hierarchies, an empty result set is
returned.</p>
@param catalog a catalog name; "" retrieves those without a catalog; <code>null</code>
means drop catalog name from the selection criteria
@param schemaPattern a schema name pattern; "" retrieves those without a schema
@param tableNamePattern a table name pattern; may be a fully-qualified name
@return a <code>ResultSet</code> object in which each row is a type description
@throws SQLException if a database access error occurs
@see #getSearchStringEscape
@since 1.4
"""
String sql =
"SELECT ' ' TABLE_CAT, ' ' TABLE_SCHEM, ' ' TABLE_NAME, ' ' SUPERTABLE_NAME FROM DUAL WHERE 1=0";
return executeQuery(sql);
} | java | public ResultSet getSuperTables(String catalog, String schemaPattern, String tableNamePattern)
throws SQLException {
String sql =
"SELECT ' ' TABLE_CAT, ' ' TABLE_SCHEM, ' ' TABLE_NAME, ' ' SUPERTABLE_NAME FROM DUAL WHERE 1=0";
return executeQuery(sql);
} | [
"public",
"ResultSet",
"getSuperTables",
"(",
"String",
"catalog",
",",
"String",
"schemaPattern",
",",
"String",
"tableNamePattern",
")",
"throws",
"SQLException",
"{",
"String",
"sql",
"=",
"\"SELECT ' ' TABLE_CAT, ' ' TABLE_SCHEM, ' ' TABLE_NAME, ' ' SUPERTABLE_NAME FROM DUAL WHERE 1=0\"",
";",
"return",
"executeQuery",
"(",
"sql",
")",
";",
"}"
] | Retrieves a description of the table hierarchies defined in a particular schema in this
database.
<P>Only supertable information for tables matching the catalog, schema and table name are
returned. The table name parameter may be a fully-qualified name, in which case, the catalog
and schemaPattern parameters are ignored. If a table does not have a super table, it is not
listed here. Supertables have to be defined in the same catalog and schema as the sub tables.
Therefore, the type description does not need to include this information for the
supertable.</p>
<P>Each type description has the following columns:</p>
<OL> <li><B>TABLE_CAT</B> String {@code
=>} the type's catalog (may be <code>null</code>)
<li><B>TABLE_SCHEM</B> String {@code =>} type's schema (may be <code>null</code>)
<li><B>TABLE_NAME</B> String
{@code =>} type name
<li><B>SUPERTABLE_NAME</B> String {@code =>} the direct super type's name </OL>
<P><B>Note:</B> If the driver does not support type hierarchies, an empty result set is
returned.</p>
@param catalog a catalog name; "" retrieves those without a catalog; <code>null</code>
means drop catalog name from the selection criteria
@param schemaPattern a schema name pattern; "" retrieves those without a schema
@param tableNamePattern a table name pattern; may be a fully-qualified name
@return a <code>ResultSet</code> object in which each row is a type description
@throws SQLException if a database access error occurs
@see #getSearchStringEscape
@since 1.4 | [
"Retrieves",
"a",
"description",
"of",
"the",
"table",
"hierarchies",
"defined",
"in",
"a",
"particular",
"schema",
"in",
"this",
"database",
"."
] | train | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbDatabaseMetaData.java#L2786-L2791 |
amzn/ion-java | src/com/amazon/ion/facet/Facets.java | Facets.asFacet | public static <T> T asFacet(Class<T> facetType, Faceted subject) {
"""
Returns a facet of the given subject if supported, returning null
otherwise.
<p>
This does not attempt to cast the subject to the requested type, since
the {@link Faceted} interface declares the intent to control the
conversion.
@return the requested facet, or null if {@code subject} is null or if
subject doesn't support the requested facet type.
"""
return subject == null ? null : subject.asFacet(facetType);
} | java | public static <T> T asFacet(Class<T> facetType, Faceted subject)
{
return subject == null ? null : subject.asFacet(facetType);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"asFacet",
"(",
"Class",
"<",
"T",
">",
"facetType",
",",
"Faceted",
"subject",
")",
"{",
"return",
"subject",
"==",
"null",
"?",
"null",
":",
"subject",
".",
"asFacet",
"(",
"facetType",
")",
";",
"}"
] | Returns a facet of the given subject if supported, returning null
otherwise.
<p>
This does not attempt to cast the subject to the requested type, since
the {@link Faceted} interface declares the intent to control the
conversion.
@return the requested facet, or null if {@code subject} is null or if
subject doesn't support the requested facet type. | [
"Returns",
"a",
"facet",
"of",
"the",
"given",
"subject",
"if",
"supported",
"returning",
"null",
"otherwise",
".",
"<p",
">",
"This",
"does",
"not",
"attempt",
"to",
"cast",
"the",
"subject",
"to",
"the",
"requested",
"type",
"since",
"the",
"{",
"@link",
"Faceted",
"}",
"interface",
"declares",
"the",
"intent",
"to",
"control",
"the",
"conversion",
"."
] | train | https://github.com/amzn/ion-java/blob/4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270/src/com/amazon/ion/facet/Facets.java#L44-L47 |
kuali/ojb-1.0.4 | src/xdoclet/java/src/xdoclet/modules/ojb/OjbTagsHandler.java | OjbTagsHandler.forAllValuePairs | public void forAllValuePairs(String template, Properties attributes) throws XDocletException {
"""
Processes the template for the comma-separated value pairs in an attribute of the current object on the specified level.
@param template The template
@param attributes The attributes of the tag
@exception XDocletException if an error occurs
@doc.tag type="block"
@doc.param name="level" optional="false" description="The level for the current object"
values="class,field,reference,collection"
@doc.param name="name" optional="true" description="The name of the attribute containg attributes (defaults to 'attributes')"
@doc.param name="default-right" optional="true" description="The default right value if none is given (defaults to empty value)"
"""
String name = attributes.getProperty(ATTRIBUTE_NAME, "attributes");
String defaultValue = attributes.getProperty(ATTRIBUTE_DEFAULT_RIGHT, "");
String attributePairs = getPropertyValue(attributes.getProperty(ATTRIBUTE_LEVEL), name);
if ((attributePairs == null) || (attributePairs.length() == 0))
{
return;
}
String token;
int pos;
for (CommaListIterator it = new CommaListIterator(attributePairs); it.hasNext();)
{
token = it.getNext();
pos = token.indexOf('=');
if (pos >= 0)
{
_curPairLeft = token.substring(0, pos);
_curPairRight = (pos < token.length() - 1 ? token.substring(pos + 1) : defaultValue);
}
else
{
_curPairLeft = token;
_curPairRight = defaultValue;
}
if (_curPairLeft.length() > 0)
{
generate(template);
}
}
_curPairLeft = null;
_curPairRight = null;
} | java | public void forAllValuePairs(String template, Properties attributes) throws XDocletException
{
String name = attributes.getProperty(ATTRIBUTE_NAME, "attributes");
String defaultValue = attributes.getProperty(ATTRIBUTE_DEFAULT_RIGHT, "");
String attributePairs = getPropertyValue(attributes.getProperty(ATTRIBUTE_LEVEL), name);
if ((attributePairs == null) || (attributePairs.length() == 0))
{
return;
}
String token;
int pos;
for (CommaListIterator it = new CommaListIterator(attributePairs); it.hasNext();)
{
token = it.getNext();
pos = token.indexOf('=');
if (pos >= 0)
{
_curPairLeft = token.substring(0, pos);
_curPairRight = (pos < token.length() - 1 ? token.substring(pos + 1) : defaultValue);
}
else
{
_curPairLeft = token;
_curPairRight = defaultValue;
}
if (_curPairLeft.length() > 0)
{
generate(template);
}
}
_curPairLeft = null;
_curPairRight = null;
} | [
"public",
"void",
"forAllValuePairs",
"(",
"String",
"template",
",",
"Properties",
"attributes",
")",
"throws",
"XDocletException",
"{",
"String",
"name",
"=",
"attributes",
".",
"getProperty",
"(",
"ATTRIBUTE_NAME",
",",
"\"attributes\"",
")",
";",
"String",
"defaultValue",
"=",
"attributes",
".",
"getProperty",
"(",
"ATTRIBUTE_DEFAULT_RIGHT",
",",
"\"\"",
")",
";",
"String",
"attributePairs",
"=",
"getPropertyValue",
"(",
"attributes",
".",
"getProperty",
"(",
"ATTRIBUTE_LEVEL",
")",
",",
"name",
")",
";",
"if",
"(",
"(",
"attributePairs",
"==",
"null",
")",
"||",
"(",
"attributePairs",
".",
"length",
"(",
")",
"==",
"0",
")",
")",
"{",
"return",
";",
"}",
"String",
"token",
";",
"int",
"pos",
";",
"for",
"(",
"CommaListIterator",
"it",
"=",
"new",
"CommaListIterator",
"(",
"attributePairs",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"token",
"=",
"it",
".",
"getNext",
"(",
")",
";",
"pos",
"=",
"token",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"pos",
">=",
"0",
")",
"{",
"_curPairLeft",
"=",
"token",
".",
"substring",
"(",
"0",
",",
"pos",
")",
";",
"_curPairRight",
"=",
"(",
"pos",
"<",
"token",
".",
"length",
"(",
")",
"-",
"1",
"?",
"token",
".",
"substring",
"(",
"pos",
"+",
"1",
")",
":",
"defaultValue",
")",
";",
"}",
"else",
"{",
"_curPairLeft",
"=",
"token",
";",
"_curPairRight",
"=",
"defaultValue",
";",
"}",
"if",
"(",
"_curPairLeft",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"generate",
"(",
"template",
")",
";",
"}",
"}",
"_curPairLeft",
"=",
"null",
";",
"_curPairRight",
"=",
"null",
";",
"}"
] | Processes the template for the comma-separated value pairs in an attribute of the current object on the specified level.
@param template The template
@param attributes The attributes of the tag
@exception XDocletException if an error occurs
@doc.tag type="block"
@doc.param name="level" optional="false" description="The level for the current object"
values="class,field,reference,collection"
@doc.param name="name" optional="true" description="The name of the attribute containg attributes (defaults to 'attributes')"
@doc.param name="default-right" optional="true" description="The default right value if none is given (defaults to empty value)" | [
"Processes",
"the",
"template",
"for",
"the",
"comma",
"-",
"separated",
"value",
"pairs",
"in",
"an",
"attribute",
"of",
"the",
"current",
"object",
"on",
"the",
"specified",
"level",
"."
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/xdoclet/java/src/xdoclet/modules/ojb/OjbTagsHandler.java#L1616-L1651 |
aws/aws-sdk-java | aws-java-sdk-servicediscovery/src/main/java/com/amazonaws/services/servicediscovery/model/Operation.java | Operation.withTargets | public Operation withTargets(java.util.Map<String, String> targets) {
"""
<p>
The name of the target entity that is associated with the operation:
</p>
<ul>
<li>
<p>
<b>NAMESPACE</b>: The namespace ID is returned in the <code>ResourceId</code> property.
</p>
</li>
<li>
<p>
<b>SERVICE</b>: The service ID is returned in the <code>ResourceId</code> property.
</p>
</li>
<li>
<p>
<b>INSTANCE</b>: The instance ID is returned in the <code>ResourceId</code> property.
</p>
</li>
</ul>
@param targets
The name of the target entity that is associated with the operation:</p>
<ul>
<li>
<p>
<b>NAMESPACE</b>: The namespace ID is returned in the <code>ResourceId</code> property.
</p>
</li>
<li>
<p>
<b>SERVICE</b>: The service ID is returned in the <code>ResourceId</code> property.
</p>
</li>
<li>
<p>
<b>INSTANCE</b>: The instance ID is returned in the <code>ResourceId</code> property.
</p>
</li>
@return Returns a reference to this object so that method calls can be chained together.
"""
setTargets(targets);
return this;
} | java | public Operation withTargets(java.util.Map<String, String> targets) {
setTargets(targets);
return this;
} | [
"public",
"Operation",
"withTargets",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"targets",
")",
"{",
"setTargets",
"(",
"targets",
")",
";",
"return",
"this",
";",
"}"
] | <p>
The name of the target entity that is associated with the operation:
</p>
<ul>
<li>
<p>
<b>NAMESPACE</b>: The namespace ID is returned in the <code>ResourceId</code> property.
</p>
</li>
<li>
<p>
<b>SERVICE</b>: The service ID is returned in the <code>ResourceId</code> property.
</p>
</li>
<li>
<p>
<b>INSTANCE</b>: The instance ID is returned in the <code>ResourceId</code> property.
</p>
</li>
</ul>
@param targets
The name of the target entity that is associated with the operation:</p>
<ul>
<li>
<p>
<b>NAMESPACE</b>: The namespace ID is returned in the <code>ResourceId</code> property.
</p>
</li>
<li>
<p>
<b>SERVICE</b>: The service ID is returned in the <code>ResourceId</code> property.
</p>
</li>
<li>
<p>
<b>INSTANCE</b>: The instance ID is returned in the <code>ResourceId</code> property.
</p>
</li>
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"The",
"name",
"of",
"the",
"target",
"entity",
"that",
"is",
"associated",
"with",
"the",
"operation",
":",
"<",
"/",
"p",
">",
"<ul",
">",
"<li",
">",
"<p",
">",
"<b",
">",
"NAMESPACE<",
"/",
"b",
">",
":",
"The",
"namespace",
"ID",
"is",
"returned",
"in",
"the",
"<code",
">",
"ResourceId<",
"/",
"code",
">",
"property",
".",
"<",
"/",
"p",
">",
"<",
"/",
"li",
">",
"<li",
">",
"<p",
">",
"<b",
">",
"SERVICE<",
"/",
"b",
">",
":",
"The",
"service",
"ID",
"is",
"returned",
"in",
"the",
"<code",
">",
"ResourceId<",
"/",
"code",
">",
"property",
".",
"<",
"/",
"p",
">",
"<",
"/",
"li",
">",
"<li",
">",
"<p",
">",
"<b",
">",
"INSTANCE<",
"/",
"b",
">",
":",
"The",
"instance",
"ID",
"is",
"returned",
"in",
"the",
"<code",
">",
"ResourceId<",
"/",
"code",
">",
"property",
".",
"<",
"/",
"p",
">",
"<",
"/",
"li",
">",
"<",
"/",
"ul",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-servicediscovery/src/main/java/com/amazonaws/services/servicediscovery/model/Operation.java#L1033-L1036 |
DDTH/ddth-commons | ddth-commons-core/src/main/java/com/github/ddth/commons/utils/TypesafeConfigUtils.java | TypesafeConfigUtils.getPeriod | public static Period getPeriod(Config config, String path) {
"""
Get a configuration as period (parses special strings like "1w"). Return {@code null}
if missing, wrong type or bad value.
@param config
@param path
@return
"""
try {
return config.getPeriod(path);
} catch (ConfigException.Missing | ConfigException.WrongType | ConfigException.BadValue e) {
if (e instanceof ConfigException.WrongType || e instanceof ConfigException.BadValue) {
LOGGER.warn(e.getMessage(), e);
}
return null;
}
} | java | public static Period getPeriod(Config config, String path) {
try {
return config.getPeriod(path);
} catch (ConfigException.Missing | ConfigException.WrongType | ConfigException.BadValue e) {
if (e instanceof ConfigException.WrongType || e instanceof ConfigException.BadValue) {
LOGGER.warn(e.getMessage(), e);
}
return null;
}
} | [
"public",
"static",
"Period",
"getPeriod",
"(",
"Config",
"config",
",",
"String",
"path",
")",
"{",
"try",
"{",
"return",
"config",
".",
"getPeriod",
"(",
"path",
")",
";",
"}",
"catch",
"(",
"ConfigException",
".",
"Missing",
"|",
"ConfigException",
".",
"WrongType",
"|",
"ConfigException",
".",
"BadValue",
"e",
")",
"{",
"if",
"(",
"e",
"instanceof",
"ConfigException",
".",
"WrongType",
"||",
"e",
"instanceof",
"ConfigException",
".",
"BadValue",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"return",
"null",
";",
"}",
"}"
] | Get a configuration as period (parses special strings like "1w"). Return {@code null}
if missing, wrong type or bad value.
@param config
@param path
@return | [
"Get",
"a",
"configuration",
"as",
"period",
"(",
"parses",
"special",
"strings",
"like",
"1w",
")",
".",
"Return",
"{",
"@code",
"null",
"}",
"if",
"missing",
"wrong",
"type",
"or",
"bad",
"value",
"."
] | train | https://github.com/DDTH/ddth-commons/blob/734f0e77321d41eeca78a557be9884df9874e46e/ddth-commons-core/src/main/java/com/github/ddth/commons/utils/TypesafeConfigUtils.java#L604-L613 |
OpenLiberty/open-liberty | dev/com.ibm.ws.container.service.compat/src/com/ibm/ws/util/ThreadContextAccessor.java | ThreadContextAccessor.repushContextClassLoader | public Object repushContextClassLoader(Object origLoader, ClassLoader loader) {
"""
Updates the context class loader of the current thread between calls to {@link #pushContextClassLoader} and {@link #popContextClassLoader}. If
the original class loader is {@link #UNCHANGED}, then this is equivalent
to {@link #pushContextClassLoader}). Otherwise, this is equivalent to {@link #setContextClassLoader}, and the passed class loader is returned.
The suggested pattern of use is:
<pre>
Object origCL = ThreadContextAccessor.UNCHANGED;
try {
for (SomeContext ctx : contexts) {
ClassLoader cl = ctx.getClassLoader();
origCL = svThreadContextAccessor.repushContextClassLoader(origCL, cl);
...
}
} finally {
svThreadContextAccessor.popContextClassLoader(origCL);
}
</pre>
@param origLoader the result of {@link #pushContextClassLoader} or {@link #repushContextClassLoader}
@param loader the new context class loader
@return the original context class loader, or {@link #UNCHANGED}
"""
if (origLoader == UNCHANGED) {
return pushContextClassLoader(loader);
}
setContextClassLoader(Thread.currentThread(), loader);
return origLoader;
} | java | public Object repushContextClassLoader(Object origLoader, ClassLoader loader) {
if (origLoader == UNCHANGED) {
return pushContextClassLoader(loader);
}
setContextClassLoader(Thread.currentThread(), loader);
return origLoader;
} | [
"public",
"Object",
"repushContextClassLoader",
"(",
"Object",
"origLoader",
",",
"ClassLoader",
"loader",
")",
"{",
"if",
"(",
"origLoader",
"==",
"UNCHANGED",
")",
"{",
"return",
"pushContextClassLoader",
"(",
"loader",
")",
";",
"}",
"setContextClassLoader",
"(",
"Thread",
".",
"currentThread",
"(",
")",
",",
"loader",
")",
";",
"return",
"origLoader",
";",
"}"
] | Updates the context class loader of the current thread between calls to {@link #pushContextClassLoader} and {@link #popContextClassLoader}. If
the original class loader is {@link #UNCHANGED}, then this is equivalent
to {@link #pushContextClassLoader}). Otherwise, this is equivalent to {@link #setContextClassLoader}, and the passed class loader is returned.
The suggested pattern of use is:
<pre>
Object origCL = ThreadContextAccessor.UNCHANGED;
try {
for (SomeContext ctx : contexts) {
ClassLoader cl = ctx.getClassLoader();
origCL = svThreadContextAccessor.repushContextClassLoader(origCL, cl);
...
}
} finally {
svThreadContextAccessor.popContextClassLoader(origCL);
}
</pre>
@param origLoader the result of {@link #pushContextClassLoader} or {@link #repushContextClassLoader}
@param loader the new context class loader
@return the original context class loader, or {@link #UNCHANGED} | [
"Updates",
"the",
"context",
"class",
"loader",
"of",
"the",
"current",
"thread",
"between",
"calls",
"to",
"{",
"@link",
"#pushContextClassLoader",
"}",
"and",
"{",
"@link",
"#popContextClassLoader",
"}",
".",
"If",
"the",
"original",
"class",
"loader",
"is",
"{",
"@link",
"#UNCHANGED",
"}",
"then",
"this",
"is",
"equivalent",
"to",
"{",
"@link",
"#pushContextClassLoader",
"}",
")",
".",
"Otherwise",
"this",
"is",
"equivalent",
"to",
"{",
"@link",
"#setContextClassLoader",
"}",
"and",
"the",
"passed",
"class",
"loader",
"is",
"returned",
".",
"The",
"suggested",
"pattern",
"of",
"use",
"is",
":"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.container.service.compat/src/com/ibm/ws/util/ThreadContextAccessor.java#L179-L186 |
apache/flink | flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/operators/GenericWriteAheadSink.java | GenericWriteAheadSink.saveHandleInState | private void saveHandleInState(final long checkpointId, final long timestamp) throws Exception {
"""
Called when a checkpoint barrier arrives. It closes any open streams to the backend
and marks them as pending for committing to the external, third-party storage system.
@param checkpointId the id of the latest received checkpoint.
@throws IOException in case something went wrong when handling the stream to the backend.
"""
//only add handle if a new OperatorState was created since the last snapshot
if (out != null) {
int subtaskIdx = getRuntimeContext().getIndexOfThisSubtask();
StreamStateHandle handle = out.closeAndGetHandle();
PendingCheckpoint pendingCheckpoint = new PendingCheckpoint(
checkpointId, subtaskIdx, timestamp, handle);
if (pendingCheckpoints.contains(pendingCheckpoint)) {
//we already have a checkpoint stored for that ID that may have been partially written,
//so we discard this "alternate version" and use the stored checkpoint
handle.discardState();
} else {
pendingCheckpoints.add(pendingCheckpoint);
}
out = null;
}
} | java | private void saveHandleInState(final long checkpointId, final long timestamp) throws Exception {
//only add handle if a new OperatorState was created since the last snapshot
if (out != null) {
int subtaskIdx = getRuntimeContext().getIndexOfThisSubtask();
StreamStateHandle handle = out.closeAndGetHandle();
PendingCheckpoint pendingCheckpoint = new PendingCheckpoint(
checkpointId, subtaskIdx, timestamp, handle);
if (pendingCheckpoints.contains(pendingCheckpoint)) {
//we already have a checkpoint stored for that ID that may have been partially written,
//so we discard this "alternate version" and use the stored checkpoint
handle.discardState();
} else {
pendingCheckpoints.add(pendingCheckpoint);
}
out = null;
}
} | [
"private",
"void",
"saveHandleInState",
"(",
"final",
"long",
"checkpointId",
",",
"final",
"long",
"timestamp",
")",
"throws",
"Exception",
"{",
"//only add handle if a new OperatorState was created since the last snapshot",
"if",
"(",
"out",
"!=",
"null",
")",
"{",
"int",
"subtaskIdx",
"=",
"getRuntimeContext",
"(",
")",
".",
"getIndexOfThisSubtask",
"(",
")",
";",
"StreamStateHandle",
"handle",
"=",
"out",
".",
"closeAndGetHandle",
"(",
")",
";",
"PendingCheckpoint",
"pendingCheckpoint",
"=",
"new",
"PendingCheckpoint",
"(",
"checkpointId",
",",
"subtaskIdx",
",",
"timestamp",
",",
"handle",
")",
";",
"if",
"(",
"pendingCheckpoints",
".",
"contains",
"(",
"pendingCheckpoint",
")",
")",
"{",
"//we already have a checkpoint stored for that ID that may have been partially written,",
"//so we discard this \"alternate version\" and use the stored checkpoint",
"handle",
".",
"discardState",
"(",
")",
";",
"}",
"else",
"{",
"pendingCheckpoints",
".",
"add",
"(",
"pendingCheckpoint",
")",
";",
"}",
"out",
"=",
"null",
";",
"}",
"}"
] | Called when a checkpoint barrier arrives. It closes any open streams to the backend
and marks them as pending for committing to the external, third-party storage system.
@param checkpointId the id of the latest received checkpoint.
@throws IOException in case something went wrong when handling the stream to the backend. | [
"Called",
"when",
"a",
"checkpoint",
"barrier",
"arrives",
".",
"It",
"closes",
"any",
"open",
"streams",
"to",
"the",
"backend",
"and",
"marks",
"them",
"as",
"pending",
"for",
"committing",
"to",
"the",
"external",
"third",
"-",
"party",
"storage",
"system",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/operators/GenericWriteAheadSink.java#L136-L155 |
exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java | LinkedWorkspaceStorageCacheImpl.removeSiblings | protected void removeSiblings(final NodeData node) {
"""
Remove sibling's subtrees from cache C, CN, CP.<br> For update (order-before) usecase.<br>
The work does remove of all descendants of the item parent. I.e. the node and its siblings (for
SNS case).<br>
"""
if (node.getIdentifier().equals(Constants.ROOT_UUID))
{
return;
}
// remove child nodes of the item parent recursive
writeLock.lock();
try
{
// remove on-parent child nodes list
nodesCache.remove(node.getParentIdentifier());
// go through the C and remove every descendant of the node parent
final QPath path = node.getQPath().makeParentPath();
final List<CacheId> toRemove = new ArrayList<CacheId>();
// find and remove by path
for (Iterator<Map.Entry<CacheKey, CacheValue>> citer = cache.entrySet().iterator(); citer.hasNext();)
{
Map.Entry<CacheKey, CacheValue> ce = citer.next();
CacheKey key = ce.getKey();
CacheValue v = ce.getValue();
if (v != null)
{
if (key.isDescendantOf(path))
{
// will remove by id too
toRemove.add(new CacheId(v.getItem().getIdentifier()));
citer.remove(); // remove
nodesCache.remove(v.getItem().getIdentifier());
propertiesCache.remove(v.getItem().getIdentifier());
}
}
else
{
citer.remove(); // remove empty C record
}
}
for (CacheId id : toRemove)
{
cache.remove(id);
}
toRemove.clear();
}
finally
{
writeLock.unlock();
}
} | java | protected void removeSiblings(final NodeData node)
{
if (node.getIdentifier().equals(Constants.ROOT_UUID))
{
return;
}
// remove child nodes of the item parent recursive
writeLock.lock();
try
{
// remove on-parent child nodes list
nodesCache.remove(node.getParentIdentifier());
// go through the C and remove every descendant of the node parent
final QPath path = node.getQPath().makeParentPath();
final List<CacheId> toRemove = new ArrayList<CacheId>();
// find and remove by path
for (Iterator<Map.Entry<CacheKey, CacheValue>> citer = cache.entrySet().iterator(); citer.hasNext();)
{
Map.Entry<CacheKey, CacheValue> ce = citer.next();
CacheKey key = ce.getKey();
CacheValue v = ce.getValue();
if (v != null)
{
if (key.isDescendantOf(path))
{
// will remove by id too
toRemove.add(new CacheId(v.getItem().getIdentifier()));
citer.remove(); // remove
nodesCache.remove(v.getItem().getIdentifier());
propertiesCache.remove(v.getItem().getIdentifier());
}
}
else
{
citer.remove(); // remove empty C record
}
}
for (CacheId id : toRemove)
{
cache.remove(id);
}
toRemove.clear();
}
finally
{
writeLock.unlock();
}
} | [
"protected",
"void",
"removeSiblings",
"(",
"final",
"NodeData",
"node",
")",
"{",
"if",
"(",
"node",
".",
"getIdentifier",
"(",
")",
".",
"equals",
"(",
"Constants",
".",
"ROOT_UUID",
")",
")",
"{",
"return",
";",
"}",
"// remove child nodes of the item parent recursive",
"writeLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"// remove on-parent child nodes list",
"nodesCache",
".",
"remove",
"(",
"node",
".",
"getParentIdentifier",
"(",
")",
")",
";",
"// go through the C and remove every descendant of the node parent",
"final",
"QPath",
"path",
"=",
"node",
".",
"getQPath",
"(",
")",
".",
"makeParentPath",
"(",
")",
";",
"final",
"List",
"<",
"CacheId",
">",
"toRemove",
"=",
"new",
"ArrayList",
"<",
"CacheId",
">",
"(",
")",
";",
"// find and remove by path",
"for",
"(",
"Iterator",
"<",
"Map",
".",
"Entry",
"<",
"CacheKey",
",",
"CacheValue",
">",
">",
"citer",
"=",
"cache",
".",
"entrySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"citer",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"Map",
".",
"Entry",
"<",
"CacheKey",
",",
"CacheValue",
">",
"ce",
"=",
"citer",
".",
"next",
"(",
")",
";",
"CacheKey",
"key",
"=",
"ce",
".",
"getKey",
"(",
")",
";",
"CacheValue",
"v",
"=",
"ce",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"v",
"!=",
"null",
")",
"{",
"if",
"(",
"key",
".",
"isDescendantOf",
"(",
"path",
")",
")",
"{",
"// will remove by id too",
"toRemove",
".",
"add",
"(",
"new",
"CacheId",
"(",
"v",
".",
"getItem",
"(",
")",
".",
"getIdentifier",
"(",
")",
")",
")",
";",
"citer",
".",
"remove",
"(",
")",
";",
"// remove",
"nodesCache",
".",
"remove",
"(",
"v",
".",
"getItem",
"(",
")",
".",
"getIdentifier",
"(",
")",
")",
";",
"propertiesCache",
".",
"remove",
"(",
"v",
".",
"getItem",
"(",
")",
".",
"getIdentifier",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"citer",
".",
"remove",
"(",
")",
";",
"// remove empty C record",
"}",
"}",
"for",
"(",
"CacheId",
"id",
":",
"toRemove",
")",
"{",
"cache",
".",
"remove",
"(",
"id",
")",
";",
"}",
"toRemove",
".",
"clear",
"(",
")",
";",
"}",
"finally",
"{",
"writeLock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] | Remove sibling's subtrees from cache C, CN, CP.<br> For update (order-before) usecase.<br>
The work does remove of all descendants of the item parent. I.e. the node and its siblings (for
SNS case).<br> | [
"Remove",
"sibling",
"s",
"subtrees",
"from",
"cache",
"C",
"CN",
"CP",
".",
"<br",
">",
"For",
"update",
"(",
"order",
"-",
"before",
")",
"usecase",
".",
"<br",
">",
"The",
"work",
"does",
"remove",
"of",
"all",
"descendants",
"of",
"the",
"item",
"parent",
".",
"I",
".",
"e",
".",
"the",
"node",
"and",
"its",
"siblings",
"(",
"for",
"SNS",
"case",
")",
".",
"<br",
">"
] | train | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java#L1810-L1865 |
UrielCh/ovh-java-sdk | ovh-java-sdk-paastimeseries/src/main/java/net/minidev/ovh/api/ApiOvhPaastimeseries.java | ApiOvhPaastimeseries.serviceName_PUT | public void serviceName_PUT(String serviceName, net.minidev.ovh.api.timeseries.OvhProject body) throws IOException {
"""
Alter this object properties
REST: PUT /paas/timeseries/{serviceName}
@param body [required] New object properties
@param serviceName [required] The internal name of your timeseries project
@deprecated
"""
String qPath = "/paas/timeseries/{serviceName}";
StringBuilder sb = path(qPath, serviceName);
exec(qPath, "PUT", sb.toString(), body);
} | java | public void serviceName_PUT(String serviceName, net.minidev.ovh.api.timeseries.OvhProject body) throws IOException {
String qPath = "/paas/timeseries/{serviceName}";
StringBuilder sb = path(qPath, serviceName);
exec(qPath, "PUT", sb.toString(), body);
} | [
"public",
"void",
"serviceName_PUT",
"(",
"String",
"serviceName",
",",
"net",
".",
"minidev",
".",
"ovh",
".",
"api",
".",
"timeseries",
".",
"OvhProject",
"body",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/paas/timeseries/{serviceName}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
")",
";",
"exec",
"(",
"qPath",
",",
"\"PUT\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"body",
")",
";",
"}"
] | Alter this object properties
REST: PUT /paas/timeseries/{serviceName}
@param body [required] New object properties
@param serviceName [required] The internal name of your timeseries project
@deprecated | [
"Alter",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-paastimeseries/src/main/java/net/minidev/ovh/api/ApiOvhPaastimeseries.java#L228-L232 |
maven-nar/nar-maven-plugin | src/main/java/com/github/maven_nar/cpptasks/msvc/VisualStudioNETProjectWriter.java | VisualStudioNETProjectWriter.addAttribute | private static void addAttribute(final AttributesImpl attributes, final String attrName, final String attrValue) {
"""
Adds an non-namespace-qualified attribute to attribute list.
@param attributes
list of attributes.
@param attrName
attribute name, may not be null.
@param attrValue
attribute value, if null attribute is not added.
"""
if (attrName == null) {
throw new IllegalArgumentException("attrName");
}
if (attrValue != null) {
attributes.addAttribute(null, attrName, attrName, "#PCDATA", attrValue);
}
} | java | private static void addAttribute(final AttributesImpl attributes, final String attrName, final String attrValue) {
if (attrName == null) {
throw new IllegalArgumentException("attrName");
}
if (attrValue != null) {
attributes.addAttribute(null, attrName, attrName, "#PCDATA", attrValue);
}
} | [
"private",
"static",
"void",
"addAttribute",
"(",
"final",
"AttributesImpl",
"attributes",
",",
"final",
"String",
"attrName",
",",
"final",
"String",
"attrValue",
")",
"{",
"if",
"(",
"attrName",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"attrName\"",
")",
";",
"}",
"if",
"(",
"attrValue",
"!=",
"null",
")",
"{",
"attributes",
".",
"addAttribute",
"(",
"null",
",",
"attrName",
",",
"attrName",
",",
"\"#PCDATA\"",
",",
"attrValue",
")",
";",
"}",
"}"
] | Adds an non-namespace-qualified attribute to attribute list.
@param attributes
list of attributes.
@param attrName
attribute name, may not be null.
@param attrValue
attribute value, if null attribute is not added. | [
"Adds",
"an",
"non",
"-",
"namespace",
"-",
"qualified",
"attribute",
"to",
"attribute",
"list",
"."
] | train | https://github.com/maven-nar/nar-maven-plugin/blob/3c622e2024296b4203431bbae3bde290a01dac00/src/main/java/com/github/maven_nar/cpptasks/msvc/VisualStudioNETProjectWriter.java#L65-L72 |
Impetus/Kundera | src/kundera-cassandra/cassandra-ds-driver/src/main/java/com/impetus/kundera/client/cassandra/dsdriver/DSClientUtilities.java | DSClientUtilities.setTextValue | private static Object setTextValue(Object entity, Field member, Object retVal) {
"""
Sets the text value.
@param entity
the entity
@param member
the member
@param retVal
the ret val
@return the object
"""
if (member != null && member.getType().isEnum())
{
EnumAccessor accessor = new EnumAccessor();
if (member != null)
{
retVal = accessor.fromString(member.getType(), (String) retVal);
}
}
else if (member != null
&& (member.getType().isAssignableFrom(char.class) || member.getType().isAssignableFrom(Character.class)))
{
retVal = new CharAccessor().fromString(member.getType(), (String) retVal);
}
return retVal;
} | java | private static Object setTextValue(Object entity, Field member, Object retVal)
{
if (member != null && member.getType().isEnum())
{
EnumAccessor accessor = new EnumAccessor();
if (member != null)
{
retVal = accessor.fromString(member.getType(), (String) retVal);
}
}
else if (member != null
&& (member.getType().isAssignableFrom(char.class) || member.getType().isAssignableFrom(Character.class)))
{
retVal = new CharAccessor().fromString(member.getType(), (String) retVal);
}
return retVal;
} | [
"private",
"static",
"Object",
"setTextValue",
"(",
"Object",
"entity",
",",
"Field",
"member",
",",
"Object",
"retVal",
")",
"{",
"if",
"(",
"member",
"!=",
"null",
"&&",
"member",
".",
"getType",
"(",
")",
".",
"isEnum",
"(",
")",
")",
"{",
"EnumAccessor",
"accessor",
"=",
"new",
"EnumAccessor",
"(",
")",
";",
"if",
"(",
"member",
"!=",
"null",
")",
"{",
"retVal",
"=",
"accessor",
".",
"fromString",
"(",
"member",
".",
"getType",
"(",
")",
",",
"(",
"String",
")",
"retVal",
")",
";",
"}",
"}",
"else",
"if",
"(",
"member",
"!=",
"null",
"&&",
"(",
"member",
".",
"getType",
"(",
")",
".",
"isAssignableFrom",
"(",
"char",
".",
"class",
")",
"||",
"member",
".",
"getType",
"(",
")",
".",
"isAssignableFrom",
"(",
"Character",
".",
"class",
")",
")",
")",
"{",
"retVal",
"=",
"new",
"CharAccessor",
"(",
")",
".",
"fromString",
"(",
"member",
".",
"getType",
"(",
")",
",",
"(",
"String",
")",
"retVal",
")",
";",
"}",
"return",
"retVal",
";",
"}"
] | Sets the text value.
@param entity
the entity
@param member
the member
@param retVal
the ret val
@return the object | [
"Sets",
"the",
"text",
"value",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-cassandra/cassandra-ds-driver/src/main/java/com/impetus/kundera/client/cassandra/dsdriver/DSClientUtilities.java#L762-L778 |
akarnokd/akarnokd-xml | src/main/java/hu/akarnokd/xml/XNElement.java | XNElement.childValue | public String childValue(String name, String namespace) {
"""
Returns the content of the first child which has the given name.
@param name the child name
@param namespace the namespace URI
@return the content or null if no such child
"""
for (XNElement e : children) {
if (Objects.equals(e.name, name) && Objects.equals(e.namespace, namespace)) {
return e.content;
}
}
return null;
} | java | public String childValue(String name, String namespace) {
for (XNElement e : children) {
if (Objects.equals(e.name, name) && Objects.equals(e.namespace, namespace)) {
return e.content;
}
}
return null;
} | [
"public",
"String",
"childValue",
"(",
"String",
"name",
",",
"String",
"namespace",
")",
"{",
"for",
"(",
"XNElement",
"e",
":",
"children",
")",
"{",
"if",
"(",
"Objects",
".",
"equals",
"(",
"e",
".",
"name",
",",
"name",
")",
"&&",
"Objects",
".",
"equals",
"(",
"e",
".",
"namespace",
",",
"namespace",
")",
")",
"{",
"return",
"e",
".",
"content",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Returns the content of the first child which has the given name.
@param name the child name
@param namespace the namespace URI
@return the content or null if no such child | [
"Returns",
"the",
"content",
"of",
"the",
"first",
"child",
"which",
"has",
"the",
"given",
"name",
"."
] | train | https://github.com/akarnokd/akarnokd-xml/blob/57466a5a9cb455a13d7121557c165287b31ee870/src/main/java/hu/akarnokd/xml/XNElement.java#L495-L502 |
iig-uni-freiburg/SEWOL | ext/org/deckfour/xes/nikefs2/NikeFS2SwapFileManager.java | NikeFS2SwapFileManager.createSwapFile | public static synchronized File createSwapFile(String prefix, String suffix) throws IOException {
"""
Creates a new, empty swap file, ready for use. It is guaranteed
that this swap file will be removed from the system either on
JVM shutdown (Unix platforms) or on subsequent use of this class
(Win32 platforms).
@param prefix Prefix to be used for this swap file.
@param suffix Suffix to be used for this swap file.
@return A new swap file.
@throws IOException
"""
File swapDir = getSwapDir();
File tmpFile = File.createTempFile(prefix, suffix, swapDir);
return tmpFile;
} | java | public static synchronized File createSwapFile(String prefix, String suffix) throws IOException {
File swapDir = getSwapDir();
File tmpFile = File.createTempFile(prefix, suffix, swapDir);
return tmpFile;
} | [
"public",
"static",
"synchronized",
"File",
"createSwapFile",
"(",
"String",
"prefix",
",",
"String",
"suffix",
")",
"throws",
"IOException",
"{",
"File",
"swapDir",
"=",
"getSwapDir",
"(",
")",
";",
"File",
"tmpFile",
"=",
"File",
".",
"createTempFile",
"(",
"prefix",
",",
"suffix",
",",
"swapDir",
")",
";",
"return",
"tmpFile",
";",
"}"
] | Creates a new, empty swap file, ready for use. It is guaranteed
that this swap file will be removed from the system either on
JVM shutdown (Unix platforms) or on subsequent use of this class
(Win32 platforms).
@param prefix Prefix to be used for this swap file.
@param suffix Suffix to be used for this swap file.
@return A new swap file.
@throws IOException | [
"Creates",
"a",
"new",
"empty",
"swap",
"file",
"ready",
"for",
"use",
".",
"It",
"is",
"guaranteed",
"that",
"this",
"swap",
"file",
"will",
"be",
"removed",
"from",
"the",
"system",
"either",
"on",
"JVM",
"shutdown",
"(",
"Unix",
"platforms",
")",
"or",
"on",
"subsequent",
"use",
"of",
"this",
"class",
"(",
"Win32",
"platforms",
")",
"."
] | train | https://github.com/iig-uni-freiburg/SEWOL/blob/e791cb07a6e62ecf837d760d58a25f32fbf6bbca/ext/org/deckfour/xes/nikefs2/NikeFS2SwapFileManager.java#L117-L121 |
igniterealtime/Smack | smack-core/src/main/java/org/jivesoftware/smack/sasl/SASLMechanism.java | SASLMechanism.authenticate | public void authenticate(String host, DomainBareJid serviceName, CallbackHandler cbh, EntityBareJid authzid, SSLSession sslSession)
throws SmackSaslException, NotConnectedException, InterruptedException {
"""
Builds and sends the <tt>auth</tt> stanza to the server. The callback handler will handle
any additional information, such as the authentication ID or realm, if it is needed.
@param host the hostname where the user account resides.
@param serviceName the xmpp service location
@param cbh the CallbackHandler to obtain user information.
@param authzid the optional authorization identity.
@param sslSession the optional SSL/TLS session (if one was established)
@throws SmackSaslException if a SASL related error occurs.
@throws NotConnectedException
@throws InterruptedException
"""
this.host = host;
this.serviceName = serviceName;
this.authorizationId = authzid;
this.sslSession = sslSession;
assert (authorizationId == null || authzidSupported());
authenticateInternal(cbh);
authenticate();
} | java | public void authenticate(String host, DomainBareJid serviceName, CallbackHandler cbh, EntityBareJid authzid, SSLSession sslSession)
throws SmackSaslException, NotConnectedException, InterruptedException {
this.host = host;
this.serviceName = serviceName;
this.authorizationId = authzid;
this.sslSession = sslSession;
assert (authorizationId == null || authzidSupported());
authenticateInternal(cbh);
authenticate();
} | [
"public",
"void",
"authenticate",
"(",
"String",
"host",
",",
"DomainBareJid",
"serviceName",
",",
"CallbackHandler",
"cbh",
",",
"EntityBareJid",
"authzid",
",",
"SSLSession",
"sslSession",
")",
"throws",
"SmackSaslException",
",",
"NotConnectedException",
",",
"InterruptedException",
"{",
"this",
".",
"host",
"=",
"host",
";",
"this",
".",
"serviceName",
"=",
"serviceName",
";",
"this",
".",
"authorizationId",
"=",
"authzid",
";",
"this",
".",
"sslSession",
"=",
"sslSession",
";",
"assert",
"(",
"authorizationId",
"==",
"null",
"||",
"authzidSupported",
"(",
")",
")",
";",
"authenticateInternal",
"(",
"cbh",
")",
";",
"authenticate",
"(",
")",
";",
"}"
] | Builds and sends the <tt>auth</tt> stanza to the server. The callback handler will handle
any additional information, such as the authentication ID or realm, if it is needed.
@param host the hostname where the user account resides.
@param serviceName the xmpp service location
@param cbh the CallbackHandler to obtain user information.
@param authzid the optional authorization identity.
@param sslSession the optional SSL/TLS session (if one was established)
@throws SmackSaslException if a SASL related error occurs.
@throws NotConnectedException
@throws InterruptedException | [
"Builds",
"and",
"sends",
"the",
"<tt",
">",
"auth<",
"/",
"tt",
">",
"stanza",
"to",
"the",
"server",
".",
"The",
"callback",
"handler",
"will",
"handle",
"any",
"additional",
"information",
"such",
"as",
"the",
"authentication",
"ID",
"or",
"realm",
"if",
"it",
"is",
"needed",
"."
] | train | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/sasl/SASLMechanism.java#L176-L185 |
JavaMoney/jsr354-ri-bp | src/main/java/org/javamoney/moneta/spi/base/BaseExchangeRateProvider.java | BaseExchangeRateProvider.isAvailable | public boolean isAvailable(CurrencyUnit base, CurrencyUnit term) {
"""
Checks if an {@link javax.money.convert.ExchangeRate} between two {@link javax.money.CurrencyUnit} is
available from this provider. This method should check, if a given rate
is <i>currently</i> defined.
@param base the base {@link javax.money.CurrencyUnit}
@param term the term {@link javax.money.CurrencyUnit}
@return {@code true}, if such an {@link javax.money.convert.ExchangeRate} is currently
defined.
"""
return isAvailable(ConversionQueryBuilder.of().setBaseCurrency(base).setTermCurrency(term).build());
} | java | public boolean isAvailable(CurrencyUnit base, CurrencyUnit term){
return isAvailable(ConversionQueryBuilder.of().setBaseCurrency(base).setTermCurrency(term).build());
} | [
"public",
"boolean",
"isAvailable",
"(",
"CurrencyUnit",
"base",
",",
"CurrencyUnit",
"term",
")",
"{",
"return",
"isAvailable",
"(",
"ConversionQueryBuilder",
".",
"of",
"(",
")",
".",
"setBaseCurrency",
"(",
"base",
")",
".",
"setTermCurrency",
"(",
"term",
")",
".",
"build",
"(",
")",
")",
";",
"}"
] | Checks if an {@link javax.money.convert.ExchangeRate} between two {@link javax.money.CurrencyUnit} is
available from this provider. This method should check, if a given rate
is <i>currently</i> defined.
@param base the base {@link javax.money.CurrencyUnit}
@param term the term {@link javax.money.CurrencyUnit}
@return {@code true}, if such an {@link javax.money.convert.ExchangeRate} is currently
defined. | [
"Checks",
"if",
"an",
"{",
"@link",
"javax",
".",
"money",
".",
"convert",
".",
"ExchangeRate",
"}",
"between",
"two",
"{",
"@link",
"javax",
".",
"money",
".",
"CurrencyUnit",
"}",
"is",
"available",
"from",
"this",
"provider",
".",
"This",
"method",
"should",
"check",
"if",
"a",
"given",
"rate",
"is",
"<i",
">",
"currently<",
"/",
"i",
">",
"defined",
"."
] | train | https://github.com/JavaMoney/jsr354-ri-bp/blob/9c147ef5623d8032a6dc4c0e5eefdfb41641a9a2/src/main/java/org/javamoney/moneta/spi/base/BaseExchangeRateProvider.java#L106-L108 |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/jdbc/JDBCResultSet.java | JDBCResultSet.getObject | public Object getObject(int columnIndex) throws SQLException {
"""
<!-- start generic documentation -->
<p>Gets the value of the designated column in the current row
of this <code>ResultSet</code> object as
an <code>Object</code> in the Java programming language.
<p>This method will return the value of the given column as a
Java object. The type of the Java object will be the default
Java object type corresponding to the column's SQL type,
following the mapping for built-in types specified in the JDBC
specification. If the value is an SQL <code>NULL</code>,
the driver returns a Java <code>null</code>.
<p>This method may also be used to read database-specific
abstract data types.
In the JDBC 2.0 API, the behavior of method
<code>getObject</code> is extended to materialize
data of SQL user-defined types.
<p>
If <code>Connection.getTypeMap</code> does not throw a
<code>SQLFeatureNotSupportedException</code>,
then when a column contains a structured or distinct value,
the behavior of this method is as
if it were a call to: <code>getObject(columnIndex,
this.getStatement().getConnection().getTypeMap())</code>.
If <code>Connection.getTypeMap</code> does throw a
<code>SQLFeatureNotSupportedException</code>,
then structured values are not supported, and distinct values
are mapped to the default Java class as determined by the
underlying SQL type of the DISTINCT type.
<!-- end generic documentation -->
@param columnIndex the first column is 1, the second is 2, ...
@return a <code>java.lang.Object</code> holding the column value
@exception SQLException if a database access error occurs or this method is
called on a closed result set
"""
checkColumn(columnIndex);
Type sourceType = resultMetaData.columnTypes[columnIndex - 1];
switch (sourceType.typeCode) {
case Types.SQL_DATE :
return getDate(columnIndex);
case Types.SQL_TIME :
case Types.SQL_TIME_WITH_TIME_ZONE :
return getTime(columnIndex);
case Types.SQL_TIMESTAMP :
case Types.SQL_TIMESTAMP_WITH_TIME_ZONE :
return getTimestamp(columnIndex);
case Types.SQL_BINARY :
case Types.SQL_VARBINARY :
return getBytes(columnIndex);
case Types.OTHER :
case Types.JAVA_OBJECT : {
Object o = getColumnInType(columnIndex, sourceType);
if (o == null) {
return null;
}
try {
return ((JavaObjectData) o).getObject();
} catch (HsqlException e) {
throw Util.sqlException(e);
}
}
default :
return getColumnInType(columnIndex, sourceType);
}
} | java | public Object getObject(int columnIndex) throws SQLException {
checkColumn(columnIndex);
Type sourceType = resultMetaData.columnTypes[columnIndex - 1];
switch (sourceType.typeCode) {
case Types.SQL_DATE :
return getDate(columnIndex);
case Types.SQL_TIME :
case Types.SQL_TIME_WITH_TIME_ZONE :
return getTime(columnIndex);
case Types.SQL_TIMESTAMP :
case Types.SQL_TIMESTAMP_WITH_TIME_ZONE :
return getTimestamp(columnIndex);
case Types.SQL_BINARY :
case Types.SQL_VARBINARY :
return getBytes(columnIndex);
case Types.OTHER :
case Types.JAVA_OBJECT : {
Object o = getColumnInType(columnIndex, sourceType);
if (o == null) {
return null;
}
try {
return ((JavaObjectData) o).getObject();
} catch (HsqlException e) {
throw Util.sqlException(e);
}
}
default :
return getColumnInType(columnIndex, sourceType);
}
} | [
"public",
"Object",
"getObject",
"(",
"int",
"columnIndex",
")",
"throws",
"SQLException",
"{",
"checkColumn",
"(",
"columnIndex",
")",
";",
"Type",
"sourceType",
"=",
"resultMetaData",
".",
"columnTypes",
"[",
"columnIndex",
"-",
"1",
"]",
";",
"switch",
"(",
"sourceType",
".",
"typeCode",
")",
"{",
"case",
"Types",
".",
"SQL_DATE",
":",
"return",
"getDate",
"(",
"columnIndex",
")",
";",
"case",
"Types",
".",
"SQL_TIME",
":",
"case",
"Types",
".",
"SQL_TIME_WITH_TIME_ZONE",
":",
"return",
"getTime",
"(",
"columnIndex",
")",
";",
"case",
"Types",
".",
"SQL_TIMESTAMP",
":",
"case",
"Types",
".",
"SQL_TIMESTAMP_WITH_TIME_ZONE",
":",
"return",
"getTimestamp",
"(",
"columnIndex",
")",
";",
"case",
"Types",
".",
"SQL_BINARY",
":",
"case",
"Types",
".",
"SQL_VARBINARY",
":",
"return",
"getBytes",
"(",
"columnIndex",
")",
";",
"case",
"Types",
".",
"OTHER",
":",
"case",
"Types",
".",
"JAVA_OBJECT",
":",
"{",
"Object",
"o",
"=",
"getColumnInType",
"(",
"columnIndex",
",",
"sourceType",
")",
";",
"if",
"(",
"o",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"try",
"{",
"return",
"(",
"(",
"JavaObjectData",
")",
"o",
")",
".",
"getObject",
"(",
")",
";",
"}",
"catch",
"(",
"HsqlException",
"e",
")",
"{",
"throw",
"Util",
".",
"sqlException",
"(",
"e",
")",
";",
"}",
"}",
"default",
":",
"return",
"getColumnInType",
"(",
"columnIndex",
",",
"sourceType",
")",
";",
"}",
"}"
] | <!-- start generic documentation -->
<p>Gets the value of the designated column in the current row
of this <code>ResultSet</code> object as
an <code>Object</code> in the Java programming language.
<p>This method will return the value of the given column as a
Java object. The type of the Java object will be the default
Java object type corresponding to the column's SQL type,
following the mapping for built-in types specified in the JDBC
specification. If the value is an SQL <code>NULL</code>,
the driver returns a Java <code>null</code>.
<p>This method may also be used to read database-specific
abstract data types.
In the JDBC 2.0 API, the behavior of method
<code>getObject</code> is extended to materialize
data of SQL user-defined types.
<p>
If <code>Connection.getTypeMap</code> does not throw a
<code>SQLFeatureNotSupportedException</code>,
then when a column contains a structured or distinct value,
the behavior of this method is as
if it were a call to: <code>getObject(columnIndex,
this.getStatement().getConnection().getTypeMap())</code>.
If <code>Connection.getTypeMap</code> does throw a
<code>SQLFeatureNotSupportedException</code>,
then structured values are not supported, and distinct values
are mapped to the default Java class as determined by the
underlying SQL type of the DISTINCT type.
<!-- end generic documentation -->
@param columnIndex the first column is 1, the second is 2, ...
@return a <code>java.lang.Object</code> holding the column value
@exception SQLException if a database access error occurs or this method is
called on a closed result set | [
"<!",
"--",
"start",
"generic",
"documentation",
"--",
">",
"<p",
">",
"Gets",
"the",
"value",
"of",
"the",
"designated",
"column",
"in",
"the",
"current",
"row",
"of",
"this",
"<code",
">",
"ResultSet<",
"/",
"code",
">",
"object",
"as",
"an",
"<code",
">",
"Object<",
"/",
"code",
">",
"in",
"the",
"Java",
"programming",
"language",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/jdbc/JDBCResultSet.java#L1504-L1540 |
looly/hulu | src/main/java/com/xiaoleilu/hulu/ActionContext.java | ActionContext.handle | protected static boolean handle(ServletRequest req, ServletResponse res) {
"""
注入ServletRequest 和 ServletResponse并处理请求
@param req ServletRequest
@param res ServletResponse
@return 是否处理成功
"""
return handler.handle((HttpServletRequest)req, (HttpServletResponse)res);
} | java | protected static boolean handle(ServletRequest req, ServletResponse res) {
return handler.handle((HttpServletRequest)req, (HttpServletResponse)res);
} | [
"protected",
"static",
"boolean",
"handle",
"(",
"ServletRequest",
"req",
",",
"ServletResponse",
"res",
")",
"{",
"return",
"handler",
".",
"handle",
"(",
"(",
"HttpServletRequest",
")",
"req",
",",
"(",
"HttpServletResponse",
")",
"res",
")",
";",
"}"
] | 注入ServletRequest 和 ServletResponse并处理请求
@param req ServletRequest
@param res ServletResponse
@return 是否处理成功 | [
"注入ServletRequest",
"和",
"ServletResponse并处理请求"
] | train | https://github.com/looly/hulu/blob/4072de684e2e2f28ac8a3a44c0d5a690b289ef28/src/main/java/com/xiaoleilu/hulu/ActionContext.java#L91-L93 |
alkacon/opencms-core | src/org/opencms/xml/page/CmsXmlPage.java | CmsXmlPage.setEnabled | public void setEnabled(String name, Locale locale, boolean isEnabled) {
"""
Sets the enabled flag of an already existing element.<p>
Note: if isEnabled is set to true, the attribute is removed
since true is the default
@param name name name of the element
@param locale locale of the element
@param isEnabled enabled flag for the element
"""
CmsXmlHtmlValue value = (CmsXmlHtmlValue)getValue(name, locale);
Element element = value.getElement();
Attribute enabled = element.attribute(ATTRIBUTE_ENABLED);
if (enabled == null) {
if (!isEnabled) {
element.addAttribute(ATTRIBUTE_ENABLED, Boolean.toString(isEnabled));
}
} else if (isEnabled) {
element.remove(enabled);
} else {
enabled.setValue(Boolean.toString(isEnabled));
}
} | java | public void setEnabled(String name, Locale locale, boolean isEnabled) {
CmsXmlHtmlValue value = (CmsXmlHtmlValue)getValue(name, locale);
Element element = value.getElement();
Attribute enabled = element.attribute(ATTRIBUTE_ENABLED);
if (enabled == null) {
if (!isEnabled) {
element.addAttribute(ATTRIBUTE_ENABLED, Boolean.toString(isEnabled));
}
} else if (isEnabled) {
element.remove(enabled);
} else {
enabled.setValue(Boolean.toString(isEnabled));
}
} | [
"public",
"void",
"setEnabled",
"(",
"String",
"name",
",",
"Locale",
"locale",
",",
"boolean",
"isEnabled",
")",
"{",
"CmsXmlHtmlValue",
"value",
"=",
"(",
"CmsXmlHtmlValue",
")",
"getValue",
"(",
"name",
",",
"locale",
")",
";",
"Element",
"element",
"=",
"value",
".",
"getElement",
"(",
")",
";",
"Attribute",
"enabled",
"=",
"element",
".",
"attribute",
"(",
"ATTRIBUTE_ENABLED",
")",
";",
"if",
"(",
"enabled",
"==",
"null",
")",
"{",
"if",
"(",
"!",
"isEnabled",
")",
"{",
"element",
".",
"addAttribute",
"(",
"ATTRIBUTE_ENABLED",
",",
"Boolean",
".",
"toString",
"(",
"isEnabled",
")",
")",
";",
"}",
"}",
"else",
"if",
"(",
"isEnabled",
")",
"{",
"element",
".",
"remove",
"(",
"enabled",
")",
";",
"}",
"else",
"{",
"enabled",
".",
"setValue",
"(",
"Boolean",
".",
"toString",
"(",
"isEnabled",
")",
")",
";",
"}",
"}"
] | Sets the enabled flag of an already existing element.<p>
Note: if isEnabled is set to true, the attribute is removed
since true is the default
@param name name name of the element
@param locale locale of the element
@param isEnabled enabled flag for the element | [
"Sets",
"the",
"enabled",
"flag",
"of",
"an",
"already",
"existing",
"element",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/xml/page/CmsXmlPage.java#L408-L423 |
davidmoten/rxjava-extras | src/main/java/com/github/davidmoten/rx/Transformers.java | Transformers.bufferWhile | public static final <T> Transformer<T, List<T>> bufferWhile(
Func1<? super T, Boolean> predicate) {
"""
Buffers the elements into continuous, non-overlapping Lists where the
boundary is determined by a predicate receiving each item, before or
after being buffered, and returns true to indicate a new buffer should
start.
<p>
The operator won't return an empty first or last buffer.
<dl>
<dt><b>Backpressure Support:</b></dt>
<dd>This operator supports backpressure.</dd>
<dt><b>Scheduler:</b></dt>
<dd>This operator does not operate by default on a particular
{@link Scheduler}.</dd>
</dl>
@param <T>
the input value type
@param predicate
the Func1 that receives each item, before being buffered, and
should return true to indicate a new buffer has to start.
@return the new Observable instance
@see #bufferWhile(Func1)
@since (if this graduates from Experimental/Beta to supported, replace
this parenthetical with the release number)
"""
return bufferWhile(predicate, 10);
} | java | public static final <T> Transformer<T, List<T>> bufferWhile(
Func1<? super T, Boolean> predicate) {
return bufferWhile(predicate, 10);
} | [
"public",
"static",
"final",
"<",
"T",
">",
"Transformer",
"<",
"T",
",",
"List",
"<",
"T",
">",
">",
"bufferWhile",
"(",
"Func1",
"<",
"?",
"super",
"T",
",",
"Boolean",
">",
"predicate",
")",
"{",
"return",
"bufferWhile",
"(",
"predicate",
",",
"10",
")",
";",
"}"
] | Buffers the elements into continuous, non-overlapping Lists where the
boundary is determined by a predicate receiving each item, before or
after being buffered, and returns true to indicate a new buffer should
start.
<p>
The operator won't return an empty first or last buffer.
<dl>
<dt><b>Backpressure Support:</b></dt>
<dd>This operator supports backpressure.</dd>
<dt><b>Scheduler:</b></dt>
<dd>This operator does not operate by default on a particular
{@link Scheduler}.</dd>
</dl>
@param <T>
the input value type
@param predicate
the Func1 that receives each item, before being buffered, and
should return true to indicate a new buffer has to start.
@return the new Observable instance
@see #bufferWhile(Func1)
@since (if this graduates from Experimental/Beta to supported, replace
this parenthetical with the release number) | [
"Buffers",
"the",
"elements",
"into",
"continuous",
"non",
"-",
"overlapping",
"Lists",
"where",
"the",
"boundary",
"is",
"determined",
"by",
"a",
"predicate",
"receiving",
"each",
"item",
"before",
"or",
"after",
"being",
"buffered",
"and",
"returns",
"true",
"to",
"indicate",
"a",
"new",
"buffer",
"should",
"start",
"."
] | train | https://github.com/davidmoten/rxjava-extras/blob/a91d2ba7d454843250e0b0fce36084f9fb02a551/src/main/java/com/github/davidmoten/rx/Transformers.java#L1180-L1183 |
jbundle/osgi | core/src/main/java/org/jbundle/util/osgi/bundle/BaseBundleActivator.java | BaseBundleActivator.getService | public Object getService(String interfaceClassName, String serviceClassName, String versionRange, Dictionary<String,String> filter) {
"""
Convenience method to get the service for this implementation class.
@param interfaceClassName
@return
"""
return ClassServiceUtility.getClassService().getClassFinder(context).getClassBundleService(interfaceClassName, serviceClassName, versionRange, filter, -1);
} | java | public Object getService(String interfaceClassName, String serviceClassName, String versionRange, Dictionary<String,String> filter)
{
return ClassServiceUtility.getClassService().getClassFinder(context).getClassBundleService(interfaceClassName, serviceClassName, versionRange, filter, -1);
} | [
"public",
"Object",
"getService",
"(",
"String",
"interfaceClassName",
",",
"String",
"serviceClassName",
",",
"String",
"versionRange",
",",
"Dictionary",
"<",
"String",
",",
"String",
">",
"filter",
")",
"{",
"return",
"ClassServiceUtility",
".",
"getClassService",
"(",
")",
".",
"getClassFinder",
"(",
"context",
")",
".",
"getClassBundleService",
"(",
"interfaceClassName",
",",
"serviceClassName",
",",
"versionRange",
",",
"filter",
",",
"-",
"1",
")",
";",
"}"
] | Convenience method to get the service for this implementation class.
@param interfaceClassName
@return | [
"Convenience",
"method",
"to",
"get",
"the",
"service",
"for",
"this",
"implementation",
"class",
"."
] | train | https://github.com/jbundle/osgi/blob/beb02aef78736a4f799aaac001c8f0327bf0536c/core/src/main/java/org/jbundle/util/osgi/bundle/BaseBundleActivator.java#L284-L287 |
b3dgs/lionengine | lionengine-core/src/main/java/com/b3dgs/lionengine/graphic/filter/FilterBlur.java | FilterBlur.createKernel | private static Kernel createKernel(float radius, int width, int height) {
"""
Create a blur kernel.
@param radius The blur radius.
@param width The image width.
@param height The image height.
@return The blur kernel.
"""
final int r = (int) Math.ceil(radius);
final int rows = r * 2 + 1;
final float[] matrix = new float[rows];
final float sigma = radius / 3;
final float sigma22 = 2 * sigma * sigma;
final float sigmaPi2 = (float) (2 * Math.PI * sigma);
final float sqrtSigmaPi2 = (float) Math.sqrt(sigmaPi2);
final float radius2 = radius * radius;
float total = 0.0F;
int index = 0;
for (int row = -r; row <= r; row++)
{
final float distance = row * (float) row;
if (distance > radius2)
{
matrix[index] = 0;
}
else
{
matrix[index] = (float) Math.exp(-distance / sigma22) / sqrtSigmaPi2;
}
total += matrix[index];
index++;
}
for (int i = 0; i < rows; i++)
{
matrix[i] /= total;
}
final float[] data = new float[width * height];
System.arraycopy(matrix, 0, data, 0, rows);
return new Kernel(rows, data);
} | java | private static Kernel createKernel(float radius, int width, int height)
{
final int r = (int) Math.ceil(radius);
final int rows = r * 2 + 1;
final float[] matrix = new float[rows];
final float sigma = radius / 3;
final float sigma22 = 2 * sigma * sigma;
final float sigmaPi2 = (float) (2 * Math.PI * sigma);
final float sqrtSigmaPi2 = (float) Math.sqrt(sigmaPi2);
final float radius2 = radius * radius;
float total = 0.0F;
int index = 0;
for (int row = -r; row <= r; row++)
{
final float distance = row * (float) row;
if (distance > radius2)
{
matrix[index] = 0;
}
else
{
matrix[index] = (float) Math.exp(-distance / sigma22) / sqrtSigmaPi2;
}
total += matrix[index];
index++;
}
for (int i = 0; i < rows; i++)
{
matrix[i] /= total;
}
final float[] data = new float[width * height];
System.arraycopy(matrix, 0, data, 0, rows);
return new Kernel(rows, data);
} | [
"private",
"static",
"Kernel",
"createKernel",
"(",
"float",
"radius",
",",
"int",
"width",
",",
"int",
"height",
")",
"{",
"final",
"int",
"r",
"=",
"(",
"int",
")",
"Math",
".",
"ceil",
"(",
"radius",
")",
";",
"final",
"int",
"rows",
"=",
"r",
"*",
"2",
"+",
"1",
";",
"final",
"float",
"[",
"]",
"matrix",
"=",
"new",
"float",
"[",
"rows",
"]",
";",
"final",
"float",
"sigma",
"=",
"radius",
"/",
"3",
";",
"final",
"float",
"sigma22",
"=",
"2",
"*",
"sigma",
"*",
"sigma",
";",
"final",
"float",
"sigmaPi2",
"=",
"(",
"float",
")",
"(",
"2",
"*",
"Math",
".",
"PI",
"*",
"sigma",
")",
";",
"final",
"float",
"sqrtSigmaPi2",
"=",
"(",
"float",
")",
"Math",
".",
"sqrt",
"(",
"sigmaPi2",
")",
";",
"final",
"float",
"radius2",
"=",
"radius",
"*",
"radius",
";",
"float",
"total",
"=",
"0.0F",
";",
"int",
"index",
"=",
"0",
";",
"for",
"(",
"int",
"row",
"=",
"-",
"r",
";",
"row",
"<=",
"r",
";",
"row",
"++",
")",
"{",
"final",
"float",
"distance",
"=",
"row",
"*",
"(",
"float",
")",
"row",
";",
"if",
"(",
"distance",
">",
"radius2",
")",
"{",
"matrix",
"[",
"index",
"]",
"=",
"0",
";",
"}",
"else",
"{",
"matrix",
"[",
"index",
"]",
"=",
"(",
"float",
")",
"Math",
".",
"exp",
"(",
"-",
"distance",
"/",
"sigma22",
")",
"/",
"sqrtSigmaPi2",
";",
"}",
"total",
"+=",
"matrix",
"[",
"index",
"]",
";",
"index",
"++",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"rows",
";",
"i",
"++",
")",
"{",
"matrix",
"[",
"i",
"]",
"/=",
"total",
";",
"}",
"final",
"float",
"[",
"]",
"data",
"=",
"new",
"float",
"[",
"width",
"*",
"height",
"]",
";",
"System",
".",
"arraycopy",
"(",
"matrix",
",",
"0",
",",
"data",
",",
"0",
",",
"rows",
")",
";",
"return",
"new",
"Kernel",
"(",
"rows",
",",
"data",
")",
";",
"}"
] | Create a blur kernel.
@param radius The blur radius.
@param width The image width.
@param height The image height.
@return The blur kernel. | [
"Create",
"a",
"blur",
"kernel",
"."
] | train | https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-core/src/main/java/com/b3dgs/lionengine/graphic/filter/FilterBlur.java#L174-L210 |
m-m-m/util | pojo/src/main/java/net/sf/mmm/util/pojo/api/TypedProperty.java | TypedProperty.appendPath | public static void appendPath(StringBuilder buffer, String... segments) {
"""
This method {@link StringBuilder#append(String) appends} the {@link #getPojoPath() pojo property path}
specified by the given {@code segments} to the given {@code buffer}.
@param buffer is the {@link StringBuilder} to append to.
@param segments are the path segments for the property.
"""
for (int i = 0; i < segments.length; i++) {
String s = segments[i];
if (i > 0) {
buffer.append(SEPARATOR);
}
buffer.append(s);
}
} | java | public static void appendPath(StringBuilder buffer, String... segments) {
for (int i = 0; i < segments.length; i++) {
String s = segments[i];
if (i > 0) {
buffer.append(SEPARATOR);
}
buffer.append(s);
}
} | [
"public",
"static",
"void",
"appendPath",
"(",
"StringBuilder",
"buffer",
",",
"String",
"...",
"segments",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"segments",
".",
"length",
";",
"i",
"++",
")",
"{",
"String",
"s",
"=",
"segments",
"[",
"i",
"]",
";",
"if",
"(",
"i",
">",
"0",
")",
"{",
"buffer",
".",
"append",
"(",
"SEPARATOR",
")",
";",
"}",
"buffer",
".",
"append",
"(",
"s",
")",
";",
"}",
"}"
] | This method {@link StringBuilder#append(String) appends} the {@link #getPojoPath() pojo property path}
specified by the given {@code segments} to the given {@code buffer}.
@param buffer is the {@link StringBuilder} to append to.
@param segments are the path segments for the property. | [
"This",
"method",
"{",
"@link",
"StringBuilder#append",
"(",
"String",
")",
"appends",
"}",
"the",
"{",
"@link",
"#getPojoPath",
"()",
"pojo",
"property",
"path",
"}",
"specified",
"by",
"the",
"given",
"{",
"@code",
"segments",
"}",
"to",
"the",
"given",
"{",
"@code",
"buffer",
"}",
"."
] | train | https://github.com/m-m-m/util/blob/f0e4e084448f8dfc83ca682a9e1618034a094ce6/pojo/src/main/java/net/sf/mmm/util/pojo/api/TypedProperty.java#L256-L265 |
opencb/biodata | biodata-tools/src/main/java/org/opencb/biodata/tools/variant/converters/proto/VariantContextToVariantProtoConverter.java | VariantContextToVariantProtoConverter.setConsequenceTypeParams | private List<ConsequenceType> setConsequenceTypeParams() {
"""
method to set Consequence Type Parameters
@return consequenceTypeList
"""
List<ConsequenceType> consequenceTypeList = new ArrayList<>();
ConsequenceType.Builder consequenceType = ConsequenceType.newBuilder();
consequenceType.setGeneName(null);
consequenceType.setEnsemblGeneId(null);
consequenceType.setEnsemblTranscriptId(null);
consequenceType.setStrand(null);
consequenceType.setBiotype(null);
consequenceType.setCDnaPosition(0);
consequenceType.setCdsPosition(0);
consequenceType.setCodon(null);
/*
* set ExpressionValues list type parameter
*/
// List<ExpressionValue> expressionValueList = new ArrayList<>();
// ExpressionValue expressionValue = new ExpressionValue();
// expressionValue.setExpression(getEnumFromString(org.opencb.biodata.models.variant.avro.ExpressionCall.class, "UP"));
/*expressionValue.setExperimentalFactor(null);
expressionValue.setExperimentId(null);
expressionValue.setExpression(null);
expressionValue.setFactorValue(null);
expressionValue.setPvalue(null);
expressionValue.setTechnologyPlatform(null);*/
// expressionValueList.add(expressionValue);
// consequenceType.setExpression(expressionValueList);
/*
* set ProteinSubstitutionScores list type parameter
*/
// List<Score> proteinSubstitutionScoreList = new ArrayList<>();
// Score score = new Score(null, null, null);
// proteinSubstitutionScoreList.add(score);
ProteinVariantAnnotation.Builder proteinVariantAnnotation = ProteinVariantAnnotation.newBuilder();
proteinVariantAnnotation.addAllSubstitutionScores(Arrays.asList());
consequenceType.setProteinVariantAnnotation(proteinVariantAnnotation);
/*
* set SoTerms list type parameter
*/
List<VariantAnnotationProto.SequenceOntologyTerm> sequenceOntologyTerms = new ArrayList<>();
VariantAnnotationProto.SequenceOntologyTerm.Builder sequenceOntologyTerm = VariantAnnotationProto.SequenceOntologyTerm.newBuilder();
sequenceOntologyTerm.setAccession(null);
sequenceOntologyTerm.setName(null);
sequenceOntologyTerms.add(sequenceOntologyTerm.build());
consequenceType.addAllSequenceOntologyTerms(sequenceOntologyTerms);
consequenceType.setStrand(null);
/*
* Add consequenceType final bean to list
*/
consequenceTypeList.add(consequenceType.build());
return consequenceTypeList;
} | java | private List<ConsequenceType> setConsequenceTypeParams(){
List<ConsequenceType> consequenceTypeList = new ArrayList<>();
ConsequenceType.Builder consequenceType = ConsequenceType.newBuilder();
consequenceType.setGeneName(null);
consequenceType.setEnsemblGeneId(null);
consequenceType.setEnsemblTranscriptId(null);
consequenceType.setStrand(null);
consequenceType.setBiotype(null);
consequenceType.setCDnaPosition(0);
consequenceType.setCdsPosition(0);
consequenceType.setCodon(null);
/*
* set ExpressionValues list type parameter
*/
// List<ExpressionValue> expressionValueList = new ArrayList<>();
// ExpressionValue expressionValue = new ExpressionValue();
// expressionValue.setExpression(getEnumFromString(org.opencb.biodata.models.variant.avro.ExpressionCall.class, "UP"));
/*expressionValue.setExperimentalFactor(null);
expressionValue.setExperimentId(null);
expressionValue.setExpression(null);
expressionValue.setFactorValue(null);
expressionValue.setPvalue(null);
expressionValue.setTechnologyPlatform(null);*/
// expressionValueList.add(expressionValue);
// consequenceType.setExpression(expressionValueList);
/*
* set ProteinSubstitutionScores list type parameter
*/
// List<Score> proteinSubstitutionScoreList = new ArrayList<>();
// Score score = new Score(null, null, null);
// proteinSubstitutionScoreList.add(score);
ProteinVariantAnnotation.Builder proteinVariantAnnotation = ProteinVariantAnnotation.newBuilder();
proteinVariantAnnotation.addAllSubstitutionScores(Arrays.asList());
consequenceType.setProteinVariantAnnotation(proteinVariantAnnotation);
/*
* set SoTerms list type parameter
*/
List<VariantAnnotationProto.SequenceOntologyTerm> sequenceOntologyTerms = new ArrayList<>();
VariantAnnotationProto.SequenceOntologyTerm.Builder sequenceOntologyTerm = VariantAnnotationProto.SequenceOntologyTerm.newBuilder();
sequenceOntologyTerm.setAccession(null);
sequenceOntologyTerm.setName(null);
sequenceOntologyTerms.add(sequenceOntologyTerm.build());
consequenceType.addAllSequenceOntologyTerms(sequenceOntologyTerms);
consequenceType.setStrand(null);
/*
* Add consequenceType final bean to list
*/
consequenceTypeList.add(consequenceType.build());
return consequenceTypeList;
} | [
"private",
"List",
"<",
"ConsequenceType",
">",
"setConsequenceTypeParams",
"(",
")",
"{",
"List",
"<",
"ConsequenceType",
">",
"consequenceTypeList",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"ConsequenceType",
".",
"Builder",
"consequenceType",
"=",
"ConsequenceType",
".",
"newBuilder",
"(",
")",
";",
"consequenceType",
".",
"setGeneName",
"(",
"null",
")",
";",
"consequenceType",
".",
"setEnsemblGeneId",
"(",
"null",
")",
";",
"consequenceType",
".",
"setEnsemblTranscriptId",
"(",
"null",
")",
";",
"consequenceType",
".",
"setStrand",
"(",
"null",
")",
";",
"consequenceType",
".",
"setBiotype",
"(",
"null",
")",
";",
"consequenceType",
".",
"setCDnaPosition",
"(",
"0",
")",
";",
"consequenceType",
".",
"setCdsPosition",
"(",
"0",
")",
";",
"consequenceType",
".",
"setCodon",
"(",
"null",
")",
";",
"/*\n * set ExpressionValues list type parameter\n */",
"// List<ExpressionValue> expressionValueList = new ArrayList<>();",
"// ExpressionValue expressionValue = new ExpressionValue();",
"// expressionValue.setExpression(getEnumFromString(org.opencb.biodata.models.variant.avro.ExpressionCall.class, \"UP\"));",
"/*expressionValue.setExperimentalFactor(null);\n expressionValue.setExperimentId(null);\n expressionValue.setExpression(null);\n expressionValue.setFactorValue(null);\n expressionValue.setPvalue(null);\n expressionValue.setTechnologyPlatform(null);*/",
"// expressionValueList.add(expressionValue);",
"// consequenceType.setExpression(expressionValueList);",
"/*\n * set ProteinSubstitutionScores list type parameter\n */",
"// List<Score> proteinSubstitutionScoreList = new ArrayList<>();",
"// Score score = new Score(null, null, null);",
"// proteinSubstitutionScoreList.add(score);",
"ProteinVariantAnnotation",
".",
"Builder",
"proteinVariantAnnotation",
"=",
"ProteinVariantAnnotation",
".",
"newBuilder",
"(",
")",
";",
"proteinVariantAnnotation",
".",
"addAllSubstitutionScores",
"(",
"Arrays",
".",
"asList",
"(",
")",
")",
";",
"consequenceType",
".",
"setProteinVariantAnnotation",
"(",
"proteinVariantAnnotation",
")",
";",
"/*\n * set SoTerms list type parameter\n */",
"List",
"<",
"VariantAnnotationProto",
".",
"SequenceOntologyTerm",
">",
"sequenceOntologyTerms",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"VariantAnnotationProto",
".",
"SequenceOntologyTerm",
".",
"Builder",
"sequenceOntologyTerm",
"=",
"VariantAnnotationProto",
".",
"SequenceOntologyTerm",
".",
"newBuilder",
"(",
")",
";",
"sequenceOntologyTerm",
".",
"setAccession",
"(",
"null",
")",
";",
"sequenceOntologyTerm",
".",
"setName",
"(",
"null",
")",
";",
"sequenceOntologyTerms",
".",
"add",
"(",
"sequenceOntologyTerm",
".",
"build",
"(",
")",
")",
";",
"consequenceType",
".",
"addAllSequenceOntologyTerms",
"(",
"sequenceOntologyTerms",
")",
";",
"consequenceType",
".",
"setStrand",
"(",
"null",
")",
";",
"/*\n * Add consequenceType final bean to list\n */",
"consequenceTypeList",
".",
"add",
"(",
"consequenceType",
".",
"build",
"(",
")",
")",
";",
"return",
"consequenceTypeList",
";",
"}"
] | method to set Consequence Type Parameters
@return consequenceTypeList | [
"method",
"to",
"set",
"Consequence",
"Type",
"Parameters"
] | train | https://github.com/opencb/biodata/blob/21b3d51d71f578efab908422aca4bab7a73097b1/biodata-tools/src/main/java/org/opencb/biodata/tools/variant/converters/proto/VariantContextToVariantProtoConverter.java#L224-L280 |
iipc/openwayback | wayback-core/src/main/java/org/archive/wayback/resourceindex/updater/LocalResourceIndexUpdater.java | LocalResourceIndexUpdater.init | public void init() throws ConfigurationException {
"""
start the background index merging thread
@throws ConfigurationException
"""
if(index == null) {
throw new ConfigurationException("No index target");
}
if(!index.isUpdatable()) {
throw new ConfigurationException("ResourceIndex is not updatable");
}
if(incoming == null) {
throw new ConfigurationException("No incoming");
}
if(runInterval > 0) {
thread = new UpdateThread(this,runInterval);
thread.start();
}
} | java | public void init() throws ConfigurationException {
if(index == null) {
throw new ConfigurationException("No index target");
}
if(!index.isUpdatable()) {
throw new ConfigurationException("ResourceIndex is not updatable");
}
if(incoming == null) {
throw new ConfigurationException("No incoming");
}
if(runInterval > 0) {
thread = new UpdateThread(this,runInterval);
thread.start();
}
} | [
"public",
"void",
"init",
"(",
")",
"throws",
"ConfigurationException",
"{",
"if",
"(",
"index",
"==",
"null",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"\"No index target\"",
")",
";",
"}",
"if",
"(",
"!",
"index",
".",
"isUpdatable",
"(",
")",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"\"ResourceIndex is not updatable\"",
")",
";",
"}",
"if",
"(",
"incoming",
"==",
"null",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"\"No incoming\"",
")",
";",
"}",
"if",
"(",
"runInterval",
">",
"0",
")",
"{",
"thread",
"=",
"new",
"UpdateThread",
"(",
"this",
",",
"runInterval",
")",
";",
"thread",
".",
"start",
"(",
")",
";",
"}",
"}"
] | start the background index merging thread
@throws ConfigurationException | [
"start",
"the",
"background",
"index",
"merging",
"thread"
] | train | https://github.com/iipc/openwayback/blob/da74c3a59a5b5a5c365bd4702dcb45d263535794/wayback-core/src/main/java/org/archive/wayback/resourceindex/updater/LocalResourceIndexUpdater.java#L76-L90 |
lievendoclo/Valkyrie-RCP | valkyrie-rcp-core/src/main/java/org/valkyriercp/util/EventListenerListHelper.java | EventListenerListHelper.fire | public void fire(String methodName, Object arg1, Object arg2) {
"""
Invokes the method with the given name and two parameters on each of the listeners
registered with this list.
@param methodName the name of the method to invoke.
@param arg1 the first argument to pass to each invocation.
@param arg2 the second argument to pass to each invocation.
@throws IllegalArgumentException if no method with the given name and 2 formal parameters
exists on the listener class managed by this list helper.
"""
if (listeners != EMPTY_OBJECT_ARRAY) {
fireEventByReflection(methodName, new Object[] { arg1, arg2 });
}
} | java | public void fire(String methodName, Object arg1, Object arg2) {
if (listeners != EMPTY_OBJECT_ARRAY) {
fireEventByReflection(methodName, new Object[] { arg1, arg2 });
}
} | [
"public",
"void",
"fire",
"(",
"String",
"methodName",
",",
"Object",
"arg1",
",",
"Object",
"arg2",
")",
"{",
"if",
"(",
"listeners",
"!=",
"EMPTY_OBJECT_ARRAY",
")",
"{",
"fireEventByReflection",
"(",
"methodName",
",",
"new",
"Object",
"[",
"]",
"{",
"arg1",
",",
"arg2",
"}",
")",
";",
"}",
"}"
] | Invokes the method with the given name and two parameters on each of the listeners
registered with this list.
@param methodName the name of the method to invoke.
@param arg1 the first argument to pass to each invocation.
@param arg2 the second argument to pass to each invocation.
@throws IllegalArgumentException if no method with the given name and 2 formal parameters
exists on the listener class managed by this list helper. | [
"Invokes",
"the",
"method",
"with",
"the",
"given",
"name",
"and",
"two",
"parameters",
"on",
"each",
"of",
"the",
"listeners",
"registered",
"with",
"this",
"list",
"."
] | train | https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/util/EventListenerListHelper.java#L250-L254 |
ZieIony/Carbon | carbon/src/main/java/carbon/drawable/ripple/LollipopDrawablesCompat.java | LollipopDrawablesCompat.createFromXml | public static Drawable createFromXml(Resources r, XmlPullParser parser) throws XmlPullParserException, IOException {
"""
Create a drawable from an XML document. For more information on how to create resources in
XML, see
<a href="{@docRoot}guide/topics/resources/drawable-resource.html">Drawable Resources</a>.
"""
return createFromXml(r, parser, null);
} | java | public static Drawable createFromXml(Resources r, XmlPullParser parser) throws XmlPullParserException, IOException {
return createFromXml(r, parser, null);
} | [
"public",
"static",
"Drawable",
"createFromXml",
"(",
"Resources",
"r",
",",
"XmlPullParser",
"parser",
")",
"throws",
"XmlPullParserException",
",",
"IOException",
"{",
"return",
"createFromXml",
"(",
"r",
",",
"parser",
",",
"null",
")",
";",
"}"
] | Create a drawable from an XML document. For more information on how to create resources in
XML, see
<a href="{@docRoot}guide/topics/resources/drawable-resource.html">Drawable Resources</a>. | [
"Create",
"a",
"drawable",
"from",
"an",
"XML",
"document",
".",
"For",
"more",
"information",
"on",
"how",
"to",
"create",
"resources",
"in",
"XML",
"see",
"<a",
"href",
"=",
"{"
] | train | https://github.com/ZieIony/Carbon/blob/78b0a432bd49edc7a6a13ce111cab274085d1693/carbon/src/main/java/carbon/drawable/ripple/LollipopDrawablesCompat.java#L99-L101 |
alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/daemon/supervisor/SyncProcessEvent.java | SyncProcessEvent.matchesAssignment | public boolean matchesAssignment(WorkerHeartbeat whb, Map<Integer, LocalAssignment> assignedTasks) {
"""
check whether the worker heartbeat is allowed in the assignedTasks
@param whb WorkerHeartbeat
@param assignedTasks assigned tasks
@return if true, the assignments(LS-LOCAL-ASSIGNMENTS) match with worker heartbeat, false otherwise
"""
boolean isMatch = true;
LocalAssignment localAssignment = assignedTasks.get(whb.getPort());
if (localAssignment == null) {
LOG.debug("Following worker has been removed, port=" + whb.getPort() + ", assignedTasks=" + assignedTasks);
isMatch = false;
} else if (!whb.getTopologyId().equals(localAssignment.getTopologyId())) {
// topology id not equal
LOG.info("topology id not equal whb=" + whb.getTopologyId() + ",localAssignment=" + localAssignment.getTopologyId());
isMatch = false;
}/*
* else if (!(whb.getTaskIds().equals(localAssignment.getTaskIds()))) { // task-id isn't equal LOG.info("task-id isn't equal whb=" + whb.getTaskIds() +
* ",localAssignment=" + localAssignment.getTaskIds()); isMatch = false; }
*/
return isMatch;
} | java | public boolean matchesAssignment(WorkerHeartbeat whb, Map<Integer, LocalAssignment> assignedTasks) {
boolean isMatch = true;
LocalAssignment localAssignment = assignedTasks.get(whb.getPort());
if (localAssignment == null) {
LOG.debug("Following worker has been removed, port=" + whb.getPort() + ", assignedTasks=" + assignedTasks);
isMatch = false;
} else if (!whb.getTopologyId().equals(localAssignment.getTopologyId())) {
// topology id not equal
LOG.info("topology id not equal whb=" + whb.getTopologyId() + ",localAssignment=" + localAssignment.getTopologyId());
isMatch = false;
}/*
* else if (!(whb.getTaskIds().equals(localAssignment.getTaskIds()))) { // task-id isn't equal LOG.info("task-id isn't equal whb=" + whb.getTaskIds() +
* ",localAssignment=" + localAssignment.getTaskIds()); isMatch = false; }
*/
return isMatch;
} | [
"public",
"boolean",
"matchesAssignment",
"(",
"WorkerHeartbeat",
"whb",
",",
"Map",
"<",
"Integer",
",",
"LocalAssignment",
">",
"assignedTasks",
")",
"{",
"boolean",
"isMatch",
"=",
"true",
";",
"LocalAssignment",
"localAssignment",
"=",
"assignedTasks",
".",
"get",
"(",
"whb",
".",
"getPort",
"(",
")",
")",
";",
"if",
"(",
"localAssignment",
"==",
"null",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Following worker has been removed, port=\"",
"+",
"whb",
".",
"getPort",
"(",
")",
"+",
"\", assignedTasks=\"",
"+",
"assignedTasks",
")",
";",
"isMatch",
"=",
"false",
";",
"}",
"else",
"if",
"(",
"!",
"whb",
".",
"getTopologyId",
"(",
")",
".",
"equals",
"(",
"localAssignment",
".",
"getTopologyId",
"(",
")",
")",
")",
"{",
"// topology id not equal",
"LOG",
".",
"info",
"(",
"\"topology id not equal whb=\"",
"+",
"whb",
".",
"getTopologyId",
"(",
")",
"+",
"\",localAssignment=\"",
"+",
"localAssignment",
".",
"getTopologyId",
"(",
")",
")",
";",
"isMatch",
"=",
"false",
";",
"}",
"/*\n * else if (!(whb.getTaskIds().equals(localAssignment.getTaskIds()))) { // task-id isn't equal LOG.info(\"task-id isn't equal whb=\" + whb.getTaskIds() +\n * \",localAssignment=\" + localAssignment.getTaskIds()); isMatch = false; }\n */",
"return",
"isMatch",
";",
"}"
] | check whether the worker heartbeat is allowed in the assignedTasks
@param whb WorkerHeartbeat
@param assignedTasks assigned tasks
@return if true, the assignments(LS-LOCAL-ASSIGNMENTS) match with worker heartbeat, false otherwise | [
"check",
"whether",
"the",
"worker",
"heartbeat",
"is",
"allowed",
"in",
"the",
"assignedTasks"
] | train | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/daemon/supervisor/SyncProcessEvent.java#L437-L453 |
spotbugs/spotbugs | spotbugs/src/main/java/edu/umd/cs/findbugs/classfile/impl/ClassPathBuilder.java | ClassPathBuilder.parseClassName | private void parseClassName(ICodeBaseEntry entry) {
"""
Attempt to parse data of given resource in order to divine the real name
of the class contained in the resource.
@param entry
the resource
"""
DataInputStream in = null;
try {
InputStream resourceIn = entry.openResource();
if (resourceIn == null) {
throw new NullPointerException("Got null resource");
}
in = new DataInputStream(resourceIn);
ClassParserInterface parser = new ClassParser(in, null, entry);
ClassNameAndSuperclassInfo.Builder builder = new ClassNameAndSuperclassInfo.Builder();
parser.parse(builder);
String trueResourceName = builder.build().getClassDescriptor().toResourceName();
if (!trueResourceName.equals(entry.getResourceName())) {
entry.overrideResourceName(trueResourceName);
}
} catch (IOException e) {
errorLogger.logError("Invalid class resource " + entry.getResourceName() + " in " + entry, e);
} catch (InvalidClassFileFormatException e) {
errorLogger.logError("Invalid class resource " + entry.getResourceName() + " in " + entry, e);
} finally {
IO.close(in);
}
} | java | private void parseClassName(ICodeBaseEntry entry) {
DataInputStream in = null;
try {
InputStream resourceIn = entry.openResource();
if (resourceIn == null) {
throw new NullPointerException("Got null resource");
}
in = new DataInputStream(resourceIn);
ClassParserInterface parser = new ClassParser(in, null, entry);
ClassNameAndSuperclassInfo.Builder builder = new ClassNameAndSuperclassInfo.Builder();
parser.parse(builder);
String trueResourceName = builder.build().getClassDescriptor().toResourceName();
if (!trueResourceName.equals(entry.getResourceName())) {
entry.overrideResourceName(trueResourceName);
}
} catch (IOException e) {
errorLogger.logError("Invalid class resource " + entry.getResourceName() + " in " + entry, e);
} catch (InvalidClassFileFormatException e) {
errorLogger.logError("Invalid class resource " + entry.getResourceName() + " in " + entry, e);
} finally {
IO.close(in);
}
} | [
"private",
"void",
"parseClassName",
"(",
"ICodeBaseEntry",
"entry",
")",
"{",
"DataInputStream",
"in",
"=",
"null",
";",
"try",
"{",
"InputStream",
"resourceIn",
"=",
"entry",
".",
"openResource",
"(",
")",
";",
"if",
"(",
"resourceIn",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"Got null resource\"",
")",
";",
"}",
"in",
"=",
"new",
"DataInputStream",
"(",
"resourceIn",
")",
";",
"ClassParserInterface",
"parser",
"=",
"new",
"ClassParser",
"(",
"in",
",",
"null",
",",
"entry",
")",
";",
"ClassNameAndSuperclassInfo",
".",
"Builder",
"builder",
"=",
"new",
"ClassNameAndSuperclassInfo",
".",
"Builder",
"(",
")",
";",
"parser",
".",
"parse",
"(",
"builder",
")",
";",
"String",
"trueResourceName",
"=",
"builder",
".",
"build",
"(",
")",
".",
"getClassDescriptor",
"(",
")",
".",
"toResourceName",
"(",
")",
";",
"if",
"(",
"!",
"trueResourceName",
".",
"equals",
"(",
"entry",
".",
"getResourceName",
"(",
")",
")",
")",
"{",
"entry",
".",
"overrideResourceName",
"(",
"trueResourceName",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"errorLogger",
".",
"logError",
"(",
"\"Invalid class resource \"",
"+",
"entry",
".",
"getResourceName",
"(",
")",
"+",
"\" in \"",
"+",
"entry",
",",
"e",
")",
";",
"}",
"catch",
"(",
"InvalidClassFileFormatException",
"e",
")",
"{",
"errorLogger",
".",
"logError",
"(",
"\"Invalid class resource \"",
"+",
"entry",
".",
"getResourceName",
"(",
")",
"+",
"\" in \"",
"+",
"entry",
",",
"e",
")",
";",
"}",
"finally",
"{",
"IO",
".",
"close",
"(",
"in",
")",
";",
"}",
"}"
] | Attempt to parse data of given resource in order to divine the real name
of the class contained in the resource.
@param entry
the resource | [
"Attempt",
"to",
"parse",
"data",
"of",
"given",
"resource",
"in",
"order",
"to",
"divine",
"the",
"real",
"name",
"of",
"the",
"class",
"contained",
"in",
"the",
"resource",
"."
] | train | https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/classfile/impl/ClassPathBuilder.java#L723-L746 |
google/closure-compiler | src/com/google/javascript/jscomp/NodeUtil.java | NodeUtil.replaceDeclarationChild | public static void replaceDeclarationChild(Node declChild, Node newStatement) {
"""
Replace the child of a var/let/const declaration (usually a name) with a new statement.
Preserves the order of side effects for all the other declaration children.
@param declChild The name node to be replaced.
@param newStatement The statement to replace with.
"""
checkArgument(isNameDeclaration(declChild.getParent()));
checkArgument(null == newStatement.getParent());
Node decl = declChild.getParent();
Node declParent = decl.getParent();
if (decl.hasOneChild()) {
declParent.replaceChild(decl, newStatement);
} else if (declChild.getNext() == null) {
decl.removeChild(declChild);
declParent.addChildAfter(newStatement, decl);
} else if (declChild.getPrevious() == null) {
decl.removeChild(declChild);
declParent.addChildBefore(newStatement, decl);
} else {
checkState(decl.hasMoreThanOneChild());
Node newDecl = new Node(decl.getToken()).srcref(decl);
for (Node after = declChild.getNext(), next; after != null; after = next) {
next = after.getNext();
newDecl.addChildToBack(after.detach());
}
decl.removeChild(declChild);
declParent.addChildAfter(newStatement, decl);
declParent.addChildAfter(newDecl, newStatement);
}
} | java | public static void replaceDeclarationChild(Node declChild, Node newStatement) {
checkArgument(isNameDeclaration(declChild.getParent()));
checkArgument(null == newStatement.getParent());
Node decl = declChild.getParent();
Node declParent = decl.getParent();
if (decl.hasOneChild()) {
declParent.replaceChild(decl, newStatement);
} else if (declChild.getNext() == null) {
decl.removeChild(declChild);
declParent.addChildAfter(newStatement, decl);
} else if (declChild.getPrevious() == null) {
decl.removeChild(declChild);
declParent.addChildBefore(newStatement, decl);
} else {
checkState(decl.hasMoreThanOneChild());
Node newDecl = new Node(decl.getToken()).srcref(decl);
for (Node after = declChild.getNext(), next; after != null; after = next) {
next = after.getNext();
newDecl.addChildToBack(after.detach());
}
decl.removeChild(declChild);
declParent.addChildAfter(newStatement, decl);
declParent.addChildAfter(newDecl, newStatement);
}
} | [
"public",
"static",
"void",
"replaceDeclarationChild",
"(",
"Node",
"declChild",
",",
"Node",
"newStatement",
")",
"{",
"checkArgument",
"(",
"isNameDeclaration",
"(",
"declChild",
".",
"getParent",
"(",
")",
")",
")",
";",
"checkArgument",
"(",
"null",
"==",
"newStatement",
".",
"getParent",
"(",
")",
")",
";",
"Node",
"decl",
"=",
"declChild",
".",
"getParent",
"(",
")",
";",
"Node",
"declParent",
"=",
"decl",
".",
"getParent",
"(",
")",
";",
"if",
"(",
"decl",
".",
"hasOneChild",
"(",
")",
")",
"{",
"declParent",
".",
"replaceChild",
"(",
"decl",
",",
"newStatement",
")",
";",
"}",
"else",
"if",
"(",
"declChild",
".",
"getNext",
"(",
")",
"==",
"null",
")",
"{",
"decl",
".",
"removeChild",
"(",
"declChild",
")",
";",
"declParent",
".",
"addChildAfter",
"(",
"newStatement",
",",
"decl",
")",
";",
"}",
"else",
"if",
"(",
"declChild",
".",
"getPrevious",
"(",
")",
"==",
"null",
")",
"{",
"decl",
".",
"removeChild",
"(",
"declChild",
")",
";",
"declParent",
".",
"addChildBefore",
"(",
"newStatement",
",",
"decl",
")",
";",
"}",
"else",
"{",
"checkState",
"(",
"decl",
".",
"hasMoreThanOneChild",
"(",
")",
")",
";",
"Node",
"newDecl",
"=",
"new",
"Node",
"(",
"decl",
".",
"getToken",
"(",
")",
")",
".",
"srcref",
"(",
"decl",
")",
";",
"for",
"(",
"Node",
"after",
"=",
"declChild",
".",
"getNext",
"(",
")",
",",
"next",
";",
"after",
"!=",
"null",
";",
"after",
"=",
"next",
")",
"{",
"next",
"=",
"after",
".",
"getNext",
"(",
")",
";",
"newDecl",
".",
"addChildToBack",
"(",
"after",
".",
"detach",
"(",
")",
")",
";",
"}",
"decl",
".",
"removeChild",
"(",
"declChild",
")",
";",
"declParent",
".",
"addChildAfter",
"(",
"newStatement",
",",
"decl",
")",
";",
"declParent",
".",
"addChildAfter",
"(",
"newDecl",
",",
"newStatement",
")",
";",
"}",
"}"
] | Replace the child of a var/let/const declaration (usually a name) with a new statement.
Preserves the order of side effects for all the other declaration children.
@param declChild The name node to be replaced.
@param newStatement The statement to replace with. | [
"Replace",
"the",
"child",
"of",
"a",
"var",
"/",
"let",
"/",
"const",
"declaration",
"(",
"usually",
"a",
"name",
")",
"with",
"a",
"new",
"statement",
".",
"Preserves",
"the",
"order",
"of",
"side",
"effects",
"for",
"all",
"the",
"other",
"declaration",
"children",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L2879-L2904 |
groovy/groovy-core | src/main/org/codehaus/groovy/syntax/Types.java | Types.canMean | public static boolean canMean( int actual, int preferred ) {
"""
Given two types, returns true if the first can be viewed as the second.
NOTE that <code>canMean()</code> is orthogonal to <code>ofType()</code>.
"""
if( actual == preferred ) {
return true;
}
switch( preferred ) {
case SYNTH_PARAMETER_DECLARATION:
case IDENTIFIER:
switch( actual ) {
case IDENTIFIER:
case KEYWORD_DEF:
case KEYWORD_DEFMACRO:
case KEYWORD_CLASS:
case KEYWORD_INTERFACE:
case KEYWORD_MIXIN:
return true;
}
break;
case SYNTH_CLASS:
case SYNTH_INTERFACE:
case SYNTH_MIXIN:
case SYNTH_METHOD:
case SYNTH_PROPERTY:
return actual == IDENTIFIER;
case SYNTH_LIST:
case SYNTH_MAP:
return actual == LEFT_SQUARE_BRACKET;
case SYNTH_CAST:
return actual == LEFT_PARENTHESIS;
case SYNTH_BLOCK:
case SYNTH_CLOSURE:
return actual == LEFT_CURLY_BRACE;
case SYNTH_LABEL:
return actual == COLON;
case SYNTH_VARIABLE_DECLARATION:
return actual == IDENTIFIER;
}
return false;
} | java | public static boolean canMean( int actual, int preferred ) {
if( actual == preferred ) {
return true;
}
switch( preferred ) {
case SYNTH_PARAMETER_DECLARATION:
case IDENTIFIER:
switch( actual ) {
case IDENTIFIER:
case KEYWORD_DEF:
case KEYWORD_DEFMACRO:
case KEYWORD_CLASS:
case KEYWORD_INTERFACE:
case KEYWORD_MIXIN:
return true;
}
break;
case SYNTH_CLASS:
case SYNTH_INTERFACE:
case SYNTH_MIXIN:
case SYNTH_METHOD:
case SYNTH_PROPERTY:
return actual == IDENTIFIER;
case SYNTH_LIST:
case SYNTH_MAP:
return actual == LEFT_SQUARE_BRACKET;
case SYNTH_CAST:
return actual == LEFT_PARENTHESIS;
case SYNTH_BLOCK:
case SYNTH_CLOSURE:
return actual == LEFT_CURLY_BRACE;
case SYNTH_LABEL:
return actual == COLON;
case SYNTH_VARIABLE_DECLARATION:
return actual == IDENTIFIER;
}
return false;
} | [
"public",
"static",
"boolean",
"canMean",
"(",
"int",
"actual",
",",
"int",
"preferred",
")",
"{",
"if",
"(",
"actual",
"==",
"preferred",
")",
"{",
"return",
"true",
";",
"}",
"switch",
"(",
"preferred",
")",
"{",
"case",
"SYNTH_PARAMETER_DECLARATION",
":",
"case",
"IDENTIFIER",
":",
"switch",
"(",
"actual",
")",
"{",
"case",
"IDENTIFIER",
":",
"case",
"KEYWORD_DEF",
":",
"case",
"KEYWORD_DEFMACRO",
":",
"case",
"KEYWORD_CLASS",
":",
"case",
"KEYWORD_INTERFACE",
":",
"case",
"KEYWORD_MIXIN",
":",
"return",
"true",
";",
"}",
"break",
";",
"case",
"SYNTH_CLASS",
":",
"case",
"SYNTH_INTERFACE",
":",
"case",
"SYNTH_MIXIN",
":",
"case",
"SYNTH_METHOD",
":",
"case",
"SYNTH_PROPERTY",
":",
"return",
"actual",
"==",
"IDENTIFIER",
";",
"case",
"SYNTH_LIST",
":",
"case",
"SYNTH_MAP",
":",
"return",
"actual",
"==",
"LEFT_SQUARE_BRACKET",
";",
"case",
"SYNTH_CAST",
":",
"return",
"actual",
"==",
"LEFT_PARENTHESIS",
";",
"case",
"SYNTH_BLOCK",
":",
"case",
"SYNTH_CLOSURE",
":",
"return",
"actual",
"==",
"LEFT_CURLY_BRACE",
";",
"case",
"SYNTH_LABEL",
":",
"return",
"actual",
"==",
"COLON",
";",
"case",
"SYNTH_VARIABLE_DECLARATION",
":",
"return",
"actual",
"==",
"IDENTIFIER",
";",
"}",
"return",
"false",
";",
"}"
] | Given two types, returns true if the first can be viewed as the second.
NOTE that <code>canMean()</code> is orthogonal to <code>ofType()</code>. | [
"Given",
"two",
"types",
"returns",
"true",
"if",
"the",
"first",
"can",
"be",
"viewed",
"as",
"the",
"second",
".",
"NOTE",
"that",
"<code",
">",
"canMean",
"()",
"<",
"/",
"code",
">",
"is",
"orthogonal",
"to",
"<code",
">",
"ofType",
"()",
"<",
"/",
"code",
">",
"."
] | train | https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/syntax/Types.java#L854-L901 |
OpenLiberty/open-liberty | dev/com.ibm.ws.injection/src/com/ibm/ws/injectionengine/osgi/internal/naming/InjectionJavaColonHelper.java | InjectionJavaColonHelper.getInjectionScopeData | protected OSGiInjectionScopeData getInjectionScopeData(NamingConstants.JavaColonNamespace namespace) throws NamingException {
"""
Internal method to obtain the injection metadata associated with
the specified component metadata. <p>
@return the associated injection metadata; or null if none exists
"""
final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
OSGiInjectionScopeData isd = null;
// Get the ComponentMetaData for the currently active component.
// There is no comp namespace if there is no active component.
ComponentMetaData cmd = ComponentMetaDataAccessorImpl.getComponentMetaDataAccessor().getComponentMetaData();
if (cmd == null) {
NamingException nex = new NamingException(Tr.formatMessage(tc, "JNDI_NON_JEE_THREAD_CWNEN1000E"));
if (isTraceOn && tc.isDebugEnabled())
Tr.debug(tc, "getInjectionScopeData : (no CMD) : " + nex.toString(true));
throw nex;
}
isd = injectionEngine.getInjectionScopeData(cmd, namespace);
if (isTraceOn && tc.isDebugEnabled())
Tr.debug(tc, cmd + " -> " + isd);
return isd;
} | java | protected OSGiInjectionScopeData getInjectionScopeData(NamingConstants.JavaColonNamespace namespace) throws NamingException {
final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
OSGiInjectionScopeData isd = null;
// Get the ComponentMetaData for the currently active component.
// There is no comp namespace if there is no active component.
ComponentMetaData cmd = ComponentMetaDataAccessorImpl.getComponentMetaDataAccessor().getComponentMetaData();
if (cmd == null) {
NamingException nex = new NamingException(Tr.formatMessage(tc, "JNDI_NON_JEE_THREAD_CWNEN1000E"));
if (isTraceOn && tc.isDebugEnabled())
Tr.debug(tc, "getInjectionScopeData : (no CMD) : " + nex.toString(true));
throw nex;
}
isd = injectionEngine.getInjectionScopeData(cmd, namespace);
if (isTraceOn && tc.isDebugEnabled())
Tr.debug(tc, cmd + " -> " + isd);
return isd;
} | [
"protected",
"OSGiInjectionScopeData",
"getInjectionScopeData",
"(",
"NamingConstants",
".",
"JavaColonNamespace",
"namespace",
")",
"throws",
"NamingException",
"{",
"final",
"boolean",
"isTraceOn",
"=",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
";",
"OSGiInjectionScopeData",
"isd",
"=",
"null",
";",
"// Get the ComponentMetaData for the currently active component.",
"// There is no comp namespace if there is no active component.",
"ComponentMetaData",
"cmd",
"=",
"ComponentMetaDataAccessorImpl",
".",
"getComponentMetaDataAccessor",
"(",
")",
".",
"getComponentMetaData",
"(",
")",
";",
"if",
"(",
"cmd",
"==",
"null",
")",
"{",
"NamingException",
"nex",
"=",
"new",
"NamingException",
"(",
"Tr",
".",
"formatMessage",
"(",
"tc",
",",
"\"JNDI_NON_JEE_THREAD_CWNEN1000E\"",
")",
")",
";",
"if",
"(",
"isTraceOn",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"getInjectionScopeData : (no CMD) : \"",
"+",
"nex",
".",
"toString",
"(",
"true",
")",
")",
";",
"throw",
"nex",
";",
"}",
"isd",
"=",
"injectionEngine",
".",
"getInjectionScopeData",
"(",
"cmd",
",",
"namespace",
")",
";",
"if",
"(",
"isTraceOn",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"Tr",
".",
"debug",
"(",
"tc",
",",
"cmd",
"+",
"\" -> \"",
"+",
"isd",
")",
";",
"return",
"isd",
";",
"}"
] | Internal method to obtain the injection metadata associated with
the specified component metadata. <p>
@return the associated injection metadata; or null if none exists | [
"Internal",
"method",
"to",
"obtain",
"the",
"injection",
"metadata",
"associated",
"with",
"the",
"specified",
"component",
"metadata",
".",
"<p",
">"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.injection/src/com/ibm/ws/injectionengine/osgi/internal/naming/InjectionJavaColonHelper.java#L149-L170 |
phax/ph-oton | ph-oton-core/src/main/java/com/helger/photon/core/menu/MenuItemDeterminatorCallback.java | MenuItemDeterminatorCallback.getAllMenuItemIDs | @Nonnull
@ReturnsMutableCopy
public static ICommonsMap <String, Boolean> getAllMenuItemIDs (@Nonnull final IMenuTree aMenuTree) {
"""
Get all menu items without usage a separate
{@link MenuItemDeterminatorCallback} instance.
@param aMenuTree
The menu tree to get all items from. May not be <code>null</code>.
@return A non-<code>null</code> map with all menu item IDs as keys and the
"expansion state" as the value.
"""
ValueEnforcer.notNull (aMenuTree, "MenuTree");
final ICommonsMap <String, Boolean> ret = new CommonsHashMap <> ();
TreeVisitor.visitTree (aMenuTree,
new DefaultHierarchyVisitorCallback <DefaultTreeItemWithID <String, IMenuObject>> ()
{
@Override
public EHierarchyVisitorReturn onItemBeforeChildren (@Nonnull final DefaultTreeItemWithID <String, IMenuObject> aItem)
{
ret.put (aItem.getID (), Boolean.valueOf (aItem.hasChildren ()));
return EHierarchyVisitorReturn.CONTINUE;
}
});
return ret;
} | java | @Nonnull
@ReturnsMutableCopy
public static ICommonsMap <String, Boolean> getAllMenuItemIDs (@Nonnull final IMenuTree aMenuTree)
{
ValueEnforcer.notNull (aMenuTree, "MenuTree");
final ICommonsMap <String, Boolean> ret = new CommonsHashMap <> ();
TreeVisitor.visitTree (aMenuTree,
new DefaultHierarchyVisitorCallback <DefaultTreeItemWithID <String, IMenuObject>> ()
{
@Override
public EHierarchyVisitorReturn onItemBeforeChildren (@Nonnull final DefaultTreeItemWithID <String, IMenuObject> aItem)
{
ret.put (aItem.getID (), Boolean.valueOf (aItem.hasChildren ()));
return EHierarchyVisitorReturn.CONTINUE;
}
});
return ret;
} | [
"@",
"Nonnull",
"@",
"ReturnsMutableCopy",
"public",
"static",
"ICommonsMap",
"<",
"String",
",",
"Boolean",
">",
"getAllMenuItemIDs",
"(",
"@",
"Nonnull",
"final",
"IMenuTree",
"aMenuTree",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aMenuTree",
",",
"\"MenuTree\"",
")",
";",
"final",
"ICommonsMap",
"<",
"String",
",",
"Boolean",
">",
"ret",
"=",
"new",
"CommonsHashMap",
"<>",
"(",
")",
";",
"TreeVisitor",
".",
"visitTree",
"(",
"aMenuTree",
",",
"new",
"DefaultHierarchyVisitorCallback",
"<",
"DefaultTreeItemWithID",
"<",
"String",
",",
"IMenuObject",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"EHierarchyVisitorReturn",
"onItemBeforeChildren",
"(",
"@",
"Nonnull",
"final",
"DefaultTreeItemWithID",
"<",
"String",
",",
"IMenuObject",
">",
"aItem",
")",
"{",
"ret",
".",
"put",
"(",
"aItem",
".",
"getID",
"(",
")",
",",
"Boolean",
".",
"valueOf",
"(",
"aItem",
".",
"hasChildren",
"(",
")",
")",
")",
";",
"return",
"EHierarchyVisitorReturn",
".",
"CONTINUE",
";",
"}",
"}",
")",
";",
"return",
"ret",
";",
"}"
] | Get all menu items without usage a separate
{@link MenuItemDeterminatorCallback} instance.
@param aMenuTree
The menu tree to get all items from. May not be <code>null</code>.
@return A non-<code>null</code> map with all menu item IDs as keys and the
"expansion state" as the value. | [
"Get",
"all",
"menu",
"items",
"without",
"usage",
"a",
"separate",
"{",
"@link",
"MenuItemDeterminatorCallback",
"}",
"instance",
"."
] | train | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-core/src/main/java/com/helger/photon/core/menu/MenuItemDeterminatorCallback.java#L180-L198 |
liferay/com-liferay-commerce | commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPSpecificationOptionPersistenceImpl.java | CPSpecificationOptionPersistenceImpl.removeByG_K | @Override
public CPSpecificationOption removeByG_K(long groupId, String key)
throws NoSuchCPSpecificationOptionException {
"""
Removes the cp specification option where groupId = ? and key = ? from the database.
@param groupId the group ID
@param key the key
@return the cp specification option that was removed
"""
CPSpecificationOption cpSpecificationOption = findByG_K(groupId, key);
return remove(cpSpecificationOption);
} | java | @Override
public CPSpecificationOption removeByG_K(long groupId, String key)
throws NoSuchCPSpecificationOptionException {
CPSpecificationOption cpSpecificationOption = findByG_K(groupId, key);
return remove(cpSpecificationOption);
} | [
"@",
"Override",
"public",
"CPSpecificationOption",
"removeByG_K",
"(",
"long",
"groupId",
",",
"String",
"key",
")",
"throws",
"NoSuchCPSpecificationOptionException",
"{",
"CPSpecificationOption",
"cpSpecificationOption",
"=",
"findByG_K",
"(",
"groupId",
",",
"key",
")",
";",
"return",
"remove",
"(",
"cpSpecificationOption",
")",
";",
"}"
] | Removes the cp specification option where groupId = ? and key = ? from the database.
@param groupId the group ID
@param key the key
@return the cp specification option that was removed | [
"Removes",
"the",
"cp",
"specification",
"option",
"where",
"groupId",
"=",
"?",
";",
"and",
"key",
"=",
"?",
";",
"from",
"the",
"database",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPSpecificationOptionPersistenceImpl.java#L2697-L2703 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.