repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
sequencelengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
sequencelengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
Azure/azure-sdk-for-java | cognitiveservices/data-plane/vision/computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/implementation/ComputerVisionImpl.java | ComputerVisionImpl.recognizeText | public void recognizeText(String url, TextRecognitionMode mode) {
"""
Recognize Text operation. When you use the Recognize Text interface, the response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for your Get Recognize Text Operation Result operation.
@param mode Type of text to recognize. Possible values include: 'Handwritten', 'Printed'
@param url Publicly reachable URL of an image
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ComputerVisionErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
"""
recognizeTextWithServiceResponseAsync(url, mode).toBlocking().single().body();
} | java | public void recognizeText(String url, TextRecognitionMode mode) {
recognizeTextWithServiceResponseAsync(url, mode).toBlocking().single().body();
} | [
"public",
"void",
"recognizeText",
"(",
"String",
"url",
",",
"TextRecognitionMode",
"mode",
")",
"{",
"recognizeTextWithServiceResponseAsync",
"(",
"url",
",",
"mode",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Recognize Text operation. When you use the Recognize Text interface, the response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for your Get Recognize Text Operation Result operation.
@param mode Type of text to recognize. Possible values include: 'Handwritten', 'Printed'
@param url Publicly reachable URL of an image
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ComputerVisionErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent | [
"Recognize",
"Text",
"operation",
".",
"When",
"you",
"use",
"the",
"Recognize",
"Text",
"interface",
"the",
"response",
"contains",
"a",
"field",
"called",
"Operation",
"-",
"Location",
".",
"The",
"Operation",
"-",
"Location",
"field",
"contains",
"the",
"URL",
"that",
"you",
"must",
"use",
"for",
"your",
"Get",
"Recognize",
"Text",
"Operation",
"Result",
"operation",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/vision/computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/implementation/ComputerVisionImpl.java#L1326-L1328 |
op4j/op4j | src/main/java/org/op4j/functions/FnCalendar.java | FnCalendar.toStr | public static final Function<Calendar,String> toStr(final DateStyle dateStyle, final TimeStyle timeStyle) {
"""
<p>
Converts the target Calendar into a String using the specified date ({@link DateStyle})
and time ({@link TimeStyle}) styles.
</p>
@param dateStyle the date style to be used
@param timeStyle the time style to be used
@return the String representation of the Calendar.
"""
return new ToString(dateStyle, timeStyle);
} | java | public static final Function<Calendar,String> toStr(final DateStyle dateStyle, final TimeStyle timeStyle) {
return new ToString(dateStyle, timeStyle);
} | [
"public",
"static",
"final",
"Function",
"<",
"Calendar",
",",
"String",
">",
"toStr",
"(",
"final",
"DateStyle",
"dateStyle",
",",
"final",
"TimeStyle",
"timeStyle",
")",
"{",
"return",
"new",
"ToString",
"(",
"dateStyle",
",",
"timeStyle",
")",
";",
"}"
] | <p>
Converts the target Calendar into a String using the specified date ({@link DateStyle})
and time ({@link TimeStyle}) styles.
</p>
@param dateStyle the date style to be used
@param timeStyle the time style to be used
@return the String representation of the Calendar. | [
"<p",
">",
"Converts",
"the",
"target",
"Calendar",
"into",
"a",
"String",
"using",
"the",
"specified",
"date",
"(",
"{",
"@link",
"DateStyle",
"}",
")",
"and",
"time",
"(",
"{",
"@link",
"TimeStyle",
"}",
")",
"styles",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/op4j/op4j/blob/b577596dfe462089d3dd169666defc6de7ad289a/src/main/java/org/op4j/functions/FnCalendar.java#L422-L424 |
hageldave/ImagingKit | ImagingKit_Fourier/src/main/java/hageldave/imagingkit/fourier/Fourier.java | Fourier.inverseTransform | public static ColorImg inverseTransform(ColorImg target, ComplexImg fourier, int channel) {
"""
Executes the inverse Fourier transforms on the specified {@link ComplexImg} that corresponds
to a specific channel of a {@link ColorImg} defined by the channel argument.
The resulting transform will be stored in the specified channel of the specified target.
If target is null a new ColorImg will be created and returned.
<p>
If the alpha channel was specified the specified target has to contain an alpha channel
({@link ColorImg#hasAlpha()}).
@param target image where the transform is stored to
@param fourier the ComplexImg that will be transformed and corresponds to the specified channel
@param channel the specified ComplexImg correspond to
@return the target img or a new ColorImg if target was null
@throws IllegalArgumentException <br>
if images are not of the same dimensions <br>
if alpha is specified as channel but specified target (if not null) is does not have an alpha channel
"""
Dimension dim = fourier.getDimension();
// if no target was specified create a new one
if(target == null) {
target = new ColorImg(dim, channel==ColorImg.channel_a);
}
// continue sanity checks
sanityCheckInverse_target(target, dim, channel);
// now do the transforms
if(fourier.getCurrentXshift() != 0 || fourier.getCurrentYshift() != 0){
ComplexValuedSampler complexIn = getSamplerForShiftedComplexImg(fourier);
RowMajorArrayAccessor realOut = new RowMajorArrayAccessor(target.getData()[channel], target.getWidth(), target.getHeight());
FFT.ifft(complexIn, realOut, realOut.getDimensions());
} else {
FFT.ifft( fourier.getDataReal(),
fourier.getDataImag(),
target.getData()[channel],
target.getWidth(), target.getHeight());
}
double scaling = 1.0/target.numValues();
ArrayUtils.scaleArray(target.getData()[channel], scaling);
return target;
} | java | public static ColorImg inverseTransform(ColorImg target, ComplexImg fourier, int channel) {
Dimension dim = fourier.getDimension();
// if no target was specified create a new one
if(target == null) {
target = new ColorImg(dim, channel==ColorImg.channel_a);
}
// continue sanity checks
sanityCheckInverse_target(target, dim, channel);
// now do the transforms
if(fourier.getCurrentXshift() != 0 || fourier.getCurrentYshift() != 0){
ComplexValuedSampler complexIn = getSamplerForShiftedComplexImg(fourier);
RowMajorArrayAccessor realOut = new RowMajorArrayAccessor(target.getData()[channel], target.getWidth(), target.getHeight());
FFT.ifft(complexIn, realOut, realOut.getDimensions());
} else {
FFT.ifft( fourier.getDataReal(),
fourier.getDataImag(),
target.getData()[channel],
target.getWidth(), target.getHeight());
}
double scaling = 1.0/target.numValues();
ArrayUtils.scaleArray(target.getData()[channel], scaling);
return target;
} | [
"public",
"static",
"ColorImg",
"inverseTransform",
"(",
"ColorImg",
"target",
",",
"ComplexImg",
"fourier",
",",
"int",
"channel",
")",
"{",
"Dimension",
"dim",
"=",
"fourier",
".",
"getDimension",
"(",
")",
";",
"// if no target was specified create a new one",
"if",
"(",
"target",
"==",
"null",
")",
"{",
"target",
"=",
"new",
"ColorImg",
"(",
"dim",
",",
"channel",
"==",
"ColorImg",
".",
"channel_a",
")",
";",
"}",
"// continue sanity checks",
"sanityCheckInverse_target",
"(",
"target",
",",
"dim",
",",
"channel",
")",
";",
"// now do the transforms",
"if",
"(",
"fourier",
".",
"getCurrentXshift",
"(",
")",
"!=",
"0",
"||",
"fourier",
".",
"getCurrentYshift",
"(",
")",
"!=",
"0",
")",
"{",
"ComplexValuedSampler",
"complexIn",
"=",
"getSamplerForShiftedComplexImg",
"(",
"fourier",
")",
";",
"RowMajorArrayAccessor",
"realOut",
"=",
"new",
"RowMajorArrayAccessor",
"(",
"target",
".",
"getData",
"(",
")",
"[",
"channel",
"]",
",",
"target",
".",
"getWidth",
"(",
")",
",",
"target",
".",
"getHeight",
"(",
")",
")",
";",
"FFT",
".",
"ifft",
"(",
"complexIn",
",",
"realOut",
",",
"realOut",
".",
"getDimensions",
"(",
")",
")",
";",
"}",
"else",
"{",
"FFT",
".",
"ifft",
"(",
"fourier",
".",
"getDataReal",
"(",
")",
",",
"fourier",
".",
"getDataImag",
"(",
")",
",",
"target",
".",
"getData",
"(",
")",
"[",
"channel",
"]",
",",
"target",
".",
"getWidth",
"(",
")",
",",
"target",
".",
"getHeight",
"(",
")",
")",
";",
"}",
"double",
"scaling",
"=",
"1.0",
"/",
"target",
".",
"numValues",
"(",
")",
";",
"ArrayUtils",
".",
"scaleArray",
"(",
"target",
".",
"getData",
"(",
")",
"[",
"channel",
"]",
",",
"scaling",
")",
";",
"return",
"target",
";",
"}"
] | Executes the inverse Fourier transforms on the specified {@link ComplexImg} that corresponds
to a specific channel of a {@link ColorImg} defined by the channel argument.
The resulting transform will be stored in the specified channel of the specified target.
If target is null a new ColorImg will be created and returned.
<p>
If the alpha channel was specified the specified target has to contain an alpha channel
({@link ColorImg#hasAlpha()}).
@param target image where the transform is stored to
@param fourier the ComplexImg that will be transformed and corresponds to the specified channel
@param channel the specified ComplexImg correspond to
@return the target img or a new ColorImg if target was null
@throws IllegalArgumentException <br>
if images are not of the same dimensions <br>
if alpha is specified as channel but specified target (if not null) is does not have an alpha channel | [
"Executes",
"the",
"inverse",
"Fourier",
"transforms",
"on",
"the",
"specified",
"{",
"@link",
"ComplexImg",
"}",
"that",
"corresponds",
"to",
"a",
"specific",
"channel",
"of",
"a",
"{",
"@link",
"ColorImg",
"}",
"defined",
"by",
"the",
"channel",
"argument",
".",
"The",
"resulting",
"transform",
"will",
"be",
"stored",
"in",
"the",
"specified",
"channel",
"of",
"the",
"specified",
"target",
".",
"If",
"target",
"is",
"null",
"a",
"new",
"ColorImg",
"will",
"be",
"created",
"and",
"returned",
".",
"<p",
">",
"If",
"the",
"alpha",
"channel",
"was",
"specified",
"the",
"specified",
"target",
"has",
"to",
"contain",
"an",
"alpha",
"channel",
"(",
"{",
"@link",
"ColorImg#hasAlpha",
"()",
"}",
")",
"."
] | train | https://github.com/hageldave/ImagingKit/blob/3837c7d550a12cf4dc5718b644ced94b97f52668/ImagingKit_Fourier/src/main/java/hageldave/imagingkit/fourier/Fourier.java#L139-L161 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/CompactDecimalDataCache.java | CompactDecimalDataCache.calculateDivisor | private static long calculateDivisor(long power10, int numZeros) {
"""
Calculate a divisor based on the magnitude and number of zeros in the
template string.
@param power10
@param numZeros
@return
"""
// We craft our divisor such that when we divide by it, we get a
// number with the same number of digits as zeros found in the
// plural variant templates. If our magnitude is 10000 and we have
// two 0's in our plural variants, then we want a divisor of 1000.
// Note that if we have 43560 which is of same magnitude as 10000.
// When we divide by 1000 we a quotient which rounds to 44 (2 digits)
long divisor = power10;
for (int i = 1; i < numZeros; i++) {
divisor /= 10;
}
return divisor;
} | java | private static long calculateDivisor(long power10, int numZeros) {
// We craft our divisor such that when we divide by it, we get a
// number with the same number of digits as zeros found in the
// plural variant templates. If our magnitude is 10000 and we have
// two 0's in our plural variants, then we want a divisor of 1000.
// Note that if we have 43560 which is of same magnitude as 10000.
// When we divide by 1000 we a quotient which rounds to 44 (2 digits)
long divisor = power10;
for (int i = 1; i < numZeros; i++) {
divisor /= 10;
}
return divisor;
} | [
"private",
"static",
"long",
"calculateDivisor",
"(",
"long",
"power10",
",",
"int",
"numZeros",
")",
"{",
"// We craft our divisor such that when we divide by it, we get a",
"// number with the same number of digits as zeros found in the",
"// plural variant templates. If our magnitude is 10000 and we have",
"// two 0's in our plural variants, then we want a divisor of 1000.",
"// Note that if we have 43560 which is of same magnitude as 10000.",
"// When we divide by 1000 we a quotient which rounds to 44 (2 digits)",
"long",
"divisor",
"=",
"power10",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"numZeros",
";",
"i",
"++",
")",
"{",
"divisor",
"/=",
"10",
";",
"}",
"return",
"divisor",
";",
"}"
] | Calculate a divisor based on the magnitude and number of zeros in the
template string.
@param power10
@param numZeros
@return | [
"Calculate",
"a",
"divisor",
"based",
"on",
"the",
"magnitude",
"and",
"number",
"of",
"zeros",
"in",
"the",
"template",
"string",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/CompactDecimalDataCache.java#L381-L393 |
groupon/monsoon | intf/src/main/java/com/groupon/lex/metrics/resolver/NamedResolverMap.java | NamedResolverMap.getBooleanOrDefault | public boolean getBooleanOrDefault(int key, boolean dfl) {
"""
Return the boolean value indicated by the given numeric key.
@param key The key of the value to return.
@param dfl The default value to return, if the key is absent.
@return The boolean value stored under the given key, or dfl.
@throws IllegalArgumentException if the value is present, but not a
boolean.
"""
Any3<Boolean, Integer, String> value = data.getOrDefault(Any2.<Integer, String>left(key), Any3.<Boolean, Integer, String>create1(dfl));
return value.get1().orElseThrow(() -> new IllegalArgumentException("expected boolean argument for param " + key));
} | java | public boolean getBooleanOrDefault(int key, boolean dfl) {
Any3<Boolean, Integer, String> value = data.getOrDefault(Any2.<Integer, String>left(key), Any3.<Boolean, Integer, String>create1(dfl));
return value.get1().orElseThrow(() -> new IllegalArgumentException("expected boolean argument for param " + key));
} | [
"public",
"boolean",
"getBooleanOrDefault",
"(",
"int",
"key",
",",
"boolean",
"dfl",
")",
"{",
"Any3",
"<",
"Boolean",
",",
"Integer",
",",
"String",
">",
"value",
"=",
"data",
".",
"getOrDefault",
"(",
"Any2",
".",
"<",
"Integer",
",",
"String",
">",
"left",
"(",
"key",
")",
",",
"Any3",
".",
"<",
"Boolean",
",",
"Integer",
",",
"String",
">",
"create1",
"(",
"dfl",
")",
")",
";",
"return",
"value",
".",
"get1",
"(",
")",
".",
"orElseThrow",
"(",
"(",
")",
"->",
"new",
"IllegalArgumentException",
"(",
"\"expected boolean argument for param \"",
"+",
"key",
")",
")",
";",
"}"
] | Return the boolean value indicated by the given numeric key.
@param key The key of the value to return.
@param dfl The default value to return, if the key is absent.
@return The boolean value stored under the given key, or dfl.
@throws IllegalArgumentException if the value is present, but not a
boolean. | [
"Return",
"the",
"boolean",
"value",
"indicated",
"by",
"the",
"given",
"numeric",
"key",
"."
] | train | https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/intf/src/main/java/com/groupon/lex/metrics/resolver/NamedResolverMap.java#L45-L48 |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/StateAssignmentOperation.java | StateAssignmentOperation.checkParallelismPreconditions | private static void checkParallelismPreconditions(OperatorState operatorState, ExecutionJobVertex executionJobVertex) {
"""
Verifies conditions in regards to parallelism and maxParallelism that must be met when restoring state.
@param operatorState state to restore
@param executionJobVertex task for which the state should be restored
"""
//----------------------------------------max parallelism preconditions-------------------------------------
if (operatorState.getMaxParallelism() < executionJobVertex.getParallelism()) {
throw new IllegalStateException("The state for task " + executionJobVertex.getJobVertexId() +
" can not be restored. The maximum parallelism (" + operatorState.getMaxParallelism() +
") of the restored state is lower than the configured parallelism (" + executionJobVertex.getParallelism() +
"). Please reduce the parallelism of the task to be lower or equal to the maximum parallelism."
);
}
// check that the number of key groups have not changed or if we need to override it to satisfy the restored state
if (operatorState.getMaxParallelism() != executionJobVertex.getMaxParallelism()) {
if (!executionJobVertex.isMaxParallelismConfigured()) {
// if the max parallelism was not explicitly specified by the user, we derive it from the state
LOG.debug("Overriding maximum parallelism for JobVertex {} from {} to {}",
executionJobVertex.getJobVertexId(), executionJobVertex.getMaxParallelism(), operatorState.getMaxParallelism());
executionJobVertex.setMaxParallelism(operatorState.getMaxParallelism());
} else {
// if the max parallelism was explicitly specified, we complain on mismatch
throw new IllegalStateException("The maximum parallelism (" +
operatorState.getMaxParallelism() + ") with which the latest " +
"checkpoint of the execution job vertex " + executionJobVertex +
" has been taken and the current maximum parallelism (" +
executionJobVertex.getMaxParallelism() + ") changed. This " +
"is currently not supported.");
}
}
} | java | private static void checkParallelismPreconditions(OperatorState operatorState, ExecutionJobVertex executionJobVertex) {
//----------------------------------------max parallelism preconditions-------------------------------------
if (operatorState.getMaxParallelism() < executionJobVertex.getParallelism()) {
throw new IllegalStateException("The state for task " + executionJobVertex.getJobVertexId() +
" can not be restored. The maximum parallelism (" + operatorState.getMaxParallelism() +
") of the restored state is lower than the configured parallelism (" + executionJobVertex.getParallelism() +
"). Please reduce the parallelism of the task to be lower or equal to the maximum parallelism."
);
}
// check that the number of key groups have not changed or if we need to override it to satisfy the restored state
if (operatorState.getMaxParallelism() != executionJobVertex.getMaxParallelism()) {
if (!executionJobVertex.isMaxParallelismConfigured()) {
// if the max parallelism was not explicitly specified by the user, we derive it from the state
LOG.debug("Overriding maximum parallelism for JobVertex {} from {} to {}",
executionJobVertex.getJobVertexId(), executionJobVertex.getMaxParallelism(), operatorState.getMaxParallelism());
executionJobVertex.setMaxParallelism(operatorState.getMaxParallelism());
} else {
// if the max parallelism was explicitly specified, we complain on mismatch
throw new IllegalStateException("The maximum parallelism (" +
operatorState.getMaxParallelism() + ") with which the latest " +
"checkpoint of the execution job vertex " + executionJobVertex +
" has been taken and the current maximum parallelism (" +
executionJobVertex.getMaxParallelism() + ") changed. This " +
"is currently not supported.");
}
}
} | [
"private",
"static",
"void",
"checkParallelismPreconditions",
"(",
"OperatorState",
"operatorState",
",",
"ExecutionJobVertex",
"executionJobVertex",
")",
"{",
"//----------------------------------------max parallelism preconditions-------------------------------------",
"if",
"(",
"operatorState",
".",
"getMaxParallelism",
"(",
")",
"<",
"executionJobVertex",
".",
"getParallelism",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"The state for task \"",
"+",
"executionJobVertex",
".",
"getJobVertexId",
"(",
")",
"+",
"\" can not be restored. The maximum parallelism (\"",
"+",
"operatorState",
".",
"getMaxParallelism",
"(",
")",
"+",
"\") of the restored state is lower than the configured parallelism (\"",
"+",
"executionJobVertex",
".",
"getParallelism",
"(",
")",
"+",
"\"). Please reduce the parallelism of the task to be lower or equal to the maximum parallelism.\"",
")",
";",
"}",
"// check that the number of key groups have not changed or if we need to override it to satisfy the restored state",
"if",
"(",
"operatorState",
".",
"getMaxParallelism",
"(",
")",
"!=",
"executionJobVertex",
".",
"getMaxParallelism",
"(",
")",
")",
"{",
"if",
"(",
"!",
"executionJobVertex",
".",
"isMaxParallelismConfigured",
"(",
")",
")",
"{",
"// if the max parallelism was not explicitly specified by the user, we derive it from the state",
"LOG",
".",
"debug",
"(",
"\"Overriding maximum parallelism for JobVertex {} from {} to {}\"",
",",
"executionJobVertex",
".",
"getJobVertexId",
"(",
")",
",",
"executionJobVertex",
".",
"getMaxParallelism",
"(",
")",
",",
"operatorState",
".",
"getMaxParallelism",
"(",
")",
")",
";",
"executionJobVertex",
".",
"setMaxParallelism",
"(",
"operatorState",
".",
"getMaxParallelism",
"(",
")",
")",
";",
"}",
"else",
"{",
"// if the max parallelism was explicitly specified, we complain on mismatch",
"throw",
"new",
"IllegalStateException",
"(",
"\"The maximum parallelism (\"",
"+",
"operatorState",
".",
"getMaxParallelism",
"(",
")",
"+",
"\") with which the latest \"",
"+",
"\"checkpoint of the execution job vertex \"",
"+",
"executionJobVertex",
"+",
"\" has been taken and the current maximum parallelism (\"",
"+",
"executionJobVertex",
".",
"getMaxParallelism",
"(",
")",
"+",
"\") changed. This \"",
"+",
"\"is currently not supported.\"",
")",
";",
"}",
"}",
"}"
] | Verifies conditions in regards to parallelism and maxParallelism that must be met when restoring state.
@param operatorState state to restore
@param executionJobVertex task for which the state should be restored | [
"Verifies",
"conditions",
"in",
"regards",
"to",
"parallelism",
"and",
"maxParallelism",
"that",
"must",
"be",
"met",
"when",
"restoring",
"state",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/StateAssignmentOperation.java#L510-L541 |
lucee/Lucee | core/src/main/java/lucee/commons/io/SystemUtil.java | SystemUtil.getSystemPropOrEnvVar | public static String getSystemPropOrEnvVar(String name, String defaultValue) {
"""
returns a system setting by either a Java property name or a System environment variable
@param name - either a lowercased Java property name (e.g. lucee.controller.disabled) or an
UPPERCASED Environment variable name ((e.g. LUCEE_CONTROLLER_DISABLED))
@param defaultValue - value to return if the neither the property nor the environment setting was
found
@return - the value of the property referenced by propOrEnv or the defaultValue if not found
"""
// env
String value = System.getenv(name);
if (!StringUtil.isEmpty(value)) return value;
// prop
value = System.getProperty(name);
if (!StringUtil.isEmpty(value)) return value;
// env 2
name = convertSystemPropToEnvVar(name);
value = System.getenv(name);
if (!StringUtil.isEmpty(value)) return value;
return defaultValue;
} | java | public static String getSystemPropOrEnvVar(String name, String defaultValue) {
// env
String value = System.getenv(name);
if (!StringUtil.isEmpty(value)) return value;
// prop
value = System.getProperty(name);
if (!StringUtil.isEmpty(value)) return value;
// env 2
name = convertSystemPropToEnvVar(name);
value = System.getenv(name);
if (!StringUtil.isEmpty(value)) return value;
return defaultValue;
} | [
"public",
"static",
"String",
"getSystemPropOrEnvVar",
"(",
"String",
"name",
",",
"String",
"defaultValue",
")",
"{",
"// env",
"String",
"value",
"=",
"System",
".",
"getenv",
"(",
"name",
")",
";",
"if",
"(",
"!",
"StringUtil",
".",
"isEmpty",
"(",
"value",
")",
")",
"return",
"value",
";",
"// prop",
"value",
"=",
"System",
".",
"getProperty",
"(",
"name",
")",
";",
"if",
"(",
"!",
"StringUtil",
".",
"isEmpty",
"(",
"value",
")",
")",
"return",
"value",
";",
"// env 2",
"name",
"=",
"convertSystemPropToEnvVar",
"(",
"name",
")",
";",
"value",
"=",
"System",
".",
"getenv",
"(",
"name",
")",
";",
"if",
"(",
"!",
"StringUtil",
".",
"isEmpty",
"(",
"value",
")",
")",
"return",
"value",
";",
"return",
"defaultValue",
";",
"}"
] | returns a system setting by either a Java property name or a System environment variable
@param name - either a lowercased Java property name (e.g. lucee.controller.disabled) or an
UPPERCASED Environment variable name ((e.g. LUCEE_CONTROLLER_DISABLED))
@param defaultValue - value to return if the neither the property nor the environment setting was
found
@return - the value of the property referenced by propOrEnv or the defaultValue if not found | [
"returns",
"a",
"system",
"setting",
"by",
"either",
"a",
"Java",
"property",
"name",
"or",
"a",
"System",
"environment",
"variable"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/commons/io/SystemUtil.java#L1165-L1180 |
apache/groovy | subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java | Sql.executeInsert | public List<GroovyRowResult> executeInsert(Map params, String sql, List<String> keyColumnNames) throws SQLException {
"""
A variant of {@link #executeInsert(String, List, List)}
useful when providing the named parameters as named arguments.
This variant allows you to receive the values of any auto-generated columns,
such as an autoincrement ID field (or fields) when you know the column name(s) of the ID field(s).
@param params a map containing the named parameters
@param sql The SQL statement to execute
@param keyColumnNames a list of column names indicating the columns that should be returned from the
inserted row or rows (some drivers may be case sensitive, e.g. may require uppercase names)
@return A list of the auto-generated row results for each inserted row (typically auto-generated keys)
@throws SQLException if a database access error occurs
@see Connection#prepareStatement(String, String[])
@since 2.3.2
"""
return executeInsert(sql, singletonList(params), keyColumnNames);
} | java | public List<GroovyRowResult> executeInsert(Map params, String sql, List<String> keyColumnNames) throws SQLException {
return executeInsert(sql, singletonList(params), keyColumnNames);
} | [
"public",
"List",
"<",
"GroovyRowResult",
">",
"executeInsert",
"(",
"Map",
"params",
",",
"String",
"sql",
",",
"List",
"<",
"String",
">",
"keyColumnNames",
")",
"throws",
"SQLException",
"{",
"return",
"executeInsert",
"(",
"sql",
",",
"singletonList",
"(",
"params",
")",
",",
"keyColumnNames",
")",
";",
"}"
] | A variant of {@link #executeInsert(String, List, List)}
useful when providing the named parameters as named arguments.
This variant allows you to receive the values of any auto-generated columns,
such as an autoincrement ID field (or fields) when you know the column name(s) of the ID field(s).
@param params a map containing the named parameters
@param sql The SQL statement to execute
@param keyColumnNames a list of column names indicating the columns that should be returned from the
inserted row or rows (some drivers may be case sensitive, e.g. may require uppercase names)
@return A list of the auto-generated row results for each inserted row (typically auto-generated keys)
@throws SQLException if a database access error occurs
@see Connection#prepareStatement(String, String[])
@since 2.3.2 | [
"A",
"variant",
"of",
"{",
"@link",
"#executeInsert",
"(",
"String",
"List",
"List",
")",
"}",
"useful",
"when",
"providing",
"the",
"named",
"parameters",
"as",
"named",
"arguments",
".",
"This",
"variant",
"allows",
"you",
"to",
"receive",
"the",
"values",
"of",
"any",
"auto",
"-",
"generated",
"columns",
"such",
"as",
"an",
"autoincrement",
"ID",
"field",
"(",
"or",
"fields",
")",
"when",
"you",
"know",
"the",
"column",
"name",
"(",
"s",
")",
"of",
"the",
"ID",
"field",
"(",
"s",
")",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java#L2736-L2738 |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/odmg/locking/ReadCommittedStrategy.java | ReadCommittedStrategy.checkWrite | public boolean checkWrite(TransactionImpl tx, Object obj) {
"""
checks whether the specified Object obj is write-locked by Transaction tx.
@param tx the transaction
@param obj the Object to be checked
@return true if lock exists, else false
"""
LockEntry writer = getWriter(obj);
if (writer == null)
return false;
else if (writer.isOwnedBy(tx))
return true;
else
return false;
} | java | public boolean checkWrite(TransactionImpl tx, Object obj)
{
LockEntry writer = getWriter(obj);
if (writer == null)
return false;
else if (writer.isOwnedBy(tx))
return true;
else
return false;
} | [
"public",
"boolean",
"checkWrite",
"(",
"TransactionImpl",
"tx",
",",
"Object",
"obj",
")",
"{",
"LockEntry",
"writer",
"=",
"getWriter",
"(",
"obj",
")",
";",
"if",
"(",
"writer",
"==",
"null",
")",
"return",
"false",
";",
"else",
"if",
"(",
"writer",
".",
"isOwnedBy",
"(",
"tx",
")",
")",
"return",
"true",
";",
"else",
"return",
"false",
";",
"}"
] | checks whether the specified Object obj is write-locked by Transaction tx.
@param tx the transaction
@param obj the Object to be checked
@return true if lock exists, else false | [
"checks",
"whether",
"the",
"specified",
"Object",
"obj",
"is",
"write",
"-",
"locked",
"by",
"Transaction",
"tx",
"."
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/odmg/locking/ReadCommittedStrategy.java#L176-L185 |
pravega/pravega | controller/src/main/java/io/pravega/controller/metrics/StreamMetrics.java | StreamMetrics.createStream | public void createStream(String scope, String streamName, int minNumSegments, Duration latency) {
"""
This method increments the global and Stream-specific counters of Stream creations, initializes other
stream-specific metrics and reports the latency of the operation.
@param scope Scope.
@param streamName Name of the Stream.
@param minNumSegments Initial number of segments for the Stream.
@param latency Latency of the createStream operation.
"""
DYNAMIC_LOGGER.incCounterValue(CREATE_STREAM, 1);
DYNAMIC_LOGGER.reportGaugeValue(OPEN_TRANSACTIONS, 0, streamTags(scope, streamName));
DYNAMIC_LOGGER.reportGaugeValue(SEGMENTS_COUNT, minNumSegments, streamTags(scope, streamName));
DYNAMIC_LOGGER.incCounterValue(SEGMENTS_SPLITS, 0, streamTags(scope, streamName));
DYNAMIC_LOGGER.incCounterValue(SEGMENTS_MERGES, 0, streamTags(scope, streamName));
createStreamLatency.reportSuccessValue(latency.toMillis());
} | java | public void createStream(String scope, String streamName, int minNumSegments, Duration latency) {
DYNAMIC_LOGGER.incCounterValue(CREATE_STREAM, 1);
DYNAMIC_LOGGER.reportGaugeValue(OPEN_TRANSACTIONS, 0, streamTags(scope, streamName));
DYNAMIC_LOGGER.reportGaugeValue(SEGMENTS_COUNT, minNumSegments, streamTags(scope, streamName));
DYNAMIC_LOGGER.incCounterValue(SEGMENTS_SPLITS, 0, streamTags(scope, streamName));
DYNAMIC_LOGGER.incCounterValue(SEGMENTS_MERGES, 0, streamTags(scope, streamName));
createStreamLatency.reportSuccessValue(latency.toMillis());
} | [
"public",
"void",
"createStream",
"(",
"String",
"scope",
",",
"String",
"streamName",
",",
"int",
"minNumSegments",
",",
"Duration",
"latency",
")",
"{",
"DYNAMIC_LOGGER",
".",
"incCounterValue",
"(",
"CREATE_STREAM",
",",
"1",
")",
";",
"DYNAMIC_LOGGER",
".",
"reportGaugeValue",
"(",
"OPEN_TRANSACTIONS",
",",
"0",
",",
"streamTags",
"(",
"scope",
",",
"streamName",
")",
")",
";",
"DYNAMIC_LOGGER",
".",
"reportGaugeValue",
"(",
"SEGMENTS_COUNT",
",",
"minNumSegments",
",",
"streamTags",
"(",
"scope",
",",
"streamName",
")",
")",
";",
"DYNAMIC_LOGGER",
".",
"incCounterValue",
"(",
"SEGMENTS_SPLITS",
",",
"0",
",",
"streamTags",
"(",
"scope",
",",
"streamName",
")",
")",
";",
"DYNAMIC_LOGGER",
".",
"incCounterValue",
"(",
"SEGMENTS_MERGES",
",",
"0",
",",
"streamTags",
"(",
"scope",
",",
"streamName",
")",
")",
";",
"createStreamLatency",
".",
"reportSuccessValue",
"(",
"latency",
".",
"toMillis",
"(",
")",
")",
";",
"}"
] | This method increments the global and Stream-specific counters of Stream creations, initializes other
stream-specific metrics and reports the latency of the operation.
@param scope Scope.
@param streamName Name of the Stream.
@param minNumSegments Initial number of segments for the Stream.
@param latency Latency of the createStream operation. | [
"This",
"method",
"increments",
"the",
"global",
"and",
"Stream",
"-",
"specific",
"counters",
"of",
"Stream",
"creations",
"initializes",
"other",
"stream",
"-",
"specific",
"metrics",
"and",
"reports",
"the",
"latency",
"of",
"the",
"operation",
"."
] | train | https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/controller/src/main/java/io/pravega/controller/metrics/StreamMetrics.java#L58-L66 |
Azure/azure-sdk-for-java | keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java | KeyVaultClientBaseImpl.updateCertificateIssuerAsync | public Observable<IssuerBundle> updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName) {
"""
Updates the specified certificate issuer.
The UpdateCertificateIssuer operation performs an update on the specified certificate issuer entity. This operation requires the certificates/setissuers permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param issuerName The name of the issuer.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the IssuerBundle object
"""
return updateCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName).map(new Func1<ServiceResponse<IssuerBundle>, IssuerBundle>() {
@Override
public IssuerBundle call(ServiceResponse<IssuerBundle> response) {
return response.body();
}
});
} | java | public Observable<IssuerBundle> updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName) {
return updateCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName).map(new Func1<ServiceResponse<IssuerBundle>, IssuerBundle>() {
@Override
public IssuerBundle call(ServiceResponse<IssuerBundle> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"IssuerBundle",
">",
"updateCertificateIssuerAsync",
"(",
"String",
"vaultBaseUrl",
",",
"String",
"issuerName",
")",
"{",
"return",
"updateCertificateIssuerWithServiceResponseAsync",
"(",
"vaultBaseUrl",
",",
"issuerName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"IssuerBundle",
">",
",",
"IssuerBundle",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"IssuerBundle",
"call",
"(",
"ServiceResponse",
"<",
"IssuerBundle",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Updates the specified certificate issuer.
The UpdateCertificateIssuer operation performs an update on the specified certificate issuer entity. This operation requires the certificates/setissuers permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param issuerName The name of the issuer.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the IssuerBundle object | [
"Updates",
"the",
"specified",
"certificate",
"issuer",
".",
"The",
"UpdateCertificateIssuer",
"operation",
"performs",
"an",
"update",
"on",
"the",
"specified",
"certificate",
"issuer",
"entity",
".",
"This",
"operation",
"requires",
"the",
"certificates",
"/",
"setissuers",
"permission",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java#L6137-L6144 |
lucee/Lucee | core/src/main/java/lucee/commons/lang/StringUtil.java | StringUtil.replaceMap | public static String replaceMap(String input, Map map, boolean ignoreCase) throws PageException {
"""
this is the public entry point for the replaceMap() method
@param input - the string on which the replacements should be performed.
@param map - a java.util.Map with key/value pairs where the key is the substring to find and the
value is the substring with which to replace the matched key
@param ignoreCase - if true then matches will not be case sensitive
@return
@throws PageException
"""
return replaceMap(input, map, ignoreCase, true);
} | java | public static String replaceMap(String input, Map map, boolean ignoreCase) throws PageException {
return replaceMap(input, map, ignoreCase, true);
} | [
"public",
"static",
"String",
"replaceMap",
"(",
"String",
"input",
",",
"Map",
"map",
",",
"boolean",
"ignoreCase",
")",
"throws",
"PageException",
"{",
"return",
"replaceMap",
"(",
"input",
",",
"map",
",",
"ignoreCase",
",",
"true",
")",
";",
"}"
] | this is the public entry point for the replaceMap() method
@param input - the string on which the replacements should be performed.
@param map - a java.util.Map with key/value pairs where the key is the substring to find and the
value is the substring with which to replace the matched key
@param ignoreCase - if true then matches will not be case sensitive
@return
@throws PageException | [
"this",
"is",
"the",
"public",
"entry",
"point",
"for",
"the",
"replaceMap",
"()",
"method"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/commons/lang/StringUtil.java#L1324-L1327 |
javagl/ND | nd-tuples/src/main/java/de/javagl/nd/tuples/d/DoubleTupleCollections.java | DoubleTupleCollections.getSize | private static int getSize(Tuple t, Iterable<? extends Tuple> tuples) {
"""
Returns the size of the given tuple. If the given tuple is
<code>null</code>, then the size of the first tuple of the
given sequence is returned. If this first tuple is <code>null</code>,
or the given sequence is empty, then -1 is returned.
@param t The tuple
@param tuples The tuples
@return The size
"""
if (t != null)
{
return t.getSize();
}
Iterator<? extends Tuple> iterator = tuples.iterator();
if (iterator.hasNext())
{
Tuple first = iterator.next();
if (first != null)
{
return first.getSize();
}
}
return -1;
} | java | private static int getSize(Tuple t, Iterable<? extends Tuple> tuples)
{
if (t != null)
{
return t.getSize();
}
Iterator<? extends Tuple> iterator = tuples.iterator();
if (iterator.hasNext())
{
Tuple first = iterator.next();
if (first != null)
{
return first.getSize();
}
}
return -1;
} | [
"private",
"static",
"int",
"getSize",
"(",
"Tuple",
"t",
",",
"Iterable",
"<",
"?",
"extends",
"Tuple",
">",
"tuples",
")",
"{",
"if",
"(",
"t",
"!=",
"null",
")",
"{",
"return",
"t",
".",
"getSize",
"(",
")",
";",
"}",
"Iterator",
"<",
"?",
"extends",
"Tuple",
">",
"iterator",
"=",
"tuples",
".",
"iterator",
"(",
")",
";",
"if",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"Tuple",
"first",
"=",
"iterator",
".",
"next",
"(",
")",
";",
"if",
"(",
"first",
"!=",
"null",
")",
"{",
"return",
"first",
".",
"getSize",
"(",
")",
";",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] | Returns the size of the given tuple. If the given tuple is
<code>null</code>, then the size of the first tuple of the
given sequence is returned. If this first tuple is <code>null</code>,
or the given sequence is empty, then -1 is returned.
@param t The tuple
@param tuples The tuples
@return The size | [
"Returns",
"the",
"size",
"of",
"the",
"given",
"tuple",
".",
"If",
"the",
"given",
"tuple",
"is",
"<code",
">",
"null<",
"/",
"code",
">",
"then",
"the",
"size",
"of",
"the",
"first",
"tuple",
"of",
"the",
"given",
"sequence",
"is",
"returned",
".",
"If",
"this",
"first",
"tuple",
"is",
"<code",
">",
"null<",
"/",
"code",
">",
"or",
"the",
"given",
"sequence",
"is",
"empty",
"then",
"-",
"1",
"is",
"returned",
"."
] | train | https://github.com/javagl/ND/blob/bcb655aaf5fc88af6194f73a27cca079186ff559/nd-tuples/src/main/java/de/javagl/nd/tuples/d/DoubleTupleCollections.java#L290-L306 |
apache/flink | flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/util/SegmentsUtil.java | SegmentsUtil.setShort | public static void setShort(MemorySegment[] segments, int offset, short value) {
"""
set short from segments.
@param segments target segments.
@param offset value offset.
"""
if (inFirstSegment(segments, offset, 2)) {
segments[0].putShort(offset, value);
} else {
setShortMultiSegments(segments, offset, value);
}
} | java | public static void setShort(MemorySegment[] segments, int offset, short value) {
if (inFirstSegment(segments, offset, 2)) {
segments[0].putShort(offset, value);
} else {
setShortMultiSegments(segments, offset, value);
}
} | [
"public",
"static",
"void",
"setShort",
"(",
"MemorySegment",
"[",
"]",
"segments",
",",
"int",
"offset",
",",
"short",
"value",
")",
"{",
"if",
"(",
"inFirstSegment",
"(",
"segments",
",",
"offset",
",",
"2",
")",
")",
"{",
"segments",
"[",
"0",
"]",
".",
"putShort",
"(",
"offset",
",",
"value",
")",
";",
"}",
"else",
"{",
"setShortMultiSegments",
"(",
"segments",
",",
"offset",
",",
"value",
")",
";",
"}",
"}"
] | set short from segments.
@param segments target segments.
@param offset value offset. | [
"set",
"short",
"from",
"segments",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/util/SegmentsUtil.java#L826-L832 |
pierre/serialization | hadoop/src/main/java/com/ning/metrics/serialization/hadoop/pig/SmileStorage.java | SmileStorage.prepareToRead | @Override
public void prepareToRead(final RecordReader reader, final PigSplit split) throws IOException {
"""
Initializes LoadFunc for reading data. This will be called during execution
before any calls to getNext. The RecordReader needs to be passed here because
it has been instantiated for a particular InputSplit.
@param reader {@link org.apache.hadoop.mapreduce.RecordReader} to be used by this instance of the LoadFunc
@param split The input {@link org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigSplit} to process
@throws java.io.IOException if there is an exception during initialization
"""
this.reader = reader;
this.split = split;
} | java | @Override
public void prepareToRead(final RecordReader reader, final PigSplit split) throws IOException
{
this.reader = reader;
this.split = split;
} | [
"@",
"Override",
"public",
"void",
"prepareToRead",
"(",
"final",
"RecordReader",
"reader",
",",
"final",
"PigSplit",
"split",
")",
"throws",
"IOException",
"{",
"this",
".",
"reader",
"=",
"reader",
";",
"this",
".",
"split",
"=",
"split",
";",
"}"
] | Initializes LoadFunc for reading data. This will be called during execution
before any calls to getNext. The RecordReader needs to be passed here because
it has been instantiated for a particular InputSplit.
@param reader {@link org.apache.hadoop.mapreduce.RecordReader} to be used by this instance of the LoadFunc
@param split The input {@link org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigSplit} to process
@throws java.io.IOException if there is an exception during initialization | [
"Initializes",
"LoadFunc",
"for",
"reading",
"data",
".",
"This",
"will",
"be",
"called",
"during",
"execution",
"before",
"any",
"calls",
"to",
"getNext",
".",
"The",
"RecordReader",
"needs",
"to",
"be",
"passed",
"here",
"because",
"it",
"has",
"been",
"instantiated",
"for",
"a",
"particular",
"InputSplit",
"."
] | train | https://github.com/pierre/serialization/blob/b15b7c749ba78bfe94dce8fc22f31b30b2e6830b/hadoop/src/main/java/com/ning/metrics/serialization/hadoop/pig/SmileStorage.java#L138-L143 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/ApplicationGatewaysInner.java | ApplicationGatewaysInner.beginUpdateTags | public ApplicationGatewayInner beginUpdateTags(String resourceGroupName, String applicationGatewayName) {
"""
Updates the specified application gateway tags.
@param resourceGroupName The name of the resource group.
@param applicationGatewayName The name of the application gateway.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the ApplicationGatewayInner object if successful.
"""
return beginUpdateTagsWithServiceResponseAsync(resourceGroupName, applicationGatewayName).toBlocking().single().body();
} | java | public ApplicationGatewayInner beginUpdateTags(String resourceGroupName, String applicationGatewayName) {
return beginUpdateTagsWithServiceResponseAsync(resourceGroupName, applicationGatewayName).toBlocking().single().body();
} | [
"public",
"ApplicationGatewayInner",
"beginUpdateTags",
"(",
"String",
"resourceGroupName",
",",
"String",
"applicationGatewayName",
")",
"{",
"return",
"beginUpdateTagsWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"applicationGatewayName",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Updates the specified application gateway tags.
@param resourceGroupName The name of the resource group.
@param applicationGatewayName The name of the application gateway.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the ApplicationGatewayInner object if successful. | [
"Updates",
"the",
"specified",
"application",
"gateway",
"tags",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/ApplicationGatewaysInner.java#L716-L718 |
padrig64/ValidationFramework | validationframework-swing/src/main/java/com/google/code/validationframework/swing/decoration/utils/IconUtils.java | IconUtils.loadImageIcon | public static ImageIcon loadImageIcon(final String iconName, final Class<?> clazz) {
"""
Loads an image icon from a resource file.
@param iconName Name of the resource file to be loaded.
@param clazz Class for which the resource exists.
@return Image icon if it could be loaded, null otherwise.
"""
ImageIcon icon = null;
if (iconName != null) {
final URL iconResource = clazz.getResource(iconName);
if (iconResource == null) {
LOGGER.error("Icon could not be loaded: '" + iconName);
icon = null;
} else {
icon = new ImageIcon(iconResource);
}
}
return icon;
} | java | public static ImageIcon loadImageIcon(final String iconName, final Class<?> clazz) {
ImageIcon icon = null;
if (iconName != null) {
final URL iconResource = clazz.getResource(iconName);
if (iconResource == null) {
LOGGER.error("Icon could not be loaded: '" + iconName);
icon = null;
} else {
icon = new ImageIcon(iconResource);
}
}
return icon;
} | [
"public",
"static",
"ImageIcon",
"loadImageIcon",
"(",
"final",
"String",
"iconName",
",",
"final",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"ImageIcon",
"icon",
"=",
"null",
";",
"if",
"(",
"iconName",
"!=",
"null",
")",
"{",
"final",
"URL",
"iconResource",
"=",
"clazz",
".",
"getResource",
"(",
"iconName",
")",
";",
"if",
"(",
"iconResource",
"==",
"null",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"Icon could not be loaded: '\"",
"+",
"iconName",
")",
";",
"icon",
"=",
"null",
";",
"}",
"else",
"{",
"icon",
"=",
"new",
"ImageIcon",
"(",
"iconResource",
")",
";",
"}",
"}",
"return",
"icon",
";",
"}"
] | Loads an image icon from a resource file.
@param iconName Name of the resource file to be loaded.
@param clazz Class for which the resource exists.
@return Image icon if it could be loaded, null otherwise. | [
"Loads",
"an",
"image",
"icon",
"from",
"a",
"resource",
"file",
"."
] | train | https://github.com/padrig64/ValidationFramework/blob/2dd3c7b3403993db366d24a927645f467ccd1dda/validationframework-swing/src/main/java/com/google/code/validationframework/swing/decoration/utils/IconUtils.java#L68-L82 |
goldmansachs/gs-collections | collections/src/main/java/com/gs/collections/impl/utility/Iterate.java | Iterate.detectIndex | public static <T> int detectIndex(Iterable<T> iterable, Predicate<? super T> predicate) {
"""
Searches for the first occurrence where the predicate evaluates to true, returns -1 if the predicate does not evaluate to true.
"""
if (iterable instanceof ArrayList<?>)
{
return ArrayListIterate.detectIndex((ArrayList<T>) iterable, predicate);
}
if (iterable instanceof List<?>)
{
return ListIterate.detectIndex((List<T>) iterable, predicate);
}
if (iterable != null)
{
return IterableIterate.detectIndex(iterable, predicate);
}
throw new IllegalArgumentException("Cannot perform detectIndex on null");
} | java | public static <T> int detectIndex(Iterable<T> iterable, Predicate<? super T> predicate)
{
if (iterable instanceof ArrayList<?>)
{
return ArrayListIterate.detectIndex((ArrayList<T>) iterable, predicate);
}
if (iterable instanceof List<?>)
{
return ListIterate.detectIndex((List<T>) iterable, predicate);
}
if (iterable != null)
{
return IterableIterate.detectIndex(iterable, predicate);
}
throw new IllegalArgumentException("Cannot perform detectIndex on null");
} | [
"public",
"static",
"<",
"T",
">",
"int",
"detectIndex",
"(",
"Iterable",
"<",
"T",
">",
"iterable",
",",
"Predicate",
"<",
"?",
"super",
"T",
">",
"predicate",
")",
"{",
"if",
"(",
"iterable",
"instanceof",
"ArrayList",
"<",
"?",
">",
")",
"{",
"return",
"ArrayListIterate",
".",
"detectIndex",
"(",
"(",
"ArrayList",
"<",
"T",
">",
")",
"iterable",
",",
"predicate",
")",
";",
"}",
"if",
"(",
"iterable",
"instanceof",
"List",
"<",
"?",
">",
")",
"{",
"return",
"ListIterate",
".",
"detectIndex",
"(",
"(",
"List",
"<",
"T",
">",
")",
"iterable",
",",
"predicate",
")",
";",
"}",
"if",
"(",
"iterable",
"!=",
"null",
")",
"{",
"return",
"IterableIterate",
".",
"detectIndex",
"(",
"iterable",
",",
"predicate",
")",
";",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Cannot perform detectIndex on null\"",
")",
";",
"}"
] | Searches for the first occurrence where the predicate evaluates to true, returns -1 if the predicate does not evaluate to true. | [
"Searches",
"for",
"the",
"first",
"occurrence",
"where",
"the",
"predicate",
"evaluates",
"to",
"true",
"returns",
"-",
"1",
"if",
"the",
"predicate",
"does",
"not",
"evaluate",
"to",
"true",
"."
] | train | https://github.com/goldmansachs/gs-collections/blob/fa8bf3e103689efa18bca2ab70203e71cde34b52/collections/src/main/java/com/gs/collections/impl/utility/Iterate.java#L2357-L2372 |
apache/fluo | modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java | Bytes.compareTo | @Override
public final int compareTo(Bytes other) {
"""
Compares this to the passed bytes, byte by byte, returning a negative, zero, or positive result
if the first sequence is less than, equal to, or greater than the second. The comparison is
performed starting with the first byte of each sequence, and proceeds until a pair of bytes
differs, or one sequence runs out of byte (is shorter). A shorter sequence is considered less
than a longer one.
@return comparison result
"""
if (this == other) {
return 0;
} else {
return compareToUnchecked(other.data, other.offset, other.length);
}
} | java | @Override
public final int compareTo(Bytes other) {
if (this == other) {
return 0;
} else {
return compareToUnchecked(other.data, other.offset, other.length);
}
} | [
"@",
"Override",
"public",
"final",
"int",
"compareTo",
"(",
"Bytes",
"other",
")",
"{",
"if",
"(",
"this",
"==",
"other",
")",
"{",
"return",
"0",
";",
"}",
"else",
"{",
"return",
"compareToUnchecked",
"(",
"other",
".",
"data",
",",
"other",
".",
"offset",
",",
"other",
".",
"length",
")",
";",
"}",
"}"
] | Compares this to the passed bytes, byte by byte, returning a negative, zero, or positive result
if the first sequence is less than, equal to, or greater than the second. The comparison is
performed starting with the first byte of each sequence, and proceeds until a pair of bytes
differs, or one sequence runs out of byte (is shorter). A shorter sequence is considered less
than a longer one.
@return comparison result | [
"Compares",
"this",
"to",
"the",
"passed",
"bytes",
"byte",
"by",
"byte",
"returning",
"a",
"negative",
"zero",
"or",
"positive",
"result",
"if",
"the",
"first",
"sequence",
"is",
"less",
"than",
"equal",
"to",
"or",
"greater",
"than",
"the",
"second",
".",
"The",
"comparison",
"is",
"performed",
"starting",
"with",
"the",
"first",
"byte",
"of",
"each",
"sequence",
"and",
"proceeds",
"until",
"a",
"pair",
"of",
"bytes",
"differs",
"or",
"one",
"sequence",
"runs",
"out",
"of",
"byte",
"(",
"is",
"shorter",
")",
".",
"A",
"shorter",
"sequence",
"is",
"considered",
"less",
"than",
"a",
"longer",
"one",
"."
] | train | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java#L198-L205 |
datastax/java-driver | core/src/main/java/com/datastax/oss/driver/internal/core/type/codec/registry/CachingCodecRegistry.java | CachingCodecRegistry.codecFor | protected <JavaTypeT> TypeCodec<JavaTypeT> codecFor(
GenericType<JavaTypeT> javaType, boolean isJavaCovariant) {
"""
Not exposed publicly, (isJavaCovariant=true) is only used for internal recursion
"""
LOG.trace(
"[{}] Looking up codec for Java type {} (covariant = {})",
logPrefix,
javaType,
isJavaCovariant);
for (TypeCodec<?> primitiveCodec : primitiveCodecs) {
if (matches(primitiveCodec, javaType, isJavaCovariant)) {
LOG.trace("[{}] Found matching primitive codec {}", logPrefix, primitiveCodec);
return uncheckedCast(primitiveCodec);
}
}
for (TypeCodec<?> userCodec : userCodecs) {
if (matches(userCodec, javaType, isJavaCovariant)) {
LOG.trace("[{}] Found matching user codec {}", logPrefix, userCodec);
return uncheckedCast(userCodec);
}
}
return uncheckedCast(getCachedCodec(null, javaType, isJavaCovariant));
} | java | protected <JavaTypeT> TypeCodec<JavaTypeT> codecFor(
GenericType<JavaTypeT> javaType, boolean isJavaCovariant) {
LOG.trace(
"[{}] Looking up codec for Java type {} (covariant = {})",
logPrefix,
javaType,
isJavaCovariant);
for (TypeCodec<?> primitiveCodec : primitiveCodecs) {
if (matches(primitiveCodec, javaType, isJavaCovariant)) {
LOG.trace("[{}] Found matching primitive codec {}", logPrefix, primitiveCodec);
return uncheckedCast(primitiveCodec);
}
}
for (TypeCodec<?> userCodec : userCodecs) {
if (matches(userCodec, javaType, isJavaCovariant)) {
LOG.trace("[{}] Found matching user codec {}", logPrefix, userCodec);
return uncheckedCast(userCodec);
}
}
return uncheckedCast(getCachedCodec(null, javaType, isJavaCovariant));
} | [
"protected",
"<",
"JavaTypeT",
">",
"TypeCodec",
"<",
"JavaTypeT",
">",
"codecFor",
"(",
"GenericType",
"<",
"JavaTypeT",
">",
"javaType",
",",
"boolean",
"isJavaCovariant",
")",
"{",
"LOG",
".",
"trace",
"(",
"\"[{}] Looking up codec for Java type {} (covariant = {})\"",
",",
"logPrefix",
",",
"javaType",
",",
"isJavaCovariant",
")",
";",
"for",
"(",
"TypeCodec",
"<",
"?",
">",
"primitiveCodec",
":",
"primitiveCodecs",
")",
"{",
"if",
"(",
"matches",
"(",
"primitiveCodec",
",",
"javaType",
",",
"isJavaCovariant",
")",
")",
"{",
"LOG",
".",
"trace",
"(",
"\"[{}] Found matching primitive codec {}\"",
",",
"logPrefix",
",",
"primitiveCodec",
")",
";",
"return",
"uncheckedCast",
"(",
"primitiveCodec",
")",
";",
"}",
"}",
"for",
"(",
"TypeCodec",
"<",
"?",
">",
"userCodec",
":",
"userCodecs",
")",
"{",
"if",
"(",
"matches",
"(",
"userCodec",
",",
"javaType",
",",
"isJavaCovariant",
")",
")",
"{",
"LOG",
".",
"trace",
"(",
"\"[{}] Found matching user codec {}\"",
",",
"logPrefix",
",",
"userCodec",
")",
";",
"return",
"uncheckedCast",
"(",
"userCodec",
")",
";",
"}",
"}",
"return",
"uncheckedCast",
"(",
"getCachedCodec",
"(",
"null",
",",
"javaType",
",",
"isJavaCovariant",
")",
")",
";",
"}"
] | Not exposed publicly, (isJavaCovariant=true) is only used for internal recursion | [
"Not",
"exposed",
"publicly",
"(",
"isJavaCovariant",
"=",
"true",
")",
"is",
"only",
"used",
"for",
"internal",
"recursion"
] | train | https://github.com/datastax/java-driver/blob/612a63f2525618e2020e86c9ad75ab37adba6132/core/src/main/java/com/datastax/oss/driver/internal/core/type/codec/registry/CachingCodecRegistry.java#L220-L240 |
Azure/azure-sdk-for-java | containerinstance/resource-manager/v2018_02_01_preview/src/main/java/com/microsoft/azure/management/containerinstance/v2018_02_01_preview/implementation/ContainerGroupsInner.java | ContainerGroupsInner.beginCreateOrUpdate | public ContainerGroupInner beginCreateOrUpdate(String resourceGroupName, String containerGroupName, ContainerGroupInner containerGroup) {
"""
Create or update container groups.
Create or update container groups with specified configurations.
@param resourceGroupName The name of the resource group.
@param containerGroupName The name of the container group.
@param containerGroup The properties of the container group to be created or updated.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the ContainerGroupInner object if successful.
"""
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, containerGroupName, containerGroup).toBlocking().single().body();
} | java | public ContainerGroupInner beginCreateOrUpdate(String resourceGroupName, String containerGroupName, ContainerGroupInner containerGroup) {
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, containerGroupName, containerGroup).toBlocking().single().body();
} | [
"public",
"ContainerGroupInner",
"beginCreateOrUpdate",
"(",
"String",
"resourceGroupName",
",",
"String",
"containerGroupName",
",",
"ContainerGroupInner",
"containerGroup",
")",
"{",
"return",
"beginCreateOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"containerGroupName",
",",
"containerGroup",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Create or update container groups.
Create or update container groups with specified configurations.
@param resourceGroupName The name of the resource group.
@param containerGroupName The name of the container group.
@param containerGroup The properties of the container group to be created or updated.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the ContainerGroupInner object if successful. | [
"Create",
"or",
"update",
"container",
"groups",
".",
"Create",
"or",
"update",
"container",
"groups",
"with",
"specified",
"configurations",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/containerinstance/resource-manager/v2018_02_01_preview/src/main/java/com/microsoft/azure/management/containerinstance/v2018_02_01_preview/implementation/ContainerGroupsInner.java#L522-L524 |
hazelcast/hazelcast | hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java | JsonUtil.getInt | public static int getInt(JsonObject object, String field, int defaultValue) {
"""
Returns a field in a Json object as an int.
@param object the Json Object
@param field the field in the Json object to return
@param defaultValue a default value for the field if the field value is null
@return the Json field value as an int
"""
final JsonValue value = object.get(field);
if (value == null || value.isNull()) {
return defaultValue;
} else {
return value.asInt();
}
} | java | public static int getInt(JsonObject object, String field, int defaultValue) {
final JsonValue value = object.get(field);
if (value == null || value.isNull()) {
return defaultValue;
} else {
return value.asInt();
}
} | [
"public",
"static",
"int",
"getInt",
"(",
"JsonObject",
"object",
",",
"String",
"field",
",",
"int",
"defaultValue",
")",
"{",
"final",
"JsonValue",
"value",
"=",
"object",
".",
"get",
"(",
"field",
")",
";",
"if",
"(",
"value",
"==",
"null",
"||",
"value",
".",
"isNull",
"(",
")",
")",
"{",
"return",
"defaultValue",
";",
"}",
"else",
"{",
"return",
"value",
".",
"asInt",
"(",
")",
";",
"}",
"}"
] | Returns a field in a Json object as an int.
@param object the Json Object
@param field the field in the Json object to return
@param defaultValue a default value for the field if the field value is null
@return the Json field value as an int | [
"Returns",
"a",
"field",
"in",
"a",
"Json",
"object",
"as",
"an",
"int",
"."
] | train | https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java#L59-L66 |
mikepenz/FastAdapter | library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java | FastAdapter.onBindViewHolder | @Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position, List<Object> payloads) {
"""
Binds the data to the created ViewHolder and sets the listeners to the holder.itemView
@param holder the viewHolder we bind the data on
@param position the global position
@param payloads the payloads for the bindViewHolder event containing data which allows to improve view animating
"""
//we do not want the binding to happen twice (the legacyBindViewMode
if (!mLegacyBindViewMode) {
if (mVerbose)
Log.v(TAG, "onBindViewHolder: " + position + "/" + holder.getItemViewType() + " isLegacy: false");
//set the R.id.fastadapter_item_adapter tag to the adapter so we always have the proper bound adapter available
holder.itemView.setTag(R.id.fastadapter_item_adapter, this);
//now we bind the item to this viewHolder
mOnBindViewHolderListener.onBindViewHolder(holder, position, payloads);
}
super.onBindViewHolder(holder, position, payloads);
} | java | @Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position, List<Object> payloads) {
//we do not want the binding to happen twice (the legacyBindViewMode
if (!mLegacyBindViewMode) {
if (mVerbose)
Log.v(TAG, "onBindViewHolder: " + position + "/" + holder.getItemViewType() + " isLegacy: false");
//set the R.id.fastadapter_item_adapter tag to the adapter so we always have the proper bound adapter available
holder.itemView.setTag(R.id.fastadapter_item_adapter, this);
//now we bind the item to this viewHolder
mOnBindViewHolderListener.onBindViewHolder(holder, position, payloads);
}
super.onBindViewHolder(holder, position, payloads);
} | [
"@",
"Override",
"public",
"void",
"onBindViewHolder",
"(",
"RecyclerView",
".",
"ViewHolder",
"holder",
",",
"int",
"position",
",",
"List",
"<",
"Object",
">",
"payloads",
")",
"{",
"//we do not want the binding to happen twice (the legacyBindViewMode",
"if",
"(",
"!",
"mLegacyBindViewMode",
")",
"{",
"if",
"(",
"mVerbose",
")",
"Log",
".",
"v",
"(",
"TAG",
",",
"\"onBindViewHolder: \"",
"+",
"position",
"+",
"\"/\"",
"+",
"holder",
".",
"getItemViewType",
"(",
")",
"+",
"\" isLegacy: false\"",
")",
";",
"//set the R.id.fastadapter_item_adapter tag to the adapter so we always have the proper bound adapter available",
"holder",
".",
"itemView",
".",
"setTag",
"(",
"R",
".",
"id",
".",
"fastadapter_item_adapter",
",",
"this",
")",
";",
"//now we bind the item to this viewHolder",
"mOnBindViewHolderListener",
".",
"onBindViewHolder",
"(",
"holder",
",",
"position",
",",
"payloads",
")",
";",
"}",
"super",
".",
"onBindViewHolder",
"(",
"holder",
",",
"position",
",",
"payloads",
")",
";",
"}"
] | Binds the data to the created ViewHolder and sets the listeners to the holder.itemView
@param holder the viewHolder we bind the data on
@param position the global position
@param payloads the payloads for the bindViewHolder event containing data which allows to improve view animating | [
"Binds",
"the",
"data",
"to",
"the",
"created",
"ViewHolder",
"and",
"sets",
"the",
"listeners",
"to",
"the",
"holder",
".",
"itemView"
] | train | https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java#L733-L745 |
Carbonado/Carbonado | src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepositoryBuilder.java | BDBRepositoryBuilder.setCompressor | public void setCompressor(String type, String compressionType) {
"""
Set the compressor for the given class, overriding a custom StorableCodecFactory.
@param type Storable to compress.
@param compressionType String representation of type of
compression. Available options are "NONE" for no compression or "GZIP"
for gzip compression
"""
mStorableCodecFactory = null;
compressionType = compressionType.toUpperCase();
if (mCompressionMap == null) {
mCompressionMap = new HashMap<String, CompressionType>();
}
CompressionType compressionEnum = CompressionType.valueOf(compressionType);
if (compressionEnum != null) {
mCompressionMap.put(type, compressionEnum);
}
} | java | public void setCompressor(String type, String compressionType) {
mStorableCodecFactory = null;
compressionType = compressionType.toUpperCase();
if (mCompressionMap == null) {
mCompressionMap = new HashMap<String, CompressionType>();
}
CompressionType compressionEnum = CompressionType.valueOf(compressionType);
if (compressionEnum != null) {
mCompressionMap.put(type, compressionEnum);
}
} | [
"public",
"void",
"setCompressor",
"(",
"String",
"type",
",",
"String",
"compressionType",
")",
"{",
"mStorableCodecFactory",
"=",
"null",
";",
"compressionType",
"=",
"compressionType",
".",
"toUpperCase",
"(",
")",
";",
"if",
"(",
"mCompressionMap",
"==",
"null",
")",
"{",
"mCompressionMap",
"=",
"new",
"HashMap",
"<",
"String",
",",
"CompressionType",
">",
"(",
")",
";",
"}",
"CompressionType",
"compressionEnum",
"=",
"CompressionType",
".",
"valueOf",
"(",
"compressionType",
")",
";",
"if",
"(",
"compressionEnum",
"!=",
"null",
")",
"{",
"mCompressionMap",
".",
"put",
"(",
"type",
",",
"compressionEnum",
")",
";",
"}",
"}"
] | Set the compressor for the given class, overriding a custom StorableCodecFactory.
@param type Storable to compress.
@param compressionType String representation of type of
compression. Available options are "NONE" for no compression or "GZIP"
for gzip compression | [
"Set",
"the",
"compressor",
"for",
"the",
"given",
"class",
"overriding",
"a",
"custom",
"StorableCodecFactory",
"."
] | train | https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepositoryBuilder.java#L1061-L1071 |
mnlipp/jgrapes | org.jgrapes.http/src/org/jgrapes/http/ResponseCreationSupport.java | ResponseCreationSupport.resourceInfo | @SuppressWarnings("PMD.EmptyCatchBlock")
public static ResourceInfo resourceInfo(URL resource) {
"""
Attempts to lookup the additional resource information for the
given URL.
If a {@link URL} references a file, it is easy to find out if
the resource referenced is a directory and to get its last
modification time. Getting the same information
for a {@link URL} that references resources in a jar is a bit
more difficult. This method handles both cases.
@param resource the resource URL
@return the resource info
"""
try {
Path path = Paths.get(resource.toURI());
return new ResourceInfo(Files.isDirectory(path),
Files.getLastModifiedTime(path).toInstant()
.with(ChronoField.NANO_OF_SECOND, 0));
} catch (FileSystemNotFoundException | IOException
| URISyntaxException e) {
// Fall through
}
if ("jar".equals(resource.getProtocol())) {
try {
JarURLConnection conn
= (JarURLConnection) resource.openConnection();
JarEntry entry = conn.getJarEntry();
return new ResourceInfo(entry.isDirectory(),
entry.getLastModifiedTime().toInstant()
.with(ChronoField.NANO_OF_SECOND, 0));
} catch (IOException e) {
// Fall through
}
}
try {
URLConnection conn = resource.openConnection();
long lastModified = conn.getLastModified();
if (lastModified != 0) {
return new ResourceInfo(null, Instant.ofEpochMilli(
lastModified).with(ChronoField.NANO_OF_SECOND, 0));
}
} catch (IOException e) {
// Fall through
}
return new ResourceInfo(null, null);
} | java | @SuppressWarnings("PMD.EmptyCatchBlock")
public static ResourceInfo resourceInfo(URL resource) {
try {
Path path = Paths.get(resource.toURI());
return new ResourceInfo(Files.isDirectory(path),
Files.getLastModifiedTime(path).toInstant()
.with(ChronoField.NANO_OF_SECOND, 0));
} catch (FileSystemNotFoundException | IOException
| URISyntaxException e) {
// Fall through
}
if ("jar".equals(resource.getProtocol())) {
try {
JarURLConnection conn
= (JarURLConnection) resource.openConnection();
JarEntry entry = conn.getJarEntry();
return new ResourceInfo(entry.isDirectory(),
entry.getLastModifiedTime().toInstant()
.with(ChronoField.NANO_OF_SECOND, 0));
} catch (IOException e) {
// Fall through
}
}
try {
URLConnection conn = resource.openConnection();
long lastModified = conn.getLastModified();
if (lastModified != 0) {
return new ResourceInfo(null, Instant.ofEpochMilli(
lastModified).with(ChronoField.NANO_OF_SECOND, 0));
}
} catch (IOException e) {
// Fall through
}
return new ResourceInfo(null, null);
} | [
"@",
"SuppressWarnings",
"(",
"\"PMD.EmptyCatchBlock\"",
")",
"public",
"static",
"ResourceInfo",
"resourceInfo",
"(",
"URL",
"resource",
")",
"{",
"try",
"{",
"Path",
"path",
"=",
"Paths",
".",
"get",
"(",
"resource",
".",
"toURI",
"(",
")",
")",
";",
"return",
"new",
"ResourceInfo",
"(",
"Files",
".",
"isDirectory",
"(",
"path",
")",
",",
"Files",
".",
"getLastModifiedTime",
"(",
"path",
")",
".",
"toInstant",
"(",
")",
".",
"with",
"(",
"ChronoField",
".",
"NANO_OF_SECOND",
",",
"0",
")",
")",
";",
"}",
"catch",
"(",
"FileSystemNotFoundException",
"|",
"IOException",
"|",
"URISyntaxException",
"e",
")",
"{",
"// Fall through",
"}",
"if",
"(",
"\"jar\"",
".",
"equals",
"(",
"resource",
".",
"getProtocol",
"(",
")",
")",
")",
"{",
"try",
"{",
"JarURLConnection",
"conn",
"=",
"(",
"JarURLConnection",
")",
"resource",
".",
"openConnection",
"(",
")",
";",
"JarEntry",
"entry",
"=",
"conn",
".",
"getJarEntry",
"(",
")",
";",
"return",
"new",
"ResourceInfo",
"(",
"entry",
".",
"isDirectory",
"(",
")",
",",
"entry",
".",
"getLastModifiedTime",
"(",
")",
".",
"toInstant",
"(",
")",
".",
"with",
"(",
"ChronoField",
".",
"NANO_OF_SECOND",
",",
"0",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"// Fall through",
"}",
"}",
"try",
"{",
"URLConnection",
"conn",
"=",
"resource",
".",
"openConnection",
"(",
")",
";",
"long",
"lastModified",
"=",
"conn",
".",
"getLastModified",
"(",
")",
";",
"if",
"(",
"lastModified",
"!=",
"0",
")",
"{",
"return",
"new",
"ResourceInfo",
"(",
"null",
",",
"Instant",
".",
"ofEpochMilli",
"(",
"lastModified",
")",
".",
"with",
"(",
"ChronoField",
".",
"NANO_OF_SECOND",
",",
"0",
")",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"// Fall through",
"}",
"return",
"new",
"ResourceInfo",
"(",
"null",
",",
"null",
")",
";",
"}"
] | Attempts to lookup the additional resource information for the
given URL.
If a {@link URL} references a file, it is easy to find out if
the resource referenced is a directory and to get its last
modification time. Getting the same information
for a {@link URL} that references resources in a jar is a bit
more difficult. This method handles both cases.
@param resource the resource URL
@return the resource info | [
"Attempts",
"to",
"lookup",
"the",
"additional",
"resource",
"information",
"for",
"the",
"given",
"URL",
"."
] | train | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.http/src/org/jgrapes/http/ResponseCreationSupport.java#L265-L299 |
OpenLiberty/open-liberty | dev/com.ibm.ws.jdbc.management.j2ee/src/com/ibm/ws/jdbc/management/j2ee/internal/JDBCResourceMBeanImpl.java | JDBCResourceMBeanImpl.setDataSourceChild | protected JDBCDataSourceMBeanImpl setDataSourceChild(String key, JDBCDataSourceMBeanImpl ds) {
"""
setDataSourceChild add a child of type JDBCDataSourceMBeanImpl to this MBean.
@param key the String value which will be used as the key for the JDBCDataSourceMBeanImpl item
@param ds the JDBCDataSourceMBeanImpl value to be associated with the specified key
@return The previous value associated with key, or null if there was no mapping for key.
(A null return can also indicate that the map previously associated null with key.)
"""
return dataSourceMBeanChildrenList.put(key, ds);
} | java | protected JDBCDataSourceMBeanImpl setDataSourceChild(String key, JDBCDataSourceMBeanImpl ds) {
return dataSourceMBeanChildrenList.put(key, ds);
} | [
"protected",
"JDBCDataSourceMBeanImpl",
"setDataSourceChild",
"(",
"String",
"key",
",",
"JDBCDataSourceMBeanImpl",
"ds",
")",
"{",
"return",
"dataSourceMBeanChildrenList",
".",
"put",
"(",
"key",
",",
"ds",
")",
";",
"}"
] | setDataSourceChild add a child of type JDBCDataSourceMBeanImpl to this MBean.
@param key the String value which will be used as the key for the JDBCDataSourceMBeanImpl item
@param ds the JDBCDataSourceMBeanImpl value to be associated with the specified key
@return The previous value associated with key, or null if there was no mapping for key.
(A null return can also indicate that the map previously associated null with key.) | [
"setDataSourceChild",
"add",
"a",
"child",
"of",
"type",
"JDBCDataSourceMBeanImpl",
"to",
"this",
"MBean",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jdbc.management.j2ee/src/com/ibm/ws/jdbc/management/j2ee/internal/JDBCResourceMBeanImpl.java#L234-L236 |
looly/hutool | hutool-http/src/main/java/cn/hutool/http/HttpUtil.java | HttpUtil.downloadString | public static String downloadString(String url, Charset customCharset) {
"""
下载远程文本
@param url 请求的url
@param customCharset 自定义的字符集,可以使用{@link CharsetUtil#charset} 方法转换
@return 文本
"""
return downloadString(url, customCharset, null);
} | java | public static String downloadString(String url, Charset customCharset) {
return downloadString(url, customCharset, null);
} | [
"public",
"static",
"String",
"downloadString",
"(",
"String",
"url",
",",
"Charset",
"customCharset",
")",
"{",
"return",
"downloadString",
"(",
"url",
",",
"customCharset",
",",
"null",
")",
";",
"}"
] | 下载远程文本
@param url 请求的url
@param customCharset 自定义的字符集,可以使用{@link CharsetUtil#charset} 方法转换
@return 文本 | [
"下载远程文本"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-http/src/main/java/cn/hutool/http/HttpUtil.java#L225-L227 |
ziccardi/jnrpe | jnrpe-plugins/src/main/java/it/jnrpe/plugin/utils/HttpUtils.java | HttpUtils.doGET | public static String doGET(final URL url, final Properties requestProps, final Integer timeout, boolean includeHeaders, boolean ignoreBody)
throws Exception {
"""
Do a http get request and return response
@param url target url
@param requestProps props to be requested
@param timeout connection timeout
@param includeHeaders whether to include headers or not
@param ignoreBody whether to ignore body content or not
@return server answer
@throws Exception on any connection
"""
return doRequest(url, requestProps, timeout, includeHeaders, ignoreBody, "GET");
} | java | public static String doGET(final URL url, final Properties requestProps, final Integer timeout, boolean includeHeaders, boolean ignoreBody)
throws Exception {
return doRequest(url, requestProps, timeout, includeHeaders, ignoreBody, "GET");
} | [
"public",
"static",
"String",
"doGET",
"(",
"final",
"URL",
"url",
",",
"final",
"Properties",
"requestProps",
",",
"final",
"Integer",
"timeout",
",",
"boolean",
"includeHeaders",
",",
"boolean",
"ignoreBody",
")",
"throws",
"Exception",
"{",
"return",
"doRequest",
"(",
"url",
",",
"requestProps",
",",
"timeout",
",",
"includeHeaders",
",",
"ignoreBody",
",",
"\"GET\"",
")",
";",
"}"
] | Do a http get request and return response
@param url target url
@param requestProps props to be requested
@param timeout connection timeout
@param includeHeaders whether to include headers or not
@param ignoreBody whether to ignore body content or not
@return server answer
@throws Exception on any connection | [
"Do",
"a",
"http",
"get",
"request",
"and",
"return",
"response"
] | train | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-plugins/src/main/java/it/jnrpe/plugin/utils/HttpUtils.java#L48-L51 |
gliga/ekstazi | ekstazi-maven-plugin/src/main/java/org/ekstazi/maven/AbstractEkstaziMojo.java | AbstractEkstaziMojo.extractParamValue | protected String extractParamValue(Plugin plugin, String paramName) throws MojoExecutionException {
"""
Locate paramName in the given (surefire) plugin. Returns value
of the file.
"""
Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration();
if (configuration == null) {
return null;
}
Xpp3Dom paramDom = configuration.getChild(paramName);
return paramDom == null ? null : paramDom.getValue();
} | java | protected String extractParamValue(Plugin plugin, String paramName) throws MojoExecutionException {
Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration();
if (configuration == null) {
return null;
}
Xpp3Dom paramDom = configuration.getChild(paramName);
return paramDom == null ? null : paramDom.getValue();
} | [
"protected",
"String",
"extractParamValue",
"(",
"Plugin",
"plugin",
",",
"String",
"paramName",
")",
"throws",
"MojoExecutionException",
"{",
"Xpp3Dom",
"configuration",
"=",
"(",
"Xpp3Dom",
")",
"plugin",
".",
"getConfiguration",
"(",
")",
";",
"if",
"(",
"configuration",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"Xpp3Dom",
"paramDom",
"=",
"configuration",
".",
"getChild",
"(",
"paramName",
")",
";",
"return",
"paramDom",
"==",
"null",
"?",
"null",
":",
"paramDom",
".",
"getValue",
"(",
")",
";",
"}"
] | Locate paramName in the given (surefire) plugin. Returns value
of the file. | [
"Locate",
"paramName",
"in",
"the",
"given",
"(",
"surefire",
")",
"plugin",
".",
"Returns",
"value",
"of",
"the",
"file",
"."
] | train | https://github.com/gliga/ekstazi/blob/5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1/ekstazi-maven-plugin/src/main/java/org/ekstazi/maven/AbstractEkstaziMojo.java#L162-L169 |
sriharshachilakapati/WebGL4J | webgl4j/src/main/java/com/shc/webgl4j/client/WebGL10.java | WebGL10.glBufferSubData | public static void glBufferSubData(int target, int offset, int size, short[] data) {
"""
<p>{@code glBufferSubData} redefines some or all of the data store for the buffer object currently bound to
{@code target}. Data starting at byte offset {@code offset} and extending for {@code size} bytes is copied to the
data store from the memory pointed to by {@code data}. An error is thrown if {@code offset} and {@code size}
together define a range beyond the bounds of the buffer object's data store.</p>
<p>{@link #GL_INVALID_ENUM} is generated if target is not {@link #GL_ARRAY_BUFFER} or {@link
#GL_ELEMENT_ARRAY_BUFFER}.</p>
<p>{@link #GL_INVALID_VALUE} is generated if offset or size is negative, or if together they define a region of
memory that extends beyond the buffer object's allocated data store.</p>
<p>{@link #GL_INVALID_OPERATION} is generated if the reserved buffer object name 0 is bound to target.</p>
@param target Specifies the target buffer object. The symbolic constant must be {@link #GL_ARRAY_BUFFER} or
{@link #GL_ELEMENT_ARRAY_BUFFER}.
@param offset Specifies the offset into the buffer object's data store where data replacement will begin,
measured in bytes.
@param size Specifies the size in bytes of the data store region being replaced.
@param data Specifies the new data that will be copied into the data store.
"""
checkContextCompatibility();
Int16Array dataBuffer = Int16ArrayNative.create(data.length);
dataBuffer.set(data);
nglBufferSubData(target, offset, size, dataBuffer);
} | java | public static void glBufferSubData(int target, int offset, int size, short[] data)
{
checkContextCompatibility();
Int16Array dataBuffer = Int16ArrayNative.create(data.length);
dataBuffer.set(data);
nglBufferSubData(target, offset, size, dataBuffer);
} | [
"public",
"static",
"void",
"glBufferSubData",
"(",
"int",
"target",
",",
"int",
"offset",
",",
"int",
"size",
",",
"short",
"[",
"]",
"data",
")",
"{",
"checkContextCompatibility",
"(",
")",
";",
"Int16Array",
"dataBuffer",
"=",
"Int16ArrayNative",
".",
"create",
"(",
"data",
".",
"length",
")",
";",
"dataBuffer",
".",
"set",
"(",
"data",
")",
";",
"nglBufferSubData",
"(",
"target",
",",
"offset",
",",
"size",
",",
"dataBuffer",
")",
";",
"}"
] | <p>{@code glBufferSubData} redefines some or all of the data store for the buffer object currently bound to
{@code target}. Data starting at byte offset {@code offset} and extending for {@code size} bytes is copied to the
data store from the memory pointed to by {@code data}. An error is thrown if {@code offset} and {@code size}
together define a range beyond the bounds of the buffer object's data store.</p>
<p>{@link #GL_INVALID_ENUM} is generated if target is not {@link #GL_ARRAY_BUFFER} or {@link
#GL_ELEMENT_ARRAY_BUFFER}.</p>
<p>{@link #GL_INVALID_VALUE} is generated if offset or size is negative, or if together they define a region of
memory that extends beyond the buffer object's allocated data store.</p>
<p>{@link #GL_INVALID_OPERATION} is generated if the reserved buffer object name 0 is bound to target.</p>
@param target Specifies the target buffer object. The symbolic constant must be {@link #GL_ARRAY_BUFFER} or
{@link #GL_ELEMENT_ARRAY_BUFFER}.
@param offset Specifies the offset into the buffer object's data store where data replacement will begin,
measured in bytes.
@param size Specifies the size in bytes of the data store region being replaced.
@param data Specifies the new data that will be copied into the data store. | [
"<p",
">",
"{",
"@code",
"glBufferSubData",
"}",
"redefines",
"some",
"or",
"all",
"of",
"the",
"data",
"store",
"for",
"the",
"buffer",
"object",
"currently",
"bound",
"to",
"{",
"@code",
"target",
"}",
".",
"Data",
"starting",
"at",
"byte",
"offset",
"{",
"@code",
"offset",
"}",
"and",
"extending",
"for",
"{",
"@code",
"size",
"}",
"bytes",
"is",
"copied",
"to",
"the",
"data",
"store",
"from",
"the",
"memory",
"pointed",
"to",
"by",
"{",
"@code",
"data",
"}",
".",
"An",
"error",
"is",
"thrown",
"if",
"{",
"@code",
"offset",
"}",
"and",
"{",
"@code",
"size",
"}",
"together",
"define",
"a",
"range",
"beyond",
"the",
"bounds",
"of",
"the",
"buffer",
"object",
"s",
"data",
"store",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/sriharshachilakapati/WebGL4J/blob/7daa425300b08b338b50cef2935289849c92d415/webgl4j/src/main/java/com/shc/webgl4j/client/WebGL10.java#L1131-L1137 |
aws/aws-sdk-java | aws-java-sdk-iot/src/main/java/com/amazonaws/services/iot/model/CreateAuthorizerRequest.java | CreateAuthorizerRequest.withTokenSigningPublicKeys | public CreateAuthorizerRequest withTokenSigningPublicKeys(java.util.Map<String, String> tokenSigningPublicKeys) {
"""
<p>
The public keys used to verify the digital signature returned by your custom authentication service.
</p>
@param tokenSigningPublicKeys
The public keys used to verify the digital signature returned by your custom authentication service.
@return Returns a reference to this object so that method calls can be chained together.
"""
setTokenSigningPublicKeys(tokenSigningPublicKeys);
return this;
} | java | public CreateAuthorizerRequest withTokenSigningPublicKeys(java.util.Map<String, String> tokenSigningPublicKeys) {
setTokenSigningPublicKeys(tokenSigningPublicKeys);
return this;
} | [
"public",
"CreateAuthorizerRequest",
"withTokenSigningPublicKeys",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"tokenSigningPublicKeys",
")",
"{",
"setTokenSigningPublicKeys",
"(",
"tokenSigningPublicKeys",
")",
";",
"return",
"this",
";",
"}"
] | <p>
The public keys used to verify the digital signature returned by your custom authentication service.
</p>
@param tokenSigningPublicKeys
The public keys used to verify the digital signature returned by your custom authentication service.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"The",
"public",
"keys",
"used",
"to",
"verify",
"the",
"digital",
"signature",
"returned",
"by",
"your",
"custom",
"authentication",
"service",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-iot/src/main/java/com/amazonaws/services/iot/model/CreateAuthorizerRequest.java#L209-L212 |
Erudika/para | para-client/src/main/java/com/erudika/para/client/ParaClient.java | ParaClient.isLinked | public boolean isLinked(ParaObject obj, String type2, String id2) {
"""
Checks if this object is linked to another.
@param type2 the other type
@param id2 the other id
@param obj the object to execute this method on
@return true if the two are linked
"""
if (obj == null || obj.getId() == null || type2 == null || id2 == null) {
return false;
}
String url = Utils.formatMessage("{0}/links/{1}/{2}", obj.getObjectURI(), type2, id2);
Boolean result = getEntity(invokeGet(url, null), Boolean.class);
return result != null && result;
} | java | public boolean isLinked(ParaObject obj, String type2, String id2) {
if (obj == null || obj.getId() == null || type2 == null || id2 == null) {
return false;
}
String url = Utils.formatMessage("{0}/links/{1}/{2}", obj.getObjectURI(), type2, id2);
Boolean result = getEntity(invokeGet(url, null), Boolean.class);
return result != null && result;
} | [
"public",
"boolean",
"isLinked",
"(",
"ParaObject",
"obj",
",",
"String",
"type2",
",",
"String",
"id2",
")",
"{",
"if",
"(",
"obj",
"==",
"null",
"||",
"obj",
".",
"getId",
"(",
")",
"==",
"null",
"||",
"type2",
"==",
"null",
"||",
"id2",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"String",
"url",
"=",
"Utils",
".",
"formatMessage",
"(",
"\"{0}/links/{1}/{2}\"",
",",
"obj",
".",
"getObjectURI",
"(",
")",
",",
"type2",
",",
"id2",
")",
";",
"Boolean",
"result",
"=",
"getEntity",
"(",
"invokeGet",
"(",
"url",
",",
"null",
")",
",",
"Boolean",
".",
"class",
")",
";",
"return",
"result",
"!=",
"null",
"&&",
"result",
";",
"}"
] | Checks if this object is linked to another.
@param type2 the other type
@param id2 the other id
@param obj the object to execute this method on
@return true if the two are linked | [
"Checks",
"if",
"this",
"object",
"is",
"linked",
"to",
"another",
"."
] | train | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-client/src/main/java/com/erudika/para/client/ParaClient.java#L998-L1005 |
micronaut-projects/micronaut-core | core/src/main/java/io/micronaut/core/bind/annotation/AbstractAnnotatedArgumentBinder.java | AbstractAnnotatedArgumentBinder.doBind | @SuppressWarnings("unchecked")
protected BindingResult<T> doBind(
ArgumentConversionContext<T> context,
ConvertibleValues<?> values,
String annotationValue) {
"""
Do binding.
@param context context
@param values values
@param annotationValue annotationValue
@return result
"""
return doConvert(doResolve(context, values, annotationValue), context);
} | java | @SuppressWarnings("unchecked")
protected BindingResult<T> doBind(
ArgumentConversionContext<T> context,
ConvertibleValues<?> values,
String annotationValue) {
return doConvert(doResolve(context, values, annotationValue), context);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"BindingResult",
"<",
"T",
">",
"doBind",
"(",
"ArgumentConversionContext",
"<",
"T",
">",
"context",
",",
"ConvertibleValues",
"<",
"?",
">",
"values",
",",
"String",
"annotationValue",
")",
"{",
"return",
"doConvert",
"(",
"doResolve",
"(",
"context",
",",
"values",
",",
"annotationValue",
")",
",",
"context",
")",
";",
"}"
] | Do binding.
@param context context
@param values values
@param annotationValue annotationValue
@return result | [
"Do",
"binding",
"."
] | train | https://github.com/micronaut-projects/micronaut-core/blob/c31f5b03ce0eb88c2f6470710987db03b8967d5c/core/src/main/java/io/micronaut/core/bind/annotation/AbstractAnnotatedArgumentBinder.java#L60-L67 |
liferay/com-liferay-commerce | commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPOptionPersistenceImpl.java | CPOptionPersistenceImpl.findByG_K | @Override
public CPOption findByG_K(long groupId, String key)
throws NoSuchCPOptionException {
"""
Returns the cp option where groupId = ? and key = ? or throws a {@link NoSuchCPOptionException} if it could not be found.
@param groupId the group ID
@param key the key
@return the matching cp option
@throws NoSuchCPOptionException if a matching cp option could not be found
"""
CPOption cpOption = fetchByG_K(groupId, key);
if (cpOption == null) {
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("groupId=");
msg.append(groupId);
msg.append(", key=");
msg.append(key);
msg.append("}");
if (_log.isDebugEnabled()) {
_log.debug(msg.toString());
}
throw new NoSuchCPOptionException(msg.toString());
}
return cpOption;
} | java | @Override
public CPOption findByG_K(long groupId, String key)
throws NoSuchCPOptionException {
CPOption cpOption = fetchByG_K(groupId, key);
if (cpOption == null) {
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("groupId=");
msg.append(groupId);
msg.append(", key=");
msg.append(key);
msg.append("}");
if (_log.isDebugEnabled()) {
_log.debug(msg.toString());
}
throw new NoSuchCPOptionException(msg.toString());
}
return cpOption;
} | [
"@",
"Override",
"public",
"CPOption",
"findByG_K",
"(",
"long",
"groupId",
",",
"String",
"key",
")",
"throws",
"NoSuchCPOptionException",
"{",
"CPOption",
"cpOption",
"=",
"fetchByG_K",
"(",
"groupId",
",",
"key",
")",
";",
"if",
"(",
"cpOption",
"==",
"null",
")",
"{",
"StringBundler",
"msg",
"=",
"new",
"StringBundler",
"(",
"6",
")",
";",
"msg",
".",
"append",
"(",
"_NO_SUCH_ENTITY_WITH_KEY",
")",
";",
"msg",
".",
"append",
"(",
"\"groupId=\"",
")",
";",
"msg",
".",
"append",
"(",
"groupId",
")",
";",
"msg",
".",
"append",
"(",
"\", key=\"",
")",
";",
"msg",
".",
"append",
"(",
"key",
")",
";",
"msg",
".",
"append",
"(",
"\"}\"",
")",
";",
"if",
"(",
"_log",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"_log",
".",
"debug",
"(",
"msg",
".",
"toString",
"(",
")",
")",
";",
"}",
"throw",
"new",
"NoSuchCPOptionException",
"(",
"msg",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"cpOption",
";",
"}"
] | Returns the cp option where groupId = ? and key = ? or throws a {@link NoSuchCPOptionException} if it could not be found.
@param groupId the group ID
@param key the key
@return the matching cp option
@throws NoSuchCPOptionException if a matching cp option could not be found | [
"Returns",
"the",
"cp",
"option",
"where",
"groupId",
"=",
"?",
";",
"and",
"key",
"=",
"?",
";",
"or",
"throws",
"a",
"{",
"@link",
"NoSuchCPOptionException",
"}",
"if",
"it",
"could",
"not",
"be",
"found",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPOptionPersistenceImpl.java#L1992-L2018 |
Azure/azure-sdk-for-java | keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java | KeyVaultClientBaseImpl.getSecret | public SecretBundle getSecret(String vaultBaseUrl, String secretName, String secretVersion) {
"""
Get a specified secret from a given key vault.
The GET operation is applicable to any secret stored in Azure Key Vault. This operation requires the secrets/get permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param secretName The name of the secret.
@param secretVersion The version of the secret.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws KeyVaultErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the SecretBundle object if successful.
"""
return getSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion).toBlocking().single().body();
} | java | public SecretBundle getSecret(String vaultBaseUrl, String secretName, String secretVersion) {
return getSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion).toBlocking().single().body();
} | [
"public",
"SecretBundle",
"getSecret",
"(",
"String",
"vaultBaseUrl",
",",
"String",
"secretName",
",",
"String",
"secretVersion",
")",
"{",
"return",
"getSecretWithServiceResponseAsync",
"(",
"vaultBaseUrl",
",",
"secretName",
",",
"secretVersion",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Get a specified secret from a given key vault.
The GET operation is applicable to any secret stored in Azure Key Vault. This operation requires the secrets/get permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param secretName The name of the secret.
@param secretVersion The version of the secret.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws KeyVaultErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the SecretBundle object if successful. | [
"Get",
"a",
"specified",
"secret",
"from",
"a",
"given",
"key",
"vault",
".",
"The",
"GET",
"operation",
"is",
"applicable",
"to",
"any",
"secret",
"stored",
"in",
"Azure",
"Key",
"Vault",
".",
"This",
"operation",
"requires",
"the",
"secrets",
"/",
"get",
"permission",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java#L3828-L3830 |
rundeck/rundeck | core/src/main/java/com/dtolabs/rundeck/core/execution/impl/common/DefaultFileCopierUtil.java | DefaultFileCopierUtil.writeTempFile | @Override
public File writeTempFile(
ExecutionContext context, File original, InputStream input,
String script
) throws FileCopierException {
"""
Write the file, stream, or text to a local temp file and return the file
@param context context
@param original source file, or null
@param input source inputstream or null
@param script source text, or null
@return temp file, this file should later be cleaned up by calling
{@link com.dtolabs.rundeck.core.execution.script.ScriptfileUtils#releaseTempFile(java.io.File)}
@throws FileCopierException if IOException occurs
"""
File tempfile = null;
try {
tempfile = ScriptfileUtils.createTempFile(context.getFramework());
} catch (IOException e) {
throw new FileCopierException("error writing to tempfile: " + e.getMessage(),
StepFailureReason.IOFailure, e);
}
return writeLocalFile(original, input, script, tempfile);
} | java | @Override
public File writeTempFile(
ExecutionContext context, File original, InputStream input,
String script
) throws FileCopierException {
File tempfile = null;
try {
tempfile = ScriptfileUtils.createTempFile(context.getFramework());
} catch (IOException e) {
throw new FileCopierException("error writing to tempfile: " + e.getMessage(),
StepFailureReason.IOFailure, e);
}
return writeLocalFile(original, input, script, tempfile);
} | [
"@",
"Override",
"public",
"File",
"writeTempFile",
"(",
"ExecutionContext",
"context",
",",
"File",
"original",
",",
"InputStream",
"input",
",",
"String",
"script",
")",
"throws",
"FileCopierException",
"{",
"File",
"tempfile",
"=",
"null",
";",
"try",
"{",
"tempfile",
"=",
"ScriptfileUtils",
".",
"createTempFile",
"(",
"context",
".",
"getFramework",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"FileCopierException",
"(",
"\"error writing to tempfile: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"StepFailureReason",
".",
"IOFailure",
",",
"e",
")",
";",
"}",
"return",
"writeLocalFile",
"(",
"original",
",",
"input",
",",
"script",
",",
"tempfile",
")",
";",
"}"
] | Write the file, stream, or text to a local temp file and return the file
@param context context
@param original source file, or null
@param input source inputstream or null
@param script source text, or null
@return temp file, this file should later be cleaned up by calling
{@link com.dtolabs.rundeck.core.execution.script.ScriptfileUtils#releaseTempFile(java.io.File)}
@throws FileCopierException if IOException occurs | [
"Write",
"the",
"file",
"stream",
"or",
"text",
"to",
"a",
"local",
"temp",
"file",
"and",
"return",
"the",
"file"
] | train | https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/execution/impl/common/DefaultFileCopierUtil.java#L427-L440 |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/Util.java | Util.mixHashCodes | public static int mixHashCodes(int hash1, int hash2, int hash3) {
"""
Mix multiple hashcodes into one.
@param hash1 First hashcode to mix
@param hash2 Second hashcode to mix
@param hash3 Third hashcode to mix
@return Mixed hash code
"""
long result = hash1 * HASHPRIME + hash2;
return (int) (result * HASHPRIME + hash3);
} | java | public static int mixHashCodes(int hash1, int hash2, int hash3) {
long result = hash1 * HASHPRIME + hash2;
return (int) (result * HASHPRIME + hash3);
} | [
"public",
"static",
"int",
"mixHashCodes",
"(",
"int",
"hash1",
",",
"int",
"hash2",
",",
"int",
"hash3",
")",
"{",
"long",
"result",
"=",
"hash1",
"*",
"HASHPRIME",
"+",
"hash2",
";",
"return",
"(",
"int",
")",
"(",
"result",
"*",
"HASHPRIME",
"+",
"hash3",
")",
";",
"}"
] | Mix multiple hashcodes into one.
@param hash1 First hashcode to mix
@param hash2 Second hashcode to mix
@param hash3 Third hashcode to mix
@return Mixed hash code | [
"Mix",
"multiple",
"hashcodes",
"into",
"one",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/Util.java#L64-L67 |
Azure/azure-sdk-for-java | cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/implementation/DatabaseAccountsInner.java | DatabaseAccountsInner.beginOfflineRegion | public void beginOfflineRegion(String resourceGroupName, String accountName, String region) {
"""
Offline the specified region for the specified Azure Cosmos DB database account.
@param resourceGroupName Name of an Azure resource group.
@param accountName Cosmos DB database account name.
@param region Cosmos DB region, with spaces between words and each word capitalized.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
"""
beginOfflineRegionWithServiceResponseAsync(resourceGroupName, accountName, region).toBlocking().single().body();
} | java | public void beginOfflineRegion(String resourceGroupName, String accountName, String region) {
beginOfflineRegionWithServiceResponseAsync(resourceGroupName, accountName, region).toBlocking().single().body();
} | [
"public",
"void",
"beginOfflineRegion",
"(",
"String",
"resourceGroupName",
",",
"String",
"accountName",
",",
"String",
"region",
")",
"{",
"beginOfflineRegionWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"accountName",
",",
"region",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Offline the specified region for the specified Azure Cosmos DB database account.
@param resourceGroupName Name of an Azure resource group.
@param accountName Cosmos DB database account name.
@param region Cosmos DB region, with spaces between words and each word capitalized.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent | [
"Offline",
"the",
"specified",
"region",
"for",
"the",
"specified",
"Azure",
"Cosmos",
"DB",
"database",
"account",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/implementation/DatabaseAccountsInner.java#L1361-L1363 |
guardtime/ksi-java-sdk | ksi-common/src/main/java/com/guardtime/ksi/util/Util.java | Util.copyData | public static int copyData(InputStream in, OutputStream out) throws IOException {
"""
Copies all available data from {@code in} to {@code out}.
<p>
Allocates a temporary memory buffer of {@link #DEFAULT_BUFFER_SIZE} bytes for this.
</p>
@param in
input stream to copy data from.
@param out
output stream to copy data to.
@return The number of bytes actually copied.
@throws IOException
if one is thrown by either {@code in} or {@code out}.
"""
return copyData(in, out, -1, DEFAULT_BUFFER_SIZE);
} | java | public static int copyData(InputStream in, OutputStream out) throws IOException {
return copyData(in, out, -1, DEFAULT_BUFFER_SIZE);
} | [
"public",
"static",
"int",
"copyData",
"(",
"InputStream",
"in",
",",
"OutputStream",
"out",
")",
"throws",
"IOException",
"{",
"return",
"copyData",
"(",
"in",
",",
"out",
",",
"-",
"1",
",",
"DEFAULT_BUFFER_SIZE",
")",
";",
"}"
] | Copies all available data from {@code in} to {@code out}.
<p>
Allocates a temporary memory buffer of {@link #DEFAULT_BUFFER_SIZE} bytes for this.
</p>
@param in
input stream to copy data from.
@param out
output stream to copy data to.
@return The number of bytes actually copied.
@throws IOException
if one is thrown by either {@code in} or {@code out}. | [
"Copies",
"all",
"available",
"data",
"from",
"{",
"@code",
"in",
"}",
"to",
"{",
"@code",
"out",
"}",
".",
"<p",
">",
"Allocates",
"a",
"temporary",
"memory",
"buffer",
"of",
"{",
"@link",
"#DEFAULT_BUFFER_SIZE",
"}",
"bytes",
"for",
"this",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-common/src/main/java/com/guardtime/ksi/util/Util.java#L573-L575 |
Azure/azure-sdk-for-java | sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/DatabaseAdvisorsInner.java | DatabaseAdvisorsInner.get | public AdvisorInner get(String resourceGroupName, String serverName, String databaseName, String advisorName) {
"""
Returns details of a Database Advisor.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param databaseName The name of the database.
@param advisorName The name of the Database Advisor.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the AdvisorInner object if successful.
"""
return getWithServiceResponseAsync(resourceGroupName, serverName, databaseName, advisorName).toBlocking().single().body();
} | java | public AdvisorInner get(String resourceGroupName, String serverName, String databaseName, String advisorName) {
return getWithServiceResponseAsync(resourceGroupName, serverName, databaseName, advisorName).toBlocking().single().body();
} | [
"public",
"AdvisorInner",
"get",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"String",
"databaseName",
",",
"String",
"advisorName",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
",",
"databaseName",
",",
"advisorName",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Returns details of a Database Advisor.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param databaseName The name of the database.
@param advisorName The name of the Database Advisor.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the AdvisorInner object if successful. | [
"Returns",
"details",
"of",
"a",
"Database",
"Advisor",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/DatabaseAdvisorsInner.java#L176-L178 |
Stratio/stratio-cassandra | src/java/org/apache/cassandra/utils/btree/NodeBuilder.java | NodeBuilder.toNode | Object[] toNode() {
"""
builds a new root BTree node - must be called on root of operation
"""
assert buildKeyPosition <= FAN_FACTOR && (buildKeyPosition > 0 || copyFrom.length > 0) : buildKeyPosition;
return buildFromRange(0, buildKeyPosition, isLeaf(copyFrom), false);
} | java | Object[] toNode()
{
assert buildKeyPosition <= FAN_FACTOR && (buildKeyPosition > 0 || copyFrom.length > 0) : buildKeyPosition;
return buildFromRange(0, buildKeyPosition, isLeaf(copyFrom), false);
} | [
"Object",
"[",
"]",
"toNode",
"(",
")",
"{",
"assert",
"buildKeyPosition",
"<=",
"FAN_FACTOR",
"&&",
"(",
"buildKeyPosition",
">",
"0",
"||",
"copyFrom",
".",
"length",
">",
"0",
")",
":",
"buildKeyPosition",
";",
"return",
"buildFromRange",
"(",
"0",
",",
"buildKeyPosition",
",",
"isLeaf",
"(",
"copyFrom",
")",
",",
"false",
")",
";",
"}"
] | builds a new root BTree node - must be called on root of operation | [
"builds",
"a",
"new",
"root",
"BTree",
"node",
"-",
"must",
"be",
"called",
"on",
"root",
"of",
"operation"
] | train | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/utils/btree/NodeBuilder.java#L265-L269 |
paypal/SeLion | client/src/main/java/com/paypal/selion/platform/asserts/SeLionAsserts.java | SeLionAsserts.assertEquals | public static void assertEquals(Object actual, Object expected, String message) {
"""
assertEquals method is used to assert based on actual and expected values and provide a Pass result for a same
match.assertEquals will yield a Fail result for a mismatch and abort the test case.
@param actual
- Actual value obtained from executing a test
@param expected
- Expected value for the test to pass.
@param message
- A descriptive text narrating a validation being done. <br>
Sample Usage<br>
<code>
SeLionAsserts.assertEquals("OK","OK", "Some Message");
</code>
"""
hardAssert.assertEquals(actual, expected, message);
} | java | public static void assertEquals(Object actual, Object expected, String message) {
hardAssert.assertEquals(actual, expected, message);
} | [
"public",
"static",
"void",
"assertEquals",
"(",
"Object",
"actual",
",",
"Object",
"expected",
",",
"String",
"message",
")",
"{",
"hardAssert",
".",
"assertEquals",
"(",
"actual",
",",
"expected",
",",
"message",
")",
";",
"}"
] | assertEquals method is used to assert based on actual and expected values and provide a Pass result for a same
match.assertEquals will yield a Fail result for a mismatch and abort the test case.
@param actual
- Actual value obtained from executing a test
@param expected
- Expected value for the test to pass.
@param message
- A descriptive text narrating a validation being done. <br>
Sample Usage<br>
<code>
SeLionAsserts.assertEquals("OK","OK", "Some Message");
</code> | [
"assertEquals",
"method",
"is",
"used",
"to",
"assert",
"based",
"on",
"actual",
"and",
"expected",
"values",
"and",
"provide",
"a",
"Pass",
"result",
"for",
"a",
"same",
"match",
".",
"assertEquals",
"will",
"yield",
"a",
"Fail",
"result",
"for",
"a",
"mismatch",
"and",
"abort",
"the",
"test",
"case",
"."
] | train | https://github.com/paypal/SeLion/blob/694d12d0df76db48d0360b16192770c6a4fbdfd2/client/src/main/java/com/paypal/selion/platform/asserts/SeLionAsserts.java#L455-L457 |
lievendoclo/Valkyrie-RCP | valkyrie-rcp-core/src/main/java/org/valkyriercp/util/GuiStandardUtils.java | GuiStandardUtils.createDebugBorder | public static void createDebugBorder(JComponent c, Color color) {
"""
Useful debug function to place a colored, line border around a component
for layout management debugging.
@param c
the component
@param color
the border color
"""
if (color == null) {
color = Color.BLACK;
}
c.setBorder(BorderFactory.createLineBorder(color));
} | java | public static void createDebugBorder(JComponent c, Color color) {
if (color == null) {
color = Color.BLACK;
}
c.setBorder(BorderFactory.createLineBorder(color));
} | [
"public",
"static",
"void",
"createDebugBorder",
"(",
"JComponent",
"c",
",",
"Color",
"color",
")",
"{",
"if",
"(",
"color",
"==",
"null",
")",
"{",
"color",
"=",
"Color",
".",
"BLACK",
";",
"}",
"c",
".",
"setBorder",
"(",
"BorderFactory",
".",
"createLineBorder",
"(",
"color",
")",
")",
";",
"}"
] | Useful debug function to place a colored, line border around a component
for layout management debugging.
@param c
the component
@param color
the border color | [
"Useful",
"debug",
"function",
"to",
"place",
"a",
"colored",
"line",
"border",
"around",
"a",
"component",
"for",
"layout",
"management",
"debugging",
"."
] | train | https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/util/GuiStandardUtils.java#L289-L294 |
mapcode-foundation/mapcode-java | src/main/java/com/mapcode/MapcodeCodec.java | MapcodeCodec.decodeToRectangle | @Nonnull
public static Rectangle decodeToRectangle(@Nonnull final String mapcode)
throws UnknownMapcodeException, IllegalArgumentException, UnknownPrecisionFormatException {
"""
Decode a mapcode to a Rectangle, which defines the valid zone for a mapcode. The boundaries of the
mapcode zone are inclusive for the South and West borders and exclusive for the North and East borders.
This is essentially the same call as a 'decode', except it returns a rectangle, rather than its center point.
@param mapcode Mapcode.
@return Rectangle Mapcode zone. South/West borders are inclusive, North/East borders exclusive.
@throws UnknownMapcodeException Thrown if the mapcode has the correct syntax,
but cannot be decoded into a point.
@throws UnknownPrecisionFormatException Thrown if the precision format is incorrect.
@throws IllegalArgumentException Thrown if arguments are null, or if the syntax of the mapcode is incorrect.
"""
return decodeToRectangle(mapcode, Territory.AAA);
} | java | @Nonnull
public static Rectangle decodeToRectangle(@Nonnull final String mapcode)
throws UnknownMapcodeException, IllegalArgumentException, UnknownPrecisionFormatException {
return decodeToRectangle(mapcode, Territory.AAA);
} | [
"@",
"Nonnull",
"public",
"static",
"Rectangle",
"decodeToRectangle",
"(",
"@",
"Nonnull",
"final",
"String",
"mapcode",
")",
"throws",
"UnknownMapcodeException",
",",
"IllegalArgumentException",
",",
"UnknownPrecisionFormatException",
"{",
"return",
"decodeToRectangle",
"(",
"mapcode",
",",
"Territory",
".",
"AAA",
")",
";",
"}"
] | Decode a mapcode to a Rectangle, which defines the valid zone for a mapcode. The boundaries of the
mapcode zone are inclusive for the South and West borders and exclusive for the North and East borders.
This is essentially the same call as a 'decode', except it returns a rectangle, rather than its center point.
@param mapcode Mapcode.
@return Rectangle Mapcode zone. South/West borders are inclusive, North/East borders exclusive.
@throws UnknownMapcodeException Thrown if the mapcode has the correct syntax,
but cannot be decoded into a point.
@throws UnknownPrecisionFormatException Thrown if the precision format is incorrect.
@throws IllegalArgumentException Thrown if arguments are null, or if the syntax of the mapcode is incorrect. | [
"Decode",
"a",
"mapcode",
"to",
"a",
"Rectangle",
"which",
"defines",
"the",
"valid",
"zone",
"for",
"a",
"mapcode",
".",
"The",
"boundaries",
"of",
"the",
"mapcode",
"zone",
"are",
"inclusive",
"for",
"the",
"South",
"and",
"West",
"borders",
"and",
"exclusive",
"for",
"the",
"North",
"and",
"East",
"borders",
".",
"This",
"is",
"essentially",
"the",
"same",
"call",
"as",
"a",
"decode",
"except",
"it",
"returns",
"a",
"rectangle",
"rather",
"than",
"its",
"center",
"point",
"."
] | train | https://github.com/mapcode-foundation/mapcode-java/blob/f12d4d9fbd460472ac0fff1f702f2ac716bc0ab8/src/main/java/com/mapcode/MapcodeCodec.java#L350-L354 |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/util/BrokerHelper.java | BrokerHelper.assertValidPkForDelete | public boolean assertValidPkForDelete(ClassDescriptor cld, Object obj) {
"""
returns true if the primary key fields are valid for delete, else false.
PK fields are valid if each of them contains a valid non-null value
@param cld the ClassDescriptor
@param obj the object
@return boolean
"""
if(!ProxyHelper.isProxy(obj))
{
FieldDescriptor fieldDescriptors[] = cld.getPkFields();
int fieldDescriptorSize = fieldDescriptors.length;
for(int i = 0; i < fieldDescriptorSize; i++)
{
FieldDescriptor fd = fieldDescriptors[i];
Object pkValue = fd.getPersistentField().get(obj);
if (representsNull(fd, pkValue))
{
return false;
}
}
}
return true;
} | java | public boolean assertValidPkForDelete(ClassDescriptor cld, Object obj)
{
if(!ProxyHelper.isProxy(obj))
{
FieldDescriptor fieldDescriptors[] = cld.getPkFields();
int fieldDescriptorSize = fieldDescriptors.length;
for(int i = 0; i < fieldDescriptorSize; i++)
{
FieldDescriptor fd = fieldDescriptors[i];
Object pkValue = fd.getPersistentField().get(obj);
if (representsNull(fd, pkValue))
{
return false;
}
}
}
return true;
} | [
"public",
"boolean",
"assertValidPkForDelete",
"(",
"ClassDescriptor",
"cld",
",",
"Object",
"obj",
")",
"{",
"if",
"(",
"!",
"ProxyHelper",
".",
"isProxy",
"(",
"obj",
")",
")",
"{",
"FieldDescriptor",
"fieldDescriptors",
"[",
"]",
"=",
"cld",
".",
"getPkFields",
"(",
")",
";",
"int",
"fieldDescriptorSize",
"=",
"fieldDescriptors",
".",
"length",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"fieldDescriptorSize",
";",
"i",
"++",
")",
"{",
"FieldDescriptor",
"fd",
"=",
"fieldDescriptors",
"[",
"i",
"]",
";",
"Object",
"pkValue",
"=",
"fd",
".",
"getPersistentField",
"(",
")",
".",
"get",
"(",
"obj",
")",
";",
"if",
"(",
"representsNull",
"(",
"fd",
",",
"pkValue",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"return",
"true",
";",
"}"
] | returns true if the primary key fields are valid for delete, else false.
PK fields are valid if each of them contains a valid non-null value
@param cld the ClassDescriptor
@param obj the object
@return boolean | [
"returns",
"true",
"if",
"the",
"primary",
"key",
"fields",
"are",
"valid",
"for",
"delete",
"else",
"false",
".",
"PK",
"fields",
"are",
"valid",
"if",
"each",
"of",
"them",
"contains",
"a",
"valid",
"non",
"-",
"null",
"value"
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/BrokerHelper.java#L475-L492 |
MGunlogson/CuckooFilter4J | src/main/java/com/github/mgunlogson/cuckoofilter4j/RamUsageEstimator.java | RamUsageEstimator.humanReadableUnits | static String humanReadableUnits(long bytes) {
"""
Returns <code>size</code> in human-readable units (GB, MB, KB or bytes).
"""
return humanReadableUnits(bytes,
new DecimalFormat("0.#", DecimalFormatSymbols.getInstance(Locale.ROOT)));
} | java | static String humanReadableUnits(long bytes) {
return humanReadableUnits(bytes,
new DecimalFormat("0.#", DecimalFormatSymbols.getInstance(Locale.ROOT)));
} | [
"static",
"String",
"humanReadableUnits",
"(",
"long",
"bytes",
")",
"{",
"return",
"humanReadableUnits",
"(",
"bytes",
",",
"new",
"DecimalFormat",
"(",
"\"0.#\"",
",",
"DecimalFormatSymbols",
".",
"getInstance",
"(",
"Locale",
".",
"ROOT",
")",
")",
")",
";",
"}"
] | Returns <code>size</code> in human-readable units (GB, MB, KB or bytes). | [
"Returns",
"<code",
">",
"size<",
"/",
"code",
">",
"in",
"human",
"-",
"readable",
"units",
"(",
"GB",
"MB",
"KB",
"or",
"bytes",
")",
"."
] | train | https://github.com/MGunlogson/CuckooFilter4J/blob/e8472aa150b201f05046d1c81cac5a5ca4348db8/src/main/java/com/github/mgunlogson/cuckoofilter4j/RamUsageEstimator.java#L386-L389 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/net/Socks4Message.java | Socks4Message.getString | private String getString(int offset, int maxLength) {
"""
Get a String from the buffer at the offset given. The method reads until
it encounters a null value or reaches the maxLength given.
"""
int index = offset;
int lastIndex = index + maxLength;
while (index < lastIndex && (buffer[index] != 0)) {
index++;
}
return new String(buffer, offset, index - offset, StandardCharsets.ISO_8859_1);
} | java | private String getString(int offset, int maxLength) {
int index = offset;
int lastIndex = index + maxLength;
while (index < lastIndex && (buffer[index] != 0)) {
index++;
}
return new String(buffer, offset, index - offset, StandardCharsets.ISO_8859_1);
} | [
"private",
"String",
"getString",
"(",
"int",
"offset",
",",
"int",
"maxLength",
")",
"{",
"int",
"index",
"=",
"offset",
";",
"int",
"lastIndex",
"=",
"index",
"+",
"maxLength",
";",
"while",
"(",
"index",
"<",
"lastIndex",
"&&",
"(",
"buffer",
"[",
"index",
"]",
"!=",
"0",
")",
")",
"{",
"index",
"++",
";",
"}",
"return",
"new",
"String",
"(",
"buffer",
",",
"offset",
",",
"index",
"-",
"offset",
",",
"StandardCharsets",
".",
"ISO_8859_1",
")",
";",
"}"
] | Get a String from the buffer at the offset given. The method reads until
it encounters a null value or reaches the maxLength given. | [
"Get",
"a",
"String",
"from",
"the",
"buffer",
"at",
"the",
"offset",
"given",
".",
"The",
"method",
"reads",
"until",
"it",
"encounters",
"a",
"null",
"value",
"or",
"reaches",
"the",
"maxLength",
"given",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/net/Socks4Message.java#L185-L192 |
apache/incubator-gobblin | gobblin-utility/src/main/java/org/apache/gobblin/util/HadoopUtils.java | HadoopUtils.renamePath | public static void renamePath(FileContext fc, Path oldName, Path newName) throws IOException {
"""
A wrapper around {@link FileContext#rename(Path, Path, Options.Rename...)}.
"""
renamePath(fc, oldName, newName, false);
} | java | public static void renamePath(FileContext fc, Path oldName, Path newName) throws IOException {
renamePath(fc, oldName, newName, false);
} | [
"public",
"static",
"void",
"renamePath",
"(",
"FileContext",
"fc",
",",
"Path",
"oldName",
",",
"Path",
"newName",
")",
"throws",
"IOException",
"{",
"renamePath",
"(",
"fc",
",",
"oldName",
",",
"newName",
",",
"false",
")",
";",
"}"
] | A wrapper around {@link FileContext#rename(Path, Path, Options.Rename...)}. | [
"A",
"wrapper",
"around",
"{"
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/HadoopUtils.java#L243-L245 |
cdk/cdk | display/renderbasic/src/main/java/org/openscience/cdk/renderer/generators/standard/SelectionVisibility.java | SelectionVisibility.isSelected | static boolean isSelected(IChemObject object, RendererModel model) {
"""
Determine if an object is selected.
@param object the object
@return object is selected
"""
if (object.getProperty(StandardGenerator.HIGHLIGHT_COLOR) != null) return true;
if (model.getSelection() != null) return model.getSelection().contains(object);
return false;
} | java | static boolean isSelected(IChemObject object, RendererModel model) {
if (object.getProperty(StandardGenerator.HIGHLIGHT_COLOR) != null) return true;
if (model.getSelection() != null) return model.getSelection().contains(object);
return false;
} | [
"static",
"boolean",
"isSelected",
"(",
"IChemObject",
"object",
",",
"RendererModel",
"model",
")",
"{",
"if",
"(",
"object",
".",
"getProperty",
"(",
"StandardGenerator",
".",
"HIGHLIGHT_COLOR",
")",
"!=",
"null",
")",
"return",
"true",
";",
"if",
"(",
"model",
".",
"getSelection",
"(",
")",
"!=",
"null",
")",
"return",
"model",
".",
"getSelection",
"(",
")",
".",
"contains",
"(",
"object",
")",
";",
"return",
"false",
";",
"}"
] | Determine if an object is selected.
@param object the object
@return object is selected | [
"Determine",
"if",
"an",
"object",
"is",
"selected",
"."
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/display/renderbasic/src/main/java/org/openscience/cdk/renderer/generators/standard/SelectionVisibility.java#L99-L103 |
Wikidata/Wikidata-Toolkit | wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/helpers/EntityDocumentBuilder.java | EntityDocumentBuilder.withLabel | public T withLabel(String text, String languageCode) {
"""
Adds an additional label to the constructed document.
@param text
the text of the label
@param languageCode
the language code of the label
@return builder object to continue construction
"""
withLabel(factory.getMonolingualTextValue(text, languageCode));
return getThis();
} | java | public T withLabel(String text, String languageCode) {
withLabel(factory.getMonolingualTextValue(text, languageCode));
return getThis();
} | [
"public",
"T",
"withLabel",
"(",
"String",
"text",
",",
"String",
"languageCode",
")",
"{",
"withLabel",
"(",
"factory",
".",
"getMonolingualTextValue",
"(",
"text",
",",
"languageCode",
")",
")",
";",
"return",
"getThis",
"(",
")",
";",
"}"
] | Adds an additional label to the constructed document.
@param text
the text of the label
@param languageCode
the language code of the label
@return builder object to continue construction | [
"Adds",
"an",
"additional",
"label",
"to",
"the",
"constructed",
"document",
"."
] | train | https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/helpers/EntityDocumentBuilder.java#L123-L126 |
fernandospr/javapns-jdk16 | src/main/java/javapns/notification/PushNotificationPayload.java | PushNotificationPayload.combined | public static PushNotificationPayload combined(String message, int badge, String sound) {
"""
Create a pre-defined payload with a simple alert message, a badge and a sound.
@param message the alert message
@param badge the badge
@param sound the name of the sound
@return a ready-to-send payload
"""
if (message == null && badge < 0 && sound == null) throw new IllegalArgumentException("Must provide at least one non-null argument");
PushNotificationPayload payload = complex();
try {
if (message != null) payload.addAlert(message);
if (badge >= 0) payload.addBadge(badge);
if (sound != null) payload.addSound(sound);
} catch (JSONException e) {
}
return payload;
} | java | public static PushNotificationPayload combined(String message, int badge, String sound) {
if (message == null && badge < 0 && sound == null) throw new IllegalArgumentException("Must provide at least one non-null argument");
PushNotificationPayload payload = complex();
try {
if (message != null) payload.addAlert(message);
if (badge >= 0) payload.addBadge(badge);
if (sound != null) payload.addSound(sound);
} catch (JSONException e) {
}
return payload;
} | [
"public",
"static",
"PushNotificationPayload",
"combined",
"(",
"String",
"message",
",",
"int",
"badge",
",",
"String",
"sound",
")",
"{",
"if",
"(",
"message",
"==",
"null",
"&&",
"badge",
"<",
"0",
"&&",
"sound",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Must provide at least one non-null argument\"",
")",
";",
"PushNotificationPayload",
"payload",
"=",
"complex",
"(",
")",
";",
"try",
"{",
"if",
"(",
"message",
"!=",
"null",
")",
"payload",
".",
"addAlert",
"(",
"message",
")",
";",
"if",
"(",
"badge",
">=",
"0",
")",
"payload",
".",
"addBadge",
"(",
"badge",
")",
";",
"if",
"(",
"sound",
"!=",
"null",
")",
"payload",
".",
"addSound",
"(",
"sound",
")",
";",
"}",
"catch",
"(",
"JSONException",
"e",
")",
"{",
"}",
"return",
"payload",
";",
"}"
] | Create a pre-defined payload with a simple alert message, a badge and a sound.
@param message the alert message
@param badge the badge
@param sound the name of the sound
@return a ready-to-send payload | [
"Create",
"a",
"pre",
"-",
"defined",
"payload",
"with",
"a",
"simple",
"alert",
"message",
"a",
"badge",
"and",
"a",
"sound",
"."
] | train | https://github.com/fernandospr/javapns-jdk16/blob/84de6d9328ab01af92f77cc60c4554de02420909/src/main/java/javapns/notification/PushNotificationPayload.java#L80-L90 |
albfernandez/itext2 | src/main/java/com/lowagie/text/pdf/PdfCell.java | PdfCell.addImage | private float addImage(Image i, float left, float right, float extraHeight, int alignment) {
"""
Adds an image to this Cell.
@param i the image to add
@param left the left border
@param right the right border
@param extraHeight extra height to add above image
@param alignment horizontal alignment (constant from Element class)
@return the height of the image
"""
Image image = Image.getInstance(i);
if (image.getScaledWidth() > right - left) {
image.scaleToFit(right - left, Float.MAX_VALUE);
}
flushCurrentLine();
if (line == null) {
line = new PdfLine(left, right, alignment, leading);
}
PdfLine imageLine = line;
// left and right in chunk is relative to the start of the line
right = right - left;
left = 0f;
if ((image.getAlignment() & Image.RIGHT) == Image.RIGHT) {
left = right - image.getScaledWidth();
} else if ((image.getAlignment() & Image.MIDDLE) == Image.MIDDLE) {
left = left + ((right - left - image.getScaledWidth()) / 2f);
}
Chunk imageChunk = new Chunk(image, left, 0);
imageLine.add(new PdfChunk(imageChunk, null));
addLine(imageLine);
return imageLine.height();
} | java | private float addImage(Image i, float left, float right, float extraHeight, int alignment) {
Image image = Image.getInstance(i);
if (image.getScaledWidth() > right - left) {
image.scaleToFit(right - left, Float.MAX_VALUE);
}
flushCurrentLine();
if (line == null) {
line = new PdfLine(left, right, alignment, leading);
}
PdfLine imageLine = line;
// left and right in chunk is relative to the start of the line
right = right - left;
left = 0f;
if ((image.getAlignment() & Image.RIGHT) == Image.RIGHT) {
left = right - image.getScaledWidth();
} else if ((image.getAlignment() & Image.MIDDLE) == Image.MIDDLE) {
left = left + ((right - left - image.getScaledWidth()) / 2f);
}
Chunk imageChunk = new Chunk(image, left, 0);
imageLine.add(new PdfChunk(imageChunk, null));
addLine(imageLine);
return imageLine.height();
} | [
"private",
"float",
"addImage",
"(",
"Image",
"i",
",",
"float",
"left",
",",
"float",
"right",
",",
"float",
"extraHeight",
",",
"int",
"alignment",
")",
"{",
"Image",
"image",
"=",
"Image",
".",
"getInstance",
"(",
"i",
")",
";",
"if",
"(",
"image",
".",
"getScaledWidth",
"(",
")",
">",
"right",
"-",
"left",
")",
"{",
"image",
".",
"scaleToFit",
"(",
"right",
"-",
"left",
",",
"Float",
".",
"MAX_VALUE",
")",
";",
"}",
"flushCurrentLine",
"(",
")",
";",
"if",
"(",
"line",
"==",
"null",
")",
"{",
"line",
"=",
"new",
"PdfLine",
"(",
"left",
",",
"right",
",",
"alignment",
",",
"leading",
")",
";",
"}",
"PdfLine",
"imageLine",
"=",
"line",
";",
"// left and right in chunk is relative to the start of the line",
"right",
"=",
"right",
"-",
"left",
";",
"left",
"=",
"0f",
";",
"if",
"(",
"(",
"image",
".",
"getAlignment",
"(",
")",
"&",
"Image",
".",
"RIGHT",
")",
"==",
"Image",
".",
"RIGHT",
")",
"{",
"left",
"=",
"right",
"-",
"image",
".",
"getScaledWidth",
"(",
")",
";",
"}",
"else",
"if",
"(",
"(",
"image",
".",
"getAlignment",
"(",
")",
"&",
"Image",
".",
"MIDDLE",
")",
"==",
"Image",
".",
"MIDDLE",
")",
"{",
"left",
"=",
"left",
"+",
"(",
"(",
"right",
"-",
"left",
"-",
"image",
".",
"getScaledWidth",
"(",
")",
")",
"/",
"2f",
")",
";",
"}",
"Chunk",
"imageChunk",
"=",
"new",
"Chunk",
"(",
"image",
",",
"left",
",",
"0",
")",
";",
"imageLine",
".",
"add",
"(",
"new",
"PdfChunk",
"(",
"imageChunk",
",",
"null",
")",
")",
";",
"addLine",
"(",
"imageLine",
")",
";",
"return",
"imageLine",
".",
"height",
"(",
")",
";",
"}"
] | Adds an image to this Cell.
@param i the image to add
@param left the left border
@param right the right border
@param extraHeight extra height to add above image
@param alignment horizontal alignment (constant from Element class)
@return the height of the image | [
"Adds",
"an",
"image",
"to",
"this",
"Cell",
"."
] | train | https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/pdf/PdfCell.java#L529-L553 |
zaproxy/zaproxy | src/org/apache/commons/httpclient/URI.java | URI.getRawCurrentHierPath | protected char[] getRawCurrentHierPath(char[] path) throws URIException {
"""
Get the raw-escaped current hierarchy level in the given path.
If the last namespace is a collection, the slash mark ('/') should be
ended with at the last character of the path string.
@param path the path
@return the current hierarchy level
@throws URIException no hierarchy level
"""
if (_is_opaque_part) {
throw new URIException(URIException.PARSING, "no hierarchy level");
}
if (path == null) {
throw new URIException(URIException.PARSING, "empty path");
}
String buff = new String(path);
int first = buff.indexOf('/');
int last = buff.lastIndexOf('/');
if (last == 0) {
return rootPath;
} else if (first != last && last != -1) {
return buff.substring(0, last).toCharArray();
}
// FIXME: it could be a document on the server side
return path;
} | java | protected char[] getRawCurrentHierPath(char[] path) throws URIException {
if (_is_opaque_part) {
throw new URIException(URIException.PARSING, "no hierarchy level");
}
if (path == null) {
throw new URIException(URIException.PARSING, "empty path");
}
String buff = new String(path);
int first = buff.indexOf('/');
int last = buff.lastIndexOf('/');
if (last == 0) {
return rootPath;
} else if (first != last && last != -1) {
return buff.substring(0, last).toCharArray();
}
// FIXME: it could be a document on the server side
return path;
} | [
"protected",
"char",
"[",
"]",
"getRawCurrentHierPath",
"(",
"char",
"[",
"]",
"path",
")",
"throws",
"URIException",
"{",
"if",
"(",
"_is_opaque_part",
")",
"{",
"throw",
"new",
"URIException",
"(",
"URIException",
".",
"PARSING",
",",
"\"no hierarchy level\"",
")",
";",
"}",
"if",
"(",
"path",
"==",
"null",
")",
"{",
"throw",
"new",
"URIException",
"(",
"URIException",
".",
"PARSING",
",",
"\"empty path\"",
")",
";",
"}",
"String",
"buff",
"=",
"new",
"String",
"(",
"path",
")",
";",
"int",
"first",
"=",
"buff",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"int",
"last",
"=",
"buff",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"last",
"==",
"0",
")",
"{",
"return",
"rootPath",
";",
"}",
"else",
"if",
"(",
"first",
"!=",
"last",
"&&",
"last",
"!=",
"-",
"1",
")",
"{",
"return",
"buff",
".",
"substring",
"(",
"0",
",",
"last",
")",
".",
"toCharArray",
"(",
")",
";",
"}",
"// FIXME: it could be a document on the server side",
"return",
"path",
";",
"}"
] | Get the raw-escaped current hierarchy level in the given path.
If the last namespace is a collection, the slash mark ('/') should be
ended with at the last character of the path string.
@param path the path
@return the current hierarchy level
@throws URIException no hierarchy level | [
"Get",
"the",
"raw",
"-",
"escaped",
"current",
"hierarchy",
"level",
"in",
"the",
"given",
"path",
".",
"If",
"the",
"last",
"namespace",
"is",
"a",
"collection",
"the",
"slash",
"mark",
"(",
"/",
")",
"should",
"be",
"ended",
"with",
"at",
"the",
"last",
"character",
"of",
"the",
"path",
"string",
"."
] | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/apache/commons/httpclient/URI.java#L2995-L3013 |
xwiki/xwiki-commons | xwiki-commons-core/xwiki-commons-crypto/xwiki-commons-crypto-pkix/src/main/java/org/xwiki/crypto/signer/internal/cms/BcStoreUtils.java | BcStoreUtils.getCertificateProvider | public static CertificateProvider getCertificateProvider(ComponentManager manager,
Collection<CertifiedPublicKey> certificates) throws GeneralSecurityException {
"""
Create a new store containing the given certificates and return it as a certificate provider.
@param manager the component manager.
@param certificates the certificates.
@return a certificate provider wrapping the collection of certificate.
@throws GeneralSecurityException if unable to initialize the provider.
"""
if (certificates == null || certificates.isEmpty()) {
return null;
}
Collection<X509CertificateHolder> certs = new ArrayList<X509CertificateHolder>(certificates.size());
for (CertifiedPublicKey cert : certificates) {
certs.add(BcUtils.getX509CertificateHolder(cert));
}
return newCertificateProvider(manager, new CollectionStore(certs));
} | java | public static CertificateProvider getCertificateProvider(ComponentManager manager,
Collection<CertifiedPublicKey> certificates) throws GeneralSecurityException
{
if (certificates == null || certificates.isEmpty()) {
return null;
}
Collection<X509CertificateHolder> certs = new ArrayList<X509CertificateHolder>(certificates.size());
for (CertifiedPublicKey cert : certificates) {
certs.add(BcUtils.getX509CertificateHolder(cert));
}
return newCertificateProvider(manager, new CollectionStore(certs));
} | [
"public",
"static",
"CertificateProvider",
"getCertificateProvider",
"(",
"ComponentManager",
"manager",
",",
"Collection",
"<",
"CertifiedPublicKey",
">",
"certificates",
")",
"throws",
"GeneralSecurityException",
"{",
"if",
"(",
"certificates",
"==",
"null",
"||",
"certificates",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"Collection",
"<",
"X509CertificateHolder",
">",
"certs",
"=",
"new",
"ArrayList",
"<",
"X509CertificateHolder",
">",
"(",
"certificates",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"CertifiedPublicKey",
"cert",
":",
"certificates",
")",
"{",
"certs",
".",
"add",
"(",
"BcUtils",
".",
"getX509CertificateHolder",
"(",
"cert",
")",
")",
";",
"}",
"return",
"newCertificateProvider",
"(",
"manager",
",",
"new",
"CollectionStore",
"(",
"certs",
")",
")",
";",
"}"
] | Create a new store containing the given certificates and return it as a certificate provider.
@param manager the component manager.
@param certificates the certificates.
@return a certificate provider wrapping the collection of certificate.
@throws GeneralSecurityException if unable to initialize the provider. | [
"Create",
"a",
"new",
"store",
"containing",
"the",
"given",
"certificates",
"and",
"return",
"it",
"as",
"a",
"certificate",
"provider",
"."
] | train | https://github.com/xwiki/xwiki-commons/blob/5374d8c6d966588c1eac7392c83da610dfb9f129/xwiki-commons-core/xwiki-commons-crypto/xwiki-commons-crypto-pkix/src/main/java/org/xwiki/crypto/signer/internal/cms/BcStoreUtils.java#L102-L116 |
tbrooks8/Precipice | precipice-core/src/main/java/net/uncontended/precipice/GuardRail.java | GuardRail.releasePermits | public void releasePermits(long number, Result result, long startNanos, long nanoTime) {
"""
Release acquired permits with known result. Since there is a known result the result
count object and latency will be updated.
@param number of permits to release
@param result of the execution
@param startNanos of the execution
@param nanoTime currentInterval nano time
"""
resultCounts.write(result, number, nanoTime);
resultLatency.write(result, number, nanoTime - startNanos, nanoTime);
for (BackPressure<Rejected> backPressure : backPressureList) {
backPressure.releasePermit(number, result, nanoTime);
}
} | java | public void releasePermits(long number, Result result, long startNanos, long nanoTime) {
resultCounts.write(result, number, nanoTime);
resultLatency.write(result, number, nanoTime - startNanos, nanoTime);
for (BackPressure<Rejected> backPressure : backPressureList) {
backPressure.releasePermit(number, result, nanoTime);
}
} | [
"public",
"void",
"releasePermits",
"(",
"long",
"number",
",",
"Result",
"result",
",",
"long",
"startNanos",
",",
"long",
"nanoTime",
")",
"{",
"resultCounts",
".",
"write",
"(",
"result",
",",
"number",
",",
"nanoTime",
")",
";",
"resultLatency",
".",
"write",
"(",
"result",
",",
"number",
",",
"nanoTime",
"-",
"startNanos",
",",
"nanoTime",
")",
";",
"for",
"(",
"BackPressure",
"<",
"Rejected",
">",
"backPressure",
":",
"backPressureList",
")",
"{",
"backPressure",
".",
"releasePermit",
"(",
"number",
",",
"result",
",",
"nanoTime",
")",
";",
"}",
"}"
] | Release acquired permits with known result. Since there is a known result the result
count object and latency will be updated.
@param number of permits to release
@param result of the execution
@param startNanos of the execution
@param nanoTime currentInterval nano time | [
"Release",
"acquired",
"permits",
"with",
"known",
"result",
".",
"Since",
"there",
"is",
"a",
"known",
"result",
"the",
"result",
"count",
"object",
"and",
"latency",
"will",
"be",
"updated",
"."
] | train | https://github.com/tbrooks8/Precipice/blob/97fae467fd676b16a96b8d88b02569d8fc1f2681/precipice-core/src/main/java/net/uncontended/precipice/GuardRail.java#L152-L159 |
atomix/atomix | core/src/main/java/io/atomix/core/registry/ClasspathScanningRegistry.java | ClasspathScanningRegistry.newInstance | @SuppressWarnings("unchecked")
private static <T> T newInstance(Class<?> type) {
"""
Instantiates the given type using a no-argument constructor.
@param type the type to instantiate
@param <T> the generic type
@return the instantiated object
@throws ServiceException if the type cannot be instantiated
"""
try {
return (T) type.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
throw new ServiceException("Cannot instantiate service class " + type, e);
}
} | java | @SuppressWarnings("unchecked")
private static <T> T newInstance(Class<?> type) {
try {
return (T) type.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
throw new ServiceException("Cannot instantiate service class " + type, e);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"static",
"<",
"T",
">",
"T",
"newInstance",
"(",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"try",
"{",
"return",
"(",
"T",
")",
"type",
".",
"newInstance",
"(",
")",
";",
"}",
"catch",
"(",
"InstantiationException",
"|",
"IllegalAccessException",
"e",
")",
"{",
"throw",
"new",
"ServiceException",
"(",
"\"Cannot instantiate service class \"",
"+",
"type",
",",
"e",
")",
";",
"}",
"}"
] | Instantiates the given type using a no-argument constructor.
@param type the type to instantiate
@param <T> the generic type
@return the instantiated object
@throws ServiceException if the type cannot be instantiated | [
"Instantiates",
"the",
"given",
"type",
"using",
"a",
"no",
"-",
"argument",
"constructor",
"."
] | train | https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/core/src/main/java/io/atomix/core/registry/ClasspathScanningRegistry.java#L128-L135 |
jpush/jmessage-api-java-client | src/main/java/cn/jmessage/api/JMessageClient.java | JMessageClient.v2GetUserMessagesByCursor | public MessageListResult v2GetUserMessagesByCursor(String username, String cursor)
throws APIConnectionException, APIRequestException {
"""
Get user's message list with cursor, the cursor will effective in 120 seconds.
And will return same count of messages as first request.
@param username Necessary parameter.
@param cursor First request will return cursor
@return MessageListResult
@throws APIConnectionException connect exception
@throws APIRequestException request exception
"""
return _reportClient.v2GetUserMessagesByCursor(username, cursor);
} | java | public MessageListResult v2GetUserMessagesByCursor(String username, String cursor)
throws APIConnectionException, APIRequestException {
return _reportClient.v2GetUserMessagesByCursor(username, cursor);
} | [
"public",
"MessageListResult",
"v2GetUserMessagesByCursor",
"(",
"String",
"username",
",",
"String",
"cursor",
")",
"throws",
"APIConnectionException",
",",
"APIRequestException",
"{",
"return",
"_reportClient",
".",
"v2GetUserMessagesByCursor",
"(",
"username",
",",
"cursor",
")",
";",
"}"
] | Get user's message list with cursor, the cursor will effective in 120 seconds.
And will return same count of messages as first request.
@param username Necessary parameter.
@param cursor First request will return cursor
@return MessageListResult
@throws APIConnectionException connect exception
@throws APIRequestException request exception | [
"Get",
"user",
"s",
"message",
"list",
"with",
"cursor",
"the",
"cursor",
"will",
"effective",
"in",
"120",
"seconds",
".",
"And",
"will",
"return",
"same",
"count",
"of",
"messages",
"as",
"first",
"request",
"."
] | train | https://github.com/jpush/jmessage-api-java-client/blob/767f5fb15e9fe5a546c00f6e68b64f6dd53c617c/src/main/java/cn/jmessage/api/JMessageClient.java#L982-L985 |
leadware/jpersistence-tools | jpersistence-tools-core/src/main/java/net/leadware/persistence/tools/core/dao/impl/JPAGenericDAORulesBasedImpl.java | JPAGenericDAORulesBasedImpl.validateEntityIntegrityConstraint | protected void validateEntityIntegrityConstraint(Object entity, DAOMode mode, DAOValidatorEvaluationTime validationTime) {
"""
Méthode de validation des contraintes d'integrités
@param entity Entité à valider
@param mode Mode DAO
@param validationTime Moment d'évaluation
"""
// Validation des contraintes d'integrites
JSR303ValidatorEngine.getDefaultInstance().validate(entity);
} | java | protected void validateEntityIntegrityConstraint(Object entity, DAOMode mode, DAOValidatorEvaluationTime validationTime) {
// Validation des contraintes d'integrites
JSR303ValidatorEngine.getDefaultInstance().validate(entity);
} | [
"protected",
"void",
"validateEntityIntegrityConstraint",
"(",
"Object",
"entity",
",",
"DAOMode",
"mode",
",",
"DAOValidatorEvaluationTime",
"validationTime",
")",
"{",
"// Validation des contraintes d'integrites\r",
"JSR303ValidatorEngine",
".",
"getDefaultInstance",
"(",
")",
".",
"validate",
"(",
"entity",
")",
";",
"}"
] | Méthode de validation des contraintes d'integrités
@param entity Entité à valider
@param mode Mode DAO
@param validationTime Moment d'évaluation | [
"Méthode",
"de",
"validation",
"des",
"contraintes",
"d",
"integrités"
] | train | https://github.com/leadware/jpersistence-tools/blob/4c15372993584579d7dbb9b23dd4c0c0fdc9e789/jpersistence-tools-core/src/main/java/net/leadware/persistence/tools/core/dao/impl/JPAGenericDAORulesBasedImpl.java#L791-L795 |
sagiegurari/fax4j | src/main/java/org/fax4j/spi/email/AbstractMailFaxClientSpi.java | AbstractMailFaxClientSpi.sendMail | protected void sendMail(FaxJob faxJob,Connection<MailResourcesHolder> mailConnection,Message message) {
"""
This function will send the mail message.
@param faxJob
The fax job object containing the needed information
@param mailConnection
The mail connection (will be released if not persistent)
@param message
The message to send
"""
if(message==null)
{
this.throwUnsupportedException();
}
else
{
//get holder
MailResourcesHolder mailResourcesHolder=mailConnection.getResource();
//get transport
Transport transport=mailResourcesHolder.getTransport();
try
{
//send message
message.saveChanges();
if(transport==null)
{
Transport.send(message,message.getAllRecipients());
}
else
{
transport.sendMessage(message,message.getAllRecipients());
}
}
catch(Throwable throwable)
{
throw new FaxException("Unable to send message.",throwable);
}
finally
{
if(!this.usePersistentConnection)
{
try
{
//close connection
this.closeMailConnection(mailConnection);
}
catch(Exception exception)
{
//log error
Logger logger=this.getLogger();
logger.logInfo(new Object[]{"Error while releasing mail connection."},exception);
}
}
}
}
} | java | protected void sendMail(FaxJob faxJob,Connection<MailResourcesHolder> mailConnection,Message message)
{
if(message==null)
{
this.throwUnsupportedException();
}
else
{
//get holder
MailResourcesHolder mailResourcesHolder=mailConnection.getResource();
//get transport
Transport transport=mailResourcesHolder.getTransport();
try
{
//send message
message.saveChanges();
if(transport==null)
{
Transport.send(message,message.getAllRecipients());
}
else
{
transport.sendMessage(message,message.getAllRecipients());
}
}
catch(Throwable throwable)
{
throw new FaxException("Unable to send message.",throwable);
}
finally
{
if(!this.usePersistentConnection)
{
try
{
//close connection
this.closeMailConnection(mailConnection);
}
catch(Exception exception)
{
//log error
Logger logger=this.getLogger();
logger.logInfo(new Object[]{"Error while releasing mail connection."},exception);
}
}
}
}
} | [
"protected",
"void",
"sendMail",
"(",
"FaxJob",
"faxJob",
",",
"Connection",
"<",
"MailResourcesHolder",
">",
"mailConnection",
",",
"Message",
"message",
")",
"{",
"if",
"(",
"message",
"==",
"null",
")",
"{",
"this",
".",
"throwUnsupportedException",
"(",
")",
";",
"}",
"else",
"{",
"//get holder",
"MailResourcesHolder",
"mailResourcesHolder",
"=",
"mailConnection",
".",
"getResource",
"(",
")",
";",
"//get transport",
"Transport",
"transport",
"=",
"mailResourcesHolder",
".",
"getTransport",
"(",
")",
";",
"try",
"{",
"//send message",
"message",
".",
"saveChanges",
"(",
")",
";",
"if",
"(",
"transport",
"==",
"null",
")",
"{",
"Transport",
".",
"send",
"(",
"message",
",",
"message",
".",
"getAllRecipients",
"(",
")",
")",
";",
"}",
"else",
"{",
"transport",
".",
"sendMessage",
"(",
"message",
",",
"message",
".",
"getAllRecipients",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"throwable",
")",
"{",
"throw",
"new",
"FaxException",
"(",
"\"Unable to send message.\"",
",",
"throwable",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"!",
"this",
".",
"usePersistentConnection",
")",
"{",
"try",
"{",
"//close connection",
"this",
".",
"closeMailConnection",
"(",
"mailConnection",
")",
";",
"}",
"catch",
"(",
"Exception",
"exception",
")",
"{",
"//log error",
"Logger",
"logger",
"=",
"this",
".",
"getLogger",
"(",
")",
";",
"logger",
".",
"logInfo",
"(",
"new",
"Object",
"[",
"]",
"{",
"\"Error while releasing mail connection.\"",
"}",
",",
"exception",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | This function will send the mail message.
@param faxJob
The fax job object containing the needed information
@param mailConnection
The mail connection (will be released if not persistent)
@param message
The message to send | [
"This",
"function",
"will",
"send",
"the",
"mail",
"message",
"."
] | train | https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/email/AbstractMailFaxClientSpi.java#L323-L372 |
sniffy/sniffy | sniffy-core/src/main/java/io/sniffy/LegacySpy.java | LegacySpy.expectAtLeast | @Deprecated
public C expectAtLeast(int allowedStatements, Threads threadMatcher, Query query) {
"""
Alias for {@link #expectBetween(int, int, Threads, Query)} with arguments {@code allowedStatements}, {@link Integer#MAX_VALUE}, {@code threads}, {@code queryType}
@since 2.2
"""
return expect(SqlQueries.minQueries(allowedStatements).threads(threadMatcher).type(adapter(query)));
} | java | @Deprecated
public C expectAtLeast(int allowedStatements, Threads threadMatcher, Query query) {
return expect(SqlQueries.minQueries(allowedStatements).threads(threadMatcher).type(adapter(query)));
} | [
"@",
"Deprecated",
"public",
"C",
"expectAtLeast",
"(",
"int",
"allowedStatements",
",",
"Threads",
"threadMatcher",
",",
"Query",
"query",
")",
"{",
"return",
"expect",
"(",
"SqlQueries",
".",
"minQueries",
"(",
"allowedStatements",
")",
".",
"threads",
"(",
"threadMatcher",
")",
".",
"type",
"(",
"adapter",
"(",
"query",
")",
")",
")",
";",
"}"
] | Alias for {@link #expectBetween(int, int, Threads, Query)} with arguments {@code allowedStatements}, {@link Integer#MAX_VALUE}, {@code threads}, {@code queryType}
@since 2.2 | [
"Alias",
"for",
"{"
] | train | https://github.com/sniffy/sniffy/blob/7bdddb9593e6b6e9fe5c7c87519f864acbc3a5c0/sniffy-core/src/main/java/io/sniffy/LegacySpy.java#L521-L524 |
apache/flink | flink-streaming-java/src/main/java/org/apache/flink/streaming/api/datastream/WindowedStream.java | WindowedStream.process | @PublicEvolving
public <R> SingleOutputStreamOperator<R> process(ProcessWindowFunction<T, R, K, W> function) {
"""
Applies the given window function to each window. The window function is called for each
evaluation of the window for each key individually. The output of the window function is
interpreted as a regular non-windowed stream.
<p>Note that this function requires that all data in the windows is buffered until the window
is evaluated, as the function provides no means of incremental aggregation.
@param function The window function.
@return The data stream that is the result of applying the window function to the window.
"""
TypeInformation<R> resultType = getProcessWindowFunctionReturnType(function, getInputType(), null);
return process(function, resultType);
} | java | @PublicEvolving
public <R> SingleOutputStreamOperator<R> process(ProcessWindowFunction<T, R, K, W> function) {
TypeInformation<R> resultType = getProcessWindowFunctionReturnType(function, getInputType(), null);
return process(function, resultType);
} | [
"@",
"PublicEvolving",
"public",
"<",
"R",
">",
"SingleOutputStreamOperator",
"<",
"R",
">",
"process",
"(",
"ProcessWindowFunction",
"<",
"T",
",",
"R",
",",
"K",
",",
"W",
">",
"function",
")",
"{",
"TypeInformation",
"<",
"R",
">",
"resultType",
"=",
"getProcessWindowFunctionReturnType",
"(",
"function",
",",
"getInputType",
"(",
")",
",",
"null",
")",
";",
"return",
"process",
"(",
"function",
",",
"resultType",
")",
";",
"}"
] | Applies the given window function to each window. The window function is called for each
evaluation of the window for each key individually. The output of the window function is
interpreted as a regular non-windowed stream.
<p>Note that this function requires that all data in the windows is buffered until the window
is evaluated, as the function provides no means of incremental aggregation.
@param function The window function.
@return The data stream that is the result of applying the window function to the window. | [
"Applies",
"the",
"given",
"window",
"function",
"to",
"each",
"window",
".",
"The",
"window",
"function",
"is",
"called",
"for",
"each",
"evaluation",
"of",
"the",
"window",
"for",
"each",
"key",
"individually",
".",
"The",
"output",
"of",
"the",
"window",
"function",
"is",
"interpreted",
"as",
"a",
"regular",
"non",
"-",
"windowed",
"stream",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/datastream/WindowedStream.java#L1052-L1057 |
infinispan/infinispan | client/hotrod-client/src/main/java/org/infinispan/client/hotrod/event/ClientEvents.java | ClientEvents.addClientQueryListener | public static void addClientQueryListener(RemoteCache<?, ?> remoteCache, Object listener, Query query) {
"""
Register a client listener that uses a query DSL based filter. The listener is expected to be annotated such that
{@link org.infinispan.client.hotrod.annotation.ClientListener#useRawData} = true and {@link
org.infinispan.client.hotrod.annotation.ClientListener#filterFactoryName} and {@link
org.infinispan.client.hotrod.annotation.ClientListener#converterFactoryName} are equal to {@link
Filters#QUERY_DSL_FILTER_FACTORY_NAME}
@param remoteCache the remote cache to attach the listener
@param listener the listener instance
@param query the query to be used for filtering and conversion (if projections are used)
"""
ClientListener l = ReflectionUtil.getAnnotation(listener.getClass(), ClientListener.class);
if (l == null) {
throw log.missingClientListenerAnnotation(listener.getClass().getName());
}
if (!l.useRawData()) {
throw log.clientListenerMustUseRawData(listener.getClass().getName());
}
if (!l.filterFactoryName().equals(Filters.QUERY_DSL_FILTER_FACTORY_NAME)) {
throw log.clientListenerMustUseDesignatedFilterConverterFactory(Filters.QUERY_DSL_FILTER_FACTORY_NAME);
}
if (!l.converterFactoryName().equals(Filters.QUERY_DSL_FILTER_FACTORY_NAME)) {
throw log.clientListenerMustUseDesignatedFilterConverterFactory(Filters.QUERY_DSL_FILTER_FACTORY_NAME);
}
Object[] factoryParams = makeFactoryParams(query);
remoteCache.addClientListener(listener, factoryParams, null);
} | java | public static void addClientQueryListener(RemoteCache<?, ?> remoteCache, Object listener, Query query) {
ClientListener l = ReflectionUtil.getAnnotation(listener.getClass(), ClientListener.class);
if (l == null) {
throw log.missingClientListenerAnnotation(listener.getClass().getName());
}
if (!l.useRawData()) {
throw log.clientListenerMustUseRawData(listener.getClass().getName());
}
if (!l.filterFactoryName().equals(Filters.QUERY_DSL_FILTER_FACTORY_NAME)) {
throw log.clientListenerMustUseDesignatedFilterConverterFactory(Filters.QUERY_DSL_FILTER_FACTORY_NAME);
}
if (!l.converterFactoryName().equals(Filters.QUERY_DSL_FILTER_FACTORY_NAME)) {
throw log.clientListenerMustUseDesignatedFilterConverterFactory(Filters.QUERY_DSL_FILTER_FACTORY_NAME);
}
Object[] factoryParams = makeFactoryParams(query);
remoteCache.addClientListener(listener, factoryParams, null);
} | [
"public",
"static",
"void",
"addClientQueryListener",
"(",
"RemoteCache",
"<",
"?",
",",
"?",
">",
"remoteCache",
",",
"Object",
"listener",
",",
"Query",
"query",
")",
"{",
"ClientListener",
"l",
"=",
"ReflectionUtil",
".",
"getAnnotation",
"(",
"listener",
".",
"getClass",
"(",
")",
",",
"ClientListener",
".",
"class",
")",
";",
"if",
"(",
"l",
"==",
"null",
")",
"{",
"throw",
"log",
".",
"missingClientListenerAnnotation",
"(",
"listener",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"l",
".",
"useRawData",
"(",
")",
")",
"{",
"throw",
"log",
".",
"clientListenerMustUseRawData",
"(",
"listener",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"l",
".",
"filterFactoryName",
"(",
")",
".",
"equals",
"(",
"Filters",
".",
"QUERY_DSL_FILTER_FACTORY_NAME",
")",
")",
"{",
"throw",
"log",
".",
"clientListenerMustUseDesignatedFilterConverterFactory",
"(",
"Filters",
".",
"QUERY_DSL_FILTER_FACTORY_NAME",
")",
";",
"}",
"if",
"(",
"!",
"l",
".",
"converterFactoryName",
"(",
")",
".",
"equals",
"(",
"Filters",
".",
"QUERY_DSL_FILTER_FACTORY_NAME",
")",
")",
"{",
"throw",
"log",
".",
"clientListenerMustUseDesignatedFilterConverterFactory",
"(",
"Filters",
".",
"QUERY_DSL_FILTER_FACTORY_NAME",
")",
";",
"}",
"Object",
"[",
"]",
"factoryParams",
"=",
"makeFactoryParams",
"(",
"query",
")",
";",
"remoteCache",
".",
"addClientListener",
"(",
"listener",
",",
"factoryParams",
",",
"null",
")",
";",
"}"
] | Register a client listener that uses a query DSL based filter. The listener is expected to be annotated such that
{@link org.infinispan.client.hotrod.annotation.ClientListener#useRawData} = true and {@link
org.infinispan.client.hotrod.annotation.ClientListener#filterFactoryName} and {@link
org.infinispan.client.hotrod.annotation.ClientListener#converterFactoryName} are equal to {@link
Filters#QUERY_DSL_FILTER_FACTORY_NAME}
@param remoteCache the remote cache to attach the listener
@param listener the listener instance
@param query the query to be used for filtering and conversion (if projections are used) | [
"Register",
"a",
"client",
"listener",
"that",
"uses",
"a",
"query",
"DSL",
"based",
"filter",
".",
"The",
"listener",
"is",
"expected",
"to",
"be",
"annotated",
"such",
"that",
"{",
"@link",
"org",
".",
"infinispan",
".",
"client",
".",
"hotrod",
".",
"annotation",
".",
"ClientListener#useRawData",
"}",
"=",
"true",
"and",
"{",
"@link",
"org",
".",
"infinispan",
".",
"client",
".",
"hotrod",
".",
"annotation",
".",
"ClientListener#filterFactoryName",
"}",
"and",
"{",
"@link",
"org",
".",
"infinispan",
".",
"client",
".",
"hotrod",
".",
"annotation",
".",
"ClientListener#converterFactoryName",
"}",
"are",
"equal",
"to",
"{",
"@link",
"Filters#QUERY_DSL_FILTER_FACTORY_NAME",
"}"
] | train | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/event/ClientEvents.java#L43-L59 |
grpc/grpc-java | netty/src/main/java/io/grpc/netty/NettyChannelBuilder.java | NettyChannelBuilder.enableKeepAlive | @Deprecated
public final NettyChannelBuilder enableKeepAlive(boolean enable, long keepAliveTime,
TimeUnit delayUnit, long keepAliveTimeout, TimeUnit timeoutUnit) {
"""
Enable keepalive with custom delay and timeout.
@deprecated Please use {@link #keepAliveTime} and {@link #keepAliveTimeout} instead
"""
if (enable) {
return keepAliveTime(keepAliveTime, delayUnit)
.keepAliveTimeout(keepAliveTimeout, timeoutUnit);
}
return keepAliveTime(KEEPALIVE_TIME_NANOS_DISABLED, TimeUnit.NANOSECONDS);
} | java | @Deprecated
public final NettyChannelBuilder enableKeepAlive(boolean enable, long keepAliveTime,
TimeUnit delayUnit, long keepAliveTimeout, TimeUnit timeoutUnit) {
if (enable) {
return keepAliveTime(keepAliveTime, delayUnit)
.keepAliveTimeout(keepAliveTimeout, timeoutUnit);
}
return keepAliveTime(KEEPALIVE_TIME_NANOS_DISABLED, TimeUnit.NANOSECONDS);
} | [
"@",
"Deprecated",
"public",
"final",
"NettyChannelBuilder",
"enableKeepAlive",
"(",
"boolean",
"enable",
",",
"long",
"keepAliveTime",
",",
"TimeUnit",
"delayUnit",
",",
"long",
"keepAliveTimeout",
",",
"TimeUnit",
"timeoutUnit",
")",
"{",
"if",
"(",
"enable",
")",
"{",
"return",
"keepAliveTime",
"(",
"keepAliveTime",
",",
"delayUnit",
")",
".",
"keepAliveTimeout",
"(",
"keepAliveTimeout",
",",
"timeoutUnit",
")",
";",
"}",
"return",
"keepAliveTime",
"(",
"KEEPALIVE_TIME_NANOS_DISABLED",
",",
"TimeUnit",
".",
"NANOSECONDS",
")",
";",
"}"
] | Enable keepalive with custom delay and timeout.
@deprecated Please use {@link #keepAliveTime} and {@link #keepAliveTimeout} instead | [
"Enable",
"keepalive",
"with",
"custom",
"delay",
"and",
"timeout",
"."
] | train | https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/netty/src/main/java/io/grpc/netty/NettyChannelBuilder.java#L339-L347 |
JakeWharton/ActionBarSherlock | actionbarsherlock/src/com/actionbarsherlock/widget/SuggestionsAdapter.java | SuggestionsAdapter.getDrawableFromResourceValue | private Drawable getDrawableFromResourceValue(String drawableId) {
"""
Gets a drawable given a value provided by a suggestion provider.
This value could be just the string value of a resource id
(e.g., "2130837524"), in which case we will try to retrieve a drawable from
the provider's resources. If the value is not an integer, it is
treated as a Uri and opened with
{@link ContentResolver#openOutputStream(android.net.Uri, String)}.
All resources and URIs are read using the suggestion provider's context.
If the string is not formatted as expected, or no drawable can be found for
the provided value, this method returns null.
@param drawableId a string like "2130837524",
"android.resource://com.android.alarmclock/2130837524",
or "content://contacts/photos/253".
@return a Drawable, or null if none found
"""
if (drawableId == null || drawableId.length() == 0 || "0".equals(drawableId)) {
return null;
}
try {
// First, see if it's just an integer
int resourceId = Integer.parseInt(drawableId);
// It's an int, look for it in the cache
String drawableUri = ContentResolver.SCHEME_ANDROID_RESOURCE
+ "://" + mProviderContext.getPackageName() + "/" + resourceId;
// Must use URI as cache key, since ints are app-specific
Drawable drawable = checkIconCache(drawableUri);
if (drawable != null) {
return drawable;
}
// Not cached, find it by resource ID
drawable = mProviderContext.getResources().getDrawable(resourceId);
// Stick it in the cache, using the URI as key
storeInIconCache(drawableUri, drawable);
return drawable;
} catch (NumberFormatException nfe) {
// It's not an integer, use it as a URI
Drawable drawable = checkIconCache(drawableId);
if (drawable != null) {
return drawable;
}
Uri uri = Uri.parse(drawableId);
drawable = getDrawable(uri);
storeInIconCache(drawableId, drawable);
return drawable;
} catch (Resources.NotFoundException nfe) {
// It was an integer, but it couldn't be found, bail out
Log.w(LOG_TAG, "Icon resource not found: " + drawableId);
return null;
}
} | java | private Drawable getDrawableFromResourceValue(String drawableId) {
if (drawableId == null || drawableId.length() == 0 || "0".equals(drawableId)) {
return null;
}
try {
// First, see if it's just an integer
int resourceId = Integer.parseInt(drawableId);
// It's an int, look for it in the cache
String drawableUri = ContentResolver.SCHEME_ANDROID_RESOURCE
+ "://" + mProviderContext.getPackageName() + "/" + resourceId;
// Must use URI as cache key, since ints are app-specific
Drawable drawable = checkIconCache(drawableUri);
if (drawable != null) {
return drawable;
}
// Not cached, find it by resource ID
drawable = mProviderContext.getResources().getDrawable(resourceId);
// Stick it in the cache, using the URI as key
storeInIconCache(drawableUri, drawable);
return drawable;
} catch (NumberFormatException nfe) {
// It's not an integer, use it as a URI
Drawable drawable = checkIconCache(drawableId);
if (drawable != null) {
return drawable;
}
Uri uri = Uri.parse(drawableId);
drawable = getDrawable(uri);
storeInIconCache(drawableId, drawable);
return drawable;
} catch (Resources.NotFoundException nfe) {
// It was an integer, but it couldn't be found, bail out
Log.w(LOG_TAG, "Icon resource not found: " + drawableId);
return null;
}
} | [
"private",
"Drawable",
"getDrawableFromResourceValue",
"(",
"String",
"drawableId",
")",
"{",
"if",
"(",
"drawableId",
"==",
"null",
"||",
"drawableId",
".",
"length",
"(",
")",
"==",
"0",
"||",
"\"0\"",
".",
"equals",
"(",
"drawableId",
")",
")",
"{",
"return",
"null",
";",
"}",
"try",
"{",
"// First, see if it's just an integer",
"int",
"resourceId",
"=",
"Integer",
".",
"parseInt",
"(",
"drawableId",
")",
";",
"// It's an int, look for it in the cache",
"String",
"drawableUri",
"=",
"ContentResolver",
".",
"SCHEME_ANDROID_RESOURCE",
"+",
"\"://\"",
"+",
"mProviderContext",
".",
"getPackageName",
"(",
")",
"+",
"\"/\"",
"+",
"resourceId",
";",
"// Must use URI as cache key, since ints are app-specific",
"Drawable",
"drawable",
"=",
"checkIconCache",
"(",
"drawableUri",
")",
";",
"if",
"(",
"drawable",
"!=",
"null",
")",
"{",
"return",
"drawable",
";",
"}",
"// Not cached, find it by resource ID",
"drawable",
"=",
"mProviderContext",
".",
"getResources",
"(",
")",
".",
"getDrawable",
"(",
"resourceId",
")",
";",
"// Stick it in the cache, using the URI as key",
"storeInIconCache",
"(",
"drawableUri",
",",
"drawable",
")",
";",
"return",
"drawable",
";",
"}",
"catch",
"(",
"NumberFormatException",
"nfe",
")",
"{",
"// It's not an integer, use it as a URI",
"Drawable",
"drawable",
"=",
"checkIconCache",
"(",
"drawableId",
")",
";",
"if",
"(",
"drawable",
"!=",
"null",
")",
"{",
"return",
"drawable",
";",
"}",
"Uri",
"uri",
"=",
"Uri",
".",
"parse",
"(",
"drawableId",
")",
";",
"drawable",
"=",
"getDrawable",
"(",
"uri",
")",
";",
"storeInIconCache",
"(",
"drawableId",
",",
"drawable",
")",
";",
"return",
"drawable",
";",
"}",
"catch",
"(",
"Resources",
".",
"NotFoundException",
"nfe",
")",
"{",
"// It was an integer, but it couldn't be found, bail out",
"Log",
".",
"w",
"(",
"LOG_TAG",
",",
"\"Icon resource not found: \"",
"+",
"drawableId",
")",
";",
"return",
"null",
";",
"}",
"}"
] | Gets a drawable given a value provided by a suggestion provider.
This value could be just the string value of a resource id
(e.g., "2130837524"), in which case we will try to retrieve a drawable from
the provider's resources. If the value is not an integer, it is
treated as a Uri and opened with
{@link ContentResolver#openOutputStream(android.net.Uri, String)}.
All resources and URIs are read using the suggestion provider's context.
If the string is not formatted as expected, or no drawable can be found for
the provided value, this method returns null.
@param drawableId a string like "2130837524",
"android.resource://com.android.alarmclock/2130837524",
or "content://contacts/photos/253".
@return a Drawable, or null if none found | [
"Gets",
"a",
"drawable",
"given",
"a",
"value",
"provided",
"by",
"a",
"suggestion",
"provider",
"."
] | train | https://github.com/JakeWharton/ActionBarSherlock/blob/2c71339e756bcc0b1424c4525680549ba3a2dc97/actionbarsherlock/src/com/actionbarsherlock/widget/SuggestionsAdapter.java#L544-L579 |
inmite/android-validation-komensky | library/src/main/java/eu/inmite/android/lib/validations/form/FormValidator.java | FormValidator.registerViewAdapter | @SuppressWarnings("TryWithIdenticalCatches")
public static void registerViewAdapter(Class<? extends View> viewType, Class<? extends IFieldAdapter<? extends View,?>> adapterClass) {
"""
Register adapter that can be used to get value from view.
@param viewType type of view adapter is determined to get values from
@param adapterClass class of adapter to register
@throws IllegalArgumentException if adapterClass is null or viewType is null
@throws FormsValidationException when there is a problem when accessing adapter class
"""
if (viewType == null || adapterClass == null) {
throw new IllegalArgumentException("arguments must not be null");
}
try {
FieldAdapterFactory.registerAdapter(viewType, adapterClass);
} catch (IllegalAccessException e) {
throw new FormsValidationException(e);
} catch (InstantiationException e) {
throw new FormsValidationException(e);
}
} | java | @SuppressWarnings("TryWithIdenticalCatches")
public static void registerViewAdapter(Class<? extends View> viewType, Class<? extends IFieldAdapter<? extends View,?>> adapterClass) {
if (viewType == null || adapterClass == null) {
throw new IllegalArgumentException("arguments must not be null");
}
try {
FieldAdapterFactory.registerAdapter(viewType, adapterClass);
} catch (IllegalAccessException e) {
throw new FormsValidationException(e);
} catch (InstantiationException e) {
throw new FormsValidationException(e);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"TryWithIdenticalCatches\"",
")",
"public",
"static",
"void",
"registerViewAdapter",
"(",
"Class",
"<",
"?",
"extends",
"View",
">",
"viewType",
",",
"Class",
"<",
"?",
"extends",
"IFieldAdapter",
"<",
"?",
"extends",
"View",
",",
"?",
">",
">",
"adapterClass",
")",
"{",
"if",
"(",
"viewType",
"==",
"null",
"||",
"adapterClass",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"arguments must not be null\"",
")",
";",
"}",
"try",
"{",
"FieldAdapterFactory",
".",
"registerAdapter",
"(",
"viewType",
",",
"adapterClass",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"e",
")",
"{",
"throw",
"new",
"FormsValidationException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"InstantiationException",
"e",
")",
"{",
"throw",
"new",
"FormsValidationException",
"(",
"e",
")",
";",
"}",
"}"
] | Register adapter that can be used to get value from view.
@param viewType type of view adapter is determined to get values from
@param adapterClass class of adapter to register
@throws IllegalArgumentException if adapterClass is null or viewType is null
@throws FormsValidationException when there is a problem when accessing adapter class | [
"Register",
"adapter",
"that",
"can",
"be",
"used",
"to",
"get",
"value",
"from",
"view",
".",
"@param",
"viewType",
"type",
"of",
"view",
"adapter",
"is",
"determined",
"to",
"get",
"values",
"from",
"@param",
"adapterClass",
"class",
"of",
"adapter",
"to",
"register"
] | train | https://github.com/inmite/android-validation-komensky/blob/7c544f2d9f104a9800fcf4757eecb3caa8e76451/library/src/main/java/eu/inmite/android/lib/validations/form/FormValidator.java#L85-L98 |
phax/ph-masterdata | ph-masterdata/src/main/java/com/helger/masterdata/currency/CurrencyHelper.java | CurrencyHelper.parseValueFormat | @Nullable
public static BigDecimal parseValueFormat (@Nullable final ECurrency eCurrency,
@Nullable final String sTextValue,
@Nullable final BigDecimal aDefault) {
"""
Try to parse a string value formatted by the {@link DecimalFormat} object
returned from {@link #getValueFormat(ECurrency)}
@param eCurrency
The currency it is about. If <code>null</code> is provided
{@link #DEFAULT_CURRENCY} is used instead.
@param sTextValue
The string value. It will be trimmed, and the decimal separator will
be adopted.
@param aDefault
The default value to be used in case parsing fails. May be
<code>null</code>.
@return The {@link BigDecimal} value matching the string value or the
passed default value.
"""
final PerCurrencySettings aPCS = getSettings (eCurrency);
final DecimalFormat aValueFormat = aPCS.getValueFormat ();
// Adopt the decimal separator
final String sRealTextValue;
// In Java 9 onwards, this the separators may be null (e.g. for AED)
if (aPCS.getDecimalSeparator () != null && aPCS.getGroupingSeparator () != null)
sRealTextValue = _getTextValueForDecimalSeparator (sTextValue,
aPCS.getDecimalSeparator (),
aPCS.getGroupingSeparator ());
else
sRealTextValue = sTextValue;
return parseCurrency (sRealTextValue, aValueFormat, aDefault, aPCS.getRoundingMode ());
} | java | @Nullable
public static BigDecimal parseValueFormat (@Nullable final ECurrency eCurrency,
@Nullable final String sTextValue,
@Nullable final BigDecimal aDefault)
{
final PerCurrencySettings aPCS = getSettings (eCurrency);
final DecimalFormat aValueFormat = aPCS.getValueFormat ();
// Adopt the decimal separator
final String sRealTextValue;
// In Java 9 onwards, this the separators may be null (e.g. for AED)
if (aPCS.getDecimalSeparator () != null && aPCS.getGroupingSeparator () != null)
sRealTextValue = _getTextValueForDecimalSeparator (sTextValue,
aPCS.getDecimalSeparator (),
aPCS.getGroupingSeparator ());
else
sRealTextValue = sTextValue;
return parseCurrency (sRealTextValue, aValueFormat, aDefault, aPCS.getRoundingMode ());
} | [
"@",
"Nullable",
"public",
"static",
"BigDecimal",
"parseValueFormat",
"(",
"@",
"Nullable",
"final",
"ECurrency",
"eCurrency",
",",
"@",
"Nullable",
"final",
"String",
"sTextValue",
",",
"@",
"Nullable",
"final",
"BigDecimal",
"aDefault",
")",
"{",
"final",
"PerCurrencySettings",
"aPCS",
"=",
"getSettings",
"(",
"eCurrency",
")",
";",
"final",
"DecimalFormat",
"aValueFormat",
"=",
"aPCS",
".",
"getValueFormat",
"(",
")",
";",
"// Adopt the decimal separator",
"final",
"String",
"sRealTextValue",
";",
"// In Java 9 onwards, this the separators may be null (e.g. for AED)",
"if",
"(",
"aPCS",
".",
"getDecimalSeparator",
"(",
")",
"!=",
"null",
"&&",
"aPCS",
".",
"getGroupingSeparator",
"(",
")",
"!=",
"null",
")",
"sRealTextValue",
"=",
"_getTextValueForDecimalSeparator",
"(",
"sTextValue",
",",
"aPCS",
".",
"getDecimalSeparator",
"(",
")",
",",
"aPCS",
".",
"getGroupingSeparator",
"(",
")",
")",
";",
"else",
"sRealTextValue",
"=",
"sTextValue",
";",
"return",
"parseCurrency",
"(",
"sRealTextValue",
",",
"aValueFormat",
",",
"aDefault",
",",
"aPCS",
".",
"getRoundingMode",
"(",
")",
")",
";",
"}"
] | Try to parse a string value formatted by the {@link DecimalFormat} object
returned from {@link #getValueFormat(ECurrency)}
@param eCurrency
The currency it is about. If <code>null</code> is provided
{@link #DEFAULT_CURRENCY} is used instead.
@param sTextValue
The string value. It will be trimmed, and the decimal separator will
be adopted.
@param aDefault
The default value to be used in case parsing fails. May be
<code>null</code>.
@return The {@link BigDecimal} value matching the string value or the
passed default value. | [
"Try",
"to",
"parse",
"a",
"string",
"value",
"formatted",
"by",
"the",
"{",
"@link",
"DecimalFormat",
"}",
"object",
"returned",
"from",
"{",
"@link",
"#getValueFormat",
"(",
"ECurrency",
")",
"}"
] | train | https://github.com/phax/ph-masterdata/blob/ca5e0b03c735b30b47930c018bfb5e71f00d0ff4/ph-masterdata/src/main/java/com/helger/masterdata/currency/CurrencyHelper.java#L528-L546 |
alkacon/opencms-core | src/org/opencms/ade/configuration/CmsADEManager.java | CmsADEManager.internalLookupConfiguration | protected CmsADEConfigData internalLookupConfiguration(CmsObject cms, String rootPath) {
"""
Internal configuration lookup method.<p>
@param cms the cms context
@param rootPath the root path for which to look up the configuration
@return the configuration for the given path
"""
boolean online = (null == cms) || isOnline(cms);
CmsADEConfigCacheState state = getCacheState(online);
return state.lookupConfiguration(rootPath);
} | java | protected CmsADEConfigData internalLookupConfiguration(CmsObject cms, String rootPath) {
boolean online = (null == cms) || isOnline(cms);
CmsADEConfigCacheState state = getCacheState(online);
return state.lookupConfiguration(rootPath);
} | [
"protected",
"CmsADEConfigData",
"internalLookupConfiguration",
"(",
"CmsObject",
"cms",
",",
"String",
"rootPath",
")",
"{",
"boolean",
"online",
"=",
"(",
"null",
"==",
"cms",
")",
"||",
"isOnline",
"(",
"cms",
")",
";",
"CmsADEConfigCacheState",
"state",
"=",
"getCacheState",
"(",
"online",
")",
";",
"return",
"state",
".",
"lookupConfiguration",
"(",
"rootPath",
")",
";",
"}"
] | Internal configuration lookup method.<p>
@param cms the cms context
@param rootPath the root path for which to look up the configuration
@return the configuration for the given path | [
"Internal",
"configuration",
"lookup",
"method",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ade/configuration/CmsADEManager.java#L1457-L1462 |
advantageous/boon | reflekt/src/main/java/io/advantageous/boon/core/Str.java | Str.idx | public static char idx( String str, int index ) {
"""
Gets character at index
@param str string
@param index index
@return char at
"""
int i = calculateIndex( str.length(), index );
char c = str.charAt( i );
return c;
} | java | public static char idx( String str, int index ) {
int i = calculateIndex( str.length(), index );
char c = str.charAt( i );
return c;
} | [
"public",
"static",
"char",
"idx",
"(",
"String",
"str",
",",
"int",
"index",
")",
"{",
"int",
"i",
"=",
"calculateIndex",
"(",
"str",
".",
"length",
"(",
")",
",",
"index",
")",
";",
"char",
"c",
"=",
"str",
".",
"charAt",
"(",
"i",
")",
";",
"return",
"c",
";",
"}"
] | Gets character at index
@param str string
@param index index
@return char at | [
"Gets",
"character",
"at",
"index"
] | train | https://github.com/advantageous/boon/blob/12712d376761aa3b33223a9f1716720ddb67cb5e/reflekt/src/main/java/io/advantageous/boon/core/Str.java#L185-L190 |
apache/incubator-druid | server/src/main/java/org/apache/druid/metadata/IndexerSQLMetadataStorageCoordinator.java | IndexerSQLMetadataStorageCoordinator.announceHistoricalSegments | @Override
public Set<DataSegment> announceHistoricalSegments(final Set<DataSegment> segments) throws IOException {
"""
Attempts to insert a set of segments to the database. Returns the set of segments actually added (segments
with identifiers already in the database will not be added).
@param segments set of segments to add
@return set of segments actually added
"""
final SegmentPublishResult result = announceHistoricalSegments(segments, null, null);
// Metadata transaction cannot fail because we are not trying to do one.
if (!result.isSuccess()) {
throw new ISE("WTF?! announceHistoricalSegments failed with null metadata, should not happen.");
}
return result.getSegments();
} | java | @Override
public Set<DataSegment> announceHistoricalSegments(final Set<DataSegment> segments) throws IOException
{
final SegmentPublishResult result = announceHistoricalSegments(segments, null, null);
// Metadata transaction cannot fail because we are not trying to do one.
if (!result.isSuccess()) {
throw new ISE("WTF?! announceHistoricalSegments failed with null metadata, should not happen.");
}
return result.getSegments();
} | [
"@",
"Override",
"public",
"Set",
"<",
"DataSegment",
">",
"announceHistoricalSegments",
"(",
"final",
"Set",
"<",
"DataSegment",
">",
"segments",
")",
"throws",
"IOException",
"{",
"final",
"SegmentPublishResult",
"result",
"=",
"announceHistoricalSegments",
"(",
"segments",
",",
"null",
",",
"null",
")",
";",
"// Metadata transaction cannot fail because we are not trying to do one.",
"if",
"(",
"!",
"result",
".",
"isSuccess",
"(",
")",
")",
"{",
"throw",
"new",
"ISE",
"(",
"\"WTF?! announceHistoricalSegments failed with null metadata, should not happen.\"",
")",
";",
"}",
"return",
"result",
".",
"getSegments",
"(",
")",
";",
"}"
] | Attempts to insert a set of segments to the database. Returns the set of segments actually added (segments
with identifiers already in the database will not be added).
@param segments set of segments to add
@return set of segments actually added | [
"Attempts",
"to",
"insert",
"a",
"set",
"of",
"segments",
"to",
"the",
"database",
".",
"Returns",
"the",
"set",
"of",
"segments",
"actually",
"added",
"(",
"segments",
"with",
"identifiers",
"already",
"in",
"the",
"database",
"will",
"not",
"be",
"added",
")",
"."
] | train | https://github.com/apache/incubator-druid/blob/f776b9408962b9006cfcfe4d6c1794751972cc8e/server/src/main/java/org/apache/druid/metadata/IndexerSQLMetadataStorageCoordinator.java#L236-L247 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/ICUBinary.java | ICUBinary.getData | public static ByteBuffer getData(ClassLoader loader, String resourceName, String itemPath) {
"""
Loads an ICU binary data file and returns it as a ByteBuffer.
The buffer contents is normally read-only, but its position etc. can be modified.
@param loader Used for loader.getResourceAsStream() unless the data is found elsewhere.
@param resourceName Resource name for use with the loader.
@param itemPath Relative ICU data item path, for example "root.res" or "coll/ucadata.icu".
@return The data as a read-only ByteBuffer,
or null if the resource could not be found.
"""
return getData(loader, resourceName, itemPath, false);
} | java | public static ByteBuffer getData(ClassLoader loader, String resourceName, String itemPath) {
return getData(loader, resourceName, itemPath, false);
} | [
"public",
"static",
"ByteBuffer",
"getData",
"(",
"ClassLoader",
"loader",
",",
"String",
"resourceName",
",",
"String",
"itemPath",
")",
"{",
"return",
"getData",
"(",
"loader",
",",
"resourceName",
",",
"itemPath",
",",
"false",
")",
";",
"}"
] | Loads an ICU binary data file and returns it as a ByteBuffer.
The buffer contents is normally read-only, but its position etc. can be modified.
@param loader Used for loader.getResourceAsStream() unless the data is found elsewhere.
@param resourceName Resource name for use with the loader.
@param itemPath Relative ICU data item path, for example "root.res" or "coll/ucadata.icu".
@return The data as a read-only ByteBuffer,
or null if the resource could not be found. | [
"Loads",
"an",
"ICU",
"binary",
"data",
"file",
"and",
"returns",
"it",
"as",
"a",
"ByteBuffer",
".",
"The",
"buffer",
"contents",
"is",
"normally",
"read",
"-",
"only",
"but",
"its",
"position",
"etc",
".",
"can",
"be",
"modified",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/ICUBinary.java#L440-L442 |
spring-projects/spring-session-data-mongodb | src/main/java/org/springframework/session/data/mongo/ReactiveMongoOperationsSessionRepository.java | ReactiveMongoOperationsSessionRepository.deleteById | @Override
public Mono<Void> deleteById(String id) {
"""
Deletes the {@link MongoSession} with the given {@link MongoSession#getId()} or does nothing if the
{@link MongoSession} is not found.
@param id the {@link MongoSession#getId()} to delete
"""
return findSession(id)
.flatMap(document -> this.mongoOperations.remove(document, this.collectionName).then(Mono.just(document)))
.map(document -> convertToSession(this.mongoSessionConverter, document))
.doOnSuccess(mongoSession -> publishEvent(new SessionDeletedEvent(this, mongoSession))) //
.then();
} | java | @Override
public Mono<Void> deleteById(String id) {
return findSession(id)
.flatMap(document -> this.mongoOperations.remove(document, this.collectionName).then(Mono.just(document)))
.map(document -> convertToSession(this.mongoSessionConverter, document))
.doOnSuccess(mongoSession -> publishEvent(new SessionDeletedEvent(this, mongoSession))) //
.then();
} | [
"@",
"Override",
"public",
"Mono",
"<",
"Void",
">",
"deleteById",
"(",
"String",
"id",
")",
"{",
"return",
"findSession",
"(",
"id",
")",
".",
"flatMap",
"(",
"document",
"->",
"this",
".",
"mongoOperations",
".",
"remove",
"(",
"document",
",",
"this",
".",
"collectionName",
")",
".",
"then",
"(",
"Mono",
".",
"just",
"(",
"document",
")",
")",
")",
".",
"map",
"(",
"document",
"->",
"convertToSession",
"(",
"this",
".",
"mongoSessionConverter",
",",
"document",
")",
")",
".",
"doOnSuccess",
"(",
"mongoSession",
"->",
"publishEvent",
"(",
"new",
"SessionDeletedEvent",
"(",
"this",
",",
"mongoSession",
")",
")",
")",
"//",
".",
"then",
"(",
")",
";",
"}"
] | Deletes the {@link MongoSession} with the given {@link MongoSession#getId()} or does nothing if the
{@link MongoSession} is not found.
@param id the {@link MongoSession#getId()} to delete | [
"Deletes",
"the",
"{",
"@link",
"MongoSession",
"}",
"with",
"the",
"given",
"{",
"@link",
"MongoSession#getId",
"()",
"}",
"or",
"does",
"nothing",
"if",
"the",
"{",
"@link",
"MongoSession",
"}",
"is",
"not",
"found",
"."
] | train | https://github.com/spring-projects/spring-session-data-mongodb/blob/c507bb2d2a9b52ea9846ffaf1ac7c71cb0e6690e/src/main/java/org/springframework/session/data/mongo/ReactiveMongoOperationsSessionRepository.java#L136-L144 |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/ThemeUtil.java | ThemeUtil.getDrawable | public static Drawable getDrawable(@NonNull final Context context,
@AttrRes final int resourceId) {
"""
Obtains the drawable, which corresponds to a specific resource id, from a context's theme. If
the given resource id is invalid, a {@link NotFoundException} will be thrown.
@param context
The context, which should be used, as an instance of the class {@link Context}. The
context may not be null
@param resourceId
The resource id of the attribute, which should be obtained, as an {@link Integer}
value. The resource id must corresponds to a valid theme attribute
@return The drawable, which has been obtained, as an instance of the class {@link Drawable}
"""
return getDrawable(context, -1, resourceId);
} | java | public static Drawable getDrawable(@NonNull final Context context,
@AttrRes final int resourceId) {
return getDrawable(context, -1, resourceId);
} | [
"public",
"static",
"Drawable",
"getDrawable",
"(",
"@",
"NonNull",
"final",
"Context",
"context",
",",
"@",
"AttrRes",
"final",
"int",
"resourceId",
")",
"{",
"return",
"getDrawable",
"(",
"context",
",",
"-",
"1",
",",
"resourceId",
")",
";",
"}"
] | Obtains the drawable, which corresponds to a specific resource id, from a context's theme. If
the given resource id is invalid, a {@link NotFoundException} will be thrown.
@param context
The context, which should be used, as an instance of the class {@link Context}. The
context may not be null
@param resourceId
The resource id of the attribute, which should be obtained, as an {@link Integer}
value. The resource id must corresponds to a valid theme attribute
@return The drawable, which has been obtained, as an instance of the class {@link Drawable} | [
"Obtains",
"the",
"drawable",
"which",
"corresponds",
"to",
"a",
"specific",
"resource",
"id",
"from",
"a",
"context",
"s",
"theme",
".",
"If",
"the",
"given",
"resource",
"id",
"is",
"invalid",
"a",
"{",
"@link",
"NotFoundException",
"}",
"will",
"be",
"thrown",
"."
] | train | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/ThemeUtil.java#L537-L540 |
ttddyy/datasource-proxy | src/main/java/net/ttddyy/dsproxy/support/ProxyDataSourceBuilder.java | ProxyDataSourceBuilder.logSlowQueryByJUL | public ProxyDataSourceBuilder logSlowQueryByJUL(long thresholdTime, TimeUnit timeUnit) {
"""
Register {@link JULSlowQueryListener}.
@param thresholdTime slow query threshold time
@param timeUnit slow query threshold time unit
@return builder
@since 1.4.1
"""
return logSlowQueryByJUL(thresholdTime, timeUnit, null, null);
} | java | public ProxyDataSourceBuilder logSlowQueryByJUL(long thresholdTime, TimeUnit timeUnit) {
return logSlowQueryByJUL(thresholdTime, timeUnit, null, null);
} | [
"public",
"ProxyDataSourceBuilder",
"logSlowQueryByJUL",
"(",
"long",
"thresholdTime",
",",
"TimeUnit",
"timeUnit",
")",
"{",
"return",
"logSlowQueryByJUL",
"(",
"thresholdTime",
",",
"timeUnit",
",",
"null",
",",
"null",
")",
";",
"}"
] | Register {@link JULSlowQueryListener}.
@param thresholdTime slow query threshold time
@param timeUnit slow query threshold time unit
@return builder
@since 1.4.1 | [
"Register",
"{",
"@link",
"JULSlowQueryListener",
"}",
"."
] | train | https://github.com/ttddyy/datasource-proxy/blob/62163ccf9a569a99aa3ad9f9151a32567447a62e/src/main/java/net/ttddyy/dsproxy/support/ProxyDataSourceBuilder.java#L439-L441 |
Azure/azure-sdk-for-java | sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/ElasticPoolActivitiesInner.java | ElasticPoolActivitiesInner.listByElasticPool | public List<ElasticPoolActivityInner> listByElasticPool(String resourceGroupName, String serverName, String elasticPoolName) {
"""
Returns elastic pool activities.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param elasticPoolName The name of the elastic pool for which to get the current activity.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the List<ElasticPoolActivityInner> object if successful.
"""
return listByElasticPoolWithServiceResponseAsync(resourceGroupName, serverName, elasticPoolName).toBlocking().single().body();
} | java | public List<ElasticPoolActivityInner> listByElasticPool(String resourceGroupName, String serverName, String elasticPoolName) {
return listByElasticPoolWithServiceResponseAsync(resourceGroupName, serverName, elasticPoolName).toBlocking().single().body();
} | [
"public",
"List",
"<",
"ElasticPoolActivityInner",
">",
"listByElasticPool",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"String",
"elasticPoolName",
")",
"{",
"return",
"listByElasticPoolWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
",",
"elasticPoolName",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Returns elastic pool activities.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param elasticPoolName The name of the elastic pool for which to get the current activity.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the List<ElasticPoolActivityInner> object if successful. | [
"Returns",
"elastic",
"pool",
"activities",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/ElasticPoolActivitiesInner.java#L72-L74 |
ivanceras/orm | src/main/java/com/ivanceras/db/server/util/ModelCurator.java | ModelCurator.crossOutLinkerTables | private void crossOutLinkerTables() {
"""
Remove a linker table present in the hasMany, then short circuit right away to the linked table
Linker tables contains composite primary keys of two tables
If each local column of the primary key is the primary of the table it is referring to
the this is a lookup table
ie. product, product_category, category
Product will have many category
Category at the same time is used by many product
Changes should be apply on both tables right away
"""
String[] primaryKeys = model.getPrimaryAttributes();
if(primaryKeys != null && primaryKeys.length == 2){//there are only 2 primary keys
//if both primary keys look up to different table which is also a primary key
String[] hasOne = model.getHasOne();
String[] hasOneLocalColum = model.getHasOneLocalColumn();
String[] hasOneReferencedColumn = model.getHasOneReferencedColumn();
int indexP1 = CStringUtils.indexOf(hasOneLocalColum, primaryKeys[0]);
int indexP2 = CStringUtils.indexOf(hasOneLocalColum, primaryKeys[1]);
if(indexP1 >= 0 && indexP2 >= 0){
String t1 = hasOne[indexP1];
String t2 = hasOne[indexP2];
String ref1 = hasOneReferencedColumn[indexP1];
String ref2 = hasOneReferencedColumn[indexP2];
ModelDef m1 = getModel(t1);
boolean isRef1Primary = CStringUtils.inArray(m1.getPrimaryAttributes(), ref1);
ModelDef m2 = getModel(t2);
boolean isRef2Primary = CStringUtils.inArray(m2.getPrimaryAttributes(), ref2);
if(model != m1 && model != m2
&& isRef1Primary
&& isRef2Primary
){
removeFromHasMany(m1, model.getTableName());//remove the hasMany of this table
removeFromHasMany(m2, model.getTableName());//remove the hasMany of this table
addToHasMany(m1, m2.getTableName(), ref2, null);
addToHasMany(m2, m1.getTableName(), ref1, null);
}
}
}
} | java | private void crossOutLinkerTables(){
String[] primaryKeys = model.getPrimaryAttributes();
if(primaryKeys != null && primaryKeys.length == 2){//there are only 2 primary keys
//if both primary keys look up to different table which is also a primary key
String[] hasOne = model.getHasOne();
String[] hasOneLocalColum = model.getHasOneLocalColumn();
String[] hasOneReferencedColumn = model.getHasOneReferencedColumn();
int indexP1 = CStringUtils.indexOf(hasOneLocalColum, primaryKeys[0]);
int indexP2 = CStringUtils.indexOf(hasOneLocalColum, primaryKeys[1]);
if(indexP1 >= 0 && indexP2 >= 0){
String t1 = hasOne[indexP1];
String t2 = hasOne[indexP2];
String ref1 = hasOneReferencedColumn[indexP1];
String ref2 = hasOneReferencedColumn[indexP2];
ModelDef m1 = getModel(t1);
boolean isRef1Primary = CStringUtils.inArray(m1.getPrimaryAttributes(), ref1);
ModelDef m2 = getModel(t2);
boolean isRef2Primary = CStringUtils.inArray(m2.getPrimaryAttributes(), ref2);
if(model != m1 && model != m2
&& isRef1Primary
&& isRef2Primary
){
removeFromHasMany(m1, model.getTableName());//remove the hasMany of this table
removeFromHasMany(m2, model.getTableName());//remove the hasMany of this table
addToHasMany(m1, m2.getTableName(), ref2, null);
addToHasMany(m2, m1.getTableName(), ref1, null);
}
}
}
} | [
"private",
"void",
"crossOutLinkerTables",
"(",
")",
"{",
"String",
"[",
"]",
"primaryKeys",
"=",
"model",
".",
"getPrimaryAttributes",
"(",
")",
";",
"if",
"(",
"primaryKeys",
"!=",
"null",
"&&",
"primaryKeys",
".",
"length",
"==",
"2",
")",
"{",
"//there are only 2 primary keys",
"//if both primary keys look up to different table which is also a primary key",
"String",
"[",
"]",
"hasOne",
"=",
"model",
".",
"getHasOne",
"(",
")",
";",
"String",
"[",
"]",
"hasOneLocalColum",
"=",
"model",
".",
"getHasOneLocalColumn",
"(",
")",
";",
"String",
"[",
"]",
"hasOneReferencedColumn",
"=",
"model",
".",
"getHasOneReferencedColumn",
"(",
")",
";",
"int",
"indexP1",
"=",
"CStringUtils",
".",
"indexOf",
"(",
"hasOneLocalColum",
",",
"primaryKeys",
"[",
"0",
"]",
")",
";",
"int",
"indexP2",
"=",
"CStringUtils",
".",
"indexOf",
"(",
"hasOneLocalColum",
",",
"primaryKeys",
"[",
"1",
"]",
")",
";",
"if",
"(",
"indexP1",
">=",
"0",
"&&",
"indexP2",
">=",
"0",
")",
"{",
"String",
"t1",
"=",
"hasOne",
"[",
"indexP1",
"]",
";",
"String",
"t2",
"=",
"hasOne",
"[",
"indexP2",
"]",
";",
"String",
"ref1",
"=",
"hasOneReferencedColumn",
"[",
"indexP1",
"]",
";",
"String",
"ref2",
"=",
"hasOneReferencedColumn",
"[",
"indexP2",
"]",
";",
"ModelDef",
"m1",
"=",
"getModel",
"(",
"t1",
")",
";",
"boolean",
"isRef1Primary",
"=",
"CStringUtils",
".",
"inArray",
"(",
"m1",
".",
"getPrimaryAttributes",
"(",
")",
",",
"ref1",
")",
";",
"ModelDef",
"m2",
"=",
"getModel",
"(",
"t2",
")",
";",
"boolean",
"isRef2Primary",
"=",
"CStringUtils",
".",
"inArray",
"(",
"m2",
".",
"getPrimaryAttributes",
"(",
")",
",",
"ref2",
")",
";",
"if",
"(",
"model",
"!=",
"m1",
"&&",
"model",
"!=",
"m2",
"&&",
"isRef1Primary",
"&&",
"isRef2Primary",
")",
"{",
"removeFromHasMany",
"(",
"m1",
",",
"model",
".",
"getTableName",
"(",
")",
")",
";",
"//remove the hasMany of this table",
"removeFromHasMany",
"(",
"m2",
",",
"model",
".",
"getTableName",
"(",
")",
")",
";",
"//remove the hasMany of this table",
"addToHasMany",
"(",
"m1",
",",
"m2",
".",
"getTableName",
"(",
")",
",",
"ref2",
",",
"null",
")",
";",
"addToHasMany",
"(",
"m2",
",",
"m1",
".",
"getTableName",
"(",
")",
",",
"ref1",
",",
"null",
")",
";",
"}",
"}",
"}",
"}"
] | Remove a linker table present in the hasMany, then short circuit right away to the linked table
Linker tables contains composite primary keys of two tables
If each local column of the primary key is the primary of the table it is referring to
the this is a lookup table
ie. product, product_category, category
Product will have many category
Category at the same time is used by many product
Changes should be apply on both tables right away | [
"Remove",
"a",
"linker",
"table",
"present",
"in",
"the",
"hasMany",
"then",
"short",
"circuit",
"right",
"away",
"to",
"the",
"linked",
"table"
] | train | https://github.com/ivanceras/orm/blob/e63213cb8abefd11df0e2d34b1c95477788e600e/src/main/java/com/ivanceras/db/server/util/ModelCurator.java#L282-L321 |
jeremylong/DependencyCheck | utils/src/main/java/org/owasp/dependencycheck/utils/ExpectedObjectInputStream.java | ExpectedObjectInputStream.resolveClass | @Override
protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
"""
{@inheritDoc}
Only deserialize instances of expected classes by validating the class name prior to deserialization.
"""
if (!this.expected.contains(desc.getName())) {
throw new InvalidClassException("Unexpected deserialization ", desc.getName());
}
return super.resolveClass(desc);
} | java | @Override
protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
if (!this.expected.contains(desc.getName())) {
throw new InvalidClassException("Unexpected deserialization ", desc.getName());
}
return super.resolveClass(desc);
} | [
"@",
"Override",
"protected",
"Class",
"<",
"?",
">",
"resolveClass",
"(",
"ObjectStreamClass",
"desc",
")",
"throws",
"IOException",
",",
"ClassNotFoundException",
"{",
"if",
"(",
"!",
"this",
".",
"expected",
".",
"contains",
"(",
"desc",
".",
"getName",
"(",
")",
")",
")",
"{",
"throw",
"new",
"InvalidClassException",
"(",
"\"Unexpected deserialization \"",
",",
"desc",
".",
"getName",
"(",
")",
")",
";",
"}",
"return",
"super",
".",
"resolveClass",
"(",
"desc",
")",
";",
"}"
] | {@inheritDoc}
Only deserialize instances of expected classes by validating the class name prior to deserialization. | [
"{",
"@inheritDoc",
"}"
] | train | https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/utils/src/main/java/org/owasp/dependencycheck/utils/ExpectedObjectInputStream.java#L61-L67 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/Expression.java | Expression.asIterator | public DTMIterator asIterator(XPathContext xctxt, int contextNode)
throws javax.xml.transform.TransformerException {
"""
Given an select expression and a context, evaluate the XPath
and return the resulting iterator.
@param xctxt The execution context.
@param contextNode The node that "." expresses.
@return A valid DTMIterator.
@throws TransformerException thrown if the active ProblemListener decides
the error condition is severe enough to halt processing.
@throws javax.xml.transform.TransformerException
@xsl.usage experimental
"""
try
{
xctxt.pushCurrentNodeAndExpression(contextNode, contextNode);
return execute(xctxt).iter();
}
finally
{
xctxt.popCurrentNodeAndExpression();
}
} | java | public DTMIterator asIterator(XPathContext xctxt, int contextNode)
throws javax.xml.transform.TransformerException
{
try
{
xctxt.pushCurrentNodeAndExpression(contextNode, contextNode);
return execute(xctxt).iter();
}
finally
{
xctxt.popCurrentNodeAndExpression();
}
} | [
"public",
"DTMIterator",
"asIterator",
"(",
"XPathContext",
"xctxt",
",",
"int",
"contextNode",
")",
"throws",
"javax",
".",
"xml",
".",
"transform",
".",
"TransformerException",
"{",
"try",
"{",
"xctxt",
".",
"pushCurrentNodeAndExpression",
"(",
"contextNode",
",",
"contextNode",
")",
";",
"return",
"execute",
"(",
"xctxt",
")",
".",
"iter",
"(",
")",
";",
"}",
"finally",
"{",
"xctxt",
".",
"popCurrentNodeAndExpression",
"(",
")",
";",
"}",
"}"
] | Given an select expression and a context, evaluate the XPath
and return the resulting iterator.
@param xctxt The execution context.
@param contextNode The node that "." expresses.
@return A valid DTMIterator.
@throws TransformerException thrown if the active ProblemListener decides
the error condition is severe enough to halt processing.
@throws javax.xml.transform.TransformerException
@xsl.usage experimental | [
"Given",
"an",
"select",
"expression",
"and",
"a",
"context",
"evaluate",
"the",
"XPath",
"and",
"return",
"the",
"resulting",
"iterator",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/Expression.java#L244-L258 |
google/truth | extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesSubject.java | MultimapWithProtoValuesSubject.usingDoubleToleranceForFieldsForValues | public MultimapWithProtoValuesFluentAssertion<M> usingDoubleToleranceForFieldsForValues(
double tolerance, Iterable<Integer> fieldNumbers) {
"""
Compares double fields with these explicitly specified top-level field numbers using the
provided absolute tolerance.
@param tolerance A finite, non-negative tolerance.
"""
return usingConfig(config.usingDoubleToleranceForFields(tolerance, fieldNumbers));
} | java | public MultimapWithProtoValuesFluentAssertion<M> usingDoubleToleranceForFieldsForValues(
double tolerance, Iterable<Integer> fieldNumbers) {
return usingConfig(config.usingDoubleToleranceForFields(tolerance, fieldNumbers));
} | [
"public",
"MultimapWithProtoValuesFluentAssertion",
"<",
"M",
">",
"usingDoubleToleranceForFieldsForValues",
"(",
"double",
"tolerance",
",",
"Iterable",
"<",
"Integer",
">",
"fieldNumbers",
")",
"{",
"return",
"usingConfig",
"(",
"config",
".",
"usingDoubleToleranceForFields",
"(",
"tolerance",
",",
"fieldNumbers",
")",
")",
";",
"}"
] | Compares double fields with these explicitly specified top-level field numbers using the
provided absolute tolerance.
@param tolerance A finite, non-negative tolerance. | [
"Compares",
"double",
"fields",
"with",
"these",
"explicitly",
"specified",
"top",
"-",
"level",
"field",
"numbers",
"using",
"the",
"provided",
"absolute",
"tolerance",
"."
] | train | https://github.com/google/truth/blob/60eceffd2e8c3297655d33ed87d965cf5af51108/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesSubject.java#L575-L578 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/db/event/NoDeleteModifyHandler.java | NoDeleteModifyHandler.init | public void init(Record record, boolean bNoDelete, boolean bNoModify) {
"""
Constructor.
@param record My owner (usually passed as null, and set on addListener in setOwner()).
""" // For this to work right, the booking number field needs a listener to re-select this file whenever it changes
m_bNoDelete = bNoDelete;
m_bNoModify = bNoModify;
super.init(record);
} | java | public void init(Record record, boolean bNoDelete, boolean bNoModify)
{ // For this to work right, the booking number field needs a listener to re-select this file whenever it changes
m_bNoDelete = bNoDelete;
m_bNoModify = bNoModify;
super.init(record);
} | [
"public",
"void",
"init",
"(",
"Record",
"record",
",",
"boolean",
"bNoDelete",
",",
"boolean",
"bNoModify",
")",
"{",
"// For this to work right, the booking number field needs a listener to re-select this file whenever it changes",
"m_bNoDelete",
"=",
"bNoDelete",
";",
"m_bNoModify",
"=",
"bNoModify",
";",
"super",
".",
"init",
"(",
"record",
")",
";",
"}"
] | Constructor.
@param record My owner (usually passed as null, and set on addListener in setOwner()). | [
"Constructor",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/event/NoDeleteModifyHandler.java#L59-L64 |
sonyxperiadev/gerrit-events | src/main/java/com/sonymobile/tools/gerrit/gerritevents/GerritJsonEventFactory.java | GerritJsonEventFactory.getBoolean | public static boolean getBoolean(JSONObject json, String key, boolean defaultValue) {
"""
Returns the value of a JSON property as a boolean if it exists and boolean value
otherwise returns the defaultValue.
@param json the JSONObject to check.
@param key the key.
@param defaultValue the value to return if the key is missing or not boolean value.
@return the value for the key as a boolean.
"""
if (json.containsKey(key)) {
boolean result;
try {
result = json.getBoolean(key);
} catch (JSONException ex) {
result = defaultValue;
}
return result;
} else {
return defaultValue;
}
} | java | public static boolean getBoolean(JSONObject json, String key, boolean defaultValue) {
if (json.containsKey(key)) {
boolean result;
try {
result = json.getBoolean(key);
} catch (JSONException ex) {
result = defaultValue;
}
return result;
} else {
return defaultValue;
}
} | [
"public",
"static",
"boolean",
"getBoolean",
"(",
"JSONObject",
"json",
",",
"String",
"key",
",",
"boolean",
"defaultValue",
")",
"{",
"if",
"(",
"json",
".",
"containsKey",
"(",
"key",
")",
")",
"{",
"boolean",
"result",
";",
"try",
"{",
"result",
"=",
"json",
".",
"getBoolean",
"(",
"key",
")",
";",
"}",
"catch",
"(",
"JSONException",
"ex",
")",
"{",
"result",
"=",
"defaultValue",
";",
"}",
"return",
"result",
";",
"}",
"else",
"{",
"return",
"defaultValue",
";",
"}",
"}"
] | Returns the value of a JSON property as a boolean if it exists and boolean value
otherwise returns the defaultValue.
@param json the JSONObject to check.
@param key the key.
@param defaultValue the value to return if the key is missing or not boolean value.
@return the value for the key as a boolean. | [
"Returns",
"the",
"value",
"of",
"a",
"JSON",
"property",
"as",
"a",
"boolean",
"if",
"it",
"exists",
"and",
"boolean",
"value",
"otherwise",
"returns",
"the",
"defaultValue",
"."
] | train | https://github.com/sonyxperiadev/gerrit-events/blob/9a443d13dded85cc4709136ac33989f2bbb34fe2/src/main/java/com/sonymobile/tools/gerrit/gerritevents/GerritJsonEventFactory.java#L233-L245 |
versionone/VersionOne.SDK.Java.ObjectModel | src/main/java/com/versionone/om/Project.java | Project.createGoal | public Goal createGoal(String name, Map<String, Object> attributes) {
"""
Create a new Goal in this Project.
@param name The initial name of the Goal.
@param attributes additional attributes for the Goal.
@return A new Goal.
"""
return getInstance().create().goal(name, this, attributes);
} | java | public Goal createGoal(String name, Map<String, Object> attributes) {
return getInstance().create().goal(name, this, attributes);
} | [
"public",
"Goal",
"createGoal",
"(",
"String",
"name",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"attributes",
")",
"{",
"return",
"getInstance",
"(",
")",
".",
"create",
"(",
")",
".",
"goal",
"(",
"name",
",",
"this",
",",
"attributes",
")",
";",
"}"
] | Create a new Goal in this Project.
@param name The initial name of the Goal.
@param attributes additional attributes for the Goal.
@return A new Goal. | [
"Create",
"a",
"new",
"Goal",
"in",
"this",
"Project",
"."
] | train | https://github.com/versionone/VersionOne.SDK.Java.ObjectModel/blob/59d35b67c849299631bca45ee94143237eb2ae1a/src/main/java/com/versionone/om/Project.java#L272-L274 |
h2oai/h2o-2 | src/main/java/water/fvec/CBSChunk.java | CBSChunk.clen | public static int clen(int values, int bpv) {
"""
Returns compressed len of the given array length if the value if represented by bpv-bits.
"""
int len = (values*bpv) >> 3;
return values*bpv % 8 == 0 ? len : len + 1;
} | java | public static int clen(int values, int bpv) {
int len = (values*bpv) >> 3;
return values*bpv % 8 == 0 ? len : len + 1;
} | [
"public",
"static",
"int",
"clen",
"(",
"int",
"values",
",",
"int",
"bpv",
")",
"{",
"int",
"len",
"=",
"(",
"values",
"*",
"bpv",
")",
">>",
"3",
";",
"return",
"values",
"*",
"bpv",
"%",
"8",
"==",
"0",
"?",
"len",
":",
"len",
"+",
"1",
";",
"}"
] | Returns compressed len of the given array length if the value if represented by bpv-bits. | [
"Returns",
"compressed",
"len",
"of",
"the",
"given",
"array",
"length",
"if",
"the",
"value",
"if",
"represented",
"by",
"bpv",
"-",
"bits",
"."
] | train | https://github.com/h2oai/h2o-2/blob/be350f3f2c2fb6f135cc07c41f83fd0e4f521ac1/src/main/java/water/fvec/CBSChunk.java#L84-L87 |
Esri/geometry-api-java | src/main/java/com/esri/core/geometry/MultiPathImpl.java | MultiPathImpl.closePathWithBezier | public void closePathWithBezier(Point2D controlPoint1, Point2D controlPoint2) {
"""
Closes last path of the MultiPathImpl with the Bezier Segment.
The start point of the Bezier is the last point of the path and the last
point of the bezier is the first point of the path.
"""
_touch();
if (isEmptyImpl())
throw new GeometryException(
"Invalid call. This operation cannot be performed on an empty geometry.");
m_bPathStarted = false;
int pathIndex = m_paths.size() - 2;
byte pf = m_pathFlags.read(pathIndex);
m_pathFlags
.write(pathIndex,
(byte) (pf | PathFlags.enumClosed | PathFlags.enumHasNonlinearSegments));
_initSegmentData(6);
byte oldType = m_segmentFlags
.read((byte) ((m_pointCount - 1) & SegmentFlags.enumSegmentMask));
m_segmentFlags.write(m_pointCount - 1,
(byte) (SegmentFlags.enumBezierSeg));
int curveIndex = m_curveParamwritePoint;
if (getSegmentDataSize(oldType) < getSegmentDataSize((byte) SegmentFlags.enumBezierSeg)) {
m_segmentParamIndex.write(m_pointCount - 1, m_curveParamwritePoint);
m_curveParamwritePoint += 6;
} else {
// there was a closing bezier curve or an arc here. We can reuse the
// storage.
curveIndex = m_segmentParamIndex.read(m_pointCount - 1);
}
double z;
m_segmentParams.write(curveIndex, controlPoint1.x);
m_segmentParams.write(curveIndex + 1, controlPoint1.y);
z = 0;// TODO: calculate me.
m_segmentParams.write(curveIndex + 2, z);
m_segmentParams.write(curveIndex + 3, controlPoint2.x);
m_segmentParams.write(curveIndex + 4, controlPoint2.y);
z = 0;// TODO: calculate me.
m_segmentParams.write(curveIndex + 5, z);
} | java | public void closePathWithBezier(Point2D controlPoint1, Point2D controlPoint2) {
_touch();
if (isEmptyImpl())
throw new GeometryException(
"Invalid call. This operation cannot be performed on an empty geometry.");
m_bPathStarted = false;
int pathIndex = m_paths.size() - 2;
byte pf = m_pathFlags.read(pathIndex);
m_pathFlags
.write(pathIndex,
(byte) (pf | PathFlags.enumClosed | PathFlags.enumHasNonlinearSegments));
_initSegmentData(6);
byte oldType = m_segmentFlags
.read((byte) ((m_pointCount - 1) & SegmentFlags.enumSegmentMask));
m_segmentFlags.write(m_pointCount - 1,
(byte) (SegmentFlags.enumBezierSeg));
int curveIndex = m_curveParamwritePoint;
if (getSegmentDataSize(oldType) < getSegmentDataSize((byte) SegmentFlags.enumBezierSeg)) {
m_segmentParamIndex.write(m_pointCount - 1, m_curveParamwritePoint);
m_curveParamwritePoint += 6;
} else {
// there was a closing bezier curve or an arc here. We can reuse the
// storage.
curveIndex = m_segmentParamIndex.read(m_pointCount - 1);
}
double z;
m_segmentParams.write(curveIndex, controlPoint1.x);
m_segmentParams.write(curveIndex + 1, controlPoint1.y);
z = 0;// TODO: calculate me.
m_segmentParams.write(curveIndex + 2, z);
m_segmentParams.write(curveIndex + 3, controlPoint2.x);
m_segmentParams.write(curveIndex + 4, controlPoint2.y);
z = 0;// TODO: calculate me.
m_segmentParams.write(curveIndex + 5, z);
} | [
"public",
"void",
"closePathWithBezier",
"(",
"Point2D",
"controlPoint1",
",",
"Point2D",
"controlPoint2",
")",
"{",
"_touch",
"(",
")",
";",
"if",
"(",
"isEmptyImpl",
"(",
")",
")",
"throw",
"new",
"GeometryException",
"(",
"\"Invalid call. This operation cannot be performed on an empty geometry.\"",
")",
";",
"m_bPathStarted",
"=",
"false",
";",
"int",
"pathIndex",
"=",
"m_paths",
".",
"size",
"(",
")",
"-",
"2",
";",
"byte",
"pf",
"=",
"m_pathFlags",
".",
"read",
"(",
"pathIndex",
")",
";",
"m_pathFlags",
".",
"write",
"(",
"pathIndex",
",",
"(",
"byte",
")",
"(",
"pf",
"|",
"PathFlags",
".",
"enumClosed",
"|",
"PathFlags",
".",
"enumHasNonlinearSegments",
")",
")",
";",
"_initSegmentData",
"(",
"6",
")",
";",
"byte",
"oldType",
"=",
"m_segmentFlags",
".",
"read",
"(",
"(",
"byte",
")",
"(",
"(",
"m_pointCount",
"-",
"1",
")",
"&",
"SegmentFlags",
".",
"enumSegmentMask",
")",
")",
";",
"m_segmentFlags",
".",
"write",
"(",
"m_pointCount",
"-",
"1",
",",
"(",
"byte",
")",
"(",
"SegmentFlags",
".",
"enumBezierSeg",
")",
")",
";",
"int",
"curveIndex",
"=",
"m_curveParamwritePoint",
";",
"if",
"(",
"getSegmentDataSize",
"(",
"oldType",
")",
"<",
"getSegmentDataSize",
"(",
"(",
"byte",
")",
"SegmentFlags",
".",
"enumBezierSeg",
")",
")",
"{",
"m_segmentParamIndex",
".",
"write",
"(",
"m_pointCount",
"-",
"1",
",",
"m_curveParamwritePoint",
")",
";",
"m_curveParamwritePoint",
"+=",
"6",
";",
"}",
"else",
"{",
"// there was a closing bezier curve or an arc here. We can reuse the",
"// storage.",
"curveIndex",
"=",
"m_segmentParamIndex",
".",
"read",
"(",
"m_pointCount",
"-",
"1",
")",
";",
"}",
"double",
"z",
";",
"m_segmentParams",
".",
"write",
"(",
"curveIndex",
",",
"controlPoint1",
".",
"x",
")",
";",
"m_segmentParams",
".",
"write",
"(",
"curveIndex",
"+",
"1",
",",
"controlPoint1",
".",
"y",
")",
";",
"z",
"=",
"0",
";",
"// TODO: calculate me.",
"m_segmentParams",
".",
"write",
"(",
"curveIndex",
"+",
"2",
",",
"z",
")",
";",
"m_segmentParams",
".",
"write",
"(",
"curveIndex",
"+",
"3",
",",
"controlPoint2",
".",
"x",
")",
";",
"m_segmentParams",
".",
"write",
"(",
"curveIndex",
"+",
"4",
",",
"controlPoint2",
".",
"y",
")",
";",
"z",
"=",
"0",
";",
"// TODO: calculate me.",
"m_segmentParams",
".",
"write",
"(",
"curveIndex",
"+",
"5",
",",
"z",
")",
";",
"}"
] | Closes last path of the MultiPathImpl with the Bezier Segment.
The start point of the Bezier is the last point of the path and the last
point of the bezier is the first point of the path. | [
"Closes",
"last",
"path",
"of",
"the",
"MultiPathImpl",
"with",
"the",
"Bezier",
"Segment",
"."
] | train | https://github.com/Esri/geometry-api-java/blob/494da8ec953d76e7c6072afbc081abfe48ff07cf/src/main/java/com/esri/core/geometry/MultiPathImpl.java#L524-L564 |
kiegroup/jbpm | jbpm-query-jpa/src/main/java/org/jbpm/query/jpa/impl/QueryCriteriaUtil.java | QueryCriteriaUtil.getEntityField | protected <T> Expression getEntityField(CriteriaQuery<T> query, String listId, Attribute attr) {
"""
This method retrieves the entity "field" that can be used as the LHS of a {@link Predicate}
</p>
This method is overridden in some extended {@link QueryCriteriaUtil} implementations
@param query The {@link CriteriaQuery} that we're building
@param listId The list id of the given {@link QueryCriteria}
@return An {@link Expression} with the {@link Path} to the field represented by the {@link QueryCriteria#getListId()} value
"""
return defaultGetEntityField(query, listId, attr);
} | java | protected <T> Expression getEntityField(CriteriaQuery<T> query, String listId, Attribute attr) {
return defaultGetEntityField(query, listId, attr);
} | [
"protected",
"<",
"T",
">",
"Expression",
"getEntityField",
"(",
"CriteriaQuery",
"<",
"T",
">",
"query",
",",
"String",
"listId",
",",
"Attribute",
"attr",
")",
"{",
"return",
"defaultGetEntityField",
"(",
"query",
",",
"listId",
",",
"attr",
")",
";",
"}"
] | This method retrieves the entity "field" that can be used as the LHS of a {@link Predicate}
</p>
This method is overridden in some extended {@link QueryCriteriaUtil} implementations
@param query The {@link CriteriaQuery} that we're building
@param listId The list id of the given {@link QueryCriteria}
@return An {@link Expression} with the {@link Path} to the field represented by the {@link QueryCriteria#getListId()} value | [
"This",
"method",
"retrieves",
"the",
"entity",
"field",
"that",
"can",
"be",
"used",
"as",
"the",
"LHS",
"of",
"a",
"{",
"@link",
"Predicate",
"}",
"<",
"/",
"p",
">",
"This",
"method",
"is",
"overridden",
"in",
"some",
"extended",
"{",
"@link",
"QueryCriteriaUtil",
"}",
"implementations"
] | train | https://github.com/kiegroup/jbpm/blob/c3473c728aa382ebbea01e380c5e754a96647b82/jbpm-query-jpa/src/main/java/org/jbpm/query/jpa/impl/QueryCriteriaUtil.java#L443-L445 |
javalite/activejdbc | activejdbc/src/main/java/org/javalite/activejdbc/Configuration.java | Configuration.overrideFromEnvironmentVariables | private void overrideFromEnvironmentVariables() {
"""
Overrides current environment's connection spec from system properties.
"""
String url = System.getenv("ACTIVEJDBC.URL");
String user = System.getenv("ACTIVEJDBC.USER");
String password = System.getenv("ACTIVEJDBC.PASSWORD");
String driver = System.getenv("ACTIVEJDBC.DRIVER");
if(!blank(url) && !blank(user) && !blank(password) && !blank(driver)){
connectionSpecMap.put(getEnvironment(), new ConnectionJdbcSpec(driver, url, user, password));
}
String jndi = System.getenv("ACTIVEJDBC.JNDI");
if(!blank(jndi)){
connectionSpecMap.put(getEnvironment(), new ConnectionJndiSpec(jndi));
}
} | java | private void overrideFromEnvironmentVariables() {
String url = System.getenv("ACTIVEJDBC.URL");
String user = System.getenv("ACTIVEJDBC.USER");
String password = System.getenv("ACTIVEJDBC.PASSWORD");
String driver = System.getenv("ACTIVEJDBC.DRIVER");
if(!blank(url) && !blank(user) && !blank(password) && !blank(driver)){
connectionSpecMap.put(getEnvironment(), new ConnectionJdbcSpec(driver, url, user, password));
}
String jndi = System.getenv("ACTIVEJDBC.JNDI");
if(!blank(jndi)){
connectionSpecMap.put(getEnvironment(), new ConnectionJndiSpec(jndi));
}
} | [
"private",
"void",
"overrideFromEnvironmentVariables",
"(",
")",
"{",
"String",
"url",
"=",
"System",
".",
"getenv",
"(",
"\"ACTIVEJDBC.URL\"",
")",
";",
"String",
"user",
"=",
"System",
".",
"getenv",
"(",
"\"ACTIVEJDBC.USER\"",
")",
";",
"String",
"password",
"=",
"System",
".",
"getenv",
"(",
"\"ACTIVEJDBC.PASSWORD\"",
")",
";",
"String",
"driver",
"=",
"System",
".",
"getenv",
"(",
"\"ACTIVEJDBC.DRIVER\"",
")",
";",
"if",
"(",
"!",
"blank",
"(",
"url",
")",
"&&",
"!",
"blank",
"(",
"user",
")",
"&&",
"!",
"blank",
"(",
"password",
")",
"&&",
"!",
"blank",
"(",
"driver",
")",
")",
"{",
"connectionSpecMap",
".",
"put",
"(",
"getEnvironment",
"(",
")",
",",
"new",
"ConnectionJdbcSpec",
"(",
"driver",
",",
"url",
",",
"user",
",",
"password",
")",
")",
";",
"}",
"String",
"jndi",
"=",
"System",
".",
"getenv",
"(",
"\"ACTIVEJDBC.JNDI\"",
")",
";",
"if",
"(",
"!",
"blank",
"(",
"jndi",
")",
")",
"{",
"connectionSpecMap",
".",
"put",
"(",
"getEnvironment",
"(",
")",
",",
"new",
"ConnectionJndiSpec",
"(",
"jndi",
")",
")",
";",
"}",
"}"
] | Overrides current environment's connection spec from system properties. | [
"Overrides",
"current",
"environment",
"s",
"connection",
"spec",
"from",
"system",
"properties",
"."
] | train | https://github.com/javalite/activejdbc/blob/ffcf5457cace19622a8f71e856cbbbe9e7dd5fcc/activejdbc/src/main/java/org/javalite/activejdbc/Configuration.java#L137-L150 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/conf/layers/LayerValidation.java | LayerValidation.assertNInNOutSet | public static void assertNInNOutSet(String layerType, String layerName, long layerIndex, long nIn, long nOut) {
"""
Asserts that the layer nIn and nOut values are set for the layer
@param layerType Type of layer ("DenseLayer", etc)
@param layerName Name of the layer (may be null if not set)
@param layerIndex Index of the layer
@param nIn nIn value
@param nOut nOut value
"""
if (nIn <= 0 || nOut <= 0) {
if (layerName == null)
layerName = "(name not set)";
throw new DL4JInvalidConfigException(layerType + " (index=" + layerIndex + ", name=" + layerName + ") nIn="
+ nIn + ", nOut=" + nOut + "; nIn and nOut must be > 0");
}
} | java | public static void assertNInNOutSet(String layerType, String layerName, long layerIndex, long nIn, long nOut) {
if (nIn <= 0 || nOut <= 0) {
if (layerName == null)
layerName = "(name not set)";
throw new DL4JInvalidConfigException(layerType + " (index=" + layerIndex + ", name=" + layerName + ") nIn="
+ nIn + ", nOut=" + nOut + "; nIn and nOut must be > 0");
}
} | [
"public",
"static",
"void",
"assertNInNOutSet",
"(",
"String",
"layerType",
",",
"String",
"layerName",
",",
"long",
"layerIndex",
",",
"long",
"nIn",
",",
"long",
"nOut",
")",
"{",
"if",
"(",
"nIn",
"<=",
"0",
"||",
"nOut",
"<=",
"0",
")",
"{",
"if",
"(",
"layerName",
"==",
"null",
")",
"layerName",
"=",
"\"(name not set)\"",
";",
"throw",
"new",
"DL4JInvalidConfigException",
"(",
"layerType",
"+",
"\" (index=\"",
"+",
"layerIndex",
"+",
"\", name=\"",
"+",
"layerName",
"+",
"\") nIn=\"",
"+",
"nIn",
"+",
"\", nOut=\"",
"+",
"nOut",
"+",
"\"; nIn and nOut must be > 0\"",
")",
";",
"}",
"}"
] | Asserts that the layer nIn and nOut values are set for the layer
@param layerType Type of layer ("DenseLayer", etc)
@param layerName Name of the layer (may be null if not set)
@param layerIndex Index of the layer
@param nIn nIn value
@param nOut nOut value | [
"Asserts",
"that",
"the",
"layer",
"nIn",
"and",
"nOut",
"values",
"are",
"set",
"for",
"the",
"layer"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/conf/layers/LayerValidation.java#L50-L57 |
Alexey1Gavrilov/ExpectIt | expectit-core/src/main/java/net/sf/expectit/filter/Filters.java | Filters.replaceInBuffer | public static Filter replaceInBuffer(final String regexp, final String replacement) {
"""
Equivalent to {@link #replaceInBuffer(java.util.regex.Pattern,
String)} but takes the regular expression
as string.
@param regexp the regular expression
@param replacement the string to be substituted for each match
@return the filter
"""
return replaceInBuffer(Pattern.compile(regexp), replacement);
} | java | public static Filter replaceInBuffer(final String regexp, final String replacement) {
return replaceInBuffer(Pattern.compile(regexp), replacement);
} | [
"public",
"static",
"Filter",
"replaceInBuffer",
"(",
"final",
"String",
"regexp",
",",
"final",
"String",
"replacement",
")",
"{",
"return",
"replaceInBuffer",
"(",
"Pattern",
".",
"compile",
"(",
"regexp",
")",
",",
"replacement",
")",
";",
"}"
] | Equivalent to {@link #replaceInBuffer(java.util.regex.Pattern,
String)} but takes the regular expression
as string.
@param regexp the regular expression
@param replacement the string to be substituted for each match
@return the filter | [
"Equivalent",
"to",
"{",
"@link",
"#replaceInBuffer",
"(",
"java",
".",
"util",
".",
"regex",
".",
"Pattern",
"String",
")",
"}",
"but",
"takes",
"the",
"regular",
"expression",
"as",
"string",
"."
] | train | https://github.com/Alexey1Gavrilov/ExpectIt/blob/5acbe1f8f895fe1dbd63e29bf3ab8e5bbf0873c3/expectit-core/src/main/java/net/sf/expectit/filter/Filters.java#L151-L153 |
orbisgis/h2gis | h2gis-functions/src/main/java/org/h2gis/functions/spatial/clean/MakeValidOp.java | MakeValidOp.nodeLineString | private Set<LineString> nodeLineString(Coordinate[] coords, GeometryFactory gf) {
"""
Nodes a LineString and returns a List of Noded LineString's. Used to
repare auto-intersecting LineString and Polygons. This method cannot
process CoordinateSequence. The noding process is limited to 3d
geometries.<br/>
Preserves duplicate coordinates.
@param coords coordinate array to be noded
@param gf geometryFactory to use
@return a list of noded LineStrings
"""
MCIndexNoder noder = new MCIndexNoder();
noder.setSegmentIntersector(new IntersectionAdder(new RobustLineIntersector()));
List<NodedSegmentString> list = new ArrayList<>();
list.add(new NodedSegmentString(coords, null));
noder.computeNodes(list);
List<LineString> lineStringList = new ArrayList<>();
for (Object segmentString : noder.getNodedSubstrings()) {
lineStringList.add(gf.createLineString(
((NodedSegmentString) segmentString).getCoordinates()
));
}
// WARNING : merger loose original linestrings
// It is useful for LinearRings but should not be used for (Multi)LineStrings
LineMerger merger = new LineMerger();
merger.add(lineStringList);
lineStringList = (List<LineString>) merger.getMergedLineStrings();
// Remove duplicate linestrings preserving main orientation
Set<LineString> lineStringSet = new HashSet<>();
for (LineString line : lineStringList) {
// TODO as equals makes a topological comparison, comparison with line.reverse maybe useless
if (!lineStringSet.contains(line) && !lineStringSet.contains(line.reverse())) {
lineStringSet.add(line);
}
}
return lineStringSet;
} | java | private Set<LineString> nodeLineString(Coordinate[] coords, GeometryFactory gf) {
MCIndexNoder noder = new MCIndexNoder();
noder.setSegmentIntersector(new IntersectionAdder(new RobustLineIntersector()));
List<NodedSegmentString> list = new ArrayList<>();
list.add(new NodedSegmentString(coords, null));
noder.computeNodes(list);
List<LineString> lineStringList = new ArrayList<>();
for (Object segmentString : noder.getNodedSubstrings()) {
lineStringList.add(gf.createLineString(
((NodedSegmentString) segmentString).getCoordinates()
));
}
// WARNING : merger loose original linestrings
// It is useful for LinearRings but should not be used for (Multi)LineStrings
LineMerger merger = new LineMerger();
merger.add(lineStringList);
lineStringList = (List<LineString>) merger.getMergedLineStrings();
// Remove duplicate linestrings preserving main orientation
Set<LineString> lineStringSet = new HashSet<>();
for (LineString line : lineStringList) {
// TODO as equals makes a topological comparison, comparison with line.reverse maybe useless
if (!lineStringSet.contains(line) && !lineStringSet.contains(line.reverse())) {
lineStringSet.add(line);
}
}
return lineStringSet;
} | [
"private",
"Set",
"<",
"LineString",
">",
"nodeLineString",
"(",
"Coordinate",
"[",
"]",
"coords",
",",
"GeometryFactory",
"gf",
")",
"{",
"MCIndexNoder",
"noder",
"=",
"new",
"MCIndexNoder",
"(",
")",
";",
"noder",
".",
"setSegmentIntersector",
"(",
"new",
"IntersectionAdder",
"(",
"new",
"RobustLineIntersector",
"(",
")",
")",
")",
";",
"List",
"<",
"NodedSegmentString",
">",
"list",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"list",
".",
"add",
"(",
"new",
"NodedSegmentString",
"(",
"coords",
",",
"null",
")",
")",
";",
"noder",
".",
"computeNodes",
"(",
"list",
")",
";",
"List",
"<",
"LineString",
">",
"lineStringList",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"Object",
"segmentString",
":",
"noder",
".",
"getNodedSubstrings",
"(",
")",
")",
"{",
"lineStringList",
".",
"add",
"(",
"gf",
".",
"createLineString",
"(",
"(",
"(",
"NodedSegmentString",
")",
"segmentString",
")",
".",
"getCoordinates",
"(",
")",
")",
")",
";",
"}",
"// WARNING : merger loose original linestrings",
"// It is useful for LinearRings but should not be used for (Multi)LineStrings",
"LineMerger",
"merger",
"=",
"new",
"LineMerger",
"(",
")",
";",
"merger",
".",
"add",
"(",
"lineStringList",
")",
";",
"lineStringList",
"=",
"(",
"List",
"<",
"LineString",
">",
")",
"merger",
".",
"getMergedLineStrings",
"(",
")",
";",
"// Remove duplicate linestrings preserving main orientation",
"Set",
"<",
"LineString",
">",
"lineStringSet",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"for",
"(",
"LineString",
"line",
":",
"lineStringList",
")",
"{",
"// TODO as equals makes a topological comparison, comparison with line.reverse maybe useless",
"if",
"(",
"!",
"lineStringSet",
".",
"contains",
"(",
"line",
")",
"&&",
"!",
"lineStringSet",
".",
"contains",
"(",
"line",
".",
"reverse",
"(",
")",
")",
")",
"{",
"lineStringSet",
".",
"add",
"(",
"line",
")",
";",
"}",
"}",
"return",
"lineStringSet",
";",
"}"
] | Nodes a LineString and returns a List of Noded LineString's. Used to
repare auto-intersecting LineString and Polygons. This method cannot
process CoordinateSequence. The noding process is limited to 3d
geometries.<br/>
Preserves duplicate coordinates.
@param coords coordinate array to be noded
@param gf geometryFactory to use
@return a list of noded LineStrings | [
"Nodes",
"a",
"LineString",
"and",
"returns",
"a",
"List",
"of",
"Noded",
"LineString",
"s",
".",
"Used",
"to",
"repare",
"auto",
"-",
"intersecting",
"LineString",
"and",
"Polygons",
".",
"This",
"method",
"cannot",
"process",
"CoordinateSequence",
".",
"The",
"noding",
"process",
"is",
"limited",
"to",
"3d",
"geometries",
".",
"<br",
"/",
">",
"Preserves",
"duplicate",
"coordinates",
"."
] | train | https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/clean/MakeValidOp.java#L647-L675 |
orbisgis/h2gis | h2gis-utilities/src/main/java/org/h2gis/utilities/TableLocation.java | TableLocation.quoteIdentifier | public static String quoteIdentifier(String identifier, boolean isH2DataBase) {
"""
Quote identifier only if necessary. Require database knowledge.
@param identifier Catalog,Schema,Table or Field name
@param isH2DataBase True if the quote is for H2, false if for POSTGRE
@return Quoted Identifier
"""
if((isH2DataBase && (Constants.H2_RESERVED_WORDS.contains(identifier.toUpperCase())
|| !H2_SPECIAL_NAME_PATTERN.matcher(identifier).find())) ||
(!isH2DataBase && (Constants.POSTGIS_RESERVED_WORDS.contains(identifier.toUpperCase())
|| !POSTGRE_SPECIAL_NAME_PATTERN.matcher(identifier).find()))) {
return quoteIdentifier(identifier);
} else {
return identifier;
}
} | java | public static String quoteIdentifier(String identifier, boolean isH2DataBase) {
if((isH2DataBase && (Constants.H2_RESERVED_WORDS.contains(identifier.toUpperCase())
|| !H2_SPECIAL_NAME_PATTERN.matcher(identifier).find())) ||
(!isH2DataBase && (Constants.POSTGIS_RESERVED_WORDS.contains(identifier.toUpperCase())
|| !POSTGRE_SPECIAL_NAME_PATTERN.matcher(identifier).find()))) {
return quoteIdentifier(identifier);
} else {
return identifier;
}
} | [
"public",
"static",
"String",
"quoteIdentifier",
"(",
"String",
"identifier",
",",
"boolean",
"isH2DataBase",
")",
"{",
"if",
"(",
"(",
"isH2DataBase",
"&&",
"(",
"Constants",
".",
"H2_RESERVED_WORDS",
".",
"contains",
"(",
"identifier",
".",
"toUpperCase",
"(",
")",
")",
"||",
"!",
"H2_SPECIAL_NAME_PATTERN",
".",
"matcher",
"(",
"identifier",
")",
".",
"find",
"(",
")",
")",
")",
"||",
"(",
"!",
"isH2DataBase",
"&&",
"(",
"Constants",
".",
"POSTGIS_RESERVED_WORDS",
".",
"contains",
"(",
"identifier",
".",
"toUpperCase",
"(",
")",
")",
"||",
"!",
"POSTGRE_SPECIAL_NAME_PATTERN",
".",
"matcher",
"(",
"identifier",
")",
".",
"find",
"(",
")",
")",
")",
")",
"{",
"return",
"quoteIdentifier",
"(",
"identifier",
")",
";",
"}",
"else",
"{",
"return",
"identifier",
";",
"}",
"}"
] | Quote identifier only if necessary. Require database knowledge.
@param identifier Catalog,Schema,Table or Field name
@param isH2DataBase True if the quote is for H2, false if for POSTGRE
@return Quoted Identifier | [
"Quote",
"identifier",
"only",
"if",
"necessary",
".",
"Require",
"database",
"knowledge",
"."
] | train | https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-utilities/src/main/java/org/h2gis/utilities/TableLocation.java#L96-L105 |
ironjacamar/ironjacamar | core/src/main/java/org/ironjacamar/core/tracer/Tracer.java | Tracer.getConnection | public static synchronized void getConnection(String poolName, Object mcp, Object cl, Object connection) {
"""
Get connection
@param poolName The name of the pool
@param mcp The managed connection pool
@param cl The connection listener
@param connection The connection
"""
log.tracef("%s", new TraceEvent(poolName,
Integer.toHexString(System.identityHashCode(mcp)),
TraceEvent.GET_CONNECTION,
Integer.toHexString(System.identityHashCode(cl)),
Integer.toHexString(System.identityHashCode(connection))));
} | java | public static synchronized void getConnection(String poolName, Object mcp, Object cl, Object connection)
{
log.tracef("%s", new TraceEvent(poolName,
Integer.toHexString(System.identityHashCode(mcp)),
TraceEvent.GET_CONNECTION,
Integer.toHexString(System.identityHashCode(cl)),
Integer.toHexString(System.identityHashCode(connection))));
} | [
"public",
"static",
"synchronized",
"void",
"getConnection",
"(",
"String",
"poolName",
",",
"Object",
"mcp",
",",
"Object",
"cl",
",",
"Object",
"connection",
")",
"{",
"log",
".",
"tracef",
"(",
"\"%s\"",
",",
"new",
"TraceEvent",
"(",
"poolName",
",",
"Integer",
".",
"toHexString",
"(",
"System",
".",
"identityHashCode",
"(",
"mcp",
")",
")",
",",
"TraceEvent",
".",
"GET_CONNECTION",
",",
"Integer",
".",
"toHexString",
"(",
"System",
".",
"identityHashCode",
"(",
"cl",
")",
")",
",",
"Integer",
".",
"toHexString",
"(",
"System",
".",
"identityHashCode",
"(",
"connection",
")",
")",
")",
")",
";",
"}"
] | Get connection
@param poolName The name of the pool
@param mcp The managed connection pool
@param cl The connection listener
@param connection The connection | [
"Get",
"connection"
] | train | https://github.com/ironjacamar/ironjacamar/blob/f0389ee7e62aa8b40ba09b251edad76d220ea796/core/src/main/java/org/ironjacamar/core/tracer/Tracer.java#L373-L380 |
eFaps/eFaps-Kernel | src/main/java/org/efaps/update/version/Application.java | Application.compileAll | public void compileAll(final String _userName,
final boolean _addRuntimeClassPath)
throws InstallationException {
"""
Compiles the ESJP's and all Cascade Styles Sheets within eFaps.
@param _userName name of logged in user for which the compile is done
(could be also <code>null</code>)
@param _addRuntimeClassPath must the classpath from the runtime be added
to the classpath also
@throws InstallationException if reload cache of compile failed
"""
if (Application.LOG.isInfoEnabled()) {
Application.LOG.info("..Compiling");
}
reloadCache();
try {
Context.begin(_userName);
try {
new ESJPCompiler(getClassPathElements()).compile(null, _addRuntimeClassPath);
} catch (final InstallationException e) {
Application.LOG.error(" error during compilation of ESJP.", e);
}
try {
AbstractStaticSourceCompiler.compileAll(this.classpathElements);
} catch (final EFapsException e) {
Application.LOG.error(" error during compilation of static sources.");
}
Context.commit();
} catch (final EFapsException e) {
throw new InstallationException("Compile failed", e);
}
} | java | public void compileAll(final String _userName,
final boolean _addRuntimeClassPath)
throws InstallationException
{
if (Application.LOG.isInfoEnabled()) {
Application.LOG.info("..Compiling");
}
reloadCache();
try {
Context.begin(_userName);
try {
new ESJPCompiler(getClassPathElements()).compile(null, _addRuntimeClassPath);
} catch (final InstallationException e) {
Application.LOG.error(" error during compilation of ESJP.", e);
}
try {
AbstractStaticSourceCompiler.compileAll(this.classpathElements);
} catch (final EFapsException e) {
Application.LOG.error(" error during compilation of static sources.");
}
Context.commit();
} catch (final EFapsException e) {
throw new InstallationException("Compile failed", e);
}
} | [
"public",
"void",
"compileAll",
"(",
"final",
"String",
"_userName",
",",
"final",
"boolean",
"_addRuntimeClassPath",
")",
"throws",
"InstallationException",
"{",
"if",
"(",
"Application",
".",
"LOG",
".",
"isInfoEnabled",
"(",
")",
")",
"{",
"Application",
".",
"LOG",
".",
"info",
"(",
"\"..Compiling\"",
")",
";",
"}",
"reloadCache",
"(",
")",
";",
"try",
"{",
"Context",
".",
"begin",
"(",
"_userName",
")",
";",
"try",
"{",
"new",
"ESJPCompiler",
"(",
"getClassPathElements",
"(",
")",
")",
".",
"compile",
"(",
"null",
",",
"_addRuntimeClassPath",
")",
";",
"}",
"catch",
"(",
"final",
"InstallationException",
"e",
")",
"{",
"Application",
".",
"LOG",
".",
"error",
"(",
"\" error during compilation of ESJP.\"",
",",
"e",
")",
";",
"}",
"try",
"{",
"AbstractStaticSourceCompiler",
".",
"compileAll",
"(",
"this",
".",
"classpathElements",
")",
";",
"}",
"catch",
"(",
"final",
"EFapsException",
"e",
")",
"{",
"Application",
".",
"LOG",
".",
"error",
"(",
"\" error during compilation of static sources.\"",
")",
";",
"}",
"Context",
".",
"commit",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"EFapsException",
"e",
")",
"{",
"throw",
"new",
"InstallationException",
"(",
"\"Compile failed\"",
",",
"e",
")",
";",
"}",
"}"
] | Compiles the ESJP's and all Cascade Styles Sheets within eFaps.
@param _userName name of logged in user for which the compile is done
(could be also <code>null</code>)
@param _addRuntimeClassPath must the classpath from the runtime be added
to the classpath also
@throws InstallationException if reload cache of compile failed | [
"Compiles",
"the",
"ESJP",
"s",
"and",
"all",
"Cascade",
"Styles",
"Sheets",
"within",
"eFaps",
"."
] | train | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/update/version/Application.java#L462-L488 |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/theta/UnionImpl.java | UnionImpl.heapifyInstance | static UnionImpl heapifyInstance(final Memory srcMem, final long seed) {
"""
Heapify a Union from a Memory Union object containing data.
Called by SetOperation.
@param srcMem The source Memory Union object.
<a href="{@docRoot}/resources/dictionary.html#mem">See Memory</a>
@param seed <a href="{@docRoot}/resources/dictionary.html#seed">See seed</a>
@return this class
"""
Family.UNION.checkFamilyID(extractFamilyID(srcMem));
final UpdateSketch gadget = HeapQuickSelectSketch.heapifyInstance(srcMem, seed);
final UnionImpl unionImpl = new UnionImpl(gadget, seed);
unionImpl.unionThetaLong_ = extractUnionThetaLong(srcMem);
unionImpl.unionEmpty_ = PreambleUtil.isEmpty(srcMem);
return unionImpl;
} | java | static UnionImpl heapifyInstance(final Memory srcMem, final long seed) {
Family.UNION.checkFamilyID(extractFamilyID(srcMem));
final UpdateSketch gadget = HeapQuickSelectSketch.heapifyInstance(srcMem, seed);
final UnionImpl unionImpl = new UnionImpl(gadget, seed);
unionImpl.unionThetaLong_ = extractUnionThetaLong(srcMem);
unionImpl.unionEmpty_ = PreambleUtil.isEmpty(srcMem);
return unionImpl;
} | [
"static",
"UnionImpl",
"heapifyInstance",
"(",
"final",
"Memory",
"srcMem",
",",
"final",
"long",
"seed",
")",
"{",
"Family",
".",
"UNION",
".",
"checkFamilyID",
"(",
"extractFamilyID",
"(",
"srcMem",
")",
")",
";",
"final",
"UpdateSketch",
"gadget",
"=",
"HeapQuickSelectSketch",
".",
"heapifyInstance",
"(",
"srcMem",
",",
"seed",
")",
";",
"final",
"UnionImpl",
"unionImpl",
"=",
"new",
"UnionImpl",
"(",
"gadget",
",",
"seed",
")",
";",
"unionImpl",
".",
"unionThetaLong_",
"=",
"extractUnionThetaLong",
"(",
"srcMem",
")",
";",
"unionImpl",
".",
"unionEmpty_",
"=",
"PreambleUtil",
".",
"isEmpty",
"(",
"srcMem",
")",
";",
"return",
"unionImpl",
";",
"}"
] | Heapify a Union from a Memory Union object containing data.
Called by SetOperation.
@param srcMem The source Memory Union object.
<a href="{@docRoot}/resources/dictionary.html#mem">See Memory</a>
@param seed <a href="{@docRoot}/resources/dictionary.html#seed">See seed</a>
@return this class | [
"Heapify",
"a",
"Union",
"from",
"a",
"Memory",
"Union",
"object",
"containing",
"data",
".",
"Called",
"by",
"SetOperation",
"."
] | train | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/theta/UnionImpl.java#L119-L126 |
MenoData/Time4J | base/src/main/java/net/time4j/DayPeriod.java | DayPeriod.of | public static DayPeriod of(Map<PlainTime, String> timeToLabels) {
"""
/*[deutsch]
<p>Erzeugt eine Instanz, die auf benutzerdefinierten Daten beruht. </p>
@param timeToLabels map containing the day-periods where the keys represent starting points
and the values represent the associated labels intended for representation
@return user-specific instance
@throws IllegalArgumentException if given map is empty or contains empty values
@since 3.13/4.10
"""
if (timeToLabels.isEmpty()) {
throw new IllegalArgumentException("Label map is empty.");
}
SortedMap<PlainTime, String> map = new TreeMap<>(timeToLabels);
for (PlainTime key : timeToLabels.keySet()) {
if (key.getHour() == 24) {
map.put(PlainTime.midnightAtStartOfDay(), timeToLabels.get(key));
map.remove(key);
} else if (timeToLabels.get(key).isEmpty()) {
throw new IllegalArgumentException("Map has empty label: " + timeToLabels);
}
}
return new DayPeriod(null, "", map);
} | java | public static DayPeriod of(Map<PlainTime, String> timeToLabels) {
if (timeToLabels.isEmpty()) {
throw new IllegalArgumentException("Label map is empty.");
}
SortedMap<PlainTime, String> map = new TreeMap<>(timeToLabels);
for (PlainTime key : timeToLabels.keySet()) {
if (key.getHour() == 24) {
map.put(PlainTime.midnightAtStartOfDay(), timeToLabels.get(key));
map.remove(key);
} else if (timeToLabels.get(key).isEmpty()) {
throw new IllegalArgumentException("Map has empty label: " + timeToLabels);
}
}
return new DayPeriod(null, "", map);
} | [
"public",
"static",
"DayPeriod",
"of",
"(",
"Map",
"<",
"PlainTime",
",",
"String",
">",
"timeToLabels",
")",
"{",
"if",
"(",
"timeToLabels",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Label map is empty.\"",
")",
";",
"}",
"SortedMap",
"<",
"PlainTime",
",",
"String",
">",
"map",
"=",
"new",
"TreeMap",
"<>",
"(",
"timeToLabels",
")",
";",
"for",
"(",
"PlainTime",
"key",
":",
"timeToLabels",
".",
"keySet",
"(",
")",
")",
"{",
"if",
"(",
"key",
".",
"getHour",
"(",
")",
"==",
"24",
")",
"{",
"map",
".",
"put",
"(",
"PlainTime",
".",
"midnightAtStartOfDay",
"(",
")",
",",
"timeToLabels",
".",
"get",
"(",
"key",
")",
")",
";",
"map",
".",
"remove",
"(",
"key",
")",
";",
"}",
"else",
"if",
"(",
"timeToLabels",
".",
"get",
"(",
"key",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Map has empty label: \"",
"+",
"timeToLabels",
")",
";",
"}",
"}",
"return",
"new",
"DayPeriod",
"(",
"null",
",",
"\"\"",
",",
"map",
")",
";",
"}"
] | /*[deutsch]
<p>Erzeugt eine Instanz, die auf benutzerdefinierten Daten beruht. </p>
@param timeToLabels map containing the day-periods where the keys represent starting points
and the values represent the associated labels intended for representation
@return user-specific instance
@throws IllegalArgumentException if given map is empty or contains empty values
@since 3.13/4.10 | [
"/",
"*",
"[",
"deutsch",
"]",
"<p",
">",
"Erzeugt",
"eine",
"Instanz",
"die",
"auf",
"benutzerdefinierten",
"Daten",
"beruht",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/DayPeriod.java#L180-L199 |
segmentio/analytics-android | analytics/src/main/java/com/segment/analytics/internal/Utils.java | Utils.getDeviceId | @SuppressLint("HardwareIds")
public static String getDeviceId(Context context) {
"""
Creates a unique device id. Suppresses `HardwareIds` lint warnings as we don't use this ID for
identifying specific users. This is also what is required by the Segment spec.
"""
String androidId = getString(context.getContentResolver(), ANDROID_ID);
if (!isNullOrEmpty(androidId)
&& !"9774d56d682e549c".equals(androidId)
&& !"unknown".equals(androidId)
&& !"000000000000000".equals(androidId)) {
return androidId;
}
// Serial number, guaranteed to be on all non phones in 2.3+.
if (!isNullOrEmpty(Build.SERIAL)) {
return Build.SERIAL;
}
// Telephony ID, guaranteed to be on all phones, requires READ_PHONE_STATE permission
if (hasPermission(context, READ_PHONE_STATE) && hasFeature(context, FEATURE_TELEPHONY)) {
TelephonyManager telephonyManager = getSystemService(context, TELEPHONY_SERVICE);
@SuppressLint("MissingPermission")
String telephonyId = telephonyManager.getDeviceId();
if (!isNullOrEmpty(telephonyId)) {
return telephonyId;
}
}
// If this still fails, generate random identifier that does not persist across installations
return UUID.randomUUID().toString();
} | java | @SuppressLint("HardwareIds")
public static String getDeviceId(Context context) {
String androidId = getString(context.getContentResolver(), ANDROID_ID);
if (!isNullOrEmpty(androidId)
&& !"9774d56d682e549c".equals(androidId)
&& !"unknown".equals(androidId)
&& !"000000000000000".equals(androidId)) {
return androidId;
}
// Serial number, guaranteed to be on all non phones in 2.3+.
if (!isNullOrEmpty(Build.SERIAL)) {
return Build.SERIAL;
}
// Telephony ID, guaranteed to be on all phones, requires READ_PHONE_STATE permission
if (hasPermission(context, READ_PHONE_STATE) && hasFeature(context, FEATURE_TELEPHONY)) {
TelephonyManager telephonyManager = getSystemService(context, TELEPHONY_SERVICE);
@SuppressLint("MissingPermission")
String telephonyId = telephonyManager.getDeviceId();
if (!isNullOrEmpty(telephonyId)) {
return telephonyId;
}
}
// If this still fails, generate random identifier that does not persist across installations
return UUID.randomUUID().toString();
} | [
"@",
"SuppressLint",
"(",
"\"HardwareIds\"",
")",
"public",
"static",
"String",
"getDeviceId",
"(",
"Context",
"context",
")",
"{",
"String",
"androidId",
"=",
"getString",
"(",
"context",
".",
"getContentResolver",
"(",
")",
",",
"ANDROID_ID",
")",
";",
"if",
"(",
"!",
"isNullOrEmpty",
"(",
"androidId",
")",
"&&",
"!",
"\"9774d56d682e549c\"",
".",
"equals",
"(",
"androidId",
")",
"&&",
"!",
"\"unknown\"",
".",
"equals",
"(",
"androidId",
")",
"&&",
"!",
"\"000000000000000\"",
".",
"equals",
"(",
"androidId",
")",
")",
"{",
"return",
"androidId",
";",
"}",
"// Serial number, guaranteed to be on all non phones in 2.3+.",
"if",
"(",
"!",
"isNullOrEmpty",
"(",
"Build",
".",
"SERIAL",
")",
")",
"{",
"return",
"Build",
".",
"SERIAL",
";",
"}",
"// Telephony ID, guaranteed to be on all phones, requires READ_PHONE_STATE permission",
"if",
"(",
"hasPermission",
"(",
"context",
",",
"READ_PHONE_STATE",
")",
"&&",
"hasFeature",
"(",
"context",
",",
"FEATURE_TELEPHONY",
")",
")",
"{",
"TelephonyManager",
"telephonyManager",
"=",
"getSystemService",
"(",
"context",
",",
"TELEPHONY_SERVICE",
")",
";",
"@",
"SuppressLint",
"(",
"\"MissingPermission\"",
")",
"String",
"telephonyId",
"=",
"telephonyManager",
".",
"getDeviceId",
"(",
")",
";",
"if",
"(",
"!",
"isNullOrEmpty",
"(",
"telephonyId",
")",
")",
"{",
"return",
"telephonyId",
";",
"}",
"}",
"// If this still fails, generate random identifier that does not persist across installations",
"return",
"UUID",
".",
"randomUUID",
"(",
")",
".",
"toString",
"(",
")",
";",
"}"
] | Creates a unique device id. Suppresses `HardwareIds` lint warnings as we don't use this ID for
identifying specific users. This is also what is required by the Segment spec. | [
"Creates",
"a",
"unique",
"device",
"id",
".",
"Suppresses",
"HardwareIds",
"lint",
"warnings",
"as",
"we",
"don",
"t",
"use",
"this",
"ID",
"for",
"identifying",
"specific",
"users",
".",
"This",
"is",
"also",
"what",
"is",
"required",
"by",
"the",
"Segment",
"spec",
"."
] | train | https://github.com/segmentio/analytics-android/blob/93c7d5bb09b593440a2347a6089db3e9f74012da/analytics/src/main/java/com/segment/analytics/internal/Utils.java#L254-L281 |
carewebframework/carewebframework-core | org.carewebframework.api-parent/org.carewebframework.api.core/src/main/java/org/carewebframework/api/AppFramework.java | AppFramework.postProcessAfterInitialization | @Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
"""
Automatically registers any container-managed bean with the framework.
@param bean Object to register.
@param beanName Name of the managed bean.
"""
registerObject(bean);
return bean;
} | java | @Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
registerObject(bean);
return bean;
} | [
"@",
"Override",
"public",
"Object",
"postProcessAfterInitialization",
"(",
"Object",
"bean",
",",
"String",
"beanName",
")",
"throws",
"BeansException",
"{",
"registerObject",
"(",
"bean",
")",
";",
"return",
"bean",
";",
"}"
] | Automatically registers any container-managed bean with the framework.
@param bean Object to register.
@param beanName Name of the managed bean. | [
"Automatically",
"registers",
"any",
"container",
"-",
"managed",
"bean",
"with",
"the",
"framework",
"."
] | train | https://github.com/carewebframework/carewebframework-core/blob/fa3252d4f7541dbe151b92c3d4f6f91433cd1673/org.carewebframework.api-parent/org.carewebframework.api.core/src/main/java/org/carewebframework/api/AppFramework.java#L197-L201 |
moparisthebest/beehive | beehive-netui-core/src/main/java/org/apache/beehive/netui/script/common/ImplicitObjectUtil.java | ImplicitObjectUtil.loadOutputFormBean | public static void loadOutputFormBean(ServletRequest request, Object bean) {
"""
Load the output form bean into the request.
@param request the request
@param bean the output form bean
"""
if(bean != null)
request.setAttribute(OUTPUT_FORM_BEAN_OBJECT_KEY, bean);
} | java | public static void loadOutputFormBean(ServletRequest request, Object bean) {
if(bean != null)
request.setAttribute(OUTPUT_FORM_BEAN_OBJECT_KEY, bean);
} | [
"public",
"static",
"void",
"loadOutputFormBean",
"(",
"ServletRequest",
"request",
",",
"Object",
"bean",
")",
"{",
"if",
"(",
"bean",
"!=",
"null",
")",
"request",
".",
"setAttribute",
"(",
"OUTPUT_FORM_BEAN_OBJECT_KEY",
",",
"bean",
")",
";",
"}"
] | Load the output form bean into the request.
@param request the request
@param bean the output form bean | [
"Load",
"the",
"output",
"form",
"bean",
"into",
"the",
"request",
"."
] | train | https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-core/src/main/java/org/apache/beehive/netui/script/common/ImplicitObjectUtil.java#L165-L168 |
xwiki/xwiki-commons | xwiki-commons-core/xwiki-commons-crypto/xwiki-commons-crypto-store/xwiki-commons-crypto-store-filesystem/src/main/java/org/xwiki/crypto/store/filesystem/internal/AbstractX509FileSystemStore.java | AbstractX509FileSystemStore.writeFooter | private static void writeFooter(BufferedWriter out, String type) throws IOException {
"""
Write a PEM like footer.
@param out the output buffered writer to write to.
@param type the type to be written in the footer.
@throws IOException on error.
"""
out.write(PEM_END + type + DASHES);
out.newLine();
} | java | private static void writeFooter(BufferedWriter out, String type) throws IOException
{
out.write(PEM_END + type + DASHES);
out.newLine();
} | [
"private",
"static",
"void",
"writeFooter",
"(",
"BufferedWriter",
"out",
",",
"String",
"type",
")",
"throws",
"IOException",
"{",
"out",
".",
"write",
"(",
"PEM_END",
"+",
"type",
"+",
"DASHES",
")",
";",
"out",
".",
"newLine",
"(",
")",
";",
"}"
] | Write a PEM like footer.
@param out the output buffered writer to write to.
@param type the type to be written in the footer.
@throws IOException on error. | [
"Write",
"a",
"PEM",
"like",
"footer",
"."
] | train | https://github.com/xwiki/xwiki-commons/blob/5374d8c6d966588c1eac7392c83da610dfb9f129/xwiki-commons-core/xwiki-commons-crypto/xwiki-commons-crypto-store/xwiki-commons-crypto-store-filesystem/src/main/java/org/xwiki/crypto/store/filesystem/internal/AbstractX509FileSystemStore.java#L130-L134 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/shape/Shape.java | Shape.getOffset | public static long getOffset(DataBuffer shapeInformation, int row, int col) {
"""
Get the offset of the specified [row,col] for the 2d array
@param shapeInformation Shape information
@param row Row index to get the offset for
@param col Column index to get the offset for
@return Buffer offset
"""
int rank = rank(shapeInformation);
if (rank != 2)
throw new IllegalArgumentException(
"Cannot use this getOffset method on arrays of rank != 2 (rank is: " + rank + ")");
return getOffsetUnsafe(shapeInformation, row, col);
} | java | public static long getOffset(DataBuffer shapeInformation, int row, int col) {
int rank = rank(shapeInformation);
if (rank != 2)
throw new IllegalArgumentException(
"Cannot use this getOffset method on arrays of rank != 2 (rank is: " + rank + ")");
return getOffsetUnsafe(shapeInformation, row, col);
} | [
"public",
"static",
"long",
"getOffset",
"(",
"DataBuffer",
"shapeInformation",
",",
"int",
"row",
",",
"int",
"col",
")",
"{",
"int",
"rank",
"=",
"rank",
"(",
"shapeInformation",
")",
";",
"if",
"(",
"rank",
"!=",
"2",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Cannot use this getOffset method on arrays of rank != 2 (rank is: \"",
"+",
"rank",
"+",
"\")\"",
")",
";",
"return",
"getOffsetUnsafe",
"(",
"shapeInformation",
",",
"row",
",",
"col",
")",
";",
"}"
] | Get the offset of the specified [row,col] for the 2d array
@param shapeInformation Shape information
@param row Row index to get the offset for
@param col Column index to get the offset for
@return Buffer offset | [
"Get",
"the",
"offset",
"of",
"the",
"specified",
"[",
"row",
"col",
"]",
"for",
"the",
"2d",
"array"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/shape/Shape.java#L991-L997 |
alkacon/opencms-core | src/org/opencms/util/CmsStringUtil.java | CmsStringUtil.countChar | public static int countChar(String s, char c) {
"""
Counts the occurrence of a given char in a given String.<p>
@param s the string
@param c the char to count
@return returns the count of occurrences of a given char in a given String
"""
int counter = 0;
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == c) {
counter++;
}
}
return counter;
} | java | public static int countChar(String s, char c) {
int counter = 0;
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == c) {
counter++;
}
}
return counter;
} | [
"public",
"static",
"int",
"countChar",
"(",
"String",
"s",
",",
"char",
"c",
")",
"{",
"int",
"counter",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"s",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"s",
".",
"charAt",
"(",
"i",
")",
"==",
"c",
")",
"{",
"counter",
"++",
";",
"}",
"}",
"return",
"counter",
";",
"}"
] | Counts the occurrence of a given char in a given String.<p>
@param s the string
@param c the char to count
@return returns the count of occurrences of a given char in a given String | [
"Counts",
"the",
"occurrence",
"of",
"a",
"given",
"char",
"in",
"a",
"given",
"String",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/util/CmsStringUtil.java#L339-L348 |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/parser/JavacParser.java | JavacParser.arrayInitializer | JCExpression arrayInitializer(int newpos, JCExpression t) {
"""
ArrayInitializer = "{" [VariableInitializer {"," VariableInitializer}] [","] "}"
"""
accept(LBRACE);
ListBuffer<JCExpression> elems = new ListBuffer<JCExpression>();
if (token.kind == COMMA) {
nextToken();
} else if (token.kind != RBRACE) {
elems.append(variableInitializer());
while (token.kind == COMMA) {
nextToken();
if (token.kind == RBRACE) break;
elems.append(variableInitializer());
}
}
accept(RBRACE);
return toP(F.at(newpos).NewArray(t, List.<JCExpression>nil(), elems.toList()));
} | java | JCExpression arrayInitializer(int newpos, JCExpression t) {
accept(LBRACE);
ListBuffer<JCExpression> elems = new ListBuffer<JCExpression>();
if (token.kind == COMMA) {
nextToken();
} else if (token.kind != RBRACE) {
elems.append(variableInitializer());
while (token.kind == COMMA) {
nextToken();
if (token.kind == RBRACE) break;
elems.append(variableInitializer());
}
}
accept(RBRACE);
return toP(F.at(newpos).NewArray(t, List.<JCExpression>nil(), elems.toList()));
} | [
"JCExpression",
"arrayInitializer",
"(",
"int",
"newpos",
",",
"JCExpression",
"t",
")",
"{",
"accept",
"(",
"LBRACE",
")",
";",
"ListBuffer",
"<",
"JCExpression",
">",
"elems",
"=",
"new",
"ListBuffer",
"<",
"JCExpression",
">",
"(",
")",
";",
"if",
"(",
"token",
".",
"kind",
"==",
"COMMA",
")",
"{",
"nextToken",
"(",
")",
";",
"}",
"else",
"if",
"(",
"token",
".",
"kind",
"!=",
"RBRACE",
")",
"{",
"elems",
".",
"append",
"(",
"variableInitializer",
"(",
")",
")",
";",
"while",
"(",
"token",
".",
"kind",
"==",
"COMMA",
")",
"{",
"nextToken",
"(",
")",
";",
"if",
"(",
"token",
".",
"kind",
"==",
"RBRACE",
")",
"break",
";",
"elems",
".",
"append",
"(",
"variableInitializer",
"(",
")",
")",
";",
"}",
"}",
"accept",
"(",
"RBRACE",
")",
";",
"return",
"toP",
"(",
"F",
".",
"at",
"(",
"newpos",
")",
".",
"NewArray",
"(",
"t",
",",
"List",
".",
"<",
"JCExpression",
">",
"nil",
"(",
")",
",",
"elems",
".",
"toList",
"(",
")",
")",
")",
";",
"}"
] | ArrayInitializer = "{" [VariableInitializer {"," VariableInitializer}] [","] "}" | [
"ArrayInitializer",
"=",
"{",
"[",
"VariableInitializer",
"{",
"VariableInitializer",
"}",
"]",
"[",
"]",
"}"
] | train | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/parser/JavacParser.java#L2286-L2301 |
Subsets and Splits