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
|
---|---|---|---|---|---|---|---|---|---|---|
Azure/azure-sdk-for-java | datalakeanalytics/resource-manager/v2015_10_01_preview/src/main/java/com/microsoft/azure/management/datalakeanalytics/v2015_10_01_preview/implementation/AccountsInner.java | AccountsInner.deleteDataLakeStoreAccountAsync | public Observable<Void> deleteDataLakeStoreAccountAsync(String resourceGroupName, String accountName, String dataLakeStoreAccountName) {
"""
Updates the Data Lake Analytics account specified to remove the specified Data Lake Store account.
@param resourceGroupName The name of the Azure resource group that contains the Data Lake Analytics account.
@param accountName The name of the Data Lake Analytics account from which to remove the Data Lake Store account.
@param dataLakeStoreAccountName The name of the Data Lake Store account to remove
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful.
"""
return deleteDataLakeStoreAccountWithServiceResponseAsync(resourceGroupName, accountName, dataLakeStoreAccountName).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | java | public Observable<Void> deleteDataLakeStoreAccountAsync(String resourceGroupName, String accountName, String dataLakeStoreAccountName) {
return deleteDataLakeStoreAccountWithServiceResponseAsync(resourceGroupName, accountName, dataLakeStoreAccountName).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Void",
">",
"deleteDataLakeStoreAccountAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"accountName",
",",
"String",
"dataLakeStoreAccountName",
")",
"{",
"return",
"deleteDataLakeStoreAccountWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"accountName",
",",
"dataLakeStoreAccountName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Void",
">",
",",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
"ServiceResponse",
"<",
"Void",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Updates the Data Lake Analytics account specified to remove the specified Data Lake Store account.
@param resourceGroupName The name of the Azure resource group that contains the Data Lake Analytics account.
@param accountName The name of the Data Lake Analytics account from which to remove the Data Lake Store account.
@param dataLakeStoreAccountName The name of the Data Lake Store account to remove
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful. | [
"Updates",
"the",
"Data",
"Lake",
"Analytics",
"account",
"specified",
"to",
"remove",
"the",
"specified",
"Data",
"Lake",
"Store",
"account",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/datalakeanalytics/resource-manager/v2015_10_01_preview/src/main/java/com/microsoft/azure/management/datalakeanalytics/v2015_10_01_preview/implementation/AccountsInner.java#L1066-L1073 |
IBM/ibm-cos-sdk-java | ibm-cos-java-sdk-s3/src/main/java/com/ibm/cloud/objectstorage/services/s3/transfer/internal/UploadCallable.java | UploadCallable.initiateMultipartUpload | private String initiateMultipartUpload(PutObjectRequest origReq, boolean isUsingEncryption) {
"""
Initiates a multipart upload and returns the upload id
@param isUsingEncryption
"""
InitiateMultipartUploadRequest req = null;
if (isUsingEncryption && origReq instanceof EncryptedPutObjectRequest) {
req = new EncryptedInitiateMultipartUploadRequest(
origReq.getBucketName(), origReq.getKey()).withCannedACL(
origReq.getCannedAcl()).withObjectMetadata(origReq.getMetadata());
((EncryptedInitiateMultipartUploadRequest) req)
.setMaterialsDescription(((EncryptedPutObjectRequest) origReq).getMaterialsDescription());
} else {
req = new InitiateMultipartUploadRequest(origReq.getBucketName(), origReq.getKey())
.withCannedACL(origReq.getCannedAcl())
.withObjectMetadata(origReq.getMetadata());
}
TransferManager.appendMultipartUserAgent(req);
req.withAccessControlList(origReq.getAccessControlList())
.withRequesterPays(origReq.isRequesterPays())
.withStorageClass(origReq.getStorageClass())
.withRedirectLocation(origReq.getRedirectLocation())
.withSSECustomerKey(origReq.getSSECustomerKey())
.withSSEAwsKeyManagementParams(origReq.getSSEAwsKeyManagementParams())
.withGeneralProgressListener(origReq.getGeneralProgressListener())
.withRequestMetricCollector(origReq.getRequestMetricCollector())
;
String uploadId = s3.initiateMultipartUpload(req).getUploadId();
log.debug("Initiated new multipart upload: " + uploadId);
return uploadId;
} | java | private String initiateMultipartUpload(PutObjectRequest origReq, boolean isUsingEncryption) {
InitiateMultipartUploadRequest req = null;
if (isUsingEncryption && origReq instanceof EncryptedPutObjectRequest) {
req = new EncryptedInitiateMultipartUploadRequest(
origReq.getBucketName(), origReq.getKey()).withCannedACL(
origReq.getCannedAcl()).withObjectMetadata(origReq.getMetadata());
((EncryptedInitiateMultipartUploadRequest) req)
.setMaterialsDescription(((EncryptedPutObjectRequest) origReq).getMaterialsDescription());
} else {
req = new InitiateMultipartUploadRequest(origReq.getBucketName(), origReq.getKey())
.withCannedACL(origReq.getCannedAcl())
.withObjectMetadata(origReq.getMetadata());
}
TransferManager.appendMultipartUserAgent(req);
req.withAccessControlList(origReq.getAccessControlList())
.withRequesterPays(origReq.isRequesterPays())
.withStorageClass(origReq.getStorageClass())
.withRedirectLocation(origReq.getRedirectLocation())
.withSSECustomerKey(origReq.getSSECustomerKey())
.withSSEAwsKeyManagementParams(origReq.getSSEAwsKeyManagementParams())
.withGeneralProgressListener(origReq.getGeneralProgressListener())
.withRequestMetricCollector(origReq.getRequestMetricCollector())
;
String uploadId = s3.initiateMultipartUpload(req).getUploadId();
log.debug("Initiated new multipart upload: " + uploadId);
return uploadId;
} | [
"private",
"String",
"initiateMultipartUpload",
"(",
"PutObjectRequest",
"origReq",
",",
"boolean",
"isUsingEncryption",
")",
"{",
"InitiateMultipartUploadRequest",
"req",
"=",
"null",
";",
"if",
"(",
"isUsingEncryption",
"&&",
"origReq",
"instanceof",
"EncryptedPutObjectRequest",
")",
"{",
"req",
"=",
"new",
"EncryptedInitiateMultipartUploadRequest",
"(",
"origReq",
".",
"getBucketName",
"(",
")",
",",
"origReq",
".",
"getKey",
"(",
")",
")",
".",
"withCannedACL",
"(",
"origReq",
".",
"getCannedAcl",
"(",
")",
")",
".",
"withObjectMetadata",
"(",
"origReq",
".",
"getMetadata",
"(",
")",
")",
";",
"(",
"(",
"EncryptedInitiateMultipartUploadRequest",
")",
"req",
")",
".",
"setMaterialsDescription",
"(",
"(",
"(",
"EncryptedPutObjectRequest",
")",
"origReq",
")",
".",
"getMaterialsDescription",
"(",
")",
")",
";",
"}",
"else",
"{",
"req",
"=",
"new",
"InitiateMultipartUploadRequest",
"(",
"origReq",
".",
"getBucketName",
"(",
")",
",",
"origReq",
".",
"getKey",
"(",
")",
")",
".",
"withCannedACL",
"(",
"origReq",
".",
"getCannedAcl",
"(",
")",
")",
".",
"withObjectMetadata",
"(",
"origReq",
".",
"getMetadata",
"(",
")",
")",
";",
"}",
"TransferManager",
".",
"appendMultipartUserAgent",
"(",
"req",
")",
";",
"req",
".",
"withAccessControlList",
"(",
"origReq",
".",
"getAccessControlList",
"(",
")",
")",
".",
"withRequesterPays",
"(",
"origReq",
".",
"isRequesterPays",
"(",
")",
")",
".",
"withStorageClass",
"(",
"origReq",
".",
"getStorageClass",
"(",
")",
")",
".",
"withRedirectLocation",
"(",
"origReq",
".",
"getRedirectLocation",
"(",
")",
")",
".",
"withSSECustomerKey",
"(",
"origReq",
".",
"getSSECustomerKey",
"(",
")",
")",
".",
"withSSEAwsKeyManagementParams",
"(",
"origReq",
".",
"getSSEAwsKeyManagementParams",
"(",
")",
")",
".",
"withGeneralProgressListener",
"(",
"origReq",
".",
"getGeneralProgressListener",
"(",
")",
")",
".",
"withRequestMetricCollector",
"(",
"origReq",
".",
"getRequestMetricCollector",
"(",
")",
")",
";",
"String",
"uploadId",
"=",
"s3",
".",
"initiateMultipartUpload",
"(",
"req",
")",
".",
"getUploadId",
"(",
")",
";",
"log",
".",
"debug",
"(",
"\"Initiated new multipart upload: \"",
"+",
"uploadId",
")",
";",
"return",
"uploadId",
";",
"}"
] | Initiates a multipart upload and returns the upload id
@param isUsingEncryption | [
"Initiates",
"a",
"multipart",
"upload",
"and",
"returns",
"the",
"upload",
"id"
] | train | https://github.com/IBM/ibm-cos-sdk-java/blob/d0bb2dd754c328a05e7dba8dc42e28b271b6daf2/ibm-cos-java-sdk-s3/src/main/java/com/ibm/cloud/objectstorage/services/s3/transfer/internal/UploadCallable.java#L331-L362 |
netty/netty | codec-http2/src/main/java/io/netty/handler/codec/http2/HttpConversionUtil.java | HttpConversionUtil.parseStatus | public static HttpResponseStatus parseStatus(CharSequence status) throws Http2Exception {
"""
Apply HTTP/2 rules while translating status code to {@link HttpResponseStatus}
@param status The status from an HTTP/2 frame
@return The HTTP/1.x status
@throws Http2Exception If there is a problem translating from HTTP/2 to HTTP/1.x
"""
HttpResponseStatus result;
try {
result = parseLine(status);
if (result == HttpResponseStatus.SWITCHING_PROTOCOLS) {
throw connectionError(PROTOCOL_ERROR, "Invalid HTTP/2 status code '%d'", result.code());
}
} catch (Http2Exception e) {
throw e;
} catch (Throwable t) {
throw connectionError(PROTOCOL_ERROR, t,
"Unrecognized HTTP status code '%s' encountered in translation to HTTP/1.x", status);
}
return result;
} | java | public static HttpResponseStatus parseStatus(CharSequence status) throws Http2Exception {
HttpResponseStatus result;
try {
result = parseLine(status);
if (result == HttpResponseStatus.SWITCHING_PROTOCOLS) {
throw connectionError(PROTOCOL_ERROR, "Invalid HTTP/2 status code '%d'", result.code());
}
} catch (Http2Exception e) {
throw e;
} catch (Throwable t) {
throw connectionError(PROTOCOL_ERROR, t,
"Unrecognized HTTP status code '%s' encountered in translation to HTTP/1.x", status);
}
return result;
} | [
"public",
"static",
"HttpResponseStatus",
"parseStatus",
"(",
"CharSequence",
"status",
")",
"throws",
"Http2Exception",
"{",
"HttpResponseStatus",
"result",
";",
"try",
"{",
"result",
"=",
"parseLine",
"(",
"status",
")",
";",
"if",
"(",
"result",
"==",
"HttpResponseStatus",
".",
"SWITCHING_PROTOCOLS",
")",
"{",
"throw",
"connectionError",
"(",
"PROTOCOL_ERROR",
",",
"\"Invalid HTTP/2 status code '%d'\"",
",",
"result",
".",
"code",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"Http2Exception",
"e",
")",
"{",
"throw",
"e",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"throw",
"connectionError",
"(",
"PROTOCOL_ERROR",
",",
"t",
",",
"\"Unrecognized HTTP status code '%s' encountered in translation to HTTP/1.x\"",
",",
"status",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Apply HTTP/2 rules while translating status code to {@link HttpResponseStatus}
@param status The status from an HTTP/2 frame
@return The HTTP/1.x status
@throws Http2Exception If there is a problem translating from HTTP/2 to HTTP/1.x | [
"Apply",
"HTTP",
"/",
"2",
"rules",
"while",
"translating",
"status",
"code",
"to",
"{",
"@link",
"HttpResponseStatus",
"}"
] | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-http2/src/main/java/io/netty/handler/codec/http2/HttpConversionUtil.java#L184-L198 |
contentful/contentful-management.java | src/main/java/com/contentful/java/cma/model/CMAWebhook.java | CMAWebhook.addHeader | public CMAWebhook addHeader(String key, String value) {
"""
Adds a custom http header to the call done by this webhook.
@param key HTTP header key to be used (aka 'X-My-Header-Name')
@param value HTTP header value to be used (aka 'this-is-my-name')
@return this webhook for chaining.
"""
if (this.headers == null) {
this.headers = new ArrayList<CMAWebhookHeader>();
}
this.headers.add(new CMAWebhookHeader(key, value));
return this;
} | java | public CMAWebhook addHeader(String key, String value) {
if (this.headers == null) {
this.headers = new ArrayList<CMAWebhookHeader>();
}
this.headers.add(new CMAWebhookHeader(key, value));
return this;
} | [
"public",
"CMAWebhook",
"addHeader",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"if",
"(",
"this",
".",
"headers",
"==",
"null",
")",
"{",
"this",
".",
"headers",
"=",
"new",
"ArrayList",
"<",
"CMAWebhookHeader",
">",
"(",
")",
";",
"}",
"this",
".",
"headers",
".",
"add",
"(",
"new",
"CMAWebhookHeader",
"(",
"key",
",",
"value",
")",
")",
";",
"return",
"this",
";",
"}"
] | Adds a custom http header to the call done by this webhook.
@param key HTTP header key to be used (aka 'X-My-Header-Name')
@param value HTTP header value to be used (aka 'this-is-my-name')
@return this webhook for chaining. | [
"Adds",
"a",
"custom",
"http",
"header",
"to",
"the",
"call",
"done",
"by",
"this",
"webhook",
"."
] | train | https://github.com/contentful/contentful-management.java/blob/ca310fb9ea9577fcff0ca57949ab7c2315fa2534/src/main/java/com/contentful/java/cma/model/CMAWebhook.java#L115-L122 |
Azure/azure-sdk-for-java | automation/resource-manager/v2015_10_31/src/main/java/com/microsoft/azure/management/automation/v2015_10_31/implementation/FieldsInner.java | FieldsInner.listByTypeAsync | public Observable<List<TypeFieldInner>> listByTypeAsync(String resourceGroupName, String automationAccountName, String moduleName, String typeName) {
"""
Retrieve a list of fields of a given type identified by module name.
@param resourceGroupName Name of an Azure Resource group.
@param automationAccountName The name of the automation account.
@param moduleName The name of module.
@param typeName The name of type.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<TypeFieldInner> object
"""
return listByTypeWithServiceResponseAsync(resourceGroupName, automationAccountName, moduleName, typeName).map(new Func1<ServiceResponse<List<TypeFieldInner>>, List<TypeFieldInner>>() {
@Override
public List<TypeFieldInner> call(ServiceResponse<List<TypeFieldInner>> response) {
return response.body();
}
});
} | java | public Observable<List<TypeFieldInner>> listByTypeAsync(String resourceGroupName, String automationAccountName, String moduleName, String typeName) {
return listByTypeWithServiceResponseAsync(resourceGroupName, automationAccountName, moduleName, typeName).map(new Func1<ServiceResponse<List<TypeFieldInner>>, List<TypeFieldInner>>() {
@Override
public List<TypeFieldInner> call(ServiceResponse<List<TypeFieldInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"List",
"<",
"TypeFieldInner",
">",
">",
"listByTypeAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"automationAccountName",
",",
"String",
"moduleName",
",",
"String",
"typeName",
")",
"{",
"return",
"listByTypeWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"automationAccountName",
",",
"moduleName",
",",
"typeName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"List",
"<",
"TypeFieldInner",
">",
">",
",",
"List",
"<",
"TypeFieldInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"List",
"<",
"TypeFieldInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"List",
"<",
"TypeFieldInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Retrieve a list of fields of a given type identified by module name.
@param resourceGroupName Name of an Azure Resource group.
@param automationAccountName The name of the automation account.
@param moduleName The name of module.
@param typeName The name of type.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<TypeFieldInner> object | [
"Retrieve",
"a",
"list",
"of",
"fields",
"of",
"a",
"given",
"type",
"identified",
"by",
"module",
"name",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/automation/resource-manager/v2015_10_31/src/main/java/com/microsoft/azure/management/automation/v2015_10_31/implementation/FieldsInner.java#L102-L109 |
EvidentSolutions/dalesbred | dalesbred/src/main/java/org/dalesbred/query/SqlQuery.java | SqlQuery.namedQuery | public static @NotNull SqlQuery namedQuery(@NotNull @SQL String sql, @NotNull Object bean) {
"""
Constructs a query with named arguments, using the properties/fields of given bean for resolving arguments.
@see #namedQuery(String, VariableResolver)
@see VariableResolver#forBean(Object)
"""
return namedQuery(sql, VariableResolver.forBean(bean));
} | java | public static @NotNull SqlQuery namedQuery(@NotNull @SQL String sql, @NotNull Object bean) {
return namedQuery(sql, VariableResolver.forBean(bean));
} | [
"public",
"static",
"@",
"NotNull",
"SqlQuery",
"namedQuery",
"(",
"@",
"NotNull",
"@",
"SQL",
"String",
"sql",
",",
"@",
"NotNull",
"Object",
"bean",
")",
"{",
"return",
"namedQuery",
"(",
"sql",
",",
"VariableResolver",
".",
"forBean",
"(",
"bean",
")",
")",
";",
"}"
] | Constructs a query with named arguments, using the properties/fields of given bean for resolving arguments.
@see #namedQuery(String, VariableResolver)
@see VariableResolver#forBean(Object) | [
"Constructs",
"a",
"query",
"with",
"named",
"arguments",
"using",
"the",
"properties",
"/",
"fields",
"of",
"given",
"bean",
"for",
"resolving",
"arguments",
"."
] | train | https://github.com/EvidentSolutions/dalesbred/blob/713f5b6e152d97e1672ca68b9ff9c7c6c288ceb1/dalesbred/src/main/java/org/dalesbred/query/SqlQuery.java#L91-L93 |
tipsy/javalin | src/main/java/io/javalin/apibuilder/ApiBuilder.java | ApiBuilder.ws | public static void ws(@NotNull String path, @NotNull Consumer<WsHandler> ws, @NotNull Set<Role> permittedRoles) {
"""
Adds a WebSocket handler with the given roles for the specified path.
The method can only be called inside a {@link Javalin#routes(EndpointGroup)}.
@see <a href="https://javalin.io/documentation#websockets">WebSockets in docs</a>
"""
staticInstance().ws(prefixPath(path), ws, permittedRoles);
} | java | public static void ws(@NotNull String path, @NotNull Consumer<WsHandler> ws, @NotNull Set<Role> permittedRoles) {
staticInstance().ws(prefixPath(path), ws, permittedRoles);
} | [
"public",
"static",
"void",
"ws",
"(",
"@",
"NotNull",
"String",
"path",
",",
"@",
"NotNull",
"Consumer",
"<",
"WsHandler",
">",
"ws",
",",
"@",
"NotNull",
"Set",
"<",
"Role",
">",
"permittedRoles",
")",
"{",
"staticInstance",
"(",
")",
".",
"ws",
"(",
"prefixPath",
"(",
"path",
")",
",",
"ws",
",",
"permittedRoles",
")",
";",
"}"
] | Adds a WebSocket handler with the given roles for the specified path.
The method can only be called inside a {@link Javalin#routes(EndpointGroup)}.
@see <a href="https://javalin.io/documentation#websockets">WebSockets in docs</a> | [
"Adds",
"a",
"WebSocket",
"handler",
"with",
"the",
"given",
"roles",
"for",
"the",
"specified",
"path",
".",
"The",
"method",
"can",
"only",
"be",
"called",
"inside",
"a",
"{",
"@link",
"Javalin#routes",
"(",
"EndpointGroup",
")",
"}",
"."
] | train | https://github.com/tipsy/javalin/blob/68b2f7592f237db1c2b597e645697eb75fdaee53/src/main/java/io/javalin/apibuilder/ApiBuilder.java#L384-L386 |
google/j2objc | jre_emul/android/platform/libcore/luni/src/main/java/libcore/net/url/UrlUtils.java | UrlUtils.findFirstOf | public static int findFirstOf(String string, String chars, int start, int end) {
"""
Returns the index of the first char of {@code chars} in {@code string}
bounded between {@code start} and {@code end}. This returns {@code end}
if none of the characters exist in the requested range.
"""
for (int i = start; i < end; i++) {
char c = string.charAt(i);
if (chars.indexOf(c) != -1) {
return i;
}
}
return end;
} | java | public static int findFirstOf(String string, String chars, int start, int end) {
for (int i = start; i < end; i++) {
char c = string.charAt(i);
if (chars.indexOf(c) != -1) {
return i;
}
}
return end;
} | [
"public",
"static",
"int",
"findFirstOf",
"(",
"String",
"string",
",",
"String",
"chars",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"start",
";",
"i",
"<",
"end",
";",
"i",
"++",
")",
"{",
"char",
"c",
"=",
"string",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"chars",
".",
"indexOf",
"(",
"c",
")",
"!=",
"-",
"1",
")",
"{",
"return",
"i",
";",
"}",
"}",
"return",
"end",
";",
"}"
] | Returns the index of the first char of {@code chars} in {@code string}
bounded between {@code start} and {@code end}. This returns {@code end}
if none of the characters exist in the requested range. | [
"Returns",
"the",
"index",
"of",
"the",
"first",
"char",
"of",
"{"
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/luni/src/main/java/libcore/net/url/UrlUtils.java#L133-L141 |
baasbox/Android-SDK | library/src/main/java/com/baasbox/android/BaasDocument.java | BaasDocument.getArray | public JsonArray getArray(String name, JsonArray otherwise) {
"""
Returns the value mapped to <code>name</code> as a {@link com.baasbox.android.json.JsonArray}
or <code>otherwise</code> if the mapping is absent.
@param name a non <code>null</code> key
@param otherwise a default value
@return the value mapped to <code>name</code> or <code>otherwise</code>
"""
return data.getArray(name, otherwise);
} | java | public JsonArray getArray(String name, JsonArray otherwise) {
return data.getArray(name, otherwise);
} | [
"public",
"JsonArray",
"getArray",
"(",
"String",
"name",
",",
"JsonArray",
"otherwise",
")",
"{",
"return",
"data",
".",
"getArray",
"(",
"name",
",",
"otherwise",
")",
";",
"}"
] | Returns the value mapped to <code>name</code> as a {@link com.baasbox.android.json.JsonArray}
or <code>otherwise</code> if the mapping is absent.
@param name a non <code>null</code> key
@param otherwise a default value
@return the value mapped to <code>name</code> or <code>otherwise</code> | [
"Returns",
"the",
"value",
"mapped",
"to",
"<code",
">",
"name<",
"/",
"code",
">",
"as",
"a",
"{",
"@link",
"com",
".",
"baasbox",
".",
"android",
".",
"json",
".",
"JsonArray",
"}",
"or",
"<code",
">",
"otherwise<",
"/",
"code",
">",
"if",
"the",
"mapping",
"is",
"absent",
"."
] | train | https://github.com/baasbox/Android-SDK/blob/6bb2203246b885b2ad63a7bfaf37c83caf15e0d8/library/src/main/java/com/baasbox/android/BaasDocument.java#L773-L775 |
RestComm/sip-servlets | sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/SipServletRequestImpl.java | SipServletRequestImpl.addInfoForRoutingBackToContainer | private void addInfoForRoutingBackToContainer(SipApplicationRouterInfo routerInfo, String applicationSessionId, String applicationName) throws ParseException, SipException {
"""
Add a route header to route back to the container
@param applicationName the application name that was chosen by the AR to route the request
@throws ParseException
@throws SipException
@throws NullPointerException
"""
final Request request = (Request) super.message;
final javax.sip.address.SipURI sipURI = JainSipUtils.createRecordRouteURI(
sipFactoryImpl.getSipNetworkInterfaceManager(),
request);
sipURI.setLrParam();
sipURI.setParameter(MessageDispatcher.ROUTE_PARAM_DIRECTIVE,
routingDirective.toString());
if(getSipSession().getRegionInternal() != null) {
sipURI.setParameter(MessageDispatcher.ROUTE_PARAM_REGION_LABEL,
getSipSession().getRegionInternal().getLabel());
sipURI.setParameter(MessageDispatcher.ROUTE_PARAM_REGION_TYPE,
getSipSession().getRegionInternal().getType().toString());
}
sipURI.setParameter(MessageDispatcher.ROUTE_PARAM_PREV_APPLICATION_NAME,
applicationName);
sipURI.setParameter(MessageDispatcher.ROUTE_PARAM_PREV_APP_ID,
applicationSessionId);
final javax.sip.address.Address routeAddress =
SipFactoryImpl.addressFactory.createAddress(sipURI);
final RouteHeader routeHeader =
SipFactoryImpl.headerFactory.createRouteHeader(routeAddress);
request.addFirst(routeHeader);
// adding the application router info to avoid calling the AppRouter twice
// See Issue 791 : http://code.google.com/p/mobicents/issues/detail?id=791
final MobicentsSipSession session = getSipSession();
session.setNextSipApplicationRouterInfo(routerInfo);
} | java | private void addInfoForRoutingBackToContainer(SipApplicationRouterInfo routerInfo, String applicationSessionId, String applicationName) throws ParseException, SipException {
final Request request = (Request) super.message;
final javax.sip.address.SipURI sipURI = JainSipUtils.createRecordRouteURI(
sipFactoryImpl.getSipNetworkInterfaceManager(),
request);
sipURI.setLrParam();
sipURI.setParameter(MessageDispatcher.ROUTE_PARAM_DIRECTIVE,
routingDirective.toString());
if(getSipSession().getRegionInternal() != null) {
sipURI.setParameter(MessageDispatcher.ROUTE_PARAM_REGION_LABEL,
getSipSession().getRegionInternal().getLabel());
sipURI.setParameter(MessageDispatcher.ROUTE_PARAM_REGION_TYPE,
getSipSession().getRegionInternal().getType().toString());
}
sipURI.setParameter(MessageDispatcher.ROUTE_PARAM_PREV_APPLICATION_NAME,
applicationName);
sipURI.setParameter(MessageDispatcher.ROUTE_PARAM_PREV_APP_ID,
applicationSessionId);
final javax.sip.address.Address routeAddress =
SipFactoryImpl.addressFactory.createAddress(sipURI);
final RouteHeader routeHeader =
SipFactoryImpl.headerFactory.createRouteHeader(routeAddress);
request.addFirst(routeHeader);
// adding the application router info to avoid calling the AppRouter twice
// See Issue 791 : http://code.google.com/p/mobicents/issues/detail?id=791
final MobicentsSipSession session = getSipSession();
session.setNextSipApplicationRouterInfo(routerInfo);
} | [
"private",
"void",
"addInfoForRoutingBackToContainer",
"(",
"SipApplicationRouterInfo",
"routerInfo",
",",
"String",
"applicationSessionId",
",",
"String",
"applicationName",
")",
"throws",
"ParseException",
",",
"SipException",
"{",
"final",
"Request",
"request",
"=",
"(",
"Request",
")",
"super",
".",
"message",
";",
"final",
"javax",
".",
"sip",
".",
"address",
".",
"SipURI",
"sipURI",
"=",
"JainSipUtils",
".",
"createRecordRouteURI",
"(",
"sipFactoryImpl",
".",
"getSipNetworkInterfaceManager",
"(",
")",
",",
"request",
")",
";",
"sipURI",
".",
"setLrParam",
"(",
")",
";",
"sipURI",
".",
"setParameter",
"(",
"MessageDispatcher",
".",
"ROUTE_PARAM_DIRECTIVE",
",",
"routingDirective",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"getSipSession",
"(",
")",
".",
"getRegionInternal",
"(",
")",
"!=",
"null",
")",
"{",
"sipURI",
".",
"setParameter",
"(",
"MessageDispatcher",
".",
"ROUTE_PARAM_REGION_LABEL",
",",
"getSipSession",
"(",
")",
".",
"getRegionInternal",
"(",
")",
".",
"getLabel",
"(",
")",
")",
";",
"sipURI",
".",
"setParameter",
"(",
"MessageDispatcher",
".",
"ROUTE_PARAM_REGION_TYPE",
",",
"getSipSession",
"(",
")",
".",
"getRegionInternal",
"(",
")",
".",
"getType",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"sipURI",
".",
"setParameter",
"(",
"MessageDispatcher",
".",
"ROUTE_PARAM_PREV_APPLICATION_NAME",
",",
"applicationName",
")",
";",
"sipURI",
".",
"setParameter",
"(",
"MessageDispatcher",
".",
"ROUTE_PARAM_PREV_APP_ID",
",",
"applicationSessionId",
")",
";",
"final",
"javax",
".",
"sip",
".",
"address",
".",
"Address",
"routeAddress",
"=",
"SipFactoryImpl",
".",
"addressFactory",
".",
"createAddress",
"(",
"sipURI",
")",
";",
"final",
"RouteHeader",
"routeHeader",
"=",
"SipFactoryImpl",
".",
"headerFactory",
".",
"createRouteHeader",
"(",
"routeAddress",
")",
";",
"request",
".",
"addFirst",
"(",
"routeHeader",
")",
";",
"// adding the application router info to avoid calling the AppRouter twice",
"// See Issue 791 : http://code.google.com/p/mobicents/issues/detail?id=791",
"final",
"MobicentsSipSession",
"session",
"=",
"getSipSession",
"(",
")",
";",
"session",
".",
"setNextSipApplicationRouterInfo",
"(",
"routerInfo",
")",
";",
"}"
] | Add a route header to route back to the container
@param applicationName the application name that was chosen by the AR to route the request
@throws ParseException
@throws SipException
@throws NullPointerException | [
"Add",
"a",
"route",
"header",
"to",
"route",
"back",
"to",
"the",
"container"
] | train | https://github.com/RestComm/sip-servlets/blob/fd7011d2803ab1d205b140768a760c8c69e0c997/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/SipServletRequestImpl.java#L1918-L1945 |
Erudika/para | para-client/src/main/java/com/erudika/para/client/ParaClient.java | ParaClient.isAllowedTo | public boolean isAllowedTo(String subjectid, String resourcePath, String httpMethod) {
"""
Checks if a subject is allowed to call method X on resource Y.
@param subjectid subject id
@param resourcePath resource path or object type
@param httpMethod HTTP method name
@return true if allowed
"""
if (StringUtils.isBlank(subjectid) || StringUtils.isBlank(resourcePath) || StringUtils.isBlank(httpMethod)) {
return false;
}
resourcePath = Utils.urlEncode(resourcePath);
String url = Utils.formatMessage("_permissions/{0}/{1}/{2}", subjectid, resourcePath, httpMethod);
Boolean result = getEntity(invokeGet(url, null), Boolean.class);
return result != null && result;
} | java | public boolean isAllowedTo(String subjectid, String resourcePath, String httpMethod) {
if (StringUtils.isBlank(subjectid) || StringUtils.isBlank(resourcePath) || StringUtils.isBlank(httpMethod)) {
return false;
}
resourcePath = Utils.urlEncode(resourcePath);
String url = Utils.formatMessage("_permissions/{0}/{1}/{2}", subjectid, resourcePath, httpMethod);
Boolean result = getEntity(invokeGet(url, null), Boolean.class);
return result != null && result;
} | [
"public",
"boolean",
"isAllowedTo",
"(",
"String",
"subjectid",
",",
"String",
"resourcePath",
",",
"String",
"httpMethod",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"subjectid",
")",
"||",
"StringUtils",
".",
"isBlank",
"(",
"resourcePath",
")",
"||",
"StringUtils",
".",
"isBlank",
"(",
"httpMethod",
")",
")",
"{",
"return",
"false",
";",
"}",
"resourcePath",
"=",
"Utils",
".",
"urlEncode",
"(",
"resourcePath",
")",
";",
"String",
"url",
"=",
"Utils",
".",
"formatMessage",
"(",
"\"_permissions/{0}/{1}/{2}\"",
",",
"subjectid",
",",
"resourcePath",
",",
"httpMethod",
")",
";",
"Boolean",
"result",
"=",
"getEntity",
"(",
"invokeGet",
"(",
"url",
",",
"null",
")",
",",
"Boolean",
".",
"class",
")",
";",
"return",
"result",
"!=",
"null",
"&&",
"result",
";",
"}"
] | Checks if a subject is allowed to call method X on resource Y.
@param subjectid subject id
@param resourcePath resource path or object type
@param httpMethod HTTP method name
@return true if allowed | [
"Checks",
"if",
"a",
"subject",
"is",
"allowed",
"to",
"call",
"method",
"X",
"on",
"resource",
"Y",
"."
] | train | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-client/src/main/java/com/erudika/para/client/ParaClient.java#L1491-L1499 |
wisdom-framework/wisdom | core/wisdom-maven-plugin/src/main/java/org/wisdom/maven/utils/WatcherUtils.java | WatcherUtils.hasExtension | public static boolean hasExtension(File file, String... extensions) {
"""
Checks whether the given file has one of the given extension.
@param file the file
@param extensions the extensions
@return {@literal true} if the file has one of the given extension, {@literal false} otherwise
"""
String extension = FilenameUtils.getExtension(file.getName());
for (String s : extensions) {
if (extension.equalsIgnoreCase(s) || ("." + extension).equalsIgnoreCase(s)) {
return true;
}
}
return false;
} | java | public static boolean hasExtension(File file, String... extensions) {
String extension = FilenameUtils.getExtension(file.getName());
for (String s : extensions) {
if (extension.equalsIgnoreCase(s) || ("." + extension).equalsIgnoreCase(s)) {
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"hasExtension",
"(",
"File",
"file",
",",
"String",
"...",
"extensions",
")",
"{",
"String",
"extension",
"=",
"FilenameUtils",
".",
"getExtension",
"(",
"file",
".",
"getName",
"(",
")",
")",
";",
"for",
"(",
"String",
"s",
":",
"extensions",
")",
"{",
"if",
"(",
"extension",
".",
"equalsIgnoreCase",
"(",
"s",
")",
"||",
"(",
"\".\"",
"+",
"extension",
")",
".",
"equalsIgnoreCase",
"(",
"s",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Checks whether the given file has one of the given extension.
@param file the file
@param extensions the extensions
@return {@literal true} if the file has one of the given extension, {@literal false} otherwise | [
"Checks",
"whether",
"the",
"given",
"file",
"has",
"one",
"of",
"the",
"given",
"extension",
"."
] | train | https://github.com/wisdom-framework/wisdom/blob/a35b6431200fec56b178c0ff60837ed73fd7874d/core/wisdom-maven-plugin/src/main/java/org/wisdom/maven/utils/WatcherUtils.java#L159-L167 |
Azure/azure-sdk-for-java | loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/implementation/LogAnalyticsDataClientImpl.java | LogAnalyticsDataClientImpl.queryAsync | public ServiceFuture<QueryResults> queryAsync(String workspaceId, QueryBody body, final ServiceCallback<QueryResults> serviceCallback) {
"""
Execute an Analytics query.
Executes an Analytics query for data. [Here](https://dev.loganalytics.io/documentation/Using-the-API) is an example for using POST with an Analytics query.
@param workspaceId ID of the workspace. This is Workspace ID from the Properties blade in the Azure portal.
@param body The Analytics query. Learn more about the [Analytics query syntax](https://azure.microsoft.com/documentation/articles/app-insights-analytics-reference/)
@param serviceCallback the async ServiceCallback to handle successful and failed responses.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceFuture} object
"""
return ServiceFuture.fromResponse(queryWithServiceResponseAsync(workspaceId, body), serviceCallback);
} | java | public ServiceFuture<QueryResults> queryAsync(String workspaceId, QueryBody body, final ServiceCallback<QueryResults> serviceCallback) {
return ServiceFuture.fromResponse(queryWithServiceResponseAsync(workspaceId, body), serviceCallback);
} | [
"public",
"ServiceFuture",
"<",
"QueryResults",
">",
"queryAsync",
"(",
"String",
"workspaceId",
",",
"QueryBody",
"body",
",",
"final",
"ServiceCallback",
"<",
"QueryResults",
">",
"serviceCallback",
")",
"{",
"return",
"ServiceFuture",
".",
"fromResponse",
"(",
"queryWithServiceResponseAsync",
"(",
"workspaceId",
",",
"body",
")",
",",
"serviceCallback",
")",
";",
"}"
] | Execute an Analytics query.
Executes an Analytics query for data. [Here](https://dev.loganalytics.io/documentation/Using-the-API) is an example for using POST with an Analytics query.
@param workspaceId ID of the workspace. This is Workspace ID from the Properties blade in the Azure portal.
@param body The Analytics query. Learn more about the [Analytics query syntax](https://azure.microsoft.com/documentation/articles/app-insights-analytics-reference/)
@param serviceCallback the async ServiceCallback to handle successful and failed responses.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceFuture} object | [
"Execute",
"an",
"Analytics",
"query",
".",
"Executes",
"an",
"Analytics",
"query",
"for",
"data",
".",
"[",
"Here",
"]",
"(",
"https",
":",
"//",
"dev",
".",
"loganalytics",
".",
"io",
"/",
"documentation",
"/",
"Using",
"-",
"the",
"-",
"API",
")",
"is",
"an",
"example",
"for",
"using",
"POST",
"with",
"an",
"Analytics",
"query",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/implementation/LogAnalyticsDataClientImpl.java#L209-L211 |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/com/send/ComQuery.java | ComQuery.sendMultiDirect | public static void sendMultiDirect(final PacketOutputStream pos, List<byte[]> sqlBytes)
throws IOException {
"""
Send directly to socket the sql data.
@param pos output stream
@param sqlBytes the query in UTF-8 bytes
@throws IOException if connection error occur
"""
pos.startPacket(0);
pos.write(Packet.COM_QUERY);
for (byte[] bytes : sqlBytes) {
pos.write(bytes);
}
pos.flush();
} | java | public static void sendMultiDirect(final PacketOutputStream pos, List<byte[]> sqlBytes)
throws IOException {
pos.startPacket(0);
pos.write(Packet.COM_QUERY);
for (byte[] bytes : sqlBytes) {
pos.write(bytes);
}
pos.flush();
} | [
"public",
"static",
"void",
"sendMultiDirect",
"(",
"final",
"PacketOutputStream",
"pos",
",",
"List",
"<",
"byte",
"[",
"]",
">",
"sqlBytes",
")",
"throws",
"IOException",
"{",
"pos",
".",
"startPacket",
"(",
"0",
")",
";",
"pos",
".",
"write",
"(",
"Packet",
".",
"COM_QUERY",
")",
";",
"for",
"(",
"byte",
"[",
"]",
"bytes",
":",
"sqlBytes",
")",
"{",
"pos",
".",
"write",
"(",
"bytes",
")",
";",
"}",
"pos",
".",
"flush",
"(",
")",
";",
"}"
] | Send directly to socket the sql data.
@param pos output stream
@param sqlBytes the query in UTF-8 bytes
@throws IOException if connection error occur | [
"Send",
"directly",
"to",
"socket",
"the",
"sql",
"data",
"."
] | train | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/send/ComQuery.java#L331-L339 |
JodaOrg/joda-time | src/main/java/org/joda/time/format/DateTimeFormatter.java | DateTimeFormatter.parseMillis | public long parseMillis(String text) {
"""
Parses a datetime from the given text, returning the number of
milliseconds since the epoch, 1970-01-01T00:00:00Z.
<p>
The parse will use the ISO chronology, and the default time zone.
If the text contains a time zone string then that will be taken into account.
@param text the text to parse, not null
@return parsed value expressed in milliseconds since the epoch
@throws UnsupportedOperationException if parsing is not supported
@throws IllegalArgumentException if the text to parse is invalid
"""
InternalParser parser = requireParser();
Chronology chrono = selectChronology(iChrono);
DateTimeParserBucket bucket = new DateTimeParserBucket(0, chrono, iLocale, iPivotYear, iDefaultYear);
return bucket.doParseMillis(parser, text);
} | java | public long parseMillis(String text) {
InternalParser parser = requireParser();
Chronology chrono = selectChronology(iChrono);
DateTimeParserBucket bucket = new DateTimeParserBucket(0, chrono, iLocale, iPivotYear, iDefaultYear);
return bucket.doParseMillis(parser, text);
} | [
"public",
"long",
"parseMillis",
"(",
"String",
"text",
")",
"{",
"InternalParser",
"parser",
"=",
"requireParser",
"(",
")",
";",
"Chronology",
"chrono",
"=",
"selectChronology",
"(",
"iChrono",
")",
";",
"DateTimeParserBucket",
"bucket",
"=",
"new",
"DateTimeParserBucket",
"(",
"0",
",",
"chrono",
",",
"iLocale",
",",
"iPivotYear",
",",
"iDefaultYear",
")",
";",
"return",
"bucket",
".",
"doParseMillis",
"(",
"parser",
",",
"text",
")",
";",
"}"
] | Parses a datetime from the given text, returning the number of
milliseconds since the epoch, 1970-01-01T00:00:00Z.
<p>
The parse will use the ISO chronology, and the default time zone.
If the text contains a time zone string then that will be taken into account.
@param text the text to parse, not null
@return parsed value expressed in milliseconds since the epoch
@throws UnsupportedOperationException if parsing is not supported
@throws IllegalArgumentException if the text to parse is invalid | [
"Parses",
"a",
"datetime",
"from",
"the",
"given",
"text",
"returning",
"the",
"number",
"of",
"milliseconds",
"since",
"the",
"epoch",
"1970",
"-",
"01",
"-",
"01T00",
":",
"00",
":",
"00Z",
".",
"<p",
">",
"The",
"parse",
"will",
"use",
"the",
"ISO",
"chronology",
"and",
"the",
"default",
"time",
"zone",
".",
"If",
"the",
"text",
"contains",
"a",
"time",
"zone",
"string",
"then",
"that",
"will",
"be",
"taken",
"into",
"account",
"."
] | train | https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/format/DateTimeFormatter.java#L822-L827 |
OpenLiberty/open-liberty | dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/cdi/util/BeanProvider.java | BeanProvider.getContextualReference | private static <T> T getContextualReference(Class<T> type, BeanManager beanManager, Set<Bean<?>> beans) {
"""
Internal helper method to resolve the right bean and resolve the contextual reference.
@param type the type of the bean in question
@param beanManager current bean-manager
@param beans beans in question
@param <T> target type
@return the contextual reference
"""
Bean<?> bean = beanManager.resolve(beans);
//logWarningIfDependent(bean);
CreationalContext<?> creationalContext = beanManager.createCreationalContext(bean);
@SuppressWarnings({ "unchecked", "UnnecessaryLocalVariable" })
T result = (T) beanManager.getReference(bean, type, creationalContext);
return result;
} | java | private static <T> T getContextualReference(Class<T> type, BeanManager beanManager, Set<Bean<?>> beans)
{
Bean<?> bean = beanManager.resolve(beans);
//logWarningIfDependent(bean);
CreationalContext<?> creationalContext = beanManager.createCreationalContext(bean);
@SuppressWarnings({ "unchecked", "UnnecessaryLocalVariable" })
T result = (T) beanManager.getReference(bean, type, creationalContext);
return result;
} | [
"private",
"static",
"<",
"T",
">",
"T",
"getContextualReference",
"(",
"Class",
"<",
"T",
">",
"type",
",",
"BeanManager",
"beanManager",
",",
"Set",
"<",
"Bean",
"<",
"?",
">",
">",
"beans",
")",
"{",
"Bean",
"<",
"?",
">",
"bean",
"=",
"beanManager",
".",
"resolve",
"(",
"beans",
")",
";",
"//logWarningIfDependent(bean);",
"CreationalContext",
"<",
"?",
">",
"creationalContext",
"=",
"beanManager",
".",
"createCreationalContext",
"(",
"bean",
")",
";",
"@",
"SuppressWarnings",
"(",
"{",
"\"unchecked\"",
",",
"\"UnnecessaryLocalVariable\"",
"}",
")",
"T",
"result",
"=",
"(",
"T",
")",
"beanManager",
".",
"getReference",
"(",
"bean",
",",
"type",
",",
"creationalContext",
")",
";",
"return",
"result",
";",
"}"
] | Internal helper method to resolve the right bean and resolve the contextual reference.
@param type the type of the bean in question
@param beanManager current bean-manager
@param beans beans in question
@param <T> target type
@return the contextual reference | [
"Internal",
"helper",
"method",
"to",
"resolve",
"the",
"right",
"bean",
"and",
"resolve",
"the",
"contextual",
"reference",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/cdi/util/BeanProvider.java#L411-L422 |
lmdbjava/lmdbjava | src/main/java/org/lmdbjava/Verifier.java | Verifier.runFor | public long runFor(final long duration, final TimeUnit unit) {
"""
Execute the verifier for the given duration.
<p>
This provides a simple way to execute the verifier for those applications
which do not wish to manage threads directly.
@param duration amount of time to execute
@param unit units used to express the duration
@return number of database rows successfully verified
"""
final long deadline = System.currentTimeMillis() + unit.toMillis(duration);
final ExecutorService es = Executors.newSingleThreadExecutor();
final Future<Long> future = es.submit(this);
try {
while (System.currentTimeMillis() < deadline && !future.isDone()) {
Thread.sleep(unit.toMillis(1));
}
} catch (final InterruptedException ignored) {
} finally {
stop();
}
final long result;
try {
result = future.get();
} catch (final InterruptedException | ExecutionException ex) {
throw new IllegalStateException(ex);
} finally {
es.shutdown();
}
return result;
} | java | public long runFor(final long duration, final TimeUnit unit) {
final long deadline = System.currentTimeMillis() + unit.toMillis(duration);
final ExecutorService es = Executors.newSingleThreadExecutor();
final Future<Long> future = es.submit(this);
try {
while (System.currentTimeMillis() < deadline && !future.isDone()) {
Thread.sleep(unit.toMillis(1));
}
} catch (final InterruptedException ignored) {
} finally {
stop();
}
final long result;
try {
result = future.get();
} catch (final InterruptedException | ExecutionException ex) {
throw new IllegalStateException(ex);
} finally {
es.shutdown();
}
return result;
} | [
"public",
"long",
"runFor",
"(",
"final",
"long",
"duration",
",",
"final",
"TimeUnit",
"unit",
")",
"{",
"final",
"long",
"deadline",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"+",
"unit",
".",
"toMillis",
"(",
"duration",
")",
";",
"final",
"ExecutorService",
"es",
"=",
"Executors",
".",
"newSingleThreadExecutor",
"(",
")",
";",
"final",
"Future",
"<",
"Long",
">",
"future",
"=",
"es",
".",
"submit",
"(",
"this",
")",
";",
"try",
"{",
"while",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
"<",
"deadline",
"&&",
"!",
"future",
".",
"isDone",
"(",
")",
")",
"{",
"Thread",
".",
"sleep",
"(",
"unit",
".",
"toMillis",
"(",
"1",
")",
")",
";",
"}",
"}",
"catch",
"(",
"final",
"InterruptedException",
"ignored",
")",
"{",
"}",
"finally",
"{",
"stop",
"(",
")",
";",
"}",
"final",
"long",
"result",
";",
"try",
"{",
"result",
"=",
"future",
".",
"get",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"InterruptedException",
"|",
"ExecutionException",
"ex",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"ex",
")",
";",
"}",
"finally",
"{",
"es",
".",
"shutdown",
"(",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Execute the verifier for the given duration.
<p>
This provides a simple way to execute the verifier for those applications
which do not wish to manage threads directly.
@param duration amount of time to execute
@param unit units used to express the duration
@return number of database rows successfully verified | [
"Execute",
"the",
"verifier",
"for",
"the",
"given",
"duration",
"."
] | train | https://github.com/lmdbjava/lmdbjava/blob/5912beb1037722c71f3ddc05e70fcbe739dfa272/src/main/java/org/lmdbjava/Verifier.java#L166-L187 |
elki-project/elki | elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/MiniMax.java | MiniMax.updateEntry | protected static void updateEntry(MatrixParadigm mat, DBIDArrayMIter prots, Int2ObjectOpenHashMap<ModifiableDBIDs> clusters, DistanceQuery<?> dq, int x, int y) {
"""
Update entry at x,y for distance matrix distances
@param mat distance matrix
@param prots calculated prototypes
@param clusters the clusters
@param dq distance query on the data set
@param x index of cluster, {@code x > y}
@param y index of cluster, {@code y < x}
"""
assert (y < x);
final DBIDArrayIter ix = mat.ix, iy = mat.iy;
final double[] distances = mat.matrix;
ModifiableDBIDs cx = clusters.get(x), cy = clusters.get(y);
DBIDVar prototype = DBIDUtil.newVar(ix.seek(x)); // Default prototype
double minMaxDist;
// Two "real" clusters:
if(cx != null && cy != null) {
minMaxDist = findPrototype(dq, cx, cy, prototype, Double.POSITIVE_INFINITY);
minMaxDist = findPrototype(dq, cy, cx, prototype, minMaxDist);
}
else if(cx != null) {
// cy is singleton.
minMaxDist = findPrototypeSingleton(dq, cx, iy.seek(y), prototype);
}
else if(cy != null) {
// cx is singleton.
minMaxDist = findPrototypeSingleton(dq, cy, ix.seek(x), prototype);
}
else {
minMaxDist = dq.distance(ix.seek(x), iy.seek(y));
prototype.set(ix);
}
final int offset = MatrixParadigm.triangleSize(x) + y;
distances[offset] = minMaxDist;
prots.seek(offset).setDBID(prototype);
} | java | protected static void updateEntry(MatrixParadigm mat, DBIDArrayMIter prots, Int2ObjectOpenHashMap<ModifiableDBIDs> clusters, DistanceQuery<?> dq, int x, int y) {
assert (y < x);
final DBIDArrayIter ix = mat.ix, iy = mat.iy;
final double[] distances = mat.matrix;
ModifiableDBIDs cx = clusters.get(x), cy = clusters.get(y);
DBIDVar prototype = DBIDUtil.newVar(ix.seek(x)); // Default prototype
double minMaxDist;
// Two "real" clusters:
if(cx != null && cy != null) {
minMaxDist = findPrototype(dq, cx, cy, prototype, Double.POSITIVE_INFINITY);
minMaxDist = findPrototype(dq, cy, cx, prototype, minMaxDist);
}
else if(cx != null) {
// cy is singleton.
minMaxDist = findPrototypeSingleton(dq, cx, iy.seek(y), prototype);
}
else if(cy != null) {
// cx is singleton.
minMaxDist = findPrototypeSingleton(dq, cy, ix.seek(x), prototype);
}
else {
minMaxDist = dq.distance(ix.seek(x), iy.seek(y));
prototype.set(ix);
}
final int offset = MatrixParadigm.triangleSize(x) + y;
distances[offset] = minMaxDist;
prots.seek(offset).setDBID(prototype);
} | [
"protected",
"static",
"void",
"updateEntry",
"(",
"MatrixParadigm",
"mat",
",",
"DBIDArrayMIter",
"prots",
",",
"Int2ObjectOpenHashMap",
"<",
"ModifiableDBIDs",
">",
"clusters",
",",
"DistanceQuery",
"<",
"?",
">",
"dq",
",",
"int",
"x",
",",
"int",
"y",
")",
"{",
"assert",
"(",
"y",
"<",
"x",
")",
";",
"final",
"DBIDArrayIter",
"ix",
"=",
"mat",
".",
"ix",
",",
"iy",
"=",
"mat",
".",
"iy",
";",
"final",
"double",
"[",
"]",
"distances",
"=",
"mat",
".",
"matrix",
";",
"ModifiableDBIDs",
"cx",
"=",
"clusters",
".",
"get",
"(",
"x",
")",
",",
"cy",
"=",
"clusters",
".",
"get",
"(",
"y",
")",
";",
"DBIDVar",
"prototype",
"=",
"DBIDUtil",
".",
"newVar",
"(",
"ix",
".",
"seek",
"(",
"x",
")",
")",
";",
"// Default prototype",
"double",
"minMaxDist",
";",
"// Two \"real\" clusters:",
"if",
"(",
"cx",
"!=",
"null",
"&&",
"cy",
"!=",
"null",
")",
"{",
"minMaxDist",
"=",
"findPrototype",
"(",
"dq",
",",
"cx",
",",
"cy",
",",
"prototype",
",",
"Double",
".",
"POSITIVE_INFINITY",
")",
";",
"minMaxDist",
"=",
"findPrototype",
"(",
"dq",
",",
"cy",
",",
"cx",
",",
"prototype",
",",
"minMaxDist",
")",
";",
"}",
"else",
"if",
"(",
"cx",
"!=",
"null",
")",
"{",
"// cy is singleton.",
"minMaxDist",
"=",
"findPrototypeSingleton",
"(",
"dq",
",",
"cx",
",",
"iy",
".",
"seek",
"(",
"y",
")",
",",
"prototype",
")",
";",
"}",
"else",
"if",
"(",
"cy",
"!=",
"null",
")",
"{",
"// cx is singleton.",
"minMaxDist",
"=",
"findPrototypeSingleton",
"(",
"dq",
",",
"cy",
",",
"ix",
".",
"seek",
"(",
"x",
")",
",",
"prototype",
")",
";",
"}",
"else",
"{",
"minMaxDist",
"=",
"dq",
".",
"distance",
"(",
"ix",
".",
"seek",
"(",
"x",
")",
",",
"iy",
".",
"seek",
"(",
"y",
")",
")",
";",
"prototype",
".",
"set",
"(",
"ix",
")",
";",
"}",
"final",
"int",
"offset",
"=",
"MatrixParadigm",
".",
"triangleSize",
"(",
"x",
")",
"+",
"y",
";",
"distances",
"[",
"offset",
"]",
"=",
"minMaxDist",
";",
"prots",
".",
"seek",
"(",
"offset",
")",
".",
"setDBID",
"(",
"prototype",
")",
";",
"}"
] | Update entry at x,y for distance matrix distances
@param mat distance matrix
@param prots calculated prototypes
@param clusters the clusters
@param dq distance query on the data set
@param x index of cluster, {@code x > y}
@param y index of cluster, {@code y < x} | [
"Update",
"entry",
"at",
"x",
"y",
"for",
"distance",
"matrix",
"distances"
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/MiniMax.java#L273-L302 |
jronrun/benayn | benayn-ustyle/src/main/java/com/benayn/ustyle/Sources.java | Sources.asString | public static String asString(Class<?> contextClass, String resourceName) throws IOException {
"""
Returns the given source as a {@link String}.
@param contextClass
@param resourceName
@return
@throws IOException
"""
Closer closer = Closer.create();
try {
return CharStreams.toString(closer.register(asCharSource(contextClass, resourceName).openStream()));
} catch (Throwable e) {
throw closer.rethrow(e);
} finally {
closer.close();
}
} | java | public static String asString(Class<?> contextClass, String resourceName) throws IOException {
Closer closer = Closer.create();
try {
return CharStreams.toString(closer.register(asCharSource(contextClass, resourceName).openStream()));
} catch (Throwable e) {
throw closer.rethrow(e);
} finally {
closer.close();
}
} | [
"public",
"static",
"String",
"asString",
"(",
"Class",
"<",
"?",
">",
"contextClass",
",",
"String",
"resourceName",
")",
"throws",
"IOException",
"{",
"Closer",
"closer",
"=",
"Closer",
".",
"create",
"(",
")",
";",
"try",
"{",
"return",
"CharStreams",
".",
"toString",
"(",
"closer",
".",
"register",
"(",
"asCharSource",
"(",
"contextClass",
",",
"resourceName",
")",
".",
"openStream",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"Throwable",
"e",
")",
"{",
"throw",
"closer",
".",
"rethrow",
"(",
"e",
")",
";",
"}",
"finally",
"{",
"closer",
".",
"close",
"(",
")",
";",
"}",
"}"
] | Returns the given source as a {@link String}.
@param contextClass
@param resourceName
@return
@throws IOException | [
"Returns",
"the",
"given",
"source",
"as",
"a",
"{",
"@link",
"String",
"}",
"."
] | train | https://github.com/jronrun/benayn/blob/7585152e10e4cac07b4274c65f1c72ad7061ae69/benayn-ustyle/src/main/java/com/benayn/ustyle/Sources.java#L64-L73 |
revapi/revapi | revapi-java-spi/src/main/java/org/revapi/java/spi/CheckBase.java | CheckBase.visitClass | @Override
public final void visitClass(@Nullable JavaTypeElement oldType, @Nullable JavaTypeElement newType) {
"""
Please override the
{@link #doVisitClass(JavaTypeElement, JavaTypeElement)}
@see Check#visitClass(JavaTypeElement, JavaTypeElement)
"""
depth++;
doVisitClass(oldType, newType);
} | java | @Override
public final void visitClass(@Nullable JavaTypeElement oldType, @Nullable JavaTypeElement newType) {
depth++;
doVisitClass(oldType, newType);
} | [
"@",
"Override",
"public",
"final",
"void",
"visitClass",
"(",
"@",
"Nullable",
"JavaTypeElement",
"oldType",
",",
"@",
"Nullable",
"JavaTypeElement",
"newType",
")",
"{",
"depth",
"++",
";",
"doVisitClass",
"(",
"oldType",
",",
"newType",
")",
";",
"}"
] | Please override the
{@link #doVisitClass(JavaTypeElement, JavaTypeElement)}
@see Check#visitClass(JavaTypeElement, JavaTypeElement) | [
"Please",
"override",
"the",
"{",
"@link",
"#doVisitClass",
"(",
"JavaTypeElement",
"JavaTypeElement",
")",
"}"
] | train | https://github.com/revapi/revapi/blob/e070b136d977441ab96fdce067a13e7e0423295b/revapi-java-spi/src/main/java/org/revapi/java/spi/CheckBase.java#L254-L258 |
wildfly/wildfly-core | cli/src/main/java/org/jboss/as/cli/parsing/ParserUtil.java | ParserUtil.parseHeaders | public static String parseHeaders(String commandLine, final CommandLineParser.CallbackHandler handler, CommandContext ctx) throws CommandFormatException {
"""
Returns the string which was actually parsed with all the substitutions
performed
"""
if (commandLine == null) {
return null;
}
SubstitutedLine sl = parseHeadersLine(commandLine, handler, ctx);
return sl == null ? null : sl.getSubstitued();
} | java | public static String parseHeaders(String commandLine, final CommandLineParser.CallbackHandler handler, CommandContext ctx) throws CommandFormatException {
if (commandLine == null) {
return null;
}
SubstitutedLine sl = parseHeadersLine(commandLine, handler, ctx);
return sl == null ? null : sl.getSubstitued();
} | [
"public",
"static",
"String",
"parseHeaders",
"(",
"String",
"commandLine",
",",
"final",
"CommandLineParser",
".",
"CallbackHandler",
"handler",
",",
"CommandContext",
"ctx",
")",
"throws",
"CommandFormatException",
"{",
"if",
"(",
"commandLine",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"SubstitutedLine",
"sl",
"=",
"parseHeadersLine",
"(",
"commandLine",
",",
"handler",
",",
"ctx",
")",
";",
"return",
"sl",
"==",
"null",
"?",
"null",
":",
"sl",
".",
"getSubstitued",
"(",
")",
";",
"}"
] | Returns the string which was actually parsed with all the substitutions
performed | [
"Returns",
"the",
"string",
"which",
"was",
"actually",
"parsed",
"with",
"all",
"the",
"substitutions",
"performed"
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/cli/src/main/java/org/jboss/as/cli/parsing/ParserUtil.java#L147-L153 |
LableOrg/java-uniqueid | uniqueid-zookeeper/src/main/java/org/lable/oss/uniqueid/zookeeper/SynchronizedUniqueIDGeneratorFactory.java | SynchronizedUniqueIDGeneratorFactory.generatorFor | public static synchronized IDGenerator generatorFor(SynchronizedGeneratorIdentity synchronizedGeneratorIdentity,
Mode mode)
throws IOException {
"""
Get the synchronized ID generator instance.
@param synchronizedGeneratorIdentity An instance of {@link SynchronizedGeneratorIdentity} to (re)use for
acquiring the generator ID.
@param mode Generator mode.
@return An instance of this class.
@throws IOException Thrown when something went wrong trying to find the cluster ID or trying to claim a
generator ID.
"""
String instanceKey = synchronizedGeneratorIdentity.getZNode();
if (!instances.containsKey(instanceKey)) {
logger.debug("Creating new instance.");
instances.putIfAbsent(instanceKey, new BaseUniqueIDGenerator(synchronizedGeneratorIdentity, mode));
}
return instances.get(instanceKey);
} | java | public static synchronized IDGenerator generatorFor(SynchronizedGeneratorIdentity synchronizedGeneratorIdentity,
Mode mode)
throws IOException {
String instanceKey = synchronizedGeneratorIdentity.getZNode();
if (!instances.containsKey(instanceKey)) {
logger.debug("Creating new instance.");
instances.putIfAbsent(instanceKey, new BaseUniqueIDGenerator(synchronizedGeneratorIdentity, mode));
}
return instances.get(instanceKey);
} | [
"public",
"static",
"synchronized",
"IDGenerator",
"generatorFor",
"(",
"SynchronizedGeneratorIdentity",
"synchronizedGeneratorIdentity",
",",
"Mode",
"mode",
")",
"throws",
"IOException",
"{",
"String",
"instanceKey",
"=",
"synchronizedGeneratorIdentity",
".",
"getZNode",
"(",
")",
";",
"if",
"(",
"!",
"instances",
".",
"containsKey",
"(",
"instanceKey",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Creating new instance.\"",
")",
";",
"instances",
".",
"putIfAbsent",
"(",
"instanceKey",
",",
"new",
"BaseUniqueIDGenerator",
"(",
"synchronizedGeneratorIdentity",
",",
"mode",
")",
")",
";",
"}",
"return",
"instances",
".",
"get",
"(",
"instanceKey",
")",
";",
"}"
] | Get the synchronized ID generator instance.
@param synchronizedGeneratorIdentity An instance of {@link SynchronizedGeneratorIdentity} to (re)use for
acquiring the generator ID.
@param mode Generator mode.
@return An instance of this class.
@throws IOException Thrown when something went wrong trying to find the cluster ID or trying to claim a
generator ID. | [
"Get",
"the",
"synchronized",
"ID",
"generator",
"instance",
"."
] | train | https://github.com/LableOrg/java-uniqueid/blob/554e30b2277765f365e7c7f598108de0ab5744f4/uniqueid-zookeeper/src/main/java/org/lable/oss/uniqueid/zookeeper/SynchronizedUniqueIDGeneratorFactory.java#L78-L88 |
lucee/Lucee | core/src/main/java/lucee/runtime/op/Caster.java | Caster.toQueryColumn | public static QueryColumn toQueryColumn(Object o) throws PageException {
"""
converts a object to a QueryColumn, if possible
@param o
@return
@throws PageException
"""
if (o instanceof QueryColumn) return (QueryColumn) o;
throw new CasterException(o, "querycolumn");
} | java | public static QueryColumn toQueryColumn(Object o) throws PageException {
if (o instanceof QueryColumn) return (QueryColumn) o;
throw new CasterException(o, "querycolumn");
} | [
"public",
"static",
"QueryColumn",
"toQueryColumn",
"(",
"Object",
"o",
")",
"throws",
"PageException",
"{",
"if",
"(",
"o",
"instanceof",
"QueryColumn",
")",
"return",
"(",
"QueryColumn",
")",
"o",
";",
"throw",
"new",
"CasterException",
"(",
"o",
",",
"\"querycolumn\"",
")",
";",
"}"
] | converts a object to a QueryColumn, if possible
@param o
@return
@throws PageException | [
"converts",
"a",
"object",
"to",
"a",
"QueryColumn",
"if",
"possible"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/runtime/op/Caster.java#L2985-L2988 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/AzureFirewallsInner.java | AzureFirewallsInner.getByResourceGroupAsync | public Observable<AzureFirewallInner> getByResourceGroupAsync(String resourceGroupName, String azureFirewallName) {
"""
Gets the specified Azure Firewall.
@param resourceGroupName The name of the resource group.
@param azureFirewallName The name of the Azure Firewall.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the AzureFirewallInner object
"""
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, azureFirewallName).map(new Func1<ServiceResponse<AzureFirewallInner>, AzureFirewallInner>() {
@Override
public AzureFirewallInner call(ServiceResponse<AzureFirewallInner> response) {
return response.body();
}
});
} | java | public Observable<AzureFirewallInner> getByResourceGroupAsync(String resourceGroupName, String azureFirewallName) {
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, azureFirewallName).map(new Func1<ServiceResponse<AzureFirewallInner>, AzureFirewallInner>() {
@Override
public AzureFirewallInner call(ServiceResponse<AzureFirewallInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"AzureFirewallInner",
">",
"getByResourceGroupAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"azureFirewallName",
")",
"{",
"return",
"getByResourceGroupWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"azureFirewallName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"AzureFirewallInner",
">",
",",
"AzureFirewallInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"AzureFirewallInner",
"call",
"(",
"ServiceResponse",
"<",
"AzureFirewallInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Gets the specified Azure Firewall.
@param resourceGroupName The name of the resource group.
@param azureFirewallName The name of the Azure Firewall.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the AzureFirewallInner object | [
"Gets",
"the",
"specified",
"Azure",
"Firewall",
"."
] | 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/AzureFirewallsInner.java#L291-L298 |
TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/net/Pipe.java | Pipe.designPipe | public void designPipe( double[][] diameters, double tau, double g, double maxd, double c, StringBuilder strWarnings ) {
"""
Calculate the dimension of the pipes.
<p>
It switch between several section geometry.
</p>
@param diameters
matrix with the commercial diameters.
@param tau
tangential stress at the bottom of the pipe..
@param g
fill degree.
@param maxd
maximum diameter.
@param c
is a geometric expression b/h where h is the height and b base
(only for rectangular or trapezium shape).
"""
switch( this.pipeSectionType ) {
case 1:
designCircularPipe(diameters, tau, g, maxd, strWarnings);
break;
case 2:
designRectangularPipe(tau, g, maxd, c, strWarnings);
break;
case 3:
designTrapeziumPipe(tau, g, maxd, c, strWarnings);
break;
default:
designCircularPipe(diameters, tau, g, maxd, strWarnings);
break;
}
} | java | public void designPipe( double[][] diameters, double tau, double g, double maxd, double c, StringBuilder strWarnings ) {
switch( this.pipeSectionType ) {
case 1:
designCircularPipe(diameters, tau, g, maxd, strWarnings);
break;
case 2:
designRectangularPipe(tau, g, maxd, c, strWarnings);
break;
case 3:
designTrapeziumPipe(tau, g, maxd, c, strWarnings);
break;
default:
designCircularPipe(diameters, tau, g, maxd, strWarnings);
break;
}
} | [
"public",
"void",
"designPipe",
"(",
"double",
"[",
"]",
"[",
"]",
"diameters",
",",
"double",
"tau",
",",
"double",
"g",
",",
"double",
"maxd",
",",
"double",
"c",
",",
"StringBuilder",
"strWarnings",
")",
"{",
"switch",
"(",
"this",
".",
"pipeSectionType",
")",
"{",
"case",
"1",
":",
"designCircularPipe",
"(",
"diameters",
",",
"tau",
",",
"g",
",",
"maxd",
",",
"strWarnings",
")",
";",
"break",
";",
"case",
"2",
":",
"designRectangularPipe",
"(",
"tau",
",",
"g",
",",
"maxd",
",",
"c",
",",
"strWarnings",
")",
";",
"break",
";",
"case",
"3",
":",
"designTrapeziumPipe",
"(",
"tau",
",",
"g",
",",
"maxd",
",",
"c",
",",
"strWarnings",
")",
";",
"break",
";",
"default",
":",
"designCircularPipe",
"(",
"diameters",
",",
"tau",
",",
"g",
",",
"maxd",
",",
"strWarnings",
")",
";",
"break",
";",
"}",
"}"
] | Calculate the dimension of the pipes.
<p>
It switch between several section geometry.
</p>
@param diameters
matrix with the commercial diameters.
@param tau
tangential stress at the bottom of the pipe..
@param g
fill degree.
@param maxd
maximum diameter.
@param c
is a geometric expression b/h where h is the height and b base
(only for rectangular or trapezium shape). | [
"Calculate",
"the",
"dimension",
"of",
"the",
"pipes",
"."
] | train | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/net/Pipe.java#L608-L624 |
apache/groovy | subprojects/groovy-nio/src/main/java/org/codehaus/groovy/runtime/NioGroovyMethods.java | NioGroovyMethods.getText | public static String getText(Path self, String charset) throws IOException {
"""
Read the content of the Path using the specified encoding and return it
as a String.
@param self the file whose content we want to read
@param charset the charset used to read the content of the file
@return a String containing the content of the file
@throws java.io.IOException if an IOException occurs.
@since 2.3.0
"""
return IOGroovyMethods.getText(newReader(self, charset));
} | java | public static String getText(Path self, String charset) throws IOException {
return IOGroovyMethods.getText(newReader(self, charset));
} | [
"public",
"static",
"String",
"getText",
"(",
"Path",
"self",
",",
"String",
"charset",
")",
"throws",
"IOException",
"{",
"return",
"IOGroovyMethods",
".",
"getText",
"(",
"newReader",
"(",
"self",
",",
"charset",
")",
")",
";",
"}"
] | Read the content of the Path using the specified encoding and return it
as a String.
@param self the file whose content we want to read
@param charset the charset used to read the content of the file
@return a String containing the content of the file
@throws java.io.IOException if an IOException occurs.
@since 2.3.0 | [
"Read",
"the",
"content",
"of",
"the",
"Path",
"using",
"the",
"specified",
"encoding",
"and",
"return",
"it",
"as",
"a",
"String",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-nio/src/main/java/org/codehaus/groovy/runtime/NioGroovyMethods.java#L380-L382 |
landawn/AbacusUtil | src/com/landawn/abacus/util/Primitives.java | Primitives.unbox | public static float[] unbox(final Float[] a, final float valueForNull) {
"""
<p>
Converts an array of object Floats to primitives handling {@code null}.
</p>
<p>
This method returns {@code null} for a {@code null} input array.
</p>
@param a
a {@code Float} array, may be {@code null}
@param valueForNull
the value to insert if {@code null} found
@return a {@code float} array, {@code null} if null array input
"""
if (a == null) {
return null;
}
return unbox(a, 0, a.length, valueForNull);
} | java | public static float[] unbox(final Float[] a, final float valueForNull) {
if (a == null) {
return null;
}
return unbox(a, 0, a.length, valueForNull);
} | [
"public",
"static",
"float",
"[",
"]",
"unbox",
"(",
"final",
"Float",
"[",
"]",
"a",
",",
"final",
"float",
"valueForNull",
")",
"{",
"if",
"(",
"a",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"unbox",
"(",
"a",
",",
"0",
",",
"a",
".",
"length",
",",
"valueForNull",
")",
";",
"}"
] | <p>
Converts an array of object Floats to primitives handling {@code null}.
</p>
<p>
This method returns {@code null} for a {@code null} input array.
</p>
@param a
a {@code Float} array, may be {@code null}
@param valueForNull
the value to insert if {@code null} found
@return a {@code float} array, {@code null} if null array input | [
"<p",
">",
"Converts",
"an",
"array",
"of",
"object",
"Floats",
"to",
"primitives",
"handling",
"{",
"@code",
"null",
"}",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/util/Primitives.java#L1137-L1143 |
dkmfbk/knowledgestore | ks-server-hbase/src/main/java/eu/fbk/knowledgestore/datastore/hbase/utils/OmidHBaseUtils.java | OmidHBaseUtils.getScanner | @Override
public ResultScanner getScanner(String tableName, Scan scan) {
"""
Gets a scanner for a specific table
@param tableName to get the scanner from
@param scan for the specific table
@param conf object to get a hold of an HBase table
"""
logger.debug("OMID Begin of getScanner(" + tableName + ", " + scan + ")");
TTable tTable = (TTable)getTable(tableName);
ResultScanner resScanner = null;
try {
resScanner = tTable.getScanner(t1, scan);
} catch (IOException e) {
logger.error("Error while trying to obtain a ResultScanner: " + tableName);
logger.error(e.getMessage());
}
return resScanner;
} | java | @Override
public ResultScanner getScanner(String tableName, Scan scan) {
logger.debug("OMID Begin of getScanner(" + tableName + ", " + scan + ")");
TTable tTable = (TTable)getTable(tableName);
ResultScanner resScanner = null;
try {
resScanner = tTable.getScanner(t1, scan);
} catch (IOException e) {
logger.error("Error while trying to obtain a ResultScanner: " + tableName);
logger.error(e.getMessage());
}
return resScanner;
} | [
"@",
"Override",
"public",
"ResultScanner",
"getScanner",
"(",
"String",
"tableName",
",",
"Scan",
"scan",
")",
"{",
"logger",
".",
"debug",
"(",
"\"OMID Begin of getScanner(\"",
"+",
"tableName",
"+",
"\", \"",
"+",
"scan",
"+",
"\")\"",
")",
";",
"TTable",
"tTable",
"=",
"(",
"TTable",
")",
"getTable",
"(",
"tableName",
")",
";",
"ResultScanner",
"resScanner",
"=",
"null",
";",
"try",
"{",
"resScanner",
"=",
"tTable",
".",
"getScanner",
"(",
"t1",
",",
"scan",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Error while trying to obtain a ResultScanner: \"",
"+",
"tableName",
")",
";",
"logger",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"resScanner",
";",
"}"
] | Gets a scanner for a specific table
@param tableName to get the scanner from
@param scan for the specific table
@param conf object to get a hold of an HBase table | [
"Gets",
"a",
"scanner",
"for",
"a",
"specific",
"table"
] | train | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-server-hbase/src/main/java/eu/fbk/knowledgestore/datastore/hbase/utils/OmidHBaseUtils.java#L276-L288 |
danieldk/dictomaton | src/main/java/eu/danieldk/dictomaton/collections/ImmutableStringShortMap.java | ImmutableStringShortMap.getOrElse | public short getOrElse(String key, short defaultValue) {
"""
Get the value associated with a key, returning a default value is it
is not in the mapping.
"""
int hash = d_keys.number(key);
if (hash == -1)
return defaultValue;
return d_values[hash - 1];
} | java | public short getOrElse(String key, short defaultValue) {
int hash = d_keys.number(key);
if (hash == -1)
return defaultValue;
return d_values[hash - 1];
} | [
"public",
"short",
"getOrElse",
"(",
"String",
"key",
",",
"short",
"defaultValue",
")",
"{",
"int",
"hash",
"=",
"d_keys",
".",
"number",
"(",
"key",
")",
";",
"if",
"(",
"hash",
"==",
"-",
"1",
")",
"return",
"defaultValue",
";",
"return",
"d_values",
"[",
"hash",
"-",
"1",
"]",
";",
"}"
] | Get the value associated with a key, returning a default value is it
is not in the mapping. | [
"Get",
"the",
"value",
"associated",
"with",
"a",
"key",
"returning",
"a",
"default",
"value",
"is",
"it",
"is",
"not",
"in",
"the",
"mapping",
"."
] | train | https://github.com/danieldk/dictomaton/blob/c0a3ae2d407ebd88023ea2d0f02a4882b0492df0/src/main/java/eu/danieldk/dictomaton/collections/ImmutableStringShortMap.java#L261-L267 |
dlemmermann/PreferencesFX | preferencesfx/src/main/java/com/dlsc/preferencesfx/PreferencesFx.java | PreferencesFx.initializeCategoryViews | private void initializeCategoryViews() {
"""
Prepares the CategoryController by creating CategoryView / CategoryPresenter pairs from all
Categories and loading them into the CategoryController.
"""
preferencesFxModel.getFlatCategoriesLst().forEach(category -> {
CategoryView categoryView = new CategoryView(preferencesFxModel, category);
CategoryPresenter categoryPresenter = new CategoryPresenter(
preferencesFxModel, category, categoryView, breadCrumbPresenter
);
categoryController.addView(category, categoryView, categoryPresenter);
});
} | java | private void initializeCategoryViews() {
preferencesFxModel.getFlatCategoriesLst().forEach(category -> {
CategoryView categoryView = new CategoryView(preferencesFxModel, category);
CategoryPresenter categoryPresenter = new CategoryPresenter(
preferencesFxModel, category, categoryView, breadCrumbPresenter
);
categoryController.addView(category, categoryView, categoryPresenter);
});
} | [
"private",
"void",
"initializeCategoryViews",
"(",
")",
"{",
"preferencesFxModel",
".",
"getFlatCategoriesLst",
"(",
")",
".",
"forEach",
"(",
"category",
"->",
"{",
"CategoryView",
"categoryView",
"=",
"new",
"CategoryView",
"(",
"preferencesFxModel",
",",
"category",
")",
";",
"CategoryPresenter",
"categoryPresenter",
"=",
"new",
"CategoryPresenter",
"(",
"preferencesFxModel",
",",
"category",
",",
"categoryView",
",",
"breadCrumbPresenter",
")",
";",
"categoryController",
".",
"addView",
"(",
"category",
",",
"categoryView",
",",
"categoryPresenter",
")",
";",
"}",
")",
";",
"}"
] | Prepares the CategoryController by creating CategoryView / CategoryPresenter pairs from all
Categories and loading them into the CategoryController. | [
"Prepares",
"the",
"CategoryController",
"by",
"creating",
"CategoryView",
"/",
"CategoryPresenter",
"pairs",
"from",
"all",
"Categories",
"and",
"loading",
"them",
"into",
"the",
"CategoryController",
"."
] | train | https://github.com/dlemmermann/PreferencesFX/blob/e06a49663ec949c2f7eb56e6b5952c030ed42d33/preferencesfx/src/main/java/com/dlsc/preferencesfx/PreferencesFx.java#L115-L123 |
netty/netty | codec-http/src/main/java/io/netty/handler/codec/http/cookie/DefaultCookie.java | DefaultCookie.validateValue | @Deprecated
protected String validateValue(String name, String value) {
"""
Validate a cookie attribute value, throws a {@link IllegalArgumentException} otherwise.
Only intended to be used by {@link io.netty.handler.codec.http.DefaultCookie}.
@param name attribute name
@param value attribute value
@return the trimmed, validated attribute value
@deprecated CookieUtil is package private, will be removed once old Cookie API is dropped
"""
return validateAttributeValue(name, value);
} | java | @Deprecated
protected String validateValue(String name, String value) {
return validateAttributeValue(name, value);
} | [
"@",
"Deprecated",
"protected",
"String",
"validateValue",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"return",
"validateAttributeValue",
"(",
"name",
",",
"value",
")",
";",
"}"
] | Validate a cookie attribute value, throws a {@link IllegalArgumentException} otherwise.
Only intended to be used by {@link io.netty.handler.codec.http.DefaultCookie}.
@param name attribute name
@param value attribute value
@return the trimmed, validated attribute value
@deprecated CookieUtil is package private, will be removed once old Cookie API is dropped | [
"Validate",
"a",
"cookie",
"attribute",
"value",
"throws",
"a",
"{"
] | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-http/src/main/java/io/netty/handler/codec/http/cookie/DefaultCookie.java#L205-L208 |
bbossgroups/bboss-elasticsearch | bboss-elasticsearch/src/main/java/org/frameworkset/elasticsearch/AbstractElasticSearchIndexRequestBuilderFactory.java | AbstractElasticSearchIndexRequestBuilderFactory.getIndexName | protected String getIndexName(String indexPrefix, long timestamp) {
"""
Gets the name of the index to use for an index request
@param indexPrefix
Prefix of index name to use -- as configured on the sink
@param timestamp
timestamp (millis) to format / use
@return index name of the form 'indexPrefix-formattedTimestamp'
"""
return new StringBuilder(indexPrefix).append('-')
.append(fastDateFormat.format(timestamp)).toString();
} | java | protected String getIndexName(String indexPrefix, long timestamp) {
return new StringBuilder(indexPrefix).append('-')
.append(fastDateFormat.format(timestamp)).toString();
} | [
"protected",
"String",
"getIndexName",
"(",
"String",
"indexPrefix",
",",
"long",
"timestamp",
")",
"{",
"return",
"new",
"StringBuilder",
"(",
"indexPrefix",
")",
".",
"append",
"(",
"'",
"'",
")",
".",
"append",
"(",
"fastDateFormat",
".",
"format",
"(",
"timestamp",
")",
")",
".",
"toString",
"(",
")",
";",
"}"
] | Gets the name of the index to use for an index request
@param indexPrefix
Prefix of index name to use -- as configured on the sink
@param timestamp
timestamp (millis) to format / use
@return index name of the form 'indexPrefix-formattedTimestamp' | [
"Gets",
"the",
"name",
"of",
"the",
"index",
"to",
"use",
"for",
"an",
"index",
"request"
] | train | https://github.com/bbossgroups/bboss-elasticsearch/blob/31717c8aa2c4c880987be53aeeb8a0cf5183c3a7/bboss-elasticsearch/src/main/java/org/frameworkset/elasticsearch/AbstractElasticSearchIndexRequestBuilderFactory.java#L95-L98 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/VirtualNetworkGatewaysInner.java | VirtualNetworkGatewaysInner.beginGetBgpPeerStatus | public BgpPeerStatusListResultInner beginGetBgpPeerStatus(String resourceGroupName, String virtualNetworkGatewayName) {
"""
The GetBgpPeerStatus operation retrieves the status of all BGP peers.
@param resourceGroupName The name of the resource group.
@param virtualNetworkGatewayName The name of the virtual network gateway.
@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 BgpPeerStatusListResultInner object if successful.
"""
return beginGetBgpPeerStatusWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayName).toBlocking().single().body();
} | java | public BgpPeerStatusListResultInner beginGetBgpPeerStatus(String resourceGroupName, String virtualNetworkGatewayName) {
return beginGetBgpPeerStatusWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayName).toBlocking().single().body();
} | [
"public",
"BgpPeerStatusListResultInner",
"beginGetBgpPeerStatus",
"(",
"String",
"resourceGroupName",
",",
"String",
"virtualNetworkGatewayName",
")",
"{",
"return",
"beginGetBgpPeerStatusWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"virtualNetworkGatewayName",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | The GetBgpPeerStatus operation retrieves the status of all BGP peers.
@param resourceGroupName The name of the resource group.
@param virtualNetworkGatewayName The name of the virtual network gateway.
@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 BgpPeerStatusListResultInner object if successful. | [
"The",
"GetBgpPeerStatus",
"operation",
"retrieves",
"the",
"status",
"of",
"all",
"BGP",
"peers",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/VirtualNetworkGatewaysInner.java#L2089-L2091 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/time/LocalDateTime.java | LocalDateTime.plusMonths | public LocalDateTime plusMonths(long months) {
"""
Returns a copy of this {@code LocalDateTime} with the specified number of months added.
<p>
This method adds the specified amount to the months field in three steps:
<ol>
<li>Add the input months to the month-of-year field</li>
<li>Check if the resulting date would be invalid</li>
<li>Adjust the day-of-month to the last valid day if necessary</li>
</ol>
<p>
For example, 2007-03-31 plus one month would result in the invalid date
2007-04-31. Instead of returning an invalid result, the last valid day
of the month, 2007-04-30, is selected instead.
<p>
This instance is immutable and unaffected by this method call.
@param months the months to add, may be negative
@return a {@code LocalDateTime} based on this date-time with the months added, not null
@throws DateTimeException if the result exceeds the supported date range
"""
LocalDate newDate = date.plusMonths(months);
return with(newDate, time);
} | java | public LocalDateTime plusMonths(long months) {
LocalDate newDate = date.plusMonths(months);
return with(newDate, time);
} | [
"public",
"LocalDateTime",
"plusMonths",
"(",
"long",
"months",
")",
"{",
"LocalDate",
"newDate",
"=",
"date",
".",
"plusMonths",
"(",
"months",
")",
";",
"return",
"with",
"(",
"newDate",
",",
"time",
")",
";",
"}"
] | Returns a copy of this {@code LocalDateTime} with the specified number of months added.
<p>
This method adds the specified amount to the months field in three steps:
<ol>
<li>Add the input months to the month-of-year field</li>
<li>Check if the resulting date would be invalid</li>
<li>Adjust the day-of-month to the last valid day if necessary</li>
</ol>
<p>
For example, 2007-03-31 plus one month would result in the invalid date
2007-04-31. Instead of returning an invalid result, the last valid day
of the month, 2007-04-30, is selected instead.
<p>
This instance is immutable and unaffected by this method call.
@param months the months to add, may be negative
@return a {@code LocalDateTime} based on this date-time with the months added, not null
@throws DateTimeException if the result exceeds the supported date range | [
"Returns",
"a",
"copy",
"of",
"this",
"{",
"@code",
"LocalDateTime",
"}",
"with",
"the",
"specified",
"number",
"of",
"months",
"added",
".",
"<p",
">",
"This",
"method",
"adds",
"the",
"specified",
"amount",
"to",
"the",
"months",
"field",
"in",
"three",
"steps",
":",
"<ol",
">",
"<li",
">",
"Add",
"the",
"input",
"months",
"to",
"the",
"month",
"-",
"of",
"-",
"year",
"field<",
"/",
"li",
">",
"<li",
">",
"Check",
"if",
"the",
"resulting",
"date",
"would",
"be",
"invalid<",
"/",
"li",
">",
"<li",
">",
"Adjust",
"the",
"day",
"-",
"of",
"-",
"month",
"to",
"the",
"last",
"valid",
"day",
"if",
"necessary<",
"/",
"li",
">",
"<",
"/",
"ol",
">",
"<p",
">",
"For",
"example",
"2007",
"-",
"03",
"-",
"31",
"plus",
"one",
"month",
"would",
"result",
"in",
"the",
"invalid",
"date",
"2007",
"-",
"04",
"-",
"31",
".",
"Instead",
"of",
"returning",
"an",
"invalid",
"result",
"the",
"last",
"valid",
"day",
"of",
"the",
"month",
"2007",
"-",
"04",
"-",
"30",
"is",
"selected",
"instead",
".",
"<p",
">",
"This",
"instance",
"is",
"immutable",
"and",
"unaffected",
"by",
"this",
"method",
"call",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/time/LocalDateTime.java#L1239-L1242 |
Metatavu/edelphi | edelphi/src/main/java/fi/metatavu/edelphi/liquibase/changes/FixInvitations.java | FixInvitations.isPanelUser | private boolean isPanelUser(JdbcConnection connection, Long panelId, String email) throws CustomChangeException {
"""
Returns whether user by email is a PanelUser or not
@param connection connection
@param panelId panel id
@param email email
@return whether user by email is a PanelUser or not
@throws CustomChangeException on error
"""
try (PreparedStatement statement = connection.prepareStatement("SELECT id FROM PANELUSER WHERE panel_id = ? AND user_id = (SELECT id FROM USEREMAIL WHERE address = ?)")) {
statement.setLong(1, panelId);
statement.setString(2, email);
try (ResultSet resultSet = statement.executeQuery()) {
return resultSet.next();
}
} catch (Exception e) {
throw new CustomChangeException(e);
}
} | java | private boolean isPanelUser(JdbcConnection connection, Long panelId, String email) throws CustomChangeException {
try (PreparedStatement statement = connection.prepareStatement("SELECT id FROM PANELUSER WHERE panel_id = ? AND user_id = (SELECT id FROM USEREMAIL WHERE address = ?)")) {
statement.setLong(1, panelId);
statement.setString(2, email);
try (ResultSet resultSet = statement.executeQuery()) {
return resultSet.next();
}
} catch (Exception e) {
throw new CustomChangeException(e);
}
} | [
"private",
"boolean",
"isPanelUser",
"(",
"JdbcConnection",
"connection",
",",
"Long",
"panelId",
",",
"String",
"email",
")",
"throws",
"CustomChangeException",
"{",
"try",
"(",
"PreparedStatement",
"statement",
"=",
"connection",
".",
"prepareStatement",
"(",
"\"SELECT id FROM PANELUSER WHERE panel_id = ? AND user_id = (SELECT id FROM USEREMAIL WHERE address = ?)\"",
")",
")",
"{",
"statement",
".",
"setLong",
"(",
"1",
",",
"panelId",
")",
";",
"statement",
".",
"setString",
"(",
"2",
",",
"email",
")",
";",
"try",
"(",
"ResultSet",
"resultSet",
"=",
"statement",
".",
"executeQuery",
"(",
")",
")",
"{",
"return",
"resultSet",
".",
"next",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"CustomChangeException",
"(",
"e",
")",
";",
"}",
"}"
] | Returns whether user by email is a PanelUser or not
@param connection connection
@param panelId panel id
@param email email
@return whether user by email is a PanelUser or not
@throws CustomChangeException on error | [
"Returns",
"whether",
"user",
"by",
"email",
"is",
"a",
"PanelUser",
"or",
"not"
] | train | https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/liquibase/changes/FixInvitations.java#L48-L59 |
aws/aws-sdk-java | aws-java-sdk-logs/src/main/java/com/amazonaws/services/logs/model/MetricFilterMatchRecord.java | MetricFilterMatchRecord.withExtractedValues | public MetricFilterMatchRecord withExtractedValues(java.util.Map<String, String> extractedValues) {
"""
<p>
The values extracted from the event data by the filter.
</p>
@param extractedValues
The values extracted from the event data by the filter.
@return Returns a reference to this object so that method calls can be chained together.
"""
setExtractedValues(extractedValues);
return this;
} | java | public MetricFilterMatchRecord withExtractedValues(java.util.Map<String, String> extractedValues) {
setExtractedValues(extractedValues);
return this;
} | [
"public",
"MetricFilterMatchRecord",
"withExtractedValues",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"extractedValues",
")",
"{",
"setExtractedValues",
"(",
"extractedValues",
")",
";",
"return",
"this",
";",
"}"
] | <p>
The values extracted from the event data by the filter.
</p>
@param extractedValues
The values extracted from the event data by the filter.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"The",
"values",
"extracted",
"from",
"the",
"event",
"data",
"by",
"the",
"filter",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-logs/src/main/java/com/amazonaws/services/logs/model/MetricFilterMatchRecord.java#L168-L171 |
undertow-io/undertow | core/src/main/java/io/undertow/server/handlers/PathHandler.java | PathHandler.addPrefixPath | public synchronized PathHandler addPrefixPath(final String path, final HttpHandler handler) {
"""
Adds a path prefix and a handler for that path. If the path does not start
with a / then one will be prepended.
<p>
The match is done on a prefix bases, so registering /foo will also match /foo/bar.
Though exact path matches are taken into account before prefix path matches. So
if an exact path match exists it's handler will be triggered.
<p>
If / is specified as the path then it will replace the default handler.
@param path If the request contains this prefix, run handler.
@param handler The handler which is activated upon match.
@return The resulting PathHandler after this path has been added to it.
"""
Handlers.handlerNotNull(handler);
pathMatcher.addPrefixPath(path, handler);
return this;
} | java | public synchronized PathHandler addPrefixPath(final String path, final HttpHandler handler) {
Handlers.handlerNotNull(handler);
pathMatcher.addPrefixPath(path, handler);
return this;
} | [
"public",
"synchronized",
"PathHandler",
"addPrefixPath",
"(",
"final",
"String",
"path",
",",
"final",
"HttpHandler",
"handler",
")",
"{",
"Handlers",
".",
"handlerNotNull",
"(",
"handler",
")",
";",
"pathMatcher",
".",
"addPrefixPath",
"(",
"path",
",",
"handler",
")",
";",
"return",
"this",
";",
"}"
] | Adds a path prefix and a handler for that path. If the path does not start
with a / then one will be prepended.
<p>
The match is done on a prefix bases, so registering /foo will also match /foo/bar.
Though exact path matches are taken into account before prefix path matches. So
if an exact path match exists it's handler will be triggered.
<p>
If / is specified as the path then it will replace the default handler.
@param path If the request contains this prefix, run handler.
@param handler The handler which is activated upon match.
@return The resulting PathHandler after this path has been added to it. | [
"Adds",
"a",
"path",
"prefix",
"and",
"a",
"handler",
"for",
"that",
"path",
".",
"If",
"the",
"path",
"does",
"not",
"start",
"with",
"a",
"/",
"then",
"one",
"will",
"be",
"prepended",
".",
"<p",
">",
"The",
"match",
"is",
"done",
"on",
"a",
"prefix",
"bases",
"so",
"registering",
"/",
"foo",
"will",
"also",
"match",
"/",
"foo",
"/",
"bar",
".",
"Though",
"exact",
"path",
"matches",
"are",
"taken",
"into",
"account",
"before",
"prefix",
"path",
"matches",
".",
"So",
"if",
"an",
"exact",
"path",
"match",
"exists",
"it",
"s",
"handler",
"will",
"be",
"triggered",
".",
"<p",
">",
"If",
"/",
"is",
"specified",
"as",
"the",
"path",
"then",
"it",
"will",
"replace",
"the",
"default",
"handler",
"."
] | train | https://github.com/undertow-io/undertow/blob/87de0b856a7a4ba8faf5b659537b9af07b763263/core/src/main/java/io/undertow/server/handlers/PathHandler.java#L127-L131 |
TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/utils/Utility.java | Utility.pipeMagnitude | public static void pipeMagnitude( double[] magnitude, double[] whereDrain, IHMProgressMonitor pm ) {
"""
Calculate the magnitudo of the several drainage area.
<p>
It begin from the first state, where the magnitudo is setted to 1, and
then it follow the path of the water until the outlet.
</p>
<p>
During this process the magnitudo of each through areas is incremented of
1 units. This operation is done for every state, so any path of the water
are analized, from the state where she is intercept until the outlet.
<p>
</p>
@param magnitudo is the array where the magnitudo is stored.
@param whereDrain array which contains where a pipe drains.
@param pm the progerss monitor.
@throw IllegalArgumentException if the water through a number of state
which is greater than the state in the network.
"""
int count = 0;
/* whereDrain Contiene gli indici degli stati riceventi. */
/* magnitude Contiene la magnitude dei vari stati. */
int length = magnitude.length;
/* Per ogni stato */
for( int i = 0; i < length; i++ ) {
count = 0;
/* la magnitude viene posta pari a 1 */
magnitude[i]++;
int k = i;
/*
* Si segue il percorso dell'acqua e si incrementa di 1 la mgnitude
* di tutti gli stati attraversati prima di raggiungere l'uscita
*/
while( whereDrain[k] != Constants.OUT_INDEX_PIPE && count < length ) {
k = (int) whereDrain[k];
magnitude[k]++;
count++;
}
if (count > length) {
pm.errorMessage(msg.message("trentoP.error.pipe"));
throw new IllegalArgumentException(msg.message("trentoP.error.pipe"));
}
}
} | java | public static void pipeMagnitude( double[] magnitude, double[] whereDrain, IHMProgressMonitor pm ) {
int count = 0;
/* whereDrain Contiene gli indici degli stati riceventi. */
/* magnitude Contiene la magnitude dei vari stati. */
int length = magnitude.length;
/* Per ogni stato */
for( int i = 0; i < length; i++ ) {
count = 0;
/* la magnitude viene posta pari a 1 */
magnitude[i]++;
int k = i;
/*
* Si segue il percorso dell'acqua e si incrementa di 1 la mgnitude
* di tutti gli stati attraversati prima di raggiungere l'uscita
*/
while( whereDrain[k] != Constants.OUT_INDEX_PIPE && count < length ) {
k = (int) whereDrain[k];
magnitude[k]++;
count++;
}
if (count > length) {
pm.errorMessage(msg.message("trentoP.error.pipe"));
throw new IllegalArgumentException(msg.message("trentoP.error.pipe"));
}
}
} | [
"public",
"static",
"void",
"pipeMagnitude",
"(",
"double",
"[",
"]",
"magnitude",
",",
"double",
"[",
"]",
"whereDrain",
",",
"IHMProgressMonitor",
"pm",
")",
"{",
"int",
"count",
"=",
"0",
";",
"/* whereDrain Contiene gli indici degli stati riceventi. */",
"/* magnitude Contiene la magnitude dei vari stati. */",
"int",
"length",
"=",
"magnitude",
".",
"length",
";",
"/* Per ogni stato */",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"count",
"=",
"0",
";",
"/* la magnitude viene posta pari a 1 */",
"magnitude",
"[",
"i",
"]",
"++",
";",
"int",
"k",
"=",
"i",
";",
"/*\n * Si segue il percorso dell'acqua e si incrementa di 1 la mgnitude\n * di tutti gli stati attraversati prima di raggiungere l'uscita\n */",
"while",
"(",
"whereDrain",
"[",
"k",
"]",
"!=",
"Constants",
".",
"OUT_INDEX_PIPE",
"&&",
"count",
"<",
"length",
")",
"{",
"k",
"=",
"(",
"int",
")",
"whereDrain",
"[",
"k",
"]",
";",
"magnitude",
"[",
"k",
"]",
"++",
";",
"count",
"++",
";",
"}",
"if",
"(",
"count",
">",
"length",
")",
"{",
"pm",
".",
"errorMessage",
"(",
"msg",
".",
"message",
"(",
"\"trentoP.error.pipe\"",
")",
")",
";",
"throw",
"new",
"IllegalArgumentException",
"(",
"msg",
".",
"message",
"(",
"\"trentoP.error.pipe\"",
")",
")",
";",
"}",
"}",
"}"
] | Calculate the magnitudo of the several drainage area.
<p>
It begin from the first state, where the magnitudo is setted to 1, and
then it follow the path of the water until the outlet.
</p>
<p>
During this process the magnitudo of each through areas is incremented of
1 units. This operation is done for every state, so any path of the water
are analized, from the state where she is intercept until the outlet.
<p>
</p>
@param magnitudo is the array where the magnitudo is stored.
@param whereDrain array which contains where a pipe drains.
@param pm the progerss monitor.
@throw IllegalArgumentException if the water through a number of state
which is greater than the state in the network. | [
"Calculate",
"the",
"magnitudo",
"of",
"the",
"several",
"drainage",
"area",
"."
] | train | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/utils/Utility.java#L265-L294 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/jmf/impl/JSMessageData.java | JSMessageData.ownership | private Object ownership(Object val, boolean forceShared) {
"""
this new instance, and it logically belongs in the locking scope of this.master.
"""
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
JmfTr.entry(this, tc, "ownership", new Object[] { val, Boolean.valueOf(forceShared) });
if (val instanceof JSMessageData) {
((JSMessageData) val).setParent(compatibilityWrapperOrSelf);
if (forceShared) {
((JSMessageData) val).sharedContents = true;
}
}
else if (val instanceof JMFEncapsulation) {
((JMFEncapsulation) val).setContainingMessageData(compatibilityWrapperOrSelf);
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
JmfTr.exit(this, tc, "ownership", val);
return val;
} | java | private Object ownership(Object val, boolean forceShared) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
JmfTr.entry(this, tc, "ownership", new Object[] { val, Boolean.valueOf(forceShared) });
if (val instanceof JSMessageData) {
((JSMessageData) val).setParent(compatibilityWrapperOrSelf);
if (forceShared) {
((JSMessageData) val).sharedContents = true;
}
}
else if (val instanceof JMFEncapsulation) {
((JMFEncapsulation) val).setContainingMessageData(compatibilityWrapperOrSelf);
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
JmfTr.exit(this, tc, "ownership", val);
return val;
} | [
"private",
"Object",
"ownership",
"(",
"Object",
"val",
",",
"boolean",
"forceShared",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"JmfTr",
".",
"entry",
"(",
"this",
",",
"tc",
",",
"\"ownership\"",
",",
"new",
"Object",
"[",
"]",
"{",
"val",
",",
"Boolean",
".",
"valueOf",
"(",
"forceShared",
")",
"}",
")",
";",
"if",
"(",
"val",
"instanceof",
"JSMessageData",
")",
"{",
"(",
"(",
"JSMessageData",
")",
"val",
")",
".",
"setParent",
"(",
"compatibilityWrapperOrSelf",
")",
";",
"if",
"(",
"forceShared",
")",
"{",
"(",
"(",
"JSMessageData",
")",
"val",
")",
".",
"sharedContents",
"=",
"true",
";",
"}",
"}",
"else",
"if",
"(",
"val",
"instanceof",
"JMFEncapsulation",
")",
"{",
"(",
"(",
"JMFEncapsulation",
")",
"val",
")",
".",
"setContainingMessageData",
"(",
"compatibilityWrapperOrSelf",
")",
";",
"}",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"JmfTr",
".",
"exit",
"(",
"this",
",",
"tc",
",",
"\"ownership\"",
",",
"val",
")",
";",
"return",
"val",
";",
"}"
] | this new instance, and it logically belongs in the locking scope of this.master. | [
"this",
"new",
"instance",
"and",
"it",
"logically",
"belongs",
"in",
"the",
"locking",
"scope",
"of",
"this",
".",
"master",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/jmf/impl/JSMessageData.java#L418-L436 |
datumbox/datumbox-framework | datumbox-framework-core/src/main/java/com/datumbox/framework/core/statistics/distributions/DiscreteDistributions.java | DiscreteDistributions.binomial | public static double binomial(int k, double p, int n) {
"""
Returns the probability of k of a specific number of tries n and probability p
@param k
@param p
@param n
@return
"""
if(k<0 || p<0 || n<1) {
throw new IllegalArgumentException("All the parameters must be positive and n larger than 1.");
}
k = Math.min(k, n);
/*
//Slow and can't handle large numbers
$probability=StatsUtilities::combination($n,$k)*pow($p,$k)*pow(1-$p,$n-$k);
*/
//fast and can handle large numbers
//Cdf(k)-Cdf(k-1)
double probability = approxBinomialCdf(k,p,n);
if(k>0) {
probability -= approxBinomialCdf(k-1,p,n);
}
return probability;
} | java | public static double binomial(int k, double p, int n) {
if(k<0 || p<0 || n<1) {
throw new IllegalArgumentException("All the parameters must be positive and n larger than 1.");
}
k = Math.min(k, n);
/*
//Slow and can't handle large numbers
$probability=StatsUtilities::combination($n,$k)*pow($p,$k)*pow(1-$p,$n-$k);
*/
//fast and can handle large numbers
//Cdf(k)-Cdf(k-1)
double probability = approxBinomialCdf(k,p,n);
if(k>0) {
probability -= approxBinomialCdf(k-1,p,n);
}
return probability;
} | [
"public",
"static",
"double",
"binomial",
"(",
"int",
"k",
",",
"double",
"p",
",",
"int",
"n",
")",
"{",
"if",
"(",
"k",
"<",
"0",
"||",
"p",
"<",
"0",
"||",
"n",
"<",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"All the parameters must be positive and n larger than 1.\"",
")",
";",
"}",
"k",
"=",
"Math",
".",
"min",
"(",
"k",
",",
"n",
")",
";",
"/*\n //Slow and can't handle large numbers\n $probability=StatsUtilities::combination($n,$k)*pow($p,$k)*pow(1-$p,$n-$k);\n */",
"//fast and can handle large numbers",
"//Cdf(k)-Cdf(k-1)",
"double",
"probability",
"=",
"approxBinomialCdf",
"(",
"k",
",",
"p",
",",
"n",
")",
";",
"if",
"(",
"k",
">",
"0",
")",
"{",
"probability",
"-=",
"approxBinomialCdf",
"(",
"k",
"-",
"1",
",",
"p",
",",
"n",
")",
";",
"}",
"return",
"probability",
";",
"}"
] | Returns the probability of k of a specific number of tries n and probability p
@param k
@param p
@param n
@return | [
"Returns",
"the",
"probability",
"of",
"k",
"of",
"a",
"specific",
"number",
"of",
"tries",
"n",
"and",
"probability",
"p"
] | train | https://github.com/datumbox/datumbox-framework/blob/909dff0476e80834f05ecdde0624dd2390e9b0ca/datumbox-framework-core/src/main/java/com/datumbox/framework/core/statistics/distributions/DiscreteDistributions.java#L76-L96 |
kaazing/gateway | util/src/main/java/org/kaazing/gateway/util/scheduler/SchedulerProvider.java | SchedulerProvider.getScheduler | public synchronized ScheduledExecutorService getScheduler(final String purpose, boolean needDedicatedThread) {
"""
/*
@param owner Object which will be using the scheduler (and shutting it down when the object is disposed)
@param purpose short description of the purpose of the scheduler, will be set as the thread name
if a dedicated thread is used
@param needDedicatedThread set this to true to guarantee the scheduler will have its own dedicated thread.
This is appropriate if the tasks that will be scheduled may take significant time,
e.g. sending periodic keep alive messages to all sessions
@return
"""
return needDedicatedThread ? new ManagedScheduledExecutorService(1, purpose, false) : sharedScheduler;
} | java | public synchronized ScheduledExecutorService getScheduler(final String purpose, boolean needDedicatedThread) {
return needDedicatedThread ? new ManagedScheduledExecutorService(1, purpose, false) : sharedScheduler;
} | [
"public",
"synchronized",
"ScheduledExecutorService",
"getScheduler",
"(",
"final",
"String",
"purpose",
",",
"boolean",
"needDedicatedThread",
")",
"{",
"return",
"needDedicatedThread",
"?",
"new",
"ManagedScheduledExecutorService",
"(",
"1",
",",
"purpose",
",",
"false",
")",
":",
"sharedScheduler",
";",
"}"
] | /*
@param owner Object which will be using the scheduler (and shutting it down when the object is disposed)
@param purpose short description of the purpose of the scheduler, will be set as the thread name
if a dedicated thread is used
@param needDedicatedThread set this to true to guarantee the scheduler will have its own dedicated thread.
This is appropriate if the tasks that will be scheduled may take significant time,
e.g. sending periodic keep alive messages to all sessions
@return | [
"/",
"*",
"@param",
"owner",
"Object",
"which",
"will",
"be",
"using",
"the",
"scheduler",
"(",
"and",
"shutting",
"it",
"down",
"when",
"the",
"object",
"is",
"disposed",
")"
] | train | https://github.com/kaazing/gateway/blob/06017b19273109b3b992e528e702586446168d57/util/src/main/java/org/kaazing/gateway/util/scheduler/SchedulerProvider.java#L54-L56 |
ironjacamar/ironjacamar | codegenerator/src/main/java/org/ironjacamar/codegenerator/code/ActivationCodeGen.java | ActivationCodeGen.writeGetAs | private void writeGetAs(Definition def, Writer out, int indent) throws IOException {
"""
Output get activation spec method
@param def definition
@param out Writer
@param indent space number
@throws IOException ioException
"""
writeWithIndent(out, indent, "/**\n");
writeWithIndent(out, indent, " * Get activation spec class\n");
writeWithIndent(out, indent, " * @return Activation spec\n");
writeWithIndent(out, indent, " */\n");
writeWithIndent(out, indent, "public " + def.getAsClass() + " getActivationSpec()");
writeLeftCurlyBracket(out, indent);
writeWithIndent(out, indent + 1, "return spec;");
writeRightCurlyBracket(out, indent);
writeEol(out);
} | java | private void writeGetAs(Definition def, Writer out, int indent) throws IOException
{
writeWithIndent(out, indent, "/**\n");
writeWithIndent(out, indent, " * Get activation spec class\n");
writeWithIndent(out, indent, " * @return Activation spec\n");
writeWithIndent(out, indent, " */\n");
writeWithIndent(out, indent, "public " + def.getAsClass() + " getActivationSpec()");
writeLeftCurlyBracket(out, indent);
writeWithIndent(out, indent + 1, "return spec;");
writeRightCurlyBracket(out, indent);
writeEol(out);
} | [
"private",
"void",
"writeGetAs",
"(",
"Definition",
"def",
",",
"Writer",
"out",
",",
"int",
"indent",
")",
"throws",
"IOException",
"{",
"writeWithIndent",
"(",
"out",
",",
"indent",
",",
"\"/**\\n\"",
")",
";",
"writeWithIndent",
"(",
"out",
",",
"indent",
",",
"\" * Get activation spec class\\n\"",
")",
";",
"writeWithIndent",
"(",
"out",
",",
"indent",
",",
"\" * @return Activation spec\\n\"",
")",
";",
"writeWithIndent",
"(",
"out",
",",
"indent",
",",
"\" */\\n\"",
")",
";",
"writeWithIndent",
"(",
"out",
",",
"indent",
",",
"\"public \"",
"+",
"def",
".",
"getAsClass",
"(",
")",
"+",
"\" getActivationSpec()\"",
")",
";",
"writeLeftCurlyBracket",
"(",
"out",
",",
"indent",
")",
";",
"writeWithIndent",
"(",
"out",
",",
"indent",
"+",
"1",
",",
"\"return spec;\"",
")",
";",
"writeRightCurlyBracket",
"(",
"out",
",",
"indent",
")",
";",
"writeEol",
"(",
"out",
")",
";",
"}"
] | Output get activation spec method
@param def definition
@param out Writer
@param indent space number
@throws IOException ioException | [
"Output",
"get",
"activation",
"spec",
"method"
] | train | https://github.com/ironjacamar/ironjacamar/blob/f0389ee7e62aa8b40ba09b251edad76d220ea796/codegenerator/src/main/java/org/ironjacamar/codegenerator/code/ActivationCodeGen.java#L136-L149 |
wildfly-swarm-archive/ARCHIVE-wildfly-swarm | logging/api/src/main/java/org/wildfly/swarm/logging/LoggingFraction.java | LoggingFraction.customFormatter | public LoggingFraction customFormatter(String name, String module, String className) {
"""
Add a CustomFormatter to this logger
@param name the name of the formatter
@param module the module that the logging handler depends on
@param className the logging handler class to be used
@return This fraction.
"""
return customFormatter(name, module, className, null);
} | java | public LoggingFraction customFormatter(String name, String module, String className) {
return customFormatter(name, module, className, null);
} | [
"public",
"LoggingFraction",
"customFormatter",
"(",
"String",
"name",
",",
"String",
"module",
",",
"String",
"className",
")",
"{",
"return",
"customFormatter",
"(",
"name",
",",
"module",
",",
"className",
",",
"null",
")",
";",
"}"
] | Add a CustomFormatter to this logger
@param name the name of the formatter
@param module the module that the logging handler depends on
@param className the logging handler class to be used
@return This fraction. | [
"Add",
"a",
"CustomFormatter",
"to",
"this",
"logger"
] | train | https://github.com/wildfly-swarm-archive/ARCHIVE-wildfly-swarm/blob/28ef71bcfa743a7267666e0ed2919c37b356c09b/logging/api/src/main/java/org/wildfly/swarm/logging/LoggingFraction.java#L140-L142 |
yavijava/yavijava | src/main/java/com/vmware/vim25/mox/VirtualMachineDeviceManager.java | VirtualMachineDeviceManager.createNetworkAdapter | public void createNetworkAdapter(VirtualNetworkAdapterType type, String networkName, String macAddress, boolean wakeOnLan, boolean startConnected) throws InvalidProperty, RuntimeFault, RemoteException, InterruptedException {
"""
Create a new virtual network adapter on the VM
Your MAC address should start with 00:50:56
"""
VirtualMachinePowerState powerState = vm.getRuntime().getPowerState();
String vmVerStr = vm.getConfig().getVersion();
int vmVer = Integer.parseInt(vmVerStr.substring(vmVerStr.length() - 2));
if ((powerState == VirtualMachinePowerState.suspended)) {
throw new InvalidPowerState();
}
HostSystem host = new HostSystem(vm.getServerConnection(), vm.getRuntime().getHost());
ComputeResource cr = (ComputeResource) host.getParent();
EnvironmentBrowser envBrowser = cr.getEnvironmentBrowser();
ConfigTarget configTarget = envBrowser.queryConfigTarget(host);
VirtualMachineConfigOption vmCfgOpt = envBrowser.queryConfigOption(null, host);
type = validateNicType(vmCfgOpt.getGuestOSDescriptor(), vm.getConfig().getGuestId(), type);
VirtualDeviceConfigSpec nicSpec = createNicSpec(type, networkName, macAddress, wakeOnLan, startConnected, configTarget);
VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec();
vmConfigSpec.setDeviceChange(new VirtualDeviceConfigSpec[]{nicSpec});
Task task = vm.reconfigVM_Task(vmConfigSpec);
task.waitForTask(200, 100);
} | java | public void createNetworkAdapter(VirtualNetworkAdapterType type, String networkName, String macAddress, boolean wakeOnLan, boolean startConnected) throws InvalidProperty, RuntimeFault, RemoteException, InterruptedException {
VirtualMachinePowerState powerState = vm.getRuntime().getPowerState();
String vmVerStr = vm.getConfig().getVersion();
int vmVer = Integer.parseInt(vmVerStr.substring(vmVerStr.length() - 2));
if ((powerState == VirtualMachinePowerState.suspended)) {
throw new InvalidPowerState();
}
HostSystem host = new HostSystem(vm.getServerConnection(), vm.getRuntime().getHost());
ComputeResource cr = (ComputeResource) host.getParent();
EnvironmentBrowser envBrowser = cr.getEnvironmentBrowser();
ConfigTarget configTarget = envBrowser.queryConfigTarget(host);
VirtualMachineConfigOption vmCfgOpt = envBrowser.queryConfigOption(null, host);
type = validateNicType(vmCfgOpt.getGuestOSDescriptor(), vm.getConfig().getGuestId(), type);
VirtualDeviceConfigSpec nicSpec = createNicSpec(type, networkName, macAddress, wakeOnLan, startConnected, configTarget);
VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec();
vmConfigSpec.setDeviceChange(new VirtualDeviceConfigSpec[]{nicSpec});
Task task = vm.reconfigVM_Task(vmConfigSpec);
task.waitForTask(200, 100);
} | [
"public",
"void",
"createNetworkAdapter",
"(",
"VirtualNetworkAdapterType",
"type",
",",
"String",
"networkName",
",",
"String",
"macAddress",
",",
"boolean",
"wakeOnLan",
",",
"boolean",
"startConnected",
")",
"throws",
"InvalidProperty",
",",
"RuntimeFault",
",",
"RemoteException",
",",
"InterruptedException",
"{",
"VirtualMachinePowerState",
"powerState",
"=",
"vm",
".",
"getRuntime",
"(",
")",
".",
"getPowerState",
"(",
")",
";",
"String",
"vmVerStr",
"=",
"vm",
".",
"getConfig",
"(",
")",
".",
"getVersion",
"(",
")",
";",
"int",
"vmVer",
"=",
"Integer",
".",
"parseInt",
"(",
"vmVerStr",
".",
"substring",
"(",
"vmVerStr",
".",
"length",
"(",
")",
"-",
"2",
")",
")",
";",
"if",
"(",
"(",
"powerState",
"==",
"VirtualMachinePowerState",
".",
"suspended",
")",
")",
"{",
"throw",
"new",
"InvalidPowerState",
"(",
")",
";",
"}",
"HostSystem",
"host",
"=",
"new",
"HostSystem",
"(",
"vm",
".",
"getServerConnection",
"(",
")",
",",
"vm",
".",
"getRuntime",
"(",
")",
".",
"getHost",
"(",
")",
")",
";",
"ComputeResource",
"cr",
"=",
"(",
"ComputeResource",
")",
"host",
".",
"getParent",
"(",
")",
";",
"EnvironmentBrowser",
"envBrowser",
"=",
"cr",
".",
"getEnvironmentBrowser",
"(",
")",
";",
"ConfigTarget",
"configTarget",
"=",
"envBrowser",
".",
"queryConfigTarget",
"(",
"host",
")",
";",
"VirtualMachineConfigOption",
"vmCfgOpt",
"=",
"envBrowser",
".",
"queryConfigOption",
"(",
"null",
",",
"host",
")",
";",
"type",
"=",
"validateNicType",
"(",
"vmCfgOpt",
".",
"getGuestOSDescriptor",
"(",
")",
",",
"vm",
".",
"getConfig",
"(",
")",
".",
"getGuestId",
"(",
")",
",",
"type",
")",
";",
"VirtualDeviceConfigSpec",
"nicSpec",
"=",
"createNicSpec",
"(",
"type",
",",
"networkName",
",",
"macAddress",
",",
"wakeOnLan",
",",
"startConnected",
",",
"configTarget",
")",
";",
"VirtualMachineConfigSpec",
"vmConfigSpec",
"=",
"new",
"VirtualMachineConfigSpec",
"(",
")",
";",
"vmConfigSpec",
".",
"setDeviceChange",
"(",
"new",
"VirtualDeviceConfigSpec",
"[",
"]",
"{",
"nicSpec",
"}",
")",
";",
"Task",
"task",
"=",
"vm",
".",
"reconfigVM_Task",
"(",
"vmConfigSpec",
")",
";",
"task",
".",
"waitForTask",
"(",
"200",
",",
"100",
")",
";",
"}"
] | Create a new virtual network adapter on the VM
Your MAC address should start with 00:50:56 | [
"Create",
"a",
"new",
"virtual",
"network",
"adapter",
"on",
"the",
"VM",
"Your",
"MAC",
"address",
"should",
"start",
"with",
"00",
":",
"50",
":",
"56"
] | train | https://github.com/yavijava/yavijava/blob/27fd2c5826115782d5eeb934f86e3e39240179cd/src/main/java/com/vmware/vim25/mox/VirtualMachineDeviceManager.java#L449-L473 |
Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/index/SecondaryIndex.java | SecondaryIndex.getIndexComparator | public static CellNameType getIndexComparator(CFMetaData baseMetadata, ColumnDefinition cdef) {
"""
Returns the index comparator for index backed by CFS, or null.
Note: it would be cleaner to have this be a member method. However we need this when opening indexes
sstables, but by then the CFS won't be fully initiated, so the SecondaryIndex object won't be accessible.
"""
switch (cdef.getIndexType())
{
case KEYS:
return new SimpleDenseCellNameType(keyComparator);
case COMPOSITES:
return CompositesIndex.getIndexComparator(baseMetadata, cdef);
case CUSTOM:
return null;
}
throw new AssertionError();
} | java | public static CellNameType getIndexComparator(CFMetaData baseMetadata, ColumnDefinition cdef)
{
switch (cdef.getIndexType())
{
case KEYS:
return new SimpleDenseCellNameType(keyComparator);
case COMPOSITES:
return CompositesIndex.getIndexComparator(baseMetadata, cdef);
case CUSTOM:
return null;
}
throw new AssertionError();
} | [
"public",
"static",
"CellNameType",
"getIndexComparator",
"(",
"CFMetaData",
"baseMetadata",
",",
"ColumnDefinition",
"cdef",
")",
"{",
"switch",
"(",
"cdef",
".",
"getIndexType",
"(",
")",
")",
"{",
"case",
"KEYS",
":",
"return",
"new",
"SimpleDenseCellNameType",
"(",
"keyComparator",
")",
";",
"case",
"COMPOSITES",
":",
"return",
"CompositesIndex",
".",
"getIndexComparator",
"(",
"baseMetadata",
",",
"cdef",
")",
";",
"case",
"CUSTOM",
":",
"return",
"null",
";",
"}",
"throw",
"new",
"AssertionError",
"(",
")",
";",
"}"
] | Returns the index comparator for index backed by CFS, or null.
Note: it would be cleaner to have this be a member method. However we need this when opening indexes
sstables, but by then the CFS won't be fully initiated, so the SecondaryIndex object won't be accessible. | [
"Returns",
"the",
"index",
"comparator",
"for",
"index",
"backed",
"by",
"CFS",
"or",
"null",
"."
] | train | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/index/SecondaryIndex.java#L368-L380 |
facebookarchive/hadoop-20 | src/hdfs/org/apache/hadoop/hdfs/server/datanode/DatanodeBlockInfo.java | DatanodeBlockInfo.detachFile | private void detachFile(int namespaceId, File file, Block b) throws IOException {
"""
Copy specified file into a temporary file. Then rename the
temporary file to the original name. This will cause any
hardlinks to the original file to be removed. The temporary
files are created in the detachDir. The temporary files will
be recovered (especially on Windows) on datanode restart.
"""
File tmpFile = blockDataFile.volume.createDetachFile(namespaceId, b, file.getName());
try {
IOUtils.copyBytes(new FileInputStream(file),
new FileOutputStream(tmpFile),
16*1024, true);
if (file.length() != tmpFile.length()) {
throw new IOException("Copy of file " + file + " size " + file.length()+
" into file " + tmpFile +
" resulted in a size of " + tmpFile.length());
}
FileUtil.replaceFile(tmpFile, file);
} catch (IOException e) {
boolean done = tmpFile.delete();
if (!done) {
DataNode.LOG.info("detachFile failed to delete temporary file " +
tmpFile);
}
throw e;
}
} | java | private void detachFile(int namespaceId, File file, Block b) throws IOException {
File tmpFile = blockDataFile.volume.createDetachFile(namespaceId, b, file.getName());
try {
IOUtils.copyBytes(new FileInputStream(file),
new FileOutputStream(tmpFile),
16*1024, true);
if (file.length() != tmpFile.length()) {
throw new IOException("Copy of file " + file + " size " + file.length()+
" into file " + tmpFile +
" resulted in a size of " + tmpFile.length());
}
FileUtil.replaceFile(tmpFile, file);
} catch (IOException e) {
boolean done = tmpFile.delete();
if (!done) {
DataNode.LOG.info("detachFile failed to delete temporary file " +
tmpFile);
}
throw e;
}
} | [
"private",
"void",
"detachFile",
"(",
"int",
"namespaceId",
",",
"File",
"file",
",",
"Block",
"b",
")",
"throws",
"IOException",
"{",
"File",
"tmpFile",
"=",
"blockDataFile",
".",
"volume",
".",
"createDetachFile",
"(",
"namespaceId",
",",
"b",
",",
"file",
".",
"getName",
"(",
")",
")",
";",
"try",
"{",
"IOUtils",
".",
"copyBytes",
"(",
"new",
"FileInputStream",
"(",
"file",
")",
",",
"new",
"FileOutputStream",
"(",
"tmpFile",
")",
",",
"16",
"*",
"1024",
",",
"true",
")",
";",
"if",
"(",
"file",
".",
"length",
"(",
")",
"!=",
"tmpFile",
".",
"length",
"(",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Copy of file \"",
"+",
"file",
"+",
"\" size \"",
"+",
"file",
".",
"length",
"(",
")",
"+",
"\" into file \"",
"+",
"tmpFile",
"+",
"\" resulted in a size of \"",
"+",
"tmpFile",
".",
"length",
"(",
")",
")",
";",
"}",
"FileUtil",
".",
"replaceFile",
"(",
"tmpFile",
",",
"file",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"boolean",
"done",
"=",
"tmpFile",
".",
"delete",
"(",
")",
";",
"if",
"(",
"!",
"done",
")",
"{",
"DataNode",
".",
"LOG",
".",
"info",
"(",
"\"detachFile failed to delete temporary file \"",
"+",
"tmpFile",
")",
";",
"}",
"throw",
"e",
";",
"}",
"}"
] | Copy specified file into a temporary file. Then rename the
temporary file to the original name. This will cause any
hardlinks to the original file to be removed. The temporary
files are created in the detachDir. The temporary files will
be recovered (especially on Windows) on datanode restart. | [
"Copy",
"specified",
"file",
"into",
"a",
"temporary",
"file",
".",
"Then",
"rename",
"the",
"temporary",
"file",
"to",
"the",
"original",
"name",
".",
"This",
"will",
"cause",
"any",
"hardlinks",
"to",
"the",
"original",
"file",
"to",
"be",
"removed",
".",
"The",
"temporary",
"files",
"are",
"created",
"in",
"the",
"detachDir",
".",
"The",
"temporary",
"files",
"will",
"be",
"recovered",
"(",
"especially",
"on",
"Windows",
")",
"on",
"datanode",
"restart",
"."
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DatanodeBlockInfo.java#L186-L206 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/dom3/LSSerializerImpl.java | LSSerializerImpl.getPathWithoutEscapes | private static String getPathWithoutEscapes(String origPath) {
"""
Replaces all escape sequences in the given path with their literal characters.
"""
if (origPath != null && origPath.length() != 0 && origPath.indexOf('%') != -1) {
// Locate the escape characters
StringTokenizer tokenizer = new StringTokenizer(origPath, "%");
StringBuffer result = new StringBuffer(origPath.length());
int size = tokenizer.countTokens();
result.append(tokenizer.nextToken());
for(int i = 1; i < size; ++i) {
String token = tokenizer.nextToken();
if (token.length() >= 2 && isHexDigit(token.charAt(0)) &&
isHexDigit(token.charAt(1))) {
// Decode the 2 digit hexadecimal number following % in '%nn'
result.append((char)Integer.valueOf(token.substring(0, 2), 16).intValue());
token = token.substring(2);
}
result.append(token);
}
return result.toString();
}
return origPath;
} | java | private static String getPathWithoutEscapes(String origPath) {
if (origPath != null && origPath.length() != 0 && origPath.indexOf('%') != -1) {
// Locate the escape characters
StringTokenizer tokenizer = new StringTokenizer(origPath, "%");
StringBuffer result = new StringBuffer(origPath.length());
int size = tokenizer.countTokens();
result.append(tokenizer.nextToken());
for(int i = 1; i < size; ++i) {
String token = tokenizer.nextToken();
if (token.length() >= 2 && isHexDigit(token.charAt(0)) &&
isHexDigit(token.charAt(1))) {
// Decode the 2 digit hexadecimal number following % in '%nn'
result.append((char)Integer.valueOf(token.substring(0, 2), 16).intValue());
token = token.substring(2);
}
result.append(token);
}
return result.toString();
}
return origPath;
} | [
"private",
"static",
"String",
"getPathWithoutEscapes",
"(",
"String",
"origPath",
")",
"{",
"if",
"(",
"origPath",
"!=",
"null",
"&&",
"origPath",
".",
"length",
"(",
")",
"!=",
"0",
"&&",
"origPath",
".",
"indexOf",
"(",
"'",
"'",
")",
"!=",
"-",
"1",
")",
"{",
"// Locate the escape characters",
"StringTokenizer",
"tokenizer",
"=",
"new",
"StringTokenizer",
"(",
"origPath",
",",
"\"%\"",
")",
";",
"StringBuffer",
"result",
"=",
"new",
"StringBuffer",
"(",
"origPath",
".",
"length",
"(",
")",
")",
";",
"int",
"size",
"=",
"tokenizer",
".",
"countTokens",
"(",
")",
";",
"result",
".",
"append",
"(",
"tokenizer",
".",
"nextToken",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"size",
";",
"++",
"i",
")",
"{",
"String",
"token",
"=",
"tokenizer",
".",
"nextToken",
"(",
")",
";",
"if",
"(",
"token",
".",
"length",
"(",
")",
">=",
"2",
"&&",
"isHexDigit",
"(",
"token",
".",
"charAt",
"(",
"0",
")",
")",
"&&",
"isHexDigit",
"(",
"token",
".",
"charAt",
"(",
"1",
")",
")",
")",
"{",
"// Decode the 2 digit hexadecimal number following % in '%nn'",
"result",
".",
"append",
"(",
"(",
"char",
")",
"Integer",
".",
"valueOf",
"(",
"token",
".",
"substring",
"(",
"0",
",",
"2",
")",
",",
"16",
")",
".",
"intValue",
"(",
")",
")",
";",
"token",
"=",
"token",
".",
"substring",
"(",
"2",
")",
";",
"}",
"result",
".",
"append",
"(",
"token",
")",
";",
"}",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}",
"return",
"origPath",
";",
"}"
] | Replaces all escape sequences in the given path with their literal characters. | [
"Replaces",
"all",
"escape",
"sequences",
"in",
"the",
"given",
"path",
"with",
"their",
"literal",
"characters",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/dom3/LSSerializerImpl.java#L1464-L1484 |
DiUS/pact-jvm | pact-jvm-consumer/src/main/java/au/com/dius/pact/consumer/dsl/PactDslRequestWithoutPath.java | PactDslRequestWithoutPath.headerFromProviderState | public PactDslRequestWithoutPath headerFromProviderState(String name, String expression, String example) {
"""
Adds a header that will have it's value injected from the provider state
@param name Header Name
@param expression Expression to be evaluated from the provider state
@param example Example value to use in the consumer test
"""
requestGenerators.addGenerator(Category.HEADER, name, new ProviderStateGenerator(expression));
requestHeaders.put(name, Collections.singletonList(example));
return this;
} | java | public PactDslRequestWithoutPath headerFromProviderState(String name, String expression, String example) {
requestGenerators.addGenerator(Category.HEADER, name, new ProviderStateGenerator(expression));
requestHeaders.put(name, Collections.singletonList(example));
return this;
} | [
"public",
"PactDslRequestWithoutPath",
"headerFromProviderState",
"(",
"String",
"name",
",",
"String",
"expression",
",",
"String",
"example",
")",
"{",
"requestGenerators",
".",
"addGenerator",
"(",
"Category",
".",
"HEADER",
",",
"name",
",",
"new",
"ProviderStateGenerator",
"(",
"expression",
")",
")",
";",
"requestHeaders",
".",
"put",
"(",
"name",
",",
"Collections",
".",
"singletonList",
"(",
"example",
")",
")",
";",
"return",
"this",
";",
"}"
] | Adds a header that will have it's value injected from the provider state
@param name Header Name
@param expression Expression to be evaluated from the provider state
@param example Example value to use in the consumer test | [
"Adds",
"a",
"header",
"that",
"will",
"have",
"it",
"s",
"value",
"injected",
"from",
"the",
"provider",
"state"
] | train | https://github.com/DiUS/pact-jvm/blob/2f447e9dd4ac152a6a36b7fcf8962d07de9ef3ef/pact-jvm-consumer/src/main/java/au/com/dius/pact/consumer/dsl/PactDslRequestWithoutPath.java#L296-L300 |
Stratio/cassandra-lucene-index | plugin/src/main/java/com/stratio/cassandra/lucene/common/JsonSerializer.java | JsonSerializer.fromString | public static <T> T fromString(String value, Class<T> valueType) throws IOException {
"""
Returns the object of the specified class represented by the specified JSON {@code String}.
@param value the JSON {@code String} to be parsed
@param valueType the class of the object to be parsed
@param <T> the type of the object to be parsed
@return an object of the specified class represented by {@code value}
@throws IOException if there are parsing problems
"""
return INSTANCE.mapper.readValue(value, valueType);
} | java | public static <T> T fromString(String value, Class<T> valueType) throws IOException {
return INSTANCE.mapper.readValue(value, valueType);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"fromString",
"(",
"String",
"value",
",",
"Class",
"<",
"T",
">",
"valueType",
")",
"throws",
"IOException",
"{",
"return",
"INSTANCE",
".",
"mapper",
".",
"readValue",
"(",
"value",
",",
"valueType",
")",
";",
"}"
] | Returns the object of the specified class represented by the specified JSON {@code String}.
@param value the JSON {@code String} to be parsed
@param valueType the class of the object to be parsed
@param <T> the type of the object to be parsed
@return an object of the specified class represented by {@code value}
@throws IOException if there are parsing problems | [
"Returns",
"the",
"object",
"of",
"the",
"specified",
"class",
"represented",
"by",
"the",
"specified",
"JSON",
"{",
"@code",
"String",
"}",
"."
] | train | https://github.com/Stratio/cassandra-lucene-index/blob/a94a4d9af6c25d40e1108729974c35c27c54441c/plugin/src/main/java/com/stratio/cassandra/lucene/common/JsonSerializer.java#L69-L71 |
m-m-m/util | scanner/src/main/java/net/sf/mmm/util/scanner/base/CharSequenceScanner.java | CharSequenceScanner.appendSubstring | public void appendSubstring(StringBuilder appendable, int start, int end) {
"""
This method appends the {@link #substring(int, int) substring} specified by {@code start} and {@code end}
to the given {@code buffer}. <br>
This avoids the overhead of creating a new string and copying the char array.
@param appendable is the buffer where to append the substring to.
@param start the start index, inclusive.
@param end the end index, exclusive.
@since 7.5.0
"""
appendable.append(this.buffer, this.initialOffset + start, end - start);
} | java | public void appendSubstring(StringBuilder appendable, int start, int end) {
appendable.append(this.buffer, this.initialOffset + start, end - start);
} | [
"public",
"void",
"appendSubstring",
"(",
"StringBuilder",
"appendable",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"appendable",
".",
"append",
"(",
"this",
".",
"buffer",
",",
"this",
".",
"initialOffset",
"+",
"start",
",",
"end",
"-",
"start",
")",
";",
"}"
] | This method appends the {@link #substring(int, int) substring} specified by {@code start} and {@code end}
to the given {@code buffer}. <br>
This avoids the overhead of creating a new string and copying the char array.
@param appendable is the buffer where to append the substring to.
@param start the start index, inclusive.
@param end the end index, exclusive.
@since 7.5.0 | [
"This",
"method",
"appends",
"the",
"{",
"@link",
"#substring",
"(",
"int",
"int",
")",
"substring",
"}",
"specified",
"by",
"{",
"@code",
"start",
"}",
"and",
"{",
"@code",
"end",
"}",
"to",
"the",
"given",
"{",
"@code",
"buffer",
"}",
".",
"<br",
">",
"This",
"avoids",
"the",
"overhead",
"of",
"creating",
"a",
"new",
"string",
"and",
"copying",
"the",
"char",
"array",
"."
] | train | https://github.com/m-m-m/util/blob/f0e4e084448f8dfc83ca682a9e1618034a094ce6/scanner/src/main/java/net/sf/mmm/util/scanner/base/CharSequenceScanner.java#L161-L164 |
samskivert/samskivert | src/main/java/com/samskivert/util/Invoker.java | Invoker.didInvokeUnit | protected void didInvokeUnit (Unit unit, long start) {
"""
Called before we process an invoker unit.
@param unit the unit about to be invoked.
@param start a timestamp recorded immediately before invocation if {@link #PERF_TRACK} is
enabled, 0L otherwise.
"""
// track some performance metrics
if (PERF_TRACK) {
long duration = System.currentTimeMillis() - start;
Object key = unit.getClass();
recordMetrics(key, duration);
// report long runners
long thresh = unit.getLongThreshold();
if (thresh == 0) {
thresh = _longThreshold;
}
if (duration > thresh) {
StringBuilder msg = new StringBuilder();
msg.append((duration >= 10*thresh) ? "Really long" : "Long");
msg.append(" invoker unit [unit=").append(unit);
msg.append(" (").append(key).append("), time=").append(duration).append("ms");
if (unit.getDetail() != null) {
msg.append(", detail=").append(unit.getDetail());
}
log.warning(msg.append("].").toString());
}
}
} | java | protected void didInvokeUnit (Unit unit, long start)
{
// track some performance metrics
if (PERF_TRACK) {
long duration = System.currentTimeMillis() - start;
Object key = unit.getClass();
recordMetrics(key, duration);
// report long runners
long thresh = unit.getLongThreshold();
if (thresh == 0) {
thresh = _longThreshold;
}
if (duration > thresh) {
StringBuilder msg = new StringBuilder();
msg.append((duration >= 10*thresh) ? "Really long" : "Long");
msg.append(" invoker unit [unit=").append(unit);
msg.append(" (").append(key).append("), time=").append(duration).append("ms");
if (unit.getDetail() != null) {
msg.append(", detail=").append(unit.getDetail());
}
log.warning(msg.append("].").toString());
}
}
} | [
"protected",
"void",
"didInvokeUnit",
"(",
"Unit",
"unit",
",",
"long",
"start",
")",
"{",
"// track some performance metrics",
"if",
"(",
"PERF_TRACK",
")",
"{",
"long",
"duration",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"start",
";",
"Object",
"key",
"=",
"unit",
".",
"getClass",
"(",
")",
";",
"recordMetrics",
"(",
"key",
",",
"duration",
")",
";",
"// report long runners",
"long",
"thresh",
"=",
"unit",
".",
"getLongThreshold",
"(",
")",
";",
"if",
"(",
"thresh",
"==",
"0",
")",
"{",
"thresh",
"=",
"_longThreshold",
";",
"}",
"if",
"(",
"duration",
">",
"thresh",
")",
"{",
"StringBuilder",
"msg",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"msg",
".",
"append",
"(",
"(",
"duration",
">=",
"10",
"*",
"thresh",
")",
"?",
"\"Really long\"",
":",
"\"Long\"",
")",
";",
"msg",
".",
"append",
"(",
"\" invoker unit [unit=\"",
")",
".",
"append",
"(",
"unit",
")",
";",
"msg",
".",
"append",
"(",
"\" (\"",
")",
".",
"append",
"(",
"key",
")",
".",
"append",
"(",
"\"), time=\"",
")",
".",
"append",
"(",
"duration",
")",
".",
"append",
"(",
"\"ms\"",
")",
";",
"if",
"(",
"unit",
".",
"getDetail",
"(",
")",
"!=",
"null",
")",
"{",
"msg",
".",
"append",
"(",
"\", detail=\"",
")",
".",
"append",
"(",
"unit",
".",
"getDetail",
"(",
")",
")",
";",
"}",
"log",
".",
"warning",
"(",
"msg",
".",
"append",
"(",
"\"].\"",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Called before we process an invoker unit.
@param unit the unit about to be invoked.
@param start a timestamp recorded immediately before invocation if {@link #PERF_TRACK} is
enabled, 0L otherwise. | [
"Called",
"before",
"we",
"process",
"an",
"invoker",
"unit",
"."
] | train | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Invoker.java#L276-L300 |
NoraUi/NoraUi | src/main/java/com/github/noraui/application/steps/CommonSteps.java | CommonSteps.updateDate | @Conditioned
@Quand("Je mets à jour la date '(.*)-(.*)' avec une '(.*)' date '(.*)'[\\.|\\?]")
@When("I update date '(.*)-(.*)' with a '(.*)' date '(.*)'[\\.|\\?]")
public void updateDate(String page, String elementName, String dateType, String dateOrKey, List<GherkinStepCondition> conditions) throws TechnicalException, FailureException {
"""
Update a html input text with a date.
@param page
The concerned page of elementName
@param elementName
is target element
@param dateOrKey
Is the new date (date or date in context (after a save))
@param dateType
'future', 'future_strict', 'today' or 'any'
@param conditions
list of 'expected' values condition and 'actual' values ({@link com.github.noraui.gherkin.GherkinStepCondition}).
@throws TechnicalException
is throws if you have a technical error (format, configuration, datas, ...) in NoraUi.
Exception with a message (no screenshot, no exception)
@throws FailureException
if the scenario encounters a functional error
"""
final String date = Context.getValue(dateOrKey) != null ? Context.getValue(dateOrKey) : dateOrKey;
if (!"".equals(date)) {
final PageElement pageElement = Page.getInstance(page).getPageElementByKey('-' + elementName);
if (date.matches(Constants.DATE_FORMAT_REG_EXP)) {
updateDateValidated(pageElement, dateType, date);
} else {
new Result.Failure<>(date, Messages.format(Messages.getMessage(Messages.FAIL_MESSAGE_WRONG_DATE_FORMAT), date, elementName), false, pageElement.getPage().getCallBack());
}
}
} | java | @Conditioned
@Quand("Je mets à jour la date '(.*)-(.*)' avec une '(.*)' date '(.*)'[\\.|\\?]")
@When("I update date '(.*)-(.*)' with a '(.*)' date '(.*)'[\\.|\\?]")
public void updateDate(String page, String elementName, String dateType, String dateOrKey, List<GherkinStepCondition> conditions) throws TechnicalException, FailureException {
final String date = Context.getValue(dateOrKey) != null ? Context.getValue(dateOrKey) : dateOrKey;
if (!"".equals(date)) {
final PageElement pageElement = Page.getInstance(page).getPageElementByKey('-' + elementName);
if (date.matches(Constants.DATE_FORMAT_REG_EXP)) {
updateDateValidated(pageElement, dateType, date);
} else {
new Result.Failure<>(date, Messages.format(Messages.getMessage(Messages.FAIL_MESSAGE_WRONG_DATE_FORMAT), date, elementName), false, pageElement.getPage().getCallBack());
}
}
} | [
"@",
"Conditioned",
"@",
"Quand",
"(",
"\"Je mets à jour la date '(.*)-(.*)' avec une '(.*)' date '(.*)'[\\\\.|\\\\?]\")",
"\r",
"@",
"When",
"(",
"\"I update date '(.*)-(.*)' with a '(.*)' date '(.*)'[\\\\.|\\\\?]\"",
")",
"public",
"void",
"updateDate",
"(",
"String",
"page",
",",
"String",
"elementName",
",",
"String",
"dateType",
",",
"String",
"dateOrKey",
",",
"List",
"<",
"GherkinStepCondition",
">",
"conditions",
")",
"throws",
"TechnicalException",
",",
"FailureException",
"{",
"final",
"String",
"date",
"=",
"Context",
".",
"getValue",
"(",
"dateOrKey",
")",
"!=",
"null",
"?",
"Context",
".",
"getValue",
"(",
"dateOrKey",
")",
":",
"dateOrKey",
";",
"if",
"(",
"!",
"\"\"",
".",
"equals",
"(",
"date",
")",
")",
"{",
"final",
"PageElement",
"pageElement",
"=",
"Page",
".",
"getInstance",
"(",
"page",
")",
".",
"getPageElementByKey",
"(",
"'",
"'",
"+",
"elementName",
")",
";",
"if",
"(",
"date",
".",
"matches",
"(",
"Constants",
".",
"DATE_FORMAT_REG_EXP",
")",
")",
"{",
"updateDateValidated",
"(",
"pageElement",
",",
"dateType",
",",
"date",
")",
";",
"}",
"else",
"{",
"new",
"Result",
".",
"Failure",
"<>",
"(",
"date",
",",
"Messages",
".",
"format",
"(",
"Messages",
".",
"getMessage",
"(",
"Messages",
".",
"FAIL_MESSAGE_WRONG_DATE_FORMAT",
")",
",",
"date",
",",
"elementName",
")",
",",
"false",
",",
"pageElement",
".",
"getPage",
"(",
")",
".",
"getCallBack",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Update a html input text with a date.
@param page
The concerned page of elementName
@param elementName
is target element
@param dateOrKey
Is the new date (date or date in context (after a save))
@param dateType
'future', 'future_strict', 'today' or 'any'
@param conditions
list of 'expected' values condition and 'actual' values ({@link com.github.noraui.gherkin.GherkinStepCondition}).
@throws TechnicalException
is throws if you have a technical error (format, configuration, datas, ...) in NoraUi.
Exception with a message (no screenshot, no exception)
@throws FailureException
if the scenario encounters a functional error | [
"Update",
"a",
"html",
"input",
"text",
"with",
"a",
"date",
"."
] | train | https://github.com/NoraUi/NoraUi/blob/5f491a3339c7d3c20d7207760bdaf2acdb8f260c/src/main/java/com/github/noraui/application/steps/CommonSteps.java#L526-L539 |
rhuss/jolokia | agent/jvm/src/main/java/org/jolokia/jvmagent/client/util/ToolsClassFinder.java | ToolsClassFinder.createClassLoader | private static ClassLoader createClassLoader(File toolsJar) throws MalformedURLException {
"""
Create a classloader and respect a security manager if installed
"""
final URL urls[] = new URL[] {toolsJar.toURI().toURL() };
if (System.getSecurityManager() == null) {
return new URLClassLoader(urls, getParentClassLoader());
} else {
return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
/** {@inheritDoc} */
public ClassLoader run() {
return new URLClassLoader(urls, getParentClassLoader());
}
});
}
} | java | private static ClassLoader createClassLoader(File toolsJar) throws MalformedURLException {
final URL urls[] = new URL[] {toolsJar.toURI().toURL() };
if (System.getSecurityManager() == null) {
return new URLClassLoader(urls, getParentClassLoader());
} else {
return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
/** {@inheritDoc} */
public ClassLoader run() {
return new URLClassLoader(urls, getParentClassLoader());
}
});
}
} | [
"private",
"static",
"ClassLoader",
"createClassLoader",
"(",
"File",
"toolsJar",
")",
"throws",
"MalformedURLException",
"{",
"final",
"URL",
"urls",
"[",
"]",
"=",
"new",
"URL",
"[",
"]",
"{",
"toolsJar",
".",
"toURI",
"(",
")",
".",
"toURL",
"(",
")",
"}",
";",
"if",
"(",
"System",
".",
"getSecurityManager",
"(",
")",
"==",
"null",
")",
"{",
"return",
"new",
"URLClassLoader",
"(",
"urls",
",",
"getParentClassLoader",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"AccessController",
".",
"doPrivileged",
"(",
"new",
"PrivilegedAction",
"<",
"ClassLoader",
">",
"(",
")",
"{",
"/** {@inheritDoc} */",
"public",
"ClassLoader",
"run",
"(",
")",
"{",
"return",
"new",
"URLClassLoader",
"(",
"urls",
",",
"getParentClassLoader",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"}",
"}"
] | Create a classloader and respect a security manager if installed | [
"Create",
"a",
"classloader",
"and",
"respect",
"a",
"security",
"manager",
"if",
"installed"
] | train | https://github.com/rhuss/jolokia/blob/dc95e7bef859b1829776c5a84c8f7738f5d7d9c3/agent/jvm/src/main/java/org/jolokia/jvmagent/client/util/ToolsClassFinder.java#L99-L111 |
jhunters/jprotobuf | src/main/java/com/baidu/bjf/remoting/protobuf/utils/MiniTemplator.java | MiniTemplator.setVariable | public void setVariable(String variableName, String variableValue) throws VariableNotDefinedException {
"""
Sets a template variable.
<p>
Convenience method for: <code>setVariable (variableName, variableValue, false)</code>
@param variableName the name of the variable to be set. Case-insensitive.
@param variableValue the new value of the variable. May be <code>null</code>.
@throws VariableNotDefinedException when no variable with the specified name exists in the template.
@see #setVariable(String, String, boolean)
"""
setVariable(variableName, variableValue, false);
} | java | public void setVariable(String variableName, String variableValue) throws VariableNotDefinedException {
setVariable(variableName, variableValue, false);
} | [
"public",
"void",
"setVariable",
"(",
"String",
"variableName",
",",
"String",
"variableValue",
")",
"throws",
"VariableNotDefinedException",
"{",
"setVariable",
"(",
"variableName",
",",
"variableValue",
",",
"false",
")",
";",
"}"
] | Sets a template variable.
<p>
Convenience method for: <code>setVariable (variableName, variableValue, false)</code>
@param variableName the name of the variable to be set. Case-insensitive.
@param variableValue the new value of the variable. May be <code>null</code>.
@throws VariableNotDefinedException when no variable with the specified name exists in the template.
@see #setVariable(String, String, boolean) | [
"Sets",
"a",
"template",
"variable",
".",
"<p",
">",
"Convenience",
"method",
"for",
":",
"<code",
">",
"setVariable",
"(",
"variableName",
"variableValue",
"false",
")",
"<",
"/",
"code",
">"
] | train | https://github.com/jhunters/jprotobuf/blob/55832c9b4792afb128e5b35139d8a3891561d8a3/src/main/java/com/baidu/bjf/remoting/protobuf/utils/MiniTemplator.java#L387-L389 |
rundeck/rundeck | core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/Validator.java | Validator.errorReport | public static Report errorReport(String key, String message) {
"""
Return a report for a single error item
@param key key
@param message message
@return report
"""
return buildReport().error(key, message).build();
} | java | public static Report errorReport(String key, String message) {
return buildReport().error(key, message).build();
} | [
"public",
"static",
"Report",
"errorReport",
"(",
"String",
"key",
",",
"String",
"message",
")",
"{",
"return",
"buildReport",
"(",
")",
".",
"error",
"(",
"key",
",",
"message",
")",
".",
"build",
"(",
")",
";",
"}"
] | Return a report for a single error item
@param key key
@param message message
@return report | [
"Return",
"a",
"report",
"for",
"a",
"single",
"error",
"item"
] | train | https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/Validator.java#L41-L43 |
alkacon/opencms-core | src/org/opencms/acacia/shared/CmsEntity.java | CmsEntity.setAttributeValue | public void setAttributeValue(String attributeName, CmsEntity value) {
"""
Sets the given attribute value. Will remove all previous attribute values.<p>
@param attributeName the attribute name
@param value the attribute value
"""
// make sure there is no attribute value set
removeAttributeSilent(attributeName);
addAttributeValue(attributeName, value);
} | java | public void setAttributeValue(String attributeName, CmsEntity value) {
// make sure there is no attribute value set
removeAttributeSilent(attributeName);
addAttributeValue(attributeName, value);
} | [
"public",
"void",
"setAttributeValue",
"(",
"String",
"attributeName",
",",
"CmsEntity",
"value",
")",
"{",
"// make sure there is no attribute value set\r",
"removeAttributeSilent",
"(",
"attributeName",
")",
";",
"addAttributeValue",
"(",
"attributeName",
",",
"value",
")",
";",
"}"
] | Sets the given attribute value. Will remove all previous attribute values.<p>
@param attributeName the attribute name
@param value the attribute value | [
"Sets",
"the",
"given",
"attribute",
"value",
".",
"Will",
"remove",
"all",
"previous",
"attribute",
"values",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/acacia/shared/CmsEntity.java#L583-L588 |
wisdom-framework/wisdom-orientdb | wisdom-orientdb-manager/src/main/java/org/wisdom/orientdb/conf/WOrientConf.java | WOrientConf.createFromApplicationConf | public static Collection<WOrientConf> createFromApplicationConf(Configuration config, String prefix) {
"""
Extract all WOrientConf configuration with the given prefix from the parent wisdom configuration.
If the prefix is <code>"orientdb"</code> and the configuration is: <br/>
<code>
orientdb.default.url = "plocal:/home/wisdom/db"
orientdb.test.url = "plocal:/home/wisdom/test/db"
</code>
<p/>
the sub configuration will be:
<p/>
<code>
[alias:default]
url = "plocal:/home/wisdom/db"
[alias:test]
url = "plocal:/home/wisdom/test/db"
</code>
@param config The wisdom configuration
@param prefix The prefix of the wisdom-orientdb configuration.
@return A Collection of WOrientConf retrieve from the Wisdom configuration file, or an empty set if there is no configuration under the given prefix.
"""
Configuration orient = config.getConfiguration(prefix);
if(orient == null){
return Collections.EMPTY_SET;
}
Set<String> subkeys = new HashSet<>();
for (String key : orient.asMap().keySet()) {
subkeys.add(key);
}
Collection<WOrientConf> subconfs = new ArrayList<>(subkeys.size());
for (String subkey : subkeys) {
subconfs.add(new WOrientConf(subkey, orient.getConfiguration(subkey)));
}
return subconfs;
} | java | public static Collection<WOrientConf> createFromApplicationConf(Configuration config, String prefix) {
Configuration orient = config.getConfiguration(prefix);
if(orient == null){
return Collections.EMPTY_SET;
}
Set<String> subkeys = new HashSet<>();
for (String key : orient.asMap().keySet()) {
subkeys.add(key);
}
Collection<WOrientConf> subconfs = new ArrayList<>(subkeys.size());
for (String subkey : subkeys) {
subconfs.add(new WOrientConf(subkey, orient.getConfiguration(subkey)));
}
return subconfs;
} | [
"public",
"static",
"Collection",
"<",
"WOrientConf",
">",
"createFromApplicationConf",
"(",
"Configuration",
"config",
",",
"String",
"prefix",
")",
"{",
"Configuration",
"orient",
"=",
"config",
".",
"getConfiguration",
"(",
"prefix",
")",
";",
"if",
"(",
"orient",
"==",
"null",
")",
"{",
"return",
"Collections",
".",
"EMPTY_SET",
";",
"}",
"Set",
"<",
"String",
">",
"subkeys",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"for",
"(",
"String",
"key",
":",
"orient",
".",
"asMap",
"(",
")",
".",
"keySet",
"(",
")",
")",
"{",
"subkeys",
".",
"add",
"(",
"key",
")",
";",
"}",
"Collection",
"<",
"WOrientConf",
">",
"subconfs",
"=",
"new",
"ArrayList",
"<>",
"(",
"subkeys",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"String",
"subkey",
":",
"subkeys",
")",
"{",
"subconfs",
".",
"add",
"(",
"new",
"WOrientConf",
"(",
"subkey",
",",
"orient",
".",
"getConfiguration",
"(",
"subkey",
")",
")",
")",
";",
"}",
"return",
"subconfs",
";",
"}"
] | Extract all WOrientConf configuration with the given prefix from the parent wisdom configuration.
If the prefix is <code>"orientdb"</code> and the configuration is: <br/>
<code>
orientdb.default.url = "plocal:/home/wisdom/db"
orientdb.test.url = "plocal:/home/wisdom/test/db"
</code>
<p/>
the sub configuration will be:
<p/>
<code>
[alias:default]
url = "plocal:/home/wisdom/db"
[alias:test]
url = "plocal:/home/wisdom/test/db"
</code>
@param config The wisdom configuration
@param prefix The prefix of the wisdom-orientdb configuration.
@return A Collection of WOrientConf retrieve from the Wisdom configuration file, or an empty set if there is no configuration under the given prefix. | [
"Extract",
"all",
"WOrientConf",
"configuration",
"with",
"the",
"given",
"prefix",
"from",
"the",
"parent",
"wisdom",
"configuration",
".",
"If",
"the",
"prefix",
"is",
"<code",
">",
"orientdb",
"<",
"/",
"code",
">",
"and",
"the",
"configuration",
"is",
":",
"<br",
"/",
">",
"<code",
">",
"orientdb",
".",
"default",
".",
"url",
"=",
"plocal",
":",
"/",
"home",
"/",
"wisdom",
"/",
"db",
"orientdb",
".",
"test",
".",
"url",
"=",
"plocal",
":",
"/",
"home",
"/",
"wisdom",
"/",
"test",
"/",
"db",
"<",
"/",
"code",
">",
"<p",
"/",
">",
"the",
"sub",
"configuration",
"will",
"be",
":",
"<p",
"/",
">",
"<code",
">",
"[",
"alias",
":",
"default",
"]",
"url",
"=",
"plocal",
":",
"/",
"home",
"/",
"wisdom",
"/",
"db",
"[",
"alias",
":",
"test",
"]",
"url",
"=",
"plocal",
":",
"/",
"home",
"/",
"wisdom",
"/",
"test",
"/",
"db",
"<",
"/",
"code",
">"
] | train | https://github.com/wisdom-framework/wisdom-orientdb/blob/fd172fc19f03ca151d81a4f9cf0ad38cb8411852/wisdom-orientdb-manager/src/main/java/org/wisdom/orientdb/conf/WOrientConf.java#L160-L180 |
netty/netty | resolver-dns/src/main/java/io/netty/resolver/dns/DnsAddressDecoder.java | DnsAddressDecoder.decodeAddress | static InetAddress decodeAddress(DnsRecord record, String name, boolean decodeIdn) {
"""
Decodes an {@link InetAddress} from an A or AAAA {@link DnsRawRecord}.
@param record the {@link DnsRecord}, most likely a {@link DnsRawRecord}
@param name the host name of the decoded address
@param decodeIdn whether to convert {@code name} to a unicode host name
@return the {@link InetAddress}, or {@code null} if {@code record} is not a {@link DnsRawRecord} or
its content is malformed
"""
if (!(record instanceof DnsRawRecord)) {
return null;
}
final ByteBuf content = ((ByteBufHolder) record).content();
final int contentLen = content.readableBytes();
if (contentLen != INADDRSZ4 && contentLen != INADDRSZ6) {
return null;
}
final byte[] addrBytes = new byte[contentLen];
content.getBytes(content.readerIndex(), addrBytes);
try {
return InetAddress.getByAddress(decodeIdn ? IDN.toUnicode(name) : name, addrBytes);
} catch (UnknownHostException e) {
// Should never reach here.
throw new Error(e);
}
} | java | static InetAddress decodeAddress(DnsRecord record, String name, boolean decodeIdn) {
if (!(record instanceof DnsRawRecord)) {
return null;
}
final ByteBuf content = ((ByteBufHolder) record).content();
final int contentLen = content.readableBytes();
if (contentLen != INADDRSZ4 && contentLen != INADDRSZ6) {
return null;
}
final byte[] addrBytes = new byte[contentLen];
content.getBytes(content.readerIndex(), addrBytes);
try {
return InetAddress.getByAddress(decodeIdn ? IDN.toUnicode(name) : name, addrBytes);
} catch (UnknownHostException e) {
// Should never reach here.
throw new Error(e);
}
} | [
"static",
"InetAddress",
"decodeAddress",
"(",
"DnsRecord",
"record",
",",
"String",
"name",
",",
"boolean",
"decodeIdn",
")",
"{",
"if",
"(",
"!",
"(",
"record",
"instanceof",
"DnsRawRecord",
")",
")",
"{",
"return",
"null",
";",
"}",
"final",
"ByteBuf",
"content",
"=",
"(",
"(",
"ByteBufHolder",
")",
"record",
")",
".",
"content",
"(",
")",
";",
"final",
"int",
"contentLen",
"=",
"content",
".",
"readableBytes",
"(",
")",
";",
"if",
"(",
"contentLen",
"!=",
"INADDRSZ4",
"&&",
"contentLen",
"!=",
"INADDRSZ6",
")",
"{",
"return",
"null",
";",
"}",
"final",
"byte",
"[",
"]",
"addrBytes",
"=",
"new",
"byte",
"[",
"contentLen",
"]",
";",
"content",
".",
"getBytes",
"(",
"content",
".",
"readerIndex",
"(",
")",
",",
"addrBytes",
")",
";",
"try",
"{",
"return",
"InetAddress",
".",
"getByAddress",
"(",
"decodeIdn",
"?",
"IDN",
".",
"toUnicode",
"(",
"name",
")",
":",
"name",
",",
"addrBytes",
")",
";",
"}",
"catch",
"(",
"UnknownHostException",
"e",
")",
"{",
"// Should never reach here.",
"throw",
"new",
"Error",
"(",
"e",
")",
";",
"}",
"}"
] | Decodes an {@link InetAddress} from an A or AAAA {@link DnsRawRecord}.
@param record the {@link DnsRecord}, most likely a {@link DnsRawRecord}
@param name the host name of the decoded address
@param decodeIdn whether to convert {@code name} to a unicode host name
@return the {@link InetAddress}, or {@code null} if {@code record} is not a {@link DnsRawRecord} or
its content is malformed | [
"Decodes",
"an",
"{",
"@link",
"InetAddress",
"}",
"from",
"an",
"A",
"or",
"AAAA",
"{",
"@link",
"DnsRawRecord",
"}",
"."
] | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/resolver-dns/src/main/java/io/netty/resolver/dns/DnsAddressDecoder.java#L45-L64 |
google/closure-compiler | src/com/google/javascript/jscomp/AstFactory.java | AstFactory.createGetProps | Node createGetProps(Node receiver, String firstPropName, String... otherPropNames) {
"""
Creates a tree of nodes representing `receiver.name1.name2.etc`.
"""
Node result = createGetProp(receiver, firstPropName);
for (String propertyName : otherPropNames) {
result = createGetProp(result, propertyName);
}
return result;
} | java | Node createGetProps(Node receiver, String firstPropName, String... otherPropNames) {
Node result = createGetProp(receiver, firstPropName);
for (String propertyName : otherPropNames) {
result = createGetProp(result, propertyName);
}
return result;
} | [
"Node",
"createGetProps",
"(",
"Node",
"receiver",
",",
"String",
"firstPropName",
",",
"String",
"...",
"otherPropNames",
")",
"{",
"Node",
"result",
"=",
"createGetProp",
"(",
"receiver",
",",
"firstPropName",
")",
";",
"for",
"(",
"String",
"propertyName",
":",
"otherPropNames",
")",
"{",
"result",
"=",
"createGetProp",
"(",
"result",
",",
"propertyName",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Creates a tree of nodes representing `receiver.name1.name2.etc`. | [
"Creates",
"a",
"tree",
"of",
"nodes",
"representing",
"receiver",
".",
"name1",
".",
"name2",
".",
"etc",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/AstFactory.java#L416-L422 |
google/jimfs | jimfs/src/main/java/com/google/common/jimfs/FileSystemView.java | FileSystemView.lockSourceAndCopy | private void lockSourceAndCopy(File sourceFile, File copyFile) {
"""
Locks source and copy files before copying content. Also marks the source file as opened so
that its content won't be deleted until after the copy if it is deleted.
"""
sourceFile.opened();
ReadWriteLock sourceLock = sourceFile.contentLock();
if (sourceLock != null) {
sourceLock.readLock().lock();
}
ReadWriteLock copyLock = copyFile.contentLock();
if (copyLock != null) {
copyLock.writeLock().lock();
}
} | java | private void lockSourceAndCopy(File sourceFile, File copyFile) {
sourceFile.opened();
ReadWriteLock sourceLock = sourceFile.contentLock();
if (sourceLock != null) {
sourceLock.readLock().lock();
}
ReadWriteLock copyLock = copyFile.contentLock();
if (copyLock != null) {
copyLock.writeLock().lock();
}
} | [
"private",
"void",
"lockSourceAndCopy",
"(",
"File",
"sourceFile",
",",
"File",
"copyFile",
")",
"{",
"sourceFile",
".",
"opened",
"(",
")",
";",
"ReadWriteLock",
"sourceLock",
"=",
"sourceFile",
".",
"contentLock",
"(",
")",
";",
"if",
"(",
"sourceLock",
"!=",
"null",
")",
"{",
"sourceLock",
".",
"readLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"}",
"ReadWriteLock",
"copyLock",
"=",
"copyFile",
".",
"contentLock",
"(",
")",
";",
"if",
"(",
"copyLock",
"!=",
"null",
")",
"{",
"copyLock",
".",
"writeLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"}",
"}"
] | Locks source and copy files before copying content. Also marks the source file as opened so
that its content won't be deleted until after the copy if it is deleted. | [
"Locks",
"source",
"and",
"copy",
"files",
"before",
"copying",
"content",
".",
"Also",
"marks",
"the",
"source",
"file",
"as",
"opened",
"so",
"that",
"its",
"content",
"won",
"t",
"be",
"deleted",
"until",
"after",
"the",
"copy",
"if",
"it",
"is",
"deleted",
"."
] | train | https://github.com/google/jimfs/blob/3eadff747a3afa7b498030f420d2d04ce700534a/jimfs/src/main/java/com/google/common/jimfs/FileSystemView.java#L666-L676 |
orbisgis/h2gis | h2gis-utilities/src/main/java/org/h2gis/utilities/jts_utils/CoordinateUtils.java | CoordinateUtils.vectorIntersection | public static Coordinate vectorIntersection(Coordinate p1, Vector3D v1, Coordinate p2, Vector3D v2) {
"""
Compute intersection point of two vectors
@param p1 Origin point
@param v1 Direction from p1
@param p2 Origin point 2
@param v2 Direction of p2
@return Null if vectors are collinear or if intersection is done behind one of origin point
"""
double delta;
Coordinate i = null;
// Cramer's rule for compute intersection of two planes
delta = v1.getX() * (-v2.getY()) - (-v1.getY()) * v2.getX();
if (delta != 0) {
double k = ((p2.x - p1.x) * (-v2.getY()) - (p2.y - p1.y) * (-v2.getX())) / delta;
// Fix precision problem with big decimal
i = new Coordinate(p1.x + k * v1.getX(), p1.y + k * v1.getY(), p1.z + k * v1.getZ());
if(new LineSegment(p1, new Coordinate(p1.x + v1.getX(), p1.y + v1.getY())).projectionFactor(i) < 0 ||
new LineSegment(p2, new Coordinate(p2.x + v2.getX(), p2.y + v2.getY())).projectionFactor(i) < 0) {
return null;
}
}
return i;
} | java | public static Coordinate vectorIntersection(Coordinate p1, Vector3D v1, Coordinate p2, Vector3D v2) {
double delta;
Coordinate i = null;
// Cramer's rule for compute intersection of two planes
delta = v1.getX() * (-v2.getY()) - (-v1.getY()) * v2.getX();
if (delta != 0) {
double k = ((p2.x - p1.x) * (-v2.getY()) - (p2.y - p1.y) * (-v2.getX())) / delta;
// Fix precision problem with big decimal
i = new Coordinate(p1.x + k * v1.getX(), p1.y + k * v1.getY(), p1.z + k * v1.getZ());
if(new LineSegment(p1, new Coordinate(p1.x + v1.getX(), p1.y + v1.getY())).projectionFactor(i) < 0 ||
new LineSegment(p2, new Coordinate(p2.x + v2.getX(), p2.y + v2.getY())).projectionFactor(i) < 0) {
return null;
}
}
return i;
} | [
"public",
"static",
"Coordinate",
"vectorIntersection",
"(",
"Coordinate",
"p1",
",",
"Vector3D",
"v1",
",",
"Coordinate",
"p2",
",",
"Vector3D",
"v2",
")",
"{",
"double",
"delta",
";",
"Coordinate",
"i",
"=",
"null",
";",
"// Cramer's rule for compute intersection of two planes",
"delta",
"=",
"v1",
".",
"getX",
"(",
")",
"*",
"(",
"-",
"v2",
".",
"getY",
"(",
")",
")",
"-",
"(",
"-",
"v1",
".",
"getY",
"(",
")",
")",
"*",
"v2",
".",
"getX",
"(",
")",
";",
"if",
"(",
"delta",
"!=",
"0",
")",
"{",
"double",
"k",
"=",
"(",
"(",
"p2",
".",
"x",
"-",
"p1",
".",
"x",
")",
"*",
"(",
"-",
"v2",
".",
"getY",
"(",
")",
")",
"-",
"(",
"p2",
".",
"y",
"-",
"p1",
".",
"y",
")",
"*",
"(",
"-",
"v2",
".",
"getX",
"(",
")",
")",
")",
"/",
"delta",
";",
"// Fix precision problem with big decimal",
"i",
"=",
"new",
"Coordinate",
"(",
"p1",
".",
"x",
"+",
"k",
"*",
"v1",
".",
"getX",
"(",
")",
",",
"p1",
".",
"y",
"+",
"k",
"*",
"v1",
".",
"getY",
"(",
")",
",",
"p1",
".",
"z",
"+",
"k",
"*",
"v1",
".",
"getZ",
"(",
")",
")",
";",
"if",
"(",
"new",
"LineSegment",
"(",
"p1",
",",
"new",
"Coordinate",
"(",
"p1",
".",
"x",
"+",
"v1",
".",
"getX",
"(",
")",
",",
"p1",
".",
"y",
"+",
"v1",
".",
"getY",
"(",
")",
")",
")",
".",
"projectionFactor",
"(",
"i",
")",
"<",
"0",
"||",
"new",
"LineSegment",
"(",
"p2",
",",
"new",
"Coordinate",
"(",
"p2",
".",
"x",
"+",
"v2",
".",
"getX",
"(",
")",
",",
"p2",
".",
"y",
"+",
"v2",
".",
"getY",
"(",
")",
")",
")",
".",
"projectionFactor",
"(",
"i",
")",
"<",
"0",
")",
"{",
"return",
"null",
";",
"}",
"}",
"return",
"i",
";",
"}"
] | Compute intersection point of two vectors
@param p1 Origin point
@param v1 Direction from p1
@param p2 Origin point 2
@param v2 Direction of p2
@return Null if vectors are collinear or if intersection is done behind one of origin point | [
"Compute",
"intersection",
"point",
"of",
"two",
"vectors"
] | train | https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-utilities/src/main/java/org/h2gis/utilities/jts_utils/CoordinateUtils.java#L124-L139 |
salesforce/Argus | ArgusCore/src/main/java/com/salesforce/dva/argus/util/Option.java | Option.findOption | public static Option findOption(String name, Option[] options) {
"""
Returns an option with the given name.
@param name The option name to search for
@param options The list of options to search through
@return The named option from the list or null if it doesn't exist
"""
for (int i = 0; i < options.length; i++) {
if (options[i].getName().equals(name)) {
return options[i];
}
}
return null;
} | java | public static Option findOption(String name, Option[] options) {
for (int i = 0; i < options.length; i++) {
if (options[i].getName().equals(name)) {
return options[i];
}
}
return null;
} | [
"public",
"static",
"Option",
"findOption",
"(",
"String",
"name",
",",
"Option",
"[",
"]",
"options",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"options",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"options",
"[",
"i",
"]",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"name",
")",
")",
"{",
"return",
"options",
"[",
"i",
"]",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Returns an option with the given name.
@param name The option name to search for
@param options The list of options to search through
@return The named option from the list or null if it doesn't exist | [
"Returns",
"an",
"option",
"with",
"the",
"given",
"name",
"."
] | train | https://github.com/salesforce/Argus/blob/121b59a268da264316cded6a3e9271366a23cd86/ArgusCore/src/main/java/com/salesforce/dva/argus/util/Option.java#L170-L177 |
UrielCh/ovh-java-sdk | ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java | ApiOvhOrder.domain_zone_new_GET | public OvhOrder domain_zone_new_GET(Boolean minimized, String zoneName) throws IOException {
"""
Get prices and contracts information
REST: GET /order/domain/zone/new
@param minimized [required] Create only mandatory records
@param zoneName [required] Name of the zone to create
"""
String qPath = "/order/domain/zone/new";
StringBuilder sb = path(qPath);
query(sb, "minimized", minimized);
query(sb, "zoneName", zoneName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhOrder.class);
} | java | public OvhOrder domain_zone_new_GET(Boolean minimized, String zoneName) throws IOException {
String qPath = "/order/domain/zone/new";
StringBuilder sb = path(qPath);
query(sb, "minimized", minimized);
query(sb, "zoneName", zoneName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhOrder.class);
} | [
"public",
"OvhOrder",
"domain_zone_new_GET",
"(",
"Boolean",
"minimized",
",",
"String",
"zoneName",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/order/domain/zone/new\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
")",
";",
"query",
"(",
"sb",
",",
"\"minimized\"",
",",
"minimized",
")",
";",
"query",
"(",
"sb",
",",
"\"zoneName\"",
",",
"zoneName",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhOrder",
".",
"class",
")",
";",
"}"
] | Get prices and contracts information
REST: GET /order/domain/zone/new
@param minimized [required] Create only mandatory records
@param zoneName [required] Name of the zone to create | [
"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#L6005-L6012 |
jglobus/JGlobus | gss/src/main/java/org/globus/gsi/gssapi/GlobusGSSContextImpl.java | GlobusGSSContextImpl.getMIC | public byte[] getMIC(byte [] inBuf,
int off,
int len,
MessageProp prop)
throws GSSException {
"""
Returns a cryptographic MIC (message integrity check)
of a specified message.
"""
throw new GSSException(GSSException.UNAVAILABLE);
/*TODO
checkContext();
logger.debug("enter getMic");
if (prop != null && (prop.getQOP() != 0 || prop.getPrivacy())) {
throw new GSSException(GSSException.BAD_QOP);
}
SSLCipherState st = this.conn.getWriteCipherState();
SSLCipherSuite cs = st.getCipherSuite();
long sequence = this.conn.getWriteSequence();
byte [] mic = new byte[GSI_MESSAGE_DIGEST_PADDING + cs.getDigestOutputLength()];
System.arraycopy(Util.toBytes(sequence), 0, mic, 0, GSI_SEQUENCE_SIZE);
System.arraycopy(Util.toBytes(len, 4), 0, mic, GSI_SEQUENCE_SIZE, 4);
this.conn.incrementWriteSequence();
int pad_ct = (cs.getDigestOutputLength()==16) ? 48 : 40;
try {
MessageDigest md =
MessageDigest.getInstance(cs.getDigestAlg());
md.update(st.getMacKey());
for(int i=0;i<pad_ct;i++) {
md.update(SSLHandshake.pad_1);
}
md.update(mic, 0, GSI_MESSAGE_DIGEST_PADDING);
md.update(inBuf, off, len);
byte[] digest = md.digest();
System.arraycopy(digest, 0, mic, GSI_MESSAGE_DIGEST_PADDING, digest.length);
} catch (NoSuchAlgorithmException e) {
throw new GlobusGSSException(GSSException.FAILURE, e);
}
if (prop != null) {
prop.setPrivacy(false);
prop.setQOP(0);
}
logger.debug("exit getMic");
return mic;
*/
} | java | public byte[] getMIC(byte [] inBuf,
int off,
int len,
MessageProp prop)
throws GSSException {
throw new GSSException(GSSException.UNAVAILABLE);
/*TODO
checkContext();
logger.debug("enter getMic");
if (prop != null && (prop.getQOP() != 0 || prop.getPrivacy())) {
throw new GSSException(GSSException.BAD_QOP);
}
SSLCipherState st = this.conn.getWriteCipherState();
SSLCipherSuite cs = st.getCipherSuite();
long sequence = this.conn.getWriteSequence();
byte [] mic = new byte[GSI_MESSAGE_DIGEST_PADDING + cs.getDigestOutputLength()];
System.arraycopy(Util.toBytes(sequence), 0, mic, 0, GSI_SEQUENCE_SIZE);
System.arraycopy(Util.toBytes(len, 4), 0, mic, GSI_SEQUENCE_SIZE, 4);
this.conn.incrementWriteSequence();
int pad_ct = (cs.getDigestOutputLength()==16) ? 48 : 40;
try {
MessageDigest md =
MessageDigest.getInstance(cs.getDigestAlg());
md.update(st.getMacKey());
for(int i=0;i<pad_ct;i++) {
md.update(SSLHandshake.pad_1);
}
md.update(mic, 0, GSI_MESSAGE_DIGEST_PADDING);
md.update(inBuf, off, len);
byte[] digest = md.digest();
System.arraycopy(digest, 0, mic, GSI_MESSAGE_DIGEST_PADDING, digest.length);
} catch (NoSuchAlgorithmException e) {
throw new GlobusGSSException(GSSException.FAILURE, e);
}
if (prop != null) {
prop.setPrivacy(false);
prop.setQOP(0);
}
logger.debug("exit getMic");
return mic;
*/
} | [
"public",
"byte",
"[",
"]",
"getMIC",
"(",
"byte",
"[",
"]",
"inBuf",
",",
"int",
"off",
",",
"int",
"len",
",",
"MessageProp",
"prop",
")",
"throws",
"GSSException",
"{",
"throw",
"new",
"GSSException",
"(",
"GSSException",
".",
"UNAVAILABLE",
")",
";",
"/*TODO\n\n checkContext();\n\n logger.debug(\"enter getMic\");\n\n if (prop != null && (prop.getQOP() != 0 || prop.getPrivacy())) {\n throw new GSSException(GSSException.BAD_QOP);\n }\n\n SSLCipherState st = this.conn.getWriteCipherState();\n SSLCipherSuite cs = st.getCipherSuite();\n long sequence = this.conn.getWriteSequence();\n\n byte [] mic = new byte[GSI_MESSAGE_DIGEST_PADDING + cs.getDigestOutputLength()];\n\n System.arraycopy(Util.toBytes(sequence), 0, mic, 0, GSI_SEQUENCE_SIZE);\n System.arraycopy(Util.toBytes(len, 4), 0, mic, GSI_SEQUENCE_SIZE, 4);\n\n this.conn.incrementWriteSequence();\n\n int pad_ct = (cs.getDigestOutputLength()==16) ? 48 : 40;\n\n try {\n MessageDigest md =\n MessageDigest.getInstance(cs.getDigestAlg());\n\n md.update(st.getMacKey());\n for(int i=0;i<pad_ct;i++) {\n md.update(SSLHandshake.pad_1);\n }\n md.update(mic, 0, GSI_MESSAGE_DIGEST_PADDING);\n md.update(inBuf, off, len);\n\n byte[] digest = md.digest();\n\n System.arraycopy(digest, 0, mic, GSI_MESSAGE_DIGEST_PADDING, digest.length);\n } catch (NoSuchAlgorithmException e) {\n throw new GlobusGSSException(GSSException.FAILURE, e);\n }\n\n if (prop != null) {\n prop.setPrivacy(false);\n prop.setQOP(0);\n }\n\n logger.debug(\"exit getMic\");\n return mic;\n*/",
"}"
] | Returns a cryptographic MIC (message integrity check)
of a specified message. | [
"Returns",
"a",
"cryptographic",
"MIC",
"(",
"message",
"integrity",
"check",
")",
"of",
"a",
"specified",
"message",
"."
] | train | https://github.com/jglobus/JGlobus/blob/e14f6f6636544fd84298f9cec749d626ea971930/gss/src/main/java/org/globus/gsi/gssapi/GlobusGSSContextImpl.java#L1771-L1826 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/optimize/solvers/accumulation/EncodedGradientsAccumulator.java | EncodedGradientsAccumulator.touch | @Override
public void touch() {
"""
This method does initialization of given worker wrt Thread-Device Affinity
"""
if (index.get() == null) {
// set index
int numDevces = Nd4j.getAffinityManager().getNumberOfDevices();
/*
if we have > 1 computational device, we assign workers to workspaces "as is", as provided via AffinityManager
*/
if (numDevces > 1 && parties > 1) {
int localIndex = Nd4j.getAffinityManager().getDeviceForCurrentThread();
index.set(localIndex);
} else {
// if we have only 1 device (like cpu system, or single gpu), just attach consumer via flat index
index.set(workersCounter.getAndIncrement());
}
}
} | java | @Override
public void touch() {
if (index.get() == null) {
// set index
int numDevces = Nd4j.getAffinityManager().getNumberOfDevices();
/*
if we have > 1 computational device, we assign workers to workspaces "as is", as provided via AffinityManager
*/
if (numDevces > 1 && parties > 1) {
int localIndex = Nd4j.getAffinityManager().getDeviceForCurrentThread();
index.set(localIndex);
} else {
// if we have only 1 device (like cpu system, or single gpu), just attach consumer via flat index
index.set(workersCounter.getAndIncrement());
}
}
} | [
"@",
"Override",
"public",
"void",
"touch",
"(",
")",
"{",
"if",
"(",
"index",
".",
"get",
"(",
")",
"==",
"null",
")",
"{",
"// set index",
"int",
"numDevces",
"=",
"Nd4j",
".",
"getAffinityManager",
"(",
")",
".",
"getNumberOfDevices",
"(",
")",
";",
"/*\n if we have > 1 computational device, we assign workers to workspaces \"as is\", as provided via AffinityManager\n */",
"if",
"(",
"numDevces",
">",
"1",
"&&",
"parties",
">",
"1",
")",
"{",
"int",
"localIndex",
"=",
"Nd4j",
".",
"getAffinityManager",
"(",
")",
".",
"getDeviceForCurrentThread",
"(",
")",
";",
"index",
".",
"set",
"(",
"localIndex",
")",
";",
"}",
"else",
"{",
"// if we have only 1 device (like cpu system, or single gpu), just attach consumer via flat index",
"index",
".",
"set",
"(",
"workersCounter",
".",
"getAndIncrement",
"(",
")",
")",
";",
"}",
"}",
"}"
] | This method does initialization of given worker wrt Thread-Device Affinity | [
"This",
"method",
"does",
"initialization",
"of",
"given",
"worker",
"wrt",
"Thread",
"-",
"Device",
"Affinity"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/optimize/solvers/accumulation/EncodedGradientsAccumulator.java#L415-L433 |
Azure/azure-sdk-for-java | keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java | KeyVaultClientBaseImpl.updateCertificatePolicy | public CertificatePolicy updateCertificatePolicy(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy) {
"""
Updates the policy for a certificate.
Set specified members in the certificate policy. Leave others as null. This operation requires the certificates/update permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param certificateName The name of the certificate in the given vault.
@param certificatePolicy The policy for the certificate.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws KeyVaultErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the CertificatePolicy object if successful.
"""
return updateCertificatePolicyWithServiceResponseAsync(vaultBaseUrl, certificateName, certificatePolicy).toBlocking().single().body();
} | java | public CertificatePolicy updateCertificatePolicy(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy) {
return updateCertificatePolicyWithServiceResponseAsync(vaultBaseUrl, certificateName, certificatePolicy).toBlocking().single().body();
} | [
"public",
"CertificatePolicy",
"updateCertificatePolicy",
"(",
"String",
"vaultBaseUrl",
",",
"String",
"certificateName",
",",
"CertificatePolicy",
"certificatePolicy",
")",
"{",
"return",
"updateCertificatePolicyWithServiceResponseAsync",
"(",
"vaultBaseUrl",
",",
"certificateName",
",",
"certificatePolicy",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Updates the policy for a certificate.
Set specified members in the certificate policy. Leave others as null. This operation requires the certificates/update permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param certificateName The name of the certificate in the given vault.
@param certificatePolicy The policy for the certificate.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws KeyVaultErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the CertificatePolicy object if successful. | [
"Updates",
"the",
"policy",
"for",
"a",
"certificate",
".",
"Set",
"specified",
"members",
"in",
"the",
"certificate",
"policy",
".",
"Leave",
"others",
"as",
"null",
".",
"This",
"operation",
"requires",
"the",
"certificates",
"/",
"update",
"permission",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java#L7241-L7243 |
mapbox/mapbox-java | services-turf/src/main/java/com/mapbox/turf/TurfMeta.java | TurfMeta.addCoordAll | @NonNull
private static List<Point> addCoordAll(@NonNull List<Point> pointList, @NonNull Feature feature,
@NonNull boolean excludeWrapCoord) {
"""
Private helper method to be used with other methods in this class.
@param pointList the {@code List} of {@link Point}s.
@param feature the {@link Feature} that you'd like
to extract the Points from.
@param excludeWrapCoord whether or not to include the final
coordinate of LinearRings that wraps the ring
in its iteration. Used if a {@link Feature} in the
{@link FeatureCollection} that's passed through
this method, is a {@link Polygon} or {@link MultiPolygon}
geometry.
@return a {@code List} made up of {@link Point}s.
@since 4.8.0
"""
return coordAllFromSingleGeometry(pointList, feature.geometry(), excludeWrapCoord);
} | java | @NonNull
private static List<Point> addCoordAll(@NonNull List<Point> pointList, @NonNull Feature feature,
@NonNull boolean excludeWrapCoord) {
return coordAllFromSingleGeometry(pointList, feature.geometry(), excludeWrapCoord);
} | [
"@",
"NonNull",
"private",
"static",
"List",
"<",
"Point",
">",
"addCoordAll",
"(",
"@",
"NonNull",
"List",
"<",
"Point",
">",
"pointList",
",",
"@",
"NonNull",
"Feature",
"feature",
",",
"@",
"NonNull",
"boolean",
"excludeWrapCoord",
")",
"{",
"return",
"coordAllFromSingleGeometry",
"(",
"pointList",
",",
"feature",
".",
"geometry",
"(",
")",
",",
"excludeWrapCoord",
")",
";",
"}"
] | Private helper method to be used with other methods in this class.
@param pointList the {@code List} of {@link Point}s.
@param feature the {@link Feature} that you'd like
to extract the Points from.
@param excludeWrapCoord whether or not to include the final
coordinate of LinearRings that wraps the ring
in its iteration. Used if a {@link Feature} in the
{@link FeatureCollection} that's passed through
this method, is a {@link Polygon} or {@link MultiPolygon}
geometry.
@return a {@code List} made up of {@link Point}s.
@since 4.8.0 | [
"Private",
"helper",
"method",
"to",
"be",
"used",
"with",
"other",
"methods",
"in",
"this",
"class",
"."
] | train | https://github.com/mapbox/mapbox-java/blob/c0be138f462f91441388584c668f3760ba0e18e2/services-turf/src/main/java/com/mapbox/turf/TurfMeta.java#L287-L291 |
TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/objects/DwgLine.java | DwgLine.readDwgLineV15 | public void readDwgLineV15(int[] data, int offset) throws Exception {
"""
Read a Line in the DWG format Version 15
@param data Array of unsigned bytes obtained from the DWG binary file
@param offset The current bit offset where the value begins
@throws Exception If an unexpected bit value is found in the DWG file. Occurs
when we are looking for LwPolylines.
"""
int bitPos = offset;
bitPos = readObjectHeaderV15(data, bitPos);
Vector v = DwgUtil.testBit(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
zflag = ((Boolean)v.get(1)).booleanValue();
v = DwgUtil.getRawDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
double x1 = ((Double)v.get(1)).doubleValue();
v = DwgUtil.getDefaultDouble(data, bitPos, x1);
bitPos = ((Integer)v.get(0)).intValue();
double x2 = ((Double)v.get(1)).doubleValue();
v = DwgUtil.getRawDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
double y1 = ((Double)v.get(1)).doubleValue();
v = DwgUtil.getDefaultDouble(data, bitPos, y1);
bitPos = ((Integer)v.get(0)).intValue();
double y2 = ((Double)v.get(1)).doubleValue();
double[] p1;
double[] p2;
if (!zflag) {
v = DwgUtil.getRawDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
double z1 = ((Double)v.get(1)).doubleValue();
v = DwgUtil.getDefaultDouble(data, bitPos, z1);
bitPos = ((Integer)v.get(0)).intValue();
double z2 = ((Double)v.get(1)).doubleValue();
p1 = new double[]{x1, y1, z1};
p2 = new double[]{x2, y2, z2};
} else {
p1 = new double[]{x1, y1};
p2 = new double[]{x2, y2};
}
this.p1 = p1;
this.p2 = p2;
v = DwgUtil.testBit(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
boolean flag = ((Boolean)v.get(1)).booleanValue();
double val;
if (flag) {
val=0.0;
} else {
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
val = ((Double)v.get(1)).doubleValue();
}
thickness = val;
v = DwgUtil.testBit(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
flag = ((Boolean)v.get(1)).booleanValue();
double x, y, z;
if (flag) {
x = y = 0.0;
z = 1.0;
} else {
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
x = ((Double)v.get(1)).doubleValue();
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
y = ((Double)v.get(1)).doubleValue();
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
z = ((Double)v.get(1)).doubleValue();
}
double[] coord = new double[]{x, y, z};
extrusion = coord;
bitPos = readObjectTailV15(data, bitPos);
} | java | public void readDwgLineV15(int[] data, int offset) throws Exception {
int bitPos = offset;
bitPos = readObjectHeaderV15(data, bitPos);
Vector v = DwgUtil.testBit(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
zflag = ((Boolean)v.get(1)).booleanValue();
v = DwgUtil.getRawDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
double x1 = ((Double)v.get(1)).doubleValue();
v = DwgUtil.getDefaultDouble(data, bitPos, x1);
bitPos = ((Integer)v.get(0)).intValue();
double x2 = ((Double)v.get(1)).doubleValue();
v = DwgUtil.getRawDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
double y1 = ((Double)v.get(1)).doubleValue();
v = DwgUtil.getDefaultDouble(data, bitPos, y1);
bitPos = ((Integer)v.get(0)).intValue();
double y2 = ((Double)v.get(1)).doubleValue();
double[] p1;
double[] p2;
if (!zflag) {
v = DwgUtil.getRawDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
double z1 = ((Double)v.get(1)).doubleValue();
v = DwgUtil.getDefaultDouble(data, bitPos, z1);
bitPos = ((Integer)v.get(0)).intValue();
double z2 = ((Double)v.get(1)).doubleValue();
p1 = new double[]{x1, y1, z1};
p2 = new double[]{x2, y2, z2};
} else {
p1 = new double[]{x1, y1};
p2 = new double[]{x2, y2};
}
this.p1 = p1;
this.p2 = p2;
v = DwgUtil.testBit(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
boolean flag = ((Boolean)v.get(1)).booleanValue();
double val;
if (flag) {
val=0.0;
} else {
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
val = ((Double)v.get(1)).doubleValue();
}
thickness = val;
v = DwgUtil.testBit(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
flag = ((Boolean)v.get(1)).booleanValue();
double x, y, z;
if (flag) {
x = y = 0.0;
z = 1.0;
} else {
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
x = ((Double)v.get(1)).doubleValue();
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
y = ((Double)v.get(1)).doubleValue();
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
z = ((Double)v.get(1)).doubleValue();
}
double[] coord = new double[]{x, y, z};
extrusion = coord;
bitPos = readObjectTailV15(data, bitPos);
} | [
"public",
"void",
"readDwgLineV15",
"(",
"int",
"[",
"]",
"data",
",",
"int",
"offset",
")",
"throws",
"Exception",
"{",
"int",
"bitPos",
"=",
"offset",
";",
"bitPos",
"=",
"readObjectHeaderV15",
"(",
"data",
",",
"bitPos",
")",
";",
"Vector",
"v",
"=",
"DwgUtil",
".",
"testBit",
"(",
"data",
",",
"bitPos",
")",
";",
"bitPos",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"0",
")",
")",
".",
"intValue",
"(",
")",
";",
"zflag",
"=",
"(",
"(",
"Boolean",
")",
"v",
".",
"get",
"(",
"1",
")",
")",
".",
"booleanValue",
"(",
")",
";",
"v",
"=",
"DwgUtil",
".",
"getRawDouble",
"(",
"data",
",",
"bitPos",
")",
";",
"bitPos",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"0",
")",
")",
".",
"intValue",
"(",
")",
";",
"double",
"x1",
"=",
"(",
"(",
"Double",
")",
"v",
".",
"get",
"(",
"1",
")",
")",
".",
"doubleValue",
"(",
")",
";",
"v",
"=",
"DwgUtil",
".",
"getDefaultDouble",
"(",
"data",
",",
"bitPos",
",",
"x1",
")",
";",
"bitPos",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"0",
")",
")",
".",
"intValue",
"(",
")",
";",
"double",
"x2",
"=",
"(",
"(",
"Double",
")",
"v",
".",
"get",
"(",
"1",
")",
")",
".",
"doubleValue",
"(",
")",
";",
"v",
"=",
"DwgUtil",
".",
"getRawDouble",
"(",
"data",
",",
"bitPos",
")",
";",
"bitPos",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"0",
")",
")",
".",
"intValue",
"(",
")",
";",
"double",
"y1",
"=",
"(",
"(",
"Double",
")",
"v",
".",
"get",
"(",
"1",
")",
")",
".",
"doubleValue",
"(",
")",
";",
"v",
"=",
"DwgUtil",
".",
"getDefaultDouble",
"(",
"data",
",",
"bitPos",
",",
"y1",
")",
";",
"bitPos",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"0",
")",
")",
".",
"intValue",
"(",
")",
";",
"double",
"y2",
"=",
"(",
"(",
"Double",
")",
"v",
".",
"get",
"(",
"1",
")",
")",
".",
"doubleValue",
"(",
")",
";",
"double",
"[",
"]",
"p1",
";",
"double",
"[",
"]",
"p2",
";",
"if",
"(",
"!",
"zflag",
")",
"{",
"v",
"=",
"DwgUtil",
".",
"getRawDouble",
"(",
"data",
",",
"bitPos",
")",
";",
"bitPos",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"0",
")",
")",
".",
"intValue",
"(",
")",
";",
"double",
"z1",
"=",
"(",
"(",
"Double",
")",
"v",
".",
"get",
"(",
"1",
")",
")",
".",
"doubleValue",
"(",
")",
";",
"v",
"=",
"DwgUtil",
".",
"getDefaultDouble",
"(",
"data",
",",
"bitPos",
",",
"z1",
")",
";",
"bitPos",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"0",
")",
")",
".",
"intValue",
"(",
")",
";",
"double",
"z2",
"=",
"(",
"(",
"Double",
")",
"v",
".",
"get",
"(",
"1",
")",
")",
".",
"doubleValue",
"(",
")",
";",
"p1",
"=",
"new",
"double",
"[",
"]",
"{",
"x1",
",",
"y1",
",",
"z1",
"}",
";",
"p2",
"=",
"new",
"double",
"[",
"]",
"{",
"x2",
",",
"y2",
",",
"z2",
"}",
";",
"}",
"else",
"{",
"p1",
"=",
"new",
"double",
"[",
"]",
"{",
"x1",
",",
"y1",
"}",
";",
"p2",
"=",
"new",
"double",
"[",
"]",
"{",
"x2",
",",
"y2",
"}",
";",
"}",
"this",
".",
"p1",
"=",
"p1",
";",
"this",
".",
"p2",
"=",
"p2",
";",
"v",
"=",
"DwgUtil",
".",
"testBit",
"(",
"data",
",",
"bitPos",
")",
";",
"bitPos",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"0",
")",
")",
".",
"intValue",
"(",
")",
";",
"boolean",
"flag",
"=",
"(",
"(",
"Boolean",
")",
"v",
".",
"get",
"(",
"1",
")",
")",
".",
"booleanValue",
"(",
")",
";",
"double",
"val",
";",
"if",
"(",
"flag",
")",
"{",
"val",
"=",
"0.0",
";",
"}",
"else",
"{",
"v",
"=",
"DwgUtil",
".",
"getBitDouble",
"(",
"data",
",",
"bitPos",
")",
";",
"bitPos",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"0",
")",
")",
".",
"intValue",
"(",
")",
";",
"val",
"=",
"(",
"(",
"Double",
")",
"v",
".",
"get",
"(",
"1",
")",
")",
".",
"doubleValue",
"(",
")",
";",
"}",
"thickness",
"=",
"val",
";",
"v",
"=",
"DwgUtil",
".",
"testBit",
"(",
"data",
",",
"bitPos",
")",
";",
"bitPos",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"0",
")",
")",
".",
"intValue",
"(",
")",
";",
"flag",
"=",
"(",
"(",
"Boolean",
")",
"v",
".",
"get",
"(",
"1",
")",
")",
".",
"booleanValue",
"(",
")",
";",
"double",
"x",
",",
"y",
",",
"z",
";",
"if",
"(",
"flag",
")",
"{",
"x",
"=",
"y",
"=",
"0.0",
";",
"z",
"=",
"1.0",
";",
"}",
"else",
"{",
"v",
"=",
"DwgUtil",
".",
"getBitDouble",
"(",
"data",
",",
"bitPos",
")",
";",
"bitPos",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"0",
")",
")",
".",
"intValue",
"(",
")",
";",
"x",
"=",
"(",
"(",
"Double",
")",
"v",
".",
"get",
"(",
"1",
")",
")",
".",
"doubleValue",
"(",
")",
";",
"v",
"=",
"DwgUtil",
".",
"getBitDouble",
"(",
"data",
",",
"bitPos",
")",
";",
"bitPos",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"0",
")",
")",
".",
"intValue",
"(",
")",
";",
"y",
"=",
"(",
"(",
"Double",
")",
"v",
".",
"get",
"(",
"1",
")",
")",
".",
"doubleValue",
"(",
")",
";",
"v",
"=",
"DwgUtil",
".",
"getBitDouble",
"(",
"data",
",",
"bitPos",
")",
";",
"bitPos",
"=",
"(",
"(",
"Integer",
")",
"v",
".",
"get",
"(",
"0",
")",
")",
".",
"intValue",
"(",
")",
";",
"z",
"=",
"(",
"(",
"Double",
")",
"v",
".",
"get",
"(",
"1",
")",
")",
".",
"doubleValue",
"(",
")",
";",
"}",
"double",
"[",
"]",
"coord",
"=",
"new",
"double",
"[",
"]",
"{",
"x",
",",
"y",
",",
"z",
"}",
";",
"extrusion",
"=",
"coord",
";",
"bitPos",
"=",
"readObjectTailV15",
"(",
"data",
",",
"bitPos",
")",
";",
"}"
] | Read a Line in the DWG format Version 15
@param data Array of unsigned bytes obtained from the DWG binary file
@param offset The current bit offset where the value begins
@throws Exception If an unexpected bit value is found in the DWG file. Occurs
when we are looking for LwPolylines. | [
"Read",
"a",
"Line",
"in",
"the",
"DWG",
"format",
"Version",
"15"
] | train | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/objects/DwgLine.java#L46-L114 |
andriusvelykis/reflow-maven-skin | reflow-velocity-tools/src/main/java/lt/velykis/maven/skins/reflow/HtmlTool.java | HtmlTool.addClass | public String addClass(String content, String selector, List<String> classNames) {
"""
Adds given class names to the elements in HTML.
@param content
HTML content to modify
@param selector
CSS selector for elements to add classes to
@param classNames
Names of classes to add to the selected elements
@return HTML content with modified elements. If no elements are found, the original content
is returned.
@since 1.0
"""
return addClass(content, selector, classNames, -1);
} | java | public String addClass(String content, String selector, List<String> classNames) {
return addClass(content, selector, classNames, -1);
} | [
"public",
"String",
"addClass",
"(",
"String",
"content",
",",
"String",
"selector",
",",
"List",
"<",
"String",
">",
"classNames",
")",
"{",
"return",
"addClass",
"(",
"content",
",",
"selector",
",",
"classNames",
",",
"-",
"1",
")",
";",
"}"
] | Adds given class names to the elements in HTML.
@param content
HTML content to modify
@param selector
CSS selector for elements to add classes to
@param classNames
Names of classes to add to the selected elements
@return HTML content with modified elements. If no elements are found, the original content
is returned.
@since 1.0 | [
"Adds",
"given",
"class",
"names",
"to",
"the",
"elements",
"in",
"HTML",
"."
] | train | https://github.com/andriusvelykis/reflow-maven-skin/blob/01170ae1426a1adfe7cc9c199e77aaa2ecb37ef2/reflow-velocity-tools/src/main/java/lt/velykis/maven/skins/reflow/HtmlTool.java#L696-L698 |
BBN-E/bue-common-open | common-core-open/src/main/java/com/bbn/bue/common/files/FileUtils.java | FileUtils.swapExtension | public static File swapExtension(final File f, final String newExtension) {
"""
Returns another file just like the input but with a different extension. If the input file has
an extension (a suffix beginning with "."), everything after the . is replaced with
newExtension. Otherwise, a newExtension is appended to the filename and a new File is returned.
Note that unless you want double .s, newExtension should not begin with a .
"""
checkNotNull(f);
checkNotNull(newExtension);
Preconditions.checkArgument(!f.isDirectory());
final String absolutePath = f.getAbsolutePath();
final int dotIndex = absolutePath.lastIndexOf(".");
String basePath;
if (dotIndex >= 0) {
basePath = absolutePath.substring(0, dotIndex);
} else {
basePath = absolutePath;
}
return new File(String.format("%s.%s", basePath, newExtension));
} | java | public static File swapExtension(final File f, final String newExtension) {
checkNotNull(f);
checkNotNull(newExtension);
Preconditions.checkArgument(!f.isDirectory());
final String absolutePath = f.getAbsolutePath();
final int dotIndex = absolutePath.lastIndexOf(".");
String basePath;
if (dotIndex >= 0) {
basePath = absolutePath.substring(0, dotIndex);
} else {
basePath = absolutePath;
}
return new File(String.format("%s.%s", basePath, newExtension));
} | [
"public",
"static",
"File",
"swapExtension",
"(",
"final",
"File",
"f",
",",
"final",
"String",
"newExtension",
")",
"{",
"checkNotNull",
"(",
"f",
")",
";",
"checkNotNull",
"(",
"newExtension",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"!",
"f",
".",
"isDirectory",
"(",
")",
")",
";",
"final",
"String",
"absolutePath",
"=",
"f",
".",
"getAbsolutePath",
"(",
")",
";",
"final",
"int",
"dotIndex",
"=",
"absolutePath",
".",
"lastIndexOf",
"(",
"\".\"",
")",
";",
"String",
"basePath",
";",
"if",
"(",
"dotIndex",
">=",
"0",
")",
"{",
"basePath",
"=",
"absolutePath",
".",
"substring",
"(",
"0",
",",
"dotIndex",
")",
";",
"}",
"else",
"{",
"basePath",
"=",
"absolutePath",
";",
"}",
"return",
"new",
"File",
"(",
"String",
".",
"format",
"(",
"\"%s.%s\"",
",",
"basePath",
",",
"newExtension",
")",
")",
";",
"}"
] | Returns another file just like the input but with a different extension. If the input file has
an extension (a suffix beginning with "."), everything after the . is replaced with
newExtension. Otherwise, a newExtension is appended to the filename and a new File is returned.
Note that unless you want double .s, newExtension should not begin with a . | [
"Returns",
"another",
"file",
"just",
"like",
"the",
"input",
"but",
"with",
"a",
"different",
"extension",
".",
"If",
"the",
"input",
"file",
"has",
"an",
"extension",
"(",
"a",
"suffix",
"beginning",
"with",
".",
")",
"everything",
"after",
"the",
".",
"is",
"replaced",
"with",
"newExtension",
".",
"Otherwise",
"a",
"newExtension",
"is",
"appended",
"to",
"the",
"filename",
"and",
"a",
"new",
"File",
"is",
"returned",
".",
"Note",
"that",
"unless",
"you",
"want",
"double",
".",
"s",
"newExtension",
"should",
"not",
"begin",
"with",
"a",
"."
] | train | https://github.com/BBN-E/bue-common-open/blob/d618652674d647867306e2e4b987a21b7c29c015/common-core-open/src/main/java/com/bbn/bue/common/files/FileUtils.java#L190-L206 |
thombergs/docx-stamper | src/main/java/org/wickedsource/docxstamper/DocxStamperConfiguration.java | DocxStamperConfiguration.exposeInterfaceToExpressionLanguage | public DocxStamperConfiguration exposeInterfaceToExpressionLanguage(Class<?> interfaceClass, Object implementation) {
"""
Exposes all methods of a given interface to the expression language.
@param interfaceClass the interface whose methods should be exposed in the expression language.
@param implementation the implementation that should be called to evaluate invocations of the interface methods
within the expression language. Must implement the interface above.
"""
this.expressionFunctions.put(interfaceClass, implementation);
return this;
} | java | public DocxStamperConfiguration exposeInterfaceToExpressionLanguage(Class<?> interfaceClass, Object implementation) {
this.expressionFunctions.put(interfaceClass, implementation);
return this;
} | [
"public",
"DocxStamperConfiguration",
"exposeInterfaceToExpressionLanguage",
"(",
"Class",
"<",
"?",
">",
"interfaceClass",
",",
"Object",
"implementation",
")",
"{",
"this",
".",
"expressionFunctions",
".",
"put",
"(",
"interfaceClass",
",",
"implementation",
")",
";",
"return",
"this",
";",
"}"
] | Exposes all methods of a given interface to the expression language.
@param interfaceClass the interface whose methods should be exposed in the expression language.
@param implementation the implementation that should be called to evaluate invocations of the interface methods
within the expression language. Must implement the interface above. | [
"Exposes",
"all",
"methods",
"of",
"a",
"given",
"interface",
"to",
"the",
"expression",
"language",
"."
] | train | https://github.com/thombergs/docx-stamper/blob/f1a7e3e92a59abaffac299532fe49450c3b041eb/src/main/java/org/wickedsource/docxstamper/DocxStamperConfiguration.java#L106-L109 |
alipay/sofa-rpc | core-impl/client/src/main/java/com/alipay/sofa/rpc/client/AllConnectConnectionHolder.java | AllConnectConnectionHolder.printFailure | protected void printFailure(String interfaceId, ProviderInfo providerInfo, ClientTransport transport) {
"""
打印连接失败日志
@param interfaceId 接口名称
@param providerInfo 服务端
@param transport 连接
"""
if (LOGGER.isInfoEnabled(consumerConfig.getAppName())) {
LOGGER.infoWithApp(consumerConfig.getAppName(), "Connect to {} provider:{} failure !", interfaceId,
providerInfo);
}
} | java | protected void printFailure(String interfaceId, ProviderInfo providerInfo, ClientTransport transport) {
if (LOGGER.isInfoEnabled(consumerConfig.getAppName())) {
LOGGER.infoWithApp(consumerConfig.getAppName(), "Connect to {} provider:{} failure !", interfaceId,
providerInfo);
}
} | [
"protected",
"void",
"printFailure",
"(",
"String",
"interfaceId",
",",
"ProviderInfo",
"providerInfo",
",",
"ClientTransport",
"transport",
")",
"{",
"if",
"(",
"LOGGER",
".",
"isInfoEnabled",
"(",
"consumerConfig",
".",
"getAppName",
"(",
")",
")",
")",
"{",
"LOGGER",
".",
"infoWithApp",
"(",
"consumerConfig",
".",
"getAppName",
"(",
")",
",",
"\"Connect to {} provider:{} failure !\"",
",",
"interfaceId",
",",
"providerInfo",
")",
";",
"}",
"}"
] | 打印连接失败日志
@param interfaceId 接口名称
@param providerInfo 服务端
@param transport 连接 | [
"打印连接失败日志"
] | train | https://github.com/alipay/sofa-rpc/blob/a31406410291e56696185a29c3ba4bd1f54488fd/core-impl/client/src/main/java/com/alipay/sofa/rpc/client/AllConnectConnectionHolder.java#L711-L716 |
bpsm/edn-java | src/main/java/us/bpsm/edn/Keyword.java | Keyword.newKeyword | public static Keyword newKeyword(String prefix, String name) {
"""
Provide a Keyword with the given prefix and name.
<p>
Keywords are interned, which means that any two keywords which are equal
(by value) will also be identical (by reference).
@param prefix
An empty String or a non-empty String obeying the restrictions
specified by edn. Never null.
@param name
A non-empty string obeying the restrictions specified by edn.
Never null.
@return a Keyword, never null.
"""
return newKeyword(newSymbol(prefix, name));
} | java | public static Keyword newKeyword(String prefix, String name) {
return newKeyword(newSymbol(prefix, name));
} | [
"public",
"static",
"Keyword",
"newKeyword",
"(",
"String",
"prefix",
",",
"String",
"name",
")",
"{",
"return",
"newKeyword",
"(",
"newSymbol",
"(",
"prefix",
",",
"name",
")",
")",
";",
"}"
] | Provide a Keyword with the given prefix and name.
<p>
Keywords are interned, which means that any two keywords which are equal
(by value) will also be identical (by reference).
@param prefix
An empty String or a non-empty String obeying the restrictions
specified by edn. Never null.
@param name
A non-empty string obeying the restrictions specified by edn.
Never null.
@return a Keyword, never null. | [
"Provide",
"a",
"Keyword",
"with",
"the",
"given",
"prefix",
"and",
"name",
".",
"<p",
">",
"Keywords",
"are",
"interned",
"which",
"means",
"that",
"any",
"two",
"keywords",
"which",
"are",
"equal",
"(",
"by",
"value",
")",
"will",
"also",
"be",
"identical",
"(",
"by",
"reference",
")",
"."
] | train | https://github.com/bpsm/edn-java/blob/c5dfdb77431da1aca3c257599b237a21575629b2/src/main/java/us/bpsm/edn/Keyword.java#L58-L60 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/NetworkInterfaceTapConfigurationsInner.java | NetworkInterfaceTapConfigurationsInner.getAsync | public Observable<NetworkInterfaceTapConfigurationInner> getAsync(String resourceGroupName, String networkInterfaceName, String tapConfigurationName) {
"""
Get the specified tap configuration on a network interface.
@param resourceGroupName The name of the resource group.
@param networkInterfaceName The name of the network interface.
@param tapConfigurationName The name of the tap configuration.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the NetworkInterfaceTapConfigurationInner object
"""
return getWithServiceResponseAsync(resourceGroupName, networkInterfaceName, tapConfigurationName).map(new Func1<ServiceResponse<NetworkInterfaceTapConfigurationInner>, NetworkInterfaceTapConfigurationInner>() {
@Override
public NetworkInterfaceTapConfigurationInner call(ServiceResponse<NetworkInterfaceTapConfigurationInner> response) {
return response.body();
}
});
} | java | public Observable<NetworkInterfaceTapConfigurationInner> getAsync(String resourceGroupName, String networkInterfaceName, String tapConfigurationName) {
return getWithServiceResponseAsync(resourceGroupName, networkInterfaceName, tapConfigurationName).map(new Func1<ServiceResponse<NetworkInterfaceTapConfigurationInner>, NetworkInterfaceTapConfigurationInner>() {
@Override
public NetworkInterfaceTapConfigurationInner call(ServiceResponse<NetworkInterfaceTapConfigurationInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"NetworkInterfaceTapConfigurationInner",
">",
"getAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"networkInterfaceName",
",",
"String",
"tapConfigurationName",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"networkInterfaceName",
",",
"tapConfigurationName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"NetworkInterfaceTapConfigurationInner",
">",
",",
"NetworkInterfaceTapConfigurationInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"NetworkInterfaceTapConfigurationInner",
"call",
"(",
"ServiceResponse",
"<",
"NetworkInterfaceTapConfigurationInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Get the specified tap configuration on a network interface.
@param resourceGroupName The name of the resource group.
@param networkInterfaceName The name of the network interface.
@param tapConfigurationName The name of the tap configuration.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the NetworkInterfaceTapConfigurationInner object | [
"Get",
"the",
"specified",
"tap",
"configuration",
"on",
"a",
"network",
"interface",
"."
] | 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/NetworkInterfaceTapConfigurationsInner.java#L297-L304 |
structr/structr | structr-ui/src/main/java/org/structr/web/common/FileHelper.java | FileHelper.transformFile | public static <T extends File> T transformFile(final SecurityContext securityContext, final String uuid, final Class<T> fileType) throws FrameworkException, IOException {
"""
Transform an existing file into the target class.
@param <T>
@param securityContext
@param uuid
@param fileType
@return transformed file
@throws FrameworkException
@throws IOException
"""
AbstractFile existingFile = getFileByUuid(securityContext, uuid);
if (existingFile != null) {
existingFile.unlockSystemPropertiesOnce();
existingFile.setProperties(securityContext, new PropertyMap(AbstractNode.type, fileType == null ? File.class.getSimpleName() : fileType.getSimpleName()));
existingFile = getFileByUuid(securityContext, uuid);
return (T)(fileType != null ? fileType.cast(existingFile) : (File) existingFile);
}
return null;
} | java | public static <T extends File> T transformFile(final SecurityContext securityContext, final String uuid, final Class<T> fileType) throws FrameworkException, IOException {
AbstractFile existingFile = getFileByUuid(securityContext, uuid);
if (existingFile != null) {
existingFile.unlockSystemPropertiesOnce();
existingFile.setProperties(securityContext, new PropertyMap(AbstractNode.type, fileType == null ? File.class.getSimpleName() : fileType.getSimpleName()));
existingFile = getFileByUuid(securityContext, uuid);
return (T)(fileType != null ? fileType.cast(existingFile) : (File) existingFile);
}
return null;
} | [
"public",
"static",
"<",
"T",
"extends",
"File",
">",
"T",
"transformFile",
"(",
"final",
"SecurityContext",
"securityContext",
",",
"final",
"String",
"uuid",
",",
"final",
"Class",
"<",
"T",
">",
"fileType",
")",
"throws",
"FrameworkException",
",",
"IOException",
"{",
"AbstractFile",
"existingFile",
"=",
"getFileByUuid",
"(",
"securityContext",
",",
"uuid",
")",
";",
"if",
"(",
"existingFile",
"!=",
"null",
")",
"{",
"existingFile",
".",
"unlockSystemPropertiesOnce",
"(",
")",
";",
"existingFile",
".",
"setProperties",
"(",
"securityContext",
",",
"new",
"PropertyMap",
"(",
"AbstractNode",
".",
"type",
",",
"fileType",
"==",
"null",
"?",
"File",
".",
"class",
".",
"getSimpleName",
"(",
")",
":",
"fileType",
".",
"getSimpleName",
"(",
")",
")",
")",
";",
"existingFile",
"=",
"getFileByUuid",
"(",
"securityContext",
",",
"uuid",
")",
";",
"return",
"(",
"T",
")",
"(",
"fileType",
"!=",
"null",
"?",
"fileType",
".",
"cast",
"(",
"existingFile",
")",
":",
"(",
"File",
")",
"existingFile",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Transform an existing file into the target class.
@param <T>
@param securityContext
@param uuid
@param fileType
@return transformed file
@throws FrameworkException
@throws IOException | [
"Transform",
"an",
"existing",
"file",
"into",
"the",
"target",
"class",
"."
] | train | https://github.com/structr/structr/blob/c111a1d0c0201c7fea5574ed69aa5a5053185a97/structr-ui/src/main/java/org/structr/web/common/FileHelper.java#L79-L94 |
google/closure-compiler | src/com/google/javascript/jscomp/NodeTraversal.java | NodeTraversal.traverseChangedFunctions | public static void traverseChangedFunctions(
final AbstractCompiler compiler, final ChangeScopeRootCallback callback) {
"""
Traversal for passes that work only on changed functions.
Suppose a loopable pass P1 uses this traversal.
Then, if a function doesn't change between two runs of P1, it won't look at
the function the second time.
(We're assuming that P1 runs to a fixpoint, o/w we may miss optimizations.)
<p>Most changes are reported with calls to Compiler.reportCodeChange(), which
doesn't know which scope changed. We keep track of the current scope by
calling Compiler.setScope inside pushScope and popScope.
The automatic tracking can be wrong in rare cases when a pass changes scope
w/out causing a call to pushScope or popScope.
Passes that do cross-scope modifications call
Compiler.reportChangeToEnclosingScope(Node n).
"""
final Node jsRoot = compiler.getJsRoot();
NodeTraversal.traverse(compiler, jsRoot,
new AbstractPreOrderCallback() {
@Override
public final boolean shouldTraverse(NodeTraversal t, Node n, Node parent) {
if (NodeUtil.isChangeScopeRoot(n) && compiler.hasScopeChanged(n)) {
callback.enterChangeScopeRoot(compiler, n);
}
return true;
}
});
} | java | public static void traverseChangedFunctions(
final AbstractCompiler compiler, final ChangeScopeRootCallback callback) {
final Node jsRoot = compiler.getJsRoot();
NodeTraversal.traverse(compiler, jsRoot,
new AbstractPreOrderCallback() {
@Override
public final boolean shouldTraverse(NodeTraversal t, Node n, Node parent) {
if (NodeUtil.isChangeScopeRoot(n) && compiler.hasScopeChanged(n)) {
callback.enterChangeScopeRoot(compiler, n);
}
return true;
}
});
} | [
"public",
"static",
"void",
"traverseChangedFunctions",
"(",
"final",
"AbstractCompiler",
"compiler",
",",
"final",
"ChangeScopeRootCallback",
"callback",
")",
"{",
"final",
"Node",
"jsRoot",
"=",
"compiler",
".",
"getJsRoot",
"(",
")",
";",
"NodeTraversal",
".",
"traverse",
"(",
"compiler",
",",
"jsRoot",
",",
"new",
"AbstractPreOrderCallback",
"(",
")",
"{",
"@",
"Override",
"public",
"final",
"boolean",
"shouldTraverse",
"(",
"NodeTraversal",
"t",
",",
"Node",
"n",
",",
"Node",
"parent",
")",
"{",
"if",
"(",
"NodeUtil",
".",
"isChangeScopeRoot",
"(",
"n",
")",
"&&",
"compiler",
".",
"hasScopeChanged",
"(",
"n",
")",
")",
"{",
"callback",
".",
"enterChangeScopeRoot",
"(",
"compiler",
",",
"n",
")",
";",
"}",
"return",
"true",
";",
"}",
"}",
")",
";",
"}"
] | Traversal for passes that work only on changed functions.
Suppose a loopable pass P1 uses this traversal.
Then, if a function doesn't change between two runs of P1, it won't look at
the function the second time.
(We're assuming that P1 runs to a fixpoint, o/w we may miss optimizations.)
<p>Most changes are reported with calls to Compiler.reportCodeChange(), which
doesn't know which scope changed. We keep track of the current scope by
calling Compiler.setScope inside pushScope and popScope.
The automatic tracking can be wrong in rare cases when a pass changes scope
w/out causing a call to pushScope or popScope.
Passes that do cross-scope modifications call
Compiler.reportChangeToEnclosingScope(Node n). | [
"Traversal",
"for",
"passes",
"that",
"work",
"only",
"on",
"changed",
"functions",
".",
"Suppose",
"a",
"loopable",
"pass",
"P1",
"uses",
"this",
"traversal",
".",
"Then",
"if",
"a",
"function",
"doesn",
"t",
"change",
"between",
"two",
"runs",
"of",
"P1",
"it",
"won",
"t",
"look",
"at",
"the",
"function",
"the",
"second",
"time",
".",
"(",
"We",
"re",
"assuming",
"that",
"P1",
"runs",
"to",
"a",
"fixpoint",
"o",
"/",
"w",
"we",
"may",
"miss",
"optimizations",
".",
")"
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeTraversal.java#L779-L792 |
twitter/cloudhopper-commons | ch-commons-util/src/main/java/com/cloudhopper/commons/util/ClassUtil.java | ClassUtil.findEnumConstant | public static Object findEnumConstant(Class<?> type, String constantName, boolean caseSensitive) {
"""
Finds an instance of an Enum constant on a class. Useful for safely
getting the value of an enum constant without an exception being thrown
like the Enum.valueOf() method causes. Also, this method optionally allows
the caller to choose whether case matters during the search.
"""
if (!type.isEnum()) {
return null;
}
for (Object obj : type.getEnumConstants()) {
String name = obj.toString();
if ((caseSensitive && name.equals(constantName)) || (!caseSensitive && name.equalsIgnoreCase(constantName))) {
return obj;
}
}
// otherwise, it wasn't found
return null;
} | java | public static Object findEnumConstant(Class<?> type, String constantName, boolean caseSensitive) {
if (!type.isEnum()) {
return null;
}
for (Object obj : type.getEnumConstants()) {
String name = obj.toString();
if ((caseSensitive && name.equals(constantName)) || (!caseSensitive && name.equalsIgnoreCase(constantName))) {
return obj;
}
}
// otherwise, it wasn't found
return null;
} | [
"public",
"static",
"Object",
"findEnumConstant",
"(",
"Class",
"<",
"?",
">",
"type",
",",
"String",
"constantName",
",",
"boolean",
"caseSensitive",
")",
"{",
"if",
"(",
"!",
"type",
".",
"isEnum",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"for",
"(",
"Object",
"obj",
":",
"type",
".",
"getEnumConstants",
"(",
")",
")",
"{",
"String",
"name",
"=",
"obj",
".",
"toString",
"(",
")",
";",
"if",
"(",
"(",
"caseSensitive",
"&&",
"name",
".",
"equals",
"(",
"constantName",
")",
")",
"||",
"(",
"!",
"caseSensitive",
"&&",
"name",
".",
"equalsIgnoreCase",
"(",
"constantName",
")",
")",
")",
"{",
"return",
"obj",
";",
"}",
"}",
"// otherwise, it wasn't found",
"return",
"null",
";",
"}"
] | Finds an instance of an Enum constant on a class. Useful for safely
getting the value of an enum constant without an exception being thrown
like the Enum.valueOf() method causes. Also, this method optionally allows
the caller to choose whether case matters during the search. | [
"Finds",
"an",
"instance",
"of",
"an",
"Enum",
"constant",
"on",
"a",
"class",
".",
"Useful",
"for",
"safely",
"getting",
"the",
"value",
"of",
"an",
"enum",
"constant",
"without",
"an",
"exception",
"being",
"thrown",
"like",
"the",
"Enum",
".",
"valueOf",
"()",
"method",
"causes",
".",
"Also",
"this",
"method",
"optionally",
"allows",
"the",
"caller",
"to",
"choose",
"whether",
"case",
"matters",
"during",
"the",
"search",
"."
] | train | https://github.com/twitter/cloudhopper-commons/blob/b5bc397dbec4537e8149e7ec0733c1d7ed477499/ch-commons-util/src/main/java/com/cloudhopper/commons/util/ClassUtil.java#L52-L64 |
elki-project/elki | elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/spatial/CTLuMedianAlgorithm.java | CTLuMedianAlgorithm.run | public OutlierResult run(Database database, Relation<N> nrel, Relation<? extends NumberVector> relation) {
"""
Main method.
@param database Database
@param nrel Neighborhood relation
@param relation Data relation (1d!)
@return Outlier detection result
"""
final NeighborSetPredicate npred = getNeighborSetPredicateFactory().instantiate(database, nrel);
WritableDoubleDataStore scores = DataStoreUtil.makeDoubleStorage(relation.getDBIDs(), DataStoreFactory.HINT_STATIC);
MeanVariance mv = new MeanVariance();
for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) {
DBIDs neighbors = npred.getNeighborDBIDs(iditer);
final double median;
{
double[] fi = new double[neighbors.size()];
// calculate and store Median of neighborhood
int c = 0;
for(DBIDIter iter = neighbors.iter(); iter.valid(); iter.advance()) {
if(DBIDUtil.equal(iditer, iter)) {
continue;
}
fi[c] = relation.get(iter).doubleValue(0);
c++;
}
if(c > 0) {
median = QuickSelect.median(fi, 0, c);
}
else {
median = relation.get(iditer).doubleValue(0);
}
}
double h = relation.get(iditer).doubleValue(0) - median;
scores.putDouble(iditer, h);
mv.put(h);
}
// Normalize scores
final double mean = mv.getMean();
final double stddev = mv.getNaiveStddev();
DoubleMinMax minmax = new DoubleMinMax();
for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) {
double score = Math.abs((scores.doubleValue(iditer) - mean) / stddev);
minmax.put(score);
scores.putDouble(iditer, score);
}
DoubleRelation scoreResult = new MaterializedDoubleRelation("MO", "Median-outlier", scores, relation.getDBIDs());
OutlierScoreMeta scoreMeta = new BasicOutlierScoreMeta(minmax.getMin(), minmax.getMax(), 0.0, Double.POSITIVE_INFINITY, 0);
OutlierResult or = new OutlierResult(scoreMeta, scoreResult);
or.addChildResult(npred);
return or;
} | java | public OutlierResult run(Database database, Relation<N> nrel, Relation<? extends NumberVector> relation) {
final NeighborSetPredicate npred = getNeighborSetPredicateFactory().instantiate(database, nrel);
WritableDoubleDataStore scores = DataStoreUtil.makeDoubleStorage(relation.getDBIDs(), DataStoreFactory.HINT_STATIC);
MeanVariance mv = new MeanVariance();
for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) {
DBIDs neighbors = npred.getNeighborDBIDs(iditer);
final double median;
{
double[] fi = new double[neighbors.size()];
// calculate and store Median of neighborhood
int c = 0;
for(DBIDIter iter = neighbors.iter(); iter.valid(); iter.advance()) {
if(DBIDUtil.equal(iditer, iter)) {
continue;
}
fi[c] = relation.get(iter).doubleValue(0);
c++;
}
if(c > 0) {
median = QuickSelect.median(fi, 0, c);
}
else {
median = relation.get(iditer).doubleValue(0);
}
}
double h = relation.get(iditer).doubleValue(0) - median;
scores.putDouble(iditer, h);
mv.put(h);
}
// Normalize scores
final double mean = mv.getMean();
final double stddev = mv.getNaiveStddev();
DoubleMinMax minmax = new DoubleMinMax();
for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) {
double score = Math.abs((scores.doubleValue(iditer) - mean) / stddev);
minmax.put(score);
scores.putDouble(iditer, score);
}
DoubleRelation scoreResult = new MaterializedDoubleRelation("MO", "Median-outlier", scores, relation.getDBIDs());
OutlierScoreMeta scoreMeta = new BasicOutlierScoreMeta(minmax.getMin(), minmax.getMax(), 0.0, Double.POSITIVE_INFINITY, 0);
OutlierResult or = new OutlierResult(scoreMeta, scoreResult);
or.addChildResult(npred);
return or;
} | [
"public",
"OutlierResult",
"run",
"(",
"Database",
"database",
",",
"Relation",
"<",
"N",
">",
"nrel",
",",
"Relation",
"<",
"?",
"extends",
"NumberVector",
">",
"relation",
")",
"{",
"final",
"NeighborSetPredicate",
"npred",
"=",
"getNeighborSetPredicateFactory",
"(",
")",
".",
"instantiate",
"(",
"database",
",",
"nrel",
")",
";",
"WritableDoubleDataStore",
"scores",
"=",
"DataStoreUtil",
".",
"makeDoubleStorage",
"(",
"relation",
".",
"getDBIDs",
"(",
")",
",",
"DataStoreFactory",
".",
"HINT_STATIC",
")",
";",
"MeanVariance",
"mv",
"=",
"new",
"MeanVariance",
"(",
")",
";",
"for",
"(",
"DBIDIter",
"iditer",
"=",
"relation",
".",
"iterDBIDs",
"(",
")",
";",
"iditer",
".",
"valid",
"(",
")",
";",
"iditer",
".",
"advance",
"(",
")",
")",
"{",
"DBIDs",
"neighbors",
"=",
"npred",
".",
"getNeighborDBIDs",
"(",
"iditer",
")",
";",
"final",
"double",
"median",
";",
"{",
"double",
"[",
"]",
"fi",
"=",
"new",
"double",
"[",
"neighbors",
".",
"size",
"(",
")",
"]",
";",
"// calculate and store Median of neighborhood",
"int",
"c",
"=",
"0",
";",
"for",
"(",
"DBIDIter",
"iter",
"=",
"neighbors",
".",
"iter",
"(",
")",
";",
"iter",
".",
"valid",
"(",
")",
";",
"iter",
".",
"advance",
"(",
")",
")",
"{",
"if",
"(",
"DBIDUtil",
".",
"equal",
"(",
"iditer",
",",
"iter",
")",
")",
"{",
"continue",
";",
"}",
"fi",
"[",
"c",
"]",
"=",
"relation",
".",
"get",
"(",
"iter",
")",
".",
"doubleValue",
"(",
"0",
")",
";",
"c",
"++",
";",
"}",
"if",
"(",
"c",
">",
"0",
")",
"{",
"median",
"=",
"QuickSelect",
".",
"median",
"(",
"fi",
",",
"0",
",",
"c",
")",
";",
"}",
"else",
"{",
"median",
"=",
"relation",
".",
"get",
"(",
"iditer",
")",
".",
"doubleValue",
"(",
"0",
")",
";",
"}",
"}",
"double",
"h",
"=",
"relation",
".",
"get",
"(",
"iditer",
")",
".",
"doubleValue",
"(",
"0",
")",
"-",
"median",
";",
"scores",
".",
"putDouble",
"(",
"iditer",
",",
"h",
")",
";",
"mv",
".",
"put",
"(",
"h",
")",
";",
"}",
"// Normalize scores",
"final",
"double",
"mean",
"=",
"mv",
".",
"getMean",
"(",
")",
";",
"final",
"double",
"stddev",
"=",
"mv",
".",
"getNaiveStddev",
"(",
")",
";",
"DoubleMinMax",
"minmax",
"=",
"new",
"DoubleMinMax",
"(",
")",
";",
"for",
"(",
"DBIDIter",
"iditer",
"=",
"relation",
".",
"iterDBIDs",
"(",
")",
";",
"iditer",
".",
"valid",
"(",
")",
";",
"iditer",
".",
"advance",
"(",
")",
")",
"{",
"double",
"score",
"=",
"Math",
".",
"abs",
"(",
"(",
"scores",
".",
"doubleValue",
"(",
"iditer",
")",
"-",
"mean",
")",
"/",
"stddev",
")",
";",
"minmax",
".",
"put",
"(",
"score",
")",
";",
"scores",
".",
"putDouble",
"(",
"iditer",
",",
"score",
")",
";",
"}",
"DoubleRelation",
"scoreResult",
"=",
"new",
"MaterializedDoubleRelation",
"(",
"\"MO\"",
",",
"\"Median-outlier\"",
",",
"scores",
",",
"relation",
".",
"getDBIDs",
"(",
")",
")",
";",
"OutlierScoreMeta",
"scoreMeta",
"=",
"new",
"BasicOutlierScoreMeta",
"(",
"minmax",
".",
"getMin",
"(",
")",
",",
"minmax",
".",
"getMax",
"(",
")",
",",
"0.0",
",",
"Double",
".",
"POSITIVE_INFINITY",
",",
"0",
")",
";",
"OutlierResult",
"or",
"=",
"new",
"OutlierResult",
"(",
"scoreMeta",
",",
"scoreResult",
")",
";",
"or",
".",
"addChildResult",
"(",
"npred",
")",
";",
"return",
"or",
";",
"}"
] | Main method.
@param database Database
@param nrel Neighborhood relation
@param relation Data relation (1d!)
@return Outlier detection result | [
"Main",
"method",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/spatial/CTLuMedianAlgorithm.java#L97-L144 |
joniles/mpxj | src/main/java/net/sf/mpxj/mspdi/DatatypeConverter.java | DatatypeConverter.parseExtendedAttribute | public static final void parseExtendedAttribute(ProjectFile file, FieldContainer mpx, String value, FieldType mpxFieldID, TimeUnit durationFormat) {
"""
Parse an extended attribute value.
@param file parent file
@param mpx parent entity
@param value string value
@param mpxFieldID field ID
@param durationFormat duration format associated with the extended attribute
"""
if (mpxFieldID != null)
{
switch (mpxFieldID.getDataType())
{
case STRING:
{
mpx.set(mpxFieldID, value);
break;
}
case DATE:
{
mpx.set(mpxFieldID, parseExtendedAttributeDate(value));
break;
}
case CURRENCY:
{
mpx.set(mpxFieldID, parseExtendedAttributeCurrency(value));
break;
}
case BOOLEAN:
{
mpx.set(mpxFieldID, parseExtendedAttributeBoolean(value));
break;
}
case NUMERIC:
{
mpx.set(mpxFieldID, parseExtendedAttributeNumber(value));
break;
}
case DURATION:
{
mpx.set(mpxFieldID, parseDuration(file, durationFormat, value));
break;
}
default:
{
break;
}
}
}
} | java | public static final void parseExtendedAttribute(ProjectFile file, FieldContainer mpx, String value, FieldType mpxFieldID, TimeUnit durationFormat)
{
if (mpxFieldID != null)
{
switch (mpxFieldID.getDataType())
{
case STRING:
{
mpx.set(mpxFieldID, value);
break;
}
case DATE:
{
mpx.set(mpxFieldID, parseExtendedAttributeDate(value));
break;
}
case CURRENCY:
{
mpx.set(mpxFieldID, parseExtendedAttributeCurrency(value));
break;
}
case BOOLEAN:
{
mpx.set(mpxFieldID, parseExtendedAttributeBoolean(value));
break;
}
case NUMERIC:
{
mpx.set(mpxFieldID, parseExtendedAttributeNumber(value));
break;
}
case DURATION:
{
mpx.set(mpxFieldID, parseDuration(file, durationFormat, value));
break;
}
default:
{
break;
}
}
}
} | [
"public",
"static",
"final",
"void",
"parseExtendedAttribute",
"(",
"ProjectFile",
"file",
",",
"FieldContainer",
"mpx",
",",
"String",
"value",
",",
"FieldType",
"mpxFieldID",
",",
"TimeUnit",
"durationFormat",
")",
"{",
"if",
"(",
"mpxFieldID",
"!=",
"null",
")",
"{",
"switch",
"(",
"mpxFieldID",
".",
"getDataType",
"(",
")",
")",
"{",
"case",
"STRING",
":",
"{",
"mpx",
".",
"set",
"(",
"mpxFieldID",
",",
"value",
")",
";",
"break",
";",
"}",
"case",
"DATE",
":",
"{",
"mpx",
".",
"set",
"(",
"mpxFieldID",
",",
"parseExtendedAttributeDate",
"(",
"value",
")",
")",
";",
"break",
";",
"}",
"case",
"CURRENCY",
":",
"{",
"mpx",
".",
"set",
"(",
"mpxFieldID",
",",
"parseExtendedAttributeCurrency",
"(",
"value",
")",
")",
";",
"break",
";",
"}",
"case",
"BOOLEAN",
":",
"{",
"mpx",
".",
"set",
"(",
"mpxFieldID",
",",
"parseExtendedAttributeBoolean",
"(",
"value",
")",
")",
";",
"break",
";",
"}",
"case",
"NUMERIC",
":",
"{",
"mpx",
".",
"set",
"(",
"mpxFieldID",
",",
"parseExtendedAttributeNumber",
"(",
"value",
")",
")",
";",
"break",
";",
"}",
"case",
"DURATION",
":",
"{",
"mpx",
".",
"set",
"(",
"mpxFieldID",
",",
"parseDuration",
"(",
"file",
",",
"durationFormat",
",",
"value",
")",
")",
";",
"break",
";",
"}",
"default",
":",
"{",
"break",
";",
"}",
"}",
"}",
"}"
] | Parse an extended attribute value.
@param file parent file
@param mpx parent entity
@param value string value
@param mpxFieldID field ID
@param durationFormat duration format associated with the extended attribute | [
"Parse",
"an",
"extended",
"attribute",
"value",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mspdi/DatatypeConverter.java#L239-L287 |
albfernandez/itext2 | src/main/java/com/lowagie/text/pdf/HyphenationAuto.java | HyphenationAuto.getHyphenatedWordPre | public String getHyphenatedWordPre(String word, BaseFont font, float fontSize, float remainingWidth) {
"""
Hyphenates a word and returns the first part of it. To get
the second part of the hyphenated word call <CODE>getHyphenatedWordPost()</CODE>.
@param word the word to hyphenate
@param font the font used by this word
@param fontSize the font size used by this word
@param remainingWidth the width available to fit this word in
@return the first part of the hyphenated word including
the hyphen symbol, if any
"""
post = word;
String hyphen = getHyphenSymbol();
float hyphenWidth = font.getWidthPoint(hyphen, fontSize);
if (hyphenWidth > remainingWidth)
return "";
Hyphenation hyphenation = hyphenator.hyphenate(word);
if (hyphenation == null) {
return "";
}
int len = hyphenation.length();
int k;
for (k = 0; k < len; ++k) {
if (font.getWidthPoint(hyphenation.getPreHyphenText(k), fontSize) + hyphenWidth > remainingWidth)
break;
}
--k;
if (k < 0)
return "";
post = hyphenation.getPostHyphenText(k);
return hyphenation.getPreHyphenText(k) + hyphen;
} | java | public String getHyphenatedWordPre(String word, BaseFont font, float fontSize, float remainingWidth) {
post = word;
String hyphen = getHyphenSymbol();
float hyphenWidth = font.getWidthPoint(hyphen, fontSize);
if (hyphenWidth > remainingWidth)
return "";
Hyphenation hyphenation = hyphenator.hyphenate(word);
if (hyphenation == null) {
return "";
}
int len = hyphenation.length();
int k;
for (k = 0; k < len; ++k) {
if (font.getWidthPoint(hyphenation.getPreHyphenText(k), fontSize) + hyphenWidth > remainingWidth)
break;
}
--k;
if (k < 0)
return "";
post = hyphenation.getPostHyphenText(k);
return hyphenation.getPreHyphenText(k) + hyphen;
} | [
"public",
"String",
"getHyphenatedWordPre",
"(",
"String",
"word",
",",
"BaseFont",
"font",
",",
"float",
"fontSize",
",",
"float",
"remainingWidth",
")",
"{",
"post",
"=",
"word",
";",
"String",
"hyphen",
"=",
"getHyphenSymbol",
"(",
")",
";",
"float",
"hyphenWidth",
"=",
"font",
".",
"getWidthPoint",
"(",
"hyphen",
",",
"fontSize",
")",
";",
"if",
"(",
"hyphenWidth",
">",
"remainingWidth",
")",
"return",
"\"\"",
";",
"Hyphenation",
"hyphenation",
"=",
"hyphenator",
".",
"hyphenate",
"(",
"word",
")",
";",
"if",
"(",
"hyphenation",
"==",
"null",
")",
"{",
"return",
"\"\"",
";",
"}",
"int",
"len",
"=",
"hyphenation",
".",
"length",
"(",
")",
";",
"int",
"k",
";",
"for",
"(",
"k",
"=",
"0",
";",
"k",
"<",
"len",
";",
"++",
"k",
")",
"{",
"if",
"(",
"font",
".",
"getWidthPoint",
"(",
"hyphenation",
".",
"getPreHyphenText",
"(",
"k",
")",
",",
"fontSize",
")",
"+",
"hyphenWidth",
">",
"remainingWidth",
")",
"break",
";",
"}",
"--",
"k",
";",
"if",
"(",
"k",
"<",
"0",
")",
"return",
"\"\"",
";",
"post",
"=",
"hyphenation",
".",
"getPostHyphenText",
"(",
"k",
")",
";",
"return",
"hyphenation",
".",
"getPreHyphenText",
"(",
"k",
")",
"+",
"hyphen",
";",
"}"
] | Hyphenates a word and returns the first part of it. To get
the second part of the hyphenated word call <CODE>getHyphenatedWordPost()</CODE>.
@param word the word to hyphenate
@param font the font used by this word
@param fontSize the font size used by this word
@param remainingWidth the width available to fit this word in
@return the first part of the hyphenated word including
the hyphen symbol, if any | [
"Hyphenates",
"a",
"word",
"and",
"returns",
"the",
"first",
"part",
"of",
"it",
".",
"To",
"get",
"the",
"second",
"part",
"of",
"the",
"hyphenated",
"word",
"call",
"<CODE",
">",
"getHyphenatedWordPost",
"()",
"<",
"/",
"CODE",
">",
"."
] | train | https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/pdf/HyphenationAuto.java#L94-L115 |
GII/broccoli | broccoli-owls/src/main/java/com/hi3project/broccoli/bsdf/impl/owl/OWLValueObject.java | OWLValueObject.buildFromCollection | public static OWLValueObject buildFromCollection(OWLModel model, Collection col) throws NotYetImplementedException, OWLTranslationException {
"""
Builds an instance, from a given collection
@param model
@param col
@return
@throws NotYetImplementedException
@throws OWLTranslationException
"""
if (col.isEmpty()) {
return null;
}
return buildFromClasAndCollection(model, OWLURIClass.from(col.iterator().next()), col);
} | java | public static OWLValueObject buildFromCollection(OWLModel model, Collection col) throws NotYetImplementedException, OWLTranslationException {
if (col.isEmpty()) {
return null;
}
return buildFromClasAndCollection(model, OWLURIClass.from(col.iterator().next()), col);
} | [
"public",
"static",
"OWLValueObject",
"buildFromCollection",
"(",
"OWLModel",
"model",
",",
"Collection",
"col",
")",
"throws",
"NotYetImplementedException",
",",
"OWLTranslationException",
"{",
"if",
"(",
"col",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"buildFromClasAndCollection",
"(",
"model",
",",
"OWLURIClass",
".",
"from",
"(",
"col",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
")",
",",
"col",
")",
";",
"}"
] | Builds an instance, from a given collection
@param model
@param col
@return
@throws NotYetImplementedException
@throws OWLTranslationException | [
"Builds",
"an",
"instance",
"from",
"a",
"given",
"collection"
] | train | https://github.com/GII/broccoli/blob/a3033a90322cbcee4dc0f1719143b84b822bc4ba/broccoli-owls/src/main/java/com/hi3project/broccoli/bsdf/impl/owl/OWLValueObject.java#L159-L164 |
radkovo/SwingBox | src/main/java/org/fit/cssbox/swingbox/view/DelegateView.java | DelegateView.preferenceChanged | @Override
public void preferenceChanged(View child, boolean width, boolean height) {
"""
Specifies that a preference has changed. Child views can call this on the
parent to indicate that the preference has changed. The root view routes
this to invalidate on the hosting component.
<p>
This can be called on a different thread from the event dispatching
thread and is basically unsafe to propagate into the component. To make
this safe, the operation is transferred over to the event dispatching
thread for completion. It is a design goal that all view methods be safe
to call without concern for concurrency, and this behavior helps make
that true.
@param child
the child view
@param width
true if the width preference has changed
@param height
true if the height preference has changed
"""
if (parent != null)
{
parent.preferenceChanged(child, width, height);
}
} | java | @Override
public void preferenceChanged(View child, boolean width, boolean height)
{
if (parent != null)
{
parent.preferenceChanged(child, width, height);
}
} | [
"@",
"Override",
"public",
"void",
"preferenceChanged",
"(",
"View",
"child",
",",
"boolean",
"width",
",",
"boolean",
"height",
")",
"{",
"if",
"(",
"parent",
"!=",
"null",
")",
"{",
"parent",
".",
"preferenceChanged",
"(",
"child",
",",
"width",
",",
"height",
")",
";",
"}",
"}"
] | Specifies that a preference has changed. Child views can call this on the
parent to indicate that the preference has changed. The root view routes
this to invalidate on the hosting component.
<p>
This can be called on a different thread from the event dispatching
thread and is basically unsafe to propagate into the component. To make
this safe, the operation is transferred over to the event dispatching
thread for completion. It is a design goal that all view methods be safe
to call without concern for concurrency, and this behavior helps make
that true.
@param child
the child view
@param width
true if the width preference has changed
@param height
true if the height preference has changed | [
"Specifies",
"that",
"a",
"preference",
"has",
"changed",
".",
"Child",
"views",
"can",
"call",
"this",
"on",
"the",
"parent",
"to",
"indicate",
"that",
"the",
"preference",
"has",
"changed",
".",
"The",
"root",
"view",
"routes",
"this",
"to",
"invalidate",
"on",
"the",
"hosting",
"component",
".",
"<p",
">",
"This",
"can",
"be",
"called",
"on",
"a",
"different",
"thread",
"from",
"the",
"event",
"dispatching",
"thread",
"and",
"is",
"basically",
"unsafe",
"to",
"propagate",
"into",
"the",
"component",
".",
"To",
"make",
"this",
"safe",
"the",
"operation",
"is",
"transferred",
"over",
"to",
"the",
"event",
"dispatching",
"thread",
"for",
"completion",
".",
"It",
"is",
"a",
"design",
"goal",
"that",
"all",
"view",
"methods",
"be",
"safe",
"to",
"call",
"without",
"concern",
"for",
"concurrency",
"and",
"this",
"behavior",
"helps",
"make",
"that",
"true",
"."
] | train | https://github.com/radkovo/SwingBox/blob/ff370f3dc54d248e4c8852c17513618c83c25984/src/main/java/org/fit/cssbox/swingbox/view/DelegateView.java#L246-L253 |
ontop/ontop | engine/system/core/src/main/java/it/unibz/inf/ontop/utils/querymanager/QueryController.java | QueryController.createGroup | public void createGroup(String groupId) throws Exception {
"""
Creates a new group and adds it to the vector QueryControllerEntity
"""
if (getElementPosition(groupId) == -1) {
QueryControllerGroup group = new QueryControllerGroup(groupId);
entities.add(group);
fireElementAdded(group);
}
else {
throw new Exception("The name is already taken, either by a query group or a query item");
}
} | java | public void createGroup(String groupId) throws Exception {
if (getElementPosition(groupId) == -1) {
QueryControllerGroup group = new QueryControllerGroup(groupId);
entities.add(group);
fireElementAdded(group);
}
else {
throw new Exception("The name is already taken, either by a query group or a query item");
}
} | [
"public",
"void",
"createGroup",
"(",
"String",
"groupId",
")",
"throws",
"Exception",
"{",
"if",
"(",
"getElementPosition",
"(",
"groupId",
")",
"==",
"-",
"1",
")",
"{",
"QueryControllerGroup",
"group",
"=",
"new",
"QueryControllerGroup",
"(",
"groupId",
")",
";",
"entities",
".",
"add",
"(",
"group",
")",
";",
"fireElementAdded",
"(",
"group",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"\"The name is already taken, either by a query group or a query item\"",
")",
";",
"}",
"}"
] | Creates a new group and adds it to the vector QueryControllerEntity | [
"Creates",
"a",
"new",
"group",
"and",
"adds",
"it",
"to",
"the",
"vector",
"QueryControllerEntity"
] | train | https://github.com/ontop/ontop/blob/ddf78b26981b6129ee9a1a59310016830f5352e4/engine/system/core/src/main/java/it/unibz/inf/ontop/utils/querymanager/QueryController.java#L64-L73 |
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.updateEntityAsync | public Observable<OperationStatus> updateEntityAsync(UUID appId, String versionId, UUID entityId, UpdateEntityOptionalParameter updateEntityOptionalParameter) {
"""
Updates the name of an entity extractor.
@param appId The application ID.
@param versionId The version ID.
@param entityId The entity extractor ID.
@param updateEntityOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the OperationStatus object
"""
return updateEntityWithServiceResponseAsync(appId, versionId, entityId, updateEntityOptionalParameter).map(new Func1<ServiceResponse<OperationStatus>, OperationStatus>() {
@Override
public OperationStatus call(ServiceResponse<OperationStatus> response) {
return response.body();
}
});
} | java | public Observable<OperationStatus> updateEntityAsync(UUID appId, String versionId, UUID entityId, UpdateEntityOptionalParameter updateEntityOptionalParameter) {
return updateEntityWithServiceResponseAsync(appId, versionId, entityId, updateEntityOptionalParameter).map(new Func1<ServiceResponse<OperationStatus>, OperationStatus>() {
@Override
public OperationStatus call(ServiceResponse<OperationStatus> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"OperationStatus",
">",
"updateEntityAsync",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"UUID",
"entityId",
",",
"UpdateEntityOptionalParameter",
"updateEntityOptionalParameter",
")",
"{",
"return",
"updateEntityWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"entityId",
",",
"updateEntityOptionalParameter",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"OperationStatus",
">",
",",
"OperationStatus",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"OperationStatus",
"call",
"(",
"ServiceResponse",
"<",
"OperationStatus",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Updates the name of an entity extractor.
@param appId The application ID.
@param versionId The version ID.
@param entityId The entity extractor ID.
@param updateEntityOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the OperationStatus object | [
"Updates",
"the",
"name",
"of",
"an",
"entity",
"extractor",
"."
] | 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#L3407-L3414 |
openskynetwork/java-adsb | src/main/java/org/opensky/libadsb/PositionDecoder.java | PositionDecoder.decodePosition | public Position decodePosition(double time, Position receiver, SurfacePositionV0Msg msg, Position reference) {
"""
Performs all reasonableness tests.
@param time time of applicability/reception of position report (seconds)
@param reference position used to decide which position of the four results of the CPR algorithm is the right one
@param receiver position to check if received position was more than 700km away and
@param msg surface position message
@return WGS84 coordinates with latitude and longitude in dec degrees, and altitude in meters. altitude might be null if unavailable
On error, the returned position is null. Check the .isReasonable() flag before using the position.
"""
Position ret = decodePosition(time, msg, reference);
if (ret != null && receiver != null && !withinReasonableRange(receiver, ret)) {
ret.setReasonable(false);
num_reasonable = 0;
}
return ret;
} | java | public Position decodePosition(double time, Position receiver, SurfacePositionV0Msg msg, Position reference) {
Position ret = decodePosition(time, msg, reference);
if (ret != null && receiver != null && !withinReasonableRange(receiver, ret)) {
ret.setReasonable(false);
num_reasonable = 0;
}
return ret;
} | [
"public",
"Position",
"decodePosition",
"(",
"double",
"time",
",",
"Position",
"receiver",
",",
"SurfacePositionV0Msg",
"msg",
",",
"Position",
"reference",
")",
"{",
"Position",
"ret",
"=",
"decodePosition",
"(",
"time",
",",
"msg",
",",
"reference",
")",
";",
"if",
"(",
"ret",
"!=",
"null",
"&&",
"receiver",
"!=",
"null",
"&&",
"!",
"withinReasonableRange",
"(",
"receiver",
",",
"ret",
")",
")",
"{",
"ret",
".",
"setReasonable",
"(",
"false",
")",
";",
"num_reasonable",
"=",
"0",
";",
"}",
"return",
"ret",
";",
"}"
] | Performs all reasonableness tests.
@param time time of applicability/reception of position report (seconds)
@param reference position used to decide which position of the four results of the CPR algorithm is the right one
@param receiver position to check if received position was more than 700km away and
@param msg surface position message
@return WGS84 coordinates with latitude and longitude in dec degrees, and altitude in meters. altitude might be null if unavailable
On error, the returned position is null. Check the .isReasonable() flag before using the position. | [
"Performs",
"all",
"reasonableness",
"tests",
"."
] | train | https://github.com/openskynetwork/java-adsb/blob/01d497d3e74ad10063ab443ab583e9c8653a8b8d/src/main/java/org/opensky/libadsb/PositionDecoder.java#L474-L481 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/matchspace/selector/impl/ParseUtil.java | ParseUtil.convertLike | static Selector convertLike(Selector arg, String pattern, String escape) {
"""
Convert a partially parsed LIKE expression, in which the pattern and escape are
in the form of token images, to the proper Selector expression to represent
the LIKE expression
@param arg the argument of the like
@param pattern the pattern image (still containing leading and trailing ')
@param escape the escape (still containing leading and trailing ') or null
@return an appropriate Selector or null if the pattern and/or escape are
syntactically invalid
"""
try
{
pattern = reduceStringLiteralToken(pattern);
boolean escaped = false;
char esc = 0;
if (escape != null) {
escape = reduceStringLiteralToken(escape);
if (escape.length() != 1)
return null;
escaped = true;
esc = escape.charAt(0);
}
return Matching.getInstance().createLikeOperator(arg, pattern, escaped, esc);
}
catch (Exception e)
{
// No FFDC Code Needed.
// FFDC driven by wrapper class.
FFDC.processException(cclass,
"com.ibm.ws.sib.matchspace.selector.impl.ParseUtil.convertLike",
e,
"1:183:1.19");
// This should never occur as to get into this we should be missing
// the sib.matchspace jar file, but we are already in it.
throw new RuntimeException(e);
}
} | java | static Selector convertLike(Selector arg, String pattern, String escape) {
try
{
pattern = reduceStringLiteralToken(pattern);
boolean escaped = false;
char esc = 0;
if (escape != null) {
escape = reduceStringLiteralToken(escape);
if (escape.length() != 1)
return null;
escaped = true;
esc = escape.charAt(0);
}
return Matching.getInstance().createLikeOperator(arg, pattern, escaped, esc);
}
catch (Exception e)
{
// No FFDC Code Needed.
// FFDC driven by wrapper class.
FFDC.processException(cclass,
"com.ibm.ws.sib.matchspace.selector.impl.ParseUtil.convertLike",
e,
"1:183:1.19");
// This should never occur as to get into this we should be missing
// the sib.matchspace jar file, but we are already in it.
throw new RuntimeException(e);
}
} | [
"static",
"Selector",
"convertLike",
"(",
"Selector",
"arg",
",",
"String",
"pattern",
",",
"String",
"escape",
")",
"{",
"try",
"{",
"pattern",
"=",
"reduceStringLiteralToken",
"(",
"pattern",
")",
";",
"boolean",
"escaped",
"=",
"false",
";",
"char",
"esc",
"=",
"0",
";",
"if",
"(",
"escape",
"!=",
"null",
")",
"{",
"escape",
"=",
"reduceStringLiteralToken",
"(",
"escape",
")",
";",
"if",
"(",
"escape",
".",
"length",
"(",
")",
"!=",
"1",
")",
"return",
"null",
";",
"escaped",
"=",
"true",
";",
"esc",
"=",
"escape",
".",
"charAt",
"(",
"0",
")",
";",
"}",
"return",
"Matching",
".",
"getInstance",
"(",
")",
".",
"createLikeOperator",
"(",
"arg",
",",
"pattern",
",",
"escaped",
",",
"esc",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// No FFDC Code Needed.",
"// FFDC driven by wrapper class.",
"FFDC",
".",
"processException",
"(",
"cclass",
",",
"\"com.ibm.ws.sib.matchspace.selector.impl.ParseUtil.convertLike\"",
",",
"e",
",",
"\"1:183:1.19\"",
")",
";",
"// This should never occur as to get into this we should be missing",
"// the sib.matchspace jar file, but we are already in it.",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] | Convert a partially parsed LIKE expression, in which the pattern and escape are
in the form of token images, to the proper Selector expression to represent
the LIKE expression
@param arg the argument of the like
@param pattern the pattern image (still containing leading and trailing ')
@param escape the escape (still containing leading and trailing ') or null
@return an appropriate Selector or null if the pattern and/or escape are
syntactically invalid | [
"Convert",
"a",
"partially",
"parsed",
"LIKE",
"expression",
"in",
"which",
"the",
"pattern",
"and",
"escape",
"are",
"in",
"the",
"form",
"of",
"token",
"images",
"to",
"the",
"proper",
"Selector",
"expression",
"to",
"represent",
"the",
"LIKE",
"expression"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/matchspace/selector/impl/ParseUtil.java#L139-L167 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/text/AttributedString.java | AttributedString.addAttribute | public void addAttribute(Attribute attribute, Object value) {
"""
Adds an attribute to the entire string.
@param attribute the attribute key
@param value the value of the attribute; may be null
@exception NullPointerException if <code>attribute</code> is null.
@exception IllegalArgumentException if the AttributedString has length 0
(attributes cannot be applied to a 0-length range).
"""
if (attribute == null) {
throw new NullPointerException();
}
int len = length();
if (len == 0) {
throw new IllegalArgumentException("Can't add attribute to 0-length text");
}
addAttributeImpl(attribute, value, 0, len);
} | java | public void addAttribute(Attribute attribute, Object value) {
if (attribute == null) {
throw new NullPointerException();
}
int len = length();
if (len == 0) {
throw new IllegalArgumentException("Can't add attribute to 0-length text");
}
addAttributeImpl(attribute, value, 0, len);
} | [
"public",
"void",
"addAttribute",
"(",
"Attribute",
"attribute",
",",
"Object",
"value",
")",
"{",
"if",
"(",
"attribute",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"}",
"int",
"len",
"=",
"length",
"(",
")",
";",
"if",
"(",
"len",
"==",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Can't add attribute to 0-length text\"",
")",
";",
"}",
"addAttributeImpl",
"(",
"attribute",
",",
"value",
",",
"0",
",",
"len",
")",
";",
"}"
] | Adds an attribute to the entire string.
@param attribute the attribute key
@param value the value of the attribute; may be null
@exception NullPointerException if <code>attribute</code> is null.
@exception IllegalArgumentException if the AttributedString has length 0
(attributes cannot be applied to a 0-length range). | [
"Adds",
"an",
"attribute",
"to",
"the",
"entire",
"string",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/text/AttributedString.java#L316-L328 |
ical4j/ical4j | src/main/java/net/fortuna/ical4j/model/property/DateProperty.java | DateProperty.setValue | public void setValue(final String value) throws ParseException {
"""
Default setValue() implementation. Allows for either DATE or DATE-TIME values.
@param value a string representation of a DATE or DATE-TIME value
@throws ParseException where the specified value is not a valid DATE or DATE-TIME
representation
"""
// value can be either a date-time or a date..
if (Value.DATE.equals(getParameter(Parameter.VALUE))) {
// ensure timezone is null for VALUE=DATE properties..
updateTimeZone(null);
this.date = new Date(value);
} else if (value != null && !value.isEmpty()){
this.date = new DateTime(value, timeZone);
}
} | java | public void setValue(final String value) throws ParseException {
// value can be either a date-time or a date..
if (Value.DATE.equals(getParameter(Parameter.VALUE))) {
// ensure timezone is null for VALUE=DATE properties..
updateTimeZone(null);
this.date = new Date(value);
} else if (value != null && !value.isEmpty()){
this.date = new DateTime(value, timeZone);
}
} | [
"public",
"void",
"setValue",
"(",
"final",
"String",
"value",
")",
"throws",
"ParseException",
"{",
"// value can be either a date-time or a date..",
"if",
"(",
"Value",
".",
"DATE",
".",
"equals",
"(",
"getParameter",
"(",
"Parameter",
".",
"VALUE",
")",
")",
")",
"{",
"// ensure timezone is null for VALUE=DATE properties..",
"updateTimeZone",
"(",
"null",
")",
";",
"this",
".",
"date",
"=",
"new",
"Date",
"(",
"value",
")",
";",
"}",
"else",
"if",
"(",
"value",
"!=",
"null",
"&&",
"!",
"value",
".",
"isEmpty",
"(",
")",
")",
"{",
"this",
".",
"date",
"=",
"new",
"DateTime",
"(",
"value",
",",
"timeZone",
")",
";",
"}",
"}"
] | Default setValue() implementation. Allows for either DATE or DATE-TIME values.
@param value a string representation of a DATE or DATE-TIME value
@throws ParseException where the specified value is not a valid DATE or DATE-TIME
representation | [
"Default",
"setValue",
"()",
"implementation",
".",
"Allows",
"for",
"either",
"DATE",
"or",
"DATE",
"-",
"TIME",
"values",
"."
] | train | https://github.com/ical4j/ical4j/blob/7ac4bd1ce2bb2e0a2906fb69a56fbd2d9d974156/src/main/java/net/fortuna/ical4j/model/property/DateProperty.java#L130-L139 |
TNG/JGiven | jgiven-core/src/main/java/com/tngtech/jgiven/impl/util/ReflectionUtil.java | ReflectionUtil.forEachSuperClass | public static void forEachSuperClass( Class<?> clazz, ClassAction action ) {
"""
Iterates over all super classes of the given class (including the class itself)
and calls action.act() for these classes.
"""
try {
action.act( clazz );
Class<?> superclass = clazz.getSuperclass();
if( superclass != null ) {
forEachSuperClass( superclass, action );
}
} catch( Exception e ) {
throw Throwables.propagate( e );
}
} | java | public static void forEachSuperClass( Class<?> clazz, ClassAction action ) {
try {
action.act( clazz );
Class<?> superclass = clazz.getSuperclass();
if( superclass != null ) {
forEachSuperClass( superclass, action );
}
} catch( Exception e ) {
throw Throwables.propagate( e );
}
} | [
"public",
"static",
"void",
"forEachSuperClass",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"ClassAction",
"action",
")",
"{",
"try",
"{",
"action",
".",
"act",
"(",
"clazz",
")",
";",
"Class",
"<",
"?",
">",
"superclass",
"=",
"clazz",
".",
"getSuperclass",
"(",
")",
";",
"if",
"(",
"superclass",
"!=",
"null",
")",
"{",
"forEachSuperClass",
"(",
"superclass",
",",
"action",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"Throwables",
".",
"propagate",
"(",
"e",
")",
";",
"}",
"}"
] | Iterates over all super classes of the given class (including the class itself)
and calls action.act() for these classes. | [
"Iterates",
"over",
"all",
"super",
"classes",
"of",
"the",
"given",
"class",
"(",
"including",
"the",
"class",
"itself",
")",
"and",
"calls",
"action",
".",
"act",
"()",
"for",
"these",
"classes",
"."
] | train | https://github.com/TNG/JGiven/blob/1a69248fc6d7eb380cdc4542e3be273842889748/jgiven-core/src/main/java/com/tngtech/jgiven/impl/util/ReflectionUtil.java#L65-L76 |
Azure/azure-sdk-for-java | sql/resource-manager/v2017_03_01_preview/src/main/java/com/microsoft/azure/management/sql/v2017_03_01_preview/implementation/ManagedDatabasesInner.java | ManagedDatabasesInner.completeRestoreAsync | public Observable<Void> completeRestoreAsync(String locationName, UUID operationId, String lastBackupName) {
"""
Completes the restore operation on a managed database.
@param locationName The name of the region where the resource is located.
@param operationId Management operation id that this request tries to complete.
@param lastBackupName The last backup name to apply
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request
"""
return completeRestoreWithServiceResponseAsync(locationName, operationId, lastBackupName).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | java | public Observable<Void> completeRestoreAsync(String locationName, UUID operationId, String lastBackupName) {
return completeRestoreWithServiceResponseAsync(locationName, operationId, lastBackupName).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Void",
">",
"completeRestoreAsync",
"(",
"String",
"locationName",
",",
"UUID",
"operationId",
",",
"String",
"lastBackupName",
")",
"{",
"return",
"completeRestoreWithServiceResponseAsync",
"(",
"locationName",
",",
"operationId",
",",
"lastBackupName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Void",
">",
",",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
"ServiceResponse",
"<",
"Void",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Completes the restore operation on a managed database.
@param locationName The name of the region where the resource is located.
@param operationId Management operation id that this request tries to complete.
@param lastBackupName The last backup name to apply
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Completes",
"the",
"restore",
"operation",
"on",
"a",
"managed",
"database",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2017_03_01_preview/src/main/java/com/microsoft/azure/management/sql/v2017_03_01_preview/implementation/ManagedDatabasesInner.java#L152-L159 |
baratine/baratine | framework/src/main/java/com/caucho/v5/ramp/hamp/InHamp.java | InHamp.readStreamCancel | private void readStreamCancel(InH3 hIn, HeadersAmp headers)
throws IOException {
"""
The stream result message is a partial or final result from the target's
stream.
"""
ServiceRefAmp serviceRef = readToAddress(hIn);
GatewayReply from = readFromAddress(hIn);
long qid = hIn.readLong();
if (log.isLoggable(_logLevel)) {
log.log(_logLevel, "stream-cancel-r " + from + "," + qid + " (in " + this + ")"
+ "\n {id:" + qid + ", to:" + serviceRef + "," + headers + "}");
}
from.streamCancel(qid);
} | java | private void readStreamCancel(InH3 hIn, HeadersAmp headers)
throws IOException
{
ServiceRefAmp serviceRef = readToAddress(hIn);
GatewayReply from = readFromAddress(hIn);
long qid = hIn.readLong();
if (log.isLoggable(_logLevel)) {
log.log(_logLevel, "stream-cancel-r " + from + "," + qid + " (in " + this + ")"
+ "\n {id:" + qid + ", to:" + serviceRef + "," + headers + "}");
}
from.streamCancel(qid);
} | [
"private",
"void",
"readStreamCancel",
"(",
"InH3",
"hIn",
",",
"HeadersAmp",
"headers",
")",
"throws",
"IOException",
"{",
"ServiceRefAmp",
"serviceRef",
"=",
"readToAddress",
"(",
"hIn",
")",
";",
"GatewayReply",
"from",
"=",
"readFromAddress",
"(",
"hIn",
")",
";",
"long",
"qid",
"=",
"hIn",
".",
"readLong",
"(",
")",
";",
"if",
"(",
"log",
".",
"isLoggable",
"(",
"_logLevel",
")",
")",
"{",
"log",
".",
"log",
"(",
"_logLevel",
",",
"\"stream-cancel-r \"",
"+",
"from",
"+",
"\",\"",
"+",
"qid",
"+",
"\" (in \"",
"+",
"this",
"+",
"\")\"",
"+",
"\"\\n {id:\"",
"+",
"qid",
"+",
"\", to:\"",
"+",
"serviceRef",
"+",
"\",\"",
"+",
"headers",
"+",
"\"}\"",
")",
";",
"}",
"from",
".",
"streamCancel",
"(",
"qid",
")",
";",
"}"
] | The stream result message is a partial or final result from the target's
stream. | [
"The",
"stream",
"result",
"message",
"is",
"a",
"partial",
"or",
"final",
"result",
"from",
"the",
"target",
"s",
"stream",
"."
] | train | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/ramp/hamp/InHamp.java#L750-L765 |
leancloud/java-sdk-all | core/src/main/java/cn/leancloud/AVObject.java | AVObject.createWithoutData | public static AVObject createWithoutData(String className, String objectId) {
"""
create a new instance with particular classname and objectId.
@param className class name
@param objectId object id
@return
"""
AVObject object = new AVObject(className);
object.setObjectId(objectId);
return object;
} | java | public static AVObject createWithoutData(String className, String objectId) {
AVObject object = new AVObject(className);
object.setObjectId(objectId);
return object;
} | [
"public",
"static",
"AVObject",
"createWithoutData",
"(",
"String",
"className",
",",
"String",
"objectId",
")",
"{",
"AVObject",
"object",
"=",
"new",
"AVObject",
"(",
"className",
")",
";",
"object",
".",
"setObjectId",
"(",
"objectId",
")",
";",
"return",
"object",
";",
"}"
] | create a new instance with particular classname and objectId.
@param className class name
@param objectId object id
@return | [
"create",
"a",
"new",
"instance",
"with",
"particular",
"classname",
"and",
"objectId",
"."
] | train | https://github.com/leancloud/java-sdk-all/blob/323f8e7ee38051b1350790e5192304768c5c9f5f/core/src/main/java/cn/leancloud/AVObject.java#L1006-L1010 |
HotelsDotCom/corc | corc-cascading/src/main/java/com/hotels/corc/cascading/OrcFile.java | OrcFile.sourcePrepare | @Override
public void sourcePrepare(FlowProcess<? extends Configuration> flowProcess, SourceCall<Corc, RecordReader> sourceCall)
throws IOException {
"""
Creates an {@link Corc} instance and stores it in the context to be reused for all rows.
"""
sourceCall.setContext((Corc) sourceCall.getInput().createValue());
} | java | @Override
public void sourcePrepare(FlowProcess<? extends Configuration> flowProcess, SourceCall<Corc, RecordReader> sourceCall)
throws IOException {
sourceCall.setContext((Corc) sourceCall.getInput().createValue());
} | [
"@",
"Override",
"public",
"void",
"sourcePrepare",
"(",
"FlowProcess",
"<",
"?",
"extends",
"Configuration",
">",
"flowProcess",
",",
"SourceCall",
"<",
"Corc",
",",
"RecordReader",
">",
"sourceCall",
")",
"throws",
"IOException",
"{",
"sourceCall",
".",
"setContext",
"(",
"(",
"Corc",
")",
"sourceCall",
".",
"getInput",
"(",
")",
".",
"createValue",
"(",
")",
")",
";",
"}"
] | Creates an {@link Corc} instance and stores it in the context to be reused for all rows. | [
"Creates",
"an",
"{"
] | train | https://github.com/HotelsDotCom/corc/blob/37ecb5966315e4cf630a878ffcbada61c50bdcd3/corc-cascading/src/main/java/com/hotels/corc/cascading/OrcFile.java#L160-L164 |
apereo/cas | support/cas-server-support-oauth-core-api/src/main/java/org/apereo/cas/support/oauth/util/OAuth20Utils.java | OAuth20Utils.writeError | public static ModelAndView writeError(final HttpServletResponse response, final String error) {
"""
Write to the output this error.
@param response the response
@param error error message
@return json -backed view.
"""
val model = CollectionUtils.wrap(OAuth20Constants.ERROR, error);
val mv = new ModelAndView(new MappingJackson2JsonView(MAPPER), (Map) model);
mv.setStatus(HttpStatus.BAD_REQUEST);
response.setStatus(HttpStatus.BAD_REQUEST.value());
return mv;
} | java | public static ModelAndView writeError(final HttpServletResponse response, final String error) {
val model = CollectionUtils.wrap(OAuth20Constants.ERROR, error);
val mv = new ModelAndView(new MappingJackson2JsonView(MAPPER), (Map) model);
mv.setStatus(HttpStatus.BAD_REQUEST);
response.setStatus(HttpStatus.BAD_REQUEST.value());
return mv;
} | [
"public",
"static",
"ModelAndView",
"writeError",
"(",
"final",
"HttpServletResponse",
"response",
",",
"final",
"String",
"error",
")",
"{",
"val",
"model",
"=",
"CollectionUtils",
".",
"wrap",
"(",
"OAuth20Constants",
".",
"ERROR",
",",
"error",
")",
";",
"val",
"mv",
"=",
"new",
"ModelAndView",
"(",
"new",
"MappingJackson2JsonView",
"(",
"MAPPER",
")",
",",
"(",
"Map",
")",
"model",
")",
";",
"mv",
".",
"setStatus",
"(",
"HttpStatus",
".",
"BAD_REQUEST",
")",
";",
"response",
".",
"setStatus",
"(",
"HttpStatus",
".",
"BAD_REQUEST",
".",
"value",
"(",
")",
")",
";",
"return",
"mv",
";",
"}"
] | Write to the output this error.
@param response the response
@param error error message
@return json -backed view. | [
"Write",
"to",
"the",
"output",
"this",
"error",
"."
] | train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/support/cas-server-support-oauth-core-api/src/main/java/org/apereo/cas/support/oauth/util/OAuth20Utils.java#L61-L67 |
google/j2objc | jre_emul/android/platform/libcore/luni/src/main/java/org/apache/harmony/xml/dom/NodeImpl.java | NodeImpl.isPrefixMappedToUri | boolean isPrefixMappedToUri(String prefix, String uri) {
"""
Returns true if the given prefix is mapped to the given URI on this
element. Since child elements can redefine prefixes, this check is
necessary: {@code
<foo xmlns:a="http://good">
<bar xmlns:a="http://evil">
<a:baz />
</bar>
</foo>}
@param prefix the prefix to find. Nullable.
@param uri the URI to match. Non-null.
"""
if (prefix == null) {
return false;
}
String actual = lookupNamespaceURI(prefix);
return uri.equals(actual);
} | java | boolean isPrefixMappedToUri(String prefix, String uri) {
if (prefix == null) {
return false;
}
String actual = lookupNamespaceURI(prefix);
return uri.equals(actual);
} | [
"boolean",
"isPrefixMappedToUri",
"(",
"String",
"prefix",
",",
"String",
"uri",
")",
"{",
"if",
"(",
"prefix",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"String",
"actual",
"=",
"lookupNamespaceURI",
"(",
"prefix",
")",
";",
"return",
"uri",
".",
"equals",
"(",
"actual",
")",
";",
"}"
] | Returns true if the given prefix is mapped to the given URI on this
element. Since child elements can redefine prefixes, this check is
necessary: {@code
<foo xmlns:a="http://good">
<bar xmlns:a="http://evil">
<a:baz />
</bar>
</foo>}
@param prefix the prefix to find. Nullable.
@param uri the URI to match. Non-null. | [
"Returns",
"true",
"if",
"the",
"given",
"prefix",
"is",
"mapped",
"to",
"the",
"given",
"URI",
"on",
"this",
"element",
".",
"Since",
"child",
"elements",
"can",
"redefine",
"prefixes",
"this",
"check",
"is",
"necessary",
":",
"{",
"@code",
"<foo",
"xmlns",
":",
"a",
"=",
"http",
":",
"//",
"good",
">",
"<bar",
"xmlns",
":",
"a",
"=",
"http",
":",
"//",
"evil",
">",
"<a",
":",
"baz",
"/",
">",
"<",
"/",
"bar",
">",
"<",
"/",
"foo",
">",
"}"
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/luni/src/main/java/org/apache/harmony/xml/dom/NodeImpl.java#L543-L550 |
ept/warc-hadoop | src/main/java/com/martinkl/warc/mapred/WARCInputFormat.java | WARCInputFormat.getRecordReader | @Override
public RecordReader<LongWritable, WARCWritable> getRecordReader(InputSplit split, JobConf job, Reporter reporter)
throws IOException {
"""
Opens a WARC file (possibly compressed) for reading, and returns a RecordReader for accessing it.
"""
reporter.setStatus(split.toString());
return new WARCReader(job, (FileSplit) split);
} | java | @Override
public RecordReader<LongWritable, WARCWritable> getRecordReader(InputSplit split, JobConf job, Reporter reporter)
throws IOException {
reporter.setStatus(split.toString());
return new WARCReader(job, (FileSplit) split);
} | [
"@",
"Override",
"public",
"RecordReader",
"<",
"LongWritable",
",",
"WARCWritable",
">",
"getRecordReader",
"(",
"InputSplit",
"split",
",",
"JobConf",
"job",
",",
"Reporter",
"reporter",
")",
"throws",
"IOException",
"{",
"reporter",
".",
"setStatus",
"(",
"split",
".",
"toString",
"(",
")",
")",
";",
"return",
"new",
"WARCReader",
"(",
"job",
",",
"(",
"FileSplit",
")",
"split",
")",
";",
"}"
] | Opens a WARC file (possibly compressed) for reading, and returns a RecordReader for accessing it. | [
"Opens",
"a",
"WARC",
"file",
"(",
"possibly",
"compressed",
")",
"for",
"reading",
"and",
"returns",
"a",
"RecordReader",
"for",
"accessing",
"it",
"."
] | train | https://github.com/ept/warc-hadoop/blob/f41cbb8002c29053eed9206e50ab9787de7da67f/src/main/java/com/martinkl/warc/mapred/WARCInputFormat.java#L37-L42 |
alkacon/opencms-core | src/org/opencms/xml/content/CmsXmlContentPropertyHelper.java | CmsXmlContentPropertyHelper.mergeDefaults | public static Map<String, String> mergeDefaults(
CmsObject cms,
CmsResource resource,
Map<String, String> properties,
Locale locale,
ServletRequest request) {
"""
Extends the given properties with the default values
from the resource's property configuration.<p>
@param cms the current CMS context
@param resource the resource to get the property configuration from
@param properties the properties to extend
@param locale the content locale
@param request the current request, if available
@return a merged map of properties
"""
Map<String, CmsXmlContentProperty> propertyConfig = null;
if (CmsResourceTypeXmlContent.isXmlContent(resource)) {
I_CmsFormatterBean formatter = null;
// check formatter configuration setting
for (Entry<String, String> property : properties.entrySet()) {
if (property.getKey().startsWith(CmsFormatterConfig.FORMATTER_SETTINGS_KEY)
&& CmsUUID.isValidUUID(property.getValue())) {
formatter = OpenCms.getADEManager().getCachedFormatters(
cms.getRequestContext().getCurrentProject().isOnlineProject()).getFormatters().get(
new CmsUUID(property.getValue()));
break;
}
}
try {
if (formatter != null) {
propertyConfig = OpenCms.getADEManager().getFormatterSettings(
cms,
formatter,
resource,
locale,
request);
} else {
// fall back to schema configuration
propertyConfig = CmsXmlContentDefinition.getContentHandlerForResource(cms, resource).getSettings(
cms,
resource);
}
} catch (CmsException e) {
// should never happen
LOG.error(e.getLocalizedMessage(), e);
}
}
return mergeDefaults(cms, propertyConfig, properties);
} | java | public static Map<String, String> mergeDefaults(
CmsObject cms,
CmsResource resource,
Map<String, String> properties,
Locale locale,
ServletRequest request) {
Map<String, CmsXmlContentProperty> propertyConfig = null;
if (CmsResourceTypeXmlContent.isXmlContent(resource)) {
I_CmsFormatterBean formatter = null;
// check formatter configuration setting
for (Entry<String, String> property : properties.entrySet()) {
if (property.getKey().startsWith(CmsFormatterConfig.FORMATTER_SETTINGS_KEY)
&& CmsUUID.isValidUUID(property.getValue())) {
formatter = OpenCms.getADEManager().getCachedFormatters(
cms.getRequestContext().getCurrentProject().isOnlineProject()).getFormatters().get(
new CmsUUID(property.getValue()));
break;
}
}
try {
if (formatter != null) {
propertyConfig = OpenCms.getADEManager().getFormatterSettings(
cms,
formatter,
resource,
locale,
request);
} else {
// fall back to schema configuration
propertyConfig = CmsXmlContentDefinition.getContentHandlerForResource(cms, resource).getSettings(
cms,
resource);
}
} catch (CmsException e) {
// should never happen
LOG.error(e.getLocalizedMessage(), e);
}
}
return mergeDefaults(cms, propertyConfig, properties);
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"String",
">",
"mergeDefaults",
"(",
"CmsObject",
"cms",
",",
"CmsResource",
"resource",
",",
"Map",
"<",
"String",
",",
"String",
">",
"properties",
",",
"Locale",
"locale",
",",
"ServletRequest",
"request",
")",
"{",
"Map",
"<",
"String",
",",
"CmsXmlContentProperty",
">",
"propertyConfig",
"=",
"null",
";",
"if",
"(",
"CmsResourceTypeXmlContent",
".",
"isXmlContent",
"(",
"resource",
")",
")",
"{",
"I_CmsFormatterBean",
"formatter",
"=",
"null",
";",
"// check formatter configuration setting",
"for",
"(",
"Entry",
"<",
"String",
",",
"String",
">",
"property",
":",
"properties",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"property",
".",
"getKey",
"(",
")",
".",
"startsWith",
"(",
"CmsFormatterConfig",
".",
"FORMATTER_SETTINGS_KEY",
")",
"&&",
"CmsUUID",
".",
"isValidUUID",
"(",
"property",
".",
"getValue",
"(",
")",
")",
")",
"{",
"formatter",
"=",
"OpenCms",
".",
"getADEManager",
"(",
")",
".",
"getCachedFormatters",
"(",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"getCurrentProject",
"(",
")",
".",
"isOnlineProject",
"(",
")",
")",
".",
"getFormatters",
"(",
")",
".",
"get",
"(",
"new",
"CmsUUID",
"(",
"property",
".",
"getValue",
"(",
")",
")",
")",
";",
"break",
";",
"}",
"}",
"try",
"{",
"if",
"(",
"formatter",
"!=",
"null",
")",
"{",
"propertyConfig",
"=",
"OpenCms",
".",
"getADEManager",
"(",
")",
".",
"getFormatterSettings",
"(",
"cms",
",",
"formatter",
",",
"resource",
",",
"locale",
",",
"request",
")",
";",
"}",
"else",
"{",
"// fall back to schema configuration",
"propertyConfig",
"=",
"CmsXmlContentDefinition",
".",
"getContentHandlerForResource",
"(",
"cms",
",",
"resource",
")",
".",
"getSettings",
"(",
"cms",
",",
"resource",
")",
";",
"}",
"}",
"catch",
"(",
"CmsException",
"e",
")",
"{",
"// should never happen",
"LOG",
".",
"error",
"(",
"e",
".",
"getLocalizedMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"return",
"mergeDefaults",
"(",
"cms",
",",
"propertyConfig",
",",
"properties",
")",
";",
"}"
] | Extends the given properties with the default values
from the resource's property configuration.<p>
@param cms the current CMS context
@param resource the resource to get the property configuration from
@param properties the properties to extend
@param locale the content locale
@param request the current request, if available
@return a merged map of properties | [
"Extends",
"the",
"given",
"properties",
"with",
"the",
"default",
"values",
"from",
"the",
"resource",
"s",
"property",
"configuration",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/xml/content/CmsXmlContentPropertyHelper.java#L402-L445 |
spotbugs/spotbugs | eclipsePlugin/src/edu/umd/cs/findbugs/plugin/eclipse/quickfix/util/ASTUtil.java | ASTUtil.getTypeDeclaration | public static TypeDeclaration getTypeDeclaration(CompilationUnit compilationUnit, String typeName)
throws TypeDeclarationNotFoundException {
"""
Returns the <CODE>TypeDeclaration</CODE> for the specified type name. The
type has to be declared in the specified <CODE>CompilationUnit</CODE>.
@param compilationUnit
The <CODE>CompilationUnit</CODE>, where the
<CODE>TypeDeclaration</CODE> is declared in.
@param typeName
The qualified class name to search for.
@return the <CODE>TypeDeclaration</CODE> found in the specified
<CODE>CompilationUnit</CODE>.
@throws TypeDeclarationNotFoundException
if no matching <CODE>TypeDeclaration</CODE> was found.
"""
requireNonNull(compilationUnit, "compilation unit");
requireNonNull(typeName, "class name");
int index = typeName.lastIndexOf('.');
String packageName = index > 0 ? typeName.substring(0, index) : "";
if (!matchesPackage(compilationUnit.getPackage(), packageName)) {
throw new TypeDeclarationNotFoundException(compilationUnit, typeName, "The package '" + packageName
+ "' doesn't match the package of the compilation unit.");
}
TypeDeclaration type = searchTypeDeclaration(compilationUnit.types(), typeName.substring(index + 1));
if (type == null) {
throw new TypeDeclarationNotFoundException(compilationUnit, typeName);
}
return type;
} | java | public static TypeDeclaration getTypeDeclaration(CompilationUnit compilationUnit, String typeName)
throws TypeDeclarationNotFoundException {
requireNonNull(compilationUnit, "compilation unit");
requireNonNull(typeName, "class name");
int index = typeName.lastIndexOf('.');
String packageName = index > 0 ? typeName.substring(0, index) : "";
if (!matchesPackage(compilationUnit.getPackage(), packageName)) {
throw new TypeDeclarationNotFoundException(compilationUnit, typeName, "The package '" + packageName
+ "' doesn't match the package of the compilation unit.");
}
TypeDeclaration type = searchTypeDeclaration(compilationUnit.types(), typeName.substring(index + 1));
if (type == null) {
throw new TypeDeclarationNotFoundException(compilationUnit, typeName);
}
return type;
} | [
"public",
"static",
"TypeDeclaration",
"getTypeDeclaration",
"(",
"CompilationUnit",
"compilationUnit",
",",
"String",
"typeName",
")",
"throws",
"TypeDeclarationNotFoundException",
"{",
"requireNonNull",
"(",
"compilationUnit",
",",
"\"compilation unit\"",
")",
";",
"requireNonNull",
"(",
"typeName",
",",
"\"class name\"",
")",
";",
"int",
"index",
"=",
"typeName",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"String",
"packageName",
"=",
"index",
">",
"0",
"?",
"typeName",
".",
"substring",
"(",
"0",
",",
"index",
")",
":",
"\"\"",
";",
"if",
"(",
"!",
"matchesPackage",
"(",
"compilationUnit",
".",
"getPackage",
"(",
")",
",",
"packageName",
")",
")",
"{",
"throw",
"new",
"TypeDeclarationNotFoundException",
"(",
"compilationUnit",
",",
"typeName",
",",
"\"The package '\"",
"+",
"packageName",
"+",
"\"' doesn't match the package of the compilation unit.\"",
")",
";",
"}",
"TypeDeclaration",
"type",
"=",
"searchTypeDeclaration",
"(",
"compilationUnit",
".",
"types",
"(",
")",
",",
"typeName",
".",
"substring",
"(",
"index",
"+",
"1",
")",
")",
";",
"if",
"(",
"type",
"==",
"null",
")",
"{",
"throw",
"new",
"TypeDeclarationNotFoundException",
"(",
"compilationUnit",
",",
"typeName",
")",
";",
"}",
"return",
"type",
";",
"}"
] | Returns the <CODE>TypeDeclaration</CODE> for the specified type name. The
type has to be declared in the specified <CODE>CompilationUnit</CODE>.
@param compilationUnit
The <CODE>CompilationUnit</CODE>, where the
<CODE>TypeDeclaration</CODE> is declared in.
@param typeName
The qualified class name to search for.
@return the <CODE>TypeDeclaration</CODE> found in the specified
<CODE>CompilationUnit</CODE>.
@throws TypeDeclarationNotFoundException
if no matching <CODE>TypeDeclaration</CODE> was found. | [
"Returns",
"the",
"<CODE",
">",
"TypeDeclaration<",
"/",
"CODE",
">",
"for",
"the",
"specified",
"type",
"name",
".",
"The",
"type",
"has",
"to",
"be",
"declared",
"in",
"the",
"specified",
"<CODE",
">",
"CompilationUnit<",
"/",
"CODE",
">",
"."
] | train | https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/edu/umd/cs/findbugs/plugin/eclipse/quickfix/util/ASTUtil.java#L248-L265 |
yanzhenjie/AndPermission | support/src/main/java/com/yanzhenjie/permission/AndPermission.java | AndPermission.getFileUri | public static Uri getFileUri(Fragment fragment, File file) {
"""
Get compatible Android 7.0 and lower versions of Uri.
@param fragment {@link Fragment}.
@param file apk file.
@return uri.
"""
return getFileUri(fragment.getContext(), file);
} | java | public static Uri getFileUri(Fragment fragment, File file) {
return getFileUri(fragment.getContext(), file);
} | [
"public",
"static",
"Uri",
"getFileUri",
"(",
"Fragment",
"fragment",
",",
"File",
"file",
")",
"{",
"return",
"getFileUri",
"(",
"fragment",
".",
"getContext",
"(",
")",
",",
"file",
")",
";",
"}"
] | Get compatible Android 7.0 and lower versions of Uri.
@param fragment {@link Fragment}.
@param file apk file.
@return uri. | [
"Get",
"compatible",
"Android",
"7",
".",
"0",
"and",
"lower",
"versions",
"of",
"Uri",
"."
] | train | https://github.com/yanzhenjie/AndPermission/blob/bbfaaecdb8ecf0f2aa270d80c0b88d022dddda7c/support/src/main/java/com/yanzhenjie/permission/AndPermission.java#L338-L340 |
telly/groundy | library/src/main/java/com/telly/groundy/CallbacksManager.java | CallbacksManager.init | public static CallbacksManager init(Bundle bundle, Object... callbackHandlers) {
"""
Call from within your activity or fragment onCreate method.
@param bundle the onSaveInstance bundle
@param callbackHandlers an array of callback handlers to mange
@return an instance of {@link CallbacksManager}
"""
if (bundle == null) {
return new CallbacksManager();
}
CallbacksManager callbacksManager = new CallbacksManager();
ArrayList<TaskHandler> taskProxies = bundle.getParcelableArrayList(TASK_PROXY_LIST);
if (taskProxies != null) {
callbacksManager.proxyTasks.addAll(taskProxies);
}
if (callbackHandlers != null) {
for (TaskHandler proxyTask : new ArrayList<TaskHandler>(callbacksManager.proxyTasks)) {
proxyTask.clearCallbacks();
proxyTask.appendCallbacks(callbackHandlers);
}
}
return callbacksManager;
} | java | public static CallbacksManager init(Bundle bundle, Object... callbackHandlers) {
if (bundle == null) {
return new CallbacksManager();
}
CallbacksManager callbacksManager = new CallbacksManager();
ArrayList<TaskHandler> taskProxies = bundle.getParcelableArrayList(TASK_PROXY_LIST);
if (taskProxies != null) {
callbacksManager.proxyTasks.addAll(taskProxies);
}
if (callbackHandlers != null) {
for (TaskHandler proxyTask : new ArrayList<TaskHandler>(callbacksManager.proxyTasks)) {
proxyTask.clearCallbacks();
proxyTask.appendCallbacks(callbackHandlers);
}
}
return callbacksManager;
} | [
"public",
"static",
"CallbacksManager",
"init",
"(",
"Bundle",
"bundle",
",",
"Object",
"...",
"callbackHandlers",
")",
"{",
"if",
"(",
"bundle",
"==",
"null",
")",
"{",
"return",
"new",
"CallbacksManager",
"(",
")",
";",
"}",
"CallbacksManager",
"callbacksManager",
"=",
"new",
"CallbacksManager",
"(",
")",
";",
"ArrayList",
"<",
"TaskHandler",
">",
"taskProxies",
"=",
"bundle",
".",
"getParcelableArrayList",
"(",
"TASK_PROXY_LIST",
")",
";",
"if",
"(",
"taskProxies",
"!=",
"null",
")",
"{",
"callbacksManager",
".",
"proxyTasks",
".",
"addAll",
"(",
"taskProxies",
")",
";",
"}",
"if",
"(",
"callbackHandlers",
"!=",
"null",
")",
"{",
"for",
"(",
"TaskHandler",
"proxyTask",
":",
"new",
"ArrayList",
"<",
"TaskHandler",
">",
"(",
"callbacksManager",
".",
"proxyTasks",
")",
")",
"{",
"proxyTask",
".",
"clearCallbacks",
"(",
")",
";",
"proxyTask",
".",
"appendCallbacks",
"(",
"callbackHandlers",
")",
";",
"}",
"}",
"return",
"callbacksManager",
";",
"}"
] | Call from within your activity or fragment onCreate method.
@param bundle the onSaveInstance bundle
@param callbackHandlers an array of callback handlers to mange
@return an instance of {@link CallbacksManager} | [
"Call",
"from",
"within",
"your",
"activity",
"or",
"fragment",
"onCreate",
"method",
"."
] | train | https://github.com/telly/groundy/blob/e90baf9901a8be20b348bd1575d5ad782560cec8/library/src/main/java/com/telly/groundy/CallbacksManager.java#L63-L81 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.