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
|
---|---|---|---|---|---|---|---|---|---|---|
line/armeria | core/src/main/java/com/linecorp/armeria/common/logging/LoggingDecoratorBuilder.java | LoggingDecoratorBuilder.responseCauseSanitizer | public T responseCauseSanitizer(Function<? super Throwable, ? extends Throwable> responseCauseSanitizer) {
"""
Sets the {@link Function} to use to sanitize a response cause before logging. You can
sanitize the stack trace of the exception to remove sensitive information, or prevent from logging
the stack trace completely by returning {@code null} in the {@link Function}. If unset, will use
{@link Function#identity()}.
"""
this.responseCauseSanitizer = requireNonNull(responseCauseSanitizer, "responseCauseSanitizer");
return self();
} | java | public T responseCauseSanitizer(Function<? super Throwable, ? extends Throwable> responseCauseSanitizer) {
this.responseCauseSanitizer = requireNonNull(responseCauseSanitizer, "responseCauseSanitizer");
return self();
} | [
"public",
"T",
"responseCauseSanitizer",
"(",
"Function",
"<",
"?",
"super",
"Throwable",
",",
"?",
"extends",
"Throwable",
">",
"responseCauseSanitizer",
")",
"{",
"this",
".",
"responseCauseSanitizer",
"=",
"requireNonNull",
"(",
"responseCauseSanitizer",
",",
"\"responseCauseSanitizer\"",
")",
";",
"return",
"self",
"(",
")",
";",
"}"
] | Sets the {@link Function} to use to sanitize a response cause before logging. You can
sanitize the stack trace of the exception to remove sensitive information, or prevent from logging
the stack trace completely by returning {@code null} in the {@link Function}. If unset, will use
{@link Function#identity()}. | [
"Sets",
"the",
"{"
] | train | https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/common/logging/LoggingDecoratorBuilder.java#L256-L259 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java | ModelsImpl.addExplicitListItem | public int addExplicitListItem(UUID appId, String versionId, UUID entityId, AddExplicitListItemOptionalParameter addExplicitListItemOptionalParameter) {
"""
Add a new item to the explicit list for the Pattern.Any entity.
@param appId The application ID.
@param versionId The version ID.
@param entityId The Pattern.Any entity extractor ID.
@param addExplicitListItemOptionalParameter the object representing the optional parameters to be set before calling this API
@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
@return the int object if successful.
"""
return addExplicitListItemWithServiceResponseAsync(appId, versionId, entityId, addExplicitListItemOptionalParameter).toBlocking().single().body();
} | java | public int addExplicitListItem(UUID appId, String versionId, UUID entityId, AddExplicitListItemOptionalParameter addExplicitListItemOptionalParameter) {
return addExplicitListItemWithServiceResponseAsync(appId, versionId, entityId, addExplicitListItemOptionalParameter).toBlocking().single().body();
} | [
"public",
"int",
"addExplicitListItem",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"UUID",
"entityId",
",",
"AddExplicitListItemOptionalParameter",
"addExplicitListItemOptionalParameter",
")",
"{",
"return",
"addExplicitListItemWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"entityId",
",",
"addExplicitListItemOptionalParameter",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Add a new item to the explicit list for the Pattern.Any entity.
@param appId The application ID.
@param versionId The version ID.
@param entityId The Pattern.Any entity extractor ID.
@param addExplicitListItemOptionalParameter the object representing the optional parameters to be set before calling this API
@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
@return the int object if successful. | [
"Add",
"a",
"new",
"item",
"to",
"the",
"explicit",
"list",
"for",
"the",
"Pattern",
".",
"Any",
"entity",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java#L9992-L9994 |
googleapis/google-cloud-java | google-cloud-clients/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/ConfigClient.java | ConfigClient.updateSink | public final LogSink updateSink(String sinkName, LogSink sink, FieldMask updateMask) {
"""
Updates a sink. This method replaces the following fields in the existing sink with values from
the new sink: `destination`, and `filter`. The updated sink might also have a new
`writer_identity`; see the `unique_writer_identity` field.
<p>Sample code:
<pre><code>
try (ConfigClient configClient = ConfigClient.create()) {
SinkName sinkName = ProjectSinkName.of("[PROJECT]", "[SINK]");
LogSink sink = LogSink.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
LogSink response = configClient.updateSink(sinkName.toString(), sink, updateMask);
}
</code></pre>
@param sinkName Required. The full resource name of the sink to update, including the parent
resource and the sink identifier:
<p>"projects/[PROJECT_ID]/sinks/[SINK_ID]"
"organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]"
"billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]"
"folders/[FOLDER_ID]/sinks/[SINK_ID]"
<p>Example: `"projects/my-project-id/sinks/my-sink-id"`.
@param sink Required. The updated sink, whose name is the same identifier that appears as part
of `sink_name`.
@param updateMask Optional. Field mask that specifies the fields in `sink` that need an update.
A sink field will be overwritten if, and only if, it is in the update mask. `name` and
output only fields cannot be updated.
<p>An empty updateMask is temporarily treated as using the following mask for backwards
compatibility purposes: destination,filter,includeChildren At some point in the future,
behavior will be removed and specifying an empty updateMask will be an error.
<p>For a detailed `FieldMask` definition, see
https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask
<p>Example: `updateMask=filter`.
@throws com.google.api.gax.rpc.ApiException if the remote call fails
"""
UpdateSinkRequest request =
UpdateSinkRequest.newBuilder()
.setSinkName(sinkName)
.setSink(sink)
.setUpdateMask(updateMask)
.build();
return updateSink(request);
} | java | public final LogSink updateSink(String sinkName, LogSink sink, FieldMask updateMask) {
UpdateSinkRequest request =
UpdateSinkRequest.newBuilder()
.setSinkName(sinkName)
.setSink(sink)
.setUpdateMask(updateMask)
.build();
return updateSink(request);
} | [
"public",
"final",
"LogSink",
"updateSink",
"(",
"String",
"sinkName",
",",
"LogSink",
"sink",
",",
"FieldMask",
"updateMask",
")",
"{",
"UpdateSinkRequest",
"request",
"=",
"UpdateSinkRequest",
".",
"newBuilder",
"(",
")",
".",
"setSinkName",
"(",
"sinkName",
")",
".",
"setSink",
"(",
"sink",
")",
".",
"setUpdateMask",
"(",
"updateMask",
")",
".",
"build",
"(",
")",
";",
"return",
"updateSink",
"(",
"request",
")",
";",
"}"
] | Updates a sink. This method replaces the following fields in the existing sink with values from
the new sink: `destination`, and `filter`. The updated sink might also have a new
`writer_identity`; see the `unique_writer_identity` field.
<p>Sample code:
<pre><code>
try (ConfigClient configClient = ConfigClient.create()) {
SinkName sinkName = ProjectSinkName.of("[PROJECT]", "[SINK]");
LogSink sink = LogSink.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
LogSink response = configClient.updateSink(sinkName.toString(), sink, updateMask);
}
</code></pre>
@param sinkName Required. The full resource name of the sink to update, including the parent
resource and the sink identifier:
<p>"projects/[PROJECT_ID]/sinks/[SINK_ID]"
"organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]"
"billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]"
"folders/[FOLDER_ID]/sinks/[SINK_ID]"
<p>Example: `"projects/my-project-id/sinks/my-sink-id"`.
@param sink Required. The updated sink, whose name is the same identifier that appears as part
of `sink_name`.
@param updateMask Optional. Field mask that specifies the fields in `sink` that need an update.
A sink field will be overwritten if, and only if, it is in the update mask. `name` and
output only fields cannot be updated.
<p>An empty updateMask is temporarily treated as using the following mask for backwards
compatibility purposes: destination,filter,includeChildren At some point in the future,
behavior will be removed and specifying an empty updateMask will be an error.
<p>For a detailed `FieldMask` definition, see
https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask
<p>Example: `updateMask=filter`.
@throws com.google.api.gax.rpc.ApiException if the remote call fails | [
"Updates",
"a",
"sink",
".",
"This",
"method",
"replaces",
"the",
"following",
"fields",
"in",
"the",
"existing",
"sink",
"with",
"values",
"from",
"the",
"new",
"sink",
":",
"destination",
"and",
"filter",
".",
"The",
"updated",
"sink",
"might",
"also",
"have",
"a",
"new",
"writer_identity",
";",
"see",
"the",
"unique_writer_identity",
"field",
"."
] | train | https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/ConfigClient.java#L613-L622 |
bwkimmel/jdcp | jdcp-core/src/main/java/ca/eandb/jdcp/remote/JobStatus.java | JobStatus.withIndeterminantProgress | public JobStatus withIndeterminantProgress() {
"""
Creates a copy of this <code>JobStatus</code> with the progress set to
an indeterminant value (<code>Double.NaN</code>).
@return A copy of this <code>JobStatus</code> with the progress set to
indeterminant.
"""
return new JobStatus(jobId, description, state, Double.NaN, status, eventId);
} | java | public JobStatus withIndeterminantProgress() {
return new JobStatus(jobId, description, state, Double.NaN, status, eventId);
} | [
"public",
"JobStatus",
"withIndeterminantProgress",
"(",
")",
"{",
"return",
"new",
"JobStatus",
"(",
"jobId",
",",
"description",
",",
"state",
",",
"Double",
".",
"NaN",
",",
"status",
",",
"eventId",
")",
";",
"}"
] | Creates a copy of this <code>JobStatus</code> with the progress set to
an indeterminant value (<code>Double.NaN</code>).
@return A copy of this <code>JobStatus</code> with the progress set to
indeterminant. | [
"Creates",
"a",
"copy",
"of",
"this",
"<code",
">",
"JobStatus<",
"/",
"code",
">",
"with",
"the",
"progress",
"set",
"to",
"an",
"indeterminant",
"value",
"(",
"<code",
">",
"Double",
".",
"NaN<",
"/",
"code",
">",
")",
"."
] | train | https://github.com/bwkimmel/jdcp/blob/630c5150c245054e2556ff370f4bad2ec793dfb7/jdcp-core/src/main/java/ca/eandb/jdcp/remote/JobStatus.java#L163-L165 |
petergeneric/stdlib | guice/common/src/main/java/com/peterphi/std/guice/common/serviceprops/ConfigurationPropertyRegistry.java | ConfigurationPropertyRegistry.addInstance | void addInstance(final Class<?> discoveredType, final Object newlyConstructed) {
"""
Register an instance of a property-consuming type; the registry will use a weak reference to hold on to this instance, so
that it can be discarded if it has a short lifespan
@param discoveredType
@param newlyConstructed
"""
WeakHashMap<Object, Void> map;
synchronized (instances)
{
map = instances.get(discoveredType);
if (map == null)
{
map = new WeakHashMap<>();
instances.put(discoveredType, map);
}
}
synchronized (map)
{
map.put(newlyConstructed, null);
}
} | java | void addInstance(final Class<?> discoveredType, final Object newlyConstructed)
{
WeakHashMap<Object, Void> map;
synchronized (instances)
{
map = instances.get(discoveredType);
if (map == null)
{
map = new WeakHashMap<>();
instances.put(discoveredType, map);
}
}
synchronized (map)
{
map.put(newlyConstructed, null);
}
} | [
"void",
"addInstance",
"(",
"final",
"Class",
"<",
"?",
">",
"discoveredType",
",",
"final",
"Object",
"newlyConstructed",
")",
"{",
"WeakHashMap",
"<",
"Object",
",",
"Void",
">",
"map",
";",
"synchronized",
"(",
"instances",
")",
"{",
"map",
"=",
"instances",
".",
"get",
"(",
"discoveredType",
")",
";",
"if",
"(",
"map",
"==",
"null",
")",
"{",
"map",
"=",
"new",
"WeakHashMap",
"<>",
"(",
")",
";",
"instances",
".",
"put",
"(",
"discoveredType",
",",
"map",
")",
";",
"}",
"}",
"synchronized",
"(",
"map",
")",
"{",
"map",
".",
"put",
"(",
"newlyConstructed",
",",
"null",
")",
";",
"}",
"}"
] | Register an instance of a property-consuming type; the registry will use a weak reference to hold on to this instance, so
that it can be discarded if it has a short lifespan
@param discoveredType
@param newlyConstructed | [
"Register",
"an",
"instance",
"of",
"a",
"property",
"-",
"consuming",
"type",
";",
"the",
"registry",
"will",
"use",
"a",
"weak",
"reference",
"to",
"hold",
"on",
"to",
"this",
"instance",
"so",
"that",
"it",
"can",
"be",
"discarded",
"if",
"it",
"has",
"a",
"short",
"lifespan"
] | train | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/common/src/main/java/com/peterphi/std/guice/common/serviceprops/ConfigurationPropertyRegistry.java#L112-L131 |
domaframework/doma-gen | src/main/java/org/seasar/doma/extension/gen/ClassDescSupport.java | ClassDescSupport.isImportTargetPackage | protected boolean isImportTargetPackage(ClassDesc classDesc, String importPackageName) {
"""
インポート対象のパッケージの場合 {@code true} を返します。
@param classDesc クラス記述
@param importPackageName インポートするパッケージ名
@return インポート対象のパッケージの場合 {@code true}
"""
if (importPackageName == null) {
return false;
}
if (importPackageName.isEmpty()) {
return false;
}
if (importPackageName.equals(classDesc.getPackageName())) {
return false;
}
if (importPackageName.equals("java.lang")) {
return false;
}
return true;
} | java | protected boolean isImportTargetPackage(ClassDesc classDesc, String importPackageName) {
if (importPackageName == null) {
return false;
}
if (importPackageName.isEmpty()) {
return false;
}
if (importPackageName.equals(classDesc.getPackageName())) {
return false;
}
if (importPackageName.equals("java.lang")) {
return false;
}
return true;
} | [
"protected",
"boolean",
"isImportTargetPackage",
"(",
"ClassDesc",
"classDesc",
",",
"String",
"importPackageName",
")",
"{",
"if",
"(",
"importPackageName",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"importPackageName",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"importPackageName",
".",
"equals",
"(",
"classDesc",
".",
"getPackageName",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"importPackageName",
".",
"equals",
"(",
"\"java.lang\"",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | インポート対象のパッケージの場合 {@code true} を返します。
@param classDesc クラス記述
@param importPackageName インポートするパッケージ名
@return インポート対象のパッケージの場合 {@code true} | [
"インポート対象のパッケージの場合",
"{",
"@code",
"true",
"}",
"を返します。"
] | train | https://github.com/domaframework/doma-gen/blob/8046e0b28d2167d444125f206ce36e554b3ee616/src/main/java/org/seasar/doma/extension/gen/ClassDescSupport.java#L73-L87 |
nilsreiter/uima-util | src/main/java/de/unistuttgart/ims/uimautil/AnnotationUtil.java | AnnotationUtil.trimBegin | public static <T extends Annotation> T trimBegin(T annotation, char... ws) {
"""
Moves the begin-index as long as a character contain in the array is at
the beginning.
@param annotation
the annotation to be trimmed
@param ws
an array of chars to be trimmed
@param <T>
the annotation type
@return the trimmed annotation
@since 0.4.2
"""
char[] s = annotation.getCoveredText().toCharArray();
if (s.length == 0)
return annotation;
int b = 0;
while (ArrayUtils.contains(ws, s[b])) {
b++;
}
annotation.setBegin(annotation.getBegin() + b);
return annotation;
} | java | public static <T extends Annotation> T trimBegin(T annotation, char... ws) {
char[] s = annotation.getCoveredText().toCharArray();
if (s.length == 0)
return annotation;
int b = 0;
while (ArrayUtils.contains(ws, s[b])) {
b++;
}
annotation.setBegin(annotation.getBegin() + b);
return annotation;
} | [
"public",
"static",
"<",
"T",
"extends",
"Annotation",
">",
"T",
"trimBegin",
"(",
"T",
"annotation",
",",
"char",
"...",
"ws",
")",
"{",
"char",
"[",
"]",
"s",
"=",
"annotation",
".",
"getCoveredText",
"(",
")",
".",
"toCharArray",
"(",
")",
";",
"if",
"(",
"s",
".",
"length",
"==",
"0",
")",
"return",
"annotation",
";",
"int",
"b",
"=",
"0",
";",
"while",
"(",
"ArrayUtils",
".",
"contains",
"(",
"ws",
",",
"s",
"[",
"b",
"]",
")",
")",
"{",
"b",
"++",
";",
"}",
"annotation",
".",
"setBegin",
"(",
"annotation",
".",
"getBegin",
"(",
")",
"+",
"b",
")",
";",
"return",
"annotation",
";",
"}"
] | Moves the begin-index as long as a character contain in the array is at
the beginning.
@param annotation
the annotation to be trimmed
@param ws
an array of chars to be trimmed
@param <T>
the annotation type
@return the trimmed annotation
@since 0.4.2 | [
"Moves",
"the",
"begin",
"-",
"index",
"as",
"long",
"as",
"a",
"character",
"contain",
"in",
"the",
"array",
"is",
"at",
"the",
"beginning",
"."
] | train | https://github.com/nilsreiter/uima-util/blob/6f3bc3b8785702fe4ab9b670b87eaa215006f593/src/main/java/de/unistuttgart/ims/uimautil/AnnotationUtil.java#L147-L159 |
elki-project/elki | elki-index/src/main/java/de/lmu/ifi/dbs/elki/index/tree/AbstractNode.java | AbstractNode.splitTo | public final void splitTo(AbstractNode<E> newNode, List<E> sorting, int splitPoint) {
"""
Redistribute entries according to the given sorting.
@param newNode Node to split to
@param sorting Sorting to use
@param splitPoint Split point
"""
assert (isLeaf() == newNode.isLeaf());
deleteAllEntries();
StringBuilder msg = LoggingConfiguration.DEBUG ? new StringBuilder(1000) : null;
for(int i = 0; i < splitPoint; i++) {
addEntry(sorting.get(i));
if(msg != null) {
msg.append("n_").append(getPageID()).append(' ').append(sorting.get(i)).append('\n');
}
}
for(int i = splitPoint; i < sorting.size(); i++) {
newNode.addEntry(sorting.get(i));
if(msg != null) {
msg.append("n_").append(newNode.getPageID()).append(' ').append(sorting.get(i)).append('\n');
}
}
if(msg != null) {
Logging.getLogger(this.getClass().getName()).fine(msg.toString());
}
} | java | public final void splitTo(AbstractNode<E> newNode, List<E> sorting, int splitPoint) {
assert (isLeaf() == newNode.isLeaf());
deleteAllEntries();
StringBuilder msg = LoggingConfiguration.DEBUG ? new StringBuilder(1000) : null;
for(int i = 0; i < splitPoint; i++) {
addEntry(sorting.get(i));
if(msg != null) {
msg.append("n_").append(getPageID()).append(' ').append(sorting.get(i)).append('\n');
}
}
for(int i = splitPoint; i < sorting.size(); i++) {
newNode.addEntry(sorting.get(i));
if(msg != null) {
msg.append("n_").append(newNode.getPageID()).append(' ').append(sorting.get(i)).append('\n');
}
}
if(msg != null) {
Logging.getLogger(this.getClass().getName()).fine(msg.toString());
}
} | [
"public",
"final",
"void",
"splitTo",
"(",
"AbstractNode",
"<",
"E",
">",
"newNode",
",",
"List",
"<",
"E",
">",
"sorting",
",",
"int",
"splitPoint",
")",
"{",
"assert",
"(",
"isLeaf",
"(",
")",
"==",
"newNode",
".",
"isLeaf",
"(",
")",
")",
";",
"deleteAllEntries",
"(",
")",
";",
"StringBuilder",
"msg",
"=",
"LoggingConfiguration",
".",
"DEBUG",
"?",
"new",
"StringBuilder",
"(",
"1000",
")",
":",
"null",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"splitPoint",
";",
"i",
"++",
")",
"{",
"addEntry",
"(",
"sorting",
".",
"get",
"(",
"i",
")",
")",
";",
"if",
"(",
"msg",
"!=",
"null",
")",
"{",
"msg",
".",
"append",
"(",
"\"n_\"",
")",
".",
"append",
"(",
"getPageID",
"(",
")",
")",
".",
"append",
"(",
"'",
"'",
")",
".",
"append",
"(",
"sorting",
".",
"get",
"(",
"i",
")",
")",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"}",
"for",
"(",
"int",
"i",
"=",
"splitPoint",
";",
"i",
"<",
"sorting",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"newNode",
".",
"addEntry",
"(",
"sorting",
".",
"get",
"(",
"i",
")",
")",
";",
"if",
"(",
"msg",
"!=",
"null",
")",
"{",
"msg",
".",
"append",
"(",
"\"n_\"",
")",
".",
"append",
"(",
"newNode",
".",
"getPageID",
"(",
")",
")",
".",
"append",
"(",
"'",
"'",
")",
".",
"append",
"(",
"sorting",
".",
"get",
"(",
"i",
")",
")",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"}",
"if",
"(",
"msg",
"!=",
"null",
")",
"{",
"Logging",
".",
"getLogger",
"(",
"this",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
".",
"fine",
"(",
"msg",
".",
"toString",
"(",
")",
")",
";",
"}",
"}"
] | Redistribute entries according to the given sorting.
@param newNode Node to split to
@param sorting Sorting to use
@param splitPoint Split point | [
"Redistribute",
"entries",
"according",
"to",
"the",
"given",
"sorting",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index/src/main/java/de/lmu/ifi/dbs/elki/index/tree/AbstractNode.java#L302-L323 |
ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/css/LineHeightProperty.java | LineHeightProperty.with | public CssSetter with(Integer value) {
"""
The used value of the property is this <code>value</code> multiplied by the
element's font size. Negative values are illegal.
"""
return new SimpleCssSetter(CSS_PROPERTY, value != null ? "" + value : null);
} | java | public CssSetter with(Integer value) {
return new SimpleCssSetter(CSS_PROPERTY, value != null ? "" + value : null);
} | [
"public",
"CssSetter",
"with",
"(",
"Integer",
"value",
")",
"{",
"return",
"new",
"SimpleCssSetter",
"(",
"CSS_PROPERTY",
",",
"value",
"!=",
"null",
"?",
"\"\"",
"+",
"value",
":",
"null",
")",
";",
"}"
] | The used value of the property is this <code>value</code> multiplied by the
element's font size. Negative values are illegal. | [
"The",
"used",
"value",
"of",
"the",
"property",
"is",
"this",
"<code",
">",
"value<",
"/",
"code",
">",
"multiplied",
"by",
"the",
"element",
"s",
"font",
"size",
".",
"Negative",
"values",
"are",
"illegal",
"."
] | train | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/css/LineHeightProperty.java#L49-L51 |
matthewhorridge/owlapi-gwt | owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLEquivalentObjectPropertiesAxiomImpl_CustomFieldSerializer.java | OWLEquivalentObjectPropertiesAxiomImpl_CustomFieldSerializer.serializeInstance | @Override
public void serializeInstance(SerializationStreamWriter streamWriter, OWLEquivalentObjectPropertiesAxiomImpl instance) throws SerializationException {
"""
Serializes the content of the object into the
{@link com.google.gwt.user.client.rpc.SerializationStreamWriter}.
@param streamWriter the {@link com.google.gwt.user.client.rpc.SerializationStreamWriter} to write the
object's content to
@param instance the object instance to serialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the serialization operation is not
successful
"""
serialize(streamWriter, instance);
} | java | @Override
public void serializeInstance(SerializationStreamWriter streamWriter, OWLEquivalentObjectPropertiesAxiomImpl instance) throws SerializationException {
serialize(streamWriter, instance);
} | [
"@",
"Override",
"public",
"void",
"serializeInstance",
"(",
"SerializationStreamWriter",
"streamWriter",
",",
"OWLEquivalentObjectPropertiesAxiomImpl",
"instance",
")",
"throws",
"SerializationException",
"{",
"serialize",
"(",
"streamWriter",
",",
"instance",
")",
";",
"}"
] | Serializes the content of the object into the
{@link com.google.gwt.user.client.rpc.SerializationStreamWriter}.
@param streamWriter the {@link com.google.gwt.user.client.rpc.SerializationStreamWriter} to write the
object's content to
@param instance the object instance to serialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the serialization operation is not
successful | [
"Serializes",
"the",
"content",
"of",
"the",
"object",
"into",
"the",
"{",
"@link",
"com",
".",
"google",
".",
"gwt",
".",
"user",
".",
"client",
".",
"rpc",
".",
"SerializationStreamWriter",
"}",
"."
] | train | https://github.com/matthewhorridge/owlapi-gwt/blob/7ab975fb6cef3c8947099983551672a3b5d4e2fd/owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLEquivalentObjectPropertiesAxiomImpl_CustomFieldSerializer.java#L75-L78 |
stickfigure/batchfb | src/main/java/com/googlecode/batchfb/impl/MultiqueryRequest.java | MultiqueryRequest.getParams | @Override
@JsonIgnore
protected Param[] getParams() {
"""
Generate the parameters approprate to a multiquery from the registered queries
"""
Map<String, String> queries = new LinkedHashMap<String, String>();
for (QueryRequest<?> req: this.queryRequests)
queries.put(req.getName(), req.getFQL());
String json = JSONUtils.toJSON(queries, this.mapper);
return new Param[] { new Param("queries", json) };
} | java | @Override
@JsonIgnore
protected Param[] getParams() {
Map<String, String> queries = new LinkedHashMap<String, String>();
for (QueryRequest<?> req: this.queryRequests)
queries.put(req.getName(), req.getFQL());
String json = JSONUtils.toJSON(queries, this.mapper);
return new Param[] { new Param("queries", json) };
} | [
"@",
"Override",
"@",
"JsonIgnore",
"protected",
"Param",
"[",
"]",
"getParams",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"queries",
"=",
"new",
"LinkedHashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"for",
"(",
"QueryRequest",
"<",
"?",
">",
"req",
":",
"this",
".",
"queryRequests",
")",
"queries",
".",
"put",
"(",
"req",
".",
"getName",
"(",
")",
",",
"req",
".",
"getFQL",
"(",
")",
")",
";",
"String",
"json",
"=",
"JSONUtils",
".",
"toJSON",
"(",
"queries",
",",
"this",
".",
"mapper",
")",
";",
"return",
"new",
"Param",
"[",
"]",
"{",
"new",
"Param",
"(",
"\"queries\"",
",",
"json",
")",
"}",
";",
"}"
] | Generate the parameters approprate to a multiquery from the registered queries | [
"Generate",
"the",
"parameters",
"approprate",
"to",
"a",
"multiquery",
"from",
"the",
"registered",
"queries"
] | train | https://github.com/stickfigure/batchfb/blob/ceeda78aa6d8397eec032ab1d8997adb7378e9e2/src/main/java/com/googlecode/batchfb/impl/MultiqueryRequest.java#L38-L48 |
BrunoEberhard/minimal-j | src/main/java/org/minimalj/util/DateUtils.java | DateUtils.parseCH | public static String parseCH(String inputText, boolean partialAllowed) {
"""
Converts a CH - Date String in a yyyy-mm-dd String. The conversion
is very lenient and tries to convert as long as its somehow clear
what the user may have wanted.
@param inputText The input text. Maybe empty or <code>null</code>.
@param partialAllowed false if the inputText has to be a complete date with month and day
@return null if the input text is empty (<code>null</code> or length 0). An empty String
if the input text doesn't fit a date or a String in format yyyy-mm-dd (or yyyy-mm or even
yyyy if partial allowed)
"""
if (StringUtils.isEmpty(inputText)) return null;
String text = cutNonDigitsAtBegin(inputText);
if (StringUtils.isEmpty(text)) return "";
text = cutNonDigitsAtEnd(text);
if (StringUtils.isEmpty(text)) return "";
// Nun hat der String sicher keinen Punkt mehr am Anfang oder Ende
if (inputText.indexOf(".") > -1) {
return parseCHWithDot(inputText, partialAllowed);
} else {
return parseCHWithoutDot(inputText, partialAllowed);
}
} | java | public static String parseCH(String inputText, boolean partialAllowed) {
if (StringUtils.isEmpty(inputText)) return null;
String text = cutNonDigitsAtBegin(inputText);
if (StringUtils.isEmpty(text)) return "";
text = cutNonDigitsAtEnd(text);
if (StringUtils.isEmpty(text)) return "";
// Nun hat der String sicher keinen Punkt mehr am Anfang oder Ende
if (inputText.indexOf(".") > -1) {
return parseCHWithDot(inputText, partialAllowed);
} else {
return parseCHWithoutDot(inputText, partialAllowed);
}
} | [
"public",
"static",
"String",
"parseCH",
"(",
"String",
"inputText",
",",
"boolean",
"partialAllowed",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"inputText",
")",
")",
"return",
"null",
";",
"String",
"text",
"=",
"cutNonDigitsAtBegin",
"(",
"inputText",
")",
";",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"text",
")",
")",
"return",
"\"\"",
";",
"text",
"=",
"cutNonDigitsAtEnd",
"(",
"text",
")",
";",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"text",
")",
")",
"return",
"\"\"",
";",
"// Nun hat der String sicher keinen Punkt mehr am Anfang oder Ende",
"if",
"(",
"inputText",
".",
"indexOf",
"(",
"\".\"",
")",
">",
"-",
"1",
")",
"{",
"return",
"parseCHWithDot",
"(",
"inputText",
",",
"partialAllowed",
")",
";",
"}",
"else",
"{",
"return",
"parseCHWithoutDot",
"(",
"inputText",
",",
"partialAllowed",
")",
";",
"}",
"}"
] | Converts a CH - Date String in a yyyy-mm-dd String. The conversion
is very lenient and tries to convert as long as its somehow clear
what the user may have wanted.
@param inputText The input text. Maybe empty or <code>null</code>.
@param partialAllowed false if the inputText has to be a complete date with month and day
@return null if the input text is empty (<code>null</code> or length 0). An empty String
if the input text doesn't fit a date or a String in format yyyy-mm-dd (or yyyy-mm or even
yyyy if partial allowed) | [
"Converts",
"a",
"CH",
"-",
"Date",
"String",
"in",
"a",
"yyyy",
"-",
"mm",
"-",
"dd",
"String",
".",
"The",
"conversion",
"is",
"very",
"lenient",
"and",
"tries",
"to",
"convert",
"as",
"long",
"as",
"its",
"somehow",
"clear",
"what",
"the",
"user",
"may",
"have",
"wanted",
"."
] | train | https://github.com/BrunoEberhard/minimal-j/blob/f7c5461b2b47a10b383aee1e2f1f150f6773703b/src/main/java/org/minimalj/util/DateUtils.java#L80-L94 |
Microsoft/malmo | Minecraft/src/main/java/com/microsoft/Malmo/Utils/MinecraftTypeHelper.java | MinecraftTypeHelper.applyColour | static IBlockState applyColour(IBlockState state, Colour colour) {
"""
Recolour the Minecraft block
@param state The block to be recoloured
@param colour The new colour
@return A new blockstate which is a recoloured version of the original
"""
for (IProperty prop : state.getProperties().keySet())
{
if (prop.getName().equals("color") && prop.getValueClass() == net.minecraft.item.EnumDyeColor.class)
{
net.minecraft.item.EnumDyeColor current = (net.minecraft.item.EnumDyeColor)state.getValue(prop);
if (!current.getName().equalsIgnoreCase(colour.name()))
{
return state.withProperty(prop, EnumDyeColor.valueOf(colour.name()));
}
}
}
return state;
} | java | static IBlockState applyColour(IBlockState state, Colour colour)
{
for (IProperty prop : state.getProperties().keySet())
{
if (prop.getName().equals("color") && prop.getValueClass() == net.minecraft.item.EnumDyeColor.class)
{
net.minecraft.item.EnumDyeColor current = (net.minecraft.item.EnumDyeColor)state.getValue(prop);
if (!current.getName().equalsIgnoreCase(colour.name()))
{
return state.withProperty(prop, EnumDyeColor.valueOf(colour.name()));
}
}
}
return state;
} | [
"static",
"IBlockState",
"applyColour",
"(",
"IBlockState",
"state",
",",
"Colour",
"colour",
")",
"{",
"for",
"(",
"IProperty",
"prop",
":",
"state",
".",
"getProperties",
"(",
")",
".",
"keySet",
"(",
")",
")",
"{",
"if",
"(",
"prop",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"\"color\"",
")",
"&&",
"prop",
".",
"getValueClass",
"(",
")",
"==",
"net",
".",
"minecraft",
".",
"item",
".",
"EnumDyeColor",
".",
"class",
")",
"{",
"net",
".",
"minecraft",
".",
"item",
".",
"EnumDyeColor",
"current",
"=",
"(",
"net",
".",
"minecraft",
".",
"item",
".",
"EnumDyeColor",
")",
"state",
".",
"getValue",
"(",
"prop",
")",
";",
"if",
"(",
"!",
"current",
".",
"getName",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"colour",
".",
"name",
"(",
")",
")",
")",
"{",
"return",
"state",
".",
"withProperty",
"(",
"prop",
",",
"EnumDyeColor",
".",
"valueOf",
"(",
"colour",
".",
"name",
"(",
")",
")",
")",
";",
"}",
"}",
"}",
"return",
"state",
";",
"}"
] | Recolour the Minecraft block
@param state The block to be recoloured
@param colour The new colour
@return A new blockstate which is a recoloured version of the original | [
"Recolour",
"the",
"Minecraft",
"block"
] | train | https://github.com/Microsoft/malmo/blob/4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a/Minecraft/src/main/java/com/microsoft/Malmo/Utils/MinecraftTypeHelper.java#L560-L574 |
UrielCh/ovh-java-sdk | ovh-java-sdk-core/src/main/java/net/minidev/ovh/api/ApiOvhAuth.java | ApiOvhAuth.time_GET | public Long time_GET() throws IOException {
"""
Get the current time of the OVH servers, since UNIX epoch
REST: GET /auth/time
"""
String qPath = "/auth/time";
StringBuilder sb = path(qPath);
String resp = execN(qPath, "GET", sb.toString(), null);
return convertTo(resp, Long.class);
} | java | public Long time_GET() throws IOException {
String qPath = "/auth/time";
StringBuilder sb = path(qPath);
String resp = execN(qPath, "GET", sb.toString(), null);
return convertTo(resp, Long.class);
} | [
"public",
"Long",
"time_GET",
"(",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/auth/time\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
")",
";",
"String",
"resp",
"=",
"execN",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"Long",
".",
"class",
")",
";",
"}"
] | Get the current time of the OVH servers, since UNIX epoch
REST: GET /auth/time | [
"Get",
"the",
"current",
"time",
"of",
"the",
"OVH",
"servers",
"since",
"UNIX",
"epoch"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-core/src/main/java/net/minidev/ovh/api/ApiOvhAuth.java#L48-L53 |
UrielCh/ovh-java-sdk | ovh-java-sdk-hostingprivateDatabase/src/main/java/net/minidev/ovh/api/ApiOvhHostingprivateDatabase.java | ApiOvhHostingprivateDatabase.serviceName_database_databaseName_extension_extensionName_GET | public OvhDatabaseExtension serviceName_database_databaseName_extension_extensionName_GET(String serviceName, String databaseName, String extensionName) throws IOException {
"""
Get this object properties
REST: GET /hosting/privateDatabase/{serviceName}/database/{databaseName}/extension/{extensionName}
@param serviceName [required] The internal name of your private database
@param databaseName [required] Database name
@param extensionName [required] Extension name
"""
String qPath = "/hosting/privateDatabase/{serviceName}/database/{databaseName}/extension/{extensionName}";
StringBuilder sb = path(qPath, serviceName, databaseName, extensionName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhDatabaseExtension.class);
} | java | public OvhDatabaseExtension serviceName_database_databaseName_extension_extensionName_GET(String serviceName, String databaseName, String extensionName) throws IOException {
String qPath = "/hosting/privateDatabase/{serviceName}/database/{databaseName}/extension/{extensionName}";
StringBuilder sb = path(qPath, serviceName, databaseName, extensionName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhDatabaseExtension.class);
} | [
"public",
"OvhDatabaseExtension",
"serviceName_database_databaseName_extension_extensionName_GET",
"(",
"String",
"serviceName",
",",
"String",
"databaseName",
",",
"String",
"extensionName",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/hosting/privateDatabase/{serviceName}/database/{databaseName}/extension/{extensionName}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"databaseName",
",",
"extensionName",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhDatabaseExtension",
".",
"class",
")",
";",
"}"
] | Get this object properties
REST: GET /hosting/privateDatabase/{serviceName}/database/{databaseName}/extension/{extensionName}
@param serviceName [required] The internal name of your private database
@param databaseName [required] Database name
@param extensionName [required] Extension name | [
"Get",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-hostingprivateDatabase/src/main/java/net/minidev/ovh/api/ApiOvhHostingprivateDatabase.java#L430-L435 |
google/error-prone-javac | src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java | Types.isAssignable | public boolean isAssignable(Type t, Type s, Warner warn) {
"""
Is t assignable to s?<br>
Equivalent to subtype except for constant values and raw
types.<br>
(not defined for Method and ForAll types)
"""
if (t.hasTag(ERROR))
return true;
if (t.getTag().isSubRangeOf(INT) && t.constValue() != null) {
int value = ((Number)t.constValue()).intValue();
switch (s.getTag()) {
case BYTE:
case CHAR:
case SHORT:
case INT:
if (s.getTag().checkRange(value))
return true;
break;
case CLASS:
switch (unboxedType(s).getTag()) {
case BYTE:
case CHAR:
case SHORT:
return isAssignable(t, unboxedType(s), warn);
}
break;
}
}
return isConvertible(t, s, warn);
} | java | public boolean isAssignable(Type t, Type s, Warner warn) {
if (t.hasTag(ERROR))
return true;
if (t.getTag().isSubRangeOf(INT) && t.constValue() != null) {
int value = ((Number)t.constValue()).intValue();
switch (s.getTag()) {
case BYTE:
case CHAR:
case SHORT:
case INT:
if (s.getTag().checkRange(value))
return true;
break;
case CLASS:
switch (unboxedType(s).getTag()) {
case BYTE:
case CHAR:
case SHORT:
return isAssignable(t, unboxedType(s), warn);
}
break;
}
}
return isConvertible(t, s, warn);
} | [
"public",
"boolean",
"isAssignable",
"(",
"Type",
"t",
",",
"Type",
"s",
",",
"Warner",
"warn",
")",
"{",
"if",
"(",
"t",
".",
"hasTag",
"(",
"ERROR",
")",
")",
"return",
"true",
";",
"if",
"(",
"t",
".",
"getTag",
"(",
")",
".",
"isSubRangeOf",
"(",
"INT",
")",
"&&",
"t",
".",
"constValue",
"(",
")",
"!=",
"null",
")",
"{",
"int",
"value",
"=",
"(",
"(",
"Number",
")",
"t",
".",
"constValue",
"(",
")",
")",
".",
"intValue",
"(",
")",
";",
"switch",
"(",
"s",
".",
"getTag",
"(",
")",
")",
"{",
"case",
"BYTE",
":",
"case",
"CHAR",
":",
"case",
"SHORT",
":",
"case",
"INT",
":",
"if",
"(",
"s",
".",
"getTag",
"(",
")",
".",
"checkRange",
"(",
"value",
")",
")",
"return",
"true",
";",
"break",
";",
"case",
"CLASS",
":",
"switch",
"(",
"unboxedType",
"(",
"s",
")",
".",
"getTag",
"(",
")",
")",
"{",
"case",
"BYTE",
":",
"case",
"CHAR",
":",
"case",
"SHORT",
":",
"return",
"isAssignable",
"(",
"t",
",",
"unboxedType",
"(",
"s",
")",
",",
"warn",
")",
";",
"}",
"break",
";",
"}",
"}",
"return",
"isConvertible",
"(",
"t",
",",
"s",
",",
"warn",
")",
";",
"}"
] | Is t assignable to s?<br>
Equivalent to subtype except for constant values and raw
types.<br>
(not defined for Method and ForAll types) | [
"Is",
"t",
"assignable",
"to",
"s?<br",
">",
"Equivalent",
"to",
"subtype",
"except",
"for",
"constant",
"values",
"and",
"raw",
"types",
".",
"<br",
">",
"(",
"not",
"defined",
"for",
"Method",
"and",
"ForAll",
"types",
")"
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java#L2047-L2071 |
wildfly/wildfly-maven-plugin | core/src/main/java/org/wildfly/plugin/core/DeploymentOperations.java | DeploymentOperations.addDeploymentOperationStep | static void addDeploymentOperationStep(final CompositeOperationBuilder builder, final Deployment deployment) {
"""
Creates an add operation on the deployment resource to the composite operation.
<p>
If the {@link Deployment#isEnabled()} is {@code false} a step to
{@linkplain #addDeployOperationStep(CompositeOperationBuilder, DeploymentDescription) deploy} the content may be
required.
</p>
@param builder the builder to add the step to
@param deployment the deployment to deploy
"""
final String name = deployment.getName();
final ModelNode address = createAddress(DEPLOYMENT, name);
final String runtimeName = deployment.getRuntimeName();
final ModelNode addOperation = createAddOperation(address);
if (runtimeName != null) {
addOperation.get(RUNTIME_NAME).set(runtimeName);
}
addOperation.get(ENABLED).set(deployment.isEnabled());
addContent(builder, addOperation, deployment);
builder.addStep(addOperation);
final Set<String> serverGroups = deployment.getServerGroups();
// If the server groups are empty this is a standalone deployment
if (!serverGroups.isEmpty()) {
for (String serverGroup : serverGroups) {
final ModelNode sgAddress = createAddress(SERVER_GROUP, serverGroup, DEPLOYMENT, name);
final ModelNode op = createAddOperation(sgAddress);
op.get(ENABLED).set(deployment.isEnabled());
if (runtimeName != null) {
op.get(RUNTIME_NAME).set(runtimeName);
}
builder.addStep(op);
}
}
} | java | static void addDeploymentOperationStep(final CompositeOperationBuilder builder, final Deployment deployment) {
final String name = deployment.getName();
final ModelNode address = createAddress(DEPLOYMENT, name);
final String runtimeName = deployment.getRuntimeName();
final ModelNode addOperation = createAddOperation(address);
if (runtimeName != null) {
addOperation.get(RUNTIME_NAME).set(runtimeName);
}
addOperation.get(ENABLED).set(deployment.isEnabled());
addContent(builder, addOperation, deployment);
builder.addStep(addOperation);
final Set<String> serverGroups = deployment.getServerGroups();
// If the server groups are empty this is a standalone deployment
if (!serverGroups.isEmpty()) {
for (String serverGroup : serverGroups) {
final ModelNode sgAddress = createAddress(SERVER_GROUP, serverGroup, DEPLOYMENT, name);
final ModelNode op = createAddOperation(sgAddress);
op.get(ENABLED).set(deployment.isEnabled());
if (runtimeName != null) {
op.get(RUNTIME_NAME).set(runtimeName);
}
builder.addStep(op);
}
}
} | [
"static",
"void",
"addDeploymentOperationStep",
"(",
"final",
"CompositeOperationBuilder",
"builder",
",",
"final",
"Deployment",
"deployment",
")",
"{",
"final",
"String",
"name",
"=",
"deployment",
".",
"getName",
"(",
")",
";",
"final",
"ModelNode",
"address",
"=",
"createAddress",
"(",
"DEPLOYMENT",
",",
"name",
")",
";",
"final",
"String",
"runtimeName",
"=",
"deployment",
".",
"getRuntimeName",
"(",
")",
";",
"final",
"ModelNode",
"addOperation",
"=",
"createAddOperation",
"(",
"address",
")",
";",
"if",
"(",
"runtimeName",
"!=",
"null",
")",
"{",
"addOperation",
".",
"get",
"(",
"RUNTIME_NAME",
")",
".",
"set",
"(",
"runtimeName",
")",
";",
"}",
"addOperation",
".",
"get",
"(",
"ENABLED",
")",
".",
"set",
"(",
"deployment",
".",
"isEnabled",
"(",
")",
")",
";",
"addContent",
"(",
"builder",
",",
"addOperation",
",",
"deployment",
")",
";",
"builder",
".",
"addStep",
"(",
"addOperation",
")",
";",
"final",
"Set",
"<",
"String",
">",
"serverGroups",
"=",
"deployment",
".",
"getServerGroups",
"(",
")",
";",
"// If the server groups are empty this is a standalone deployment",
"if",
"(",
"!",
"serverGroups",
".",
"isEmpty",
"(",
")",
")",
"{",
"for",
"(",
"String",
"serverGroup",
":",
"serverGroups",
")",
"{",
"final",
"ModelNode",
"sgAddress",
"=",
"createAddress",
"(",
"SERVER_GROUP",
",",
"serverGroup",
",",
"DEPLOYMENT",
",",
"name",
")",
";",
"final",
"ModelNode",
"op",
"=",
"createAddOperation",
"(",
"sgAddress",
")",
";",
"op",
".",
"get",
"(",
"ENABLED",
")",
".",
"set",
"(",
"deployment",
".",
"isEnabled",
"(",
")",
")",
";",
"if",
"(",
"runtimeName",
"!=",
"null",
")",
"{",
"op",
".",
"get",
"(",
"RUNTIME_NAME",
")",
".",
"set",
"(",
"runtimeName",
")",
";",
"}",
"builder",
".",
"addStep",
"(",
"op",
")",
";",
"}",
"}",
"}"
] | Creates an add operation on the deployment resource to the composite operation.
<p>
If the {@link Deployment#isEnabled()} is {@code false} a step to
{@linkplain #addDeployOperationStep(CompositeOperationBuilder, DeploymentDescription) deploy} the content may be
required.
</p>
@param builder the builder to add the step to
@param deployment the deployment to deploy | [
"Creates",
"an",
"add",
"operation",
"on",
"the",
"deployment",
"resource",
"to",
"the",
"composite",
"operation",
".",
"<p",
">",
"If",
"the",
"{",
"@link",
"Deployment#isEnabled",
"()",
"}",
"is",
"{",
"@code",
"false",
"}",
"a",
"step",
"to",
"{",
"@linkplain",
"#addDeployOperationStep",
"(",
"CompositeOperationBuilder",
"DeploymentDescription",
")",
"deploy",
"}",
"the",
"content",
"may",
"be",
"required",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/wildfly/wildfly-maven-plugin/blob/c0e2d7ee28e511092561801959eae253b2b56def/core/src/main/java/org/wildfly/plugin/core/DeploymentOperations.java#L302-L328 |
OpenLiberty/open-liberty | dev/com.ibm.ws.config/src/com/ibm/ws/config/admin/internal/ConfigurationAdminImpl.java | ConfigurationAdminImpl.getConfiguration | @Override
public ExtendedConfiguration getConfiguration(String pid, String location) throws IOException {
"""
/*
(non-Javadoc)
@see
org.osgi.service.cm.ConfigurationAdmin#getConfiguration(java.lang.String,
java.lang.String)
If Configuration already exists(exists in table, or serialized), return the
existing configuration.
If existing configuration's location is null, set it with specified
location before returning it.
If Configuration doesn't already exist, create a new Configuration objects
with null properties
and bound to the specified location including null location.
SecurityException is thrown if caller doesn't have proper
ConfigurationPermission.
@param pid
@param location
"""
this.caFactory.checkConfigurationPermission();
return caFactory.getConfigurationStore().getConfiguration(pid, location);
} | java | @Override
public ExtendedConfiguration getConfiguration(String pid, String location) throws IOException {
this.caFactory.checkConfigurationPermission();
return caFactory.getConfigurationStore().getConfiguration(pid, location);
} | [
"@",
"Override",
"public",
"ExtendedConfiguration",
"getConfiguration",
"(",
"String",
"pid",
",",
"String",
"location",
")",
"throws",
"IOException",
"{",
"this",
".",
"caFactory",
".",
"checkConfigurationPermission",
"(",
")",
";",
"return",
"caFactory",
".",
"getConfigurationStore",
"(",
")",
".",
"getConfiguration",
"(",
"pid",
",",
"location",
")",
";",
"}"
] | /*
(non-Javadoc)
@see
org.osgi.service.cm.ConfigurationAdmin#getConfiguration(java.lang.String,
java.lang.String)
If Configuration already exists(exists in table, or serialized), return the
existing configuration.
If existing configuration's location is null, set it with specified
location before returning it.
If Configuration doesn't already exist, create a new Configuration objects
with null properties
and bound to the specified location including null location.
SecurityException is thrown if caller doesn't have proper
ConfigurationPermission.
@param pid
@param location | [
"/",
"*",
"(",
"non",
"-",
"Javadoc",
")"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.config/src/com/ibm/ws/config/admin/internal/ConfigurationAdminImpl.java#L147-L151 |
kenyee/android-ddp-client | src/com/keysolutions/ddpclient/android/DDPStateSingleton.java | DDPStateSingleton.sendOAuthHTTPRequest | private void sendOAuthHTTPRequest(String serviceName, String accessToken, String credentialToken, Response.Listener listener) {
"""
/*
Login with OAuth requires the priming of "pending credentials" on the server to receive a secret
"""
RequestQueue queue = Volley.newRequestQueue(mContext);
String url = "http://" + getServerHostname() + ":" + getServerPort() + "/_oauth/" + serviceName + "/";
//as far as I know, Facebook is the only one that only returns a long-lived token on mobile login
String params;
if (accessTokenServices.contains(serviceName)) {
params = "?accessToken=" + accessToken + "&state=" + generateState(credentialToken);
} else {
params = "?code=" + accessToken + "&state=" + generateState(credentialToken);
}
StringRequest request = new StringRequest(Request.Method.GET, url + params,
listener, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
error.printStackTrace();
if (BuildConfig.DEBUG) {
log.debug("If you're getting a weird error, " +
"this could be because you haven't configured " +
"your server for ddp loginWithOAuth yet. " +
"For Facebook login, remove accounts-facebook " +
"and add jasperlu:accounts-facebook-ddp instead.");
}
}
});
queue.add(request);
} | java | private void sendOAuthHTTPRequest(String serviceName, String accessToken, String credentialToken, Response.Listener listener) {
RequestQueue queue = Volley.newRequestQueue(mContext);
String url = "http://" + getServerHostname() + ":" + getServerPort() + "/_oauth/" + serviceName + "/";
//as far as I know, Facebook is the only one that only returns a long-lived token on mobile login
String params;
if (accessTokenServices.contains(serviceName)) {
params = "?accessToken=" + accessToken + "&state=" + generateState(credentialToken);
} else {
params = "?code=" + accessToken + "&state=" + generateState(credentialToken);
}
StringRequest request = new StringRequest(Request.Method.GET, url + params,
listener, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
error.printStackTrace();
if (BuildConfig.DEBUG) {
log.debug("If you're getting a weird error, " +
"this could be because you haven't configured " +
"your server for ddp loginWithOAuth yet. " +
"For Facebook login, remove accounts-facebook " +
"and add jasperlu:accounts-facebook-ddp instead.");
}
}
});
queue.add(request);
} | [
"private",
"void",
"sendOAuthHTTPRequest",
"(",
"String",
"serviceName",
",",
"String",
"accessToken",
",",
"String",
"credentialToken",
",",
"Response",
".",
"Listener",
"listener",
")",
"{",
"RequestQueue",
"queue",
"=",
"Volley",
".",
"newRequestQueue",
"(",
"mContext",
")",
";",
"String",
"url",
"=",
"\"http://\"",
"+",
"getServerHostname",
"(",
")",
"+",
"\":\"",
"+",
"getServerPort",
"(",
")",
"+",
"\"/_oauth/\"",
"+",
"serviceName",
"+",
"\"/\"",
";",
"//as far as I know, Facebook is the only one that only returns a long-lived token on mobile login",
"String",
"params",
";",
"if",
"(",
"accessTokenServices",
".",
"contains",
"(",
"serviceName",
")",
")",
"{",
"params",
"=",
"\"?accessToken=\"",
"+",
"accessToken",
"+",
"\"&state=\"",
"+",
"generateState",
"(",
"credentialToken",
")",
";",
"}",
"else",
"{",
"params",
"=",
"\"?code=\"",
"+",
"accessToken",
"+",
"\"&state=\"",
"+",
"generateState",
"(",
"credentialToken",
")",
";",
"}",
"StringRequest",
"request",
"=",
"new",
"StringRequest",
"(",
"Request",
".",
"Method",
".",
"GET",
",",
"url",
"+",
"params",
",",
"listener",
",",
"new",
"Response",
".",
"ErrorListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onErrorResponse",
"(",
"VolleyError",
"error",
")",
"{",
"error",
".",
"printStackTrace",
"(",
")",
";",
"if",
"(",
"BuildConfig",
".",
"DEBUG",
")",
"{",
"log",
".",
"debug",
"(",
"\"If you're getting a weird error, \"",
"+",
"\"this could be because you haven't configured \"",
"+",
"\"your server for ddp loginWithOAuth yet. \"",
"+",
"\"For Facebook login, remove accounts-facebook \"",
"+",
"\"and add jasperlu:accounts-facebook-ddp instead.\"",
")",
";",
"}",
"}",
"}",
")",
";",
"queue",
".",
"add",
"(",
"request",
")",
";",
"}"
] | /*
Login with OAuth requires the priming of "pending credentials" on the server to receive a secret | [
"/",
"*",
"Login",
"with",
"OAuth",
"requires",
"the",
"priming",
"of",
"pending",
"credentials",
"on",
"the",
"server",
"to",
"receive",
"a",
"secret"
] | train | https://github.com/kenyee/android-ddp-client/blob/6ab416e415570a03f96c383497144dd742de3f08/src/com/keysolutions/ddpclient/android/DDPStateSingleton.java#L472-L499 |
mfornos/humanize | humanize-icu/src/main/java/humanize/ICUHumanize.java | ICUHumanize.parseNumber | public static Number parseNumber(final String text, final Locale locale) throws ParseException {
"""
<p>
Same as {@link #parseNumber(String) parseNumber} for the specified
locale.
</p>
@param text
String containing a spelled out number.
@param locale
Target locale
@return Text converted to Number
@throws ParseException
"""
return withinLocale(new Callable<Number>()
{
public Number call() throws Exception
{
return parseNumber(text);
}
}, locale);
} | java | public static Number parseNumber(final String text, final Locale locale) throws ParseException
{
return withinLocale(new Callable<Number>()
{
public Number call() throws Exception
{
return parseNumber(text);
}
}, locale);
} | [
"public",
"static",
"Number",
"parseNumber",
"(",
"final",
"String",
"text",
",",
"final",
"Locale",
"locale",
")",
"throws",
"ParseException",
"{",
"return",
"withinLocale",
"(",
"new",
"Callable",
"<",
"Number",
">",
"(",
")",
"{",
"public",
"Number",
"call",
"(",
")",
"throws",
"Exception",
"{",
"return",
"parseNumber",
"(",
"text",
")",
";",
"}",
"}",
",",
"locale",
")",
";",
"}"
] | <p>
Same as {@link #parseNumber(String) parseNumber} for the specified
locale.
</p>
@param text
String containing a spelled out number.
@param locale
Target locale
@return Text converted to Number
@throws ParseException | [
"<p",
">",
"Same",
"as",
"{",
"@link",
"#parseNumber",
"(",
"String",
")",
"parseNumber",
"}",
"for",
"the",
"specified",
"locale",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/mfornos/humanize/blob/59fc103045de9d217c9e77dbcb7621f992f46c63/humanize-icu/src/main/java/humanize/ICUHumanize.java#L1476-L1485 |
aws/aws-sdk-java | aws-java-sdk-sqs/src/main/java/com/amazonaws/services/sqs/buffered/ReceiveQueueBuffer.java | ReceiveQueueBuffer.issueFuture | private ReceiveMessageFuture issueFuture(int size,
QueueBufferCallback<ReceiveMessageRequest, ReceiveMessageResult> callback) {
"""
Creates and returns a new future object. Sleeps if the list of already-issued but as yet
unsatisfied futures is over a throttle limit.
@return never null
"""
synchronized (futures) {
ReceiveMessageFuture theFuture = new ReceiveMessageFuture(callback, size);
futures.addLast(theFuture);
return theFuture;
}
} | java | private ReceiveMessageFuture issueFuture(int size,
QueueBufferCallback<ReceiveMessageRequest, ReceiveMessageResult> callback) {
synchronized (futures) {
ReceiveMessageFuture theFuture = new ReceiveMessageFuture(callback, size);
futures.addLast(theFuture);
return theFuture;
}
} | [
"private",
"ReceiveMessageFuture",
"issueFuture",
"(",
"int",
"size",
",",
"QueueBufferCallback",
"<",
"ReceiveMessageRequest",
",",
"ReceiveMessageResult",
">",
"callback",
")",
"{",
"synchronized",
"(",
"futures",
")",
"{",
"ReceiveMessageFuture",
"theFuture",
"=",
"new",
"ReceiveMessageFuture",
"(",
"callback",
",",
"size",
")",
";",
"futures",
".",
"addLast",
"(",
"theFuture",
")",
";",
"return",
"theFuture",
";",
"}",
"}"
] | Creates and returns a new future object. Sleeps if the list of already-issued but as yet
unsatisfied futures is over a throttle limit.
@return never null | [
"Creates",
"and",
"returns",
"a",
"new",
"future",
"object",
".",
"Sleeps",
"if",
"the",
"list",
"of",
"already",
"-",
"issued",
"but",
"as",
"yet",
"unsatisfied",
"futures",
"is",
"over",
"a",
"throttle",
"limit",
"."
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-sqs/src/main/java/com/amazonaws/services/sqs/buffered/ReceiveQueueBuffer.java#L161-L168 |
facebookarchive/hadoop-20 | src/core/org/apache/hadoop/io/file/tfile/Utils.java | Utils.writeVLong | @SuppressWarnings("fallthrough")
public static void writeVLong(DataOutput out, long n) throws IOException {
"""
Encoding a Long integer into a variable-length encoding format.
<ul>
<li>if n in [-32, 127): encode in one byte with the actual value.
Otherwise,
<li>if n in [-20*2^8, 20*2^8): encode in two bytes: byte[0] = n/256 - 52;
byte[1]=n&0xff. Otherwise,
<li>if n IN [-16*2^16, 16*2^16): encode in three bytes: byte[0]=n/2^16 -
88; byte[1]=(n>>8)&0xff; byte[2]=n&0xff. Otherwise,
<li>if n in [-8*2^24, 8*2^24): encode in four bytes: byte[0]=n/2^24 - 112;
byte[1] = (n>>16)&0xff; byte[2] = (n>>8)&0xff; byte[3]=n&0xff. Otherwise:
<li>if n in [-2^31, 2^31): encode in five bytes: byte[0]=-125; byte[1] =
(n>>24)&0xff; byte[2]=(n>>16)&0xff; byte[3]=(n>>8)&0xff; byte[4]=n&0xff;
<li>if n in [-2^39, 2^39): encode in six bytes: byte[0]=-124; byte[1] =
(n>>32)&0xff; byte[2]=(n>>24)&0xff; byte[3]=(n>>16)&0xff;
byte[4]=(n>>8)&0xff; byte[5]=n&0xff
<li>if n in [-2^47, 2^47): encode in seven bytes: byte[0]=-123; byte[1] =
(n>>40)&0xff; byte[2]=(n>>32)&0xff; byte[3]=(n>>24)&0xff;
byte[4]=(n>>16)&0xff; byte[5]=(n>>8)&0xff; byte[6]=n&0xff;
<li>if n in [-2^55, 2^55): encode in eight bytes: byte[0]=-122; byte[1] =
(n>>48)&0xff; byte[2] = (n>>40)&0xff; byte[3]=(n>>32)&0xff;
byte[4]=(n>>24)&0xff; byte[5]=(n>>16)&0xff; byte[6]=(n>>8)&0xff;
byte[7]=n&0xff;
<li>if n in [-2^63, 2^63): encode in nine bytes: byte[0]=-121; byte[1] =
(n>>54)&0xff; byte[2] = (n>>48)&0xff; byte[3] = (n>>40)&0xff;
byte[4]=(n>>32)&0xff; byte[5]=(n>>24)&0xff; byte[6]=(n>>16)&0xff;
byte[7]=(n>>8)&0xff; byte[8]=n&0xff;
</ul>
@param out
output stream
@param n
the integer number
@throws IOException
"""
if ((n < 128) && (n >= -32)) {
out.writeByte((int) n);
return;
}
long un = (n < 0) ? ~n : n;
// how many bytes do we need to represent the number with sign bit?
int len = (Long.SIZE - Long.numberOfLeadingZeros(un)) / 8 + 1;
int firstByte = (int) (n >> ((len - 1) * 8));
switch (len) {
case 1:
// fall it through to firstByte==-1, len=2.
firstByte >>= 8;
case 2:
if ((firstByte < 20) && (firstByte >= -20)) {
out.writeByte(firstByte - 52);
out.writeByte((int) n);
return;
}
// fall it through to firstByte==0/-1, len=3.
firstByte >>= 8;
case 3:
if ((firstByte < 16) && (firstByte >= -16)) {
out.writeByte(firstByte - 88);
out.writeShort((int) n);
return;
}
// fall it through to firstByte==0/-1, len=4.
firstByte >>= 8;
case 4:
if ((firstByte < 8) && (firstByte >= -8)) {
out.writeByte(firstByte - 112);
out.writeShort(((int) n) >>> 8);
out.writeByte((int) n);
return;
}
out.writeByte(len - 129);
out.writeInt((int) n);
return;
case 5:
out.writeByte(len - 129);
out.writeInt((int) (n >>> 8));
out.writeByte((int) n);
return;
case 6:
out.writeByte(len - 129);
out.writeInt((int) (n >>> 16));
out.writeShort((int) n);
return;
case 7:
out.writeByte(len - 129);
out.writeInt((int) (n >>> 24));
out.writeShort((int) (n >>> 8));
out.writeByte((int) n);
return;
case 8:
out.writeByte(len - 129);
out.writeLong(n);
return;
default:
throw new RuntimeException("Internel error");
}
} | java | @SuppressWarnings("fallthrough")
public static void writeVLong(DataOutput out, long n) throws IOException {
if ((n < 128) && (n >= -32)) {
out.writeByte((int) n);
return;
}
long un = (n < 0) ? ~n : n;
// how many bytes do we need to represent the number with sign bit?
int len = (Long.SIZE - Long.numberOfLeadingZeros(un)) / 8 + 1;
int firstByte = (int) (n >> ((len - 1) * 8));
switch (len) {
case 1:
// fall it through to firstByte==-1, len=2.
firstByte >>= 8;
case 2:
if ((firstByte < 20) && (firstByte >= -20)) {
out.writeByte(firstByte - 52);
out.writeByte((int) n);
return;
}
// fall it through to firstByte==0/-1, len=3.
firstByte >>= 8;
case 3:
if ((firstByte < 16) && (firstByte >= -16)) {
out.writeByte(firstByte - 88);
out.writeShort((int) n);
return;
}
// fall it through to firstByte==0/-1, len=4.
firstByte >>= 8;
case 4:
if ((firstByte < 8) && (firstByte >= -8)) {
out.writeByte(firstByte - 112);
out.writeShort(((int) n) >>> 8);
out.writeByte((int) n);
return;
}
out.writeByte(len - 129);
out.writeInt((int) n);
return;
case 5:
out.writeByte(len - 129);
out.writeInt((int) (n >>> 8));
out.writeByte((int) n);
return;
case 6:
out.writeByte(len - 129);
out.writeInt((int) (n >>> 16));
out.writeShort((int) n);
return;
case 7:
out.writeByte(len - 129);
out.writeInt((int) (n >>> 24));
out.writeShort((int) (n >>> 8));
out.writeByte((int) n);
return;
case 8:
out.writeByte(len - 129);
out.writeLong(n);
return;
default:
throw new RuntimeException("Internel error");
}
} | [
"@",
"SuppressWarnings",
"(",
"\"fallthrough\"",
")",
"public",
"static",
"void",
"writeVLong",
"(",
"DataOutput",
"out",
",",
"long",
"n",
")",
"throws",
"IOException",
"{",
"if",
"(",
"(",
"n",
"<",
"128",
")",
"&&",
"(",
"n",
">=",
"-",
"32",
")",
")",
"{",
"out",
".",
"writeByte",
"(",
"(",
"int",
")",
"n",
")",
";",
"return",
";",
"}",
"long",
"un",
"=",
"(",
"n",
"<",
"0",
")",
"?",
"~",
"n",
":",
"n",
";",
"// how many bytes do we need to represent the number with sign bit?",
"int",
"len",
"=",
"(",
"Long",
".",
"SIZE",
"-",
"Long",
".",
"numberOfLeadingZeros",
"(",
"un",
")",
")",
"/",
"8",
"+",
"1",
";",
"int",
"firstByte",
"=",
"(",
"int",
")",
"(",
"n",
">>",
"(",
"(",
"len",
"-",
"1",
")",
"*",
"8",
")",
")",
";",
"switch",
"(",
"len",
")",
"{",
"case",
"1",
":",
"// fall it through to firstByte==-1, len=2.",
"firstByte",
">>=",
"8",
";",
"case",
"2",
":",
"if",
"(",
"(",
"firstByte",
"<",
"20",
")",
"&&",
"(",
"firstByte",
">=",
"-",
"20",
")",
")",
"{",
"out",
".",
"writeByte",
"(",
"firstByte",
"-",
"52",
")",
";",
"out",
".",
"writeByte",
"(",
"(",
"int",
")",
"n",
")",
";",
"return",
";",
"}",
"// fall it through to firstByte==0/-1, len=3.",
"firstByte",
">>=",
"8",
";",
"case",
"3",
":",
"if",
"(",
"(",
"firstByte",
"<",
"16",
")",
"&&",
"(",
"firstByte",
">=",
"-",
"16",
")",
")",
"{",
"out",
".",
"writeByte",
"(",
"firstByte",
"-",
"88",
")",
";",
"out",
".",
"writeShort",
"(",
"(",
"int",
")",
"n",
")",
";",
"return",
";",
"}",
"// fall it through to firstByte==0/-1, len=4.",
"firstByte",
">>=",
"8",
";",
"case",
"4",
":",
"if",
"(",
"(",
"firstByte",
"<",
"8",
")",
"&&",
"(",
"firstByte",
">=",
"-",
"8",
")",
")",
"{",
"out",
".",
"writeByte",
"(",
"firstByte",
"-",
"112",
")",
";",
"out",
".",
"writeShort",
"(",
"(",
"(",
"int",
")",
"n",
")",
">>>",
"8",
")",
";",
"out",
".",
"writeByte",
"(",
"(",
"int",
")",
"n",
")",
";",
"return",
";",
"}",
"out",
".",
"writeByte",
"(",
"len",
"-",
"129",
")",
";",
"out",
".",
"writeInt",
"(",
"(",
"int",
")",
"n",
")",
";",
"return",
";",
"case",
"5",
":",
"out",
".",
"writeByte",
"(",
"len",
"-",
"129",
")",
";",
"out",
".",
"writeInt",
"(",
"(",
"int",
")",
"(",
"n",
">>>",
"8",
")",
")",
";",
"out",
".",
"writeByte",
"(",
"(",
"int",
")",
"n",
")",
";",
"return",
";",
"case",
"6",
":",
"out",
".",
"writeByte",
"(",
"len",
"-",
"129",
")",
";",
"out",
".",
"writeInt",
"(",
"(",
"int",
")",
"(",
"n",
">>>",
"16",
")",
")",
";",
"out",
".",
"writeShort",
"(",
"(",
"int",
")",
"n",
")",
";",
"return",
";",
"case",
"7",
":",
"out",
".",
"writeByte",
"(",
"len",
"-",
"129",
")",
";",
"out",
".",
"writeInt",
"(",
"(",
"int",
")",
"(",
"n",
">>>",
"24",
")",
")",
";",
"out",
".",
"writeShort",
"(",
"(",
"int",
")",
"(",
"n",
">>>",
"8",
")",
")",
";",
"out",
".",
"writeByte",
"(",
"(",
"int",
")",
"n",
")",
";",
"return",
";",
"case",
"8",
":",
"out",
".",
"writeByte",
"(",
"len",
"-",
"129",
")",
";",
"out",
".",
"writeLong",
"(",
"n",
")",
";",
"return",
";",
"default",
":",
"throw",
"new",
"RuntimeException",
"(",
"\"Internel error\"",
")",
";",
"}",
"}"
] | Encoding a Long integer into a variable-length encoding format.
<ul>
<li>if n in [-32, 127): encode in one byte with the actual value.
Otherwise,
<li>if n in [-20*2^8, 20*2^8): encode in two bytes: byte[0] = n/256 - 52;
byte[1]=n&0xff. Otherwise,
<li>if n IN [-16*2^16, 16*2^16): encode in three bytes: byte[0]=n/2^16 -
88; byte[1]=(n>>8)&0xff; byte[2]=n&0xff. Otherwise,
<li>if n in [-8*2^24, 8*2^24): encode in four bytes: byte[0]=n/2^24 - 112;
byte[1] = (n>>16)&0xff; byte[2] = (n>>8)&0xff; byte[3]=n&0xff. Otherwise:
<li>if n in [-2^31, 2^31): encode in five bytes: byte[0]=-125; byte[1] =
(n>>24)&0xff; byte[2]=(n>>16)&0xff; byte[3]=(n>>8)&0xff; byte[4]=n&0xff;
<li>if n in [-2^39, 2^39): encode in six bytes: byte[0]=-124; byte[1] =
(n>>32)&0xff; byte[2]=(n>>24)&0xff; byte[3]=(n>>16)&0xff;
byte[4]=(n>>8)&0xff; byte[5]=n&0xff
<li>if n in [-2^47, 2^47): encode in seven bytes: byte[0]=-123; byte[1] =
(n>>40)&0xff; byte[2]=(n>>32)&0xff; byte[3]=(n>>24)&0xff;
byte[4]=(n>>16)&0xff; byte[5]=(n>>8)&0xff; byte[6]=n&0xff;
<li>if n in [-2^55, 2^55): encode in eight bytes: byte[0]=-122; byte[1] =
(n>>48)&0xff; byte[2] = (n>>40)&0xff; byte[3]=(n>>32)&0xff;
byte[4]=(n>>24)&0xff; byte[5]=(n>>16)&0xff; byte[6]=(n>>8)&0xff;
byte[7]=n&0xff;
<li>if n in [-2^63, 2^63): encode in nine bytes: byte[0]=-121; byte[1] =
(n>>54)&0xff; byte[2] = (n>>48)&0xff; byte[3] = (n>>40)&0xff;
byte[4]=(n>>32)&0xff; byte[5]=(n>>24)&0xff; byte[6]=(n>>16)&0xff;
byte[7]=(n>>8)&0xff; byte[8]=n&0xff;
</ul>
@param out
output stream
@param n
the integer number
@throws IOException | [
"Encoding",
"a",
"Long",
"integer",
"into",
"a",
"variable",
"-",
"length",
"encoding",
"format",
".",
"<ul",
">",
"<li",
">",
"if",
"n",
"in",
"[",
"-",
"32",
"127",
")",
":",
"encode",
"in",
"one",
"byte",
"with",
"the",
"actual",
"value",
".",
"Otherwise",
"<li",
">",
"if",
"n",
"in",
"[",
"-",
"20",
"*",
"2^8",
"20",
"*",
"2^8",
")",
":",
"encode",
"in",
"two",
"bytes",
":",
"byte",
"[",
"0",
"]",
"=",
"n",
"/",
"256",
"-",
"52",
";",
"byte",
"[",
"1",
"]",
"=",
"n&0xff",
".",
"Otherwise",
"<li",
">",
"if",
"n",
"IN",
"[",
"-",
"16",
"*",
"2^16",
"16",
"*",
"2^16",
")",
":",
"encode",
"in",
"three",
"bytes",
":",
"byte",
"[",
"0",
"]",
"=",
"n",
"/",
"2^16",
"-",
"88",
";",
"byte",
"[",
"1",
"]",
"=",
"(",
"n",
">>",
"8",
")",
"&0xff",
";",
"byte",
"[",
"2",
"]",
"=",
"n&0xff",
".",
"Otherwise",
"<li",
">",
"if",
"n",
"in",
"[",
"-",
"8",
"*",
"2^24",
"8",
"*",
"2^24",
")",
":",
"encode",
"in",
"four",
"bytes",
":",
"byte",
"[",
"0",
"]",
"=",
"n",
"/",
"2^24",
"-",
"112",
";",
"byte",
"[",
"1",
"]",
"=",
"(",
"n",
">>",
"16",
")",
"&0xff",
";",
"byte",
"[",
"2",
"]",
"=",
"(",
"n",
">>",
"8",
")",
"&0xff",
";",
"byte",
"[",
"3",
"]",
"=",
"n&0xff",
".",
"Otherwise",
":",
"<li",
">",
"if",
"n",
"in",
"[",
"-",
"2^31",
"2^31",
")",
":",
"encode",
"in",
"five",
"bytes",
":",
"byte",
"[",
"0",
"]",
"=",
"-",
"125",
";",
"byte",
"[",
"1",
"]",
"=",
"(",
"n",
">>",
"24",
")",
"&0xff",
";",
"byte",
"[",
"2",
"]",
"=",
"(",
"n",
">>",
"16",
")",
"&0xff",
";",
"byte",
"[",
"3",
"]",
"=",
"(",
"n",
">>",
"8",
")",
"&0xff",
";",
"byte",
"[",
"4",
"]",
"=",
"n&0xff",
";",
"<li",
">",
"if",
"n",
"in",
"[",
"-",
"2^39",
"2^39",
")",
":",
"encode",
"in",
"six",
"bytes",
":",
"byte",
"[",
"0",
"]",
"=",
"-",
"124",
";",
"byte",
"[",
"1",
"]",
"=",
"(",
"n",
">>",
"32",
")",
"&0xff",
";",
"byte",
"[",
"2",
"]",
"=",
"(",
"n",
">>",
"24",
")",
"&0xff",
";",
"byte",
"[",
"3",
"]",
"=",
"(",
"n",
">>",
"16",
")",
"&0xff",
";",
"byte",
"[",
"4",
"]",
"=",
"(",
"n",
">>",
"8",
")",
"&0xff",
";",
"byte",
"[",
"5",
"]",
"=",
"n&0xff",
"<li",
">",
"if",
"n",
"in",
"[",
"-",
"2^47",
"2^47",
")",
":",
"encode",
"in",
"seven",
"bytes",
":",
"byte",
"[",
"0",
"]",
"=",
"-",
"123",
";",
"byte",
"[",
"1",
"]",
"=",
"(",
"n",
">>",
"40",
")",
"&0xff",
";",
"byte",
"[",
"2",
"]",
"=",
"(",
"n",
">>",
"32",
")",
"&0xff",
";",
"byte",
"[",
"3",
"]",
"=",
"(",
"n",
">>",
"24",
")",
"&0xff",
";",
"byte",
"[",
"4",
"]",
"=",
"(",
"n",
">>",
"16",
")",
"&0xff",
";",
"byte",
"[",
"5",
"]",
"=",
"(",
"n",
">>",
"8",
")",
"&0xff",
";",
"byte",
"[",
"6",
"]",
"=",
"n&0xff",
";",
"<li",
">",
"if",
"n",
"in",
"[",
"-",
"2^55",
"2^55",
")",
":",
"encode",
"in",
"eight",
"bytes",
":",
"byte",
"[",
"0",
"]",
"=",
"-",
"122",
";",
"byte",
"[",
"1",
"]",
"=",
"(",
"n",
">>",
"48",
")",
"&0xff",
";",
"byte",
"[",
"2",
"]",
"=",
"(",
"n",
">>",
"40",
")",
"&0xff",
";",
"byte",
"[",
"3",
"]",
"=",
"(",
"n",
">>",
"32",
")",
"&0xff",
";",
"byte",
"[",
"4",
"]",
"=",
"(",
"n",
">>",
"24",
")",
"&0xff",
";",
"byte",
"[",
"5",
"]",
"=",
"(",
"n",
">>",
"16",
")",
"&0xff",
";",
"byte",
"[",
"6",
"]",
"=",
"(",
"n",
">>",
"8",
")",
"&0xff",
";",
"byte",
"[",
"7",
"]",
"=",
"n&0xff",
";",
"<li",
">",
"if",
"n",
"in",
"[",
"-",
"2^63",
"2^63",
")",
":",
"encode",
"in",
"nine",
"bytes",
":",
"byte",
"[",
"0",
"]",
"=",
"-",
"121",
";",
"byte",
"[",
"1",
"]",
"=",
"(",
"n",
">>",
"54",
")",
"&0xff",
";",
"byte",
"[",
"2",
"]",
"=",
"(",
"n",
">>",
"48",
")",
"&0xff",
";",
"byte",
"[",
"3",
"]",
"=",
"(",
"n",
">>",
"40",
")",
"&0xff",
";",
"byte",
"[",
"4",
"]",
"=",
"(",
"n",
">>",
"32",
")",
"&0xff",
";",
"byte",
"[",
"5",
"]",
"=",
"(",
"n",
">>",
"24",
")",
"&0xff",
";",
"byte",
"[",
"6",
"]",
"=",
"(",
"n",
">>",
"16",
")",
"&0xff",
";",
"byte",
"[",
"7",
"]",
"=",
"(",
"n",
">>",
"8",
")",
"&0xff",
";",
"byte",
"[",
"8",
"]",
"=",
"n&0xff",
";",
"<",
"/",
"ul",
">"
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/core/org/apache/hadoop/io/file/tfile/Utils.java#L90-L154 |
ldapchai/ldapchai | src/main/java/com/novell/ldapchai/impl/edir/NmasCrFactory.java | NmasCrFactory.readAssignedChallengeSet | public static ChallengeSet readAssignedChallengeSet( final ChaiUser theUser )
throws ChaiUnavailableException, ChaiOperationException, ChaiValidationException {
"""
This method will first read the user's assigned password challenge set policy.
@param theUser ChaiUser to read policy for
@return A valid ChallengeSet if found, otherwise null.
@throws ChaiOperationException If there is an error during the operation
@throws ChaiUnavailableException If the directory server(s) are unavailable
@throws ChaiValidationException when there is a logical problem with the challenge set data, such as more randoms required then exist
"""
return readAssignedChallengeSet( theUser, Locale.getDefault() );
} | java | public static ChallengeSet readAssignedChallengeSet( final ChaiUser theUser )
throws ChaiUnavailableException, ChaiOperationException, ChaiValidationException
{
return readAssignedChallengeSet( theUser, Locale.getDefault() );
} | [
"public",
"static",
"ChallengeSet",
"readAssignedChallengeSet",
"(",
"final",
"ChaiUser",
"theUser",
")",
"throws",
"ChaiUnavailableException",
",",
"ChaiOperationException",
",",
"ChaiValidationException",
"{",
"return",
"readAssignedChallengeSet",
"(",
"theUser",
",",
"Locale",
".",
"getDefault",
"(",
")",
")",
";",
"}"
] | This method will first read the user's assigned password challenge set policy.
@param theUser ChaiUser to read policy for
@return A valid ChallengeSet if found, otherwise null.
@throws ChaiOperationException If there is an error during the operation
@throws ChaiUnavailableException If the directory server(s) are unavailable
@throws ChaiValidationException when there is a logical problem with the challenge set data, such as more randoms required then exist | [
"This",
"method",
"will",
"first",
"read",
"the",
"user",
"s",
"assigned",
"password",
"challenge",
"set",
"policy",
"."
] | train | https://github.com/ldapchai/ldapchai/blob/a6d4b5dbfa4e270db0ce70892512cbe39e64b874/src/main/java/com/novell/ldapchai/impl/edir/NmasCrFactory.java#L188-L192 |
Azure/azure-sdk-for-java | datamigration/resource-manager/v2017_11_15_preview/src/main/java/com/microsoft/azure/management/datamigration/v2017_11_15_preview/implementation/ServicesInner.java | ServicesInner.getByResourceGroupAsync | public Observable<DataMigrationServiceInner> getByResourceGroupAsync(String groupName, String serviceName) {
"""
Get DMS Service Instance.
The services resource is the top-level resource that represents the Data Migration Service. The GET method retrieves information about a service instance.
@param groupName Name of the resource group
@param serviceName Name of the service
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the DataMigrationServiceInner object
"""
return getByResourceGroupWithServiceResponseAsync(groupName, serviceName).map(new Func1<ServiceResponse<DataMigrationServiceInner>, DataMigrationServiceInner>() {
@Override
public DataMigrationServiceInner call(ServiceResponse<DataMigrationServiceInner> response) {
return response.body();
}
});
} | java | public Observable<DataMigrationServiceInner> getByResourceGroupAsync(String groupName, String serviceName) {
return getByResourceGroupWithServiceResponseAsync(groupName, serviceName).map(new Func1<ServiceResponse<DataMigrationServiceInner>, DataMigrationServiceInner>() {
@Override
public DataMigrationServiceInner call(ServiceResponse<DataMigrationServiceInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"DataMigrationServiceInner",
">",
"getByResourceGroupAsync",
"(",
"String",
"groupName",
",",
"String",
"serviceName",
")",
"{",
"return",
"getByResourceGroupWithServiceResponseAsync",
"(",
"groupName",
",",
"serviceName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"DataMigrationServiceInner",
">",
",",
"DataMigrationServiceInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"DataMigrationServiceInner",
"call",
"(",
"ServiceResponse",
"<",
"DataMigrationServiceInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Get DMS Service Instance.
The services resource is the top-level resource that represents the Data Migration Service. The GET method retrieves information about a service instance.
@param groupName Name of the resource group
@param serviceName Name of the service
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the DataMigrationServiceInner object | [
"Get",
"DMS",
"Service",
"Instance",
".",
"The",
"services",
"resource",
"is",
"the",
"top",
"-",
"level",
"resource",
"that",
"represents",
"the",
"Data",
"Migration",
"Service",
".",
"The",
"GET",
"method",
"retrieves",
"information",
"about",
"a",
"service",
"instance",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/datamigration/resource-manager/v2017_11_15_preview/src/main/java/com/microsoft/azure/management/datamigration/v2017_11_15_preview/implementation/ServicesInner.java#L371-L378 |
tvesalainen/util | vfs/src/main/java/org/vesalainen/vfs/VirtualFileChannel.java | VirtualFileChannel.tryLock | @Override
public FileLock tryLock(long position, long size, boolean shared) throws IOException {
"""
Returns always a lock. Locking virtual file makes no sense. Dummy
implementation is provided so that existing applications don't throw
exception.
@param position
@param size
@param shared
@return
@throws IOException
"""
return new FileLockImpl(this, position, size, shared);
} | java | @Override
public FileLock tryLock(long position, long size, boolean shared) throws IOException
{
return new FileLockImpl(this, position, size, shared);
} | [
"@",
"Override",
"public",
"FileLock",
"tryLock",
"(",
"long",
"position",
",",
"long",
"size",
",",
"boolean",
"shared",
")",
"throws",
"IOException",
"{",
"return",
"new",
"FileLockImpl",
"(",
"this",
",",
"position",
",",
"size",
",",
"shared",
")",
";",
"}"
] | Returns always a lock. Locking virtual file makes no sense. Dummy
implementation is provided so that existing applications don't throw
exception.
@param position
@param size
@param shared
@return
@throws IOException | [
"Returns",
"always",
"a",
"lock",
".",
"Locking",
"virtual",
"file",
"makes",
"no",
"sense",
".",
"Dummy",
"implementation",
"is",
"provided",
"so",
"that",
"existing",
"applications",
"don",
"t",
"throw",
"exception",
"."
] | train | https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/vfs/src/main/java/org/vesalainen/vfs/VirtualFileChannel.java#L399-L403 |
alkacon/opencms-core | src-gwt/org/opencms/ade/containerpage/client/ui/groupeditor/A_CmsGroupEditor.java | A_CmsGroupEditor.setSaveEnabled | protected void setSaveEnabled(boolean enabled, String disabledMessage) {
"""
Enables or disables the save button.<p>
@param enabled <code>true</code> to enable the save button
@param disabledMessage the message to display when the button is disabled
"""
if (m_saveButton != null) {
if (enabled) {
m_saveButton.enable();
} else {
m_saveButton.disable(disabledMessage);
}
}
} | java | protected void setSaveEnabled(boolean enabled, String disabledMessage) {
if (m_saveButton != null) {
if (enabled) {
m_saveButton.enable();
} else {
m_saveButton.disable(disabledMessage);
}
}
} | [
"protected",
"void",
"setSaveEnabled",
"(",
"boolean",
"enabled",
",",
"String",
"disabledMessage",
")",
"{",
"if",
"(",
"m_saveButton",
"!=",
"null",
")",
"{",
"if",
"(",
"enabled",
")",
"{",
"m_saveButton",
".",
"enable",
"(",
")",
";",
"}",
"else",
"{",
"m_saveButton",
".",
"disable",
"(",
"disabledMessage",
")",
";",
"}",
"}",
"}"
] | Enables or disables the save button.<p>
@param enabled <code>true</code> to enable the save button
@param disabledMessage the message to display when the button is disabled | [
"Enables",
"or",
"disables",
"the",
"save",
"button",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ade/containerpage/client/ui/groupeditor/A_CmsGroupEditor.java#L615-L624 |
xwiki/xwiki-commons | xwiki-commons-core/xwiki-commons-xml/src/main/java/org/htmlcleaner/XWikiDOMSerializer.java | XWikiDOMSerializer.createDOM | public Document createDOM(DocumentBuilder documentBuilder, TagNode rootNode) throws ParserConfigurationException {
"""
Create the DOM given a rootNode and a document builder.
This method is a replica of {@link DomSerializer#createDOM(TagNode)} excepts that it requires to give a
DocumentBuilder.
@param documentBuilder the {@link DocumentBuilder} instance to use, DocumentBuilder is not guaranteed to
be thread safe so at most the safe instance should be used only in the same thread
@param rootNode the HTML Cleaner root node to serialize
@return the W3C Document object
@throws ParserConfigurationException if there's an error during serialization
"""
Document document = createDocument(documentBuilder, rootNode);
createSubnodes(document, document.getDocumentElement(), rootNode.getAllChildren());
return document;
} | java | public Document createDOM(DocumentBuilder documentBuilder, TagNode rootNode) throws ParserConfigurationException
{
Document document = createDocument(documentBuilder, rootNode);
createSubnodes(document, document.getDocumentElement(), rootNode.getAllChildren());
return document;
} | [
"public",
"Document",
"createDOM",
"(",
"DocumentBuilder",
"documentBuilder",
",",
"TagNode",
"rootNode",
")",
"throws",
"ParserConfigurationException",
"{",
"Document",
"document",
"=",
"createDocument",
"(",
"documentBuilder",
",",
"rootNode",
")",
";",
"createSubnodes",
"(",
"document",
",",
"document",
".",
"getDocumentElement",
"(",
")",
",",
"rootNode",
".",
"getAllChildren",
"(",
")",
")",
";",
"return",
"document",
";",
"}"
] | Create the DOM given a rootNode and a document builder.
This method is a replica of {@link DomSerializer#createDOM(TagNode)} excepts that it requires to give a
DocumentBuilder.
@param documentBuilder the {@link DocumentBuilder} instance to use, DocumentBuilder is not guaranteed to
be thread safe so at most the safe instance should be used only in the same thread
@param rootNode the HTML Cleaner root node to serialize
@return the W3C Document object
@throws ParserConfigurationException if there's an error during serialization | [
"Create",
"the",
"DOM",
"given",
"a",
"rootNode",
"and",
"a",
"document",
"builder",
".",
"This",
"method",
"is",
"a",
"replica",
"of",
"{"
] | train | https://github.com/xwiki/xwiki-commons/blob/5374d8c6d966588c1eac7392c83da610dfb9f129/xwiki-commons-core/xwiki-commons-xml/src/main/java/org/htmlcleaner/XWikiDOMSerializer.java#L167-L174 |
apereo/cas | support/cas-server-support-ldap-core/src/main/java/org/apereo/cas/util/LdapUtils.java | LdapUtils.executeSearchOperation | public static Response<SearchResult> executeSearchOperation(final ConnectionFactory connectionFactory,
final String baseDn,
final SearchFilter filter,
final String... returnAttributes) throws LdapException {
"""
Execute search operation.
@param connectionFactory the connection factory
@param baseDn the base dn
@param filter the filter
@param returnAttributes the return attributes
@return the response
@throws LdapException the ldap exception
"""
return executeSearchOperation(connectionFactory, baseDn, filter, null, returnAttributes);
} | java | public static Response<SearchResult> executeSearchOperation(final ConnectionFactory connectionFactory,
final String baseDn,
final SearchFilter filter,
final String... returnAttributes) throws LdapException {
return executeSearchOperation(connectionFactory, baseDn, filter, null, returnAttributes);
} | [
"public",
"static",
"Response",
"<",
"SearchResult",
">",
"executeSearchOperation",
"(",
"final",
"ConnectionFactory",
"connectionFactory",
",",
"final",
"String",
"baseDn",
",",
"final",
"SearchFilter",
"filter",
",",
"final",
"String",
"...",
"returnAttributes",
")",
"throws",
"LdapException",
"{",
"return",
"executeSearchOperation",
"(",
"connectionFactory",
",",
"baseDn",
",",
"filter",
",",
"null",
",",
"returnAttributes",
")",
";",
"}"
] | Execute search operation.
@param connectionFactory the connection factory
@param baseDn the base dn
@param filter the filter
@param returnAttributes the return attributes
@return the response
@throws LdapException the ldap exception | [
"Execute",
"search",
"operation",
"."
] | train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/support/cas-server-support-ldap-core/src/main/java/org/apereo/cas/util/LdapUtils.java#L228-L233 |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/parsing/ParseUtils.java | ParseUtils.duplicateNamedElement | public static XMLStreamException duplicateNamedElement(final XMLExtendedStreamReader reader, final String name) {
"""
Get an exception reporting that an element of a given type and name has
already been declared in this scope.
@param reader the stream reader
@param name the name that was redeclared
@return the exception
"""
final XMLStreamException ex = ControllerLogger.ROOT_LOGGER.duplicateNamedElement(name, reader.getLocation());
return new XMLStreamValidationException(ex.getMessage(),
ValidationError.from(ex, ErrorType.DUPLICATE_ELEMENT)
.element(reader.getName())
.attribute(QName.valueOf("name"))
.attributeValue(name),
ex);
} | java | public static XMLStreamException duplicateNamedElement(final XMLExtendedStreamReader reader, final String name) {
final XMLStreamException ex = ControllerLogger.ROOT_LOGGER.duplicateNamedElement(name, reader.getLocation());
return new XMLStreamValidationException(ex.getMessage(),
ValidationError.from(ex, ErrorType.DUPLICATE_ELEMENT)
.element(reader.getName())
.attribute(QName.valueOf("name"))
.attributeValue(name),
ex);
} | [
"public",
"static",
"XMLStreamException",
"duplicateNamedElement",
"(",
"final",
"XMLExtendedStreamReader",
"reader",
",",
"final",
"String",
"name",
")",
"{",
"final",
"XMLStreamException",
"ex",
"=",
"ControllerLogger",
".",
"ROOT_LOGGER",
".",
"duplicateNamedElement",
"(",
"name",
",",
"reader",
".",
"getLocation",
"(",
")",
")",
";",
"return",
"new",
"XMLStreamValidationException",
"(",
"ex",
".",
"getMessage",
"(",
")",
",",
"ValidationError",
".",
"from",
"(",
"ex",
",",
"ErrorType",
".",
"DUPLICATE_ELEMENT",
")",
".",
"element",
"(",
"reader",
".",
"getName",
"(",
")",
")",
".",
"attribute",
"(",
"QName",
".",
"valueOf",
"(",
"\"name\"",
")",
")",
".",
"attributeValue",
"(",
"name",
")",
",",
"ex",
")",
";",
"}"
] | Get an exception reporting that an element of a given type and name has
already been declared in this scope.
@param reader the stream reader
@param name the name that was redeclared
@return the exception | [
"Get",
"an",
"exception",
"reporting",
"that",
"an",
"element",
"of",
"a",
"given",
"type",
"and",
"name",
"has",
"already",
"been",
"declared",
"in",
"this",
"scope",
"."
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/parsing/ParseUtils.java#L364-L373 |
liyiorg/weixin-popular | src/main/java/weixin/popular/api/PayMchAPI.java | PayMchAPI.sandboxnewPayGetsignkey | public static SandboxSignkey sandboxnewPayGetsignkey(String mch_id,String key) {
"""
获取仿真测试验签秘钥
@param mch_id mch_id
@param key key
@return sandbox_signkey
@since 2.8.13
"""
MchBaseResult mchBaseResult = new MchBaseResult();
mchBaseResult.setMch_id(mch_id);
mchBaseResult.setNonce_str(UUID.randomUUID().toString().replace("-", ""));
Map<String,String> map = MapUtil.objectToMap(mchBaseResult);
String sign = SignatureUtil.generateSign(map,mchBaseResult.getSign_type(),key);
mchBaseResult.setSign(sign);
String closeorderXML = XMLConverUtil.convertToXML(mchBaseResult);
HttpUriRequest httpUriRequest = RequestBuilder.post()
.setHeader(xmlHeader)
.setUri(MCH_URI + "/sandboxnew/pay/getsignkey")
.setEntity(new StringEntity(closeorderXML,Charset.forName("utf-8")))
.build();
return LocalHttpClient.executeXmlResult(httpUriRequest, SandboxSignkey.class, mchBaseResult.getSign_type(), key);
} | java | public static SandboxSignkey sandboxnewPayGetsignkey(String mch_id,String key){
MchBaseResult mchBaseResult = new MchBaseResult();
mchBaseResult.setMch_id(mch_id);
mchBaseResult.setNonce_str(UUID.randomUUID().toString().replace("-", ""));
Map<String,String> map = MapUtil.objectToMap(mchBaseResult);
String sign = SignatureUtil.generateSign(map,mchBaseResult.getSign_type(),key);
mchBaseResult.setSign(sign);
String closeorderXML = XMLConverUtil.convertToXML(mchBaseResult);
HttpUriRequest httpUriRequest = RequestBuilder.post()
.setHeader(xmlHeader)
.setUri(MCH_URI + "/sandboxnew/pay/getsignkey")
.setEntity(new StringEntity(closeorderXML,Charset.forName("utf-8")))
.build();
return LocalHttpClient.executeXmlResult(httpUriRequest, SandboxSignkey.class, mchBaseResult.getSign_type(), key);
} | [
"public",
"static",
"SandboxSignkey",
"sandboxnewPayGetsignkey",
"(",
"String",
"mch_id",
",",
"String",
"key",
")",
"{",
"MchBaseResult",
"mchBaseResult",
"=",
"new",
"MchBaseResult",
"(",
")",
";",
"mchBaseResult",
".",
"setMch_id",
"(",
"mch_id",
")",
";",
"mchBaseResult",
".",
"setNonce_str",
"(",
"UUID",
".",
"randomUUID",
"(",
")",
".",
"toString",
"(",
")",
".",
"replace",
"(",
"\"-\"",
",",
"\"\"",
")",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"map",
"=",
"MapUtil",
".",
"objectToMap",
"(",
"mchBaseResult",
")",
";",
"String",
"sign",
"=",
"SignatureUtil",
".",
"generateSign",
"(",
"map",
",",
"mchBaseResult",
".",
"getSign_type",
"(",
")",
",",
"key",
")",
";",
"mchBaseResult",
".",
"setSign",
"(",
"sign",
")",
";",
"String",
"closeorderXML",
"=",
"XMLConverUtil",
".",
"convertToXML",
"(",
"mchBaseResult",
")",
";",
"HttpUriRequest",
"httpUriRequest",
"=",
"RequestBuilder",
".",
"post",
"(",
")",
".",
"setHeader",
"(",
"xmlHeader",
")",
".",
"setUri",
"(",
"MCH_URI",
"+",
"\"/sandboxnew/pay/getsignkey\"",
")",
".",
"setEntity",
"(",
"new",
"StringEntity",
"(",
"closeorderXML",
",",
"Charset",
".",
"forName",
"(",
"\"utf-8\"",
")",
")",
")",
".",
"build",
"(",
")",
";",
"return",
"LocalHttpClient",
".",
"executeXmlResult",
"(",
"httpUriRequest",
",",
"SandboxSignkey",
".",
"class",
",",
"mchBaseResult",
".",
"getSign_type",
"(",
")",
",",
"key",
")",
";",
"}"
] | 获取仿真测试验签秘钥
@param mch_id mch_id
@param key key
@return sandbox_signkey
@since 2.8.13 | [
"获取仿真测试验签秘钥"
] | train | https://github.com/liyiorg/weixin-popular/blob/c64255292d41463bdb671938feaabf42a335d82c/src/main/java/weixin/popular/api/PayMchAPI.java#L71-L85 |
j256/ormlite-core | src/main/java/com/j256/ormlite/stmt/QueryBuilder.java | QueryBuilder.leftJoin | public QueryBuilder<T, ID> leftJoin(QueryBuilder<?, ?> joinedQueryBuilder) throws SQLException {
"""
Similar to {@link #join(QueryBuilder)} but it will use "LEFT JOIN" instead.
See: <a href="http://www.w3schools.com/sql/sql_join_left.asp" >LEFT JOIN SQL docs</a>
<p>
<b>NOTE:</b> RIGHT and FULL JOIN SQL commands are not supported because we are only returning objects from the
"left" table.
</p>
<p>
<b>NOTE:</b> This will do combine the WHERE statement of the two query builders with a SQL "AND". See
{@link #leftJoinOr(QueryBuilder)}.
</p>
"""
addJoinInfo(JoinType.LEFT, null, null, joinedQueryBuilder, JoinWhereOperation.AND);
return this;
} | java | public QueryBuilder<T, ID> leftJoin(QueryBuilder<?, ?> joinedQueryBuilder) throws SQLException {
addJoinInfo(JoinType.LEFT, null, null, joinedQueryBuilder, JoinWhereOperation.AND);
return this;
} | [
"public",
"QueryBuilder",
"<",
"T",
",",
"ID",
">",
"leftJoin",
"(",
"QueryBuilder",
"<",
"?",
",",
"?",
">",
"joinedQueryBuilder",
")",
"throws",
"SQLException",
"{",
"addJoinInfo",
"(",
"JoinType",
".",
"LEFT",
",",
"null",
",",
"null",
",",
"joinedQueryBuilder",
",",
"JoinWhereOperation",
".",
"AND",
")",
";",
"return",
"this",
";",
"}"
] | Similar to {@link #join(QueryBuilder)} but it will use "LEFT JOIN" instead.
See: <a href="http://www.w3schools.com/sql/sql_join_left.asp" >LEFT JOIN SQL docs</a>
<p>
<b>NOTE:</b> RIGHT and FULL JOIN SQL commands are not supported because we are only returning objects from the
"left" table.
</p>
<p>
<b>NOTE:</b> This will do combine the WHERE statement of the two query builders with a SQL "AND". See
{@link #leftJoinOr(QueryBuilder)}.
</p> | [
"Similar",
"to",
"{",
"@link",
"#join",
"(",
"QueryBuilder",
")",
"}",
"but",
"it",
"will",
"use",
"LEFT",
"JOIN",
"instead",
"."
] | train | https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/stmt/QueryBuilder.java#L327-L330 |
Impetus/Kundera | src/jpa-engine/core/src/main/java/com/impetus/kundera/persistence/EntityManagerFactoryImpl.java | EntityManagerFactoryImpl.createEntityManager | @Override
public final EntityManager createEntityManager(Map map) {
"""
Create a new application-managed EntityManager with the specified Map of
properties. This method returns a new EntityManager instance each time it
is invoked. The isOpen method will return true on the returned instance.
@param map
properties for entity manager
@return entity manager instance
@throws IllegalStateException
if the entity manager factory has been closed
"""
// For Application managed persistence context, type is always EXTENDED
if (isOpen())
{
return new EntityManagerImpl(this, map, transactionType, PersistenceContextType.EXTENDED);
}
throw new IllegalStateException("Entity manager factory has been closed.");
} | java | @Override
public final EntityManager createEntityManager(Map map)
{
// For Application managed persistence context, type is always EXTENDED
if (isOpen())
{
return new EntityManagerImpl(this, map, transactionType, PersistenceContextType.EXTENDED);
}
throw new IllegalStateException("Entity manager factory has been closed.");
} | [
"@",
"Override",
"public",
"final",
"EntityManager",
"createEntityManager",
"(",
"Map",
"map",
")",
"{",
"// For Application managed persistence context, type is always EXTENDED\r",
"if",
"(",
"isOpen",
"(",
")",
")",
"{",
"return",
"new",
"EntityManagerImpl",
"(",
"this",
",",
"map",
",",
"transactionType",
",",
"PersistenceContextType",
".",
"EXTENDED",
")",
";",
"}",
"throw",
"new",
"IllegalStateException",
"(",
"\"Entity manager factory has been closed.\"",
")",
";",
"}"
] | Create a new application-managed EntityManager with the specified Map of
properties. This method returns a new EntityManager instance each time it
is invoked. The isOpen method will return true on the returned instance.
@param map
properties for entity manager
@return entity manager instance
@throws IllegalStateException
if the entity manager factory has been closed | [
"Create",
"a",
"new",
"application",
"-",
"managed",
"EntityManager",
"with",
"the",
"specified",
"Map",
"of",
"properties",
".",
"This",
"method",
"returns",
"a",
"new",
"EntityManager",
"instance",
"each",
"time",
"it",
"is",
"invoked",
".",
"The",
"isOpen",
"method",
"will",
"return",
"true",
"on",
"the",
"returned",
"instance",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/jpa-engine/core/src/main/java/com/impetus/kundera/persistence/EntityManagerFactoryImpl.java#L266-L275 |
apache/flink | flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/util/SegmentsUtil.java | SegmentsUtil.setByte | public static void setByte(MemorySegment[] segments, int offset, byte value) {
"""
set byte from segments.
@param segments target segments.
@param offset value offset.
"""
if (inFirstSegment(segments, offset, 1)) {
segments[0].put(offset, value);
} else {
setByteMultiSegments(segments, offset, value);
}
} | java | public static void setByte(MemorySegment[] segments, int offset, byte value) {
if (inFirstSegment(segments, offset, 1)) {
segments[0].put(offset, value);
} else {
setByteMultiSegments(segments, offset, value);
}
} | [
"public",
"static",
"void",
"setByte",
"(",
"MemorySegment",
"[",
"]",
"segments",
",",
"int",
"offset",
",",
"byte",
"value",
")",
"{",
"if",
"(",
"inFirstSegment",
"(",
"segments",
",",
"offset",
",",
"1",
")",
")",
"{",
"segments",
"[",
"0",
"]",
".",
"put",
"(",
"offset",
",",
"value",
")",
";",
"}",
"else",
"{",
"setByteMultiSegments",
"(",
"segments",
",",
"offset",
",",
"value",
")",
";",
"}",
"}"
] | set byte from segments.
@param segments target segments.
@param offset value offset. | [
"set",
"byte",
"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#L597-L603 |
roboconf/roboconf-platform | core/roboconf-target-docker/src/main/java/net/roboconf/target/docker/internal/DockerMachineConfigurator.java | DockerMachineConfigurator.createImage | void createImage( String imageId ) throws TargetException {
"""
Creates an image.
@param imageId the image ID
@throws TargetException if something went wrong
"""
// If there is no Dockerfile, this method will do nothing
File targetDirectory = this.parameters.getTargetPropertiesDirectory();
String dockerFilePath = this.parameters.getTargetProperties().get( GENERATE_IMAGE_FROM );
if( ! Utils.isEmptyOrWhitespaces( dockerFilePath ) && targetDirectory != null ) {
this.logger.fine( "Trying to create image " + imageId + " from a Dockerfile." );
File dockerFile = new File( targetDirectory, dockerFilePath );
if( ! dockerFile.exists())
throw new TargetException( "No Dockerfile was found at " + dockerFile );
// Start the build.
// This will block the current thread until the creation is complete.
String builtImageId;
this.logger.fine( "Asking Docker to build the image from our Dockerfile." );
try {
builtImageId = this.dockerClient
.buildImageCmd( dockerFile )
.withTags( Sets.newHashSet( imageId ))
.withPull( true )
.exec( new RoboconfBuildImageResultCallback())
.awaitImageId();
} catch( Exception e ) {
Utils.logException( this.logger, e );
throw new TargetException( e );
}
// No need to store the real image ID... Docker has it.
// Besides, we search images by both IDs and tags.
// Anyway, we can log the information.
this.logger.fine( "Image '" + builtImageId + "' was succesfully generated by Roboconf." );
}
} | java | void createImage( String imageId ) throws TargetException {
// If there is no Dockerfile, this method will do nothing
File targetDirectory = this.parameters.getTargetPropertiesDirectory();
String dockerFilePath = this.parameters.getTargetProperties().get( GENERATE_IMAGE_FROM );
if( ! Utils.isEmptyOrWhitespaces( dockerFilePath ) && targetDirectory != null ) {
this.logger.fine( "Trying to create image " + imageId + " from a Dockerfile." );
File dockerFile = new File( targetDirectory, dockerFilePath );
if( ! dockerFile.exists())
throw new TargetException( "No Dockerfile was found at " + dockerFile );
// Start the build.
// This will block the current thread until the creation is complete.
String builtImageId;
this.logger.fine( "Asking Docker to build the image from our Dockerfile." );
try {
builtImageId = this.dockerClient
.buildImageCmd( dockerFile )
.withTags( Sets.newHashSet( imageId ))
.withPull( true )
.exec( new RoboconfBuildImageResultCallback())
.awaitImageId();
} catch( Exception e ) {
Utils.logException( this.logger, e );
throw new TargetException( e );
}
// No need to store the real image ID... Docker has it.
// Besides, we search images by both IDs and tags.
// Anyway, we can log the information.
this.logger.fine( "Image '" + builtImageId + "' was succesfully generated by Roboconf." );
}
} | [
"void",
"createImage",
"(",
"String",
"imageId",
")",
"throws",
"TargetException",
"{",
"// If there is no Dockerfile, this method will do nothing",
"File",
"targetDirectory",
"=",
"this",
".",
"parameters",
".",
"getTargetPropertiesDirectory",
"(",
")",
";",
"String",
"dockerFilePath",
"=",
"this",
".",
"parameters",
".",
"getTargetProperties",
"(",
")",
".",
"get",
"(",
"GENERATE_IMAGE_FROM",
")",
";",
"if",
"(",
"!",
"Utils",
".",
"isEmptyOrWhitespaces",
"(",
"dockerFilePath",
")",
"&&",
"targetDirectory",
"!=",
"null",
")",
"{",
"this",
".",
"logger",
".",
"fine",
"(",
"\"Trying to create image \"",
"+",
"imageId",
"+",
"\" from a Dockerfile.\"",
")",
";",
"File",
"dockerFile",
"=",
"new",
"File",
"(",
"targetDirectory",
",",
"dockerFilePath",
")",
";",
"if",
"(",
"!",
"dockerFile",
".",
"exists",
"(",
")",
")",
"throw",
"new",
"TargetException",
"(",
"\"No Dockerfile was found at \"",
"+",
"dockerFile",
")",
";",
"// Start the build.",
"// This will block the current thread until the creation is complete.",
"String",
"builtImageId",
";",
"this",
".",
"logger",
".",
"fine",
"(",
"\"Asking Docker to build the image from our Dockerfile.\"",
")",
";",
"try",
"{",
"builtImageId",
"=",
"this",
".",
"dockerClient",
".",
"buildImageCmd",
"(",
"dockerFile",
")",
".",
"withTags",
"(",
"Sets",
".",
"newHashSet",
"(",
"imageId",
")",
")",
".",
"withPull",
"(",
"true",
")",
".",
"exec",
"(",
"new",
"RoboconfBuildImageResultCallback",
"(",
")",
")",
".",
"awaitImageId",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"Utils",
".",
"logException",
"(",
"this",
".",
"logger",
",",
"e",
")",
";",
"throw",
"new",
"TargetException",
"(",
"e",
")",
";",
"}",
"// No need to store the real image ID... Docker has it.",
"// Besides, we search images by both IDs and tags.",
"// Anyway, we can log the information.",
"this",
".",
"logger",
".",
"fine",
"(",
"\"Image '\"",
"+",
"builtImageId",
"+",
"\"' was succesfully generated by Roboconf.\"",
")",
";",
"}",
"}"
] | Creates an image.
@param imageId the image ID
@throws TargetException if something went wrong | [
"Creates",
"an",
"image",
"."
] | train | https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-target-docker/src/main/java/net/roboconf/target/docker/internal/DockerMachineConfigurator.java#L260-L294 |
apache/groovy | src/main/java/org/codehaus/groovy/transform/trait/Traits.java | Traits.collectSelfTypes | public static LinkedHashSet<ClassNode> collectSelfTypes(
ClassNode receiver,
LinkedHashSet<ClassNode> selfTypes) {
"""
Collects all the self types that a type should extend or implement, given
the traits is implements. Collects from interfaces and superclasses too.
@param receiver a class node that may implement a trait
@param selfTypes a collection where the list of self types will be written
@return the selfTypes collection itself
@since 2.4.0
"""
return collectSelfTypes(receiver, selfTypes, true, true);
} | java | public static LinkedHashSet<ClassNode> collectSelfTypes(
ClassNode receiver,
LinkedHashSet<ClassNode> selfTypes) {
return collectSelfTypes(receiver, selfTypes, true, true);
} | [
"public",
"static",
"LinkedHashSet",
"<",
"ClassNode",
">",
"collectSelfTypes",
"(",
"ClassNode",
"receiver",
",",
"LinkedHashSet",
"<",
"ClassNode",
">",
"selfTypes",
")",
"{",
"return",
"collectSelfTypes",
"(",
"receiver",
",",
"selfTypes",
",",
"true",
",",
"true",
")",
";",
"}"
] | Collects all the self types that a type should extend or implement, given
the traits is implements. Collects from interfaces and superclasses too.
@param receiver a class node that may implement a trait
@param selfTypes a collection where the list of self types will be written
@return the selfTypes collection itself
@since 2.4.0 | [
"Collects",
"all",
"the",
"self",
"types",
"that",
"a",
"type",
"should",
"extend",
"or",
"implement",
"given",
"the",
"traits",
"is",
"implements",
".",
"Collects",
"from",
"interfaces",
"and",
"superclasses",
"too",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/transform/trait/Traits.java#L308-L312 |
OpenLiberty/open-liberty | dev/com.ibm.ws.jdbc/src/com/ibm/ws/rsadapter/AdapterUtil.java | AdapterUtil.createXAException | public static XAException createXAException(String key, Object args, int xaErrorCode) {
"""
Create an XAException with a translated error message and an XA error code.
The XAException constructors provided by the XAException API allow only for either an
error message or an XA error code to be specified. This method constructs an
XAException with both. The error message is created from the NLS key and arguments.
@param key the NLS key.
@param args Object or Object[] listing parameters for the message; can be null if none.
@param xaErrorCode the XA error code.
@return a newly constructed XAException with the specified XA error code and a
descriptive error message.
"""
XAException xaX = new XAException(
args == null ?
getNLSMessage(key) :
getNLSMessage(key, args));
xaX.errorCode = xaErrorCode;
return xaX;
} | java | public static XAException createXAException(String key, Object args, int xaErrorCode) {
XAException xaX = new XAException(
args == null ?
getNLSMessage(key) :
getNLSMessage(key, args));
xaX.errorCode = xaErrorCode;
return xaX;
} | [
"public",
"static",
"XAException",
"createXAException",
"(",
"String",
"key",
",",
"Object",
"args",
",",
"int",
"xaErrorCode",
")",
"{",
"XAException",
"xaX",
"=",
"new",
"XAException",
"(",
"args",
"==",
"null",
"?",
"getNLSMessage",
"(",
"key",
")",
":",
"getNLSMessage",
"(",
"key",
",",
"args",
")",
")",
";",
"xaX",
".",
"errorCode",
"=",
"xaErrorCode",
";",
"return",
"xaX",
";",
"}"
] | Create an XAException with a translated error message and an XA error code.
The XAException constructors provided by the XAException API allow only for either an
error message or an XA error code to be specified. This method constructs an
XAException with both. The error message is created from the NLS key and arguments.
@param key the NLS key.
@param args Object or Object[] listing parameters for the message; can be null if none.
@param xaErrorCode the XA error code.
@return a newly constructed XAException with the specified XA error code and a
descriptive error message. | [
"Create",
"an",
"XAException",
"with",
"a",
"translated",
"error",
"message",
"and",
"an",
"XA",
"error",
"code",
".",
"The",
"XAException",
"constructors",
"provided",
"by",
"the",
"XAException",
"API",
"allow",
"only",
"for",
"either",
"an",
"error",
"message",
"or",
"an",
"XA",
"error",
"code",
"to",
"be",
"specified",
".",
"This",
"method",
"constructs",
"an",
"XAException",
"with",
"both",
".",
"The",
"error",
"message",
"is",
"created",
"from",
"the",
"NLS",
"key",
"and",
"arguments",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jdbc/src/com/ibm/ws/rsadapter/AdapterUtil.java#L142-L151 |
kamcpp/avicenna | src/avicenna/src/main/java/org/labcrypto/avicenna/Avicenna.java | Avicenna.get | public static <T> T get(Class<T> clazz, Collection<String> qualifiers) {
"""
Retrieves a stored dependnecy using class object and qualifiers.
@param clazz Class type which its related dependency reference should be retrieved.
@param qualifiers List of qualifiers to distinguish between similar types.
"""
SortedSet<String> qs = new TreeSet<String>();
if (qualifiers != null) {
qs.addAll(qualifiers);
}
return dependencyContainer.get(DependencyIdentifier.getDependencyIdentifierForClass(clazz, qs));
} | java | public static <T> T get(Class<T> clazz, Collection<String> qualifiers) {
SortedSet<String> qs = new TreeSet<String>();
if (qualifiers != null) {
qs.addAll(qualifiers);
}
return dependencyContainer.get(DependencyIdentifier.getDependencyIdentifierForClass(clazz, qs));
} | [
"public",
"static",
"<",
"T",
">",
"T",
"get",
"(",
"Class",
"<",
"T",
">",
"clazz",
",",
"Collection",
"<",
"String",
">",
"qualifiers",
")",
"{",
"SortedSet",
"<",
"String",
">",
"qs",
"=",
"new",
"TreeSet",
"<",
"String",
">",
"(",
")",
";",
"if",
"(",
"qualifiers",
"!=",
"null",
")",
"{",
"qs",
".",
"addAll",
"(",
"qualifiers",
")",
";",
"}",
"return",
"dependencyContainer",
".",
"get",
"(",
"DependencyIdentifier",
".",
"getDependencyIdentifierForClass",
"(",
"clazz",
",",
"qs",
")",
")",
";",
"}"
] | Retrieves a stored dependnecy using class object and qualifiers.
@param clazz Class type which its related dependency reference should be retrieved.
@param qualifiers List of qualifiers to distinguish between similar types. | [
"Retrieves",
"a",
"stored",
"dependnecy",
"using",
"class",
"object",
"and",
"qualifiers",
"."
] | train | https://github.com/kamcpp/avicenna/blob/0fc4eff447761140cd3799287427d99c63ea6e6e/src/avicenna/src/main/java/org/labcrypto/avicenna/Avicenna.java#L181-L187 |
Impetus/Kundera | src/jpa-engine/core/src/main/java/com/impetus/kundera/persistence/IdGenerator.java | IdGenerator.onAutoGenerator | private Object onAutoGenerator(EntityMetadata m, Client<?> client, Object e) {
"""
Generate Id when given auto generation strategy.
@param m
@param client
@param e
@param kunderaMetadata
"""
Object autogenerator = getAutoGenClazz(client);
if (autogenerator instanceof AutoGenerator)
{
Object generatedId = ((AutoGenerator)autogenerator).generate(client, m.getIdAttribute().getJavaType().getSimpleName());
try
{
generatedId = PropertyAccessorHelper.fromSourceToTargetClass(m.getIdAttribute().getJavaType(),
generatedId.getClass(), generatedId);
PropertyAccessorHelper.setId(e, m, generatedId);
return generatedId;
}
catch (IllegalArgumentException iae)
{
log.error("Unknown data type for ids : " + m.getIdAttribute().getJavaType());
throw new KunderaException("Unknown data type for ids : " + m.getIdAttribute().getJavaType(), iae);
}
}
throw new IllegalArgumentException(GenerationType.class.getSimpleName() + "." + GenerationType.AUTO
+ " Strategy not supported by this client :" + client.getClass().getName());
} | java | private Object onAutoGenerator(EntityMetadata m, Client<?> client, Object e)
{
Object autogenerator = getAutoGenClazz(client);
if (autogenerator instanceof AutoGenerator)
{
Object generatedId = ((AutoGenerator)autogenerator).generate(client, m.getIdAttribute().getJavaType().getSimpleName());
try
{
generatedId = PropertyAccessorHelper.fromSourceToTargetClass(m.getIdAttribute().getJavaType(),
generatedId.getClass(), generatedId);
PropertyAccessorHelper.setId(e, m, generatedId);
return generatedId;
}
catch (IllegalArgumentException iae)
{
log.error("Unknown data type for ids : " + m.getIdAttribute().getJavaType());
throw new KunderaException("Unknown data type for ids : " + m.getIdAttribute().getJavaType(), iae);
}
}
throw new IllegalArgumentException(GenerationType.class.getSimpleName() + "." + GenerationType.AUTO
+ " Strategy not supported by this client :" + client.getClass().getName());
} | [
"private",
"Object",
"onAutoGenerator",
"(",
"EntityMetadata",
"m",
",",
"Client",
"<",
"?",
">",
"client",
",",
"Object",
"e",
")",
"{",
"Object",
"autogenerator",
"=",
"getAutoGenClazz",
"(",
"client",
")",
";",
"if",
"(",
"autogenerator",
"instanceof",
"AutoGenerator",
")",
"{",
"Object",
"generatedId",
"=",
"(",
"(",
"AutoGenerator",
")",
"autogenerator",
")",
".",
"generate",
"(",
"client",
",",
"m",
".",
"getIdAttribute",
"(",
")",
".",
"getJavaType",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
";",
"try",
"{",
"generatedId",
"=",
"PropertyAccessorHelper",
".",
"fromSourceToTargetClass",
"(",
"m",
".",
"getIdAttribute",
"(",
")",
".",
"getJavaType",
"(",
")",
",",
"generatedId",
".",
"getClass",
"(",
")",
",",
"generatedId",
")",
";",
"PropertyAccessorHelper",
".",
"setId",
"(",
"e",
",",
"m",
",",
"generatedId",
")",
";",
"return",
"generatedId",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"iae",
")",
"{",
"log",
".",
"error",
"(",
"\"Unknown data type for ids : \"",
"+",
"m",
".",
"getIdAttribute",
"(",
")",
".",
"getJavaType",
"(",
")",
")",
";",
"throw",
"new",
"KunderaException",
"(",
"\"Unknown data type for ids : \"",
"+",
"m",
".",
"getIdAttribute",
"(",
")",
".",
"getJavaType",
"(",
")",
",",
"iae",
")",
";",
"}",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
"GenerationType",
".",
"class",
".",
"getSimpleName",
"(",
")",
"+",
"\".\"",
"+",
"GenerationType",
".",
"AUTO",
"+",
"\" Strategy not supported by this client :\"",
"+",
"client",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}"
] | Generate Id when given auto generation strategy.
@param m
@param client
@param e
@param kunderaMetadata | [
"Generate",
"Id",
"when",
"given",
"auto",
"generation",
"strategy",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/jpa-engine/core/src/main/java/com/impetus/kundera/persistence/IdGenerator.java#L109-L132 |
spring-projects/spring-ldap | core/src/main/java/org/springframework/ldap/support/LdapUtils.java | LdapUtils.removeFirst | public static LdapName removeFirst(Name dn, Name pathToRemove) {
"""
Remove the supplied path from the beginning the specified
<code>Name</code> if the name instance starts with
<code>path</code>. Useful for stripping base path suffix from a
<code>Name</code>. The original Name will not be affected.
@param dn the dn to strip from.
@param pathToRemove the path to remove from the beginning the dn instance.
@return an LdapName instance that is a copy of the original name with the
specified path stripped from its beginning.
@since 2.0
"""
Assert.notNull(dn, "dn must not be null");
Assert.notNull(pathToRemove, "pathToRemove must not be null");
LdapName result = newLdapName(dn);
LdapName path = returnOrConstructLdapNameFromName(pathToRemove);
if(path.size() == 0 || !dn.startsWith(path)) {
return result;
}
for(int i = 0; i < path.size(); i++) {
try {
result.remove(0);
} catch (InvalidNameException e) {
throw convertLdapException(e);
}
}
return result;
} | java | public static LdapName removeFirst(Name dn, Name pathToRemove) {
Assert.notNull(dn, "dn must not be null");
Assert.notNull(pathToRemove, "pathToRemove must not be null");
LdapName result = newLdapName(dn);
LdapName path = returnOrConstructLdapNameFromName(pathToRemove);
if(path.size() == 0 || !dn.startsWith(path)) {
return result;
}
for(int i = 0; i < path.size(); i++) {
try {
result.remove(0);
} catch (InvalidNameException e) {
throw convertLdapException(e);
}
}
return result;
} | [
"public",
"static",
"LdapName",
"removeFirst",
"(",
"Name",
"dn",
",",
"Name",
"pathToRemove",
")",
"{",
"Assert",
".",
"notNull",
"(",
"dn",
",",
"\"dn must not be null\"",
")",
";",
"Assert",
".",
"notNull",
"(",
"pathToRemove",
",",
"\"pathToRemove must not be null\"",
")",
";",
"LdapName",
"result",
"=",
"newLdapName",
"(",
"dn",
")",
";",
"LdapName",
"path",
"=",
"returnOrConstructLdapNameFromName",
"(",
"pathToRemove",
")",
";",
"if",
"(",
"path",
".",
"size",
"(",
")",
"==",
"0",
"||",
"!",
"dn",
".",
"startsWith",
"(",
"path",
")",
")",
"{",
"return",
"result",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"path",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"try",
"{",
"result",
".",
"remove",
"(",
"0",
")",
";",
"}",
"catch",
"(",
"InvalidNameException",
"e",
")",
"{",
"throw",
"convertLdapException",
"(",
"e",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | Remove the supplied path from the beginning the specified
<code>Name</code> if the name instance starts with
<code>path</code>. Useful for stripping base path suffix from a
<code>Name</code>. The original Name will not be affected.
@param dn the dn to strip from.
@param pathToRemove the path to remove from the beginning the dn instance.
@return an LdapName instance that is a copy of the original name with the
specified path stripped from its beginning.
@since 2.0 | [
"Remove",
"the",
"supplied",
"path",
"from",
"the",
"beginning",
"the",
"specified",
"<code",
">",
"Name<",
"/",
"code",
">",
"if",
"the",
"name",
"instance",
"starts",
"with",
"<code",
">",
"path<",
"/",
"code",
">",
".",
"Useful",
"for",
"stripping",
"base",
"path",
"suffix",
"from",
"a",
"<code",
">",
"Name<",
"/",
"code",
">",
".",
"The",
"original",
"Name",
"will",
"not",
"be",
"affected",
"."
] | train | https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/support/LdapUtils.java#L441-L461 |
seedstack/i18n-addon | core/src/main/java/org/seedstack/i18n/internal/domain/model/key/Key.java | Key.addTranslation | public Translation addTranslation(String locale, String value) {
"""
Saves or updates the translation for the specified locale.
If the key was outdated, checks if the key is still outdated.
@param locale specified the translation locale
@param value translation value
@return the new translation
@throws java.lang.IllegalArgumentException if the locale is null or empty
or contains other characters than letters and "-".
"""
return addTranslation(locale, value, false);
} | java | public Translation addTranslation(String locale, String value) {
return addTranslation(locale, value, false);
} | [
"public",
"Translation",
"addTranslation",
"(",
"String",
"locale",
",",
"String",
"value",
")",
"{",
"return",
"addTranslation",
"(",
"locale",
",",
"value",
",",
"false",
")",
";",
"}"
] | Saves or updates the translation for the specified locale.
If the key was outdated, checks if the key is still outdated.
@param locale specified the translation locale
@param value translation value
@return the new translation
@throws java.lang.IllegalArgumentException if the locale is null or empty
or contains other characters than letters and "-". | [
"Saves",
"or",
"updates",
"the",
"translation",
"for",
"the",
"specified",
"locale",
".",
"If",
"the",
"key",
"was",
"outdated",
"checks",
"if",
"the",
"key",
"is",
"still",
"outdated",
"."
] | train | https://github.com/seedstack/i18n-addon/blob/1e65101d8554623f09bda2497b0151fd10a16615/core/src/main/java/org/seedstack/i18n/internal/domain/model/key/Key.java#L70-L72 |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/access/AuthorizationResult.java | AuthorizationResult.failIfDenied | public void failIfDenied(ModelNode operation, PathAddress targetAddress) throws OperationFailedException {
"""
Utility method to throw a standard failure if {@link #getDecision()} is
{@link org.jboss.as.controller.access.AuthorizationResult.Decision#DENY}.
@param operation the operation the triggered this authorization result. Cannot be {@code null}
@param targetAddress the target address of the request that triggered this authorization result. Cannot be {@code null}
@throws OperationFailedException if {@link #getDecision()} is
{@link org.jboss.as.controller.access.AuthorizationResult.Decision#DENY}
"""
if (decision == AuthorizationResult.Decision.DENY) {
throw ControllerLogger.ACCESS_LOGGER.unauthorized(operation.get(OP).asString(),
targetAddress, explanation);
}
} | java | public void failIfDenied(ModelNode operation, PathAddress targetAddress) throws OperationFailedException {
if (decision == AuthorizationResult.Decision.DENY) {
throw ControllerLogger.ACCESS_LOGGER.unauthorized(operation.get(OP).asString(),
targetAddress, explanation);
}
} | [
"public",
"void",
"failIfDenied",
"(",
"ModelNode",
"operation",
",",
"PathAddress",
"targetAddress",
")",
"throws",
"OperationFailedException",
"{",
"if",
"(",
"decision",
"==",
"AuthorizationResult",
".",
"Decision",
".",
"DENY",
")",
"{",
"throw",
"ControllerLogger",
".",
"ACCESS_LOGGER",
".",
"unauthorized",
"(",
"operation",
".",
"get",
"(",
"OP",
")",
".",
"asString",
"(",
")",
",",
"targetAddress",
",",
"explanation",
")",
";",
"}",
"}"
] | Utility method to throw a standard failure if {@link #getDecision()} is
{@link org.jboss.as.controller.access.AuthorizationResult.Decision#DENY}.
@param operation the operation the triggered this authorization result. Cannot be {@code null}
@param targetAddress the target address of the request that triggered this authorization result. Cannot be {@code null}
@throws OperationFailedException if {@link #getDecision()} is
{@link org.jboss.as.controller.access.AuthorizationResult.Decision#DENY} | [
"Utility",
"method",
"to",
"throw",
"a",
"standard",
"failure",
"if",
"{",
"@link",
"#getDecision",
"()",
"}",
"is",
"{",
"@link",
"org",
".",
"jboss",
".",
"as",
".",
"controller",
".",
"access",
".",
"AuthorizationResult",
".",
"Decision#DENY",
"}",
"."
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/access/AuthorizationResult.java#L119-L125 |
BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/mock/servlet/MockHttpServletRequest.java | MockHttpServletRequest.setCookie | public void setCookie(final String name, final String value) {
"""
Sets a cookie on this request instance.
@param name The cookie name.
@param value The value of the cookie to set.
"""
if (name != null) {
Cookie cookie = new Cookie(name, value);
cookies.put(name, cookie);
}
} | java | public void setCookie(final String name, final String value) {
if (name != null) {
Cookie cookie = new Cookie(name, value);
cookies.put(name, cookie);
}
} | [
"public",
"void",
"setCookie",
"(",
"final",
"String",
"name",
",",
"final",
"String",
"value",
")",
"{",
"if",
"(",
"name",
"!=",
"null",
")",
"{",
"Cookie",
"cookie",
"=",
"new",
"Cookie",
"(",
"name",
",",
"value",
")",
";",
"cookies",
".",
"put",
"(",
"name",
",",
"cookie",
")",
";",
"}",
"}"
] | Sets a cookie on this request instance.
@param name The cookie name.
@param value The value of the cookie to set. | [
"Sets",
"a",
"cookie",
"on",
"this",
"request",
"instance",
"."
] | train | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/mock/servlet/MockHttpServletRequest.java#L94-L99 |
amaembo/streamex | src/main/java/one/util/streamex/AbstractStreamEx.java | AbstractStreamEx.toListAndThen | public <R> R toListAndThen(Function<? super List<T>, R> finisher) {
"""
Creates a {@link List} containing the elements of this stream, then
performs finishing transformation and returns its result. There are no
guarantees on the type, serializability or thread-safety of the
{@code List} created.
<p>
This is a terminal operation.
@param <R> the type of the result
@param finisher a function to be applied to the intermediate list
@return result of applying the finisher transformation to the list of the
stream elements.
@since 0.2.3
@see #toList()
"""
if (context.fjp != null)
return context.terminate(() -> finisher.apply(toList()));
return finisher.apply(toList());
} | java | public <R> R toListAndThen(Function<? super List<T>, R> finisher) {
if (context.fjp != null)
return context.terminate(() -> finisher.apply(toList()));
return finisher.apply(toList());
} | [
"public",
"<",
"R",
">",
"R",
"toListAndThen",
"(",
"Function",
"<",
"?",
"super",
"List",
"<",
"T",
">",
",",
"R",
">",
"finisher",
")",
"{",
"if",
"(",
"context",
".",
"fjp",
"!=",
"null",
")",
"return",
"context",
".",
"terminate",
"(",
"(",
")",
"->",
"finisher",
".",
"apply",
"(",
"toList",
"(",
")",
")",
")",
";",
"return",
"finisher",
".",
"apply",
"(",
"toList",
"(",
")",
")",
";",
"}"
] | Creates a {@link List} containing the elements of this stream, then
performs finishing transformation and returns its result. There are no
guarantees on the type, serializability or thread-safety of the
{@code List} created.
<p>
This is a terminal operation.
@param <R> the type of the result
@param finisher a function to be applied to the intermediate list
@return result of applying the finisher transformation to the list of the
stream elements.
@since 0.2.3
@see #toList() | [
"Creates",
"a",
"{",
"@link",
"List",
"}",
"containing",
"the",
"elements",
"of",
"this",
"stream",
"then",
"performs",
"finishing",
"transformation",
"and",
"returns",
"its",
"result",
".",
"There",
"are",
"no",
"guarantees",
"on",
"the",
"type",
"serializability",
"or",
"thread",
"-",
"safety",
"of",
"the",
"{",
"@code",
"List",
"}",
"created",
"."
] | train | https://github.com/amaembo/streamex/blob/936bbd1b7dfbcf64a3b990682bfc848213441d14/src/main/java/one/util/streamex/AbstractStreamEx.java#L1231-L1235 |
joniles/mpxj | src/main/java/net/sf/mpxj/common/InputStreamHelper.java | InputStreamHelper.processZipStream | private static void processZipStream(File dir, InputStream inputStream) throws IOException {
"""
Expands a zip file input stream into a temporary directory.
@param dir temporary directory
@param inputStream zip file input stream
"""
ZipInputStream zip = new ZipInputStream(inputStream);
while (true)
{
ZipEntry entry = zip.getNextEntry();
if (entry == null)
{
break;
}
File file = new File(dir, entry.getName());
if (entry.isDirectory())
{
FileHelper.mkdirsQuietly(file);
continue;
}
File parent = file.getParentFile();
if (parent != null)
{
FileHelper.mkdirsQuietly(parent);
}
FileOutputStream fos = new FileOutputStream(file);
byte[] bytes = new byte[1024];
int length;
while ((length = zip.read(bytes)) >= 0)
{
fos.write(bytes, 0, length);
}
fos.close();
}
} | java | private static void processZipStream(File dir, InputStream inputStream) throws IOException
{
ZipInputStream zip = new ZipInputStream(inputStream);
while (true)
{
ZipEntry entry = zip.getNextEntry();
if (entry == null)
{
break;
}
File file = new File(dir, entry.getName());
if (entry.isDirectory())
{
FileHelper.mkdirsQuietly(file);
continue;
}
File parent = file.getParentFile();
if (parent != null)
{
FileHelper.mkdirsQuietly(parent);
}
FileOutputStream fos = new FileOutputStream(file);
byte[] bytes = new byte[1024];
int length;
while ((length = zip.read(bytes)) >= 0)
{
fos.write(bytes, 0, length);
}
fos.close();
}
} | [
"private",
"static",
"void",
"processZipStream",
"(",
"File",
"dir",
",",
"InputStream",
"inputStream",
")",
"throws",
"IOException",
"{",
"ZipInputStream",
"zip",
"=",
"new",
"ZipInputStream",
"(",
"inputStream",
")",
";",
"while",
"(",
"true",
")",
"{",
"ZipEntry",
"entry",
"=",
"zip",
".",
"getNextEntry",
"(",
")",
";",
"if",
"(",
"entry",
"==",
"null",
")",
"{",
"break",
";",
"}",
"File",
"file",
"=",
"new",
"File",
"(",
"dir",
",",
"entry",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"entry",
".",
"isDirectory",
"(",
")",
")",
"{",
"FileHelper",
".",
"mkdirsQuietly",
"(",
"file",
")",
";",
"continue",
";",
"}",
"File",
"parent",
"=",
"file",
".",
"getParentFile",
"(",
")",
";",
"if",
"(",
"parent",
"!=",
"null",
")",
"{",
"FileHelper",
".",
"mkdirsQuietly",
"(",
"parent",
")",
";",
"}",
"FileOutputStream",
"fos",
"=",
"new",
"FileOutputStream",
"(",
"file",
")",
";",
"byte",
"[",
"]",
"bytes",
"=",
"new",
"byte",
"[",
"1024",
"]",
";",
"int",
"length",
";",
"while",
"(",
"(",
"length",
"=",
"zip",
".",
"read",
"(",
"bytes",
")",
")",
">=",
"0",
")",
"{",
"fos",
".",
"write",
"(",
"bytes",
",",
"0",
",",
"length",
")",
";",
"}",
"fos",
".",
"close",
"(",
")",
";",
"}",
"}"
] | Expands a zip file input stream into a temporary directory.
@param dir temporary directory
@param inputStream zip file input stream | [
"Expands",
"a",
"zip",
"file",
"input",
"stream",
"into",
"a",
"temporary",
"directory",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/common/InputStreamHelper.java#L115-L148 |
algolia/algoliasearch-client-java | src/main/java/com/algolia/search/saas/APIClient.java | APIClient.generateSecuredApiKey | @Deprecated
public String generateSecuredApiKey(String privateApiKey, String tagFilters) throws NoSuchAlgorithmException, InvalidKeyException {
"""
Generate a secured and public API Key from a list of tagFilters and an
optional user token identifying the current user
@param privateApiKey your private API Key
@param tagFilters the list of tags applied to the query (used as security)
@deprecated Use `generateSecuredApiKey(String privateApiKey, Query query)` version
"""
if (!tagFilters.contains("="))
return generateSecuredApiKey(privateApiKey, new Query().setTagFilters(tagFilters), null);
else {
return Base64.encodeBase64String(String.format("%s%s", hmac(privateApiKey, tagFilters), tagFilters).getBytes(Charset.forName("UTF8")));
}
} | java | @Deprecated
public String generateSecuredApiKey(String privateApiKey, String tagFilters) throws NoSuchAlgorithmException, InvalidKeyException {
if (!tagFilters.contains("="))
return generateSecuredApiKey(privateApiKey, new Query().setTagFilters(tagFilters), null);
else {
return Base64.encodeBase64String(String.format("%s%s", hmac(privateApiKey, tagFilters), tagFilters).getBytes(Charset.forName("UTF8")));
}
} | [
"@",
"Deprecated",
"public",
"String",
"generateSecuredApiKey",
"(",
"String",
"privateApiKey",
",",
"String",
"tagFilters",
")",
"throws",
"NoSuchAlgorithmException",
",",
"InvalidKeyException",
"{",
"if",
"(",
"!",
"tagFilters",
".",
"contains",
"(",
"\"=\"",
")",
")",
"return",
"generateSecuredApiKey",
"(",
"privateApiKey",
",",
"new",
"Query",
"(",
")",
".",
"setTagFilters",
"(",
"tagFilters",
")",
",",
"null",
")",
";",
"else",
"{",
"return",
"Base64",
".",
"encodeBase64String",
"(",
"String",
".",
"format",
"(",
"\"%s%s\"",
",",
"hmac",
"(",
"privateApiKey",
",",
"tagFilters",
")",
",",
"tagFilters",
")",
".",
"getBytes",
"(",
"Charset",
".",
"forName",
"(",
"\"UTF8\"",
")",
")",
")",
";",
"}",
"}"
] | Generate a secured and public API Key from a list of tagFilters and an
optional user token identifying the current user
@param privateApiKey your private API Key
@param tagFilters the list of tags applied to the query (used as security)
@deprecated Use `generateSecuredApiKey(String privateApiKey, Query query)` version | [
"Generate",
"a",
"secured",
"and",
"public",
"API",
"Key",
"from",
"a",
"list",
"of",
"tagFilters",
"and",
"an",
"optional",
"user",
"token",
"identifying",
"the",
"current",
"user"
] | train | https://github.com/algolia/algoliasearch-client-java/blob/a05da2f66c099fe6f77295c7b6a8a12c24e95f9b/src/main/java/com/algolia/search/saas/APIClient.java#L977-L984 |
lucee/Lucee | core/src/main/java/lucee/runtime/schedule/StorageUtil.java | StorageUtil.toDate | public Date toDate(Element el, String attributeName, Date defaultValue) {
"""
reads a XML Element Attribute ans cast it to a Date
@param el XML Element to read Attribute from it
@param attributeName Name of the Attribute to read
@param defaultValue if attribute doesn't exist return default value
@return Attribute Value
"""
return new DateImpl(toDateTime(el, attributeName, defaultValue));
} | java | public Date toDate(Element el, String attributeName, Date defaultValue) {
return new DateImpl(toDateTime(el, attributeName, defaultValue));
} | [
"public",
"Date",
"toDate",
"(",
"Element",
"el",
",",
"String",
"attributeName",
",",
"Date",
"defaultValue",
")",
"{",
"return",
"new",
"DateImpl",
"(",
"toDateTime",
"(",
"el",
",",
"attributeName",
",",
"defaultValue",
")",
")",
";",
"}"
] | reads a XML Element Attribute ans cast it to a Date
@param el XML Element to read Attribute from it
@param attributeName Name of the Attribute to read
@param defaultValue if attribute doesn't exist return default value
@return Attribute Value | [
"reads",
"a",
"XML",
"Element",
"Attribute",
"ans",
"cast",
"it",
"to",
"a",
"Date"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/runtime/schedule/StorageUtil.java#L287-L289 |
fabric8io/fabric8-forge | addons/utils/src/main/java/io/fabric8/forge/addon/utils/CommandHelpers.java | CommandHelpers.setInitialComponentValue | public static <T> void setInitialComponentValue(UIInput<T> inputComponent, T value) {
"""
If the initial value is not blank lets set the value on the underlying component
"""
if (value != null) {
inputComponent.setValue(value);
}
} | java | public static <T> void setInitialComponentValue(UIInput<T> inputComponent, T value) {
if (value != null) {
inputComponent.setValue(value);
}
} | [
"public",
"static",
"<",
"T",
">",
"void",
"setInitialComponentValue",
"(",
"UIInput",
"<",
"T",
">",
"inputComponent",
",",
"T",
"value",
")",
"{",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"inputComponent",
".",
"setValue",
"(",
"value",
")",
";",
"}",
"}"
] | If the initial value is not blank lets set the value on the underlying component | [
"If",
"the",
"initial",
"value",
"is",
"not",
"blank",
"lets",
"set",
"the",
"value",
"on",
"the",
"underlying",
"component"
] | train | https://github.com/fabric8io/fabric8-forge/blob/a59871bae4d5c5d3ece10f1e8758e73663087f19/addons/utils/src/main/java/io/fabric8/forge/addon/utils/CommandHelpers.java#L74-L78 |
dlemmermann/CalendarFX | CalendarFXRecurrence/src/main/java/com/google/ical/iter/Generators.java | Generators.byYearDayGenerator | static Generator byYearDayGenerator(int[] yearDays, final DateValue dtStart) {
"""
constructs a day generator that generates dates in the current month that
fall on one of the given days of the year.
@param yearDays elements in [-366,366] != 0
"""
final int[] uYearDays = Util.uniquify(yearDays);
return new Generator() {
int year = dtStart.year();
int month = dtStart.month();
int[] dates;
int i = 0;
{
checkMonth();
}
void checkMonth() {
// now, calculate the first week of the month
int doyOfMonth1 = TimeUtils.dayOfYear(year, month, 1);
int nDays = TimeUtils.monthLength(year, month);
int nYearDays = TimeUtils.yearLength(year);
IntSet udates = new IntSet();
for (int j = 0; j < uYearDays.length; j++) {
int yearDay = uYearDays[j];
if (yearDay < 0) {
yearDay += nYearDays + 1;
}
int date = yearDay - doyOfMonth1;
if (date >= 1 && date <= nDays) {
udates.add(date);
}
}
dates = udates.toIntArray();
}
@Override
boolean generate(DTBuilder builder) {
if (year != builder.year || month != builder.month) {
year = builder.year;
month = builder.month;
checkMonth();
i = 0;
}
if (i >= dates.length) {
return false;
}
builder.day = dates[i++];
return true;
}
@Override
public String toString() {
return "byYearDayGenerator";
}
};
} | java | static Generator byYearDayGenerator(int[] yearDays, final DateValue dtStart) {
final int[] uYearDays = Util.uniquify(yearDays);
return new Generator() {
int year = dtStart.year();
int month = dtStart.month();
int[] dates;
int i = 0;
{
checkMonth();
}
void checkMonth() {
// now, calculate the first week of the month
int doyOfMonth1 = TimeUtils.dayOfYear(year, month, 1);
int nDays = TimeUtils.monthLength(year, month);
int nYearDays = TimeUtils.yearLength(year);
IntSet udates = new IntSet();
for (int j = 0; j < uYearDays.length; j++) {
int yearDay = uYearDays[j];
if (yearDay < 0) {
yearDay += nYearDays + 1;
}
int date = yearDay - doyOfMonth1;
if (date >= 1 && date <= nDays) {
udates.add(date);
}
}
dates = udates.toIntArray();
}
@Override
boolean generate(DTBuilder builder) {
if (year != builder.year || month != builder.month) {
year = builder.year;
month = builder.month;
checkMonth();
i = 0;
}
if (i >= dates.length) {
return false;
}
builder.day = dates[i++];
return true;
}
@Override
public String toString() {
return "byYearDayGenerator";
}
};
} | [
"static",
"Generator",
"byYearDayGenerator",
"(",
"int",
"[",
"]",
"yearDays",
",",
"final",
"DateValue",
"dtStart",
")",
"{",
"final",
"int",
"[",
"]",
"uYearDays",
"=",
"Util",
".",
"uniquify",
"(",
"yearDays",
")",
";",
"return",
"new",
"Generator",
"(",
")",
"{",
"int",
"year",
"=",
"dtStart",
".",
"year",
"(",
")",
";",
"int",
"month",
"=",
"dtStart",
".",
"month",
"(",
")",
";",
"int",
"[",
"]",
"dates",
";",
"int",
"i",
"=",
"0",
";",
"{",
"checkMonth",
"(",
")",
";",
"}",
"void",
"checkMonth",
"(",
")",
"{",
"// now, calculate the first week of the month",
"int",
"doyOfMonth1",
"=",
"TimeUtils",
".",
"dayOfYear",
"(",
"year",
",",
"month",
",",
"1",
")",
";",
"int",
"nDays",
"=",
"TimeUtils",
".",
"monthLength",
"(",
"year",
",",
"month",
")",
";",
"int",
"nYearDays",
"=",
"TimeUtils",
".",
"yearLength",
"(",
"year",
")",
";",
"IntSet",
"udates",
"=",
"new",
"IntSet",
"(",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"uYearDays",
".",
"length",
";",
"j",
"++",
")",
"{",
"int",
"yearDay",
"=",
"uYearDays",
"[",
"j",
"]",
";",
"if",
"(",
"yearDay",
"<",
"0",
")",
"{",
"yearDay",
"+=",
"nYearDays",
"+",
"1",
";",
"}",
"int",
"date",
"=",
"yearDay",
"-",
"doyOfMonth1",
";",
"if",
"(",
"date",
">=",
"1",
"&&",
"date",
"<=",
"nDays",
")",
"{",
"udates",
".",
"add",
"(",
"date",
")",
";",
"}",
"}",
"dates",
"=",
"udates",
".",
"toIntArray",
"(",
")",
";",
"}",
"@",
"Override",
"boolean",
"generate",
"(",
"DTBuilder",
"builder",
")",
"{",
"if",
"(",
"year",
"!=",
"builder",
".",
"year",
"||",
"month",
"!=",
"builder",
".",
"month",
")",
"{",
"year",
"=",
"builder",
".",
"year",
";",
"month",
"=",
"builder",
".",
"month",
";",
"checkMonth",
"(",
")",
";",
"i",
"=",
"0",
";",
"}",
"if",
"(",
"i",
">=",
"dates",
".",
"length",
")",
"{",
"return",
"false",
";",
"}",
"builder",
".",
"day",
"=",
"dates",
"[",
"i",
"++",
"]",
";",
"return",
"true",
";",
"}",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"\"byYearDayGenerator\"",
";",
"}",
"}",
";",
"}"
] | constructs a day generator that generates dates in the current month that
fall on one of the given days of the year.
@param yearDays elements in [-366,366] != 0 | [
"constructs",
"a",
"day",
"generator",
"that",
"generates",
"dates",
"in",
"the",
"current",
"month",
"that",
"fall",
"on",
"one",
"of",
"the",
"given",
"days",
"of",
"the",
"year",
"."
] | train | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXRecurrence/src/main/java/com/google/ical/iter/Generators.java#L993-L1047 |
Azure/azure-sdk-for-java | mysql/resource-manager/v2017_12_01/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01/implementation/ConfigurationsInner.java | ConfigurationsInner.beginCreateOrUpdate | public ConfigurationInner beginCreateOrUpdate(String resourceGroupName, String serverName, String configurationName, ConfigurationInner parameters) {
"""
Updates a configuration of a server.
@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 configurationName The name of the server configuration.
@param parameters The required parameters for updating a server configuration.
@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 ConfigurationInner object if successful.
"""
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, configurationName, parameters).toBlocking().single().body();
} | java | public ConfigurationInner beginCreateOrUpdate(String resourceGroupName, String serverName, String configurationName, ConfigurationInner parameters) {
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, configurationName, parameters).toBlocking().single().body();
} | [
"public",
"ConfigurationInner",
"beginCreateOrUpdate",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"String",
"configurationName",
",",
"ConfigurationInner",
"parameters",
")",
"{",
"return",
"beginCreateOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
",",
"configurationName",
",",
"parameters",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Updates a configuration of a server.
@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 configurationName The name of the server configuration.
@param parameters The required parameters for updating a server configuration.
@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 ConfigurationInner object if successful. | [
"Updates",
"a",
"configuration",
"of",
"a",
"server",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/mysql/resource-manager/v2017_12_01/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01/implementation/ConfigurationsInner.java#L172-L174 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/factory/BaseNDArrayFactory.java | BaseNDArrayFactory.arange | @Override
public INDArray arange(double begin, double end, double step) {
"""
Array of evenly spaced values.
@param begin the begin of the range
@param end the end of the range
@return the range vector
"""
return Nd4j.create(ArrayUtil.toDoubles(ArrayUtil.range((int) begin, (int) end, (int)step)));
} | java | @Override
public INDArray arange(double begin, double end, double step) {
return Nd4j.create(ArrayUtil.toDoubles(ArrayUtil.range((int) begin, (int) end, (int)step)));
} | [
"@",
"Override",
"public",
"INDArray",
"arange",
"(",
"double",
"begin",
",",
"double",
"end",
",",
"double",
"step",
")",
"{",
"return",
"Nd4j",
".",
"create",
"(",
"ArrayUtil",
".",
"toDoubles",
"(",
"ArrayUtil",
".",
"range",
"(",
"(",
"int",
")",
"begin",
",",
"(",
"int",
")",
"end",
",",
"(",
"int",
")",
"step",
")",
")",
")",
";",
"}"
] | Array of evenly spaced values.
@param begin the begin of the range
@param end the end of the range
@return the range vector | [
"Array",
"of",
"evenly",
"spaced",
"values",
"."
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/factory/BaseNDArrayFactory.java#L350-L353 |
krummas/DrizzleJDBC | src/main/java/org/drizzle/jdbc/DrizzleDataSource.java | DrizzleDataSource.getConnection | public Connection getConnection() throws SQLException {
"""
<p>Attempts to establish a connection with the data source that this <code>DataSource</code> object represents.
@return a connection to the data source
@throws java.sql.SQLException if a database access error occurs
"""
try {
return new DrizzleConnection(new MySQLProtocol(hostname, port, database, null, null, new Properties()),
new DrizzleQueryFactory());
} catch (QueryException e) {
throw SQLExceptionMapper.get(e);
}
} | java | public Connection getConnection() throws SQLException {
try {
return new DrizzleConnection(new MySQLProtocol(hostname, port, database, null, null, new Properties()),
new DrizzleQueryFactory());
} catch (QueryException e) {
throw SQLExceptionMapper.get(e);
}
} | [
"public",
"Connection",
"getConnection",
"(",
")",
"throws",
"SQLException",
"{",
"try",
"{",
"return",
"new",
"DrizzleConnection",
"(",
"new",
"MySQLProtocol",
"(",
"hostname",
",",
"port",
",",
"database",
",",
"null",
",",
"null",
",",
"new",
"Properties",
"(",
")",
")",
",",
"new",
"DrizzleQueryFactory",
"(",
")",
")",
";",
"}",
"catch",
"(",
"QueryException",
"e",
")",
"{",
"throw",
"SQLExceptionMapper",
".",
"get",
"(",
"e",
")",
";",
"}",
"}"
] | <p>Attempts to establish a connection with the data source that this <code>DataSource</code> object represents.
@return a connection to the data source
@throws java.sql.SQLException if a database access error occurs | [
"<p",
">",
"Attempts",
"to",
"establish",
"a",
"connection",
"with",
"the",
"data",
"source",
"that",
"this",
"<code",
">",
"DataSource<",
"/",
"code",
">",
"object",
"represents",
"."
] | train | https://github.com/krummas/DrizzleJDBC/blob/716f31fd71f3cc289edf69844d8117deb86d98d6/src/main/java/org/drizzle/jdbc/DrizzleDataSource.java#L60-L67 |
primefaces/primefaces | src/main/java/org/primefaces/util/LocaleUtils.java | LocaleUtils.resolveLocale | public static Locale resolveLocale(Object locale, String clientId) {
"""
Gets a {@link Locale} instance by the value of the component attribute "locale" which can be String or {@link Locale} or null.
<p>
If NULL is passed the view root default locale is used.
@param locale given locale
@return resolved Locale
"""
Locale result = null;
if (locale != null) {
if (locale instanceof String) {
result = toLocale((String) locale);
}
else if (locale instanceof java.util.Locale) {
result = (java.util.Locale) locale;
}
else {
throw new IllegalArgumentException("Type:" + locale.getClass() + " is not a valid locale type for: " + clientId);
}
}
else {
// default to the view local
result = FacesContext.getCurrentInstance().getViewRoot().getLocale();
}
return result;
} | java | public static Locale resolveLocale(Object locale, String clientId) {
Locale result = null;
if (locale != null) {
if (locale instanceof String) {
result = toLocale((String) locale);
}
else if (locale instanceof java.util.Locale) {
result = (java.util.Locale) locale;
}
else {
throw new IllegalArgumentException("Type:" + locale.getClass() + " is not a valid locale type for: " + clientId);
}
}
else {
// default to the view local
result = FacesContext.getCurrentInstance().getViewRoot().getLocale();
}
return result;
} | [
"public",
"static",
"Locale",
"resolveLocale",
"(",
"Object",
"locale",
",",
"String",
"clientId",
")",
"{",
"Locale",
"result",
"=",
"null",
";",
"if",
"(",
"locale",
"!=",
"null",
")",
"{",
"if",
"(",
"locale",
"instanceof",
"String",
")",
"{",
"result",
"=",
"toLocale",
"(",
"(",
"String",
")",
"locale",
")",
";",
"}",
"else",
"if",
"(",
"locale",
"instanceof",
"java",
".",
"util",
".",
"Locale",
")",
"{",
"result",
"=",
"(",
"java",
".",
"util",
".",
"Locale",
")",
"locale",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Type:\"",
"+",
"locale",
".",
"getClass",
"(",
")",
"+",
"\" is not a valid locale type for: \"",
"+",
"clientId",
")",
";",
"}",
"}",
"else",
"{",
"// default to the view local",
"result",
"=",
"FacesContext",
".",
"getCurrentInstance",
"(",
")",
".",
"getViewRoot",
"(",
")",
".",
"getLocale",
"(",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Gets a {@link Locale} instance by the value of the component attribute "locale" which can be String or {@link Locale} or null.
<p>
If NULL is passed the view root default locale is used.
@param locale given locale
@return resolved Locale | [
"Gets",
"a",
"{",
"@link",
"Locale",
"}",
"instance",
"by",
"the",
"value",
"of",
"the",
"component",
"attribute",
"locale",
"which",
"can",
"be",
"String",
"or",
"{",
"@link",
"Locale",
"}",
"or",
"null",
".",
"<p",
">",
"If",
"NULL",
"is",
"passed",
"the",
"view",
"root",
"default",
"locale",
"is",
"used",
"."
] | train | https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/util/LocaleUtils.java#L86-L106 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java | FileUtil.isDirectory | public static boolean isDirectory(Path path, boolean isFollowLinks) {
"""
判断是否为目录,如果file为null,则返回false
@param path {@link Path}
@param isFollowLinks 是否追踪到软链对应的真实地址
@return 如果为目录true
@since 3.1.0
"""
if (null == path) {
return false;
}
final LinkOption[] options = isFollowLinks ? new LinkOption[0] : new LinkOption[] { LinkOption.NOFOLLOW_LINKS };
return Files.isDirectory(path, options);
} | java | public static boolean isDirectory(Path path, boolean isFollowLinks) {
if (null == path) {
return false;
}
final LinkOption[] options = isFollowLinks ? new LinkOption[0] : new LinkOption[] { LinkOption.NOFOLLOW_LINKS };
return Files.isDirectory(path, options);
} | [
"public",
"static",
"boolean",
"isDirectory",
"(",
"Path",
"path",
",",
"boolean",
"isFollowLinks",
")",
"{",
"if",
"(",
"null",
"==",
"path",
")",
"{",
"return",
"false",
";",
"}",
"final",
"LinkOption",
"[",
"]",
"options",
"=",
"isFollowLinks",
"?",
"new",
"LinkOption",
"[",
"0",
"]",
":",
"new",
"LinkOption",
"[",
"]",
"{",
"LinkOption",
".",
"NOFOLLOW_LINKS",
"}",
";",
"return",
"Files",
".",
"isDirectory",
"(",
"path",
",",
"options",
")",
";",
"}"
] | 判断是否为目录,如果file为null,则返回false
@param path {@link Path}
@param isFollowLinks 是否追踪到软链对应的真实地址
@return 如果为目录true
@since 3.1.0 | [
"判断是否为目录,如果file为null,则返回false"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java#L1257-L1263 |
flow/caustic | api/src/main/java/com/flowpowered/caustic/api/util/TextureAtlas.java | TextureAtlas.addTexture | public void addTexture(String name, InputStream input) throws TextureTooBigException, IOException {
"""
Adds the provided texture from the {@link java.io.InputStream} into this {@link TextureAtlas}.
@param name The name of this {@link Texture}
@param input The {@link java.io.InputStream} of the texture
@throws com.flowpowered.caustic.api.util.TextureAtlas.TextureTooBigException
@throws java.io.IOException
"""
addTexture(name, ImageIO.read(input));
input.close();
} | java | public void addTexture(String name, InputStream input) throws TextureTooBigException, IOException {
addTexture(name, ImageIO.read(input));
input.close();
} | [
"public",
"void",
"addTexture",
"(",
"String",
"name",
",",
"InputStream",
"input",
")",
"throws",
"TextureTooBigException",
",",
"IOException",
"{",
"addTexture",
"(",
"name",
",",
"ImageIO",
".",
"read",
"(",
"input",
")",
")",
";",
"input",
".",
"close",
"(",
")",
";",
"}"
] | Adds the provided texture from the {@link java.io.InputStream} into this {@link TextureAtlas}.
@param name The name of this {@link Texture}
@param input The {@link java.io.InputStream} of the texture
@throws com.flowpowered.caustic.api.util.TextureAtlas.TextureTooBigException
@throws java.io.IOException | [
"Adds",
"the",
"provided",
"texture",
"from",
"the",
"{",
"@link",
"java",
".",
"io",
".",
"InputStream",
"}",
"into",
"this",
"{",
"@link",
"TextureAtlas",
"}",
"."
] | train | https://github.com/flow/caustic/blob/88652fcf0621ce158a0e92ce4c570ed6b1f6fca9/api/src/main/java/com/flowpowered/caustic/api/util/TextureAtlas.java#L78-L81 |
jpush/jmessage-api-java-client | src/main/java/cn/jmessage/api/chatroom/ChatRoomClient.java | ChatRoomClient.getChatRoomMembers | public ChatRoomMemberList getChatRoomMembers(long roomId, int start, int count)
throws APIConnectionException, APIRequestException {
"""
Get all member info of chat room
@param roomId chat room id
@param start start index
@param count member count
@return {@link ChatRoomMemberList}
@throws APIConnectionException connect exception
@throws APIRequestException request exception
"""
Preconditions.checkArgument(roomId > 0, "room id is invalid");
Preconditions.checkArgument(start >= 0 && count > 0, "Illegal argument");
ResponseWrapper responseWrapper = _httpClient.sendGet(_baseUrl + mChatRoomPath + "/" + roomId + "/members"
+ "?start=" + start + "&count=" + count);
return ChatRoomMemberList.fromResponse(responseWrapper, ChatRoomMemberList.class);
} | java | public ChatRoomMemberList getChatRoomMembers(long roomId, int start, int count)
throws APIConnectionException, APIRequestException {
Preconditions.checkArgument(roomId > 0, "room id is invalid");
Preconditions.checkArgument(start >= 0 && count > 0, "Illegal argument");
ResponseWrapper responseWrapper = _httpClient.sendGet(_baseUrl + mChatRoomPath + "/" + roomId + "/members"
+ "?start=" + start + "&count=" + count);
return ChatRoomMemberList.fromResponse(responseWrapper, ChatRoomMemberList.class);
} | [
"public",
"ChatRoomMemberList",
"getChatRoomMembers",
"(",
"long",
"roomId",
",",
"int",
"start",
",",
"int",
"count",
")",
"throws",
"APIConnectionException",
",",
"APIRequestException",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"roomId",
">",
"0",
",",
"\"room id is invalid\"",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"start",
">=",
"0",
"&&",
"count",
">",
"0",
",",
"\"Illegal argument\"",
")",
";",
"ResponseWrapper",
"responseWrapper",
"=",
"_httpClient",
".",
"sendGet",
"(",
"_baseUrl",
"+",
"mChatRoomPath",
"+",
"\"/\"",
"+",
"roomId",
"+",
"\"/members\"",
"+",
"\"?start=\"",
"+",
"start",
"+",
"\"&count=\"",
"+",
"count",
")",
";",
"return",
"ChatRoomMemberList",
".",
"fromResponse",
"(",
"responseWrapper",
",",
"ChatRoomMemberList",
".",
"class",
")",
";",
"}"
] | Get all member info of chat room
@param roomId chat room id
@param start start index
@param count member count
@return {@link ChatRoomMemberList}
@throws APIConnectionException connect exception
@throws APIRequestException request exception | [
"Get",
"all",
"member",
"info",
"of",
"chat",
"room"
] | train | https://github.com/jpush/jmessage-api-java-client/blob/767f5fb15e9fe5a546c00f6e68b64f6dd53c617c/src/main/java/cn/jmessage/api/chatroom/ChatRoomClient.java#L172-L179 |
ops4j/org.ops4j.pax.web | pax-web-extender-whiteboard/src/main/java/org/ops4j/pax/web/extender/whiteboard/internal/util/ServicePropertiesUtils.java | ServicePropertiesUtils.getIntegerProperty | public static Integer getIntegerProperty(final ServiceReference<?> serviceReference, final String key) {
"""
Returns a property as Integer.
@param serviceReference service reference; cannot be null
@param key property key; cannot be null
@return property value; null if property is not set or property value is
not an Integer
@throws NullArgumentException - If service reference is null - If key is null
"""
NullArgumentException.validateNotNull(serviceReference, "Service reference");
NullArgumentException.validateNotEmpty(key, true, "Property key");
final Object value = serviceReference.getProperty(key);
if (value instanceof Integer) {
return (Integer) value;
} else if (value != null) {
try {
return Integer.parseInt(String.valueOf(value));
} catch (NumberFormatException e) {
final String message = String.format("Property [%s] value must be an Integer: %s", key, e.getMessage());
LOG.error(message, e);
return null;
}
} else {
return null;
}
} | java | public static Integer getIntegerProperty(final ServiceReference<?> serviceReference, final String key) {
NullArgumentException.validateNotNull(serviceReference, "Service reference");
NullArgumentException.validateNotEmpty(key, true, "Property key");
final Object value = serviceReference.getProperty(key);
if (value instanceof Integer) {
return (Integer) value;
} else if (value != null) {
try {
return Integer.parseInt(String.valueOf(value));
} catch (NumberFormatException e) {
final String message = String.format("Property [%s] value must be an Integer: %s", key, e.getMessage());
LOG.error(message, e);
return null;
}
} else {
return null;
}
} | [
"public",
"static",
"Integer",
"getIntegerProperty",
"(",
"final",
"ServiceReference",
"<",
"?",
">",
"serviceReference",
",",
"final",
"String",
"key",
")",
"{",
"NullArgumentException",
".",
"validateNotNull",
"(",
"serviceReference",
",",
"\"Service reference\"",
")",
";",
"NullArgumentException",
".",
"validateNotEmpty",
"(",
"key",
",",
"true",
",",
"\"Property key\"",
")",
";",
"final",
"Object",
"value",
"=",
"serviceReference",
".",
"getProperty",
"(",
"key",
")",
";",
"if",
"(",
"value",
"instanceof",
"Integer",
")",
"{",
"return",
"(",
"Integer",
")",
"value",
";",
"}",
"else",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"try",
"{",
"return",
"Integer",
".",
"parseInt",
"(",
"String",
".",
"valueOf",
"(",
"value",
")",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"final",
"String",
"message",
"=",
"String",
".",
"format",
"(",
"\"Property [%s] value must be an Integer: %s\"",
",",
"key",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"LOG",
".",
"error",
"(",
"message",
",",
"e",
")",
";",
"return",
"null",
";",
"}",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Returns a property as Integer.
@param serviceReference service reference; cannot be null
@param key property key; cannot be null
@return property value; null if property is not set or property value is
not an Integer
@throws NullArgumentException - If service reference is null - If key is null | [
"Returns",
"a",
"property",
"as",
"Integer",
"."
] | train | https://github.com/ops4j/org.ops4j.pax.web/blob/9ecf3676c1d316be0d43ea7fcfdc8f0defffc2a2/pax-web-extender-whiteboard/src/main/java/org/ops4j/pax/web/extender/whiteboard/internal/util/ServicePropertiesUtils.java#L93-L110 |
b3dgs/lionengine | lionengine-core/src/main/java/com/b3dgs/lionengine/ResourceLoader.java | ResourceLoader.await | public synchronized void await() {
"""
Wait for load to finish. Can be called only if {@link #start()} were performed somewhere before.
@throws LionEngineException If loading skipped or loader has not been started.
"""
if (!started.get())
{
throw new LionEngineException(ERROR_NOT_STARTED);
}
try
{
thread.join();
}
catch (final InterruptedException exception)
{
Thread.currentThread().interrupt();
throw new LionEngineException(exception, ERROR_SKIPPED);
}
finally
{
done.set(true);
}
} | java | public synchronized void await()
{
if (!started.get())
{
throw new LionEngineException(ERROR_NOT_STARTED);
}
try
{
thread.join();
}
catch (final InterruptedException exception)
{
Thread.currentThread().interrupt();
throw new LionEngineException(exception, ERROR_SKIPPED);
}
finally
{
done.set(true);
}
} | [
"public",
"synchronized",
"void",
"await",
"(",
")",
"{",
"if",
"(",
"!",
"started",
".",
"get",
"(",
")",
")",
"{",
"throw",
"new",
"LionEngineException",
"(",
"ERROR_NOT_STARTED",
")",
";",
"}",
"try",
"{",
"thread",
".",
"join",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"InterruptedException",
"exception",
")",
"{",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"throw",
"new",
"LionEngineException",
"(",
"exception",
",",
"ERROR_SKIPPED",
")",
";",
"}",
"finally",
"{",
"done",
".",
"set",
"(",
"true",
")",
";",
"}",
"}"
] | Wait for load to finish. Can be called only if {@link #start()} were performed somewhere before.
@throws LionEngineException If loading skipped or loader has not been started. | [
"Wait",
"for",
"load",
"to",
"finish",
".",
"Can",
"be",
"called",
"only",
"if",
"{",
"@link",
"#start",
"()",
"}",
"were",
"performed",
"somewhere",
"before",
"."
] | train | https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-core/src/main/java/com/b3dgs/lionengine/ResourceLoader.java#L107-L126 |
liyiorg/weixin-popular | src/main/java/weixin/popular/api/MessageAPI.java | MessageAPI.messageCustomSend | public static BaseResult messageCustomSend(String access_token, Message message) {
"""
消息发送
@param access_token access_token
@param message message
@return BaseResult
"""
String str = JsonUtil.toJSONString(message);
return messageCustomSend(access_token, str);
} | java | public static BaseResult messageCustomSend(String access_token, Message message) {
String str = JsonUtil.toJSONString(message);
return messageCustomSend(access_token, str);
} | [
"public",
"static",
"BaseResult",
"messageCustomSend",
"(",
"String",
"access_token",
",",
"Message",
"message",
")",
"{",
"String",
"str",
"=",
"JsonUtil",
".",
"toJSONString",
"(",
"message",
")",
";",
"return",
"messageCustomSend",
"(",
"access_token",
",",
"str",
")",
";",
"}"
] | 消息发送
@param access_token access_token
@param message message
@return BaseResult | [
"消息发送"
] | train | https://github.com/liyiorg/weixin-popular/blob/c64255292d41463bdb671938feaabf42a335d82c/src/main/java/weixin/popular/api/MessageAPI.java#L68-L71 |
samskivert/pythagoras | src/main/java/pythagoras/d/Matrix4.java | Matrix4.setTranslation | public Matrix4 setTranslation (double x, double y, double z) {
"""
Sets the translation component of this matrix.
@return a reference to this matrix, for chaining.
"""
m30 = x;
m31 = y;
m32 = z;
return this;
} | java | public Matrix4 setTranslation (double x, double y, double z) {
m30 = x;
m31 = y;
m32 = z;
return this;
} | [
"public",
"Matrix4",
"setTranslation",
"(",
"double",
"x",
",",
"double",
"y",
",",
"double",
"z",
")",
"{",
"m30",
"=",
"x",
";",
"m31",
"=",
"y",
";",
"m32",
"=",
"z",
";",
"return",
"this",
";",
"}"
] | Sets the translation component of this matrix.
@return a reference to this matrix, for chaining. | [
"Sets",
"the",
"translation",
"component",
"of",
"this",
"matrix",
"."
] | train | https://github.com/samskivert/pythagoras/blob/b8fea743ee8a7d742ad9c06ee4f11f50571fbd32/src/main/java/pythagoras/d/Matrix4.java#L169-L174 |
spring-projects/spring-hateoas | src/main/java/org/springframework/hateoas/config/WebClientConfigurer.java | WebClientConfigurer.hypermediaExchangeStrategies | public ExchangeStrategies hypermediaExchangeStrategies() {
"""
Return a set of {@link ExchangeStrategies} driven by registered {@link HypermediaType}s.
@return a collection of {@link Encoder}s and {@link Decoder} assembled into a {@link ExchangeStrategies}.
"""
List<Encoder<?>> encoders = new ArrayList<>();
List<Decoder<?>> decoders = new ArrayList<>();
this.hypermediaTypes.forEach(hypermedia -> {
ObjectMapper objectMapper = hypermedia.configureObjectMapper(this.mapper.copy());
MimeType[] mimeTypes = hypermedia.getMediaTypes().toArray(new MimeType[0]);
encoders.add(new Jackson2JsonEncoder(objectMapper, mimeTypes));
decoders.add(new Jackson2JsonDecoder(objectMapper, mimeTypes));
});
return ExchangeStrategies.builder().codecs(clientCodecConfigurer -> {
encoders.forEach(encoder -> clientCodecConfigurer.customCodecs().encoder(encoder));
decoders.forEach(decoder -> clientCodecConfigurer.customCodecs().decoder(decoder));
}).build();
} | java | public ExchangeStrategies hypermediaExchangeStrategies() {
List<Encoder<?>> encoders = new ArrayList<>();
List<Decoder<?>> decoders = new ArrayList<>();
this.hypermediaTypes.forEach(hypermedia -> {
ObjectMapper objectMapper = hypermedia.configureObjectMapper(this.mapper.copy());
MimeType[] mimeTypes = hypermedia.getMediaTypes().toArray(new MimeType[0]);
encoders.add(new Jackson2JsonEncoder(objectMapper, mimeTypes));
decoders.add(new Jackson2JsonDecoder(objectMapper, mimeTypes));
});
return ExchangeStrategies.builder().codecs(clientCodecConfigurer -> {
encoders.forEach(encoder -> clientCodecConfigurer.customCodecs().encoder(encoder));
decoders.forEach(decoder -> clientCodecConfigurer.customCodecs().decoder(decoder));
}).build();
} | [
"public",
"ExchangeStrategies",
"hypermediaExchangeStrategies",
"(",
")",
"{",
"List",
"<",
"Encoder",
"<",
"?",
">",
">",
"encoders",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"List",
"<",
"Decoder",
"<",
"?",
">",
">",
"decoders",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"this",
".",
"hypermediaTypes",
".",
"forEach",
"(",
"hypermedia",
"->",
"{",
"ObjectMapper",
"objectMapper",
"=",
"hypermedia",
".",
"configureObjectMapper",
"(",
"this",
".",
"mapper",
".",
"copy",
"(",
")",
")",
";",
"MimeType",
"[",
"]",
"mimeTypes",
"=",
"hypermedia",
".",
"getMediaTypes",
"(",
")",
".",
"toArray",
"(",
"new",
"MimeType",
"[",
"0",
"]",
")",
";",
"encoders",
".",
"add",
"(",
"new",
"Jackson2JsonEncoder",
"(",
"objectMapper",
",",
"mimeTypes",
")",
")",
";",
"decoders",
".",
"add",
"(",
"new",
"Jackson2JsonDecoder",
"(",
"objectMapper",
",",
"mimeTypes",
")",
")",
";",
"}",
")",
";",
"return",
"ExchangeStrategies",
".",
"builder",
"(",
")",
".",
"codecs",
"(",
"clientCodecConfigurer",
"->",
"{",
"encoders",
".",
"forEach",
"(",
"encoder",
"->",
"clientCodecConfigurer",
".",
"customCodecs",
"(",
")",
".",
"encoder",
"(",
"encoder",
")",
")",
";",
"decoders",
".",
"forEach",
"(",
"decoder",
"->",
"clientCodecConfigurer",
".",
"customCodecs",
"(",
")",
".",
"decoder",
"(",
"decoder",
")",
")",
";",
"}",
")",
".",
"build",
"(",
")",
";",
"}"
] | Return a set of {@link ExchangeStrategies} driven by registered {@link HypermediaType}s.
@return a collection of {@link Encoder}s and {@link Decoder} assembled into a {@link ExchangeStrategies}. | [
"Return",
"a",
"set",
"of",
"{",
"@link",
"ExchangeStrategies",
"}",
"driven",
"by",
"registered",
"{",
"@link",
"HypermediaType",
"}",
"s",
"."
] | train | https://github.com/spring-projects/spring-hateoas/blob/70ebff9309f086cd8d6a97daf67e0dc215c87d9c/src/main/java/org/springframework/hateoas/config/WebClientConfigurer.java#L54-L74 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/provider/certpath/X509CertPath.java | X509CertPath.encodePKCS7 | private byte[] encodePKCS7() throws CertificateEncodingException {
"""
Encode the CertPath using PKCS#7 format.
@return a byte array containing the binary encoding of the PKCS#7 object
@exception CertificateEncodingException if an exception occurs
"""
PKCS7 p7 = new PKCS7(new AlgorithmId[0],
new ContentInfo(ContentInfo.DATA_OID, null),
certs.toArray(new X509Certificate[certs.size()]),
new SignerInfo[0]);
DerOutputStream derout = new DerOutputStream();
try {
p7.encodeSignedData(derout);
} catch (IOException ioe) {
throw new CertificateEncodingException(ioe.getMessage());
}
return derout.toByteArray();
} | java | private byte[] encodePKCS7() throws CertificateEncodingException {
PKCS7 p7 = new PKCS7(new AlgorithmId[0],
new ContentInfo(ContentInfo.DATA_OID, null),
certs.toArray(new X509Certificate[certs.size()]),
new SignerInfo[0]);
DerOutputStream derout = new DerOutputStream();
try {
p7.encodeSignedData(derout);
} catch (IOException ioe) {
throw new CertificateEncodingException(ioe.getMessage());
}
return derout.toByteArray();
} | [
"private",
"byte",
"[",
"]",
"encodePKCS7",
"(",
")",
"throws",
"CertificateEncodingException",
"{",
"PKCS7",
"p7",
"=",
"new",
"PKCS7",
"(",
"new",
"AlgorithmId",
"[",
"0",
"]",
",",
"new",
"ContentInfo",
"(",
"ContentInfo",
".",
"DATA_OID",
",",
"null",
")",
",",
"certs",
".",
"toArray",
"(",
"new",
"X509Certificate",
"[",
"certs",
".",
"size",
"(",
")",
"]",
")",
",",
"new",
"SignerInfo",
"[",
"0",
"]",
")",
";",
"DerOutputStream",
"derout",
"=",
"new",
"DerOutputStream",
"(",
")",
";",
"try",
"{",
"p7",
".",
"encodeSignedData",
"(",
"derout",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"throw",
"new",
"CertificateEncodingException",
"(",
"ioe",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"derout",
".",
"toByteArray",
"(",
")",
";",
"}"
] | Encode the CertPath using PKCS#7 format.
@return a byte array containing the binary encoding of the PKCS#7 object
@exception CertificateEncodingException if an exception occurs | [
"Encode",
"the",
"CertPath",
"using",
"PKCS#7",
"format",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/provider/certpath/X509CertPath.java#L323-L335 |
alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/cluster/Cluster.java | Cluster.get_topology_id | public static String get_topology_id(StormClusterState zkCluster, String storm_name) throws Exception {
"""
if a topology's name is equal to the input storm_name, then return the topology id, otherwise return null
"""
List<String> active_storms = zkCluster.active_storms();
String rtn = null;
if (active_storms != null) {
for (String topology_id : active_storms) {
if (!topology_id.contains(storm_name)) {
continue;
}
StormBase base = zkCluster.storm_base(topology_id, null);
if (base != null && storm_name.equals(Common.getTopologyNameById(topology_id))) {
rtn = topology_id;
break;
}
}
}
return rtn;
} | java | public static String get_topology_id(StormClusterState zkCluster, String storm_name) throws Exception {
List<String> active_storms = zkCluster.active_storms();
String rtn = null;
if (active_storms != null) {
for (String topology_id : active_storms) {
if (!topology_id.contains(storm_name)) {
continue;
}
StormBase base = zkCluster.storm_base(topology_id, null);
if (base != null && storm_name.equals(Common.getTopologyNameById(topology_id))) {
rtn = topology_id;
break;
}
}
}
return rtn;
} | [
"public",
"static",
"String",
"get_topology_id",
"(",
"StormClusterState",
"zkCluster",
",",
"String",
"storm_name",
")",
"throws",
"Exception",
"{",
"List",
"<",
"String",
">",
"active_storms",
"=",
"zkCluster",
".",
"active_storms",
"(",
")",
";",
"String",
"rtn",
"=",
"null",
";",
"if",
"(",
"active_storms",
"!=",
"null",
")",
"{",
"for",
"(",
"String",
"topology_id",
":",
"active_storms",
")",
"{",
"if",
"(",
"!",
"topology_id",
".",
"contains",
"(",
"storm_name",
")",
")",
"{",
"continue",
";",
"}",
"StormBase",
"base",
"=",
"zkCluster",
".",
"storm_base",
"(",
"topology_id",
",",
"null",
")",
";",
"if",
"(",
"base",
"!=",
"null",
"&&",
"storm_name",
".",
"equals",
"(",
"Common",
".",
"getTopologyNameById",
"(",
"topology_id",
")",
")",
")",
"{",
"rtn",
"=",
"topology_id",
";",
"break",
";",
"}",
"}",
"}",
"return",
"rtn",
";",
"}"
] | if a topology's name is equal to the input storm_name, then return the topology id, otherwise return null | [
"if",
"a",
"topology",
"s",
"name",
"is",
"equal",
"to",
"the",
"input",
"storm_name",
"then",
"return",
"the",
"topology",
"id",
"otherwise",
"return",
"null"
] | train | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/cluster/Cluster.java#L224-L241 |
hal/core | gui/src/main/java/org/jboss/as/console/mbui/behaviour/LoadResourceProcedure.java | LoadResourceProcedure.assignKeyFromAddressNode | private static void assignKeyFromAddressNode(ModelNode payload, ModelNode address) {
"""
the model representations we use internally carry along the entity keys.
these are derived from the resource address, but will be available as synthetic resource attributes.
@param payload
@param address
"""
List<Property> props = address.asPropertyList();
Property lastToken = props.get(props.size()-1);
payload.get("entity.key").set(lastToken.getValue().asString());
} | java | private static void assignKeyFromAddressNode(ModelNode payload, ModelNode address) {
List<Property> props = address.asPropertyList();
Property lastToken = props.get(props.size()-1);
payload.get("entity.key").set(lastToken.getValue().asString());
} | [
"private",
"static",
"void",
"assignKeyFromAddressNode",
"(",
"ModelNode",
"payload",
",",
"ModelNode",
"address",
")",
"{",
"List",
"<",
"Property",
">",
"props",
"=",
"address",
".",
"asPropertyList",
"(",
")",
";",
"Property",
"lastToken",
"=",
"props",
".",
"get",
"(",
"props",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"payload",
".",
"get",
"(",
"\"entity.key\"",
")",
".",
"set",
"(",
"lastToken",
".",
"getValue",
"(",
")",
".",
"asString",
"(",
")",
")",
";",
"}"
] | the model representations we use internally carry along the entity keys.
these are derived from the resource address, but will be available as synthetic resource attributes.
@param payload
@param address | [
"the",
"model",
"representations",
"we",
"use",
"internally",
"carry",
"along",
"the",
"entity",
"keys",
".",
"these",
"are",
"derived",
"from",
"the",
"resource",
"address",
"but",
"will",
"be",
"available",
"as",
"synthetic",
"resource",
"attributes",
"."
] | train | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/mbui/behaviour/LoadResourceProcedure.java#L179-L183 |
JM-Lab/utils-java8 | src/main/java/kr/jm/utils/helper/JMOptional.java | JMOptional.ifNotNull | public static <T> void ifNotNull(T object, Consumer<T> consumer) {
"""
If not null.
@param <T> the type parameter
@param object the object
@param consumer the consumer
"""
Optional.ofNullable(object).ifPresent(consumer);
} | java | public static <T> void ifNotNull(T object, Consumer<T> consumer) {
Optional.ofNullable(object).ifPresent(consumer);
} | [
"public",
"static",
"<",
"T",
">",
"void",
"ifNotNull",
"(",
"T",
"object",
",",
"Consumer",
"<",
"T",
">",
"consumer",
")",
"{",
"Optional",
".",
"ofNullable",
"(",
"object",
")",
".",
"ifPresent",
"(",
"consumer",
")",
";",
"}"
] | If not null.
@param <T> the type parameter
@param object the object
@param consumer the consumer | [
"If",
"not",
"null",
"."
] | train | https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMOptional.java#L217-L219 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java | Evaluation.fBeta | public double fBeta(double beta, int classLabel, double defaultValue) {
"""
Calculate the f_beta for a given class, where f_beta is defined as:<br>
(1+beta^2) * (precision * recall) / (beta^2 * precision + recall).<br>
F1 is a special case of f_beta, with beta=1.0
@param beta Beta value to use
@param classLabel Class label
@param defaultValue Default value to use when precision or recall is undefined (0/0 for prec. or recall)
@return F_beta
"""
double precision = precision(classLabel, -1);
double recall = recall(classLabel, -1);
if (precision == -1 || recall == -1) {
return defaultValue;
}
return EvaluationUtils.fBeta(beta, precision, recall);
} | java | public double fBeta(double beta, int classLabel, double defaultValue) {
double precision = precision(classLabel, -1);
double recall = recall(classLabel, -1);
if (precision == -1 || recall == -1) {
return defaultValue;
}
return EvaluationUtils.fBeta(beta, precision, recall);
} | [
"public",
"double",
"fBeta",
"(",
"double",
"beta",
",",
"int",
"classLabel",
",",
"double",
"defaultValue",
")",
"{",
"double",
"precision",
"=",
"precision",
"(",
"classLabel",
",",
"-",
"1",
")",
";",
"double",
"recall",
"=",
"recall",
"(",
"classLabel",
",",
"-",
"1",
")",
";",
"if",
"(",
"precision",
"==",
"-",
"1",
"||",
"recall",
"==",
"-",
"1",
")",
"{",
"return",
"defaultValue",
";",
"}",
"return",
"EvaluationUtils",
".",
"fBeta",
"(",
"beta",
",",
"precision",
",",
"recall",
")",
";",
"}"
] | Calculate the f_beta for a given class, where f_beta is defined as:<br>
(1+beta^2) * (precision * recall) / (beta^2 * precision + recall).<br>
F1 is a special case of f_beta, with beta=1.0
@param beta Beta value to use
@param classLabel Class label
@param defaultValue Default value to use when precision or recall is undefined (0/0 for prec. or recall)
@return F_beta | [
"Calculate",
"the",
"f_beta",
"for",
"a",
"given",
"class",
"where",
"f_beta",
"is",
"defined",
"as",
":",
"<br",
">",
"(",
"1",
"+",
"beta^2",
")",
"*",
"(",
"precision",
"*",
"recall",
")",
"/",
"(",
"beta^2",
"*",
"precision",
"+",
"recall",
")",
".",
"<br",
">",
"F1",
"is",
"a",
"special",
"case",
"of",
"f_beta",
"with",
"beta",
"=",
"1",
".",
"0"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/Evaluation.java#L1225-L1232 |
windup/windup | config/impl/src/main/java/org/jboss/windup/config/loader/RuleProviderSorter.java | RuleProviderSorter.checkForCycles | private void checkForCycles(DefaultDirectedWeightedGraph<RuleProvider, DefaultEdge> graph) {
"""
Use the jgrapht cycle checker to detect any cycles in the provided dependency graph.
"""
CycleDetector<RuleProvider, DefaultEdge> cycleDetector = new CycleDetector<>(graph);
if (cycleDetector.detectCycles())
{
// if we have cycles, then try to throw an exception with some usable data
Set<RuleProvider> cycles = cycleDetector.findCycles();
StringBuilder errorSB = new StringBuilder();
for (RuleProvider cycle : cycles)
{
errorSB.append("Found dependency cycle involving: " + cycle.getMetadata().getID()).append(System.lineSeparator());
Set<RuleProvider> subCycleSet = cycleDetector.findCyclesContainingVertex(cycle);
for (RuleProvider subCycle : subCycleSet)
{
errorSB.append("\tSubcycle: " + subCycle.getMetadata().getID()).append(System.lineSeparator());
}
}
throw new RuntimeException("Dependency cycles detected: " + errorSB.toString());
}
} | java | private void checkForCycles(DefaultDirectedWeightedGraph<RuleProvider, DefaultEdge> graph)
{
CycleDetector<RuleProvider, DefaultEdge> cycleDetector = new CycleDetector<>(graph);
if (cycleDetector.detectCycles())
{
// if we have cycles, then try to throw an exception with some usable data
Set<RuleProvider> cycles = cycleDetector.findCycles();
StringBuilder errorSB = new StringBuilder();
for (RuleProvider cycle : cycles)
{
errorSB.append("Found dependency cycle involving: " + cycle.getMetadata().getID()).append(System.lineSeparator());
Set<RuleProvider> subCycleSet = cycleDetector.findCyclesContainingVertex(cycle);
for (RuleProvider subCycle : subCycleSet)
{
errorSB.append("\tSubcycle: " + subCycle.getMetadata().getID()).append(System.lineSeparator());
}
}
throw new RuntimeException("Dependency cycles detected: " + errorSB.toString());
}
} | [
"private",
"void",
"checkForCycles",
"(",
"DefaultDirectedWeightedGraph",
"<",
"RuleProvider",
",",
"DefaultEdge",
">",
"graph",
")",
"{",
"CycleDetector",
"<",
"RuleProvider",
",",
"DefaultEdge",
">",
"cycleDetector",
"=",
"new",
"CycleDetector",
"<>",
"(",
"graph",
")",
";",
"if",
"(",
"cycleDetector",
".",
"detectCycles",
"(",
")",
")",
"{",
"// if we have cycles, then try to throw an exception with some usable data",
"Set",
"<",
"RuleProvider",
">",
"cycles",
"=",
"cycleDetector",
".",
"findCycles",
"(",
")",
";",
"StringBuilder",
"errorSB",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"RuleProvider",
"cycle",
":",
"cycles",
")",
"{",
"errorSB",
".",
"append",
"(",
"\"Found dependency cycle involving: \"",
"+",
"cycle",
".",
"getMetadata",
"(",
")",
".",
"getID",
"(",
")",
")",
".",
"append",
"(",
"System",
".",
"lineSeparator",
"(",
")",
")",
";",
"Set",
"<",
"RuleProvider",
">",
"subCycleSet",
"=",
"cycleDetector",
".",
"findCyclesContainingVertex",
"(",
"cycle",
")",
";",
"for",
"(",
"RuleProvider",
"subCycle",
":",
"subCycleSet",
")",
"{",
"errorSB",
".",
"append",
"(",
"\"\\tSubcycle: \"",
"+",
"subCycle",
".",
"getMetadata",
"(",
")",
".",
"getID",
"(",
")",
")",
".",
"append",
"(",
"System",
".",
"lineSeparator",
"(",
")",
")",
";",
"}",
"}",
"throw",
"new",
"RuntimeException",
"(",
"\"Dependency cycles detected: \"",
"+",
"errorSB",
".",
"toString",
"(",
")",
")",
";",
"}",
"}"
] | Use the jgrapht cycle checker to detect any cycles in the provided dependency graph. | [
"Use",
"the",
"jgrapht",
"cycle",
"checker",
"to",
"detect",
"any",
"cycles",
"in",
"the",
"provided",
"dependency",
"graph",
"."
] | train | https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/config/impl/src/main/java/org/jboss/windup/config/loader/RuleProviderSorter.java#L267-L287 |
jenkinsci/java-client-api | jenkins-client/src/main/java/com/offbytwo/jenkins/client/util/UrlUtils.java | UrlUtils.toJsonApiUri | public static URI toJsonApiUri(final URI uri, final String context, final String path) {
"""
Create a JSON URI from the supplied parameters.
@param uri the server URI
@param context the server context if any
@param path the specific API path
@return new full URI instance
"""
String p = path;
if (!p.matches("(?i)https?://.*")) p = join(context, p);
if (!p.contains("?")) {
p = join(p, "api/json");
} else {
final String[] components = p.split("\\?", 2);
p = join(components[0], "api/json") + "?" + components[1];
}
return uri.resolve("/").resolve(p.replace(" ", "%20"));
} | java | public static URI toJsonApiUri(final URI uri, final String context, final String path) {
String p = path;
if (!p.matches("(?i)https?://.*")) p = join(context, p);
if (!p.contains("?")) {
p = join(p, "api/json");
} else {
final String[] components = p.split("\\?", 2);
p = join(components[0], "api/json") + "?" + components[1];
}
return uri.resolve("/").resolve(p.replace(" ", "%20"));
} | [
"public",
"static",
"URI",
"toJsonApiUri",
"(",
"final",
"URI",
"uri",
",",
"final",
"String",
"context",
",",
"final",
"String",
"path",
")",
"{",
"String",
"p",
"=",
"path",
";",
"if",
"(",
"!",
"p",
".",
"matches",
"(",
"\"(?i)https?://.*\"",
")",
")",
"p",
"=",
"join",
"(",
"context",
",",
"p",
")",
";",
"if",
"(",
"!",
"p",
".",
"contains",
"(",
"\"?\"",
")",
")",
"{",
"p",
"=",
"join",
"(",
"p",
",",
"\"api/json\"",
")",
";",
"}",
"else",
"{",
"final",
"String",
"[",
"]",
"components",
"=",
"p",
".",
"split",
"(",
"\"\\\\?\"",
",",
"2",
")",
";",
"p",
"=",
"join",
"(",
"components",
"[",
"0",
"]",
",",
"\"api/json\"",
")",
"+",
"\"?\"",
"+",
"components",
"[",
"1",
"]",
";",
"}",
"return",
"uri",
".",
"resolve",
"(",
"\"/\"",
")",
".",
"resolve",
"(",
"p",
".",
"replace",
"(",
"\" \"",
",",
"\"%20\"",
")",
")",
";",
"}"
] | Create a JSON URI from the supplied parameters.
@param uri the server URI
@param context the server context if any
@param path the specific API path
@return new full URI instance | [
"Create",
"a",
"JSON",
"URI",
"from",
"the",
"supplied",
"parameters",
"."
] | train | https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/client/util/UrlUtils.java#L127-L138 |
phax/ph-oton | ph-oton-uictrls/src/main/java/com/helger/photon/uictrls/fineupload5/FineUploader5DeleteFile.java | FineUploader5DeleteFile.addCustomHeaders | @Nonnull
public FineUploader5DeleteFile addCustomHeaders (@Nullable final Map <String, String> aCustomHeaders) {
"""
Any additional headers to attach to all delete file requests.
@param aCustomHeaders
Custom headers to be added.
@return this
"""
m_aDeleteFileCustomHeaders.addAll (aCustomHeaders);
return this;
} | java | @Nonnull
public FineUploader5DeleteFile addCustomHeaders (@Nullable final Map <String, String> aCustomHeaders)
{
m_aDeleteFileCustomHeaders.addAll (aCustomHeaders);
return this;
} | [
"@",
"Nonnull",
"public",
"FineUploader5DeleteFile",
"addCustomHeaders",
"(",
"@",
"Nullable",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"aCustomHeaders",
")",
"{",
"m_aDeleteFileCustomHeaders",
".",
"addAll",
"(",
"aCustomHeaders",
")",
";",
"return",
"this",
";",
"}"
] | Any additional headers to attach to all delete file requests.
@param aCustomHeaders
Custom headers to be added.
@return this | [
"Any",
"additional",
"headers",
"to",
"attach",
"to",
"all",
"delete",
"file",
"requests",
"."
] | train | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-uictrls/src/main/java/com/helger/photon/uictrls/fineupload5/FineUploader5DeleteFile.java#L82-L87 |
carewebframework/carewebframework-core | org.carewebframework.api-parent/org.carewebframework.api.core/src/main/java/org/carewebframework/api/context/ContextManager.java | ContextManager.appendResponse | public static void appendResponse(StringBuilder buffer, String response) {
"""
Accumulate response values in string buffer.
@param buffer StringBuilder to which to append response
@param response Appended to buffer
"""
if (response != null && !response.isEmpty()) {
if (buffer.length() > 0) {
buffer.append("\r\n");
}
buffer.append(response);
}
} | java | public static void appendResponse(StringBuilder buffer, String response) {
if (response != null && !response.isEmpty()) {
if (buffer.length() > 0) {
buffer.append("\r\n");
}
buffer.append(response);
}
} | [
"public",
"static",
"void",
"appendResponse",
"(",
"StringBuilder",
"buffer",
",",
"String",
"response",
")",
"{",
"if",
"(",
"response",
"!=",
"null",
"&&",
"!",
"response",
".",
"isEmpty",
"(",
")",
")",
"{",
"if",
"(",
"buffer",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"buffer",
".",
"append",
"(",
"\"\\r\\n\"",
")",
";",
"}",
"buffer",
".",
"append",
"(",
"response",
")",
";",
"}",
"}"
] | Accumulate response values in string buffer.
@param buffer StringBuilder to which to append response
@param response Appended to buffer | [
"Accumulate",
"response",
"values",
"in",
"string",
"buffer",
"."
] | train | https://github.com/carewebframework/carewebframework-core/blob/fa3252d4f7541dbe151b92c3d4f6f91433cd1673/org.carewebframework.api-parent/org.carewebframework.api.core/src/main/java/org/carewebframework/api/context/ContextManager.java#L89-L97 |
ngageoint/geopackage-android-map | geopackage-map/src/main/java/mil/nga/geopackage/map/features/StyleUtils.java | StyleUtils.setFeatureStyle | public static boolean setFeatureStyle(PolylineOptions polylineOptions, FeatureStyleExtension featureStyleExtension, FeatureRow featureRow, float density) {
"""
Set the feature row style into the polyline options
@param polylineOptions polyline options
@param featureStyleExtension feature style extension
@param featureRow feature row
@param density display density: {@link android.util.DisplayMetrics#density}
@return true if style was set into the polyline options
"""
FeatureStyle featureStyle = featureStyleExtension.getFeatureStyle(featureRow);
return setFeatureStyle(polylineOptions, featureStyle, density);
} | java | public static boolean setFeatureStyle(PolylineOptions polylineOptions, FeatureStyleExtension featureStyleExtension, FeatureRow featureRow, float density) {
FeatureStyle featureStyle = featureStyleExtension.getFeatureStyle(featureRow);
return setFeatureStyle(polylineOptions, featureStyle, density);
} | [
"public",
"static",
"boolean",
"setFeatureStyle",
"(",
"PolylineOptions",
"polylineOptions",
",",
"FeatureStyleExtension",
"featureStyleExtension",
",",
"FeatureRow",
"featureRow",
",",
"float",
"density",
")",
"{",
"FeatureStyle",
"featureStyle",
"=",
"featureStyleExtension",
".",
"getFeatureStyle",
"(",
"featureRow",
")",
";",
"return",
"setFeatureStyle",
"(",
"polylineOptions",
",",
"featureStyle",
",",
"density",
")",
";",
"}"
] | Set the feature row style into the polyline options
@param polylineOptions polyline options
@param featureStyleExtension feature style extension
@param featureRow feature row
@param density display density: {@link android.util.DisplayMetrics#density}
@return true if style was set into the polyline options | [
"Set",
"the",
"feature",
"row",
"style",
"into",
"the",
"polyline",
"options"
] | train | https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/features/StyleUtils.java#L399-L404 |
alkacon/opencms-core | src/org/opencms/staticexport/CmsAdvancedLinkSubstitutionHandler.java | CmsAdvancedLinkSubstitutionHandler.isExcluded | protected boolean isExcluded(CmsObject cms, String path) {
"""
Returns if the given path starts with an exclude prefix.<p>
@param cms the cms context
@param path the path to check
@return <code>true</code> if the given path starts with an exclude prefix
"""
List<String> excludes = getExcludes(cms);
// now check if the current link start with one of the exclude links
for (int i = 0; i < excludes.size(); i++) {
if (path.startsWith(excludes.get(i))) {
return true;
}
}
return false;
} | java | protected boolean isExcluded(CmsObject cms, String path) {
List<String> excludes = getExcludes(cms);
// now check if the current link start with one of the exclude links
for (int i = 0; i < excludes.size(); i++) {
if (path.startsWith(excludes.get(i))) {
return true;
}
}
return false;
} | [
"protected",
"boolean",
"isExcluded",
"(",
"CmsObject",
"cms",
",",
"String",
"path",
")",
"{",
"List",
"<",
"String",
">",
"excludes",
"=",
"getExcludes",
"(",
"cms",
")",
";",
"// now check if the current link start with one of the exclude links",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"excludes",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"path",
".",
"startsWith",
"(",
"excludes",
".",
"get",
"(",
"i",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Returns if the given path starts with an exclude prefix.<p>
@param cms the cms context
@param path the path to check
@return <code>true</code> if the given path starts with an exclude prefix | [
"Returns",
"if",
"the",
"given",
"path",
"starts",
"with",
"an",
"exclude",
"prefix",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/staticexport/CmsAdvancedLinkSubstitutionHandler.java#L128-L138 |
Carbonado/Carbonado | src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java | CodeBuilderUtil.blankValue | public static void blankValue(CodeBuilder b, TypeDesc type) {
"""
Generates code to push a blank value to the stack. For objects, it is
null, and for primitive types it is zero or false.
"""
switch (type.getTypeCode()) {
default:
b.loadNull();
break;
case TypeDesc.BYTE_CODE:
case TypeDesc.CHAR_CODE:
case TypeDesc.SHORT_CODE:
case TypeDesc.INT_CODE:
b.loadConstant(0);
break;
case TypeDesc.BOOLEAN_CODE:
b.loadConstant(false);
break;
case TypeDesc.LONG_CODE:
b.loadConstant(0L);
break;
case TypeDesc.FLOAT_CODE:
b.loadConstant(0.0f);
break;
case TypeDesc.DOUBLE_CODE:
b.loadConstant(0.0);
break;
}
} | java | public static void blankValue(CodeBuilder b, TypeDesc type) {
switch (type.getTypeCode()) {
default:
b.loadNull();
break;
case TypeDesc.BYTE_CODE:
case TypeDesc.CHAR_CODE:
case TypeDesc.SHORT_CODE:
case TypeDesc.INT_CODE:
b.loadConstant(0);
break;
case TypeDesc.BOOLEAN_CODE:
b.loadConstant(false);
break;
case TypeDesc.LONG_CODE:
b.loadConstant(0L);
break;
case TypeDesc.FLOAT_CODE:
b.loadConstant(0.0f);
break;
case TypeDesc.DOUBLE_CODE:
b.loadConstant(0.0);
break;
}
} | [
"public",
"static",
"void",
"blankValue",
"(",
"CodeBuilder",
"b",
",",
"TypeDesc",
"type",
")",
"{",
"switch",
"(",
"type",
".",
"getTypeCode",
"(",
")",
")",
"{",
"default",
":",
"b",
".",
"loadNull",
"(",
")",
";",
"break",
";",
"case",
"TypeDesc",
".",
"BYTE_CODE",
":",
"case",
"TypeDesc",
".",
"CHAR_CODE",
":",
"case",
"TypeDesc",
".",
"SHORT_CODE",
":",
"case",
"TypeDesc",
".",
"INT_CODE",
":",
"b",
".",
"loadConstant",
"(",
"0",
")",
";",
"break",
";",
"case",
"TypeDesc",
".",
"BOOLEAN_CODE",
":",
"b",
".",
"loadConstant",
"(",
"false",
")",
";",
"break",
";",
"case",
"TypeDesc",
".",
"LONG_CODE",
":",
"b",
".",
"loadConstant",
"(",
"0L",
")",
";",
"break",
";",
"case",
"TypeDesc",
".",
"FLOAT_CODE",
":",
"b",
".",
"loadConstant",
"(",
"0.0f",
")",
";",
"break",
";",
"case",
"TypeDesc",
".",
"DOUBLE_CODE",
":",
"b",
".",
"loadConstant",
"(",
"0.0",
")",
";",
"break",
";",
"}",
"}"
] | Generates code to push a blank value to the stack. For objects, it is
null, and for primitive types it is zero or false. | [
"Generates",
"code",
"to",
"push",
"a",
"blank",
"value",
"to",
"the",
"stack",
".",
"For",
"objects",
"it",
"is",
"null",
"and",
"for",
"primitive",
"types",
"it",
"is",
"zero",
"or",
"false",
"."
] | train | https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java#L756-L786 |
recommenders/rival | rival-evaluate/src/main/java/net/recommenders/rival/evaluation/statistics/ConfidenceInterval.java | ConfidenceInterval.getConfidenceInterval | public double[] getConfidenceInterval(final double alpha, final Map<?, Double> metricValuesPerDimension) {
"""
Method that takes only one metric as parameter. It is useful when
comparing more than two metrics (so that a confidence interval is
computed for each of them), as suggested in [Sakai, 2014]
@param alpha probability of incorrectly rejecting the null hypothesis (1
- confidence_level)
@param metricValuesPerDimension one value of the metric for each
dimension
@return array with the confidence interval: [mean - margin of error, mean
+ margin of error]
"""
SummaryStatistics differences = new SummaryStatistics();
for (Double d : metricValuesPerDimension.values()) {
differences.addValue(d);
}
return getConfidenceInterval(alpha, (int) differences.getN() - 1, (int) differences.getN(), differences.getStandardDeviation(), differences.getMean());
} | java | public double[] getConfidenceInterval(final double alpha, final Map<?, Double> metricValuesPerDimension) {
SummaryStatistics differences = new SummaryStatistics();
for (Double d : metricValuesPerDimension.values()) {
differences.addValue(d);
}
return getConfidenceInterval(alpha, (int) differences.getN() - 1, (int) differences.getN(), differences.getStandardDeviation(), differences.getMean());
} | [
"public",
"double",
"[",
"]",
"getConfidenceInterval",
"(",
"final",
"double",
"alpha",
",",
"final",
"Map",
"<",
"?",
",",
"Double",
">",
"metricValuesPerDimension",
")",
"{",
"SummaryStatistics",
"differences",
"=",
"new",
"SummaryStatistics",
"(",
")",
";",
"for",
"(",
"Double",
"d",
":",
"metricValuesPerDimension",
".",
"values",
"(",
")",
")",
"{",
"differences",
".",
"addValue",
"(",
"d",
")",
";",
"}",
"return",
"getConfidenceInterval",
"(",
"alpha",
",",
"(",
"int",
")",
"differences",
".",
"getN",
"(",
")",
"-",
"1",
",",
"(",
"int",
")",
"differences",
".",
"getN",
"(",
")",
",",
"differences",
".",
"getStandardDeviation",
"(",
")",
",",
"differences",
".",
"getMean",
"(",
")",
")",
";",
"}"
] | Method that takes only one metric as parameter. It is useful when
comparing more than two metrics (so that a confidence interval is
computed for each of them), as suggested in [Sakai, 2014]
@param alpha probability of incorrectly rejecting the null hypothesis (1
- confidence_level)
@param metricValuesPerDimension one value of the metric for each
dimension
@return array with the confidence interval: [mean - margin of error, mean
+ margin of error] | [
"Method",
"that",
"takes",
"only",
"one",
"metric",
"as",
"parameter",
".",
"It",
"is",
"useful",
"when",
"comparing",
"more",
"than",
"two",
"metrics",
"(",
"so",
"that",
"a",
"confidence",
"interval",
"is",
"computed",
"for",
"each",
"of",
"them",
")",
"as",
"suggested",
"in",
"[",
"Sakai",
"2014",
"]"
] | train | https://github.com/recommenders/rival/blob/6ee8223e91810ae1c6052899595af3906e0c34c6/rival-evaluate/src/main/java/net/recommenders/rival/evaluation/statistics/ConfidenceInterval.java#L169-L175 |
dashorst/wicket-stuff-markup-validator | jing/src/main/java/com/thaiopensource/datatype/xsd/DurationDatatype.java | DurationDatatype.computeDays | private static BigInteger computeDays(BigInteger months, int refYear, int refMonth) {
"""
Returns the number of days spanned by a period of months starting with a particular
reference year and month.
"""
switch (months.signum()) {
case 0:
return BigInteger.valueOf(0);
case -1:
return computeDays(months.negate(), refYear, refMonth).negate();
}
// Complete cycle of Gregorian calendar is 400 years
BigInteger[] tem = months.divideAndRemainder(BigInteger.valueOf(400*12));
--refMonth; // use 0 base to match Java
int total = 0;
for (int rem = tem[1].intValue(); rem > 0; rem--) {
total += daysInMonth(refYear, refMonth);
if (++refMonth == 12) {
refMonth = 0;
refYear++;
}
}
// In the Gregorian calendar, there are 97 (= 100 + 4 - 1) leap years every 400 years.
return tem[0].multiply(BigInteger.valueOf(365*400 + 97)).add(BigInteger.valueOf(total));
} | java | private static BigInteger computeDays(BigInteger months, int refYear, int refMonth) {
switch (months.signum()) {
case 0:
return BigInteger.valueOf(0);
case -1:
return computeDays(months.negate(), refYear, refMonth).negate();
}
// Complete cycle of Gregorian calendar is 400 years
BigInteger[] tem = months.divideAndRemainder(BigInteger.valueOf(400*12));
--refMonth; // use 0 base to match Java
int total = 0;
for (int rem = tem[1].intValue(); rem > 0; rem--) {
total += daysInMonth(refYear, refMonth);
if (++refMonth == 12) {
refMonth = 0;
refYear++;
}
}
// In the Gregorian calendar, there are 97 (= 100 + 4 - 1) leap years every 400 years.
return tem[0].multiply(BigInteger.valueOf(365*400 + 97)).add(BigInteger.valueOf(total));
} | [
"private",
"static",
"BigInteger",
"computeDays",
"(",
"BigInteger",
"months",
",",
"int",
"refYear",
",",
"int",
"refMonth",
")",
"{",
"switch",
"(",
"months",
".",
"signum",
"(",
")",
")",
"{",
"case",
"0",
":",
"return",
"BigInteger",
".",
"valueOf",
"(",
"0",
")",
";",
"case",
"-",
"1",
":",
"return",
"computeDays",
"(",
"months",
".",
"negate",
"(",
")",
",",
"refYear",
",",
"refMonth",
")",
".",
"negate",
"(",
")",
";",
"}",
"// Complete cycle of Gregorian calendar is 400 years",
"BigInteger",
"[",
"]",
"tem",
"=",
"months",
".",
"divideAndRemainder",
"(",
"BigInteger",
".",
"valueOf",
"(",
"400",
"*",
"12",
")",
")",
";",
"--",
"refMonth",
";",
"// use 0 base to match Java",
"int",
"total",
"=",
"0",
";",
"for",
"(",
"int",
"rem",
"=",
"tem",
"[",
"1",
"]",
".",
"intValue",
"(",
")",
";",
"rem",
">",
"0",
";",
"rem",
"--",
")",
"{",
"total",
"+=",
"daysInMonth",
"(",
"refYear",
",",
"refMonth",
")",
";",
"if",
"(",
"++",
"refMonth",
"==",
"12",
")",
"{",
"refMonth",
"=",
"0",
";",
"refYear",
"++",
";",
"}",
"}",
"// In the Gregorian calendar, there are 97 (= 100 + 4 - 1) leap years every 400 years.",
"return",
"tem",
"[",
"0",
"]",
".",
"multiply",
"(",
"BigInteger",
".",
"valueOf",
"(",
"365",
"*",
"400",
"+",
"97",
")",
")",
".",
"add",
"(",
"BigInteger",
".",
"valueOf",
"(",
"total",
")",
")",
";",
"}"
] | Returns the number of days spanned by a period of months starting with a particular
reference year and month. | [
"Returns",
"the",
"number",
"of",
"days",
"spanned",
"by",
"a",
"period",
"of",
"months",
"starting",
"with",
"a",
"particular",
"reference",
"year",
"and",
"month",
"."
] | train | https://github.com/dashorst/wicket-stuff-markup-validator/blob/9e529a4dc8bfdbbe4c794f3132ef400a006560a1/jing/src/main/java/com/thaiopensource/datatype/xsd/DurationDatatype.java#L179-L199 |
liferay/com-liferay-commerce | commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPDisplayLayoutPersistenceImpl.java | CPDisplayLayoutPersistenceImpl.findByUUID_G | @Override
public CPDisplayLayout findByUUID_G(String uuid, long groupId)
throws NoSuchCPDisplayLayoutException {
"""
Returns the cp display layout where uuid = ? and groupId = ? or throws a {@link NoSuchCPDisplayLayoutException} if it could not be found.
@param uuid the uuid
@param groupId the group ID
@return the matching cp display layout
@throws NoSuchCPDisplayLayoutException if a matching cp display layout could not be found
"""
CPDisplayLayout cpDisplayLayout = fetchByUUID_G(uuid, groupId);
if (cpDisplayLayout == null) {
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("uuid=");
msg.append(uuid);
msg.append(", groupId=");
msg.append(groupId);
msg.append("}");
if (_log.isDebugEnabled()) {
_log.debug(msg.toString());
}
throw new NoSuchCPDisplayLayoutException(msg.toString());
}
return cpDisplayLayout;
} | java | @Override
public CPDisplayLayout findByUUID_G(String uuid, long groupId)
throws NoSuchCPDisplayLayoutException {
CPDisplayLayout cpDisplayLayout = fetchByUUID_G(uuid, groupId);
if (cpDisplayLayout == null) {
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("uuid=");
msg.append(uuid);
msg.append(", groupId=");
msg.append(groupId);
msg.append("}");
if (_log.isDebugEnabled()) {
_log.debug(msg.toString());
}
throw new NoSuchCPDisplayLayoutException(msg.toString());
}
return cpDisplayLayout;
} | [
"@",
"Override",
"public",
"CPDisplayLayout",
"findByUUID_G",
"(",
"String",
"uuid",
",",
"long",
"groupId",
")",
"throws",
"NoSuchCPDisplayLayoutException",
"{",
"CPDisplayLayout",
"cpDisplayLayout",
"=",
"fetchByUUID_G",
"(",
"uuid",
",",
"groupId",
")",
";",
"if",
"(",
"cpDisplayLayout",
"==",
"null",
")",
"{",
"StringBundler",
"msg",
"=",
"new",
"StringBundler",
"(",
"6",
")",
";",
"msg",
".",
"append",
"(",
"_NO_SUCH_ENTITY_WITH_KEY",
")",
";",
"msg",
".",
"append",
"(",
"\"uuid=\"",
")",
";",
"msg",
".",
"append",
"(",
"uuid",
")",
";",
"msg",
".",
"append",
"(",
"\", groupId=\"",
")",
";",
"msg",
".",
"append",
"(",
"groupId",
")",
";",
"msg",
".",
"append",
"(",
"\"}\"",
")",
";",
"if",
"(",
"_log",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"_log",
".",
"debug",
"(",
"msg",
".",
"toString",
"(",
")",
")",
";",
"}",
"throw",
"new",
"NoSuchCPDisplayLayoutException",
"(",
"msg",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"cpDisplayLayout",
";",
"}"
] | Returns the cp display layout where uuid = ? and groupId = ? or throws a {@link NoSuchCPDisplayLayoutException} if it could not be found.
@param uuid the uuid
@param groupId the group ID
@return the matching cp display layout
@throws NoSuchCPDisplayLayoutException if a matching cp display layout could not be found | [
"Returns",
"the",
"cp",
"display",
"layout",
"where",
"uuid",
"=",
"?",
";",
"and",
"groupId",
"=",
"?",
";",
"or",
"throws",
"a",
"{",
"@link",
"NoSuchCPDisplayLayoutException",
"}",
"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/CPDisplayLayoutPersistenceImpl.java#L665-L691 |
udoprog/ffwd-client-java | src/main/java/com/google/protobuf250/CodedInputStream.java | CodedInputStream.readRawVarint32 | static int readRawVarint32(final InputStream input) throws IOException {
"""
Reads a varint from the input one byte at a time, so that it does not
read any bytes after the end of the varint. If you simply wrapped the
stream in a CodedInputStream and used {@link #readRawVarint32(InputStream)}
then you would probably end up reading past the end of the varint since
CodedInputStream buffers its input.
"""
final int firstByte = input.read();
if (firstByte == -1) {
throw InvalidProtocolBufferException.truncatedMessage();
}
return readRawVarint32(firstByte, input);
} | java | static int readRawVarint32(final InputStream input) throws IOException {
final int firstByte = input.read();
if (firstByte == -1) {
throw InvalidProtocolBufferException.truncatedMessage();
}
return readRawVarint32(firstByte, input);
} | [
"static",
"int",
"readRawVarint32",
"(",
"final",
"InputStream",
"input",
")",
"throws",
"IOException",
"{",
"final",
"int",
"firstByte",
"=",
"input",
".",
"read",
"(",
")",
";",
"if",
"(",
"firstByte",
"==",
"-",
"1",
")",
"{",
"throw",
"InvalidProtocolBufferException",
".",
"truncatedMessage",
"(",
")",
";",
"}",
"return",
"readRawVarint32",
"(",
"firstByte",
",",
"input",
")",
";",
"}"
] | Reads a varint from the input one byte at a time, so that it does not
read any bytes after the end of the varint. If you simply wrapped the
stream in a CodedInputStream and used {@link #readRawVarint32(InputStream)}
then you would probably end up reading past the end of the varint since
CodedInputStream buffers its input. | [
"Reads",
"a",
"varint",
"from",
"the",
"input",
"one",
"byte",
"at",
"a",
"time",
"so",
"that",
"it",
"does",
"not",
"read",
"any",
"bytes",
"after",
"the",
"end",
"of",
"the",
"varint",
".",
"If",
"you",
"simply",
"wrapped",
"the",
"stream",
"in",
"a",
"CodedInputStream",
"and",
"used",
"{"
] | train | https://github.com/udoprog/ffwd-client-java/blob/b4161d2b138e3edb8fa9420cc3cc653d5764cf5b/src/main/java/com/google/protobuf250/CodedInputStream.java#L413-L419 |
lessthanoptimal/ejml | main/ejml-zdense/src/org/ejml/dense/row/MatrixFeatures_ZDRM.java | MatrixFeatures_ZDRM.isZeros | public static boolean isZeros(ZMatrixD1 m , double tol ) {
"""
Checks to see all the elements in the matrix are zeros
@param m A matrix. Not modified.
@return True if all elements are zeros or false if not
"""
int length = m.getNumElements()*2;
for( int i = 0; i < length; i++ ) {
if( Math.abs(m.data[i]) > tol )
return false;
}
return true;
} | java | public static boolean isZeros(ZMatrixD1 m , double tol )
{
int length = m.getNumElements()*2;
for( int i = 0; i < length; i++ ) {
if( Math.abs(m.data[i]) > tol )
return false;
}
return true;
} | [
"public",
"static",
"boolean",
"isZeros",
"(",
"ZMatrixD1",
"m",
",",
"double",
"tol",
")",
"{",
"int",
"length",
"=",
"m",
".",
"getNumElements",
"(",
")",
"*",
"2",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"Math",
".",
"abs",
"(",
"m",
".",
"data",
"[",
"i",
"]",
")",
">",
"tol",
")",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Checks to see all the elements in the matrix are zeros
@param m A matrix. Not modified.
@return True if all elements are zeros or false if not | [
"Checks",
"to",
"see",
"all",
"the",
"elements",
"in",
"the",
"matrix",
"are",
"zeros"
] | train | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-zdense/src/org/ejml/dense/row/MatrixFeatures_ZDRM.java#L423-L432 |
ag-gipp/MathMLTools | mathml-core/src/main/java/com/formulasearchengine/mathmltools/helper/XMLHelper.java | XMLHelper.getElementB | public static Node getElementB(Node node, String xPath) throws XPathExpressionException {
"""
Helper program: Extracts the specified XPATH expression
from an XML-String.
@param node the node
@param xPath the x path
@return NodeList
@throws XPathExpressionException the x path expression exception
"""
XPathExpression expr = xpath.compile(xPath);
return getElementB(node, expr);
} | java | public static Node getElementB(Node node, String xPath) throws XPathExpressionException {
XPathExpression expr = xpath.compile(xPath);
return getElementB(node, expr);
} | [
"public",
"static",
"Node",
"getElementB",
"(",
"Node",
"node",
",",
"String",
"xPath",
")",
"throws",
"XPathExpressionException",
"{",
"XPathExpression",
"expr",
"=",
"xpath",
".",
"compile",
"(",
"xPath",
")",
";",
"return",
"getElementB",
"(",
"node",
",",
"expr",
")",
";",
"}"
] | Helper program: Extracts the specified XPATH expression
from an XML-String.
@param node the node
@param xPath the x path
@return NodeList
@throws XPathExpressionException the x path expression exception | [
"Helper",
"program",
":",
"Extracts",
"the",
"specified",
"XPATH",
"expression",
"from",
"an",
"XML",
"-",
"String",
"."
] | train | https://github.com/ag-gipp/MathMLTools/blob/77c69b6366a5b8720796d1cd9d155ba26c2f1b20/mathml-core/src/main/java/com/formulasearchengine/mathmltools/helper/XMLHelper.java#L140-L143 |
alb-i986/selenium-tinafw | src/main/java/me/alb_i986/selenium/tinafw/ui/PageHelper.java | PageHelper.hitKeys | public static void hitKeys(WebDriver driver, CharSequence keys) {
"""
Typical use is to simulate hitting ESCAPE or ENTER.
@param driver
@param keys
@see Actions#sendKeys(CharSequence...)
"""
new Actions(driver)
.sendKeys(keys)
.perform()
;
} | java | public static void hitKeys(WebDriver driver, CharSequence keys) {
new Actions(driver)
.sendKeys(keys)
.perform()
;
} | [
"public",
"static",
"void",
"hitKeys",
"(",
"WebDriver",
"driver",
",",
"CharSequence",
"keys",
")",
"{",
"new",
"Actions",
"(",
"driver",
")",
".",
"sendKeys",
"(",
"keys",
")",
".",
"perform",
"(",
")",
";",
"}"
] | Typical use is to simulate hitting ESCAPE or ENTER.
@param driver
@param keys
@see Actions#sendKeys(CharSequence...) | [
"Typical",
"use",
"is",
"to",
"simulate",
"hitting",
"ESCAPE",
"or",
"ENTER",
"."
] | train | https://github.com/alb-i986/selenium-tinafw/blob/91c66720cda9f69751f96c58c0a0624b2222186e/src/main/java/me/alb_i986/selenium/tinafw/ui/PageHelper.java#L245-L250 |
cloudant/sync-android | cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/query/QueryImpl.java | QueryImpl.listIndexes | @Override
public List<Index> listIndexes() throws QueryException {
"""
Get a list of indexes and their definitions as a Map.
Returns:
{ indexName: { type: json,
name: indexName,
fields: [field1, field2]
}
@return Map of indexes in the database.
"""
try {
return DatabaseImpl.get(dbQueue.submit(new ListIndexesCallable()));
} catch (ExecutionException e) {
String msg = "Failed to list indexes";
logger.log(Level.SEVERE, msg, e);
throw new QueryException(msg, e);
}
} | java | @Override
public List<Index> listIndexes() throws QueryException {
try {
return DatabaseImpl.get(dbQueue.submit(new ListIndexesCallable()));
} catch (ExecutionException e) {
String msg = "Failed to list indexes";
logger.log(Level.SEVERE, msg, e);
throw new QueryException(msg, e);
}
} | [
"@",
"Override",
"public",
"List",
"<",
"Index",
">",
"listIndexes",
"(",
")",
"throws",
"QueryException",
"{",
"try",
"{",
"return",
"DatabaseImpl",
".",
"get",
"(",
"dbQueue",
".",
"submit",
"(",
"new",
"ListIndexesCallable",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"ExecutionException",
"e",
")",
"{",
"String",
"msg",
"=",
"\"Failed to list indexes\"",
";",
"logger",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"msg",
",",
"e",
")",
";",
"throw",
"new",
"QueryException",
"(",
"msg",
",",
"e",
")",
";",
"}",
"}"
] | Get a list of indexes and their definitions as a Map.
Returns:
{ indexName: { type: json,
name: indexName,
fields: [field1, field2]
}
@return Map of indexes in the database. | [
"Get",
"a",
"list",
"of",
"indexes",
"and",
"their",
"definitions",
"as",
"a",
"Map",
"."
] | train | https://github.com/cloudant/sync-android/blob/5f1416ed1bd9ab05d7a4b8736480c8ae68bd7383/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/query/QueryImpl.java#L124-L134 |
graknlabs/grakn | server/src/graql/analytics/KCoreVertexProgram.java | KCoreVertexProgram.getMessageCountExcludeSelf | private static int getMessageCountExcludeSelf(Messenger<String> messenger, String id) {
"""
count the messages from relations, so need to filter its own msg
"""
Set<String> messageSet = newHashSet(messenger.receiveMessages());
messageSet.remove(id);
return messageSet.size();
} | java | private static int getMessageCountExcludeSelf(Messenger<String> messenger, String id) {
Set<String> messageSet = newHashSet(messenger.receiveMessages());
messageSet.remove(id);
return messageSet.size();
} | [
"private",
"static",
"int",
"getMessageCountExcludeSelf",
"(",
"Messenger",
"<",
"String",
">",
"messenger",
",",
"String",
"id",
")",
"{",
"Set",
"<",
"String",
">",
"messageSet",
"=",
"newHashSet",
"(",
"messenger",
".",
"receiveMessages",
"(",
")",
")",
";",
"messageSet",
".",
"remove",
"(",
"id",
")",
";",
"return",
"messageSet",
".",
"size",
"(",
")",
";",
"}"
] | count the messages from relations, so need to filter its own msg | [
"count",
"the",
"messages",
"from",
"relations",
"so",
"need",
"to",
"filter",
"its",
"own",
"msg"
] | train | https://github.com/graknlabs/grakn/blob/6aaee75ea846202474d591f8809d62028262fac5/server/src/graql/analytics/KCoreVertexProgram.java#L215-L219 |
orbisgis/h2gis | h2gis-functions/src/main/java/org/h2gis/functions/spatial/mesh/DelaunayData.java | DelaunayData.addGeometry | private void addGeometry(Geometry geom) throws IllegalArgumentException {
"""
Add a geometry to the list of points and edges used by the triangulation.
@param geom Any geometry
@throws IllegalArgumentException
"""
if(!geom.isValid()) {
throw new IllegalArgumentException("Provided geometry is not valid !");
}
if(geom instanceof GeometryCollection) {
Map<TriangulationPoint, Integer> pts = new HashMap<TriangulationPoint, Integer>(geom.getNumPoints());
List<Integer> segments = new ArrayList<Integer>(pts.size());
AtomicInteger pointsCount = new AtomicInteger(0);
PointHandler pointHandler = new PointHandler(this, pts, pointsCount);
LineStringHandler lineStringHandler = new LineStringHandler(this, pts, pointsCount, segments);
for(int geomId = 0; geomId < geom.getNumGeometries(); geomId++) {
addSimpleGeometry(geom.getGeometryN(geomId), pointHandler, lineStringHandler);
}
int[] index = new int[segments.size()];
for(int i = 0; i < index.length; i++) {
index[i] = segments.get(i);
}
// Construct final points array by reversing key,value of hash map
TriangulationPoint[] ptsArray = new TriangulationPoint[pointsCount.get()];
for(Map.Entry<TriangulationPoint, Integer> entry : pts.entrySet()) {
ptsArray[entry.getValue()] = entry.getKey();
}
pts.clear();
convertedInput = new ConstrainedPointSet(Arrays.asList(ptsArray), index);
} else {
addGeometry(geom.getFactory().createGeometryCollection(new Geometry[]{geom}));
}
} | java | private void addGeometry(Geometry geom) throws IllegalArgumentException {
if(!geom.isValid()) {
throw new IllegalArgumentException("Provided geometry is not valid !");
}
if(geom instanceof GeometryCollection) {
Map<TriangulationPoint, Integer> pts = new HashMap<TriangulationPoint, Integer>(geom.getNumPoints());
List<Integer> segments = new ArrayList<Integer>(pts.size());
AtomicInteger pointsCount = new AtomicInteger(0);
PointHandler pointHandler = new PointHandler(this, pts, pointsCount);
LineStringHandler lineStringHandler = new LineStringHandler(this, pts, pointsCount, segments);
for(int geomId = 0; geomId < geom.getNumGeometries(); geomId++) {
addSimpleGeometry(geom.getGeometryN(geomId), pointHandler, lineStringHandler);
}
int[] index = new int[segments.size()];
for(int i = 0; i < index.length; i++) {
index[i] = segments.get(i);
}
// Construct final points array by reversing key,value of hash map
TriangulationPoint[] ptsArray = new TriangulationPoint[pointsCount.get()];
for(Map.Entry<TriangulationPoint, Integer> entry : pts.entrySet()) {
ptsArray[entry.getValue()] = entry.getKey();
}
pts.clear();
convertedInput = new ConstrainedPointSet(Arrays.asList(ptsArray), index);
} else {
addGeometry(geom.getFactory().createGeometryCollection(new Geometry[]{geom}));
}
} | [
"private",
"void",
"addGeometry",
"(",
"Geometry",
"geom",
")",
"throws",
"IllegalArgumentException",
"{",
"if",
"(",
"!",
"geom",
".",
"isValid",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Provided geometry is not valid !\"",
")",
";",
"}",
"if",
"(",
"geom",
"instanceof",
"GeometryCollection",
")",
"{",
"Map",
"<",
"TriangulationPoint",
",",
"Integer",
">",
"pts",
"=",
"new",
"HashMap",
"<",
"TriangulationPoint",
",",
"Integer",
">",
"(",
"geom",
".",
"getNumPoints",
"(",
")",
")",
";",
"List",
"<",
"Integer",
">",
"segments",
"=",
"new",
"ArrayList",
"<",
"Integer",
">",
"(",
"pts",
".",
"size",
"(",
")",
")",
";",
"AtomicInteger",
"pointsCount",
"=",
"new",
"AtomicInteger",
"(",
"0",
")",
";",
"PointHandler",
"pointHandler",
"=",
"new",
"PointHandler",
"(",
"this",
",",
"pts",
",",
"pointsCount",
")",
";",
"LineStringHandler",
"lineStringHandler",
"=",
"new",
"LineStringHandler",
"(",
"this",
",",
"pts",
",",
"pointsCount",
",",
"segments",
")",
";",
"for",
"(",
"int",
"geomId",
"=",
"0",
";",
"geomId",
"<",
"geom",
".",
"getNumGeometries",
"(",
")",
";",
"geomId",
"++",
")",
"{",
"addSimpleGeometry",
"(",
"geom",
".",
"getGeometryN",
"(",
"geomId",
")",
",",
"pointHandler",
",",
"lineStringHandler",
")",
";",
"}",
"int",
"[",
"]",
"index",
"=",
"new",
"int",
"[",
"segments",
".",
"size",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"index",
".",
"length",
";",
"i",
"++",
")",
"{",
"index",
"[",
"i",
"]",
"=",
"segments",
".",
"get",
"(",
"i",
")",
";",
"}",
"// Construct final points array by reversing key,value of hash map",
"TriangulationPoint",
"[",
"]",
"ptsArray",
"=",
"new",
"TriangulationPoint",
"[",
"pointsCount",
".",
"get",
"(",
")",
"]",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"TriangulationPoint",
",",
"Integer",
">",
"entry",
":",
"pts",
".",
"entrySet",
"(",
")",
")",
"{",
"ptsArray",
"[",
"entry",
".",
"getValue",
"(",
")",
"]",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"}",
"pts",
".",
"clear",
"(",
")",
";",
"convertedInput",
"=",
"new",
"ConstrainedPointSet",
"(",
"Arrays",
".",
"asList",
"(",
"ptsArray",
")",
",",
"index",
")",
";",
"}",
"else",
"{",
"addGeometry",
"(",
"geom",
".",
"getFactory",
"(",
")",
".",
"createGeometryCollection",
"(",
"new",
"Geometry",
"[",
"]",
"{",
"geom",
"}",
")",
")",
";",
"}",
"}"
] | Add a geometry to the list of points and edges used by the triangulation.
@param geom Any geometry
@throws IllegalArgumentException | [
"Add",
"a",
"geometry",
"to",
"the",
"list",
"of",
"points",
"and",
"edges",
"used",
"by",
"the",
"triangulation",
"."
] | train | https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/mesh/DelaunayData.java#L288-L315 |
Axway/Grapes | utils/src/main/java/org/axway/grapes/utils/client/GrapesClient.java | GrapesClient.approveLicense | public void approveLicense(final String licenseId, final Boolean approve, final String user, final String password) throws GrapesCommunicationException, AuthenticationException {
"""
Approve or reject a license
@param licenseId
@param approve
@throws GrapesCommunicationException
@throws javax.naming.AuthenticationException
"""
final Client client = getClient(user, password);
final WebResource resource = client.resource(serverURL).path(RequestUtils.getLicensePath(licenseId));
final ClientResponse response = resource.queryParam(ServerAPI.APPROVED_PARAM, approve.toString()).post(ClientResponse.class);
client.destroy();
if(ClientResponse.Status.OK.getStatusCode() != response.getStatus()){
final String message = "Failed to approve license " + licenseId;
if(LOG.isErrorEnabled()) {
LOG.error(String.format(HTTP_STATUS_TEMPLATE_MSG, message, response.getStatus()));
}
throw new GrapesCommunicationException(message, response.getStatus());
}
} | java | public void approveLicense(final String licenseId, final Boolean approve, final String user, final String password) throws GrapesCommunicationException, AuthenticationException{
final Client client = getClient(user, password);
final WebResource resource = client.resource(serverURL).path(RequestUtils.getLicensePath(licenseId));
final ClientResponse response = resource.queryParam(ServerAPI.APPROVED_PARAM, approve.toString()).post(ClientResponse.class);
client.destroy();
if(ClientResponse.Status.OK.getStatusCode() != response.getStatus()){
final String message = "Failed to approve license " + licenseId;
if(LOG.isErrorEnabled()) {
LOG.error(String.format(HTTP_STATUS_TEMPLATE_MSG, message, response.getStatus()));
}
throw new GrapesCommunicationException(message, response.getStatus());
}
} | [
"public",
"void",
"approveLicense",
"(",
"final",
"String",
"licenseId",
",",
"final",
"Boolean",
"approve",
",",
"final",
"String",
"user",
",",
"final",
"String",
"password",
")",
"throws",
"GrapesCommunicationException",
",",
"AuthenticationException",
"{",
"final",
"Client",
"client",
"=",
"getClient",
"(",
"user",
",",
"password",
")",
";",
"final",
"WebResource",
"resource",
"=",
"client",
".",
"resource",
"(",
"serverURL",
")",
".",
"path",
"(",
"RequestUtils",
".",
"getLicensePath",
"(",
"licenseId",
")",
")",
";",
"final",
"ClientResponse",
"response",
"=",
"resource",
".",
"queryParam",
"(",
"ServerAPI",
".",
"APPROVED_PARAM",
",",
"approve",
".",
"toString",
"(",
")",
")",
".",
"post",
"(",
"ClientResponse",
".",
"class",
")",
";",
"client",
".",
"destroy",
"(",
")",
";",
"if",
"(",
"ClientResponse",
".",
"Status",
".",
"OK",
".",
"getStatusCode",
"(",
")",
"!=",
"response",
".",
"getStatus",
"(",
")",
")",
"{",
"final",
"String",
"message",
"=",
"\"Failed to approve license \"",
"+",
"licenseId",
";",
"if",
"(",
"LOG",
".",
"isErrorEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"error",
"(",
"String",
".",
"format",
"(",
"HTTP_STATUS_TEMPLATE_MSG",
",",
"message",
",",
"response",
".",
"getStatus",
"(",
")",
")",
")",
";",
"}",
"throw",
"new",
"GrapesCommunicationException",
"(",
"message",
",",
"response",
".",
"getStatus",
"(",
")",
")",
";",
"}",
"}"
] | Approve or reject a license
@param licenseId
@param approve
@throws GrapesCommunicationException
@throws javax.naming.AuthenticationException | [
"Approve",
"or",
"reject",
"a",
"license"
] | train | https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/utils/src/main/java/org/axway/grapes/utils/client/GrapesClient.java#L737-L750 |
katjahahn/PortEx | src/main/java/com/github/katjahahn/parser/IOUtil.java | IOUtil.readMap | public static Map<String, String[]> readMap(String filename)
throws IOException {
"""
Reads the specified file into a map. The first value is used as key. The
rest is put into a list and used as map value. Each entry is one line of
the file.
<p>
Ensures that no null value is returned.
<p>
Uses the default {@link #DEFAULT_DELIMITER}
@param filename
the name of the specification file (not the path to it)
@return a map with the first column as keys and the other columns as
values.
@throws IOException
if unable to read the specification file
"""
return readMap(filename, DEFAULT_DELIMITER);
} | java | public static Map<String, String[]> readMap(String filename)
throws IOException {
return readMap(filename, DEFAULT_DELIMITER);
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"readMap",
"(",
"String",
"filename",
")",
"throws",
"IOException",
"{",
"return",
"readMap",
"(",
"filename",
",",
"DEFAULT_DELIMITER",
")",
";",
"}"
] | Reads the specified file into a map. The first value is used as key. The
rest is put into a list and used as map value. Each entry is one line of
the file.
<p>
Ensures that no null value is returned.
<p>
Uses the default {@link #DEFAULT_DELIMITER}
@param filename
the name of the specification file (not the path to it)
@return a map with the first column as keys and the other columns as
values.
@throws IOException
if unable to read the specification file | [
"Reads",
"the",
"specified",
"file",
"into",
"a",
"map",
".",
"The",
"first",
"value",
"is",
"used",
"as",
"key",
".",
"The",
"rest",
"is",
"put",
"into",
"a",
"list",
"and",
"used",
"as",
"map",
"value",
".",
"Each",
"entry",
"is",
"one",
"line",
"of",
"the",
"file",
".",
"<p",
">",
"Ensures",
"that",
"no",
"null",
"value",
"is",
"returned",
".",
"<p",
">",
"Uses",
"the",
"default",
"{",
"@link",
"#DEFAULT_DELIMITER",
"}"
] | train | https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/IOUtil.java#L367-L370 |
VoltDB/voltdb | src/frontend/org/voltdb/jdbc/JDBC4CallableStatement.java | JDBC4CallableStatement.getDate | @Override
public Date getDate(int parameterIndex, Calendar cal) throws SQLException {
"""
Retrieves the value of the designated JDBC DATE parameter as a java.sql.Date object, using the given Calendar object to construct the date.
"""
checkClosed();
throw SQLError.noSupport();
} | java | @Override
public Date getDate(int parameterIndex, Calendar cal) throws SQLException
{
checkClosed();
throw SQLError.noSupport();
} | [
"@",
"Override",
"public",
"Date",
"getDate",
"(",
"int",
"parameterIndex",
",",
"Calendar",
"cal",
")",
"throws",
"SQLException",
"{",
"checkClosed",
"(",
")",
";",
"throw",
"SQLError",
".",
"noSupport",
"(",
")",
";",
"}"
] | Retrieves the value of the designated JDBC DATE parameter as a java.sql.Date object, using the given Calendar object to construct the date. | [
"Retrieves",
"the",
"value",
"of",
"the",
"designated",
"JDBC",
"DATE",
"parameter",
"as",
"a",
"java",
".",
"sql",
".",
"Date",
"object",
"using",
"the",
"given",
"Calendar",
"object",
"to",
"construct",
"the",
"date",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/jdbc/JDBC4CallableStatement.java#L191-L196 |
hawkular/hawkular-agent | hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/protocol/platform/OshiPlatformCache.java | OshiPlatformCache.getMetric | public Double getMetric(PlatformResourceType type, String name, ID metricToCollect) {
"""
Given a platform resource type, a name, and a metric name, this will return that metric's value,
or null if there is no resource that can be identified by the name and type.
@param type identifies the platform resource whose metric is to be collected
@param name name of the resource whose metric is to be collected
@param metricToCollect the metric to collect
@return the value of the metric, or null if there is no resource identified by the name
"""
switch (type) {
case OPERATING_SYSTEM: {
return getOperatingSystemMetric(metricToCollect);
}
case MEMORY: {
return getMemoryMetric(metricToCollect);
}
case FILE_STORE: {
return getFileStoreMetric(name, metricToCollect);
}
case PROCESSOR: {
return getProcessorMetric(name, metricToCollect);
}
case POWER_SOURCE: {
return getPowerSourceMetric(name, metricToCollect);
}
default: {
throw new IllegalArgumentException(
"Platform resource [" + type + "][" + name + "] does not have metrics");
}
}
} | java | public Double getMetric(PlatformResourceType type, String name, ID metricToCollect) {
switch (type) {
case OPERATING_SYSTEM: {
return getOperatingSystemMetric(metricToCollect);
}
case MEMORY: {
return getMemoryMetric(metricToCollect);
}
case FILE_STORE: {
return getFileStoreMetric(name, metricToCollect);
}
case PROCESSOR: {
return getProcessorMetric(name, metricToCollect);
}
case POWER_SOURCE: {
return getPowerSourceMetric(name, metricToCollect);
}
default: {
throw new IllegalArgumentException(
"Platform resource [" + type + "][" + name + "] does not have metrics");
}
}
} | [
"public",
"Double",
"getMetric",
"(",
"PlatformResourceType",
"type",
",",
"String",
"name",
",",
"ID",
"metricToCollect",
")",
"{",
"switch",
"(",
"type",
")",
"{",
"case",
"OPERATING_SYSTEM",
":",
"{",
"return",
"getOperatingSystemMetric",
"(",
"metricToCollect",
")",
";",
"}",
"case",
"MEMORY",
":",
"{",
"return",
"getMemoryMetric",
"(",
"metricToCollect",
")",
";",
"}",
"case",
"FILE_STORE",
":",
"{",
"return",
"getFileStoreMetric",
"(",
"name",
",",
"metricToCollect",
")",
";",
"}",
"case",
"PROCESSOR",
":",
"{",
"return",
"getProcessorMetric",
"(",
"name",
",",
"metricToCollect",
")",
";",
"}",
"case",
"POWER_SOURCE",
":",
"{",
"return",
"getPowerSourceMetric",
"(",
"name",
",",
"metricToCollect",
")",
";",
"}",
"default",
":",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Platform resource [\"",
"+",
"type",
"+",
"\"][\"",
"+",
"name",
"+",
"\"] does not have metrics\"",
")",
";",
"}",
"}",
"}"
] | Given a platform resource type, a name, and a metric name, this will return that metric's value,
or null if there is no resource that can be identified by the name and type.
@param type identifies the platform resource whose metric is to be collected
@param name name of the resource whose metric is to be collected
@param metricToCollect the metric to collect
@return the value of the metric, or null if there is no resource identified by the name | [
"Given",
"a",
"platform",
"resource",
"type",
"a",
"name",
"and",
"a",
"metric",
"name",
"this",
"will",
"return",
"that",
"metric",
"s",
"value",
"or",
"null",
"if",
"there",
"is",
"no",
"resource",
"that",
"can",
"be",
"identified",
"by",
"the",
"name",
"and",
"type",
"."
] | train | https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/protocol/platform/OshiPlatformCache.java#L372-L394 |
Mthwate/DatLib | src/main/java/com/mthwate/datlib/HashUtils.java | HashUtils.md2Hex | public static String md2Hex(String data, Charset charset) throws NoSuchAlgorithmException {
"""
Hashes a string using the MD2 algorithm. Returns a hexadecimal result.
@since 1.1
@param data the string to hash
@param charset the charset of the string
@return the hexadecimal MD2 hash of the string
@throws NoSuchAlgorithmException the algorithm is not supported by existing providers
"""
return md2Hex(data.getBytes(charset));
} | java | public static String md2Hex(String data, Charset charset) throws NoSuchAlgorithmException {
return md2Hex(data.getBytes(charset));
} | [
"public",
"static",
"String",
"md2Hex",
"(",
"String",
"data",
",",
"Charset",
"charset",
")",
"throws",
"NoSuchAlgorithmException",
"{",
"return",
"md2Hex",
"(",
"data",
".",
"getBytes",
"(",
"charset",
")",
")",
";",
"}"
] | Hashes a string using the MD2 algorithm. Returns a hexadecimal result.
@since 1.1
@param data the string to hash
@param charset the charset of the string
@return the hexadecimal MD2 hash of the string
@throws NoSuchAlgorithmException the algorithm is not supported by existing providers | [
"Hashes",
"a",
"string",
"using",
"the",
"MD2",
"algorithm",
".",
"Returns",
"a",
"hexadecimal",
"result",
"."
] | train | https://github.com/Mthwate/DatLib/blob/f0b3a9f9cf6fdc773d4f86234ebd95986c9b6077/src/main/java/com/mthwate/datlib/HashUtils.java#L138-L140 |
algolia/algoliasearch-client-java | src/main/java/com/algolia/search/saas/Index.java | Index.saveRule | public JSONObject saveRule(String objectID, JSONObject rule, boolean forwardToReplicas, RequestOptions requestOptions) throws AlgoliaException {
"""
Save a query rule
@param objectID the objectId of the query rule to save
@param rule the content of this query rule
@param forwardToReplicas Forward this operation to the replica indices
@param requestOptions Options to pass to this request
"""
try {
return client.putRequest("/1/indexes/" + encodedIndexName + "/rules/" + URLEncoder.encode(objectID, "UTF-8") + "?forwardToReplicas=" + forwardToReplicas, rule.toString(), requestOptions);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
} | java | public JSONObject saveRule(String objectID, JSONObject rule, boolean forwardToReplicas, RequestOptions requestOptions) throws AlgoliaException {
try {
return client.putRequest("/1/indexes/" + encodedIndexName + "/rules/" + URLEncoder.encode(objectID, "UTF-8") + "?forwardToReplicas=" + forwardToReplicas, rule.toString(), requestOptions);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
} | [
"public",
"JSONObject",
"saveRule",
"(",
"String",
"objectID",
",",
"JSONObject",
"rule",
",",
"boolean",
"forwardToReplicas",
",",
"RequestOptions",
"requestOptions",
")",
"throws",
"AlgoliaException",
"{",
"try",
"{",
"return",
"client",
".",
"putRequest",
"(",
"\"/1/indexes/\"",
"+",
"encodedIndexName",
"+",
"\"/rules/\"",
"+",
"URLEncoder",
".",
"encode",
"(",
"objectID",
",",
"\"UTF-8\"",
")",
"+",
"\"?forwardToReplicas=\"",
"+",
"forwardToReplicas",
",",
"rule",
".",
"toString",
"(",
")",
",",
"requestOptions",
")",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] | Save a query rule
@param objectID the objectId of the query rule to save
@param rule the content of this query rule
@param forwardToReplicas Forward this operation to the replica indices
@param requestOptions Options to pass to this request | [
"Save",
"a",
"query",
"rule"
] | train | https://github.com/algolia/algoliasearch-client-java/blob/a05da2f66c099fe6f77295c7b6a8a12c24e95f9b/src/main/java/com/algolia/search/saas/Index.java#L1699-L1705 |
RKumsher/utils | src/main/java/com/github/rkumsher/date/RandomDateUtils.java | RandomDateUtils.randomYear | public static Year randomYear(int startInclusive, int endExclusive) {
"""
Returns a random {@link Year} within the specified range.
@param startInclusive the earliest {@link Year} that can be returned
@param endExclusive the upper bound (not included)
@return the random {@link Year}
@throws IllegalArgumentException if endExclusive is earlier than startInclusive, if end is
before {@link RandomDateUtils#MIN_INSTANT}, or if start is after {@link
RandomDateUtils#MAX_INSTANT}
"""
checkArgument(startInclusive < MAX_YEAR, "Start must be before %s", MAX_YEAR);
checkArgument(startInclusive >= MIN_YEAR, "Start must be on or after %s", MIN_YEAR);
checkArgument(endExclusive > MIN_YEAR, "End must be after %s", MIN_YEAR);
checkArgument(endExclusive <= MAX_YEAR, "End must be on or before %s", MAX_YEAR);
checkArgument(startInclusive <= endExclusive, "End must be on or after start");
return Year.of(RandomUtils.nextInt(startInclusive, endExclusive));
} | java | public static Year randomYear(int startInclusive, int endExclusive) {
checkArgument(startInclusive < MAX_YEAR, "Start must be before %s", MAX_YEAR);
checkArgument(startInclusive >= MIN_YEAR, "Start must be on or after %s", MIN_YEAR);
checkArgument(endExclusive > MIN_YEAR, "End must be after %s", MIN_YEAR);
checkArgument(endExclusive <= MAX_YEAR, "End must be on or before %s", MAX_YEAR);
checkArgument(startInclusive <= endExclusive, "End must be on or after start");
return Year.of(RandomUtils.nextInt(startInclusive, endExclusive));
} | [
"public",
"static",
"Year",
"randomYear",
"(",
"int",
"startInclusive",
",",
"int",
"endExclusive",
")",
"{",
"checkArgument",
"(",
"startInclusive",
"<",
"MAX_YEAR",
",",
"\"Start must be before %s\"",
",",
"MAX_YEAR",
")",
";",
"checkArgument",
"(",
"startInclusive",
">=",
"MIN_YEAR",
",",
"\"Start must be on or after %s\"",
",",
"MIN_YEAR",
")",
";",
"checkArgument",
"(",
"endExclusive",
">",
"MIN_YEAR",
",",
"\"End must be after %s\"",
",",
"MIN_YEAR",
")",
";",
"checkArgument",
"(",
"endExclusive",
"<=",
"MAX_YEAR",
",",
"\"End must be on or before %s\"",
",",
"MAX_YEAR",
")",
";",
"checkArgument",
"(",
"startInclusive",
"<=",
"endExclusive",
",",
"\"End must be on or after start\"",
")",
";",
"return",
"Year",
".",
"of",
"(",
"RandomUtils",
".",
"nextInt",
"(",
"startInclusive",
",",
"endExclusive",
")",
")",
";",
"}"
] | Returns a random {@link Year} within the specified range.
@param startInclusive the earliest {@link Year} that can be returned
@param endExclusive the upper bound (not included)
@return the random {@link Year}
@throws IllegalArgumentException if endExclusive is earlier than startInclusive, if end is
before {@link RandomDateUtils#MIN_INSTANT}, or if start is after {@link
RandomDateUtils#MAX_INSTANT} | [
"Returns",
"a",
"random",
"{",
"@link",
"Year",
"}",
"within",
"the",
"specified",
"range",
"."
] | train | https://github.com/RKumsher/utils/blob/fcdb190569cd0288249bf4b46fd418f8c01d1caf/src/main/java/com/github/rkumsher/date/RandomDateUtils.java#L895-L902 |
khuxtable/seaglass | src/main/java/com/seaglasslookandfeel/SeaGlassSynthPainterImpl.java | SeaGlassSynthPainterImpl.paintBackground | private void paintBackground(SynthContext ctx, Graphics g, int x, int y, int w, int h, int orientation) {
"""
Paint the object's background.
@param ctx the SynthContext.
@param g the Graphics context.
@param x the x location corresponding to the upper-left
coordinate to paint.
@param y the y location corresponding to the upper left
coordinate to paint.
@param w the width to paint.
@param h the height to paint.
@param orientation the component's orientation, used to construct an
affine transform.
"""
Component c = ctx.getComponent();
boolean ltr = c.getComponentOrientation().isLeftToRight();
// Don't RTL flip JSpliders as they handle it internaly
if (ctx.getComponent() instanceof JSlider)
ltr = true;
if (orientation == SwingConstants.VERTICAL && ltr) {
AffineTransform transform = new AffineTransform();
transform.scale(-1, 1);
transform.rotate(Math.toRadians(90));
paintBackground(ctx, g, y, x, h, w, transform);
} else if (orientation == SwingConstants.VERTICAL) {
AffineTransform transform = new AffineTransform();
transform.rotate(Math.toRadians(90));
transform.translate(0, -(x + w));
paintBackground(ctx, g, y, x, h, w, transform);
} else if (orientation == SwingConstants.HORIZONTAL && ltr) {
paintBackground(ctx, g, x, y, w, h, null);
} else {
// horizontal and right-to-left orientation
AffineTransform transform = new AffineTransform();
transform.translate(x, y);
transform.scale(-1, 1);
transform.translate(-w, 0);
paintBackground(ctx, g, 0, 0, w, h, transform);
}
} | java | private void paintBackground(SynthContext ctx, Graphics g, int x, int y, int w, int h, int orientation) {
Component c = ctx.getComponent();
boolean ltr = c.getComponentOrientation().isLeftToRight();
// Don't RTL flip JSpliders as they handle it internaly
if (ctx.getComponent() instanceof JSlider)
ltr = true;
if (orientation == SwingConstants.VERTICAL && ltr) {
AffineTransform transform = new AffineTransform();
transform.scale(-1, 1);
transform.rotate(Math.toRadians(90));
paintBackground(ctx, g, y, x, h, w, transform);
} else if (orientation == SwingConstants.VERTICAL) {
AffineTransform transform = new AffineTransform();
transform.rotate(Math.toRadians(90));
transform.translate(0, -(x + w));
paintBackground(ctx, g, y, x, h, w, transform);
} else if (orientation == SwingConstants.HORIZONTAL && ltr) {
paintBackground(ctx, g, x, y, w, h, null);
} else {
// horizontal and right-to-left orientation
AffineTransform transform = new AffineTransform();
transform.translate(x, y);
transform.scale(-1, 1);
transform.translate(-w, 0);
paintBackground(ctx, g, 0, 0, w, h, transform);
}
} | [
"private",
"void",
"paintBackground",
"(",
"SynthContext",
"ctx",
",",
"Graphics",
"g",
",",
"int",
"x",
",",
"int",
"y",
",",
"int",
"w",
",",
"int",
"h",
",",
"int",
"orientation",
")",
"{",
"Component",
"c",
"=",
"ctx",
".",
"getComponent",
"(",
")",
";",
"boolean",
"ltr",
"=",
"c",
".",
"getComponentOrientation",
"(",
")",
".",
"isLeftToRight",
"(",
")",
";",
"// Don't RTL flip JSpliders as they handle it internaly",
"if",
"(",
"ctx",
".",
"getComponent",
"(",
")",
"instanceof",
"JSlider",
")",
"ltr",
"=",
"true",
";",
"if",
"(",
"orientation",
"==",
"SwingConstants",
".",
"VERTICAL",
"&&",
"ltr",
")",
"{",
"AffineTransform",
"transform",
"=",
"new",
"AffineTransform",
"(",
")",
";",
"transform",
".",
"scale",
"(",
"-",
"1",
",",
"1",
")",
";",
"transform",
".",
"rotate",
"(",
"Math",
".",
"toRadians",
"(",
"90",
")",
")",
";",
"paintBackground",
"(",
"ctx",
",",
"g",
",",
"y",
",",
"x",
",",
"h",
",",
"w",
",",
"transform",
")",
";",
"}",
"else",
"if",
"(",
"orientation",
"==",
"SwingConstants",
".",
"VERTICAL",
")",
"{",
"AffineTransform",
"transform",
"=",
"new",
"AffineTransform",
"(",
")",
";",
"transform",
".",
"rotate",
"(",
"Math",
".",
"toRadians",
"(",
"90",
")",
")",
";",
"transform",
".",
"translate",
"(",
"0",
",",
"-",
"(",
"x",
"+",
"w",
")",
")",
";",
"paintBackground",
"(",
"ctx",
",",
"g",
",",
"y",
",",
"x",
",",
"h",
",",
"w",
",",
"transform",
")",
";",
"}",
"else",
"if",
"(",
"orientation",
"==",
"SwingConstants",
".",
"HORIZONTAL",
"&&",
"ltr",
")",
"{",
"paintBackground",
"(",
"ctx",
",",
"g",
",",
"x",
",",
"y",
",",
"w",
",",
"h",
",",
"null",
")",
";",
"}",
"else",
"{",
"// horizontal and right-to-left orientation",
"AffineTransform",
"transform",
"=",
"new",
"AffineTransform",
"(",
")",
";",
"transform",
".",
"translate",
"(",
"x",
",",
"y",
")",
";",
"transform",
".",
"scale",
"(",
"-",
"1",
",",
"1",
")",
";",
"transform",
".",
"translate",
"(",
"-",
"w",
",",
"0",
")",
";",
"paintBackground",
"(",
"ctx",
",",
"g",
",",
"0",
",",
"0",
",",
"w",
",",
"h",
",",
"transform",
")",
";",
"}",
"}"
] | Paint the object's background.
@param ctx the SynthContext.
@param g the Graphics context.
@param x the x location corresponding to the upper-left
coordinate to paint.
@param y the y location corresponding to the upper left
coordinate to paint.
@param w the width to paint.
@param h the height to paint.
@param orientation the component's orientation, used to construct an
affine transform. | [
"Paint",
"the",
"object",
"s",
"background",
"."
] | train | https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/SeaGlassSynthPainterImpl.java#L208-L240 |
alkacon/opencms-core | src-modules/org/opencms/workplace/tools/searchindex/CmsHookListSearchCategory.java | CmsHookListSearchCategory.onGetCall | @Override
protected void onGetCall(Object peer, int index) {
"""
Set the search page of the peer Object
(<code>{@link org.opencms.search.CmsSearch#setSearchPage(int)}</code>)
to zero if the internal backup list of categories (taken at clear time which
is triggered by <code>{@link org.opencms.workplace.CmsWidgetDialog#ACTION_SAVE}</code>)
was empty (no restriction) and now categories are contained or if the new
backup list of categories is no subset of the current categories any
more (more restrictive search than before). <p>
@see org.opencms.workplace.tools.searchindex.CmsHookList#onGetCall(java.lang.Object, int)
"""
// zero categories are all (first condition)
if (((m_backupCategories.size() == 0) && (size() != 0)) || !(containsAll(m_backupCategories))) {
((CmsSearchParameters)peer).setSearchPage(1);
}
} | java | @Override
protected void onGetCall(Object peer, int index) {
// zero categories are all (first condition)
if (((m_backupCategories.size() == 0) && (size() != 0)) || !(containsAll(m_backupCategories))) {
((CmsSearchParameters)peer).setSearchPage(1);
}
} | [
"@",
"Override",
"protected",
"void",
"onGetCall",
"(",
"Object",
"peer",
",",
"int",
"index",
")",
"{",
"// zero categories are all (first condition)",
"if",
"(",
"(",
"(",
"m_backupCategories",
".",
"size",
"(",
")",
"==",
"0",
")",
"&&",
"(",
"size",
"(",
")",
"!=",
"0",
")",
")",
"||",
"!",
"(",
"containsAll",
"(",
"m_backupCategories",
")",
")",
")",
"{",
"(",
"(",
"CmsSearchParameters",
")",
"peer",
")",
".",
"setSearchPage",
"(",
"1",
")",
";",
"}",
"}"
] | Set the search page of the peer Object
(<code>{@link org.opencms.search.CmsSearch#setSearchPage(int)}</code>)
to zero if the internal backup list of categories (taken at clear time which
is triggered by <code>{@link org.opencms.workplace.CmsWidgetDialog#ACTION_SAVE}</code>)
was empty (no restriction) and now categories are contained or if the new
backup list of categories is no subset of the current categories any
more (more restrictive search than before). <p>
@see org.opencms.workplace.tools.searchindex.CmsHookList#onGetCall(java.lang.Object, int) | [
"Set",
"the",
"search",
"page",
"of",
"the",
"peer",
"Object",
"(",
"<code",
">",
"{",
"@link",
"org",
".",
"opencms",
".",
"search",
".",
"CmsSearch#setSearchPage",
"(",
"int",
")",
"}",
"<",
"/",
"code",
">",
")",
"to",
"zero",
"if",
"the",
"internal",
"backup",
"list",
"of",
"categories",
"(",
"taken",
"at",
"clear",
"time",
"which",
"is",
"triggered",
"by",
"<code",
">",
"{",
"@link",
"org",
".",
"opencms",
".",
"workplace",
".",
"CmsWidgetDialog#ACTION_SAVE",
"}",
"<",
"/",
"code",
">",
")",
"was",
"empty",
"(",
"no",
"restriction",
")",
"and",
"now",
"categories",
"are",
"contained",
"or",
"if",
"the",
"new",
"backup",
"list",
"of",
"categories",
"is",
"no",
"subset",
"of",
"the",
"current",
"categories",
"any",
"more",
"(",
"more",
"restrictive",
"search",
"than",
"before",
")",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-modules/org/opencms/workplace/tools/searchindex/CmsHookListSearchCategory.java#L155-L162 |
sd4324530/fastweixin | src/main/java/com/github/sd4324530/fastweixin/servlet/WeixinControllerSupport.java | WeixinControllerSupport.process | @RequestMapping(method = RequestMethod.POST)
protected final void process(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
"""
微信消息交互处理
@param request http 请求对象
@param response http 响应对象
@throws ServletException 异常
@throws IOException IO异常
"""
if (isLegal(request)) {
String result = processRequest(request);
//设置正确的 content-type 以防止中文乱码
response.setContentType("text/xml;charset=UTF-8");
PrintWriter writer = response.getWriter();
writer.write(result);
writer.close();
}
} | java | @RequestMapping(method = RequestMethod.POST)
protected final void process(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (isLegal(request)) {
String result = processRequest(request);
//设置正确的 content-type 以防止中文乱码
response.setContentType("text/xml;charset=UTF-8");
PrintWriter writer = response.getWriter();
writer.write(result);
writer.close();
}
} | [
"@",
"RequestMapping",
"(",
"method",
"=",
"RequestMethod",
".",
"POST",
")",
"protected",
"final",
"void",
"process",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
")",
"throws",
"ServletException",
",",
"IOException",
"{",
"if",
"(",
"isLegal",
"(",
"request",
")",
")",
"{",
"String",
"result",
"=",
"processRequest",
"(",
"request",
")",
";",
"//设置正确的 content-type 以防止中文乱码",
"response",
".",
"setContentType",
"(",
"\"text/xml;charset=UTF-8\"",
")",
";",
"PrintWriter",
"writer",
"=",
"response",
".",
"getWriter",
"(",
")",
";",
"writer",
".",
"write",
"(",
"result",
")",
";",
"writer",
".",
"close",
"(",
")",
";",
"}",
"}"
] | 微信消息交互处理
@param request http 请求对象
@param response http 响应对象
@throws ServletException 异常
@throws IOException IO异常 | [
"微信消息交互处理"
] | train | https://github.com/sd4324530/fastweixin/blob/6bc0a7abfa23aad0dbad4c3123a47a7fb53f3447/src/main/java/com/github/sd4324530/fastweixin/servlet/WeixinControllerSupport.java#L49-L59 |
hypercube1024/firefly | firefly-db/src/main/java/com/firefly/db/jdbc/helper/DefaultBeanProcessor.java | DefaultBeanProcessor.createBean | private <T> T createBean(ResultSet rs, Class<T> type,
PropertyDescriptor[] props, int[] columnToProperty)
throws SQLException {
"""
Creates a new object and initializes its fields from the ResultSet.
@param <T> The type of bean to create
@param rs The result set.
@param type The bean type (the return type of the object).
@param props The property descriptors.
@param columnToProperty The column indices in the result set.
@return An initialized object.
@throws SQLException if a database error occurs.
"""
T bean = this.newInstance(type);
return populateBean(rs, bean, props, columnToProperty);
} | java | private <T> T createBean(ResultSet rs, Class<T> type,
PropertyDescriptor[] props, int[] columnToProperty)
throws SQLException {
T bean = this.newInstance(type);
return populateBean(rs, bean, props, columnToProperty);
} | [
"private",
"<",
"T",
">",
"T",
"createBean",
"(",
"ResultSet",
"rs",
",",
"Class",
"<",
"T",
">",
"type",
",",
"PropertyDescriptor",
"[",
"]",
"props",
",",
"int",
"[",
"]",
"columnToProperty",
")",
"throws",
"SQLException",
"{",
"T",
"bean",
"=",
"this",
".",
"newInstance",
"(",
"type",
")",
";",
"return",
"populateBean",
"(",
"rs",
",",
"bean",
",",
"props",
",",
"columnToProperty",
")",
";",
"}"
] | Creates a new object and initializes its fields from the ResultSet.
@param <T> The type of bean to create
@param rs The result set.
@param type The bean type (the return type of the object).
@param props The property descriptors.
@param columnToProperty The column indices in the result set.
@return An initialized object.
@throws SQLException if a database error occurs. | [
"Creates",
"a",
"new",
"object",
"and",
"initializes",
"its",
"fields",
"from",
"the",
"ResultSet",
"."
] | train | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-db/src/main/java/com/firefly/db/jdbc/helper/DefaultBeanProcessor.java#L93-L99 |
googleapis/cloud-bigtable-client | bigtable-client-core-parent/bigtable-client-core/src/main/java/com/google/cloud/bigtable/grpc/BigtableSession.java | BigtableSession.createChannelPool | protected ManagedChannel createChannelPool(final ChannelPool.ChannelFactory channelFactory, int count)
throws IOException {
"""
Create a new {@link com.google.cloud.bigtable.grpc.io.ChannelPool}, with auth headers. This
method allows users to override the default implementation with their own.
@param channelFactory a {@link ChannelPool.ChannelFactory} object.
@param count The number of channels in the pool.
@return a {@link com.google.cloud.bigtable.grpc.io.ChannelPool} object.
@throws java.io.IOException if any.
"""
return new ChannelPool(channelFactory, count);
} | java | protected ManagedChannel createChannelPool(final ChannelPool.ChannelFactory channelFactory, int count)
throws IOException {
return new ChannelPool(channelFactory, count);
} | [
"protected",
"ManagedChannel",
"createChannelPool",
"(",
"final",
"ChannelPool",
".",
"ChannelFactory",
"channelFactory",
",",
"int",
"count",
")",
"throws",
"IOException",
"{",
"return",
"new",
"ChannelPool",
"(",
"channelFactory",
",",
"count",
")",
";",
"}"
] | Create a new {@link com.google.cloud.bigtable.grpc.io.ChannelPool}, with auth headers. This
method allows users to override the default implementation with their own.
@param channelFactory a {@link ChannelPool.ChannelFactory} object.
@param count The number of channels in the pool.
@return a {@link com.google.cloud.bigtable.grpc.io.ChannelPool} object.
@throws java.io.IOException if any. | [
"Create",
"a",
"new",
"{",
"@link",
"com",
".",
"google",
".",
"cloud",
".",
"bigtable",
".",
"grpc",
".",
"io",
".",
"ChannelPool",
"}",
"with",
"auth",
"headers",
".",
"This",
"method",
"allows",
"users",
"to",
"override",
"the",
"default",
"implementation",
"with",
"their",
"own",
"."
] | train | https://github.com/googleapis/cloud-bigtable-client/blob/53543f36e4d6f9ed1963640d91a35be2a2047656/bigtable-client-core-parent/bigtable-client-core/src/main/java/com/google/cloud/bigtable/grpc/BigtableSession.java#L520-L523 |
atomix/atomix | cluster/src/main/java/io/atomix/cluster/MulticastConfig.java | MulticastConfig.setGroup | public MulticastConfig setGroup(String group) {
"""
Sets the multicast group.
@param group the multicast group
@return the multicast configuration
@throws ConfigurationException if the group is invalid
"""
try {
InetAddress address = InetAddress.getByName(group);
if (!address.isMulticastAddress()) {
throw new ConfigurationException("Invalid multicast group " + group);
}
return setGroup(address);
} catch (UnknownHostException e) {
throw new ConfigurationException("Failed to locate multicast group", e);
}
} | java | public MulticastConfig setGroup(String group) {
try {
InetAddress address = InetAddress.getByName(group);
if (!address.isMulticastAddress()) {
throw new ConfigurationException("Invalid multicast group " + group);
}
return setGroup(address);
} catch (UnknownHostException e) {
throw new ConfigurationException("Failed to locate multicast group", e);
}
} | [
"public",
"MulticastConfig",
"setGroup",
"(",
"String",
"group",
")",
"{",
"try",
"{",
"InetAddress",
"address",
"=",
"InetAddress",
".",
"getByName",
"(",
"group",
")",
";",
"if",
"(",
"!",
"address",
".",
"isMulticastAddress",
"(",
")",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"\"Invalid multicast group \"",
"+",
"group",
")",
";",
"}",
"return",
"setGroup",
"(",
"address",
")",
";",
"}",
"catch",
"(",
"UnknownHostException",
"e",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"\"Failed to locate multicast group\"",
",",
"e",
")",
";",
"}",
"}"
] | Sets the multicast group.
@param group the multicast group
@return the multicast configuration
@throws ConfigurationException if the group is invalid | [
"Sets",
"the",
"multicast",
"group",
"."
] | train | https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/cluster/src/main/java/io/atomix/cluster/MulticastConfig.java#L81-L91 |
mabe02/lanterna | src/main/java/com/googlecode/lanterna/gui2/dialogs/ListSelectDialog.java | ListSelectDialog.showDialog | public static <T> T showDialog(WindowBasedTextGUI textGUI, String title, String description, int listBoxHeight, T... items) {
"""
Shortcut for quickly creating a new dialog
@param textGUI Text GUI to add the dialog to
@param title Title of the dialog
@param description Description of the dialog
@param listBoxHeight Maximum height of the list box, scrollbars will be used if there are more items
@param items Items in the dialog
@param <T> Type of items in the dialog
@return The selected item or {@code null} if cancelled
"""
int width = 0;
for(T item: items) {
width = Math.max(width, TerminalTextUtils.getColumnWidth(item.toString()));
}
width += 2;
return showDialog(textGUI, title, description, new TerminalSize(width, listBoxHeight), items);
} | java | public static <T> T showDialog(WindowBasedTextGUI textGUI, String title, String description, int listBoxHeight, T... items) {
int width = 0;
for(T item: items) {
width = Math.max(width, TerminalTextUtils.getColumnWidth(item.toString()));
}
width += 2;
return showDialog(textGUI, title, description, new TerminalSize(width, listBoxHeight), items);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"showDialog",
"(",
"WindowBasedTextGUI",
"textGUI",
",",
"String",
"title",
",",
"String",
"description",
",",
"int",
"listBoxHeight",
",",
"T",
"...",
"items",
")",
"{",
"int",
"width",
"=",
"0",
";",
"for",
"(",
"T",
"item",
":",
"items",
")",
"{",
"width",
"=",
"Math",
".",
"max",
"(",
"width",
",",
"TerminalTextUtils",
".",
"getColumnWidth",
"(",
"item",
".",
"toString",
"(",
")",
")",
")",
";",
"}",
"width",
"+=",
"2",
";",
"return",
"showDialog",
"(",
"textGUI",
",",
"title",
",",
"description",
",",
"new",
"TerminalSize",
"(",
"width",
",",
"listBoxHeight",
")",
",",
"items",
")",
";",
"}"
] | Shortcut for quickly creating a new dialog
@param textGUI Text GUI to add the dialog to
@param title Title of the dialog
@param description Description of the dialog
@param listBoxHeight Maximum height of the list box, scrollbars will be used if there are more items
@param items Items in the dialog
@param <T> Type of items in the dialog
@return The selected item or {@code null} if cancelled | [
"Shortcut",
"for",
"quickly",
"creating",
"a",
"new",
"dialog"
] | train | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/gui2/dialogs/ListSelectDialog.java#L142-L149 |
spotbugs/spotbugs | eclipsePlugin/src/de/tobject/findbugs/reporter/JdtUtils.java | JdtUtils.sortAnonymous | private static void sortAnonymous(List<IType> anonymous, IType anonType) {
"""
Sort given anonymous classes in order like java compiler would generate
output classes, in context of given anonymous type
@param anonymous
"""
SourceOffsetComparator sourceComparator = new SourceOffsetComparator();
final AnonymClassComparator classComparator = new AnonymClassComparator(anonType, sourceComparator);
Collections.sort(anonymous, classComparator);
// if (Reporter.DEBUG) {
// debugCompilePrio(classComparator);
// }
} | java | private static void sortAnonymous(List<IType> anonymous, IType anonType) {
SourceOffsetComparator sourceComparator = new SourceOffsetComparator();
final AnonymClassComparator classComparator = new AnonymClassComparator(anonType, sourceComparator);
Collections.sort(anonymous, classComparator);
// if (Reporter.DEBUG) {
// debugCompilePrio(classComparator);
// }
} | [
"private",
"static",
"void",
"sortAnonymous",
"(",
"List",
"<",
"IType",
">",
"anonymous",
",",
"IType",
"anonType",
")",
"{",
"SourceOffsetComparator",
"sourceComparator",
"=",
"new",
"SourceOffsetComparator",
"(",
")",
";",
"final",
"AnonymClassComparator",
"classComparator",
"=",
"new",
"AnonymClassComparator",
"(",
"anonType",
",",
"sourceComparator",
")",
";",
"Collections",
".",
"sort",
"(",
"anonymous",
",",
"classComparator",
")",
";",
"// if (Reporter.DEBUG) {",
"// debugCompilePrio(classComparator);",
"// }",
"}"
] | Sort given anonymous classes in order like java compiler would generate
output classes, in context of given anonymous type
@param anonymous | [
"Sort",
"given",
"anonymous",
"classes",
"in",
"order",
"like",
"java",
"compiler",
"would",
"generate",
"output",
"classes",
"in",
"context",
"of",
"given",
"anonymous",
"type"
] | train | https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/de/tobject/findbugs/reporter/JdtUtils.java#L333-L342 |
Stratio/stratio-cassandra | src/java/org/apache/cassandra/repair/RepairJob.java | RepairJob.submitDifferencers | public void submitDifferencers() {
"""
Submit differencers for running.
All tree *must* have been received before this is called.
"""
assert !failed;
List<Differencer> differencers = new ArrayList<>();
// We need to difference all trees one against another
for (int i = 0; i < trees.size() - 1; ++i)
{
TreeResponse r1 = trees.get(i);
for (int j = i + 1; j < trees.size(); ++j)
{
TreeResponse r2 = trees.get(j);
Differencer differencer = new Differencer(desc, r1, r2);
differencers.add(differencer);
logger.debug("Queueing comparison {}", differencer);
}
}
waitForSync = new AtomicInteger(differencers.size());
for (Differencer differencer : differencers)
taskExecutor.submit(differencer);
trees.clear(); // allows gc to do its thing
} | java | public void submitDifferencers()
{
assert !failed;
List<Differencer> differencers = new ArrayList<>();
// We need to difference all trees one against another
for (int i = 0; i < trees.size() - 1; ++i)
{
TreeResponse r1 = trees.get(i);
for (int j = i + 1; j < trees.size(); ++j)
{
TreeResponse r2 = trees.get(j);
Differencer differencer = new Differencer(desc, r1, r2);
differencers.add(differencer);
logger.debug("Queueing comparison {}", differencer);
}
}
waitForSync = new AtomicInteger(differencers.size());
for (Differencer differencer : differencers)
taskExecutor.submit(differencer);
trees.clear(); // allows gc to do its thing
} | [
"public",
"void",
"submitDifferencers",
"(",
")",
"{",
"assert",
"!",
"failed",
";",
"List",
"<",
"Differencer",
">",
"differencers",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"// We need to difference all trees one against another",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"trees",
".",
"size",
"(",
")",
"-",
"1",
";",
"++",
"i",
")",
"{",
"TreeResponse",
"r1",
"=",
"trees",
".",
"get",
"(",
"i",
")",
";",
"for",
"(",
"int",
"j",
"=",
"i",
"+",
"1",
";",
"j",
"<",
"trees",
".",
"size",
"(",
")",
";",
"++",
"j",
")",
"{",
"TreeResponse",
"r2",
"=",
"trees",
".",
"get",
"(",
"j",
")",
";",
"Differencer",
"differencer",
"=",
"new",
"Differencer",
"(",
"desc",
",",
"r1",
",",
"r2",
")",
";",
"differencers",
".",
"add",
"(",
"differencer",
")",
";",
"logger",
".",
"debug",
"(",
"\"Queueing comparison {}\"",
",",
"differencer",
")",
";",
"}",
"}",
"waitForSync",
"=",
"new",
"AtomicInteger",
"(",
"differencers",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"Differencer",
"differencer",
":",
"differencers",
")",
"taskExecutor",
".",
"submit",
"(",
"differencer",
")",
";",
"trees",
".",
"clear",
"(",
")",
";",
"// allows gc to do its thing",
"}"
] | Submit differencers for running.
All tree *must* have been received before this is called. | [
"Submit",
"differencers",
"for",
"running",
".",
"All",
"tree",
"*",
"must",
"*",
"have",
"been",
"received",
"before",
"this",
"is",
"called",
"."
] | train | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/repair/RepairJob.java#L201-L222 |
joniles/mpxj | src/main/java/net/sf/mpxj/mpp/FieldMap.java | FieldMap.populateContainer | public void populateContainer(Class<? extends FieldType> type, FieldContainer container, Integer id, byte[][] fixedData, Var2Data varData) {
"""
Given a container, and a set of raw data blocks, this method extracts
the field data and writes it into the container.
@param type expected type
@param container field container
@param id entity ID
@param fixedData fixed data block
@param varData var data block
"""
//System.out.println(container.getClass().getSimpleName()+": " + id);
for (FieldItem item : m_map.values())
{
if (item.getType().getClass().equals(type))
{
//System.out.println(item.m_type);
Object value = item.read(id, fixedData, varData);
//System.out.println(item.m_type.getClass().getSimpleName() + "." + item.m_type + ": " + value);
container.set(item.getType(), value);
}
}
} | java | public void populateContainer(Class<? extends FieldType> type, FieldContainer container, Integer id, byte[][] fixedData, Var2Data varData)
{
//System.out.println(container.getClass().getSimpleName()+": " + id);
for (FieldItem item : m_map.values())
{
if (item.getType().getClass().equals(type))
{
//System.out.println(item.m_type);
Object value = item.read(id, fixedData, varData);
//System.out.println(item.m_type.getClass().getSimpleName() + "." + item.m_type + ": " + value);
container.set(item.getType(), value);
}
}
} | [
"public",
"void",
"populateContainer",
"(",
"Class",
"<",
"?",
"extends",
"FieldType",
">",
"type",
",",
"FieldContainer",
"container",
",",
"Integer",
"id",
",",
"byte",
"[",
"]",
"[",
"]",
"fixedData",
",",
"Var2Data",
"varData",
")",
"{",
"//System.out.println(container.getClass().getSimpleName()+\": \" + id);",
"for",
"(",
"FieldItem",
"item",
":",
"m_map",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"item",
".",
"getType",
"(",
")",
".",
"getClass",
"(",
")",
".",
"equals",
"(",
"type",
")",
")",
"{",
"//System.out.println(item.m_type);",
"Object",
"value",
"=",
"item",
".",
"read",
"(",
"id",
",",
"fixedData",
",",
"varData",
")",
";",
"//System.out.println(item.m_type.getClass().getSimpleName() + \".\" + item.m_type + \": \" + value);",
"container",
".",
"set",
"(",
"item",
".",
"getType",
"(",
")",
",",
"value",
")",
";",
"}",
"}",
"}"
] | Given a container, and a set of raw data blocks, this method extracts
the field data and writes it into the container.
@param type expected type
@param container field container
@param id entity ID
@param fixedData fixed data block
@param varData var data block | [
"Given",
"a",
"container",
"and",
"a",
"set",
"of",
"raw",
"data",
"blocks",
"this",
"method",
"extracts",
"the",
"field",
"data",
"and",
"writes",
"it",
"into",
"the",
"container",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/FieldMap.java#L430-L443 |
Kickflip/kickflip-android-sdk | sdk/src/main/java/io/kickflip/sdk/api/KickflipApiClient.java | KickflipApiClient.loginUser | public void loginUser(String username, final String password, final KickflipCallback cb) {
"""
Login an exiting Kickflip User and make it active.
@param username The Kickflip user's username
@param password The Kickflip user's password
@param cb This callback will receive a User in {@link io.kickflip.sdk.api.KickflipCallback#onSuccess(io.kickflip.sdk.api.json.Response)}
or an Exception {@link io.kickflip.sdk.api.KickflipCallback#onError(io.kickflip.sdk.exception.KickflipException)}.
"""
GenericData data = new GenericData();
data.put("username", username);
data.put("password", password);
post(GET_USER_PRIVATE, new UrlEncodedContent(data), User.class, new KickflipCallback() {
@Override
public void onSuccess(final Response response) {
if (VERBOSE)
Log.i(TAG, "loginUser response: " + response);
storeNewUserResponse((User) response, password);
postResponseToCallback(cb, response);
}
@Override
public void onError(final KickflipException error) {
Log.w(TAG, "loginUser Error: " + error);
postExceptionToCallback(cb, error);
}
});
} | java | public void loginUser(String username, final String password, final KickflipCallback cb) {
GenericData data = new GenericData();
data.put("username", username);
data.put("password", password);
post(GET_USER_PRIVATE, new UrlEncodedContent(data), User.class, new KickflipCallback() {
@Override
public void onSuccess(final Response response) {
if (VERBOSE)
Log.i(TAG, "loginUser response: " + response);
storeNewUserResponse((User) response, password);
postResponseToCallback(cb, response);
}
@Override
public void onError(final KickflipException error) {
Log.w(TAG, "loginUser Error: " + error);
postExceptionToCallback(cb, error);
}
});
} | [
"public",
"void",
"loginUser",
"(",
"String",
"username",
",",
"final",
"String",
"password",
",",
"final",
"KickflipCallback",
"cb",
")",
"{",
"GenericData",
"data",
"=",
"new",
"GenericData",
"(",
")",
";",
"data",
".",
"put",
"(",
"\"username\"",
",",
"username",
")",
";",
"data",
".",
"put",
"(",
"\"password\"",
",",
"password",
")",
";",
"post",
"(",
"GET_USER_PRIVATE",
",",
"new",
"UrlEncodedContent",
"(",
"data",
")",
",",
"User",
".",
"class",
",",
"new",
"KickflipCallback",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onSuccess",
"(",
"final",
"Response",
"response",
")",
"{",
"if",
"(",
"VERBOSE",
")",
"Log",
".",
"i",
"(",
"TAG",
",",
"\"loginUser response: \"",
"+",
"response",
")",
";",
"storeNewUserResponse",
"(",
"(",
"User",
")",
"response",
",",
"password",
")",
";",
"postResponseToCallback",
"(",
"cb",
",",
"response",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"onError",
"(",
"final",
"KickflipException",
"error",
")",
"{",
"Log",
".",
"w",
"(",
"TAG",
",",
"\"loginUser Error: \"",
"+",
"error",
")",
";",
"postExceptionToCallback",
"(",
"cb",
",",
"error",
")",
";",
"}",
"}",
")",
";",
"}"
] | Login an exiting Kickflip User and make it active.
@param username The Kickflip user's username
@param password The Kickflip user's password
@param cb This callback will receive a User in {@link io.kickflip.sdk.api.KickflipCallback#onSuccess(io.kickflip.sdk.api.json.Response)}
or an Exception {@link io.kickflip.sdk.api.KickflipCallback#onError(io.kickflip.sdk.exception.KickflipException)}. | [
"Login",
"an",
"exiting",
"Kickflip",
"User",
"and",
"make",
"it",
"active",
"."
] | train | https://github.com/Kickflip/kickflip-android-sdk/blob/af3aae5f1128d7376e67aefe11a3a1a3844be734/sdk/src/main/java/io/kickflip/sdk/api/KickflipApiClient.java#L214-L234 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.