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
|
---|---|---|---|---|---|---|---|---|---|---|
Javacord/Javacord | javacord-core/src/main/java/org/javacord/core/DiscordApiImpl.java | DiscordApiImpl.getOrCreateKnownCustomEmoji | public KnownCustomEmoji getOrCreateKnownCustomEmoji(Server server, JsonNode data) {
"""
Gets or creates a new known custom emoji object.
@param server The server of the emoji.
@param data The data of the emoji.
@return The emoji for the given json object.
"""
long id = Long.parseLong(data.get("id").asText());
return customEmojis.computeIfAbsent(id, key -> new KnownCustomEmojiImpl(this, server, data));
} | java | public KnownCustomEmoji getOrCreateKnownCustomEmoji(Server server, JsonNode data) {
long id = Long.parseLong(data.get("id").asText());
return customEmojis.computeIfAbsent(id, key -> new KnownCustomEmojiImpl(this, server, data));
} | [
"public",
"KnownCustomEmoji",
"getOrCreateKnownCustomEmoji",
"(",
"Server",
"server",
",",
"JsonNode",
"data",
")",
"{",
"long",
"id",
"=",
"Long",
".",
"parseLong",
"(",
"data",
".",
"get",
"(",
"\"id\"",
")",
".",
"asText",
"(",
")",
")",
";",
"return",
"customEmojis",
".",
"computeIfAbsent",
"(",
"id",
",",
"key",
"->",
"new",
"KnownCustomEmojiImpl",
"(",
"this",
",",
"server",
",",
"data",
")",
")",
";",
"}"
] | Gets or creates a new known custom emoji object.
@param server The server of the emoji.
@param data The data of the emoji.
@return The emoji for the given json object. | [
"Gets",
"or",
"creates",
"a",
"new",
"known",
"custom",
"emoji",
"object",
"."
] | train | https://github.com/Javacord/Javacord/blob/915aad084dc5e863284267529d0dccd625fc6886/javacord-core/src/main/java/org/javacord/core/DiscordApiImpl.java#L813-L816 |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/metadata/RepositoryTags.java | RepositoryTags.getOpeningTagById | public String getOpeningTagById(int elementId, String attributes) {
"""
returns the opening xml-tag associated with the repository element with
id <code>elementId</code>.
@return the resulting tag
"""
return "<" + table.getKeyByValue(new Integer(elementId)) + " " + attributes + ">";
} | java | public String getOpeningTagById(int elementId, String attributes)
{
return "<" + table.getKeyByValue(new Integer(elementId)) + " " + attributes + ">";
} | [
"public",
"String",
"getOpeningTagById",
"(",
"int",
"elementId",
",",
"String",
"attributes",
")",
"{",
"return",
"\"<\"",
"+",
"table",
".",
"getKeyByValue",
"(",
"new",
"Integer",
"(",
"elementId",
")",
")",
"+",
"\" \"",
"+",
"attributes",
"+",
"\">\"",
";",
"}"
] | returns the opening xml-tag associated with the repository element with
id <code>elementId</code>.
@return the resulting tag | [
"returns",
"the",
"opening",
"xml",
"-",
"tag",
"associated",
"with",
"the",
"repository",
"element",
"with",
"id",
"<code",
">",
"elementId<",
"/",
"code",
">",
"."
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/metadata/RepositoryTags.java#L231-L234 |
btrplace/scheduler | choco/src/main/java/org/btrplace/scheduler/choco/DefaultReconfigurationProblem.java | DefaultReconfigurationProblem.defaultHeuristic | private void defaultHeuristic() {
"""
A naive heuristic to be sure every variables will be instantiated.
"""
IntStrategy intStrat = Search.intVarSearch(new FirstFail(csp), new IntDomainMin(), csp.retrieveIntVars(true));
SetStrategy setStrat = new SetStrategy(csp.retrieveSetVars(), new InputOrder<>(csp), new SetDomainMin(), true);
RealStrategy realStrat = new RealStrategy(csp.retrieveRealVars(), new Occurrence<>(), new RealDomainMiddle());
solver.setSearch(new StrategiesSequencer(intStrat, realStrat, setStrat));
} | java | private void defaultHeuristic() {
IntStrategy intStrat = Search.intVarSearch(new FirstFail(csp), new IntDomainMin(), csp.retrieveIntVars(true));
SetStrategy setStrat = new SetStrategy(csp.retrieveSetVars(), new InputOrder<>(csp), new SetDomainMin(), true);
RealStrategy realStrat = new RealStrategy(csp.retrieveRealVars(), new Occurrence<>(), new RealDomainMiddle());
solver.setSearch(new StrategiesSequencer(intStrat, realStrat, setStrat));
} | [
"private",
"void",
"defaultHeuristic",
"(",
")",
"{",
"IntStrategy",
"intStrat",
"=",
"Search",
".",
"intVarSearch",
"(",
"new",
"FirstFail",
"(",
"csp",
")",
",",
"new",
"IntDomainMin",
"(",
")",
",",
"csp",
".",
"retrieveIntVars",
"(",
"true",
")",
")",
";",
"SetStrategy",
"setStrat",
"=",
"new",
"SetStrategy",
"(",
"csp",
".",
"retrieveSetVars",
"(",
")",
",",
"new",
"InputOrder",
"<>",
"(",
"csp",
")",
",",
"new",
"SetDomainMin",
"(",
")",
",",
"true",
")",
";",
"RealStrategy",
"realStrat",
"=",
"new",
"RealStrategy",
"(",
"csp",
".",
"retrieveRealVars",
"(",
")",
",",
"new",
"Occurrence",
"<>",
"(",
")",
",",
"new",
"RealDomainMiddle",
"(",
")",
")",
";",
"solver",
".",
"setSearch",
"(",
"new",
"StrategiesSequencer",
"(",
"intStrat",
",",
"realStrat",
",",
"setStrat",
")",
")",
";",
"}"
] | A naive heuristic to be sure every variables will be instantiated. | [
"A",
"naive",
"heuristic",
"to",
"be",
"sure",
"every",
"variables",
"will",
"be",
"instantiated",
"."
] | train | https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/choco/src/main/java/org/btrplace/scheduler/choco/DefaultReconfigurationProblem.java#L324-L329 |
Swagger2Markup/swagger2markup | src/main/java/io/github/swagger2markup/internal/adapter/PropertyAdapter.java | PropertyAdapter.generateExample | public static Object generateExample(Property property, MarkupDocBuilder markupDocBuilder) {
"""
Generate a default example value for property.
@param property property
@param markupDocBuilder doc builder
@return a generated example for the property
"""
if (property.getType() == null) {
return "untyped";
}
switch (property.getType()) {
case "integer":
return ExamplesUtil.generateIntegerExample(property instanceof IntegerProperty ? ((IntegerProperty) property).getEnum() : null);
case "number":
return 0.0;
case "boolean":
return true;
case "string":
return ExamplesUtil.generateStringExample(property.getFormat(), property instanceof StringProperty ? ((StringProperty) property).getEnum() : null);
case "ref":
if (property instanceof RefProperty) {
if (logger.isDebugEnabled()) logger.debug("generateExample RefProperty for " + property.getName());
return markupDocBuilder.copy(false).crossReference(((RefProperty) property).getSimpleRef()).toString();
} else {
if (logger.isDebugEnabled()) logger.debug("generateExample for ref not RefProperty");
}
case "array":
if (property instanceof ArrayProperty) {
return generateArrayExample((ArrayProperty) property, markupDocBuilder);
}
default:
return property.getType();
}
} | java | public static Object generateExample(Property property, MarkupDocBuilder markupDocBuilder) {
if (property.getType() == null) {
return "untyped";
}
switch (property.getType()) {
case "integer":
return ExamplesUtil.generateIntegerExample(property instanceof IntegerProperty ? ((IntegerProperty) property).getEnum() : null);
case "number":
return 0.0;
case "boolean":
return true;
case "string":
return ExamplesUtil.generateStringExample(property.getFormat(), property instanceof StringProperty ? ((StringProperty) property).getEnum() : null);
case "ref":
if (property instanceof RefProperty) {
if (logger.isDebugEnabled()) logger.debug("generateExample RefProperty for " + property.getName());
return markupDocBuilder.copy(false).crossReference(((RefProperty) property).getSimpleRef()).toString();
} else {
if (logger.isDebugEnabled()) logger.debug("generateExample for ref not RefProperty");
}
case "array":
if (property instanceof ArrayProperty) {
return generateArrayExample((ArrayProperty) property, markupDocBuilder);
}
default:
return property.getType();
}
} | [
"public",
"static",
"Object",
"generateExample",
"(",
"Property",
"property",
",",
"MarkupDocBuilder",
"markupDocBuilder",
")",
"{",
"if",
"(",
"property",
".",
"getType",
"(",
")",
"==",
"null",
")",
"{",
"return",
"\"untyped\"",
";",
"}",
"switch",
"(",
"property",
".",
"getType",
"(",
")",
")",
"{",
"case",
"\"integer\"",
":",
"return",
"ExamplesUtil",
".",
"generateIntegerExample",
"(",
"property",
"instanceof",
"IntegerProperty",
"?",
"(",
"(",
"IntegerProperty",
")",
"property",
")",
".",
"getEnum",
"(",
")",
":",
"null",
")",
";",
"case",
"\"number\"",
":",
"return",
"0.0",
";",
"case",
"\"boolean\"",
":",
"return",
"true",
";",
"case",
"\"string\"",
":",
"return",
"ExamplesUtil",
".",
"generateStringExample",
"(",
"property",
".",
"getFormat",
"(",
")",
",",
"property",
"instanceof",
"StringProperty",
"?",
"(",
"(",
"StringProperty",
")",
"property",
")",
".",
"getEnum",
"(",
")",
":",
"null",
")",
";",
"case",
"\"ref\"",
":",
"if",
"(",
"property",
"instanceof",
"RefProperty",
")",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"logger",
".",
"debug",
"(",
"\"generateExample RefProperty for \"",
"+",
"property",
".",
"getName",
"(",
")",
")",
";",
"return",
"markupDocBuilder",
".",
"copy",
"(",
"false",
")",
".",
"crossReference",
"(",
"(",
"(",
"RefProperty",
")",
"property",
")",
".",
"getSimpleRef",
"(",
")",
")",
".",
"toString",
"(",
")",
";",
"}",
"else",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"logger",
".",
"debug",
"(",
"\"generateExample for ref not RefProperty\"",
")",
";",
"}",
"case",
"\"array\"",
":",
"if",
"(",
"property",
"instanceof",
"ArrayProperty",
")",
"{",
"return",
"generateArrayExample",
"(",
"(",
"ArrayProperty",
")",
"property",
",",
"markupDocBuilder",
")",
";",
"}",
"default",
":",
"return",
"property",
".",
"getType",
"(",
")",
";",
"}",
"}"
] | Generate a default example value for property.
@param property property
@param markupDocBuilder doc builder
@return a generated example for the property | [
"Generate",
"a",
"default",
"example",
"value",
"for",
"property",
"."
] | train | https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/adapter/PropertyAdapter.java#L76-L105 |
Azure/azure-sdk-for-java | sql/resource-manager/v2015_05_01_preview/src/main/java/com/microsoft/azure/management/sql/v2015_05_01_preview/implementation/ServerKeysInner.java | ServerKeysInner.createOrUpdate | public ServerKeyInner createOrUpdate(String resourceGroupName, String serverName, String keyName, ServerKeyInner parameters) {
"""
Creates or updates a server key.
@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 keyName The name of the server key to be operated on (updated or created). The key name is required to be in the format of 'vault_key_version'. For example, if the keyId is https://YourVaultName.vault.azure.net/keys/YourKeyName/01234567890123456789012345678901, then the server key name should be formatted as: YourVaultName_YourKeyName_01234567890123456789012345678901
@param parameters The requested server key resource state.
@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 ServerKeyInner object if successful.
"""
return createOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, keyName, parameters).toBlocking().last().body();
} | java | public ServerKeyInner createOrUpdate(String resourceGroupName, String serverName, String keyName, ServerKeyInner parameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, keyName, parameters).toBlocking().last().body();
} | [
"public",
"ServerKeyInner",
"createOrUpdate",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"String",
"keyName",
",",
"ServerKeyInner",
"parameters",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
",",
"keyName",
",",
"parameters",
")",
".",
"toBlocking",
"(",
")",
".",
"last",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Creates or updates a server key.
@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 keyName The name of the server key to be operated on (updated or created). The key name is required to be in the format of 'vault_key_version'. For example, if the keyId is https://YourVaultName.vault.azure.net/keys/YourKeyName/01234567890123456789012345678901, then the server key name should be formatted as: YourVaultName_YourKeyName_01234567890123456789012345678901
@param parameters The requested server key resource state.
@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 ServerKeyInner object if successful. | [
"Creates",
"or",
"updates",
"a",
"server",
"key",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2015_05_01_preview/src/main/java/com/microsoft/azure/management/sql/v2015_05_01_preview/implementation/ServerKeysInner.java#L322-L324 |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java | ZipFileIndex.get4ByteLittleEndian | private static int get4ByteLittleEndian(byte[] buf, int pos) {
"""
return the 4 bytes buf[i..i+3] as an integer in little endian format.
"""
return (buf[pos] & 0xFF) + ((buf[pos + 1] & 0xFF) << 8) +
((buf[pos + 2] & 0xFF) << 16) + ((buf[pos + 3] & 0xFF) << 24);
} | java | private static int get4ByteLittleEndian(byte[] buf, int pos) {
return (buf[pos] & 0xFF) + ((buf[pos + 1] & 0xFF) << 8) +
((buf[pos + 2] & 0xFF) << 16) + ((buf[pos + 3] & 0xFF) << 24);
} | [
"private",
"static",
"int",
"get4ByteLittleEndian",
"(",
"byte",
"[",
"]",
"buf",
",",
"int",
"pos",
")",
"{",
"return",
"(",
"buf",
"[",
"pos",
"]",
"&",
"0xFF",
")",
"+",
"(",
"(",
"buf",
"[",
"pos",
"+",
"1",
"]",
"&",
"0xFF",
")",
"<<",
"8",
")",
"+",
"(",
"(",
"buf",
"[",
"pos",
"+",
"2",
"]",
"&",
"0xFF",
")",
"<<",
"16",
")",
"+",
"(",
"(",
"buf",
"[",
"pos",
"+",
"3",
"]",
"&",
"0xFF",
")",
"<<",
"24",
")",
";",
"}"
] | return the 4 bytes buf[i..i+3] as an integer in little endian format. | [
"return",
"the",
"4",
"bytes",
"buf",
"[",
"i",
"..",
"i",
"+",
"3",
"]",
"as",
"an",
"integer",
"in",
"little",
"endian",
"format",
"."
] | train | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java#L474-L477 |
molgenis/molgenis | molgenis-data/src/main/java/org/molgenis/data/meta/EntityTypeRepositoryDecorator.java | EntityTypeRepositoryDecorator.removeMappedByAttributes | private void removeMappedByAttributes(Map<String, EntityType> resolvedEntityTypes) {
"""
Removes the mappedBy attributes of each OneToMany pair in the supplied map of EntityTypes
"""
resolvedEntityTypes
.values()
.stream()
.flatMap(EntityType::getMappedByAttributes)
.filter(attribute -> resolvedEntityTypes.containsKey(attribute.getEntity().getId()))
.forEach(attribute -> dataService.delete(ATTRIBUTE_META_DATA, attribute));
} | java | private void removeMappedByAttributes(Map<String, EntityType> resolvedEntityTypes) {
resolvedEntityTypes
.values()
.stream()
.flatMap(EntityType::getMappedByAttributes)
.filter(attribute -> resolvedEntityTypes.containsKey(attribute.getEntity().getId()))
.forEach(attribute -> dataService.delete(ATTRIBUTE_META_DATA, attribute));
} | [
"private",
"void",
"removeMappedByAttributes",
"(",
"Map",
"<",
"String",
",",
"EntityType",
">",
"resolvedEntityTypes",
")",
"{",
"resolvedEntityTypes",
".",
"values",
"(",
")",
".",
"stream",
"(",
")",
".",
"flatMap",
"(",
"EntityType",
"::",
"getMappedByAttributes",
")",
".",
"filter",
"(",
"attribute",
"->",
"resolvedEntityTypes",
".",
"containsKey",
"(",
"attribute",
".",
"getEntity",
"(",
")",
".",
"getId",
"(",
")",
")",
")",
".",
"forEach",
"(",
"attribute",
"->",
"dataService",
".",
"delete",
"(",
"ATTRIBUTE_META_DATA",
",",
"attribute",
")",
")",
";",
"}"
] | Removes the mappedBy attributes of each OneToMany pair in the supplied map of EntityTypes | [
"Removes",
"the",
"mappedBy",
"attributes",
"of",
"each",
"OneToMany",
"pair",
"in",
"the",
"supplied",
"map",
"of",
"EntityTypes"
] | train | https://github.com/molgenis/molgenis/blob/b4d0d6b27e6f6c8d7505a3863dc03b589601f987/molgenis-data/src/main/java/org/molgenis/data/meta/EntityTypeRepositoryDecorator.java#L210-L217 |
basho/riak-java-client | src/main/java/com/basho/riak/client/api/RiakClient.java | RiakClient.newClient | public static RiakClient newClient(RiakNode.Builder nodeBuilder, String... addresses) throws UnknownHostException {
"""
Static factory method to create a new client instance.
@since 2.0.3
@see #newClient(RiakNode.Builder, List)
"""
return newClient(nodeBuilder, Arrays.asList(addresses));
} | java | public static RiakClient newClient(RiakNode.Builder nodeBuilder, String... addresses) throws UnknownHostException
{
return newClient(nodeBuilder, Arrays.asList(addresses));
} | [
"public",
"static",
"RiakClient",
"newClient",
"(",
"RiakNode",
".",
"Builder",
"nodeBuilder",
",",
"String",
"...",
"addresses",
")",
"throws",
"UnknownHostException",
"{",
"return",
"newClient",
"(",
"nodeBuilder",
",",
"Arrays",
".",
"asList",
"(",
"addresses",
")",
")",
";",
"}"
] | Static factory method to create a new client instance.
@since 2.0.3
@see #newClient(RiakNode.Builder, List) | [
"Static",
"factory",
"method",
"to",
"create",
"a",
"new",
"client",
"instance",
"."
] | train | https://github.com/basho/riak-java-client/blob/bed6cd60f360bacf1b873ab92dd74f2526651e71/src/main/java/com/basho/riak/client/api/RiakClient.java#L298-L301 |
liferay/com-liferay-commerce | commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPInstancePersistenceImpl.java | CPInstancePersistenceImpl.removeByC_C | @Override
public CPInstance removeByC_C(long CPDefinitionId, String CPInstanceUuid)
throws NoSuchCPInstanceException {
"""
Removes the cp instance where CPDefinitionId = ? and CPInstanceUuid = ? from the database.
@param CPDefinitionId the cp definition ID
@param CPInstanceUuid the cp instance uuid
@return the cp instance that was removed
"""
CPInstance cpInstance = findByC_C(CPDefinitionId, CPInstanceUuid);
return remove(cpInstance);
} | java | @Override
public CPInstance removeByC_C(long CPDefinitionId, String CPInstanceUuid)
throws NoSuchCPInstanceException {
CPInstance cpInstance = findByC_C(CPDefinitionId, CPInstanceUuid);
return remove(cpInstance);
} | [
"@",
"Override",
"public",
"CPInstance",
"removeByC_C",
"(",
"long",
"CPDefinitionId",
",",
"String",
"CPInstanceUuid",
")",
"throws",
"NoSuchCPInstanceException",
"{",
"CPInstance",
"cpInstance",
"=",
"findByC_C",
"(",
"CPDefinitionId",
",",
"CPInstanceUuid",
")",
";",
"return",
"remove",
"(",
"cpInstance",
")",
";",
"}"
] | Removes the cp instance where CPDefinitionId = ? and CPInstanceUuid = ? from the database.
@param CPDefinitionId the cp definition ID
@param CPInstanceUuid the cp instance uuid
@return the cp instance that was removed | [
"Removes",
"the",
"cp",
"instance",
"where",
"CPDefinitionId",
"=",
"?",
";",
"and",
"CPInstanceUuid",
"=",
"?",
";",
"from",
"the",
"database",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPInstancePersistenceImpl.java#L4233-L4239 |
broadinstitute/barclay | src/main/java/org/broadinstitute/barclay/utils/Utils.java | Utils.wrapParagraph | public static String wrapParagraph(final String input, final int width) {
"""
A utility method to wrap multiple lines of text, while respecting the original
newlines.
@param input the String of text to wrap
@param width the width in characters into which to wrap the text. Less than 1 is treated as 1
@return the original string with newlines added, and starting spaces trimmed
so that the resulting lines fit inside a column of with characters.
"""
if (input == null || input.isEmpty()) {
return input;
}
final StringBuilder out = new StringBuilder();
try (final BufferedReader bufReader = new BufferedReader(new StringReader(input))) {
out.append(bufReader.lines()
.map(line -> WordUtils.wrap(line, width))
.collect(Collectors.joining("\n")));
} catch (IOException e) {
throw new RuntimeException("Unreachable Statement.\nHow did the Buffered reader throw when it was " +
"wrapping a StringReader?", e);
}
//if the last character of the input is a newline, we need to add another newline to conserve that.
if (input.charAt(input.length() - 1) == '\n') {
out.append('\n');
}
return out.toString();
} | java | public static String wrapParagraph(final String input, final int width) {
if (input == null || input.isEmpty()) {
return input;
}
final StringBuilder out = new StringBuilder();
try (final BufferedReader bufReader = new BufferedReader(new StringReader(input))) {
out.append(bufReader.lines()
.map(line -> WordUtils.wrap(line, width))
.collect(Collectors.joining("\n")));
} catch (IOException e) {
throw new RuntimeException("Unreachable Statement.\nHow did the Buffered reader throw when it was " +
"wrapping a StringReader?", e);
}
//if the last character of the input is a newline, we need to add another newline to conserve that.
if (input.charAt(input.length() - 1) == '\n') {
out.append('\n');
}
return out.toString();
} | [
"public",
"static",
"String",
"wrapParagraph",
"(",
"final",
"String",
"input",
",",
"final",
"int",
"width",
")",
"{",
"if",
"(",
"input",
"==",
"null",
"||",
"input",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"input",
";",
"}",
"final",
"StringBuilder",
"out",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"try",
"(",
"final",
"BufferedReader",
"bufReader",
"=",
"new",
"BufferedReader",
"(",
"new",
"StringReader",
"(",
"input",
")",
")",
")",
"{",
"out",
".",
"append",
"(",
"bufReader",
".",
"lines",
"(",
")",
".",
"map",
"(",
"line",
"->",
"WordUtils",
".",
"wrap",
"(",
"line",
",",
"width",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"joining",
"(",
"\"\\n\"",
")",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unreachable Statement.\\nHow did the Buffered reader throw when it was \"",
"+",
"\"wrapping a StringReader?\"",
",",
"e",
")",
";",
"}",
"//if the last character of the input is a newline, we need to add another newline to conserve that.",
"if",
"(",
"input",
".",
"charAt",
"(",
"input",
".",
"length",
"(",
")",
"-",
"1",
")",
"==",
"'",
"'",
")",
"{",
"out",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"return",
"out",
".",
"toString",
"(",
")",
";",
"}"
] | A utility method to wrap multiple lines of text, while respecting the original
newlines.
@param input the String of text to wrap
@param width the width in characters into which to wrap the text. Less than 1 is treated as 1
@return the original string with newlines added, and starting spaces trimmed
so that the resulting lines fit inside a column of with characters. | [
"A",
"utility",
"method",
"to",
"wrap",
"multiple",
"lines",
"of",
"text",
"while",
"respecting",
"the",
"original",
"newlines",
"."
] | train | https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/utils/Utils.java#L154-L175 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/mock/CommonsMock.java | MockSupplier.createNoParams | @Nonnull
public static <T> MockSupplier createNoParams (@Nonnull final Class <T> aDstClass,
@Nonnull final Supplier <T> aSupplier) {
"""
Create a mock supplier for a factory without parameters.
@param aDstClass
The destination class to be mocked. May not be <code>null</code>.
@param aSupplier
The supplier/factory without parameters to be used. May not be
<code>null</code>.
@return Never <code>null</code>.
@param <T>
The type to be mocked
"""
ValueEnforcer.notNull (aDstClass, "DstClass");
ValueEnforcer.notNull (aSupplier, "Supplier");
return new MockSupplier (aDstClass, null, aParam -> aSupplier.get ());
} | java | @Nonnull
public static <T> MockSupplier createNoParams (@Nonnull final Class <T> aDstClass,
@Nonnull final Supplier <T> aSupplier)
{
ValueEnforcer.notNull (aDstClass, "DstClass");
ValueEnforcer.notNull (aSupplier, "Supplier");
return new MockSupplier (aDstClass, null, aParam -> aSupplier.get ());
} | [
"@",
"Nonnull",
"public",
"static",
"<",
"T",
">",
"MockSupplier",
"createNoParams",
"(",
"@",
"Nonnull",
"final",
"Class",
"<",
"T",
">",
"aDstClass",
",",
"@",
"Nonnull",
"final",
"Supplier",
"<",
"T",
">",
"aSupplier",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aDstClass",
",",
"\"DstClass\"",
")",
";",
"ValueEnforcer",
".",
"notNull",
"(",
"aSupplier",
",",
"\"Supplier\"",
")",
";",
"return",
"new",
"MockSupplier",
"(",
"aDstClass",
",",
"null",
",",
"aParam",
"->",
"aSupplier",
".",
"get",
"(",
")",
")",
";",
"}"
] | Create a mock supplier for a factory without parameters.
@param aDstClass
The destination class to be mocked. May not be <code>null</code>.
@param aSupplier
The supplier/factory without parameters to be used. May not be
<code>null</code>.
@return Never <code>null</code>.
@param <T>
The type to be mocked | [
"Create",
"a",
"mock",
"supplier",
"for",
"a",
"factory",
"without",
"parameters",
"."
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/mock/CommonsMock.java#L231-L238 |
apiman/apiman | manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/util/ExceptionFactory.java | ExceptionFactory.apiVersionNotFoundException | public static final ApiVersionNotFoundException apiVersionNotFoundException(String apiId, String version) {
"""
Creates an exception from an API id and version.
@param apiId the API id
@param version the API version
@return the exception
"""
return new ApiVersionNotFoundException(Messages.i18n.format("ApiVersionDoesNotExist", apiId, version)); //$NON-NLS-1$
} | java | public static final ApiVersionNotFoundException apiVersionNotFoundException(String apiId, String version) {
return new ApiVersionNotFoundException(Messages.i18n.format("ApiVersionDoesNotExist", apiId, version)); //$NON-NLS-1$
} | [
"public",
"static",
"final",
"ApiVersionNotFoundException",
"apiVersionNotFoundException",
"(",
"String",
"apiId",
",",
"String",
"version",
")",
"{",
"return",
"new",
"ApiVersionNotFoundException",
"(",
"Messages",
".",
"i18n",
".",
"format",
"(",
"\"ApiVersionDoesNotExist\"",
",",
"apiId",
",",
"version",
")",
")",
";",
"//$NON-NLS-1$",
"}"
] | Creates an exception from an API id and version.
@param apiId the API id
@param version the API version
@return the exception | [
"Creates",
"an",
"exception",
"from",
"an",
"API",
"id",
"and",
"version",
"."
] | train | https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/util/ExceptionFactory.java#L229-L231 |
apache/reef | lang/java/reef-runtime-yarn/src/main/java/org/apache/reef/runtime/yarn/driver/YarnContainerManager.java | YarnContainerManager.onContainerStarted | @Override
public void onContainerStarted(final ContainerId containerId, final Map<String, ByteBuffer> stringByteBufferMap) {
"""
NM Callback: NM accepts the starting container request.
@param containerId ID of a new container being started.
@param stringByteBufferMap a Map between the auxiliary service names and their outputs. Not used.
"""
final Optional<Container> container = this.containers.getOptional(containerId.toString());
if (container.isPresent()) {
this.nodeManager.getContainerStatusAsync(containerId, container.get().getNodeId());
}
} | java | @Override
public void onContainerStarted(final ContainerId containerId, final Map<String, ByteBuffer> stringByteBufferMap) {
final Optional<Container> container = this.containers.getOptional(containerId.toString());
if (container.isPresent()) {
this.nodeManager.getContainerStatusAsync(containerId, container.get().getNodeId());
}
} | [
"@",
"Override",
"public",
"void",
"onContainerStarted",
"(",
"final",
"ContainerId",
"containerId",
",",
"final",
"Map",
"<",
"String",
",",
"ByteBuffer",
">",
"stringByteBufferMap",
")",
"{",
"final",
"Optional",
"<",
"Container",
">",
"container",
"=",
"this",
".",
"containers",
".",
"getOptional",
"(",
"containerId",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"container",
".",
"isPresent",
"(",
")",
")",
"{",
"this",
".",
"nodeManager",
".",
"getContainerStatusAsync",
"(",
"containerId",
",",
"container",
".",
"get",
"(",
")",
".",
"getNodeId",
"(",
")",
")",
";",
"}",
"}"
] | NM Callback: NM accepts the starting container request.
@param containerId ID of a new container being started.
@param stringByteBufferMap a Map between the auxiliary service names and their outputs. Not used. | [
"NM",
"Callback",
":",
"NM",
"accepts",
"the",
"starting",
"container",
"request",
"."
] | train | https://github.com/apache/reef/blob/e2c47121cde21108a602c560cf76565a40d0e916/lang/java/reef-runtime-yarn/src/main/java/org/apache/reef/runtime/yarn/driver/YarnContainerManager.java#L223-L229 |
undera/jmeter-plugins | infra/common/src/main/java/kg/apc/charting/plotters/AbstractRowPlotter.java | AbstractRowPlotter.isChartPointValid | protected boolean isChartPointValid(int xx, int yy) {
"""
/*
Check if the point (x,y) is contained in the chart area
We check only minX, maxX, and maxY to avoid flickering.
We take max(chartRect.y, y) as redering value
This is done to prevent line out of range if new point is added
during chart paint.
"""
boolean ret = true;
//check x
if (xx < chartRect.x || xx > chartRect.x + chartRect.width) {
ret = false;
} else //check y bellow x axis
if (yy > chartRect.y + chartRect.height) {
ret = false;
}
return ret;
} | java | protected boolean isChartPointValid(int xx, int yy) {
boolean ret = true;
//check x
if (xx < chartRect.x || xx > chartRect.x + chartRect.width) {
ret = false;
} else //check y bellow x axis
if (yy > chartRect.y + chartRect.height) {
ret = false;
}
return ret;
} | [
"protected",
"boolean",
"isChartPointValid",
"(",
"int",
"xx",
",",
"int",
"yy",
")",
"{",
"boolean",
"ret",
"=",
"true",
";",
"//check x",
"if",
"(",
"xx",
"<",
"chartRect",
".",
"x",
"||",
"xx",
">",
"chartRect",
".",
"x",
"+",
"chartRect",
".",
"width",
")",
"{",
"ret",
"=",
"false",
";",
"}",
"else",
"//check y bellow x axis",
"if",
"(",
"yy",
">",
"chartRect",
".",
"y",
"+",
"chartRect",
".",
"height",
")",
"{",
"ret",
"=",
"false",
";",
"}",
"return",
"ret",
";",
"}"
] | /*
Check if the point (x,y) is contained in the chart area
We check only minX, maxX, and maxY to avoid flickering.
We take max(chartRect.y, y) as redering value
This is done to prevent line out of range if new point is added
during chart paint. | [
"/",
"*",
"Check",
"if",
"the",
"point",
"(",
"x",
"y",
")",
"is",
"contained",
"in",
"the",
"chart",
"area",
"We",
"check",
"only",
"minX",
"maxX",
"and",
"maxY",
"to",
"avoid",
"flickering",
".",
"We",
"take",
"max",
"(",
"chartRect",
".",
"y",
"y",
")",
"as",
"redering",
"value",
"This",
"is",
"done",
"to",
"prevent",
"line",
"out",
"of",
"range",
"if",
"new",
"point",
"is",
"added",
"during",
"chart",
"paint",
"."
] | train | https://github.com/undera/jmeter-plugins/blob/416d2a77249ab921c7e4134c3e6a9639901ef7e8/infra/common/src/main/java/kg/apc/charting/plotters/AbstractRowPlotter.java#L63-L75 |
ibm-bluemix-mobile-services/bms-clientsdk-android-core | lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/api/MCAAuthorizationManager.java | MCAAuthorizationManager.createInstance | public static synchronized MCAAuthorizationManager createInstance(Context context, String tenantId, String bluemixRegion) {
"""
Init singleton instance with context, tenantId and Bluemix region.
@param context Application context
@param tenantId the unique tenant id of the MCA service instance that the application connects to.
@param bluemixRegion Specifies the Bluemix deployment to use.
@return The singleton instance
"""
instance = createInstance(context, tenantId);
if (null != bluemixRegion) {
instance.bluemixRegionSuffix = bluemixRegion;
}
return instance;
} | java | public static synchronized MCAAuthorizationManager createInstance(Context context, String tenantId, String bluemixRegion) {
instance = createInstance(context, tenantId);
if (null != bluemixRegion) {
instance.bluemixRegionSuffix = bluemixRegion;
}
return instance;
} | [
"public",
"static",
"synchronized",
"MCAAuthorizationManager",
"createInstance",
"(",
"Context",
"context",
",",
"String",
"tenantId",
",",
"String",
"bluemixRegion",
")",
"{",
"instance",
"=",
"createInstance",
"(",
"context",
",",
"tenantId",
")",
";",
"if",
"(",
"null",
"!=",
"bluemixRegion",
")",
"{",
"instance",
".",
"bluemixRegionSuffix",
"=",
"bluemixRegion",
";",
"}",
"return",
"instance",
";",
"}"
] | Init singleton instance with context, tenantId and Bluemix region.
@param context Application context
@param tenantId the unique tenant id of the MCA service instance that the application connects to.
@param bluemixRegion Specifies the Bluemix deployment to use.
@return The singleton instance | [
"Init",
"singleton",
"instance",
"with",
"context",
"tenantId",
"and",
"Bluemix",
"region",
"."
] | train | https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-android-core/blob/8db4f00d0d564792397bfc0e5bd57d52a238b858/lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/security/mca/api/MCAAuthorizationManager.java#L116-L123 |
UrielCh/ovh-java-sdk | ovh-java-sdk-status/src/main/java/net/minidev/ovh/api/ApiOvhStatus.java | ApiOvhStatus.task_GET | public ArrayList<OvhTask> task_GET(OvhTaskImpactEnum impact, OvhTaskStatusEnum status, OvhTaskTypeEnum type) throws IOException {
"""
Find all the incidents or maintenances linked to your services
REST: GET /status/task
@param impact [required] Filter by impact
@param status [required] Filter by status
@param type [required] Filter by type
API beta
"""
String qPath = "/status/task";
StringBuilder sb = path(qPath);
query(sb, "impact", impact);
query(sb, "status", status);
query(sb, "type", type);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t1);
} | java | public ArrayList<OvhTask> task_GET(OvhTaskImpactEnum impact, OvhTaskStatusEnum status, OvhTaskTypeEnum type) throws IOException {
String qPath = "/status/task";
StringBuilder sb = path(qPath);
query(sb, "impact", impact);
query(sb, "status", status);
query(sb, "type", type);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t1);
} | [
"public",
"ArrayList",
"<",
"OvhTask",
">",
"task_GET",
"(",
"OvhTaskImpactEnum",
"impact",
",",
"OvhTaskStatusEnum",
"status",
",",
"OvhTaskTypeEnum",
"type",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/status/task\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
")",
";",
"query",
"(",
"sb",
",",
"\"impact\"",
",",
"impact",
")",
";",
"query",
"(",
"sb",
",",
"\"status\"",
",",
"status",
")",
";",
"query",
"(",
"sb",
",",
"\"type\"",
",",
"type",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"t1",
")",
";",
"}"
] | Find all the incidents or maintenances linked to your services
REST: GET /status/task
@param impact [required] Filter by impact
@param status [required] Filter by status
@param type [required] Filter by type
API beta | [
"Find",
"all",
"the",
"incidents",
"or",
"maintenances",
"linked",
"to",
"your",
"services"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-status/src/main/java/net/minidev/ovh/api/ApiOvhStatus.java#L33-L41 |
looly/hutool | hutool-extra/src/main/java/cn/hutool/extra/template/engine/beetl/BeetlUtil.java | BeetlUtil.createFileGroupTemplate | public static GroupTemplate createFileGroupTemplate(String dir, Charset charset) {
"""
创建文件目录的模板组 {@link GroupTemplate},配置文件使用全局默认<br>
此时自定义的配置文件可在ClassPath中放入beetl.properties配置
@param dir 目录路径(绝对路径)
@param charset 读取模板文件的编码
@return {@link GroupTemplate}
@since 3.2.0
"""
return createGroupTemplate(new FileResourceLoader(dir, charset.name()));
} | java | public static GroupTemplate createFileGroupTemplate(String dir, Charset charset) {
return createGroupTemplate(new FileResourceLoader(dir, charset.name()));
} | [
"public",
"static",
"GroupTemplate",
"createFileGroupTemplate",
"(",
"String",
"dir",
",",
"Charset",
"charset",
")",
"{",
"return",
"createGroupTemplate",
"(",
"new",
"FileResourceLoader",
"(",
"dir",
",",
"charset",
".",
"name",
"(",
")",
")",
")",
";",
"}"
] | 创建文件目录的模板组 {@link GroupTemplate},配置文件使用全局默认<br>
此时自定义的配置文件可在ClassPath中放入beetl.properties配置
@param dir 目录路径(绝对路径)
@param charset 读取模板文件的编码
@return {@link GroupTemplate}
@since 3.2.0 | [
"创建文件目录的模板组",
"{",
"@link",
"GroupTemplate",
"}",
",配置文件使用全局默认<br",
">",
"此时自定义的配置文件可在ClassPath中放入beetl",
".",
"properties配置"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-extra/src/main/java/cn/hutool/extra/template/engine/beetl/BeetlUtil.java#L96-L98 |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/HeapCache.java | HeapCache.putValue | protected final void putValue(final Entry e, final V _value) {
"""
Update the value directly within entry lock. Since we did not start
entry processing we do not need to notify any waiting threads.
"""
if (!isUpdateTimeNeeded()) {
insertOrUpdateAndCalculateExpiry(e, _value, 0, 0, 0 , INSERT_STAT_PUT);
} else {
long t = clock.millis();
insertOrUpdateAndCalculateExpiry(e, _value, t, t, t, INSERT_STAT_PUT);
}
} | java | protected final void putValue(final Entry e, final V _value) {
if (!isUpdateTimeNeeded()) {
insertOrUpdateAndCalculateExpiry(e, _value, 0, 0, 0 , INSERT_STAT_PUT);
} else {
long t = clock.millis();
insertOrUpdateAndCalculateExpiry(e, _value, t, t, t, INSERT_STAT_PUT);
}
} | [
"protected",
"final",
"void",
"putValue",
"(",
"final",
"Entry",
"e",
",",
"final",
"V",
"_value",
")",
"{",
"if",
"(",
"!",
"isUpdateTimeNeeded",
"(",
")",
")",
"{",
"insertOrUpdateAndCalculateExpiry",
"(",
"e",
",",
"_value",
",",
"0",
",",
"0",
",",
"0",
",",
"INSERT_STAT_PUT",
")",
";",
"}",
"else",
"{",
"long",
"t",
"=",
"clock",
".",
"millis",
"(",
")",
";",
"insertOrUpdateAndCalculateExpiry",
"(",
"e",
",",
"_value",
",",
"t",
",",
"t",
",",
"t",
",",
"INSERT_STAT_PUT",
")",
";",
"}",
"}"
] | Update the value directly within entry lock. Since we did not start
entry processing we do not need to notify any waiting threads. | [
"Update",
"the",
"value",
"directly",
"within",
"entry",
"lock",
".",
"Since",
"we",
"did",
"not",
"start",
"entry",
"processing",
"we",
"do",
"not",
"need",
"to",
"notify",
"any",
"waiting",
"threads",
"."
] | train | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/HeapCache.java#L764-L771 |
Azure/azure-sdk-for-java | appservice/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/appservice/v2018_02_01/implementation/AppServiceCertificateOrdersInner.java | AppServiceCertificateOrdersInner.retrieveCertificateActionsAsync | public Observable<List<CertificateOrderActionInner>> retrieveCertificateActionsAsync(String resourceGroupName, String name) {
"""
Retrieve the list of certificate actions.
Retrieve the list of certificate actions.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of the certificate order.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<CertificateOrderActionInner> object
"""
return retrieveCertificateActionsWithServiceResponseAsync(resourceGroupName, name).map(new Func1<ServiceResponse<List<CertificateOrderActionInner>>, List<CertificateOrderActionInner>>() {
@Override
public List<CertificateOrderActionInner> call(ServiceResponse<List<CertificateOrderActionInner>> response) {
return response.body();
}
});
} | java | public Observable<List<CertificateOrderActionInner>> retrieveCertificateActionsAsync(String resourceGroupName, String name) {
return retrieveCertificateActionsWithServiceResponseAsync(resourceGroupName, name).map(new Func1<ServiceResponse<List<CertificateOrderActionInner>>, List<CertificateOrderActionInner>>() {
@Override
public List<CertificateOrderActionInner> call(ServiceResponse<List<CertificateOrderActionInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"List",
"<",
"CertificateOrderActionInner",
">",
">",
"retrieveCertificateActionsAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"name",
")",
"{",
"return",
"retrieveCertificateActionsWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"name",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"List",
"<",
"CertificateOrderActionInner",
">",
">",
",",
"List",
"<",
"CertificateOrderActionInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"List",
"<",
"CertificateOrderActionInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"List",
"<",
"CertificateOrderActionInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Retrieve the list of certificate actions.
Retrieve the list of certificate actions.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of the certificate order.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<CertificateOrderActionInner> object | [
"Retrieve",
"the",
"list",
"of",
"certificate",
"actions",
".",
"Retrieve",
"the",
"list",
"of",
"certificate",
"actions",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/appservice/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/appservice/v2018_02_01/implementation/AppServiceCertificateOrdersInner.java#L2261-L2268 |
bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/kits/WalletAppKit.java | WalletAppKit.isChainFileLocked | public boolean isChainFileLocked() throws IOException {
"""
Tests to see if the spvchain file has an operating system file lock on it. Useful for checking if your app
is already running. If another copy of your app is running and you start the appkit anyway, an exception will
be thrown during the startup process. Returns false if the chain file does not exist or is a directory.
"""
RandomAccessFile file2 = null;
try {
File file = new File(directory, filePrefix + ".spvchain");
if (!file.exists())
return false;
if (file.isDirectory())
return false;
file2 = new RandomAccessFile(file, "rw");
FileLock lock = file2.getChannel().tryLock();
if (lock == null)
return true;
lock.release();
return false;
} finally {
if (file2 != null)
file2.close();
}
} | java | public boolean isChainFileLocked() throws IOException {
RandomAccessFile file2 = null;
try {
File file = new File(directory, filePrefix + ".spvchain");
if (!file.exists())
return false;
if (file.isDirectory())
return false;
file2 = new RandomAccessFile(file, "rw");
FileLock lock = file2.getChannel().tryLock();
if (lock == null)
return true;
lock.release();
return false;
} finally {
if (file2 != null)
file2.close();
}
} | [
"public",
"boolean",
"isChainFileLocked",
"(",
")",
"throws",
"IOException",
"{",
"RandomAccessFile",
"file2",
"=",
"null",
";",
"try",
"{",
"File",
"file",
"=",
"new",
"File",
"(",
"directory",
",",
"filePrefix",
"+",
"\".spvchain\"",
")",
";",
"if",
"(",
"!",
"file",
".",
"exists",
"(",
")",
")",
"return",
"false",
";",
"if",
"(",
"file",
".",
"isDirectory",
"(",
")",
")",
"return",
"false",
";",
"file2",
"=",
"new",
"RandomAccessFile",
"(",
"file",
",",
"\"rw\"",
")",
";",
"FileLock",
"lock",
"=",
"file2",
".",
"getChannel",
"(",
")",
".",
"tryLock",
"(",
")",
";",
"if",
"(",
"lock",
"==",
"null",
")",
"return",
"true",
";",
"lock",
".",
"release",
"(",
")",
";",
"return",
"false",
";",
"}",
"finally",
"{",
"if",
"(",
"file2",
"!=",
"null",
")",
"file2",
".",
"close",
"(",
")",
";",
"}",
"}"
] | Tests to see if the spvchain file has an operating system file lock on it. Useful for checking if your app
is already running. If another copy of your app is running and you start the appkit anyway, an exception will
be thrown during the startup process. Returns false if the chain file does not exist or is a directory. | [
"Tests",
"to",
"see",
"if",
"the",
"spvchain",
"file",
"has",
"an",
"operating",
"system",
"file",
"lock",
"on",
"it",
".",
"Useful",
"for",
"checking",
"if",
"your",
"app",
"is",
"already",
"running",
".",
"If",
"another",
"copy",
"of",
"your",
"app",
"is",
"running",
"and",
"you",
"start",
"the",
"appkit",
"anyway",
"an",
"exception",
"will",
"be",
"thrown",
"during",
"the",
"startup",
"process",
".",
"Returns",
"false",
"if",
"the",
"chain",
"file",
"does",
"not",
"exist",
"or",
"is",
"a",
"directory",
"."
] | train | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/kits/WalletAppKit.java#L259-L277 |
real-logic/simple-binary-encoding | sbe-tool/src/main/java/uk/co/real_logic/sbe/otf/Types.java | Types.getLong | public static long getLong(final DirectBuffer buffer, final int index, final Encoding encoding) {
"""
Get a long value from a buffer at a given index for a given {@link Encoding}.
@param buffer from which to read.
@param index at which he integer should be read.
@param encoding of the value.
@return the value of the encoded long.
"""
switch (encoding.primitiveType())
{
case CHAR:
return buffer.getByte(index);
case INT8:
return buffer.getByte(index);
case INT16:
return buffer.getShort(index, encoding.byteOrder());
case INT32:
return buffer.getInt(index, encoding.byteOrder());
case INT64:
return buffer.getLong(index, encoding.byteOrder());
case UINT8:
return (short)(buffer.getByte(index) & 0xFF);
case UINT16:
return buffer.getShort(index, encoding.byteOrder()) & 0xFFFF;
case UINT32:
return buffer.getInt(index, encoding.byteOrder()) & 0xFFFF_FFFFL;
case UINT64:
return buffer.getLong(index, encoding.byteOrder());
default:
throw new IllegalArgumentException("Unsupported type for long: " + encoding.primitiveType());
}
} | java | public static long getLong(final DirectBuffer buffer, final int index, final Encoding encoding)
{
switch (encoding.primitiveType())
{
case CHAR:
return buffer.getByte(index);
case INT8:
return buffer.getByte(index);
case INT16:
return buffer.getShort(index, encoding.byteOrder());
case INT32:
return buffer.getInt(index, encoding.byteOrder());
case INT64:
return buffer.getLong(index, encoding.byteOrder());
case UINT8:
return (short)(buffer.getByte(index) & 0xFF);
case UINT16:
return buffer.getShort(index, encoding.byteOrder()) & 0xFFFF;
case UINT32:
return buffer.getInt(index, encoding.byteOrder()) & 0xFFFF_FFFFL;
case UINT64:
return buffer.getLong(index, encoding.byteOrder());
default:
throw new IllegalArgumentException("Unsupported type for long: " + encoding.primitiveType());
}
} | [
"public",
"static",
"long",
"getLong",
"(",
"final",
"DirectBuffer",
"buffer",
",",
"final",
"int",
"index",
",",
"final",
"Encoding",
"encoding",
")",
"{",
"switch",
"(",
"encoding",
".",
"primitiveType",
"(",
")",
")",
"{",
"case",
"CHAR",
":",
"return",
"buffer",
".",
"getByte",
"(",
"index",
")",
";",
"case",
"INT8",
":",
"return",
"buffer",
".",
"getByte",
"(",
"index",
")",
";",
"case",
"INT16",
":",
"return",
"buffer",
".",
"getShort",
"(",
"index",
",",
"encoding",
".",
"byteOrder",
"(",
")",
")",
";",
"case",
"INT32",
":",
"return",
"buffer",
".",
"getInt",
"(",
"index",
",",
"encoding",
".",
"byteOrder",
"(",
")",
")",
";",
"case",
"INT64",
":",
"return",
"buffer",
".",
"getLong",
"(",
"index",
",",
"encoding",
".",
"byteOrder",
"(",
")",
")",
";",
"case",
"UINT8",
":",
"return",
"(",
"short",
")",
"(",
"buffer",
".",
"getByte",
"(",
"index",
")",
"&",
"0xFF",
")",
";",
"case",
"UINT16",
":",
"return",
"buffer",
".",
"getShort",
"(",
"index",
",",
"encoding",
".",
"byteOrder",
"(",
")",
")",
"&",
"0xFFFF",
";",
"case",
"UINT32",
":",
"return",
"buffer",
".",
"getInt",
"(",
"index",
",",
"encoding",
".",
"byteOrder",
"(",
")",
")",
"&",
"0xFFFF_FFFF",
"",
"L",
";",
"case",
"UINT64",
":",
"return",
"buffer",
".",
"getLong",
"(",
"index",
",",
"encoding",
".",
"byteOrder",
"(",
")",
")",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unsupported type for long: \"",
"+",
"encoding",
".",
"primitiveType",
"(",
")",
")",
";",
"}",
"}"
] | Get a long value from a buffer at a given index for a given {@link Encoding}.
@param buffer from which to read.
@param index at which he integer should be read.
@param encoding of the value.
@return the value of the encoded long. | [
"Get",
"a",
"long",
"value",
"from",
"a",
"buffer",
"at",
"a",
"given",
"index",
"for",
"a",
"given",
"{",
"@link",
"Encoding",
"}",
"."
] | train | https://github.com/real-logic/simple-binary-encoding/blob/9a7be490c86d98f0e430e4189bc6c8c4fbef658b/sbe-tool/src/main/java/uk/co/real_logic/sbe/otf/Types.java#L80-L114 |
mp911de/visualizr | visualizr-metrics/src/main/java/biz/paluch/visualizr/metrics/VisualizrReporter.java | VisualizrReporter.reportGauge | private void reportGauge(String name, Gauge gauge) {
"""
Report a gauge using the field gauge. Only numeric values are used.
@param name
@param gauge
"""
String prefixedName = prefix(name);
Object value = gauge.getValue();
if (value instanceof Number) {
if (!snapshots.hasDescriptor(prefixedName)) {
snapshots.setDescriptor(prefixedName, MetricItem.Builder.create().count("gauge").build());
}
long timestamp = getTimestamp();
snapshots.addSnapshot(prefixedName, timestamp, (Map) map("gauge", value));
}
} | java | private void reportGauge(String name, Gauge gauge) {
String prefixedName = prefix(name);
Object value = gauge.getValue();
if (value instanceof Number) {
if (!snapshots.hasDescriptor(prefixedName)) {
snapshots.setDescriptor(prefixedName, MetricItem.Builder.create().count("gauge").build());
}
long timestamp = getTimestamp();
snapshots.addSnapshot(prefixedName, timestamp, (Map) map("gauge", value));
}
} | [
"private",
"void",
"reportGauge",
"(",
"String",
"name",
",",
"Gauge",
"gauge",
")",
"{",
"String",
"prefixedName",
"=",
"prefix",
"(",
"name",
")",
";",
"Object",
"value",
"=",
"gauge",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"value",
"instanceof",
"Number",
")",
"{",
"if",
"(",
"!",
"snapshots",
".",
"hasDescriptor",
"(",
"prefixedName",
")",
")",
"{",
"snapshots",
".",
"setDescriptor",
"(",
"prefixedName",
",",
"MetricItem",
".",
"Builder",
".",
"create",
"(",
")",
".",
"count",
"(",
"\"gauge\"",
")",
".",
"build",
"(",
")",
")",
";",
"}",
"long",
"timestamp",
"=",
"getTimestamp",
"(",
")",
";",
"snapshots",
".",
"addSnapshot",
"(",
"prefixedName",
",",
"timestamp",
",",
"(",
"Map",
")",
"map",
"(",
"\"gauge\"",
",",
"value",
")",
")",
";",
"}",
"}"
] | Report a gauge using the field gauge. Only numeric values are used.
@param name
@param gauge | [
"Report",
"a",
"gauge",
"using",
"the",
"field",
"gauge",
".",
"Only",
"numeric",
"values",
"are",
"used",
"."
] | train | https://github.com/mp911de/visualizr/blob/57206391692e88b2c59d52d4f18faa4cdfd32a98/visualizr-metrics/src/main/java/biz/paluch/visualizr/metrics/VisualizrReporter.java#L231-L244 |
astrapi69/jaulp-wicket | jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/ajax/editable/tabs/AjaxAddableTabbedPanel.java | AjaxAddableTabbedPanel.newCloseLink | protected WebMarkupContainer newCloseLink(final String linkId, final int index) {
"""
Factory method for links used to close the selected tab.
The created component is attached to the following markup. Label component with id: title
will be added for you by the tabbed panel.
<pre>
<a href="#" wicket:id="link"><span wicket:id="title">[[tab title]]</span></a>
</pre>
Example implementation:
<pre>
protected WebMarkupContainer newCloseLink(String linkId, final int index)
{
return new Link(linkId)
{
private static final long serialVersionUID = 1L;
public void onClick()
{
setSelectedTab(index);
}
};
}
</pre>
@param linkId
component id with which the link should be created
@param index
index of the tab that should be activated when this link is clicked. See
{@link #setSelectedTab(int)}.
@return created link component
"""
return new AjaxFallbackLink<Void>(linkId)
{
private static final long serialVersionUID = 1L;
@Override
public void onClick(final AjaxRequestTarget target)
{
if (target != null)
{
onRemoveTab(target, index);
}
onAjaxUpdate(target);
}
};
} | java | protected WebMarkupContainer newCloseLink(final String linkId, final int index)
{
return new AjaxFallbackLink<Void>(linkId)
{
private static final long serialVersionUID = 1L;
@Override
public void onClick(final AjaxRequestTarget target)
{
if (target != null)
{
onRemoveTab(target, index);
}
onAjaxUpdate(target);
}
};
} | [
"protected",
"WebMarkupContainer",
"newCloseLink",
"(",
"final",
"String",
"linkId",
",",
"final",
"int",
"index",
")",
"{",
"return",
"new",
"AjaxFallbackLink",
"<",
"Void",
">",
"(",
"linkId",
")",
"{",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"@",
"Override",
"public",
"void",
"onClick",
"(",
"final",
"AjaxRequestTarget",
"target",
")",
"{",
"if",
"(",
"target",
"!=",
"null",
")",
"{",
"onRemoveTab",
"(",
"target",
",",
"index",
")",
";",
"}",
"onAjaxUpdate",
"(",
"target",
")",
";",
"}",
"}",
";",
"}"
] | Factory method for links used to close the selected tab.
The created component is attached to the following markup. Label component with id: title
will be added for you by the tabbed panel.
<pre>
<a href="#" wicket:id="link"><span wicket:id="title">[[tab title]]</span></a>
</pre>
Example implementation:
<pre>
protected WebMarkupContainer newCloseLink(String linkId, final int index)
{
return new Link(linkId)
{
private static final long serialVersionUID = 1L;
public void onClick()
{
setSelectedTab(index);
}
};
}
</pre>
@param linkId
component id with which the link should be created
@param index
index of the tab that should be activated when this link is clicked. See
{@link #setSelectedTab(int)}.
@return created link component | [
"Factory",
"method",
"for",
"links",
"used",
"to",
"close",
"the",
"selected",
"tab",
"."
] | train | https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/ajax/editable/tabs/AjaxAddableTabbedPanel.java#L392-L409 |
gliga/ekstazi | org.ekstazi.core/src/main/java/org/ekstazi/util/FileUtil.java | FileUtil.isSecondNewerThanFirst | public static boolean isSecondNewerThanFirst(File first, File second) {
"""
Checks if tool jar is newer than JUnit jar. If tool jar is newer, return
true; false otherwise.
"""
boolean isSecondNewerThanFirst = false;
// If file does not exist, it cannot be newer.
if (second.exists()) {
long firstLastModified = first.lastModified();
long secondLastModified = second.lastModified();
// 0L is returned if there was any error, so we check if both last
// modification stamps are != 0L.
if (firstLastModified != 0L && secondLastModified != 0L) {
isSecondNewerThanFirst = secondLastModified > firstLastModified;
}
}
return isSecondNewerThanFirst;
} | java | public static boolean isSecondNewerThanFirst(File first, File second) {
boolean isSecondNewerThanFirst = false;
// If file does not exist, it cannot be newer.
if (second.exists()) {
long firstLastModified = first.lastModified();
long secondLastModified = second.lastModified();
// 0L is returned if there was any error, so we check if both last
// modification stamps are != 0L.
if (firstLastModified != 0L && secondLastModified != 0L) {
isSecondNewerThanFirst = secondLastModified > firstLastModified;
}
}
return isSecondNewerThanFirst;
} | [
"public",
"static",
"boolean",
"isSecondNewerThanFirst",
"(",
"File",
"first",
",",
"File",
"second",
")",
"{",
"boolean",
"isSecondNewerThanFirst",
"=",
"false",
";",
"// If file does not exist, it cannot be newer.",
"if",
"(",
"second",
".",
"exists",
"(",
")",
")",
"{",
"long",
"firstLastModified",
"=",
"first",
".",
"lastModified",
"(",
")",
";",
"long",
"secondLastModified",
"=",
"second",
".",
"lastModified",
"(",
")",
";",
"// 0L is returned if there was any error, so we check if both last",
"// modification stamps are != 0L.",
"if",
"(",
"firstLastModified",
"!=",
"0L",
"&&",
"secondLastModified",
"!=",
"0L",
")",
"{",
"isSecondNewerThanFirst",
"=",
"secondLastModified",
">",
"firstLastModified",
";",
"}",
"}",
"return",
"isSecondNewerThanFirst",
";",
"}"
] | Checks if tool jar is newer than JUnit jar. If tool jar is newer, return
true; false otherwise. | [
"Checks",
"if",
"tool",
"jar",
"is",
"newer",
"than",
"JUnit",
"jar",
".",
"If",
"tool",
"jar",
"is",
"newer",
"return",
"true",
";",
"false",
"otherwise",
"."
] | train | https://github.com/gliga/ekstazi/blob/5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1/org.ekstazi.core/src/main/java/org/ekstazi/util/FileUtil.java#L93-L106 |
rzwitserloot/lombok | src/core/lombok/core/handlers/HandlerUtil.java | HandlerUtil.toWitherName | public static String toWitherName(AST<?, ?, ?> ast, AnnotationValues<Accessors> accessors, CharSequence fieldName, boolean isBoolean) {
"""
Generates a wither name from a given field name.
Strategy:
<ul>
<li>Reduce the field's name to its base name by stripping off any prefix (from {@code Accessors}). If the field name does not fit
the prefix list, this method immediately returns {@code null}.</li>
<li>Only if {@code isBoolean} is true: Check if the field starts with {@code is} followed by a non-lowercase character.
If so, replace {@code is} with {@code with} and return that.</li>
<li>Check if the first character of the field is lowercase. If so, check if the second character
exists and is title or upper case. If so, uppercase the first character. If not, titlecase the first character.</li>
<li>Return {@code "with"} plus the possibly title/uppercased first character, and the rest of the field name.</li>
</ul>
@param accessors Accessors configuration.
@param fieldName the name of the field.
@param isBoolean if the field is of type 'boolean'. For fields of type {@code java.lang.Boolean}, you should provide {@code false}.
@return The wither name for this field, or {@code null} if this field does not fit expected patterns and therefore cannot be turned into a getter name.
"""
return toAccessorName(ast, accessors, fieldName, isBoolean, "with", "with", false);
} | java | public static String toWitherName(AST<?, ?, ?> ast, AnnotationValues<Accessors> accessors, CharSequence fieldName, boolean isBoolean) {
return toAccessorName(ast, accessors, fieldName, isBoolean, "with", "with", false);
} | [
"public",
"static",
"String",
"toWitherName",
"(",
"AST",
"<",
"?",
",",
"?",
",",
"?",
">",
"ast",
",",
"AnnotationValues",
"<",
"Accessors",
">",
"accessors",
",",
"CharSequence",
"fieldName",
",",
"boolean",
"isBoolean",
")",
"{",
"return",
"toAccessorName",
"(",
"ast",
",",
"accessors",
",",
"fieldName",
",",
"isBoolean",
",",
"\"with\"",
",",
"\"with\"",
",",
"false",
")",
";",
"}"
] | Generates a wither name from a given field name.
Strategy:
<ul>
<li>Reduce the field's name to its base name by stripping off any prefix (from {@code Accessors}). If the field name does not fit
the prefix list, this method immediately returns {@code null}.</li>
<li>Only if {@code isBoolean} is true: Check if the field starts with {@code is} followed by a non-lowercase character.
If so, replace {@code is} with {@code with} and return that.</li>
<li>Check if the first character of the field is lowercase. If so, check if the second character
exists and is title or upper case. If so, uppercase the first character. If not, titlecase the first character.</li>
<li>Return {@code "with"} plus the possibly title/uppercased first character, and the rest of the field name.</li>
</ul>
@param accessors Accessors configuration.
@param fieldName the name of the field.
@param isBoolean if the field is of type 'boolean'. For fields of type {@code java.lang.Boolean}, you should provide {@code false}.
@return The wither name for this field, or {@code null} if this field does not fit expected patterns and therefore cannot be turned into a getter name. | [
"Generates",
"a",
"wither",
"name",
"from",
"a",
"given",
"field",
"name",
"."
] | train | https://github.com/rzwitserloot/lombok/blob/75601240760bd81ff95fcde7a1b8185769ce64e8/src/core/lombok/core/handlers/HandlerUtil.java#L519-L521 |
apache/incubator-gobblin | gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinClusterUtils.java | GobblinClusterUtils.getAppWorkDirPath | public static String getAppWorkDirPath(String applicationName, String applicationId) {
"""
Get the application working directory {@link String}.
@param applicationName the application name
@param applicationId the application ID in string form
@return the cluster application working directory {@link String}
"""
return applicationName + Path.SEPARATOR + applicationId;
} | java | public static String getAppWorkDirPath(String applicationName, String applicationId) {
return applicationName + Path.SEPARATOR + applicationId;
} | [
"public",
"static",
"String",
"getAppWorkDirPath",
"(",
"String",
"applicationName",
",",
"String",
"applicationId",
")",
"{",
"return",
"applicationName",
"+",
"Path",
".",
"SEPARATOR",
"+",
"applicationId",
";",
"}"
] | Get the application working directory {@link String}.
@param applicationName the application name
@param applicationId the application ID in string form
@return the cluster application working directory {@link String} | [
"Get",
"the",
"application",
"working",
"directory",
"{",
"@link",
"String",
"}",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinClusterUtils.java#L79-L81 |
googleads/googleads-java-lib | examples/admanager_axis/src/main/java/admanager/axis/v201902/teamservice/GetAllTeams.java | GetAllTeams.runExample | public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
throws RemoteException {
"""
Runs the example.
@param adManagerServices the services factory.
@param session the session.
@throws ApiException if the API request failed with one or more service errors.
@throws RemoteException if the API request failed due to other errors.
"""
// Get the TeamService.
TeamServiceInterface teamService = adManagerServices.get(session, TeamServiceInterface.class);
// Create a statement to select all teams.
StatementBuilder statementBuilder =
new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
// Default for total result set size.
int totalResultSetSize = 0;
do {
// Get teams by statement.
TeamPage page = teamService.getTeamsByStatement(statementBuilder.toStatement());
if (page.getResults() != null) {
totalResultSetSize = page.getTotalResultSetSize();
int i = page.getStartIndex();
for (Team team : page.getResults()) {
System.out.printf(
"%d) Team with ID %d and name '%s' was found.%n", i++, team.getId(), team.getName());
}
}
statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while (statementBuilder.getOffset() < totalResultSetSize);
System.out.printf("Number of results found: %d%n", totalResultSetSize);
} | java | public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
throws RemoteException {
// Get the TeamService.
TeamServiceInterface teamService = adManagerServices.get(session, TeamServiceInterface.class);
// Create a statement to select all teams.
StatementBuilder statementBuilder =
new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
// Default for total result set size.
int totalResultSetSize = 0;
do {
// Get teams by statement.
TeamPage page = teamService.getTeamsByStatement(statementBuilder.toStatement());
if (page.getResults() != null) {
totalResultSetSize = page.getTotalResultSetSize();
int i = page.getStartIndex();
for (Team team : page.getResults()) {
System.out.printf(
"%d) Team with ID %d and name '%s' was found.%n", i++, team.getId(), team.getName());
}
}
statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while (statementBuilder.getOffset() < totalResultSetSize);
System.out.printf("Number of results found: %d%n", totalResultSetSize);
} | [
"public",
"static",
"void",
"runExample",
"(",
"AdManagerServices",
"adManagerServices",
",",
"AdManagerSession",
"session",
")",
"throws",
"RemoteException",
"{",
"// Get the TeamService.",
"TeamServiceInterface",
"teamService",
"=",
"adManagerServices",
".",
"get",
"(",
"session",
",",
"TeamServiceInterface",
".",
"class",
")",
";",
"// Create a statement to select all teams.",
"StatementBuilder",
"statementBuilder",
"=",
"new",
"StatementBuilder",
"(",
")",
".",
"orderBy",
"(",
"\"id ASC\"",
")",
".",
"limit",
"(",
"StatementBuilder",
".",
"SUGGESTED_PAGE_LIMIT",
")",
";",
"// Default for total result set size.",
"int",
"totalResultSetSize",
"=",
"0",
";",
"do",
"{",
"// Get teams by statement.",
"TeamPage",
"page",
"=",
"teamService",
".",
"getTeamsByStatement",
"(",
"statementBuilder",
".",
"toStatement",
"(",
")",
")",
";",
"if",
"(",
"page",
".",
"getResults",
"(",
")",
"!=",
"null",
")",
"{",
"totalResultSetSize",
"=",
"page",
".",
"getTotalResultSetSize",
"(",
")",
";",
"int",
"i",
"=",
"page",
".",
"getStartIndex",
"(",
")",
";",
"for",
"(",
"Team",
"team",
":",
"page",
".",
"getResults",
"(",
")",
")",
"{",
"System",
".",
"out",
".",
"printf",
"(",
"\"%d) Team with ID %d and name '%s' was found.%n\"",
",",
"i",
"++",
",",
"team",
".",
"getId",
"(",
")",
",",
"team",
".",
"getName",
"(",
")",
")",
";",
"}",
"}",
"statementBuilder",
".",
"increaseOffsetBy",
"(",
"StatementBuilder",
".",
"SUGGESTED_PAGE_LIMIT",
")",
";",
"}",
"while",
"(",
"statementBuilder",
".",
"getOffset",
"(",
")",
"<",
"totalResultSetSize",
")",
";",
"System",
".",
"out",
".",
"printf",
"(",
"\"Number of results found: %d%n\"",
",",
"totalResultSetSize",
")",
";",
"}"
] | Runs the example.
@param adManagerServices the services factory.
@param session the session.
@throws ApiException if the API request failed with one or more service errors.
@throws RemoteException if the API request failed due to other errors. | [
"Runs",
"the",
"example",
"."
] | train | https://github.com/googleads/googleads-java-lib/blob/967957cc4f6076514e3a7926fe653e4f1f7cc9c9/examples/admanager_axis/src/main/java/admanager/axis/v201902/teamservice/GetAllTeams.java#L51-L80 |
SeleniumHQ/selenium | java/server/src/org/openqa/grid/common/RegistrationRequest.java | RegistrationRequest.fromJson | public static RegistrationRequest fromJson(Map<String, Object> raw) throws JsonException {
"""
Create an object from a registration request formatted as a json string.
"""
// If we could, we'd just get Json to coerce this for us, but that would lead to endless
// recursion as the first thing it would do would be to call this very method. *sigh*
Json json = new Json();
RegistrationRequest request = new RegistrationRequest();
if (raw.get("name") instanceof String) {
request.name = (String) raw.get("name");
}
if (raw.get("description") instanceof String) {
request.description = (String) raw.get("description");
}
if (raw.get("configuration") instanceof Map) {
// This is nasty. Look away now!
String converted = json.toJson(raw.get("configuration"));
request.configuration = GridConfiguredJson.toType(converted, GridNodeConfiguration.class);
}
if (raw.get("configuration") instanceof GridNodeConfiguration) {
request.configuration = (GridNodeConfiguration)raw.get("configuration");
}
return request;
} | java | public static RegistrationRequest fromJson(Map<String, Object> raw) throws JsonException {
// If we could, we'd just get Json to coerce this for us, but that would lead to endless
// recursion as the first thing it would do would be to call this very method. *sigh*
Json json = new Json();
RegistrationRequest request = new RegistrationRequest();
if (raw.get("name") instanceof String) {
request.name = (String) raw.get("name");
}
if (raw.get("description") instanceof String) {
request.description = (String) raw.get("description");
}
if (raw.get("configuration") instanceof Map) {
// This is nasty. Look away now!
String converted = json.toJson(raw.get("configuration"));
request.configuration = GridConfiguredJson.toType(converted, GridNodeConfiguration.class);
}
if (raw.get("configuration") instanceof GridNodeConfiguration) {
request.configuration = (GridNodeConfiguration)raw.get("configuration");
}
return request;
} | [
"public",
"static",
"RegistrationRequest",
"fromJson",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"raw",
")",
"throws",
"JsonException",
"{",
"// If we could, we'd just get Json to coerce this for us, but that would lead to endless",
"// recursion as the first thing it would do would be to call this very method. *sigh*",
"Json",
"json",
"=",
"new",
"Json",
"(",
")",
";",
"RegistrationRequest",
"request",
"=",
"new",
"RegistrationRequest",
"(",
")",
";",
"if",
"(",
"raw",
".",
"get",
"(",
"\"name\"",
")",
"instanceof",
"String",
")",
"{",
"request",
".",
"name",
"=",
"(",
"String",
")",
"raw",
".",
"get",
"(",
"\"name\"",
")",
";",
"}",
"if",
"(",
"raw",
".",
"get",
"(",
"\"description\"",
")",
"instanceof",
"String",
")",
"{",
"request",
".",
"description",
"=",
"(",
"String",
")",
"raw",
".",
"get",
"(",
"\"description\"",
")",
";",
"}",
"if",
"(",
"raw",
".",
"get",
"(",
"\"configuration\"",
")",
"instanceof",
"Map",
")",
"{",
"// This is nasty. Look away now!",
"String",
"converted",
"=",
"json",
".",
"toJson",
"(",
"raw",
".",
"get",
"(",
"\"configuration\"",
")",
")",
";",
"request",
".",
"configuration",
"=",
"GridConfiguredJson",
".",
"toType",
"(",
"converted",
",",
"GridNodeConfiguration",
".",
"class",
")",
";",
"}",
"if",
"(",
"raw",
".",
"get",
"(",
"\"configuration\"",
")",
"instanceof",
"GridNodeConfiguration",
")",
"{",
"request",
".",
"configuration",
"=",
"(",
"GridNodeConfiguration",
")",
"raw",
".",
"get",
"(",
"\"configuration\"",
")",
";",
"}",
"return",
"request",
";",
"}"
] | Create an object from a registration request formatted as a json string. | [
"Create",
"an",
"object",
"from",
"a",
"registration",
"request",
"formatted",
"as",
"a",
"json",
"string",
"."
] | train | https://github.com/SeleniumHQ/selenium/blob/7af172729f17b20269c8ca4ea6f788db48616535/java/server/src/org/openqa/grid/common/RegistrationRequest.java#L119-L144 |
Ordinastie/MalisisCore | src/main/java/net/malisis/core/inventory/MalisisInventoryContainer.java | MalisisInventoryContainer.handleDropSlot | private ItemStack handleDropSlot(MalisisSlot hoveredSlot, boolean fullStack) {
"""
Drops itemStack from hovering slot.
@param hoveredSlot the slot
@param fullStack the full stack
@return the item stack
"""
ItemStack itemStack = hoveredSlot.getItemStack();
if (itemStack.isEmpty() || !hoveredSlot.isState(PLAYER_EXTRACT))
return itemStack;
ItemUtils.ItemStackSplitter iss = new ItemUtils.ItemStackSplitter(hoveredSlot.getItemStack());
iss.split(fullStack ? ItemUtils.FULL_STACK : 1);
hoveredSlot.setItemStack(iss.source);
//if (slot.hasChanged())
hoveredSlot.onSlotChanged();
owner.dropItem(iss.split, true);
if (iss.amount != 0)
hoveredSlot.onPickupFromSlot(owner, iss.split);
return iss.split;
} | java | private ItemStack handleDropSlot(MalisisSlot hoveredSlot, boolean fullStack)
{
ItemStack itemStack = hoveredSlot.getItemStack();
if (itemStack.isEmpty() || !hoveredSlot.isState(PLAYER_EXTRACT))
return itemStack;
ItemUtils.ItemStackSplitter iss = new ItemUtils.ItemStackSplitter(hoveredSlot.getItemStack());
iss.split(fullStack ? ItemUtils.FULL_STACK : 1);
hoveredSlot.setItemStack(iss.source);
//if (slot.hasChanged())
hoveredSlot.onSlotChanged();
owner.dropItem(iss.split, true);
if (iss.amount != 0)
hoveredSlot.onPickupFromSlot(owner, iss.split);
return iss.split;
} | [
"private",
"ItemStack",
"handleDropSlot",
"(",
"MalisisSlot",
"hoveredSlot",
",",
"boolean",
"fullStack",
")",
"{",
"ItemStack",
"itemStack",
"=",
"hoveredSlot",
".",
"getItemStack",
"(",
")",
";",
"if",
"(",
"itemStack",
".",
"isEmpty",
"(",
")",
"||",
"!",
"hoveredSlot",
".",
"isState",
"(",
"PLAYER_EXTRACT",
")",
")",
"return",
"itemStack",
";",
"ItemUtils",
".",
"ItemStackSplitter",
"iss",
"=",
"new",
"ItemUtils",
".",
"ItemStackSplitter",
"(",
"hoveredSlot",
".",
"getItemStack",
"(",
")",
")",
";",
"iss",
".",
"split",
"(",
"fullStack",
"?",
"ItemUtils",
".",
"FULL_STACK",
":",
"1",
")",
";",
"hoveredSlot",
".",
"setItemStack",
"(",
"iss",
".",
"source",
")",
";",
"//if (slot.hasChanged())",
"hoveredSlot",
".",
"onSlotChanged",
"(",
")",
";",
"owner",
".",
"dropItem",
"(",
"iss",
".",
"split",
",",
"true",
")",
";",
"if",
"(",
"iss",
".",
"amount",
"!=",
"0",
")",
"hoveredSlot",
".",
"onPickupFromSlot",
"(",
"owner",
",",
"iss",
".",
"split",
")",
";",
"return",
"iss",
".",
"split",
";",
"}"
] | Drops itemStack from hovering slot.
@param hoveredSlot the slot
@param fullStack the full stack
@return the item stack | [
"Drops",
"itemStack",
"from",
"hovering",
"slot",
"."
] | train | https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/inventory/MalisisInventoryContainer.java#L579-L597 |
stratosphere/stratosphere | stratosphere-runtime/src/main/java/eu/stratosphere/pact/runtime/task/DataSourceTask.java | DataSourceTask.getLogString | private String getLogString(String message, String taskName) {
"""
Utility function that composes a string for logging purposes. The string includes the given message and
the index of the task in its task group together with the number of tasks in the task group.
@param message The main message for the log.
@param taskName The name of the task.
@return The string ready for logging.
"""
return RegularPactTask.constructLogString(message, taskName, this);
} | java | private String getLogString(String message, String taskName) {
return RegularPactTask.constructLogString(message, taskName, this);
} | [
"private",
"String",
"getLogString",
"(",
"String",
"message",
",",
"String",
"taskName",
")",
"{",
"return",
"RegularPactTask",
".",
"constructLogString",
"(",
"message",
",",
"taskName",
",",
"this",
")",
";",
"}"
] | Utility function that composes a string for logging purposes. The string includes the given message and
the index of the task in its task group together with the number of tasks in the task group.
@param message The main message for the log.
@param taskName The name of the task.
@return The string ready for logging. | [
"Utility",
"function",
"that",
"composes",
"a",
"string",
"for",
"logging",
"purposes",
".",
"The",
"string",
"includes",
"the",
"given",
"message",
"and",
"the",
"index",
"of",
"the",
"task",
"in",
"its",
"task",
"group",
"together",
"with",
"the",
"number",
"of",
"tasks",
"in",
"the",
"task",
"group",
"."
] | train | https://github.com/stratosphere/stratosphere/blob/c543a08f9676c5b2b0a7088123bd6e795a8ae0c8/stratosphere-runtime/src/main/java/eu/stratosphere/pact/runtime/task/DataSourceTask.java#L403-L405 |
evernote/evernote-sdk-android | library/src/main/java/com/evernote/client/android/EvernoteUtil.java | EvernoteUtil.getEvernoteInstallStatus | public static EvernoteInstallStatus getEvernoteInstallStatus(Context context, String action) {
"""
Checks if Evernote is installed and if the app can resolve this action.
"""
PackageManager packageManager = context.getPackageManager();
Intent intent = new Intent(action).setPackage(PACKAGE_NAME);
List<ResolveInfo> resolveInfos = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
if (!resolveInfos.isEmpty()) {
return validateSignature(packageManager);
}
try {
// authentication feature not available, yet
packageManager.getPackageInfo(PACKAGE_NAME, PackageManager.GET_ACTIVITIES);
return EvernoteInstallStatus.OLD_VERSION;
} catch (Exception e) {
return EvernoteInstallStatus.NOT_INSTALLED;
}
} | java | public static EvernoteInstallStatus getEvernoteInstallStatus(Context context, String action) {
PackageManager packageManager = context.getPackageManager();
Intent intent = new Intent(action).setPackage(PACKAGE_NAME);
List<ResolveInfo> resolveInfos = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
if (!resolveInfos.isEmpty()) {
return validateSignature(packageManager);
}
try {
// authentication feature not available, yet
packageManager.getPackageInfo(PACKAGE_NAME, PackageManager.GET_ACTIVITIES);
return EvernoteInstallStatus.OLD_VERSION;
} catch (Exception e) {
return EvernoteInstallStatus.NOT_INSTALLED;
}
} | [
"public",
"static",
"EvernoteInstallStatus",
"getEvernoteInstallStatus",
"(",
"Context",
"context",
",",
"String",
"action",
")",
"{",
"PackageManager",
"packageManager",
"=",
"context",
".",
"getPackageManager",
"(",
")",
";",
"Intent",
"intent",
"=",
"new",
"Intent",
"(",
"action",
")",
".",
"setPackage",
"(",
"PACKAGE_NAME",
")",
";",
"List",
"<",
"ResolveInfo",
">",
"resolveInfos",
"=",
"packageManager",
".",
"queryIntentActivities",
"(",
"intent",
",",
"PackageManager",
".",
"MATCH_DEFAULT_ONLY",
")",
";",
"if",
"(",
"!",
"resolveInfos",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"validateSignature",
"(",
"packageManager",
")",
";",
"}",
"try",
"{",
"// authentication feature not available, yet",
"packageManager",
".",
"getPackageInfo",
"(",
"PACKAGE_NAME",
",",
"PackageManager",
".",
"GET_ACTIVITIES",
")",
";",
"return",
"EvernoteInstallStatus",
".",
"OLD_VERSION",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"EvernoteInstallStatus",
".",
"NOT_INSTALLED",
";",
"}",
"}"
] | Checks if Evernote is installed and if the app can resolve this action. | [
"Checks",
"if",
"Evernote",
"is",
"installed",
"and",
"if",
"the",
"app",
"can",
"resolve",
"this",
"action",
"."
] | train | https://github.com/evernote/evernote-sdk-android/blob/fc59be643e85c4f59d562d1bfe76563997aa73cf/library/src/main/java/com/evernote/client/android/EvernoteUtil.java#L256-L273 |
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.examplesMethod | public List<LabelTextObject> examplesMethod(UUID appId, String versionId, String modelId, ExamplesMethodOptionalParameter examplesMethodOptionalParameter) {
"""
Gets the utterances for the given model in the given app version.
@param appId The application ID.
@param versionId The version ID.
@param modelId The ID (GUID) of the model.
@param examplesMethodOptionalParameter 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 List<LabelTextObject> object if successful.
"""
return examplesMethodWithServiceResponseAsync(appId, versionId, modelId, examplesMethodOptionalParameter).toBlocking().single().body();
} | java | public List<LabelTextObject> examplesMethod(UUID appId, String versionId, String modelId, ExamplesMethodOptionalParameter examplesMethodOptionalParameter) {
return examplesMethodWithServiceResponseAsync(appId, versionId, modelId, examplesMethodOptionalParameter).toBlocking().single().body();
} | [
"public",
"List",
"<",
"LabelTextObject",
">",
"examplesMethod",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"String",
"modelId",
",",
"ExamplesMethodOptionalParameter",
"examplesMethodOptionalParameter",
")",
"{",
"return",
"examplesMethodWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"modelId",
",",
"examplesMethodOptionalParameter",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Gets the utterances for the given model in the given app version.
@param appId The application ID.
@param versionId The version ID.
@param modelId The ID (GUID) of the model.
@param examplesMethodOptionalParameter 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 List<LabelTextObject> object if successful. | [
"Gets",
"the",
"utterances",
"for",
"the",
"given",
"model",
"in",
"the",
"given",
"app",
"version",
"."
] | 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#L2624-L2626 |
yanzhenjie/SwipeRecyclerView | x/src/main/java/com/yanzhenjie/recyclerview/SwipeMenuLayout.java | SwipeMenuLayout.getSwipeDuration | private int getSwipeDuration(MotionEvent ev, int velocity) {
"""
compute finish duration.
@param ev up event.
@param velocity velocity x.
@return finish duration.
"""
int sx = getScrollX();
int dx = (int)(ev.getX() - sx);
final int width = mSwipeCurrentHorizontal.getMenuWidth();
final int halfWidth = width / 2;
final float distanceRatio = Math.min(1f, 1.0f * Math.abs(dx) / width);
final float distance = halfWidth + halfWidth * distanceInfluenceForSnapDuration(distanceRatio);
int duration;
if (velocity > 0) {
duration = 4 * Math.round(1000 * Math.abs(distance / velocity));
} else {
final float pageDelta = (float)Math.abs(dx) / width;
duration = (int)((pageDelta + 1) * 100);
}
duration = Math.min(duration, mScrollerDuration);
return duration;
} | java | private int getSwipeDuration(MotionEvent ev, int velocity) {
int sx = getScrollX();
int dx = (int)(ev.getX() - sx);
final int width = mSwipeCurrentHorizontal.getMenuWidth();
final int halfWidth = width / 2;
final float distanceRatio = Math.min(1f, 1.0f * Math.abs(dx) / width);
final float distance = halfWidth + halfWidth * distanceInfluenceForSnapDuration(distanceRatio);
int duration;
if (velocity > 0) {
duration = 4 * Math.round(1000 * Math.abs(distance / velocity));
} else {
final float pageDelta = (float)Math.abs(dx) / width;
duration = (int)((pageDelta + 1) * 100);
}
duration = Math.min(duration, mScrollerDuration);
return duration;
} | [
"private",
"int",
"getSwipeDuration",
"(",
"MotionEvent",
"ev",
",",
"int",
"velocity",
")",
"{",
"int",
"sx",
"=",
"getScrollX",
"(",
")",
";",
"int",
"dx",
"=",
"(",
"int",
")",
"(",
"ev",
".",
"getX",
"(",
")",
"-",
"sx",
")",
";",
"final",
"int",
"width",
"=",
"mSwipeCurrentHorizontal",
".",
"getMenuWidth",
"(",
")",
";",
"final",
"int",
"halfWidth",
"=",
"width",
"/",
"2",
";",
"final",
"float",
"distanceRatio",
"=",
"Math",
".",
"min",
"(",
"1f",
",",
"1.0f",
"*",
"Math",
".",
"abs",
"(",
"dx",
")",
"/",
"width",
")",
";",
"final",
"float",
"distance",
"=",
"halfWidth",
"+",
"halfWidth",
"*",
"distanceInfluenceForSnapDuration",
"(",
"distanceRatio",
")",
";",
"int",
"duration",
";",
"if",
"(",
"velocity",
">",
"0",
")",
"{",
"duration",
"=",
"4",
"*",
"Math",
".",
"round",
"(",
"1000",
"*",
"Math",
".",
"abs",
"(",
"distance",
"/",
"velocity",
")",
")",
";",
"}",
"else",
"{",
"final",
"float",
"pageDelta",
"=",
"(",
"float",
")",
"Math",
".",
"abs",
"(",
"dx",
")",
"/",
"width",
";",
"duration",
"=",
"(",
"int",
")",
"(",
"(",
"pageDelta",
"+",
"1",
")",
"*",
"100",
")",
";",
"}",
"duration",
"=",
"Math",
".",
"min",
"(",
"duration",
",",
"mScrollerDuration",
")",
";",
"return",
"duration",
";",
"}"
] | compute finish duration.
@param ev up event.
@param velocity velocity x.
@return finish duration. | [
"compute",
"finish",
"duration",
"."
] | train | https://github.com/yanzhenjie/SwipeRecyclerView/blob/69aa14d05da09beaeb880240c62f7de6f4f1bb39/x/src/main/java/com/yanzhenjie/recyclerview/SwipeMenuLayout.java#L305-L321 |
couchbase/couchbase-java-client | src/main/java/com/couchbase/client/java/query/dsl/Expression.java | Expression.wrapWith | private static String wrapWith(char wrapper, String... input) {
"""
Helper method to wrap varargs with the given character.
@param wrapper the wrapper character.
@param input the input fields to wrap.
@return a concatenated string with characters wrapped.
"""
StringBuilder escaped = new StringBuilder();
for (String i : input) {
escaped.append(", ");
escaped.append(wrapper).append(i).append(wrapper);
}
if (escaped.length() > 2) {
escaped.delete(0, 2);
}
return escaped.toString();
} | java | private static String wrapWith(char wrapper, String... input) {
StringBuilder escaped = new StringBuilder();
for (String i : input) {
escaped.append(", ");
escaped.append(wrapper).append(i).append(wrapper);
}
if (escaped.length() > 2) {
escaped.delete(0, 2);
}
return escaped.toString();
} | [
"private",
"static",
"String",
"wrapWith",
"(",
"char",
"wrapper",
",",
"String",
"...",
"input",
")",
"{",
"StringBuilder",
"escaped",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"String",
"i",
":",
"input",
")",
"{",
"escaped",
".",
"append",
"(",
"\", \"",
")",
";",
"escaped",
".",
"append",
"(",
"wrapper",
")",
".",
"append",
"(",
"i",
")",
".",
"append",
"(",
"wrapper",
")",
";",
"}",
"if",
"(",
"escaped",
".",
"length",
"(",
")",
">",
"2",
")",
"{",
"escaped",
".",
"delete",
"(",
"0",
",",
"2",
")",
";",
"}",
"return",
"escaped",
".",
"toString",
"(",
")",
";",
"}"
] | Helper method to wrap varargs with the given character.
@param wrapper the wrapper character.
@param input the input fields to wrap.
@return a concatenated string with characters wrapped. | [
"Helper",
"method",
"to",
"wrap",
"varargs",
"with",
"the",
"given",
"character",
"."
] | train | https://github.com/couchbase/couchbase-java-client/blob/f36a0ee0c66923bdde47838ca543e50cbaa99e14/src/main/java/com/couchbase/client/java/query/dsl/Expression.java#L1886-L1896 |
casmi/casmi | src/main/java/casmi/image/Image.java | Image.getRed | public final double getRed(int x, int y) {
"""
Returns the red color value of the pixel data in this Image.
@param x
The x-coordinate of the pixel.
@param y
The y-coordinate of the pixel.
@return
The red color value of the pixel.
"""
int[] pixels = ((DataBufferInt)img.getRaster().getDataBuffer()).getData();
int idx = x + y * width;
return (pixels[idx] >> 16 & 0x000000ff);
} | java | public final double getRed(int x, int y) {
int[] pixels = ((DataBufferInt)img.getRaster().getDataBuffer()).getData();
int idx = x + y * width;
return (pixels[idx] >> 16 & 0x000000ff);
} | [
"public",
"final",
"double",
"getRed",
"(",
"int",
"x",
",",
"int",
"y",
")",
"{",
"int",
"[",
"]",
"pixels",
"=",
"(",
"(",
"DataBufferInt",
")",
"img",
".",
"getRaster",
"(",
")",
".",
"getDataBuffer",
"(",
")",
")",
".",
"getData",
"(",
")",
";",
"int",
"idx",
"=",
"x",
"+",
"y",
"*",
"width",
";",
"return",
"(",
"pixels",
"[",
"idx",
"]",
">>",
"16",
"&",
"0x000000ff",
")",
";",
"}"
] | Returns the red color value of the pixel data in this Image.
@param x
The x-coordinate of the pixel.
@param y
The y-coordinate of the pixel.
@return
The red color value of the pixel. | [
"Returns",
"the",
"red",
"color",
"value",
"of",
"the",
"pixel",
"data",
"in",
"this",
"Image",
"."
] | train | https://github.com/casmi/casmi/blob/90f6514a9cbce0685186e7a92beb69e22a3b11c4/src/main/java/casmi/image/Image.java#L271-L276 |
aeshell/aesh-readline | readline/src/main/java/org/aesh/readline/util/Parser.java | Parser.formatDisplayList | public static String formatDisplayList(String[] displayList, int termHeight, int termWidth) {
"""
Format completions so that they look similar to GNU Readline
@param displayList to format
@param termHeight max height
@param termWidth max width
@return formatted string to be outputted
"""
return formatDisplayList(Arrays.asList(displayList), termHeight, termWidth);
} | java | public static String formatDisplayList(String[] displayList, int termHeight, int termWidth) {
return formatDisplayList(Arrays.asList(displayList), termHeight, termWidth);
} | [
"public",
"static",
"String",
"formatDisplayList",
"(",
"String",
"[",
"]",
"displayList",
",",
"int",
"termHeight",
",",
"int",
"termWidth",
")",
"{",
"return",
"formatDisplayList",
"(",
"Arrays",
".",
"asList",
"(",
"displayList",
")",
",",
"termHeight",
",",
"termWidth",
")",
";",
"}"
] | Format completions so that they look similar to GNU Readline
@param displayList to format
@param termHeight max height
@param termWidth max width
@return formatted string to be outputted | [
"Format",
"completions",
"so",
"that",
"they",
"look",
"similar",
"to",
"GNU",
"Readline"
] | train | https://github.com/aeshell/aesh-readline/blob/3d7258f6490a422658ec85c8457514390c03232d/readline/src/main/java/org/aesh/readline/util/Parser.java#L60-L62 |
eFaps/eFaps-Kernel | src/main/java/org/efaps/db/Context.java | Context.getUserAttributes | public UserAttributesSet getUserAttributes()
throws EFapsException {
"""
Method to get the UserAttributesSet of the user of this context.
@return UserAttributesSet
@throws EFapsException on error
"""
if (containsSessionAttribute(UserAttributesSet.CONTEXTMAPKEY)) {
return (UserAttributesSet) getSessionAttribute(UserAttributesSet.CONTEXTMAPKEY);
} else {
throw new EFapsException(Context.class, "getUserAttributes.NoSessionAttribute");
}
} | java | public UserAttributesSet getUserAttributes()
throws EFapsException
{
if (containsSessionAttribute(UserAttributesSet.CONTEXTMAPKEY)) {
return (UserAttributesSet) getSessionAttribute(UserAttributesSet.CONTEXTMAPKEY);
} else {
throw new EFapsException(Context.class, "getUserAttributes.NoSessionAttribute");
}
} | [
"public",
"UserAttributesSet",
"getUserAttributes",
"(",
")",
"throws",
"EFapsException",
"{",
"if",
"(",
"containsSessionAttribute",
"(",
"UserAttributesSet",
".",
"CONTEXTMAPKEY",
")",
")",
"{",
"return",
"(",
"UserAttributesSet",
")",
"getSessionAttribute",
"(",
"UserAttributesSet",
".",
"CONTEXTMAPKEY",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"EFapsException",
"(",
"Context",
".",
"class",
",",
"\"getUserAttributes.NoSessionAttribute\"",
")",
";",
"}",
"}"
] | Method to get the UserAttributesSet of the user of this context.
@return UserAttributesSet
@throws EFapsException on error | [
"Method",
"to",
"get",
"the",
"UserAttributesSet",
"of",
"the",
"user",
"of",
"this",
"context",
"."
] | train | https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/db/Context.java#L703-L711 |
brunocvcunha/inutils4j | src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java | DateUtils.rollTime | public static java.sql.Time rollTime(java.util.Date startDate, int period, int amount) {
"""
Roll the java.util.Time forward or backward.
@param startDate - The start date
@param period Calendar.YEAR etc
@param amount - Negative to rollbackwards.
"""
GregorianCalendar gc = new GregorianCalendar();
gc.setTime(startDate);
gc.add(period, amount);
return new java.sql.Time(gc.getTime().getTime());
} | java | public static java.sql.Time rollTime(java.util.Date startDate, int period, int amount) {
GregorianCalendar gc = new GregorianCalendar();
gc.setTime(startDate);
gc.add(period, amount);
return new java.sql.Time(gc.getTime().getTime());
} | [
"public",
"static",
"java",
".",
"sql",
".",
"Time",
"rollTime",
"(",
"java",
".",
"util",
".",
"Date",
"startDate",
",",
"int",
"period",
",",
"int",
"amount",
")",
"{",
"GregorianCalendar",
"gc",
"=",
"new",
"GregorianCalendar",
"(",
")",
";",
"gc",
".",
"setTime",
"(",
"startDate",
")",
";",
"gc",
".",
"add",
"(",
"period",
",",
"amount",
")",
";",
"return",
"new",
"java",
".",
"sql",
".",
"Time",
"(",
"gc",
".",
"getTime",
"(",
")",
".",
"getTime",
"(",
")",
")",
";",
"}"
] | Roll the java.util.Time forward or backward.
@param startDate - The start date
@param period Calendar.YEAR etc
@param amount - Negative to rollbackwards. | [
"Roll",
"the",
"java",
".",
"util",
".",
"Time",
"forward",
"or",
"backward",
"."
] | train | https://github.com/brunocvcunha/inutils4j/blob/223c4443c2cee662576ce644e552588fa114aa94/src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java#L141-L146 |
fhoeben/hsac-fitnesse-fixtures | src/main/java/nl/hsac/fitnesse/fixture/util/selenium/by/GridBy.java | GridBy.getXPathForRowByValueInOtherColumn | public static String getXPathForRowByValueInOtherColumn(String selectIndex, String value) {
"""
Creates an XPath expression-segment that will find a row, selecting the row based on the
text in a specific column.
@param selectIndex index of the column to find value in (usually obtained via {@link #getXPathForColumnIndex(String)}).
@param value text to find in the column.
@return XPath expression selecting a tr in the table.
"""
return String.format("/tr[td[%1$s]/descendant-or-self::text()[normalized(.)='%2$s']]", selectIndex, value);
} | java | public static String getXPathForRowByValueInOtherColumn(String selectIndex, String value) {
return String.format("/tr[td[%1$s]/descendant-or-self::text()[normalized(.)='%2$s']]", selectIndex, value);
} | [
"public",
"static",
"String",
"getXPathForRowByValueInOtherColumn",
"(",
"String",
"selectIndex",
",",
"String",
"value",
")",
"{",
"return",
"String",
".",
"format",
"(",
"\"/tr[td[%1$s]/descendant-or-self::text()[normalized(.)='%2$s']]\"",
",",
"selectIndex",
",",
"value",
")",
";",
"}"
] | Creates an XPath expression-segment that will find a row, selecting the row based on the
text in a specific column.
@param selectIndex index of the column to find value in (usually obtained via {@link #getXPathForColumnIndex(String)}).
@param value text to find in the column.
@return XPath expression selecting a tr in the table. | [
"Creates",
"an",
"XPath",
"expression",
"-",
"segment",
"that",
"will",
"find",
"a",
"row",
"selecting",
"the",
"row",
"based",
"on",
"the",
"text",
"in",
"a",
"specific",
"column",
"."
] | train | https://github.com/fhoeben/hsac-fitnesse-fixtures/blob/4e9018d7386a9aa65bfcbf07eb28ae064edd1732/src/main/java/nl/hsac/fitnesse/fixture/util/selenium/by/GridBy.java#L65-L67 |
couchbase/couchbase-jvm-core | src/main/java/com/couchbase/client/core/config/loader/AbstractLoader.java | AbstractLoader.replaceHostWildcard | protected String replaceHostWildcard(String input, NetworkAddress hostname) {
"""
Replaces the host wildcard from an incoming config with a proper hostname.
@param input the input config.
@param hostname the hostname to replace it with.
@return a replaced configuration.
"""
return input.replace("$HOST", hostname.address());
} | java | protected String replaceHostWildcard(String input, NetworkAddress hostname) {
return input.replace("$HOST", hostname.address());
} | [
"protected",
"String",
"replaceHostWildcard",
"(",
"String",
"input",
",",
"NetworkAddress",
"hostname",
")",
"{",
"return",
"input",
".",
"replace",
"(",
"\"$HOST\"",
",",
"hostname",
".",
"address",
"(",
")",
")",
";",
"}"
] | Replaces the host wildcard from an incoming config with a proper hostname.
@param input the input config.
@param hostname the hostname to replace it with.
@return a replaced configuration. | [
"Replaces",
"the",
"host",
"wildcard",
"from",
"an",
"incoming",
"config",
"with",
"a",
"proper",
"hostname",
"."
] | train | https://github.com/couchbase/couchbase-jvm-core/blob/97f0427112c2168fee1d6499904f5fa0e24c6797/src/main/java/com/couchbase/client/core/config/loader/AbstractLoader.java#L237-L239 |
http-builder-ng/http-builder-ng | http-builder-ng-core/src/main/java/groovyx/net/http/HttpBuilder.java | HttpBuilder.headAsync | public CompletableFuture<Object> headAsync(final Consumer<HttpConfig> configuration) {
"""
Executes an asynchronous HEAD request on the configured URI (asynchronous alias to `head(Consumer)`), with additional configuration provided by the
configuration function.
This method is generally used for Java-specific configuration.
[source,java]
----
HttpBuilder http = HttpBuilder.configure(config -> {
config.getRequest().setUri("http://localhost:10101");
});
CompletableFuture<Object> future = http.headAsync(config -> {
config.getRequest().getUri().setPath("/foo");
});
Object result = future.get();
----
The `configuration` function allows additional configuration for this request based on the {@link HttpConfig} interface.
@param configuration the additional configuration closure (delegated to {@link HttpConfig})
@return the resulting content wrapped in a {@link CompletableFuture}
"""
return CompletableFuture.supplyAsync(() -> head(configuration), getExecutor());
} | java | public CompletableFuture<Object> headAsync(final Consumer<HttpConfig> configuration) {
return CompletableFuture.supplyAsync(() -> head(configuration), getExecutor());
} | [
"public",
"CompletableFuture",
"<",
"Object",
">",
"headAsync",
"(",
"final",
"Consumer",
"<",
"HttpConfig",
">",
"configuration",
")",
"{",
"return",
"CompletableFuture",
".",
"supplyAsync",
"(",
"(",
")",
"->",
"head",
"(",
"configuration",
")",
",",
"getExecutor",
"(",
")",
")",
";",
"}"
] | Executes an asynchronous HEAD request on the configured URI (asynchronous alias to `head(Consumer)`), with additional configuration provided by the
configuration function.
This method is generally used for Java-specific configuration.
[source,java]
----
HttpBuilder http = HttpBuilder.configure(config -> {
config.getRequest().setUri("http://localhost:10101");
});
CompletableFuture<Object> future = http.headAsync(config -> {
config.getRequest().getUri().setPath("/foo");
});
Object result = future.get();
----
The `configuration` function allows additional configuration for this request based on the {@link HttpConfig} interface.
@param configuration the additional configuration closure (delegated to {@link HttpConfig})
@return the resulting content wrapped in a {@link CompletableFuture} | [
"Executes",
"an",
"asynchronous",
"HEAD",
"request",
"on",
"the",
"configured",
"URI",
"(",
"asynchronous",
"alias",
"to",
"head",
"(",
"Consumer",
")",
")",
"with",
"additional",
"configuration",
"provided",
"by",
"the",
"configuration",
"function",
"."
] | train | https://github.com/http-builder-ng/http-builder-ng/blob/865f37732c102c748d3db8b905199dac9222a525/http-builder-ng-core/src/main/java/groovyx/net/http/HttpBuilder.java#L631-L633 |
googleapis/cloud-bigtable-client | bigtable-client-core-parent/bigtable-client-core/src/main/java/com/google/cloud/bigtable/grpc/BigtableSession.java | BigtableSession.createManagedPool | protected ManagedChannel createManagedPool(String host, int channelCount) throws IOException {
"""
Create a new {@link com.google.cloud.bigtable.grpc.io.ChannelPool}, with auth headers, that
will be cleaned up when the connection closes.
@param host a {@link java.lang.String} object.
@return a {@link com.google.cloud.bigtable.grpc.io.ChannelPool} object.
@throws java.io.IOException if any.
"""
ManagedChannel channelPool = createChannelPool(host, channelCount);
managedChannels.add(channelPool);
return channelPool;
} | java | protected ManagedChannel createManagedPool(String host, int channelCount) throws IOException {
ManagedChannel channelPool = createChannelPool(host, channelCount);
managedChannels.add(channelPool);
return channelPool;
} | [
"protected",
"ManagedChannel",
"createManagedPool",
"(",
"String",
"host",
",",
"int",
"channelCount",
")",
"throws",
"IOException",
"{",
"ManagedChannel",
"channelPool",
"=",
"createChannelPool",
"(",
"host",
",",
"channelCount",
")",
";",
"managedChannels",
".",
"add",
"(",
"channelPool",
")",
";",
"return",
"channelPool",
";",
"}"
] | Create a new {@link com.google.cloud.bigtable.grpc.io.ChannelPool}, with auth headers, that
will be cleaned up when the connection closes.
@param host a {@link java.lang.String} object.
@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",
"that",
"will",
"be",
"cleaned",
"up",
"when",
"the",
"connection",
"closes",
"."
] | 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#L533-L537 |
ironjacamar/ironjacamar | rarinfo/src/main/java/org/ironjacamar/rarinfo/Main.java | Main.removeIntrospectedValue | private static void removeIntrospectedValue(Map<String, String> m, String name) {
"""
Remove introspected value
@param m The map
@param name The name
"""
if (m != null)
{
m.remove(name);
if (name.length() == 1)
{
name = name.toUpperCase(Locale.US);
}
else
{
name = name.substring(0, 1).toUpperCase(Locale.US) + name.substring(1);
}
m.remove(name);
if (name.length() == 1)
{
name = name.toLowerCase(Locale.US);
}
else
{
name = name.substring(0, 1).toLowerCase(Locale.US) + name.substring(1);
}
m.remove(name);
}
} | java | private static void removeIntrospectedValue(Map<String, String> m, String name)
{
if (m != null)
{
m.remove(name);
if (name.length() == 1)
{
name = name.toUpperCase(Locale.US);
}
else
{
name = name.substring(0, 1).toUpperCase(Locale.US) + name.substring(1);
}
m.remove(name);
if (name.length() == 1)
{
name = name.toLowerCase(Locale.US);
}
else
{
name = name.substring(0, 1).toLowerCase(Locale.US) + name.substring(1);
}
m.remove(name);
}
} | [
"private",
"static",
"void",
"removeIntrospectedValue",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"m",
",",
"String",
"name",
")",
"{",
"if",
"(",
"m",
"!=",
"null",
")",
"{",
"m",
".",
"remove",
"(",
"name",
")",
";",
"if",
"(",
"name",
".",
"length",
"(",
")",
"==",
"1",
")",
"{",
"name",
"=",
"name",
".",
"toUpperCase",
"(",
"Locale",
".",
"US",
")",
";",
"}",
"else",
"{",
"name",
"=",
"name",
".",
"substring",
"(",
"0",
",",
"1",
")",
".",
"toUpperCase",
"(",
"Locale",
".",
"US",
")",
"+",
"name",
".",
"substring",
"(",
"1",
")",
";",
"}",
"m",
".",
"remove",
"(",
"name",
")",
";",
"if",
"(",
"name",
".",
"length",
"(",
")",
"==",
"1",
")",
"{",
"name",
"=",
"name",
".",
"toLowerCase",
"(",
"Locale",
".",
"US",
")",
";",
"}",
"else",
"{",
"name",
"=",
"name",
".",
"substring",
"(",
"0",
",",
"1",
")",
".",
"toLowerCase",
"(",
"Locale",
".",
"US",
")",
"+",
"name",
".",
"substring",
"(",
"1",
")",
";",
"}",
"m",
".",
"remove",
"(",
"name",
")",
";",
"}",
"}"
] | Remove introspected value
@param m The map
@param name The name | [
"Remove",
"introspected",
"value"
] | train | https://github.com/ironjacamar/ironjacamar/blob/f0389ee7e62aa8b40ba09b251edad76d220ea796/rarinfo/src/main/java/org/ironjacamar/rarinfo/Main.java#L1389-L1417 |
alkacon/opencms-core | src/org/opencms/staticexport/CmsLinkProcessor.java | CmsLinkProcessor.processLinks | public String processLinks(String content) throws ParserException {
"""
Starts link processing for the given content in processing mode.<p>
Macros are replaced by links.<p>
@param content the content to process
@return the processed content with replaced macros
@throws ParserException if something goes wrong
"""
m_mode = PROCESS_LINKS;
return process(content, m_encoding);
} | java | public String processLinks(String content) throws ParserException {
m_mode = PROCESS_LINKS;
return process(content, m_encoding);
} | [
"public",
"String",
"processLinks",
"(",
"String",
"content",
")",
"throws",
"ParserException",
"{",
"m_mode",
"=",
"PROCESS_LINKS",
";",
"return",
"process",
"(",
"content",
",",
"m_encoding",
")",
";",
"}"
] | Starts link processing for the given content in processing mode.<p>
Macros are replaced by links.<p>
@param content the content to process
@return the processed content with replaced macros
@throws ParserException if something goes wrong | [
"Starts",
"link",
"processing",
"for",
"the",
"given",
"content",
"in",
"processing",
"mode",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/staticexport/CmsLinkProcessor.java#L216-L220 |
aws/aws-sdk-java | src/samples/AmazonEC2SpotInstances-Advanced/Requests.java | Requests.init | private void init(String instanceType, String amiID, String bidPrice, String securityGroup) throws Exception {
"""
The only information needed to create a client are security credentials
consisting of the AWS Access Key ID and Secret Access Key. All other
configuration, such as the service endpoints, are performed
automatically. Client parameters, such as proxies, can be specified in an
optional ClientConfiguration object when constructing a client.
@see com.amazonaws.auth.BasicAWSCredentials
@see com.amazonaws.auth.PropertiesCredentials
@see com.amazonaws.ClientConfiguration
"""
/*
* The ProfileCredentialsProvider will return your [default]
* credential profile by reading from the credentials file located at
* (~/.aws/credentials).
*/
AWSCredentials credentials = null;
try {
credentials = new ProfileCredentialsProvider().getCredentials();
} catch (Exception e) {
throw new AmazonClientException(
"Cannot load the credentials from the credential profiles file. " +
"Please make sure that your credentials file is at the correct " +
"location (~/.aws/credentials), and is in valid format.",
e);
}
ec2 = AmazonEC2ClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(credentials))
.withRegion("us-west-2")
.build();
this.instanceType = instanceType;
this.amiID = amiID;
this.bidPrice = bidPrice;
this.securityGroup = securityGroup;
this.deleteOnTermination = true;
this.placementGroupName = null;
} | java | private void init(String instanceType, String amiID, String bidPrice, String securityGroup) throws Exception {
/*
* The ProfileCredentialsProvider will return your [default]
* credential profile by reading from the credentials file located at
* (~/.aws/credentials).
*/
AWSCredentials credentials = null;
try {
credentials = new ProfileCredentialsProvider().getCredentials();
} catch (Exception e) {
throw new AmazonClientException(
"Cannot load the credentials from the credential profiles file. " +
"Please make sure that your credentials file is at the correct " +
"location (~/.aws/credentials), and is in valid format.",
e);
}
ec2 = AmazonEC2ClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(credentials))
.withRegion("us-west-2")
.build();
this.instanceType = instanceType;
this.amiID = amiID;
this.bidPrice = bidPrice;
this.securityGroup = securityGroup;
this.deleteOnTermination = true;
this.placementGroupName = null;
} | [
"private",
"void",
"init",
"(",
"String",
"instanceType",
",",
"String",
"amiID",
",",
"String",
"bidPrice",
",",
"String",
"securityGroup",
")",
"throws",
"Exception",
"{",
"/*\r\n * The ProfileCredentialsProvider will return your [default]\r\n * credential profile by reading from the credentials file located at\r\n * (~/.aws/credentials).\r\n */",
"AWSCredentials",
"credentials",
"=",
"null",
";",
"try",
"{",
"credentials",
"=",
"new",
"ProfileCredentialsProvider",
"(",
")",
".",
"getCredentials",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"AmazonClientException",
"(",
"\"Cannot load the credentials from the credential profiles file. \"",
"+",
"\"Please make sure that your credentials file is at the correct \"",
"+",
"\"location (~/.aws/credentials), and is in valid format.\"",
",",
"e",
")",
";",
"}",
"ec2",
"=",
"AmazonEC2ClientBuilder",
".",
"standard",
"(",
")",
".",
"withCredentials",
"(",
"new",
"AWSStaticCredentialsProvider",
"(",
"credentials",
")",
")",
".",
"withRegion",
"(",
"\"us-west-2\"",
")",
".",
"build",
"(",
")",
";",
"this",
".",
"instanceType",
"=",
"instanceType",
";",
"this",
".",
"amiID",
"=",
"amiID",
";",
"this",
".",
"bidPrice",
"=",
"bidPrice",
";",
"this",
".",
"securityGroup",
"=",
"securityGroup",
";",
"this",
".",
"deleteOnTermination",
"=",
"true",
";",
"this",
".",
"placementGroupName",
"=",
"null",
";",
"}"
] | The only information needed to create a client are security credentials
consisting of the AWS Access Key ID and Secret Access Key. All other
configuration, such as the service endpoints, are performed
automatically. Client parameters, such as proxies, can be specified in an
optional ClientConfiguration object when constructing a client.
@see com.amazonaws.auth.BasicAWSCredentials
@see com.amazonaws.auth.PropertiesCredentials
@see com.amazonaws.ClientConfiguration | [
"The",
"only",
"information",
"needed",
"to",
"create",
"a",
"client",
"are",
"security",
"credentials",
"consisting",
"of",
"the",
"AWS",
"Access",
"Key",
"ID",
"and",
"Secret",
"Access",
"Key",
".",
"All",
"other",
"configuration",
"such",
"as",
"the",
"service",
"endpoints",
"are",
"performed",
"automatically",
".",
"Client",
"parameters",
"such",
"as",
"proxies",
"can",
"be",
"specified",
"in",
"an",
"optional",
"ClientConfiguration",
"object",
"when",
"constructing",
"a",
"client",
"."
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/src/samples/AmazonEC2SpotInstances-Advanced/Requests.java#L82-L110 |
jbossas/jboss-invocation | src/main/java/org/jboss/invocation/proxy/AbstractSubclassFactory.java | AbstractSubclassFactory.overrideMethod | protected boolean overrideMethod(Method method, MethodIdentifier identifier, MethodBodyCreator creator) {
"""
Creates a new method on the generated class that overrides the given methods, unless a method with the same signature has
already been overridden.
@param method The method to override
@param identifier The identifier of the method to override
@param creator The {@link MethodBodyCreator} used to create the method body
@return {@code true} if the method was successfully overridden, {@code false} otherwise
"""
if (!overriddenMethods.contains(identifier)) {
overriddenMethods.add(identifier);
creator.overrideMethod(classFile.addMethod(method), method);
return true;
}
return false;
} | java | protected boolean overrideMethod(Method method, MethodIdentifier identifier, MethodBodyCreator creator) {
if (!overriddenMethods.contains(identifier)) {
overriddenMethods.add(identifier);
creator.overrideMethod(classFile.addMethod(method), method);
return true;
}
return false;
} | [
"protected",
"boolean",
"overrideMethod",
"(",
"Method",
"method",
",",
"MethodIdentifier",
"identifier",
",",
"MethodBodyCreator",
"creator",
")",
"{",
"if",
"(",
"!",
"overriddenMethods",
".",
"contains",
"(",
"identifier",
")",
")",
"{",
"overriddenMethods",
".",
"add",
"(",
"identifier",
")",
";",
"creator",
".",
"overrideMethod",
"(",
"classFile",
".",
"addMethod",
"(",
"method",
")",
",",
"method",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Creates a new method on the generated class that overrides the given methods, unless a method with the same signature has
already been overridden.
@param method The method to override
@param identifier The identifier of the method to override
@param creator The {@link MethodBodyCreator} used to create the method body
@return {@code true} if the method was successfully overridden, {@code false} otherwise | [
"Creates",
"a",
"new",
"method",
"on",
"the",
"generated",
"class",
"that",
"overrides",
"the",
"given",
"methods",
"unless",
"a",
"method",
"with",
"the",
"same",
"signature",
"has",
"already",
"been",
"overridden",
"."
] | train | https://github.com/jbossas/jboss-invocation/blob/f72586a554264cbc78fcdad9fdd3e84b833249c9/src/main/java/org/jboss/invocation/proxy/AbstractSubclassFactory.java#L116-L123 |
LearnLib/automatalib | incremental/src/main/java/net/automatalib/incremental/dfa/dag/AbstractIncrementalDFADAGBuilder.java | AbstractIncrementalDFADAGBuilder.updateSignature | protected State updateSignature(State state, Acceptance acc) {
"""
Updates the signature for a given state.
@param state
the state
@param acc
the new acceptance value
@return the canonical state for the updated signature
"""
assert (state != init);
StateSignature sig = state.getSignature();
if (sig.acceptance == acc) {
return state;
}
register.remove(sig);
sig.acceptance = acc;
sig.updateHashCode();
return replaceOrRegister(state);
} | java | protected State updateSignature(State state, Acceptance acc) {
assert (state != init);
StateSignature sig = state.getSignature();
if (sig.acceptance == acc) {
return state;
}
register.remove(sig);
sig.acceptance = acc;
sig.updateHashCode();
return replaceOrRegister(state);
} | [
"protected",
"State",
"updateSignature",
"(",
"State",
"state",
",",
"Acceptance",
"acc",
")",
"{",
"assert",
"(",
"state",
"!=",
"init",
")",
";",
"StateSignature",
"sig",
"=",
"state",
".",
"getSignature",
"(",
")",
";",
"if",
"(",
"sig",
".",
"acceptance",
"==",
"acc",
")",
"{",
"return",
"state",
";",
"}",
"register",
".",
"remove",
"(",
"sig",
")",
";",
"sig",
".",
"acceptance",
"=",
"acc",
";",
"sig",
".",
"updateHashCode",
"(",
")",
";",
"return",
"replaceOrRegister",
"(",
"state",
")",
";",
"}"
] | Updates the signature for a given state.
@param state
the state
@param acc
the new acceptance value
@return the canonical state for the updated signature | [
"Updates",
"the",
"signature",
"for",
"a",
"given",
"state",
"."
] | train | https://github.com/LearnLib/automatalib/blob/8a462ec52f6eaab9f8996e344f2163a72cb8aa6e/incremental/src/main/java/net/automatalib/incremental/dfa/dag/AbstractIncrementalDFADAGBuilder.java#L246-L256 |
alibaba/canal | client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/config/bind/RelaxedDataBinder.java | RelaxedDataBinder.setNameAliases | public void setNameAliases(Map<String, List<String>> aliases) {
"""
Set name aliases.
@param aliases a map of property name to aliases
"""
this.nameAliases = new LinkedMultiValueMap<String, String>(aliases);
} | java | public void setNameAliases(Map<String, List<String>> aliases) {
this.nameAliases = new LinkedMultiValueMap<String, String>(aliases);
} | [
"public",
"void",
"setNameAliases",
"(",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"aliases",
")",
"{",
"this",
".",
"nameAliases",
"=",
"new",
"LinkedMultiValueMap",
"<",
"String",
",",
"String",
">",
"(",
"aliases",
")",
";",
"}"
] | Set name aliases.
@param aliases a map of property name to aliases | [
"Set",
"name",
"aliases",
"."
] | train | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/config/bind/RelaxedDataBinder.java#L91-L93 |
joniles/mpxj | src/main/java/net/sf/mpxj/mpx/MPXReader.java | MPXReader.populateFileCreationRecord | static void populateFileCreationRecord(Record record, ProjectProperties properties) {
"""
Populate a file creation record.
@param record MPX record
@param properties project properties
"""
properties.setMpxProgramName(record.getString(0));
properties.setMpxFileVersion(FileVersion.getInstance(record.getString(1)));
properties.setMpxCodePage(record.getCodePage(2));
} | java | static void populateFileCreationRecord(Record record, ProjectProperties properties)
{
properties.setMpxProgramName(record.getString(0));
properties.setMpxFileVersion(FileVersion.getInstance(record.getString(1)));
properties.setMpxCodePage(record.getCodePage(2));
} | [
"static",
"void",
"populateFileCreationRecord",
"(",
"Record",
"record",
",",
"ProjectProperties",
"properties",
")",
"{",
"properties",
".",
"setMpxProgramName",
"(",
"record",
".",
"getString",
"(",
"0",
")",
")",
";",
"properties",
".",
"setMpxFileVersion",
"(",
"FileVersion",
".",
"getInstance",
"(",
"record",
".",
"getString",
"(",
"1",
")",
")",
")",
";",
"properties",
".",
"setMpxCodePage",
"(",
"record",
".",
"getCodePage",
"(",
"2",
")",
")",
";",
"}"
] | Populate a file creation record.
@param record MPX record
@param properties project properties | [
"Populate",
"a",
"file",
"creation",
"record",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpx/MPXReader.java#L1474-L1479 |
czyzby/gdx-lml | kiwi/src/main/java/com/github/czyzby/kiwi/util/gdx/reflection/Reflection.java | Reflection.getAnnotation | public static <Type extends Annotation> Type getAnnotation(final Method method, final Class<Type> annotationType) {
"""
Utility method that allows to extract actual annotation from method, bypassing LibGDX annotation wrapper.
Returns null if annotation is not present.
@param method method that might be annotated.
@param annotationType class of the annotation.
@return an instance of the annotation if the method is annotated or null if not.
@param <Type> type of annotation.
"""
if (isAnnotationPresent(method, annotationType)) {
return method.getDeclaredAnnotation(annotationType).getAnnotation(annotationType);
}
return null;
} | java | public static <Type extends Annotation> Type getAnnotation(final Method method, final Class<Type> annotationType) {
if (isAnnotationPresent(method, annotationType)) {
return method.getDeclaredAnnotation(annotationType).getAnnotation(annotationType);
}
return null;
} | [
"public",
"static",
"<",
"Type",
"extends",
"Annotation",
">",
"Type",
"getAnnotation",
"(",
"final",
"Method",
"method",
",",
"final",
"Class",
"<",
"Type",
">",
"annotationType",
")",
"{",
"if",
"(",
"isAnnotationPresent",
"(",
"method",
",",
"annotationType",
")",
")",
"{",
"return",
"method",
".",
"getDeclaredAnnotation",
"(",
"annotationType",
")",
".",
"getAnnotation",
"(",
"annotationType",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Utility method that allows to extract actual annotation from method, bypassing LibGDX annotation wrapper.
Returns null if annotation is not present.
@param method method that might be annotated.
@param annotationType class of the annotation.
@return an instance of the annotation if the method is annotated or null if not.
@param <Type> type of annotation. | [
"Utility",
"method",
"that",
"allows",
"to",
"extract",
"actual",
"annotation",
"from",
"method",
"bypassing",
"LibGDX",
"annotation",
"wrapper",
".",
"Returns",
"null",
"if",
"annotation",
"is",
"not",
"present",
"."
] | train | https://github.com/czyzby/gdx-lml/blob/7623b322e6afe49ad4dd636c80c230150a1cfa4e/kiwi/src/main/java/com/github/czyzby/kiwi/util/gdx/reflection/Reflection.java#L106-L111 |
artikcloud/artikcloud-java | src/main/java/cloud/artik/api/UsersApi.java | UsersApi.getUserDeviceTypes | public DeviceTypesEnvelope getUserDeviceTypes(String userId, Integer offset, Integer count, Boolean includeShared) throws ApiException {
"""
Get User Device Types
Retrieve User's Device Types
@param userId User ID. (required)
@param offset Offset for pagination. (optional)
@param count Desired count of items in the result set (optional)
@param includeShared Optional. Boolean (true/false) - If false, only return the user's device types. If true, also return device types shared by other users. (optional)
@return DeviceTypesEnvelope
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
"""
ApiResponse<DeviceTypesEnvelope> resp = getUserDeviceTypesWithHttpInfo(userId, offset, count, includeShared);
return resp.getData();
} | java | public DeviceTypesEnvelope getUserDeviceTypes(String userId, Integer offset, Integer count, Boolean includeShared) throws ApiException {
ApiResponse<DeviceTypesEnvelope> resp = getUserDeviceTypesWithHttpInfo(userId, offset, count, includeShared);
return resp.getData();
} | [
"public",
"DeviceTypesEnvelope",
"getUserDeviceTypes",
"(",
"String",
"userId",
",",
"Integer",
"offset",
",",
"Integer",
"count",
",",
"Boolean",
"includeShared",
")",
"throws",
"ApiException",
"{",
"ApiResponse",
"<",
"DeviceTypesEnvelope",
">",
"resp",
"=",
"getUserDeviceTypesWithHttpInfo",
"(",
"userId",
",",
"offset",
",",
"count",
",",
"includeShared",
")",
";",
"return",
"resp",
".",
"getData",
"(",
")",
";",
"}"
] | Get User Device Types
Retrieve User's Device Types
@param userId User ID. (required)
@param offset Offset for pagination. (optional)
@param count Desired count of items in the result set (optional)
@param includeShared Optional. Boolean (true/false) - If false, only return the user's device types. If true, also return device types shared by other users. (optional)
@return DeviceTypesEnvelope
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body | [
"Get",
"User",
"Device",
"Types",
"Retrieve",
"User'",
";",
"s",
"Device",
"Types"
] | train | https://github.com/artikcloud/artikcloud-java/blob/412f447573e7796ab4f685c0bdd5eb76185a365c/src/main/java/cloud/artik/api/UsersApi.java#L505-L508 |
j256/simplejmx | src/main/java/com/j256/simplejmx/client/JmxClient.java | JmxClient.getOperationsInfo | public MBeanOperationInfo[] getOperationsInfo(ObjectName name) throws JMException {
"""
Return an array of the operations associated with the bean name.
"""
checkClientConnected();
try {
return mbeanConn.getMBeanInfo(name).getOperations();
} catch (Exception e) {
throw createJmException("Problems getting bean information from " + name, e);
}
} | java | public MBeanOperationInfo[] getOperationsInfo(ObjectName name) throws JMException {
checkClientConnected();
try {
return mbeanConn.getMBeanInfo(name).getOperations();
} catch (Exception e) {
throw createJmException("Problems getting bean information from " + name, e);
}
} | [
"public",
"MBeanOperationInfo",
"[",
"]",
"getOperationsInfo",
"(",
"ObjectName",
"name",
")",
"throws",
"JMException",
"{",
"checkClientConnected",
"(",
")",
";",
"try",
"{",
"return",
"mbeanConn",
".",
"getMBeanInfo",
"(",
"name",
")",
".",
"getOperations",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"createJmException",
"(",
"\"Problems getting bean information from \"",
"+",
"name",
",",
"e",
")",
";",
"}",
"}"
] | Return an array of the operations associated with the bean name. | [
"Return",
"an",
"array",
"of",
"the",
"operations",
"associated",
"with",
"the",
"bean",
"name",
"."
] | train | https://github.com/j256/simplejmx/blob/1a04f52512dfa0a711ba0cc7023c604dbc82a352/src/main/java/com/j256/simplejmx/client/JmxClient.java#L274-L281 |
BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/TextDuplicator.java | TextDuplicator.setupUI | private void setupUI(final String labelText) {
"""
Add the controls to the UI.
@param labelText the text to show in the duplicator field's label.
"""
WButton dupBtn = new WButton("Duplicate");
dupBtn.setAction(new DuplicateAction());
WButton clrBtn = new WButton("Clear");
clrBtn.setAction(new ClearAction());
add(new WLabel(labelText, textFld));
add(textFld);
add(dupBtn);
add(clrBtn);
add(new WAjaxControl(dupBtn, this));
add(new WAjaxControl(clrBtn, this));
} | java | private void setupUI(final String labelText) {
WButton dupBtn = new WButton("Duplicate");
dupBtn.setAction(new DuplicateAction());
WButton clrBtn = new WButton("Clear");
clrBtn.setAction(new ClearAction());
add(new WLabel(labelText, textFld));
add(textFld);
add(dupBtn);
add(clrBtn);
add(new WAjaxControl(dupBtn, this));
add(new WAjaxControl(clrBtn, this));
} | [
"private",
"void",
"setupUI",
"(",
"final",
"String",
"labelText",
")",
"{",
"WButton",
"dupBtn",
"=",
"new",
"WButton",
"(",
"\"Duplicate\"",
")",
";",
"dupBtn",
".",
"setAction",
"(",
"new",
"DuplicateAction",
"(",
")",
")",
";",
"WButton",
"clrBtn",
"=",
"new",
"WButton",
"(",
"\"Clear\"",
")",
";",
"clrBtn",
".",
"setAction",
"(",
"new",
"ClearAction",
"(",
")",
")",
";",
"add",
"(",
"new",
"WLabel",
"(",
"labelText",
",",
"textFld",
")",
")",
";",
"add",
"(",
"textFld",
")",
";",
"add",
"(",
"dupBtn",
")",
";",
"add",
"(",
"clrBtn",
")",
";",
"add",
"(",
"new",
"WAjaxControl",
"(",
"dupBtn",
",",
"this",
")",
")",
";",
"add",
"(",
"new",
"WAjaxControl",
"(",
"clrBtn",
",",
"this",
")",
")",
";",
"}"
] | Add the controls to the UI.
@param labelText the text to show in the duplicator field's label. | [
"Add",
"the",
"controls",
"to",
"the",
"UI",
"."
] | train | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/TextDuplicator.java#L48-L61 |
spring-projects/spring-data-solr | src/main/java/org/springframework/data/solr/core/QueryParserBase.java | QueryParserBase.getMappedFieldName | protected String getMappedFieldName(String fieldName, @Nullable Class<?> domainType) {
"""
Get the mapped field name using meta information derived from the given domain type.
@param fieldName
@param domainType
@return
@since 4.0
"""
if (domainType == null || mappingContext == null) {
return fieldName;
}
SolrPersistentEntity entity = mappingContext.getPersistentEntity(domainType);
if (entity == null) {
return fieldName;
}
SolrPersistentProperty property = entity.getPersistentProperty(fieldName);
return property != null ? property.getFieldName() : fieldName;
} | java | protected String getMappedFieldName(String fieldName, @Nullable Class<?> domainType) {
if (domainType == null || mappingContext == null) {
return fieldName;
}
SolrPersistentEntity entity = mappingContext.getPersistentEntity(domainType);
if (entity == null) {
return fieldName;
}
SolrPersistentProperty property = entity.getPersistentProperty(fieldName);
return property != null ? property.getFieldName() : fieldName;
} | [
"protected",
"String",
"getMappedFieldName",
"(",
"String",
"fieldName",
",",
"@",
"Nullable",
"Class",
"<",
"?",
">",
"domainType",
")",
"{",
"if",
"(",
"domainType",
"==",
"null",
"||",
"mappingContext",
"==",
"null",
")",
"{",
"return",
"fieldName",
";",
"}",
"SolrPersistentEntity",
"entity",
"=",
"mappingContext",
".",
"getPersistentEntity",
"(",
"domainType",
")",
";",
"if",
"(",
"entity",
"==",
"null",
")",
"{",
"return",
"fieldName",
";",
"}",
"SolrPersistentProperty",
"property",
"=",
"entity",
".",
"getPersistentProperty",
"(",
"fieldName",
")",
";",
"return",
"property",
"!=",
"null",
"?",
"property",
".",
"getFieldName",
"(",
")",
":",
"fieldName",
";",
"}"
] | Get the mapped field name using meta information derived from the given domain type.
@param fieldName
@param domainType
@return
@since 4.0 | [
"Get",
"the",
"mapped",
"field",
"name",
"using",
"meta",
"information",
"derived",
"from",
"the",
"given",
"domain",
"type",
"."
] | train | https://github.com/spring-projects/spring-data-solr/blob/20be5cb82498b70134dfda6c1a91ad21f8e657e0/src/main/java/org/springframework/data/solr/core/QueryParserBase.java#L327-L340 |
exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/dataflow/ImportNodeData.java | ImportNodeData.createNodeData | public static ImportNodeData createNodeData(NodeData parent, InternalQName name, InternalQName primaryTypeName,
int index, int orderNumber) {
"""
Factory method
@param parent NodeData
@param name InternalQName
@param primaryTypeName InternalQName
@param index int
@param orderNumber int
@return
"""
ImportNodeData nodeData = null;
QPath path = QPath.makeChildPath(parent.getQPath(), name, index);
nodeData =
new ImportNodeData(path, IdGenerator.generate(), -1, primaryTypeName, new InternalQName[0], orderNumber,
parent.getIdentifier(), parent.getACL());
return nodeData;
} | java | public static ImportNodeData createNodeData(NodeData parent, InternalQName name, InternalQName primaryTypeName,
int index, int orderNumber)
{
ImportNodeData nodeData = null;
QPath path = QPath.makeChildPath(parent.getQPath(), name, index);
nodeData =
new ImportNodeData(path, IdGenerator.generate(), -1, primaryTypeName, new InternalQName[0], orderNumber,
parent.getIdentifier(), parent.getACL());
return nodeData;
} | [
"public",
"static",
"ImportNodeData",
"createNodeData",
"(",
"NodeData",
"parent",
",",
"InternalQName",
"name",
",",
"InternalQName",
"primaryTypeName",
",",
"int",
"index",
",",
"int",
"orderNumber",
")",
"{",
"ImportNodeData",
"nodeData",
"=",
"null",
";",
"QPath",
"path",
"=",
"QPath",
".",
"makeChildPath",
"(",
"parent",
".",
"getQPath",
"(",
")",
",",
"name",
",",
"index",
")",
";",
"nodeData",
"=",
"new",
"ImportNodeData",
"(",
"path",
",",
"IdGenerator",
".",
"generate",
"(",
")",
",",
"-",
"1",
",",
"primaryTypeName",
",",
"new",
"InternalQName",
"[",
"0",
"]",
",",
"orderNumber",
",",
"parent",
".",
"getIdentifier",
"(",
")",
",",
"parent",
".",
"getACL",
"(",
")",
")",
";",
"return",
"nodeData",
";",
"}"
] | Factory method
@param parent NodeData
@param name InternalQName
@param primaryTypeName InternalQName
@param index int
@param orderNumber int
@return | [
"Factory",
"method"
] | train | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/dataflow/ImportNodeData.java#L396-L405 |
maguro/aunit | junit/src/main/java/com/toolazydogs/aunit/Assert.java | Assert.assertToken | public static void assertToken(String message, int expectedChannel, int expectedType, String expectedText, Token token) {
"""
Asserts properties of a token.
@param message the message to display on failure.
@param expectedChannel the channel the token should appear on.
@param expectedType the expected type of the token.
@param expectedText the expected text of the token.
@param token the token to assert.
"""
assertEquals(message + " (channel check)", expectedChannel, token.getChannel());
assertEquals(message + " (type check)", expectedType, token.getType());
assertEquals(message + " (text check)", expectedText, token.getText());
} | java | public static void assertToken(String message, int expectedChannel, int expectedType, String expectedText, Token token)
{
assertEquals(message + " (channel check)", expectedChannel, token.getChannel());
assertEquals(message + " (type check)", expectedType, token.getType());
assertEquals(message + " (text check)", expectedText, token.getText());
} | [
"public",
"static",
"void",
"assertToken",
"(",
"String",
"message",
",",
"int",
"expectedChannel",
",",
"int",
"expectedType",
",",
"String",
"expectedText",
",",
"Token",
"token",
")",
"{",
"assertEquals",
"(",
"message",
"+",
"\" (channel check)\"",
",",
"expectedChannel",
",",
"token",
".",
"getChannel",
"(",
")",
")",
";",
"assertEquals",
"(",
"message",
"+",
"\" (type check)\"",
",",
"expectedType",
",",
"token",
".",
"getType",
"(",
")",
")",
";",
"assertEquals",
"(",
"message",
"+",
"\" (text check)\"",
",",
"expectedText",
",",
"token",
".",
"getText",
"(",
")",
")",
";",
"}"
] | Asserts properties of a token.
@param message the message to display on failure.
@param expectedChannel the channel the token should appear on.
@param expectedType the expected type of the token.
@param expectedText the expected text of the token.
@param token the token to assert. | [
"Asserts",
"properties",
"of",
"a",
"token",
"."
] | train | https://github.com/maguro/aunit/blob/1f972e35b28327e5e2e7881befc928df0546d74c/junit/src/main/java/com/toolazydogs/aunit/Assert.java#L115-L120 |
raphw/byte-buddy | byte-buddy-dep/src/main/java/net/bytebuddy/utility/JavaConstant.java | Dynamic.ofInvocation | public static Dynamic ofInvocation(MethodDescription.InDefinedShape methodDescription, Object... rawArgument) {
"""
Represents a constant that is resolved by invoking a {@code static} factory method or a constructor.
@param methodDescription The method or constructor to invoke to create the represented constant value.
@param rawArgument The method's or constructor's constant arguments.
@return A dynamic constant that is resolved by the supplied factory method or constructor.
"""
return ofInvocation(methodDescription, Arrays.asList(rawArgument));
} | java | public static Dynamic ofInvocation(MethodDescription.InDefinedShape methodDescription, Object... rawArgument) {
return ofInvocation(methodDescription, Arrays.asList(rawArgument));
} | [
"public",
"static",
"Dynamic",
"ofInvocation",
"(",
"MethodDescription",
".",
"InDefinedShape",
"methodDescription",
",",
"Object",
"...",
"rawArgument",
")",
"{",
"return",
"ofInvocation",
"(",
"methodDescription",
",",
"Arrays",
".",
"asList",
"(",
"rawArgument",
")",
")",
";",
"}"
] | Represents a constant that is resolved by invoking a {@code static} factory method or a constructor.
@param methodDescription The method or constructor to invoke to create the represented constant value.
@param rawArgument The method's or constructor's constant arguments.
@return A dynamic constant that is resolved by the supplied factory method or constructor. | [
"Represents",
"a",
"constant",
"that",
"is",
"resolved",
"by",
"invoking",
"a",
"{",
"@code",
"static",
"}",
"factory",
"method",
"or",
"a",
"constructor",
"."
] | train | https://github.com/raphw/byte-buddy/blob/4d2dac80efb6bed89367567260f6811c2f712d12/byte-buddy-dep/src/main/java/net/bytebuddy/utility/JavaConstant.java#L1564-L1566 |
netty/netty | common/src/main/java/io/netty/util/internal/PlatformDependent.java | PlatformDependent.equalsConstantTime | public static int equalsConstantTime(byte[] bytes1, int startPos1, byte[] bytes2, int startPos2, int length) {
"""
Compare two {@code byte} arrays for equality without leaking timing information.
For performance reasons no bounds checking on the parameters is performed.
<p>
The {@code int} return type is intentional and is designed to allow cascading of constant time operations:
<pre>
byte[] s1 = new {1, 2, 3};
byte[] s2 = new {1, 2, 3};
byte[] s3 = new {1, 2, 3};
byte[] s4 = new {4, 5, 6};
boolean equals = (equalsConstantTime(s1, 0, s2, 0, s1.length) &
equalsConstantTime(s3, 0, s4, 0, s3.length)) != 0;
</pre>
@param bytes1 the first byte array.
@param startPos1 the position (inclusive) to start comparing in {@code bytes1}.
@param bytes2 the second byte array.
@param startPos2 the position (inclusive) to start comparing in {@code bytes2}.
@param length the amount of bytes to compare. This is assumed to be validated as not going out of bounds
by the caller.
@return {@code 0} if not equal. {@code 1} if equal.
"""
return !hasUnsafe() || !unalignedAccess() ?
ConstantTimeUtils.equalsConstantTime(bytes1, startPos1, bytes2, startPos2, length) :
PlatformDependent0.equalsConstantTime(bytes1, startPos1, bytes2, startPos2, length);
} | java | public static int equalsConstantTime(byte[] bytes1, int startPos1, byte[] bytes2, int startPos2, int length) {
return !hasUnsafe() || !unalignedAccess() ?
ConstantTimeUtils.equalsConstantTime(bytes1, startPos1, bytes2, startPos2, length) :
PlatformDependent0.equalsConstantTime(bytes1, startPos1, bytes2, startPos2, length);
} | [
"public",
"static",
"int",
"equalsConstantTime",
"(",
"byte",
"[",
"]",
"bytes1",
",",
"int",
"startPos1",
",",
"byte",
"[",
"]",
"bytes2",
",",
"int",
"startPos2",
",",
"int",
"length",
")",
"{",
"return",
"!",
"hasUnsafe",
"(",
")",
"||",
"!",
"unalignedAccess",
"(",
")",
"?",
"ConstantTimeUtils",
".",
"equalsConstantTime",
"(",
"bytes1",
",",
"startPos1",
",",
"bytes2",
",",
"startPos2",
",",
"length",
")",
":",
"PlatformDependent0",
".",
"equalsConstantTime",
"(",
"bytes1",
",",
"startPos1",
",",
"bytes2",
",",
"startPos2",
",",
"length",
")",
";",
"}"
] | Compare two {@code byte} arrays for equality without leaking timing information.
For performance reasons no bounds checking on the parameters is performed.
<p>
The {@code int} return type is intentional and is designed to allow cascading of constant time operations:
<pre>
byte[] s1 = new {1, 2, 3};
byte[] s2 = new {1, 2, 3};
byte[] s3 = new {1, 2, 3};
byte[] s4 = new {4, 5, 6};
boolean equals = (equalsConstantTime(s1, 0, s2, 0, s1.length) &
equalsConstantTime(s3, 0, s4, 0, s3.length)) != 0;
</pre>
@param bytes1 the first byte array.
@param startPos1 the position (inclusive) to start comparing in {@code bytes1}.
@param bytes2 the second byte array.
@param startPos2 the position (inclusive) to start comparing in {@code bytes2}.
@param length the amount of bytes to compare. This is assumed to be validated as not going out of bounds
by the caller.
@return {@code 0} if not equal. {@code 1} if equal. | [
"Compare",
"two",
"{"
] | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/common/src/main/java/io/netty/util/internal/PlatformDependent.java#L736-L740 |
jbundle/jbundle | thin/base/remote/src/main/java/org/jbundle/thin/base/remote/proxy/ReceiveQueueProxy.java | ReceiveQueueProxy.addRemoteMessageFilter | public BaseMessageFilter addRemoteMessageFilter(BaseMessageFilter messageFilter, RemoteSession remoteSession) throws RemoteException {
"""
Add a message filter to this remote receive queue.
@param messageFilter The message filter to add.
@param remoteSession The remote session.
@return The filter ID.
"""
BaseTransport transport = this.createProxyTransport(ADD_REMOTE_MESSAGE_FILTER);
transport.addParam(FILTER, messageFilter); // Don't use COMMAND
String strSessionPathID = null;
if (remoteSession instanceof BaseProxy)
{ // Always a SessionProxy
strSessionPathID = ((BaseProxy)remoteSession).getIDPath();
}
transport.addParam(SESSION, strSessionPathID);
Object strReturn = transport.sendMessageAndGetReply();
Object objReturn = transport.convertReturnObject(strReturn);
return (BaseMessageFilter)objReturn;
} | java | public BaseMessageFilter addRemoteMessageFilter(BaseMessageFilter messageFilter, RemoteSession remoteSession) throws RemoteException
{
BaseTransport transport = this.createProxyTransport(ADD_REMOTE_MESSAGE_FILTER);
transport.addParam(FILTER, messageFilter); // Don't use COMMAND
String strSessionPathID = null;
if (remoteSession instanceof BaseProxy)
{ // Always a SessionProxy
strSessionPathID = ((BaseProxy)remoteSession).getIDPath();
}
transport.addParam(SESSION, strSessionPathID);
Object strReturn = transport.sendMessageAndGetReply();
Object objReturn = transport.convertReturnObject(strReturn);
return (BaseMessageFilter)objReturn;
} | [
"public",
"BaseMessageFilter",
"addRemoteMessageFilter",
"(",
"BaseMessageFilter",
"messageFilter",
",",
"RemoteSession",
"remoteSession",
")",
"throws",
"RemoteException",
"{",
"BaseTransport",
"transport",
"=",
"this",
".",
"createProxyTransport",
"(",
"ADD_REMOTE_MESSAGE_FILTER",
")",
";",
"transport",
".",
"addParam",
"(",
"FILTER",
",",
"messageFilter",
")",
";",
"// Don't use COMMAND",
"String",
"strSessionPathID",
"=",
"null",
";",
"if",
"(",
"remoteSession",
"instanceof",
"BaseProxy",
")",
"{",
"// Always a SessionProxy",
"strSessionPathID",
"=",
"(",
"(",
"BaseProxy",
")",
"remoteSession",
")",
".",
"getIDPath",
"(",
")",
";",
"}",
"transport",
".",
"addParam",
"(",
"SESSION",
",",
"strSessionPathID",
")",
";",
"Object",
"strReturn",
"=",
"transport",
".",
"sendMessageAndGetReply",
"(",
")",
";",
"Object",
"objReturn",
"=",
"transport",
".",
"convertReturnObject",
"(",
"strReturn",
")",
";",
"return",
"(",
"BaseMessageFilter",
")",
"objReturn",
";",
"}"
] | Add a message filter to this remote receive queue.
@param messageFilter The message filter to add.
@param remoteSession The remote session.
@return The filter ID. | [
"Add",
"a",
"message",
"filter",
"to",
"this",
"remote",
"receive",
"queue",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/remote/src/main/java/org/jbundle/thin/base/remote/proxy/ReceiveQueueProxy.java#L79-L92 |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/edge/GradientToEdgeFeatures.java | GradientToEdgeFeatures.nonMaxSuppressionCrude4 | static public GrayF32 nonMaxSuppressionCrude4(GrayF32 intensity , GrayS32 derivX , GrayS32 derivY, GrayF32 output ) {
"""
<p>
Sets edge intensities to zero if the pixel has an intensity which is less than any of
the two adjacent pixels. Pixel adjacency is determined based upon the sign of the image gradient. Less precise
than other methods, but faster.
</p>
@param intensity Edge intensities. Not modified.
@param derivX Image derivative along x-axis.
@param derivY Image derivative along y-axis.
@param output Filtered intensity. If null a new image will be declared and returned. Modified.
@return Filtered edge intensity.
"""
InputSanityCheck.checkSameShape(intensity,derivX,derivY);
output = InputSanityCheck.checkDeclare(intensity,output);
if(BoofConcurrency.USE_CONCURRENT ) {
ImplEdgeNonMaxSuppressionCrude_MT.inner4(intensity, derivX, derivY, output);
ImplEdgeNonMaxSuppressionCrude_MT.border4(intensity, derivX, derivY, output);
} else {
ImplEdgeNonMaxSuppressionCrude.inner4(intensity, derivX, derivY, output);
ImplEdgeNonMaxSuppressionCrude.border4(intensity, derivX, derivY, output);
}
return output;
} | java | static public GrayF32 nonMaxSuppressionCrude4(GrayF32 intensity , GrayS32 derivX , GrayS32 derivY, GrayF32 output )
{
InputSanityCheck.checkSameShape(intensity,derivX,derivY);
output = InputSanityCheck.checkDeclare(intensity,output);
if(BoofConcurrency.USE_CONCURRENT ) {
ImplEdgeNonMaxSuppressionCrude_MT.inner4(intensity, derivX, derivY, output);
ImplEdgeNonMaxSuppressionCrude_MT.border4(intensity, derivX, derivY, output);
} else {
ImplEdgeNonMaxSuppressionCrude.inner4(intensity, derivX, derivY, output);
ImplEdgeNonMaxSuppressionCrude.border4(intensity, derivX, derivY, output);
}
return output;
} | [
"static",
"public",
"GrayF32",
"nonMaxSuppressionCrude4",
"(",
"GrayF32",
"intensity",
",",
"GrayS32",
"derivX",
",",
"GrayS32",
"derivY",
",",
"GrayF32",
"output",
")",
"{",
"InputSanityCheck",
".",
"checkSameShape",
"(",
"intensity",
",",
"derivX",
",",
"derivY",
")",
";",
"output",
"=",
"InputSanityCheck",
".",
"checkDeclare",
"(",
"intensity",
",",
"output",
")",
";",
"if",
"(",
"BoofConcurrency",
".",
"USE_CONCURRENT",
")",
"{",
"ImplEdgeNonMaxSuppressionCrude_MT",
".",
"inner4",
"(",
"intensity",
",",
"derivX",
",",
"derivY",
",",
"output",
")",
";",
"ImplEdgeNonMaxSuppressionCrude_MT",
".",
"border4",
"(",
"intensity",
",",
"derivX",
",",
"derivY",
",",
"output",
")",
";",
"}",
"else",
"{",
"ImplEdgeNonMaxSuppressionCrude",
".",
"inner4",
"(",
"intensity",
",",
"derivX",
",",
"derivY",
",",
"output",
")",
";",
"ImplEdgeNonMaxSuppressionCrude",
".",
"border4",
"(",
"intensity",
",",
"derivX",
",",
"derivY",
",",
"output",
")",
";",
"}",
"return",
"output",
";",
"}"
] | <p>
Sets edge intensities to zero if the pixel has an intensity which is less than any of
the two adjacent pixels. Pixel adjacency is determined based upon the sign of the image gradient. Less precise
than other methods, but faster.
</p>
@param intensity Edge intensities. Not modified.
@param derivX Image derivative along x-axis.
@param derivY Image derivative along y-axis.
@param output Filtered intensity. If null a new image will be declared and returned. Modified.
@return Filtered edge intensity. | [
"<p",
">",
"Sets",
"edge",
"intensities",
"to",
"zero",
"if",
"the",
"pixel",
"has",
"an",
"intensity",
"which",
"is",
"less",
"than",
"any",
"of",
"the",
"two",
"adjacent",
"pixels",
".",
"Pixel",
"adjacency",
"is",
"determined",
"based",
"upon",
"the",
"sign",
"of",
"the",
"image",
"gradient",
".",
"Less",
"precise",
"than",
"other",
"methods",
"but",
"faster",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/edge/GradientToEdgeFeatures.java#L353-L367 |
alkacon/opencms-core | src/org/opencms/db/CmsSecurityManager.java | CmsSecurityManager.lookupPrincipal | public I_CmsPrincipal lookupPrincipal(CmsRequestContext context, String principalName) {
"""
Lookup and read the user or group with the given name.<p>
@param context the current request context
@param principalName the name of the principal to lookup
@return the principal (group or user) if found, otherwise <code>null</code>
"""
CmsDbContext dbc = m_dbContextFactory.getDbContext(context);
I_CmsPrincipal result = null;
try {
result = m_driverManager.lookupPrincipal(dbc, CmsOrganizationalUnit.removeLeadingSeparator(principalName));
} finally {
dbc.clear();
}
return result;
} | java | public I_CmsPrincipal lookupPrincipal(CmsRequestContext context, String principalName) {
CmsDbContext dbc = m_dbContextFactory.getDbContext(context);
I_CmsPrincipal result = null;
try {
result = m_driverManager.lookupPrincipal(dbc, CmsOrganizationalUnit.removeLeadingSeparator(principalName));
} finally {
dbc.clear();
}
return result;
} | [
"public",
"I_CmsPrincipal",
"lookupPrincipal",
"(",
"CmsRequestContext",
"context",
",",
"String",
"principalName",
")",
"{",
"CmsDbContext",
"dbc",
"=",
"m_dbContextFactory",
".",
"getDbContext",
"(",
"context",
")",
";",
"I_CmsPrincipal",
"result",
"=",
"null",
";",
"try",
"{",
"result",
"=",
"m_driverManager",
".",
"lookupPrincipal",
"(",
"dbc",
",",
"CmsOrganizationalUnit",
".",
"removeLeadingSeparator",
"(",
"principalName",
")",
")",
";",
"}",
"finally",
"{",
"dbc",
".",
"clear",
"(",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Lookup and read the user or group with the given name.<p>
@param context the current request context
@param principalName the name of the principal to lookup
@return the principal (group or user) if found, otherwise <code>null</code> | [
"Lookup",
"and",
"read",
"the",
"user",
"or",
"group",
"with",
"the",
"given",
"name",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/db/CmsSecurityManager.java#L3642-L3652 |
finmath/finmath-lib | src/main/java/net/finmath/modelling/descriptor/xmlparser/FPMLParser.java | FPMLParser.getSwapLegProductDescriptor | private InterestRateSwapLegProductDescriptor getSwapLegProductDescriptor(Element leg) {
"""
Construct an InterestRateSwapLegProductDescriptor from a node in a FpML file.
@param leg The node containing the leg.
@return Descriptor of the swap leg.
"""
//is this a fixed rate leg?
boolean isFixed = leg.getElementsByTagName("calculationPeriodDates").item(0).getAttributes().getNamedItem("id").getTextContent().equalsIgnoreCase("fixedCalcPeriodDates");
//get start and end dates of contract
LocalDate startDate = LocalDate.parse(((Element) leg.getElementsByTagName("effectiveDate").item(0)).getElementsByTagName("unadjustedDate").item(0).getTextContent());
LocalDate maturityDate = LocalDate.parse(((Element) leg.getElementsByTagName("terminationDate").item(0)).getElementsByTagName("unadjustedDate").item(0).getTextContent());
//determine fixing/payment offset if available
int fixingOffsetDays = 0;
if(leg.getElementsByTagName("fixingDates").getLength() > 0) {
fixingOffsetDays = Integer.parseInt(((Element) leg.getElementsByTagName("fixingDates").item(0)).getElementsByTagName("periodMultiplier").item(0).getTextContent());
}
int paymentOffsetDays = 0;
if(leg.getElementsByTagName("paymentDaysOffset").getLength() > 0) {
paymentOffsetDays = Integer.parseInt(((Element) leg.getElementsByTagName("paymentDaysOffset").item(0)).getElementsByTagName("periodMultiplier").item(0).getTextContent());
}
//Crop xml date roll convention to match internal format
String xmlInput = ((Element) leg.getElementsByTagName("calculationPeriodDatesAdjustments").item(0)).getElementsByTagName("businessDayConvention").item(0).getTextContent();
xmlInput = xmlInput.replaceAll("ING", "");
DateRollConvention dateRollConvention = DateRollConvention.getEnum(xmlInput);
//get daycount convention
DaycountConvention daycountConvention = DaycountConvention.getEnum(leg.getElementsByTagName("dayCountFraction").item(0).getTextContent());
//get trade frequency
Frequency frequency = null;
Element calcNode = (Element) leg.getElementsByTagName("calculationPeriodFrequency").item(0);
int multiplier = Integer.parseInt(calcNode.getElementsByTagName("periodMultiplier").item(0).getTextContent());
switch(calcNode.getElementsByTagName("period").item(0).getTextContent().toUpperCase()) {
case "D" : if(multiplier == 1) {frequency = Frequency.DAILY;} break;
case "Y" : if(multiplier == 1) {frequency = Frequency.ANNUAL;} break;
case "M" : switch(multiplier) {
case 1 : frequency = Frequency.MONTHLY;
case 3 : frequency = Frequency.QUARTERLY;
case 6 : frequency = Frequency.SEMIANNUAL;
}
}
//build schedule
ScheduleDescriptor schedule = new ScheduleDescriptor(startDate, maturityDate, frequency, daycountConvention, shortPeriodConvention,
dateRollConvention, abstractBusinessdayCalendar, fixingOffsetDays, paymentOffsetDays);
// get notional
double notional = Double.parseDouble(((Element) leg.getElementsByTagName("notionalSchedule").item(0)).getElementsByTagName("initialValue").item(0).getTextContent());
// get fixed rate and forward curve if applicable
double spread = 0;
String forwardCurveName = "";
if(isFixed) {
spread = Double.parseDouble(((Element) leg.getElementsByTagName("fixedRateSchedule").item(0)).getElementsByTagName("initialValue").item(0).getTextContent());
} else {
forwardCurveName = leg.getElementsByTagName("floatingRateIndex").item(0).getTextContent();
}
return new InterestRateSwapLegProductDescriptor(forwardCurveName, discountCurveName, schedule, notional, spread, false);
} | java | private InterestRateSwapLegProductDescriptor getSwapLegProductDescriptor(Element leg) {
//is this a fixed rate leg?
boolean isFixed = leg.getElementsByTagName("calculationPeriodDates").item(0).getAttributes().getNamedItem("id").getTextContent().equalsIgnoreCase("fixedCalcPeriodDates");
//get start and end dates of contract
LocalDate startDate = LocalDate.parse(((Element) leg.getElementsByTagName("effectiveDate").item(0)).getElementsByTagName("unadjustedDate").item(0).getTextContent());
LocalDate maturityDate = LocalDate.parse(((Element) leg.getElementsByTagName("terminationDate").item(0)).getElementsByTagName("unadjustedDate").item(0).getTextContent());
//determine fixing/payment offset if available
int fixingOffsetDays = 0;
if(leg.getElementsByTagName("fixingDates").getLength() > 0) {
fixingOffsetDays = Integer.parseInt(((Element) leg.getElementsByTagName("fixingDates").item(0)).getElementsByTagName("periodMultiplier").item(0).getTextContent());
}
int paymentOffsetDays = 0;
if(leg.getElementsByTagName("paymentDaysOffset").getLength() > 0) {
paymentOffsetDays = Integer.parseInt(((Element) leg.getElementsByTagName("paymentDaysOffset").item(0)).getElementsByTagName("periodMultiplier").item(0).getTextContent());
}
//Crop xml date roll convention to match internal format
String xmlInput = ((Element) leg.getElementsByTagName("calculationPeriodDatesAdjustments").item(0)).getElementsByTagName("businessDayConvention").item(0).getTextContent();
xmlInput = xmlInput.replaceAll("ING", "");
DateRollConvention dateRollConvention = DateRollConvention.getEnum(xmlInput);
//get daycount convention
DaycountConvention daycountConvention = DaycountConvention.getEnum(leg.getElementsByTagName("dayCountFraction").item(0).getTextContent());
//get trade frequency
Frequency frequency = null;
Element calcNode = (Element) leg.getElementsByTagName("calculationPeriodFrequency").item(0);
int multiplier = Integer.parseInt(calcNode.getElementsByTagName("periodMultiplier").item(0).getTextContent());
switch(calcNode.getElementsByTagName("period").item(0).getTextContent().toUpperCase()) {
case "D" : if(multiplier == 1) {frequency = Frequency.DAILY;} break;
case "Y" : if(multiplier == 1) {frequency = Frequency.ANNUAL;} break;
case "M" : switch(multiplier) {
case 1 : frequency = Frequency.MONTHLY;
case 3 : frequency = Frequency.QUARTERLY;
case 6 : frequency = Frequency.SEMIANNUAL;
}
}
//build schedule
ScheduleDescriptor schedule = new ScheduleDescriptor(startDate, maturityDate, frequency, daycountConvention, shortPeriodConvention,
dateRollConvention, abstractBusinessdayCalendar, fixingOffsetDays, paymentOffsetDays);
// get notional
double notional = Double.parseDouble(((Element) leg.getElementsByTagName("notionalSchedule").item(0)).getElementsByTagName("initialValue").item(0).getTextContent());
// get fixed rate and forward curve if applicable
double spread = 0;
String forwardCurveName = "";
if(isFixed) {
spread = Double.parseDouble(((Element) leg.getElementsByTagName("fixedRateSchedule").item(0)).getElementsByTagName("initialValue").item(0).getTextContent());
} else {
forwardCurveName = leg.getElementsByTagName("floatingRateIndex").item(0).getTextContent();
}
return new InterestRateSwapLegProductDescriptor(forwardCurveName, discountCurveName, schedule, notional, spread, false);
} | [
"private",
"InterestRateSwapLegProductDescriptor",
"getSwapLegProductDescriptor",
"(",
"Element",
"leg",
")",
"{",
"//is this a fixed rate leg?\r",
"boolean",
"isFixed",
"=",
"leg",
".",
"getElementsByTagName",
"(",
"\"calculationPeriodDates\"",
")",
".",
"item",
"(",
"0",
")",
".",
"getAttributes",
"(",
")",
".",
"getNamedItem",
"(",
"\"id\"",
")",
".",
"getTextContent",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"\"fixedCalcPeriodDates\"",
")",
";",
"//get start and end dates of contract\r",
"LocalDate",
"startDate",
"=",
"LocalDate",
".",
"parse",
"(",
"(",
"(",
"Element",
")",
"leg",
".",
"getElementsByTagName",
"(",
"\"effectiveDate\"",
")",
".",
"item",
"(",
"0",
")",
")",
".",
"getElementsByTagName",
"(",
"\"unadjustedDate\"",
")",
".",
"item",
"(",
"0",
")",
".",
"getTextContent",
"(",
")",
")",
";",
"LocalDate",
"maturityDate",
"=",
"LocalDate",
".",
"parse",
"(",
"(",
"(",
"Element",
")",
"leg",
".",
"getElementsByTagName",
"(",
"\"terminationDate\"",
")",
".",
"item",
"(",
"0",
")",
")",
".",
"getElementsByTagName",
"(",
"\"unadjustedDate\"",
")",
".",
"item",
"(",
"0",
")",
".",
"getTextContent",
"(",
")",
")",
";",
"//determine fixing/payment offset if available\r",
"int",
"fixingOffsetDays",
"=",
"0",
";",
"if",
"(",
"leg",
".",
"getElementsByTagName",
"(",
"\"fixingDates\"",
")",
".",
"getLength",
"(",
")",
">",
"0",
")",
"{",
"fixingOffsetDays",
"=",
"Integer",
".",
"parseInt",
"(",
"(",
"(",
"Element",
")",
"leg",
".",
"getElementsByTagName",
"(",
"\"fixingDates\"",
")",
".",
"item",
"(",
"0",
")",
")",
".",
"getElementsByTagName",
"(",
"\"periodMultiplier\"",
")",
".",
"item",
"(",
"0",
")",
".",
"getTextContent",
"(",
")",
")",
";",
"}",
"int",
"paymentOffsetDays",
"=",
"0",
";",
"if",
"(",
"leg",
".",
"getElementsByTagName",
"(",
"\"paymentDaysOffset\"",
")",
".",
"getLength",
"(",
")",
">",
"0",
")",
"{",
"paymentOffsetDays",
"=",
"Integer",
".",
"parseInt",
"(",
"(",
"(",
"Element",
")",
"leg",
".",
"getElementsByTagName",
"(",
"\"paymentDaysOffset\"",
")",
".",
"item",
"(",
"0",
")",
")",
".",
"getElementsByTagName",
"(",
"\"periodMultiplier\"",
")",
".",
"item",
"(",
"0",
")",
".",
"getTextContent",
"(",
")",
")",
";",
"}",
"//Crop xml date roll convention to match internal format\r",
"String",
"xmlInput",
"=",
"(",
"(",
"Element",
")",
"leg",
".",
"getElementsByTagName",
"(",
"\"calculationPeriodDatesAdjustments\"",
")",
".",
"item",
"(",
"0",
")",
")",
".",
"getElementsByTagName",
"(",
"\"businessDayConvention\"",
")",
".",
"item",
"(",
"0",
")",
".",
"getTextContent",
"(",
")",
";",
"xmlInput",
"=",
"xmlInput",
".",
"replaceAll",
"(",
"\"ING\"",
",",
"\"\"",
")",
";",
"DateRollConvention",
"dateRollConvention",
"=",
"DateRollConvention",
".",
"getEnum",
"(",
"xmlInput",
")",
";",
"//get daycount convention\r",
"DaycountConvention",
"daycountConvention",
"=",
"DaycountConvention",
".",
"getEnum",
"(",
"leg",
".",
"getElementsByTagName",
"(",
"\"dayCountFraction\"",
")",
".",
"item",
"(",
"0",
")",
".",
"getTextContent",
"(",
")",
")",
";",
"//get trade frequency\r",
"Frequency",
"frequency",
"=",
"null",
";",
"Element",
"calcNode",
"=",
"(",
"Element",
")",
"leg",
".",
"getElementsByTagName",
"(",
"\"calculationPeriodFrequency\"",
")",
".",
"item",
"(",
"0",
")",
";",
"int",
"multiplier",
"=",
"Integer",
".",
"parseInt",
"(",
"calcNode",
".",
"getElementsByTagName",
"(",
"\"periodMultiplier\"",
")",
".",
"item",
"(",
"0",
")",
".",
"getTextContent",
"(",
")",
")",
";",
"switch",
"(",
"calcNode",
".",
"getElementsByTagName",
"(",
"\"period\"",
")",
".",
"item",
"(",
"0",
")",
".",
"getTextContent",
"(",
")",
".",
"toUpperCase",
"(",
")",
")",
"{",
"case",
"\"D\"",
":",
"if",
"(",
"multiplier",
"==",
"1",
")",
"{",
"frequency",
"=",
"Frequency",
".",
"DAILY",
";",
"}",
"break",
";",
"case",
"\"Y\"",
":",
"if",
"(",
"multiplier",
"==",
"1",
")",
"{",
"frequency",
"=",
"Frequency",
".",
"ANNUAL",
";",
"}",
"break",
";",
"case",
"\"M\"",
":",
"switch",
"(",
"multiplier",
")",
"{",
"case",
"1",
":",
"frequency",
"=",
"Frequency",
".",
"MONTHLY",
";",
"case",
"3",
":",
"frequency",
"=",
"Frequency",
".",
"QUARTERLY",
";",
"case",
"6",
":",
"frequency",
"=",
"Frequency",
".",
"SEMIANNUAL",
";",
"}",
"}",
"//build schedule\r",
"ScheduleDescriptor",
"schedule",
"=",
"new",
"ScheduleDescriptor",
"(",
"startDate",
",",
"maturityDate",
",",
"frequency",
",",
"daycountConvention",
",",
"shortPeriodConvention",
",",
"dateRollConvention",
",",
"abstractBusinessdayCalendar",
",",
"fixingOffsetDays",
",",
"paymentOffsetDays",
")",
";",
"// get notional\r",
"double",
"notional",
"=",
"Double",
".",
"parseDouble",
"(",
"(",
"(",
"Element",
")",
"leg",
".",
"getElementsByTagName",
"(",
"\"notionalSchedule\"",
")",
".",
"item",
"(",
"0",
")",
")",
".",
"getElementsByTagName",
"(",
"\"initialValue\"",
")",
".",
"item",
"(",
"0",
")",
".",
"getTextContent",
"(",
")",
")",
";",
"// get fixed rate and forward curve if applicable\r",
"double",
"spread",
"=",
"0",
";",
"String",
"forwardCurveName",
"=",
"\"\"",
";",
"if",
"(",
"isFixed",
")",
"{",
"spread",
"=",
"Double",
".",
"parseDouble",
"(",
"(",
"(",
"Element",
")",
"leg",
".",
"getElementsByTagName",
"(",
"\"fixedRateSchedule\"",
")",
".",
"item",
"(",
"0",
")",
")",
".",
"getElementsByTagName",
"(",
"\"initialValue\"",
")",
".",
"item",
"(",
"0",
")",
".",
"getTextContent",
"(",
")",
")",
";",
"}",
"else",
"{",
"forwardCurveName",
"=",
"leg",
".",
"getElementsByTagName",
"(",
"\"floatingRateIndex\"",
")",
".",
"item",
"(",
"0",
")",
".",
"getTextContent",
"(",
")",
";",
"}",
"return",
"new",
"InterestRateSwapLegProductDescriptor",
"(",
"forwardCurveName",
",",
"discountCurveName",
",",
"schedule",
",",
"notional",
",",
"spread",
",",
"false",
")",
";",
"}"
] | Construct an InterestRateSwapLegProductDescriptor from a node in a FpML file.
@param leg The node containing the leg.
@return Descriptor of the swap leg. | [
"Construct",
"an",
"InterestRateSwapLegProductDescriptor",
"from",
"a",
"node",
"in",
"a",
"FpML",
"file",
"."
] | train | https://github.com/finmath/finmath-lib/blob/a3c067d52dd33feb97d851df6cab130e4116759f/src/main/java/net/finmath/modelling/descriptor/xmlparser/FPMLParser.java#L128-L186 |
exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java | NodeImpl.checkedOut | public boolean checkedOut() throws UnsupportedRepositoryOperationException, RepositoryException {
"""
Tell if this node or its nearest versionable ancestor is checked-out.
@return boolean
@throws UnsupportedRepositoryOperationException
if Versionable operations is not supported
@throws RepositoryException
if error occurs
"""
// this will also check if item is valid
NodeData vancestor = getVersionableAncestor();
if (vancestor != null)
{
PropertyData isCheckedOut =
(PropertyData)dataManager.getItemData(vancestor, new QPathEntry(Constants.JCR_ISCHECKEDOUT, 1),
ItemType.PROPERTY);
return ValueDataUtil.getBoolean(isCheckedOut.getValues().get(0));
}
return true;
} | java | public boolean checkedOut() throws UnsupportedRepositoryOperationException, RepositoryException
{
// this will also check if item is valid
NodeData vancestor = getVersionableAncestor();
if (vancestor != null)
{
PropertyData isCheckedOut =
(PropertyData)dataManager.getItemData(vancestor, new QPathEntry(Constants.JCR_ISCHECKEDOUT, 1),
ItemType.PROPERTY);
return ValueDataUtil.getBoolean(isCheckedOut.getValues().get(0));
}
return true;
} | [
"public",
"boolean",
"checkedOut",
"(",
")",
"throws",
"UnsupportedRepositoryOperationException",
",",
"RepositoryException",
"{",
"// this will also check if item is valid",
"NodeData",
"vancestor",
"=",
"getVersionableAncestor",
"(",
")",
";",
"if",
"(",
"vancestor",
"!=",
"null",
")",
"{",
"PropertyData",
"isCheckedOut",
"=",
"(",
"PropertyData",
")",
"dataManager",
".",
"getItemData",
"(",
"vancestor",
",",
"new",
"QPathEntry",
"(",
"Constants",
".",
"JCR_ISCHECKEDOUT",
",",
"1",
")",
",",
"ItemType",
".",
"PROPERTY",
")",
";",
"return",
"ValueDataUtil",
".",
"getBoolean",
"(",
"isCheckedOut",
".",
"getValues",
"(",
")",
".",
"get",
"(",
"0",
")",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Tell if this node or its nearest versionable ancestor is checked-out.
@return boolean
@throws UnsupportedRepositoryOperationException
if Versionable operations is not supported
@throws RepositoryException
if error occurs | [
"Tell",
"if",
"this",
"node",
"or",
"its",
"nearest",
"versionable",
"ancestor",
"is",
"checked",
"-",
"out",
"."
] | train | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java#L433-L447 |
groupon/odo | proxyui/src/main/java/com/groupon/odo/controllers/ScriptController.java | ScriptController.getScript | @RequestMapping(value = "/api/scripts/ {
"""
Get a specific script
@param model
@param scriptIdentifier
@return
@throws Exception
"""scriptIdentifier}", method = RequestMethod.GET)
public
@ResponseBody
Script getScript(Model model, @PathVariable String scriptIdentifier) throws Exception {
return ScriptService.getInstance().getScript(Integer.parseInt(scriptIdentifier));
} | java | @RequestMapping(value = "/api/scripts/{scriptIdentifier}", method = RequestMethod.GET)
public
@ResponseBody
Script getScript(Model model, @PathVariable String scriptIdentifier) throws Exception {
return ScriptService.getInstance().getScript(Integer.parseInt(scriptIdentifier));
} | [
"@",
"RequestMapping",
"(",
"value",
"=",
"\"/api/scripts/{scriptIdentifier}\"",
",",
"method",
"=",
"RequestMethod",
".",
"GET",
")",
"public",
"@",
"ResponseBody",
"Script",
"getScript",
"(",
"Model",
"model",
",",
"@",
"PathVariable",
"String",
"scriptIdentifier",
")",
"throws",
"Exception",
"{",
"return",
"ScriptService",
".",
"getInstance",
"(",
")",
".",
"getScript",
"(",
"Integer",
".",
"parseInt",
"(",
"scriptIdentifier",
")",
")",
";",
"}"
] | Get a specific script
@param model
@param scriptIdentifier
@return
@throws Exception | [
"Get",
"a",
"specific",
"script"
] | train | https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxyui/src/main/java/com/groupon/odo/controllers/ScriptController.java#L66-L71 |
JodaOrg/joda-time | src/main/java/org/joda/time/Interval.java | Interval.withDurationBeforeEnd | public Interval withDurationBeforeEnd(ReadableDuration duration) {
"""
Creates a new interval with the specified duration before the end instant.
@param duration the duration to subtract from the end to get the new start instant, null means zero
@return an interval with the end from this interval and a calculated start
@throws IllegalArgumentException if the duration is negative
"""
long durationMillis = DateTimeUtils.getDurationMillis(duration);
if (durationMillis == toDurationMillis()) {
return this;
}
Chronology chrono = getChronology();
long endMillis = getEndMillis();
long startMillis = chrono.add(endMillis, durationMillis, -1);
return new Interval(startMillis, endMillis, chrono);
} | java | public Interval withDurationBeforeEnd(ReadableDuration duration) {
long durationMillis = DateTimeUtils.getDurationMillis(duration);
if (durationMillis == toDurationMillis()) {
return this;
}
Chronology chrono = getChronology();
long endMillis = getEndMillis();
long startMillis = chrono.add(endMillis, durationMillis, -1);
return new Interval(startMillis, endMillis, chrono);
} | [
"public",
"Interval",
"withDurationBeforeEnd",
"(",
"ReadableDuration",
"duration",
")",
"{",
"long",
"durationMillis",
"=",
"DateTimeUtils",
".",
"getDurationMillis",
"(",
"duration",
")",
";",
"if",
"(",
"durationMillis",
"==",
"toDurationMillis",
"(",
")",
")",
"{",
"return",
"this",
";",
"}",
"Chronology",
"chrono",
"=",
"getChronology",
"(",
")",
";",
"long",
"endMillis",
"=",
"getEndMillis",
"(",
")",
";",
"long",
"startMillis",
"=",
"chrono",
".",
"add",
"(",
"endMillis",
",",
"durationMillis",
",",
"-",
"1",
")",
";",
"return",
"new",
"Interval",
"(",
"startMillis",
",",
"endMillis",
",",
"chrono",
")",
";",
"}"
] | Creates a new interval with the specified duration before the end instant.
@param duration the duration to subtract from the end to get the new start instant, null means zero
@return an interval with the end from this interval and a calculated start
@throws IllegalArgumentException if the duration is negative | [
"Creates",
"a",
"new",
"interval",
"with",
"the",
"specified",
"duration",
"before",
"the",
"end",
"instant",
"."
] | train | https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/Interval.java#L516-L525 |
Stratio/deep-spark | deep-cassandra/src/main/java/com/stratio/deep/cassandra/thrift/ThriftRangeUtils.java | ThriftRangeUtils.build | public static ThriftRangeUtils build(CassandraDeepJobConfig config) {
"""
Returns a new {@link ThriftRangeUtils} using the specified configuration.
@param config the Deep configuration object.
"""
String host = config.getHost();
int rpcPort = config.getRpcPort();
int splitSize = config.getSplitSize();
String keyspace = config.getKeyspace();
String columnFamily = config.getColumnFamily();
String partitionerClassName = config.getPartitionerClassName();
IPartitioner partitioner = Utils.newTypeInstance(partitionerClassName, IPartitioner.class);
return new ThriftRangeUtils(partitioner, host, rpcPort, keyspace, columnFamily, splitSize);
} | java | public static ThriftRangeUtils build(CassandraDeepJobConfig config) {
String host = config.getHost();
int rpcPort = config.getRpcPort();
int splitSize = config.getSplitSize();
String keyspace = config.getKeyspace();
String columnFamily = config.getColumnFamily();
String partitionerClassName = config.getPartitionerClassName();
IPartitioner partitioner = Utils.newTypeInstance(partitionerClassName, IPartitioner.class);
return new ThriftRangeUtils(partitioner, host, rpcPort, keyspace, columnFamily, splitSize);
} | [
"public",
"static",
"ThriftRangeUtils",
"build",
"(",
"CassandraDeepJobConfig",
"config",
")",
"{",
"String",
"host",
"=",
"config",
".",
"getHost",
"(",
")",
";",
"int",
"rpcPort",
"=",
"config",
".",
"getRpcPort",
"(",
")",
";",
"int",
"splitSize",
"=",
"config",
".",
"getSplitSize",
"(",
")",
";",
"String",
"keyspace",
"=",
"config",
".",
"getKeyspace",
"(",
")",
";",
"String",
"columnFamily",
"=",
"config",
".",
"getColumnFamily",
"(",
")",
";",
"String",
"partitionerClassName",
"=",
"config",
".",
"getPartitionerClassName",
"(",
")",
";",
"IPartitioner",
"partitioner",
"=",
"Utils",
".",
"newTypeInstance",
"(",
"partitionerClassName",
",",
"IPartitioner",
".",
"class",
")",
";",
"return",
"new",
"ThriftRangeUtils",
"(",
"partitioner",
",",
"host",
",",
"rpcPort",
",",
"keyspace",
",",
"columnFamily",
",",
"splitSize",
")",
";",
"}"
] | Returns a new {@link ThriftRangeUtils} using the specified configuration.
@param config the Deep configuration object. | [
"Returns",
"a",
"new",
"{",
"@link",
"ThriftRangeUtils",
"}",
"using",
"the",
"specified",
"configuration",
"."
] | train | https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-cassandra/src/main/java/com/stratio/deep/cassandra/thrift/ThriftRangeUtils.java#L88-L97 |
Alluxio/alluxio | underfs/wasb/src/main/java/alluxio/underfs/wasb/WasbUnderFileSystem.java | WasbUnderFileSystem.createInstance | public static WasbUnderFileSystem createInstance(AlluxioURI uri,
UnderFileSystemConfiguration conf, AlluxioConfiguration alluxioConf) {
"""
Factory method to construct a new Wasb {@link UnderFileSystem}.
@param uri the {@link AlluxioURI} for this UFS
@param conf the configuration for this UFS
@param alluxioConf Alluxio configuration
@return a new Wasb {@link UnderFileSystem} instance
"""
Configuration wasbConf = createConfiguration(conf);
return new WasbUnderFileSystem(uri, conf, wasbConf, alluxioConf);
} | java | public static WasbUnderFileSystem createInstance(AlluxioURI uri,
UnderFileSystemConfiguration conf, AlluxioConfiguration alluxioConf) {
Configuration wasbConf = createConfiguration(conf);
return new WasbUnderFileSystem(uri, conf, wasbConf, alluxioConf);
} | [
"public",
"static",
"WasbUnderFileSystem",
"createInstance",
"(",
"AlluxioURI",
"uri",
",",
"UnderFileSystemConfiguration",
"conf",
",",
"AlluxioConfiguration",
"alluxioConf",
")",
"{",
"Configuration",
"wasbConf",
"=",
"createConfiguration",
"(",
"conf",
")",
";",
"return",
"new",
"WasbUnderFileSystem",
"(",
"uri",
",",
"conf",
",",
"wasbConf",
",",
"alluxioConf",
")",
";",
"}"
] | Factory method to construct a new Wasb {@link UnderFileSystem}.
@param uri the {@link AlluxioURI} for this UFS
@param conf the configuration for this UFS
@param alluxioConf Alluxio configuration
@return a new Wasb {@link UnderFileSystem} instance | [
"Factory",
"method",
"to",
"construct",
"a",
"new",
"Wasb",
"{",
"@link",
"UnderFileSystem",
"}",
"."
] | train | https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/underfs/wasb/src/main/java/alluxio/underfs/wasb/WasbUnderFileSystem.java#L70-L74 |
voldemort/voldemort | src/java/voldemort/store/readonly/chunk/ChunkedFileSet.java | ChunkedFileSet.renameReadOnlyV2Files | private void renameReadOnlyV2Files(int masterPartitionId, int correctReplicaType) {
"""
This function looks for files with the "wrong" replica type in their name, and
if it finds any, renames them.
Those files may have ended up on this server either because:
- 1. We restored them from another server, where they were named according to
another replica type. Or,
- 2. The {@link voldemort.store.readonly.mr.azkaban.VoldemortBuildAndPushJob}
and the {@link voldemort.store.readonly.fetcher.HdfsFetcher} are
operating in 'build.primary.replicas.only' mode, so they only ever built
and fetched replica 0 of any given file.
Note: This is an implementation detail of the READONLY_V2 naming scheme, and should
not be used outside of that scope.
@param masterPartitionId partition ID of the "primary replica"
@param correctReplicaType replica number which should be found on the current
node for the provided masterPartitionId.
"""
for (int replica = 0; replica < routingStrategy.getNumReplicas(); replica++) {
if (replica != correctReplicaType) {
int chunkId = 0;
while (true) {
String fileName = Integer.toString(masterPartitionId) + "_"
+ Integer.toString(replica) + "_"
+ Integer.toString(chunkId);
File index = getIndexFile(fileName);
File data = getDataFile(fileName);
if(index.exists() && data.exists()) {
// We found files with the "wrong" replica type, so let's rename them
String correctFileName = Integer.toString(masterPartitionId) + "_"
+ Integer.toString(correctReplicaType) + "_"
+ Integer.toString(chunkId);
File indexWithCorrectReplicaType = getIndexFile(correctFileName);
File dataWithCorrectReplicaType = getDataFile(correctFileName);
Utils.move(index, indexWithCorrectReplicaType);
Utils.move(data, dataWithCorrectReplicaType);
// Maybe change this to DEBUG?
logger.info("Renamed files with wrong replica type: "
+ index.getAbsolutePath() + "|data -> "
+ indexWithCorrectReplicaType.getName() + "|data");
} else if(index.exists() ^ data.exists()) {
throw new VoldemortException("One of the following does not exist: "
+ index.toString()
+ " or "
+ data.toString() + ".");
} else {
// The files don't exist, or we've gone over all available chunks,
// so let's move on.
break;
}
chunkId++;
}
}
}
} | java | private void renameReadOnlyV2Files(int masterPartitionId, int correctReplicaType) {
for (int replica = 0; replica < routingStrategy.getNumReplicas(); replica++) {
if (replica != correctReplicaType) {
int chunkId = 0;
while (true) {
String fileName = Integer.toString(masterPartitionId) + "_"
+ Integer.toString(replica) + "_"
+ Integer.toString(chunkId);
File index = getIndexFile(fileName);
File data = getDataFile(fileName);
if(index.exists() && data.exists()) {
// We found files with the "wrong" replica type, so let's rename them
String correctFileName = Integer.toString(masterPartitionId) + "_"
+ Integer.toString(correctReplicaType) + "_"
+ Integer.toString(chunkId);
File indexWithCorrectReplicaType = getIndexFile(correctFileName);
File dataWithCorrectReplicaType = getDataFile(correctFileName);
Utils.move(index, indexWithCorrectReplicaType);
Utils.move(data, dataWithCorrectReplicaType);
// Maybe change this to DEBUG?
logger.info("Renamed files with wrong replica type: "
+ index.getAbsolutePath() + "|data -> "
+ indexWithCorrectReplicaType.getName() + "|data");
} else if(index.exists() ^ data.exists()) {
throw new VoldemortException("One of the following does not exist: "
+ index.toString()
+ " or "
+ data.toString() + ".");
} else {
// The files don't exist, or we've gone over all available chunks,
// so let's move on.
break;
}
chunkId++;
}
}
}
} | [
"private",
"void",
"renameReadOnlyV2Files",
"(",
"int",
"masterPartitionId",
",",
"int",
"correctReplicaType",
")",
"{",
"for",
"(",
"int",
"replica",
"=",
"0",
";",
"replica",
"<",
"routingStrategy",
".",
"getNumReplicas",
"(",
")",
";",
"replica",
"++",
")",
"{",
"if",
"(",
"replica",
"!=",
"correctReplicaType",
")",
"{",
"int",
"chunkId",
"=",
"0",
";",
"while",
"(",
"true",
")",
"{",
"String",
"fileName",
"=",
"Integer",
".",
"toString",
"(",
"masterPartitionId",
")",
"+",
"\"_\"",
"+",
"Integer",
".",
"toString",
"(",
"replica",
")",
"+",
"\"_\"",
"+",
"Integer",
".",
"toString",
"(",
"chunkId",
")",
";",
"File",
"index",
"=",
"getIndexFile",
"(",
"fileName",
")",
";",
"File",
"data",
"=",
"getDataFile",
"(",
"fileName",
")",
";",
"if",
"(",
"index",
".",
"exists",
"(",
")",
"&&",
"data",
".",
"exists",
"(",
")",
")",
"{",
"// We found files with the \"wrong\" replica type, so let's rename them",
"String",
"correctFileName",
"=",
"Integer",
".",
"toString",
"(",
"masterPartitionId",
")",
"+",
"\"_\"",
"+",
"Integer",
".",
"toString",
"(",
"correctReplicaType",
")",
"+",
"\"_\"",
"+",
"Integer",
".",
"toString",
"(",
"chunkId",
")",
";",
"File",
"indexWithCorrectReplicaType",
"=",
"getIndexFile",
"(",
"correctFileName",
")",
";",
"File",
"dataWithCorrectReplicaType",
"=",
"getDataFile",
"(",
"correctFileName",
")",
";",
"Utils",
".",
"move",
"(",
"index",
",",
"indexWithCorrectReplicaType",
")",
";",
"Utils",
".",
"move",
"(",
"data",
",",
"dataWithCorrectReplicaType",
")",
";",
"// Maybe change this to DEBUG?",
"logger",
".",
"info",
"(",
"\"Renamed files with wrong replica type: \"",
"+",
"index",
".",
"getAbsolutePath",
"(",
")",
"+",
"\"|data -> \"",
"+",
"indexWithCorrectReplicaType",
".",
"getName",
"(",
")",
"+",
"\"|data\"",
")",
";",
"}",
"else",
"if",
"(",
"index",
".",
"exists",
"(",
")",
"^",
"data",
".",
"exists",
"(",
")",
")",
"{",
"throw",
"new",
"VoldemortException",
"(",
"\"One of the following does not exist: \"",
"+",
"index",
".",
"toString",
"(",
")",
"+",
"\" or \"",
"+",
"data",
".",
"toString",
"(",
")",
"+",
"\".\"",
")",
";",
"}",
"else",
"{",
"// The files don't exist, or we've gone over all available chunks,",
"// so let's move on.",
"break",
";",
"}",
"chunkId",
"++",
";",
"}",
"}",
"}",
"}"
] | This function looks for files with the "wrong" replica type in their name, and
if it finds any, renames them.
Those files may have ended up on this server either because:
- 1. We restored them from another server, where they were named according to
another replica type. Or,
- 2. The {@link voldemort.store.readonly.mr.azkaban.VoldemortBuildAndPushJob}
and the {@link voldemort.store.readonly.fetcher.HdfsFetcher} are
operating in 'build.primary.replicas.only' mode, so they only ever built
and fetched replica 0 of any given file.
Note: This is an implementation detail of the READONLY_V2 naming scheme, and should
not be used outside of that scope.
@param masterPartitionId partition ID of the "primary replica"
@param correctReplicaType replica number which should be found on the current
node for the provided masterPartitionId. | [
"This",
"function",
"looks",
"for",
"files",
"with",
"the",
"wrong",
"replica",
"type",
"in",
"their",
"name",
"and",
"if",
"it",
"finds",
"any",
"renames",
"them",
"."
] | train | https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/store/readonly/chunk/ChunkedFileSet.java#L299-L340 |
drapostolos/rdp4j | src/main/java/com/github/drapostolos/rdp4j/ListenerNotifier.java | ListenerNotifier.notifyListeners | private <T extends Rdp4jListener> void notifyListeners(Class<T> listenerType, Notifier<T> notifier)
throws InterruptedException {
"""
/*
Ignore if a listener crashes. Log on ERROR level and continue with next listener.
Don't let one listener ruin for other listeners...
if interrupted re-throw InterruptedException.
"""
for (Rdp4jListener listener : listeners) {
if (isInstanceOf(listener, listenerType)) {
/*
* This cast is correct, since we check if listener
* is instance of listenerType.
*/
@SuppressWarnings("unchecked")
T listener2 = (T) listener;
try {
notifier.notify(listener2);
} catch (InterruptedException e) {
throw e;
} catch (Throwable e) {
logErrorMessage(e);
}
}
}
} | java | private <T extends Rdp4jListener> void notifyListeners(Class<T> listenerType, Notifier<T> notifier)
throws InterruptedException {
for (Rdp4jListener listener : listeners) {
if (isInstanceOf(listener, listenerType)) {
/*
* This cast is correct, since we check if listener
* is instance of listenerType.
*/
@SuppressWarnings("unchecked")
T listener2 = (T) listener;
try {
notifier.notify(listener2);
} catch (InterruptedException e) {
throw e;
} catch (Throwable e) {
logErrorMessage(e);
}
}
}
} | [
"private",
"<",
"T",
"extends",
"Rdp4jListener",
">",
"void",
"notifyListeners",
"(",
"Class",
"<",
"T",
">",
"listenerType",
",",
"Notifier",
"<",
"T",
">",
"notifier",
")",
"throws",
"InterruptedException",
"{",
"for",
"(",
"Rdp4jListener",
"listener",
":",
"listeners",
")",
"{",
"if",
"(",
"isInstanceOf",
"(",
"listener",
",",
"listenerType",
")",
")",
"{",
"/*\n * This cast is correct, since we check if listener\n * is instance of listenerType.\n */",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"T",
"listener2",
"=",
"(",
"T",
")",
"listener",
";",
"try",
"{",
"notifier",
".",
"notify",
"(",
"listener2",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"throw",
"e",
";",
"}",
"catch",
"(",
"Throwable",
"e",
")",
"{",
"logErrorMessage",
"(",
"e",
")",
";",
"}",
"}",
"}",
"}"
] | /*
Ignore if a listener crashes. Log on ERROR level and continue with next listener.
Don't let one listener ruin for other listeners...
if interrupted re-throw InterruptedException. | [
"/",
"*",
"Ignore",
"if",
"a",
"listener",
"crashes",
".",
"Log",
"on",
"ERROR",
"level",
"and",
"continue",
"with",
"next",
"listener",
".",
"Don",
"t",
"let",
"one",
"listener",
"ruin",
"for",
"other",
"listeners",
"...",
"if",
"interrupted",
"re",
"-",
"throw",
"InterruptedException",
"."
] | train | https://github.com/drapostolos/rdp4j/blob/ec1db2444d245b7ccd6607182bb56a027fa66d6b/src/main/java/com/github/drapostolos/rdp4j/ListenerNotifier.java#L159-L178 |
jbundle/jbundle | base/screen/view/html/src/main/java/org/jbundle/base/screen/view/html/HBaseGridScreen.java | HBaseGridScreen.printNavButtonControls | public void printNavButtonControls(PrintWriter out, int iPrintOptions) {
"""
Display the end grid in input format.
@return true if default params were found for this form.
@param out The http output stream.
@exception DBException File exception.
"""
out.println("<tr>");
int iNumCols = ((BaseGridScreen)this.getScreenField()).getSFieldCount();
for (int i = 0; i < iNumCols; i++)
{ // First, print the nav controls
ScreenField sField = ((BaseGridScreen)this.getScreenField()).getSField(i);
HScreenField sFieldView = (HScreenField)sField.getScreenFieldView();
boolean bPrintControl = this.getScreenField().isPrintableControl(sField, iPrintOptions);
//x if (sField instanceof BasePanel)
//x bPrintControl = false; // ?
if (i < ((BaseGridScreen)this.getScreenField()).getNavCount())
bPrintControl = true;
if (bPrintControl)
sFieldView.printHtmlHeading(out);
}
out.println("</tr>");
} | java | public void printNavButtonControls(PrintWriter out, int iPrintOptions)
{
out.println("<tr>");
int iNumCols = ((BaseGridScreen)this.getScreenField()).getSFieldCount();
for (int i = 0; i < iNumCols; i++)
{ // First, print the nav controls
ScreenField sField = ((BaseGridScreen)this.getScreenField()).getSField(i);
HScreenField sFieldView = (HScreenField)sField.getScreenFieldView();
boolean bPrintControl = this.getScreenField().isPrintableControl(sField, iPrintOptions);
//x if (sField instanceof BasePanel)
//x bPrintControl = false; // ?
if (i < ((BaseGridScreen)this.getScreenField()).getNavCount())
bPrintControl = true;
if (bPrintControl)
sFieldView.printHtmlHeading(out);
}
out.println("</tr>");
} | [
"public",
"void",
"printNavButtonControls",
"(",
"PrintWriter",
"out",
",",
"int",
"iPrintOptions",
")",
"{",
"out",
".",
"println",
"(",
"\"<tr>\"",
")",
";",
"int",
"iNumCols",
"=",
"(",
"(",
"BaseGridScreen",
")",
"this",
".",
"getScreenField",
"(",
")",
")",
".",
"getSFieldCount",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"iNumCols",
";",
"i",
"++",
")",
"{",
"// First, print the nav controls",
"ScreenField",
"sField",
"=",
"(",
"(",
"BaseGridScreen",
")",
"this",
".",
"getScreenField",
"(",
")",
")",
".",
"getSField",
"(",
"i",
")",
";",
"HScreenField",
"sFieldView",
"=",
"(",
"HScreenField",
")",
"sField",
".",
"getScreenFieldView",
"(",
")",
";",
"boolean",
"bPrintControl",
"=",
"this",
".",
"getScreenField",
"(",
")",
".",
"isPrintableControl",
"(",
"sField",
",",
"iPrintOptions",
")",
";",
"//x if (sField instanceof BasePanel)",
"//x bPrintControl = false; // ?",
"if",
"(",
"i",
"<",
"(",
"(",
"BaseGridScreen",
")",
"this",
".",
"getScreenField",
"(",
")",
")",
".",
"getNavCount",
"(",
")",
")",
"bPrintControl",
"=",
"true",
";",
"if",
"(",
"bPrintControl",
")",
"sFieldView",
".",
"printHtmlHeading",
"(",
"out",
")",
";",
"}",
"out",
".",
"println",
"(",
"\"</tr>\"",
")",
";",
"}"
] | Display the end grid in input format.
@return true if default params were found for this form.
@param out The http output stream.
@exception DBException File exception. | [
"Display",
"the",
"end",
"grid",
"in",
"input",
"format",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/view/html/src/main/java/org/jbundle/base/screen/view/html/HBaseGridScreen.java#L189-L206 |
alipay/sofa-hessian | src/main/java/com/caucho/hessian/io/Hessian2Output.java | Hessian2Output.writeFault | public void writeFault(String code, String message, Object detail)
throws IOException {
"""
Writes a fault. The fault will be written
as a descriptive string followed by an object:
<code><pre>
F map
</pre></code>
<code><pre>
F H
\x04code
\x10the fault code
\x07message
\x11the fault message
\x06detail
M\xnnjavax.ejb.FinderException
...
Z
Z
</pre></code>
@param code the fault code, a three digit
"""
flushIfFull();
writeVersion();
_buffer[_offset++] = (byte) 'F';
_buffer[_offset++] = (byte) 'H';
addRef(new Object(), _refCount++, false);
writeString("code");
writeString(code);
writeString("message");
writeString(message);
if (detail != null) {
writeString("detail");
writeObject(detail);
}
flushIfFull();
_buffer[_offset++] = (byte) 'Z';
} | java | public void writeFault(String code, String message, Object detail)
throws IOException
{
flushIfFull();
writeVersion();
_buffer[_offset++] = (byte) 'F';
_buffer[_offset++] = (byte) 'H';
addRef(new Object(), _refCount++, false);
writeString("code");
writeString(code);
writeString("message");
writeString(message);
if (detail != null) {
writeString("detail");
writeObject(detail);
}
flushIfFull();
_buffer[_offset++] = (byte) 'Z';
} | [
"public",
"void",
"writeFault",
"(",
"String",
"code",
",",
"String",
"message",
",",
"Object",
"detail",
")",
"throws",
"IOException",
"{",
"flushIfFull",
"(",
")",
";",
"writeVersion",
"(",
")",
";",
"_buffer",
"[",
"_offset",
"++",
"]",
"=",
"(",
"byte",
")",
"'",
"'",
";",
"_buffer",
"[",
"_offset",
"++",
"]",
"=",
"(",
"byte",
")",
"'",
"'",
";",
"addRef",
"(",
"new",
"Object",
"(",
")",
",",
"_refCount",
"++",
",",
"false",
")",
";",
"writeString",
"(",
"\"code\"",
")",
";",
"writeString",
"(",
"code",
")",
";",
"writeString",
"(",
"\"message\"",
")",
";",
"writeString",
"(",
"message",
")",
";",
"if",
"(",
"detail",
"!=",
"null",
")",
"{",
"writeString",
"(",
"\"detail\"",
")",
";",
"writeObject",
"(",
"detail",
")",
";",
"}",
"flushIfFull",
"(",
")",
";",
"_buffer",
"[",
"_offset",
"++",
"]",
"=",
"(",
"byte",
")",
"'",
"'",
";",
"}"
] | Writes a fault. The fault will be written
as a descriptive string followed by an object:
<code><pre>
F map
</pre></code>
<code><pre>
F H
\x04code
\x10the fault code
\x07message
\x11the fault message
\x06detail
M\xnnjavax.ejb.FinderException
...
Z
Z
</pre></code>
@param code the fault code, a three digit | [
"Writes",
"a",
"fault",
".",
"The",
"fault",
"will",
"be",
"written",
"as",
"a",
"descriptive",
"string",
"followed",
"by",
"an",
"object",
":"
] | train | https://github.com/alipay/sofa-hessian/blob/89e4f5af28602101dab7b498995018871616357b/src/main/java/com/caucho/hessian/io/Hessian2Output.java#L421-L446 |
joniles/mpxj | src/main/java/net/sf/mpxj/conceptdraw/ConceptDrawProjectReader.java | ConceptDrawProjectReader.readExceptionDay | private void readExceptionDay(ProjectCalendar mpxjCalendar, ExceptedDay day) {
"""
Read an exception day for a calendar.
@param mpxjCalendar ProjectCalendar instance
@param day ConceptDraw PROJECT exception day
"""
ProjectCalendarException mpxjException = mpxjCalendar.addCalendarException(day.getDate(), day.getDate());
if (day.isIsDayWorking())
{
for (Document.Calendars.Calendar.ExceptedDays.ExceptedDay.TimePeriods.TimePeriod period : day.getTimePeriods().getTimePeriod())
{
mpxjException.addRange(new DateRange(period.getFrom(), period.getTo()));
}
}
} | java | private void readExceptionDay(ProjectCalendar mpxjCalendar, ExceptedDay day)
{
ProjectCalendarException mpxjException = mpxjCalendar.addCalendarException(day.getDate(), day.getDate());
if (day.isIsDayWorking())
{
for (Document.Calendars.Calendar.ExceptedDays.ExceptedDay.TimePeriods.TimePeriod period : day.getTimePeriods().getTimePeriod())
{
mpxjException.addRange(new DateRange(period.getFrom(), period.getTo()));
}
}
} | [
"private",
"void",
"readExceptionDay",
"(",
"ProjectCalendar",
"mpxjCalendar",
",",
"ExceptedDay",
"day",
")",
"{",
"ProjectCalendarException",
"mpxjException",
"=",
"mpxjCalendar",
".",
"addCalendarException",
"(",
"day",
".",
"getDate",
"(",
")",
",",
"day",
".",
"getDate",
"(",
")",
")",
";",
"if",
"(",
"day",
".",
"isIsDayWorking",
"(",
")",
")",
"{",
"for",
"(",
"Document",
".",
"Calendars",
".",
"Calendar",
".",
"ExceptedDays",
".",
"ExceptedDay",
".",
"TimePeriods",
".",
"TimePeriod",
"period",
":",
"day",
".",
"getTimePeriods",
"(",
")",
".",
"getTimePeriod",
"(",
")",
")",
"{",
"mpxjException",
".",
"addRange",
"(",
"new",
"DateRange",
"(",
"period",
".",
"getFrom",
"(",
")",
",",
"period",
".",
"getTo",
"(",
")",
")",
")",
";",
"}",
"}",
"}"
] | Read an exception day for a calendar.
@param mpxjCalendar ProjectCalendar instance
@param day ConceptDraw PROJECT exception day | [
"Read",
"an",
"exception",
"day",
"for",
"a",
"calendar",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/conceptdraw/ConceptDrawProjectReader.java#L271-L281 |
google/error-prone-javac | src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsWriter.java | JdepsWriter.toTag | String toTag(Archive source, String name, Archive target) {
"""
If the given archive is JDK archive, this method returns the profile name
only if -profile option is specified; it accesses a private JDK API and
the returned value will have "JDK internal API" prefix
For non-JDK archives, this method returns the file name of the archive.
"""
if (source == target || !target.getModule().isNamed()) {
return target.getName();
}
Module module = target.getModule();
String pn = name;
if ((type == CLASS || type == VERBOSE)) {
int i = name.lastIndexOf('.');
pn = i > 0 ? name.substring(0, i) : "";
}
// exported API
if (module.isExported(pn) && !module.isJDKUnsupported()) {
return showProfileOrModule(module);
}
// JDK internal API
if (!source.getModule().isJDK() && module.isJDK()){
return "JDK internal API (" + module.name() + ")";
}
// qualified exports or inaccessible
boolean isExported = module.isExported(pn, source.getModule().name());
return module.name() + (isExported ? " (qualified)" : " (internal)");
} | java | String toTag(Archive source, String name, Archive target) {
if (source == target || !target.getModule().isNamed()) {
return target.getName();
}
Module module = target.getModule();
String pn = name;
if ((type == CLASS || type == VERBOSE)) {
int i = name.lastIndexOf('.');
pn = i > 0 ? name.substring(0, i) : "";
}
// exported API
if (module.isExported(pn) && !module.isJDKUnsupported()) {
return showProfileOrModule(module);
}
// JDK internal API
if (!source.getModule().isJDK() && module.isJDK()){
return "JDK internal API (" + module.name() + ")";
}
// qualified exports or inaccessible
boolean isExported = module.isExported(pn, source.getModule().name());
return module.name() + (isExported ? " (qualified)" : " (internal)");
} | [
"String",
"toTag",
"(",
"Archive",
"source",
",",
"String",
"name",
",",
"Archive",
"target",
")",
"{",
"if",
"(",
"source",
"==",
"target",
"||",
"!",
"target",
".",
"getModule",
"(",
")",
".",
"isNamed",
"(",
")",
")",
"{",
"return",
"target",
".",
"getName",
"(",
")",
";",
"}",
"Module",
"module",
"=",
"target",
".",
"getModule",
"(",
")",
";",
"String",
"pn",
"=",
"name",
";",
"if",
"(",
"(",
"type",
"==",
"CLASS",
"||",
"type",
"==",
"VERBOSE",
")",
")",
"{",
"int",
"i",
"=",
"name",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"pn",
"=",
"i",
">",
"0",
"?",
"name",
".",
"substring",
"(",
"0",
",",
"i",
")",
":",
"\"\"",
";",
"}",
"// exported API",
"if",
"(",
"module",
".",
"isExported",
"(",
"pn",
")",
"&&",
"!",
"module",
".",
"isJDKUnsupported",
"(",
")",
")",
"{",
"return",
"showProfileOrModule",
"(",
"module",
")",
";",
"}",
"// JDK internal API",
"if",
"(",
"!",
"source",
".",
"getModule",
"(",
")",
".",
"isJDK",
"(",
")",
"&&",
"module",
".",
"isJDK",
"(",
")",
")",
"{",
"return",
"\"JDK internal API (\"",
"+",
"module",
".",
"name",
"(",
")",
"+",
"\")\"",
";",
"}",
"// qualified exports or inaccessible",
"boolean",
"isExported",
"=",
"module",
".",
"isExported",
"(",
"pn",
",",
"source",
".",
"getModule",
"(",
")",
".",
"name",
"(",
")",
")",
";",
"return",
"module",
".",
"name",
"(",
")",
"+",
"(",
"isExported",
"?",
"\" (qualified)\"",
":",
"\" (internal)\"",
")",
";",
"}"
] | If the given archive is JDK archive, this method returns the profile name
only if -profile option is specified; it accesses a private JDK API and
the returned value will have "JDK internal API" prefix
For non-JDK archives, this method returns the file name of the archive. | [
"If",
"the",
"given",
"archive",
"is",
"JDK",
"archive",
"this",
"method",
"returns",
"the",
"profile",
"name",
"only",
"if",
"-",
"profile",
"option",
"is",
"specified",
";",
"it",
"accesses",
"a",
"private",
"JDK",
"API",
"and",
"the",
"returned",
"value",
"will",
"have",
"JDK",
"internal",
"API",
"prefix"
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsWriter.java#L308-L333 |
tommyettinger/RegExodus | src/main/java/regexodus/ds/CharArrayList.java | CharArrayList.removeElements | public void removeElements(final int from, final int to) {
"""
Removes elements of this type-specific list using optimized system calls.
@param from the start index (inclusive).
@param to the end index (exclusive).
"""
CharArrays.ensureFromTo(size, from, to);
System.arraycopy(a, to, a, from, size - to);
size -= (to - from);
} | java | public void removeElements(final int from, final int to) {
CharArrays.ensureFromTo(size, from, to);
System.arraycopy(a, to, a, from, size - to);
size -= (to - from);
} | [
"public",
"void",
"removeElements",
"(",
"final",
"int",
"from",
",",
"final",
"int",
"to",
")",
"{",
"CharArrays",
".",
"ensureFromTo",
"(",
"size",
",",
"from",
",",
"to",
")",
";",
"System",
".",
"arraycopy",
"(",
"a",
",",
"to",
",",
"a",
",",
"from",
",",
"size",
"-",
"to",
")",
";",
"size",
"-=",
"(",
"to",
"-",
"from",
")",
";",
"}"
] | Removes elements of this type-specific list using optimized system calls.
@param from the start index (inclusive).
@param to the end index (exclusive). | [
"Removes",
"elements",
"of",
"this",
"type",
"-",
"specific",
"list",
"using",
"optimized",
"system",
"calls",
"."
] | train | https://github.com/tommyettinger/RegExodus/blob/d4af9bb7c132c5f9d29f45b76121f93b2f89de16/src/main/java/regexodus/ds/CharArrayList.java#L481-L485 |
google/closure-templates | java/src/com/google/template/soy/jbcsrc/restricted/Expression.java | Expression.asNonNullable | public Expression asNonNullable() {
"""
Returns an equivalent expression where {@link #isNonNullable()} returns {@code true}.
"""
if (isNonNullable()) {
return this;
}
return new Expression(resultType, features.plus(Feature.NON_NULLABLE)) {
@Override
protected void doGen(CodeBuilder adapter) {
Expression.this.gen(adapter);
}
};
} | java | public Expression asNonNullable() {
if (isNonNullable()) {
return this;
}
return new Expression(resultType, features.plus(Feature.NON_NULLABLE)) {
@Override
protected void doGen(CodeBuilder adapter) {
Expression.this.gen(adapter);
}
};
} | [
"public",
"Expression",
"asNonNullable",
"(",
")",
"{",
"if",
"(",
"isNonNullable",
"(",
")",
")",
"{",
"return",
"this",
";",
"}",
"return",
"new",
"Expression",
"(",
"resultType",
",",
"features",
".",
"plus",
"(",
"Feature",
".",
"NON_NULLABLE",
")",
")",
"{",
"@",
"Override",
"protected",
"void",
"doGen",
"(",
"CodeBuilder",
"adapter",
")",
"{",
"Expression",
".",
"this",
".",
"gen",
"(",
"adapter",
")",
";",
"}",
"}",
";",
"}"
] | Returns an equivalent expression where {@link #isNonNullable()} returns {@code true}. | [
"Returns",
"an",
"equivalent",
"expression",
"where",
"{"
] | train | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/restricted/Expression.java#L312-L322 |
apache/incubator-gobblin | gobblin-metrics-libs/gobblin-metrics-base/src/main/java/org/apache/gobblin/metrics/event/MultiTimingEvent.java | MultiTimingEvent.endStage | public void endStage() {
"""
End the previous stage and record the time spent in that stage.
"""
if (this.currentStage != null) {
long time = System.currentTimeMillis() - this.currentStageStart;
this.timings.add(new Stage(this.currentStage, time));
if (reportAsMetrics && submitter.getMetricContext().isPresent()) {
String timerName = submitter.getNamespace() + "." + name + "." + this.currentStage;
submitter.getMetricContext().get().timer(timerName).update(time, TimeUnit.MILLISECONDS);
}
}
this.currentStage = null;
} | java | public void endStage() {
if (this.currentStage != null) {
long time = System.currentTimeMillis() - this.currentStageStart;
this.timings.add(new Stage(this.currentStage, time));
if (reportAsMetrics && submitter.getMetricContext().isPresent()) {
String timerName = submitter.getNamespace() + "." + name + "." + this.currentStage;
submitter.getMetricContext().get().timer(timerName).update(time, TimeUnit.MILLISECONDS);
}
}
this.currentStage = null;
} | [
"public",
"void",
"endStage",
"(",
")",
"{",
"if",
"(",
"this",
".",
"currentStage",
"!=",
"null",
")",
"{",
"long",
"time",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"this",
".",
"currentStageStart",
";",
"this",
".",
"timings",
".",
"add",
"(",
"new",
"Stage",
"(",
"this",
".",
"currentStage",
",",
"time",
")",
")",
";",
"if",
"(",
"reportAsMetrics",
"&&",
"submitter",
".",
"getMetricContext",
"(",
")",
".",
"isPresent",
"(",
")",
")",
"{",
"String",
"timerName",
"=",
"submitter",
".",
"getNamespace",
"(",
")",
"+",
"\".\"",
"+",
"name",
"+",
"\".\"",
"+",
"this",
".",
"currentStage",
";",
"submitter",
".",
"getMetricContext",
"(",
")",
".",
"get",
"(",
")",
".",
"timer",
"(",
"timerName",
")",
".",
"update",
"(",
"time",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
";",
"}",
"}",
"this",
".",
"currentStage",
"=",
"null",
";",
"}"
] | End the previous stage and record the time spent in that stage. | [
"End",
"the",
"previous",
"stage",
"and",
"record",
"the",
"time",
"spent",
"in",
"that",
"stage",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-metrics-libs/gobblin-metrics-base/src/main/java/org/apache/gobblin/metrics/event/MultiTimingEvent.java#L97-L107 |
google/closure-templates | java/src/com/google/template/soy/jbcsrc/restricted/BytecodeUtils.java | BytecodeUtils.newLinkedHashMap | public static Expression newLinkedHashMap(
Iterable<? extends Expression> keys, Iterable<? extends Expression> values) {
"""
Returns an expression that returns a new {@link LinkedHashMap} containing all the given
entries.
"""
return newMap(keys, values, ConstructorRef.LINKED_HASH_MAP_CAPACITY, LINKED_HASH_MAP_TYPE);
} | java | public static Expression newLinkedHashMap(
Iterable<? extends Expression> keys, Iterable<? extends Expression> values) {
return newMap(keys, values, ConstructorRef.LINKED_HASH_MAP_CAPACITY, LINKED_HASH_MAP_TYPE);
} | [
"public",
"static",
"Expression",
"newLinkedHashMap",
"(",
"Iterable",
"<",
"?",
"extends",
"Expression",
">",
"keys",
",",
"Iterable",
"<",
"?",
"extends",
"Expression",
">",
"values",
")",
"{",
"return",
"newMap",
"(",
"keys",
",",
"values",
",",
"ConstructorRef",
".",
"LINKED_HASH_MAP_CAPACITY",
",",
"LINKED_HASH_MAP_TYPE",
")",
";",
"}"
] | Returns an expression that returns a new {@link LinkedHashMap} containing all the given
entries. | [
"Returns",
"an",
"expression",
"that",
"returns",
"a",
"new",
"{"
] | train | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/restricted/BytecodeUtils.java#L907-L910 |
apache/flink | flink-core/src/main/java/org/apache/flink/types/StringValue.java | StringValue.setValue | public void setValue(char[] chars, int offset, int len) {
"""
Sets the value of the StringValue to a substring of the given value.
@param chars The new string value (as a character array).
@param offset The position to start the substring.
@param len The length of the substring.
"""
checkNotNull(chars);
if (offset < 0 || len < 0 || offset > chars.length - len) {
throw new IndexOutOfBoundsException();
}
ensureSize(len);
System.arraycopy(chars, offset, this.value, 0, len);
this.len = len;
this.hashCode = 0;
} | java | public void setValue(char[] chars, int offset, int len) {
checkNotNull(chars);
if (offset < 0 || len < 0 || offset > chars.length - len) {
throw new IndexOutOfBoundsException();
}
ensureSize(len);
System.arraycopy(chars, offset, this.value, 0, len);
this.len = len;
this.hashCode = 0;
} | [
"public",
"void",
"setValue",
"(",
"char",
"[",
"]",
"chars",
",",
"int",
"offset",
",",
"int",
"len",
")",
"{",
"checkNotNull",
"(",
"chars",
")",
";",
"if",
"(",
"offset",
"<",
"0",
"||",
"len",
"<",
"0",
"||",
"offset",
">",
"chars",
".",
"length",
"-",
"len",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
")",
";",
"}",
"ensureSize",
"(",
"len",
")",
";",
"System",
".",
"arraycopy",
"(",
"chars",
",",
"offset",
",",
"this",
".",
"value",
",",
"0",
",",
"len",
")",
";",
"this",
".",
"len",
"=",
"len",
";",
"this",
".",
"hashCode",
"=",
"0",
";",
"}"
] | Sets the value of the StringValue to a substring of the given value.
@param chars The new string value (as a character array).
@param offset The position to start the substring.
@param len The length of the substring. | [
"Sets",
"the",
"value",
"of",
"the",
"StringValue",
"to",
"a",
"substring",
"of",
"the",
"given",
"value",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/types/StringValue.java#L221-L231 |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/lib/StringConverter.java | StringConverter.inputStreamToString | public static String inputStreamToString(InputStream x,
String encoding) throws IOException {
"""
Using a Reader and a Writer, returns a String from an InputStream.
Method based on Hypersonic Code
@param x InputStream to read from
@throws IOException
@return a Java string
"""
InputStreamReader in = new InputStreamReader(x, encoding);
StringWriter writer = new StringWriter();
int blocksize = 8 * 1024;
char[] buffer = new char[blocksize];
for (;;) {
int read = in.read(buffer);
if (read == -1) {
break;
}
writer.write(buffer, 0, read);
}
writer.close();
return writer.toString();
} | java | public static String inputStreamToString(InputStream x,
String encoding) throws IOException {
InputStreamReader in = new InputStreamReader(x, encoding);
StringWriter writer = new StringWriter();
int blocksize = 8 * 1024;
char[] buffer = new char[blocksize];
for (;;) {
int read = in.read(buffer);
if (read == -1) {
break;
}
writer.write(buffer, 0, read);
}
writer.close();
return writer.toString();
} | [
"public",
"static",
"String",
"inputStreamToString",
"(",
"InputStream",
"x",
",",
"String",
"encoding",
")",
"throws",
"IOException",
"{",
"InputStreamReader",
"in",
"=",
"new",
"InputStreamReader",
"(",
"x",
",",
"encoding",
")",
";",
"StringWriter",
"writer",
"=",
"new",
"StringWriter",
"(",
")",
";",
"int",
"blocksize",
"=",
"8",
"*",
"1024",
";",
"char",
"[",
"]",
"buffer",
"=",
"new",
"char",
"[",
"blocksize",
"]",
";",
"for",
"(",
";",
";",
")",
"{",
"int",
"read",
"=",
"in",
".",
"read",
"(",
"buffer",
")",
";",
"if",
"(",
"read",
"==",
"-",
"1",
")",
"{",
"break",
";",
"}",
"writer",
".",
"write",
"(",
"buffer",
",",
"0",
",",
"read",
")",
";",
"}",
"writer",
".",
"close",
"(",
")",
";",
"return",
"writer",
".",
"toString",
"(",
")",
";",
"}"
] | Using a Reader and a Writer, returns a String from an InputStream.
Method based on Hypersonic Code
@param x InputStream to read from
@throws IOException
@return a Java string | [
"Using",
"a",
"Reader",
"and",
"a",
"Writer",
"returns",
"a",
"String",
"from",
"an",
"InputStream",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/StringConverter.java#L636-L657 |
infinispan/infinispan | commons/src/main/java/org/infinispan/commons/marshall/MarshallUtil.java | MarshallUtil.marshallByteArray | public static void marshallByteArray(byte[] array, ObjectOutput out) throws IOException {
"""
Same as {@link #marshallArray(Object[], ObjectOutput)} but specialized for byte arrays.
@see #marshallArray(Object[], ObjectOutput).
"""
final int size = array == null ? NULL_VALUE : array.length;
marshallSize(out, size);
if (size <= 0) {
return;
}
out.write(array);
} | java | public static void marshallByteArray(byte[] array, ObjectOutput out) throws IOException {
final int size = array == null ? NULL_VALUE : array.length;
marshallSize(out, size);
if (size <= 0) {
return;
}
out.write(array);
} | [
"public",
"static",
"void",
"marshallByteArray",
"(",
"byte",
"[",
"]",
"array",
",",
"ObjectOutput",
"out",
")",
"throws",
"IOException",
"{",
"final",
"int",
"size",
"=",
"array",
"==",
"null",
"?",
"NULL_VALUE",
":",
"array",
".",
"length",
";",
"marshallSize",
"(",
"out",
",",
"size",
")",
";",
"if",
"(",
"size",
"<=",
"0",
")",
"{",
"return",
";",
"}",
"out",
".",
"write",
"(",
"array",
")",
";",
"}"
] | Same as {@link #marshallArray(Object[], ObjectOutput)} but specialized for byte arrays.
@see #marshallArray(Object[], ObjectOutput). | [
"Same",
"as",
"{",
"@link",
"#marshallArray",
"(",
"Object",
"[]",
"ObjectOutput",
")",
"}",
"but",
"specialized",
"for",
"byte",
"arrays",
"."
] | train | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/marshall/MarshallUtil.java#L355-L362 |
jbundle/jbundle | thin/base/message/src/main/java/org/jbundle/thin/base/message/TreeMessage.java | TreeMessage.putNative | public void putNative(String key, Object value) {
"""
Put the raw value for this param in the (xpath) map.
@param strParam The xpath key.
@param objValue The raw data to set this location in the message.
"""
String strValue = null;
if (value != null)
strValue = value.toString();
CreateMode createMode = CreateMode.DONT_CREATE;
if (value != null)
{
createMode = CreateMode.CREATE_IF_NOT_FOUND;
if (Util.isCData(strValue))
createMode = CreateMode.CREATE_CDATA_NODE;
}
Node node = this.getNode(null, key, createMode, true);
if (node != null)
{
if (strValue != null)
node.setNodeValue(strValue);
else
node.getParentNode().removeChild(node);
}
} | java | public void putNative(String key, Object value)
{
String strValue = null;
if (value != null)
strValue = value.toString();
CreateMode createMode = CreateMode.DONT_CREATE;
if (value != null)
{
createMode = CreateMode.CREATE_IF_NOT_FOUND;
if (Util.isCData(strValue))
createMode = CreateMode.CREATE_CDATA_NODE;
}
Node node = this.getNode(null, key, createMode, true);
if (node != null)
{
if (strValue != null)
node.setNodeValue(strValue);
else
node.getParentNode().removeChild(node);
}
} | [
"public",
"void",
"putNative",
"(",
"String",
"key",
",",
"Object",
"value",
")",
"{",
"String",
"strValue",
"=",
"null",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"strValue",
"=",
"value",
".",
"toString",
"(",
")",
";",
"CreateMode",
"createMode",
"=",
"CreateMode",
".",
"DONT_CREATE",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"createMode",
"=",
"CreateMode",
".",
"CREATE_IF_NOT_FOUND",
";",
"if",
"(",
"Util",
".",
"isCData",
"(",
"strValue",
")",
")",
"createMode",
"=",
"CreateMode",
".",
"CREATE_CDATA_NODE",
";",
"}",
"Node",
"node",
"=",
"this",
".",
"getNode",
"(",
"null",
",",
"key",
",",
"createMode",
",",
"true",
")",
";",
"if",
"(",
"node",
"!=",
"null",
")",
"{",
"if",
"(",
"strValue",
"!=",
"null",
")",
"node",
".",
"setNodeValue",
"(",
"strValue",
")",
";",
"else",
"node",
".",
"getParentNode",
"(",
")",
".",
"removeChild",
"(",
"node",
")",
";",
"}",
"}"
] | Put the raw value for this param in the (xpath) map.
@param strParam The xpath key.
@param objValue The raw data to set this location in the message. | [
"Put",
"the",
"raw",
"value",
"for",
"this",
"param",
"in",
"the",
"(",
"xpath",
")",
"map",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/message/src/main/java/org/jbundle/thin/base/message/TreeMessage.java#L114-L134 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java | FileUtil.readUtf8Lines | public static List<String> readUtf8Lines(File file) throws IORuntimeException {
"""
从文件中读取每一行数据
@param file 文件
@return 文件中的每行内容的集合List
@throws IORuntimeException IO异常
@since 3.1.1
"""
return readLines(file, CharsetUtil.CHARSET_UTF_8);
} | java | public static List<String> readUtf8Lines(File file) throws IORuntimeException {
return readLines(file, CharsetUtil.CHARSET_UTF_8);
} | [
"public",
"static",
"List",
"<",
"String",
">",
"readUtf8Lines",
"(",
"File",
"file",
")",
"throws",
"IORuntimeException",
"{",
"return",
"readLines",
"(",
"file",
",",
"CharsetUtil",
".",
"CHARSET_UTF_8",
")",
";",
"}"
] | 从文件中读取每一行数据
@param file 文件
@return 文件中的每行内容的集合List
@throws IORuntimeException IO异常
@since 3.1.1 | [
"从文件中读取每一行数据"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java#L2368-L2370 |
zaproxy/zaproxy | src/org/apache/commons/httpclient/HttpMethodBase.java | HttpMethodBase.readResponse | protected void readResponse(HttpState state, HttpConnection conn)
throws IOException, HttpException {
"""
Reads the response from the given {@link HttpConnection connection}.
<p>
The response is processed as the following sequence of actions:
<ol>
<li>
{@link #readStatusLine(HttpState,HttpConnection)} is
invoked to read the request line.
</li>
<li>
{@link #processStatusLine(HttpState,HttpConnection)}
is invoked, allowing the method to process the status line if
desired.
</li>
<li>
{@link #readResponseHeaders(HttpState,HttpConnection)} is invoked to read
the associated headers.
</li>
<li>
{@link #processResponseHeaders(HttpState,HttpConnection)} is invoked, allowing
the method to process the headers if desired.
</li>
<li>
{@link #readResponseBody(HttpState,HttpConnection)} is
invoked to read the associated body (if any).
</li>
<li>
{@link #processResponseBody(HttpState,HttpConnection)} is invoked, allowing the
method to process the response body if desired.
</li>
</ol>
Subclasses may want to override one or more of the above methods to to
customize the processing. (Or they may choose to override this method
if dramatically different processing is required.)
@param state the {@link HttpState state} information associated with this method
@param conn the {@link HttpConnection connection} used to execute
this HTTP method
@throws IOException if an I/O (transport) error occurs. Some transport exceptions
can be recovered from.
@throws HttpException if a protocol exception occurs. Usually protocol exceptions
cannot be recovered from.
"""
LOG.trace(
"enter HttpMethodBase.readResponse(HttpState, HttpConnection)");
// Status line & line may have already been received
// if 'expect - continue' handshake has been used
while (this.statusLine == null) {
readStatusLine(state, conn);
processStatusLine(state, conn);
readResponseHeaders(state, conn);
processResponseHeaders(state, conn);
int status = this.statusLine.getStatusCode();
if ((status >= 100) && (status < 200)) {
if (LOG.isInfoEnabled()) {
LOG.info("Discarding unexpected response: " + this.statusLine.toString());
}
this.statusLine = null;
}
}
readResponseBody(state, conn);
processResponseBody(state, conn);
} | java | protected void readResponse(HttpState state, HttpConnection conn)
throws IOException, HttpException {
LOG.trace(
"enter HttpMethodBase.readResponse(HttpState, HttpConnection)");
// Status line & line may have already been received
// if 'expect - continue' handshake has been used
while (this.statusLine == null) {
readStatusLine(state, conn);
processStatusLine(state, conn);
readResponseHeaders(state, conn);
processResponseHeaders(state, conn);
int status = this.statusLine.getStatusCode();
if ((status >= 100) && (status < 200)) {
if (LOG.isInfoEnabled()) {
LOG.info("Discarding unexpected response: " + this.statusLine.toString());
}
this.statusLine = null;
}
}
readResponseBody(state, conn);
processResponseBody(state, conn);
} | [
"protected",
"void",
"readResponse",
"(",
"HttpState",
"state",
",",
"HttpConnection",
"conn",
")",
"throws",
"IOException",
",",
"HttpException",
"{",
"LOG",
".",
"trace",
"(",
"\"enter HttpMethodBase.readResponse(HttpState, HttpConnection)\"",
")",
";",
"// Status line & line may have already been received",
"// if 'expect - continue' handshake has been used",
"while",
"(",
"this",
".",
"statusLine",
"==",
"null",
")",
"{",
"readStatusLine",
"(",
"state",
",",
"conn",
")",
";",
"processStatusLine",
"(",
"state",
",",
"conn",
")",
";",
"readResponseHeaders",
"(",
"state",
",",
"conn",
")",
";",
"processResponseHeaders",
"(",
"state",
",",
"conn",
")",
";",
"int",
"status",
"=",
"this",
".",
"statusLine",
".",
"getStatusCode",
"(",
")",
";",
"if",
"(",
"(",
"status",
">=",
"100",
")",
"&&",
"(",
"status",
"<",
"200",
")",
")",
"{",
"if",
"(",
"LOG",
".",
"isInfoEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Discarding unexpected response: \"",
"+",
"this",
".",
"statusLine",
".",
"toString",
"(",
")",
")",
";",
"}",
"this",
".",
"statusLine",
"=",
"null",
";",
"}",
"}",
"readResponseBody",
"(",
"state",
",",
"conn",
")",
";",
"processResponseBody",
"(",
"state",
",",
"conn",
")",
";",
"}"
] | Reads the response from the given {@link HttpConnection connection}.
<p>
The response is processed as the following sequence of actions:
<ol>
<li>
{@link #readStatusLine(HttpState,HttpConnection)} is
invoked to read the request line.
</li>
<li>
{@link #processStatusLine(HttpState,HttpConnection)}
is invoked, allowing the method to process the status line if
desired.
</li>
<li>
{@link #readResponseHeaders(HttpState,HttpConnection)} is invoked to read
the associated headers.
</li>
<li>
{@link #processResponseHeaders(HttpState,HttpConnection)} is invoked, allowing
the method to process the headers if desired.
</li>
<li>
{@link #readResponseBody(HttpState,HttpConnection)} is
invoked to read the associated body (if any).
</li>
<li>
{@link #processResponseBody(HttpState,HttpConnection)} is invoked, allowing the
method to process the response body if desired.
</li>
</ol>
Subclasses may want to override one or more of the above methods to to
customize the processing. (Or they may choose to override this method
if dramatically different processing is required.)
@param state the {@link HttpState state} information associated with this method
@param conn the {@link HttpConnection connection} used to execute
this HTTP method
@throws IOException if an I/O (transport) error occurs. Some transport exceptions
can be recovered from.
@throws HttpException if a protocol exception occurs. Usually protocol exceptions
cannot be recovered from. | [
"Reads",
"the",
"response",
"from",
"the",
"given",
"{",
"@link",
"HttpConnection",
"connection",
"}",
"."
] | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/apache/commons/httpclient/HttpMethodBase.java#L1862-L1884 |
mabe02/lanterna | src/main/java/com/googlecode/lanterna/screen/ScreenBuffer.java | ScreenBuffer.copyFrom | public void copyFrom(TextImage source, int startRowIndex, int rows, int startColumnIndex, int columns, int destinationRowOffset, int destinationColumnOffset) {
"""
Copies the content from a TextImage into this buffer.
@param source Source to copy content from
@param startRowIndex Which row in the source image to start copying from
@param rows How many rows to copy
@param startColumnIndex Which column in the source image to start copying from
@param columns How many columns to copy
@param destinationRowOffset The row offset in this buffer of where to place the copied content
@param destinationColumnOffset The column offset in this buffer of where to place the copied content
"""
source.copyTo(backend, startRowIndex, rows, startColumnIndex, columns, destinationRowOffset, destinationColumnOffset);
} | java | public void copyFrom(TextImage source, int startRowIndex, int rows, int startColumnIndex, int columns, int destinationRowOffset, int destinationColumnOffset) {
source.copyTo(backend, startRowIndex, rows, startColumnIndex, columns, destinationRowOffset, destinationColumnOffset);
} | [
"public",
"void",
"copyFrom",
"(",
"TextImage",
"source",
",",
"int",
"startRowIndex",
",",
"int",
"rows",
",",
"int",
"startColumnIndex",
",",
"int",
"columns",
",",
"int",
"destinationRowOffset",
",",
"int",
"destinationColumnOffset",
")",
"{",
"source",
".",
"copyTo",
"(",
"backend",
",",
"startRowIndex",
",",
"rows",
",",
"startColumnIndex",
",",
"columns",
",",
"destinationRowOffset",
",",
"destinationColumnOffset",
")",
";",
"}"
] | Copies the content from a TextImage into this buffer.
@param source Source to copy content from
@param startRowIndex Which row in the source image to start copying from
@param rows How many rows to copy
@param startColumnIndex Which column in the source image to start copying from
@param columns How many columns to copy
@param destinationRowOffset The row offset in this buffer of where to place the copied content
@param destinationColumnOffset The column offset in this buffer of where to place the copied content | [
"Copies",
"the",
"content",
"from",
"a",
"TextImage",
"into",
"this",
"buffer",
"."
] | train | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/screen/ScreenBuffer.java#L139-L141 |
kuali/kc-s2sgen | coeus-s2sgen-impl/src/main/java/org/kuali/coeus/s2sgen/impl/location/S2SLocationServiceImpl.java | S2SLocationServiceImpl.getStateFromName | @Override
public StateContract getStateFromName(String countryAlternateCode, String stateName) {
"""
This method is to get a State object from the state name
@param stateName Name of the state
@return State object matching the name.
"""
CountryContract country = getCountryFromCode(countryAlternateCode);
return getKcStateService().getState(country.getCode(), stateName);
} | java | @Override
public StateContract getStateFromName(String countryAlternateCode, String stateName) {
CountryContract country = getCountryFromCode(countryAlternateCode);
return getKcStateService().getState(country.getCode(), stateName);
} | [
"@",
"Override",
"public",
"StateContract",
"getStateFromName",
"(",
"String",
"countryAlternateCode",
",",
"String",
"stateName",
")",
"{",
"CountryContract",
"country",
"=",
"getCountryFromCode",
"(",
"countryAlternateCode",
")",
";",
"return",
"getKcStateService",
"(",
")",
".",
"getState",
"(",
"country",
".",
"getCode",
"(",
")",
",",
"stateName",
")",
";",
"}"
] | This method is to get a State object from the state name
@param stateName Name of the state
@return State object matching the name. | [
"This",
"method",
"is",
"to",
"get",
"a",
"State",
"object",
"from",
"the",
"state",
"name"
] | train | https://github.com/kuali/kc-s2sgen/blob/2886380e1e3cb8bdd732ba99b2afa6ffc630bb37/coeus-s2sgen-impl/src/main/java/org/kuali/coeus/s2sgen/impl/location/S2SLocationServiceImpl.java#L65-L70 |
intive-FDV/DynamicJasper | src/main/java/ar/com/fdvs/dj/domain/builders/DynamicReportBuilder.java | DynamicReportBuilder.setTemplateFile | public DynamicReportBuilder setTemplateFile(String path, boolean importFields, boolean importVariables, boolean importParameters, boolean importDatasets) {
"""
The full path of a jrxml file, or the path in the classpath of a jrxml
resource.
@param path
@return
"""
report.setTemplateFileName(path);
report.setTemplateImportFields(importFields);
report.setTemplateImportParameters(importParameters);
report.setTemplateImportVariables(importVariables);
report.setTemplateImportDatasets(importDatasets);
return this;
} | java | public DynamicReportBuilder setTemplateFile(String path, boolean importFields, boolean importVariables, boolean importParameters, boolean importDatasets) {
report.setTemplateFileName(path);
report.setTemplateImportFields(importFields);
report.setTemplateImportParameters(importParameters);
report.setTemplateImportVariables(importVariables);
report.setTemplateImportDatasets(importDatasets);
return this;
} | [
"public",
"DynamicReportBuilder",
"setTemplateFile",
"(",
"String",
"path",
",",
"boolean",
"importFields",
",",
"boolean",
"importVariables",
",",
"boolean",
"importParameters",
",",
"boolean",
"importDatasets",
")",
"{",
"report",
".",
"setTemplateFileName",
"(",
"path",
")",
";",
"report",
".",
"setTemplateImportFields",
"(",
"importFields",
")",
";",
"report",
".",
"setTemplateImportParameters",
"(",
"importParameters",
")",
";",
"report",
".",
"setTemplateImportVariables",
"(",
"importVariables",
")",
";",
"report",
".",
"setTemplateImportDatasets",
"(",
"importDatasets",
")",
";",
"return",
"this",
";",
"}"
] | The full path of a jrxml file, or the path in the classpath of a jrxml
resource.
@param path
@return | [
"The",
"full",
"path",
"of",
"a",
"jrxml",
"file",
"or",
"the",
"path",
"in",
"the",
"classpath",
"of",
"a",
"jrxml",
"resource",
"."
] | train | https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/domain/builders/DynamicReportBuilder.java#L1003-L1010 |
Azure/azure-sdk-for-java | containerregistry/resource-manager/v2018_02_01_preview/src/main/java/com/microsoft/azure/management/containerregistry/v2018_02_01_preview/implementation/BuildTasksInner.java | BuildTasksInner.beginUpdateAsync | public Observable<BuildTaskInner> beginUpdateAsync(String resourceGroupName, String registryName, String buildTaskName, BuildTaskUpdateParameters buildTaskUpdateParameters) {
"""
Updates a build task with the specified parameters.
@param resourceGroupName The name of the resource group to which the container registry belongs.
@param registryName The name of the container registry.
@param buildTaskName The name of the container registry build task.
@param buildTaskUpdateParameters The parameters for updating a build task.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the BuildTaskInner object
"""
return beginUpdateWithServiceResponseAsync(resourceGroupName, registryName, buildTaskName, buildTaskUpdateParameters).map(new Func1<ServiceResponse<BuildTaskInner>, BuildTaskInner>() {
@Override
public BuildTaskInner call(ServiceResponse<BuildTaskInner> response) {
return response.body();
}
});
} | java | public Observable<BuildTaskInner> beginUpdateAsync(String resourceGroupName, String registryName, String buildTaskName, BuildTaskUpdateParameters buildTaskUpdateParameters) {
return beginUpdateWithServiceResponseAsync(resourceGroupName, registryName, buildTaskName, buildTaskUpdateParameters).map(new Func1<ServiceResponse<BuildTaskInner>, BuildTaskInner>() {
@Override
public BuildTaskInner call(ServiceResponse<BuildTaskInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"BuildTaskInner",
">",
"beginUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"registryName",
",",
"String",
"buildTaskName",
",",
"BuildTaskUpdateParameters",
"buildTaskUpdateParameters",
")",
"{",
"return",
"beginUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"registryName",
",",
"buildTaskName",
",",
"buildTaskUpdateParameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"BuildTaskInner",
">",
",",
"BuildTaskInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"BuildTaskInner",
"call",
"(",
"ServiceResponse",
"<",
"BuildTaskInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Updates a build task with the specified parameters.
@param resourceGroupName The name of the resource group to which the container registry belongs.
@param registryName The name of the container registry.
@param buildTaskName The name of the container registry build task.
@param buildTaskUpdateParameters The parameters for updating a build task.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the BuildTaskInner object | [
"Updates",
"a",
"build",
"task",
"with",
"the",
"specified",
"parameters",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/containerregistry/resource-manager/v2018_02_01_preview/src/main/java/com/microsoft/azure/management/containerregistry/v2018_02_01_preview/implementation/BuildTasksInner.java#L917-L924 |
SonarSource/sonarqube | server/sonar-process/src/main/java/org/sonar/process/logging/Log4JPropertiesBuilder.java | Log4JPropertiesBuilder.configureGlobalFileLog | public void configureGlobalFileLog(RootLoggerConfig config, File logDir, String logPattern) {
"""
Make log4j2 configuration for a process to push all its logs to a log file.
<p>
<ul>
<li>the file's name will use the prefix defined in {@link RootLoggerConfig#getProcessId()#getLogFilenamePrefix()}.</li>
<li>the file will follow the rotation policy defined in property {@link #ROLLING_POLICY_PROPERTY} and
the max number of files defined in property {@link #MAX_FILES_PROPERTY}</li>
<li>the logs will follow the specified log pattern</li>
</ul>
</p>
@see #buildLogPattern(RootLoggerConfig)
"""
String appenderRef = writeFileAppender(config, logDir, logPattern);
putProperty(ROOT_LOGGER_NAME + ".appenderRef." + appenderRef + ".ref", appenderRef);
} | java | public void configureGlobalFileLog(RootLoggerConfig config, File logDir, String logPattern) {
String appenderRef = writeFileAppender(config, logDir, logPattern);
putProperty(ROOT_LOGGER_NAME + ".appenderRef." + appenderRef + ".ref", appenderRef);
} | [
"public",
"void",
"configureGlobalFileLog",
"(",
"RootLoggerConfig",
"config",
",",
"File",
"logDir",
",",
"String",
"logPattern",
")",
"{",
"String",
"appenderRef",
"=",
"writeFileAppender",
"(",
"config",
",",
"logDir",
",",
"logPattern",
")",
";",
"putProperty",
"(",
"ROOT_LOGGER_NAME",
"+",
"\".appenderRef.\"",
"+",
"appenderRef",
"+",
"\".ref\"",
",",
"appenderRef",
")",
";",
"}"
] | Make log4j2 configuration for a process to push all its logs to a log file.
<p>
<ul>
<li>the file's name will use the prefix defined in {@link RootLoggerConfig#getProcessId()#getLogFilenamePrefix()}.</li>
<li>the file will follow the rotation policy defined in property {@link #ROLLING_POLICY_PROPERTY} and
the max number of files defined in property {@link #MAX_FILES_PROPERTY}</li>
<li>the logs will follow the specified log pattern</li>
</ul>
</p>
@see #buildLogPattern(RootLoggerConfig) | [
"Make",
"log4j2",
"configuration",
"for",
"a",
"process",
"to",
"push",
"all",
"its",
"logs",
"to",
"a",
"log",
"file",
".",
"<p",
">",
"<ul",
">",
"<li",
">",
"the",
"file",
"s",
"name",
"will",
"use",
"the",
"prefix",
"defined",
"in",
"{",
"@link",
"RootLoggerConfig#getProcessId",
"()",
"#getLogFilenamePrefix",
"()",
"}",
".",
"<",
"/",
"li",
">",
"<li",
">",
"the",
"file",
"will",
"follow",
"the",
"rotation",
"policy",
"defined",
"in",
"property",
"{",
"@link",
"#ROLLING_POLICY_PROPERTY",
"}",
"and",
"the",
"max",
"number",
"of",
"files",
"defined",
"in",
"property",
"{",
"@link",
"#MAX_FILES_PROPERTY",
"}",
"<",
"/",
"li",
">",
"<li",
">",
"the",
"logs",
"will",
"follow",
"the",
"specified",
"log",
"pattern<",
"/",
"li",
">",
"<",
"/",
"ul",
">",
"<",
"/",
"p",
">"
] | train | https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-process/src/main/java/org/sonar/process/logging/Log4JPropertiesBuilder.java#L81-L85 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/db/filter/StartSearchFilter.java | StartSearchFilter.doRemoteCriteria | public boolean doRemoteCriteria(StringBuffer strbFilter, boolean bIncludeFileName, Vector<BaseField> vParamList) {
"""
/*
Set up/do the remote criteria.
@param strbFilter The SQL query string to add to.
@param bIncludeFileName Include the file name with this query?
@param vParamList The param list to add the raw data to (for prepared statements).
@return True if you should not skip this record (does a check on the local data).
"""
BaseField fldToCompare = m_fldToCompare; // Cache this in case it is changed
KeyArea keyArea = this.getOwner().getKeyArea();
m_fldToCheck = keyArea.getField(DBConstants.MAIN_KEY_FIELD);
String strSeekSignSave = m_strSeekSign;
if (m_strSeekSign == DBConstants.BLANK)
{
m_strSeekSign = GREATER_THAN_EQUAL;
if (keyArea.getKeyOrder(DBConstants.MAIN_KEY_FIELD) == DBConstants.DESCENDING)
m_strSeekSign = LESS_THAN_EQUAL;
}
// Now, we have to convert the field to a CDate for the compare to use
if (m_fldToCheck instanceof DateField)
this.fakeTheDate(); // Convert the string field to a date for compare
boolean bDontSkip = super.doRemoteCriteria(strbFilter, bIncludeFileName, vParamList); // Dont skip this record
m_fldToCheck = null;
m_fldToCompare = fldToCompare; // Set this value back
m_strSeekSign = strSeekSignSave; // Restore this.
return bDontSkip;
} | java | public boolean doRemoteCriteria(StringBuffer strbFilter, boolean bIncludeFileName, Vector<BaseField> vParamList)
{
BaseField fldToCompare = m_fldToCompare; // Cache this in case it is changed
KeyArea keyArea = this.getOwner().getKeyArea();
m_fldToCheck = keyArea.getField(DBConstants.MAIN_KEY_FIELD);
String strSeekSignSave = m_strSeekSign;
if (m_strSeekSign == DBConstants.BLANK)
{
m_strSeekSign = GREATER_THAN_EQUAL;
if (keyArea.getKeyOrder(DBConstants.MAIN_KEY_FIELD) == DBConstants.DESCENDING)
m_strSeekSign = LESS_THAN_EQUAL;
}
// Now, we have to convert the field to a CDate for the compare to use
if (m_fldToCheck instanceof DateField)
this.fakeTheDate(); // Convert the string field to a date for compare
boolean bDontSkip = super.doRemoteCriteria(strbFilter, bIncludeFileName, vParamList); // Dont skip this record
m_fldToCheck = null;
m_fldToCompare = fldToCompare; // Set this value back
m_strSeekSign = strSeekSignSave; // Restore this.
return bDontSkip;
} | [
"public",
"boolean",
"doRemoteCriteria",
"(",
"StringBuffer",
"strbFilter",
",",
"boolean",
"bIncludeFileName",
",",
"Vector",
"<",
"BaseField",
">",
"vParamList",
")",
"{",
"BaseField",
"fldToCompare",
"=",
"m_fldToCompare",
";",
"// Cache this in case it is changed",
"KeyArea",
"keyArea",
"=",
"this",
".",
"getOwner",
"(",
")",
".",
"getKeyArea",
"(",
")",
";",
"m_fldToCheck",
"=",
"keyArea",
".",
"getField",
"(",
"DBConstants",
".",
"MAIN_KEY_FIELD",
")",
";",
"String",
"strSeekSignSave",
"=",
"m_strSeekSign",
";",
"if",
"(",
"m_strSeekSign",
"==",
"DBConstants",
".",
"BLANK",
")",
"{",
"m_strSeekSign",
"=",
"GREATER_THAN_EQUAL",
";",
"if",
"(",
"keyArea",
".",
"getKeyOrder",
"(",
"DBConstants",
".",
"MAIN_KEY_FIELD",
")",
"==",
"DBConstants",
".",
"DESCENDING",
")",
"m_strSeekSign",
"=",
"LESS_THAN_EQUAL",
";",
"}",
"// Now, we have to convert the field to a CDate for the compare to use",
"if",
"(",
"m_fldToCheck",
"instanceof",
"DateField",
")",
"this",
".",
"fakeTheDate",
"(",
")",
";",
"// Convert the string field to a date for compare",
"boolean",
"bDontSkip",
"=",
"super",
".",
"doRemoteCriteria",
"(",
"strbFilter",
",",
"bIncludeFileName",
",",
"vParamList",
")",
";",
"// Dont skip this record",
"m_fldToCheck",
"=",
"null",
";",
"m_fldToCompare",
"=",
"fldToCompare",
";",
"// Set this value back",
"m_strSeekSign",
"=",
"strSeekSignSave",
";",
"// Restore this.",
"return",
"bDontSkip",
";",
"}"
] | /*
Set up/do the remote criteria.
@param strbFilter The SQL query string to add to.
@param bIncludeFileName Include the file name with this query?
@param vParamList The param list to add the raw data to (for prepared statements).
@return True if you should not skip this record (does a check on the local data). | [
"/",
"*",
"Set",
"up",
"/",
"do",
"the",
"remote",
"criteria",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/filter/StartSearchFilter.java#L100-L121 |
pgjdbc/pgjdbc | pgjdbc/src/main/java/org/postgresql/jdbc/EscapedFunctions2.java | EscapedFunctions2.sqlhour | public static void sqlhour(StringBuilder buf, List<? extends CharSequence> parsedArgs) throws SQLException {
"""
hour translation
@param buf The buffer to append into
@param parsedArgs arguments
@throws SQLException if something wrong happens
"""
singleArgumentFunctionCall(buf, "extract(hour from ", "hour", parsedArgs);
} | java | public static void sqlhour(StringBuilder buf, List<? extends CharSequence> parsedArgs) throws SQLException {
singleArgumentFunctionCall(buf, "extract(hour from ", "hour", parsedArgs);
} | [
"public",
"static",
"void",
"sqlhour",
"(",
"StringBuilder",
"buf",
",",
"List",
"<",
"?",
"extends",
"CharSequence",
">",
"parsedArgs",
")",
"throws",
"SQLException",
"{",
"singleArgumentFunctionCall",
"(",
"buf",
",",
"\"extract(hour from \"",
",",
"\"hour\"",
",",
"parsedArgs",
")",
";",
"}"
] | hour translation
@param buf The buffer to append into
@param parsedArgs arguments
@throws SQLException if something wrong happens | [
"hour",
"translation"
] | train | https://github.com/pgjdbc/pgjdbc/blob/95ba7b261e39754674c5817695ae5ebf9a341fae/pgjdbc/src/main/java/org/postgresql/jdbc/EscapedFunctions2.java#L405-L407 |
twitter/cloudhopper-commons | ch-sxmp/src/main/java/com/cloudhopper/sxmp/OptionalParamMap.java | OptionalParamMap.getLong | public Long getLong(String key, Long defaultValue) {
"""
/*
getLong will successfully return for both Long values and Integer values
it will convert the Integer to a Long
"""
Object o = get(key);
if (o != null) {
if (o instanceof Long) {
return (Long) o;
} else if (o instanceof Integer) {
return new Long((Integer)o);
}
}
return defaultValue;
} | java | public Long getLong(String key, Long defaultValue) {
Object o = get(key);
if (o != null) {
if (o instanceof Long) {
return (Long) o;
} else if (o instanceof Integer) {
return new Long((Integer)o);
}
}
return defaultValue;
} | [
"public",
"Long",
"getLong",
"(",
"String",
"key",
",",
"Long",
"defaultValue",
")",
"{",
"Object",
"o",
"=",
"get",
"(",
"key",
")",
";",
"if",
"(",
"o",
"!=",
"null",
")",
"{",
"if",
"(",
"o",
"instanceof",
"Long",
")",
"{",
"return",
"(",
"Long",
")",
"o",
";",
"}",
"else",
"if",
"(",
"o",
"instanceof",
"Integer",
")",
"{",
"return",
"new",
"Long",
"(",
"(",
"Integer",
")",
"o",
")",
";",
"}",
"}",
"return",
"defaultValue",
";",
"}"
] | /*
getLong will successfully return for both Long values and Integer values
it will convert the Integer to a Long | [
"/",
"*",
"getLong",
"will",
"successfully",
"return",
"for",
"both",
"Long",
"values",
"and",
"Integer",
"values",
"it",
"will",
"convert",
"the",
"Integer",
"to",
"a",
"Long"
] | train | https://github.com/twitter/cloudhopper-commons/blob/b5bc397dbec4537e8149e7ec0733c1d7ed477499/ch-sxmp/src/main/java/com/cloudhopper/sxmp/OptionalParamMap.java#L110-L120 |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/fdt/PostProcessor.java | PostProcessor.getGroupList | public List<Group> getGroupList(final int[] priKeyIndices, final int numStdDev,
final int limit) {
"""
Return the most frequent Groups associated with Primary Keys based on the size of the groups.
@param priKeyIndices the indices of the primary dimensions
@param numStdDev the number of standard deviations for the error bounds, this value is an
integer and must be one of 1, 2, or 3.
<a href="{@docRoot}/resources/dictionary.html#numStdDev">See Number of Standard Deviations</a>
@param limit the maximum number of rows to return. If ≤ 0, all rows will be returned.
@return the most frequent Groups associated with Primary Keys based on the size of the groups.
"""
//allows subsequent queries with different priKeyIndices without rebuilding the map
if (!mapValid) { populateMap(priKeyIndices); }
return populateList(numStdDev, limit);
} | java | public List<Group> getGroupList(final int[] priKeyIndices, final int numStdDev,
final int limit) {
//allows subsequent queries with different priKeyIndices without rebuilding the map
if (!mapValid) { populateMap(priKeyIndices); }
return populateList(numStdDev, limit);
} | [
"public",
"List",
"<",
"Group",
">",
"getGroupList",
"(",
"final",
"int",
"[",
"]",
"priKeyIndices",
",",
"final",
"int",
"numStdDev",
",",
"final",
"int",
"limit",
")",
"{",
"//allows subsequent queries with different priKeyIndices without rebuilding the map",
"if",
"(",
"!",
"mapValid",
")",
"{",
"populateMap",
"(",
"priKeyIndices",
")",
";",
"}",
"return",
"populateList",
"(",
"numStdDev",
",",
"limit",
")",
";",
"}"
] | Return the most frequent Groups associated with Primary Keys based on the size of the groups.
@param priKeyIndices the indices of the primary dimensions
@param numStdDev the number of standard deviations for the error bounds, this value is an
integer and must be one of 1, 2, or 3.
<a href="{@docRoot}/resources/dictionary.html#numStdDev">See Number of Standard Deviations</a>
@param limit the maximum number of rows to return. If ≤ 0, all rows will be returned.
@return the most frequent Groups associated with Primary Keys based on the size of the groups. | [
"Return",
"the",
"most",
"frequent",
"Groups",
"associated",
"with",
"Primary",
"Keys",
"based",
"on",
"the",
"size",
"of",
"the",
"groups",
"."
] | train | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/fdt/PostProcessor.java#L73-L78 |
alipay/sofa-rpc | core/api/src/main/java/com/alipay/sofa/rpc/filter/FilterInvoker.java | FilterInvoker.getBooleanMethodParam | protected boolean getBooleanMethodParam(String methodName, String paramKey, boolean defaultValue) {
"""
取得方法的特殊参数配置
@param methodName 方法名
@param paramKey 参数关键字
@param defaultValue 默认值
@return 都找不到为false boolean method param
"""
if (CommonUtils.isEmpty(configContext)) {
return defaultValue;
}
Boolean o = (Boolean) configContext.get(buildMethodKey(methodName, paramKey));
if (o == null) {
o = (Boolean) configContext.get(paramKey);
return o == null ? defaultValue : o;
} else {
return o;
}
} | java | protected boolean getBooleanMethodParam(String methodName, String paramKey, boolean defaultValue) {
if (CommonUtils.isEmpty(configContext)) {
return defaultValue;
}
Boolean o = (Boolean) configContext.get(buildMethodKey(methodName, paramKey));
if (o == null) {
o = (Boolean) configContext.get(paramKey);
return o == null ? defaultValue : o;
} else {
return o;
}
} | [
"protected",
"boolean",
"getBooleanMethodParam",
"(",
"String",
"methodName",
",",
"String",
"paramKey",
",",
"boolean",
"defaultValue",
")",
"{",
"if",
"(",
"CommonUtils",
".",
"isEmpty",
"(",
"configContext",
")",
")",
"{",
"return",
"defaultValue",
";",
"}",
"Boolean",
"o",
"=",
"(",
"Boolean",
")",
"configContext",
".",
"get",
"(",
"buildMethodKey",
"(",
"methodName",
",",
"paramKey",
")",
")",
";",
"if",
"(",
"o",
"==",
"null",
")",
"{",
"o",
"=",
"(",
"Boolean",
")",
"configContext",
".",
"get",
"(",
"paramKey",
")",
";",
"return",
"o",
"==",
"null",
"?",
"defaultValue",
":",
"o",
";",
"}",
"else",
"{",
"return",
"o",
";",
"}",
"}"
] | 取得方法的特殊参数配置
@param methodName 方法名
@param paramKey 参数关键字
@param defaultValue 默认值
@return 都找不到为false boolean method param | [
"取得方法的特殊参数配置"
] | train | https://github.com/alipay/sofa-rpc/blob/a31406410291e56696185a29c3ba4bd1f54488fd/core/api/src/main/java/com/alipay/sofa/rpc/filter/FilterInvoker.java#L140-L151 |
svenkubiak/mangooio | mangooio-core/src/main/java/io/mangoo/routing/handlers/RequestHandler.java | RequestHandler.getResponse | protected Response getResponse(HttpServerExchange exchange) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, MangooTemplateEngineException, IOException {
"""
Execute filters if exists in the following order:
RequestFilter, ControllerFilter, MethodFilter
@param exchange The Undertow HttpServerExchange
@return A Response object that will be merged to the final response
@throws NoSuchMethodException
@throws IllegalAccessException
@throws InvocationTargetException
@throws TemplateException
@throws IOException
@throws MangooTemplateEngineException
"""
//execute global request filter
Response response = Response.withOk();
if (this.attachment.hasRequestFilter()) {
final MangooRequestFilter mangooRequestFilter = Application.getInstance(MangooRequestFilter.class);
response = mangooRequestFilter.execute(this.attachment.getRequest(), response);
}
if (response.isEndResponse()) {
return response;
}
//execute controller filters
response = executeFilter(this.attachment.getClassAnnotations(), response);
if (response.isEndResponse()) {
return response;
}
//execute method filters
response = executeFilter(this.attachment.getMethodAnnotations(), response);
if (response.isEndResponse()) {
return response;
}
return invokeController(exchange, response);
} | java | protected Response getResponse(HttpServerExchange exchange) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, MangooTemplateEngineException, IOException {
//execute global request filter
Response response = Response.withOk();
if (this.attachment.hasRequestFilter()) {
final MangooRequestFilter mangooRequestFilter = Application.getInstance(MangooRequestFilter.class);
response = mangooRequestFilter.execute(this.attachment.getRequest(), response);
}
if (response.isEndResponse()) {
return response;
}
//execute controller filters
response = executeFilter(this.attachment.getClassAnnotations(), response);
if (response.isEndResponse()) {
return response;
}
//execute method filters
response = executeFilter(this.attachment.getMethodAnnotations(), response);
if (response.isEndResponse()) {
return response;
}
return invokeController(exchange, response);
} | [
"protected",
"Response",
"getResponse",
"(",
"HttpServerExchange",
"exchange",
")",
"throws",
"NoSuchMethodException",
",",
"IllegalAccessException",
",",
"InvocationTargetException",
",",
"MangooTemplateEngineException",
",",
"IOException",
"{",
"//execute global request filter",
"Response",
"response",
"=",
"Response",
".",
"withOk",
"(",
")",
";",
"if",
"(",
"this",
".",
"attachment",
".",
"hasRequestFilter",
"(",
")",
")",
"{",
"final",
"MangooRequestFilter",
"mangooRequestFilter",
"=",
"Application",
".",
"getInstance",
"(",
"MangooRequestFilter",
".",
"class",
")",
";",
"response",
"=",
"mangooRequestFilter",
".",
"execute",
"(",
"this",
".",
"attachment",
".",
"getRequest",
"(",
")",
",",
"response",
")",
";",
"}",
"if",
"(",
"response",
".",
"isEndResponse",
"(",
")",
")",
"{",
"return",
"response",
";",
"}",
"//execute controller filters",
"response",
"=",
"executeFilter",
"(",
"this",
".",
"attachment",
".",
"getClassAnnotations",
"(",
")",
",",
"response",
")",
";",
"if",
"(",
"response",
".",
"isEndResponse",
"(",
")",
")",
"{",
"return",
"response",
";",
"}",
"//execute method filters",
"response",
"=",
"executeFilter",
"(",
"this",
".",
"attachment",
".",
"getMethodAnnotations",
"(",
")",
",",
"response",
")",
";",
"if",
"(",
"response",
".",
"isEndResponse",
"(",
")",
")",
"{",
"return",
"response",
";",
"}",
"return",
"invokeController",
"(",
"exchange",
",",
"response",
")",
";",
"}"
] | Execute filters if exists in the following order:
RequestFilter, ControllerFilter, MethodFilter
@param exchange The Undertow HttpServerExchange
@return A Response object that will be merged to the final response
@throws NoSuchMethodException
@throws IllegalAccessException
@throws InvocationTargetException
@throws TemplateException
@throws IOException
@throws MangooTemplateEngineException | [
"Execute",
"filters",
"if",
"exists",
"in",
"the",
"following",
"order",
":",
"RequestFilter",
"ControllerFilter",
"MethodFilter"
] | train | https://github.com/svenkubiak/mangooio/blob/b3beb6d09510dbbab0ed947d5069c463e1fda6e7/mangooio-core/src/main/java/io/mangoo/routing/handlers/RequestHandler.java#L95-L120 |
OpenVidu/openvidu | openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/MediaEndpoint.java | MediaEndpoint.addIceCandidate | public synchronized void addIceCandidate(IceCandidate candidate) throws OpenViduException {
"""
Add a new {@link IceCandidate} received gathered by the remote peer of this
{@link WebRtcEndpoint}.
@param candidate the remote candidate
"""
if (!this.isWeb()) {
throw new OpenViduException(Code.MEDIA_NOT_A_WEB_ENDPOINT_ERROR_CODE, "Operation not supported");
}
if (webEndpoint == null) {
candidates.addLast(candidate);
} else {
internalAddIceCandidate(candidate);
}
} | java | public synchronized void addIceCandidate(IceCandidate candidate) throws OpenViduException {
if (!this.isWeb()) {
throw new OpenViduException(Code.MEDIA_NOT_A_WEB_ENDPOINT_ERROR_CODE, "Operation not supported");
}
if (webEndpoint == null) {
candidates.addLast(candidate);
} else {
internalAddIceCandidate(candidate);
}
} | [
"public",
"synchronized",
"void",
"addIceCandidate",
"(",
"IceCandidate",
"candidate",
")",
"throws",
"OpenViduException",
"{",
"if",
"(",
"!",
"this",
".",
"isWeb",
"(",
")",
")",
"{",
"throw",
"new",
"OpenViduException",
"(",
"Code",
".",
"MEDIA_NOT_A_WEB_ENDPOINT_ERROR_CODE",
",",
"\"Operation not supported\"",
")",
";",
"}",
"if",
"(",
"webEndpoint",
"==",
"null",
")",
"{",
"candidates",
".",
"addLast",
"(",
"candidate",
")",
";",
"}",
"else",
"{",
"internalAddIceCandidate",
"(",
"candidate",
")",
";",
"}",
"}"
] | Add a new {@link IceCandidate} received gathered by the remote peer of this
{@link WebRtcEndpoint}.
@param candidate the remote candidate | [
"Add",
"a",
"new",
"{",
"@link",
"IceCandidate",
"}",
"received",
"gathered",
"by",
"the",
"remote",
"peer",
"of",
"this",
"{",
"@link",
"WebRtcEndpoint",
"}",
"."
] | train | https://github.com/OpenVidu/openvidu/blob/89db47dd37949ceab29e5228371a8fcab04d8d55/openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/MediaEndpoint.java#L300-L309 |
hazelcast/hazelcast | hazelcast/src/main/java/com/hazelcast/config/Config.java | Config.setSemaphoreConfigs | public Config setSemaphoreConfigs(Map<String, SemaphoreConfig> semaphoreConfigs) {
"""
Sets the map of semaphore configurations, mapped by config name.
The config name may be a pattern with which the configuration will be
obtained in the future.
@param semaphoreConfigs the semaphore configuration map to set
@return this config instance
"""
this.semaphoreConfigs.clear();
this.semaphoreConfigs.putAll(semaphoreConfigs);
for (final Entry<String, SemaphoreConfig> entry : this.semaphoreConfigs.entrySet()) {
entry.getValue().setName(entry.getKey());
}
return this;
} | java | public Config setSemaphoreConfigs(Map<String, SemaphoreConfig> semaphoreConfigs) {
this.semaphoreConfigs.clear();
this.semaphoreConfigs.putAll(semaphoreConfigs);
for (final Entry<String, SemaphoreConfig> entry : this.semaphoreConfigs.entrySet()) {
entry.getValue().setName(entry.getKey());
}
return this;
} | [
"public",
"Config",
"setSemaphoreConfigs",
"(",
"Map",
"<",
"String",
",",
"SemaphoreConfig",
">",
"semaphoreConfigs",
")",
"{",
"this",
".",
"semaphoreConfigs",
".",
"clear",
"(",
")",
";",
"this",
".",
"semaphoreConfigs",
".",
"putAll",
"(",
"semaphoreConfigs",
")",
";",
"for",
"(",
"final",
"Entry",
"<",
"String",
",",
"SemaphoreConfig",
">",
"entry",
":",
"this",
".",
"semaphoreConfigs",
".",
"entrySet",
"(",
")",
")",
"{",
"entry",
".",
"getValue",
"(",
")",
".",
"setName",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Sets the map of semaphore configurations, mapped by config name.
The config name may be a pattern with which the configuration will be
obtained in the future.
@param semaphoreConfigs the semaphore configuration map to set
@return this config instance | [
"Sets",
"the",
"map",
"of",
"semaphore",
"configurations",
"mapped",
"by",
"config",
"name",
".",
"The",
"config",
"name",
"may",
"be",
"a",
"pattern",
"with",
"which",
"the",
"configuration",
"will",
"be",
"obtained",
"in",
"the",
"future",
"."
] | train | https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/config/Config.java#L2376-L2383 |
OpenBEL/openbel-framework | org.openbel.framework.common/src/main/java/org/openbel/framework/common/protonetwork/model/ProtoEdgeTable.java | ProtoEdgeTable.addEdges | public void addEdges(final Integer stmt, final TableProtoEdge... newEdges) {
"""
Adds 1 or more {@link TableProtoEdge proto edges} to the table and
associates them with the supporting {@link TableStatement statement}
index.
<p>
There must be at least one {@link TableProtoEdge proto edge} to
associate to a statement otherwise an exception is thrown.
</p>
@param stmt the {@link TableStatement statement} index to associate the
{@link TableProtoEdge proto edges} to, which cannot be null
@param newEdges the {@link TableProtoEdge proto edges} array to add to
the table, which cannot be null or have a length less than 1
@throws InvalidArgument May be thrown if <tt>stmt</tt> is <tt>null</tt>,
<tt>newEdges</tt> is null, or <tt>newEdges</tt> is <tt> <= 0</tt>
"""
if (stmt == null) {
throw new InvalidArgument("stmt", stmt);
}
if (newEdges == null || newEdges.length <= 0) {
throw new InvalidArgument("newEdges", newEdges);
}
Set<Integer> edges = stmtEdges.get(stmt);
if (edges == null) {
edges = new HashSet<Integer>();
stmtEdges.put(stmt, edges);
}
for (final TableProtoEdge newEdge : newEdges) {
int idx = protoEdges.size();
protoEdges.add(newEdge);
Integer existingEdge = visited.get(newEdge);
if (existingEdge != null) {
getEquivalences().put(idx, existingEdge);
} else {
visited.put(newEdge, idx);
getEquivalences().put(idx, getEquivalences().size());
}
edges.add(idx);
Set<Integer> stmts = new LinkedHashSet<Integer>();
stmts.add(stmt);
edgeStmts.put(idx, stmts);
}
} | java | public void addEdges(final Integer stmt, final TableProtoEdge... newEdges) {
if (stmt == null) {
throw new InvalidArgument("stmt", stmt);
}
if (newEdges == null || newEdges.length <= 0) {
throw new InvalidArgument("newEdges", newEdges);
}
Set<Integer> edges = stmtEdges.get(stmt);
if (edges == null) {
edges = new HashSet<Integer>();
stmtEdges.put(stmt, edges);
}
for (final TableProtoEdge newEdge : newEdges) {
int idx = protoEdges.size();
protoEdges.add(newEdge);
Integer existingEdge = visited.get(newEdge);
if (existingEdge != null) {
getEquivalences().put(idx, existingEdge);
} else {
visited.put(newEdge, idx);
getEquivalences().put(idx, getEquivalences().size());
}
edges.add(idx);
Set<Integer> stmts = new LinkedHashSet<Integer>();
stmts.add(stmt);
edgeStmts.put(idx, stmts);
}
} | [
"public",
"void",
"addEdges",
"(",
"final",
"Integer",
"stmt",
",",
"final",
"TableProtoEdge",
"...",
"newEdges",
")",
"{",
"if",
"(",
"stmt",
"==",
"null",
")",
"{",
"throw",
"new",
"InvalidArgument",
"(",
"\"stmt\"",
",",
"stmt",
")",
";",
"}",
"if",
"(",
"newEdges",
"==",
"null",
"||",
"newEdges",
".",
"length",
"<=",
"0",
")",
"{",
"throw",
"new",
"InvalidArgument",
"(",
"\"newEdges\"",
",",
"newEdges",
")",
";",
"}",
"Set",
"<",
"Integer",
">",
"edges",
"=",
"stmtEdges",
".",
"get",
"(",
"stmt",
")",
";",
"if",
"(",
"edges",
"==",
"null",
")",
"{",
"edges",
"=",
"new",
"HashSet",
"<",
"Integer",
">",
"(",
")",
";",
"stmtEdges",
".",
"put",
"(",
"stmt",
",",
"edges",
")",
";",
"}",
"for",
"(",
"final",
"TableProtoEdge",
"newEdge",
":",
"newEdges",
")",
"{",
"int",
"idx",
"=",
"protoEdges",
".",
"size",
"(",
")",
";",
"protoEdges",
".",
"add",
"(",
"newEdge",
")",
";",
"Integer",
"existingEdge",
"=",
"visited",
".",
"get",
"(",
"newEdge",
")",
";",
"if",
"(",
"existingEdge",
"!=",
"null",
")",
"{",
"getEquivalences",
"(",
")",
".",
"put",
"(",
"idx",
",",
"existingEdge",
")",
";",
"}",
"else",
"{",
"visited",
".",
"put",
"(",
"newEdge",
",",
"idx",
")",
";",
"getEquivalences",
"(",
")",
".",
"put",
"(",
"idx",
",",
"getEquivalences",
"(",
")",
".",
"size",
"(",
")",
")",
";",
"}",
"edges",
".",
"add",
"(",
"idx",
")",
";",
"Set",
"<",
"Integer",
">",
"stmts",
"=",
"new",
"LinkedHashSet",
"<",
"Integer",
">",
"(",
")",
";",
"stmts",
".",
"add",
"(",
"stmt",
")",
";",
"edgeStmts",
".",
"put",
"(",
"idx",
",",
"stmts",
")",
";",
"}",
"}"
] | Adds 1 or more {@link TableProtoEdge proto edges} to the table and
associates them with the supporting {@link TableStatement statement}
index.
<p>
There must be at least one {@link TableProtoEdge proto edge} to
associate to a statement otherwise an exception is thrown.
</p>
@param stmt the {@link TableStatement statement} index to associate the
{@link TableProtoEdge proto edges} to, which cannot be null
@param newEdges the {@link TableProtoEdge proto edges} array to add to
the table, which cannot be null or have a length less than 1
@throws InvalidArgument May be thrown if <tt>stmt</tt> is <tt>null</tt>,
<tt>newEdges</tt> is null, or <tt>newEdges</tt> is <tt> <= 0</tt> | [
"Adds",
"1",
"or",
"more",
"{",
"@link",
"TableProtoEdge",
"proto",
"edges",
"}",
"to",
"the",
"table",
"and",
"associates",
"them",
"with",
"the",
"supporting",
"{",
"@link",
"TableStatement",
"statement",
"}",
"index",
".",
"<p",
">",
"There",
"must",
"be",
"at",
"least",
"one",
"{",
"@link",
"TableProtoEdge",
"proto",
"edge",
"}",
"to",
"associate",
"to",
"a",
"statement",
"otherwise",
"an",
"exception",
"is",
"thrown",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.common/src/main/java/org/openbel/framework/common/protonetwork/model/ProtoEdgeTable.java#L127-L159 |
apache/incubator-druid | extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/ApproximateHistogram.java | ApproximateHistogram.fromBytesSparse | public static ApproximateHistogram fromBytesSparse(ByteBuffer buf) {
"""
Constructs an ApproximateHistogram object from the given dense byte-buffer representation
@param buf ByteBuffer to construct an ApproximateHistogram from
@return ApproximateHistogram constructed from the given ByteBuffer
"""
int size = buf.getInt();
int binCount = -1 * buf.getInt();
float[] positions = new float[size];
long[] bins = new long[size];
for (int i = 0; i < binCount; ++i) {
positions[i] = buf.getFloat();
}
for (int i = 0; i < binCount; ++i) {
bins[i] = buf.getLong();
}
float min = buf.getFloat();
float max = buf.getFloat();
return new ApproximateHistogram(binCount, positions, bins, min, max);
} | java | public static ApproximateHistogram fromBytesSparse(ByteBuffer buf)
{
int size = buf.getInt();
int binCount = -1 * buf.getInt();
float[] positions = new float[size];
long[] bins = new long[size];
for (int i = 0; i < binCount; ++i) {
positions[i] = buf.getFloat();
}
for (int i = 0; i < binCount; ++i) {
bins[i] = buf.getLong();
}
float min = buf.getFloat();
float max = buf.getFloat();
return new ApproximateHistogram(binCount, positions, bins, min, max);
} | [
"public",
"static",
"ApproximateHistogram",
"fromBytesSparse",
"(",
"ByteBuffer",
"buf",
")",
"{",
"int",
"size",
"=",
"buf",
".",
"getInt",
"(",
")",
";",
"int",
"binCount",
"=",
"-",
"1",
"*",
"buf",
".",
"getInt",
"(",
")",
";",
"float",
"[",
"]",
"positions",
"=",
"new",
"float",
"[",
"size",
"]",
";",
"long",
"[",
"]",
"bins",
"=",
"new",
"long",
"[",
"size",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"binCount",
";",
"++",
"i",
")",
"{",
"positions",
"[",
"i",
"]",
"=",
"buf",
".",
"getFloat",
"(",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"binCount",
";",
"++",
"i",
")",
"{",
"bins",
"[",
"i",
"]",
"=",
"buf",
".",
"getLong",
"(",
")",
";",
"}",
"float",
"min",
"=",
"buf",
".",
"getFloat",
"(",
")",
";",
"float",
"max",
"=",
"buf",
".",
"getFloat",
"(",
")",
";",
"return",
"new",
"ApproximateHistogram",
"(",
"binCount",
",",
"positions",
",",
"bins",
",",
"min",
",",
"max",
")",
";",
"}"
] | Constructs an ApproximateHistogram object from the given dense byte-buffer representation
@param buf ByteBuffer to construct an ApproximateHistogram from
@return ApproximateHistogram constructed from the given ByteBuffer | [
"Constructs",
"an",
"ApproximateHistogram",
"object",
"from",
"the",
"given",
"dense",
"byte",
"-",
"buffer",
"representation"
] | train | https://github.com/apache/incubator-druid/blob/f776b9408962b9006cfcfe4d6c1794751972cc8e/extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/ApproximateHistogram.java#L1336-L1355 |
google/closure-compiler | src/com/google/javascript/jscomp/RewriteAsyncIteration.java | RewriteAsyncIteration.convertYieldOfAsyncGenerator | private void convertYieldOfAsyncGenerator(NodeTraversal t, LexicalContext ctx, Node yieldNode) {
"""
Converts a yield into a yield of an ActionRecord to perform "YIELD" or "YIELD_STAR".
<pre>{@code
yield;
yield first;
yield* second;
}</pre>
<p>becomes
<pre>{@code
yield new ActionRecord(ActionEnum.YIELD_VALUE, undefined);
yield new ActionRecord(ActionEnum.YIELD_VALUE, first);
yield new ActionRecord(ActionEnum.YIELD_STAR, second);
}</pre>
@param yieldNode the Node to be converted
"""
checkNotNull(yieldNode);
checkState(yieldNode.isYield());
checkState(ctx != null && ctx.function != null);
checkState(ctx.function.isAsyncGeneratorFunction());
Node expression = yieldNode.removeFirstChild();
Node newActionRecord =
astFactory.createNewNode(astFactory.createQName(t.getScope(), ACTION_RECORD_NAME));
if (yieldNode.isYieldAll()) {
checkNotNull(expression);
// yield* expression becomes new ActionRecord(YIELD_STAR, expression)
newActionRecord.addChildToBack(astFactory.createQName(t.getScope(), ACTION_ENUM_YIELD_STAR));
newActionRecord.addChildToBack(expression);
} else {
if (expression == null) {
expression = NodeUtil.newUndefinedNode(null);
}
// yield expression becomes new ActionRecord(YIELD, expression)
newActionRecord.addChildToBack(astFactory.createQName(t.getScope(), ACTION_ENUM_YIELD));
newActionRecord.addChildToBack(expression);
}
newActionRecord.useSourceInfoIfMissingFromForTree(yieldNode);
yieldNode.addChildToFront(newActionRecord);
yieldNode.removeProp(Node.YIELD_ALL);
} | java | private void convertYieldOfAsyncGenerator(NodeTraversal t, LexicalContext ctx, Node yieldNode) {
checkNotNull(yieldNode);
checkState(yieldNode.isYield());
checkState(ctx != null && ctx.function != null);
checkState(ctx.function.isAsyncGeneratorFunction());
Node expression = yieldNode.removeFirstChild();
Node newActionRecord =
astFactory.createNewNode(astFactory.createQName(t.getScope(), ACTION_RECORD_NAME));
if (yieldNode.isYieldAll()) {
checkNotNull(expression);
// yield* expression becomes new ActionRecord(YIELD_STAR, expression)
newActionRecord.addChildToBack(astFactory.createQName(t.getScope(), ACTION_ENUM_YIELD_STAR));
newActionRecord.addChildToBack(expression);
} else {
if (expression == null) {
expression = NodeUtil.newUndefinedNode(null);
}
// yield expression becomes new ActionRecord(YIELD, expression)
newActionRecord.addChildToBack(astFactory.createQName(t.getScope(), ACTION_ENUM_YIELD));
newActionRecord.addChildToBack(expression);
}
newActionRecord.useSourceInfoIfMissingFromForTree(yieldNode);
yieldNode.addChildToFront(newActionRecord);
yieldNode.removeProp(Node.YIELD_ALL);
} | [
"private",
"void",
"convertYieldOfAsyncGenerator",
"(",
"NodeTraversal",
"t",
",",
"LexicalContext",
"ctx",
",",
"Node",
"yieldNode",
")",
"{",
"checkNotNull",
"(",
"yieldNode",
")",
";",
"checkState",
"(",
"yieldNode",
".",
"isYield",
"(",
")",
")",
";",
"checkState",
"(",
"ctx",
"!=",
"null",
"&&",
"ctx",
".",
"function",
"!=",
"null",
")",
";",
"checkState",
"(",
"ctx",
".",
"function",
".",
"isAsyncGeneratorFunction",
"(",
")",
")",
";",
"Node",
"expression",
"=",
"yieldNode",
".",
"removeFirstChild",
"(",
")",
";",
"Node",
"newActionRecord",
"=",
"astFactory",
".",
"createNewNode",
"(",
"astFactory",
".",
"createQName",
"(",
"t",
".",
"getScope",
"(",
")",
",",
"ACTION_RECORD_NAME",
")",
")",
";",
"if",
"(",
"yieldNode",
".",
"isYieldAll",
"(",
")",
")",
"{",
"checkNotNull",
"(",
"expression",
")",
";",
"// yield* expression becomes new ActionRecord(YIELD_STAR, expression)",
"newActionRecord",
".",
"addChildToBack",
"(",
"astFactory",
".",
"createQName",
"(",
"t",
".",
"getScope",
"(",
")",
",",
"ACTION_ENUM_YIELD_STAR",
")",
")",
";",
"newActionRecord",
".",
"addChildToBack",
"(",
"expression",
")",
";",
"}",
"else",
"{",
"if",
"(",
"expression",
"==",
"null",
")",
"{",
"expression",
"=",
"NodeUtil",
".",
"newUndefinedNode",
"(",
"null",
")",
";",
"}",
"// yield expression becomes new ActionRecord(YIELD, expression)",
"newActionRecord",
".",
"addChildToBack",
"(",
"astFactory",
".",
"createQName",
"(",
"t",
".",
"getScope",
"(",
")",
",",
"ACTION_ENUM_YIELD",
")",
")",
";",
"newActionRecord",
".",
"addChildToBack",
"(",
"expression",
")",
";",
"}",
"newActionRecord",
".",
"useSourceInfoIfMissingFromForTree",
"(",
"yieldNode",
")",
";",
"yieldNode",
".",
"addChildToFront",
"(",
"newActionRecord",
")",
";",
"yieldNode",
".",
"removeProp",
"(",
"Node",
".",
"YIELD_ALL",
")",
";",
"}"
] | Converts a yield into a yield of an ActionRecord to perform "YIELD" or "YIELD_STAR".
<pre>{@code
yield;
yield first;
yield* second;
}</pre>
<p>becomes
<pre>{@code
yield new ActionRecord(ActionEnum.YIELD_VALUE, undefined);
yield new ActionRecord(ActionEnum.YIELD_VALUE, first);
yield new ActionRecord(ActionEnum.YIELD_STAR, second);
}</pre>
@param yieldNode the Node to be converted | [
"Converts",
"a",
"yield",
"into",
"a",
"yield",
"of",
"an",
"ActionRecord",
"to",
"perform",
"YIELD",
"or",
"YIELD_STAR",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/RewriteAsyncIteration.java#L448-L475 |
mercadopago/dx-java | src/main/java/com/mercadopago/core/MPApiResponse.java | MPApiResponse.parseRequest | private void parseRequest(HttpMethod httpMethod, HttpRequestBase request, JsonObject payload) throws MPException {
"""
Parses the http request in a custom MPApiResponse object.
@param httpMethod enum with the method executed
@param request HttpRequestBase object
@param payload JsonObject with the payload
@throws MPException
"""
this.method = httpMethod.toString();
this.url = request.getURI().toString();
if (payload != null) {
this.payload = payload.toString();
}
} | java | private void parseRequest(HttpMethod httpMethod, HttpRequestBase request, JsonObject payload) throws MPException {
this.method = httpMethod.toString();
this.url = request.getURI().toString();
if (payload != null) {
this.payload = payload.toString();
}
} | [
"private",
"void",
"parseRequest",
"(",
"HttpMethod",
"httpMethod",
",",
"HttpRequestBase",
"request",
",",
"JsonObject",
"payload",
")",
"throws",
"MPException",
"{",
"this",
".",
"method",
"=",
"httpMethod",
".",
"toString",
"(",
")",
";",
"this",
".",
"url",
"=",
"request",
".",
"getURI",
"(",
")",
".",
"toString",
"(",
")",
";",
"if",
"(",
"payload",
"!=",
"null",
")",
"{",
"this",
".",
"payload",
"=",
"payload",
".",
"toString",
"(",
")",
";",
"}",
"}"
] | Parses the http request in a custom MPApiResponse object.
@param httpMethod enum with the method executed
@param request HttpRequestBase object
@param payload JsonObject with the payload
@throws MPException | [
"Parses",
"the",
"http",
"request",
"in",
"a",
"custom",
"MPApiResponse",
"object",
"."
] | train | https://github.com/mercadopago/dx-java/blob/9df65a6bfb4db0c1fddd7699a5b109643961b03f/src/main/java/com/mercadopago/core/MPApiResponse.java#L90-L96 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.