repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
sequencelengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
sequencelengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/ObjectExtensions.java | ObjectExtensions.operator_doubleArrow | public static <T> T operator_doubleArrow(T object, Procedure1<? super T> block) {
"""
The <code>doubleArrow</code> operator is used as a 'with'- or 'let'-operation.
It allows to bind an object to a local scope in order to do something on it.
Example:
<code>
new Person => [
firstName = 'Han'
lastName = 'Solo'
]
</code>
@param object
an object. Can be <code>null</code>.
@param block
the block to execute with the given object. Must not be <code>null</code>.
@return the reference to object.
@since 2.3
"""
block.apply(object);
return object;
} | java | public static <T> T operator_doubleArrow(T object, Procedure1<? super T> block) {
block.apply(object);
return object;
} | [
"public",
"static",
"<",
"T",
">",
"T",
"operator_doubleArrow",
"(",
"T",
"object",
",",
"Procedure1",
"<",
"?",
"super",
"T",
">",
"block",
")",
"{",
"block",
".",
"apply",
"(",
"object",
")",
";",
"return",
"object",
";",
"}"
] | The <code>doubleArrow</code> operator is used as a 'with'- or 'let'-operation.
It allows to bind an object to a local scope in order to do something on it.
Example:
<code>
new Person => [
firstName = 'Han'
lastName = 'Solo'
]
</code>
@param object
an object. Can be <code>null</code>.
@param block
the block to execute with the given object. Must not be <code>null</code>.
@return the reference to object.
@since 2.3 | [
"The",
"<code",
">",
"doubleArrow<",
"/",
"code",
">",
"operator",
"is",
"used",
"as",
"a",
"with",
"-",
"or",
"let",
"-",
"operation",
".",
"It",
"allows",
"to",
"bind",
"an",
"object",
"to",
"a",
"local",
"scope",
"in",
"order",
"to",
"do",
"something",
"on",
"it",
"."
] | train | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/ObjectExtensions.java#L138-L141 |
UrielCh/ovh-java-sdk | ovh-java-sdk-caascontainers/src/main/java/net/minidev/ovh/api/ApiOvhCaascontainers.java | ApiOvhCaascontainers.serviceName_registry_credentials_credentialsId_DELETE | public void serviceName_registry_credentials_credentialsId_DELETE(String serviceName, String credentialsId) throws IOException {
"""
Delete the registry credentials.
REST: DELETE /caas/containers/{serviceName}/registry/credentials/{credentialsId}
@param credentialsId [required] credentials id
@param serviceName [required] service name
API beta
"""
String qPath = "/caas/containers/{serviceName}/registry/credentials/{credentialsId}";
StringBuilder sb = path(qPath, serviceName, credentialsId);
exec(qPath, "DELETE", sb.toString(), null);
} | java | public void serviceName_registry_credentials_credentialsId_DELETE(String serviceName, String credentialsId) throws IOException {
String qPath = "/caas/containers/{serviceName}/registry/credentials/{credentialsId}";
StringBuilder sb = path(qPath, serviceName, credentialsId);
exec(qPath, "DELETE", sb.toString(), null);
} | [
"public",
"void",
"serviceName_registry_credentials_credentialsId_DELETE",
"(",
"String",
"serviceName",
",",
"String",
"credentialsId",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/caas/containers/{serviceName}/registry/credentials/{credentialsId}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"credentialsId",
")",
";",
"exec",
"(",
"qPath",
",",
"\"DELETE\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"}"
] | Delete the registry credentials.
REST: DELETE /caas/containers/{serviceName}/registry/credentials/{credentialsId}
@param credentialsId [required] credentials id
@param serviceName [required] service name
API beta | [
"Delete",
"the",
"registry",
"credentials",
"."
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-caascontainers/src/main/java/net/minidev/ovh/api/ApiOvhCaascontainers.java#L311-L315 |
aws/aws-sdk-java | aws-java-sdk-amplify/src/main/java/com/amazonaws/services/amplify/model/UpdateAppRequest.java | UpdateAppRequest.withEnvironmentVariables | public UpdateAppRequest withEnvironmentVariables(java.util.Map<String, String> environmentVariables) {
"""
<p>
Environment Variables for an Amplify App.
</p>
@param environmentVariables
Environment Variables for an Amplify App.
@return Returns a reference to this object so that method calls can be chained together.
"""
setEnvironmentVariables(environmentVariables);
return this;
} | java | public UpdateAppRequest withEnvironmentVariables(java.util.Map<String, String> environmentVariables) {
setEnvironmentVariables(environmentVariables);
return this;
} | [
"public",
"UpdateAppRequest",
"withEnvironmentVariables",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"environmentVariables",
")",
"{",
"setEnvironmentVariables",
"(",
"environmentVariables",
")",
";",
"return",
"this",
";",
"}"
] | <p>
Environment Variables for an Amplify App.
</p>
@param environmentVariables
Environment Variables for an Amplify App.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"Environment",
"Variables",
"for",
"an",
"Amplify",
"App",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-amplify/src/main/java/com/amazonaws/services/amplify/model/UpdateAppRequest.java#L352-L355 |
salesforce/Argus | ArgusCore/src/main/java/com/salesforce/dva/argus/entity/Notification.java | Notification.getMetricToAnnotate | public static Metric getMetricToAnnotate(String metric) {
"""
Given a metric to annotate expression, return a corresponding metric object.
@param metric The metric to annotate expression.
@return The corresponding metric or null if the metric to annotate expression is invalid.
"""
Metric result = null;
if (metric != null && !metric.isEmpty()) {
Pattern pattern = Pattern.compile(
"([\\w,\\-,\\.,/]+):([\\w,\\-,\\.,/]+)(\\{(?:[\\w,\\-,\\.,/]+=[\\w,\\-,\\.,/,\\*,|]+)(?:,[\\w,\\-,\\.,/]+=[\\w,\\-,\\.,/,\\*,|]+)*\\})?:([\\w,\\-,\\.,/]+)");
Matcher matcher = pattern.matcher(metric.replaceAll("\\s", ""));
if (matcher.matches()) {
String scopeName = matcher.group(1);
String metricName = matcher.group(2);
String tagString = matcher.group(3);
Map<String, String> tags = new HashMap<>();
if (tagString != null) {
tagString = tagString.replaceAll("\\{", "").replaceAll("\\}", "");
for (String tag : tagString.split(",")) {
String[] entry = tag.split("=");
tags.put(entry[0], entry[1]);
}
}
result = new Metric(scopeName, metricName);
result.setTags(tags);
}
}
return result;
} | java | public static Metric getMetricToAnnotate(String metric) {
Metric result = null;
if (metric != null && !metric.isEmpty()) {
Pattern pattern = Pattern.compile(
"([\\w,\\-,\\.,/]+):([\\w,\\-,\\.,/]+)(\\{(?:[\\w,\\-,\\.,/]+=[\\w,\\-,\\.,/,\\*,|]+)(?:,[\\w,\\-,\\.,/]+=[\\w,\\-,\\.,/,\\*,|]+)*\\})?:([\\w,\\-,\\.,/]+)");
Matcher matcher = pattern.matcher(metric.replaceAll("\\s", ""));
if (matcher.matches()) {
String scopeName = matcher.group(1);
String metricName = matcher.group(2);
String tagString = matcher.group(3);
Map<String, String> tags = new HashMap<>();
if (tagString != null) {
tagString = tagString.replaceAll("\\{", "").replaceAll("\\}", "");
for (String tag : tagString.split(",")) {
String[] entry = tag.split("=");
tags.put(entry[0], entry[1]);
}
}
result = new Metric(scopeName, metricName);
result.setTags(tags);
}
}
return result;
} | [
"public",
"static",
"Metric",
"getMetricToAnnotate",
"(",
"String",
"metric",
")",
"{",
"Metric",
"result",
"=",
"null",
";",
"if",
"(",
"metric",
"!=",
"null",
"&&",
"!",
"metric",
".",
"isEmpty",
"(",
")",
")",
"{",
"Pattern",
"pattern",
"=",
"Pattern",
".",
"compile",
"(",
"\"([\\\\w,\\\\-,\\\\.,/]+):([\\\\w,\\\\-,\\\\.,/]+)(\\\\{(?:[\\\\w,\\\\-,\\\\.,/]+=[\\\\w,\\\\-,\\\\.,/,\\\\*,|]+)(?:,[\\\\w,\\\\-,\\\\.,/]+=[\\\\w,\\\\-,\\\\.,/,\\\\*,|]+)*\\\\})?:([\\\\w,\\\\-,\\\\.,/]+)\"",
")",
";",
"Matcher",
"matcher",
"=",
"pattern",
".",
"matcher",
"(",
"metric",
".",
"replaceAll",
"(",
"\"\\\\s\"",
",",
"\"\"",
")",
")",
";",
"if",
"(",
"matcher",
".",
"matches",
"(",
")",
")",
"{",
"String",
"scopeName",
"=",
"matcher",
".",
"group",
"(",
"1",
")",
";",
"String",
"metricName",
"=",
"matcher",
".",
"group",
"(",
"2",
")",
";",
"String",
"tagString",
"=",
"matcher",
".",
"group",
"(",
"3",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"tags",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"if",
"(",
"tagString",
"!=",
"null",
")",
"{",
"tagString",
"=",
"tagString",
".",
"replaceAll",
"(",
"\"\\\\{\"",
",",
"\"\"",
")",
".",
"replaceAll",
"(",
"\"\\\\}\"",
",",
"\"\"",
")",
";",
"for",
"(",
"String",
"tag",
":",
"tagString",
".",
"split",
"(",
"\",\"",
")",
")",
"{",
"String",
"[",
"]",
"entry",
"=",
"tag",
".",
"split",
"(",
"\"=\"",
")",
";",
"tags",
".",
"put",
"(",
"entry",
"[",
"0",
"]",
",",
"entry",
"[",
"1",
"]",
")",
";",
"}",
"}",
"result",
"=",
"new",
"Metric",
"(",
"scopeName",
",",
"metricName",
")",
";",
"result",
".",
"setTags",
"(",
"tags",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | Given a metric to annotate expression, return a corresponding metric object.
@param metric The metric to annotate expression.
@return The corresponding metric or null if the metric to annotate expression is invalid. | [
"Given",
"a",
"metric",
"to",
"annotate",
"expression",
"return",
"a",
"corresponding",
"metric",
"object",
"."
] | train | https://github.com/salesforce/Argus/blob/121b59a268da264316cded6a3e9271366a23cd86/ArgusCore/src/main/java/com/salesforce/dva/argus/entity/Notification.java#L367-L394 |
riversun/finbin | src/main/java/org/riversun/finbin/BinarySearcher.java | BinarySearcher.indexOf | public int indexOf(byte[] srcBytes, byte[] searchBytes, int startIndex) {
"""
Returns the index within this byte-array of the first occurrence of the
specified(search bytes) byte array.<br>
Starting the search at the specified index<br>
@param srcBytes
@param searchBytes
@param startIndex
@return
"""
final int endIndex = srcBytes.length - 1;
return indexOf(srcBytes, searchBytes, startIndex, endIndex);
} | java | public int indexOf(byte[] srcBytes, byte[] searchBytes, int startIndex) {
final int endIndex = srcBytes.length - 1;
return indexOf(srcBytes, searchBytes, startIndex, endIndex);
} | [
"public",
"int",
"indexOf",
"(",
"byte",
"[",
"]",
"srcBytes",
",",
"byte",
"[",
"]",
"searchBytes",
",",
"int",
"startIndex",
")",
"{",
"final",
"int",
"endIndex",
"=",
"srcBytes",
".",
"length",
"-",
"1",
";",
"return",
"indexOf",
"(",
"srcBytes",
",",
"searchBytes",
",",
"startIndex",
",",
"endIndex",
")",
";",
"}"
] | Returns the index within this byte-array of the first occurrence of the
specified(search bytes) byte array.<br>
Starting the search at the specified index<br>
@param srcBytes
@param searchBytes
@param startIndex
@return | [
"Returns",
"the",
"index",
"within",
"this",
"byte",
"-",
"array",
"of",
"the",
"first",
"occurrence",
"of",
"the",
"specified",
"(",
"search",
"bytes",
")",
"byte",
"array",
".",
"<br",
">",
"Starting",
"the",
"search",
"at",
"the",
"specified",
"index<br",
">"
] | train | https://github.com/riversun/finbin/blob/d1db86a0d2966dcf47087340bbd0727a9d508b3e/src/main/java/org/riversun/finbin/BinarySearcher.java#L65-L68 |
Azure/azure-sdk-for-java | containerregistry/resource-manager/v2018_02_01_preview/src/main/java/com/microsoft/azure/management/containerregistry/v2018_02_01_preview/implementation/BuildStepsInner.java | BuildStepsInner.updateAsync | public Observable<BuildStepInner> updateAsync(String resourceGroupName, String registryName, String buildTaskName, String stepName, BuildStepUpdateParameters buildStepUpdateParameters) {
"""
Updates a build step in a build task.
@param resourceGroupName The name of the resource group to which the container registry belongs.
@param registryName The name of the container registry.
@param buildTaskName The name of the container registry build task.
@param stepName The name of a build step for a container registry build task.
@param buildStepUpdateParameters The parameters for updating a build step.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request
"""
return updateWithServiceResponseAsync(resourceGroupName, registryName, buildTaskName, stepName, buildStepUpdateParameters).map(new Func1<ServiceResponse<BuildStepInner>, BuildStepInner>() {
@Override
public BuildStepInner call(ServiceResponse<BuildStepInner> response) {
return response.body();
}
});
} | java | public Observable<BuildStepInner> updateAsync(String resourceGroupName, String registryName, String buildTaskName, String stepName, BuildStepUpdateParameters buildStepUpdateParameters) {
return updateWithServiceResponseAsync(resourceGroupName, registryName, buildTaskName, stepName, buildStepUpdateParameters).map(new Func1<ServiceResponse<BuildStepInner>, BuildStepInner>() {
@Override
public BuildStepInner call(ServiceResponse<BuildStepInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"BuildStepInner",
">",
"updateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"registryName",
",",
"String",
"buildTaskName",
",",
"String",
"stepName",
",",
"BuildStepUpdateParameters",
"buildStepUpdateParameters",
")",
"{",
"return",
"updateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"registryName",
",",
"buildTaskName",
",",
"stepName",
",",
"buildStepUpdateParameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"BuildStepInner",
">",
",",
"BuildStepInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"BuildStepInner",
"call",
"(",
"ServiceResponse",
"<",
"BuildStepInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Updates a build step in a build task.
@param resourceGroupName The name of the resource group to which the container registry belongs.
@param registryName The name of the container registry.
@param buildTaskName The name of the container registry build task.
@param stepName The name of a build step for a container registry build task.
@param buildStepUpdateParameters The parameters for updating a build step.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Updates",
"a",
"build",
"step",
"in",
"a",
"build",
"task",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/containerregistry/resource-manager/v2018_02_01_preview/src/main/java/com/microsoft/azure/management/containerregistry/v2018_02_01_preview/implementation/BuildStepsInner.java#L934-L941 |
Azure/azure-sdk-for-java | marketplaceordering/resource-manager/v2015_06_01/src/main/java/com/microsoft/azure/management/marketplaceordering/v2015_06_01/implementation/MarketplaceAgreementsInner.java | MarketplaceAgreementsInner.getAgreementAsync | public Observable<AgreementTermsInner> getAgreementAsync(String publisherId, String offerId, String planId) {
"""
Get marketplace agreement.
@param publisherId Publisher identifier string of image being deployed.
@param offerId Offer identifier string of image being deployed.
@param planId Plan identifier string of image being deployed.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the AgreementTermsInner object
"""
return getAgreementWithServiceResponseAsync(publisherId, offerId, planId).map(new Func1<ServiceResponse<AgreementTermsInner>, AgreementTermsInner>() {
@Override
public AgreementTermsInner call(ServiceResponse<AgreementTermsInner> response) {
return response.body();
}
});
} | java | public Observable<AgreementTermsInner> getAgreementAsync(String publisherId, String offerId, String planId) {
return getAgreementWithServiceResponseAsync(publisherId, offerId, planId).map(new Func1<ServiceResponse<AgreementTermsInner>, AgreementTermsInner>() {
@Override
public AgreementTermsInner call(ServiceResponse<AgreementTermsInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"AgreementTermsInner",
">",
"getAgreementAsync",
"(",
"String",
"publisherId",
",",
"String",
"offerId",
",",
"String",
"planId",
")",
"{",
"return",
"getAgreementWithServiceResponseAsync",
"(",
"publisherId",
",",
"offerId",
",",
"planId",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"AgreementTermsInner",
">",
",",
"AgreementTermsInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"AgreementTermsInner",
"call",
"(",
"ServiceResponse",
"<",
"AgreementTermsInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Get marketplace agreement.
@param publisherId Publisher identifier string of image being deployed.
@param offerId Offer identifier string of image being deployed.
@param planId Plan identifier string of image being deployed.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the AgreementTermsInner object | [
"Get",
"marketplace",
"agreement",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/marketplaceordering/resource-manager/v2015_06_01/src/main/java/com/microsoft/azure/management/marketplaceordering/v2015_06_01/implementation/MarketplaceAgreementsInner.java#L508-L515 |
google/identity-toolkit-java-client | src/main/java/com/google/identitytoolkit/GitkitClient.java | GitkitClient.verifyPassword | public GitkitUser verifyPassword(String email, String password)
throws GitkitClientException, GitkitServerException {
"""
Verifies the user entered password at Gitkit server.
@param email The email of the user
@param password The password inputed by the user
@return Gitkit user if password is valid.
@throws GitkitClientException for invalid request
@throws GitkitServerException for server error
"""
return verifyPassword(email, password, null, null);
} | java | public GitkitUser verifyPassword(String email, String password)
throws GitkitClientException, GitkitServerException {
return verifyPassword(email, password, null, null);
} | [
"public",
"GitkitUser",
"verifyPassword",
"(",
"String",
"email",
",",
"String",
"password",
")",
"throws",
"GitkitClientException",
",",
"GitkitServerException",
"{",
"return",
"verifyPassword",
"(",
"email",
",",
"password",
",",
"null",
",",
"null",
")",
";",
"}"
] | Verifies the user entered password at Gitkit server.
@param email The email of the user
@param password The password inputed by the user
@return Gitkit user if password is valid.
@throws GitkitClientException for invalid request
@throws GitkitServerException for server error | [
"Verifies",
"the",
"user",
"entered",
"password",
"at",
"Gitkit",
"server",
"."
] | train | https://github.com/google/identity-toolkit-java-client/blob/61dda1aabbd541ad5e431e840fd266bfca5f8a4a/src/main/java/com/google/identitytoolkit/GitkitClient.java#L250-L253 |
netscaler/nitro | src/main/java/com/citrix/netscaler/nitro/resource/config/appfw/appfwhtmlerrorpage.java | appfwhtmlerrorpage.get | public static appfwhtmlerrorpage get(nitro_service service, options option) throws Exception {
"""
Use this API to fetch all the appfwhtmlerrorpage resources that are configured on netscaler.
"""
appfwhtmlerrorpage obj = new appfwhtmlerrorpage();
appfwhtmlerrorpage[] response = (appfwhtmlerrorpage[])obj.get_resources(service,option);
return response[0];
} | java | public static appfwhtmlerrorpage get(nitro_service service, options option) throws Exception{
appfwhtmlerrorpage obj = new appfwhtmlerrorpage();
appfwhtmlerrorpage[] response = (appfwhtmlerrorpage[])obj.get_resources(service,option);
return response[0];
} | [
"public",
"static",
"appfwhtmlerrorpage",
"get",
"(",
"nitro_service",
"service",
",",
"options",
"option",
")",
"throws",
"Exception",
"{",
"appfwhtmlerrorpage",
"obj",
"=",
"new",
"appfwhtmlerrorpage",
"(",
")",
";",
"appfwhtmlerrorpage",
"[",
"]",
"response",
"=",
"(",
"appfwhtmlerrorpage",
"[",
"]",
")",
"obj",
".",
"get_resources",
"(",
"service",
",",
"option",
")",
";",
"return",
"response",
"[",
"0",
"]",
";",
"}"
] | Use this API to fetch all the appfwhtmlerrorpage resources that are configured on netscaler. | [
"Use",
"this",
"API",
"to",
"fetch",
"all",
"the",
"appfwhtmlerrorpage",
"resources",
"that",
"are",
"configured",
"on",
"netscaler",
"."
] | train | https://github.com/netscaler/nitro/blob/2a98692dcf4e4ec430c7d7baab8382e4ba5a35e4/src/main/java/com/citrix/netscaler/nitro/resource/config/appfw/appfwhtmlerrorpage.java#L125-L129 |
maven-nar/nar-maven-plugin | src/main/java/com/github/maven_nar/cpptasks/DependencyTable.java | DependencyTable.getDependencyInfo | public DependencyInfo getDependencyInfo(final String sourceRelativeName, final String includePathIdentifier) {
"""
This method returns a DependencyInfo for the specific source file and
include path identifier
"""
DependencyInfo dependInfo = null;
final DependencyInfo[] dependInfos = (DependencyInfo[]) this.dependencies.get(sourceRelativeName);
if (dependInfos != null) {
for (final DependencyInfo dependInfo2 : dependInfos) {
dependInfo = dependInfo2;
if (dependInfo.getIncludePathIdentifier().equals(includePathIdentifier)) {
return dependInfo;
}
}
}
return null;
} | java | public DependencyInfo getDependencyInfo(final String sourceRelativeName, final String includePathIdentifier) {
DependencyInfo dependInfo = null;
final DependencyInfo[] dependInfos = (DependencyInfo[]) this.dependencies.get(sourceRelativeName);
if (dependInfos != null) {
for (final DependencyInfo dependInfo2 : dependInfos) {
dependInfo = dependInfo2;
if (dependInfo.getIncludePathIdentifier().equals(includePathIdentifier)) {
return dependInfo;
}
}
}
return null;
} | [
"public",
"DependencyInfo",
"getDependencyInfo",
"(",
"final",
"String",
"sourceRelativeName",
",",
"final",
"String",
"includePathIdentifier",
")",
"{",
"DependencyInfo",
"dependInfo",
"=",
"null",
";",
"final",
"DependencyInfo",
"[",
"]",
"dependInfos",
"=",
"(",
"DependencyInfo",
"[",
"]",
")",
"this",
".",
"dependencies",
".",
"get",
"(",
"sourceRelativeName",
")",
";",
"if",
"(",
"dependInfos",
"!=",
"null",
")",
"{",
"for",
"(",
"final",
"DependencyInfo",
"dependInfo2",
":",
"dependInfos",
")",
"{",
"dependInfo",
"=",
"dependInfo2",
";",
"if",
"(",
"dependInfo",
".",
"getIncludePathIdentifier",
"(",
")",
".",
"equals",
"(",
"includePathIdentifier",
")",
")",
"{",
"return",
"dependInfo",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] | This method returns a DependencyInfo for the specific source file and
include path identifier | [
"This",
"method",
"returns",
"a",
"DependencyInfo",
"for",
"the",
"specific",
"source",
"file",
"and",
"include",
"path",
"identifier"
] | train | https://github.com/maven-nar/nar-maven-plugin/blob/3c622e2024296b4203431bbae3bde290a01dac00/src/main/java/com/github/maven_nar/cpptasks/DependencyTable.java#L350-L362 |
line/armeria | grpc/src/main/java/com/linecorp/armeria/unsafe/grpc/GrpcUnsafeBufferUtil.java | GrpcUnsafeBufferUtil.releaseBuffer | public static void releaseBuffer(Object message, RequestContext ctx) {
"""
Releases the {@link ByteBuf} backing the provided {@link Message}.
"""
final IdentityHashMap<Object, ByteBuf> buffers = ctx.attr(BUFFERS).get();
checkState(buffers != null,
"Releasing buffer even though storeBuffer has not been called.");
final ByteBuf removed = buffers.remove(message);
if (removed == null) {
throw new IllegalArgumentException("The provided message does not have a stored buffer.");
}
removed.release();
} | java | public static void releaseBuffer(Object message, RequestContext ctx) {
final IdentityHashMap<Object, ByteBuf> buffers = ctx.attr(BUFFERS).get();
checkState(buffers != null,
"Releasing buffer even though storeBuffer has not been called.");
final ByteBuf removed = buffers.remove(message);
if (removed == null) {
throw new IllegalArgumentException("The provided message does not have a stored buffer.");
}
removed.release();
} | [
"public",
"static",
"void",
"releaseBuffer",
"(",
"Object",
"message",
",",
"RequestContext",
"ctx",
")",
"{",
"final",
"IdentityHashMap",
"<",
"Object",
",",
"ByteBuf",
">",
"buffers",
"=",
"ctx",
".",
"attr",
"(",
"BUFFERS",
")",
".",
"get",
"(",
")",
";",
"checkState",
"(",
"buffers",
"!=",
"null",
",",
"\"Releasing buffer even though storeBuffer has not been called.\"",
")",
";",
"final",
"ByteBuf",
"removed",
"=",
"buffers",
".",
"remove",
"(",
"message",
")",
";",
"if",
"(",
"removed",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The provided message does not have a stored buffer.\"",
")",
";",
"}",
"removed",
".",
"release",
"(",
")",
";",
"}"
] | Releases the {@link ByteBuf} backing the provided {@link Message}. | [
"Releases",
"the",
"{"
] | train | https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/grpc/src/main/java/com/linecorp/armeria/unsafe/grpc/GrpcUnsafeBufferUtil.java#L53-L62 |
box/box-java-sdk | src/main/java/com/box/sdk/BoxFolder.java | BoxFolder.uploadFile | public BoxFile.Info uploadFile(UploadFileCallback callback, String name) {
"""
Uploads a new file to this folder.
@param callback the callback which allows file content to be written on output stream.
@param name the name to give the uploaded file.
@return the uploaded file's info.
"""
FileUploadParams uploadInfo = new FileUploadParams()
.setUploadFileCallback(callback)
.setName(name);
return this.uploadFile(uploadInfo);
} | java | public BoxFile.Info uploadFile(UploadFileCallback callback, String name) {
FileUploadParams uploadInfo = new FileUploadParams()
.setUploadFileCallback(callback)
.setName(name);
return this.uploadFile(uploadInfo);
} | [
"public",
"BoxFile",
".",
"Info",
"uploadFile",
"(",
"UploadFileCallback",
"callback",
",",
"String",
"name",
")",
"{",
"FileUploadParams",
"uploadInfo",
"=",
"new",
"FileUploadParams",
"(",
")",
".",
"setUploadFileCallback",
"(",
"callback",
")",
".",
"setName",
"(",
"name",
")",
";",
"return",
"this",
".",
"uploadFile",
"(",
"uploadInfo",
")",
";",
"}"
] | Uploads a new file to this folder.
@param callback the callback which allows file content to be written on output stream.
@param name the name to give the uploaded file.
@return the uploaded file's info. | [
"Uploads",
"a",
"new",
"file",
"to",
"this",
"folder",
"."
] | train | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L466-L471 |
Talend/tesb-rt-se | examples/cxf/jaxrs-attachments/service/src/main/java/service/attachment/MultipartsServiceImpl.java | MultipartsServiceImpl.duplicateMultipartBody | private MultipartBody duplicateMultipartBody(MultipartBody body) {
"""
Verifies the MultipartBody by reading the individual parts
and copying them to a new MultipartBody instance which
will be written out in the multipart/mixed format.
@param body the incoming MultipartBody
@return new MultipartBody
"""
// It is possible to access individual parts by the Content-Id values
// This MultipartBody is expected to contain 3 parts,
// "book1", "book2" and "image".
// These individual parts have their Content-Type set to
// application/xml, application/json and application/octet-stream
// MultipartBody will use the Content-Type value of the individual
// part to read its data in a type safe way by delegating to a matching
// JAX-RS MessageBodyReader provider
Book jaxbBook = body.getAttachmentObject("book1", Book.class);
Book jsonBook = body.getAttachmentObject("book2", Book.class);
// Accessing individual attachment part, its DataHandler will be
// used to access the underlying input stream, the type-safe access
// is also possible
Attachment imageAtt = body.getAttachment("image");
if ("JAXB".equals(jaxbBook.getName()) && 1L == jaxbBook.getId()
&& "JSON".equals(jsonBook.getName()) && 2L == jsonBook.getId()
&& imageAtt != null) {
return createMultipartBody(jaxbBook, jsonBook, imageAtt.getDataHandler());
}
throw new RuntimeException("Received Book attachment is corrupted");
} | java | private MultipartBody duplicateMultipartBody(MultipartBody body) {
// It is possible to access individual parts by the Content-Id values
// This MultipartBody is expected to contain 3 parts,
// "book1", "book2" and "image".
// These individual parts have their Content-Type set to
// application/xml, application/json and application/octet-stream
// MultipartBody will use the Content-Type value of the individual
// part to read its data in a type safe way by delegating to a matching
// JAX-RS MessageBodyReader provider
Book jaxbBook = body.getAttachmentObject("book1", Book.class);
Book jsonBook = body.getAttachmentObject("book2", Book.class);
// Accessing individual attachment part, its DataHandler will be
// used to access the underlying input stream, the type-safe access
// is also possible
Attachment imageAtt = body.getAttachment("image");
if ("JAXB".equals(jaxbBook.getName()) && 1L == jaxbBook.getId()
&& "JSON".equals(jsonBook.getName()) && 2L == jsonBook.getId()
&& imageAtt != null) {
return createMultipartBody(jaxbBook, jsonBook, imageAtt.getDataHandler());
}
throw new RuntimeException("Received Book attachment is corrupted");
} | [
"private",
"MultipartBody",
"duplicateMultipartBody",
"(",
"MultipartBody",
"body",
")",
"{",
"// It is possible to access individual parts by the Content-Id values",
"// This MultipartBody is expected to contain 3 parts, ",
"// \"book1\", \"book2\" and \"image\". ",
"// These individual parts have their Content-Type set to ",
"// application/xml, application/json and application/octet-stream",
"// MultipartBody will use the Content-Type value of the individual",
"// part to read its data in a type safe way by delegating to a matching ",
"// JAX-RS MessageBodyReader provider",
"Book",
"jaxbBook",
"=",
"body",
".",
"getAttachmentObject",
"(",
"\"book1\"",
",",
"Book",
".",
"class",
")",
";",
"Book",
"jsonBook",
"=",
"body",
".",
"getAttachmentObject",
"(",
"\"book2\"",
",",
"Book",
".",
"class",
")",
";",
"// Accessing individual attachment part, its DataHandler will be ",
"// used to access the underlying input stream, the type-safe access",
"// is also possible",
"Attachment",
"imageAtt",
"=",
"body",
".",
"getAttachment",
"(",
"\"image\"",
")",
";",
"if",
"(",
"\"JAXB\"",
".",
"equals",
"(",
"jaxbBook",
".",
"getName",
"(",
")",
")",
"&&",
"1L",
"==",
"jaxbBook",
".",
"getId",
"(",
")",
"&&",
"\"JSON\"",
".",
"equals",
"(",
"jsonBook",
".",
"getName",
"(",
")",
")",
"&&",
"2L",
"==",
"jsonBook",
".",
"getId",
"(",
")",
"&&",
"imageAtt",
"!=",
"null",
")",
"{",
"return",
"createMultipartBody",
"(",
"jaxbBook",
",",
"jsonBook",
",",
"imageAtt",
".",
"getDataHandler",
"(",
")",
")",
";",
"}",
"throw",
"new",
"RuntimeException",
"(",
"\"Received Book attachment is corrupted\"",
")",
";",
"}"
] | Verifies the MultipartBody by reading the individual parts
and copying them to a new MultipartBody instance which
will be written out in the multipart/mixed format.
@param body the incoming MultipartBody
@return new MultipartBody | [
"Verifies",
"the",
"MultipartBody",
"by",
"reading",
"the",
"individual",
"parts",
"and",
"copying",
"them",
"to",
"a",
"new",
"MultipartBody",
"instance",
"which",
"will",
"be",
"written",
"out",
"in",
"the",
"multipart",
"/",
"mixed",
"format",
"."
] | train | https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/examples/cxf/jaxrs-attachments/service/src/main/java/service/attachment/MultipartsServiceImpl.java#L38-L66 |
drapostolos/type-parser | src/main/java/com/github/drapostolos/typeparser/TypeParserBuilder.java | TypeParserBuilder.registerParser | public <T> TypeParserBuilder registerParser(Class<T> targetType, Parser<T> parser) {
"""
Register a custom made {@link Parser} implementation, associated with
the given {@code targetType}.
@param targetType associated with given {@code parser}.
@param parser custom made {@link Parser} implementation.
@return {@link TypeParserBuilder}
@throws NullPointerException if any given argument is null.
"""
if (parser == null) {
throw new NullPointerException(makeNullArgumentErrorMsg("parser"));
}
if (targetType == null) {
throw new NullPointerException(makeNullArgumentErrorMsg("targetType"));
}
if (targetType.isArray()) {
String message = "Cannot register Parser for array class. Register a Parser for "
+ "the component type '%s' instead, as arrays are handled automatically "
+ "internally in type-parser.";
Class<?> componentType = targetType.getComponentType();
throw new IllegalArgumentException(String.format(message, componentType.getName()));
}
parsers.put(targetType, decorateParser(targetType, parser));
return this;
} | java | public <T> TypeParserBuilder registerParser(Class<T> targetType, Parser<T> parser) {
if (parser == null) {
throw new NullPointerException(makeNullArgumentErrorMsg("parser"));
}
if (targetType == null) {
throw new NullPointerException(makeNullArgumentErrorMsg("targetType"));
}
if (targetType.isArray()) {
String message = "Cannot register Parser for array class. Register a Parser for "
+ "the component type '%s' instead, as arrays are handled automatically "
+ "internally in type-parser.";
Class<?> componentType = targetType.getComponentType();
throw new IllegalArgumentException(String.format(message, componentType.getName()));
}
parsers.put(targetType, decorateParser(targetType, parser));
return this;
} | [
"public",
"<",
"T",
">",
"TypeParserBuilder",
"registerParser",
"(",
"Class",
"<",
"T",
">",
"targetType",
",",
"Parser",
"<",
"T",
">",
"parser",
")",
"{",
"if",
"(",
"parser",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"makeNullArgumentErrorMsg",
"(",
"\"parser\"",
")",
")",
";",
"}",
"if",
"(",
"targetType",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"makeNullArgumentErrorMsg",
"(",
"\"targetType\"",
")",
")",
";",
"}",
"if",
"(",
"targetType",
".",
"isArray",
"(",
")",
")",
"{",
"String",
"message",
"=",
"\"Cannot register Parser for array class. Register a Parser for \"",
"+",
"\"the component type '%s' instead, as arrays are handled automatically \"",
"+",
"\"internally in type-parser.\"",
";",
"Class",
"<",
"?",
">",
"componentType",
"=",
"targetType",
".",
"getComponentType",
"(",
")",
";",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"message",
",",
"componentType",
".",
"getName",
"(",
")",
")",
")",
";",
"}",
"parsers",
".",
"put",
"(",
"targetType",
",",
"decorateParser",
"(",
"targetType",
",",
"parser",
")",
")",
";",
"return",
"this",
";",
"}"
] | Register a custom made {@link Parser} implementation, associated with
the given {@code targetType}.
@param targetType associated with given {@code parser}.
@param parser custom made {@link Parser} implementation.
@return {@link TypeParserBuilder}
@throws NullPointerException if any given argument is null. | [
"Register",
"a",
"custom",
"made",
"{",
"@link",
"Parser",
"}",
"implementation",
"associated",
"with",
"the",
"given",
"{",
"@code",
"targetType",
"}",
"."
] | train | https://github.com/drapostolos/type-parser/blob/74c66311f8dd009897c74ab5069e36c045cda073/src/main/java/com/github/drapostolos/typeparser/TypeParserBuilder.java#L62-L78 |
GenesysPureEngage/workspace-client-java | src/main/java/com/genesys/internal/workspace/api/VoiceApi.java | VoiceApi.setFocusTimeCall | public ApiSuccessResponse setFocusTimeCall(String id, SetFocusTimeData setFocusTimeData) throws ApiException {
"""
Set the focus time of call
Set the focus time to the specified call.
@param id The connection ID of the call. (required)
@param setFocusTimeData Request parameters. (required)
@return ApiSuccessResponse
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
"""
ApiResponse<ApiSuccessResponse> resp = setFocusTimeCallWithHttpInfo(id, setFocusTimeData);
return resp.getData();
} | java | public ApiSuccessResponse setFocusTimeCall(String id, SetFocusTimeData setFocusTimeData) throws ApiException {
ApiResponse<ApiSuccessResponse> resp = setFocusTimeCallWithHttpInfo(id, setFocusTimeData);
return resp.getData();
} | [
"public",
"ApiSuccessResponse",
"setFocusTimeCall",
"(",
"String",
"id",
",",
"SetFocusTimeData",
"setFocusTimeData",
")",
"throws",
"ApiException",
"{",
"ApiResponse",
"<",
"ApiSuccessResponse",
">",
"resp",
"=",
"setFocusTimeCallWithHttpInfo",
"(",
"id",
",",
"setFocusTimeData",
")",
";",
"return",
"resp",
".",
"getData",
"(",
")",
";",
"}"
] | Set the focus time of call
Set the focus time to the specified call.
@param id The connection ID of the call. (required)
@param setFocusTimeData Request parameters. (required)
@return ApiSuccessResponse
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body | [
"Set",
"the",
"focus",
"time",
"of",
"call",
"Set",
"the",
"focus",
"time",
"to",
"the",
"specified",
"call",
"."
] | train | https://github.com/GenesysPureEngage/workspace-client-java/blob/509fdd9e89b9359d012f9a72be95037a3cef53e6/src/main/java/com/genesys/internal/workspace/api/VoiceApi.java#L4083-L4086 |
google/error-prone-javac | src/jdk.compiler/share/classes/com/sun/tools/javac/util/AbstractLog.java | AbstractLog.mandatoryNote | public void mandatoryNote(final JavaFileObject file, Note noteKey) {
"""
Provide a non-fatal notification, unless suppressed by the -nowarn option.
@param noteKey The key for the localized notification message.
"""
report(diags.mandatoryNote(getSource(file), noteKey));
} | java | public void mandatoryNote(final JavaFileObject file, Note noteKey) {
report(diags.mandatoryNote(getSource(file), noteKey));
} | [
"public",
"void",
"mandatoryNote",
"(",
"final",
"JavaFileObject",
"file",
",",
"Note",
"noteKey",
")",
"{",
"report",
"(",
"diags",
".",
"mandatoryNote",
"(",
"getSource",
"(",
"file",
")",
",",
"noteKey",
")",
")",
";",
"}"
] | Provide a non-fatal notification, unless suppressed by the -nowarn option.
@param noteKey The key for the localized notification message. | [
"Provide",
"a",
"non",
"-",
"fatal",
"notification",
"unless",
"suppressed",
"by",
"the",
"-",
"nowarn",
"option",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.compiler/share/classes/com/sun/tools/javac/util/AbstractLog.java#L392-L394 |
linkedin/dexmaker | dexmaker/src/main/java/com/android/dx/stock/ProxyBuilder.java | ProxyBuilder.setInvocationHandler | public static void setInvocationHandler(Object instance, InvocationHandler handler) {
"""
Sets the proxy's {@link InvocationHandler}.
<p>
If you create a proxy with {@link #build()}, the proxy will already have a handler set,
provided that you configured one with {@link #handler(InvocationHandler)}.
<p>
If you generate a proxy class with {@link #buildProxyClass()}, instances of the proxy class
will not automatically have a handler set, and it is necessary to use this method with each
instance.
@throws IllegalArgumentException if the object supplied is not a proxy created by this class.
"""
try {
Field handlerField = instance.getClass().getDeclaredField(FIELD_NAME_HANDLER);
handlerField.setAccessible(true);
handlerField.set(instance, handler);
} catch (NoSuchFieldException e) {
throw new IllegalArgumentException("Not a valid proxy instance", e);
} catch (IllegalAccessException e) {
// Should not be thrown, we just set the field to accessible.
throw new AssertionError(e);
}
} | java | public static void setInvocationHandler(Object instance, InvocationHandler handler) {
try {
Field handlerField = instance.getClass().getDeclaredField(FIELD_NAME_HANDLER);
handlerField.setAccessible(true);
handlerField.set(instance, handler);
} catch (NoSuchFieldException e) {
throw new IllegalArgumentException("Not a valid proxy instance", e);
} catch (IllegalAccessException e) {
// Should not be thrown, we just set the field to accessible.
throw new AssertionError(e);
}
} | [
"public",
"static",
"void",
"setInvocationHandler",
"(",
"Object",
"instance",
",",
"InvocationHandler",
"handler",
")",
"{",
"try",
"{",
"Field",
"handlerField",
"=",
"instance",
".",
"getClass",
"(",
")",
".",
"getDeclaredField",
"(",
"FIELD_NAME_HANDLER",
")",
";",
"handlerField",
".",
"setAccessible",
"(",
"true",
")",
";",
"handlerField",
".",
"set",
"(",
"instance",
",",
"handler",
")",
";",
"}",
"catch",
"(",
"NoSuchFieldException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Not a valid proxy instance\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"e",
")",
"{",
"// Should not be thrown, we just set the field to accessible.",
"throw",
"new",
"AssertionError",
"(",
"e",
")",
";",
"}",
"}"
] | Sets the proxy's {@link InvocationHandler}.
<p>
If you create a proxy with {@link #build()}, the proxy will already have a handler set,
provided that you configured one with {@link #handler(InvocationHandler)}.
<p>
If you generate a proxy class with {@link #buildProxyClass()}, instances of the proxy class
will not automatically have a handler set, and it is necessary to use this method with each
instance.
@throws IllegalArgumentException if the object supplied is not a proxy created by this class. | [
"Sets",
"the",
"proxy",
"s",
"{",
"@link",
"InvocationHandler",
"}",
".",
"<p",
">",
"If",
"you",
"create",
"a",
"proxy",
"with",
"{",
"@link",
"#build",
"()",
"}",
"the",
"proxy",
"will",
"already",
"have",
"a",
"handler",
"set",
"provided",
"that",
"you",
"configured",
"one",
"with",
"{",
"@link",
"#handler",
"(",
"InvocationHandler",
")",
"}",
".",
"<p",
">",
"If",
"you",
"generate",
"a",
"proxy",
"class",
"with",
"{",
"@link",
"#buildProxyClass",
"()",
"}",
"instances",
"of",
"the",
"proxy",
"class",
"will",
"not",
"automatically",
"have",
"a",
"handler",
"set",
"and",
"it",
"is",
"necessary",
"to",
"use",
"this",
"method",
"with",
"each",
"instance",
"."
] | train | https://github.com/linkedin/dexmaker/blob/c58ffebcbb2564c7d1fa6fb58b48f351c330296d/dexmaker/src/main/java/com/android/dx/stock/ProxyBuilder.java#L419-L430 |
xiaosunzhu/resource-utils | src/main/java/net/sunyijun/resource/ResourceUtil.java | ResourceUtil.copyResourceToFile | public static void copyResourceToFile(String resourceAbsoluteClassPath, File targetFile) throws IOException {
"""
Copy resources to file system.
@param resourceAbsoluteClassPath resource's absolute class path, start with "/"
@param targetFile target file
@throws java.io.IOException
"""
InputStream is = ResourceUtil.class.getResourceAsStream(resourceAbsoluteClassPath);
if (is == null) {
throw new IOException("Resource not found! " + resourceAbsoluteClassPath);
}
OutputStream os = null;
try {
os = new FileOutputStream(targetFile);
byte[] buffer = new byte[2048];
int length;
while ((length = is.read(buffer)) != -1) {
os.write(buffer, 0, length);
}
os.flush();
} finally {
try {
is.close();
if (os != null) {
os.close();
}
} catch (Exception ignore) {
// ignore
}
}
} | java | public static void copyResourceToFile(String resourceAbsoluteClassPath, File targetFile) throws IOException {
InputStream is = ResourceUtil.class.getResourceAsStream(resourceAbsoluteClassPath);
if (is == null) {
throw new IOException("Resource not found! " + resourceAbsoluteClassPath);
}
OutputStream os = null;
try {
os = new FileOutputStream(targetFile);
byte[] buffer = new byte[2048];
int length;
while ((length = is.read(buffer)) != -1) {
os.write(buffer, 0, length);
}
os.flush();
} finally {
try {
is.close();
if (os != null) {
os.close();
}
} catch (Exception ignore) {
// ignore
}
}
} | [
"public",
"static",
"void",
"copyResourceToFile",
"(",
"String",
"resourceAbsoluteClassPath",
",",
"File",
"targetFile",
")",
"throws",
"IOException",
"{",
"InputStream",
"is",
"=",
"ResourceUtil",
".",
"class",
".",
"getResourceAsStream",
"(",
"resourceAbsoluteClassPath",
")",
";",
"if",
"(",
"is",
"==",
"null",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Resource not found! \"",
"+",
"resourceAbsoluteClassPath",
")",
";",
"}",
"OutputStream",
"os",
"=",
"null",
";",
"try",
"{",
"os",
"=",
"new",
"FileOutputStream",
"(",
"targetFile",
")",
";",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"2048",
"]",
";",
"int",
"length",
";",
"while",
"(",
"(",
"length",
"=",
"is",
".",
"read",
"(",
"buffer",
")",
")",
"!=",
"-",
"1",
")",
"{",
"os",
".",
"write",
"(",
"buffer",
",",
"0",
",",
"length",
")",
";",
"}",
"os",
".",
"flush",
"(",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"is",
".",
"close",
"(",
")",
";",
"if",
"(",
"os",
"!=",
"null",
")",
"{",
"os",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"ignore",
")",
"{",
"// ignore\r",
"}",
"}",
"}"
] | Copy resources to file system.
@param resourceAbsoluteClassPath resource's absolute class path, start with "/"
@param targetFile target file
@throws java.io.IOException | [
"Copy",
"resources",
"to",
"file",
"system",
"."
] | train | https://github.com/xiaosunzhu/resource-utils/blob/4f2bf3f36df10195a978f122ed682ba1eb0462b5/src/main/java/net/sunyijun/resource/ResourceUtil.java#L39-L63 |
UrielCh/ovh-java-sdk | ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java | ApiOvhOrder.cdn_dedicated_serviceName_cacheRule_duration_GET | public OvhOrder cdn_dedicated_serviceName_cacheRule_duration_GET(String serviceName, String duration, OvhOrderCacheRuleEnum cacheRule) throws IOException {
"""
Get prices and contracts information
REST: GET /order/cdn/dedicated/{serviceName}/cacheRule/{duration}
@param cacheRule [required] cache rule upgrade option to 100 or 1000
@param serviceName [required] The internal name of your CDN offer
@param duration [required] Duration
"""
String qPath = "/order/cdn/dedicated/{serviceName}/cacheRule/{duration}";
StringBuilder sb = path(qPath, serviceName, duration);
query(sb, "cacheRule", cacheRule);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhOrder.class);
} | java | public OvhOrder cdn_dedicated_serviceName_cacheRule_duration_GET(String serviceName, String duration, OvhOrderCacheRuleEnum cacheRule) throws IOException {
String qPath = "/order/cdn/dedicated/{serviceName}/cacheRule/{duration}";
StringBuilder sb = path(qPath, serviceName, duration);
query(sb, "cacheRule", cacheRule);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhOrder.class);
} | [
"public",
"OvhOrder",
"cdn_dedicated_serviceName_cacheRule_duration_GET",
"(",
"String",
"serviceName",
",",
"String",
"duration",
",",
"OvhOrderCacheRuleEnum",
"cacheRule",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/order/cdn/dedicated/{serviceName}/cacheRule/{duration}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"duration",
")",
";",
"query",
"(",
"sb",
",",
"\"cacheRule\"",
",",
"cacheRule",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhOrder",
".",
"class",
")",
";",
"}"
] | Get prices and contracts information
REST: GET /order/cdn/dedicated/{serviceName}/cacheRule/{duration}
@param cacheRule [required] cache rule upgrade option to 100 or 1000
@param serviceName [required] The internal name of your CDN offer
@param duration [required] Duration | [
"Get",
"prices",
"and",
"contracts",
"information"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java#L5277-L5283 |
xcesco/kripton | kripton-processor/src/main/java/com/abubusoft/kripton/processor/core/AssertKripton.java | AssertKripton.asserTrueOrForeignKeyNotFound | public static void asserTrueOrForeignKeyNotFound(boolean expression, SQLiteEntity currentEntity, ClassName entity) {
"""
Asser true or foreign key not found.
@param expression
the expression
@param currentEntity
the current entity
@param entity
the entity
"""
if (!expression) {
throw (new ForeignKeyNotFoundException(currentEntity, entity));
}
} | java | public static void asserTrueOrForeignKeyNotFound(boolean expression, SQLiteEntity currentEntity, ClassName entity) {
if (!expression) {
throw (new ForeignKeyNotFoundException(currentEntity, entity));
}
} | [
"public",
"static",
"void",
"asserTrueOrForeignKeyNotFound",
"(",
"boolean",
"expression",
",",
"SQLiteEntity",
"currentEntity",
",",
"ClassName",
"entity",
")",
"{",
"if",
"(",
"!",
"expression",
")",
"{",
"throw",
"(",
"new",
"ForeignKeyNotFoundException",
"(",
"currentEntity",
",",
"entity",
")",
")",
";",
"}",
"}"
] | Asser true or foreign key not found.
@param expression
the expression
@param currentEntity
the current entity
@param entity
the entity | [
"Asser",
"true",
"or",
"foreign",
"key",
"not",
"found",
"."
] | train | https://github.com/xcesco/kripton/blob/90de2c0523d39b99e81b8d38aa996898762f594a/kripton-processor/src/main/java/com/abubusoft/kripton/processor/core/AssertKripton.java#L347-L353 |
citiususc/hipster | hipster-core/src/main/java/es/usc/citius/hipster/util/examples/maze/Maze2D.java | Maze2D.validLocationsFrom | public Collection<Point> validLocationsFrom(Point loc) {
"""
Return all neighbor empty points from a specific location point.
@param loc source point
@return collection of empty neighbor points.
"""
Collection<Point> validMoves = new HashSet<Point>();
// Check for all valid movements
for (int row = -1; row <= 1; row++) {
for (int column = -1; column <= 1; column++) {
try {
if (isFree(new Point(loc.x + column, loc.y + row))) {
validMoves.add(new Point(loc.x + column, loc.y + row));
}
} catch (ArrayIndexOutOfBoundsException ex) {
// Invalid move!
}
}
}
validMoves.remove(loc);
return validMoves;
} | java | public Collection<Point> validLocationsFrom(Point loc) {
Collection<Point> validMoves = new HashSet<Point>();
// Check for all valid movements
for (int row = -1; row <= 1; row++) {
for (int column = -1; column <= 1; column++) {
try {
if (isFree(new Point(loc.x + column, loc.y + row))) {
validMoves.add(new Point(loc.x + column, loc.y + row));
}
} catch (ArrayIndexOutOfBoundsException ex) {
// Invalid move!
}
}
}
validMoves.remove(loc);
return validMoves;
} | [
"public",
"Collection",
"<",
"Point",
">",
"validLocationsFrom",
"(",
"Point",
"loc",
")",
"{",
"Collection",
"<",
"Point",
">",
"validMoves",
"=",
"new",
"HashSet",
"<",
"Point",
">",
"(",
")",
";",
"// Check for all valid movements",
"for",
"(",
"int",
"row",
"=",
"-",
"1",
";",
"row",
"<=",
"1",
";",
"row",
"++",
")",
"{",
"for",
"(",
"int",
"column",
"=",
"-",
"1",
";",
"column",
"<=",
"1",
";",
"column",
"++",
")",
"{",
"try",
"{",
"if",
"(",
"isFree",
"(",
"new",
"Point",
"(",
"loc",
".",
"x",
"+",
"column",
",",
"loc",
".",
"y",
"+",
"row",
")",
")",
")",
"{",
"validMoves",
".",
"add",
"(",
"new",
"Point",
"(",
"loc",
".",
"x",
"+",
"column",
",",
"loc",
".",
"y",
"+",
"row",
")",
")",
";",
"}",
"}",
"catch",
"(",
"ArrayIndexOutOfBoundsException",
"ex",
")",
"{",
"// Invalid move!",
"}",
"}",
"}",
"validMoves",
".",
"remove",
"(",
"loc",
")",
";",
"return",
"validMoves",
";",
"}"
] | Return all neighbor empty points from a specific location point.
@param loc source point
@return collection of empty neighbor points. | [
"Return",
"all",
"neighbor",
"empty",
"points",
"from",
"a",
"specific",
"location",
"point",
"."
] | train | https://github.com/citiususc/hipster/blob/9ab1236abb833a27641ae73ba9ca890d5c17598e/hipster-core/src/main/java/es/usc/citius/hipster/util/examples/maze/Maze2D.java#L382-L399 |
apache/flink | flink-core/src/main/java/org/apache/flink/util/IOUtils.java | IOUtils.copyBytes | public static void copyBytes(final InputStream in, final OutputStream out, final int buffSize, final boolean close)
throws IOException {
"""
Copies from one stream to another.
@param in
InputStream to read from
@param out
OutputStream to write to
@param buffSize
the size of the buffer
@param close
whether or not close the InputStream and OutputStream at the end. The streams are closed in the finally
clause.
@throws IOException
thrown if an error occurred while writing to the output stream
"""
@SuppressWarnings("resource")
final PrintStream ps = out instanceof PrintStream ? (PrintStream) out : null;
final byte[] buf = new byte[buffSize];
try {
int bytesRead = in.read(buf);
while (bytesRead >= 0) {
out.write(buf, 0, bytesRead);
if ((ps != null) && ps.checkError()) {
throw new IOException("Unable to write to output stream.");
}
bytesRead = in.read(buf);
}
} finally {
if (close) {
out.close();
in.close();
}
}
} | java | public static void copyBytes(final InputStream in, final OutputStream out, final int buffSize, final boolean close)
throws IOException {
@SuppressWarnings("resource")
final PrintStream ps = out instanceof PrintStream ? (PrintStream) out : null;
final byte[] buf = new byte[buffSize];
try {
int bytesRead = in.read(buf);
while (bytesRead >= 0) {
out.write(buf, 0, bytesRead);
if ((ps != null) && ps.checkError()) {
throw new IOException("Unable to write to output stream.");
}
bytesRead = in.read(buf);
}
} finally {
if (close) {
out.close();
in.close();
}
}
} | [
"public",
"static",
"void",
"copyBytes",
"(",
"final",
"InputStream",
"in",
",",
"final",
"OutputStream",
"out",
",",
"final",
"int",
"buffSize",
",",
"final",
"boolean",
"close",
")",
"throws",
"IOException",
"{",
"@",
"SuppressWarnings",
"(",
"\"resource\"",
")",
"final",
"PrintStream",
"ps",
"=",
"out",
"instanceof",
"PrintStream",
"?",
"(",
"PrintStream",
")",
"out",
":",
"null",
";",
"final",
"byte",
"[",
"]",
"buf",
"=",
"new",
"byte",
"[",
"buffSize",
"]",
";",
"try",
"{",
"int",
"bytesRead",
"=",
"in",
".",
"read",
"(",
"buf",
")",
";",
"while",
"(",
"bytesRead",
">=",
"0",
")",
"{",
"out",
".",
"write",
"(",
"buf",
",",
"0",
",",
"bytesRead",
")",
";",
"if",
"(",
"(",
"ps",
"!=",
"null",
")",
"&&",
"ps",
".",
"checkError",
"(",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Unable to write to output stream.\"",
")",
";",
"}",
"bytesRead",
"=",
"in",
".",
"read",
"(",
"buf",
")",
";",
"}",
"}",
"finally",
"{",
"if",
"(",
"close",
")",
"{",
"out",
".",
"close",
"(",
")",
";",
"in",
".",
"close",
"(",
")",
";",
"}",
"}",
"}"
] | Copies from one stream to another.
@param in
InputStream to read from
@param out
OutputStream to write to
@param buffSize
the size of the buffer
@param close
whether or not close the InputStream and OutputStream at the end. The streams are closed in the finally
clause.
@throws IOException
thrown if an error occurred while writing to the output stream | [
"Copies",
"from",
"one",
"stream",
"to",
"another",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/util/IOUtils.java#L56-L77 |
jbundle/jbundle | thin/base/db/base/src/main/java/org/jbundle/thin/base/db/FieldTable.java | FieldTable.setHandle | public FieldList setHandle(Object bookmark, int iHandleType) throws DBException {
"""
Reposition to this record Using this bookmark.
@param Object bookmark Bookmark.
@param int iHandleType Type of handle (see getHandle).
@exception FILE_NOT_OPEN.
@return record if found/null - record not found.
"""
if (this.doSetHandle(bookmark, iHandleType))
return this.getRecord();
else
return null;
} | java | public FieldList setHandle(Object bookmark, int iHandleType) throws DBException
{
if (this.doSetHandle(bookmark, iHandleType))
return this.getRecord();
else
return null;
} | [
"public",
"FieldList",
"setHandle",
"(",
"Object",
"bookmark",
",",
"int",
"iHandleType",
")",
"throws",
"DBException",
"{",
"if",
"(",
"this",
".",
"doSetHandle",
"(",
"bookmark",
",",
"iHandleType",
")",
")",
"return",
"this",
".",
"getRecord",
"(",
")",
";",
"else",
"return",
"null",
";",
"}"
] | Reposition to this record Using this bookmark.
@param Object bookmark Bookmark.
@param int iHandleType Type of handle (see getHandle).
@exception FILE_NOT_OPEN.
@return record if found/null - record not found. | [
"Reposition",
"to",
"this",
"record",
"Using",
"this",
"bookmark",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/db/base/src/main/java/org/jbundle/thin/base/db/FieldTable.java#L477-L483 |
trajano/caliper | caliper/src/main/java/com/google/caliper/runner/ServerSocketService.java | ServerSocketService.getConnection | public ListenableFuture<OpenedSocket> getConnection(UUID id) {
"""
Returns a {@link ListenableFuture} for an open connection corresponding to the given id.
<p>N.B. calling this method 'consumes' the connection and as such calling it twice with the
same id will not work, the second future returned will never complete. Similarly calling it
with an id that does not correspond to a worker trying to connect will also fail.
"""
checkState(isRunning(), "You can only get connections from a running service: %s", this);
return getConnectionImpl(id, Source.REQUEST);
} | java | public ListenableFuture<OpenedSocket> getConnection(UUID id) {
checkState(isRunning(), "You can only get connections from a running service: %s", this);
return getConnectionImpl(id, Source.REQUEST);
} | [
"public",
"ListenableFuture",
"<",
"OpenedSocket",
">",
"getConnection",
"(",
"UUID",
"id",
")",
"{",
"checkState",
"(",
"isRunning",
"(",
")",
",",
"\"You can only get connections from a running service: %s\"",
",",
"this",
")",
";",
"return",
"getConnectionImpl",
"(",
"id",
",",
"Source",
".",
"REQUEST",
")",
";",
"}"
] | Returns a {@link ListenableFuture} for an open connection corresponding to the given id.
<p>N.B. calling this method 'consumes' the connection and as such calling it twice with the
same id will not work, the second future returned will never complete. Similarly calling it
with an id that does not correspond to a worker trying to connect will also fail. | [
"Returns",
"a",
"{",
"@link",
"ListenableFuture",
"}",
"for",
"an",
"open",
"connection",
"corresponding",
"to",
"the",
"given",
"id",
"."
] | train | https://github.com/trajano/caliper/blob/a8bcfd84fa9d7b893b3edfadc3b13240ae5cd658/caliper/src/main/java/com/google/caliper/runner/ServerSocketService.java#L134-L137 |
deeplearning4j/deeplearning4j | datavec/datavec-data/datavec-data-image/src/main/java/org/datavec/image/transform/ColorConversionTransform.java | ColorConversionTransform.doTransform | @Override
protected ImageWritable doTransform(ImageWritable image, Random random) {
"""
Takes an image and returns a transformed image.
Uses the random object in the case of random transformations.
@param image to transform, null == end of stream
@param random object to use (or null for deterministic)
@return transformed image
"""
if (image == null) {
return null;
}
Mat mat = (Mat) converter.convert(image.getFrame());
Mat result = new Mat();
try {
cvtColor(mat, result, conversionCode);
} catch (Exception e) {
throw new RuntimeException(e);
}
return new ImageWritable(converter.convert(result));
} | java | @Override
protected ImageWritable doTransform(ImageWritable image, Random random) {
if (image == null) {
return null;
}
Mat mat = (Mat) converter.convert(image.getFrame());
Mat result = new Mat();
try {
cvtColor(mat, result, conversionCode);
} catch (Exception e) {
throw new RuntimeException(e);
}
return new ImageWritable(converter.convert(result));
} | [
"@",
"Override",
"protected",
"ImageWritable",
"doTransform",
"(",
"ImageWritable",
"image",
",",
"Random",
"random",
")",
"{",
"if",
"(",
"image",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"Mat",
"mat",
"=",
"(",
"Mat",
")",
"converter",
".",
"convert",
"(",
"image",
".",
"getFrame",
"(",
")",
")",
";",
"Mat",
"result",
"=",
"new",
"Mat",
"(",
")",
";",
"try",
"{",
"cvtColor",
"(",
"mat",
",",
"result",
",",
"conversionCode",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"return",
"new",
"ImageWritable",
"(",
"converter",
".",
"convert",
"(",
"result",
")",
")",
";",
"}"
] | Takes an image and returns a transformed image.
Uses the random object in the case of random transformations.
@param image to transform, null == end of stream
@param random object to use (or null for deterministic)
@return transformed image | [
"Takes",
"an",
"image",
"and",
"returns",
"a",
"transformed",
"image",
".",
"Uses",
"the",
"random",
"object",
"in",
"the",
"case",
"of",
"random",
"transformations",
"."
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/datavec/datavec-data/datavec-data-image/src/main/java/org/datavec/image/transform/ColorConversionTransform.java#L81-L97 |
unbescape/unbescape | src/main/java/org/unbescape/xml/XmlEscape.java | XmlEscape.escapeXml11 | public static void escapeXml11(final Reader reader, final Writer writer, final XmlEscapeType type, final XmlEscapeLevel level)
throws IOException {
"""
<p>
Perform a (configurable) XML 1.1 <strong>escape</strong> operation on a <tt>Reader</tt> input,
writing results to a <tt>Writer</tt>.
</p>
<p>
This method will perform an escape operation according to the specified
{@link org.unbescape.xml.XmlEscapeType} and {@link org.unbescape.xml.XmlEscapeLevel}
argument values.
</p>
<p>
All other <tt>Reader</tt>/<tt>Writer</tt>-based <tt>escapeXml11*(...)</tt> methods call this one with preconfigured
<tt>type</tt> and <tt>level</tt> values.
</p>
<p>
This method is <strong>thread-safe</strong>.
</p>
@param reader the <tt>Reader</tt> reading the text to be escaped.
@param type the type of escape operation to be performed, see {@link org.unbescape.xml.XmlEscapeType}.
@param writer the <tt>java.io.Writer</tt> to which the escaped result will be written. Nothing will
be written at all to this writer if input is <tt>null</tt>.
@param level the escape level to be applied, see {@link org.unbescape.xml.XmlEscapeLevel}.
@throws IOException if an input/output exception occurs
@since 1.1.2
"""
escapeXml(reader, writer, XmlEscapeSymbols.XML11_SYMBOLS, type, level);
} | java | public static void escapeXml11(final Reader reader, final Writer writer, final XmlEscapeType type, final XmlEscapeLevel level)
throws IOException {
escapeXml(reader, writer, XmlEscapeSymbols.XML11_SYMBOLS, type, level);
} | [
"public",
"static",
"void",
"escapeXml11",
"(",
"final",
"Reader",
"reader",
",",
"final",
"Writer",
"writer",
",",
"final",
"XmlEscapeType",
"type",
",",
"final",
"XmlEscapeLevel",
"level",
")",
"throws",
"IOException",
"{",
"escapeXml",
"(",
"reader",
",",
"writer",
",",
"XmlEscapeSymbols",
".",
"XML11_SYMBOLS",
",",
"type",
",",
"level",
")",
";",
"}"
] | <p>
Perform a (configurable) XML 1.1 <strong>escape</strong> operation on a <tt>Reader</tt> input,
writing results to a <tt>Writer</tt>.
</p>
<p>
This method will perform an escape operation according to the specified
{@link org.unbescape.xml.XmlEscapeType} and {@link org.unbescape.xml.XmlEscapeLevel}
argument values.
</p>
<p>
All other <tt>Reader</tt>/<tt>Writer</tt>-based <tt>escapeXml11*(...)</tt> methods call this one with preconfigured
<tt>type</tt> and <tt>level</tt> values.
</p>
<p>
This method is <strong>thread-safe</strong>.
</p>
@param reader the <tt>Reader</tt> reading the text to be escaped.
@param type the type of escape operation to be performed, see {@link org.unbescape.xml.XmlEscapeType}.
@param writer the <tt>java.io.Writer</tt> to which the escaped result will be written. Nothing will
be written at all to this writer if input is <tt>null</tt>.
@param level the escape level to be applied, see {@link org.unbescape.xml.XmlEscapeLevel}.
@throws IOException if an input/output exception occurs
@since 1.1.2 | [
"<p",
">",
"Perform",
"a",
"(",
"configurable",
")",
"XML",
"1",
".",
"1",
"<strong",
">",
"escape<",
"/",
"strong",
">",
"operation",
"on",
"a",
"<tt",
">",
"Reader<",
"/",
"tt",
">",
"input",
"writing",
"results",
"to",
"a",
"<tt",
">",
"Writer<",
"/",
"tt",
">",
".",
"<",
"/",
"p",
">",
"<p",
">",
"This",
"method",
"will",
"perform",
"an",
"escape",
"operation",
"according",
"to",
"the",
"specified",
"{",
"@link",
"org",
".",
"unbescape",
".",
"xml",
".",
"XmlEscapeType",
"}",
"and",
"{",
"@link",
"org",
".",
"unbescape",
".",
"xml",
".",
"XmlEscapeLevel",
"}",
"argument",
"values",
".",
"<",
"/",
"p",
">",
"<p",
">",
"All",
"other",
"<tt",
">",
"Reader<",
"/",
"tt",
">",
"/",
"<tt",
">",
"Writer<",
"/",
"tt",
">",
"-",
"based",
"<tt",
">",
"escapeXml11",
"*",
"(",
"...",
")",
"<",
"/",
"tt",
">",
"methods",
"call",
"this",
"one",
"with",
"preconfigured",
"<tt",
">",
"type<",
"/",
"tt",
">",
"and",
"<tt",
">",
"level<",
"/",
"tt",
">",
"values",
".",
"<",
"/",
"p",
">",
"<p",
">",
"This",
"method",
"is",
"<strong",
">",
"thread",
"-",
"safe<",
"/",
"strong",
">",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/unbescape/unbescape/blob/ec5435fb3508c2eed25d8165dc27ded2602cae13/src/main/java/org/unbescape/xml/XmlEscape.java#L1622-L1625 |
box/box-java-sdk | src/main/java/com/box/sdk/BoxFile.java | BoxFile.createMetadata | public Metadata createMetadata(String typeName, Metadata metadata) {
"""
Creates metadata on this file in the specified template type.
@param typeName the metadata template type name.
@param metadata the new metadata values.
@return the metadata returned from the server.
"""
String scope = Metadata.scopeBasedOnType(typeName);
return this.createMetadata(typeName, scope, metadata);
} | java | public Metadata createMetadata(String typeName, Metadata metadata) {
String scope = Metadata.scopeBasedOnType(typeName);
return this.createMetadata(typeName, scope, metadata);
} | [
"public",
"Metadata",
"createMetadata",
"(",
"String",
"typeName",
",",
"Metadata",
"metadata",
")",
"{",
"String",
"scope",
"=",
"Metadata",
".",
"scopeBasedOnType",
"(",
"typeName",
")",
";",
"return",
"this",
".",
"createMetadata",
"(",
"typeName",
",",
"scope",
",",
"metadata",
")",
";",
"}"
] | Creates metadata on this file in the specified template type.
@param typeName the metadata template type name.
@param metadata the new metadata values.
@return the metadata returned from the server. | [
"Creates",
"metadata",
"on",
"this",
"file",
"in",
"the",
"specified",
"template",
"type",
"."
] | train | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L1019-L1022 |
leadware/jpersistence-tools | jpersistence-tools-core/src/main/java/net/leadware/persistence/tools/core/dao/impl/JPAGenericDAORulesBasedImpl.java | JPAGenericDAORulesBasedImpl.addOrders | protected void addOrders(CriteriaBuilder criteriaBuilder, Root<T> root, CriteriaQuery<T> criteriaQuery, Map<String, OrderType> orders) {
"""
Méthode de chargement des ordres
@param criteriaBuilder Constructeur de criteres
@param root Objet racine
@param criteriaQuery Requete de critères
@param orders Liste des ordres
"""
// Si la liste est vide
if(orders == null || orders.size() == 0) return;
// Liste d'ordres
List<Order> lOrders = new ArrayList<Order>();
// Parcours
for (String property : orders.keySet()) {
// Si la propriete est vide
if(property == null || property.trim().length() == 0) continue;
// Evaluation de la ppt
Path<?> path = buildPropertyPathForAnyType(root, property.trim());
// Obtention du Type
OrderType type = orders.get(property);
// Si le type est null
if(type == null) continue;
// Si on est en ASC
if(type.equals(OrderType.ASC)) lOrders.add(criteriaBuilder.asc(path));
else lOrders.add(criteriaBuilder.desc(path));
}
// Ajout
criteriaQuery.orderBy(lOrders);
} | java | protected void addOrders(CriteriaBuilder criteriaBuilder, Root<T> root, CriteriaQuery<T> criteriaQuery, Map<String, OrderType> orders) {
// Si la liste est vide
if(orders == null || orders.size() == 0) return;
// Liste d'ordres
List<Order> lOrders = new ArrayList<Order>();
// Parcours
for (String property : orders.keySet()) {
// Si la propriete est vide
if(property == null || property.trim().length() == 0) continue;
// Evaluation de la ppt
Path<?> path = buildPropertyPathForAnyType(root, property.trim());
// Obtention du Type
OrderType type = orders.get(property);
// Si le type est null
if(type == null) continue;
// Si on est en ASC
if(type.equals(OrderType.ASC)) lOrders.add(criteriaBuilder.asc(path));
else lOrders.add(criteriaBuilder.desc(path));
}
// Ajout
criteriaQuery.orderBy(lOrders);
} | [
"protected",
"void",
"addOrders",
"(",
"CriteriaBuilder",
"criteriaBuilder",
",",
"Root",
"<",
"T",
">",
"root",
",",
"CriteriaQuery",
"<",
"T",
">",
"criteriaQuery",
",",
"Map",
"<",
"String",
",",
"OrderType",
">",
"orders",
")",
"{",
"// Si la liste est vide\r",
"if",
"(",
"orders",
"==",
"null",
"||",
"orders",
".",
"size",
"(",
")",
"==",
"0",
")",
"return",
";",
"// Liste d'ordres\r",
"List",
"<",
"Order",
">",
"lOrders",
"=",
"new",
"ArrayList",
"<",
"Order",
">",
"(",
")",
";",
"// Parcours\r",
"for",
"(",
"String",
"property",
":",
"orders",
".",
"keySet",
"(",
")",
")",
"{",
"// Si la propriete est vide\r",
"if",
"(",
"property",
"==",
"null",
"||",
"property",
".",
"trim",
"(",
")",
".",
"length",
"(",
")",
"==",
"0",
")",
"continue",
";",
"// Evaluation de la ppt\r",
"Path",
"<",
"?",
">",
"path",
"=",
"buildPropertyPathForAnyType",
"(",
"root",
",",
"property",
".",
"trim",
"(",
")",
")",
";",
"// Obtention du Type\r",
"OrderType",
"type",
"=",
"orders",
".",
"get",
"(",
"property",
")",
";",
"// Si le type est null\r",
"if",
"(",
"type",
"==",
"null",
")",
"continue",
";",
"// Si on est en ASC\r",
"if",
"(",
"type",
".",
"equals",
"(",
"OrderType",
".",
"ASC",
")",
")",
"lOrders",
".",
"add",
"(",
"criteriaBuilder",
".",
"asc",
"(",
"path",
")",
")",
";",
"else",
"lOrders",
".",
"add",
"(",
"criteriaBuilder",
".",
"desc",
"(",
"path",
")",
")",
";",
"}",
"// Ajout\r",
"criteriaQuery",
".",
"orderBy",
"(",
"lOrders",
")",
";",
"}"
] | Méthode de chargement des ordres
@param criteriaBuilder Constructeur de criteres
@param root Objet racine
@param criteriaQuery Requete de critères
@param orders Liste des ordres | [
"Méthode",
"de",
"chargement",
"des",
"ordres"
] | train | https://github.com/leadware/jpersistence-tools/blob/4c15372993584579d7dbb9b23dd4c0c0fdc9e789/jpersistence-tools-core/src/main/java/net/leadware/persistence/tools/core/dao/impl/JPAGenericDAORulesBasedImpl.java#L675-L705 |
JOML-CI/JOML | src/org/joml/Matrix4d.java | Matrix4d.translateLocal | public Matrix4d translateLocal(Vector3dc offset, Matrix4d dest) {
"""
Pre-multiply a translation to this matrix by translating by the given number of
units in x, y and z and store the result in <code>dest</code>.
<p>
If <code>M</code> is <code>this</code> matrix and <code>T</code> the translation
matrix, then the new matrix will be <code>T * M</code>. So when
transforming a vector <code>v</code> with the new matrix by using
<code>T * M * v</code>, the translation will be applied last!
<p>
In order to set the matrix to a translation transformation without pre-multiplying
it, use {@link #translation(Vector3dc)}.
@see #translation(Vector3dc)
@param offset
the number of units in x, y and z by which to translate
@param dest
will hold the result
@return dest
"""
return translateLocal(offset.x(), offset.y(), offset.z(), dest);
} | java | public Matrix4d translateLocal(Vector3dc offset, Matrix4d dest) {
return translateLocal(offset.x(), offset.y(), offset.z(), dest);
} | [
"public",
"Matrix4d",
"translateLocal",
"(",
"Vector3dc",
"offset",
",",
"Matrix4d",
"dest",
")",
"{",
"return",
"translateLocal",
"(",
"offset",
".",
"x",
"(",
")",
",",
"offset",
".",
"y",
"(",
")",
",",
"offset",
".",
"z",
"(",
")",
",",
"dest",
")",
";",
"}"
] | Pre-multiply a translation to this matrix by translating by the given number of
units in x, y and z and store the result in <code>dest</code>.
<p>
If <code>M</code> is <code>this</code> matrix and <code>T</code> the translation
matrix, then the new matrix will be <code>T * M</code>. So when
transforming a vector <code>v</code> with the new matrix by using
<code>T * M * v</code>, the translation will be applied last!
<p>
In order to set the matrix to a translation transformation without pre-multiplying
it, use {@link #translation(Vector3dc)}.
@see #translation(Vector3dc)
@param offset
the number of units in x, y and z by which to translate
@param dest
will hold the result
@return dest | [
"Pre",
"-",
"multiply",
"a",
"translation",
"to",
"this",
"matrix",
"by",
"translating",
"by",
"the",
"given",
"number",
"of",
"units",
"in",
"x",
"y",
"and",
"z",
"and",
"store",
"the",
"result",
"in",
"<code",
">",
"dest<",
"/",
"code",
">",
".",
"<p",
">",
"If",
"<code",
">",
"M<",
"/",
"code",
">",
"is",
"<code",
">",
"this<",
"/",
"code",
">",
"matrix",
"and",
"<code",
">",
"T<",
"/",
"code",
">",
"the",
"translation",
"matrix",
"then",
"the",
"new",
"matrix",
"will",
"be",
"<code",
">",
"T",
"*",
"M<",
"/",
"code",
">",
".",
"So",
"when",
"transforming",
"a",
"vector",
"<code",
">",
"v<",
"/",
"code",
">",
"with",
"the",
"new",
"matrix",
"by",
"using",
"<code",
">",
"T",
"*",
"M",
"*",
"v<",
"/",
"code",
">",
"the",
"translation",
"will",
"be",
"applied",
"last!",
"<p",
">",
"In",
"order",
"to",
"set",
"the",
"matrix",
"to",
"a",
"translation",
"transformation",
"without",
"pre",
"-",
"multiplying",
"it",
"use",
"{",
"@link",
"#translation",
"(",
"Vector3dc",
")",
"}",
"."
] | train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Matrix4d.java#L5636-L5638 |
jglobus/JGlobus | gridftp/src/main/java/org/globus/ftp/GridFTPClient.java | GridFTPClient.changeGroup | public void changeGroup(String group, String file)
throws IOException, ServerException {
"""
Change the Unix group membership of a file.
@param group the name or ID of the group
@param file the file whose group membership should be changed
@exception ServerException if an error occurred.
"""
String arguments = group + " " + file;
Command cmd = new Command("SITE CHGRP", arguments);
try {
controlChannel.execute(cmd);
} catch (UnexpectedReplyCodeException urce) {
throw ServerException.embedUnexpectedReplyCodeException(urce);
} catch (FTPReplyParseException rpe) {
throw ServerException.embedFTPReplyParseException(rpe);
}
} | java | public void changeGroup(String group, String file)
throws IOException, ServerException {
String arguments = group + " " + file;
Command cmd = new Command("SITE CHGRP", arguments);
try {
controlChannel.execute(cmd);
} catch (UnexpectedReplyCodeException urce) {
throw ServerException.embedUnexpectedReplyCodeException(urce);
} catch (FTPReplyParseException rpe) {
throw ServerException.embedFTPReplyParseException(rpe);
}
} | [
"public",
"void",
"changeGroup",
"(",
"String",
"group",
",",
"String",
"file",
")",
"throws",
"IOException",
",",
"ServerException",
"{",
"String",
"arguments",
"=",
"group",
"+",
"\" \"",
"+",
"file",
";",
"Command",
"cmd",
"=",
"new",
"Command",
"(",
"\"SITE CHGRP\"",
",",
"arguments",
")",
";",
"try",
"{",
"controlChannel",
".",
"execute",
"(",
"cmd",
")",
";",
"}",
"catch",
"(",
"UnexpectedReplyCodeException",
"urce",
")",
"{",
"throw",
"ServerException",
".",
"embedUnexpectedReplyCodeException",
"(",
"urce",
")",
";",
"}",
"catch",
"(",
"FTPReplyParseException",
"rpe",
")",
"{",
"throw",
"ServerException",
".",
"embedFTPReplyParseException",
"(",
"rpe",
")",
";",
"}",
"}"
] | Change the Unix group membership of a file.
@param group the name or ID of the group
@param file the file whose group membership should be changed
@exception ServerException if an error occurred. | [
"Change",
"the",
"Unix",
"group",
"membership",
"of",
"a",
"file",
"."
] | train | https://github.com/jglobus/JGlobus/blob/e14f6f6636544fd84298f9cec749d626ea971930/gridftp/src/main/java/org/globus/ftp/GridFTPClient.java#L1085-L1096 |
codeprimate-software/cp-elements | src/main/java/org/cp/elements/lang/Assert.java | Assert.notEmpty | public static void notEmpty(Object[] array, Supplier<String> message) {
"""
Asserts that the {@link Object array} is not empty.
The assertion holds if and only if the {@link Object array} is not {@literal null} and contains at least 1 element.
@param array {@link Object array} to evaluate.
@param message {@link Supplier} containing the message using in the {@link IllegalArgumentException} thrown
if the assertion fails.
@throws java.lang.IllegalArgumentException if the {@link Object array} is {@literal null} or empty.
@see java.lang.Object[]
"""
if (isEmpty(array)) {
throw new IllegalArgumentException(message.get());
}
} | java | public static void notEmpty(Object[] array, Supplier<String> message) {
if (isEmpty(array)) {
throw new IllegalArgumentException(message.get());
}
} | [
"public",
"static",
"void",
"notEmpty",
"(",
"Object",
"[",
"]",
"array",
",",
"Supplier",
"<",
"String",
">",
"message",
")",
"{",
"if",
"(",
"isEmpty",
"(",
"array",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"message",
".",
"get",
"(",
")",
")",
";",
"}",
"}"
] | Asserts that the {@link Object array} is not empty.
The assertion holds if and only if the {@link Object array} is not {@literal null} and contains at least 1 element.
@param array {@link Object array} to evaluate.
@param message {@link Supplier} containing the message using in the {@link IllegalArgumentException} thrown
if the assertion fails.
@throws java.lang.IllegalArgumentException if the {@link Object array} is {@literal null} or empty.
@see java.lang.Object[] | [
"Asserts",
"that",
"the",
"{",
"@link",
"Object",
"array",
"}",
"is",
"not",
"empty",
"."
] | train | https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/lang/Assert.java#L973-L977 |
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.getCompositeEntity | public CompositeEntityExtractor getCompositeEntity(UUID appId, String versionId, UUID cEntityId) {
"""
Gets information about the composite entity model.
@param appId The application ID.
@param versionId The version ID.
@param cEntityId The composite entity extractor ID.
@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 CompositeEntityExtractor object if successful.
"""
return getCompositeEntityWithServiceResponseAsync(appId, versionId, cEntityId).toBlocking().single().body();
} | java | public CompositeEntityExtractor getCompositeEntity(UUID appId, String versionId, UUID cEntityId) {
return getCompositeEntityWithServiceResponseAsync(appId, versionId, cEntityId).toBlocking().single().body();
} | [
"public",
"CompositeEntityExtractor",
"getCompositeEntity",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"UUID",
"cEntityId",
")",
"{",
"return",
"getCompositeEntityWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"cEntityId",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Gets information about the composite entity model.
@param appId The application ID.
@param versionId The version ID.
@param cEntityId The composite entity extractor ID.
@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 CompositeEntityExtractor object if successful. | [
"Gets",
"information",
"about",
"the",
"composite",
"entity",
"model",
"."
] | 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#L3937-L3939 |
alkacon/opencms-core | src/org/opencms/gwt/CmsVfsService.java | CmsVfsService.renameResourceInternal | public String renameResourceInternal(CmsUUID structureId, String newName) throws CmsException {
"""
Internal implementation for renaming a resource.<p>
@param structureId the structure id of the resource to rename
@param newName the new resource name
@return either null if the rename was successful, or an error message
@throws CmsException if something goes wrong
"""
newName = newName.trim();
CmsObject rootCms = OpenCms.initCmsObject(getCmsObject());
rootCms.getRequestContext().setSiteRoot("");
Locale locale = OpenCms.getWorkplaceManager().getWorkplaceLocale(rootCms);
try {
CmsResource.checkResourceName(newName);
} catch (CmsIllegalArgumentException e) {
return e.getLocalizedMessage(locale);
}
CmsResource resource = rootCms.readResource(structureId, CmsResourceFilter.IGNORE_EXPIRATION);
String oldPath = resource.getRootPath();
String parentPath = CmsResource.getParentFolder(oldPath);
String newPath = CmsStringUtil.joinPaths(parentPath, newName);
try {
ensureLock(resource);
rootCms.moveResource(oldPath, newPath);
resource = rootCms.readResource(structureId, CmsResourceFilter.IGNORE_EXPIRATION);
} catch (CmsException e) {
return e.getLocalizedMessage(OpenCms.getWorkplaceManager().getWorkplaceLocale(rootCms));
}
tryUnlock(resource);
return null;
} | java | public String renameResourceInternal(CmsUUID structureId, String newName) throws CmsException {
newName = newName.trim();
CmsObject rootCms = OpenCms.initCmsObject(getCmsObject());
rootCms.getRequestContext().setSiteRoot("");
Locale locale = OpenCms.getWorkplaceManager().getWorkplaceLocale(rootCms);
try {
CmsResource.checkResourceName(newName);
} catch (CmsIllegalArgumentException e) {
return e.getLocalizedMessage(locale);
}
CmsResource resource = rootCms.readResource(structureId, CmsResourceFilter.IGNORE_EXPIRATION);
String oldPath = resource.getRootPath();
String parentPath = CmsResource.getParentFolder(oldPath);
String newPath = CmsStringUtil.joinPaths(parentPath, newName);
try {
ensureLock(resource);
rootCms.moveResource(oldPath, newPath);
resource = rootCms.readResource(structureId, CmsResourceFilter.IGNORE_EXPIRATION);
} catch (CmsException e) {
return e.getLocalizedMessage(OpenCms.getWorkplaceManager().getWorkplaceLocale(rootCms));
}
tryUnlock(resource);
return null;
} | [
"public",
"String",
"renameResourceInternal",
"(",
"CmsUUID",
"structureId",
",",
"String",
"newName",
")",
"throws",
"CmsException",
"{",
"newName",
"=",
"newName",
".",
"trim",
"(",
")",
";",
"CmsObject",
"rootCms",
"=",
"OpenCms",
".",
"initCmsObject",
"(",
"getCmsObject",
"(",
")",
")",
";",
"rootCms",
".",
"getRequestContext",
"(",
")",
".",
"setSiteRoot",
"(",
"\"\"",
")",
";",
"Locale",
"locale",
"=",
"OpenCms",
".",
"getWorkplaceManager",
"(",
")",
".",
"getWorkplaceLocale",
"(",
"rootCms",
")",
";",
"try",
"{",
"CmsResource",
".",
"checkResourceName",
"(",
"newName",
")",
";",
"}",
"catch",
"(",
"CmsIllegalArgumentException",
"e",
")",
"{",
"return",
"e",
".",
"getLocalizedMessage",
"(",
"locale",
")",
";",
"}",
"CmsResource",
"resource",
"=",
"rootCms",
".",
"readResource",
"(",
"structureId",
",",
"CmsResourceFilter",
".",
"IGNORE_EXPIRATION",
")",
";",
"String",
"oldPath",
"=",
"resource",
".",
"getRootPath",
"(",
")",
";",
"String",
"parentPath",
"=",
"CmsResource",
".",
"getParentFolder",
"(",
"oldPath",
")",
";",
"String",
"newPath",
"=",
"CmsStringUtil",
".",
"joinPaths",
"(",
"parentPath",
",",
"newName",
")",
";",
"try",
"{",
"ensureLock",
"(",
"resource",
")",
";",
"rootCms",
".",
"moveResource",
"(",
"oldPath",
",",
"newPath",
")",
";",
"resource",
"=",
"rootCms",
".",
"readResource",
"(",
"structureId",
",",
"CmsResourceFilter",
".",
"IGNORE_EXPIRATION",
")",
";",
"}",
"catch",
"(",
"CmsException",
"e",
")",
"{",
"return",
"e",
".",
"getLocalizedMessage",
"(",
"OpenCms",
".",
"getWorkplaceManager",
"(",
")",
".",
"getWorkplaceLocale",
"(",
"rootCms",
")",
")",
";",
"}",
"tryUnlock",
"(",
"resource",
")",
";",
"return",
"null",
";",
"}"
] | Internal implementation for renaming a resource.<p>
@param structureId the structure id of the resource to rename
@param newName the new resource name
@return either null if the rename was successful, or an error message
@throws CmsException if something goes wrong | [
"Internal",
"implementation",
"for",
"renaming",
"a",
"resource",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/gwt/CmsVfsService.java#L996-L1020 |
eobermuhlner/big-math | ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigDecimalMath.java | BigDecimalMath.acot | public static BigDecimal acot(BigDecimal x, MathContext mathContext) {
"""
Calculates the inverse cotangens (arc cotangens) of {@link BigDecimal} x.
<p>See: <a href="http://en.wikipedia.org/wiki/Arccotangens">Wikipedia: Arccotangens</a></p>
@param x the {@link BigDecimal} to calculate the arc cotangens for
@param mathContext the {@link MathContext} used for the result
@return the calculated arc cotangens {@link BigDecimal} with the precision specified in the <code>mathContext</code>
@throws UnsupportedOperationException if the {@link MathContext} has unlimited precision
"""
checkMathContext(mathContext);
MathContext mc = new MathContext(mathContext.getPrecision() + 4, mathContext.getRoundingMode());
BigDecimal result = pi(mc).divide(TWO, mc).subtract(atan(x, mc), mc);
return round(result, mathContext);
} | java | public static BigDecimal acot(BigDecimal x, MathContext mathContext) {
checkMathContext(mathContext);
MathContext mc = new MathContext(mathContext.getPrecision() + 4, mathContext.getRoundingMode());
BigDecimal result = pi(mc).divide(TWO, mc).subtract(atan(x, mc), mc);
return round(result, mathContext);
} | [
"public",
"static",
"BigDecimal",
"acot",
"(",
"BigDecimal",
"x",
",",
"MathContext",
"mathContext",
")",
"{",
"checkMathContext",
"(",
"mathContext",
")",
";",
"MathContext",
"mc",
"=",
"new",
"MathContext",
"(",
"mathContext",
".",
"getPrecision",
"(",
")",
"+",
"4",
",",
"mathContext",
".",
"getRoundingMode",
"(",
")",
")",
";",
"BigDecimal",
"result",
"=",
"pi",
"(",
"mc",
")",
".",
"divide",
"(",
"TWO",
",",
"mc",
")",
".",
"subtract",
"(",
"atan",
"(",
"x",
",",
"mc",
")",
",",
"mc",
")",
";",
"return",
"round",
"(",
"result",
",",
"mathContext",
")",
";",
"}"
] | Calculates the inverse cotangens (arc cotangens) of {@link BigDecimal} x.
<p>See: <a href="http://en.wikipedia.org/wiki/Arccotangens">Wikipedia: Arccotangens</a></p>
@param x the {@link BigDecimal} to calculate the arc cotangens for
@param mathContext the {@link MathContext} used for the result
@return the calculated arc cotangens {@link BigDecimal} with the precision specified in the <code>mathContext</code>
@throws UnsupportedOperationException if the {@link MathContext} has unlimited precision | [
"Calculates",
"the",
"inverse",
"cotangens",
"(",
"arc",
"cotangens",
")",
"of",
"{",
"@link",
"BigDecimal",
"}",
"x",
"."
] | train | https://github.com/eobermuhlner/big-math/blob/52c4fc334d0d722b295de740c1018ee400e3e8f2/ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigDecimalMath.java#L1516-L1521 |
gmessner/gitlab4j-api | src/main/java/org/gitlab4j/api/GitLabApiClient.java | GitLabApiClient.enableRequestResponseLogging | void enableRequestResponseLogging(Logger logger, Level level, int maxEntityLength, List<String> maskedHeaderNames) {
"""
Enable the logging of the requests to and the responses from the GitLab server API.
@param logger the Logger instance to log to
@param level the logging level (SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST)
@param maxEntitySize maximum number of entity bytes to be logged. When logging if the maxEntitySize
is reached, the entity logging will be truncated at maxEntitySize and "...more..." will be added at
the end of the log entry. If maxEntitySize is <= 0, entity logging will be disabled
@param maskedHeaderNames a list of header names that should have the values masked
"""
MaskingLoggingFilter loggingFilter = new MaskingLoggingFilter(logger, level, maxEntityLength, maskedHeaderNames);
clientConfig.register(loggingFilter);
// Recreate the Client instance if already created.
if (apiClient != null) {
createApiClient();
}
} | java | void enableRequestResponseLogging(Logger logger, Level level, int maxEntityLength, List<String> maskedHeaderNames) {
MaskingLoggingFilter loggingFilter = new MaskingLoggingFilter(logger, level, maxEntityLength, maskedHeaderNames);
clientConfig.register(loggingFilter);
// Recreate the Client instance if already created.
if (apiClient != null) {
createApiClient();
}
} | [
"void",
"enableRequestResponseLogging",
"(",
"Logger",
"logger",
",",
"Level",
"level",
",",
"int",
"maxEntityLength",
",",
"List",
"<",
"String",
">",
"maskedHeaderNames",
")",
"{",
"MaskingLoggingFilter",
"loggingFilter",
"=",
"new",
"MaskingLoggingFilter",
"(",
"logger",
",",
"level",
",",
"maxEntityLength",
",",
"maskedHeaderNames",
")",
";",
"clientConfig",
".",
"register",
"(",
"loggingFilter",
")",
";",
"// Recreate the Client instance if already created.",
"if",
"(",
"apiClient",
"!=",
"null",
")",
"{",
"createApiClient",
"(",
")",
";",
"}",
"}"
] | Enable the logging of the requests to and the responses from the GitLab server API.
@param logger the Logger instance to log to
@param level the logging level (SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST)
@param maxEntitySize maximum number of entity bytes to be logged. When logging if the maxEntitySize
is reached, the entity logging will be truncated at maxEntitySize and "...more..." will be added at
the end of the log entry. If maxEntitySize is <= 0, entity logging will be disabled
@param maskedHeaderNames a list of header names that should have the values masked | [
"Enable",
"the",
"logging",
"of",
"the",
"requests",
"to",
"and",
"the",
"responses",
"from",
"the",
"GitLab",
"server",
"API",
"."
] | train | https://github.com/gmessner/gitlab4j-api/blob/ab045070abac0a8f4ccbf17b5ed9bfdef5723eed/src/main/java/org/gitlab4j/api/GitLabApiClient.java#L253-L262 |
twilliamson/mogwee-logging | src/main/java/com/mogwee/logging/Logger.java | Logger.infof | public final void infof(String message, Object... args) {
"""
Logs a formatted message if INFO logging is enabled.
@param message a <a href="http://download.oracle.com/javase/6/docs/api/java/util/Formatter.html#syntax">format string</a>
@param args arguments referenced by the format specifiers in the format string.
"""
logf(Level.INFO, null, message, args);
} | java | public final void infof(String message, Object... args)
{
logf(Level.INFO, null, message, args);
} | [
"public",
"final",
"void",
"infof",
"(",
"String",
"message",
",",
"Object",
"...",
"args",
")",
"{",
"logf",
"(",
"Level",
".",
"INFO",
",",
"null",
",",
"message",
",",
"args",
")",
";",
"}"
] | Logs a formatted message if INFO logging is enabled.
@param message a <a href="http://download.oracle.com/javase/6/docs/api/java/util/Formatter.html#syntax">format string</a>
@param args arguments referenced by the format specifiers in the format string. | [
"Logs",
"a",
"formatted",
"message",
"if",
"INFO",
"logging",
"is",
"enabled",
"."
] | train | https://github.com/twilliamson/mogwee-logging/blob/30b99c2649de455432d956a8f6a74316de4cd62c/src/main/java/com/mogwee/logging/Logger.java#L148-L151 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/Utility.java | Utility.escapeUnprintable | public static <T extends Appendable> boolean escapeUnprintable(T result, int c) {
"""
Escape unprintable characters using <backslash>uxxxx notation
for U+0000 to U+FFFF and <backslash>Uxxxxxxxx for U+10000 and
above. If the character is printable ASCII, then do nothing
and return FALSE. Otherwise, append the escaped notation and
return TRUE.
"""
try {
if (isUnprintable(c)) {
result.append('\\');
if ((c & ~0xFFFF) != 0) {
result.append('U');
result.append(DIGITS[0xF&(c>>28)]);
result.append(DIGITS[0xF&(c>>24)]);
result.append(DIGITS[0xF&(c>>20)]);
result.append(DIGITS[0xF&(c>>16)]);
} else {
result.append('u');
}
result.append(DIGITS[0xF&(c>>12)]);
result.append(DIGITS[0xF&(c>>8)]);
result.append(DIGITS[0xF&(c>>4)]);
result.append(DIGITS[0xF&c]);
return true;
}
return false;
} catch (IOException e) {
throw new IllegalIcuArgumentException(e);
}
} | java | public static <T extends Appendable> boolean escapeUnprintable(T result, int c) {
try {
if (isUnprintable(c)) {
result.append('\\');
if ((c & ~0xFFFF) != 0) {
result.append('U');
result.append(DIGITS[0xF&(c>>28)]);
result.append(DIGITS[0xF&(c>>24)]);
result.append(DIGITS[0xF&(c>>20)]);
result.append(DIGITS[0xF&(c>>16)]);
} else {
result.append('u');
}
result.append(DIGITS[0xF&(c>>12)]);
result.append(DIGITS[0xF&(c>>8)]);
result.append(DIGITS[0xF&(c>>4)]);
result.append(DIGITS[0xF&c]);
return true;
}
return false;
} catch (IOException e) {
throw new IllegalIcuArgumentException(e);
}
} | [
"public",
"static",
"<",
"T",
"extends",
"Appendable",
">",
"boolean",
"escapeUnprintable",
"(",
"T",
"result",
",",
"int",
"c",
")",
"{",
"try",
"{",
"if",
"(",
"isUnprintable",
"(",
"c",
")",
")",
"{",
"result",
".",
"append",
"(",
"'",
"'",
")",
";",
"if",
"(",
"(",
"c",
"&",
"~",
"0xFFFF",
")",
"!=",
"0",
")",
"{",
"result",
".",
"append",
"(",
"'",
"'",
")",
";",
"result",
".",
"append",
"(",
"DIGITS",
"[",
"0xF",
"&",
"(",
"c",
">>",
"28",
")",
"]",
")",
";",
"result",
".",
"append",
"(",
"DIGITS",
"[",
"0xF",
"&",
"(",
"c",
">>",
"24",
")",
"]",
")",
";",
"result",
".",
"append",
"(",
"DIGITS",
"[",
"0xF",
"&",
"(",
"c",
">>",
"20",
")",
"]",
")",
";",
"result",
".",
"append",
"(",
"DIGITS",
"[",
"0xF",
"&",
"(",
"c",
">>",
"16",
")",
"]",
")",
";",
"}",
"else",
"{",
"result",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"result",
".",
"append",
"(",
"DIGITS",
"[",
"0xF",
"&",
"(",
"c",
">>",
"12",
")",
"]",
")",
";",
"result",
".",
"append",
"(",
"DIGITS",
"[",
"0xF",
"&",
"(",
"c",
">>",
"8",
")",
"]",
")",
";",
"result",
".",
"append",
"(",
"DIGITS",
"[",
"0xF",
"&",
"(",
"c",
">>",
"4",
")",
"]",
")",
";",
"result",
".",
"append",
"(",
"DIGITS",
"[",
"0xF",
"&",
"c",
"]",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"IllegalIcuArgumentException",
"(",
"e",
")",
";",
"}",
"}"
] | Escape unprintable characters using <backslash>uxxxx notation
for U+0000 to U+FFFF and <backslash>Uxxxxxxxx for U+10000 and
above. If the character is printable ASCII, then do nothing
and return FALSE. Otherwise, append the escaped notation and
return TRUE. | [
"Escape",
"unprintable",
"characters",
"using",
"<backslash",
">",
"uxxxx",
"notation",
"for",
"U",
"+",
"0000",
"to",
"U",
"+",
"FFFF",
"and",
"<backslash",
">",
"Uxxxxxxxx",
"for",
"U",
"+",
"10000",
"and",
"above",
".",
"If",
"the",
"character",
"is",
"printable",
"ASCII",
"then",
"do",
"nothing",
"and",
"return",
"FALSE",
".",
"Otherwise",
"append",
"the",
"escaped",
"notation",
"and",
"return",
"TRUE",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/Utility.java#L1488-L1511 |
landawn/AbacusUtil | src/com/landawn/abacus/dataSource/PoolablePreparedStatement.java | PoolablePreparedStatement.setNString | @Override
public void setNString(int parameterIndex, String value) throws SQLException {
"""
Method setNString.
@param parameterIndex
@param value
@throws SQLException
@see java.sql.PreparedStatement#setNString(int, String)
"""
internalStmt.setNString(parameterIndex, value);
} | java | @Override
public void setNString(int parameterIndex, String value) throws SQLException {
internalStmt.setNString(parameterIndex, value);
} | [
"@",
"Override",
"public",
"void",
"setNString",
"(",
"int",
"parameterIndex",
",",
"String",
"value",
")",
"throws",
"SQLException",
"{",
"internalStmt",
".",
"setNString",
"(",
"parameterIndex",
",",
"value",
")",
";",
"}"
] | Method setNString.
@param parameterIndex
@param value
@throws SQLException
@see java.sql.PreparedStatement#setNString(int, String) | [
"Method",
"setNString",
"."
] | train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/dataSource/PoolablePreparedStatement.java#L857-L860 |
teatrove/teatrove | trove/src/main/java/org/teatrove/trove/classfile/ClassFile.java | ClassFile.addMethod | public MethodInfo addMethod(Modifiers modifiers,
String methodName,
TypeDesc ret,
TypeDesc... params) {
"""
Add a method to this class.
@param ret Is null if method returns void.
@param params May be null if method accepts no parameters.
"""
return addMethod(modifiers, methodName, null, ret, params);
} | java | public MethodInfo addMethod(Modifiers modifiers,
String methodName,
TypeDesc ret,
TypeDesc... params) {
return addMethod(modifiers, methodName, null, ret, params);
} | [
"public",
"MethodInfo",
"addMethod",
"(",
"Modifiers",
"modifiers",
",",
"String",
"methodName",
",",
"TypeDesc",
"ret",
",",
"TypeDesc",
"...",
"params",
")",
"{",
"return",
"addMethod",
"(",
"modifiers",
",",
"methodName",
",",
"null",
",",
"ret",
",",
"params",
")",
";",
"}"
] | Add a method to this class.
@param ret Is null if method returns void.
@param params May be null if method accepts no parameters. | [
"Add",
"a",
"method",
"to",
"this",
"class",
"."
] | train | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/ClassFile.java#L410-L415 |
OpenLiberty/open-liberty | dev/com.ibm.ws.logging.hpel/src/com/ibm/websphere/logging/hpel/reader/HpelFormatter.java | HpelFormatter.setDateFormat | public void setDateFormat(Locale locale, boolean isoDateFormat) {
"""
Sets the formatter locale and the dateFormat that will be used to localize a log record being formatted. The formatter locale will be used
when {@link #formatRecord(RepositoryLogRecord)} is invoked. It is possible to format a log record with a locale other than
one set by this method using {@link #formatRecord(RepositoryLogRecord, Locale)}. the formatter locale will be set to the system
locale until this method gets invoked. The dateFormat can be either the default format or the ISO-8601 format.
@param locale the Locale to be used for localizing the log record, <code>null</code> to disable message localization.
@param flag to use ISO-8601 date format for output.
"""
this.locale = locale;
if (null == locale) {
dateFormat = FormatSet.customizeDateFormat(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM), isoDateFormat);
} else {
dateFormat = FormatSet.customizeDateFormat(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, locale), isoDateFormat);
}
} | java | public void setDateFormat(Locale locale, boolean isoDateFormat) {
this.locale = locale;
if (null == locale) {
dateFormat = FormatSet.customizeDateFormat(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM), isoDateFormat);
} else {
dateFormat = FormatSet.customizeDateFormat(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, locale), isoDateFormat);
}
} | [
"public",
"void",
"setDateFormat",
"(",
"Locale",
"locale",
",",
"boolean",
"isoDateFormat",
")",
"{",
"this",
".",
"locale",
"=",
"locale",
";",
"if",
"(",
"null",
"==",
"locale",
")",
"{",
"dateFormat",
"=",
"FormatSet",
".",
"customizeDateFormat",
"(",
"DateFormat",
".",
"getDateTimeInstance",
"(",
"DateFormat",
".",
"SHORT",
",",
"DateFormat",
".",
"MEDIUM",
")",
",",
"isoDateFormat",
")",
";",
"}",
"else",
"{",
"dateFormat",
"=",
"FormatSet",
".",
"customizeDateFormat",
"(",
"DateFormat",
".",
"getDateTimeInstance",
"(",
"DateFormat",
".",
"SHORT",
",",
"DateFormat",
".",
"MEDIUM",
",",
"locale",
")",
",",
"isoDateFormat",
")",
";",
"}",
"}"
] | Sets the formatter locale and the dateFormat that will be used to localize a log record being formatted. The formatter locale will be used
when {@link #formatRecord(RepositoryLogRecord)} is invoked. It is possible to format a log record with a locale other than
one set by this method using {@link #formatRecord(RepositoryLogRecord, Locale)}. the formatter locale will be set to the system
locale until this method gets invoked. The dateFormat can be either the default format or the ISO-8601 format.
@param locale the Locale to be used for localizing the log record, <code>null</code> to disable message localization.
@param flag to use ISO-8601 date format for output. | [
"Sets",
"the",
"formatter",
"locale",
"and",
"the",
"dateFormat",
"that",
"will",
"be",
"used",
"to",
"localize",
"a",
"log",
"record",
"being",
"formatted",
".",
"The",
"formatter",
"locale",
"will",
"be",
"used",
"when",
"{",
"@link",
"#formatRecord",
"(",
"RepositoryLogRecord",
")",
"}",
"is",
"invoked",
".",
"It",
"is",
"possible",
"to",
"format",
"a",
"log",
"record",
"with",
"a",
"locale",
"other",
"than",
"one",
"set",
"by",
"this",
"method",
"using",
"{",
"@link",
"#formatRecord",
"(",
"RepositoryLogRecord",
"Locale",
")",
"}",
".",
"the",
"formatter",
"locale",
"will",
"be",
"set",
"to",
"the",
"system",
"locale",
"until",
"this",
"method",
"gets",
"invoked",
".",
"The",
"dateFormat",
"can",
"be",
"either",
"the",
"default",
"format",
"or",
"the",
"ISO",
"-",
"8601",
"format",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.logging.hpel/src/com/ibm/websphere/logging/hpel/reader/HpelFormatter.java#L307-L314 |
google/closure-compiler | src/com/google/javascript/jscomp/TypeCheck.java | TypeCheck.visitInterfacePropertyAssignment | private void visitInterfacePropertyAssignment(Node object, Node lvalue) {
"""
Visits an lvalue node for cases such as
<pre>
interface.prototype.property = ...;
</pre>
"""
if (!lvalue.getParent().isAssign()) {
// assignments to interface properties cannot be in destructuring patterns or for-of loops
reportInvalidInterfaceMemberDeclaration(object);
return;
}
Node assign = lvalue.getParent();
Node rvalue = assign.getSecondChild();
JSType rvalueType = getJSType(rvalue);
// Only 2 values are allowed for interface methods:
// goog.abstractMethod
// function () {};
// Other (non-method) interface properties must be stub declarations without assignments, e.g.
// someinterface.prototype.nonMethodProperty;
// which is why we enforce that `rvalueType.isFunctionType()`.
if (!rvalueType.isFunctionType()) {
reportInvalidInterfaceMemberDeclaration(object);
}
if (rvalue.isFunction() && !NodeUtil.isEmptyBlock(NodeUtil.getFunctionBody(rvalue))) {
String abstractMethodName = compiler.getCodingConvention().getAbstractMethodName();
compiler.report(JSError.make(object, INTERFACE_METHOD_NOT_EMPTY, abstractMethodName));
}
} | java | private void visitInterfacePropertyAssignment(Node object, Node lvalue) {
if (!lvalue.getParent().isAssign()) {
// assignments to interface properties cannot be in destructuring patterns or for-of loops
reportInvalidInterfaceMemberDeclaration(object);
return;
}
Node assign = lvalue.getParent();
Node rvalue = assign.getSecondChild();
JSType rvalueType = getJSType(rvalue);
// Only 2 values are allowed for interface methods:
// goog.abstractMethod
// function () {};
// Other (non-method) interface properties must be stub declarations without assignments, e.g.
// someinterface.prototype.nonMethodProperty;
// which is why we enforce that `rvalueType.isFunctionType()`.
if (!rvalueType.isFunctionType()) {
reportInvalidInterfaceMemberDeclaration(object);
}
if (rvalue.isFunction() && !NodeUtil.isEmptyBlock(NodeUtil.getFunctionBody(rvalue))) {
String abstractMethodName = compiler.getCodingConvention().getAbstractMethodName();
compiler.report(JSError.make(object, INTERFACE_METHOD_NOT_EMPTY, abstractMethodName));
}
} | [
"private",
"void",
"visitInterfacePropertyAssignment",
"(",
"Node",
"object",
",",
"Node",
"lvalue",
")",
"{",
"if",
"(",
"!",
"lvalue",
".",
"getParent",
"(",
")",
".",
"isAssign",
"(",
")",
")",
"{",
"// assignments to interface properties cannot be in destructuring patterns or for-of loops",
"reportInvalidInterfaceMemberDeclaration",
"(",
"object",
")",
";",
"return",
";",
"}",
"Node",
"assign",
"=",
"lvalue",
".",
"getParent",
"(",
")",
";",
"Node",
"rvalue",
"=",
"assign",
".",
"getSecondChild",
"(",
")",
";",
"JSType",
"rvalueType",
"=",
"getJSType",
"(",
"rvalue",
")",
";",
"// Only 2 values are allowed for interface methods:",
"// goog.abstractMethod",
"// function () {};",
"// Other (non-method) interface properties must be stub declarations without assignments, e.g.",
"// someinterface.prototype.nonMethodProperty;",
"// which is why we enforce that `rvalueType.isFunctionType()`.",
"if",
"(",
"!",
"rvalueType",
".",
"isFunctionType",
"(",
")",
")",
"{",
"reportInvalidInterfaceMemberDeclaration",
"(",
"object",
")",
";",
"}",
"if",
"(",
"rvalue",
".",
"isFunction",
"(",
")",
"&&",
"!",
"NodeUtil",
".",
"isEmptyBlock",
"(",
"NodeUtil",
".",
"getFunctionBody",
"(",
"rvalue",
")",
")",
")",
"{",
"String",
"abstractMethodName",
"=",
"compiler",
".",
"getCodingConvention",
"(",
")",
".",
"getAbstractMethodName",
"(",
")",
";",
"compiler",
".",
"report",
"(",
"JSError",
".",
"make",
"(",
"object",
",",
"INTERFACE_METHOD_NOT_EMPTY",
",",
"abstractMethodName",
")",
")",
";",
"}",
"}"
] | Visits an lvalue node for cases such as
<pre>
interface.prototype.property = ...;
</pre> | [
"Visits",
"an",
"lvalue",
"node",
"for",
"cases",
"such",
"as"
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/TypeCheck.java#L1801-L1825 |
aspectran/aspectran | core/src/main/java/com/aspectran/core/component/session/FileSessionDataStore.java | FileSessionDataStore.restoreAttributes | private void restoreAttributes(InputStream is, int size, SessionData data) throws Exception {
"""
Load attributes from an input stream that contains session data.
@param is the input stream containing session data
@param size number of attributes
@param data the data to restore to
@throws Exception if the input stream is invalid or fails to read
"""
if (size > 0) {
// input stream should not be closed here
Map<String, Object> attributes = new HashMap<>();
ObjectInputStream ois = new CustomObjectInputStream(is);
for (int i = 0; i < size; i++) {
String key = ois.readUTF();
Object value = ois.readObject();
attributes.put(key, value);
}
data.putAllAttributes(attributes);
}
} | java | private void restoreAttributes(InputStream is, int size, SessionData data) throws Exception {
if (size > 0) {
// input stream should not be closed here
Map<String, Object> attributes = new HashMap<>();
ObjectInputStream ois = new CustomObjectInputStream(is);
for (int i = 0; i < size; i++) {
String key = ois.readUTF();
Object value = ois.readObject();
attributes.put(key, value);
}
data.putAllAttributes(attributes);
}
} | [
"private",
"void",
"restoreAttributes",
"(",
"InputStream",
"is",
",",
"int",
"size",
",",
"SessionData",
"data",
")",
"throws",
"Exception",
"{",
"if",
"(",
"size",
">",
"0",
")",
"{",
"// input stream should not be closed here\r",
"Map",
"<",
"String",
",",
"Object",
">",
"attributes",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"ObjectInputStream",
"ois",
"=",
"new",
"CustomObjectInputStream",
"(",
"is",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"String",
"key",
"=",
"ois",
".",
"readUTF",
"(",
")",
";",
"Object",
"value",
"=",
"ois",
".",
"readObject",
"(",
")",
";",
"attributes",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"}",
"data",
".",
"putAllAttributes",
"(",
"attributes",
")",
";",
"}",
"}"
] | Load attributes from an input stream that contains session data.
@param is the input stream containing session data
@param size number of attributes
@param data the data to restore to
@throws Exception if the input stream is invalid or fails to read | [
"Load",
"attributes",
"from",
"an",
"input",
"stream",
"that",
"contains",
"session",
"data",
"."
] | train | https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/component/session/FileSessionDataStore.java#L394-L406 |
upwork/java-upwork | src/com/Upwork/api/Routers/Activities/Team.java | Team.addActivity | public JSONObject addActivity(String company, String team, HashMap<String, String> params) throws JSONException {
"""
Create an oTask/Activity record within a team
@param company Company ID
@param team Team ID
@param params Parameters
@throws JSONException If error occurred
@return {@link JSONObject}
"""
return oClient.post("/otask/v1/tasks/companies/" + company + "/teams/" + team + "/tasks", params);
} | java | public JSONObject addActivity(String company, String team, HashMap<String, String> params) throws JSONException {
return oClient.post("/otask/v1/tasks/companies/" + company + "/teams/" + team + "/tasks", params);
} | [
"public",
"JSONObject",
"addActivity",
"(",
"String",
"company",
",",
"String",
"team",
",",
"HashMap",
"<",
"String",
",",
"String",
">",
"params",
")",
"throws",
"JSONException",
"{",
"return",
"oClient",
".",
"post",
"(",
"\"/otask/v1/tasks/companies/\"",
"+",
"company",
"+",
"\"/teams/\"",
"+",
"team",
"+",
"\"/tasks\"",
",",
"params",
")",
";",
"}"
] | Create an oTask/Activity record within a team
@param company Company ID
@param team Team ID
@param params Parameters
@throws JSONException If error occurred
@return {@link JSONObject} | [
"Create",
"an",
"oTask",
"/",
"Activity",
"record",
"within",
"a",
"team"
] | train | https://github.com/upwork/java-upwork/blob/342297161503a74e9e0bddbd381ab5eebf4dc454/src/com/Upwork/api/Routers/Activities/Team.java#L97-L99 |
apache/groovy | subprojects/groovy-xml/src/main/java/groovy/xml/Namespace.java | Namespace.get | public QName get(String localName) {
"""
Returns the QName for the given localName.
@param localName
the local name within this
"""
if (uri != null && uri.length() > 0) {
if (prefix != null) {
return new QName(uri, localName, prefix);
}
else {
return new QName(uri, localName);
}
}
else {
return new QName(localName);
}
} | java | public QName get(String localName) {
if (uri != null && uri.length() > 0) {
if (prefix != null) {
return new QName(uri, localName, prefix);
}
else {
return new QName(uri, localName);
}
}
else {
return new QName(localName);
}
} | [
"public",
"QName",
"get",
"(",
"String",
"localName",
")",
"{",
"if",
"(",
"uri",
"!=",
"null",
"&&",
"uri",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"if",
"(",
"prefix",
"!=",
"null",
")",
"{",
"return",
"new",
"QName",
"(",
"uri",
",",
"localName",
",",
"prefix",
")",
";",
"}",
"else",
"{",
"return",
"new",
"QName",
"(",
"uri",
",",
"localName",
")",
";",
"}",
"}",
"else",
"{",
"return",
"new",
"QName",
"(",
"localName",
")",
";",
"}",
"}"
] | Returns the QName for the given localName.
@param localName
the local name within this | [
"Returns",
"the",
"QName",
"for",
"the",
"given",
"localName",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-xml/src/main/java/groovy/xml/Namespace.java#L48-L60 |
gallandarakhneorg/afc | core/maths/mathgen/src/main/java/org/arakhne/afc/math/MathUtil.java | MathUtil.getCohenSutherlandCode | @Pure
public static int getCohenSutherlandCode(int px, int py, int rxmin, int rymin, int rxmax, int rymax) {
"""
Compute the zone where the point is against the given rectangle
according to the <a href="http://en.wikipedia.org/wiki/Cohen%E2%80%93Sutherland_algorithm">Cohen-Sutherland algorithm</a>.
@param px is the coordinates of the points.
@param py is the coordinates of the points.
@param rxmin is the min of the coordinates of the rectangle.
@param rymin is the min of the coordinates of the rectangle.
@param rxmax is the max of the coordinates of the rectangle.
@param rymax is the max of the coordinates of the rectangle.
@return the zone
@see MathConstants#COHEN_SUTHERLAND_BOTTOM
@see MathConstants#COHEN_SUTHERLAND_TOP
@see MathConstants#COHEN_SUTHERLAND_LEFT
@see MathConstants#COHEN_SUTHERLAND_RIGHT
@see MathConstants#COHEN_SUTHERLAND_INSIDE
"""
assert rxmin <= rxmax : AssertMessages.lowerEqualParameters(2, rxmin, 4, rxmax);
assert rymin <= rymax : AssertMessages.lowerEqualParameters(3, rymin, 5, rymax);
// initialised as being inside of clip window
int code = COHEN_SUTHERLAND_INSIDE;
if (px < rxmin) {
// to the left of clip window
code |= COHEN_SUTHERLAND_LEFT;
}
if (px > rxmax) {
// to the right of clip window
code |= COHEN_SUTHERLAND_RIGHT;
}
if (py < rymin) {
// to the bottom of clip window
code |= COHEN_SUTHERLAND_BOTTOM;
}
if (py > rymax) {
// to the top of clip window
code |= COHEN_SUTHERLAND_TOP;
}
return code;
} | java | @Pure
public static int getCohenSutherlandCode(int px, int py, int rxmin, int rymin, int rxmax, int rymax) {
assert rxmin <= rxmax : AssertMessages.lowerEqualParameters(2, rxmin, 4, rxmax);
assert rymin <= rymax : AssertMessages.lowerEqualParameters(3, rymin, 5, rymax);
// initialised as being inside of clip window
int code = COHEN_SUTHERLAND_INSIDE;
if (px < rxmin) {
// to the left of clip window
code |= COHEN_SUTHERLAND_LEFT;
}
if (px > rxmax) {
// to the right of clip window
code |= COHEN_SUTHERLAND_RIGHT;
}
if (py < rymin) {
// to the bottom of clip window
code |= COHEN_SUTHERLAND_BOTTOM;
}
if (py > rymax) {
// to the top of clip window
code |= COHEN_SUTHERLAND_TOP;
}
return code;
} | [
"@",
"Pure",
"public",
"static",
"int",
"getCohenSutherlandCode",
"(",
"int",
"px",
",",
"int",
"py",
",",
"int",
"rxmin",
",",
"int",
"rymin",
",",
"int",
"rxmax",
",",
"int",
"rymax",
")",
"{",
"assert",
"rxmin",
"<=",
"rxmax",
":",
"AssertMessages",
".",
"lowerEqualParameters",
"(",
"2",
",",
"rxmin",
",",
"4",
",",
"rxmax",
")",
";",
"assert",
"rymin",
"<=",
"rymax",
":",
"AssertMessages",
".",
"lowerEqualParameters",
"(",
"3",
",",
"rymin",
",",
"5",
",",
"rymax",
")",
";",
"// initialised as being inside of clip window",
"int",
"code",
"=",
"COHEN_SUTHERLAND_INSIDE",
";",
"if",
"(",
"px",
"<",
"rxmin",
")",
"{",
"// to the left of clip window",
"code",
"|=",
"COHEN_SUTHERLAND_LEFT",
";",
"}",
"if",
"(",
"px",
">",
"rxmax",
")",
"{",
"// to the right of clip window",
"code",
"|=",
"COHEN_SUTHERLAND_RIGHT",
";",
"}",
"if",
"(",
"py",
"<",
"rymin",
")",
"{",
"// to the bottom of clip window",
"code",
"|=",
"COHEN_SUTHERLAND_BOTTOM",
";",
"}",
"if",
"(",
"py",
">",
"rymax",
")",
"{",
"// to the top of clip window",
"code",
"|=",
"COHEN_SUTHERLAND_TOP",
";",
"}",
"return",
"code",
";",
"}"
] | Compute the zone where the point is against the given rectangle
according to the <a href="http://en.wikipedia.org/wiki/Cohen%E2%80%93Sutherland_algorithm">Cohen-Sutherland algorithm</a>.
@param px is the coordinates of the points.
@param py is the coordinates of the points.
@param rxmin is the min of the coordinates of the rectangle.
@param rymin is the min of the coordinates of the rectangle.
@param rxmax is the max of the coordinates of the rectangle.
@param rymax is the max of the coordinates of the rectangle.
@return the zone
@see MathConstants#COHEN_SUTHERLAND_BOTTOM
@see MathConstants#COHEN_SUTHERLAND_TOP
@see MathConstants#COHEN_SUTHERLAND_LEFT
@see MathConstants#COHEN_SUTHERLAND_RIGHT
@see MathConstants#COHEN_SUTHERLAND_INSIDE | [
"Compute",
"the",
"zone",
"where",
"the",
"point",
"is",
"against",
"the",
"given",
"rectangle",
"according",
"to",
"the",
"<a",
"href",
"=",
"http",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Cohen%E2%80%93Sutherland_algorithm",
">",
"Cohen",
"-",
"Sutherland",
"algorithm<",
"/",
"a",
">",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgen/src/main/java/org/arakhne/afc/math/MathUtil.java#L489-L512 |
carewebframework/carewebframework-core | org.carewebframework.shell/src/main/java/org/carewebframework/shell/CareWebShellEx.java | CareWebShellEx.registerLayout | public void registerLayout(String path, String resource) throws Exception {
"""
Registers a layout at the specified path.
@param path Format is <tab name>\<tree node path>
@param resource Location of the xml layout.
@throws Exception Unspecified exception.
"""
Layout layout = LayoutParser.parseResource(resource);
ElementUI parent = parentFromPath(path);
if (parent != null) {
layout.materialize(parent);
}
} | java | public void registerLayout(String path, String resource) throws Exception {
Layout layout = LayoutParser.parseResource(resource);
ElementUI parent = parentFromPath(path);
if (parent != null) {
layout.materialize(parent);
}
} | [
"public",
"void",
"registerLayout",
"(",
"String",
"path",
",",
"String",
"resource",
")",
"throws",
"Exception",
"{",
"Layout",
"layout",
"=",
"LayoutParser",
".",
"parseResource",
"(",
"resource",
")",
";",
"ElementUI",
"parent",
"=",
"parentFromPath",
"(",
"path",
")",
";",
"if",
"(",
"parent",
"!=",
"null",
")",
"{",
"layout",
".",
"materialize",
"(",
"parent",
")",
";",
"}",
"}"
] | Registers a layout at the specified path.
@param path Format is <tab name>\<tree node path>
@param resource Location of the xml layout.
@throws Exception Unspecified exception. | [
"Registers",
"a",
"layout",
"at",
"the",
"specified",
"path",
"."
] | train | https://github.com/carewebframework/carewebframework-core/blob/fa3252d4f7541dbe151b92c3d4f6f91433cd1673/org.carewebframework.shell/src/main/java/org/carewebframework/shell/CareWebShellEx.java#L311-L318 |
menacher/java-game-server | jetserver/src/main/java/org/menacheri/jetserver/util/NettyUtils.java | NettyUtils.readSocketAddress | public static InetSocketAddress readSocketAddress(ChannelBuffer buffer) {
"""
Read a socket address from a buffer. The socket address will be provided
as two strings containing host and port.
@param buffer
The buffer containing the host and port as string.
@return The InetSocketAddress object created from host and port or null
in case the strings are not there.
"""
String remoteHost = NettyUtils.readString(buffer);
int remotePort = 0;
if (buffer.readableBytes() >= 4)
{
remotePort = buffer.readInt();
}
else
{
return null;
}
InetSocketAddress remoteAddress = null;
if (null != remoteHost)
{
remoteAddress = new InetSocketAddress(remoteHost, remotePort);
}
return remoteAddress;
} | java | public static InetSocketAddress readSocketAddress(ChannelBuffer buffer)
{
String remoteHost = NettyUtils.readString(buffer);
int remotePort = 0;
if (buffer.readableBytes() >= 4)
{
remotePort = buffer.readInt();
}
else
{
return null;
}
InetSocketAddress remoteAddress = null;
if (null != remoteHost)
{
remoteAddress = new InetSocketAddress(remoteHost, remotePort);
}
return remoteAddress;
} | [
"public",
"static",
"InetSocketAddress",
"readSocketAddress",
"(",
"ChannelBuffer",
"buffer",
")",
"{",
"String",
"remoteHost",
"=",
"NettyUtils",
".",
"readString",
"(",
"buffer",
")",
";",
"int",
"remotePort",
"=",
"0",
";",
"if",
"(",
"buffer",
".",
"readableBytes",
"(",
")",
">=",
"4",
")",
"{",
"remotePort",
"=",
"buffer",
".",
"readInt",
"(",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"InetSocketAddress",
"remoteAddress",
"=",
"null",
";",
"if",
"(",
"null",
"!=",
"remoteHost",
")",
"{",
"remoteAddress",
"=",
"new",
"InetSocketAddress",
"(",
"remoteHost",
",",
"remotePort",
")",
";",
"}",
"return",
"remoteAddress",
";",
"}"
] | Read a socket address from a buffer. The socket address will be provided
as two strings containing host and port.
@param buffer
The buffer containing the host and port as string.
@return The InetSocketAddress object created from host and port or null
in case the strings are not there. | [
"Read",
"a",
"socket",
"address",
"from",
"a",
"buffer",
".",
"The",
"socket",
"address",
"will",
"be",
"provided",
"as",
"two",
"strings",
"containing",
"host",
"and",
"port",
"."
] | train | https://github.com/menacher/java-game-server/blob/668ca49e8bd1dac43add62378cf6c22a93125d48/jetserver/src/main/java/org/menacheri/jetserver/util/NettyUtils.java#L384-L402 |
rundeck/rundeck | core/src/main/java/com/dtolabs/rundeck/core/utils/StringArrayUtil.java | StringArrayUtil.asString | public static String asString(final Object[] input, final String delim) {
"""
Format an array of objects as a string separated by a delimiter by calling toString on each object
@param input List to format
@param delim delimiter string to insert between elements
@return formatted string
"""
final StringBuffer sb = new StringBuffer();
for (int i = 0 ; i < input.length ; i++) {
if (i > 0) {
sb.append(delim);
}
sb.append(input[i].toString());
}
return sb.toString();
} | java | public static String asString(final Object[] input, final String delim) {
final StringBuffer sb = new StringBuffer();
for (int i = 0 ; i < input.length ; i++) {
if (i > 0) {
sb.append(delim);
}
sb.append(input[i].toString());
}
return sb.toString();
} | [
"public",
"static",
"String",
"asString",
"(",
"final",
"Object",
"[",
"]",
"input",
",",
"final",
"String",
"delim",
")",
"{",
"final",
"StringBuffer",
"sb",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"input",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"i",
">",
"0",
")",
"{",
"sb",
".",
"append",
"(",
"delim",
")",
";",
"}",
"sb",
".",
"append",
"(",
"input",
"[",
"i",
"]",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] | Format an array of objects as a string separated by a delimiter by calling toString on each object
@param input List to format
@param delim delimiter string to insert between elements
@return formatted string | [
"Format",
"an",
"array",
"of",
"objects",
"as",
"a",
"string",
"separated",
"by",
"a",
"delimiter",
"by",
"calling",
"toString",
"on",
"each",
"object"
] | train | https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/StringArrayUtil.java#L63-L72 |
elki-project/elki | elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkcop/MkCoPTreeNode.java | MkCoPTreeNode.progressiveKnnDistanceApproximation | protected ApproximationLine progressiveKnnDistanceApproximation(int k_max) {
"""
Determines and returns the progressive approximation for the knn distances
of this node as the maximum of the progressive approximations of all
entries.
@param k_max the maximum k parameter
@return the conservative approximation for the knn distances
"""
if(!isLeaf()) {
throw new UnsupportedOperationException("Progressive KNN-distance approximation " + "is only vailable in leaf nodes!");
}
// determine k_0, y_1, y_kmax
int k_0 = 0;
double y_1 = Double.POSITIVE_INFINITY;
double y_kmax = Double.POSITIVE_INFINITY;
for(int i = 0; i < getNumEntries(); i++) {
MkCoPLeafEntry entry = (MkCoPLeafEntry) getEntry(i);
ApproximationLine approx = entry.getProgressiveKnnDistanceApproximation();
k_0 = Math.max(approx.getK_0(), k_0);
}
for(int i = 0; i < getNumEntries(); i++) {
MkCoPLeafEntry entry = (MkCoPLeafEntry) getEntry(i);
ApproximationLine approx = entry.getProgressiveKnnDistanceApproximation();
y_1 = Math.min(approx.getValueAt(k_0), y_1);
y_kmax = Math.min(approx.getValueAt(k_max), y_kmax);
}
// determine m and t
double m = (y_kmax - y_1) / (FastMath.log(k_max) - FastMath.log(k_0));
double t = y_1 - m * FastMath.log(k_0);
return new ApproximationLine(k_0, m, t);
} | java | protected ApproximationLine progressiveKnnDistanceApproximation(int k_max) {
if(!isLeaf()) {
throw new UnsupportedOperationException("Progressive KNN-distance approximation " + "is only vailable in leaf nodes!");
}
// determine k_0, y_1, y_kmax
int k_0 = 0;
double y_1 = Double.POSITIVE_INFINITY;
double y_kmax = Double.POSITIVE_INFINITY;
for(int i = 0; i < getNumEntries(); i++) {
MkCoPLeafEntry entry = (MkCoPLeafEntry) getEntry(i);
ApproximationLine approx = entry.getProgressiveKnnDistanceApproximation();
k_0 = Math.max(approx.getK_0(), k_0);
}
for(int i = 0; i < getNumEntries(); i++) {
MkCoPLeafEntry entry = (MkCoPLeafEntry) getEntry(i);
ApproximationLine approx = entry.getProgressiveKnnDistanceApproximation();
y_1 = Math.min(approx.getValueAt(k_0), y_1);
y_kmax = Math.min(approx.getValueAt(k_max), y_kmax);
}
// determine m and t
double m = (y_kmax - y_1) / (FastMath.log(k_max) - FastMath.log(k_0));
double t = y_1 - m * FastMath.log(k_0);
return new ApproximationLine(k_0, m, t);
} | [
"protected",
"ApproximationLine",
"progressiveKnnDistanceApproximation",
"(",
"int",
"k_max",
")",
"{",
"if",
"(",
"!",
"isLeaf",
"(",
")",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Progressive KNN-distance approximation \"",
"+",
"\"is only vailable in leaf nodes!\"",
")",
";",
"}",
"// determine k_0, y_1, y_kmax",
"int",
"k_0",
"=",
"0",
";",
"double",
"y_1",
"=",
"Double",
".",
"POSITIVE_INFINITY",
";",
"double",
"y_kmax",
"=",
"Double",
".",
"POSITIVE_INFINITY",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"getNumEntries",
"(",
")",
";",
"i",
"++",
")",
"{",
"MkCoPLeafEntry",
"entry",
"=",
"(",
"MkCoPLeafEntry",
")",
"getEntry",
"(",
"i",
")",
";",
"ApproximationLine",
"approx",
"=",
"entry",
".",
"getProgressiveKnnDistanceApproximation",
"(",
")",
";",
"k_0",
"=",
"Math",
".",
"max",
"(",
"approx",
".",
"getK_0",
"(",
")",
",",
"k_0",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"getNumEntries",
"(",
")",
";",
"i",
"++",
")",
"{",
"MkCoPLeafEntry",
"entry",
"=",
"(",
"MkCoPLeafEntry",
")",
"getEntry",
"(",
"i",
")",
";",
"ApproximationLine",
"approx",
"=",
"entry",
".",
"getProgressiveKnnDistanceApproximation",
"(",
")",
";",
"y_1",
"=",
"Math",
".",
"min",
"(",
"approx",
".",
"getValueAt",
"(",
"k_0",
")",
",",
"y_1",
")",
";",
"y_kmax",
"=",
"Math",
".",
"min",
"(",
"approx",
".",
"getValueAt",
"(",
"k_max",
")",
",",
"y_kmax",
")",
";",
"}",
"// determine m and t",
"double",
"m",
"=",
"(",
"y_kmax",
"-",
"y_1",
")",
"/",
"(",
"FastMath",
".",
"log",
"(",
"k_max",
")",
"-",
"FastMath",
".",
"log",
"(",
"k_0",
")",
")",
";",
"double",
"t",
"=",
"y_1",
"-",
"m",
"*",
"FastMath",
".",
"log",
"(",
"k_0",
")",
";",
"return",
"new",
"ApproximationLine",
"(",
"k_0",
",",
"m",
",",
"t",
")",
";",
"}"
] | Determines and returns the progressive approximation for the knn distances
of this node as the maximum of the progressive approximations of all
entries.
@param k_max the maximum k parameter
@return the conservative approximation for the knn distances | [
"Determines",
"and",
"returns",
"the",
"progressive",
"approximation",
"for",
"the",
"knn",
"distances",
"of",
"this",
"node",
"as",
"the",
"maximum",
"of",
"the",
"progressive",
"approximations",
"of",
"all",
"entries",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkcop/MkCoPTreeNode.java#L111-L139 |
marvinlabs/android-intents | library/src/main/java/com/marvinlabs/intents/GeoIntents.java | GeoIntents.newMapsIntent | public static Intent newMapsIntent(String address, String placeTitle) {
"""
Intent that should allow opening a map showing the given address (if it exists)
@param address The address to search
@param placeTitle The title to show on the marker
@return the intent
"""
StringBuilder sb = new StringBuilder();
sb.append("geo:0,0?q=");
String addressEncoded = Uri.encode(address);
sb.append(addressEncoded);
// pass text for the info window
String titleEncoded = Uri.encode(" (" + placeTitle + ")");
sb.append(titleEncoded);
return new Intent(Intent.ACTION_VIEW, Uri.parse(sb.toString()));
} | java | public static Intent newMapsIntent(String address, String placeTitle) {
StringBuilder sb = new StringBuilder();
sb.append("geo:0,0?q=");
String addressEncoded = Uri.encode(address);
sb.append(addressEncoded);
// pass text for the info window
String titleEncoded = Uri.encode(" (" + placeTitle + ")");
sb.append(titleEncoded);
return new Intent(Intent.ACTION_VIEW, Uri.parse(sb.toString()));
} | [
"public",
"static",
"Intent",
"newMapsIntent",
"(",
"String",
"address",
",",
"String",
"placeTitle",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sb",
".",
"append",
"(",
"\"geo:0,0?q=\"",
")",
";",
"String",
"addressEncoded",
"=",
"Uri",
".",
"encode",
"(",
"address",
")",
";",
"sb",
".",
"append",
"(",
"addressEncoded",
")",
";",
"// pass text for the info window",
"String",
"titleEncoded",
"=",
"Uri",
".",
"encode",
"(",
"\" (\"",
"+",
"placeTitle",
"+",
"\")\"",
")",
";",
"sb",
".",
"append",
"(",
"titleEncoded",
")",
";",
"return",
"new",
"Intent",
"(",
"Intent",
".",
"ACTION_VIEW",
",",
"Uri",
".",
"parse",
"(",
"sb",
".",
"toString",
"(",
")",
")",
")",
";",
"}"
] | Intent that should allow opening a map showing the given address (if it exists)
@param address The address to search
@param placeTitle The title to show on the marker
@return the intent | [
"Intent",
"that",
"should",
"allow",
"opening",
"a",
"map",
"showing",
"the",
"given",
"address",
"(",
"if",
"it",
"exists",
")"
] | train | https://github.com/marvinlabs/android-intents/blob/33e79c825188b6a97601869522533cc825801f6e/library/src/main/java/com/marvinlabs/intents/GeoIntents.java#L37-L49 |
ManfredTremmel/gwt-commons-lang3 | src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java | FieldUtils.writeField | public static void writeField(final Field field, final Object target, final Object value, final boolean forceAccess)
throws IllegalAccessException {
"""
Writes a {@link Field}.
@param field
to write
@param target
the object to call on, may be {@code null} for {@code static} fields
@param value
to set
@param forceAccess
whether to break scope restrictions using the
{@link java.lang.reflect.AccessibleObject#setAccessible(boolean)} method. {@code false} will only
match {@code public} fields.
@throws IllegalArgumentException
if the field is {@code null} or {@code value} is not assignable
@throws IllegalAccessException
if the field is not made accessible or is {@code final}
"""
Validate.isTrue(field != null, "The field must not be null");
if (forceAccess && !field.isAccessible()) {
field.setAccessible(true);
} else {
MemberUtils.setAccessibleWorkaround(field);
}
field.set(target, value);
} | java | public static void writeField(final Field field, final Object target, final Object value, final boolean forceAccess)
throws IllegalAccessException {
Validate.isTrue(field != null, "The field must not be null");
if (forceAccess && !field.isAccessible()) {
field.setAccessible(true);
} else {
MemberUtils.setAccessibleWorkaround(field);
}
field.set(target, value);
} | [
"public",
"static",
"void",
"writeField",
"(",
"final",
"Field",
"field",
",",
"final",
"Object",
"target",
",",
"final",
"Object",
"value",
",",
"final",
"boolean",
"forceAccess",
")",
"throws",
"IllegalAccessException",
"{",
"Validate",
".",
"isTrue",
"(",
"field",
"!=",
"null",
",",
"\"The field must not be null\"",
")",
";",
"if",
"(",
"forceAccess",
"&&",
"!",
"field",
".",
"isAccessible",
"(",
")",
")",
"{",
"field",
".",
"setAccessible",
"(",
"true",
")",
";",
"}",
"else",
"{",
"MemberUtils",
".",
"setAccessibleWorkaround",
"(",
"field",
")",
";",
"}",
"field",
".",
"set",
"(",
"target",
",",
"value",
")",
";",
"}"
] | Writes a {@link Field}.
@param field
to write
@param target
the object to call on, may be {@code null} for {@code static} fields
@param value
to set
@param forceAccess
whether to break scope restrictions using the
{@link java.lang.reflect.AccessibleObject#setAccessible(boolean)} method. {@code false} will only
match {@code public} fields.
@throws IllegalArgumentException
if the field is {@code null} or {@code value} is not assignable
@throws IllegalAccessException
if the field is not made accessible or is {@code final} | [
"Writes",
"a",
"{",
"@link",
"Field",
"}",
"."
] | train | https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java#L683-L692 |
haifengl/smile | math/src/main/java/smile/math/special/Gamma.java | Gamma.regularizedUpperIncompleteGamma | public static double regularizedUpperIncompleteGamma(double s, double x) {
"""
Regularized Upper/Complementary Incomplete Gamma Function
Q(s,x) = 1 - P(s,x) = 1 - <i><big>∫</big><sub><small>0</small></sub><sup><small>x</small></sup> e<sup>-t</sup> t<sup>(s-1)</sup> dt</i>
"""
if (s < 0.0) {
throw new IllegalArgumentException("Invalid s: " + s);
}
if (x < 0.0) {
throw new IllegalArgumentException("Invalid x: " + x);
}
double igf = 0.0;
if (x != 0.0) {
if (x == 1.0 / 0.0) {
igf = 1.0;
} else {
if (x < s + 1.0) {
// Series representation
igf = 1.0 - regularizedIncompleteGammaSeries(s, x);
} else {
// Continued fraction representation
igf = 1.0 - regularizedIncompleteGammaFraction(s, x);
}
}
}
return igf;
} | java | public static double regularizedUpperIncompleteGamma(double s, double x) {
if (s < 0.0) {
throw new IllegalArgumentException("Invalid s: " + s);
}
if (x < 0.0) {
throw new IllegalArgumentException("Invalid x: " + x);
}
double igf = 0.0;
if (x != 0.0) {
if (x == 1.0 / 0.0) {
igf = 1.0;
} else {
if (x < s + 1.0) {
// Series representation
igf = 1.0 - regularizedIncompleteGammaSeries(s, x);
} else {
// Continued fraction representation
igf = 1.0 - regularizedIncompleteGammaFraction(s, x);
}
}
}
return igf;
} | [
"public",
"static",
"double",
"regularizedUpperIncompleteGamma",
"(",
"double",
"s",
",",
"double",
"x",
")",
"{",
"if",
"(",
"s",
"<",
"0.0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid s: \"",
"+",
"s",
")",
";",
"}",
"if",
"(",
"x",
"<",
"0.0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid x: \"",
"+",
"x",
")",
";",
"}",
"double",
"igf",
"=",
"0.0",
";",
"if",
"(",
"x",
"!=",
"0.0",
")",
"{",
"if",
"(",
"x",
"==",
"1.0",
"/",
"0.0",
")",
"{",
"igf",
"=",
"1.0",
";",
"}",
"else",
"{",
"if",
"(",
"x",
"<",
"s",
"+",
"1.0",
")",
"{",
"// Series representation",
"igf",
"=",
"1.0",
"-",
"regularizedIncompleteGammaSeries",
"(",
"s",
",",
"x",
")",
";",
"}",
"else",
"{",
"// Continued fraction representation",
"igf",
"=",
"1.0",
"-",
"regularizedIncompleteGammaFraction",
"(",
"s",
",",
"x",
")",
";",
"}",
"}",
"}",
"return",
"igf",
";",
"}"
] | Regularized Upper/Complementary Incomplete Gamma Function
Q(s,x) = 1 - P(s,x) = 1 - <i><big>∫</big><sub><small>0</small></sub><sup><small>x</small></sup> e<sup>-t</sup> t<sup>(s-1)</sup> dt</i> | [
"Regularized",
"Upper",
"/",
"Complementary",
"Incomplete",
"Gamma",
"Function",
"Q",
"(",
"s",
"x",
")",
"=",
"1",
"-",
"P",
"(",
"s",
"x",
")",
"=",
"1",
"-",
"<i",
">",
"<big",
">",
"∫",
";",
"<",
"/",
"big",
">",
"<sub",
">",
"<small",
">",
"0<",
"/",
"small",
">",
"<",
"/",
"sub",
">",
"<sup",
">",
"<small",
">",
"x<",
"/",
"small",
">",
"<",
"/",
"sup",
">",
"e<sup",
">",
"-",
"t<",
"/",
"sup",
">",
"t<sup",
">",
"(",
"s",
"-",
"1",
")",
"<",
"/",
"sup",
">",
"dt<",
"/",
"i",
">"
] | train | https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/math/src/main/java/smile/math/special/Gamma.java#L148-L173 |
Netflix/eureka | eureka-core/src/main/java/com/netflix/eureka/aws/AwsAsgUtil.java | AwsAsgUtil.isASGEnabled | public boolean isASGEnabled(InstanceInfo instanceInfo) {
"""
Return the status of the ASG whether is enabled or disabled for service.
The value is picked up from the cache except the very first time.
@param instanceInfo the instanceInfo for the lookup
@return true if enabled, false otherwise
"""
CacheKey cacheKey = new CacheKey(getAccountId(instanceInfo, accountId), instanceInfo.getASGName());
Boolean result = asgCache.getIfPresent(cacheKey);
if (result != null) {
return result;
} else {
if (!serverConfig.shouldUseAwsAsgApi()) {
// Disabled, cached values (if any) are still being returned if the caller makes
// a decision to call the disabled client during some sort of transitioning
// period, but no new values will be fetched while disabled.
logger.info(("'{}' is not cached at the moment and won't be fetched because querying AWS ASGs "
+ "has been disabled via the config, returning the fallback value."),
cacheKey);
return true;
}
logger.info("Cache value for asg {} does not exist yet, async refreshing.", cacheKey.asgName);
// Only do an async refresh if it does not yet exist. Do this to refrain from calling aws api too much
asgCache.refresh(cacheKey);
return true;
}
} | java | public boolean isASGEnabled(InstanceInfo instanceInfo) {
CacheKey cacheKey = new CacheKey(getAccountId(instanceInfo, accountId), instanceInfo.getASGName());
Boolean result = asgCache.getIfPresent(cacheKey);
if (result != null) {
return result;
} else {
if (!serverConfig.shouldUseAwsAsgApi()) {
// Disabled, cached values (if any) are still being returned if the caller makes
// a decision to call the disabled client during some sort of transitioning
// period, but no new values will be fetched while disabled.
logger.info(("'{}' is not cached at the moment and won't be fetched because querying AWS ASGs "
+ "has been disabled via the config, returning the fallback value."),
cacheKey);
return true;
}
logger.info("Cache value for asg {} does not exist yet, async refreshing.", cacheKey.asgName);
// Only do an async refresh if it does not yet exist. Do this to refrain from calling aws api too much
asgCache.refresh(cacheKey);
return true;
}
} | [
"public",
"boolean",
"isASGEnabled",
"(",
"InstanceInfo",
"instanceInfo",
")",
"{",
"CacheKey",
"cacheKey",
"=",
"new",
"CacheKey",
"(",
"getAccountId",
"(",
"instanceInfo",
",",
"accountId",
")",
",",
"instanceInfo",
".",
"getASGName",
"(",
")",
")",
";",
"Boolean",
"result",
"=",
"asgCache",
".",
"getIfPresent",
"(",
"cacheKey",
")",
";",
"if",
"(",
"result",
"!=",
"null",
")",
"{",
"return",
"result",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"serverConfig",
".",
"shouldUseAwsAsgApi",
"(",
")",
")",
"{",
"// Disabled, cached values (if any) are still being returned if the caller makes",
"// a decision to call the disabled client during some sort of transitioning",
"// period, but no new values will be fetched while disabled.",
"logger",
".",
"info",
"(",
"(",
"\"'{}' is not cached at the moment and won't be fetched because querying AWS ASGs \"",
"+",
"\"has been disabled via the config, returning the fallback value.\"",
")",
",",
"cacheKey",
")",
";",
"return",
"true",
";",
"}",
"logger",
".",
"info",
"(",
"\"Cache value for asg {} does not exist yet, async refreshing.\"",
",",
"cacheKey",
".",
"asgName",
")",
";",
"// Only do an async refresh if it does not yet exist. Do this to refrain from calling aws api too much",
"asgCache",
".",
"refresh",
"(",
"cacheKey",
")",
";",
"return",
"true",
";",
"}",
"}"
] | Return the status of the ASG whether is enabled or disabled for service.
The value is picked up from the cache except the very first time.
@param instanceInfo the instanceInfo for the lookup
@return true if enabled, false otherwise | [
"Return",
"the",
"status",
"of",
"the",
"ASG",
"whether",
"is",
"enabled",
"or",
"disabled",
"for",
"service",
".",
"The",
"value",
"is",
"picked",
"up",
"from",
"the",
"cache",
"except",
"the",
"very",
"first",
"time",
"."
] | train | https://github.com/Netflix/eureka/blob/48446d956be09df6650a3c00b7ebd7e2d1e1544f/eureka-core/src/main/java/com/netflix/eureka/aws/AwsAsgUtil.java#L162-L185 |
apache/flink | flink-libraries/flink-streaming-python/src/main/java/org/apache/flink/streaming/python/util/InterpreterUtils.java | InterpreterUtils.deserializeFunction | @SuppressWarnings("unchecked")
public static <X> X deserializeFunction(RuntimeContext context, byte[] serFun) throws FlinkException {
"""
Deserialize the given python function. If the functions class definition cannot be found we assume that this is
the first invocation of this method for a given job and load the python script containing the class definition
via jython.
@param context the RuntimeContext of the java function
@param serFun serialized python UDF
@return deserialized python UDF
@throws FlinkException if the deserialization failed
"""
if (!jythonInitialized) {
// This branch is only tested by end-to-end tests
String path = context.getDistributedCache().getFile(PythonConstants.FLINK_PYTHON_DC_ID).getAbsolutePath();
String scriptName = PythonStreamExecutionEnvironment.PythonJobParameters.getScriptName(context.getExecutionConfig().getGlobalJobParameters());
try {
initPythonInterpreter(
new String[]{Paths.get(path, scriptName).toString()},
path,
scriptName);
} catch (Exception e) {
try {
LOG.error("Initialization of jython failed.", e);
throw new FlinkRuntimeException("Initialization of jython failed.", e);
} catch (Exception ie) {
// this may occur if the initial exception relies on jython being initialized properly
LOG.error("Initialization of jython failed. Could not print original stacktrace.", ie);
throw new FlinkRuntimeException("Initialization of jython failed. Could not print original stacktrace.");
}
}
}
try {
return (X) SerializationUtils.deserializeObject(serFun);
} catch (IOException | ClassNotFoundException ex) {
throw new FlinkException("Deserialization of user-function failed.", ex);
}
} | java | @SuppressWarnings("unchecked")
public static <X> X deserializeFunction(RuntimeContext context, byte[] serFun) throws FlinkException {
if (!jythonInitialized) {
// This branch is only tested by end-to-end tests
String path = context.getDistributedCache().getFile(PythonConstants.FLINK_PYTHON_DC_ID).getAbsolutePath();
String scriptName = PythonStreamExecutionEnvironment.PythonJobParameters.getScriptName(context.getExecutionConfig().getGlobalJobParameters());
try {
initPythonInterpreter(
new String[]{Paths.get(path, scriptName).toString()},
path,
scriptName);
} catch (Exception e) {
try {
LOG.error("Initialization of jython failed.", e);
throw new FlinkRuntimeException("Initialization of jython failed.", e);
} catch (Exception ie) {
// this may occur if the initial exception relies on jython being initialized properly
LOG.error("Initialization of jython failed. Could not print original stacktrace.", ie);
throw new FlinkRuntimeException("Initialization of jython failed. Could not print original stacktrace.");
}
}
}
try {
return (X) SerializationUtils.deserializeObject(serFun);
} catch (IOException | ClassNotFoundException ex) {
throw new FlinkException("Deserialization of user-function failed.", ex);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"X",
">",
"X",
"deserializeFunction",
"(",
"RuntimeContext",
"context",
",",
"byte",
"[",
"]",
"serFun",
")",
"throws",
"FlinkException",
"{",
"if",
"(",
"!",
"jythonInitialized",
")",
"{",
"// This branch is only tested by end-to-end tests",
"String",
"path",
"=",
"context",
".",
"getDistributedCache",
"(",
")",
".",
"getFile",
"(",
"PythonConstants",
".",
"FLINK_PYTHON_DC_ID",
")",
".",
"getAbsolutePath",
"(",
")",
";",
"String",
"scriptName",
"=",
"PythonStreamExecutionEnvironment",
".",
"PythonJobParameters",
".",
"getScriptName",
"(",
"context",
".",
"getExecutionConfig",
"(",
")",
".",
"getGlobalJobParameters",
"(",
")",
")",
";",
"try",
"{",
"initPythonInterpreter",
"(",
"new",
"String",
"[",
"]",
"{",
"Paths",
".",
"get",
"(",
"path",
",",
"scriptName",
")",
".",
"toString",
"(",
")",
"}",
",",
"path",
",",
"scriptName",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"try",
"{",
"LOG",
".",
"error",
"(",
"\"Initialization of jython failed.\"",
",",
"e",
")",
";",
"throw",
"new",
"FlinkRuntimeException",
"(",
"\"Initialization of jython failed.\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"Exception",
"ie",
")",
"{",
"// this may occur if the initial exception relies on jython being initialized properly",
"LOG",
".",
"error",
"(",
"\"Initialization of jython failed. Could not print original stacktrace.\"",
",",
"ie",
")",
";",
"throw",
"new",
"FlinkRuntimeException",
"(",
"\"Initialization of jython failed. Could not print original stacktrace.\"",
")",
";",
"}",
"}",
"}",
"try",
"{",
"return",
"(",
"X",
")",
"SerializationUtils",
".",
"deserializeObject",
"(",
"serFun",
")",
";",
"}",
"catch",
"(",
"IOException",
"|",
"ClassNotFoundException",
"ex",
")",
"{",
"throw",
"new",
"FlinkException",
"(",
"\"Deserialization of user-function failed.\"",
",",
"ex",
")",
";",
"}",
"}"
] | Deserialize the given python function. If the functions class definition cannot be found we assume that this is
the first invocation of this method for a given job and load the python script containing the class definition
via jython.
@param context the RuntimeContext of the java function
@param serFun serialized python UDF
@return deserialized python UDF
@throws FlinkException if the deserialization failed | [
"Deserialize",
"the",
"given",
"python",
"function",
".",
"If",
"the",
"functions",
"class",
"definition",
"cannot",
"be",
"found",
"we",
"assume",
"that",
"this",
"is",
"the",
"first",
"invocation",
"of",
"this",
"method",
"for",
"a",
"given",
"job",
"and",
"load",
"the",
"python",
"script",
"containing",
"the",
"class",
"definition",
"via",
"jython",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-libraries/flink-streaming-python/src/main/java/org/apache/flink/streaming/python/util/InterpreterUtils.java#L64-L95 |
Azure/azure-sdk-for-java | labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/GlobalUsersInner.java | GlobalUsersInner.beginResetPasswordAsync | public Observable<Void> beginResetPasswordAsync(String userName, ResetPasswordPayload resetPasswordPayload) {
"""
Resets the user password on an environment This operation can take a while to complete.
@param userName The name of the user.
@param resetPasswordPayload Represents the payload for resetting passwords.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful.
"""
return beginResetPasswordWithServiceResponseAsync(userName, resetPasswordPayload).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | java | public Observable<Void> beginResetPasswordAsync(String userName, ResetPasswordPayload resetPasswordPayload) {
return beginResetPasswordWithServiceResponseAsync(userName, resetPasswordPayload).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Void",
">",
"beginResetPasswordAsync",
"(",
"String",
"userName",
",",
"ResetPasswordPayload",
"resetPasswordPayload",
")",
"{",
"return",
"beginResetPasswordWithServiceResponseAsync",
"(",
"userName",
",",
"resetPasswordPayload",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Void",
">",
",",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
"ServiceResponse",
"<",
"Void",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Resets the user password on an environment This operation can take a while to complete.
@param userName The name of the user.
@param resetPasswordPayload Represents the payload for resetting passwords.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful. | [
"Resets",
"the",
"user",
"password",
"on",
"an",
"environment",
"This",
"operation",
"can",
"take",
"a",
"while",
"to",
"complete",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/GlobalUsersInner.java#L1023-L1030 |
google/error-prone-javac | src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Operators.java | Operators.initOperators | @SafeVarargs
private final <O extends OperatorHelper> void initOperators(Map<Name, List<O>> opsMap, O... ops) {
"""
Complete the initialization of an operator helper by storing it into the corresponding operator map.
"""
for (O o : ops) {
Name opName = o.name;
List<O> helpers = opsMap.getOrDefault(opName, List.nil());
opsMap.put(opName, helpers.prepend(o));
}
} | java | @SafeVarargs
private final <O extends OperatorHelper> void initOperators(Map<Name, List<O>> opsMap, O... ops) {
for (O o : ops) {
Name opName = o.name;
List<O> helpers = opsMap.getOrDefault(opName, List.nil());
opsMap.put(opName, helpers.prepend(o));
}
} | [
"@",
"SafeVarargs",
"private",
"final",
"<",
"O",
"extends",
"OperatorHelper",
">",
"void",
"initOperators",
"(",
"Map",
"<",
"Name",
",",
"List",
"<",
"O",
">",
">",
"opsMap",
",",
"O",
"...",
"ops",
")",
"{",
"for",
"(",
"O",
"o",
":",
"ops",
")",
"{",
"Name",
"opName",
"=",
"o",
".",
"name",
";",
"List",
"<",
"O",
">",
"helpers",
"=",
"opsMap",
".",
"getOrDefault",
"(",
"opName",
",",
"List",
".",
"nil",
"(",
")",
")",
";",
"opsMap",
".",
"put",
"(",
"opName",
",",
"helpers",
".",
"prepend",
"(",
"o",
")",
")",
";",
"}",
"}"
] | Complete the initialization of an operator helper by storing it into the corresponding operator map. | [
"Complete",
"the",
"initialization",
"of",
"an",
"operator",
"helper",
"by",
"storing",
"it",
"into",
"the",
"corresponding",
"operator",
"map",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Operators.java#L818-L825 |
nikhaldi/android-view-selector | src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java | ViewSelectorAssertions.assertThatSelection | public static ViewSelectionAssert assertThatSelection(String selector, Activity activity) {
"""
Fluent assertion entry point for a selection of views from the given activity
based on the given selector. It may be helpful to statically import this rather
than {@link #assertThat(ViewSelection)} to avoid conflicts with other statically
imported {@code assertThat()} methods.
"""
return assertThat(selection(selector, activity));
} | java | public static ViewSelectionAssert assertThatSelection(String selector, Activity activity) {
return assertThat(selection(selector, activity));
} | [
"public",
"static",
"ViewSelectionAssert",
"assertThatSelection",
"(",
"String",
"selector",
",",
"Activity",
"activity",
")",
"{",
"return",
"assertThat",
"(",
"selection",
"(",
"selector",
",",
"activity",
")",
")",
";",
"}"
] | Fluent assertion entry point for a selection of views from the given activity
based on the given selector. It may be helpful to statically import this rather
than {@link #assertThat(ViewSelection)} to avoid conflicts with other statically
imported {@code assertThat()} methods. | [
"Fluent",
"assertion",
"entry",
"point",
"for",
"a",
"selection",
"of",
"views",
"from",
"the",
"given",
"activity",
"based",
"on",
"the",
"given",
"selector",
".",
"It",
"may",
"be",
"helpful",
"to",
"statically",
"import",
"this",
"rather",
"than",
"{"
] | train | https://github.com/nikhaldi/android-view-selector/blob/d3e4bf05f6111d116c6b0c1a8c51396e8bfae9b5/src/main/java/com/nikhaldimann/viewselector/ViewSelectorAssertions.java#L53-L55 |
classgraph/classgraph | src/main/java/nonapi/io/github/classgraph/json/JSONDeserializer.java | JSONDeserializer.deserializeToField | public static void deserializeToField(final Object containingObject, final String fieldName, final String json,
final ClassFieldCache classFieldCache) throws IllegalArgumentException {
"""
Deserialize JSON to a new object graph, with the root object of the specified expected type, and store the
root object in the named field of the given containing object. Works for generic types, since it is possible
to obtain the generic type of a field.
@param containingObject
The object containing the named field to deserialize the object graph into.
@param fieldName
The name of the field to set with the result.
@param json
the JSON string to deserialize.
@param classFieldCache
The class field cache. Reusing this cache will increase the speed if many JSON documents of the
same type need to be parsed.
@throws IllegalArgumentException
If anything goes wrong during deserialization.
"""
if (containingObject == null) {
throw new IllegalArgumentException("Cannot deserialize to a field of a null object");
}
// Parse the JSON
Object parsedJSON;
try {
parsedJSON = JSONParser.parseJSON(json);
} catch (final ParseException e) {
throw new IllegalArgumentException("Could not parse JSON", e);
}
// Create a JSONObject with one field of the requested name, and deserialize that into the requested object
final JSONObject wrapperJsonObj = new JSONObject(1);
wrapperJsonObj.items.add(new SimpleEntry<>(fieldName, parsedJSON));
// Populate the object field
// (no need to call getInitialIdToObjectMap(), since toplevel object is a wrapper, which doesn't have an id)
final List<Runnable> collectionElementAdders = new ArrayList<>();
populateObjectFromJsonObject(containingObject, containingObject.getClass(), wrapperJsonObj, classFieldCache,
new HashMap<CharSequence, Object>(), collectionElementAdders);
for (final Runnable runnable : collectionElementAdders) {
runnable.run();
}
} | java | public static void deserializeToField(final Object containingObject, final String fieldName, final String json,
final ClassFieldCache classFieldCache) throws IllegalArgumentException {
if (containingObject == null) {
throw new IllegalArgumentException("Cannot deserialize to a field of a null object");
}
// Parse the JSON
Object parsedJSON;
try {
parsedJSON = JSONParser.parseJSON(json);
} catch (final ParseException e) {
throw new IllegalArgumentException("Could not parse JSON", e);
}
// Create a JSONObject with one field of the requested name, and deserialize that into the requested object
final JSONObject wrapperJsonObj = new JSONObject(1);
wrapperJsonObj.items.add(new SimpleEntry<>(fieldName, parsedJSON));
// Populate the object field
// (no need to call getInitialIdToObjectMap(), since toplevel object is a wrapper, which doesn't have an id)
final List<Runnable> collectionElementAdders = new ArrayList<>();
populateObjectFromJsonObject(containingObject, containingObject.getClass(), wrapperJsonObj, classFieldCache,
new HashMap<CharSequence, Object>(), collectionElementAdders);
for (final Runnable runnable : collectionElementAdders) {
runnable.run();
}
} | [
"public",
"static",
"void",
"deserializeToField",
"(",
"final",
"Object",
"containingObject",
",",
"final",
"String",
"fieldName",
",",
"final",
"String",
"json",
",",
"final",
"ClassFieldCache",
"classFieldCache",
")",
"throws",
"IllegalArgumentException",
"{",
"if",
"(",
"containingObject",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Cannot deserialize to a field of a null object\"",
")",
";",
"}",
"// Parse the JSON",
"Object",
"parsedJSON",
";",
"try",
"{",
"parsedJSON",
"=",
"JSONParser",
".",
"parseJSON",
"(",
"json",
")",
";",
"}",
"catch",
"(",
"final",
"ParseException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Could not parse JSON\"",
",",
"e",
")",
";",
"}",
"// Create a JSONObject with one field of the requested name, and deserialize that into the requested object",
"final",
"JSONObject",
"wrapperJsonObj",
"=",
"new",
"JSONObject",
"(",
"1",
")",
";",
"wrapperJsonObj",
".",
"items",
".",
"add",
"(",
"new",
"SimpleEntry",
"<>",
"(",
"fieldName",
",",
"parsedJSON",
")",
")",
";",
"// Populate the object field",
"// (no need to call getInitialIdToObjectMap(), since toplevel object is a wrapper, which doesn't have an id)",
"final",
"List",
"<",
"Runnable",
">",
"collectionElementAdders",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"populateObjectFromJsonObject",
"(",
"containingObject",
",",
"containingObject",
".",
"getClass",
"(",
")",
",",
"wrapperJsonObj",
",",
"classFieldCache",
",",
"new",
"HashMap",
"<",
"CharSequence",
",",
"Object",
">",
"(",
")",
",",
"collectionElementAdders",
")",
";",
"for",
"(",
"final",
"Runnable",
"runnable",
":",
"collectionElementAdders",
")",
"{",
"runnable",
".",
"run",
"(",
")",
";",
"}",
"}"
] | Deserialize JSON to a new object graph, with the root object of the specified expected type, and store the
root object in the named field of the given containing object. Works for generic types, since it is possible
to obtain the generic type of a field.
@param containingObject
The object containing the named field to deserialize the object graph into.
@param fieldName
The name of the field to set with the result.
@param json
the JSON string to deserialize.
@param classFieldCache
The class field cache. Reusing this cache will increase the speed if many JSON documents of the
same type need to be parsed.
@throws IllegalArgumentException
If anything goes wrong during deserialization. | [
"Deserialize",
"JSON",
"to",
"a",
"new",
"object",
"graph",
"with",
"the",
"root",
"object",
"of",
"the",
"specified",
"expected",
"type",
"and",
"store",
"the",
"root",
"object",
"in",
"the",
"named",
"field",
"of",
"the",
"given",
"containing",
"object",
".",
"Works",
"for",
"generic",
"types",
"since",
"it",
"is",
"possible",
"to",
"obtain",
"the",
"generic",
"type",
"of",
"a",
"field",
"."
] | train | https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/json/JSONDeserializer.java#L712-L738 |
webmetrics/browsermob-proxy | src/main/java/org/browsermob/proxy/jetty/jetty/servlet/WebApplicationHandler.java | WebApplicationHandler.addFilterServletMapping | public FilterHolder addFilterServletMapping(String servletName, String filterName, int dispatches) {
"""
Add a servlet filter mapping
@param servletName The name of the servlet to be filtered.
@param filterName The name of the filter.
@param dispatches An integer formed by the logical OR of FilterHolder.__REQUEST,
FilterHolder.__FORWARD,FilterHolder.__INCLUDE and/or FilterHolder.__ERROR.
@return The holder of the filter instance.
"""
FilterHolder holder= (FilterHolder)_filterMap.get(filterName);
if (holder == null)
throw new IllegalArgumentException("Unknown filter :" + filterName);
_servletFilterMap.add(servletName, new FilterMapping(null,holder,dispatches));
return holder;
} | java | public FilterHolder addFilterServletMapping(String servletName, String filterName, int dispatches)
{
FilterHolder holder= (FilterHolder)_filterMap.get(filterName);
if (holder == null)
throw new IllegalArgumentException("Unknown filter :" + filterName);
_servletFilterMap.add(servletName, new FilterMapping(null,holder,dispatches));
return holder;
} | [
"public",
"FilterHolder",
"addFilterServletMapping",
"(",
"String",
"servletName",
",",
"String",
"filterName",
",",
"int",
"dispatches",
")",
"{",
"FilterHolder",
"holder",
"=",
"(",
"FilterHolder",
")",
"_filterMap",
".",
"get",
"(",
"filterName",
")",
";",
"if",
"(",
"holder",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unknown filter :\"",
"+",
"filterName",
")",
";",
"_servletFilterMap",
".",
"add",
"(",
"servletName",
",",
"new",
"FilterMapping",
"(",
"null",
",",
"holder",
",",
"dispatches",
")",
")",
";",
"return",
"holder",
";",
"}"
] | Add a servlet filter mapping
@param servletName The name of the servlet to be filtered.
@param filterName The name of the filter.
@param dispatches An integer formed by the logical OR of FilterHolder.__REQUEST,
FilterHolder.__FORWARD,FilterHolder.__INCLUDE and/or FilterHolder.__ERROR.
@return The holder of the filter instance. | [
"Add",
"a",
"servlet",
"filter",
"mapping"
] | train | https://github.com/webmetrics/browsermob-proxy/blob/a9252e62246ac33d55d51b993ba1159404e7d389/src/main/java/org/browsermob/proxy/jetty/jetty/servlet/WebApplicationHandler.java#L144-L151 |
cdapio/tigon | tigon-queue/src/main/java/co/cask/tigon/data/transaction/queue/inmemory/InMemoryQueueService.java | InMemoryQueueService.resetAllQueuesOrStreams | private void resetAllQueuesOrStreams(boolean clearStreams, @Nullable String prefix) {
"""
Drop either all streams or all queues.
@param clearStreams if true, drops all streams, if false, clears all queues.
@param prefix if non-null, drops only queues with a name that begins with this prefix.
"""
List<String> toRemove = Lists.newArrayListWithCapacity(queues.size());
for (String queueName : queues.keySet()) {
if ((clearStreams && QueueName.isStream(queueName)) || (!clearStreams && QueueName.isQueue(queueName))) {
if (prefix == null || queueName.startsWith(prefix)) {
toRemove.add(queueName);
}
}
}
for (String queueName : toRemove) {
queues.remove(queueName);
}
} | java | private void resetAllQueuesOrStreams(boolean clearStreams, @Nullable String prefix) {
List<String> toRemove = Lists.newArrayListWithCapacity(queues.size());
for (String queueName : queues.keySet()) {
if ((clearStreams && QueueName.isStream(queueName)) || (!clearStreams && QueueName.isQueue(queueName))) {
if (prefix == null || queueName.startsWith(prefix)) {
toRemove.add(queueName);
}
}
}
for (String queueName : toRemove) {
queues.remove(queueName);
}
} | [
"private",
"void",
"resetAllQueuesOrStreams",
"(",
"boolean",
"clearStreams",
",",
"@",
"Nullable",
"String",
"prefix",
")",
"{",
"List",
"<",
"String",
">",
"toRemove",
"=",
"Lists",
".",
"newArrayListWithCapacity",
"(",
"queues",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"String",
"queueName",
":",
"queues",
".",
"keySet",
"(",
")",
")",
"{",
"if",
"(",
"(",
"clearStreams",
"&&",
"QueueName",
".",
"isStream",
"(",
"queueName",
")",
")",
"||",
"(",
"!",
"clearStreams",
"&&",
"QueueName",
".",
"isQueue",
"(",
"queueName",
")",
")",
")",
"{",
"if",
"(",
"prefix",
"==",
"null",
"||",
"queueName",
".",
"startsWith",
"(",
"prefix",
")",
")",
"{",
"toRemove",
".",
"add",
"(",
"queueName",
")",
";",
"}",
"}",
"}",
"for",
"(",
"String",
"queueName",
":",
"toRemove",
")",
"{",
"queues",
".",
"remove",
"(",
"queueName",
")",
";",
"}",
"}"
] | Drop either all streams or all queues.
@param clearStreams if true, drops all streams, if false, clears all queues.
@param prefix if non-null, drops only queues with a name that begins with this prefix. | [
"Drop",
"either",
"all",
"streams",
"or",
"all",
"queues",
"."
] | train | https://github.com/cdapio/tigon/blob/5be6dffd7c79519d1211bb08f75be7dcfbbad392/tigon-queue/src/main/java/co/cask/tigon/data/transaction/queue/inmemory/InMemoryQueueService.java#L71-L83 |
joniles/mpxj | src/main/java/net/sf/mpxj/json/JsonWriter.java | JsonWriter.writeBooleanField | private void writeBooleanField(String fieldName, Object value) throws IOException {
"""
Write a boolean field to the JSON file.
@param fieldName field name
@param value field value
"""
boolean val = ((Boolean) value).booleanValue();
if (val)
{
m_writer.writeNameValuePair(fieldName, val);
}
} | java | private void writeBooleanField(String fieldName, Object value) throws IOException
{
boolean val = ((Boolean) value).booleanValue();
if (val)
{
m_writer.writeNameValuePair(fieldName, val);
}
} | [
"private",
"void",
"writeBooleanField",
"(",
"String",
"fieldName",
",",
"Object",
"value",
")",
"throws",
"IOException",
"{",
"boolean",
"val",
"=",
"(",
"(",
"Boolean",
")",
"value",
")",
".",
"booleanValue",
"(",
")",
";",
"if",
"(",
"val",
")",
"{",
"m_writer",
".",
"writeNameValuePair",
"(",
"fieldName",
",",
"val",
")",
";",
"}",
"}"
] | Write a boolean field to the JSON file.
@param fieldName field name
@param value field value | [
"Write",
"a",
"boolean",
"field",
"to",
"the",
"JSON",
"file",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonWriter.java#L400-L407 |
kkopacz/agiso-tempel | templates/abstract-velocityDirectoryExtendEngine/src/main/java/org/agiso/tempel/engine/VelocityDirectoryExtendEngine.java | VelocityDirectoryExtendEngine.processVelocityResource | @Override
protected void processVelocityResource(ITemplateSource source, VelocityContext context, String target) throws Exception {
"""
Szablon może być pojedynczym plikiem (wówczas silnik działa tak jak silnik
{@link VelocityFileEngine}, lub katalogiem. W takiej sytuacji przetwarzane
są wszsytkie jego wpisy.
"""
if(source.isFile()) {
super.processVelocityFile(source.getEntry(source.getResource()), context, target);
} else if(source.isDirectory()) {
for(ITemplateSourceEntry entry : source.listEntries()) {
if(entry.isFile()) {
processVelocityFile(entry, context, target);
} else if(entry.isDirectory()) {
processVelocityDirectory(entry, context, target);
}
}
}
} | java | @Override
protected void processVelocityResource(ITemplateSource source, VelocityContext context, String target) throws Exception {
if(source.isFile()) {
super.processVelocityFile(source.getEntry(source.getResource()), context, target);
} else if(source.isDirectory()) {
for(ITemplateSourceEntry entry : source.listEntries()) {
if(entry.isFile()) {
processVelocityFile(entry, context, target);
} else if(entry.isDirectory()) {
processVelocityDirectory(entry, context, target);
}
}
}
} | [
"@",
"Override",
"protected",
"void",
"processVelocityResource",
"(",
"ITemplateSource",
"source",
",",
"VelocityContext",
"context",
",",
"String",
"target",
")",
"throws",
"Exception",
"{",
"if",
"(",
"source",
".",
"isFile",
"(",
")",
")",
"{",
"super",
".",
"processVelocityFile",
"(",
"source",
".",
"getEntry",
"(",
"source",
".",
"getResource",
"(",
")",
")",
",",
"context",
",",
"target",
")",
";",
"}",
"else",
"if",
"(",
"source",
".",
"isDirectory",
"(",
")",
")",
"{",
"for",
"(",
"ITemplateSourceEntry",
"entry",
":",
"source",
".",
"listEntries",
"(",
")",
")",
"{",
"if",
"(",
"entry",
".",
"isFile",
"(",
")",
")",
"{",
"processVelocityFile",
"(",
"entry",
",",
"context",
",",
"target",
")",
";",
"}",
"else",
"if",
"(",
"entry",
".",
"isDirectory",
"(",
")",
")",
"{",
"processVelocityDirectory",
"(",
"entry",
",",
"context",
",",
"target",
")",
";",
"}",
"}",
"}",
"}"
] | Szablon może być pojedynczym plikiem (wówczas silnik działa tak jak silnik
{@link VelocityFileEngine}, lub katalogiem. W takiej sytuacji przetwarzane
są wszsytkie jego wpisy. | [
"Szablon",
"może",
"być",
"pojedynczym",
"plikiem",
"(",
"wówczas",
"silnik",
"działa",
"tak",
"jak",
"silnik",
"{"
] | train | https://github.com/kkopacz/agiso-tempel/blob/ff7a96153153b6bc07212d776816b87d9538f6fa/templates/abstract-velocityDirectoryExtendEngine/src/main/java/org/agiso/tempel/engine/VelocityDirectoryExtendEngine.java#L44-L57 |
timols/java-gitlab-api | src/main/java/org/gitlab/api/GitlabAPI.java | GitlabAPI.editGroupBadge | public GitlabBadge editGroupBadge(Integer groupId, Integer badgeId, String linkUrl, String imageUrl) throws IOException {
"""
Edit group badge
@param groupId The id of the group for which the badge should be edited
@param badgeId The id of the badge that should be edited
@param linkUrl The URL that the badge should link to
@param imageUrl The URL to the badge image
@return The updated badge
@throws IOException on GitLab API call error
"""
String tailUrl = GitlabGroup.URL + "/" + groupId + GitlabBadge.URL
+ "/" + badgeId;
GitlabHTTPRequestor requestor = retrieve().method(PUT);
requestor.with("link_url", linkUrl)
.with("image_url", imageUrl);
return requestor.to(tailUrl, GitlabBadge.class);
} | java | public GitlabBadge editGroupBadge(Integer groupId, Integer badgeId, String linkUrl, String imageUrl) throws IOException {
String tailUrl = GitlabGroup.URL + "/" + groupId + GitlabBadge.URL
+ "/" + badgeId;
GitlabHTTPRequestor requestor = retrieve().method(PUT);
requestor.with("link_url", linkUrl)
.with("image_url", imageUrl);
return requestor.to(tailUrl, GitlabBadge.class);
} | [
"public",
"GitlabBadge",
"editGroupBadge",
"(",
"Integer",
"groupId",
",",
"Integer",
"badgeId",
",",
"String",
"linkUrl",
",",
"String",
"imageUrl",
")",
"throws",
"IOException",
"{",
"String",
"tailUrl",
"=",
"GitlabGroup",
".",
"URL",
"+",
"\"/\"",
"+",
"groupId",
"+",
"GitlabBadge",
".",
"URL",
"+",
"\"/\"",
"+",
"badgeId",
";",
"GitlabHTTPRequestor",
"requestor",
"=",
"retrieve",
"(",
")",
".",
"method",
"(",
"PUT",
")",
";",
"requestor",
".",
"with",
"(",
"\"link_url\"",
",",
"linkUrl",
")",
".",
"with",
"(",
"\"image_url\"",
",",
"imageUrl",
")",
";",
"return",
"requestor",
".",
"to",
"(",
"tailUrl",
",",
"GitlabBadge",
".",
"class",
")",
";",
"}"
] | Edit group badge
@param groupId The id of the group for which the badge should be edited
@param badgeId The id of the badge that should be edited
@param linkUrl The URL that the badge should link to
@param imageUrl The URL to the badge image
@return The updated badge
@throws IOException on GitLab API call error | [
"Edit",
"group",
"badge"
] | train | https://github.com/timols/java-gitlab-api/blob/f03eedf952cfbb40306be3bf9234dcf78fab029e/src/main/java/org/gitlab/api/GitlabAPI.java#L2729-L2736 |
micronaut-projects/micronaut-core | inject/src/main/java/io/micronaut/inject/annotation/DefaultAnnotationMetadata.java | DefaultAnnotationMetadata.mutateMember | @Internal
public static AnnotationMetadata mutateMember(
AnnotationMetadata annotationMetadata,
String annotationName,
String member,
Object value) {
"""
<p>Sets a member of the given {@link AnnotationMetadata} return a new annotation metadata instance without
mutating the existing.</p>
<p>WARNING: for internal use only be the framework</p>
@param annotationMetadata The metadata
@param annotationName The annotation name
@param member The member
@param value The value
@return The metadata
"""
return mutateMember(annotationMetadata, annotationName, Collections.singletonMap(member, value));
} | java | @Internal
public static AnnotationMetadata mutateMember(
AnnotationMetadata annotationMetadata,
String annotationName,
String member,
Object value) {
return mutateMember(annotationMetadata, annotationName, Collections.singletonMap(member, value));
} | [
"@",
"Internal",
"public",
"static",
"AnnotationMetadata",
"mutateMember",
"(",
"AnnotationMetadata",
"annotationMetadata",
",",
"String",
"annotationName",
",",
"String",
"member",
",",
"Object",
"value",
")",
"{",
"return",
"mutateMember",
"(",
"annotationMetadata",
",",
"annotationName",
",",
"Collections",
".",
"singletonMap",
"(",
"member",
",",
"value",
")",
")",
";",
"}"
] | <p>Sets a member of the given {@link AnnotationMetadata} return a new annotation metadata instance without
mutating the existing.</p>
<p>WARNING: for internal use only be the framework</p>
@param annotationMetadata The metadata
@param annotationName The annotation name
@param member The member
@param value The value
@return The metadata | [
"<p",
">",
"Sets",
"a",
"member",
"of",
"the",
"given",
"{",
"@link",
"AnnotationMetadata",
"}",
"return",
"a",
"new",
"annotation",
"metadata",
"instance",
"without",
"mutating",
"the",
"existing",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/micronaut-projects/micronaut-core/blob/c31f5b03ce0eb88c2f6470710987db03b8967d5c/inject/src/main/java/io/micronaut/inject/annotation/DefaultAnnotationMetadata.java#L918-L926 |
OpenLiberty/open-liberty | dev/com.ibm.ws.repository/src/com/ibm/ws/repository/transport/client/DataModelSerializer.java | DataModelSerializer.getClassForFieldName | private static ClassAndMethod getClassForFieldName(String fieldName, Class<?> classToLookForFieldIn) {
"""
Gets a class for a JSON field name, by looking in a given Class for an appropriate setter.
The setter is assumed not to be a Collection.
@param fieldName the name to use to search for the getter.
@param classToLookForFieldIn the Class to search for the getter within.
@return instance of ClassAndMethod if one is found, null otherwise
"""
return internalGetClassForFieldName(fieldName, classToLookForFieldIn, false);
} | java | private static ClassAndMethod getClassForFieldName(String fieldName, Class<?> classToLookForFieldIn) {
return internalGetClassForFieldName(fieldName, classToLookForFieldIn, false);
} | [
"private",
"static",
"ClassAndMethod",
"getClassForFieldName",
"(",
"String",
"fieldName",
",",
"Class",
"<",
"?",
">",
"classToLookForFieldIn",
")",
"{",
"return",
"internalGetClassForFieldName",
"(",
"fieldName",
",",
"classToLookForFieldIn",
",",
"false",
")",
";",
"}"
] | Gets a class for a JSON field name, by looking in a given Class for an appropriate setter.
The setter is assumed not to be a Collection.
@param fieldName the name to use to search for the getter.
@param classToLookForFieldIn the Class to search for the getter within.
@return instance of ClassAndMethod if one is found, null otherwise | [
"Gets",
"a",
"class",
"for",
"a",
"JSON",
"field",
"name",
"by",
"looking",
"in",
"a",
"given",
"Class",
"for",
"an",
"appropriate",
"setter",
".",
"The",
"setter",
"is",
"assumed",
"not",
"to",
"be",
"a",
"Collection",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.repository/src/com/ibm/ws/repository/transport/client/DataModelSerializer.java#L395-L397 |
Waikato/moa | moa/src/main/java/com/yahoo/labs/samoa/instances/SparseInstanceData.java | SparseInstanceData.setValue | @Override
public void setValue(int attributeIndex, double d) {
"""
Sets the value.
@param attributeIndex the attribute index
@param d the d
"""
int index = locateIndex(attributeIndex);
if (index(index) == attributeIndex) {
this.attributeValues[index] = d;
} else {
// We need to add the value
}
} | java | @Override
public void setValue(int attributeIndex, double d) {
int index = locateIndex(attributeIndex);
if (index(index) == attributeIndex) {
this.attributeValues[index] = d;
} else {
// We need to add the value
}
} | [
"@",
"Override",
"public",
"void",
"setValue",
"(",
"int",
"attributeIndex",
",",
"double",
"d",
")",
"{",
"int",
"index",
"=",
"locateIndex",
"(",
"attributeIndex",
")",
";",
"if",
"(",
"index",
"(",
"index",
")",
"==",
"attributeIndex",
")",
"{",
"this",
".",
"attributeValues",
"[",
"index",
"]",
"=",
"d",
";",
"}",
"else",
"{",
"// We need to add the value",
"}",
"}"
] | Sets the value.
@param attributeIndex the attribute index
@param d the d | [
"Sets",
"the",
"value",
"."
] | train | https://github.com/Waikato/moa/blob/395982e5100bfe75a3a4d26115462ce2cc74cbb0/moa/src/main/java/com/yahoo/labs/samoa/instances/SparseInstanceData.java#L218-L226 |
wildfly/wildfly-core | patching/src/main/java/org/jboss/as/patching/ZipUtils.java | ZipUtils.unzip | private static void unzip(final ZipFile zip, final File patchDir) throws IOException {
"""
unpack...
@param zip the zip
@param patchDir the patch dir
@throws IOException
"""
final Enumeration<? extends ZipEntry> entries = zip.entries();
while(entries.hasMoreElements()) {
final ZipEntry entry = entries.nextElement();
final String name = entry.getName();
final File current = new File(patchDir, name);
if(entry.isDirectory()) {
continue;
} else {
if(! current.getParentFile().exists()) {
current.getParentFile().mkdirs();
}
try (final InputStream eis = zip.getInputStream(entry)){
Files.copy(eis, current.toPath());
//copy(eis, current);
}
}
}
} | java | private static void unzip(final ZipFile zip, final File patchDir) throws IOException {
final Enumeration<? extends ZipEntry> entries = zip.entries();
while(entries.hasMoreElements()) {
final ZipEntry entry = entries.nextElement();
final String name = entry.getName();
final File current = new File(patchDir, name);
if(entry.isDirectory()) {
continue;
} else {
if(! current.getParentFile().exists()) {
current.getParentFile().mkdirs();
}
try (final InputStream eis = zip.getInputStream(entry)){
Files.copy(eis, current.toPath());
//copy(eis, current);
}
}
}
} | [
"private",
"static",
"void",
"unzip",
"(",
"final",
"ZipFile",
"zip",
",",
"final",
"File",
"patchDir",
")",
"throws",
"IOException",
"{",
"final",
"Enumeration",
"<",
"?",
"extends",
"ZipEntry",
">",
"entries",
"=",
"zip",
".",
"entries",
"(",
")",
";",
"while",
"(",
"entries",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"final",
"ZipEntry",
"entry",
"=",
"entries",
".",
"nextElement",
"(",
")",
";",
"final",
"String",
"name",
"=",
"entry",
".",
"getName",
"(",
")",
";",
"final",
"File",
"current",
"=",
"new",
"File",
"(",
"patchDir",
",",
"name",
")",
";",
"if",
"(",
"entry",
".",
"isDirectory",
"(",
")",
")",
"{",
"continue",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"current",
".",
"getParentFile",
"(",
")",
".",
"exists",
"(",
")",
")",
"{",
"current",
".",
"getParentFile",
"(",
")",
".",
"mkdirs",
"(",
")",
";",
"}",
"try",
"(",
"final",
"InputStream",
"eis",
"=",
"zip",
".",
"getInputStream",
"(",
"entry",
")",
")",
"{",
"Files",
".",
"copy",
"(",
"eis",
",",
"current",
".",
"toPath",
"(",
")",
")",
";",
"//copy(eis, current);",
"}",
"}",
"}",
"}"
] | unpack...
@param zip the zip
@param patchDir the patch dir
@throws IOException | [
"unpack",
"..."
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/patching/src/main/java/org/jboss/as/patching/ZipUtils.java#L113-L131 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/LocalNetworkGatewaysInner.java | LocalNetworkGatewaysInner.beginUpdateTags | public LocalNetworkGatewayInner beginUpdateTags(String resourceGroupName, String localNetworkGatewayName, Map<String, String> tags) {
"""
Updates a local network gateway tags.
@param resourceGroupName The name of the resource group.
@param localNetworkGatewayName The name of the local network gateway.
@param tags Resource tags.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the LocalNetworkGatewayInner object if successful.
"""
return beginUpdateTagsWithServiceResponseAsync(resourceGroupName, localNetworkGatewayName, tags).toBlocking().single().body();
} | java | public LocalNetworkGatewayInner beginUpdateTags(String resourceGroupName, String localNetworkGatewayName, Map<String, String> tags) {
return beginUpdateTagsWithServiceResponseAsync(resourceGroupName, localNetworkGatewayName, tags).toBlocking().single().body();
} | [
"public",
"LocalNetworkGatewayInner",
"beginUpdateTags",
"(",
"String",
"resourceGroupName",
",",
"String",
"localNetworkGatewayName",
",",
"Map",
"<",
"String",
",",
"String",
">",
"tags",
")",
"{",
"return",
"beginUpdateTagsWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"localNetworkGatewayName",
",",
"tags",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Updates a local network gateway tags.
@param resourceGroupName The name of the resource group.
@param localNetworkGatewayName The name of the local network gateway.
@param tags Resource tags.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the LocalNetworkGatewayInner object if successful. | [
"Updates",
"a",
"local",
"network",
"gateway",
"tags",
"."
] | 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/LocalNetworkGatewaysInner.java#L744-L746 |
Ordinastie/MalisisCore | src/main/java/net/malisis/core/inventory/MalisisInventoryContainer.java | MalisisInventoryContainer.handleNormalClick | private ItemStack handleNormalClick(MalisisSlot slot, boolean fullStack) {
"""
Handles the normal left or right click.
@param slot the slot
@param fullStack the full stack
@return the item stack
"""
if (!getPickedItemStack().isEmpty() && !slot.isItemValid(pickedItemStack))
return getPickedItemStack();
// already picked up an itemStack, insert/swap itemStack
if (!getPickedItemStack().isEmpty())
{
if (slot.isState(PLAYER_INSERT | PLAYER_EXTRACT))
setPickedItemStack(slot.insert(pickedItemStack, fullStack ? ItemUtils.FULL_STACK : 1, true));
}
// pick itemStack in slot
else if (slot.isState(PLAYER_EXTRACT))
setPickedItemStack(slot.extract(fullStack ? ItemUtils.FULL_STACK : ItemUtils.HALF_STACK));
return getPickedItemStack();
} | java | private ItemStack handleNormalClick(MalisisSlot slot, boolean fullStack)
{
if (!getPickedItemStack().isEmpty() && !slot.isItemValid(pickedItemStack))
return getPickedItemStack();
// already picked up an itemStack, insert/swap itemStack
if (!getPickedItemStack().isEmpty())
{
if (slot.isState(PLAYER_INSERT | PLAYER_EXTRACT))
setPickedItemStack(slot.insert(pickedItemStack, fullStack ? ItemUtils.FULL_STACK : 1, true));
}
// pick itemStack in slot
else if (slot.isState(PLAYER_EXTRACT))
setPickedItemStack(slot.extract(fullStack ? ItemUtils.FULL_STACK : ItemUtils.HALF_STACK));
return getPickedItemStack();
} | [
"private",
"ItemStack",
"handleNormalClick",
"(",
"MalisisSlot",
"slot",
",",
"boolean",
"fullStack",
")",
"{",
"if",
"(",
"!",
"getPickedItemStack",
"(",
")",
".",
"isEmpty",
"(",
")",
"&&",
"!",
"slot",
".",
"isItemValid",
"(",
"pickedItemStack",
")",
")",
"return",
"getPickedItemStack",
"(",
")",
";",
"// already picked up an itemStack, insert/swap itemStack",
"if",
"(",
"!",
"getPickedItemStack",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"if",
"(",
"slot",
".",
"isState",
"(",
"PLAYER_INSERT",
"|",
"PLAYER_EXTRACT",
")",
")",
"setPickedItemStack",
"(",
"slot",
".",
"insert",
"(",
"pickedItemStack",
",",
"fullStack",
"?",
"ItemUtils",
".",
"FULL_STACK",
":",
"1",
",",
"true",
")",
")",
";",
"}",
"// pick itemStack in slot",
"else",
"if",
"(",
"slot",
".",
"isState",
"(",
"PLAYER_EXTRACT",
")",
")",
"setPickedItemStack",
"(",
"slot",
".",
"extract",
"(",
"fullStack",
"?",
"ItemUtils",
".",
"FULL_STACK",
":",
"ItemUtils",
".",
"HALF_STACK",
")",
")",
";",
"return",
"getPickedItemStack",
"(",
")",
";",
"}"
] | Handles the normal left or right click.
@param slot the slot
@param fullStack the full stack
@return the item stack | [
"Handles",
"the",
"normal",
"left",
"or",
"right",
"click",
"."
] | train | https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/inventory/MalisisInventoryContainer.java#L459-L475 |
iig-uni-freiburg/SEWOL | ext/org/deckfour/xes/out/XMxmlSerializer.java | XMxmlSerializer.addModelReference | protected void addModelReference(XAttributable object, SXTag target)
throws IOException {
"""
Helper method, adds all model references of an attributable to the given
tag.
@param object
Attributable element.
@param target
Tag to add model references to.
"""
XAttributeLiteral modelRefAttr = (XAttributeLiteral) object
.getAttributes().get(XSemanticExtension.KEY_MODELREFERENCE);
if (modelRefAttr != null) {
target.addAttribute("modelReference", modelRefAttr.getValue());
}
} | java | protected void addModelReference(XAttributable object, SXTag target)
throws IOException {
XAttributeLiteral modelRefAttr = (XAttributeLiteral) object
.getAttributes().get(XSemanticExtension.KEY_MODELREFERENCE);
if (modelRefAttr != null) {
target.addAttribute("modelReference", modelRefAttr.getValue());
}
} | [
"protected",
"void",
"addModelReference",
"(",
"XAttributable",
"object",
",",
"SXTag",
"target",
")",
"throws",
"IOException",
"{",
"XAttributeLiteral",
"modelRefAttr",
"=",
"(",
"XAttributeLiteral",
")",
"object",
".",
"getAttributes",
"(",
")",
".",
"get",
"(",
"XSemanticExtension",
".",
"KEY_MODELREFERENCE",
")",
";",
"if",
"(",
"modelRefAttr",
"!=",
"null",
")",
"{",
"target",
".",
"addAttribute",
"(",
"\"modelReference\"",
",",
"modelRefAttr",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}"
] | Helper method, adds all model references of an attributable to the given
tag.
@param object
Attributable element.
@param target
Tag to add model references to. | [
"Helper",
"method",
"adds",
"all",
"model",
"references",
"of",
"an",
"attributable",
"to",
"the",
"given",
"tag",
"."
] | train | https://github.com/iig-uni-freiburg/SEWOL/blob/e791cb07a6e62ecf837d760d58a25f32fbf6bbca/ext/org/deckfour/xes/out/XMxmlSerializer.java#L296-L303 |
Impetus/Kundera | src/kundera-cassandra/cassandra-core/src/main/java/com/impetus/client/cassandra/thrift/CQLTranslator.java | CQLTranslator.buildOrderByClause | public void buildOrderByClause(StringBuilder builder, String field, Object orderType, boolean useToken) {
"""
Builds the order by clause.
@param builder
the builder
@param field
the field
@param orderType
the order type
@param useToken
the use token
"""
builder.append(SPACE_STRING);
builder.append(SORT_CLAUSE);
builder = ensureCase(builder, field, useToken);
builder.append(SPACE_STRING);
builder.append(orderType);
} | java | public void buildOrderByClause(StringBuilder builder, String field, Object orderType, boolean useToken)
{
builder.append(SPACE_STRING);
builder.append(SORT_CLAUSE);
builder = ensureCase(builder, field, useToken);
builder.append(SPACE_STRING);
builder.append(orderType);
} | [
"public",
"void",
"buildOrderByClause",
"(",
"StringBuilder",
"builder",
",",
"String",
"field",
",",
"Object",
"orderType",
",",
"boolean",
"useToken",
")",
"{",
"builder",
".",
"append",
"(",
"SPACE_STRING",
")",
";",
"builder",
".",
"append",
"(",
"SORT_CLAUSE",
")",
";",
"builder",
"=",
"ensureCase",
"(",
"builder",
",",
"field",
",",
"useToken",
")",
";",
"builder",
".",
"append",
"(",
"SPACE_STRING",
")",
";",
"builder",
".",
"append",
"(",
"orderType",
")",
";",
"}"
] | Builds the order by clause.
@param builder
the builder
@param field
the field
@param orderType
the order type
@param useToken
the use token | [
"Builds",
"the",
"order",
"by",
"clause",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-cassandra/cassandra-core/src/main/java/com/impetus/client/cassandra/thrift/CQLTranslator.java#L1488-L1495 |
bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/PeerGroup.java | PeerGroup.addConnectedEventListener | public void addConnectedEventListener(Executor executor, PeerConnectedEventListener listener) {
"""
<p>Adds a listener that will be notified on the given executor when
new peers are connected to.</p>
"""
peerConnectedEventListeners.add(new ListenerRegistration<>(checkNotNull(listener), executor));
for (Peer peer : getConnectedPeers())
peer.addConnectedEventListener(executor, listener);
for (Peer peer : getPendingPeers())
peer.addConnectedEventListener(executor, listener);
} | java | public void addConnectedEventListener(Executor executor, PeerConnectedEventListener listener) {
peerConnectedEventListeners.add(new ListenerRegistration<>(checkNotNull(listener), executor));
for (Peer peer : getConnectedPeers())
peer.addConnectedEventListener(executor, listener);
for (Peer peer : getPendingPeers())
peer.addConnectedEventListener(executor, listener);
} | [
"public",
"void",
"addConnectedEventListener",
"(",
"Executor",
"executor",
",",
"PeerConnectedEventListener",
"listener",
")",
"{",
"peerConnectedEventListeners",
".",
"add",
"(",
"new",
"ListenerRegistration",
"<>",
"(",
"checkNotNull",
"(",
"listener",
")",
",",
"executor",
")",
")",
";",
"for",
"(",
"Peer",
"peer",
":",
"getConnectedPeers",
"(",
")",
")",
"peer",
".",
"addConnectedEventListener",
"(",
"executor",
",",
"listener",
")",
";",
"for",
"(",
"Peer",
"peer",
":",
"getPendingPeers",
"(",
")",
")",
"peer",
".",
"addConnectedEventListener",
"(",
"executor",
",",
"listener",
")",
";",
"}"
] | <p>Adds a listener that will be notified on the given executor when
new peers are connected to.</p> | [
"<p",
">",
"Adds",
"a",
"listener",
"that",
"will",
"be",
"notified",
"on",
"the",
"given",
"executor",
"when",
"new",
"peers",
"are",
"connected",
"to",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/PeerGroup.java#L673-L679 |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/util/StringUtilities.java | StringUtilities.getOccurrenceCount | public static int getOccurrenceCount(String expr, String str) {
"""
Returns the number of occurrences of the substring in the given string.
@param expr The string to look for occurrences of
@param str The string to search
@return The number of occurences
"""
int ret = 0;
Pattern p = Pattern.compile(expr);
Matcher m = p.matcher(str);
while(m.find())
++ret;
return ret;
} | java | public static int getOccurrenceCount(String expr, String str)
{
int ret = 0;
Pattern p = Pattern.compile(expr);
Matcher m = p.matcher(str);
while(m.find())
++ret;
return ret;
} | [
"public",
"static",
"int",
"getOccurrenceCount",
"(",
"String",
"expr",
",",
"String",
"str",
")",
"{",
"int",
"ret",
"=",
"0",
";",
"Pattern",
"p",
"=",
"Pattern",
".",
"compile",
"(",
"expr",
")",
";",
"Matcher",
"m",
"=",
"p",
".",
"matcher",
"(",
"str",
")",
";",
"while",
"(",
"m",
".",
"find",
"(",
")",
")",
"++",
"ret",
";",
"return",
"ret",
";",
"}"
] | Returns the number of occurrences of the substring in the given string.
@param expr The string to look for occurrences of
@param str The string to search
@return The number of occurences | [
"Returns",
"the",
"number",
"of",
"occurrences",
"of",
"the",
"substring",
"in",
"the",
"given",
"string",
"."
] | train | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/util/StringUtilities.java#L301-L309 |
audit4j/audit4j-core | src/main/java/org/audit4j/core/annotation/DeIdentifyUtil.java | DeIdentifyUtil.deidentifyRight | public static String deidentifyRight(String str, int size) {
"""
Deidentify right.
@param str the str
@param size the size
@return the string
@since 2.0.0
"""
int end = str.length();
int repeat;
if (size > str.length()) {
repeat = str.length();
} else {
repeat = size;
}
return StringUtils.overlay(str, StringUtils.repeat('*', repeat), end - size, end);
} | java | public static String deidentifyRight(String str, int size) {
int end = str.length();
int repeat;
if (size > str.length()) {
repeat = str.length();
} else {
repeat = size;
}
return StringUtils.overlay(str, StringUtils.repeat('*', repeat), end - size, end);
} | [
"public",
"static",
"String",
"deidentifyRight",
"(",
"String",
"str",
",",
"int",
"size",
")",
"{",
"int",
"end",
"=",
"str",
".",
"length",
"(",
")",
";",
"int",
"repeat",
";",
"if",
"(",
"size",
">",
"str",
".",
"length",
"(",
")",
")",
"{",
"repeat",
"=",
"str",
".",
"length",
"(",
")",
";",
"}",
"else",
"{",
"repeat",
"=",
"size",
";",
"}",
"return",
"StringUtils",
".",
"overlay",
"(",
"str",
",",
"StringUtils",
".",
"repeat",
"(",
"'",
"'",
",",
"repeat",
")",
",",
"end",
"-",
"size",
",",
"end",
")",
";",
"}"
] | Deidentify right.
@param str the str
@param size the size
@return the string
@since 2.0.0 | [
"Deidentify",
"right",
"."
] | train | https://github.com/audit4j/audit4j-core/blob/dc8569108851e64cb0ecc7a39048db0ad070fba2/src/main/java/org/audit4j/core/annotation/DeIdentifyUtil.java#L68-L77 |
phax/ph-oton | ph-oton-uicore/src/main/java/com/helger/photon/uicore/html/swf/HCSWFObject.java | HCSWFObject.addFlashVar | @Nonnull
public final HCSWFObject addFlashVar (@Nonnull final String sName, final Object aValue) {
"""
Add a parameter to be passed to the Flash object
@param sName
Parameter name
@param aValue
Parameter value
@return this
"""
if (!JSMarshaller.isJSIdentifier (sName))
throw new IllegalArgumentException ("The name '" + sName + "' is not a legal JS identifier!");
if (m_aFlashVars == null)
m_aFlashVars = new CommonsLinkedHashMap <> ();
m_aFlashVars.put (sName, aValue);
return this;
} | java | @Nonnull
public final HCSWFObject addFlashVar (@Nonnull final String sName, final Object aValue)
{
if (!JSMarshaller.isJSIdentifier (sName))
throw new IllegalArgumentException ("The name '" + sName + "' is not a legal JS identifier!");
if (m_aFlashVars == null)
m_aFlashVars = new CommonsLinkedHashMap <> ();
m_aFlashVars.put (sName, aValue);
return this;
} | [
"@",
"Nonnull",
"public",
"final",
"HCSWFObject",
"addFlashVar",
"(",
"@",
"Nonnull",
"final",
"String",
"sName",
",",
"final",
"Object",
"aValue",
")",
"{",
"if",
"(",
"!",
"JSMarshaller",
".",
"isJSIdentifier",
"(",
"sName",
")",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The name '\"",
"+",
"sName",
"+",
"\"' is not a legal JS identifier!\"",
")",
";",
"if",
"(",
"m_aFlashVars",
"==",
"null",
")",
"m_aFlashVars",
"=",
"new",
"CommonsLinkedHashMap",
"<>",
"(",
")",
";",
"m_aFlashVars",
".",
"put",
"(",
"sName",
",",
"aValue",
")",
";",
"return",
"this",
";",
"}"
] | Add a parameter to be passed to the Flash object
@param sName
Parameter name
@param aValue
Parameter value
@return this | [
"Add",
"a",
"parameter",
"to",
"be",
"passed",
"to",
"the",
"Flash",
"object"
] | train | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-uicore/src/main/java/com/helger/photon/uicore/html/swf/HCSWFObject.java#L168-L178 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/X400Address.java | X400Address.constrains | public int constrains(GeneralNameInterface inputName) throws UnsupportedOperationException {
"""
Return type of constraint inputName places on this name:<ul>
<li>NAME_DIFF_TYPE = -1: input name is different type from name (i.e. does not constrain).
<li>NAME_MATCH = 0: input name matches name.
<li>NAME_NARROWS = 1: input name narrows name (is lower in the naming subtree)
<li>NAME_WIDENS = 2: input name widens name (is higher in the naming subtree)
<li>NAME_SAME_TYPE = 3: input name does not match or narrow name, but is same type.
</ul>. These results are used in checking NameConstraints during
certification path verification.
@param inputName to be checked for being constrained
@returns constraint type above
@throws UnsupportedOperationException if name is same type, but comparison operations are
not supported for this name type.
"""
int constraintType;
if (inputName == null)
constraintType = NAME_DIFF_TYPE;
else if (inputName.getType() != NAME_X400)
constraintType = NAME_DIFF_TYPE;
else
//Narrowing, widening, and match constraints not defined in rfc2459 for X400Address
throw new UnsupportedOperationException("Narrowing, widening, and match are not supported for X400Address.");
return constraintType;
} | java | public int constrains(GeneralNameInterface inputName) throws UnsupportedOperationException {
int constraintType;
if (inputName == null)
constraintType = NAME_DIFF_TYPE;
else if (inputName.getType() != NAME_X400)
constraintType = NAME_DIFF_TYPE;
else
//Narrowing, widening, and match constraints not defined in rfc2459 for X400Address
throw new UnsupportedOperationException("Narrowing, widening, and match are not supported for X400Address.");
return constraintType;
} | [
"public",
"int",
"constrains",
"(",
"GeneralNameInterface",
"inputName",
")",
"throws",
"UnsupportedOperationException",
"{",
"int",
"constraintType",
";",
"if",
"(",
"inputName",
"==",
"null",
")",
"constraintType",
"=",
"NAME_DIFF_TYPE",
";",
"else",
"if",
"(",
"inputName",
".",
"getType",
"(",
")",
"!=",
"NAME_X400",
")",
"constraintType",
"=",
"NAME_DIFF_TYPE",
";",
"else",
"//Narrowing, widening, and match constraints not defined in rfc2459 for X400Address",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Narrowing, widening, and match are not supported for X400Address.\"",
")",
";",
"return",
"constraintType",
";",
"}"
] | Return type of constraint inputName places on this name:<ul>
<li>NAME_DIFF_TYPE = -1: input name is different type from name (i.e. does not constrain).
<li>NAME_MATCH = 0: input name matches name.
<li>NAME_NARROWS = 1: input name narrows name (is lower in the naming subtree)
<li>NAME_WIDENS = 2: input name widens name (is higher in the naming subtree)
<li>NAME_SAME_TYPE = 3: input name does not match or narrow name, but is same type.
</ul>. These results are used in checking NameConstraints during
certification path verification.
@param inputName to be checked for being constrained
@returns constraint type above
@throws UnsupportedOperationException if name is same type, but comparison operations are
not supported for this name type. | [
"Return",
"type",
"of",
"constraint",
"inputName",
"places",
"on",
"this",
"name",
":",
"<ul",
">",
"<li",
">",
"NAME_DIFF_TYPE",
"=",
"-",
"1",
":",
"input",
"name",
"is",
"different",
"type",
"from",
"name",
"(",
"i",
".",
"e",
".",
"does",
"not",
"constrain",
")",
".",
"<li",
">",
"NAME_MATCH",
"=",
"0",
":",
"input",
"name",
"matches",
"name",
".",
"<li",
">",
"NAME_NARROWS",
"=",
"1",
":",
"input",
"name",
"narrows",
"name",
"(",
"is",
"lower",
"in",
"the",
"naming",
"subtree",
")",
"<li",
">",
"NAME_WIDENS",
"=",
"2",
":",
"input",
"name",
"widens",
"name",
"(",
"is",
"higher",
"in",
"the",
"naming",
"subtree",
")",
"<li",
">",
"NAME_SAME_TYPE",
"=",
"3",
":",
"input",
"name",
"does",
"not",
"match",
"or",
"narrow",
"name",
"but",
"is",
"same",
"type",
".",
"<",
"/",
"ul",
">",
".",
"These",
"results",
"are",
"used",
"in",
"checking",
"NameConstraints",
"during",
"certification",
"path",
"verification",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/X400Address.java#L399-L409 |
orbisgis/h2gis | h2gis-functions/src/main/java/org/h2gis/functions/spatial/edit/ST_RemoveRepeatedPoints.java | ST_RemoveRepeatedPoints.removeDuplicateCoordinates | public static Polygon removeDuplicateCoordinates(Polygon polygon, double tolerance) throws SQLException {
"""
Removes duplicated coordinates within a Polygon.
@param polygon the input polygon
@param tolerance to delete the coordinates
@return
@throws java.sql.SQLException
"""
Coordinate[] shellCoords = CoordinateUtils.removeRepeatedCoordinates(polygon.getExteriorRing().getCoordinates(),tolerance,true);
LinearRing shell = FACTORY.createLinearRing(shellCoords);
ArrayList<LinearRing> holes = new ArrayList<LinearRing>();
for (int i = 0; i < polygon.getNumInteriorRing(); i++) {
Coordinate[] holeCoords = CoordinateUtils.removeRepeatedCoordinates(polygon.getInteriorRingN(i).getCoordinates(), tolerance, true);
if (holeCoords.length < 4) {
throw new SQLException("Not enough coordinates to build a new LinearRing.\n Please adjust the tolerance");
}
holes.add(FACTORY.createLinearRing(holeCoords));
}
return FACTORY.createPolygon(shell, GeometryFactory.toLinearRingArray(holes));
} | java | public static Polygon removeDuplicateCoordinates(Polygon polygon, double tolerance) throws SQLException {
Coordinate[] shellCoords = CoordinateUtils.removeRepeatedCoordinates(polygon.getExteriorRing().getCoordinates(),tolerance,true);
LinearRing shell = FACTORY.createLinearRing(shellCoords);
ArrayList<LinearRing> holes = new ArrayList<LinearRing>();
for (int i = 0; i < polygon.getNumInteriorRing(); i++) {
Coordinate[] holeCoords = CoordinateUtils.removeRepeatedCoordinates(polygon.getInteriorRingN(i).getCoordinates(), tolerance, true);
if (holeCoords.length < 4) {
throw new SQLException("Not enough coordinates to build a new LinearRing.\n Please adjust the tolerance");
}
holes.add(FACTORY.createLinearRing(holeCoords));
}
return FACTORY.createPolygon(shell, GeometryFactory.toLinearRingArray(holes));
} | [
"public",
"static",
"Polygon",
"removeDuplicateCoordinates",
"(",
"Polygon",
"polygon",
",",
"double",
"tolerance",
")",
"throws",
"SQLException",
"{",
"Coordinate",
"[",
"]",
"shellCoords",
"=",
"CoordinateUtils",
".",
"removeRepeatedCoordinates",
"(",
"polygon",
".",
"getExteriorRing",
"(",
")",
".",
"getCoordinates",
"(",
")",
",",
"tolerance",
",",
"true",
")",
";",
"LinearRing",
"shell",
"=",
"FACTORY",
".",
"createLinearRing",
"(",
"shellCoords",
")",
";",
"ArrayList",
"<",
"LinearRing",
">",
"holes",
"=",
"new",
"ArrayList",
"<",
"LinearRing",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"polygon",
".",
"getNumInteriorRing",
"(",
")",
";",
"i",
"++",
")",
"{",
"Coordinate",
"[",
"]",
"holeCoords",
"=",
"CoordinateUtils",
".",
"removeRepeatedCoordinates",
"(",
"polygon",
".",
"getInteriorRingN",
"(",
"i",
")",
".",
"getCoordinates",
"(",
")",
",",
"tolerance",
",",
"true",
")",
";",
"if",
"(",
"holeCoords",
".",
"length",
"<",
"4",
")",
"{",
"throw",
"new",
"SQLException",
"(",
"\"Not enough coordinates to build a new LinearRing.\\n Please adjust the tolerance\"",
")",
";",
"}",
"holes",
".",
"add",
"(",
"FACTORY",
".",
"createLinearRing",
"(",
"holeCoords",
")",
")",
";",
"}",
"return",
"FACTORY",
".",
"createPolygon",
"(",
"shell",
",",
"GeometryFactory",
".",
"toLinearRingArray",
"(",
"holes",
")",
")",
";",
"}"
] | Removes duplicated coordinates within a Polygon.
@param polygon the input polygon
@param tolerance to delete the coordinates
@return
@throws java.sql.SQLException | [
"Removes",
"duplicated",
"coordinates",
"within",
"a",
"Polygon",
"."
] | train | https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/edit/ST_RemoveRepeatedPoints.java#L157-L169 |
OpenLiberty/open-liberty | dev/com.ibm.ws.session/src/com/ibm/ws/session/StoreCallback.java | StoreCallback.sessionLastAccessTimeSet | public void sessionLastAccessTimeSet(ISession session, long old, long newaccess) {
"""
Method sessionLastAccessTimeSet
<p>
@param session
@param old
@param newaccess
@see com.ibm.wsspi.session.IStoreCallback#sessionLastAccessTimeSet(com.ibm.wsspi.session.ISession, long, long)
"""
_sessionStateEventDispatcher.sessionLastAccessTimeSet(session, old, newaccess);
} | java | public void sessionLastAccessTimeSet(ISession session, long old, long newaccess) {
_sessionStateEventDispatcher.sessionLastAccessTimeSet(session, old, newaccess);
} | [
"public",
"void",
"sessionLastAccessTimeSet",
"(",
"ISession",
"session",
",",
"long",
"old",
",",
"long",
"newaccess",
")",
"{",
"_sessionStateEventDispatcher",
".",
"sessionLastAccessTimeSet",
"(",
"session",
",",
"old",
",",
"newaccess",
")",
";",
"}"
] | Method sessionLastAccessTimeSet
<p>
@param session
@param old
@param newaccess
@see com.ibm.wsspi.session.IStoreCallback#sessionLastAccessTimeSet(com.ibm.wsspi.session.ISession, long, long) | [
"Method",
"sessionLastAccessTimeSet",
"<p",
">"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.session/src/com/ibm/ws/session/StoreCallback.java#L224-L227 |
pravega/pravega | segmentstore/server/src/main/java/io/pravega/segmentstore/server/writer/SegmentAggregator.java | SegmentAggregator.mergeIfNecessary | private CompletableFuture<WriterFlushResult> mergeIfNecessary(WriterFlushResult flushResult, TimeoutTimer timer) {
"""
Executes a merger of a Transaction StreamSegment into this one.
Conditions for merger:
<ul>
<li> This StreamSegment is stand-alone (not a Transaction).
<li> The next outstanding operation is a MergeSegmentOperation for a Transaction StreamSegment of this StreamSegment.
<li> The StreamSegment to merge is not deleted, it is sealed and is fully flushed to Storage.
</ul>
Effects of the merger:
<ul> The entire contents of the given Transaction StreamSegment will be concatenated to this StreamSegment as one unit.
<li> The metadata for this StreamSegment will be updated to reflect the new length of this StreamSegment.
<li> The given Transaction Segment will cease to exist.
</ul>
<p>
Note that various other data integrity checks are done pre and post merger as part of this operation which are meant
to ensure the StreamSegment is not in a corrupted state.
@param flushResult The flush result from the previous chained operation.
@param timer Timer for the operation.
@return A CompletableFuture that, when completed, will contain the number of bytes that were merged into this
StreamSegment. If failed, the Future will contain the exception that caused it.
"""
ensureInitializedAndNotClosed();
long traceId = LoggerHelpers.traceEnterWithContext(log, this.traceObjectId, "mergeIfNecessary");
StorageOperation first = this.operations.getFirst();
if (first == null || !(first instanceof MergeSegmentOperation)) {
// Either no operation or first operation is not a MergeTransaction. Nothing to do.
LoggerHelpers.traceLeave(log, this.traceObjectId, "mergeIfNecessary", traceId, flushResult);
return CompletableFuture.completedFuture(flushResult);
}
MergeSegmentOperation mergeSegmentOperation = (MergeSegmentOperation) first;
UpdateableSegmentMetadata transactionMetadata = this.dataSource.getStreamSegmentMetadata(mergeSegmentOperation.getSourceSegmentId());
return mergeWith(transactionMetadata, mergeSegmentOperation, timer)
.thenApply(mergeResult -> {
flushResult.withFlushResult(mergeResult);
LoggerHelpers.traceLeave(log, this.traceObjectId, "mergeIfNecessary", traceId, flushResult);
return flushResult;
});
} | java | private CompletableFuture<WriterFlushResult> mergeIfNecessary(WriterFlushResult flushResult, TimeoutTimer timer) {
ensureInitializedAndNotClosed();
long traceId = LoggerHelpers.traceEnterWithContext(log, this.traceObjectId, "mergeIfNecessary");
StorageOperation first = this.operations.getFirst();
if (first == null || !(first instanceof MergeSegmentOperation)) {
// Either no operation or first operation is not a MergeTransaction. Nothing to do.
LoggerHelpers.traceLeave(log, this.traceObjectId, "mergeIfNecessary", traceId, flushResult);
return CompletableFuture.completedFuture(flushResult);
}
MergeSegmentOperation mergeSegmentOperation = (MergeSegmentOperation) first;
UpdateableSegmentMetadata transactionMetadata = this.dataSource.getStreamSegmentMetadata(mergeSegmentOperation.getSourceSegmentId());
return mergeWith(transactionMetadata, mergeSegmentOperation, timer)
.thenApply(mergeResult -> {
flushResult.withFlushResult(mergeResult);
LoggerHelpers.traceLeave(log, this.traceObjectId, "mergeIfNecessary", traceId, flushResult);
return flushResult;
});
} | [
"private",
"CompletableFuture",
"<",
"WriterFlushResult",
">",
"mergeIfNecessary",
"(",
"WriterFlushResult",
"flushResult",
",",
"TimeoutTimer",
"timer",
")",
"{",
"ensureInitializedAndNotClosed",
"(",
")",
";",
"long",
"traceId",
"=",
"LoggerHelpers",
".",
"traceEnterWithContext",
"(",
"log",
",",
"this",
".",
"traceObjectId",
",",
"\"mergeIfNecessary\"",
")",
";",
"StorageOperation",
"first",
"=",
"this",
".",
"operations",
".",
"getFirst",
"(",
")",
";",
"if",
"(",
"first",
"==",
"null",
"||",
"!",
"(",
"first",
"instanceof",
"MergeSegmentOperation",
")",
")",
"{",
"// Either no operation or first operation is not a MergeTransaction. Nothing to do.",
"LoggerHelpers",
".",
"traceLeave",
"(",
"log",
",",
"this",
".",
"traceObjectId",
",",
"\"mergeIfNecessary\"",
",",
"traceId",
",",
"flushResult",
")",
";",
"return",
"CompletableFuture",
".",
"completedFuture",
"(",
"flushResult",
")",
";",
"}",
"MergeSegmentOperation",
"mergeSegmentOperation",
"=",
"(",
"MergeSegmentOperation",
")",
"first",
";",
"UpdateableSegmentMetadata",
"transactionMetadata",
"=",
"this",
".",
"dataSource",
".",
"getStreamSegmentMetadata",
"(",
"mergeSegmentOperation",
".",
"getSourceSegmentId",
"(",
")",
")",
";",
"return",
"mergeWith",
"(",
"transactionMetadata",
",",
"mergeSegmentOperation",
",",
"timer",
")",
".",
"thenApply",
"(",
"mergeResult",
"->",
"{",
"flushResult",
".",
"withFlushResult",
"(",
"mergeResult",
")",
";",
"LoggerHelpers",
".",
"traceLeave",
"(",
"log",
",",
"this",
".",
"traceObjectId",
",",
"\"mergeIfNecessary\"",
",",
"traceId",
",",
"flushResult",
")",
";",
"return",
"flushResult",
";",
"}",
")",
";",
"}"
] | Executes a merger of a Transaction StreamSegment into this one.
Conditions for merger:
<ul>
<li> This StreamSegment is stand-alone (not a Transaction).
<li> The next outstanding operation is a MergeSegmentOperation for a Transaction StreamSegment of this StreamSegment.
<li> The StreamSegment to merge is not deleted, it is sealed and is fully flushed to Storage.
</ul>
Effects of the merger:
<ul> The entire contents of the given Transaction StreamSegment will be concatenated to this StreamSegment as one unit.
<li> The metadata for this StreamSegment will be updated to reflect the new length of this StreamSegment.
<li> The given Transaction Segment will cease to exist.
</ul>
<p>
Note that various other data integrity checks are done pre and post merger as part of this operation which are meant
to ensure the StreamSegment is not in a corrupted state.
@param flushResult The flush result from the previous chained operation.
@param timer Timer for the operation.
@return A CompletableFuture that, when completed, will contain the number of bytes that were merged into this
StreamSegment. If failed, the Future will contain the exception that caused it. | [
"Executes",
"a",
"merger",
"of",
"a",
"Transaction",
"StreamSegment",
"into",
"this",
"one",
".",
"Conditions",
"for",
"merger",
":",
"<ul",
">",
"<li",
">",
"This",
"StreamSegment",
"is",
"stand",
"-",
"alone",
"(",
"not",
"a",
"Transaction",
")",
".",
"<li",
">",
"The",
"next",
"outstanding",
"operation",
"is",
"a",
"MergeSegmentOperation",
"for",
"a",
"Transaction",
"StreamSegment",
"of",
"this",
"StreamSegment",
".",
"<li",
">",
"The",
"StreamSegment",
"to",
"merge",
"is",
"not",
"deleted",
"it",
"is",
"sealed",
"and",
"is",
"fully",
"flushed",
"to",
"Storage",
".",
"<",
"/",
"ul",
">",
"Effects",
"of",
"the",
"merger",
":",
"<ul",
">",
"The",
"entire",
"contents",
"of",
"the",
"given",
"Transaction",
"StreamSegment",
"will",
"be",
"concatenated",
"to",
"this",
"StreamSegment",
"as",
"one",
"unit",
".",
"<li",
">",
"The",
"metadata",
"for",
"this",
"StreamSegment",
"will",
"be",
"updated",
"to",
"reflect",
"the",
"new",
"length",
"of",
"this",
"StreamSegment",
".",
"<li",
">",
"The",
"given",
"Transaction",
"Segment",
"will",
"cease",
"to",
"exist",
".",
"<",
"/",
"ul",
">",
"<p",
">",
"Note",
"that",
"various",
"other",
"data",
"integrity",
"checks",
"are",
"done",
"pre",
"and",
"post",
"merger",
"as",
"part",
"of",
"this",
"operation",
"which",
"are",
"meant",
"to",
"ensure",
"the",
"StreamSegment",
"is",
"not",
"in",
"a",
"corrupted",
"state",
"."
] | train | https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/segmentstore/server/src/main/java/io/pravega/segmentstore/server/writer/SegmentAggregator.java#L861-L880 |
SimiaCryptus/utilities | java-util/src/main/java/com/simiacryptus/util/Util.java | Util.pathTo | public static String pathTo(@javax.annotation.Nonnull final File from, @javax.annotation.Nonnull final File to) {
"""
Path to string.
@param from the from
@param to the to
@return the string
"""
return from.toPath().relativize(to.toPath()).toString().replaceAll("\\\\", "/");
} | java | public static String pathTo(@javax.annotation.Nonnull final File from, @javax.annotation.Nonnull final File to) {
return from.toPath().relativize(to.toPath()).toString().replaceAll("\\\\", "/");
} | [
"public",
"static",
"String",
"pathTo",
"(",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"File",
"from",
",",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"File",
"to",
")",
"{",
"return",
"from",
".",
"toPath",
"(",
")",
".",
"relativize",
"(",
"to",
".",
"toPath",
"(",
")",
")",
".",
"toString",
"(",
")",
".",
"replaceAll",
"(",
"\"\\\\\\\\\"",
",",
"\"/\"",
")",
";",
"}"
] | Path to string.
@param from the from
@param to the to
@return the string | [
"Path",
"to",
"string",
"."
] | train | https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/Util.java#L356-L358 |
trellis-ldp/trellis | core/http/src/main/java/org/trellisldp/http/impl/HttpUtils.java | HttpUtils.checkIfUnmodifiedSince | public static void checkIfUnmodifiedSince(final String ifUnmodifiedSince, final Instant modified) {
"""
Check for a conditional operation.
@param ifUnmodifiedSince the If-Unmodified-Since header
@param modified the resource modification date
"""
final Instant time = parseDate(ifUnmodifiedSince);
if (time != null && modified.truncatedTo(SECONDS).isAfter(time)) {
throw new ClientErrorException(status(PRECONDITION_FAILED).build());
}
} | java | public static void checkIfUnmodifiedSince(final String ifUnmodifiedSince, final Instant modified) {
final Instant time = parseDate(ifUnmodifiedSince);
if (time != null && modified.truncatedTo(SECONDS).isAfter(time)) {
throw new ClientErrorException(status(PRECONDITION_FAILED).build());
}
} | [
"public",
"static",
"void",
"checkIfUnmodifiedSince",
"(",
"final",
"String",
"ifUnmodifiedSince",
",",
"final",
"Instant",
"modified",
")",
"{",
"final",
"Instant",
"time",
"=",
"parseDate",
"(",
"ifUnmodifiedSince",
")",
";",
"if",
"(",
"time",
"!=",
"null",
"&&",
"modified",
".",
"truncatedTo",
"(",
"SECONDS",
")",
".",
"isAfter",
"(",
"time",
")",
")",
"{",
"throw",
"new",
"ClientErrorException",
"(",
"status",
"(",
"PRECONDITION_FAILED",
")",
".",
"build",
"(",
")",
")",
";",
"}",
"}"
] | Check for a conditional operation.
@param ifUnmodifiedSince the If-Unmodified-Since header
@param modified the resource modification date | [
"Check",
"for",
"a",
"conditional",
"operation",
"."
] | train | https://github.com/trellis-ldp/trellis/blob/789fd7a3df86cab7ebba63e72bf4e58397e5f42d/core/http/src/main/java/org/trellisldp/http/impl/HttpUtils.java#L324-L329 |
grycap/coreutils | coreutils-fiber/src/main/java/es/upv/grycap/coreutils/fiber/http/Http2Client.java | Http2Client.asyncGet | public void asyncGet(final String url, final @Nullable List<String> acceptableMediaTypes, final boolean nocache, final Callback callback) {
"""
Retrieve information from a server via a HTTP GET request.
@param url - URL target of this request
@param acceptableMediaTypes - Content-Types that are acceptable for this request
@param nocache - don't accept an invalidated cached response, and don't store the server's response in any cache
@param callback - is called back when the response is readable
"""
final String url2 = requireNonNull(trimToNull(url), "A non-empty URL expected");
requireNonNull(callback, "A valid callback expected");
// configure cache
final CacheControl.Builder cacheControlBuilder = new CacheControl.Builder();
if (nocache) cacheControlBuilder.noCache().noStore();
else cacheControlBuilder.maxStale(3600, TimeUnit.SECONDS);
// prepare request
final Request.Builder requestBuilder = new Request.Builder().cacheControl(cacheControlBuilder.build()).url(url2);
ofNullable(acceptableMediaTypes).orElse(emptyList()).stream().filter(Objects::nonNull).forEach(type -> requestBuilder.addHeader("Accept", type));
// submit request
client.newCall(requestBuilder.build()).enqueue(callback);
} | java | public void asyncGet(final String url, final @Nullable List<String> acceptableMediaTypes, final boolean nocache, final Callback callback) {
final String url2 = requireNonNull(trimToNull(url), "A non-empty URL expected");
requireNonNull(callback, "A valid callback expected");
// configure cache
final CacheControl.Builder cacheControlBuilder = new CacheControl.Builder();
if (nocache) cacheControlBuilder.noCache().noStore();
else cacheControlBuilder.maxStale(3600, TimeUnit.SECONDS);
// prepare request
final Request.Builder requestBuilder = new Request.Builder().cacheControl(cacheControlBuilder.build()).url(url2);
ofNullable(acceptableMediaTypes).orElse(emptyList()).stream().filter(Objects::nonNull).forEach(type -> requestBuilder.addHeader("Accept", type));
// submit request
client.newCall(requestBuilder.build()).enqueue(callback);
} | [
"public",
"void",
"asyncGet",
"(",
"final",
"String",
"url",
",",
"final",
"@",
"Nullable",
"List",
"<",
"String",
">",
"acceptableMediaTypes",
",",
"final",
"boolean",
"nocache",
",",
"final",
"Callback",
"callback",
")",
"{",
"final",
"String",
"url2",
"=",
"requireNonNull",
"(",
"trimToNull",
"(",
"url",
")",
",",
"\"A non-empty URL expected\"",
")",
";",
"requireNonNull",
"(",
"callback",
",",
"\"A valid callback expected\"",
")",
";",
"// configure cache",
"final",
"CacheControl",
".",
"Builder",
"cacheControlBuilder",
"=",
"new",
"CacheControl",
".",
"Builder",
"(",
")",
";",
"if",
"(",
"nocache",
")",
"cacheControlBuilder",
".",
"noCache",
"(",
")",
".",
"noStore",
"(",
")",
";",
"else",
"cacheControlBuilder",
".",
"maxStale",
"(",
"3600",
",",
"TimeUnit",
".",
"SECONDS",
")",
";",
"// prepare request",
"final",
"Request",
".",
"Builder",
"requestBuilder",
"=",
"new",
"Request",
".",
"Builder",
"(",
")",
".",
"cacheControl",
"(",
"cacheControlBuilder",
".",
"build",
"(",
")",
")",
".",
"url",
"(",
"url2",
")",
";",
"ofNullable",
"(",
"acceptableMediaTypes",
")",
".",
"orElse",
"(",
"emptyList",
"(",
")",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"Objects",
"::",
"nonNull",
")",
".",
"forEach",
"(",
"type",
"->",
"requestBuilder",
".",
"addHeader",
"(",
"\"Accept\"",
",",
"type",
")",
")",
";",
"// submit request",
"client",
".",
"newCall",
"(",
"requestBuilder",
".",
"build",
"(",
")",
")",
".",
"enqueue",
"(",
"callback",
")",
";",
"}"
] | Retrieve information from a server via a HTTP GET request.
@param url - URL target of this request
@param acceptableMediaTypes - Content-Types that are acceptable for this request
@param nocache - don't accept an invalidated cached response, and don't store the server's response in any cache
@param callback - is called back when the response is readable | [
"Retrieve",
"information",
"from",
"a",
"server",
"via",
"a",
"HTTP",
"GET",
"request",
"."
] | train | https://github.com/grycap/coreutils/blob/e6db61dc50b49ea7276c0c29c7401204681a10c2/coreutils-fiber/src/main/java/es/upv/grycap/coreutils/fiber/http/Http2Client.java#L93-L105 |
astrapi69/jaulp-wicket | jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/labeled/label/LabeledEnumLabelPanel.java | LabeledEnumLabelPanel.newEnumLabel | @SuppressWarnings( {
"""
Factory method for create a new {@link EnumLabel}. This method is invoked in the constructor
from the derived classes and can be overridden so users can provide their own version of a
new {@link EnumLabel}.
@param id
the id
@param model
the model of the label
@return the new {@link EnumLabel}.
""" "rawtypes", "unchecked" })
protected EnumLabel newEnumLabel(final String id, final IModel<T> model)
{
final IModel viewableLabelModel = new PropertyModel(model.getObject(), this.getId());
return ComponentFactory.newEnumLabel(id, viewableLabelModel);
} | java | @SuppressWarnings({ "rawtypes", "unchecked" })
protected EnumLabel newEnumLabel(final String id, final IModel<T> model)
{
final IModel viewableLabelModel = new PropertyModel(model.getObject(), this.getId());
return ComponentFactory.newEnumLabel(id, viewableLabelModel);
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"rawtypes\"",
",",
"\"unchecked\"",
"}",
")",
"protected",
"EnumLabel",
"newEnumLabel",
"(",
"final",
"String",
"id",
",",
"final",
"IModel",
"<",
"T",
">",
"model",
")",
"{",
"final",
"IModel",
"viewableLabelModel",
"=",
"new",
"PropertyModel",
"(",
"model",
".",
"getObject",
"(",
")",
",",
"this",
".",
"getId",
"(",
")",
")",
";",
"return",
"ComponentFactory",
".",
"newEnumLabel",
"(",
"id",
",",
"viewableLabelModel",
")",
";",
"}"
] | Factory method for create a new {@link EnumLabel}. This method is invoked in the constructor
from the derived classes and can be overridden so users can provide their own version of a
new {@link EnumLabel}.
@param id
the id
@param model
the model of the label
@return the new {@link EnumLabel}. | [
"Factory",
"method",
"for",
"create",
"a",
"new",
"{",
"@link",
"EnumLabel",
"}",
".",
"This",
"method",
"is",
"invoked",
"in",
"the",
"constructor",
"from",
"the",
"derived",
"classes",
"and",
"can",
"be",
"overridden",
"so",
"users",
"can",
"provide",
"their",
"own",
"version",
"of",
"a",
"new",
"{",
"@link",
"EnumLabel",
"}",
"."
] | train | https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/labeled/label/LabeledEnumLabelPanel.java#L80-L85 |
OpenLiberty/open-liberty | dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/osgi/container/config/WebAppConfigurator.java | WebAppConfigurator.configureWebAppHelperFactory | public void configureWebAppHelperFactory(WebAppConfiguratorHelperFactory webAppConfiguratorHelperFactory, ResourceRefConfigFactory resourceRefConfigFactory) {
"""
Configure the WebApp helper factory
@param webAppConfiguratorHelperFactory The factory to be used
@param resourceRefConfigFactory
"""
webAppHelper = webAppConfiguratorHelperFactory.createWebAppConfiguratorHelper(this, resourceRefConfigFactory, getListenerInterfaces());
this.configHelpers.add(webAppHelper);
} | java | public void configureWebAppHelperFactory(WebAppConfiguratorHelperFactory webAppConfiguratorHelperFactory, ResourceRefConfigFactory resourceRefConfigFactory) {
webAppHelper = webAppConfiguratorHelperFactory.createWebAppConfiguratorHelper(this, resourceRefConfigFactory, getListenerInterfaces());
this.configHelpers.add(webAppHelper);
} | [
"public",
"void",
"configureWebAppHelperFactory",
"(",
"WebAppConfiguratorHelperFactory",
"webAppConfiguratorHelperFactory",
",",
"ResourceRefConfigFactory",
"resourceRefConfigFactory",
")",
"{",
"webAppHelper",
"=",
"webAppConfiguratorHelperFactory",
".",
"createWebAppConfiguratorHelper",
"(",
"this",
",",
"resourceRefConfigFactory",
",",
"getListenerInterfaces",
"(",
")",
")",
";",
"this",
".",
"configHelpers",
".",
"add",
"(",
"webAppHelper",
")",
";",
"}"
] | Configure the WebApp helper factory
@param webAppConfiguratorHelperFactory The factory to be used
@param resourceRefConfigFactory | [
"Configure",
"the",
"WebApp",
"helper",
"factory"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/osgi/container/config/WebAppConfigurator.java#L217-L220 |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/alg/transform/ii/IntegralImageOps.java | IntegralImageOps.convolveSparse | public static int convolveSparse(GrayS32 integral , IntegralKernel kernel , int x , int y ) {
"""
Convolves a kernel around a single point in the integral image.
@param integral Input integral image. Not modified.
@param kernel Convolution kernel.
@param x Pixel the convolution is performed at.
@param y Pixel the convolution is performed at.
@return Value of the convolution
"""
return ImplIntegralImageOps.convolveSparse(integral, kernel, x, y);
} | java | public static int convolveSparse(GrayS32 integral , IntegralKernel kernel , int x , int y )
{
return ImplIntegralImageOps.convolveSparse(integral, kernel, x, y);
} | [
"public",
"static",
"int",
"convolveSparse",
"(",
"GrayS32",
"integral",
",",
"IntegralKernel",
"kernel",
",",
"int",
"x",
",",
"int",
"y",
")",
"{",
"return",
"ImplIntegralImageOps",
".",
"convolveSparse",
"(",
"integral",
",",
"kernel",
",",
"x",
",",
"y",
")",
";",
"}"
] | Convolves a kernel around a single point in the integral image.
@param integral Input integral image. Not modified.
@param kernel Convolution kernel.
@param x Pixel the convolution is performed at.
@param y Pixel the convolution is performed at.
@return Value of the convolution | [
"Convolves",
"a",
"kernel",
"around",
"a",
"single",
"point",
"in",
"the",
"integral",
"image",
"."
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/transform/ii/IntegralImageOps.java#L340-L343 |
Azure/azure-sdk-for-java | mysql/resource-manager/v2017_12_01/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01/implementation/ServersInner.java | ServersInner.beginCreate | public ServerInner beginCreate(String resourceGroupName, String serverName, ServerForCreate parameters) {
"""
Creates a new server or updates an existing server. The update action will overwrite the existing server.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param parameters The required parameters for creating or updating a server.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the ServerInner object if successful.
"""
return beginCreateWithServiceResponseAsync(resourceGroupName, serverName, parameters).toBlocking().single().body();
} | java | public ServerInner beginCreate(String resourceGroupName, String serverName, ServerForCreate parameters) {
return beginCreateWithServiceResponseAsync(resourceGroupName, serverName, parameters).toBlocking().single().body();
} | [
"public",
"ServerInner",
"beginCreate",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"ServerForCreate",
"parameters",
")",
"{",
"return",
"beginCreateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
",",
"parameters",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Creates a new server or updates an existing server. The update action will overwrite the existing server.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param parameters The required parameters for creating or updating a server.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the ServerInner object if successful. | [
"Creates",
"a",
"new",
"server",
"or",
"updates",
"an",
"existing",
"server",
".",
"The",
"update",
"action",
"will",
"overwrite",
"the",
"existing",
"server",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/mysql/resource-manager/v2017_12_01/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01/implementation/ServersInner.java#L193-L195 |
wcm-io/wcm-io-handler | commons/src/main/java/io/wcm/handler/commons/dom/HtmlElement.java | HtmlElement.setData | public final T setData(String attributeName, String value) {
"""
Custom Html5 "data-*" attribute.
@param attributeName Name of HTML5 data attribute (without the 'data-' prefix).
@param value Value of attribute
@return Self reference
"""
setAttribute(ATTRIBUTE_DATA_PREFIX + attributeName, value);
return (T)this;
} | java | public final T setData(String attributeName, String value) {
setAttribute(ATTRIBUTE_DATA_PREFIX + attributeName, value);
return (T)this;
} | [
"public",
"final",
"T",
"setData",
"(",
"String",
"attributeName",
",",
"String",
"value",
")",
"{",
"setAttribute",
"(",
"ATTRIBUTE_DATA_PREFIX",
"+",
"attributeName",
",",
"value",
")",
";",
"return",
"(",
"T",
")",
"this",
";",
"}"
] | Custom Html5 "data-*" attribute.
@param attributeName Name of HTML5 data attribute (without the 'data-' prefix).
@param value Value of attribute
@return Self reference | [
"Custom",
"Html5",
"data",
"-",
"*",
"attribute",
"."
] | train | https://github.com/wcm-io/wcm-io-handler/blob/b0fc1c11a3ceb89efb73826dcfd480d6a00c19af/commons/src/main/java/io/wcm/handler/commons/dom/HtmlElement.java#L246-L249 |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/splitmerge/SplitMergeLineFitLoop.java | SplitMergeLineFitLoop.splitPixels | protected void splitPixels(int indexStart, int length) {
"""
Recursively splits pixels between indexStart to indexStart+length. A split happens if there is a pixel
more than the desired distance away from the two end points. Results are placed into 'splits'
"""
// too short to split
if( length < minimumSideLengthPixel)
return;
// end points of the line
int indexEnd = (indexStart+length)%N;
int splitOffset = selectSplitOffset(indexStart,length);
if( splitOffset >= 0 ) {
// System.out.println(" splitting ");
splitPixels(indexStart, splitOffset);
int indexSplit = (indexStart+splitOffset)%N;
splits.add(indexSplit);
splitPixels(indexSplit, circularDistance(indexSplit, indexEnd));
}
} | java | protected void splitPixels(int indexStart, int length) {
// too short to split
if( length < minimumSideLengthPixel)
return;
// end points of the line
int indexEnd = (indexStart+length)%N;
int splitOffset = selectSplitOffset(indexStart,length);
if( splitOffset >= 0 ) {
// System.out.println(" splitting ");
splitPixels(indexStart, splitOffset);
int indexSplit = (indexStart+splitOffset)%N;
splits.add(indexSplit);
splitPixels(indexSplit, circularDistance(indexSplit, indexEnd));
}
} | [
"protected",
"void",
"splitPixels",
"(",
"int",
"indexStart",
",",
"int",
"length",
")",
"{",
"// too short to split",
"if",
"(",
"length",
"<",
"minimumSideLengthPixel",
")",
"return",
";",
"// end points of the line",
"int",
"indexEnd",
"=",
"(",
"indexStart",
"+",
"length",
")",
"%",
"N",
";",
"int",
"splitOffset",
"=",
"selectSplitOffset",
"(",
"indexStart",
",",
"length",
")",
";",
"if",
"(",
"splitOffset",
">=",
"0",
")",
"{",
"//\t\t\tSystem.out.println(\" splitting \");",
"splitPixels",
"(",
"indexStart",
",",
"splitOffset",
")",
";",
"int",
"indexSplit",
"=",
"(",
"indexStart",
"+",
"splitOffset",
")",
"%",
"N",
";",
"splits",
".",
"add",
"(",
"indexSplit",
")",
";",
"splitPixels",
"(",
"indexSplit",
",",
"circularDistance",
"(",
"indexSplit",
",",
"indexEnd",
")",
")",
";",
"}",
"}"
] | Recursively splits pixels between indexStart to indexStart+length. A split happens if there is a pixel
more than the desired distance away from the two end points. Results are placed into 'splits' | [
"Recursively",
"splits",
"pixels",
"between",
"indexStart",
"to",
"indexStart",
"+",
"length",
".",
"A",
"split",
"happens",
"if",
"there",
"is",
"a",
"pixel",
"more",
"than",
"the",
"desired",
"distance",
"away",
"from",
"the",
"two",
"end",
"points",
".",
"Results",
"are",
"placed",
"into",
"splits"
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/splitmerge/SplitMergeLineFitLoop.java#L98-L115 |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/services/path/PathManagerService.java | PathManagerService.addPathEntry | final PathEntry addPathEntry(final String pathName, final String path, final String relativeTo, final boolean readOnly) {
"""
Adds an entry for a path and sends an {@link org.jboss.as.controller.services.path.PathManager.Event#ADDED}
notification to any registered {@linkplain org.jboss.as.controller.services.path.PathManager.Callback callbacks}.
@param pathName the logical name of the path within the model. Cannot be {@code null}
@param path the value of the path within the model. This is either an absolute path or
the relative portion of the path. Cannot be {@code null}
@param relativeTo the name of the path this path is relative to. If {@code null} this is an absolute path
@param readOnly {@code true} if the path is immutable, and cannot be removed or modified via a management operation
@return the entry that represents the path
@throws RuntimeException if an entry with the given {@code pathName} is already registered
"""
PathEntry pathEntry;
synchronized (pathEntries) {
if (pathEntries.containsKey(pathName)) {
throw ControllerLogger.ROOT_LOGGER.pathEntryAlreadyExists(pathName);
}
pathEntry = new PathEntry(pathName, path, relativeTo, readOnly, relativeTo == null ? absoluteResolver : relativeResolver);
pathEntries.put(pathName, pathEntry);
if (relativeTo != null) {
addDependent(pathName, relativeTo);
}
}
triggerCallbacksForEvent(pathEntry, Event.ADDED);
return pathEntry;
} | java | final PathEntry addPathEntry(final String pathName, final String path, final String relativeTo, final boolean readOnly) {
PathEntry pathEntry;
synchronized (pathEntries) {
if (pathEntries.containsKey(pathName)) {
throw ControllerLogger.ROOT_LOGGER.pathEntryAlreadyExists(pathName);
}
pathEntry = new PathEntry(pathName, path, relativeTo, readOnly, relativeTo == null ? absoluteResolver : relativeResolver);
pathEntries.put(pathName, pathEntry);
if (relativeTo != null) {
addDependent(pathName, relativeTo);
}
}
triggerCallbacksForEvent(pathEntry, Event.ADDED);
return pathEntry;
} | [
"final",
"PathEntry",
"addPathEntry",
"(",
"final",
"String",
"pathName",
",",
"final",
"String",
"path",
",",
"final",
"String",
"relativeTo",
",",
"final",
"boolean",
"readOnly",
")",
"{",
"PathEntry",
"pathEntry",
";",
"synchronized",
"(",
"pathEntries",
")",
"{",
"if",
"(",
"pathEntries",
".",
"containsKey",
"(",
"pathName",
")",
")",
"{",
"throw",
"ControllerLogger",
".",
"ROOT_LOGGER",
".",
"pathEntryAlreadyExists",
"(",
"pathName",
")",
";",
"}",
"pathEntry",
"=",
"new",
"PathEntry",
"(",
"pathName",
",",
"path",
",",
"relativeTo",
",",
"readOnly",
",",
"relativeTo",
"==",
"null",
"?",
"absoluteResolver",
":",
"relativeResolver",
")",
";",
"pathEntries",
".",
"put",
"(",
"pathName",
",",
"pathEntry",
")",
";",
"if",
"(",
"relativeTo",
"!=",
"null",
")",
"{",
"addDependent",
"(",
"pathName",
",",
"relativeTo",
")",
";",
"}",
"}",
"triggerCallbacksForEvent",
"(",
"pathEntry",
",",
"Event",
".",
"ADDED",
")",
";",
"return",
"pathEntry",
";",
"}"
] | Adds an entry for a path and sends an {@link org.jboss.as.controller.services.path.PathManager.Event#ADDED}
notification to any registered {@linkplain org.jboss.as.controller.services.path.PathManager.Callback callbacks}.
@param pathName the logical name of the path within the model. Cannot be {@code null}
@param path the value of the path within the model. This is either an absolute path or
the relative portion of the path. Cannot be {@code null}
@param relativeTo the name of the path this path is relative to. If {@code null} this is an absolute path
@param readOnly {@code true} if the path is immutable, and cannot be removed or modified via a management operation
@return the entry that represents the path
@throws RuntimeException if an entry with the given {@code pathName} is already registered | [
"Adds",
"an",
"entry",
"for",
"a",
"path",
"and",
"sends",
"an",
"{",
"@link",
"org",
".",
"jboss",
".",
"as",
".",
"controller",
".",
"services",
".",
"path",
".",
"PathManager",
".",
"Event#ADDED",
"}",
"notification",
"to",
"any",
"registered",
"{",
"@linkplain",
"org",
".",
"jboss",
".",
"as",
".",
"controller",
".",
"services",
".",
"path",
".",
"PathManager",
".",
"Callback",
"callbacks",
"}",
"."
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/services/path/PathManagerService.java#L295-L310 |
alkacon/opencms-core | src/org/opencms/lock/CmsLockManager.java | CmsLockManager.removeResourcesInProject | public void removeResourcesInProject(CmsUUID projectId, boolean removeSystemLocks) {
"""
Removes all resources locked in a project.<p>
@param projectId the ID of the project where the resources have been locked
@param removeSystemLocks if <code>true</code>, also system locks are removed
"""
Iterator<CmsLock> itLocks = OpenCms.getMemoryMonitor().getAllCachedLocks().iterator();
while (itLocks.hasNext()) {
CmsLock currentLock = itLocks.next();
if (removeSystemLocks && currentLock.getSystemLock().getProjectId().equals(projectId)) {
unlockResource(currentLock.getResourceName(), true);
}
if (currentLock.getEditionLock().getProjectId().equals(projectId)) {
unlockResource(currentLock.getResourceName(), false);
}
}
} | java | public void removeResourcesInProject(CmsUUID projectId, boolean removeSystemLocks) {
Iterator<CmsLock> itLocks = OpenCms.getMemoryMonitor().getAllCachedLocks().iterator();
while (itLocks.hasNext()) {
CmsLock currentLock = itLocks.next();
if (removeSystemLocks && currentLock.getSystemLock().getProjectId().equals(projectId)) {
unlockResource(currentLock.getResourceName(), true);
}
if (currentLock.getEditionLock().getProjectId().equals(projectId)) {
unlockResource(currentLock.getResourceName(), false);
}
}
} | [
"public",
"void",
"removeResourcesInProject",
"(",
"CmsUUID",
"projectId",
",",
"boolean",
"removeSystemLocks",
")",
"{",
"Iterator",
"<",
"CmsLock",
">",
"itLocks",
"=",
"OpenCms",
".",
"getMemoryMonitor",
"(",
")",
".",
"getAllCachedLocks",
"(",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"itLocks",
".",
"hasNext",
"(",
")",
")",
"{",
"CmsLock",
"currentLock",
"=",
"itLocks",
".",
"next",
"(",
")",
";",
"if",
"(",
"removeSystemLocks",
"&&",
"currentLock",
".",
"getSystemLock",
"(",
")",
".",
"getProjectId",
"(",
")",
".",
"equals",
"(",
"projectId",
")",
")",
"{",
"unlockResource",
"(",
"currentLock",
".",
"getResourceName",
"(",
")",
",",
"true",
")",
";",
"}",
"if",
"(",
"currentLock",
".",
"getEditionLock",
"(",
")",
".",
"getProjectId",
"(",
")",
".",
"equals",
"(",
"projectId",
")",
")",
"{",
"unlockResource",
"(",
"currentLock",
".",
"getResourceName",
"(",
")",
",",
"false",
")",
";",
"}",
"}",
"}"
] | Removes all resources locked in a project.<p>
@param projectId the ID of the project where the resources have been locked
@param removeSystemLocks if <code>true</code>, also system locks are removed | [
"Removes",
"all",
"resources",
"locked",
"in",
"a",
"project",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/lock/CmsLockManager.java#L627-L639 |
BranchMetrics/android-branch-deep-linking | Branch-SDK/src/io/branch/referral/Branch.java | Branch.initSession | public boolean initSession(BranchUniversalReferralInitListener callback, Uri data, Activity activity) {
"""
<p>Initialises a session with the Branch API.</p>
@param callback A {@link BranchUniversalReferralInitListener} instance that will be called
following successful (or unsuccessful) initialisation of the session
with the Branch API.
@param data A {@link Uri} variable containing the details of the source link that
led to this initialisation action.
@param activity The calling {@link Activity} for context.
@return A {@link Boolean} value that will return <i>false</i> if the supplied
<i>data</i> parameter cannot be handled successfully - i.e. is not of a
valid URI format.
"""
readAndStripParam(data, activity);
initSession(callback, activity);
return true;
} | java | public boolean initSession(BranchUniversalReferralInitListener callback, Uri data, Activity activity) {
readAndStripParam(data, activity);
initSession(callback, activity);
return true;
} | [
"public",
"boolean",
"initSession",
"(",
"BranchUniversalReferralInitListener",
"callback",
",",
"Uri",
"data",
",",
"Activity",
"activity",
")",
"{",
"readAndStripParam",
"(",
"data",
",",
"activity",
")",
";",
"initSession",
"(",
"callback",
",",
"activity",
")",
";",
"return",
"true",
";",
"}"
] | <p>Initialises a session with the Branch API.</p>
@param callback A {@link BranchUniversalReferralInitListener} instance that will be called
following successful (or unsuccessful) initialisation of the session
with the Branch API.
@param data A {@link Uri} variable containing the details of the source link that
led to this initialisation action.
@param activity The calling {@link Activity} for context.
@return A {@link Boolean} value that will return <i>false</i> if the supplied
<i>data</i> parameter cannot be handled successfully - i.e. is not of a
valid URI format. | [
"<p",
">",
"Initialises",
"a",
"session",
"with",
"the",
"Branch",
"API",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/BranchMetrics/android-branch-deep-linking/blob/e3bee2ccfcbf6d4bf1a5815b5b86666e4ff8f848/Branch-SDK/src/io/branch/referral/Branch.java#L1073-L1077 |
Omertron/api-themoviedb | src/main/java/com/omertron/themoviedbapi/methods/TmdbMovies.java | TmdbMovies.getReleaseDates | public ResultList<ReleaseDates> getReleaseDates(int movieId) throws MovieDbException {
"""
Get the release dates, certifications and related information by country for a specific movie id.
The results are keyed by country code and contain a type value.
@param movieId
@return
@throws MovieDbException
"""
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, movieId);
URL url = new ApiUrl(apiKey, MethodBase.MOVIE).subMethod(MethodSub.RELEASE_DATES).buildUrl(parameters);
WrapperGenericList<ReleaseDates> wrapper = processWrapper(getTypeReference(ReleaseDates.class), url, "release dates");
return wrapper.getResultsList();
} | java | public ResultList<ReleaseDates> getReleaseDates(int movieId) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, movieId);
URL url = new ApiUrl(apiKey, MethodBase.MOVIE).subMethod(MethodSub.RELEASE_DATES).buildUrl(parameters);
WrapperGenericList<ReleaseDates> wrapper = processWrapper(getTypeReference(ReleaseDates.class), url, "release dates");
return wrapper.getResultsList();
} | [
"public",
"ResultList",
"<",
"ReleaseDates",
">",
"getReleaseDates",
"(",
"int",
"movieId",
")",
"throws",
"MovieDbException",
"{",
"TmdbParameters",
"parameters",
"=",
"new",
"TmdbParameters",
"(",
")",
";",
"parameters",
".",
"add",
"(",
"Param",
".",
"ID",
",",
"movieId",
")",
";",
"URL",
"url",
"=",
"new",
"ApiUrl",
"(",
"apiKey",
",",
"MethodBase",
".",
"MOVIE",
")",
".",
"subMethod",
"(",
"MethodSub",
".",
"RELEASE_DATES",
")",
".",
"buildUrl",
"(",
"parameters",
")",
";",
"WrapperGenericList",
"<",
"ReleaseDates",
">",
"wrapper",
"=",
"processWrapper",
"(",
"getTypeReference",
"(",
"ReleaseDates",
".",
"class",
")",
",",
"url",
",",
"\"release dates\"",
")",
";",
"return",
"wrapper",
".",
"getResultsList",
"(",
")",
";",
"}"
] | Get the release dates, certifications and related information by country for a specific movie id.
The results are keyed by country code and contain a type value.
@param movieId
@return
@throws MovieDbException | [
"Get",
"the",
"release",
"dates",
"certifications",
"and",
"related",
"information",
"by",
"country",
"for",
"a",
"specific",
"movie",
"id",
"."
] | train | https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbMovies.java#L346-L353 |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/transform/TransformersImpl.java | TransformersImpl.transformAddress | protected static PathAddress transformAddress(final PathAddress original, final TransformationTarget target) {
"""
Transform a path address.
@param original the path address to be transformed
@param target the transformation target
@return the transformed path address
"""
final List<PathAddressTransformer> transformers = target.getPathTransformation(original);
final Iterator<PathAddressTransformer> transformations = transformers.iterator();
final PathAddressTransformer.BuilderImpl builder = new PathAddressTransformer.BuilderImpl(transformations, original);
return builder.start();
} | java | protected static PathAddress transformAddress(final PathAddress original, final TransformationTarget target) {
final List<PathAddressTransformer> transformers = target.getPathTransformation(original);
final Iterator<PathAddressTransformer> transformations = transformers.iterator();
final PathAddressTransformer.BuilderImpl builder = new PathAddressTransformer.BuilderImpl(transformations, original);
return builder.start();
} | [
"protected",
"static",
"PathAddress",
"transformAddress",
"(",
"final",
"PathAddress",
"original",
",",
"final",
"TransformationTarget",
"target",
")",
"{",
"final",
"List",
"<",
"PathAddressTransformer",
">",
"transformers",
"=",
"target",
".",
"getPathTransformation",
"(",
"original",
")",
";",
"final",
"Iterator",
"<",
"PathAddressTransformer",
">",
"transformations",
"=",
"transformers",
".",
"iterator",
"(",
")",
";",
"final",
"PathAddressTransformer",
".",
"BuilderImpl",
"builder",
"=",
"new",
"PathAddressTransformer",
".",
"BuilderImpl",
"(",
"transformations",
",",
"original",
")",
";",
"return",
"builder",
".",
"start",
"(",
")",
";",
"}"
] | Transform a path address.
@param original the path address to be transformed
@param target the transformation target
@return the transformed path address | [
"Transform",
"a",
"path",
"address",
"."
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/transform/TransformersImpl.java#L159-L164 |
alexvasilkov/GestureViews | library/src/main/java/com/alexvasilkov/gestures/utils/GravityUtils.java | GravityUtils.getDefaultPivot | public static void getDefaultPivot(Settings settings, Point out) {
"""
Calculates default pivot point for scale and rotation.
@param settings Image settings
@param out Output point
"""
getMovementAreaPosition(settings, tmpRect2);
Gravity.apply(settings.getGravity(), 0, 0, tmpRect2, tmpRect1);
out.set(tmpRect1.left, tmpRect1.top);
} | java | public static void getDefaultPivot(Settings settings, Point out) {
getMovementAreaPosition(settings, tmpRect2);
Gravity.apply(settings.getGravity(), 0, 0, tmpRect2, tmpRect1);
out.set(tmpRect1.left, tmpRect1.top);
} | [
"public",
"static",
"void",
"getDefaultPivot",
"(",
"Settings",
"settings",
",",
"Point",
"out",
")",
"{",
"getMovementAreaPosition",
"(",
"settings",
",",
"tmpRect2",
")",
";",
"Gravity",
".",
"apply",
"(",
"settings",
".",
"getGravity",
"(",
")",
",",
"0",
",",
"0",
",",
"tmpRect2",
",",
"tmpRect1",
")",
";",
"out",
".",
"set",
"(",
"tmpRect1",
".",
"left",
",",
"tmpRect1",
".",
"top",
")",
";",
"}"
] | Calculates default pivot point for scale and rotation.
@param settings Image settings
@param out Output point | [
"Calculates",
"default",
"pivot",
"point",
"for",
"scale",
"and",
"rotation",
"."
] | train | https://github.com/alexvasilkov/GestureViews/blob/f0a4c266e31dcad23bd0d9013531bc1c501b9c9f/library/src/main/java/com/alexvasilkov/gestures/utils/GravityUtils.java#L73-L77 |
ironjacamar/ironjacamar | codegenerator/src/main/java/org/ironjacamar/codegenerator/xml/Ra10XmlGen.java | Ra10XmlGen.writeXmlBody | @Override
public void writeXmlBody(Definition def, Writer out) throws IOException {
"""
Output xml
@param def definition
@param out Writer
@throws IOException ioException
"""
writeConnectorVersion(out);
int indent = 1;
writeIndent(out, indent);
out.write("<display-name>Display Name</display-name>");
writeEol(out);
writeIndent(out, indent);
out.write("<vendor-name>Red Hat Inc</vendor-name>");
writeEol(out);
writeIndent(out, indent);
out.write("<spec-version>1.0</spec-version>");
writeEol(out);
writeIndent(out, indent);
out.write("<eis-type>Test RA</eis-type>");
writeEol(out);
writeIndent(out, indent);
out.write("<version>0.1</version>");
writeEol(out);
writeIndent(out, indent);
out.write("<resourceadapter>");
writeEol(out);
writeOutbound(def, out, indent + 1);
writeIndent(out, indent);
out.write("</resourceadapter>");
writeEol(out);
out.write("</connector>");
writeEol(out);
} | java | @Override
public void writeXmlBody(Definition def, Writer out) throws IOException
{
writeConnectorVersion(out);
int indent = 1;
writeIndent(out, indent);
out.write("<display-name>Display Name</display-name>");
writeEol(out);
writeIndent(out, indent);
out.write("<vendor-name>Red Hat Inc</vendor-name>");
writeEol(out);
writeIndent(out, indent);
out.write("<spec-version>1.0</spec-version>");
writeEol(out);
writeIndent(out, indent);
out.write("<eis-type>Test RA</eis-type>");
writeEol(out);
writeIndent(out, indent);
out.write("<version>0.1</version>");
writeEol(out);
writeIndent(out, indent);
out.write("<resourceadapter>");
writeEol(out);
writeOutbound(def, out, indent + 1);
writeIndent(out, indent);
out.write("</resourceadapter>");
writeEol(out);
out.write("</connector>");
writeEol(out);
} | [
"@",
"Override",
"public",
"void",
"writeXmlBody",
"(",
"Definition",
"def",
",",
"Writer",
"out",
")",
"throws",
"IOException",
"{",
"writeConnectorVersion",
"(",
"out",
")",
";",
"int",
"indent",
"=",
"1",
";",
"writeIndent",
"(",
"out",
",",
"indent",
")",
";",
"out",
".",
"write",
"(",
"\"<display-name>Display Name</display-name>\"",
")",
";",
"writeEol",
"(",
"out",
")",
";",
"writeIndent",
"(",
"out",
",",
"indent",
")",
";",
"out",
".",
"write",
"(",
"\"<vendor-name>Red Hat Inc</vendor-name>\"",
")",
";",
"writeEol",
"(",
"out",
")",
";",
"writeIndent",
"(",
"out",
",",
"indent",
")",
";",
"out",
".",
"write",
"(",
"\"<spec-version>1.0</spec-version>\"",
")",
";",
"writeEol",
"(",
"out",
")",
";",
"writeIndent",
"(",
"out",
",",
"indent",
")",
";",
"out",
".",
"write",
"(",
"\"<eis-type>Test RA</eis-type>\"",
")",
";",
"writeEol",
"(",
"out",
")",
";",
"writeIndent",
"(",
"out",
",",
"indent",
")",
";",
"out",
".",
"write",
"(",
"\"<version>0.1</version>\"",
")",
";",
"writeEol",
"(",
"out",
")",
";",
"writeIndent",
"(",
"out",
",",
"indent",
")",
";",
"out",
".",
"write",
"(",
"\"<resourceadapter>\"",
")",
";",
"writeEol",
"(",
"out",
")",
";",
"writeOutbound",
"(",
"def",
",",
"out",
",",
"indent",
"+",
"1",
")",
";",
"writeIndent",
"(",
"out",
",",
"indent",
")",
";",
"out",
".",
"write",
"(",
"\"</resourceadapter>\"",
")",
";",
"writeEol",
"(",
"out",
")",
";",
"out",
".",
"write",
"(",
"\"</connector>\"",
")",
";",
"writeEol",
"(",
"out",
")",
";",
"}"
] | Output xml
@param def definition
@param out Writer
@throws IOException ioException | [
"Output",
"xml"
] | train | https://github.com/ironjacamar/ironjacamar/blob/f0389ee7e62aa8b40ba09b251edad76d220ea796/codegenerator/src/main/java/org/ironjacamar/codegenerator/xml/Ra10XmlGen.java#L45-L78 |
voldemort/voldemort | src/java/voldemort/server/protocol/admin/AsyncOperationService.java | AsyncOperationService.submitOperation | public synchronized void submitOperation(int requestId, AsyncOperation operation) {
"""
Submit a operations. Throw a run time exception if the operations is
already submitted
@param operation The asynchronous operations to submit
@param requestId Id of the request
"""
if(this.operations.containsKey(requestId))
throw new VoldemortException("Request " + requestId
+ " already submitted to the system");
this.operations.put(requestId, operation);
scheduler.scheduleNow(operation);
logger.debug("Handling async operation " + requestId);
} | java | public synchronized void submitOperation(int requestId, AsyncOperation operation) {
if(this.operations.containsKey(requestId))
throw new VoldemortException("Request " + requestId
+ " already submitted to the system");
this.operations.put(requestId, operation);
scheduler.scheduleNow(operation);
logger.debug("Handling async operation " + requestId);
} | [
"public",
"synchronized",
"void",
"submitOperation",
"(",
"int",
"requestId",
",",
"AsyncOperation",
"operation",
")",
"{",
"if",
"(",
"this",
".",
"operations",
".",
"containsKey",
"(",
"requestId",
")",
")",
"throw",
"new",
"VoldemortException",
"(",
"\"Request \"",
"+",
"requestId",
"+",
"\" already submitted to the system\"",
")",
";",
"this",
".",
"operations",
".",
"put",
"(",
"requestId",
",",
"operation",
")",
";",
"scheduler",
".",
"scheduleNow",
"(",
"operation",
")",
";",
"logger",
".",
"debug",
"(",
"\"Handling async operation \"",
"+",
"requestId",
")",
";",
"}"
] | Submit a operations. Throw a run time exception if the operations is
already submitted
@param operation The asynchronous operations to submit
@param requestId Id of the request | [
"Submit",
"a",
"operations",
".",
"Throw",
"a",
"run",
"time",
"exception",
"if",
"the",
"operations",
"is",
"already",
"submitted"
] | train | https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/server/protocol/admin/AsyncOperationService.java#L68-L76 |
bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/PeerGroup.java | PeerGroup.connectTo | @Nullable
public Peer connectTo(InetSocketAddress address) {
"""
Connect to a peer by creating a channel to the destination address. This should not be
used normally - let the PeerGroup manage connections through {@link #start()}
@param address destination IP and port.
@return The newly created Peer object or null if the peer could not be connected.
Use {@link Peer#getConnectionOpenFuture()} if you
want a future which completes when the connection is open.
"""
lock.lock();
try {
PeerAddress peerAddress = new PeerAddress(params, address);
backoffMap.put(peerAddress, new ExponentialBackoff(peerBackoffParams));
return connectTo(peerAddress, true, vConnectTimeoutMillis);
} finally {
lock.unlock();
}
} | java | @Nullable
public Peer connectTo(InetSocketAddress address) {
lock.lock();
try {
PeerAddress peerAddress = new PeerAddress(params, address);
backoffMap.put(peerAddress, new ExponentialBackoff(peerBackoffParams));
return connectTo(peerAddress, true, vConnectTimeoutMillis);
} finally {
lock.unlock();
}
} | [
"@",
"Nullable",
"public",
"Peer",
"connectTo",
"(",
"InetSocketAddress",
"address",
")",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"PeerAddress",
"peerAddress",
"=",
"new",
"PeerAddress",
"(",
"params",
",",
"address",
")",
";",
"backoffMap",
".",
"put",
"(",
"peerAddress",
",",
"new",
"ExponentialBackoff",
"(",
"peerBackoffParams",
")",
")",
";",
"return",
"connectTo",
"(",
"peerAddress",
",",
"true",
",",
"vConnectTimeoutMillis",
")",
";",
"}",
"finally",
"{",
"lock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] | Connect to a peer by creating a channel to the destination address. This should not be
used normally - let the PeerGroup manage connections through {@link #start()}
@param address destination IP and port.
@return The newly created Peer object or null if the peer could not be connected.
Use {@link Peer#getConnectionOpenFuture()} if you
want a future which completes when the connection is open. | [
"Connect",
"to",
"a",
"peer",
"by",
"creating",
"a",
"channel",
"to",
"the",
"destination",
"address",
".",
"This",
"should",
"not",
"be",
"used",
"normally",
"-",
"let",
"the",
"PeerGroup",
"manage",
"connections",
"through",
"{",
"@link",
"#start",
"()",
"}"
] | train | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/PeerGroup.java#L1307-L1317 |
Azure/azure-sdk-for-java | applicationinsights/resource-manager/v2015_05_01/src/main/java/com/microsoft/azure/management/applicationinsights/v2015_05_01/implementation/ExportConfigurationsInner.java | ExportConfigurationsInner.deleteAsync | public Observable<ApplicationInsightsComponentExportConfigurationInner> deleteAsync(String resourceGroupName, String resourceName, String exportId) {
"""
Delete a Continuous Export configuration of an Application Insights component.
@param resourceGroupName The name of the resource group.
@param resourceName The name of the Application Insights component resource.
@param exportId The Continuous Export configuration ID. This is unique within a Application Insights component.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ApplicationInsightsComponentExportConfigurationInner object
"""
return deleteWithServiceResponseAsync(resourceGroupName, resourceName, exportId).map(new Func1<ServiceResponse<ApplicationInsightsComponentExportConfigurationInner>, ApplicationInsightsComponentExportConfigurationInner>() {
@Override
public ApplicationInsightsComponentExportConfigurationInner call(ServiceResponse<ApplicationInsightsComponentExportConfigurationInner> response) {
return response.body();
}
});
} | java | public Observable<ApplicationInsightsComponentExportConfigurationInner> deleteAsync(String resourceGroupName, String resourceName, String exportId) {
return deleteWithServiceResponseAsync(resourceGroupName, resourceName, exportId).map(new Func1<ServiceResponse<ApplicationInsightsComponentExportConfigurationInner>, ApplicationInsightsComponentExportConfigurationInner>() {
@Override
public ApplicationInsightsComponentExportConfigurationInner call(ServiceResponse<ApplicationInsightsComponentExportConfigurationInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ApplicationInsightsComponentExportConfigurationInner",
">",
"deleteAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"resourceName",
",",
"String",
"exportId",
")",
"{",
"return",
"deleteWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"resourceName",
",",
"exportId",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"ApplicationInsightsComponentExportConfigurationInner",
">",
",",
"ApplicationInsightsComponentExportConfigurationInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ApplicationInsightsComponentExportConfigurationInner",
"call",
"(",
"ServiceResponse",
"<",
"ApplicationInsightsComponentExportConfigurationInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Delete a Continuous Export configuration of an Application Insights component.
@param resourceGroupName The name of the resource group.
@param resourceName The name of the Application Insights component resource.
@param exportId The Continuous Export configuration ID. This is unique within a Application Insights component.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ApplicationInsightsComponentExportConfigurationInner object | [
"Delete",
"a",
"Continuous",
"Export",
"configuration",
"of",
"an",
"Application",
"Insights",
"component",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/applicationinsights/resource-manager/v2015_05_01/src/main/java/com/microsoft/azure/management/applicationinsights/v2015_05_01/implementation/ExportConfigurationsInner.java#L301-L308 |
roboconf/roboconf-platform | miscellaneous/roboconf-doc-generator/src/main/java/net/roboconf/doc/generator/internal/GraphUtils.java | GraphUtils.writeGraph | public static void writeGraph(
File outputFile,
Component selectedComponent,
Layout<AbstractType,String> layout,
Graph<AbstractType,String> graph ,
AbstractEdgeShapeTransformer<AbstractType,String> edgeShapeTransformer,
Map<String,String> options )
throws IOException {
"""
Writes a graph as a PNG image.
@param outputFile the output file
@param selectedComponent the component to highlight
@param layout the layout
@param graph the graph
@param edgeShapeTransformer the transformer for edge shapes (straight line, curved line, etc)
@throws IOException if something went wrong
"""
VisualizationImageServer<AbstractType,String> vis =
new VisualizationImageServer<AbstractType,String>( layout, layout.getSize());
vis.setBackground( Color.WHITE );
vis.getRenderContext().setEdgeLabelTransformer( new NoStringLabeller ());
vis.getRenderContext().setEdgeShapeTransformer( edgeShapeTransformer );
vis.getRenderContext().setVertexLabelTransformer( new ToStringLabeller<AbstractType> ());
vis.getRenderContext().setVertexShapeTransformer( new VertexShape());
vis.getRenderContext().setVertexFontTransformer( new VertexFont());
Color defaultBgColor = decode( options.get( DocConstants.OPTION_IMG_BACKGROUND_COLOR ), DocConstants.DEFAULT_BACKGROUND_COLOR );
Color highlightBgcolor = decode( options.get( DocConstants.OPTION_IMG_HIGHLIGHT_BG_COLOR ), DocConstants.DEFAULT_HIGHLIGHT_BG_COLOR );
vis.getRenderContext().setVertexFillPaintTransformer( new VertexColor( selectedComponent, defaultBgColor, highlightBgcolor ));
Color defaultFgColor = decode( options.get( DocConstants.OPTION_IMG_FOREGROUND_COLOR ), DocConstants.DEFAULT_FOREGROUND_COLOR );
vis.getRenderContext().setVertexLabelRenderer( new MyVertexLabelRenderer( selectedComponent, defaultFgColor ));
vis.getRenderer().getVertexLabelRenderer().setPosition( Position.CNTR );
BufferedImage image = (BufferedImage) vis.getImage(
new Point2D.Double(
layout.getSize().getWidth() / 2,
layout.getSize().getHeight() / 2),
new Dimension( layout.getSize()));
ImageIO.write( image, "png", outputFile );
} | java | public static void writeGraph(
File outputFile,
Component selectedComponent,
Layout<AbstractType,String> layout,
Graph<AbstractType,String> graph ,
AbstractEdgeShapeTransformer<AbstractType,String> edgeShapeTransformer,
Map<String,String> options )
throws IOException {
VisualizationImageServer<AbstractType,String> vis =
new VisualizationImageServer<AbstractType,String>( layout, layout.getSize());
vis.setBackground( Color.WHITE );
vis.getRenderContext().setEdgeLabelTransformer( new NoStringLabeller ());
vis.getRenderContext().setEdgeShapeTransformer( edgeShapeTransformer );
vis.getRenderContext().setVertexLabelTransformer( new ToStringLabeller<AbstractType> ());
vis.getRenderContext().setVertexShapeTransformer( new VertexShape());
vis.getRenderContext().setVertexFontTransformer( new VertexFont());
Color defaultBgColor = decode( options.get( DocConstants.OPTION_IMG_BACKGROUND_COLOR ), DocConstants.DEFAULT_BACKGROUND_COLOR );
Color highlightBgcolor = decode( options.get( DocConstants.OPTION_IMG_HIGHLIGHT_BG_COLOR ), DocConstants.DEFAULT_HIGHLIGHT_BG_COLOR );
vis.getRenderContext().setVertexFillPaintTransformer( new VertexColor( selectedComponent, defaultBgColor, highlightBgcolor ));
Color defaultFgColor = decode( options.get( DocConstants.OPTION_IMG_FOREGROUND_COLOR ), DocConstants.DEFAULT_FOREGROUND_COLOR );
vis.getRenderContext().setVertexLabelRenderer( new MyVertexLabelRenderer( selectedComponent, defaultFgColor ));
vis.getRenderer().getVertexLabelRenderer().setPosition( Position.CNTR );
BufferedImage image = (BufferedImage) vis.getImage(
new Point2D.Double(
layout.getSize().getWidth() / 2,
layout.getSize().getHeight() / 2),
new Dimension( layout.getSize()));
ImageIO.write( image, "png", outputFile );
} | [
"public",
"static",
"void",
"writeGraph",
"(",
"File",
"outputFile",
",",
"Component",
"selectedComponent",
",",
"Layout",
"<",
"AbstractType",
",",
"String",
">",
"layout",
",",
"Graph",
"<",
"AbstractType",
",",
"String",
">",
"graph",
",",
"AbstractEdgeShapeTransformer",
"<",
"AbstractType",
",",
"String",
">",
"edgeShapeTransformer",
",",
"Map",
"<",
"String",
",",
"String",
">",
"options",
")",
"throws",
"IOException",
"{",
"VisualizationImageServer",
"<",
"AbstractType",
",",
"String",
">",
"vis",
"=",
"new",
"VisualizationImageServer",
"<",
"AbstractType",
",",
"String",
">",
"(",
"layout",
",",
"layout",
".",
"getSize",
"(",
")",
")",
";",
"vis",
".",
"setBackground",
"(",
"Color",
".",
"WHITE",
")",
";",
"vis",
".",
"getRenderContext",
"(",
")",
".",
"setEdgeLabelTransformer",
"(",
"new",
"NoStringLabeller",
"(",
")",
")",
";",
"vis",
".",
"getRenderContext",
"(",
")",
".",
"setEdgeShapeTransformer",
"(",
"edgeShapeTransformer",
")",
";",
"vis",
".",
"getRenderContext",
"(",
")",
".",
"setVertexLabelTransformer",
"(",
"new",
"ToStringLabeller",
"<",
"AbstractType",
">",
"(",
")",
")",
";",
"vis",
".",
"getRenderContext",
"(",
")",
".",
"setVertexShapeTransformer",
"(",
"new",
"VertexShape",
"(",
")",
")",
";",
"vis",
".",
"getRenderContext",
"(",
")",
".",
"setVertexFontTransformer",
"(",
"new",
"VertexFont",
"(",
")",
")",
";",
"Color",
"defaultBgColor",
"=",
"decode",
"(",
"options",
".",
"get",
"(",
"DocConstants",
".",
"OPTION_IMG_BACKGROUND_COLOR",
")",
",",
"DocConstants",
".",
"DEFAULT_BACKGROUND_COLOR",
")",
";",
"Color",
"highlightBgcolor",
"=",
"decode",
"(",
"options",
".",
"get",
"(",
"DocConstants",
".",
"OPTION_IMG_HIGHLIGHT_BG_COLOR",
")",
",",
"DocConstants",
".",
"DEFAULT_HIGHLIGHT_BG_COLOR",
")",
";",
"vis",
".",
"getRenderContext",
"(",
")",
".",
"setVertexFillPaintTransformer",
"(",
"new",
"VertexColor",
"(",
"selectedComponent",
",",
"defaultBgColor",
",",
"highlightBgcolor",
")",
")",
";",
"Color",
"defaultFgColor",
"=",
"decode",
"(",
"options",
".",
"get",
"(",
"DocConstants",
".",
"OPTION_IMG_FOREGROUND_COLOR",
")",
",",
"DocConstants",
".",
"DEFAULT_FOREGROUND_COLOR",
")",
";",
"vis",
".",
"getRenderContext",
"(",
")",
".",
"setVertexLabelRenderer",
"(",
"new",
"MyVertexLabelRenderer",
"(",
"selectedComponent",
",",
"defaultFgColor",
")",
")",
";",
"vis",
".",
"getRenderer",
"(",
")",
".",
"getVertexLabelRenderer",
"(",
")",
".",
"setPosition",
"(",
"Position",
".",
"CNTR",
")",
";",
"BufferedImage",
"image",
"=",
"(",
"BufferedImage",
")",
"vis",
".",
"getImage",
"(",
"new",
"Point2D",
".",
"Double",
"(",
"layout",
".",
"getSize",
"(",
")",
".",
"getWidth",
"(",
")",
"/",
"2",
",",
"layout",
".",
"getSize",
"(",
")",
".",
"getHeight",
"(",
")",
"/",
"2",
")",
",",
"new",
"Dimension",
"(",
"layout",
".",
"getSize",
"(",
")",
")",
")",
";",
"ImageIO",
".",
"write",
"(",
"image",
",",
"\"png\"",
",",
"outputFile",
")",
";",
"}"
] | Writes a graph as a PNG image.
@param outputFile the output file
@param selectedComponent the component to highlight
@param layout the layout
@param graph the graph
@param edgeShapeTransformer the transformer for edge shapes (straight line, curved line, etc)
@throws IOException if something went wrong | [
"Writes",
"a",
"graph",
"as",
"a",
"PNG",
"image",
"."
] | train | https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/miscellaneous/roboconf-doc-generator/src/main/java/net/roboconf/doc/generator/internal/GraphUtils.java#L109-L144 |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java | FormatUtil.formatTo | public static StringBuilder formatTo(StringBuilder buf, double[][] d, String pre, String pos, String csep, NumberFormat nf) {
"""
Formats the array of double arrays d with the specified separators and
fraction digits.
@param buf Output buffer
@param d the double array to be formatted
@param pre Row prefix (e.g. " [")
@param pos Row postfix (e.g. "]\n")
@param csep Separator for columns (e.g. ", ")
@param nf the number format to use
@return Output buffer buf
"""
if(d == null) {
return buf.append("null");
}
if(d.length == 0) {
return buf;
}
for(int i = 0; i < d.length; i++) {
formatTo(buf.append(pre), d[i], csep, nf).append(pos);
}
return buf;
} | java | public static StringBuilder formatTo(StringBuilder buf, double[][] d, String pre, String pos, String csep, NumberFormat nf) {
if(d == null) {
return buf.append("null");
}
if(d.length == 0) {
return buf;
}
for(int i = 0; i < d.length; i++) {
formatTo(buf.append(pre), d[i], csep, nf).append(pos);
}
return buf;
} | [
"public",
"static",
"StringBuilder",
"formatTo",
"(",
"StringBuilder",
"buf",
",",
"double",
"[",
"]",
"[",
"]",
"d",
",",
"String",
"pre",
",",
"String",
"pos",
",",
"String",
"csep",
",",
"NumberFormat",
"nf",
")",
"{",
"if",
"(",
"d",
"==",
"null",
")",
"{",
"return",
"buf",
".",
"append",
"(",
"\"null\"",
")",
";",
"}",
"if",
"(",
"d",
".",
"length",
"==",
"0",
")",
"{",
"return",
"buf",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"d",
".",
"length",
";",
"i",
"++",
")",
"{",
"formatTo",
"(",
"buf",
".",
"append",
"(",
"pre",
")",
",",
"d",
"[",
"i",
"]",
",",
"csep",
",",
"nf",
")",
".",
"append",
"(",
"pos",
")",
";",
"}",
"return",
"buf",
";",
"}"
] | Formats the array of double arrays d with the specified separators and
fraction digits.
@param buf Output buffer
@param d the double array to be formatted
@param pre Row prefix (e.g. " [")
@param pos Row postfix (e.g. "]\n")
@param csep Separator for columns (e.g. ", ")
@param nf the number format to use
@return Output buffer buf | [
"Formats",
"the",
"array",
"of",
"double",
"arrays",
"d",
"with",
"the",
"specified",
"separators",
"and",
"fraction",
"digits",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java#L596-L607 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.