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
|
---|---|---|---|---|---|---|---|---|---|---|
uber/rides-java-sdk | uber-core-oauth-client-adapter/src/main/java/com/uber/sdk/core/auth/OAuth2Credentials.java | OAuth2Credentials.clearCredential | public void clearCredential(String userId) throws AuthException {
"""
Clears the credential for the user in the underlying (@link DateStore}.
@throws AuthException If the credential could not be cleared.
"""
try {
authorizationCodeFlow.getCredentialDataStore().delete(userId);
} catch (IOException e) {
throw new AuthException("Unable to clear credential.", e);
}
} | java | public void clearCredential(String userId) throws AuthException {
try {
authorizationCodeFlow.getCredentialDataStore().delete(userId);
} catch (IOException e) {
throw new AuthException("Unable to clear credential.", e);
}
} | [
"public",
"void",
"clearCredential",
"(",
"String",
"userId",
")",
"throws",
"AuthException",
"{",
"try",
"{",
"authorizationCodeFlow",
".",
"getCredentialDataStore",
"(",
")",
".",
"delete",
"(",
"userId",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"AuthException",
"(",
"\"Unable to clear credential.\"",
",",
"e",
")",
";",
"}",
"}"
] | Clears the credential for the user in the underlying (@link DateStore}.
@throws AuthException If the credential could not be cleared. | [
"Clears",
"the",
"credential",
"for",
"the",
"user",
"in",
"the",
"underlying",
"("
] | train | https://github.com/uber/rides-java-sdk/blob/6c75570ab7884f8ecafaad312ef471dd33f64c42/uber-core-oauth-client-adapter/src/main/java/com/uber/sdk/core/auth/OAuth2Credentials.java#L287-L293 |
gallandarakhneorg/afc | core/text/src/main/java/org/arakhne/afc/text/TextUtil.java | TextUtil.mergeBrackets | @Pure
@Inline(value = "TextUtil.join(' {
"""
Merge the given strings with to brackets.
The brackets are used to delimit the groups
of characters.
<p>Examples:
<ul>
<li><code>mergeBrackets("a","b","cd")</code> returns the string
<code>"{a}{b}{cd}"</code></li>
<li><code>mergeBrackets("a{bcd")</code> returns the string
<code>"{a{bcd}"</code></li>
</ul>
@param <T> is the type of the parameters.
@param strs is the array of strings.
@return the string with bracketed strings.
"""', '}', $1)", imported = {TextUtil.class})
public static <T> String mergeBrackets(@SuppressWarnings("unchecked") T... strs) {
return join('{', '}', strs);
} | java | @Pure
@Inline(value = "TextUtil.join('{', '}', $1)", imported = {TextUtil.class})
public static <T> String mergeBrackets(@SuppressWarnings("unchecked") T... strs) {
return join('{', '}', strs);
} | [
"@",
"Pure",
"@",
"Inline",
"(",
"value",
"=",
"\"TextUtil.join('{', '}', $1)\"",
",",
"imported",
"=",
"{",
"TextUtil",
".",
"class",
"}",
")",
"public",
"static",
"<",
"T",
">",
"String",
"mergeBrackets",
"(",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"T",
"...",
"strs",
")",
"{",
"return",
"join",
"(",
"'",
"'",
",",
"'",
"'",
",",
"strs",
")",
";",
"}"
] | Merge the given strings with to brackets.
The brackets are used to delimit the groups
of characters.
<p>Examples:
<ul>
<li><code>mergeBrackets("a","b","cd")</code> returns the string
<code>"{a}{b}{cd}"</code></li>
<li><code>mergeBrackets("a{bcd")</code> returns the string
<code>"{a{bcd}"</code></li>
</ul>
@param <T> is the type of the parameters.
@param strs is the array of strings.
@return the string with bracketed strings. | [
"Merge",
"the",
"given",
"strings",
"with",
"to",
"brackets",
".",
"The",
"brackets",
"are",
"used",
"to",
"delimit",
"the",
"groups",
"of",
"characters",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/text/src/main/java/org/arakhne/afc/text/TextUtil.java#L842-L846 |
devnied/EMV-NFC-Paycard-Enrollment | library/src/main/java/com/github/devnied/emvnfccard/parser/impl/AbstractParser.java | AbstractParser.getTransactionCounter | protected int getTransactionCounter() throws CommunicationException {
"""
Method used to get Transaction counter
@return the number of card transaction
@throws CommunicationException communication error
"""
int ret = UNKNOW;
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Get Transaction Counter ATC");
}
byte[] data = template.get().getProvider().transceive(new CommandApdu(CommandEnum.GET_DATA, 0x9F, 0x36, 0).toBytes());
if (ResponseUtils.isSucceed(data)) {
// Extract ATC
byte[] val = TlvUtil.getValue(data, EmvTags.APP_TRANSACTION_COUNTER);
if (val != null) {
ret = BytesUtils.byteArrayToInt(val);
}
}
return ret;
} | java | protected int getTransactionCounter() throws CommunicationException {
int ret = UNKNOW;
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Get Transaction Counter ATC");
}
byte[] data = template.get().getProvider().transceive(new CommandApdu(CommandEnum.GET_DATA, 0x9F, 0x36, 0).toBytes());
if (ResponseUtils.isSucceed(data)) {
// Extract ATC
byte[] val = TlvUtil.getValue(data, EmvTags.APP_TRANSACTION_COUNTER);
if (val != null) {
ret = BytesUtils.byteArrayToInt(val);
}
}
return ret;
} | [
"protected",
"int",
"getTransactionCounter",
"(",
")",
"throws",
"CommunicationException",
"{",
"int",
"ret",
"=",
"UNKNOW",
";",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Get Transaction Counter ATC\"",
")",
";",
"}",
"byte",
"[",
"]",
"data",
"=",
"template",
".",
"get",
"(",
")",
".",
"getProvider",
"(",
")",
".",
"transceive",
"(",
"new",
"CommandApdu",
"(",
"CommandEnum",
".",
"GET_DATA",
",",
"0x9F",
",",
"0x36",
",",
"0",
")",
".",
"toBytes",
"(",
")",
")",
";",
"if",
"(",
"ResponseUtils",
".",
"isSucceed",
"(",
"data",
")",
")",
"{",
"// Extract ATC",
"byte",
"[",
"]",
"val",
"=",
"TlvUtil",
".",
"getValue",
"(",
"data",
",",
"EmvTags",
".",
"APP_TRANSACTION_COUNTER",
")",
";",
"if",
"(",
"val",
"!=",
"null",
")",
"{",
"ret",
"=",
"BytesUtils",
".",
"byteArrayToInt",
"(",
"val",
")",
";",
"}",
"}",
"return",
"ret",
";",
"}"
] | Method used to get Transaction counter
@return the number of card transaction
@throws CommunicationException communication error | [
"Method",
"used",
"to",
"get",
"Transaction",
"counter"
] | train | https://github.com/devnied/EMV-NFC-Paycard-Enrollment/blob/bfbd3960708689154a7a75c8a9a934197d738a5b/library/src/main/java/com/github/devnied/emvnfccard/parser/impl/AbstractParser.java#L169-L183 |
SonarSource/sonarqube | sonar-core/src/main/java/org/sonar/core/util/UuidFactoryFast.java | UuidFactoryFast.putLong | private static void putLong(byte[] array, long l, int pos, int numberOfLongBytes) {
"""
Puts the lower numberOfLongBytes from l into the array, starting index pos.
"""
for (int i = 0; i < numberOfLongBytes; ++i) {
array[pos + numberOfLongBytes - i - 1] = (byte) (l >>> (i * 8));
}
} | java | private static void putLong(byte[] array, long l, int pos, int numberOfLongBytes) {
for (int i = 0; i < numberOfLongBytes; ++i) {
array[pos + numberOfLongBytes - i - 1] = (byte) (l >>> (i * 8));
}
} | [
"private",
"static",
"void",
"putLong",
"(",
"byte",
"[",
"]",
"array",
",",
"long",
"l",
",",
"int",
"pos",
",",
"int",
"numberOfLongBytes",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"numberOfLongBytes",
";",
"++",
"i",
")",
"{",
"array",
"[",
"pos",
"+",
"numberOfLongBytes",
"-",
"i",
"-",
"1",
"]",
"=",
"(",
"byte",
")",
"(",
"l",
">>>",
"(",
"i",
"*",
"8",
")",
")",
";",
"}",
"}"
] | Puts the lower numberOfLongBytes from l into the array, starting index pos. | [
"Puts",
"the",
"lower",
"numberOfLongBytes",
"from",
"l",
"into",
"the",
"array",
"starting",
"index",
"pos",
"."
] | train | https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-core/src/main/java/org/sonar/core/util/UuidFactoryFast.java#L62-L66 |
Azure/azure-sdk-for-java | hdinsight/resource-manager/v2018_06_01_preview/src/main/java/com/microsoft/azure/management/hdinsight/v2018_06_01_preview/implementation/ConfigurationsInner.java | ConfigurationsInner.list | public ClusterConfigurationsInner list(String resourceGroupName, String clusterName) {
"""
Gets all configuration information for an HDI cluster.
@param resourceGroupName The name of the resource group.
@param clusterName The name of the cluster.
@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 ClusterConfigurationsInner object if successful.
"""
return listWithServiceResponseAsync(resourceGroupName, clusterName).toBlocking().single().body();
} | java | public ClusterConfigurationsInner list(String resourceGroupName, String clusterName) {
return listWithServiceResponseAsync(resourceGroupName, clusterName).toBlocking().single().body();
} | [
"public",
"ClusterConfigurationsInner",
"list",
"(",
"String",
"resourceGroupName",
",",
"String",
"clusterName",
")",
"{",
"return",
"listWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"clusterName",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Gets all configuration information for an HDI cluster.
@param resourceGroupName The name of the resource group.
@param clusterName The name of the cluster.
@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 ClusterConfigurationsInner object if successful. | [
"Gets",
"all",
"configuration",
"information",
"for",
"an",
"HDI",
"cluster",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/hdinsight/resource-manager/v2018_06_01_preview/src/main/java/com/microsoft/azure/management/hdinsight/v2018_06_01_preview/implementation/ConfigurationsInner.java#L86-L88 |
lmdbjava/lmdbjava | src/main/java/org/lmdbjava/ByteArrayProxy.java | ByteArrayProxy.compareArrays | @SuppressWarnings("checkstyle:ReturnCount")
public static int compareArrays(final byte[] o1, final byte[] o2) {
"""
Lexicographically compare two byte arrays.
@param o1 left operand (required)
@param o2 right operand (required)
@return as specified by {@link Comparable} interface
"""
requireNonNull(o1);
requireNonNull(o2);
if (o1 == o2) {
return 0;
}
final int minLength = Math.min(o1.length, o2.length);
for (int i = 0; i < minLength; i++) {
final int lw = Byte.toUnsignedInt(o1[i]);
final int rw = Byte.toUnsignedInt(o2[i]);
final int result = Integer.compareUnsigned(lw, rw);
if (result != 0) {
return result;
}
}
return o1.length - o2.length;
} | java | @SuppressWarnings("checkstyle:ReturnCount")
public static int compareArrays(final byte[] o1, final byte[] o2) {
requireNonNull(o1);
requireNonNull(o2);
if (o1 == o2) {
return 0;
}
final int minLength = Math.min(o1.length, o2.length);
for (int i = 0; i < minLength; i++) {
final int lw = Byte.toUnsignedInt(o1[i]);
final int rw = Byte.toUnsignedInt(o2[i]);
final int result = Integer.compareUnsigned(lw, rw);
if (result != 0) {
return result;
}
}
return o1.length - o2.length;
} | [
"@",
"SuppressWarnings",
"(",
"\"checkstyle:ReturnCount\"",
")",
"public",
"static",
"int",
"compareArrays",
"(",
"final",
"byte",
"[",
"]",
"o1",
",",
"final",
"byte",
"[",
"]",
"o2",
")",
"{",
"requireNonNull",
"(",
"o1",
")",
";",
"requireNonNull",
"(",
"o2",
")",
";",
"if",
"(",
"o1",
"==",
"o2",
")",
"{",
"return",
"0",
";",
"}",
"final",
"int",
"minLength",
"=",
"Math",
".",
"min",
"(",
"o1",
".",
"length",
",",
"o2",
".",
"length",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"minLength",
";",
"i",
"++",
")",
"{",
"final",
"int",
"lw",
"=",
"Byte",
".",
"toUnsignedInt",
"(",
"o1",
"[",
"i",
"]",
")",
";",
"final",
"int",
"rw",
"=",
"Byte",
".",
"toUnsignedInt",
"(",
"o2",
"[",
"i",
"]",
")",
";",
"final",
"int",
"result",
"=",
"Integer",
".",
"compareUnsigned",
"(",
"lw",
",",
"rw",
")",
";",
"if",
"(",
"result",
"!=",
"0",
")",
"{",
"return",
"result",
";",
"}",
"}",
"return",
"o1",
".",
"length",
"-",
"o2",
".",
"length",
";",
"}"
] | Lexicographically compare two byte arrays.
@param o1 left operand (required)
@param o2 right operand (required)
@return as specified by {@link Comparable} interface | [
"Lexicographically",
"compare",
"two",
"byte",
"arrays",
"."
] | train | https://github.com/lmdbjava/lmdbjava/blob/5912beb1037722c71f3ddc05e70fcbe739dfa272/src/main/java/org/lmdbjava/ByteArrayProxy.java#L50-L69 |
amaembo/streamex | src/main/java/one/util/streamex/MoreCollectors.java | MoreCollectors.onlyOne | public static <T> Collector<T, ?, Optional<T>> onlyOne(Predicate<? super T> predicate) {
"""
Returns a {@code Collector} which collects the stream element satisfying the predicate
if there is only one such element.
<p>
This method returns a
<a href="package-summary.html#ShortCircuitReduction">short-circuiting
collector</a>.
@param predicate a predicate to be applied to the stream elements
@param <T> the type of the input elements
@return a collector which returns an {@link Optional} describing the only
element of the stream satisfying the predicate. If stream contains no elements satisfying the predicate,
or more than one such element, an empty {@code Optional} is returned.
@since 0.6.7
"""
return filtering(predicate, onlyOne());
} | java | public static <T> Collector<T, ?, Optional<T>> onlyOne(Predicate<? super T> predicate) {
return filtering(predicate, onlyOne());
} | [
"public",
"static",
"<",
"T",
">",
"Collector",
"<",
"T",
",",
"?",
",",
"Optional",
"<",
"T",
">",
">",
"onlyOne",
"(",
"Predicate",
"<",
"?",
"super",
"T",
">",
"predicate",
")",
"{",
"return",
"filtering",
"(",
"predicate",
",",
"onlyOne",
"(",
")",
")",
";",
"}"
] | Returns a {@code Collector} which collects the stream element satisfying the predicate
if there is only one such element.
<p>
This method returns a
<a href="package-summary.html#ShortCircuitReduction">short-circuiting
collector</a>.
@param predicate a predicate to be applied to the stream elements
@param <T> the type of the input elements
@return a collector which returns an {@link Optional} describing the only
element of the stream satisfying the predicate. If stream contains no elements satisfying the predicate,
or more than one such element, an empty {@code Optional} is returned.
@since 0.6.7 | [
"Returns",
"a",
"{",
"@code",
"Collector",
"}",
"which",
"collects",
"the",
"stream",
"element",
"satisfying",
"the",
"predicate",
"if",
"there",
"is",
"only",
"one",
"such",
"element",
"."
] | train | https://github.com/amaembo/streamex/blob/936bbd1b7dfbcf64a3b990682bfc848213441d14/src/main/java/one/util/streamex/MoreCollectors.java#L531-L533 |
OpenLiberty/open-liberty | dev/com.ibm.ws.security/src/com/ibm/ws/security/internal/SecurityServiceImpl.java | SecurityServiceImpl.getEffectiveSecurityConfiguration | private SecurityConfiguration getEffectiveSecurityConfiguration() {
"""
Eventually this will be execution context aware and pick the right domain.
Till then, we're only accessing the system domain configuration.
@return SecurityConfiguration representing the "effective" configuration
for the execution context.
"""
SecurityConfiguration effectiveConfig = configs.getService(cfgSystemDomain);
if (effectiveConfig == null) {
Tr.error(tc, "SECURITY_SERVICE_ERROR_BAD_DOMAIN", cfgSystemDomain, CFG_KEY_SYSTEM_DOMAIN);
throw new IllegalArgumentException(Tr.formatMessage(tc, "SECURITY_SERVICE_ERROR_BAD_DOMAIN", cfgSystemDomain, CFG_KEY_SYSTEM_DOMAIN));
}
return effectiveConfig;
} | java | private SecurityConfiguration getEffectiveSecurityConfiguration() {
SecurityConfiguration effectiveConfig = configs.getService(cfgSystemDomain);
if (effectiveConfig == null) {
Tr.error(tc, "SECURITY_SERVICE_ERROR_BAD_DOMAIN", cfgSystemDomain, CFG_KEY_SYSTEM_DOMAIN);
throw new IllegalArgumentException(Tr.formatMessage(tc, "SECURITY_SERVICE_ERROR_BAD_DOMAIN", cfgSystemDomain, CFG_KEY_SYSTEM_DOMAIN));
}
return effectiveConfig;
} | [
"private",
"SecurityConfiguration",
"getEffectiveSecurityConfiguration",
"(",
")",
"{",
"SecurityConfiguration",
"effectiveConfig",
"=",
"configs",
".",
"getService",
"(",
"cfgSystemDomain",
")",
";",
"if",
"(",
"effectiveConfig",
"==",
"null",
")",
"{",
"Tr",
".",
"error",
"(",
"tc",
",",
"\"SECURITY_SERVICE_ERROR_BAD_DOMAIN\"",
",",
"cfgSystemDomain",
",",
"CFG_KEY_SYSTEM_DOMAIN",
")",
";",
"throw",
"new",
"IllegalArgumentException",
"(",
"Tr",
".",
"formatMessage",
"(",
"tc",
",",
"\"SECURITY_SERVICE_ERROR_BAD_DOMAIN\"",
",",
"cfgSystemDomain",
",",
"CFG_KEY_SYSTEM_DOMAIN",
")",
")",
";",
"}",
"return",
"effectiveConfig",
";",
"}"
] | Eventually this will be execution context aware and pick the right domain.
Till then, we're only accessing the system domain configuration.
@return SecurityConfiguration representing the "effective" configuration
for the execution context. | [
"Eventually",
"this",
"will",
"be",
"execution",
"context",
"aware",
"and",
"pick",
"the",
"right",
"domain",
".",
"Till",
"then",
"we",
"re",
"only",
"accessing",
"the",
"system",
"domain",
"configuration",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security/src/com/ibm/ws/security/internal/SecurityServiceImpl.java#L374-L381 |
sniggle/simple-pgp | simple-pgp-api/src/main/java/me/sniggle/pgp/crypt/internal/io/IOUtils.java | IOUtils.copy | public static void copy(InputStream inputStream, OutputStream outputStream) throws IOException {
"""
copies the input stream to the output stream
@param inputStream
the source stream
@param outputStream
the target stream
@throws IOException
"""
LOGGER.trace("copy(InputStream, OutputStream)");
copy(inputStream, outputStream, new byte[BUFFER_SIZE]);
} | java | public static void copy(InputStream inputStream, OutputStream outputStream) throws IOException {
LOGGER.trace("copy(InputStream, OutputStream)");
copy(inputStream, outputStream, new byte[BUFFER_SIZE]);
} | [
"public",
"static",
"void",
"copy",
"(",
"InputStream",
"inputStream",
",",
"OutputStream",
"outputStream",
")",
"throws",
"IOException",
"{",
"LOGGER",
".",
"trace",
"(",
"\"copy(InputStream, OutputStream)\"",
")",
";",
"copy",
"(",
"inputStream",
",",
"outputStream",
",",
"new",
"byte",
"[",
"BUFFER_SIZE",
"]",
")",
";",
"}"
] | copies the input stream to the output stream
@param inputStream
the source stream
@param outputStream
the target stream
@throws IOException | [
"copies",
"the",
"input",
"stream",
"to",
"the",
"output",
"stream"
] | train | https://github.com/sniggle/simple-pgp/blob/2ab83e4d370b8189f767d8e4e4c7e6020e60fbe3/simple-pgp-api/src/main/java/me/sniggle/pgp/crypt/internal/io/IOUtils.java#L54-L57 |
googleapis/google-http-java-client | google-http-client-xml/src/main/java/com/google/api/client/xml/atom/Atom.java | Atom.setSlugHeader | public static void setSlugHeader(HttpHeaders headers, String value) {
"""
Sets the {@code "Slug"} header, properly escaping the header value. See <a
href="http://tools.ietf.org/html/rfc5023#section-9.7">The Slug Header</a>.
@since 1.14
"""
if (value == null) {
headers.remove("Slug");
} else {
headers.set("Slug", Lists.newArrayList(Arrays.asList(SLUG_ESCAPER.escape(value))));
}
} | java | public static void setSlugHeader(HttpHeaders headers, String value) {
if (value == null) {
headers.remove("Slug");
} else {
headers.set("Slug", Lists.newArrayList(Arrays.asList(SLUG_ESCAPER.escape(value))));
}
} | [
"public",
"static",
"void",
"setSlugHeader",
"(",
"HttpHeaders",
"headers",
",",
"String",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"headers",
".",
"remove",
"(",
"\"Slug\"",
")",
";",
"}",
"else",
"{",
"headers",
".",
"set",
"(",
"\"Slug\"",
",",
"Lists",
".",
"newArrayList",
"(",
"Arrays",
".",
"asList",
"(",
"SLUG_ESCAPER",
".",
"escape",
"(",
"value",
")",
")",
")",
")",
";",
"}",
"}"
] | Sets the {@code "Slug"} header, properly escaping the header value. See <a
href="http://tools.ietf.org/html/rfc5023#section-9.7">The Slug Header</a>.
@since 1.14 | [
"Sets",
"the",
"{",
"@code",
"Slug",
"}",
"header",
"properly",
"escaping",
"the",
"header",
"value",
".",
"See",
"<a",
"href",
"=",
"http",
":",
"//",
"tools",
".",
"ietf",
".",
"org",
"/",
"html",
"/",
"rfc5023#section",
"-",
"9",
".",
"7",
">",
"The",
"Slug",
"Header<",
"/",
"a",
">",
"."
] | train | https://github.com/googleapis/google-http-java-client/blob/0988ae4e0f26a80f579b6adb2b276dd8254928de/google-http-client-xml/src/main/java/com/google/api/client/xml/atom/Atom.java#L85-L91 |
netscaler/nitro | src/main/java/com/citrix/netscaler/nitro/resource/base/base_resource.java | base_resource.resource_to_string | protected String resource_to_string(nitro_service service, String id, options option) {
"""
Converts netscaler resource to Json string.
@param service nitro_service object.
@param id sessionId.
@param option Options object.
@return string in Json format.
"""
Boolean warning = service.get_warning();
String onerror = service.get_onerror();
String result = service.get_payload_formatter().resource_to_string(this, id, option, warning, onerror);
return result;
} | java | protected String resource_to_string(nitro_service service, String id, options option)
{
Boolean warning = service.get_warning();
String onerror = service.get_onerror();
String result = service.get_payload_formatter().resource_to_string(this, id, option, warning, onerror);
return result;
} | [
"protected",
"String",
"resource_to_string",
"(",
"nitro_service",
"service",
",",
"String",
"id",
",",
"options",
"option",
")",
"{",
"Boolean",
"warning",
"=",
"service",
".",
"get_warning",
"(",
")",
";",
"String",
"onerror",
"=",
"service",
".",
"get_onerror",
"(",
")",
";",
"String",
"result",
"=",
"service",
".",
"get_payload_formatter",
"(",
")",
".",
"resource_to_string",
"(",
"this",
",",
"id",
",",
"option",
",",
"warning",
",",
"onerror",
")",
";",
"return",
"result",
";",
"}"
] | Converts netscaler resource to Json string.
@param service nitro_service object.
@param id sessionId.
@param option Options object.
@return string in Json format. | [
"Converts",
"netscaler",
"resource",
"to",
"Json",
"string",
"."
] | train | https://github.com/netscaler/nitro/blob/2a98692dcf4e4ec430c7d7baab8382e4ba5a35e4/src/main/java/com/citrix/netscaler/nitro/resource/base/base_resource.java#L65-L71 |
dashorst/wicket-stuff-markup-validator | jing/src/main/java/com/thaiopensource/validate/nvdl/Mode.java | Mode.bindAttribute | boolean bindAttribute(String ns, String wildcard, AttributeActionSet actions) {
"""
Adds a set of attribute actions to be performed in this mode
for attributes in a specified namespace.
@param ns The namespace pattern.
@param wildcard The wildcard character.
@param actions The set of attribute actions.
@return true if successfully added, that is the namespace was
not already present in the attributeMap, otherwise false, the
caller should signal a script error in this case.
"""
NamespaceSpecification nss = new NamespaceSpecification(ns, wildcard);
if (nssAttributeMap.get(nss) != null)
return false;
for (Enumeration e = nssAttributeMap.keys(); e.hasMoreElements();) {
NamespaceSpecification nssI = (NamespaceSpecification)e.nextElement();
if (nss.compete(nssI)) {
return false;
}
}
nssAttributeMap.put(nss, actions);
return true;
} | java | boolean bindAttribute(String ns, String wildcard, AttributeActionSet actions) {
NamespaceSpecification nss = new NamespaceSpecification(ns, wildcard);
if (nssAttributeMap.get(nss) != null)
return false;
for (Enumeration e = nssAttributeMap.keys(); e.hasMoreElements();) {
NamespaceSpecification nssI = (NamespaceSpecification)e.nextElement();
if (nss.compete(nssI)) {
return false;
}
}
nssAttributeMap.put(nss, actions);
return true;
} | [
"boolean",
"bindAttribute",
"(",
"String",
"ns",
",",
"String",
"wildcard",
",",
"AttributeActionSet",
"actions",
")",
"{",
"NamespaceSpecification",
"nss",
"=",
"new",
"NamespaceSpecification",
"(",
"ns",
",",
"wildcard",
")",
";",
"if",
"(",
"nssAttributeMap",
".",
"get",
"(",
"nss",
")",
"!=",
"null",
")",
"return",
"false",
";",
"for",
"(",
"Enumeration",
"e",
"=",
"nssAttributeMap",
".",
"keys",
"(",
")",
";",
"e",
".",
"hasMoreElements",
"(",
")",
";",
")",
"{",
"NamespaceSpecification",
"nssI",
"=",
"(",
"NamespaceSpecification",
")",
"e",
".",
"nextElement",
"(",
")",
";",
"if",
"(",
"nss",
".",
"compete",
"(",
"nssI",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"nssAttributeMap",
".",
"put",
"(",
"nss",
",",
"actions",
")",
";",
"return",
"true",
";",
"}"
] | Adds a set of attribute actions to be performed in this mode
for attributes in a specified namespace.
@param ns The namespace pattern.
@param wildcard The wildcard character.
@param actions The set of attribute actions.
@return true if successfully added, that is the namespace was
not already present in the attributeMap, otherwise false, the
caller should signal a script error in this case. | [
"Adds",
"a",
"set",
"of",
"attribute",
"actions",
"to",
"be",
"performed",
"in",
"this",
"mode",
"for",
"attributes",
"in",
"a",
"specified",
"namespace",
"."
] | train | https://github.com/dashorst/wicket-stuff-markup-validator/blob/9e529a4dc8bfdbbe4c794f3132ef400a006560a1/jing/src/main/java/com/thaiopensource/validate/nvdl/Mode.java#L389-L401 |
betfair/cougar | cougar-framework/cougar-zipkin-common/src/main/java/com/betfair/cougar/modules/zipkin/impl/ZipkinAnnotationsStore.java | ZipkinAnnotationsStore.addAnnotation | @Nonnull
public ZipkinAnnotationsStore addAnnotation(@Nonnull String key, @Nonnull String value) {
"""
Adds a (binary) string annotation for an event.
@param key The key of the annotation
@param value The value of the annotation
@return this object
"""
return addBinaryAnnotation(key, value, defaultEndpoint);
} | java | @Nonnull
public ZipkinAnnotationsStore addAnnotation(@Nonnull String key, @Nonnull String value) {
return addBinaryAnnotation(key, value, defaultEndpoint);
} | [
"@",
"Nonnull",
"public",
"ZipkinAnnotationsStore",
"addAnnotation",
"(",
"@",
"Nonnull",
"String",
"key",
",",
"@",
"Nonnull",
"String",
"value",
")",
"{",
"return",
"addBinaryAnnotation",
"(",
"key",
",",
"value",
",",
"defaultEndpoint",
")",
";",
"}"
] | Adds a (binary) string annotation for an event.
@param key The key of the annotation
@param value The value of the annotation
@return this object | [
"Adds",
"a",
"(",
"binary",
")",
"string",
"annotation",
"for",
"an",
"event",
"."
] | train | https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/cougar-zipkin-common/src/main/java/com/betfair/cougar/modules/zipkin/impl/ZipkinAnnotationsStore.java#L82-L85 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/CharsetUtil.java | CharsetUtil.convert | public static String convert(String source, Charset srcCharset, Charset destCharset) {
"""
转换字符串的字符集编码<br>
当以错误的编码读取为字符串时,打印字符串将出现乱码。<br>
此方法用于纠正因读取使用编码错误导致的乱码问题。<br>
例如,在Servlet请求中客户端用GBK编码了请求参数,我们使用UTF-8读取到的是乱码,此时,使用此方法即可还原原编码的内容
<pre>
客户端 -》 GBK编码 -》 Servlet容器 -》 UTF-8解码 -》 乱码
乱码 -》 UTF-8编码 -》 GBK解码 -》 正确内容
</pre>
@param source 字符串
@param srcCharset 源字符集,默认ISO-8859-1
@param destCharset 目标字符集,默认UTF-8
@return 转换后的字符集
"""
if(null == srcCharset) {
srcCharset = StandardCharsets.ISO_8859_1;
}
if(null == destCharset) {
destCharset = StandardCharsets.UTF_8;
}
if (StrUtil.isBlank(source) || srcCharset.equals(destCharset)) {
return source;
}
return new String(source.getBytes(srcCharset), destCharset);
} | java | public static String convert(String source, Charset srcCharset, Charset destCharset) {
if(null == srcCharset) {
srcCharset = StandardCharsets.ISO_8859_1;
}
if(null == destCharset) {
destCharset = StandardCharsets.UTF_8;
}
if (StrUtil.isBlank(source) || srcCharset.equals(destCharset)) {
return source;
}
return new String(source.getBytes(srcCharset), destCharset);
} | [
"public",
"static",
"String",
"convert",
"(",
"String",
"source",
",",
"Charset",
"srcCharset",
",",
"Charset",
"destCharset",
")",
"{",
"if",
"(",
"null",
"==",
"srcCharset",
")",
"{",
"srcCharset",
"=",
"StandardCharsets",
".",
"ISO_8859_1",
";",
"}",
"if",
"(",
"null",
"==",
"destCharset",
")",
"{",
"destCharset",
"=",
"StandardCharsets",
".",
"UTF_8",
";",
"}",
"if",
"(",
"StrUtil",
".",
"isBlank",
"(",
"source",
")",
"||",
"srcCharset",
".",
"equals",
"(",
"destCharset",
")",
")",
"{",
"return",
"source",
";",
"}",
"return",
"new",
"String",
"(",
"source",
".",
"getBytes",
"(",
"srcCharset",
")",
",",
"destCharset",
")",
";",
"}"
] | 转换字符串的字符集编码<br>
当以错误的编码读取为字符串时,打印字符串将出现乱码。<br>
此方法用于纠正因读取使用编码错误导致的乱码问题。<br>
例如,在Servlet请求中客户端用GBK编码了请求参数,我们使用UTF-8读取到的是乱码,此时,使用此方法即可还原原编码的内容
<pre>
客户端 -》 GBK编码 -》 Servlet容器 -》 UTF-8解码 -》 乱码
乱码 -》 UTF-8编码 -》 GBK解码 -》 正确内容
</pre>
@param source 字符串
@param srcCharset 源字符集,默认ISO-8859-1
@param destCharset 目标字符集,默认UTF-8
@return 转换后的字符集 | [
"转换字符串的字符集编码<br",
">",
"当以错误的编码读取为字符串时,打印字符串将出现乱码。<br",
">",
"此方法用于纠正因读取使用编码错误导致的乱码问题。<br",
">",
"例如,在Servlet请求中客户端用GBK编码了请求参数,我们使用UTF",
"-",
"8读取到的是乱码,此时,使用此方法即可还原原编码的内容",
"<pre",
">",
"客户端",
"-",
"》",
"GBK编码",
"-",
"》",
"Servlet容器",
"-",
"》",
"UTF",
"-",
"8解码",
"-",
"》",
"乱码",
"乱码",
"-",
"》",
"UTF",
"-",
"8编码",
"-",
"》",
"GBK解码",
"-",
"》",
"正确内容",
"<",
"/",
"pre",
">"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/CharsetUtil.java#L67-L80 |
elki-project/elki | elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/DBSCAN.java | DBSCAN.processNeighbors | private void processNeighbors(DoubleDBIDListIter neighbor, ModifiableDBIDs currentCluster, ArrayModifiableDBIDs seeds) {
"""
Process a single core point.
@param neighbor Iterator over neighbors
@param currentCluster Current cluster
@param seeds Seed set
"""
final boolean ismetric = getDistanceFunction().isMetric();
for(; neighbor.valid(); neighbor.advance()) {
if(processedIDs.add(neighbor)) {
if(!ismetric || neighbor.doubleValue() > 0.) {
seeds.add(neighbor);
}
}
else if(!noise.remove(neighbor)) {
continue;
}
currentCluster.add(neighbor);
}
} | java | private void processNeighbors(DoubleDBIDListIter neighbor, ModifiableDBIDs currentCluster, ArrayModifiableDBIDs seeds) {
final boolean ismetric = getDistanceFunction().isMetric();
for(; neighbor.valid(); neighbor.advance()) {
if(processedIDs.add(neighbor)) {
if(!ismetric || neighbor.doubleValue() > 0.) {
seeds.add(neighbor);
}
}
else if(!noise.remove(neighbor)) {
continue;
}
currentCluster.add(neighbor);
}
} | [
"private",
"void",
"processNeighbors",
"(",
"DoubleDBIDListIter",
"neighbor",
",",
"ModifiableDBIDs",
"currentCluster",
",",
"ArrayModifiableDBIDs",
"seeds",
")",
"{",
"final",
"boolean",
"ismetric",
"=",
"getDistanceFunction",
"(",
")",
".",
"isMetric",
"(",
")",
";",
"for",
"(",
";",
"neighbor",
".",
"valid",
"(",
")",
";",
"neighbor",
".",
"advance",
"(",
")",
")",
"{",
"if",
"(",
"processedIDs",
".",
"add",
"(",
"neighbor",
")",
")",
"{",
"if",
"(",
"!",
"ismetric",
"||",
"neighbor",
".",
"doubleValue",
"(",
")",
">",
"0.",
")",
"{",
"seeds",
".",
"add",
"(",
"neighbor",
")",
";",
"}",
"}",
"else",
"if",
"(",
"!",
"noise",
".",
"remove",
"(",
"neighbor",
")",
")",
"{",
"continue",
";",
"}",
"currentCluster",
".",
"add",
"(",
"neighbor",
")",
";",
"}",
"}"
] | Process a single core point.
@param neighbor Iterator over neighbors
@param currentCluster Current cluster
@param seeds Seed set | [
"Process",
"a",
"single",
"core",
"point",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/DBSCAN.java#L260-L273 |
google/j2objc | jre_emul/android/platform/external/mockwebserver/src/main/java/com/google/mockwebserver/MockResponse.java | MockResponse.throttleBody | public MockResponse throttleBody(int bytesPerPeriod, long period, TimeUnit unit) {
"""
Throttles the response body writer to sleep for the given period after each
series of {@code bytesPerPeriod} bytes are written. Use this to simulate
network behavior.
"""
this.throttleBytesPerPeriod = bytesPerPeriod;
this.throttlePeriod = period;
this.throttleUnit = unit;
return this;
} | java | public MockResponse throttleBody(int bytesPerPeriod, long period, TimeUnit unit) {
this.throttleBytesPerPeriod = bytesPerPeriod;
this.throttlePeriod = period;
this.throttleUnit = unit;
return this;
} | [
"public",
"MockResponse",
"throttleBody",
"(",
"int",
"bytesPerPeriod",
",",
"long",
"period",
",",
"TimeUnit",
"unit",
")",
"{",
"this",
".",
"throttleBytesPerPeriod",
"=",
"bytesPerPeriod",
";",
"this",
".",
"throttlePeriod",
"=",
"period",
";",
"this",
".",
"throttleUnit",
"=",
"unit",
";",
"return",
"this",
";",
"}"
] | Throttles the response body writer to sleep for the given period after each
series of {@code bytesPerPeriod} bytes are written. Use this to simulate
network behavior. | [
"Throttles",
"the",
"response",
"body",
"writer",
"to",
"sleep",
"for",
"the",
"given",
"period",
"after",
"each",
"series",
"of",
"{"
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/mockwebserver/src/main/java/com/google/mockwebserver/MockResponse.java#L236-L241 |
ltsopensource/light-task-scheduler | lts-core/src/main/java/com/github/ltsopensource/core/commons/utils/WebUtils.java | WebUtils.decode | public static String decode(String value, String charset) {
"""
使用指定的字符集反编码请求参数值。
@param value 参数值
@param charset 字符集
@return 反编码后的参数值
"""
String result = null;
if (!StringUtils.isEmpty(value)) {
try {
result = URLDecoder.decode(value, charset);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return result;
} | java | public static String decode(String value, String charset) {
String result = null;
if (!StringUtils.isEmpty(value)) {
try {
result = URLDecoder.decode(value, charset);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return result;
} | [
"public",
"static",
"String",
"decode",
"(",
"String",
"value",
",",
"String",
"charset",
")",
"{",
"String",
"result",
"=",
"null",
";",
"if",
"(",
"!",
"StringUtils",
".",
"isEmpty",
"(",
"value",
")",
")",
"{",
"try",
"{",
"result",
"=",
"URLDecoder",
".",
"decode",
"(",
"value",
",",
"charset",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | 使用指定的字符集反编码请求参数值。
@param value 参数值
@param charset 字符集
@return 反编码后的参数值 | [
"使用指定的字符集反编码请求参数值。"
] | train | https://github.com/ltsopensource/light-task-scheduler/blob/64d3aa000ff5022be5e94f511b58f405e5f4c8eb/lts-core/src/main/java/com/github/ltsopensource/core/commons/utils/WebUtils.java#L313-L323 |
Azure/azure-sdk-for-java | containerservice/resource-manager/v2019_02_01/src/main/java/com/microsoft/azure/management/containerservice/v2019_02_01/implementation/OpenShiftManagedClustersInner.java | OpenShiftManagedClustersInner.beginCreateOrUpdateAsync | public Observable<OpenShiftManagedClusterInner> beginCreateOrUpdateAsync(String resourceGroupName, String resourceName, OpenShiftManagedClusterInner parameters) {
"""
Creates or updates an OpenShift managed cluster.
Creates or updates a OpenShift managed cluster with the specified configuration for agents and OpenShift version.
@param resourceGroupName The name of the resource group.
@param resourceName The name of the OpenShift managed cluster resource.
@param parameters Parameters supplied to the Create or Update an OpenShift Managed Cluster operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the OpenShiftManagedClusterInner object
"""
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, resourceName, parameters).map(new Func1<ServiceResponse<OpenShiftManagedClusterInner>, OpenShiftManagedClusterInner>() {
@Override
public OpenShiftManagedClusterInner call(ServiceResponse<OpenShiftManagedClusterInner> response) {
return response.body();
}
});
} | java | public Observable<OpenShiftManagedClusterInner> beginCreateOrUpdateAsync(String resourceGroupName, String resourceName, OpenShiftManagedClusterInner parameters) {
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, resourceName, parameters).map(new Func1<ServiceResponse<OpenShiftManagedClusterInner>, OpenShiftManagedClusterInner>() {
@Override
public OpenShiftManagedClusterInner call(ServiceResponse<OpenShiftManagedClusterInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"OpenShiftManagedClusterInner",
">",
"beginCreateOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"resourceName",
",",
"OpenShiftManagedClusterInner",
"parameters",
")",
"{",
"return",
"beginCreateOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"resourceName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"OpenShiftManagedClusterInner",
">",
",",
"OpenShiftManagedClusterInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"OpenShiftManagedClusterInner",
"call",
"(",
"ServiceResponse",
"<",
"OpenShiftManagedClusterInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Creates or updates an OpenShift managed cluster.
Creates or updates a OpenShift managed cluster with the specified configuration for agents and OpenShift version.
@param resourceGroupName The name of the resource group.
@param resourceName The name of the OpenShift managed cluster resource.
@param parameters Parameters supplied to the Create or Update an OpenShift Managed Cluster operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the OpenShiftManagedClusterInner object | [
"Creates",
"or",
"updates",
"an",
"OpenShift",
"managed",
"cluster",
".",
"Creates",
"or",
"updates",
"a",
"OpenShift",
"managed",
"cluster",
"with",
"the",
"specified",
"configuration",
"for",
"agents",
"and",
"OpenShift",
"version",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/containerservice/resource-manager/v2019_02_01/src/main/java/com/microsoft/azure/management/containerservice/v2019_02_01/implementation/OpenShiftManagedClustersInner.java#L552-L559 |
UrielCh/ovh-java-sdk | ovh-java-sdk-cloud/src/main/java/net/minidev/ovh/api/ApiOvhCloud.java | ApiOvhCloud.serviceName_pca_pcaServiceName_serviceInfos_PUT | public void serviceName_pca_pcaServiceName_serviceInfos_PUT(String serviceName, String pcaServiceName, OvhService body) throws IOException {
"""
Alter this object properties
REST: PUT /cloud/{serviceName}/pca/{pcaServiceName}/serviceInfos
@param body [required] New object properties
@param serviceName [required] The internal name of your public cloud passport
@param pcaServiceName [required] The internal name of your PCA offer
@deprecated
"""
String qPath = "/cloud/{serviceName}/pca/{pcaServiceName}/serviceInfos";
StringBuilder sb = path(qPath, serviceName, pcaServiceName);
exec(qPath, "PUT", sb.toString(), body);
} | java | public void serviceName_pca_pcaServiceName_serviceInfos_PUT(String serviceName, String pcaServiceName, OvhService body) throws IOException {
String qPath = "/cloud/{serviceName}/pca/{pcaServiceName}/serviceInfos";
StringBuilder sb = path(qPath, serviceName, pcaServiceName);
exec(qPath, "PUT", sb.toString(), body);
} | [
"public",
"void",
"serviceName_pca_pcaServiceName_serviceInfos_PUT",
"(",
"String",
"serviceName",
",",
"String",
"pcaServiceName",
",",
"OvhService",
"body",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/cloud/{serviceName}/pca/{pcaServiceName}/serviceInfos\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"pcaServiceName",
")",
";",
"exec",
"(",
"qPath",
",",
"\"PUT\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"body",
")",
";",
"}"
] | Alter this object properties
REST: PUT /cloud/{serviceName}/pca/{pcaServiceName}/serviceInfos
@param body [required] New object properties
@param serviceName [required] The internal name of your public cloud passport
@param pcaServiceName [required] The internal name of your PCA offer
@deprecated | [
"Alter",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-cloud/src/main/java/net/minidev/ovh/api/ApiOvhCloud.java#L2435-L2439 |
lucee/Lucee | core/src/main/java/lucee/runtime/tag/Zip.java | Zip.required | private void required(String attributeName, Resource attributValue, boolean exists) throws ApplicationException {
"""
throw a error if the value is empty (null)
@param attributeName
@param attributValue
@throws ApplicationException
"""
if (attributValue == null)
throw new ApplicationException("invalid attribute constellation for the tag zip", "attribute [" + attributeName + "] is required, if action is [" + action + "]");
if (exists && !attributValue.exists()) throw new ApplicationException(attributeName + " resource [" + attributValue + "] doesn't exist");
else if (exists && !attributValue.canRead()) throw new ApplicationException("no access to " + attributeName + " resource [" + attributValue + "]");
} | java | private void required(String attributeName, Resource attributValue, boolean exists) throws ApplicationException {
if (attributValue == null)
throw new ApplicationException("invalid attribute constellation for the tag zip", "attribute [" + attributeName + "] is required, if action is [" + action + "]");
if (exists && !attributValue.exists()) throw new ApplicationException(attributeName + " resource [" + attributValue + "] doesn't exist");
else if (exists && !attributValue.canRead()) throw new ApplicationException("no access to " + attributeName + " resource [" + attributValue + "]");
} | [
"private",
"void",
"required",
"(",
"String",
"attributeName",
",",
"Resource",
"attributValue",
",",
"boolean",
"exists",
")",
"throws",
"ApplicationException",
"{",
"if",
"(",
"attributValue",
"==",
"null",
")",
"throw",
"new",
"ApplicationException",
"(",
"\"invalid attribute constellation for the tag zip\"",
",",
"\"attribute [\"",
"+",
"attributeName",
"+",
"\"] is required, if action is [\"",
"+",
"action",
"+",
"\"]\"",
")",
";",
"if",
"(",
"exists",
"&&",
"!",
"attributValue",
".",
"exists",
"(",
")",
")",
"throw",
"new",
"ApplicationException",
"(",
"attributeName",
"+",
"\" resource [\"",
"+",
"attributValue",
"+",
"\"] doesn't exist\"",
")",
";",
"else",
"if",
"(",
"exists",
"&&",
"!",
"attributValue",
".",
"canRead",
"(",
")",
")",
"throw",
"new",
"ApplicationException",
"(",
"\"no access to \"",
"+",
"attributeName",
"+",
"\" resource [\"",
"+",
"attributValue",
"+",
"\"]\"",
")",
";",
"}"
] | throw a error if the value is empty (null)
@param attributeName
@param attributValue
@throws ApplicationException | [
"throw",
"a",
"error",
"if",
"the",
"value",
"is",
"empty",
"(",
"null",
")"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/runtime/tag/Zip.java#L694-L701 |
kamcpp/avicenna | src/avicenna/src/main/java/org/labcrypto/avicenna/Avicenna.java | Avicenna.defineDependency | public static <T> void defineDependency(Class<T> clazz, T dependency) {
"""
Adds a direct mapping between a type and an object.
@param clazz Class type which should be injected.
@param dependency Dependency reference which should be copied to injection targets.
"""
defineDependency(clazz, null, dependency);
} | java | public static <T> void defineDependency(Class<T> clazz, T dependency) {
defineDependency(clazz, null, dependency);
} | [
"public",
"static",
"<",
"T",
">",
"void",
"defineDependency",
"(",
"Class",
"<",
"T",
">",
"clazz",
",",
"T",
"dependency",
")",
"{",
"defineDependency",
"(",
"clazz",
",",
"null",
",",
"dependency",
")",
";",
"}"
] | Adds a direct mapping between a type and an object.
@param clazz Class type which should be injected.
@param dependency Dependency reference which should be copied to injection targets. | [
"Adds",
"a",
"direct",
"mapping",
"between",
"a",
"type",
"and",
"an",
"object",
"."
] | train | https://github.com/kamcpp/avicenna/blob/0fc4eff447761140cd3799287427d99c63ea6e6e/src/avicenna/src/main/java/org/labcrypto/avicenna/Avicenna.java#L145-L147 |
Netflix/conductor | core/src/main/java/com/netflix/conductor/core/execution/mapper/ForkJoinDynamicTaskMapper.java | ForkJoinDynamicTaskMapper.createJoinTask | @VisibleForTesting
Task createJoinTask(Workflow workflowInstance, WorkflowTask joinWorkflowTask, HashMap<String, Object> joinInput) {
"""
This method creates a JOIN task that is used in the {@link this#getMappedTasks(TaskMapperContext)}
at the end to add a join task to be scheduled after all the fork tasks
@param workflowInstance: A instance of the {@link Workflow} which represents the workflow being executed.
@param joinWorkflowTask: A instance of {@link WorkflowTask} which is of type {@link TaskType#JOIN}
@param joinInput: The input which is set in the {@link Task#setInputData(Map)}
@return a new instance of {@link Task} representing a {@link SystemTaskType#JOIN}
"""
Task joinTask = new Task();
joinTask.setTaskType(SystemTaskType.JOIN.name());
joinTask.setTaskDefName(SystemTaskType.JOIN.name());
joinTask.setReferenceTaskName(joinWorkflowTask.getTaskReferenceName());
joinTask.setWorkflowInstanceId(workflowInstance.getWorkflowId());
joinTask.setWorkflowType(workflowInstance.getWorkflowName());
joinTask.setCorrelationId(workflowInstance.getCorrelationId());
joinTask.setScheduledTime(System.currentTimeMillis());
joinTask.setInputData(joinInput);
joinTask.setTaskId(IDGenerator.generate());
joinTask.setStatus(Task.Status.IN_PROGRESS);
joinTask.setWorkflowTask(joinWorkflowTask);
return joinTask;
} | java | @VisibleForTesting
Task createJoinTask(Workflow workflowInstance, WorkflowTask joinWorkflowTask, HashMap<String, Object> joinInput) {
Task joinTask = new Task();
joinTask.setTaskType(SystemTaskType.JOIN.name());
joinTask.setTaskDefName(SystemTaskType.JOIN.name());
joinTask.setReferenceTaskName(joinWorkflowTask.getTaskReferenceName());
joinTask.setWorkflowInstanceId(workflowInstance.getWorkflowId());
joinTask.setWorkflowType(workflowInstance.getWorkflowName());
joinTask.setCorrelationId(workflowInstance.getCorrelationId());
joinTask.setScheduledTime(System.currentTimeMillis());
joinTask.setInputData(joinInput);
joinTask.setTaskId(IDGenerator.generate());
joinTask.setStatus(Task.Status.IN_PROGRESS);
joinTask.setWorkflowTask(joinWorkflowTask);
return joinTask;
} | [
"@",
"VisibleForTesting",
"Task",
"createJoinTask",
"(",
"Workflow",
"workflowInstance",
",",
"WorkflowTask",
"joinWorkflowTask",
",",
"HashMap",
"<",
"String",
",",
"Object",
">",
"joinInput",
")",
"{",
"Task",
"joinTask",
"=",
"new",
"Task",
"(",
")",
";",
"joinTask",
".",
"setTaskType",
"(",
"SystemTaskType",
".",
"JOIN",
".",
"name",
"(",
")",
")",
";",
"joinTask",
".",
"setTaskDefName",
"(",
"SystemTaskType",
".",
"JOIN",
".",
"name",
"(",
")",
")",
";",
"joinTask",
".",
"setReferenceTaskName",
"(",
"joinWorkflowTask",
".",
"getTaskReferenceName",
"(",
")",
")",
";",
"joinTask",
".",
"setWorkflowInstanceId",
"(",
"workflowInstance",
".",
"getWorkflowId",
"(",
")",
")",
";",
"joinTask",
".",
"setWorkflowType",
"(",
"workflowInstance",
".",
"getWorkflowName",
"(",
")",
")",
";",
"joinTask",
".",
"setCorrelationId",
"(",
"workflowInstance",
".",
"getCorrelationId",
"(",
")",
")",
";",
"joinTask",
".",
"setScheduledTime",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
";",
"joinTask",
".",
"setInputData",
"(",
"joinInput",
")",
";",
"joinTask",
".",
"setTaskId",
"(",
"IDGenerator",
".",
"generate",
"(",
")",
")",
";",
"joinTask",
".",
"setStatus",
"(",
"Task",
".",
"Status",
".",
"IN_PROGRESS",
")",
";",
"joinTask",
".",
"setWorkflowTask",
"(",
"joinWorkflowTask",
")",
";",
"return",
"joinTask",
";",
"}"
] | This method creates a JOIN task that is used in the {@link this#getMappedTasks(TaskMapperContext)}
at the end to add a join task to be scheduled after all the fork tasks
@param workflowInstance: A instance of the {@link Workflow} which represents the workflow being executed.
@param joinWorkflowTask: A instance of {@link WorkflowTask} which is of type {@link TaskType#JOIN}
@param joinInput: The input which is set in the {@link Task#setInputData(Map)}
@return a new instance of {@link Task} representing a {@link SystemTaskType#JOIN} | [
"This",
"method",
"creates",
"a",
"JOIN",
"task",
"that",
"is",
"used",
"in",
"the",
"{",
"@link",
"this#getMappedTasks",
"(",
"TaskMapperContext",
")",
"}",
"at",
"the",
"end",
"to",
"add",
"a",
"join",
"task",
"to",
"be",
"scheduled",
"after",
"all",
"the",
"fork",
"tasks"
] | train | https://github.com/Netflix/conductor/blob/78fae0ed9ddea22891f9eebb96a2ec0b2783dca0/core/src/main/java/com/netflix/conductor/core/execution/mapper/ForkJoinDynamicTaskMapper.java#L208-L223 |
rnorth/visible-assertions | src/main/java/org/rnorth/visibleassertions/VisibleAssertions.java | VisibleAssertions.assertThrows | public static <T> void assertThrows(String message, Class<? extends Exception> exceptionClass, Callable<T> callable) {
"""
Assert that a given callable throws an exception of a particular class.
<p>
The assertion passes if the callable throws exactly the same class of exception (not a subclass).
<p>
If the callable doesn't throw an exception at all, or if another class of exception is thrown, the assertion
fails.
<p>
If the assertion passes, a green tick will be shown. If the assertion fails, a red cross will be shown.
@param message message to display alongside the assertion outcome
@param exceptionClass the expected exception class
@param callable a Callable to invoke
@param <T> return type of the callable
"""
T result;
try {
result = callable.call();
fail(message, "No exception was thrown (expected " + exceptionClass.getSimpleName() + " but '" + result + "' was returned instead)");
} catch (Exception e) {
if (!e.getClass().equals(exceptionClass)) {
fail(message, e.getClass().getSimpleName() + " was thrown instead of " + exceptionClass.getSimpleName());
}
}
pass(message);
} | java | public static <T> void assertThrows(String message, Class<? extends Exception> exceptionClass, Callable<T> callable) {
T result;
try {
result = callable.call();
fail(message, "No exception was thrown (expected " + exceptionClass.getSimpleName() + " but '" + result + "' was returned instead)");
} catch (Exception e) {
if (!e.getClass().equals(exceptionClass)) {
fail(message, e.getClass().getSimpleName() + " was thrown instead of " + exceptionClass.getSimpleName());
}
}
pass(message);
} | [
"public",
"static",
"<",
"T",
">",
"void",
"assertThrows",
"(",
"String",
"message",
",",
"Class",
"<",
"?",
"extends",
"Exception",
">",
"exceptionClass",
",",
"Callable",
"<",
"T",
">",
"callable",
")",
"{",
"T",
"result",
";",
"try",
"{",
"result",
"=",
"callable",
".",
"call",
"(",
")",
";",
"fail",
"(",
"message",
",",
"\"No exception was thrown (expected \"",
"+",
"exceptionClass",
".",
"getSimpleName",
"(",
")",
"+",
"\" but '\"",
"+",
"result",
"+",
"\"' was returned instead)\"",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"if",
"(",
"!",
"e",
".",
"getClass",
"(",
")",
".",
"equals",
"(",
"exceptionClass",
")",
")",
"{",
"fail",
"(",
"message",
",",
"e",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
"+",
"\" was thrown instead of \"",
"+",
"exceptionClass",
".",
"getSimpleName",
"(",
")",
")",
";",
"}",
"}",
"pass",
"(",
"message",
")",
";",
"}"
] | Assert that a given callable throws an exception of a particular class.
<p>
The assertion passes if the callable throws exactly the same class of exception (not a subclass).
<p>
If the callable doesn't throw an exception at all, or if another class of exception is thrown, the assertion
fails.
<p>
If the assertion passes, a green tick will be shown. If the assertion fails, a red cross will be shown.
@param message message to display alongside the assertion outcome
@param exceptionClass the expected exception class
@param callable a Callable to invoke
@param <T> return type of the callable | [
"Assert",
"that",
"a",
"given",
"callable",
"throws",
"an",
"exception",
"of",
"a",
"particular",
"class",
".",
"<p",
">",
"The",
"assertion",
"passes",
"if",
"the",
"callable",
"throws",
"exactly",
"the",
"same",
"class",
"of",
"exception",
"(",
"not",
"a",
"subclass",
")",
".",
"<p",
">",
"If",
"the",
"callable",
"doesn",
"t",
"throw",
"an",
"exception",
"at",
"all",
"or",
"if",
"another",
"class",
"of",
"exception",
"is",
"thrown",
"the",
"assertion",
"fails",
".",
"<p",
">",
"If",
"the",
"assertion",
"passes",
"a",
"green",
"tick",
"will",
"be",
"shown",
".",
"If",
"the",
"assertion",
"fails",
"a",
"red",
"cross",
"will",
"be",
"shown",
"."
] | train | https://github.com/rnorth/visible-assertions/blob/6d7a7724db40ac0e9f87279553f814b790310b3b/src/main/java/org/rnorth/visibleassertions/VisibleAssertions.java#L376-L388 |
xqbase/util | util-jdk17/src/main/java/com/xqbase/util/Time.java | Time.parse | public static long parse(String date, String time) {
"""
Convert a date and a time string to a Unix time (in milliseconds).
Either date or time can be null.
"""
return parseDate(date) + parseTime(time) + timeZoneOffset;
} | java | public static long parse(String date, String time) {
return parseDate(date) + parseTime(time) + timeZoneOffset;
} | [
"public",
"static",
"long",
"parse",
"(",
"String",
"date",
",",
"String",
"time",
")",
"{",
"return",
"parseDate",
"(",
"date",
")",
"+",
"parseTime",
"(",
"time",
")",
"+",
"timeZoneOffset",
";",
"}"
] | Convert a date and a time string to a Unix time (in milliseconds).
Either date or time can be null. | [
"Convert",
"a",
"date",
"and",
"a",
"time",
"string",
"to",
"a",
"Unix",
"time",
"(",
"in",
"milliseconds",
")",
".",
"Either",
"date",
"or",
"time",
"can",
"be",
"null",
"."
] | train | https://github.com/xqbase/util/blob/e7b9167b6c701b9eec988a9d1e68446cef5ef420/util-jdk17/src/main/java/com/xqbase/util/Time.java#L51-L53 |
Javacord/Javacord | javacord-api/src/main/java/org/javacord/api/entity/message/embed/EmbedBuilder.java | EmbedBuilder.addInlineField | public EmbedBuilder addInlineField(String name, String value) {
"""
Adds an inline field to the embed.
@param name The name of the field.
@param value The value of the field.
@return The current instance in order to chain call methods.
"""
delegate.addField(name, value, true);
return this;
} | java | public EmbedBuilder addInlineField(String name, String value) {
delegate.addField(name, value, true);
return this;
} | [
"public",
"EmbedBuilder",
"addInlineField",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"delegate",
".",
"addField",
"(",
"name",
",",
"value",
",",
"true",
")",
";",
"return",
"this",
";",
"}"
] | Adds an inline field to the embed.
@param name The name of the field.
@param value The value of the field.
@return The current instance in order to chain call methods. | [
"Adds",
"an",
"inline",
"field",
"to",
"the",
"embed",
"."
] | train | https://github.com/Javacord/Javacord/blob/915aad084dc5e863284267529d0dccd625fc6886/javacord-api/src/main/java/org/javacord/api/entity/message/embed/EmbedBuilder.java#L599-L602 |
apache/incubator-gobblin | gobblin-core-base/src/main/java/org/apache/gobblin/instrumented/converter/InstrumentedConverterBase.java | InstrumentedConverterBase.afterConvert | public void afterConvert(Iterable<DO> iterable, long startTimeNanos) {
"""
Called after conversion.
@param iterable conversion result.
@param startTimeNanos start time of conversion.
"""
Instrumented.updateTimer(this.converterTimer, System.nanoTime() - startTimeNanos, TimeUnit.NANOSECONDS);
} | java | public void afterConvert(Iterable<DO> iterable, long startTimeNanos) {
Instrumented.updateTimer(this.converterTimer, System.nanoTime() - startTimeNanos, TimeUnit.NANOSECONDS);
} | [
"public",
"void",
"afterConvert",
"(",
"Iterable",
"<",
"DO",
">",
"iterable",
",",
"long",
"startTimeNanos",
")",
"{",
"Instrumented",
".",
"updateTimer",
"(",
"this",
".",
"converterTimer",
",",
"System",
".",
"nanoTime",
"(",
")",
"-",
"startTimeNanos",
",",
"TimeUnit",
".",
"NANOSECONDS",
")",
";",
"}"
] | Called after conversion.
@param iterable conversion result.
@param startTimeNanos start time of conversion. | [
"Called",
"after",
"conversion",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-core-base/src/main/java/org/apache/gobblin/instrumented/converter/InstrumentedConverterBase.java#L156-L158 |
onepf/OpenIAB | library/src/main/java/org/onepf/oms/OpenIabHelper.java | OpenIabHelper.getStoreSku | @NotNull
public static String getStoreSku(@NotNull final String appStoreName, @NotNull String sku) {
"""
Return the previously mapped store SKU for the internal SKU
@param appStoreName The store name
@param sku The internal SKU
@return SKU used in the store for the specified internal SKU
@see org.onepf.oms.SkuManager#mapSku(String, String, String)
@deprecated Use {@link org.onepf.oms.SkuManager#getStoreSku(String, String)}
<p/>
"""
return SkuManager.getInstance().getStoreSku(appStoreName, sku);
} | java | @NotNull
public static String getStoreSku(@NotNull final String appStoreName, @NotNull String sku) {
return SkuManager.getInstance().getStoreSku(appStoreName, sku);
} | [
"@",
"NotNull",
"public",
"static",
"String",
"getStoreSku",
"(",
"@",
"NotNull",
"final",
"String",
"appStoreName",
",",
"@",
"NotNull",
"String",
"sku",
")",
"{",
"return",
"SkuManager",
".",
"getInstance",
"(",
")",
".",
"getStoreSku",
"(",
"appStoreName",
",",
"sku",
")",
";",
"}"
] | Return the previously mapped store SKU for the internal SKU
@param appStoreName The store name
@param sku The internal SKU
@return SKU used in the store for the specified internal SKU
@see org.onepf.oms.SkuManager#mapSku(String, String, String)
@deprecated Use {@link org.onepf.oms.SkuManager#getStoreSku(String, String)}
<p/> | [
"Return",
"the",
"previously",
"mapped",
"store",
"SKU",
"for",
"the",
"internal",
"SKU"
] | train | https://github.com/onepf/OpenIAB/blob/90552d53c5303b322940d96a0c4b7cb797d78760/library/src/main/java/org/onepf/oms/OpenIabHelper.java#L367-L370 |
OpenLiberty/open-liberty | dev/com.ibm.ws.security.social/src/com/ibm/ws/security/social/twitter/TwitterTokenServices.java | TwitterTokenServices.getRequestToken | public void getRequestToken(HttpServletRequest request, HttpServletResponse response, String callbackUrl, String stateValue, SocialLoginConfig config) {
"""
Attemps to obtain a request token from the oauth/request_token Twitter API. This request token can later be used to
obtain an access token. If a request token is successfully obtained, the request is redirected to the oauth/authorize
Twitter API to have Twitter authenticate the user and allow the user to authorize the application to access Twitter data.
@param request
@param response
@param callbackUrl
URL that Twitter should redirect to with the oauth_token and oauth_verifier parameters once the request token is
issued.
@param stateValue
@param config
"""
TwitterEndpointServices twitter = getTwitterEndpointServices();
twitter.setConsumerKey(config.getClientId());
twitter.setConsumerSecret(config.getClientSecret());
Map<String, Object> result = twitter.obtainRequestToken(config, callbackUrl);
if (result == null || result.isEmpty()) {
Tr.error(tc, "TWITTER_ERROR_OBTAINING_ENDPOINT_RESULT", new Object[] { TwitterConstants.TWITTER_ENDPOINT_REQUEST_TOKEN });
ErrorHandlerImpl.getInstance().handleErrorResponse(response);
return;
}
if (tc.isDebugEnabled()) {
Tr.debug(tc, TwitterConstants.TWITTER_ENDPOINT_REQUEST_TOKEN + " result: " + result.toString());
}
try {
if (!isSuccessfulResult(result, TwitterConstants.TWITTER_ENDPOINT_REQUEST_TOKEN)) {
ErrorHandlerImpl.getInstance().handleErrorResponse(response);
return;
}
// If successful, the result has already been verified to contain a non-empty oauth_token and oauth_token_secret
String requestToken = (String) result.get(TwitterConstants.RESPONSE_OAUTH_TOKEN);
// Cache request token to verify against later
setCookies(request, response, requestToken, stateValue);
// Redirect to authorization endpoint with the provided request token
String authzEndpoint = config.getAuthorizationEndpoint();
try {
SocialUtil.validateEndpointWithQuery(authzEndpoint);
} catch (SocialLoginException e) {
Tr.error(tc, "FAILED_TO_REDIRECT_TO_AUTHZ_ENDPOINT", new Object[] { config.getUniqueId(), e.getMessage() });
ErrorHandlerImpl.getInstance().handleErrorResponse(response);
return;
}
String queryChar = (authzEndpoint.contains("?")) ? "&" : "?";
response.sendRedirect(authzEndpoint + queryChar + TwitterConstants.PARAM_OAUTH_TOKEN + "=" + requestToken);
} catch (IOException e) {
Tr.error(tc, "TWITTER_REDIRECT_IOEXCEPTION", new Object[] { TwitterConstants.TWITTER_ENDPOINT_REQUEST_TOKEN, e.getLocalizedMessage() });
ErrorHandlerImpl.getInstance().handleErrorResponse(response, HttpServletResponse.SC_BAD_REQUEST);
return;
}
} | java | public void getRequestToken(HttpServletRequest request, HttpServletResponse response, String callbackUrl, String stateValue, SocialLoginConfig config) {
TwitterEndpointServices twitter = getTwitterEndpointServices();
twitter.setConsumerKey(config.getClientId());
twitter.setConsumerSecret(config.getClientSecret());
Map<String, Object> result = twitter.obtainRequestToken(config, callbackUrl);
if (result == null || result.isEmpty()) {
Tr.error(tc, "TWITTER_ERROR_OBTAINING_ENDPOINT_RESULT", new Object[] { TwitterConstants.TWITTER_ENDPOINT_REQUEST_TOKEN });
ErrorHandlerImpl.getInstance().handleErrorResponse(response);
return;
}
if (tc.isDebugEnabled()) {
Tr.debug(tc, TwitterConstants.TWITTER_ENDPOINT_REQUEST_TOKEN + " result: " + result.toString());
}
try {
if (!isSuccessfulResult(result, TwitterConstants.TWITTER_ENDPOINT_REQUEST_TOKEN)) {
ErrorHandlerImpl.getInstance().handleErrorResponse(response);
return;
}
// If successful, the result has already been verified to contain a non-empty oauth_token and oauth_token_secret
String requestToken = (String) result.get(TwitterConstants.RESPONSE_OAUTH_TOKEN);
// Cache request token to verify against later
setCookies(request, response, requestToken, stateValue);
// Redirect to authorization endpoint with the provided request token
String authzEndpoint = config.getAuthorizationEndpoint();
try {
SocialUtil.validateEndpointWithQuery(authzEndpoint);
} catch (SocialLoginException e) {
Tr.error(tc, "FAILED_TO_REDIRECT_TO_AUTHZ_ENDPOINT", new Object[] { config.getUniqueId(), e.getMessage() });
ErrorHandlerImpl.getInstance().handleErrorResponse(response);
return;
}
String queryChar = (authzEndpoint.contains("?")) ? "&" : "?";
response.sendRedirect(authzEndpoint + queryChar + TwitterConstants.PARAM_OAUTH_TOKEN + "=" + requestToken);
} catch (IOException e) {
Tr.error(tc, "TWITTER_REDIRECT_IOEXCEPTION", new Object[] { TwitterConstants.TWITTER_ENDPOINT_REQUEST_TOKEN, e.getLocalizedMessage() });
ErrorHandlerImpl.getInstance().handleErrorResponse(response, HttpServletResponse.SC_BAD_REQUEST);
return;
}
} | [
"public",
"void",
"getRequestToken",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
",",
"String",
"callbackUrl",
",",
"String",
"stateValue",
",",
"SocialLoginConfig",
"config",
")",
"{",
"TwitterEndpointServices",
"twitter",
"=",
"getTwitterEndpointServices",
"(",
")",
";",
"twitter",
".",
"setConsumerKey",
"(",
"config",
".",
"getClientId",
"(",
")",
")",
";",
"twitter",
".",
"setConsumerSecret",
"(",
"config",
".",
"getClientSecret",
"(",
")",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"result",
"=",
"twitter",
".",
"obtainRequestToken",
"(",
"config",
",",
"callbackUrl",
")",
";",
"if",
"(",
"result",
"==",
"null",
"||",
"result",
".",
"isEmpty",
"(",
")",
")",
"{",
"Tr",
".",
"error",
"(",
"tc",
",",
"\"TWITTER_ERROR_OBTAINING_ENDPOINT_RESULT\"",
",",
"new",
"Object",
"[",
"]",
"{",
"TwitterConstants",
".",
"TWITTER_ENDPOINT_REQUEST_TOKEN",
"}",
")",
";",
"ErrorHandlerImpl",
".",
"getInstance",
"(",
")",
".",
"handleErrorResponse",
"(",
"response",
")",
";",
"return",
";",
"}",
"if",
"(",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"TwitterConstants",
".",
"TWITTER_ENDPOINT_REQUEST_TOKEN",
"+",
"\" result: \"",
"+",
"result",
".",
"toString",
"(",
")",
")",
";",
"}",
"try",
"{",
"if",
"(",
"!",
"isSuccessfulResult",
"(",
"result",
",",
"TwitterConstants",
".",
"TWITTER_ENDPOINT_REQUEST_TOKEN",
")",
")",
"{",
"ErrorHandlerImpl",
".",
"getInstance",
"(",
")",
".",
"handleErrorResponse",
"(",
"response",
")",
";",
"return",
";",
"}",
"// If successful, the result has already been verified to contain a non-empty oauth_token and oauth_token_secret",
"String",
"requestToken",
"=",
"(",
"String",
")",
"result",
".",
"get",
"(",
"TwitterConstants",
".",
"RESPONSE_OAUTH_TOKEN",
")",
";",
"// Cache request token to verify against later",
"setCookies",
"(",
"request",
",",
"response",
",",
"requestToken",
",",
"stateValue",
")",
";",
"// Redirect to authorization endpoint with the provided request token",
"String",
"authzEndpoint",
"=",
"config",
".",
"getAuthorizationEndpoint",
"(",
")",
";",
"try",
"{",
"SocialUtil",
".",
"validateEndpointWithQuery",
"(",
"authzEndpoint",
")",
";",
"}",
"catch",
"(",
"SocialLoginException",
"e",
")",
"{",
"Tr",
".",
"error",
"(",
"tc",
",",
"\"FAILED_TO_REDIRECT_TO_AUTHZ_ENDPOINT\"",
",",
"new",
"Object",
"[",
"]",
"{",
"config",
".",
"getUniqueId",
"(",
")",
",",
"e",
".",
"getMessage",
"(",
")",
"}",
")",
";",
"ErrorHandlerImpl",
".",
"getInstance",
"(",
")",
".",
"handleErrorResponse",
"(",
"response",
")",
";",
"return",
";",
"}",
"String",
"queryChar",
"=",
"(",
"authzEndpoint",
".",
"contains",
"(",
"\"?\"",
")",
")",
"?",
"\"&\"",
":",
"\"?\"",
";",
"response",
".",
"sendRedirect",
"(",
"authzEndpoint",
"+",
"queryChar",
"+",
"TwitterConstants",
".",
"PARAM_OAUTH_TOKEN",
"+",
"\"=\"",
"+",
"requestToken",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"Tr",
".",
"error",
"(",
"tc",
",",
"\"TWITTER_REDIRECT_IOEXCEPTION\"",
",",
"new",
"Object",
"[",
"]",
"{",
"TwitterConstants",
".",
"TWITTER_ENDPOINT_REQUEST_TOKEN",
",",
"e",
".",
"getLocalizedMessage",
"(",
")",
"}",
")",
";",
"ErrorHandlerImpl",
".",
"getInstance",
"(",
")",
".",
"handleErrorResponse",
"(",
"response",
",",
"HttpServletResponse",
".",
"SC_BAD_REQUEST",
")",
";",
"return",
";",
"}",
"}"
] | Attemps to obtain a request token from the oauth/request_token Twitter API. This request token can later be used to
obtain an access token. If a request token is successfully obtained, the request is redirected to the oauth/authorize
Twitter API to have Twitter authenticate the user and allow the user to authorize the application to access Twitter data.
@param request
@param response
@param callbackUrl
URL that Twitter should redirect to with the oauth_token and oauth_verifier parameters once the request token is
issued.
@param stateValue
@param config | [
"Attemps",
"to",
"obtain",
"a",
"request",
"token",
"from",
"the",
"oauth",
"/",
"request_token",
"Twitter",
"API",
".",
"This",
"request",
"token",
"can",
"later",
"be",
"used",
"to",
"obtain",
"an",
"access",
"token",
".",
"If",
"a",
"request",
"token",
"is",
"successfully",
"obtained",
"the",
"request",
"is",
"redirected",
"to",
"the",
"oauth",
"/",
"authorize",
"Twitter",
"API",
"to",
"have",
"Twitter",
"authenticate",
"the",
"user",
"and",
"allow",
"the",
"user",
"to",
"authorize",
"the",
"application",
"to",
"access",
"Twitter",
"data",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.social/src/com/ibm/ws/security/social/twitter/TwitterTokenServices.java#L56-L101 |
johnkil/Android-ProgressFragment | progressfragment-native/src/com/devspark/progressfragment/ProgressFragment.java | ProgressFragment.setContentShown | private void setContentShown(boolean shown, boolean animate) {
"""
Control whether the content is being displayed. You can make it not
displayed if you are waiting for the initial data to show in it. During
this time an indeterminant progress indicator will be shown instead.
@param shown If true, the content view is shown; if false, the progress
indicator. The initial value is true.
@param animate If true, an animation will be used to transition to the
new state.
"""
ensureContent();
if (mContentShown == shown) {
return;
}
mContentShown = shown;
if (shown) {
if (animate) {
mProgressContainer.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out));
mContentContainer.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in));
} else {
mProgressContainer.clearAnimation();
mContentContainer.clearAnimation();
}
mProgressContainer.setVisibility(View.GONE);
mContentContainer.setVisibility(View.VISIBLE);
} else {
if (animate) {
mProgressContainer.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in));
mContentContainer.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out));
} else {
mProgressContainer.clearAnimation();
mContentContainer.clearAnimation();
}
mProgressContainer.setVisibility(View.VISIBLE);
mContentContainer.setVisibility(View.GONE);
}
} | java | private void setContentShown(boolean shown, boolean animate) {
ensureContent();
if (mContentShown == shown) {
return;
}
mContentShown = shown;
if (shown) {
if (animate) {
mProgressContainer.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out));
mContentContainer.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in));
} else {
mProgressContainer.clearAnimation();
mContentContainer.clearAnimation();
}
mProgressContainer.setVisibility(View.GONE);
mContentContainer.setVisibility(View.VISIBLE);
} else {
if (animate) {
mProgressContainer.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in));
mContentContainer.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out));
} else {
mProgressContainer.clearAnimation();
mContentContainer.clearAnimation();
}
mProgressContainer.setVisibility(View.VISIBLE);
mContentContainer.setVisibility(View.GONE);
}
} | [
"private",
"void",
"setContentShown",
"(",
"boolean",
"shown",
",",
"boolean",
"animate",
")",
"{",
"ensureContent",
"(",
")",
";",
"if",
"(",
"mContentShown",
"==",
"shown",
")",
"{",
"return",
";",
"}",
"mContentShown",
"=",
"shown",
";",
"if",
"(",
"shown",
")",
"{",
"if",
"(",
"animate",
")",
"{",
"mProgressContainer",
".",
"startAnimation",
"(",
"AnimationUtils",
".",
"loadAnimation",
"(",
"getActivity",
"(",
")",
",",
"android",
".",
"R",
".",
"anim",
".",
"fade_out",
")",
")",
";",
"mContentContainer",
".",
"startAnimation",
"(",
"AnimationUtils",
".",
"loadAnimation",
"(",
"getActivity",
"(",
")",
",",
"android",
".",
"R",
".",
"anim",
".",
"fade_in",
")",
")",
";",
"}",
"else",
"{",
"mProgressContainer",
".",
"clearAnimation",
"(",
")",
";",
"mContentContainer",
".",
"clearAnimation",
"(",
")",
";",
"}",
"mProgressContainer",
".",
"setVisibility",
"(",
"View",
".",
"GONE",
")",
";",
"mContentContainer",
".",
"setVisibility",
"(",
"View",
".",
"VISIBLE",
")",
";",
"}",
"else",
"{",
"if",
"(",
"animate",
")",
"{",
"mProgressContainer",
".",
"startAnimation",
"(",
"AnimationUtils",
".",
"loadAnimation",
"(",
"getActivity",
"(",
")",
",",
"android",
".",
"R",
".",
"anim",
".",
"fade_in",
")",
")",
";",
"mContentContainer",
".",
"startAnimation",
"(",
"AnimationUtils",
".",
"loadAnimation",
"(",
"getActivity",
"(",
")",
",",
"android",
".",
"R",
".",
"anim",
".",
"fade_out",
")",
")",
";",
"}",
"else",
"{",
"mProgressContainer",
".",
"clearAnimation",
"(",
")",
";",
"mContentContainer",
".",
"clearAnimation",
"(",
")",
";",
"}",
"mProgressContainer",
".",
"setVisibility",
"(",
"View",
".",
"VISIBLE",
")",
";",
"mContentContainer",
".",
"setVisibility",
"(",
"View",
".",
"GONE",
")",
";",
"}",
"}"
] | Control whether the content is being displayed. You can make it not
displayed if you are waiting for the initial data to show in it. During
this time an indeterminant progress indicator will be shown instead.
@param shown If true, the content view is shown; if false, the progress
indicator. The initial value is true.
@param animate If true, an animation will be used to transition to the
new state. | [
"Control",
"whether",
"the",
"content",
"is",
"being",
"displayed",
".",
"You",
"can",
"make",
"it",
"not",
"displayed",
"if",
"you",
"are",
"waiting",
"for",
"the",
"initial",
"data",
"to",
"show",
"in",
"it",
".",
"During",
"this",
"time",
"an",
"indeterminant",
"progress",
"indicator",
"will",
"be",
"shown",
"instead",
"."
] | train | https://github.com/johnkil/Android-ProgressFragment/blob/f4b3b969f36f3ac9598c662722630f9ffb151bd6/progressfragment-native/src/com/devspark/progressfragment/ProgressFragment.java#L202-L229 |
liferay/com-liferay-commerce | commerce-api/src/main/java/com/liferay/commerce/model/CommerceAvailabilityEstimateWrapper.java | CommerceAvailabilityEstimateWrapper.getTitle | @Override
public String getTitle(String languageId, boolean useDefault) {
"""
Returns the localized title of this commerce availability estimate in the language, optionally using the default language if no localization exists for the requested language.
@param languageId the ID of the language
@param useDefault whether to use the default language if no localization exists for the requested language
@return the localized title of this commerce availability estimate
"""
return _commerceAvailabilityEstimate.getTitle(languageId, useDefault);
} | java | @Override
public String getTitle(String languageId, boolean useDefault) {
return _commerceAvailabilityEstimate.getTitle(languageId, useDefault);
} | [
"@",
"Override",
"public",
"String",
"getTitle",
"(",
"String",
"languageId",
",",
"boolean",
"useDefault",
")",
"{",
"return",
"_commerceAvailabilityEstimate",
".",
"getTitle",
"(",
"languageId",
",",
"useDefault",
")",
";",
"}"
] | Returns the localized title of this commerce availability estimate in the language, optionally using the default language if no localization exists for the requested language.
@param languageId the ID of the language
@param useDefault whether to use the default language if no localization exists for the requested language
@return the localized title of this commerce availability estimate | [
"Returns",
"the",
"localized",
"title",
"of",
"this",
"commerce",
"availability",
"estimate",
"in",
"the",
"language",
"optionally",
"using",
"the",
"default",
"language",
"if",
"no",
"localization",
"exists",
"for",
"the",
"requested",
"language",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-api/src/main/java/com/liferay/commerce/model/CommerceAvailabilityEstimateWrapper.java#L313-L316 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/ArabicShaping.java | ArabicShaping.flipArray | private static int flipArray(char [] dest, int start, int e, int w) {
"""
/*
Name : flipArray
Function: inverts array, so that start becomes end and vice versa
"""
int r;
if (w > start) {
// shift, assume small buffer size so don't use arraycopy
r = w;
w = start;
while (r < e) {
dest[w++] = dest[r++];
}
} else {
w = e;
}
return w;
} | java | private static int flipArray(char [] dest, int start, int e, int w){
int r;
if (w > start) {
// shift, assume small buffer size so don't use arraycopy
r = w;
w = start;
while (r < e) {
dest[w++] = dest[r++];
}
} else {
w = e;
}
return w;
} | [
"private",
"static",
"int",
"flipArray",
"(",
"char",
"[",
"]",
"dest",
",",
"int",
"start",
",",
"int",
"e",
",",
"int",
"w",
")",
"{",
"int",
"r",
";",
"if",
"(",
"w",
">",
"start",
")",
"{",
"// shift, assume small buffer size so don't use arraycopy",
"r",
"=",
"w",
";",
"w",
"=",
"start",
";",
"while",
"(",
"r",
"<",
"e",
")",
"{",
"dest",
"[",
"w",
"++",
"]",
"=",
"dest",
"[",
"r",
"++",
"]",
";",
"}",
"}",
"else",
"{",
"w",
"=",
"e",
";",
"}",
"return",
"w",
";",
"}"
] | /*
Name : flipArray
Function: inverts array, so that start becomes end and vice versa | [
"/",
"*",
"Name",
":",
"flipArray",
"Function",
":",
"inverts",
"array",
"so",
"that",
"start",
"becomes",
"end",
"and",
"vice",
"versa"
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/ArabicShaping.java#L1183-L1196 |
javagl/ND | nd-tuples/src/main/java/de/javagl/nd/tuples/i/IntTuples.java | IntTuples.compareLexicographically | public static int compareLexicographically(IntTuple t0, IntTuple t1) {
"""
Compares two tuples lexicographically, starting with
the elements of the lowest index.
@param t0 The first tuple
@param t1 The second tuple
@return -1 if the first tuple is lexicographically
smaller than the second, +1 if it is larger, and
0 if they are equal.
@throws IllegalArgumentException If the given tuples do not
have the same {@link Tuple#getSize() size}
"""
Utils.checkForEqualSize(t0, t1);
for (int i=0; i<t0.getSize(); i++)
{
if (t0.get(i) < t1.get(i))
{
return -1;
}
else if (t0.get(i) > t1.get(i))
{
return 1;
}
}
return 0;
} | java | public static int compareLexicographically(IntTuple t0, IntTuple t1)
{
Utils.checkForEqualSize(t0, t1);
for (int i=0; i<t0.getSize(); i++)
{
if (t0.get(i) < t1.get(i))
{
return -1;
}
else if (t0.get(i) > t1.get(i))
{
return 1;
}
}
return 0;
} | [
"public",
"static",
"int",
"compareLexicographically",
"(",
"IntTuple",
"t0",
",",
"IntTuple",
"t1",
")",
"{",
"Utils",
".",
"checkForEqualSize",
"(",
"t0",
",",
"t1",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"t0",
".",
"getSize",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"t0",
".",
"get",
"(",
"i",
")",
"<",
"t1",
".",
"get",
"(",
"i",
")",
")",
"{",
"return",
"-",
"1",
";",
"}",
"else",
"if",
"(",
"t0",
".",
"get",
"(",
"i",
")",
">",
"t1",
".",
"get",
"(",
"i",
")",
")",
"{",
"return",
"1",
";",
"}",
"}",
"return",
"0",
";",
"}"
] | Compares two tuples lexicographically, starting with
the elements of the lowest index.
@param t0 The first tuple
@param t1 The second tuple
@return -1 if the first tuple is lexicographically
smaller than the second, +1 if it is larger, and
0 if they are equal.
@throws IllegalArgumentException If the given tuples do not
have the same {@link Tuple#getSize() size} | [
"Compares",
"two",
"tuples",
"lexicographically",
"starting",
"with",
"the",
"elements",
"of",
"the",
"lowest",
"index",
"."
] | train | https://github.com/javagl/ND/blob/bcb655aaf5fc88af6194f73a27cca079186ff559/nd-tuples/src/main/java/de/javagl/nd/tuples/i/IntTuples.java#L902-L917 |
joniles/mpxj | src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java | ProjectTreeController.addTasks | private void addTasks(MpxjTreeNode parentNode, ChildTaskContainer parent) {
"""
Add tasks to the tree.
@param parentNode parent tree node
@param parent parent task container
"""
for (Task task : parent.getChildTasks())
{
final Task t = task;
MpxjTreeNode childNode = new MpxjTreeNode(task, TASK_EXCLUDED_METHODS)
{
@Override public String toString()
{
return t.getName();
}
};
parentNode.add(childNode);
addTasks(childNode, task);
}
} | java | private void addTasks(MpxjTreeNode parentNode, ChildTaskContainer parent)
{
for (Task task : parent.getChildTasks())
{
final Task t = task;
MpxjTreeNode childNode = new MpxjTreeNode(task, TASK_EXCLUDED_METHODS)
{
@Override public String toString()
{
return t.getName();
}
};
parentNode.add(childNode);
addTasks(childNode, task);
}
} | [
"private",
"void",
"addTasks",
"(",
"MpxjTreeNode",
"parentNode",
",",
"ChildTaskContainer",
"parent",
")",
"{",
"for",
"(",
"Task",
"task",
":",
"parent",
".",
"getChildTasks",
"(",
")",
")",
"{",
"final",
"Task",
"t",
"=",
"task",
";",
"MpxjTreeNode",
"childNode",
"=",
"new",
"MpxjTreeNode",
"(",
"task",
",",
"TASK_EXCLUDED_METHODS",
")",
"{",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"t",
".",
"getName",
"(",
")",
";",
"}",
"}",
";",
"parentNode",
".",
"add",
"(",
"childNode",
")",
";",
"addTasks",
"(",
"childNode",
",",
"task",
")",
";",
"}",
"}"
] | Add tasks to the tree.
@param parentNode parent tree node
@param parent parent task container | [
"Add",
"tasks",
"to",
"the",
"tree",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java#L198-L213 |
QSFT/Doradus | doradus-client/src/main/java/com/dell/doradus/client/RESTClient.java | RESTClient.sendRequest | public RESTResponse sendRequest(HttpMethod method, String uri,
Map<String, String> headers, byte[] body)
throws IOException {
"""
Send a REST command with the given method, URI, headers, and body to the
server and return the response in a {@link RESTResponse} object.
@param method HTTP method such as "GET" or "POST".
@param uri URI such as "/foo/bar?baz"
@param headers Headers to be included in the request, including content-type
if a body is included. Content-type is set automatically.
@param body Input entity to send with request in binary.
@return {@link RESTResponse} containing response from server.
@throws IOException If an error occurs on the socket.
"""
// Compress body using GZIP and add a content-encoding header if compression is requested.
byte[] entity = body;
if (m_bCompress && body != null && body.length > 0) {
entity = Utils.compressGZIP(body);
headers.put(HttpDefs.CONTENT_ENCODING, "gzip");
}
return sendAndReceive(method, uri, headers, entity);
} | java | public RESTResponse sendRequest(HttpMethod method, String uri,
Map<String, String> headers, byte[] body)
throws IOException {
// Compress body using GZIP and add a content-encoding header if compression is requested.
byte[] entity = body;
if (m_bCompress && body != null && body.length > 0) {
entity = Utils.compressGZIP(body);
headers.put(HttpDefs.CONTENT_ENCODING, "gzip");
}
return sendAndReceive(method, uri, headers, entity);
} | [
"public",
"RESTResponse",
"sendRequest",
"(",
"HttpMethod",
"method",
",",
"String",
"uri",
",",
"Map",
"<",
"String",
",",
"String",
">",
"headers",
",",
"byte",
"[",
"]",
"body",
")",
"throws",
"IOException",
"{",
"// Compress body using GZIP and add a content-encoding header if compression is requested.\r",
"byte",
"[",
"]",
"entity",
"=",
"body",
";",
"if",
"(",
"m_bCompress",
"&&",
"body",
"!=",
"null",
"&&",
"body",
".",
"length",
">",
"0",
")",
"{",
"entity",
"=",
"Utils",
".",
"compressGZIP",
"(",
"body",
")",
";",
"headers",
".",
"put",
"(",
"HttpDefs",
".",
"CONTENT_ENCODING",
",",
"\"gzip\"",
")",
";",
"}",
"return",
"sendAndReceive",
"(",
"method",
",",
"uri",
",",
"headers",
",",
"entity",
")",
";",
"}"
] | Send a REST command with the given method, URI, headers, and body to the
server and return the response in a {@link RESTResponse} object.
@param method HTTP method such as "GET" or "POST".
@param uri URI such as "/foo/bar?baz"
@param headers Headers to be included in the request, including content-type
if a body is included. Content-type is set automatically.
@param body Input entity to send with request in binary.
@return {@link RESTResponse} containing response from server.
@throws IOException If an error occurs on the socket. | [
"Send",
"a",
"REST",
"command",
"with",
"the",
"given",
"method",
"URI",
"headers",
"and",
"body",
"to",
"the",
"server",
"and",
"return",
"the",
"response",
"in",
"a",
"{",
"@link",
"RESTResponse",
"}",
"object",
"."
] | train | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/RESTClient.java#L282-L292 |
rometools/rome | rome/src/main/java/com/rometools/rome/io/impl/DateParser.java | DateParser.parseUsingMask | private static Date parseUsingMask(final String[] masks, String sDate, final Locale locale) {
"""
Parses a Date out of a string using an array of masks.
<p/>
It uses the masks in order until one of them succedes or all fail.
<p/>
@param masks array of masks to use for parsing the string
@param sDate string to parse for a date.
@return the Date represented by the given string using one of the given masks. It returns
<b>null</b> if it was not possible to parse the the string with any of the masks.
"""
if (sDate != null) {
sDate = sDate.trim();
}
ParsePosition pp = null;
Date d = null;
for (int i = 0; d == null && i < masks.length; i++) {
final DateFormat df = new SimpleDateFormat(masks[i], locale);
// df.setLenient(false);
df.setLenient(true);
try {
pp = new ParsePosition(0);
d = df.parse(sDate, pp);
if (pp.getIndex() != sDate.length()) {
d = null;
}
} catch (final Exception ex1) {
}
}
return d;
} | java | private static Date parseUsingMask(final String[] masks, String sDate, final Locale locale) {
if (sDate != null) {
sDate = sDate.trim();
}
ParsePosition pp = null;
Date d = null;
for (int i = 0; d == null && i < masks.length; i++) {
final DateFormat df = new SimpleDateFormat(masks[i], locale);
// df.setLenient(false);
df.setLenient(true);
try {
pp = new ParsePosition(0);
d = df.parse(sDate, pp);
if (pp.getIndex() != sDate.length()) {
d = null;
}
} catch (final Exception ex1) {
}
}
return d;
} | [
"private",
"static",
"Date",
"parseUsingMask",
"(",
"final",
"String",
"[",
"]",
"masks",
",",
"String",
"sDate",
",",
"final",
"Locale",
"locale",
")",
"{",
"if",
"(",
"sDate",
"!=",
"null",
")",
"{",
"sDate",
"=",
"sDate",
".",
"trim",
"(",
")",
";",
"}",
"ParsePosition",
"pp",
"=",
"null",
";",
"Date",
"d",
"=",
"null",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"d",
"==",
"null",
"&&",
"i",
"<",
"masks",
".",
"length",
";",
"i",
"++",
")",
"{",
"final",
"DateFormat",
"df",
"=",
"new",
"SimpleDateFormat",
"(",
"masks",
"[",
"i",
"]",
",",
"locale",
")",
";",
"// df.setLenient(false);",
"df",
".",
"setLenient",
"(",
"true",
")",
";",
"try",
"{",
"pp",
"=",
"new",
"ParsePosition",
"(",
"0",
")",
";",
"d",
"=",
"df",
".",
"parse",
"(",
"sDate",
",",
"pp",
")",
";",
"if",
"(",
"pp",
".",
"getIndex",
"(",
")",
"!=",
"sDate",
".",
"length",
"(",
")",
")",
"{",
"d",
"=",
"null",
";",
"}",
"}",
"catch",
"(",
"final",
"Exception",
"ex1",
")",
"{",
"}",
"}",
"return",
"d",
";",
"}"
] | Parses a Date out of a string using an array of masks.
<p/>
It uses the masks in order until one of them succedes or all fail.
<p/>
@param masks array of masks to use for parsing the string
@param sDate string to parse for a date.
@return the Date represented by the given string using one of the given masks. It returns
<b>null</b> if it was not possible to parse the the string with any of the masks. | [
"Parses",
"a",
"Date",
"out",
"of",
"a",
"string",
"using",
"an",
"array",
"of",
"masks",
".",
"<p",
"/",
">",
"It",
"uses",
"the",
"masks",
"in",
"order",
"until",
"one",
"of",
"them",
"succedes",
"or",
"all",
"fail",
".",
"<p",
"/",
">"
] | train | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome/src/main/java/com/rometools/rome/io/impl/DateParser.java#L100-L120 |
bluelinelabs/Conductor | demo/src/main/java/com/bluelinelabs/conductor/demo/util/AnimUtils.java | AnimUtils.createIntProperty | public static <T> Property<T, Integer> createIntProperty(final IntProp<T> impl) {
"""
The animation framework has an optimization for <code>Properties</code> of type
<code>int</code> but it was only made public in API24, so wrap the impl in our own type
and conditionally create the appropriate type, delegating the implementation.
"""
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
return new IntProperty<T>(impl.name) {
@Override
public Integer get(T object) {
return impl.get(object);
}
@Override
public void setValue(T object, int value) {
impl.set(object, value);
}
};
} else {
return new Property<T, Integer>(Integer.class, impl.name) {
@Override
public Integer get(T object) {
return impl.get(object);
}
@Override
public void set(T object, Integer value) {
impl.set(object, value);
}
};
}
} | java | public static <T> Property<T, Integer> createIntProperty(final IntProp<T> impl) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
return new IntProperty<T>(impl.name) {
@Override
public Integer get(T object) {
return impl.get(object);
}
@Override
public void setValue(T object, int value) {
impl.set(object, value);
}
};
} else {
return new Property<T, Integer>(Integer.class, impl.name) {
@Override
public Integer get(T object) {
return impl.get(object);
}
@Override
public void set(T object, Integer value) {
impl.set(object, value);
}
};
}
} | [
"public",
"static",
"<",
"T",
">",
"Property",
"<",
"T",
",",
"Integer",
">",
"createIntProperty",
"(",
"final",
"IntProp",
"<",
"T",
">",
"impl",
")",
"{",
"if",
"(",
"Build",
".",
"VERSION",
".",
"SDK_INT",
">=",
"Build",
".",
"VERSION_CODES",
".",
"N",
")",
"{",
"return",
"new",
"IntProperty",
"<",
"T",
">",
"(",
"impl",
".",
"name",
")",
"{",
"@",
"Override",
"public",
"Integer",
"get",
"(",
"T",
"object",
")",
"{",
"return",
"impl",
".",
"get",
"(",
"object",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"setValue",
"(",
"T",
"object",
",",
"int",
"value",
")",
"{",
"impl",
".",
"set",
"(",
"object",
",",
"value",
")",
";",
"}",
"}",
";",
"}",
"else",
"{",
"return",
"new",
"Property",
"<",
"T",
",",
"Integer",
">",
"(",
"Integer",
".",
"class",
",",
"impl",
".",
"name",
")",
"{",
"@",
"Override",
"public",
"Integer",
"get",
"(",
"T",
"object",
")",
"{",
"return",
"impl",
".",
"get",
"(",
"object",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"set",
"(",
"T",
"object",
",",
"Integer",
"value",
")",
"{",
"impl",
".",
"set",
"(",
"object",
",",
"value",
")",
";",
"}",
"}",
";",
"}",
"}"
] | The animation framework has an optimization for <code>Properties</code> of type
<code>int</code> but it was only made public in API24, so wrap the impl in our own type
and conditionally create the appropriate type, delegating the implementation. | [
"The",
"animation",
"framework",
"has",
"an",
"optimization",
"for",
"<code",
">",
"Properties<",
"/",
"code",
">",
"of",
"type",
"<code",
">",
"int<",
"/",
"code",
">",
"but",
"it",
"was",
"only",
"made",
"public",
"in",
"API24",
"so",
"wrap",
"the",
"impl",
"in",
"our",
"own",
"type",
"and",
"conditionally",
"create",
"the",
"appropriate",
"type",
"delegating",
"the",
"implementation",
"."
] | train | https://github.com/bluelinelabs/Conductor/blob/94c9121bb16f93b481954513a8e3905846829fb2/demo/src/main/java/com/bluelinelabs/conductor/demo/util/AnimUtils.java#L109-L135 |
JOML-CI/JOML | src/org/joml/Matrix3x2d.java | Matrix3x2d.scaleAround | public Matrix3x2d scaleAround(double sx, double sy, double ox, double oy) {
"""
Apply scaling to this matrix by scaling the base axes by the given sx and
sy factors while using <code>(ox, oy)</code> as the scaling origin.
<p>
If <code>M</code> is <code>this</code> matrix and <code>S</code> the scaling matrix,
then the new matrix will be <code>M * S</code>. So when transforming a
vector <code>v</code> with the new matrix by using <code>M * S * v</code>, the
scaling will be applied first!
<p>
This method is equivalent to calling: <code>translate(ox, oy).scale(sx, sy).translate(-ox, -oy)</code>
@param sx
the scaling factor of the x component
@param sy
the scaling factor of the y component
@param ox
the x coordinate of the scaling origin
@param oy
the y coordinate of the scaling origin
@return this
"""
return scaleAround(sx, sy, ox, oy, this);
} | java | public Matrix3x2d scaleAround(double sx, double sy, double ox, double oy) {
return scaleAround(sx, sy, ox, oy, this);
} | [
"public",
"Matrix3x2d",
"scaleAround",
"(",
"double",
"sx",
",",
"double",
"sy",
",",
"double",
"ox",
",",
"double",
"oy",
")",
"{",
"return",
"scaleAround",
"(",
"sx",
",",
"sy",
",",
"ox",
",",
"oy",
",",
"this",
")",
";",
"}"
] | Apply scaling to this matrix by scaling the base axes by the given sx and
sy factors while using <code>(ox, oy)</code> as the scaling origin.
<p>
If <code>M</code> is <code>this</code> matrix and <code>S</code> the scaling matrix,
then the new matrix will be <code>M * S</code>. So when transforming a
vector <code>v</code> with the new matrix by using <code>M * S * v</code>, the
scaling will be applied first!
<p>
This method is equivalent to calling: <code>translate(ox, oy).scale(sx, sy).translate(-ox, -oy)</code>
@param sx
the scaling factor of the x component
@param sy
the scaling factor of the y component
@param ox
the x coordinate of the scaling origin
@param oy
the y coordinate of the scaling origin
@return this | [
"Apply",
"scaling",
"to",
"this",
"matrix",
"by",
"scaling",
"the",
"base",
"axes",
"by",
"the",
"given",
"sx",
"and",
"sy",
"factors",
"while",
"using",
"<code",
">",
"(",
"ox",
"oy",
")",
"<",
"/",
"code",
">",
"as",
"the",
"scaling",
"origin",
".",
"<p",
">",
"If",
"<code",
">",
"M<",
"/",
"code",
">",
"is",
"<code",
">",
"this<",
"/",
"code",
">",
"matrix",
"and",
"<code",
">",
"S<",
"/",
"code",
">",
"the",
"scaling",
"matrix",
"then",
"the",
"new",
"matrix",
"will",
"be",
"<code",
">",
"M",
"*",
"S<",
"/",
"code",
">",
".",
"So",
"when",
"transforming",
"a",
"vector",
"<code",
">",
"v<",
"/",
"code",
">",
"with",
"the",
"new",
"matrix",
"by",
"using",
"<code",
">",
"M",
"*",
"S",
"*",
"v<",
"/",
"code",
">",
"the",
"scaling",
"will",
"be",
"applied",
"first!",
"<p",
">",
"This",
"method",
"is",
"equivalent",
"to",
"calling",
":",
"<code",
">",
"translate",
"(",
"ox",
"oy",
")",
".",
"scale",
"(",
"sx",
"sy",
")",
".",
"translate",
"(",
"-",
"ox",
"-",
"oy",
")",
"<",
"/",
"code",
">"
] | train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Matrix3x2d.java#L1464-L1466 |
agmip/translator-dssat | src/main/java/org/agmip/translators/dssat/DssatControllerOutput.java | DssatControllerOutput.recordSWData | private void recordSWData(Map expData, DssatCommonOutput output) {
"""
write soil/weather files
@param expData The holder for experiment data include soil/weather data
@param output The DSSAT Writer object
"""
String id;
HashMap<String, Map> swData;
try {
if (output instanceof DssatSoilOutput) {
Map soilTmp = getObjectOr(expData, "soil", new HashMap());
if (soilTmp.isEmpty()) {
id = getObjectOr(expData, "soil_id", "");
} else {
id = soilHelper.getSoilID(soilTmp);
}
// id = id.substring(0, 2);
swData = soilData;
expData.put("soil_id", id);
} else {
// id = getObjectOr(expData, "wst_id", "");
// id = getWthFileName(getObjectOr(expData, "weather", new HashMap()));
Map wthTmp = getObjectOr(expData, "weather", new HashMap());
if (wthTmp.isEmpty()) {
id = getObjectOr(expData, "wst_id", "");
} else {
id = wthHelper.createWthFileName(wthTmp);
}
swData = wthData;
expData.put("wst_id", id);
}
if (!id.equals("") && !swData.containsKey(id)) {
swData.put(id, expData);
// Future fut = executor.submit(new DssatTranslateRunner(output, expData, arg0));
// swfiles.put(id, fut);
// futFiles.add(fut);
}
} catch (Exception e) {
LOG.error(getStackTrace(e));
}
} | java | private void recordSWData(Map expData, DssatCommonOutput output) {
String id;
HashMap<String, Map> swData;
try {
if (output instanceof DssatSoilOutput) {
Map soilTmp = getObjectOr(expData, "soil", new HashMap());
if (soilTmp.isEmpty()) {
id = getObjectOr(expData, "soil_id", "");
} else {
id = soilHelper.getSoilID(soilTmp);
}
// id = id.substring(0, 2);
swData = soilData;
expData.put("soil_id", id);
} else {
// id = getObjectOr(expData, "wst_id", "");
// id = getWthFileName(getObjectOr(expData, "weather", new HashMap()));
Map wthTmp = getObjectOr(expData, "weather", new HashMap());
if (wthTmp.isEmpty()) {
id = getObjectOr(expData, "wst_id", "");
} else {
id = wthHelper.createWthFileName(wthTmp);
}
swData = wthData;
expData.put("wst_id", id);
}
if (!id.equals("") && !swData.containsKey(id)) {
swData.put(id, expData);
// Future fut = executor.submit(new DssatTranslateRunner(output, expData, arg0));
// swfiles.put(id, fut);
// futFiles.add(fut);
}
} catch (Exception e) {
LOG.error(getStackTrace(e));
}
} | [
"private",
"void",
"recordSWData",
"(",
"Map",
"expData",
",",
"DssatCommonOutput",
"output",
")",
"{",
"String",
"id",
";",
"HashMap",
"<",
"String",
",",
"Map",
">",
"swData",
";",
"try",
"{",
"if",
"(",
"output",
"instanceof",
"DssatSoilOutput",
")",
"{",
"Map",
"soilTmp",
"=",
"getObjectOr",
"(",
"expData",
",",
"\"soil\"",
",",
"new",
"HashMap",
"(",
")",
")",
";",
"if",
"(",
"soilTmp",
".",
"isEmpty",
"(",
")",
")",
"{",
"id",
"=",
"getObjectOr",
"(",
"expData",
",",
"\"soil_id\"",
",",
"\"\"",
")",
";",
"}",
"else",
"{",
"id",
"=",
"soilHelper",
".",
"getSoilID",
"(",
"soilTmp",
")",
";",
"}",
"// id = id.substring(0, 2);",
"swData",
"=",
"soilData",
";",
"expData",
".",
"put",
"(",
"\"soil_id\"",
",",
"id",
")",
";",
"}",
"else",
"{",
"// id = getObjectOr(expData, \"wst_id\", \"\");",
"// id = getWthFileName(getObjectOr(expData, \"weather\", new HashMap()));",
"Map",
"wthTmp",
"=",
"getObjectOr",
"(",
"expData",
",",
"\"weather\"",
",",
"new",
"HashMap",
"(",
")",
")",
";",
"if",
"(",
"wthTmp",
".",
"isEmpty",
"(",
")",
")",
"{",
"id",
"=",
"getObjectOr",
"(",
"expData",
",",
"\"wst_id\"",
",",
"\"\"",
")",
";",
"}",
"else",
"{",
"id",
"=",
"wthHelper",
".",
"createWthFileName",
"(",
"wthTmp",
")",
";",
"}",
"swData",
"=",
"wthData",
";",
"expData",
".",
"put",
"(",
"\"wst_id\"",
",",
"id",
")",
";",
"}",
"if",
"(",
"!",
"id",
".",
"equals",
"(",
"\"\"",
")",
"&&",
"!",
"swData",
".",
"containsKey",
"(",
"id",
")",
")",
"{",
"swData",
".",
"put",
"(",
"id",
",",
"expData",
")",
";",
"// Future fut = executor.submit(new DssatTranslateRunner(output, expData, arg0));",
"// swfiles.put(id, fut);",
"// futFiles.add(fut);",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"getStackTrace",
"(",
"e",
")",
")",
";",
"}",
"}"
] | write soil/weather files
@param expData The holder for experiment data include soil/weather data
@param output The DSSAT Writer object | [
"write",
"soil",
"/",
"weather",
"files"
] | train | https://github.com/agmip/translator-dssat/blob/4be61d998f106eb7234ea8701b63c3746ae688f4/src/main/java/org/agmip/translators/dssat/DssatControllerOutput.java#L284-L319 |
mboudreau/Alternator | src/main/java/com/amazonaws/services/dynamodb/AmazonDynamoDBClient.java | AmazonDynamoDBClient.describeTable | public DescribeTableResult describeTable(DescribeTableRequest describeTableRequest)
throws AmazonServiceException, AmazonClientException {
"""
<p>
Retrieves information about the table, including the current status of
the table, the primary key schema and when the table was created.
</p>
<p>
If the table does not exist, Amazon DynamoDB returns a
<code>ResourceNotFoundException</code> .
</p>
@param describeTableRequest Container for the necessary parameters to
execute the DescribeTable service method on AmazonDynamoDB.
@return The response from the DescribeTable service method, as
returned by AmazonDynamoDB.
@throws InternalServerErrorException
@throws ResourceNotFoundException
@throws AmazonClientException
If any internal errors are encountered inside the client while
attempting to make the request or handle the response. For example
if a network connection is not available.
@throws AmazonServiceException
If an error response is returned by AmazonDynamoDB indicating
either a problem with the data in the request, or a server side issue.
"""
ExecutionContext executionContext = createExecutionContext(describeTableRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
Request<DescribeTableRequest> request = marshall(describeTableRequest,
new DescribeTableRequestMarshaller(),
executionContext.getAwsRequestMetrics());
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
Unmarshaller<DescribeTableResult, JsonUnmarshallerContext> unmarshaller = new DescribeTableResultJsonUnmarshaller();
JsonResponseHandler<DescribeTableResult> responseHandler = new JsonResponseHandler<DescribeTableResult>(unmarshaller);
return invoke(request, responseHandler, executionContext);
} | java | public DescribeTableResult describeTable(DescribeTableRequest describeTableRequest)
throws AmazonServiceException, AmazonClientException {
ExecutionContext executionContext = createExecutionContext(describeTableRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
Request<DescribeTableRequest> request = marshall(describeTableRequest,
new DescribeTableRequestMarshaller(),
executionContext.getAwsRequestMetrics());
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
Unmarshaller<DescribeTableResult, JsonUnmarshallerContext> unmarshaller = new DescribeTableResultJsonUnmarshaller();
JsonResponseHandler<DescribeTableResult> responseHandler = new JsonResponseHandler<DescribeTableResult>(unmarshaller);
return invoke(request, responseHandler, executionContext);
} | [
"public",
"DescribeTableResult",
"describeTable",
"(",
"DescribeTableRequest",
"describeTableRequest",
")",
"throws",
"AmazonServiceException",
",",
"AmazonClientException",
"{",
"ExecutionContext",
"executionContext",
"=",
"createExecutionContext",
"(",
"describeTableRequest",
")",
";",
"AWSRequestMetrics",
"awsRequestMetrics",
"=",
"executionContext",
".",
"getAwsRequestMetrics",
"(",
")",
";",
"Request",
"<",
"DescribeTableRequest",
">",
"request",
"=",
"marshall",
"(",
"describeTableRequest",
",",
"new",
"DescribeTableRequestMarshaller",
"(",
")",
",",
"executionContext",
".",
"getAwsRequestMetrics",
"(",
")",
")",
";",
"// Binds the request metrics to the current request.",
"request",
".",
"setAWSRequestMetrics",
"(",
"awsRequestMetrics",
")",
";",
"Unmarshaller",
"<",
"DescribeTableResult",
",",
"JsonUnmarshallerContext",
">",
"unmarshaller",
"=",
"new",
"DescribeTableResultJsonUnmarshaller",
"(",
")",
";",
"JsonResponseHandler",
"<",
"DescribeTableResult",
">",
"responseHandler",
"=",
"new",
"JsonResponseHandler",
"<",
"DescribeTableResult",
">",
"(",
"unmarshaller",
")",
";",
"return",
"invoke",
"(",
"request",
",",
"responseHandler",
",",
"executionContext",
")",
";",
"}"
] | <p>
Retrieves information about the table, including the current status of
the table, the primary key schema and when the table was created.
</p>
<p>
If the table does not exist, Amazon DynamoDB returns a
<code>ResourceNotFoundException</code> .
</p>
@param describeTableRequest Container for the necessary parameters to
execute the DescribeTable service method on AmazonDynamoDB.
@return The response from the DescribeTable service method, as
returned by AmazonDynamoDB.
@throws InternalServerErrorException
@throws ResourceNotFoundException
@throws AmazonClientException
If any internal errors are encountered inside the client while
attempting to make the request or handle the response. For example
if a network connection is not available.
@throws AmazonServiceException
If an error response is returned by AmazonDynamoDB indicating
either a problem with the data in the request, or a server side issue. | [
"<p",
">",
"Retrieves",
"information",
"about",
"the",
"table",
"including",
"the",
"current",
"status",
"of",
"the",
"table",
"the",
"primary",
"key",
"schema",
"and",
"when",
"the",
"table",
"was",
"created",
".",
"<",
"/",
"p",
">",
"<p",
">",
"If",
"the",
"table",
"does",
"not",
"exist",
"Amazon",
"DynamoDB",
"returns",
"a",
"<code",
">",
"ResourceNotFoundException<",
"/",
"code",
">",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/mboudreau/Alternator/blob/4b230ac843494cb10e46ddc2848f5b5d377d7b72/src/main/java/com/amazonaws/services/dynamodb/AmazonDynamoDBClient.java#L589-L601 |
liyiorg/weixin-popular | src/main/java/weixin/popular/api/SnsAPI.java | SnsAPI.auth | public static BaseResult auth(String access_token,String openid) {
"""
检验授权凭证(access_token)是否有效
@since 2.8.1
@param access_token access_token
@param openid openid
@return result
"""
HttpUriRequest httpUriRequest = RequestBuilder.get()
.setUri(BASE_URI + "/sns/auth")
.addParameter(PARAM_ACCESS_TOKEN, API.accessToken(access_token))
.addParameter("openid", openid)
.build();
return LocalHttpClient.executeJsonResult(httpUriRequest,BaseResult.class);
} | java | public static BaseResult auth(String access_token,String openid){
HttpUriRequest httpUriRequest = RequestBuilder.get()
.setUri(BASE_URI + "/sns/auth")
.addParameter(PARAM_ACCESS_TOKEN, API.accessToken(access_token))
.addParameter("openid", openid)
.build();
return LocalHttpClient.executeJsonResult(httpUriRequest,BaseResult.class);
} | [
"public",
"static",
"BaseResult",
"auth",
"(",
"String",
"access_token",
",",
"String",
"openid",
")",
"{",
"HttpUriRequest",
"httpUriRequest",
"=",
"RequestBuilder",
".",
"get",
"(",
")",
".",
"setUri",
"(",
"BASE_URI",
"+",
"\"/sns/auth\"",
")",
".",
"addParameter",
"(",
"PARAM_ACCESS_TOKEN",
",",
"API",
".",
"accessToken",
"(",
"access_token",
")",
")",
".",
"addParameter",
"(",
"\"openid\"",
",",
"openid",
")",
".",
"build",
"(",
")",
";",
"return",
"LocalHttpClient",
".",
"executeJsonResult",
"(",
"httpUriRequest",
",",
"BaseResult",
".",
"class",
")",
";",
"}"
] | 检验授权凭证(access_token)是否有效
@since 2.8.1
@param access_token access_token
@param openid openid
@return result | [
"检验授权凭证(access_token)是否有效"
] | train | https://github.com/liyiorg/weixin-popular/blob/c64255292d41463bdb671938feaabf42a335d82c/src/main/java/weixin/popular/api/SnsAPI.java#L110-L117 |
twitter/hraven | hraven-core/src/main/java/com/twitter/hraven/datasource/AppSummaryService.java | AppSummaryService.getTimestamp | long getTimestamp(long runId, AggregationConstants.AGGREGATION_TYPE aggType) {
"""
find out the top of the day/week timestamp
@param runId
@return top of the day/week timestamp
"""
if (AggregationConstants.AGGREGATION_TYPE.DAILY.equals(aggType)) {
// get top of the hour
long dayTimestamp = runId - (runId % Constants.MILLIS_ONE_DAY);
return dayTimestamp;
} else if (AggregationConstants.AGGREGATION_TYPE.WEEKLY.equals(aggType)) {
// get top of the hour
Calendar c = Calendar.getInstance();
c.setTimeInMillis(runId);
int d = c.get(Calendar.DAY_OF_WEEK);
// get the first day of the week
long weekTimestamp = runId - (d - 1) * Constants.MILLIS_ONE_DAY;
// get the top of the day for that first day
weekTimestamp = weekTimestamp - weekTimestamp % Constants.MILLIS_ONE_DAY;
return weekTimestamp;
}
return 0L;
} | java | long getTimestamp(long runId, AggregationConstants.AGGREGATION_TYPE aggType) {
if (AggregationConstants.AGGREGATION_TYPE.DAILY.equals(aggType)) {
// get top of the hour
long dayTimestamp = runId - (runId % Constants.MILLIS_ONE_DAY);
return dayTimestamp;
} else if (AggregationConstants.AGGREGATION_TYPE.WEEKLY.equals(aggType)) {
// get top of the hour
Calendar c = Calendar.getInstance();
c.setTimeInMillis(runId);
int d = c.get(Calendar.DAY_OF_WEEK);
// get the first day of the week
long weekTimestamp = runId - (d - 1) * Constants.MILLIS_ONE_DAY;
// get the top of the day for that first day
weekTimestamp = weekTimestamp - weekTimestamp % Constants.MILLIS_ONE_DAY;
return weekTimestamp;
}
return 0L;
} | [
"long",
"getTimestamp",
"(",
"long",
"runId",
",",
"AggregationConstants",
".",
"AGGREGATION_TYPE",
"aggType",
")",
"{",
"if",
"(",
"AggregationConstants",
".",
"AGGREGATION_TYPE",
".",
"DAILY",
".",
"equals",
"(",
"aggType",
")",
")",
"{",
"// get top of the hour",
"long",
"dayTimestamp",
"=",
"runId",
"-",
"(",
"runId",
"%",
"Constants",
".",
"MILLIS_ONE_DAY",
")",
";",
"return",
"dayTimestamp",
";",
"}",
"else",
"if",
"(",
"AggregationConstants",
".",
"AGGREGATION_TYPE",
".",
"WEEKLY",
".",
"equals",
"(",
"aggType",
")",
")",
"{",
"// get top of the hour",
"Calendar",
"c",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"c",
".",
"setTimeInMillis",
"(",
"runId",
")",
";",
"int",
"d",
"=",
"c",
".",
"get",
"(",
"Calendar",
".",
"DAY_OF_WEEK",
")",
";",
"// get the first day of the week",
"long",
"weekTimestamp",
"=",
"runId",
"-",
"(",
"d",
"-",
"1",
")",
"*",
"Constants",
".",
"MILLIS_ONE_DAY",
";",
"// get the top of the day for that first day",
"weekTimestamp",
"=",
"weekTimestamp",
"-",
"weekTimestamp",
"%",
"Constants",
".",
"MILLIS_ONE_DAY",
";",
"return",
"weekTimestamp",
";",
"}",
"return",
"0L",
";",
"}"
] | find out the top of the day/week timestamp
@param runId
@return top of the day/week timestamp | [
"find",
"out",
"the",
"top",
"of",
"the",
"day",
"/",
"week",
"timestamp"
] | train | https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-core/src/main/java/com/twitter/hraven/datasource/AppSummaryService.java#L366-L383 |
Azure/azure-sdk-for-java | labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/OperationsInner.java | OperationsInner.getAsync | public Observable<OperationResultInner> getAsync(String locationName, String operationName) {
"""
Get operation.
@param locationName The name of the location.
@param operationName The name of the operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the OperationResultInner object
"""
return getWithServiceResponseAsync(locationName, operationName).map(new Func1<ServiceResponse<OperationResultInner>, OperationResultInner>() {
@Override
public OperationResultInner call(ServiceResponse<OperationResultInner> response) {
return response.body();
}
});
} | java | public Observable<OperationResultInner> getAsync(String locationName, String operationName) {
return getWithServiceResponseAsync(locationName, operationName).map(new Func1<ServiceResponse<OperationResultInner>, OperationResultInner>() {
@Override
public OperationResultInner call(ServiceResponse<OperationResultInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"OperationResultInner",
">",
"getAsync",
"(",
"String",
"locationName",
",",
"String",
"operationName",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"locationName",
",",
"operationName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"OperationResultInner",
">",
",",
"OperationResultInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"OperationResultInner",
"call",
"(",
"ServiceResponse",
"<",
"OperationResultInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Get operation.
@param locationName The name of the location.
@param operationName The name of the operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the OperationResultInner object | [
"Get",
"operation",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/OperationsInner.java#L95-L102 |
google/j2objc | jre_emul/android/platform/libcore/xml/src/main/java/org/kxml2/io/KXmlParser.java | KXmlParser.pushContentSource | private void pushContentSource(char[] newBuffer) {
"""
Prepends the characters of {@code newBuffer} to be read before the
current buffer.
"""
nextContentSource = new ContentSource(nextContentSource, buffer, position, limit);
buffer = newBuffer;
position = 0;
limit = newBuffer.length;
} | java | private void pushContentSource(char[] newBuffer) {
nextContentSource = new ContentSource(nextContentSource, buffer, position, limit);
buffer = newBuffer;
position = 0;
limit = newBuffer.length;
} | [
"private",
"void",
"pushContentSource",
"(",
"char",
"[",
"]",
"newBuffer",
")",
"{",
"nextContentSource",
"=",
"new",
"ContentSource",
"(",
"nextContentSource",
",",
"buffer",
",",
"position",
",",
"limit",
")",
";",
"buffer",
"=",
"newBuffer",
";",
"position",
"=",
"0",
";",
"limit",
"=",
"newBuffer",
".",
"length",
";",
"}"
] | Prepends the characters of {@code newBuffer} to be read before the
current buffer. | [
"Prepends",
"the",
"characters",
"of",
"{"
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/xml/src/main/java/org/kxml2/io/KXmlParser.java#L2162-L2167 |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/main/JavaCompiler.java | JavaCompiler.printSource | JavaFileObject printSource(Env<AttrContext> env, JCClassDecl cdef) throws IOException {
"""
Emit plain Java source for a class.
@param env The attribution environment of the outermost class
containing this class.
@param cdef The class definition to be printed.
"""
JavaFileObject outFile
= fileManager.getJavaFileForOutput(CLASS_OUTPUT,
cdef.sym.flatname.toString(),
JavaFileObject.Kind.SOURCE,
null);
if (inputFiles.contains(outFile)) {
log.error(cdef.pos(), "source.cant.overwrite.input.file", outFile);
return null;
} else {
BufferedWriter out = new BufferedWriter(outFile.openWriter());
try {
new Pretty(out, true).printUnit(env.toplevel, cdef);
if (verbose)
log.printVerbose("wrote.file", outFile);
} finally {
out.close();
}
return outFile;
}
} | java | JavaFileObject printSource(Env<AttrContext> env, JCClassDecl cdef) throws IOException {
JavaFileObject outFile
= fileManager.getJavaFileForOutput(CLASS_OUTPUT,
cdef.sym.flatname.toString(),
JavaFileObject.Kind.SOURCE,
null);
if (inputFiles.contains(outFile)) {
log.error(cdef.pos(), "source.cant.overwrite.input.file", outFile);
return null;
} else {
BufferedWriter out = new BufferedWriter(outFile.openWriter());
try {
new Pretty(out, true).printUnit(env.toplevel, cdef);
if (verbose)
log.printVerbose("wrote.file", outFile);
} finally {
out.close();
}
return outFile;
}
} | [
"JavaFileObject",
"printSource",
"(",
"Env",
"<",
"AttrContext",
">",
"env",
",",
"JCClassDecl",
"cdef",
")",
"throws",
"IOException",
"{",
"JavaFileObject",
"outFile",
"=",
"fileManager",
".",
"getJavaFileForOutput",
"(",
"CLASS_OUTPUT",
",",
"cdef",
".",
"sym",
".",
"flatname",
".",
"toString",
"(",
")",
",",
"JavaFileObject",
".",
"Kind",
".",
"SOURCE",
",",
"null",
")",
";",
"if",
"(",
"inputFiles",
".",
"contains",
"(",
"outFile",
")",
")",
"{",
"log",
".",
"error",
"(",
"cdef",
".",
"pos",
"(",
")",
",",
"\"source.cant.overwrite.input.file\"",
",",
"outFile",
")",
";",
"return",
"null",
";",
"}",
"else",
"{",
"BufferedWriter",
"out",
"=",
"new",
"BufferedWriter",
"(",
"outFile",
".",
"openWriter",
"(",
")",
")",
";",
"try",
"{",
"new",
"Pretty",
"(",
"out",
",",
"true",
")",
".",
"printUnit",
"(",
"env",
".",
"toplevel",
",",
"cdef",
")",
";",
"if",
"(",
"verbose",
")",
"log",
".",
"printVerbose",
"(",
"\"wrote.file\"",
",",
"outFile",
")",
";",
"}",
"finally",
"{",
"out",
".",
"close",
"(",
")",
";",
"}",
"return",
"outFile",
";",
"}",
"}"
] | Emit plain Java source for a class.
@param env The attribution environment of the outermost class
containing this class.
@param cdef The class definition to be printed. | [
"Emit",
"plain",
"Java",
"source",
"for",
"a",
"class",
"."
] | train | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java#L716-L736 |
GenesysPureEngage/workspace-client-java | src/main/java/com/genesys/workspace/VoiceApi.java | VoiceApi.initiateConference | public void initiateConference(String connId, String destination) throws WorkspaceApiException {
"""
Initiate a two-step conference to the specified destination. This places the existing call on
hold and creates a new call in the dialing state (step 1). After initiating the conference you can use
`completeConference()` to complete the conference and bring all parties into the same call (step 2).
@param connId The connection ID of the call to start the conference from. This call will be placed on hold.
@param destination The number to be dialed.
"""
this.initiateConference(connId, destination, null, null, null, null, null);
} | java | public void initiateConference(String connId, String destination) throws WorkspaceApiException {
this.initiateConference(connId, destination, null, null, null, null, null);
} | [
"public",
"void",
"initiateConference",
"(",
"String",
"connId",
",",
"String",
"destination",
")",
"throws",
"WorkspaceApiException",
"{",
"this",
".",
"initiateConference",
"(",
"connId",
",",
"destination",
",",
"null",
",",
"null",
",",
"null",
",",
"null",
",",
"null",
")",
";",
"}"
] | Initiate a two-step conference to the specified destination. This places the existing call on
hold and creates a new call in the dialing state (step 1). After initiating the conference you can use
`completeConference()` to complete the conference and bring all parties into the same call (step 2).
@param connId The connection ID of the call to start the conference from. This call will be placed on hold.
@param destination The number to be dialed. | [
"Initiate",
"a",
"two",
"-",
"step",
"conference",
"to",
"the",
"specified",
"destination",
".",
"This",
"places",
"the",
"existing",
"call",
"on",
"hold",
"and",
"creates",
"a",
"new",
"call",
"in",
"the",
"dialing",
"state",
"(",
"step",
"1",
")",
".",
"After",
"initiating",
"the",
"conference",
"you",
"can",
"use",
"completeConference",
"()",
"to",
"complete",
"the",
"conference",
"and",
"bring",
"all",
"parties",
"into",
"the",
"same",
"call",
"(",
"step",
"2",
")",
"."
] | train | https://github.com/GenesysPureEngage/workspace-client-java/blob/509fdd9e89b9359d012f9a72be95037a3cef53e6/src/main/java/com/genesys/workspace/VoiceApi.java#L663-L665 |
UrielCh/ovh-java-sdk | ovh-java-sdk-ipLoadbalancing/src/main/java/net/minidev/ovh/api/ApiOvhIpLoadbalancing.java | ApiOvhIpLoadbalancing.serviceName_udp_farm_farmId_PUT | public void serviceName_udp_farm_farmId_PUT(String serviceName, Long farmId, OvhBackendUdp body) throws IOException {
"""
Alter this object properties
REST: PUT /ipLoadbalancing/{serviceName}/udp/farm/{farmId}
@param body [required] New object properties
@param serviceName [required] The internal name of your IP load balancing
@param farmId [required] Id of your farm
API beta
"""
String qPath = "/ipLoadbalancing/{serviceName}/udp/farm/{farmId}";
StringBuilder sb = path(qPath, serviceName, farmId);
exec(qPath, "PUT", sb.toString(), body);
} | java | public void serviceName_udp_farm_farmId_PUT(String serviceName, Long farmId, OvhBackendUdp body) throws IOException {
String qPath = "/ipLoadbalancing/{serviceName}/udp/farm/{farmId}";
StringBuilder sb = path(qPath, serviceName, farmId);
exec(qPath, "PUT", sb.toString(), body);
} | [
"public",
"void",
"serviceName_udp_farm_farmId_PUT",
"(",
"String",
"serviceName",
",",
"Long",
"farmId",
",",
"OvhBackendUdp",
"body",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/ipLoadbalancing/{serviceName}/udp/farm/{farmId}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"farmId",
")",
";",
"exec",
"(",
"qPath",
",",
"\"PUT\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"body",
")",
";",
"}"
] | Alter this object properties
REST: PUT /ipLoadbalancing/{serviceName}/udp/farm/{farmId}
@param body [required] New object properties
@param serviceName [required] The internal name of your IP load balancing
@param farmId [required] Id of your farm
API beta | [
"Alter",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-ipLoadbalancing/src/main/java/net/minidev/ovh/api/ApiOvhIpLoadbalancing.java#L912-L916 |
konmik/solid | streams/src/main/java/solid/stream/Stream.java | Stream.distinct | public Stream<T> distinct() {
"""
Returns a new stream that filters out duplicate items off the current stream.
<p/>
This operator keeps a list of all items that has been passed to
compare it against next items.
@return a new stream that filters out duplicate items off the current stream.
"""
final ArrayList<T> passed = new ArrayList<>();
return filter(new Func1<T, Boolean>() {
@Override
public Boolean call(T value) {
if (passed.contains(value))
return false;
passed.add(value);
return true;
}
});
} | java | public Stream<T> distinct() {
final ArrayList<T> passed = new ArrayList<>();
return filter(new Func1<T, Boolean>() {
@Override
public Boolean call(T value) {
if (passed.contains(value))
return false;
passed.add(value);
return true;
}
});
} | [
"public",
"Stream",
"<",
"T",
">",
"distinct",
"(",
")",
"{",
"final",
"ArrayList",
"<",
"T",
">",
"passed",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"return",
"filter",
"(",
"new",
"Func1",
"<",
"T",
",",
"Boolean",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Boolean",
"call",
"(",
"T",
"value",
")",
"{",
"if",
"(",
"passed",
".",
"contains",
"(",
"value",
")",
")",
"return",
"false",
";",
"passed",
".",
"add",
"(",
"value",
")",
";",
"return",
"true",
";",
"}",
"}",
")",
";",
"}"
] | Returns a new stream that filters out duplicate items off the current stream.
<p/>
This operator keeps a list of all items that has been passed to
compare it against next items.
@return a new stream that filters out duplicate items off the current stream. | [
"Returns",
"a",
"new",
"stream",
"that",
"filters",
"out",
"duplicate",
"items",
"off",
"the",
"current",
"stream",
".",
"<p",
"/",
">",
"This",
"operator",
"keeps",
"a",
"list",
"of",
"all",
"items",
"that",
"has",
"been",
"passed",
"to",
"compare",
"it",
"against",
"next",
"items",
"."
] | train | https://github.com/konmik/solid/blob/3d6c452ef3219fd843547f3590b3d2e1ad3f1d17/streams/src/main/java/solid/stream/Stream.java#L482-L493 |
fuinorg/objects4j | src/main/java/org/fuin/objects4j/vo/LocaleStrValidator.java | LocaleStrValidator.isValid | public static final boolean isValid(final String value) {
"""
Check that a given string is a valid {@link java.util.Locale}.
@param value
Value to check.
@return Returns <code>true</code> if it's a valid Localed else <code>false</code> is returned.
"""
if (value == null) {
return true;
}
final Locale locale;
final int p = value.indexOf("__");
if (p > -1) {
locale = new Locale(value.substring(0, p), null, value.substring(p + 2));
} else {
final StringTokenizer tok = new StringTokenizer(value, "_");
if (tok.countTokens() == 1) {
locale = new Locale(value);
} else if (tok.countTokens() == 2) {
locale = new Locale(tok.nextToken(), tok.nextToken());
} else if (tok.countTokens() == 3) {
locale = new Locale(tok.nextToken(), tok.nextToken(), tok.nextToken());
} else {
return false;
}
}
return LocaleConverter.validLocale(locale);
} | java | public static final boolean isValid(final String value) {
if (value == null) {
return true;
}
final Locale locale;
final int p = value.indexOf("__");
if (p > -1) {
locale = new Locale(value.substring(0, p), null, value.substring(p + 2));
} else {
final StringTokenizer tok = new StringTokenizer(value, "_");
if (tok.countTokens() == 1) {
locale = new Locale(value);
} else if (tok.countTokens() == 2) {
locale = new Locale(tok.nextToken(), tok.nextToken());
} else if (tok.countTokens() == 3) {
locale = new Locale(tok.nextToken(), tok.nextToken(), tok.nextToken());
} else {
return false;
}
}
return LocaleConverter.validLocale(locale);
} | [
"public",
"static",
"final",
"boolean",
"isValid",
"(",
"final",
"String",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"final",
"Locale",
"locale",
";",
"final",
"int",
"p",
"=",
"value",
".",
"indexOf",
"(",
"\"__\"",
")",
";",
"if",
"(",
"p",
">",
"-",
"1",
")",
"{",
"locale",
"=",
"new",
"Locale",
"(",
"value",
".",
"substring",
"(",
"0",
",",
"p",
")",
",",
"null",
",",
"value",
".",
"substring",
"(",
"p",
"+",
"2",
")",
")",
";",
"}",
"else",
"{",
"final",
"StringTokenizer",
"tok",
"=",
"new",
"StringTokenizer",
"(",
"value",
",",
"\"_\"",
")",
";",
"if",
"(",
"tok",
".",
"countTokens",
"(",
")",
"==",
"1",
")",
"{",
"locale",
"=",
"new",
"Locale",
"(",
"value",
")",
";",
"}",
"else",
"if",
"(",
"tok",
".",
"countTokens",
"(",
")",
"==",
"2",
")",
"{",
"locale",
"=",
"new",
"Locale",
"(",
"tok",
".",
"nextToken",
"(",
")",
",",
"tok",
".",
"nextToken",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"tok",
".",
"countTokens",
"(",
")",
"==",
"3",
")",
"{",
"locale",
"=",
"new",
"Locale",
"(",
"tok",
".",
"nextToken",
"(",
")",
",",
"tok",
".",
"nextToken",
"(",
")",
",",
"tok",
".",
"nextToken",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"LocaleConverter",
".",
"validLocale",
"(",
"locale",
")",
";",
"}"
] | Check that a given string is a valid {@link java.util.Locale}.
@param value
Value to check.
@return Returns <code>true</code> if it's a valid Localed else <code>false</code> is returned. | [
"Check",
"that",
"a",
"given",
"string",
"is",
"a",
"valid",
"{",
"@link",
"java",
".",
"util",
".",
"Locale",
"}",
"."
] | train | https://github.com/fuinorg/objects4j/blob/e7f278b5bae073ebb6a76053650571c718f36246/src/main/java/org/fuin/objects4j/vo/LocaleStrValidator.java#L51-L72 |
xcesco/kripton | kripton-processor/src/main/java/com/abubusoft/kripton/processor/sqlite/ModifyBeanHelper.java | ModifyBeanHelper.generateWhereCondition | public void generateWhereCondition(MethodSpec.Builder methodBuilder, SQLiteModelMethod method, SqlAnalyzer analyzer) {
"""
Generate where condition.
@param methodBuilder
the method builder
@param method
the method
@param analyzer
the analyzer
"""
SQLiteEntity entity = method.getEntity();
String beanParamName = method.getParameters().get(0).value0;
SQLProperty property;
boolean nullable;
TypeName beanClass = typeName(entity.getElement());
// methodBuilder.addStatement("$T<String>
// _sqlWhereParams=getWhereParamsArray()", ArrayList.class);
for (String item : analyzer.getUsedBeanPropertyNames()) {
property = entity.findPropertyByName(item);
// methodBuilder.addCode("_sqlWhereParams.add(");
methodBuilder.addCode("_contentValues.addWhereArgs(");
nullable = TypeUtility.isNullable(property);
if (nullable && !(property.hasTypeAdapter())) {
// transform null in ""
methodBuilder.addCode("($L==null?\"\":", getter(beanParamName, beanClass, property));
}
// check for string conversion
TypeUtility.beginStringConversion(methodBuilder, property);
SQLTransformer.javaProperty2WhereCondition(methodBuilder, method, beanParamName, beanClass, property);
// check for string conversion
TypeUtility.endStringConversion(methodBuilder, property);
if (nullable && !(property.hasTypeAdapter())) {
methodBuilder.addCode(")");
}
methodBuilder.addCode(");\n");
}
} | java | public void generateWhereCondition(MethodSpec.Builder methodBuilder, SQLiteModelMethod method, SqlAnalyzer analyzer) {
SQLiteEntity entity = method.getEntity();
String beanParamName = method.getParameters().get(0).value0;
SQLProperty property;
boolean nullable;
TypeName beanClass = typeName(entity.getElement());
// methodBuilder.addStatement("$T<String>
// _sqlWhereParams=getWhereParamsArray()", ArrayList.class);
for (String item : analyzer.getUsedBeanPropertyNames()) {
property = entity.findPropertyByName(item);
// methodBuilder.addCode("_sqlWhereParams.add(");
methodBuilder.addCode("_contentValues.addWhereArgs(");
nullable = TypeUtility.isNullable(property);
if (nullable && !(property.hasTypeAdapter())) {
// transform null in ""
methodBuilder.addCode("($L==null?\"\":", getter(beanParamName, beanClass, property));
}
// check for string conversion
TypeUtility.beginStringConversion(methodBuilder, property);
SQLTransformer.javaProperty2WhereCondition(methodBuilder, method, beanParamName, beanClass, property);
// check for string conversion
TypeUtility.endStringConversion(methodBuilder, property);
if (nullable && !(property.hasTypeAdapter())) {
methodBuilder.addCode(")");
}
methodBuilder.addCode(");\n");
}
} | [
"public",
"void",
"generateWhereCondition",
"(",
"MethodSpec",
".",
"Builder",
"methodBuilder",
",",
"SQLiteModelMethod",
"method",
",",
"SqlAnalyzer",
"analyzer",
")",
"{",
"SQLiteEntity",
"entity",
"=",
"method",
".",
"getEntity",
"(",
")",
";",
"String",
"beanParamName",
"=",
"method",
".",
"getParameters",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"value0",
";",
"SQLProperty",
"property",
";",
"boolean",
"nullable",
";",
"TypeName",
"beanClass",
"=",
"typeName",
"(",
"entity",
".",
"getElement",
"(",
")",
")",
";",
"// methodBuilder.addStatement(\"$T<String>",
"// _sqlWhereParams=getWhereParamsArray()\", ArrayList.class);",
"for",
"(",
"String",
"item",
":",
"analyzer",
".",
"getUsedBeanPropertyNames",
"(",
")",
")",
"{",
"property",
"=",
"entity",
".",
"findPropertyByName",
"(",
"item",
")",
";",
"// methodBuilder.addCode(\"_sqlWhereParams.add(\");",
"methodBuilder",
".",
"addCode",
"(",
"\"_contentValues.addWhereArgs(\"",
")",
";",
"nullable",
"=",
"TypeUtility",
".",
"isNullable",
"(",
"property",
")",
";",
"if",
"(",
"nullable",
"&&",
"!",
"(",
"property",
".",
"hasTypeAdapter",
"(",
")",
")",
")",
"{",
"// transform null in \"\"",
"methodBuilder",
".",
"addCode",
"(",
"\"($L==null?\\\"\\\":\"",
",",
"getter",
"(",
"beanParamName",
",",
"beanClass",
",",
"property",
")",
")",
";",
"}",
"// check for string conversion",
"TypeUtility",
".",
"beginStringConversion",
"(",
"methodBuilder",
",",
"property",
")",
";",
"SQLTransformer",
".",
"javaProperty2WhereCondition",
"(",
"methodBuilder",
",",
"method",
",",
"beanParamName",
",",
"beanClass",
",",
"property",
")",
";",
"// check for string conversion",
"TypeUtility",
".",
"endStringConversion",
"(",
"methodBuilder",
",",
"property",
")",
";",
"if",
"(",
"nullable",
"&&",
"!",
"(",
"property",
".",
"hasTypeAdapter",
"(",
")",
")",
")",
"{",
"methodBuilder",
".",
"addCode",
"(",
"\")\"",
")",
";",
"}",
"methodBuilder",
".",
"addCode",
"(",
"\");\\n\"",
")",
";",
"}",
"}"
] | Generate where condition.
@param methodBuilder
the method builder
@param method
the method
@param analyzer
the analyzer | [
"Generate",
"where",
"condition",
"."
] | train | https://github.com/xcesco/kripton/blob/90de2c0523d39b99e81b8d38aa996898762f594a/kripton-processor/src/main/java/com/abubusoft/kripton/processor/sqlite/ModifyBeanHelper.java#L207-L242 |
OpenLiberty/open-liberty | dev/com.ibm.ws.jdbc/src/com/ibm/ws/rsadapter/AdapterUtil.java | AdapterUtil.mapSQLException | public static SQLException mapSQLException(SQLException se, Object mapper) {
"""
Translates a SQLException from the database. Exception mapping code is
now consolidated into AdapterUtil.mapException.
@param SQLException se - the SQLException from the database
@param mapper the managed connection or managed connection factory capable of
mapping the exception. If this value is NULL, then exception mapping is
not performed. If stale statement handling or connection error handling
is required then the managed connection must be supplied.
@return SQLException - the mapped SQLException
"""
return (SQLException) mapException(se, null, mapper, true);
} | java | public static SQLException mapSQLException(SQLException se, Object mapper) {
return (SQLException) mapException(se, null, mapper, true);
} | [
"public",
"static",
"SQLException",
"mapSQLException",
"(",
"SQLException",
"se",
",",
"Object",
"mapper",
")",
"{",
"return",
"(",
"SQLException",
")",
"mapException",
"(",
"se",
",",
"null",
",",
"mapper",
",",
"true",
")",
";",
"}"
] | Translates a SQLException from the database. Exception mapping code is
now consolidated into AdapterUtil.mapException.
@param SQLException se - the SQLException from the database
@param mapper the managed connection or managed connection factory capable of
mapping the exception. If this value is NULL, then exception mapping is
not performed. If stale statement handling or connection error handling
is required then the managed connection must be supplied.
@return SQLException - the mapped SQLException | [
"Translates",
"a",
"SQLException",
"from",
"the",
"database",
".",
"Exception",
"mapping",
"code",
"is",
"now",
"consolidated",
"into",
"AdapterUtil",
".",
"mapException",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jdbc/src/com/ibm/ws/rsadapter/AdapterUtil.java#L1257-L1259 |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/alg/geo/triangulate/PixelDepthLinearMetric.java | PixelDepthLinearMetric.depth2View | public double depth2View( Point2D_F64 a , Point2D_F64 b , Se3_F64 fromAtoB ) {
"""
Computes pixel depth in image 'a' from two observations.
@param a Observation in first frame. In calibrated coordinates. Not modified.
@param b Observation in second frame. In calibrated coordinates. Not modified.
@param fromAtoB Transform from frame a to frame b.
@return Pixel depth in first frame. In same units as T inside of fromAtoB.
"""
DMatrixRMaj R = fromAtoB.getR();
Vector3D_F64 T = fromAtoB.getT();
GeometryMath_F64.multCrossA(b, R, temp0);
GeometryMath_F64.mult(temp0,a,temp1);
GeometryMath_F64.cross(b, T, temp2);
return -(temp2.x+temp2.y+temp2.z)/(temp1.x+temp1.y+temp1.z);
} | java | public double depth2View( Point2D_F64 a , Point2D_F64 b , Se3_F64 fromAtoB )
{
DMatrixRMaj R = fromAtoB.getR();
Vector3D_F64 T = fromAtoB.getT();
GeometryMath_F64.multCrossA(b, R, temp0);
GeometryMath_F64.mult(temp0,a,temp1);
GeometryMath_F64.cross(b, T, temp2);
return -(temp2.x+temp2.y+temp2.z)/(temp1.x+temp1.y+temp1.z);
} | [
"public",
"double",
"depth2View",
"(",
"Point2D_F64",
"a",
",",
"Point2D_F64",
"b",
",",
"Se3_F64",
"fromAtoB",
")",
"{",
"DMatrixRMaj",
"R",
"=",
"fromAtoB",
".",
"getR",
"(",
")",
";",
"Vector3D_F64",
"T",
"=",
"fromAtoB",
".",
"getT",
"(",
")",
";",
"GeometryMath_F64",
".",
"multCrossA",
"(",
"b",
",",
"R",
",",
"temp0",
")",
";",
"GeometryMath_F64",
".",
"mult",
"(",
"temp0",
",",
"a",
",",
"temp1",
")",
";",
"GeometryMath_F64",
".",
"cross",
"(",
"b",
",",
"T",
",",
"temp2",
")",
";",
"return",
"-",
"(",
"temp2",
".",
"x",
"+",
"temp2",
".",
"y",
"+",
"temp2",
".",
"z",
")",
"/",
"(",
"temp1",
".",
"x",
"+",
"temp1",
".",
"y",
"+",
"temp1",
".",
"z",
")",
";",
"}"
] | Computes pixel depth in image 'a' from two observations.
@param a Observation in first frame. In calibrated coordinates. Not modified.
@param b Observation in second frame. In calibrated coordinates. Not modified.
@param fromAtoB Transform from frame a to frame b.
@return Pixel depth in first frame. In same units as T inside of fromAtoB. | [
"Computes",
"pixel",
"depth",
"in",
"image",
"a",
"from",
"two",
"observations",
"."
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/triangulate/PixelDepthLinearMetric.java#L101-L112 |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/TableWorks.java | TableWorks.addIndex | Index addIndex(int[] col, HsqlName name, boolean unique, boolean migrating) {
"""
Because of the way indexes and column data are held in memory and on
disk, it is necessary to recreate the table when an index is added to a
non-empty cached table.
<p> With empty tables, Index objects are simply added
<p> With MEOMRY and TEXT tables, a new index is built up and nodes for
earch row are interlinked (fredt@users)
@param col int[]
@param name HsqlName
@param unique boolean
@return new index
"""
Index newindex;
if (table.isEmpty(session) || table.isIndexingMutable()) {
PersistentStore store = session.sessionData.getRowStore(table);
newindex = table.createIndex(store, name, col, null, null, unique, migrating,
false, false);
} else {
newindex = table.createIndexStructure(name, col, null, null,
unique, migrating, false, false);
Table tn = table.moveDefinition(session, table.tableType, null,
null, newindex, -1, 0, emptySet,
emptySet);
// for all sessions move the data
tn.moveData(session, table, -1, 0);
database.persistentStoreCollection.releaseStore(table);
table = tn;
setNewTableInSchema(table);
updateConstraints(table, emptySet);
}
database.schemaManager.addSchemaObject(newindex);
database.schemaManager.recompileDependentObjects(table);
return newindex;
} | java | Index addIndex(int[] col, HsqlName name, boolean unique, boolean migrating) {
Index newindex;
if (table.isEmpty(session) || table.isIndexingMutable()) {
PersistentStore store = session.sessionData.getRowStore(table);
newindex = table.createIndex(store, name, col, null, null, unique, migrating,
false, false);
} else {
newindex = table.createIndexStructure(name, col, null, null,
unique, migrating, false, false);
Table tn = table.moveDefinition(session, table.tableType, null,
null, newindex, -1, 0, emptySet,
emptySet);
// for all sessions move the data
tn.moveData(session, table, -1, 0);
database.persistentStoreCollection.releaseStore(table);
table = tn;
setNewTableInSchema(table);
updateConstraints(table, emptySet);
}
database.schemaManager.addSchemaObject(newindex);
database.schemaManager.recompileDependentObjects(table);
return newindex;
} | [
"Index",
"addIndex",
"(",
"int",
"[",
"]",
"col",
",",
"HsqlName",
"name",
",",
"boolean",
"unique",
",",
"boolean",
"migrating",
")",
"{",
"Index",
"newindex",
";",
"if",
"(",
"table",
".",
"isEmpty",
"(",
"session",
")",
"||",
"table",
".",
"isIndexingMutable",
"(",
")",
")",
"{",
"PersistentStore",
"store",
"=",
"session",
".",
"sessionData",
".",
"getRowStore",
"(",
"table",
")",
";",
"newindex",
"=",
"table",
".",
"createIndex",
"(",
"store",
",",
"name",
",",
"col",
",",
"null",
",",
"null",
",",
"unique",
",",
"migrating",
",",
"false",
",",
"false",
")",
";",
"}",
"else",
"{",
"newindex",
"=",
"table",
".",
"createIndexStructure",
"(",
"name",
",",
"col",
",",
"null",
",",
"null",
",",
"unique",
",",
"migrating",
",",
"false",
",",
"false",
")",
";",
"Table",
"tn",
"=",
"table",
".",
"moveDefinition",
"(",
"session",
",",
"table",
".",
"tableType",
",",
"null",
",",
"null",
",",
"newindex",
",",
"-",
"1",
",",
"0",
",",
"emptySet",
",",
"emptySet",
")",
";",
"// for all sessions move the data",
"tn",
".",
"moveData",
"(",
"session",
",",
"table",
",",
"-",
"1",
",",
"0",
")",
";",
"database",
".",
"persistentStoreCollection",
".",
"releaseStore",
"(",
"table",
")",
";",
"table",
"=",
"tn",
";",
"setNewTableInSchema",
"(",
"table",
")",
";",
"updateConstraints",
"(",
"table",
",",
"emptySet",
")",
";",
"}",
"database",
".",
"schemaManager",
".",
"addSchemaObject",
"(",
"newindex",
")",
";",
"database",
".",
"schemaManager",
".",
"recompileDependentObjects",
"(",
"table",
")",
";",
"return",
"newindex",
";",
"}"
] | Because of the way indexes and column data are held in memory and on
disk, it is necessary to recreate the table when an index is added to a
non-empty cached table.
<p> With empty tables, Index objects are simply added
<p> With MEOMRY and TEXT tables, a new index is built up and nodes for
earch row are interlinked (fredt@users)
@param col int[]
@param name HsqlName
@param unique boolean
@return new index | [
"Because",
"of",
"the",
"way",
"indexes",
"and",
"column",
"data",
"are",
"held",
"in",
"memory",
"and",
"on",
"disk",
"it",
"is",
"necessary",
"to",
"recreate",
"the",
"table",
"when",
"an",
"index",
"is",
"added",
"to",
"a",
"non",
"-",
"empty",
"cached",
"table",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/TableWorks.java#L486-L517 |
Bedework/bw-util | bw-util-xml/src/main/java/org/bedework/util/xml/XmlUtil.java | XmlUtil.getReqOneNodeVal | public static String getReqOneNodeVal(final Node el, final String name)
throws SAXException {
"""
Get the value of an element. We expect 1 child node otherwise we raise an
exception.
@param el Node whose value we want
@param name String name to make exception messages more readable
@return String node value
@throws SAXException
"""
String str = getOneNodeVal(el, name);
if ((str == null) || (str.length() == 0)) {
throw new SAXException("Missing property value: " + name);
}
return str;
} | java | public static String getReqOneNodeVal(final Node el, final String name)
throws SAXException {
String str = getOneNodeVal(el, name);
if ((str == null) || (str.length() == 0)) {
throw new SAXException("Missing property value: " + name);
}
return str;
} | [
"public",
"static",
"String",
"getReqOneNodeVal",
"(",
"final",
"Node",
"el",
",",
"final",
"String",
"name",
")",
"throws",
"SAXException",
"{",
"String",
"str",
"=",
"getOneNodeVal",
"(",
"el",
",",
"name",
")",
";",
"if",
"(",
"(",
"str",
"==",
"null",
")",
"||",
"(",
"str",
".",
"length",
"(",
")",
"==",
"0",
")",
")",
"{",
"throw",
"new",
"SAXException",
"(",
"\"Missing property value: \"",
"+",
"name",
")",
";",
"}",
"return",
"str",
";",
"}"
] | Get the value of an element. We expect 1 child node otherwise we raise an
exception.
@param el Node whose value we want
@param name String name to make exception messages more readable
@return String node value
@throws SAXException | [
"Get",
"the",
"value",
"of",
"an",
"element",
".",
"We",
"expect",
"1",
"child",
"node",
"otherwise",
"we",
"raise",
"an",
"exception",
"."
] | train | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-xml/src/main/java/org/bedework/util/xml/XmlUtil.java#L189-L198 |
EsotericSoftware/kryo | benchmarks/src/main/java/com/esotericsoftware/kryo/benchmarks/KryoBenchmarks.java | KryoBenchmarks.main | static public void main (String[] args) throws Exception {
"""
To run from command line: $ mvn clean install exec:java -Dexec.args="-f 4 -wi 5 -i 3 -t 2 -w 2s -r 2s"
<p>
Fork 0 can be used for debugging/development, eg: -f 0 -wi 1 -i 1 -t 1 -w 1s -r 1s [benchmarkClassName]
"""
if (args.length == 0) {
String commandLine = "-f 0 -wi 1 -i 1 -t 1 -w 1s -r 1s " // For developement only (fork 0, short runs).
// + "-bs 2500000 ArrayBenchmark" //
// + "-rf csv FieldSerializerBenchmark.field FieldSerializerBenchmark.tagged" //
// + "FieldSerializerBenchmark.tagged" //
;
System.out.println(commandLine);
args = commandLine.split(" ");
}
Main.main(args);
} | java | static public void main (String[] args) throws Exception {
if (args.length == 0) {
String commandLine = "-f 0 -wi 1 -i 1 -t 1 -w 1s -r 1s " // For developement only (fork 0, short runs).
// + "-bs 2500000 ArrayBenchmark" //
// + "-rf csv FieldSerializerBenchmark.field FieldSerializerBenchmark.tagged" //
// + "FieldSerializerBenchmark.tagged" //
;
System.out.println(commandLine);
args = commandLine.split(" ");
}
Main.main(args);
} | [
"static",
"public",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"throws",
"Exception",
"{",
"if",
"(",
"args",
".",
"length",
"==",
"0",
")",
"{",
"String",
"commandLine",
"=",
"\"-f 0 -wi 1 -i 1 -t 1 -w 1s -r 1s \"",
"// For developement only (fork 0, short runs).",
"// + \"-bs 2500000 ArrayBenchmark\" //",
"// + \"-rf csv FieldSerializerBenchmark.field FieldSerializerBenchmark.tagged\" //",
"// + \"FieldSerializerBenchmark.tagged\" //",
";",
"System",
".",
"out",
".",
"println",
"(",
"commandLine",
")",
";",
"args",
"=",
"commandLine",
".",
"split",
"(",
"\" \"",
")",
";",
"}",
"Main",
".",
"main",
"(",
"args",
")",
";",
"}"
] | To run from command line: $ mvn clean install exec:java -Dexec.args="-f 4 -wi 5 -i 3 -t 2 -w 2s -r 2s"
<p>
Fork 0 can be used for debugging/development, eg: -f 0 -wi 1 -i 1 -t 1 -w 1s -r 1s [benchmarkClassName] | [
"To",
"run",
"from",
"command",
"line",
":",
"$",
"mvn",
"clean",
"install",
"exec",
":",
"java",
"-",
"Dexec",
".",
"args",
"=",
"-",
"f",
"4",
"-",
"wi",
"5",
"-",
"i",
"3",
"-",
"t",
"2",
"-",
"w",
"2s",
"-",
"r",
"2s",
"<p",
">",
"Fork",
"0",
"can",
"be",
"used",
"for",
"debugging",
"/",
"development",
"eg",
":",
"-",
"f",
"0",
"-",
"wi",
"1",
"-",
"i",
"1",
"-",
"t",
"1",
"-",
"w",
"1s",
"-",
"r",
"1s",
"[",
"benchmarkClassName",
"]"
] | train | https://github.com/EsotericSoftware/kryo/blob/a8be1ab26f347f299a3c3f7171d6447dd5390845/benchmarks/src/main/java/com/esotericsoftware/kryo/benchmarks/KryoBenchmarks.java#L28-L39 |
JOML-CI/JOML | src/org/joml/Matrix4d.java | Matrix4d.orthoSymmetricLH | public Matrix4d orthoSymmetricLH(double width, double height, double zNear, double zFar, Matrix4d dest) {
"""
Apply a symmetric orthographic projection transformation for a left-handed coordinate system
using OpenGL's NDC z range of <code>[-1..+1]</code> to this matrix and store the result in <code>dest</code>.
<p>
This method is equivalent to calling {@link #orthoLH(double, double, double, double, double, double, Matrix4d) orthoLH()} with
<code>left=-width/2</code>, <code>right=+width/2</code>, <code>bottom=-height/2</code> and <code>top=+height/2</code>.
<p>
If <code>M</code> is <code>this</code> matrix and <code>O</code> the orthographic projection matrix,
then the new matrix will be <code>M * O</code>. So when transforming a
vector <code>v</code> with the new matrix by using <code>M * O * v</code>, the
orthographic projection transformation will be applied first!
<p>
In order to set the matrix to a symmetric orthographic projection without post-multiplying it,
use {@link #setOrthoSymmetricLH(double, double, double, double) setOrthoSymmetricLH()}.
<p>
Reference: <a href="http://www.songho.ca/opengl/gl_projectionmatrix.html#ortho">http://www.songho.ca</a>
@see #setOrthoSymmetricLH(double, double, double, double)
@param width
the distance between the right and left frustum edges
@param height
the distance between the top and bottom frustum edges
@param zNear
near clipping plane distance
@param zFar
far clipping plane distance
@param dest
will hold the result
@return dest
"""
return orthoSymmetricLH(width, height, zNear, zFar, false, dest);
} | java | public Matrix4d orthoSymmetricLH(double width, double height, double zNear, double zFar, Matrix4d dest) {
return orthoSymmetricLH(width, height, zNear, zFar, false, dest);
} | [
"public",
"Matrix4d",
"orthoSymmetricLH",
"(",
"double",
"width",
",",
"double",
"height",
",",
"double",
"zNear",
",",
"double",
"zFar",
",",
"Matrix4d",
"dest",
")",
"{",
"return",
"orthoSymmetricLH",
"(",
"width",
",",
"height",
",",
"zNear",
",",
"zFar",
",",
"false",
",",
"dest",
")",
";",
"}"
] | Apply a symmetric orthographic projection transformation for a left-handed coordinate system
using OpenGL's NDC z range of <code>[-1..+1]</code> to this matrix and store the result in <code>dest</code>.
<p>
This method is equivalent to calling {@link #orthoLH(double, double, double, double, double, double, Matrix4d) orthoLH()} with
<code>left=-width/2</code>, <code>right=+width/2</code>, <code>bottom=-height/2</code> and <code>top=+height/2</code>.
<p>
If <code>M</code> is <code>this</code> matrix and <code>O</code> the orthographic projection matrix,
then the new matrix will be <code>M * O</code>. So when transforming a
vector <code>v</code> with the new matrix by using <code>M * O * v</code>, the
orthographic projection transformation will be applied first!
<p>
In order to set the matrix to a symmetric orthographic projection without post-multiplying it,
use {@link #setOrthoSymmetricLH(double, double, double, double) setOrthoSymmetricLH()}.
<p>
Reference: <a href="http://www.songho.ca/opengl/gl_projectionmatrix.html#ortho">http://www.songho.ca</a>
@see #setOrthoSymmetricLH(double, double, double, double)
@param width
the distance between the right and left frustum edges
@param height
the distance between the top and bottom frustum edges
@param zNear
near clipping plane distance
@param zFar
far clipping plane distance
@param dest
will hold the result
@return dest | [
"Apply",
"a",
"symmetric",
"orthographic",
"projection",
"transformation",
"for",
"a",
"left",
"-",
"handed",
"coordinate",
"system",
"using",
"OpenGL",
"s",
"NDC",
"z",
"range",
"of",
"<code",
">",
"[",
"-",
"1",
"..",
"+",
"1",
"]",
"<",
"/",
"code",
">",
"to",
"this",
"matrix",
"and",
"store",
"the",
"result",
"in",
"<code",
">",
"dest<",
"/",
"code",
">",
".",
"<p",
">",
"This",
"method",
"is",
"equivalent",
"to",
"calling",
"{",
"@link",
"#orthoLH",
"(",
"double",
"double",
"double",
"double",
"double",
"double",
"Matrix4d",
")",
"orthoLH",
"()",
"}",
"with",
"<code",
">",
"left",
"=",
"-",
"width",
"/",
"2<",
"/",
"code",
">",
"<code",
">",
"right",
"=",
"+",
"width",
"/",
"2<",
"/",
"code",
">",
"<code",
">",
"bottom",
"=",
"-",
"height",
"/",
"2<",
"/",
"code",
">",
"and",
"<code",
">",
"top",
"=",
"+",
"height",
"/",
"2<",
"/",
"code",
">",
".",
"<p",
">",
"If",
"<code",
">",
"M<",
"/",
"code",
">",
"is",
"<code",
">",
"this<",
"/",
"code",
">",
"matrix",
"and",
"<code",
">",
"O<",
"/",
"code",
">",
"the",
"orthographic",
"projection",
"matrix",
"then",
"the",
"new",
"matrix",
"will",
"be",
"<code",
">",
"M",
"*",
"O<",
"/",
"code",
">",
".",
"So",
"when",
"transforming",
"a",
"vector",
"<code",
">",
"v<",
"/",
"code",
">",
"with",
"the",
"new",
"matrix",
"by",
"using",
"<code",
">",
"M",
"*",
"O",
"*",
"v<",
"/",
"code",
">",
"the",
"orthographic",
"projection",
"transformation",
"will",
"be",
"applied",
"first!",
"<p",
">",
"In",
"order",
"to",
"set",
"the",
"matrix",
"to",
"a",
"symmetric",
"orthographic",
"projection",
"without",
"post",
"-",
"multiplying",
"it",
"use",
"{",
"@link",
"#setOrthoSymmetricLH",
"(",
"double",
"double",
"double",
"double",
")",
"setOrthoSymmetricLH",
"()",
"}",
".",
"<p",
">",
"Reference",
":",
"<a",
"href",
"=",
"http",
":",
"//",
"www",
".",
"songho",
".",
"ca",
"/",
"opengl",
"/",
"gl_projectionmatrix",
".",
"html#ortho",
">",
"http",
":",
"//",
"www",
".",
"songho",
".",
"ca<",
"/",
"a",
">"
] | train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Matrix4d.java#L10325-L10327 |
threerings/narya | tools/src/main/java/com/threerings/presents/tools/GeneratedSourceMerger.java | GeneratedSourceMerger.extractGeneratedSection | protected Section extractGeneratedSection (Matcher m, String input) {
"""
Returns a section name and its contents from the given matcher pointing to the start of a
section. <code>m</code> is at the end of the section when this returns.
"""
int startIdx = m.start();
String name = m.group(1);
if (m.group(2).equals("DISABLED")) {
return new Section(name, input.substring(startIdx, m.end()), true);
}
Preconditions.checkArgument(m.group(2).equals("START"), "'%s' END without START",
name);
Preconditions.checkArgument(m.find(), "'%s' START without END", name);
String endName = m.group(1);
Preconditions.checkArgument(m.group(2).equals("END"),
"'%s' START after '%s' START", endName, name);
Preconditions.checkArgument(endName.equals(name),
"'%s' END after '%s' START", endName, name);
return new Section(name, input.substring(startIdx, m.end()), false);
} | java | protected Section extractGeneratedSection (Matcher m, String input)
{
int startIdx = m.start();
String name = m.group(1);
if (m.group(2).equals("DISABLED")) {
return new Section(name, input.substring(startIdx, m.end()), true);
}
Preconditions.checkArgument(m.group(2).equals("START"), "'%s' END without START",
name);
Preconditions.checkArgument(m.find(), "'%s' START without END", name);
String endName = m.group(1);
Preconditions.checkArgument(m.group(2).equals("END"),
"'%s' START after '%s' START", endName, name);
Preconditions.checkArgument(endName.equals(name),
"'%s' END after '%s' START", endName, name);
return new Section(name, input.substring(startIdx, m.end()), false);
} | [
"protected",
"Section",
"extractGeneratedSection",
"(",
"Matcher",
"m",
",",
"String",
"input",
")",
"{",
"int",
"startIdx",
"=",
"m",
".",
"start",
"(",
")",
";",
"String",
"name",
"=",
"m",
".",
"group",
"(",
"1",
")",
";",
"if",
"(",
"m",
".",
"group",
"(",
"2",
")",
".",
"equals",
"(",
"\"DISABLED\"",
")",
")",
"{",
"return",
"new",
"Section",
"(",
"name",
",",
"input",
".",
"substring",
"(",
"startIdx",
",",
"m",
".",
"end",
"(",
")",
")",
",",
"true",
")",
";",
"}",
"Preconditions",
".",
"checkArgument",
"(",
"m",
".",
"group",
"(",
"2",
")",
".",
"equals",
"(",
"\"START\"",
")",
",",
"\"'%s' END without START\"",
",",
"name",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"m",
".",
"find",
"(",
")",
",",
"\"'%s' START without END\"",
",",
"name",
")",
";",
"String",
"endName",
"=",
"m",
".",
"group",
"(",
"1",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"m",
".",
"group",
"(",
"2",
")",
".",
"equals",
"(",
"\"END\"",
")",
",",
"\"'%s' START after '%s' START\"",
",",
"endName",
",",
"name",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"endName",
".",
"equals",
"(",
"name",
")",
",",
"\"'%s' END after '%s' START\"",
",",
"endName",
",",
"name",
")",
";",
"return",
"new",
"Section",
"(",
"name",
",",
"input",
".",
"substring",
"(",
"startIdx",
",",
"m",
".",
"end",
"(",
")",
")",
",",
"false",
")",
";",
"}"
] | Returns a section name and its contents from the given matcher pointing to the start of a
section. <code>m</code> is at the end of the section when this returns. | [
"Returns",
"a",
"section",
"name",
"and",
"its",
"contents",
"from",
"the",
"given",
"matcher",
"pointing",
"to",
"the",
"start",
"of",
"a",
"section",
".",
"<code",
">",
"m<",
"/",
"code",
">",
"is",
"at",
"the",
"end",
"of",
"the",
"section",
"when",
"this",
"returns",
"."
] | train | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/tools/src/main/java/com/threerings/presents/tools/GeneratedSourceMerger.java#L98-L114 |
steveohara/j2mod | src/main/java/com/ghgande/j2mod/modbus/msg/ReadFileRecordRequest.java | ReadFileRecordRequest.readData | public void readData(DataInput din) throws IOException {
"""
readData -- read all the data for this request.
@throws java.io.IOException If the data cannot be read
"""
int byteCount = din.readUnsignedByte();
int recordCount = byteCount / 7;
records = new RecordRequest[recordCount];
for (int i = 0; i < recordCount; i++) {
if (din.readByte() != 6) {
throw new IOException();
}
int file = din.readUnsignedShort();
int record = din.readUnsignedShort();
if (record < 0 || record >= 10000) {
throw new IOException();
}
int count = din.readUnsignedShort();
records[i] = new RecordRequest(file, record, count);
}
} | java | public void readData(DataInput din) throws IOException {
int byteCount = din.readUnsignedByte();
int recordCount = byteCount / 7;
records = new RecordRequest[recordCount];
for (int i = 0; i < recordCount; i++) {
if (din.readByte() != 6) {
throw new IOException();
}
int file = din.readUnsignedShort();
int record = din.readUnsignedShort();
if (record < 0 || record >= 10000) {
throw new IOException();
}
int count = din.readUnsignedShort();
records[i] = new RecordRequest(file, record, count);
}
} | [
"public",
"void",
"readData",
"(",
"DataInput",
"din",
")",
"throws",
"IOException",
"{",
"int",
"byteCount",
"=",
"din",
".",
"readUnsignedByte",
"(",
")",
";",
"int",
"recordCount",
"=",
"byteCount",
"/",
"7",
";",
"records",
"=",
"new",
"RecordRequest",
"[",
"recordCount",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"recordCount",
";",
"i",
"++",
")",
"{",
"if",
"(",
"din",
".",
"readByte",
"(",
")",
"!=",
"6",
")",
"{",
"throw",
"new",
"IOException",
"(",
")",
";",
"}",
"int",
"file",
"=",
"din",
".",
"readUnsignedShort",
"(",
")",
";",
"int",
"record",
"=",
"din",
".",
"readUnsignedShort",
"(",
")",
";",
"if",
"(",
"record",
"<",
"0",
"||",
"record",
">=",
"10000",
")",
"{",
"throw",
"new",
"IOException",
"(",
")",
";",
"}",
"int",
"count",
"=",
"din",
".",
"readUnsignedShort",
"(",
")",
";",
"records",
"[",
"i",
"]",
"=",
"new",
"RecordRequest",
"(",
"file",
",",
"record",
",",
"count",
")",
";",
"}",
"}"
] | readData -- read all the data for this request.
@throws java.io.IOException If the data cannot be read | [
"readData",
"--",
"read",
"all",
"the",
"data",
"for",
"this",
"request",
"."
] | train | https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/msg/ReadFileRecordRequest.java#L175-L196 |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/typesystem/SARLOperationHelper.java | SARLOperationHelper._hasSideEffects | protected Boolean _hasSideEffects(XThrowExpression expression, ISideEffectContext context) {
"""
Test if the given expression has side effects.
@param expression the expression.
@param context the list of context expressions.
@return {@code true} if the expression has side effects.
"""
return hasSideEffects(expression.getExpression(), context);
} | java | protected Boolean _hasSideEffects(XThrowExpression expression, ISideEffectContext context) {
return hasSideEffects(expression.getExpression(), context);
} | [
"protected",
"Boolean",
"_hasSideEffects",
"(",
"XThrowExpression",
"expression",
",",
"ISideEffectContext",
"context",
")",
"{",
"return",
"hasSideEffects",
"(",
"expression",
".",
"getExpression",
"(",
")",
",",
"context",
")",
";",
"}"
] | Test if the given expression has side effects.
@param expression the expression.
@param context the list of context expressions.
@return {@code true} if the expression has side effects. | [
"Test",
"if",
"the",
"given",
"expression",
"has",
"side",
"effects",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/typesystem/SARLOperationHelper.java#L349-L351 |
eurekaclinical/protempa | protempa-framework/src/main/java/org/protempa/JBossRuleCreator.java | JBossRuleCreator.visit | @Override
public void visit(HighLevelAbstractionDefinition def) throws ProtempaException {
"""
Translates a high-level abstraction definition into rules.
@param def a {@link HighLevelAbstractionDefinition}. Cannot be
<code>null</code>.
@throws KnowledgeSourceReadException if an error occurs accessing the
knowledge source during rule creation.
"""
LOGGER.log(Level.FINER, "Creating rule for {0}", def);
try {
Set<ExtendedPropositionDefinition> epdsC = def
.getExtendedPropositionDefinitions();
/*
* If there are no extended proposition definitions defined, we
* might still have an inverseIsA relationship with another
* high-level abstraction definition.
*/
if (!epdsC.isEmpty()) {
Rule rule = new Rule(def.getId());
rule.setSalience(TWO_SALIENCE);
ExtendedPropositionDefinition[] epds = epdsC
.toArray(new ExtendedPropositionDefinition[epdsC.size()]);
for (int i = 0; i < epds.length; i++) {
Pattern p = new Pattern(i, PROP_OT);
GetMatchesPredicateExpression matchesPredicateExpression = new GetMatchesPredicateExpression(epds[i], this.cache);
Constraint c = new PredicateConstraint(
matchesPredicateExpression);
p.addConstraint(c);
rule.addPattern(p);
}
rule.addPattern(new EvalCondition(
new HighLevelAbstractionCondition(def, epds), null));
rule.setConsequence(new HighLevelAbstractionConsequence(def,
epds, this.derivationsBuilder));
this.ruleToAbstractionDefinition.put(rule, def);
rules.add(rule);
ABSTRACTION_COMBINER.toRules(def, rules, this.derivationsBuilder);
}
} catch (InvalidRuleException e) {
throw new AssertionError(e.getClass().getName() + ": "
+ e.getMessage());
}
} | java | @Override
public void visit(HighLevelAbstractionDefinition def) throws ProtempaException {
LOGGER.log(Level.FINER, "Creating rule for {0}", def);
try {
Set<ExtendedPropositionDefinition> epdsC = def
.getExtendedPropositionDefinitions();
/*
* If there are no extended proposition definitions defined, we
* might still have an inverseIsA relationship with another
* high-level abstraction definition.
*/
if (!epdsC.isEmpty()) {
Rule rule = new Rule(def.getId());
rule.setSalience(TWO_SALIENCE);
ExtendedPropositionDefinition[] epds = epdsC
.toArray(new ExtendedPropositionDefinition[epdsC.size()]);
for (int i = 0; i < epds.length; i++) {
Pattern p = new Pattern(i, PROP_OT);
GetMatchesPredicateExpression matchesPredicateExpression = new GetMatchesPredicateExpression(epds[i], this.cache);
Constraint c = new PredicateConstraint(
matchesPredicateExpression);
p.addConstraint(c);
rule.addPattern(p);
}
rule.addPattern(new EvalCondition(
new HighLevelAbstractionCondition(def, epds), null));
rule.setConsequence(new HighLevelAbstractionConsequence(def,
epds, this.derivationsBuilder));
this.ruleToAbstractionDefinition.put(rule, def);
rules.add(rule);
ABSTRACTION_COMBINER.toRules(def, rules, this.derivationsBuilder);
}
} catch (InvalidRuleException e) {
throw new AssertionError(e.getClass().getName() + ": "
+ e.getMessage());
}
} | [
"@",
"Override",
"public",
"void",
"visit",
"(",
"HighLevelAbstractionDefinition",
"def",
")",
"throws",
"ProtempaException",
"{",
"LOGGER",
".",
"log",
"(",
"Level",
".",
"FINER",
",",
"\"Creating rule for {0}\"",
",",
"def",
")",
";",
"try",
"{",
"Set",
"<",
"ExtendedPropositionDefinition",
">",
"epdsC",
"=",
"def",
".",
"getExtendedPropositionDefinitions",
"(",
")",
";",
"/*\n * If there are no extended proposition definitions defined, we\n * might still have an inverseIsA relationship with another\n * high-level abstraction definition.\n */",
"if",
"(",
"!",
"epdsC",
".",
"isEmpty",
"(",
")",
")",
"{",
"Rule",
"rule",
"=",
"new",
"Rule",
"(",
"def",
".",
"getId",
"(",
")",
")",
";",
"rule",
".",
"setSalience",
"(",
"TWO_SALIENCE",
")",
";",
"ExtendedPropositionDefinition",
"[",
"]",
"epds",
"=",
"epdsC",
".",
"toArray",
"(",
"new",
"ExtendedPropositionDefinition",
"[",
"epdsC",
".",
"size",
"(",
")",
"]",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"epds",
".",
"length",
";",
"i",
"++",
")",
"{",
"Pattern",
"p",
"=",
"new",
"Pattern",
"(",
"i",
",",
"PROP_OT",
")",
";",
"GetMatchesPredicateExpression",
"matchesPredicateExpression",
"=",
"new",
"GetMatchesPredicateExpression",
"(",
"epds",
"[",
"i",
"]",
",",
"this",
".",
"cache",
")",
";",
"Constraint",
"c",
"=",
"new",
"PredicateConstraint",
"(",
"matchesPredicateExpression",
")",
";",
"p",
".",
"addConstraint",
"(",
"c",
")",
";",
"rule",
".",
"addPattern",
"(",
"p",
")",
";",
"}",
"rule",
".",
"addPattern",
"(",
"new",
"EvalCondition",
"(",
"new",
"HighLevelAbstractionCondition",
"(",
"def",
",",
"epds",
")",
",",
"null",
")",
")",
";",
"rule",
".",
"setConsequence",
"(",
"new",
"HighLevelAbstractionConsequence",
"(",
"def",
",",
"epds",
",",
"this",
".",
"derivationsBuilder",
")",
")",
";",
"this",
".",
"ruleToAbstractionDefinition",
".",
"put",
"(",
"rule",
",",
"def",
")",
";",
"rules",
".",
"add",
"(",
"rule",
")",
";",
"ABSTRACTION_COMBINER",
".",
"toRules",
"(",
"def",
",",
"rules",
",",
"this",
".",
"derivationsBuilder",
")",
";",
"}",
"}",
"catch",
"(",
"InvalidRuleException",
"e",
")",
"{",
"throw",
"new",
"AssertionError",
"(",
"e",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\": \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Translates a high-level abstraction definition into rules.
@param def a {@link HighLevelAbstractionDefinition}. Cannot be
<code>null</code>.
@throws KnowledgeSourceReadException if an error occurs accessing the
knowledge source during rule creation. | [
"Translates",
"a",
"high",
"-",
"level",
"abstraction",
"definition",
"into",
"rules",
"."
] | train | https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/JBossRuleCreator.java#L253-L290 |
mapbox/mapbox-java | services-geojson/src/main/java/com/mapbox/geojson/Polygon.java | Polygon.fromLngLats | static Polygon fromLngLats(@NonNull double[][][] coordinates) {
"""
Create a new instance of this class by passing in three dimensional double array which defines
the geometry of this polygon.
@param coordinates a three dimensional double array defining this polygons geometry
@return a new instance of this class defined by the values passed inside this static factory
method
@since 3.0.0
"""
List<List<Point>> converted = new ArrayList<>(coordinates.length);
for (double[][] coordinate : coordinates) {
List<Point> innerList = new ArrayList<>(coordinate.length);
for (double[] pointCoordinate : coordinate) {
innerList.add(Point.fromLngLat(pointCoordinate));
}
converted.add(innerList);
}
return new Polygon(TYPE, null, converted);
} | java | static Polygon fromLngLats(@NonNull double[][][] coordinates) {
List<List<Point>> converted = new ArrayList<>(coordinates.length);
for (double[][] coordinate : coordinates) {
List<Point> innerList = new ArrayList<>(coordinate.length);
for (double[] pointCoordinate : coordinate) {
innerList.add(Point.fromLngLat(pointCoordinate));
}
converted.add(innerList);
}
return new Polygon(TYPE, null, converted);
} | [
"static",
"Polygon",
"fromLngLats",
"(",
"@",
"NonNull",
"double",
"[",
"]",
"[",
"]",
"[",
"]",
"coordinates",
")",
"{",
"List",
"<",
"List",
"<",
"Point",
">>",
"converted",
"=",
"new",
"ArrayList",
"<>",
"(",
"coordinates",
".",
"length",
")",
";",
"for",
"(",
"double",
"[",
"]",
"[",
"]",
"coordinate",
":",
"coordinates",
")",
"{",
"List",
"<",
"Point",
">",
"innerList",
"=",
"new",
"ArrayList",
"<>",
"(",
"coordinate",
".",
"length",
")",
";",
"for",
"(",
"double",
"[",
"]",
"pointCoordinate",
":",
"coordinate",
")",
"{",
"innerList",
".",
"add",
"(",
"Point",
".",
"fromLngLat",
"(",
"pointCoordinate",
")",
")",
";",
"}",
"converted",
".",
"add",
"(",
"innerList",
")",
";",
"}",
"return",
"new",
"Polygon",
"(",
"TYPE",
",",
"null",
",",
"converted",
")",
";",
"}"
] | Create a new instance of this class by passing in three dimensional double array which defines
the geometry of this polygon.
@param coordinates a three dimensional double array defining this polygons geometry
@return a new instance of this class defined by the values passed inside this static factory
method
@since 3.0.0 | [
"Create",
"a",
"new",
"instance",
"of",
"this",
"class",
"by",
"passing",
"in",
"three",
"dimensional",
"double",
"array",
"which",
"defines",
"the",
"geometry",
"of",
"this",
"polygon",
"."
] | train | https://github.com/mapbox/mapbox-java/blob/c0be138f462f91441388584c668f3760ba0e18e2/services-geojson/src/main/java/com/mapbox/geojson/Polygon.java#L127-L137 |
salesforce/Argus | ArgusCore/src/main/java/com/salesforce/dva/argus/entity/JPAEntity.java | JPAEntity.findByPrimaryKey | public static <E extends Identifiable> E findByPrimaryKey(EntityManager em, BigInteger id, Class<E> type) {
"""
Finds a JPA entity by its primary key.
@param <E> The JPA entity type.
@param em The entity manager to use. Cannot be null.
@param id The ID of the entity to find. Must be a positive, non-zero integer.
@param type The runtime type to cast the result value to.
@return The corresponding entity or null if no entity exists.
"""
requireArgument(em != null, "The entity manager cannot be null.");
requireArgument(id != null && id.compareTo(ZERO) > 0, "ID cannot be null and must be positive and non-zero");
requireArgument(type != null, "The entity type cannot be null.");
TypedQuery<E> query = em.createNamedQuery("JPAEntity.findByPrimaryKey", type);
query.setHint("javax.persistence.cache.storeMode", "REFRESH");
try {
query.setParameter("id", id);
query.setParameter("deleted", false);
return query.getSingleResult();
} catch (NoResultException ex) {
return null;
}
} | java | public static <E extends Identifiable> E findByPrimaryKey(EntityManager em, BigInteger id, Class<E> type) {
requireArgument(em != null, "The entity manager cannot be null.");
requireArgument(id != null && id.compareTo(ZERO) > 0, "ID cannot be null and must be positive and non-zero");
requireArgument(type != null, "The entity type cannot be null.");
TypedQuery<E> query = em.createNamedQuery("JPAEntity.findByPrimaryKey", type);
query.setHint("javax.persistence.cache.storeMode", "REFRESH");
try {
query.setParameter("id", id);
query.setParameter("deleted", false);
return query.getSingleResult();
} catch (NoResultException ex) {
return null;
}
} | [
"public",
"static",
"<",
"E",
"extends",
"Identifiable",
">",
"E",
"findByPrimaryKey",
"(",
"EntityManager",
"em",
",",
"BigInteger",
"id",
",",
"Class",
"<",
"E",
">",
"type",
")",
"{",
"requireArgument",
"(",
"em",
"!=",
"null",
",",
"\"The entity manager cannot be null.\"",
")",
";",
"requireArgument",
"(",
"id",
"!=",
"null",
"&&",
"id",
".",
"compareTo",
"(",
"ZERO",
")",
">",
"0",
",",
"\"ID cannot be null and must be positive and non-zero\"",
")",
";",
"requireArgument",
"(",
"type",
"!=",
"null",
",",
"\"The entity type cannot be null.\"",
")",
";",
"TypedQuery",
"<",
"E",
">",
"query",
"=",
"em",
".",
"createNamedQuery",
"(",
"\"JPAEntity.findByPrimaryKey\"",
",",
"type",
")",
";",
"query",
".",
"setHint",
"(",
"\"javax.persistence.cache.storeMode\"",
",",
"\"REFRESH\"",
")",
";",
"try",
"{",
"query",
".",
"setParameter",
"(",
"\"id\"",
",",
"id",
")",
";",
"query",
".",
"setParameter",
"(",
"\"deleted\"",
",",
"false",
")",
";",
"return",
"query",
".",
"getSingleResult",
"(",
")",
";",
"}",
"catch",
"(",
"NoResultException",
"ex",
")",
"{",
"return",
"null",
";",
"}",
"}"
] | Finds a JPA entity by its primary key.
@param <E> The JPA entity type.
@param em The entity manager to use. Cannot be null.
@param id The ID of the entity to find. Must be a positive, non-zero integer.
@param type The runtime type to cast the result value to.
@return The corresponding entity or null if no entity exists. | [
"Finds",
"a",
"JPA",
"entity",
"by",
"its",
"primary",
"key",
"."
] | train | https://github.com/salesforce/Argus/blob/121b59a268da264316cded6a3e9271366a23cd86/ArgusCore/src/main/java/com/salesforce/dva/argus/entity/JPAEntity.java#L181-L196 |
shinesolutions/swagger-aem | java/generated/src/main/java/com/shinesolutions/swaggeraem4j/api/ConsoleApi.java | ConsoleApi.postSamlConfigurationAsync | public com.squareup.okhttp.Call postSamlConfigurationAsync(Boolean post, Boolean apply, Boolean delete, String action, String location, List<String> path, String serviceRanking, String idpUrl, String idpCertAlias, Boolean idpHttpRedirect, String serviceProviderEntityId, String assertionConsumerServiceURL, String spPrivateKeyAlias, String keyStorePassword, String defaultRedirectUrl, String userIDAttribute, Boolean useEncryption, Boolean createUser, Boolean addGroupMemberships, String groupMembershipAttribute, List<String> defaultGroups, String nameIdFormat, List<String> synchronizeAttributes, Boolean handleLogout, String logoutUrl, String clockTolerance, String digestMethod, String signatureMethod, String userIntermediatePath, List<String> propertylist, final ApiCallback<SamlConfigurationInformations> callback) throws ApiException {
"""
(asynchronously)
@param post (optional)
@param apply (optional)
@param delete (optional)
@param action (optional)
@param location (optional)
@param path (optional)
@param serviceRanking (optional)
@param idpUrl (optional)
@param idpCertAlias (optional)
@param idpHttpRedirect (optional)
@param serviceProviderEntityId (optional)
@param assertionConsumerServiceURL (optional)
@param spPrivateKeyAlias (optional)
@param keyStorePassword (optional)
@param defaultRedirectUrl (optional)
@param userIDAttribute (optional)
@param useEncryption (optional)
@param createUser (optional)
@param addGroupMemberships (optional)
@param groupMembershipAttribute (optional)
@param defaultGroups (optional)
@param nameIdFormat (optional)
@param synchronizeAttributes (optional)
@param handleLogout (optional)
@param logoutUrl (optional)
@param clockTolerance (optional)
@param digestMethod (optional)
@param signatureMethod (optional)
@param userIntermediatePath (optional)
@param propertylist (optional)
@param callback The callback to be executed when the API call finishes
@return The request call
@throws ApiException If fail to process the API call, e.g. serializing the request body object
"""
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
callback.onDownloadProgress(bytesRead, contentLength, done);
}
};
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
@Override
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
callback.onUploadProgress(bytesWritten, contentLength, done);
}
};
}
com.squareup.okhttp.Call call = postSamlConfigurationValidateBeforeCall(post, apply, delete, action, location, path, serviceRanking, idpUrl, idpCertAlias, idpHttpRedirect, serviceProviderEntityId, assertionConsumerServiceURL, spPrivateKeyAlias, keyStorePassword, defaultRedirectUrl, userIDAttribute, useEncryption, createUser, addGroupMemberships, groupMembershipAttribute, defaultGroups, nameIdFormat, synchronizeAttributes, handleLogout, logoutUrl, clockTolerance, digestMethod, signatureMethod, userIntermediatePath, propertylist, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken<SamlConfigurationInformations>(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
} | java | public com.squareup.okhttp.Call postSamlConfigurationAsync(Boolean post, Boolean apply, Boolean delete, String action, String location, List<String> path, String serviceRanking, String idpUrl, String idpCertAlias, Boolean idpHttpRedirect, String serviceProviderEntityId, String assertionConsumerServiceURL, String spPrivateKeyAlias, String keyStorePassword, String defaultRedirectUrl, String userIDAttribute, Boolean useEncryption, Boolean createUser, Boolean addGroupMemberships, String groupMembershipAttribute, List<String> defaultGroups, String nameIdFormat, List<String> synchronizeAttributes, Boolean handleLogout, String logoutUrl, String clockTolerance, String digestMethod, String signatureMethod, String userIntermediatePath, List<String> propertylist, final ApiCallback<SamlConfigurationInformations> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
callback.onDownloadProgress(bytesRead, contentLength, done);
}
};
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
@Override
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
callback.onUploadProgress(bytesWritten, contentLength, done);
}
};
}
com.squareup.okhttp.Call call = postSamlConfigurationValidateBeforeCall(post, apply, delete, action, location, path, serviceRanking, idpUrl, idpCertAlias, idpHttpRedirect, serviceProviderEntityId, assertionConsumerServiceURL, spPrivateKeyAlias, keyStorePassword, defaultRedirectUrl, userIDAttribute, useEncryption, createUser, addGroupMemberships, groupMembershipAttribute, defaultGroups, nameIdFormat, synchronizeAttributes, handleLogout, logoutUrl, clockTolerance, digestMethod, signatureMethod, userIntermediatePath, propertylist, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken<SamlConfigurationInformations>(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
} | [
"public",
"com",
".",
"squareup",
".",
"okhttp",
".",
"Call",
"postSamlConfigurationAsync",
"(",
"Boolean",
"post",
",",
"Boolean",
"apply",
",",
"Boolean",
"delete",
",",
"String",
"action",
",",
"String",
"location",
",",
"List",
"<",
"String",
">",
"path",
",",
"String",
"serviceRanking",
",",
"String",
"idpUrl",
",",
"String",
"idpCertAlias",
",",
"Boolean",
"idpHttpRedirect",
",",
"String",
"serviceProviderEntityId",
",",
"String",
"assertionConsumerServiceURL",
",",
"String",
"spPrivateKeyAlias",
",",
"String",
"keyStorePassword",
",",
"String",
"defaultRedirectUrl",
",",
"String",
"userIDAttribute",
",",
"Boolean",
"useEncryption",
",",
"Boolean",
"createUser",
",",
"Boolean",
"addGroupMemberships",
",",
"String",
"groupMembershipAttribute",
",",
"List",
"<",
"String",
">",
"defaultGroups",
",",
"String",
"nameIdFormat",
",",
"List",
"<",
"String",
">",
"synchronizeAttributes",
",",
"Boolean",
"handleLogout",
",",
"String",
"logoutUrl",
",",
"String",
"clockTolerance",
",",
"String",
"digestMethod",
",",
"String",
"signatureMethod",
",",
"String",
"userIntermediatePath",
",",
"List",
"<",
"String",
">",
"propertylist",
",",
"final",
"ApiCallback",
"<",
"SamlConfigurationInformations",
">",
"callback",
")",
"throws",
"ApiException",
"{",
"ProgressResponseBody",
".",
"ProgressListener",
"progressListener",
"=",
"null",
";",
"ProgressRequestBody",
".",
"ProgressRequestListener",
"progressRequestListener",
"=",
"null",
";",
"if",
"(",
"callback",
"!=",
"null",
")",
"{",
"progressListener",
"=",
"new",
"ProgressResponseBody",
".",
"ProgressListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"update",
"(",
"long",
"bytesRead",
",",
"long",
"contentLength",
",",
"boolean",
"done",
")",
"{",
"callback",
".",
"onDownloadProgress",
"(",
"bytesRead",
",",
"contentLength",
",",
"done",
")",
";",
"}",
"}",
";",
"progressRequestListener",
"=",
"new",
"ProgressRequestBody",
".",
"ProgressRequestListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onRequestProgress",
"(",
"long",
"bytesWritten",
",",
"long",
"contentLength",
",",
"boolean",
"done",
")",
"{",
"callback",
".",
"onUploadProgress",
"(",
"bytesWritten",
",",
"contentLength",
",",
"done",
")",
";",
"}",
"}",
";",
"}",
"com",
".",
"squareup",
".",
"okhttp",
".",
"Call",
"call",
"=",
"postSamlConfigurationValidateBeforeCall",
"(",
"post",
",",
"apply",
",",
"delete",
",",
"action",
",",
"location",
",",
"path",
",",
"serviceRanking",
",",
"idpUrl",
",",
"idpCertAlias",
",",
"idpHttpRedirect",
",",
"serviceProviderEntityId",
",",
"assertionConsumerServiceURL",
",",
"spPrivateKeyAlias",
",",
"keyStorePassword",
",",
"defaultRedirectUrl",
",",
"userIDAttribute",
",",
"useEncryption",
",",
"createUser",
",",
"addGroupMemberships",
",",
"groupMembershipAttribute",
",",
"defaultGroups",
",",
"nameIdFormat",
",",
"synchronizeAttributes",
",",
"handleLogout",
",",
"logoutUrl",
",",
"clockTolerance",
",",
"digestMethod",
",",
"signatureMethod",
",",
"userIntermediatePath",
",",
"propertylist",
",",
"progressListener",
",",
"progressRequestListener",
")",
";",
"Type",
"localVarReturnType",
"=",
"new",
"TypeToken",
"<",
"SamlConfigurationInformations",
">",
"(",
")",
"{",
"}",
".",
"getType",
"(",
")",
";",
"apiClient",
".",
"executeAsync",
"(",
"call",
",",
"localVarReturnType",
",",
"callback",
")",
";",
"return",
"call",
";",
"}"
] | (asynchronously)
@param post (optional)
@param apply (optional)
@param delete (optional)
@param action (optional)
@param location (optional)
@param path (optional)
@param serviceRanking (optional)
@param idpUrl (optional)
@param idpCertAlias (optional)
@param idpHttpRedirect (optional)
@param serviceProviderEntityId (optional)
@param assertionConsumerServiceURL (optional)
@param spPrivateKeyAlias (optional)
@param keyStorePassword (optional)
@param defaultRedirectUrl (optional)
@param userIDAttribute (optional)
@param useEncryption (optional)
@param createUser (optional)
@param addGroupMemberships (optional)
@param groupMembershipAttribute (optional)
@param defaultGroups (optional)
@param nameIdFormat (optional)
@param synchronizeAttributes (optional)
@param handleLogout (optional)
@param logoutUrl (optional)
@param clockTolerance (optional)
@param digestMethod (optional)
@param signatureMethod (optional)
@param userIntermediatePath (optional)
@param propertylist (optional)
@param callback The callback to be executed when the API call finishes
@return The request call
@throws ApiException If fail to process the API call, e.g. serializing the request body object | [
"(",
"asynchronously",
")"
] | train | https://github.com/shinesolutions/swagger-aem/blob/ae7da4df93e817dc2bad843779b2069d9c4e7c6b/java/generated/src/main/java/com/shinesolutions/swaggeraem4j/api/ConsoleApi.java#L585-L610 |
Jasig/uPortal | uPortal-groups/uPortal-groups-core/src/main/java/org/apereo/portal/services/GroupService.java | GroupService.findLockableGroup | public static ILockableEntityGroup findLockableGroup(String key, String lockOwner)
throws GroupsException {
"""
Returns a pre-existing <code>ILockableEntityGroup</code> or null if the group is not found.
@param key String - the group key.
@param lockOwner String - the owner of the lock, typically the user.
@return org.apereo.portal.groups.ILockableEntityGroup
"""
LOGGER.trace("Invoking findLockableGroup for key='{}', lockOwner='{}'", key, lockOwner);
return instance().ifindLockableGroup(key, lockOwner);
} | java | public static ILockableEntityGroup findLockableGroup(String key, String lockOwner)
throws GroupsException {
LOGGER.trace("Invoking findLockableGroup for key='{}', lockOwner='{}'", key, lockOwner);
return instance().ifindLockableGroup(key, lockOwner);
} | [
"public",
"static",
"ILockableEntityGroup",
"findLockableGroup",
"(",
"String",
"key",
",",
"String",
"lockOwner",
")",
"throws",
"GroupsException",
"{",
"LOGGER",
".",
"trace",
"(",
"\"Invoking findLockableGroup for key='{}', lockOwner='{}'\"",
",",
"key",
",",
"lockOwner",
")",
";",
"return",
"instance",
"(",
")",
".",
"ifindLockableGroup",
"(",
"key",
",",
"lockOwner",
")",
";",
"}"
] | Returns a pre-existing <code>ILockableEntityGroup</code> or null if the group is not found.
@param key String - the group key.
@param lockOwner String - the owner of the lock, typically the user.
@return org.apereo.portal.groups.ILockableEntityGroup | [
"Returns",
"a",
"pre",
"-",
"existing",
"<code",
">",
"ILockableEntityGroup<",
"/",
"code",
">",
"or",
"null",
"if",
"the",
"group",
"is",
"not",
"found",
"."
] | train | https://github.com/Jasig/uPortal/blob/c1986542abb9acd214268f2df21c6305ad2f262b/uPortal-groups/uPortal-groups-core/src/main/java/org/apereo/portal/services/GroupService.java#L91-L95 |
vladmihalcea/flexy-pool | flexy-pool-core/src/main/java/com/vladmihalcea/flexypool/util/LazyJndiResolver.java | LazyJndiResolver.newInstance | @SuppressWarnings("unchecked")
public static <T> T newInstance(String name, Class<?> objectType) {
"""
Creates a new Proxy instance
@param name JNDI name of the object to be lazily looked up
@param objectType object type
@param <T> typed parameter
@return Proxy object
"""
return (T) Proxy.newProxyInstance(
ClassLoaderUtils.getClassLoader(),
new Class[]{objectType},
new LazyJndiResolver(name));
} | java | @SuppressWarnings("unchecked")
public static <T> T newInstance(String name, Class<?> objectType) {
return (T) Proxy.newProxyInstance(
ClassLoaderUtils.getClassLoader(),
new Class[]{objectType},
new LazyJndiResolver(name));
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"T",
">",
"T",
"newInstance",
"(",
"String",
"name",
",",
"Class",
"<",
"?",
">",
"objectType",
")",
"{",
"return",
"(",
"T",
")",
"Proxy",
".",
"newProxyInstance",
"(",
"ClassLoaderUtils",
".",
"getClassLoader",
"(",
")",
",",
"new",
"Class",
"[",
"]",
"{",
"objectType",
"}",
",",
"new",
"LazyJndiResolver",
"(",
"name",
")",
")",
";",
"}"
] | Creates a new Proxy instance
@param name JNDI name of the object to be lazily looked up
@param objectType object type
@param <T> typed parameter
@return Proxy object | [
"Creates",
"a",
"new",
"Proxy",
"instance"
] | train | https://github.com/vladmihalcea/flexy-pool/blob/d763d359e68299c2b4e28e4b67770581ae083431/flexy-pool-core/src/main/java/com/vladmihalcea/flexypool/util/LazyJndiResolver.java#L60-L66 |
opentelecoms-org/jsmpp | jsmpp/src/main/java/org/jsmpp/util/RelativeTimeFormatter.java | RelativeTimeFormatter.format | public String format(Calendar calendar, Calendar smscCalendar) {
"""
Return the relative time from the calendar datetime against the SMSC datetime.
@param calendar the date.
@param smscCalendar the SMSC date.
@return The relative time between the calendar date and the SMSC calendar date.
"""
if (calendar == null || smscCalendar == null) {
return null;
}
long diffTimeInMillis = calendar.getTimeInMillis() - smscCalendar.getTimeInMillis();
if (diffTimeInMillis < 0) {
throw new IllegalArgumentException("The requested relative time has already past.");
}
// calculate period from epoch, this is not as accurate as Joda-Time Period class or Java 8 Period
Calendar offsetEpoch = Calendar.getInstance(utcTimeZone);
offsetEpoch.setTimeInMillis(diffTimeInMillis);
int years = offsetEpoch.get(Calendar.YEAR) - 1970;
int months = offsetEpoch.get(Calendar.MONTH);
int days = offsetEpoch.get(Calendar.DAY_OF_MONTH) - 1;
int hours = offsetEpoch.get(Calendar.HOUR_OF_DAY);
int minutes = offsetEpoch.get(Calendar.MINUTE);
int seconds = offsetEpoch.get(Calendar.SECOND);
if (years >= 100) {
throw new IllegalArgumentException("The requested relative time is more then a century (" + years + " years).");
}
return format(years, months, days, hours, minutes, seconds);
} | java | public String format(Calendar calendar, Calendar smscCalendar) {
if (calendar == null || smscCalendar == null) {
return null;
}
long diffTimeInMillis = calendar.getTimeInMillis() - smscCalendar.getTimeInMillis();
if (diffTimeInMillis < 0) {
throw new IllegalArgumentException("The requested relative time has already past.");
}
// calculate period from epoch, this is not as accurate as Joda-Time Period class or Java 8 Period
Calendar offsetEpoch = Calendar.getInstance(utcTimeZone);
offsetEpoch.setTimeInMillis(diffTimeInMillis);
int years = offsetEpoch.get(Calendar.YEAR) - 1970;
int months = offsetEpoch.get(Calendar.MONTH);
int days = offsetEpoch.get(Calendar.DAY_OF_MONTH) - 1;
int hours = offsetEpoch.get(Calendar.HOUR_OF_DAY);
int minutes = offsetEpoch.get(Calendar.MINUTE);
int seconds = offsetEpoch.get(Calendar.SECOND);
if (years >= 100) {
throw new IllegalArgumentException("The requested relative time is more then a century (" + years + " years).");
}
return format(years, months, days, hours, minutes, seconds);
} | [
"public",
"String",
"format",
"(",
"Calendar",
"calendar",
",",
"Calendar",
"smscCalendar",
")",
"{",
"if",
"(",
"calendar",
"==",
"null",
"||",
"smscCalendar",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"long",
"diffTimeInMillis",
"=",
"calendar",
".",
"getTimeInMillis",
"(",
")",
"-",
"smscCalendar",
".",
"getTimeInMillis",
"(",
")",
";",
"if",
"(",
"diffTimeInMillis",
"<",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The requested relative time has already past.\"",
")",
";",
"}",
"// calculate period from epoch, this is not as accurate as Joda-Time Period class or Java 8 Period",
"Calendar",
"offsetEpoch",
"=",
"Calendar",
".",
"getInstance",
"(",
"utcTimeZone",
")",
";",
"offsetEpoch",
".",
"setTimeInMillis",
"(",
"diffTimeInMillis",
")",
";",
"int",
"years",
"=",
"offsetEpoch",
".",
"get",
"(",
"Calendar",
".",
"YEAR",
")",
"-",
"1970",
";",
"int",
"months",
"=",
"offsetEpoch",
".",
"get",
"(",
"Calendar",
".",
"MONTH",
")",
";",
"int",
"days",
"=",
"offsetEpoch",
".",
"get",
"(",
"Calendar",
".",
"DAY_OF_MONTH",
")",
"-",
"1",
";",
"int",
"hours",
"=",
"offsetEpoch",
".",
"get",
"(",
"Calendar",
".",
"HOUR_OF_DAY",
")",
";",
"int",
"minutes",
"=",
"offsetEpoch",
".",
"get",
"(",
"Calendar",
".",
"MINUTE",
")",
";",
"int",
"seconds",
"=",
"offsetEpoch",
".",
"get",
"(",
"Calendar",
".",
"SECOND",
")",
";",
"if",
"(",
"years",
">=",
"100",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The requested relative time is more then a century (\"",
"+",
"years",
"+",
"\" years).\"",
")",
";",
"}",
"return",
"format",
"(",
"years",
",",
"months",
",",
"days",
",",
"hours",
",",
"minutes",
",",
"seconds",
")",
";",
"}"
] | Return the relative time from the calendar datetime against the SMSC datetime.
@param calendar the date.
@param smscCalendar the SMSC date.
@return The relative time between the calendar date and the SMSC calendar date. | [
"Return",
"the",
"relative",
"time",
"from",
"the",
"calendar",
"datetime",
"against",
"the",
"SMSC",
"datetime",
"."
] | train | https://github.com/opentelecoms-org/jsmpp/blob/acc15e73e7431deabc803731971b15323315baaf/jsmpp/src/main/java/org/jsmpp/util/RelativeTimeFormatter.java#L64-L89 |
scireum/parsii | src/main/java/parsii/eval/Parser.java | Parser.reOrder | protected Expression reOrder(Expression left, Expression right, BinaryOperation.Op op) {
"""
/*
Reorders the operands of the given operation in order to generate a "left handed" AST which performs evaluations
in natural order (from left to right).
"""
if (right instanceof BinaryOperation) {
BinaryOperation rightOp = (BinaryOperation) right;
if (!rightOp.isSealed() && rightOp.getOp().getPriority() == op.getPriority()) {
replaceLeft(rightOp, left, op);
return right;
}
}
return new BinaryOperation(op, left, right);
} | java | protected Expression reOrder(Expression left, Expression right, BinaryOperation.Op op) {
if (right instanceof BinaryOperation) {
BinaryOperation rightOp = (BinaryOperation) right;
if (!rightOp.isSealed() && rightOp.getOp().getPriority() == op.getPriority()) {
replaceLeft(rightOp, left, op);
return right;
}
}
return new BinaryOperation(op, left, right);
} | [
"protected",
"Expression",
"reOrder",
"(",
"Expression",
"left",
",",
"Expression",
"right",
",",
"BinaryOperation",
".",
"Op",
"op",
")",
"{",
"if",
"(",
"right",
"instanceof",
"BinaryOperation",
")",
"{",
"BinaryOperation",
"rightOp",
"=",
"(",
"BinaryOperation",
")",
"right",
";",
"if",
"(",
"!",
"rightOp",
".",
"isSealed",
"(",
")",
"&&",
"rightOp",
".",
"getOp",
"(",
")",
".",
"getPriority",
"(",
")",
"==",
"op",
".",
"getPriority",
"(",
")",
")",
"{",
"replaceLeft",
"(",
"rightOp",
",",
"left",
",",
"op",
")",
";",
"return",
"right",
";",
"}",
"}",
"return",
"new",
"BinaryOperation",
"(",
"op",
",",
"left",
",",
"right",
")",
";",
"}"
] | /*
Reorders the operands of the given operation in order to generate a "left handed" AST which performs evaluations
in natural order (from left to right). | [
"/",
"*",
"Reorders",
"the",
"operands",
"of",
"the",
"given",
"operation",
"in",
"order",
"to",
"generate",
"a",
"left",
"handed",
"AST",
"which",
"performs",
"evaluations",
"in",
"natural",
"order",
"(",
"from",
"left",
"to",
"right",
")",
"."
] | train | https://github.com/scireum/parsii/blob/fbf686155b1147b9e07ae21dcd02820b15c79a8c/src/main/java/parsii/eval/Parser.java#L299-L308 |
Javen205/IJPay | src/main/java/com/jpay/util/IOUtils.java | IOUtils.toFile | public static void toFile(InputStream input, File file) throws IOException {
"""
InputStream to File
@param input the <code>InputStream</code> to read from
@param file the File to write
@throws IOException id异常
"""
OutputStream os = new FileOutputStream(file);
int bytesRead = 0;
byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
while ((bytesRead = input.read(buffer, 0, DEFAULT_BUFFER_SIZE)) != -1) {
os.write(buffer, 0, bytesRead);
}
IOUtils.closeQuietly(os);
IOUtils.closeQuietly(input);
} | java | public static void toFile(InputStream input, File file) throws IOException {
OutputStream os = new FileOutputStream(file);
int bytesRead = 0;
byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
while ((bytesRead = input.read(buffer, 0, DEFAULT_BUFFER_SIZE)) != -1) {
os.write(buffer, 0, bytesRead);
}
IOUtils.closeQuietly(os);
IOUtils.closeQuietly(input);
} | [
"public",
"static",
"void",
"toFile",
"(",
"InputStream",
"input",
",",
"File",
"file",
")",
"throws",
"IOException",
"{",
"OutputStream",
"os",
"=",
"new",
"FileOutputStream",
"(",
"file",
")",
";",
"int",
"bytesRead",
"=",
"0",
";",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"DEFAULT_BUFFER_SIZE",
"]",
";",
"while",
"(",
"(",
"bytesRead",
"=",
"input",
".",
"read",
"(",
"buffer",
",",
"0",
",",
"DEFAULT_BUFFER_SIZE",
")",
")",
"!=",
"-",
"1",
")",
"{",
"os",
".",
"write",
"(",
"buffer",
",",
"0",
",",
"bytesRead",
")",
";",
"}",
"IOUtils",
".",
"closeQuietly",
"(",
"os",
")",
";",
"IOUtils",
".",
"closeQuietly",
"(",
"input",
")",
";",
"}"
] | InputStream to File
@param input the <code>InputStream</code> to read from
@param file the File to write
@throws IOException id异常 | [
"InputStream",
"to",
"File"
] | train | https://github.com/Javen205/IJPay/blob/78da6be4b70675abc6a41df74817532fa257ef29/src/main/java/com/jpay/util/IOUtils.java#L66-L75 |
maven-nar/nar-maven-plugin | src/main/java/com/github/maven_nar/cpptasks/msvc/MsvcProjectWriter.java | MsvcProjectWriter.getSources | private File[] getSources(final List<File> sourceList) {
"""
Get alphabetized array of source files.
@param sourceList
list of source files
@return File[] source files
"""
final File[] sortedSources = new File[sourceList.size()];
sourceList.toArray(sortedSources);
Arrays.sort(sortedSources, new Comparator<File>() {
@Override
public int compare(final File o1, final File o2) {
return o1.getName().compareTo(o2.getName());
}
});
return sortedSources;
} | java | private File[] getSources(final List<File> sourceList) {
final File[] sortedSources = new File[sourceList.size()];
sourceList.toArray(sortedSources);
Arrays.sort(sortedSources, new Comparator<File>() {
@Override
public int compare(final File o1, final File o2) {
return o1.getName().compareTo(o2.getName());
}
});
return sortedSources;
} | [
"private",
"File",
"[",
"]",
"getSources",
"(",
"final",
"List",
"<",
"File",
">",
"sourceList",
")",
"{",
"final",
"File",
"[",
"]",
"sortedSources",
"=",
"new",
"File",
"[",
"sourceList",
".",
"size",
"(",
")",
"]",
";",
"sourceList",
".",
"toArray",
"(",
"sortedSources",
")",
";",
"Arrays",
".",
"sort",
"(",
"sortedSources",
",",
"new",
"Comparator",
"<",
"File",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"int",
"compare",
"(",
"final",
"File",
"o1",
",",
"final",
"File",
"o2",
")",
"{",
"return",
"o1",
".",
"getName",
"(",
")",
".",
"compareTo",
"(",
"o2",
".",
"getName",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"return",
"sortedSources",
";",
"}"
] | Get alphabetized array of source files.
@param sourceList
list of source files
@return File[] source files | [
"Get",
"alphabetized",
"array",
"of",
"source",
"files",
"."
] | train | https://github.com/maven-nar/nar-maven-plugin/blob/3c622e2024296b4203431bbae3bde290a01dac00/src/main/java/com/github/maven_nar/cpptasks/msvc/MsvcProjectWriter.java#L163-L173 |
bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/crypto/HDUtils.java | HDUtils.parsePath | public static List<ChildNumber> parsePath(@Nonnull String path) {
"""
The path is a human-friendly representation of the deterministic path. For example:
"44H / 0H / 0H / 1 / 1"
Where a letter "H" means hardened key. Spaces are ignored.
"""
String[] parsedNodes = path.replace("M", "").split("/");
List<ChildNumber> nodes = new ArrayList<>();
for (String n : parsedNodes) {
n = n.replaceAll(" ", "");
if (n.length() == 0) continue;
boolean isHard = n.endsWith("H");
if (isHard) n = n.substring(0, n.length() - 1);
int nodeNumber = Integer.parseInt(n);
nodes.add(new ChildNumber(nodeNumber, isHard));
}
return nodes;
} | java | public static List<ChildNumber> parsePath(@Nonnull String path) {
String[] parsedNodes = path.replace("M", "").split("/");
List<ChildNumber> nodes = new ArrayList<>();
for (String n : parsedNodes) {
n = n.replaceAll(" ", "");
if (n.length() == 0) continue;
boolean isHard = n.endsWith("H");
if (isHard) n = n.substring(0, n.length() - 1);
int nodeNumber = Integer.parseInt(n);
nodes.add(new ChildNumber(nodeNumber, isHard));
}
return nodes;
} | [
"public",
"static",
"List",
"<",
"ChildNumber",
">",
"parsePath",
"(",
"@",
"Nonnull",
"String",
"path",
")",
"{",
"String",
"[",
"]",
"parsedNodes",
"=",
"path",
".",
"replace",
"(",
"\"M\"",
",",
"\"\"",
")",
".",
"split",
"(",
"\"/\"",
")",
";",
"List",
"<",
"ChildNumber",
">",
"nodes",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"String",
"n",
":",
"parsedNodes",
")",
"{",
"n",
"=",
"n",
".",
"replaceAll",
"(",
"\" \"",
",",
"\"\"",
")",
";",
"if",
"(",
"n",
".",
"length",
"(",
")",
"==",
"0",
")",
"continue",
";",
"boolean",
"isHard",
"=",
"n",
".",
"endsWith",
"(",
"\"H\"",
")",
";",
"if",
"(",
"isHard",
")",
"n",
"=",
"n",
".",
"substring",
"(",
"0",
",",
"n",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"int",
"nodeNumber",
"=",
"Integer",
".",
"parseInt",
"(",
"n",
")",
";",
"nodes",
".",
"add",
"(",
"new",
"ChildNumber",
"(",
"nodeNumber",
",",
"isHard",
")",
")",
";",
"}",
"return",
"nodes",
";",
"}"
] | The path is a human-friendly representation of the deterministic path. For example:
"44H / 0H / 0H / 1 / 1"
Where a letter "H" means hardened key. Spaces are ignored. | [
"The",
"path",
"is",
"a",
"human",
"-",
"friendly",
"representation",
"of",
"the",
"deterministic",
"path",
".",
"For",
"example",
":"
] | train | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/crypto/HDUtils.java#L92-L106 |
google/j2objc | jre_emul/android/frameworks/base/core/java/com/android/internal/util/ArrayUtils.java | ArrayUtils.containsAll | public static <T> boolean containsAll(T[] array, T[] check) {
"""
Test if all {@code check} items are contained in {@code array}.
"""
for (T checkItem : check) {
if (!contains(array, checkItem)) {
return false;
}
}
return true;
} | java | public static <T> boolean containsAll(T[] array, T[] check) {
for (T checkItem : check) {
if (!contains(array, checkItem)) {
return false;
}
}
return true;
} | [
"public",
"static",
"<",
"T",
">",
"boolean",
"containsAll",
"(",
"T",
"[",
"]",
"array",
",",
"T",
"[",
"]",
"check",
")",
"{",
"for",
"(",
"T",
"checkItem",
":",
"check",
")",
"{",
"if",
"(",
"!",
"contains",
"(",
"array",
",",
"checkItem",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Test if all {@code check} items are contained in {@code array}. | [
"Test",
"if",
"all",
"{"
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/frameworks/base/core/java/com/android/internal/util/ArrayUtils.java#L151-L158 |
Omertron/api-themoviedb | src/main/java/com/omertron/themoviedbapi/methods/TmdbMovies.java | TmdbMovies.getSimilarMovies | public ResultList<MovieInfo> getSimilarMovies(int movieId, Integer page, String language) throws MovieDbException {
"""
The similar movies method will let you retrieve the similar movies for a particular movie.
This data is created dynamically but with the help of users votes on TMDb.
The data is much better with movies that have more keywords
@param movieId
@param language
@param page
@return
@throws MovieDbException
"""
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, movieId);
parameters.add(Param.LANGUAGE, language);
parameters.add(Param.PAGE, page);
URL url = new ApiUrl(apiKey, MethodBase.MOVIE).subMethod(MethodSub.SIMILAR).buildUrl(parameters);
WrapperGenericList<MovieInfo> wrapper = processWrapper(getTypeReference(MovieInfo.class), url, "similar movies");
return wrapper.getResultsList();
} | java | public ResultList<MovieInfo> getSimilarMovies(int movieId, Integer page, String language) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, movieId);
parameters.add(Param.LANGUAGE, language);
parameters.add(Param.PAGE, page);
URL url = new ApiUrl(apiKey, MethodBase.MOVIE).subMethod(MethodSub.SIMILAR).buildUrl(parameters);
WrapperGenericList<MovieInfo> wrapper = processWrapper(getTypeReference(MovieInfo.class), url, "similar movies");
return wrapper.getResultsList();
} | [
"public",
"ResultList",
"<",
"MovieInfo",
">",
"getSimilarMovies",
"(",
"int",
"movieId",
",",
"Integer",
"page",
",",
"String",
"language",
")",
"throws",
"MovieDbException",
"{",
"TmdbParameters",
"parameters",
"=",
"new",
"TmdbParameters",
"(",
")",
";",
"parameters",
".",
"add",
"(",
"Param",
".",
"ID",
",",
"movieId",
")",
";",
"parameters",
".",
"add",
"(",
"Param",
".",
"LANGUAGE",
",",
"language",
")",
";",
"parameters",
".",
"add",
"(",
"Param",
".",
"PAGE",
",",
"page",
")",
";",
"URL",
"url",
"=",
"new",
"ApiUrl",
"(",
"apiKey",
",",
"MethodBase",
".",
"MOVIE",
")",
".",
"subMethod",
"(",
"MethodSub",
".",
"SIMILAR",
")",
".",
"buildUrl",
"(",
"parameters",
")",
";",
"WrapperGenericList",
"<",
"MovieInfo",
">",
"wrapper",
"=",
"processWrapper",
"(",
"getTypeReference",
"(",
"MovieInfo",
".",
"class",
")",
",",
"url",
",",
"\"similar movies\"",
")",
";",
"return",
"wrapper",
".",
"getResultsList",
"(",
")",
";",
"}"
] | The similar movies method will let you retrieve the similar movies for a particular movie.
This data is created dynamically but with the help of users votes on TMDb.
The data is much better with movies that have more keywords
@param movieId
@param language
@param page
@return
@throws MovieDbException | [
"The",
"similar",
"movies",
"method",
"will",
"let",
"you",
"retrieve",
"the",
"similar",
"movies",
"for",
"a",
"particular",
"movie",
"."
] | train | https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbMovies.java#L392-L401 |
threerings/narya | core/src/main/java/com/threerings/presents/client/ClientDObjectMgr.java | ClientDObjectMgr.notifyFailure | protected void notifyFailure (int oid, String message) {
"""
Notifies the subscribers that had requested this object (for subscription) that it is not
available.
"""
// let the penders know that the object is not available
PendingRequest<?> req = _penders.remove(oid);
if (req == null) {
log.warning("Failed to get object, but no one cares?!", "oid", oid);
return;
}
for (int ii = 0; ii < req.targets.size(); ii++) {
req.targets.get(ii).requestFailed(oid, new ObjectAccessException(message));
}
} | java | protected void notifyFailure (int oid, String message)
{
// let the penders know that the object is not available
PendingRequest<?> req = _penders.remove(oid);
if (req == null) {
log.warning("Failed to get object, but no one cares?!", "oid", oid);
return;
}
for (int ii = 0; ii < req.targets.size(); ii++) {
req.targets.get(ii).requestFailed(oid, new ObjectAccessException(message));
}
} | [
"protected",
"void",
"notifyFailure",
"(",
"int",
"oid",
",",
"String",
"message",
")",
"{",
"// let the penders know that the object is not available",
"PendingRequest",
"<",
"?",
">",
"req",
"=",
"_penders",
".",
"remove",
"(",
"oid",
")",
";",
"if",
"(",
"req",
"==",
"null",
")",
"{",
"log",
".",
"warning",
"(",
"\"Failed to get object, but no one cares?!\"",
",",
"\"oid\"",
",",
"oid",
")",
";",
"return",
";",
"}",
"for",
"(",
"int",
"ii",
"=",
"0",
";",
"ii",
"<",
"req",
".",
"targets",
".",
"size",
"(",
")",
";",
"ii",
"++",
")",
"{",
"req",
".",
"targets",
".",
"get",
"(",
"ii",
")",
".",
"requestFailed",
"(",
"oid",
",",
"new",
"ObjectAccessException",
"(",
"message",
")",
")",
";",
"}",
"}"
] | Notifies the subscribers that had requested this object (for subscription) that it is not
available. | [
"Notifies",
"the",
"subscribers",
"that",
"had",
"requested",
"this",
"object",
"(",
"for",
"subscription",
")",
"that",
"it",
"is",
"not",
"available",
"."
] | train | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/client/ClientDObjectMgr.java#L379-L391 |
facebookarchive/hadoop-20 | src/core/org/apache/hadoop/util/UTF8ByteArrayUtils.java | UTF8ByteArrayUtils.findNthByte | public static int findNthByte(byte [] utf, int start, int length, byte b, int n) {
"""
Find the nth occurrence of the given byte b in a UTF-8 encoded string
@param utf a byte array containing a UTF-8 encoded string
@param start starting offset
@param length the length of byte array
@param b the byte to find
@param n the desired occurrence of the given byte
@return position that nth occurrence of the given byte if exists; otherwise -1
"""
int pos = -1;
int nextStart = start;
for (int i = 0; i < n; i++) {
pos = findByte(utf, nextStart, length, b);
if (pos < 0) {
return pos;
}
nextStart = pos + 1;
}
return pos;
} | java | public static int findNthByte(byte [] utf, int start, int length, byte b, int n) {
int pos = -1;
int nextStart = start;
for (int i = 0; i < n; i++) {
pos = findByte(utf, nextStart, length, b);
if (pos < 0) {
return pos;
}
nextStart = pos + 1;
}
return pos;
} | [
"public",
"static",
"int",
"findNthByte",
"(",
"byte",
"[",
"]",
"utf",
",",
"int",
"start",
",",
"int",
"length",
",",
"byte",
"b",
",",
"int",
"n",
")",
"{",
"int",
"pos",
"=",
"-",
"1",
";",
"int",
"nextStart",
"=",
"start",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"pos",
"=",
"findByte",
"(",
"utf",
",",
"nextStart",
",",
"length",
",",
"b",
")",
";",
"if",
"(",
"pos",
"<",
"0",
")",
"{",
"return",
"pos",
";",
"}",
"nextStart",
"=",
"pos",
"+",
"1",
";",
"}",
"return",
"pos",
";",
"}"
] | Find the nth occurrence of the given byte b in a UTF-8 encoded string
@param utf a byte array containing a UTF-8 encoded string
@param start starting offset
@param length the length of byte array
@param b the byte to find
@param n the desired occurrence of the given byte
@return position that nth occurrence of the given byte if exists; otherwise -1 | [
"Find",
"the",
"nth",
"occurrence",
"of",
"the",
"given",
"byte",
"b",
"in",
"a",
"UTF",
"-",
"8",
"encoded",
"string"
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/core/org/apache/hadoop/util/UTF8ByteArrayUtils.java#L73-L84 |
Azure/azure-sdk-for-java | iothub/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/iothub/v2018_04_01/implementation/CertificatesInner.java | CertificatesInner.getAsync | public Observable<CertificateDescriptionInner> getAsync(String resourceGroupName, String resourceName, String certificateName) {
"""
Get the certificate.
Returns the certificate.
@param resourceGroupName The name of the resource group that contains the IoT hub.
@param resourceName The name of the IoT hub.
@param certificateName The name of the certificate
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the CertificateDescriptionInner object
"""
return getWithServiceResponseAsync(resourceGroupName, resourceName, certificateName).map(new Func1<ServiceResponse<CertificateDescriptionInner>, CertificateDescriptionInner>() {
@Override
public CertificateDescriptionInner call(ServiceResponse<CertificateDescriptionInner> response) {
return response.body();
}
});
} | java | public Observable<CertificateDescriptionInner> getAsync(String resourceGroupName, String resourceName, String certificateName) {
return getWithServiceResponseAsync(resourceGroupName, resourceName, certificateName).map(new Func1<ServiceResponse<CertificateDescriptionInner>, CertificateDescriptionInner>() {
@Override
public CertificateDescriptionInner call(ServiceResponse<CertificateDescriptionInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"CertificateDescriptionInner",
">",
"getAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"resourceName",
",",
"String",
"certificateName",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"resourceName",
",",
"certificateName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"CertificateDescriptionInner",
">",
",",
"CertificateDescriptionInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"CertificateDescriptionInner",
"call",
"(",
"ServiceResponse",
"<",
"CertificateDescriptionInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Get the certificate.
Returns the certificate.
@param resourceGroupName The name of the resource group that contains the IoT hub.
@param resourceName The name of the IoT hub.
@param certificateName The name of the certificate
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the CertificateDescriptionInner object | [
"Get",
"the",
"certificate",
".",
"Returns",
"the",
"certificate",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/iothub/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/iothub/v2018_04_01/implementation/CertificatesInner.java#L217-L224 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-util/src/main/java/org/deeplearning4j/util/Dl4jReflection.java | Dl4jReflection.getFieldsAsProperties | public static Properties getFieldsAsProperties(Object obj, Class<?>[] clazzes) throws Exception {
"""
Get fields as properties
@param obj the object to get fields for
@param clazzes the classes to use for reflection and properties.
T
@return the fields as properties
"""
Properties props = new Properties();
for (Field field : obj.getClass().getDeclaredFields()) {
if (Modifier.isStatic(field.getModifiers()))
continue;
field.setAccessible(true);
Class<?> type = field.getType();
if (clazzes == null || contains(type, clazzes)) {
Object val = field.get(obj);
if (val != null)
props.put(field.getName(), val.toString());
}
}
return props;
} | java | public static Properties getFieldsAsProperties(Object obj, Class<?>[] clazzes) throws Exception {
Properties props = new Properties();
for (Field field : obj.getClass().getDeclaredFields()) {
if (Modifier.isStatic(field.getModifiers()))
continue;
field.setAccessible(true);
Class<?> type = field.getType();
if (clazzes == null || contains(type, clazzes)) {
Object val = field.get(obj);
if (val != null)
props.put(field.getName(), val.toString());
}
}
return props;
} | [
"public",
"static",
"Properties",
"getFieldsAsProperties",
"(",
"Object",
"obj",
",",
"Class",
"<",
"?",
">",
"[",
"]",
"clazzes",
")",
"throws",
"Exception",
"{",
"Properties",
"props",
"=",
"new",
"Properties",
"(",
")",
";",
"for",
"(",
"Field",
"field",
":",
"obj",
".",
"getClass",
"(",
")",
".",
"getDeclaredFields",
"(",
")",
")",
"{",
"if",
"(",
"Modifier",
".",
"isStatic",
"(",
"field",
".",
"getModifiers",
"(",
")",
")",
")",
"continue",
";",
"field",
".",
"setAccessible",
"(",
"true",
")",
";",
"Class",
"<",
"?",
">",
"type",
"=",
"field",
".",
"getType",
"(",
")",
";",
"if",
"(",
"clazzes",
"==",
"null",
"||",
"contains",
"(",
"type",
",",
"clazzes",
")",
")",
"{",
"Object",
"val",
"=",
"field",
".",
"get",
"(",
"obj",
")",
";",
"if",
"(",
"val",
"!=",
"null",
")",
"props",
".",
"put",
"(",
"field",
".",
"getName",
"(",
")",
",",
"val",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"return",
"props",
";",
"}"
] | Get fields as properties
@param obj the object to get fields for
@param clazzes the classes to use for reflection and properties.
T
@return the fields as properties | [
"Get",
"fields",
"as",
"properties"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-util/src/main/java/org/deeplearning4j/util/Dl4jReflection.java#L106-L122 |
UrielCh/ovh-java-sdk | ovh-java-sdk-sms/src/main/java/net/minidev/ovh/api/ApiOvhSms.java | ApiOvhSms.serviceName_virtualNumbers_number_chatAccess_GET | public OvhChatAccess serviceName_virtualNumbers_number_chatAccess_GET(String serviceName, String number) throws IOException {
"""
Get this object properties
REST: GET /sms/{serviceName}/virtualNumbers/{number}/chatAccess
@param serviceName [required] The internal name of your SMS offer
@param number [required] The virtual number
"""
String qPath = "/sms/{serviceName}/virtualNumbers/{number}/chatAccess";
StringBuilder sb = path(qPath, serviceName, number);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhChatAccess.class);
} | java | public OvhChatAccess serviceName_virtualNumbers_number_chatAccess_GET(String serviceName, String number) throws IOException {
String qPath = "/sms/{serviceName}/virtualNumbers/{number}/chatAccess";
StringBuilder sb = path(qPath, serviceName, number);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhChatAccess.class);
} | [
"public",
"OvhChatAccess",
"serviceName_virtualNumbers_number_chatAccess_GET",
"(",
"String",
"serviceName",
",",
"String",
"number",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/sms/{serviceName}/virtualNumbers/{number}/chatAccess\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"number",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhChatAccess",
".",
"class",
")",
";",
"}"
] | Get this object properties
REST: GET /sms/{serviceName}/virtualNumbers/{number}/chatAccess
@param serviceName [required] The internal name of your SMS offer
@param number [required] The virtual number | [
"Get",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-sms/src/main/java/net/minidev/ovh/api/ApiOvhSms.java#L471-L476 |
stapler/stapler | groovy/src/main/java/org/kohsuke/stapler/jelly/groovy/SimpleTemplateParser.java | SimpleTemplateParser.groovySection | private void groovySection(Reader reader, StringWriter sw) throws IOException {
"""
Closes the currently open write and writes the following text as normal Groovy script code until it reaches an end %>.
@param reader a reader for the template text
@param sw a StringWriter to write expression content
@throws IOException if something goes wrong
"""
sw.write("\"\"\");");
int c;
while ((c = reader.read()) != -1) {
if (c == '%') {
c = reader.read();
if (c != '>') {
sw.write('%');
} else {
break;
}
}
/* Don't eat EOL chars in sections - as they are valid instruction separators.
* See http://jira.codehaus.org/browse/GROOVY-980
*/
// if (c != '\n' && c != '\r') {
sw.write(c);
//}
}
sw.write(";\n"+printCommand()+"(\"\"\"");
} | java | private void groovySection(Reader reader, StringWriter sw) throws IOException {
sw.write("\"\"\");");
int c;
while ((c = reader.read()) != -1) {
if (c == '%') {
c = reader.read();
if (c != '>') {
sw.write('%');
} else {
break;
}
}
/* Don't eat EOL chars in sections - as they are valid instruction separators.
* See http://jira.codehaus.org/browse/GROOVY-980
*/
// if (c != '\n' && c != '\r') {
sw.write(c);
//}
}
sw.write(";\n"+printCommand()+"(\"\"\"");
} | [
"private",
"void",
"groovySection",
"(",
"Reader",
"reader",
",",
"StringWriter",
"sw",
")",
"throws",
"IOException",
"{",
"sw",
".",
"write",
"(",
"\"\\\"\\\"\\\");\"",
")",
";",
"int",
"c",
";",
"while",
"(",
"(",
"c",
"=",
"reader",
".",
"read",
"(",
")",
")",
"!=",
"-",
"1",
")",
"{",
"if",
"(",
"c",
"==",
"'",
"'",
")",
"{",
"c",
"=",
"reader",
".",
"read",
"(",
")",
";",
"if",
"(",
"c",
"!=",
"'",
"'",
")",
"{",
"sw",
".",
"write",
"(",
"'",
"'",
")",
";",
"}",
"else",
"{",
"break",
";",
"}",
"}",
"/* Don't eat EOL chars in sections - as they are valid instruction separators.\n * See http://jira.codehaus.org/browse/GROOVY-980\n */",
"// if (c != '\\n' && c != '\\r') {",
"sw",
".",
"write",
"(",
"c",
")",
";",
"//}",
"}",
"sw",
".",
"write",
"(",
"\";\\n\"",
"+",
"printCommand",
"(",
")",
"+",
"\"(\\\"\\\"\\\"\"",
")",
";",
"}"
] | Closes the currently open write and writes the following text as normal Groovy script code until it reaches an end %>.
@param reader a reader for the template text
@param sw a StringWriter to write expression content
@throws IOException if something goes wrong | [
"Closes",
"the",
"currently",
"open",
"write",
"and",
"writes",
"the",
"following",
"text",
"as",
"normal",
"Groovy",
"script",
"code",
"until",
"it",
"reaches",
"an",
"end",
"%",
">",
"."
] | train | https://github.com/stapler/stapler/blob/11ad5af185e062fb46e01bf9fbed66f3ebf2a8f7/groovy/src/main/java/org/kohsuke/stapler/jelly/groovy/SimpleTemplateParser.java#L161-L181 |
EdwardRaff/JSAT | JSAT/src/jsat/classifiers/neuralnetwork/BackPropagationNet.java | BackPropagationNet.feedForward | private void feedForward(Vec input, List<Vec> activations, List<Vec> derivatives) {
"""
Feeds a vector through the network to get an output
@param input the input to feed forward though the network
@param activations the list of allocated vectors to store the activation
outputs for each layer
@param derivatives the list of allocated vectors to store the derivatives
of the activations
"""
Vec x = input;
for(int i = 0; i < Ws.size(); i++)
{
Matrix W_i = Ws.get(i);
Vec b_i = bs.get(i);
Vec a_i = activations.get(i);
a_i.zeroOut();
W_i.multiply(x, 1, a_i);
a_i.mutableAdd(b_i);
a_i.applyFunction(f);
Vec d_i = derivatives.get(i);
a_i.copyTo(d_i);
d_i.applyFunction(f.getD());
x = a_i;
}
} | java | private void feedForward(Vec input, List<Vec> activations, List<Vec> derivatives)
{
Vec x = input;
for(int i = 0; i < Ws.size(); i++)
{
Matrix W_i = Ws.get(i);
Vec b_i = bs.get(i);
Vec a_i = activations.get(i);
a_i.zeroOut();
W_i.multiply(x, 1, a_i);
a_i.mutableAdd(b_i);
a_i.applyFunction(f);
Vec d_i = derivatives.get(i);
a_i.copyTo(d_i);
d_i.applyFunction(f.getD());
x = a_i;
}
} | [
"private",
"void",
"feedForward",
"(",
"Vec",
"input",
",",
"List",
"<",
"Vec",
">",
"activations",
",",
"List",
"<",
"Vec",
">",
"derivatives",
")",
"{",
"Vec",
"x",
"=",
"input",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"Ws",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"Matrix",
"W_i",
"=",
"Ws",
".",
"get",
"(",
"i",
")",
";",
"Vec",
"b_i",
"=",
"bs",
".",
"get",
"(",
"i",
")",
";",
"Vec",
"a_i",
"=",
"activations",
".",
"get",
"(",
"i",
")",
";",
"a_i",
".",
"zeroOut",
"(",
")",
";",
"W_i",
".",
"multiply",
"(",
"x",
",",
"1",
",",
"a_i",
")",
";",
"a_i",
".",
"mutableAdd",
"(",
"b_i",
")",
";",
"a_i",
".",
"applyFunction",
"(",
"f",
")",
";",
"Vec",
"d_i",
"=",
"derivatives",
".",
"get",
"(",
"i",
")",
";",
"a_i",
".",
"copyTo",
"(",
"d_i",
")",
";",
"d_i",
".",
"applyFunction",
"(",
"f",
".",
"getD",
"(",
")",
")",
";",
"x",
"=",
"a_i",
";",
"}",
"}"
] | Feeds a vector through the network to get an output
@param input the input to feed forward though the network
@param activations the list of allocated vectors to store the activation
outputs for each layer
@param derivatives the list of allocated vectors to store the derivatives
of the activations | [
"Feeds",
"a",
"vector",
"through",
"the",
"network",
"to",
"get",
"an",
"output"
] | train | https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/neuralnetwork/BackPropagationNet.java#L826-L847 |
MythTV-Clients/MythTV-Service-API | src/main/java/org/mythtv/services/api/ServerVersionQuery.java | ServerVersionQuery.isServerReachable | public static boolean isServerReachable(String baseUrl, long connectTimeout, TimeUnit timeUnit) throws IOException {
"""
Check if the server is reachable
@param baseUrl The url of the server to test
@param connectTimeout connection timeout
@param timeUnit connection timeout unit
@return true if reachable otherwise false.
@throws IOException if an error occurs
"""
OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(connectTimeout, timeUnit);
return isServerReachable(baseUrl, client);
} | java | public static boolean isServerReachable(String baseUrl, long connectTimeout, TimeUnit timeUnit) throws IOException {
OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(connectTimeout, timeUnit);
return isServerReachable(baseUrl, client);
} | [
"public",
"static",
"boolean",
"isServerReachable",
"(",
"String",
"baseUrl",
",",
"long",
"connectTimeout",
",",
"TimeUnit",
"timeUnit",
")",
"throws",
"IOException",
"{",
"OkHttpClient",
"client",
"=",
"new",
"OkHttpClient",
"(",
")",
";",
"client",
".",
"setConnectTimeout",
"(",
"connectTimeout",
",",
"timeUnit",
")",
";",
"return",
"isServerReachable",
"(",
"baseUrl",
",",
"client",
")",
";",
"}"
] | Check if the server is reachable
@param baseUrl The url of the server to test
@param connectTimeout connection timeout
@param timeUnit connection timeout unit
@return true if reachable otherwise false.
@throws IOException if an error occurs | [
"Check",
"if",
"the",
"server",
"is",
"reachable"
] | train | https://github.com/MythTV-Clients/MythTV-Service-API/blob/7951954f767515550738f1b064d6c97099e6df15/src/main/java/org/mythtv/services/api/ServerVersionQuery.java#L110-L114 |
grails/gorm-hibernate5 | grails-datastore-gorm-hibernate5/src/main/groovy/org/grails/orm/hibernate/query/AbstractHibernateCriteriaBuilder.java | AbstractHibernateCriteriaBuilder.addProjectionToList | protected void addProjectionToList(Projection propertyProjection, String alias) {
"""
Adds a projection to the projectList for the given alias
@param propertyProjection The projection
@param alias The alias
"""
if (alias != null) {
projectionList.add(propertyProjection,alias);
}
else {
projectionList.add(propertyProjection);
}
} | java | protected void addProjectionToList(Projection propertyProjection, String alias) {
if (alias != null) {
projectionList.add(propertyProjection,alias);
}
else {
projectionList.add(propertyProjection);
}
} | [
"protected",
"void",
"addProjectionToList",
"(",
"Projection",
"propertyProjection",
",",
"String",
"alias",
")",
"{",
"if",
"(",
"alias",
"!=",
"null",
")",
"{",
"projectionList",
".",
"add",
"(",
"propertyProjection",
",",
"alias",
")",
";",
"}",
"else",
"{",
"projectionList",
".",
"add",
"(",
"propertyProjection",
")",
";",
"}",
"}"
] | Adds a projection to the projectList for the given alias
@param propertyProjection The projection
@param alias The alias | [
"Adds",
"a",
"projection",
"to",
"the",
"projectList",
"for",
"the",
"given",
"alias"
] | train | https://github.com/grails/gorm-hibernate5/blob/0ebb80cd769ef2bea955723d4543828a3e9542ef/grails-datastore-gorm-hibernate5/src/main/groovy/org/grails/orm/hibernate/query/AbstractHibernateCriteriaBuilder.java#L147-L154 |
hypercube1024/firefly | firefly/src/main/java/com/firefly/codec/http2/encode/UrlEncoded.java | UrlEncoded.decodeTo | public static void decodeTo(String content, MultiMap<String> map, String charset) {
"""
Decoded parameters to Map.
@param content the string containing the encoded parameters
@param map the MultiMap to put parsed query parameters into
@param charset the charset to use for decoding
"""
decodeTo(content, map, charset == null ? null : Charset.forName(charset));
} | java | public static void decodeTo(String content, MultiMap<String> map, String charset) {
decodeTo(content, map, charset == null ? null : Charset.forName(charset));
} | [
"public",
"static",
"void",
"decodeTo",
"(",
"String",
"content",
",",
"MultiMap",
"<",
"String",
">",
"map",
",",
"String",
"charset",
")",
"{",
"decodeTo",
"(",
"content",
",",
"map",
",",
"charset",
"==",
"null",
"?",
"null",
":",
"Charset",
".",
"forName",
"(",
"charset",
")",
")",
";",
"}"
] | Decoded parameters to Map.
@param content the string containing the encoded parameters
@param map the MultiMap to put parsed query parameters into
@param charset the charset to use for decoding | [
"Decoded",
"parameters",
"to",
"Map",
"."
] | train | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly/src/main/java/com/firefly/codec/http2/encode/UrlEncoded.java#L175-L177 |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/abst/fiducial/SquareImage_to_FiducialDetector.java | SquareImage_to_FiducialDetector.addPatternImage | public void addPatternImage(T pattern, double threshold, double lengthSide) {
"""
Add a new pattern to be detected. This function takes in a raw gray scale image and thresholds it.
@param pattern Gray scale image of the pattern
@param threshold Threshold used to convert it into a binary image
@param lengthSide Length of a side on the square in world units.
"""
GrayU8 binary = new GrayU8(pattern.width,pattern.height);
GThresholdImageOps.threshold(pattern,binary,threshold,false);
alg.addPattern(binary, lengthSide);
} | java | public void addPatternImage(T pattern, double threshold, double lengthSide) {
GrayU8 binary = new GrayU8(pattern.width,pattern.height);
GThresholdImageOps.threshold(pattern,binary,threshold,false);
alg.addPattern(binary, lengthSide);
} | [
"public",
"void",
"addPatternImage",
"(",
"T",
"pattern",
",",
"double",
"threshold",
",",
"double",
"lengthSide",
")",
"{",
"GrayU8",
"binary",
"=",
"new",
"GrayU8",
"(",
"pattern",
".",
"width",
",",
"pattern",
".",
"height",
")",
";",
"GThresholdImageOps",
".",
"threshold",
"(",
"pattern",
",",
"binary",
",",
"threshold",
",",
"false",
")",
";",
"alg",
".",
"addPattern",
"(",
"binary",
",",
"lengthSide",
")",
";",
"}"
] | Add a new pattern to be detected. This function takes in a raw gray scale image and thresholds it.
@param pattern Gray scale image of the pattern
@param threshold Threshold used to convert it into a binary image
@param lengthSide Length of a side on the square in world units. | [
"Add",
"a",
"new",
"pattern",
"to",
"be",
"detected",
".",
"This",
"function",
"takes",
"in",
"a",
"raw",
"gray",
"scale",
"image",
"and",
"thresholds",
"it",
"."
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/abst/fiducial/SquareImage_to_FiducialDetector.java#L48-L52 |
datasift/datasift-java | src/main/java/com/datasift/client/managedsource/sources/Yammer.java | Yammer.addOAutToken | public Yammer addOAutToken(String oAuthAccessToken, long expires, String name) {
"""
/*
Adds an OAuth token to the managed source
@param oAuthAccessToken an oauth2 token
@param name a human friendly name for this auth token
@param expires identity resource expiry date/time as a UTC timestamp, i.e. when the token expires
@return this
"""
if (oAuthAccessToken == null || oAuthAccessToken.isEmpty()) {
throw new IllegalArgumentException("A valid OAuth and refresh token is required");
}
AuthParams parameterSet = newAuthParams(name, expires);
parameterSet.set("value", oAuthAccessToken);
return this;
} | java | public Yammer addOAutToken(String oAuthAccessToken, long expires, String name) {
if (oAuthAccessToken == null || oAuthAccessToken.isEmpty()) {
throw new IllegalArgumentException("A valid OAuth and refresh token is required");
}
AuthParams parameterSet = newAuthParams(name, expires);
parameterSet.set("value", oAuthAccessToken);
return this;
} | [
"public",
"Yammer",
"addOAutToken",
"(",
"String",
"oAuthAccessToken",
",",
"long",
"expires",
",",
"String",
"name",
")",
"{",
"if",
"(",
"oAuthAccessToken",
"==",
"null",
"||",
"oAuthAccessToken",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"A valid OAuth and refresh token is required\"",
")",
";",
"}",
"AuthParams",
"parameterSet",
"=",
"newAuthParams",
"(",
"name",
",",
"expires",
")",
";",
"parameterSet",
".",
"set",
"(",
"\"value\"",
",",
"oAuthAccessToken",
")",
";",
"return",
"this",
";",
"}"
] | /*
Adds an OAuth token to the managed source
@param oAuthAccessToken an oauth2 token
@param name a human friendly name for this auth token
@param expires identity resource expiry date/time as a UTC timestamp, i.e. when the token expires
@return this | [
"/",
"*",
"Adds",
"an",
"OAuth",
"token",
"to",
"the",
"managed",
"source"
] | train | https://github.com/datasift/datasift-java/blob/09de124f2a1a507ff6181e59875c6f325290850e/src/main/java/com/datasift/client/managedsource/sources/Yammer.java#L31-L38 |
UrielCh/ovh-java-sdk | ovh-java-sdk-emailexchange/src/main/java/net/minidev/ovh/api/ApiOvhEmailexchange.java | ApiOvhEmailexchange.organizationName_service_exchangeService_domain_domainName_disclaimer_POST | public OvhTask organizationName_service_exchangeService_domain_domainName_disclaimer_POST(String organizationName, String exchangeService, String domainName, String content, Boolean outsideOnly) throws IOException {
"""
Create organization disclaimer of each email
REST: POST /email/exchange/{organizationName}/service/{exchangeService}/domain/{domainName}/disclaimer
@param outsideOnly [required] Activate the disclaimer only for external emails
@param content [required] Signature, added at the bottom of your organization emails
@param organizationName [required] The internal name of your exchange organization
@param exchangeService [required] The internal name of your exchange service
@param domainName [required] Domain name
"""
String qPath = "/email/exchange/{organizationName}/service/{exchangeService}/domain/{domainName}/disclaimer";
StringBuilder sb = path(qPath, organizationName, exchangeService, domainName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "content", content);
addBody(o, "outsideOnly", outsideOnly);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhTask.class);
} | java | public OvhTask organizationName_service_exchangeService_domain_domainName_disclaimer_POST(String organizationName, String exchangeService, String domainName, String content, Boolean outsideOnly) throws IOException {
String qPath = "/email/exchange/{organizationName}/service/{exchangeService}/domain/{domainName}/disclaimer";
StringBuilder sb = path(qPath, organizationName, exchangeService, domainName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "content", content);
addBody(o, "outsideOnly", outsideOnly);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhTask.class);
} | [
"public",
"OvhTask",
"organizationName_service_exchangeService_domain_domainName_disclaimer_POST",
"(",
"String",
"organizationName",
",",
"String",
"exchangeService",
",",
"String",
"domainName",
",",
"String",
"content",
",",
"Boolean",
"outsideOnly",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/email/exchange/{organizationName}/service/{exchangeService}/domain/{domainName}/disclaimer\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"organizationName",
",",
"exchangeService",
",",
"domainName",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"content\"",
",",
"content",
")",
";",
"addBody",
"(",
"o",
",",
"\"outsideOnly\"",
",",
"outsideOnly",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhTask",
".",
"class",
")",
";",
"}"
] | Create organization disclaimer of each email
REST: POST /email/exchange/{organizationName}/service/{exchangeService}/domain/{domainName}/disclaimer
@param outsideOnly [required] Activate the disclaimer only for external emails
@param content [required] Signature, added at the bottom of your organization emails
@param organizationName [required] The internal name of your exchange organization
@param exchangeService [required] The internal name of your exchange service
@param domainName [required] Domain name | [
"Create",
"organization",
"disclaimer",
"of",
"each",
"email"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-emailexchange/src/main/java/net/minidev/ovh/api/ApiOvhEmailexchange.java#L561-L569 |
joniles/mpxj | src/main/java/net/sf/mpxj/fasttrack/FastTrackData.java | FastTrackData.matchChildBlock | private final boolean matchChildBlock(int bufferIndex) {
"""
Locate a child block by byte pattern and validate by
checking the length of the string we are expecting
to follow the pattern.
@param bufferIndex start index
@return true if a child block starts at this point
"""
//
// Match the pattern we see at the start of the child block
//
int index = 0;
for (byte b : CHILD_BLOCK_PATTERN)
{
if (b != m_buffer[bufferIndex + index])
{
return false;
}
++index;
}
//
// The first step will produce false positives. To handle this, we should find
// the name of the block next, and check to ensure that the length
// of the name makes sense.
//
int nameLength = FastTrackUtility.getInt(m_buffer, bufferIndex + index);
// System.out.println("Name length: " + nameLength);
//
// if (nameLength > 0 && nameLength < 100)
// {
// String name = new String(m_buffer, bufferIndex+index+4, nameLength, CharsetHelper.UTF16LE);
// System.out.println("Name: " + name);
// }
return nameLength > 0 && nameLength < 100;
} | java | private final boolean matchChildBlock(int bufferIndex)
{
//
// Match the pattern we see at the start of the child block
//
int index = 0;
for (byte b : CHILD_BLOCK_PATTERN)
{
if (b != m_buffer[bufferIndex + index])
{
return false;
}
++index;
}
//
// The first step will produce false positives. To handle this, we should find
// the name of the block next, and check to ensure that the length
// of the name makes sense.
//
int nameLength = FastTrackUtility.getInt(m_buffer, bufferIndex + index);
// System.out.println("Name length: " + nameLength);
//
// if (nameLength > 0 && nameLength < 100)
// {
// String name = new String(m_buffer, bufferIndex+index+4, nameLength, CharsetHelper.UTF16LE);
// System.out.println("Name: " + name);
// }
return nameLength > 0 && nameLength < 100;
} | [
"private",
"final",
"boolean",
"matchChildBlock",
"(",
"int",
"bufferIndex",
")",
"{",
"//",
"// Match the pattern we see at the start of the child block",
"//",
"int",
"index",
"=",
"0",
";",
"for",
"(",
"byte",
"b",
":",
"CHILD_BLOCK_PATTERN",
")",
"{",
"if",
"(",
"b",
"!=",
"m_buffer",
"[",
"bufferIndex",
"+",
"index",
"]",
")",
"{",
"return",
"false",
";",
"}",
"++",
"index",
";",
"}",
"//",
"// The first step will produce false positives. To handle this, we should find",
"// the name of the block next, and check to ensure that the length",
"// of the name makes sense.",
"//",
"int",
"nameLength",
"=",
"FastTrackUtility",
".",
"getInt",
"(",
"m_buffer",
",",
"bufferIndex",
"+",
"index",
")",
";",
"// System.out.println(\"Name length: \" + nameLength);",
"// ",
"// if (nameLength > 0 && nameLength < 100)",
"// {",
"// String name = new String(m_buffer, bufferIndex+index+4, nameLength, CharsetHelper.UTF16LE);",
"// System.out.println(\"Name: \" + name);",
"// }",
"return",
"nameLength",
">",
"0",
"&&",
"nameLength",
"<",
"100",
";",
"}"
] | Locate a child block by byte pattern and validate by
checking the length of the string we are expecting
to follow the pattern.
@param bufferIndex start index
@return true if a child block starts at this point | [
"Locate",
"a",
"child",
"block",
"by",
"byte",
"pattern",
"and",
"validate",
"by",
"checking",
"the",
"length",
"of",
"the",
"string",
"we",
"are",
"expecting",
"to",
"follow",
"the",
"pattern",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/fasttrack/FastTrackData.java#L307-L338 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/field/event/MergeTableHandler.java | MergeTableHandler.fieldChanged | public int fieldChanged(boolean bDisplayOption, int iMoveMode) {
"""
The Field has Changed.
If this field is true, add the table back to the grid query and requery the grid table.
@param bDisplayOption If true, display the change.
@param iMoveMode The type of move being done (init/read/screen).
@return The error code (or NORMAL_RETURN if okay).
"""
boolean flag = this.getOwner().getState();
if (flag)
m_mergeRecord.getTable().addTable(m_subRecord.getTable());
else
m_mergeRecord.getTable().removeTable(m_subRecord.getTable());
m_mergeRecord.close(); // Must requery on Add, should close on delete
if (m_gridScreen == null)
return DBConstants.NORMAL_RETURN;
else
return super.fieldChanged(bDisplayOption, iMoveMode);
} | java | public int fieldChanged(boolean bDisplayOption, int iMoveMode)
{
boolean flag = this.getOwner().getState();
if (flag)
m_mergeRecord.getTable().addTable(m_subRecord.getTable());
else
m_mergeRecord.getTable().removeTable(m_subRecord.getTable());
m_mergeRecord.close(); // Must requery on Add, should close on delete
if (m_gridScreen == null)
return DBConstants.NORMAL_RETURN;
else
return super.fieldChanged(bDisplayOption, iMoveMode);
} | [
"public",
"int",
"fieldChanged",
"(",
"boolean",
"bDisplayOption",
",",
"int",
"iMoveMode",
")",
"{",
"boolean",
"flag",
"=",
"this",
".",
"getOwner",
"(",
")",
".",
"getState",
"(",
")",
";",
"if",
"(",
"flag",
")",
"m_mergeRecord",
".",
"getTable",
"(",
")",
".",
"addTable",
"(",
"m_subRecord",
".",
"getTable",
"(",
")",
")",
";",
"else",
"m_mergeRecord",
".",
"getTable",
"(",
")",
".",
"removeTable",
"(",
"m_subRecord",
".",
"getTable",
"(",
")",
")",
";",
"m_mergeRecord",
".",
"close",
"(",
")",
";",
"// Must requery on Add, should close on delete",
"if",
"(",
"m_gridScreen",
"==",
"null",
")",
"return",
"DBConstants",
".",
"NORMAL_RETURN",
";",
"else",
"return",
"super",
".",
"fieldChanged",
"(",
"bDisplayOption",
",",
"iMoveMode",
")",
";",
"}"
] | The Field has Changed.
If this field is true, add the table back to the grid query and requery the grid table.
@param bDisplayOption If true, display the change.
@param iMoveMode The type of move being done (init/read/screen).
@return The error code (or NORMAL_RETURN if okay). | [
"The",
"Field",
"has",
"Changed",
".",
"If",
"this",
"field",
"is",
"true",
"add",
"the",
"table",
"back",
"to",
"the",
"grid",
"query",
"and",
"requery",
"the",
"grid",
"table",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/event/MergeTableHandler.java#L111-L123 |
alkacon/opencms-core | src/org/opencms/xml/containerpage/CmsXmlGroupContainer.java | CmsXmlGroupContainer.fillResource | protected void fillResource(CmsObject cms, Element element, CmsResource res) {
"""
Fills a {@link CmsXmlVfsFileValue} with the resource identified by the given id.<p>
@param cms the current CMS context
@param element the XML element to fill
@param res the resource to use
"""
String xpath = element.getPath();
int pos = xpath.lastIndexOf("/" + XmlNode.GroupContainers.name() + "/");
if (pos > 0) {
xpath = xpath.substring(pos + 1);
}
CmsRelationType type = getHandler().getRelationType(xpath);
CmsXmlVfsFileValue.fillEntry(element, res.getStructureId(), res.getRootPath(), type);
} | java | protected void fillResource(CmsObject cms, Element element, CmsResource res) {
String xpath = element.getPath();
int pos = xpath.lastIndexOf("/" + XmlNode.GroupContainers.name() + "/");
if (pos > 0) {
xpath = xpath.substring(pos + 1);
}
CmsRelationType type = getHandler().getRelationType(xpath);
CmsXmlVfsFileValue.fillEntry(element, res.getStructureId(), res.getRootPath(), type);
} | [
"protected",
"void",
"fillResource",
"(",
"CmsObject",
"cms",
",",
"Element",
"element",
",",
"CmsResource",
"res",
")",
"{",
"String",
"xpath",
"=",
"element",
".",
"getPath",
"(",
")",
";",
"int",
"pos",
"=",
"xpath",
".",
"lastIndexOf",
"(",
"\"/\"",
"+",
"XmlNode",
".",
"GroupContainers",
".",
"name",
"(",
")",
"+",
"\"/\"",
")",
";",
"if",
"(",
"pos",
">",
"0",
")",
"{",
"xpath",
"=",
"xpath",
".",
"substring",
"(",
"pos",
"+",
"1",
")",
";",
"}",
"CmsRelationType",
"type",
"=",
"getHandler",
"(",
")",
".",
"getRelationType",
"(",
"xpath",
")",
";",
"CmsXmlVfsFileValue",
".",
"fillEntry",
"(",
"element",
",",
"res",
".",
"getStructureId",
"(",
")",
",",
"res",
".",
"getRootPath",
"(",
")",
",",
"type",
")",
";",
"}"
] | Fills a {@link CmsXmlVfsFileValue} with the resource identified by the given id.<p>
@param cms the current CMS context
@param element the XML element to fill
@param res the resource to use | [
"Fills",
"a",
"{",
"@link",
"CmsXmlVfsFileValue",
"}",
"with",
"the",
"resource",
"identified",
"by",
"the",
"given",
"id",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/xml/containerpage/CmsXmlGroupContainer.java#L281-L290 |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/core/repository/ValidationDataRepository.java | ValidationDataRepository.findByParamTypeAndMethodAndUrlAndNameAndParentId | public ValidationData findByParamTypeAndMethodAndUrlAndNameAndParentId(ParamType paramType, String method, String url, String name, Long parentId) {
"""
Find by param type and method and url and name and parent id validation data.
@param paramType the param type
@param method the method
@param url the url
@param name the name
@param parentId the parent id
@return the validation data
"""
if (parentId == null) {
return this.findByParamTypeAndMethodAndUrlAndName(paramType, method, url, name).stream().filter(d -> d.getParentId() == null).findAny().orElse(null);
}
return this.findByParamTypeAndMethodAndUrlAndName(paramType, method, url, name).stream()
.filter(d -> d.getParentId() != null && d.getParentId().equals(parentId)).findAny().orElse(null);
} | java | public ValidationData findByParamTypeAndMethodAndUrlAndNameAndParentId(ParamType paramType, String method, String url, String name, Long parentId) {
if (parentId == null) {
return this.findByParamTypeAndMethodAndUrlAndName(paramType, method, url, name).stream().filter(d -> d.getParentId() == null).findAny().orElse(null);
}
return this.findByParamTypeAndMethodAndUrlAndName(paramType, method, url, name).stream()
.filter(d -> d.getParentId() != null && d.getParentId().equals(parentId)).findAny().orElse(null);
} | [
"public",
"ValidationData",
"findByParamTypeAndMethodAndUrlAndNameAndParentId",
"(",
"ParamType",
"paramType",
",",
"String",
"method",
",",
"String",
"url",
",",
"String",
"name",
",",
"Long",
"parentId",
")",
"{",
"if",
"(",
"parentId",
"==",
"null",
")",
"{",
"return",
"this",
".",
"findByParamTypeAndMethodAndUrlAndName",
"(",
"paramType",
",",
"method",
",",
"url",
",",
"name",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"d",
"->",
"d",
".",
"getParentId",
"(",
")",
"==",
"null",
")",
".",
"findAny",
"(",
")",
".",
"orElse",
"(",
"null",
")",
";",
"}",
"return",
"this",
".",
"findByParamTypeAndMethodAndUrlAndName",
"(",
"paramType",
",",
"method",
",",
"url",
",",
"name",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"d",
"->",
"d",
".",
"getParentId",
"(",
")",
"!=",
"null",
"&&",
"d",
".",
"getParentId",
"(",
")",
".",
"equals",
"(",
"parentId",
")",
")",
".",
"findAny",
"(",
")",
".",
"orElse",
"(",
"null",
")",
";",
"}"
] | Find by param type and method and url and name and parent id validation data.
@param paramType the param type
@param method the method
@param url the url
@param name the name
@param parentId the parent id
@return the validation data | [
"Find",
"by",
"param",
"type",
"and",
"method",
"and",
"url",
"and",
"name",
"and",
"parent",
"id",
"validation",
"data",
"."
] | train | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/repository/ValidationDataRepository.java#L197-L204 |
cloudfoundry-community/cf-java-component | cf-spring/src/main/java/cf/spring/servicebroker/AbstractAnnotationCatalogAccessorProvider.java | AbstractAnnotationCatalogAccessorProvider.getMethodAccessor | protected BrokerServiceAccessor getMethodAccessor(String serviceBrokerName, CatalogService description) {
"""
Returns the accessor used to access the specified service of the
specified broker.
@param serviceBrokerName the name of the broker offering the specified service
@param description the service description
"""
return new AnnotationBrokerServiceAccessor(description, serviceBrokerName, getBeanClass(serviceBrokerName),
context.getBean(serviceBrokerName));
} | java | protected BrokerServiceAccessor getMethodAccessor(String serviceBrokerName, CatalogService description) {
return new AnnotationBrokerServiceAccessor(description, serviceBrokerName, getBeanClass(serviceBrokerName),
context.getBean(serviceBrokerName));
} | [
"protected",
"BrokerServiceAccessor",
"getMethodAccessor",
"(",
"String",
"serviceBrokerName",
",",
"CatalogService",
"description",
")",
"{",
"return",
"new",
"AnnotationBrokerServiceAccessor",
"(",
"description",
",",
"serviceBrokerName",
",",
"getBeanClass",
"(",
"serviceBrokerName",
")",
",",
"context",
".",
"getBean",
"(",
"serviceBrokerName",
")",
")",
";",
"}"
] | Returns the accessor used to access the specified service of the
specified broker.
@param serviceBrokerName the name of the broker offering the specified service
@param description the service description | [
"Returns",
"the",
"accessor",
"used",
"to",
"access",
"the",
"specified",
"service",
"of",
"the",
"specified",
"broker",
"."
] | train | https://github.com/cloudfoundry-community/cf-java-component/blob/9d7d54f2b599f3e4f4706bc0c471e144065671fa/cf-spring/src/main/java/cf/spring/servicebroker/AbstractAnnotationCatalogAccessorProvider.java#L48-L51 |
dbracewell/hermes | hermes-core/src/main/java/com/davidbracewell/hermes/DocumentFactory.java | DocumentFactory.createRaw | public Document createRaw(@NonNull String content) {
"""
Creates a document with the given content written in the default language. This method does not apply any {@link
TextNormalizer}
@param content the content
@return the document
"""
return createRaw(StringUtils.EMPTY, content, defaultLanguage, Collections.emptyMap());
} | java | public Document createRaw(@NonNull String content) {
return createRaw(StringUtils.EMPTY, content, defaultLanguage, Collections.emptyMap());
} | [
"public",
"Document",
"createRaw",
"(",
"@",
"NonNull",
"String",
"content",
")",
"{",
"return",
"createRaw",
"(",
"StringUtils",
".",
"EMPTY",
",",
"content",
",",
"defaultLanguage",
",",
"Collections",
".",
"emptyMap",
"(",
")",
")",
";",
"}"
] | Creates a document with the given content written in the default language. This method does not apply any {@link
TextNormalizer}
@param content the content
@return the document | [
"Creates",
"a",
"document",
"with",
"the",
"given",
"content",
"written",
"in",
"the",
"default",
"language",
".",
"This",
"method",
"does",
"not",
"apply",
"any",
"{",
"@link",
"TextNormalizer",
"}"
] | train | https://github.com/dbracewell/hermes/blob/9ebefe7ad5dea1b731ae6931a30771eb75325ea3/hermes-core/src/main/java/com/davidbracewell/hermes/DocumentFactory.java#L181-L183 |
alkacon/opencms-core | src-modules/org/opencms/workplace/tools/content/CmsMergePages.java | CmsMergePages.reportList | private void reportList(List collected, boolean doReport) {
"""
Creates a report list of all resources in one of the collected lists.<p>
@param collected the list to create the output from
@param doReport flag to enable detailed report
"""
int size = collected.size();
// now loop through all collected resources
m_report.println(
Messages.get().container(Messages.RPT_NUM_PAGES_1, new Integer(size)),
I_CmsReport.FORMAT_HEADLINE);
if (doReport) {
int count = 1;
Iterator i = collected.iterator();
while (i.hasNext()) {
String resName = (String)i.next();
m_report.print(
org.opencms.report.Messages.get().container(
org.opencms.report.Messages.RPT_SUCCESSION_2,
String.valueOf(count++),
String.valueOf(size)),
I_CmsReport.FORMAT_NOTE);
m_report.println(Messages.get().container(Messages.RPT_PROCESS_1, resName), I_CmsReport.FORMAT_NOTE);
}
}
m_report.println(Messages.get().container(Messages.RPT_MERGE_PAGES_END_0), I_CmsReport.FORMAT_HEADLINE);
} | java | private void reportList(List collected, boolean doReport) {
int size = collected.size();
// now loop through all collected resources
m_report.println(
Messages.get().container(Messages.RPT_NUM_PAGES_1, new Integer(size)),
I_CmsReport.FORMAT_HEADLINE);
if (doReport) {
int count = 1;
Iterator i = collected.iterator();
while (i.hasNext()) {
String resName = (String)i.next();
m_report.print(
org.opencms.report.Messages.get().container(
org.opencms.report.Messages.RPT_SUCCESSION_2,
String.valueOf(count++),
String.valueOf(size)),
I_CmsReport.FORMAT_NOTE);
m_report.println(Messages.get().container(Messages.RPT_PROCESS_1, resName), I_CmsReport.FORMAT_NOTE);
}
}
m_report.println(Messages.get().container(Messages.RPT_MERGE_PAGES_END_0), I_CmsReport.FORMAT_HEADLINE);
} | [
"private",
"void",
"reportList",
"(",
"List",
"collected",
",",
"boolean",
"doReport",
")",
"{",
"int",
"size",
"=",
"collected",
".",
"size",
"(",
")",
";",
"// now loop through all collected resources",
"m_report",
".",
"println",
"(",
"Messages",
".",
"get",
"(",
")",
".",
"container",
"(",
"Messages",
".",
"RPT_NUM_PAGES_1",
",",
"new",
"Integer",
"(",
"size",
")",
")",
",",
"I_CmsReport",
".",
"FORMAT_HEADLINE",
")",
";",
"if",
"(",
"doReport",
")",
"{",
"int",
"count",
"=",
"1",
";",
"Iterator",
"i",
"=",
"collected",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"i",
".",
"hasNext",
"(",
")",
")",
"{",
"String",
"resName",
"=",
"(",
"String",
")",
"i",
".",
"next",
"(",
")",
";",
"m_report",
".",
"print",
"(",
"org",
".",
"opencms",
".",
"report",
".",
"Messages",
".",
"get",
"(",
")",
".",
"container",
"(",
"org",
".",
"opencms",
".",
"report",
".",
"Messages",
".",
"RPT_SUCCESSION_2",
",",
"String",
".",
"valueOf",
"(",
"count",
"++",
")",
",",
"String",
".",
"valueOf",
"(",
"size",
")",
")",
",",
"I_CmsReport",
".",
"FORMAT_NOTE",
")",
";",
"m_report",
".",
"println",
"(",
"Messages",
".",
"get",
"(",
")",
".",
"container",
"(",
"Messages",
".",
"RPT_PROCESS_1",
",",
"resName",
")",
",",
"I_CmsReport",
".",
"FORMAT_NOTE",
")",
";",
"}",
"}",
"m_report",
".",
"println",
"(",
"Messages",
".",
"get",
"(",
")",
".",
"container",
"(",
"Messages",
".",
"RPT_MERGE_PAGES_END_0",
")",
",",
"I_CmsReport",
".",
"FORMAT_HEADLINE",
")",
";",
"}"
] | Creates a report list of all resources in one of the collected lists.<p>
@param collected the list to create the output from
@param doReport flag to enable detailed report | [
"Creates",
"a",
"report",
"list",
"of",
"all",
"resources",
"in",
"one",
"of",
"the",
"collected",
"lists",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-modules/org/opencms/workplace/tools/content/CmsMergePages.java#L751-L774 |
atomix/atomix | protocols/raft/src/main/java/io/atomix/protocols/raft/roles/ActiveRole.java | ActiveRole.isLogUpToDate | boolean isLogUpToDate(long lastIndex, long lastTerm, RaftRequest request) {
"""
Returns a boolean value indicating whether the given candidate's log is up-to-date.
"""
// Read the last entry from the log.
final Indexed<RaftLogEntry> lastEntry = raft.getLogWriter().getLastEntry();
// If the log is empty then vote for the candidate.
if (lastEntry == null) {
log.debug("Accepted {}: candidate's log is up-to-date", request);
return true;
}
// If the candidate's last log term is lower than the local log's last entry term, reject the request.
if (lastTerm < lastEntry.entry().term()) {
log.debug("Rejected {}: candidate's last log entry ({}) is at a lower term than the local log ({})", request, lastTerm, lastEntry.entry().term());
return false;
}
// If the candidate's last term is equal to the local log's last entry term, reject the request if the
// candidate's last index is less than the local log's last index. If the candidate's last log term is
// greater than the local log's last term then it's considered up to date, and if both have the same term
// then the candidate's last index must be greater than the local log's last index.
if (lastTerm == lastEntry.entry().term() && lastIndex < lastEntry.index()) {
log.debug("Rejected {}: candidate's last log entry ({}) is at a lower index than the local log ({})", request, lastIndex, lastEntry.index());
return false;
}
// If we made it this far, the candidate's last term is greater than or equal to the local log's last
// term, and if equal to the local log's last term, the candidate's last index is equal to or greater
// than the local log's last index.
log.debug("Accepted {}: candidate's log is up-to-date", request);
return true;
} | java | boolean isLogUpToDate(long lastIndex, long lastTerm, RaftRequest request) {
// Read the last entry from the log.
final Indexed<RaftLogEntry> lastEntry = raft.getLogWriter().getLastEntry();
// If the log is empty then vote for the candidate.
if (lastEntry == null) {
log.debug("Accepted {}: candidate's log is up-to-date", request);
return true;
}
// If the candidate's last log term is lower than the local log's last entry term, reject the request.
if (lastTerm < lastEntry.entry().term()) {
log.debug("Rejected {}: candidate's last log entry ({}) is at a lower term than the local log ({})", request, lastTerm, lastEntry.entry().term());
return false;
}
// If the candidate's last term is equal to the local log's last entry term, reject the request if the
// candidate's last index is less than the local log's last index. If the candidate's last log term is
// greater than the local log's last term then it's considered up to date, and if both have the same term
// then the candidate's last index must be greater than the local log's last index.
if (lastTerm == lastEntry.entry().term() && lastIndex < lastEntry.index()) {
log.debug("Rejected {}: candidate's last log entry ({}) is at a lower index than the local log ({})", request, lastIndex, lastEntry.index());
return false;
}
// If we made it this far, the candidate's last term is greater than or equal to the local log's last
// term, and if equal to the local log's last term, the candidate's last index is equal to or greater
// than the local log's last index.
log.debug("Accepted {}: candidate's log is up-to-date", request);
return true;
} | [
"boolean",
"isLogUpToDate",
"(",
"long",
"lastIndex",
",",
"long",
"lastTerm",
",",
"RaftRequest",
"request",
")",
"{",
"// Read the last entry from the log.",
"final",
"Indexed",
"<",
"RaftLogEntry",
">",
"lastEntry",
"=",
"raft",
".",
"getLogWriter",
"(",
")",
".",
"getLastEntry",
"(",
")",
";",
"// If the log is empty then vote for the candidate.",
"if",
"(",
"lastEntry",
"==",
"null",
")",
"{",
"log",
".",
"debug",
"(",
"\"Accepted {}: candidate's log is up-to-date\"",
",",
"request",
")",
";",
"return",
"true",
";",
"}",
"// If the candidate's last log term is lower than the local log's last entry term, reject the request.",
"if",
"(",
"lastTerm",
"<",
"lastEntry",
".",
"entry",
"(",
")",
".",
"term",
"(",
")",
")",
"{",
"log",
".",
"debug",
"(",
"\"Rejected {}: candidate's last log entry ({}) is at a lower term than the local log ({})\"",
",",
"request",
",",
"lastTerm",
",",
"lastEntry",
".",
"entry",
"(",
")",
".",
"term",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"// If the candidate's last term is equal to the local log's last entry term, reject the request if the",
"// candidate's last index is less than the local log's last index. If the candidate's last log term is",
"// greater than the local log's last term then it's considered up to date, and if both have the same term",
"// then the candidate's last index must be greater than the local log's last index.",
"if",
"(",
"lastTerm",
"==",
"lastEntry",
".",
"entry",
"(",
")",
".",
"term",
"(",
")",
"&&",
"lastIndex",
"<",
"lastEntry",
".",
"index",
"(",
")",
")",
"{",
"log",
".",
"debug",
"(",
"\"Rejected {}: candidate's last log entry ({}) is at a lower index than the local log ({})\"",
",",
"request",
",",
"lastIndex",
",",
"lastEntry",
".",
"index",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"// If we made it this far, the candidate's last term is greater than or equal to the local log's last",
"// term, and if equal to the local log's last term, the candidate's last index is equal to or greater",
"// than the local log's last index.",
"log",
".",
"debug",
"(",
"\"Accepted {}: candidate's log is up-to-date\"",
",",
"request",
")",
";",
"return",
"true",
";",
"}"
] | Returns a boolean value indicating whether the given candidate's log is up-to-date. | [
"Returns",
"a",
"boolean",
"value",
"indicating",
"whether",
"the",
"given",
"candidate",
"s",
"log",
"is",
"up",
"-",
"to",
"-",
"date",
"."
] | train | https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/roles/ActiveRole.java#L190-L220 |
kuali/ojb-1.0.4 | src/xdoclet/java/src/xdoclet/modules/ojb/OjbTagsHandler.java | OjbTagsHandler.forAllClassDefinitions | public void forAllClassDefinitions(String template, Properties attributes) throws XDocletException {
"""
Processes the template for all class definitions.
@param template The template
@param attributes The attributes of the tag
@exception XDocletException if an error occurs
@doc.tag type="block"
"""
for (Iterator it = _model.getClasses(); it.hasNext(); )
{
_curClassDef = (ClassDescriptorDef)it.next();
generate(template);
}
_curClassDef = null;
LogHelper.debug(true, OjbTagsHandler.class, "forAllClassDefinitions", "Processed "+_model.getNumClasses()+" types");
} | java | public void forAllClassDefinitions(String template, Properties attributes) throws XDocletException
{
for (Iterator it = _model.getClasses(); it.hasNext(); )
{
_curClassDef = (ClassDescriptorDef)it.next();
generate(template);
}
_curClassDef = null;
LogHelper.debug(true, OjbTagsHandler.class, "forAllClassDefinitions", "Processed "+_model.getNumClasses()+" types");
} | [
"public",
"void",
"forAllClassDefinitions",
"(",
"String",
"template",
",",
"Properties",
"attributes",
")",
"throws",
"XDocletException",
"{",
"for",
"(",
"Iterator",
"it",
"=",
"_model",
".",
"getClasses",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"_curClassDef",
"=",
"(",
"ClassDescriptorDef",
")",
"it",
".",
"next",
"(",
")",
";",
"generate",
"(",
"template",
")",
";",
"}",
"_curClassDef",
"=",
"null",
";",
"LogHelper",
".",
"debug",
"(",
"true",
",",
"OjbTagsHandler",
".",
"class",
",",
"\"forAllClassDefinitions\"",
",",
"\"Processed \"",
"+",
"_model",
".",
"getNumClasses",
"(",
")",
"+",
"\" types\"",
")",
";",
"}"
] | Processes the template for all class definitions.
@param template The template
@param attributes The attributes of the tag
@exception XDocletException if an error occurs
@doc.tag type="block" | [
"Processes",
"the",
"template",
"for",
"all",
"class",
"definitions",
"."
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/xdoclet/java/src/xdoclet/modules/ojb/OjbTagsHandler.java#L172-L182 |
alkacon/opencms-core | src/org/opencms/main/OpenCmsCore.java | OpenCmsCore.initContext | protected synchronized void initContext(ServletContext context) throws CmsInitException {
"""
Initialization of the OpenCms runtime environment.<p>
The connection information for the database is read
from the <code>opencms.properties</code> configuration file and all
driver manager are initialized via the initializer,
which usually will be an instance of a <code>OpenCms</code> class.
@param context configuration of OpenCms from <code>web.xml</code>
@throws CmsInitException in case OpenCms can not be initialized
"""
m_gwtServiceContexts = new HashMap<String, CmsGwtServiceContext>();
// automatic servlet container recognition and specific behavior:
CmsServletContainerSettings servletContainerSettings = new CmsServletContainerSettings(context);
getSystemInfo().init(servletContainerSettings);
// Collect the configurations
CmsParameterConfiguration configuration;
try {
configuration = new CmsParameterConfiguration(getSystemInfo().getConfigurationFileRfsPath());
} catch (Exception e) {
throw new CmsInitException(
Messages.get().container(
Messages.ERR_CRITICAL_INIT_PROPFILE_1,
getSystemInfo().getConfigurationFileRfsPath()),
e);
}
String throwException = configuration.getString("servlet.exception.enabled", "auto");
if (!throwException.equals("auto")) {
// set the parameter is not automatic, the rest of the servlet container dependent parameters
// will be set when reading the system configuration, if not set to auto
boolean throwExc = Boolean.valueOf(throwException).booleanValue();
getSystemInfo().getServletContainerSettings().setServletThrowsException(throwExc);
}
// check if the wizard is enabled, if so stop initialization
if (configuration.getBoolean("wizard.enabled", true)) {
throw new CmsInitException(Messages.get().container(Messages.ERR_CRITICAL_INIT_WIZARD_0));
}
// add an indicator that the configuration was processed from the servlet context
configuration.add("context.servlet.container", context.getServerInfo());
// output startup message and copyright to STDERR
System.err.println(
Messages.get().getBundle().key(
Messages.LOG_STARTUP_CONSOLE_NOTE_2,
OpenCms.getSystemInfo().getVersionNumber(),
getSystemInfo().getWebApplicationName()));
for (int i = 0; i < Messages.COPYRIGHT_BY_ALKACON.length; i++) {
System.err.println(Messages.COPYRIGHT_BY_ALKACON[i]);
}
System.err.println();
// initialize the configuration
initConfiguration(configuration);
} | java | protected synchronized void initContext(ServletContext context) throws CmsInitException {
m_gwtServiceContexts = new HashMap<String, CmsGwtServiceContext>();
// automatic servlet container recognition and specific behavior:
CmsServletContainerSettings servletContainerSettings = new CmsServletContainerSettings(context);
getSystemInfo().init(servletContainerSettings);
// Collect the configurations
CmsParameterConfiguration configuration;
try {
configuration = new CmsParameterConfiguration(getSystemInfo().getConfigurationFileRfsPath());
} catch (Exception e) {
throw new CmsInitException(
Messages.get().container(
Messages.ERR_CRITICAL_INIT_PROPFILE_1,
getSystemInfo().getConfigurationFileRfsPath()),
e);
}
String throwException = configuration.getString("servlet.exception.enabled", "auto");
if (!throwException.equals("auto")) {
// set the parameter is not automatic, the rest of the servlet container dependent parameters
// will be set when reading the system configuration, if not set to auto
boolean throwExc = Boolean.valueOf(throwException).booleanValue();
getSystemInfo().getServletContainerSettings().setServletThrowsException(throwExc);
}
// check if the wizard is enabled, if so stop initialization
if (configuration.getBoolean("wizard.enabled", true)) {
throw new CmsInitException(Messages.get().container(Messages.ERR_CRITICAL_INIT_WIZARD_0));
}
// add an indicator that the configuration was processed from the servlet context
configuration.add("context.servlet.container", context.getServerInfo());
// output startup message and copyright to STDERR
System.err.println(
Messages.get().getBundle().key(
Messages.LOG_STARTUP_CONSOLE_NOTE_2,
OpenCms.getSystemInfo().getVersionNumber(),
getSystemInfo().getWebApplicationName()));
for (int i = 0; i < Messages.COPYRIGHT_BY_ALKACON.length; i++) {
System.err.println(Messages.COPYRIGHT_BY_ALKACON[i]);
}
System.err.println();
// initialize the configuration
initConfiguration(configuration);
} | [
"protected",
"synchronized",
"void",
"initContext",
"(",
"ServletContext",
"context",
")",
"throws",
"CmsInitException",
"{",
"m_gwtServiceContexts",
"=",
"new",
"HashMap",
"<",
"String",
",",
"CmsGwtServiceContext",
">",
"(",
")",
";",
"// automatic servlet container recognition and specific behavior:",
"CmsServletContainerSettings",
"servletContainerSettings",
"=",
"new",
"CmsServletContainerSettings",
"(",
"context",
")",
";",
"getSystemInfo",
"(",
")",
".",
"init",
"(",
"servletContainerSettings",
")",
";",
"// Collect the configurations",
"CmsParameterConfiguration",
"configuration",
";",
"try",
"{",
"configuration",
"=",
"new",
"CmsParameterConfiguration",
"(",
"getSystemInfo",
"(",
")",
".",
"getConfigurationFileRfsPath",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"CmsInitException",
"(",
"Messages",
".",
"get",
"(",
")",
".",
"container",
"(",
"Messages",
".",
"ERR_CRITICAL_INIT_PROPFILE_1",
",",
"getSystemInfo",
"(",
")",
".",
"getConfigurationFileRfsPath",
"(",
")",
")",
",",
"e",
")",
";",
"}",
"String",
"throwException",
"=",
"configuration",
".",
"getString",
"(",
"\"servlet.exception.enabled\"",
",",
"\"auto\"",
")",
";",
"if",
"(",
"!",
"throwException",
".",
"equals",
"(",
"\"auto\"",
")",
")",
"{",
"// set the parameter is not automatic, the rest of the servlet container dependent parameters",
"// will be set when reading the system configuration, if not set to auto",
"boolean",
"throwExc",
"=",
"Boolean",
".",
"valueOf",
"(",
"throwException",
")",
".",
"booleanValue",
"(",
")",
";",
"getSystemInfo",
"(",
")",
".",
"getServletContainerSettings",
"(",
")",
".",
"setServletThrowsException",
"(",
"throwExc",
")",
";",
"}",
"// check if the wizard is enabled, if so stop initialization",
"if",
"(",
"configuration",
".",
"getBoolean",
"(",
"\"wizard.enabled\"",
",",
"true",
")",
")",
"{",
"throw",
"new",
"CmsInitException",
"(",
"Messages",
".",
"get",
"(",
")",
".",
"container",
"(",
"Messages",
".",
"ERR_CRITICAL_INIT_WIZARD_0",
")",
")",
";",
"}",
"// add an indicator that the configuration was processed from the servlet context",
"configuration",
".",
"add",
"(",
"\"context.servlet.container\"",
",",
"context",
".",
"getServerInfo",
"(",
")",
")",
";",
"// output startup message and copyright to STDERR",
"System",
".",
"err",
".",
"println",
"(",
"Messages",
".",
"get",
"(",
")",
".",
"getBundle",
"(",
")",
".",
"key",
"(",
"Messages",
".",
"LOG_STARTUP_CONSOLE_NOTE_2",
",",
"OpenCms",
".",
"getSystemInfo",
"(",
")",
".",
"getVersionNumber",
"(",
")",
",",
"getSystemInfo",
"(",
")",
".",
"getWebApplicationName",
"(",
")",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"Messages",
".",
"COPYRIGHT_BY_ALKACON",
".",
"length",
";",
"i",
"++",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"Messages",
".",
"COPYRIGHT_BY_ALKACON",
"[",
"i",
"]",
")",
";",
"}",
"System",
".",
"err",
".",
"println",
"(",
")",
";",
"// initialize the configuration",
"initConfiguration",
"(",
"configuration",
")",
";",
"}"
] | Initialization of the OpenCms runtime environment.<p>
The connection information for the database is read
from the <code>opencms.properties</code> configuration file and all
driver manager are initialized via the initializer,
which usually will be an instance of a <code>OpenCms</code> class.
@param context configuration of OpenCms from <code>web.xml</code>
@throws CmsInitException in case OpenCms can not be initialized | [
"Initialization",
"of",
"the",
"OpenCms",
"runtime",
"environment",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/main/OpenCmsCore.java#L1706-L1755 |
VoltDB/voltdb | src/frontend/org/voltdb/SnapshotDaemon.java | SnapshotDaemon.createAndWatchRequestNode | public void createAndWatchRequestNode(final long clientHandle,
final Connection c,
SnapshotInitiationInfo snapInfo,
boolean notifyChanges) throws ForwardClientException {
"""
Try to create the ZK request node and watch it if created successfully.
"""
boolean requestExists = false;
final String requestId = createRequestNode(snapInfo);
if (requestId == null) {
requestExists = true;
} else {
if (!snapInfo.isTruncationRequest()) {
try {
registerUserSnapshotResponseWatch(requestId, clientHandle, c, notifyChanges);
} catch (Exception e) {
VoltDB.crashLocalVoltDB("Failed to register ZK watch on snapshot response", true, e);
}
}
else {
// need to construct a success response of some sort here to indicate the truncation attempt
// was successfully attempted
VoltTable result = SnapshotUtil.constructNodeResultsTable();
result.addRow(-1,
CoreUtils.getHostnameOrAddress(),
"",
"SUCCESS",
"SNAPSHOT REQUEST QUEUED");
final ClientResponseImpl resp =
new ClientResponseImpl(ClientResponseImpl.SUCCESS,
new VoltTable[] {result},
"User-requested truncation snapshot successfully queued for execution.",
clientHandle);
ByteBuffer buf = ByteBuffer.allocate(resp.getSerializedSize() + 4);
buf.putInt(buf.capacity() - 4);
resp.flattenToBuffer(buf).flip();
c.writeStream().enqueue(buf);
}
}
if (requestExists) {
VoltTable result = SnapshotUtil.constructNodeResultsTable();
result.addRow(-1,
CoreUtils.getHostnameOrAddress(),
"",
"FAILURE",
"SNAPSHOT IN PROGRESS");
throw new ForwardClientException("A request to perform a user snapshot already exists", result);
}
} | java | public void createAndWatchRequestNode(final long clientHandle,
final Connection c,
SnapshotInitiationInfo snapInfo,
boolean notifyChanges) throws ForwardClientException {
boolean requestExists = false;
final String requestId = createRequestNode(snapInfo);
if (requestId == null) {
requestExists = true;
} else {
if (!snapInfo.isTruncationRequest()) {
try {
registerUserSnapshotResponseWatch(requestId, clientHandle, c, notifyChanges);
} catch (Exception e) {
VoltDB.crashLocalVoltDB("Failed to register ZK watch on snapshot response", true, e);
}
}
else {
// need to construct a success response of some sort here to indicate the truncation attempt
// was successfully attempted
VoltTable result = SnapshotUtil.constructNodeResultsTable();
result.addRow(-1,
CoreUtils.getHostnameOrAddress(),
"",
"SUCCESS",
"SNAPSHOT REQUEST QUEUED");
final ClientResponseImpl resp =
new ClientResponseImpl(ClientResponseImpl.SUCCESS,
new VoltTable[] {result},
"User-requested truncation snapshot successfully queued for execution.",
clientHandle);
ByteBuffer buf = ByteBuffer.allocate(resp.getSerializedSize() + 4);
buf.putInt(buf.capacity() - 4);
resp.flattenToBuffer(buf).flip();
c.writeStream().enqueue(buf);
}
}
if (requestExists) {
VoltTable result = SnapshotUtil.constructNodeResultsTable();
result.addRow(-1,
CoreUtils.getHostnameOrAddress(),
"",
"FAILURE",
"SNAPSHOT IN PROGRESS");
throw new ForwardClientException("A request to perform a user snapshot already exists", result);
}
} | [
"public",
"void",
"createAndWatchRequestNode",
"(",
"final",
"long",
"clientHandle",
",",
"final",
"Connection",
"c",
",",
"SnapshotInitiationInfo",
"snapInfo",
",",
"boolean",
"notifyChanges",
")",
"throws",
"ForwardClientException",
"{",
"boolean",
"requestExists",
"=",
"false",
";",
"final",
"String",
"requestId",
"=",
"createRequestNode",
"(",
"snapInfo",
")",
";",
"if",
"(",
"requestId",
"==",
"null",
")",
"{",
"requestExists",
"=",
"true",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"snapInfo",
".",
"isTruncationRequest",
"(",
")",
")",
"{",
"try",
"{",
"registerUserSnapshotResponseWatch",
"(",
"requestId",
",",
"clientHandle",
",",
"c",
",",
"notifyChanges",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"VoltDB",
".",
"crashLocalVoltDB",
"(",
"\"Failed to register ZK watch on snapshot response\"",
",",
"true",
",",
"e",
")",
";",
"}",
"}",
"else",
"{",
"// need to construct a success response of some sort here to indicate the truncation attempt",
"// was successfully attempted",
"VoltTable",
"result",
"=",
"SnapshotUtil",
".",
"constructNodeResultsTable",
"(",
")",
";",
"result",
".",
"addRow",
"(",
"-",
"1",
",",
"CoreUtils",
".",
"getHostnameOrAddress",
"(",
")",
",",
"\"\"",
",",
"\"SUCCESS\"",
",",
"\"SNAPSHOT REQUEST QUEUED\"",
")",
";",
"final",
"ClientResponseImpl",
"resp",
"=",
"new",
"ClientResponseImpl",
"(",
"ClientResponseImpl",
".",
"SUCCESS",
",",
"new",
"VoltTable",
"[",
"]",
"{",
"result",
"}",
",",
"\"User-requested truncation snapshot successfully queued for execution.\"",
",",
"clientHandle",
")",
";",
"ByteBuffer",
"buf",
"=",
"ByteBuffer",
".",
"allocate",
"(",
"resp",
".",
"getSerializedSize",
"(",
")",
"+",
"4",
")",
";",
"buf",
".",
"putInt",
"(",
"buf",
".",
"capacity",
"(",
")",
"-",
"4",
")",
";",
"resp",
".",
"flattenToBuffer",
"(",
"buf",
")",
".",
"flip",
"(",
")",
";",
"c",
".",
"writeStream",
"(",
")",
".",
"enqueue",
"(",
"buf",
")",
";",
"}",
"}",
"if",
"(",
"requestExists",
")",
"{",
"VoltTable",
"result",
"=",
"SnapshotUtil",
".",
"constructNodeResultsTable",
"(",
")",
";",
"result",
".",
"addRow",
"(",
"-",
"1",
",",
"CoreUtils",
".",
"getHostnameOrAddress",
"(",
")",
",",
"\"\"",
",",
"\"FAILURE\"",
",",
"\"SNAPSHOT IN PROGRESS\"",
")",
";",
"throw",
"new",
"ForwardClientException",
"(",
"\"A request to perform a user snapshot already exists\"",
",",
"result",
")",
";",
"}",
"}"
] | Try to create the ZK request node and watch it if created successfully. | [
"Try",
"to",
"create",
"the",
"ZK",
"request",
"node",
"and",
"watch",
"it",
"if",
"created",
"successfully",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/SnapshotDaemon.java#L1704-L1750 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/layers/BasePretrainNetwork.java | BasePretrainNetwork.getCorruptedInput | public INDArray getCorruptedInput(INDArray x, double corruptionLevel) {
"""
Corrupts the given input by doing a binomial sampling
given the corruption level
@param x the input to corrupt
@param corruptionLevel the corruption value
@return the binomial sampled corrupted input
"""
INDArray corrupted = Nd4j.getDistributions().createBinomial(1, 1 - corruptionLevel).sample(x.ulike());
corrupted.muli(x.castTo(corrupted.dataType()));
return corrupted;
} | java | public INDArray getCorruptedInput(INDArray x, double corruptionLevel) {
INDArray corrupted = Nd4j.getDistributions().createBinomial(1, 1 - corruptionLevel).sample(x.ulike());
corrupted.muli(x.castTo(corrupted.dataType()));
return corrupted;
} | [
"public",
"INDArray",
"getCorruptedInput",
"(",
"INDArray",
"x",
",",
"double",
"corruptionLevel",
")",
"{",
"INDArray",
"corrupted",
"=",
"Nd4j",
".",
"getDistributions",
"(",
")",
".",
"createBinomial",
"(",
"1",
",",
"1",
"-",
"corruptionLevel",
")",
".",
"sample",
"(",
"x",
".",
"ulike",
"(",
")",
")",
";",
"corrupted",
".",
"muli",
"(",
"x",
".",
"castTo",
"(",
"corrupted",
".",
"dataType",
"(",
")",
")",
")",
";",
"return",
"corrupted",
";",
"}"
] | Corrupts the given input by doing a binomial sampling
given the corruption level
@param x the input to corrupt
@param corruptionLevel the corruption value
@return the binomial sampled corrupted input | [
"Corrupts",
"the",
"given",
"input",
"by",
"doing",
"a",
"binomial",
"sampling",
"given",
"the",
"corruption",
"level"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/layers/BasePretrainNetwork.java#L61-L65 |
pmayweg/sonar-groovy | sonar-groovy-plugin/src/main/java/org/sonar/plugins/groovy/jacoco/JaCoCoReportMerger.java | JaCoCoReportMerger.mergeReports | public static void mergeReports(File reportOverall, File... reports) {
"""
Merge all reports in reportOverall.
@param reportOverall destination file of merge.
@param reports files to be merged.
"""
SessionInfoStore infoStore = new SessionInfoStore();
ExecutionDataStore dataStore = new ExecutionDataStore();
boolean isCurrentVersionFormat = loadSourceFiles(infoStore, dataStore, reports);
try (BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(reportOverall))) {
Object visitor;
if (isCurrentVersionFormat) {
visitor = new ExecutionDataWriter(outputStream);
} else {
visitor = new org.jacoco.previous.core.data.ExecutionDataWriter(outputStream);
}
infoStore.accept((ISessionInfoVisitor) visitor);
dataStore.accept((IExecutionDataVisitor) visitor);
} catch (IOException e) {
throw new IllegalStateException(String.format("Unable to write overall coverage report %s", reportOverall.getAbsolutePath()), e);
}
} | java | public static void mergeReports(File reportOverall, File... reports) {
SessionInfoStore infoStore = new SessionInfoStore();
ExecutionDataStore dataStore = new ExecutionDataStore();
boolean isCurrentVersionFormat = loadSourceFiles(infoStore, dataStore, reports);
try (BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(reportOverall))) {
Object visitor;
if (isCurrentVersionFormat) {
visitor = new ExecutionDataWriter(outputStream);
} else {
visitor = new org.jacoco.previous.core.data.ExecutionDataWriter(outputStream);
}
infoStore.accept((ISessionInfoVisitor) visitor);
dataStore.accept((IExecutionDataVisitor) visitor);
} catch (IOException e) {
throw new IllegalStateException(String.format("Unable to write overall coverage report %s", reportOverall.getAbsolutePath()), e);
}
} | [
"public",
"static",
"void",
"mergeReports",
"(",
"File",
"reportOverall",
",",
"File",
"...",
"reports",
")",
"{",
"SessionInfoStore",
"infoStore",
"=",
"new",
"SessionInfoStore",
"(",
")",
";",
"ExecutionDataStore",
"dataStore",
"=",
"new",
"ExecutionDataStore",
"(",
")",
";",
"boolean",
"isCurrentVersionFormat",
"=",
"loadSourceFiles",
"(",
"infoStore",
",",
"dataStore",
",",
"reports",
")",
";",
"try",
"(",
"BufferedOutputStream",
"outputStream",
"=",
"new",
"BufferedOutputStream",
"(",
"new",
"FileOutputStream",
"(",
"reportOverall",
")",
")",
")",
"{",
"Object",
"visitor",
";",
"if",
"(",
"isCurrentVersionFormat",
")",
"{",
"visitor",
"=",
"new",
"ExecutionDataWriter",
"(",
"outputStream",
")",
";",
"}",
"else",
"{",
"visitor",
"=",
"new",
"org",
".",
"jacoco",
".",
"previous",
".",
"core",
".",
"data",
".",
"ExecutionDataWriter",
"(",
"outputStream",
")",
";",
"}",
"infoStore",
".",
"accept",
"(",
"(",
"ISessionInfoVisitor",
")",
"visitor",
")",
";",
"dataStore",
".",
"accept",
"(",
"(",
"IExecutionDataVisitor",
")",
"visitor",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"String",
".",
"format",
"(",
"\"Unable to write overall coverage report %s\"",
",",
"reportOverall",
".",
"getAbsolutePath",
"(",
")",
")",
",",
"e",
")",
";",
"}",
"}"
] | Merge all reports in reportOverall.
@param reportOverall destination file of merge.
@param reports files to be merged. | [
"Merge",
"all",
"reports",
"in",
"reportOverall",
"."
] | train | https://github.com/pmayweg/sonar-groovy/blob/2d78d6578304601613db928795d81de340e6fa34/sonar-groovy-plugin/src/main/java/org/sonar/plugins/groovy/jacoco/JaCoCoReportMerger.java#L49-L66 |
threerings/narya | tools/src/main/java/com/threerings/presents/tools/SourceFile.java | SourceFile.writeln | protected void writeln (BufferedWriter bout, String line)
throws IOException {
"""
Helper function for writing a string and a newline to a writer.
"""
bout.write(line);
bout.newLine();
} | java | protected void writeln (BufferedWriter bout, String line)
throws IOException
{
bout.write(line);
bout.newLine();
} | [
"protected",
"void",
"writeln",
"(",
"BufferedWriter",
"bout",
",",
"String",
"line",
")",
"throws",
"IOException",
"{",
"bout",
".",
"write",
"(",
"line",
")",
";",
"bout",
".",
"newLine",
"(",
")",
";",
"}"
] | Helper function for writing a string and a newline to a writer. | [
"Helper",
"function",
"for",
"writing",
"a",
"string",
"and",
"a",
"newline",
"to",
"a",
"writer",
"."
] | train | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/tools/src/main/java/com/threerings/presents/tools/SourceFile.java#L205-L210 |
Impetus/Kundera | src/kundera-cassandra/cassandra-core/src/main/java/com/impetus/client/cassandra/schemamanager/CassandraSchemaManager.java | CassandraSchemaManager.isMetadataSame | private boolean isMetadataSame(ColumnDef columnDef, ColumnInfo columnInfo, boolean isCql3Enabled,
boolean isCounterColumnType) throws Exception {
"""
is metadata same method returns true if ColumnDef and columnInfo have
same metadata.
@param columnDef
the column def
@param columnInfo
the column info
@param isCql3Enabled
the is cql3 enabled
@param isCounterColumnType
the is counter column type
@return true, if is metadata same
@throws Exception
the exception
"""
return isIndexPresent(columnInfo, columnDef, isCql3Enabled, isCounterColumnType);
} | java | private boolean isMetadataSame(ColumnDef columnDef, ColumnInfo columnInfo, boolean isCql3Enabled,
boolean isCounterColumnType) throws Exception
{
return isIndexPresent(columnInfo, columnDef, isCql3Enabled, isCounterColumnType);
} | [
"private",
"boolean",
"isMetadataSame",
"(",
"ColumnDef",
"columnDef",
",",
"ColumnInfo",
"columnInfo",
",",
"boolean",
"isCql3Enabled",
",",
"boolean",
"isCounterColumnType",
")",
"throws",
"Exception",
"{",
"return",
"isIndexPresent",
"(",
"columnInfo",
",",
"columnDef",
",",
"isCql3Enabled",
",",
"isCounterColumnType",
")",
";",
"}"
] | is metadata same method returns true if ColumnDef and columnInfo have
same metadata.
@param columnDef
the column def
@param columnInfo
the column info
@param isCql3Enabled
the is cql3 enabled
@param isCounterColumnType
the is counter column type
@return true, if is metadata same
@throws Exception
the exception | [
"is",
"metadata",
"same",
"method",
"returns",
"true",
"if",
"ColumnDef",
"and",
"columnInfo",
"have",
"same",
"metadata",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-cassandra/cassandra-core/src/main/java/com/impetus/client/cassandra/schemamanager/CassandraSchemaManager.java#L1953-L1957 |
ludovicianul/selenium-on-steroids | src/main/java/com/insidecoding/sos/webdriver/WebDriverHelper.java | WebDriverHelper.verifyText | public boolean verifyText(final By by, final String text) {
"""
Verifies that the given element contains the given text.
@param by
the method of identifying the element
@param text
the text to be matched
@return true if the given element contains the given text or false
otherwise
"""
WebElement element = driver.findElement(by);
if (element.getText().equals(text)) {
LOG.info("Element: " + element + " contains the given text: "
+ text);
return true;
}
LOG.info("Element: " + element + " does NOT contain the given text: "
+ text);
return false;
} | java | public boolean verifyText(final By by, final String text) {
WebElement element = driver.findElement(by);
if (element.getText().equals(text)) {
LOG.info("Element: " + element + " contains the given text: "
+ text);
return true;
}
LOG.info("Element: " + element + " does NOT contain the given text: "
+ text);
return false;
} | [
"public",
"boolean",
"verifyText",
"(",
"final",
"By",
"by",
",",
"final",
"String",
"text",
")",
"{",
"WebElement",
"element",
"=",
"driver",
".",
"findElement",
"(",
"by",
")",
";",
"if",
"(",
"element",
".",
"getText",
"(",
")",
".",
"equals",
"(",
"text",
")",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Element: \"",
"+",
"element",
"+",
"\" contains the given text: \"",
"+",
"text",
")",
";",
"return",
"true",
";",
"}",
"LOG",
".",
"info",
"(",
"\"Element: \"",
"+",
"element",
"+",
"\" does NOT contain the given text: \"",
"+",
"text",
")",
";",
"return",
"false",
";",
"}"
] | Verifies that the given element contains the given text.
@param by
the method of identifying the element
@param text
the text to be matched
@return true if the given element contains the given text or false
otherwise | [
"Verifies",
"that",
"the",
"given",
"element",
"contains",
"the",
"given",
"text",
"."
] | train | https://github.com/ludovicianul/selenium-on-steroids/blob/f89d91c59f686114f94624bfc55712f278005bfa/src/main/java/com/insidecoding/sos/webdriver/WebDriverHelper.java#L308-L321 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.