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
listlengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
listlengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
upwork/java-upwork | src/com/Upwork/api/Routers/Reports/Time.java | Time._getByType | private JSONObject _getByType(String company, String team, String agency, HashMap<String, String> params, Boolean hideFinDetails) throws JSONException {
"""
Generate Time Reports for a Specific Team/Comapny/Agency
@param company Company ID
@param team (Optional) Team ID
@param agency (Optional) Agency ID
@param params (Optional) Parameters
@param hideFinDetails (Optional) Hides all financial details
@throws JSONException If error occurred
@return {@link JSONObject}
"""
String url = "";
if (team != null) {
url = "/teams/" + team;
if (hideFinDetails) {
url = url + "/hours";
}
} else if (agency != null) {
url = "/agencies/" + agency;
}
return oClient.get("/timereports/v1/companies/" + company + url, params);
} | java | private JSONObject _getByType(String company, String team, String agency, HashMap<String, String> params, Boolean hideFinDetails) throws JSONException {
String url = "";
if (team != null) {
url = "/teams/" + team;
if (hideFinDetails) {
url = url + "/hours";
}
} else if (agency != null) {
url = "/agencies/" + agency;
}
return oClient.get("/timereports/v1/companies/" + company + url, params);
} | [
"private",
"JSONObject",
"_getByType",
"(",
"String",
"company",
",",
"String",
"team",
",",
"String",
"agency",
",",
"HashMap",
"<",
"String",
",",
"String",
">",
"params",
",",
"Boolean",
"hideFinDetails",
")",
"throws",
"JSONException",
"{",
"String",
"url",
"=",
"\"\"",
";",
"if",
"(",
"team",
"!=",
"null",
")",
"{",
"url",
"=",
"\"/teams/\"",
"+",
"team",
";",
"if",
"(",
"hideFinDetails",
")",
"{",
"url",
"=",
"url",
"+",
"\"/hours\"",
";",
"}",
"}",
"else",
"if",
"(",
"agency",
"!=",
"null",
")",
"{",
"url",
"=",
"\"/agencies/\"",
"+",
"agency",
";",
"}",
"return",
"oClient",
".",
"get",
"(",
"\"/timereports/v1/companies/\"",
"+",
"company",
"+",
"url",
",",
"params",
")",
";",
"}"
]
| Generate Time Reports for a Specific Team/Comapny/Agency
@param company Company ID
@param team (Optional) Team ID
@param agency (Optional) Agency ID
@param params (Optional) Parameters
@param hideFinDetails (Optional) Hides all financial details
@throws JSONException If error occurred
@return {@link JSONObject} | [
"Generate",
"Time",
"Reports",
"for",
"a",
"Specific",
"Team",
"/",
"Comapny",
"/",
"Agency"
]
| train | https://github.com/upwork/java-upwork/blob/342297161503a74e9e0bddbd381ab5eebf4dc454/src/com/Upwork/api/Routers/Reports/Time.java#L57-L69 |
TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/StringUtilities.java | StringUtilities.streamToScanner | @SuppressWarnings("resource")
public static Scanner streamToScanner( InputStream stream, String delimiter ) {
"""
Get scanner from input stream.
<b>Note: the scanner needs to be closed after use.</b>
@param stream the stream to read.
@param delimiter the delimiter to use.
@return the scanner.
"""
java.util.Scanner s = new java.util.Scanner(stream).useDelimiter(delimiter);
return s;
} | java | @SuppressWarnings("resource")
public static Scanner streamToScanner( InputStream stream, String delimiter ) {
java.util.Scanner s = new java.util.Scanner(stream).useDelimiter(delimiter);
return s;
} | [
"@",
"SuppressWarnings",
"(",
"\"resource\"",
")",
"public",
"static",
"Scanner",
"streamToScanner",
"(",
"InputStream",
"stream",
",",
"String",
"delimiter",
")",
"{",
"java",
".",
"util",
".",
"Scanner",
"s",
"=",
"new",
"java",
".",
"util",
".",
"Scanner",
"(",
"stream",
")",
".",
"useDelimiter",
"(",
"delimiter",
")",
";",
"return",
"s",
";",
"}"
]
| Get scanner from input stream.
<b>Note: the scanner needs to be closed after use.</b>
@param stream the stream to read.
@param delimiter the delimiter to use.
@return the scanner. | [
"Get",
"scanner",
"from",
"input",
"stream",
"."
]
| train | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/StringUtilities.java#L141-L145 |
spotify/helios | helios-tools/src/main/java/com/spotify/helios/cli/CliConfig.java | CliConfig.fromUserConfig | public static CliConfig fromUserConfig(final Map<String, String> environmentVariables)
throws IOException, URISyntaxException {
"""
Returns a CliConfig instance with values from a config file from under the users home
directory:
<p><user.home>/.helios/config
<p>If the file is not found, a CliConfig with pre-defined values will be returned.
@return The configuration
@throws IOException If the file exists but could not be read
@throws URISyntaxException If a HELIOS_MASTER env var is present and doesn't parse as a URI
"""
final String userHome = System.getProperty("user.home");
final String defaults = userHome + File.separator + CONFIG_PATH;
final File defaultsFile = new File(defaults);
return fromFile(defaultsFile, environmentVariables);
} | java | public static CliConfig fromUserConfig(final Map<String, String> environmentVariables)
throws IOException, URISyntaxException {
final String userHome = System.getProperty("user.home");
final String defaults = userHome + File.separator + CONFIG_PATH;
final File defaultsFile = new File(defaults);
return fromFile(defaultsFile, environmentVariables);
} | [
"public",
"static",
"CliConfig",
"fromUserConfig",
"(",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"environmentVariables",
")",
"throws",
"IOException",
",",
"URISyntaxException",
"{",
"final",
"String",
"userHome",
"=",
"System",
".",
"getProperty",
"(",
"\"user.home\"",
")",
";",
"final",
"String",
"defaults",
"=",
"userHome",
"+",
"File",
".",
"separator",
"+",
"CONFIG_PATH",
";",
"final",
"File",
"defaultsFile",
"=",
"new",
"File",
"(",
"defaults",
")",
";",
"return",
"fromFile",
"(",
"defaultsFile",
",",
"environmentVariables",
")",
";",
"}"
]
| Returns a CliConfig instance with values from a config file from under the users home
directory:
<p><user.home>/.helios/config
<p>If the file is not found, a CliConfig with pre-defined values will be returned.
@return The configuration
@throws IOException If the file exists but could not be read
@throws URISyntaxException If a HELIOS_MASTER env var is present and doesn't parse as a URI | [
"Returns",
"a",
"CliConfig",
"instance",
"with",
"values",
"from",
"a",
"config",
"file",
"from",
"under",
"the",
"users",
"home",
"directory",
":"
]
| train | https://github.com/spotify/helios/blob/c9000bc1d6908651570be8b057d4981bba4df5b4/helios-tools/src/main/java/com/spotify/helios/cli/CliConfig.java#L107-L113 |
artikcloud/artikcloud-java | src/main/java/cloud/artik/api/DevicesManagementApi.java | DevicesManagementApi.getStatusesAsync | public com.squareup.okhttp.Call getStatusesAsync(String tid, Integer count, Integer offset, String status, String dids, final ApiCallback<TaskStatusesEnvelope> callback) throws ApiException {
"""
Returns the details and status of a task id and the individual statuses of each device id in the list. (asynchronously)
Returns the details and status of a task id and the individual statuses of each device id in the list.
@param tid Task ID. (required)
@param count Max results count. (optional)
@param offset Result starting offset. (optional)
@param status Status filter. Comma-separated statuses. (optional)
@param dids Devices filter. Comma-separated device IDs. (optional)
@param callback The callback to be executed when the API call finishes
@return The request call
@throws ApiException If fail to process the API call, e.g. serializing the request body object
"""
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
callback.onDownloadProgress(bytesRead, contentLength, done);
}
};
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
@Override
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
callback.onUploadProgress(bytesWritten, contentLength, done);
}
};
}
com.squareup.okhttp.Call call = getStatusesValidateBeforeCall(tid, count, offset, status, dids, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken<TaskStatusesEnvelope>(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
} | java | public com.squareup.okhttp.Call getStatusesAsync(String tid, Integer count, Integer offset, String status, String dids, final ApiCallback<TaskStatusesEnvelope> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
callback.onDownloadProgress(bytesRead, contentLength, done);
}
};
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
@Override
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
callback.onUploadProgress(bytesWritten, contentLength, done);
}
};
}
com.squareup.okhttp.Call call = getStatusesValidateBeforeCall(tid, count, offset, status, dids, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken<TaskStatusesEnvelope>(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
} | [
"public",
"com",
".",
"squareup",
".",
"okhttp",
".",
"Call",
"getStatusesAsync",
"(",
"String",
"tid",
",",
"Integer",
"count",
",",
"Integer",
"offset",
",",
"String",
"status",
",",
"String",
"dids",
",",
"final",
"ApiCallback",
"<",
"TaskStatusesEnvelope",
">",
"callback",
")",
"throws",
"ApiException",
"{",
"ProgressResponseBody",
".",
"ProgressListener",
"progressListener",
"=",
"null",
";",
"ProgressRequestBody",
".",
"ProgressRequestListener",
"progressRequestListener",
"=",
"null",
";",
"if",
"(",
"callback",
"!=",
"null",
")",
"{",
"progressListener",
"=",
"new",
"ProgressResponseBody",
".",
"ProgressListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"update",
"(",
"long",
"bytesRead",
",",
"long",
"contentLength",
",",
"boolean",
"done",
")",
"{",
"callback",
".",
"onDownloadProgress",
"(",
"bytesRead",
",",
"contentLength",
",",
"done",
")",
";",
"}",
"}",
";",
"progressRequestListener",
"=",
"new",
"ProgressRequestBody",
".",
"ProgressRequestListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onRequestProgress",
"(",
"long",
"bytesWritten",
",",
"long",
"contentLength",
",",
"boolean",
"done",
")",
"{",
"callback",
".",
"onUploadProgress",
"(",
"bytesWritten",
",",
"contentLength",
",",
"done",
")",
";",
"}",
"}",
";",
"}",
"com",
".",
"squareup",
".",
"okhttp",
".",
"Call",
"call",
"=",
"getStatusesValidateBeforeCall",
"(",
"tid",
",",
"count",
",",
"offset",
",",
"status",
",",
"dids",
",",
"progressListener",
",",
"progressRequestListener",
")",
";",
"Type",
"localVarReturnType",
"=",
"new",
"TypeToken",
"<",
"TaskStatusesEnvelope",
">",
"(",
")",
"{",
"}",
".",
"getType",
"(",
")",
";",
"apiClient",
".",
"executeAsync",
"(",
"call",
",",
"localVarReturnType",
",",
"callback",
")",
";",
"return",
"call",
";",
"}"
]
| Returns the details and status of a task id and the individual statuses of each device id in the list. (asynchronously)
Returns the details and status of a task id and the individual statuses of each device id in the list.
@param tid Task ID. (required)
@param count Max results count. (optional)
@param offset Result starting offset. (optional)
@param status Status filter. Comma-separated statuses. (optional)
@param dids Devices filter. Comma-separated device IDs. (optional)
@param callback The callback to be executed when the API call finishes
@return The request call
@throws ApiException If fail to process the API call, e.g. serializing the request body object | [
"Returns",
"the",
"details",
"and",
"status",
"of",
"a",
"task",
"id",
"and",
"the",
"individual",
"statuses",
"of",
"each",
"device",
"id",
"in",
"the",
"list",
".",
"(",
"asynchronously",
")",
"Returns",
"the",
"details",
"and",
"status",
"of",
"a",
"task",
"id",
"and",
"the",
"individual",
"statuses",
"of",
"each",
"device",
"id",
"in",
"the",
"list",
"."
]
| train | https://github.com/artikcloud/artikcloud-java/blob/412f447573e7796ab4f685c0bdd5eb76185a365c/src/main/java/cloud/artik/api/DevicesManagementApi.java#L927-L952 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/indexing/BooleanIndexing.java | BooleanIndexing.replaceWhere | public static void replaceWhere(@NonNull INDArray to, @NonNull Number set, @NonNull Condition condition) {
"""
This method does element-wise assessing for 2 equal-sized matrices, for each element that matches Condition
@param to
@param set
@param condition
"""
if (!(condition instanceof BaseCondition))
throw new UnsupportedOperationException("Only static Conditions are supported");
Nd4j.getExecutioner().exec(new CompareAndSet(to, set.doubleValue(), condition));
} | java | public static void replaceWhere(@NonNull INDArray to, @NonNull Number set, @NonNull Condition condition) {
if (!(condition instanceof BaseCondition))
throw new UnsupportedOperationException("Only static Conditions are supported");
Nd4j.getExecutioner().exec(new CompareAndSet(to, set.doubleValue(), condition));
} | [
"public",
"static",
"void",
"replaceWhere",
"(",
"@",
"NonNull",
"INDArray",
"to",
",",
"@",
"NonNull",
"Number",
"set",
",",
"@",
"NonNull",
"Condition",
"condition",
")",
"{",
"if",
"(",
"!",
"(",
"condition",
"instanceof",
"BaseCondition",
")",
")",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Only static Conditions are supported\"",
")",
";",
"Nd4j",
".",
"getExecutioner",
"(",
")",
".",
"exec",
"(",
"new",
"CompareAndSet",
"(",
"to",
",",
"set",
".",
"doubleValue",
"(",
")",
",",
"condition",
")",
")",
";",
"}"
]
| This method does element-wise assessing for 2 equal-sized matrices, for each element that matches Condition
@param to
@param set
@param condition | [
"This",
"method",
"does",
"element",
"-",
"wise",
"assessing",
"for",
"2",
"equal",
"-",
"sized",
"matrices",
"for",
"each",
"element",
"that",
"matches",
"Condition"
]
| train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/indexing/BooleanIndexing.java#L263-L268 |
ist-dresden/composum | sling/core/commons/src/main/java/com/composum/sling/core/util/JsonUtil.java | JsonUtil.exportChildOrderProperty | public static void exportChildOrderProperty(JsonWriter writer, Resource resource)
throws IOException {
"""
Writes the names of all children (except the 'jcr:content' child) into one array value
named '_child_order_' as a hint to recalculate the original order of the children.
@param writer
@param resource
@throws IOException
"""
List<String> names = new ArrayList<>();
Iterable<Resource> children = resource.getChildren();
for (Resource child : children) {
String name = child.getName();
if (!ResourceUtil.CONTENT_NODE.equals(name)) {
names.add(name);
}
}
if (names.size() > 0) {
writer.name(MappingRules.CHILD_ORDER_NAME);
writer.beginArray();
for (String name : names) {
if (!ResourceUtil.CONTENT_NODE.equals(name)) {
writer.value(name);
}
}
writer.endArray();
}
} | java | public static void exportChildOrderProperty(JsonWriter writer, Resource resource)
throws IOException {
List<String> names = new ArrayList<>();
Iterable<Resource> children = resource.getChildren();
for (Resource child : children) {
String name = child.getName();
if (!ResourceUtil.CONTENT_NODE.equals(name)) {
names.add(name);
}
}
if (names.size() > 0) {
writer.name(MappingRules.CHILD_ORDER_NAME);
writer.beginArray();
for (String name : names) {
if (!ResourceUtil.CONTENT_NODE.equals(name)) {
writer.value(name);
}
}
writer.endArray();
}
} | [
"public",
"static",
"void",
"exportChildOrderProperty",
"(",
"JsonWriter",
"writer",
",",
"Resource",
"resource",
")",
"throws",
"IOException",
"{",
"List",
"<",
"String",
">",
"names",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"Iterable",
"<",
"Resource",
">",
"children",
"=",
"resource",
".",
"getChildren",
"(",
")",
";",
"for",
"(",
"Resource",
"child",
":",
"children",
")",
"{",
"String",
"name",
"=",
"child",
".",
"getName",
"(",
")",
";",
"if",
"(",
"!",
"ResourceUtil",
".",
"CONTENT_NODE",
".",
"equals",
"(",
"name",
")",
")",
"{",
"names",
".",
"add",
"(",
"name",
")",
";",
"}",
"}",
"if",
"(",
"names",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"writer",
".",
"name",
"(",
"MappingRules",
".",
"CHILD_ORDER_NAME",
")",
";",
"writer",
".",
"beginArray",
"(",
")",
";",
"for",
"(",
"String",
"name",
":",
"names",
")",
"{",
"if",
"(",
"!",
"ResourceUtil",
".",
"CONTENT_NODE",
".",
"equals",
"(",
"name",
")",
")",
"{",
"writer",
".",
"value",
"(",
"name",
")",
";",
"}",
"}",
"writer",
".",
"endArray",
"(",
")",
";",
"}",
"}"
]
| Writes the names of all children (except the 'jcr:content' child) into one array value
named '_child_order_' as a hint to recalculate the original order of the children.
@param writer
@param resource
@throws IOException | [
"Writes",
"the",
"names",
"of",
"all",
"children",
"(",
"except",
"the",
"jcr",
":",
"content",
"child",
")",
"into",
"one",
"array",
"value",
"named",
"_child_order_",
"as",
"a",
"hint",
"to",
"recalculate",
"the",
"original",
"order",
"of",
"the",
"children",
"."
]
| train | https://github.com/ist-dresden/composum/blob/ebc79f559f6022c935240c19102539bdfb1bd1e2/sling/core/commons/src/main/java/com/composum/sling/core/util/JsonUtil.java#L307-L327 |
jcuda/jcuda | JCudaJava/src/main/java/jcuda/runtime/JCuda.java | JCuda.cudaSetupArgument | @Deprecated
public static int cudaSetupArgument(Pointer arg, long size, long offset) {
"""
[C++ API] Configure a device launch
<pre>
template < class T > cudaError_t cudaSetupArgument (
T arg,
size_t offset ) [inline]
</pre>
<div>
<p>[C++ API] Configure a device launch
Pushes <tt>size</tt> bytes of the argument pointed to by <tt>arg</tt>
at <tt>offset</tt> bytes from the start of the parameter passing area,
which starts at offset 0. The arguments are stored in the top of the
execution stack. cudaSetupArgument() must
be preceded by a call to cudaConfigureCall().
</p>
<div>
<span>Note:</span>
<p>Note that this
function may also return error codes from previous, asynchronous
launches.
</p>
</div>
</p>
</div>
@param arg Argument to push for a kernel launch
@param size Size of argument
@param offset Offset in argument stack to push new arg
@param arg Argument to push for a kernel launch
@param offset Offset in argument stack to push new arg
@return cudaSuccess
@see JCuda#cudaConfigureCall
@see JCuda#cudaFuncGetAttributes
@see JCuda#cudaLaunch
@see JCuda#cudaSetDoubleForDevice
@see JCuda#cudaSetDoubleForHost
@see JCuda#cudaSetupArgument
@deprecated This function is deprecated as of CUDA 7.0
"""
return checkResult(cudaSetupArgumentNative(arg, size, offset));
} | java | @Deprecated
public static int cudaSetupArgument(Pointer arg, long size, long offset)
{
return checkResult(cudaSetupArgumentNative(arg, size, offset));
} | [
"@",
"Deprecated",
"public",
"static",
"int",
"cudaSetupArgument",
"(",
"Pointer",
"arg",
",",
"long",
"size",
",",
"long",
"offset",
")",
"{",
"return",
"checkResult",
"(",
"cudaSetupArgumentNative",
"(",
"arg",
",",
"size",
",",
"offset",
")",
")",
";",
"}"
]
| [C++ API] Configure a device launch
<pre>
template < class T > cudaError_t cudaSetupArgument (
T arg,
size_t offset ) [inline]
</pre>
<div>
<p>[C++ API] Configure a device launch
Pushes <tt>size</tt> bytes of the argument pointed to by <tt>arg</tt>
at <tt>offset</tt> bytes from the start of the parameter passing area,
which starts at offset 0. The arguments are stored in the top of the
execution stack. cudaSetupArgument() must
be preceded by a call to cudaConfigureCall().
</p>
<div>
<span>Note:</span>
<p>Note that this
function may also return error codes from previous, asynchronous
launches.
</p>
</div>
</p>
</div>
@param arg Argument to push for a kernel launch
@param size Size of argument
@param offset Offset in argument stack to push new arg
@param arg Argument to push for a kernel launch
@param offset Offset in argument stack to push new arg
@return cudaSuccess
@see JCuda#cudaConfigureCall
@see JCuda#cudaFuncGetAttributes
@see JCuda#cudaLaunch
@see JCuda#cudaSetDoubleForDevice
@see JCuda#cudaSetDoubleForHost
@see JCuda#cudaSetupArgument
@deprecated This function is deprecated as of CUDA 7.0 | [
"[",
"C",
"++",
"API",
"]",
"Configure",
"a",
"device",
"launch"
]
| train | https://github.com/jcuda/jcuda/blob/468528b5b9b37dfceb6ed83fcfd889e9b359f984/JCudaJava/src/main/java/jcuda/runtime/JCuda.java#L10270-L10274 |
jmeetsma/Iglu-Util | src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java | StringSupport.getRootCauseAndStackTrace | public static String getRootCauseAndStackTrace(Throwable t, int depth) {
"""
Retrieves stack trace from throwable.
@param t
@param depth
@return
"""
while(t.getCause() != null) {
t = t.getCause();
}
return t.toString() + "\n" + getStackTrace(t, depth, null);
} | java | public static String getRootCauseAndStackTrace(Throwable t, int depth) {
while(t.getCause() != null) {
t = t.getCause();
}
return t.toString() + "\n" + getStackTrace(t, depth, null);
} | [
"public",
"static",
"String",
"getRootCauseAndStackTrace",
"(",
"Throwable",
"t",
",",
"int",
"depth",
")",
"{",
"while",
"(",
"t",
".",
"getCause",
"(",
")",
"!=",
"null",
")",
"{",
"t",
"=",
"t",
".",
"getCause",
"(",
")",
";",
"}",
"return",
"t",
".",
"toString",
"(",
")",
"+",
"\"\\n\"",
"+",
"getStackTrace",
"(",
"t",
",",
"depth",
",",
"null",
")",
";",
"}"
]
| Retrieves stack trace from throwable.
@param t
@param depth
@return | [
"Retrieves",
"stack",
"trace",
"from",
"throwable",
"."
]
| train | https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java#L945-L951 |
JetBrains/xodus | vfs/src/main/java/jetbrains/exodus/vfs/VirtualFileSystem.java | VirtualFileSystem.openFile | @Nullable
public File openFile(@NotNull final Transaction txn, @NotNull final String path, boolean create) {
"""
Returns existing {@linkplain File} with specified path or creates the new one if {@code create} is {@code true},
otherwise returns {@code null}. If {@code create} is {@code true} it never returns {@code null}.
@param txn {@linkplain Transaction} instance
@param path file path
@param create {@code true} if new file creation is allowed
@return existing or newly created {@linkplain File} if if {@code create} is {@code true}, or {@code null}
@see File
"""
final ArrayByteIterable key = StringBinding.stringToEntry(path);
final ByteIterable value = pathnames.get(txn, key);
if (value != null) {
return new File(path, value);
}
if (create) {
return createFile(txn, path);
}
return null;
} | java | @Nullable
public File openFile(@NotNull final Transaction txn, @NotNull final String path, boolean create) {
final ArrayByteIterable key = StringBinding.stringToEntry(path);
final ByteIterable value = pathnames.get(txn, key);
if (value != null) {
return new File(path, value);
}
if (create) {
return createFile(txn, path);
}
return null;
} | [
"@",
"Nullable",
"public",
"File",
"openFile",
"(",
"@",
"NotNull",
"final",
"Transaction",
"txn",
",",
"@",
"NotNull",
"final",
"String",
"path",
",",
"boolean",
"create",
")",
"{",
"final",
"ArrayByteIterable",
"key",
"=",
"StringBinding",
".",
"stringToEntry",
"(",
"path",
")",
";",
"final",
"ByteIterable",
"value",
"=",
"pathnames",
".",
"get",
"(",
"txn",
",",
"key",
")",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"return",
"new",
"File",
"(",
"path",
",",
"value",
")",
";",
"}",
"if",
"(",
"create",
")",
"{",
"return",
"createFile",
"(",
"txn",
",",
"path",
")",
";",
"}",
"return",
"null",
";",
"}"
]
| Returns existing {@linkplain File} with specified path or creates the new one if {@code create} is {@code true},
otherwise returns {@code null}. If {@code create} is {@code true} it never returns {@code null}.
@param txn {@linkplain Transaction} instance
@param path file path
@param create {@code true} if new file creation is allowed
@return existing or newly created {@linkplain File} if if {@code create} is {@code true}, or {@code null}
@see File | [
"Returns",
"existing",
"{",
"@linkplain",
"File",
"}",
"with",
"specified",
"path",
"or",
"creates",
"the",
"new",
"one",
"if",
"{",
"@code",
"create",
"}",
"is",
"{",
"@code",
"true",
"}",
"otherwise",
"returns",
"{",
"@code",
"null",
"}",
".",
"If",
"{",
"@code",
"create",
"}",
"is",
"{",
"@code",
"true",
"}",
"it",
"never",
"returns",
"{",
"@code",
"null",
"}",
"."
]
| train | https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/vfs/src/main/java/jetbrains/exodus/vfs/VirtualFileSystem.java#L264-L275 |
beangle/beangle3 | commons/model/src/main/java/org/beangle/commons/transfer/importer/AbstractItemImporter.java | AbstractItemImporter.setAttrs | public void setAttrs(String[] attrs, String[] descs) {
"""
<p>
Setter for the field <code>attrs</code>.
</p>
@param attrs an array of {@link java.lang.String} objects.
"""
for (int i = 0; i < attrs.length && i < descs.length; i++) {
descriptions.put(attrs[i], descs[i]);
}
this.attrs = attrs;
} | java | public void setAttrs(String[] attrs, String[] descs) {
for (int i = 0; i < attrs.length && i < descs.length; i++) {
descriptions.put(attrs[i], descs[i]);
}
this.attrs = attrs;
} | [
"public",
"void",
"setAttrs",
"(",
"String",
"[",
"]",
"attrs",
",",
"String",
"[",
"]",
"descs",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"attrs",
".",
"length",
"&&",
"i",
"<",
"descs",
".",
"length",
";",
"i",
"++",
")",
"{",
"descriptions",
".",
"put",
"(",
"attrs",
"[",
"i",
"]",
",",
"descs",
"[",
"i",
"]",
")",
";",
"}",
"this",
".",
"attrs",
"=",
"attrs",
";",
"}"
]
| <p>
Setter for the field <code>attrs</code>.
</p>
@param attrs an array of {@link java.lang.String} objects. | [
"<p",
">",
"Setter",
"for",
"the",
"field",
"<code",
">",
"attrs<",
"/",
"code",
">",
".",
"<",
"/",
"p",
">"
]
| train | https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/model/src/main/java/org/beangle/commons/transfer/importer/AbstractItemImporter.java#L165-L170 |
mgm-tp/jfunk | jfunk-core/src/main/java/com/mgmtp/jfunk/core/scripting/ScriptContext.java | ScriptContext.resetFixedData | @Cmd
public void resetFixedData(final String dataSetKey, final String entryKey) {
"""
Resets fixed values in the data source for the {@link DataSet} with the specified key and the
entry with the specified key.
@param dataSetKey
if {@code null}, all fixed values are reset
@param entryKey
if {@code null}, all fixed values in the {@link DataSet} are reset
"""
if (dataSetKey == null) {
log.info("Resetting all fixed values.");
dataSourceProvider.get().resetFixedValues();
return;
}
String resolvedDataSetKey = resolveProperty(dataSetKey);
if (entryKey == null) {
log.info("Resetting fixed values for data set '{}'", resolvedDataSetKey);
dataSourceProvider.get().resetFixedValues(resolvedDataSetKey);
return;
}
String resolvedEntryKey = resolveProperty(entryKey);
log.info("Resetting fixed value for data set '{}' and entry '{}'", resolvedDataSetKey, resolvedEntryKey);
dataSourceProvider.get().resetFixedValue(resolvedDataSetKey, resolvedEntryKey);
} | java | @Cmd
public void resetFixedData(final String dataSetKey, final String entryKey) {
if (dataSetKey == null) {
log.info("Resetting all fixed values.");
dataSourceProvider.get().resetFixedValues();
return;
}
String resolvedDataSetKey = resolveProperty(dataSetKey);
if (entryKey == null) {
log.info("Resetting fixed values for data set '{}'", resolvedDataSetKey);
dataSourceProvider.get().resetFixedValues(resolvedDataSetKey);
return;
}
String resolvedEntryKey = resolveProperty(entryKey);
log.info("Resetting fixed value for data set '{}' and entry '{}'", resolvedDataSetKey, resolvedEntryKey);
dataSourceProvider.get().resetFixedValue(resolvedDataSetKey, resolvedEntryKey);
} | [
"@",
"Cmd",
"public",
"void",
"resetFixedData",
"(",
"final",
"String",
"dataSetKey",
",",
"final",
"String",
"entryKey",
")",
"{",
"if",
"(",
"dataSetKey",
"==",
"null",
")",
"{",
"log",
".",
"info",
"(",
"\"Resetting all fixed values.\"",
")",
";",
"dataSourceProvider",
".",
"get",
"(",
")",
".",
"resetFixedValues",
"(",
")",
";",
"return",
";",
"}",
"String",
"resolvedDataSetKey",
"=",
"resolveProperty",
"(",
"dataSetKey",
")",
";",
"if",
"(",
"entryKey",
"==",
"null",
")",
"{",
"log",
".",
"info",
"(",
"\"Resetting fixed values for data set '{}'\"",
",",
"resolvedDataSetKey",
")",
";",
"dataSourceProvider",
".",
"get",
"(",
")",
".",
"resetFixedValues",
"(",
"resolvedDataSetKey",
")",
";",
"return",
";",
"}",
"String",
"resolvedEntryKey",
"=",
"resolveProperty",
"(",
"entryKey",
")",
";",
"log",
".",
"info",
"(",
"\"Resetting fixed value for data set '{}' and entry '{}'\"",
",",
"resolvedDataSetKey",
",",
"resolvedEntryKey",
")",
";",
"dataSourceProvider",
".",
"get",
"(",
")",
".",
"resetFixedValue",
"(",
"resolvedDataSetKey",
",",
"resolvedEntryKey",
")",
";",
"}"
]
| Resets fixed values in the data source for the {@link DataSet} with the specified key and the
entry with the specified key.
@param dataSetKey
if {@code null}, all fixed values are reset
@param entryKey
if {@code null}, all fixed values in the {@link DataSet} are reset | [
"Resets",
"fixed",
"values",
"in",
"the",
"data",
"source",
"for",
"the",
"{",
"@link",
"DataSet",
"}",
"with",
"the",
"specified",
"key",
"and",
"the",
"entry",
"with",
"the",
"specified",
"key",
"."
]
| train | https://github.com/mgm-tp/jfunk/blob/5b9fecac5778b988bb458085ded39ea9a4c7c2ae/jfunk-core/src/main/java/com/mgmtp/jfunk/core/scripting/ScriptContext.java#L504-L522 |
doanduyhai/Achilles | achilles-core/src/main/java/info/archinnov/achilles/internals/dsl/options/AbstractOptionsForSelect.java | AbstractOptionsForSelect.withRowAsyncListener | public T withRowAsyncListener(Function<Row, Row> rowAsyncListener) {
"""
Add the given async listener on the {@link com.datastax.driver.core.Row} object.
Example of usage:
<pre class="code"><code class="java">
.withRowAsyncListener(row -> {
//Do something with the row object here
})
</code></pre>
Remark: <strong>You can inspect and read values from the row object</strong>
"""
getOptions().setRowAsyncListeners(Optional.of(asList(rowAsyncListener)));
return getThis();
} | java | public T withRowAsyncListener(Function<Row, Row> rowAsyncListener) {
getOptions().setRowAsyncListeners(Optional.of(asList(rowAsyncListener)));
return getThis();
} | [
"public",
"T",
"withRowAsyncListener",
"(",
"Function",
"<",
"Row",
",",
"Row",
">",
"rowAsyncListener",
")",
"{",
"getOptions",
"(",
")",
".",
"setRowAsyncListeners",
"(",
"Optional",
".",
"of",
"(",
"asList",
"(",
"rowAsyncListener",
")",
")",
")",
";",
"return",
"getThis",
"(",
")",
";",
"}"
]
| Add the given async listener on the {@link com.datastax.driver.core.Row} object.
Example of usage:
<pre class="code"><code class="java">
.withRowAsyncListener(row -> {
//Do something with the row object here
})
</code></pre>
Remark: <strong>You can inspect and read values from the row object</strong> | [
"Add",
"the",
"given",
"async",
"listener",
"on",
"the",
"{",
"@link",
"com",
".",
"datastax",
".",
"driver",
".",
"core",
".",
"Row",
"}",
"object",
".",
"Example",
"of",
"usage",
":",
"<pre",
"class",
"=",
"code",
">",
"<code",
"class",
"=",
"java",
">"
]
| train | https://github.com/doanduyhai/Achilles/blob/8281c33100e72c993e570592ae1a5306afac6813/achilles-core/src/main/java/info/archinnov/achilles/internals/dsl/options/AbstractOptionsForSelect.java#L236-L239 |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java | SARLJvmModelInferrer.appendSerialNumberIfSerializable | protected void appendSerialNumberIfSerializable(GenerationContext context, XtendTypeDeclaration source, JvmGenericType target) {
"""
Append the serial number field if and only if the container type is serializable.
<p>The serial number field is computed from the given context and from the generated fields.
@param context the current generation context.
@param source the source object.
@param target the inferred JVM object.
@see #appendSerialNumber(GenerationContext, XtendTypeDeclaration, JvmGenericType)
"""
if (!target.isInterface() && this.inheritanceHelper.isSubTypeOf(target, Serializable.class, null)) {
appendSerialNumber(context, source, target);
}
} | java | protected void appendSerialNumberIfSerializable(GenerationContext context, XtendTypeDeclaration source, JvmGenericType target) {
if (!target.isInterface() && this.inheritanceHelper.isSubTypeOf(target, Serializable.class, null)) {
appendSerialNumber(context, source, target);
}
} | [
"protected",
"void",
"appendSerialNumberIfSerializable",
"(",
"GenerationContext",
"context",
",",
"XtendTypeDeclaration",
"source",
",",
"JvmGenericType",
"target",
")",
"{",
"if",
"(",
"!",
"target",
".",
"isInterface",
"(",
")",
"&&",
"this",
".",
"inheritanceHelper",
".",
"isSubTypeOf",
"(",
"target",
",",
"Serializable",
".",
"class",
",",
"null",
")",
")",
"{",
"appendSerialNumber",
"(",
"context",
",",
"source",
",",
"target",
")",
";",
"}",
"}"
]
| Append the serial number field if and only if the container type is serializable.
<p>The serial number field is computed from the given context and from the generated fields.
@param context the current generation context.
@param source the source object.
@param target the inferred JVM object.
@see #appendSerialNumber(GenerationContext, XtendTypeDeclaration, JvmGenericType) | [
"Append",
"the",
"serial",
"number",
"field",
"if",
"and",
"only",
"if",
"the",
"container",
"type",
"is",
"serializable",
"."
]
| train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L2801-L2805 |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/tracker/meanshift/TrackerMeanShiftComaniciu2003.java | TrackerMeanShiftComaniciu2003.distanceHistogram | protected double distanceHistogram(float histogramA[], float histogramB[]) {
"""
Computes the difference between two histograms using SAD.
This is a change from the paper, which uses Bhattacharyya. Bhattacharyya could give poor performance
even with perfect data since two errors can cancel each other out. For example, part of the histogram
is too small and another part is too large.
"""
double sumP = 0;
for( int i = 0; i < histogramA.length; i++ ) {
float q = histogramA[i];
float p = histogramB[i];
sumP += Math.abs(q-p);
}
return sumP;
} | java | protected double distanceHistogram(float histogramA[], float histogramB[]) {
double sumP = 0;
for( int i = 0; i < histogramA.length; i++ ) {
float q = histogramA[i];
float p = histogramB[i];
sumP += Math.abs(q-p);
}
return sumP;
} | [
"protected",
"double",
"distanceHistogram",
"(",
"float",
"histogramA",
"[",
"]",
",",
"float",
"histogramB",
"[",
"]",
")",
"{",
"double",
"sumP",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"histogramA",
".",
"length",
";",
"i",
"++",
")",
"{",
"float",
"q",
"=",
"histogramA",
"[",
"i",
"]",
";",
"float",
"p",
"=",
"histogramB",
"[",
"i",
"]",
";",
"sumP",
"+=",
"Math",
".",
"abs",
"(",
"q",
"-",
"p",
")",
";",
"}",
"return",
"sumP",
";",
"}"
]
| Computes the difference between two histograms using SAD.
This is a change from the paper, which uses Bhattacharyya. Bhattacharyya could give poor performance
even with perfect data since two errors can cancel each other out. For example, part of the histogram
is too small and another part is too large. | [
"Computes",
"the",
"difference",
"between",
"two",
"histograms",
"using",
"SAD",
"."
]
| train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/meanshift/TrackerMeanShiftComaniciu2003.java#L325-L333 |
gliga/ekstazi | org.ekstazi.core/src/main/java/org/ekstazi/instrument/CoverageMethodVisitor.java | CoverageMethodVisitor.insertTInvocation0 | private void insertTInvocation0(String className, int probeId) {
"""
Checks if the class name belongs to a set of classes that should be
ignored; if not, an invocation to coverage monitor is inserted.
@param className
Name of the class to be passed to coverage monitor.
"""
// Check if class name has been seen since the last label.
if (!mSeenClasses.add(className)) return;
// Check if this class name should be ignored.
if (Types.isIgnorableInternalName(className)) return;
// x. (we tried). Surround invocation of monitor with
// try/finally. This approach did not work in some cases as I
// was using local variables to save exception exception that
// has to be thrown; however, the same local variable may be
// used in finally block, so I would override.
// NOTE: The following is deprecated and excluded from code
// (see monitor for new approach and accesses to fields):
// We check if class contains "$" in which case we assume (without
// consequences) that the class is inner and we invoke coverage method
// that takes string as input. The reason for this special treatment is
// access policy, as the inner class may be private and we cannot load
// its .class. (See 57f5365935d26d2e6c47ec368612c6b003a2da79 for the
// test that is throwing an exception without this.) However, note
// that this slows down the execution a lot.
// boolean isNonInnerClass = !className.contains("$");
boolean isNonInnerClass = true;
// See the class visitor; currently we override
// the version number to 49 for all classes that have lower version
// number (so else branch should not be executed for this reason any
// more). Earlier comment: Note that we have to use class name in case
// of classes that have classfiles with major version of 48 or lower
// as ldc could not load .class prior to version 49 (in theory we
// could generate a method that does it for us, as the compiler
// would do, but then we would change bytecode too much).
if (isNonInnerClass && mIsNewerThanJava4) {
insertTInvocation(className, probeId);
} else {
// DEPRECATED: This part is deprecated and should never be executed.
// Using Class.forName(className) was very slow.
mv.visitLdcInsn(className.replaceAll("/", "."));
mv.visitMethodInsn(Opcodes.INVOKESTATIC, Names.COVERAGE_MONITOR_VM,
Instr.COVERAGE_MONITOR_MNAME, Instr.STRING_V_DESC, false);
}
} | java | private void insertTInvocation0(String className, int probeId) {
// Check if class name has been seen since the last label.
if (!mSeenClasses.add(className)) return;
// Check if this class name should be ignored.
if (Types.isIgnorableInternalName(className)) return;
// x. (we tried). Surround invocation of monitor with
// try/finally. This approach did not work in some cases as I
// was using local variables to save exception exception that
// has to be thrown; however, the same local variable may be
// used in finally block, so I would override.
// NOTE: The following is deprecated and excluded from code
// (see monitor for new approach and accesses to fields):
// We check if class contains "$" in which case we assume (without
// consequences) that the class is inner and we invoke coverage method
// that takes string as input. The reason for this special treatment is
// access policy, as the inner class may be private and we cannot load
// its .class. (See 57f5365935d26d2e6c47ec368612c6b003a2da79 for the
// test that is throwing an exception without this.) However, note
// that this slows down the execution a lot.
// boolean isNonInnerClass = !className.contains("$");
boolean isNonInnerClass = true;
// See the class visitor; currently we override
// the version number to 49 for all classes that have lower version
// number (so else branch should not be executed for this reason any
// more). Earlier comment: Note that we have to use class name in case
// of classes that have classfiles with major version of 48 or lower
// as ldc could not load .class prior to version 49 (in theory we
// could generate a method that does it for us, as the compiler
// would do, but then we would change bytecode too much).
if (isNonInnerClass && mIsNewerThanJava4) {
insertTInvocation(className, probeId);
} else {
// DEPRECATED: This part is deprecated and should never be executed.
// Using Class.forName(className) was very slow.
mv.visitLdcInsn(className.replaceAll("/", "."));
mv.visitMethodInsn(Opcodes.INVOKESTATIC, Names.COVERAGE_MONITOR_VM,
Instr.COVERAGE_MONITOR_MNAME, Instr.STRING_V_DESC, false);
}
} | [
"private",
"void",
"insertTInvocation0",
"(",
"String",
"className",
",",
"int",
"probeId",
")",
"{",
"// Check if class name has been seen since the last label.",
"if",
"(",
"!",
"mSeenClasses",
".",
"add",
"(",
"className",
")",
")",
"return",
";",
"// Check if this class name should be ignored.",
"if",
"(",
"Types",
".",
"isIgnorableInternalName",
"(",
"className",
")",
")",
"return",
";",
"// x. (we tried). Surround invocation of monitor with",
"// try/finally. This approach did not work in some cases as I",
"// was using local variables to save exception exception that",
"// has to be thrown; however, the same local variable may be",
"// used in finally block, so I would override.",
"// NOTE: The following is deprecated and excluded from code",
"// (see monitor for new approach and accesses to fields):",
"// We check if class contains \"$\" in which case we assume (without",
"// consequences) that the class is inner and we invoke coverage method",
"// that takes string as input. The reason for this special treatment is",
"// access policy, as the inner class may be private and we cannot load",
"// its .class. (See 57f5365935d26d2e6c47ec368612c6b003a2da79 for the",
"// test that is throwing an exception without this.) However, note",
"// that this slows down the execution a lot.",
"// boolean isNonInnerClass = !className.contains(\"$\");",
"boolean",
"isNonInnerClass",
"=",
"true",
";",
"// See the class visitor; currently we override",
"// the version number to 49 for all classes that have lower version",
"// number (so else branch should not be executed for this reason any",
"// more). Earlier comment: Note that we have to use class name in case",
"// of classes that have classfiles with major version of 48 or lower",
"// as ldc could not load .class prior to version 49 (in theory we",
"// could generate a method that does it for us, as the compiler",
"// would do, but then we would change bytecode too much).",
"if",
"(",
"isNonInnerClass",
"&&",
"mIsNewerThanJava4",
")",
"{",
"insertTInvocation",
"(",
"className",
",",
"probeId",
")",
";",
"}",
"else",
"{",
"// DEPRECATED: This part is deprecated and should never be executed.",
"// Using Class.forName(className) was very slow.",
"mv",
".",
"visitLdcInsn",
"(",
"className",
".",
"replaceAll",
"(",
"\"/\"",
",",
"\".\"",
")",
")",
";",
"mv",
".",
"visitMethodInsn",
"(",
"Opcodes",
".",
"INVOKESTATIC",
",",
"Names",
".",
"COVERAGE_MONITOR_VM",
",",
"Instr",
".",
"COVERAGE_MONITOR_MNAME",
",",
"Instr",
".",
"STRING_V_DESC",
",",
"false",
")",
";",
"}",
"}"
]
| Checks if the class name belongs to a set of classes that should be
ignored; if not, an invocation to coverage monitor is inserted.
@param className
Name of the class to be passed to coverage monitor. | [
"Checks",
"if",
"the",
"class",
"name",
"belongs",
"to",
"a",
"set",
"of",
"classes",
"that",
"should",
"be",
"ignored",
";",
"if",
"not",
"an",
"invocation",
"to",
"coverage",
"monitor",
"is",
"inserted",
"."
]
| train | https://github.com/gliga/ekstazi/blob/5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1/org.ekstazi.core/src/main/java/org/ekstazi/instrument/CoverageMethodVisitor.java#L210-L250 |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/hash/MurmurHash3Adaptor.java | MurmurHash3Adaptor.hashToLongs | public static long[] hashToLongs(final byte[] data, final long seed) {
"""
Hash a byte[] and long seed.
@param data the input byte array.
@param seed A long valued seed.
@return The 128-bit hash as a long[2].
"""
if ((data == null) || (data.length == 0)) {
return null;
}
return hash(data, seed);
} | java | public static long[] hashToLongs(final byte[] data, final long seed) {
if ((data == null) || (data.length == 0)) {
return null;
}
return hash(data, seed);
} | [
"public",
"static",
"long",
"[",
"]",
"hashToLongs",
"(",
"final",
"byte",
"[",
"]",
"data",
",",
"final",
"long",
"seed",
")",
"{",
"if",
"(",
"(",
"data",
"==",
"null",
")",
"||",
"(",
"data",
".",
"length",
"==",
"0",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"hash",
"(",
"data",
",",
"seed",
")",
";",
"}"
]
| Hash a byte[] and long seed.
@param data the input byte array.
@param seed A long valued seed.
@return The 128-bit hash as a long[2]. | [
"Hash",
"a",
"byte",
"[]",
"and",
"long",
"seed",
"."
]
| train | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/hash/MurmurHash3Adaptor.java#L194-L199 |
exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java | CacheableWorkspaceDataManager.registerListener | private void registerListener(final ChangesLogWrapper logWrapper, TransactionableResourceManager txResourceManager)
throws RepositoryException {
"""
This will allow to notify listeners that are not TxAware once the Tx is committed
@param logWrapper
@throws RepositoryException if any error occurs
"""
try
{
// Why calling the listeners non tx aware has been done like this:
// 1. If we call them in the commit phase and we use Arjuna with ISPN, we get:
// ActionStatus.COMMITTING > is not in a valid state to be invoking cache operations on.
// at org.infinispan.interceptors.TxInterceptor.enlist(TxInterceptor.java:195)
// at org.infinispan.interceptors.TxInterceptor.enlistReadAndInvokeNext(TxInterceptor.java:167)
// at org.infinispan.interceptors.TxInterceptor.visitGetKeyValueCommand(TxInterceptor.java:162)
// at org.infinispan.commands.read.GetKeyValueCommand.acceptVisitor(GetKeyValueCommand.java:64)
// This is due to the fact that ISPN enlist the cache even for a read access and enlistments are not
// allowed in the commit phase
// 2. If we call them in the commit phase, we use Arjuna with ISPN and we suspend the current tx,
// we get deadlocks because we try to acquire locks on cache entries that have been locked by the main tx.
// 3. If we call them in the afterComplete, we use JOTM with ISPN and we suspend and resume the current tx, we get:
// jotm: resume: Invalid Transaction Status:STATUS_COMMITTED (Current.java, line 743)
// javax.transaction.InvalidTransactionException: Invalid resume org.objectweb.jotm.TransactionImpl
// at org.objectweb.jotm.Current.resume(Current.java:744)
// This is due to the fact that it is not allowed to resume a tx when its status is STATUS_COMMITED
txResourceManager.addListener(new TransactionableResourceManagerListener()
{
public void onCommit(boolean onePhase) throws Exception
{
}
public void onAfterCompletion(int status) throws Exception
{
if (status == Status.STATUS_COMMITTED)
{
// Since the tx is successfully committed we can call components non tx aware
// The listeners will need to be executed outside the current tx so we suspend
// the current tx we can face enlistment issues on product like ISPN
transactionManager.suspend();
SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
{
public Void run()
{
notifySaveItems(logWrapper.getChangesLog(), false);
return null;
}
});
// Since the resume method could cause issue with some TM at this stage, we don't resume the tx
}
}
public void onAbort() throws Exception
{
}
});
}
catch (Exception e)
{
throw new RepositoryException("The listener for the components not tx aware could not be added", e);
}
} | java | private void registerListener(final ChangesLogWrapper logWrapper, TransactionableResourceManager txResourceManager)
throws RepositoryException
{
try
{
// Why calling the listeners non tx aware has been done like this:
// 1. If we call them in the commit phase and we use Arjuna with ISPN, we get:
// ActionStatus.COMMITTING > is not in a valid state to be invoking cache operations on.
// at org.infinispan.interceptors.TxInterceptor.enlist(TxInterceptor.java:195)
// at org.infinispan.interceptors.TxInterceptor.enlistReadAndInvokeNext(TxInterceptor.java:167)
// at org.infinispan.interceptors.TxInterceptor.visitGetKeyValueCommand(TxInterceptor.java:162)
// at org.infinispan.commands.read.GetKeyValueCommand.acceptVisitor(GetKeyValueCommand.java:64)
// This is due to the fact that ISPN enlist the cache even for a read access and enlistments are not
// allowed in the commit phase
// 2. If we call them in the commit phase, we use Arjuna with ISPN and we suspend the current tx,
// we get deadlocks because we try to acquire locks on cache entries that have been locked by the main tx.
// 3. If we call them in the afterComplete, we use JOTM with ISPN and we suspend and resume the current tx, we get:
// jotm: resume: Invalid Transaction Status:STATUS_COMMITTED (Current.java, line 743)
// javax.transaction.InvalidTransactionException: Invalid resume org.objectweb.jotm.TransactionImpl
// at org.objectweb.jotm.Current.resume(Current.java:744)
// This is due to the fact that it is not allowed to resume a tx when its status is STATUS_COMMITED
txResourceManager.addListener(new TransactionableResourceManagerListener()
{
public void onCommit(boolean onePhase) throws Exception
{
}
public void onAfterCompletion(int status) throws Exception
{
if (status == Status.STATUS_COMMITTED)
{
// Since the tx is successfully committed we can call components non tx aware
// The listeners will need to be executed outside the current tx so we suspend
// the current tx we can face enlistment issues on product like ISPN
transactionManager.suspend();
SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
{
public Void run()
{
notifySaveItems(logWrapper.getChangesLog(), false);
return null;
}
});
// Since the resume method could cause issue with some TM at this stage, we don't resume the tx
}
}
public void onAbort() throws Exception
{
}
});
}
catch (Exception e)
{
throw new RepositoryException("The listener for the components not tx aware could not be added", e);
}
} | [
"private",
"void",
"registerListener",
"(",
"final",
"ChangesLogWrapper",
"logWrapper",
",",
"TransactionableResourceManager",
"txResourceManager",
")",
"throws",
"RepositoryException",
"{",
"try",
"{",
"// Why calling the listeners non tx aware has been done like this:",
"// 1. If we call them in the commit phase and we use Arjuna with ISPN, we get:",
"// ActionStatus.COMMITTING > is not in a valid state to be invoking cache operations on.",
"// at org.infinispan.interceptors.TxInterceptor.enlist(TxInterceptor.java:195)",
"// at org.infinispan.interceptors.TxInterceptor.enlistReadAndInvokeNext(TxInterceptor.java:167)",
"// at org.infinispan.interceptors.TxInterceptor.visitGetKeyValueCommand(TxInterceptor.java:162)",
"// at org.infinispan.commands.read.GetKeyValueCommand.acceptVisitor(GetKeyValueCommand.java:64)",
"// This is due to the fact that ISPN enlist the cache even for a read access and enlistments are not ",
"// allowed in the commit phase",
"// 2. If we call them in the commit phase, we use Arjuna with ISPN and we suspend the current tx,",
"// we get deadlocks because we try to acquire locks on cache entries that have been locked by the main tx.",
"// 3. If we call them in the afterComplete, we use JOTM with ISPN and we suspend and resume the current tx, we get:",
"// jotm: resume: Invalid Transaction Status:STATUS_COMMITTED (Current.java, line 743) ",
"// javax.transaction.InvalidTransactionException: Invalid resume org.objectweb.jotm.TransactionImpl",
"// at org.objectweb.jotm.Current.resume(Current.java:744)",
"// This is due to the fact that it is not allowed to resume a tx when its status is STATUS_COMMITED",
"txResourceManager",
".",
"addListener",
"(",
"new",
"TransactionableResourceManagerListener",
"(",
")",
"{",
"public",
"void",
"onCommit",
"(",
"boolean",
"onePhase",
")",
"throws",
"Exception",
"{",
"}",
"public",
"void",
"onAfterCompletion",
"(",
"int",
"status",
")",
"throws",
"Exception",
"{",
"if",
"(",
"status",
"==",
"Status",
".",
"STATUS_COMMITTED",
")",
"{",
"// Since the tx is successfully committed we can call components non tx aware",
"// The listeners will need to be executed outside the current tx so we suspend",
"// the current tx we can face enlistment issues on product like ISPN",
"transactionManager",
".",
"suspend",
"(",
")",
";",
"SecurityHelper",
".",
"doPrivilegedAction",
"(",
"new",
"PrivilegedAction",
"<",
"Void",
">",
"(",
")",
"{",
"public",
"Void",
"run",
"(",
")",
"{",
"notifySaveItems",
"(",
"logWrapper",
".",
"getChangesLog",
"(",
")",
",",
"false",
")",
";",
"return",
"null",
";",
"}",
"}",
")",
";",
"// Since the resume method could cause issue with some TM at this stage, we don't resume the tx",
"}",
"}",
"public",
"void",
"onAbort",
"(",
")",
"throws",
"Exception",
"{",
"}",
"}",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RepositoryException",
"(",
"\"The listener for the components not tx aware could not be added\"",
",",
"e",
")",
";",
"}",
"}"
]
| This will allow to notify listeners that are not TxAware once the Tx is committed
@param logWrapper
@throws RepositoryException if any error occurs | [
"This",
"will",
"allow",
"to",
"notify",
"listeners",
"that",
"are",
"not",
"TxAware",
"once",
"the",
"Tx",
"is",
"committed"
]
| train | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java#L1210-L1269 |
jurmous/etcd4j | src/main/java/mousio/etcd4j/security/SecurityContextBuilder.java | SecurityContextBuilder.forKeystore | public static SslContext forKeystore(String keystorePath, String keystorePassword)
throws SecurityContextException {
"""
Builds SslContext using a protected keystore file. Adequate for non-mutual TLS connections.
@param keystorePath Path for keystore file
@param keystorePassword Password for protected keystore file
@return SslContext ready to use
@throws SecurityContextException for any troubles building the SslContext
"""
return forKeystore(keystorePath, keystorePassword, "SunX509");
} | java | public static SslContext forKeystore(String keystorePath, String keystorePassword)
throws SecurityContextException {
return forKeystore(keystorePath, keystorePassword, "SunX509");
} | [
"public",
"static",
"SslContext",
"forKeystore",
"(",
"String",
"keystorePath",
",",
"String",
"keystorePassword",
")",
"throws",
"SecurityContextException",
"{",
"return",
"forKeystore",
"(",
"keystorePath",
",",
"keystorePassword",
",",
"\"SunX509\"",
")",
";",
"}"
]
| Builds SslContext using a protected keystore file. Adequate for non-mutual TLS connections.
@param keystorePath Path for keystore file
@param keystorePassword Password for protected keystore file
@return SslContext ready to use
@throws SecurityContextException for any troubles building the SslContext | [
"Builds",
"SslContext",
"using",
"a",
"protected",
"keystore",
"file",
".",
"Adequate",
"for",
"non",
"-",
"mutual",
"TLS",
"connections",
"."
]
| train | https://github.com/jurmous/etcd4j/blob/ffb1d574cf85bbab025dd566ce250f1860bbcbc7/src/main/java/mousio/etcd4j/security/SecurityContextBuilder.java#L27-L30 |
ebean-orm/ebean-querybean | src/main/java/io/ebean/typequery/PBaseCompareable.java | PBaseCompareable.inRange | public final R inRange(T lower, T upper) {
"""
Greater or equal to lower value and strictly less than upper value.
<p>
This is generally preferable over Between for date and datetime types
as SQL Between is inclusive on the upper bound (<=) and generally we
need the upper bound to be exclusive (<).
</p>
@param lower the lower bind value (>=)
@param upper the upper bind value (<)
@return the root query bean instance
"""
expr().inRange(_name, lower, upper);
return _root;
} | java | public final R inRange(T lower, T upper) {
expr().inRange(_name, lower, upper);
return _root;
} | [
"public",
"final",
"R",
"inRange",
"(",
"T",
"lower",
",",
"T",
"upper",
")",
"{",
"expr",
"(",
")",
".",
"inRange",
"(",
"_name",
",",
"lower",
",",
"upper",
")",
";",
"return",
"_root",
";",
"}"
]
| Greater or equal to lower value and strictly less than upper value.
<p>
This is generally preferable over Between for date and datetime types
as SQL Between is inclusive on the upper bound (<=) and generally we
need the upper bound to be exclusive (<).
</p>
@param lower the lower bind value (>=)
@param upper the upper bind value (<)
@return the root query bean instance | [
"Greater",
"or",
"equal",
"to",
"lower",
"value",
"and",
"strictly",
"less",
"than",
"upper",
"value",
".",
"<p",
">",
"This",
"is",
"generally",
"preferable",
"over",
"Between",
"for",
"date",
"and",
"datetime",
"types",
"as",
"SQL",
"Between",
"is",
"inclusive",
"on",
"the",
"upper",
"bound",
"(",
"<",
"=",
")",
"and",
"generally",
"we",
"need",
"the",
"upper",
"bound",
"to",
"be",
"exclusive",
"(",
"<",
")",
".",
"<",
"/",
"p",
">"
]
| train | https://github.com/ebean-orm/ebean-querybean/blob/821650cb817c9c0fdcc97f93408dc79170b12423/src/main/java/io/ebean/typequery/PBaseCompareable.java#L89-L92 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/XPathContext.java | XPathContext.pushExpressionState | public final void pushExpressionState(int cn, int en, PrefixResolver nc) {
"""
Push the current context node, expression node, and prefix resolver.
@param cn the <a href="http://www.w3.org/TR/xslt#dt-current-node">current node</a>.
@param en the sub-expression context node.
@param nc the namespace context (prefix resolver.
"""
m_currentNodes.push(cn);
m_currentExpressionNodes.push(cn);
m_prefixResolvers.push(nc);
} | java | public final void pushExpressionState(int cn, int en, PrefixResolver nc)
{
m_currentNodes.push(cn);
m_currentExpressionNodes.push(cn);
m_prefixResolvers.push(nc);
} | [
"public",
"final",
"void",
"pushExpressionState",
"(",
"int",
"cn",
",",
"int",
"en",
",",
"PrefixResolver",
"nc",
")",
"{",
"m_currentNodes",
".",
"push",
"(",
"cn",
")",
";",
"m_currentExpressionNodes",
".",
"push",
"(",
"cn",
")",
";",
"m_prefixResolvers",
".",
"push",
"(",
"nc",
")",
";",
"}"
]
| Push the current context node, expression node, and prefix resolver.
@param cn the <a href="http://www.w3.org/TR/xslt#dt-current-node">current node</a>.
@param en the sub-expression context node.
@param nc the namespace context (prefix resolver. | [
"Push",
"the",
"current",
"context",
"node",
"expression",
"node",
"and",
"prefix",
"resolver",
"."
]
| train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/XPathContext.java#L767-L772 |
orbisgis/h2gis | h2gis-functions/src/main/java/org/h2gis/functions/spatial/earth/SunCalc.java | SunCalc.getAzimuth | private static double getAzimuth(double H, double phi, double d) {
"""
Sun azimuth in radians (direction along the horizon, measured from north to east)
e.g. 0 is north
@param H
@param phi
@param d
@return
"""
return Math.atan2(Math.sin(H),
Math.cos(H) * Math.sin(phi) - Math.tan(d) * Math.cos(phi))+Math.PI;
} | java | private static double getAzimuth(double H, double phi, double d) {
return Math.atan2(Math.sin(H),
Math.cos(H) * Math.sin(phi) - Math.tan(d) * Math.cos(phi))+Math.PI;
} | [
"private",
"static",
"double",
"getAzimuth",
"(",
"double",
"H",
",",
"double",
"phi",
",",
"double",
"d",
")",
"{",
"return",
"Math",
".",
"atan2",
"(",
"Math",
".",
"sin",
"(",
"H",
")",
",",
"Math",
".",
"cos",
"(",
"H",
")",
"*",
"Math",
".",
"sin",
"(",
"phi",
")",
"-",
"Math",
".",
"tan",
"(",
"d",
")",
"*",
"Math",
".",
"cos",
"(",
"phi",
")",
")",
"+",
"Math",
".",
"PI",
";",
"}"
]
| Sun azimuth in radians (direction along the horizon, measured from north to east)
e.g. 0 is north
@param H
@param phi
@param d
@return | [
"Sun",
"azimuth",
"in",
"radians",
"(",
"direction",
"along",
"the",
"horizon",
"measured",
"from",
"north",
"to",
"east",
")",
"e",
".",
"g",
".",
"0",
"is",
"north"
]
| train | https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/earth/SunCalc.java#L123-L126 |
DDTH/ddth-queue | ddth-queue-core/src/main/java/com/github/ddth/pubsub/impl/universal/UniversalIdIntMessage.java | UniversalIdIntMessage.newInstance | public static UniversalIdIntMessage newInstance(Long id, byte[] content) {
"""
Create a new {@link UniversalIdIntMessage} object with specified id and
content.
@param id
@param content
@return
"""
UniversalIdIntMessage msg = newInstance(content);
msg.setId(id);
return msg;
} | java | public static UniversalIdIntMessage newInstance(Long id, byte[] content) {
UniversalIdIntMessage msg = newInstance(content);
msg.setId(id);
return msg;
} | [
"public",
"static",
"UniversalIdIntMessage",
"newInstance",
"(",
"Long",
"id",
",",
"byte",
"[",
"]",
"content",
")",
"{",
"UniversalIdIntMessage",
"msg",
"=",
"newInstance",
"(",
"content",
")",
";",
"msg",
".",
"setId",
"(",
"id",
")",
";",
"return",
"msg",
";",
"}"
]
| Create a new {@link UniversalIdIntMessage} object with specified id and
content.
@param id
@param content
@return | [
"Create",
"a",
"new",
"{",
"@link",
"UniversalIdIntMessage",
"}",
"object",
"with",
"specified",
"id",
"and",
"content",
"."
]
| train | https://github.com/DDTH/ddth-queue/blob/b20776850d23111d3d71fc8ed6023c590bc3621f/ddth-queue-core/src/main/java/com/github/ddth/pubsub/impl/universal/UniversalIdIntMessage.java#L76-L80 |
Graylog2/graylog2-server | graylog2-server/src/main/java/org/graylog2/alerts/AbstractAlertCondition.java | AbstractAlertCondition.buildQueryFilter | protected String buildQueryFilter(String streamId, String query) {
"""
Combines the given stream ID and query string into a single filter string.
@param streamId the stream ID
@param query the query string (might be null or empty)
@return the combined filter string
"""
checkArgument(streamId != null, "streamId parameter cannot be null");
final String trimmedStreamId = streamId.trim();
checkArgument(!trimmedStreamId.isEmpty(), "streamId parameter cannot be empty");
final StringBuilder builder = new StringBuilder().append("streams:").append(trimmedStreamId);
if (query != null) {
final String trimmedQuery = query.trim();
if (!trimmedQuery.isEmpty() && !"*".equals(trimmedQuery)) {
builder.append(" AND (").append(trimmedQuery).append(")");
}
}
return builder.toString();
} | java | protected String buildQueryFilter(String streamId, String query) {
checkArgument(streamId != null, "streamId parameter cannot be null");
final String trimmedStreamId = streamId.trim();
checkArgument(!trimmedStreamId.isEmpty(), "streamId parameter cannot be empty");
final StringBuilder builder = new StringBuilder().append("streams:").append(trimmedStreamId);
if (query != null) {
final String trimmedQuery = query.trim();
if (!trimmedQuery.isEmpty() && !"*".equals(trimmedQuery)) {
builder.append(" AND (").append(trimmedQuery).append(")");
}
}
return builder.toString();
} | [
"protected",
"String",
"buildQueryFilter",
"(",
"String",
"streamId",
",",
"String",
"query",
")",
"{",
"checkArgument",
"(",
"streamId",
"!=",
"null",
",",
"\"streamId parameter cannot be null\"",
")",
";",
"final",
"String",
"trimmedStreamId",
"=",
"streamId",
".",
"trim",
"(",
")",
";",
"checkArgument",
"(",
"!",
"trimmedStreamId",
".",
"isEmpty",
"(",
")",
",",
"\"streamId parameter cannot be empty\"",
")",
";",
"final",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
".",
"append",
"(",
"\"streams:\"",
")",
".",
"append",
"(",
"trimmedStreamId",
")",
";",
"if",
"(",
"query",
"!=",
"null",
")",
"{",
"final",
"String",
"trimmedQuery",
"=",
"query",
".",
"trim",
"(",
")",
";",
"if",
"(",
"!",
"trimmedQuery",
".",
"isEmpty",
"(",
")",
"&&",
"!",
"\"*\"",
".",
"equals",
"(",
"trimmedQuery",
")",
")",
"{",
"builder",
".",
"append",
"(",
"\" AND (\"",
")",
".",
"append",
"(",
"trimmedQuery",
")",
".",
"append",
"(",
"\")\"",
")",
";",
"}",
"}",
"return",
"builder",
".",
"toString",
"(",
")",
";",
"}"
]
| Combines the given stream ID and query string into a single filter string.
@param streamId the stream ID
@param query the query string (might be null or empty)
@return the combined filter string | [
"Combines",
"the",
"given",
"stream",
"ID",
"and",
"query",
"string",
"into",
"a",
"single",
"filter",
"string",
"."
]
| train | https://github.com/Graylog2/graylog2-server/blob/50b565dcead6e0a372236d5c2f8530dc5726fa9b/graylog2-server/src/main/java/org/graylog2/alerts/AbstractAlertCondition.java#L170-L187 |
LearnLib/learnlib | commons/acex/src/main/java/de/learnlib/acex/analyzers/AcexAnalysisAlgorithms.java | AcexAnalysisAlgorithms.exponentialSearchBwd | public static <E> int exponentialSearchBwd(AbstractCounterexample<E> acex, int low, int high) {
"""
Search for a suffix index using an exponential search.
@param acex
the abstract counterexample
@param low
the lower bound of the search range
@param high
the upper bound of the search range
@return an index <code>i</code> such that <code>acex.testEffect(i) != acex.testEffect(i+1)</code>
"""
assert !acex.testEffects(low, high);
int ofs = 1;
E effHigh = acex.effect(high);
int highIter = high;
int lowIter = low;
while (highIter - ofs > lowIter) {
int next = highIter - ofs;
E eff = acex.effect(next);
if (!acex.checkEffects(eff, effHigh)) {
lowIter = next;
break;
}
highIter = next;
ofs *= 2;
}
return binarySearchRight(acex, lowIter, highIter);
} | java | public static <E> int exponentialSearchBwd(AbstractCounterexample<E> acex, int low, int high) {
assert !acex.testEffects(low, high);
int ofs = 1;
E effHigh = acex.effect(high);
int highIter = high;
int lowIter = low;
while (highIter - ofs > lowIter) {
int next = highIter - ofs;
E eff = acex.effect(next);
if (!acex.checkEffects(eff, effHigh)) {
lowIter = next;
break;
}
highIter = next;
ofs *= 2;
}
return binarySearchRight(acex, lowIter, highIter);
} | [
"public",
"static",
"<",
"E",
">",
"int",
"exponentialSearchBwd",
"(",
"AbstractCounterexample",
"<",
"E",
">",
"acex",
",",
"int",
"low",
",",
"int",
"high",
")",
"{",
"assert",
"!",
"acex",
".",
"testEffects",
"(",
"low",
",",
"high",
")",
";",
"int",
"ofs",
"=",
"1",
";",
"E",
"effHigh",
"=",
"acex",
".",
"effect",
"(",
"high",
")",
";",
"int",
"highIter",
"=",
"high",
";",
"int",
"lowIter",
"=",
"low",
";",
"while",
"(",
"highIter",
"-",
"ofs",
">",
"lowIter",
")",
"{",
"int",
"next",
"=",
"highIter",
"-",
"ofs",
";",
"E",
"eff",
"=",
"acex",
".",
"effect",
"(",
"next",
")",
";",
"if",
"(",
"!",
"acex",
".",
"checkEffects",
"(",
"eff",
",",
"effHigh",
")",
")",
"{",
"lowIter",
"=",
"next",
";",
"break",
";",
"}",
"highIter",
"=",
"next",
";",
"ofs",
"*=",
"2",
";",
"}",
"return",
"binarySearchRight",
"(",
"acex",
",",
"lowIter",
",",
"highIter",
")",
";",
"}"
]
| Search for a suffix index using an exponential search.
@param acex
the abstract counterexample
@param low
the lower bound of the search range
@param high
the upper bound of the search range
@return an index <code>i</code> such that <code>acex.testEffect(i) != acex.testEffect(i+1)</code> | [
"Search",
"for",
"a",
"suffix",
"index",
"using",
"an",
"exponential",
"search",
"."
]
| train | https://github.com/LearnLib/learnlib/blob/fa38a14adcc0664099f180d671ffa42480318d7b/commons/acex/src/main/java/de/learnlib/acex/analyzers/AcexAnalysisAlgorithms.java#L90-L111 |
Netflix/Hystrix | hystrix-core/src/main/java/com/netflix/hystrix/collapser/CollapsedRequestSubject.java | CollapsedRequestSubject.setException | @Override
public void setException(Exception e) {
"""
When set any client thread blocking on get() will immediately be unblocked and receive the exception.
@throws IllegalStateException
if called more than once or after setResponse.
@param e received exception that gets set on the initial command
"""
if (!isTerminated()) {
subject.onError(e);
} else {
throw new IllegalStateException("Response has already terminated so exception can not be set", e);
}
} | java | @Override
public void setException(Exception e) {
if (!isTerminated()) {
subject.onError(e);
} else {
throw new IllegalStateException("Response has already terminated so exception can not be set", e);
}
} | [
"@",
"Override",
"public",
"void",
"setException",
"(",
"Exception",
"e",
")",
"{",
"if",
"(",
"!",
"isTerminated",
"(",
")",
")",
"{",
"subject",
".",
"onError",
"(",
"e",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Response has already terminated so exception can not be set\"",
",",
"e",
")",
";",
"}",
"}"
]
| When set any client thread blocking on get() will immediately be unblocked and receive the exception.
@throws IllegalStateException
if called more than once or after setResponse.
@param e received exception that gets set on the initial command | [
"When",
"set",
"any",
"client",
"thread",
"blocking",
"on",
"get",
"()",
"will",
"immediately",
"be",
"unblocked",
"and",
"receive",
"the",
"exception",
"."
]
| train | https://github.com/Netflix/Hystrix/blob/3cb21589895e9f8f87cfcdbc9d96d9f63d48b848/hystrix-core/src/main/java/com/netflix/hystrix/collapser/CollapsedRequestSubject.java#L169-L176 |
structurizr/java | structurizr-core/src/com/structurizr/model/DeploymentNode.java | DeploymentNode.addDeploymentNode | public DeploymentNode addDeploymentNode(String name, String description, String technology) {
"""
Adds a child deployment node.
@param name the name of the deployment node
@param description a short description
@param technology the technology
@return a DeploymentNode object
"""
return addDeploymentNode(name, description, technology, 1);
} | java | public DeploymentNode addDeploymentNode(String name, String description, String technology) {
return addDeploymentNode(name, description, technology, 1);
} | [
"public",
"DeploymentNode",
"addDeploymentNode",
"(",
"String",
"name",
",",
"String",
"description",
",",
"String",
"technology",
")",
"{",
"return",
"addDeploymentNode",
"(",
"name",
",",
"description",
",",
"technology",
",",
"1",
")",
";",
"}"
]
| Adds a child deployment node.
@param name the name of the deployment node
@param description a short description
@param technology the technology
@return a DeploymentNode object | [
"Adds",
"a",
"child",
"deployment",
"node",
"."
]
| train | https://github.com/structurizr/java/blob/4b204f077877a24bcac363f5ecf0e129a0f9f4c5/structurizr-core/src/com/structurizr/model/DeploymentNode.java#L65-L67 |
lievendoclo/Valkyrie-RCP | valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/form/support/MessageSourceFieldFaceSource.java | MessageSourceFieldFaceSource.getMessage | protected String getMessage(String contextId, String fieldPath, String[] faceDescriptorProperties,
String defaultValue) {
"""
Returns the value of the required property of the FieldFace. Delegates to the getMessageKeys for the message key
generation strategy.
"""
String[] keys = getMessageKeys(contextId, fieldPath, faceDescriptorProperties);
try {
return getMessageSourceAccessor().getMessage(new DefaultMessageSourceResolvable(keys, null, defaultValue));
} catch (NoSuchMessageException e) {
if (log.isDebugEnabled()) {
log.debug(e.getMessage());
}
return null;
}
} | java | protected String getMessage(String contextId, String fieldPath, String[] faceDescriptorProperties,
String defaultValue) {
String[] keys = getMessageKeys(contextId, fieldPath, faceDescriptorProperties);
try {
return getMessageSourceAccessor().getMessage(new DefaultMessageSourceResolvable(keys, null, defaultValue));
} catch (NoSuchMessageException e) {
if (log.isDebugEnabled()) {
log.debug(e.getMessage());
}
return null;
}
} | [
"protected",
"String",
"getMessage",
"(",
"String",
"contextId",
",",
"String",
"fieldPath",
",",
"String",
"[",
"]",
"faceDescriptorProperties",
",",
"String",
"defaultValue",
")",
"{",
"String",
"[",
"]",
"keys",
"=",
"getMessageKeys",
"(",
"contextId",
",",
"fieldPath",
",",
"faceDescriptorProperties",
")",
";",
"try",
"{",
"return",
"getMessageSourceAccessor",
"(",
")",
".",
"getMessage",
"(",
"new",
"DefaultMessageSourceResolvable",
"(",
"keys",
",",
"null",
",",
"defaultValue",
")",
")",
";",
"}",
"catch",
"(",
"NoSuchMessageException",
"e",
")",
"{",
"if",
"(",
"log",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"log",
".",
"debug",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"null",
";",
"}",
"}"
]
| Returns the value of the required property of the FieldFace. Delegates to the getMessageKeys for the message key
generation strategy. | [
"Returns",
"the",
"value",
"of",
"the",
"required",
"property",
"of",
"the",
"FieldFace",
".",
"Delegates",
"to",
"the",
"getMessageKeys",
"for",
"the",
"message",
"key",
"generation",
"strategy",
"."
]
| train | https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/binding/form/support/MessageSourceFieldFaceSource.java#L122-L133 |
pgjdbc/pgjdbc | pgjdbc/src/main/java/org/postgresql/fastpath/Fastpath.java | Fastpath.getInteger | public int getInteger(String name, FastpathArg[] args) throws SQLException {
"""
This convenience method assumes that the return value is an integer.
@param name Function name
@param args Function arguments
@return integer result
@throws SQLException if a database-access error occurs or no result
"""
byte[] returnValue = fastpath(name, args);
if (returnValue == null) {
throw new PSQLException(
GT.tr("Fastpath call {0} - No result was returned and we expected an integer.", name),
PSQLState.NO_DATA);
}
if (returnValue.length == 4) {
return ByteConverter.int4(returnValue, 0);
} else {
throw new PSQLException(GT.tr(
"Fastpath call {0} - No result was returned or wrong size while expecting an integer.",
name), PSQLState.NO_DATA);
}
} | java | public int getInteger(String name, FastpathArg[] args) throws SQLException {
byte[] returnValue = fastpath(name, args);
if (returnValue == null) {
throw new PSQLException(
GT.tr("Fastpath call {0} - No result was returned and we expected an integer.", name),
PSQLState.NO_DATA);
}
if (returnValue.length == 4) {
return ByteConverter.int4(returnValue, 0);
} else {
throw new PSQLException(GT.tr(
"Fastpath call {0} - No result was returned or wrong size while expecting an integer.",
name), PSQLState.NO_DATA);
}
} | [
"public",
"int",
"getInteger",
"(",
"String",
"name",
",",
"FastpathArg",
"[",
"]",
"args",
")",
"throws",
"SQLException",
"{",
"byte",
"[",
"]",
"returnValue",
"=",
"fastpath",
"(",
"name",
",",
"args",
")",
";",
"if",
"(",
"returnValue",
"==",
"null",
")",
"{",
"throw",
"new",
"PSQLException",
"(",
"GT",
".",
"tr",
"(",
"\"Fastpath call {0} - No result was returned and we expected an integer.\"",
",",
"name",
")",
",",
"PSQLState",
".",
"NO_DATA",
")",
";",
"}",
"if",
"(",
"returnValue",
".",
"length",
"==",
"4",
")",
"{",
"return",
"ByteConverter",
".",
"int4",
"(",
"returnValue",
",",
"0",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"PSQLException",
"(",
"GT",
".",
"tr",
"(",
"\"Fastpath call {0} - No result was returned or wrong size while expecting an integer.\"",
",",
"name",
")",
",",
"PSQLState",
".",
"NO_DATA",
")",
";",
"}",
"}"
]
| This convenience method assumes that the return value is an integer.
@param name Function name
@param args Function arguments
@return integer result
@throws SQLException if a database-access error occurs or no result | [
"This",
"convenience",
"method",
"assumes",
"that",
"the",
"return",
"value",
"is",
"an",
"integer",
"."
]
| train | https://github.com/pgjdbc/pgjdbc/blob/95ba7b261e39754674c5817695ae5ebf9a341fae/pgjdbc/src/main/java/org/postgresql/fastpath/Fastpath.java#L157-L172 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.msgstore/src/com/ibm/ws/sib/msgstore/persistence/PersistenceFactory.java | PersistenceFactory.getPersistentMessageStore | public static PersistentMessageStore getPersistentMessageStore(MessageStoreImpl msi, XidManager xidManager, Configuration configuration) throws SevereMessageStoreException {
"""
Factory method for {@link PersistentMessageStore} objects.
@param msi the {@link MessageStoreImpl} object
@param xidManager the {@link XidManager} object
@param configuration the {@link Configuration} object
@return a {@link PersistentMessageStore} object
@throws SevereMessageStoreException
"""
// Override configuration from property if present
String pmsImplClassName = msi.getProperty(MessageStoreConstants.PROP_PERSISTENT_MESSAGE_STORE_CLASS,
configuration.getPersistentMessageStoreClassname());
// No value for the implementation class yet? Use the default
if (pmsImplClassName == null)
{
pmsImplClassName = MessageStoreConstants.PROP_PERSISTENT_MESSAGE_STORE_CLASS_DEFAULT;
}
PersistentMessageStore persistentMessageStore = null;
try
{
Class clazz = Class.forName(pmsImplClassName);
persistentMessageStore = (PersistentMessageStore)clazz.newInstance();
persistentMessageStore.initialize(msi, xidManager, configuration);
}
catch (ClassNotFoundException e)
{
com.ibm.ws.ffdc.FFDCFilter.processException(e, "com.ibm.ws.sib.msgstore.persistence.impl.PersistenceFactory.getPersistentMessageStore", "1:72:1.15.1.1");
throw new SevereMessageStoreException(e);
}
catch (InstantiationException e)
{
com.ibm.ws.ffdc.FFDCFilter.processException(e, "com.ibm.ws.sib.msgstore.persistence.impl.PersistenceFactory.getPersistentMessageStore", "1:77:1.15.1.1");
throw new SevereMessageStoreException(e);
}
catch (IllegalAccessException e)
{
com.ibm.ws.ffdc.FFDCFilter.processException(e, "com.ibm.ws.sib.msgstore.persistence.impl.PersistenceFactory.getPersistentMessageStore", "1:82:1.15.1.1");
throw new SevereMessageStoreException(e);
}
return persistentMessageStore;
} | java | public static PersistentMessageStore getPersistentMessageStore(MessageStoreImpl msi, XidManager xidManager, Configuration configuration) throws SevereMessageStoreException
{
// Override configuration from property if present
String pmsImplClassName = msi.getProperty(MessageStoreConstants.PROP_PERSISTENT_MESSAGE_STORE_CLASS,
configuration.getPersistentMessageStoreClassname());
// No value for the implementation class yet? Use the default
if (pmsImplClassName == null)
{
pmsImplClassName = MessageStoreConstants.PROP_PERSISTENT_MESSAGE_STORE_CLASS_DEFAULT;
}
PersistentMessageStore persistentMessageStore = null;
try
{
Class clazz = Class.forName(pmsImplClassName);
persistentMessageStore = (PersistentMessageStore)clazz.newInstance();
persistentMessageStore.initialize(msi, xidManager, configuration);
}
catch (ClassNotFoundException e)
{
com.ibm.ws.ffdc.FFDCFilter.processException(e, "com.ibm.ws.sib.msgstore.persistence.impl.PersistenceFactory.getPersistentMessageStore", "1:72:1.15.1.1");
throw new SevereMessageStoreException(e);
}
catch (InstantiationException e)
{
com.ibm.ws.ffdc.FFDCFilter.processException(e, "com.ibm.ws.sib.msgstore.persistence.impl.PersistenceFactory.getPersistentMessageStore", "1:77:1.15.1.1");
throw new SevereMessageStoreException(e);
}
catch (IllegalAccessException e)
{
com.ibm.ws.ffdc.FFDCFilter.processException(e, "com.ibm.ws.sib.msgstore.persistence.impl.PersistenceFactory.getPersistentMessageStore", "1:82:1.15.1.1");
throw new SevereMessageStoreException(e);
}
return persistentMessageStore;
} | [
"public",
"static",
"PersistentMessageStore",
"getPersistentMessageStore",
"(",
"MessageStoreImpl",
"msi",
",",
"XidManager",
"xidManager",
",",
"Configuration",
"configuration",
")",
"throws",
"SevereMessageStoreException",
"{",
"// Override configuration from property if present",
"String",
"pmsImplClassName",
"=",
"msi",
".",
"getProperty",
"(",
"MessageStoreConstants",
".",
"PROP_PERSISTENT_MESSAGE_STORE_CLASS",
",",
"configuration",
".",
"getPersistentMessageStoreClassname",
"(",
")",
")",
";",
"// No value for the implementation class yet? Use the default",
"if",
"(",
"pmsImplClassName",
"==",
"null",
")",
"{",
"pmsImplClassName",
"=",
"MessageStoreConstants",
".",
"PROP_PERSISTENT_MESSAGE_STORE_CLASS_DEFAULT",
";",
"}",
"PersistentMessageStore",
"persistentMessageStore",
"=",
"null",
";",
"try",
"{",
"Class",
"clazz",
"=",
"Class",
".",
"forName",
"(",
"pmsImplClassName",
")",
";",
"persistentMessageStore",
"=",
"(",
"PersistentMessageStore",
")",
"clazz",
".",
"newInstance",
"(",
")",
";",
"persistentMessageStore",
".",
"initialize",
"(",
"msi",
",",
"xidManager",
",",
"configuration",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"e",
")",
"{",
"com",
".",
"ibm",
".",
"ws",
".",
"ffdc",
".",
"FFDCFilter",
".",
"processException",
"(",
"e",
",",
"\"com.ibm.ws.sib.msgstore.persistence.impl.PersistenceFactory.getPersistentMessageStore\"",
",",
"\"1:72:1.15.1.1\"",
")",
";",
"throw",
"new",
"SevereMessageStoreException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"InstantiationException",
"e",
")",
"{",
"com",
".",
"ibm",
".",
"ws",
".",
"ffdc",
".",
"FFDCFilter",
".",
"processException",
"(",
"e",
",",
"\"com.ibm.ws.sib.msgstore.persistence.impl.PersistenceFactory.getPersistentMessageStore\"",
",",
"\"1:77:1.15.1.1\"",
")",
";",
"throw",
"new",
"SevereMessageStoreException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"e",
")",
"{",
"com",
".",
"ibm",
".",
"ws",
".",
"ffdc",
".",
"FFDCFilter",
".",
"processException",
"(",
"e",
",",
"\"com.ibm.ws.sib.msgstore.persistence.impl.PersistenceFactory.getPersistentMessageStore\"",
",",
"\"1:82:1.15.1.1\"",
")",
";",
"throw",
"new",
"SevereMessageStoreException",
"(",
"e",
")",
";",
"}",
"return",
"persistentMessageStore",
";",
"}"
]
| Factory method for {@link PersistentMessageStore} objects.
@param msi the {@link MessageStoreImpl} object
@param xidManager the {@link XidManager} object
@param configuration the {@link Configuration} object
@return a {@link PersistentMessageStore} object
@throws SevereMessageStoreException | [
"Factory",
"method",
"for",
"{",
"@link",
"PersistentMessageStore",
"}",
"objects",
"."
]
| train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.msgstore/src/com/ibm/ws/sib/msgstore/persistence/PersistenceFactory.java#L32-L68 |
netty/netty | common/src/main/java/io/netty/util/ResourceLeakDetectorFactory.java | ResourceLeakDetectorFactory.newResourceLeakDetector | public final <T> ResourceLeakDetector<T> newResourceLeakDetector(Class<T> resource) {
"""
Returns a new instance of a {@link ResourceLeakDetector} with the given resource class.
@param resource the resource class used to initialize the {@link ResourceLeakDetector}
@param <T> the type of the resource class
@return a new instance of {@link ResourceLeakDetector}
"""
return newResourceLeakDetector(resource, ResourceLeakDetector.SAMPLING_INTERVAL);
} | java | public final <T> ResourceLeakDetector<T> newResourceLeakDetector(Class<T> resource) {
return newResourceLeakDetector(resource, ResourceLeakDetector.SAMPLING_INTERVAL);
} | [
"public",
"final",
"<",
"T",
">",
"ResourceLeakDetector",
"<",
"T",
">",
"newResourceLeakDetector",
"(",
"Class",
"<",
"T",
">",
"resource",
")",
"{",
"return",
"newResourceLeakDetector",
"(",
"resource",
",",
"ResourceLeakDetector",
".",
"SAMPLING_INTERVAL",
")",
";",
"}"
]
| Returns a new instance of a {@link ResourceLeakDetector} with the given resource class.
@param resource the resource class used to initialize the {@link ResourceLeakDetector}
@param <T> the type of the resource class
@return a new instance of {@link ResourceLeakDetector} | [
"Returns",
"a",
"new",
"instance",
"of",
"a",
"{",
"@link",
"ResourceLeakDetector",
"}",
"with",
"the",
"given",
"resource",
"class",
"."
]
| train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/common/src/main/java/io/netty/util/ResourceLeakDetectorFactory.java#L64-L66 |
couchbase/couchbase-java-client | src/main/java/com/couchbase/client/java/query/dsl/functions/DateFunctions.java | DateFunctions.dateTruncMillis | public static Expression dateTruncMillis(String expression, DatePart part) {
"""
Returned expression results in UNIX timestamp that has been truncated so that the given date part
is the least significant.
"""
return dateTruncMillis(x(expression), part);
} | java | public static Expression dateTruncMillis(String expression, DatePart part) {
return dateTruncMillis(x(expression), part);
} | [
"public",
"static",
"Expression",
"dateTruncMillis",
"(",
"String",
"expression",
",",
"DatePart",
"part",
")",
"{",
"return",
"dateTruncMillis",
"(",
"x",
"(",
"expression",
")",
",",
"part",
")",
";",
"}"
]
| Returned expression results in UNIX timestamp that has been truncated so that the given date part
is the least significant. | [
"Returned",
"expression",
"results",
"in",
"UNIX",
"timestamp",
"that",
"has",
"been",
"truncated",
"so",
"that",
"the",
"given",
"date",
"part",
"is",
"the",
"least",
"significant",
"."
]
| train | https://github.com/couchbase/couchbase-java-client/blob/f36a0ee0c66923bdde47838ca543e50cbaa99e14/src/main/java/com/couchbase/client/java/query/dsl/functions/DateFunctions.java#L180-L182 |
netty/netty | codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2LocalFlowController.java | DefaultHttp2LocalFlowController.windowUpdateRatio | public void windowUpdateRatio(Http2Stream stream, float ratio) throws Http2Exception {
"""
The window update ratio is used to determine when a window update must be sent. If the ratio
of bytes processed since the last update has meet or exceeded this ratio then a window update will
be sent. This window update ratio will only be applied to {@code streamId}.
<p>
Note it is the responsibly of the caller to ensure that the the
initial {@code SETTINGS} frame is sent before this is called. It would
be considered a {@link Http2Error#PROTOCOL_ERROR} if a {@code WINDOW_UPDATE}
was generated by this method before the initial {@code SETTINGS} frame is sent.
@param stream the stream for which {@code ratio} applies to.
@param ratio the ratio to use when checking if a {@code WINDOW_UPDATE} is determined necessary.
@throws Http2Exception If a protocol-error occurs while generating {@code WINDOW_UPDATE} frames
"""
assert ctx != null && ctx.executor().inEventLoop();
checkValidRatio(ratio);
FlowState state = state(stream);
state.windowUpdateRatio(ratio);
state.writeWindowUpdateIfNeeded();
} | java | public void windowUpdateRatio(Http2Stream stream, float ratio) throws Http2Exception {
assert ctx != null && ctx.executor().inEventLoop();
checkValidRatio(ratio);
FlowState state = state(stream);
state.windowUpdateRatio(ratio);
state.writeWindowUpdateIfNeeded();
} | [
"public",
"void",
"windowUpdateRatio",
"(",
"Http2Stream",
"stream",
",",
"float",
"ratio",
")",
"throws",
"Http2Exception",
"{",
"assert",
"ctx",
"!=",
"null",
"&&",
"ctx",
".",
"executor",
"(",
")",
".",
"inEventLoop",
"(",
")",
";",
"checkValidRatio",
"(",
"ratio",
")",
";",
"FlowState",
"state",
"=",
"state",
"(",
"stream",
")",
";",
"state",
".",
"windowUpdateRatio",
"(",
"ratio",
")",
";",
"state",
".",
"writeWindowUpdateIfNeeded",
"(",
")",
";",
"}"
]
| The window update ratio is used to determine when a window update must be sent. If the ratio
of bytes processed since the last update has meet or exceeded this ratio then a window update will
be sent. This window update ratio will only be applied to {@code streamId}.
<p>
Note it is the responsibly of the caller to ensure that the the
initial {@code SETTINGS} frame is sent before this is called. It would
be considered a {@link Http2Error#PROTOCOL_ERROR} if a {@code WINDOW_UPDATE}
was generated by this method before the initial {@code SETTINGS} frame is sent.
@param stream the stream for which {@code ratio} applies to.
@param ratio the ratio to use when checking if a {@code WINDOW_UPDATE} is determined necessary.
@throws Http2Exception If a protocol-error occurs while generating {@code WINDOW_UPDATE} frames | [
"The",
"window",
"update",
"ratio",
"is",
"used",
"to",
"determine",
"when",
"a",
"window",
"update",
"must",
"be",
"sent",
".",
"If",
"the",
"ratio",
"of",
"bytes",
"processed",
"since",
"the",
"last",
"update",
"has",
"meet",
"or",
"exceeded",
"this",
"ratio",
"then",
"a",
"window",
"update",
"will",
"be",
"sent",
".",
"This",
"window",
"update",
"ratio",
"will",
"only",
"be",
"applied",
"to",
"{"
]
| train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2LocalFlowController.java#L242-L248 |
actorapp/actor-platform | actor-sdk/sdk-core/runtime/runtime-shared/src/main/java/im/actor/runtime/markdown/MarkdownParser.java | MarkdownParser.handleSpan | private boolean handleSpan(TextCursor cursor, int blockEnd, ArrayList<MDText> elements) {
"""
Handling span
@param cursor text cursor
@param blockEnd span search limit
@param elements current elements
@return is
"""
if (mode != MODE_ONLY_LINKS) {
int spanStart = findSpanStart(cursor, blockEnd);
if (spanStart >= 0) {
char span = cursor.text.charAt(spanStart);
int spanEnd = findSpanEnd(cursor, spanStart, blockEnd, span);
if (spanEnd >= 0) {
// Handling next elements before span
handleUrls(cursor, spanStart, elements);
// Increment offset before processing internal spans
cursor.currentOffset++;
// Building child spans
MDText[] spanElements = handleSpans(cursor, spanEnd - 1);
// End of search: move cursor after span
cursor.currentOffset = spanEnd;
MDSpan spanElement = new MDSpan(
span == '*' ? MDSpan.TYPE_BOLD : MDSpan.TYPE_ITALIC,
spanElements);
elements.add(spanElement);
return true;
}
}
}
handleUrls(cursor, blockEnd, elements);
return false;
} | java | private boolean handleSpan(TextCursor cursor, int blockEnd, ArrayList<MDText> elements) {
if (mode != MODE_ONLY_LINKS) {
int spanStart = findSpanStart(cursor, blockEnd);
if (spanStart >= 0) {
char span = cursor.text.charAt(spanStart);
int spanEnd = findSpanEnd(cursor, spanStart, blockEnd, span);
if (spanEnd >= 0) {
// Handling next elements before span
handleUrls(cursor, spanStart, elements);
// Increment offset before processing internal spans
cursor.currentOffset++;
// Building child spans
MDText[] spanElements = handleSpans(cursor, spanEnd - 1);
// End of search: move cursor after span
cursor.currentOffset = spanEnd;
MDSpan spanElement = new MDSpan(
span == '*' ? MDSpan.TYPE_BOLD : MDSpan.TYPE_ITALIC,
spanElements);
elements.add(spanElement);
return true;
}
}
}
handleUrls(cursor, blockEnd, elements);
return false;
} | [
"private",
"boolean",
"handleSpan",
"(",
"TextCursor",
"cursor",
",",
"int",
"blockEnd",
",",
"ArrayList",
"<",
"MDText",
">",
"elements",
")",
"{",
"if",
"(",
"mode",
"!=",
"MODE_ONLY_LINKS",
")",
"{",
"int",
"spanStart",
"=",
"findSpanStart",
"(",
"cursor",
",",
"blockEnd",
")",
";",
"if",
"(",
"spanStart",
">=",
"0",
")",
"{",
"char",
"span",
"=",
"cursor",
".",
"text",
".",
"charAt",
"(",
"spanStart",
")",
";",
"int",
"spanEnd",
"=",
"findSpanEnd",
"(",
"cursor",
",",
"spanStart",
",",
"blockEnd",
",",
"span",
")",
";",
"if",
"(",
"spanEnd",
">=",
"0",
")",
"{",
"// Handling next elements before span",
"handleUrls",
"(",
"cursor",
",",
"spanStart",
",",
"elements",
")",
";",
"// Increment offset before processing internal spans",
"cursor",
".",
"currentOffset",
"++",
";",
"// Building child spans",
"MDText",
"[",
"]",
"spanElements",
"=",
"handleSpans",
"(",
"cursor",
",",
"spanEnd",
"-",
"1",
")",
";",
"// End of search: move cursor after span",
"cursor",
".",
"currentOffset",
"=",
"spanEnd",
";",
"MDSpan",
"spanElement",
"=",
"new",
"MDSpan",
"(",
"span",
"==",
"'",
"'",
"?",
"MDSpan",
".",
"TYPE_BOLD",
":",
"MDSpan",
".",
"TYPE_ITALIC",
",",
"spanElements",
")",
";",
"elements",
".",
"add",
"(",
"spanElement",
")",
";",
"return",
"true",
";",
"}",
"}",
"}",
"handleUrls",
"(",
"cursor",
",",
"blockEnd",
",",
"elements",
")",
";",
"return",
"false",
";",
"}"
]
| Handling span
@param cursor text cursor
@param blockEnd span search limit
@param elements current elements
@return is | [
"Handling",
"span"
]
| train | https://github.com/actorapp/actor-platform/blob/5123c1584757c6eeea0ed2a0e7e043629871a0c6/actor-sdk/sdk-core/runtime/runtime-shared/src/main/java/im/actor/runtime/markdown/MarkdownParser.java#L112-L146 |
threerings/gwt-utils | src/main/java/com/threerings/gwt/ui/Popups.java | Popups.centerOn | public static <T extends PopupPanel> T centerOn (T popup, int ypos) {
"""
Centers the supplied vertically on the supplied trigger widget. The popup's showing state
will be preserved.
@return the supplied popup.
"""
boolean wasHidden = !popup.isShowing();
boolean wasVisible = popup.isVisible();
if (wasVisible) {
popup.setVisible(false);
}
if (wasHidden) {
popup.show();
}
int left = (Window.getClientWidth() - popup.getOffsetWidth()) >> 1;
int top = ypos - popup.getOffsetHeight()/2;
// bound the popup into the visible browser area if possible
if (popup.getOffsetHeight() < Window.getClientHeight()) {
top = Math.min(Math.max(0, top), Window.getClientHeight() - popup.getOffsetHeight());
}
popup.setPopupPosition(left, top);
if (wasHidden) {
popup.hide();
}
if (wasVisible) {
popup.setVisible(true);
}
return popup;
} | java | public static <T extends PopupPanel> T centerOn (T popup, int ypos)
{
boolean wasHidden = !popup.isShowing();
boolean wasVisible = popup.isVisible();
if (wasVisible) {
popup.setVisible(false);
}
if (wasHidden) {
popup.show();
}
int left = (Window.getClientWidth() - popup.getOffsetWidth()) >> 1;
int top = ypos - popup.getOffsetHeight()/2;
// bound the popup into the visible browser area if possible
if (popup.getOffsetHeight() < Window.getClientHeight()) {
top = Math.min(Math.max(0, top), Window.getClientHeight() - popup.getOffsetHeight());
}
popup.setPopupPosition(left, top);
if (wasHidden) {
popup.hide();
}
if (wasVisible) {
popup.setVisible(true);
}
return popup;
} | [
"public",
"static",
"<",
"T",
"extends",
"PopupPanel",
">",
"T",
"centerOn",
"(",
"T",
"popup",
",",
"int",
"ypos",
")",
"{",
"boolean",
"wasHidden",
"=",
"!",
"popup",
".",
"isShowing",
"(",
")",
";",
"boolean",
"wasVisible",
"=",
"popup",
".",
"isVisible",
"(",
")",
";",
"if",
"(",
"wasVisible",
")",
"{",
"popup",
".",
"setVisible",
"(",
"false",
")",
";",
"}",
"if",
"(",
"wasHidden",
")",
"{",
"popup",
".",
"show",
"(",
")",
";",
"}",
"int",
"left",
"=",
"(",
"Window",
".",
"getClientWidth",
"(",
")",
"-",
"popup",
".",
"getOffsetWidth",
"(",
")",
")",
">>",
"1",
";",
"int",
"top",
"=",
"ypos",
"-",
"popup",
".",
"getOffsetHeight",
"(",
")",
"/",
"2",
";",
"// bound the popup into the visible browser area if possible",
"if",
"(",
"popup",
".",
"getOffsetHeight",
"(",
")",
"<",
"Window",
".",
"getClientHeight",
"(",
")",
")",
"{",
"top",
"=",
"Math",
".",
"min",
"(",
"Math",
".",
"max",
"(",
"0",
",",
"top",
")",
",",
"Window",
".",
"getClientHeight",
"(",
")",
"-",
"popup",
".",
"getOffsetHeight",
"(",
")",
")",
";",
"}",
"popup",
".",
"setPopupPosition",
"(",
"left",
",",
"top",
")",
";",
"if",
"(",
"wasHidden",
")",
"{",
"popup",
".",
"hide",
"(",
")",
";",
"}",
"if",
"(",
"wasVisible",
")",
"{",
"popup",
".",
"setVisible",
"(",
"true",
")",
";",
"}",
"return",
"popup",
";",
"}"
]
| Centers the supplied vertically on the supplied trigger widget. The popup's showing state
will be preserved.
@return the supplied popup. | [
"Centers",
"the",
"supplied",
"vertically",
"on",
"the",
"supplied",
"trigger",
"widget",
".",
"The",
"popup",
"s",
"showing",
"state",
"will",
"be",
"preserved",
"."
]
| train | https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/ui/Popups.java#L240-L264 |
jamesagnew/hapi-fhir | hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/conformance/ShExGenerator.java | ShExGenerator.genInnerTypeDef | private String genInnerTypeDef(StructureDefinition sd, ElementDefinition ed) {
"""
Generate a definition for a referenced element
@param sd Containing structure definition
@param ed Inner element
@return ShEx representation of element reference
"""
String path = ed.hasBase() ? ed.getBase().getPath() : ed.getPath();;
ST element_reference = tmplt(SHAPE_DEFINITION_TEMPLATE);
element_reference.add("resourceDecl", ""); // Not a resource
element_reference.add("id", path);
String comment = ed.getShort();
element_reference.add("comment", comment == null? " " : "# " + comment);
List<String> elements = new ArrayList<String>();
for (ElementDefinition child: ProfileUtilities.getChildList(sd, path, null))
elements.add(genElementDefinition(sd, child));
element_reference.add("elements", StringUtils.join(elements, "\n"));
return element_reference.render();
} | java | private String genInnerTypeDef(StructureDefinition sd, ElementDefinition ed) {
String path = ed.hasBase() ? ed.getBase().getPath() : ed.getPath();;
ST element_reference = tmplt(SHAPE_DEFINITION_TEMPLATE);
element_reference.add("resourceDecl", ""); // Not a resource
element_reference.add("id", path);
String comment = ed.getShort();
element_reference.add("comment", comment == null? " " : "# " + comment);
List<String> elements = new ArrayList<String>();
for (ElementDefinition child: ProfileUtilities.getChildList(sd, path, null))
elements.add(genElementDefinition(sd, child));
element_reference.add("elements", StringUtils.join(elements, "\n"));
return element_reference.render();
} | [
"private",
"String",
"genInnerTypeDef",
"(",
"StructureDefinition",
"sd",
",",
"ElementDefinition",
"ed",
")",
"{",
"String",
"path",
"=",
"ed",
".",
"hasBase",
"(",
")",
"?",
"ed",
".",
"getBase",
"(",
")",
".",
"getPath",
"(",
")",
":",
"ed",
".",
"getPath",
"(",
")",
";",
";",
"ST",
"element_reference",
"=",
"tmplt",
"(",
"SHAPE_DEFINITION_TEMPLATE",
")",
";",
"element_reference",
".",
"add",
"(",
"\"resourceDecl\"",
",",
"\"\"",
")",
";",
"// Not a resource\r",
"element_reference",
".",
"add",
"(",
"\"id\"",
",",
"path",
")",
";",
"String",
"comment",
"=",
"ed",
".",
"getShort",
"(",
")",
";",
"element_reference",
".",
"add",
"(",
"\"comment\"",
",",
"comment",
"==",
"null",
"?",
"\" \"",
":",
"\"# \"",
"+",
"comment",
")",
";",
"List",
"<",
"String",
">",
"elements",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"ElementDefinition",
"child",
":",
"ProfileUtilities",
".",
"getChildList",
"(",
"sd",
",",
"path",
",",
"null",
")",
")",
"elements",
".",
"(",
"genElementDefinition",
"(",
"sd",
",",
"child",
")",
")",
";",
"element_reference",
".",
"add",
"(",
"\"elements\"",
",",
"StringUtils",
".",
"join",
"(",
"elements",
",",
"\"\\n\"",
")",
")",
";",
"return",
"element_reference",
".",
"render",
"(",
")",
";",
"}"
]
| Generate a definition for a referenced element
@param sd Containing structure definition
@param ed Inner element
@return ShEx representation of element reference | [
"Generate",
"a",
"definition",
"for",
"a",
"referenced",
"element"
]
| train | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/conformance/ShExGenerator.java#L685-L699 |
TNG/ArchUnit | archunit/src/main/java/com/tngtech/archunit/library/dependencies/Slices.java | Slices.assignedFrom | @PublicAPI(usage = ACCESS)
public static Transformer assignedFrom(SliceAssignment sliceAssignment) {
"""
Supports partitioning a set of {@link JavaClasses} into different {@link Slices} by the supplied
{@link SliceAssignment}. This is basically a mapping {@link JavaClass} -> {@link SliceIdentifier},
i.e. if the {@link SliceAssignment} returns the same
{@link SliceIdentifier} for two classes they will end up in the same slice.
A {@link JavaClass} will be ignored within the slices, if its {@link SliceIdentifier} is
{@link SliceIdentifier#ignore()}. For example
<p>
Suppose there are four classes:<br><br>
{@code com.somewhere.SomeClass}<br>
{@code com.somewhere.AnotherClass}<br>
{@code com.other.elsewhere.YetAnotherClass}<br>
{@code com.randomly.anywhere.AndYetAnotherClass}<br><br>
If slices are created by specifying<br><br>
{@code Slices.of(classes).assignedFrom(customAssignment)}<br><br>
and the {@code customAssignment} maps<br><br>
{@code com.somewhere -> SliceIdentifier.of("somewhere")}<br>
{@code com.other.elsewhere -> SliceIdentifier.of("elsewhere")}<br>
{@code com.randomly -> SliceIdentifier.ignore()}<br><br>
then the result will be two slices, identified by the single strings 'somewhere' (containing {@code SomeClass}
and {@code AnotherClass}) and 'elsewhere' (containing {@code YetAnotherClass}). The class {@code AndYetAnotherClass}
will be missing from all slices.
@param sliceAssignment The assignment of {@link JavaClass} to {@link SliceIdentifier}
@return Slices partitioned according the supplied assignment
"""
String description = "slices assigned from " + sliceAssignment.getDescription();
return new Transformer(sliceAssignment, description);
} | java | @PublicAPI(usage = ACCESS)
public static Transformer assignedFrom(SliceAssignment sliceAssignment) {
String description = "slices assigned from " + sliceAssignment.getDescription();
return new Transformer(sliceAssignment, description);
} | [
"@",
"PublicAPI",
"(",
"usage",
"=",
"ACCESS",
")",
"public",
"static",
"Transformer",
"assignedFrom",
"(",
"SliceAssignment",
"sliceAssignment",
")",
"{",
"String",
"description",
"=",
"\"slices assigned from \"",
"+",
"sliceAssignment",
".",
"getDescription",
"(",
")",
";",
"return",
"new",
"Transformer",
"(",
"sliceAssignment",
",",
"description",
")",
";",
"}"
]
| Supports partitioning a set of {@link JavaClasses} into different {@link Slices} by the supplied
{@link SliceAssignment}. This is basically a mapping {@link JavaClass} -> {@link SliceIdentifier},
i.e. if the {@link SliceAssignment} returns the same
{@link SliceIdentifier} for two classes they will end up in the same slice.
A {@link JavaClass} will be ignored within the slices, if its {@link SliceIdentifier} is
{@link SliceIdentifier#ignore()}. For example
<p>
Suppose there are four classes:<br><br>
{@code com.somewhere.SomeClass}<br>
{@code com.somewhere.AnotherClass}<br>
{@code com.other.elsewhere.YetAnotherClass}<br>
{@code com.randomly.anywhere.AndYetAnotherClass}<br><br>
If slices are created by specifying<br><br>
{@code Slices.of(classes).assignedFrom(customAssignment)}<br><br>
and the {@code customAssignment} maps<br><br>
{@code com.somewhere -> SliceIdentifier.of("somewhere")}<br>
{@code com.other.elsewhere -> SliceIdentifier.of("elsewhere")}<br>
{@code com.randomly -> SliceIdentifier.ignore()}<br><br>
then the result will be two slices, identified by the single strings 'somewhere' (containing {@code SomeClass}
and {@code AnotherClass}) and 'elsewhere' (containing {@code YetAnotherClass}). The class {@code AndYetAnotherClass}
will be missing from all slices.
@param sliceAssignment The assignment of {@link JavaClass} to {@link SliceIdentifier}
@return Slices partitioned according the supplied assignment | [
"Supports",
"partitioning",
"a",
"set",
"of",
"{",
"@link",
"JavaClasses",
"}",
"into",
"different",
"{",
"@link",
"Slices",
"}",
"by",
"the",
"supplied",
"{",
"@link",
"SliceAssignment",
"}",
".",
"This",
"is",
"basically",
"a",
"mapping",
"{",
"@link",
"JavaClass",
"}",
"-",
">",
";",
"{",
"@link",
"SliceIdentifier",
"}",
"i",
".",
"e",
".",
"if",
"the",
"{",
"@link",
"SliceAssignment",
"}",
"returns",
"the",
"same",
"{",
"@link",
"SliceIdentifier",
"}",
"for",
"two",
"classes",
"they",
"will",
"end",
"up",
"in",
"the",
"same",
"slice",
".",
"A",
"{",
"@link",
"JavaClass",
"}",
"will",
"be",
"ignored",
"within",
"the",
"slices",
"if",
"its",
"{",
"@link",
"SliceIdentifier",
"}",
"is",
"{",
"@link",
"SliceIdentifier#ignore",
"()",
"}",
".",
"For",
"example",
"<p",
">",
"Suppose",
"there",
"are",
"four",
"classes",
":",
"<br",
">",
"<br",
">",
"{",
"@code",
"com",
".",
"somewhere",
".",
"SomeClass",
"}",
"<br",
">",
"{",
"@code",
"com",
".",
"somewhere",
".",
"AnotherClass",
"}",
"<br",
">",
"{",
"@code",
"com",
".",
"other",
".",
"elsewhere",
".",
"YetAnotherClass",
"}",
"<br",
">",
"{",
"@code",
"com",
".",
"randomly",
".",
"anywhere",
".",
"AndYetAnotherClass",
"}",
"<br",
">",
"<br",
">",
"If",
"slices",
"are",
"created",
"by",
"specifying<br",
">",
"<br",
">",
"{",
"@code",
"Slices",
".",
"of",
"(",
"classes",
")",
".",
"assignedFrom",
"(",
"customAssignment",
")",
"}",
"<br",
">",
"<br",
">"
]
| train | https://github.com/TNG/ArchUnit/blob/024c5d2502e91de6cb586b86c7084dbd12f3ef37/archunit/src/main/java/com/tngtech/archunit/library/dependencies/Slices.java#L154-L158 |
alexvasilkov/GestureViews | library/src/main/java/com/alexvasilkov/gestures/Settings.java | Settings.setOverscrollDistance | public Settings setOverscrollDistance(float distanceX, float distanceY) {
"""
Setting overscroll distance in pixels. User will be able to "over scroll"
up to this distance. Cannot be < 0.
<p>
Default value is 0.
@param distanceX Horizontal overscroll distance in pixels
@param distanceY Vertical overscroll distance in pixels
@return Current settings object for calls chaining
"""
if (distanceX < 0f || distanceY < 0f) {
throw new IllegalArgumentException("Overscroll distance cannot be < 0");
}
overscrollDistanceX = distanceX;
overscrollDistanceY = distanceY;
return this;
} | java | public Settings setOverscrollDistance(float distanceX, float distanceY) {
if (distanceX < 0f || distanceY < 0f) {
throw new IllegalArgumentException("Overscroll distance cannot be < 0");
}
overscrollDistanceX = distanceX;
overscrollDistanceY = distanceY;
return this;
} | [
"public",
"Settings",
"setOverscrollDistance",
"(",
"float",
"distanceX",
",",
"float",
"distanceY",
")",
"{",
"if",
"(",
"distanceX",
"<",
"0f",
"||",
"distanceY",
"<",
"0f",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Overscroll distance cannot be < 0\"",
")",
";",
"}",
"overscrollDistanceX",
"=",
"distanceX",
";",
"overscrollDistanceY",
"=",
"distanceY",
";",
"return",
"this",
";",
"}"
]
| Setting overscroll distance in pixels. User will be able to "over scroll"
up to this distance. Cannot be < 0.
<p>
Default value is 0.
@param distanceX Horizontal overscroll distance in pixels
@param distanceY Vertical overscroll distance in pixels
@return Current settings object for calls chaining | [
"Setting",
"overscroll",
"distance",
"in",
"pixels",
".",
"User",
"will",
"be",
"able",
"to",
"over",
"scroll",
"up",
"to",
"this",
"distance",
".",
"Cannot",
"be",
"<",
";",
"0",
".",
"<p",
">",
"Default",
"value",
"is",
"0",
"."
]
| train | https://github.com/alexvasilkov/GestureViews/blob/f0a4c266e31dcad23bd0d9013531bc1c501b9c9f/library/src/main/java/com/alexvasilkov/gestures/Settings.java#L331-L338 |
crawljax/crawljax | core/src/main/java/com/crawljax/core/configuration/CrawlElement.java | CrawlElement.withAttribute | public CrawlElement withAttribute(String attributeName, String value) {
"""
Restrict CrawlElement to include only HTML elements with the specified attribute. For example
<div class="foo">... <div class="bar">.. </div> </div>
withAttribute("class", "foo") Would restrict this CrawlElement to only include the div with
class="foo"... AttributeName and value strings can support wild-card characters. Use % in to
represent a wild-card string. e.g (% is the regex .*) When withAttribute() is called multiple
times the CrawlElement will match only those HTML elements that have all the specified
attributes.
@param attributeName the name of the attribute
@param value the value of the attribute
@return this CrawlElement
"""
if (this.underXpath == null || this.underXpath.isEmpty()) {
this.underXpath = "//" + this.tagName + "[@" + attributeName + "='" + value + "']";
} else {
this.underXpath = this.underXpath + " | " + "//" + this.tagName + "[@" + attributeName
+ "='" + value + "']";
}
return this;
} | java | public CrawlElement withAttribute(String attributeName, String value) {
if (this.underXpath == null || this.underXpath.isEmpty()) {
this.underXpath = "//" + this.tagName + "[@" + attributeName + "='" + value + "']";
} else {
this.underXpath = this.underXpath + " | " + "//" + this.tagName + "[@" + attributeName
+ "='" + value + "']";
}
return this;
} | [
"public",
"CrawlElement",
"withAttribute",
"(",
"String",
"attributeName",
",",
"String",
"value",
")",
"{",
"if",
"(",
"this",
".",
"underXpath",
"==",
"null",
"||",
"this",
".",
"underXpath",
".",
"isEmpty",
"(",
")",
")",
"{",
"this",
".",
"underXpath",
"=",
"\"//\"",
"+",
"this",
".",
"tagName",
"+",
"\"[@\"",
"+",
"attributeName",
"+",
"\"='\"",
"+",
"value",
"+",
"\"']\"",
";",
"}",
"else",
"{",
"this",
".",
"underXpath",
"=",
"this",
".",
"underXpath",
"+",
"\" | \"",
"+",
"\"//\"",
"+",
"this",
".",
"tagName",
"+",
"\"[@\"",
"+",
"attributeName",
"+",
"\"='\"",
"+",
"value",
"+",
"\"']\"",
";",
"}",
"return",
"this",
";",
"}"
]
| Restrict CrawlElement to include only HTML elements with the specified attribute. For example
<div class="foo">... <div class="bar">.. </div> </div>
withAttribute("class", "foo") Would restrict this CrawlElement to only include the div with
class="foo"... AttributeName and value strings can support wild-card characters. Use % in to
represent a wild-card string. e.g (% is the regex .*) When withAttribute() is called multiple
times the CrawlElement will match only those HTML elements that have all the specified
attributes.
@param attributeName the name of the attribute
@param value the value of the attribute
@return this CrawlElement | [
"Restrict",
"CrawlElement",
"to",
"include",
"only",
"HTML",
"elements",
"with",
"the",
"specified",
"attribute",
".",
"For",
"example",
"<",
";",
"div",
"class",
"=",
"foo",
">",
";",
"...",
"<",
";",
"div",
"class",
"=",
"bar",
">",
";",
"..",
"<",
";",
"/",
"div>",
";",
"<",
";",
"/",
"div>",
";",
"withAttribute",
"(",
"class",
"foo",
")",
"Would",
"restrict",
"this",
"CrawlElement",
"to",
"only",
"include",
"the",
"div",
"with",
"class",
"=",
"foo",
"...",
"AttributeName",
"and",
"value",
"strings",
"can",
"support",
"wild",
"-",
"card",
"characters",
".",
"Use",
"%",
"in",
"to",
"represent",
"a",
"wild",
"-",
"card",
"string",
".",
"e",
".",
"g",
"(",
"%",
"is",
"the",
"regex",
".",
"*",
")",
"When",
"withAttribute",
"()",
"is",
"called",
"multiple",
"times",
"the",
"CrawlElement",
"will",
"match",
"only",
"those",
"HTML",
"elements",
"that",
"have",
"all",
"the",
"specified",
"attributes",
"."
]
| train | https://github.com/crawljax/crawljax/blob/d339f4f622ca902ccd35322065821e52a62ec543/core/src/main/java/com/crawljax/core/configuration/CrawlElement.java#L83-L91 |
elki-project/elki | elki-core-dbids/src/main/java/de/lmu/ifi/dbs/elki/database/ids/QuickSelectDBIDs.java | QuickSelectDBIDs.insertionSort | private static void insertionSort(ArrayModifiableDBIDs data, Comparator<? super DBIDRef> comparator, int start, int end, DBIDArrayIter iter1, DBIDArrayIter iter2) {
"""
Sort a small array using repetitive insertion sort.
@param data Data to sort
@param start Interval start
@param end Interval end
"""
for(int i = start + 1; i < end; i++) {
for(int j = i; j > start; j--) {
if(comparator.compare(iter1.seek(j - 1), iter2.seek(j)) <= 0) {
break;
}
data.swap(j, j - 1);
}
}
} | java | private static void insertionSort(ArrayModifiableDBIDs data, Comparator<? super DBIDRef> comparator, int start, int end, DBIDArrayIter iter1, DBIDArrayIter iter2) {
for(int i = start + 1; i < end; i++) {
for(int j = i; j > start; j--) {
if(comparator.compare(iter1.seek(j - 1), iter2.seek(j)) <= 0) {
break;
}
data.swap(j, j - 1);
}
}
} | [
"private",
"static",
"void",
"insertionSort",
"(",
"ArrayModifiableDBIDs",
"data",
",",
"Comparator",
"<",
"?",
"super",
"DBIDRef",
">",
"comparator",
",",
"int",
"start",
",",
"int",
"end",
",",
"DBIDArrayIter",
"iter1",
",",
"DBIDArrayIter",
"iter2",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"start",
"+",
"1",
";",
"i",
"<",
"end",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"i",
";",
"j",
">",
"start",
";",
"j",
"--",
")",
"{",
"if",
"(",
"comparator",
".",
"compare",
"(",
"iter1",
".",
"seek",
"(",
"j",
"-",
"1",
")",
",",
"iter2",
".",
"seek",
"(",
"j",
")",
")",
"<=",
"0",
")",
"{",
"break",
";",
"}",
"data",
".",
"swap",
"(",
"j",
",",
"j",
"-",
"1",
")",
";",
"}",
"}",
"}"
]
| Sort a small array using repetitive insertion sort.
@param data Data to sort
@param start Interval start
@param end Interval end | [
"Sort",
"a",
"small",
"array",
"using",
"repetitive",
"insertion",
"sort",
"."
]
| train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-dbids/src/main/java/de/lmu/ifi/dbs/elki/database/ids/QuickSelectDBIDs.java#L280-L289 |
landawn/AbacusUtil | src/com/landawn/abacus/util/DateUtil.java | DateUtil.parseCalendar | public static Calendar parseCalendar(final String calendar, final String format, final TimeZone timeZone) {
"""
Converts the specified <code>calendar</code> with the specified {@code format} to a new instance of Calendar.
<code>null</code> is returned if the specified <code>date</code> is null or empty.
@param calendar
@param format
@param timeZone
@return
"""
if (N.isNullOrEmpty(calendar) || (calendar.length() == 4 && "null".equalsIgnoreCase(calendar))) {
return null;
}
return createCalendar(parse(calendar, format, timeZone));
} | java | public static Calendar parseCalendar(final String calendar, final String format, final TimeZone timeZone) {
if (N.isNullOrEmpty(calendar) || (calendar.length() == 4 && "null".equalsIgnoreCase(calendar))) {
return null;
}
return createCalendar(parse(calendar, format, timeZone));
} | [
"public",
"static",
"Calendar",
"parseCalendar",
"(",
"final",
"String",
"calendar",
",",
"final",
"String",
"format",
",",
"final",
"TimeZone",
"timeZone",
")",
"{",
"if",
"(",
"N",
".",
"isNullOrEmpty",
"(",
"calendar",
")",
"||",
"(",
"calendar",
".",
"length",
"(",
")",
"==",
"4",
"&&",
"\"null\"",
".",
"equalsIgnoreCase",
"(",
"calendar",
")",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"createCalendar",
"(",
"parse",
"(",
"calendar",
",",
"format",
",",
"timeZone",
")",
")",
";",
"}"
]
| Converts the specified <code>calendar</code> with the specified {@code format} to a new instance of Calendar.
<code>null</code> is returned if the specified <code>date</code> is null or empty.
@param calendar
@param format
@param timeZone
@return | [
"Converts",
"the",
"specified",
"<code",
">",
"calendar<",
"/",
"code",
">",
"with",
"the",
"specified",
"{",
"@code",
"format",
"}",
"to",
"a",
"new",
"instance",
"of",
"Calendar",
".",
"<code",
">",
"null<",
"/",
"code",
">",
"is",
"returned",
"if",
"the",
"specified",
"<code",
">",
"date<",
"/",
"code",
">",
"is",
"null",
"or",
"empty",
"."
]
| train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/util/DateUtil.java#L483-L489 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/NetworkProfilesInner.java | NetworkProfilesInner.getByResourceGroupAsync | public Observable<NetworkProfileInner> getByResourceGroupAsync(String resourceGroupName, String networkProfileName, String expand) {
"""
Gets the specified network profile in a specified resource group.
@param resourceGroupName The name of the resource group.
@param networkProfileName The name of the PublicIPPrefx.
@param expand Expands referenced resources.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the NetworkProfileInner object
"""
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, networkProfileName, expand).map(new Func1<ServiceResponse<NetworkProfileInner>, NetworkProfileInner>() {
@Override
public NetworkProfileInner call(ServiceResponse<NetworkProfileInner> response) {
return response.body();
}
});
} | java | public Observable<NetworkProfileInner> getByResourceGroupAsync(String resourceGroupName, String networkProfileName, String expand) {
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, networkProfileName, expand).map(new Func1<ServiceResponse<NetworkProfileInner>, NetworkProfileInner>() {
@Override
public NetworkProfileInner call(ServiceResponse<NetworkProfileInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"NetworkProfileInner",
">",
"getByResourceGroupAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"networkProfileName",
",",
"String",
"expand",
")",
"{",
"return",
"getByResourceGroupWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"networkProfileName",
",",
"expand",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"NetworkProfileInner",
">",
",",
"NetworkProfileInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"NetworkProfileInner",
"call",
"(",
"ServiceResponse",
"<",
"NetworkProfileInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Gets the specified network profile in a specified resource group.
@param resourceGroupName The name of the resource group.
@param networkProfileName The name of the PublicIPPrefx.
@param expand Expands referenced resources.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the NetworkProfileInner object | [
"Gets",
"the",
"specified",
"network",
"profile",
"in",
"a",
"specified",
"resource",
"group",
"."
]
| train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/NetworkProfilesInner.java#L286-L293 |
lucee/Lucee | core/src/main/java/lucee/transformer/util/SourceCode.java | SourceCode.subCFMLString | public SourceCode subCFMLString(int start, int count) {
"""
return a subset of the current SourceCode
@param start start position of the new subset.
@param count length of the new subset.
@return subset of the SourceCode as new SourcCode
"""
return new SourceCode(String.valueOf(text, start, count), writeLog, dialect);
} | java | public SourceCode subCFMLString(int start, int count) {
return new SourceCode(String.valueOf(text, start, count), writeLog, dialect);
} | [
"public",
"SourceCode",
"subCFMLString",
"(",
"int",
"start",
",",
"int",
"count",
")",
"{",
"return",
"new",
"SourceCode",
"(",
"String",
".",
"valueOf",
"(",
"text",
",",
"start",
",",
"count",
")",
",",
"writeLog",
",",
"dialect",
")",
";",
"}"
]
| return a subset of the current SourceCode
@param start start position of the new subset.
@param count length of the new subset.
@return subset of the SourceCode as new SourcCode | [
"return",
"a",
"subset",
"of",
"the",
"current",
"SourceCode"
]
| train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/transformer/util/SourceCode.java#L687-L690 |
classgraph/classgraph | src/main/java/io/github/classgraph/ClassInfo.java | ClassInfo.getOrCreateClassInfo | static ClassInfo getOrCreateClassInfo(final String className, final int classModifiers,
final Map<String, ClassInfo> classNameToClassInfo) {
"""
Get a ClassInfo object, or create it if it doesn't exist. N.B. not threadsafe, so ClassInfo objects should
only ever be constructed by a single thread.
@param className
the class name
@param classModifiers
the class modifiers
@param classNameToClassInfo
the map from class name to class info
@return the or create class info
"""
ClassInfo classInfo = classNameToClassInfo.get(className);
if (classInfo == null) {
classNameToClassInfo.put(className,
classInfo = new ClassInfo(className, classModifiers, /* classfileResource = */ null));
}
classInfo.setModifiers(classModifiers);
return classInfo;
} | java | static ClassInfo getOrCreateClassInfo(final String className, final int classModifiers,
final Map<String, ClassInfo> classNameToClassInfo) {
ClassInfo classInfo = classNameToClassInfo.get(className);
if (classInfo == null) {
classNameToClassInfo.put(className,
classInfo = new ClassInfo(className, classModifiers, /* classfileResource = */ null));
}
classInfo.setModifiers(classModifiers);
return classInfo;
} | [
"static",
"ClassInfo",
"getOrCreateClassInfo",
"(",
"final",
"String",
"className",
",",
"final",
"int",
"classModifiers",
",",
"final",
"Map",
"<",
"String",
",",
"ClassInfo",
">",
"classNameToClassInfo",
")",
"{",
"ClassInfo",
"classInfo",
"=",
"classNameToClassInfo",
".",
"get",
"(",
"className",
")",
";",
"if",
"(",
"classInfo",
"==",
"null",
")",
"{",
"classNameToClassInfo",
".",
"put",
"(",
"className",
",",
"classInfo",
"=",
"new",
"ClassInfo",
"(",
"className",
",",
"classModifiers",
",",
"/* classfileResource = */",
"null",
")",
")",
";",
"}",
"classInfo",
".",
"setModifiers",
"(",
"classModifiers",
")",
";",
"return",
"classInfo",
";",
"}"
]
| Get a ClassInfo object, or create it if it doesn't exist. N.B. not threadsafe, so ClassInfo objects should
only ever be constructed by a single thread.
@param className
the class name
@param classModifiers
the class modifiers
@param classNameToClassInfo
the map from class name to class info
@return the or create class info | [
"Get",
"a",
"ClassInfo",
"object",
"or",
"create",
"it",
"if",
"it",
"doesn",
"t",
"exist",
".",
"N",
".",
"B",
".",
"not",
"threadsafe",
"so",
"ClassInfo",
"objects",
"should",
"only",
"ever",
"be",
"constructed",
"by",
"a",
"single",
"thread",
"."
]
| train | https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfo.java#L309-L318 |
UrielCh/ovh-java-sdk | ovh-java-sdk-dedicatedCloud/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedCloud.java | ApiOvhDedicatedCloud.location_pccZone_hypervisor_shortName_GET | public OvhOs location_pccZone_hypervisor_shortName_GET(String pccZone, String shortName) throws IOException {
"""
Get this object properties
REST: GET /dedicatedCloud/location/{pccZone}/hypervisor/{shortName}
@param pccZone [required] Name of pccZone
@param shortName [required] Short name of hypervisor
"""
String qPath = "/dedicatedCloud/location/{pccZone}/hypervisor/{shortName}";
StringBuilder sb = path(qPath, pccZone, shortName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhOs.class);
} | java | public OvhOs location_pccZone_hypervisor_shortName_GET(String pccZone, String shortName) throws IOException {
String qPath = "/dedicatedCloud/location/{pccZone}/hypervisor/{shortName}";
StringBuilder sb = path(qPath, pccZone, shortName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhOs.class);
} | [
"public",
"OvhOs",
"location_pccZone_hypervisor_shortName_GET",
"(",
"String",
"pccZone",
",",
"String",
"shortName",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/dedicatedCloud/location/{pccZone}/hypervisor/{shortName}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"pccZone",
",",
"shortName",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhOs",
".",
"class",
")",
";",
"}"
]
| Get this object properties
REST: GET /dedicatedCloud/location/{pccZone}/hypervisor/{shortName}
@param pccZone [required] Name of pccZone
@param shortName [required] Short name of hypervisor | [
"Get",
"this",
"object",
"properties"
]
| train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-dedicatedCloud/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedCloud.java#L3081-L3086 |
fuinorg/objects4j | src/main/java/org/fuin/objects4j/vo/HourRange.java | HourRange.joinWithNextDay | public HourRange joinWithNextDay(@NotNull final HourRange other) {
"""
Appends a single hour range to this one and returns a new instance. This is only allowed if this instance has 'to=24:00' and
'from=00:00' for the other instance.
@param other
Range start starts with '00:00'
@return New instance with "from" taken from this instance and 'to' taken from the other one.
"""
Contract.requireArgNotNull("other", other);
if (!this.to.equals(new Hour(24, 0))) {
throw new ConstraintViolationException("The 'to' hour value of this instance is not '24:00', but was: '" + this.to + "'");
}
if (!other.from.equals(new Hour(0, 0))) {
throw new ConstraintViolationException(
"The 'from' hour value of the other instance is not '00:00', but was: '" + other.from + "'");
}
final int thisClosedMinutes = getClosedMinutes();
final int otherOpenMinutes = other.getOpenMinutes();
if (otherOpenMinutes > thisClosedMinutes) {
throw new ConstraintViolationException(
"The hour range of the other instance cannot be greater than hours not used by this instance: this='" + this
+ "', other='" + other + "'");
}
if (this.from.equals(other.to)) {
return new HourRange("00:00-24:00");
}
return new HourRange(this.from, other.to);
} | java | public HourRange joinWithNextDay(@NotNull final HourRange other) {
Contract.requireArgNotNull("other", other);
if (!this.to.equals(new Hour(24, 0))) {
throw new ConstraintViolationException("The 'to' hour value of this instance is not '24:00', but was: '" + this.to + "'");
}
if (!other.from.equals(new Hour(0, 0))) {
throw new ConstraintViolationException(
"The 'from' hour value of the other instance is not '00:00', but was: '" + other.from + "'");
}
final int thisClosedMinutes = getClosedMinutes();
final int otherOpenMinutes = other.getOpenMinutes();
if (otherOpenMinutes > thisClosedMinutes) {
throw new ConstraintViolationException(
"The hour range of the other instance cannot be greater than hours not used by this instance: this='" + this
+ "', other='" + other + "'");
}
if (this.from.equals(other.to)) {
return new HourRange("00:00-24:00");
}
return new HourRange(this.from, other.to);
} | [
"public",
"HourRange",
"joinWithNextDay",
"(",
"@",
"NotNull",
"final",
"HourRange",
"other",
")",
"{",
"Contract",
".",
"requireArgNotNull",
"(",
"\"other\"",
",",
"other",
")",
";",
"if",
"(",
"!",
"this",
".",
"to",
".",
"equals",
"(",
"new",
"Hour",
"(",
"24",
",",
"0",
")",
")",
")",
"{",
"throw",
"new",
"ConstraintViolationException",
"(",
"\"The 'to' hour value of this instance is not '24:00', but was: '\"",
"+",
"this",
".",
"to",
"+",
"\"'\"",
")",
";",
"}",
"if",
"(",
"!",
"other",
".",
"from",
".",
"equals",
"(",
"new",
"Hour",
"(",
"0",
",",
"0",
")",
")",
")",
"{",
"throw",
"new",
"ConstraintViolationException",
"(",
"\"The 'from' hour value of the other instance is not '00:00', but was: '\"",
"+",
"other",
".",
"from",
"+",
"\"'\"",
")",
";",
"}",
"final",
"int",
"thisClosedMinutes",
"=",
"getClosedMinutes",
"(",
")",
";",
"final",
"int",
"otherOpenMinutes",
"=",
"other",
".",
"getOpenMinutes",
"(",
")",
";",
"if",
"(",
"otherOpenMinutes",
">",
"thisClosedMinutes",
")",
"{",
"throw",
"new",
"ConstraintViolationException",
"(",
"\"The hour range of the other instance cannot be greater than hours not used by this instance: this='\"",
"+",
"this",
"+",
"\"', other='\"",
"+",
"other",
"+",
"\"'\"",
")",
";",
"}",
"if",
"(",
"this",
".",
"from",
".",
"equals",
"(",
"other",
".",
"to",
")",
")",
"{",
"return",
"new",
"HourRange",
"(",
"\"00:00-24:00\"",
")",
";",
"}",
"return",
"new",
"HourRange",
"(",
"this",
".",
"from",
",",
"other",
".",
"to",
")",
";",
"}"
]
| Appends a single hour range to this one and returns a new instance. This is only allowed if this instance has 'to=24:00' and
'from=00:00' for the other instance.
@param other
Range start starts with '00:00'
@return New instance with "from" taken from this instance and 'to' taken from the other one. | [
"Appends",
"a",
"single",
"hour",
"range",
"to",
"this",
"one",
"and",
"returns",
"a",
"new",
"instance",
".",
"This",
"is",
"only",
"allowed",
"if",
"this",
"instance",
"has",
"to",
"=",
"24",
":",
"00",
"and",
"from",
"=",
"00",
":",
"00",
"for",
"the",
"other",
"instance",
"."
]
| train | https://github.com/fuinorg/objects4j/blob/e7f278b5bae073ebb6a76053650571c718f36246/src/main/java/org/fuin/objects4j/vo/HourRange.java#L236-L256 |
wanglinsong/thx-webservice | src/main/java/com/tascape/qa/th/ws/comm/WebServiceCommunication.java | WebServiceCommunication.postJson | public String postJson(String endpoint, String params, JSONObject json, String requestId) throws IOException {
"""
Issues HTTP POST request, returns response body as string.
@param endpoint endpoint of request url
@param params request line parameters
@param json request body
@param requestId request id for record response time in millisecond
@return response body
@throws IOException in case of any IO related issue
"""
String url = String.format("%s%s?%s", this.baseUri, endpoint, StringUtils.isBlank(params) ? "" : params);
LOG.debug("{} POST {}", this.hashCode(), url);
HttpPost post = new HttpPost(url);
StringEntity entity = new StringEntity(json.toString());
entity.setContentType(ContentType.APPLICATION_JSON.getMimeType());
post.setEntity(entity);
this.addHeaders(post);
HttpClientContext context = this.getHttpClientContext();
long start = System.currentTimeMillis();
CloseableHttpResponse response = this.client.execute(post, context);
if (!StringUtils.isBlank(requestId)) {
this.responseTime.put(requestId, System.currentTimeMillis() - start);
}
String res = check(response);
return res;
} | java | public String postJson(String endpoint, String params, JSONObject json, String requestId) throws IOException {
String url = String.format("%s%s?%s", this.baseUri, endpoint, StringUtils.isBlank(params) ? "" : params);
LOG.debug("{} POST {}", this.hashCode(), url);
HttpPost post = new HttpPost(url);
StringEntity entity = new StringEntity(json.toString());
entity.setContentType(ContentType.APPLICATION_JSON.getMimeType());
post.setEntity(entity);
this.addHeaders(post);
HttpClientContext context = this.getHttpClientContext();
long start = System.currentTimeMillis();
CloseableHttpResponse response = this.client.execute(post, context);
if (!StringUtils.isBlank(requestId)) {
this.responseTime.put(requestId, System.currentTimeMillis() - start);
}
String res = check(response);
return res;
} | [
"public",
"String",
"postJson",
"(",
"String",
"endpoint",
",",
"String",
"params",
",",
"JSONObject",
"json",
",",
"String",
"requestId",
")",
"throws",
"IOException",
"{",
"String",
"url",
"=",
"String",
".",
"format",
"(",
"\"%s%s?%s\"",
",",
"this",
".",
"baseUri",
",",
"endpoint",
",",
"StringUtils",
".",
"isBlank",
"(",
"params",
")",
"?",
"\"\"",
":",
"params",
")",
";",
"LOG",
".",
"debug",
"(",
"\"{} POST {}\"",
",",
"this",
".",
"hashCode",
"(",
")",
",",
"url",
")",
";",
"HttpPost",
"post",
"=",
"new",
"HttpPost",
"(",
"url",
")",
";",
"StringEntity",
"entity",
"=",
"new",
"StringEntity",
"(",
"json",
".",
"toString",
"(",
")",
")",
";",
"entity",
".",
"setContentType",
"(",
"ContentType",
".",
"APPLICATION_JSON",
".",
"getMimeType",
"(",
")",
")",
";",
"post",
".",
"setEntity",
"(",
"entity",
")",
";",
"this",
".",
"addHeaders",
"(",
"post",
")",
";",
"HttpClientContext",
"context",
"=",
"this",
".",
"getHttpClientContext",
"(",
")",
";",
"long",
"start",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"CloseableHttpResponse",
"response",
"=",
"this",
".",
"client",
".",
"execute",
"(",
"post",
",",
"context",
")",
";",
"if",
"(",
"!",
"StringUtils",
".",
"isBlank",
"(",
"requestId",
")",
")",
"{",
"this",
".",
"responseTime",
".",
"put",
"(",
"requestId",
",",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"start",
")",
";",
"}",
"String",
"res",
"=",
"check",
"(",
"response",
")",
";",
"return",
"res",
";",
"}"
]
| Issues HTTP POST request, returns response body as string.
@param endpoint endpoint of request url
@param params request line parameters
@param json request body
@param requestId request id for record response time in millisecond
@return response body
@throws IOException in case of any IO related issue | [
"Issues",
"HTTP",
"POST",
"request",
"returns",
"response",
"body",
"as",
"string",
"."
]
| train | https://github.com/wanglinsong/thx-webservice/blob/29bc084b09ad35b012eb7c6b5c9ee55337ddee28/src/main/java/com/tascape/qa/th/ws/comm/WebServiceCommunication.java#L878-L897 |
alkacon/opencms-core | src/org/opencms/ui/login/CmsPasswordForm.java | CmsPasswordForm.setErrorOldPassword | public void setErrorOldPassword(UserError error, String style) {
"""
Sets the old password error.<p>
@param error the error
@param style the style class
"""
m_oldPasswordField.setComponentError(error);
m_oldPasswordStyle.setStyle(style);
} | java | public void setErrorOldPassword(UserError error, String style) {
m_oldPasswordField.setComponentError(error);
m_oldPasswordStyle.setStyle(style);
} | [
"public",
"void",
"setErrorOldPassword",
"(",
"UserError",
"error",
",",
"String",
"style",
")",
"{",
"m_oldPasswordField",
".",
"setComponentError",
"(",
"error",
")",
";",
"m_oldPasswordStyle",
".",
"setStyle",
"(",
"style",
")",
";",
"}"
]
| Sets the old password error.<p>
@param error the error
@param style the style class | [
"Sets",
"the",
"old",
"password",
"error",
".",
"<p",
">"
]
| train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/login/CmsPasswordForm.java#L206-L210 |
liferay/com-liferay-commerce | commerce-product-type-virtual-service/src/main/java/com/liferay/commerce/product/type/virtual/service/persistence/impl/CPDefinitionVirtualSettingPersistenceImpl.java | CPDefinitionVirtualSettingPersistenceImpl.removeByC_C | @Override
public CPDefinitionVirtualSetting removeByC_C(long classNameId, long classPK)
throws NoSuchCPDefinitionVirtualSettingException {
"""
Removes the cp definition virtual setting where classNameId = ? and classPK = ? from the database.
@param classNameId the class name ID
@param classPK the class pk
@return the cp definition virtual setting that was removed
"""
CPDefinitionVirtualSetting cpDefinitionVirtualSetting = findByC_C(classNameId,
classPK);
return remove(cpDefinitionVirtualSetting);
} | java | @Override
public CPDefinitionVirtualSetting removeByC_C(long classNameId, long classPK)
throws NoSuchCPDefinitionVirtualSettingException {
CPDefinitionVirtualSetting cpDefinitionVirtualSetting = findByC_C(classNameId,
classPK);
return remove(cpDefinitionVirtualSetting);
} | [
"@",
"Override",
"public",
"CPDefinitionVirtualSetting",
"removeByC_C",
"(",
"long",
"classNameId",
",",
"long",
"classPK",
")",
"throws",
"NoSuchCPDefinitionVirtualSettingException",
"{",
"CPDefinitionVirtualSetting",
"cpDefinitionVirtualSetting",
"=",
"findByC_C",
"(",
"classNameId",
",",
"classPK",
")",
";",
"return",
"remove",
"(",
"cpDefinitionVirtualSetting",
")",
";",
"}"
]
| Removes the cp definition virtual setting where classNameId = ? and classPK = ? from the database.
@param classNameId the class name ID
@param classPK the class pk
@return the cp definition virtual setting that was removed | [
"Removes",
"the",
"cp",
"definition",
"virtual",
"setting",
"where",
"classNameId",
"=",
"?",
";",
"and",
"classPK",
"=",
"?",
";",
"from",
"the",
"database",
"."
]
| train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-type-virtual-service/src/main/java/com/liferay/commerce/product/type/virtual/service/persistence/impl/CPDefinitionVirtualSettingPersistenceImpl.java#L1660-L1667 |
twilio/twilio-java | src/main/java/com/twilio/rest/fax/v1/FaxReader.java | FaxReader.firstPage | @Override
@SuppressWarnings("checkstyle:linelength")
public Page<Fax> firstPage(final TwilioRestClient client) {
"""
Make the request to the Twilio API to perform the read.
@param client TwilioRestClient with which to make the request
@return Fax ResourceSet
"""
Request request = new Request(
HttpMethod.GET,
Domains.FAX.toString(),
"/v1/Faxes",
client.getRegion()
);
addQueryParams(request);
return pageForRequest(client, request);
} | java | @Override
@SuppressWarnings("checkstyle:linelength")
public Page<Fax> firstPage(final TwilioRestClient client) {
Request request = new Request(
HttpMethod.GET,
Domains.FAX.toString(),
"/v1/Faxes",
client.getRegion()
);
addQueryParams(request);
return pageForRequest(client, request);
} | [
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"\"checkstyle:linelength\"",
")",
"public",
"Page",
"<",
"Fax",
">",
"firstPage",
"(",
"final",
"TwilioRestClient",
"client",
")",
"{",
"Request",
"request",
"=",
"new",
"Request",
"(",
"HttpMethod",
".",
"GET",
",",
"Domains",
".",
"FAX",
".",
"toString",
"(",
")",
",",
"\"/v1/Faxes\"",
",",
"client",
".",
"getRegion",
"(",
")",
")",
";",
"addQueryParams",
"(",
"request",
")",
";",
"return",
"pageForRequest",
"(",
"client",
",",
"request",
")",
";",
"}"
]
| Make the request to the Twilio API to perform the read.
@param client TwilioRestClient with which to make the request
@return Fax ResourceSet | [
"Make",
"the",
"request",
"to",
"the",
"Twilio",
"API",
"to",
"perform",
"the",
"read",
"."
]
| train | https://github.com/twilio/twilio-java/blob/0318974c0a6a152994af167d430255684d5e9b9f/src/main/java/com/twilio/rest/fax/v1/FaxReader.java#L102-L114 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/db/shared/SharedBaseRecordTable.java | SharedBaseRecordTable.doLocalCriteria | public boolean doLocalCriteria(StringBuffer strFilter, boolean bIncludeFileName, Vector<BaseField> vParamList) {
"""
Set up/do the local criteria.
This is only here to accomodate local file systems that can't handle
REMOTE criteria. All you have to do here to handle the remote criteria
locally is to call: return record.handleRemoteCriteria(xx, yy).
""" // Default BaseListener
return super.doLocalCriteria(strFilter, bIncludeFileName, vParamList); // If can't handle remote
} | java | public boolean doLocalCriteria(StringBuffer strFilter, boolean bIncludeFileName, Vector<BaseField> vParamList)
{ // Default BaseListener
return super.doLocalCriteria(strFilter, bIncludeFileName, vParamList); // If can't handle remote
} | [
"public",
"boolean",
"doLocalCriteria",
"(",
"StringBuffer",
"strFilter",
",",
"boolean",
"bIncludeFileName",
",",
"Vector",
"<",
"BaseField",
">",
"vParamList",
")",
"{",
"// Default BaseListener",
"return",
"super",
".",
"doLocalCriteria",
"(",
"strFilter",
",",
"bIncludeFileName",
",",
"vParamList",
")",
";",
"// If can't handle remote",
"}"
]
| Set up/do the local criteria.
This is only here to accomodate local file systems that can't handle
REMOTE criteria. All you have to do here to handle the remote criteria
locally is to call: return record.handleRemoteCriteria(xx, yy). | [
"Set",
"up",
"/",
"do",
"the",
"local",
"criteria",
".",
"This",
"is",
"only",
"here",
"to",
"accomodate",
"local",
"file",
"systems",
"that",
"can",
"t",
"handle",
"REMOTE",
"criteria",
".",
"All",
"you",
"have",
"to",
"do",
"here",
"to",
"handle",
"the",
"remote",
"criteria",
"locally",
"is",
"to",
"call",
":",
"return",
"record",
".",
"handleRemoteCriteria",
"(",
"xx",
"yy",
")",
"."
]
| train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/shared/SharedBaseRecordTable.java#L365-L368 |
google/error-prone-javac | src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/TypeMaker.java | TypeMaker.getTypes | public static com.sun.javadoc.Type[] getTypes(DocEnv env, List<Type> ts) {
"""
Convert a list of javac types into an array of javadoc types.
"""
return getTypes(env, ts, new com.sun.javadoc.Type[ts.length()]);
} | java | public static com.sun.javadoc.Type[] getTypes(DocEnv env, List<Type> ts) {
return getTypes(env, ts, new com.sun.javadoc.Type[ts.length()]);
} | [
"public",
"static",
"com",
".",
"sun",
".",
"javadoc",
".",
"Type",
"[",
"]",
"getTypes",
"(",
"DocEnv",
"env",
",",
"List",
"<",
"Type",
">",
"ts",
")",
"{",
"return",
"getTypes",
"(",
"env",
",",
"ts",
",",
"new",
"com",
".",
"sun",
".",
"javadoc",
".",
"Type",
"[",
"ts",
".",
"length",
"(",
")",
"]",
")",
";",
"}"
]
| Convert a list of javac types into an array of javadoc types. | [
"Convert",
"a",
"list",
"of",
"javac",
"types",
"into",
"an",
"array",
"of",
"javadoc",
"types",
"."
]
| train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/TypeMaker.java#L118-L120 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/rng/distribution/impl/SaddlePointExpansion.java | SaddlePointExpansion.logBinomialProbability | public static double logBinomialProbability(int x, int n, double p, double q) {
"""
Compute the logarithm of the PMF for a binomial distribution
using the saddle point expansion.
@param x the value at which the probability is evaluated.
@param n the number of trials.
@param p the probability of success.
@param q the probability of failure (1 - p).
@return log(p(x)).
"""
double ret;
if (x == 0) {
if (p < 0.1) {
ret = -getDeviancePart(n, n * q) - n * p;
} else {
ret = n * FastMath.log(q);
}
} else if (x == n) {
if (q < 0.1) {
ret = -getDeviancePart(n, n * p) - n * q;
} else {
ret = n * FastMath.log(p);
}
} else {
ret = getStirlingError(n) - getStirlingError(x) - getStirlingError(n - x) - getDeviancePart(x, n * p)
- getDeviancePart(n - x, n * q);
double f = (MathUtils.TWO_PI * x * (n - x)) / n;
ret = -0.5 * FastMath.log(f) + ret;
}
return ret;
} | java | public static double logBinomialProbability(int x, int n, double p, double q) {
double ret;
if (x == 0) {
if (p < 0.1) {
ret = -getDeviancePart(n, n * q) - n * p;
} else {
ret = n * FastMath.log(q);
}
} else if (x == n) {
if (q < 0.1) {
ret = -getDeviancePart(n, n * p) - n * q;
} else {
ret = n * FastMath.log(p);
}
} else {
ret = getStirlingError(n) - getStirlingError(x) - getStirlingError(n - x) - getDeviancePart(x, n * p)
- getDeviancePart(n - x, n * q);
double f = (MathUtils.TWO_PI * x * (n - x)) / n;
ret = -0.5 * FastMath.log(f) + ret;
}
return ret;
} | [
"public",
"static",
"double",
"logBinomialProbability",
"(",
"int",
"x",
",",
"int",
"n",
",",
"double",
"p",
",",
"double",
"q",
")",
"{",
"double",
"ret",
";",
"if",
"(",
"x",
"==",
"0",
")",
"{",
"if",
"(",
"p",
"<",
"0.1",
")",
"{",
"ret",
"=",
"-",
"getDeviancePart",
"(",
"n",
",",
"n",
"*",
"q",
")",
"-",
"n",
"*",
"p",
";",
"}",
"else",
"{",
"ret",
"=",
"n",
"*",
"FastMath",
".",
"log",
"(",
"q",
")",
";",
"}",
"}",
"else",
"if",
"(",
"x",
"==",
"n",
")",
"{",
"if",
"(",
"q",
"<",
"0.1",
")",
"{",
"ret",
"=",
"-",
"getDeviancePart",
"(",
"n",
",",
"n",
"*",
"p",
")",
"-",
"n",
"*",
"q",
";",
"}",
"else",
"{",
"ret",
"=",
"n",
"*",
"FastMath",
".",
"log",
"(",
"p",
")",
";",
"}",
"}",
"else",
"{",
"ret",
"=",
"getStirlingError",
"(",
"n",
")",
"-",
"getStirlingError",
"(",
"x",
")",
"-",
"getStirlingError",
"(",
"n",
"-",
"x",
")",
"-",
"getDeviancePart",
"(",
"x",
",",
"n",
"*",
"p",
")",
"-",
"getDeviancePart",
"(",
"n",
"-",
"x",
",",
"n",
"*",
"q",
")",
";",
"double",
"f",
"=",
"(",
"MathUtils",
".",
"TWO_PI",
"*",
"x",
"*",
"(",
"n",
"-",
"x",
")",
")",
"/",
"n",
";",
"ret",
"=",
"-",
"0.5",
"*",
"FastMath",
".",
"log",
"(",
"f",
")",
"+",
"ret",
";",
"}",
"return",
"ret",
";",
"}"
]
| Compute the logarithm of the PMF for a binomial distribution
using the saddle point expansion.
@param x the value at which the probability is evaluated.
@param n the number of trials.
@param p the probability of success.
@param q the probability of failure (1 - p).
@return log(p(x)). | [
"Compute",
"the",
"logarithm",
"of",
"the",
"PMF",
"for",
"a",
"binomial",
"distribution",
"using",
"the",
"saddle",
"point",
"expansion",
"."
]
| train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/rng/distribution/impl/SaddlePointExpansion.java#L178-L199 |
OpenLiberty/open-liberty | dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/config/util/GAEUtils.java | GAEUtils.wildcardMatch | static boolean wildcardMatch(String filename, String wildcardMatcher) {
"""
Checks a filename to see if it matches the specified wildcard matcher,
always testing case-sensitive. <p> The wildcard matcher uses the
characters '?' and '*' to represent a single or multiple (zero or more)
wildcard characters. This is the same as often found on Dos/Unix command
lines. The check is case-sensitive always.
<pre>
wildcardMatch("c.txt", "*.txt") --> true
wildcardMatch("c.txt", "*.jpg") --> false
wildcardMatch("a/b/c.txt", "a/b/*") --> true
wildcardMatch("c.txt", "*.???") --> true
wildcardMatch("c.txt", "*.????") --> false
</pre> N.B. the sequence "*?" does not work properly at present in match
strings.
@param filename the filename to match on
@param wildcardMatcher the wildcard string to match against
@return true if the filename matches the wilcard string
@see IOCase#SENSITIVE
"""
return wildcardMatch(filename, wildcardMatcher, IOCase.SENSITIVE);
} | java | static boolean wildcardMatch(String filename, String wildcardMatcher)
{
return wildcardMatch(filename, wildcardMatcher, IOCase.SENSITIVE);
} | [
"static",
"boolean",
"wildcardMatch",
"(",
"String",
"filename",
",",
"String",
"wildcardMatcher",
")",
"{",
"return",
"wildcardMatch",
"(",
"filename",
",",
"wildcardMatcher",
",",
"IOCase",
".",
"SENSITIVE",
")",
";",
"}"
]
| Checks a filename to see if it matches the specified wildcard matcher,
always testing case-sensitive. <p> The wildcard matcher uses the
characters '?' and '*' to represent a single or multiple (zero or more)
wildcard characters. This is the same as often found on Dos/Unix command
lines. The check is case-sensitive always.
<pre>
wildcardMatch("c.txt", "*.txt") --> true
wildcardMatch("c.txt", "*.jpg") --> false
wildcardMatch("a/b/c.txt", "a/b/*") --> true
wildcardMatch("c.txt", "*.???") --> true
wildcardMatch("c.txt", "*.????") --> false
</pre> N.B. the sequence "*?" does not work properly at present in match
strings.
@param filename the filename to match on
@param wildcardMatcher the wildcard string to match against
@return true if the filename matches the wilcard string
@see IOCase#SENSITIVE | [
"Checks",
"a",
"filename",
"to",
"see",
"if",
"it",
"matches",
"the",
"specified",
"wildcard",
"matcher",
"always",
"testing",
"case",
"-",
"sensitive",
".",
"<p",
">",
"The",
"wildcard",
"matcher",
"uses",
"the",
"characters",
"?",
"and",
"*",
"to",
"represent",
"a",
"single",
"or",
"multiple",
"(",
"zero",
"or",
"more",
")",
"wildcard",
"characters",
".",
"This",
"is",
"the",
"same",
"as",
"often",
"found",
"on",
"Dos",
"/",
"Unix",
"command",
"lines",
".",
"The",
"check",
"is",
"case",
"-",
"sensitive",
"always",
".",
"<pre",
">",
"wildcardMatch",
"(",
"c",
".",
"txt",
"*",
".",
"txt",
")",
"--",
">",
"true",
"wildcardMatch",
"(",
"c",
".",
"txt",
"*",
".",
"jpg",
")",
"--",
">",
"false",
"wildcardMatch",
"(",
"a",
"/",
"b",
"/",
"c",
".",
"txt",
"a",
"/",
"b",
"/",
"*",
")",
"--",
">",
"true",
"wildcardMatch",
"(",
"c",
".",
"txt",
"*",
".",
"???",
")",
"--",
">",
"true",
"wildcardMatch",
"(",
"c",
".",
"txt",
"*",
".",
"????",
")",
"--",
">",
"false",
"<",
"/",
"pre",
">",
"N",
".",
"B",
".",
"the",
"sequence",
"*",
"?",
"does",
"not",
"work",
"properly",
"at",
"present",
"in",
"match",
"strings",
"."
]
| train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/config/util/GAEUtils.java#L150-L153 |
Azure/azure-sdk-for-java | edgegateway/resource-manager/v2019_03_01/src/main/java/com/microsoft/azure/management/edgegateway/v2019_03_01/implementation/SharesInner.java | SharesInner.beginRefreshAsync | public Observable<Void> beginRefreshAsync(String deviceName, String name, String resourceGroupName) {
"""
Refreshes the share metadata with the data from the cloud.
@param deviceName The device name.
@param name The share name.
@param resourceGroupName The resource group name.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful.
"""
return beginRefreshWithServiceResponseAsync(deviceName, name, resourceGroupName).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | java | public Observable<Void> beginRefreshAsync(String deviceName, String name, String resourceGroupName) {
return beginRefreshWithServiceResponseAsync(deviceName, name, resourceGroupName).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Void",
">",
"beginRefreshAsync",
"(",
"String",
"deviceName",
",",
"String",
"name",
",",
"String",
"resourceGroupName",
")",
"{",
"return",
"beginRefreshWithServiceResponseAsync",
"(",
"deviceName",
",",
"name",
",",
"resourceGroupName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Void",
">",
",",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
"ServiceResponse",
"<",
"Void",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Refreshes the share metadata with the data from the cloud.
@param deviceName The device name.
@param name The share name.
@param resourceGroupName The resource group name.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful. | [
"Refreshes",
"the",
"share",
"metadata",
"with",
"the",
"data",
"from",
"the",
"cloud",
"."
]
| train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/edgegateway/resource-manager/v2019_03_01/src/main/java/com/microsoft/azure/management/edgegateway/v2019_03_01/implementation/SharesInner.java#L786-L793 |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/MessageBuilder.java | MessageBuilder.buildTruncate | public static Message buildTruncate(Zxid lastPrefixZxid, Zxid lastZxid) {
"""
Creates a TRUNCATE message.
@param lastPrefixZxid truncate receiver's log from lastPrefixZxid
exclusively.
@param lastZxid the last zxid for the synchronization.
@return a protobuf message.
"""
ZabMessage.Zxid lpz = toProtoZxid(lastPrefixZxid);
ZabMessage.Zxid lz = toProtoZxid(lastZxid);
Truncate trunc = Truncate.newBuilder().setLastPrefixZxid(lpz)
.setLastZxid(lz)
.build();
return Message.newBuilder().setType(MessageType.TRUNCATE)
.setTruncate(trunc)
.build();
} | java | public static Message buildTruncate(Zxid lastPrefixZxid, Zxid lastZxid) {
ZabMessage.Zxid lpz = toProtoZxid(lastPrefixZxid);
ZabMessage.Zxid lz = toProtoZxid(lastZxid);
Truncate trunc = Truncate.newBuilder().setLastPrefixZxid(lpz)
.setLastZxid(lz)
.build();
return Message.newBuilder().setType(MessageType.TRUNCATE)
.setTruncate(trunc)
.build();
} | [
"public",
"static",
"Message",
"buildTruncate",
"(",
"Zxid",
"lastPrefixZxid",
",",
"Zxid",
"lastZxid",
")",
"{",
"ZabMessage",
".",
"Zxid",
"lpz",
"=",
"toProtoZxid",
"(",
"lastPrefixZxid",
")",
";",
"ZabMessage",
".",
"Zxid",
"lz",
"=",
"toProtoZxid",
"(",
"lastZxid",
")",
";",
"Truncate",
"trunc",
"=",
"Truncate",
".",
"newBuilder",
"(",
")",
".",
"setLastPrefixZxid",
"(",
"lpz",
")",
".",
"setLastZxid",
"(",
"lz",
")",
".",
"build",
"(",
")",
";",
"return",
"Message",
".",
"newBuilder",
"(",
")",
".",
"setType",
"(",
"MessageType",
".",
"TRUNCATE",
")",
".",
"setTruncate",
"(",
"trunc",
")",
".",
"build",
"(",
")",
";",
"}"
]
| Creates a TRUNCATE message.
@param lastPrefixZxid truncate receiver's log from lastPrefixZxid
exclusively.
@param lastZxid the last zxid for the synchronization.
@return a protobuf message. | [
"Creates",
"a",
"TRUNCATE",
"message",
"."
]
| train | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/MessageBuilder.java#L268-L277 |
OpenLiberty/open-liberty | dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/Director.java | Director.enableConsoleLog | public void enableConsoleLog(Level level, boolean verbose) {
"""
Enables console logging amd console error logging
@param level Level of log
@param verbose if verbose should be set
"""
InstallLogUtils.enableConsoleLogging(level, verbose);
InstallLogUtils.enableConsoleErrorLogging(verbose);
} | java | public void enableConsoleLog(Level level, boolean verbose) {
InstallLogUtils.enableConsoleLogging(level, verbose);
InstallLogUtils.enableConsoleErrorLogging(verbose);
} | [
"public",
"void",
"enableConsoleLog",
"(",
"Level",
"level",
",",
"boolean",
"verbose",
")",
"{",
"InstallLogUtils",
".",
"enableConsoleLogging",
"(",
"level",
",",
"verbose",
")",
";",
"InstallLogUtils",
".",
"enableConsoleErrorLogging",
"(",
"verbose",
")",
";",
"}"
]
| Enables console logging amd console error logging
@param level Level of log
@param verbose if verbose should be set | [
"Enables",
"console",
"logging",
"amd",
"console",
"error",
"logging"
]
| train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.install/src/com/ibm/ws/install/internal/Director.java#L1041-L1044 |
ocelotds/ocelot | ocelot-web/src/main/java/org/ocelotds/cache/CacheArgumentServices.java | CacheArgumentServices.computeArgPart | public String computeArgPart(String[] keys, List<String> jsonArgs, List<String> paramNames) {
"""
Compute the part of cache key that depends of arguments
@param keys : key from annotation
@param jsonArgs : actual args
@param paramNames : parameter name of concern method
@return
"""
if (keys.length == 0) {
return "";
} else if (Constants.Cache.USE_ALL_ARGUMENTS.equals(keys[0])) {
return Arrays.toString(jsonArgs.toArray(new String[jsonArgs.size()]));
} else {
return computeSpecifiedArgPart(keys, jsonArgs, paramNames);
}
} | java | public String computeArgPart(String[] keys, List<String> jsonArgs, List<String> paramNames) {
if (keys.length == 0) {
return "";
} else if (Constants.Cache.USE_ALL_ARGUMENTS.equals(keys[0])) {
return Arrays.toString(jsonArgs.toArray(new String[jsonArgs.size()]));
} else {
return computeSpecifiedArgPart(keys, jsonArgs, paramNames);
}
} | [
"public",
"String",
"computeArgPart",
"(",
"String",
"[",
"]",
"keys",
",",
"List",
"<",
"String",
">",
"jsonArgs",
",",
"List",
"<",
"String",
">",
"paramNames",
")",
"{",
"if",
"(",
"keys",
".",
"length",
"==",
"0",
")",
"{",
"return",
"\"\"",
";",
"}",
"else",
"if",
"(",
"Constants",
".",
"Cache",
".",
"USE_ALL_ARGUMENTS",
".",
"equals",
"(",
"keys",
"[",
"0",
"]",
")",
")",
"{",
"return",
"Arrays",
".",
"toString",
"(",
"jsonArgs",
".",
"toArray",
"(",
"new",
"String",
"[",
"jsonArgs",
".",
"size",
"(",
")",
"]",
")",
")",
";",
"}",
"else",
"{",
"return",
"computeSpecifiedArgPart",
"(",
"keys",
",",
"jsonArgs",
",",
"paramNames",
")",
";",
"}",
"}"
]
| Compute the part of cache key that depends of arguments
@param keys : key from annotation
@param jsonArgs : actual args
@param paramNames : parameter name of concern method
@return | [
"Compute",
"the",
"part",
"of",
"cache",
"key",
"that",
"depends",
"of",
"arguments"
]
| train | https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-web/src/main/java/org/ocelotds/cache/CacheArgumentServices.java#L38-L46 |
Azure/azure-sdk-for-java | datalakeanalytics/resource-manager/v2015_10_01_preview/src/main/java/com/microsoft/azure/management/datalakeanalytics/v2015_10_01_preview/implementation/AccountsInner.java | AccountsInner.getByResourceGroupAsync | public Observable<DataLakeAnalyticsAccountInner> getByResourceGroupAsync(String resourceGroupName, String accountName) {
"""
Gets details of the specified Data Lake Analytics account.
@param resourceGroupName The name of the Azure resource group that contains the Data Lake Analytics account.
@param accountName The name of the Data Lake Analytics account to retrieve.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the DataLakeAnalyticsAccountInner object
"""
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, accountName).map(new Func1<ServiceResponse<DataLakeAnalyticsAccountInner>, DataLakeAnalyticsAccountInner>() {
@Override
public DataLakeAnalyticsAccountInner call(ServiceResponse<DataLakeAnalyticsAccountInner> response) {
return response.body();
}
});
} | java | public Observable<DataLakeAnalyticsAccountInner> getByResourceGroupAsync(String resourceGroupName, String accountName) {
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, accountName).map(new Func1<ServiceResponse<DataLakeAnalyticsAccountInner>, DataLakeAnalyticsAccountInner>() {
@Override
public DataLakeAnalyticsAccountInner call(ServiceResponse<DataLakeAnalyticsAccountInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"DataLakeAnalyticsAccountInner",
">",
"getByResourceGroupAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"accountName",
")",
"{",
"return",
"getByResourceGroupWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"accountName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"DataLakeAnalyticsAccountInner",
">",
",",
"DataLakeAnalyticsAccountInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"DataLakeAnalyticsAccountInner",
"call",
"(",
"ServiceResponse",
"<",
"DataLakeAnalyticsAccountInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Gets details of the specified Data Lake Analytics account.
@param resourceGroupName The name of the Azure resource group that contains the Data Lake Analytics account.
@param accountName The name of the Data Lake Analytics account to retrieve.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the DataLakeAnalyticsAccountInner object | [
"Gets",
"details",
"of",
"the",
"specified",
"Data",
"Lake",
"Analytics",
"account",
"."
]
| train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/datalakeanalytics/resource-manager/v2015_10_01_preview/src/main/java/com/microsoft/azure/management/datalakeanalytics/v2015_10_01_preview/implementation/AccountsInner.java#L2380-L2387 |
landawn/AbacusUtil | src/com/landawn/abacus/util/CouchbaseExecutor.java | CouchbaseExecutor.fromJSON | public static <T> T fromJSON(final Class<T> targetClass, final String json) {
"""
Returns an instance of the specified target class with the property values from the specified JSON String.
@param targetClass <code>JsonArray.class</code>, <code>JsonObject.class</code> or <code>JsonDocument.class</code>
@param json
@return
"""
if (targetClass.equals(JsonObject.class)) {
return (T) JsonObject.from(N.fromJSON(Map.class, json));
} else if (targetClass.equals(JsonArray.class)) {
return (T) JsonArray.from(N.fromJSON(List.class, json));
} else if (targetClass.equals(JsonDocument.class)) {
final JsonObject jsonObject = JsonObject.from(N.fromJSON(Map.class, json));
final String id = N.stringOf(jsonObject.get(_ID));
jsonObject.removeKey(_ID);
return (T) JsonDocument.create(id, jsonObject);
} else {
throw new IllegalArgumentException("Unsupported type: " + ClassUtil.getCanonicalClassName(targetClass));
}
} | java | public static <T> T fromJSON(final Class<T> targetClass, final String json) {
if (targetClass.equals(JsonObject.class)) {
return (T) JsonObject.from(N.fromJSON(Map.class, json));
} else if (targetClass.equals(JsonArray.class)) {
return (T) JsonArray.from(N.fromJSON(List.class, json));
} else if (targetClass.equals(JsonDocument.class)) {
final JsonObject jsonObject = JsonObject.from(N.fromJSON(Map.class, json));
final String id = N.stringOf(jsonObject.get(_ID));
jsonObject.removeKey(_ID);
return (T) JsonDocument.create(id, jsonObject);
} else {
throw new IllegalArgumentException("Unsupported type: " + ClassUtil.getCanonicalClassName(targetClass));
}
} | [
"public",
"static",
"<",
"T",
">",
"T",
"fromJSON",
"(",
"final",
"Class",
"<",
"T",
">",
"targetClass",
",",
"final",
"String",
"json",
")",
"{",
"if",
"(",
"targetClass",
".",
"equals",
"(",
"JsonObject",
".",
"class",
")",
")",
"{",
"return",
"(",
"T",
")",
"JsonObject",
".",
"from",
"(",
"N",
".",
"fromJSON",
"(",
"Map",
".",
"class",
",",
"json",
")",
")",
";",
"}",
"else",
"if",
"(",
"targetClass",
".",
"equals",
"(",
"JsonArray",
".",
"class",
")",
")",
"{",
"return",
"(",
"T",
")",
"JsonArray",
".",
"from",
"(",
"N",
".",
"fromJSON",
"(",
"List",
".",
"class",
",",
"json",
")",
")",
";",
"}",
"else",
"if",
"(",
"targetClass",
".",
"equals",
"(",
"JsonDocument",
".",
"class",
")",
")",
"{",
"final",
"JsonObject",
"jsonObject",
"=",
"JsonObject",
".",
"from",
"(",
"N",
".",
"fromJSON",
"(",
"Map",
".",
"class",
",",
"json",
")",
")",
";",
"final",
"String",
"id",
"=",
"N",
".",
"stringOf",
"(",
"jsonObject",
".",
"get",
"(",
"_ID",
")",
")",
";",
"jsonObject",
".",
"removeKey",
"(",
"_ID",
")",
";",
"return",
"(",
"T",
")",
"JsonDocument",
".",
"create",
"(",
"id",
",",
"jsonObject",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unsupported type: \"",
"+",
"ClassUtil",
".",
"getCanonicalClassName",
"(",
"targetClass",
")",
")",
";",
"}",
"}"
]
| Returns an instance of the specified target class with the property values from the specified JSON String.
@param targetClass <code>JsonArray.class</code>, <code>JsonObject.class</code> or <code>JsonDocument.class</code>
@param json
@return | [
"Returns",
"an",
"instance",
"of",
"the",
"specified",
"target",
"class",
"with",
"the",
"property",
"values",
"from",
"the",
"specified",
"JSON",
"String",
"."
]
| train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/util/CouchbaseExecutor.java#L446-L461 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/http/HttpHeaderMap.java | HttpHeaderMap.addDateHeader | public void addDateHeader (@Nonnull @Nonempty final String sName, final long nMillis) {
"""
Add the passed header as a date header.
@param sName
Header name. May neither be <code>null</code> nor empty.
@param nMillis
The milliseconds to set as a date.
"""
addDateHeader (sName, PDTFactory.createZonedDateTime (nMillis));
} | java | public void addDateHeader (@Nonnull @Nonempty final String sName, final long nMillis)
{
addDateHeader (sName, PDTFactory.createZonedDateTime (nMillis));
} | [
"public",
"void",
"addDateHeader",
"(",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sName",
",",
"final",
"long",
"nMillis",
")",
"{",
"addDateHeader",
"(",
"sName",
",",
"PDTFactory",
".",
"createZonedDateTime",
"(",
"nMillis",
")",
")",
";",
"}"
]
| Add the passed header as a date header.
@param sName
Header name. May neither be <code>null</code> nor empty.
@param nMillis
The milliseconds to set as a date. | [
"Add",
"the",
"passed",
"header",
"as",
"a",
"date",
"header",
"."
]
| train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/http/HttpHeaderMap.java#L290-L293 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/DateIntervalInfo.java | DateIntervalInfo.getIntervalPattern | public PatternInfo getIntervalPattern(String skeleton, int field) {
"""
Get the interval pattern given the largest different calendar field.
@param skeleton the skeleton
@param field the largest different calendar field
@return interval pattern return null if interval pattern is not found.
@throws IllegalArgumentException if getting interval pattern on
a calendar field that is smaller
than the MINIMUM_SUPPORTED_CALENDAR_FIELD
"""
if ( field > MINIMUM_SUPPORTED_CALENDAR_FIELD ) {
throw new IllegalArgumentException("no support for field less than SECOND");
}
Map<String, PatternInfo> patternsOfOneSkeleton = fIntervalPatterns.get(skeleton);
if ( patternsOfOneSkeleton != null ) {
PatternInfo intervalPattern = patternsOfOneSkeleton.
get(CALENDAR_FIELD_TO_PATTERN_LETTER[field]);
if ( intervalPattern != null ) {
return intervalPattern;
}
}
return null;
} | java | public PatternInfo getIntervalPattern(String skeleton, int field)
{
if ( field > MINIMUM_SUPPORTED_CALENDAR_FIELD ) {
throw new IllegalArgumentException("no support for field less than SECOND");
}
Map<String, PatternInfo> patternsOfOneSkeleton = fIntervalPatterns.get(skeleton);
if ( patternsOfOneSkeleton != null ) {
PatternInfo intervalPattern = patternsOfOneSkeleton.
get(CALENDAR_FIELD_TO_PATTERN_LETTER[field]);
if ( intervalPattern != null ) {
return intervalPattern;
}
}
return null;
} | [
"public",
"PatternInfo",
"getIntervalPattern",
"(",
"String",
"skeleton",
",",
"int",
"field",
")",
"{",
"if",
"(",
"field",
">",
"MINIMUM_SUPPORTED_CALENDAR_FIELD",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"no support for field less than SECOND\"",
")",
";",
"}",
"Map",
"<",
"String",
",",
"PatternInfo",
">",
"patternsOfOneSkeleton",
"=",
"fIntervalPatterns",
".",
"get",
"(",
"skeleton",
")",
";",
"if",
"(",
"patternsOfOneSkeleton",
"!=",
"null",
")",
"{",
"PatternInfo",
"intervalPattern",
"=",
"patternsOfOneSkeleton",
".",
"get",
"(",
"CALENDAR_FIELD_TO_PATTERN_LETTER",
"[",
"field",
"]",
")",
";",
"if",
"(",
"intervalPattern",
"!=",
"null",
")",
"{",
"return",
"intervalPattern",
";",
"}",
"}",
"return",
"null",
";",
"}"
]
| Get the interval pattern given the largest different calendar field.
@param skeleton the skeleton
@param field the largest different calendar field
@return interval pattern return null if interval pattern is not found.
@throws IllegalArgumentException if getting interval pattern on
a calendar field that is smaller
than the MINIMUM_SUPPORTED_CALENDAR_FIELD | [
"Get",
"the",
"interval",
"pattern",
"given",
"the",
"largest",
"different",
"calendar",
"field",
"."
]
| train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/DateIntervalInfo.java#L842-L856 |
OpenLiberty/open-liberty | dev/com.ibm.ws.security.common/src/com/ibm/ws/security/common/web/JavaScriptUtils.java | JavaScriptUtils.getJavaScriptForRedirect | public String getJavaScriptForRedirect(String reqUrlCookieName, String redirectUrl) throws Exception {
"""
Creates a JavaScript HTML block that:
<ol>
<li>Creates a cookie with the specified name whose value is the browser's current location
<li>Redirects the browser to the specified URL
</ol>
"""
return getJavaScriptForRedirect(reqUrlCookieName, redirectUrl, null);
} | java | public String getJavaScriptForRedirect(String reqUrlCookieName, String redirectUrl) throws Exception {
return getJavaScriptForRedirect(reqUrlCookieName, redirectUrl, null);
} | [
"public",
"String",
"getJavaScriptForRedirect",
"(",
"String",
"reqUrlCookieName",
",",
"String",
"redirectUrl",
")",
"throws",
"Exception",
"{",
"return",
"getJavaScriptForRedirect",
"(",
"reqUrlCookieName",
",",
"redirectUrl",
",",
"null",
")",
";",
"}"
]
| Creates a JavaScript HTML block that:
<ol>
<li>Creates a cookie with the specified name whose value is the browser's current location
<li>Redirects the browser to the specified URL
</ol> | [
"Creates",
"a",
"JavaScript",
"HTML",
"block",
"that",
":",
"<ol",
">",
"<li",
">",
"Creates",
"a",
"cookie",
"with",
"the",
"specified",
"name",
"whose",
"value",
"is",
"the",
"browser",
"s",
"current",
"location",
"<li",
">",
"Redirects",
"the",
"browser",
"to",
"the",
"specified",
"URL",
"<",
"/",
"ol",
">"
]
| train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.common/src/com/ibm/ws/security/common/web/JavaScriptUtils.java#L110-L112 |
openbase/jul | processing/xml/src/main/java/org/openbase/jul/processing/xml/processing/XMLProcessor.java | XMLProcessor.normalizeFormatting | public static Node normalizeFormatting(final Node doc) throws CouldNotProcessException {
"""
Creates a pretty formatted version of doc. Note: does not remove line breaks!
@param doc
@return
"""
try {
return createDocumentFromString(normalizeFormattingAsString(doc));
} catch (XMLParsingException ex) {
throw new CouldNotProcessException("Couldn't normalize formatting. Returning old document.", ex);
}
} | java | public static Node normalizeFormatting(final Node doc) throws CouldNotProcessException {
try {
return createDocumentFromString(normalizeFormattingAsString(doc));
} catch (XMLParsingException ex) {
throw new CouldNotProcessException("Couldn't normalize formatting. Returning old document.", ex);
}
} | [
"public",
"static",
"Node",
"normalizeFormatting",
"(",
"final",
"Node",
"doc",
")",
"throws",
"CouldNotProcessException",
"{",
"try",
"{",
"return",
"createDocumentFromString",
"(",
"normalizeFormattingAsString",
"(",
"doc",
")",
")",
";",
"}",
"catch",
"(",
"XMLParsingException",
"ex",
")",
"{",
"throw",
"new",
"CouldNotProcessException",
"(",
"\"Couldn't normalize formatting. Returning old document.\"",
",",
"ex",
")",
";",
"}",
"}"
]
| Creates a pretty formatted version of doc. Note: does not remove line breaks!
@param doc
@return | [
"Creates",
"a",
"pretty",
"formatted",
"version",
"of",
"doc",
".",
"Note",
":",
"does",
"not",
"remove",
"line",
"breaks!"
]
| train | https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/processing/xml/src/main/java/org/openbase/jul/processing/xml/processing/XMLProcessor.java#L385-L391 |
ops4j/org.ops4j.pax.logging | pax-logging-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java | PropertiesUtil.loadClose | static Properties loadClose(final InputStream in, final Object source) {
"""
Loads and closes the given property input stream. If an error occurs, log to the status logger.
@param in a property input stream.
@param source a source object describing the source, like a resource string or a URL.
@return a new Properties object
"""
final Properties props = new Properties();
if (null != in) {
try {
props.load(in);
} catch (final IOException e) {
LowLevelLogUtil.logException("Unable to read " + source, e);
} finally {
try {
in.close();
} catch (final IOException e) {
LowLevelLogUtil.logException("Unable to close " + source, e);
}
}
}
return props;
} | java | static Properties loadClose(final InputStream in, final Object source) {
final Properties props = new Properties();
if (null != in) {
try {
props.load(in);
} catch (final IOException e) {
LowLevelLogUtil.logException("Unable to read " + source, e);
} finally {
try {
in.close();
} catch (final IOException e) {
LowLevelLogUtil.logException("Unable to close " + source, e);
}
}
}
return props;
} | [
"static",
"Properties",
"loadClose",
"(",
"final",
"InputStream",
"in",
",",
"final",
"Object",
"source",
")",
"{",
"final",
"Properties",
"props",
"=",
"new",
"Properties",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"in",
")",
"{",
"try",
"{",
"props",
".",
"load",
"(",
"in",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"e",
")",
"{",
"LowLevelLogUtil",
".",
"logException",
"(",
"\"Unable to read \"",
"+",
"source",
",",
"e",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"in",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"e",
")",
"{",
"LowLevelLogUtil",
".",
"logException",
"(",
"\"Unable to close \"",
"+",
"source",
",",
"e",
")",
";",
"}",
"}",
"}",
"return",
"props",
";",
"}"
]
| Loads and closes the given property input stream. If an error occurs, log to the status logger.
@param in a property input stream.
@param source a source object describing the source, like a resource string or a URL.
@return a new Properties object | [
"Loads",
"and",
"closes",
"the",
"given",
"property",
"input",
"stream",
".",
"If",
"an",
"error",
"occurs",
"log",
"to",
"the",
"status",
"logger",
"."
]
| train | https://github.com/ops4j/org.ops4j.pax.logging/blob/493de4e1db4fe9f981f3dd78b8e40e5bf2b2e59d/pax-logging-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java#L77-L93 |
micronaut-projects/micronaut-core | inject/src/main/java/io/micronaut/inject/annotation/AbstractAnnotationMetadataBuilder.java | AbstractAnnotationMetadataBuilder.buildForParent | public AnnotationMetadata buildForParent(T parent, T element) {
"""
Build the meta data for the given method element excluding any class metadata.
@param parent The parent element
@param element The element
@return The {@link AnnotationMetadata}
"""
final AnnotationMetadata existing = MUTATED_ANNOTATION_METADATA.get(element);
DefaultAnnotationMetadata annotationMetadata;
if (existing instanceof DefaultAnnotationMetadata) {
// ugly, but will have to do
annotationMetadata = (DefaultAnnotationMetadata) ((DefaultAnnotationMetadata) existing).clone();
} else {
annotationMetadata = new DefaultAnnotationMetadata();
}
return buildInternal(parent, element, annotationMetadata, false, false);
} | java | public AnnotationMetadata buildForParent(T parent, T element) {
final AnnotationMetadata existing = MUTATED_ANNOTATION_METADATA.get(element);
DefaultAnnotationMetadata annotationMetadata;
if (existing instanceof DefaultAnnotationMetadata) {
// ugly, but will have to do
annotationMetadata = (DefaultAnnotationMetadata) ((DefaultAnnotationMetadata) existing).clone();
} else {
annotationMetadata = new DefaultAnnotationMetadata();
}
return buildInternal(parent, element, annotationMetadata, false, false);
} | [
"public",
"AnnotationMetadata",
"buildForParent",
"(",
"T",
"parent",
",",
"T",
"element",
")",
"{",
"final",
"AnnotationMetadata",
"existing",
"=",
"MUTATED_ANNOTATION_METADATA",
".",
"get",
"(",
"element",
")",
";",
"DefaultAnnotationMetadata",
"annotationMetadata",
";",
"if",
"(",
"existing",
"instanceof",
"DefaultAnnotationMetadata",
")",
"{",
"// ugly, but will have to do",
"annotationMetadata",
"=",
"(",
"DefaultAnnotationMetadata",
")",
"(",
"(",
"DefaultAnnotationMetadata",
")",
"existing",
")",
".",
"clone",
"(",
")",
";",
"}",
"else",
"{",
"annotationMetadata",
"=",
"new",
"DefaultAnnotationMetadata",
"(",
")",
";",
"}",
"return",
"buildInternal",
"(",
"parent",
",",
"element",
",",
"annotationMetadata",
",",
"false",
",",
"false",
")",
";",
"}"
]
| Build the meta data for the given method element excluding any class metadata.
@param parent The parent element
@param element The element
@return The {@link AnnotationMetadata} | [
"Build",
"the",
"meta",
"data",
"for",
"the",
"given",
"method",
"element",
"excluding",
"any",
"class",
"metadata",
"."
]
| train | https://github.com/micronaut-projects/micronaut-core/blob/c31f5b03ce0eb88c2f6470710987db03b8967d5c/inject/src/main/java/io/micronaut/inject/annotation/AbstractAnnotationMetadataBuilder.java#L165-L175 |
matthewhorridge/owlapi-gwt | owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLObjectInverseOfImpl_CustomFieldSerializer.java | OWLObjectInverseOfImpl_CustomFieldSerializer.serializeInstance | @Override
public void serializeInstance(SerializationStreamWriter streamWriter, OWLObjectInverseOfImpl instance) throws SerializationException {
"""
Serializes the content of the object into the
{@link com.google.gwt.user.client.rpc.SerializationStreamWriter}.
@param streamWriter the {@link com.google.gwt.user.client.rpc.SerializationStreamWriter} to write the
object's content to
@param instance the object instance to serialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the serialization operation is not
successful
"""
serialize(streamWriter, instance);
} | java | @Override
public void serializeInstance(SerializationStreamWriter streamWriter, OWLObjectInverseOfImpl instance) throws SerializationException {
serialize(streamWriter, instance);
} | [
"@",
"Override",
"public",
"void",
"serializeInstance",
"(",
"SerializationStreamWriter",
"streamWriter",
",",
"OWLObjectInverseOfImpl",
"instance",
")",
"throws",
"SerializationException",
"{",
"serialize",
"(",
"streamWriter",
",",
"instance",
")",
";",
"}"
]
| Serializes the content of the object into the
{@link com.google.gwt.user.client.rpc.SerializationStreamWriter}.
@param streamWriter the {@link com.google.gwt.user.client.rpc.SerializationStreamWriter} to write the
object's content to
@param instance the object instance to serialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the serialization operation is not
successful | [
"Serializes",
"the",
"content",
"of",
"the",
"object",
"into",
"the",
"{",
"@link",
"com",
".",
"google",
".",
"gwt",
".",
"user",
".",
"client",
".",
"rpc",
".",
"SerializationStreamWriter",
"}",
"."
]
| train | https://github.com/matthewhorridge/owlapi-gwt/blob/7ab975fb6cef3c8947099983551672a3b5d4e2fd/owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLObjectInverseOfImpl_CustomFieldSerializer.java#L70-L73 |
elki-project/elki | addons/xtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/xtree/util/XSplitter.java | XSplitter.generateDistributionsAndSurfaceSums | private double generateDistributionsAndSurfaceSums(int minEntries, int maxEntries, int[] entriesByLB, int[] entriesByUB) {
"""
Generates both sets of <code>(maxEntries - minEntries + 1)</code>
distributions of the first <code>minEntries</code> entries together with
the next <code>0</code> to <code>maxEntries - minEntries</code> entries for
each of the orderings in <code>entriesByLB</code> and
<code>entriesByUB</code>. <br>
For all distributions, the sums of the two resulting MBRs' surfaces are
calculated and the overall sum is returned.
@param minEntries minimally allowed subgroup size
@param maxEntries maximally allowed subgroup size; if
<code>< node.getNumEntries()</code>, ONLY the first half (
<code>[minEntries,maxEntries]</code>) of the possible partitions is
calculated
@param entriesByLB entries sorted by lower bound value of some dimension
@param entriesByUB entries sorted by upper bound value of some dimension
@return the sum of all resulting MBRs' surface sums of the partitions
ranging in <code>{minEntries, ..., maxEntries</code> in both of the
input orderings
"""
// the old variant is minimally slower
// double surfaceSum = 0;
// for(int limit = minEntries; limit <= maxEntries; limit++) {
// HyperBoundingBox mbr1 = mbr(entriesByLB, 0, limit);
// HyperBoundingBox mbr2 = mbr(entriesByLB, limit, entriesByLB.length);
// surfaceSum += mbr1.perimeter() + mbr2.perimeter();
// mbr1 = mbr(entriesByUB, 0, limit);
// mbr2 = mbr(entriesByUB, limit, entriesByUB.length);
// surfaceSum += mbr1.perimeter() + mbr2.perimeter();
// }
// return surfaceSum;
int dim = tree.getDimensionality();
// get surface sum for lower-bound sorting
double surfaceSum = getSurfaceSums4Sorting(minEntries, maxEntries, entriesByLB, dim);
// get surface sum for upper-bound sorting
surfaceSum += getSurfaceSums4Sorting(minEntries, maxEntries, entriesByUB, dim);
return surfaceSum;
} | java | private double generateDistributionsAndSurfaceSums(int minEntries, int maxEntries, int[] entriesByLB, int[] entriesByUB) {
// the old variant is minimally slower
// double surfaceSum = 0;
// for(int limit = minEntries; limit <= maxEntries; limit++) {
// HyperBoundingBox mbr1 = mbr(entriesByLB, 0, limit);
// HyperBoundingBox mbr2 = mbr(entriesByLB, limit, entriesByLB.length);
// surfaceSum += mbr1.perimeter() + mbr2.perimeter();
// mbr1 = mbr(entriesByUB, 0, limit);
// mbr2 = mbr(entriesByUB, limit, entriesByUB.length);
// surfaceSum += mbr1.perimeter() + mbr2.perimeter();
// }
// return surfaceSum;
int dim = tree.getDimensionality();
// get surface sum for lower-bound sorting
double surfaceSum = getSurfaceSums4Sorting(minEntries, maxEntries, entriesByLB, dim);
// get surface sum for upper-bound sorting
surfaceSum += getSurfaceSums4Sorting(minEntries, maxEntries, entriesByUB, dim);
return surfaceSum;
} | [
"private",
"double",
"generateDistributionsAndSurfaceSums",
"(",
"int",
"minEntries",
",",
"int",
"maxEntries",
",",
"int",
"[",
"]",
"entriesByLB",
",",
"int",
"[",
"]",
"entriesByUB",
")",
"{",
"// the old variant is minimally slower",
"// double surfaceSum = 0;",
"// for(int limit = minEntries; limit <= maxEntries; limit++) {",
"// HyperBoundingBox mbr1 = mbr(entriesByLB, 0, limit);",
"// HyperBoundingBox mbr2 = mbr(entriesByLB, limit, entriesByLB.length);",
"// surfaceSum += mbr1.perimeter() + mbr2.perimeter();",
"// mbr1 = mbr(entriesByUB, 0, limit);",
"// mbr2 = mbr(entriesByUB, limit, entriesByUB.length);",
"// surfaceSum += mbr1.perimeter() + mbr2.perimeter();",
"// }",
"// return surfaceSum;",
"int",
"dim",
"=",
"tree",
".",
"getDimensionality",
"(",
")",
";",
"// get surface sum for lower-bound sorting",
"double",
"surfaceSum",
"=",
"getSurfaceSums4Sorting",
"(",
"minEntries",
",",
"maxEntries",
",",
"entriesByLB",
",",
"dim",
")",
";",
"// get surface sum for upper-bound sorting",
"surfaceSum",
"+=",
"getSurfaceSums4Sorting",
"(",
"minEntries",
",",
"maxEntries",
",",
"entriesByUB",
",",
"dim",
")",
";",
"return",
"surfaceSum",
";",
"}"
]
| Generates both sets of <code>(maxEntries - minEntries + 1)</code>
distributions of the first <code>minEntries</code> entries together with
the next <code>0</code> to <code>maxEntries - minEntries</code> entries for
each of the orderings in <code>entriesByLB</code> and
<code>entriesByUB</code>. <br>
For all distributions, the sums of the two resulting MBRs' surfaces are
calculated and the overall sum is returned.
@param minEntries minimally allowed subgroup size
@param maxEntries maximally allowed subgroup size; if
<code>< node.getNumEntries()</code>, ONLY the first half (
<code>[minEntries,maxEntries]</code>) of the possible partitions is
calculated
@param entriesByLB entries sorted by lower bound value of some dimension
@param entriesByUB entries sorted by upper bound value of some dimension
@return the sum of all resulting MBRs' surface sums of the partitions
ranging in <code>{minEntries, ..., maxEntries</code> in both of the
input orderings | [
"Generates",
"both",
"sets",
"of",
"<code",
">",
"(",
"maxEntries",
"-",
"minEntries",
"+",
"1",
")",
"<",
"/",
"code",
">",
"distributions",
"of",
"the",
"first",
"<code",
">",
"minEntries<",
"/",
"code",
">",
"entries",
"together",
"with",
"the",
"next",
"<code",
">",
"0<",
"/",
"code",
">",
"to",
"<code",
">",
"maxEntries",
"-",
"minEntries<",
"/",
"code",
">",
"entries",
"for",
"each",
"of",
"the",
"orderings",
"in",
"<code",
">",
"entriesByLB<",
"/",
"code",
">",
"and",
"<code",
">",
"entriesByUB<",
"/",
"code",
">",
".",
"<br",
">",
"For",
"all",
"distributions",
"the",
"sums",
"of",
"the",
"two",
"resulting",
"MBRs",
"surfaces",
"are",
"calculated",
"and",
"the",
"overall",
"sum",
"is",
"returned",
"."
]
| train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/xtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/xtree/util/XSplitter.java#L110-L128 |
JodaOrg/joda-time | src/main/java/org/joda/time/format/DateTimeParserBucket.java | DateTimeParserBucket.saveField | public void saveField(DateTimeFieldType fieldType, String text, Locale locale) {
"""
Saves a datetime field text value.
@param fieldType the field type
@param text the text value
@param locale the locale to use
"""
obtainSaveField().init(fieldType.getField(iChrono), text, locale);
} | java | public void saveField(DateTimeFieldType fieldType, String text, Locale locale) {
obtainSaveField().init(fieldType.getField(iChrono), text, locale);
} | [
"public",
"void",
"saveField",
"(",
"DateTimeFieldType",
"fieldType",
",",
"String",
"text",
",",
"Locale",
"locale",
")",
"{",
"obtainSaveField",
"(",
")",
".",
"init",
"(",
"fieldType",
".",
"getField",
"(",
"iChrono",
")",
",",
"text",
",",
"locale",
")",
";",
"}"
]
| Saves a datetime field text value.
@param fieldType the field type
@param text the text value
@param locale the locale to use | [
"Saves",
"a",
"datetime",
"field",
"text",
"value",
"."
]
| train | https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/format/DateTimeParserBucket.java#L319-L321 |
alkacon/opencms-core | src/org/opencms/ui/favorites/CmsFavoriteDialog.java | CmsFavoriteDialog.getProject | private String getProject(CmsObject cms, CmsFavoriteEntry entry) throws CmsException {
"""
Gets the project name for a favorite entry.
@param cms the CMS context
@param entry the favorite entry
@return the project name for the favorite entry
@throws CmsException if something goes wrong
"""
String result = m_projectLabels.get(entry.getProjectId());
if (result == null) {
result = cms.readProject(entry.getProjectId()).getName();
m_projectLabels.put(entry.getProjectId(), result);
}
return result;
} | java | private String getProject(CmsObject cms, CmsFavoriteEntry entry) throws CmsException {
String result = m_projectLabels.get(entry.getProjectId());
if (result == null) {
result = cms.readProject(entry.getProjectId()).getName();
m_projectLabels.put(entry.getProjectId(), result);
}
return result;
} | [
"private",
"String",
"getProject",
"(",
"CmsObject",
"cms",
",",
"CmsFavoriteEntry",
"entry",
")",
"throws",
"CmsException",
"{",
"String",
"result",
"=",
"m_projectLabels",
".",
"get",
"(",
"entry",
".",
"getProjectId",
"(",
")",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"result",
"=",
"cms",
".",
"readProject",
"(",
"entry",
".",
"getProjectId",
"(",
")",
")",
".",
"getName",
"(",
")",
";",
"m_projectLabels",
".",
"put",
"(",
"entry",
".",
"getProjectId",
"(",
")",
",",
"result",
")",
";",
"}",
"return",
"result",
";",
"}"
]
| Gets the project name for a favorite entry.
@param cms the CMS context
@param entry the favorite entry
@return the project name for the favorite entry
@throws CmsException if something goes wrong | [
"Gets",
"the",
"project",
"name",
"for",
"a",
"favorite",
"entry",
"."
]
| train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/favorites/CmsFavoriteDialog.java#L376-L384 |
alkacon/opencms-core | src-gwt/org/opencms/ade/contenteditor/client/CmsContentEditor.java | CmsContentEditor.addChangeListener | private void addChangeListener(JavaScriptObject changeListener, String changeScope) {
"""
Adds the change listener to the observer.<p>
@param changeListener the change listener
@param changeScope the change scope
"""
try {
System.out.println("Adding native listener for scope " + changeScope);
m_entityObserver.addEntityChangeListener(new CmsEntityChangeListenerWrapper(changeListener), changeScope);
} catch (Exception e) {
CmsDebugLog.getInstance().printLine("Exception occured during listener registration" + e.getMessage());
}
} | java | private void addChangeListener(JavaScriptObject changeListener, String changeScope) {
try {
System.out.println("Adding native listener for scope " + changeScope);
m_entityObserver.addEntityChangeListener(new CmsEntityChangeListenerWrapper(changeListener), changeScope);
} catch (Exception e) {
CmsDebugLog.getInstance().printLine("Exception occured during listener registration" + e.getMessage());
}
} | [
"private",
"void",
"addChangeListener",
"(",
"JavaScriptObject",
"changeListener",
",",
"String",
"changeScope",
")",
"{",
"try",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Adding native listener for scope \"",
"+",
"changeScope",
")",
";",
"m_entityObserver",
".",
"addEntityChangeListener",
"(",
"new",
"CmsEntityChangeListenerWrapper",
"(",
"changeListener",
")",
",",
"changeScope",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"CmsDebugLog",
".",
"getInstance",
"(",
")",
".",
"printLine",
"(",
"\"Exception occured during listener registration\"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
]
| Adds the change listener to the observer.<p>
@param changeListener the change listener
@param changeScope the change scope | [
"Adds",
"the",
"change",
"listener",
"to",
"the",
"observer",
".",
"<p",
">"
]
| train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ade/contenteditor/client/CmsContentEditor.java#L2109-L2118 |
goldmansachs/gs-collections | collections/src/main/java/com/gs/collections/impl/parallel/ParallelIterate.java | ParallelIterate.forEach | public static <T> void forEach(Iterable<T> iterable, Procedure<? super T> procedure, int batchSize) {
"""
Iterate over the collection specified in parallel batches using default runtime parameter values. The
{@code Procedure} used must be stateless, or use concurrent aware objects if they are to be shared.
<p>
e.g.
<pre>
{@code final Map<Object, Boolean> chm = new ConcurrentHashMap<Object, Boolean>();}
ParallelIterate.<b>forEachBatchSize</b>(collection, new Procedure()
{
public void value(Object object)
{
chm.put(object, Boolean.TRUE);
}
}, 100);
</pre>
"""
ParallelIterate.forEach(iterable, procedure, batchSize, ParallelIterate.EXECUTOR_SERVICE);
} | java | public static <T> void forEach(Iterable<T> iterable, Procedure<? super T> procedure, int batchSize)
{
ParallelIterate.forEach(iterable, procedure, batchSize, ParallelIterate.EXECUTOR_SERVICE);
} | [
"public",
"static",
"<",
"T",
">",
"void",
"forEach",
"(",
"Iterable",
"<",
"T",
">",
"iterable",
",",
"Procedure",
"<",
"?",
"super",
"T",
">",
"procedure",
",",
"int",
"batchSize",
")",
"{",
"ParallelIterate",
".",
"forEach",
"(",
"iterable",
",",
"procedure",
",",
"batchSize",
",",
"ParallelIterate",
".",
"EXECUTOR_SERVICE",
")",
";",
"}"
]
| Iterate over the collection specified in parallel batches using default runtime parameter values. The
{@code Procedure} used must be stateless, or use concurrent aware objects if they are to be shared.
<p>
e.g.
<pre>
{@code final Map<Object, Boolean> chm = new ConcurrentHashMap<Object, Boolean>();}
ParallelIterate.<b>forEachBatchSize</b>(collection, new Procedure()
{
public void value(Object object)
{
chm.put(object, Boolean.TRUE);
}
}, 100);
</pre> | [
"Iterate",
"over",
"the",
"collection",
"specified",
"in",
"parallel",
"batches",
"using",
"default",
"runtime",
"parameter",
"values",
".",
"The",
"{"
]
| train | https://github.com/goldmansachs/gs-collections/blob/fa8bf3e103689efa18bca2ab70203e71cde34b52/collections/src/main/java/com/gs/collections/impl/parallel/ParallelIterate.java#L303-L306 |
adamfisk/littleshoot-util | src/main/java/org/littleshoot/util/NumberUtils.java | NumberUtils.isBigger | public static boolean isBigger(final BigInteger big1, final BigInteger big2) {
"""
Returns whether the first {@link BigInteger} is bigger than the second.
@param big1 The first {@link BigInteger} to compare.
@param big2 The second {@link BigInteger} to compare.
@return <code>true</code> if the first {@link BigInteger} is bigger
than the second, otherwise <code>false</code>.
"""
final int compared = big1.compareTo(big2);
if (compared > 0)
{
return true;
}
return false;
} | java | public static boolean isBigger(final BigInteger big1, final BigInteger big2)
{
final int compared = big1.compareTo(big2);
if (compared > 0)
{
return true;
}
return false;
} | [
"public",
"static",
"boolean",
"isBigger",
"(",
"final",
"BigInteger",
"big1",
",",
"final",
"BigInteger",
"big2",
")",
"{",
"final",
"int",
"compared",
"=",
"big1",
".",
"compareTo",
"(",
"big2",
")",
";",
"if",
"(",
"compared",
">",
"0",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
]
| Returns whether the first {@link BigInteger} is bigger than the second.
@param big1 The first {@link BigInteger} to compare.
@param big2 The second {@link BigInteger} to compare.
@return <code>true</code> if the first {@link BigInteger} is bigger
than the second, otherwise <code>false</code>. | [
"Returns",
"whether",
"the",
"first",
"{",
"@link",
"BigInteger",
"}",
"is",
"bigger",
"than",
"the",
"second",
"."
]
| train | https://github.com/adamfisk/littleshoot-util/blob/3c0dc4955116b3382d6b0575d2f164b7508a4f73/src/main/java/org/littleshoot/util/NumberUtils.java#L24-L32 |
alkacon/opencms-core | src/org/opencms/staticexport/CmsLinkManager.java | CmsLinkManager.getRootPath | public String getRootPath(CmsObject cms, String targetUri) {
"""
Returns the resource root path in the OpenCms VFS for the given target URI link, or <code>null</code> in
case the link points to an external site.<p>
This methods does not support relative target URI links, so the given URI must be an absolute link.<p>
See {@link #getRootPath(CmsObject, String)} for a full explanation of this method.<p>
@param cms the current users OpenCms context
@param targetUri the target URI link
@return the resource root path in the OpenCms VFS for the given target URI link, or <code>null</code> in
case the link points to an external site
@see #getRootPath(CmsObject, String, String)
@since 7.0.2
"""
return getRootPath(cms, targetUri, null);
} | java | public String getRootPath(CmsObject cms, String targetUri) {
return getRootPath(cms, targetUri, null);
} | [
"public",
"String",
"getRootPath",
"(",
"CmsObject",
"cms",
",",
"String",
"targetUri",
")",
"{",
"return",
"getRootPath",
"(",
"cms",
",",
"targetUri",
",",
"null",
")",
";",
"}"
]
| Returns the resource root path in the OpenCms VFS for the given target URI link, or <code>null</code> in
case the link points to an external site.<p>
This methods does not support relative target URI links, so the given URI must be an absolute link.<p>
See {@link #getRootPath(CmsObject, String)} for a full explanation of this method.<p>
@param cms the current users OpenCms context
@param targetUri the target URI link
@return the resource root path in the OpenCms VFS for the given target URI link, or <code>null</code> in
case the link points to an external site
@see #getRootPath(CmsObject, String, String)
@since 7.0.2 | [
"Returns",
"the",
"resource",
"root",
"path",
"in",
"the",
"OpenCms",
"VFS",
"for",
"the",
"given",
"target",
"URI",
"link",
"or",
"<code",
">",
"null<",
"/",
"code",
">",
"in",
"case",
"the",
"link",
"points",
"to",
"an",
"external",
"site",
".",
"<p",
">"
]
| train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/staticexport/CmsLinkManager.java#L503-L506 |
spring-projects/spring-hateoas | src/main/java/org/springframework/hateoas/server/mvc/RepresentationModelAssemblerSupport.java | RepresentationModelAssemblerSupport.createModelWithId | protected D createModelWithId(Object id, T entity) {
"""
Creates a new resource with a self link to the given id.
@param entity must not be {@literal null}.
@param id must not be {@literal null}.
@return
"""
return createModelWithId(id, entity, new Object[0]);
} | java | protected D createModelWithId(Object id, T entity) {
return createModelWithId(id, entity, new Object[0]);
} | [
"protected",
"D",
"createModelWithId",
"(",
"Object",
"id",
",",
"T",
"entity",
")",
"{",
"return",
"createModelWithId",
"(",
"id",
",",
"entity",
",",
"new",
"Object",
"[",
"0",
"]",
")",
";",
"}"
]
| Creates a new resource with a self link to the given id.
@param entity must not be {@literal null}.
@param id must not be {@literal null}.
@return | [
"Creates",
"a",
"new",
"resource",
"with",
"a",
"self",
"link",
"to",
"the",
"given",
"id",
"."
]
| train | https://github.com/spring-projects/spring-hateoas/blob/70ebff9309f086cd8d6a97daf67e0dc215c87d9c/src/main/java/org/springframework/hateoas/server/mvc/RepresentationModelAssemblerSupport.java#L78-L80 |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/module/engagement/interaction/fragment/MessageCenterFragment.java | MessageCenterFragment.onScroll | @Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
"""
/* Show header elevation when listview can scroll up; flatten header when listview
scrolls to the top; For pre-llolipop devices, fallback to a divider
"""
boolean bCanScrollUp;
if (android.os.Build.VERSION.SDK_INT < 14) {
bCanScrollUp = view.getChildCount() > 0
&& (view.getFirstVisiblePosition() > 0 ||
view.getChildAt(0).getTop() < view.getPaddingTop());
} else {
bCanScrollUp = ViewCompat.canScrollVertically(view, -1);
}
showToolbarElevation(bCanScrollUp);
} | java | @Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
boolean bCanScrollUp;
if (android.os.Build.VERSION.SDK_INT < 14) {
bCanScrollUp = view.getChildCount() > 0
&& (view.getFirstVisiblePosition() > 0 ||
view.getChildAt(0).getTop() < view.getPaddingTop());
} else {
bCanScrollUp = ViewCompat.canScrollVertically(view, -1);
}
showToolbarElevation(bCanScrollUp);
} | [
"@",
"Override",
"public",
"void",
"onScroll",
"(",
"AbsListView",
"view",
",",
"int",
"firstVisibleItem",
",",
"int",
"visibleItemCount",
",",
"int",
"totalItemCount",
")",
"{",
"boolean",
"bCanScrollUp",
";",
"if",
"(",
"android",
".",
"os",
".",
"Build",
".",
"VERSION",
".",
"SDK_INT",
"<",
"14",
")",
"{",
"bCanScrollUp",
"=",
"view",
".",
"getChildCount",
"(",
")",
">",
"0",
"&&",
"(",
"view",
".",
"getFirstVisiblePosition",
"(",
")",
">",
"0",
"||",
"view",
".",
"getChildAt",
"(",
"0",
")",
".",
"getTop",
"(",
")",
"<",
"view",
".",
"getPaddingTop",
"(",
")",
")",
";",
"}",
"else",
"{",
"bCanScrollUp",
"=",
"ViewCompat",
".",
"canScrollVertically",
"(",
"view",
",",
"-",
"1",
")",
";",
"}",
"showToolbarElevation",
"(",
"bCanScrollUp",
")",
";",
"}"
]
| /* Show header elevation when listview can scroll up; flatten header when listview
scrolls to the top; For pre-llolipop devices, fallback to a divider | [
"/",
"*",
"Show",
"header",
"elevation",
"when",
"listview",
"can",
"scroll",
"up",
";",
"flatten",
"header",
"when",
"listview",
"scrolls",
"to",
"the",
"top",
";",
"For",
"pre",
"-",
"llolipop",
"devices",
"fallback",
"to",
"a",
"divider"
]
| train | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/module/engagement/interaction/fragment/MessageCenterFragment.java#L1065-L1076 |
google/error-prone-javac | src/jdk.javadoc/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java | LinkFactoryImpl.getClassToolTip | private String getClassToolTip(ClassDoc classDoc, boolean isTypeLink) {
"""
Given a class, return the appropriate tool tip.
@param classDoc the class to get the tool tip for.
@return the tool tip for the appropriate class.
"""
Configuration configuration = m_writer.configuration;
Utils utils = configuration.utils;
if (isTypeLink) {
return configuration.getText("doclet.Href_Type_Param_Title",
classDoc.name());
} else if (classDoc.isInterface()){
return configuration.getText("doclet.Href_Interface_Title",
utils.getPackageName(classDoc.containingPackage()));
} else if (classDoc.isAnnotationType()) {
return configuration.getText("doclet.Href_Annotation_Title",
utils.getPackageName(classDoc.containingPackage()));
} else if (classDoc.isEnum()) {
return configuration.getText("doclet.Href_Enum_Title",
utils.getPackageName(classDoc.containingPackage()));
} else {
return configuration.getText("doclet.Href_Class_Title",
utils.getPackageName(classDoc.containingPackage()));
}
} | java | private String getClassToolTip(ClassDoc classDoc, boolean isTypeLink) {
Configuration configuration = m_writer.configuration;
Utils utils = configuration.utils;
if (isTypeLink) {
return configuration.getText("doclet.Href_Type_Param_Title",
classDoc.name());
} else if (classDoc.isInterface()){
return configuration.getText("doclet.Href_Interface_Title",
utils.getPackageName(classDoc.containingPackage()));
} else if (classDoc.isAnnotationType()) {
return configuration.getText("doclet.Href_Annotation_Title",
utils.getPackageName(classDoc.containingPackage()));
} else if (classDoc.isEnum()) {
return configuration.getText("doclet.Href_Enum_Title",
utils.getPackageName(classDoc.containingPackage()));
} else {
return configuration.getText("doclet.Href_Class_Title",
utils.getPackageName(classDoc.containingPackage()));
}
} | [
"private",
"String",
"getClassToolTip",
"(",
"ClassDoc",
"classDoc",
",",
"boolean",
"isTypeLink",
")",
"{",
"Configuration",
"configuration",
"=",
"m_writer",
".",
"configuration",
";",
"Utils",
"utils",
"=",
"configuration",
".",
"utils",
";",
"if",
"(",
"isTypeLink",
")",
"{",
"return",
"configuration",
".",
"getText",
"(",
"\"doclet.Href_Type_Param_Title\"",
",",
"classDoc",
".",
"name",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"classDoc",
".",
"isInterface",
"(",
")",
")",
"{",
"return",
"configuration",
".",
"getText",
"(",
"\"doclet.Href_Interface_Title\"",
",",
"utils",
".",
"getPackageName",
"(",
"classDoc",
".",
"containingPackage",
"(",
")",
")",
")",
";",
"}",
"else",
"if",
"(",
"classDoc",
".",
"isAnnotationType",
"(",
")",
")",
"{",
"return",
"configuration",
".",
"getText",
"(",
"\"doclet.Href_Annotation_Title\"",
",",
"utils",
".",
"getPackageName",
"(",
"classDoc",
".",
"containingPackage",
"(",
")",
")",
")",
";",
"}",
"else",
"if",
"(",
"classDoc",
".",
"isEnum",
"(",
")",
")",
"{",
"return",
"configuration",
".",
"getText",
"(",
"\"doclet.Href_Enum_Title\"",
",",
"utils",
".",
"getPackageName",
"(",
"classDoc",
".",
"containingPackage",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"return",
"configuration",
".",
"getText",
"(",
"\"doclet.Href_Class_Title\"",
",",
"utils",
".",
"getPackageName",
"(",
"classDoc",
".",
"containingPackage",
"(",
")",
")",
")",
";",
"}",
"}"
]
| Given a class, return the appropriate tool tip.
@param classDoc the class to get the tool tip for.
@return the tool tip for the appropriate class. | [
"Given",
"a",
"class",
"return",
"the",
"appropriate",
"tool",
"tip",
"."
]
| train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java#L174-L193 |
googleads/googleads-java-lib | modules/ads_lib_axis/src/main/java/com/google/api/ads/common/lib/soap/axis/HttpHandler.java | HttpHandler.createHttpRequest | private HttpRequest createHttpRequest(MessageContext msgContext)
throws SOAPException, IOException {
"""
Creates an HTTP request based on the message context.
@param msgContext the Axis message context
@return a new {@link HttpRequest} with content and headers populated
"""
Message requestMessage =
Preconditions.checkNotNull(
msgContext.getRequestMessage(), "Null request message on message context");
// Construct the output stream.
String contentType = requestMessage.getContentType(msgContext.getSOAPConstants());
ByteArrayOutputStream bos = new ByteArrayOutputStream(BUFFER_SIZE);
if (msgContext.isPropertyTrue(HTTPConstants.MC_GZIP_REQUEST)) {
logger.debug("Compressing request");
try (GZIPOutputStream gzipOs = new GZIPOutputStream(bos, BUFFER_SIZE)) {
requestMessage.writeTo(gzipOs);
}
} else {
logger.debug("Not compressing request");
requestMessage.writeTo(bos);
}
HttpRequest httpRequest =
requestFactory.buildPostRequest(
new GenericUrl(msgContext.getStrProp(MessageContext.TRANS_URL)),
new ByteArrayContent(contentType, bos.toByteArray()));
int timeoutMillis = msgContext.getTimeout();
if (timeoutMillis >= 0) {
logger.debug("Setting read and connect timeout to {} millis", timeoutMillis);
// These are not the same, but MessageContext has only one definition of timeout.
httpRequest.setReadTimeout(timeoutMillis);
httpRequest.setConnectTimeout(timeoutMillis);
}
// Copy the request headers from the message context to the post request.
setHttpRequestHeaders(msgContext, httpRequest);
return httpRequest;
} | java | private HttpRequest createHttpRequest(MessageContext msgContext)
throws SOAPException, IOException {
Message requestMessage =
Preconditions.checkNotNull(
msgContext.getRequestMessage(), "Null request message on message context");
// Construct the output stream.
String contentType = requestMessage.getContentType(msgContext.getSOAPConstants());
ByteArrayOutputStream bos = new ByteArrayOutputStream(BUFFER_SIZE);
if (msgContext.isPropertyTrue(HTTPConstants.MC_GZIP_REQUEST)) {
logger.debug("Compressing request");
try (GZIPOutputStream gzipOs = new GZIPOutputStream(bos, BUFFER_SIZE)) {
requestMessage.writeTo(gzipOs);
}
} else {
logger.debug("Not compressing request");
requestMessage.writeTo(bos);
}
HttpRequest httpRequest =
requestFactory.buildPostRequest(
new GenericUrl(msgContext.getStrProp(MessageContext.TRANS_URL)),
new ByteArrayContent(contentType, bos.toByteArray()));
int timeoutMillis = msgContext.getTimeout();
if (timeoutMillis >= 0) {
logger.debug("Setting read and connect timeout to {} millis", timeoutMillis);
// These are not the same, but MessageContext has only one definition of timeout.
httpRequest.setReadTimeout(timeoutMillis);
httpRequest.setConnectTimeout(timeoutMillis);
}
// Copy the request headers from the message context to the post request.
setHttpRequestHeaders(msgContext, httpRequest);
return httpRequest;
} | [
"private",
"HttpRequest",
"createHttpRequest",
"(",
"MessageContext",
"msgContext",
")",
"throws",
"SOAPException",
",",
"IOException",
"{",
"Message",
"requestMessage",
"=",
"Preconditions",
".",
"checkNotNull",
"(",
"msgContext",
".",
"getRequestMessage",
"(",
")",
",",
"\"Null request message on message context\"",
")",
";",
"// Construct the output stream.",
"String",
"contentType",
"=",
"requestMessage",
".",
"getContentType",
"(",
"msgContext",
".",
"getSOAPConstants",
"(",
")",
")",
";",
"ByteArrayOutputStream",
"bos",
"=",
"new",
"ByteArrayOutputStream",
"(",
"BUFFER_SIZE",
")",
";",
"if",
"(",
"msgContext",
".",
"isPropertyTrue",
"(",
"HTTPConstants",
".",
"MC_GZIP_REQUEST",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Compressing request\"",
")",
";",
"try",
"(",
"GZIPOutputStream",
"gzipOs",
"=",
"new",
"GZIPOutputStream",
"(",
"bos",
",",
"BUFFER_SIZE",
")",
")",
"{",
"requestMessage",
".",
"writeTo",
"(",
"gzipOs",
")",
";",
"}",
"}",
"else",
"{",
"logger",
".",
"debug",
"(",
"\"Not compressing request\"",
")",
";",
"requestMessage",
".",
"writeTo",
"(",
"bos",
")",
";",
"}",
"HttpRequest",
"httpRequest",
"=",
"requestFactory",
".",
"buildPostRequest",
"(",
"new",
"GenericUrl",
"(",
"msgContext",
".",
"getStrProp",
"(",
"MessageContext",
".",
"TRANS_URL",
")",
")",
",",
"new",
"ByteArrayContent",
"(",
"contentType",
",",
"bos",
".",
"toByteArray",
"(",
")",
")",
")",
";",
"int",
"timeoutMillis",
"=",
"msgContext",
".",
"getTimeout",
"(",
")",
";",
"if",
"(",
"timeoutMillis",
">=",
"0",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Setting read and connect timeout to {} millis\"",
",",
"timeoutMillis",
")",
";",
"// These are not the same, but MessageContext has only one definition of timeout.",
"httpRequest",
".",
"setReadTimeout",
"(",
"timeoutMillis",
")",
";",
"httpRequest",
".",
"setConnectTimeout",
"(",
"timeoutMillis",
")",
";",
"}",
"// Copy the request headers from the message context to the post request.",
"setHttpRequestHeaders",
"(",
"msgContext",
",",
"httpRequest",
")",
";",
"return",
"httpRequest",
";",
"}"
]
| Creates an HTTP request based on the message context.
@param msgContext the Axis message context
@return a new {@link HttpRequest} with content and headers populated | [
"Creates",
"an",
"HTTP",
"request",
"based",
"on",
"the",
"message",
"context",
"."
]
| train | https://github.com/googleads/googleads-java-lib/blob/967957cc4f6076514e3a7926fe653e4f1f7cc9c9/modules/ads_lib_axis/src/main/java/com/google/api/ads/common/lib/soap/axis/HttpHandler.java#L114-L151 |
lucee/Lucee | core/src/main/java/lucee/runtime/PageSourceImpl.java | PageSourceImpl.pathRemoveLast | private static String pathRemoveLast(String path, RefBoolean isOutSide) {
"""
remove the last elemtn of a path
@param path path to remove last element from it
@param isOutSide
@return path with removed element
"""
if (path.length() == 0) {
isOutSide.setValue(true);
return "..";
}
else if (path.endsWith("..")) {
isOutSide.setValue(true);
return path.concat("/..");// path+"/..";
}
return path.substring(0, path.lastIndexOf('/'));
} | java | private static String pathRemoveLast(String path, RefBoolean isOutSide) {
if (path.length() == 0) {
isOutSide.setValue(true);
return "..";
}
else if (path.endsWith("..")) {
isOutSide.setValue(true);
return path.concat("/..");// path+"/..";
}
return path.substring(0, path.lastIndexOf('/'));
} | [
"private",
"static",
"String",
"pathRemoveLast",
"(",
"String",
"path",
",",
"RefBoolean",
"isOutSide",
")",
"{",
"if",
"(",
"path",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"isOutSide",
".",
"setValue",
"(",
"true",
")",
";",
"return",
"\"..\"",
";",
"}",
"else",
"if",
"(",
"path",
".",
"endsWith",
"(",
"\"..\"",
")",
")",
"{",
"isOutSide",
".",
"setValue",
"(",
"true",
")",
";",
"return",
"path",
".",
"concat",
"(",
"\"/..\"",
")",
";",
"// path+\"/..\";",
"}",
"return",
"path",
".",
"substring",
"(",
"0",
",",
"path",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
")",
";",
"}"
]
| remove the last elemtn of a path
@param path path to remove last element from it
@param isOutSide
@return path with removed element | [
"remove",
"the",
"last",
"elemtn",
"of",
"a",
"path"
]
| train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/runtime/PageSourceImpl.java#L600-L610 |
landawn/AbacusUtil | src/com/landawn/abacus/util/RegExUtil.java | RegExUtil.removeFirst | public static String removeFirst(final String text, final Pattern regex) {
"""
<p>Removes the first substring of the text string that matches the given regular expression pattern.</p>
This method is a {@code null} safe equivalent to:
<ul>
<li>{@code pattern.matcher(text).replaceFirst(N.EMPTY_STRING)}</li>
</ul>
<p>A {@code null} reference passed to this method is a no-op.</p>
<pre>
StringUtils.removeFirst(null, *) = null
StringUtils.removeFirst("any", (Pattern) null) = "any"
StringUtils.removeFirst("any", Pattern.compile("")) = "any"
StringUtils.removeFirst("any", Pattern.compile(".*")) = ""
StringUtils.removeFirst("any", Pattern.compile(".+")) = ""
StringUtils.removeFirst("abc", Pattern.compile(".?")) = "bc"
StringUtils.removeFirst("A<__>\n<__>B", Pattern.compile("<.*>")) = "A\n<__>B"
StringUtils.removeFirst("A<__>\n<__>B", Pattern.compile("(?s)<.*>")) = "AB"
StringUtils.removeFirst("ABCabc123", Pattern.compile("[a-z]")) = "ABCbc123"
StringUtils.removeFirst("ABCabc123abc", Pattern.compile("[a-z]+")) = "ABC123abc"
</pre>
@param text text to remove from, may be null
@param regex the regular expression pattern to which this string is to be matched
@return the text with the first replacement processed,
{@code null} if null String input
@see #replaceFirst(String, Pattern, String)
@see java.util.regex.Matcher#replaceFirst(String)
@see java.util.regex.Pattern
"""
return replaceFirst(text, regex, N.EMPTY_STRING);
} | java | public static String removeFirst(final String text, final Pattern regex) {
return replaceFirst(text, regex, N.EMPTY_STRING);
} | [
"public",
"static",
"String",
"removeFirst",
"(",
"final",
"String",
"text",
",",
"final",
"Pattern",
"regex",
")",
"{",
"return",
"replaceFirst",
"(",
"text",
",",
"regex",
",",
"N",
".",
"EMPTY_STRING",
")",
";",
"}"
]
| <p>Removes the first substring of the text string that matches the given regular expression pattern.</p>
This method is a {@code null} safe equivalent to:
<ul>
<li>{@code pattern.matcher(text).replaceFirst(N.EMPTY_STRING)}</li>
</ul>
<p>A {@code null} reference passed to this method is a no-op.</p>
<pre>
StringUtils.removeFirst(null, *) = null
StringUtils.removeFirst("any", (Pattern) null) = "any"
StringUtils.removeFirst("any", Pattern.compile("")) = "any"
StringUtils.removeFirst("any", Pattern.compile(".*")) = ""
StringUtils.removeFirst("any", Pattern.compile(".+")) = ""
StringUtils.removeFirst("abc", Pattern.compile(".?")) = "bc"
StringUtils.removeFirst("A<__>\n<__>B", Pattern.compile("<.*>")) = "A\n<__>B"
StringUtils.removeFirst("A<__>\n<__>B", Pattern.compile("(?s)<.*>")) = "AB"
StringUtils.removeFirst("ABCabc123", Pattern.compile("[a-z]")) = "ABCbc123"
StringUtils.removeFirst("ABCabc123abc", Pattern.compile("[a-z]+")) = "ABC123abc"
</pre>
@param text text to remove from, may be null
@param regex the regular expression pattern to which this string is to be matched
@return the text with the first replacement processed,
{@code null} if null String input
@see #replaceFirst(String, Pattern, String)
@see java.util.regex.Matcher#replaceFirst(String)
@see java.util.regex.Pattern | [
"<p",
">",
"Removes",
"the",
"first",
"substring",
"of",
"the",
"text",
"string",
"that",
"matches",
"the",
"given",
"regular",
"expression",
"pattern",
".",
"<",
"/",
"p",
">"
]
| train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/util/RegExUtil.java#L150-L152 |
apache/flink | flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/StreamQueryConfig.java | StreamQueryConfig.withIdleStateRetentionTime | public StreamQueryConfig withIdleStateRetentionTime(Time minTime, Time maxTime) {
"""
Specifies a minimum and a maximum time interval for how long idle state, i.e., state which
was not updated, will be retained.
State will never be cleared until it was idle for less than the minimum time and will never
be kept if it was idle for more than the maximum time.
<p>When new data arrives for previously cleaned-up state, the new data will be handled as if it
was the first data. This can result in previous results being overwritten.
<p>Set to 0 (zero) to never clean-up the state.
<p>NOTE: Cleaning up state requires additional bookkeeping which becomes less expensive for
larger differences of minTime and maxTime. The difference between minTime and maxTime must be
at least 5 minutes.
@param minTime The minimum time interval for which idle state is retained. Set to 0 (zero) to
never clean-up the state.
@param maxTime The maximum time interval for which idle state is retained. Must be at least
5 minutes greater than minTime. Set to 0 (zero) to never clean-up the state.
"""
if (maxTime.toMilliseconds() - minTime.toMilliseconds() < 300000 &&
!(maxTime.toMilliseconds() == 0 && minTime.toMilliseconds() == 0)) {
throw new IllegalArgumentException(
"Difference between minTime: " + minTime.toString() + " and maxTime: " + maxTime.toString() +
"shoud be at least 5 minutes.");
}
minIdleStateRetentionTime = minTime.toMilliseconds();
maxIdleStateRetentionTime = maxTime.toMilliseconds();
return this;
} | java | public StreamQueryConfig withIdleStateRetentionTime(Time minTime, Time maxTime) {
if (maxTime.toMilliseconds() - minTime.toMilliseconds() < 300000 &&
!(maxTime.toMilliseconds() == 0 && minTime.toMilliseconds() == 0)) {
throw new IllegalArgumentException(
"Difference between minTime: " + minTime.toString() + " and maxTime: " + maxTime.toString() +
"shoud be at least 5 minutes.");
}
minIdleStateRetentionTime = minTime.toMilliseconds();
maxIdleStateRetentionTime = maxTime.toMilliseconds();
return this;
} | [
"public",
"StreamQueryConfig",
"withIdleStateRetentionTime",
"(",
"Time",
"minTime",
",",
"Time",
"maxTime",
")",
"{",
"if",
"(",
"maxTime",
".",
"toMilliseconds",
"(",
")",
"-",
"minTime",
".",
"toMilliseconds",
"(",
")",
"<",
"300000",
"&&",
"!",
"(",
"maxTime",
".",
"toMilliseconds",
"(",
")",
"==",
"0",
"&&",
"minTime",
".",
"toMilliseconds",
"(",
")",
"==",
"0",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Difference between minTime: \"",
"+",
"minTime",
".",
"toString",
"(",
")",
"+",
"\" and maxTime: \"",
"+",
"maxTime",
".",
"toString",
"(",
")",
"+",
"\"shoud be at least 5 minutes.\"",
")",
";",
"}",
"minIdleStateRetentionTime",
"=",
"minTime",
".",
"toMilliseconds",
"(",
")",
";",
"maxIdleStateRetentionTime",
"=",
"maxTime",
".",
"toMilliseconds",
"(",
")",
";",
"return",
"this",
";",
"}"
]
| Specifies a minimum and a maximum time interval for how long idle state, i.e., state which
was not updated, will be retained.
State will never be cleared until it was idle for less than the minimum time and will never
be kept if it was idle for more than the maximum time.
<p>When new data arrives for previously cleaned-up state, the new data will be handled as if it
was the first data. This can result in previous results being overwritten.
<p>Set to 0 (zero) to never clean-up the state.
<p>NOTE: Cleaning up state requires additional bookkeeping which becomes less expensive for
larger differences of minTime and maxTime. The difference between minTime and maxTime must be
at least 5 minutes.
@param minTime The minimum time interval for which idle state is retained. Set to 0 (zero) to
never clean-up the state.
@param maxTime The maximum time interval for which idle state is retained. Must be at least
5 minutes greater than minTime. Set to 0 (zero) to never clean-up the state. | [
"Specifies",
"a",
"minimum",
"and",
"a",
"maximum",
"time",
"interval",
"for",
"how",
"long",
"idle",
"state",
"i",
".",
"e",
".",
"state",
"which",
"was",
"not",
"updated",
"will",
"be",
"retained",
".",
"State",
"will",
"never",
"be",
"cleared",
"until",
"it",
"was",
"idle",
"for",
"less",
"than",
"the",
"minimum",
"time",
"and",
"will",
"never",
"be",
"kept",
"if",
"it",
"was",
"idle",
"for",
"more",
"than",
"the",
"maximum",
"time",
"."
]
| train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/StreamQueryConfig.java#L62-L73 |
codeprimate-software/cp-elements | src/main/java/org/cp/elements/lang/ElementsExceptionsFactory.java | ElementsExceptionsFactory.newApplicationException | public static ApplicationException newApplicationException(String message, Object... args) {
"""
Constructs and initializes a new {@link ApplicationException} with the given {@link String message}
formatted with the given {@link Object[] arguments}.
@param message {@link String} describing the {@link ApplicationException exception}.
@param args {@link Object[] arguments} used to replace format placeholders in the {@link String message}.
@return a new {@link ApplicationException} with the given {@link String message}.
@see #newApplicationException(Throwable, String, Object...)
@see org.cp.elements.util.ApplicationException
"""
return newApplicationException(null, message, args);
} | java | public static ApplicationException newApplicationException(String message, Object... args) {
return newApplicationException(null, message, args);
} | [
"public",
"static",
"ApplicationException",
"newApplicationException",
"(",
"String",
"message",
",",
"Object",
"...",
"args",
")",
"{",
"return",
"newApplicationException",
"(",
"null",
",",
"message",
",",
"args",
")",
";",
"}"
]
| Constructs and initializes a new {@link ApplicationException} with the given {@link String message}
formatted with the given {@link Object[] arguments}.
@param message {@link String} describing the {@link ApplicationException exception}.
@param args {@link Object[] arguments} used to replace format placeholders in the {@link String message}.
@return a new {@link ApplicationException} with the given {@link String message}.
@see #newApplicationException(Throwable, String, Object...)
@see org.cp.elements.util.ApplicationException | [
"Constructs",
"and",
"initializes",
"a",
"new",
"{",
"@link",
"ApplicationException",
"}",
"with",
"the",
"given",
"{",
"@link",
"String",
"message",
"}",
"formatted",
"with",
"the",
"given",
"{",
"@link",
"Object",
"[]",
"arguments",
"}",
"."
]
| train | https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/lang/ElementsExceptionsFactory.java#L761-L763 |
apereo/cas | core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/http/SimpleHttpClientFactoryBean.java | SimpleHttpClientFactoryBean.buildRequestExecutorService | private FutureRequestExecutionService buildRequestExecutorService(final CloseableHttpClient httpClient) {
"""
Build a {@link FutureRequestExecutionService} from the current properties and a HTTP client.
@param httpClient the provided HTTP client
@return the built request executor service
"""
if (this.executorService == null) {
this.executorService = new ThreadPoolExecutor(this.threadsNumber, this.threadsNumber, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(this.queueSize));
}
return new FutureRequestExecutionService(httpClient, this.executorService);
} | java | private FutureRequestExecutionService buildRequestExecutorService(final CloseableHttpClient httpClient) {
if (this.executorService == null) {
this.executorService = new ThreadPoolExecutor(this.threadsNumber, this.threadsNumber, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(this.queueSize));
}
return new FutureRequestExecutionService(httpClient, this.executorService);
} | [
"private",
"FutureRequestExecutionService",
"buildRequestExecutorService",
"(",
"final",
"CloseableHttpClient",
"httpClient",
")",
"{",
"if",
"(",
"this",
".",
"executorService",
"==",
"null",
")",
"{",
"this",
".",
"executorService",
"=",
"new",
"ThreadPoolExecutor",
"(",
"this",
".",
"threadsNumber",
",",
"this",
".",
"threadsNumber",
",",
"0L",
",",
"TimeUnit",
".",
"MILLISECONDS",
",",
"new",
"LinkedBlockingQueue",
"<>",
"(",
"this",
".",
"queueSize",
")",
")",
";",
"}",
"return",
"new",
"FutureRequestExecutionService",
"(",
"httpClient",
",",
"this",
".",
"executorService",
")",
";",
"}"
]
| Build a {@link FutureRequestExecutionService} from the current properties and a HTTP client.
@param httpClient the provided HTTP client
@return the built request executor service | [
"Build",
"a",
"{",
"@link",
"FutureRequestExecutionService",
"}",
"from",
"the",
"current",
"properties",
"and",
"a",
"HTTP",
"client",
"."
]
| train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/http/SimpleHttpClientFactoryBean.java#L255-L260 |
nohana/Amalgam | amalgam/src/main/java/com/amalgam/os/BundleUtils.java | BundleUtils.optLongArray | @Nullable
public static long[] optLongArray(@Nullable Bundle bundle, @Nullable String key) {
"""
Returns a optional long array value. In other words, returns the value mapped by key if it exists and is a long array.
The bundle argument is allowed to be {@code null}. If the bundle is null, this method returns null.
@param bundle a bundle. If the bundle is null, this method will return null.
@param key a key for the value.
@return a long array value if exists, null otherwise.
@see android.os.Bundle#getInt(String, int)
"""
return optLongArray(bundle, key, new long[0]);
} | java | @Nullable
public static long[] optLongArray(@Nullable Bundle bundle, @Nullable String key) {
return optLongArray(bundle, key, new long[0]);
} | [
"@",
"Nullable",
"public",
"static",
"long",
"[",
"]",
"optLongArray",
"(",
"@",
"Nullable",
"Bundle",
"bundle",
",",
"@",
"Nullable",
"String",
"key",
")",
"{",
"return",
"optLongArray",
"(",
"bundle",
",",
"key",
",",
"new",
"long",
"[",
"0",
"]",
")",
";",
"}"
]
| Returns a optional long array value. In other words, returns the value mapped by key if it exists and is a long array.
The bundle argument is allowed to be {@code null}. If the bundle is null, this method returns null.
@param bundle a bundle. If the bundle is null, this method will return null.
@param key a key for the value.
@return a long array value if exists, null otherwise.
@see android.os.Bundle#getInt(String, int) | [
"Returns",
"a",
"optional",
"long",
"array",
"value",
".",
"In",
"other",
"words",
"returns",
"the",
"value",
"mapped",
"by",
"key",
"if",
"it",
"exists",
"and",
"is",
"a",
"long",
"array",
".",
"The",
"bundle",
"argument",
"is",
"allowed",
"to",
"be",
"{"
]
| train | https://github.com/nohana/Amalgam/blob/57809ddbfe7897e979cf507982ce0b3aa5e0ed8a/amalgam/src/main/java/com/amalgam/os/BundleUtils.java#L659-L662 |
sebastiangraf/jSCSI | bundles/commons/src/main/java/org/jscsi/parser/AbstractMessageParser.java | AbstractMessageParser.serializeBasicHeaderSegment | final void serializeBasicHeaderSegment (final ByteBuffer dst, final int offset) throws InternetSCSIException {
"""
This method serializes the whole BHS to its byte representation.
@param dst The destination <code>ByteBuffer</code> to write to.
@param offset The start offset in <code>dst</code>.
@throws InternetSCSIException If any violation of the iSCSI-Standard emerge.
"""
dst.position(offset);
dst.putInt(offset, dst.getInt() | serializeBytes1to3());
dst.position(offset + BasicHeaderSegment.BYTES_8_11);
dst.putInt(serializeBytes8to11());
dst.putInt(serializeBytes12to15());
dst.position(offset + BasicHeaderSegment.BYTES_20_23);
dst.putInt(serializeBytes20to23());
dst.putInt(serializeBytes24to27());
dst.putInt(serializeBytes28to31());
dst.putInt(serializeBytes32to35());
dst.putInt(serializeBytes36to39());
dst.putInt(serializeBytes40to43());
dst.putInt(serializeBytes44to47());
} | java | final void serializeBasicHeaderSegment (final ByteBuffer dst, final int offset) throws InternetSCSIException {
dst.position(offset);
dst.putInt(offset, dst.getInt() | serializeBytes1to3());
dst.position(offset + BasicHeaderSegment.BYTES_8_11);
dst.putInt(serializeBytes8to11());
dst.putInt(serializeBytes12to15());
dst.position(offset + BasicHeaderSegment.BYTES_20_23);
dst.putInt(serializeBytes20to23());
dst.putInt(serializeBytes24to27());
dst.putInt(serializeBytes28to31());
dst.putInt(serializeBytes32to35());
dst.putInt(serializeBytes36to39());
dst.putInt(serializeBytes40to43());
dst.putInt(serializeBytes44to47());
} | [
"final",
"void",
"serializeBasicHeaderSegment",
"(",
"final",
"ByteBuffer",
"dst",
",",
"final",
"int",
"offset",
")",
"throws",
"InternetSCSIException",
"{",
"dst",
".",
"position",
"(",
"offset",
")",
";",
"dst",
".",
"putInt",
"(",
"offset",
",",
"dst",
".",
"getInt",
"(",
")",
"|",
"serializeBytes1to3",
"(",
")",
")",
";",
"dst",
".",
"position",
"(",
"offset",
"+",
"BasicHeaderSegment",
".",
"BYTES_8_11",
")",
";",
"dst",
".",
"putInt",
"(",
"serializeBytes8to11",
"(",
")",
")",
";",
"dst",
".",
"putInt",
"(",
"serializeBytes12to15",
"(",
")",
")",
";",
"dst",
".",
"position",
"(",
"offset",
"+",
"BasicHeaderSegment",
".",
"BYTES_20_23",
")",
";",
"dst",
".",
"putInt",
"(",
"serializeBytes20to23",
"(",
")",
")",
";",
"dst",
".",
"putInt",
"(",
"serializeBytes24to27",
"(",
")",
")",
";",
"dst",
".",
"putInt",
"(",
"serializeBytes28to31",
"(",
")",
")",
";",
"dst",
".",
"putInt",
"(",
"serializeBytes32to35",
"(",
")",
")",
";",
"dst",
".",
"putInt",
"(",
"serializeBytes36to39",
"(",
")",
")",
";",
"dst",
".",
"putInt",
"(",
"serializeBytes40to43",
"(",
")",
")",
";",
"dst",
".",
"putInt",
"(",
"serializeBytes44to47",
"(",
")",
")",
";",
"}"
]
| This method serializes the whole BHS to its byte representation.
@param dst The destination <code>ByteBuffer</code> to write to.
@param offset The start offset in <code>dst</code>.
@throws InternetSCSIException If any violation of the iSCSI-Standard emerge. | [
"This",
"method",
"serializes",
"the",
"whole",
"BHS",
"to",
"its",
"byte",
"representation",
"."
]
| train | https://github.com/sebastiangraf/jSCSI/blob/6169bfe73f0b15de7d6485453555389e782ae888/bundles/commons/src/main/java/org/jscsi/parser/AbstractMessageParser.java#L112-L129 |
Erudika/para | para-client/src/main/java/com/erudika/para/client/ParaClient.java | ParaClient.findByIds | public <P extends ParaObject> List<P> findByIds(List<String> ids) {
"""
Simple multi id search.
@param <P> type of the object
@param ids a list of ids to search for
@return a list of object found
"""
MultivaluedMap<String, String> params = new MultivaluedHashMap<>();
params.put("ids", ids);
return getItems(find("ids", params));
} | java | public <P extends ParaObject> List<P> findByIds(List<String> ids) {
MultivaluedMap<String, String> params = new MultivaluedHashMap<>();
params.put("ids", ids);
return getItems(find("ids", params));
} | [
"public",
"<",
"P",
"extends",
"ParaObject",
">",
"List",
"<",
"P",
">",
"findByIds",
"(",
"List",
"<",
"String",
">",
"ids",
")",
"{",
"MultivaluedMap",
"<",
"String",
",",
"String",
">",
"params",
"=",
"new",
"MultivaluedHashMap",
"<>",
"(",
")",
";",
"params",
".",
"put",
"(",
"\"ids\"",
",",
"ids",
")",
";",
"return",
"getItems",
"(",
"find",
"(",
"\"ids\"",
",",
"params",
")",
")",
";",
"}"
]
| Simple multi id search.
@param <P> type of the object
@param ids a list of ids to search for
@return a list of object found | [
"Simple",
"multi",
"id",
"search",
"."
]
| train | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-client/src/main/java/com/erudika/para/client/ParaClient.java#L671-L675 |
Impetus/Kundera | src/kundera-cassandra/cassandra-core/src/main/java/com/impetus/client/cassandra/thrift/CQLTranslator.java | CQLTranslator.appendList | private boolean appendList(StringBuilder builder, Object value) {
"""
Appends a object of type {@link java.util.List}
@param builder
the builder
@param value
the value
@return true, if successful
"""
boolean isPresent = false;
if (value instanceof Collection)
{
Collection collection = ((Collection) value);
isPresent = true;
builder.append(Constants.OPEN_SQUARE_BRACKET);
for (Object o : collection)
{
// Allowing null values.
appendValue(builder, o != null ? o.getClass() : null, o, false);
builder.append(Constants.COMMA);
}
if (!collection.isEmpty())
{
builder.deleteCharAt(builder.length() - 1);
}
builder.append(Constants.CLOSE_SQUARE_BRACKET);
}
else
{
appendValue(builder, value.getClass(), value, false);
}
return isPresent;
} | java | private boolean appendList(StringBuilder builder, Object value)
{
boolean isPresent = false;
if (value instanceof Collection)
{
Collection collection = ((Collection) value);
isPresent = true;
builder.append(Constants.OPEN_SQUARE_BRACKET);
for (Object o : collection)
{
// Allowing null values.
appendValue(builder, o != null ? o.getClass() : null, o, false);
builder.append(Constants.COMMA);
}
if (!collection.isEmpty())
{
builder.deleteCharAt(builder.length() - 1);
}
builder.append(Constants.CLOSE_SQUARE_BRACKET);
}
else
{
appendValue(builder, value.getClass(), value, false);
}
return isPresent;
} | [
"private",
"boolean",
"appendList",
"(",
"StringBuilder",
"builder",
",",
"Object",
"value",
")",
"{",
"boolean",
"isPresent",
"=",
"false",
";",
"if",
"(",
"value",
"instanceof",
"Collection",
")",
"{",
"Collection",
"collection",
"=",
"(",
"(",
"Collection",
")",
"value",
")",
";",
"isPresent",
"=",
"true",
";",
"builder",
".",
"append",
"(",
"Constants",
".",
"OPEN_SQUARE_BRACKET",
")",
";",
"for",
"(",
"Object",
"o",
":",
"collection",
")",
"{",
"// Allowing null values.",
"appendValue",
"(",
"builder",
",",
"o",
"!=",
"null",
"?",
"o",
".",
"getClass",
"(",
")",
":",
"null",
",",
"o",
",",
"false",
")",
";",
"builder",
".",
"append",
"(",
"Constants",
".",
"COMMA",
")",
";",
"}",
"if",
"(",
"!",
"collection",
".",
"isEmpty",
"(",
")",
")",
"{",
"builder",
".",
"deleteCharAt",
"(",
"builder",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"}",
"builder",
".",
"append",
"(",
"Constants",
".",
"CLOSE_SQUARE_BRACKET",
")",
";",
"}",
"else",
"{",
"appendValue",
"(",
"builder",
",",
"value",
".",
"getClass",
"(",
")",
",",
"value",
",",
"false",
")",
";",
"}",
"return",
"isPresent",
";",
"}"
]
| Appends a object of type {@link java.util.List}
@param builder
the builder
@param value
the value
@return true, if successful | [
"Appends",
"a",
"object",
"of",
"type",
"{",
"@link",
"java",
".",
"util",
".",
"List",
"}"
]
| train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-cassandra/cassandra-core/src/main/java/com/impetus/client/cassandra/thrift/CQLTranslator.java#L1137-L1163 |
khuxtable/seaglass | src/main/java/com/seaglasslookandfeel/util/WindowUtils.java | WindowUtils.createAncestorListener | private static AncestorListener createAncestorListener(JComponent component, final WindowListener windowListener) {
"""
Create the ancestor listener.
@param component the component.
@param windowListener the listener.
@return the weak referenced listener.
"""
final WeakReference<JComponent> weakReference = new WeakReference<JComponent>(component);
return new AncestorListener() {
public void ancestorAdded(AncestorEvent event) {
// TODO if the WeakReference's object is null, remove the
// WeakReference as an AncestorListener.
Window window = weakReference.get() == null ? null : SwingUtilities.getWindowAncestor(weakReference.get());
if (window != null) {
window.removeWindowListener(windowListener);
window.addWindowListener(windowListener);
}
}
public void ancestorRemoved(AncestorEvent event) {
Window window = weakReference.get() == null ? null : SwingUtilities.getWindowAncestor(weakReference.get());
if (window != null) {
window.removeWindowListener(windowListener);
}
}
public void ancestorMoved(AncestorEvent event) {
// no implementation.
}
};
} | java | private static AncestorListener createAncestorListener(JComponent component, final WindowListener windowListener) {
final WeakReference<JComponent> weakReference = new WeakReference<JComponent>(component);
return new AncestorListener() {
public void ancestorAdded(AncestorEvent event) {
// TODO if the WeakReference's object is null, remove the
// WeakReference as an AncestorListener.
Window window = weakReference.get() == null ? null : SwingUtilities.getWindowAncestor(weakReference.get());
if (window != null) {
window.removeWindowListener(windowListener);
window.addWindowListener(windowListener);
}
}
public void ancestorRemoved(AncestorEvent event) {
Window window = weakReference.get() == null ? null : SwingUtilities.getWindowAncestor(weakReference.get());
if (window != null) {
window.removeWindowListener(windowListener);
}
}
public void ancestorMoved(AncestorEvent event) {
// no implementation.
}
};
} | [
"private",
"static",
"AncestorListener",
"createAncestorListener",
"(",
"JComponent",
"component",
",",
"final",
"WindowListener",
"windowListener",
")",
"{",
"final",
"WeakReference",
"<",
"JComponent",
">",
"weakReference",
"=",
"new",
"WeakReference",
"<",
"JComponent",
">",
"(",
"component",
")",
";",
"return",
"new",
"AncestorListener",
"(",
")",
"{",
"public",
"void",
"ancestorAdded",
"(",
"AncestorEvent",
"event",
")",
"{",
"// TODO if the WeakReference's object is null, remove the",
"// WeakReference as an AncestorListener.",
"Window",
"window",
"=",
"weakReference",
".",
"get",
"(",
")",
"==",
"null",
"?",
"null",
":",
"SwingUtilities",
".",
"getWindowAncestor",
"(",
"weakReference",
".",
"get",
"(",
")",
")",
";",
"if",
"(",
"window",
"!=",
"null",
")",
"{",
"window",
".",
"removeWindowListener",
"(",
"windowListener",
")",
";",
"window",
".",
"addWindowListener",
"(",
"windowListener",
")",
";",
"}",
"}",
"public",
"void",
"ancestorRemoved",
"(",
"AncestorEvent",
"event",
")",
"{",
"Window",
"window",
"=",
"weakReference",
".",
"get",
"(",
")",
"==",
"null",
"?",
"null",
":",
"SwingUtilities",
".",
"getWindowAncestor",
"(",
"weakReference",
".",
"get",
"(",
")",
")",
";",
"if",
"(",
"window",
"!=",
"null",
")",
"{",
"window",
".",
"removeWindowListener",
"(",
"windowListener",
")",
";",
"}",
"}",
"public",
"void",
"ancestorMoved",
"(",
"AncestorEvent",
"event",
")",
"{",
"// no implementation.",
"}",
"}",
";",
"}"
]
| Create the ancestor listener.
@param component the component.
@param windowListener the listener.
@return the weak referenced listener. | [
"Create",
"the",
"ancestor",
"listener",
"."
]
| train | https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/util/WindowUtils.java#L246-L273 |
OpenLiberty/open-liberty | dev/com.ibm.ws.logging.hpel/src/com/ibm/ws/logging/hpel/impl/LogRecordBrowser.java | LogRecordBrowser.recordsInProcess | public OnePidRecordListImpl recordsInProcess(long min, long max, final LogRecordFilter filter) {
"""
Returns records belonging to a process and satisfying the filter.
@param min the low time limit (the oldest log record).
@param max the upper time limit (the youngest log record).
@param filter criteria to filter logs records on.
@return the iterable list of records.
"""
return startRecordsInProcess(min, max, filter==null ? new AllAcceptVerifier() : new FullFilterVerifier(filter));
} | java | public OnePidRecordListImpl recordsInProcess(long min, long max, final LogRecordFilter filter) {
return startRecordsInProcess(min, max, filter==null ? new AllAcceptVerifier() : new FullFilterVerifier(filter));
} | [
"public",
"OnePidRecordListImpl",
"recordsInProcess",
"(",
"long",
"min",
",",
"long",
"max",
",",
"final",
"LogRecordFilter",
"filter",
")",
"{",
"return",
"startRecordsInProcess",
"(",
"min",
",",
"max",
",",
"filter",
"==",
"null",
"?",
"new",
"AllAcceptVerifier",
"(",
")",
":",
"new",
"FullFilterVerifier",
"(",
"filter",
")",
")",
";",
"}"
]
| Returns records belonging to a process and satisfying the filter.
@param min the low time limit (the oldest log record).
@param max the upper time limit (the youngest log record).
@param filter criteria to filter logs records on.
@return the iterable list of records. | [
"Returns",
"records",
"belonging",
"to",
"a",
"process",
"and",
"satisfying",
"the",
"filter",
"."
]
| train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.logging.hpel/src/com/ibm/ws/logging/hpel/impl/LogRecordBrowser.java#L65-L67 |
kotcrab/vis-ui | ui/src/main/java/com/kotcrab/vis/ui/util/form/FormValidator.java | FormValidator.directoryEmpty | public FormInputValidator directoryEmpty (VisValidatableTextField field, String errorMsg) {
"""
Validates if relative path entered in text field points to an existing and empty directory.
"""
DirectoryContentValidator validator = new DirectoryContentValidator(errorMsg, true);
field.addValidator(validator);
add(field);
return validator;
} | java | public FormInputValidator directoryEmpty (VisValidatableTextField field, String errorMsg) {
DirectoryContentValidator validator = new DirectoryContentValidator(errorMsg, true);
field.addValidator(validator);
add(field);
return validator;
} | [
"public",
"FormInputValidator",
"directoryEmpty",
"(",
"VisValidatableTextField",
"field",
",",
"String",
"errorMsg",
")",
"{",
"DirectoryContentValidator",
"validator",
"=",
"new",
"DirectoryContentValidator",
"(",
"errorMsg",
",",
"true",
")",
";",
"field",
".",
"addValidator",
"(",
"validator",
")",
";",
"add",
"(",
"field",
")",
";",
"return",
"validator",
";",
"}"
]
| Validates if relative path entered in text field points to an existing and empty directory. | [
"Validates",
"if",
"relative",
"path",
"entered",
"in",
"text",
"field",
"points",
"to",
"an",
"existing",
"and",
"empty",
"directory",
"."
]
| train | https://github.com/kotcrab/vis-ui/blob/3b68f82d94ae32bffa2a3399c63f432e0f4908e0/ui/src/main/java/com/kotcrab/vis/ui/util/form/FormValidator.java#L164-L169 |
marvinlabs/android-intents | library/src/main/java/com/marvinlabs/intents/MediaIntents.java | MediaIntents.newPlayMediaFileIntent | public static Intent newPlayMediaFileIntent(File file, String type) {
"""
Open the media player to play the given media
@param file The file path of the media to play.
@param type The mime type
@return the intent
"""
return newPlayMediaIntent(Uri.fromFile(file), type);
} | java | public static Intent newPlayMediaFileIntent(File file, String type) {
return newPlayMediaIntent(Uri.fromFile(file), type);
} | [
"public",
"static",
"Intent",
"newPlayMediaFileIntent",
"(",
"File",
"file",
",",
"String",
"type",
")",
"{",
"return",
"newPlayMediaIntent",
"(",
"Uri",
".",
"fromFile",
"(",
"file",
")",
",",
"type",
")",
";",
"}"
]
| Open the media player to play the given media
@param file The file path of the media to play.
@param type The mime type
@return the intent | [
"Open",
"the",
"media",
"player",
"to",
"play",
"the",
"given",
"media"
]
| train | https://github.com/marvinlabs/android-intents/blob/33e79c825188b6a97601869522533cc825801f6e/library/src/main/java/com/marvinlabs/intents/MediaIntents.java#L160-L162 |
Netflix/ribbon | ribbon-loadbalancer/src/main/java/com/netflix/client/ClientFactory.java | ClientFactory.getNamedLoadBalancer | public static synchronized ILoadBalancer getNamedLoadBalancer(String name) {
"""
Get the load balancer associated with the name, or create one with the default {@link ClientConfigFactory} if does not exist
@throws RuntimeException if any error occurs
"""
ILoadBalancer lb = namedLBMap.get(name);
if (lb != null) {
return lb;
} else {
try {
lb = registerNamedLoadBalancerFromclientConfig(name, getNamedConfig(name));
} catch (ClientException e) {
throw new RuntimeException("Unable to create load balancer", e);
}
namedLBMap.put(name, lb);
return lb;
}
} | java | public static synchronized ILoadBalancer getNamedLoadBalancer(String name) {
ILoadBalancer lb = namedLBMap.get(name);
if (lb != null) {
return lb;
} else {
try {
lb = registerNamedLoadBalancerFromclientConfig(name, getNamedConfig(name));
} catch (ClientException e) {
throw new RuntimeException("Unable to create load balancer", e);
}
namedLBMap.put(name, lb);
return lb;
}
} | [
"public",
"static",
"synchronized",
"ILoadBalancer",
"getNamedLoadBalancer",
"(",
"String",
"name",
")",
"{",
"ILoadBalancer",
"lb",
"=",
"namedLBMap",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"lb",
"!=",
"null",
")",
"{",
"return",
"lb",
";",
"}",
"else",
"{",
"try",
"{",
"lb",
"=",
"registerNamedLoadBalancerFromclientConfig",
"(",
"name",
",",
"getNamedConfig",
"(",
"name",
")",
")",
";",
"}",
"catch",
"(",
"ClientException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unable to create load balancer\"",
",",
"e",
")",
";",
"}",
"namedLBMap",
".",
"put",
"(",
"name",
",",
"lb",
")",
";",
"return",
"lb",
";",
"}",
"}"
]
| Get the load balancer associated with the name, or create one with the default {@link ClientConfigFactory} if does not exist
@throws RuntimeException if any error occurs | [
"Get",
"the",
"load",
"balancer",
"associated",
"with",
"the",
"name",
"or",
"create",
"one",
"with",
"the",
"default",
"{",
"@link",
"ClientConfigFactory",
"}",
"if",
"does",
"not",
"exist"
]
| train | https://github.com/Netflix/ribbon/blob/d15cd7715b0bf2f64ae6ca98c5e4d184f178e261/ribbon-loadbalancer/src/main/java/com/netflix/client/ClientFactory.java#L137-L150 |
cdk/cdk | tool/hash/src/main/java/org/openscience/cdk/hash/HashGeneratorMaker.java | HashGeneratorMaker.atomic | public AtomHashGenerator atomic() {
"""
Given the current configuration create an {@link AtomHashGenerator}.
@return instance of the generator
@throws IllegalArgumentException no depth or encoders were configured
"""
if (depth < 0) throw new IllegalArgumentException("no depth specified, use .depth(int)");
List<AtomEncoder> encoders = new ArrayList<AtomEncoder>();
// set is ordered
for (AtomEncoder encoder : encoderSet) {
encoders.add(encoder);
}
encoders.addAll(this.customEncoders);
// check if suppression of atoms is wanted - if not use a default value
// we also use the 'Basic' generator (see below)
boolean suppress = suppression != AtomSuppression.unsuppressed();
AtomEncoder encoder = new ConjugatedAtomEncoder(encoders);
SeedGenerator seeds = new SeedGenerator(encoder, suppression);
AbstractAtomHashGenerator simple = suppress ? new SuppressedAtomHashGenerator(seeds, new Xorshift(),
makeStereoEncoderFactory(), suppression, depth) : new BasicAtomHashGenerator(seeds, new Xorshift(),
makeStereoEncoderFactory(), depth);
// if there is a finder for checking equivalent vertices then the user
// wants to 'perturb' the hashed
if (equivSetFinder != null) {
return new PerturbedAtomHashGenerator(seeds, simple, new Xorshift(), makeStereoEncoderFactory(),
equivSetFinder, suppression);
} else {
// no equivalence set finder - just use the simple hash
return simple;
}
} | java | public AtomHashGenerator atomic() {
if (depth < 0) throw new IllegalArgumentException("no depth specified, use .depth(int)");
List<AtomEncoder> encoders = new ArrayList<AtomEncoder>();
// set is ordered
for (AtomEncoder encoder : encoderSet) {
encoders.add(encoder);
}
encoders.addAll(this.customEncoders);
// check if suppression of atoms is wanted - if not use a default value
// we also use the 'Basic' generator (see below)
boolean suppress = suppression != AtomSuppression.unsuppressed();
AtomEncoder encoder = new ConjugatedAtomEncoder(encoders);
SeedGenerator seeds = new SeedGenerator(encoder, suppression);
AbstractAtomHashGenerator simple = suppress ? new SuppressedAtomHashGenerator(seeds, new Xorshift(),
makeStereoEncoderFactory(), suppression, depth) : new BasicAtomHashGenerator(seeds, new Xorshift(),
makeStereoEncoderFactory(), depth);
// if there is a finder for checking equivalent vertices then the user
// wants to 'perturb' the hashed
if (equivSetFinder != null) {
return new PerturbedAtomHashGenerator(seeds, simple, new Xorshift(), makeStereoEncoderFactory(),
equivSetFinder, suppression);
} else {
// no equivalence set finder - just use the simple hash
return simple;
}
} | [
"public",
"AtomHashGenerator",
"atomic",
"(",
")",
"{",
"if",
"(",
"depth",
"<",
"0",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"no depth specified, use .depth(int)\"",
")",
";",
"List",
"<",
"AtomEncoder",
">",
"encoders",
"=",
"new",
"ArrayList",
"<",
"AtomEncoder",
">",
"(",
")",
";",
"// set is ordered",
"for",
"(",
"AtomEncoder",
"encoder",
":",
"encoderSet",
")",
"{",
"encoders",
".",
"add",
"(",
"encoder",
")",
";",
"}",
"encoders",
".",
"addAll",
"(",
"this",
".",
"customEncoders",
")",
";",
"// check if suppression of atoms is wanted - if not use a default value",
"// we also use the 'Basic' generator (see below)",
"boolean",
"suppress",
"=",
"suppression",
"!=",
"AtomSuppression",
".",
"unsuppressed",
"(",
")",
";",
"AtomEncoder",
"encoder",
"=",
"new",
"ConjugatedAtomEncoder",
"(",
"encoders",
")",
";",
"SeedGenerator",
"seeds",
"=",
"new",
"SeedGenerator",
"(",
"encoder",
",",
"suppression",
")",
";",
"AbstractAtomHashGenerator",
"simple",
"=",
"suppress",
"?",
"new",
"SuppressedAtomHashGenerator",
"(",
"seeds",
",",
"new",
"Xorshift",
"(",
")",
",",
"makeStereoEncoderFactory",
"(",
")",
",",
"suppression",
",",
"depth",
")",
":",
"new",
"BasicAtomHashGenerator",
"(",
"seeds",
",",
"new",
"Xorshift",
"(",
")",
",",
"makeStereoEncoderFactory",
"(",
")",
",",
"depth",
")",
";",
"// if there is a finder for checking equivalent vertices then the user",
"// wants to 'perturb' the hashed",
"if",
"(",
"equivSetFinder",
"!=",
"null",
")",
"{",
"return",
"new",
"PerturbedAtomHashGenerator",
"(",
"seeds",
",",
"simple",
",",
"new",
"Xorshift",
"(",
")",
",",
"makeStereoEncoderFactory",
"(",
")",
",",
"equivSetFinder",
",",
"suppression",
")",
";",
"}",
"else",
"{",
"// no equivalence set finder - just use the simple hash",
"return",
"simple",
";",
"}",
"}"
]
| Given the current configuration create an {@link AtomHashGenerator}.
@return instance of the generator
@throws IllegalArgumentException no depth or encoders were configured | [
"Given",
"the",
"current",
"configuration",
"create",
"an",
"{",
"@link",
"AtomHashGenerator",
"}",
"."
]
| train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/tool/hash/src/main/java/org/openscience/cdk/hash/HashGeneratorMaker.java#L317-L349 |
linkedin/PalDB | paldb/src/main/java/com/linkedin/paldb/api/Configuration.java | Configuration.getFloat | public float getFloat(String key, float defaultValue) {
"""
Gets the float value for <code>key</code> or <code>defaultValue</code> if not found.
@param key key to get value for
@param defaultValue default value if key not found
@return value or <code>defaultValue</code> if not found
"""
if (containsKey(key)) {
return Float.parseFloat(get(key));
} else {
return defaultValue;
}
} | java | public float getFloat(String key, float defaultValue) {
if (containsKey(key)) {
return Float.parseFloat(get(key));
} else {
return defaultValue;
}
} | [
"public",
"float",
"getFloat",
"(",
"String",
"key",
",",
"float",
"defaultValue",
")",
"{",
"if",
"(",
"containsKey",
"(",
"key",
")",
")",
"{",
"return",
"Float",
".",
"parseFloat",
"(",
"get",
"(",
"key",
")",
")",
";",
"}",
"else",
"{",
"return",
"defaultValue",
";",
"}",
"}"
]
| Gets the float value for <code>key</code> or <code>defaultValue</code> if not found.
@param key key to get value for
@param defaultValue default value if key not found
@return value or <code>defaultValue</code> if not found | [
"Gets",
"the",
"float",
"value",
"for",
"<code",
">",
"key<",
"/",
"code",
">",
"or",
"<code",
">",
"defaultValue<",
"/",
"code",
">",
"if",
"not",
"found",
"."
]
| train | https://github.com/linkedin/PalDB/blob/d05ccdd3f67855eb2675dbd82599f19aa7a9f650/paldb/src/main/java/com/linkedin/paldb/api/Configuration.java#L318-L324 |
janus-project/guava.janusproject.io | guava/src/com/google/common/util/concurrent/MoreExecutors.java | MoreExecutors.shutdownAndAwaitTermination | @Beta
public static boolean shutdownAndAwaitTermination(
ExecutorService service, long timeout, TimeUnit unit) {
"""
Shuts down the given executor gradually, first disabling new submissions and later cancelling
existing tasks.
<p>The method takes the following steps:
<ol>
<li>calls {@link ExecutorService#shutdown()}, disabling acceptance of new submitted tasks.
<li>waits for half of the specified timeout.
<li>if the timeout expires, it calls {@link ExecutorService#shutdownNow()}, cancelling
pending tasks and interrupting running tasks.
<li>waits for the other half of the specified timeout.
</ol>
<p>If, at any step of the process, the given executor is terminated or the calling thread is
interrupted, the method calls {@link ExecutorService#shutdownNow()}, cancelling
pending tasks and interrupting running tasks.
@param service the {@code ExecutorService} to shut down
@param timeout the maximum time to wait for the {@code ExecutorService} to terminate
@param unit the time unit of the timeout argument
@return {@code true} if the pool was terminated successfully, {@code false} if the
{@code ExecutorService} could not terminate <b>or</b> the thread running this method
is interrupted while waiting for the {@code ExecutorService} to terminate
@since 17.0
"""
checkNotNull(unit);
// Disable new tasks from being submitted
service.shutdown();
try {
long halfTimeoutNanos = TimeUnit.NANOSECONDS.convert(timeout, unit) / 2;
// Wait for half the duration of the timeout for existing tasks to terminate
if (!service.awaitTermination(halfTimeoutNanos, TimeUnit.NANOSECONDS)) {
// Cancel currently executing tasks
service.shutdownNow();
// Wait the other half of the timeout for tasks to respond to being cancelled
service.awaitTermination(halfTimeoutNanos, TimeUnit.NANOSECONDS);
}
} catch (InterruptedException ie) {
// Preserve interrupt status
Thread.currentThread().interrupt();
// (Re-)Cancel if current thread also interrupted
service.shutdownNow();
}
return service.isTerminated();
} | java | @Beta
public static boolean shutdownAndAwaitTermination(
ExecutorService service, long timeout, TimeUnit unit) {
checkNotNull(unit);
// Disable new tasks from being submitted
service.shutdown();
try {
long halfTimeoutNanos = TimeUnit.NANOSECONDS.convert(timeout, unit) / 2;
// Wait for half the duration of the timeout for existing tasks to terminate
if (!service.awaitTermination(halfTimeoutNanos, TimeUnit.NANOSECONDS)) {
// Cancel currently executing tasks
service.shutdownNow();
// Wait the other half of the timeout for tasks to respond to being cancelled
service.awaitTermination(halfTimeoutNanos, TimeUnit.NANOSECONDS);
}
} catch (InterruptedException ie) {
// Preserve interrupt status
Thread.currentThread().interrupt();
// (Re-)Cancel if current thread also interrupted
service.shutdownNow();
}
return service.isTerminated();
} | [
"@",
"Beta",
"public",
"static",
"boolean",
"shutdownAndAwaitTermination",
"(",
"ExecutorService",
"service",
",",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"{",
"checkNotNull",
"(",
"unit",
")",
";",
"// Disable new tasks from being submitted",
"service",
".",
"shutdown",
"(",
")",
";",
"try",
"{",
"long",
"halfTimeoutNanos",
"=",
"TimeUnit",
".",
"NANOSECONDS",
".",
"convert",
"(",
"timeout",
",",
"unit",
")",
"/",
"2",
";",
"// Wait for half the duration of the timeout for existing tasks to terminate",
"if",
"(",
"!",
"service",
".",
"awaitTermination",
"(",
"halfTimeoutNanos",
",",
"TimeUnit",
".",
"NANOSECONDS",
")",
")",
"{",
"// Cancel currently executing tasks",
"service",
".",
"shutdownNow",
"(",
")",
";",
"// Wait the other half of the timeout for tasks to respond to being cancelled",
"service",
".",
"awaitTermination",
"(",
"halfTimeoutNanos",
",",
"TimeUnit",
".",
"NANOSECONDS",
")",
";",
"}",
"}",
"catch",
"(",
"InterruptedException",
"ie",
")",
"{",
"// Preserve interrupt status",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"// (Re-)Cancel if current thread also interrupted",
"service",
".",
"shutdownNow",
"(",
")",
";",
"}",
"return",
"service",
".",
"isTerminated",
"(",
")",
";",
"}"
]
| Shuts down the given executor gradually, first disabling new submissions and later cancelling
existing tasks.
<p>The method takes the following steps:
<ol>
<li>calls {@link ExecutorService#shutdown()}, disabling acceptance of new submitted tasks.
<li>waits for half of the specified timeout.
<li>if the timeout expires, it calls {@link ExecutorService#shutdownNow()}, cancelling
pending tasks and interrupting running tasks.
<li>waits for the other half of the specified timeout.
</ol>
<p>If, at any step of the process, the given executor is terminated or the calling thread is
interrupted, the method calls {@link ExecutorService#shutdownNow()}, cancelling
pending tasks and interrupting running tasks.
@param service the {@code ExecutorService} to shut down
@param timeout the maximum time to wait for the {@code ExecutorService} to terminate
@param unit the time unit of the timeout argument
@return {@code true} if the pool was terminated successfully, {@code false} if the
{@code ExecutorService} could not terminate <b>or</b> the thread running this method
is interrupted while waiting for the {@code ExecutorService} to terminate
@since 17.0 | [
"Shuts",
"down",
"the",
"given",
"executor",
"gradually",
"first",
"disabling",
"new",
"submissions",
"and",
"later",
"cancelling",
"existing",
"tasks",
"."
]
| train | https://github.com/janus-project/guava.janusproject.io/blob/1c48fb672c9fdfddf276970570f703fa1115f588/guava/src/com/google/common/util/concurrent/MoreExecutors.java#L939-L961 |
joniles/mpxj | src/main/java/net/sf/mpxj/planner/PlannerWriter.java | PlannerWriter.getWorkingDayString | private String getWorkingDayString(ProjectCalendar mpxjCalendar, Day day) {
"""
Returns a flag represented as a String, indicating if
the supplied day is a working day.
@param mpxjCalendar MPXJ ProjectCalendar instance
@param day Day instance
@return boolean flag as a string
"""
String result = null;
net.sf.mpxj.DayType type = mpxjCalendar.getWorkingDay(day);
if (type == null)
{
type = net.sf.mpxj.DayType.DEFAULT;
}
switch (type)
{
case WORKING:
{
result = "0";
break;
}
case NON_WORKING:
{
result = "1";
break;
}
case DEFAULT:
{
result = "2";
break;
}
}
return (result);
} | java | private String getWorkingDayString(ProjectCalendar mpxjCalendar, Day day)
{
String result = null;
net.sf.mpxj.DayType type = mpxjCalendar.getWorkingDay(day);
if (type == null)
{
type = net.sf.mpxj.DayType.DEFAULT;
}
switch (type)
{
case WORKING:
{
result = "0";
break;
}
case NON_WORKING:
{
result = "1";
break;
}
case DEFAULT:
{
result = "2";
break;
}
}
return (result);
} | [
"private",
"String",
"getWorkingDayString",
"(",
"ProjectCalendar",
"mpxjCalendar",
",",
"Day",
"day",
")",
"{",
"String",
"result",
"=",
"null",
";",
"net",
".",
"sf",
".",
"mpxj",
".",
"DayType",
"type",
"=",
"mpxjCalendar",
".",
"getWorkingDay",
"(",
"day",
")",
";",
"if",
"(",
"type",
"==",
"null",
")",
"{",
"type",
"=",
"net",
".",
"sf",
".",
"mpxj",
".",
"DayType",
".",
"DEFAULT",
";",
"}",
"switch",
"(",
"type",
")",
"{",
"case",
"WORKING",
":",
"{",
"result",
"=",
"\"0\"",
";",
"break",
";",
"}",
"case",
"NON_WORKING",
":",
"{",
"result",
"=",
"\"1\"",
";",
"break",
";",
"}",
"case",
"DEFAULT",
":",
"{",
"result",
"=",
"\"2\"",
";",
"break",
";",
"}",
"}",
"return",
"(",
"result",
")",
";",
"}"
]
| Returns a flag represented as a String, indicating if
the supplied day is a working day.
@param mpxjCalendar MPXJ ProjectCalendar instance
@param day Day instance
@return boolean flag as a string | [
"Returns",
"a",
"flag",
"represented",
"as",
"a",
"String",
"indicating",
"if",
"the",
"supplied",
"day",
"is",
"a",
"working",
"day",
"."
]
| train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/planner/PlannerWriter.java#L661-L692 |
before/quality-check | modules/quality-check/src/main/java/net/sf/qualitycheck/ConditionalCheck.java | ConditionalCheck.isNumeric | @ArgumentsChecked
@Throws( {
"""
Ensures that a readable sequence of {@code char} values is numeric. Numeric arguments consist only of the
characters 0-9 and may start with 0 (compared to number arguments, which must be valid numbers - think of a bank
account number).
<p>
We recommend to use the overloaded method {@link Check#isNumeric(CharSequence, String)} and pass as second
argument the name of the parameter to enhance the exception message.
@param condition
condition must be {@code true}^ so that the check will be performed
@param value
a readable sequence of {@code char} values which must be a number
@throws IllegalNumberArgumentException
if the given argument {@code value} is no number
""" IllegalNullArgumentException.class, IllegalNumberArgumentException.class })
public static <T extends CharSequence> void isNumeric(final boolean condition, @Nonnull final T value) {
if (condition) {
Check.isNumeric(value);
}
} | java | @ArgumentsChecked
@Throws({ IllegalNullArgumentException.class, IllegalNumberArgumentException.class })
public static <T extends CharSequence> void isNumeric(final boolean condition, @Nonnull final T value) {
if (condition) {
Check.isNumeric(value);
}
} | [
"@",
"ArgumentsChecked",
"@",
"Throws",
"(",
"{",
"IllegalNullArgumentException",
".",
"class",
",",
"IllegalNumberArgumentException",
".",
"class",
"}",
")",
"public",
"static",
"<",
"T",
"extends",
"CharSequence",
">",
"void",
"isNumeric",
"(",
"final",
"boolean",
"condition",
",",
"@",
"Nonnull",
"final",
"T",
"value",
")",
"{",
"if",
"(",
"condition",
")",
"{",
"Check",
".",
"isNumeric",
"(",
"value",
")",
";",
"}",
"}"
]
| Ensures that a readable sequence of {@code char} values is numeric. Numeric arguments consist only of the
characters 0-9 and may start with 0 (compared to number arguments, which must be valid numbers - think of a bank
account number).
<p>
We recommend to use the overloaded method {@link Check#isNumeric(CharSequence, String)} and pass as second
argument the name of the parameter to enhance the exception message.
@param condition
condition must be {@code true}^ so that the check will be performed
@param value
a readable sequence of {@code char} values which must be a number
@throws IllegalNumberArgumentException
if the given argument {@code value} is no number | [
"Ensures",
"that",
"a",
"readable",
"sequence",
"of",
"{",
"@code",
"char",
"}",
"values",
"is",
"numeric",
".",
"Numeric",
"arguments",
"consist",
"only",
"of",
"the",
"characters",
"0",
"-",
"9",
"and",
"may",
"start",
"with",
"0",
"(",
"compared",
"to",
"number",
"arguments",
"which",
"must",
"be",
"valid",
"numbers",
"-",
"think",
"of",
"a",
"bank",
"account",
"number",
")",
"."
]
| train | https://github.com/before/quality-check/blob/a75c32c39434ddb1f89bece57acae0536724c15a/modules/quality-check/src/main/java/net/sf/qualitycheck/ConditionalCheck.java#L910-L916 |
rapidpro/expressions | java/src/main/java/io/rapidpro/expressions/dates/DateParser.java | DateParser.yearFrom2Digits | protected static int yearFrom2Digits(int shortYear, int currentYear) {
"""
Converts a relative 2-digit year to an absolute 4-digit year
@param shortYear the relative year
@return the absolute year
"""
if (shortYear < 100) {
shortYear += currentYear - (currentYear % 100);
if (Math.abs(shortYear - currentYear) >= 50) {
if (shortYear < currentYear) {
return shortYear + 100;
} else {
return shortYear - 100;
}
}
}
return shortYear;
} | java | protected static int yearFrom2Digits(int shortYear, int currentYear) {
if (shortYear < 100) {
shortYear += currentYear - (currentYear % 100);
if (Math.abs(shortYear - currentYear) >= 50) {
if (shortYear < currentYear) {
return shortYear + 100;
} else {
return shortYear - 100;
}
}
}
return shortYear;
} | [
"protected",
"static",
"int",
"yearFrom2Digits",
"(",
"int",
"shortYear",
",",
"int",
"currentYear",
")",
"{",
"if",
"(",
"shortYear",
"<",
"100",
")",
"{",
"shortYear",
"+=",
"currentYear",
"-",
"(",
"currentYear",
"%",
"100",
")",
";",
"if",
"(",
"Math",
".",
"abs",
"(",
"shortYear",
"-",
"currentYear",
")",
">=",
"50",
")",
"{",
"if",
"(",
"shortYear",
"<",
"currentYear",
")",
"{",
"return",
"shortYear",
"+",
"100",
";",
"}",
"else",
"{",
"return",
"shortYear",
"-",
"100",
";",
"}",
"}",
"}",
"return",
"shortYear",
";",
"}"
]
| Converts a relative 2-digit year to an absolute 4-digit year
@param shortYear the relative year
@return the absolute year | [
"Converts",
"a",
"relative",
"2",
"-",
"digit",
"year",
"to",
"an",
"absolute",
"4",
"-",
"digit",
"year"
]
| train | https://github.com/rapidpro/expressions/blob/b03d91ec58fc328960bce90ecb5fa49dcf467627/java/src/main/java/io/rapidpro/expressions/dates/DateParser.java#L369-L381 |
weld/core | impl/src/main/java/org/jboss/weld/util/collections/Iterables.java | Iterables.addAll | public static <T> boolean addAll(Collection<T> target, Iterable<? extends T> iterable) {
"""
Add all elements in the iterable to the collection.
@param target
@param iterable
@return true if the target was modified, false otherwise
"""
if (iterable instanceof Collection) {
return target.addAll((Collection<? extends T>) iterable);
}
return Iterators.addAll(target, iterable.iterator());
} | java | public static <T> boolean addAll(Collection<T> target, Iterable<? extends T> iterable) {
if (iterable instanceof Collection) {
return target.addAll((Collection<? extends T>) iterable);
}
return Iterators.addAll(target, iterable.iterator());
} | [
"public",
"static",
"<",
"T",
">",
"boolean",
"addAll",
"(",
"Collection",
"<",
"T",
">",
"target",
",",
"Iterable",
"<",
"?",
"extends",
"T",
">",
"iterable",
")",
"{",
"if",
"(",
"iterable",
"instanceof",
"Collection",
")",
"{",
"return",
"target",
".",
"addAll",
"(",
"(",
"Collection",
"<",
"?",
"extends",
"T",
">",
")",
"iterable",
")",
";",
"}",
"return",
"Iterators",
".",
"addAll",
"(",
"target",
",",
"iterable",
".",
"iterator",
"(",
")",
")",
";",
"}"
]
| Add all elements in the iterable to the collection.
@param target
@param iterable
@return true if the target was modified, false otherwise | [
"Add",
"all",
"elements",
"in",
"the",
"iterable",
"to",
"the",
"collection",
"."
]
| train | https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/util/collections/Iterables.java#L41-L46 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/VariableStack.java | VariableStack.getGlobalVariable | public XObject getGlobalVariable(XPathContext xctxt, final int index)
throws TransformerException {
"""
Get a global variable or parameter from the global stack frame.
@param xctxt The XPath context, which must be passed in order to
lazy evaluate variables.
@param index Global variable index relative to the global stack
frame bottom.
@return The value of the variable.
@throws TransformerException
"""
XObject val = _stackFrames[index];
// Lazy execution of variables.
if (val.getType() == XObject.CLASS_UNRESOLVEDVARIABLE)
return (_stackFrames[index] = val.execute(xctxt));
return val;
} | java | public XObject getGlobalVariable(XPathContext xctxt, final int index)
throws TransformerException
{
XObject val = _stackFrames[index];
// Lazy execution of variables.
if (val.getType() == XObject.CLASS_UNRESOLVEDVARIABLE)
return (_stackFrames[index] = val.execute(xctxt));
return val;
} | [
"public",
"XObject",
"getGlobalVariable",
"(",
"XPathContext",
"xctxt",
",",
"final",
"int",
"index",
")",
"throws",
"TransformerException",
"{",
"XObject",
"val",
"=",
"_stackFrames",
"[",
"index",
"]",
";",
"// Lazy execution of variables.",
"if",
"(",
"val",
".",
"getType",
"(",
")",
"==",
"XObject",
".",
"CLASS_UNRESOLVEDVARIABLE",
")",
"return",
"(",
"_stackFrames",
"[",
"index",
"]",
"=",
"val",
".",
"execute",
"(",
"xctxt",
")",
")",
";",
"return",
"val",
";",
"}"
]
| Get a global variable or parameter from the global stack frame.
@param xctxt The XPath context, which must be passed in order to
lazy evaluate variables.
@param index Global variable index relative to the global stack
frame bottom.
@return The value of the variable.
@throws TransformerException | [
"Get",
"a",
"global",
"variable",
"or",
"parameter",
"from",
"the",
"global",
"stack",
"frame",
"."
]
| train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/VariableStack.java#L444-L455 |
baidubce/bce-sdk-java | src/main/java/com/baidubce/services/subnet/SubnetClient.java | SubnetClient.createSubnet | public CreateSubnetResponse createSubnet(CreateSubnetRequest request)
throws BceClientException {
"""
Create a subnet with the specified options.
You must fill the field of clientToken,which is especially for keeping idempotent.
<p/>
@param request The request containing all options for creating subnet.
@return List of subnetId newly created
@throws BceClientException
"""
checkNotNull(request, "request should not be null.");
if (Strings.isNullOrEmpty(request.getClientToken())) {
request.setClientToken(this.generateClientToken());
}
checkStringNotEmpty(request.getName(), "name should not be empty");
checkStringNotEmpty(request.getCidr(), "cidr should not be empty");
checkStringNotEmpty(request.getZoneName(), "zone name should not be empty");
checkStringNotEmpty(request.getVpcId(), "vpc id should not be empty");
InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, SUBNET_PREFIX);
if (!Strings.isNullOrEmpty(request.getClientToken())) {
internalRequest.addParameter("clientToken", request.getClientToken());
}
fillPayload(internalRequest, request);
return invokeHttpClient(internalRequest, CreateSubnetResponse.class);
} | java | public CreateSubnetResponse createSubnet(CreateSubnetRequest request)
throws BceClientException {
checkNotNull(request, "request should not be null.");
if (Strings.isNullOrEmpty(request.getClientToken())) {
request.setClientToken(this.generateClientToken());
}
checkStringNotEmpty(request.getName(), "name should not be empty");
checkStringNotEmpty(request.getCidr(), "cidr should not be empty");
checkStringNotEmpty(request.getZoneName(), "zone name should not be empty");
checkStringNotEmpty(request.getVpcId(), "vpc id should not be empty");
InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, SUBNET_PREFIX);
if (!Strings.isNullOrEmpty(request.getClientToken())) {
internalRequest.addParameter("clientToken", request.getClientToken());
}
fillPayload(internalRequest, request);
return invokeHttpClient(internalRequest, CreateSubnetResponse.class);
} | [
"public",
"CreateSubnetResponse",
"createSubnet",
"(",
"CreateSubnetRequest",
"request",
")",
"throws",
"BceClientException",
"{",
"checkNotNull",
"(",
"request",
",",
"\"request should not be null.\"",
")",
";",
"if",
"(",
"Strings",
".",
"isNullOrEmpty",
"(",
"request",
".",
"getClientToken",
"(",
")",
")",
")",
"{",
"request",
".",
"setClientToken",
"(",
"this",
".",
"generateClientToken",
"(",
")",
")",
";",
"}",
"checkStringNotEmpty",
"(",
"request",
".",
"getName",
"(",
")",
",",
"\"name should not be empty\"",
")",
";",
"checkStringNotEmpty",
"(",
"request",
".",
"getCidr",
"(",
")",
",",
"\"cidr should not be empty\"",
")",
";",
"checkStringNotEmpty",
"(",
"request",
".",
"getZoneName",
"(",
")",
",",
"\"zone name should not be empty\"",
")",
";",
"checkStringNotEmpty",
"(",
"request",
".",
"getVpcId",
"(",
")",
",",
"\"vpc id should not be empty\"",
")",
";",
"InternalRequest",
"internalRequest",
"=",
"this",
".",
"createRequest",
"(",
"request",
",",
"HttpMethodName",
".",
"POST",
",",
"SUBNET_PREFIX",
")",
";",
"if",
"(",
"!",
"Strings",
".",
"isNullOrEmpty",
"(",
"request",
".",
"getClientToken",
"(",
")",
")",
")",
"{",
"internalRequest",
".",
"addParameter",
"(",
"\"clientToken\"",
",",
"request",
".",
"getClientToken",
"(",
")",
")",
";",
"}",
"fillPayload",
"(",
"internalRequest",
",",
"request",
")",
";",
"return",
"invokeHttpClient",
"(",
"internalRequest",
",",
"CreateSubnetResponse",
".",
"class",
")",
";",
"}"
]
| Create a subnet with the specified options.
You must fill the field of clientToken,which is especially for keeping idempotent.
<p/>
@param request The request containing all options for creating subnet.
@return List of subnetId newly created
@throws BceClientException | [
"Create",
"a",
"subnet",
"with",
"the",
"specified",
"options",
".",
"You",
"must",
"fill",
"the",
"field",
"of",
"clientToken",
"which",
"is",
"especially",
"for",
"keeping",
"idempotent",
".",
"<p",
"/",
">"
]
| train | https://github.com/baidubce/bce-sdk-java/blob/f7140f28dd82121515c88ded7bfe769a37d0ec4a/src/main/java/com/baidubce/services/subnet/SubnetClient.java#L178-L195 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.