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
|
---|---|---|---|---|---|---|---|---|---|---|
UrielCh/ovh-java-sdk | ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java | ApiOvhOrder.telephony_spare_new_GET | public OvhOrder telephony_spare_new_GET(String brand, String mondialRelayId, Long quantity, Long shippingContactId) throws IOException {
"""
Get prices and contracts information
REST: GET /order/telephony/spare/new
@param shippingContactId [required] Shipping contact information id from /me entry point
@param brand [required] Spare phone brand model
@param mondialRelayId [required] Use /supply/mondialRelay entry point to specify a relay point and ignore shipping contact address information entry.
@param quantity [required] Number of phone quantity
"""
String qPath = "/order/telephony/spare/new";
StringBuilder sb = path(qPath);
query(sb, "brand", brand);
query(sb, "mondialRelayId", mondialRelayId);
query(sb, "quantity", quantity);
query(sb, "shippingContactId", shippingContactId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhOrder.class);
} | java | public OvhOrder telephony_spare_new_GET(String brand, String mondialRelayId, Long quantity, Long shippingContactId) throws IOException {
String qPath = "/order/telephony/spare/new";
StringBuilder sb = path(qPath);
query(sb, "brand", brand);
query(sb, "mondialRelayId", mondialRelayId);
query(sb, "quantity", quantity);
query(sb, "shippingContactId", shippingContactId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhOrder.class);
} | [
"public",
"OvhOrder",
"telephony_spare_new_GET",
"(",
"String",
"brand",
",",
"String",
"mondialRelayId",
",",
"Long",
"quantity",
",",
"Long",
"shippingContactId",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/order/telephony/spare/new\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
")",
";",
"query",
"(",
"sb",
",",
"\"brand\"",
",",
"brand",
")",
";",
"query",
"(",
"sb",
",",
"\"mondialRelayId\"",
",",
"mondialRelayId",
")",
";",
"query",
"(",
"sb",
",",
"\"quantity\"",
",",
"quantity",
")",
";",
"query",
"(",
"sb",
",",
"\"shippingContactId\"",
",",
"shippingContactId",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhOrder",
".",
"class",
")",
";",
"}"
] | Get prices and contracts information
REST: GET /order/telephony/spare/new
@param shippingContactId [required] Shipping contact information id from /me entry point
@param brand [required] Spare phone brand model
@param mondialRelayId [required] Use /supply/mondialRelay entry point to specify a relay point and ignore shipping contact address information entry.
@param quantity [required] Number of phone quantity | [
"Get",
"prices",
"and",
"contracts",
"information"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java#L6064-L6073 |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/operators/DataSinkTask.java | DataSinkTask.initInputReaders | @SuppressWarnings("unchecked")
private void initInputReaders() throws Exception {
"""
Initializes the input readers of the DataSinkTask.
@throws RuntimeException
Thrown in case of invalid task input configuration.
"""
int numGates = 0;
// ---------------- create the input readers ---------------------
// in case where a logical input unions multiple physical inputs, create a union reader
final int groupSize = this.config.getGroupSize(0);
numGates += groupSize;
if (groupSize == 1) {
// non-union case
inputReader = new MutableRecordReader<DeserializationDelegate<IT>>(
getEnvironment().getInputGate(0),
getEnvironment().getTaskManagerInfo().getTmpDirectories());
} else if (groupSize > 1){
// union case
inputReader = new MutableRecordReader<IOReadableWritable>(
new UnionInputGate(getEnvironment().getAllInputGates()),
getEnvironment().getTaskManagerInfo().getTmpDirectories());
} else {
throw new Exception("Illegal input group size in task configuration: " + groupSize);
}
this.inputTypeSerializerFactory = this.config.getInputSerializer(0, getUserCodeClassLoader());
@SuppressWarnings({ "rawtypes" })
final MutableObjectIterator<?> iter = new ReaderIterator(inputReader, this.inputTypeSerializerFactory.getSerializer());
this.reader = (MutableObjectIterator<IT>)iter;
// final sanity check
if (numGates != this.config.getNumInputs()) {
throw new Exception("Illegal configuration: Number of input gates and group sizes are not consistent.");
}
} | java | @SuppressWarnings("unchecked")
private void initInputReaders() throws Exception {
int numGates = 0;
// ---------------- create the input readers ---------------------
// in case where a logical input unions multiple physical inputs, create a union reader
final int groupSize = this.config.getGroupSize(0);
numGates += groupSize;
if (groupSize == 1) {
// non-union case
inputReader = new MutableRecordReader<DeserializationDelegate<IT>>(
getEnvironment().getInputGate(0),
getEnvironment().getTaskManagerInfo().getTmpDirectories());
} else if (groupSize > 1){
// union case
inputReader = new MutableRecordReader<IOReadableWritable>(
new UnionInputGate(getEnvironment().getAllInputGates()),
getEnvironment().getTaskManagerInfo().getTmpDirectories());
} else {
throw new Exception("Illegal input group size in task configuration: " + groupSize);
}
this.inputTypeSerializerFactory = this.config.getInputSerializer(0, getUserCodeClassLoader());
@SuppressWarnings({ "rawtypes" })
final MutableObjectIterator<?> iter = new ReaderIterator(inputReader, this.inputTypeSerializerFactory.getSerializer());
this.reader = (MutableObjectIterator<IT>)iter;
// final sanity check
if (numGates != this.config.getNumInputs()) {
throw new Exception("Illegal configuration: Number of input gates and group sizes are not consistent.");
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"void",
"initInputReaders",
"(",
")",
"throws",
"Exception",
"{",
"int",
"numGates",
"=",
"0",
";",
"// ---------------- create the input readers ---------------------",
"// in case where a logical input unions multiple physical inputs, create a union reader",
"final",
"int",
"groupSize",
"=",
"this",
".",
"config",
".",
"getGroupSize",
"(",
"0",
")",
";",
"numGates",
"+=",
"groupSize",
";",
"if",
"(",
"groupSize",
"==",
"1",
")",
"{",
"// non-union case",
"inputReader",
"=",
"new",
"MutableRecordReader",
"<",
"DeserializationDelegate",
"<",
"IT",
">",
">",
"(",
"getEnvironment",
"(",
")",
".",
"getInputGate",
"(",
"0",
")",
",",
"getEnvironment",
"(",
")",
".",
"getTaskManagerInfo",
"(",
")",
".",
"getTmpDirectories",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"groupSize",
">",
"1",
")",
"{",
"// union case",
"inputReader",
"=",
"new",
"MutableRecordReader",
"<",
"IOReadableWritable",
">",
"(",
"new",
"UnionInputGate",
"(",
"getEnvironment",
"(",
")",
".",
"getAllInputGates",
"(",
")",
")",
",",
"getEnvironment",
"(",
")",
".",
"getTaskManagerInfo",
"(",
")",
".",
"getTmpDirectories",
"(",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"\"Illegal input group size in task configuration: \"",
"+",
"groupSize",
")",
";",
"}",
"this",
".",
"inputTypeSerializerFactory",
"=",
"this",
".",
"config",
".",
"getInputSerializer",
"(",
"0",
",",
"getUserCodeClassLoader",
"(",
")",
")",
";",
"@",
"SuppressWarnings",
"(",
"{",
"\"rawtypes\"",
"}",
")",
"final",
"MutableObjectIterator",
"<",
"?",
">",
"iter",
"=",
"new",
"ReaderIterator",
"(",
"inputReader",
",",
"this",
".",
"inputTypeSerializerFactory",
".",
"getSerializer",
"(",
")",
")",
";",
"this",
".",
"reader",
"=",
"(",
"MutableObjectIterator",
"<",
"IT",
">",
")",
"iter",
";",
"// final sanity check",
"if",
"(",
"numGates",
"!=",
"this",
".",
"config",
".",
"getNumInputs",
"(",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Illegal configuration: Number of input gates and group sizes are not consistent.\"",
")",
";",
"}",
"}"
] | Initializes the input readers of the DataSinkTask.
@throws RuntimeException
Thrown in case of invalid task input configuration. | [
"Initializes",
"the",
"input",
"readers",
"of",
"the",
"DataSinkTask",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/operators/DataSinkTask.java#L360-L390 |
apache/reef | lang/java/reef-applications/reef-vortex/src/main/java/org/apache/reef/vortex/driver/RunningWorkers.java | RunningWorkers.cancelTasklet | void cancelTasklet(final boolean mayInterruptIfRunning, final int taskletId) {
"""
Concurrency: Called by multiple threads.
Parameter: Same taskletId can come in multiple times.
"""
lock.lock();
try {
// This is not ideal since we are using a linear time search on all the workers.
final String workerId = getWhereTaskletWasScheduledTo(taskletId);
if (workerId == null) {
// launchTasklet called but not yet running.
taskletsToCancel.add(taskletId);
return;
}
if (mayInterruptIfRunning) {
LOG.log(Level.FINE, "Cancelling running Tasklet with ID {0}.", taskletId);
runningWorkers.get(workerId).cancelTasklet(taskletId);
}
} finally {
lock.unlock();
}
} | java | void cancelTasklet(final boolean mayInterruptIfRunning, final int taskletId) {
lock.lock();
try {
// This is not ideal since we are using a linear time search on all the workers.
final String workerId = getWhereTaskletWasScheduledTo(taskletId);
if (workerId == null) {
// launchTasklet called but not yet running.
taskletsToCancel.add(taskletId);
return;
}
if (mayInterruptIfRunning) {
LOG.log(Level.FINE, "Cancelling running Tasklet with ID {0}.", taskletId);
runningWorkers.get(workerId).cancelTasklet(taskletId);
}
} finally {
lock.unlock();
}
} | [
"void",
"cancelTasklet",
"(",
"final",
"boolean",
"mayInterruptIfRunning",
",",
"final",
"int",
"taskletId",
")",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"// This is not ideal since we are using a linear time search on all the workers.",
"final",
"String",
"workerId",
"=",
"getWhereTaskletWasScheduledTo",
"(",
"taskletId",
")",
";",
"if",
"(",
"workerId",
"==",
"null",
")",
"{",
"// launchTasklet called but not yet running.",
"taskletsToCancel",
".",
"add",
"(",
"taskletId",
")",
";",
"return",
";",
"}",
"if",
"(",
"mayInterruptIfRunning",
")",
"{",
"LOG",
".",
"log",
"(",
"Level",
".",
"FINE",
",",
"\"Cancelling running Tasklet with ID {0}.\"",
",",
"taskletId",
")",
";",
"runningWorkers",
".",
"get",
"(",
"workerId",
")",
".",
"cancelTasklet",
"(",
"taskletId",
")",
";",
"}",
"}",
"finally",
"{",
"lock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] | Concurrency: Called by multiple threads.
Parameter: Same taskletId can come in multiple times. | [
"Concurrency",
":",
"Called",
"by",
"multiple",
"threads",
".",
"Parameter",
":",
"Same",
"taskletId",
"can",
"come",
"in",
"multiple",
"times",
"."
] | train | https://github.com/apache/reef/blob/e2c47121cde21108a602c560cf76565a40d0e916/lang/java/reef-applications/reef-vortex/src/main/java/org/apache/reef/vortex/driver/RunningWorkers.java#L186-L204 |
j-a-w-r/jawr-main-repo | jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinGenerator.java | CssSkinGenerator.updateLocaleVariants | private void updateLocaleVariants(ResourceBrowser rsBrowser, String path, Set<String> localeVariants) {
"""
Update the locale variants from the directory path given in parameter
@param rsBrowser
the resource browser
@param path
the skin path
@param localeVariants
the set of locale variants to update
"""
Set<String> skinPaths = rsBrowser.getResourceNames(path);
for (Iterator<String> itSkinPath = skinPaths.iterator(); itSkinPath.hasNext();) {
String skinPath = path + itSkinPath.next();
if (rsBrowser.isDirectory(skinPath)) {
String skinDirName = PathNormalizer.getPathName(skinPath);
if (LocaleUtils.LOCALE_SUFFIXES.contains(skinDirName)) {
localeVariants.add(skinDirName);
}
}
}
} | java | private void updateLocaleVariants(ResourceBrowser rsBrowser, String path, Set<String> localeVariants) {
Set<String> skinPaths = rsBrowser.getResourceNames(path);
for (Iterator<String> itSkinPath = skinPaths.iterator(); itSkinPath.hasNext();) {
String skinPath = path + itSkinPath.next();
if (rsBrowser.isDirectory(skinPath)) {
String skinDirName = PathNormalizer.getPathName(skinPath);
if (LocaleUtils.LOCALE_SUFFIXES.contains(skinDirName)) {
localeVariants.add(skinDirName);
}
}
}
} | [
"private",
"void",
"updateLocaleVariants",
"(",
"ResourceBrowser",
"rsBrowser",
",",
"String",
"path",
",",
"Set",
"<",
"String",
">",
"localeVariants",
")",
"{",
"Set",
"<",
"String",
">",
"skinPaths",
"=",
"rsBrowser",
".",
"getResourceNames",
"(",
"path",
")",
";",
"for",
"(",
"Iterator",
"<",
"String",
">",
"itSkinPath",
"=",
"skinPaths",
".",
"iterator",
"(",
")",
";",
"itSkinPath",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"String",
"skinPath",
"=",
"path",
"+",
"itSkinPath",
".",
"next",
"(",
")",
";",
"if",
"(",
"rsBrowser",
".",
"isDirectory",
"(",
"skinPath",
")",
")",
"{",
"String",
"skinDirName",
"=",
"PathNormalizer",
".",
"getPathName",
"(",
"skinPath",
")",
";",
"if",
"(",
"LocaleUtils",
".",
"LOCALE_SUFFIXES",
".",
"contains",
"(",
"skinDirName",
")",
")",
"{",
"localeVariants",
".",
"add",
"(",
"skinDirName",
")",
";",
"}",
"}",
"}",
"}"
] | Update the locale variants from the directory path given in parameter
@param rsBrowser
the resource browser
@param path
the skin path
@param localeVariants
the set of locale variants to update | [
"Update",
"the",
"locale",
"variants",
"from",
"the",
"directory",
"path",
"given",
"in",
"parameter"
] | train | https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinGenerator.java#L573-L585 |
Waikato/moa | moa/src/main/java/moa/core/Utils.java | Utils.roundDouble | public static /*@pure@*/ double roundDouble(double value,int afterDecimalPoint) {
"""
Rounds a double to the given number of decimal places.
@param value the double value
@param afterDecimalPoint the number of digits after the decimal point
@return the double rounded to the given precision
"""
double mask = Math.pow(10.0, (double)afterDecimalPoint);
return (double)(Math.round(value * mask)) / mask;
} | java | public static /*@pure@*/ double roundDouble(double value,int afterDecimalPoint) {
double mask = Math.pow(10.0, (double)afterDecimalPoint);
return (double)(Math.round(value * mask)) / mask;
} | [
"public",
"static",
"/*@pure@*/",
"double",
"roundDouble",
"(",
"double",
"value",
",",
"int",
"afterDecimalPoint",
")",
"{",
"double",
"mask",
"=",
"Math",
".",
"pow",
"(",
"10.0",
",",
"(",
"double",
")",
"afterDecimalPoint",
")",
";",
"return",
"(",
"double",
")",
"(",
"Math",
".",
"round",
"(",
"value",
"*",
"mask",
")",
")",
"/",
"mask",
";",
"}"
] | Rounds a double to the given number of decimal places.
@param value the double value
@param afterDecimalPoint the number of digits after the decimal point
@return the double rounded to the given precision | [
"Rounds",
"a",
"double",
"to",
"the",
"given",
"number",
"of",
"decimal",
"places",
"."
] | train | https://github.com/Waikato/moa/blob/395982e5100bfe75a3a4d26115462ce2cc74cbb0/moa/src/main/java/moa/core/Utils.java#L1307-L1312 |
mozilla/rhino | src/org/mozilla/javascript/Parser.java | Parser.createDestructuringAssignment | Node createDestructuringAssignment(int type, Node left, Node right) {
"""
Given a destructuring assignment with a left hand side parsed
as an array or object literal and a right hand side expression,
rewrite as a series of assignments to the variables defined in
left from property accesses to the expression on the right.
@param type declaration type: Token.VAR or Token.LET or -1
@param left array or object literal containing NAME nodes for
variables to assign
@param right expression to assign from
@return expression that performs a series of assignments to
the variables defined in left
"""
String tempName = currentScriptOrFn.getNextTempName();
Node result = destructuringAssignmentHelper(type, left, right,
tempName);
Node comma = result.getLastChild();
comma.addChildToBack(createName(tempName));
return result;
} | java | Node createDestructuringAssignment(int type, Node left, Node right)
{
String tempName = currentScriptOrFn.getNextTempName();
Node result = destructuringAssignmentHelper(type, left, right,
tempName);
Node comma = result.getLastChild();
comma.addChildToBack(createName(tempName));
return result;
} | [
"Node",
"createDestructuringAssignment",
"(",
"int",
"type",
",",
"Node",
"left",
",",
"Node",
"right",
")",
"{",
"String",
"tempName",
"=",
"currentScriptOrFn",
".",
"getNextTempName",
"(",
")",
";",
"Node",
"result",
"=",
"destructuringAssignmentHelper",
"(",
"type",
",",
"left",
",",
"right",
",",
"tempName",
")",
";",
"Node",
"comma",
"=",
"result",
".",
"getLastChild",
"(",
")",
";",
"comma",
".",
"addChildToBack",
"(",
"createName",
"(",
"tempName",
")",
")",
";",
"return",
"result",
";",
"}"
] | Given a destructuring assignment with a left hand side parsed
as an array or object literal and a right hand side expression,
rewrite as a series of assignments to the variables defined in
left from property accesses to the expression on the right.
@param type declaration type: Token.VAR or Token.LET or -1
@param left array or object literal containing NAME nodes for
variables to assign
@param right expression to assign from
@return expression that performs a series of assignments to
the variables defined in left | [
"Given",
"a",
"destructuring",
"assignment",
"with",
"a",
"left",
"hand",
"side",
"parsed",
"as",
"an",
"array",
"or",
"object",
"literal",
"and",
"a",
"right",
"hand",
"side",
"expression",
"rewrite",
"as",
"a",
"series",
"of",
"assignments",
"to",
"the",
"variables",
"defined",
"in",
"left",
"from",
"property",
"accesses",
"to",
"the",
"expression",
"on",
"the",
"right",
"."
] | train | https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/Parser.java#L3996-L4004 |
apache/incubator-gobblin | gobblin-modules/gobblin-sql/src/main/java/org/apache/gobblin/source/jdbc/SqlQueryUtils.java | SqlQueryUtils.addPredicate | public static String addPredicate(String query, String predicateCond) {
"""
Add a new predicate(filter condition) to the query. The method will add a "where" clause if
none exists. Otherwise, it will add the condition as a conjunction (and).
<b>Note that this method is rather limited. It works only if there are no other clauses after
"where"</b>
@param query the query string to modify
@param predicateCond the predicate to add to the query
@return query the new query string
@throws IllegalArgumentException if the predicate cannot be added because of additional clauses
"""
if (Strings.isNullOrEmpty(predicateCond)) {
return query;
}
String normalizedQuery = query.toLowerCase().trim();
checkArgument(normalizedQuery.contains(" from "),
"query does not contain 'from': " + query);
checkArgument(! normalizedQuery.contains(" by "),
"query contains 'order by' or 'group by': " + query);
checkArgument(! normalizedQuery.contains(" having "),
"query contains 'having': " + query);
checkArgument(! normalizedQuery.contains(" limit "),
"query contains 'limit': " + query);
String keyword = " where ";
if (normalizedQuery.contains(keyword)) {
keyword = " and ";
}
query = query + keyword + "(" + predicateCond + ")";
return query;
} | java | public static String addPredicate(String query, String predicateCond) {
if (Strings.isNullOrEmpty(predicateCond)) {
return query;
}
String normalizedQuery = query.toLowerCase().trim();
checkArgument(normalizedQuery.contains(" from "),
"query does not contain 'from': " + query);
checkArgument(! normalizedQuery.contains(" by "),
"query contains 'order by' or 'group by': " + query);
checkArgument(! normalizedQuery.contains(" having "),
"query contains 'having': " + query);
checkArgument(! normalizedQuery.contains(" limit "),
"query contains 'limit': " + query);
String keyword = " where ";
if (normalizedQuery.contains(keyword)) {
keyword = " and ";
}
query = query + keyword + "(" + predicateCond + ")";
return query;
} | [
"public",
"static",
"String",
"addPredicate",
"(",
"String",
"query",
",",
"String",
"predicateCond",
")",
"{",
"if",
"(",
"Strings",
".",
"isNullOrEmpty",
"(",
"predicateCond",
")",
")",
"{",
"return",
"query",
";",
"}",
"String",
"normalizedQuery",
"=",
"query",
".",
"toLowerCase",
"(",
")",
".",
"trim",
"(",
")",
";",
"checkArgument",
"(",
"normalizedQuery",
".",
"contains",
"(",
"\" from \"",
")",
",",
"\"query does not contain 'from': \"",
"+",
"query",
")",
";",
"checkArgument",
"(",
"!",
"normalizedQuery",
".",
"contains",
"(",
"\" by \"",
")",
",",
"\"query contains 'order by' or 'group by': \"",
"+",
"query",
")",
";",
"checkArgument",
"(",
"!",
"normalizedQuery",
".",
"contains",
"(",
"\" having \"",
")",
",",
"\"query contains 'having': \"",
"+",
"query",
")",
";",
"checkArgument",
"(",
"!",
"normalizedQuery",
".",
"contains",
"(",
"\" limit \"",
")",
",",
"\"query contains 'limit': \"",
"+",
"query",
")",
";",
"String",
"keyword",
"=",
"\" where \"",
";",
"if",
"(",
"normalizedQuery",
".",
"contains",
"(",
"keyword",
")",
")",
"{",
"keyword",
"=",
"\" and \"",
";",
"}",
"query",
"=",
"query",
"+",
"keyword",
"+",
"\"(\"",
"+",
"predicateCond",
"+",
"\")\"",
";",
"return",
"query",
";",
"}"
] | Add a new predicate(filter condition) to the query. The method will add a "where" clause if
none exists. Otherwise, it will add the condition as a conjunction (and).
<b>Note that this method is rather limited. It works only if there are no other clauses after
"where"</b>
@param query the query string to modify
@param predicateCond the predicate to add to the query
@return query the new query string
@throws IllegalArgumentException if the predicate cannot be added because of additional clauses | [
"Add",
"a",
"new",
"predicate",
"(",
"filter",
"condition",
")",
"to",
"the",
"query",
".",
"The",
"method",
"will",
"add",
"a",
"where",
"clause",
"if",
"none",
"exists",
".",
"Otherwise",
"it",
"will",
"add",
"the",
"condition",
"as",
"a",
"conjunction",
"(",
"and",
")",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-sql/src/main/java/org/apache/gobblin/source/jdbc/SqlQueryUtils.java#L43-L63 |
exoplatform/jcr | exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/deltav/ReportCommand.java | ReportCommand.getProperties | protected Set<QName> getProperties(HierarchicalProperty body) {
"""
Returns the list of properties.
@param body request body
@return the list of properties
"""
HashSet<QName> properties = new HashSet<QName>();
HierarchicalProperty prop = body.getChild(new QName("DAV:", "prop"));
if (prop == null)
{
return properties;
}
for (int i = 0; i < prop.getChildren().size(); i++)
{
HierarchicalProperty property = prop.getChild(i);
properties.add(property.getName());
}
return properties;
} | java | protected Set<QName> getProperties(HierarchicalProperty body)
{
HashSet<QName> properties = new HashSet<QName>();
HierarchicalProperty prop = body.getChild(new QName("DAV:", "prop"));
if (prop == null)
{
return properties;
}
for (int i = 0; i < prop.getChildren().size(); i++)
{
HierarchicalProperty property = prop.getChild(i);
properties.add(property.getName());
}
return properties;
} | [
"protected",
"Set",
"<",
"QName",
">",
"getProperties",
"(",
"HierarchicalProperty",
"body",
")",
"{",
"HashSet",
"<",
"QName",
">",
"properties",
"=",
"new",
"HashSet",
"<",
"QName",
">",
"(",
")",
";",
"HierarchicalProperty",
"prop",
"=",
"body",
".",
"getChild",
"(",
"new",
"QName",
"(",
"\"DAV:\"",
",",
"\"prop\"",
")",
")",
";",
"if",
"(",
"prop",
"==",
"null",
")",
"{",
"return",
"properties",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"prop",
".",
"getChildren",
"(",
")",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"HierarchicalProperty",
"property",
"=",
"prop",
".",
"getChild",
"(",
"i",
")",
";",
"properties",
".",
"add",
"(",
"property",
".",
"getName",
"(",
")",
")",
";",
"}",
"return",
"properties",
";",
"}"
] | Returns the list of properties.
@param body request body
@return the list of properties | [
"Returns",
"the",
"list",
"of",
"properties",
"."
] | train | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/deltav/ReportCommand.java#L123-L140 |
nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/util/Debugger.java | Debugger.printInfo | public static void printInfo(Object caller, Object message) {
"""
Print an INFO message
@param caller the calling object
@param message the INFO message
"""
StringBuilder text = new StringBuilder();
Class<?> c = callerBuilder(caller, text);
if(message instanceof Throwable)
getLog(c).info(text.append(stackTrace((Throwable)message)));
else
getLog(c).info(text.append(message));
} | java | public static void printInfo(Object caller, Object message)
{
StringBuilder text = new StringBuilder();
Class<?> c = callerBuilder(caller, text);
if(message instanceof Throwable)
getLog(c).info(text.append(stackTrace((Throwable)message)));
else
getLog(c).info(text.append(message));
} | [
"public",
"static",
"void",
"printInfo",
"(",
"Object",
"caller",
",",
"Object",
"message",
")",
"{",
"StringBuilder",
"text",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"Class",
"<",
"?",
">",
"c",
"=",
"callerBuilder",
"(",
"caller",
",",
"text",
")",
";",
"if",
"(",
"message",
"instanceof",
"Throwable",
")",
"getLog",
"(",
"c",
")",
".",
"info",
"(",
"text",
".",
"append",
"(",
"stackTrace",
"(",
"(",
"Throwable",
")",
"message",
")",
")",
")",
";",
"else",
"getLog",
"(",
"c",
")",
".",
"info",
"(",
"text",
".",
"append",
"(",
"message",
")",
")",
";",
"}"
] | Print an INFO message
@param caller the calling object
@param message the INFO message | [
"Print",
"an",
"INFO",
"message"
] | train | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Debugger.java#L492-L504 |
google/error-prone | check_api/src/main/java/com/google/errorprone/fixes/SuggestedFixes.java | SuggestedFixes.addSuppressWarnings | @Nullable
public static Fix addSuppressWarnings(VisitorState state, String warningToSuppress) {
"""
Returns a fix that adds a {@code @SuppressWarnings(warningToSuppress)} to the closest
suppressible element to the node pointed at by {@code state.getPath()}.
@see #addSuppressWarnings(VisitorState, String, String)
"""
return addSuppressWarnings(state, warningToSuppress, null);
} | java | @Nullable
public static Fix addSuppressWarnings(VisitorState state, String warningToSuppress) {
return addSuppressWarnings(state, warningToSuppress, null);
} | [
"@",
"Nullable",
"public",
"static",
"Fix",
"addSuppressWarnings",
"(",
"VisitorState",
"state",
",",
"String",
"warningToSuppress",
")",
"{",
"return",
"addSuppressWarnings",
"(",
"state",
",",
"warningToSuppress",
",",
"null",
")",
";",
"}"
] | Returns a fix that adds a {@code @SuppressWarnings(warningToSuppress)} to the closest
suppressible element to the node pointed at by {@code state.getPath()}.
@see #addSuppressWarnings(VisitorState, String, String) | [
"Returns",
"a",
"fix",
"that",
"adds",
"a",
"{",
"@code",
"@SuppressWarnings",
"(",
"warningToSuppress",
")",
"}",
"to",
"the",
"closest",
"suppressible",
"element",
"to",
"the",
"node",
"pointed",
"at",
"by",
"{",
"@code",
"state",
".",
"getPath",
"()",
"}",
"."
] | train | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/fixes/SuggestedFixes.java#L549-L552 |
kristiankime/FCollections | src/main/java/com/artclod/common/collect/ArrayFList.java | ArrayFList.mkString | public String mkString(String start, String sep, String end) {
"""
Looping without creating in iterator is faster so we reimplement some methods for speed
"""
StringBuilder ret = new StringBuilder(start);
for (int i = 0; i < inner.size(); i++) {
ret.append(inner.get(i));
if (i != (inner.size() - 1)) {
ret.append(sep);
}
}
return ret.append(end).toString();
} | java | public String mkString(String start, String sep, String end) {
StringBuilder ret = new StringBuilder(start);
for (int i = 0; i < inner.size(); i++) {
ret.append(inner.get(i));
if (i != (inner.size() - 1)) {
ret.append(sep);
}
}
return ret.append(end).toString();
} | [
"public",
"String",
"mkString",
"(",
"String",
"start",
",",
"String",
"sep",
",",
"String",
"end",
")",
"{",
"StringBuilder",
"ret",
"=",
"new",
"StringBuilder",
"(",
"start",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"inner",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"ret",
".",
"append",
"(",
"inner",
".",
"get",
"(",
"i",
")",
")",
";",
"if",
"(",
"i",
"!=",
"(",
"inner",
".",
"size",
"(",
")",
"-",
"1",
")",
")",
"{",
"ret",
".",
"append",
"(",
"sep",
")",
";",
"}",
"}",
"return",
"ret",
".",
"append",
"(",
"end",
")",
".",
"toString",
"(",
")",
";",
"}"
] | Looping without creating in iterator is faster so we reimplement some methods for speed | [
"Looping",
"without",
"creating",
"in",
"iterator",
"is",
"faster",
"so",
"we",
"reimplement",
"some",
"methods",
"for",
"speed"
] | train | https://github.com/kristiankime/FCollections/blob/a72eccf3c91ab855b72bedb2f6c1c9ad1499710a/src/main/java/com/artclod/common/collect/ArrayFList.java#L109-L118 |
omalley/hadoop-gpl-compression | src/java/com/hadoop/mapreduce/LzoTextInputFormat.java | LzoTextInputFormat.readIndex | private LzoIndex readIndex(Path file, FileSystem fs) throws IOException {
"""
Read the index of the lzo file.
@param split
Read the index of this file.
@param fs
The index file is on this file system.
@throws IOException
"""
FSDataInputStream indexIn = null;
try {
Path indexFile = new Path(file.toString() + LZO_INDEX_SUFFIX);
if (!fs.exists(indexFile)) {
// return empty index, fall back to the unsplittable mode
return new LzoIndex();
}
long indexLen = fs.getFileStatus(indexFile).getLen();
int blocks = (int) (indexLen / 8);
LzoIndex index = new LzoIndex(blocks);
indexIn = fs.open(indexFile);
for (int i = 0; i < blocks; i++) {
index.set(i, indexIn.readLong());
}
return index;
} finally {
if (indexIn != null) {
indexIn.close();
}
}
} | java | private LzoIndex readIndex(Path file, FileSystem fs) throws IOException {
FSDataInputStream indexIn = null;
try {
Path indexFile = new Path(file.toString() + LZO_INDEX_SUFFIX);
if (!fs.exists(indexFile)) {
// return empty index, fall back to the unsplittable mode
return new LzoIndex();
}
long indexLen = fs.getFileStatus(indexFile).getLen();
int blocks = (int) (indexLen / 8);
LzoIndex index = new LzoIndex(blocks);
indexIn = fs.open(indexFile);
for (int i = 0; i < blocks; i++) {
index.set(i, indexIn.readLong());
}
return index;
} finally {
if (indexIn != null) {
indexIn.close();
}
}
} | [
"private",
"LzoIndex",
"readIndex",
"(",
"Path",
"file",
",",
"FileSystem",
"fs",
")",
"throws",
"IOException",
"{",
"FSDataInputStream",
"indexIn",
"=",
"null",
";",
"try",
"{",
"Path",
"indexFile",
"=",
"new",
"Path",
"(",
"file",
".",
"toString",
"(",
")",
"+",
"LZO_INDEX_SUFFIX",
")",
";",
"if",
"(",
"!",
"fs",
".",
"exists",
"(",
"indexFile",
")",
")",
"{",
"// return empty index, fall back to the unsplittable mode",
"return",
"new",
"LzoIndex",
"(",
")",
";",
"}",
"long",
"indexLen",
"=",
"fs",
".",
"getFileStatus",
"(",
"indexFile",
")",
".",
"getLen",
"(",
")",
";",
"int",
"blocks",
"=",
"(",
"int",
")",
"(",
"indexLen",
"/",
"8",
")",
";",
"LzoIndex",
"index",
"=",
"new",
"LzoIndex",
"(",
"blocks",
")",
";",
"indexIn",
"=",
"fs",
".",
"open",
"(",
"indexFile",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"blocks",
";",
"i",
"++",
")",
"{",
"index",
".",
"set",
"(",
"i",
",",
"indexIn",
".",
"readLong",
"(",
")",
")",
";",
"}",
"return",
"index",
";",
"}",
"finally",
"{",
"if",
"(",
"indexIn",
"!=",
"null",
")",
"{",
"indexIn",
".",
"close",
"(",
")",
";",
"}",
"}",
"}"
] | Read the index of the lzo file.
@param split
Read the index of this file.
@param fs
The index file is on this file system.
@throws IOException | [
"Read",
"the",
"index",
"of",
"the",
"lzo",
"file",
"."
] | train | https://github.com/omalley/hadoop-gpl-compression/blob/64ab3eb60fffac2a4d77680d506b34b02fcc3d7e/src/java/com/hadoop/mapreduce/LzoTextInputFormat.java#L156-L178 |
m-m-m/util | nls/src/main/java/net/sf/mmm/util/nls/base/AbstractNlsBundleFactory.java | AbstractNlsBundleFactory.createHandler | protected InvocationHandler createHandler(Class<? extends NlsBundle> bundleInterface) {
"""
This method creates a new {@link InvocationHandler} for the given {@code bundleInterface}.
@param bundleInterface is the {@link Class} reflecting the {@link NlsBundle} interface.
@return the {@link InvocationHandler} for the given {@code bundleInterface}.
"""
String bundleName = NlsBundleHelper.getInstance().getQualifiedLocation(bundleInterface);
NlsBundleOptions options = getBundleOptions(bundleInterface);
return new NlsBundleInvocationHandler(bundleInterface, bundleName, options);
} | java | protected InvocationHandler createHandler(Class<? extends NlsBundle> bundleInterface) {
String bundleName = NlsBundleHelper.getInstance().getQualifiedLocation(bundleInterface);
NlsBundleOptions options = getBundleOptions(bundleInterface);
return new NlsBundleInvocationHandler(bundleInterface, bundleName, options);
} | [
"protected",
"InvocationHandler",
"createHandler",
"(",
"Class",
"<",
"?",
"extends",
"NlsBundle",
">",
"bundleInterface",
")",
"{",
"String",
"bundleName",
"=",
"NlsBundleHelper",
".",
"getInstance",
"(",
")",
".",
"getQualifiedLocation",
"(",
"bundleInterface",
")",
";",
"NlsBundleOptions",
"options",
"=",
"getBundleOptions",
"(",
"bundleInterface",
")",
";",
"return",
"new",
"NlsBundleInvocationHandler",
"(",
"bundleInterface",
",",
"bundleName",
",",
"options",
")",
";",
"}"
] | This method creates a new {@link InvocationHandler} for the given {@code bundleInterface}.
@param bundleInterface is the {@link Class} reflecting the {@link NlsBundle} interface.
@return the {@link InvocationHandler} for the given {@code bundleInterface}. | [
"This",
"method",
"creates",
"a",
"new",
"{",
"@link",
"InvocationHandler",
"}",
"for",
"the",
"given",
"{",
"@code",
"bundleInterface",
"}",
"."
] | train | https://github.com/m-m-m/util/blob/f0e4e084448f8dfc83ca682a9e1618034a094ce6/nls/src/main/java/net/sf/mmm/util/nls/base/AbstractNlsBundleFactory.java#L186-L191 |
datumbox/datumbox-framework | datumbox-framework-common/src/main/java/com/datumbox/framework/common/dataobjects/TransposeDataCollection2D.java | TransposeDataCollection2D.put | public final TransposeDataCollection put(Object key, TransposeDataCollection value) {
"""
Adds a particular key-value into the internal map. It returns the previous
value which was associated with that key.
@param key
@param value
@return
"""
return internalData.put(key, value);
} | java | public final TransposeDataCollection put(Object key, TransposeDataCollection value) {
return internalData.put(key, value);
} | [
"public",
"final",
"TransposeDataCollection",
"put",
"(",
"Object",
"key",
",",
"TransposeDataCollection",
"value",
")",
"{",
"return",
"internalData",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"}"
] | Adds a particular key-value into the internal map. It returns the previous
value which was associated with that key.
@param key
@param value
@return | [
"Adds",
"a",
"particular",
"key",
"-",
"value",
"into",
"the",
"internal",
"map",
".",
"It",
"returns",
"the",
"previous",
"value",
"which",
"was",
"associated",
"with",
"that",
"key",
"."
] | train | https://github.com/datumbox/datumbox-framework/blob/909dff0476e80834f05ecdde0624dd2390e9b0ca/datumbox-framework-common/src/main/java/com/datumbox/framework/common/dataobjects/TransposeDataCollection2D.java#L79-L81 |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/typesystem/SARLTypeComputer.java | SARLTypeComputer._computeTypes | protected void _computeTypes(SarlAssertExpression object, ITypeComputationState state) {
"""
Compute the type of an assert expression.
@param object the expression.
@param state the state of the type resolver.
"""
state.withExpectation(getTypeForName(Boolean.class, state)).computeTypes(object.getCondition());
} | java | protected void _computeTypes(SarlAssertExpression object, ITypeComputationState state) {
state.withExpectation(getTypeForName(Boolean.class, state)).computeTypes(object.getCondition());
} | [
"protected",
"void",
"_computeTypes",
"(",
"SarlAssertExpression",
"object",
",",
"ITypeComputationState",
"state",
")",
"{",
"state",
".",
"withExpectation",
"(",
"getTypeForName",
"(",
"Boolean",
".",
"class",
",",
"state",
")",
")",
".",
"computeTypes",
"(",
"object",
".",
"getCondition",
"(",
")",
")",
";",
"}"
] | Compute the type of an assert expression.
@param object the expression.
@param state the state of the type resolver. | [
"Compute",
"the",
"type",
"of",
"an",
"assert",
"expression",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/typesystem/SARLTypeComputer.java#L191-L193 |
Jasig/uPortal | uPortal-utils/uPortal-utils-core/src/main/java/org/apereo/portal/utils/ResourceUtils.java | ResourceUtils.getResourceUri | public static String getResourceUri(Resource resource) {
"""
First tries {@link Resource#getURI()} and if that fails with a FileNotFoundException then
{@link Resource#getDescription()} is returned.
"""
try {
return resource.getURI().toString();
} catch (FileNotFoundException e) {
return resource.getDescription();
} catch (IOException e) {
throw new RuntimeException("Could not create URI for resource: " + resource, e);
}
} | java | public static String getResourceUri(Resource resource) {
try {
return resource.getURI().toString();
} catch (FileNotFoundException e) {
return resource.getDescription();
} catch (IOException e) {
throw new RuntimeException("Could not create URI for resource: " + resource, e);
}
} | [
"public",
"static",
"String",
"getResourceUri",
"(",
"Resource",
"resource",
")",
"{",
"try",
"{",
"return",
"resource",
".",
"getURI",
"(",
")",
".",
"toString",
"(",
")",
";",
"}",
"catch",
"(",
"FileNotFoundException",
"e",
")",
"{",
"return",
"resource",
".",
"getDescription",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Could not create URI for resource: \"",
"+",
"resource",
",",
"e",
")",
";",
"}",
"}"
] | First tries {@link Resource#getURI()} and if that fails with a FileNotFoundException then
{@link Resource#getDescription()} is returned. | [
"First",
"tries",
"{"
] | train | https://github.com/Jasig/uPortal/blob/c1986542abb9acd214268f2df21c6305ad2f262b/uPortal-utils/uPortal-utils-core/src/main/java/org/apereo/portal/utils/ResourceUtils.java#L29-L37 |
Carbonado/Carbonado | src/main/java/com/amazon/carbonado/raw/KeyDecoder.java | KeyDecoder.decodeFloatObjDesc | public static Float decodeFloatObjDesc(byte[] src, int srcOffset)
throws CorruptEncodingException {
"""
Decodes a Float object from exactly 4 bytes.
@param src source of encoded bytes
@param srcOffset offset into source array
@return Float object or null
"""
int bits = DataDecoder.decodeFloatBits(src, srcOffset);
if (bits >= 0) {
bits ^= 0x7fffffff;
}
return bits == 0x7fffffff ? null : Float.intBitsToFloat(bits);
} | java | public static Float decodeFloatObjDesc(byte[] src, int srcOffset)
throws CorruptEncodingException
{
int bits = DataDecoder.decodeFloatBits(src, srcOffset);
if (bits >= 0) {
bits ^= 0x7fffffff;
}
return bits == 0x7fffffff ? null : Float.intBitsToFloat(bits);
} | [
"public",
"static",
"Float",
"decodeFloatObjDesc",
"(",
"byte",
"[",
"]",
"src",
",",
"int",
"srcOffset",
")",
"throws",
"CorruptEncodingException",
"{",
"int",
"bits",
"=",
"DataDecoder",
".",
"decodeFloatBits",
"(",
"src",
",",
"srcOffset",
")",
";",
"if",
"(",
"bits",
">=",
"0",
")",
"{",
"bits",
"^=",
"0x7fffffff",
";",
"}",
"return",
"bits",
"==",
"0x7fffffff",
"?",
"null",
":",
"Float",
".",
"intBitsToFloat",
"(",
"bits",
")",
";",
"}"
] | Decodes a Float object from exactly 4 bytes.
@param src source of encoded bytes
@param srcOffset offset into source array
@return Float object or null | [
"Decodes",
"a",
"Float",
"object",
"from",
"exactly",
"4",
"bytes",
"."
] | train | https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyDecoder.java#L293-L301 |
jlinn/quartz-redis-jobstore | src/main/java/net/joelinn/quartz/jobstore/AbstractRedisStorage.java | AbstractRedisStorage.resumeJob | public void resumeJob(JobKey jobKey, T jedis) throws JobPersistenceException {
"""
Resume (un-pause) the <code>{@link org.quartz.Job}</code> with the given key.
@param jobKey the key of the job to be resumed
@param jedis a thread-safe Redis connection
"""
for (OperableTrigger trigger : getTriggersForJob(jobKey, jedis)) {
resumeTrigger(trigger.getKey(), jedis);
}
} | java | public void resumeJob(JobKey jobKey, T jedis) throws JobPersistenceException {
for (OperableTrigger trigger : getTriggersForJob(jobKey, jedis)) {
resumeTrigger(trigger.getKey(), jedis);
}
} | [
"public",
"void",
"resumeJob",
"(",
"JobKey",
"jobKey",
",",
"T",
"jedis",
")",
"throws",
"JobPersistenceException",
"{",
"for",
"(",
"OperableTrigger",
"trigger",
":",
"getTriggersForJob",
"(",
"jobKey",
",",
"jedis",
")",
")",
"{",
"resumeTrigger",
"(",
"trigger",
".",
"getKey",
"(",
")",
",",
"jedis",
")",
";",
"}",
"}"
] | Resume (un-pause) the <code>{@link org.quartz.Job}</code> with the given key.
@param jobKey the key of the job to be resumed
@param jedis a thread-safe Redis connection | [
"Resume",
"(",
"un",
"-",
"pause",
")",
"the",
"<code",
">",
"{"
] | train | https://github.com/jlinn/quartz-redis-jobstore/blob/be9a52ee776d8a09866fe99fd9718bc13a0cb992/src/main/java/net/joelinn/quartz/jobstore/AbstractRedisStorage.java#L617-L621 |
geomajas/geomajas-project-client-gwt2 | plugin/tilebasedlayer/impl/src/main/java/org/geomajas/gwt2/plugin/tilebasedlayer/client/TileBasedLayerClient.java | TileBasedLayerClient.createOsmLayer | @Deprecated
public OsmLayer createOsmLayer(String id, TileConfiguration conf, String url) {
"""
Create a new OSM layer with an URL to an OSM tile service.
<p/>
The URL should have placeholders for the x- and y-coordinate and tile level in the form of {x}, {y}, {z}.
The file extension of the tiles should be part of the URL.
@param id The unique ID of the layer.
@param conf The tile configuration.
@param url The URL to the tile service.
@return A new OSM layer.
@deprecated use {@link #createOsmLayer(String, int, String)}
"""
OsmLayer layer = new OsmLayer(id, conf);
layer.addUrl(url);
return layer;
} | java | @Deprecated
public OsmLayer createOsmLayer(String id, TileConfiguration conf, String url) {
OsmLayer layer = new OsmLayer(id, conf);
layer.addUrl(url);
return layer;
} | [
"@",
"Deprecated",
"public",
"OsmLayer",
"createOsmLayer",
"(",
"String",
"id",
",",
"TileConfiguration",
"conf",
",",
"String",
"url",
")",
"{",
"OsmLayer",
"layer",
"=",
"new",
"OsmLayer",
"(",
"id",
",",
"conf",
")",
";",
"layer",
".",
"addUrl",
"(",
"url",
")",
";",
"return",
"layer",
";",
"}"
] | Create a new OSM layer with an URL to an OSM tile service.
<p/>
The URL should have placeholders for the x- and y-coordinate and tile level in the form of {x}, {y}, {z}.
The file extension of the tiles should be part of the URL.
@param id The unique ID of the layer.
@param conf The tile configuration.
@param url The URL to the tile service.
@return A new OSM layer.
@deprecated use {@link #createOsmLayer(String, int, String)} | [
"Create",
"a",
"new",
"OSM",
"layer",
"with",
"an",
"URL",
"to",
"an",
"OSM",
"tile",
"service",
".",
"<p",
"/",
">",
"The",
"URL",
"should",
"have",
"placeholders",
"for",
"the",
"x",
"-",
"and",
"y",
"-",
"coordinate",
"and",
"tile",
"level",
"in",
"the",
"form",
"of",
"{",
"x",
"}",
"{",
"y",
"}",
"{",
"z",
"}",
".",
"The",
"file",
"extension",
"of",
"the",
"tiles",
"should",
"be",
"part",
"of",
"the",
"URL",
"."
] | train | https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/plugin/tilebasedlayer/impl/src/main/java/org/geomajas/gwt2/plugin/tilebasedlayer/client/TileBasedLayerClient.java#L169-L174 |
ksclarke/freelib-utils | src/main/java/info/freelibrary/util/FileUtils.java | FileUtils.copyMetadata | private static void copyMetadata(final File aFile, final Element aElement) {
"""
Copy file metadata into the supplied file element.
@param aFile A file to extract metadata from
@param aElement A destination element for the file metadata
"""
final SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT, Locale.US);
final StringBuilder permissions = new StringBuilder();
final Date date = new Date(aFile.lastModified());
aElement.setAttribute(FILE_PATH, aFile.getAbsolutePath());
aElement.setAttribute(MODIFIED, formatter.format(date));
if (aFile.canRead()) {
permissions.append('r');
}
if (aFile.canWrite()) {
permissions.append('w');
}
aElement.setAttribute("permissions", permissions.toString());
} | java | private static void copyMetadata(final File aFile, final Element aElement) {
final SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT, Locale.US);
final StringBuilder permissions = new StringBuilder();
final Date date = new Date(aFile.lastModified());
aElement.setAttribute(FILE_PATH, aFile.getAbsolutePath());
aElement.setAttribute(MODIFIED, formatter.format(date));
if (aFile.canRead()) {
permissions.append('r');
}
if (aFile.canWrite()) {
permissions.append('w');
}
aElement.setAttribute("permissions", permissions.toString());
} | [
"private",
"static",
"void",
"copyMetadata",
"(",
"final",
"File",
"aFile",
",",
"final",
"Element",
"aElement",
")",
"{",
"final",
"SimpleDateFormat",
"formatter",
"=",
"new",
"SimpleDateFormat",
"(",
"DATE_FORMAT",
",",
"Locale",
".",
"US",
")",
";",
"final",
"StringBuilder",
"permissions",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"final",
"Date",
"date",
"=",
"new",
"Date",
"(",
"aFile",
".",
"lastModified",
"(",
")",
")",
";",
"aElement",
".",
"setAttribute",
"(",
"FILE_PATH",
",",
"aFile",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"aElement",
".",
"setAttribute",
"(",
"MODIFIED",
",",
"formatter",
".",
"format",
"(",
"date",
")",
")",
";",
"if",
"(",
"aFile",
".",
"canRead",
"(",
")",
")",
"{",
"permissions",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"if",
"(",
"aFile",
".",
"canWrite",
"(",
")",
")",
"{",
"permissions",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"aElement",
".",
"setAttribute",
"(",
"\"permissions\"",
",",
"permissions",
".",
"toString",
"(",
")",
")",
";",
"}"
] | Copy file metadata into the supplied file element.
@param aFile A file to extract metadata from
@param aElement A destination element for the file metadata | [
"Copy",
"file",
"metadata",
"into",
"the",
"supplied",
"file",
"element",
"."
] | train | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/FileUtils.java#L862-L879 |
jdereg/java-util | src/main/java/com/cedarsoftware/util/UrlUtilities.java | UrlUtilities.getContentFromUrl | @Deprecated
public static byte[] getContentFromUrl(String url, Map inCookies, Map outCookies, Proxy proxy, SSLSocketFactory factory, HostnameVerifier verifier) {
"""
Get content from the passed in URL. This code will open a connection to
the passed in server, fetch the requested content, and return it as a
byte[].
Anyone using the proxy calls such as this one should have that managed by the jvm with -D parameters:
http.proxyHost
http.proxyPort (default: 80)
http.nonProxyHosts (should always include localhost)
https.proxyHost
https.proxyPort
Example: -Dhttp.proxyHost=proxy.example.org -Dhttp.proxyPort=8080 -Dhttps.proxyHost=proxy.example.org -Dhttps.proxyPort=8080 -Dhttp.nonProxyHosts=*.foo.com|localhost|*.td.afg
@param url URL to hit
@param proxy Proxy server to create connection (or null if not needed)
@param factory custom SSLSocket factory (or null if not needed)
@param verifier custom Hostnameverifier (or null if not needed)
@return byte[] of content fetched from URL.
@deprecated As of release 1.13.0, replaced by {@link #getContentFromUrl(String)}
"""
return getContentFromUrl(url, inCookies, outCookies, true);
} | java | @Deprecated
public static byte[] getContentFromUrl(String url, Map inCookies, Map outCookies, Proxy proxy, SSLSocketFactory factory, HostnameVerifier verifier)
{
return getContentFromUrl(url, inCookies, outCookies, true);
} | [
"@",
"Deprecated",
"public",
"static",
"byte",
"[",
"]",
"getContentFromUrl",
"(",
"String",
"url",
",",
"Map",
"inCookies",
",",
"Map",
"outCookies",
",",
"Proxy",
"proxy",
",",
"SSLSocketFactory",
"factory",
",",
"HostnameVerifier",
"verifier",
")",
"{",
"return",
"getContentFromUrl",
"(",
"url",
",",
"inCookies",
",",
"outCookies",
",",
"true",
")",
";",
"}"
] | Get content from the passed in URL. This code will open a connection to
the passed in server, fetch the requested content, and return it as a
byte[].
Anyone using the proxy calls such as this one should have that managed by the jvm with -D parameters:
http.proxyHost
http.proxyPort (default: 80)
http.nonProxyHosts (should always include localhost)
https.proxyHost
https.proxyPort
Example: -Dhttp.proxyHost=proxy.example.org -Dhttp.proxyPort=8080 -Dhttps.proxyHost=proxy.example.org -Dhttps.proxyPort=8080 -Dhttp.nonProxyHosts=*.foo.com|localhost|*.td.afg
@param url URL to hit
@param proxy Proxy server to create connection (or null if not needed)
@param factory custom SSLSocket factory (or null if not needed)
@param verifier custom Hostnameverifier (or null if not needed)
@return byte[] of content fetched from URL.
@deprecated As of release 1.13.0, replaced by {@link #getContentFromUrl(String)} | [
"Get",
"content",
"from",
"the",
"passed",
"in",
"URL",
".",
"This",
"code",
"will",
"open",
"a",
"connection",
"to",
"the",
"passed",
"in",
"server",
"fetch",
"the",
"requested",
"content",
"and",
"return",
"it",
"as",
"a",
"byte",
"[]",
"."
] | train | https://github.com/jdereg/java-util/blob/a2dce61aed16d6454ee575174dda1ba6bff0015c/src/main/java/com/cedarsoftware/util/UrlUtilities.java#L804-L808 |
UrielCh/ovh-java-sdk | ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java | ApiOvhTelephony.billingAccount_line_serviceName_click2CallUser_id_changePassword_POST | public void billingAccount_line_serviceName_click2CallUser_id_changePassword_POST(String billingAccount, String serviceName, Long id, String password) throws IOException {
"""
Change the password of the click2call user
REST: POST /telephony/{billingAccount}/line/{serviceName}/click2CallUser/{id}/changePassword
@param password [required] The password
@param billingAccount [required] The name of your billingAccount
@param serviceName [required]
@param id [required] Id of the object
"""
String qPath = "/telephony/{billingAccount}/line/{serviceName}/click2CallUser/{id}/changePassword";
StringBuilder sb = path(qPath, billingAccount, serviceName, id);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "password", password);
exec(qPath, "POST", sb.toString(), o);
} | java | public void billingAccount_line_serviceName_click2CallUser_id_changePassword_POST(String billingAccount, String serviceName, Long id, String password) throws IOException {
String qPath = "/telephony/{billingAccount}/line/{serviceName}/click2CallUser/{id}/changePassword";
StringBuilder sb = path(qPath, billingAccount, serviceName, id);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "password", password);
exec(qPath, "POST", sb.toString(), o);
} | [
"public",
"void",
"billingAccount_line_serviceName_click2CallUser_id_changePassword_POST",
"(",
"String",
"billingAccount",
",",
"String",
"serviceName",
",",
"Long",
"id",
",",
"String",
"password",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/telephony/{billingAccount}/line/{serviceName}/click2CallUser/{id}/changePassword\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"billingAccount",
",",
"serviceName",
",",
"id",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"password\"",
",",
"password",
")",
";",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"}"
] | Change the password of the click2call user
REST: POST /telephony/{billingAccount}/line/{serviceName}/click2CallUser/{id}/changePassword
@param password [required] The password
@param billingAccount [required] The name of your billingAccount
@param serviceName [required]
@param id [required] Id of the object | [
"Change",
"the",
"password",
"of",
"the",
"click2call",
"user"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L871-L877 |
i-net-software/jlessc | src/com/inet/lib/less/UrlUtils.java | UrlUtils.dataUri | static void dataUri( CssFormatter formatter, String relativeUrlStr, final String urlString, String type ) throws IOException {
"""
Implementation of the function data-uri.
@param formatter current formatter
@param relativeUrlStr relative URL of the less script. Is used as base URL
@param urlString the url parameter of the function
@param type the mime type
@throws IOException If any I/O errors occur on reading the content
"""
String urlStr = removeQuote( urlString );
InputStream input;
try {
input = formatter.getReaderFactory().openStream( formatter.getBaseURL(), urlStr, relativeUrlStr );
} catch( Exception e ) {
boolean quote = urlString != urlStr;
String rewrittenUrl;
if( formatter.isRewriteUrl( urlStr ) ) {
URL relativeUrl = new URL( relativeUrlStr );
relativeUrl = new URL( relativeUrl, urlStr );
rewrittenUrl = relativeUrl.getPath();
rewrittenUrl = quote ? urlString.charAt( 0 ) + rewrittenUrl + urlString.charAt( 0 ) : rewrittenUrl;
} else {
rewrittenUrl = urlString;
}
formatter.append( "url(" ).append( rewrittenUrl ).append( ')' );
return;
}
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
int count;
byte[] data = new byte[16384];
while( (count = input.read( data, 0, data.length )) > 0 ) {
buffer.write( data, 0, count );
}
input.close();
byte[] bytes = buffer.toByteArray();
if( bytes.length >= 32 * 1024 ) {
formatter.append( "url(" ).append( urlString ).append( ')' );
} else {
dataUri( formatter, bytes, urlStr, type );
}
} | java | static void dataUri( CssFormatter formatter, String relativeUrlStr, final String urlString, String type ) throws IOException {
String urlStr = removeQuote( urlString );
InputStream input;
try {
input = formatter.getReaderFactory().openStream( formatter.getBaseURL(), urlStr, relativeUrlStr );
} catch( Exception e ) {
boolean quote = urlString != urlStr;
String rewrittenUrl;
if( formatter.isRewriteUrl( urlStr ) ) {
URL relativeUrl = new URL( relativeUrlStr );
relativeUrl = new URL( relativeUrl, urlStr );
rewrittenUrl = relativeUrl.getPath();
rewrittenUrl = quote ? urlString.charAt( 0 ) + rewrittenUrl + urlString.charAt( 0 ) : rewrittenUrl;
} else {
rewrittenUrl = urlString;
}
formatter.append( "url(" ).append( rewrittenUrl ).append( ')' );
return;
}
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
int count;
byte[] data = new byte[16384];
while( (count = input.read( data, 0, data.length )) > 0 ) {
buffer.write( data, 0, count );
}
input.close();
byte[] bytes = buffer.toByteArray();
if( bytes.length >= 32 * 1024 ) {
formatter.append( "url(" ).append( urlString ).append( ')' );
} else {
dataUri( formatter, bytes, urlStr, type );
}
} | [
"static",
"void",
"dataUri",
"(",
"CssFormatter",
"formatter",
",",
"String",
"relativeUrlStr",
",",
"final",
"String",
"urlString",
",",
"String",
"type",
")",
"throws",
"IOException",
"{",
"String",
"urlStr",
"=",
"removeQuote",
"(",
"urlString",
")",
";",
"InputStream",
"input",
";",
"try",
"{",
"input",
"=",
"formatter",
".",
"getReaderFactory",
"(",
")",
".",
"openStream",
"(",
"formatter",
".",
"getBaseURL",
"(",
")",
",",
"urlStr",
",",
"relativeUrlStr",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"boolean",
"quote",
"=",
"urlString",
"!=",
"urlStr",
";",
"String",
"rewrittenUrl",
";",
"if",
"(",
"formatter",
".",
"isRewriteUrl",
"(",
"urlStr",
")",
")",
"{",
"URL",
"relativeUrl",
"=",
"new",
"URL",
"(",
"relativeUrlStr",
")",
";",
"relativeUrl",
"=",
"new",
"URL",
"(",
"relativeUrl",
",",
"urlStr",
")",
";",
"rewrittenUrl",
"=",
"relativeUrl",
".",
"getPath",
"(",
")",
";",
"rewrittenUrl",
"=",
"quote",
"?",
"urlString",
".",
"charAt",
"(",
"0",
")",
"+",
"rewrittenUrl",
"+",
"urlString",
".",
"charAt",
"(",
"0",
")",
":",
"rewrittenUrl",
";",
"}",
"else",
"{",
"rewrittenUrl",
"=",
"urlString",
";",
"}",
"formatter",
".",
"append",
"(",
"\"url(\"",
")",
".",
"append",
"(",
"rewrittenUrl",
")",
".",
"append",
"(",
"'",
"'",
")",
";",
"return",
";",
"}",
"ByteArrayOutputStream",
"buffer",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"int",
"count",
";",
"byte",
"[",
"]",
"data",
"=",
"new",
"byte",
"[",
"16384",
"]",
";",
"while",
"(",
"(",
"count",
"=",
"input",
".",
"read",
"(",
"data",
",",
"0",
",",
"data",
".",
"length",
")",
")",
">",
"0",
")",
"{",
"buffer",
".",
"write",
"(",
"data",
",",
"0",
",",
"count",
")",
";",
"}",
"input",
".",
"close",
"(",
")",
";",
"byte",
"[",
"]",
"bytes",
"=",
"buffer",
".",
"toByteArray",
"(",
")",
";",
"if",
"(",
"bytes",
".",
"length",
">=",
"32",
"*",
"1024",
")",
"{",
"formatter",
".",
"append",
"(",
"\"url(\"",
")",
".",
"append",
"(",
"urlString",
")",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"else",
"{",
"dataUri",
"(",
"formatter",
",",
"bytes",
",",
"urlStr",
",",
"type",
")",
";",
"}",
"}"
] | Implementation of the function data-uri.
@param formatter current formatter
@param relativeUrlStr relative URL of the less script. Is used as base URL
@param urlString the url parameter of the function
@param type the mime type
@throws IOException If any I/O errors occur on reading the content | [
"Implementation",
"of",
"the",
"function",
"data",
"-",
"uri",
"."
] | train | https://github.com/i-net-software/jlessc/blob/15b13e1637f6cc2e4d72df021e23ee0ca8d5e629/src/com/inet/lib/less/UrlUtils.java#L171-L207 |
OpenLiberty/open-liberty | dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/InvalidationAuditDaemon.java | InvalidationAuditDaemon.filterExternalCacheFragment | public ExternalInvalidation filterExternalCacheFragment(String cacheName, ExternalInvalidation externalCacheFragment) {
"""
This ensures that the specified ExternalCacheFragment has not
been invalidated.
@param externalCacheFragment The unfiltered ExternalCacheFragment.
@return The filtered ExternalCacheFragment.
"""
InvalidationTableList invalidationTableList = getInvalidationTableList(cacheName);
try {
invalidationTableList.readWriteLock.readLock().lock();
return internalFilterExternalCacheFragment(cacheName, invalidationTableList, externalCacheFragment);
} finally {
invalidationTableList.readWriteLock.readLock().unlock();
}
} | java | public ExternalInvalidation filterExternalCacheFragment(String cacheName, ExternalInvalidation externalCacheFragment) {
InvalidationTableList invalidationTableList = getInvalidationTableList(cacheName);
try {
invalidationTableList.readWriteLock.readLock().lock();
return internalFilterExternalCacheFragment(cacheName, invalidationTableList, externalCacheFragment);
} finally {
invalidationTableList.readWriteLock.readLock().unlock();
}
} | [
"public",
"ExternalInvalidation",
"filterExternalCacheFragment",
"(",
"String",
"cacheName",
",",
"ExternalInvalidation",
"externalCacheFragment",
")",
"{",
"InvalidationTableList",
"invalidationTableList",
"=",
"getInvalidationTableList",
"(",
"cacheName",
")",
";",
"try",
"{",
"invalidationTableList",
".",
"readWriteLock",
".",
"readLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"return",
"internalFilterExternalCacheFragment",
"(",
"cacheName",
",",
"invalidationTableList",
",",
"externalCacheFragment",
")",
";",
"}",
"finally",
"{",
"invalidationTableList",
".",
"readWriteLock",
".",
"readLock",
"(",
")",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] | This ensures that the specified ExternalCacheFragment has not
been invalidated.
@param externalCacheFragment The unfiltered ExternalCacheFragment.
@return The filtered ExternalCacheFragment. | [
"This",
"ensures",
"that",
"the",
"specified",
"ExternalCacheFragment",
"has",
"not",
"been",
"invalidated",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/InvalidationAuditDaemon.java#L256-L264 |
UrielCh/ovh-java-sdk | ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java | ApiOvhMe.telephony_settings_GET | public OvhSettings telephony_settings_GET() throws IOException {
"""
Get the telephony settings linked to the customer account
REST: GET /me/telephony/settings
"""
String qPath = "/me/telephony/settings";
StringBuilder sb = path(qPath);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhSettings.class);
} | java | public OvhSettings telephony_settings_GET() throws IOException {
String qPath = "/me/telephony/settings";
StringBuilder sb = path(qPath);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhSettings.class);
} | [
"public",
"OvhSettings",
"telephony_settings_GET",
"(",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/me/telephony/settings\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhSettings",
".",
"class",
")",
";",
"}"
] | Get the telephony settings linked to the customer account
REST: GET /me/telephony/settings | [
"Get",
"the",
"telephony",
"settings",
"linked",
"to",
"the",
"customer",
"account"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java#L1801-L1806 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/compression/CompressedDataBuffer.java | CompressedDataBuffer.readUnknown | public static DataBuffer readUnknown(DataInputStream s, AllocationMode allocMode, long length, DataType type) {
"""
Drop-in replacement wrapper for BaseDataBuffer.read() method, aware of CompressedDataBuffer
@param s
@return
"""
// if buffer is uncompressed, it'll be valid buffer, so we'll just return it
if (type != DataType.COMPRESSED) {
DataBuffer buffer = Nd4j.createBuffer(type, length, false);
buffer.read(s, allocMode, length, type);
return buffer;
} else {
try {
// if buffer is compressed one, we''ll restore it here
String compressionAlgorithm = s.readUTF();
long compressedLength = s.readLong();
long originalLength = s.readLong();
long numberOfElements = s.readLong();
DataType originalType = DataType.values()[s.readInt()];
byte[] temp = new byte[(int) compressedLength];
for (int i = 0; i < compressedLength; i++) {
temp[i] = s.readByte();
}
Pointer pointer = new BytePointer(temp);
CompressionDescriptor descriptor = new CompressionDescriptor();
descriptor.setCompressedLength(compressedLength);
descriptor.setCompressionAlgorithm(compressionAlgorithm);
descriptor.setOriginalLength(originalLength);
descriptor.setNumberOfElements(numberOfElements);
descriptor.setOriginalDataType(originalType);
return new CompressedDataBuffer(pointer, descriptor);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
} | java | public static DataBuffer readUnknown(DataInputStream s, AllocationMode allocMode, long length, DataType type) {
// if buffer is uncompressed, it'll be valid buffer, so we'll just return it
if (type != DataType.COMPRESSED) {
DataBuffer buffer = Nd4j.createBuffer(type, length, false);
buffer.read(s, allocMode, length, type);
return buffer;
} else {
try {
// if buffer is compressed one, we''ll restore it here
String compressionAlgorithm = s.readUTF();
long compressedLength = s.readLong();
long originalLength = s.readLong();
long numberOfElements = s.readLong();
DataType originalType = DataType.values()[s.readInt()];
byte[] temp = new byte[(int) compressedLength];
for (int i = 0; i < compressedLength; i++) {
temp[i] = s.readByte();
}
Pointer pointer = new BytePointer(temp);
CompressionDescriptor descriptor = new CompressionDescriptor();
descriptor.setCompressedLength(compressedLength);
descriptor.setCompressionAlgorithm(compressionAlgorithm);
descriptor.setOriginalLength(originalLength);
descriptor.setNumberOfElements(numberOfElements);
descriptor.setOriginalDataType(originalType);
return new CompressedDataBuffer(pointer, descriptor);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
} | [
"public",
"static",
"DataBuffer",
"readUnknown",
"(",
"DataInputStream",
"s",
",",
"AllocationMode",
"allocMode",
",",
"long",
"length",
",",
"DataType",
"type",
")",
"{",
"// if buffer is uncompressed, it'll be valid buffer, so we'll just return it",
"if",
"(",
"type",
"!=",
"DataType",
".",
"COMPRESSED",
")",
"{",
"DataBuffer",
"buffer",
"=",
"Nd4j",
".",
"createBuffer",
"(",
"type",
",",
"length",
",",
"false",
")",
";",
"buffer",
".",
"read",
"(",
"s",
",",
"allocMode",
",",
"length",
",",
"type",
")",
";",
"return",
"buffer",
";",
"}",
"else",
"{",
"try",
"{",
"// if buffer is compressed one, we''ll restore it here",
"String",
"compressionAlgorithm",
"=",
"s",
".",
"readUTF",
"(",
")",
";",
"long",
"compressedLength",
"=",
"s",
".",
"readLong",
"(",
")",
";",
"long",
"originalLength",
"=",
"s",
".",
"readLong",
"(",
")",
";",
"long",
"numberOfElements",
"=",
"s",
".",
"readLong",
"(",
")",
";",
"DataType",
"originalType",
"=",
"DataType",
".",
"values",
"(",
")",
"[",
"s",
".",
"readInt",
"(",
")",
"]",
";",
"byte",
"[",
"]",
"temp",
"=",
"new",
"byte",
"[",
"(",
"int",
")",
"compressedLength",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"compressedLength",
";",
"i",
"++",
")",
"{",
"temp",
"[",
"i",
"]",
"=",
"s",
".",
"readByte",
"(",
")",
";",
"}",
"Pointer",
"pointer",
"=",
"new",
"BytePointer",
"(",
"temp",
")",
";",
"CompressionDescriptor",
"descriptor",
"=",
"new",
"CompressionDescriptor",
"(",
")",
";",
"descriptor",
".",
"setCompressedLength",
"(",
"compressedLength",
")",
";",
"descriptor",
".",
"setCompressionAlgorithm",
"(",
"compressionAlgorithm",
")",
";",
"descriptor",
".",
"setOriginalLength",
"(",
"originalLength",
")",
";",
"descriptor",
".",
"setNumberOfElements",
"(",
"numberOfElements",
")",
";",
"descriptor",
".",
"setOriginalDataType",
"(",
"originalType",
")",
";",
"return",
"new",
"CompressedDataBuffer",
"(",
"pointer",
",",
"descriptor",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"}"
] | Drop-in replacement wrapper for BaseDataBuffer.read() method, aware of CompressedDataBuffer
@param s
@return | [
"Drop",
"-",
"in",
"replacement",
"wrapper",
"for",
"BaseDataBuffer",
".",
"read",
"()",
"method",
"aware",
"of",
"CompressedDataBuffer"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/compression/CompressedDataBuffer.java#L97-L129 |
JetBrains/xodus | openAPI/src/main/java/jetbrains/exodus/env/EnvironmentConfig.java | EnvironmentConfig.setGcStartIn | public EnvironmentConfig setGcStartIn(final int startInMillis) throws InvalidSettingException {
"""
Sets the number of milliseconds which the database garbage collector is postponed for after the
{@linkplain Environment} is created. Default value is {@code 10000}.
<p>Mutable at runtime: no
@param startInMillis number of milliseconds which the database garbage collector should be postponed for after the
{@linkplain Environment} is created
@return this {@code EnvironmentConfig} instance
@throws InvalidSettingException {@code startInMillis} is negative
"""
if (startInMillis < 0) {
throw new InvalidSettingException("GC can't be postponed for that number of milliseconds: " + startInMillis);
}
return setSetting(GC_START_IN, startInMillis);
} | java | public EnvironmentConfig setGcStartIn(final int startInMillis) throws InvalidSettingException {
if (startInMillis < 0) {
throw new InvalidSettingException("GC can't be postponed for that number of milliseconds: " + startInMillis);
}
return setSetting(GC_START_IN, startInMillis);
} | [
"public",
"EnvironmentConfig",
"setGcStartIn",
"(",
"final",
"int",
"startInMillis",
")",
"throws",
"InvalidSettingException",
"{",
"if",
"(",
"startInMillis",
"<",
"0",
")",
"{",
"throw",
"new",
"InvalidSettingException",
"(",
"\"GC can't be postponed for that number of milliseconds: \"",
"+",
"startInMillis",
")",
";",
"}",
"return",
"setSetting",
"(",
"GC_START_IN",
",",
"startInMillis",
")",
";",
"}"
] | Sets the number of milliseconds which the database garbage collector is postponed for after the
{@linkplain Environment} is created. Default value is {@code 10000}.
<p>Mutable at runtime: no
@param startInMillis number of milliseconds which the database garbage collector should be postponed for after the
{@linkplain Environment} is created
@return this {@code EnvironmentConfig} instance
@throws InvalidSettingException {@code startInMillis} is negative | [
"Sets",
"the",
"number",
"of",
"milliseconds",
"which",
"the",
"database",
"garbage",
"collector",
"is",
"postponed",
"for",
"after",
"the",
"{",
"@linkplain",
"Environment",
"}",
"is",
"created",
".",
"Default",
"value",
"is",
"{",
"@code",
"10000",
"}",
".",
"<p",
">",
"Mutable",
"at",
"runtime",
":",
"no"
] | train | https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/openAPI/src/main/java/jetbrains/exodus/env/EnvironmentConfig.java#L1822-L1827 |
maxirosson/jdroid-android | jdroid-android-google-inappbilling/src/main/java/com/jdroid/android/google/inappbilling/client/utils/Security.java | Security.verify | public static boolean verify(PublicKey publicKey, String signedData, String signature) {
"""
Verifies that the signature from the server matches the computed signature on the data.
Returns true if the data is correctly signed.
@param publicKey public key associated with the developer account
@param signedData signed data from server
@param signature server signature
@return true if the data and signature match
"""
byte[] signatureBytes;
try {
signatureBytes = Base64.decode(signature, Base64.DEFAULT);
} catch (IllegalArgumentException e) {
LOGGER.error("Base64 decoding failed.");
return false;
}
try {
Signature sig = Signature.getInstance(SIGNATURE_ALGORITHM);
sig.initVerify(publicKey);
sig.update(signedData.getBytes());
if (!sig.verify(signatureBytes)) {
LOGGER.error("Signature verification failed.");
return false;
}
return true;
} catch (NoSuchAlgorithmException e) {
LOGGER.error("NoSuchAlgorithmException.");
} catch (InvalidKeyException e) {
LOGGER.error("Invalid key specification.");
} catch (SignatureException e) {
LOGGER.error("Signature exception.");
}
return false;
} | java | public static boolean verify(PublicKey publicKey, String signedData, String signature) {
byte[] signatureBytes;
try {
signatureBytes = Base64.decode(signature, Base64.DEFAULT);
} catch (IllegalArgumentException e) {
LOGGER.error("Base64 decoding failed.");
return false;
}
try {
Signature sig = Signature.getInstance(SIGNATURE_ALGORITHM);
sig.initVerify(publicKey);
sig.update(signedData.getBytes());
if (!sig.verify(signatureBytes)) {
LOGGER.error("Signature verification failed.");
return false;
}
return true;
} catch (NoSuchAlgorithmException e) {
LOGGER.error("NoSuchAlgorithmException.");
} catch (InvalidKeyException e) {
LOGGER.error("Invalid key specification.");
} catch (SignatureException e) {
LOGGER.error("Signature exception.");
}
return false;
} | [
"public",
"static",
"boolean",
"verify",
"(",
"PublicKey",
"publicKey",
",",
"String",
"signedData",
",",
"String",
"signature",
")",
"{",
"byte",
"[",
"]",
"signatureBytes",
";",
"try",
"{",
"signatureBytes",
"=",
"Base64",
".",
"decode",
"(",
"signature",
",",
"Base64",
".",
"DEFAULT",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"Base64 decoding failed.\"",
")",
";",
"return",
"false",
";",
"}",
"try",
"{",
"Signature",
"sig",
"=",
"Signature",
".",
"getInstance",
"(",
"SIGNATURE_ALGORITHM",
")",
";",
"sig",
".",
"initVerify",
"(",
"publicKey",
")",
";",
"sig",
".",
"update",
"(",
"signedData",
".",
"getBytes",
"(",
")",
")",
";",
"if",
"(",
"!",
"sig",
".",
"verify",
"(",
"signatureBytes",
")",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"Signature verification failed.\"",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
"catch",
"(",
"NoSuchAlgorithmException",
"e",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"NoSuchAlgorithmException.\"",
")",
";",
"}",
"catch",
"(",
"InvalidKeyException",
"e",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"Invalid key specification.\"",
")",
";",
"}",
"catch",
"(",
"SignatureException",
"e",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"Signature exception.\"",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Verifies that the signature from the server matches the computed signature on the data.
Returns true if the data is correctly signed.
@param publicKey public key associated with the developer account
@param signedData signed data from server
@param signature server signature
@return true if the data and signature match | [
"Verifies",
"that",
"the",
"signature",
"from",
"the",
"server",
"matches",
"the",
"computed",
"signature",
"on",
"the",
"data",
".",
"Returns",
"true",
"if",
"the",
"data",
"is",
"correctly",
"signed",
"."
] | train | https://github.com/maxirosson/jdroid-android/blob/1ba9cae56a16fa36bdb2c9c04379853f0300707f/jdroid-android-google-inappbilling/src/main/java/com/jdroid/android/google/inappbilling/client/utils/Security.java#L89-L114 |
classgraph/classgraph | src/main/java/io/github/classgraph/ModuleReaderProxy.java | ModuleReaderProxy.openOrRead | private Object openOrRead(final String path, final boolean open) throws SecurityException {
"""
Use the proxied ModuleReader to open the named resource as an InputStream.
@param path
The path to the resource to open.
@param open
if true, call moduleReader.open(name).get() (returning an InputStream), otherwise call
moduleReader.read(name).get() (returning a ByteBuffer).
@return An {@link InputStream} for the content of the resource.
@throws SecurityException
If the module cannot be accessed.
"""
final String methodName = open ? "open" : "read";
final Object /* Optional<InputStream> */ optionalInputStream = ReflectionUtils.invokeMethod(moduleReader,
methodName, String.class, path, /* throwException = */ true);
if (optionalInputStream == null) {
throw new IllegalArgumentException("Got null result from moduleReader." + methodName + "(name)");
}
final Object /* InputStream */ inputStream = ReflectionUtils.invokeMethod(optionalInputStream, "get",
/* throwException = */ true);
if (inputStream == null) {
throw new IllegalArgumentException("Got null result from moduleReader." + methodName + "(name).get()");
}
return inputStream;
} | java | private Object openOrRead(final String path, final boolean open) throws SecurityException {
final String methodName = open ? "open" : "read";
final Object /* Optional<InputStream> */ optionalInputStream = ReflectionUtils.invokeMethod(moduleReader,
methodName, String.class, path, /* throwException = */ true);
if (optionalInputStream == null) {
throw new IllegalArgumentException("Got null result from moduleReader." + methodName + "(name)");
}
final Object /* InputStream */ inputStream = ReflectionUtils.invokeMethod(optionalInputStream, "get",
/* throwException = */ true);
if (inputStream == null) {
throw new IllegalArgumentException("Got null result from moduleReader." + methodName + "(name).get()");
}
return inputStream;
} | [
"private",
"Object",
"openOrRead",
"(",
"final",
"String",
"path",
",",
"final",
"boolean",
"open",
")",
"throws",
"SecurityException",
"{",
"final",
"String",
"methodName",
"=",
"open",
"?",
"\"open\"",
":",
"\"read\"",
";",
"final",
"Object",
"/* Optional<InputStream> */",
"optionalInputStream",
"=",
"ReflectionUtils",
".",
"invokeMethod",
"(",
"moduleReader",
",",
"methodName",
",",
"String",
".",
"class",
",",
"path",
",",
"/* throwException = */",
"true",
")",
";",
"if",
"(",
"optionalInputStream",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Got null result from moduleReader.\"",
"+",
"methodName",
"+",
"\"(name)\"",
")",
";",
"}",
"final",
"Object",
"/* InputStream */",
"inputStream",
"=",
"ReflectionUtils",
".",
"invokeMethod",
"(",
"optionalInputStream",
",",
"\"get\"",
",",
"/* throwException = */",
"true",
")",
";",
"if",
"(",
"inputStream",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Got null result from moduleReader.\"",
"+",
"methodName",
"+",
"\"(name).get()\"",
")",
";",
"}",
"return",
"inputStream",
";",
"}"
] | Use the proxied ModuleReader to open the named resource as an InputStream.
@param path
The path to the resource to open.
@param open
if true, call moduleReader.open(name).get() (returning an InputStream), otherwise call
moduleReader.read(name).get() (returning a ByteBuffer).
@return An {@link InputStream} for the content of the resource.
@throws SecurityException
If the module cannot be accessed. | [
"Use",
"the",
"proxied",
"ModuleReader",
"to",
"open",
"the",
"named",
"resource",
"as",
"an",
"InputStream",
"."
] | train | https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ModuleReaderProxy.java#L134-L147 |
jferard/fastods | fastods/src/main/java/com/github/jferard/fastods/odselement/StylesContainer.java | StylesContainer.addChildCellStyle | public TableCellStyle addChildCellStyle(final TableCellStyle style, final DataStyle dataStyle) {
"""
Add a child style that mixes the cell style with a data style to the container
@param style the cell style
@param dataStyle the data style
@return the mixed cell style
"""
final ChildCellStyle childKey = new ChildCellStyle(style, dataStyle);
TableCellStyle anonymousStyle = this.anonymousStyleByChildCellStyle.get(childKey);
if (anonymousStyle == null) {
this.addDataStyle(dataStyle);
if (!style.hasParent()) { // here, the style may already be a child style
this.addContentFontFaceContainerStyle(style);
}
final String name = style.getRealName() + "-_-" + dataStyle.getName();
final TableCellStyleBuilder anonymousStyleBuilder = TableCellStyle.builder(name)
.parentCellStyle(style).dataStyle(dataStyle);
if (dataStyle.isHidden()) {
anonymousStyleBuilder.hidden();
}
anonymousStyle = anonymousStyleBuilder.build();
this.addContentFontFaceContainerStyle(anonymousStyle);
this.anonymousStyleByChildCellStyle.put(childKey, anonymousStyle);
}
return anonymousStyle;
} | java | public TableCellStyle addChildCellStyle(final TableCellStyle style, final DataStyle dataStyle) {
final ChildCellStyle childKey = new ChildCellStyle(style, dataStyle);
TableCellStyle anonymousStyle = this.anonymousStyleByChildCellStyle.get(childKey);
if (anonymousStyle == null) {
this.addDataStyle(dataStyle);
if (!style.hasParent()) { // here, the style may already be a child style
this.addContentFontFaceContainerStyle(style);
}
final String name = style.getRealName() + "-_-" + dataStyle.getName();
final TableCellStyleBuilder anonymousStyleBuilder = TableCellStyle.builder(name)
.parentCellStyle(style).dataStyle(dataStyle);
if (dataStyle.isHidden()) {
anonymousStyleBuilder.hidden();
}
anonymousStyle = anonymousStyleBuilder.build();
this.addContentFontFaceContainerStyle(anonymousStyle);
this.anonymousStyleByChildCellStyle.put(childKey, anonymousStyle);
}
return anonymousStyle;
} | [
"public",
"TableCellStyle",
"addChildCellStyle",
"(",
"final",
"TableCellStyle",
"style",
",",
"final",
"DataStyle",
"dataStyle",
")",
"{",
"final",
"ChildCellStyle",
"childKey",
"=",
"new",
"ChildCellStyle",
"(",
"style",
",",
"dataStyle",
")",
";",
"TableCellStyle",
"anonymousStyle",
"=",
"this",
".",
"anonymousStyleByChildCellStyle",
".",
"get",
"(",
"childKey",
")",
";",
"if",
"(",
"anonymousStyle",
"==",
"null",
")",
"{",
"this",
".",
"addDataStyle",
"(",
"dataStyle",
")",
";",
"if",
"(",
"!",
"style",
".",
"hasParent",
"(",
")",
")",
"{",
"// here, the style may already be a child style",
"this",
".",
"addContentFontFaceContainerStyle",
"(",
"style",
")",
";",
"}",
"final",
"String",
"name",
"=",
"style",
".",
"getRealName",
"(",
")",
"+",
"\"-_-\"",
"+",
"dataStyle",
".",
"getName",
"(",
")",
";",
"final",
"TableCellStyleBuilder",
"anonymousStyleBuilder",
"=",
"TableCellStyle",
".",
"builder",
"(",
"name",
")",
".",
"parentCellStyle",
"(",
"style",
")",
".",
"dataStyle",
"(",
"dataStyle",
")",
";",
"if",
"(",
"dataStyle",
".",
"isHidden",
"(",
")",
")",
"{",
"anonymousStyleBuilder",
".",
"hidden",
"(",
")",
";",
"}",
"anonymousStyle",
"=",
"anonymousStyleBuilder",
".",
"build",
"(",
")",
";",
"this",
".",
"addContentFontFaceContainerStyle",
"(",
"anonymousStyle",
")",
";",
"this",
".",
"anonymousStyleByChildCellStyle",
".",
"put",
"(",
"childKey",
",",
"anonymousStyle",
")",
";",
"}",
"return",
"anonymousStyle",
";",
"}"
] | Add a child style that mixes the cell style with a data style to the container
@param style the cell style
@param dataStyle the data style
@return the mixed cell style | [
"Add",
"a",
"child",
"style",
"that",
"mixes",
"the",
"cell",
"style",
"with",
"a",
"data",
"style",
"to",
"the",
"container"
] | train | https://github.com/jferard/fastods/blob/a034d173083ffa602dc525699b97f753082eaef9/fastods/src/main/java/com/github/jferard/fastods/odselement/StylesContainer.java#L124-L143 |
JoeKerouac/utils | src/main/java/com/joe/utils/secure/impl/SymmetryCipher.java | SymmetryCipher.buildInstance | public static CipherUtil buildInstance(Algorithms algorithms, byte[] keySpec) {
"""
SymmetryCipher构造器
@param algorithms 算法
@param keySpec keySpec
@return CipherUtil
"""
SecretKey key = KeyTools.buildKey(algorithms, keySpec);
return new SymmetryCipher(algorithms, key);
} | java | public static CipherUtil buildInstance(Algorithms algorithms, byte[] keySpec) {
SecretKey key = KeyTools.buildKey(algorithms, keySpec);
return new SymmetryCipher(algorithms, key);
} | [
"public",
"static",
"CipherUtil",
"buildInstance",
"(",
"Algorithms",
"algorithms",
",",
"byte",
"[",
"]",
"keySpec",
")",
"{",
"SecretKey",
"key",
"=",
"KeyTools",
".",
"buildKey",
"(",
"algorithms",
",",
"keySpec",
")",
";",
"return",
"new",
"SymmetryCipher",
"(",
"algorithms",
",",
"key",
")",
";",
"}"
] | SymmetryCipher构造器
@param algorithms 算法
@param keySpec keySpec
@return CipherUtil | [
"SymmetryCipher构造器"
] | train | https://github.com/JoeKerouac/utils/blob/45e1b2dc4d736956674fc4dcbe6cf84eaee69278/src/main/java/com/joe/utils/secure/impl/SymmetryCipher.java#L84-L87 |
apache/groovy | src/main/java/org/codehaus/groovy/ast/tools/WideningCategories.java | WideningCategories.lowestUpperBound | public static ClassNode lowestUpperBound(ClassNode a, ClassNode b) {
"""
Given two class nodes, returns the first common supertype, or the class itself
if there are equal. For example, Double and Float would return Number, while
Set and String would return Object.
This method is not guaranteed to return a class node which corresponds to a
real type. For example, if two types have more than one interface in common
and are not in the same hierarchy branch, then the returned type will be a
virtual type implementing all those interfaces.
Calls to this method are supposed to be made with resolved generics. This means
that you can have wildcards, but no placeholder.
@param a first class node
@param b second class node
@return first common supertype
"""
ClassNode lub = lowestUpperBound(a, b, null, null);
if (lub==null || !lub.isUsingGenerics()) return lub;
// types may be parameterized. If so, we must ensure that generic type arguments
// are made compatible
if (lub instanceof LowestUpperBoundClassNode) {
// no parent super class representing both types could be found
// or both class nodes implement common interfaces which may have
// been parameterized differently.
// We must create a classnode for which the "superclass" is potentially parameterized
// plus the interfaces
ClassNode superClass = lub.getSuperClass();
ClassNode psc = superClass.isUsingGenerics()?parameterizeLowestUpperBound(superClass, a, b, lub):superClass;
ClassNode[] interfaces = lub.getInterfaces();
ClassNode[] pinterfaces = new ClassNode[interfaces.length];
for (int i = 0, interfacesLength = interfaces.length; i < interfacesLength; i++) {
final ClassNode icn = interfaces[i];
if (icn.isUsingGenerics()) {
pinterfaces[i] = parameterizeLowestUpperBound(icn, a, b, lub);
} else {
pinterfaces[i] = icn;
}
}
return new LowestUpperBoundClassNode(((LowestUpperBoundClassNode)lub).name, psc, pinterfaces);
} else {
return parameterizeLowestUpperBound(lub, a, b, lub);
}
} | java | public static ClassNode lowestUpperBound(ClassNode a, ClassNode b) {
ClassNode lub = lowestUpperBound(a, b, null, null);
if (lub==null || !lub.isUsingGenerics()) return lub;
// types may be parameterized. If so, we must ensure that generic type arguments
// are made compatible
if (lub instanceof LowestUpperBoundClassNode) {
// no parent super class representing both types could be found
// or both class nodes implement common interfaces which may have
// been parameterized differently.
// We must create a classnode for which the "superclass" is potentially parameterized
// plus the interfaces
ClassNode superClass = lub.getSuperClass();
ClassNode psc = superClass.isUsingGenerics()?parameterizeLowestUpperBound(superClass, a, b, lub):superClass;
ClassNode[] interfaces = lub.getInterfaces();
ClassNode[] pinterfaces = new ClassNode[interfaces.length];
for (int i = 0, interfacesLength = interfaces.length; i < interfacesLength; i++) {
final ClassNode icn = interfaces[i];
if (icn.isUsingGenerics()) {
pinterfaces[i] = parameterizeLowestUpperBound(icn, a, b, lub);
} else {
pinterfaces[i] = icn;
}
}
return new LowestUpperBoundClassNode(((LowestUpperBoundClassNode)lub).name, psc, pinterfaces);
} else {
return parameterizeLowestUpperBound(lub, a, b, lub);
}
} | [
"public",
"static",
"ClassNode",
"lowestUpperBound",
"(",
"ClassNode",
"a",
",",
"ClassNode",
"b",
")",
"{",
"ClassNode",
"lub",
"=",
"lowestUpperBound",
"(",
"a",
",",
"b",
",",
"null",
",",
"null",
")",
";",
"if",
"(",
"lub",
"==",
"null",
"||",
"!",
"lub",
".",
"isUsingGenerics",
"(",
")",
")",
"return",
"lub",
";",
"// types may be parameterized. If so, we must ensure that generic type arguments",
"// are made compatible",
"if",
"(",
"lub",
"instanceof",
"LowestUpperBoundClassNode",
")",
"{",
"// no parent super class representing both types could be found",
"// or both class nodes implement common interfaces which may have",
"// been parameterized differently.",
"// We must create a classnode for which the \"superclass\" is potentially parameterized",
"// plus the interfaces",
"ClassNode",
"superClass",
"=",
"lub",
".",
"getSuperClass",
"(",
")",
";",
"ClassNode",
"psc",
"=",
"superClass",
".",
"isUsingGenerics",
"(",
")",
"?",
"parameterizeLowestUpperBound",
"(",
"superClass",
",",
"a",
",",
"b",
",",
"lub",
")",
":",
"superClass",
";",
"ClassNode",
"[",
"]",
"interfaces",
"=",
"lub",
".",
"getInterfaces",
"(",
")",
";",
"ClassNode",
"[",
"]",
"pinterfaces",
"=",
"new",
"ClassNode",
"[",
"interfaces",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"interfacesLength",
"=",
"interfaces",
".",
"length",
";",
"i",
"<",
"interfacesLength",
";",
"i",
"++",
")",
"{",
"final",
"ClassNode",
"icn",
"=",
"interfaces",
"[",
"i",
"]",
";",
"if",
"(",
"icn",
".",
"isUsingGenerics",
"(",
")",
")",
"{",
"pinterfaces",
"[",
"i",
"]",
"=",
"parameterizeLowestUpperBound",
"(",
"icn",
",",
"a",
",",
"b",
",",
"lub",
")",
";",
"}",
"else",
"{",
"pinterfaces",
"[",
"i",
"]",
"=",
"icn",
";",
"}",
"}",
"return",
"new",
"LowestUpperBoundClassNode",
"(",
"(",
"(",
"LowestUpperBoundClassNode",
")",
"lub",
")",
".",
"name",
",",
"psc",
",",
"pinterfaces",
")",
";",
"}",
"else",
"{",
"return",
"parameterizeLowestUpperBound",
"(",
"lub",
",",
"a",
",",
"b",
",",
"lub",
")",
";",
"}",
"}"
] | Given two class nodes, returns the first common supertype, or the class itself
if there are equal. For example, Double and Float would return Number, while
Set and String would return Object.
This method is not guaranteed to return a class node which corresponds to a
real type. For example, if two types have more than one interface in common
and are not in the same hierarchy branch, then the returned type will be a
virtual type implementing all those interfaces.
Calls to this method are supposed to be made with resolved generics. This means
that you can have wildcards, but no placeholder.
@param a first class node
@param b second class node
@return first common supertype | [
"Given",
"two",
"class",
"nodes",
"returns",
"the",
"first",
"common",
"supertype",
"or",
"the",
"class",
"itself",
"if",
"there",
"are",
"equal",
".",
"For",
"example",
"Double",
"and",
"Float",
"would",
"return",
"Number",
"while",
"Set",
"and",
"String",
"would",
"return",
"Object",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/ast/tools/WideningCategories.java#L209-L240 |
mikepenz/FastAdapter | app/src/main/java/com/mikepenz/fastadapter/app/items/ImageItem.java | ImageItem.animateHeart | public void animateHeart(View imageLovedOn, View imageLovedOff, boolean on) {
"""
helper method to animate the heart view
@param imageLovedOn
@param imageLovedOff
@param on
"""
imageLovedOn.setVisibility(View.VISIBLE);
imageLovedOff.setVisibility(View.VISIBLE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
viewPropertyStartCompat(imageLovedOff.animate().scaleX(on ? 0 : 1).scaleY(on ? 0 : 1).alpha(on ? 0 : 1));
viewPropertyStartCompat(imageLovedOn.animate().scaleX(on ? 1 : 0).scaleY(on ? 1 : 0).alpha(on ? 1 : 0));
}
} | java | public void animateHeart(View imageLovedOn, View imageLovedOff, boolean on) {
imageLovedOn.setVisibility(View.VISIBLE);
imageLovedOff.setVisibility(View.VISIBLE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
viewPropertyStartCompat(imageLovedOff.animate().scaleX(on ? 0 : 1).scaleY(on ? 0 : 1).alpha(on ? 0 : 1));
viewPropertyStartCompat(imageLovedOn.animate().scaleX(on ? 1 : 0).scaleY(on ? 1 : 0).alpha(on ? 1 : 0));
}
} | [
"public",
"void",
"animateHeart",
"(",
"View",
"imageLovedOn",
",",
"View",
"imageLovedOff",
",",
"boolean",
"on",
")",
"{",
"imageLovedOn",
".",
"setVisibility",
"(",
"View",
".",
"VISIBLE",
")",
";",
"imageLovedOff",
".",
"setVisibility",
"(",
"View",
".",
"VISIBLE",
")",
";",
"if",
"(",
"Build",
".",
"VERSION",
".",
"SDK_INT",
">=",
"Build",
".",
"VERSION_CODES",
".",
"HONEYCOMB_MR1",
")",
"{",
"viewPropertyStartCompat",
"(",
"imageLovedOff",
".",
"animate",
"(",
")",
".",
"scaleX",
"(",
"on",
"?",
"0",
":",
"1",
")",
".",
"scaleY",
"(",
"on",
"?",
"0",
":",
"1",
")",
".",
"alpha",
"(",
"on",
"?",
"0",
":",
"1",
")",
")",
";",
"viewPropertyStartCompat",
"(",
"imageLovedOn",
".",
"animate",
"(",
")",
".",
"scaleX",
"(",
"on",
"?",
"1",
":",
"0",
")",
".",
"scaleY",
"(",
"on",
"?",
"1",
":",
"0",
")",
".",
"alpha",
"(",
"on",
"?",
"1",
":",
"0",
")",
")",
";",
"}",
"}"
] | helper method to animate the heart view
@param imageLovedOn
@param imageLovedOff
@param on | [
"helper",
"method",
"to",
"animate",
"the",
"heart",
"view"
] | train | https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/app/src/main/java/com/mikepenz/fastadapter/app/items/ImageItem.java#L136-L144 |
BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/builder/ExpressionBuilder.java | ExpressionBuilder.notEquals | public ExpressionBuilder notEquals(final SubordinateTrigger trigger, final Object compare) {
"""
Appends a not equals test to the condition.
@param trigger the trigger field.
@param compare the value to use in the compare.
@return this ExpressionBuilder.
"""
BooleanExpression exp = new CompareExpression(CompareType.NOT_EQUAL, trigger, compare);
appendExpression(exp);
return this;
} | java | public ExpressionBuilder notEquals(final SubordinateTrigger trigger, final Object compare) {
BooleanExpression exp = new CompareExpression(CompareType.NOT_EQUAL, trigger, compare);
appendExpression(exp);
return this;
} | [
"public",
"ExpressionBuilder",
"notEquals",
"(",
"final",
"SubordinateTrigger",
"trigger",
",",
"final",
"Object",
"compare",
")",
"{",
"BooleanExpression",
"exp",
"=",
"new",
"CompareExpression",
"(",
"CompareType",
".",
"NOT_EQUAL",
",",
"trigger",
",",
"compare",
")",
";",
"appendExpression",
"(",
"exp",
")",
";",
"return",
"this",
";",
"}"
] | Appends a not equals test to the condition.
@param trigger the trigger field.
@param compare the value to use in the compare.
@return this ExpressionBuilder. | [
"Appends",
"a",
"not",
"equals",
"test",
"to",
"the",
"condition",
"."
] | train | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/subordinate/builder/ExpressionBuilder.java#L77-L82 |
galaxyproject/blend4j | src/main/java/com/github/jmchilton/blend4j/BaseClient.java | BaseClient.deleteResponse | protected ClientResponse deleteResponse(final WebResource webResource, final boolean checkResponse) {
"""
Gets the response for a DELETE request.
@param webResource The {@link WebResource} to send the request to.
@param checkResponse True if an exception should be thrown on failure, false otherwise.
@return The {@link ClientResponse} for this request.
@throws ResponseException If the response was not successful.
"""
final ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).delete(ClientResponse.class);
if(checkResponse) {
this.checkResponse(response);
}
return response;
} | java | protected ClientResponse deleteResponse(final WebResource webResource, final boolean checkResponse) {
final ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).delete(ClientResponse.class);
if(checkResponse) {
this.checkResponse(response);
}
return response;
} | [
"protected",
"ClientResponse",
"deleteResponse",
"(",
"final",
"WebResource",
"webResource",
",",
"final",
"boolean",
"checkResponse",
")",
"{",
"final",
"ClientResponse",
"response",
"=",
"webResource",
".",
"accept",
"(",
"MediaType",
".",
"APPLICATION_JSON",
")",
".",
"delete",
"(",
"ClientResponse",
".",
"class",
")",
";",
"if",
"(",
"checkResponse",
")",
"{",
"this",
".",
"checkResponse",
"(",
"response",
")",
";",
"}",
"return",
"response",
";",
"}"
] | Gets the response for a DELETE request.
@param webResource The {@link WebResource} to send the request to.
@param checkResponse True if an exception should be thrown on failure, false otherwise.
@return The {@link ClientResponse} for this request.
@throws ResponseException If the response was not successful. | [
"Gets",
"the",
"response",
"for",
"a",
"DELETE",
"request",
"."
] | train | https://github.com/galaxyproject/blend4j/blob/a2ec4e412be40013bb88a3a2cf2478abd19ce162/src/main/java/com/github/jmchilton/blend4j/BaseClient.java#L105-L111 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/shape/Shape.java | Shape.shapeEquals | public static boolean shapeEquals(int[] shape1, int[] shape2) {
"""
Returns whether 2 shapes are equals by checking for dimension semantics
as well as array equality
@param shape1 the first shape for comparison
@param shape2 the second shape for comparison
@return whether the shapes are equivalent
"""
if (isColumnVectorShape(shape1) && isColumnVectorShape(shape2)) {
return Arrays.equals(shape1, shape2);
}
if (isRowVectorShape(shape1) && isRowVectorShape(shape2)) {
int[] shape1Comp = squeeze(shape1);
int[] shape2Comp = squeeze(shape2);
return Arrays.equals(shape1Comp, shape2Comp);
}
//scalars
if(shape1.length == 0 || shape2.length == 0) {
if(shape1.length == 0 && shapeIsScalar(shape2)) {
return true;
}
if(shape2.length == 0 && shapeIsScalar(shape1)) {
return true;
}
}
shape1 = squeeze(shape1);
shape2 = squeeze(shape2);
return scalarEquals(shape1, shape2) || Arrays.equals(shape1, shape2);
} | java | public static boolean shapeEquals(int[] shape1, int[] shape2) {
if (isColumnVectorShape(shape1) && isColumnVectorShape(shape2)) {
return Arrays.equals(shape1, shape2);
}
if (isRowVectorShape(shape1) && isRowVectorShape(shape2)) {
int[] shape1Comp = squeeze(shape1);
int[] shape2Comp = squeeze(shape2);
return Arrays.equals(shape1Comp, shape2Comp);
}
//scalars
if(shape1.length == 0 || shape2.length == 0) {
if(shape1.length == 0 && shapeIsScalar(shape2)) {
return true;
}
if(shape2.length == 0 && shapeIsScalar(shape1)) {
return true;
}
}
shape1 = squeeze(shape1);
shape2 = squeeze(shape2);
return scalarEquals(shape1, shape2) || Arrays.equals(shape1, shape2);
} | [
"public",
"static",
"boolean",
"shapeEquals",
"(",
"int",
"[",
"]",
"shape1",
",",
"int",
"[",
"]",
"shape2",
")",
"{",
"if",
"(",
"isColumnVectorShape",
"(",
"shape1",
")",
"&&",
"isColumnVectorShape",
"(",
"shape2",
")",
")",
"{",
"return",
"Arrays",
".",
"equals",
"(",
"shape1",
",",
"shape2",
")",
";",
"}",
"if",
"(",
"isRowVectorShape",
"(",
"shape1",
")",
"&&",
"isRowVectorShape",
"(",
"shape2",
")",
")",
"{",
"int",
"[",
"]",
"shape1Comp",
"=",
"squeeze",
"(",
"shape1",
")",
";",
"int",
"[",
"]",
"shape2Comp",
"=",
"squeeze",
"(",
"shape2",
")",
";",
"return",
"Arrays",
".",
"equals",
"(",
"shape1Comp",
",",
"shape2Comp",
")",
";",
"}",
"//scalars",
"if",
"(",
"shape1",
".",
"length",
"==",
"0",
"||",
"shape2",
".",
"length",
"==",
"0",
")",
"{",
"if",
"(",
"shape1",
".",
"length",
"==",
"0",
"&&",
"shapeIsScalar",
"(",
"shape2",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"shape2",
".",
"length",
"==",
"0",
"&&",
"shapeIsScalar",
"(",
"shape1",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"shape1",
"=",
"squeeze",
"(",
"shape1",
")",
";",
"shape2",
"=",
"squeeze",
"(",
"shape2",
")",
";",
"return",
"scalarEquals",
"(",
"shape1",
",",
"shape2",
")",
"||",
"Arrays",
".",
"equals",
"(",
"shape1",
",",
"shape2",
")",
";",
"}"
] | Returns whether 2 shapes are equals by checking for dimension semantics
as well as array equality
@param shape1 the first shape for comparison
@param shape2 the second shape for comparison
@return whether the shapes are equivalent | [
"Returns",
"whether",
"2",
"shapes",
"are",
"equals",
"by",
"checking",
"for",
"dimension",
"semantics",
"as",
"well",
"as",
"array",
"equality"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/shape/Shape.java#L1494-L1521 |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/abst/geo/bundle/SceneStructureMetric.java | SceneStructureMetric.setCamera | public void setCamera(int which , boolean fixed , BundleAdjustmentCamera model ) {
"""
Specifies the camera model being used.
@param which Which camera is being specified
@param fixed If these parameters are constant or not
@param model The camera model
"""
cameras[which].known = fixed;
cameras[which].model = model;
} | java | public void setCamera(int which , boolean fixed , BundleAdjustmentCamera model ) {
cameras[which].known = fixed;
cameras[which].model = model;
} | [
"public",
"void",
"setCamera",
"(",
"int",
"which",
",",
"boolean",
"fixed",
",",
"BundleAdjustmentCamera",
"model",
")",
"{",
"cameras",
"[",
"which",
"]",
".",
"known",
"=",
"fixed",
";",
"cameras",
"[",
"which",
"]",
".",
"model",
"=",
"model",
";",
"}"
] | Specifies the camera model being used.
@param which Which camera is being specified
@param fixed If these parameters are constant or not
@param model The camera model | [
"Specifies",
"the",
"camera",
"model",
"being",
"used",
"."
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/abst/geo/bundle/SceneStructureMetric.java#L135-L138 |
mapbox/mapbox-java | services-turf/src/main/java/com/mapbox/turf/TurfAssertions.java | TurfAssertions.geojsonType | public static void geojsonType(GeoJson value, String type, String name) {
"""
Enforce expectations about types of GeoJson objects for Turf.
@param value any GeoJson object
@param type expected GeoJson type
@param name name of calling function
@see <a href="http://turfjs.org/docs/#geojsontype">Turf geojsonType documentation</a>
@since 1.2.0
"""
if (type == null || type.length() == 0 || name == null || name.length() == 0) {
throw new TurfException("Type and name required");
}
if (value == null || !value.type().equals(type)) {
throw new TurfException("Invalid input to " + name + ": must be a " + type
+ ", given " + (value != null ? value.type() : " null"));
}
} | java | public static void geojsonType(GeoJson value, String type, String name) {
if (type == null || type.length() == 0 || name == null || name.length() == 0) {
throw new TurfException("Type and name required");
}
if (value == null || !value.type().equals(type)) {
throw new TurfException("Invalid input to " + name + ": must be a " + type
+ ", given " + (value != null ? value.type() : " null"));
}
} | [
"public",
"static",
"void",
"geojsonType",
"(",
"GeoJson",
"value",
",",
"String",
"type",
",",
"String",
"name",
")",
"{",
"if",
"(",
"type",
"==",
"null",
"||",
"type",
".",
"length",
"(",
")",
"==",
"0",
"||",
"name",
"==",
"null",
"||",
"name",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"TurfException",
"(",
"\"Type and name required\"",
")",
";",
"}",
"if",
"(",
"value",
"==",
"null",
"||",
"!",
"value",
".",
"type",
"(",
")",
".",
"equals",
"(",
"type",
")",
")",
"{",
"throw",
"new",
"TurfException",
"(",
"\"Invalid input to \"",
"+",
"name",
"+",
"\": must be a \"",
"+",
"type",
"+",
"\", given \"",
"+",
"(",
"value",
"!=",
"null",
"?",
"value",
".",
"type",
"(",
")",
":",
"\" null\"",
")",
")",
";",
"}",
"}"
] | Enforce expectations about types of GeoJson objects for Turf.
@param value any GeoJson object
@param type expected GeoJson type
@param name name of calling function
@see <a href="http://turfjs.org/docs/#geojsontype">Turf geojsonType documentation</a>
@since 1.2.0 | [
"Enforce",
"expectations",
"about",
"types",
"of",
"GeoJson",
"objects",
"for",
"Turf",
"."
] | train | https://github.com/mapbox/mapbox-java/blob/c0be138f462f91441388584c668f3760ba0e18e2/services-turf/src/main/java/com/mapbox/turf/TurfAssertions.java#L44-L52 |
kuali/ojb-1.0.4 | src/xdoclet/java/src/xdoclet/modules/ojb/CommaListIterator.java | CommaListIterator.sameLists | public static boolean sameLists(String list1, String list2) {
"""
Compares the two comma-separated lists.
@param list1 The first list
@param list2 The second list
@return <code>true</code> if the lists are equal
"""
return new CommaListIterator(list1).equals(new CommaListIterator(list2));
} | java | public static boolean sameLists(String list1, String list2)
{
return new CommaListIterator(list1).equals(new CommaListIterator(list2));
} | [
"public",
"static",
"boolean",
"sameLists",
"(",
"String",
"list1",
",",
"String",
"list2",
")",
"{",
"return",
"new",
"CommaListIterator",
"(",
"list1",
")",
".",
"equals",
"(",
"new",
"CommaListIterator",
"(",
"list2",
")",
")",
";",
"}"
] | Compares the two comma-separated lists.
@param list1 The first list
@param list2 The second list
@return <code>true</code> if the lists are equal | [
"Compares",
"the",
"two",
"comma",
"-",
"separated",
"lists",
"."
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/xdoclet/java/src/xdoclet/modules/ojb/CommaListIterator.java#L143-L146 |
UrielCh/ovh-java-sdk | ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java | ApiOvhOrder.dedicatedCloud_serviceName_upgradeRessource_duration_GET | public OvhOrder dedicatedCloud_serviceName_upgradeRessource_duration_GET(String serviceName, String duration, OvhUpgradeTypeEnum upgradeType, Long upgradedRessourceId, OvhUpgradeRessourceTypeEnum upgradedRessourceType) throws IOException {
"""
Get prices and contracts information
REST: GET /order/dedicatedCloud/{serviceName}/upgradeRessource/{duration}
@param upgradedRessourceType [required] The type of ressource you want to upgrade.
@param upgradedRessourceId [required] The id of a particular ressource you want to upgrade in your Private Cloud (useless for "all" UpgradeRessourceTypeEnum)
@param upgradeType [required] The type of upgrade you want to process on the ressource(s)
@param serviceName [required]
@param duration [required] Duration
"""
String qPath = "/order/dedicatedCloud/{serviceName}/upgradeRessource/{duration}";
StringBuilder sb = path(qPath, serviceName, duration);
query(sb, "upgradeType", upgradeType);
query(sb, "upgradedRessourceId", upgradedRessourceId);
query(sb, "upgradedRessourceType", upgradedRessourceType);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhOrder.class);
} | java | public OvhOrder dedicatedCloud_serviceName_upgradeRessource_duration_GET(String serviceName, String duration, OvhUpgradeTypeEnum upgradeType, Long upgradedRessourceId, OvhUpgradeRessourceTypeEnum upgradedRessourceType) throws IOException {
String qPath = "/order/dedicatedCloud/{serviceName}/upgradeRessource/{duration}";
StringBuilder sb = path(qPath, serviceName, duration);
query(sb, "upgradeType", upgradeType);
query(sb, "upgradedRessourceId", upgradedRessourceId);
query(sb, "upgradedRessourceType", upgradedRessourceType);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhOrder.class);
} | [
"public",
"OvhOrder",
"dedicatedCloud_serviceName_upgradeRessource_duration_GET",
"(",
"String",
"serviceName",
",",
"String",
"duration",
",",
"OvhUpgradeTypeEnum",
"upgradeType",
",",
"Long",
"upgradedRessourceId",
",",
"OvhUpgradeRessourceTypeEnum",
"upgradedRessourceType",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/order/dedicatedCloud/{serviceName}/upgradeRessource/{duration}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"duration",
")",
";",
"query",
"(",
"sb",
",",
"\"upgradeType\"",
",",
"upgradeType",
")",
";",
"query",
"(",
"sb",
",",
"\"upgradedRessourceId\"",
",",
"upgradedRessourceId",
")",
";",
"query",
"(",
"sb",
",",
"\"upgradedRessourceType\"",
",",
"upgradedRessourceType",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhOrder",
".",
"class",
")",
";",
"}"
] | Get prices and contracts information
REST: GET /order/dedicatedCloud/{serviceName}/upgradeRessource/{duration}
@param upgradedRessourceType [required] The type of ressource you want to upgrade.
@param upgradedRessourceId [required] The id of a particular ressource you want to upgrade in your Private Cloud (useless for "all" UpgradeRessourceTypeEnum)
@param upgradeType [required] The type of upgrade you want to process on the ressource(s)
@param serviceName [required]
@param duration [required] Duration | [
"Get",
"prices",
"and",
"contracts",
"information"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java#L5755-L5763 |
validator/validator | src/nu/validator/xml/HtmlSerializer.java | HtmlSerializer.endElement | @Override
public void endElement(String namespaceURI, String localName, String qName)
throws SAXException {
"""
Writes an end tag if the element is an XHTML element and is not an empty
element in HTML 4.01 Strict.
@param namespaceURI
the XML namespace
@param localName
the element name in the namespace
@param qName
ignored
@throws SAXException
if there are IO problems
"""
try {
if (XHTML_NS.equals(namespaceURI)
&& Arrays.binarySearch(emptyElements, localName) < 0) {
this.writer.write("</");
this.writer.write(localName);
this.writer.write('>');
}
} catch (IOException ioe) {
throw (SAXException)new SAXException(ioe).initCause(ioe);
}
} | java | @Override
public void endElement(String namespaceURI, String localName, String qName)
throws SAXException {
try {
if (XHTML_NS.equals(namespaceURI)
&& Arrays.binarySearch(emptyElements, localName) < 0) {
this.writer.write("</");
this.writer.write(localName);
this.writer.write('>');
}
} catch (IOException ioe) {
throw (SAXException)new SAXException(ioe).initCause(ioe);
}
} | [
"@",
"Override",
"public",
"void",
"endElement",
"(",
"String",
"namespaceURI",
",",
"String",
"localName",
",",
"String",
"qName",
")",
"throws",
"SAXException",
"{",
"try",
"{",
"if",
"(",
"XHTML_NS",
".",
"equals",
"(",
"namespaceURI",
")",
"&&",
"Arrays",
".",
"binarySearch",
"(",
"emptyElements",
",",
"localName",
")",
"<",
"0",
")",
"{",
"this",
".",
"writer",
".",
"write",
"(",
"\"</\"",
")",
";",
"this",
".",
"writer",
".",
"write",
"(",
"localName",
")",
";",
"this",
".",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"throw",
"(",
"SAXException",
")",
"new",
"SAXException",
"(",
"ioe",
")",
".",
"initCause",
"(",
"ioe",
")",
";",
"}",
"}"
] | Writes an end tag if the element is an XHTML element and is not an empty
element in HTML 4.01 Strict.
@param namespaceURI
the XML namespace
@param localName
the element name in the namespace
@param qName
ignored
@throws SAXException
if there are IO problems | [
"Writes",
"an",
"end",
"tag",
"if",
"the",
"element",
"is",
"an",
"XHTML",
"element",
"and",
"is",
"not",
"an",
"empty",
"element",
"in",
"HTML",
"4",
".",
"01",
"Strict",
"."
] | train | https://github.com/validator/validator/blob/c7b7f85b3a364df7d9944753fb5b2cd0ce642889/src/nu/validator/xml/HtmlSerializer.java#L205-L218 |
box/box-java-sdk | src/main/java/com/box/sdk/BoxFile.java | BoxFile.getInfoWithRepresentations | public BoxFile.Info getInfoWithRepresentations(String representationHints, String... fields) {
"""
Gets information about this item including a specified set of representations.
@see <a href=https://developer.box.com/reference#section-x-rep-hints-header>X-Rep-Hints Header</a>
@param representationHints hints for representations to be retrieved
@param fields the fields to retrieve.
@return info about this item containing only the specified fields, including representations.
"""
if (representationHints.matches(Representation.X_REP_HINTS_PATTERN)) {
//Since the user intends to get representations, add it to fields, even if user has missed it
Set<String> fieldsSet = new HashSet<String>(Arrays.asList(fields));
fieldsSet.add("representations");
String queryString = new QueryStringBuilder().appendParam("fields",
fieldsSet.toArray(new String[fieldsSet.size()])).toString();
URL url = FILE_URL_TEMPLATE.buildWithQuery(this.getAPI().getBaseURL(), queryString, this.getID());
BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET");
request.addHeader("X-Rep-Hints", representationHints);
BoxJSONResponse response = (BoxJSONResponse) request.send();
return new Info(response.getJSON());
} else {
throw new BoxAPIException("Represention hints is not valid."
+ " Refer documention on how to construct X-Rep-Hints Header");
}
} | java | public BoxFile.Info getInfoWithRepresentations(String representationHints, String... fields) {
if (representationHints.matches(Representation.X_REP_HINTS_PATTERN)) {
//Since the user intends to get representations, add it to fields, even if user has missed it
Set<String> fieldsSet = new HashSet<String>(Arrays.asList(fields));
fieldsSet.add("representations");
String queryString = new QueryStringBuilder().appendParam("fields",
fieldsSet.toArray(new String[fieldsSet.size()])).toString();
URL url = FILE_URL_TEMPLATE.buildWithQuery(this.getAPI().getBaseURL(), queryString, this.getID());
BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET");
request.addHeader("X-Rep-Hints", representationHints);
BoxJSONResponse response = (BoxJSONResponse) request.send();
return new Info(response.getJSON());
} else {
throw new BoxAPIException("Represention hints is not valid."
+ " Refer documention on how to construct X-Rep-Hints Header");
}
} | [
"public",
"BoxFile",
".",
"Info",
"getInfoWithRepresentations",
"(",
"String",
"representationHints",
",",
"String",
"...",
"fields",
")",
"{",
"if",
"(",
"representationHints",
".",
"matches",
"(",
"Representation",
".",
"X_REP_HINTS_PATTERN",
")",
")",
"{",
"//Since the user intends to get representations, add it to fields, even if user has missed it",
"Set",
"<",
"String",
">",
"fieldsSet",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
"Arrays",
".",
"asList",
"(",
"fields",
")",
")",
";",
"fieldsSet",
".",
"add",
"(",
"\"representations\"",
")",
";",
"String",
"queryString",
"=",
"new",
"QueryStringBuilder",
"(",
")",
".",
"appendParam",
"(",
"\"fields\"",
",",
"fieldsSet",
".",
"toArray",
"(",
"new",
"String",
"[",
"fieldsSet",
".",
"size",
"(",
")",
"]",
")",
")",
".",
"toString",
"(",
")",
";",
"URL",
"url",
"=",
"FILE_URL_TEMPLATE",
".",
"buildWithQuery",
"(",
"this",
".",
"getAPI",
"(",
")",
".",
"getBaseURL",
"(",
")",
",",
"queryString",
",",
"this",
".",
"getID",
"(",
")",
")",
";",
"BoxAPIRequest",
"request",
"=",
"new",
"BoxAPIRequest",
"(",
"this",
".",
"getAPI",
"(",
")",
",",
"url",
",",
"\"GET\"",
")",
";",
"request",
".",
"addHeader",
"(",
"\"X-Rep-Hints\"",
",",
"representationHints",
")",
";",
"BoxJSONResponse",
"response",
"=",
"(",
"BoxJSONResponse",
")",
"request",
".",
"send",
"(",
")",
";",
"return",
"new",
"Info",
"(",
"response",
".",
"getJSON",
"(",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"BoxAPIException",
"(",
"\"Represention hints is not valid.\"",
"+",
"\" Refer documention on how to construct X-Rep-Hints Header\"",
")",
";",
"}",
"}"
] | Gets information about this item including a specified set of representations.
@see <a href=https://developer.box.com/reference#section-x-rep-hints-header>X-Rep-Hints Header</a>
@param representationHints hints for representations to be retrieved
@param fields the fields to retrieve.
@return info about this item containing only the specified fields, including representations. | [
"Gets",
"information",
"about",
"this",
"item",
"including",
"a",
"specified",
"set",
"of",
"representations",
".",
"@see",
"<a",
"href",
"=",
"https",
":",
"//",
"developer",
".",
"box",
".",
"com",
"/",
"reference#section",
"-",
"x",
"-",
"rep",
"-",
"hints",
"-",
"header",
">",
"X",
"-",
"Rep",
"-",
"Hints",
"Header<",
"/",
"a",
">"
] | train | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L474-L491 |
alkacon/opencms-core | src/org/opencms/util/CmsHtmlStripper.java | CmsHtmlStripper.addPreserveTags | public void addPreserveTags(final String tagList, final char separator) {
"""
Convenience method for adding several tags to preserve
in form of a delimiter-separated String.<p>
The String will be <code>{@link CmsStringUtil#splitAsList(String, char, boolean)}</code>
with <code>tagList</code> as the first argument, <code>separator</code> as the
second argument and the third argument set to true (trimming - support).<p>
@param tagList a delimiter-separated String with case-insensitive tag names to preserve by
<code>{@link #stripHtml(String)}</code>
@param separator the delimiter that separates tag names in the <code>tagList</code> argument
@see #addPreserveTag(String)
"""
List<String> tags = CmsStringUtil.splitAsList(tagList, separator, true);
addPreserveTagList(tags);
} | java | public void addPreserveTags(final String tagList, final char separator) {
List<String> tags = CmsStringUtil.splitAsList(tagList, separator, true);
addPreserveTagList(tags);
} | [
"public",
"void",
"addPreserveTags",
"(",
"final",
"String",
"tagList",
",",
"final",
"char",
"separator",
")",
"{",
"List",
"<",
"String",
">",
"tags",
"=",
"CmsStringUtil",
".",
"splitAsList",
"(",
"tagList",
",",
"separator",
",",
"true",
")",
";",
"addPreserveTagList",
"(",
"tags",
")",
";",
"}"
] | Convenience method for adding several tags to preserve
in form of a delimiter-separated String.<p>
The String will be <code>{@link CmsStringUtil#splitAsList(String, char, boolean)}</code>
with <code>tagList</code> as the first argument, <code>separator</code> as the
second argument and the third argument set to true (trimming - support).<p>
@param tagList a delimiter-separated String with case-insensitive tag names to preserve by
<code>{@link #stripHtml(String)}</code>
@param separator the delimiter that separates tag names in the <code>tagList</code> argument
@see #addPreserveTag(String) | [
"Convenience",
"method",
"for",
"adding",
"several",
"tags",
"to",
"preserve",
"in",
"form",
"of",
"a",
"delimiter",
"-",
"separated",
"String",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/util/CmsHtmlStripper.java#L140-L144 |
jcuda/jcusparse | JCusparseJava/src/main/java/jcuda/jcusparse/JCusparse.java | JCusparse.cusparseCdotci | public static int cusparseCdotci(
cusparseHandle handle,
int nnz,
Pointer xVal,
Pointer xInd,
Pointer y,
Pointer resultDevHostPtr,
int idxBase) {
"""
Description: dot product of complex conjugate of a sparse vector x
and a dense vector y.
"""
return checkResult(cusparseCdotciNative(handle, nnz, xVal, xInd, y, resultDevHostPtr, idxBase));
} | java | public static int cusparseCdotci(
cusparseHandle handle,
int nnz,
Pointer xVal,
Pointer xInd,
Pointer y,
Pointer resultDevHostPtr,
int idxBase)
{
return checkResult(cusparseCdotciNative(handle, nnz, xVal, xInd, y, resultDevHostPtr, idxBase));
} | [
"public",
"static",
"int",
"cusparseCdotci",
"(",
"cusparseHandle",
"handle",
",",
"int",
"nnz",
",",
"Pointer",
"xVal",
",",
"Pointer",
"xInd",
",",
"Pointer",
"y",
",",
"Pointer",
"resultDevHostPtr",
",",
"int",
"idxBase",
")",
"{",
"return",
"checkResult",
"(",
"cusparseCdotciNative",
"(",
"handle",
",",
"nnz",
",",
"xVal",
",",
"xInd",
",",
"y",
",",
"resultDevHostPtr",
",",
"idxBase",
")",
")",
";",
"}"
] | Description: dot product of complex conjugate of a sparse vector x
and a dense vector y. | [
"Description",
":",
"dot",
"product",
"of",
"complex",
"conjugate",
"of",
"a",
"sparse",
"vector",
"x",
"and",
"a",
"dense",
"vector",
"y",
"."
] | train | https://github.com/jcuda/jcusparse/blob/7687a62a4ef6b76cb91cf7da93d4cf5ade96a791/JCusparseJava/src/main/java/jcuda/jcusparse/JCusparse.java#L812-L822 |
authlete/authlete-java-common | src/main/java/com/authlete/common/util/TypedProperties.java | TypedProperties.setEnum | public <TEnum extends Enum<TEnum>> void setEnum(Enum<?> key, TEnum value) {
"""
Equivalent to {@link #setEnum(String, Enum)
setEnum}{@code (key.name(), value)}.
If {@code key} is null, nothing is done.
"""
if (key == null)
{
return;
}
setEnum(key.name(), value);
} | java | public <TEnum extends Enum<TEnum>> void setEnum(Enum<?> key, TEnum value)
{
if (key == null)
{
return;
}
setEnum(key.name(), value);
} | [
"public",
"<",
"TEnum",
"extends",
"Enum",
"<",
"TEnum",
">",
">",
"void",
"setEnum",
"(",
"Enum",
"<",
"?",
">",
"key",
",",
"TEnum",
"value",
")",
"{",
"if",
"(",
"key",
"==",
"null",
")",
"{",
"return",
";",
"}",
"setEnum",
"(",
"key",
".",
"name",
"(",
")",
",",
"value",
")",
";",
"}"
] | Equivalent to {@link #setEnum(String, Enum)
setEnum}{@code (key.name(), value)}.
If {@code key} is null, nothing is done. | [
"Equivalent",
"to",
"{"
] | train | https://github.com/authlete/authlete-java-common/blob/49c94c483713cbf5a04d805ff7dbd83766c9c964/src/main/java/com/authlete/common/util/TypedProperties.java#L772-L780 |
UrielCh/ovh-java-sdk | ovh-java-sdk-router/src/main/java/net/minidev/ovh/api/ApiOvhRouter.java | ApiOvhRouter.serviceName_vpn_id_PUT | public void serviceName_vpn_id_PUT(String serviceName, Long id, OvhVpn body) throws IOException {
"""
Alter this object properties
REST: PUT /router/{serviceName}/vpn/{id}
@param body [required] New object properties
@param serviceName [required] The internal name of your Router offer
@param id [required]
"""
String qPath = "/router/{serviceName}/vpn/{id}";
StringBuilder sb = path(qPath, serviceName, id);
exec(qPath, "PUT", sb.toString(), body);
} | java | public void serviceName_vpn_id_PUT(String serviceName, Long id, OvhVpn body) throws IOException {
String qPath = "/router/{serviceName}/vpn/{id}";
StringBuilder sb = path(qPath, serviceName, id);
exec(qPath, "PUT", sb.toString(), body);
} | [
"public",
"void",
"serviceName_vpn_id_PUT",
"(",
"String",
"serviceName",
",",
"Long",
"id",
",",
"OvhVpn",
"body",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/router/{serviceName}/vpn/{id}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"id",
")",
";",
"exec",
"(",
"qPath",
",",
"\"PUT\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"body",
")",
";",
"}"
] | Alter this object properties
REST: PUT /router/{serviceName}/vpn/{id}
@param body [required] New object properties
@param serviceName [required] The internal name of your Router offer
@param id [required] | [
"Alter",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-router/src/main/java/net/minidev/ovh/api/ApiOvhRouter.java#L90-L94 |
datacleaner/DataCleaner | components/pattern-finder/src/main/java/org/datacleaner/beans/stringpattern/PatternFinder.java | PatternFinder.run | public void run(final R row, final String value, final int distinctCount) {
"""
This method should be invoked by the user of the PatternFinder. Invoke it
for each value in your dataset. Repeated values are handled correctly but
if available it is more efficient to handle only the distinct values and
their corresponding distinct counts.
@param row
the row containing the value
@param value
the string value to be tokenized and matched against other
patterns
@param distinctCount
the count of the value
"""
final List<Token> tokens;
try {
tokens = _tokenizer.tokenize(value);
} catch (final RuntimeException e) {
throw new IllegalStateException("Error occurred while tokenizing value: " + value, e);
}
final String patternCode = getPatternCode(tokens);
final Collection<TokenPattern> patterns = getOrCreatePatterns(patternCode);
// lock on "patterns" since it is going to be the same collection for
// all matching pattern codes.
synchronized (patterns) {
boolean match = false;
for (final TokenPattern pattern : patterns) {
if (pattern.match(tokens)) {
storeMatch(pattern, row, value, distinctCount);
match = true;
break;
}
}
if (!match) {
final TokenPattern pattern;
try {
pattern = new TokenPatternImpl(value, tokens, _configuration);
} catch (final RuntimeException e) {
throw new IllegalStateException("Error occurred while creating pattern for: " + tokens, e);
}
storeNewPattern(pattern, row, value, distinctCount);
patterns.add(pattern);
}
}
} | java | public void run(final R row, final String value, final int distinctCount) {
final List<Token> tokens;
try {
tokens = _tokenizer.tokenize(value);
} catch (final RuntimeException e) {
throw new IllegalStateException("Error occurred while tokenizing value: " + value, e);
}
final String patternCode = getPatternCode(tokens);
final Collection<TokenPattern> patterns = getOrCreatePatterns(patternCode);
// lock on "patterns" since it is going to be the same collection for
// all matching pattern codes.
synchronized (patterns) {
boolean match = false;
for (final TokenPattern pattern : patterns) {
if (pattern.match(tokens)) {
storeMatch(pattern, row, value, distinctCount);
match = true;
break;
}
}
if (!match) {
final TokenPattern pattern;
try {
pattern = new TokenPatternImpl(value, tokens, _configuration);
} catch (final RuntimeException e) {
throw new IllegalStateException("Error occurred while creating pattern for: " + tokens, e);
}
storeNewPattern(pattern, row, value, distinctCount);
patterns.add(pattern);
}
}
} | [
"public",
"void",
"run",
"(",
"final",
"R",
"row",
",",
"final",
"String",
"value",
",",
"final",
"int",
"distinctCount",
")",
"{",
"final",
"List",
"<",
"Token",
">",
"tokens",
";",
"try",
"{",
"tokens",
"=",
"_tokenizer",
".",
"tokenize",
"(",
"value",
")",
";",
"}",
"catch",
"(",
"final",
"RuntimeException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Error occurred while tokenizing value: \"",
"+",
"value",
",",
"e",
")",
";",
"}",
"final",
"String",
"patternCode",
"=",
"getPatternCode",
"(",
"tokens",
")",
";",
"final",
"Collection",
"<",
"TokenPattern",
">",
"patterns",
"=",
"getOrCreatePatterns",
"(",
"patternCode",
")",
";",
"// lock on \"patterns\" since it is going to be the same collection for",
"// all matching pattern codes.",
"synchronized",
"(",
"patterns",
")",
"{",
"boolean",
"match",
"=",
"false",
";",
"for",
"(",
"final",
"TokenPattern",
"pattern",
":",
"patterns",
")",
"{",
"if",
"(",
"pattern",
".",
"match",
"(",
"tokens",
")",
")",
"{",
"storeMatch",
"(",
"pattern",
",",
"row",
",",
"value",
",",
"distinctCount",
")",
";",
"match",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"match",
")",
"{",
"final",
"TokenPattern",
"pattern",
";",
"try",
"{",
"pattern",
"=",
"new",
"TokenPatternImpl",
"(",
"value",
",",
"tokens",
",",
"_configuration",
")",
";",
"}",
"catch",
"(",
"final",
"RuntimeException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Error occurred while creating pattern for: \"",
"+",
"tokens",
",",
"e",
")",
";",
"}",
"storeNewPattern",
"(",
"pattern",
",",
"row",
",",
"value",
",",
"distinctCount",
")",
";",
"patterns",
".",
"add",
"(",
"pattern",
")",
";",
"}",
"}",
"}"
] | This method should be invoked by the user of the PatternFinder. Invoke it
for each value in your dataset. Repeated values are handled correctly but
if available it is more efficient to handle only the distinct values and
their corresponding distinct counts.
@param row
the row containing the value
@param value
the string value to be tokenized and matched against other
patterns
@param distinctCount
the count of the value | [
"This",
"method",
"should",
"be",
"invoked",
"by",
"the",
"user",
"of",
"the",
"PatternFinder",
".",
"Invoke",
"it",
"for",
"each",
"value",
"in",
"your",
"dataset",
".",
"Repeated",
"values",
"are",
"handled",
"correctly",
"but",
"if",
"available",
"it",
"is",
"more",
"efficient",
"to",
"handle",
"only",
"the",
"distinct",
"values",
"and",
"their",
"corresponding",
"distinct",
"counts",
"."
] | train | https://github.com/datacleaner/DataCleaner/blob/9aa01fdac3560cef51c55df3cb2ac5c690b57639/components/pattern-finder/src/main/java/org/datacleaner/beans/stringpattern/PatternFinder.java#L71-L106 |
Baidu-AIP/java-sdk | src/main/java/com/baidu/aip/kg/AipKnowledgeGraphic.java | AipKnowledgeGraphic.getTaskStatus | public JSONObject getTaskStatus(int id, HashMap<String, String> options) {
"""
查询任务状态接口
查询指定的任务的最新执行状态
@param id - 任务ID
@param options - 可选参数对象,key: value都为string类型
options - options列表:
@return JSONObject
"""
AipRequest request = new AipRequest();
preOperation(request);
request.addBody("id", id);
if (options != null) {
request.addBody(options);
}
request.setUri(KnowledgeGraphicConsts.TASK_STATUS);
postOperation(request);
return requestServer(request);
} | java | public JSONObject getTaskStatus(int id, HashMap<String, String> options) {
AipRequest request = new AipRequest();
preOperation(request);
request.addBody("id", id);
if (options != null) {
request.addBody(options);
}
request.setUri(KnowledgeGraphicConsts.TASK_STATUS);
postOperation(request);
return requestServer(request);
} | [
"public",
"JSONObject",
"getTaskStatus",
"(",
"int",
"id",
",",
"HashMap",
"<",
"String",
",",
"String",
">",
"options",
")",
"{",
"AipRequest",
"request",
"=",
"new",
"AipRequest",
"(",
")",
";",
"preOperation",
"(",
"request",
")",
";",
"request",
".",
"addBody",
"(",
"\"id\"",
",",
"id",
")",
";",
"if",
"(",
"options",
"!=",
"null",
")",
"{",
"request",
".",
"addBody",
"(",
"options",
")",
";",
"}",
"request",
".",
"setUri",
"(",
"KnowledgeGraphicConsts",
".",
"TASK_STATUS",
")",
";",
"postOperation",
"(",
"request",
")",
";",
"return",
"requestServer",
"(",
"request",
")",
";",
"}"
] | 查询任务状态接口
查询指定的任务的最新执行状态
@param id - 任务ID
@param options - 可选参数对象,key: value都为string类型
options - options列表:
@return JSONObject | [
"查询任务状态接口",
"查询指定的任务的最新执行状态"
] | train | https://github.com/Baidu-AIP/java-sdk/blob/16bb8b7bb8f9bbcb7c8af62d0a67a1e79eecad90/src/main/java/com/baidu/aip/kg/AipKnowledgeGraphic.java#L167-L178 |
OpenLiberty/open-liberty | dev/com.ibm.ws.webcontainer.security/src/com/ibm/ws/webcontainer/security/ReferrerURLCookieHandler.java | ReferrerURLCookieHandler.getReferrerURLFromCookies | @Sensitive
public String getReferrerURLFromCookies(HttpServletRequest req, String cookieName) {
"""
Retrieve the referrer URL from the HttpServletRequest's cookies.
This will decode the URL and restore the host name if it was removed.
@param req
@return referrerURL
"""
Cookie[] cookies = req.getCookies();
String referrerURL = CookieHelper.getCookieValue(cookies, cookieName);
if (referrerURL != null) {
StringBuffer URL = req.getRequestURL();
referrerURL = decodeURL(referrerURL);
referrerURL = restoreHostNameToURL(referrerURL, URL.toString());
}
return referrerURL;
} | java | @Sensitive
public String getReferrerURLFromCookies(HttpServletRequest req, String cookieName) {
Cookie[] cookies = req.getCookies();
String referrerURL = CookieHelper.getCookieValue(cookies, cookieName);
if (referrerURL != null) {
StringBuffer URL = req.getRequestURL();
referrerURL = decodeURL(referrerURL);
referrerURL = restoreHostNameToURL(referrerURL, URL.toString());
}
return referrerURL;
} | [
"@",
"Sensitive",
"public",
"String",
"getReferrerURLFromCookies",
"(",
"HttpServletRequest",
"req",
",",
"String",
"cookieName",
")",
"{",
"Cookie",
"[",
"]",
"cookies",
"=",
"req",
".",
"getCookies",
"(",
")",
";",
"String",
"referrerURL",
"=",
"CookieHelper",
".",
"getCookieValue",
"(",
"cookies",
",",
"cookieName",
")",
";",
"if",
"(",
"referrerURL",
"!=",
"null",
")",
"{",
"StringBuffer",
"URL",
"=",
"req",
".",
"getRequestURL",
"(",
")",
";",
"referrerURL",
"=",
"decodeURL",
"(",
"referrerURL",
")",
";",
"referrerURL",
"=",
"restoreHostNameToURL",
"(",
"referrerURL",
",",
"URL",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"referrerURL",
";",
"}"
] | Retrieve the referrer URL from the HttpServletRequest's cookies.
This will decode the URL and restore the host name if it was removed.
@param req
@return referrerURL | [
"Retrieve",
"the",
"referrer",
"URL",
"from",
"the",
"HttpServletRequest",
"s",
"cookies",
".",
"This",
"will",
"decode",
"the",
"URL",
"and",
"restore",
"the",
"host",
"name",
"if",
"it",
"was",
"removed",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer.security/src/com/ibm/ws/webcontainer/security/ReferrerURLCookieHandler.java#L50-L60 |
mozilla/rhino | src/org/mozilla/javascript/ScriptableObject.java | ScriptableObject.deleteProperty | public static boolean deleteProperty(Scriptable obj, String name) {
"""
Removes the property from an object or its prototype chain.
<p>
Searches for a property with <code>name</code> in obj or
its prototype chain. If it is found, the object's delete
method is called.
@param obj a JavaScript object
@param name a property name
@return true if the property doesn't exist or was successfully removed
@since 1.5R2
"""
Scriptable base = getBase(obj, name);
if (base == null)
return true;
base.delete(name);
return !base.has(name, obj);
} | java | public static boolean deleteProperty(Scriptable obj, String name)
{
Scriptable base = getBase(obj, name);
if (base == null)
return true;
base.delete(name);
return !base.has(name, obj);
} | [
"public",
"static",
"boolean",
"deleteProperty",
"(",
"Scriptable",
"obj",
",",
"String",
"name",
")",
"{",
"Scriptable",
"base",
"=",
"getBase",
"(",
"obj",
",",
"name",
")",
";",
"if",
"(",
"base",
"==",
"null",
")",
"return",
"true",
";",
"base",
".",
"delete",
"(",
"name",
")",
";",
"return",
"!",
"base",
".",
"has",
"(",
"name",
",",
"obj",
")",
";",
"}"
] | Removes the property from an object or its prototype chain.
<p>
Searches for a property with <code>name</code> in obj or
its prototype chain. If it is found, the object's delete
method is called.
@param obj a JavaScript object
@param name a property name
@return true if the property doesn't exist or was successfully removed
@since 1.5R2 | [
"Removes",
"the",
"property",
"from",
"an",
"object",
"or",
"its",
"prototype",
"chain",
".",
"<p",
">",
"Searches",
"for",
"a",
"property",
"with",
"<code",
">",
"name<",
"/",
"code",
">",
"in",
"obj",
"or",
"its",
"prototype",
"chain",
".",
"If",
"it",
"is",
"found",
"the",
"object",
"s",
"delete",
"method",
"is",
"called",
"."
] | train | https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptableObject.java#L2579-L2586 |
bushidowallet/bushido-java-service | bushido-service-lib/src/main/java/com/bccapi/bitlib/model/CompactInt.java | CompactInt.toBytes | public static byte[] toBytes(long value) {
"""
Turn a long value into an array of bytes containing the CompactInt
representation.
@param value
The value to turn into an array of bytes.
@return an array of bytes.
"""
if (isLessThan(value, 253)) {
return new byte[] { (byte) value };
} else if (isLessThan(value, 65536)) {
return new byte[] { (byte) 253, (byte) (value), (byte) (value >> 8) };
} else if (isLessThan(value, 4294967295L)) {
byte[] bytes = new byte[5];
bytes[0] = (byte) 254;
BitUtils.uint32ToByteArrayLE(value, bytes, 1);
return bytes;
} else {
byte[] bytes = new byte[9];
bytes[0] = (byte) 255;
BitUtils.uint32ToByteArrayLE(value, bytes, 1);
BitUtils.uint32ToByteArrayLE(value >>> 32, bytes, 5);
return bytes;
}
} | java | public static byte[] toBytes(long value) {
if (isLessThan(value, 253)) {
return new byte[] { (byte) value };
} else if (isLessThan(value, 65536)) {
return new byte[] { (byte) 253, (byte) (value), (byte) (value >> 8) };
} else if (isLessThan(value, 4294967295L)) {
byte[] bytes = new byte[5];
bytes[0] = (byte) 254;
BitUtils.uint32ToByteArrayLE(value, bytes, 1);
return bytes;
} else {
byte[] bytes = new byte[9];
bytes[0] = (byte) 255;
BitUtils.uint32ToByteArrayLE(value, bytes, 1);
BitUtils.uint32ToByteArrayLE(value >>> 32, bytes, 5);
return bytes;
}
} | [
"public",
"static",
"byte",
"[",
"]",
"toBytes",
"(",
"long",
"value",
")",
"{",
"if",
"(",
"isLessThan",
"(",
"value",
",",
"253",
")",
")",
"{",
"return",
"new",
"byte",
"[",
"]",
"{",
"(",
"byte",
")",
"value",
"}",
";",
"}",
"else",
"if",
"(",
"isLessThan",
"(",
"value",
",",
"65536",
")",
")",
"{",
"return",
"new",
"byte",
"[",
"]",
"{",
"(",
"byte",
")",
"253",
",",
"(",
"byte",
")",
"(",
"value",
")",
",",
"(",
"byte",
")",
"(",
"value",
">>",
"8",
")",
"}",
";",
"}",
"else",
"if",
"(",
"isLessThan",
"(",
"value",
",",
"4294967295L",
")",
")",
"{",
"byte",
"[",
"]",
"bytes",
"=",
"new",
"byte",
"[",
"5",
"]",
";",
"bytes",
"[",
"0",
"]",
"=",
"(",
"byte",
")",
"254",
";",
"BitUtils",
".",
"uint32ToByteArrayLE",
"(",
"value",
",",
"bytes",
",",
"1",
")",
";",
"return",
"bytes",
";",
"}",
"else",
"{",
"byte",
"[",
"]",
"bytes",
"=",
"new",
"byte",
"[",
"9",
"]",
";",
"bytes",
"[",
"0",
"]",
"=",
"(",
"byte",
")",
"255",
";",
"BitUtils",
".",
"uint32ToByteArrayLE",
"(",
"value",
",",
"bytes",
",",
"1",
")",
";",
"BitUtils",
".",
"uint32ToByteArrayLE",
"(",
"value",
">>>",
"32",
",",
"bytes",
",",
"5",
")",
";",
"return",
"bytes",
";",
"}",
"}"
] | Turn a long value into an array of bytes containing the CompactInt
representation.
@param value
The value to turn into an array of bytes.
@return an array of bytes. | [
"Turn",
"a",
"long",
"value",
"into",
"an",
"array",
"of",
"bytes",
"containing",
"the",
"CompactInt",
"representation",
"."
] | train | https://github.com/bushidowallet/bushido-java-service/blob/e1a0157527e57459b509718044d2df44084876a2/bushido-service-lib/src/main/java/com/bccapi/bitlib/model/CompactInt.java#L97-L114 |
ReactiveX/RxJavaAsyncUtil | src/main/java/rx/util/async/operators/LatchedObserver.java | LatchedObserver.createIndexed | public static <T> LatchedObserver<T> createIndexed(Action2<? super T, ? super Integer> onNext) {
"""
Create a LatchedObserver with the given indexed callback function(s).
"""
return createIndexed(onNext, new CountDownLatch(1));
} | java | public static <T> LatchedObserver<T> createIndexed(Action2<? super T, ? super Integer> onNext) {
return createIndexed(onNext, new CountDownLatch(1));
} | [
"public",
"static",
"<",
"T",
">",
"LatchedObserver",
"<",
"T",
">",
"createIndexed",
"(",
"Action2",
"<",
"?",
"super",
"T",
",",
"?",
"super",
"Integer",
">",
"onNext",
")",
"{",
"return",
"createIndexed",
"(",
"onNext",
",",
"new",
"CountDownLatch",
"(",
"1",
")",
")",
";",
"}"
] | Create a LatchedObserver with the given indexed callback function(s). | [
"Create",
"a",
"LatchedObserver",
"with",
"the",
"given",
"indexed",
"callback",
"function",
"(",
"s",
")",
"."
] | train | https://github.com/ReactiveX/RxJavaAsyncUtil/blob/6294e1da30e639df79f76399906229314c14e74d/src/main/java/rx/util/async/operators/LatchedObserver.java#L165-L167 |
konmik/nucleus | nucleus/src/main/java/nucleus/view/NucleusLayout.java | NucleusLayout.getActivity | public Activity getActivity() {
"""
Returns the unwrapped activity of the view or throws an exception.
@return an unwrapped activity
"""
Context context = getContext();
while (!(context instanceof Activity) && context instanceof ContextWrapper)
context = ((ContextWrapper) context).getBaseContext();
if (!(context instanceof Activity))
throw new IllegalStateException("Expected an activity context, got " + context.getClass().getSimpleName());
return (Activity) context;
} | java | public Activity getActivity() {
Context context = getContext();
while (!(context instanceof Activity) && context instanceof ContextWrapper)
context = ((ContextWrapper) context).getBaseContext();
if (!(context instanceof Activity))
throw new IllegalStateException("Expected an activity context, got " + context.getClass().getSimpleName());
return (Activity) context;
} | [
"public",
"Activity",
"getActivity",
"(",
")",
"{",
"Context",
"context",
"=",
"getContext",
"(",
")",
";",
"while",
"(",
"!",
"(",
"context",
"instanceof",
"Activity",
")",
"&&",
"context",
"instanceof",
"ContextWrapper",
")",
"context",
"=",
"(",
"(",
"ContextWrapper",
")",
"context",
")",
".",
"getBaseContext",
"(",
")",
";",
"if",
"(",
"!",
"(",
"context",
"instanceof",
"Activity",
")",
")",
"throw",
"new",
"IllegalStateException",
"(",
"\"Expected an activity context, got \"",
"+",
"context",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
";",
"return",
"(",
"Activity",
")",
"context",
";",
"}"
] | Returns the unwrapped activity of the view or throws an exception.
@return an unwrapped activity | [
"Returns",
"the",
"unwrapped",
"activity",
"of",
"the",
"view",
"or",
"throws",
"an",
"exception",
"."
] | train | https://github.com/konmik/nucleus/blob/b161484a2bbf66a7896a8c1f61fa7187856ca5f7/nucleus/src/main/java/nucleus/view/NucleusLayout.java#L76-L83 |
mygreen/super-csv-annotation | src/main/java/com/github/mygreen/supercsv/io/AbstractCsvAnnotationBeanWriter.java | AbstractCsvAnnotationBeanWriter.extractBeanValues | protected void extractBeanValues(final Object source, final String[] nameMapping) throws SuperCsvReflectionException {
"""
Extracts the bean values, using the supplied name mapping array.
@param source
the bean
@param nameMapping
the name mapping
@throws NullPointerException
if source or nameMapping are null
@throws SuperCsvReflectionException
if there was a reflection exception extracting the bean value
"""
Objects.requireNonNull(nameMapping, "the nameMapping array can't be null as it's used to map from fields to columns");
beanValues.clear();
for( int i = 0; i < nameMapping.length; i++ ) {
final String fieldName = nameMapping[i];
if( fieldName == null ) {
beanValues.add(null); // assume they always want a blank column
} else {
Method getMethod = cache.getGetMethod(source, fieldName);
try {
beanValues.add(getMethod.invoke(source));
}
catch(final Exception e) {
throw new SuperCsvReflectionException(String.format("error extracting bean value for field %s",
fieldName), e);
}
}
}
} | java | protected void extractBeanValues(final Object source, final String[] nameMapping) throws SuperCsvReflectionException {
Objects.requireNonNull(nameMapping, "the nameMapping array can't be null as it's used to map from fields to columns");
beanValues.clear();
for( int i = 0; i < nameMapping.length; i++ ) {
final String fieldName = nameMapping[i];
if( fieldName == null ) {
beanValues.add(null); // assume they always want a blank column
} else {
Method getMethod = cache.getGetMethod(source, fieldName);
try {
beanValues.add(getMethod.invoke(source));
}
catch(final Exception e) {
throw new SuperCsvReflectionException(String.format("error extracting bean value for field %s",
fieldName), e);
}
}
}
} | [
"protected",
"void",
"extractBeanValues",
"(",
"final",
"Object",
"source",
",",
"final",
"String",
"[",
"]",
"nameMapping",
")",
"throws",
"SuperCsvReflectionException",
"{",
"Objects",
".",
"requireNonNull",
"(",
"nameMapping",
",",
"\"the nameMapping array can't be null as it's used to map from fields to columns\"",
")",
";",
"beanValues",
".",
"clear",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nameMapping",
".",
"length",
";",
"i",
"++",
")",
"{",
"final",
"String",
"fieldName",
"=",
"nameMapping",
"[",
"i",
"]",
";",
"if",
"(",
"fieldName",
"==",
"null",
")",
"{",
"beanValues",
".",
"add",
"(",
"null",
")",
";",
"// assume they always want a blank column\r",
"}",
"else",
"{",
"Method",
"getMethod",
"=",
"cache",
".",
"getGetMethod",
"(",
"source",
",",
"fieldName",
")",
";",
"try",
"{",
"beanValues",
".",
"add",
"(",
"getMethod",
".",
"invoke",
"(",
"source",
")",
")",
";",
"}",
"catch",
"(",
"final",
"Exception",
"e",
")",
"{",
"throw",
"new",
"SuperCsvReflectionException",
"(",
"String",
".",
"format",
"(",
"\"error extracting bean value for field %s\"",
",",
"fieldName",
")",
",",
"e",
")",
";",
"}",
"}",
"}",
"}"
] | Extracts the bean values, using the supplied name mapping array.
@param source
the bean
@param nameMapping
the name mapping
@throws NullPointerException
if source or nameMapping are null
@throws SuperCsvReflectionException
if there was a reflection exception extracting the bean value | [
"Extracts",
"the",
"bean",
"values",
"using",
"the",
"supplied",
"name",
"mapping",
"array",
"."
] | train | https://github.com/mygreen/super-csv-annotation/blob/9910320cb6dc143be972c7d10d9ab5ffb09c3b84/src/main/java/com/github/mygreen/supercsv/io/AbstractCsvAnnotationBeanWriter.java#L183-L209 |
raydac/java-comment-preprocessor | jcp/src/main/java/com/igormaznitsa/meta/common/utils/Assertions.java | Assertions.assertNull | public static <T> T assertNull(@Nullable final String failMessage, @Nullable final T object) {
"""
Assert that value is null
@param <T> type of the object to check
@param failMessage the message to be provided for failure, can be null
@param object the object to check
@return the same input parameter if all is ok
@throws AssertionError it will be thrown if the value is not null
@since 1.1.0
"""
if (object != null) {
final String txt = failMessage == null ? "Object must be NULL" : failMessage;
final AssertionError error = new AssertionError(txt);
MetaErrorListeners.fireError(txt, error);
throw error;
}
return object;
} | java | public static <T> T assertNull(@Nullable final String failMessage, @Nullable final T object) {
if (object != null) {
final String txt = failMessage == null ? "Object must be NULL" : failMessage;
final AssertionError error = new AssertionError(txt);
MetaErrorListeners.fireError(txt, error);
throw error;
}
return object;
} | [
"public",
"static",
"<",
"T",
">",
"T",
"assertNull",
"(",
"@",
"Nullable",
"final",
"String",
"failMessage",
",",
"@",
"Nullable",
"final",
"T",
"object",
")",
"{",
"if",
"(",
"object",
"!=",
"null",
")",
"{",
"final",
"String",
"txt",
"=",
"failMessage",
"==",
"null",
"?",
"\"Object must be NULL\"",
":",
"failMessage",
";",
"final",
"AssertionError",
"error",
"=",
"new",
"AssertionError",
"(",
"txt",
")",
";",
"MetaErrorListeners",
".",
"fireError",
"(",
"txt",
",",
"error",
")",
";",
"throw",
"error",
";",
"}",
"return",
"object",
";",
"}"
] | Assert that value is null
@param <T> type of the object to check
@param failMessage the message to be provided for failure, can be null
@param object the object to check
@return the same input parameter if all is ok
@throws AssertionError it will be thrown if the value is not null
@since 1.1.0 | [
"Assert",
"that",
"value",
"is",
"null"
] | train | https://github.com/raydac/java-comment-preprocessor/blob/83ac87b575ac084914d77695a8c8673de3b8300c/jcp/src/main/java/com/igormaznitsa/meta/common/utils/Assertions.java#L90-L98 |
landawn/AbacusUtil | src/com/landawn/abacus/android/util/SQLiteExecutor.java | SQLiteExecutor.toList | static <T> List<T> toList(Class<T> targetClass, Cursor cursor) {
"""
Returns values from all rows associated with the specified <code>targetClass</code> if the specified <code>targetClass</code> is an entity class, otherwise, only returns values from first column.
@param targetClass entity class or specific column type.
@param cursor
@return
"""
return toList(targetClass, cursor, 0, Integer.MAX_VALUE);
} | java | static <T> List<T> toList(Class<T> targetClass, Cursor cursor) {
return toList(targetClass, cursor, 0, Integer.MAX_VALUE);
} | [
"static",
"<",
"T",
">",
"List",
"<",
"T",
">",
"toList",
"(",
"Class",
"<",
"T",
">",
"targetClass",
",",
"Cursor",
"cursor",
")",
"{",
"return",
"toList",
"(",
"targetClass",
",",
"cursor",
",",
"0",
",",
"Integer",
".",
"MAX_VALUE",
")",
";",
"}"
] | Returns values from all rows associated with the specified <code>targetClass</code> if the specified <code>targetClass</code> is an entity class, otherwise, only returns values from first column.
@param targetClass entity class or specific column type.
@param cursor
@return | [
"Returns",
"values",
"from",
"all",
"rows",
"associated",
"with",
"the",
"specified",
"<code",
">",
"targetClass<",
"/",
"code",
">",
"if",
"the",
"specified",
"<code",
">",
"targetClass<",
"/",
"code",
">",
"is",
"an",
"entity",
"class",
"otherwise",
"only",
"returns",
"values",
"from",
"first",
"column",
"."
] | train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/android/util/SQLiteExecutor.java#L269-L271 |
line/centraldogma | server/src/main/java/com/linecorp/centraldogma/server/PluginGroup.java | PluginGroup.loadPlugins | @Nullable
static PluginGroup loadPlugins(ClassLoader classLoader, PluginTarget target, CentralDogmaConfig config) {
"""
Returns a new {@link PluginGroup} which holds the {@link Plugin}s loaded from the classpath.
{@code null} is returned if there is no {@link Plugin} whose target equals to the specified
{@code target}.
@param classLoader which is used to load the {@link Plugin}s
@param target the {@link PluginTarget} which would be loaded
"""
requireNonNull(classLoader, "classLoader");
requireNonNull(target, "target");
requireNonNull(config, "config");
final ServiceLoader<Plugin> loader = ServiceLoader.load(Plugin.class, classLoader);
final Builder<Plugin> plugins = new Builder<>();
for (Plugin plugin : loader) {
if (target == plugin.target() && plugin.isEnabled(config)) {
plugins.add(plugin);
}
}
final List<Plugin> list = plugins.build();
if (list.isEmpty()) {
return null;
}
return new PluginGroup(list, Executors.newSingleThreadExecutor(new DefaultThreadFactory(
"plugins-for-" + target.name().toLowerCase().replace("_", "-"), true)));
} | java | @Nullable
static PluginGroup loadPlugins(ClassLoader classLoader, PluginTarget target, CentralDogmaConfig config) {
requireNonNull(classLoader, "classLoader");
requireNonNull(target, "target");
requireNonNull(config, "config");
final ServiceLoader<Plugin> loader = ServiceLoader.load(Plugin.class, classLoader);
final Builder<Plugin> plugins = new Builder<>();
for (Plugin plugin : loader) {
if (target == plugin.target() && plugin.isEnabled(config)) {
plugins.add(plugin);
}
}
final List<Plugin> list = plugins.build();
if (list.isEmpty()) {
return null;
}
return new PluginGroup(list, Executors.newSingleThreadExecutor(new DefaultThreadFactory(
"plugins-for-" + target.name().toLowerCase().replace("_", "-"), true)));
} | [
"@",
"Nullable",
"static",
"PluginGroup",
"loadPlugins",
"(",
"ClassLoader",
"classLoader",
",",
"PluginTarget",
"target",
",",
"CentralDogmaConfig",
"config",
")",
"{",
"requireNonNull",
"(",
"classLoader",
",",
"\"classLoader\"",
")",
";",
"requireNonNull",
"(",
"target",
",",
"\"target\"",
")",
";",
"requireNonNull",
"(",
"config",
",",
"\"config\"",
")",
";",
"final",
"ServiceLoader",
"<",
"Plugin",
">",
"loader",
"=",
"ServiceLoader",
".",
"load",
"(",
"Plugin",
".",
"class",
",",
"classLoader",
")",
";",
"final",
"Builder",
"<",
"Plugin",
">",
"plugins",
"=",
"new",
"Builder",
"<>",
"(",
")",
";",
"for",
"(",
"Plugin",
"plugin",
":",
"loader",
")",
"{",
"if",
"(",
"target",
"==",
"plugin",
".",
"target",
"(",
")",
"&&",
"plugin",
".",
"isEnabled",
"(",
"config",
")",
")",
"{",
"plugins",
".",
"add",
"(",
"plugin",
")",
";",
"}",
"}",
"final",
"List",
"<",
"Plugin",
">",
"list",
"=",
"plugins",
".",
"build",
"(",
")",
";",
"if",
"(",
"list",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"new",
"PluginGroup",
"(",
"list",
",",
"Executors",
".",
"newSingleThreadExecutor",
"(",
"new",
"DefaultThreadFactory",
"(",
"\"plugins-for-\"",
"+",
"target",
".",
"name",
"(",
")",
".",
"toLowerCase",
"(",
")",
".",
"replace",
"(",
"\"_\"",
",",
"\"-\"",
")",
",",
"true",
")",
")",
")",
";",
"}"
] | Returns a new {@link PluginGroup} which holds the {@link Plugin}s loaded from the classpath.
{@code null} is returned if there is no {@link Plugin} whose target equals to the specified
{@code target}.
@param classLoader which is used to load the {@link Plugin}s
@param target the {@link PluginTarget} which would be loaded | [
"Returns",
"a",
"new",
"{",
"@link",
"PluginGroup",
"}",
"which",
"holds",
"the",
"{",
"@link",
"Plugin",
"}",
"s",
"loaded",
"from",
"the",
"classpath",
".",
"{",
"@code",
"null",
"}",
"is",
"returned",
"if",
"there",
"is",
"no",
"{",
"@link",
"Plugin",
"}",
"whose",
"target",
"equals",
"to",
"the",
"specified",
"{",
"@code",
"target",
"}",
"."
] | train | https://github.com/line/centraldogma/blob/b9e46c67fbc26628c2186ce2f46e7fb303c831e9/server/src/main/java/com/linecorp/centraldogma/server/PluginGroup.java#L75-L96 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/ops/SDBaseOps.java | SDBaseOps.reverseSequence | public SDVariable reverseSequence(String name, SDVariable x, SDVariable seq_lengths, int seqDim, int batchDim) {
"""
Reverse sequence op: for each slice along dimension seqDimension, the first seqLength values are reversed
@param name Name of the output variable
@param x Input variable
@param seq_lengths Length of the sequences
@param seqDim Sequence dimension
@param batchDim Batch dimension
@return Reversed sequences
"""
SDVariable ret = f().reverseSequence(x, seq_lengths, seqDim, batchDim);
return updateVariableNameAndReference(ret, name);
} | java | public SDVariable reverseSequence(String name, SDVariable x, SDVariable seq_lengths, int seqDim, int batchDim) {
SDVariable ret = f().reverseSequence(x, seq_lengths, seqDim, batchDim);
return updateVariableNameAndReference(ret, name);
} | [
"public",
"SDVariable",
"reverseSequence",
"(",
"String",
"name",
",",
"SDVariable",
"x",
",",
"SDVariable",
"seq_lengths",
",",
"int",
"seqDim",
",",
"int",
"batchDim",
")",
"{",
"SDVariable",
"ret",
"=",
"f",
"(",
")",
".",
"reverseSequence",
"(",
"x",
",",
"seq_lengths",
",",
"seqDim",
",",
"batchDim",
")",
";",
"return",
"updateVariableNameAndReference",
"(",
"ret",
",",
"name",
")",
";",
"}"
] | Reverse sequence op: for each slice along dimension seqDimension, the first seqLength values are reversed
@param name Name of the output variable
@param x Input variable
@param seq_lengths Length of the sequences
@param seqDim Sequence dimension
@param batchDim Batch dimension
@return Reversed sequences | [
"Reverse",
"sequence",
"op",
":",
"for",
"each",
"slice",
"along",
"dimension",
"seqDimension",
"the",
"first",
"seqLength",
"values",
"are",
"reversed"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/ops/SDBaseOps.java#L1889-L1892 |
jeremybrooks/jinx | src/main/java/net/jeremybrooks/jinx/api/StatsApi.java | StatsApi.getPhotosetStats | public Stats getPhotosetStats(Date date, String photosetId) throws JinxException {
"""
Get the number of views on a photoset for a given date.
This method requires authentication with 'read' permission.
@param date stats will be returned for this date. Required.
@param photosetId id of the photoset to get stats for. Required.
@return number of views on a photoset for a given date.
@throws JinxException if required parameters are missing, or if there are any errors.
@see <a href="https://www.flickr.com/services/api/flickr.stats.getPhotosetStats.html">flickr.stats.getPhotosetStats</a>
"""
JinxUtils.validateParams(date, photosetId);
Map<String, String> params = new TreeMap<>();
params.put("method", "flickr.stats.getPhotosetStats");
params.put("date", JinxUtils.formatDateAsYMD(date));
params.put("photoset_id", photosetId);
return jinx.flickrGet(params, Stats.class);
} | java | public Stats getPhotosetStats(Date date, String photosetId) throws JinxException {
JinxUtils.validateParams(date, photosetId);
Map<String, String> params = new TreeMap<>();
params.put("method", "flickr.stats.getPhotosetStats");
params.put("date", JinxUtils.formatDateAsYMD(date));
params.put("photoset_id", photosetId);
return jinx.flickrGet(params, Stats.class);
} | [
"public",
"Stats",
"getPhotosetStats",
"(",
"Date",
"date",
",",
"String",
"photosetId",
")",
"throws",
"JinxException",
"{",
"JinxUtils",
".",
"validateParams",
"(",
"date",
",",
"photosetId",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"params",
"=",
"new",
"TreeMap",
"<>",
"(",
")",
";",
"params",
".",
"put",
"(",
"\"method\"",
",",
"\"flickr.stats.getPhotosetStats\"",
")",
";",
"params",
".",
"put",
"(",
"\"date\"",
",",
"JinxUtils",
".",
"formatDateAsYMD",
"(",
"date",
")",
")",
";",
"params",
".",
"put",
"(",
"\"photoset_id\"",
",",
"photosetId",
")",
";",
"return",
"jinx",
".",
"flickrGet",
"(",
"params",
",",
"Stats",
".",
"class",
")",
";",
"}"
] | Get the number of views on a photoset for a given date.
This method requires authentication with 'read' permission.
@param date stats will be returned for this date. Required.
@param photosetId id of the photoset to get stats for. Required.
@return number of views on a photoset for a given date.
@throws JinxException if required parameters are missing, or if there are any errors.
@see <a href="https://www.flickr.com/services/api/flickr.stats.getPhotosetStats.html">flickr.stats.getPhotosetStats</a> | [
"Get",
"the",
"number",
"of",
"views",
"on",
"a",
"photoset",
"for",
"a",
"given",
"date",
"."
] | train | https://github.com/jeremybrooks/jinx/blob/ab7a4b7462d08bcbfd9b98bd3f5029771c20f6c6/src/main/java/net/jeremybrooks/jinx/api/StatsApi.java#L310-L317 |
RobotiumTech/robotium | robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java | ViewFetcher.areViewsIdentical | private boolean areViewsIdentical(View firstView, View secondView) {
"""
Compares if the specified views are identical. This is used instead of View.compare
as it always returns false in cases where the View tree is refreshed.
@param firstView the first view
@param secondView the second view
@return true if views are equal
"""
if(firstView.getId() != secondView.getId() || !firstView.getClass().isAssignableFrom(secondView.getClass())){
return false;
}
if (firstView.getParent() != null && firstView.getParent() instanceof View &&
secondView.getParent() != null && secondView.getParent() instanceof View) {
return areViewsIdentical((View) firstView.getParent(), (View) secondView.getParent());
} else {
return true;
}
} | java | private boolean areViewsIdentical(View firstView, View secondView){
if(firstView.getId() != secondView.getId() || !firstView.getClass().isAssignableFrom(secondView.getClass())){
return false;
}
if (firstView.getParent() != null && firstView.getParent() instanceof View &&
secondView.getParent() != null && secondView.getParent() instanceof View) {
return areViewsIdentical((View) firstView.getParent(), (View) secondView.getParent());
} else {
return true;
}
} | [
"private",
"boolean",
"areViewsIdentical",
"(",
"View",
"firstView",
",",
"View",
"secondView",
")",
"{",
"if",
"(",
"firstView",
".",
"getId",
"(",
")",
"!=",
"secondView",
".",
"getId",
"(",
")",
"||",
"!",
"firstView",
".",
"getClass",
"(",
")",
".",
"isAssignableFrom",
"(",
"secondView",
".",
"getClass",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"firstView",
".",
"getParent",
"(",
")",
"!=",
"null",
"&&",
"firstView",
".",
"getParent",
"(",
")",
"instanceof",
"View",
"&&",
"secondView",
".",
"getParent",
"(",
")",
"!=",
"null",
"&&",
"secondView",
".",
"getParent",
"(",
")",
"instanceof",
"View",
")",
"{",
"return",
"areViewsIdentical",
"(",
"(",
"View",
")",
"firstView",
".",
"getParent",
"(",
")",
",",
"(",
"View",
")",
"secondView",
".",
"getParent",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}"
] | Compares if the specified views are identical. This is used instead of View.compare
as it always returns false in cases where the View tree is refreshed.
@param firstView the first view
@param secondView the second view
@return true if views are equal | [
"Compares",
"if",
"the",
"specified",
"views",
"are",
"identical",
".",
"This",
"is",
"used",
"instead",
"of",
"View",
".",
"compare",
"as",
"it",
"always",
"returns",
"false",
"in",
"cases",
"where",
"the",
"View",
"tree",
"is",
"refreshed",
"."
] | train | https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/ViewFetcher.java#L534-L546 |
Crab2died/Excel4J | src/main/java/com/github/crab2died/ExcelUtils.java | ExcelUtils.noTemplateSheet2Excel | public void noTemplateSheet2Excel(List<NoTemplateSheetWrapper> sheets, String targetPath)
throws Excel4JException, IOException {
"""
无模板、基于注解、多sheet数据
@param sheets 待导出sheet数据
@param targetPath 生成的Excel输出全路径
@throws Excel4JException 异常
@throws IOException 异常
"""
try (OutputStream fos = new FileOutputStream(targetPath);
Workbook workbook = exportExcelNoTemplateHandler(sheets, true)) {
workbook.write(fos);
}
} | java | public void noTemplateSheet2Excel(List<NoTemplateSheetWrapper> sheets, String targetPath)
throws Excel4JException, IOException {
try (OutputStream fos = new FileOutputStream(targetPath);
Workbook workbook = exportExcelNoTemplateHandler(sheets, true)) {
workbook.write(fos);
}
} | [
"public",
"void",
"noTemplateSheet2Excel",
"(",
"List",
"<",
"NoTemplateSheetWrapper",
">",
"sheets",
",",
"String",
"targetPath",
")",
"throws",
"Excel4JException",
",",
"IOException",
"{",
"try",
"(",
"OutputStream",
"fos",
"=",
"new",
"FileOutputStream",
"(",
"targetPath",
")",
";",
"Workbook",
"workbook",
"=",
"exportExcelNoTemplateHandler",
"(",
"sheets",
",",
"true",
")",
")",
"{",
"workbook",
".",
"write",
"(",
"fos",
")",
";",
"}",
"}"
] | 无模板、基于注解、多sheet数据
@param sheets 待导出sheet数据
@param targetPath 生成的Excel输出全路径
@throws Excel4JException 异常
@throws IOException 异常 | [
"无模板、基于注解、多sheet数据"
] | train | https://github.com/Crab2died/Excel4J/blob/2ab0a3b8226a69ff868c3ead6e724f3a774f5f77/src/main/java/com/github/crab2died/ExcelUtils.java#L1128-L1135 |
couchbase/couchbase-java-client | src/main/java/com/couchbase/client/java/query/dsl/functions/DateFunctions.java | DateFunctions.millisToStr | public static Expression millisToStr(String expression, String format) {
"""
Returned expression results in the string in the supported format to which
the UNIX milliseconds has been converted.
"""
return millisToStr(x(expression), format);
} | java | public static Expression millisToStr(String expression, String format) {
return millisToStr(x(expression), format);
} | [
"public",
"static",
"Expression",
"millisToStr",
"(",
"String",
"expression",
",",
"String",
"format",
")",
"{",
"return",
"millisToStr",
"(",
"x",
"(",
"expression",
")",
",",
"format",
")",
";",
"}"
] | Returned expression results in the string in the supported format to which
the UNIX milliseconds has been converted. | [
"Returned",
"expression",
"results",
"in",
"the",
"string",
"in",
"the",
"supported",
"format",
"to",
"which",
"the",
"UNIX",
"milliseconds",
"has",
"been",
"converted",
"."
] | train | https://github.com/couchbase/couchbase-java-client/blob/f36a0ee0c66923bdde47838ca543e50cbaa99e14/src/main/java/com/couchbase/client/java/query/dsl/functions/DateFunctions.java#L243-L245 |
micronaut-projects/micronaut-core | inject/src/main/java/io/micronaut/inject/annotation/AnnotationMetadataSupport.java | AnnotationMetadataSupport.registerDefaultValues | static void registerDefaultValues(String annotation, Map<String, Object> defaultValues) {
"""
Registers default values for the given annotation and values.
@param annotation The annotation
@param defaultValues The default values
"""
if (StringUtils.isNotEmpty(annotation)) {
ANNOTATION_DEFAULTS.put(annotation.intern(), defaultValues);
}
} | java | static void registerDefaultValues(String annotation, Map<String, Object> defaultValues) {
if (StringUtils.isNotEmpty(annotation)) {
ANNOTATION_DEFAULTS.put(annotation.intern(), defaultValues);
}
} | [
"static",
"void",
"registerDefaultValues",
"(",
"String",
"annotation",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"defaultValues",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isNotEmpty",
"(",
"annotation",
")",
")",
"{",
"ANNOTATION_DEFAULTS",
".",
"put",
"(",
"annotation",
".",
"intern",
"(",
")",
",",
"defaultValues",
")",
";",
"}",
"}"
] | Registers default values for the given annotation and values.
@param annotation The annotation
@param defaultValues The default values | [
"Registers",
"default",
"values",
"for",
"the",
"given",
"annotation",
"and",
"values",
"."
] | train | https://github.com/micronaut-projects/micronaut-core/blob/c31f5b03ce0eb88c2f6470710987db03b8967d5c/inject/src/main/java/io/micronaut/inject/annotation/AnnotationMetadataSupport.java#L166-L170 |
elki-project/elki | elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/invertedlist/InMemoryInvertedIndex.java | InMemoryInvertedIndex.naiveQuery | private double naiveQuery(V obj, WritableDoubleDataStore scores, HashSetModifiableDBIDs cands) {
"""
Query the most similar objects, abstract version.
@param obj Query object
@param scores Score storage (must be initialized with zeros!)
@param cands Non-zero objects set (must be empty)
@return Result
"""
if(obj instanceof SparseNumberVector) {
return naiveQuerySparse((SparseNumberVector) obj, scores, cands);
}
else {
return naiveQueryDense(obj, scores, cands);
}
} | java | private double naiveQuery(V obj, WritableDoubleDataStore scores, HashSetModifiableDBIDs cands) {
if(obj instanceof SparseNumberVector) {
return naiveQuerySparse((SparseNumberVector) obj, scores, cands);
}
else {
return naiveQueryDense(obj, scores, cands);
}
} | [
"private",
"double",
"naiveQuery",
"(",
"V",
"obj",
",",
"WritableDoubleDataStore",
"scores",
",",
"HashSetModifiableDBIDs",
"cands",
")",
"{",
"if",
"(",
"obj",
"instanceof",
"SparseNumberVector",
")",
"{",
"return",
"naiveQuerySparse",
"(",
"(",
"SparseNumberVector",
")",
"obj",
",",
"scores",
",",
"cands",
")",
";",
"}",
"else",
"{",
"return",
"naiveQueryDense",
"(",
"obj",
",",
"scores",
",",
"cands",
")",
";",
"}",
"}"
] | Query the most similar objects, abstract version.
@param obj Query object
@param scores Score storage (must be initialized with zeros!)
@param cands Non-zero objects set (must be empty)
@return Result | [
"Query",
"the",
"most",
"similar",
"objects",
"abstract",
"version",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/invertedlist/InMemoryInvertedIndex.java#L239-L246 |
UrielCh/ovh-java-sdk | ovh-java-sdk-licensevirtuozzo/src/main/java/net/minidev/ovh/api/ApiOvhLicensevirtuozzo.java | ApiOvhLicensevirtuozzo.orderableVersions_GET | public ArrayList<OvhVirtuozzoOrderConfiguration> orderableVersions_GET(String ip) throws IOException {
"""
Get the orderable Virtuozzo versions
REST: GET /license/virtuozzo/orderableVersions
@param ip [required] Your license Ip
"""
String qPath = "/license/virtuozzo/orderableVersions";
StringBuilder sb = path(qPath);
query(sb, "ip", ip);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t4);
} | java | public ArrayList<OvhVirtuozzoOrderConfiguration> orderableVersions_GET(String ip) throws IOException {
String qPath = "/license/virtuozzo/orderableVersions";
StringBuilder sb = path(qPath);
query(sb, "ip", ip);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t4);
} | [
"public",
"ArrayList",
"<",
"OvhVirtuozzoOrderConfiguration",
">",
"orderableVersions_GET",
"(",
"String",
"ip",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/license/virtuozzo/orderableVersions\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
")",
";",
"query",
"(",
"sb",
",",
"\"ip\"",
",",
"ip",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"t4",
")",
";",
"}"
] | Get the orderable Virtuozzo versions
REST: GET /license/virtuozzo/orderableVersions
@param ip [required] Your license Ip | [
"Get",
"the",
"orderable",
"Virtuozzo",
"versions"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-licensevirtuozzo/src/main/java/net/minidev/ovh/api/ApiOvhLicensevirtuozzo.java#L257-L263 |
indeedeng/util | util-core/src/main/java/com/indeed/util/core/sort/Quicksortables.java | Quicksortables.heapSort | public static void heapSort(Quicksortable q, int size) {
"""
sorts the elements in q using the heapsort method
@param q The quicksortable to heapsort.
@param size The size of the quicksortable.
"""
q = reverseQuicksortable(q);
makeHeap(q, size);
sortheap(q, size);
} | java | public static void heapSort(Quicksortable q, int size) {
q = reverseQuicksortable(q);
makeHeap(q, size);
sortheap(q, size);
} | [
"public",
"static",
"void",
"heapSort",
"(",
"Quicksortable",
"q",
",",
"int",
"size",
")",
"{",
"q",
"=",
"reverseQuicksortable",
"(",
"q",
")",
";",
"makeHeap",
"(",
"q",
",",
"size",
")",
";",
"sortheap",
"(",
"q",
",",
"size",
")",
";",
"}"
] | sorts the elements in q using the heapsort method
@param q The quicksortable to heapsort.
@param size The size of the quicksortable. | [
"sorts",
"the",
"elements",
"in",
"q",
"using",
"the",
"heapsort",
"method"
] | train | https://github.com/indeedeng/util/blob/332008426cf14b57e7fc3e817d9423e3f84fb922/util-core/src/main/java/com/indeed/util/core/sort/Quicksortables.java#L241-L245 |
dnsjava/dnsjava | org/xbill/DNS/ReverseMap.java | ReverseMap.fromAddress | public static Name
fromAddress(String addr, int family) throws UnknownHostException {
"""
Creates a reverse map name corresponding to an address contained in
a String.
@param addr The address from which to build a name.
@return The name corresponding to the address in the reverse map.
@throws UnknownHostException The string does not contain a valid address.
"""
byte [] array = Address.toByteArray(addr, family);
if (array == null)
throw new UnknownHostException("Invalid IP address");
return fromAddress(array);
} | java | public static Name
fromAddress(String addr, int family) throws UnknownHostException {
byte [] array = Address.toByteArray(addr, family);
if (array == null)
throw new UnknownHostException("Invalid IP address");
return fromAddress(array);
} | [
"public",
"static",
"Name",
"fromAddress",
"(",
"String",
"addr",
",",
"int",
"family",
")",
"throws",
"UnknownHostException",
"{",
"byte",
"[",
"]",
"array",
"=",
"Address",
".",
"toByteArray",
"(",
"addr",
",",
"family",
")",
";",
"if",
"(",
"array",
"==",
"null",
")",
"throw",
"new",
"UnknownHostException",
"(",
"\"Invalid IP address\"",
")",
";",
"return",
"fromAddress",
"(",
"array",
")",
";",
"}"
] | Creates a reverse map name corresponding to an address contained in
a String.
@param addr The address from which to build a name.
@return The name corresponding to the address in the reverse map.
@throws UnknownHostException The string does not contain a valid address. | [
"Creates",
"a",
"reverse",
"map",
"name",
"corresponding",
"to",
"an",
"address",
"contained",
"in",
"a",
"String",
"."
] | train | https://github.com/dnsjava/dnsjava/blob/d97b6a0685d59143372bb392ab591dd8dd840b61/org/xbill/DNS/ReverseMap.java#L105-L111 |
lukin0110/poeditor-java | src/main/java/be/lukin/poeditor/POEditorClient.java | POEditorClient.addContributor | public boolean addContributor(String projectId, String name, String email, String language) {
"""
Add/create a contributor for a language of a project
@param projectId id of the project
@param name name of the contributor
@param email email of the contributor
@param language language for the contributor
@return boolean if the contributor has been added
"""
ResponseWrapper wrapper = service.addProjectMember(Action.ADD_CONTRIBUTOR, apiKey, projectId, name, email, language, 0);
ApiUtils.checkResponse(wrapper.response);
return "200".equals(wrapper.response.code);
} | java | public boolean addContributor(String projectId, String name, String email, String language){
ResponseWrapper wrapper = service.addProjectMember(Action.ADD_CONTRIBUTOR, apiKey, projectId, name, email, language, 0);
ApiUtils.checkResponse(wrapper.response);
return "200".equals(wrapper.response.code);
} | [
"public",
"boolean",
"addContributor",
"(",
"String",
"projectId",
",",
"String",
"name",
",",
"String",
"email",
",",
"String",
"language",
")",
"{",
"ResponseWrapper",
"wrapper",
"=",
"service",
".",
"addProjectMember",
"(",
"Action",
".",
"ADD_CONTRIBUTOR",
",",
"apiKey",
",",
"projectId",
",",
"name",
",",
"email",
",",
"language",
",",
"0",
")",
";",
"ApiUtils",
".",
"checkResponse",
"(",
"wrapper",
".",
"response",
")",
";",
"return",
"\"200\"",
".",
"equals",
"(",
"wrapper",
".",
"response",
".",
"code",
")",
";",
"}"
] | Add/create a contributor for a language of a project
@param projectId id of the project
@param name name of the contributor
@param email email of the contributor
@param language language for the contributor
@return boolean if the contributor has been added | [
"Add",
"/",
"create",
"a",
"contributor",
"for",
"a",
"language",
"of",
"a",
"project"
] | train | https://github.com/lukin0110/poeditor-java/blob/42a2cd3136da1276b29a57a483c94050cc7d1d01/src/main/java/be/lukin/poeditor/POEditorClient.java#L197-L201 |
alkacon/opencms-core | src/org/opencms/widgets/A_CmsAdeGalleryWidget.java | A_CmsAdeGalleryWidget.getWidgetConfiguration | protected CmsGalleryWidgetConfiguration getWidgetConfiguration(
CmsObject cms,
CmsMessages messages,
I_CmsWidgetParameter param) {
"""
Returns the widget configuration.<p>
@param cms an initialized instance of a CmsObject
@param messages the dialog where the widget is used on
@param param the widget parameter to generate the widget for
@return the widget configuration
"""
if (m_widgetConfiguration == null) {
m_widgetConfiguration = new CmsGalleryWidgetConfiguration(cms, messages, param, getConfiguration());
}
return m_widgetConfiguration;
} | java | protected CmsGalleryWidgetConfiguration getWidgetConfiguration(
CmsObject cms,
CmsMessages messages,
I_CmsWidgetParameter param) {
if (m_widgetConfiguration == null) {
m_widgetConfiguration = new CmsGalleryWidgetConfiguration(cms, messages, param, getConfiguration());
}
return m_widgetConfiguration;
} | [
"protected",
"CmsGalleryWidgetConfiguration",
"getWidgetConfiguration",
"(",
"CmsObject",
"cms",
",",
"CmsMessages",
"messages",
",",
"I_CmsWidgetParameter",
"param",
")",
"{",
"if",
"(",
"m_widgetConfiguration",
"==",
"null",
")",
"{",
"m_widgetConfiguration",
"=",
"new",
"CmsGalleryWidgetConfiguration",
"(",
"cms",
",",
"messages",
",",
"param",
",",
"getConfiguration",
"(",
")",
")",
";",
"}",
"return",
"m_widgetConfiguration",
";",
"}"
] | Returns the widget configuration.<p>
@param cms an initialized instance of a CmsObject
@param messages the dialog where the widget is used on
@param param the widget parameter to generate the widget for
@return the widget configuration | [
"Returns",
"the",
"widget",
"configuration",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/widgets/A_CmsAdeGalleryWidget.java#L451-L460 |
Azure/azure-sdk-for-java | network/resource-manager/v2017_10_01/src/main/java/com/microsoft/azure/management/network/v2017_10_01/implementation/VirtualNetworkPeeringsInner.java | VirtualNetworkPeeringsInner.beginCreateOrUpdate | public VirtualNetworkPeeringInner beginCreateOrUpdate(String resourceGroupName, String virtualNetworkName, String virtualNetworkPeeringName, VirtualNetworkPeeringInner virtualNetworkPeeringParameters) {
"""
Creates or updates a peering in the specified virtual network.
@param resourceGroupName The name of the resource group.
@param virtualNetworkName The name of the virtual network.
@param virtualNetworkPeeringName The name of the peering.
@param virtualNetworkPeeringParameters Parameters supplied to the create or update virtual network peering operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the VirtualNetworkPeeringInner object if successful.
"""
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName, virtualNetworkPeeringParameters).toBlocking().single().body();
} | java | public VirtualNetworkPeeringInner beginCreateOrUpdate(String resourceGroupName, String virtualNetworkName, String virtualNetworkPeeringName, VirtualNetworkPeeringInner virtualNetworkPeeringParameters) {
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName, virtualNetworkPeeringParameters).toBlocking().single().body();
} | [
"public",
"VirtualNetworkPeeringInner",
"beginCreateOrUpdate",
"(",
"String",
"resourceGroupName",
",",
"String",
"virtualNetworkName",
",",
"String",
"virtualNetworkPeeringName",
",",
"VirtualNetworkPeeringInner",
"virtualNetworkPeeringParameters",
")",
"{",
"return",
"beginCreateOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"virtualNetworkName",
",",
"virtualNetworkPeeringName",
",",
"virtualNetworkPeeringParameters",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Creates or updates a peering in the specified virtual network.
@param resourceGroupName The name of the resource group.
@param virtualNetworkName The name of the virtual network.
@param virtualNetworkPeeringName The name of the peering.
@param virtualNetworkPeeringParameters Parameters supplied to the create or update virtual network peering operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the VirtualNetworkPeeringInner object if successful. | [
"Creates",
"or",
"updates",
"a",
"peering",
"in",
"the",
"specified",
"virtual",
"network",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2017_10_01/src/main/java/com/microsoft/azure/management/network/v2017_10_01/implementation/VirtualNetworkPeeringsInner.java#L444-L446 |
revapi/revapi | revapi/src/main/java/org/revapi/AnalysisResult.java | AnalysisResult.fakeFailure | public static AnalysisResult fakeFailure(Exception failure) {
"""
Similar to {@link #fakeSuccess()}, this returns a failed analysis result without the need to run any analysis.
@param failure the failure to report
@return a "fake" failed analysis result
"""
return new AnalysisResult(failure, new Extensions(Collections.emptyMap(), Collections.emptyMap(),
Collections.emptyMap(), Collections.emptyMap()));
} | java | public static AnalysisResult fakeFailure(Exception failure) {
return new AnalysisResult(failure, new Extensions(Collections.emptyMap(), Collections.emptyMap(),
Collections.emptyMap(), Collections.emptyMap()));
} | [
"public",
"static",
"AnalysisResult",
"fakeFailure",
"(",
"Exception",
"failure",
")",
"{",
"return",
"new",
"AnalysisResult",
"(",
"failure",
",",
"new",
"Extensions",
"(",
"Collections",
".",
"emptyMap",
"(",
")",
",",
"Collections",
".",
"emptyMap",
"(",
")",
",",
"Collections",
".",
"emptyMap",
"(",
")",
",",
"Collections",
".",
"emptyMap",
"(",
")",
")",
")",
";",
"}"
] | Similar to {@link #fakeSuccess()}, this returns a failed analysis result without the need to run any analysis.
@param failure the failure to report
@return a "fake" failed analysis result | [
"Similar",
"to",
"{",
"@link",
"#fakeSuccess",
"()",
"}",
"this",
"returns",
"a",
"failed",
"analysis",
"result",
"without",
"the",
"need",
"to",
"run",
"any",
"analysis",
"."
] | train | https://github.com/revapi/revapi/blob/e070b136d977441ab96fdce067a13e7e0423295b/revapi/src/main/java/org/revapi/AnalysisResult.java#L69-L72 |
aws/aws-sdk-java | aws-java-sdk-core/src/main/java/com/amazonaws/util/RuntimeHttpUtils.java | RuntimeHttpUtils.fetchFile | @SuppressWarnings("deprecation")
public static InputStream fetchFile(
final URI uri,
final ClientConfiguration config) throws IOException {
"""
Fetches a file from the URI given and returns an input stream to it.
@param uri the uri of the file to fetch
@param config optional configuration overrides
@return an InputStream containing the retrieved data
@throws IOException on error
"""
HttpParams httpClientParams = new BasicHttpParams();
HttpProtocolParams.setUserAgent(
httpClientParams, getUserAgent(config, null));
HttpConnectionParams.setConnectionTimeout(
httpClientParams, getConnectionTimeout(config));
HttpConnectionParams.setSoTimeout(
httpClientParams, getSocketTimeout(config));
DefaultHttpClient httpclient = new DefaultHttpClient(httpClientParams);
if (config != null) {
String proxyHost = config.getProxyHost();
int proxyPort = config.getProxyPort();
if (proxyHost != null && proxyPort > 0) {
HttpHost proxy = new HttpHost(proxyHost, proxyPort);
httpclient.getParams().setParameter(
ConnRoutePNames.DEFAULT_PROXY, proxy);
if (config.getProxyUsername() != null
&& config.getProxyPassword() != null) {
httpclient.getCredentialsProvider().setCredentials(
new AuthScope(proxyHost, proxyPort),
new NTCredentials(config.getProxyUsername(),
config.getProxyPassword(),
config.getProxyWorkstation(),
config.getProxyDomain()));
}
}
}
HttpResponse response = httpclient.execute(new HttpGet(uri));
if (response.getStatusLine().getStatusCode() != 200) {
throw new IOException("Error fetching file from " + uri + ": "
+ response);
}
return new HttpClientWrappingInputStream(
httpclient,
response.getEntity().getContent());
} | java | @SuppressWarnings("deprecation")
public static InputStream fetchFile(
final URI uri,
final ClientConfiguration config) throws IOException {
HttpParams httpClientParams = new BasicHttpParams();
HttpProtocolParams.setUserAgent(
httpClientParams, getUserAgent(config, null));
HttpConnectionParams.setConnectionTimeout(
httpClientParams, getConnectionTimeout(config));
HttpConnectionParams.setSoTimeout(
httpClientParams, getSocketTimeout(config));
DefaultHttpClient httpclient = new DefaultHttpClient(httpClientParams);
if (config != null) {
String proxyHost = config.getProxyHost();
int proxyPort = config.getProxyPort();
if (proxyHost != null && proxyPort > 0) {
HttpHost proxy = new HttpHost(proxyHost, proxyPort);
httpclient.getParams().setParameter(
ConnRoutePNames.DEFAULT_PROXY, proxy);
if (config.getProxyUsername() != null
&& config.getProxyPassword() != null) {
httpclient.getCredentialsProvider().setCredentials(
new AuthScope(proxyHost, proxyPort),
new NTCredentials(config.getProxyUsername(),
config.getProxyPassword(),
config.getProxyWorkstation(),
config.getProxyDomain()));
}
}
}
HttpResponse response = httpclient.execute(new HttpGet(uri));
if (response.getStatusLine().getStatusCode() != 200) {
throw new IOException("Error fetching file from " + uri + ": "
+ response);
}
return new HttpClientWrappingInputStream(
httpclient,
response.getEntity().getContent());
} | [
"@",
"SuppressWarnings",
"(",
"\"deprecation\"",
")",
"public",
"static",
"InputStream",
"fetchFile",
"(",
"final",
"URI",
"uri",
",",
"final",
"ClientConfiguration",
"config",
")",
"throws",
"IOException",
"{",
"HttpParams",
"httpClientParams",
"=",
"new",
"BasicHttpParams",
"(",
")",
";",
"HttpProtocolParams",
".",
"setUserAgent",
"(",
"httpClientParams",
",",
"getUserAgent",
"(",
"config",
",",
"null",
")",
")",
";",
"HttpConnectionParams",
".",
"setConnectionTimeout",
"(",
"httpClientParams",
",",
"getConnectionTimeout",
"(",
"config",
")",
")",
";",
"HttpConnectionParams",
".",
"setSoTimeout",
"(",
"httpClientParams",
",",
"getSocketTimeout",
"(",
"config",
")",
")",
";",
"DefaultHttpClient",
"httpclient",
"=",
"new",
"DefaultHttpClient",
"(",
"httpClientParams",
")",
";",
"if",
"(",
"config",
"!=",
"null",
")",
"{",
"String",
"proxyHost",
"=",
"config",
".",
"getProxyHost",
"(",
")",
";",
"int",
"proxyPort",
"=",
"config",
".",
"getProxyPort",
"(",
")",
";",
"if",
"(",
"proxyHost",
"!=",
"null",
"&&",
"proxyPort",
">",
"0",
")",
"{",
"HttpHost",
"proxy",
"=",
"new",
"HttpHost",
"(",
"proxyHost",
",",
"proxyPort",
")",
";",
"httpclient",
".",
"getParams",
"(",
")",
".",
"setParameter",
"(",
"ConnRoutePNames",
".",
"DEFAULT_PROXY",
",",
"proxy",
")",
";",
"if",
"(",
"config",
".",
"getProxyUsername",
"(",
")",
"!=",
"null",
"&&",
"config",
".",
"getProxyPassword",
"(",
")",
"!=",
"null",
")",
"{",
"httpclient",
".",
"getCredentialsProvider",
"(",
")",
".",
"setCredentials",
"(",
"new",
"AuthScope",
"(",
"proxyHost",
",",
"proxyPort",
")",
",",
"new",
"NTCredentials",
"(",
"config",
".",
"getProxyUsername",
"(",
")",
",",
"config",
".",
"getProxyPassword",
"(",
")",
",",
"config",
".",
"getProxyWorkstation",
"(",
")",
",",
"config",
".",
"getProxyDomain",
"(",
")",
")",
")",
";",
"}",
"}",
"}",
"HttpResponse",
"response",
"=",
"httpclient",
".",
"execute",
"(",
"new",
"HttpGet",
"(",
"uri",
")",
")",
";",
"if",
"(",
"response",
".",
"getStatusLine",
"(",
")",
".",
"getStatusCode",
"(",
")",
"!=",
"200",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Error fetching file from \"",
"+",
"uri",
"+",
"\": \"",
"+",
"response",
")",
";",
"}",
"return",
"new",
"HttpClientWrappingInputStream",
"(",
"httpclient",
",",
"response",
".",
"getEntity",
"(",
")",
".",
"getContent",
"(",
")",
")",
";",
"}"
] | Fetches a file from the URI given and returns an input stream to it.
@param uri the uri of the file to fetch
@param config optional configuration overrides
@return an InputStream containing the retrieved data
@throws IOException on error | [
"Fetches",
"a",
"file",
"from",
"the",
"URI",
"given",
"and",
"returns",
"an",
"input",
"stream",
"to",
"it",
"."
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-core/src/main/java/com/amazonaws/util/RuntimeHttpUtils.java#L60-L109 |
Azure/azure-sdk-for-java | batch/data-plane/src/main/java/com/microsoft/azure/batch/PoolOperations.java | PoolOperations.enableAutoScale | public void enableAutoScale(String poolId, String autoScaleFormula) throws BatchErrorException, IOException {
"""
Enables automatic scaling on the specified pool.
@param poolId
The ID of the pool.
@param autoScaleFormula
The formula for the desired number of compute nodes in the pool.
@throws BatchErrorException
Exception thrown when an error response is received from the
Batch service.
@throws IOException
Exception thrown when there is an error in
serialization/deserialization of data sent to/received from the
Batch service.
"""
enableAutoScale(poolId, autoScaleFormula, null, null);
} | java | public void enableAutoScale(String poolId, String autoScaleFormula) throws BatchErrorException, IOException {
enableAutoScale(poolId, autoScaleFormula, null, null);
} | [
"public",
"void",
"enableAutoScale",
"(",
"String",
"poolId",
",",
"String",
"autoScaleFormula",
")",
"throws",
"BatchErrorException",
",",
"IOException",
"{",
"enableAutoScale",
"(",
"poolId",
",",
"autoScaleFormula",
",",
"null",
",",
"null",
")",
";",
"}"
] | Enables automatic scaling on the specified pool.
@param poolId
The ID of the pool.
@param autoScaleFormula
The formula for the desired number of compute nodes in the pool.
@throws BatchErrorException
Exception thrown when an error response is received from the
Batch service.
@throws IOException
Exception thrown when there is an error in
serialization/deserialization of data sent to/received from the
Batch service. | [
"Enables",
"automatic",
"scaling",
"on",
"the",
"specified",
"pool",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batch/data-plane/src/main/java/com/microsoft/azure/batch/PoolOperations.java#L690-L692 |
googleapis/google-cloud-java | google-cloud-clients/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/JobControllerClient.java | JobControllerClient.submitJob | public final Job submitJob(String projectId, String region, Job job) {
"""
Submits a job to a cluster.
<p>Sample code:
<pre><code>
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
String projectId = "";
String region = "";
Job job = Job.newBuilder().build();
Job response = jobControllerClient.submitJob(projectId, region, job);
}
</code></pre>
@param projectId Required. The ID of the Google Cloud Platform project that the job belongs to.
@param region Required. The Cloud Dataproc region in which to handle the request.
@param job Required. The job resource.
@throws com.google.api.gax.rpc.ApiException if the remote call fails
"""
SubmitJobRequest request =
SubmitJobRequest.newBuilder().setProjectId(projectId).setRegion(region).setJob(job).build();
return submitJob(request);
} | java | public final Job submitJob(String projectId, String region, Job job) {
SubmitJobRequest request =
SubmitJobRequest.newBuilder().setProjectId(projectId).setRegion(region).setJob(job).build();
return submitJob(request);
} | [
"public",
"final",
"Job",
"submitJob",
"(",
"String",
"projectId",
",",
"String",
"region",
",",
"Job",
"job",
")",
"{",
"SubmitJobRequest",
"request",
"=",
"SubmitJobRequest",
".",
"newBuilder",
"(",
")",
".",
"setProjectId",
"(",
"projectId",
")",
".",
"setRegion",
"(",
"region",
")",
".",
"setJob",
"(",
"job",
")",
".",
"build",
"(",
")",
";",
"return",
"submitJob",
"(",
"request",
")",
";",
"}"
] | Submits a job to a cluster.
<p>Sample code:
<pre><code>
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
String projectId = "";
String region = "";
Job job = Job.newBuilder().build();
Job response = jobControllerClient.submitJob(projectId, region, job);
}
</code></pre>
@param projectId Required. The ID of the Google Cloud Platform project that the job belongs to.
@param region Required. The Cloud Dataproc region in which to handle the request.
@param job Required. The job resource.
@throws com.google.api.gax.rpc.ApiException if the remote call fails | [
"Submits",
"a",
"job",
"to",
"a",
"cluster",
"."
] | train | https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/JobControllerClient.java#L179-L184 |
powermock/powermock | powermock-api/powermock-api-support/src/main/java/org/powermock/api/support/Stubber.java | Stubber.stubMethod | public static void stubMethod(Class<?> declaringClass, String methodName, Object returnObject) {
"""
Add a method that should be intercepted and return another value (
{@code returnObject}) (i.e. the method is stubbed).
"""
if (declaringClass == null) {
throw new IllegalArgumentException("declaringClass cannot be null");
}
if (methodName == null || methodName.length() == 0) {
throw new IllegalArgumentException("methodName cannot be empty");
}
Method[] methods = Whitebox.getMethods(declaringClass, methodName);
if (methods.length == 0) {
throw new MethodNotFoundException(String.format("Couldn't find a method with name %s in the class hierarchy of %s", methodName,
declaringClass.getName()));
} else if (methods.length > 1) {
throw new TooManyMethodsFoundException(String.format("Found %d methods with name %s in the class hierarchy of %s.", methods.length,
methodName, declaringClass.getName()));
}
MockRepository.putMethodToStub(methods[0], returnObject);
} | java | public static void stubMethod(Class<?> declaringClass, String methodName, Object returnObject) {
if (declaringClass == null) {
throw new IllegalArgumentException("declaringClass cannot be null");
}
if (methodName == null || methodName.length() == 0) {
throw new IllegalArgumentException("methodName cannot be empty");
}
Method[] methods = Whitebox.getMethods(declaringClass, methodName);
if (methods.length == 0) {
throw new MethodNotFoundException(String.format("Couldn't find a method with name %s in the class hierarchy of %s", methodName,
declaringClass.getName()));
} else if (methods.length > 1) {
throw new TooManyMethodsFoundException(String.format("Found %d methods with name %s in the class hierarchy of %s.", methods.length,
methodName, declaringClass.getName()));
}
MockRepository.putMethodToStub(methods[0], returnObject);
} | [
"public",
"static",
"void",
"stubMethod",
"(",
"Class",
"<",
"?",
">",
"declaringClass",
",",
"String",
"methodName",
",",
"Object",
"returnObject",
")",
"{",
"if",
"(",
"declaringClass",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"declaringClass cannot be null\"",
")",
";",
"}",
"if",
"(",
"methodName",
"==",
"null",
"||",
"methodName",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"methodName cannot be empty\"",
")",
";",
"}",
"Method",
"[",
"]",
"methods",
"=",
"Whitebox",
".",
"getMethods",
"(",
"declaringClass",
",",
"methodName",
")",
";",
"if",
"(",
"methods",
".",
"length",
"==",
"0",
")",
"{",
"throw",
"new",
"MethodNotFoundException",
"(",
"String",
".",
"format",
"(",
"\"Couldn't find a method with name %s in the class hierarchy of %s\"",
",",
"methodName",
",",
"declaringClass",
".",
"getName",
"(",
")",
")",
")",
";",
"}",
"else",
"if",
"(",
"methods",
".",
"length",
">",
"1",
")",
"{",
"throw",
"new",
"TooManyMethodsFoundException",
"(",
"String",
".",
"format",
"(",
"\"Found %d methods with name %s in the class hierarchy of %s.\"",
",",
"methods",
".",
"length",
",",
"methodName",
",",
"declaringClass",
".",
"getName",
"(",
")",
")",
")",
";",
"}",
"MockRepository",
".",
"putMethodToStub",
"(",
"methods",
"[",
"0",
"]",
",",
"returnObject",
")",
";",
"}"
] | Add a method that should be intercepted and return another value (
{@code returnObject}) (i.e. the method is stubbed). | [
"Add",
"a",
"method",
"that",
"should",
"be",
"intercepted",
"and",
"return",
"another",
"value",
"(",
"{"
] | train | https://github.com/powermock/powermock/blob/e8cd68026c284c6a7efe66959809eeebd8d1f9ad/powermock-api/powermock-api-support/src/main/java/org/powermock/api/support/Stubber.java#L38-L55 |
OpenLiberty/open-liberty | dev/com.ibm.ws.kernel.feature.cmdline/src/com/ibm/ws/kernel/feature/internal/generator/ManifestFileProcessor.java | ManifestFileProcessor.getUsrProductFeatureDefinitions | private Map<String, ProvisioningFeatureDefinition> getUsrProductFeatureDefinitions() {
"""
Retrieves a Map of feature definitions in default usr product extension location
@return Null if the user directory cannot be found. An empty map if the features manifests cannot
be found. A Map of product extension features if all goes well.
"""
Map<String, ProvisioningFeatureDefinition> features = null;
File userDir = Utils.getUserDir();
if (userDir != null && userDir.exists()) {
File userFeatureDir = new File(userDir, USER_FEATURE_DIR);
if (userFeatureDir.exists()) {
features = new TreeMap<String, ProvisioningFeatureDefinition>();
File[] userManifestFiles = userFeatureDir.listFiles(MFFilter);
if (userManifestFiles != null) {
for (File file : userManifestFiles) {
try {
ProvisioningFeatureDefinition fd = new SubsystemFeatureDefinitionImpl(USR_PRODUCT_EXT_NAME, file);
features.put(fd.getSymbolicName(), fd);
} catch (IOException e) {
// TODO: PROPER NLS MESSAGE
throw new FeatureToolException("Unable to read feature manifest from user extension: " + file,
(String) null,
e,
ReturnCode.BAD_FEATURE_DEFINITION);
}
}
}
}
}
return features;
} | java | private Map<String, ProvisioningFeatureDefinition> getUsrProductFeatureDefinitions() {
Map<String, ProvisioningFeatureDefinition> features = null;
File userDir = Utils.getUserDir();
if (userDir != null && userDir.exists()) {
File userFeatureDir = new File(userDir, USER_FEATURE_DIR);
if (userFeatureDir.exists()) {
features = new TreeMap<String, ProvisioningFeatureDefinition>();
File[] userManifestFiles = userFeatureDir.listFiles(MFFilter);
if (userManifestFiles != null) {
for (File file : userManifestFiles) {
try {
ProvisioningFeatureDefinition fd = new SubsystemFeatureDefinitionImpl(USR_PRODUCT_EXT_NAME, file);
features.put(fd.getSymbolicName(), fd);
} catch (IOException e) {
// TODO: PROPER NLS MESSAGE
throw new FeatureToolException("Unable to read feature manifest from user extension: " + file,
(String) null,
e,
ReturnCode.BAD_FEATURE_DEFINITION);
}
}
}
}
}
return features;
} | [
"private",
"Map",
"<",
"String",
",",
"ProvisioningFeatureDefinition",
">",
"getUsrProductFeatureDefinitions",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"ProvisioningFeatureDefinition",
">",
"features",
"=",
"null",
";",
"File",
"userDir",
"=",
"Utils",
".",
"getUserDir",
"(",
")",
";",
"if",
"(",
"userDir",
"!=",
"null",
"&&",
"userDir",
".",
"exists",
"(",
")",
")",
"{",
"File",
"userFeatureDir",
"=",
"new",
"File",
"(",
"userDir",
",",
"USER_FEATURE_DIR",
")",
";",
"if",
"(",
"userFeatureDir",
".",
"exists",
"(",
")",
")",
"{",
"features",
"=",
"new",
"TreeMap",
"<",
"String",
",",
"ProvisioningFeatureDefinition",
">",
"(",
")",
";",
"File",
"[",
"]",
"userManifestFiles",
"=",
"userFeatureDir",
".",
"listFiles",
"(",
"MFFilter",
")",
";",
"if",
"(",
"userManifestFiles",
"!=",
"null",
")",
"{",
"for",
"(",
"File",
"file",
":",
"userManifestFiles",
")",
"{",
"try",
"{",
"ProvisioningFeatureDefinition",
"fd",
"=",
"new",
"SubsystemFeatureDefinitionImpl",
"(",
"USR_PRODUCT_EXT_NAME",
",",
"file",
")",
";",
"features",
".",
"put",
"(",
"fd",
".",
"getSymbolicName",
"(",
")",
",",
"fd",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"// TODO: PROPER NLS MESSAGE",
"throw",
"new",
"FeatureToolException",
"(",
"\"Unable to read feature manifest from user extension: \"",
"+",
"file",
",",
"(",
"String",
")",
"null",
",",
"e",
",",
"ReturnCode",
".",
"BAD_FEATURE_DEFINITION",
")",
";",
"}",
"}",
"}",
"}",
"}",
"return",
"features",
";",
"}"
] | Retrieves a Map of feature definitions in default usr product extension location
@return Null if the user directory cannot be found. An empty map if the features manifests cannot
be found. A Map of product extension features if all goes well. | [
"Retrieves",
"a",
"Map",
"of",
"feature",
"definitions",
"in",
"default",
"usr",
"product",
"extension",
"location"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.feature.cmdline/src/com/ibm/ws/kernel/feature/internal/generator/ManifestFileProcessor.java#L287-L313 |
xetorthio/jedis | src/main/java/redis/clients/jedis/BinaryJedis.java | BinaryJedis.sismember | @Override
public Boolean sismember(final byte[] key, final byte[] member) {
"""
Return true if member is a member of the set stored at key, otherwise false is returned.
<p>
Time complexity O(1)
@param key
@param member
@return Boolean reply, specifically: true if the element is a member of the set false if the element
is not a member of the set OR if the key does not exist
"""
checkIsInMultiOrPipeline();
client.sismember(key, member);
return client.getIntegerReply() == 1;
} | java | @Override
public Boolean sismember(final byte[] key, final byte[] member) {
checkIsInMultiOrPipeline();
client.sismember(key, member);
return client.getIntegerReply() == 1;
} | [
"@",
"Override",
"public",
"Boolean",
"sismember",
"(",
"final",
"byte",
"[",
"]",
"key",
",",
"final",
"byte",
"[",
"]",
"member",
")",
"{",
"checkIsInMultiOrPipeline",
"(",
")",
";",
"client",
".",
"sismember",
"(",
"key",
",",
"member",
")",
";",
"return",
"client",
".",
"getIntegerReply",
"(",
")",
"==",
"1",
";",
"}"
] | Return true if member is a member of the set stored at key, otherwise false is returned.
<p>
Time complexity O(1)
@param key
@param member
@return Boolean reply, specifically: true if the element is a member of the set false if the element
is not a member of the set OR if the key does not exist | [
"Return",
"true",
"if",
"member",
"is",
"a",
"member",
"of",
"the",
"set",
"stored",
"at",
"key",
"otherwise",
"false",
"is",
"returned",
".",
"<p",
">",
"Time",
"complexity",
"O",
"(",
"1",
")"
] | train | https://github.com/xetorthio/jedis/blob/ef4ab403f9d8fd88bd05092fea96de2e9db0bede/src/main/java/redis/clients/jedis/BinaryJedis.java#L1496-L1501 |
looly/hutool | hutool-cron/src/main/java/cn/hutool/cron/Scheduler.java | Scheduler.schedule | public String schedule(String pattern, Task task) {
"""
新增Task,使用随机UUID
@param pattern {@link CronPattern}对应的String表达式
@param task {@link Task}
@return ID
"""
String id = UUID.randomUUID().toString();
schedule(id, pattern, task);
return id;
} | java | public String schedule(String pattern, Task task) {
String id = UUID.randomUUID().toString();
schedule(id, pattern, task);
return id;
} | [
"public",
"String",
"schedule",
"(",
"String",
"pattern",
",",
"Task",
"task",
")",
"{",
"String",
"id",
"=",
"UUID",
".",
"randomUUID",
"(",
")",
".",
"toString",
"(",
")",
";",
"schedule",
"(",
"id",
",",
"pattern",
",",
"task",
")",
";",
"return",
"id",
";",
"}"
] | 新增Task,使用随机UUID
@param pattern {@link CronPattern}对应的String表达式
@param task {@link Task}
@return ID | [
"新增Task,使用随机UUID"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-cron/src/main/java/cn/hutool/cron/Scheduler.java#L217-L221 |
primefaces/primefaces | src/main/java/org/primefaces/component/imagecropper/ImageCropperRenderer.java | ImageCropperRenderer.getImageResource | private Resource getImageResource(FacesContext facesContext, ImageCropper imageCropper) {
"""
Attempt to obtain the resource from the server by parsing the valueExpression of the image attribute. Returns null
if the valueExpression is not of the form #{resource['path/to/resource']} or #{resource['library:name']}. Otherwise
returns the value obtained by ResourceHandler.createResource().
"""
Resource resource = null;
ValueExpression imageValueExpression = imageCropper.getValueExpression(ImageCropper.PropertyKeys.image.toString());
if (imageValueExpression != null) {
String imageValueExpressionString = imageValueExpression.getExpressionString();
if (imageValueExpressionString.matches("^[#][{]resource\\['[^']+'\\][}]$")) {
imageValueExpressionString = imageValueExpressionString.replaceFirst("^[#][{]resource\\['", "");
imageValueExpressionString = imageValueExpressionString.replaceFirst("'\\][}]$", "");
String resourceLibrary = null;
String resourceName;
String[] resourceInfo = imageValueExpressionString.split(":");
if (resourceInfo.length == 2) {
resourceLibrary = resourceInfo[0];
resourceName = resourceInfo[1];
}
else {
resourceName = resourceInfo[0];
}
if (resourceName != null) {
Application application = facesContext.getApplication();
ResourceHandler resourceHandler = application.getResourceHandler();
if (resourceLibrary != null) {
resource = resourceHandler.createResource(resourceName, resourceLibrary);
}
else {
resource = resourceHandler.createResource(resourceName);
}
}
}
}
return resource;
} | java | private Resource getImageResource(FacesContext facesContext, ImageCropper imageCropper) {
Resource resource = null;
ValueExpression imageValueExpression = imageCropper.getValueExpression(ImageCropper.PropertyKeys.image.toString());
if (imageValueExpression != null) {
String imageValueExpressionString = imageValueExpression.getExpressionString();
if (imageValueExpressionString.matches("^[#][{]resource\\['[^']+'\\][}]$")) {
imageValueExpressionString = imageValueExpressionString.replaceFirst("^[#][{]resource\\['", "");
imageValueExpressionString = imageValueExpressionString.replaceFirst("'\\][}]$", "");
String resourceLibrary = null;
String resourceName;
String[] resourceInfo = imageValueExpressionString.split(":");
if (resourceInfo.length == 2) {
resourceLibrary = resourceInfo[0];
resourceName = resourceInfo[1];
}
else {
resourceName = resourceInfo[0];
}
if (resourceName != null) {
Application application = facesContext.getApplication();
ResourceHandler resourceHandler = application.getResourceHandler();
if (resourceLibrary != null) {
resource = resourceHandler.createResource(resourceName, resourceLibrary);
}
else {
resource = resourceHandler.createResource(resourceName);
}
}
}
}
return resource;
} | [
"private",
"Resource",
"getImageResource",
"(",
"FacesContext",
"facesContext",
",",
"ImageCropper",
"imageCropper",
")",
"{",
"Resource",
"resource",
"=",
"null",
";",
"ValueExpression",
"imageValueExpression",
"=",
"imageCropper",
".",
"getValueExpression",
"(",
"ImageCropper",
".",
"PropertyKeys",
".",
"image",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"imageValueExpression",
"!=",
"null",
")",
"{",
"String",
"imageValueExpressionString",
"=",
"imageValueExpression",
".",
"getExpressionString",
"(",
")",
";",
"if",
"(",
"imageValueExpressionString",
".",
"matches",
"(",
"\"^[#][{]resource\\\\['[^']+'\\\\][}]$\"",
")",
")",
"{",
"imageValueExpressionString",
"=",
"imageValueExpressionString",
".",
"replaceFirst",
"(",
"\"^[#][{]resource\\\\['\"",
",",
"\"\"",
")",
";",
"imageValueExpressionString",
"=",
"imageValueExpressionString",
".",
"replaceFirst",
"(",
"\"'\\\\][}]$\"",
",",
"\"\"",
")",
";",
"String",
"resourceLibrary",
"=",
"null",
";",
"String",
"resourceName",
";",
"String",
"[",
"]",
"resourceInfo",
"=",
"imageValueExpressionString",
".",
"split",
"(",
"\":\"",
")",
";",
"if",
"(",
"resourceInfo",
".",
"length",
"==",
"2",
")",
"{",
"resourceLibrary",
"=",
"resourceInfo",
"[",
"0",
"]",
";",
"resourceName",
"=",
"resourceInfo",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"resourceName",
"=",
"resourceInfo",
"[",
"0",
"]",
";",
"}",
"if",
"(",
"resourceName",
"!=",
"null",
")",
"{",
"Application",
"application",
"=",
"facesContext",
".",
"getApplication",
"(",
")",
";",
"ResourceHandler",
"resourceHandler",
"=",
"application",
".",
"getResourceHandler",
"(",
")",
";",
"if",
"(",
"resourceLibrary",
"!=",
"null",
")",
"{",
"resource",
"=",
"resourceHandler",
".",
"createResource",
"(",
"resourceName",
",",
"resourceLibrary",
")",
";",
"}",
"else",
"{",
"resource",
"=",
"resourceHandler",
".",
"createResource",
"(",
"resourceName",
")",
";",
"}",
"}",
"}",
"}",
"return",
"resource",
";",
"}"
] | Attempt to obtain the resource from the server by parsing the valueExpression of the image attribute. Returns null
if the valueExpression is not of the form #{resource['path/to/resource']} or #{resource['library:name']}. Otherwise
returns the value obtained by ResourceHandler.createResource(). | [
"Attempt",
"to",
"obtain",
"the",
"resource",
"from",
"the",
"server",
"by",
"parsing",
"the",
"valueExpression",
"of",
"the",
"image",
"attribute",
".",
"Returns",
"null",
"if",
"the",
"valueExpression",
"is",
"not",
"of",
"the",
"form",
"#",
"{",
"resource",
"[",
"path",
"/",
"to",
"/",
"resource",
"]",
"}",
"or",
"#",
"{",
"resource",
"[",
"library",
":",
"name",
"]",
"}",
".",
"Otherwise",
"returns",
"the",
"value",
"obtained",
"by",
"ResourceHandler",
".",
"createResource",
"()",
"."
] | train | https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/component/imagecropper/ImageCropperRenderer.java#L237-L276 |
looly/hutool | hutool-db/src/main/java/cn/hutool/db/sql/SqlExecutor.java | SqlExecutor.executeForGeneratedKey | public static Long executeForGeneratedKey(Connection conn, String sql, Object... params) throws SQLException {
"""
执行非查询语句,返回主键<br>
发查询语句包括 插入、更新、删除<br>
此方法不会关闭Connection
@param conn 数据库连接对象
@param sql SQL
@param params 参数
@return 主键
@throws SQLException SQL执行异常
"""
PreparedStatement ps = null;
ResultSet rs = null;
try {
ps = StatementUtil.prepareStatement(conn, sql, params);
ps.executeUpdate();
rs = ps.getGeneratedKeys();
if (rs != null && rs.next()) {
try {
return rs.getLong(1);
} catch (SQLException e) {
// 可能会出现没有主键返回的情况
}
}
return null;
} finally {
DbUtil.close(ps);
DbUtil.close(rs);
}
} | java | public static Long executeForGeneratedKey(Connection conn, String sql, Object... params) throws SQLException {
PreparedStatement ps = null;
ResultSet rs = null;
try {
ps = StatementUtil.prepareStatement(conn, sql, params);
ps.executeUpdate();
rs = ps.getGeneratedKeys();
if (rs != null && rs.next()) {
try {
return rs.getLong(1);
} catch (SQLException e) {
// 可能会出现没有主键返回的情况
}
}
return null;
} finally {
DbUtil.close(ps);
DbUtil.close(rs);
}
} | [
"public",
"static",
"Long",
"executeForGeneratedKey",
"(",
"Connection",
"conn",
",",
"String",
"sql",
",",
"Object",
"...",
"params",
")",
"throws",
"SQLException",
"{",
"PreparedStatement",
"ps",
"=",
"null",
";",
"ResultSet",
"rs",
"=",
"null",
";",
"try",
"{",
"ps",
"=",
"StatementUtil",
".",
"prepareStatement",
"(",
"conn",
",",
"sql",
",",
"params",
")",
";",
"ps",
".",
"executeUpdate",
"(",
")",
";",
"rs",
"=",
"ps",
".",
"getGeneratedKeys",
"(",
")",
";",
"if",
"(",
"rs",
"!=",
"null",
"&&",
"rs",
".",
"next",
"(",
")",
")",
"{",
"try",
"{",
"return",
"rs",
".",
"getLong",
"(",
"1",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"// 可能会出现没有主键返回的情况",
"}",
"}",
"return",
"null",
";",
"}",
"finally",
"{",
"DbUtil",
".",
"close",
"(",
"ps",
")",
";",
"DbUtil",
".",
"close",
"(",
"rs",
")",
";",
"}",
"}"
] | 执行非查询语句,返回主键<br>
发查询语句包括 插入、更新、删除<br>
此方法不会关闭Connection
@param conn 数据库连接对象
@param sql SQL
@param params 参数
@return 主键
@throws SQLException SQL执行异常 | [
"执行非查询语句,返回主键<br",
">",
"发查询语句包括",
"插入、更新、删除<br",
">",
"此方法不会关闭Connection"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-db/src/main/java/cn/hutool/db/sql/SqlExecutor.java#L132-L151 |
alkacon/opencms-core | src/org/opencms/relations/CmsCategoryService.java | CmsCategoryService.addResourceToCategory | public void addResourceToCategory(CmsObject cms, String resourceName, CmsCategory category) throws CmsException {
"""
Adds a resource identified by the given resource name to the given category.<p>
The resource has to be locked.<p>
@param cms the current cms context
@param resourceName the site relative path to the resource to add
@param category the category to add the resource to
@throws CmsException if something goes wrong
"""
if (readResourceCategories(cms, cms.readResource(resourceName, CmsResourceFilter.IGNORE_EXPIRATION)).contains(
category)) {
return;
}
String sitePath = cms.getRequestContext().removeSiteRoot(category.getRootPath());
cms.addRelationToResource(resourceName, sitePath, CmsRelationType.CATEGORY.getName());
String parentCatPath = category.getPath();
// recursively add to higher level categories
if (parentCatPath.endsWith("/")) {
parentCatPath = parentCatPath.substring(0, parentCatPath.length() - 1);
}
if (parentCatPath.lastIndexOf('/') > 0) {
addResourceToCategory(cms, resourceName, parentCatPath.substring(0, parentCatPath.lastIndexOf('/') + 1));
}
} | java | public void addResourceToCategory(CmsObject cms, String resourceName, CmsCategory category) throws CmsException {
if (readResourceCategories(cms, cms.readResource(resourceName, CmsResourceFilter.IGNORE_EXPIRATION)).contains(
category)) {
return;
}
String sitePath = cms.getRequestContext().removeSiteRoot(category.getRootPath());
cms.addRelationToResource(resourceName, sitePath, CmsRelationType.CATEGORY.getName());
String parentCatPath = category.getPath();
// recursively add to higher level categories
if (parentCatPath.endsWith("/")) {
parentCatPath = parentCatPath.substring(0, parentCatPath.length() - 1);
}
if (parentCatPath.lastIndexOf('/') > 0) {
addResourceToCategory(cms, resourceName, parentCatPath.substring(0, parentCatPath.lastIndexOf('/') + 1));
}
} | [
"public",
"void",
"addResourceToCategory",
"(",
"CmsObject",
"cms",
",",
"String",
"resourceName",
",",
"CmsCategory",
"category",
")",
"throws",
"CmsException",
"{",
"if",
"(",
"readResourceCategories",
"(",
"cms",
",",
"cms",
".",
"readResource",
"(",
"resourceName",
",",
"CmsResourceFilter",
".",
"IGNORE_EXPIRATION",
")",
")",
".",
"contains",
"(",
"category",
")",
")",
"{",
"return",
";",
"}",
"String",
"sitePath",
"=",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"removeSiteRoot",
"(",
"category",
".",
"getRootPath",
"(",
")",
")",
";",
"cms",
".",
"addRelationToResource",
"(",
"resourceName",
",",
"sitePath",
",",
"CmsRelationType",
".",
"CATEGORY",
".",
"getName",
"(",
")",
")",
";",
"String",
"parentCatPath",
"=",
"category",
".",
"getPath",
"(",
")",
";",
"// recursively add to higher level categories",
"if",
"(",
"parentCatPath",
".",
"endsWith",
"(",
"\"/\"",
")",
")",
"{",
"parentCatPath",
"=",
"parentCatPath",
".",
"substring",
"(",
"0",
",",
"parentCatPath",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"}",
"if",
"(",
"parentCatPath",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
">",
"0",
")",
"{",
"addResourceToCategory",
"(",
"cms",
",",
"resourceName",
",",
"parentCatPath",
".",
"substring",
"(",
"0",
",",
"parentCatPath",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
"+",
"1",
")",
")",
";",
"}",
"}"
] | Adds a resource identified by the given resource name to the given category.<p>
The resource has to be locked.<p>
@param cms the current cms context
@param resourceName the site relative path to the resource to add
@param category the category to add the resource to
@throws CmsException if something goes wrong | [
"Adds",
"a",
"resource",
"identified",
"by",
"the",
"given",
"resource",
"name",
"to",
"the",
"given",
"category",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/relations/CmsCategoryService.java#L102-L119 |
heroku/heroku.jar | heroku-api/src/main/java/com/heroku/api/request/log/LogStreamResponse.java | LogStreamResponse.openStream | public InputStream openStream() {
"""
Creates a {@link URLConnection} to logplex. SSL verification is not used because Logplex's certificate is not signed by an authority that exists
in the standard java keystore.
@return input stream
"""
try {
URLConnection urlConnection = logStreamURL.openConnection();
if (urlConnection instanceof HttpsURLConnection) {
HttpsURLConnection https = (HttpsURLConnection) urlConnection;
https.setSSLSocketFactory(Heroku.sslContext(false).getSocketFactory());
https.setHostnameVerifier(Heroku.hostnameVerifier(false));
}
urlConnection.connect();
return urlConnection.getInputStream();
} catch (IOException e) {
throw new HerokuAPIException("IOException while opening log stream", e);
}
} | java | public InputStream openStream() {
try {
URLConnection urlConnection = logStreamURL.openConnection();
if (urlConnection instanceof HttpsURLConnection) {
HttpsURLConnection https = (HttpsURLConnection) urlConnection;
https.setSSLSocketFactory(Heroku.sslContext(false).getSocketFactory());
https.setHostnameVerifier(Heroku.hostnameVerifier(false));
}
urlConnection.connect();
return urlConnection.getInputStream();
} catch (IOException e) {
throw new HerokuAPIException("IOException while opening log stream", e);
}
} | [
"public",
"InputStream",
"openStream",
"(",
")",
"{",
"try",
"{",
"URLConnection",
"urlConnection",
"=",
"logStreamURL",
".",
"openConnection",
"(",
")",
";",
"if",
"(",
"urlConnection",
"instanceof",
"HttpsURLConnection",
")",
"{",
"HttpsURLConnection",
"https",
"=",
"(",
"HttpsURLConnection",
")",
"urlConnection",
";",
"https",
".",
"setSSLSocketFactory",
"(",
"Heroku",
".",
"sslContext",
"(",
"false",
")",
".",
"getSocketFactory",
"(",
")",
")",
";",
"https",
".",
"setHostnameVerifier",
"(",
"Heroku",
".",
"hostnameVerifier",
"(",
"false",
")",
")",
";",
"}",
"urlConnection",
".",
"connect",
"(",
")",
";",
"return",
"urlConnection",
".",
"getInputStream",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"HerokuAPIException",
"(",
"\"IOException while opening log stream\"",
",",
"e",
")",
";",
"}",
"}"
] | Creates a {@link URLConnection} to logplex. SSL verification is not used because Logplex's certificate is not signed by an authority that exists
in the standard java keystore.
@return input stream | [
"Creates",
"a",
"{"
] | train | https://github.com/heroku/heroku.jar/blob/d9e52991293159498c10c498c6f91fcdd637378e/heroku-api/src/main/java/com/heroku/api/request/log/LogStreamResponse.java#L39-L53 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java | FileUtil.writeUtf8String | public static File writeUtf8String(String content, File file) throws IORuntimeException {
"""
将String写入文件,覆盖模式,字符集为UTF-8
@param content 写入的内容
@param file 文件
@return 写入的文件
@throws IORuntimeException IO异常
"""
return writeString(content, file, CharsetUtil.CHARSET_UTF_8);
} | java | public static File writeUtf8String(String content, File file) throws IORuntimeException {
return writeString(content, file, CharsetUtil.CHARSET_UTF_8);
} | [
"public",
"static",
"File",
"writeUtf8String",
"(",
"String",
"content",
",",
"File",
"file",
")",
"throws",
"IORuntimeException",
"{",
"return",
"writeString",
"(",
"content",
",",
"file",
",",
"CharsetUtil",
".",
"CHARSET_UTF_8",
")",
";",
"}"
] | 将String写入文件,覆盖模式,字符集为UTF-8
@param content 写入的内容
@param file 文件
@return 写入的文件
@throws IORuntimeException IO异常 | [
"将String写入文件,覆盖模式,字符集为UTF",
"-",
"8"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java#L2707-L2709 |
kiegroup/drools | drools-compiler/src/main/java/org/drools/compiler/builder/impl/KnowledgeBuilderImpl.java | KnowledgeBuilderImpl.addPackageFromDrl | public void addPackageFromDrl(final Reader reader,
final Resource sourceResource) throws DroolsParserException,
IOException {
"""
Load a rule package from DRL source and associate all loaded artifacts
with the given resource.
@param reader
@param sourceResource the source resource for the read artifacts
@throws DroolsParserException
@throws IOException
"""
this.resource = sourceResource;
final DrlParser parser = new DrlParser(configuration.getLanguageLevel());
final PackageDescr pkg = parser.parse(sourceResource, reader);
this.results.addAll(parser.getErrors());
if (pkg == null) {
addBuilderResult(new ParserError(sourceResource, "Parser returned a null Package", 0, 0));
}
if (!parser.hasErrors()) {
addPackage(pkg);
}
this.resource = null;
} | java | public void addPackageFromDrl(final Reader reader,
final Resource sourceResource) throws DroolsParserException,
IOException {
this.resource = sourceResource;
final DrlParser parser = new DrlParser(configuration.getLanguageLevel());
final PackageDescr pkg = parser.parse(sourceResource, reader);
this.results.addAll(parser.getErrors());
if (pkg == null) {
addBuilderResult(new ParserError(sourceResource, "Parser returned a null Package", 0, 0));
}
if (!parser.hasErrors()) {
addPackage(pkg);
}
this.resource = null;
} | [
"public",
"void",
"addPackageFromDrl",
"(",
"final",
"Reader",
"reader",
",",
"final",
"Resource",
"sourceResource",
")",
"throws",
"DroolsParserException",
",",
"IOException",
"{",
"this",
".",
"resource",
"=",
"sourceResource",
";",
"final",
"DrlParser",
"parser",
"=",
"new",
"DrlParser",
"(",
"configuration",
".",
"getLanguageLevel",
"(",
")",
")",
";",
"final",
"PackageDescr",
"pkg",
"=",
"parser",
".",
"parse",
"(",
"sourceResource",
",",
"reader",
")",
";",
"this",
".",
"results",
".",
"addAll",
"(",
"parser",
".",
"getErrors",
"(",
")",
")",
";",
"if",
"(",
"pkg",
"==",
"null",
")",
"{",
"addBuilderResult",
"(",
"new",
"ParserError",
"(",
"sourceResource",
",",
"\"Parser returned a null Package\"",
",",
"0",
",",
"0",
")",
")",
";",
"}",
"if",
"(",
"!",
"parser",
".",
"hasErrors",
"(",
")",
")",
"{",
"addPackage",
"(",
"pkg",
")",
";",
"}",
"this",
".",
"resource",
"=",
"null",
";",
"}"
] | Load a rule package from DRL source and associate all loaded artifacts
with the given resource.
@param reader
@param sourceResource the source resource for the read artifacts
@throws DroolsParserException
@throws IOException | [
"Load",
"a",
"rule",
"package",
"from",
"DRL",
"source",
"and",
"associate",
"all",
"loaded",
"artifacts",
"with",
"the",
"given",
"resource",
"."
] | train | https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/builder/impl/KnowledgeBuilderImpl.java#L358-L373 |
michael-rapp/AndroidMaterialValidation | library/src/main/java/de/mrapp/android/validation/Validators.java | Validators.notEmpty | public static Validator<CharSequence> notEmpty(@NonNull final Context context,
@StringRes final int resourceId) {
"""
Creates and returns a validator, which allows to validate texts to ensure, that they are not
empty.
@param context
The context, which should be used to retrieve the error message, as an instance of
the class {@link Context}. The context may not be null
@param resourceId
The resource ID of the string resource, which contains the error message, which
should be set, as an {@link Integer} value. The resource ID must correspond to a
valid string resource
@return The validator, which has been created, as an instance of the type {@link Validator}
"""
return new NotEmptyValidator(context, resourceId);
} | java | public static Validator<CharSequence> notEmpty(@NonNull final Context context,
@StringRes final int resourceId) {
return new NotEmptyValidator(context, resourceId);
} | [
"public",
"static",
"Validator",
"<",
"CharSequence",
">",
"notEmpty",
"(",
"@",
"NonNull",
"final",
"Context",
"context",
",",
"@",
"StringRes",
"final",
"int",
"resourceId",
")",
"{",
"return",
"new",
"NotEmptyValidator",
"(",
"context",
",",
"resourceId",
")",
";",
"}"
] | Creates and returns a validator, which allows to validate texts to ensure, that they are not
empty.
@param context
The context, which should be used to retrieve the error message, as an instance of
the class {@link Context}. The context may not be null
@param resourceId
The resource ID of the string resource, which contains the error message, which
should be set, as an {@link Integer} value. The resource ID must correspond to a
valid string resource
@return The validator, which has been created, as an instance of the type {@link Validator} | [
"Creates",
"and",
"returns",
"a",
"validator",
"which",
"allows",
"to",
"validate",
"texts",
"to",
"ensure",
"that",
"they",
"are",
"not",
"empty",
"."
] | train | https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/Validators.java#L372-L375 |
alkacon/opencms-core | src/org/opencms/db/CmsDriverManager.java | CmsDriverManager.updateLastLoginDate | public void updateLastLoginDate(CmsDbContext dbc, CmsUser user) throws CmsException {
"""
Updates the last login date on the given user to the current time.<p>
@param dbc the current database context
@param user the user to be updated
@throws CmsException if operation was not successful
"""
m_monitor.clearUserCache(user);
// set the last login time to the current time
user.setLastlogin(System.currentTimeMillis());
dbc.setAttribute(ATTRIBUTE_LOGIN, user.getName());
getUserDriver(dbc).writeUser(dbc, user);
// update cache
m_monitor.cacheUser(user);
// invalidate all user dependent caches
m_monitor.flushCache(
CmsMemoryMonitor.CacheType.ACL,
CmsMemoryMonitor.CacheType.GROUP,
CmsMemoryMonitor.CacheType.ORG_UNIT,
CmsMemoryMonitor.CacheType.USERGROUPS,
CmsMemoryMonitor.CacheType.USER_LIST,
CmsMemoryMonitor.CacheType.PERMISSION,
CmsMemoryMonitor.CacheType.RESOURCE_LIST);
// fire user modified event
Map<String, Object> eventData = new HashMap<String, Object>();
eventData.put(I_CmsEventListener.KEY_USER_ID, user.getId().toString());
eventData.put(I_CmsEventListener.KEY_USER_NAME, user.getName());
eventData.put(I_CmsEventListener.KEY_USER_ACTION, I_CmsEventListener.VALUE_USER_MODIFIED_ACTION_WRITE_USER);
eventData.put(I_CmsEventListener.KEY_USER_CHANGES, Integer.valueOf(CmsUser.FLAG_LAST_LOGIN));
OpenCms.fireCmsEvent(new CmsEvent(I_CmsEventListener.EVENT_USER_MODIFIED, eventData));
} | java | public void updateLastLoginDate(CmsDbContext dbc, CmsUser user) throws CmsException {
m_monitor.clearUserCache(user);
// set the last login time to the current time
user.setLastlogin(System.currentTimeMillis());
dbc.setAttribute(ATTRIBUTE_LOGIN, user.getName());
getUserDriver(dbc).writeUser(dbc, user);
// update cache
m_monitor.cacheUser(user);
// invalidate all user dependent caches
m_monitor.flushCache(
CmsMemoryMonitor.CacheType.ACL,
CmsMemoryMonitor.CacheType.GROUP,
CmsMemoryMonitor.CacheType.ORG_UNIT,
CmsMemoryMonitor.CacheType.USERGROUPS,
CmsMemoryMonitor.CacheType.USER_LIST,
CmsMemoryMonitor.CacheType.PERMISSION,
CmsMemoryMonitor.CacheType.RESOURCE_LIST);
// fire user modified event
Map<String, Object> eventData = new HashMap<String, Object>();
eventData.put(I_CmsEventListener.KEY_USER_ID, user.getId().toString());
eventData.put(I_CmsEventListener.KEY_USER_NAME, user.getName());
eventData.put(I_CmsEventListener.KEY_USER_ACTION, I_CmsEventListener.VALUE_USER_MODIFIED_ACTION_WRITE_USER);
eventData.put(I_CmsEventListener.KEY_USER_CHANGES, Integer.valueOf(CmsUser.FLAG_LAST_LOGIN));
OpenCms.fireCmsEvent(new CmsEvent(I_CmsEventListener.EVENT_USER_MODIFIED, eventData));
} | [
"public",
"void",
"updateLastLoginDate",
"(",
"CmsDbContext",
"dbc",
",",
"CmsUser",
"user",
")",
"throws",
"CmsException",
"{",
"m_monitor",
".",
"clearUserCache",
"(",
"user",
")",
";",
"// set the last login time to the current time",
"user",
".",
"setLastlogin",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
";",
"dbc",
".",
"setAttribute",
"(",
"ATTRIBUTE_LOGIN",
",",
"user",
".",
"getName",
"(",
")",
")",
";",
"getUserDriver",
"(",
"dbc",
")",
".",
"writeUser",
"(",
"dbc",
",",
"user",
")",
";",
"// update cache",
"m_monitor",
".",
"cacheUser",
"(",
"user",
")",
";",
"// invalidate all user dependent caches",
"m_monitor",
".",
"flushCache",
"(",
"CmsMemoryMonitor",
".",
"CacheType",
".",
"ACL",
",",
"CmsMemoryMonitor",
".",
"CacheType",
".",
"GROUP",
",",
"CmsMemoryMonitor",
".",
"CacheType",
".",
"ORG_UNIT",
",",
"CmsMemoryMonitor",
".",
"CacheType",
".",
"USERGROUPS",
",",
"CmsMemoryMonitor",
".",
"CacheType",
".",
"USER_LIST",
",",
"CmsMemoryMonitor",
".",
"CacheType",
".",
"PERMISSION",
",",
"CmsMemoryMonitor",
".",
"CacheType",
".",
"RESOURCE_LIST",
")",
";",
"// fire user modified event",
"Map",
"<",
"String",
",",
"Object",
">",
"eventData",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"eventData",
".",
"put",
"(",
"I_CmsEventListener",
".",
"KEY_USER_ID",
",",
"user",
".",
"getId",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"eventData",
".",
"put",
"(",
"I_CmsEventListener",
".",
"KEY_USER_NAME",
",",
"user",
".",
"getName",
"(",
")",
")",
";",
"eventData",
".",
"put",
"(",
"I_CmsEventListener",
".",
"KEY_USER_ACTION",
",",
"I_CmsEventListener",
".",
"VALUE_USER_MODIFIED_ACTION_WRITE_USER",
")",
";",
"eventData",
".",
"put",
"(",
"I_CmsEventListener",
".",
"KEY_USER_CHANGES",
",",
"Integer",
".",
"valueOf",
"(",
"CmsUser",
".",
"FLAG_LAST_LOGIN",
")",
")",
";",
"OpenCms",
".",
"fireCmsEvent",
"(",
"new",
"CmsEvent",
"(",
"I_CmsEventListener",
".",
"EVENT_USER_MODIFIED",
",",
"eventData",
")",
")",
";",
"}"
] | Updates the last login date on the given user to the current time.<p>
@param dbc the current database context
@param user the user to be updated
@throws CmsException if operation was not successful | [
"Updates",
"the",
"last",
"login",
"date",
"on",
"the",
"given",
"user",
"to",
"the",
"current",
"time",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/db/CmsDriverManager.java#L9399-L9426 |
kochedykov/jlibmodbus | src/com/intelligt/modbus/jlibmodbus/msg/ModbusRequestBuilder.java | ModbusRequestBuilder.buildDiagnostics | public ModbusRequest buildDiagnostics(DiagnosticsSubFunctionCode subFunctionCode, int serverAddress, int data) throws ModbusNumberException {
"""
The function uses a sub-function code field in the query to define the type of test to
be performed. The server echoes both the function code and sub-function code in a normal
response. Some of the diagnostics cause data to be returned from the remote device in the
data field of a normal response.
@param subFunctionCode a sub-function code
@param serverAddress a slave address
@param data request data field
@return DiagnosticsRequest instance
@throws ModbusNumberException if server address is in-valid
@see DiagnosticsRequest
@see DiagnosticsSubFunctionCode
"""
DiagnosticsRequest request = new DiagnosticsRequest();
request.setServerAddress(serverAddress);
request.setSubFunctionCode(subFunctionCode);
request.setSubFunctionData(data);
return request;
} | java | public ModbusRequest buildDiagnostics(DiagnosticsSubFunctionCode subFunctionCode, int serverAddress, int data) throws ModbusNumberException {
DiagnosticsRequest request = new DiagnosticsRequest();
request.setServerAddress(serverAddress);
request.setSubFunctionCode(subFunctionCode);
request.setSubFunctionData(data);
return request;
} | [
"public",
"ModbusRequest",
"buildDiagnostics",
"(",
"DiagnosticsSubFunctionCode",
"subFunctionCode",
",",
"int",
"serverAddress",
",",
"int",
"data",
")",
"throws",
"ModbusNumberException",
"{",
"DiagnosticsRequest",
"request",
"=",
"new",
"DiagnosticsRequest",
"(",
")",
";",
"request",
".",
"setServerAddress",
"(",
"serverAddress",
")",
";",
"request",
".",
"setSubFunctionCode",
"(",
"subFunctionCode",
")",
";",
"request",
".",
"setSubFunctionData",
"(",
"data",
")",
";",
"return",
"request",
";",
"}"
] | The function uses a sub-function code field in the query to define the type of test to
be performed. The server echoes both the function code and sub-function code in a normal
response. Some of the diagnostics cause data to be returned from the remote device in the
data field of a normal response.
@param subFunctionCode a sub-function code
@param serverAddress a slave address
@param data request data field
@return DiagnosticsRequest instance
@throws ModbusNumberException if server address is in-valid
@see DiagnosticsRequest
@see DiagnosticsSubFunctionCode | [
"The",
"function",
"uses",
"a",
"sub",
"-",
"function",
"code",
"field",
"in",
"the",
"query",
"to",
"define",
"the",
"type",
"of",
"test",
"to",
"be",
"performed",
".",
"The",
"server",
"echoes",
"both",
"the",
"function",
"code",
"and",
"sub",
"-",
"function",
"code",
"in",
"a",
"normal",
"response",
".",
"Some",
"of",
"the",
"diagnostics",
"cause",
"data",
"to",
"be",
"returned",
"from",
"the",
"remote",
"device",
"in",
"the",
"data",
"field",
"of",
"a",
"normal",
"response",
"."
] | train | https://github.com/kochedykov/jlibmodbus/blob/197cb39e2649e61a6fe3cb7dc91a701d847e14be/src/com/intelligt/modbus/jlibmodbus/msg/ModbusRequestBuilder.java#L185-L191 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/Transliterator.java | Transliterator.registerAlias | public static void registerAlias(String aliasID, String realID) {
"""
Register an ID as an alias of another ID. Instantiating
alias ID produces the same result as instantiating the original ID.
This is generally used to create short aliases of compound IDs.
<p>Because ICU may choose to cache Transliterator objects internally, this must
be called at application startup, prior to any calls to
Transliterator.getInstance to avoid undefined behavior.
@param aliasID The new ID being registered.
@param realID The existing ID that the new ID should be an alias of.
"""
registry.put(aliasID, realID, true);
} | java | public static void registerAlias(String aliasID, String realID) {
registry.put(aliasID, realID, true);
} | [
"public",
"static",
"void",
"registerAlias",
"(",
"String",
"aliasID",
",",
"String",
"realID",
")",
"{",
"registry",
".",
"put",
"(",
"aliasID",
",",
"realID",
",",
"true",
")",
";",
"}"
] | Register an ID as an alias of another ID. Instantiating
alias ID produces the same result as instantiating the original ID.
This is generally used to create short aliases of compound IDs.
<p>Because ICU may choose to cache Transliterator objects internally, this must
be called at application startup, prior to any calls to
Transliterator.getInstance to avoid undefined behavior.
@param aliasID The new ID being registered.
@param realID The existing ID that the new ID should be an alias of. | [
"Register",
"an",
"ID",
"as",
"an",
"alias",
"of",
"another",
"ID",
".",
"Instantiating",
"alias",
"ID",
"produces",
"the",
"same",
"result",
"as",
"instantiating",
"the",
"original",
"ID",
".",
"This",
"is",
"generally",
"used",
"to",
"create",
"short",
"aliases",
"of",
"compound",
"IDs",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/Transliterator.java#L1731-L1733 |
icode/ameba | src/main/java/ameba/websocket/sockjs/frame/SockJsFrame.java | SockJsFrame.messageFrame | public static SockJsFrame messageFrame(SockJsMessageCodec codec, String... messages) {
"""
<p>messageFrame.</p>
@param codec a {@link ameba.websocket.sockjs.frame.SockJsMessageCodec} object.
@param messages a {@link java.lang.String} object.
@return a {@link ameba.websocket.sockjs.frame.SockJsFrame} object.
"""
String encoded = codec.encode(messages);
return new SockJsFrame(encoded);
} | java | public static SockJsFrame messageFrame(SockJsMessageCodec codec, String... messages) {
String encoded = codec.encode(messages);
return new SockJsFrame(encoded);
} | [
"public",
"static",
"SockJsFrame",
"messageFrame",
"(",
"SockJsMessageCodec",
"codec",
",",
"String",
"...",
"messages",
")",
"{",
"String",
"encoded",
"=",
"codec",
".",
"encode",
"(",
"messages",
")",
";",
"return",
"new",
"SockJsFrame",
"(",
"encoded",
")",
";",
"}"
] | <p>messageFrame.</p>
@param codec a {@link ameba.websocket.sockjs.frame.SockJsMessageCodec} object.
@param messages a {@link java.lang.String} object.
@return a {@link ameba.websocket.sockjs.frame.SockJsFrame} object. | [
"<p",
">",
"messageFrame",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/icode/ameba/blob/9d4956e935898e41331b2745e400ef869cd265e0/src/main/java/ameba/websocket/sockjs/frame/SockJsFrame.java#L86-L89 |
TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/demmanipulation/pitfiller/OmsPitfiller.java | OmsPitfiller.addPitToStack | private void addPitToStack( int row, int col ) {
"""
Adds a pit position to the stack.
@param row the row of the pit.
@param col the col of the pit.
"""
currentPitsCount = currentPitsCount + 1;
if (currentPitsCount >= pitsStackSize) {
pitsStackSize = (int) (pitsStackSize + nCols * nRows * .1) + 2;
currentPitRows = realloc(currentPitRows, pitsStackSize);
currentPitCols = realloc(currentPitCols, pitsStackSize);
dn = realloc(dn, pitsStackSize);
}
currentPitRows[currentPitsCount] = row;
currentPitCols[currentPitsCount] = col;
} | java | private void addPitToStack( int row, int col ) {
currentPitsCount = currentPitsCount + 1;
if (currentPitsCount >= pitsStackSize) {
pitsStackSize = (int) (pitsStackSize + nCols * nRows * .1) + 2;
currentPitRows = realloc(currentPitRows, pitsStackSize);
currentPitCols = realloc(currentPitCols, pitsStackSize);
dn = realloc(dn, pitsStackSize);
}
currentPitRows[currentPitsCount] = row;
currentPitCols[currentPitsCount] = col;
} | [
"private",
"void",
"addPitToStack",
"(",
"int",
"row",
",",
"int",
"col",
")",
"{",
"currentPitsCount",
"=",
"currentPitsCount",
"+",
"1",
";",
"if",
"(",
"currentPitsCount",
">=",
"pitsStackSize",
")",
"{",
"pitsStackSize",
"=",
"(",
"int",
")",
"(",
"pitsStackSize",
"+",
"nCols",
"*",
"nRows",
"*",
".1",
")",
"+",
"2",
";",
"currentPitRows",
"=",
"realloc",
"(",
"currentPitRows",
",",
"pitsStackSize",
")",
";",
"currentPitCols",
"=",
"realloc",
"(",
"currentPitCols",
",",
"pitsStackSize",
")",
";",
"dn",
"=",
"realloc",
"(",
"dn",
",",
"pitsStackSize",
")",
";",
"}",
"currentPitRows",
"[",
"currentPitsCount",
"]",
"=",
"row",
";",
"currentPitCols",
"[",
"currentPitsCount",
"]",
"=",
"col",
";",
"}"
] | Adds a pit position to the stack.
@param row the row of the pit.
@param col the col of the pit. | [
"Adds",
"a",
"pit",
"position",
"to",
"the",
"stack",
"."
] | train | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/demmanipulation/pitfiller/OmsPitfiller.java#L457-L468 |
apache/incubator-druid | sql/src/main/java/org/apache/druid/sql/calcite/expression/ExtractionFns.java | ExtractionFns.fromQueryGranularity | public static ExtractionFn fromQueryGranularity(final Granularity queryGranularity) {
"""
Converts a QueryGranularity to an extractionFn, if possible. This is the inverse of
{@link #toQueryGranularity(ExtractionFn)}. This will always return a non-null extractionFn if
queryGranularity is non-null.
@param queryGranularity granularity
@return extractionFn, or null if queryGranularity is null
"""
if (queryGranularity == null) {
return null;
} else {
return new TimeFormatExtractionFn(null, null, null, queryGranularity, true);
}
} | java | public static ExtractionFn fromQueryGranularity(final Granularity queryGranularity)
{
if (queryGranularity == null) {
return null;
} else {
return new TimeFormatExtractionFn(null, null, null, queryGranularity, true);
}
} | [
"public",
"static",
"ExtractionFn",
"fromQueryGranularity",
"(",
"final",
"Granularity",
"queryGranularity",
")",
"{",
"if",
"(",
"queryGranularity",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"new",
"TimeFormatExtractionFn",
"(",
"null",
",",
"null",
",",
"null",
",",
"queryGranularity",
",",
"true",
")",
";",
"}",
"}"
] | Converts a QueryGranularity to an extractionFn, if possible. This is the inverse of
{@link #toQueryGranularity(ExtractionFn)}. This will always return a non-null extractionFn if
queryGranularity is non-null.
@param queryGranularity granularity
@return extractionFn, or null if queryGranularity is null | [
"Converts",
"a",
"QueryGranularity",
"to",
"an",
"extractionFn",
"if",
"possible",
".",
"This",
"is",
"the",
"inverse",
"of",
"{",
"@link",
"#toQueryGranularity",
"(",
"ExtractionFn",
")",
"}",
".",
"This",
"will",
"always",
"return",
"a",
"non",
"-",
"null",
"extractionFn",
"if",
"queryGranularity",
"is",
"non",
"-",
"null",
"."
] | train | https://github.com/apache/incubator-druid/blob/f776b9408962b9006cfcfe4d6c1794751972cc8e/sql/src/main/java/org/apache/druid/sql/calcite/expression/ExtractionFns.java#L62-L69 |
haraldk/TwelveMonkeys | common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java | StringUtil.toCSVString | public static String toCSVString(Object[] pStringArray, String pDelimiterString) {
"""
Converts a string array to a string separated by the given delimiter.
@param pStringArray the string array
@param pDelimiterString the delimiter string
@return string of delimiter separated values
@throws IllegalArgumentException if {@code pDelimiterString == null}
"""
if (pStringArray == null) {
return "";
}
if (pDelimiterString == null) {
throw new IllegalArgumentException("delimiter == null");
}
StringBuilder buffer = new StringBuilder();
for (int i = 0; i < pStringArray.length; i++) {
if (i > 0) {
buffer.append(pDelimiterString);
}
buffer.append(pStringArray[i]);
}
return buffer.toString();
} | java | public static String toCSVString(Object[] pStringArray, String pDelimiterString) {
if (pStringArray == null) {
return "";
}
if (pDelimiterString == null) {
throw new IllegalArgumentException("delimiter == null");
}
StringBuilder buffer = new StringBuilder();
for (int i = 0; i < pStringArray.length; i++) {
if (i > 0) {
buffer.append(pDelimiterString);
}
buffer.append(pStringArray[i]);
}
return buffer.toString();
} | [
"public",
"static",
"String",
"toCSVString",
"(",
"Object",
"[",
"]",
"pStringArray",
",",
"String",
"pDelimiterString",
")",
"{",
"if",
"(",
"pStringArray",
"==",
"null",
")",
"{",
"return",
"\"\"",
";",
"}",
"if",
"(",
"pDelimiterString",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"delimiter == null\"",
")",
";",
"}",
"StringBuilder",
"buffer",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"pStringArray",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"i",
">",
"0",
")",
"{",
"buffer",
".",
"append",
"(",
"pDelimiterString",
")",
";",
"}",
"buffer",
".",
"append",
"(",
"pStringArray",
"[",
"i",
"]",
")",
";",
"}",
"return",
"buffer",
".",
"toString",
"(",
")",
";",
"}"
] | Converts a string array to a string separated by the given delimiter.
@param pStringArray the string array
@param pDelimiterString the delimiter string
@return string of delimiter separated values
@throws IllegalArgumentException if {@code pDelimiterString == null} | [
"Converts",
"a",
"string",
"array",
"to",
"a",
"string",
"separated",
"by",
"the",
"given",
"delimiter",
"."
] | train | https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java#L1589-L1607 |
FudanNLP/fnlp | fnlp-core/src/main/java/org/fnlp/nlp/cn/tag/AbstractTagger.java | AbstractTagger.tagFile | public void tagFile(String input,String output,String sep) {
"""
序列标注方法,输入输出为文件
@param input 输入文件 UTF8编码
@param output 输出文件 UTF8编码
"""
String s = tagFile(input,"\n");
try {
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(
output), "utf-8");
BufferedWriter bw = new BufferedWriter(writer);
bw.write(s);
bw.close();
} catch (Exception e) {
System.out.println("写输出文件错误");
e.printStackTrace();
}
} | java | public void tagFile(String input,String output,String sep){
String s = tagFile(input,"\n");
try {
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(
output), "utf-8");
BufferedWriter bw = new BufferedWriter(writer);
bw.write(s);
bw.close();
} catch (Exception e) {
System.out.println("写输出文件错误");
e.printStackTrace();
}
} | [
"public",
"void",
"tagFile",
"(",
"String",
"input",
",",
"String",
"output",
",",
"String",
"sep",
")",
"{",
"String",
"s",
"=",
"tagFile",
"(",
"input",
",",
"\"\\n\"",
")",
";",
"try",
"{",
"OutputStreamWriter",
"writer",
"=",
"new",
"OutputStreamWriter",
"(",
"new",
"FileOutputStream",
"(",
"output",
")",
",",
"\"utf-8\"",
")",
";",
"BufferedWriter",
"bw",
"=",
"new",
"BufferedWriter",
"(",
"writer",
")",
";",
"bw",
".",
"write",
"(",
"s",
")",
";",
"bw",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"写输出文件错误\");\r",
"",
"",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}"
] | 序列标注方法,输入输出为文件
@param input 输入文件 UTF8编码
@param output 输出文件 UTF8编码 | [
"序列标注方法,输入输出为文件"
] | train | https://github.com/FudanNLP/fnlp/blob/ce258f3e4a5add2ba0b5e4cbac7cab2190af6659/fnlp-core/src/main/java/org/fnlp/nlp/cn/tag/AbstractTagger.java#L126-L138 |
xwiki/xwiki-commons | xwiki-commons-tools/xwiki-commons-tool-extension-plugin/src/main/java/org/xwiki/tool/extension/internal/MavenBuildExtensionRepository.java | MavenBuildExtensionRepository.openStream | @Override
public InputStream openStream(org.eclipse.aether.artifact.Artifact artifact) throws IOException {
"""
{@inheritDoc}
<p>
Override standard {@link #openStream(org.eclipse.aether.artifact.Artifact)} to reuse running Maven session which
is much faster.
@see org.xwiki.extension.repository.aether.internal.AetherExtensionRepository#openStream(org.eclipse.aether.artifact.Artifact)
"""
XWikiRepositorySystemSession session = createRepositorySystemSession();
List<RemoteRepository> repositories = newResolutionRepositories(session);
// /////////////////////////////////////////////////////////////////////////////:
ArtifactRequest artifactRequest = new ArtifactRequest();
artifactRequest.setRepositories(repositories);
artifactRequest.setArtifact(artifact);
ArtifactResult artifactResult;
try {
RepositorySystem repositorySystem = getRepositorySystem();
artifactResult = repositorySystem.resolveArtifact(session, artifactRequest);
} catch (org.eclipse.aether.resolution.ArtifactResolutionException e) {
throw new IOException("Failed to resolve artifact", e);
}
File aetherFile = artifactResult.getArtifact().getFile();
return new AetherExtensionFileInputStream(aetherFile, false);
} | java | @Override
public InputStream openStream(org.eclipse.aether.artifact.Artifact artifact) throws IOException
{
XWikiRepositorySystemSession session = createRepositorySystemSession();
List<RemoteRepository> repositories = newResolutionRepositories(session);
// /////////////////////////////////////////////////////////////////////////////:
ArtifactRequest artifactRequest = new ArtifactRequest();
artifactRequest.setRepositories(repositories);
artifactRequest.setArtifact(artifact);
ArtifactResult artifactResult;
try {
RepositorySystem repositorySystem = getRepositorySystem();
artifactResult = repositorySystem.resolveArtifact(session, artifactRequest);
} catch (org.eclipse.aether.resolution.ArtifactResolutionException e) {
throw new IOException("Failed to resolve artifact", e);
}
File aetherFile = artifactResult.getArtifact().getFile();
return new AetherExtensionFileInputStream(aetherFile, false);
} | [
"@",
"Override",
"public",
"InputStream",
"openStream",
"(",
"org",
".",
"eclipse",
".",
"aether",
".",
"artifact",
".",
"Artifact",
"artifact",
")",
"throws",
"IOException",
"{",
"XWikiRepositorySystemSession",
"session",
"=",
"createRepositorySystemSession",
"(",
")",
";",
"List",
"<",
"RemoteRepository",
">",
"repositories",
"=",
"newResolutionRepositories",
"(",
"session",
")",
";",
"// /////////////////////////////////////////////////////////////////////////////:",
"ArtifactRequest",
"artifactRequest",
"=",
"new",
"ArtifactRequest",
"(",
")",
";",
"artifactRequest",
".",
"setRepositories",
"(",
"repositories",
")",
";",
"artifactRequest",
".",
"setArtifact",
"(",
"artifact",
")",
";",
"ArtifactResult",
"artifactResult",
";",
"try",
"{",
"RepositorySystem",
"repositorySystem",
"=",
"getRepositorySystem",
"(",
")",
";",
"artifactResult",
"=",
"repositorySystem",
".",
"resolveArtifact",
"(",
"session",
",",
"artifactRequest",
")",
";",
"}",
"catch",
"(",
"org",
".",
"eclipse",
".",
"aether",
".",
"resolution",
".",
"ArtifactResolutionException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Failed to resolve artifact\"",
",",
"e",
")",
";",
"}",
"File",
"aetherFile",
"=",
"artifactResult",
".",
"getArtifact",
"(",
")",
".",
"getFile",
"(",
")",
";",
"return",
"new",
"AetherExtensionFileInputStream",
"(",
"aetherFile",
",",
"false",
")",
";",
"}"
] | {@inheritDoc}
<p>
Override standard {@link #openStream(org.eclipse.aether.artifact.Artifact)} to reuse running Maven session which
is much faster.
@see org.xwiki.extension.repository.aether.internal.AetherExtensionRepository#openStream(org.eclipse.aether.artifact.Artifact) | [
"{",
"@inheritDoc",
"}",
"<p",
">",
"Override",
"standard",
"{",
"@link",
"#openStream",
"(",
"org",
".",
"eclipse",
".",
"aether",
".",
"artifact",
".",
"Artifact",
")",
"}",
"to",
"reuse",
"running",
"Maven",
"session",
"which",
"is",
"much",
"faster",
"."
] | train | https://github.com/xwiki/xwiki-commons/blob/5374d8c6d966588c1eac7392c83da610dfb9f129/xwiki-commons-tools/xwiki-commons-tool-extension-plugin/src/main/java/org/xwiki/tool/extension/internal/MavenBuildExtensionRepository.java#L94-L118 |
wildfly/wildfly-core | patching/src/main/java/org/jboss/as/patching/runner/IdentityPatchContext.java | IdentityPatchContext.createRollbackElement | protected static PatchElement createRollbackElement(final PatchEntry entry) {
"""
Create a patch element for the rollback patch.
@param entry the entry
@return the new patch element
"""
final PatchElement patchElement = entry.element;
final String patchId;
final Patch.PatchType patchType = patchElement.getProvider().getPatchType();
if (patchType == Patch.PatchType.CUMULATIVE) {
patchId = entry.getCumulativePatchID();
} else {
patchId = patchElement.getId();
}
return createPatchElement(entry, patchId, entry.rollbackActions);
} | java | protected static PatchElement createRollbackElement(final PatchEntry entry) {
final PatchElement patchElement = entry.element;
final String patchId;
final Patch.PatchType patchType = patchElement.getProvider().getPatchType();
if (patchType == Patch.PatchType.CUMULATIVE) {
patchId = entry.getCumulativePatchID();
} else {
patchId = patchElement.getId();
}
return createPatchElement(entry, patchId, entry.rollbackActions);
} | [
"protected",
"static",
"PatchElement",
"createRollbackElement",
"(",
"final",
"PatchEntry",
"entry",
")",
"{",
"final",
"PatchElement",
"patchElement",
"=",
"entry",
".",
"element",
";",
"final",
"String",
"patchId",
";",
"final",
"Patch",
".",
"PatchType",
"patchType",
"=",
"patchElement",
".",
"getProvider",
"(",
")",
".",
"getPatchType",
"(",
")",
";",
"if",
"(",
"patchType",
"==",
"Patch",
".",
"PatchType",
".",
"CUMULATIVE",
")",
"{",
"patchId",
"=",
"entry",
".",
"getCumulativePatchID",
"(",
")",
";",
"}",
"else",
"{",
"patchId",
"=",
"patchElement",
".",
"getId",
"(",
")",
";",
"}",
"return",
"createPatchElement",
"(",
"entry",
",",
"patchId",
",",
"entry",
".",
"rollbackActions",
")",
";",
"}"
] | Create a patch element for the rollback patch.
@param entry the entry
@return the new patch element | [
"Create",
"a",
"patch",
"element",
"for",
"the",
"rollback",
"patch",
"."
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/patching/src/main/java/org/jboss/as/patching/runner/IdentityPatchContext.java#L940-L950 |
alkacon/opencms-core | src/org/opencms/jsp/CmsJspNavBuilder.java | CmsJspNavBuilder.getDefaultFile | @Deprecated
public static String getDefaultFile(CmsObject cms, String folder) {
"""
Returns the full name (including VFS path) of the default file for this navigation element
or <code>null</code> if the navigation element is not a folder.<p>
The default file of a folder is determined by the value of the property
<code>default-file</code> or the system wide property setting.<p>
@param cms the CMS object
@param folder full name of the folder
@return the name of the default file
@deprecated use {@link CmsObject#readDefaultFile(String)} instead
"""
if (folder.endsWith("/")) {
try {
CmsResource defaultFile = cms.readDefaultFile(folder);
if (defaultFile != null) {
return cms.getSitePath(defaultFile);
}
} catch (CmsException e) {
LOG.debug(e.getLocalizedMessage(), e);
}
return folder;
}
return null;
} | java | @Deprecated
public static String getDefaultFile(CmsObject cms, String folder) {
if (folder.endsWith("/")) {
try {
CmsResource defaultFile = cms.readDefaultFile(folder);
if (defaultFile != null) {
return cms.getSitePath(defaultFile);
}
} catch (CmsException e) {
LOG.debug(e.getLocalizedMessage(), e);
}
return folder;
}
return null;
} | [
"@",
"Deprecated",
"public",
"static",
"String",
"getDefaultFile",
"(",
"CmsObject",
"cms",
",",
"String",
"folder",
")",
"{",
"if",
"(",
"folder",
".",
"endsWith",
"(",
"\"/\"",
")",
")",
"{",
"try",
"{",
"CmsResource",
"defaultFile",
"=",
"cms",
".",
"readDefaultFile",
"(",
"folder",
")",
";",
"if",
"(",
"defaultFile",
"!=",
"null",
")",
"{",
"return",
"cms",
".",
"getSitePath",
"(",
"defaultFile",
")",
";",
"}",
"}",
"catch",
"(",
"CmsException",
"e",
")",
"{",
"LOG",
".",
"debug",
"(",
"e",
".",
"getLocalizedMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"return",
"folder",
";",
"}",
"return",
"null",
";",
"}"
] | Returns the full name (including VFS path) of the default file for this navigation element
or <code>null</code> if the navigation element is not a folder.<p>
The default file of a folder is determined by the value of the property
<code>default-file</code> or the system wide property setting.<p>
@param cms the CMS object
@param folder full name of the folder
@return the name of the default file
@deprecated use {@link CmsObject#readDefaultFile(String)} instead | [
"Returns",
"the",
"full",
"name",
"(",
"including",
"VFS",
"path",
")",
"of",
"the",
"default",
"file",
"for",
"this",
"navigation",
"element",
"or",
"<code",
">",
"null<",
"/",
"code",
">",
"if",
"the",
"navigation",
"element",
"is",
"not",
"a",
"folder",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/CmsJspNavBuilder.java#L202-L217 |
geomajas/geomajas-project-hammer-gwt | hammer-gwt/src/main/java/org/geomajas/hammergwt/client/HammerWidget.java | HammerWidget.setOption | @Api
public <T> void setOption(GestureOption<T> option, T value) {
"""
Change initial settings of this widget.
@param option {@link org.geomajas.hammergwt.client.option.GestureOption}
@param value T look at {@link org.geomajas.hammergwt.client.option.GestureOptions}
interface for all possible types
@param <T>
@since 1.0.0
"""
hammertime.setOption(option, value);
} | java | @Api
public <T> void setOption(GestureOption<T> option, T value) {
hammertime.setOption(option, value);
} | [
"@",
"Api",
"public",
"<",
"T",
">",
"void",
"setOption",
"(",
"GestureOption",
"<",
"T",
">",
"option",
",",
"T",
"value",
")",
"{",
"hammertime",
".",
"setOption",
"(",
"option",
",",
"value",
")",
";",
"}"
] | Change initial settings of this widget.
@param option {@link org.geomajas.hammergwt.client.option.GestureOption}
@param value T look at {@link org.geomajas.hammergwt.client.option.GestureOptions}
interface for all possible types
@param <T>
@since 1.0.0 | [
"Change",
"initial",
"settings",
"of",
"this",
"widget",
"."
] | train | https://github.com/geomajas/geomajas-project-hammer-gwt/blob/bc764171bed55e5a9eced72f0078ec22b8105b62/hammer-gwt/src/main/java/org/geomajas/hammergwt/client/HammerWidget.java#L81-L84 |
alkacon/opencms-core | src/org/opencms/widgets/serialdate/CmsSerialDateValue.java | CmsSerialDateValue.readOptionalUUID | private CmsUUID readOptionalUUID(JSONObject json, String key) {
"""
Read an optional uuid stored as JSON string.
@param json the JSON object to readfrom.
@param key the key for the UUID in the provided JSON object.
@return the uuid, or <code>null</code> if the uuid can not be read.
"""
String id = readOptionalString(json, key, null);
if (null != id) {
try {
CmsUUID uuid = CmsUUID.valueOf(id);
return uuid;
} catch (NumberFormatException e) {
LOG.debug("Reading optional UUID failed. Could not convert \"" + id + "\" to a valid UUID.");
}
}
return null;
} | java | private CmsUUID readOptionalUUID(JSONObject json, String key) {
String id = readOptionalString(json, key, null);
if (null != id) {
try {
CmsUUID uuid = CmsUUID.valueOf(id);
return uuid;
} catch (NumberFormatException e) {
LOG.debug("Reading optional UUID failed. Could not convert \"" + id + "\" to a valid UUID.");
}
}
return null;
} | [
"private",
"CmsUUID",
"readOptionalUUID",
"(",
"JSONObject",
"json",
",",
"String",
"key",
")",
"{",
"String",
"id",
"=",
"readOptionalString",
"(",
"json",
",",
"key",
",",
"null",
")",
";",
"if",
"(",
"null",
"!=",
"id",
")",
"{",
"try",
"{",
"CmsUUID",
"uuid",
"=",
"CmsUUID",
".",
"valueOf",
"(",
"id",
")",
";",
"return",
"uuid",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Reading optional UUID failed. Could not convert \\\"\"",
"+",
"id",
"+",
"\"\\\" to a valid UUID.\"",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Read an optional uuid stored as JSON string.
@param json the JSON object to readfrom.
@param key the key for the UUID in the provided JSON object.
@return the uuid, or <code>null</code> if the uuid can not be read. | [
"Read",
"an",
"optional",
"uuid",
"stored",
"as",
"JSON",
"string",
"."
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/widgets/serialdate/CmsSerialDateValue.java#L405-L417 |
azkaban/azkaban | az-core/src/main/java/azkaban/utils/PropsUtils.java | PropsUtils.getPropertyDiff | public static String getPropertyDiff(Props oldProps, Props newProps) {
"""
The difference between old and new Props
@param oldProps old Props
@param newProps new Props
@return string formatted difference
"""
final StringBuilder builder = new StringBuilder("");
// oldProps can not be null during the below comparison process.
if (oldProps == null) {
oldProps = new Props();
}
if (newProps == null) {
newProps = new Props();
}
final MapDifference<String, String> md =
Maps.difference(toStringMap(oldProps, false), toStringMap(newProps, false));
final Map<String, String> newlyCreatedProperty = md.entriesOnlyOnRight();
if (newlyCreatedProperty != null && newlyCreatedProperty.size() > 0) {
builder.append("Newly created Properties: ");
newlyCreatedProperty.forEach((k, v) -> {
builder.append("[ " + k + ", " + v + "], ");
});
builder.append("\n");
}
final Map<String, String> deletedProperty = md.entriesOnlyOnLeft();
if (deletedProperty != null && deletedProperty.size() > 0) {
builder.append("Deleted Properties: ");
deletedProperty.forEach((k, v) -> {
builder.append("[ " + k + ", " + v + "], ");
});
builder.append("\n");
}
final Map<String, MapDifference.ValueDifference<String>> diffProperties = md.entriesDiffering();
if (diffProperties != null && diffProperties.size() > 0) {
builder.append("Modified Properties: ");
diffProperties.forEach((k, v) -> {
builder.append("[ " + k + ", " + v.leftValue() + "-->" + v.rightValue() + "], ");
});
}
return builder.toString();
} | java | public static String getPropertyDiff(Props oldProps, Props newProps) {
final StringBuilder builder = new StringBuilder("");
// oldProps can not be null during the below comparison process.
if (oldProps == null) {
oldProps = new Props();
}
if (newProps == null) {
newProps = new Props();
}
final MapDifference<String, String> md =
Maps.difference(toStringMap(oldProps, false), toStringMap(newProps, false));
final Map<String, String> newlyCreatedProperty = md.entriesOnlyOnRight();
if (newlyCreatedProperty != null && newlyCreatedProperty.size() > 0) {
builder.append("Newly created Properties: ");
newlyCreatedProperty.forEach((k, v) -> {
builder.append("[ " + k + ", " + v + "], ");
});
builder.append("\n");
}
final Map<String, String> deletedProperty = md.entriesOnlyOnLeft();
if (deletedProperty != null && deletedProperty.size() > 0) {
builder.append("Deleted Properties: ");
deletedProperty.forEach((k, v) -> {
builder.append("[ " + k + ", " + v + "], ");
});
builder.append("\n");
}
final Map<String, MapDifference.ValueDifference<String>> diffProperties = md.entriesDiffering();
if (diffProperties != null && diffProperties.size() > 0) {
builder.append("Modified Properties: ");
diffProperties.forEach((k, v) -> {
builder.append("[ " + k + ", " + v.leftValue() + "-->" + v.rightValue() + "], ");
});
}
return builder.toString();
} | [
"public",
"static",
"String",
"getPropertyDiff",
"(",
"Props",
"oldProps",
",",
"Props",
"newProps",
")",
"{",
"final",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
"\"\"",
")",
";",
"// oldProps can not be null during the below comparison process.",
"if",
"(",
"oldProps",
"==",
"null",
")",
"{",
"oldProps",
"=",
"new",
"Props",
"(",
")",
";",
"}",
"if",
"(",
"newProps",
"==",
"null",
")",
"{",
"newProps",
"=",
"new",
"Props",
"(",
")",
";",
"}",
"final",
"MapDifference",
"<",
"String",
",",
"String",
">",
"md",
"=",
"Maps",
".",
"difference",
"(",
"toStringMap",
"(",
"oldProps",
",",
"false",
")",
",",
"toStringMap",
"(",
"newProps",
",",
"false",
")",
")",
";",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"newlyCreatedProperty",
"=",
"md",
".",
"entriesOnlyOnRight",
"(",
")",
";",
"if",
"(",
"newlyCreatedProperty",
"!=",
"null",
"&&",
"newlyCreatedProperty",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"builder",
".",
"append",
"(",
"\"Newly created Properties: \"",
")",
";",
"newlyCreatedProperty",
".",
"forEach",
"(",
"(",
"k",
",",
"v",
")",
"->",
"{",
"builder",
".",
"append",
"(",
"\"[ \"",
"+",
"k",
"+",
"\", \"",
"+",
"v",
"+",
"\"], \"",
")",
";",
"}",
")",
";",
"builder",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"}",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"deletedProperty",
"=",
"md",
".",
"entriesOnlyOnLeft",
"(",
")",
";",
"if",
"(",
"deletedProperty",
"!=",
"null",
"&&",
"deletedProperty",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"builder",
".",
"append",
"(",
"\"Deleted Properties: \"",
")",
";",
"deletedProperty",
".",
"forEach",
"(",
"(",
"k",
",",
"v",
")",
"->",
"{",
"builder",
".",
"append",
"(",
"\"[ \"",
"+",
"k",
"+",
"\", \"",
"+",
"v",
"+",
"\"], \"",
")",
";",
"}",
")",
";",
"builder",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"}",
"final",
"Map",
"<",
"String",
",",
"MapDifference",
".",
"ValueDifference",
"<",
"String",
">",
">",
"diffProperties",
"=",
"md",
".",
"entriesDiffering",
"(",
")",
";",
"if",
"(",
"diffProperties",
"!=",
"null",
"&&",
"diffProperties",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"builder",
".",
"append",
"(",
"\"Modified Properties: \"",
")",
";",
"diffProperties",
".",
"forEach",
"(",
"(",
"k",
",",
"v",
")",
"->",
"{",
"builder",
".",
"append",
"(",
"\"[ \"",
"+",
"k",
"+",
"\", \"",
"+",
"v",
".",
"leftValue",
"(",
")",
"+",
"\"-->\"",
"+",
"v",
".",
"rightValue",
"(",
")",
"+",
"\"], \"",
")",
";",
"}",
")",
";",
"}",
"return",
"builder",
".",
"toString",
"(",
")",
";",
"}"
] | The difference between old and new Props
@param oldProps old Props
@param newProps new Props
@return string formatted difference | [
"The",
"difference",
"between",
"old",
"and",
"new",
"Props"
] | train | https://github.com/azkaban/azkaban/blob/d258ea7d6e66807c6eff79c5325d6d3443618dff/az-core/src/main/java/azkaban/utils/PropsUtils.java#L441-L483 |
google/error-prone-javac | src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialFieldWriter.java | HtmlSerialFieldWriter.addMemberDescription | public void addMemberDescription(VariableElement field, DocTree serialFieldTag, Content contentTree) {
"""
Add the description text for this member represented by the tag.
@param serialFieldTag the field to document (represented by tag)
@param contentTree the tree to which the deprecated info will be added
"""
CommentHelper ch = utils.getCommentHelper(field);
List<? extends DocTree> description = ch.getDescription(configuration, serialFieldTag);
if (!description.isEmpty()) {
Content serialFieldContent = new RawHtml(ch.getText(description));
Content div = HtmlTree.DIV(HtmlStyle.block, serialFieldContent);
contentTree.addContent(div);
}
} | java | public void addMemberDescription(VariableElement field, DocTree serialFieldTag, Content contentTree) {
CommentHelper ch = utils.getCommentHelper(field);
List<? extends DocTree> description = ch.getDescription(configuration, serialFieldTag);
if (!description.isEmpty()) {
Content serialFieldContent = new RawHtml(ch.getText(description));
Content div = HtmlTree.DIV(HtmlStyle.block, serialFieldContent);
contentTree.addContent(div);
}
} | [
"public",
"void",
"addMemberDescription",
"(",
"VariableElement",
"field",
",",
"DocTree",
"serialFieldTag",
",",
"Content",
"contentTree",
")",
"{",
"CommentHelper",
"ch",
"=",
"utils",
".",
"getCommentHelper",
"(",
"field",
")",
";",
"List",
"<",
"?",
"extends",
"DocTree",
">",
"description",
"=",
"ch",
".",
"getDescription",
"(",
"configuration",
",",
"serialFieldTag",
")",
";",
"if",
"(",
"!",
"description",
".",
"isEmpty",
"(",
")",
")",
"{",
"Content",
"serialFieldContent",
"=",
"new",
"RawHtml",
"(",
"ch",
".",
"getText",
"(",
"description",
")",
")",
";",
"Content",
"div",
"=",
"HtmlTree",
".",
"DIV",
"(",
"HtmlStyle",
".",
"block",
",",
"serialFieldContent",
")",
";",
"contentTree",
".",
"addContent",
"(",
"div",
")",
";",
"}",
"}"
] | Add the description text for this member represented by the tag.
@param serialFieldTag the field to document (represented by tag)
@param contentTree the tree to which the deprecated info will be added | [
"Add",
"the",
"description",
"text",
"for",
"this",
"member",
"represented",
"by",
"the",
"tag",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialFieldWriter.java#L177-L185 |
Subsets and Splits