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
|
---|---|---|---|---|---|---|---|---|---|---|
smartsheet-platform/smartsheet-java-sdk | src/main/java/com/smartsheet/api/internal/util/Util.java | Util.throwIfNull | public static void throwIfNull(Object obj1, Object obj2) {
"""
faster util method that avoids creation of array for two-arg cases
"""
if(obj1 == null){
throw new IllegalArgumentException();
}
if(obj2 == null){
throw new IllegalArgumentException();
}
} | java | public static void throwIfNull(Object obj1, Object obj2) {
if(obj1 == null){
throw new IllegalArgumentException();
}
if(obj2 == null){
throw new IllegalArgumentException();
}
} | [
"public",
"static",
"void",
"throwIfNull",
"(",
"Object",
"obj1",
",",
"Object",
"obj2",
")",
"{",
"if",
"(",
"obj1",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"if",
"(",
"obj2",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"}"
] | faster util method that avoids creation of array for two-arg cases | [
"faster",
"util",
"method",
"that",
"avoids",
"creation",
"of",
"array",
"for",
"two",
"-",
"arg",
"cases"
] | train | https://github.com/smartsheet-platform/smartsheet-java-sdk/blob/f60e264412076271f83b65889ef9b891fad83df8/src/main/java/com/smartsheet/api/internal/util/Util.java#L36-L43 |
Azure/azure-sdk-for-java | containerservice/resource-manager/v2019_02_01/src/main/java/com/microsoft/azure/management/containerservice/v2019_02_01/implementation/OpenShiftManagedClustersInner.java | OpenShiftManagedClustersInner.updateTagsAsync | public Observable<OpenShiftManagedClusterInner> updateTagsAsync(String resourceGroupName, String resourceName) {
"""
Updates tags on an OpenShift managed cluster.
Updates an OpenShift managed cluster with the specified tags.
@param resourceGroupName The name of the resource group.
@param resourceName The name of the OpenShift managed cluster resource.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request
"""
return updateTagsWithServiceResponseAsync(resourceGroupName, resourceName).map(new Func1<ServiceResponse<OpenShiftManagedClusterInner>, OpenShiftManagedClusterInner>() {
@Override
public OpenShiftManagedClusterInner call(ServiceResponse<OpenShiftManagedClusterInner> response) {
return response.body();
}
});
} | java | public Observable<OpenShiftManagedClusterInner> updateTagsAsync(String resourceGroupName, String resourceName) {
return updateTagsWithServiceResponseAsync(resourceGroupName, resourceName).map(new Func1<ServiceResponse<OpenShiftManagedClusterInner>, OpenShiftManagedClusterInner>() {
@Override
public OpenShiftManagedClusterInner call(ServiceResponse<OpenShiftManagedClusterInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"OpenShiftManagedClusterInner",
">",
"updateTagsAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"resourceName",
")",
"{",
"return",
"updateTagsWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"resourceName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"OpenShiftManagedClusterInner",
">",
",",
"OpenShiftManagedClusterInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"OpenShiftManagedClusterInner",
"call",
"(",
"ServiceResponse",
"<",
"OpenShiftManagedClusterInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Updates tags on an OpenShift managed cluster.
Updates an OpenShift managed cluster with the specified tags.
@param resourceGroupName The name of the resource group.
@param resourceName The name of the OpenShift managed cluster resource.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Updates",
"tags",
"on",
"an",
"OpenShift",
"managed",
"cluster",
".",
"Updates",
"an",
"OpenShift",
"managed",
"cluster",
"with",
"the",
"specified",
"tags",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/containerservice/resource-manager/v2019_02_01/src/main/java/com/microsoft/azure/management/containerservice/v2019_02_01/implementation/OpenShiftManagedClustersInner.java#L646-L653 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToUnknownStream.java | ToUnknownStream.startDTD | public void startDTD(String name, String publicId, String systemId)
throws SAXException {
"""
Pass the call on to the underlying handler
@see org.xml.sax.ext.LexicalHandler#startDTD(String, String, String)
"""
m_handler.startDTD(name, publicId, systemId);
} | java | public void startDTD(String name, String publicId, String systemId)
throws SAXException
{
m_handler.startDTD(name, publicId, systemId);
} | [
"public",
"void",
"startDTD",
"(",
"String",
"name",
",",
"String",
"publicId",
",",
"String",
"systemId",
")",
"throws",
"SAXException",
"{",
"m_handler",
".",
"startDTD",
"(",
"name",
",",
"publicId",
",",
"systemId",
")",
";",
"}"
] | Pass the call on to the underlying handler
@see org.xml.sax.ext.LexicalHandler#startDTD(String, String, String) | [
"Pass",
"the",
"call",
"on",
"to",
"the",
"underlying",
"handler"
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToUnknownStream.java#L944-L948 |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/HeapCache.java | HeapCache.removeEntryForEviction | public void removeEntryForEviction(Entry<K, V> e) {
"""
Remove the entry from the hash table. The entry is already removed from the replacement list.
Stop the timer, if needed. The remove races with a clear. The clear
is not updating each entry state to e.isGone() but just drops the whole hash table instead.
<p>With completion of the method the entry content is no more visible. "Nulling" out the key
or value of the entry is incorrect, since there can be another thread which is just about to
return the entry contents.
"""
boolean f = hash.remove(e);
checkForHashCodeChange(e);
timing.cancelExpiryTimer(e);
e.setGone();
} | java | public void removeEntryForEviction(Entry<K, V> e) {
boolean f = hash.remove(e);
checkForHashCodeChange(e);
timing.cancelExpiryTimer(e);
e.setGone();
} | [
"public",
"void",
"removeEntryForEviction",
"(",
"Entry",
"<",
"K",
",",
"V",
">",
"e",
")",
"{",
"boolean",
"f",
"=",
"hash",
".",
"remove",
"(",
"e",
")",
";",
"checkForHashCodeChange",
"(",
"e",
")",
";",
"timing",
".",
"cancelExpiryTimer",
"(",
"e",
")",
";",
"e",
".",
"setGone",
"(",
")",
";",
"}"
] | Remove the entry from the hash table. The entry is already removed from the replacement list.
Stop the timer, if needed. The remove races with a clear. The clear
is not updating each entry state to e.isGone() but just drops the whole hash table instead.
<p>With completion of the method the entry content is no more visible. "Nulling" out the key
or value of the entry is incorrect, since there can be another thread which is just about to
return the entry contents. | [
"Remove",
"the",
"entry",
"from",
"the",
"hash",
"table",
".",
"The",
"entry",
"is",
"already",
"removed",
"from",
"the",
"replacement",
"list",
".",
"Stop",
"the",
"timer",
"if",
"needed",
".",
"The",
"remove",
"races",
"with",
"a",
"clear",
".",
"The",
"clear",
"is",
"not",
"updating",
"each",
"entry",
"state",
"to",
"e",
".",
"isGone",
"()",
"but",
"just",
"drops",
"the",
"whole",
"hash",
"table",
"instead",
"."
] | train | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/HeapCache.java#L1322-L1327 |
podio/podio-java | src/main/java/com/podio/org/OrgAPI.java | OrgAPI.updateOrganization | public void updateOrganization(int orgId, OrganizationCreate data) {
"""
Updates an organization with new name and logo. Note that the URL of the
organization will not change even though the name changes.
@param orgId
The id of the organization
@param data
The new data
"""
getResourceFactory().getApiResource("/org/" + orgId)
.entity(data, MediaType.APPLICATION_JSON_TYPE).put();
} | java | public void updateOrganization(int orgId, OrganizationCreate data) {
getResourceFactory().getApiResource("/org/" + orgId)
.entity(data, MediaType.APPLICATION_JSON_TYPE).put();
} | [
"public",
"void",
"updateOrganization",
"(",
"int",
"orgId",
",",
"OrganizationCreate",
"data",
")",
"{",
"getResourceFactory",
"(",
")",
".",
"getApiResource",
"(",
"\"/org/\"",
"+",
"orgId",
")",
".",
"entity",
"(",
"data",
",",
"MediaType",
".",
"APPLICATION_JSON_TYPE",
")",
".",
"put",
"(",
")",
";",
"}"
] | Updates an organization with new name and logo. Note that the URL of the
organization will not change even though the name changes.
@param orgId
The id of the organization
@param data
The new data | [
"Updates",
"an",
"organization",
"with",
"new",
"name",
"and",
"logo",
".",
"Note",
"that",
"the",
"URL",
"of",
"the",
"organization",
"will",
"not",
"change",
"even",
"though",
"the",
"name",
"changes",
"."
] | train | https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/org/OrgAPI.java#L42-L45 |
Cornutum/tcases | tcases-openapi/src/main/java/org/cornutum/tcases/openapi/io/TcasesOpenApiIO.java | TcasesOpenApiIO.getRequestInputModel | public static SystemInputDef getRequestInputModel( InputStream api, ModelOptions options) {
"""
Returns a {@link SystemInputDef system input definition} for the API requests defined by the given
OpenAPI specification. Returns null if the given spec defines no API requests to model.
"""
try( OpenApiReader reader = new OpenApiReader( api))
{
return TcasesOpenApi.getRequestInputModel( reader.read(), options);
}
} | java | public static SystemInputDef getRequestInputModel( InputStream api, ModelOptions options)
{
try( OpenApiReader reader = new OpenApiReader( api))
{
return TcasesOpenApi.getRequestInputModel( reader.read(), options);
}
} | [
"public",
"static",
"SystemInputDef",
"getRequestInputModel",
"(",
"InputStream",
"api",
",",
"ModelOptions",
"options",
")",
"{",
"try",
"(",
"OpenApiReader",
"reader",
"=",
"new",
"OpenApiReader",
"(",
"api",
")",
")",
"{",
"return",
"TcasesOpenApi",
".",
"getRequestInputModel",
"(",
"reader",
".",
"read",
"(",
")",
",",
"options",
")",
";",
"}",
"}"
] | Returns a {@link SystemInputDef system input definition} for the API requests defined by the given
OpenAPI specification. Returns null if the given spec defines no API requests to model. | [
"Returns",
"a",
"{"
] | train | https://github.com/Cornutum/tcases/blob/21e15cf107fa149620c40f4bda1829c1224fcfb1/tcases-openapi/src/main/java/org/cornutum/tcases/openapi/io/TcasesOpenApiIO.java#L49-L55 |
Viascom/groundwork | foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/placeholder/DefaultPlaceholderStrategy.java | DefaultPlaceholderStrategy.addPlaceholder | @Override
public void addPlaceholder(String placeholder, String value) {
"""
Add a placeholder to the strategy
@param placeholder name of the placholder
@param value value of the placeholder
"""
placeholderMap.put(placeholder, value);
} | java | @Override
public void addPlaceholder(String placeholder, String value) {
placeholderMap.put(placeholder, value);
} | [
"@",
"Override",
"public",
"void",
"addPlaceholder",
"(",
"String",
"placeholder",
",",
"String",
"value",
")",
"{",
"placeholderMap",
".",
"put",
"(",
"placeholder",
",",
"value",
")",
";",
"}"
] | Add a placeholder to the strategy
@param placeholder name of the placholder
@param value value of the placeholder | [
"Add",
"a",
"placeholder",
"to",
"the",
"strategy"
] | train | https://github.com/Viascom/groundwork/blob/d3f7d0df65e2e75861fc7db938090683f2cdf919/foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/placeholder/DefaultPlaceholderStrategy.java#L46-L49 |
Omertron/api-themoviedb | src/main/java/com/omertron/themoviedbapi/methods/TmdbAccount.java | TmdbAccount.modifyWatchList | public StatusCode modifyWatchList(String sessionId, int accountId, MediaType mediaType, Integer movieId, boolean addToWatchlist) throws MovieDbException {
"""
Add or remove a movie to an accounts watch list.
@param sessionId
@param accountId
@param movieId
@param mediaType
@param addToWatchlist
@return
@throws MovieDbException
"""
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.SESSION_ID, sessionId);
parameters.add(Param.ID, accountId);
String jsonBody = new PostTools()
.add(PostBody.MEDIA_TYPE, mediaType.toString().toLowerCase())
.add(PostBody.MEDIA_ID, movieId)
.add(PostBody.WATCHLIST, addToWatchlist)
.build();
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).subMethod(MethodSub.WATCHLIST).buildUrl(parameters);
String webpage = httpTools.postRequest(url, jsonBody);
try {
return MAPPER.readValue(webpage, StatusCode.class);
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to modify watch list", url, ex);
}
} | java | public StatusCode modifyWatchList(String sessionId, int accountId, MediaType mediaType, Integer movieId, boolean addToWatchlist) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.SESSION_ID, sessionId);
parameters.add(Param.ID, accountId);
String jsonBody = new PostTools()
.add(PostBody.MEDIA_TYPE, mediaType.toString().toLowerCase())
.add(PostBody.MEDIA_ID, movieId)
.add(PostBody.WATCHLIST, addToWatchlist)
.build();
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).subMethod(MethodSub.WATCHLIST).buildUrl(parameters);
String webpage = httpTools.postRequest(url, jsonBody);
try {
return MAPPER.readValue(webpage, StatusCode.class);
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to modify watch list", url, ex);
}
} | [
"public",
"StatusCode",
"modifyWatchList",
"(",
"String",
"sessionId",
",",
"int",
"accountId",
",",
"MediaType",
"mediaType",
",",
"Integer",
"movieId",
",",
"boolean",
"addToWatchlist",
")",
"throws",
"MovieDbException",
"{",
"TmdbParameters",
"parameters",
"=",
"new",
"TmdbParameters",
"(",
")",
";",
"parameters",
".",
"add",
"(",
"Param",
".",
"SESSION_ID",
",",
"sessionId",
")",
";",
"parameters",
".",
"add",
"(",
"Param",
".",
"ID",
",",
"accountId",
")",
";",
"String",
"jsonBody",
"=",
"new",
"PostTools",
"(",
")",
".",
"add",
"(",
"PostBody",
".",
"MEDIA_TYPE",
",",
"mediaType",
".",
"toString",
"(",
")",
".",
"toLowerCase",
"(",
")",
")",
".",
"add",
"(",
"PostBody",
".",
"MEDIA_ID",
",",
"movieId",
")",
".",
"add",
"(",
"PostBody",
".",
"WATCHLIST",
",",
"addToWatchlist",
")",
".",
"build",
"(",
")",
";",
"URL",
"url",
"=",
"new",
"ApiUrl",
"(",
"apiKey",
",",
"MethodBase",
".",
"ACCOUNT",
")",
".",
"subMethod",
"(",
"MethodSub",
".",
"WATCHLIST",
")",
".",
"buildUrl",
"(",
"parameters",
")",
";",
"String",
"webpage",
"=",
"httpTools",
".",
"postRequest",
"(",
"url",
",",
"jsonBody",
")",
";",
"try",
"{",
"return",
"MAPPER",
".",
"readValue",
"(",
"webpage",
",",
"StatusCode",
".",
"class",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"MovieDbException",
"(",
"ApiExceptionType",
".",
"MAPPING_FAILED",
",",
"\"Failed to modify watch list\"",
",",
"url",
",",
"ex",
")",
";",
"}",
"}"
] | Add or remove a movie to an accounts watch list.
@param sessionId
@param accountId
@param movieId
@param mediaType
@param addToWatchlist
@return
@throws MovieDbException | [
"Add",
"or",
"remove",
"a",
"movie",
"to",
"an",
"accounts",
"watch",
"list",
"."
] | train | https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbAccount.java#L275-L294 |
Azure/azure-sdk-for-java | sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/ElasticPoolsInner.java | ElasticPoolsInner.beginUpdateAsync | public Observable<ElasticPoolInner> beginUpdateAsync(String resourceGroupName, String serverName, String elasticPoolName, ElasticPoolUpdate parameters) {
"""
Updates an existing elastic pool.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param elasticPoolName The name of the elastic pool to be updated.
@param parameters The required parameters for updating an elastic pool.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ElasticPoolInner object
"""
return beginUpdateWithServiceResponseAsync(resourceGroupName, serverName, elasticPoolName, parameters).map(new Func1<ServiceResponse<ElasticPoolInner>, ElasticPoolInner>() {
@Override
public ElasticPoolInner call(ServiceResponse<ElasticPoolInner> response) {
return response.body();
}
});
} | java | public Observable<ElasticPoolInner> beginUpdateAsync(String resourceGroupName, String serverName, String elasticPoolName, ElasticPoolUpdate parameters) {
return beginUpdateWithServiceResponseAsync(resourceGroupName, serverName, elasticPoolName, parameters).map(new Func1<ServiceResponse<ElasticPoolInner>, ElasticPoolInner>() {
@Override
public ElasticPoolInner call(ServiceResponse<ElasticPoolInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ElasticPoolInner",
">",
"beginUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"String",
"elasticPoolName",
",",
"ElasticPoolUpdate",
"parameters",
")",
"{",
"return",
"beginUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
",",
"elasticPoolName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"ElasticPoolInner",
">",
",",
"ElasticPoolInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ElasticPoolInner",
"call",
"(",
"ServiceResponse",
"<",
"ElasticPoolInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Updates an existing elastic pool.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param elasticPoolName The name of the elastic pool to be updated.
@param parameters The required parameters for updating an elastic pool.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ElasticPoolInner object | [
"Updates",
"an",
"existing",
"elastic",
"pool",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/ElasticPoolsInner.java#L411-L418 |
google/closure-compiler | src/com/google/javascript/jscomp/NodeUtil.java | NodeUtil.newQNameDeclaration | public static Node newQNameDeclaration(
AbstractCompiler compiler, String name, Node value, JSDocInfo info) {
"""
Creates a node representing a qualified name.
@param name A qualified name (e.g. "foo" or "foo.bar.baz")
@return A VAR node, or an EXPR_RESULT node containing an ASSIGN or NAME node.
"""
return newQNameDeclaration(compiler, name, value, info, Token.VAR);
} | java | public static Node newQNameDeclaration(
AbstractCompiler compiler, String name, Node value, JSDocInfo info) {
return newQNameDeclaration(compiler, name, value, info, Token.VAR);
} | [
"public",
"static",
"Node",
"newQNameDeclaration",
"(",
"AbstractCompiler",
"compiler",
",",
"String",
"name",
",",
"Node",
"value",
",",
"JSDocInfo",
"info",
")",
"{",
"return",
"newQNameDeclaration",
"(",
"compiler",
",",
"name",
",",
"value",
",",
"info",
",",
"Token",
".",
"VAR",
")",
";",
"}"
] | Creates a node representing a qualified name.
@param name A qualified name (e.g. "foo" or "foo.bar.baz")
@return A VAR node, or an EXPR_RESULT node containing an ASSIGN or NAME node. | [
"Creates",
"a",
"node",
"representing",
"a",
"qualified",
"name",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeUtil.java#L4050-L4053 |
gallandarakhneorg/afc | advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d3/ifx/RectangularPrism3ifx.java | RectangularPrism3ifx.depthProperty | @Pure
public IntegerProperty depthProperty() {
"""
Replies the property that is the depth of the box.
@return the depth property.
"""
if (this.depth == null) {
this.depth = new ReadOnlyIntegerWrapper(this, MathFXAttributeNames.DEPTH);
this.depth.bind(Bindings.subtract(maxZProperty(), minZProperty()));
}
return this.depth;
} | java | @Pure
public IntegerProperty depthProperty() {
if (this.depth == null) {
this.depth = new ReadOnlyIntegerWrapper(this, MathFXAttributeNames.DEPTH);
this.depth.bind(Bindings.subtract(maxZProperty(), minZProperty()));
}
return this.depth;
} | [
"@",
"Pure",
"public",
"IntegerProperty",
"depthProperty",
"(",
")",
"{",
"if",
"(",
"this",
".",
"depth",
"==",
"null",
")",
"{",
"this",
".",
"depth",
"=",
"new",
"ReadOnlyIntegerWrapper",
"(",
"this",
",",
"MathFXAttributeNames",
".",
"DEPTH",
")",
";",
"this",
".",
"depth",
".",
"bind",
"(",
"Bindings",
".",
"subtract",
"(",
"maxZProperty",
"(",
")",
",",
"minZProperty",
"(",
")",
")",
")",
";",
"}",
"return",
"this",
".",
"depth",
";",
"}"
] | Replies the property that is the depth of the box.
@return the depth property. | [
"Replies",
"the",
"property",
"that",
"is",
"the",
"depth",
"of",
"the",
"box",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d3/ifx/RectangularPrism3ifx.java#L397-L404 |
kiegroup/jbpm | jbpm-human-task/jbpm-human-task-jpa/src/main/java/org/jbpm/services/task/impl/model/TaskDataImpl.java | TaskDataImpl.setOutput | public void setOutput(long outputContentId, ContentData outputContentData) {
"""
Sets the content data for this task data. It will set the <field>outputContentId</field> from the specified
outputContentId, <field>outputAccessType</field>, <field>outputType</field> from the specified
outputContentData.
@param outputContentId id of output content
@param outputContentData contentData
"""
setOutputContentId(outputContentId);
setOutputAccessType(outputContentData.getAccessType());
setOutputType(outputContentData.getType());
} | java | public void setOutput(long outputContentId, ContentData outputContentData) {
setOutputContentId(outputContentId);
setOutputAccessType(outputContentData.getAccessType());
setOutputType(outputContentData.getType());
} | [
"public",
"void",
"setOutput",
"(",
"long",
"outputContentId",
",",
"ContentData",
"outputContentData",
")",
"{",
"setOutputContentId",
"(",
"outputContentId",
")",
";",
"setOutputAccessType",
"(",
"outputContentData",
".",
"getAccessType",
"(",
")",
")",
";",
"setOutputType",
"(",
"outputContentData",
".",
"getType",
"(",
")",
")",
";",
"}"
] | Sets the content data for this task data. It will set the <field>outputContentId</field> from the specified
outputContentId, <field>outputAccessType</field>, <field>outputType</field> from the specified
outputContentData.
@param outputContentId id of output content
@param outputContentData contentData | [
"Sets",
"the",
"content",
"data",
"for",
"this",
"task",
"data",
".",
"It",
"will",
"set",
"the",
"<field",
">",
"outputContentId<",
"/",
"field",
">",
"from",
"the",
"specified",
"outputContentId",
"<field",
">",
"outputAccessType<",
"/",
"field",
">",
"<field",
">",
"outputType<",
"/",
"field",
">",
"from",
"the",
"specified",
"outputContentData",
"."
] | train | https://github.com/kiegroup/jbpm/blob/c3473c728aa382ebbea01e380c5e754a96647b82/jbpm-human-task/jbpm-human-task-jpa/src/main/java/org/jbpm/services/task/impl/model/TaskDataImpl.java#L568-L572 |
Mozu/mozu-java | mozu-java-core/src/main/java/com/mozu/api/urls/commerce/customer/CustomerSegmentUrl.java | CustomerSegmentUrl.getSegmentUrl | public static MozuUrl getSegmentUrl(Integer id, String responseFields) {
"""
Get Resource Url for GetSegment
@param id Unique identifier of the customer segment to retrieve.
@param responseFields Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.
@return String Resource Url
"""
UrlFormatter formatter = new UrlFormatter("/api/commerce/customer/segments/{id}?responseFields={responseFields}");
formatter.formatUrl("id", id);
formatter.formatUrl("responseFields", responseFields);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | java | public static MozuUrl getSegmentUrl(Integer id, String responseFields)
{
UrlFormatter formatter = new UrlFormatter("/api/commerce/customer/segments/{id}?responseFields={responseFields}");
formatter.formatUrl("id", id);
formatter.formatUrl("responseFields", responseFields);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | [
"public",
"static",
"MozuUrl",
"getSegmentUrl",
"(",
"Integer",
"id",
",",
"String",
"responseFields",
")",
"{",
"UrlFormatter",
"formatter",
"=",
"new",
"UrlFormatter",
"(",
"\"/api/commerce/customer/segments/{id}?responseFields={responseFields}\"",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"id\"",
",",
"id",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"responseFields\"",
",",
"responseFields",
")",
";",
"return",
"new",
"MozuUrl",
"(",
"formatter",
".",
"getResourceUrl",
"(",
")",
",",
"MozuUrl",
".",
"UrlLocation",
".",
"TENANT_POD",
")",
";",
"}"
] | Get Resource Url for GetSegment
@param id Unique identifier of the customer segment to retrieve.
@param responseFields Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.
@return String Resource Url | [
"Get",
"Resource",
"Url",
"for",
"GetSegment"
] | train | https://github.com/Mozu/mozu-java/blob/5beadde73601a859f845e3e2fc1077b39c8bea83/mozu-java-core/src/main/java/com/mozu/api/urls/commerce/customer/CustomerSegmentUrl.java#L42-L48 |
mozilla/rhino | src/org/mozilla/javascript/UintMap.java | UintMap.getInt | public int getInt(int key, int defaultValue) {
"""
Get integer value assigned with key.
@return key integer value or defaultValue if key is absent
"""
if (key < 0) Kit.codeBug();
int index = findIndex(key);
if (0 <= index) {
if (ivaluesShift != 0) {
return keys[ivaluesShift + index];
}
return 0;
}
return defaultValue;
} | java | public int getInt(int key, int defaultValue) {
if (key < 0) Kit.codeBug();
int index = findIndex(key);
if (0 <= index) {
if (ivaluesShift != 0) {
return keys[ivaluesShift + index];
}
return 0;
}
return defaultValue;
} | [
"public",
"int",
"getInt",
"(",
"int",
"key",
",",
"int",
"defaultValue",
")",
"{",
"if",
"(",
"key",
"<",
"0",
")",
"Kit",
".",
"codeBug",
"(",
")",
";",
"int",
"index",
"=",
"findIndex",
"(",
"key",
")",
";",
"if",
"(",
"0",
"<=",
"index",
")",
"{",
"if",
"(",
"ivaluesShift",
"!=",
"0",
")",
"{",
"return",
"keys",
"[",
"ivaluesShift",
"+",
"index",
"]",
";",
"}",
"return",
"0",
";",
"}",
"return",
"defaultValue",
";",
"}"
] | Get integer value assigned with key.
@return key integer value or defaultValue if key is absent | [
"Get",
"integer",
"value",
"assigned",
"with",
"key",
"."
] | train | https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/UintMap.java#L77-L87 |
OpenLiberty/open-liberty | dev/com.ibm.ws.cdi.internal/src/com/ibm/ws/cdi/internal/archive/AbstractCDIArchive.java | AbstractCDIArchive.getBeanDiscoveryMode | public BeanDiscoveryMode getBeanDiscoveryMode(CDIRuntime cdiRuntime, BeansXml beansXml) {
"""
Determine the bean deployment archive scanning mode
If there is a beans.xml, the bean discovery mode will be used.
If there is no beans.xml, the mode will be annotated, unless the enableImplicitBeanArchives is configured as false via the server.xml.
If there is no beans.xml and the enableImplicitBeanArchives attribute on cdi12 is configured to false, the scanning mode is none.
@return
"""
BeanDiscoveryMode mode = BeanDiscoveryMode.ANNOTATED;
if (beansXml != null) {
mode = beansXml.getBeanDiscoveryMode();
} else if (cdiRuntime.isImplicitBeanArchivesScanningDisabled(this)) {
// If the server.xml has the configuration of enableImplicitBeanArchives sets to false, we will not scan the implicit bean archives
mode = BeanDiscoveryMode.NONE;
}
return mode;
} | java | public BeanDiscoveryMode getBeanDiscoveryMode(CDIRuntime cdiRuntime, BeansXml beansXml) {
BeanDiscoveryMode mode = BeanDiscoveryMode.ANNOTATED;
if (beansXml != null) {
mode = beansXml.getBeanDiscoveryMode();
} else if (cdiRuntime.isImplicitBeanArchivesScanningDisabled(this)) {
// If the server.xml has the configuration of enableImplicitBeanArchives sets to false, we will not scan the implicit bean archives
mode = BeanDiscoveryMode.NONE;
}
return mode;
} | [
"public",
"BeanDiscoveryMode",
"getBeanDiscoveryMode",
"(",
"CDIRuntime",
"cdiRuntime",
",",
"BeansXml",
"beansXml",
")",
"{",
"BeanDiscoveryMode",
"mode",
"=",
"BeanDiscoveryMode",
".",
"ANNOTATED",
";",
"if",
"(",
"beansXml",
"!=",
"null",
")",
"{",
"mode",
"=",
"beansXml",
".",
"getBeanDiscoveryMode",
"(",
")",
";",
"}",
"else",
"if",
"(",
"cdiRuntime",
".",
"isImplicitBeanArchivesScanningDisabled",
"(",
"this",
")",
")",
"{",
"// If the server.xml has the configuration of enableImplicitBeanArchives sets to false, we will not scan the implicit bean archives",
"mode",
"=",
"BeanDiscoveryMode",
".",
"NONE",
";",
"}",
"return",
"mode",
";",
"}"
] | Determine the bean deployment archive scanning mode
If there is a beans.xml, the bean discovery mode will be used.
If there is no beans.xml, the mode will be annotated, unless the enableImplicitBeanArchives is configured as false via the server.xml.
If there is no beans.xml and the enableImplicitBeanArchives attribute on cdi12 is configured to false, the scanning mode is none.
@return | [
"Determine",
"the",
"bean",
"deployment",
"archive",
"scanning",
"mode",
"If",
"there",
"is",
"a",
"beans",
".",
"xml",
"the",
"bean",
"discovery",
"mode",
"will",
"be",
"used",
".",
"If",
"there",
"is",
"no",
"beans",
".",
"xml",
"the",
"mode",
"will",
"be",
"annotated",
"unless",
"the",
"enableImplicitBeanArchives",
"is",
"configured",
"as",
"false",
"via",
"the",
"server",
".",
"xml",
".",
"If",
"there",
"is",
"no",
"beans",
".",
"xml",
"and",
"the",
"enableImplicitBeanArchives",
"attribute",
"on",
"cdi12",
"is",
"configured",
"to",
"false",
"the",
"scanning",
"mode",
"is",
"none",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.cdi.internal/src/com/ibm/ws/cdi/internal/archive/AbstractCDIArchive.java#L183-L192 |
JRebirth/JRebirth | org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/service/AbstractService.java | AbstractService.updateProgress | public void updateProgress(final Wave wave, final double workDone, final double totalWork, final double progressIncrement) {
"""
Update the progress of the service task related to the given wave.
@param wave the wave that trigger the service task call
@param workDone the amount of overall work done
@param totalWork the amount of total work to do
@param progressIncrement the value increment used to filter useless progress event
"""
if (wave.get(JRebirthWaves.SERVICE_TASK).checkProgressRatio(workDone, totalWork, progressIncrement)) {
// Increase the task progression
JRebirth.runIntoJAT("ServiceTask Workdone (dbl) " + workDone + RATIO_SEPARATOR + totalWork,
() -> wave.get(JRebirthWaves.SERVICE_TASK).updateProgress(workDone, totalWork));
}
} | java | public void updateProgress(final Wave wave, final double workDone, final double totalWork, final double progressIncrement) {
if (wave.get(JRebirthWaves.SERVICE_TASK).checkProgressRatio(workDone, totalWork, progressIncrement)) {
// Increase the task progression
JRebirth.runIntoJAT("ServiceTask Workdone (dbl) " + workDone + RATIO_SEPARATOR + totalWork,
() -> wave.get(JRebirthWaves.SERVICE_TASK).updateProgress(workDone, totalWork));
}
} | [
"public",
"void",
"updateProgress",
"(",
"final",
"Wave",
"wave",
",",
"final",
"double",
"workDone",
",",
"final",
"double",
"totalWork",
",",
"final",
"double",
"progressIncrement",
")",
"{",
"if",
"(",
"wave",
".",
"get",
"(",
"JRebirthWaves",
".",
"SERVICE_TASK",
")",
".",
"checkProgressRatio",
"(",
"workDone",
",",
"totalWork",
",",
"progressIncrement",
")",
")",
"{",
"// Increase the task progression",
"JRebirth",
".",
"runIntoJAT",
"(",
"\"ServiceTask Workdone (dbl) \"",
"+",
"workDone",
"+",
"RATIO_SEPARATOR",
"+",
"totalWork",
",",
"(",
")",
"->",
"wave",
".",
"get",
"(",
"JRebirthWaves",
".",
"SERVICE_TASK",
")",
".",
"updateProgress",
"(",
"workDone",
",",
"totalWork",
")",
")",
";",
"}",
"}"
] | Update the progress of the service task related to the given wave.
@param wave the wave that trigger the service task call
@param workDone the amount of overall work done
@param totalWork the amount of total work to do
@param progressIncrement the value increment used to filter useless progress event | [
"Update",
"the",
"progress",
"of",
"the",
"service",
"task",
"related",
"to",
"the",
"given",
"wave",
"."
] | train | https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/service/AbstractService.java#L330-L338 |
ManfredTremmel/gwt-commons-lang3 | src/main/java/org/apache/commons/lang3/text/WordUtils.java | WordUtils.isDelimiter | private static boolean isDelimiter(final char ch, final char[] delimiters) {
"""
Is the character a delimiter.
@param ch the character to check
@param delimiters the delimiters
@return true if it is a delimiter
"""
if (delimiters == null) {
return CharUtils.isWhitespace(ch);
}
for (final char delimiter : delimiters) {
if (ch == delimiter) {
return true;
}
}
return false;
} | java | private static boolean isDelimiter(final char ch, final char[] delimiters) {
if (delimiters == null) {
return CharUtils.isWhitespace(ch);
}
for (final char delimiter : delimiters) {
if (ch == delimiter) {
return true;
}
}
return false;
} | [
"private",
"static",
"boolean",
"isDelimiter",
"(",
"final",
"char",
"ch",
",",
"final",
"char",
"[",
"]",
"delimiters",
")",
"{",
"if",
"(",
"delimiters",
"==",
"null",
")",
"{",
"return",
"CharUtils",
".",
"isWhitespace",
"(",
"ch",
")",
";",
"}",
"for",
"(",
"final",
"char",
"delimiter",
":",
"delimiters",
")",
"{",
"if",
"(",
"ch",
"==",
"delimiter",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Is the character a delimiter.
@param ch the character to check
@param delimiters the delimiters
@return true if it is a delimiter | [
"Is",
"the",
"character",
"a",
"delimiter",
"."
] | train | https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/text/WordUtils.java#L743-L753 |
ppiastucki/recast4j | detour/src/main/java/org/recast4j/detour/DetourCommon.java | DetourCommon.overlapPolyPoly2D | static boolean overlapPolyPoly2D(float[] polya, int npolya, float[] polyb, int npolyb) {
"""
/ All vertices are projected onto the xz-plane, so the y-values are ignored.
"""
for (int i = 0, j = npolya - 1; i < npolya; j = i++) {
int va = j * 3;
int vb = i * 3;
float[] n = new float[] { polya[vb + 2] - polya[va + 2], 0, -(polya[vb + 0] - polya[va + 0]) };
float[] aminmax = projectPoly(n, polya, npolya);
float[] bminmax = projectPoly(n, polyb, npolyb);
if (!overlapRange(aminmax[0], aminmax[1], bminmax[0], bminmax[1], eps)) {
// Found separating axis
return false;
}
}
for (int i = 0, j = npolyb - 1; i < npolyb; j = i++) {
int va = j * 3;
int vb = i * 3;
float[] n = new float[] { polyb[vb + 2] - polyb[va + 2], 0, -(polyb[vb + 0] - polyb[va + 0]) };
float[] aminmax = projectPoly(n, polya, npolya);
float[] bminmax = projectPoly(n, polyb, npolyb);
if (!overlapRange(aminmax[0], aminmax[1], bminmax[0], bminmax[1], eps)) {
// Found separating axis
return false;
}
}
return true;
} | java | static boolean overlapPolyPoly2D(float[] polya, int npolya, float[] polyb, int npolyb) {
for (int i = 0, j = npolya - 1; i < npolya; j = i++) {
int va = j * 3;
int vb = i * 3;
float[] n = new float[] { polya[vb + 2] - polya[va + 2], 0, -(polya[vb + 0] - polya[va + 0]) };
float[] aminmax = projectPoly(n, polya, npolya);
float[] bminmax = projectPoly(n, polyb, npolyb);
if (!overlapRange(aminmax[0], aminmax[1], bminmax[0], bminmax[1], eps)) {
// Found separating axis
return false;
}
}
for (int i = 0, j = npolyb - 1; i < npolyb; j = i++) {
int va = j * 3;
int vb = i * 3;
float[] n = new float[] { polyb[vb + 2] - polyb[va + 2], 0, -(polyb[vb + 0] - polyb[va + 0]) };
float[] aminmax = projectPoly(n, polya, npolya);
float[] bminmax = projectPoly(n, polyb, npolyb);
if (!overlapRange(aminmax[0], aminmax[1], bminmax[0], bminmax[1], eps)) {
// Found separating axis
return false;
}
}
return true;
} | [
"static",
"boolean",
"overlapPolyPoly2D",
"(",
"float",
"[",
"]",
"polya",
",",
"int",
"npolya",
",",
"float",
"[",
"]",
"polyb",
",",
"int",
"npolyb",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"j",
"=",
"npolya",
"-",
"1",
";",
"i",
"<",
"npolya",
";",
"j",
"=",
"i",
"++",
")",
"{",
"int",
"va",
"=",
"j",
"*",
"3",
";",
"int",
"vb",
"=",
"i",
"*",
"3",
";",
"float",
"[",
"]",
"n",
"=",
"new",
"float",
"[",
"]",
"{",
"polya",
"[",
"vb",
"+",
"2",
"]",
"-",
"polya",
"[",
"va",
"+",
"2",
"]",
",",
"0",
",",
"-",
"(",
"polya",
"[",
"vb",
"+",
"0",
"]",
"-",
"polya",
"[",
"va",
"+",
"0",
"]",
")",
"}",
";",
"float",
"[",
"]",
"aminmax",
"=",
"projectPoly",
"(",
"n",
",",
"polya",
",",
"npolya",
")",
";",
"float",
"[",
"]",
"bminmax",
"=",
"projectPoly",
"(",
"n",
",",
"polyb",
",",
"npolyb",
")",
";",
"if",
"(",
"!",
"overlapRange",
"(",
"aminmax",
"[",
"0",
"]",
",",
"aminmax",
"[",
"1",
"]",
",",
"bminmax",
"[",
"0",
"]",
",",
"bminmax",
"[",
"1",
"]",
",",
"eps",
")",
")",
"{",
"// Found separating axis",
"return",
"false",
";",
"}",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"j",
"=",
"npolyb",
"-",
"1",
";",
"i",
"<",
"npolyb",
";",
"j",
"=",
"i",
"++",
")",
"{",
"int",
"va",
"=",
"j",
"*",
"3",
";",
"int",
"vb",
"=",
"i",
"*",
"3",
";",
"float",
"[",
"]",
"n",
"=",
"new",
"float",
"[",
"]",
"{",
"polyb",
"[",
"vb",
"+",
"2",
"]",
"-",
"polyb",
"[",
"va",
"+",
"2",
"]",
",",
"0",
",",
"-",
"(",
"polyb",
"[",
"vb",
"+",
"0",
"]",
"-",
"polyb",
"[",
"va",
"+",
"0",
"]",
")",
"}",
";",
"float",
"[",
"]",
"aminmax",
"=",
"projectPoly",
"(",
"n",
",",
"polya",
",",
"npolya",
")",
";",
"float",
"[",
"]",
"bminmax",
"=",
"projectPoly",
"(",
"n",
",",
"polyb",
",",
"npolyb",
")",
";",
"if",
"(",
"!",
"overlapRange",
"(",
"aminmax",
"[",
"0",
"]",
",",
"aminmax",
"[",
"1",
"]",
",",
"bminmax",
"[",
"0",
"]",
",",
"bminmax",
"[",
"1",
"]",
",",
"eps",
")",
")",
"{",
"// Found separating axis",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | / All vertices are projected onto the xz-plane, so the y-values are ignored. | [
"/",
"All",
"vertices",
"are",
"projected",
"onto",
"the",
"xz",
"-",
"plane",
"so",
"the",
"y",
"-",
"values",
"are",
"ignored",
"."
] | train | https://github.com/ppiastucki/recast4j/blob/a414dc34f16b87c95fb4e0f46c28a7830d421788/detour/src/main/java/org/recast4j/detour/DetourCommon.java#L407-L436 |
guppy4j/libraries | static/src/main/java/org/guppy4j/Objects.java | Objects.castIfInstance | public static <T> T castIfInstance(Object o, Class<T> c) {
"""
Conditional casting, useful for equals() implementations using instanceof
@param o The other object
@param c The class to check for
@param <T> The generic type of the target class
@return The object cast as a T, or null if o is not an instance of c
"""
return o != null && c.isInstance(o) ? c.cast(o) : null;
} | java | public static <T> T castIfInstance(Object o, Class<T> c) {
return o != null && c.isInstance(o) ? c.cast(o) : null;
} | [
"public",
"static",
"<",
"T",
">",
"T",
"castIfInstance",
"(",
"Object",
"o",
",",
"Class",
"<",
"T",
">",
"c",
")",
"{",
"return",
"o",
"!=",
"null",
"&&",
"c",
".",
"isInstance",
"(",
"o",
")",
"?",
"c",
".",
"cast",
"(",
"o",
")",
":",
"null",
";",
"}"
] | Conditional casting, useful for equals() implementations using instanceof
@param o The other object
@param c The class to check for
@param <T> The generic type of the target class
@return The object cast as a T, or null if o is not an instance of c | [
"Conditional",
"casting",
"useful",
"for",
"equals",
"()",
"implementations",
"using",
"instanceof"
] | train | https://github.com/guppy4j/libraries/blob/5d7a0a7b3fe1ad5c907a5c232b8187727f51f474/static/src/main/java/org/guppy4j/Objects.java#L32-L34 |
fhoeben/hsac-fitnesse-fixtures | src/main/java/nl/hsac/fitnesse/fixture/fit/MapColumnFixture.java | MapColumnFixture.acceptAlternativeInputValuesFromTable | public static void acceptAlternativeInputValuesFromTable(Map<String, Object> rowValues, String[][] leftAcceptedForRight) {
"""
Replaces values found in the rowValues based on the supplied table.
Cell 0,1 defines the key to work with.
Other rows define a replacement value: if value in first column is found
it is replaced with the one from the second.
@param rowValues values to replace in.
@param leftAcceptedForRight table describing replacements.
"""
String key = leftAcceptedForRight[0][1];
Object valuePresent = rowValues.get(key);
String translation = findToValue(leftAcceptedForRight, 0, 1, valuePresent);
if (translation != null) {
rowValues.put(key, translation);
}
} | java | public static void acceptAlternativeInputValuesFromTable(Map<String, Object> rowValues, String[][] leftAcceptedForRight) {
String key = leftAcceptedForRight[0][1];
Object valuePresent = rowValues.get(key);
String translation = findToValue(leftAcceptedForRight, 0, 1, valuePresent);
if (translation != null) {
rowValues.put(key, translation);
}
} | [
"public",
"static",
"void",
"acceptAlternativeInputValuesFromTable",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"rowValues",
",",
"String",
"[",
"]",
"[",
"]",
"leftAcceptedForRight",
")",
"{",
"String",
"key",
"=",
"leftAcceptedForRight",
"[",
"0",
"]",
"[",
"1",
"]",
";",
"Object",
"valuePresent",
"=",
"rowValues",
".",
"get",
"(",
"key",
")",
";",
"String",
"translation",
"=",
"findToValue",
"(",
"leftAcceptedForRight",
",",
"0",
",",
"1",
",",
"valuePresent",
")",
";",
"if",
"(",
"translation",
"!=",
"null",
")",
"{",
"rowValues",
".",
"put",
"(",
"key",
",",
"translation",
")",
";",
"}",
"}"
] | Replaces values found in the rowValues based on the supplied table.
Cell 0,1 defines the key to work with.
Other rows define a replacement value: if value in first column is found
it is replaced with the one from the second.
@param rowValues values to replace in.
@param leftAcceptedForRight table describing replacements. | [
"Replaces",
"values",
"found",
"in",
"the",
"rowValues",
"based",
"on",
"the",
"supplied",
"table",
".",
"Cell",
"0",
"1",
"defines",
"the",
"key",
"to",
"work",
"with",
".",
"Other",
"rows",
"define",
"a",
"replacement",
"value",
":",
"if",
"value",
"in",
"first",
"column",
"is",
"found",
"it",
"is",
"replaced",
"with",
"the",
"one",
"from",
"the",
"second",
"."
] | train | https://github.com/fhoeben/hsac-fitnesse-fixtures/blob/4e9018d7386a9aa65bfcbf07eb28ae064edd1732/src/main/java/nl/hsac/fitnesse/fixture/fit/MapColumnFixture.java#L99-L106 |
jwtk/jjwt | impl/src/main/java/io/jsonwebtoken/impl/crypto/EllipticCurveProvider.java | EllipticCurveProvider.generateKeyPair | public static KeyPair generateKeyPair(SignatureAlgorithm alg, SecureRandom random) {
"""
Generates a new secure-random key pair of sufficient strength for the specified Elliptic Curve {@link
SignatureAlgorithm} (must be one of {@code ES256}, {@code ES384} or {@code ES512}) using the specified {@link
SecureRandom} random number generator. This is a convenience method that immediately delegates to {@link
#generateKeyPair(String, String, SignatureAlgorithm, SecureRandom)} using {@code "EC"} as the {@code
jcaAlgorithmName}.
@param alg alg the algorithm indicating strength, must be one of {@code ES256}, {@code ES384} or {@code
ES512}
@param random the SecureRandom generator to use during key generation.
@return a new secure-randomly generated key pair of sufficient strength for the specified {@link
SignatureAlgorithm} (must be one of {@code ES256}, {@code ES384} or {@code ES512}) using the specified {@link
SecureRandom} random number generator.
@see #generateKeyPair()
@see #generateKeyPair(SignatureAlgorithm)
@see #generateKeyPair(String, String, SignatureAlgorithm, SecureRandom)
"""
return generateKeyPair("EC", null, alg, random);
} | java | public static KeyPair generateKeyPair(SignatureAlgorithm alg, SecureRandom random) {
return generateKeyPair("EC", null, alg, random);
} | [
"public",
"static",
"KeyPair",
"generateKeyPair",
"(",
"SignatureAlgorithm",
"alg",
",",
"SecureRandom",
"random",
")",
"{",
"return",
"generateKeyPair",
"(",
"\"EC\"",
",",
"null",
",",
"alg",
",",
"random",
")",
";",
"}"
] | Generates a new secure-random key pair of sufficient strength for the specified Elliptic Curve {@link
SignatureAlgorithm} (must be one of {@code ES256}, {@code ES384} or {@code ES512}) using the specified {@link
SecureRandom} random number generator. This is a convenience method that immediately delegates to {@link
#generateKeyPair(String, String, SignatureAlgorithm, SecureRandom)} using {@code "EC"} as the {@code
jcaAlgorithmName}.
@param alg alg the algorithm indicating strength, must be one of {@code ES256}, {@code ES384} or {@code
ES512}
@param random the SecureRandom generator to use during key generation.
@return a new secure-randomly generated key pair of sufficient strength for the specified {@link
SignatureAlgorithm} (must be one of {@code ES256}, {@code ES384} or {@code ES512}) using the specified {@link
SecureRandom} random number generator.
@see #generateKeyPair()
@see #generateKeyPair(SignatureAlgorithm)
@see #generateKeyPair(String, String, SignatureAlgorithm, SecureRandom) | [
"Generates",
"a",
"new",
"secure",
"-",
"random",
"key",
"pair",
"of",
"sufficient",
"strength",
"for",
"the",
"specified",
"Elliptic",
"Curve",
"{",
"@link",
"SignatureAlgorithm",
"}",
"(",
"must",
"be",
"one",
"of",
"{",
"@code",
"ES256",
"}",
"{",
"@code",
"ES384",
"}",
"or",
"{",
"@code",
"ES512",
"}",
")",
"using",
"the",
"specified",
"{",
"@link",
"SecureRandom",
"}",
"random",
"number",
"generator",
".",
"This",
"is",
"a",
"convenience",
"method",
"that",
"immediately",
"delegates",
"to",
"{",
"@link",
"#generateKeyPair",
"(",
"String",
"String",
"SignatureAlgorithm",
"SecureRandom",
")",
"}",
"using",
"{",
"@code",
"EC",
"}",
"as",
"the",
"{",
"@code",
"jcaAlgorithmName",
"}",
"."
] | train | https://github.com/jwtk/jjwt/blob/86b6096946752cffcfbc9b0a5503f1ea195cc140/impl/src/main/java/io/jsonwebtoken/impl/crypto/EllipticCurveProvider.java#L103-L105 |
baidubce/bce-sdk-java | src/main/java/com/baidubce/services/tsdb/model/Datapoint.java | Datapoint.addDoubleValue | public Datapoint addDoubleValue(long time, double value) {
"""
Add datapoint of double type value.
@param time datapoint's timestamp
@param value datapoint's value
@return Datapoint
"""
initialValues();
checkType(TsdbConstants.TYPE_DOUBLE);
values.add(Lists.<JsonNode> newArrayList(new LongNode(time), new DoubleNode(value)));
return this;
} | java | public Datapoint addDoubleValue(long time, double value) {
initialValues();
checkType(TsdbConstants.TYPE_DOUBLE);
values.add(Lists.<JsonNode> newArrayList(new LongNode(time), new DoubleNode(value)));
return this;
} | [
"public",
"Datapoint",
"addDoubleValue",
"(",
"long",
"time",
",",
"double",
"value",
")",
"{",
"initialValues",
"(",
")",
";",
"checkType",
"(",
"TsdbConstants",
".",
"TYPE_DOUBLE",
")",
";",
"values",
".",
"add",
"(",
"Lists",
".",
"<",
"JsonNode",
">",
"newArrayList",
"(",
"new",
"LongNode",
"(",
"time",
")",
",",
"new",
"DoubleNode",
"(",
"value",
")",
")",
")",
";",
"return",
"this",
";",
"}"
] | Add datapoint of double type value.
@param time datapoint's timestamp
@param value datapoint's value
@return Datapoint | [
"Add",
"datapoint",
"of",
"double",
"type",
"value",
"."
] | train | https://github.com/baidubce/bce-sdk-java/blob/f7140f28dd82121515c88ded7bfe769a37d0ec4a/src/main/java/com/baidubce/services/tsdb/model/Datapoint.java#L125-L131 |
VueGWT/vue-gwt | processors/src/main/java/com/axellience/vuegwt/processors/component/template/parser/TemplateParser.java | TemplateParser.shouldSkipExpressionProcessing | private boolean shouldSkipExpressionProcessing(String expressionString) {
"""
In some cases we want to skip expression processing for optimization. This is when we are sure
the expression is valid and there is no need to create a Java method for it.
@param expressionString The expression to asses
@return true if we can skip the expression
"""
// We don't skip if it's a component prop as we want Java validation
// We don't optimize String expression, as we want GWT to convert Java values
// to String for us (Enums, wrapped primitives...)
return currentProp == null && !String.class
.getCanonicalName()
.equals(currentExpressionReturnType.toString()) && isSimpleVueJsExpression(
expressionString);
} | java | private boolean shouldSkipExpressionProcessing(String expressionString) {
// We don't skip if it's a component prop as we want Java validation
// We don't optimize String expression, as we want GWT to convert Java values
// to String for us (Enums, wrapped primitives...)
return currentProp == null && !String.class
.getCanonicalName()
.equals(currentExpressionReturnType.toString()) && isSimpleVueJsExpression(
expressionString);
} | [
"private",
"boolean",
"shouldSkipExpressionProcessing",
"(",
"String",
"expressionString",
")",
"{",
"// We don't skip if it's a component prop as we want Java validation",
"// We don't optimize String expression, as we want GWT to convert Java values",
"// to String for us (Enums, wrapped primitives...)",
"return",
"currentProp",
"==",
"null",
"&&",
"!",
"String",
".",
"class",
".",
"getCanonicalName",
"(",
")",
".",
"equals",
"(",
"currentExpressionReturnType",
".",
"toString",
"(",
")",
")",
"&&",
"isSimpleVueJsExpression",
"(",
"expressionString",
")",
";",
"}"
] | In some cases we want to skip expression processing for optimization. This is when we are sure
the expression is valid and there is no need to create a Java method for it.
@param expressionString The expression to asses
@return true if we can skip the expression | [
"In",
"some",
"cases",
"we",
"want",
"to",
"skip",
"expression",
"processing",
"for",
"optimization",
".",
"This",
"is",
"when",
"we",
"are",
"sure",
"the",
"expression",
"is",
"valid",
"and",
"there",
"is",
"no",
"need",
"to",
"create",
"a",
"Java",
"method",
"for",
"it",
"."
] | train | https://github.com/VueGWT/vue-gwt/blob/961cd83aed6fe8e2dd80c279847f1b3f62918a1f/processors/src/main/java/com/axellience/vuegwt/processors/component/template/parser/TemplateParser.java#L591-L599 |
banq/jdonframework | src/main/java/com/jdon/util/UtilDateTime.java | UtilDateTime.toDate | public static java.util.Date toDate(String monthStr, String dayStr, String yearStr, String hourStr, String minuteStr, String secondStr) {
"""
Makes a Date from separate Strings for month, day, year, hour, minute,
and second.
@param monthStr
The month String
@param dayStr
The day String
@param yearStr
The year String
@param hourStr
The hour String
@param minuteStr
The minute String
@param secondStr
The second String
@return A Date made from separate Strings for month, day, year, hour,
minute, and second.
"""
int month, day, year, hour, minute, second;
try {
month = Integer.parseInt(monthStr);
day = Integer.parseInt(dayStr);
year = Integer.parseInt(yearStr);
hour = Integer.parseInt(hourStr);
minute = Integer.parseInt(minuteStr);
second = Integer.parseInt(secondStr);
} catch (Exception e) {
return null;
}
return toDate(month, day, year, hour, minute, second);
} | java | public static java.util.Date toDate(String monthStr, String dayStr, String yearStr, String hourStr, String minuteStr, String secondStr) {
int month, day, year, hour, minute, second;
try {
month = Integer.parseInt(monthStr);
day = Integer.parseInt(dayStr);
year = Integer.parseInt(yearStr);
hour = Integer.parseInt(hourStr);
minute = Integer.parseInt(minuteStr);
second = Integer.parseInt(secondStr);
} catch (Exception e) {
return null;
}
return toDate(month, day, year, hour, minute, second);
} | [
"public",
"static",
"java",
".",
"util",
".",
"Date",
"toDate",
"(",
"String",
"monthStr",
",",
"String",
"dayStr",
",",
"String",
"yearStr",
",",
"String",
"hourStr",
",",
"String",
"minuteStr",
",",
"String",
"secondStr",
")",
"{",
"int",
"month",
",",
"day",
",",
"year",
",",
"hour",
",",
"minute",
",",
"second",
";",
"try",
"{",
"month",
"=",
"Integer",
".",
"parseInt",
"(",
"monthStr",
")",
";",
"day",
"=",
"Integer",
".",
"parseInt",
"(",
"dayStr",
")",
";",
"year",
"=",
"Integer",
".",
"parseInt",
"(",
"yearStr",
")",
";",
"hour",
"=",
"Integer",
".",
"parseInt",
"(",
"hourStr",
")",
";",
"minute",
"=",
"Integer",
".",
"parseInt",
"(",
"minuteStr",
")",
";",
"second",
"=",
"Integer",
".",
"parseInt",
"(",
"secondStr",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"null",
";",
"}",
"return",
"toDate",
"(",
"month",
",",
"day",
",",
"year",
",",
"hour",
",",
"minute",
",",
"second",
")",
";",
"}"
] | Makes a Date from separate Strings for month, day, year, hour, minute,
and second.
@param monthStr
The month String
@param dayStr
The day String
@param yearStr
The year String
@param hourStr
The hour String
@param minuteStr
The minute String
@param secondStr
The second String
@return A Date made from separate Strings for month, day, year, hour,
minute, and second. | [
"Makes",
"a",
"Date",
"from",
"separate",
"Strings",
"for",
"month",
"day",
"year",
"hour",
"minute",
"and",
"second",
"."
] | train | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/util/UtilDateTime.java#L375-L389 |
wcm-io-caravan/caravan-hal | resource/src/main/java/io/wcm/caravan/hal/resource/HalResource.java | HalResource.removeEmbedded | public HalResource removeEmbedded(String relation, int index) {
"""
Removes one embedded resource for the given relation and index.
@param relation Embedded resource relation
@param index Array index
@return HAL resource
"""
return removeResource(HalResourceType.EMBEDDED, relation, index);
} | java | public HalResource removeEmbedded(String relation, int index) {
return removeResource(HalResourceType.EMBEDDED, relation, index);
} | [
"public",
"HalResource",
"removeEmbedded",
"(",
"String",
"relation",
",",
"int",
"index",
")",
"{",
"return",
"removeResource",
"(",
"HalResourceType",
".",
"EMBEDDED",
",",
"relation",
",",
"index",
")",
";",
"}"
] | Removes one embedded resource for the given relation and index.
@param relation Embedded resource relation
@param index Array index
@return HAL resource | [
"Removes",
"one",
"embedded",
"resource",
"for",
"the",
"given",
"relation",
"and",
"index",
"."
] | train | https://github.com/wcm-io-caravan/caravan-hal/blob/25d58756b58c70c8c48a17fe781e673dd93d5085/resource/src/main/java/io/wcm/caravan/hal/resource/HalResource.java#L469-L471 |
haraldk/TwelveMonkeys | imageio/imageio-icns/src/main/java/com/twelvemonkeys/imageio/plugins/icns/ICNSUtil.java | ICNSUtil.decompress | static void decompress(final DataInputStream input, final byte[] result, int offset, int length) throws IOException {
"""
NOTE: This is very close to PackBits (as described by the Wikipedia article), but it is not PackBits!
"""
int resultPos = offset;
int remaining = length;
while (remaining > 0) {
byte run = input.readByte();
int runLength;
if ((run & 0x80) != 0) {
// Compressed run
runLength = run + 131; // PackBits: -run + 1 and run == 0x80 is no-op... This allows 1 byte longer runs...
byte runData = input.readByte();
for (int i = 0; i < runLength; i++) {
result[resultPos++] = runData;
}
}
else {
// Uncompressed run
runLength = run + 1;
input.readFully(result, resultPos, runLength);
resultPos += runLength;
}
remaining -= runLength;
}
} | java | static void decompress(final DataInputStream input, final byte[] result, int offset, int length) throws IOException {
int resultPos = offset;
int remaining = length;
while (remaining > 0) {
byte run = input.readByte();
int runLength;
if ((run & 0x80) != 0) {
// Compressed run
runLength = run + 131; // PackBits: -run + 1 and run == 0x80 is no-op... This allows 1 byte longer runs...
byte runData = input.readByte();
for (int i = 0; i < runLength; i++) {
result[resultPos++] = runData;
}
}
else {
// Uncompressed run
runLength = run + 1;
input.readFully(result, resultPos, runLength);
resultPos += runLength;
}
remaining -= runLength;
}
} | [
"static",
"void",
"decompress",
"(",
"final",
"DataInputStream",
"input",
",",
"final",
"byte",
"[",
"]",
"result",
",",
"int",
"offset",
",",
"int",
"length",
")",
"throws",
"IOException",
"{",
"int",
"resultPos",
"=",
"offset",
";",
"int",
"remaining",
"=",
"length",
";",
"while",
"(",
"remaining",
">",
"0",
")",
"{",
"byte",
"run",
"=",
"input",
".",
"readByte",
"(",
")",
";",
"int",
"runLength",
";",
"if",
"(",
"(",
"run",
"&",
"0x80",
")",
"!=",
"0",
")",
"{",
"// Compressed run",
"runLength",
"=",
"run",
"+",
"131",
";",
"// PackBits: -run + 1 and run == 0x80 is no-op... This allows 1 byte longer runs...",
"byte",
"runData",
"=",
"input",
".",
"readByte",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"runLength",
";",
"i",
"++",
")",
"{",
"result",
"[",
"resultPos",
"++",
"]",
"=",
"runData",
";",
"}",
"}",
"else",
"{",
"// Uncompressed run",
"runLength",
"=",
"run",
"+",
"1",
";",
"input",
".",
"readFully",
"(",
"result",
",",
"resultPos",
",",
"runLength",
")",
";",
"resultPos",
"+=",
"runLength",
";",
"}",
"remaining",
"-=",
"runLength",
";",
"}",
"}"
] | NOTE: This is very close to PackBits (as described by the Wikipedia article), but it is not PackBits! | [
"NOTE",
":",
"This",
"is",
"very",
"close",
"to",
"PackBits",
"(",
"as",
"described",
"by",
"the",
"Wikipedia",
"article",
")",
"but",
"it",
"is",
"not",
"PackBits!"
] | train | https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/imageio/imageio-icns/src/main/java/com/twelvemonkeys/imageio/plugins/icns/ICNSUtil.java#L75-L103 |
jenkinsci/jenkins | core/src/main/java/hudson/FilePath.java | FilePath.act | public <T> T act(final FileCallable<T> callable) throws IOException, InterruptedException {
"""
Executes some program on the machine that this {@link FilePath} exists,
so that one can perform local file operations.
"""
return act(callable,callable.getClass().getClassLoader());
} | java | public <T> T act(final FileCallable<T> callable) throws IOException, InterruptedException {
return act(callable,callable.getClass().getClassLoader());
} | [
"public",
"<",
"T",
">",
"T",
"act",
"(",
"final",
"FileCallable",
"<",
"T",
">",
"callable",
")",
"throws",
"IOException",
",",
"InterruptedException",
"{",
"return",
"act",
"(",
"callable",
",",
"callable",
".",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
")",
";",
"}"
] | Executes some program on the machine that this {@link FilePath} exists,
so that one can perform local file operations. | [
"Executes",
"some",
"program",
"on",
"the",
"machine",
"that",
"this",
"{"
] | train | https://github.com/jenkinsci/jenkins/blob/44c4d3989232082c254d27ae360aa810669f44b7/core/src/main/java/hudson/FilePath.java#L1057-L1059 |
netscaler/nitro | src/main/java/com/citrix/netscaler/nitro/resource/stat/audit/audit_stats.java | audit_stats.get_nitro_response | protected base_resource[] get_nitro_response(nitro_service service, String response) throws Exception {
"""
<pre>
converts nitro response into object and returns the object array in case of get request.
</pre>
"""
audit_stats[] resources = new audit_stats[1];
audit_response result = (audit_response) service.get_payload_formatter().string_to_resource(audit_response.class, response);
if(result.errorcode != 0) {
if (result.errorcode == 444) {
service.clear_session();
}
if(result.severity != null)
{
if (result.severity.equals("ERROR"))
throw new nitro_exception(result.message,result.errorcode);
}
else
{
throw new nitro_exception(result.message,result.errorcode);
}
}
resources[0] = result.audit;
return resources;
} | java | protected base_resource[] get_nitro_response(nitro_service service, String response) throws Exception {
audit_stats[] resources = new audit_stats[1];
audit_response result = (audit_response) service.get_payload_formatter().string_to_resource(audit_response.class, response);
if(result.errorcode != 0) {
if (result.errorcode == 444) {
service.clear_session();
}
if(result.severity != null)
{
if (result.severity.equals("ERROR"))
throw new nitro_exception(result.message,result.errorcode);
}
else
{
throw new nitro_exception(result.message,result.errorcode);
}
}
resources[0] = result.audit;
return resources;
} | [
"protected",
"base_resource",
"[",
"]",
"get_nitro_response",
"(",
"nitro_service",
"service",
",",
"String",
"response",
")",
"throws",
"Exception",
"{",
"audit_stats",
"[",
"]",
"resources",
"=",
"new",
"audit_stats",
"[",
"1",
"]",
";",
"audit_response",
"result",
"=",
"(",
"audit_response",
")",
"service",
".",
"get_payload_formatter",
"(",
")",
".",
"string_to_resource",
"(",
"audit_response",
".",
"class",
",",
"response",
")",
";",
"if",
"(",
"result",
".",
"errorcode",
"!=",
"0",
")",
"{",
"if",
"(",
"result",
".",
"errorcode",
"==",
"444",
")",
"{",
"service",
".",
"clear_session",
"(",
")",
";",
"}",
"if",
"(",
"result",
".",
"severity",
"!=",
"null",
")",
"{",
"if",
"(",
"result",
".",
"severity",
".",
"equals",
"(",
"\"ERROR\"",
")",
")",
"throw",
"new",
"nitro_exception",
"(",
"result",
".",
"message",
",",
"result",
".",
"errorcode",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"nitro_exception",
"(",
"result",
".",
"message",
",",
"result",
".",
"errorcode",
")",
";",
"}",
"}",
"resources",
"[",
"0",
"]",
"=",
"result",
".",
"audit",
";",
"return",
"resources",
";",
"}"
] | <pre>
converts nitro response into object and returns the object array in case of get request.
</pre> | [
"<pre",
">",
"converts",
"nitro",
"response",
"into",
"object",
"and",
"returns",
"the",
"object",
"array",
"in",
"case",
"of",
"get",
"request",
".",
"<",
"/",
"pre",
">"
] | train | https://github.com/netscaler/nitro/blob/2a98692dcf4e4ec430c7d7baab8382e4ba5a35e4/src/main/java/com/citrix/netscaler/nitro/resource/stat/audit/audit_stats.java#L280-L299 |
killme2008/xmemcached | src/main/java/net/rubyeye/xmemcached/auth/AuthInfo.java | AuthInfo.cramMD5 | public static AuthInfo cramMD5(String username, String password) {
"""
Get a typical auth descriptor for CRAM-MD5 auth with the given username and password.
@param u the username
@param p the password
@return an AuthInfo
"""
return new AuthInfo(new PlainCallbackHandler(username, password), new String[] {"CRAM-MD5"});
} | java | public static AuthInfo cramMD5(String username, String password) {
return new AuthInfo(new PlainCallbackHandler(username, password), new String[] {"CRAM-MD5"});
} | [
"public",
"static",
"AuthInfo",
"cramMD5",
"(",
"String",
"username",
",",
"String",
"password",
")",
"{",
"return",
"new",
"AuthInfo",
"(",
"new",
"PlainCallbackHandler",
"(",
"username",
",",
"password",
")",
",",
"new",
"String",
"[",
"]",
"{",
"\"CRAM-MD5\"",
"}",
")",
";",
"}"
] | Get a typical auth descriptor for CRAM-MD5 auth with the given username and password.
@param u the username
@param p the password
@return an AuthInfo | [
"Get",
"a",
"typical",
"auth",
"descriptor",
"for",
"CRAM",
"-",
"MD5",
"auth",
"with",
"the",
"given",
"username",
"and",
"password",
"."
] | train | https://github.com/killme2008/xmemcached/blob/66150915938813b3e3413de1d7b43b6ff9b1478d/src/main/java/net/rubyeye/xmemcached/auth/AuthInfo.java#L60-L62 |
datumbox/datumbox-framework | datumbox-framework-core/src/main/java/com/datumbox/framework/core/mathematics/regularization/L1Regularizer.java | L1Regularizer.estimatePenalty | public static <K> double estimatePenalty(double l1, Map<K, Double> weights) {
"""
Estimates the penalty by adding the L1 regularization.
@param l1
@param weights
@param <K>
@return
"""
double penalty = 0.0;
if(l1 > 0.0) {
double sumAbsWeights = 0.0;
for(double w : weights.values()) {
sumAbsWeights += Math.abs(w);
}
penalty = l1*sumAbsWeights;
}
return penalty;
} | java | public static <K> double estimatePenalty(double l1, Map<K, Double> weights) {
double penalty = 0.0;
if(l1 > 0.0) {
double sumAbsWeights = 0.0;
for(double w : weights.values()) {
sumAbsWeights += Math.abs(w);
}
penalty = l1*sumAbsWeights;
}
return penalty;
} | [
"public",
"static",
"<",
"K",
">",
"double",
"estimatePenalty",
"(",
"double",
"l1",
",",
"Map",
"<",
"K",
",",
"Double",
">",
"weights",
")",
"{",
"double",
"penalty",
"=",
"0.0",
";",
"if",
"(",
"l1",
">",
"0.0",
")",
"{",
"double",
"sumAbsWeights",
"=",
"0.0",
";",
"for",
"(",
"double",
"w",
":",
"weights",
".",
"values",
"(",
")",
")",
"{",
"sumAbsWeights",
"+=",
"Math",
".",
"abs",
"(",
"w",
")",
";",
"}",
"penalty",
"=",
"l1",
"*",
"sumAbsWeights",
";",
"}",
"return",
"penalty",
";",
"}"
] | Estimates the penalty by adding the L1 regularization.
@param l1
@param weights
@param <K>
@return | [
"Estimates",
"the",
"penalty",
"by",
"adding",
"the",
"L1",
"regularization",
"."
] | train | https://github.com/datumbox/datumbox-framework/blob/909dff0476e80834f05ecdde0624dd2390e9b0ca/datumbox-framework-core/src/main/java/com/datumbox/framework/core/mathematics/regularization/L1Regularizer.java#L71-L81 |
JodaOrg/joda-time | src/main/java/org/joda/time/format/DateTimeFormatter.java | DateTimeFormatter.parseInto | public int parseInto(ReadWritableInstant instant, String text, int position) {
"""
Parses a datetime from the given text, at the given position, saving the
result into the fields of the given ReadWritableInstant. If the parse
succeeds, the return value is the new text position. Note that the parse
may succeed without fully reading the text and in this case those fields
that were read will be set.
<p>
Only those fields present in the string will be changed in the specified
instant. All other fields will remain unaltered. Thus if the string only
contains a year and a month, then the day and time will be retained from
the input instant. If this is not the behaviour you want, then reset the
fields before calling this method, or use {@link #parseDateTime(String)}
or {@link #parseMutableDateTime(String)}.
<p>
If it fails, the return value is negative, but the instant may still be
modified. To determine the position where the parse failed, apply the
one's complement operator (~) on the return value.
<p>
This parse method ignores the {@link #getDefaultYear() default year} and
parses using the year from the supplied instant based on the chronology
and time-zone of the supplied instant.
<p>
The parse will use the chronology of the instant.
@param instant an instant that will be modified, not null
@param text the text to parse
@param position position to start parsing from
@return new position, negative value means parse failed -
apply complement operator (~) to get position of failure
@throws UnsupportedOperationException if parsing is not supported
@throws IllegalArgumentException if the instant is null
@throws IllegalArgumentException if any field is out of range
"""
InternalParser parser = requireParser();
if (instant == null) {
throw new IllegalArgumentException("Instant must not be null");
}
long instantMillis = instant.getMillis();
Chronology chrono = instant.getChronology();
int defaultYear = DateTimeUtils.getChronology(chrono).year().get(instantMillis);
long instantLocal = instantMillis + chrono.getZone().getOffset(instantMillis);
chrono = selectChronology(chrono);
DateTimeParserBucket bucket = new DateTimeParserBucket(
instantLocal, chrono, iLocale, iPivotYear, defaultYear);
int newPos = parser.parseInto(bucket, text, position);
instant.setMillis(bucket.computeMillis(false, text));
if (iOffsetParsed && bucket.getOffsetInteger() != null) {
int parsedOffset = bucket.getOffsetInteger();
DateTimeZone parsedZone = DateTimeZone.forOffsetMillis(parsedOffset);
chrono = chrono.withZone(parsedZone);
} else if (bucket.getZone() != null) {
chrono = chrono.withZone(bucket.getZone());
}
instant.setChronology(chrono);
if (iZone != null) {
instant.setZone(iZone);
}
return newPos;
} | java | public int parseInto(ReadWritableInstant instant, String text, int position) {
InternalParser parser = requireParser();
if (instant == null) {
throw new IllegalArgumentException("Instant must not be null");
}
long instantMillis = instant.getMillis();
Chronology chrono = instant.getChronology();
int defaultYear = DateTimeUtils.getChronology(chrono).year().get(instantMillis);
long instantLocal = instantMillis + chrono.getZone().getOffset(instantMillis);
chrono = selectChronology(chrono);
DateTimeParserBucket bucket = new DateTimeParserBucket(
instantLocal, chrono, iLocale, iPivotYear, defaultYear);
int newPos = parser.parseInto(bucket, text, position);
instant.setMillis(bucket.computeMillis(false, text));
if (iOffsetParsed && bucket.getOffsetInteger() != null) {
int parsedOffset = bucket.getOffsetInteger();
DateTimeZone parsedZone = DateTimeZone.forOffsetMillis(parsedOffset);
chrono = chrono.withZone(parsedZone);
} else if (bucket.getZone() != null) {
chrono = chrono.withZone(bucket.getZone());
}
instant.setChronology(chrono);
if (iZone != null) {
instant.setZone(iZone);
}
return newPos;
} | [
"public",
"int",
"parseInto",
"(",
"ReadWritableInstant",
"instant",
",",
"String",
"text",
",",
"int",
"position",
")",
"{",
"InternalParser",
"parser",
"=",
"requireParser",
"(",
")",
";",
"if",
"(",
"instant",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Instant must not be null\"",
")",
";",
"}",
"long",
"instantMillis",
"=",
"instant",
".",
"getMillis",
"(",
")",
";",
"Chronology",
"chrono",
"=",
"instant",
".",
"getChronology",
"(",
")",
";",
"int",
"defaultYear",
"=",
"DateTimeUtils",
".",
"getChronology",
"(",
"chrono",
")",
".",
"year",
"(",
")",
".",
"get",
"(",
"instantMillis",
")",
";",
"long",
"instantLocal",
"=",
"instantMillis",
"+",
"chrono",
".",
"getZone",
"(",
")",
".",
"getOffset",
"(",
"instantMillis",
")",
";",
"chrono",
"=",
"selectChronology",
"(",
"chrono",
")",
";",
"DateTimeParserBucket",
"bucket",
"=",
"new",
"DateTimeParserBucket",
"(",
"instantLocal",
",",
"chrono",
",",
"iLocale",
",",
"iPivotYear",
",",
"defaultYear",
")",
";",
"int",
"newPos",
"=",
"parser",
".",
"parseInto",
"(",
"bucket",
",",
"text",
",",
"position",
")",
";",
"instant",
".",
"setMillis",
"(",
"bucket",
".",
"computeMillis",
"(",
"false",
",",
"text",
")",
")",
";",
"if",
"(",
"iOffsetParsed",
"&&",
"bucket",
".",
"getOffsetInteger",
"(",
")",
"!=",
"null",
")",
"{",
"int",
"parsedOffset",
"=",
"bucket",
".",
"getOffsetInteger",
"(",
")",
";",
"DateTimeZone",
"parsedZone",
"=",
"DateTimeZone",
".",
"forOffsetMillis",
"(",
"parsedOffset",
")",
";",
"chrono",
"=",
"chrono",
".",
"withZone",
"(",
"parsedZone",
")",
";",
"}",
"else",
"if",
"(",
"bucket",
".",
"getZone",
"(",
")",
"!=",
"null",
")",
"{",
"chrono",
"=",
"chrono",
".",
"withZone",
"(",
"bucket",
".",
"getZone",
"(",
")",
")",
";",
"}",
"instant",
".",
"setChronology",
"(",
"chrono",
")",
";",
"if",
"(",
"iZone",
"!=",
"null",
")",
"{",
"instant",
".",
"setZone",
"(",
"iZone",
")",
";",
"}",
"return",
"newPos",
";",
"}"
] | Parses a datetime from the given text, at the given position, saving the
result into the fields of the given ReadWritableInstant. If the parse
succeeds, the return value is the new text position. Note that the parse
may succeed without fully reading the text and in this case those fields
that were read will be set.
<p>
Only those fields present in the string will be changed in the specified
instant. All other fields will remain unaltered. Thus if the string only
contains a year and a month, then the day and time will be retained from
the input instant. If this is not the behaviour you want, then reset the
fields before calling this method, or use {@link #parseDateTime(String)}
or {@link #parseMutableDateTime(String)}.
<p>
If it fails, the return value is negative, but the instant may still be
modified. To determine the position where the parse failed, apply the
one's complement operator (~) on the return value.
<p>
This parse method ignores the {@link #getDefaultYear() default year} and
parses using the year from the supplied instant based on the chronology
and time-zone of the supplied instant.
<p>
The parse will use the chronology of the instant.
@param instant an instant that will be modified, not null
@param text the text to parse
@param position position to start parsing from
@return new position, negative value means parse failed -
apply complement operator (~) to get position of failure
@throws UnsupportedOperationException if parsing is not supported
@throws IllegalArgumentException if the instant is null
@throws IllegalArgumentException if any field is out of range | [
"Parses",
"a",
"datetime",
"from",
"the",
"given",
"text",
"at",
"the",
"given",
"position",
"saving",
"the",
"result",
"into",
"the",
"fields",
"of",
"the",
"given",
"ReadWritableInstant",
".",
"If",
"the",
"parse",
"succeeds",
"the",
"return",
"value",
"is",
"the",
"new",
"text",
"position",
".",
"Note",
"that",
"the",
"parse",
"may",
"succeed",
"without",
"fully",
"reading",
"the",
"text",
"and",
"in",
"this",
"case",
"those",
"fields",
"that",
"were",
"read",
"will",
"be",
"set",
".",
"<p",
">",
"Only",
"those",
"fields",
"present",
"in",
"the",
"string",
"will",
"be",
"changed",
"in",
"the",
"specified",
"instant",
".",
"All",
"other",
"fields",
"will",
"remain",
"unaltered",
".",
"Thus",
"if",
"the",
"string",
"only",
"contains",
"a",
"year",
"and",
"a",
"month",
"then",
"the",
"day",
"and",
"time",
"will",
"be",
"retained",
"from",
"the",
"input",
"instant",
".",
"If",
"this",
"is",
"not",
"the",
"behaviour",
"you",
"want",
"then",
"reset",
"the",
"fields",
"before",
"calling",
"this",
"method",
"or",
"use",
"{",
"@link",
"#parseDateTime",
"(",
"String",
")",
"}",
"or",
"{",
"@link",
"#parseMutableDateTime",
"(",
"String",
")",
"}",
".",
"<p",
">",
"If",
"it",
"fails",
"the",
"return",
"value",
"is",
"negative",
"but",
"the",
"instant",
"may",
"still",
"be",
"modified",
".",
"To",
"determine",
"the",
"position",
"where",
"the",
"parse",
"failed",
"apply",
"the",
"one",
"s",
"complement",
"operator",
"(",
"~",
")",
"on",
"the",
"return",
"value",
".",
"<p",
">",
"This",
"parse",
"method",
"ignores",
"the",
"{",
"@link",
"#getDefaultYear",
"()",
"default",
"year",
"}",
"and",
"parses",
"using",
"the",
"year",
"from",
"the",
"supplied",
"instant",
"based",
"on",
"the",
"chronology",
"and",
"time",
"-",
"zone",
"of",
"the",
"supplied",
"instant",
".",
"<p",
">",
"The",
"parse",
"will",
"use",
"the",
"chronology",
"of",
"the",
"instant",
"."
] | train | https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/format/DateTimeFormatter.java#L780-L808 |
Omertron/api-themoviedb | src/main/java/com/omertron/themoviedbapi/methods/TmdbPeople.java | TmdbPeople.getPersonInfo | public PersonInfo getPersonInfo(int personId, String... appendToResponse) throws MovieDbException {
"""
Get the general person information for a specific id.
@param personId
@param appendToResponse
@return
@throws MovieDbException
"""
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, personId);
parameters.add(Param.APPEND, appendToResponse);
// Switch combined credits for tv & movie.
String atr = (String) parameters.get(Param.APPEND);
if (StringUtils.isNotBlank(atr) && atr.contains("combined_credits")) {
atr = atr.replace("combined_credits", "tv_credits,movie_credits");
parameters.add(Param.APPEND, atr);
}
URL url = new ApiUrl(apiKey, MethodBase.PERSON).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
return MAPPER.readValue(webpage, PersonInfo.class);
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get person info", url, ex);
}
} | java | public PersonInfo getPersonInfo(int personId, String... appendToResponse) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, personId);
parameters.add(Param.APPEND, appendToResponse);
// Switch combined credits for tv & movie.
String atr = (String) parameters.get(Param.APPEND);
if (StringUtils.isNotBlank(atr) && atr.contains("combined_credits")) {
atr = atr.replace("combined_credits", "tv_credits,movie_credits");
parameters.add(Param.APPEND, atr);
}
URL url = new ApiUrl(apiKey, MethodBase.PERSON).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
return MAPPER.readValue(webpage, PersonInfo.class);
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get person info", url, ex);
}
} | [
"public",
"PersonInfo",
"getPersonInfo",
"(",
"int",
"personId",
",",
"String",
"...",
"appendToResponse",
")",
"throws",
"MovieDbException",
"{",
"TmdbParameters",
"parameters",
"=",
"new",
"TmdbParameters",
"(",
")",
";",
"parameters",
".",
"add",
"(",
"Param",
".",
"ID",
",",
"personId",
")",
";",
"parameters",
".",
"add",
"(",
"Param",
".",
"APPEND",
",",
"appendToResponse",
")",
";",
"// Switch combined credits for tv & movie.",
"String",
"atr",
"=",
"(",
"String",
")",
"parameters",
".",
"get",
"(",
"Param",
".",
"APPEND",
")",
";",
"if",
"(",
"StringUtils",
".",
"isNotBlank",
"(",
"atr",
")",
"&&",
"atr",
".",
"contains",
"(",
"\"combined_credits\"",
")",
")",
"{",
"atr",
"=",
"atr",
".",
"replace",
"(",
"\"combined_credits\"",
",",
"\"tv_credits,movie_credits\"",
")",
";",
"parameters",
".",
"add",
"(",
"Param",
".",
"APPEND",
",",
"atr",
")",
";",
"}",
"URL",
"url",
"=",
"new",
"ApiUrl",
"(",
"apiKey",
",",
"MethodBase",
".",
"PERSON",
")",
".",
"buildUrl",
"(",
"parameters",
")",
";",
"String",
"webpage",
"=",
"httpTools",
".",
"getRequest",
"(",
"url",
")",
";",
"try",
"{",
"return",
"MAPPER",
".",
"readValue",
"(",
"webpage",
",",
"PersonInfo",
".",
"class",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"MovieDbException",
"(",
"ApiExceptionType",
".",
"MAPPING_FAILED",
",",
"\"Failed to get person info\"",
",",
"url",
",",
"ex",
")",
";",
"}",
"}"
] | Get the general person information for a specific id.
@param personId
@param appendToResponse
@return
@throws MovieDbException | [
"Get",
"the",
"general",
"person",
"information",
"for",
"a",
"specific",
"id",
"."
] | train | https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbPeople.java#L77-L97 |
yegor256/takes | src/main/java/org/takes/rs/RsWithHeaders.java | RsWithHeaders.extend | @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
private static Iterable<String> extend(final Response res,
final Iterable<? extends CharSequence> headers) throws IOException {
"""
Add to head additional headers.
@param res Original response
@param headers Values witch will be added to head
@return Head with additional headers
@throws IOException If fails
"""
Response resp = res;
for (final CharSequence hdr: headers) {
resp = new RsWithHeader(resp, hdr);
}
return resp.head();
} | java | @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
private static Iterable<String> extend(final Response res,
final Iterable<? extends CharSequence> headers) throws IOException {
Response resp = res;
for (final CharSequence hdr: headers) {
resp = new RsWithHeader(resp, hdr);
}
return resp.head();
} | [
"@",
"SuppressWarnings",
"(",
"\"PMD.AvoidInstantiatingObjectsInLoops\"",
")",
"private",
"static",
"Iterable",
"<",
"String",
">",
"extend",
"(",
"final",
"Response",
"res",
",",
"final",
"Iterable",
"<",
"?",
"extends",
"CharSequence",
">",
"headers",
")",
"throws",
"IOException",
"{",
"Response",
"resp",
"=",
"res",
";",
"for",
"(",
"final",
"CharSequence",
"hdr",
":",
"headers",
")",
"{",
"resp",
"=",
"new",
"RsWithHeader",
"(",
"resp",
",",
"hdr",
")",
";",
"}",
"return",
"resp",
".",
"head",
"(",
")",
";",
"}"
] | Add to head additional headers.
@param res Original response
@param headers Values witch will be added to head
@return Head with additional headers
@throws IOException If fails | [
"Add",
"to",
"head",
"additional",
"headers",
"."
] | train | https://github.com/yegor256/takes/blob/a4f4d939c8f8e0af190025716ad7f22b7de40e70/src/main/java/org/takes/rs/RsWithHeaders.java#L90-L98 |
apiman/apiman | gateway/engine/ispn/src/main/java/io/apiman/gateway/engine/ispn/io/RegistryCacheMapWrapper.java | RegistryCacheMapWrapper.unmarshalAs | private <T> T unmarshalAs(String valueAsString, Class<T> asClass) throws IOException {
"""
Unmarshall the given type of object.
@param valueAsString
@param asClass
@throws IOException
"""
return mapper.reader(asClass).readValue(valueAsString);
} | java | private <T> T unmarshalAs(String valueAsString, Class<T> asClass) throws IOException {
return mapper.reader(asClass).readValue(valueAsString);
} | [
"private",
"<",
"T",
">",
"T",
"unmarshalAs",
"(",
"String",
"valueAsString",
",",
"Class",
"<",
"T",
">",
"asClass",
")",
"throws",
"IOException",
"{",
"return",
"mapper",
".",
"reader",
"(",
"asClass",
")",
".",
"readValue",
"(",
"valueAsString",
")",
";",
"}"
] | Unmarshall the given type of object.
@param valueAsString
@param asClass
@throws IOException | [
"Unmarshall",
"the",
"given",
"type",
"of",
"object",
"."
] | train | https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/ispn/src/main/java/io/apiman/gateway/engine/ispn/io/RegistryCacheMapWrapper.java#L188-L190 |
Azure/azure-sdk-for-java | keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java | KeyVaultClientBaseImpl.updateCertificateIssuerAsync | public ServiceFuture<IssuerBundle> updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes, final ServiceCallback<IssuerBundle> serviceCallback) {
"""
Updates the specified certificate issuer.
The UpdateCertificateIssuer operation performs an update on the specified certificate issuer entity. This operation requires the certificates/setissuers permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param issuerName The name of the issuer.
@param provider The issuer provider.
@param credentials The credentials to be used for the issuer.
@param organizationDetails Details of the organization as provided to the issuer.
@param attributes Attributes of the issuer object.
@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(updateCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes), serviceCallback);
} | java | public ServiceFuture<IssuerBundle> updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes, final ServiceCallback<IssuerBundle> serviceCallback) {
return ServiceFuture.fromResponse(updateCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes), serviceCallback);
} | [
"public",
"ServiceFuture",
"<",
"IssuerBundle",
">",
"updateCertificateIssuerAsync",
"(",
"String",
"vaultBaseUrl",
",",
"String",
"issuerName",
",",
"String",
"provider",
",",
"IssuerCredentials",
"credentials",
",",
"OrganizationDetails",
"organizationDetails",
",",
"IssuerAttributes",
"attributes",
",",
"final",
"ServiceCallback",
"<",
"IssuerBundle",
">",
"serviceCallback",
")",
"{",
"return",
"ServiceFuture",
".",
"fromResponse",
"(",
"updateCertificateIssuerWithServiceResponseAsync",
"(",
"vaultBaseUrl",
",",
"issuerName",
",",
"provider",
",",
"credentials",
",",
"organizationDetails",
",",
"attributes",
")",
",",
"serviceCallback",
")",
";",
"}"
] | Updates the specified certificate issuer.
The UpdateCertificateIssuer operation performs an update on the specified certificate issuer entity. This operation requires the certificates/setissuers permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param issuerName The name of the issuer.
@param provider The issuer provider.
@param credentials The credentials to be used for the issuer.
@param organizationDetails Details of the organization as provided to the issuer.
@param attributes Attributes of the issuer object.
@param serviceCallback the async ServiceCallback to handle successful and failed responses.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceFuture} object | [
"Updates",
"the",
"specified",
"certificate",
"issuer",
".",
"The",
"UpdateCertificateIssuer",
"operation",
"performs",
"an",
"update",
"on",
"the",
"specified",
"certificate",
"issuer",
"entity",
".",
"This",
"operation",
"requires",
"the",
"certificates",
"/",
"setissuers",
"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#L6222-L6224 |
juebanlin/util4j | util4j/src/main/java/net/jueb/util4j/bytesStream/bytes/HexUtil.java | HexUtil.SimplePrettyHexDump | public static String SimplePrettyHexDump(byte bytes[], int offset, int length) {
"""
将字节转换成十六进制字符串
@param bytes 数据
@param offset 起始位置
@param length 从起始位置开始的长度
@return
"""
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(bos);
int rows = length / 16;//打印的行数
int ac = length % 16;//剩余的字节数
for (int i = 0; i < rows; ++i)
ps.printf("%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n", //
bytes[offset + (16 * i) + 0], //
bytes[offset + (16 * i) + 1], //
bytes[offset + (16 * i) + 2], //
bytes[offset + (16 * i) + 3], //
bytes[offset + (16 * i) + 4], //
bytes[offset + (16 * i) + 5], //
bytes[offset + (16 * i) + 6], //
bytes[offset + (16 * i) + 7], //
bytes[offset + (16 * i) + 8], //
bytes[offset + (16 * i) + 9], //
bytes[offset + (16 * i) + 10], //
bytes[offset + (16 * i) + 11], //
bytes[offset + (16 * i) + 12], //
bytes[offset + (16 * i) + 13], //
bytes[offset + (16 * i) + 14], //
bytes[offset + (16 * i) + 15], //
byteToChar(bytes[offset + (16 * i) + 0]), //
byteToChar(bytes[offset + (16 * i) + 1]), //
byteToChar(bytes[offset + (16 * i) + 2]), //
byteToChar(bytes[offset + (16 * i) + 3]), //
byteToChar(bytes[offset + (16 * i) + 4]), //
byteToChar(bytes[offset + (16 * i) + 5]), //
byteToChar(bytes[offset + (16 * i) + 6]), //
byteToChar(bytes[offset + (16 * i) + 7]), //
byteToChar(bytes[offset + (16 * i) + 8]), //
byteToChar(bytes[offset + (16 * i) + 9]), //
byteToChar(bytes[offset + (16 * i) + 10]), //
byteToChar(bytes[offset + (16 * i) + 11]), //
byteToChar(bytes[offset + (16 * i) + 12]), //
byteToChar(bytes[offset + (16 * i) + 13]), //
byteToChar(bytes[offset + (16 * i) + 14]), //
byteToChar(bytes[offset + (16 * i) + 15]));
for (int i = 0; i < ac; i++)
ps.printf("%02X ", bytes[offset + rows * 16 + i]);
for (int i = 0; ac > 0 && i < 16 - ac; i++)
ps.printf("%s", " ");
for (int i = 0; i < ac; i++)
ps.printf("%c", byteToChar(bytes[offset + rows * 16 + i]));
return bos.toString();
} | java | public static String SimplePrettyHexDump(byte bytes[], int offset, int length)
{
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(bos);
int rows = length / 16;//打印的行数
int ac = length % 16;//剩余的字节数
for (int i = 0; i < rows; ++i)
ps.printf("%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n", //
bytes[offset + (16 * i) + 0], //
bytes[offset + (16 * i) + 1], //
bytes[offset + (16 * i) + 2], //
bytes[offset + (16 * i) + 3], //
bytes[offset + (16 * i) + 4], //
bytes[offset + (16 * i) + 5], //
bytes[offset + (16 * i) + 6], //
bytes[offset + (16 * i) + 7], //
bytes[offset + (16 * i) + 8], //
bytes[offset + (16 * i) + 9], //
bytes[offset + (16 * i) + 10], //
bytes[offset + (16 * i) + 11], //
bytes[offset + (16 * i) + 12], //
bytes[offset + (16 * i) + 13], //
bytes[offset + (16 * i) + 14], //
bytes[offset + (16 * i) + 15], //
byteToChar(bytes[offset + (16 * i) + 0]), //
byteToChar(bytes[offset + (16 * i) + 1]), //
byteToChar(bytes[offset + (16 * i) + 2]), //
byteToChar(bytes[offset + (16 * i) + 3]), //
byteToChar(bytes[offset + (16 * i) + 4]), //
byteToChar(bytes[offset + (16 * i) + 5]), //
byteToChar(bytes[offset + (16 * i) + 6]), //
byteToChar(bytes[offset + (16 * i) + 7]), //
byteToChar(bytes[offset + (16 * i) + 8]), //
byteToChar(bytes[offset + (16 * i) + 9]), //
byteToChar(bytes[offset + (16 * i) + 10]), //
byteToChar(bytes[offset + (16 * i) + 11]), //
byteToChar(bytes[offset + (16 * i) + 12]), //
byteToChar(bytes[offset + (16 * i) + 13]), //
byteToChar(bytes[offset + (16 * i) + 14]), //
byteToChar(bytes[offset + (16 * i) + 15]));
for (int i = 0; i < ac; i++)
ps.printf("%02X ", bytes[offset + rows * 16 + i]);
for (int i = 0; ac > 0 && i < 16 - ac; i++)
ps.printf("%s", " ");
for (int i = 0; i < ac; i++)
ps.printf("%c", byteToChar(bytes[offset + rows * 16 + i]));
return bos.toString();
} | [
"public",
"static",
"String",
"SimplePrettyHexDump",
"(",
"byte",
"bytes",
"[",
"]",
",",
"int",
"offset",
",",
"int",
"length",
")",
"{",
"ByteArrayOutputStream",
"bos",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"PrintStream",
"ps",
"=",
"new",
"PrintStream",
"(",
"bos",
")",
";",
"int",
"rows",
"=",
"length",
"/",
"16",
";",
"//打印的行数",
"int",
"ac",
"=",
"length",
"%",
"16",
";",
"//剩余的字节数",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"rows",
";",
"++",
"i",
")",
"ps",
".",
"printf",
"(",
"\"%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\\n\"",
"",
",",
"//",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"0",
"]",
",",
"//",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"1",
"]",
",",
"//",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"2",
"]",
",",
"//",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"3",
"]",
",",
"//",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"4",
"]",
",",
"//",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"5",
"]",
",",
"//",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"6",
"]",
",",
"//",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"7",
"]",
",",
"//",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"8",
"]",
",",
"//",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"9",
"]",
",",
"//",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"10",
"]",
",",
"//",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"11",
"]",
",",
"//",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"12",
"]",
",",
"//",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"13",
"]",
",",
"//",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"14",
"]",
",",
"//",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"15",
"]",
",",
"//",
"byteToChar",
"(",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"0",
"]",
")",
",",
"//",
"byteToChar",
"(",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"1",
"]",
")",
",",
"//",
"byteToChar",
"(",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"2",
"]",
")",
",",
"//",
"byteToChar",
"(",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"3",
"]",
")",
",",
"//",
"byteToChar",
"(",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"4",
"]",
")",
",",
"//",
"byteToChar",
"(",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"5",
"]",
")",
",",
"//",
"byteToChar",
"(",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"6",
"]",
")",
",",
"//",
"byteToChar",
"(",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"7",
"]",
")",
",",
"//",
"byteToChar",
"(",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"8",
"]",
")",
",",
"//",
"byteToChar",
"(",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"9",
"]",
")",
",",
"//",
"byteToChar",
"(",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"10",
"]",
")",
",",
"//",
"byteToChar",
"(",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"11",
"]",
")",
",",
"//",
"byteToChar",
"(",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"12",
"]",
")",
",",
"//",
"byteToChar",
"(",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"13",
"]",
")",
",",
"//",
"byteToChar",
"(",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"14",
"]",
")",
",",
"//",
"byteToChar",
"(",
"bytes",
"[",
"offset",
"+",
"(",
"16",
"*",
"i",
")",
"+",
"15",
"]",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"ac",
";",
"i",
"++",
")",
"ps",
".",
"printf",
"(",
"\"%02X \"",
"",
",",
"bytes",
"[",
"offset",
"+",
"rows",
"*",
"16",
"+",
"i",
"]",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"ac",
">",
"0",
"&&",
"i",
"<",
"16",
"-",
"ac",
";",
"i",
"++",
")",
"ps",
".",
"printf",
"(",
"\"%s\"",
"",
",",
"\" \"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"ac",
";",
"i",
"++",
")",
"ps",
".",
"printf",
"(",
"\"%c\"",
"",
",",
"byteToChar",
"(",
"bytes",
"[",
"offset",
"+",
"rows",
"*",
"16",
"+",
"i",
"]",
")",
")",
";",
"return",
"bos",
".",
"toString",
"(",
")",
";",
"}"
] | 将字节转换成十六进制字符串
@param bytes 数据
@param offset 起始位置
@param length 从起始位置开始的长度
@return | [
"将字节转换成十六进制字符串"
] | train | https://github.com/juebanlin/util4j/blob/c404b2dbdedf7a8890533b351257fa8af4f1439f/util4j/src/main/java/net/jueb/util4j/bytesStream/bytes/HexUtil.java#L291-L338 |
landawn/AbacusUtil | src/com/landawn/abacus/hash/BloomFilter.java | BloomFilter.optimalNumOfHashFunctions | static int optimalNumOfHashFunctions(long n, long m) {
"""
Computes the optimal k (number of hashes per element inserted in Bloom filter), given the
expected insertions and total number of bits in the Bloom filter.
See http://en.wikipedia.org/wiki/File:Bloom_filter_fp_probability.svg for the formula.
@param n expected insertions (must be positive)
@param m total number of bits in Bloom filter (must be positive)
"""
// (m / n) * log(2), but avoid truncation due to division!
return Math.max(1, (int) Math.round((double) m / n * Math.log(2)));
} | java | static int optimalNumOfHashFunctions(long n, long m) {
// (m / n) * log(2), but avoid truncation due to division!
return Math.max(1, (int) Math.round((double) m / n * Math.log(2)));
} | [
"static",
"int",
"optimalNumOfHashFunctions",
"(",
"long",
"n",
",",
"long",
"m",
")",
"{",
"// (m / n) * log(2), but avoid truncation due to division!",
"return",
"Math",
".",
"max",
"(",
"1",
",",
"(",
"int",
")",
"Math",
".",
"round",
"(",
"(",
"double",
")",
"m",
"/",
"n",
"*",
"Math",
".",
"log",
"(",
"2",
")",
")",
")",
";",
"}"
] | Computes the optimal k (number of hashes per element inserted in Bloom filter), given the
expected insertions and total number of bits in the Bloom filter.
See http://en.wikipedia.org/wiki/File:Bloom_filter_fp_probability.svg for the formula.
@param n expected insertions (must be positive)
@param m total number of bits in Bloom filter (must be positive) | [
"Computes",
"the",
"optimal",
"k",
"(",
"number",
"of",
"hashes",
"per",
"element",
"inserted",
"in",
"Bloom",
"filter",
")",
"given",
"the",
"expected",
"insertions",
"and",
"total",
"number",
"of",
"bits",
"in",
"the",
"Bloom",
"filter",
"."
] | train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/hash/BloomFilter.java#L386-L389 |
rhuss/jolokia | agent/core/src/main/java/org/jolokia/detector/AbstractServerDetector.java | AbstractServerDetector.getVersionFromJsr77 | protected String getVersionFromJsr77(MBeanServerExecutor pMbeanServers) {
"""
Get the version number from a JSR-77 compliant server
@param pMbeanServers servers to query
@return version number or null if not found.
"""
Set<ObjectName> names = searchMBeans(pMbeanServers, "*:j2eeType=J2EEServer,*");
// Take the first one
if (names.size() > 0) {
return getAttributeValue(pMbeanServers, names.iterator().next(), "serverVersion");
}
return null;
} | java | protected String getVersionFromJsr77(MBeanServerExecutor pMbeanServers) {
Set<ObjectName> names = searchMBeans(pMbeanServers, "*:j2eeType=J2EEServer,*");
// Take the first one
if (names.size() > 0) {
return getAttributeValue(pMbeanServers, names.iterator().next(), "serverVersion");
}
return null;
} | [
"protected",
"String",
"getVersionFromJsr77",
"(",
"MBeanServerExecutor",
"pMbeanServers",
")",
"{",
"Set",
"<",
"ObjectName",
">",
"names",
"=",
"searchMBeans",
"(",
"pMbeanServers",
",",
"\"*:j2eeType=J2EEServer,*\"",
")",
";",
"// Take the first one",
"if",
"(",
"names",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"return",
"getAttributeValue",
"(",
"pMbeanServers",
",",
"names",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
",",
"\"serverVersion\"",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Get the version number from a JSR-77 compliant server
@param pMbeanServers servers to query
@return version number or null if not found. | [
"Get",
"the",
"version",
"number",
"from",
"a",
"JSR",
"-",
"77",
"compliant",
"server"
] | train | https://github.com/rhuss/jolokia/blob/dc95e7bef859b1829776c5a84c8f7738f5d7d9c3/agent/core/src/main/java/org/jolokia/detector/AbstractServerDetector.java#L148-L155 |
dropwizard/metrics | metrics-core/src/main/java/com/codahale/metrics/ConsoleReporter.java | ConsoleReporter.printIfEnabled | private void printIfEnabled(MetricAttribute type, String status) {
"""
Print only if the attribute is enabled
@param type Metric attribute
@param status Status to be logged
"""
if (getDisabledMetricAttributes().contains(type)) {
return;
}
output.println(status);
} | java | private void printIfEnabled(MetricAttribute type, String status) {
if (getDisabledMetricAttributes().contains(type)) {
return;
}
output.println(status);
} | [
"private",
"void",
"printIfEnabled",
"(",
"MetricAttribute",
"type",
",",
"String",
"status",
")",
"{",
"if",
"(",
"getDisabledMetricAttributes",
"(",
")",
".",
"contains",
"(",
"type",
")",
")",
"{",
"return",
";",
"}",
"output",
".",
"println",
"(",
"status",
")",
";",
"}"
] | Print only if the attribute is enabled
@param type Metric attribute
@param status Status to be logged | [
"Print",
"only",
"if",
"the",
"attribute",
"is",
"enabled"
] | train | https://github.com/dropwizard/metrics/blob/3c6105a0b9b4416c59e16b6b841b123052d6f57d/metrics-core/src/main/java/com/codahale/metrics/ConsoleReporter.java#L350-L356 |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/StatementManager.java | StatementManager.getDeleteStatement | public PreparedStatement getDeleteStatement(ClassDescriptor cld) throws PersistenceBrokerSQLException, PersistenceBrokerException {
"""
return a prepared DELETE Statement fitting for the given ClassDescriptor
"""
try
{
return cld.getStatementsForClass(m_conMan).getDeleteStmt(m_conMan.getConnection());
}
catch (SQLException e)
{
throw new PersistenceBrokerSQLException("Could not build statement ask for", e);
}
catch (LookupException e)
{
throw new PersistenceBrokerException("Used ConnectionManager instance could not obtain a connection", e);
}
} | java | public PreparedStatement getDeleteStatement(ClassDescriptor cld) throws PersistenceBrokerSQLException, PersistenceBrokerException
{
try
{
return cld.getStatementsForClass(m_conMan).getDeleteStmt(m_conMan.getConnection());
}
catch (SQLException e)
{
throw new PersistenceBrokerSQLException("Could not build statement ask for", e);
}
catch (LookupException e)
{
throw new PersistenceBrokerException("Used ConnectionManager instance could not obtain a connection", e);
}
} | [
"public",
"PreparedStatement",
"getDeleteStatement",
"(",
"ClassDescriptor",
"cld",
")",
"throws",
"PersistenceBrokerSQLException",
",",
"PersistenceBrokerException",
"{",
"try",
"{",
"return",
"cld",
".",
"getStatementsForClass",
"(",
"m_conMan",
")",
".",
"getDeleteStmt",
"(",
"m_conMan",
".",
"getConnection",
"(",
")",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"new",
"PersistenceBrokerSQLException",
"(",
"\"Could not build statement ask for\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"LookupException",
"e",
")",
"{",
"throw",
"new",
"PersistenceBrokerException",
"(",
"\"Used ConnectionManager instance could not obtain a connection\"",
",",
"e",
")",
";",
"}",
"}"
] | return a prepared DELETE Statement fitting for the given ClassDescriptor | [
"return",
"a",
"prepared",
"DELETE",
"Statement",
"fitting",
"for",
"the",
"given",
"ClassDescriptor"
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/StatementManager.java#L549-L563 |
Bedework/bw-util | bw-util-http/src/main/java/org/bedework/util/http/BasicHttpClient.java | BasicHttpClient.setCredentials | public void setCredentials(final String user, final String pw) {
"""
Set the credentials. user == null for unauthenticated.
@param user
@param pw
"""
if (user == null) {
credentials = null;
} else {
credentials = new UsernamePasswordCredentials(user, pw);
}
} | java | public void setCredentials(final String user, final String pw) {
if (user == null) {
credentials = null;
} else {
credentials = new UsernamePasswordCredentials(user, pw);
}
} | [
"public",
"void",
"setCredentials",
"(",
"final",
"String",
"user",
",",
"final",
"String",
"pw",
")",
"{",
"if",
"(",
"user",
"==",
"null",
")",
"{",
"credentials",
"=",
"null",
";",
"}",
"else",
"{",
"credentials",
"=",
"new",
"UsernamePasswordCredentials",
"(",
"user",
",",
"pw",
")",
";",
"}",
"}"
] | Set the credentials. user == null for unauthenticated.
@param user
@param pw | [
"Set",
"the",
"credentials",
".",
"user",
"==",
"null",
"for",
"unauthenticated",
"."
] | train | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-http/src/main/java/org/bedework/util/http/BasicHttpClient.java#L420-L426 |
OpenLiberty/open-liberty | dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ws/traceinfo/ejbcontainer/TETxLifeCycleInfo.java | TETxLifeCycleInfo.traceCommon | public static void traceCommon(int opType, String txId, String desc) {
"""
This is called by the EJB container server code to write a
common record to the trace log, if enabled.
"""
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
{
StringBuffer sbuf = new StringBuffer();
sbuf
.append(TxLifeCycle_State_Type_Str).append(DataDelimiter)
.append(TxLifeCycle_State_Type).append(DataDelimiter)
.append(opType).append(DataDelimiter)
.append(txId).append(DataDelimiter)
.append(desc);
Tr.debug(tc, sbuf.toString());
}
} | java | public static void traceCommon(int opType, String txId, String desc)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
{
StringBuffer sbuf = new StringBuffer();
sbuf
.append(TxLifeCycle_State_Type_Str).append(DataDelimiter)
.append(TxLifeCycle_State_Type).append(DataDelimiter)
.append(opType).append(DataDelimiter)
.append(txId).append(DataDelimiter)
.append(desc);
Tr.debug(tc, sbuf.toString());
}
} | [
"public",
"static",
"void",
"traceCommon",
"(",
"int",
"opType",
",",
"String",
"txId",
",",
"String",
"desc",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"StringBuffer",
"sbuf",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"sbuf",
".",
"append",
"(",
"TxLifeCycle_State_Type_Str",
")",
".",
"append",
"(",
"DataDelimiter",
")",
".",
"append",
"(",
"TxLifeCycle_State_Type",
")",
".",
"append",
"(",
"DataDelimiter",
")",
".",
"append",
"(",
"opType",
")",
".",
"append",
"(",
"DataDelimiter",
")",
".",
"append",
"(",
"txId",
")",
".",
"append",
"(",
"DataDelimiter",
")",
".",
"append",
"(",
"desc",
")",
";",
"Tr",
".",
"debug",
"(",
"tc",
",",
"sbuf",
".",
"toString",
"(",
")",
")",
";",
"}",
"}"
] | This is called by the EJB container server code to write a
common record to the trace log, if enabled. | [
"This",
"is",
"called",
"by",
"the",
"EJB",
"container",
"server",
"code",
"to",
"write",
"a",
"common",
"record",
"to",
"the",
"trace",
"log",
"if",
"enabled",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ws/traceinfo/ejbcontainer/TETxLifeCycleInfo.java#L76-L91 |
Azure/azure-sdk-for-java | applicationinsights/resource-manager/v2015_05_01/src/main/java/com/microsoft/azure/management/applicationinsights/v2015_05_01/implementation/ComponentsInner.java | ComponentsInner.getByResourceGroupAsync | public Observable<ApplicationInsightsComponentInner> getByResourceGroupAsync(String resourceGroupName, String resourceName) {
"""
Returns an Application Insights component.
@param resourceGroupName The name of the resource group.
@param resourceName The name of the Application Insights component resource.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ApplicationInsightsComponentInner object
"""
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, resourceName).map(new Func1<ServiceResponse<ApplicationInsightsComponentInner>, ApplicationInsightsComponentInner>() {
@Override
public ApplicationInsightsComponentInner call(ServiceResponse<ApplicationInsightsComponentInner> response) {
return response.body();
}
});
} | java | public Observable<ApplicationInsightsComponentInner> getByResourceGroupAsync(String resourceGroupName, String resourceName) {
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, resourceName).map(new Func1<ServiceResponse<ApplicationInsightsComponentInner>, ApplicationInsightsComponentInner>() {
@Override
public ApplicationInsightsComponentInner call(ServiceResponse<ApplicationInsightsComponentInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ApplicationInsightsComponentInner",
">",
"getByResourceGroupAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"resourceName",
")",
"{",
"return",
"getByResourceGroupWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"resourceName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"ApplicationInsightsComponentInner",
">",
",",
"ApplicationInsightsComponentInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ApplicationInsightsComponentInner",
"call",
"(",
"ServiceResponse",
"<",
"ApplicationInsightsComponentInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Returns an Application Insights component.
@param resourceGroupName The name of the resource group.
@param resourceName The name of the Application Insights component resource.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ApplicationInsightsComponentInner object | [
"Returns",
"an",
"Application",
"Insights",
"component",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/applicationinsights/resource-manager/v2015_05_01/src/main/java/com/microsoft/azure/management/applicationinsights/v2015_05_01/implementation/ComponentsInner.java#L457-L464 |
lucee/Lucee | core/src/main/java/lucee/commons/io/res/util/ResourceUtil.java | ResourceUtil.getPathToChild | public static String getPathToChild(Resource file, Resource dir) {
"""
return diffrents of one file to a other if first is child of second otherwise return null
@param file file to search
@param dir directory to search
"""
if (dir == null || !file.getResourceProvider().getScheme().equals(dir.getResourceProvider().getScheme())) return null;
boolean isFile = file.isFile();
String str = "/";
while (file != null) {
if (file.equals(dir)) {
if (isFile) return str.substring(0, str.length() - 1);
return str;
}
str = "/" + file.getName() + str;
file = file.getParentResource();
}
return null;
} | java | public static String getPathToChild(Resource file, Resource dir) {
if (dir == null || !file.getResourceProvider().getScheme().equals(dir.getResourceProvider().getScheme())) return null;
boolean isFile = file.isFile();
String str = "/";
while (file != null) {
if (file.equals(dir)) {
if (isFile) return str.substring(0, str.length() - 1);
return str;
}
str = "/" + file.getName() + str;
file = file.getParentResource();
}
return null;
} | [
"public",
"static",
"String",
"getPathToChild",
"(",
"Resource",
"file",
",",
"Resource",
"dir",
")",
"{",
"if",
"(",
"dir",
"==",
"null",
"||",
"!",
"file",
".",
"getResourceProvider",
"(",
")",
".",
"getScheme",
"(",
")",
".",
"equals",
"(",
"dir",
".",
"getResourceProvider",
"(",
")",
".",
"getScheme",
"(",
")",
")",
")",
"return",
"null",
";",
"boolean",
"isFile",
"=",
"file",
".",
"isFile",
"(",
")",
";",
"String",
"str",
"=",
"\"/\"",
";",
"while",
"(",
"file",
"!=",
"null",
")",
"{",
"if",
"(",
"file",
".",
"equals",
"(",
"dir",
")",
")",
"{",
"if",
"(",
"isFile",
")",
"return",
"str",
".",
"substring",
"(",
"0",
",",
"str",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"return",
"str",
";",
"}",
"str",
"=",
"\"/\"",
"+",
"file",
".",
"getName",
"(",
")",
"+",
"str",
";",
"file",
"=",
"file",
".",
"getParentResource",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
] | return diffrents of one file to a other if first is child of second otherwise return null
@param file file to search
@param dir directory to search | [
"return",
"diffrents",
"of",
"one",
"file",
"to",
"a",
"other",
"if",
"first",
"is",
"child",
"of",
"second",
"otherwise",
"return",
"null"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/commons/io/res/util/ResourceUtil.java#L819-L832 |
ops4j/org.ops4j.pax.logging | pax-logging-log4j2/src/main/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtil.java | ResolverUtil.loadImplementationsInJar | private void loadImplementationsInJar(final Test test, final String parent, final File jarFile) {
"""
Finds matching classes within a jar files that contains a folder structure matching the package structure. If the
File is not a JarFile or does not exist a warning will be logged, but no error will be raised.
@param test
a Test used to filter the classes that are discovered
@param parent
the parent package under which classes must be in order to be considered
@param jarFile
the jar file to be examined for classes
"""
@SuppressWarnings("resource")
JarInputStream jarStream = null;
try {
jarStream = new JarInputStream(new FileInputStream(jarFile));
loadImplementationsInJar(test, parent, jarFile.getPath(), jarStream);
} catch (final FileNotFoundException ex) {
LOGGER.error("Could not search jar file '" + jarFile + "' for classes matching criteria: " + test
+ " file not found", ex);
} catch (final IOException ioe) {
LOGGER.error("Could not search jar file '" + jarFile + "' for classes matching criteria: " + test
+ " due to an IOException", ioe);
} finally {
close(jarStream, jarFile);
}
} | java | private void loadImplementationsInJar(final Test test, final String parent, final File jarFile) {
@SuppressWarnings("resource")
JarInputStream jarStream = null;
try {
jarStream = new JarInputStream(new FileInputStream(jarFile));
loadImplementationsInJar(test, parent, jarFile.getPath(), jarStream);
} catch (final FileNotFoundException ex) {
LOGGER.error("Could not search jar file '" + jarFile + "' for classes matching criteria: " + test
+ " file not found", ex);
} catch (final IOException ioe) {
LOGGER.error("Could not search jar file '" + jarFile + "' for classes matching criteria: " + test
+ " due to an IOException", ioe);
} finally {
close(jarStream, jarFile);
}
} | [
"private",
"void",
"loadImplementationsInJar",
"(",
"final",
"Test",
"test",
",",
"final",
"String",
"parent",
",",
"final",
"File",
"jarFile",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"resource\"",
")",
"JarInputStream",
"jarStream",
"=",
"null",
";",
"try",
"{",
"jarStream",
"=",
"new",
"JarInputStream",
"(",
"new",
"FileInputStream",
"(",
"jarFile",
")",
")",
";",
"loadImplementationsInJar",
"(",
"test",
",",
"parent",
",",
"jarFile",
".",
"getPath",
"(",
")",
",",
"jarStream",
")",
";",
"}",
"catch",
"(",
"final",
"FileNotFoundException",
"ex",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"Could not search jar file '\"",
"+",
"jarFile",
"+",
"\"' for classes matching criteria: \"",
"+",
"test",
"+",
"\" file not found\"",
",",
"ex",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"ioe",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"Could not search jar file '\"",
"+",
"jarFile",
"+",
"\"' for classes matching criteria: \"",
"+",
"test",
"+",
"\" due to an IOException\"",
",",
"ioe",
")",
";",
"}",
"finally",
"{",
"close",
"(",
"jarStream",
",",
"jarFile",
")",
";",
"}",
"}"
] | Finds matching classes within a jar files that contains a folder structure matching the package structure. If the
File is not a JarFile or does not exist a warning will be logged, but no error will be raised.
@param test
a Test used to filter the classes that are discovered
@param parent
the parent package under which classes must be in order to be considered
@param jarFile
the jar file to be examined for classes | [
"Finds",
"matching",
"classes",
"within",
"a",
"jar",
"files",
"that",
"contains",
"a",
"folder",
"structure",
"matching",
"the",
"package",
"structure",
".",
"If",
"the",
"File",
"is",
"not",
"a",
"JarFile",
"or",
"does",
"not",
"exist",
"a",
"warning",
"will",
"be",
"logged",
"but",
"no",
"error",
"will",
"be",
"raised",
"."
] | train | https://github.com/ops4j/org.ops4j.pax.logging/blob/493de4e1db4fe9f981f3dd78b8e40e5bf2b2e59d/pax-logging-log4j2/src/main/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtil.java#L309-L324 |
sculptor/sculptor | sculptor-generator/sculptor-generator-core/src/main/java/org/sculptor/generator/util/HelperBase.java | HelperBase.getGetAccessor | public String getGetAccessor(TypedElement e, String prefix) {
"""
Get-accessor method name of a property, according to JavaBeans naming
conventions.
"""
String capName = toFirstUpper(e.getName());
if (prefix != null) {
capName = toFirstUpper(prefix) + capName;
}
// Note that Boolean object type is not named with is prefix (according
// to java beans spec)
String result = isBooleanPrimitiveType(e) ? "is" + capName : "get" + ("Class".equals(capName) ? "Class_" : capName);
return result;
} | java | public String getGetAccessor(TypedElement e, String prefix) {
String capName = toFirstUpper(e.getName());
if (prefix != null) {
capName = toFirstUpper(prefix) + capName;
}
// Note that Boolean object type is not named with is prefix (according
// to java beans spec)
String result = isBooleanPrimitiveType(e) ? "is" + capName : "get" + ("Class".equals(capName) ? "Class_" : capName);
return result;
} | [
"public",
"String",
"getGetAccessor",
"(",
"TypedElement",
"e",
",",
"String",
"prefix",
")",
"{",
"String",
"capName",
"=",
"toFirstUpper",
"(",
"e",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"prefix",
"!=",
"null",
")",
"{",
"capName",
"=",
"toFirstUpper",
"(",
"prefix",
")",
"+",
"capName",
";",
"}",
"// Note that Boolean object type is not named with is prefix (according",
"// to java beans spec)",
"String",
"result",
"=",
"isBooleanPrimitiveType",
"(",
"e",
")",
"?",
"\"is\"",
"+",
"capName",
":",
"\"get\"",
"+",
"(",
"\"Class\"",
".",
"equals",
"(",
"capName",
")",
"?",
"\"Class_\"",
":",
"capName",
")",
";",
"return",
"result",
";",
"}"
] | Get-accessor method name of a property, according to JavaBeans naming
conventions. | [
"Get",
"-",
"accessor",
"method",
"name",
"of",
"a",
"property",
"according",
"to",
"JavaBeans",
"naming",
"conventions",
"."
] | train | https://github.com/sculptor/sculptor/blob/38df06ceb7e40f5f52dbd53b1cd1d07ee11aade5/sculptor-generator/sculptor-generator-core/src/main/java/org/sculptor/generator/util/HelperBase.java#L479-L488 |
apache/flink | flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/functions/SqlFunctionUtils.java | SqlFunctionUtils.regexpReplace | public static String regexpReplace(String str, String regex, String replacement) {
"""
Returns a string resulting from replacing all substrings that match the regular
expression with replacement.
"""
if (regex.isEmpty()) {
return str;
}
try {
// we should use StringBuffer here because Matcher only accept it
StringBuffer sb = new StringBuffer();
Matcher m = REGEXP_PATTERN_CACHE.get(regex).matcher(str);
while (m.find()) {
m.appendReplacement(sb, replacement);
}
m.appendTail(sb);
return sb.toString();
} catch (Exception e) {
LOG.error(
String.format("Exception in regexpReplace('%s', '%s', '%s')", str, regex, replacement),
e);
// return null if exception in regex replace
return null;
}
} | java | public static String regexpReplace(String str, String regex, String replacement) {
if (regex.isEmpty()) {
return str;
}
try {
// we should use StringBuffer here because Matcher only accept it
StringBuffer sb = new StringBuffer();
Matcher m = REGEXP_PATTERN_CACHE.get(regex).matcher(str);
while (m.find()) {
m.appendReplacement(sb, replacement);
}
m.appendTail(sb);
return sb.toString();
} catch (Exception e) {
LOG.error(
String.format("Exception in regexpReplace('%s', '%s', '%s')", str, regex, replacement),
e);
// return null if exception in regex replace
return null;
}
} | [
"public",
"static",
"String",
"regexpReplace",
"(",
"String",
"str",
",",
"String",
"regex",
",",
"String",
"replacement",
")",
"{",
"if",
"(",
"regex",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"str",
";",
"}",
"try",
"{",
"// we should use StringBuffer here because Matcher only accept it",
"StringBuffer",
"sb",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"Matcher",
"m",
"=",
"REGEXP_PATTERN_CACHE",
".",
"get",
"(",
"regex",
")",
".",
"matcher",
"(",
"str",
")",
";",
"while",
"(",
"m",
".",
"find",
"(",
")",
")",
"{",
"m",
".",
"appendReplacement",
"(",
"sb",
",",
"replacement",
")",
";",
"}",
"m",
".",
"appendTail",
"(",
"sb",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"String",
".",
"format",
"(",
"\"Exception in regexpReplace('%s', '%s', '%s')\"",
",",
"str",
",",
"regex",
",",
"replacement",
")",
",",
"e",
")",
";",
"// return null if exception in regex replace",
"return",
"null",
";",
"}",
"}"
] | Returns a string resulting from replacing all substrings that match the regular
expression with replacement. | [
"Returns",
"a",
"string",
"resulting",
"from",
"replacing",
"all",
"substrings",
"that",
"match",
"the",
"regular",
"expression",
"with",
"replacement",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/functions/SqlFunctionUtils.java#L346-L366 |
Stratio/bdt | src/main/java/com/stratio/qa/specs/SeleniumSpec.java | SeleniumSpec.setupApp | @Given("^My app is running in '([^:]+?)(:.+?)?'$")
public void setupApp(String host, String port) {
"""
Set app host and port {@code host, @code port}
@param host host where app is running
@param port port where app is running
"""
assertThat(host).isNotEmpty();
if (port == null) {
port = ":80";
}
commonspec.setWebHost(host);
commonspec.setWebPort(port);
commonspec.setRestHost(host);
commonspec.setRestPort(port);
} | java | @Given("^My app is running in '([^:]+?)(:.+?)?'$")
public void setupApp(String host, String port) {
assertThat(host).isNotEmpty();
if (port == null) {
port = ":80";
}
commonspec.setWebHost(host);
commonspec.setWebPort(port);
commonspec.setRestHost(host);
commonspec.setRestPort(port);
} | [
"@",
"Given",
"(",
"\"^My app is running in '([^:]+?)(:.+?)?'$\"",
")",
"public",
"void",
"setupApp",
"(",
"String",
"host",
",",
"String",
"port",
")",
"{",
"assertThat",
"(",
"host",
")",
".",
"isNotEmpty",
"(",
")",
";",
"if",
"(",
"port",
"==",
"null",
")",
"{",
"port",
"=",
"\":80\"",
";",
"}",
"commonspec",
".",
"setWebHost",
"(",
"host",
")",
";",
"commonspec",
".",
"setWebPort",
"(",
"port",
")",
";",
"commonspec",
".",
"setRestHost",
"(",
"host",
")",
";",
"commonspec",
".",
"setRestPort",
"(",
"port",
")",
";",
"}"
] | Set app host and port {@code host, @code port}
@param host host where app is running
@param port port where app is running | [
"Set",
"app",
"host",
"and",
"port",
"{",
"@code",
"host",
"@code",
"port",
"}"
] | train | https://github.com/Stratio/bdt/blob/55324d19e7497764ad3dd7139923e13eb9841d75/src/main/java/com/stratio/qa/specs/SeleniumSpec.java#L89-L101 |
SvenEwald/xmlbeam | src/main/java/org/xmlbeam/DefaultXPathBinder.java | DefaultXPathBinder.asString | @Override
public CloseableValue<String> asString() {
"""
Evaluates the XPath as a String value. This method is just a shortcut for as(String.class);
@return String value of evaluation result.
"""
final Class<?> callerClass = ReflectionHelper.getDirectCallerClass();
return bindSingeValue(String.class, callerClass);
} | java | @Override
public CloseableValue<String> asString() {
final Class<?> callerClass = ReflectionHelper.getDirectCallerClass();
return bindSingeValue(String.class, callerClass);
} | [
"@",
"Override",
"public",
"CloseableValue",
"<",
"String",
">",
"asString",
"(",
")",
"{",
"final",
"Class",
"<",
"?",
">",
"callerClass",
"=",
"ReflectionHelper",
".",
"getDirectCallerClass",
"(",
")",
";",
"return",
"bindSingeValue",
"(",
"String",
".",
"class",
",",
"callerClass",
")",
";",
"}"
] | Evaluates the XPath as a String value. This method is just a shortcut for as(String.class);
@return String value of evaluation result. | [
"Evaluates",
"the",
"XPath",
"as",
"a",
"String",
"value",
".",
"This",
"method",
"is",
"just",
"a",
"shortcut",
"for",
"as",
"(",
"String",
".",
"class",
")",
";"
] | train | https://github.com/SvenEwald/xmlbeam/blob/acaac1b8fa28d246f17187f5e3c6696458a0b447/src/main/java/org/xmlbeam/DefaultXPathBinder.java#L98-L102 |
johncarl81/transfuse | transfuse-api/src/main/java/org/androidtransfuse/util/InjectionUtil.java | InjectionUtil.setField | public static void setField(Class<?> targetClass, Object target, String field, Object value) {
"""
Updates field with the given value.
@param targetClass class representing the object containing the field.
@param target object containing the field to update
@param field name of the field
@param value object to update the field to
"""
try {
Field classField = targetClass.getDeclaredField(field);
AccessController.doPrivileged(
new SetFieldPrivilegedAction(classField, target, value));
} catch (NoSuchFieldException e) {
throw new TransfuseInjectionException(
"NoSuchFieldException Exception during field injection: " + field + " in " + target.getClass(), e);
} catch (PrivilegedActionException e) {
throw new TransfuseInjectionException("PrivilegedActionException Exception during field injection", e);
} catch (Exception e) {
throw new TransfuseInjectionException("Exception during field injection", e);
}
} | java | public static void setField(Class<?> targetClass, Object target, String field, Object value) {
try {
Field classField = targetClass.getDeclaredField(field);
AccessController.doPrivileged(
new SetFieldPrivilegedAction(classField, target, value));
} catch (NoSuchFieldException e) {
throw new TransfuseInjectionException(
"NoSuchFieldException Exception during field injection: " + field + " in " + target.getClass(), e);
} catch (PrivilegedActionException e) {
throw new TransfuseInjectionException("PrivilegedActionException Exception during field injection", e);
} catch (Exception e) {
throw new TransfuseInjectionException("Exception during field injection", e);
}
} | [
"public",
"static",
"void",
"setField",
"(",
"Class",
"<",
"?",
">",
"targetClass",
",",
"Object",
"target",
",",
"String",
"field",
",",
"Object",
"value",
")",
"{",
"try",
"{",
"Field",
"classField",
"=",
"targetClass",
".",
"getDeclaredField",
"(",
"field",
")",
";",
"AccessController",
".",
"doPrivileged",
"(",
"new",
"SetFieldPrivilegedAction",
"(",
"classField",
",",
"target",
",",
"value",
")",
")",
";",
"}",
"catch",
"(",
"NoSuchFieldException",
"e",
")",
"{",
"throw",
"new",
"TransfuseInjectionException",
"(",
"\"NoSuchFieldException Exception during field injection: \"",
"+",
"field",
"+",
"\" in \"",
"+",
"target",
".",
"getClass",
"(",
")",
",",
"e",
")",
";",
"}",
"catch",
"(",
"PrivilegedActionException",
"e",
")",
"{",
"throw",
"new",
"TransfuseInjectionException",
"(",
"\"PrivilegedActionException Exception during field injection\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"TransfuseInjectionException",
"(",
"\"Exception during field injection\"",
",",
"e",
")",
";",
"}",
"}"
] | Updates field with the given value.
@param targetClass class representing the object containing the field.
@param target object containing the field to update
@param field name of the field
@param value object to update the field to | [
"Updates",
"field",
"with",
"the",
"given",
"value",
"."
] | train | https://github.com/johncarl81/transfuse/blob/a5f837504797a6c4f8628f7e1dde09b8e6368c8b/transfuse-api/src/main/java/org/androidtransfuse/util/InjectionUtil.java#L96-L111 |
osmdroid/osmdroid | osmdroid-mapsforge/src/main/java/org/osmdroid/mapsforge/MapsForgeTileSource.java | MapsForgeTileSource.createFromFiles | public static MapsForgeTileSource createFromFiles(File[] file, XmlRenderTheme theme, String themeName) {
"""
Creates a new MapsForgeTileSource from file[].
<p></p>
Parameters minZoom and maxZoom are obtained from the
database. If they cannot be obtained from the DB, the default values as
defined by this class are used, which is zoom = 3-20
@param file
@param theme this can be null, in which case the default them will be used
@param themeName when using a custom theme, this sets up the osmdroid caching correctly
@return
"""
//these settings are ignored and are set based on .map file info
int minZoomLevel = MIN_ZOOM;
int maxZoomLevel = MAX_ZOOM;
int tileSizePixels = TILE_SIZE_PIXELS;
return new MapsForgeTileSource(themeName, minZoomLevel, maxZoomLevel, tileSizePixels, file, theme, MultiMapDataStore.DataPolicy.RETURN_ALL, null);
} | java | public static MapsForgeTileSource createFromFiles(File[] file, XmlRenderTheme theme, String themeName) {
//these settings are ignored and are set based on .map file info
int minZoomLevel = MIN_ZOOM;
int maxZoomLevel = MAX_ZOOM;
int tileSizePixels = TILE_SIZE_PIXELS;
return new MapsForgeTileSource(themeName, minZoomLevel, maxZoomLevel, tileSizePixels, file, theme, MultiMapDataStore.DataPolicy.RETURN_ALL, null);
} | [
"public",
"static",
"MapsForgeTileSource",
"createFromFiles",
"(",
"File",
"[",
"]",
"file",
",",
"XmlRenderTheme",
"theme",
",",
"String",
"themeName",
")",
"{",
"//these settings are ignored and are set based on .map file info",
"int",
"minZoomLevel",
"=",
"MIN_ZOOM",
";",
"int",
"maxZoomLevel",
"=",
"MAX_ZOOM",
";",
"int",
"tileSizePixels",
"=",
"TILE_SIZE_PIXELS",
";",
"return",
"new",
"MapsForgeTileSource",
"(",
"themeName",
",",
"minZoomLevel",
",",
"maxZoomLevel",
",",
"tileSizePixels",
",",
"file",
",",
"theme",
",",
"MultiMapDataStore",
".",
"DataPolicy",
".",
"RETURN_ALL",
",",
"null",
")",
";",
"}"
] | Creates a new MapsForgeTileSource from file[].
<p></p>
Parameters minZoom and maxZoom are obtained from the
database. If they cannot be obtained from the DB, the default values as
defined by this class are used, which is zoom = 3-20
@param file
@param theme this can be null, in which case the default them will be used
@param themeName when using a custom theme, this sets up the osmdroid caching correctly
@return | [
"Creates",
"a",
"new",
"MapsForgeTileSource",
"from",
"file",
"[]",
".",
"<p",
">",
"<",
"/",
"p",
">",
"Parameters",
"minZoom",
"and",
"maxZoom",
"are",
"obtained",
"from",
"the",
"database",
".",
"If",
"they",
"cannot",
"be",
"obtained",
"from",
"the",
"DB",
"the",
"default",
"values",
"as",
"defined",
"by",
"this",
"class",
"are",
"used",
"which",
"is",
"zoom",
"=",
"3",
"-",
"20"
] | train | https://github.com/osmdroid/osmdroid/blob/3b178b2f078497dd88c137110e87aafe45ad2b16/osmdroid-mapsforge/src/main/java/org/osmdroid/mapsforge/MapsForgeTileSource.java#L145-L152 |
ManfredTremmel/gwt-commons-lang3 | src/main/java/org/apache/commons/lang3/time/DateUtils.java | DateUtils.parseDateStrictly | @GwtIncompatible("incompatible method")
public static Date parseDateStrictly(final String str, final Locale locale, final String... parsePatterns) throws ParseException {
"""
<p>Parses a string representing a date by trying a variety of different parsers,
using the default date format symbols for the given locale..</p>
<p>The parse will try each parse pattern in turn.
A parse is only deemed successful if it parses the whole of the input string.
If no parse patterns match, a ParseException is thrown.</p>
The parser parses strictly - it does not allow for dates such as "February 942, 1996".
@param str the date to parse, not null
@param locale the locale whose date format symbols should be used. If <code>null</code>,
the system locale is used (as per {@link #parseDateStrictly(String, String...)}).
@param parsePatterns the date format patterns to use, see SimpleDateFormat, not null
@return the parsed date
@throws IllegalArgumentException if the date string or pattern array is null
@throws ParseException if none of the date patterns were suitable
@since 3.2
"""
return parseDateWithLeniency(str, locale, parsePatterns, false);
} | java | @GwtIncompatible("incompatible method")
public static Date parseDateStrictly(final String str, final Locale locale, final String... parsePatterns) throws ParseException {
return parseDateWithLeniency(str, locale, parsePatterns, false);
} | [
"@",
"GwtIncompatible",
"(",
"\"incompatible method\"",
")",
"public",
"static",
"Date",
"parseDateStrictly",
"(",
"final",
"String",
"str",
",",
"final",
"Locale",
"locale",
",",
"final",
"String",
"...",
"parsePatterns",
")",
"throws",
"ParseException",
"{",
"return",
"parseDateWithLeniency",
"(",
"str",
",",
"locale",
",",
"parsePatterns",
",",
"false",
")",
";",
"}"
] | <p>Parses a string representing a date by trying a variety of different parsers,
using the default date format symbols for the given locale..</p>
<p>The parse will try each parse pattern in turn.
A parse is only deemed successful if it parses the whole of the input string.
If no parse patterns match, a ParseException is thrown.</p>
The parser parses strictly - it does not allow for dates such as "February 942, 1996".
@param str the date to parse, not null
@param locale the locale whose date format symbols should be used. If <code>null</code>,
the system locale is used (as per {@link #parseDateStrictly(String, String...)}).
@param parsePatterns the date format patterns to use, see SimpleDateFormat, not null
@return the parsed date
@throws IllegalArgumentException if the date string or pattern array is null
@throws ParseException if none of the date patterns were suitable
@since 3.2 | [
"<p",
">",
"Parses",
"a",
"string",
"representing",
"a",
"date",
"by",
"trying",
"a",
"variety",
"of",
"different",
"parsers",
"using",
"the",
"default",
"date",
"format",
"symbols",
"for",
"the",
"given",
"locale",
"..",
"<",
"/",
"p",
">"
] | train | https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/time/DateUtils.java#L348-L351 |
sdl/odata | odata_api/src/main/java/com/sdl/odata/util/edm/EntityDataModelUtil.java | EntityDataModelUtil.getAndCheckFunctionImport | public static FunctionImport getAndCheckFunctionImport(EntityDataModel entityDataModel, String functionImportName) {
"""
Gets the function import by the specified name, throw an exception if no function import with the specified name
exists.
@param entityDataModel The entity data model.
@param functionImportName The name of the function import.
@return The function import
"""
FunctionImport functionImport = entityDataModel.getEntityContainer().getFunctionImport(functionImportName);
if (functionImport == null) {
throw new ODataSystemException("Function import not found in the entity data model: " + functionImportName);
}
return functionImport;
} | java | public static FunctionImport getAndCheckFunctionImport(EntityDataModel entityDataModel, String functionImportName) {
FunctionImport functionImport = entityDataModel.getEntityContainer().getFunctionImport(functionImportName);
if (functionImport == null) {
throw new ODataSystemException("Function import not found in the entity data model: " + functionImportName);
}
return functionImport;
} | [
"public",
"static",
"FunctionImport",
"getAndCheckFunctionImport",
"(",
"EntityDataModel",
"entityDataModel",
",",
"String",
"functionImportName",
")",
"{",
"FunctionImport",
"functionImport",
"=",
"entityDataModel",
".",
"getEntityContainer",
"(",
")",
".",
"getFunctionImport",
"(",
"functionImportName",
")",
";",
"if",
"(",
"functionImport",
"==",
"null",
")",
"{",
"throw",
"new",
"ODataSystemException",
"(",
"\"Function import not found in the entity data model: \"",
"+",
"functionImportName",
")",
";",
"}",
"return",
"functionImport",
";",
"}"
] | Gets the function import by the specified name, throw an exception if no function import with the specified name
exists.
@param entityDataModel The entity data model.
@param functionImportName The name of the function import.
@return The function import | [
"Gets",
"the",
"function",
"import",
"by",
"the",
"specified",
"name",
"throw",
"an",
"exception",
"if",
"no",
"function",
"import",
"with",
"the",
"specified",
"name",
"exists",
"."
] | train | https://github.com/sdl/odata/blob/eb747d73e9af0f4e59a25b82ed656e526a7e2189/odata_api/src/main/java/com/sdl/odata/util/edm/EntityDataModelUtil.java#L598-L605 |
jhunters/jprotobuf | src/main/java/com/baidu/bjf/remoting/protobuf/ProtobufIDLProxy.java | ProtobufIDLProxy.createSingle | public static IDLProxyObject createSingle(Reader reader, boolean debug, File path) throws IOException {
"""
Creates the single.
@param reader the reader
@param debug the debug
@param path the path
@return the IDL proxy object
@throws IOException Signals that an I/O exception has occurred.
"""
return createSingle(reader, debug, path, true);
} | java | public static IDLProxyObject createSingle(Reader reader, boolean debug, File path) throws IOException {
return createSingle(reader, debug, path, true);
} | [
"public",
"static",
"IDLProxyObject",
"createSingle",
"(",
"Reader",
"reader",
",",
"boolean",
"debug",
",",
"File",
"path",
")",
"throws",
"IOException",
"{",
"return",
"createSingle",
"(",
"reader",
",",
"debug",
",",
"path",
",",
"true",
")",
";",
"}"
] | Creates the single.
@param reader the reader
@param debug the debug
@param path the path
@return the IDL proxy object
@throws IOException Signals that an I/O exception has occurred. | [
"Creates",
"the",
"single",
"."
] | train | https://github.com/jhunters/jprotobuf/blob/55832c9b4792afb128e5b35139d8a3891561d8a3/src/main/java/com/baidu/bjf/remoting/protobuf/ProtobufIDLProxy.java#L1057-L1059 |
GerdHolz/TOVAL | src/de/invation/code/toval/graphic/diagrams/panels/ScatterChartPanel.java | ScatterChartPanel.setTickSpacing | public void setTickSpacing(ValueDimension dim, double minorTickSpacing, int multiplicator, boolean repaint) {
"""
Sets the tick spacing for the coordinate axis of the given dimension.<br>
<value>minorTickSpacing</value> sets the minor tick spacing,
major tick spacing is a multiple of minor tick spacing and determined with the help of <value>multiplicator</value>
@param dim Reference dimension for calculation
@param minorTickSpacing Minor tick spacing
@param multiplicator Multiplicator for detrermining the major tick spacing.
"""
double tickSpacing = minorTickSpacing;
if(onlyIntegerTicks.get(dim)) {
tickSpacing = (int) tickSpacing;
if (tickSpacing == 0) tickSpacing = 1;
}
getTickInfo(dim).setTickSpacing(tickSpacing, multiplicator);
if(repaint){
revalidate();
repaint();
}
} | java | public void setTickSpacing(ValueDimension dim, double minorTickSpacing, int multiplicator, boolean repaint) {
double tickSpacing = minorTickSpacing;
if(onlyIntegerTicks.get(dim)) {
tickSpacing = (int) tickSpacing;
if (tickSpacing == 0) tickSpacing = 1;
}
getTickInfo(dim).setTickSpacing(tickSpacing, multiplicator);
if(repaint){
revalidate();
repaint();
}
} | [
"public",
"void",
"setTickSpacing",
"(",
"ValueDimension",
"dim",
",",
"double",
"minorTickSpacing",
",",
"int",
"multiplicator",
",",
"boolean",
"repaint",
")",
"{",
"double",
"tickSpacing",
"=",
"minorTickSpacing",
";",
"if",
"(",
"onlyIntegerTicks",
".",
"get",
"(",
"dim",
")",
")",
"{",
"tickSpacing",
"=",
"(",
"int",
")",
"tickSpacing",
";",
"if",
"(",
"tickSpacing",
"==",
"0",
")",
"tickSpacing",
"=",
"1",
";",
"}",
"getTickInfo",
"(",
"dim",
")",
".",
"setTickSpacing",
"(",
"tickSpacing",
",",
"multiplicator",
")",
";",
"if",
"(",
"repaint",
")",
"{",
"revalidate",
"(",
")",
";",
"repaint",
"(",
")",
";",
"}",
"}"
] | Sets the tick spacing for the coordinate axis of the given dimension.<br>
<value>minorTickSpacing</value> sets the minor tick spacing,
major tick spacing is a multiple of minor tick spacing and determined with the help of <value>multiplicator</value>
@param dim Reference dimension for calculation
@param minorTickSpacing Minor tick spacing
@param multiplicator Multiplicator for detrermining the major tick spacing. | [
"Sets",
"the",
"tick",
"spacing",
"for",
"the",
"coordinate",
"axis",
"of",
"the",
"given",
"dimension",
".",
"<br",
">",
"<value",
">",
"minorTickSpacing<",
"/",
"value",
">",
"sets",
"the",
"minor",
"tick",
"spacing",
"major",
"tick",
"spacing",
"is",
"a",
"multiple",
"of",
"minor",
"tick",
"spacing",
"and",
"determined",
"with",
"the",
"help",
"of",
"<value",
">",
"multiplicator<",
"/",
"value",
">"
] | train | https://github.com/GerdHolz/TOVAL/blob/036922cdfd710fa53b18e5dbe1e07f226f731fde/src/de/invation/code/toval/graphic/diagrams/panels/ScatterChartPanel.java#L223-L234 |
drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/StrUtils.java | StrUtils.countMatches | public static int countMatches(final CharSequence str, final char ch) {
"""
<p>
Counts how many times the char appears in the given string.
</p>
<p>
A {@code null} or empty ("") String input returns {@code 0}.
</p>
<pre>
StringUtils.countMatches(null, *) = 0
StringUtils.countMatches("", *) = 0
StringUtils.countMatches("abba", 0) = 0
StringUtils.countMatches("abba", 'a') = 2
StringUtils.countMatches("abba", 'b') = 2
StringUtils.countMatches("abba", 'x') = 0
</pre>
@param str
the CharSequence to check, may be null
@param ch
the char to count
@return the number of occurrences, 0 if the CharSequence is {@code null}
@since 3.4
"""
if (isEmpty(str)) {
return 0;
}
int count = 0;
// We could also call str.toCharArray() for faster look ups but that
// would generate more garbage.
for (int i = 0; i < str.length(); i++) {
if (ch == str.charAt(i)) {
count++;
}
}
return count;
} | java | public static int countMatches(final CharSequence str, final char ch) {
if (isEmpty(str)) {
return 0;
}
int count = 0;
// We could also call str.toCharArray() for faster look ups but that
// would generate more garbage.
for (int i = 0; i < str.length(); i++) {
if (ch == str.charAt(i)) {
count++;
}
}
return count;
} | [
"public",
"static",
"int",
"countMatches",
"(",
"final",
"CharSequence",
"str",
",",
"final",
"char",
"ch",
")",
"{",
"if",
"(",
"isEmpty",
"(",
"str",
")",
")",
"{",
"return",
"0",
";",
"}",
"int",
"count",
"=",
"0",
";",
"// We could also call str.toCharArray() for faster look ups but that",
"// would generate more garbage.",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"str",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"ch",
"==",
"str",
".",
"charAt",
"(",
"i",
")",
")",
"{",
"count",
"++",
";",
"}",
"}",
"return",
"count",
";",
"}"
] | <p>
Counts how many times the char appears in the given string.
</p>
<p>
A {@code null} or empty ("") String input returns {@code 0}.
</p>
<pre>
StringUtils.countMatches(null, *) = 0
StringUtils.countMatches("", *) = 0
StringUtils.countMatches("abba", 0) = 0
StringUtils.countMatches("abba", 'a') = 2
StringUtils.countMatches("abba", 'b') = 2
StringUtils.countMatches("abba", 'x') = 0
</pre>
@param str
the CharSequence to check, may be null
@param ch
the char to count
@return the number of occurrences, 0 if the CharSequence is {@code null}
@since 3.4 | [
"<p",
">",
"Counts",
"how",
"many",
"times",
"the",
"char",
"appears",
"in",
"the",
"given",
"string",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/StrUtils.java#L821-L834 |
Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/animation/GVRAvatar.java | GVRAvatar.animate | public GVRAnimator animate(int animIndex, float timeInSec) {
"""
Evaluates the animation with the given index at the specified time.
@param animIndex 0-based index of {@link GVRAnimator} to start
@param timeInSec time to evaluate the animation at
@see GVRAvatar#stop()
@see #start(String)
"""
if ((animIndex < 0) || (animIndex >= mAnimations.size()))
{
throw new IndexOutOfBoundsException("Animation index out of bounds");
}
GVRAnimator anim = mAnimations.get(animIndex);
anim.animate(timeInSec);
return anim;
} | java | public GVRAnimator animate(int animIndex, float timeInSec)
{
if ((animIndex < 0) || (animIndex >= mAnimations.size()))
{
throw new IndexOutOfBoundsException("Animation index out of bounds");
}
GVRAnimator anim = mAnimations.get(animIndex);
anim.animate(timeInSec);
return anim;
} | [
"public",
"GVRAnimator",
"animate",
"(",
"int",
"animIndex",
",",
"float",
"timeInSec",
")",
"{",
"if",
"(",
"(",
"animIndex",
"<",
"0",
")",
"||",
"(",
"animIndex",
">=",
"mAnimations",
".",
"size",
"(",
")",
")",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"Animation index out of bounds\"",
")",
";",
"}",
"GVRAnimator",
"anim",
"=",
"mAnimations",
".",
"get",
"(",
"animIndex",
")",
";",
"anim",
".",
"animate",
"(",
"timeInSec",
")",
";",
"return",
"anim",
";",
"}"
] | Evaluates the animation with the given index at the specified time.
@param animIndex 0-based index of {@link GVRAnimator} to start
@param timeInSec time to evaluate the animation at
@see GVRAvatar#stop()
@see #start(String) | [
"Evaluates",
"the",
"animation",
"with",
"the",
"given",
"index",
"at",
"the",
"specified",
"time",
"."
] | train | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/animation/GVRAvatar.java#L449-L458 |
Azure/azure-sdk-for-java | locks/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/locks/v2016_09_01/implementation/ManagementLocksInner.java | ManagementLocksInner.createOrUpdateAtSubscriptionLevel | public ManagementLockObjectInner createOrUpdateAtSubscriptionLevel(String lockName, ManagementLockObjectInner parameters) {
"""
Creates or updates a management lock at the subscription level.
When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions.
@param lockName The name of lock. The lock name can be a maximum of 260 characters. It cannot contain <, > %, &, :, \, ?, /, or any control characters.
@param parameters The management lock parameters.
@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 ManagementLockObjectInner object if successful.
"""
return createOrUpdateAtSubscriptionLevelWithServiceResponseAsync(lockName, parameters).toBlocking().single().body();
} | java | public ManagementLockObjectInner createOrUpdateAtSubscriptionLevel(String lockName, ManagementLockObjectInner parameters) {
return createOrUpdateAtSubscriptionLevelWithServiceResponseAsync(lockName, parameters).toBlocking().single().body();
} | [
"public",
"ManagementLockObjectInner",
"createOrUpdateAtSubscriptionLevel",
"(",
"String",
"lockName",
",",
"ManagementLockObjectInner",
"parameters",
")",
"{",
"return",
"createOrUpdateAtSubscriptionLevelWithServiceResponseAsync",
"(",
"lockName",
",",
"parameters",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Creates or updates a management lock at the subscription level.
When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions.
@param lockName The name of lock. The lock name can be a maximum of 260 characters. It cannot contain <, > %, &, :, \, ?, /, or any control characters.
@param parameters The management lock parameters.
@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 ManagementLockObjectInner object if successful. | [
"Creates",
"or",
"updates",
"a",
"management",
"lock",
"at",
"the",
"subscription",
"level",
".",
"When",
"you",
"apply",
"a",
"lock",
"at",
"a",
"parent",
"scope",
"all",
"child",
"resources",
"inherit",
"the",
"same",
"lock",
".",
"To",
"create",
"management",
"locks",
"you",
"must",
"have",
"access",
"to",
"Microsoft",
".",
"Authorization",
"/",
"*",
"or",
"Microsoft",
".",
"Authorization",
"/",
"locks",
"/",
"*",
"actions",
".",
"Of",
"the",
"built",
"-",
"in",
"roles",
"only",
"Owner",
"and",
"User",
"Access",
"Administrator",
"are",
"granted",
"those",
"actions",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/locks/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/locks/v2016_09_01/implementation/ManagementLocksInner.java#L1043-L1045 |
UrielCh/ovh-java-sdk | ovh-java-sdk-ip/src/main/java/net/minidev/ovh/api/ApiOvhIp.java | ApiOvhIp.ip_mitigation_ipOnMitigation_GET | public OvhMitigationIp ip_mitigation_ipOnMitigation_GET(String ip, String ipOnMitigation) throws IOException {
"""
Get this object properties
REST: GET /ip/{ip}/mitigation/{ipOnMitigation}
@param ip [required]
@param ipOnMitigation [required]
"""
String qPath = "/ip/{ip}/mitigation/{ipOnMitigation}";
StringBuilder sb = path(qPath, ip, ipOnMitigation);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhMitigationIp.class);
} | java | public OvhMitigationIp ip_mitigation_ipOnMitigation_GET(String ip, String ipOnMitigation) throws IOException {
String qPath = "/ip/{ip}/mitigation/{ipOnMitigation}";
StringBuilder sb = path(qPath, ip, ipOnMitigation);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhMitigationIp.class);
} | [
"public",
"OvhMitigationIp",
"ip_mitigation_ipOnMitigation_GET",
"(",
"String",
"ip",
",",
"String",
"ipOnMitigation",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/ip/{ip}/mitigation/{ipOnMitigation}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"ip",
",",
"ipOnMitigation",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhMitigationIp",
".",
"class",
")",
";",
"}"
] | Get this object properties
REST: GET /ip/{ip}/mitigation/{ipOnMitigation}
@param ip [required]
@param ipOnMitigation [required] | [
"Get",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-ip/src/main/java/net/minidev/ovh/api/ApiOvhIp.java#L696-L701 |
google/jimfs | jimfs/src/main/java/com/google/common/jimfs/AttributeService.java | AttributeService.copyAttributes | public void copyAttributes(File file, File copy, AttributeCopyOption copyOption) {
"""
Copies the attributes of the given file to the given copy file.
"""
switch (copyOption) {
case ALL:
file.copyAttributes(copy);
break;
case BASIC:
file.copyBasicAttributes(copy);
break;
default:
// don't copy
}
} | java | public void copyAttributes(File file, File copy, AttributeCopyOption copyOption) {
switch (copyOption) {
case ALL:
file.copyAttributes(copy);
break;
case BASIC:
file.copyBasicAttributes(copy);
break;
default:
// don't copy
}
} | [
"public",
"void",
"copyAttributes",
"(",
"File",
"file",
",",
"File",
"copy",
",",
"AttributeCopyOption",
"copyOption",
")",
"{",
"switch",
"(",
"copyOption",
")",
"{",
"case",
"ALL",
":",
"file",
".",
"copyAttributes",
"(",
"copy",
")",
";",
"break",
";",
"case",
"BASIC",
":",
"file",
".",
"copyBasicAttributes",
"(",
"copy",
")",
";",
"break",
";",
"default",
":",
"// don't copy",
"}",
"}"
] | Copies the attributes of the given file to the given copy file. | [
"Copies",
"the",
"attributes",
"of",
"the",
"given",
"file",
"to",
"the",
"given",
"copy",
"file",
"."
] | train | https://github.com/google/jimfs/blob/3eadff747a3afa7b498030f420d2d04ce700534a/jimfs/src/main/java/com/google/common/jimfs/AttributeService.java#L172-L183 |
Impetus/Kundera | src/kundera-cassandra/cassandra-core/src/main/java/com/impetus/client/cassandra/schemamanager/CassandraSchemaManager.java | CassandraSchemaManager.createIndexUsingThrift | private void createIndexUsingThrift(TableInfo tableInfo, CfDef cfDef) throws Exception {
"""
Creates the index using thrift.
@param tableInfo
the table info
@param cfDef
the cf def
@throws Exception
the exception
"""
for (IndexInfo indexInfo : tableInfo.getColumnsToBeIndexed())
{
for (ColumnDef columnDef : cfDef.getColumn_metadata())
{
if (new String(columnDef.getName(), Constants.ENCODING).equals(indexInfo.getColumnName()))
{
columnDef.setIndex_type(CassandraIndexHelper.getIndexType(indexInfo.getIndexType()));
// columnDef.setIndex_name(indexInfo.getIndexName());
}
}
}
cassandra_client.system_update_column_family(cfDef);
} | java | private void createIndexUsingThrift(TableInfo tableInfo, CfDef cfDef) throws Exception
{
for (IndexInfo indexInfo : tableInfo.getColumnsToBeIndexed())
{
for (ColumnDef columnDef : cfDef.getColumn_metadata())
{
if (new String(columnDef.getName(), Constants.ENCODING).equals(indexInfo.getColumnName()))
{
columnDef.setIndex_type(CassandraIndexHelper.getIndexType(indexInfo.getIndexType()));
// columnDef.setIndex_name(indexInfo.getIndexName());
}
}
}
cassandra_client.system_update_column_family(cfDef);
} | [
"private",
"void",
"createIndexUsingThrift",
"(",
"TableInfo",
"tableInfo",
",",
"CfDef",
"cfDef",
")",
"throws",
"Exception",
"{",
"for",
"(",
"IndexInfo",
"indexInfo",
":",
"tableInfo",
".",
"getColumnsToBeIndexed",
"(",
")",
")",
"{",
"for",
"(",
"ColumnDef",
"columnDef",
":",
"cfDef",
".",
"getColumn_metadata",
"(",
")",
")",
"{",
"if",
"(",
"new",
"String",
"(",
"columnDef",
".",
"getName",
"(",
")",
",",
"Constants",
".",
"ENCODING",
")",
".",
"equals",
"(",
"indexInfo",
".",
"getColumnName",
"(",
")",
")",
")",
"{",
"columnDef",
".",
"setIndex_type",
"(",
"CassandraIndexHelper",
".",
"getIndexType",
"(",
"indexInfo",
".",
"getIndexType",
"(",
")",
")",
")",
";",
"// columnDef.setIndex_name(indexInfo.getIndexName());",
"}",
"}",
"}",
"cassandra_client",
".",
"system_update_column_family",
"(",
"cfDef",
")",
";",
"}"
] | Creates the index using thrift.
@param tableInfo
the table info
@param cfDef
the cf def
@throws Exception
the exception | [
"Creates",
"the",
"index",
"using",
"thrift",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-cassandra/cassandra-core/src/main/java/com/impetus/client/cassandra/schemamanager/CassandraSchemaManager.java#L1368-L1382 |
pwheel/spring-security-oauth2-client | src/main/java/com/racquettrack/security/oauth/OAuth2AuthenticationEntryPoint.java | OAuth2AuthenticationEntryPoint.constructAdditionalAuthParameters | protected StringBuilder constructAdditionalAuthParameters(Map<String, String> additionalParameters) {
"""
Provided so that subclasses can override the default behaviour. Note that the recommended method to add
additional parameters is via {@link OAuth2ServiceProperties#setAdditionalAuthParams(java.util.Map)}.
Subclasses should never return null, as this was result in "null" being appended to the redirect uri
(see {@link StringBuilder#append(StringBuffer)}. Even if there are no additional parameters, return a
StringBuilder.
@param additionalParameters A Map of additional parameters to set.
@return A {@link StringBuilder} containing the additional parameters, if there are any. Do not return null.
"""
StringBuilder result = new StringBuilder();
if (additionalParameters != null &&
!additionalParameters.isEmpty()) {
for (Map.Entry<String, String> entry : additionalParameters.entrySet()) {
result.append("&")
.append(entry.getKey())
.append("=")
.append(entry.getValue());
}
}
return result;
} | java | protected StringBuilder constructAdditionalAuthParameters(Map<String, String> additionalParameters) {
StringBuilder result = new StringBuilder();
if (additionalParameters != null &&
!additionalParameters.isEmpty()) {
for (Map.Entry<String, String> entry : additionalParameters.entrySet()) {
result.append("&")
.append(entry.getKey())
.append("=")
.append(entry.getValue());
}
}
return result;
} | [
"protected",
"StringBuilder",
"constructAdditionalAuthParameters",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"additionalParameters",
")",
"{",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"additionalParameters",
"!=",
"null",
"&&",
"!",
"additionalParameters",
".",
"isEmpty",
"(",
")",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"additionalParameters",
".",
"entrySet",
"(",
")",
")",
"{",
"result",
".",
"append",
"(",
"\"&\"",
")",
".",
"append",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
".",
"append",
"(",
"\"=\"",
")",
".",
"append",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | Provided so that subclasses can override the default behaviour. Note that the recommended method to add
additional parameters is via {@link OAuth2ServiceProperties#setAdditionalAuthParams(java.util.Map)}.
Subclasses should never return null, as this was result in "null" being appended to the redirect uri
(see {@link StringBuilder#append(StringBuffer)}. Even if there are no additional parameters, return a
StringBuilder.
@param additionalParameters A Map of additional parameters to set.
@return A {@link StringBuilder} containing the additional parameters, if there are any. Do not return null. | [
"Provided",
"so",
"that",
"subclasses",
"can",
"override",
"the",
"default",
"behaviour",
".",
"Note",
"that",
"the",
"recommended",
"method",
"to",
"add",
"additional",
"parameters",
"is",
"via",
"{",
"@link",
"OAuth2ServiceProperties#setAdditionalAuthParams",
"(",
"java",
".",
"util",
".",
"Map",
")",
"}",
"."
] | train | https://github.com/pwheel/spring-security-oauth2-client/blob/c0258823493e268495c9752c5d752f74c6809c6b/src/main/java/com/racquettrack/security/oauth/OAuth2AuthenticationEntryPoint.java#L83-L97 |
zaproxy/zaproxy | src/org/parosproxy/paros/network/HttpSender.java | HttpSender.sendAndReceive | public void sendAndReceive(HttpMessage message, HttpRequestConfig requestConfig) throws IOException {
"""
Sends the request of given HTTP {@code message} with the given configurations.
@param message the message that will be sent
@param requestConfig the request configurations.
@throws IllegalArgumentException if any of the parameters is {@code null}
@throws IOException if an error occurred while sending the message or following the redirections
@since 2.6.0
@see #sendAndReceive(HttpMessage, boolean)
"""
if (message == null) {
throw new IllegalArgumentException("Parameter message must not be null.");
}
if (requestConfig == null) {
throw new IllegalArgumentException("Parameter requestConfig must not be null.");
}
sendAndReceiveImpl(message, requestConfig);
if (requestConfig.isFollowRedirects()) {
followRedirections(message, requestConfig);
}
} | java | public void sendAndReceive(HttpMessage message, HttpRequestConfig requestConfig) throws IOException {
if (message == null) {
throw new IllegalArgumentException("Parameter message must not be null.");
}
if (requestConfig == null) {
throw new IllegalArgumentException("Parameter requestConfig must not be null.");
}
sendAndReceiveImpl(message, requestConfig);
if (requestConfig.isFollowRedirects()) {
followRedirections(message, requestConfig);
}
} | [
"public",
"void",
"sendAndReceive",
"(",
"HttpMessage",
"message",
",",
"HttpRequestConfig",
"requestConfig",
")",
"throws",
"IOException",
"{",
"if",
"(",
"message",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter message must not be null.\"",
")",
";",
"}",
"if",
"(",
"requestConfig",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter requestConfig must not be null.\"",
")",
";",
"}",
"sendAndReceiveImpl",
"(",
"message",
",",
"requestConfig",
")",
";",
"if",
"(",
"requestConfig",
".",
"isFollowRedirects",
"(",
")",
")",
"{",
"followRedirections",
"(",
"message",
",",
"requestConfig",
")",
";",
"}",
"}"
] | Sends the request of given HTTP {@code message} with the given configurations.
@param message the message that will be sent
@param requestConfig the request configurations.
@throws IllegalArgumentException if any of the parameters is {@code null}
@throws IOException if an error occurred while sending the message or following the redirections
@since 2.6.0
@see #sendAndReceive(HttpMessage, boolean) | [
"Sends",
"the",
"request",
"of",
"given",
"HTTP",
"{",
"@code",
"message",
"}",
"with",
"the",
"given",
"configurations",
"."
] | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/parosproxy/paros/network/HttpSender.java#L877-L890 |
networknt/light-4j | client/src/main/java/com/networknt/client/Http2Client.java | Http2Client.populateHeader | public Result populateHeader(ClientRequest request, String authToken, String correlationId, String traceabilityId) {
"""
Support API to API calls with scope token. The token is the original token from consumer and
the client credentials token of caller API is added from cache. authToken, correlationId and
traceabilityId are passed in as strings.
This method is used in API to API call
@param request the http request
@param authToken the authorization token
@param correlationId the correlation id
@param traceabilityId the traceability id
@return Result when fail to get jwt, it will return a Status.
"""
if(traceabilityId != null) {
addAuthTokenTrace(request, authToken, traceabilityId);
} else {
addAuthToken(request, authToken);
}
Result<Jwt> result = tokenManager.getJwt(request);
if(result.isFailure()) { return Failure.of(result.getError()); }
request.getRequestHeaders().put(HttpStringConstants.CORRELATION_ID, correlationId);
request.getRequestHeaders().put(HttpStringConstants.SCOPE_TOKEN, "Bearer " + result.getResult().getJwt());
return result;
} | java | public Result populateHeader(ClientRequest request, String authToken, String correlationId, String traceabilityId) {
if(traceabilityId != null) {
addAuthTokenTrace(request, authToken, traceabilityId);
} else {
addAuthToken(request, authToken);
}
Result<Jwt> result = tokenManager.getJwt(request);
if(result.isFailure()) { return Failure.of(result.getError()); }
request.getRequestHeaders().put(HttpStringConstants.CORRELATION_ID, correlationId);
request.getRequestHeaders().put(HttpStringConstants.SCOPE_TOKEN, "Bearer " + result.getResult().getJwt());
return result;
} | [
"public",
"Result",
"populateHeader",
"(",
"ClientRequest",
"request",
",",
"String",
"authToken",
",",
"String",
"correlationId",
",",
"String",
"traceabilityId",
")",
"{",
"if",
"(",
"traceabilityId",
"!=",
"null",
")",
"{",
"addAuthTokenTrace",
"(",
"request",
",",
"authToken",
",",
"traceabilityId",
")",
";",
"}",
"else",
"{",
"addAuthToken",
"(",
"request",
",",
"authToken",
")",
";",
"}",
"Result",
"<",
"Jwt",
">",
"result",
"=",
"tokenManager",
".",
"getJwt",
"(",
"request",
")",
";",
"if",
"(",
"result",
".",
"isFailure",
"(",
")",
")",
"{",
"return",
"Failure",
".",
"of",
"(",
"result",
".",
"getError",
"(",
")",
")",
";",
"}",
"request",
".",
"getRequestHeaders",
"(",
")",
".",
"put",
"(",
"HttpStringConstants",
".",
"CORRELATION_ID",
",",
"correlationId",
")",
";",
"request",
".",
"getRequestHeaders",
"(",
")",
".",
"put",
"(",
"HttpStringConstants",
".",
"SCOPE_TOKEN",
",",
"\"Bearer \"",
"+",
"result",
".",
"getResult",
"(",
")",
".",
"getJwt",
"(",
")",
")",
";",
"return",
"result",
";",
"}"
] | Support API to API calls with scope token. The token is the original token from consumer and
the client credentials token of caller API is added from cache. authToken, correlationId and
traceabilityId are passed in as strings.
This method is used in API to API call
@param request the http request
@param authToken the authorization token
@param correlationId the correlation id
@param traceabilityId the traceability id
@return Result when fail to get jwt, it will return a Status. | [
"Support",
"API",
"to",
"API",
"calls",
"with",
"scope",
"token",
".",
"The",
"token",
"is",
"the",
"original",
"token",
"from",
"consumer",
"and",
"the",
"client",
"credentials",
"token",
"of",
"caller",
"API",
"is",
"added",
"from",
"cache",
".",
"authToken",
"correlationId",
"and",
"traceabilityId",
"are",
"passed",
"in",
"as",
"strings",
"."
] | train | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/client/src/main/java/com/networknt/client/Http2Client.java#L370-L381 |
Nexmo/nexmo-java | src/main/java/com/nexmo/client/auth/RequestSigning.java | RequestSigning.verifyRequestSignature | public static boolean verifyRequestSignature(HttpServletRequest request, String secretKey) {
"""
Verifies the signature in an HttpServletRequest.
@param request The HttpServletRequest to be verified
@param secretKey The pre-shared secret key used by the sender of the request to create the signature
@return true if the signature is correct for this request and secret key.
"""
return verifyRequestSignature(request, secretKey, System.currentTimeMillis());
} | java | public static boolean verifyRequestSignature(HttpServletRequest request, String secretKey) {
return verifyRequestSignature(request, secretKey, System.currentTimeMillis());
} | [
"public",
"static",
"boolean",
"verifyRequestSignature",
"(",
"HttpServletRequest",
"request",
",",
"String",
"secretKey",
")",
"{",
"return",
"verifyRequestSignature",
"(",
"request",
",",
"secretKey",
",",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
";",
"}"
] | Verifies the signature in an HttpServletRequest.
@param request The HttpServletRequest to be verified
@param secretKey The pre-shared secret key used by the sender of the request to create the signature
@return true if the signature is correct for this request and secret key. | [
"Verifies",
"the",
"signature",
"in",
"an",
"HttpServletRequest",
"."
] | train | https://github.com/Nexmo/nexmo-java/blob/7427eff6d6baa5a5bd9197fa096bcf2564191cf5/src/main/java/com/nexmo/client/auth/RequestSigning.java#L127-L129 |
bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/protocols/channels/StoredPaymentChannelClientStates.java | StoredPaymentChannelClientStates.getAnnouncePeerGroup | private TransactionBroadcaster getAnnouncePeerGroup() {
"""
If the peer group has not been set for MAX_SECONDS_TO_WAIT_FOR_BROADCASTER_TO_BE_SET seconds, then
the programmer probably forgot to set it and we should throw exception.
"""
try {
return announcePeerGroupFuture.get(MAX_SECONDS_TO_WAIT_FOR_BROADCASTER_TO_BE_SET, TimeUnit.SECONDS);
} catch (InterruptedException e) {
throw new RuntimeException(e);
} catch (ExecutionException e) {
throw new RuntimeException(e);
} catch (TimeoutException e) {
String err = "Transaction broadcaster not set";
log.error(err);
throw new RuntimeException(err, e);
}
} | java | private TransactionBroadcaster getAnnouncePeerGroup() {
try {
return announcePeerGroupFuture.get(MAX_SECONDS_TO_WAIT_FOR_BROADCASTER_TO_BE_SET, TimeUnit.SECONDS);
} catch (InterruptedException e) {
throw new RuntimeException(e);
} catch (ExecutionException e) {
throw new RuntimeException(e);
} catch (TimeoutException e) {
String err = "Transaction broadcaster not set";
log.error(err);
throw new RuntimeException(err, e);
}
} | [
"private",
"TransactionBroadcaster",
"getAnnouncePeerGroup",
"(",
")",
"{",
"try",
"{",
"return",
"announcePeerGroupFuture",
".",
"get",
"(",
"MAX_SECONDS_TO_WAIT_FOR_BROADCASTER_TO_BE_SET",
",",
"TimeUnit",
".",
"SECONDS",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"ExecutionException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"TimeoutException",
"e",
")",
"{",
"String",
"err",
"=",
"\"Transaction broadcaster not set\"",
";",
"log",
".",
"error",
"(",
"err",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"err",
",",
"e",
")",
";",
"}",
"}"
] | If the peer group has not been set for MAX_SECONDS_TO_WAIT_FOR_BROADCASTER_TO_BE_SET seconds, then
the programmer probably forgot to set it and we should throw exception. | [
"If",
"the",
"peer",
"group",
"has",
"not",
"been",
"set",
"for",
"MAX_SECONDS_TO_WAIT_FOR_BROADCASTER_TO_BE_SET",
"seconds",
"then",
"the",
"programmer",
"probably",
"forgot",
"to",
"set",
"it",
"and",
"we",
"should",
"throw",
"exception",
"."
] | train | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/protocols/channels/StoredPaymentChannelClientStates.java#L245-L257 |
anotheria/moskito | moskito-integration/moskito-cdi/src/main/java/net/anotheria/moskito/integration/cdi/AbstractInterceptor.java | AbstractInterceptor.createMethodLevelAccumulators | private void createMethodLevelAccumulators(OnDemandStatsProducer<T> producer, Method method) {
"""
Create method level accumulators.
@param producer {@link OnDemandStatsProducer}
@param method annotated method
"""
//several @Accumulators in accumulators holder
String methodName = getMethodName(method);
Accumulates accAnnotationHolderMethods = (Accumulates) method.getAnnotation(Accumulates.class);
if (accAnnotationHolderMethods != null) {
Accumulate[] accAnnotations = accAnnotationHolderMethods.value();
for (Accumulate accAnnotation : accAnnotations) {
createAccumulator(
producer.getProducerId(),
accAnnotation,
formAccumulatorNameForMethod(producer, accAnnotation, method),
methodName
);
}
}
//If there is no @Accumulates annotation but @Accumulate is present
createAccumulator(
producer.getProducerId(),
method.getAnnotation(Accumulate.class),
formAccumulatorNameForMethod(producer, method.getAnnotation(Accumulate.class), method),
methodName
);
} | java | private void createMethodLevelAccumulators(OnDemandStatsProducer<T> producer, Method method) {
//several @Accumulators in accumulators holder
String methodName = getMethodName(method);
Accumulates accAnnotationHolderMethods = (Accumulates) method.getAnnotation(Accumulates.class);
if (accAnnotationHolderMethods != null) {
Accumulate[] accAnnotations = accAnnotationHolderMethods.value();
for (Accumulate accAnnotation : accAnnotations) {
createAccumulator(
producer.getProducerId(),
accAnnotation,
formAccumulatorNameForMethod(producer, accAnnotation, method),
methodName
);
}
}
//If there is no @Accumulates annotation but @Accumulate is present
createAccumulator(
producer.getProducerId(),
method.getAnnotation(Accumulate.class),
formAccumulatorNameForMethod(producer, method.getAnnotation(Accumulate.class), method),
methodName
);
} | [
"private",
"void",
"createMethodLevelAccumulators",
"(",
"OnDemandStatsProducer",
"<",
"T",
">",
"producer",
",",
"Method",
"method",
")",
"{",
"//several @Accumulators in accumulators holder",
"String",
"methodName",
"=",
"getMethodName",
"(",
"method",
")",
";",
"Accumulates",
"accAnnotationHolderMethods",
"=",
"(",
"Accumulates",
")",
"method",
".",
"getAnnotation",
"(",
"Accumulates",
".",
"class",
")",
";",
"if",
"(",
"accAnnotationHolderMethods",
"!=",
"null",
")",
"{",
"Accumulate",
"[",
"]",
"accAnnotations",
"=",
"accAnnotationHolderMethods",
".",
"value",
"(",
")",
";",
"for",
"(",
"Accumulate",
"accAnnotation",
":",
"accAnnotations",
")",
"{",
"createAccumulator",
"(",
"producer",
".",
"getProducerId",
"(",
")",
",",
"accAnnotation",
",",
"formAccumulatorNameForMethod",
"(",
"producer",
",",
"accAnnotation",
",",
"method",
")",
",",
"methodName",
")",
";",
"}",
"}",
"//If there is no @Accumulates annotation but @Accumulate is present",
"createAccumulator",
"(",
"producer",
".",
"getProducerId",
"(",
")",
",",
"method",
".",
"getAnnotation",
"(",
"Accumulate",
".",
"class",
")",
",",
"formAccumulatorNameForMethod",
"(",
"producer",
",",
"method",
".",
"getAnnotation",
"(",
"Accumulate",
".",
"class",
")",
",",
"method",
")",
",",
"methodName",
")",
";",
"}"
] | Create method level accumulators.
@param producer {@link OnDemandStatsProducer}
@param method annotated method | [
"Create",
"method",
"level",
"accumulators",
"."
] | train | https://github.com/anotheria/moskito/blob/0fdb79053b98a6ece610fa159f59bc3331e4cf05/moskito-integration/moskito-cdi/src/main/java/net/anotheria/moskito/integration/cdi/AbstractInterceptor.java#L150-L173 |
Labs64/swid-generator | src/main/java/com/labs64/utils/swid/processor/DefaultSwidProcessor.java | DefaultSwidProcessor.setSoftwareId | public DefaultSwidProcessor setSoftwareId(final String uniqueId, final String tagCreatorRegid) {
"""
Identifies the specific version of a product (tag: software_id).
@param uniqueId
software unique ID
@param tagCreatorRegid
tag creator registration ID
@return a reference to this object.
"""
swidTag.setSoftwareId(
new SoftwareIdComplexType(
new Token(uniqueId, idGenerator.nextId()),
new RegistrationId(tagCreatorRegid, idGenerator.nextId()),
idGenerator.nextId()));
return this;
} | java | public DefaultSwidProcessor setSoftwareId(final String uniqueId, final String tagCreatorRegid) {
swidTag.setSoftwareId(
new SoftwareIdComplexType(
new Token(uniqueId, idGenerator.nextId()),
new RegistrationId(tagCreatorRegid, idGenerator.nextId()),
idGenerator.nextId()));
return this;
} | [
"public",
"DefaultSwidProcessor",
"setSoftwareId",
"(",
"final",
"String",
"uniqueId",
",",
"final",
"String",
"tagCreatorRegid",
")",
"{",
"swidTag",
".",
"setSoftwareId",
"(",
"new",
"SoftwareIdComplexType",
"(",
"new",
"Token",
"(",
"uniqueId",
",",
"idGenerator",
".",
"nextId",
"(",
")",
")",
",",
"new",
"RegistrationId",
"(",
"tagCreatorRegid",
",",
"idGenerator",
".",
"nextId",
"(",
")",
")",
",",
"idGenerator",
".",
"nextId",
"(",
")",
")",
")",
";",
"return",
"this",
";",
"}"
] | Identifies the specific version of a product (tag: software_id).
@param uniqueId
software unique ID
@param tagCreatorRegid
tag creator registration ID
@return a reference to this object. | [
"Identifies",
"the",
"specific",
"version",
"of",
"a",
"product",
"(",
"tag",
":",
"software_id",
")",
"."
] | train | https://github.com/Labs64/swid-generator/blob/cf78d2469469a09701bce7c5f966ac6de2b7c613/src/main/java/com/labs64/utils/swid/processor/DefaultSwidProcessor.java#L174-L181 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/PluralRulesLoader.java | PluralRulesLoader.getRulesIdForLocale | public String getRulesIdForLocale(ULocale locale, PluralType type) {
"""
Gets the rulesId from the locale,with locale fallback. If there is no
rulesId, return null. The rulesId might be the empty string if the rule
is the default rule.
"""
Map<String, String> idMap = getLocaleIdToRulesIdMap(type);
String localeId = ULocale.canonicalize(locale.getBaseName());
String rulesId = null;
while (null == (rulesId = idMap.get(localeId))) {
int ix = localeId.lastIndexOf("_");
if (ix == -1) {
break;
}
localeId = localeId.substring(0, ix);
}
return rulesId;
} | java | public String getRulesIdForLocale(ULocale locale, PluralType type) {
Map<String, String> idMap = getLocaleIdToRulesIdMap(type);
String localeId = ULocale.canonicalize(locale.getBaseName());
String rulesId = null;
while (null == (rulesId = idMap.get(localeId))) {
int ix = localeId.lastIndexOf("_");
if (ix == -1) {
break;
}
localeId = localeId.substring(0, ix);
}
return rulesId;
} | [
"public",
"String",
"getRulesIdForLocale",
"(",
"ULocale",
"locale",
",",
"PluralType",
"type",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"idMap",
"=",
"getLocaleIdToRulesIdMap",
"(",
"type",
")",
";",
"String",
"localeId",
"=",
"ULocale",
".",
"canonicalize",
"(",
"locale",
".",
"getBaseName",
"(",
")",
")",
";",
"String",
"rulesId",
"=",
"null",
";",
"while",
"(",
"null",
"==",
"(",
"rulesId",
"=",
"idMap",
".",
"get",
"(",
"localeId",
")",
")",
")",
"{",
"int",
"ix",
"=",
"localeId",
".",
"lastIndexOf",
"(",
"\"_\"",
")",
";",
"if",
"(",
"ix",
"==",
"-",
"1",
")",
"{",
"break",
";",
"}",
"localeId",
"=",
"localeId",
".",
"substring",
"(",
"0",
",",
"ix",
")",
";",
"}",
"return",
"rulesId",
";",
"}"
] | Gets the rulesId from the locale,with locale fallback. If there is no
rulesId, return null. The rulesId might be the empty string if the rule
is the default rule. | [
"Gets",
"the",
"rulesId",
"from",
"the",
"locale",
"with",
"locale",
"fallback",
".",
"If",
"there",
"is",
"no",
"rulesId",
"return",
"null",
".",
"The",
"rulesId",
"might",
"be",
"the",
"empty",
"string",
"if",
"the",
"rule",
"is",
"the",
"default",
"rule",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/PluralRulesLoader.java#L166-L178 |
Alluxio/alluxio | core/common/src/main/java/alluxio/underfs/ObjectUnderFileSystem.java | ObjectUnderFileSystem.getChildName | protected String getChildName(String child, String parent) throws IOException {
"""
Gets the child name based on the parent name.
@param child the key of the child
@param parent the key of the parent
@return the child key with the parent prefix removed
"""
if (child.startsWith(parent)) {
return child.substring(parent.length());
}
throw new IOException(ExceptionMessage.INVALID_PREFIX.getMessage(parent, child));
} | java | protected String getChildName(String child, String parent) throws IOException {
if (child.startsWith(parent)) {
return child.substring(parent.length());
}
throw new IOException(ExceptionMessage.INVALID_PREFIX.getMessage(parent, child));
} | [
"protected",
"String",
"getChildName",
"(",
"String",
"child",
",",
"String",
"parent",
")",
"throws",
"IOException",
"{",
"if",
"(",
"child",
".",
"startsWith",
"(",
"parent",
")",
")",
"{",
"return",
"child",
".",
"substring",
"(",
"parent",
".",
"length",
"(",
")",
")",
";",
"}",
"throw",
"new",
"IOException",
"(",
"ExceptionMessage",
".",
"INVALID_PREFIX",
".",
"getMessage",
"(",
"parent",
",",
"child",
")",
")",
";",
"}"
] | Gets the child name based on the parent name.
@param child the key of the child
@param parent the key of the parent
@return the child key with the parent prefix removed | [
"Gets",
"the",
"child",
"name",
"based",
"on",
"the",
"parent",
"name",
"."
] | train | https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/underfs/ObjectUnderFileSystem.java#L894-L899 |
pressgang-ccms/PressGangCCMSContentSpecProcessor | src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java | ContentSpecProcessor.getTopicForTopicNode | protected TopicWrapper getTopicForTopicNode(final DataProviderFactory providerFactory, final ITopicNode topicNode) {
"""
Gets or creates the underlying Topic Entity for a spec topic.
@param providerFactory
@param topicNode The spec topic to get the topic entity for.
@return The topic entity if one could be found, otherwise null.
"""
TopicWrapper topic = null;
if (topicNode.isTopicANewTopic()) {
topic = getTopicForNewTopicNode(providerFactory, topicNode);
} else if (topicNode.isTopicAClonedTopic()) {
topic = ProcessorUtilities.cloneTopic(providerFactory, topicNode, serverEntities);
} else if (topicNode.isTopicAnExistingTopic()) {
topic = getTopicForExistingTopicNode(providerFactory, topicNode);
}
return topic;
} | java | protected TopicWrapper getTopicForTopicNode(final DataProviderFactory providerFactory, final ITopicNode topicNode) {
TopicWrapper topic = null;
if (topicNode.isTopicANewTopic()) {
topic = getTopicForNewTopicNode(providerFactory, topicNode);
} else if (topicNode.isTopicAClonedTopic()) {
topic = ProcessorUtilities.cloneTopic(providerFactory, topicNode, serverEntities);
} else if (topicNode.isTopicAnExistingTopic()) {
topic = getTopicForExistingTopicNode(providerFactory, topicNode);
}
return topic;
} | [
"protected",
"TopicWrapper",
"getTopicForTopicNode",
"(",
"final",
"DataProviderFactory",
"providerFactory",
",",
"final",
"ITopicNode",
"topicNode",
")",
"{",
"TopicWrapper",
"topic",
"=",
"null",
";",
"if",
"(",
"topicNode",
".",
"isTopicANewTopic",
"(",
")",
")",
"{",
"topic",
"=",
"getTopicForNewTopicNode",
"(",
"providerFactory",
",",
"topicNode",
")",
";",
"}",
"else",
"if",
"(",
"topicNode",
".",
"isTopicAClonedTopic",
"(",
")",
")",
"{",
"topic",
"=",
"ProcessorUtilities",
".",
"cloneTopic",
"(",
"providerFactory",
",",
"topicNode",
",",
"serverEntities",
")",
";",
"}",
"else",
"if",
"(",
"topicNode",
".",
"isTopicAnExistingTopic",
"(",
")",
")",
"{",
"topic",
"=",
"getTopicForExistingTopicNode",
"(",
"providerFactory",
",",
"topicNode",
")",
";",
"}",
"return",
"topic",
";",
"}"
] | Gets or creates the underlying Topic Entity for a spec topic.
@param providerFactory
@param topicNode The spec topic to get the topic entity for.
@return The topic entity if one could be found, otherwise null. | [
"Gets",
"or",
"creates",
"the",
"underlying",
"Topic",
"Entity",
"for",
"a",
"spec",
"topic",
"."
] | train | https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java#L628-L640 |
facebookarchive/hadoop-20 | src/contrib/highavailability/src/java/org/apache/hadoop/hdfs/server/namenode/AvatarStorageSetup.java | AvatarStorageSetup.checkImageStorage | private static String checkImageStorage(URI sharedImage, URI sharedEdits) {
"""
Shared image needs to be in file storage, or QJM providing that QJM also
stores edits.
"""
if (sharedImage.getScheme().equals(NNStorage.LOCAL_URI_SCHEME)) {
// shared image is stored in file storage
return "";
} else if (sharedImage.getScheme().equals(
QuorumJournalManager.QJM_URI_SCHEME)
&& sharedImage.equals(sharedEdits)) {
// image is stored in qjm together with edits
return "";
}
return "Shared image uri: " + sharedImage + " must be either file storage"
+ " or be equal to shared edits storage " + sharedEdits + ". ";
} | java | private static String checkImageStorage(URI sharedImage, URI sharedEdits) {
if (sharedImage.getScheme().equals(NNStorage.LOCAL_URI_SCHEME)) {
// shared image is stored in file storage
return "";
} else if (sharedImage.getScheme().equals(
QuorumJournalManager.QJM_URI_SCHEME)
&& sharedImage.equals(sharedEdits)) {
// image is stored in qjm together with edits
return "";
}
return "Shared image uri: " + sharedImage + " must be either file storage"
+ " or be equal to shared edits storage " + sharedEdits + ". ";
} | [
"private",
"static",
"String",
"checkImageStorage",
"(",
"URI",
"sharedImage",
",",
"URI",
"sharedEdits",
")",
"{",
"if",
"(",
"sharedImage",
".",
"getScheme",
"(",
")",
".",
"equals",
"(",
"NNStorage",
".",
"LOCAL_URI_SCHEME",
")",
")",
"{",
"// shared image is stored in file storage",
"return",
"\"\"",
";",
"}",
"else",
"if",
"(",
"sharedImage",
".",
"getScheme",
"(",
")",
".",
"equals",
"(",
"QuorumJournalManager",
".",
"QJM_URI_SCHEME",
")",
"&&",
"sharedImage",
".",
"equals",
"(",
"sharedEdits",
")",
")",
"{",
"// image is stored in qjm together with edits",
"return",
"\"\"",
";",
"}",
"return",
"\"Shared image uri: \"",
"+",
"sharedImage",
"+",
"\" must be either file storage\"",
"+",
"\" or be equal to shared edits storage \"",
"+",
"sharedEdits",
"+",
"\". \"",
";",
"}"
] | Shared image needs to be in file storage, or QJM providing that QJM also
stores edits. | [
"Shared",
"image",
"needs",
"to",
"be",
"in",
"file",
"storage",
"or",
"QJM",
"providing",
"that",
"QJM",
"also",
"stores",
"edits",
"."
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/contrib/highavailability/src/java/org/apache/hadoop/hdfs/server/namenode/AvatarStorageSetup.java#L123-L135 |
tracee/tracee | core/src/main/java/io/tracee/Utilities.java | Utilities.generateSessionIdIfNecessary | public static void generateSessionIdIfNecessary(final TraceeBackend backend, final String sessionId) {
"""
Generate session id hash if it doesn't exist in TraceeBackend and configuration asks for one
@param backend Currently used TraceeBackend
@param sessionId Current http sessionId
"""
if (backend != null && !backend.containsKey(TraceeConstants.SESSION_ID_KEY) && backend.getConfiguration().shouldGenerateSessionId()) {
backend.put(TraceeConstants.SESSION_ID_KEY, Utilities.createAlphanumericHash(sessionId, backend.getConfiguration().generatedSessionIdLength()));
}
} | java | public static void generateSessionIdIfNecessary(final TraceeBackend backend, final String sessionId) {
if (backend != null && !backend.containsKey(TraceeConstants.SESSION_ID_KEY) && backend.getConfiguration().shouldGenerateSessionId()) {
backend.put(TraceeConstants.SESSION_ID_KEY, Utilities.createAlphanumericHash(sessionId, backend.getConfiguration().generatedSessionIdLength()));
}
} | [
"public",
"static",
"void",
"generateSessionIdIfNecessary",
"(",
"final",
"TraceeBackend",
"backend",
",",
"final",
"String",
"sessionId",
")",
"{",
"if",
"(",
"backend",
"!=",
"null",
"&&",
"!",
"backend",
".",
"containsKey",
"(",
"TraceeConstants",
".",
"SESSION_ID_KEY",
")",
"&&",
"backend",
".",
"getConfiguration",
"(",
")",
".",
"shouldGenerateSessionId",
"(",
")",
")",
"{",
"backend",
".",
"put",
"(",
"TraceeConstants",
".",
"SESSION_ID_KEY",
",",
"Utilities",
".",
"createAlphanumericHash",
"(",
"sessionId",
",",
"backend",
".",
"getConfiguration",
"(",
")",
".",
"generatedSessionIdLength",
"(",
")",
")",
")",
";",
"}",
"}"
] | Generate session id hash if it doesn't exist in TraceeBackend and configuration asks for one
@param backend Currently used TraceeBackend
@param sessionId Current http sessionId | [
"Generate",
"session",
"id",
"hash",
"if",
"it",
"doesn",
"t",
"exist",
"in",
"TraceeBackend",
"and",
"configuration",
"asks",
"for",
"one"
] | train | https://github.com/tracee/tracee/blob/15a68e435248f57757beb8ceac6db5b7f6035bb3/core/src/main/java/io/tracee/Utilities.java#L78-L82 |
derari/cthul | objects/src/main/java/org/cthul/objects/Boxing.java | Boxing.unboxAll | public static Object unboxAll(Object[] src, int srcPos, int len) {
"""
Transforms an array of {@code Boolean}, {@code Character}, or {@code Number}
into a primitive array.
@param src source array
@param srcPos start position
@param len length
@return primitive array
"""
if (srcPos >= src.length) {
throw new IndexOutOfBoundsException(String.valueOf(srcPos));
}
Class<?> type = src[srcPos].getClass();
return unboxAll(type, src, srcPos, len);
} | java | public static Object unboxAll(Object[] src, int srcPos, int len) {
if (srcPos >= src.length) {
throw new IndexOutOfBoundsException(String.valueOf(srcPos));
}
Class<?> type = src[srcPos].getClass();
return unboxAll(type, src, srcPos, len);
} | [
"public",
"static",
"Object",
"unboxAll",
"(",
"Object",
"[",
"]",
"src",
",",
"int",
"srcPos",
",",
"int",
"len",
")",
"{",
"if",
"(",
"srcPos",
">=",
"src",
".",
"length",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"String",
".",
"valueOf",
"(",
"srcPos",
")",
")",
";",
"}",
"Class",
"<",
"?",
">",
"type",
"=",
"src",
"[",
"srcPos",
"]",
".",
"getClass",
"(",
")",
";",
"return",
"unboxAll",
"(",
"type",
",",
"src",
",",
"srcPos",
",",
"len",
")",
";",
"}"
] | Transforms an array of {@code Boolean}, {@code Character}, or {@code Number}
into a primitive array.
@param src source array
@param srcPos start position
@param len length
@return primitive array | [
"Transforms",
"an",
"array",
"of",
"{"
] | train | https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/objects/src/main/java/org/cthul/objects/Boxing.java#L157-L163 |
prestodb/presto | presto-main/src/main/java/com/facebook/presto/execution/buffer/ClientBuffer.java | ClientBuffer.loadPagesIfNecessary | private boolean loadPagesIfNecessary(PagesSupplier pagesSupplier, DataSize maxSize) {
"""
If there no data, attempt to load some from the pages supplier.
"""
checkState(!Thread.holdsLock(this), "Can not load pages while holding a lock on this");
boolean dataAddedOrNoMorePages;
List<SerializedPageReference> pageReferences;
synchronized (this) {
if (noMorePages) {
return false;
}
if (!pages.isEmpty()) {
return false;
}
// The page supplier has incremented the page reference count, and addPages below also increments
// the reference count, so we need to drop the page supplier reference. The call dereferencePage
// is performed outside of synchronized to avoid making a callback while holding a lock.
pageReferences = pagesSupplier.getPages(maxSize);
// add the pages to this buffer, which will increase the reference count
addPages(pageReferences);
// check for no more pages
if (!pagesSupplier.mayHaveMorePages()) {
noMorePages = true;
}
dataAddedOrNoMorePages = !pageReferences.isEmpty() || noMorePages;
}
// sent pages will have an initial reference count, so drop it
pageReferences.forEach(SerializedPageReference::dereferencePage);
return dataAddedOrNoMorePages;
} | java | private boolean loadPagesIfNecessary(PagesSupplier pagesSupplier, DataSize maxSize)
{
checkState(!Thread.holdsLock(this), "Can not load pages while holding a lock on this");
boolean dataAddedOrNoMorePages;
List<SerializedPageReference> pageReferences;
synchronized (this) {
if (noMorePages) {
return false;
}
if (!pages.isEmpty()) {
return false;
}
// The page supplier has incremented the page reference count, and addPages below also increments
// the reference count, so we need to drop the page supplier reference. The call dereferencePage
// is performed outside of synchronized to avoid making a callback while holding a lock.
pageReferences = pagesSupplier.getPages(maxSize);
// add the pages to this buffer, which will increase the reference count
addPages(pageReferences);
// check for no more pages
if (!pagesSupplier.mayHaveMorePages()) {
noMorePages = true;
}
dataAddedOrNoMorePages = !pageReferences.isEmpty() || noMorePages;
}
// sent pages will have an initial reference count, so drop it
pageReferences.forEach(SerializedPageReference::dereferencePage);
return dataAddedOrNoMorePages;
} | [
"private",
"boolean",
"loadPagesIfNecessary",
"(",
"PagesSupplier",
"pagesSupplier",
",",
"DataSize",
"maxSize",
")",
"{",
"checkState",
"(",
"!",
"Thread",
".",
"holdsLock",
"(",
"this",
")",
",",
"\"Can not load pages while holding a lock on this\"",
")",
";",
"boolean",
"dataAddedOrNoMorePages",
";",
"List",
"<",
"SerializedPageReference",
">",
"pageReferences",
";",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"noMorePages",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"pages",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"// The page supplier has incremented the page reference count, and addPages below also increments",
"// the reference count, so we need to drop the page supplier reference. The call dereferencePage",
"// is performed outside of synchronized to avoid making a callback while holding a lock.",
"pageReferences",
"=",
"pagesSupplier",
".",
"getPages",
"(",
"maxSize",
")",
";",
"// add the pages to this buffer, which will increase the reference count",
"addPages",
"(",
"pageReferences",
")",
";",
"// check for no more pages",
"if",
"(",
"!",
"pagesSupplier",
".",
"mayHaveMorePages",
"(",
")",
")",
"{",
"noMorePages",
"=",
"true",
";",
"}",
"dataAddedOrNoMorePages",
"=",
"!",
"pageReferences",
".",
"isEmpty",
"(",
")",
"||",
"noMorePages",
";",
"}",
"// sent pages will have an initial reference count, so drop it",
"pageReferences",
".",
"forEach",
"(",
"SerializedPageReference",
"::",
"dereferencePage",
")",
";",
"return",
"dataAddedOrNoMorePages",
";",
"}"
] | If there no data, attempt to load some from the pages supplier. | [
"If",
"there",
"no",
"data",
"attempt",
"to",
"load",
"some",
"from",
"the",
"pages",
"supplier",
"."
] | train | https://github.com/prestodb/presto/blob/89de5e379d8f85e139d292b0add8c537a2a01a88/presto-main/src/main/java/com/facebook/presto/execution/buffer/ClientBuffer.java#L257-L291 |
Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/utility/ResourceCache.java | ResourceCache.wrapCallback | public static CompressedTextureCallback wrapCallback(
ResourceCache<GVRImage> cache, CompressedTextureCallback callback) {
"""
Wrap the callback, to cache the
{@link CompressedTextureCallback#loaded(GVRHybridObject, GVRAndroidResource)
loaded()} resource
"""
return new CompressedTextureCallbackWrapper(cache, callback);
} | java | public static CompressedTextureCallback wrapCallback(
ResourceCache<GVRImage> cache, CompressedTextureCallback callback) {
return new CompressedTextureCallbackWrapper(cache, callback);
} | [
"public",
"static",
"CompressedTextureCallback",
"wrapCallback",
"(",
"ResourceCache",
"<",
"GVRImage",
">",
"cache",
",",
"CompressedTextureCallback",
"callback",
")",
"{",
"return",
"new",
"CompressedTextureCallbackWrapper",
"(",
"cache",
",",
"callback",
")",
";",
"}"
] | Wrap the callback, to cache the
{@link CompressedTextureCallback#loaded(GVRHybridObject, GVRAndroidResource)
loaded()} resource | [
"Wrap",
"the",
"callback",
"to",
"cache",
"the",
"{"
] | train | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/utility/ResourceCache.java#L77-L80 |
aws/aws-sdk-java | aws-java-sdk-apigatewayv2/src/main/java/com/amazonaws/services/apigatewayv2/model/UpdateRouteResponseResult.java | UpdateRouteResponseResult.withResponseModels | public UpdateRouteResponseResult withResponseModels(java.util.Map<String, String> responseModels) {
"""
<p>
Represents the response models of a route response.
</p>
@param responseModels
Represents the response models of a route response.
@return Returns a reference to this object so that method calls can be chained together.
"""
setResponseModels(responseModels);
return this;
} | java | public UpdateRouteResponseResult withResponseModels(java.util.Map<String, String> responseModels) {
setResponseModels(responseModels);
return this;
} | [
"public",
"UpdateRouteResponseResult",
"withResponseModels",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"responseModels",
")",
"{",
"setResponseModels",
"(",
"responseModels",
")",
";",
"return",
"this",
";",
"}"
] | <p>
Represents the response models of a route response.
</p>
@param responseModels
Represents the response models of a route response.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"Represents",
"the",
"response",
"models",
"of",
"a",
"route",
"response",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-apigatewayv2/src/main/java/com/amazonaws/services/apigatewayv2/model/UpdateRouteResponseResult.java#L127-L130 |
grails/grails-core | grails-spring/src/main/groovy/org/grails/spring/GrailsApplicationContext.java | GrailsApplicationContext.registerSingleton | public void registerSingleton(String name, Class<?> clazz) throws BeansException {
"""
Register a singleton bean with the underlying bean factory.
<p>For more advanced needs, register with the underlying BeanFactory directly.
@see #getDefaultListableBeanFactory
"""
GenericBeanDefinition bd = new GenericBeanDefinition();
bd.setBeanClass(clazz);
getDefaultListableBeanFactory().registerBeanDefinition(name, bd);
} | java | public void registerSingleton(String name, Class<?> clazz) throws BeansException {
GenericBeanDefinition bd = new GenericBeanDefinition();
bd.setBeanClass(clazz);
getDefaultListableBeanFactory().registerBeanDefinition(name, bd);
} | [
"public",
"void",
"registerSingleton",
"(",
"String",
"name",
",",
"Class",
"<",
"?",
">",
"clazz",
")",
"throws",
"BeansException",
"{",
"GenericBeanDefinition",
"bd",
"=",
"new",
"GenericBeanDefinition",
"(",
")",
";",
"bd",
".",
"setBeanClass",
"(",
"clazz",
")",
";",
"getDefaultListableBeanFactory",
"(",
")",
".",
"registerBeanDefinition",
"(",
"name",
",",
"bd",
")",
";",
"}"
] | Register a singleton bean with the underlying bean factory.
<p>For more advanced needs, register with the underlying BeanFactory directly.
@see #getDefaultListableBeanFactory | [
"Register",
"a",
"singleton",
"bean",
"with",
"the",
"underlying",
"bean",
"factory",
".",
"<p",
">",
"For",
"more",
"advanced",
"needs",
"register",
"with",
"the",
"underlying",
"BeanFactory",
"directly",
"."
] | train | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-spring/src/main/groovy/org/grails/spring/GrailsApplicationContext.java#L132-L136 |
Microsoft/malmo | Minecraft/src/main/java/com/microsoft/Malmo/Utils/TCPSocketChannel.java | TCPSocketChannel.sendTCPString | public boolean sendTCPString(String message, int retries) {
"""
Send string over TCP to the specified address via the specified port, including a header.
@param message string to be sent over TCP
@param retries number of times to retry in event of failure
@return true if message was successfully sent
"""
Log(Level.FINE, "About to send: " + message);
byte[] bytes = message.getBytes();
return sendTCPBytes(bytes, retries);
} | java | public boolean sendTCPString(String message, int retries)
{
Log(Level.FINE, "About to send: " + message);
byte[] bytes = message.getBytes();
return sendTCPBytes(bytes, retries);
} | [
"public",
"boolean",
"sendTCPString",
"(",
"String",
"message",
",",
"int",
"retries",
")",
"{",
"Log",
"(",
"Level",
".",
"FINE",
",",
"\"About to send: \"",
"+",
"message",
")",
";",
"byte",
"[",
"]",
"bytes",
"=",
"message",
".",
"getBytes",
"(",
")",
";",
"return",
"sendTCPBytes",
"(",
"bytes",
",",
"retries",
")",
";",
"}"
] | Send string over TCP to the specified address via the specified port, including a header.
@param message string to be sent over TCP
@param retries number of times to retry in event of failure
@return true if message was successfully sent | [
"Send",
"string",
"over",
"TCP",
"to",
"the",
"specified",
"address",
"via",
"the",
"specified",
"port",
"including",
"a",
"header",
"."
] | train | https://github.com/Microsoft/malmo/blob/4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a/Minecraft/src/main/java/com/microsoft/Malmo/Utils/TCPSocketChannel.java#L108-L113 |
deeplearning4j/deeplearning4j | nd4j/nd4j-common/src/main/java/org/nd4j/base/Preconditions.java | Preconditions.checkNotNull | public static void checkNotNull(Object o, String message, Object... args) {
"""
Check the specified boolean argument. Throws an IllegalStateException with the specified message if {@code o} is false.
Note that the message may specify argument locations using "%s" - for example,
{@code checkArgument(false, "Got %s values, expected %s", 3, "more"} would throw an IllegalStateException
with the message "Got 3 values, expected more"
@param o Object to check
@param message Message for exception. May be null.
@param args Arguments to place in message
"""
if (o == null) {
throwStateEx(message, args);
}
} | java | public static void checkNotNull(Object o, String message, Object... args) {
if (o == null) {
throwStateEx(message, args);
}
} | [
"public",
"static",
"void",
"checkNotNull",
"(",
"Object",
"o",
",",
"String",
"message",
",",
"Object",
"...",
"args",
")",
"{",
"if",
"(",
"o",
"==",
"null",
")",
"{",
"throwStateEx",
"(",
"message",
",",
"args",
")",
";",
"}",
"}"
] | Check the specified boolean argument. Throws an IllegalStateException with the specified message if {@code o} is false.
Note that the message may specify argument locations using "%s" - for example,
{@code checkArgument(false, "Got %s values, expected %s", 3, "more"} would throw an IllegalStateException
with the message "Got 3 values, expected more"
@param o Object to check
@param message Message for exception. May be null.
@param args Arguments to place in message | [
"Check",
"the",
"specified",
"boolean",
"argument",
".",
"Throws",
"an",
"IllegalStateException",
"with",
"the",
"specified",
"message",
"if",
"{",
"@code",
"o",
"}",
"is",
"false",
".",
"Note",
"that",
"the",
"message",
"may",
"specify",
"argument",
"locations",
"using",
"%s",
"-",
"for",
"example",
"{",
"@code",
"checkArgument",
"(",
"false",
"Got",
"%s",
"values",
"expected",
"%s",
"3",
"more",
"}",
"would",
"throw",
"an",
"IllegalStateException",
"with",
"the",
"message",
"Got",
"3",
"values",
"expected",
"more"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-common/src/main/java/org/nd4j/base/Preconditions.java#L628-L632 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/util/ValidationUtils.java | ValidationUtils.validate2x2NonNegative | public static int[][] validate2x2NonNegative(int[][] data, String paramName) {
"""
Reformats the input array to a 2x2 array and checks that all values are >= 0.
If the array is 2x1 ([[a], [b]]), returns [[a, a], [b, b]]
If the array is 1x2 ([[a, b]]), returns [[a, b], [a, b]]
If the array is 2x2, returns the array
@param data An array
@param paramName The param name, for error reporting
@return An int array of length 2 that represents the input
"""
for(int[] part : data)
validateNonNegative(part, paramName);
return validate2x2(data, paramName);
}
/**
* Reformats the input array to a 2x2 array.
*
* If the array is 2x1 ([[a], [b]]), returns [[a, a], [b, b]]
* If the array is 1x2 ([[a, b]]), returns [[a, b], [a, b]]
* If the array is 2x2, returns the array
*
* @param data An array
* @param paramName The param name, for error reporting
* @return An int array of length 2 that represents the input
*/
public static int[][] validate2x2(int[][] data, String paramName){
if(data == null) {
return null;
}
Preconditions.checkArgument(
(data.length == 1 && data[0].length == 2) ||
(data.length == 2 &&
(data[0].length == 1 || data[0].length == 2) &&
(data[1].length == 1 || data[1].length == 2) &&
data[0].length == data[1].length
),
"Value for %s must have shape 2x1, 1x2, or 2x2, got %sx%s shaped array: %s",
paramName, data.length, data[0].length, data);
if(data.length == 1) {
return new int[][]{
data[0],
data[0]
};
} else if(data[0].length == 1){
return new int[][]{
new int[]{data[0][0], data[0][0]},
new int[]{data[1][0], data[1][0]}
};
} else {
return data;
}
} | java | public static int[][] validate2x2NonNegative(int[][] data, String paramName){
for(int[] part : data)
validateNonNegative(part, paramName);
return validate2x2(data, paramName);
}
/**
* Reformats the input array to a 2x2 array.
*
* If the array is 2x1 ([[a], [b]]), returns [[a, a], [b, b]]
* If the array is 1x2 ([[a, b]]), returns [[a, b], [a, b]]
* If the array is 2x2, returns the array
*
* @param data An array
* @param paramName The param name, for error reporting
* @return An int array of length 2 that represents the input
*/
public static int[][] validate2x2(int[][] data, String paramName){
if(data == null) {
return null;
}
Preconditions.checkArgument(
(data.length == 1 && data[0].length == 2) ||
(data.length == 2 &&
(data[0].length == 1 || data[0].length == 2) &&
(data[1].length == 1 || data[1].length == 2) &&
data[0].length == data[1].length
),
"Value for %s must have shape 2x1, 1x2, or 2x2, got %sx%s shaped array: %s",
paramName, data.length, data[0].length, data);
if(data.length == 1) {
return new int[][]{
data[0],
data[0]
};
} else if(data[0].length == 1){
return new int[][]{
new int[]{data[0][0], data[0][0]},
new int[]{data[1][0], data[1][0]}
};
} else {
return data;
}
} | [
"public",
"static",
"int",
"[",
"]",
"[",
"]",
"validate2x2NonNegative",
"(",
"int",
"[",
"]",
"[",
"]",
"data",
",",
"String",
"paramName",
")",
"{",
"for",
"(",
"int",
"[",
"]",
"part",
":",
"data",
")",
"validateNonNegative",
"(",
"part",
",",
"paramName",
")",
";",
"return",
"validate2x2",
"(",
"data",
",",
"paramName",
")",
";",
"}",
"/**\n * Reformats the input array to a 2x2 array.\n *\n * If the array is 2x1 ([[a], [b]]), returns [[a, a], [b, b]]\n * If the array is 1x2 ([[a, b]]), returns [[a, b], [a, b]]\n * If the array is 2x2, returns the array\n *\n * @param data An array\n * @param paramName The param name, for error reporting\n * @return An int array of length 2 that represents the input\n */",
"public",
"static",
"int",
"[",
"]",
"[",
"]",
"validate2x2",
"(",
"int",
"[",
"]",
"[",
"]",
"data",
",",
"String",
"paramName",
")",
"{",
"if",
"(",
"data",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"Preconditions",
".",
"checkArgument",
"(",
"(",
"data",
".",
"length",
"==",
"1",
"&&",
"data",
"[",
"0",
"]",
".",
"length",
"==",
"2",
")",
"||",
"(",
"data",
".",
"length",
"==",
"2",
"&&",
"(",
"data",
"[",
"0",
"]",
".",
"length",
"==",
"1",
"||",
"data",
"[",
"0",
"]",
".",
"length",
"==",
"2",
")",
"&&",
"(",
"data",
"[",
"1",
"]",
".",
"length",
"==",
"1",
"||",
"data",
"[",
"1",
"]",
".",
"length",
"==",
"2",
")",
"&&",
"data",
"[",
"0",
"]",
".",
"length",
"==",
"data",
"[",
"1",
"]",
".",
"length",
")",
",",
"\"Value for %s must have shape 2x1, 1x2, or 2x2, got %sx%s shaped array: %s\"",
",",
"paramName",
",",
"data",
".",
"length",
",",
"data",
"[",
"0",
"]",
".",
"length",
",",
"data",
")",
";",
"if",
"(",
"data",
".",
"length",
"==",
"1",
")",
"{",
"return",
"new",
"int",
"[",
"]",
"[",
"]",
"{",
"data",
"[",
"0",
"]",
",",
"data",
"[",
"0",
"]",
"}",
";",
"}",
"else",
"if",
"(",
"data",
"[",
"0",
"]",
".",
"length",
"==",
"1",
")",
"{",
"return",
"new",
"int",
"[",
"]",
"[",
"]",
"{",
"new",
"int",
"[",
"]",
"{",
"data",
"[",
"0",
"]",
"[",
"0",
"]",
",",
"data",
"[",
"0",
"]",
"[",
"0",
"]",
"}",
",",
"new",
"int",
"[",
"]",
"{",
"data",
"[",
"1",
"]",
"[",
"0",
"]",
",",
"data",
"[",
"1",
"]",
"[",
"0",
"]",
"}",
"}",
";",
"}",
"else",
"{",
"return",
"data",
";",
"}",
"}"
] | Reformats the input array to a 2x2 array and checks that all values are >= 0.
If the array is 2x1 ([[a], [b]]), returns [[a, a], [b, b]]
If the array is 1x2 ([[a, b]]), returns [[a, b], [a, b]]
If the array is 2x2, returns the array
@param data An array
@param paramName The param name, for error reporting
@return An int array of length 2 that represents the input | [
"Reformats",
"the",
"input",
"array",
"to",
"a",
"2x2",
"array",
"and",
"checks",
"that",
"all",
"values",
"are",
">",
"=",
"0",
"."
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/util/ValidationUtils.java#L172-L218 |
PeterisP/LVTagger | src/main/java/edu/stanford/nlp/io/IOUtils.java | IOUtils.writeObjectToFileNoExceptions | public static File writeObjectToFileNoExceptions(Object o, String filename) {
"""
Write object to a file with the specified name.
@param o
object to be written to file
@param filename
name of the temp file
@return File containing the object, or null if an exception was caught
"""
File file = null;
ObjectOutputStream oos = null;
try {
file = new File(filename);
// file.createNewFile(); // cdm may 2005: does nothing needed
oos = new ObjectOutputStream(new BufferedOutputStream(
new GZIPOutputStream(new FileOutputStream(file))));
oos.writeObject(o);
oos.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
closeIgnoringExceptions(oos);
}
return file;
} | java | public static File writeObjectToFileNoExceptions(Object o, String filename) {
File file = null;
ObjectOutputStream oos = null;
try {
file = new File(filename);
// file.createNewFile(); // cdm may 2005: does nothing needed
oos = new ObjectOutputStream(new BufferedOutputStream(
new GZIPOutputStream(new FileOutputStream(file))));
oos.writeObject(o);
oos.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
closeIgnoringExceptions(oos);
}
return file;
} | [
"public",
"static",
"File",
"writeObjectToFileNoExceptions",
"(",
"Object",
"o",
",",
"String",
"filename",
")",
"{",
"File",
"file",
"=",
"null",
";",
"ObjectOutputStream",
"oos",
"=",
"null",
";",
"try",
"{",
"file",
"=",
"new",
"File",
"(",
"filename",
")",
";",
"// file.createNewFile(); // cdm may 2005: does nothing needed\r",
"oos",
"=",
"new",
"ObjectOutputStream",
"(",
"new",
"BufferedOutputStream",
"(",
"new",
"GZIPOutputStream",
"(",
"new",
"FileOutputStream",
"(",
"file",
")",
")",
")",
")",
";",
"oos",
".",
"writeObject",
"(",
"o",
")",
";",
"oos",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"finally",
"{",
"closeIgnoringExceptions",
"(",
"oos",
")",
";",
"}",
"return",
"file",
";",
"}"
] | Write object to a file with the specified name.
@param o
object to be written to file
@param filename
name of the temp file
@return File containing the object, or null if an exception was caught | [
"Write",
"object",
"to",
"a",
"file",
"with",
"the",
"specified",
"name",
"."
] | train | https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/io/IOUtils.java#L95-L111 |
eclipse/xtext-extras | org.eclipse.xtext.xbase/src/org/eclipse/xtext/xbase/typesystem/internal/ScopeProviderAccess.java | ScopeProviderAccess.getErrorNode | private INode getErrorNode(XExpression expression, INode node) {
"""
Returns the node that best describes the error, e.g. if there is an expression
<code>com::foo::DoesNotExist::method()</code> the error will be rooted at <code>com</code>, but
the real problem is <code>com::foo::DoesNotExist</code>.
"""
if (expression instanceof XFeatureCall) {
XFeatureCall featureCall = (XFeatureCall) expression;
if (!canBeTypeLiteral(featureCall)) {
return node;
}
if (featureCall.eContainingFeature() == XbasePackage.Literals.XMEMBER_FEATURE_CALL__MEMBER_CALL_TARGET) {
XMemberFeatureCall container = (XMemberFeatureCall) featureCall.eContainer();
if (canBeTypeLiteral(container)) {
boolean explicitStatic = container.isExplicitStatic();
XMemberFeatureCall outerMost = getLongestTypeLiteralCandidate(container, explicitStatic);
if (outerMost != null)
return NodeModelUtils.getNode(outerMost);
}
}
}
return node;
} | java | private INode getErrorNode(XExpression expression, INode node) {
if (expression instanceof XFeatureCall) {
XFeatureCall featureCall = (XFeatureCall) expression;
if (!canBeTypeLiteral(featureCall)) {
return node;
}
if (featureCall.eContainingFeature() == XbasePackage.Literals.XMEMBER_FEATURE_CALL__MEMBER_CALL_TARGET) {
XMemberFeatureCall container = (XMemberFeatureCall) featureCall.eContainer();
if (canBeTypeLiteral(container)) {
boolean explicitStatic = container.isExplicitStatic();
XMemberFeatureCall outerMost = getLongestTypeLiteralCandidate(container, explicitStatic);
if (outerMost != null)
return NodeModelUtils.getNode(outerMost);
}
}
}
return node;
} | [
"private",
"INode",
"getErrorNode",
"(",
"XExpression",
"expression",
",",
"INode",
"node",
")",
"{",
"if",
"(",
"expression",
"instanceof",
"XFeatureCall",
")",
"{",
"XFeatureCall",
"featureCall",
"=",
"(",
"XFeatureCall",
")",
"expression",
";",
"if",
"(",
"!",
"canBeTypeLiteral",
"(",
"featureCall",
")",
")",
"{",
"return",
"node",
";",
"}",
"if",
"(",
"featureCall",
".",
"eContainingFeature",
"(",
")",
"==",
"XbasePackage",
".",
"Literals",
".",
"XMEMBER_FEATURE_CALL__MEMBER_CALL_TARGET",
")",
"{",
"XMemberFeatureCall",
"container",
"=",
"(",
"XMemberFeatureCall",
")",
"featureCall",
".",
"eContainer",
"(",
")",
";",
"if",
"(",
"canBeTypeLiteral",
"(",
"container",
")",
")",
"{",
"boolean",
"explicitStatic",
"=",
"container",
".",
"isExplicitStatic",
"(",
")",
";",
"XMemberFeatureCall",
"outerMost",
"=",
"getLongestTypeLiteralCandidate",
"(",
"container",
",",
"explicitStatic",
")",
";",
"if",
"(",
"outerMost",
"!=",
"null",
")",
"return",
"NodeModelUtils",
".",
"getNode",
"(",
"outerMost",
")",
";",
"}",
"}",
"}",
"return",
"node",
";",
"}"
] | Returns the node that best describes the error, e.g. if there is an expression
<code>com::foo::DoesNotExist::method()</code> the error will be rooted at <code>com</code>, but
the real problem is <code>com::foo::DoesNotExist</code>. | [
"Returns",
"the",
"node",
"that",
"best",
"describes",
"the",
"error",
"e",
".",
"g",
".",
"if",
"there",
"is",
"an",
"expression",
"<code",
">",
"com",
"::",
"foo",
"::",
"DoesNotExist",
"::",
"method",
"()",
"<",
"/",
"code",
">",
"the",
"error",
"will",
"be",
"rooted",
"at",
"<code",
">",
"com<",
"/",
"code",
">",
"but",
"the",
"real",
"problem",
"is",
"<code",
">",
"com",
"::",
"foo",
"::",
"DoesNotExist<",
"/",
"code",
">",
"."
] | train | https://github.com/eclipse/xtext-extras/blob/451359541295323a29f5855e633f770cec02069a/org.eclipse.xtext.xbase/src/org/eclipse/xtext/xbase/typesystem/internal/ScopeProviderAccess.java#L187-L204 |
vatbub/common | core/src/main/java/com/github/vatbub/common/core/Prefs.java | Prefs.setPreference | public void setPreference(String prefKey, String prefValue) {
"""
Sets the value of the specified preference in the properties file
@param prefKey The key of the preference to save
@param prefValue The value of the preference to save
"""
props.setProperty(prefKey, prefValue);
savePreferences();
} | java | public void setPreference(String prefKey, String prefValue) {
props.setProperty(prefKey, prefValue);
savePreferences();
} | [
"public",
"void",
"setPreference",
"(",
"String",
"prefKey",
",",
"String",
"prefValue",
")",
"{",
"props",
".",
"setProperty",
"(",
"prefKey",
",",
"prefValue",
")",
";",
"savePreferences",
"(",
")",
";",
"}"
] | Sets the value of the specified preference in the properties file
@param prefKey The key of the preference to save
@param prefValue The value of the preference to save | [
"Sets",
"the",
"value",
"of",
"the",
"specified",
"preference",
"in",
"the",
"properties",
"file"
] | train | https://github.com/vatbub/common/blob/8b9fd2ece0a23d520ce53b66c84cbd094e378443/core/src/main/java/com/github/vatbub/common/core/Prefs.java#L73-L76 |
GoogleCloudPlatform/bigdata-interop | gcsio/src/main/java/com/google/cloud/hadoop/gcsio/GoogleCloudStorageImpl.java | GoogleCloudStorageImpl.createItemInfoForBucket | public static GoogleCloudStorageItemInfo createItemInfoForBucket(
StorageResourceId resourceId, Bucket bucket) {
"""
Helper for converting a StorageResourceId + Bucket into a GoogleCloudStorageItemInfo.
"""
Preconditions.checkArgument(resourceId != null, "resourceId must not be null");
Preconditions.checkArgument(bucket != null, "bucket must not be null");
Preconditions.checkArgument(
resourceId.isBucket(), "resourceId must be a Bucket. resourceId: %s", resourceId);
Preconditions.checkArgument(
resourceId.getBucketName().equals(bucket.getName()),
"resourceId.getBucketName() must equal bucket.getName(): '%s' vs '%s'",
resourceId.getBucketName(), bucket.getName());
// For buckets, size is 0.
return new GoogleCloudStorageItemInfo(resourceId, bucket.getTimeCreated().getValue(),
0, bucket.getLocation(), bucket.getStorageClass());
} | java | public static GoogleCloudStorageItemInfo createItemInfoForBucket(
StorageResourceId resourceId, Bucket bucket) {
Preconditions.checkArgument(resourceId != null, "resourceId must not be null");
Preconditions.checkArgument(bucket != null, "bucket must not be null");
Preconditions.checkArgument(
resourceId.isBucket(), "resourceId must be a Bucket. resourceId: %s", resourceId);
Preconditions.checkArgument(
resourceId.getBucketName().equals(bucket.getName()),
"resourceId.getBucketName() must equal bucket.getName(): '%s' vs '%s'",
resourceId.getBucketName(), bucket.getName());
// For buckets, size is 0.
return new GoogleCloudStorageItemInfo(resourceId, bucket.getTimeCreated().getValue(),
0, bucket.getLocation(), bucket.getStorageClass());
} | [
"public",
"static",
"GoogleCloudStorageItemInfo",
"createItemInfoForBucket",
"(",
"StorageResourceId",
"resourceId",
",",
"Bucket",
"bucket",
")",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"resourceId",
"!=",
"null",
",",
"\"resourceId must not be null\"",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"bucket",
"!=",
"null",
",",
"\"bucket must not be null\"",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"resourceId",
".",
"isBucket",
"(",
")",
",",
"\"resourceId must be a Bucket. resourceId: %s\"",
",",
"resourceId",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"resourceId",
".",
"getBucketName",
"(",
")",
".",
"equals",
"(",
"bucket",
".",
"getName",
"(",
")",
")",
",",
"\"resourceId.getBucketName() must equal bucket.getName(): '%s' vs '%s'\"",
",",
"resourceId",
".",
"getBucketName",
"(",
")",
",",
"bucket",
".",
"getName",
"(",
")",
")",
";",
"// For buckets, size is 0.",
"return",
"new",
"GoogleCloudStorageItemInfo",
"(",
"resourceId",
",",
"bucket",
".",
"getTimeCreated",
"(",
")",
".",
"getValue",
"(",
")",
",",
"0",
",",
"bucket",
".",
"getLocation",
"(",
")",
",",
"bucket",
".",
"getStorageClass",
"(",
")",
")",
";",
"}"
] | Helper for converting a StorageResourceId + Bucket into a GoogleCloudStorageItemInfo. | [
"Helper",
"for",
"converting",
"a",
"StorageResourceId",
"+",
"Bucket",
"into",
"a",
"GoogleCloudStorageItemInfo",
"."
] | train | https://github.com/GoogleCloudPlatform/bigdata-interop/blob/918d91c80a63e36046edb28972a5c65d3326a858/gcsio/src/main/java/com/google/cloud/hadoop/gcsio/GoogleCloudStorageImpl.java#L1451-L1465 |
liferay/com-liferay-commerce | commerce-tax-service/src/main/java/com/liferay/commerce/tax/service/persistence/impl/CommerceTaxMethodPersistenceImpl.java | CommerceTaxMethodPersistenceImpl.findAll | @Override
public List<CommerceTaxMethod> findAll(int start, int end) {
"""
Returns a range of all the commerce tax methods.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CommerceTaxMethodModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param start the lower bound of the range of commerce tax methods
@param end the upper bound of the range of commerce tax methods (not inclusive)
@return the range of commerce tax methods
"""
return findAll(start, end, null);
} | java | @Override
public List<CommerceTaxMethod> findAll(int start, int end) {
return findAll(start, end, null);
} | [
"@",
"Override",
"public",
"List",
"<",
"CommerceTaxMethod",
">",
"findAll",
"(",
"int",
"start",
",",
"int",
"end",
")",
"{",
"return",
"findAll",
"(",
"start",
",",
"end",
",",
"null",
")",
";",
"}"
] | Returns a range of all the commerce tax methods.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CommerceTaxMethodModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param start the lower bound of the range of commerce tax methods
@param end the upper bound of the range of commerce tax methods (not inclusive)
@return the range of commerce tax methods | [
"Returns",
"a",
"range",
"of",
"all",
"the",
"commerce",
"tax",
"methods",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-tax-service/src/main/java/com/liferay/commerce/tax/service/persistence/impl/CommerceTaxMethodPersistenceImpl.java#L2005-L2008 |
Azure/azure-sdk-for-java | containerregistry/resource-manager/v2018_09_01/src/main/java/com/microsoft/azure/management/containerregistry/v2018_09_01/implementation/TasksInner.java | TasksInner.createAsync | public Observable<TaskInner> createAsync(String resourceGroupName, String registryName, String taskName, TaskInner taskCreateParameters) {
"""
Creates a task for a container registry with the specified parameters.
@param resourceGroupName The name of the resource group to which the container registry belongs.
@param registryName The name of the container registry.
@param taskName The name of the container registry task.
@param taskCreateParameters The parameters for creating a task.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request
"""
return createWithServiceResponseAsync(resourceGroupName, registryName, taskName, taskCreateParameters).map(new Func1<ServiceResponse<TaskInner>, TaskInner>() {
@Override
public TaskInner call(ServiceResponse<TaskInner> response) {
return response.body();
}
});
} | java | public Observable<TaskInner> createAsync(String resourceGroupName, String registryName, String taskName, TaskInner taskCreateParameters) {
return createWithServiceResponseAsync(resourceGroupName, registryName, taskName, taskCreateParameters).map(new Func1<ServiceResponse<TaskInner>, TaskInner>() {
@Override
public TaskInner call(ServiceResponse<TaskInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"TaskInner",
">",
"createAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"registryName",
",",
"String",
"taskName",
",",
"TaskInner",
"taskCreateParameters",
")",
"{",
"return",
"createWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"registryName",
",",
"taskName",
",",
"taskCreateParameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"TaskInner",
">",
",",
"TaskInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"TaskInner",
"call",
"(",
"ServiceResponse",
"<",
"TaskInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Creates a task for a container registry with the specified parameters.
@param resourceGroupName The name of the resource group to which the container registry belongs.
@param registryName The name of the container registry.
@param taskName The name of the container registry task.
@param taskCreateParameters The parameters for creating a task.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Creates",
"a",
"task",
"for",
"a",
"container",
"registry",
"with",
"the",
"specified",
"parameters",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/containerregistry/resource-manager/v2018_09_01/src/main/java/com/microsoft/azure/management/containerregistry/v2018_09_01/implementation/TasksInner.java#L362-L369 |
getlantern/kaleidoscope | src/main/java/org/kaleidoscope/LocalTrustGraph.java | LocalTrustGraph.addRoute | public void addRoute(final LocalTrustGraphNode a, final LocalTrustGraphNode b) {
"""
add bidirectioanl trust graph links between two nodes.
@param a node that will form a trust link with 'b'
@param b node that will form a trust link with 'a'
"""
addDirectedRoute(a,b);
addDirectedRoute(b,a);
} | java | public void addRoute(final LocalTrustGraphNode a, final LocalTrustGraphNode b) {
addDirectedRoute(a,b);
addDirectedRoute(b,a);
} | [
"public",
"void",
"addRoute",
"(",
"final",
"LocalTrustGraphNode",
"a",
",",
"final",
"LocalTrustGraphNode",
"b",
")",
"{",
"addDirectedRoute",
"(",
"a",
",",
"b",
")",
";",
"addDirectedRoute",
"(",
"b",
",",
"a",
")",
";",
"}"
] | add bidirectioanl trust graph links between two nodes.
@param a node that will form a trust link with 'b'
@param b node that will form a trust link with 'a' | [
"add",
"bidirectioanl",
"trust",
"graph",
"links",
"between",
"two",
"nodes",
"."
] | train | https://github.com/getlantern/kaleidoscope/blob/7516f05724c8f54e5d535d23da9116817c08a09f/src/main/java/org/kaleidoscope/LocalTrustGraph.java#L271-L274 |
powermock/powermock | powermock-reflect/src/main/java/org/powermock/reflect/internal/WhiteboxImpl.java | WhiteboxImpl.setInternalState | public static void setInternalState(Object object, Object value, Object... additionalValues) {
"""
Set the value of a field using reflection. This method will traverse the
super class hierarchy until the first field assignable to the
<tt>value</tt> type is found. The <tt>value</tt> (or
<tt>additionaValues</tt> if present) will then be assigned to this field.
@param object the object to modify
@param value the new value of the field
@param additionalValues Additional values to set on the object
"""
setField(object, value,
findFieldInHierarchy(object, new AssignableFromFieldTypeMatcherStrategy(getType(value))));
if (additionalValues != null && additionalValues.length > 0) {
for (Object additionalValue : additionalValues) {
setField(
object,
additionalValue,
findFieldInHierarchy(object, new AssignableFromFieldTypeMatcherStrategy(
getType(additionalValue))));
}
}
} | java | public static void setInternalState(Object object, Object value, Object... additionalValues) {
setField(object, value,
findFieldInHierarchy(object, new AssignableFromFieldTypeMatcherStrategy(getType(value))));
if (additionalValues != null && additionalValues.length > 0) {
for (Object additionalValue : additionalValues) {
setField(
object,
additionalValue,
findFieldInHierarchy(object, new AssignableFromFieldTypeMatcherStrategy(
getType(additionalValue))));
}
}
} | [
"public",
"static",
"void",
"setInternalState",
"(",
"Object",
"object",
",",
"Object",
"value",
",",
"Object",
"...",
"additionalValues",
")",
"{",
"setField",
"(",
"object",
",",
"value",
",",
"findFieldInHierarchy",
"(",
"object",
",",
"new",
"AssignableFromFieldTypeMatcherStrategy",
"(",
"getType",
"(",
"value",
")",
")",
")",
")",
";",
"if",
"(",
"additionalValues",
"!=",
"null",
"&&",
"additionalValues",
".",
"length",
">",
"0",
")",
"{",
"for",
"(",
"Object",
"additionalValue",
":",
"additionalValues",
")",
"{",
"setField",
"(",
"object",
",",
"additionalValue",
",",
"findFieldInHierarchy",
"(",
"object",
",",
"new",
"AssignableFromFieldTypeMatcherStrategy",
"(",
"getType",
"(",
"additionalValue",
")",
")",
")",
")",
";",
"}",
"}",
"}"
] | Set the value of a field using reflection. This method will traverse the
super class hierarchy until the first field assignable to the
<tt>value</tt> type is found. The <tt>value</tt> (or
<tt>additionaValues</tt> if present) will then be assigned to this field.
@param object the object to modify
@param value the new value of the field
@param additionalValues Additional values to set on the object | [
"Set",
"the",
"value",
"of",
"a",
"field",
"using",
"reflection",
".",
"This",
"method",
"will",
"traverse",
"the",
"super",
"class",
"hierarchy",
"until",
"the",
"first",
"field",
"assignable",
"to",
"the",
"<tt",
">",
"value<",
"/",
"tt",
">",
"type",
"is",
"found",
".",
"The",
"<tt",
">",
"value<",
"/",
"tt",
">",
"(",
"or",
"<tt",
">",
"additionaValues<",
"/",
"tt",
">",
"if",
"present",
")",
"will",
"then",
"be",
"assigned",
"to",
"this",
"field",
"."
] | train | https://github.com/powermock/powermock/blob/e8cd68026c284c6a7efe66959809eeebd8d1f9ad/powermock-reflect/src/main/java/org/powermock/reflect/internal/WhiteboxImpl.java#L343-L355 |
exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java | RepositoryImpl.internalLogin | SessionImpl internalLogin(ConversationState state, String workspaceName) throws LoginException,
NoSuchWorkspaceException, RepositoryException {
"""
Internal login.
@param state ConversationState
@param workspaceName workspace name
@return SessionImpl
@throws LoginException error of logic
@throws NoSuchWorkspaceException if no workspace found with name
@throws RepositoryException Repository error
"""
if (workspaceName == null)
{
workspaceName = config.getDefaultWorkspaceName();
if (workspaceName == null)
{
throw new NoSuchWorkspaceException("Both workspace and default-workspace name are null! ");
}
}
if (!isWorkspaceInitialized(workspaceName))
{
throw new NoSuchWorkspaceException("Workspace '" + workspaceName + "' not found. "
+ "Probably is not initialized. If so either Initialize it manually or turn on the RepositoryInitializer");
}
SessionFactory sessionFactory = repositoryContainer.getWorkspaceContainer(workspaceName).getSessionFactory();
return sessionFactory.createSession(state);
} | java | SessionImpl internalLogin(ConversationState state, String workspaceName) throws LoginException,
NoSuchWorkspaceException, RepositoryException
{
if (workspaceName == null)
{
workspaceName = config.getDefaultWorkspaceName();
if (workspaceName == null)
{
throw new NoSuchWorkspaceException("Both workspace and default-workspace name are null! ");
}
}
if (!isWorkspaceInitialized(workspaceName))
{
throw new NoSuchWorkspaceException("Workspace '" + workspaceName + "' not found. "
+ "Probably is not initialized. If so either Initialize it manually or turn on the RepositoryInitializer");
}
SessionFactory sessionFactory = repositoryContainer.getWorkspaceContainer(workspaceName).getSessionFactory();
return sessionFactory.createSession(state);
} | [
"SessionImpl",
"internalLogin",
"(",
"ConversationState",
"state",
",",
"String",
"workspaceName",
")",
"throws",
"LoginException",
",",
"NoSuchWorkspaceException",
",",
"RepositoryException",
"{",
"if",
"(",
"workspaceName",
"==",
"null",
")",
"{",
"workspaceName",
"=",
"config",
".",
"getDefaultWorkspaceName",
"(",
")",
";",
"if",
"(",
"workspaceName",
"==",
"null",
")",
"{",
"throw",
"new",
"NoSuchWorkspaceException",
"(",
"\"Both workspace and default-workspace name are null! \"",
")",
";",
"}",
"}",
"if",
"(",
"!",
"isWorkspaceInitialized",
"(",
"workspaceName",
")",
")",
"{",
"throw",
"new",
"NoSuchWorkspaceException",
"(",
"\"Workspace '\"",
"+",
"workspaceName",
"+",
"\"' not found. \"",
"+",
"\"Probably is not initialized. If so either Initialize it manually or turn on the RepositoryInitializer\"",
")",
";",
"}",
"SessionFactory",
"sessionFactory",
"=",
"repositoryContainer",
".",
"getWorkspaceContainer",
"(",
"workspaceName",
")",
".",
"getSessionFactory",
"(",
")",
";",
"return",
"sessionFactory",
".",
"createSession",
"(",
"state",
")",
";",
"}"
] | Internal login.
@param state ConversationState
@param workspaceName workspace name
@return SessionImpl
@throws LoginException error of logic
@throws NoSuchWorkspaceException if no workspace found with name
@throws RepositoryException Repository error | [
"Internal",
"login",
"."
] | train | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java#L684-L705 |
foundation-runtime/service-directory | 1.2/sd-api/src/main/java/com/cisco/oss/foundation/directory/lookup/LookupManagerImpl.java | LookupManagerImpl.removeNotificationHandler | @Override
public void removeNotificationHandler(String serviceName, NotificationHandler handler) throws ServiceException {
"""
Remove the NotificationHandler from the Service.
@param serviceName
the service name.
@param handler
the NotificationHandler for the service.
@deprecated
"""
ServiceInstanceUtils.validateManagerIsStarted(isStarted.get());
ServiceInstanceUtils.validateServiceName(serviceName);
if (handler == null) {
throw new ServiceException(ErrorCode.SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR,
ErrorCode.SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR.getMessageTemplate(),
"NotificationHandler");
}
getLookupService().removeNotificationHandler(serviceName, handler);
} | java | @Override
public void removeNotificationHandler(String serviceName, NotificationHandler handler) throws ServiceException {
ServiceInstanceUtils.validateManagerIsStarted(isStarted.get());
ServiceInstanceUtils.validateServiceName(serviceName);
if (handler == null) {
throw new ServiceException(ErrorCode.SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR,
ErrorCode.SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR.getMessageTemplate(),
"NotificationHandler");
}
getLookupService().removeNotificationHandler(serviceName, handler);
} | [
"@",
"Override",
"public",
"void",
"removeNotificationHandler",
"(",
"String",
"serviceName",
",",
"NotificationHandler",
"handler",
")",
"throws",
"ServiceException",
"{",
"ServiceInstanceUtils",
".",
"validateManagerIsStarted",
"(",
"isStarted",
".",
"get",
"(",
")",
")",
";",
"ServiceInstanceUtils",
".",
"validateServiceName",
"(",
"serviceName",
")",
";",
"if",
"(",
"handler",
"==",
"null",
")",
"{",
"throw",
"new",
"ServiceException",
"(",
"ErrorCode",
".",
"SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR",
",",
"ErrorCode",
".",
"SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR",
".",
"getMessageTemplate",
"(",
")",
",",
"\"NotificationHandler\"",
")",
";",
"}",
"getLookupService",
"(",
")",
".",
"removeNotificationHandler",
"(",
"serviceName",
",",
"handler",
")",
";",
"}"
] | Remove the NotificationHandler from the Service.
@param serviceName
the service name.
@param handler
the NotificationHandler for the service.
@deprecated | [
"Remove",
"the",
"NotificationHandler",
"from",
"the",
"Service",
"."
] | train | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.2/sd-api/src/main/java/com/cisco/oss/foundation/directory/lookup/LookupManagerImpl.java#L385-L397 |
Tourenathan-G5organisation/SiliCompressor | silicompressor/src/main/java/com/iceteck/silicompressorr/SiliCompressor.java | SiliCompressor.getCompressBitmap | public Bitmap getCompressBitmap(String imagePath, boolean deleteSourceImage) throws IOException {
"""
Compress the image at with the specified path and return the bitmap data of the compressed image.
@param imagePath The path of the image file you wish to compress.
@param deleteSourceImage If True will delete the source file
@return Compress image bitmap
@throws IOException
"""
File imageFile = new File(compressImage(imagePath, new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "Silicompressor/images")));
Uri newImageUri = FileProvider.getUriForFile(mContext, FILE_PROVIDER_AUTHORITY, imageFile);
Bitmap bitmap = MediaStore.Images.Media.getBitmap(mContext.getContentResolver(), newImageUri);
if (deleteSourceImage) {
boolean isdeleted = deleteImageFile(imagePath);
Log.d(LOG_TAG, (isdeleted) ? "Source image file deleted" : "Error: Source image file not deleted.");
}
// Delete the file created during the image compression
deleteImageFile(imageFile.getAbsolutePath());
// Return the required bitmap
return bitmap;
} | java | public Bitmap getCompressBitmap(String imagePath, boolean deleteSourceImage) throws IOException {
File imageFile = new File(compressImage(imagePath, new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "Silicompressor/images")));
Uri newImageUri = FileProvider.getUriForFile(mContext, FILE_PROVIDER_AUTHORITY, imageFile);
Bitmap bitmap = MediaStore.Images.Media.getBitmap(mContext.getContentResolver(), newImageUri);
if (deleteSourceImage) {
boolean isdeleted = deleteImageFile(imagePath);
Log.d(LOG_TAG, (isdeleted) ? "Source image file deleted" : "Error: Source image file not deleted.");
}
// Delete the file created during the image compression
deleteImageFile(imageFile.getAbsolutePath());
// Return the required bitmap
return bitmap;
} | [
"public",
"Bitmap",
"getCompressBitmap",
"(",
"String",
"imagePath",
",",
"boolean",
"deleteSourceImage",
")",
"throws",
"IOException",
"{",
"File",
"imageFile",
"=",
"new",
"File",
"(",
"compressImage",
"(",
"imagePath",
",",
"new",
"File",
"(",
"Environment",
".",
"getExternalStoragePublicDirectory",
"(",
"Environment",
".",
"DIRECTORY_PICTURES",
")",
",",
"\"Silicompressor/images\"",
")",
")",
")",
";",
"Uri",
"newImageUri",
"=",
"FileProvider",
".",
"getUriForFile",
"(",
"mContext",
",",
"FILE_PROVIDER_AUTHORITY",
",",
"imageFile",
")",
";",
"Bitmap",
"bitmap",
"=",
"MediaStore",
".",
"Images",
".",
"Media",
".",
"getBitmap",
"(",
"mContext",
".",
"getContentResolver",
"(",
")",
",",
"newImageUri",
")",
";",
"if",
"(",
"deleteSourceImage",
")",
"{",
"boolean",
"isdeleted",
"=",
"deleteImageFile",
"(",
"imagePath",
")",
";",
"Log",
".",
"d",
"(",
"LOG_TAG",
",",
"(",
"isdeleted",
")",
"?",
"\"Source image file deleted\"",
":",
"\"Error: Source image file not deleted.\"",
")",
";",
"}",
"// Delete the file created during the image compression",
"deleteImageFile",
"(",
"imageFile",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"// Return the required bitmap",
"return",
"bitmap",
";",
"}"
] | Compress the image at with the specified path and return the bitmap data of the compressed image.
@param imagePath The path of the image file you wish to compress.
@param deleteSourceImage If True will delete the source file
@return Compress image bitmap
@throws IOException | [
"Compress",
"the",
"image",
"at",
"with",
"the",
"specified",
"path",
"and",
"return",
"the",
"bitmap",
"data",
"of",
"the",
"compressed",
"image",
"."
] | train | https://github.com/Tourenathan-G5organisation/SiliCompressor/blob/546f6cd7b2a7a783e1122df46c1e237f8938fe72/silicompressor/src/main/java/com/iceteck/silicompressorr/SiliCompressor.java#L161-L178 |
BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WDataTableRenderer.java | WDataTableRenderer.doPaintRows | private void doPaintRows(final WDataTable table, final WebXmlRenderContext renderContext) {
"""
Override paintRow so that we only paint the first-level nodes for tree-tables.
@param table the table to paint the rows for.
@param renderContext the RenderContext to paint to.
"""
TableDataModel model = table.getDataModel();
WRepeater repeater = table.getRepeater();
List<?> beanList = repeater.getBeanList();
final int rowCount = beanList.size();
WComponent row = repeater.getRepeatedComponent();
for (int i = 0; i < rowCount; i++) {
if (model instanceof TreeTableDataModel) {
Integer nodeIdx = (Integer) beanList.get(i);
TableTreeNode node = ((TreeTableDataModel) model).getNodeAtLine(nodeIdx);
if (node.getLevel() != 1) {
// Handled by the layout, so don't paint the row.
continue;
}
}
// Each row has its own context. This is why we can reuse the same
// WComponent instance for each row.
UIContext rowContext = repeater.getRowContext(beanList.get(i), i);
UIContextHolder.pushContext(rowContext);
try {
row.paint(renderContext);
} finally {
UIContextHolder.popContext();
}
}
} | java | private void doPaintRows(final WDataTable table, final WebXmlRenderContext renderContext) {
TableDataModel model = table.getDataModel();
WRepeater repeater = table.getRepeater();
List<?> beanList = repeater.getBeanList();
final int rowCount = beanList.size();
WComponent row = repeater.getRepeatedComponent();
for (int i = 0; i < rowCount; i++) {
if (model instanceof TreeTableDataModel) {
Integer nodeIdx = (Integer) beanList.get(i);
TableTreeNode node = ((TreeTableDataModel) model).getNodeAtLine(nodeIdx);
if (node.getLevel() != 1) {
// Handled by the layout, so don't paint the row.
continue;
}
}
// Each row has its own context. This is why we can reuse the same
// WComponent instance for each row.
UIContext rowContext = repeater.getRowContext(beanList.get(i), i);
UIContextHolder.pushContext(rowContext);
try {
row.paint(renderContext);
} finally {
UIContextHolder.popContext();
}
}
} | [
"private",
"void",
"doPaintRows",
"(",
"final",
"WDataTable",
"table",
",",
"final",
"WebXmlRenderContext",
"renderContext",
")",
"{",
"TableDataModel",
"model",
"=",
"table",
".",
"getDataModel",
"(",
")",
";",
"WRepeater",
"repeater",
"=",
"table",
".",
"getRepeater",
"(",
")",
";",
"List",
"<",
"?",
">",
"beanList",
"=",
"repeater",
".",
"getBeanList",
"(",
")",
";",
"final",
"int",
"rowCount",
"=",
"beanList",
".",
"size",
"(",
")",
";",
"WComponent",
"row",
"=",
"repeater",
".",
"getRepeatedComponent",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"rowCount",
";",
"i",
"++",
")",
"{",
"if",
"(",
"model",
"instanceof",
"TreeTableDataModel",
")",
"{",
"Integer",
"nodeIdx",
"=",
"(",
"Integer",
")",
"beanList",
".",
"get",
"(",
"i",
")",
";",
"TableTreeNode",
"node",
"=",
"(",
"(",
"TreeTableDataModel",
")",
"model",
")",
".",
"getNodeAtLine",
"(",
"nodeIdx",
")",
";",
"if",
"(",
"node",
".",
"getLevel",
"(",
")",
"!=",
"1",
")",
"{",
"// Handled by the layout, so don't paint the row.",
"continue",
";",
"}",
"}",
"// Each row has its own context. This is why we can reuse the same",
"// WComponent instance for each row.",
"UIContext",
"rowContext",
"=",
"repeater",
".",
"getRowContext",
"(",
"beanList",
".",
"get",
"(",
"i",
")",
",",
"i",
")",
";",
"UIContextHolder",
".",
"pushContext",
"(",
"rowContext",
")",
";",
"try",
"{",
"row",
".",
"paint",
"(",
"renderContext",
")",
";",
"}",
"finally",
"{",
"UIContextHolder",
".",
"popContext",
"(",
")",
";",
"}",
"}",
"}"
] | Override paintRow so that we only paint the first-level nodes for tree-tables.
@param table the table to paint the rows for.
@param renderContext the RenderContext to paint to. | [
"Override",
"paintRow",
"so",
"that",
"we",
"only",
"paint",
"the",
"first",
"-",
"level",
"nodes",
"for",
"tree",
"-",
"tables",
"."
] | train | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WDataTableRenderer.java#L332-L362 |
Azure/azure-sdk-for-java | kusto/resource-manager/v2018_09_07_preview/src/main/java/com/microsoft/azure/management/kusto/v2018_09_07_preview/implementation/ClustersInner.java | ClustersInner.beginUpdate | public ClusterInner beginUpdate(String resourceGroupName, String clusterName, ClusterUpdate parameters) {
"""
Update a Kusto cluster.
@param resourceGroupName The name of the resource group containing the Kusto cluster.
@param clusterName The name of the Kusto cluster.
@param parameters The Kusto cluster parameters supplied to the Update operation.
@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 ClusterInner object if successful.
"""
return beginUpdateWithServiceResponseAsync(resourceGroupName, clusterName, parameters).toBlocking().single().body();
} | java | public ClusterInner beginUpdate(String resourceGroupName, String clusterName, ClusterUpdate parameters) {
return beginUpdateWithServiceResponseAsync(resourceGroupName, clusterName, parameters).toBlocking().single().body();
} | [
"public",
"ClusterInner",
"beginUpdate",
"(",
"String",
"resourceGroupName",
",",
"String",
"clusterName",
",",
"ClusterUpdate",
"parameters",
")",
"{",
"return",
"beginUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"clusterName",
",",
"parameters",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Update a Kusto cluster.
@param resourceGroupName The name of the resource group containing the Kusto cluster.
@param clusterName The name of the Kusto cluster.
@param parameters The Kusto cluster parameters supplied to the Update operation.
@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 ClusterInner object if successful. | [
"Update",
"a",
"Kusto",
"cluster",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/kusto/resource-manager/v2018_09_07_preview/src/main/java/com/microsoft/azure/management/kusto/v2018_09_07_preview/implementation/ClustersInner.java#L480-L482 |
eduarddrenth/ConfigurableReports | src/main/java/com/vectorprint/report/itext/EventHelper.java | EventHelper.printFailureHeader | protected void printFailureHeader(PdfTemplate template, float x, float y) {
"""
when failure information is appended to the report, a header on each page will be printed refering to this
information.
@param template
@param x
@param y
"""
Font f = DebugHelper.debugFontLink(template, getSettings());
Chunk c = new Chunk(getSettings().getProperty("failures in report, see end of report", "failureheader"), f);
ColumnText.showTextAligned(template, Element.ALIGN_LEFT, new Phrase(c), x, y, 0);
} | java | protected void printFailureHeader(PdfTemplate template, float x, float y) {
Font f = DebugHelper.debugFontLink(template, getSettings());
Chunk c = new Chunk(getSettings().getProperty("failures in report, see end of report", "failureheader"), f);
ColumnText.showTextAligned(template, Element.ALIGN_LEFT, new Phrase(c), x, y, 0);
} | [
"protected",
"void",
"printFailureHeader",
"(",
"PdfTemplate",
"template",
",",
"float",
"x",
",",
"float",
"y",
")",
"{",
"Font",
"f",
"=",
"DebugHelper",
".",
"debugFontLink",
"(",
"template",
",",
"getSettings",
"(",
")",
")",
";",
"Chunk",
"c",
"=",
"new",
"Chunk",
"(",
"getSettings",
"(",
")",
".",
"getProperty",
"(",
"\"failures in report, see end of report\"",
",",
"\"failureheader\"",
")",
",",
"f",
")",
";",
"ColumnText",
".",
"showTextAligned",
"(",
"template",
",",
"Element",
".",
"ALIGN_LEFT",
",",
"new",
"Phrase",
"(",
"c",
")",
",",
"x",
",",
"y",
",",
"0",
")",
";",
"}"
] | when failure information is appended to the report, a header on each page will be printed refering to this
information.
@param template
@param x
@param y | [
"when",
"failure",
"information",
"is",
"appended",
"to",
"the",
"report",
"a",
"header",
"on",
"each",
"page",
"will",
"be",
"printed",
"refering",
"to",
"this",
"information",
"."
] | train | https://github.com/eduarddrenth/ConfigurableReports/blob/b5fb7a89e16d9b35f557f3bf620594f821fa1552/src/main/java/com/vectorprint/report/itext/EventHelper.java#L242-L246 |
netscaler/nitro | src/main/java/com/citrix/netscaler/nitro/resource/config/aaa/aaapreauthenticationpolicy_binding.java | aaapreauthenticationpolicy_binding.get | public static aaapreauthenticationpolicy_binding get(nitro_service service, String name) throws Exception {
"""
Use this API to fetch aaapreauthenticationpolicy_binding resource of given name .
"""
aaapreauthenticationpolicy_binding obj = new aaapreauthenticationpolicy_binding();
obj.set_name(name);
aaapreauthenticationpolicy_binding response = (aaapreauthenticationpolicy_binding) obj.get_resource(service);
return response;
} | java | public static aaapreauthenticationpolicy_binding get(nitro_service service, String name) throws Exception{
aaapreauthenticationpolicy_binding obj = new aaapreauthenticationpolicy_binding();
obj.set_name(name);
aaapreauthenticationpolicy_binding response = (aaapreauthenticationpolicy_binding) obj.get_resource(service);
return response;
} | [
"public",
"static",
"aaapreauthenticationpolicy_binding",
"get",
"(",
"nitro_service",
"service",
",",
"String",
"name",
")",
"throws",
"Exception",
"{",
"aaapreauthenticationpolicy_binding",
"obj",
"=",
"new",
"aaapreauthenticationpolicy_binding",
"(",
")",
";",
"obj",
".",
"set_name",
"(",
"name",
")",
";",
"aaapreauthenticationpolicy_binding",
"response",
"=",
"(",
"aaapreauthenticationpolicy_binding",
")",
"obj",
".",
"get_resource",
"(",
"service",
")",
";",
"return",
"response",
";",
"}"
] | Use this API to fetch aaapreauthenticationpolicy_binding resource of given name . | [
"Use",
"this",
"API",
"to",
"fetch",
"aaapreauthenticationpolicy_binding",
"resource",
"of",
"given",
"name",
"."
] | train | https://github.com/netscaler/nitro/blob/2a98692dcf4e4ec430c7d7baab8382e4ba5a35e4/src/main/java/com/citrix/netscaler/nitro/resource/config/aaa/aaapreauthenticationpolicy_binding.java#L114-L119 |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedClient.java | MemcachedClient.getVersions | @Override
public Map<SocketAddress, String> getVersions() {
"""
Get the versions of all of the connected memcacheds.
@return a Map of SocketAddress to String for connected servers
@throws IllegalStateException in the rare circumstance where queue is too
full to accept any more requests
"""
final Map<SocketAddress, String> rv =
new ConcurrentHashMap<SocketAddress, String>();
CountDownLatch blatch = broadcastOp(new BroadcastOpFactory() {
@Override
public Operation newOp(final MemcachedNode n,
final CountDownLatch latch) {
final SocketAddress sa = n.getSocketAddress();
return opFact.version(new OperationCallback() {
@Override
public void receivedStatus(OperationStatus s) {
rv.put(sa, s.getMessage());
}
@Override
public void complete() {
latch.countDown();
}
});
}
});
try {
blatch.await(operationTimeout, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
throw new RuntimeException("Interrupted waiting for versions", e);
}
return rv;
} | java | @Override
public Map<SocketAddress, String> getVersions() {
final Map<SocketAddress, String> rv =
new ConcurrentHashMap<SocketAddress, String>();
CountDownLatch blatch = broadcastOp(new BroadcastOpFactory() {
@Override
public Operation newOp(final MemcachedNode n,
final CountDownLatch latch) {
final SocketAddress sa = n.getSocketAddress();
return opFact.version(new OperationCallback() {
@Override
public void receivedStatus(OperationStatus s) {
rv.put(sa, s.getMessage());
}
@Override
public void complete() {
latch.countDown();
}
});
}
});
try {
blatch.await(operationTimeout, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
throw new RuntimeException("Interrupted waiting for versions", e);
}
return rv;
} | [
"@",
"Override",
"public",
"Map",
"<",
"SocketAddress",
",",
"String",
">",
"getVersions",
"(",
")",
"{",
"final",
"Map",
"<",
"SocketAddress",
",",
"String",
">",
"rv",
"=",
"new",
"ConcurrentHashMap",
"<",
"SocketAddress",
",",
"String",
">",
"(",
")",
";",
"CountDownLatch",
"blatch",
"=",
"broadcastOp",
"(",
"new",
"BroadcastOpFactory",
"(",
")",
"{",
"@",
"Override",
"public",
"Operation",
"newOp",
"(",
"final",
"MemcachedNode",
"n",
",",
"final",
"CountDownLatch",
"latch",
")",
"{",
"final",
"SocketAddress",
"sa",
"=",
"n",
".",
"getSocketAddress",
"(",
")",
";",
"return",
"opFact",
".",
"version",
"(",
"new",
"OperationCallback",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"receivedStatus",
"(",
"OperationStatus",
"s",
")",
"{",
"rv",
".",
"put",
"(",
"sa",
",",
"s",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"complete",
"(",
")",
"{",
"latch",
".",
"countDown",
"(",
")",
";",
"}",
"}",
")",
";",
"}",
"}",
")",
";",
"try",
"{",
"blatch",
".",
"await",
"(",
"operationTimeout",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Interrupted waiting for versions\"",
",",
"e",
")",
";",
"}",
"return",
"rv",
";",
"}"
] | Get the versions of all of the connected memcacheds.
@return a Map of SocketAddress to String for connected servers
@throws IllegalStateException in the rare circumstance where queue is too
full to accept any more requests | [
"Get",
"the",
"versions",
"of",
"all",
"of",
"the",
"connected",
"memcacheds",
"."
] | train | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedClient.java#L1658-L1687 |
liferay/com-liferay-commerce | commerce-service/src/main/java/com/liferay/commerce/service/persistence/impl/CommerceAddressPersistenceImpl.java | CommerceAddressPersistenceImpl.findByCommerceCountryId | @Override
public List<CommerceAddress> findByCommerceCountryId(
long commerceCountryId, int start, int end) {
"""
Returns a range of all the commerce addresses where commerceCountryId = ?.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CommerceAddressModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param commerceCountryId the commerce country ID
@param start the lower bound of the range of commerce addresses
@param end the upper bound of the range of commerce addresses (not inclusive)
@return the range of matching commerce addresses
"""
return findByCommerceCountryId(commerceCountryId, start, end, null);
} | java | @Override
public List<CommerceAddress> findByCommerceCountryId(
long commerceCountryId, int start, int end) {
return findByCommerceCountryId(commerceCountryId, start, end, null);
} | [
"@",
"Override",
"public",
"List",
"<",
"CommerceAddress",
">",
"findByCommerceCountryId",
"(",
"long",
"commerceCountryId",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"return",
"findByCommerceCountryId",
"(",
"commerceCountryId",
",",
"start",
",",
"end",
",",
"null",
")",
";",
"}"
] | Returns a range of all the commerce addresses where commerceCountryId = ?.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CommerceAddressModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param commerceCountryId the commerce country ID
@param start the lower bound of the range of commerce addresses
@param end the upper bound of the range of commerce addresses (not inclusive)
@return the range of matching commerce addresses | [
"Returns",
"a",
"range",
"of",
"all",
"the",
"commerce",
"addresses",
"where",
"commerceCountryId",
"=",
"?",
";",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-service/src/main/java/com/liferay/commerce/service/persistence/impl/CommerceAddressPersistenceImpl.java#L660-L664 |
ManfredTremmel/gwt-commons-lang3 | src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java | ReflectionToStringBuilder.toStringExclude | public static String toStringExclude(final Object object, final Collection<String> excludeFieldNames) {
"""
Builds a String for a toString method excluding the given field names.
@param object
The object to "toString".
@param excludeFieldNames
The field names to exclude. Null excludes nothing.
@return The toString value.
"""
return toStringExclude(object, toNoNullStringArray(excludeFieldNames));
} | java | public static String toStringExclude(final Object object, final Collection<String> excludeFieldNames) {
return toStringExclude(object, toNoNullStringArray(excludeFieldNames));
} | [
"public",
"static",
"String",
"toStringExclude",
"(",
"final",
"Object",
"object",
",",
"final",
"Collection",
"<",
"String",
">",
"excludeFieldNames",
")",
"{",
"return",
"toStringExclude",
"(",
"object",
",",
"toNoNullStringArray",
"(",
"excludeFieldNames",
")",
")",
";",
"}"
] | Builds a String for a toString method excluding the given field names.
@param object
The object to "toString".
@param excludeFieldNames
The field names to exclude. Null excludes nothing.
@return The toString value. | [
"Builds",
"a",
"String",
"for",
"a",
"toString",
"method",
"excluding",
"the",
"given",
"field",
"names",
"."
] | train | https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java#L375-L377 |
glyptodon/guacamole-client | extensions/guacamole-auth-totp/src/main/java/org/apache/guacamole/totp/TOTPGenerator.java | TOTPGenerator.getMacInstance | private static Mac getMacInstance(Mode mode, Key key)
throws InvalidKeyException {
"""
Returns a new Mac instance which produces message authentication codes
using the given secret key and the algorithm required by the given TOTP
mode.
@param mode
The TOTP mode which dictates the HMAC algorithm to be used.
@param key
The secret key to use to produce message authentication codes.
@return
A new Mac instance which produces message authentication codes
using the given secret key and the algorithm required by the given
TOTP mode.
@throws InvalidKeyException
If the provided key is invalid for the requested TOTP mode.
"""
try {
Mac hmac = Mac.getInstance(mode.getAlgorithmName());
hmac.init(key);
return hmac;
}
catch (NoSuchAlgorithmException e) {
throw new UnsupportedOperationException("Support for the HMAC "
+ "algorithm required for TOTP in " + mode + " mode is "
+ "missing.", e);
}
} | java | private static Mac getMacInstance(Mode mode, Key key)
throws InvalidKeyException {
try {
Mac hmac = Mac.getInstance(mode.getAlgorithmName());
hmac.init(key);
return hmac;
}
catch (NoSuchAlgorithmException e) {
throw new UnsupportedOperationException("Support for the HMAC "
+ "algorithm required for TOTP in " + mode + " mode is "
+ "missing.", e);
}
} | [
"private",
"static",
"Mac",
"getMacInstance",
"(",
"Mode",
"mode",
",",
"Key",
"key",
")",
"throws",
"InvalidKeyException",
"{",
"try",
"{",
"Mac",
"hmac",
"=",
"Mac",
".",
"getInstance",
"(",
"mode",
".",
"getAlgorithmName",
"(",
")",
")",
";",
"hmac",
".",
"init",
"(",
"key",
")",
";",
"return",
"hmac",
";",
"}",
"catch",
"(",
"NoSuchAlgorithmException",
"e",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Support for the HMAC \"",
"+",
"\"algorithm required for TOTP in \"",
"+",
"mode",
"+",
"\" mode is \"",
"+",
"\"missing.\"",
",",
"e",
")",
";",
"}",
"}"
] | Returns a new Mac instance which produces message authentication codes
using the given secret key and the algorithm required by the given TOTP
mode.
@param mode
The TOTP mode which dictates the HMAC algorithm to be used.
@param key
The secret key to use to produce message authentication codes.
@return
A new Mac instance which produces message authentication codes
using the given secret key and the algorithm required by the given
TOTP mode.
@throws InvalidKeyException
If the provided key is invalid for the requested TOTP mode. | [
"Returns",
"a",
"new",
"Mac",
"instance",
"which",
"produces",
"message",
"authentication",
"codes",
"using",
"the",
"given",
"secret",
"key",
"and",
"the",
"algorithm",
"required",
"by",
"the",
"given",
"TOTP",
"mode",
"."
] | train | https://github.com/glyptodon/guacamole-client/blob/ea1b10e9d1e3f1fa640dff2ca64d61b44bf1ace9/extensions/guacamole-auth-totp/src/main/java/org/apache/guacamole/totp/TOTPGenerator.java#L298-L312 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.