repository_name stringlengths 7 58 | func_path_in_repository stringlengths 18 188 | func_name stringlengths 7 127 | whole_func_string stringlengths 77 3.91k | language stringclasses 1
value | func_code_string stringlengths 77 3.91k | func_code_tokens listlengths 20 745 | func_documentation_string stringlengths 61 1.98k | func_documentation_tokens listlengths 1 477 | split_name stringclasses 1
value | func_code_url stringlengths 111 288 |
|---|---|---|---|---|---|---|---|---|---|---|
assertthat/selenium-shutterbug | src/main/java/com/assertthat/selenium_shutterbug/core/PageSnapshot.java | PageSnapshot.highlightWithText | public PageSnapshot highlightWithText(WebElement element, String text) {
try {
highlightWithText(element, Color.red, 3, text, Color.red, new Font("Serif", Font.BOLD, 20));
} catch (RasterFormatException rfe) {
throw new ElementOutsideViewportException(ELEMENT_OUT_OF_VIEWPORT_EX_MESSAGE, rfe);
}
return this;
} | java | public PageSnapshot highlightWithText(WebElement element, String text) {
try {
highlightWithText(element, Color.red, 3, text, Color.red, new Font("Serif", Font.BOLD, 20));
} catch (RasterFormatException rfe) {
throw new ElementOutsideViewportException(ELEMENT_OUT_OF_VIEWPORT_EX_MESSAGE, rfe);
}
return this;
} | [
"public",
"PageSnapshot",
"highlightWithText",
"(",
"WebElement",
"element",
",",
"String",
"text",
")",
"{",
"try",
"{",
"highlightWithText",
"(",
"element",
",",
"Color",
".",
"red",
",",
"3",
",",
"text",
",",
"Color",
".",
"red",
",",
"new",
"Font",
... | Highlight WebElement within the page (same as in {@link #highlight(WebElement)}}
and adding provided text above highlighted element.
@param element WebElement to be highlighted with Color.red
and line width 3
@param text test to be places above highlighted element with
Color.red, font "Serif", BOLD, size 20
@return instance of type PageSnapshot | [
"Highlight",
"WebElement",
"within",
"the",
"page",
"(",
"same",
"as",
"in",
"{",
"@link",
"#highlight",
"(",
"WebElement",
")",
"}}",
"and",
"adding",
"provided",
"text",
"above",
"highlighted",
"element",
"."
] | train | https://github.com/assertthat/selenium-shutterbug/blob/770d9b92423200d262c9ab70e40405921d81e262/src/main/java/com/assertthat/selenium_shutterbug/core/PageSnapshot.java#L71-L78 |
vorburger/ch.vorburger.exec | src/main/java/ch/vorburger/exec/ManagedProcessBuilder.java | ManagedProcessBuilder.addArgument | protected ManagedProcessBuilder addArgument(String argPart1, String separator, String argPart2) {
// @see MariaDB4j Issue #30 why 'quoting' (https://github.com/vorburger/MariaDB4j/issues/30)
StringBuilder sb = new StringBuilder();
sb.append(StringUtils.quoteArgument(argPart1));
sb.append(separator);
sb.append(StringUtils.quoteArgument(argPart2));
// @see https://issues.apache.org/jira/browse/EXEC-93 why we have to use 'false' here
// TODO Remove the false when commons-exec has a release including EXEC-93 fixed.
addArgument(sb.toString(), false);
return this;
} | java | protected ManagedProcessBuilder addArgument(String argPart1, String separator, String argPart2) {
// @see MariaDB4j Issue #30 why 'quoting' (https://github.com/vorburger/MariaDB4j/issues/30)
StringBuilder sb = new StringBuilder();
sb.append(StringUtils.quoteArgument(argPart1));
sb.append(separator);
sb.append(StringUtils.quoteArgument(argPart2));
// @see https://issues.apache.org/jira/browse/EXEC-93 why we have to use 'false' here
// TODO Remove the false when commons-exec has a release including EXEC-93 fixed.
addArgument(sb.toString(), false);
return this;
} | [
"protected",
"ManagedProcessBuilder",
"addArgument",
"(",
"String",
"argPart1",
",",
"String",
"separator",
",",
"String",
"argPart2",
")",
"{",
"// @see MariaDB4j Issue #30 why 'quoting' (https://github.com/vorburger/MariaDB4j/issues/30)",
"StringBuilder",
"sb",
"=",
"new",
"S... | Adds a single argument to the command, composed of two parts and a given separator.
The two parts are independently escaped (see above), and then concatenated using the separator. | [
"Adds",
"a",
"single",
"argument",
"to",
"the",
"command",
"composed",
"of",
"two",
"parts",
"and",
"a",
"given",
"separator",
".",
"The",
"two",
"parts",
"are",
"independently",
"escaped",
"(",
"see",
"above",
")",
"and",
"then",
"concatenated",
"using",
... | train | https://github.com/vorburger/ch.vorburger.exec/blob/98853c55c8dfb3a6185019b8928df2a091baa471/src/main/java/ch/vorburger/exec/ManagedProcessBuilder.java#L137-L147 |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/util/TimeUtil.java | TimeUtil.fillDateTimePool | public static final int fillDateTimePool(IWord[] wPool, IWord word)
{
int pIdx = getDateTimeIndex(word.getEntity(0));
if ( pIdx == DATETIME_NONE ) {
return DATETIME_NONE;
}
if ( wPool[pIdx] == null ) {
wPool[pIdx] = word;
return pIdx;
}
return DATETIME_NONE;
} | java | public static final int fillDateTimePool(IWord[] wPool, IWord word)
{
int pIdx = getDateTimeIndex(word.getEntity(0));
if ( pIdx == DATETIME_NONE ) {
return DATETIME_NONE;
}
if ( wPool[pIdx] == null ) {
wPool[pIdx] = word;
return pIdx;
}
return DATETIME_NONE;
} | [
"public",
"static",
"final",
"int",
"fillDateTimePool",
"(",
"IWord",
"[",
"]",
"wPool",
",",
"IWord",
"word",
")",
"{",
"int",
"pIdx",
"=",
"getDateTimeIndex",
"(",
"word",
".",
"getEntity",
"(",
"0",
")",
")",
";",
"if",
"(",
"pIdx",
"==",
"DATETIME_... | fill the date-time pool specified part through the specified
time entity string.
@param wPool
@param word
@return int | [
"fill",
"the",
"date",
"-",
"time",
"pool",
"specified",
"part",
"through",
"the",
"specified",
"time",
"entity",
"string",
"."
] | train | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/TimeUtil.java#L100-L113 |
dain/leveldb | leveldb/src/main/java/org/iq80/leveldb/util/Slice.java | Slice.setLong | public void setLong(int index, long value)
{
checkPositionIndexes(index, index + SIZE_OF_LONG, this.length);
index += offset;
data[index] = (byte) (value);
data[index + 1] = (byte) (value >>> 8);
data[index + 2] = (byte) (value >>> 16);
data[index + 3] = (byte) (value >>> 24);
data[index + 4] = (byte) (value >>> 32);
data[index + 5] = (byte) (value >>> 40);
data[index + 6] = (byte) (value >>> 48);
data[index + 7] = (byte) (value >>> 56);
} | java | public void setLong(int index, long value)
{
checkPositionIndexes(index, index + SIZE_OF_LONG, this.length);
index += offset;
data[index] = (byte) (value);
data[index + 1] = (byte) (value >>> 8);
data[index + 2] = (byte) (value >>> 16);
data[index + 3] = (byte) (value >>> 24);
data[index + 4] = (byte) (value >>> 32);
data[index + 5] = (byte) (value >>> 40);
data[index + 6] = (byte) (value >>> 48);
data[index + 7] = (byte) (value >>> 56);
} | [
"public",
"void",
"setLong",
"(",
"int",
"index",
",",
"long",
"value",
")",
"{",
"checkPositionIndexes",
"(",
"index",
",",
"index",
"+",
"SIZE_OF_LONG",
",",
"this",
".",
"length",
")",
";",
"index",
"+=",
"offset",
";",
"data",
"[",
"index",
"]",
"=... | Sets the specified 64-bit long integer at the specified absolute
{@code index} in this buffer.
@throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0} or
{@code index + 8} is greater than {@code this.capacity} | [
"Sets",
"the",
"specified",
"64",
"-",
"bit",
"long",
"integer",
"at",
"the",
"specified",
"absolute",
"{",
"@code",
"index",
"}",
"in",
"this",
"buffer",
"."
] | train | https://github.com/dain/leveldb/blob/7994065b48eada2ef29e7fefd172c2ad1e0110eb/leveldb/src/main/java/org/iq80/leveldb/util/Slice.java#L326-L338 |
schallee/alib4j | jvm/src/main/java/net/darkmist/alib/jvm/JVMLauncher.java | JVMLauncher.getProcessBuilder | public static ProcessBuilder getProcessBuilder(Class<?> mainClass, List<String> args) throws LauncherException
{
return getProcessBuilder(mainClass.getName(), getClassPathURLsFor(mainClass), args);
} | java | public static ProcessBuilder getProcessBuilder(Class<?> mainClass, List<String> args) throws LauncherException
{
return getProcessBuilder(mainClass.getName(), getClassPathURLsFor(mainClass), args);
} | [
"public",
"static",
"ProcessBuilder",
"getProcessBuilder",
"(",
"Class",
"<",
"?",
">",
"mainClass",
",",
"List",
"<",
"String",
">",
"args",
")",
"throws",
"LauncherException",
"{",
"return",
"getProcessBuilder",
"(",
"mainClass",
".",
"getName",
"(",
")",
",... | Get a process loader for a JVM. The class path for the JVM
is computed based on the class loaders for the main class.
@param mainClass Main class to run
@param args Additional command line parameters
@return ProcessBuilder that has not been started. | [
"Get",
"a",
"process",
"loader",
"for",
"a",
"JVM",
".",
"The",
"class",
"path",
"for",
"the",
"JVM",
"is",
"computed",
"based",
"on",
"the",
"class",
"loaders",
"for",
"the",
"main",
"class",
"."
] | train | https://github.com/schallee/alib4j/blob/0e0718aee574bbb62268e1cf58e99286529ce529/jvm/src/main/java/net/darkmist/alib/jvm/JVMLauncher.java#L194-L197 |
wcm-io/wcm-io-wcm | commons/src/main/java/io/wcm/wcm/commons/util/Path.java | Path.getAbsoluteParent | public static String getAbsoluteParent(@NotNull String path, int parentLevel, @NotNull ResourceResolver resourceResolver) {
if (parentLevel < 0) {
return "";
}
int level = parentLevel + getAbsoluteLevelOffset(path, resourceResolver);
return Text.getAbsoluteParent(path, level);
} | java | public static String getAbsoluteParent(@NotNull String path, int parentLevel, @NotNull ResourceResolver resourceResolver) {
if (parentLevel < 0) {
return "";
}
int level = parentLevel + getAbsoluteLevelOffset(path, resourceResolver);
return Text.getAbsoluteParent(path, level);
} | [
"public",
"static",
"String",
"getAbsoluteParent",
"(",
"@",
"NotNull",
"String",
"path",
",",
"int",
"parentLevel",
",",
"@",
"NotNull",
"ResourceResolver",
"resourceResolver",
")",
"{",
"if",
"(",
"parentLevel",
"<",
"0",
")",
"{",
"return",
"\"\"",
";",
"... | Get absolute parent of given path.
If the path is a version history or launch path the path level is adjusted accordingly.
This is a replacement for {@link com.day.text.Text#getAbsoluteParent(String, int)}.
@param path Path
@param parentLevel Parent level
@param resourceResolver Resource resolver
@return Absolute parent path or empty string if path is invalid | [
"Get",
"absolute",
"parent",
"of",
"given",
"path",
".",
"If",
"the",
"path",
"is",
"a",
"version",
"history",
"or",
"launch",
"path",
"the",
"path",
"level",
"is",
"adjusted",
"accordingly",
".",
"This",
"is",
"a",
"replacement",
"for",
"{"
] | train | https://github.com/wcm-io/wcm-io-wcm/blob/8eff9434f2f4b6462fdb718f8769ad793c55b8d7/commons/src/main/java/io/wcm/wcm/commons/util/Path.java#L78-L84 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/ValueEnforcer.java | ValueEnforcer.isEqual | public static void isEqual (final int nValue, final int nExpectedValue, final String sName)
{
if (isEnabled ())
isEqual (nValue, nExpectedValue, () -> sName);
} | java | public static void isEqual (final int nValue, final int nExpectedValue, final String sName)
{
if (isEnabled ())
isEqual (nValue, nExpectedValue, () -> sName);
} | [
"public",
"static",
"void",
"isEqual",
"(",
"final",
"int",
"nValue",
",",
"final",
"int",
"nExpectedValue",
",",
"final",
"String",
"sName",
")",
"{",
"if",
"(",
"isEnabled",
"(",
")",
")",
"isEqual",
"(",
"nValue",
",",
"nExpectedValue",
",",
"(",
")",... | Check that the passed value is the same as the provided expected value
using <code>==</code> to check comparison.
@param nValue
The First value.
@param nExpectedValue
The expected value.
@param sName
The name of the value (e.g. the parameter name)
@throws IllegalArgumentException
if the passed value is not <code>null</code>. | [
"Check",
"that",
"the",
"passed",
"value",
"is",
"the",
"same",
"as",
"the",
"provided",
"expected",
"value",
"using",
"<code",
">",
"==",
"<",
"/",
"code",
">",
"to",
"check",
"comparison",
"."
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/ValueEnforcer.java#L1534-L1538 |
netty/netty | common/src/main/java/io/netty/util/NetUtil.java | NetUtil.getByName | public static Inet6Address getByName(CharSequence ip, boolean ipv4Mapped) {
byte[] bytes = getIPv6ByName(ip, ipv4Mapped);
if (bytes == null) {
return null;
}
try {
return Inet6Address.getByAddress(null, bytes, -1);
} catch (UnknownHostException e) {
throw new RuntimeException(e); // Should never happen
}
} | java | public static Inet6Address getByName(CharSequence ip, boolean ipv4Mapped) {
byte[] bytes = getIPv6ByName(ip, ipv4Mapped);
if (bytes == null) {
return null;
}
try {
return Inet6Address.getByAddress(null, bytes, -1);
} catch (UnknownHostException e) {
throw new RuntimeException(e); // Should never happen
}
} | [
"public",
"static",
"Inet6Address",
"getByName",
"(",
"CharSequence",
"ip",
",",
"boolean",
"ipv4Mapped",
")",
"{",
"byte",
"[",
"]",
"bytes",
"=",
"getIPv6ByName",
"(",
"ip",
",",
"ipv4Mapped",
")",
";",
"if",
"(",
"bytes",
"==",
"null",
")",
"{",
"retu... | Returns the {@link Inet6Address} representation of a {@link CharSequence} IP address.
<p>
The {@code ipv4Mapped} parameter specifies how IPv4 addresses should be treated.
"IPv4 mapped" format as
defined in <a href="http://tools.ietf.org/html/rfc4291#section-2.5.5">rfc 4291 section 2</a> is supported.
@param ip {@link CharSequence} IP address to be converted to a {@link Inet6Address}
@param ipv4Mapped
<ul>
<li>{@code true} To allow IPv4 mapped inputs to be translated into {@link Inet6Address}</li>
<li>{@code false} Consider IPv4 mapped addresses as invalid.</li>
</ul>
@return {@link Inet6Address} representation of the {@code ip} or {@code null} if not a valid IP address. | [
"Returns",
"the",
"{"
] | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/common/src/main/java/io/netty/util/NetUtil.java#L715-L725 |
spring-cloud/spring-cloud-config | spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/support/AwsCodeCommitCredentialProvider.java | AwsCodeCommitCredentialProvider.retrieveAwsCredentials | private AWSCredentials retrieveAwsCredentials() {
if (this.awsCredentialProvider == null) {
if (this.username != null && this.password != null) {
this.logger.debug("Creating a static AWSCredentialsProvider");
this.awsCredentialProvider = new AWSStaticCredentialsProvider(
new BasicAWSCredentials(this.username, this.password));
}
else {
this.logger.debug("Creating a default AWSCredentialsProvider");
this.awsCredentialProvider = new DefaultAWSCredentialsProviderChain();
}
}
return this.awsCredentialProvider.getCredentials();
} | java | private AWSCredentials retrieveAwsCredentials() {
if (this.awsCredentialProvider == null) {
if (this.username != null && this.password != null) {
this.logger.debug("Creating a static AWSCredentialsProvider");
this.awsCredentialProvider = new AWSStaticCredentialsProvider(
new BasicAWSCredentials(this.username, this.password));
}
else {
this.logger.debug("Creating a default AWSCredentialsProvider");
this.awsCredentialProvider = new DefaultAWSCredentialsProviderChain();
}
}
return this.awsCredentialProvider.getCredentials();
} | [
"private",
"AWSCredentials",
"retrieveAwsCredentials",
"(",
")",
"{",
"if",
"(",
"this",
".",
"awsCredentialProvider",
"==",
"null",
")",
"{",
"if",
"(",
"this",
".",
"username",
"!=",
"null",
"&&",
"this",
".",
"password",
"!=",
"null",
")",
"{",
"this",
... | Get the AWSCredentials. If an AWSCredentialProvider was specified, use that,
otherwise, create a new AWSCredentialsProvider. If the username and password are
provided, then use those directly as AWSCredentials. Otherwise us the
{@link DefaultAWSCredentialsProviderChain} as is standard with AWS applications.
@return the AWS credentials. | [
"Get",
"the",
"AWSCredentials",
".",
"If",
"an",
"AWSCredentialProvider",
"was",
"specified",
"use",
"that",
"otherwise",
"create",
"a",
"new",
"AWSCredentialsProvider",
".",
"If",
"the",
"username",
"and",
"password",
"are",
"provided",
"then",
"use",
"those",
... | train | https://github.com/spring-cloud/spring-cloud-config/blob/6b99631f78bac4e1b521d2cc126c8b2da45d1f1f/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/support/AwsCodeCommitCredentialProvider.java#L264-L277 |
geomajas/geomajas-project-client-gwt | client/src/main/java/org/geomajas/gwt/client/gfx/context/DomHelper.java | DomHelper.createOrUpdateElement | public Element createOrUpdateElement(Object parent, String name, String type, Style style) {
return createOrUpdateElement(parent, name, type, style, true);
} | java | public Element createOrUpdateElement(Object parent, String name, String type, Style style) {
return createOrUpdateElement(parent, name, type, style, true);
} | [
"public",
"Element",
"createOrUpdateElement",
"(",
"Object",
"parent",
",",
"String",
"name",
",",
"String",
"type",
",",
"Style",
"style",
")",
"{",
"return",
"createOrUpdateElement",
"(",
"parent",
",",
"name",
",",
"type",
",",
"style",
",",
"true",
")",
... | Create or update an element in the DOM. The id will be generated.
@param parent
the parent group
@param name
the local group name of the element (should be unique within the group)
@param type
the type of the element (tag name, e.g. 'image')
@param style
The style to apply on the element.
@return the created or updated element or null if creation failed | [
"Create",
"or",
"update",
"an",
"element",
"in",
"the",
"DOM",
".",
"The",
"id",
"will",
"be",
"generated",
"."
] | train | https://github.com/geomajas/geomajas-project-client-gwt/blob/1c1adc48deb192ed825265eebcc74d70bbf45670/client/src/main/java/org/geomajas/gwt/client/gfx/context/DomHelper.java#L142-L144 |
foundation-runtime/service-directory | 1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/HeartbeatDirectoryRegistrationService.java | HeartbeatDirectoryRegistrationService.unregisterCachedServiceInstance | private void unregisterCachedServiceInstance(
String serviceName, String providerId) {
try {
write.lock();
ServiceInstanceId id = new ServiceInstanceId(serviceName, providerId);
getCacheServiceInstances().remove(id);
LOGGER.debug(
"delete cached ProvidedServiceInstance, serviceName={}, providerId={}.",
serviceName, providerId);
} finally {
write.unlock();
}
} | java | private void unregisterCachedServiceInstance(
String serviceName, String providerId) {
try {
write.lock();
ServiceInstanceId id = new ServiceInstanceId(serviceName, providerId);
getCacheServiceInstances().remove(id);
LOGGER.debug(
"delete cached ProvidedServiceInstance, serviceName={}, providerId={}.",
serviceName, providerId);
} finally {
write.unlock();
}
} | [
"private",
"void",
"unregisterCachedServiceInstance",
"(",
"String",
"serviceName",
",",
"String",
"providerId",
")",
"{",
"try",
"{",
"write",
".",
"lock",
"(",
")",
";",
"ServiceInstanceId",
"id",
"=",
"new",
"ServiceInstanceId",
"(",
"serviceName",
",",
"prov... | Delete the Cached ProvidedServiceInstance by serviceName and providerId.
It is thread safe.
@param serviceName
the serviceName.
@param providerId
the providerId. | [
"Delete",
"the",
"Cached",
"ProvidedServiceInstance",
"by",
"serviceName",
"and",
"providerId",
"."
] | train | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/HeartbeatDirectoryRegistrationService.java#L371-L383 |
googleapis/google-http-java-client | google-http-client/src/main/java/com/google/api/client/util/Types.java | Types.newInstance | public static <T> T newInstance(Class<T> clazz) {
// TODO(yanivi): investigate "sneaky" options for allocating the class that GSON uses, like
// setting the constructor to be accessible, or possibly provide a factory method of a special
// name
try {
return clazz.newInstance();
} catch (IllegalAccessException e) {
throw handleExceptionForNewInstance(e, clazz);
} catch (InstantiationException e) {
throw handleExceptionForNewInstance(e, clazz);
}
} | java | public static <T> T newInstance(Class<T> clazz) {
// TODO(yanivi): investigate "sneaky" options for allocating the class that GSON uses, like
// setting the constructor to be accessible, or possibly provide a factory method of a special
// name
try {
return clazz.newInstance();
} catch (IllegalAccessException e) {
throw handleExceptionForNewInstance(e, clazz);
} catch (InstantiationException e) {
throw handleExceptionForNewInstance(e, clazz);
}
} | [
"public",
"static",
"<",
"T",
">",
"T",
"newInstance",
"(",
"Class",
"<",
"T",
">",
"clazz",
")",
"{",
"// TODO(yanivi): investigate \"sneaky\" options for allocating the class that GSON uses, like",
"// setting the constructor to be accessible, or possibly provide a factory method o... | Creates a new instance of the given class by invoking its default constructor.
<p>The given class must be public and must have a public default constructor, and must not be
an array or an interface or be abstract. If an enclosing class, it must be static. | [
"Creates",
"a",
"new",
"instance",
"of",
"the",
"given",
"class",
"by",
"invoking",
"its",
"default",
"constructor",
"."
] | train | https://github.com/googleapis/google-http-java-client/blob/0988ae4e0f26a80f579b6adb2b276dd8254928de/google-http-client/src/main/java/com/google/api/client/util/Types.java#L108-L119 |
GoogleCloudPlatform/google-cloud-datastore | java/datastore/src/main/java/com/google/datastore/v1/client/DatastoreHelper.java | DatastoreHelper.getServiceAccountCredential | public static Credential getServiceAccountCredential(String serviceAccountId,
String privateKeyFile) throws GeneralSecurityException, IOException {
return getServiceAccountCredential(serviceAccountId, privateKeyFile, DatastoreOptions.SCOPES);
} | java | public static Credential getServiceAccountCredential(String serviceAccountId,
String privateKeyFile) throws GeneralSecurityException, IOException {
return getServiceAccountCredential(serviceAccountId, privateKeyFile, DatastoreOptions.SCOPES);
} | [
"public",
"static",
"Credential",
"getServiceAccountCredential",
"(",
"String",
"serviceAccountId",
",",
"String",
"privateKeyFile",
")",
"throws",
"GeneralSecurityException",
",",
"IOException",
"{",
"return",
"getServiceAccountCredential",
"(",
"serviceAccountId",
",",
"p... | Constructs credentials for the given account and key.
@param serviceAccountId service account ID (typically an e-mail address).
@param privateKeyFile the file name from which to get the private key.
@return valid credentials or {@code null} | [
"Constructs",
"credentials",
"for",
"the",
"given",
"account",
"and",
"key",
"."
] | train | https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/a23940d0634d7f537faf01ad9e60598046bcb40a/java/datastore/src/main/java/com/google/datastore/v1/client/DatastoreHelper.java#L163-L166 |
Azure/azure-sdk-for-java | automation/resource-manager/v2015_10_31/src/main/java/com/microsoft/azure/management/automation/v2015_10_31/implementation/StatisticsInner.java | StatisticsInner.listByAutomationAccountAsync | public Observable<List<StatisticsModelInner>> listByAutomationAccountAsync(String resourceGroupName, String automationAccountName, String filter) {
return listByAutomationAccountWithServiceResponseAsync(resourceGroupName, automationAccountName, filter).map(new Func1<ServiceResponse<List<StatisticsModelInner>>, List<StatisticsModelInner>>() {
@Override
public List<StatisticsModelInner> call(ServiceResponse<List<StatisticsModelInner>> response) {
return response.body();
}
});
} | java | public Observable<List<StatisticsModelInner>> listByAutomationAccountAsync(String resourceGroupName, String automationAccountName, String filter) {
return listByAutomationAccountWithServiceResponseAsync(resourceGroupName, automationAccountName, filter).map(new Func1<ServiceResponse<List<StatisticsModelInner>>, List<StatisticsModelInner>>() {
@Override
public List<StatisticsModelInner> call(ServiceResponse<List<StatisticsModelInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"List",
"<",
"StatisticsModelInner",
">",
">",
"listByAutomationAccountAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"automationAccountName",
",",
"String",
"filter",
")",
"{",
"return",
"listByAutomationAccountWithServiceResponseAs... | Retrieve the statistics for the account.
@param resourceGroupName Name of an Azure Resource group.
@param automationAccountName The name of the automation account.
@param filter The filter to apply on the operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<StatisticsModelInner> object | [
"Retrieve",
"the",
"statistics",
"for",
"the",
"account",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/automation/resource-manager/v2015_10_31/src/main/java/com/microsoft/azure/management/automation/v2015_10_31/implementation/StatisticsInner.java#L182-L189 |
googleapis/google-cloud-java | google-cloud-clients/google-cloud-spanner/src/main/java/com/google/cloud/spanner/Value.java | Value.float64Array | public static Value float64Array(@Nullable double[] v) {
return float64Array(v, 0, v == null ? 0 : v.length);
} | java | public static Value float64Array(@Nullable double[] v) {
return float64Array(v, 0, v == null ? 0 : v.length);
} | [
"public",
"static",
"Value",
"float64Array",
"(",
"@",
"Nullable",
"double",
"[",
"]",
"v",
")",
"{",
"return",
"float64Array",
"(",
"v",
",",
"0",
",",
"v",
"==",
"null",
"?",
"0",
":",
"v",
".",
"length",
")",
";",
"}"
] | Returns an {@code ARRAY<FLOAT64>} value.
@param v the source of element values, which may be null to produce a value for which {@code
isNull()} is {@code true} | [
"Returns",
"an",
"{",
"@code",
"ARRAY<FLOAT64",
">",
"}",
"value",
"."
] | train | https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-spanner/src/main/java/com/google/cloud/spanner/Value.java#L258-L260 |
spotbugs/spotbugs | spotbugs/src/gui/main/edu/umd/cs/findbugs/gui2/MainFrame.java | MainFrame.openAnalysis | public boolean openAnalysis(File f, SaveType saveType) {
if (!f.exists() || !f.canRead()) {
throw new IllegalArgumentException("Can't read " + f.getPath());
}
mainFrameLoadSaveHelper.prepareForFileLoad(f, saveType);
mainFrameLoadSaveHelper.loadAnalysis(f);
return true;
} | java | public boolean openAnalysis(File f, SaveType saveType) {
if (!f.exists() || !f.canRead()) {
throw new IllegalArgumentException("Can't read " + f.getPath());
}
mainFrameLoadSaveHelper.prepareForFileLoad(f, saveType);
mainFrameLoadSaveHelper.loadAnalysis(f);
return true;
} | [
"public",
"boolean",
"openAnalysis",
"(",
"File",
"f",
",",
"SaveType",
"saveType",
")",
"{",
"if",
"(",
"!",
"f",
".",
"exists",
"(",
")",
"||",
"!",
"f",
".",
"canRead",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Can't re... | Opens the analysis. Also clears the source and summary panes. Makes
comments enabled false. Sets the saveType and adds the file to the recent
menu.
@param f
@return whether the operation was successful | [
"Opens",
"the",
"analysis",
".",
"Also",
"clears",
"the",
"source",
"and",
"summary",
"panes",
".",
"Makes",
"comments",
"enabled",
"false",
".",
"Sets",
"the",
"saveType",
"and",
"adds",
"the",
"file",
"to",
"the",
"recent",
"menu",
"."
] | train | https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/gui/main/edu/umd/cs/findbugs/gui2/MainFrame.java#L392-L401 |
datastax/java-driver | query-builder/src/main/java/com/datastax/oss/driver/api/querybuilder/SchemaBuilder.java | SchemaBuilder.dropFunction | @NonNull
public static Drop dropFunction(
@Nullable CqlIdentifier keyspace, @NonNull CqlIdentifier functionName) {
return new DefaultDrop(keyspace, functionName, "FUNCTION");
} | java | @NonNull
public static Drop dropFunction(
@Nullable CqlIdentifier keyspace, @NonNull CqlIdentifier functionName) {
return new DefaultDrop(keyspace, functionName, "FUNCTION");
} | [
"@",
"NonNull",
"public",
"static",
"Drop",
"dropFunction",
"(",
"@",
"Nullable",
"CqlIdentifier",
"keyspace",
",",
"@",
"NonNull",
"CqlIdentifier",
"functionName",
")",
"{",
"return",
"new",
"DefaultDrop",
"(",
"keyspace",
",",
"functionName",
",",
"\"FUNCTION\""... | Starts a DROP FUNCTION query for the given function name for the given keyspace name. | [
"Starts",
"a",
"DROP",
"FUNCTION",
"query",
"for",
"the",
"given",
"function",
"name",
"for",
"the",
"given",
"keyspace",
"name",
"."
] | train | https://github.com/datastax/java-driver/blob/612a63f2525618e2020e86c9ad75ab37adba6132/query-builder/src/main/java/com/datastax/oss/driver/api/querybuilder/SchemaBuilder.java#L515-L519 |
line/armeria | thrift/src/main/java/com/linecorp/armeria/server/thrift/THttpService.java | THttpService.newDecorator | public static Function<Service<RpcRequest, RpcResponse>, THttpService> newDecorator(
SerializationFormat defaultSerializationFormat,
Iterable<SerializationFormat> otherAllowedSerializationFormats) {
final SerializationFormat[] allowedSerializationFormatArray = newAllowedSerializationFormats(
defaultSerializationFormat, otherAllowedSerializationFormats);
return delegate -> new THttpService(delegate, allowedSerializationFormatArray);
} | java | public static Function<Service<RpcRequest, RpcResponse>, THttpService> newDecorator(
SerializationFormat defaultSerializationFormat,
Iterable<SerializationFormat> otherAllowedSerializationFormats) {
final SerializationFormat[] allowedSerializationFormatArray = newAllowedSerializationFormats(
defaultSerializationFormat, otherAllowedSerializationFormats);
return delegate -> new THttpService(delegate, allowedSerializationFormatArray);
} | [
"public",
"static",
"Function",
"<",
"Service",
"<",
"RpcRequest",
",",
"RpcResponse",
">",
",",
"THttpService",
">",
"newDecorator",
"(",
"SerializationFormat",
"defaultSerializationFormat",
",",
"Iterable",
"<",
"SerializationFormat",
">",
"otherAllowedSerializationForm... | Creates a new decorator that supports the protocols specified in {@code allowedSerializationFormats} and
defaults to the specified {@code defaultSerializationFormat} when the client doesn't specify one.
Currently, the only way to specify a serialization format is by using the HTTP session protocol and
setting the Content-Type header to the appropriate {@link SerializationFormat#mediaType()}.
@param defaultSerializationFormat the default serialization format to use when not specified by the
client
@param otherAllowedSerializationFormats other serialization formats that should be supported by this
service in addition to the default | [
"Creates",
"a",
"new",
"decorator",
"that",
"supports",
"the",
"protocols",
"specified",
"in",
"{",
"@code",
"allowedSerializationFormats",
"}",
"and",
"defaults",
"to",
"the",
"specified",
"{",
"@code",
"defaultSerializationFormat",
"}",
"when",
"the",
"client",
... | train | https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/thrift/src/main/java/com/linecorp/armeria/server/thrift/THttpService.java#L332-L340 |
Impetus/Kundera | src/kundera-cassandra/cassandra-ds-driver/src/main/java/com/impetus/kundera/client/cassandra/dsdriver/DSClient.java | DSClient.iterateAndReturn | private List iterateAndReturn(ResultSet rSet, EntityMetadata metadata) {
MetamodelImpl metaModel =
(MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(metadata.getPersistenceUnit());
EntityType entityType = metaModel.entity(metadata.getEntityClazz());
Iterator<Row> rowIter = rSet.iterator();
List results = new ArrayList();
Map<String, Object> relationalValues = new HashMap<String, Object>();
while (rowIter.hasNext()) {
Object entity = null;
Row row = rowIter.next();
populateObjectFromRow(metadata, metaModel, entityType, results, relationalValues, entity, row);
}
return results;
} | java | private List iterateAndReturn(ResultSet rSet, EntityMetadata metadata) {
MetamodelImpl metaModel =
(MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(metadata.getPersistenceUnit());
EntityType entityType = metaModel.entity(metadata.getEntityClazz());
Iterator<Row> rowIter = rSet.iterator();
List results = new ArrayList();
Map<String, Object> relationalValues = new HashMap<String, Object>();
while (rowIter.hasNext()) {
Object entity = null;
Row row = rowIter.next();
populateObjectFromRow(metadata, metaModel, entityType, results, relationalValues, entity, row);
}
return results;
} | [
"private",
"List",
"iterateAndReturn",
"(",
"ResultSet",
"rSet",
",",
"EntityMetadata",
"metadata",
")",
"{",
"MetamodelImpl",
"metaModel",
"=",
"(",
"MetamodelImpl",
")",
"kunderaMetadata",
".",
"getApplicationMetadata",
"(",
")",
".",
"getMetamodel",
"(",
"metadat... | Iterate and return.
@param rSet
the r set
@param entityClazz
the entity clazz
@param metadata
the metadata
@return the list | [
"Iterate",
"and",
"return",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-cassandra/cassandra-ds-driver/src/main/java/com/impetus/kundera/client/cassandra/dsdriver/DSClient.java#L811-L827 |
hyperledger/fabric-sdk-java | src/main/java/org/hyperledger/fabric/sdk/Channel.java | Channel.serializeChannel | public byte[] serializeChannel() throws IOException, InvalidArgumentException {
if (isShutdown()) {
throw new InvalidArgumentException(format("Channel %s has been shutdown.", getName()));
}
ObjectOutputStream out = null;
try {
ByteArrayOutputStream bai = new ByteArrayOutputStream();
out = new ObjectOutputStream(bai);
out.writeObject(this);
out.flush();
return bai.toByteArray();
} finally {
if (null != out) {
try {
out.close();
} catch (IOException e) {
logger.error(e); // best effort.
}
}
}
} | java | public byte[] serializeChannel() throws IOException, InvalidArgumentException {
if (isShutdown()) {
throw new InvalidArgumentException(format("Channel %s has been shutdown.", getName()));
}
ObjectOutputStream out = null;
try {
ByteArrayOutputStream bai = new ByteArrayOutputStream();
out = new ObjectOutputStream(bai);
out.writeObject(this);
out.flush();
return bai.toByteArray();
} finally {
if (null != out) {
try {
out.close();
} catch (IOException e) {
logger.error(e); // best effort.
}
}
}
} | [
"public",
"byte",
"[",
"]",
"serializeChannel",
"(",
")",
"throws",
"IOException",
",",
"InvalidArgumentException",
"{",
"if",
"(",
"isShutdown",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"format",
"(",
"\"Channel %s has been shutdown.\"",... | Serialize channel to a byte array using Java serialization.
Deserialized channel will NOT be in an initialized state.
@throws InvalidArgumentException
@throws IOException | [
"Serialize",
"channel",
"to",
"a",
"byte",
"array",
"using",
"Java",
"serialization",
".",
"Deserialized",
"channel",
"will",
"NOT",
"be",
"in",
"an",
"initialized",
"state",
"."
] | train | https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L6164-L6188 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NumberFormat.java | NumberFormat.parseObject | @Override
public final Object parseObject(String source,
ParsePosition parsePosition) {
return parse(source, parsePosition);
} | java | @Override
public final Object parseObject(String source,
ParsePosition parsePosition) {
return parse(source, parsePosition);
} | [
"@",
"Override",
"public",
"final",
"Object",
"parseObject",
"(",
"String",
"source",
",",
"ParsePosition",
"parsePosition",
")",
"{",
"return",
"parse",
"(",
"source",
",",
"parsePosition",
")",
";",
"}"
] | Parses text from a string to produce a number.
@param source the String to parse
@param parsePosition the position at which to start the parse
@return the parsed number, or null
@see java.text.NumberFormat#parseObject(String, ParsePosition) | [
"Parses",
"text",
"from",
"a",
"string",
"to",
"produce",
"a",
"number",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/NumberFormat.java#L276-L280 |
qiniu/java-sdk | src/main/java/com/qiniu/cdn/CdnManager.java | CdnManager.createTimestampAntiLeechUrl | public static String createTimestampAntiLeechUrl(
String host, String fileName, final StringMap queryStringMap, String encryptKey, long deadline)
throws QiniuException {
URL urlObj = null;
try {
String urlToSign = null;
if (queryStringMap != null && queryStringMap.size() > 0) {
List<String> queryStrings = new ArrayList<String>();
for (Map.Entry<String, Object> entry : queryStringMap.map().entrySet()) {
StringBuilder queryStringBuilder = new StringBuilder();
queryStringBuilder.append(URLEncoder.encode(entry.getKey(), "utf-8"));
queryStringBuilder.append("=");
queryStringBuilder.append(URLEncoder.encode(entry.getValue().toString(), "utf-8"));
queryStrings.add(queryStringBuilder.toString());
}
urlToSign = String.format("%s/%s?%s", host, fileName, StringUtils.join(queryStrings, "&"));
} else {
urlToSign = String.format("%s/%s", host, fileName);
}
urlObj = new URL(urlToSign);
} catch (Exception e) {
throw new QiniuException(e, "timestamp anti leech failed");
}
return createTimestampAntiLeechUrl(urlObj, encryptKey, deadline);
} | java | public static String createTimestampAntiLeechUrl(
String host, String fileName, final StringMap queryStringMap, String encryptKey, long deadline)
throws QiniuException {
URL urlObj = null;
try {
String urlToSign = null;
if (queryStringMap != null && queryStringMap.size() > 0) {
List<String> queryStrings = new ArrayList<String>();
for (Map.Entry<String, Object> entry : queryStringMap.map().entrySet()) {
StringBuilder queryStringBuilder = new StringBuilder();
queryStringBuilder.append(URLEncoder.encode(entry.getKey(), "utf-8"));
queryStringBuilder.append("=");
queryStringBuilder.append(URLEncoder.encode(entry.getValue().toString(), "utf-8"));
queryStrings.add(queryStringBuilder.toString());
}
urlToSign = String.format("%s/%s?%s", host, fileName, StringUtils.join(queryStrings, "&"));
} else {
urlToSign = String.format("%s/%s", host, fileName);
}
urlObj = new URL(urlToSign);
} catch (Exception e) {
throw new QiniuException(e, "timestamp anti leech failed");
}
return createTimestampAntiLeechUrl(urlObj, encryptKey, deadline);
} | [
"public",
"static",
"String",
"createTimestampAntiLeechUrl",
"(",
"String",
"host",
",",
"String",
"fileName",
",",
"final",
"StringMap",
"queryStringMap",
",",
"String",
"encryptKey",
",",
"long",
"deadline",
")",
"throws",
"QiniuException",
"{",
"URL",
"urlObj",
... | 构建七牛标准的基于时间戳的防盗链
参考文档:<a href="https://support.qiniu.com/question/195128">时间戳防盗链</a>
@param host 自定义域名,例如 http://img.abc.com
@param fileName 待访问的原始文件名,必须是utf8编码,不需要进行urlencode
@param queryStringMap 业务自身的查询参数,必须是utf8编码,不需要进行urlencode
@param encryptKey 时间戳防盗链的签名密钥,从七牛后台获取
@param deadline 链接的有效期时间戳,是以秒为单位的Unix时间戳
@return signedUrl 最终的带时间戳防盗链的url | [
"构建七牛标准的基于时间戳的防盗链",
"参考文档:<a",
"href",
"=",
"https",
":",
"//",
"support",
".",
"qiniu",
".",
"com",
"/",
"question",
"/",
"195128",
">",
"时间戳防盗链<",
"/",
"a",
">"
] | train | https://github.com/qiniu/java-sdk/blob/6c05f3fb718403a496c725b048e9241f80171499/src/main/java/com/qiniu/cdn/CdnManager.java#L242-L267 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/net/URLConnection.java | URLConnection.setRequestProperty | public void setRequestProperty(String key, String value) {
if (connected)
throw new IllegalStateException("Already connected");
if (key == null)
throw new NullPointerException ("key is null");
if (requests == null)
requests = new MessageHeader();
requests.set(key, value);
} | java | public void setRequestProperty(String key, String value) {
if (connected)
throw new IllegalStateException("Already connected");
if (key == null)
throw new NullPointerException ("key is null");
if (requests == null)
requests = new MessageHeader();
requests.set(key, value);
} | [
"public",
"void",
"setRequestProperty",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"if",
"(",
"connected",
")",
"throw",
"new",
"IllegalStateException",
"(",
"\"Already connected\"",
")",
";",
"if",
"(",
"key",
"==",
"null",
")",
"throw",
"new",... | Sets the general request property. If a property with the key already
exists, overwrite its value with the new value.
<p> NOTE: HTTP requires all request properties which can
legally have multiple instances with the same key
to use a comma-seperated list syntax which enables multiple
properties to be appended into a single property.
@param key the keyword by which the request is known
(e.g., "<code>Accept</code>").
@param value the value associated with it.
@throws IllegalStateException if already connected
@throws NullPointerException if key is <CODE>null</CODE>
@see #getRequestProperty(java.lang.String) | [
"Sets",
"the",
"general",
"request",
"property",
".",
"If",
"a",
"property",
"with",
"the",
"key",
"already",
"exists",
"overwrite",
"its",
"value",
"with",
"the",
"new",
"value",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/net/URLConnection.java#L1068-L1078 |
xwiki/xwiki-commons | xwiki-commons-core/xwiki-commons-properties/src/main/java/org/xwiki/properties/internal/converter/EnumConverter.java | EnumConverter.generateInvalidErrorMessage | private String generateInvalidErrorMessage(Object[] enumValues, String testValue)
{
StringBuffer errorMessage = new StringBuffer("Unable to convert value [" + testValue + "].");
errorMessage.append(" Allowed values are (case insensitive) ");
StringBuffer valueList = new StringBuffer();
int index = 1;
for (Object enumValue : enumValues) {
if (valueList.length() > 0) {
if (++index == enumValues.length) {
valueList.append(" or ");
} else {
valueList.append(", ");
}
}
valueList.append('"');
valueList.append(enumValue);
valueList.append('"');
}
errorMessage.append(valueList);
errorMessage.append('.');
return errorMessage.toString();
} | java | private String generateInvalidErrorMessage(Object[] enumValues, String testValue)
{
StringBuffer errorMessage = new StringBuffer("Unable to convert value [" + testValue + "].");
errorMessage.append(" Allowed values are (case insensitive) ");
StringBuffer valueList = new StringBuffer();
int index = 1;
for (Object enumValue : enumValues) {
if (valueList.length() > 0) {
if (++index == enumValues.length) {
valueList.append(" or ");
} else {
valueList.append(", ");
}
}
valueList.append('"');
valueList.append(enumValue);
valueList.append('"');
}
errorMessage.append(valueList);
errorMessage.append('.');
return errorMessage.toString();
} | [
"private",
"String",
"generateInvalidErrorMessage",
"(",
"Object",
"[",
"]",
"enumValues",
",",
"String",
"testValue",
")",
"{",
"StringBuffer",
"errorMessage",
"=",
"new",
"StringBuffer",
"(",
"\"Unable to convert value [\"",
"+",
"testValue",
"+",
"\"].\"",
")",
"... | Generate error message to use in the {@link ConversionException}.
@param enumValues possible values of the enum.
@param testValue the value to convert.
@return the generated error message. | [
"Generate",
"error",
"message",
"to",
"use",
"in",
"the",
"{",
"@link",
"ConversionException",
"}",
"."
] | train | https://github.com/xwiki/xwiki-commons/blob/5374d8c6d966588c1eac7392c83da610dfb9f129/xwiki-commons-core/xwiki-commons-properties/src/main/java/org/xwiki/properties/internal/converter/EnumConverter.java#L67-L94 |
ops4j/org.ops4j.pax.logging | pax-logging-api/src/main/java/org/apache/logging/log4j/ThreadContext.java | ThreadContext.putAll | public static void putAll(final Map<String, String> m) {
if (contextMap instanceof ThreadContextMap2) {
((ThreadContextMap2) contextMap).putAll(m);
} else if (contextMap instanceof DefaultThreadContextMap) {
((DefaultThreadContextMap) contextMap).putAll(m);
} else {
for (final Map.Entry<String, String> entry: m.entrySet()) {
contextMap.put(entry.getKey(), entry.getValue());
}
}
} | java | public static void putAll(final Map<String, String> m) {
if (contextMap instanceof ThreadContextMap2) {
((ThreadContextMap2) contextMap).putAll(m);
} else if (contextMap instanceof DefaultThreadContextMap) {
((DefaultThreadContextMap) contextMap).putAll(m);
} else {
for (final Map.Entry<String, String> entry: m.entrySet()) {
contextMap.put(entry.getKey(), entry.getValue());
}
}
} | [
"public",
"static",
"void",
"putAll",
"(",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"m",
")",
"{",
"if",
"(",
"contextMap",
"instanceof",
"ThreadContextMap2",
")",
"{",
"(",
"(",
"ThreadContextMap2",
")",
"contextMap",
")",
".",
"putAll",
"(",
... | Puts all given context map entries into the current thread's
context map.
<p>If the current thread does not have a context map it is
created as a side effect.</p>
@param m The map.
@since 2.7 | [
"Puts",
"all",
"given",
"context",
"map",
"entries",
"into",
"the",
"current",
"thread",
"s",
"context",
"map",
"."
] | train | https://github.com/ops4j/org.ops4j.pax.logging/blob/493de4e1db4fe9f981f3dd78b8e40e5bf2b2e59d/pax-logging-api/src/main/java/org/apache/logging/log4j/ThreadContext.java#L248-L258 |
UrielCh/ovh-java-sdk | ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java | ApiOvhTelephony.billingAccount_easyHunting_serviceName_PUT | public void billingAccount_easyHunting_serviceName_PUT(String billingAccount, String serviceName, OvhEasyHunting body) throws IOException {
String qPath = "/telephony/{billingAccount}/easyHunting/{serviceName}";
StringBuilder sb = path(qPath, billingAccount, serviceName);
exec(qPath, "PUT", sb.toString(), body);
} | java | public void billingAccount_easyHunting_serviceName_PUT(String billingAccount, String serviceName, OvhEasyHunting body) throws IOException {
String qPath = "/telephony/{billingAccount}/easyHunting/{serviceName}";
StringBuilder sb = path(qPath, billingAccount, serviceName);
exec(qPath, "PUT", sb.toString(), body);
} | [
"public",
"void",
"billingAccount_easyHunting_serviceName_PUT",
"(",
"String",
"billingAccount",
",",
"String",
"serviceName",
",",
"OvhEasyHunting",
"body",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/telephony/{billingAccount}/easyHunting/{serviceName}\"",
... | Alter this object properties
REST: PUT /telephony/{billingAccount}/easyHunting/{serviceName}
@param body [required] New object properties
@param billingAccount [required] The name of your billingAccount
@param serviceName [required] | [
"Alter",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L3450-L3454 |
greese/dasein-util | src/main/java/org/dasein/util/ConcurrentCache.java | ConcurrentCache.put | public V put(K key, V val) {
//synchronized( this ) {
//WeakReference<V> ref = new WeakReference<V>(val);
SoftReference<V> ref = new SoftReference<V>(val);
cache.put(key, ref);
return get(key);
//}
} | java | public V put(K key, V val) {
//synchronized( this ) {
//WeakReference<V> ref = new WeakReference<V>(val);
SoftReference<V> ref = new SoftReference<V>(val);
cache.put(key, ref);
return get(key);
//}
} | [
"public",
"V",
"put",
"(",
"K",
"key",
",",
"V",
"val",
")",
"{",
"//synchronized( this ) {",
"//WeakReference<V> ref = new WeakReference<V>(val);",
"SoftReference",
"<",
"V",
">",
"ref",
"=",
"new",
"SoftReference",
"<",
"V",
">",
"(",
"val",
")",
";",
"cache... | Places the specified value into the cache.
@param key the key for the item being placed into the cache
@param val the item to be cached
@return the resulting value stored in the cache | [
"Places",
"the",
"specified",
"value",
"into",
"the",
"cache",
"."
] | train | https://github.com/greese/dasein-util/blob/648606dcb4bd382e3287a6c897a32e65d553dc47/src/main/java/org/dasein/util/ConcurrentCache.java#L259-L267 |
ddf-project/DDF | core/src/main/java/io/ddf/DDFManager.java | DDFManager.get | public static DDFManager get(EngineType engineType) throws DDFException {
if (engineType == null) {
engineType = EngineType.fromString(ConfigConstant.ENGINE_NAME_DEFAULT.toString());
}
String className = Config.getValue(engineType.name(), ConfigConstant.FIELD_DDF_MANAGER);
if (Strings.isNullOrEmpty(className)) {
throw new DDFException("ERROR: When initializaing ddfmanager, class " +
className + " not found");
}
try {
DDFManager manager = (DDFManager) Class.forName(className).newInstance();
if (manager == null) {
throw new DDFException("ERROR: Initializaing manager fail.");
}
return manager;
} catch (Exception e) {
// throw new DDFException("Cannot get DDFManager for engine " + engineName, e);
throw new DDFException(
"Cannot get DDFManager for engine " + engineType.name() + " " +
"classname " + className + " " + e.getMessage());
}
} | java | public static DDFManager get(EngineType engineType) throws DDFException {
if (engineType == null) {
engineType = EngineType.fromString(ConfigConstant.ENGINE_NAME_DEFAULT.toString());
}
String className = Config.getValue(engineType.name(), ConfigConstant.FIELD_DDF_MANAGER);
if (Strings.isNullOrEmpty(className)) {
throw new DDFException("ERROR: When initializaing ddfmanager, class " +
className + " not found");
}
try {
DDFManager manager = (DDFManager) Class.forName(className).newInstance();
if (manager == null) {
throw new DDFException("ERROR: Initializaing manager fail.");
}
return manager;
} catch (Exception e) {
// throw new DDFException("Cannot get DDFManager for engine " + engineName, e);
throw new DDFException(
"Cannot get DDFManager for engine " + engineType.name() + " " +
"classname " + className + " " + e.getMessage());
}
} | [
"public",
"static",
"DDFManager",
"get",
"(",
"EngineType",
"engineType",
")",
"throws",
"DDFException",
"{",
"if",
"(",
"engineType",
"==",
"null",
")",
"{",
"engineType",
"=",
"EngineType",
".",
"fromString",
"(",
"ConfigConstant",
".",
"ENGINE_NAME_DEFAULT",
... | Returns a new instance of {@link DDFManager} for the given engine type
@param engineType
@return
@throws Exception | [
"Returns",
"a",
"new",
"instance",
"of",
"{",
"@link",
"DDFManager",
"}",
"for",
"the",
"given",
"engine",
"type"
] | train | https://github.com/ddf-project/DDF/blob/e4e68315dcec1ed8b287bf1ee73baa88e7e41eba/core/src/main/java/io/ddf/DDFManager.java#L230-L255 |
Wikidata/Wikidata-Toolkit | wdtk-examples/src/main/java/org/wikidata/wdtk/examples/LifeExpectancyProcessor.java | LifeExpectancyProcessor.getYearIfAny | private int getYearIfAny(StatementDocument document, String propertyId) {
TimeValue date = document.findStatementTimeValue(propertyId);
if (date != null && date.getPrecision() >= TimeValue.PREC_YEAR) {
return (int) date.getYear();
} else {
return Integer.MIN_VALUE;
}
} | java | private int getYearIfAny(StatementDocument document, String propertyId) {
TimeValue date = document.findStatementTimeValue(propertyId);
if (date != null && date.getPrecision() >= TimeValue.PREC_YEAR) {
return (int) date.getYear();
} else {
return Integer.MIN_VALUE;
}
} | [
"private",
"int",
"getYearIfAny",
"(",
"StatementDocument",
"document",
",",
"String",
"propertyId",
")",
"{",
"TimeValue",
"date",
"=",
"document",
".",
"findStatementTimeValue",
"(",
"propertyId",
")",
";",
"if",
"(",
"date",
"!=",
"null",
"&&",
"date",
".",... | Helper method that finds the first value of a time-valued property (if
any), and extracts an integer year. It checks if the value has sufficient
precision to extract an exact year.
@param document
the document to extract the data from
@param propertyId
the string id of the property to look for
@return the year, or Interger.MIN_VALUE if none was found | [
"Helper",
"method",
"that",
"finds",
"the",
"first",
"value",
"of",
"a",
"time",
"-",
"valued",
"property",
"(",
"if",
"any",
")",
"and",
"extracts",
"an",
"integer",
"year",
".",
"It",
"checks",
"if",
"the",
"value",
"has",
"sufficient",
"precision",
"t... | train | https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-examples/src/main/java/org/wikidata/wdtk/examples/LifeExpectancyProcessor.java#L155-L162 |
before/uadetector | modules/uadetector-core/src/main/java/net/sf/uadetector/datastore/UpdateOperationWithCacheFileTask.java | UpdateOperationWithCacheFileTask.renameFile | protected static void renameFile(@Nonnull final File from, @Nonnull final File to) {
Check.notNull(from, "from");
Check.stateIsTrue(from.exists(), "Argument 'from' must not be an existing file.");
Check.notNull(to, "to");
Check.stateIsTrue(from.renameTo(to), "Renaming file from '%s' to '%s' failed.", from.getAbsolutePath(), to.getAbsolutePath());
} | java | protected static void renameFile(@Nonnull final File from, @Nonnull final File to) {
Check.notNull(from, "from");
Check.stateIsTrue(from.exists(), "Argument 'from' must not be an existing file.");
Check.notNull(to, "to");
Check.stateIsTrue(from.renameTo(to), "Renaming file from '%s' to '%s' failed.", from.getAbsolutePath(), to.getAbsolutePath());
} | [
"protected",
"static",
"void",
"renameFile",
"(",
"@",
"Nonnull",
"final",
"File",
"from",
",",
"@",
"Nonnull",
"final",
"File",
"to",
")",
"{",
"Check",
".",
"notNull",
"(",
"from",
",",
"\"from\"",
")",
";",
"Check",
".",
"stateIsTrue",
"(",
"from",
... | Renames the given file {@code from} to the new file {@code to}.
@param from
an existing file
@param to
a new file
@throws net.sf.qualitycheck.exception.IllegalNullArgumentException
if one of the given arguments is {@code null}
@throws net.sf.qualitycheck.exception.IllegalStateOfArgumentException
if the file can not be renamed | [
"Renames",
"the",
"given",
"file",
"{",
"@code",
"from",
"}",
"to",
"the",
"new",
"file",
"{",
"@code",
"to",
"}",
"."
] | train | https://github.com/before/uadetector/blob/215fb652723c52866572cff885f52a3fe67b9db5/modules/uadetector-core/src/main/java/net/sf/uadetector/datastore/UpdateOperationWithCacheFileTask.java#L184-L189 |
apache/flink | flink-connectors/flink-connector-kafka-base/src/main/java/org/apache/flink/table/descriptors/Kafka.java | Kafka.startFromSpecificOffset | public Kafka startFromSpecificOffset(int partition, long specificOffset) {
this.startupMode = StartupMode.SPECIFIC_OFFSETS;
if (this.specificOffsets == null) {
this.specificOffsets = new HashMap<>();
}
this.specificOffsets.put(partition, specificOffset);
return this;
} | java | public Kafka startFromSpecificOffset(int partition, long specificOffset) {
this.startupMode = StartupMode.SPECIFIC_OFFSETS;
if (this.specificOffsets == null) {
this.specificOffsets = new HashMap<>();
}
this.specificOffsets.put(partition, specificOffset);
return this;
} | [
"public",
"Kafka",
"startFromSpecificOffset",
"(",
"int",
"partition",
",",
"long",
"specificOffset",
")",
"{",
"this",
".",
"startupMode",
"=",
"StartupMode",
".",
"SPECIFIC_OFFSETS",
";",
"if",
"(",
"this",
".",
"specificOffsets",
"==",
"null",
")",
"{",
"th... | Configures to start reading partitions from specific offsets and specifies the given offset for
the given partition.
@param partition partition index
@param specificOffset partition offset to start reading from
@see FlinkKafkaConsumerBase#setStartFromSpecificOffsets(Map) | [
"Configures",
"to",
"start",
"reading",
"partitions",
"from",
"specific",
"offsets",
"and",
"specifies",
"the",
"given",
"offset",
"for",
"the",
"given",
"partition",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-connectors/flink-connector-kafka-base/src/main/java/org/apache/flink/table/descriptors/Kafka.java#L177-L184 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/string/StringHelper.java | StringHelper.getImploded | @Nonnull
public static <KEYTYPE, VALUETYPE> String getImploded (final char cSepOuter,
final char cSepInner,
@Nullable final Map <KEYTYPE, VALUETYPE> aElements)
{
return getImplodedMapped (cSepOuter, cSepInner, aElements, String::valueOf, String::valueOf);
} | java | @Nonnull
public static <KEYTYPE, VALUETYPE> String getImploded (final char cSepOuter,
final char cSepInner,
@Nullable final Map <KEYTYPE, VALUETYPE> aElements)
{
return getImplodedMapped (cSepOuter, cSepInner, aElements, String::valueOf, String::valueOf);
} | [
"@",
"Nonnull",
"public",
"static",
"<",
"KEYTYPE",
",",
"VALUETYPE",
">",
"String",
"getImploded",
"(",
"final",
"char",
"cSepOuter",
",",
"final",
"char",
"cSepInner",
",",
"@",
"Nullable",
"final",
"Map",
"<",
"KEYTYPE",
",",
"VALUETYPE",
">",
"aElements"... | Get a concatenated String from all elements of the passed map, separated by
the specified separator chars.
@param cSepOuter
The separator to use for separating the map entries.
@param cSepInner
The separator to use for separating the key from the value.
@param aElements
The map to convert. May be <code>null</code> or empty.
@return The concatenated string.
@param <KEYTYPE>
Map key type
@param <VALUETYPE>
Map value type | [
"Get",
"a",
"concatenated",
"String",
"from",
"all",
"elements",
"of",
"the",
"passed",
"map",
"separated",
"by",
"the",
"specified",
"separator",
"chars",
"."
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/string/StringHelper.java#L1059-L1065 |
ManfredTremmel/gwt-commons-lang3 | src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java | TypeUtils.getTypeArguments | private static Map<TypeVariable<?>, Type> getTypeArguments(Class<?> cls, final Class<?> toClass,
final Map<TypeVariable<?>, Type> subtypeVarAssigns) {
// make sure they're assignable
if (!isAssignable(cls, toClass)) {
return null;
}
// can't work with primitives
if (cls.isPrimitive()) {
// both classes are primitives?
if (toClass.isPrimitive()) {
// dealing with widening here. No type arguments to be
// harvested with these two types.
return new HashMap<>();
}
// work with wrapper the wrapper class instead of the primitive
cls = ClassUtils.primitiveToWrapper(cls);
}
// create a copy of the incoming map, or an empty one if it's null
final HashMap<TypeVariable<?>, Type> typeVarAssigns = subtypeVarAssigns == null ? new HashMap<TypeVariable<?>, Type>()
: new HashMap<>(subtypeVarAssigns);
// has target class been reached?
if (toClass.equals(cls)) {
return typeVarAssigns;
}
// walk the inheritance hierarchy until the target class is reached
return getTypeArguments(getClosestParentType(cls, toClass), toClass, typeVarAssigns);
} | java | private static Map<TypeVariable<?>, Type> getTypeArguments(Class<?> cls, final Class<?> toClass,
final Map<TypeVariable<?>, Type> subtypeVarAssigns) {
// make sure they're assignable
if (!isAssignable(cls, toClass)) {
return null;
}
// can't work with primitives
if (cls.isPrimitive()) {
// both classes are primitives?
if (toClass.isPrimitive()) {
// dealing with widening here. No type arguments to be
// harvested with these two types.
return new HashMap<>();
}
// work with wrapper the wrapper class instead of the primitive
cls = ClassUtils.primitiveToWrapper(cls);
}
// create a copy of the incoming map, or an empty one if it's null
final HashMap<TypeVariable<?>, Type> typeVarAssigns = subtypeVarAssigns == null ? new HashMap<TypeVariable<?>, Type>()
: new HashMap<>(subtypeVarAssigns);
// has target class been reached?
if (toClass.equals(cls)) {
return typeVarAssigns;
}
// walk the inheritance hierarchy until the target class is reached
return getTypeArguments(getClosestParentType(cls, toClass), toClass, typeVarAssigns);
} | [
"private",
"static",
"Map",
"<",
"TypeVariable",
"<",
"?",
">",
",",
"Type",
">",
"getTypeArguments",
"(",
"Class",
"<",
"?",
">",
"cls",
",",
"final",
"Class",
"<",
"?",
">",
"toClass",
",",
"final",
"Map",
"<",
"TypeVariable",
"<",
"?",
">",
",",
... | <p>Return a map of the type arguments of a class in the context of {@code toClass}.</p>
@param cls the class in question
@param toClass the context class
@param subtypeVarAssigns a map with type variables
@return the {@code Map} with type arguments | [
"<p",
">",
"Return",
"a",
"map",
"of",
"the",
"type",
"arguments",
"of",
"a",
"class",
"in",
"the",
"context",
"of",
"{",
"@code",
"toClass",
"}",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java#L903-L934 |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/factory/feature/disparity/FactoryStereoDisparity.java | FactoryStereoDisparity.regionSparseWta | public static <T extends ImageGray<T>> StereoDisparitySparse<T>
regionSparseWta( int minDisparity , int maxDisparity,
int regionRadiusX, int regionRadiusY ,
double maxPerPixelError ,
double texture ,
boolean subpixelInterpolation ,
Class<T> imageType ) {
double maxError = (regionRadiusX*2+1)*(regionRadiusY*2+1)*maxPerPixelError;
if( imageType == GrayU8.class ) {
DisparitySparseSelect<int[]> select;
if( subpixelInterpolation)
select = selectDisparitySparseSubpixel_S32((int) maxError, texture);
else
select = selectDisparitySparse_S32((int) maxError, texture);
DisparitySparseScoreSadRect<int[],GrayU8>
score = scoreDisparitySparseSadRect_U8(minDisparity,maxDisparity, regionRadiusX, regionRadiusY);
return new WrapDisparitySparseSadRect(score,select);
} else if( imageType == GrayF32.class ) {
DisparitySparseSelect<float[]> select;
if( subpixelInterpolation )
select = selectDisparitySparseSubpixel_F32((int) maxError, texture);
else
select = selectDisparitySparse_F32((int) maxError, texture);
DisparitySparseScoreSadRect<float[],GrayF32>
score = scoreDisparitySparseSadRect_F32(minDisparity,maxDisparity, regionRadiusX, regionRadiusY);
return new WrapDisparitySparseSadRect(score,select);
} else
throw new RuntimeException("Image type not supported: "+imageType.getSimpleName() );
} | java | public static <T extends ImageGray<T>> StereoDisparitySparse<T>
regionSparseWta( int minDisparity , int maxDisparity,
int regionRadiusX, int regionRadiusY ,
double maxPerPixelError ,
double texture ,
boolean subpixelInterpolation ,
Class<T> imageType ) {
double maxError = (regionRadiusX*2+1)*(regionRadiusY*2+1)*maxPerPixelError;
if( imageType == GrayU8.class ) {
DisparitySparseSelect<int[]> select;
if( subpixelInterpolation)
select = selectDisparitySparseSubpixel_S32((int) maxError, texture);
else
select = selectDisparitySparse_S32((int) maxError, texture);
DisparitySparseScoreSadRect<int[],GrayU8>
score = scoreDisparitySparseSadRect_U8(minDisparity,maxDisparity, regionRadiusX, regionRadiusY);
return new WrapDisparitySparseSadRect(score,select);
} else if( imageType == GrayF32.class ) {
DisparitySparseSelect<float[]> select;
if( subpixelInterpolation )
select = selectDisparitySparseSubpixel_F32((int) maxError, texture);
else
select = selectDisparitySparse_F32((int) maxError, texture);
DisparitySparseScoreSadRect<float[],GrayF32>
score = scoreDisparitySparseSadRect_F32(minDisparity,maxDisparity, regionRadiusX, regionRadiusY);
return new WrapDisparitySparseSadRect(score,select);
} else
throw new RuntimeException("Image type not supported: "+imageType.getSimpleName() );
} | [
"public",
"static",
"<",
"T",
"extends",
"ImageGray",
"<",
"T",
">",
">",
"StereoDisparitySparse",
"<",
"T",
">",
"regionSparseWta",
"(",
"int",
"minDisparity",
",",
"int",
"maxDisparity",
",",
"int",
"regionRadiusX",
",",
"int",
"regionRadiusY",
",",
"double"... | WTA algorithms that computes disparity on a sparse per-pixel basis as requested..
@param minDisparity Minimum disparity that it will check. Must be ≥ 0 and < maxDisparity
@param maxDisparity Maximum disparity that it will calculate. Must be > 0
@param regionRadiusX Radius of the rectangular region along x-axis.
@param regionRadiusY Radius of the rectangular region along y-axis.
@param maxPerPixelError Maximum allowed error in a region per pixel. Set to < 0 to disable.
@param texture Tolerance for how similar optimal region is to other region. Closer to zero is more tolerant.
Try 0.1
@param subpixelInterpolation true to turn on sub-pixel interpolation
@param imageType Type of input image.
@param <T> Image type
@return Sparse disparity algorithm | [
"WTA",
"algorithms",
"that",
"computes",
"disparity",
"on",
"a",
"sparse",
"per",
"-",
"pixel",
"basis",
"as",
"requested",
".."
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/factory/feature/disparity/FactoryStereoDisparity.java#L241-L275 |
apache/flink | flink-core/src/main/java/org/apache/flink/types/StringValue.java | StringValue.setValue | public void setValue(StringValue value, int offset, int len) {
checkNotNull(value);
setValue(value.value, offset, len);
} | java | public void setValue(StringValue value, int offset, int len) {
checkNotNull(value);
setValue(value.value, offset, len);
} | [
"public",
"void",
"setValue",
"(",
"StringValue",
"value",
",",
"int",
"offset",
",",
"int",
"len",
")",
"{",
"checkNotNull",
"(",
"value",
")",
";",
"setValue",
"(",
"value",
".",
"value",
",",
"offset",
",",
"len",
")",
";",
"}"
] | Sets the value of the StringValue to a substring of the given string.
@param value The new string value.
@param offset The position to start the substring.
@param len The length of the substring. | [
"Sets",
"the",
"value",
"of",
"the",
"StringValue",
"to",
"a",
"substring",
"of",
"the",
"given",
"string",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/types/StringValue.java#L172-L175 |
Azure/azure-sdk-for-java | keyvault/resource-manager/v2016_10_01/src/main/java/com/microsoft/azure/management/keyvault/v2016_10_01/implementation/VaultsInner.java | VaultsInner.updateAccessPolicyAsync | public Observable<VaultAccessPolicyParametersInner> updateAccessPolicyAsync(String resourceGroupName, String vaultName, AccessPolicyUpdateKind operationKind, VaultAccessPolicyProperties properties) {
return updateAccessPolicyWithServiceResponseAsync(resourceGroupName, vaultName, operationKind, properties).map(new Func1<ServiceResponse<VaultAccessPolicyParametersInner>, VaultAccessPolicyParametersInner>() {
@Override
public VaultAccessPolicyParametersInner call(ServiceResponse<VaultAccessPolicyParametersInner> response) {
return response.body();
}
});
} | java | public Observable<VaultAccessPolicyParametersInner> updateAccessPolicyAsync(String resourceGroupName, String vaultName, AccessPolicyUpdateKind operationKind, VaultAccessPolicyProperties properties) {
return updateAccessPolicyWithServiceResponseAsync(resourceGroupName, vaultName, operationKind, properties).map(new Func1<ServiceResponse<VaultAccessPolicyParametersInner>, VaultAccessPolicyParametersInner>() {
@Override
public VaultAccessPolicyParametersInner call(ServiceResponse<VaultAccessPolicyParametersInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"VaultAccessPolicyParametersInner",
">",
"updateAccessPolicyAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"vaultName",
",",
"AccessPolicyUpdateKind",
"operationKind",
",",
"VaultAccessPolicyProperties",
"properties",
")",
"{",
"return... | Update access policies in a key vault in the specified subscription.
@param resourceGroupName The name of the Resource Group to which the vault belongs.
@param vaultName Name of the vault
@param operationKind Name of the operation. Possible values include: 'add', 'replace', 'remove'
@param properties Properties of the access policy
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the VaultAccessPolicyParametersInner object | [
"Update",
"access",
"policies",
"in",
"a",
"key",
"vault",
"in",
"the",
"specified",
"subscription",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/keyvault/resource-manager/v2016_10_01/src/main/java/com/microsoft/azure/management/keyvault/v2016_10_01/implementation/VaultsInner.java#L546-L553 |
Azure/azure-sdk-for-java | mediaservices/data-plane/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java | ODataAtomMarshaller.marshalEntry | public void marshalEntry(Object content, OutputStream stream)
throws JAXBException {
marshaller.marshal(createEntry(content), stream);
} | java | public void marshalEntry(Object content, OutputStream stream)
throws JAXBException {
marshaller.marshal(createEntry(content), stream);
} | [
"public",
"void",
"marshalEntry",
"(",
"Object",
"content",
",",
"OutputStream",
"stream",
")",
"throws",
"JAXBException",
"{",
"marshaller",
".",
"marshal",
"(",
"createEntry",
"(",
"content",
")",
",",
"stream",
")",
";",
"}"
] | Convert the given content into an ATOM entry and write it to the given
stream.
@param content
Content object to send
@param stream
Stream to write to
@throws JAXBException
if content is malformed/not marshallable | [
"Convert",
"the",
"given",
"content",
"into",
"an",
"ATOM",
"entry",
"and",
"write",
"it",
"to",
"the",
"given",
"stream",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/mediaservices/data-plane/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java#L109-L112 |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/nio/PathFileObject.java | PathFileObject.createDirectoryPathFileObject | static PathFileObject createDirectoryPathFileObject(JavacPathFileManager fileManager,
final Path path, final Path dir) {
return new PathFileObject(fileManager, path) {
@Override
String inferBinaryName(Iterable<? extends Path> paths) {
return toBinaryName(dir.relativize(path));
}
};
} | java | static PathFileObject createDirectoryPathFileObject(JavacPathFileManager fileManager,
final Path path, final Path dir) {
return new PathFileObject(fileManager, path) {
@Override
String inferBinaryName(Iterable<? extends Path> paths) {
return toBinaryName(dir.relativize(path));
}
};
} | [
"static",
"PathFileObject",
"createDirectoryPathFileObject",
"(",
"JavacPathFileManager",
"fileManager",
",",
"final",
"Path",
"path",
",",
"final",
"Path",
"dir",
")",
"{",
"return",
"new",
"PathFileObject",
"(",
"fileManager",
",",
"path",
")",
"{",
"@",
"Overri... | Create a PathFileObject within a directory, such that the binary name
can be inferred from the relationship to the parent directory. | [
"Create",
"a",
"PathFileObject",
"within",
"a",
"directory",
"such",
"that",
"the",
"binary",
"name",
"can",
"be",
"inferred",
"from",
"the",
"relationship",
"to",
"the",
"parent",
"directory",
"."
] | train | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/nio/PathFileObject.java#L71-L79 |
loldevs/riotapi | rest/src/main/java/net/boreeas/riotapi/rest/ThrottledApiHandler.java | ThrottledApiHandler.getLeagueEntries | public Future<Map<Long, List<LeagueItem>>> getLeagueEntries(long... summoners) {
return new ApiFuture<>(() -> handler.getLeagueEntries(summoners));
} | java | public Future<Map<Long, List<LeagueItem>>> getLeagueEntries(long... summoners) {
return new ApiFuture<>(() -> handler.getLeagueEntries(summoners));
} | [
"public",
"Future",
"<",
"Map",
"<",
"Long",
",",
"List",
"<",
"LeagueItem",
">",
">",
">",
"getLeagueEntries",
"(",
"long",
"...",
"summoners",
")",
"{",
"return",
"new",
"ApiFuture",
"<>",
"(",
"(",
")",
"->",
"handler",
".",
"getLeagueEntries",
"(",
... | Get a listing of all league entries in the summoners' leagues
@param summoners The ids of the summoners
@return A map, mapping summoner ids to lists of league entries for that summoner
@see <a href=https://developer.riotgames.com/api/methods#!/593/1863>Official API documentation</a> | [
"Get",
"a",
"listing",
"of",
"all",
"league",
"entries",
"in",
"the",
"summoners",
"leagues"
] | train | https://github.com/loldevs/riotapi/blob/0b8aac407aa5289845f249024f9732332855544f/rest/src/main/java/net/boreeas/riotapi/rest/ThrottledApiHandler.java#L255-L257 |
synchronoss/cpo-api | cpo-jdbc/src/main/java/org/synchronoss/cpo/transform/jdbc/TransformCharArray.java | TransformCharArray.transformOut | @Override
public String transformOut(JdbcPreparedStatementFactory jpsf, char[] attributeObject) throws CpoException {
String retStr = null;
if (attributeObject != null) {
retStr = new String(attributeObject);
}
return retStr;
} | java | @Override
public String transformOut(JdbcPreparedStatementFactory jpsf, char[] attributeObject) throws CpoException {
String retStr = null;
if (attributeObject != null) {
retStr = new String(attributeObject);
}
return retStr;
} | [
"@",
"Override",
"public",
"String",
"transformOut",
"(",
"JdbcPreparedStatementFactory",
"jpsf",
",",
"char",
"[",
"]",
"attributeObject",
")",
"throws",
"CpoException",
"{",
"String",
"retStr",
"=",
"null",
";",
"if",
"(",
"attributeObject",
"!=",
"null",
")",... | Transforms the data from the class attribute to the object required by the datasource
@param cpoAdapter The CpoAdapter for the datasource where the attribute is being persisted
@param parentObject The object that contains the attribute being persisted.
@param attributeObject The object that represents the attribute being persisted.
@return The object to be stored in the datasource
@throws CpoException | [
"Transforms",
"the",
"data",
"from",
"the",
"class",
"attribute",
"to",
"the",
"object",
"required",
"by",
"the",
"datasource"
] | train | https://github.com/synchronoss/cpo-api/blob/dc745aca3b3206abf80b85d9689b0132f5baa694/cpo-jdbc/src/main/java/org/synchronoss/cpo/transform/jdbc/TransformCharArray.java#L66-L75 |
fozziethebeat/S-Space | opt/src/main/java/edu/ucla/sspace/lra/LatentRelationalAnalysis.java | LatentRelationalAnalysis.printMatrix | public static void printMatrix(int rows, int cols, Matrix m) {
for(int col_num = 0; col_num < cols; col_num++) {
for (int row_num = 0; row_num < rows; row_num++) {
System.out.print(m.get(row_num,col_num) + " ");
}
System.out.print("\n");
}
System.out.print("\n");
} | java | public static void printMatrix(int rows, int cols, Matrix m) {
for(int col_num = 0; col_num < cols; col_num++) {
for (int row_num = 0; row_num < rows; row_num++) {
System.out.print(m.get(row_num,col_num) + " ");
}
System.out.print("\n");
}
System.out.print("\n");
} | [
"public",
"static",
"void",
"printMatrix",
"(",
"int",
"rows",
",",
"int",
"cols",
",",
"Matrix",
"m",
")",
"{",
"for",
"(",
"int",
"col_num",
"=",
"0",
";",
"col_num",
"<",
"cols",
";",
"col_num",
"++",
")",
"{",
"for",
"(",
"int",
"row_num",
"=",... | prints the {@code Matrix} to standard out.
@param rows an {@code int} containing the number of rows in m
@param cols an {@code int} containing the number of cols in m
@param m the {@code Matrix} to print
@return void | [
"prints",
"the",
"{",
"@code",
"Matrix",
"}",
"to",
"standard",
"out",
"."
] | train | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/opt/src/main/java/edu/ucla/sspace/lra/LatentRelationalAnalysis.java#L993-L1001 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/PatternsImpl.java | PatternsImpl.batchAddPatterns | public List<PatternRuleInfo> batchAddPatterns(UUID appId, String versionId, List<PatternRuleCreateObject> patterns) {
return batchAddPatternsWithServiceResponseAsync(appId, versionId, patterns).toBlocking().single().body();
} | java | public List<PatternRuleInfo> batchAddPatterns(UUID appId, String versionId, List<PatternRuleCreateObject> patterns) {
return batchAddPatternsWithServiceResponseAsync(appId, versionId, patterns).toBlocking().single().body();
} | [
"public",
"List",
"<",
"PatternRuleInfo",
">",
"batchAddPatterns",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"List",
"<",
"PatternRuleCreateObject",
">",
"patterns",
")",
"{",
"return",
"batchAddPatternsWithServiceResponseAsync",
"(",
"appId",
",",
"ver... | Adds a batch of patterns to the specified application.
@param appId The application ID.
@param versionId The version ID.
@param patterns A JSON array containing patterns.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the List<PatternRuleInfo> object if successful. | [
"Adds",
"a",
"batch",
"of",
"patterns",
"to",
"the",
"specified",
"application",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/PatternsImpl.java#L476-L478 |
google/error-prone-javac | src/java.compiler/share/classes/javax/lang/model/util/ElementFilter.java | ElementFilter.constructorsIn | public static Set<ExecutableElement>
constructorsIn(Set<? extends Element> elements) {
return setFilter(elements, CONSTRUCTOR_KIND, ExecutableElement.class);
} | java | public static Set<ExecutableElement>
constructorsIn(Set<? extends Element> elements) {
return setFilter(elements, CONSTRUCTOR_KIND, ExecutableElement.class);
} | [
"public",
"static",
"Set",
"<",
"ExecutableElement",
">",
"constructorsIn",
"(",
"Set",
"<",
"?",
"extends",
"Element",
">",
"elements",
")",
"{",
"return",
"setFilter",
"(",
"elements",
",",
"CONSTRUCTOR_KIND",
",",
"ExecutableElement",
".",
"class",
")",
";"... | Returns a set of constructors in {@code elements}.
@return a set of constructors in {@code elements}
@param elements the elements to filter | [
"Returns",
"a",
"set",
"of",
"constructors",
"in",
"{"
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/java.compiler/share/classes/javax/lang/model/util/ElementFilter.java#L122-L125 |
mikepenz/MaterialDrawer | library/src/main/java/com/mikepenz/materialdrawer/Drawer.java | Drawer.setToolbar | public void setToolbar(@NonNull Activity activity, @NonNull Toolbar toolbar, boolean recreateActionBarDrawerToggle) {
this.mDrawerBuilder.mToolbar = toolbar;
this.mDrawerBuilder.handleDrawerNavigation(activity, recreateActionBarDrawerToggle);
} | java | public void setToolbar(@NonNull Activity activity, @NonNull Toolbar toolbar, boolean recreateActionBarDrawerToggle) {
this.mDrawerBuilder.mToolbar = toolbar;
this.mDrawerBuilder.handleDrawerNavigation(activity, recreateActionBarDrawerToggle);
} | [
"public",
"void",
"setToolbar",
"(",
"@",
"NonNull",
"Activity",
"activity",
",",
"@",
"NonNull",
"Toolbar",
"toolbar",
",",
"boolean",
"recreateActionBarDrawerToggle",
")",
"{",
"this",
".",
"mDrawerBuilder",
".",
"mToolbar",
"=",
"toolbar",
";",
"this",
".",
... | Sets the toolbar which should be used in combination with the drawer
This will handle the ActionBarDrawerToggle for you.
Do not set this if you are in a sub activity and want to handle the back arrow on your own
@param activity
@param toolbar the toolbar which is used in combination with the drawer
@param recreateActionBarDrawerToggle defines if the ActionBarDrawerToggle needs to be recreated with the new set Toolbar | [
"Sets",
"the",
"toolbar",
"which",
"should",
"be",
"used",
"in",
"combination",
"with",
"the",
"drawer",
"This",
"will",
"handle",
"the",
"ActionBarDrawerToggle",
"for",
"you",
".",
"Do",
"not",
"set",
"this",
"if",
"you",
"are",
"in",
"a",
"sub",
"activit... | train | https://github.com/mikepenz/MaterialDrawer/blob/f4fb31635767edead0a01cee7b7588942b89d8d9/library/src/main/java/com/mikepenz/materialdrawer/Drawer.java#L113-L116 |
opencb/java-common-libs | commons-datastore/commons-datastore-solr/src/main/java/org/opencb/commons/datastore/solr/SolrManager.java | SolrManager.removeCore | public void removeCore(String coreName) throws SolrException {
try {
CoreAdminRequest.unloadCore(coreName, true, true, solrClient);
} catch (SolrServerException | IOException e) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e.getMessage(), e);
}
} | java | public void removeCore(String coreName) throws SolrException {
try {
CoreAdminRequest.unloadCore(coreName, true, true, solrClient);
} catch (SolrServerException | IOException e) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e.getMessage(), e);
}
} | [
"public",
"void",
"removeCore",
"(",
"String",
"coreName",
")",
"throws",
"SolrException",
"{",
"try",
"{",
"CoreAdminRequest",
".",
"unloadCore",
"(",
"coreName",
",",
"true",
",",
"true",
",",
"solrClient",
")",
";",
"}",
"catch",
"(",
"SolrServerException",... | Remove a core.
@param coreName Core name
@throws SolrException SolrException | [
"Remove",
"a",
"core",
"."
] | train | https://github.com/opencb/java-common-libs/blob/5c97682530d0be55828e1e4e374ff01fceb5f198/commons-datastore/commons-datastore-solr/src/main/java/org/opencb/commons/datastore/solr/SolrManager.java#L253-L259 |
btrplace/scheduler | json/src/main/java/org/btrplace/json/model/view/network/NetworkConverter.java | NetworkConverter.linksFromJSON | public void linksFromJSON(Model mo, Network net, JSONArray a) throws JSONConverterException {
for (Object o : a) {
linkFromJSON(mo, net, (JSONObject) o);
}
} | java | public void linksFromJSON(Model mo, Network net, JSONArray a) throws JSONConverterException {
for (Object o : a) {
linkFromJSON(mo, net, (JSONObject) o);
}
} | [
"public",
"void",
"linksFromJSON",
"(",
"Model",
"mo",
",",
"Network",
"net",
",",
"JSONArray",
"a",
")",
"throws",
"JSONConverterException",
"{",
"for",
"(",
"Object",
"o",
":",
"a",
")",
"{",
"linkFromJSON",
"(",
"mo",
",",
"net",
",",
"(",
"JSONObject... | Convert a JSON array of links to a Java List of links.
@param net the network to populate
@param a the json array | [
"Convert",
"a",
"JSON",
"array",
"of",
"links",
"to",
"a",
"Java",
"List",
"of",
"links",
"."
] | train | https://github.com/btrplace/scheduler/blob/611063aad0b47a016e57ebf36fa4dfdf24de09e8/json/src/main/java/org/btrplace/json/model/view/network/NetworkConverter.java#L302-L306 |
apereo/cas | support/cas-server-support-oauth-core-api/src/main/java/org/apereo/cas/support/oauth/util/OAuth20Utils.java | OAuth20Utils.getRegisteredOAuthServiceByRedirectUri | public static OAuthRegisteredService getRegisteredOAuthServiceByRedirectUri(final ServicesManager servicesManager, final String redirectUri) {
return getRegisteredOAuthServiceByPredicate(servicesManager, s -> s.matches(redirectUri));
} | java | public static OAuthRegisteredService getRegisteredOAuthServiceByRedirectUri(final ServicesManager servicesManager, final String redirectUri) {
return getRegisteredOAuthServiceByPredicate(servicesManager, s -> s.matches(redirectUri));
} | [
"public",
"static",
"OAuthRegisteredService",
"getRegisteredOAuthServiceByRedirectUri",
"(",
"final",
"ServicesManager",
"servicesManager",
",",
"final",
"String",
"redirectUri",
")",
"{",
"return",
"getRegisteredOAuthServiceByPredicate",
"(",
"servicesManager",
",",
"s",
"->... | Gets registered oauth service by redirect uri.
@param servicesManager the services manager
@param redirectUri the redirect uri
@return the registered OAuth service by redirect uri | [
"Gets",
"registered",
"oauth",
"service",
"by",
"redirect",
"uri",
"."
] | train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/support/cas-server-support-oauth-core-api/src/main/java/org/apereo/cas/support/oauth/util/OAuth20Utils.java#L87-L89 |
deeplearning4j/deeplearning4j | datavec/datavec-local/src/main/java/org/datavec/local/transforms/AnalyzeLocal.java | AnalyzeLocal.analyzeQualitySequence | public static DataQualityAnalysis analyzeQualitySequence(Schema schema, SequenceRecordReader data) {
int nColumns = schema.numColumns();
List<QualityAnalysisState> states = new ArrayList<>();
QualityAnalysisAddFunction addFn = new QualityAnalysisAddFunction(schema);
while(data.hasNext()){
List<List<Writable>> seq = data.sequenceRecord();
for(List<Writable> step : seq){
states = addFn.apply(states, step);
}
}
List<ColumnQuality> list = new ArrayList<>(nColumns);
for (QualityAnalysisState qualityState : states) {
list.add(qualityState.getColumnQuality());
}
return new DataQualityAnalysis(schema, list);
} | java | public static DataQualityAnalysis analyzeQualitySequence(Schema schema, SequenceRecordReader data) {
int nColumns = schema.numColumns();
List<QualityAnalysisState> states = new ArrayList<>();
QualityAnalysisAddFunction addFn = new QualityAnalysisAddFunction(schema);
while(data.hasNext()){
List<List<Writable>> seq = data.sequenceRecord();
for(List<Writable> step : seq){
states = addFn.apply(states, step);
}
}
List<ColumnQuality> list = new ArrayList<>(nColumns);
for (QualityAnalysisState qualityState : states) {
list.add(qualityState.getColumnQuality());
}
return new DataQualityAnalysis(schema, list);
} | [
"public",
"static",
"DataQualityAnalysis",
"analyzeQualitySequence",
"(",
"Schema",
"schema",
",",
"SequenceRecordReader",
"data",
")",
"{",
"int",
"nColumns",
"=",
"schema",
".",
"numColumns",
"(",
")",
";",
"List",
"<",
"QualityAnalysisState",
">",
"states",
"="... | Analyze the data quality of sequence data - provides a report on missing values, values that don't comply with schema, etc
@param schema Schema for data
@param data Data to analyze
@return DataQualityAnalysis object | [
"Analyze",
"the",
"data",
"quality",
"of",
"sequence",
"data",
"-",
"provides",
"a",
"report",
"on",
"missing",
"values",
"values",
"that",
"don",
"t",
"comply",
"with",
"schema",
"etc"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/datavec/datavec-local/src/main/java/org/datavec/local/transforms/AnalyzeLocal.java#L95-L112 |
rey5137/material | material/src/main/java/com/rey/material/widget/EditText.java | EditText.performFiltering | protected void performFiltering(CharSequence text, int start, int end, int keyCode) {
if(mAutoCompleteMode == AUTOCOMPLETE_MODE_MULTI)
((InternalMultiAutoCompleteTextView)mInputView).superPerformFiltering(text, start, end, keyCode);
} | java | protected void performFiltering(CharSequence text, int start, int end, int keyCode) {
if(mAutoCompleteMode == AUTOCOMPLETE_MODE_MULTI)
((InternalMultiAutoCompleteTextView)mInputView).superPerformFiltering(text, start, end, keyCode);
} | [
"protected",
"void",
"performFiltering",
"(",
"CharSequence",
"text",
",",
"int",
"start",
",",
"int",
"end",
",",
"int",
"keyCode",
")",
"{",
"if",
"(",
"mAutoCompleteMode",
"==",
"AUTOCOMPLETE_MODE_MULTI",
")",
"(",
"(",
"InternalMultiAutoCompleteTextView",
")",... | <p>Starts filtering the content of the drop down list. The filtering
pattern is the specified range of text from the edit box. Subclasses may
override this method to filter with a different pattern, for
instance a smaller substring of <code>text</code>.</p> | [
"<p",
">",
"Starts",
"filtering",
"the",
"content",
"of",
"the",
"drop",
"down",
"list",
".",
"The",
"filtering",
"pattern",
"is",
"the",
"specified",
"range",
"of",
"text",
"from",
"the",
"edit",
"box",
".",
"Subclasses",
"may",
"override",
"this",
"metho... | train | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/EditText.java#L790-L793 |
Impetus/Kundera | src/jpa-engine/core/src/main/java/com/impetus/kundera/persistence/EntityManagerSession.java | EntityManagerSession.lookup | @SuppressWarnings("unchecked")
protected <T> T lookup(Class<T> entityClass, Object id)
{
String key = cacheKey(entityClass, id);
LOG.debug("Reading from L1 >> " + key);
T o = (T) sessionCache.get(key);
// go to second-level cache
if (o == null)
{
LOG.debug("Reading from L2 >> " + key);
Cache c = (Cache) getL2Cache();
if (c != null)
{
o = (T) c.get(key);
if (o != null)
{
LOG.debug("Found item in second level cache!");
}
}
}
return o;
} | java | @SuppressWarnings("unchecked")
protected <T> T lookup(Class<T> entityClass, Object id)
{
String key = cacheKey(entityClass, id);
LOG.debug("Reading from L1 >> " + key);
T o = (T) sessionCache.get(key);
// go to second-level cache
if (o == null)
{
LOG.debug("Reading from L2 >> " + key);
Cache c = (Cache) getL2Cache();
if (c != null)
{
o = (T) c.get(key);
if (o != null)
{
LOG.debug("Found item in second level cache!");
}
}
}
return o;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"<",
"T",
">",
"T",
"lookup",
"(",
"Class",
"<",
"T",
">",
"entityClass",
",",
"Object",
"id",
")",
"{",
"String",
"key",
"=",
"cacheKey",
"(",
"entityClass",
",",
"id",
")",
";",
"LOG",
... | Find in cache.
@param <T>
the generic type
@param entityClass
the entity class
@param id
the id
@return the t | [
"Find",
"in",
"cache",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/jpa-engine/core/src/main/java/com/impetus/kundera/persistence/EntityManagerSession.java#L64-L86 |
alkacon/opencms-core | src/org/opencms/workplace/explorer/CmsExplorerTypeSettings.java | CmsExplorerTypeSettings.addIconRule | public void addIconRule(String extension, String icon, String bigIcon, String smallIconStyle, String bigIconStyle) {
CmsIconRule rule = new CmsIconRule(extension, icon, bigIcon, smallIconStyle, bigIconStyle);
m_iconRules.put(extension, rule);
} | java | public void addIconRule(String extension, String icon, String bigIcon, String smallIconStyle, String bigIconStyle) {
CmsIconRule rule = new CmsIconRule(extension, icon, bigIcon, smallIconStyle, bigIconStyle);
m_iconRules.put(extension, rule);
} | [
"public",
"void",
"addIconRule",
"(",
"String",
"extension",
",",
"String",
"icon",
",",
"String",
"bigIcon",
",",
"String",
"smallIconStyle",
",",
"String",
"bigIconStyle",
")",
"{",
"CmsIconRule",
"rule",
"=",
"new",
"CmsIconRule",
"(",
"extension",
",",
"ic... | Adds a new icon rule to this explorer type.<p>
@param extension the extension for the icon rule
@param icon the small icon
@param bigIcon the big icon
@param smallIconStyle the small icon CSS style class
@param bigIconStyle the big icon CSS style class | [
"Adds",
"a",
"new",
"icon",
"rule",
"to",
"this",
"explorer",
"type",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/workplace/explorer/CmsExplorerTypeSettings.java#L237-L241 |
lightblueseas/file-worker | src/main/java/de/alpharogroup/file/delete/DeleteFileExtensions.java | DeleteFileExtensions.deleteAllFilesWithSuffix | public static void deleteAllFilesWithSuffix(final File file, final String theSuffix)
throws IOException
{
final String filePath = file.getAbsolutePath();
final String suffix[] = { theSuffix };
final List<File> files = FileSearchExtensions.findFiles(filePath, suffix);
final int fileCount = files.size();
for (int i = 0; i < fileCount; i++)
{
DeleteFileExtensions.deleteFile(files.get(i));
}
} | java | public static void deleteAllFilesWithSuffix(final File file, final String theSuffix)
throws IOException
{
final String filePath = file.getAbsolutePath();
final String suffix[] = { theSuffix };
final List<File> files = FileSearchExtensions.findFiles(filePath, suffix);
final int fileCount = files.size();
for (int i = 0; i < fileCount; i++)
{
DeleteFileExtensions.deleteFile(files.get(i));
}
} | [
"public",
"static",
"void",
"deleteAllFilesWithSuffix",
"(",
"final",
"File",
"file",
",",
"final",
"String",
"theSuffix",
")",
"throws",
"IOException",
"{",
"final",
"String",
"filePath",
"=",
"file",
".",
"getAbsolutePath",
"(",
")",
";",
"final",
"String",
... | Deletes all files with the given suffix recursively.
@param file
The directory from where to delete the files wiht the given suffix.
@param theSuffix
The suffix from the files to delete.
@throws IOException
Signals that an I/O exception has occurred. | [
"Deletes",
"all",
"files",
"with",
"the",
"given",
"suffix",
"recursively",
"."
] | train | https://github.com/lightblueseas/file-worker/blob/2c81de10fb5d68de64c1abc3ed64ca681ce76da8/src/main/java/de/alpharogroup/file/delete/DeleteFileExtensions.java#L184-L195 |
ManfredTremmel/gwt-commons-lang3 | src/main/java/org/apache/commons/lang3/math/NumberUtils.java | NumberUtils.toInt | public static int toInt(final String str, final int defaultValue) {
if(str == null) {
return defaultValue;
}
try {
return Integer.parseInt(str);
} catch (final NumberFormatException nfe) {
return defaultValue;
}
} | java | public static int toInt(final String str, final int defaultValue) {
if(str == null) {
return defaultValue;
}
try {
return Integer.parseInt(str);
} catch (final NumberFormatException nfe) {
return defaultValue;
}
} | [
"public",
"static",
"int",
"toInt",
"(",
"final",
"String",
"str",
",",
"final",
"int",
"defaultValue",
")",
"{",
"if",
"(",
"str",
"==",
"null",
")",
"{",
"return",
"defaultValue",
";",
"}",
"try",
"{",
"return",
"Integer",
".",
"parseInt",
"(",
"str"... | <p>Convert a <code>String</code> to an <code>int</code>, returning a
default value if the conversion fails.</p>
<p>If the string is <code>null</code>, the default value is returned.</p>
<pre>
NumberUtils.toInt(null, 1) = 1
NumberUtils.toInt("", 1) = 1
NumberUtils.toInt("1", 0) = 1
</pre>
@param str the string to convert, may be null
@param defaultValue the default value
@return the int represented by the string, or the default if conversion fails
@since 2.1 | [
"<p",
">",
"Convert",
"a",
"<code",
">",
"String<",
"/",
"code",
">",
"to",
"an",
"<code",
">",
"int<",
"/",
"code",
">",
"returning",
"a",
"default",
"value",
"if",
"the",
"conversion",
"fails",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/math/NumberUtils.java#L120-L129 |
mgormley/optimize | src/main/java/edu/jhu/hlt/optimize/function/Bounds.java | Bounds.getSymmetricBounds | public static Bounds getSymmetricBounds(int dim, double l, double u) {
double [] L = new double[dim];
double [] U = new double[dim];
for(int i=0; i<dim; i++) {
L[i] = l;
U[i] = u;
}
return new Bounds(L, U);
} | java | public static Bounds getSymmetricBounds(int dim, double l, double u) {
double [] L = new double[dim];
double [] U = new double[dim];
for(int i=0; i<dim; i++) {
L[i] = l;
U[i] = u;
}
return new Bounds(L, U);
} | [
"public",
"static",
"Bounds",
"getSymmetricBounds",
"(",
"int",
"dim",
",",
"double",
"l",
",",
"double",
"u",
")",
"{",
"double",
"[",
"]",
"L",
"=",
"new",
"double",
"[",
"dim",
"]",
";",
"double",
"[",
"]",
"U",
"=",
"new",
"double",
"[",
"dim",... | Gets bounds which are identical for all dimensions.
@param dim The number of dimensions.
@param l The value of all lower bounds.
@param u The value of all upper bounds.
@return The new bounds. | [
"Gets",
"bounds",
"which",
"are",
"identical",
"for",
"all",
"dimensions",
"."
] | train | https://github.com/mgormley/optimize/blob/3d1b93260b99febb8a5ecd9e8543c223e151a8d3/src/main/java/edu/jhu/hlt/optimize/function/Bounds.java#L67-L75 |
xerial/larray | larray-buffer/src/main/java/xerial/larray/buffer/LBufferAPI.java | LBufferAPI.copyTo | public void copyTo(int srcOffset, byte[] destArray, int destOffset, int size) {
int cursor = destOffset;
for (ByteBuffer bb : toDirectByteBuffers(srcOffset, size)) {
int bbSize = bb.remaining();
if ((cursor + bbSize) > destArray.length)
throw new ArrayIndexOutOfBoundsException(String.format("cursor + bbSize = %,d", cursor + bbSize));
bb.get(destArray, cursor, bbSize);
cursor += bbSize;
}
} | java | public void copyTo(int srcOffset, byte[] destArray, int destOffset, int size) {
int cursor = destOffset;
for (ByteBuffer bb : toDirectByteBuffers(srcOffset, size)) {
int bbSize = bb.remaining();
if ((cursor + bbSize) > destArray.length)
throw new ArrayIndexOutOfBoundsException(String.format("cursor + bbSize = %,d", cursor + bbSize));
bb.get(destArray, cursor, bbSize);
cursor += bbSize;
}
} | [
"public",
"void",
"copyTo",
"(",
"int",
"srcOffset",
",",
"byte",
"[",
"]",
"destArray",
",",
"int",
"destOffset",
",",
"int",
"size",
")",
"{",
"int",
"cursor",
"=",
"destOffset",
";",
"for",
"(",
"ByteBuffer",
"bb",
":",
"toDirectByteBuffers",
"(",
"sr... | Copy the contents of this buffer begginning from the srcOffset to a destination byte array
@param srcOffset
@param destArray
@param destOffset
@param size | [
"Copy",
"the",
"contents",
"of",
"this",
"buffer",
"begginning",
"from",
"the",
"srcOffset",
"to",
"a",
"destination",
"byte",
"array"
] | train | https://github.com/xerial/larray/blob/9a1462623c0e56ca67c5341ea29832963c29479f/larray-buffer/src/main/java/xerial/larray/buffer/LBufferAPI.java#L237-L246 |
TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/hydrogeomorphology/lwrecruitment/NetIndexComparator.java | NetIndexComparator.compare | @Override
public int compare( SimpleFeature f1, SimpleFeature f2 ) {
int linkid1 = (Integer) f1.getAttribute(LINKID);
int linkid2 = (Integer) f2.getAttribute(LINKID);
if (linkid1 < linkid2) {
return -1;
} else if (linkid1 > linkid2) {
return 1;
} else {
return 0;
}
} | java | @Override
public int compare( SimpleFeature f1, SimpleFeature f2 ) {
int linkid1 = (Integer) f1.getAttribute(LINKID);
int linkid2 = (Integer) f2.getAttribute(LINKID);
if (linkid1 < linkid2) {
return -1;
} else if (linkid1 > linkid2) {
return 1;
} else {
return 0;
}
} | [
"@",
"Override",
"public",
"int",
"compare",
"(",
"SimpleFeature",
"f1",
",",
"SimpleFeature",
"f2",
")",
"{",
"int",
"linkid1",
"=",
"(",
"Integer",
")",
"f1",
".",
"getAttribute",
"(",
"LINKID",
")",
";",
"int",
"linkid2",
"=",
"(",
"Integer",
")",
"... | establish the position of each net point respect to the others | [
"establish",
"the",
"position",
"of",
"each",
"net",
"point",
"respect",
"to",
"the",
"others"
] | train | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/hydrogeomorphology/lwrecruitment/NetIndexComparator.java#L28-L40 |
apache/incubator-gobblin | gobblin-modules/gobblin-kafka-09/src/main/java/org/apache/gobblin/metrics/kafka/KafkaKeyValueProducerPusher.java | KafkaKeyValueProducerPusher.pushMessages | public void pushMessages(List<Pair<K, V>> messages) {
for (Pair<K, V> message: messages) {
this.producer.send(new ProducerRecord<>(topic, message.getKey(), message.getValue()), (recordMetadata, e) -> {
if (e != null) {
log.error("Failed to send message to topic {} due to exception: ", topic, e);
}
});
}
} | java | public void pushMessages(List<Pair<K, V>> messages) {
for (Pair<K, V> message: messages) {
this.producer.send(new ProducerRecord<>(topic, message.getKey(), message.getValue()), (recordMetadata, e) -> {
if (e != null) {
log.error("Failed to send message to topic {} due to exception: ", topic, e);
}
});
}
} | [
"public",
"void",
"pushMessages",
"(",
"List",
"<",
"Pair",
"<",
"K",
",",
"V",
">",
">",
"messages",
")",
"{",
"for",
"(",
"Pair",
"<",
"K",
",",
"V",
">",
"message",
":",
"messages",
")",
"{",
"this",
".",
"producer",
".",
"send",
"(",
"new",
... | Push all keyed messages to the Kafka topic.
@param messages List of keyed messages to push to Kakfa. | [
"Push",
"all",
"keyed",
"messages",
"to",
"the",
"Kafka",
"topic",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-kafka-09/src/main/java/org/apache/gobblin/metrics/kafka/KafkaKeyValueProducerPusher.java#L81-L89 |
CloudSlang/cs-actions | cs-ssh/src/main/java/io/cloudslang/content/ssh/utils/CacheUtils.java | CacheUtils.removeSshSession | public static void removeSshSession(GlobalSessionObject<Map<String, SSHConnection>> sessionParam, String sessionId) {
if (sessionParam != null) {
SessionResource<Map<String, SSHConnection>> resource = sessionParam.getResource();
if (resource != null) {
Map<String, SSHConnection> tempMap = resource.get();
if (tempMap != null) {
tempMap.remove(sessionId);
}
}
}
} | java | public static void removeSshSession(GlobalSessionObject<Map<String, SSHConnection>> sessionParam, String sessionId) {
if (sessionParam != null) {
SessionResource<Map<String, SSHConnection>> resource = sessionParam.getResource();
if (resource != null) {
Map<String, SSHConnection> tempMap = resource.get();
if (tempMap != null) {
tempMap.remove(sessionId);
}
}
}
} | [
"public",
"static",
"void",
"removeSshSession",
"(",
"GlobalSessionObject",
"<",
"Map",
"<",
"String",
",",
"SSHConnection",
">",
">",
"sessionParam",
",",
"String",
"sessionId",
")",
"{",
"if",
"(",
"sessionParam",
"!=",
"null",
")",
"{",
"SessionResource",
"... | Remove the SSH session (and associated channel if any) from the cache.
@param sessionParam The cache.
@param sessionId The key to the session in the cache map. | [
"Remove",
"the",
"SSH",
"session",
"(",
"and",
"associated",
"channel",
"if",
"any",
")",
"from",
"the",
"cache",
"."
] | train | https://github.com/CloudSlang/cs-actions/blob/9a1be1e99ad88286a6c153d5f2275df6ae1a57a1/cs-ssh/src/main/java/io/cloudslang/content/ssh/utils/CacheUtils.java#L105-L115 |
skyscreamer/JSONassert | src/main/java/org/skyscreamer/jsonassert/JSONAssert.java | JSONAssert.assertEquals | public static void assertEquals(String message, String expectedStr, String actualStr, boolean strict)
throws JSONException {
assertEquals(message, expectedStr, actualStr, strict ? JSONCompareMode.STRICT : JSONCompareMode.LENIENT);
} | java | public static void assertEquals(String message, String expectedStr, String actualStr, boolean strict)
throws JSONException {
assertEquals(message, expectedStr, actualStr, strict ? JSONCompareMode.STRICT : JSONCompareMode.LENIENT);
} | [
"public",
"static",
"void",
"assertEquals",
"(",
"String",
"message",
",",
"String",
"expectedStr",
",",
"String",
"actualStr",
",",
"boolean",
"strict",
")",
"throws",
"JSONException",
"{",
"assertEquals",
"(",
"message",
",",
"expectedStr",
",",
"actualStr",
"... | Asserts that the JSONArray provided matches the expected string. If it isn't it throws an
{@link AssertionError}.
@param message Error message to be displayed in case of assertion failure
@param expectedStr Expected JSON string
@param actualStr String to compare
@param strict Enables strict checking
@throws JSONException JSON parsing error | [
"Asserts",
"that",
"the",
"JSONArray",
"provided",
"matches",
"the",
"expected",
"string",
".",
"If",
"it",
"isn",
"t",
"it",
"throws",
"an",
"{",
"@link",
"AssertionError",
"}",
"."
] | train | https://github.com/skyscreamer/JSONassert/blob/830efcf546d07f955d8a213cc5c8a1db34d78f04/src/main/java/org/skyscreamer/jsonassert/JSONAssert.java#L349-L352 |
looly/hutool | hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelBase.java | ExcelBase.getCell | public Cell getCell(int x, int y, boolean isCreateIfNotExist) {
final Row row = isCreateIfNotExist ? RowUtil.getOrCreateRow(this.sheet, y) : this.sheet.getRow(y);
if (null != row) {
return isCreateIfNotExist ? CellUtil.getOrCreateCell(row, x) : row.getCell(x);
}
return null;
} | java | public Cell getCell(int x, int y, boolean isCreateIfNotExist) {
final Row row = isCreateIfNotExist ? RowUtil.getOrCreateRow(this.sheet, y) : this.sheet.getRow(y);
if (null != row) {
return isCreateIfNotExist ? CellUtil.getOrCreateCell(row, x) : row.getCell(x);
}
return null;
} | [
"public",
"Cell",
"getCell",
"(",
"int",
"x",
",",
"int",
"y",
",",
"boolean",
"isCreateIfNotExist",
")",
"{",
"final",
"Row",
"row",
"=",
"isCreateIfNotExist",
"?",
"RowUtil",
".",
"getOrCreateRow",
"(",
"this",
".",
"sheet",
",",
"y",
")",
":",
"this",... | 获取指定坐标单元格,如果isCreateIfNotExist为false,则在单元格不存在时返回<code>null</code>
@param x X坐标,从0计数,既列号
@param y Y坐标,从0计数,既行号
@param isCreateIfNotExist 单元格不存在时是否创建
@return {@link Cell}
@since 4.0.6 | [
"获取指定坐标单元格,如果isCreateIfNotExist为false,则在单元格不存在时返回<code",
">",
"null<",
"/",
"code",
">"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelBase.java#L172-L178 |
alkacon/opencms-core | src/org/opencms/ui/components/CmsResourceIcon.java | CmsResourceIcon.getIconHTML | public static String getIconHTML(CmsResourceUtil resUtil, CmsResourceState state, boolean showLocks) {
return "<span class=\""
+ OpenCmsTheme.RESOURCE_ICON
+ "\">"
+ getIconInnerHTML(resUtil, state, showLocks, true)
+ "</span>";
} | java | public static String getIconHTML(CmsResourceUtil resUtil, CmsResourceState state, boolean showLocks) {
return "<span class=\""
+ OpenCmsTheme.RESOURCE_ICON
+ "\">"
+ getIconInnerHTML(resUtil, state, showLocks, true)
+ "</span>";
} | [
"public",
"static",
"String",
"getIconHTML",
"(",
"CmsResourceUtil",
"resUtil",
",",
"CmsResourceState",
"state",
",",
"boolean",
"showLocks",
")",
"{",
"return",
"\"<span class=\\\"\"",
"+",
"OpenCmsTheme",
".",
"RESOURCE_ICON",
"+",
"\"\\\">\"",
"+",
"getIconInnerHT... | Returns the icon HTML.<p>
@param resUtil the resource util for the resource
@param state the resource state
@param showLocks <code>true</code> to show lock state overlay
@return the icon HTML | [
"Returns",
"the",
"icon",
"HTML",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/components/CmsResourceIcon.java#L203-L210 |
spring-projects/spring-plugin | core/src/main/java/org/springframework/plugin/core/OrderAwarePluginRegistry.java | OrderAwarePluginRegistry.createReverse | @Deprecated
public static <S, T extends Plugin<S>> OrderAwarePluginRegistry<T, S> createReverse(List<? extends T> plugins) {
return of(plugins, DEFAULT_REVERSE_COMPARATOR);
} | java | @Deprecated
public static <S, T extends Plugin<S>> OrderAwarePluginRegistry<T, S> createReverse(List<? extends T> plugins) {
return of(plugins, DEFAULT_REVERSE_COMPARATOR);
} | [
"@",
"Deprecated",
"public",
"static",
"<",
"S",
",",
"T",
"extends",
"Plugin",
"<",
"S",
">",
">",
"OrderAwarePluginRegistry",
"<",
"T",
",",
"S",
">",
"createReverse",
"(",
"List",
"<",
"?",
"extends",
"T",
">",
"plugins",
")",
"{",
"return",
"of",
... | Creates a new {@link OrderAwarePluginRegistry} with the given {@link Plugin}s and the order of the {@link Plugin}s
reverted.
@param plugins must not be {@literal null}.
@return
@deprecated since 2.0, for removal in 2.1. Prefer {@link OrderAwarePluginRegistry#ofReverse(List)} | [
"Creates",
"a",
"new",
"{",
"@link",
"OrderAwarePluginRegistry",
"}",
"with",
"the",
"given",
"{",
"@link",
"Plugin",
"}",
"s",
"and",
"the",
"order",
"of",
"the",
"{",
"@link",
"Plugin",
"}",
"s",
"reverted",
"."
] | train | https://github.com/spring-projects/spring-plugin/blob/953d2ce12f05f26444fbb3bf21011f538f729868/core/src/main/java/org/springframework/plugin/core/OrderAwarePluginRegistry.java#L190-L193 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/VpnSitesInner.java | VpnSitesInner.getByResourceGroup | public VpnSiteInner getByResourceGroup(String resourceGroupName, String vpnSiteName) {
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, vpnSiteName).toBlocking().single().body();
} | java | public VpnSiteInner getByResourceGroup(String resourceGroupName, String vpnSiteName) {
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, vpnSiteName).toBlocking().single().body();
} | [
"public",
"VpnSiteInner",
"getByResourceGroup",
"(",
"String",
"resourceGroupName",
",",
"String",
"vpnSiteName",
")",
"{",
"return",
"getByResourceGroupWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"vpnSiteName",
")",
".",
"toBlocking",
"(",
")",
".",
"sing... | Retrieves the details of a VPNsite.
@param resourceGroupName The resource group name of the VpnSite.
@param vpnSiteName The name of the VpnSite being retrieved.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the VpnSiteInner object if successful. | [
"Retrieves",
"the",
"details",
"of",
"a",
"VPNsite",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/VpnSitesInner.java#L126-L128 |
powermock/powermock | powermock-api/powermock-api-mockito2/src/main/java/org/powermock/api/mockito/PowerMockito.java | PowerMockito.doReturn | public static PowerMockitoStubber doReturn(Object toBeReturned, Object... othersToBeReturned) {
return POWERMOCKITO_CORE.doAnswer(toBeReturned, othersToBeReturned);
} | java | public static PowerMockitoStubber doReturn(Object toBeReturned, Object... othersToBeReturned) {
return POWERMOCKITO_CORE.doAnswer(toBeReturned, othersToBeReturned);
} | [
"public",
"static",
"PowerMockitoStubber",
"doReturn",
"(",
"Object",
"toBeReturned",
",",
"Object",
"...",
"othersToBeReturned",
")",
"{",
"return",
"POWERMOCKITO_CORE",
".",
"doAnswer",
"(",
"toBeReturned",
",",
"othersToBeReturned",
")",
";",
"}"
] | Same as {@link #doReturn(Object)} but sets consecutive values to be returned. Remember to use
<code>doReturn()</code> in those rare occasions when you cannot use {@link PowerMockito#when(Object)}.
<p>
<b>Beware that {@link PowerMockito#when(Object)} is always recommended for stubbing because it is argument type-safe
and more readable</b> (especially when stubbing consecutive calls).
<p>
Here are those rare occasions when doReturn() comes handy:
<p>
<p>
<ol>
<li>When spying real objects and calling real methods on a spy brings side effects
<p>
<pre class="code"><code class="java">
List list = new LinkedList();
List spy = spy(list);
<p>
//Impossible: real method is called so spy.get(0) throws IndexOutOfBoundsException (the list is yet empty)
when(spy.get(0)).thenReturn("foo", "bar", "qix");
<p>
//You have to use doReturn() for stubbing:
doReturn("foo", "bar", "qix").when(spy).get(0);
</code></pre>
</li>
<p>
<li>Overriding a previous exception-stubbing:
<pre class="code"><code class="java">
when(mock.foo()).thenThrow(new RuntimeException());
<p>
//Impossible: the exception-stubbed foo() method is called so RuntimeException is thrown.
when(mock.foo()).thenReturn("bar", "foo", "qix");
<p>
//You have to use doReturn() for stubbing:
doReturn("bar", "foo", "qix").when(mock).foo();
</code></pre>
</li>
</ol>
<p>
Above scenarios shows a trade-off of Mockito's elegant syntax. Note that the scenarios are very rare, though.
Spying should be sporadic and overriding exception-stubbing is very rare. Not to mention that in general
overriding stubbing is a potential code smell that points out too much stubbing.
<p>
See examples in javadoc for {@link PowerMockito} class
@param toBeReturned to be returned when the stubbed method is called
@param othersToBeReturned to be returned in consecutive calls when the stubbed method is called
@return stubber - to select a method for stubbing
@since 1.6.5 | [
"Same",
"as",
"{",
"@link",
"#doReturn",
"(",
"Object",
")",
"}",
"but",
"sets",
"consecutive",
"values",
"to",
"be",
"returned",
".",
"Remember",
"to",
"use",
"<code",
">",
"doReturn",
"()",
"<",
"/",
"code",
">",
"in",
"those",
"rare",
"occasions",
"... | train | https://github.com/powermock/powermock/blob/e8cd68026c284c6a7efe66959809eeebd8d1f9ad/powermock-api/powermock-api-mockito2/src/main/java/org/powermock/api/mockito/PowerMockito.java#L763-L765 |
TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/net/Pipe.java | Pipe.verifyEmptyDegree | public double verifyEmptyDegree( StringBuilder strWarnings, double q ) {
/* Pari a A * ( Rh ^1/6 ) */
double B;
/* Anglo formato dalla sezione bagnata */
double thta;
/* Costante */
double known;
/*
* [rad]Angolo formato dalla sezione bagnata, adottando un diametro
* commerciale
*/
double newtheta = 0;
B = (q * sqrt(WSPECIFICWEIGHT / 2.8)) / (CUBICMETER2LITER * getKs());
/* Angolo formato dalla sezione bagnata [rad] */
thta = 2 * acos(1 - 2 * 0.8);
known = (B * TWO_TENOVERTHREE) / pow(diameterToVerify / METER2CM, THIRTHEENOVERSIX);
/*
* Angolo formato dalla sezione bagnata considerando un diametro
* commerciale [rad]
*/
newtheta = Utility.thisBisection(thta, known, ONEOVERSIX, minG, accuracy, jMax, pm, strWarnings);
/* Grado di riempimento del tubo */
emptyDegree = 0.5 * (1 - cos(newtheta / 2));
return newtheta;
} | java | public double verifyEmptyDegree( StringBuilder strWarnings, double q ) {
/* Pari a A * ( Rh ^1/6 ) */
double B;
/* Anglo formato dalla sezione bagnata */
double thta;
/* Costante */
double known;
/*
* [rad]Angolo formato dalla sezione bagnata, adottando un diametro
* commerciale
*/
double newtheta = 0;
B = (q * sqrt(WSPECIFICWEIGHT / 2.8)) / (CUBICMETER2LITER * getKs());
/* Angolo formato dalla sezione bagnata [rad] */
thta = 2 * acos(1 - 2 * 0.8);
known = (B * TWO_TENOVERTHREE) / pow(diameterToVerify / METER2CM, THIRTHEENOVERSIX);
/*
* Angolo formato dalla sezione bagnata considerando un diametro
* commerciale [rad]
*/
newtheta = Utility.thisBisection(thta, known, ONEOVERSIX, minG, accuracy, jMax, pm, strWarnings);
/* Grado di riempimento del tubo */
emptyDegree = 0.5 * (1 - cos(newtheta / 2));
return newtheta;
} | [
"public",
"double",
"verifyEmptyDegree",
"(",
"StringBuilder",
"strWarnings",
",",
"double",
"q",
")",
"{",
"/* Pari a A * ( Rh ^1/6 ) */",
"double",
"B",
";",
"/* Anglo formato dalla sezione bagnata */",
"double",
"thta",
";",
"/* Costante */",
"double",
"known",
";",
... | Verify if the empty degree is greather than the 0.8.
@param strWarnings
a string which collect all the warning messages.
@param q discharge in this pipe. | [
"Verify",
"if",
"the",
"empty",
"degree",
"is",
"greather",
"than",
"the",
"0",
".",
"8",
"."
] | train | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/net/Pipe.java#L1445-L1473 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/lang/Integer.java | Integer.valueOf | public static Integer valueOf(String s, int radix) throws NumberFormatException {
return Integer.valueOf(parseInt(s,radix));
} | java | public static Integer valueOf(String s, int radix) throws NumberFormatException {
return Integer.valueOf(parseInt(s,radix));
} | [
"public",
"static",
"Integer",
"valueOf",
"(",
"String",
"s",
",",
"int",
"radix",
")",
"throws",
"NumberFormatException",
"{",
"return",
"Integer",
".",
"valueOf",
"(",
"parseInt",
"(",
"s",
",",
"radix",
")",
")",
";",
"}"
] | Returns an {@code Integer} object holding the value
extracted from the specified {@code String} when parsed
with the radix given by the second argument. The first argument
is interpreted as representing a signed integer in the radix
specified by the second argument, exactly as if the arguments
were given to the {@link #parseInt(java.lang.String, int)}
method. The result is an {@code Integer} object that
represents the integer value specified by the string.
<p>In other words, this method returns an {@code Integer}
object equal to the value of:
<blockquote>
{@code new Integer(Integer.parseInt(s, radix))}
</blockquote>
@param s the string to be parsed.
@param radix the radix to be used in interpreting {@code s}
@return an {@code Integer} object holding the value
represented by the string argument in the specified
radix.
@exception NumberFormatException if the {@code String}
does not contain a parsable {@code int}. | [
"Returns",
"an",
"{",
"@code",
"Integer",
"}",
"object",
"holding",
"the",
"value",
"extracted",
"from",
"the",
"specified",
"{",
"@code",
"String",
"}",
"when",
"parsed",
"with",
"the",
"radix",
"given",
"by",
"the",
"second",
"argument",
".",
"The",
"fir... | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/lang/Integer.java#L556-L558 |
gallandarakhneorg/afc | core/util/src/main/java/org/arakhne/afc/util/IntegerList.java | IntegerList.removeElementInSegment | protected boolean removeElementInSegment(int segmentIndex, int element) {
if ((element == this.values[segmentIndex]) && (element == this.values[segmentIndex + 1])) {
// Remove the segment
if (this.values.length == 2) {
this.values = null;
this.size = 0;
} else {
final int[] newTab = new int[this.values.length - 2];
System.arraycopy(this.values, 0, newTab, 0, segmentIndex);
System.arraycopy(this.values, segmentIndex + 2, newTab, segmentIndex, newTab.length - segmentIndex);
this.values = newTab;
--this.size;
}
return true;
}
if ((element >= this.values[segmentIndex]) && (element <= this.values[segmentIndex + 1])) {
if (element == this.values[segmentIndex]) {
// Move the lower bound
++this.values[segmentIndex];
--this.size;
} else if (element == this.values[segmentIndex + 1]) {
// Move the upper bound
--this.values[segmentIndex + 1];
--this.size;
} else {
// Split the segment
final int[] newTab = new int[this.values.length + 2];
System.arraycopy(this.values, 0, newTab, 0, segmentIndex + 1);
System.arraycopy(this.values, segmentIndex + 1, newTab, segmentIndex + 3, newTab.length - segmentIndex - 3);
newTab[segmentIndex + 1] = element - 1;
newTab[segmentIndex + 2] = element + 1;
this.values = newTab;
--this.size;
}
return true;
}
return false;
} | java | protected boolean removeElementInSegment(int segmentIndex, int element) {
if ((element == this.values[segmentIndex]) && (element == this.values[segmentIndex + 1])) {
// Remove the segment
if (this.values.length == 2) {
this.values = null;
this.size = 0;
} else {
final int[] newTab = new int[this.values.length - 2];
System.arraycopy(this.values, 0, newTab, 0, segmentIndex);
System.arraycopy(this.values, segmentIndex + 2, newTab, segmentIndex, newTab.length - segmentIndex);
this.values = newTab;
--this.size;
}
return true;
}
if ((element >= this.values[segmentIndex]) && (element <= this.values[segmentIndex + 1])) {
if (element == this.values[segmentIndex]) {
// Move the lower bound
++this.values[segmentIndex];
--this.size;
} else if (element == this.values[segmentIndex + 1]) {
// Move the upper bound
--this.values[segmentIndex + 1];
--this.size;
} else {
// Split the segment
final int[] newTab = new int[this.values.length + 2];
System.arraycopy(this.values, 0, newTab, 0, segmentIndex + 1);
System.arraycopy(this.values, segmentIndex + 1, newTab, segmentIndex + 3, newTab.length - segmentIndex - 3);
newTab[segmentIndex + 1] = element - 1;
newTab[segmentIndex + 2] = element + 1;
this.values = newTab;
--this.size;
}
return true;
}
return false;
} | [
"protected",
"boolean",
"removeElementInSegment",
"(",
"int",
"segmentIndex",
",",
"int",
"element",
")",
"{",
"if",
"(",
"(",
"element",
"==",
"this",
".",
"values",
"[",
"segmentIndex",
"]",
")",
"&&",
"(",
"element",
"==",
"this",
".",
"values",
"[",
... | Remove the {@code element} in the segment starting at index
{@code segmentIndex}.
@param segmentIndex is the index of the segment from which the
element must be removed.
@param element is the element to remove.
@return <code>true</code> if the element was removed, otherwhise <code>false</code> | [
"Remove",
"the",
"{",
"@code",
"element",
"}",
"in",
"the",
"segment",
"starting",
"at",
"index",
"{",
"@code",
"segmentIndex",
"}",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/util/src/main/java/org/arakhne/afc/util/IntegerList.java#L453-L493 |
pravega/pravega | client/src/main/java/io/pravega/client/stream/ScalingPolicy.java | ScalingPolicy.byEventRate | public static ScalingPolicy byEventRate(int targetRate, int scaleFactor, int minNumSegments) {
Preconditions.checkArgument(targetRate > 0, "Target rate should be > 0.");
Preconditions.checkArgument(scaleFactor > 0, "Scale factor should be > 0. Otherwise use fixed scaling policy.");
Preconditions.checkArgument(minNumSegments > 0, "Minimum number of segments should be > 0.");
return new ScalingPolicy(ScaleType.BY_RATE_IN_EVENTS_PER_SEC, targetRate, scaleFactor, minNumSegments);
} | java | public static ScalingPolicy byEventRate(int targetRate, int scaleFactor, int minNumSegments) {
Preconditions.checkArgument(targetRate > 0, "Target rate should be > 0.");
Preconditions.checkArgument(scaleFactor > 0, "Scale factor should be > 0. Otherwise use fixed scaling policy.");
Preconditions.checkArgument(minNumSegments > 0, "Minimum number of segments should be > 0.");
return new ScalingPolicy(ScaleType.BY_RATE_IN_EVENTS_PER_SEC, targetRate, scaleFactor, minNumSegments);
} | [
"public",
"static",
"ScalingPolicy",
"byEventRate",
"(",
"int",
"targetRate",
",",
"int",
"scaleFactor",
",",
"int",
"minNumSegments",
")",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"targetRate",
">",
"0",
",",
"\"Target rate should be > 0.\"",
")",
";",
"P... | Create a scaling policy to configure a stream to scale up and down according
to event rate. Pravega scales a stream segment up in the case that one of these
conditions holds:
- The two-minute rate is greater than 5x the target rate
- The five-minute rate is greater than 2x the target rate
- The ten-minute rate is greater than the target rate
It scales a segment down (merges with a neighbor segment) in the case that both
these conditions hold:
- The two-, five-, ten-minute rate is smaller than the target rate
- The twenty-minute rate is smaller than half of the target rate
We additionally consider a cool-down period during which the segment is not
considered for scaling. This period is determined by the configuration
parameter autoScale.cooldownInSeconds; the default value is 10 minutes.
The scale factor bounds the number of new segments that can be created upon
a scaling event. In the case the controller computes the number of splits
to be greater than the scale factor for a given scale-up event, the number
of splits for the event is going to be equal to the scale factor.
The policy is configured with a minimum number of segments for the stream,
independent of the number of scale down events.
@param targetRate Target rate in events per second to enable scaling events
per segment.
@param scaleFactor Maximum number of splits of a segment for a scale-up event.
@param minNumSegments Minimum number of segments that a stream can have
independent of the number of scale down events.
@return Scaling policy object. | [
"Create",
"a",
"scaling",
"policy",
"to",
"configure",
"a",
"stream",
"to",
"scale",
"up",
"and",
"down",
"according",
"to",
"event",
"rate",
".",
"Pravega",
"scales",
"a",
"stream",
"segment",
"up",
"in",
"the",
"case",
"that",
"one",
"of",
"these",
"co... | train | https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/client/src/main/java/io/pravega/client/stream/ScalingPolicy.java#L100-L105 |
synchronoss/cpo-api | cpo-cassandra/src/main/java/org/synchronoss/cpo/cassandra/CassandraCpoAdapter.java | CassandraCpoAdapter.processUpdateGroup | protected <T> long processUpdateGroup(Collection<T> coll, String groupType, String groupName, Collection<CpoWhere> wheres, Collection<CpoOrderBy> orderBy, Collection<CpoNativeFunction> nativeExpressions) throws CpoException {
Session sess;
long updateCount = 0;
try {
sess = getWriteSession();
updateCount = processUpdateGroup(coll.toArray(), groupType, groupName, wheres, orderBy, nativeExpressions, sess);
} catch (Exception e) {
// Any exception has to try to rollback the work;
ExceptionHelper.reThrowCpoException(e, "processUpdateGroup(Collection coll, String groupType, String groupName) failed");
}
return updateCount;
} | java | protected <T> long processUpdateGroup(Collection<T> coll, String groupType, String groupName, Collection<CpoWhere> wheres, Collection<CpoOrderBy> orderBy, Collection<CpoNativeFunction> nativeExpressions) throws CpoException {
Session sess;
long updateCount = 0;
try {
sess = getWriteSession();
updateCount = processUpdateGroup(coll.toArray(), groupType, groupName, wheres, orderBy, nativeExpressions, sess);
} catch (Exception e) {
// Any exception has to try to rollback the work;
ExceptionHelper.reThrowCpoException(e, "processUpdateGroup(Collection coll, String groupType, String groupName) failed");
}
return updateCount;
} | [
"protected",
"<",
"T",
">",
"long",
"processUpdateGroup",
"(",
"Collection",
"<",
"T",
">",
"coll",
",",
"String",
"groupType",
",",
"String",
"groupName",
",",
"Collection",
"<",
"CpoWhere",
">",
"wheres",
",",
"Collection",
"<",
"CpoOrderBy",
">",
"orderBy... | DOCUMENT ME!
@param coll DOCUMENT ME!
@param groupType DOCUMENT ME!
@param groupName DOCUMENT ME!
@return DOCUMENT ME!
@throws CpoException DOCUMENT ME! | [
"DOCUMENT",
"ME!"
] | train | https://github.com/synchronoss/cpo-api/blob/dc745aca3b3206abf80b85d9689b0132f5baa694/cpo-cassandra/src/main/java/org/synchronoss/cpo/cassandra/CassandraCpoAdapter.java#L2108-L2121 |
ACRA/acra | acra-core/src/main/java/org/acra/collector/ConfigurationCollector.java | ConfigurationCollector.activeFlags | @NonNull
private String activeFlags(@NonNull SparseArray<String> valueNames, int bitfield) {
final StringBuilder result = new StringBuilder();
// Look for masks, apply it an retrieve the masked value
for (int i = 0; i < valueNames.size(); i++) {
final int maskValue = valueNames.keyAt(i);
if (valueNames.get(maskValue).endsWith(SUFFIX_MASK)) {
final int value = bitfield & maskValue;
if (value > 0) {
if (result.length() > 0) {
result.append('+');
}
result.append(valueNames.get(value));
}
}
}
return result.toString();
} | java | @NonNull
private String activeFlags(@NonNull SparseArray<String> valueNames, int bitfield) {
final StringBuilder result = new StringBuilder();
// Look for masks, apply it an retrieve the masked value
for (int i = 0; i < valueNames.size(); i++) {
final int maskValue = valueNames.keyAt(i);
if (valueNames.get(maskValue).endsWith(SUFFIX_MASK)) {
final int value = bitfield & maskValue;
if (value > 0) {
if (result.length() > 0) {
result.append('+');
}
result.append(valueNames.get(value));
}
}
}
return result.toString();
} | [
"@",
"NonNull",
"private",
"String",
"activeFlags",
"(",
"@",
"NonNull",
"SparseArray",
"<",
"String",
">",
"valueNames",
",",
"int",
"bitfield",
")",
"{",
"final",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"// Look for masks, apply ... | Some fields contain multiple value types which can be isolated by
applying a bitmask. That method returns the concatenation of active
values.
@param valueNames The array containing the different values and names for this
field. Must contain mask values too.
@param bitfield The bitfield to inspect.
@return The names of the different values contained in the bitfield,
separated by '+'. | [
"Some",
"fields",
"contain",
"multiple",
"value",
"types",
"which",
"can",
"be",
"isolated",
"by",
"applying",
"a",
"bitmask",
".",
"That",
"method",
"returns",
"the",
"concatenation",
"of",
"active",
"values",
"."
] | train | https://github.com/ACRA/acra/blob/bfa3235ab110328c5ab2f792ddf8ee87be4a32d1/acra-core/src/main/java/org/acra/collector/ConfigurationCollector.java#L238-L256 |
jbundle/jbundle | base/remote/src/main/java/org/jbundle/base/remote/db/TableSession.java | TableSession.doSetHandle | public Object doSetHandle(Object bookmark, int iOpenMode, String strFields, int iHandleType) throws DBException, RemoteException
{
int iOldOpenMode = this.getMainRecord().getOpenMode();
try {
Utility.getLogger().info("EJB doSetHandle, key= " + bookmark);
Record record = this.getMainRecord();
// SELECT (fields to select)
synchronized (this.getTask())
{
Record recordBase = this.getMainRecord().getTable().getCurrentTable().getRecord();
this.getMainRecord().setOpenMode(iOpenMode);
int iFieldTypes = this.getFieldTypes(recordBase);
if (strFields != null)
this.getMainRecord().setSelected(strFields); // Select these fields
else
{
if (iFieldTypes == BaseBuffer.PHYSICAL_FIELDS)
this.getMainRecord().setSelected(true); // Select these fields (otherwise leave the selection alone)
}
iFieldTypes = this.getFieldTypes(recordBase);
// pend(don) Make sure the table does not serve up the current record (temporary fix until messaging is okay).
record.setEditMode(Constants.EDIT_NONE);
// Obviously, the previous code needs to be in a record messageListener method.
record = record.setHandle(bookmark, iHandleType);
if (record != null)
{
recordBase = this.getMainRecord().getTable().getCurrentTable().getRecord();
BaseBuffer buffer = new VectorBuffer(null, iFieldTypes);
buffer.fieldsToBuffer(recordBase, iFieldTypes);
return buffer.getPhysicalData();
}
else
return new Boolean(false);
}
} catch (DBException ex) {
throw ex;
} catch (Exception ex) {
ex.printStackTrace();
throw new DBException(ex.getMessage());
} finally {
this.getMainRecord().setOpenMode((iOldOpenMode & ~DBConstants.LOCK_TYPE_MASK) | (iOpenMode & DBConstants.LOCK_TYPE_MASK)); // Keep the client lock settings
}
} | java | public Object doSetHandle(Object bookmark, int iOpenMode, String strFields, int iHandleType) throws DBException, RemoteException
{
int iOldOpenMode = this.getMainRecord().getOpenMode();
try {
Utility.getLogger().info("EJB doSetHandle, key= " + bookmark);
Record record = this.getMainRecord();
// SELECT (fields to select)
synchronized (this.getTask())
{
Record recordBase = this.getMainRecord().getTable().getCurrentTable().getRecord();
this.getMainRecord().setOpenMode(iOpenMode);
int iFieldTypes = this.getFieldTypes(recordBase);
if (strFields != null)
this.getMainRecord().setSelected(strFields); // Select these fields
else
{
if (iFieldTypes == BaseBuffer.PHYSICAL_FIELDS)
this.getMainRecord().setSelected(true); // Select these fields (otherwise leave the selection alone)
}
iFieldTypes = this.getFieldTypes(recordBase);
// pend(don) Make sure the table does not serve up the current record (temporary fix until messaging is okay).
record.setEditMode(Constants.EDIT_NONE);
// Obviously, the previous code needs to be in a record messageListener method.
record = record.setHandle(bookmark, iHandleType);
if (record != null)
{
recordBase = this.getMainRecord().getTable().getCurrentTable().getRecord();
BaseBuffer buffer = new VectorBuffer(null, iFieldTypes);
buffer.fieldsToBuffer(recordBase, iFieldTypes);
return buffer.getPhysicalData();
}
else
return new Boolean(false);
}
} catch (DBException ex) {
throw ex;
} catch (Exception ex) {
ex.printStackTrace();
throw new DBException(ex.getMessage());
} finally {
this.getMainRecord().setOpenMode((iOldOpenMode & ~DBConstants.LOCK_TYPE_MASK) | (iOpenMode & DBConstants.LOCK_TYPE_MASK)); // Keep the client lock settings
}
} | [
"public",
"Object",
"doSetHandle",
"(",
"Object",
"bookmark",
",",
"int",
"iOpenMode",
",",
"String",
"strFields",
",",
"int",
"iHandleType",
")",
"throws",
"DBException",
",",
"RemoteException",
"{",
"int",
"iOldOpenMode",
"=",
"this",
".",
"getMainRecord",
"("... | Reposition to this record using this bookmark.
<p />JiniTables can't access the datasource on the server, so they must use the bookmark.
@param bookmark The handle of the record to retrieve.
@param iHandleType The type of handle to use.
@return The record or the return code as an Boolean. | [
"Reposition",
"to",
"this",
"record",
"using",
"this",
"bookmark",
".",
"<p",
"/",
">",
"JiniTables",
"can",
"t",
"access",
"the",
"datasource",
"on",
"the",
"server",
"so",
"they",
"must",
"use",
"the",
"bookmark",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/remote/src/main/java/org/jbundle/base/remote/db/TableSession.java#L587-L632 |
OpenLiberty/open-liberty | dev/com.ibm.ws.security.fat.common/src/com/ibm/ws/security/fat/common/utils/CommonIOUtils.java | CommonIOUtils.replaceStringsInFile | public boolean replaceStringsInFile(String filePath, Map<String, String> replaceValues) {
return replaceStringsInFile(filePath, replaceValues, null);
} | java | public boolean replaceStringsInFile(String filePath, Map<String, String> replaceValues) {
return replaceStringsInFile(filePath, replaceValues, null);
} | [
"public",
"boolean",
"replaceStringsInFile",
"(",
"String",
"filePath",
",",
"Map",
"<",
"String",
",",
"String",
">",
"replaceValues",
")",
"{",
"return",
"replaceStringsInFile",
"(",
"filePath",
",",
"replaceValues",
",",
"null",
")",
";",
"}"
] | Replaces all occurrences of the strings included in {@code replaceValues} within the file specified by {@code filePath}.
If {@code outputFilePath} is null or empty, the resulting text will be output to the same path as {@code filePath}.
@param filePath
File in which the string will be replaced.
@param replaceValues
Map of strings to be replaced.
@param outputFilePath
File to which results will be written if a change was made. If null or empty, this is set to the
value of {@code filePath}.
@return | [
"Replaces",
"all",
"occurrences",
"of",
"the",
"strings",
"included",
"in",
"{",
"@code",
"replaceValues",
"}",
"within",
"the",
"file",
"specified",
"by",
"{",
"@code",
"filePath",
"}",
".",
"If",
"{",
"@code",
"outputFilePath",
"}",
"is",
"null",
"or",
"... | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.fat.common/src/com/ibm/ws/security/fat/common/utils/CommonIOUtils.java#L42-L44 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java | ModelsImpl.deleteHierarchicalEntityChildAsync | public Observable<OperationStatus> deleteHierarchicalEntityChildAsync(UUID appId, String versionId, UUID hEntityId, UUID hChildId) {
return deleteHierarchicalEntityChildWithServiceResponseAsync(appId, versionId, hEntityId, hChildId).map(new Func1<ServiceResponse<OperationStatus>, OperationStatus>() {
@Override
public OperationStatus call(ServiceResponse<OperationStatus> response) {
return response.body();
}
});
} | java | public Observable<OperationStatus> deleteHierarchicalEntityChildAsync(UUID appId, String versionId, UUID hEntityId, UUID hChildId) {
return deleteHierarchicalEntityChildWithServiceResponseAsync(appId, versionId, hEntityId, hChildId).map(new Func1<ServiceResponse<OperationStatus>, OperationStatus>() {
@Override
public OperationStatus call(ServiceResponse<OperationStatus> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"OperationStatus",
">",
"deleteHierarchicalEntityChildAsync",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"UUID",
"hEntityId",
",",
"UUID",
"hChildId",
")",
"{",
"return",
"deleteHierarchicalEntityChildWithServiceResponseAsync",
"("... | Deletes a hierarchical entity extractor child from the application.
@param appId The application ID.
@param versionId The version ID.
@param hEntityId The hierarchical entity extractor ID.
@param hChildId The hierarchical entity extractor child ID.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the OperationStatus object | [
"Deletes",
"a",
"hierarchical",
"entity",
"extractor",
"child",
"from",
"the",
"application",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java#L6575-L6582 |
web3j/web3j | core/src/main/java/org/web3j/crypto/Bip44WalletUtils.java | Bip44WalletUtils.generateBip44Wallet | public static Bip39Wallet generateBip44Wallet(String password, File destinationDirectory,
boolean testNet)
throws CipherException, IOException {
byte[] initialEntropy = new byte[16];
SecureRandomUtils.secureRandom().nextBytes(initialEntropy);
String mnemonic = MnemonicUtils.generateMnemonic(initialEntropy);
byte[] seed = MnemonicUtils.generateSeed(mnemonic, null);
Bip32ECKeyPair masterKeypair = Bip32ECKeyPair.generateKeyPair(seed);
Bip32ECKeyPair bip44Keypair = generateBip44KeyPair(masterKeypair, testNet);
String walletFile = generateWalletFile(password, bip44Keypair, destinationDirectory, false);
return new Bip39Wallet(walletFile, mnemonic);
} | java | public static Bip39Wallet generateBip44Wallet(String password, File destinationDirectory,
boolean testNet)
throws CipherException, IOException {
byte[] initialEntropy = new byte[16];
SecureRandomUtils.secureRandom().nextBytes(initialEntropy);
String mnemonic = MnemonicUtils.generateMnemonic(initialEntropy);
byte[] seed = MnemonicUtils.generateSeed(mnemonic, null);
Bip32ECKeyPair masterKeypair = Bip32ECKeyPair.generateKeyPair(seed);
Bip32ECKeyPair bip44Keypair = generateBip44KeyPair(masterKeypair, testNet);
String walletFile = generateWalletFile(password, bip44Keypair, destinationDirectory, false);
return new Bip39Wallet(walletFile, mnemonic);
} | [
"public",
"static",
"Bip39Wallet",
"generateBip44Wallet",
"(",
"String",
"password",
",",
"File",
"destinationDirectory",
",",
"boolean",
"testNet",
")",
"throws",
"CipherException",
",",
"IOException",
"{",
"byte",
"[",
"]",
"initialEntropy",
"=",
"new",
"byte",
... | Generates a BIP-44 compatible Ethereum wallet on top of BIP-39 generated seed.
@param password Will be used for both wallet encryption and passphrase for BIP-39 seed
@param destinationDirectory The directory containing the wallet
@param testNet should use the testNet derive path
@return A BIP-39 compatible Ethereum wallet
@throws CipherException if the underlying cipher is not available
@throws IOException if the destination cannot be written to | [
"Generates",
"a",
"BIP",
"-",
"44",
"compatible",
"Ethereum",
"wallet",
"on",
"top",
"of",
"BIP",
"-",
"39",
"generated",
"seed",
"."
] | train | https://github.com/web3j/web3j/blob/f99ceb19cdd65895c18e0a565034767ca18ea9fc/core/src/main/java/org/web3j/crypto/Bip44WalletUtils.java#L34-L49 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/Normalizer2.java | Normalizer2.getInstance | public static Normalizer2 getInstance(InputStream data, String name, Mode mode) {
// TODO: If callers really use this API, then we should add an overload that takes a ByteBuffer.
ByteBuffer bytes = null;
if (data != null) {
try {
bytes = ICUBinary.getByteBufferFromInputStreamAndCloseStream(data);
} catch (IOException e) {
throw new ICUUncheckedIOException(e);
}
}
Norm2AllModes all2Modes=Norm2AllModes.getInstance(bytes, name);
switch(mode) {
case COMPOSE: return all2Modes.comp;
case DECOMPOSE: return all2Modes.decomp;
case FCD: return all2Modes.fcd;
case COMPOSE_CONTIGUOUS: return all2Modes.fcc;
default: return null; // will not occur
}
} | java | public static Normalizer2 getInstance(InputStream data, String name, Mode mode) {
// TODO: If callers really use this API, then we should add an overload that takes a ByteBuffer.
ByteBuffer bytes = null;
if (data != null) {
try {
bytes = ICUBinary.getByteBufferFromInputStreamAndCloseStream(data);
} catch (IOException e) {
throw new ICUUncheckedIOException(e);
}
}
Norm2AllModes all2Modes=Norm2AllModes.getInstance(bytes, name);
switch(mode) {
case COMPOSE: return all2Modes.comp;
case DECOMPOSE: return all2Modes.decomp;
case FCD: return all2Modes.fcd;
case COMPOSE_CONTIGUOUS: return all2Modes.fcc;
default: return null; // will not occur
}
} | [
"public",
"static",
"Normalizer2",
"getInstance",
"(",
"InputStream",
"data",
",",
"String",
"name",
",",
"Mode",
"mode",
")",
"{",
"// TODO: If callers really use this API, then we should add an overload that takes a ByteBuffer.",
"ByteBuffer",
"bytes",
"=",
"null",
";",
"... | Returns a Normalizer2 instance which uses the specified data file
(an ICU data file if data=null, or else custom binary data)
and which composes or decomposes text according to the specified mode.
Returns an unmodifiable singleton instance.
<ul>
<li>Use data=null for data files that are part of ICU's own data.
<li>Use name="nfc" and COMPOSE/DECOMPOSE for Unicode standard NFC/NFD.
<li>Use name="nfkc" and COMPOSE/DECOMPOSE for Unicode standard NFKC/NFKD.
<li>Use name="nfkc_cf" and COMPOSE for Unicode standard NFKC_CF=NFKC_Casefold.
</ul>
If data!=null, then the binary data is read once and cached using the provided
name as the key.
If you know or expect the data to be cached already, you can use data!=null
for non-ICU data as well.
<p>Any {@link java.io.IOException} is wrapped into a {@link android.icu.util.ICUUncheckedIOException}.
@param data the binary, big-endian normalization (.nrm file) data, or null for ICU data
@param name "nfc" or "nfkc" or "nfkc_cf" or name of custom data file
@param mode normalization mode (compose or decompose etc.)
@return the requested Normalizer2, if successful | [
"Returns",
"a",
"Normalizer2",
"instance",
"which",
"uses",
"the",
"specified",
"data",
"file",
"(",
"an",
"ICU",
"data",
"file",
"if",
"data",
"=",
"null",
"or",
"else",
"custom",
"binary",
"data",
")",
"and",
"which",
"composes",
"or",
"decomposes",
"tex... | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/Normalizer2.java#L181-L199 |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/XMLUtils.java | XMLUtils.getChildElements | public static List<Element> getChildElements(final Element elem, final DitaClass cls) {
return getChildElements(elem, cls, false);
} | java | public static List<Element> getChildElements(final Element elem, final DitaClass cls) {
return getChildElements(elem, cls, false);
} | [
"public",
"static",
"List",
"<",
"Element",
">",
"getChildElements",
"(",
"final",
"Element",
"elem",
",",
"final",
"DitaClass",
"cls",
")",
"{",
"return",
"getChildElements",
"(",
"elem",
",",
"cls",
",",
"false",
")",
";",
"}"
] | List child elements by DITA class.
@param elem root element
@param cls DITA class to match elements
@return list of matching elements | [
"List",
"child",
"elements",
"by",
"DITA",
"class",
"."
] | train | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/XMLUtils.java#L180-L182 |
Azure/azure-sdk-for-java | compute/resource-manager/v2017_12_01/src/main/java/com/microsoft/azure/management/compute/v2017_12_01/implementation/LogAnalyticsInner.java | LogAnalyticsInner.exportRequestRateByIntervalAsync | public Observable<LogAnalyticsOperationResultInner> exportRequestRateByIntervalAsync(String location, RequestRateByIntervalInput parameters) {
return exportRequestRateByIntervalWithServiceResponseAsync(location, parameters).map(new Func1<ServiceResponse<LogAnalyticsOperationResultInner>, LogAnalyticsOperationResultInner>() {
@Override
public LogAnalyticsOperationResultInner call(ServiceResponse<LogAnalyticsOperationResultInner> response) {
return response.body();
}
});
} | java | public Observable<LogAnalyticsOperationResultInner> exportRequestRateByIntervalAsync(String location, RequestRateByIntervalInput parameters) {
return exportRequestRateByIntervalWithServiceResponseAsync(location, parameters).map(new Func1<ServiceResponse<LogAnalyticsOperationResultInner>, LogAnalyticsOperationResultInner>() {
@Override
public LogAnalyticsOperationResultInner call(ServiceResponse<LogAnalyticsOperationResultInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"LogAnalyticsOperationResultInner",
">",
"exportRequestRateByIntervalAsync",
"(",
"String",
"location",
",",
"RequestRateByIntervalInput",
"parameters",
")",
"{",
"return",
"exportRequestRateByIntervalWithServiceResponseAsync",
"(",
"location",
",",
... | Export logs that show Api requests made by this subscription in the given time window to show throttling activities.
@param location The location upon which virtual-machine-sizes is queried.
@param parameters Parameters supplied to the LogAnalytics getRequestRateByInterval Api.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Export",
"logs",
"that",
"show",
"Api",
"requests",
"made",
"by",
"this",
"subscription",
"in",
"the",
"given",
"time",
"window",
"to",
"show",
"throttling",
"activities",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/compute/resource-manager/v2017_12_01/src/main/java/com/microsoft/azure/management/compute/v2017_12_01/implementation/LogAnalyticsInner.java#L111-L118 |
OpenLiberty/open-liberty | dev/com.ibm.ws.security.common/src/com/ibm/ws/security/common/config/CommonConfigUtils.java | CommonConfigUtils.getRequiredConfigAttributeWithDefaultValue | public String getRequiredConfigAttributeWithDefaultValue(Map<String, Object> props, String key, String defaultValue) {
return getRequiredConfigAttributeWithDefaultValueAndConfigId(props, key, defaultValue, null);
} | java | public String getRequiredConfigAttributeWithDefaultValue(Map<String, Object> props, String key, String defaultValue) {
return getRequiredConfigAttributeWithDefaultValueAndConfigId(props, key, defaultValue, null);
} | [
"public",
"String",
"getRequiredConfigAttributeWithDefaultValue",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"props",
",",
"String",
"key",
",",
"String",
"defaultValue",
")",
"{",
"return",
"getRequiredConfigAttributeWithDefaultValueAndConfigId",
"(",
"props",
",",... | Returns the value for the configuration attribute matching the key provided. If the value does not exist or is empty, the
resulting value will be {@code null} and an error message will be logged. | [
"Returns",
"the",
"value",
"for",
"the",
"configuration",
"attribute",
"matching",
"the",
"key",
"provided",
".",
"If",
"the",
"value",
"does",
"not",
"exist",
"or",
"is",
"empty",
"the",
"resulting",
"value",
"will",
"be",
"{"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.common/src/com/ibm/ws/security/common/config/CommonConfigUtils.java#L60-L62 |
santhosh-tekuri/jlibs | core/src/main/java/jlibs/core/lang/RuntimeUtil.java | RuntimeUtil.redirectStreams | public static void redirectStreams(Process process, OutputStream output, OutputStream error){
if(output!=null)
new Thread(new IOPump(process.getInputStream(), output, false, false).asRunnable()).start();
if(error!=null)
new Thread(new IOPump(process.getErrorStream(), error, false, false).asRunnable()).start();
} | java | public static void redirectStreams(Process process, OutputStream output, OutputStream error){
if(output!=null)
new Thread(new IOPump(process.getInputStream(), output, false, false).asRunnable()).start();
if(error!=null)
new Thread(new IOPump(process.getErrorStream(), error, false, false).asRunnable()).start();
} | [
"public",
"static",
"void",
"redirectStreams",
"(",
"Process",
"process",
",",
"OutputStream",
"output",
",",
"OutputStream",
"error",
")",
"{",
"if",
"(",
"output",
"!=",
"null",
")",
"new",
"Thread",
"(",
"new",
"IOPump",
"(",
"process",
".",
"getInputStre... | Redirects given process's input and error streams to the specified streams.
the streams specified are not closed automatically. The streams passed
can be null, if you don't want to redirect them.
@param process process whose streams to be redirected
@param output outputStream to which process's inputStream is redirected.<br>
null if you don't want to redirect.
@param error outputStream to which process's errorStream is redirected.<br>
null if you don't want to redirect. | [
"Redirects",
"given",
"process",
"s",
"input",
"and",
"error",
"streams",
"to",
"the",
"specified",
"streams",
".",
"the",
"streams",
"specified",
"are",
"not",
"closed",
"automatically",
".",
"The",
"streams",
"passed",
"can",
"be",
"null",
"if",
"you",
"do... | train | https://github.com/santhosh-tekuri/jlibs/blob/59c28719f054123cf778278154e1b92e943ad232/core/src/main/java/jlibs/core/lang/RuntimeUtil.java#L43-L48 |
blackfizz/EazeGraph | EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/StackedBarChart.java | StackedBarChart.calculateBounds | protected void calculateBounds(float _Width, float _Margin) {
int last = 0;
for (StackedBarModel model : mData) {
float lastY = 0;
float cumulatedValues = 0;
// used if seperators are enabled, to prevent information loss
int usableGraphHeight = mGraphHeight - (int) (mSeparatorWidth * (model.getBars().size() - 1));
for (BarModel barModel : model.getBars()) {
cumulatedValues += barModel.getValue();
}
last += _Margin / 2;
for (BarModel barModel : model.getBars()) {
// calculate topX for the StackedBarModel part
float newY = ((barModel.getValue() * usableGraphHeight) / cumulatedValues) + lastY;
float height = newY - lastY;
Rect textBounds = new Rect();
String value = String.valueOf(barModel.getValue());
mTextPaint.getTextBounds(value, 0, value.length(), textBounds);
if (textBounds.height() * 1.5f < height && textBounds.width() * 1.1f < _Width) {
barModel.setShowValue(true);
barModel.setValueBounds(textBounds);
}
barModel.setBarBounds(new RectF(last, lastY, last + _Width, newY));
lastY = newY;
}
model.setLegendBounds(new RectF(last, 0, last + _Width, mLegendHeight));
last += _Width + (_Margin / 2);
}
Utils.calculateLegendInformation(mData, 0, mContentRect.width(), mLegendPaint);
} | java | protected void calculateBounds(float _Width, float _Margin) {
int last = 0;
for (StackedBarModel model : mData) {
float lastY = 0;
float cumulatedValues = 0;
// used if seperators are enabled, to prevent information loss
int usableGraphHeight = mGraphHeight - (int) (mSeparatorWidth * (model.getBars().size() - 1));
for (BarModel barModel : model.getBars()) {
cumulatedValues += barModel.getValue();
}
last += _Margin / 2;
for (BarModel barModel : model.getBars()) {
// calculate topX for the StackedBarModel part
float newY = ((barModel.getValue() * usableGraphHeight) / cumulatedValues) + lastY;
float height = newY - lastY;
Rect textBounds = new Rect();
String value = String.valueOf(barModel.getValue());
mTextPaint.getTextBounds(value, 0, value.length(), textBounds);
if (textBounds.height() * 1.5f < height && textBounds.width() * 1.1f < _Width) {
barModel.setShowValue(true);
barModel.setValueBounds(textBounds);
}
barModel.setBarBounds(new RectF(last, lastY, last + _Width, newY));
lastY = newY;
}
model.setLegendBounds(new RectF(last, 0, last + _Width, mLegendHeight));
last += _Width + (_Margin / 2);
}
Utils.calculateLegendInformation(mData, 0, mContentRect.width(), mLegendPaint);
} | [
"protected",
"void",
"calculateBounds",
"(",
"float",
"_Width",
",",
"float",
"_Margin",
")",
"{",
"int",
"last",
"=",
"0",
";",
"for",
"(",
"StackedBarModel",
"model",
":",
"mData",
")",
"{",
"float",
"lastY",
"=",
"0",
";",
"float",
"cumulatedValues",
... | Calculates the bar boundaries based on the bar width and bar margin.
@param _Width Calculated bar width
@param _Margin Calculated bar margin | [
"Calculates",
"the",
"bar",
"boundaries",
"based",
"on",
"the",
"bar",
"width",
"and",
"bar",
"margin",
"."
] | train | https://github.com/blackfizz/EazeGraph/blob/ce5e68ecc70e154f83bbb2fcce1a970db125c1e6/EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/StackedBarChart.java#L230-L269 |
lightbend/config | config/src/main/java/com/typesafe/config/ConfigFactory.java | ConfigFactory.parseString | public static Config parseString(String s, ConfigParseOptions options) {
return Parseable.newString(s, options).parse().toConfig();
} | java | public static Config parseString(String s, ConfigParseOptions options) {
return Parseable.newString(s, options).parse().toConfig();
} | [
"public",
"static",
"Config",
"parseString",
"(",
"String",
"s",
",",
"ConfigParseOptions",
"options",
")",
"{",
"return",
"Parseable",
".",
"newString",
"(",
"s",
",",
"options",
")",
".",
"parse",
"(",
")",
".",
"toConfig",
"(",
")",
";",
"}"
] | Parses a string (which should be valid HOCON or JSON by default, or
the syntax specified in the options otherwise).
@param s string to parse
@param options parse options
@return the parsed configuration | [
"Parses",
"a",
"string",
"(",
"which",
"should",
"be",
"valid",
"HOCON",
"or",
"JSON",
"by",
"default",
"or",
"the",
"syntax",
"specified",
"in",
"the",
"options",
"otherwise",
")",
"."
] | train | https://github.com/lightbend/config/blob/68cebfde5e861e9a5fdc75ceff366ed95e17d475/config/src/main/java/com/typesafe/config/ConfigFactory.java#L1050-L1052 |
wwadge/bonecp | bonecp/src/main/java/com/jolbox/bonecp/ConnectionHandle.java | ConnectionHandle.sendInitSQL | protected static void sendInitSQL(Connection connection, String initSQL) throws SQLException{
// fetch any configured setup sql.
if (initSQL != null){
Statement stmt = null;
try{
stmt = connection.createStatement();
stmt.execute(initSQL);
if (testSupport){ // only to aid code coverage, normally set to false
stmt = null;
}
} finally{
if (stmt != null){
stmt.close();
}
}
}
} | java | protected static void sendInitSQL(Connection connection, String initSQL) throws SQLException{
// fetch any configured setup sql.
if (initSQL != null){
Statement stmt = null;
try{
stmt = connection.createStatement();
stmt.execute(initSQL);
if (testSupport){ // only to aid code coverage, normally set to false
stmt = null;
}
} finally{
if (stmt != null){
stmt.close();
}
}
}
} | [
"protected",
"static",
"void",
"sendInitSQL",
"(",
"Connection",
"connection",
",",
"String",
"initSQL",
")",
"throws",
"SQLException",
"{",
"// fetch any configured setup sql.\r",
"if",
"(",
"initSQL",
"!=",
"null",
")",
"{",
"Statement",
"stmt",
"=",
"null",
";"... | Sends out the SQL as defined in the config upon first init of the connection.
@param connection
@param initSQL
@throws SQLException | [
"Sends",
"out",
"the",
"SQL",
"as",
"defined",
"in",
"the",
"config",
"upon",
"first",
"init",
"of",
"the",
"connection",
"."
] | train | https://github.com/wwadge/bonecp/blob/74bc3287025fc137ca28909f0f7693edae37a15d/bonecp/src/main/java/com/jolbox/bonecp/ConnectionHandle.java#L351-L367 |
UrielCh/ovh-java-sdk | ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java | ApiOvhOrder.dedicated_server_serviceName_bandwidth_GET | public ArrayList<String> dedicated_server_serviceName_bandwidth_GET(String serviceName, OvhBandwidthOrderEnum bandwidth, OvhBandwidthOrderTypeEnum type) throws IOException {
String qPath = "/order/dedicated/server/{serviceName}/bandwidth";
StringBuilder sb = path(qPath, serviceName);
query(sb, "bandwidth", bandwidth);
query(sb, "type", type);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t1);
} | java | public ArrayList<String> dedicated_server_serviceName_bandwidth_GET(String serviceName, OvhBandwidthOrderEnum bandwidth, OvhBandwidthOrderTypeEnum type) throws IOException {
String qPath = "/order/dedicated/server/{serviceName}/bandwidth";
StringBuilder sb = path(qPath, serviceName);
query(sb, "bandwidth", bandwidth);
query(sb, "type", type);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t1);
} | [
"public",
"ArrayList",
"<",
"String",
">",
"dedicated_server_serviceName_bandwidth_GET",
"(",
"String",
"serviceName",
",",
"OvhBandwidthOrderEnum",
"bandwidth",
",",
"OvhBandwidthOrderTypeEnum",
"type",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/order... | Get allowed durations for 'bandwidth' option
REST: GET /order/dedicated/server/{serviceName}/bandwidth
@param bandwidth [required] Bandwidth to allocate
@param type [required] bandwidth type
@param serviceName [required] The internal name of your dedicated server | [
"Get",
"allowed",
"durations",
"for",
"bandwidth",
"option"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java#L2537-L2544 |
OpenLiberty/open-liberty | dev/com.ibm.ws.microprofile.config.1.1/src/com/ibm/ws/microprofile/config/impl/ConversionManager.java | ConversionManager.convertCompatible | protected ConversionStatus convertCompatible(String rawString, Class<?> type) {
ConversionStatus status = new ConversionStatus();
for (PriorityConverter con : converters.getAll()) {
Type key = con.getType();
if (key instanceof Class) {
Class<?> clazz = (Class<?>) key;
if (type.isAssignableFrom(clazz)) {
Object converted = convert(rawString, key);
status.setConverted(converted);
break;
}
} else if (key instanceof TypeVariable) {
TypeVariable<?> typeVariable = (TypeVariable<?>) key;
status = convertGenericClazz(rawString, type, typeVariable);
if (status.isConverterFound()) {
break;
}
}
}
return status;
} | java | protected ConversionStatus convertCompatible(String rawString, Class<?> type) {
ConversionStatus status = new ConversionStatus();
for (PriorityConverter con : converters.getAll()) {
Type key = con.getType();
if (key instanceof Class) {
Class<?> clazz = (Class<?>) key;
if (type.isAssignableFrom(clazz)) {
Object converted = convert(rawString, key);
status.setConverted(converted);
break;
}
} else if (key instanceof TypeVariable) {
TypeVariable<?> typeVariable = (TypeVariable<?>) key;
status = convertGenericClazz(rawString, type, typeVariable);
if (status.isConverterFound()) {
break;
}
}
}
return status;
} | [
"protected",
"ConversionStatus",
"convertCompatible",
"(",
"String",
"rawString",
",",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"ConversionStatus",
"status",
"=",
"new",
"ConversionStatus",
"(",
")",
";",
"for",
"(",
"PriorityConverter",
"con",
":",
"converters... | Converts from String based on isAssignableFrom or instanceof
@param rawString
@param type
@return ConversionStatus<T> whether a converter is found and the converted value | [
"Converts",
"from",
"String",
"based",
"on",
"isAssignableFrom",
"or",
"instanceof"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.microprofile.config.1.1/src/com/ibm/ws/microprofile/config/impl/ConversionManager.java#L213-L234 |
DataArt/CalculationEngine | calculation-engine/engine-model/src/main/java/com/dataart/spreadsheetanalytics/model/CellValue.java | CellValue.from | public static ICellValue from(Object o) {
if (o == null) { return BLANK; }
else if (o instanceof String) { return new CellValue(o, String.class); }
else if (o instanceof Double) { return new CellValue(o, Double.class); }
else if (o instanceof Integer) { return new CellValue(new Double((Integer) o)); }
else if (o instanceof Boolean) { return new CellValue(o, Boolean.class); }
throw new CalculationEngineException(String.format("The object %s of class %s is not supported as type for CellValue", o, o.getClass().getSimpleName()));
} | java | public static ICellValue from(Object o) {
if (o == null) { return BLANK; }
else if (o instanceof String) { return new CellValue(o, String.class); }
else if (o instanceof Double) { return new CellValue(o, Double.class); }
else if (o instanceof Integer) { return new CellValue(new Double((Integer) o)); }
else if (o instanceof Boolean) { return new CellValue(o, Boolean.class); }
throw new CalculationEngineException(String.format("The object %s of class %s is not supported as type for CellValue", o, o.getClass().getSimpleName()));
} | [
"public",
"static",
"ICellValue",
"from",
"(",
"Object",
"o",
")",
"{",
"if",
"(",
"o",
"==",
"null",
")",
"{",
"return",
"BLANK",
";",
"}",
"else",
"if",
"(",
"o",
"instanceof",
"String",
")",
"{",
"return",
"new",
"CellValue",
"(",
"o",
",",
"Str... | Creates new instance of {@link CellValue} with given argument.
Supported types: null, String, Double, Boolean. | [
"Creates",
"new",
"instance",
"of",
"{"
] | train | https://github.com/DataArt/CalculationEngine/blob/34ce1d9c1f9b57a502906b274311d28580b134e5/calculation-engine/engine-model/src/main/java/com/dataart/spreadsheetanalytics/model/CellValue.java#L53-L61 |
arakelian/docker-junit-rule | src/main/java/com/arakelian/docker/junit/Container.java | Container.waitForPort | public final void waitForPort(final String portName, final int timeout, final TimeUnit unit) {
final Binding binding = getPortBinding(portName);
waitForPort(binding.getHost(), binding.getPort(), timeout, unit);
} | java | public final void waitForPort(final String portName, final int timeout, final TimeUnit unit) {
final Binding binding = getPortBinding(portName);
waitForPort(binding.getHost(), binding.getPort(), timeout, unit);
} | [
"public",
"final",
"void",
"waitForPort",
"(",
"final",
"String",
"portName",
",",
"final",
"int",
"timeout",
",",
"final",
"TimeUnit",
"unit",
")",
"{",
"final",
"Binding",
"binding",
"=",
"getPortBinding",
"(",
"portName",
")",
";",
"waitForPort",
"(",
"bi... | Wait for the specified port to accept socket connection within a given time frame.
@param portName
docker port name, e.g. 9200/tcp
@param timeout
timeout value
@param unit
timeout units | [
"Wait",
"for",
"the",
"specified",
"port",
"to",
"accept",
"socket",
"connection",
"within",
"a",
"given",
"time",
"frame",
"."
] | train | https://github.com/arakelian/docker-junit-rule/blob/cc99d63896a07df398b53fd5f0f6e4777e3b23cf/src/main/java/com/arakelian/docker/junit/Container.java#L460-L463 |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/linsol/qr/SolveNullSpaceQRP_DDRM.java | SolveNullSpaceQRP_DDRM.process | public boolean process(DMatrixRMaj A , int numSingularValues, DMatrixRMaj nullspace ) {
decomposition.decompose(A);
if( A.numRows > A.numCols ) {
Q.reshape(A.numCols,Math.min(A.numRows,A.numCols));
decomposition.getQ(Q, true);
} else {
Q.reshape(A.numCols, A.numCols);
decomposition.getQ(Q, false);
}
nullspace.reshape(Q.numRows,numSingularValues);
CommonOps_DDRM.extract(Q,0,Q.numRows,Q.numCols-numSingularValues,Q.numCols,nullspace,0,0);
return true;
} | java | public boolean process(DMatrixRMaj A , int numSingularValues, DMatrixRMaj nullspace ) {
decomposition.decompose(A);
if( A.numRows > A.numCols ) {
Q.reshape(A.numCols,Math.min(A.numRows,A.numCols));
decomposition.getQ(Q, true);
} else {
Q.reshape(A.numCols, A.numCols);
decomposition.getQ(Q, false);
}
nullspace.reshape(Q.numRows,numSingularValues);
CommonOps_DDRM.extract(Q,0,Q.numRows,Q.numCols-numSingularValues,Q.numCols,nullspace,0,0);
return true;
} | [
"public",
"boolean",
"process",
"(",
"DMatrixRMaj",
"A",
",",
"int",
"numSingularValues",
",",
"DMatrixRMaj",
"nullspace",
")",
"{",
"decomposition",
".",
"decompose",
"(",
"A",
")",
";",
"if",
"(",
"A",
".",
"numRows",
">",
"A",
".",
"numCols",
")",
"{"... | Finds the null space of A
@param A (Input) Matrix. Modified
@param numSingularValues Number of singular values
@param nullspace Storage for null-space
@return true if successful or false if it failed | [
"Finds",
"the",
"null",
"space",
"of",
"A"
] | train | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/linsol/qr/SolveNullSpaceQRP_DDRM.java#L48-L63 |
facebookarchive/hadoop-20 | src/contrib/fairscheduler/src/java/org/apache/hadoop/mapred/FairScheduler.java | FairScheduler.slotsUsedWithWeightToSlotRatio | private double slotsUsedWithWeightToSlotRatio(double w2sRatio, TaskType type) {
double slotsTaken = 0;
for (JobInfo info : infos.values()) {
slotsTaken += computeShare(info, w2sRatio, type);
}
return slotsTaken;
} | java | private double slotsUsedWithWeightToSlotRatio(double w2sRatio, TaskType type) {
double slotsTaken = 0;
for (JobInfo info : infos.values()) {
slotsTaken += computeShare(info, w2sRatio, type);
}
return slotsTaken;
} | [
"private",
"double",
"slotsUsedWithWeightToSlotRatio",
"(",
"double",
"w2sRatio",
",",
"TaskType",
"type",
")",
"{",
"double",
"slotsTaken",
"=",
"0",
";",
"for",
"(",
"JobInfo",
"info",
":",
"infos",
".",
"values",
"(",
")",
")",
"{",
"slotsTaken",
"+=",
... | Compute the number of slots that would be used given a weight-to-slot
ratio w2sRatio. | [
"Compute",
"the",
"number",
"of",
"slots",
"that",
"would",
"be",
"used",
"given",
"a",
"weight",
"-",
"to",
"-",
"slot",
"ratio",
"w2sRatio",
"."
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/contrib/fairscheduler/src/java/org/apache/hadoop/mapred/FairScheduler.java#L1964-L1970 |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/types/Type.java | Type.castToType | public Object castToType(SessionInterface session, Object a, Type type) {
return convertToType(session, a, type);
} | java | public Object castToType(SessionInterface session, Object a, Type type) {
return convertToType(session, a, type);
} | [
"public",
"Object",
"castToType",
"(",
"SessionInterface",
"session",
",",
"Object",
"a",
",",
"Type",
"type",
")",
"{",
"return",
"convertToType",
"(",
"session",
",",
"a",
",",
"type",
")",
";",
"}"
] | Explicit casts are handled by this method.
SQL standard 6.12 rules for enforcement of size, precision and scale
are implemented. For CHARACTER values, it performs truncation in all
cases of long strings. | [
"Explicit",
"casts",
"are",
"handled",
"by",
"this",
"method",
".",
"SQL",
"standard",
"6",
".",
"12",
"rules",
"for",
"enforcement",
"of",
"size",
"precision",
"and",
"scale",
"are",
"implemented",
".",
"For",
"CHARACTER",
"values",
"it",
"performs",
"trunc... | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/types/Type.java#L253-L255 |
VoltDB/voltdb | src/frontend/org/voltcore/messaging/SocketJoiner.java | SocketJoiner.publishHostId | private JSONObject publishHostId(
InetSocketAddress hostAddr,
MessagingChannel messagingChannel,
Set<String> activeVersions) throws Exception
{
JSONObject jsObj = new JSONObject();
jsObj.put(TYPE, ConnectionType.PUBLISH_HOSTID.name());
jsObj.put(HOST_ID, m_localHostId);
jsObj.put(PORT, m_internalPort);
jsObj.put(ADDRESS,
m_internalInterface.isEmpty() ? m_reportedInternalInterface : m_internalInterface);
jsObj.put(VERSION_STRING, m_acceptor.getVersionChecker().getVersionString());
jsObj = m_acceptor.decorate(jsObj, Optional.empty());
jsObj.put(MAY_EXCHANGE_TS, true);
byte[] jsBytes = jsObj.toString(4).getBytes(StandardCharsets.UTF_8);
ByteBuffer pushHostId = ByteBuffer.allocate(4 + jsBytes.length);
pushHostId.putInt(jsBytes.length);
pushHostId.put(jsBytes).flip();
messagingChannel.writeMessage(pushHostId);
// read the json response from socketjoiner with version info and validate it
return processJSONResponse(messagingChannel, activeVersions, true);
} | java | private JSONObject publishHostId(
InetSocketAddress hostAddr,
MessagingChannel messagingChannel,
Set<String> activeVersions) throws Exception
{
JSONObject jsObj = new JSONObject();
jsObj.put(TYPE, ConnectionType.PUBLISH_HOSTID.name());
jsObj.put(HOST_ID, m_localHostId);
jsObj.put(PORT, m_internalPort);
jsObj.put(ADDRESS,
m_internalInterface.isEmpty() ? m_reportedInternalInterface : m_internalInterface);
jsObj.put(VERSION_STRING, m_acceptor.getVersionChecker().getVersionString());
jsObj = m_acceptor.decorate(jsObj, Optional.empty());
jsObj.put(MAY_EXCHANGE_TS, true);
byte[] jsBytes = jsObj.toString(4).getBytes(StandardCharsets.UTF_8);
ByteBuffer pushHostId = ByteBuffer.allocate(4 + jsBytes.length);
pushHostId.putInt(jsBytes.length);
pushHostId.put(jsBytes).flip();
messagingChannel.writeMessage(pushHostId);
// read the json response from socketjoiner with version info and validate it
return processJSONResponse(messagingChannel, activeVersions, true);
} | [
"private",
"JSONObject",
"publishHostId",
"(",
"InetSocketAddress",
"hostAddr",
",",
"MessagingChannel",
"messagingChannel",
",",
"Set",
"<",
"String",
">",
"activeVersions",
")",
"throws",
"Exception",
"{",
"JSONObject",
"jsObj",
"=",
"new",
"JSONObject",
"(",
")",... | Connection handshake to non-leader node, broadcast the new hostId to each node of the
cluster (except the leader).
@param
@return JSONObject response message from peer node
@throws Exception | [
"Connection",
"handshake",
"to",
"non",
"-",
"leader",
"node",
"broadcast",
"the",
"new",
"hostId",
"to",
"each",
"node",
"of",
"the",
"cluster",
"(",
"except",
"the",
"leader",
")",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltcore/messaging/SocketJoiner.java#L810-L834 |
UrielCh/ovh-java-sdk | ovh-java-sdk-cloud/src/main/java/net/minidev/ovh/api/ApiOvhCloud.java | ApiOvhCloud.project_serviceName_ip_GET | public ArrayList<OvhCloudIp> project_serviceName_ip_GET(String serviceName) throws IOException {
String qPath = "/cloud/project/{serviceName}/ip";
StringBuilder sb = path(qPath, serviceName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t14);
} | java | public ArrayList<OvhCloudIp> project_serviceName_ip_GET(String serviceName) throws IOException {
String qPath = "/cloud/project/{serviceName}/ip";
StringBuilder sb = path(qPath, serviceName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t14);
} | [
"public",
"ArrayList",
"<",
"OvhCloudIp",
">",
"project_serviceName_ip_GET",
"(",
"String",
"serviceName",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/cloud/project/{serviceName}/ip\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"... | Get ips
REST: GET /cloud/project/{serviceName}/ip
@param serviceName [required] Project id | [
"Get",
"ips"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-cloud/src/main/java/net/minidev/ovh/api/ApiOvhCloud.java#L1336-L1341 |
Carbonado/Carbonado | src/main/java/com/amazon/carbonado/raw/DataDecoder.java | DataDecoder.decodeByteObj | public static Byte decodeByteObj(byte[] src, int srcOffset)
throws CorruptEncodingException
{
try {
int b = src[srcOffset];
if (b == NULL_BYTE_HIGH || b == NULL_BYTE_LOW) {
return null;
}
return decodeByte(src, srcOffset + 1);
} catch (IndexOutOfBoundsException e) {
throw new CorruptEncodingException(null, e);
}
} | java | public static Byte decodeByteObj(byte[] src, int srcOffset)
throws CorruptEncodingException
{
try {
int b = src[srcOffset];
if (b == NULL_BYTE_HIGH || b == NULL_BYTE_LOW) {
return null;
}
return decodeByte(src, srcOffset + 1);
} catch (IndexOutOfBoundsException e) {
throw new CorruptEncodingException(null, e);
}
} | [
"public",
"static",
"Byte",
"decodeByteObj",
"(",
"byte",
"[",
"]",
"src",
",",
"int",
"srcOffset",
")",
"throws",
"CorruptEncodingException",
"{",
"try",
"{",
"int",
"b",
"=",
"src",
"[",
"srcOffset",
"]",
";",
"if",
"(",
"b",
"==",
"NULL_BYTE_HIGH",
"|... | Decodes a signed Byte object from exactly 1 or 2 bytes. If null is
returned, then 1 byte was read.
@param src source of encoded bytes
@param srcOffset offset into source array
@return signed Byte object or null | [
"Decodes",
"a",
"signed",
"Byte",
"object",
"from",
"exactly",
"1",
"or",
"2",
"bytes",
".",
"If",
"null",
"is",
"returned",
"then",
"1",
"byte",
"was",
"read",
"."
] | train | https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/DataDecoder.java#L153-L165 |
fuzzylite/jfuzzylite | jfuzzylite/src/main/java/com/fuzzylite/defuzzifier/Bisector.java | Bisector.defuzzify | @Override
public double defuzzify(Term term, double minimum, double maximum) {
if (!Op.isFinite(minimum + maximum)) {
return Double.NaN;
}
final double dx = (maximum - minimum) / getResolution();
int counter = getResolution();
int left = 0, right = 0;
double leftArea = 0, rightArea = 0;
double xLeft = minimum, xRight = maximum;
while (counter-- > 0) {
if (Op.isLE(leftArea, rightArea)) {
xLeft = minimum + (left + 0.5) * dx;
leftArea += term.membership(xLeft);
left++;
} else {
xRight = maximum - (right + 0.5) * dx;
rightArea += term.membership(xRight);
right++;
}
}
//Inverse weighted average to compensate
return (leftArea * xRight + rightArea * xLeft) / (leftArea + rightArea);
} | java | @Override
public double defuzzify(Term term, double minimum, double maximum) {
if (!Op.isFinite(minimum + maximum)) {
return Double.NaN;
}
final double dx = (maximum - minimum) / getResolution();
int counter = getResolution();
int left = 0, right = 0;
double leftArea = 0, rightArea = 0;
double xLeft = minimum, xRight = maximum;
while (counter-- > 0) {
if (Op.isLE(leftArea, rightArea)) {
xLeft = minimum + (left + 0.5) * dx;
leftArea += term.membership(xLeft);
left++;
} else {
xRight = maximum - (right + 0.5) * dx;
rightArea += term.membership(xRight);
right++;
}
}
//Inverse weighted average to compensate
return (leftArea * xRight + rightArea * xLeft) / (leftArea + rightArea);
} | [
"@",
"Override",
"public",
"double",
"defuzzify",
"(",
"Term",
"term",
",",
"double",
"minimum",
",",
"double",
"maximum",
")",
"{",
"if",
"(",
"!",
"Op",
".",
"isFinite",
"(",
"minimum",
"+",
"maximum",
")",
")",
"{",
"return",
"Double",
".",
"NaN",
... | Computes the bisector of a fuzzy set. The defuzzification process
integrates over the fuzzy set utilizing the boundaries given as parameters.
The integration algorithm is the midpoint rectangle method
(https://en.wikipedia.org/wiki/Rectangle_method).
@param term is the fuzzy set
@param minimum is the minimum value of the fuzzy set
@param maximum is the maximum value of the fuzzy set
@return the `x`-coordinate of the bisector of the fuzzy set | [
"Computes",
"the",
"bisector",
"of",
"a",
"fuzzy",
"set",
".",
"The",
"defuzzification",
"process",
"integrates",
"over",
"the",
"fuzzy",
"set",
"utilizing",
"the",
"boundaries",
"given",
"as",
"parameters",
".",
"The",
"integration",
"algorithm",
"is",
"the",
... | train | https://github.com/fuzzylite/jfuzzylite/blob/583ac1928f39512af75de80d560e67448039595a/jfuzzylite/src/main/java/com/fuzzylite/defuzzifier/Bisector.java#L53-L76 |
kaazing/gateway | mina.core/core/src/main/java/org/apache/mina/handler/demux/DemuxingIoHandler.java | DemuxingIoHandler.messageSent | @Override
public void messageSent(IoSession session, Object message) throws Exception {
MessageHandler<Object> handler = findSentMessageHandler(message.getClass());
if (handler != null) {
handler.handleMessage(session, message);
} else {
throw new UnknownMessageTypeException(
"No handler found for message type: " +
message.getClass().getSimpleName());
}
} | java | @Override
public void messageSent(IoSession session, Object message) throws Exception {
MessageHandler<Object> handler = findSentMessageHandler(message.getClass());
if (handler != null) {
handler.handleMessage(session, message);
} else {
throw new UnknownMessageTypeException(
"No handler found for message type: " +
message.getClass().getSimpleName());
}
} | [
"@",
"Override",
"public",
"void",
"messageSent",
"(",
"IoSession",
"session",
",",
"Object",
"message",
")",
"throws",
"Exception",
"{",
"MessageHandler",
"<",
"Object",
">",
"handler",
"=",
"findSentMessageHandler",
"(",
"message",
".",
"getClass",
"(",
")",
... | Invoked when a message written by IoSession.write(Object) is sent out.
<b>Warning !</b> If you are to overload this method, be aware that you
_must_ call the messageHandler in your own method, otherwise it won't
be called. | [
"Invoked",
"when",
"a",
"message",
"written",
"by",
"IoSession",
".",
"write",
"(",
"Object",
")",
"is",
"sent",
"out",
"."
] | train | https://github.com/kaazing/gateway/blob/06017b19273109b3b992e528e702586446168d57/mina.core/core/src/main/java/org/apache/mina/handler/demux/DemuxingIoHandler.java#L243-L253 |
fcrepo4/fcrepo4 | fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/utils/FedoraTypesUtils.java | FedoraTypesUtils.touch | private static void touch(final Node node, final Calendar modified, final String modifyingUser) {
touch(node, null, null, modified, modifyingUser);
} | java | private static void touch(final Node node, final Calendar modified, final String modifyingUser) {
touch(node, null, null, modified, modifyingUser);
} | [
"private",
"static",
"void",
"touch",
"(",
"final",
"Node",
"node",
",",
"final",
"Calendar",
"modified",
",",
"final",
"String",
"modifyingUser",
")",
"{",
"touch",
"(",
"node",
",",
"null",
",",
"null",
",",
"modified",
",",
"modifyingUser",
")",
";",
... | Updates the LAST_MODIFIED_DATE and LAST_MODIFIED_BY properties to the provided values.
@param node The JCR node
@param modified the modification date, or null if not explicitly set
@param modifyingUser the userID who modified this resource or null if not explicitly set | [
"Updates",
"the",
"LAST_MODIFIED_DATE",
"and",
"LAST_MODIFIED_BY",
"properties",
"to",
"the",
"provided",
"values",
"."
] | train | https://github.com/fcrepo4/fcrepo4/blob/7489ad5bc8fb44e2442c93eceb7d97ac54553ab6/fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/utils/FedoraTypesUtils.java#L454-L456 |
RuedigerMoeller/kontraktor | src/main/java/org/nustaq/kontraktor/asyncio/AsyncFile.java | AsyncFile.asInputStream | public InputStream asInputStream() {
if ( tmp != null )
throw new RuntimeException("can create Input/OutputStream only once");
tmp = new byte[1];
return new InputStream() {
@Override
public void close() throws IOException {
AsyncFile.this.close();
}
@Override
public int read() throws IOException {
// should rarely be called, super slow
int read = read(tmp, 0, 1);
if ( read < 1 ) {
return -1;
}
return (tmp[0]+256)&0xff;
}
@Override
public int read(byte b[], int off, int len) throws IOException {
if ( event == null ) {
event = new AsyncFileIOEvent(0,0, ByteBuffer.allocate(len));
}
if ( event.getBuffer().capacity() < len ) {
event.buffer = ByteBuffer.allocate(len);
}
ByteBuffer buffer = event.buffer;
event.reset();
event = AsyncFile.this.read(event.getNextPosition(), len, buffer).await();
int readlen = event.getRead();
if ( readlen > 0 )
buffer.get(b,off,readlen);
return readlen;
}
};
} | java | public InputStream asInputStream() {
if ( tmp != null )
throw new RuntimeException("can create Input/OutputStream only once");
tmp = new byte[1];
return new InputStream() {
@Override
public void close() throws IOException {
AsyncFile.this.close();
}
@Override
public int read() throws IOException {
// should rarely be called, super slow
int read = read(tmp, 0, 1);
if ( read < 1 ) {
return -1;
}
return (tmp[0]+256)&0xff;
}
@Override
public int read(byte b[], int off, int len) throws IOException {
if ( event == null ) {
event = new AsyncFileIOEvent(0,0, ByteBuffer.allocate(len));
}
if ( event.getBuffer().capacity() < len ) {
event.buffer = ByteBuffer.allocate(len);
}
ByteBuffer buffer = event.buffer;
event.reset();
event = AsyncFile.this.read(event.getNextPosition(), len, buffer).await();
int readlen = event.getRead();
if ( readlen > 0 )
buffer.get(b,off,readlen);
return readlen;
}
};
} | [
"public",
"InputStream",
"asInputStream",
"(",
")",
"{",
"if",
"(",
"tmp",
"!=",
"null",
")",
"throw",
"new",
"RuntimeException",
"(",
"\"can create Input/OutputStream only once\"",
")",
";",
"tmp",
"=",
"new",
"byte",
"[",
"1",
"]",
";",
"return",
"new",
"I... | /*
return a pseudo-blocking input stream. Note: due to limitations of the current await implementation (stack based),
when reading many files concurrently from a single actor thread don't mix high latency file locations (e.g. remote file systems vs. local)
with low latency ones. If this is required, fall back to the more basic read/write methods returning futures. | [
"/",
"*",
"return",
"a",
"pseudo",
"-",
"blocking",
"input",
"stream",
".",
"Note",
":",
"due",
"to",
"limitations",
"of",
"the",
"current",
"await",
"implementation",
"(",
"stack",
"based",
")",
"when",
"reading",
"many",
"files",
"concurrently",
"from",
... | train | https://github.com/RuedigerMoeller/kontraktor/blob/d5f3817f9476f3786187b8ef00400b7a4f25a404/src/main/java/org/nustaq/kontraktor/asyncio/AsyncFile.java#L58-L98 |
Azure/azure-sdk-for-java | mediaservices/resource-manager/v2018_07_01/src/main/java/com/microsoft/azure/management/mediaservices/v2018_07_01/implementation/ContentKeyPoliciesInner.java | ContentKeyPoliciesInner.getAsync | public Observable<ContentKeyPolicyInner> getAsync(String resourceGroupName, String accountName, String contentKeyPolicyName) {
return getWithServiceResponseAsync(resourceGroupName, accountName, contentKeyPolicyName).map(new Func1<ServiceResponse<ContentKeyPolicyInner>, ContentKeyPolicyInner>() {
@Override
public ContentKeyPolicyInner call(ServiceResponse<ContentKeyPolicyInner> response) {
return response.body();
}
});
} | java | public Observable<ContentKeyPolicyInner> getAsync(String resourceGroupName, String accountName, String contentKeyPolicyName) {
return getWithServiceResponseAsync(resourceGroupName, accountName, contentKeyPolicyName).map(new Func1<ServiceResponse<ContentKeyPolicyInner>, ContentKeyPolicyInner>() {
@Override
public ContentKeyPolicyInner call(ServiceResponse<ContentKeyPolicyInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ContentKeyPolicyInner",
">",
"getAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"accountName",
",",
"String",
"contentKeyPolicyName",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"accountName",... | Get a Content Key Policy.
Get the details of a Content Key Policy in the Media Services account.
@param resourceGroupName The name of the resource group within the Azure subscription.
@param accountName The Media Services account name.
@param contentKeyPolicyName The Content Key Policy name.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ContentKeyPolicyInner object | [
"Get",
"a",
"Content",
"Key",
"Policy",
".",
"Get",
"the",
"details",
"of",
"a",
"Content",
"Key",
"Policy",
"in",
"the",
"Media",
"Services",
"account",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/mediaservices/resource-manager/v2018_07_01/src/main/java/com/microsoft/azure/management/mediaservices/v2018_07_01/implementation/ContentKeyPoliciesInner.java#L404-L411 |
dnsjava/dnsjava | org/xbill/DNS/Cache.java | Cache.addNegative | public synchronized void
addNegative(Name name, int type, SOARecord soa, int cred) {
long ttl = 0;
if (soa != null)
ttl = soa.getTTL();
Element element = findElement(name, type, 0);
if (ttl == 0) {
if (element != null && element.compareCredibility(cred) <= 0)
removeElement(name, type);
} else {
if (element != null && element.compareCredibility(cred) <= 0)
element = null;
if (element == null)
addElement(name, new NegativeElement(name, type,
soa, cred,
maxncache));
}
} | java | public synchronized void
addNegative(Name name, int type, SOARecord soa, int cred) {
long ttl = 0;
if (soa != null)
ttl = soa.getTTL();
Element element = findElement(name, type, 0);
if (ttl == 0) {
if (element != null && element.compareCredibility(cred) <= 0)
removeElement(name, type);
} else {
if (element != null && element.compareCredibility(cred) <= 0)
element = null;
if (element == null)
addElement(name, new NegativeElement(name, type,
soa, cred,
maxncache));
}
} | [
"public",
"synchronized",
"void",
"addNegative",
"(",
"Name",
"name",
",",
"int",
"type",
",",
"SOARecord",
"soa",
",",
"int",
"cred",
")",
"{",
"long",
"ttl",
"=",
"0",
";",
"if",
"(",
"soa",
"!=",
"null",
")",
"ttl",
"=",
"soa",
".",
"getTTL",
"(... | Adds a negative entry to the Cache.
@param name The name of the negative entry
@param type The type of the negative entry
@param soa The SOA record to add to the negative cache entry, or null.
The negative cache ttl is derived from the SOA.
@param cred The credibility of the negative entry | [
"Adds",
"a",
"negative",
"entry",
"to",
"the",
"Cache",
"."
] | train | https://github.com/dnsjava/dnsjava/blob/d97b6a0685d59143372bb392ab591dd8dd840b61/org/xbill/DNS/Cache.java#L381-L398 |
b3dgs/lionengine | lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/tile/map/collision/CollisionCategoryConfig.java | CollisionCategoryConfig.imports | public static CollisionCategory imports(Xml root, MapTileCollision map)
{
Check.notNull(root);
Check.notNull(map);
final Collection<Xml> children = root.getChildren(TileGroupsConfig.NODE_GROUP);
final Collection<CollisionGroup> groups = new ArrayList<>(children.size());
for (final Xml groupNode : children)
{
final String groupName = groupNode.getText();
final CollisionGroup group = map.getCollisionGroup(groupName);
groups.add(group);
}
final String axisName = root.readString(ATT_AXIS);
final Axis axis;
try
{
axis = Axis.valueOf(axisName);
}
catch (final IllegalArgumentException exception)
{
throw new LionEngineException(exception, ERROR_AXIS + axisName);
}
final int x = root.readInteger(ATT_X);
final int y = root.readInteger(ATT_Y);
final boolean glue = root.readBoolean(true, ATT_GLUE);
final String name = root.readString(ATT_NAME);
return new CollisionCategory(name, axis, x, y, glue, groups);
} | java | public static CollisionCategory imports(Xml root, MapTileCollision map)
{
Check.notNull(root);
Check.notNull(map);
final Collection<Xml> children = root.getChildren(TileGroupsConfig.NODE_GROUP);
final Collection<CollisionGroup> groups = new ArrayList<>(children.size());
for (final Xml groupNode : children)
{
final String groupName = groupNode.getText();
final CollisionGroup group = map.getCollisionGroup(groupName);
groups.add(group);
}
final String axisName = root.readString(ATT_AXIS);
final Axis axis;
try
{
axis = Axis.valueOf(axisName);
}
catch (final IllegalArgumentException exception)
{
throw new LionEngineException(exception, ERROR_AXIS + axisName);
}
final int x = root.readInteger(ATT_X);
final int y = root.readInteger(ATT_Y);
final boolean glue = root.readBoolean(true, ATT_GLUE);
final String name = root.readString(ATT_NAME);
return new CollisionCategory(name, axis, x, y, glue, groups);
} | [
"public",
"static",
"CollisionCategory",
"imports",
"(",
"Xml",
"root",
",",
"MapTileCollision",
"map",
")",
"{",
"Check",
".",
"notNull",
"(",
"root",
")",
";",
"Check",
".",
"notNull",
"(",
"map",
")",
";",
"final",
"Collection",
"<",
"Xml",
">",
"chil... | Create the category data from node.
@param root The root reference (must not be <code>null</code>).
@param map The map reference (must not be <code>null</code>).
@return The category node instance.
@throws LionEngineException If unable to read node. | [
"Create",
"the",
"category",
"data",
"from",
"node",
"."
] | train | https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/tile/map/collision/CollisionCategoryConfig.java#L127-L159 |
carewebframework/carewebframework-vista | org.carewebframework.vista.mbroker/src/main/java/org/carewebframework/vista/mbroker/BrokerSession.java | BrokerSession.onRPCError | protected void onRPCError(int asyncHandle, int asyncError, String text) {
IAsyncRPCEvent callback = getCallback(asyncHandle);
if (callback != null) {
callback.onRPCError(asyncHandle, asyncError, text);
}
} | java | protected void onRPCError(int asyncHandle, int asyncError, String text) {
IAsyncRPCEvent callback = getCallback(asyncHandle);
if (callback != null) {
callback.onRPCError(asyncHandle, asyncError, text);
}
} | [
"protected",
"void",
"onRPCError",
"(",
"int",
"asyncHandle",
",",
"int",
"asyncError",
",",
"String",
"text",
")",
"{",
"IAsyncRPCEvent",
"callback",
"=",
"getCallback",
"(",
"asyncHandle",
")",
";",
"if",
"(",
"callback",
"!=",
"null",
")",
"{",
"callback"... | Invokes the callback for the specified handle when an error is encountered during an
asynchronous RPC call.
@param asyncHandle The unique handle for the asynchronous RPC call.
@param asyncError The error code.
@param text The error text. | [
"Invokes",
"the",
"callback",
"for",
"the",
"specified",
"handle",
"when",
"an",
"error",
"is",
"encountered",
"during",
"an",
"asynchronous",
"RPC",
"call",
"."
] | train | https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.mbroker/src/main/java/org/carewebframework/vista/mbroker/BrokerSession.java#L666-L672 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.