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
|
---|---|---|---|---|---|---|---|---|---|---|
OpenBEL/openbel-framework | org.openbel.framework.common/src/main/java/org/openbel/framework/common/lang/Signature.java | Signature.matches | public SemanticStatus matches(final Signature other) {
"""
Returns the {@link SemanticStatus semantic status} of the supplied
signature against this one.
@param other {@link Signature}
@return SemanticStatus, which may be null
"""
if (other == null) return null;
// Check simple function/return types first
if (getFunction() != other.getFunction()) return INVALID_FUNCTION;
if (getReturnType() != other.getReturnType())
return INVALID_RETURN_TYPE;
String[] myargs = this.getArguments();
String[] otherargs = other.getArguments();
return argumentsMatch(myargs, otherargs);
} | java | public SemanticStatus matches(final Signature other) {
if (other == null) return null;
// Check simple function/return types first
if (getFunction() != other.getFunction()) return INVALID_FUNCTION;
if (getReturnType() != other.getReturnType())
return INVALID_RETURN_TYPE;
String[] myargs = this.getArguments();
String[] otherargs = other.getArguments();
return argumentsMatch(myargs, otherargs);
} | [
"public",
"SemanticStatus",
"matches",
"(",
"final",
"Signature",
"other",
")",
"{",
"if",
"(",
"other",
"==",
"null",
")",
"return",
"null",
";",
"// Check simple function/return types first",
"if",
"(",
"getFunction",
"(",
")",
"!=",
"other",
".",
"getFunction",
"(",
")",
")",
"return",
"INVALID_FUNCTION",
";",
"if",
"(",
"getReturnType",
"(",
")",
"!=",
"other",
".",
"getReturnType",
"(",
")",
")",
"return",
"INVALID_RETURN_TYPE",
";",
"String",
"[",
"]",
"myargs",
"=",
"this",
".",
"getArguments",
"(",
")",
";",
"String",
"[",
"]",
"otherargs",
"=",
"other",
".",
"getArguments",
"(",
")",
";",
"return",
"argumentsMatch",
"(",
"myargs",
",",
"otherargs",
")",
";",
"}"
] | Returns the {@link SemanticStatus semantic status} of the supplied
signature against this one.
@param other {@link Signature}
@return SemanticStatus, which may be null | [
"Returns",
"the",
"{",
"@link",
"SemanticStatus",
"semantic",
"status",
"}",
"of",
"the",
"supplied",
"signature",
"against",
"this",
"one",
"."
] | train | https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.common/src/main/java/org/openbel/framework/common/lang/Signature.java#L289-L301 |
likethecolor/Alchemy-API | src/main/java/com/likethecolor/alchemy/api/parser/json/AbstractParser.java | AbstractParser.getBoolean | protected Boolean getBoolean(final String key, final JSONObject jsonObject) {
"""
Check to make sure the JSONObject has the specified key and if so return
the value as a boolean. If no key is found null is returned.
If the value is not JSON boolean (true/false) then {@link #getNonStandardBoolean(String, JSONObject)}
is called.
@param key name of the field to fetch from the json object
@param jsonObject object from which to fetch the value
@return boolean value corresponding to the key or null if key not found
@see #getNonStandardBoolean(String, JSONObject)
"""
Boolean value = null;
if(hasKey(key, jsonObject)) {
try {
value = jsonObject.getBoolean(key);
}
catch(JSONException e) {
LOGGER.debug("Could not get boolean from JSONObject for key: " + key, e);
LOGGER.debug("Trying to get the truthy value");
value = getNonStandardBoolean(key, jsonObject);
}
}
return value;
} | java | protected Boolean getBoolean(final String key, final JSONObject jsonObject) {
Boolean value = null;
if(hasKey(key, jsonObject)) {
try {
value = jsonObject.getBoolean(key);
}
catch(JSONException e) {
LOGGER.debug("Could not get boolean from JSONObject for key: " + key, e);
LOGGER.debug("Trying to get the truthy value");
value = getNonStandardBoolean(key, jsonObject);
}
}
return value;
} | [
"protected",
"Boolean",
"getBoolean",
"(",
"final",
"String",
"key",
",",
"final",
"JSONObject",
"jsonObject",
")",
"{",
"Boolean",
"value",
"=",
"null",
";",
"if",
"(",
"hasKey",
"(",
"key",
",",
"jsonObject",
")",
")",
"{",
"try",
"{",
"value",
"=",
"jsonObject",
".",
"getBoolean",
"(",
"key",
")",
";",
"}",
"catch",
"(",
"JSONException",
"e",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Could not get boolean from JSONObject for key: \"",
"+",
"key",
",",
"e",
")",
";",
"LOGGER",
".",
"debug",
"(",
"\"Trying to get the truthy value\"",
")",
";",
"value",
"=",
"getNonStandardBoolean",
"(",
"key",
",",
"jsonObject",
")",
";",
"}",
"}",
"return",
"value",
";",
"}"
] | Check to make sure the JSONObject has the specified key and if so return
the value as a boolean. If no key is found null is returned.
If the value is not JSON boolean (true/false) then {@link #getNonStandardBoolean(String, JSONObject)}
is called.
@param key name of the field to fetch from the json object
@param jsonObject object from which to fetch the value
@return boolean value corresponding to the key or null if key not found
@see #getNonStandardBoolean(String, JSONObject) | [
"Check",
"to",
"make",
"sure",
"the",
"JSONObject",
"has",
"the",
"specified",
"key",
"and",
"if",
"so",
"return",
"the",
"value",
"as",
"a",
"boolean",
".",
"If",
"no",
"key",
"is",
"found",
"null",
"is",
"returned",
"."
] | train | https://github.com/likethecolor/Alchemy-API/blob/5208cfc92a878ceeaff052787af29da92d98db7e/src/main/java/com/likethecolor/alchemy/api/parser/json/AbstractParser.java#L80-L93 |
carewebframework/carewebframework-vista | org.carewebframework.vista.api-parent/org.carewebframework.vista.api.esig/src/main/java/org/carewebframework/vista/esig/ESigList.java | ESigList.indexOf | public int indexOf(IESigType eSigType, String id) {
"""
Returns the index of a sig item identified by type and id.
@param eSigType The esignature type.
@param id The item id.
@return Index of item.
"""
return items.indexOf(new ESigItem(eSigType, id));
} | java | public int indexOf(IESigType eSigType, String id) {
return items.indexOf(new ESigItem(eSigType, id));
} | [
"public",
"int",
"indexOf",
"(",
"IESigType",
"eSigType",
",",
"String",
"id",
")",
"{",
"return",
"items",
".",
"indexOf",
"(",
"new",
"ESigItem",
"(",
"eSigType",
",",
"id",
")",
")",
";",
"}"
] | Returns the index of a sig item identified by type and id.
@param eSigType The esignature type.
@param id The item id.
@return Index of item. | [
"Returns",
"the",
"index",
"of",
"a",
"sig",
"item",
"identified",
"by",
"type",
"and",
"id",
"."
] | train | https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.api-parent/org.carewebframework.vista.api.esig/src/main/java/org/carewebframework/vista/esig/ESigList.java#L94-L96 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/VirtualNetworkGatewaysInner.java | VirtualNetworkGatewaysInner.beginGenerateVpnProfile | public String beginGenerateVpnProfile(String resourceGroupName, String virtualNetworkGatewayName, VpnClientParameters parameters) {
"""
Generates VPN profile for P2S client of the virtual network gateway in the specified resource group. Used for IKEV2 and radius based authentication.
@param resourceGroupName The name of the resource group.
@param virtualNetworkGatewayName The name of the virtual network gateway.
@param parameters Parameters supplied to the generate virtual network gateway VPN client package 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 String object if successful.
"""
return beginGenerateVpnProfileWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayName, parameters).toBlocking().single().body();
} | java | public String beginGenerateVpnProfile(String resourceGroupName, String virtualNetworkGatewayName, VpnClientParameters parameters) {
return beginGenerateVpnProfileWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayName, parameters).toBlocking().single().body();
} | [
"public",
"String",
"beginGenerateVpnProfile",
"(",
"String",
"resourceGroupName",
",",
"String",
"virtualNetworkGatewayName",
",",
"VpnClientParameters",
"parameters",
")",
"{",
"return",
"beginGenerateVpnProfileWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"virtualNetworkGatewayName",
",",
"parameters",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Generates VPN profile for P2S client of the virtual network gateway in the specified resource group. Used for IKEV2 and radius based authentication.
@param resourceGroupName The name of the resource group.
@param virtualNetworkGatewayName The name of the virtual network gateway.
@param parameters Parameters supplied to the generate virtual network gateway VPN client package 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 String object if successful. | [
"Generates",
"VPN",
"profile",
"for",
"P2S",
"client",
"of",
"the",
"virtual",
"network",
"gateway",
"in",
"the",
"specified",
"resource",
"group",
".",
"Used",
"for",
"IKEV2",
"and",
"radius",
"based",
"authentication",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/VirtualNetworkGatewaysInner.java#L1707-L1709 |
xebia/Xebium | src/main/java/com/xebia/incubator/xebium/SeleniumDriverFixture.java | SeleniumDriverFixture.doOnWith | public boolean doOnWith(final String command, final String target, final String value) {
"""
<p><code>
| ensure | do | <i>type</i> | on | <i>searchString</i> | with | <i>some text</i> |
</code></p>
@param command
@param target
@param value
@return
"""
LOG.info("Performing | " + command + " | " + target + " | " + value + " |");
return executeDoCommand(command, new String[] { unalias(target), unalias(value) });
} | java | public boolean doOnWith(final String command, final String target, final String value) {
LOG.info("Performing | " + command + " | " + target + " | " + value + " |");
return executeDoCommand(command, new String[] { unalias(target), unalias(value) });
} | [
"public",
"boolean",
"doOnWith",
"(",
"final",
"String",
"command",
",",
"final",
"String",
"target",
",",
"final",
"String",
"value",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Performing | \"",
"+",
"command",
"+",
"\" | \"",
"+",
"target",
"+",
"\" | \"",
"+",
"value",
"+",
"\" |\"",
")",
";",
"return",
"executeDoCommand",
"(",
"command",
",",
"new",
"String",
"[",
"]",
"{",
"unalias",
"(",
"target",
")",
",",
"unalias",
"(",
"value",
")",
"}",
")",
";",
"}"
] | <p><code>
| ensure | do | <i>type</i> | on | <i>searchString</i> | with | <i>some text</i> |
</code></p>
@param command
@param target
@param value
@return | [
"<p",
">",
"<code",
">",
"|",
"ensure",
"|",
"do",
"|",
"<i",
">",
"type<",
"/",
"i",
">",
"|",
"on",
"|",
"<i",
">",
"searchString<",
"/",
"i",
">",
"|",
"with",
"|",
"<i",
">",
"some",
"text<",
"/",
"i",
">",
"|",
"<",
"/",
"code",
">",
"<",
"/",
"p",
">"
] | train | https://github.com/xebia/Xebium/blob/594f6d9e65622acdbd03dba0700b17645981da1f/src/main/java/com/xebia/incubator/xebium/SeleniumDriverFixture.java#L370-L373 |
carewebframework/carewebframework-core | org.carewebframework.messaging-parent/org.carewebframework.messaging.amqp-parent/org.carewebframework.messaging.amqp.rabbitmq/src/main/java/org/carewebframework/messaging/amqp/rabbitmq/Broker.java | Broker.sendMessage | public void sendMessage(String channel, Message message) {
"""
Sends an event to the default exchange.
@param channel Name of the channel.
@param message Message to send.
"""
ensureChannel(channel);
admin.getRabbitTemplate().convertAndSend(exchange.getName(), channel, message);
} | java | public void sendMessage(String channel, Message message) {
ensureChannel(channel);
admin.getRabbitTemplate().convertAndSend(exchange.getName(), channel, message);
} | [
"public",
"void",
"sendMessage",
"(",
"String",
"channel",
",",
"Message",
"message",
")",
"{",
"ensureChannel",
"(",
"channel",
")",
";",
"admin",
".",
"getRabbitTemplate",
"(",
")",
".",
"convertAndSend",
"(",
"exchange",
".",
"getName",
"(",
")",
",",
"channel",
",",
"message",
")",
";",
"}"
] | Sends an event to the default exchange.
@param channel Name of the channel.
@param message Message to send. | [
"Sends",
"an",
"event",
"to",
"the",
"default",
"exchange",
"."
] | train | https://github.com/carewebframework/carewebframework-core/blob/fa3252d4f7541dbe151b92c3d4f6f91433cd1673/org.carewebframework.messaging-parent/org.carewebframework.messaging.amqp-parent/org.carewebframework.messaging.amqp.rabbitmq/src/main/java/org/carewebframework/messaging/amqp/rabbitmq/Broker.java#L104-L107 |
icode/ameba | src/main/java/ameba/db/ebean/filter/CommonExprTransformer.java | CommonExprTransformer.fillArgs | public static void fillArgs(String operator, Val<Expression>[] args, ExpressionList<?> et) {
"""
<p>fillArgs.</p>
@param operator a {@link java.lang.String} object.
@param args an array of {@link ameba.db.dsl.QueryExprMeta.Val} objects.
@param et a {@link io.ebean.ExpressionList} object.
"""
for (Val<Expression> val : args) {
if (val.object() instanceof Expression) {
et.add(val.expr());
} else {
throw new QuerySyntaxException(Messages.get("dsl.arguments.error3", operator));
}
}
} | java | public static void fillArgs(String operator, Val<Expression>[] args, ExpressionList<?> et) {
for (Val<Expression> val : args) {
if (val.object() instanceof Expression) {
et.add(val.expr());
} else {
throw new QuerySyntaxException(Messages.get("dsl.arguments.error3", operator));
}
}
} | [
"public",
"static",
"void",
"fillArgs",
"(",
"String",
"operator",
",",
"Val",
"<",
"Expression",
">",
"[",
"]",
"args",
",",
"ExpressionList",
"<",
"?",
">",
"et",
")",
"{",
"for",
"(",
"Val",
"<",
"Expression",
">",
"val",
":",
"args",
")",
"{",
"if",
"(",
"val",
".",
"object",
"(",
")",
"instanceof",
"Expression",
")",
"{",
"et",
".",
"add",
"(",
"val",
".",
"expr",
"(",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"QuerySyntaxException",
"(",
"Messages",
".",
"get",
"(",
"\"dsl.arguments.error3\"",
",",
"operator",
")",
")",
";",
"}",
"}",
"}"
] | <p>fillArgs.</p>
@param operator a {@link java.lang.String} object.
@param args an array of {@link ameba.db.dsl.QueryExprMeta.Val} objects.
@param et a {@link io.ebean.ExpressionList} object. | [
"<p",
">",
"fillArgs",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/icode/ameba/blob/9d4956e935898e41331b2745e400ef869cd265e0/src/main/java/ameba/db/ebean/filter/CommonExprTransformer.java#L47-L55 |
sdl/odata | odata_api/src/main/java/com/sdl/odata/util/edm/EntityDataModelUtil.java | EntityDataModelUtil.getAndCheckType | public static Type getAndCheckType(EntityDataModel entityDataModel, Class<?> javaType) {
"""
Gets the OData type for a Java type and throws an exception if there is no OData type for the Java type.
@param entityDataModel The entity data model.
@param javaType The Java type.
@return The OData type for the Java type.
@throws ODataSystemException If there is no OData type for the specified Java type.
"""
Type type = entityDataModel.getType(javaType);
if (type == null) {
throw new ODataSystemException("No type found in the entity data model for Java type: "
+ javaType.getName());
}
return type;
} | java | public static Type getAndCheckType(EntityDataModel entityDataModel, Class<?> javaType) {
Type type = entityDataModel.getType(javaType);
if (type == null) {
throw new ODataSystemException("No type found in the entity data model for Java type: "
+ javaType.getName());
}
return type;
} | [
"public",
"static",
"Type",
"getAndCheckType",
"(",
"EntityDataModel",
"entityDataModel",
",",
"Class",
"<",
"?",
">",
"javaType",
")",
"{",
"Type",
"type",
"=",
"entityDataModel",
".",
"getType",
"(",
"javaType",
")",
";",
"if",
"(",
"type",
"==",
"null",
")",
"{",
"throw",
"new",
"ODataSystemException",
"(",
"\"No type found in the entity data model for Java type: \"",
"+",
"javaType",
".",
"getName",
"(",
")",
")",
";",
"}",
"return",
"type",
";",
"}"
] | Gets the OData type for a Java type and throws an exception if there is no OData type for the Java type.
@param entityDataModel The entity data model.
@param javaType The Java type.
@return The OData type for the Java type.
@throws ODataSystemException If there is no OData type for the specified Java type. | [
"Gets",
"the",
"OData",
"type",
"for",
"a",
"Java",
"type",
"and",
"throws",
"an",
"exception",
"if",
"there",
"is",
"no",
"OData",
"type",
"for",
"the",
"Java",
"type",
"."
] | train | https://github.com/sdl/odata/blob/eb747d73e9af0f4e59a25b82ed656e526a7e2189/odata_api/src/main/java/com/sdl/odata/util/edm/EntityDataModelUtil.java#L85-L92 |
camunda/camunda-bpm-platform | distro/wildfly/subsystem/src/main/java/org/camunda/bpm/container/impl/jboss/util/CustomMarshaller.java | CustomMarshaller.getValueTypes | public static AttributeDefinition[] getValueTypes(Object instance, Class clazz) {
"""
Obtain the 'valueTypes' of the ObjectTypeAttributeDefinition through reflection because they are private in Wildfly 8.
"""
try {
if (ObjectTypeAttributeDefinition.class.isAssignableFrom(clazz)) {
Field valueTypesField = clazz.getDeclaredField("valueTypes");
valueTypesField.setAccessible(true);
Object value = valueTypesField.get(instance);
if (value != null) {
if (AttributeDefinition[].class.isAssignableFrom(value.getClass())) {
return (AttributeDefinition[]) value;
}
}
return (AttributeDefinition[]) value;
}
} catch (Exception e) {
throw new RuntimeException("Unable to get valueTypes.", e);
}
return null;
} | java | public static AttributeDefinition[] getValueTypes(Object instance, Class clazz) {
try {
if (ObjectTypeAttributeDefinition.class.isAssignableFrom(clazz)) {
Field valueTypesField = clazz.getDeclaredField("valueTypes");
valueTypesField.setAccessible(true);
Object value = valueTypesField.get(instance);
if (value != null) {
if (AttributeDefinition[].class.isAssignableFrom(value.getClass())) {
return (AttributeDefinition[]) value;
}
}
return (AttributeDefinition[]) value;
}
} catch (Exception e) {
throw new RuntimeException("Unable to get valueTypes.", e);
}
return null;
} | [
"public",
"static",
"AttributeDefinition",
"[",
"]",
"getValueTypes",
"(",
"Object",
"instance",
",",
"Class",
"clazz",
")",
"{",
"try",
"{",
"if",
"(",
"ObjectTypeAttributeDefinition",
".",
"class",
".",
"isAssignableFrom",
"(",
"clazz",
")",
")",
"{",
"Field",
"valueTypesField",
"=",
"clazz",
".",
"getDeclaredField",
"(",
"\"valueTypes\"",
")",
";",
"valueTypesField",
".",
"setAccessible",
"(",
"true",
")",
";",
"Object",
"value",
"=",
"valueTypesField",
".",
"get",
"(",
"instance",
")",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"if",
"(",
"AttributeDefinition",
"[",
"]",
".",
"class",
".",
"isAssignableFrom",
"(",
"value",
".",
"getClass",
"(",
")",
")",
")",
"{",
"return",
"(",
"AttributeDefinition",
"[",
"]",
")",
"value",
";",
"}",
"}",
"return",
"(",
"AttributeDefinition",
"[",
"]",
")",
"value",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unable to get valueTypes.\"",
",",
"e",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Obtain the 'valueTypes' of the ObjectTypeAttributeDefinition through reflection because they are private in Wildfly 8. | [
"Obtain",
"the",
"valueTypes",
"of",
"the",
"ObjectTypeAttributeDefinition",
"through",
"reflection",
"because",
"they",
"are",
"private",
"in",
"Wildfly",
"8",
"."
] | train | https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/distro/wildfly/subsystem/src/main/java/org/camunda/bpm/container/impl/jboss/util/CustomMarshaller.java#L36-L54 |
Azure/azure-sdk-for-java | dns/resource-manager/v2016_04_01/src/main/java/com/microsoft/azure/management/dns/v2016_04_01/implementation/ZonesInner.java | ZonesInner.beginDelete | public ZoneDeleteResultInner beginDelete(String resourceGroupName, String zoneName, String ifMatch) {
"""
Deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation cannot be undone.
@param resourceGroupName The name of the resource group.
@param zoneName The name of the DNS zone (without a terminating dot).
@param ifMatch The etag of the DNS zone. Omit this value to always delete the current zone. Specify the last-seen etag value to prevent accidentally deleting any concurrent changes.
@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 ZoneDeleteResultInner object if successful.
"""
return beginDeleteWithServiceResponseAsync(resourceGroupName, zoneName, ifMatch).toBlocking().single().body();
} | java | public ZoneDeleteResultInner beginDelete(String resourceGroupName, String zoneName, String ifMatch) {
return beginDeleteWithServiceResponseAsync(resourceGroupName, zoneName, ifMatch).toBlocking().single().body();
} | [
"public",
"ZoneDeleteResultInner",
"beginDelete",
"(",
"String",
"resourceGroupName",
",",
"String",
"zoneName",
",",
"String",
"ifMatch",
")",
"{",
"return",
"beginDeleteWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"zoneName",
",",
"ifMatch",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation cannot be undone.
@param resourceGroupName The name of the resource group.
@param zoneName The name of the DNS zone (without a terminating dot).
@param ifMatch The etag of the DNS zone. Omit this value to always delete the current zone. Specify the last-seen etag value to prevent accidentally deleting any concurrent changes.
@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 ZoneDeleteResultInner object if successful. | [
"Deletes",
"a",
"DNS",
"zone",
".",
"WARNING",
":",
"All",
"DNS",
"records",
"in",
"the",
"zone",
"will",
"also",
"be",
"deleted",
".",
"This",
"operation",
"cannot",
"be",
"undone",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/dns/resource-manager/v2016_04_01/src/main/java/com/microsoft/azure/management/dns/v2016_04_01/implementation/ZonesInner.java#L526-L528 |
Azure/azure-sdk-for-java | edgegateway/resource-manager/v2019_03_01/src/main/java/com/microsoft/azure/management/edgegateway/v2019_03_01/implementation/DevicesInner.java | DevicesInner.createOrUpdate | public DataBoxEdgeDeviceInner createOrUpdate(String deviceName, String resourceGroupName, DataBoxEdgeDeviceInner dataBoxEdgeDevice) {
"""
Creates or updates a Data Box Edge/Gateway resource.
@param deviceName The device name.
@param resourceGroupName The resource group name.
@param dataBoxEdgeDevice The resource object.
@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 DataBoxEdgeDeviceInner object if successful.
"""
return createOrUpdateWithServiceResponseAsync(deviceName, resourceGroupName, dataBoxEdgeDevice).toBlocking().last().body();
} | java | public DataBoxEdgeDeviceInner createOrUpdate(String deviceName, String resourceGroupName, DataBoxEdgeDeviceInner dataBoxEdgeDevice) {
return createOrUpdateWithServiceResponseAsync(deviceName, resourceGroupName, dataBoxEdgeDevice).toBlocking().last().body();
} | [
"public",
"DataBoxEdgeDeviceInner",
"createOrUpdate",
"(",
"String",
"deviceName",
",",
"String",
"resourceGroupName",
",",
"DataBoxEdgeDeviceInner",
"dataBoxEdgeDevice",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"deviceName",
",",
"resourceGroupName",
",",
"dataBoxEdgeDevice",
")",
".",
"toBlocking",
"(",
")",
".",
"last",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Creates or updates a Data Box Edge/Gateway resource.
@param deviceName The device name.
@param resourceGroupName The resource group name.
@param dataBoxEdgeDevice The resource object.
@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 DataBoxEdgeDeviceInner object if successful. | [
"Creates",
"or",
"updates",
"a",
"Data",
"Box",
"Edge",
"/",
"Gateway",
"resource",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/edgegateway/resource-manager/v2019_03_01/src/main/java/com/microsoft/azure/management/edgegateway/v2019_03_01/implementation/DevicesInner.java#L703-L705 |
LearnLib/automatalib | commons/smartcollections/src/main/java/net/automatalib/commons/smartcollections/AbstractLinkedList.java | AbstractLinkedList.replaceEntry | protected void replaceEntry(T oldEntry, T newEntry) {
"""
Replaces an entry in the list.
@param oldEntry
the entry to be replaced.
@param newEntry
the replacement entry.
"""
T prev = oldEntry.getPrev();
T next = newEntry.getNext();
if (prev != null) {
prev.setNext(newEntry);
} else {
head = newEntry;
}
if (next != null) {
next.setPrev(newEntry);
} else {
last = newEntry;
}
} | java | protected void replaceEntry(T oldEntry, T newEntry) {
T prev = oldEntry.getPrev();
T next = newEntry.getNext();
if (prev != null) {
prev.setNext(newEntry);
} else {
head = newEntry;
}
if (next != null) {
next.setPrev(newEntry);
} else {
last = newEntry;
}
} | [
"protected",
"void",
"replaceEntry",
"(",
"T",
"oldEntry",
",",
"T",
"newEntry",
")",
"{",
"T",
"prev",
"=",
"oldEntry",
".",
"getPrev",
"(",
")",
";",
"T",
"next",
"=",
"newEntry",
".",
"getNext",
"(",
")",
";",
"if",
"(",
"prev",
"!=",
"null",
")",
"{",
"prev",
".",
"setNext",
"(",
"newEntry",
")",
";",
"}",
"else",
"{",
"head",
"=",
"newEntry",
";",
"}",
"if",
"(",
"next",
"!=",
"null",
")",
"{",
"next",
".",
"setPrev",
"(",
"newEntry",
")",
";",
"}",
"else",
"{",
"last",
"=",
"newEntry",
";",
"}",
"}"
] | Replaces an entry in the list.
@param oldEntry
the entry to be replaced.
@param newEntry
the replacement entry. | [
"Replaces",
"an",
"entry",
"in",
"the",
"list",
"."
] | train | https://github.com/LearnLib/automatalib/blob/8a462ec52f6eaab9f8996e344f2163a72cb8aa6e/commons/smartcollections/src/main/java/net/automatalib/commons/smartcollections/AbstractLinkedList.java#L179-L192 |
lordcodes/SnackbarBuilder | snackbarbuilder/src/main/java/com/github/andrewlord1990/snackbarbuilder/SnackbarBuilder.java | SnackbarBuilder.dismissCallback | @SuppressWarnings("WeakerAccess")
public SnackbarBuilder dismissCallback(final SnackbarDismissCallback callback) {
"""
Set the callback to be informed of the Snackbar being dismissed through some means.
@param callback The callback.
@return This instance.
"""
callbacks.add(new SnackbarCallback() {
public void onSnackbarDismissed(Snackbar snackbar, int dismissEvent) {
callback.onSnackbarDismissed(snackbar, dismissEvent);
}
});
return this;
} | java | @SuppressWarnings("WeakerAccess")
public SnackbarBuilder dismissCallback(final SnackbarDismissCallback callback) {
callbacks.add(new SnackbarCallback() {
public void onSnackbarDismissed(Snackbar snackbar, int dismissEvent) {
callback.onSnackbarDismissed(snackbar, dismissEvent);
}
});
return this;
} | [
"@",
"SuppressWarnings",
"(",
"\"WeakerAccess\"",
")",
"public",
"SnackbarBuilder",
"dismissCallback",
"(",
"final",
"SnackbarDismissCallback",
"callback",
")",
"{",
"callbacks",
".",
"add",
"(",
"new",
"SnackbarCallback",
"(",
")",
"{",
"public",
"void",
"onSnackbarDismissed",
"(",
"Snackbar",
"snackbar",
",",
"int",
"dismissEvent",
")",
"{",
"callback",
".",
"onSnackbarDismissed",
"(",
"snackbar",
",",
"dismissEvent",
")",
";",
"}",
"}",
")",
";",
"return",
"this",
";",
"}"
] | Set the callback to be informed of the Snackbar being dismissed through some means.
@param callback The callback.
@return This instance. | [
"Set",
"the",
"callback",
"to",
"be",
"informed",
"of",
"the",
"Snackbar",
"being",
"dismissed",
"through",
"some",
"means",
"."
] | train | https://github.com/lordcodes/SnackbarBuilder/blob/a104a753c78ed66940c19d295e141a521cf81d73/snackbarbuilder/src/main/java/com/github/andrewlord1990/snackbarbuilder/SnackbarBuilder.java#L357-L365 |
facebookarchive/hadoop-20 | src/core/org/apache/hadoop/fs/FileUtil.java | FileUtil.unZip | public static void unZip(File inFile, File unzipDir) throws IOException {
"""
Given a File input it will unzip the file in a the unzip directory
passed as the second parameter
@param inFile The zip file as input
@param unzipDir The unzip directory where to unzip the zip file.
@throws IOException
"""
Enumeration<? extends ZipEntry> entries;
ZipFile zipFile = new ZipFile(inFile);
try {
entries = zipFile.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
if (!entry.isDirectory()) {
InputStream in = zipFile.getInputStream(entry);
try {
File file = new File(unzipDir, entry.getName());
if (!file.getParentFile().mkdirs()) {
if (!file.getParentFile().isDirectory()) {
throw new IOException("Mkdirs failed to create " +
file.getParentFile().toString());
}
}
OutputStream out = new FileOutputStream(file);
try {
byte[] buffer = new byte[8192];
int i;
while ((i = in.read(buffer)) != -1) {
out.write(buffer, 0, i);
}
} finally {
out.close();
}
} finally {
in.close();
}
}
}
} finally {
zipFile.close();
}
} | java | public static void unZip(File inFile, File unzipDir) throws IOException {
Enumeration<? extends ZipEntry> entries;
ZipFile zipFile = new ZipFile(inFile);
try {
entries = zipFile.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
if (!entry.isDirectory()) {
InputStream in = zipFile.getInputStream(entry);
try {
File file = new File(unzipDir, entry.getName());
if (!file.getParentFile().mkdirs()) {
if (!file.getParentFile().isDirectory()) {
throw new IOException("Mkdirs failed to create " +
file.getParentFile().toString());
}
}
OutputStream out = new FileOutputStream(file);
try {
byte[] buffer = new byte[8192];
int i;
while ((i = in.read(buffer)) != -1) {
out.write(buffer, 0, i);
}
} finally {
out.close();
}
} finally {
in.close();
}
}
}
} finally {
zipFile.close();
}
} | [
"public",
"static",
"void",
"unZip",
"(",
"File",
"inFile",
",",
"File",
"unzipDir",
")",
"throws",
"IOException",
"{",
"Enumeration",
"<",
"?",
"extends",
"ZipEntry",
">",
"entries",
";",
"ZipFile",
"zipFile",
"=",
"new",
"ZipFile",
"(",
"inFile",
")",
";",
"try",
"{",
"entries",
"=",
"zipFile",
".",
"entries",
"(",
")",
";",
"while",
"(",
"entries",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"ZipEntry",
"entry",
"=",
"entries",
".",
"nextElement",
"(",
")",
";",
"if",
"(",
"!",
"entry",
".",
"isDirectory",
"(",
")",
")",
"{",
"InputStream",
"in",
"=",
"zipFile",
".",
"getInputStream",
"(",
"entry",
")",
";",
"try",
"{",
"File",
"file",
"=",
"new",
"File",
"(",
"unzipDir",
",",
"entry",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"!",
"file",
".",
"getParentFile",
"(",
")",
".",
"mkdirs",
"(",
")",
")",
"{",
"if",
"(",
"!",
"file",
".",
"getParentFile",
"(",
")",
".",
"isDirectory",
"(",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Mkdirs failed to create \"",
"+",
"file",
".",
"getParentFile",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"OutputStream",
"out",
"=",
"new",
"FileOutputStream",
"(",
"file",
")",
";",
"try",
"{",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"8192",
"]",
";",
"int",
"i",
";",
"while",
"(",
"(",
"i",
"=",
"in",
".",
"read",
"(",
"buffer",
")",
")",
"!=",
"-",
"1",
")",
"{",
"out",
".",
"write",
"(",
"buffer",
",",
"0",
",",
"i",
")",
";",
"}",
"}",
"finally",
"{",
"out",
".",
"close",
"(",
")",
";",
"}",
"}",
"finally",
"{",
"in",
".",
"close",
"(",
")",
";",
"}",
"}",
"}",
"}",
"finally",
"{",
"zipFile",
".",
"close",
"(",
")",
";",
"}",
"}"
] | Given a File input it will unzip the file in a the unzip directory
passed as the second parameter
@param inFile The zip file as input
@param unzipDir The unzip directory where to unzip the zip file.
@throws IOException | [
"Given",
"a",
"File",
"input",
"it",
"will",
"unzip",
"the",
"file",
"in",
"a",
"the",
"unzip",
"directory",
"passed",
"as",
"the",
"second",
"parameter"
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/core/org/apache/hadoop/fs/FileUtil.java#L632-L668 |
Azure/azure-sdk-for-java | containerregistry/resource-manager/v2017_06_01_preview/src/main/java/com/microsoft/azure/management/containerregistry/v2017_06_01_preview/implementation/RegistriesInner.java | RegistriesInner.beginUpdate | public RegistryInner beginUpdate(String resourceGroupName, String registryName, RegistryUpdateParameters registryUpdateParameters) {
"""
Updates 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 registryUpdateParameters The parameters for updating a container registry.
@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 RegistryInner object if successful.
"""
return beginUpdateWithServiceResponseAsync(resourceGroupName, registryName, registryUpdateParameters).toBlocking().single().body();
} | java | public RegistryInner beginUpdate(String resourceGroupName, String registryName, RegistryUpdateParameters registryUpdateParameters) {
return beginUpdateWithServiceResponseAsync(resourceGroupName, registryName, registryUpdateParameters).toBlocking().single().body();
} | [
"public",
"RegistryInner",
"beginUpdate",
"(",
"String",
"resourceGroupName",
",",
"String",
"registryName",
",",
"RegistryUpdateParameters",
"registryUpdateParameters",
")",
"{",
"return",
"beginUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"registryName",
",",
"registryUpdateParameters",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Updates 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 registryUpdateParameters The parameters for updating a container registry.
@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 RegistryInner object if successful. | [
"Updates",
"a",
"container",
"registry",
"with",
"the",
"specified",
"parameters",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/containerregistry/resource-manager/v2017_06_01_preview/src/main/java/com/microsoft/azure/management/containerregistry/v2017_06_01_preview/implementation/RegistriesInner.java#L717-L719 |
h2oai/h2o-3 | h2o-automl/src/main/java/ai/h2o/automl/AutoML.java | AutoML.pollAndUpdateProgress | private void pollAndUpdateProgress(Stage stage, String name, WorkAllocations.Work work, Job parentJob, Job subJob) {
"""
***************** Jobs Build / Configure / Run / Poll section (model agnostic, kind of...) *****************//
"""
pollAndUpdateProgress(stage, name, work, parentJob, subJob, false);
} | java | private void pollAndUpdateProgress(Stage stage, String name, WorkAllocations.Work work, Job parentJob, Job subJob) {
pollAndUpdateProgress(stage, name, work, parentJob, subJob, false);
} | [
"private",
"void",
"pollAndUpdateProgress",
"(",
"Stage",
"stage",
",",
"String",
"name",
",",
"WorkAllocations",
".",
"Work",
"work",
",",
"Job",
"parentJob",
",",
"Job",
"subJob",
")",
"{",
"pollAndUpdateProgress",
"(",
"stage",
",",
"name",
",",
"work",
",",
"parentJob",
",",
"subJob",
",",
"false",
")",
";",
"}"
] | ***************** Jobs Build / Configure / Run / Poll section (model agnostic, kind of...) *****************// | [
"*****************",
"Jobs",
"Build",
"/",
"Configure",
"/",
"Run",
"/",
"Poll",
"section",
"(",
"model",
"agnostic",
"kind",
"of",
"...",
")",
"*****************",
"//"
] | train | https://github.com/h2oai/h2o-3/blob/845eb49dfeaadf638b6e2f779d82fac996391fad/h2o-automl/src/main/java/ai/h2o/automl/AutoML.java#L555-L557 |
alkacon/opencms-core | src/org/opencms/search/CmsSearchIndex.java | CmsSearchIndex.getMultiTermQueryFilter | protected Query getMultiTermQueryFilter(String field, List<String> terms) {
"""
Returns a cached Lucene term query filter for the given field and terms.<p>
@param field the field to use
@param terms the term to use
@return a cached Lucene term query filter for the given field and terms
"""
return getMultiTermQueryFilter(field, null, terms);
} | java | protected Query getMultiTermQueryFilter(String field, List<String> terms) {
return getMultiTermQueryFilter(field, null, terms);
} | [
"protected",
"Query",
"getMultiTermQueryFilter",
"(",
"String",
"field",
",",
"List",
"<",
"String",
">",
"terms",
")",
"{",
"return",
"getMultiTermQueryFilter",
"(",
"field",
",",
"null",
",",
"terms",
")",
";",
"}"
] | Returns a cached Lucene term query filter for the given field and terms.<p>
@param field the field to use
@param terms the term to use
@return a cached Lucene term query filter for the given field and terms | [
"Returns",
"a",
"cached",
"Lucene",
"term",
"query",
"filter",
"for",
"the",
"given",
"field",
"and",
"terms",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/search/CmsSearchIndex.java#L1620-L1623 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/typeconvert/TypeConverter.java | TypeConverter.convertToLong | public static long convertToLong (@Nullable final Object aSrcValue, final long nDefault) {
"""
Convert the passed source value to long
@param aSrcValue
The source value. May be <code>null</code>.
@param nDefault
The default value to be returned if an error occurs during type
conversion.
@return The converted value.
@throws RuntimeException
If the converter itself throws an exception
@see TypeConverterProviderBestMatch
"""
final Long aValue = convert (aSrcValue, Long.class, null);
return aValue == null ? nDefault : aValue.longValue ();
} | java | public static long convertToLong (@Nullable final Object aSrcValue, final long nDefault)
{
final Long aValue = convert (aSrcValue, Long.class, null);
return aValue == null ? nDefault : aValue.longValue ();
} | [
"public",
"static",
"long",
"convertToLong",
"(",
"@",
"Nullable",
"final",
"Object",
"aSrcValue",
",",
"final",
"long",
"nDefault",
")",
"{",
"final",
"Long",
"aValue",
"=",
"convert",
"(",
"aSrcValue",
",",
"Long",
".",
"class",
",",
"null",
")",
";",
"return",
"aValue",
"==",
"null",
"?",
"nDefault",
":",
"aValue",
".",
"longValue",
"(",
")",
";",
"}"
] | Convert the passed source value to long
@param aSrcValue
The source value. May be <code>null</code>.
@param nDefault
The default value to be returned if an error occurs during type
conversion.
@return The converted value.
@throws RuntimeException
If the converter itself throws an exception
@see TypeConverterProviderBestMatch | [
"Convert",
"the",
"passed",
"source",
"value",
"to",
"long"
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/typeconvert/TypeConverter.java#L375-L379 |
Azure/azure-sdk-for-java | appservice/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/appservice/v2018_02_01/implementation/DiagnosticsInner.java | DiagnosticsInner.executeSiteDetector | public DiagnosticDetectorResponseInner executeSiteDetector(String resourceGroupName, String siteName, String detectorName, String diagnosticCategory) {
"""
Execute Detector.
Execute Detector.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param siteName Site Name
@param detectorName Detector Resource Name
@param diagnosticCategory Category Name
@throws IllegalArgumentException thrown if parameters fail the validation
@throws DefaultErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the DiagnosticDetectorResponseInner object if successful.
"""
return executeSiteDetectorWithServiceResponseAsync(resourceGroupName, siteName, detectorName, diagnosticCategory).toBlocking().single().body();
} | java | public DiagnosticDetectorResponseInner executeSiteDetector(String resourceGroupName, String siteName, String detectorName, String diagnosticCategory) {
return executeSiteDetectorWithServiceResponseAsync(resourceGroupName, siteName, detectorName, diagnosticCategory).toBlocking().single().body();
} | [
"public",
"DiagnosticDetectorResponseInner",
"executeSiteDetector",
"(",
"String",
"resourceGroupName",
",",
"String",
"siteName",
",",
"String",
"detectorName",
",",
"String",
"diagnosticCategory",
")",
"{",
"return",
"executeSiteDetectorWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"siteName",
",",
"detectorName",
",",
"diagnosticCategory",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Execute Detector.
Execute Detector.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param siteName Site Name
@param detectorName Detector Resource Name
@param diagnosticCategory Category Name
@throws IllegalArgumentException thrown if parameters fail the validation
@throws DefaultErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the DiagnosticDetectorResponseInner object if successful. | [
"Execute",
"Detector",
".",
"Execute",
"Detector",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/appservice/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/appservice/v2018_02_01/implementation/DiagnosticsInner.java#L1134-L1136 |
threerings/narya | core/src/main/java/com/threerings/presents/util/ClassUtil.java | ClassUtil.findMethod | public static Method findMethod (Class<?> clazz, String name) {
"""
Locates and returns the first method in the supplied class whose name is equal to the
specified name.
@return the method with the specified name or null if no method with that name could be
found.
"""
Method[] methods = clazz.getMethods();
for (Method method : methods) {
if (method.getName().equals(name)) {
return method;
}
}
return null;
} | java | public static Method findMethod (Class<?> clazz, String name)
{
Method[] methods = clazz.getMethods();
for (Method method : methods) {
if (method.getName().equals(name)) {
return method;
}
}
return null;
} | [
"public",
"static",
"Method",
"findMethod",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"String",
"name",
")",
"{",
"Method",
"[",
"]",
"methods",
"=",
"clazz",
".",
"getMethods",
"(",
")",
";",
"for",
"(",
"Method",
"method",
":",
"methods",
")",
"{",
"if",
"(",
"method",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"name",
")",
")",
"{",
"return",
"method",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Locates and returns the first method in the supplied class whose name is equal to the
specified name.
@return the method with the specified name or null if no method with that name could be
found. | [
"Locates",
"and",
"returns",
"the",
"first",
"method",
"in",
"the",
"supplied",
"class",
"whose",
"name",
"is",
"equal",
"to",
"the",
"specified",
"name",
"."
] | train | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/util/ClassUtil.java#L100-L109 |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/alg/transform/pyramid/PyramidOps.java | PyramidOps.scaleDown2 | public static <T extends ImageGray<T>>
void scaleDown2(T input , T output ) {
"""
Scales down the input by a factor of 2. Every other pixel along both axises is skipped.
"""
if( input instanceof GrayF32) {
ImplPyramidOps.scaleDown2((GrayF32)input,(GrayF32)output);
} else if( input instanceof GrayU8) {
ImplPyramidOps.scaleDown2((GrayU8)input,(GrayU8)output);
} else {
throw new IllegalArgumentException("Image type not yet supported");
}
} | java | public static <T extends ImageGray<T>>
void scaleDown2(T input , T output ) {
if( input instanceof GrayF32) {
ImplPyramidOps.scaleDown2((GrayF32)input,(GrayF32)output);
} else if( input instanceof GrayU8) {
ImplPyramidOps.scaleDown2((GrayU8)input,(GrayU8)output);
} else {
throw new IllegalArgumentException("Image type not yet supported");
}
} | [
"public",
"static",
"<",
"T",
"extends",
"ImageGray",
"<",
"T",
">",
">",
"void",
"scaleDown2",
"(",
"T",
"input",
",",
"T",
"output",
")",
"{",
"if",
"(",
"input",
"instanceof",
"GrayF32",
")",
"{",
"ImplPyramidOps",
".",
"scaleDown2",
"(",
"(",
"GrayF32",
")",
"input",
",",
"(",
"GrayF32",
")",
"output",
")",
";",
"}",
"else",
"if",
"(",
"input",
"instanceof",
"GrayU8",
")",
"{",
"ImplPyramidOps",
".",
"scaleDown2",
"(",
"(",
"GrayU8",
")",
"input",
",",
"(",
"GrayU8",
")",
"output",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Image type not yet supported\"",
")",
";",
"}",
"}"
] | Scales down the input by a factor of 2. Every other pixel along both axises is skipped. | [
"Scales",
"down",
"the",
"input",
"by",
"a",
"factor",
"of",
"2",
".",
"Every",
"other",
"pixel",
"along",
"both",
"axises",
"is",
"skipped",
"."
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/transform/pyramid/PyramidOps.java#L152-L161 |
spring-projects/spring-data-solr | src/main/java/org/springframework/data/solr/core/DefaultQueryParser.java | DefaultQueryParser.appendSort | protected void appendSort(SolrQuery solrQuery, @Nullable Sort sort, @Nullable Class<?> domainType) {
"""
Append sorting parameters to {@link SolrQuery}
@param solrQuery
@param sort
"""
if (sort == null) {
return;
}
for (Order order : sort) {
solrQuery.addSort(getMappedFieldName(order.getProperty(), domainType),
order.isAscending() ? ORDER.asc : ORDER.desc);
}
} | java | protected void appendSort(SolrQuery solrQuery, @Nullable Sort sort, @Nullable Class<?> domainType) {
if (sort == null) {
return;
}
for (Order order : sort) {
solrQuery.addSort(getMappedFieldName(order.getProperty(), domainType),
order.isAscending() ? ORDER.asc : ORDER.desc);
}
} | [
"protected",
"void",
"appendSort",
"(",
"SolrQuery",
"solrQuery",
",",
"@",
"Nullable",
"Sort",
"sort",
",",
"@",
"Nullable",
"Class",
"<",
"?",
">",
"domainType",
")",
"{",
"if",
"(",
"sort",
"==",
"null",
")",
"{",
"return",
";",
"}",
"for",
"(",
"Order",
"order",
":",
"sort",
")",
"{",
"solrQuery",
".",
"addSort",
"(",
"getMappedFieldName",
"(",
"order",
".",
"getProperty",
"(",
")",
",",
"domainType",
")",
",",
"order",
".",
"isAscending",
"(",
")",
"?",
"ORDER",
".",
"asc",
":",
"ORDER",
".",
"desc",
")",
";",
"}",
"}"
] | Append sorting parameters to {@link SolrQuery}
@param solrQuery
@param sort | [
"Append",
"sorting",
"parameters",
"to",
"{",
"@link",
"SolrQuery",
"}"
] | train | https://github.com/spring-projects/spring-data-solr/blob/20be5cb82498b70134dfda6c1a91ad21f8e657e0/src/main/java/org/springframework/data/solr/core/DefaultQueryParser.java#L505-L515 |
jpush/jmessage-api-java-client | src/main/java/cn/jmessage/api/JMessageClient.java | JMessageClient.addOrRemoveCrossGroupMember | public ResponseWrapper addOrRemoveCrossGroupMember(long gid, CrossGroup[] groups)
throws APIConnectionException, APIRequestException {
"""
Add or remove group members from a given group id.
@param gid Necessary, target group id.
@param groups Necessary
@return No content
@throws APIConnectionException connect exception
@throws APIRequestException request exception
"""
return _crossAppClient.addOrRemoveCrossGroupMembers(gid, groups);
} | java | public ResponseWrapper addOrRemoveCrossGroupMember(long gid, CrossGroup[] groups)
throws APIConnectionException, APIRequestException {
return _crossAppClient.addOrRemoveCrossGroupMembers(gid, groups);
} | [
"public",
"ResponseWrapper",
"addOrRemoveCrossGroupMember",
"(",
"long",
"gid",
",",
"CrossGroup",
"[",
"]",
"groups",
")",
"throws",
"APIConnectionException",
",",
"APIRequestException",
"{",
"return",
"_crossAppClient",
".",
"addOrRemoveCrossGroupMembers",
"(",
"gid",
",",
"groups",
")",
";",
"}"
] | Add or remove group members from a given group id.
@param gid Necessary, target group id.
@param groups Necessary
@return No content
@throws APIConnectionException connect exception
@throws APIRequestException request exception | [
"Add",
"or",
"remove",
"group",
"members",
"from",
"a",
"given",
"group",
"id",
"."
] | train | https://github.com/jpush/jmessage-api-java-client/blob/767f5fb15e9fe5a546c00f6e68b64f6dd53c617c/src/main/java/cn/jmessage/api/JMessageClient.java#L594-L597 |
UrielCh/ovh-java-sdk | ovh-java-sdk-emaildomain/src/main/java/net/minidev/ovh/api/ApiOvhEmaildomain.java | ApiOvhEmaildomain.domain_responder_account_PUT | public void domain_responder_account_PUT(String domain, String account, OvhResponder body) throws IOException {
"""
Alter this object properties
REST: PUT /email/domain/{domain}/responder/{account}
@param body [required] New object properties
@param domain [required] Name of your domain name
@param account [required] Name of account
"""
String qPath = "/email/domain/{domain}/responder/{account}";
StringBuilder sb = path(qPath, domain, account);
exec(qPath, "PUT", sb.toString(), body);
} | java | public void domain_responder_account_PUT(String domain, String account, OvhResponder body) throws IOException {
String qPath = "/email/domain/{domain}/responder/{account}";
StringBuilder sb = path(qPath, domain, account);
exec(qPath, "PUT", sb.toString(), body);
} | [
"public",
"void",
"domain_responder_account_PUT",
"(",
"String",
"domain",
",",
"String",
"account",
",",
"OvhResponder",
"body",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/email/domain/{domain}/responder/{account}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"domain",
",",
"account",
")",
";",
"exec",
"(",
"qPath",
",",
"\"PUT\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"body",
")",
";",
"}"
] | Alter this object properties
REST: PUT /email/domain/{domain}/responder/{account}
@param body [required] New object properties
@param domain [required] Name of your domain name
@param account [required] Name of account | [
"Alter",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-emaildomain/src/main/java/net/minidev/ovh/api/ApiOvhEmaildomain.java#L965-L969 |
Netflix/spectator | spectator-web-spring/src/main/java/com/netflix/spectator/controllers/MetricsController.java | MetricsController.encodeRegistry | Map<String, MetricValues> encodeRegistry(
Registry sourceRegistry, Predicate<Measurement> filter) {
"""
Internal API for encoding a registry that can be encoded as JSON.
This is a helper function for the REST endpoint and to test against.
"""
Map<String, MetricValues> metricMap = new HashMap<>();
/*
* Flatten the meter measurements into a map of measurements keyed by
* the name and mapped to the different tag variants.
*/
for (Meter meter : sourceRegistry) {
String kind = knownMeterKinds.computeIfAbsent(
meter.id(), k -> meterToKind(sourceRegistry, meter));
for (Measurement measurement : meter.measure()) {
if (!filter.test(measurement)) {
continue;
}
if (Double.isNaN(measurement.value())) {
continue;
}
String meterName = measurement.id().name();
MetricValues have = metricMap.get(meterName);
if (have == null) {
metricMap.put(meterName, new MetricValues(kind, measurement));
} else {
have.addMeasurement(measurement);
}
}
}
return metricMap;
} | java | Map<String, MetricValues> encodeRegistry(
Registry sourceRegistry, Predicate<Measurement> filter) {
Map<String, MetricValues> metricMap = new HashMap<>();
/*
* Flatten the meter measurements into a map of measurements keyed by
* the name and mapped to the different tag variants.
*/
for (Meter meter : sourceRegistry) {
String kind = knownMeterKinds.computeIfAbsent(
meter.id(), k -> meterToKind(sourceRegistry, meter));
for (Measurement measurement : meter.measure()) {
if (!filter.test(measurement)) {
continue;
}
if (Double.isNaN(measurement.value())) {
continue;
}
String meterName = measurement.id().name();
MetricValues have = metricMap.get(meterName);
if (have == null) {
metricMap.put(meterName, new MetricValues(kind, measurement));
} else {
have.addMeasurement(measurement);
}
}
}
return metricMap;
} | [
"Map",
"<",
"String",
",",
"MetricValues",
">",
"encodeRegistry",
"(",
"Registry",
"sourceRegistry",
",",
"Predicate",
"<",
"Measurement",
">",
"filter",
")",
"{",
"Map",
"<",
"String",
",",
"MetricValues",
">",
"metricMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"/*\n * Flatten the meter measurements into a map of measurements keyed by\n * the name and mapped to the different tag variants.\n */",
"for",
"(",
"Meter",
"meter",
":",
"sourceRegistry",
")",
"{",
"String",
"kind",
"=",
"knownMeterKinds",
".",
"computeIfAbsent",
"(",
"meter",
".",
"id",
"(",
")",
",",
"k",
"->",
"meterToKind",
"(",
"sourceRegistry",
",",
"meter",
")",
")",
";",
"for",
"(",
"Measurement",
"measurement",
":",
"meter",
".",
"measure",
"(",
")",
")",
"{",
"if",
"(",
"!",
"filter",
".",
"test",
"(",
"measurement",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"Double",
".",
"isNaN",
"(",
"measurement",
".",
"value",
"(",
")",
")",
")",
"{",
"continue",
";",
"}",
"String",
"meterName",
"=",
"measurement",
".",
"id",
"(",
")",
".",
"name",
"(",
")",
";",
"MetricValues",
"have",
"=",
"metricMap",
".",
"get",
"(",
"meterName",
")",
";",
"if",
"(",
"have",
"==",
"null",
")",
"{",
"metricMap",
".",
"put",
"(",
"meterName",
",",
"new",
"MetricValues",
"(",
"kind",
",",
"measurement",
")",
")",
";",
"}",
"else",
"{",
"have",
".",
"addMeasurement",
"(",
"measurement",
")",
";",
"}",
"}",
"}",
"return",
"metricMap",
";",
"}"
] | Internal API for encoding a registry that can be encoded as JSON.
This is a helper function for the REST endpoint and to test against. | [
"Internal",
"API",
"for",
"encoding",
"a",
"registry",
"that",
"can",
"be",
"encoded",
"as",
"JSON",
".",
"This",
"is",
"a",
"helper",
"function",
"for",
"the",
"REST",
"endpoint",
"and",
"to",
"test",
"against",
"."
] | train | https://github.com/Netflix/spectator/blob/259318252770de3bad581b85adff187d8f2c6537/spectator-web-spring/src/main/java/com/netflix/spectator/controllers/MetricsController.java#L126-L156 |
undertow-io/undertow | core/src/main/java/io/undertow/server/handlers/proxy/mod_cluster/NodePingUtil.java | NodePingUtil.pingHttpClient | static void pingHttpClient(URI connection, PingCallback callback, HttpServerExchange exchange, UndertowClient client, XnioSsl xnioSsl, OptionMap options) {
"""
Try to ping a server using the undertow client.
@param connection the connection URI
@param callback the ping callback
@param exchange the http servers exchange
@param client the undertow client
@param xnioSsl the ssl setup
@param options the options
"""
final XnioIoThread thread = exchange.getIoThread();
final RequestExchangeListener exchangeListener = new RequestExchangeListener(callback, NodeHealthChecker.NO_CHECK, true);
final Runnable r = new HttpClientPingTask(connection, exchangeListener, thread, client, xnioSsl, exchange.getConnection().getByteBufferPool(), options);
exchange.dispatch(exchange.isInIoThread() ? SameThreadExecutor.INSTANCE : thread, r);
// Schedule timeout task
scheduleCancelTask(exchange.getIoThread(), exchangeListener, 5, TimeUnit.SECONDS);
} | java | static void pingHttpClient(URI connection, PingCallback callback, HttpServerExchange exchange, UndertowClient client, XnioSsl xnioSsl, OptionMap options) {
final XnioIoThread thread = exchange.getIoThread();
final RequestExchangeListener exchangeListener = new RequestExchangeListener(callback, NodeHealthChecker.NO_CHECK, true);
final Runnable r = new HttpClientPingTask(connection, exchangeListener, thread, client, xnioSsl, exchange.getConnection().getByteBufferPool(), options);
exchange.dispatch(exchange.isInIoThread() ? SameThreadExecutor.INSTANCE : thread, r);
// Schedule timeout task
scheduleCancelTask(exchange.getIoThread(), exchangeListener, 5, TimeUnit.SECONDS);
} | [
"static",
"void",
"pingHttpClient",
"(",
"URI",
"connection",
",",
"PingCallback",
"callback",
",",
"HttpServerExchange",
"exchange",
",",
"UndertowClient",
"client",
",",
"XnioSsl",
"xnioSsl",
",",
"OptionMap",
"options",
")",
"{",
"final",
"XnioIoThread",
"thread",
"=",
"exchange",
".",
"getIoThread",
"(",
")",
";",
"final",
"RequestExchangeListener",
"exchangeListener",
"=",
"new",
"RequestExchangeListener",
"(",
"callback",
",",
"NodeHealthChecker",
".",
"NO_CHECK",
",",
"true",
")",
";",
"final",
"Runnable",
"r",
"=",
"new",
"HttpClientPingTask",
"(",
"connection",
",",
"exchangeListener",
",",
"thread",
",",
"client",
",",
"xnioSsl",
",",
"exchange",
".",
"getConnection",
"(",
")",
".",
"getByteBufferPool",
"(",
")",
",",
"options",
")",
";",
"exchange",
".",
"dispatch",
"(",
"exchange",
".",
"isInIoThread",
"(",
")",
"?",
"SameThreadExecutor",
".",
"INSTANCE",
":",
"thread",
",",
"r",
")",
";",
"// Schedule timeout task",
"scheduleCancelTask",
"(",
"exchange",
".",
"getIoThread",
"(",
")",
",",
"exchangeListener",
",",
"5",
",",
"TimeUnit",
".",
"SECONDS",
")",
";",
"}"
] | Try to ping a server using the undertow client.
@param connection the connection URI
@param callback the ping callback
@param exchange the http servers exchange
@param client the undertow client
@param xnioSsl the ssl setup
@param options the options | [
"Try",
"to",
"ping",
"a",
"server",
"using",
"the",
"undertow",
"client",
"."
] | train | https://github.com/undertow-io/undertow/blob/87de0b856a7a4ba8faf5b659537b9af07b763263/core/src/main/java/io/undertow/server/handlers/proxy/mod_cluster/NodePingUtil.java#L103-L111 |
mgm-tp/jfunk | jfunk-common/src/main/java/com/mgmtp/jfunk/common/util/ExtendedProperties.java | ExtendedProperties.get | public String get(final Object key, final boolean process) {
"""
Looks up a property. Recursively checks the defaults if necessary. If the property is found
as a system property, this value will be used.
@param key
The property key
@param process
If {@code true}, the looked-up value is passed to
{@link #processPropertyValue(String)}, and the processed result is returned.
@return The property value, or {@code null} if the property is not found
"""
String value = propsMap.get(key);
if (process) {
value = processPropertyValue(value);
}
return value == null && defaults != null ? defaults.get(key) : value;
} | java | public String get(final Object key, final boolean process) {
String value = propsMap.get(key);
if (process) {
value = processPropertyValue(value);
}
return value == null && defaults != null ? defaults.get(key) : value;
} | [
"public",
"String",
"get",
"(",
"final",
"Object",
"key",
",",
"final",
"boolean",
"process",
")",
"{",
"String",
"value",
"=",
"propsMap",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"process",
")",
"{",
"value",
"=",
"processPropertyValue",
"(",
"value",
")",
";",
"}",
"return",
"value",
"==",
"null",
"&&",
"defaults",
"!=",
"null",
"?",
"defaults",
".",
"get",
"(",
"key",
")",
":",
"value",
";",
"}"
] | Looks up a property. Recursively checks the defaults if necessary. If the property is found
as a system property, this value will be used.
@param key
The property key
@param process
If {@code true}, the looked-up value is passed to
{@link #processPropertyValue(String)}, and the processed result is returned.
@return The property value, or {@code null} if the property is not found | [
"Looks",
"up",
"a",
"property",
".",
"Recursively",
"checks",
"the",
"defaults",
"if",
"necessary",
".",
"If",
"the",
"property",
"is",
"found",
"as",
"a",
"system",
"property",
"this",
"value",
"will",
"be",
"used",
"."
] | train | https://github.com/mgm-tp/jfunk/blob/5b9fecac5778b988bb458085ded39ea9a4c7c2ae/jfunk-common/src/main/java/com/mgmtp/jfunk/common/util/ExtendedProperties.java#L167-L173 |
netscaler/sdx_nitro | src/main/java/com/citrix/sdx/nitro/resource/config/mps/snmp_trap.java | snmp_trap.update | public static snmp_trap update(nitro_service client, snmp_trap resource) throws Exception {
"""
<pre>
Use this operation to modify snmp trap destination.
</pre>
"""
resource.validate("modify");
return ((snmp_trap[]) resource.update_resource(client))[0];
} | java | public static snmp_trap update(nitro_service client, snmp_trap resource) throws Exception
{
resource.validate("modify");
return ((snmp_trap[]) resource.update_resource(client))[0];
} | [
"public",
"static",
"snmp_trap",
"update",
"(",
"nitro_service",
"client",
",",
"snmp_trap",
"resource",
")",
"throws",
"Exception",
"{",
"resource",
".",
"validate",
"(",
"\"modify\"",
")",
";",
"return",
"(",
"(",
"snmp_trap",
"[",
"]",
")",
"resource",
".",
"update_resource",
"(",
"client",
")",
")",
"[",
"0",
"]",
";",
"}"
] | <pre>
Use this operation to modify snmp trap destination.
</pre> | [
"<pre",
">",
"Use",
"this",
"operation",
"to",
"modify",
"snmp",
"trap",
"destination",
".",
"<",
"/",
"pre",
">"
] | train | https://github.com/netscaler/sdx_nitro/blob/c840919f1a8f7c0a5634c0f23d34fa14d1765ff1/src/main/java/com/citrix/sdx/nitro/resource/config/mps/snmp_trap.java#L218-L222 |
TheHortonMachine/hortonmachine | hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/utils/Utility.java | Utility.verifyFeatureKey | private static void verifyFeatureKey( String key, String searchedField, IHMProgressMonitor pm ) {
"""
Verify if there is a key of a FeatureCollections.
@param key
@throws IllegalArgumentException
if the key is null.
"""
if (key == null) {
if (pm != null) {
pm.errorMessage(msg.message("trentoP.error.featureKey") + searchedField);
}
throw new IllegalArgumentException(msg.message("trentoP.error.featureKey") + searchedField);
}
} | java | private static void verifyFeatureKey( String key, String searchedField, IHMProgressMonitor pm ) {
if (key == null) {
if (pm != null) {
pm.errorMessage(msg.message("trentoP.error.featureKey") + searchedField);
}
throw new IllegalArgumentException(msg.message("trentoP.error.featureKey") + searchedField);
}
} | [
"private",
"static",
"void",
"verifyFeatureKey",
"(",
"String",
"key",
",",
"String",
"searchedField",
",",
"IHMProgressMonitor",
"pm",
")",
"{",
"if",
"(",
"key",
"==",
"null",
")",
"{",
"if",
"(",
"pm",
"!=",
"null",
")",
"{",
"pm",
".",
"errorMessage",
"(",
"msg",
".",
"message",
"(",
"\"trentoP.error.featureKey\"",
")",
"+",
"searchedField",
")",
";",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
"msg",
".",
"message",
"(",
"\"trentoP.error.featureKey\"",
")",
"+",
"searchedField",
")",
";",
"}",
"}"
] | Verify if there is a key of a FeatureCollections.
@param key
@throws IllegalArgumentException
if the key is null. | [
"Verify",
"if",
"there",
"is",
"a",
"key",
"of",
"a",
"FeatureCollections",
"."
] | train | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/hmachine/src/main/java/org/hortonmachine/hmachine/modules/networktools/trento_p/utils/Utility.java#L395-L403 |
dkpro/dkpro-jwpl | de.tudarmstadt.ukp.wikipedia.util/src/main/java/de/tudarmstadt/ukp/wikipedia/util/templates/WikipediaTemplateInfo.java | WikipediaTemplateInfo.revisionContainsTemplateNames | public boolean revisionContainsTemplateNames(int revId, List<String> templateNames) throws WikiApiException {
"""
Determines whether a given revision contains a given template name
@param revId
@param templateNames a list of template names
@return
@throws WikiApiException
"""
List<String> tplList = getTemplateNamesFromRevision(revId);
for(String tpl:tplList){
for(String templateName:templateNames){
if(tpl.equalsIgnoreCase(templateName)){
return true;
}
}
}
return false;
} | java | public boolean revisionContainsTemplateNames(int revId, List<String> templateNames) throws WikiApiException{
List<String> tplList = getTemplateNamesFromRevision(revId);
for(String tpl:tplList){
for(String templateName:templateNames){
if(tpl.equalsIgnoreCase(templateName)){
return true;
}
}
}
return false;
} | [
"public",
"boolean",
"revisionContainsTemplateNames",
"(",
"int",
"revId",
",",
"List",
"<",
"String",
">",
"templateNames",
")",
"throws",
"WikiApiException",
"{",
"List",
"<",
"String",
">",
"tplList",
"=",
"getTemplateNamesFromRevision",
"(",
"revId",
")",
";",
"for",
"(",
"String",
"tpl",
":",
"tplList",
")",
"{",
"for",
"(",
"String",
"templateName",
":",
"templateNames",
")",
"{",
"if",
"(",
"tpl",
".",
"equalsIgnoreCase",
"(",
"templateName",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | Determines whether a given revision contains a given template name
@param revId
@param templateNames a list of template names
@return
@throws WikiApiException | [
"Determines",
"whether",
"a",
"given",
"revision",
"contains",
"a",
"given",
"template",
"name"
] | train | https://github.com/dkpro/dkpro-jwpl/blob/0a0304b6a0aa13acc18838957994e06dd4613a58/de.tudarmstadt.ukp.wikipedia.util/src/main/java/de/tudarmstadt/ukp/wikipedia/util/templates/WikipediaTemplateInfo.java#L1265-L1275 |
mozilla/rhino | src/org/mozilla/javascript/RhinoException.java | RhinoException.getScriptStackTrace | public String getScriptStackTrace(int limit, String functionName) {
"""
Get a string representing the script stack of this exception.
If optimization is enabled, this includes java stack elements
whose source and method names suggest they have been generated
by the Rhino script compiler.
The optional "limit" parameter limits the number of stack frames returned.
The "functionName" parameter will exclude any stack frames "below" the
specified function on the stack.
@param limit the number of stack frames returned
@param functionName the name of a function on the stack -- frames below it will be ignored
@return a script stack dump
@since 1.8.0
"""
ScriptStackElement[] stack = getScriptStack(limit, functionName);
return formatStackTrace(stack, details());
} | java | public String getScriptStackTrace(int limit, String functionName)
{
ScriptStackElement[] stack = getScriptStack(limit, functionName);
return formatStackTrace(stack, details());
} | [
"public",
"String",
"getScriptStackTrace",
"(",
"int",
"limit",
",",
"String",
"functionName",
")",
"{",
"ScriptStackElement",
"[",
"]",
"stack",
"=",
"getScriptStack",
"(",
"limit",
",",
"functionName",
")",
";",
"return",
"formatStackTrace",
"(",
"stack",
",",
"details",
"(",
")",
")",
";",
"}"
] | Get a string representing the script stack of this exception.
If optimization is enabled, this includes java stack elements
whose source and method names suggest they have been generated
by the Rhino script compiler.
The optional "limit" parameter limits the number of stack frames returned.
The "functionName" parameter will exclude any stack frames "below" the
specified function on the stack.
@param limit the number of stack frames returned
@param functionName the name of a function on the stack -- frames below it will be ignored
@return a script stack dump
@since 1.8.0 | [
"Get",
"a",
"string",
"representing",
"the",
"script",
"stack",
"of",
"this",
"exception",
".",
"If",
"optimization",
"is",
"enabled",
"this",
"includes",
"java",
"stack",
"elements",
"whose",
"source",
"and",
"method",
"names",
"suggest",
"they",
"have",
"been",
"generated",
"by",
"the",
"Rhino",
"script",
"compiler",
".",
"The",
"optional",
"limit",
"parameter",
"limits",
"the",
"number",
"of",
"stack",
"frames",
"returned",
".",
"The",
"functionName",
"parameter",
"will",
"exclude",
"any",
"stack",
"frames",
"below",
"the",
"specified",
"function",
"on",
"the",
"stack",
"."
] | train | https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/RhinoException.java#L221-L225 |
landawn/AbacusUtil | src/com/landawn/abacus/util/JdbcUtil.java | JdbcUtil.prepareQuery | public static PreparedQuery prepareQuery(final Connection conn, final String sql, final boolean autoGeneratedKeys) throws SQLException {
"""
Never write below code because it will definitely cause {@code Connection} leak:
<pre>
<code>
JdbcUtil.prepareQuery(dataSource.getConnection(), sql, autoGeneratedKeys);
</code>
</pre>
@param conn the specified {@code conn} won't be close after this query is executed.
@param sql
@param autoGeneratedKeys
@return
@throws SQLException
"""
return new PreparedQuery(conn.prepareStatement(sql, autoGeneratedKeys ? Statement.RETURN_GENERATED_KEYS : Statement.NO_GENERATED_KEYS));
} | java | public static PreparedQuery prepareQuery(final Connection conn, final String sql, final boolean autoGeneratedKeys) throws SQLException {
return new PreparedQuery(conn.prepareStatement(sql, autoGeneratedKeys ? Statement.RETURN_GENERATED_KEYS : Statement.NO_GENERATED_KEYS));
} | [
"public",
"static",
"PreparedQuery",
"prepareQuery",
"(",
"final",
"Connection",
"conn",
",",
"final",
"String",
"sql",
",",
"final",
"boolean",
"autoGeneratedKeys",
")",
"throws",
"SQLException",
"{",
"return",
"new",
"PreparedQuery",
"(",
"conn",
".",
"prepareStatement",
"(",
"sql",
",",
"autoGeneratedKeys",
"?",
"Statement",
".",
"RETURN_GENERATED_KEYS",
":",
"Statement",
".",
"NO_GENERATED_KEYS",
")",
")",
";",
"}"
] | Never write below code because it will definitely cause {@code Connection} leak:
<pre>
<code>
JdbcUtil.prepareQuery(dataSource.getConnection(), sql, autoGeneratedKeys);
</code>
</pre>
@param conn the specified {@code conn} won't be close after this query is executed.
@param sql
@param autoGeneratedKeys
@return
@throws SQLException | [
"Never",
"write",
"below",
"code",
"because",
"it",
"will",
"definitely",
"cause",
"{",
"@code",
"Connection",
"}",
"leak",
":",
"<pre",
">",
"<code",
">",
"JdbcUtil",
".",
"prepareQuery",
"(",
"dataSource",
".",
"getConnection",
"()",
"sql",
"autoGeneratedKeys",
")",
";",
"<",
"/",
"code",
">",
"<",
"/",
"pre",
">"
] | train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/util/JdbcUtil.java#L1291-L1293 |
drewnoakes/metadata-extractor | Source/com/drew/lang/Rational.java | Rational.getSimplifiedInstance | @NotNull
public Rational getSimplifiedInstance() {
"""
<p>
Simplifies the representation of this {@link Rational} number.</p>
<p>
For example, 5/10 simplifies to 1/2 because both Numerator
and Denominator share a common factor of 5.</p>
<p>
Uses the Euclidean Algorithm to find the greatest common divisor.</p>
@return A simplified instance if one exists, otherwise a copy of the original value.
"""
long gcd = GCD(_numerator, _denominator);
return new Rational(_numerator / gcd, _denominator / gcd);
} | java | @NotNull
public Rational getSimplifiedInstance()
{
long gcd = GCD(_numerator, _denominator);
return new Rational(_numerator / gcd, _denominator / gcd);
} | [
"@",
"NotNull",
"public",
"Rational",
"getSimplifiedInstance",
"(",
")",
"{",
"long",
"gcd",
"=",
"GCD",
"(",
"_numerator",
",",
"_denominator",
")",
";",
"return",
"new",
"Rational",
"(",
"_numerator",
"/",
"gcd",
",",
"_denominator",
"/",
"gcd",
")",
";",
"}"
] | <p>
Simplifies the representation of this {@link Rational} number.</p>
<p>
For example, 5/10 simplifies to 1/2 because both Numerator
and Denominator share a common factor of 5.</p>
<p>
Uses the Euclidean Algorithm to find the greatest common divisor.</p>
@return A simplified instance if one exists, otherwise a copy of the original value. | [
"<p",
">",
"Simplifies",
"the",
"representation",
"of",
"this",
"{",
"@link",
"Rational",
"}",
"number",
".",
"<",
"/",
"p",
">",
"<p",
">",
"For",
"example",
"5",
"/",
"10",
"simplifies",
"to",
"1",
"/",
"2",
"because",
"both",
"Numerator",
"and",
"Denominator",
"share",
"a",
"common",
"factor",
"of",
"5",
".",
"<",
"/",
"p",
">",
"<p",
">",
"Uses",
"the",
"Euclidean",
"Algorithm",
"to",
"find",
"the",
"greatest",
"common",
"divisor",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/drewnoakes/metadata-extractor/blob/a958e0b61b50e590731b3be1dca8df8e21ebd43c/Source/com/drew/lang/Rational.java#L298-L304 |
dropbox/dropbox-sdk-java | examples/upload-file/src/main/java/com/dropbox/core/examples/upload_file/Main.java | Main.uploadFile | private static void uploadFile(DbxClientV2 dbxClient, File localFile, String dropboxPath) {
"""
Uploads a file in a single request. This approach is preferred for small files since it
eliminates unnecessary round-trips to the servers.
@param dbxClient Dropbox user authenticated client
@param localFIle local file to upload
@param dropboxPath Where to upload the file to within Dropbox
"""
try (InputStream in = new FileInputStream(localFile)) {
ProgressListener progressListener = l -> printProgress(l, localFile.length());
FileMetadata metadata = dbxClient.files().uploadBuilder(dropboxPath)
.withMode(WriteMode.ADD)
.withClientModified(new Date(localFile.lastModified()))
.uploadAndFinish(in, progressListener);
System.out.println(metadata.toStringMultiline());
} catch (UploadErrorException ex) {
System.err.println("Error uploading to Dropbox: " + ex.getMessage());
System.exit(1);
} catch (DbxException ex) {
System.err.println("Error uploading to Dropbox: " + ex.getMessage());
System.exit(1);
} catch (IOException ex) {
System.err.println("Error reading from file \"" + localFile + "\": " + ex.getMessage());
System.exit(1);
}
} | java | private static void uploadFile(DbxClientV2 dbxClient, File localFile, String dropboxPath) {
try (InputStream in = new FileInputStream(localFile)) {
ProgressListener progressListener = l -> printProgress(l, localFile.length());
FileMetadata metadata = dbxClient.files().uploadBuilder(dropboxPath)
.withMode(WriteMode.ADD)
.withClientModified(new Date(localFile.lastModified()))
.uploadAndFinish(in, progressListener);
System.out.println(metadata.toStringMultiline());
} catch (UploadErrorException ex) {
System.err.println("Error uploading to Dropbox: " + ex.getMessage());
System.exit(1);
} catch (DbxException ex) {
System.err.println("Error uploading to Dropbox: " + ex.getMessage());
System.exit(1);
} catch (IOException ex) {
System.err.println("Error reading from file \"" + localFile + "\": " + ex.getMessage());
System.exit(1);
}
} | [
"private",
"static",
"void",
"uploadFile",
"(",
"DbxClientV2",
"dbxClient",
",",
"File",
"localFile",
",",
"String",
"dropboxPath",
")",
"{",
"try",
"(",
"InputStream",
"in",
"=",
"new",
"FileInputStream",
"(",
"localFile",
")",
")",
"{",
"ProgressListener",
"progressListener",
"=",
"l",
"->",
"printProgress",
"(",
"l",
",",
"localFile",
".",
"length",
"(",
")",
")",
";",
"FileMetadata",
"metadata",
"=",
"dbxClient",
".",
"files",
"(",
")",
".",
"uploadBuilder",
"(",
"dropboxPath",
")",
".",
"withMode",
"(",
"WriteMode",
".",
"ADD",
")",
".",
"withClientModified",
"(",
"new",
"Date",
"(",
"localFile",
".",
"lastModified",
"(",
")",
")",
")",
".",
"uploadAndFinish",
"(",
"in",
",",
"progressListener",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"metadata",
".",
"toStringMultiline",
"(",
")",
")",
";",
"}",
"catch",
"(",
"UploadErrorException",
"ex",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"Error uploading to Dropbox: \"",
"+",
"ex",
".",
"getMessage",
"(",
")",
")",
";",
"System",
".",
"exit",
"(",
"1",
")",
";",
"}",
"catch",
"(",
"DbxException",
"ex",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"Error uploading to Dropbox: \"",
"+",
"ex",
".",
"getMessage",
"(",
")",
")",
";",
"System",
".",
"exit",
"(",
"1",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"Error reading from file \\\"\"",
"+",
"localFile",
"+",
"\"\\\": \"",
"+",
"ex",
".",
"getMessage",
"(",
")",
")",
";",
"System",
".",
"exit",
"(",
"1",
")",
";",
"}",
"}"
] | Uploads a file in a single request. This approach is preferred for small files since it
eliminates unnecessary round-trips to the servers.
@param dbxClient Dropbox user authenticated client
@param localFIle local file to upload
@param dropboxPath Where to upload the file to within Dropbox | [
"Uploads",
"a",
"file",
"in",
"a",
"single",
"request",
".",
"This",
"approach",
"is",
"preferred",
"for",
"small",
"files",
"since",
"it",
"eliminates",
"unnecessary",
"round",
"-",
"trips",
"to",
"the",
"servers",
"."
] | train | https://github.com/dropbox/dropbox-sdk-java/blob/d86157005fad6233c18b4b0f10f00b8d9d56ae92/examples/upload-file/src/main/java/com/dropbox/core/examples/upload_file/Main.java#L48-L68 |
ThreeTen/threetenbp | src/main/java/org/threeten/bp/format/DateTimeFormatterBuilder.java | DateTimeFormatterBuilder.appendInternal | private int appendInternal(DateTimePrinterParser pp) {
"""
Appends a printer and/or parser to the internal list handling padding.
@param pp the printer-parser to add, not null
@return the index into the active parsers list
"""
Jdk8Methods.requireNonNull(pp, "pp");
if (active.padNextWidth > 0) {
if (pp != null) {
pp = new PadPrinterParserDecorator(pp, active.padNextWidth, active.padNextChar);
}
active.padNextWidth = 0;
active.padNextChar = 0;
}
active.printerParsers.add(pp);
active.valueParserIndex = -1;
return active.printerParsers.size() - 1;
} | java | private int appendInternal(DateTimePrinterParser pp) {
Jdk8Methods.requireNonNull(pp, "pp");
if (active.padNextWidth > 0) {
if (pp != null) {
pp = new PadPrinterParserDecorator(pp, active.padNextWidth, active.padNextChar);
}
active.padNextWidth = 0;
active.padNextChar = 0;
}
active.printerParsers.add(pp);
active.valueParserIndex = -1;
return active.printerParsers.size() - 1;
} | [
"private",
"int",
"appendInternal",
"(",
"DateTimePrinterParser",
"pp",
")",
"{",
"Jdk8Methods",
".",
"requireNonNull",
"(",
"pp",
",",
"\"pp\"",
")",
";",
"if",
"(",
"active",
".",
"padNextWidth",
">",
"0",
")",
"{",
"if",
"(",
"pp",
"!=",
"null",
")",
"{",
"pp",
"=",
"new",
"PadPrinterParserDecorator",
"(",
"pp",
",",
"active",
".",
"padNextWidth",
",",
"active",
".",
"padNextChar",
")",
";",
"}",
"active",
".",
"padNextWidth",
"=",
"0",
";",
"active",
".",
"padNextChar",
"=",
"0",
";",
"}",
"active",
".",
"printerParsers",
".",
"add",
"(",
"pp",
")",
";",
"active",
".",
"valueParserIndex",
"=",
"-",
"1",
";",
"return",
"active",
".",
"printerParsers",
".",
"size",
"(",
")",
"-",
"1",
";",
"}"
] | Appends a printer and/or parser to the internal list handling padding.
@param pp the printer-parser to add, not null
@return the index into the active parsers list | [
"Appends",
"a",
"printer",
"and",
"/",
"or",
"parser",
"to",
"the",
"internal",
"list",
"handling",
"padding",
"."
] | train | https://github.com/ThreeTen/threetenbp/blob/5f05b649f89f205aabd96b2f83c36796ec616fe6/src/main/java/org/threeten/bp/format/DateTimeFormatterBuilder.java#L1834-L1846 |
boncey/Flickr4Java | src/main/java/com/flickr4java/flickr/util/UrlUtilities.java | UrlUtilities.createBuddyIconUrl | @Deprecated
public static String createBuddyIconUrl(int iconFarm, int iconServer, String id) {
"""
Construct the BuddyIconUrl with {@code http} scheme.
<p>
If none available, return the <a href="http://www.flickr.com/images/buddyicon.jpg">default</a>, or an URL assembled from farm, iconserver and nsid.
@see <a href="http://flickr.com/services/api/misc.buddyicons.html">Flickr Documentation</a>
@param iconFarm
@param iconServer
@param id
@return The BuddyIconUrl
@deprecated use {@link #createSecureBuddyIconUrl(int, int, java.lang.String) }
"""
return createBuddyIconUrl("http", iconFarm, iconServer, id);
} | java | @Deprecated
public static String createBuddyIconUrl(int iconFarm, int iconServer, String id) {
return createBuddyIconUrl("http", iconFarm, iconServer, id);
} | [
"@",
"Deprecated",
"public",
"static",
"String",
"createBuddyIconUrl",
"(",
"int",
"iconFarm",
",",
"int",
"iconServer",
",",
"String",
"id",
")",
"{",
"return",
"createBuddyIconUrl",
"(",
"\"http\"",
",",
"iconFarm",
",",
"iconServer",
",",
"id",
")",
";",
"}"
] | Construct the BuddyIconUrl with {@code http} scheme.
<p>
If none available, return the <a href="http://www.flickr.com/images/buddyicon.jpg">default</a>, or an URL assembled from farm, iconserver and nsid.
@see <a href="http://flickr.com/services/api/misc.buddyicons.html">Flickr Documentation</a>
@param iconFarm
@param iconServer
@param id
@return The BuddyIconUrl
@deprecated use {@link #createSecureBuddyIconUrl(int, int, java.lang.String) } | [
"Construct",
"the",
"BuddyIconUrl",
"with",
"{",
"@code",
"http",
"}",
"scheme",
".",
"<p",
">",
"If",
"none",
"available",
"return",
"the",
"<a",
"href",
"=",
"http",
":",
"//",
"www",
".",
"flickr",
".",
"com",
"/",
"images",
"/",
"buddyicon",
".",
"jpg",
">",
"default<",
"/",
"a",
">",
"or",
"an",
"URL",
"assembled",
"from",
"farm",
"iconserver",
"and",
"nsid",
"."
] | train | https://github.com/boncey/Flickr4Java/blob/f66987ba0e360e5fb7730efbbb8c51f3d978fc25/src/main/java/com/flickr4java/flickr/util/UrlUtilities.java#L182-L185 |
hazelcast/hazelcast-kubernetes | src/main/java/com/hazelcast/kubernetes/RestClient.java | RestClient.buildSslSocketFactory | private SSLSocketFactory buildSslSocketFactory() {
"""
Builds SSL Socket Factory with the public CA Certificate from Kubernetes Master.
"""
try {
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(null, null);
keyStore.setCertificateEntry("ca", generateCertificate());
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(keyStore);
SSLContext context = SSLContext.getInstance("TLSv1.2");
context.init(null, tmf.getTrustManagers(), null);
return context.getSocketFactory();
} catch (Exception e) {
throw new KubernetesClientException("Failure in generating SSLSocketFactory", e);
}
} | java | private SSLSocketFactory buildSslSocketFactory() {
try {
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(null, null);
keyStore.setCertificateEntry("ca", generateCertificate());
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(keyStore);
SSLContext context = SSLContext.getInstance("TLSv1.2");
context.init(null, tmf.getTrustManagers(), null);
return context.getSocketFactory();
} catch (Exception e) {
throw new KubernetesClientException("Failure in generating SSLSocketFactory", e);
}
} | [
"private",
"SSLSocketFactory",
"buildSslSocketFactory",
"(",
")",
"{",
"try",
"{",
"KeyStore",
"keyStore",
"=",
"KeyStore",
".",
"getInstance",
"(",
"KeyStore",
".",
"getDefaultType",
"(",
")",
")",
";",
"keyStore",
".",
"load",
"(",
"null",
",",
"null",
")",
";",
"keyStore",
".",
"setCertificateEntry",
"(",
"\"ca\"",
",",
"generateCertificate",
"(",
")",
")",
";",
"TrustManagerFactory",
"tmf",
"=",
"TrustManagerFactory",
".",
"getInstance",
"(",
"TrustManagerFactory",
".",
"getDefaultAlgorithm",
"(",
")",
")",
";",
"tmf",
".",
"init",
"(",
"keyStore",
")",
";",
"SSLContext",
"context",
"=",
"SSLContext",
".",
"getInstance",
"(",
"\"TLSv1.2\"",
")",
";",
"context",
".",
"init",
"(",
"null",
",",
"tmf",
".",
"getTrustManagers",
"(",
")",
",",
"null",
")",
";",
"return",
"context",
".",
"getSocketFactory",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"KubernetesClientException",
"(",
"\"Failure in generating SSLSocketFactory\"",
",",
"e",
")",
";",
"}",
"}"
] | Builds SSL Socket Factory with the public CA Certificate from Kubernetes Master. | [
"Builds",
"SSL",
"Socket",
"Factory",
"with",
"the",
"public",
"CA",
"Certificate",
"from",
"Kubernetes",
"Master",
"."
] | train | https://github.com/hazelcast/hazelcast-kubernetes/blob/b1144067addf56d1446a9e1007f5cb3290b86815/src/main/java/com/hazelcast/kubernetes/RestClient.java#L174-L190 |
OpenTSDB/opentsdb | src/tools/TreeSync.java | TreeSync.purgeTree | public int purgeTree(final int tree_id, final boolean delete_definition)
throws Exception {
"""
Attempts to delete all data generated by the given tree, and optionally,
the tree definition itself.
@param tree_id The tree with data to delete
@param delete_definition Whether or not the tree definition itself should
be removed from the system
@return 0 if completed successfully, something else if an error occurred
"""
if (delete_definition) {
LOG.info("Deleting tree branches and definition for: " + tree_id);
} else {
LOG.info("Deleting tree branches for: " + tree_id);
}
Tree.deleteTree(tsdb, tree_id, delete_definition).joinUninterruptibly();
LOG.info("Completed tree deletion for: " + tree_id);
return 0;
} | java | public int purgeTree(final int tree_id, final boolean delete_definition)
throws Exception {
if (delete_definition) {
LOG.info("Deleting tree branches and definition for: " + tree_id);
} else {
LOG.info("Deleting tree branches for: " + tree_id);
}
Tree.deleteTree(tsdb, tree_id, delete_definition).joinUninterruptibly();
LOG.info("Completed tree deletion for: " + tree_id);
return 0;
} | [
"public",
"int",
"purgeTree",
"(",
"final",
"int",
"tree_id",
",",
"final",
"boolean",
"delete_definition",
")",
"throws",
"Exception",
"{",
"if",
"(",
"delete_definition",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Deleting tree branches and definition for: \"",
"+",
"tree_id",
")",
";",
"}",
"else",
"{",
"LOG",
".",
"info",
"(",
"\"Deleting tree branches for: \"",
"+",
"tree_id",
")",
";",
"}",
"Tree",
".",
"deleteTree",
"(",
"tsdb",
",",
"tree_id",
",",
"delete_definition",
")",
".",
"joinUninterruptibly",
"(",
")",
";",
"LOG",
".",
"info",
"(",
"\"Completed tree deletion for: \"",
"+",
"tree_id",
")",
";",
"return",
"0",
";",
"}"
] | Attempts to delete all data generated by the given tree, and optionally,
the tree definition itself.
@param tree_id The tree with data to delete
@param delete_definition Whether or not the tree definition itself should
be removed from the system
@return 0 if completed successfully, something else if an error occurred | [
"Attempts",
"to",
"delete",
"all",
"data",
"generated",
"by",
"the",
"given",
"tree",
"and",
"optionally",
"the",
"tree",
"definition",
"itself",
"."
] | train | https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tools/TreeSync.java#L324-L334 |
hyperledger/fabric-sdk-java | src/main/java/org/hyperledger/fabric_ca/sdk/HFCAClient.java | HFCAClient.getHFCAAffiliations | public HFCAAffiliation getHFCAAffiliations(User registrar) throws AffiliationException, InvalidArgumentException {
"""
gets all affiliations that the registrar is allowed to see
@param registrar The identity of the registrar (i.e. who is performing the registration).
@return The affiliations that were requested
@throws AffiliationException if getting all affiliations fails
@throws InvalidArgumentException
"""
if (cryptoSuite == null) {
throw new InvalidArgumentException("Crypto primitives not set.");
}
if (registrar == null) {
throw new InvalidArgumentException("Registrar should be a valid member");
}
logger.debug(format("affiliations url: %s, registrar: %s", url, registrar.getName()));
try {
JsonObject result = httpGet(HFCAAffiliation.HFCA_AFFILIATION, registrar);
HFCAAffiliation affiliations = new HFCAAffiliation(result);
logger.debug(format("affiliations url: %s, registrar: %s done.", url, registrar));
return affiliations;
} catch (HTTPException e) {
String msg = format("[HTTP Status Code: %d] - Error while getting all affiliations from url '%s': %s", e.getStatusCode(), url, e.getMessage());
AffiliationException affiliationException = new AffiliationException(msg, e);
logger.error(msg);
throw affiliationException;
} catch (Exception e) {
String msg = format("Error while getting all affiliations from url '%s': %s", url, e.getMessage());
AffiliationException affiliationException = new AffiliationException(msg, e);
logger.error(msg);
throw affiliationException;
}
} | java | public HFCAAffiliation getHFCAAffiliations(User registrar) throws AffiliationException, InvalidArgumentException {
if (cryptoSuite == null) {
throw new InvalidArgumentException("Crypto primitives not set.");
}
if (registrar == null) {
throw new InvalidArgumentException("Registrar should be a valid member");
}
logger.debug(format("affiliations url: %s, registrar: %s", url, registrar.getName()));
try {
JsonObject result = httpGet(HFCAAffiliation.HFCA_AFFILIATION, registrar);
HFCAAffiliation affiliations = new HFCAAffiliation(result);
logger.debug(format("affiliations url: %s, registrar: %s done.", url, registrar));
return affiliations;
} catch (HTTPException e) {
String msg = format("[HTTP Status Code: %d] - Error while getting all affiliations from url '%s': %s", e.getStatusCode(), url, e.getMessage());
AffiliationException affiliationException = new AffiliationException(msg, e);
logger.error(msg);
throw affiliationException;
} catch (Exception e) {
String msg = format("Error while getting all affiliations from url '%s': %s", url, e.getMessage());
AffiliationException affiliationException = new AffiliationException(msg, e);
logger.error(msg);
throw affiliationException;
}
} | [
"public",
"HFCAAffiliation",
"getHFCAAffiliations",
"(",
"User",
"registrar",
")",
"throws",
"AffiliationException",
",",
"InvalidArgumentException",
"{",
"if",
"(",
"cryptoSuite",
"==",
"null",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Crypto primitives not set.\"",
")",
";",
"}",
"if",
"(",
"registrar",
"==",
"null",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Registrar should be a valid member\"",
")",
";",
"}",
"logger",
".",
"debug",
"(",
"format",
"(",
"\"affiliations url: %s, registrar: %s\"",
",",
"url",
",",
"registrar",
".",
"getName",
"(",
")",
")",
")",
";",
"try",
"{",
"JsonObject",
"result",
"=",
"httpGet",
"(",
"HFCAAffiliation",
".",
"HFCA_AFFILIATION",
",",
"registrar",
")",
";",
"HFCAAffiliation",
"affiliations",
"=",
"new",
"HFCAAffiliation",
"(",
"result",
")",
";",
"logger",
".",
"debug",
"(",
"format",
"(",
"\"affiliations url: %s, registrar: %s done.\"",
",",
"url",
",",
"registrar",
")",
")",
";",
"return",
"affiliations",
";",
"}",
"catch",
"(",
"HTTPException",
"e",
")",
"{",
"String",
"msg",
"=",
"format",
"(",
"\"[HTTP Status Code: %d] - Error while getting all affiliations from url '%s': %s\"",
",",
"e",
".",
"getStatusCode",
"(",
")",
",",
"url",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"AffiliationException",
"affiliationException",
"=",
"new",
"AffiliationException",
"(",
"msg",
",",
"e",
")",
";",
"logger",
".",
"error",
"(",
"msg",
")",
";",
"throw",
"affiliationException",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"String",
"msg",
"=",
"format",
"(",
"\"Error while getting all affiliations from url '%s': %s\"",
",",
"url",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"AffiliationException",
"affiliationException",
"=",
"new",
"AffiliationException",
"(",
"msg",
",",
"e",
")",
";",
"logger",
".",
"error",
"(",
"msg",
")",
";",
"throw",
"affiliationException",
";",
"}",
"}"
] | gets all affiliations that the registrar is allowed to see
@param registrar The identity of the registrar (i.e. who is performing the registration).
@return The affiliations that were requested
@throws AffiliationException if getting all affiliations fails
@throws InvalidArgumentException | [
"gets",
"all",
"affiliations",
"that",
"the",
"registrar",
"is",
"allowed",
"to",
"see"
] | train | https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric_ca/sdk/HFCAClient.java#L1055-L1084 |
netty/netty | codec-http/src/main/java/io/netty/handler/codec/http/cors/CorsConfigBuilder.java | CorsConfigBuilder.preflightResponseHeader | public <T> CorsConfigBuilder preflightResponseHeader(final CharSequence name, final Iterable<T> value) {
"""
Returns HTTP response headers that should be added to a CORS preflight response.
An intermediary like a load balancer might require that a CORS preflight request
have certain headers set. This enables such headers to be added.
@param name the name of the HTTP header.
@param value the values for the HTTP header.
@param <T> the type of values that the Iterable contains.
@return {@link CorsConfigBuilder} to support method chaining.
"""
preflightHeaders.put(name, new ConstantValueGenerator(value));
return this;
} | java | public <T> CorsConfigBuilder preflightResponseHeader(final CharSequence name, final Iterable<T> value) {
preflightHeaders.put(name, new ConstantValueGenerator(value));
return this;
} | [
"public",
"<",
"T",
">",
"CorsConfigBuilder",
"preflightResponseHeader",
"(",
"final",
"CharSequence",
"name",
",",
"final",
"Iterable",
"<",
"T",
">",
"value",
")",
"{",
"preflightHeaders",
".",
"put",
"(",
"name",
",",
"new",
"ConstantValueGenerator",
"(",
"value",
")",
")",
";",
"return",
"this",
";",
"}"
] | Returns HTTP response headers that should be added to a CORS preflight response.
An intermediary like a load balancer might require that a CORS preflight request
have certain headers set. This enables such headers to be added.
@param name the name of the HTTP header.
@param value the values for the HTTP header.
@param <T> the type of values that the Iterable contains.
@return {@link CorsConfigBuilder} to support method chaining. | [
"Returns",
"HTTP",
"response",
"headers",
"that",
"should",
"be",
"added",
"to",
"a",
"CORS",
"preflight",
"response",
"."
] | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-http/src/main/java/io/netty/handler/codec/http/cors/CorsConfigBuilder.java#L303-L306 |
phax/ph-oton | ph-oton-core/src/main/java/com/helger/photon/core/menu/ui/MenuRendererCallback.java | MenuRendererCallback.createRenderedMenu | @Nonnull
public static <T extends IHCList <T, HCLI>> T createRenderedMenu (@Nonnull final ILayoutExecutionContext aLEC,
@Nonnull final ISupplier <T> aFactory,
@Nonnull final IMenuItemRenderer <T> aRenderer,
@Nonnull final ICommonsMap <String, Boolean> aDisplayMenuItemIDs) {
"""
Render the whole menu
@param aLEC
The current layout execution context. Required for cookie-less
handling. May not be <code>null</code>.
@param aFactory
The factory to be used to create nodes of type T. May not be
<code>null</code>.
@param aRenderer
The renderer to use
@param aDisplayMenuItemIDs
The menu items to display as a map from menu item ID to expanded
state
@return Never <code>null</code>.
@param <T>
HC list type to be instantiated
"""
return createRenderedMenu (aLEC, aFactory, aLEC.getMenuTree ().getRootItem (), aRenderer, aDisplayMenuItemIDs);
} | java | @Nonnull
public static <T extends IHCList <T, HCLI>> T createRenderedMenu (@Nonnull final ILayoutExecutionContext aLEC,
@Nonnull final ISupplier <T> aFactory,
@Nonnull final IMenuItemRenderer <T> aRenderer,
@Nonnull final ICommonsMap <String, Boolean> aDisplayMenuItemIDs)
{
return createRenderedMenu (aLEC, aFactory, aLEC.getMenuTree ().getRootItem (), aRenderer, aDisplayMenuItemIDs);
} | [
"@",
"Nonnull",
"public",
"static",
"<",
"T",
"extends",
"IHCList",
"<",
"T",
",",
"HCLI",
">",
">",
"T",
"createRenderedMenu",
"(",
"@",
"Nonnull",
"final",
"ILayoutExecutionContext",
"aLEC",
",",
"@",
"Nonnull",
"final",
"ISupplier",
"<",
"T",
">",
"aFactory",
",",
"@",
"Nonnull",
"final",
"IMenuItemRenderer",
"<",
"T",
">",
"aRenderer",
",",
"@",
"Nonnull",
"final",
"ICommonsMap",
"<",
"String",
",",
"Boolean",
">",
"aDisplayMenuItemIDs",
")",
"{",
"return",
"createRenderedMenu",
"(",
"aLEC",
",",
"aFactory",
",",
"aLEC",
".",
"getMenuTree",
"(",
")",
".",
"getRootItem",
"(",
")",
",",
"aRenderer",
",",
"aDisplayMenuItemIDs",
")",
";",
"}"
] | Render the whole menu
@param aLEC
The current layout execution context. Required for cookie-less
handling. May not be <code>null</code>.
@param aFactory
The factory to be used to create nodes of type T. May not be
<code>null</code>.
@param aRenderer
The renderer to use
@param aDisplayMenuItemIDs
The menu items to display as a map from menu item ID to expanded
state
@return Never <code>null</code>.
@param <T>
HC list type to be instantiated | [
"Render",
"the",
"whole",
"menu"
] | train | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-core/src/main/java/com/helger/photon/core/menu/ui/MenuRendererCallback.java#L290-L297 |
Waikato/moa | moa/src/main/java/moa/classifiers/lazy/SAMkNN.java | SAMkNN.clean | private void clean(Instances cleanAgainst, Instances toClean, boolean onlyLast) {
"""
Removes distance-based all instances from the input samples that contradict those in the STM.
"""
if (cleanAgainst.numInstances() > this.kOption.getValue() && toClean.numInstances() > 0){
if (onlyLast){
cleanSingle(cleanAgainst, (cleanAgainst.numInstances()-1), toClean);
}else{
for (int i=0; i < cleanAgainst.numInstances(); i++){
cleanSingle(cleanAgainst, i, toClean);
}
}
}
} | java | private void clean(Instances cleanAgainst, Instances toClean, boolean onlyLast) {
if (cleanAgainst.numInstances() > this.kOption.getValue() && toClean.numInstances() > 0){
if (onlyLast){
cleanSingle(cleanAgainst, (cleanAgainst.numInstances()-1), toClean);
}else{
for (int i=0; i < cleanAgainst.numInstances(); i++){
cleanSingle(cleanAgainst, i, toClean);
}
}
}
} | [
"private",
"void",
"clean",
"(",
"Instances",
"cleanAgainst",
",",
"Instances",
"toClean",
",",
"boolean",
"onlyLast",
")",
"{",
"if",
"(",
"cleanAgainst",
".",
"numInstances",
"(",
")",
">",
"this",
".",
"kOption",
".",
"getValue",
"(",
")",
"&&",
"toClean",
".",
"numInstances",
"(",
")",
">",
"0",
")",
"{",
"if",
"(",
"onlyLast",
")",
"{",
"cleanSingle",
"(",
"cleanAgainst",
",",
"(",
"cleanAgainst",
".",
"numInstances",
"(",
")",
"-",
"1",
")",
",",
"toClean",
")",
";",
"}",
"else",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"cleanAgainst",
".",
"numInstances",
"(",
")",
";",
"i",
"++",
")",
"{",
"cleanSingle",
"(",
"cleanAgainst",
",",
"i",
",",
"toClean",
")",
";",
"}",
"}",
"}",
"}"
] | Removes distance-based all instances from the input samples that contradict those in the STM. | [
"Removes",
"distance",
"-",
"based",
"all",
"instances",
"from",
"the",
"input",
"samples",
"that",
"contradict",
"those",
"in",
"the",
"STM",
"."
] | train | https://github.com/Waikato/moa/blob/395982e5100bfe75a3a4d26115462ce2cc74cbb0/moa/src/main/java/moa/classifiers/lazy/SAMkNN.java#L359-L369 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/field/event/ReComputeTimeOffsetHandler.java | ReComputeTimeOffsetHandler.init | public void init(BaseField field, String targetFieldName, DateTimeField fldOtherDate) {
"""
Constructor.
@param field The basefield owner of this listener (usually null and set on setOwner()).
@param iTargetFieldSeq The date field sequence in this owner to use to calc the difference.
@param fldOtherDate The other date field to use in calculating the date difference. If null, uses the current time.
"""
m_fldOtherDate = fldOtherDate;
super.init(field, targetFieldName, null);
} | java | public void init(BaseField field, String targetFieldName, DateTimeField fldOtherDate)
{
m_fldOtherDate = fldOtherDate;
super.init(field, targetFieldName, null);
} | [
"public",
"void",
"init",
"(",
"BaseField",
"field",
",",
"String",
"targetFieldName",
",",
"DateTimeField",
"fldOtherDate",
")",
"{",
"m_fldOtherDate",
"=",
"fldOtherDate",
";",
"super",
".",
"init",
"(",
"field",
",",
"targetFieldName",
",",
"null",
")",
";",
"}"
] | Constructor.
@param field The basefield owner of this listener (usually null and set on setOwner()).
@param iTargetFieldSeq The date field sequence in this owner to use to calc the difference.
@param fldOtherDate The other date field to use in calculating the date difference. If null, uses the current time. | [
"Constructor",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/event/ReComputeTimeOffsetHandler.java#L65-L69 |
cdk/cdk | base/core/src/main/java/org/openscience/cdk/graph/EssentialCycles.java | EssentialCycles.isEssential | private boolean isEssential(final Cycle candidate, final Collection<Cycle> relevant) {
"""
Determines whether the <i>cycle</i> is essential.
@param candidate a cycle which is a member of the MCB
@param relevant relevant cycles of the same length as <i>cycle</i>
@return whether the candidate is essential
"""
// construct an alternative basis with all equal weight relevant cycles
final List<Cycle> alternate = new ArrayList<Cycle>(relevant.size() + basis.size());
final int weight = candidate.length();
for (final Cycle cycle : basis.members()) {
if (cycle.length() < weight) alternate.add(cycle);
}
for (final Cycle cycle : relevant) {
if (!cycle.equals(candidate)) alternate.add(cycle);
}
// if the alternate basis is smaller, the candidate is essential
return BitMatrix.from(alternate).eliminate() < basis.size();
} | java | private boolean isEssential(final Cycle candidate, final Collection<Cycle> relevant) {
// construct an alternative basis with all equal weight relevant cycles
final List<Cycle> alternate = new ArrayList<Cycle>(relevant.size() + basis.size());
final int weight = candidate.length();
for (final Cycle cycle : basis.members()) {
if (cycle.length() < weight) alternate.add(cycle);
}
for (final Cycle cycle : relevant) {
if (!cycle.equals(candidate)) alternate.add(cycle);
}
// if the alternate basis is smaller, the candidate is essential
return BitMatrix.from(alternate).eliminate() < basis.size();
} | [
"private",
"boolean",
"isEssential",
"(",
"final",
"Cycle",
"candidate",
",",
"final",
"Collection",
"<",
"Cycle",
">",
"relevant",
")",
"{",
"// construct an alternative basis with all equal weight relevant cycles",
"final",
"List",
"<",
"Cycle",
">",
"alternate",
"=",
"new",
"ArrayList",
"<",
"Cycle",
">",
"(",
"relevant",
".",
"size",
"(",
")",
"+",
"basis",
".",
"size",
"(",
")",
")",
";",
"final",
"int",
"weight",
"=",
"candidate",
".",
"length",
"(",
")",
";",
"for",
"(",
"final",
"Cycle",
"cycle",
":",
"basis",
".",
"members",
"(",
")",
")",
"{",
"if",
"(",
"cycle",
".",
"length",
"(",
")",
"<",
"weight",
")",
"alternate",
".",
"add",
"(",
"cycle",
")",
";",
"}",
"for",
"(",
"final",
"Cycle",
"cycle",
":",
"relevant",
")",
"{",
"if",
"(",
"!",
"cycle",
".",
"equals",
"(",
"candidate",
")",
")",
"alternate",
".",
"add",
"(",
"cycle",
")",
";",
"}",
"// if the alternate basis is smaller, the candidate is essential",
"return",
"BitMatrix",
".",
"from",
"(",
"alternate",
")",
".",
"eliminate",
"(",
")",
"<",
"basis",
".",
"size",
"(",
")",
";",
"}"
] | Determines whether the <i>cycle</i> is essential.
@param candidate a cycle which is a member of the MCB
@param relevant relevant cycles of the same length as <i>cycle</i>
@return whether the candidate is essential | [
"Determines",
"whether",
"the",
"<i",
">",
"cycle<",
"/",
"i",
">",
"is",
"essential",
"."
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/base/core/src/main/java/org/openscience/cdk/graph/EssentialCycles.java#L171-L186 |
Azure/azure-sdk-for-java | appservice/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/appservice/v2018_02_01/implementation/AppServiceCertificateOrdersInner.java | AppServiceCertificateOrdersInner.resendEmailAsync | public Observable<Void> resendEmailAsync(String resourceGroupName, String certificateOrderName) {
"""
Resend certificate email.
Resend certificate email.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param certificateOrderName Name of the certificate order.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful.
"""
return resendEmailWithServiceResponseAsync(resourceGroupName, certificateOrderName).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | java | public Observable<Void> resendEmailAsync(String resourceGroupName, String certificateOrderName) {
return resendEmailWithServiceResponseAsync(resourceGroupName, certificateOrderName).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Void",
">",
"resendEmailAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"certificateOrderName",
")",
"{",
"return",
"resendEmailWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"certificateOrderName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Void",
">",
",",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
"ServiceResponse",
"<",
"Void",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Resend certificate email.
Resend certificate email.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param certificateOrderName Name of the certificate order.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful. | [
"Resend",
"certificate",
"email",
".",
"Resend",
"certificate",
"email",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/appservice/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/appservice/v2018_02_01/implementation/AppServiceCertificateOrdersInner.java#L1804-L1811 |
apache/groovy | src/main/java/org/codehaus/groovy/transform/trait/Traits.java | Traits.getAsType | @SuppressWarnings("unchecked")
public static <T> T getAsType(Object self, Class<T> clazz) {
"""
Converts a class implementing some trait into a target class. If the trait is a dynamic proxy and
that the target class is assignable to the target object of the proxy, then the target object is
returned. Otherwise, falls back to {@link org.codehaus.groovy.runtime.DefaultGroovyMethods#asType(java.lang.Object, Class)}
@param self an object to be coerced to some class
@param clazz the class to be coerced to
@return the object coerced to the target class, or the proxy instance if it is compatible with the target class.
"""
if (self instanceof GeneratedGroovyProxy) {
Object proxyTarget = ((GeneratedGroovyProxy)self).getProxyTarget();
if (clazz.isAssignableFrom(proxyTarget.getClass())) {
return (T) proxyTarget;
}
}
return DefaultGroovyMethods.asType(self, clazz);
} | java | @SuppressWarnings("unchecked")
public static <T> T getAsType(Object self, Class<T> clazz) {
if (self instanceof GeneratedGroovyProxy) {
Object proxyTarget = ((GeneratedGroovyProxy)self).getProxyTarget();
if (clazz.isAssignableFrom(proxyTarget.getClass())) {
return (T) proxyTarget;
}
}
return DefaultGroovyMethods.asType(self, clazz);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"T",
">",
"T",
"getAsType",
"(",
"Object",
"self",
",",
"Class",
"<",
"T",
">",
"clazz",
")",
"{",
"if",
"(",
"self",
"instanceof",
"GeneratedGroovyProxy",
")",
"{",
"Object",
"proxyTarget",
"=",
"(",
"(",
"GeneratedGroovyProxy",
")",
"self",
")",
".",
"getProxyTarget",
"(",
")",
";",
"if",
"(",
"clazz",
".",
"isAssignableFrom",
"(",
"proxyTarget",
".",
"getClass",
"(",
")",
")",
")",
"{",
"return",
"(",
"T",
")",
"proxyTarget",
";",
"}",
"}",
"return",
"DefaultGroovyMethods",
".",
"asType",
"(",
"self",
",",
"clazz",
")",
";",
"}"
] | Converts a class implementing some trait into a target class. If the trait is a dynamic proxy and
that the target class is assignable to the target object of the proxy, then the target object is
returned. Otherwise, falls back to {@link org.codehaus.groovy.runtime.DefaultGroovyMethods#asType(java.lang.Object, Class)}
@param self an object to be coerced to some class
@param clazz the class to be coerced to
@return the object coerced to the target class, or the proxy instance if it is compatible with the target class. | [
"Converts",
"a",
"class",
"implementing",
"some",
"trait",
"into",
"a",
"target",
"class",
".",
"If",
"the",
"trait",
"is",
"a",
"dynamic",
"proxy",
"and",
"that",
"the",
"target",
"class",
"is",
"assignable",
"to",
"the",
"target",
"object",
"of",
"the",
"proxy",
"then",
"the",
"target",
"object",
"is",
"returned",
".",
"Otherwise",
"falls",
"back",
"to",
"{"
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/transform/trait/Traits.java#L253-L262 |
BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WPanelTypeExample.java | WPanelTypeExample.buildSubordinates | private void buildSubordinates() {
"""
The subordinate controls used to show/hide parts of the configuration options based on the selected WPanel Type.
"""
WSubordinateControl control = new WSubordinateControl();
Rule rule = new Rule();
rule.setCondition(new Equal(panelType, WPanel.Type.HEADER));
rule.addActionOnTrue(new Show(showUtilBarField));
rule.addActionOnTrue(new Show(showMenuField));
rule.addActionOnTrue(new Hide(contentField));
rule.addActionOnFalse(new Hide(showUtilBarField));
rule.addActionOnFalse(new Hide(showMenuField));
rule.addActionOnFalse(new Show(contentField));
control.addRule(rule);
rule = new Rule();
rule.setCondition(
new Or(
new Equal(panelType, WPanel.Type.CHROME),
new Equal(panelType, WPanel.Type.ACTION),
new Equal(panelType, WPanel.Type.HEADER)
));
rule.addActionOnTrue(new Show(headingField));
rule.addActionOnFalse(new Hide(headingField));
control.addRule(rule);
add(control);
} | java | private void buildSubordinates() {
WSubordinateControl control = new WSubordinateControl();
Rule rule = new Rule();
rule.setCondition(new Equal(panelType, WPanel.Type.HEADER));
rule.addActionOnTrue(new Show(showUtilBarField));
rule.addActionOnTrue(new Show(showMenuField));
rule.addActionOnTrue(new Hide(contentField));
rule.addActionOnFalse(new Hide(showUtilBarField));
rule.addActionOnFalse(new Hide(showMenuField));
rule.addActionOnFalse(new Show(contentField));
control.addRule(rule);
rule = new Rule();
rule.setCondition(
new Or(
new Equal(panelType, WPanel.Type.CHROME),
new Equal(panelType, WPanel.Type.ACTION),
new Equal(panelType, WPanel.Type.HEADER)
));
rule.addActionOnTrue(new Show(headingField));
rule.addActionOnFalse(new Hide(headingField));
control.addRule(rule);
add(control);
} | [
"private",
"void",
"buildSubordinates",
"(",
")",
"{",
"WSubordinateControl",
"control",
"=",
"new",
"WSubordinateControl",
"(",
")",
";",
"Rule",
"rule",
"=",
"new",
"Rule",
"(",
")",
";",
"rule",
".",
"setCondition",
"(",
"new",
"Equal",
"(",
"panelType",
",",
"WPanel",
".",
"Type",
".",
"HEADER",
")",
")",
";",
"rule",
".",
"addActionOnTrue",
"(",
"new",
"Show",
"(",
"showUtilBarField",
")",
")",
";",
"rule",
".",
"addActionOnTrue",
"(",
"new",
"Show",
"(",
"showMenuField",
")",
")",
";",
"rule",
".",
"addActionOnTrue",
"(",
"new",
"Hide",
"(",
"contentField",
")",
")",
";",
"rule",
".",
"addActionOnFalse",
"(",
"new",
"Hide",
"(",
"showUtilBarField",
")",
")",
";",
"rule",
".",
"addActionOnFalse",
"(",
"new",
"Hide",
"(",
"showMenuField",
")",
")",
";",
"rule",
".",
"addActionOnFalse",
"(",
"new",
"Show",
"(",
"contentField",
")",
")",
";",
"control",
".",
"addRule",
"(",
"rule",
")",
";",
"rule",
"=",
"new",
"Rule",
"(",
")",
";",
"rule",
".",
"setCondition",
"(",
"new",
"Or",
"(",
"new",
"Equal",
"(",
"panelType",
",",
"WPanel",
".",
"Type",
".",
"CHROME",
")",
",",
"new",
"Equal",
"(",
"panelType",
",",
"WPanel",
".",
"Type",
".",
"ACTION",
")",
",",
"new",
"Equal",
"(",
"panelType",
",",
"WPanel",
".",
"Type",
".",
"HEADER",
")",
")",
")",
";",
"rule",
".",
"addActionOnTrue",
"(",
"new",
"Show",
"(",
"headingField",
")",
")",
";",
"rule",
".",
"addActionOnFalse",
"(",
"new",
"Hide",
"(",
"headingField",
")",
")",
";",
"control",
".",
"addRule",
"(",
"rule",
")",
";",
"add",
"(",
"control",
")",
";",
"}"
] | The subordinate controls used to show/hide parts of the configuration options based on the selected WPanel Type. | [
"The",
"subordinate",
"controls",
"used",
"to",
"show",
"/",
"hide",
"parts",
"of",
"the",
"configuration",
"options",
"based",
"on",
"the",
"selected",
"WPanel",
"Type",
"."
] | train | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WPanelTypeExample.java#L263-L285 |
di2e/Argo | ArgoWirelineFormat/src/main/java/ws/argo/wireline/response/ServiceWrapper.java | ServiceWrapper.addAccessPoint | public void addAccessPoint(String label, String ip, String port, String url, String dataType, String data) {
"""
Add a new access point for the service record. This structure exists to
help deal with network access issues and not multiple contracts. For
example, a service could have an access point that is different because of
multiple NICs that host is accessible on. It's not to have a service
accessible by HTTP and HTTPS - those are actually two different service
contract IDs. So if you have multiple access points that are actually
providing connection Information for different contracts, then you've done
something wrong.
<p>Understand that you don't need to fill out all the fields in the service
record. Just the ones you need to provide to the client to satisfy the
service contract. For example, a REST services likely only needs the URL
provided and a database might need the IP address, port and URL.
<p>Or, it could be a total free-for-all and you can put in totally obscure and
whacky connection information into the data field.
@param label - hint about why you might need this access point e.g.
internal or external network
@param ip - Plain IP address
@param port - port the service is listening on
@param url - the URL (or portion of the URL) that the client needs to
connect
@param dataType - a hint about what might be in the data section
@param data - totally free-form data (it's BASE64 encoded in both the XML
and JSON)
"""
AccessPoint ap = new AccessPoint();
ap.label = label;
ap.ipAddress = ip;
ap.port = port;
ap.url = url;
ap.dataType = dataType;
ap.data = data;
accessPoints.add(ap);
} | java | public void addAccessPoint(String label, String ip, String port, String url, String dataType, String data) {
AccessPoint ap = new AccessPoint();
ap.label = label;
ap.ipAddress = ip;
ap.port = port;
ap.url = url;
ap.dataType = dataType;
ap.data = data;
accessPoints.add(ap);
} | [
"public",
"void",
"addAccessPoint",
"(",
"String",
"label",
",",
"String",
"ip",
",",
"String",
"port",
",",
"String",
"url",
",",
"String",
"dataType",
",",
"String",
"data",
")",
"{",
"AccessPoint",
"ap",
"=",
"new",
"AccessPoint",
"(",
")",
";",
"ap",
".",
"label",
"=",
"label",
";",
"ap",
".",
"ipAddress",
"=",
"ip",
";",
"ap",
".",
"port",
"=",
"port",
";",
"ap",
".",
"url",
"=",
"url",
";",
"ap",
".",
"dataType",
"=",
"dataType",
";",
"ap",
".",
"data",
"=",
"data",
";",
"accessPoints",
".",
"add",
"(",
"ap",
")",
";",
"}"
] | Add a new access point for the service record. This structure exists to
help deal with network access issues and not multiple contracts. For
example, a service could have an access point that is different because of
multiple NICs that host is accessible on. It's not to have a service
accessible by HTTP and HTTPS - those are actually two different service
contract IDs. So if you have multiple access points that are actually
providing connection Information for different contracts, then you've done
something wrong.
<p>Understand that you don't need to fill out all the fields in the service
record. Just the ones you need to provide to the client to satisfy the
service contract. For example, a REST services likely only needs the URL
provided and a database might need the IP address, port and URL.
<p>Or, it could be a total free-for-all and you can put in totally obscure and
whacky connection information into the data field.
@param label - hint about why you might need this access point e.g.
internal or external network
@param ip - Plain IP address
@param port - port the service is listening on
@param url - the URL (or portion of the URL) that the client needs to
connect
@param dataType - a hint about what might be in the data section
@param data - totally free-form data (it's BASE64 encoded in both the XML
and JSON) | [
"Add",
"a",
"new",
"access",
"point",
"for",
"the",
"service",
"record",
".",
"This",
"structure",
"exists",
"to",
"help",
"deal",
"with",
"network",
"access",
"issues",
"and",
"not",
"multiple",
"contracts",
".",
"For",
"example",
"a",
"service",
"could",
"have",
"an",
"access",
"point",
"that",
"is",
"different",
"because",
"of",
"multiple",
"NICs",
"that",
"host",
"is",
"accessible",
"on",
".",
"It",
"s",
"not",
"to",
"have",
"a",
"service",
"accessible",
"by",
"HTTP",
"and",
"HTTPS",
"-",
"those",
"are",
"actually",
"two",
"different",
"service",
"contract",
"IDs",
".",
"So",
"if",
"you",
"have",
"multiple",
"access",
"points",
"that",
"are",
"actually",
"providing",
"connection",
"Information",
"for",
"different",
"contracts",
"then",
"you",
"ve",
"done",
"something",
"wrong",
"."
] | train | https://github.com/di2e/Argo/blob/f537a03d2d25fdfecda7999ec10e1da67dc3b8f3/ArgoWirelineFormat/src/main/java/ws/argo/wireline/response/ServiceWrapper.java#L225-L237 |
looly/hutool | hutool-json/src/main/java/cn/hutool/json/JSONGetter.java | JSONGetter.get | public <T> T get(K key, Class<T> type, boolean ignoreError) throws ConvertException {
"""
获取指定类型的对象
@param <T> 获取的对象类型
@param key 键
@param type 获取对象类型
@param ignoreError 是否跳过转换失败的对象或值
@return 对象
@throws ConvertException 转换异常
@since 3.0.8
"""
final Object value = this.getObj(key);
if(null == value){
return null;
}
return JSONConverter.jsonConvert(type, value, ignoreError);
} | java | public <T> T get(K key, Class<T> type, boolean ignoreError) throws ConvertException{
final Object value = this.getObj(key);
if(null == value){
return null;
}
return JSONConverter.jsonConvert(type, value, ignoreError);
} | [
"public",
"<",
"T",
">",
"T",
"get",
"(",
"K",
"key",
",",
"Class",
"<",
"T",
">",
"type",
",",
"boolean",
"ignoreError",
")",
"throws",
"ConvertException",
"{",
"final",
"Object",
"value",
"=",
"this",
".",
"getObj",
"(",
"key",
")",
";",
"if",
"(",
"null",
"==",
"value",
")",
"{",
"return",
"null",
";",
"}",
"return",
"JSONConverter",
".",
"jsonConvert",
"(",
"type",
",",
"value",
",",
"ignoreError",
")",
";",
"}"
] | 获取指定类型的对象
@param <T> 获取的对象类型
@param key 键
@param type 获取对象类型
@param ignoreError 是否跳过转换失败的对象或值
@return 对象
@throws ConvertException 转换异常
@since 3.0.8 | [
"获取指定类型的对象"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-json/src/main/java/cn/hutool/json/JSONGetter.java#L126-L132 |
Azure/azure-sdk-for-java | keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/messagesecurity/HttpMessageSecurity.java | HttpMessageSecurity.unprotectPayload | private String unprotectPayload(String payload) throws IOException {
"""
Unencrypt encrypted payload.
@param payload
base64url serialized JWEObject.
@return Unencrypted message.
"""
try {
JWEObject jweObject = JWEObject.deserialize(MessageSecurityHelper.base64UrltoString(payload));
JWEHeader jweHeader = jweObject.jweHeader();
if (!clientEncryptionKey.kid().equals(jweHeader.kid()) || !jweHeader.alg().equals("RSA-OAEP")
|| !jweHeader.enc().equals("A128CBC-HS256")) {
throw new IOException("Invalid protected response");
}
byte[] key = MessageSecurityHelper.base64UrltoByteArray(jweObject.encryptedKey());
RsaKey clientEncryptionRsaKey = new RsaKey(clientEncryptionKey.kid(), clientEncryptionKey.toRSA(true));
byte[] aesKeyBytes = clientEncryptionRsaKey.decryptAsync(key, null, null, null, "RSA-OAEP").get();
SymmetricKey aesKey = new SymmetricKey(UUID.randomUUID().toString(), aesKeyBytes);
byte[] result = aesKey.decryptAsync(MessageSecurityHelper.base64UrltoByteArray(jweObject.cipherText()),
MessageSecurityHelper.base64UrltoByteArray(jweObject.iv()),
jweObject.originalProtected().getBytes(MESSAGE_ENCODING),
MessageSecurityHelper.base64UrltoByteArray(jweObject.tag()), "A128CBC-HS256").get();
return new String(result, MESSAGE_ENCODING);
} catch (ExecutionException e) {
// unexpected;
return null;
} catch (InterruptedException e) {
// unexpected;
return null;
} catch (NoSuchAlgorithmException e) {
// unexpected;
return null;
}
} | java | private String unprotectPayload(String payload) throws IOException {
try {
JWEObject jweObject = JWEObject.deserialize(MessageSecurityHelper.base64UrltoString(payload));
JWEHeader jweHeader = jweObject.jweHeader();
if (!clientEncryptionKey.kid().equals(jweHeader.kid()) || !jweHeader.alg().equals("RSA-OAEP")
|| !jweHeader.enc().equals("A128CBC-HS256")) {
throw new IOException("Invalid protected response");
}
byte[] key = MessageSecurityHelper.base64UrltoByteArray(jweObject.encryptedKey());
RsaKey clientEncryptionRsaKey = new RsaKey(clientEncryptionKey.kid(), clientEncryptionKey.toRSA(true));
byte[] aesKeyBytes = clientEncryptionRsaKey.decryptAsync(key, null, null, null, "RSA-OAEP").get();
SymmetricKey aesKey = new SymmetricKey(UUID.randomUUID().toString(), aesKeyBytes);
byte[] result = aesKey.decryptAsync(MessageSecurityHelper.base64UrltoByteArray(jweObject.cipherText()),
MessageSecurityHelper.base64UrltoByteArray(jweObject.iv()),
jweObject.originalProtected().getBytes(MESSAGE_ENCODING),
MessageSecurityHelper.base64UrltoByteArray(jweObject.tag()), "A128CBC-HS256").get();
return new String(result, MESSAGE_ENCODING);
} catch (ExecutionException e) {
// unexpected;
return null;
} catch (InterruptedException e) {
// unexpected;
return null;
} catch (NoSuchAlgorithmException e) {
// unexpected;
return null;
}
} | [
"private",
"String",
"unprotectPayload",
"(",
"String",
"payload",
")",
"throws",
"IOException",
"{",
"try",
"{",
"JWEObject",
"jweObject",
"=",
"JWEObject",
".",
"deserialize",
"(",
"MessageSecurityHelper",
".",
"base64UrltoString",
"(",
"payload",
")",
")",
";",
"JWEHeader",
"jweHeader",
"=",
"jweObject",
".",
"jweHeader",
"(",
")",
";",
"if",
"(",
"!",
"clientEncryptionKey",
".",
"kid",
"(",
")",
".",
"equals",
"(",
"jweHeader",
".",
"kid",
"(",
")",
")",
"||",
"!",
"jweHeader",
".",
"alg",
"(",
")",
".",
"equals",
"(",
"\"RSA-OAEP\"",
")",
"||",
"!",
"jweHeader",
".",
"enc",
"(",
")",
".",
"equals",
"(",
"\"A128CBC-HS256\"",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Invalid protected response\"",
")",
";",
"}",
"byte",
"[",
"]",
"key",
"=",
"MessageSecurityHelper",
".",
"base64UrltoByteArray",
"(",
"jweObject",
".",
"encryptedKey",
"(",
")",
")",
";",
"RsaKey",
"clientEncryptionRsaKey",
"=",
"new",
"RsaKey",
"(",
"clientEncryptionKey",
".",
"kid",
"(",
")",
",",
"clientEncryptionKey",
".",
"toRSA",
"(",
"true",
")",
")",
";",
"byte",
"[",
"]",
"aesKeyBytes",
"=",
"clientEncryptionRsaKey",
".",
"decryptAsync",
"(",
"key",
",",
"null",
",",
"null",
",",
"null",
",",
"\"RSA-OAEP\"",
")",
".",
"get",
"(",
")",
";",
"SymmetricKey",
"aesKey",
"=",
"new",
"SymmetricKey",
"(",
"UUID",
".",
"randomUUID",
"(",
")",
".",
"toString",
"(",
")",
",",
"aesKeyBytes",
")",
";",
"byte",
"[",
"]",
"result",
"=",
"aesKey",
".",
"decryptAsync",
"(",
"MessageSecurityHelper",
".",
"base64UrltoByteArray",
"(",
"jweObject",
".",
"cipherText",
"(",
")",
")",
",",
"MessageSecurityHelper",
".",
"base64UrltoByteArray",
"(",
"jweObject",
".",
"iv",
"(",
")",
")",
",",
"jweObject",
".",
"originalProtected",
"(",
")",
".",
"getBytes",
"(",
"MESSAGE_ENCODING",
")",
",",
"MessageSecurityHelper",
".",
"base64UrltoByteArray",
"(",
"jweObject",
".",
"tag",
"(",
")",
")",
",",
"\"A128CBC-HS256\"",
")",
".",
"get",
"(",
")",
";",
"return",
"new",
"String",
"(",
"result",
",",
"MESSAGE_ENCODING",
")",
";",
"}",
"catch",
"(",
"ExecutionException",
"e",
")",
"{",
"// unexpected;",
"return",
"null",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"// unexpected;",
"return",
"null",
";",
"}",
"catch",
"(",
"NoSuchAlgorithmException",
"e",
")",
"{",
"// unexpected;",
"return",
"null",
";",
"}",
"}"
] | Unencrypt encrypted payload.
@param payload
base64url serialized JWEObject.
@return Unencrypted message. | [
"Unencrypt",
"encrypted",
"payload",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/messagesecurity/HttpMessageSecurity.java#L339-L371 |
inferred/FreeBuilder | src/main/java/org/inferred/freebuilder/processor/source/ScopeHandler.java | ScopeHandler.visibilityIn | ScopeState visibilityIn(QualifiedName scope, QualifiedName type) {
"""
Returns whether {@code type} is visible in, or can be imported into, the body of {@code type}.
"""
Set<QualifiedName> possibleConflicts = typesInScope(scope).get(type.getSimpleName());
if (possibleConflicts.equals(ImmutableSet.of(type))) {
return ScopeState.IN_SCOPE;
} else if (!possibleConflicts.isEmpty()) {
return ScopeState.HIDDEN;
} else if (!scope.isTopLevel()) {
return visibilityIn(scope.enclosingType(), type);
} else {
return visibilityIn(scope.getPackage(), type);
}
} | java | ScopeState visibilityIn(QualifiedName scope, QualifiedName type) {
Set<QualifiedName> possibleConflicts = typesInScope(scope).get(type.getSimpleName());
if (possibleConflicts.equals(ImmutableSet.of(type))) {
return ScopeState.IN_SCOPE;
} else if (!possibleConflicts.isEmpty()) {
return ScopeState.HIDDEN;
} else if (!scope.isTopLevel()) {
return visibilityIn(scope.enclosingType(), type);
} else {
return visibilityIn(scope.getPackage(), type);
}
} | [
"ScopeState",
"visibilityIn",
"(",
"QualifiedName",
"scope",
",",
"QualifiedName",
"type",
")",
"{",
"Set",
"<",
"QualifiedName",
">",
"possibleConflicts",
"=",
"typesInScope",
"(",
"scope",
")",
".",
"get",
"(",
"type",
".",
"getSimpleName",
"(",
")",
")",
";",
"if",
"(",
"possibleConflicts",
".",
"equals",
"(",
"ImmutableSet",
".",
"of",
"(",
"type",
")",
")",
")",
"{",
"return",
"ScopeState",
".",
"IN_SCOPE",
";",
"}",
"else",
"if",
"(",
"!",
"possibleConflicts",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"ScopeState",
".",
"HIDDEN",
";",
"}",
"else",
"if",
"(",
"!",
"scope",
".",
"isTopLevel",
"(",
")",
")",
"{",
"return",
"visibilityIn",
"(",
"scope",
".",
"enclosingType",
"(",
")",
",",
"type",
")",
";",
"}",
"else",
"{",
"return",
"visibilityIn",
"(",
"scope",
".",
"getPackage",
"(",
")",
",",
"type",
")",
";",
"}",
"}"
] | Returns whether {@code type} is visible in, or can be imported into, the body of {@code type}. | [
"Returns",
"whether",
"{"
] | train | https://github.com/inferred/FreeBuilder/blob/d5a222f90648aece135da4b971c55a60afe8649c/src/main/java/org/inferred/freebuilder/processor/source/ScopeHandler.java#L77-L88 |
jglobus/JGlobus | ssl-proxies/src/main/java/org/globus/util/GlobusPathMatchingResourcePatternResolver.java | GlobusPathMatchingResourcePatternResolver.parseFilesInDirectory | private void parseFilesInDirectory(File currentDirectory, Vector<GlobusResource> pathsMatchingLocationPattern) {
"""
Compares every file's Absolute Path against the locationPattern, if they match
a GlobusResource is created with the file's Absolute Path and added to pathsMatchingLocationPattern.
@param currentDirectory The directory whose files to parse.
@param pathsMatchingLocationPattern Holds GlobusResource instances of all the paths which matched the locationPattern
"""
File[] directoryContents = null;
if (currentDirectory.isDirectory()) {
directoryContents = currentDirectory.listFiles(); //Get a list of the files and directories
} else {
directoryContents = new File[1];
directoryContents[0] = currentDirectory;
}
String absolutePath = null;
Matcher locationPatternMatcher = null;
if(directoryContents != null){
for (File currentFile : directoryContents) {
if (currentFile.isFile()) { //We are only interested in files not directories
absolutePath = currentFile.getAbsolutePath();
locationPatternMatcher = locationPattern.matcher(absolutePath);
if (locationPatternMatcher.find()) {
pathsMatchingLocationPattern.add(new GlobusResource(absolutePath));
}
}
}
}
} | java | private void parseFilesInDirectory(File currentDirectory, Vector<GlobusResource> pathsMatchingLocationPattern) {
File[] directoryContents = null;
if (currentDirectory.isDirectory()) {
directoryContents = currentDirectory.listFiles(); //Get a list of the files and directories
} else {
directoryContents = new File[1];
directoryContents[0] = currentDirectory;
}
String absolutePath = null;
Matcher locationPatternMatcher = null;
if(directoryContents != null){
for (File currentFile : directoryContents) {
if (currentFile.isFile()) { //We are only interested in files not directories
absolutePath = currentFile.getAbsolutePath();
locationPatternMatcher = locationPattern.matcher(absolutePath);
if (locationPatternMatcher.find()) {
pathsMatchingLocationPattern.add(new GlobusResource(absolutePath));
}
}
}
}
} | [
"private",
"void",
"parseFilesInDirectory",
"(",
"File",
"currentDirectory",
",",
"Vector",
"<",
"GlobusResource",
">",
"pathsMatchingLocationPattern",
")",
"{",
"File",
"[",
"]",
"directoryContents",
"=",
"null",
";",
"if",
"(",
"currentDirectory",
".",
"isDirectory",
"(",
")",
")",
"{",
"directoryContents",
"=",
"currentDirectory",
".",
"listFiles",
"(",
")",
";",
"//Get a list of the files and directories",
"}",
"else",
"{",
"directoryContents",
"=",
"new",
"File",
"[",
"1",
"]",
";",
"directoryContents",
"[",
"0",
"]",
"=",
"currentDirectory",
";",
"}",
"String",
"absolutePath",
"=",
"null",
";",
"Matcher",
"locationPatternMatcher",
"=",
"null",
";",
"if",
"(",
"directoryContents",
"!=",
"null",
")",
"{",
"for",
"(",
"File",
"currentFile",
":",
"directoryContents",
")",
"{",
"if",
"(",
"currentFile",
".",
"isFile",
"(",
")",
")",
"{",
"//We are only interested in files not directories",
"absolutePath",
"=",
"currentFile",
".",
"getAbsolutePath",
"(",
")",
";",
"locationPatternMatcher",
"=",
"locationPattern",
".",
"matcher",
"(",
"absolutePath",
")",
";",
"if",
"(",
"locationPatternMatcher",
".",
"find",
"(",
")",
")",
"{",
"pathsMatchingLocationPattern",
".",
"add",
"(",
"new",
"GlobusResource",
"(",
"absolutePath",
")",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | Compares every file's Absolute Path against the locationPattern, if they match
a GlobusResource is created with the file's Absolute Path and added to pathsMatchingLocationPattern.
@param currentDirectory The directory whose files to parse.
@param pathsMatchingLocationPattern Holds GlobusResource instances of all the paths which matched the locationPattern | [
"Compares",
"every",
"file",
"s",
"Absolute",
"Path",
"against",
"the",
"locationPattern",
"if",
"they",
"match",
"a",
"GlobusResource",
"is",
"created",
"with",
"the",
"file",
"s",
"Absolute",
"Path",
"and",
"added",
"to",
"pathsMatchingLocationPattern",
"."
] | train | https://github.com/jglobus/JGlobus/blob/e14f6f6636544fd84298f9cec749d626ea971930/ssl-proxies/src/main/java/org/globus/util/GlobusPathMatchingResourcePatternResolver.java#L171-L192 |
liferay/com-liferay-commerce | commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CProductPersistenceImpl.java | CProductPersistenceImpl.findByGroupId | @Override
public List<CProduct> findByGroupId(long groupId) {
"""
Returns all the c products where groupId = ?.
@param groupId the group ID
@return the matching c products
"""
return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
} | java | @Override
public List<CProduct> findByGroupId(long groupId) {
return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
} | [
"@",
"Override",
"public",
"List",
"<",
"CProduct",
">",
"findByGroupId",
"(",
"long",
"groupId",
")",
"{",
"return",
"findByGroupId",
"(",
"groupId",
",",
"QueryUtil",
".",
"ALL_POS",
",",
"QueryUtil",
".",
"ALL_POS",
",",
"null",
")",
";",
"}"
] | Returns all the c products where groupId = ?.
@param groupId the group ID
@return the matching c products | [
"Returns",
"all",
"the",
"c",
"products",
"where",
"groupId",
"=",
"?",
";",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CProductPersistenceImpl.java#L1499-L1502 |
banq/jdonframework | src/main/java/com/jdon/util/jdom/DataFormatFilter.java | DataFormatFilter.endElement | public void endElement (String uri, String localName, String qName)
throws SAXException {
"""
Add newline and indentation prior to end tag.
<p>If the element has contained other elements, the tag
will appear indented on a new line; otherwise, it will
appear immediately following whatever came before.</p>
<p>The newline and indentation will be passed on down
the filter chain through regular characters events.</p>
@param uri The element's Namespace URI.
@param localName The element's local name.
@param qName The element's qualified (prefixed) name.
@exception org.xml.sax.SAXException If a filter
further down the chain raises an exception.
@see org.xml.sax.ContentHandler#endElement
"""
boolean seenElement = (state == SEEN_ELEMENT);
state = stateStack.pop();
if (seenElement) {
doNewline();
doIndent();
}
super.endElement(uri, localName, qName);
} | java | public void endElement (String uri, String localName, String qName)
throws SAXException
{
boolean seenElement = (state == SEEN_ELEMENT);
state = stateStack.pop();
if (seenElement) {
doNewline();
doIndent();
}
super.endElement(uri, localName, qName);
} | [
"public",
"void",
"endElement",
"(",
"String",
"uri",
",",
"String",
"localName",
",",
"String",
"qName",
")",
"throws",
"SAXException",
"{",
"boolean",
"seenElement",
"=",
"(",
"state",
"==",
"SEEN_ELEMENT",
")",
";",
"state",
"=",
"stateStack",
".",
"pop",
"(",
")",
";",
"if",
"(",
"seenElement",
")",
"{",
"doNewline",
"(",
")",
";",
"doIndent",
"(",
")",
";",
"}",
"super",
".",
"endElement",
"(",
"uri",
",",
"localName",
",",
"qName",
")",
";",
"}"
] | Add newline and indentation prior to end tag.
<p>If the element has contained other elements, the tag
will appear indented on a new line; otherwise, it will
appear immediately following whatever came before.</p>
<p>The newline and indentation will be passed on down
the filter chain through regular characters events.</p>
@param uri The element's Namespace URI.
@param localName The element's local name.
@param qName The element's qualified (prefixed) name.
@exception org.xml.sax.SAXException If a filter
further down the chain raises an exception.
@see org.xml.sax.ContentHandler#endElement | [
"Add",
"newline",
"and",
"indentation",
"prior",
"to",
"end",
"tag",
"."
] | train | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/util/jdom/DataFormatFilter.java#L276-L286 |
zxing/zxing | android/src/com/google/zxing/client/android/camera/CameraManager.java | CameraManager.setTorch | public synchronized void setTorch(boolean newSetting) {
"""
Convenience method for {@link com.google.zxing.client.android.CaptureActivity}
@param newSetting if {@code true}, light should be turned on if currently off. And vice versa.
"""
OpenCamera theCamera = camera;
if (theCamera != null && newSetting != configManager.getTorchState(theCamera.getCamera())) {
boolean wasAutoFocusManager = autoFocusManager != null;
if (wasAutoFocusManager) {
autoFocusManager.stop();
autoFocusManager = null;
}
configManager.setTorch(theCamera.getCamera(), newSetting);
if (wasAutoFocusManager) {
autoFocusManager = new AutoFocusManager(context, theCamera.getCamera());
autoFocusManager.start();
}
}
} | java | public synchronized void setTorch(boolean newSetting) {
OpenCamera theCamera = camera;
if (theCamera != null && newSetting != configManager.getTorchState(theCamera.getCamera())) {
boolean wasAutoFocusManager = autoFocusManager != null;
if (wasAutoFocusManager) {
autoFocusManager.stop();
autoFocusManager = null;
}
configManager.setTorch(theCamera.getCamera(), newSetting);
if (wasAutoFocusManager) {
autoFocusManager = new AutoFocusManager(context, theCamera.getCamera());
autoFocusManager.start();
}
}
} | [
"public",
"synchronized",
"void",
"setTorch",
"(",
"boolean",
"newSetting",
")",
"{",
"OpenCamera",
"theCamera",
"=",
"camera",
";",
"if",
"(",
"theCamera",
"!=",
"null",
"&&",
"newSetting",
"!=",
"configManager",
".",
"getTorchState",
"(",
"theCamera",
".",
"getCamera",
"(",
")",
")",
")",
"{",
"boolean",
"wasAutoFocusManager",
"=",
"autoFocusManager",
"!=",
"null",
";",
"if",
"(",
"wasAutoFocusManager",
")",
"{",
"autoFocusManager",
".",
"stop",
"(",
")",
";",
"autoFocusManager",
"=",
"null",
";",
"}",
"configManager",
".",
"setTorch",
"(",
"theCamera",
".",
"getCamera",
"(",
")",
",",
"newSetting",
")",
";",
"if",
"(",
"wasAutoFocusManager",
")",
"{",
"autoFocusManager",
"=",
"new",
"AutoFocusManager",
"(",
"context",
",",
"theCamera",
".",
"getCamera",
"(",
")",
")",
";",
"autoFocusManager",
".",
"start",
"(",
")",
";",
"}",
"}",
"}"
] | Convenience method for {@link com.google.zxing.client.android.CaptureActivity}
@param newSetting if {@code true}, light should be turned on if currently off. And vice versa. | [
"Convenience",
"method",
"for",
"{",
"@link",
"com",
".",
"google",
".",
"zxing",
".",
"client",
".",
"android",
".",
"CaptureActivity",
"}"
] | train | https://github.com/zxing/zxing/blob/653ac2a3beb11481eff82e7d5f2bab8a745f7fac/android/src/com/google/zxing/client/android/camera/CameraManager.java#L174-L188 |
apache/incubator-heron | heron/packing/src/java/org/apache/heron/packing/binpacking/FirstFitDecreasingPacking.java | FirstFitDecreasingPacking.removeInstancesFromContainers | private void removeInstancesFromContainers(PackingPlanBuilder packingPlanBuilder,
Map<String, Integer> componentsToScaleDown) {
"""
Removes instances from containers during scaling down
@param packingPlanBuilder existing packing plan
@param componentsToScaleDown scale down factor for the components.
"""
List<ResourceRequirement> resourceRequirements =
getSortedInstances(componentsToScaleDown.keySet());
InstanceCountScorer instanceCountScorer = new InstanceCountScorer();
ContainerIdScorer containerIdScorer = new ContainerIdScorer(false);
for (ResourceRequirement resourceRequirement : resourceRequirements) {
String componentName = resourceRequirement.getComponentName();
int numInstancesToRemove = -componentsToScaleDown.get(componentName);
List<Scorer<Container>> scorers = new ArrayList<>();
scorers.add(new HomogeneityScorer(componentName, true)); // all-same-component containers
scorers.add(instanceCountScorer); // then fewest instances
scorers.add(new HomogeneityScorer(componentName, false)); // then most homogeneous
scorers.add(containerIdScorer); // then highest container id
for (int j = 0; j < numInstancesToRemove; j++) {
packingPlanBuilder.removeInstance(scorers, componentName);
}
}
} | java | private void removeInstancesFromContainers(PackingPlanBuilder packingPlanBuilder,
Map<String, Integer> componentsToScaleDown) {
List<ResourceRequirement> resourceRequirements =
getSortedInstances(componentsToScaleDown.keySet());
InstanceCountScorer instanceCountScorer = new InstanceCountScorer();
ContainerIdScorer containerIdScorer = new ContainerIdScorer(false);
for (ResourceRequirement resourceRequirement : resourceRequirements) {
String componentName = resourceRequirement.getComponentName();
int numInstancesToRemove = -componentsToScaleDown.get(componentName);
List<Scorer<Container>> scorers = new ArrayList<>();
scorers.add(new HomogeneityScorer(componentName, true)); // all-same-component containers
scorers.add(instanceCountScorer); // then fewest instances
scorers.add(new HomogeneityScorer(componentName, false)); // then most homogeneous
scorers.add(containerIdScorer); // then highest container id
for (int j = 0; j < numInstancesToRemove; j++) {
packingPlanBuilder.removeInstance(scorers, componentName);
}
}
} | [
"private",
"void",
"removeInstancesFromContainers",
"(",
"PackingPlanBuilder",
"packingPlanBuilder",
",",
"Map",
"<",
"String",
",",
"Integer",
">",
"componentsToScaleDown",
")",
"{",
"List",
"<",
"ResourceRequirement",
">",
"resourceRequirements",
"=",
"getSortedInstances",
"(",
"componentsToScaleDown",
".",
"keySet",
"(",
")",
")",
";",
"InstanceCountScorer",
"instanceCountScorer",
"=",
"new",
"InstanceCountScorer",
"(",
")",
";",
"ContainerIdScorer",
"containerIdScorer",
"=",
"new",
"ContainerIdScorer",
"(",
"false",
")",
";",
"for",
"(",
"ResourceRequirement",
"resourceRequirement",
":",
"resourceRequirements",
")",
"{",
"String",
"componentName",
"=",
"resourceRequirement",
".",
"getComponentName",
"(",
")",
";",
"int",
"numInstancesToRemove",
"=",
"-",
"componentsToScaleDown",
".",
"get",
"(",
"componentName",
")",
";",
"List",
"<",
"Scorer",
"<",
"Container",
">",
">",
"scorers",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"scorers",
".",
"add",
"(",
"new",
"HomogeneityScorer",
"(",
"componentName",
",",
"true",
")",
")",
";",
"// all-same-component containers",
"scorers",
".",
"add",
"(",
"instanceCountScorer",
")",
";",
"// then fewest instances",
"scorers",
".",
"add",
"(",
"new",
"HomogeneityScorer",
"(",
"componentName",
",",
"false",
")",
")",
";",
"// then most homogeneous",
"scorers",
".",
"add",
"(",
"containerIdScorer",
")",
";",
"// then highest container id",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"numInstancesToRemove",
";",
"j",
"++",
")",
"{",
"packingPlanBuilder",
".",
"removeInstance",
"(",
"scorers",
",",
"componentName",
")",
";",
"}",
"}",
"}"
] | Removes instances from containers during scaling down
@param packingPlanBuilder existing packing plan
@param componentsToScaleDown scale down factor for the components. | [
"Removes",
"instances",
"from",
"containers",
"during",
"scaling",
"down"
] | train | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/packing/src/java/org/apache/heron/packing/binpacking/FirstFitDecreasingPacking.java#L257-L280 |
apache/incubator-gobblin | gobblin-utility/src/main/java/org/apache/gobblin/util/SerializationUtils.java | SerializationUtils.serializeState | public static <T extends State> void serializeState(FileSystem fs, Path jobStateFilePath, T state)
throws IOException {
"""
Serialize a {@link State} instance to a file.
@param fs the {@link FileSystem} instance for creating the file
@param jobStateFilePath the path to the file
@param state the {@link State} to serialize
@param <T> the {@link State} object type
@throws IOException if it fails to serialize the {@link State} instance
"""
serializeState(fs, jobStateFilePath, state, fs.getDefaultReplication(jobStateFilePath));
} | java | public static <T extends State> void serializeState(FileSystem fs, Path jobStateFilePath, T state)
throws IOException {
serializeState(fs, jobStateFilePath, state, fs.getDefaultReplication(jobStateFilePath));
} | [
"public",
"static",
"<",
"T",
"extends",
"State",
">",
"void",
"serializeState",
"(",
"FileSystem",
"fs",
",",
"Path",
"jobStateFilePath",
",",
"T",
"state",
")",
"throws",
"IOException",
"{",
"serializeState",
"(",
"fs",
",",
"jobStateFilePath",
",",
"state",
",",
"fs",
".",
"getDefaultReplication",
"(",
"jobStateFilePath",
")",
")",
";",
"}"
] | Serialize a {@link State} instance to a file.
@param fs the {@link FileSystem} instance for creating the file
@param jobStateFilePath the path to the file
@param state the {@link State} to serialize
@param <T> the {@link State} object type
@throws IOException if it fails to serialize the {@link State} instance | [
"Serialize",
"a",
"{",
"@link",
"State",
"}",
"instance",
"to",
"a",
"file",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/SerializationUtils.java#L141-L144 |
JadiraOrg/jadira | bindings/src/main/java/org/jadira/bindings/core/binder/BasicBinder.java | BasicBinder.registerExtendedBinder | protected <I, T extends I> void registerExtendedBinder(Class<I> iface, T provider) {
"""
Register a custom, typesafe binder implementation which can be retrieved later
@param iface The interface for the provider to be registered.
@param provider The implementation.
@param <I> The class to be registered
@param <T> Implementation of the binder type, I.
"""
extendedBinders.put(iface, provider);
} | java | protected <I, T extends I> void registerExtendedBinder(Class<I> iface, T provider) {
extendedBinders.put(iface, provider);
} | [
"protected",
"<",
"I",
",",
"T",
"extends",
"I",
">",
"void",
"registerExtendedBinder",
"(",
"Class",
"<",
"I",
">",
"iface",
",",
"T",
"provider",
")",
"{",
"extendedBinders",
".",
"put",
"(",
"iface",
",",
"provider",
")",
";",
"}"
] | Register a custom, typesafe binder implementation which can be retrieved later
@param iface The interface for the provider to be registered.
@param provider The implementation.
@param <I> The class to be registered
@param <T> Implementation of the binder type, I. | [
"Register",
"a",
"custom",
"typesafe",
"binder",
"implementation",
"which",
"can",
"be",
"retrieved",
"later"
] | train | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/bindings/src/main/java/org/jadira/bindings/core/binder/BasicBinder.java#L513-L515 |
OpenLiberty/open-liberty | dev/com.ibm.ws.kernel.service/src/com/ibm/ws/kernel/service/util/SecureAction.java | SecureAction.getService | public <S> S getService(final ServiceReference<S> reference, final BundleContext context) {
"""
Gets a service object. Same as calling
context.getService(reference)
@param reference the ServiceReference
@param context the BundleContext
@return a service object
"""
if (System.getSecurityManager() == null)
return context.getService(reference);
return AccessController.doPrivileged(new PrivilegedAction<S>() {
@Override
public S run() {
return context.getService(reference);
}
}, controlContext);
} | java | public <S> S getService(final ServiceReference<S> reference, final BundleContext context) {
if (System.getSecurityManager() == null)
return context.getService(reference);
return AccessController.doPrivileged(new PrivilegedAction<S>() {
@Override
public S run() {
return context.getService(reference);
}
}, controlContext);
} | [
"public",
"<",
"S",
">",
"S",
"getService",
"(",
"final",
"ServiceReference",
"<",
"S",
">",
"reference",
",",
"final",
"BundleContext",
"context",
")",
"{",
"if",
"(",
"System",
".",
"getSecurityManager",
"(",
")",
"==",
"null",
")",
"return",
"context",
".",
"getService",
"(",
"reference",
")",
";",
"return",
"AccessController",
".",
"doPrivileged",
"(",
"new",
"PrivilegedAction",
"<",
"S",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"S",
"run",
"(",
")",
"{",
"return",
"context",
".",
"getService",
"(",
"reference",
")",
";",
"}",
"}",
",",
"controlContext",
")",
";",
"}"
] | Gets a service object. Same as calling
context.getService(reference)
@param reference the ServiceReference
@param context the BundleContext
@return a service object | [
"Gets",
"a",
"service",
"object",
".",
"Same",
"as",
"calling",
"context",
".",
"getService",
"(",
"reference",
")"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.service/src/com/ibm/ws/kernel/service/util/SecureAction.java#L453-L462 |
aws/aws-sdk-java | aws-java-sdk-code-generator/src/main/java/com/amazonaws/codegen/internal/Utils.java | Utils.getRequiredResourceAsStream | public static InputStream getRequiredResourceAsStream(Class<?> clzz, String location) {
"""
Return an InputStream of the specified resource, failing if it can't be found.
@param clzz
@param location
Location of resource
"""
InputStream resourceStream = clzz.getResourceAsStream(location);
if (resourceStream == null) {
// Try with a leading "/"
if (!location.startsWith("/")) {
resourceStream = clzz.getResourceAsStream("/" + location);
}
if (resourceStream == null) {
throw new RuntimeException("Resource file was not found at location " + location);
}
}
return resourceStream;
} | java | public static InputStream getRequiredResourceAsStream(Class<?> clzz, String location) {
InputStream resourceStream = clzz.getResourceAsStream(location);
if (resourceStream == null) {
// Try with a leading "/"
if (!location.startsWith("/")) {
resourceStream = clzz.getResourceAsStream("/" + location);
}
if (resourceStream == null) {
throw new RuntimeException("Resource file was not found at location " + location);
}
}
return resourceStream;
} | [
"public",
"static",
"InputStream",
"getRequiredResourceAsStream",
"(",
"Class",
"<",
"?",
">",
"clzz",
",",
"String",
"location",
")",
"{",
"InputStream",
"resourceStream",
"=",
"clzz",
".",
"getResourceAsStream",
"(",
"location",
")",
";",
"if",
"(",
"resourceStream",
"==",
"null",
")",
"{",
"// Try with a leading \"/\"",
"if",
"(",
"!",
"location",
".",
"startsWith",
"(",
"\"/\"",
")",
")",
"{",
"resourceStream",
"=",
"clzz",
".",
"getResourceAsStream",
"(",
"\"/\"",
"+",
"location",
")",
";",
"}",
"if",
"(",
"resourceStream",
"==",
"null",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Resource file was not found at location \"",
"+",
"location",
")",
";",
"}",
"}",
"return",
"resourceStream",
";",
"}"
] | Return an InputStream of the specified resource, failing if it can't be found.
@param clzz
@param location
Location of resource | [
"Return",
"an",
"InputStream",
"of",
"the",
"specified",
"resource",
"failing",
"if",
"it",
"can",
"t",
"be",
"found",
"."
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-code-generator/src/main/java/com/amazonaws/codegen/internal/Utils.java#L208-L222 |
devnewton/jnuit | pngdecoder/src/main/java/de/matthiasmann/twl/utils/PNGDecoder.java | PNGDecoder.overwriteTRNS | public void overwriteTRNS(byte r, byte g, byte b) {
"""
Overwrites the tRNS chunk entry to make a selected color transparent.
<p>This can only be invoked when the image has no alpha channel.</p>
<p>Calling this method causes {@link #hasAlpha()} to return true.</p>
@param r the red component of the color to make transparent
@param g the green component of the color to make transparent
@param b the blue component of the color to make transparent
@throws UnsupportedOperationException if the tRNS chunk data can't be set
@see #hasAlphaChannel()
"""
if(hasAlphaChannel()) {
throw new UnsupportedOperationException("image has an alpha channel");
}
byte[] pal = this.palette;
if(pal == null) {
transPixel = new byte[] { 0, r, 0, g, 0, b };
} else {
paletteA = new byte[pal.length/3];
for(int i=0,j=0 ; i<pal.length ; i+=3,j++) {
if(pal[i] != r || pal[i+1] != g || pal[i+2] != b) {
paletteA[j] = (byte)0xFF;
}
}
}
} | java | public void overwriteTRNS(byte r, byte g, byte b) {
if(hasAlphaChannel()) {
throw new UnsupportedOperationException("image has an alpha channel");
}
byte[] pal = this.palette;
if(pal == null) {
transPixel = new byte[] { 0, r, 0, g, 0, b };
} else {
paletteA = new byte[pal.length/3];
for(int i=0,j=0 ; i<pal.length ; i+=3,j++) {
if(pal[i] != r || pal[i+1] != g || pal[i+2] != b) {
paletteA[j] = (byte)0xFF;
}
}
}
} | [
"public",
"void",
"overwriteTRNS",
"(",
"byte",
"r",
",",
"byte",
"g",
",",
"byte",
"b",
")",
"{",
"if",
"(",
"hasAlphaChannel",
"(",
")",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"image has an alpha channel\"",
")",
";",
"}",
"byte",
"[",
"]",
"pal",
"=",
"this",
".",
"palette",
";",
"if",
"(",
"pal",
"==",
"null",
")",
"{",
"transPixel",
"=",
"new",
"byte",
"[",
"]",
"{",
"0",
",",
"r",
",",
"0",
",",
"g",
",",
"0",
",",
"b",
"}",
";",
"}",
"else",
"{",
"paletteA",
"=",
"new",
"byte",
"[",
"pal",
".",
"length",
"/",
"3",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"j",
"=",
"0",
";",
"i",
"<",
"pal",
".",
"length",
";",
"i",
"+=",
"3",
",",
"j",
"++",
")",
"{",
"if",
"(",
"pal",
"[",
"i",
"]",
"!=",
"r",
"||",
"pal",
"[",
"i",
"+",
"1",
"]",
"!=",
"g",
"||",
"pal",
"[",
"i",
"+",
"2",
"]",
"!=",
"b",
")",
"{",
"paletteA",
"[",
"j",
"]",
"=",
"(",
"byte",
")",
"0xFF",
";",
"}",
"}",
"}",
"}"
] | Overwrites the tRNS chunk entry to make a selected color transparent.
<p>This can only be invoked when the image has no alpha channel.</p>
<p>Calling this method causes {@link #hasAlpha()} to return true.</p>
@param r the red component of the color to make transparent
@param g the green component of the color to make transparent
@param b the blue component of the color to make transparent
@throws UnsupportedOperationException if the tRNS chunk data can't be set
@see #hasAlphaChannel() | [
"Overwrites",
"the",
"tRNS",
"chunk",
"entry",
"to",
"make",
"a",
"selected",
"color",
"transparent",
".",
"<p",
">",
"This",
"can",
"only",
"be",
"invoked",
"when",
"the",
"image",
"has",
"no",
"alpha",
"channel",
".",
"<",
"/",
"p",
">",
"<p",
">",
"Calling",
"this",
"method",
"causes",
"{",
"@link",
"#hasAlpha",
"()",
"}",
"to",
"return",
"true",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/devnewton/jnuit/blob/191f19b55a17451d0f277c151c7e9b4427a12415/pngdecoder/src/main/java/de/matthiasmann/twl/utils/PNGDecoder.java#L190-L205 |
fcrepo4/fcrepo4 | fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/services/BinaryServiceImpl.java | BinaryServiceImpl.find | @Override
public FedoraBinary find(final FedoraSession session, final String path) {
"""
Retrieve a Datastream instance by pid and dsid
@param path jcr path to the datastream
@return datastream
"""
return cast(findNode(session, path));
} | java | @Override
public FedoraBinary find(final FedoraSession session, final String path) {
return cast(findNode(session, path));
} | [
"@",
"Override",
"public",
"FedoraBinary",
"find",
"(",
"final",
"FedoraSession",
"session",
",",
"final",
"String",
"path",
")",
"{",
"return",
"cast",
"(",
"findNode",
"(",
"session",
",",
"path",
")",
")",
";",
"}"
] | Retrieve a Datastream instance by pid and dsid
@param path jcr path to the datastream
@return datastream | [
"Retrieve",
"a",
"Datastream",
"instance",
"by",
"pid",
"and",
"dsid"
] | train | https://github.com/fcrepo4/fcrepo4/blob/7489ad5bc8fb44e2442c93eceb7d97ac54553ab6/fcrepo-kernel-modeshape/src/main/java/org/fcrepo/kernel/modeshape/services/BinaryServiceImpl.java#L127-L130 |
xmlet/XsdAsmFaster | src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java | XsdAsmInterfaces.generateInnerSequenceClass | private ClassWriter generateInnerSequenceClass(String typeName, String className, String apiName) {
"""
Creates the inner classes that are used to support the sequence behaviour.
@param typeName The name of the next type to return.
@param className The name of the class which contains the sequence.
@param apiName The name of the generated fluent interface.
@return The {@link ClassWriter} object which represents the inner class created to support sequence behaviour.
"""
ClassWriter classWriter = generateClass(typeName, JAVA_OBJECT, new String[] {CUSTOM_ATTRIBUTE_GROUP}, getClassSignature(new String[]{CUSTOM_ATTRIBUTE_GROUP}, typeName, apiName), ACC_PUBLIC + ACC_SUPER, apiName);
generateClassMethods(classWriter, typeName, className, apiName, false);
return classWriter;
} | java | private ClassWriter generateInnerSequenceClass(String typeName, String className, String apiName) {
ClassWriter classWriter = generateClass(typeName, JAVA_OBJECT, new String[] {CUSTOM_ATTRIBUTE_GROUP}, getClassSignature(new String[]{CUSTOM_ATTRIBUTE_GROUP}, typeName, apiName), ACC_PUBLIC + ACC_SUPER, apiName);
generateClassMethods(classWriter, typeName, className, apiName, false);
return classWriter;
} | [
"private",
"ClassWriter",
"generateInnerSequenceClass",
"(",
"String",
"typeName",
",",
"String",
"className",
",",
"String",
"apiName",
")",
"{",
"ClassWriter",
"classWriter",
"=",
"generateClass",
"(",
"typeName",
",",
"JAVA_OBJECT",
",",
"new",
"String",
"[",
"]",
"{",
"CUSTOM_ATTRIBUTE_GROUP",
"}",
",",
"getClassSignature",
"(",
"new",
"String",
"[",
"]",
"{",
"CUSTOM_ATTRIBUTE_GROUP",
"}",
",",
"typeName",
",",
"apiName",
")",
",",
"ACC_PUBLIC",
"+",
"ACC_SUPER",
",",
"apiName",
")",
";",
"generateClassMethods",
"(",
"classWriter",
",",
"typeName",
",",
"className",
",",
"apiName",
",",
"false",
")",
";",
"return",
"classWriter",
";",
"}"
] | Creates the inner classes that are used to support the sequence behaviour.
@param typeName The name of the next type to return.
@param className The name of the class which contains the sequence.
@param apiName The name of the generated fluent interface.
@return The {@link ClassWriter} object which represents the inner class created to support sequence behaviour. | [
"Creates",
"the",
"inner",
"classes",
"that",
"are",
"used",
"to",
"support",
"the",
"sequence",
"behaviour",
"."
] | train | https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java#L501-L507 |
rollbar/rollbar-java | rollbar-android/src/main/java/com/rollbar/android/Rollbar.java | Rollbar.log | public void log(Throwable error, Map<String, Object> custom, String description) {
"""
Record an error with custom parameters and human readable description at the default level
returned by {@link com.rollbar.notifier.Rollbar#level}.
@param error the error.
@param custom the custom data.
@param description the human readable description of error.
"""
log(error, custom, description, null);
} | java | public void log(Throwable error, Map<String, Object> custom, String description) {
log(error, custom, description, null);
} | [
"public",
"void",
"log",
"(",
"Throwable",
"error",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"custom",
",",
"String",
"description",
")",
"{",
"log",
"(",
"error",
",",
"custom",
",",
"description",
",",
"null",
")",
";",
"}"
] | Record an error with custom parameters and human readable description at the default level
returned by {@link com.rollbar.notifier.Rollbar#level}.
@param error the error.
@param custom the custom data.
@param description the human readable description of error. | [
"Record",
"an",
"error",
"with",
"custom",
"parameters",
"and",
"human",
"readable",
"description",
"at",
"the",
"default",
"level",
"returned",
"by",
"{",
"@link",
"com",
".",
"rollbar",
".",
"notifier",
".",
"Rollbar#level",
"}",
"."
] | train | https://github.com/rollbar/rollbar-java/blob/5eb4537d1363722b51cfcce55b427cbd8489f17b/rollbar-android/src/main/java/com/rollbar/android/Rollbar.java#L734-L736 |
jlinn/quartz-redis-jobstore | src/main/java/net/joelinn/quartz/jobstore/AbstractRedisStorage.java | AbstractRedisStorage.applyMisfire | protected boolean applyMisfire(OperableTrigger trigger, T jedis) throws JobPersistenceException {
"""
Determine whether or not the given trigger has misfired.
If so, notify the {@link org.quartz.spi.SchedulerSignaler} and update the trigger.
@param trigger the trigger to check for misfire
@param jedis a thread-safe Redis connection
@return false if the trigger has misfired; true otherwise
@throws JobPersistenceException
"""
long misfireTime = System.currentTimeMillis();
if(misfireThreshold > 0){
misfireTime -= misfireThreshold;
}
final Date nextFireTime = trigger.getNextFireTime();
if(nextFireTime == null || nextFireTime.getTime() > misfireTime
|| trigger.getMisfireInstruction() == Trigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY){
return false;
}
Calendar calendar = null;
if(trigger.getCalendarName() != null){
calendar = retrieveCalendar(trigger.getCalendarName(), jedis);
}
signaler.notifyTriggerListenersMisfired((OperableTrigger) trigger.clone());
trigger.updateAfterMisfire(calendar);
storeTrigger(trigger, true, jedis);
if(trigger.getNextFireTime() == null){
setTriggerState(RedisTriggerState.COMPLETED, (double) System.currentTimeMillis(), redisSchema.triggerHashKey(trigger.getKey()), jedis);
signaler.notifySchedulerListenersFinalized(trigger);
}
else if(nextFireTime.equals(trigger.getNextFireTime())){
return false;
}
return true;
} | java | protected boolean applyMisfire(OperableTrigger trigger, T jedis) throws JobPersistenceException {
long misfireTime = System.currentTimeMillis();
if(misfireThreshold > 0){
misfireTime -= misfireThreshold;
}
final Date nextFireTime = trigger.getNextFireTime();
if(nextFireTime == null || nextFireTime.getTime() > misfireTime
|| trigger.getMisfireInstruction() == Trigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY){
return false;
}
Calendar calendar = null;
if(trigger.getCalendarName() != null){
calendar = retrieveCalendar(trigger.getCalendarName(), jedis);
}
signaler.notifyTriggerListenersMisfired((OperableTrigger) trigger.clone());
trigger.updateAfterMisfire(calendar);
storeTrigger(trigger, true, jedis);
if(trigger.getNextFireTime() == null){
setTriggerState(RedisTriggerState.COMPLETED, (double) System.currentTimeMillis(), redisSchema.triggerHashKey(trigger.getKey()), jedis);
signaler.notifySchedulerListenersFinalized(trigger);
}
else if(nextFireTime.equals(trigger.getNextFireTime())){
return false;
}
return true;
} | [
"protected",
"boolean",
"applyMisfire",
"(",
"OperableTrigger",
"trigger",
",",
"T",
"jedis",
")",
"throws",
"JobPersistenceException",
"{",
"long",
"misfireTime",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"if",
"(",
"misfireThreshold",
">",
"0",
")",
"{",
"misfireTime",
"-=",
"misfireThreshold",
";",
"}",
"final",
"Date",
"nextFireTime",
"=",
"trigger",
".",
"getNextFireTime",
"(",
")",
";",
"if",
"(",
"nextFireTime",
"==",
"null",
"||",
"nextFireTime",
".",
"getTime",
"(",
")",
">",
"misfireTime",
"||",
"trigger",
".",
"getMisfireInstruction",
"(",
")",
"==",
"Trigger",
".",
"MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY",
")",
"{",
"return",
"false",
";",
"}",
"Calendar",
"calendar",
"=",
"null",
";",
"if",
"(",
"trigger",
".",
"getCalendarName",
"(",
")",
"!=",
"null",
")",
"{",
"calendar",
"=",
"retrieveCalendar",
"(",
"trigger",
".",
"getCalendarName",
"(",
")",
",",
"jedis",
")",
";",
"}",
"signaler",
".",
"notifyTriggerListenersMisfired",
"(",
"(",
"OperableTrigger",
")",
"trigger",
".",
"clone",
"(",
")",
")",
";",
"trigger",
".",
"updateAfterMisfire",
"(",
"calendar",
")",
";",
"storeTrigger",
"(",
"trigger",
",",
"true",
",",
"jedis",
")",
";",
"if",
"(",
"trigger",
".",
"getNextFireTime",
"(",
")",
"==",
"null",
")",
"{",
"setTriggerState",
"(",
"RedisTriggerState",
".",
"COMPLETED",
",",
"(",
"double",
")",
"System",
".",
"currentTimeMillis",
"(",
")",
",",
"redisSchema",
".",
"triggerHashKey",
"(",
"trigger",
".",
"getKey",
"(",
")",
")",
",",
"jedis",
")",
";",
"signaler",
".",
"notifySchedulerListenersFinalized",
"(",
"trigger",
")",
";",
"}",
"else",
"if",
"(",
"nextFireTime",
".",
"equals",
"(",
"trigger",
".",
"getNextFireTime",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Determine whether or not the given trigger has misfired.
If so, notify the {@link org.quartz.spi.SchedulerSignaler} and update the trigger.
@param trigger the trigger to check for misfire
@param jedis a thread-safe Redis connection
@return false if the trigger has misfired; true otherwise
@throws JobPersistenceException | [
"Determine",
"whether",
"or",
"not",
"the",
"given",
"trigger",
"has",
"misfired",
".",
"If",
"so",
"notify",
"the",
"{"
] | train | https://github.com/jlinn/quartz-redis-jobstore/blob/be9a52ee776d8a09866fe99fd9718bc13a0cb992/src/main/java/net/joelinn/quartz/jobstore/AbstractRedisStorage.java#L560-L588 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/ops/SDBaseOps.java | SDBaseOps.scalarSet | public SDVariable scalarSet(String name, SDVariable in, Number set) {
"""
Return a variable with equal shape to the input, but all elements set to value 'set'
@param name Name of the output variable
@param in Input variable
@param set Value to set
@return Output variable
"""
SDVariable ret = f().scalarSet(in, set);
return updateVariableNameAndReference(ret, name);
} | java | public SDVariable scalarSet(String name, SDVariable in, Number set) {
SDVariable ret = f().scalarSet(in, set);
return updateVariableNameAndReference(ret, name);
} | [
"public",
"SDVariable",
"scalarSet",
"(",
"String",
"name",
",",
"SDVariable",
"in",
",",
"Number",
"set",
")",
"{",
"SDVariable",
"ret",
"=",
"f",
"(",
")",
".",
"scalarSet",
"(",
"in",
",",
"set",
")",
";",
"return",
"updateVariableNameAndReference",
"(",
"ret",
",",
"name",
")",
";",
"}"
] | Return a variable with equal shape to the input, but all elements set to value 'set'
@param name Name of the output variable
@param in Input variable
@param set Value to set
@return Output variable | [
"Return",
"a",
"variable",
"with",
"equal",
"shape",
"to",
"the",
"input",
"but",
"all",
"elements",
"set",
"to",
"value",
"set"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/ops/SDBaseOps.java#L2005-L2008 |
alkacon/opencms-core | src/org/opencms/ui/apps/logfile/CmsLogChannelTable.java | CmsLogChannelTable.changeLoggerLevel | void changeLoggerLevel(LoggerLevel clickedLevel, Set<Logger> clickedLogger) {
"""
Sets a given Level to a Set of Loggers.<p>
@param clickedLevel to be set
@param clickedLogger to get level changed
"""
for (Logger logger : clickedLogger) {
@SuppressWarnings("resource")
LoggerContext context = logger.getContext();
Configuration config = context.getConfiguration();
LoggerConfig loggerConfig = config.getLoggerConfig(logger.getName());
LoggerConfig specificConfig = loggerConfig;
if (!loggerConfig.getName().equals(logger.getName())) {
specificConfig = new LoggerConfig(logger.getName(), clickedLevel.getLevel(), true);
specificConfig.setParent(loggerConfig);
config.addLogger(logger.getName(), specificConfig);
}
specificConfig.setLevel(clickedLevel.getLevel());
context.updateLoggers();
}
updateLevel();
} | java | void changeLoggerLevel(LoggerLevel clickedLevel, Set<Logger> clickedLogger) {
for (Logger logger : clickedLogger) {
@SuppressWarnings("resource")
LoggerContext context = logger.getContext();
Configuration config = context.getConfiguration();
LoggerConfig loggerConfig = config.getLoggerConfig(logger.getName());
LoggerConfig specificConfig = loggerConfig;
if (!loggerConfig.getName().equals(logger.getName())) {
specificConfig = new LoggerConfig(logger.getName(), clickedLevel.getLevel(), true);
specificConfig.setParent(loggerConfig);
config.addLogger(logger.getName(), specificConfig);
}
specificConfig.setLevel(clickedLevel.getLevel());
context.updateLoggers();
}
updateLevel();
} | [
"void",
"changeLoggerLevel",
"(",
"LoggerLevel",
"clickedLevel",
",",
"Set",
"<",
"Logger",
">",
"clickedLogger",
")",
"{",
"for",
"(",
"Logger",
"logger",
":",
"clickedLogger",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"resource\"",
")",
"LoggerContext",
"context",
"=",
"logger",
".",
"getContext",
"(",
")",
";",
"Configuration",
"config",
"=",
"context",
".",
"getConfiguration",
"(",
")",
";",
"LoggerConfig",
"loggerConfig",
"=",
"config",
".",
"getLoggerConfig",
"(",
"logger",
".",
"getName",
"(",
")",
")",
";",
"LoggerConfig",
"specificConfig",
"=",
"loggerConfig",
";",
"if",
"(",
"!",
"loggerConfig",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"logger",
".",
"getName",
"(",
")",
")",
")",
"{",
"specificConfig",
"=",
"new",
"LoggerConfig",
"(",
"logger",
".",
"getName",
"(",
")",
",",
"clickedLevel",
".",
"getLevel",
"(",
")",
",",
"true",
")",
";",
"specificConfig",
".",
"setParent",
"(",
"loggerConfig",
")",
";",
"config",
".",
"addLogger",
"(",
"logger",
".",
"getName",
"(",
")",
",",
"specificConfig",
")",
";",
"}",
"specificConfig",
".",
"setLevel",
"(",
"clickedLevel",
".",
"getLevel",
"(",
")",
")",
";",
"context",
".",
"updateLoggers",
"(",
")",
";",
"}",
"updateLevel",
"(",
")",
";",
"}"
] | Sets a given Level to a Set of Loggers.<p>
@param clickedLevel to be set
@param clickedLogger to get level changed | [
"Sets",
"a",
"given",
"Level",
"to",
"a",
"Set",
"of",
"Loggers",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/apps/logfile/CmsLogChannelTable.java#L504-L521 |
jtablesaw/tablesaw | core/src/main/java/tech/tablesaw/aggregate/CrossTab.java | CrossTab.rowPercents | public static Table rowPercents(Table table, CategoricalColumn<?> column1, CategoricalColumn<?> column2) {
"""
Returns a table containing the row percents made from a source table, after first calculating the counts
cross-tabulated from the given columns
"""
Table xTabs = counts(table, column1, column2);
return rowPercents(xTabs);
} | java | public static Table rowPercents(Table table, CategoricalColumn<?> column1, CategoricalColumn<?> column2) {
Table xTabs = counts(table, column1, column2);
return rowPercents(xTabs);
} | [
"public",
"static",
"Table",
"rowPercents",
"(",
"Table",
"table",
",",
"CategoricalColumn",
"<",
"?",
">",
"column1",
",",
"CategoricalColumn",
"<",
"?",
">",
"column2",
")",
"{",
"Table",
"xTabs",
"=",
"counts",
"(",
"table",
",",
"column1",
",",
"column2",
")",
";",
"return",
"rowPercents",
"(",
"xTabs",
")",
";",
"}"
] | Returns a table containing the row percents made from a source table, after first calculating the counts
cross-tabulated from the given columns | [
"Returns",
"a",
"table",
"containing",
"the",
"row",
"percents",
"made",
"from",
"a",
"source",
"table",
"after",
"first",
"calculating",
"the",
"counts",
"cross",
"-",
"tabulated",
"from",
"the",
"given",
"columns"
] | train | https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/aggregate/CrossTab.java#L261-L264 |
jruby/jcodings | src/org/jcodings/AbstractEncoding.java | AbstractEncoding.isNewLine | @Override
public boolean isNewLine(byte[]bytes, int p, int end) {
"""
onigenc_is_mbc_newline_0x0a / used also by multibyte encodings
"""
return p < end ? bytes[p] == Encoding.NEW_LINE : false;
} | java | @Override
public boolean isNewLine(byte[]bytes, int p, int end) {
return p < end ? bytes[p] == Encoding.NEW_LINE : false;
} | [
"@",
"Override",
"public",
"boolean",
"isNewLine",
"(",
"byte",
"[",
"]",
"bytes",
",",
"int",
"p",
",",
"int",
"end",
")",
"{",
"return",
"p",
"<",
"end",
"?",
"bytes",
"[",
"p",
"]",
"==",
"Encoding",
".",
"NEW_LINE",
":",
"false",
";",
"}"
] | onigenc_is_mbc_newline_0x0a / used also by multibyte encodings | [
"onigenc_is_mbc_newline_0x0a",
"/",
"used",
"also",
"by",
"multibyte",
"encodings"
] | train | https://github.com/jruby/jcodings/blob/8e09c6caab59f9a0b9760e57d2708eea185c2de1/src/org/jcodings/AbstractEncoding.java#L51-L54 |
Netflix/astyanax | astyanax-entity-mapper/src/main/java/com/netflix/astyanax/entitystore/CompositeEntityMapper.java | CompositeEntityMapper.constructEntity | T constructEntity(K id, com.netflix.astyanax.model.Column<ByteBuffer> column) {
"""
Construct an entity object from a row key and column list.
@param id
@param cl
@return
"""
try {
// First, construct the parent class and give it an id
T entity = clazz.newInstance();
idMapper.setValue(entity, id);
setEntityFieldsFromColumnName(entity, column.getRawName().duplicate());
valueMapper.setField(entity, column.getByteBufferValue().duplicate());
return entity;
} catch(Exception e) {
throw new PersistenceException("failed to construct entity", e);
}
} | java | T constructEntity(K id, com.netflix.astyanax.model.Column<ByteBuffer> column) {
try {
// First, construct the parent class and give it an id
T entity = clazz.newInstance();
idMapper.setValue(entity, id);
setEntityFieldsFromColumnName(entity, column.getRawName().duplicate());
valueMapper.setField(entity, column.getByteBufferValue().duplicate());
return entity;
} catch(Exception e) {
throw new PersistenceException("failed to construct entity", e);
}
} | [
"T",
"constructEntity",
"(",
"K",
"id",
",",
"com",
".",
"netflix",
".",
"astyanax",
".",
"model",
".",
"Column",
"<",
"ByteBuffer",
">",
"column",
")",
"{",
"try",
"{",
"// First, construct the parent class and give it an id",
"T",
"entity",
"=",
"clazz",
".",
"newInstance",
"(",
")",
";",
"idMapper",
".",
"setValue",
"(",
"entity",
",",
"id",
")",
";",
"setEntityFieldsFromColumnName",
"(",
"entity",
",",
"column",
".",
"getRawName",
"(",
")",
".",
"duplicate",
"(",
")",
")",
";",
"valueMapper",
".",
"setField",
"(",
"entity",
",",
"column",
".",
"getByteBufferValue",
"(",
")",
".",
"duplicate",
"(",
")",
")",
";",
"return",
"entity",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"PersistenceException",
"(",
"\"failed to construct entity\"",
",",
"e",
")",
";",
"}",
"}"
] | Construct an entity object from a row key and column list.
@param id
@param cl
@return | [
"Construct",
"an",
"entity",
"object",
"from",
"a",
"row",
"key",
"and",
"column",
"list",
"."
] | train | https://github.com/Netflix/astyanax/blob/bcc3fd26e2dda05a923751aa32b139f6209fecdf/astyanax-entity-mapper/src/main/java/com/netflix/astyanax/entitystore/CompositeEntityMapper.java#L248-L259 |
xiancloud/xian | xian-zookeeper/xian-curator/xian-curator-x-discovery/src/main/java/org/apache/curator/x/discovery/details/ServiceDiscoveryImpl.java | ServiceDiscoveryImpl.queryForInstances | @Override
public Collection<ServiceInstance<T>> queryForInstances(String name) throws Exception {
"""
Return all known instances for the given group
@param name name of the group
@return list of instances (or an empty list)
@throws Exception errors
"""
return queryForInstances(name, null);
} | java | @Override
public Collection<ServiceInstance<T>> queryForInstances(String name) throws Exception
{
return queryForInstances(name, null);
} | [
"@",
"Override",
"public",
"Collection",
"<",
"ServiceInstance",
"<",
"T",
">",
">",
"queryForInstances",
"(",
"String",
"name",
")",
"throws",
"Exception",
"{",
"return",
"queryForInstances",
"(",
"name",
",",
"null",
")",
";",
"}"
] | Return all known instances for the given group
@param name name of the group
@return list of instances (or an empty list)
@throws Exception errors | [
"Return",
"all",
"known",
"instances",
"for",
"the",
"given",
"group"
] | train | https://github.com/xiancloud/xian/blob/1948e088545553d2745b2c86d8b5a64988bb850e/xian-zookeeper/xian-curator/xian-curator-x-discovery/src/main/java/org/apache/curator/x/discovery/details/ServiceDiscoveryImpl.java#L307-L311 |
zandero/settings | src/main/java/com/zandero/settings/Settings.java | Settings.getList | public <T> List<T> getList(String name, Class<T> type) {
"""
Returns setting a list of objects
@param name setting name
@param type type of object
@param <T> type
@return list of found setting
@throws IllegalArgumentException in case settings could not be converted to given type
"""
Object value = super.get(name);
// make sure correct objects are returned
if (value instanceof List) {
ArrayList<T> output = new ArrayList<>();
List list = (List) value;
for (Object item : list) {
output.add(type.cast(item));
}
return output;
}
throw new IllegalArgumentException("Setting: '" + name + "', can't be converted to List<" + type.getName() + ">: '" + value + "'!");
} | java | public <T> List<T> getList(String name, Class<T> type) {
Object value = super.get(name);
// make sure correct objects are returned
if (value instanceof List) {
ArrayList<T> output = new ArrayList<>();
List list = (List) value;
for (Object item : list) {
output.add(type.cast(item));
}
return output;
}
throw new IllegalArgumentException("Setting: '" + name + "', can't be converted to List<" + type.getName() + ">: '" + value + "'!");
} | [
"public",
"<",
"T",
">",
"List",
"<",
"T",
">",
"getList",
"(",
"String",
"name",
",",
"Class",
"<",
"T",
">",
"type",
")",
"{",
"Object",
"value",
"=",
"super",
".",
"get",
"(",
"name",
")",
";",
"// make sure correct objects are returned",
"if",
"(",
"value",
"instanceof",
"List",
")",
"{",
"ArrayList",
"<",
"T",
">",
"output",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"List",
"list",
"=",
"(",
"List",
")",
"value",
";",
"for",
"(",
"Object",
"item",
":",
"list",
")",
"{",
"output",
".",
"add",
"(",
"type",
".",
"cast",
"(",
"item",
")",
")",
";",
"}",
"return",
"output",
";",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Setting: '\"",
"+",
"name",
"+",
"\"', can't be converted to List<\"",
"+",
"type",
".",
"getName",
"(",
")",
"+",
"\">: '\"",
"+",
"value",
"+",
"\"'!\"",
")",
";",
"}"
] | Returns setting a list of objects
@param name setting name
@param type type of object
@param <T> type
@return list of found setting
@throws IllegalArgumentException in case settings could not be converted to given type | [
"Returns",
"setting",
"a",
"list",
"of",
"objects"
] | train | https://github.com/zandero/settings/blob/802b44f41bc75e7eb2761028db8c73b7e59620c7/src/main/java/com/zandero/settings/Settings.java#L201-L219 |
carewebframework/carewebframework-core | org.carewebframework.shell/src/main/java/org/carewebframework/shell/CareWebUtil.java | CareWebUtil.associateCSH | public static void associateCSH(BaseUIComponent component, String module, String topic, String label) {
"""
Associates help context with a component.
@param component The component.
@param module The help module identifier.
@param topic The topic id.
@param label The topic label.
"""
HelpContext context = new HelpContext(module, topic, label);
HelpUtil.associateCSH(component, context, getShell());
} | java | public static void associateCSH(BaseUIComponent component, String module, String topic, String label) {
HelpContext context = new HelpContext(module, topic, label);
HelpUtil.associateCSH(component, context, getShell());
} | [
"public",
"static",
"void",
"associateCSH",
"(",
"BaseUIComponent",
"component",
",",
"String",
"module",
",",
"String",
"topic",
",",
"String",
"label",
")",
"{",
"HelpContext",
"context",
"=",
"new",
"HelpContext",
"(",
"module",
",",
"topic",
",",
"label",
")",
";",
"HelpUtil",
".",
"associateCSH",
"(",
"component",
",",
"context",
",",
"getShell",
"(",
")",
")",
";",
"}"
] | Associates help context with a component.
@param component The component.
@param module The help module identifier.
@param topic The topic id.
@param label The topic label. | [
"Associates",
"help",
"context",
"with",
"a",
"component",
"."
] | train | https://github.com/carewebframework/carewebframework-core/blob/fa3252d4f7541dbe151b92c3d4f6f91433cd1673/org.carewebframework.shell/src/main/java/org/carewebframework/shell/CareWebUtil.java#L124-L127 |
zeroturnaround/zt-exec | src/main/java/org/zeroturnaround/exec/ProcessInitException.java | ProcessInitException.newInstance | public static ProcessInitException newInstance(String prefix, IOException e) {
"""
Try to wrap a given {@link IOException} into a {@link ProcessInitException}.
@param prefix prefix to be added in the message.
@param e existing exception possibly containing an error code in its message.
@return new exception containing the prefix, error code and its description in the message plus the error code value as a field,
<code>null</code> if we were unable to find an error code from the original message.
"""
String m = e.getMessage();
if (m == null) {
return null;
}
int i = m.lastIndexOf(BEFORE_CODE);
if (i == -1) {
return null;
}
int j = m.indexOf(AFTER_CODE, i);
if (j == -1) {
return null;
}
int code;
try {
code = Integer.parseInt(m.substring(i + BEFORE_CODE.length(), j));
}
catch (NumberFormatException n) {
return null;
}
return new ProcessInitException(prefix + NEW_INFIX + m.substring(i + BEFORE_CODE.length()), e, code);
} | java | public static ProcessInitException newInstance(String prefix, IOException e) {
String m = e.getMessage();
if (m == null) {
return null;
}
int i = m.lastIndexOf(BEFORE_CODE);
if (i == -1) {
return null;
}
int j = m.indexOf(AFTER_CODE, i);
if (j == -1) {
return null;
}
int code;
try {
code = Integer.parseInt(m.substring(i + BEFORE_CODE.length(), j));
}
catch (NumberFormatException n) {
return null;
}
return new ProcessInitException(prefix + NEW_INFIX + m.substring(i + BEFORE_CODE.length()), e, code);
} | [
"public",
"static",
"ProcessInitException",
"newInstance",
"(",
"String",
"prefix",
",",
"IOException",
"e",
")",
"{",
"String",
"m",
"=",
"e",
".",
"getMessage",
"(",
")",
";",
"if",
"(",
"m",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"int",
"i",
"=",
"m",
".",
"lastIndexOf",
"(",
"BEFORE_CODE",
")",
";",
"if",
"(",
"i",
"==",
"-",
"1",
")",
"{",
"return",
"null",
";",
"}",
"int",
"j",
"=",
"m",
".",
"indexOf",
"(",
"AFTER_CODE",
",",
"i",
")",
";",
"if",
"(",
"j",
"==",
"-",
"1",
")",
"{",
"return",
"null",
";",
"}",
"int",
"code",
";",
"try",
"{",
"code",
"=",
"Integer",
".",
"parseInt",
"(",
"m",
".",
"substring",
"(",
"i",
"+",
"BEFORE_CODE",
".",
"length",
"(",
")",
",",
"j",
")",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"n",
")",
"{",
"return",
"null",
";",
"}",
"return",
"new",
"ProcessInitException",
"(",
"prefix",
"+",
"NEW_INFIX",
"+",
"m",
".",
"substring",
"(",
"i",
"+",
"BEFORE_CODE",
".",
"length",
"(",
")",
")",
",",
"e",
",",
"code",
")",
";",
"}"
] | Try to wrap a given {@link IOException} into a {@link ProcessInitException}.
@param prefix prefix to be added in the message.
@param e existing exception possibly containing an error code in its message.
@return new exception containing the prefix, error code and its description in the message plus the error code value as a field,
<code>null</code> if we were unable to find an error code from the original message. | [
"Try",
"to",
"wrap",
"a",
"given",
"{",
"@link",
"IOException",
"}",
"into",
"a",
"{",
"@link",
"ProcessInitException",
"}",
"."
] | train | https://github.com/zeroturnaround/zt-exec/blob/6c3b93b99bf3c69c9f41d6350bf7707005b6a4cd/src/main/java/org/zeroturnaround/exec/ProcessInitException.java#L60-L81 |
Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/GVRSceneObject.java | GVRSceneObject.prettyPrint | public void prettyPrint(StringBuffer sb, int indent) {
"""
Generate debug dump of the tree from the scene object.
It should include a newline character at the end.
@param sb the {@code StringBuffer} to dump the object.
@param indent indentation level as number of spaces.
"""
sb.append(Log.getSpaces(indent));
sb.append(getClass().getSimpleName());
sb.append(" [name=");
sb.append(this.getName());
sb.append("]");
sb.append(System.lineSeparator());
GVRRenderData rdata = getRenderData();
GVRTransform trans = getTransform();
if (rdata == null) {
sb.append(Log.getSpaces(indent + 2));
sb.append("RenderData: null");
sb.append(System.lineSeparator());
} else {
rdata.prettyPrint(sb, indent + 2);
}
sb.append(Log.getSpaces(indent + 2));
sb.append("Transform: "); sb.append(trans);
sb.append(System.lineSeparator());
// dump its children
for (GVRSceneObject child : getChildren()) {
child.prettyPrint(sb, indent + 2);
}
} | java | public void prettyPrint(StringBuffer sb, int indent) {
sb.append(Log.getSpaces(indent));
sb.append(getClass().getSimpleName());
sb.append(" [name=");
sb.append(this.getName());
sb.append("]");
sb.append(System.lineSeparator());
GVRRenderData rdata = getRenderData();
GVRTransform trans = getTransform();
if (rdata == null) {
sb.append(Log.getSpaces(indent + 2));
sb.append("RenderData: null");
sb.append(System.lineSeparator());
} else {
rdata.prettyPrint(sb, indent + 2);
}
sb.append(Log.getSpaces(indent + 2));
sb.append("Transform: "); sb.append(trans);
sb.append(System.lineSeparator());
// dump its children
for (GVRSceneObject child : getChildren()) {
child.prettyPrint(sb, indent + 2);
}
} | [
"public",
"void",
"prettyPrint",
"(",
"StringBuffer",
"sb",
",",
"int",
"indent",
")",
"{",
"sb",
".",
"append",
"(",
"Log",
".",
"getSpaces",
"(",
"indent",
")",
")",
";",
"sb",
".",
"append",
"(",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\" [name=\"",
")",
";",
"sb",
".",
"append",
"(",
"this",
".",
"getName",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"]\"",
")",
";",
"sb",
".",
"append",
"(",
"System",
".",
"lineSeparator",
"(",
")",
")",
";",
"GVRRenderData",
"rdata",
"=",
"getRenderData",
"(",
")",
";",
"GVRTransform",
"trans",
"=",
"getTransform",
"(",
")",
";",
"if",
"(",
"rdata",
"==",
"null",
")",
"{",
"sb",
".",
"append",
"(",
"Log",
".",
"getSpaces",
"(",
"indent",
"+",
"2",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"RenderData: null\"",
")",
";",
"sb",
".",
"append",
"(",
"System",
".",
"lineSeparator",
"(",
")",
")",
";",
"}",
"else",
"{",
"rdata",
".",
"prettyPrint",
"(",
"sb",
",",
"indent",
"+",
"2",
")",
";",
"}",
"sb",
".",
"append",
"(",
"Log",
".",
"getSpaces",
"(",
"indent",
"+",
"2",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"Transform: \"",
")",
";",
"sb",
".",
"append",
"(",
"trans",
")",
";",
"sb",
".",
"append",
"(",
"System",
".",
"lineSeparator",
"(",
")",
")",
";",
"// dump its children",
"for",
"(",
"GVRSceneObject",
"child",
":",
"getChildren",
"(",
")",
")",
"{",
"child",
".",
"prettyPrint",
"(",
"sb",
",",
"indent",
"+",
"2",
")",
";",
"}",
"}"
] | Generate debug dump of the tree from the scene object.
It should include a newline character at the end.
@param sb the {@code StringBuffer} to dump the object.
@param indent indentation level as number of spaces. | [
"Generate",
"debug",
"dump",
"of",
"the",
"tree",
"from",
"the",
"scene",
"object",
".",
"It",
"should",
"include",
"a",
"newline",
"character",
"at",
"the",
"end",
"."
] | train | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/GVRSceneObject.java#L1183-L1208 |
h2oai/h2o-3 | h2o-core/src/main/java/water/util/VecUtils.java | VecUtils.UUIDToStringVec | public static Vec UUIDToStringVec(Vec src) {
"""
Create a new {@link Vec} of string values from a UUID {@link Vec}.
String {@link Vec} is the standard hexadecimal representations of a UUID.
@param src a UUID {@link Vec}
@return a string {@link Vec}
"""
if( !src.isUUID() ) throw new H2OIllegalArgumentException("UUIDToStringVec() conversion only works on UUID columns");
Vec res = new MRTask() {
@Override public void map(Chunk chk, NewChunk newChk) {
if (chk instanceof C0DChunk) { // all NAs
for (int i=0; i < chk._len; i++)
newChk.addNA();
} else {
for (int i=0; i < chk._len; i++) {
if (!chk.isNA(i))
newChk.addStr(PrettyPrint.UUID(chk.at16l(i), chk.at16h(i)));
else
newChk.addNA();
}
}
}
}.doAll(Vec.T_STR,src).outputFrame().anyVec();
assert res != null;
return res;
} | java | public static Vec UUIDToStringVec(Vec src) {
if( !src.isUUID() ) throw new H2OIllegalArgumentException("UUIDToStringVec() conversion only works on UUID columns");
Vec res = new MRTask() {
@Override public void map(Chunk chk, NewChunk newChk) {
if (chk instanceof C0DChunk) { // all NAs
for (int i=0; i < chk._len; i++)
newChk.addNA();
} else {
for (int i=0; i < chk._len; i++) {
if (!chk.isNA(i))
newChk.addStr(PrettyPrint.UUID(chk.at16l(i), chk.at16h(i)));
else
newChk.addNA();
}
}
}
}.doAll(Vec.T_STR,src).outputFrame().anyVec();
assert res != null;
return res;
} | [
"public",
"static",
"Vec",
"UUIDToStringVec",
"(",
"Vec",
"src",
")",
"{",
"if",
"(",
"!",
"src",
".",
"isUUID",
"(",
")",
")",
"throw",
"new",
"H2OIllegalArgumentException",
"(",
"\"UUIDToStringVec() conversion only works on UUID columns\"",
")",
";",
"Vec",
"res",
"=",
"new",
"MRTask",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"map",
"(",
"Chunk",
"chk",
",",
"NewChunk",
"newChk",
")",
"{",
"if",
"(",
"chk",
"instanceof",
"C0DChunk",
")",
"{",
"// all NAs",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"chk",
".",
"_len",
";",
"i",
"++",
")",
"newChk",
".",
"addNA",
"(",
")",
";",
"}",
"else",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"chk",
".",
"_len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"chk",
".",
"isNA",
"(",
"i",
")",
")",
"newChk",
".",
"addStr",
"(",
"PrettyPrint",
".",
"UUID",
"(",
"chk",
".",
"at16l",
"(",
"i",
")",
",",
"chk",
".",
"at16h",
"(",
"i",
")",
")",
")",
";",
"else",
"newChk",
".",
"addNA",
"(",
")",
";",
"}",
"}",
"}",
"}",
".",
"doAll",
"(",
"Vec",
".",
"T_STR",
",",
"src",
")",
".",
"outputFrame",
"(",
")",
".",
"anyVec",
"(",
")",
";",
"assert",
"res",
"!=",
"null",
";",
"return",
"res",
";",
"}"
] | Create a new {@link Vec} of string values from a UUID {@link Vec}.
String {@link Vec} is the standard hexadecimal representations of a UUID.
@param src a UUID {@link Vec}
@return a string {@link Vec} | [
"Create",
"a",
"new",
"{",
"@link",
"Vec",
"}",
"of",
"string",
"values",
"from",
"a",
"UUID",
"{",
"@link",
"Vec",
"}",
"."
] | train | https://github.com/h2oai/h2o-3/blob/845eb49dfeaadf638b6e2f779d82fac996391fad/h2o-core/src/main/java/water/util/VecUtils.java#L367-L386 |
apollographql/apollo-android | apollo-api/src/main/java/com/apollographql/apollo/api/ResponseField.java | ResponseField.forBoolean | public static ResponseField forBoolean(String responseName, String fieldName, Map<String, Object> arguments,
boolean optional, List<Condition> conditions) {
"""
Factory method for creating a Field instance representing {@link Type#BOOLEAN}.
@param responseName alias for the result of a field
@param fieldName name of the field in the GraphQL operation
@param arguments arguments to be passed along with the field
@param optional whether the arguments passed along are optional or required
@param conditions list of conditions for this field
@return Field instance representing {@link Type#BOOLEAN}
"""
return new ResponseField(Type.BOOLEAN, responseName, fieldName, arguments, optional, conditions);
} | java | public static ResponseField forBoolean(String responseName, String fieldName, Map<String, Object> arguments,
boolean optional, List<Condition> conditions) {
return new ResponseField(Type.BOOLEAN, responseName, fieldName, arguments, optional, conditions);
} | [
"public",
"static",
"ResponseField",
"forBoolean",
"(",
"String",
"responseName",
",",
"String",
"fieldName",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"arguments",
",",
"boolean",
"optional",
",",
"List",
"<",
"Condition",
">",
"conditions",
")",
"{",
"return",
"new",
"ResponseField",
"(",
"Type",
".",
"BOOLEAN",
",",
"responseName",
",",
"fieldName",
",",
"arguments",
",",
"optional",
",",
"conditions",
")",
";",
"}"
] | Factory method for creating a Field instance representing {@link Type#BOOLEAN}.
@param responseName alias for the result of a field
@param fieldName name of the field in the GraphQL operation
@param arguments arguments to be passed along with the field
@param optional whether the arguments passed along are optional or required
@param conditions list of conditions for this field
@return Field instance representing {@link Type#BOOLEAN} | [
"Factory",
"method",
"for",
"creating",
"a",
"Field",
"instance",
"representing",
"{",
"@link",
"Type#BOOLEAN",
"}",
"."
] | train | https://github.com/apollographql/apollo-android/blob/a78869a76e17f77e42c7a88f0099914fe7ffa5b6/apollo-api/src/main/java/com/apollographql/apollo/api/ResponseField.java#L100-L103 |
tvbarthel/Cheerleader | library/src/main/java/fr/tvbarthel/cheerleader/library/player/PlaybackService.java | PlaybackService.loadArtwork | private void loadArtwork(final Context context, final String artworkUrl) {
"""
Load the track artwork.
@param context context used by {@link com.squareup.picasso.Picasso} to load the artwork asynchronously.
@param artworkUrl artwork url of the track.
"""
mMainThreadHandler.post(new Runnable() {
@Override
public void run() {
final Picasso picasso = Picasso.with(context);
picasso.cancelRequest(mMediaSessionArtworkTarget);
picasso.load(artworkUrl)
.centerCrop()
.resize(MEDIA_SESSION_ARTWORK_SIZE, MEDIA_SESSION_ARTWORK_SIZE)
.into(mMediaSessionArtworkTarget);
}
});
} | java | private void loadArtwork(final Context context, final String artworkUrl) {
mMainThreadHandler.post(new Runnable() {
@Override
public void run() {
final Picasso picasso = Picasso.with(context);
picasso.cancelRequest(mMediaSessionArtworkTarget);
picasso.load(artworkUrl)
.centerCrop()
.resize(MEDIA_SESSION_ARTWORK_SIZE, MEDIA_SESSION_ARTWORK_SIZE)
.into(mMediaSessionArtworkTarget);
}
});
} | [
"private",
"void",
"loadArtwork",
"(",
"final",
"Context",
"context",
",",
"final",
"String",
"artworkUrl",
")",
"{",
"mMainThreadHandler",
".",
"post",
"(",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"final",
"Picasso",
"picasso",
"=",
"Picasso",
".",
"with",
"(",
"context",
")",
";",
"picasso",
".",
"cancelRequest",
"(",
"mMediaSessionArtworkTarget",
")",
";",
"picasso",
".",
"load",
"(",
"artworkUrl",
")",
".",
"centerCrop",
"(",
")",
".",
"resize",
"(",
"MEDIA_SESSION_ARTWORK_SIZE",
",",
"MEDIA_SESSION_ARTWORK_SIZE",
")",
".",
"into",
"(",
"mMediaSessionArtworkTarget",
")",
";",
"}",
"}",
")",
";",
"}"
] | Load the track artwork.
@param context context used by {@link com.squareup.picasso.Picasso} to load the artwork asynchronously.
@param artworkUrl artwork url of the track. | [
"Load",
"the",
"track",
"artwork",
"."
] | train | https://github.com/tvbarthel/Cheerleader/blob/f61527e4cc44fcd0ed2e1e98aca285f8c236f24e/library/src/main/java/fr/tvbarthel/cheerleader/library/player/PlaybackService.java#L778-L790 |
JodaOrg/joda-time | src/main/java/org/joda/time/convert/CalendarConverter.java | CalendarConverter.getChronology | public Chronology getChronology(Object object, Chronology chrono) {
"""
Gets the chronology.
<p>
If a chronology is specified then it is used.
Otherwise, it is the GJChronology if a GregorianCalendar is used,
BuddhistChronology if a BuddhistCalendar is used or ISOChronology otherwise.
The time zone is extracted from the calendar if possible, default used if not.
@param object the Calendar to convert, must not be null
@param chrono the chronology to use, null means use Calendar
@return the chronology, never null
@throws NullPointerException if the object is null
@throws ClassCastException if the object is an invalid type
"""
if (chrono != null) {
return chrono;
}
Calendar cal = (Calendar) object;
DateTimeZone zone = null;
try {
zone = DateTimeZone.forTimeZone(cal.getTimeZone());
} catch (IllegalArgumentException ex) {
zone = DateTimeZone.getDefault();
}
return getChronology(cal, zone);
} | java | public Chronology getChronology(Object object, Chronology chrono) {
if (chrono != null) {
return chrono;
}
Calendar cal = (Calendar) object;
DateTimeZone zone = null;
try {
zone = DateTimeZone.forTimeZone(cal.getTimeZone());
} catch (IllegalArgumentException ex) {
zone = DateTimeZone.getDefault();
}
return getChronology(cal, zone);
} | [
"public",
"Chronology",
"getChronology",
"(",
"Object",
"object",
",",
"Chronology",
"chrono",
")",
"{",
"if",
"(",
"chrono",
"!=",
"null",
")",
"{",
"return",
"chrono",
";",
"}",
"Calendar",
"cal",
"=",
"(",
"Calendar",
")",
"object",
";",
"DateTimeZone",
"zone",
"=",
"null",
";",
"try",
"{",
"zone",
"=",
"DateTimeZone",
".",
"forTimeZone",
"(",
"cal",
".",
"getTimeZone",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"ex",
")",
"{",
"zone",
"=",
"DateTimeZone",
".",
"getDefault",
"(",
")",
";",
"}",
"return",
"getChronology",
"(",
"cal",
",",
"zone",
")",
";",
"}"
] | Gets the chronology.
<p>
If a chronology is specified then it is used.
Otherwise, it is the GJChronology if a GregorianCalendar is used,
BuddhistChronology if a BuddhistCalendar is used or ISOChronology otherwise.
The time zone is extracted from the calendar if possible, default used if not.
@param object the Calendar to convert, must not be null
@param chrono the chronology to use, null means use Calendar
@return the chronology, never null
@throws NullPointerException if the object is null
@throws ClassCastException if the object is an invalid type | [
"Gets",
"the",
"chronology",
".",
"<p",
">",
"If",
"a",
"chronology",
"is",
"specified",
"then",
"it",
"is",
"used",
".",
"Otherwise",
"it",
"is",
"the",
"GJChronology",
"if",
"a",
"GregorianCalendar",
"is",
"used",
"BuddhistChronology",
"if",
"a",
"BuddhistCalendar",
"is",
"used",
"or",
"ISOChronology",
"otherwise",
".",
"The",
"time",
"zone",
"is",
"extracted",
"from",
"the",
"calendar",
"if",
"possible",
"default",
"used",
"if",
"not",
"."
] | train | https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/convert/CalendarConverter.java#L67-L80 |
Erudika/para | para-server/src/main/java/com/erudika/para/i18n/LanguageUtils.java | LanguageUtils.disapproveTranslation | public boolean disapproveTranslation(String appid, String langCode, String key) {
"""
Disapproves a translation for a given language.
@param appid appid name of the {@link com.erudika.para.core.App}
@param langCode the 2-letter language code
@param key the translation key
@return true if the operation was successful
"""
if (StringUtils.isBlank(langCode) || key == null || getDefaultLanguageCode().equals(langCode)) {
return false;
}
Sysprop s = dao.read(appid, keyPrefix.concat(langCode));
if (s != null) {
String value = getDefaultLanguage(appid).get(key);
s.addProperty(key, value);
dao.update(appid, s);
if (LANG_CACHE.containsKey(langCode)) {
LANG_CACHE.get(langCode).put(key, value);
}
updateTranslationProgressMap(appid, langCode, MINUS);
return true;
}
return false;
} | java | public boolean disapproveTranslation(String appid, String langCode, String key) {
if (StringUtils.isBlank(langCode) || key == null || getDefaultLanguageCode().equals(langCode)) {
return false;
}
Sysprop s = dao.read(appid, keyPrefix.concat(langCode));
if (s != null) {
String value = getDefaultLanguage(appid).get(key);
s.addProperty(key, value);
dao.update(appid, s);
if (LANG_CACHE.containsKey(langCode)) {
LANG_CACHE.get(langCode).put(key, value);
}
updateTranslationProgressMap(appid, langCode, MINUS);
return true;
}
return false;
} | [
"public",
"boolean",
"disapproveTranslation",
"(",
"String",
"appid",
",",
"String",
"langCode",
",",
"String",
"key",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"langCode",
")",
"||",
"key",
"==",
"null",
"||",
"getDefaultLanguageCode",
"(",
")",
".",
"equals",
"(",
"langCode",
")",
")",
"{",
"return",
"false",
";",
"}",
"Sysprop",
"s",
"=",
"dao",
".",
"read",
"(",
"appid",
",",
"keyPrefix",
".",
"concat",
"(",
"langCode",
")",
")",
";",
"if",
"(",
"s",
"!=",
"null",
")",
"{",
"String",
"value",
"=",
"getDefaultLanguage",
"(",
"appid",
")",
".",
"get",
"(",
"key",
")",
";",
"s",
".",
"addProperty",
"(",
"key",
",",
"value",
")",
";",
"dao",
".",
"update",
"(",
"appid",
",",
"s",
")",
";",
"if",
"(",
"LANG_CACHE",
".",
"containsKey",
"(",
"langCode",
")",
")",
"{",
"LANG_CACHE",
".",
"get",
"(",
"langCode",
")",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"}",
"updateTranslationProgressMap",
"(",
"appid",
",",
"langCode",
",",
"MINUS",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Disapproves a translation for a given language.
@param appid appid name of the {@link com.erudika.para.core.App}
@param langCode the 2-letter language code
@param key the translation key
@return true if the operation was successful | [
"Disapproves",
"a",
"translation",
"for",
"a",
"given",
"language",
"."
] | train | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/i18n/LanguageUtils.java#L351-L367 |
khuxtable/seaglass | src/main/java/com/seaglasslookandfeel/painter/ScrollBarButtonPainter.java | ScrollBarButtonPainter.fillScrollBarButtonInteriorColors | private void fillScrollBarButtonInteriorColors(Graphics2D g, Shape s, boolean isIncrease, boolean buttonsTogether) {
"""
DOCUMENT ME!
@param g DOCUMENT ME!
@param s DOCUMENT ME!
@param isIncrease DOCUMENT ME!
@param buttonsTogether DOCUMENT ME!
"""
g.setPaint(getScrollBarButtonBackgroundPaint(s, isIncrease, buttonsTogether));
g.fill(s);
int width = s.getBounds().width;
g.setPaint(getScrollBarButtonLinePaint());
g.drawLine(0, 0, width - 1, 0);
if (state != Which.FOREGROUND_CAP && buttonsTogether) {
int height = s.getBounds().height;
g.setPaint(getScrollBarButtonDividerPaint(isIncrease));
g.drawLine(width - 1, 1, width - 1, height - 1);
}
} | java | private void fillScrollBarButtonInteriorColors(Graphics2D g, Shape s, boolean isIncrease, boolean buttonsTogether) {
g.setPaint(getScrollBarButtonBackgroundPaint(s, isIncrease, buttonsTogether));
g.fill(s);
int width = s.getBounds().width;
g.setPaint(getScrollBarButtonLinePaint());
g.drawLine(0, 0, width - 1, 0);
if (state != Which.FOREGROUND_CAP && buttonsTogether) {
int height = s.getBounds().height;
g.setPaint(getScrollBarButtonDividerPaint(isIncrease));
g.drawLine(width - 1, 1, width - 1, height - 1);
}
} | [
"private",
"void",
"fillScrollBarButtonInteriorColors",
"(",
"Graphics2D",
"g",
",",
"Shape",
"s",
",",
"boolean",
"isIncrease",
",",
"boolean",
"buttonsTogether",
")",
"{",
"g",
".",
"setPaint",
"(",
"getScrollBarButtonBackgroundPaint",
"(",
"s",
",",
"isIncrease",
",",
"buttonsTogether",
")",
")",
";",
"g",
".",
"fill",
"(",
"s",
")",
";",
"int",
"width",
"=",
"s",
".",
"getBounds",
"(",
")",
".",
"width",
";",
"g",
".",
"setPaint",
"(",
"getScrollBarButtonLinePaint",
"(",
")",
")",
";",
"g",
".",
"drawLine",
"(",
"0",
",",
"0",
",",
"width",
"-",
"1",
",",
"0",
")",
";",
"if",
"(",
"state",
"!=",
"Which",
".",
"FOREGROUND_CAP",
"&&",
"buttonsTogether",
")",
"{",
"int",
"height",
"=",
"s",
".",
"getBounds",
"(",
")",
".",
"height",
";",
"g",
".",
"setPaint",
"(",
"getScrollBarButtonDividerPaint",
"(",
"isIncrease",
")",
")",
";",
"g",
".",
"drawLine",
"(",
"width",
"-",
"1",
",",
"1",
",",
"width",
"-",
"1",
",",
"height",
"-",
"1",
")",
";",
"}",
"}"
] | DOCUMENT ME!
@param g DOCUMENT ME!
@param s DOCUMENT ME!
@param isIncrease DOCUMENT ME!
@param buttonsTogether DOCUMENT ME! | [
"DOCUMENT",
"ME!"
] | train | https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/painter/ScrollBarButtonPainter.java#L298-L313 |
lightblueseas/vintage-time | src/main/java/de/alpharogroup/date/CalculateDateExtensions.java | CalculateDateExtensions.substractMonthsFromDate | public static Date substractMonthsFromDate(final Date date, final int substractMonths) {
"""
Substract months to the given Date object and returns it.
@param date
The Date object to substract the months.
@param substractMonths
The months to substract.
@return The resulted Date object.
"""
final Calendar dateOnCalendar = Calendar.getInstance();
dateOnCalendar.setTime(date);
dateOnCalendar.add(Calendar.MONTH, substractMonths * -1);
return dateOnCalendar.getTime();
} | java | public static Date substractMonthsFromDate(final Date date, final int substractMonths)
{
final Calendar dateOnCalendar = Calendar.getInstance();
dateOnCalendar.setTime(date);
dateOnCalendar.add(Calendar.MONTH, substractMonths * -1);
return dateOnCalendar.getTime();
} | [
"public",
"static",
"Date",
"substractMonthsFromDate",
"(",
"final",
"Date",
"date",
",",
"final",
"int",
"substractMonths",
")",
"{",
"final",
"Calendar",
"dateOnCalendar",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"dateOnCalendar",
".",
"setTime",
"(",
"date",
")",
";",
"dateOnCalendar",
".",
"add",
"(",
"Calendar",
".",
"MONTH",
",",
"substractMonths",
"*",
"-",
"1",
")",
";",
"return",
"dateOnCalendar",
".",
"getTime",
"(",
")",
";",
"}"
] | Substract months to the given Date object and returns it.
@param date
The Date object to substract the months.
@param substractMonths
The months to substract.
@return The resulted Date object. | [
"Substract",
"months",
"to",
"the",
"given",
"Date",
"object",
"and",
"returns",
"it",
"."
] | train | https://github.com/lightblueseas/vintage-time/blob/fbf201e679d9f9b92e7b5771f3eea1413cc2e113/src/main/java/de/alpharogroup/date/CalculateDateExtensions.java#L405-L411 |
albfernandez/itext2 | src/main/java/com/lowagie/text/Utilities.java | Utilities.convertToUtf32 | public static int convertToUtf32(String text, int idx) {
"""
Converts a unicode character in a String to a UTF32 code point value
@param text a String that has the unicode character(s)
@param idx the index of the 'high' character
@return the codepoint value
@since 2.1.2
"""
return (((text.charAt(idx) - 0xd800) * 0x400) + (text.charAt(idx + 1) - 0xdc00)) + 0x10000;
} | java | public static int convertToUtf32(String text, int idx) {
return (((text.charAt(idx) - 0xd800) * 0x400) + (text.charAt(idx + 1) - 0xdc00)) + 0x10000;
} | [
"public",
"static",
"int",
"convertToUtf32",
"(",
"String",
"text",
",",
"int",
"idx",
")",
"{",
"return",
"(",
"(",
"(",
"text",
".",
"charAt",
"(",
"idx",
")",
"-",
"0xd800",
")",
"*",
"0x400",
")",
"+",
"(",
"text",
".",
"charAt",
"(",
"idx",
"+",
"1",
")",
"-",
"0xdc00",
")",
")",
"+",
"0x10000",
";",
"}"
] | Converts a unicode character in a String to a UTF32 code point value
@param text a String that has the unicode character(s)
@param idx the index of the 'high' character
@return the codepoint value
@since 2.1.2 | [
"Converts",
"a",
"unicode",
"character",
"in",
"a",
"String",
"to",
"a",
"UTF32",
"code",
"point",
"value"
] | train | https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/Utilities.java#L326-L328 |
TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/ENU.java | ENU.enuToEcef | public Coordinate enuToEcef( Coordinate cEnu ) {
"""
Converts an ENU coordinate to Earth-Centered Earth-Fixed (ECEF).
@param cEnu the enu coordinate.
@return the ecef coordinate.
"""
double[][] enu = new double[][]{{cEnu.x}, {cEnu.y}, {cEnu.z}};
RealMatrix enuMatrix = MatrixUtils.createRealMatrix(enu);
RealMatrix deltasMatrix = _inverseRotationMatrix.multiply(enuMatrix);
double[] column = deltasMatrix.getColumn(0);
double cecfX = column[0] + _ecefROriginX;
double cecfY = column[1] + _ecefROriginY;
double cecfZ = column[2] + _ecefROriginZ;
return new Coordinate(cecfX, cecfY, cecfZ);
} | java | public Coordinate enuToEcef( Coordinate cEnu ) {
double[][] enu = new double[][]{{cEnu.x}, {cEnu.y}, {cEnu.z}};
RealMatrix enuMatrix = MatrixUtils.createRealMatrix(enu);
RealMatrix deltasMatrix = _inverseRotationMatrix.multiply(enuMatrix);
double[] column = deltasMatrix.getColumn(0);
double cecfX = column[0] + _ecefROriginX;
double cecfY = column[1] + _ecefROriginY;
double cecfZ = column[2] + _ecefROriginZ;
return new Coordinate(cecfX, cecfY, cecfZ);
} | [
"public",
"Coordinate",
"enuToEcef",
"(",
"Coordinate",
"cEnu",
")",
"{",
"double",
"[",
"]",
"[",
"]",
"enu",
"=",
"new",
"double",
"[",
"]",
"[",
"]",
"{",
"{",
"cEnu",
".",
"x",
"}",
",",
"{",
"cEnu",
".",
"y",
"}",
",",
"{",
"cEnu",
".",
"z",
"}",
"}",
";",
"RealMatrix",
"enuMatrix",
"=",
"MatrixUtils",
".",
"createRealMatrix",
"(",
"enu",
")",
";",
"RealMatrix",
"deltasMatrix",
"=",
"_inverseRotationMatrix",
".",
"multiply",
"(",
"enuMatrix",
")",
";",
"double",
"[",
"]",
"column",
"=",
"deltasMatrix",
".",
"getColumn",
"(",
"0",
")",
";",
"double",
"cecfX",
"=",
"column",
"[",
"0",
"]",
"+",
"_ecefROriginX",
";",
"double",
"cecfY",
"=",
"column",
"[",
"1",
"]",
"+",
"_ecefROriginY",
";",
"double",
"cecfZ",
"=",
"column",
"[",
"2",
"]",
"+",
"_ecefROriginZ",
";",
"return",
"new",
"Coordinate",
"(",
"cecfX",
",",
"cecfY",
",",
"cecfZ",
")",
";",
"}"
] | Converts an ENU coordinate to Earth-Centered Earth-Fixed (ECEF).
@param cEnu the enu coordinate.
@return the ecef coordinate. | [
"Converts",
"an",
"ENU",
"coordinate",
"to",
"Earth",
"-",
"Centered",
"Earth",
"-",
"Fixed",
"(",
"ECEF",
")",
"."
] | train | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/ENU.java#L185-L197 |
thombergs/docx-stamper | src/main/java/org/wickedsource/docxstamper/el/ExpressionResolver.java | ExpressionResolver.resolveExpression | public Object resolveExpression(String expressionString, Object contextRoot) {
"""
Runs the given expression against the given context object and returns the result of the evaluated expression.
@param expressionString the expression to evaluate.
@param contextRoot the context object against which the expression is evaluated.
@return the result of the evaluated expression.
"""
if ((expressionString.startsWith("${") || expressionString.startsWith("#{")) && expressionString.endsWith("}")) {
expressionString = expressionUtil.stripExpression(expressionString);
}
ExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext evaluationContext = new StandardEvaluationContext(contextRoot);
evaluationContextConfigurer.configureEvaluationContext(evaluationContext);
Expression expression = parser.parseExpression(expressionString);
return expression.getValue(evaluationContext);
} | java | public Object resolveExpression(String expressionString, Object contextRoot) {
if ((expressionString.startsWith("${") || expressionString.startsWith("#{")) && expressionString.endsWith("}")) {
expressionString = expressionUtil.stripExpression(expressionString);
}
ExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext evaluationContext = new StandardEvaluationContext(contextRoot);
evaluationContextConfigurer.configureEvaluationContext(evaluationContext);
Expression expression = parser.parseExpression(expressionString);
return expression.getValue(evaluationContext);
} | [
"public",
"Object",
"resolveExpression",
"(",
"String",
"expressionString",
",",
"Object",
"contextRoot",
")",
"{",
"if",
"(",
"(",
"expressionString",
".",
"startsWith",
"(",
"\"${\"",
")",
"||",
"expressionString",
".",
"startsWith",
"(",
"\"#{\"",
")",
")",
"&&",
"expressionString",
".",
"endsWith",
"(",
"\"}\"",
")",
")",
"{",
"expressionString",
"=",
"expressionUtil",
".",
"stripExpression",
"(",
"expressionString",
")",
";",
"}",
"ExpressionParser",
"parser",
"=",
"new",
"SpelExpressionParser",
"(",
")",
";",
"StandardEvaluationContext",
"evaluationContext",
"=",
"new",
"StandardEvaluationContext",
"(",
"contextRoot",
")",
";",
"evaluationContextConfigurer",
".",
"configureEvaluationContext",
"(",
"evaluationContext",
")",
";",
"Expression",
"expression",
"=",
"parser",
".",
"parseExpression",
"(",
"expressionString",
")",
";",
"return",
"expression",
".",
"getValue",
"(",
"evaluationContext",
")",
";",
"}"
] | Runs the given expression against the given context object and returns the result of the evaluated expression.
@param expressionString the expression to evaluate.
@param contextRoot the context object against which the expression is evaluated.
@return the result of the evaluated expression. | [
"Runs",
"the",
"given",
"expression",
"against",
"the",
"given",
"context",
"object",
"and",
"returns",
"the",
"result",
"of",
"the",
"evaluated",
"expression",
"."
] | train | https://github.com/thombergs/docx-stamper/blob/f1a7e3e92a59abaffac299532fe49450c3b041eb/src/main/java/org/wickedsource/docxstamper/el/ExpressionResolver.java#L30-L39 |
maguro/aunit | junit/src/main/java/com/toolazydogs/aunit/Assert.java | Assert.assertTree | public static void assertTree(String message, String rootText, String preorder, Tree tree) {
"""
Asserts a parse tree.
@param message the message to display on failure.
@param rootText the text of the root of the tree.
@param preorder the preorder traversal of the tree.
@param tree an ANTLR tree to assert on.
"""
assertNotNull("tree should be non-null", tree);
assertEquals(message + " (asserting type of root)", rootText, tree.getText());
assertPreordered(message, preorder, tree);
} | java | public static void assertTree(String message, String rootText, String preorder, Tree tree)
{
assertNotNull("tree should be non-null", tree);
assertEquals(message + " (asserting type of root)", rootText, tree.getText());
assertPreordered(message, preorder, tree);
} | [
"public",
"static",
"void",
"assertTree",
"(",
"String",
"message",
",",
"String",
"rootText",
",",
"String",
"preorder",
",",
"Tree",
"tree",
")",
"{",
"assertNotNull",
"(",
"\"tree should be non-null\"",
",",
"tree",
")",
";",
"assertEquals",
"(",
"message",
"+",
"\" (asserting type of root)\"",
",",
"rootText",
",",
"tree",
".",
"getText",
"(",
")",
")",
";",
"assertPreordered",
"(",
"message",
",",
"preorder",
",",
"tree",
")",
";",
"}"
] | Asserts a parse tree.
@param message the message to display on failure.
@param rootText the text of the root of the tree.
@param preorder the preorder traversal of the tree.
@param tree an ANTLR tree to assert on. | [
"Asserts",
"a",
"parse",
"tree",
"."
] | train | https://github.com/maguro/aunit/blob/1f972e35b28327e5e2e7881befc928df0546d74c/junit/src/main/java/com/toolazydogs/aunit/Assert.java#L324-L329 |
foundation-runtime/logging | logging-api/src/main/java/com/cisco/oss/foundation/logging/transactions/TransactionLogger.java | TransactionLogger.addTimePerComponent | private static void addTimePerComponent(HashMap<String, Long> mapComponentTimes, Component component) {
"""
Add component processing time to given map
@param mapComponentTimes
@param component
"""
Long currentTimeOfComponent = 0L;
String key = component.getComponentType();
if (mapComponentTimes.containsKey(key)) {
currentTimeOfComponent = mapComponentTimes.get(key);
}
//when transactions are run in parallel, we should log the longest transaction only to avoid that
//for ex 'Total time' would be 100ms and transactions in parallel to hornetQ will be 2000ms
Long maxTime = Math.max(component.getTime(), currentTimeOfComponent);
mapComponentTimes.put(key, maxTime);
} | java | private static void addTimePerComponent(HashMap<String, Long> mapComponentTimes, Component component) {
Long currentTimeOfComponent = 0L;
String key = component.getComponentType();
if (mapComponentTimes.containsKey(key)) {
currentTimeOfComponent = mapComponentTimes.get(key);
}
//when transactions are run in parallel, we should log the longest transaction only to avoid that
//for ex 'Total time' would be 100ms and transactions in parallel to hornetQ will be 2000ms
Long maxTime = Math.max(component.getTime(), currentTimeOfComponent);
mapComponentTimes.put(key, maxTime);
} | [
"private",
"static",
"void",
"addTimePerComponent",
"(",
"HashMap",
"<",
"String",
",",
"Long",
">",
"mapComponentTimes",
",",
"Component",
"component",
")",
"{",
"Long",
"currentTimeOfComponent",
"=",
"0L",
";",
"String",
"key",
"=",
"component",
".",
"getComponentType",
"(",
")",
";",
"if",
"(",
"mapComponentTimes",
".",
"containsKey",
"(",
"key",
")",
")",
"{",
"currentTimeOfComponent",
"=",
"mapComponentTimes",
".",
"get",
"(",
"key",
")",
";",
"}",
"//when transactions are run in parallel, we should log the longest transaction only to avoid that ",
"//for ex 'Total time' would be 100ms and transactions in parallel to hornetQ will be 2000ms ",
"Long",
"maxTime",
"=",
"Math",
".",
"max",
"(",
"component",
".",
"getTime",
"(",
")",
",",
"currentTimeOfComponent",
")",
";",
"mapComponentTimes",
".",
"put",
"(",
"key",
",",
"maxTime",
")",
";",
"}"
] | Add component processing time to given map
@param mapComponentTimes
@param component | [
"Add",
"component",
"processing",
"time",
"to",
"given",
"map"
] | train | https://github.com/foundation-runtime/logging/blob/cd0a07b3c5b458ecf90ab92a1e0c72a067f5cbd6/logging-api/src/main/java/com/cisco/oss/foundation/logging/transactions/TransactionLogger.java#L446-L456 |
google/closure-compiler | src/com/google/javascript/jscomp/CheckAccessControls.java | CheckAccessControls.checkNameVisibility | private void checkNameVisibility(Scope scope, Node name) {
"""
Reports an error if the given name is not visible in the current context.
@param scope The current scope.
@param name The name node.
"""
if (!name.isName()) {
return;
}
Var var = scope.getVar(name.getString());
if (var == null) {
return;
}
Visibility v = checkPrivateNameConvention(
AccessControlUtils.getEffectiveNameVisibility(
name, var, defaultVisibilityForFiles), name);
switch (v) {
case PACKAGE:
if (!isPackageAccessAllowed(var, name)) {
compiler.report(
JSError.make(
name,
BAD_PACKAGE_PROPERTY_ACCESS,
name.getString(),
var.getSourceFile().getName()));
}
break;
case PRIVATE:
if (!isPrivateAccessAllowed(var, name)) {
compiler.report(
JSError.make(
name,
BAD_PRIVATE_GLOBAL_ACCESS,
name.getString(),
var.getSourceFile().getName()));
}
break;
default:
// Nothing to do for PUBLIC and PROTECTED
// (which is irrelevant for names).
break;
}
} | java | private void checkNameVisibility(Scope scope, Node name) {
if (!name.isName()) {
return;
}
Var var = scope.getVar(name.getString());
if (var == null) {
return;
}
Visibility v = checkPrivateNameConvention(
AccessControlUtils.getEffectiveNameVisibility(
name, var, defaultVisibilityForFiles), name);
switch (v) {
case PACKAGE:
if (!isPackageAccessAllowed(var, name)) {
compiler.report(
JSError.make(
name,
BAD_PACKAGE_PROPERTY_ACCESS,
name.getString(),
var.getSourceFile().getName()));
}
break;
case PRIVATE:
if (!isPrivateAccessAllowed(var, name)) {
compiler.report(
JSError.make(
name,
BAD_PRIVATE_GLOBAL_ACCESS,
name.getString(),
var.getSourceFile().getName()));
}
break;
default:
// Nothing to do for PUBLIC and PROTECTED
// (which is irrelevant for names).
break;
}
} | [
"private",
"void",
"checkNameVisibility",
"(",
"Scope",
"scope",
",",
"Node",
"name",
")",
"{",
"if",
"(",
"!",
"name",
".",
"isName",
"(",
")",
")",
"{",
"return",
";",
"}",
"Var",
"var",
"=",
"scope",
".",
"getVar",
"(",
"name",
".",
"getString",
"(",
")",
")",
";",
"if",
"(",
"var",
"==",
"null",
")",
"{",
"return",
";",
"}",
"Visibility",
"v",
"=",
"checkPrivateNameConvention",
"(",
"AccessControlUtils",
".",
"getEffectiveNameVisibility",
"(",
"name",
",",
"var",
",",
"defaultVisibilityForFiles",
")",
",",
"name",
")",
";",
"switch",
"(",
"v",
")",
"{",
"case",
"PACKAGE",
":",
"if",
"(",
"!",
"isPackageAccessAllowed",
"(",
"var",
",",
"name",
")",
")",
"{",
"compiler",
".",
"report",
"(",
"JSError",
".",
"make",
"(",
"name",
",",
"BAD_PACKAGE_PROPERTY_ACCESS",
",",
"name",
".",
"getString",
"(",
")",
",",
"var",
".",
"getSourceFile",
"(",
")",
".",
"getName",
"(",
")",
")",
")",
";",
"}",
"break",
";",
"case",
"PRIVATE",
":",
"if",
"(",
"!",
"isPrivateAccessAllowed",
"(",
"var",
",",
"name",
")",
")",
"{",
"compiler",
".",
"report",
"(",
"JSError",
".",
"make",
"(",
"name",
",",
"BAD_PRIVATE_GLOBAL_ACCESS",
",",
"name",
".",
"getString",
"(",
")",
",",
"var",
".",
"getSourceFile",
"(",
")",
".",
"getName",
"(",
")",
")",
")",
";",
"}",
"break",
";",
"default",
":",
"// Nothing to do for PUBLIC and PROTECTED",
"// (which is irrelevant for names).",
"break",
";",
"}",
"}"
] | Reports an error if the given name is not visible in the current context.
@param scope The current scope.
@param name The name node. | [
"Reports",
"an",
"error",
"if",
"the",
"given",
"name",
"is",
"not",
"visible",
"in",
"the",
"current",
"context",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckAccessControls.java#L551-L591 |
anotheria/moskito | moskito-aop/src/main/java/net/anotheria/moskito/aop/aspect/AbstractMoskitoAspect.java | AbstractMoskitoAspect.getProducer | protected OnDemandStatsProducer<S> getProducer(final ProceedingJoinPoint pjp, final String aProducerId, final String aCategory, final String aSubsystem, final boolean withMethod,
final IOnDemandStatsFactory<S> factory, final boolean tracingSupported) {
"""
See {@link #getProducer(ProceedingJoinPoint, String, String, String, boolean, IOnDemandStatsFactory, boolean, boolean)} - with attachLoggers -
providen by {@link MoskitoAspectConfiguration#isAttachDefaultStatLoggers()}.
@param pjp
the pjp is used to obtain the producer id automatically if it's not submitted.
@param aProducerId
submitted producer id, used if configured in aop.
@param aCategory
submitted category.
@param aSubsystem
submitted subsystem.
@param withMethod
if true the name of the method will be part of the automatically generated producer id.
@param factory
OnDemandStatsProducer factory
@param tracingSupported
is tracing supported
@return {@link OnDemandStatsProducer}
"""
return getProducer(pjp, aProducerId, aCategory, aSubsystem, withMethod, factory, tracingSupported, config.isAttachDefaultStatLoggers());
} | java | protected OnDemandStatsProducer<S> getProducer(final ProceedingJoinPoint pjp, final String aProducerId, final String aCategory, final String aSubsystem, final boolean withMethod,
final IOnDemandStatsFactory<S> factory, final boolean tracingSupported) {
return getProducer(pjp, aProducerId, aCategory, aSubsystem, withMethod, factory, tracingSupported, config.isAttachDefaultStatLoggers());
} | [
"protected",
"OnDemandStatsProducer",
"<",
"S",
">",
"getProducer",
"(",
"final",
"ProceedingJoinPoint",
"pjp",
",",
"final",
"String",
"aProducerId",
",",
"final",
"String",
"aCategory",
",",
"final",
"String",
"aSubsystem",
",",
"final",
"boolean",
"withMethod",
",",
"final",
"IOnDemandStatsFactory",
"<",
"S",
">",
"factory",
",",
"final",
"boolean",
"tracingSupported",
")",
"{",
"return",
"getProducer",
"(",
"pjp",
",",
"aProducerId",
",",
"aCategory",
",",
"aSubsystem",
",",
"withMethod",
",",
"factory",
",",
"tracingSupported",
",",
"config",
".",
"isAttachDefaultStatLoggers",
"(",
")",
")",
";",
"}"
] | See {@link #getProducer(ProceedingJoinPoint, String, String, String, boolean, IOnDemandStatsFactory, boolean, boolean)} - with attachLoggers -
providen by {@link MoskitoAspectConfiguration#isAttachDefaultStatLoggers()}.
@param pjp
the pjp is used to obtain the producer id automatically if it's not submitted.
@param aProducerId
submitted producer id, used if configured in aop.
@param aCategory
submitted category.
@param aSubsystem
submitted subsystem.
@param withMethod
if true the name of the method will be part of the automatically generated producer id.
@param factory
OnDemandStatsProducer factory
@param tracingSupported
is tracing supported
@return {@link OnDemandStatsProducer} | [
"See",
"{",
"@link",
"#getProducer",
"(",
"ProceedingJoinPoint",
"String",
"String",
"String",
"boolean",
"IOnDemandStatsFactory",
"boolean",
"boolean",
")",
"}",
"-",
"with",
"attachLoggers",
"-",
"providen",
"by",
"{",
"@link",
"MoskitoAspectConfiguration#isAttachDefaultStatLoggers",
"()",
"}",
"."
] | train | https://github.com/anotheria/moskito/blob/0fdb79053b98a6ece610fa159f59bc3331e4cf05/moskito-aop/src/main/java/net/anotheria/moskito/aop/aspect/AbstractMoskitoAspect.java#L77-L80 |
forge/javaee-descriptors | impl/src/main/java/org/jboss/shrinkwrap/descriptor/impl/orm10/OrmDescriptorImpl.java | OrmDescriptorImpl.addNamespace | public OrmDescriptor addNamespace(String name, String value) {
"""
Adds a new namespace
@return the current instance of <code>OrmDescriptor</code>
"""
model.attribute(name, value);
return this;
} | java | public OrmDescriptor addNamespace(String name, String value)
{
model.attribute(name, value);
return this;
} | [
"public",
"OrmDescriptor",
"addNamespace",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"model",
".",
"attribute",
"(",
"name",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Adds a new namespace
@return the current instance of <code>OrmDescriptor</code> | [
"Adds",
"a",
"new",
"namespace"
] | train | https://github.com/forge/javaee-descriptors/blob/cb914330a1a0b04bfc1d0f199bd9cde3bbf0b3ed/impl/src/main/java/org/jboss/shrinkwrap/descriptor/impl/orm10/OrmDescriptorImpl.java#L92-L96 |
stratosphere/stratosphere | stratosphere-compiler/src/main/java/eu/stratosphere/compiler/DataStatistics.java | DataStatistics.cacheBaseStatistics | public void cacheBaseStatistics(BaseStatistics statistics, String identifyer) {
"""
Caches the given statistics. They are later retrievable under the given identifier.
@param statistics The statistics to cache.
@param identifyer The identifier which may be later used to retrieve the statistics.
"""
synchronized (this.baseStatisticsCache) {
this.baseStatisticsCache.put(identifyer, statistics);
}
} | java | public void cacheBaseStatistics(BaseStatistics statistics, String identifyer) {
synchronized (this.baseStatisticsCache) {
this.baseStatisticsCache.put(identifyer, statistics);
}
} | [
"public",
"void",
"cacheBaseStatistics",
"(",
"BaseStatistics",
"statistics",
",",
"String",
"identifyer",
")",
"{",
"synchronized",
"(",
"this",
".",
"baseStatisticsCache",
")",
"{",
"this",
".",
"baseStatisticsCache",
".",
"put",
"(",
"identifyer",
",",
"statistics",
")",
";",
"}",
"}"
] | Caches the given statistics. They are later retrievable under the given identifier.
@param statistics The statistics to cache.
@param identifyer The identifier which may be later used to retrieve the statistics. | [
"Caches",
"the",
"given",
"statistics",
".",
"They",
"are",
"later",
"retrievable",
"under",
"the",
"given",
"identifier",
"."
] | train | https://github.com/stratosphere/stratosphere/blob/c543a08f9676c5b2b0a7088123bd6e795a8ae0c8/stratosphere-compiler/src/main/java/eu/stratosphere/compiler/DataStatistics.java#L59-L63 |
cdk/cdk | app/depict/src/main/java/org/openscience/cdk/depict/DepictionGenerator.java | DepictionGenerator.withHighlight | public DepictionGenerator withHighlight(Iterable<? extends IChemObject> chemObjs, Color color) {
"""
Highlight the provided set of atoms and bonds in the depiction in the
specified color.
Calling this methods appends to the current highlight buffer. The buffer
is cleared after each depiction is generated (e.g. {@link #depict(IAtomContainer)}).
@param chemObjs set of atoms and bonds
@param color the color to highlight
@return new generator for method chaining
@see StandardGenerator#HIGHLIGHT_COLOR
"""
DepictionGenerator copy = new DepictionGenerator(this);
for (IChemObject chemObj : chemObjs)
copy.highlight.put(chemObj, color);
return copy;
} | java | public DepictionGenerator withHighlight(Iterable<? extends IChemObject> chemObjs, Color color) {
DepictionGenerator copy = new DepictionGenerator(this);
for (IChemObject chemObj : chemObjs)
copy.highlight.put(chemObj, color);
return copy;
} | [
"public",
"DepictionGenerator",
"withHighlight",
"(",
"Iterable",
"<",
"?",
"extends",
"IChemObject",
">",
"chemObjs",
",",
"Color",
"color",
")",
"{",
"DepictionGenerator",
"copy",
"=",
"new",
"DepictionGenerator",
"(",
"this",
")",
";",
"for",
"(",
"IChemObject",
"chemObj",
":",
"chemObjs",
")",
"copy",
".",
"highlight",
".",
"put",
"(",
"chemObj",
",",
"color",
")",
";",
"return",
"copy",
";",
"}"
] | Highlight the provided set of atoms and bonds in the depiction in the
specified color.
Calling this methods appends to the current highlight buffer. The buffer
is cleared after each depiction is generated (e.g. {@link #depict(IAtomContainer)}).
@param chemObjs set of atoms and bonds
@param color the color to highlight
@return new generator for method chaining
@see StandardGenerator#HIGHLIGHT_COLOR | [
"Highlight",
"the",
"provided",
"set",
"of",
"atoms",
"and",
"bonds",
"in",
"the",
"depiction",
"in",
"the",
"specified",
"color",
"."
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/app/depict/src/main/java/org/openscience/cdk/depict/DepictionGenerator.java#L978-L983 |
mikepenz/MaterialDrawer | library/src/main/java/com/mikepenz/materialdrawer/DrawerUtils.java | DrawerUtils.addStickyFooterDivider | private static void addStickyFooterDivider(Context ctx, ViewGroup footerView) {
"""
adds the shadow to the stickyFooter
@param ctx
@param footerView
"""
LinearLayout divider = new LinearLayout(ctx);
LinearLayout.LayoutParams dividerParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
divider.setMinimumHeight((int) UIUtils.convertDpToPixel(1, ctx));
divider.setOrientation(LinearLayout.VERTICAL);
divider.setBackgroundColor(UIUtils.getThemeColorFromAttrOrRes(ctx, R.attr.material_drawer_divider, R.color.material_drawer_divider));
footerView.addView(divider, dividerParams);
} | java | private static void addStickyFooterDivider(Context ctx, ViewGroup footerView) {
LinearLayout divider = new LinearLayout(ctx);
LinearLayout.LayoutParams dividerParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
divider.setMinimumHeight((int) UIUtils.convertDpToPixel(1, ctx));
divider.setOrientation(LinearLayout.VERTICAL);
divider.setBackgroundColor(UIUtils.getThemeColorFromAttrOrRes(ctx, R.attr.material_drawer_divider, R.color.material_drawer_divider));
footerView.addView(divider, dividerParams);
} | [
"private",
"static",
"void",
"addStickyFooterDivider",
"(",
"Context",
"ctx",
",",
"ViewGroup",
"footerView",
")",
"{",
"LinearLayout",
"divider",
"=",
"new",
"LinearLayout",
"(",
"ctx",
")",
";",
"LinearLayout",
".",
"LayoutParams",
"dividerParams",
"=",
"new",
"LinearLayout",
".",
"LayoutParams",
"(",
"ViewGroup",
".",
"LayoutParams",
".",
"MATCH_PARENT",
",",
"ViewGroup",
".",
"LayoutParams",
".",
"WRAP_CONTENT",
")",
";",
"divider",
".",
"setMinimumHeight",
"(",
"(",
"int",
")",
"UIUtils",
".",
"convertDpToPixel",
"(",
"1",
",",
"ctx",
")",
")",
";",
"divider",
".",
"setOrientation",
"(",
"LinearLayout",
".",
"VERTICAL",
")",
";",
"divider",
".",
"setBackgroundColor",
"(",
"UIUtils",
".",
"getThemeColorFromAttrOrRes",
"(",
"ctx",
",",
"R",
".",
"attr",
".",
"material_drawer_divider",
",",
"R",
".",
"color",
".",
"material_drawer_divider",
")",
")",
";",
"footerView",
".",
"addView",
"(",
"divider",
",",
"dividerParams",
")",
";",
"}"
] | adds the shadow to the stickyFooter
@param ctx
@param footerView | [
"adds",
"the",
"shadow",
"to",
"the",
"stickyFooter"
] | train | https://github.com/mikepenz/MaterialDrawer/blob/f4fb31635767edead0a01cee7b7588942b89d8d9/library/src/main/java/com/mikepenz/materialdrawer/DrawerUtils.java#L381-L388 |
camunda/camunda-bpm-platform | engine/src/main/java/org/camunda/bpm/engine/impl/javax/el/ListELResolver.java | ListELResolver.isReadOnly | @Override
public boolean isReadOnly(ELContext context, Object base, Object property) {
"""
If the base object is a list, returns whether a call to
{@link #setValue(ELContext, Object, Object, Object)} will always fail. If the base is a List,
the propertyResolved property of the ELContext object must be set to true by this resolver,
before returning. If this property is not true after this method is called, the caller should
ignore the return value. If this resolver was constructed in read-only mode, this method will
always return true. If a List was created using java.util.Collections.unmodifiableList(List),
this method must return true. Unfortunately, there is no Collections API method to detect
this. However, an implementation can create a prototype unmodifiable List and query its
runtime type to see if it matches the runtime type of the base object as a workaround.
@param context
The context of this evaluation.
@param base
The list to analyze. Only bases of type List are handled by this resolver.
@param property
The index of the element in the list to return the acceptable type for. Will be
coerced into an integer, but otherwise ignored by this resolver.
@return If the propertyResolved property of ELContext was set to true, then true if calling
the setValue method will always fail or false if it is possible that such a call may
succeed; otherwise undefined.
@throws PropertyNotFoundException
if the given index is out of bounds for this list.
@throws IllegalArgumentException
if the property could not be coerced into an integer.
@throws NullPointerException
if context is null
@throws ELException
if an exception was thrown while performing the property or variable resolution.
The thrown exception must be included as the cause property of this exception, if
available.
"""
if (context == null) {
throw new NullPointerException("context is null");
}
if (isResolvable(base)) {
toIndex((List<?>) base, property);
context.setPropertyResolved(true);
}
return readOnly;
} | java | @Override
public boolean isReadOnly(ELContext context, Object base, Object property) {
if (context == null) {
throw new NullPointerException("context is null");
}
if (isResolvable(base)) {
toIndex((List<?>) base, property);
context.setPropertyResolved(true);
}
return readOnly;
} | [
"@",
"Override",
"public",
"boolean",
"isReadOnly",
"(",
"ELContext",
"context",
",",
"Object",
"base",
",",
"Object",
"property",
")",
"{",
"if",
"(",
"context",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"context is null\"",
")",
";",
"}",
"if",
"(",
"isResolvable",
"(",
"base",
")",
")",
"{",
"toIndex",
"(",
"(",
"List",
"<",
"?",
">",
")",
"base",
",",
"property",
")",
";",
"context",
".",
"setPropertyResolved",
"(",
"true",
")",
";",
"}",
"return",
"readOnly",
";",
"}"
] | If the base object is a list, returns whether a call to
{@link #setValue(ELContext, Object, Object, Object)} will always fail. If the base is a List,
the propertyResolved property of the ELContext object must be set to true by this resolver,
before returning. If this property is not true after this method is called, the caller should
ignore the return value. If this resolver was constructed in read-only mode, this method will
always return true. If a List was created using java.util.Collections.unmodifiableList(List),
this method must return true. Unfortunately, there is no Collections API method to detect
this. However, an implementation can create a prototype unmodifiable List and query its
runtime type to see if it matches the runtime type of the base object as a workaround.
@param context
The context of this evaluation.
@param base
The list to analyze. Only bases of type List are handled by this resolver.
@param property
The index of the element in the list to return the acceptable type for. Will be
coerced into an integer, but otherwise ignored by this resolver.
@return If the propertyResolved property of ELContext was set to true, then true if calling
the setValue method will always fail or false if it is possible that such a call may
succeed; otherwise undefined.
@throws PropertyNotFoundException
if the given index is out of bounds for this list.
@throws IllegalArgumentException
if the property could not be coerced into an integer.
@throws NullPointerException
if context is null
@throws ELException
if an exception was thrown while performing the property or variable resolution.
The thrown exception must be included as the cause property of this exception, if
available. | [
"If",
"the",
"base",
"object",
"is",
"a",
"list",
"returns",
"whether",
"a",
"call",
"to",
"{",
"@link",
"#setValue",
"(",
"ELContext",
"Object",
"Object",
"Object",
")",
"}",
"will",
"always",
"fail",
".",
"If",
"the",
"base",
"is",
"a",
"List",
"the",
"propertyResolved",
"property",
"of",
"the",
"ELContext",
"object",
"must",
"be",
"set",
"to",
"true",
"by",
"this",
"resolver",
"before",
"returning",
".",
"If",
"this",
"property",
"is",
"not",
"true",
"after",
"this",
"method",
"is",
"called",
"the",
"caller",
"should",
"ignore",
"the",
"return",
"value",
".",
"If",
"this",
"resolver",
"was",
"constructed",
"in",
"read",
"-",
"only",
"mode",
"this",
"method",
"will",
"always",
"return",
"true",
".",
"If",
"a",
"List",
"was",
"created",
"using",
"java",
".",
"util",
".",
"Collections",
".",
"unmodifiableList",
"(",
"List",
")",
"this",
"method",
"must",
"return",
"true",
".",
"Unfortunately",
"there",
"is",
"no",
"Collections",
"API",
"method",
"to",
"detect",
"this",
".",
"However",
"an",
"implementation",
"can",
"create",
"a",
"prototype",
"unmodifiable",
"List",
"and",
"query",
"its",
"runtime",
"type",
"to",
"see",
"if",
"it",
"matches",
"the",
"runtime",
"type",
"of",
"the",
"base",
"object",
"as",
"a",
"workaround",
"."
] | train | https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/javax/el/ListELResolver.java#L199-L209 |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java | MapComposedElement.addPoint | public int addPoint(double x, double y, int groupIndex) {
"""
Add the specified point at the end of the specified group.
@param x x coordinate
@param y y coordinate
@param groupIndex the index of the group.
@return the index of the point in the element.
@throws IndexOutOfBoundsException in case of error.
"""
final int groupCount = getGroupCount();
if (groupIndex < 0) {
throw new IndexOutOfBoundsException(groupIndex + "<0"); //$NON-NLS-1$
}
if (groupIndex >= groupCount) {
throw new IndexOutOfBoundsException(groupIndex + ">=" + groupCount); //$NON-NLS-1$
}
int pointIndex;
if (this.pointCoordinates == null) {
this.pointCoordinates = new double[] {x, y};
this.partIndexes = null;
pointIndex = 0;
} else {
pointIndex = lastInGroup(groupIndex);
double[] pts = new double[this.pointCoordinates.length + 2];
pointIndex += 2;
System.arraycopy(this.pointCoordinates, 0, pts, 0, pointIndex);
System.arraycopy(this.pointCoordinates, pointIndex, pts, pointIndex + 2, this.pointCoordinates.length - pointIndex);
pts[pointIndex] = x;
pts[pointIndex + 1] = y;
this.pointCoordinates = pts;
pts = null;
//Shift the following groups's indexes
if (this.partIndexes != null) {
for (int idx = groupIndex; idx < this.partIndexes.length; ++idx) {
this.partIndexes[idx] += 2;
}
}
pointIndex /= 2.;
}
fireShapeChanged();
fireElementChanged();
return pointIndex;
} | java | public int addPoint(double x, double y, int groupIndex) {
final int groupCount = getGroupCount();
if (groupIndex < 0) {
throw new IndexOutOfBoundsException(groupIndex + "<0"); //$NON-NLS-1$
}
if (groupIndex >= groupCount) {
throw new IndexOutOfBoundsException(groupIndex + ">=" + groupCount); //$NON-NLS-1$
}
int pointIndex;
if (this.pointCoordinates == null) {
this.pointCoordinates = new double[] {x, y};
this.partIndexes = null;
pointIndex = 0;
} else {
pointIndex = lastInGroup(groupIndex);
double[] pts = new double[this.pointCoordinates.length + 2];
pointIndex += 2;
System.arraycopy(this.pointCoordinates, 0, pts, 0, pointIndex);
System.arraycopy(this.pointCoordinates, pointIndex, pts, pointIndex + 2, this.pointCoordinates.length - pointIndex);
pts[pointIndex] = x;
pts[pointIndex + 1] = y;
this.pointCoordinates = pts;
pts = null;
//Shift the following groups's indexes
if (this.partIndexes != null) {
for (int idx = groupIndex; idx < this.partIndexes.length; ++idx) {
this.partIndexes[idx] += 2;
}
}
pointIndex /= 2.;
}
fireShapeChanged();
fireElementChanged();
return pointIndex;
} | [
"public",
"int",
"addPoint",
"(",
"double",
"x",
",",
"double",
"y",
",",
"int",
"groupIndex",
")",
"{",
"final",
"int",
"groupCount",
"=",
"getGroupCount",
"(",
")",
";",
"if",
"(",
"groupIndex",
"<",
"0",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"groupIndex",
"+",
"\"<0\"",
")",
";",
"//$NON-NLS-1$",
"}",
"if",
"(",
"groupIndex",
">=",
"groupCount",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"groupIndex",
"+",
"\">=\"",
"+",
"groupCount",
")",
";",
"//$NON-NLS-1$",
"}",
"int",
"pointIndex",
";",
"if",
"(",
"this",
".",
"pointCoordinates",
"==",
"null",
")",
"{",
"this",
".",
"pointCoordinates",
"=",
"new",
"double",
"[",
"]",
"{",
"x",
",",
"y",
"}",
";",
"this",
".",
"partIndexes",
"=",
"null",
";",
"pointIndex",
"=",
"0",
";",
"}",
"else",
"{",
"pointIndex",
"=",
"lastInGroup",
"(",
"groupIndex",
")",
";",
"double",
"[",
"]",
"pts",
"=",
"new",
"double",
"[",
"this",
".",
"pointCoordinates",
".",
"length",
"+",
"2",
"]",
";",
"pointIndex",
"+=",
"2",
";",
"System",
".",
"arraycopy",
"(",
"this",
".",
"pointCoordinates",
",",
"0",
",",
"pts",
",",
"0",
",",
"pointIndex",
")",
";",
"System",
".",
"arraycopy",
"(",
"this",
".",
"pointCoordinates",
",",
"pointIndex",
",",
"pts",
",",
"pointIndex",
"+",
"2",
",",
"this",
".",
"pointCoordinates",
".",
"length",
"-",
"pointIndex",
")",
";",
"pts",
"[",
"pointIndex",
"]",
"=",
"x",
";",
"pts",
"[",
"pointIndex",
"+",
"1",
"]",
"=",
"y",
";",
"this",
".",
"pointCoordinates",
"=",
"pts",
";",
"pts",
"=",
"null",
";",
"//Shift the following groups's indexes",
"if",
"(",
"this",
".",
"partIndexes",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"idx",
"=",
"groupIndex",
";",
"idx",
"<",
"this",
".",
"partIndexes",
".",
"length",
";",
"++",
"idx",
")",
"{",
"this",
".",
"partIndexes",
"[",
"idx",
"]",
"+=",
"2",
";",
"}",
"}",
"pointIndex",
"/=",
"2.",
";",
"}",
"fireShapeChanged",
"(",
")",
";",
"fireElementChanged",
"(",
")",
";",
"return",
"pointIndex",
";",
"}"
] | Add the specified point at the end of the specified group.
@param x x coordinate
@param y y coordinate
@param groupIndex the index of the group.
@return the index of the point in the element.
@throws IndexOutOfBoundsException in case of error. | [
"Add",
"the",
"specified",
"point",
"at",
"the",
"end",
"of",
"the",
"specified",
"group",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapComposedElement.java#L604-L647 |
elki-project/elki | elki-core/src/main/java/de/lmu/ifi/dbs/elki/result/textwriter/TextWriterWriterInterface.java | TextWriterWriterInterface.writeObject | @SuppressWarnings("unchecked")
public final void writeObject(TextWriterStream out, String label, Object object) throws IOException {
"""
Non-type-checking version.
@param out Output stream
@param label Label to prefix
@param object object to output
@throws IOException on IO errors
"""
write(out, label, (O) object);
} | java | @SuppressWarnings("unchecked")
public final void writeObject(TextWriterStream out, String label, Object object) throws IOException {
write(out, label, (O) object);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"final",
"void",
"writeObject",
"(",
"TextWriterStream",
"out",
",",
"String",
"label",
",",
"Object",
"object",
")",
"throws",
"IOException",
"{",
"write",
"(",
"out",
",",
"label",
",",
"(",
"O",
")",
"object",
")",
";",
"}"
] | Non-type-checking version.
@param out Output stream
@param label Label to prefix
@param object object to output
@throws IOException on IO errors | [
"Non",
"-",
"type",
"-",
"checking",
"version",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core/src/main/java/de/lmu/ifi/dbs/elki/result/textwriter/TextWriterWriterInterface.java#L52-L55 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/ExpressRouteCrossConnectionsInner.java | ExpressRouteCrossConnectionsInner.getByResourceGroupAsync | public Observable<ExpressRouteCrossConnectionInner> getByResourceGroupAsync(String resourceGroupName, String crossConnectionName) {
"""
Gets details about the specified ExpressRouteCrossConnection.
@param resourceGroupName The name of the resource group (peering location of the circuit).
@param crossConnectionName The name of the ExpressRouteCrossConnection (service key of the circuit).
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ExpressRouteCrossConnectionInner object
"""
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, crossConnectionName).map(new Func1<ServiceResponse<ExpressRouteCrossConnectionInner>, ExpressRouteCrossConnectionInner>() {
@Override
public ExpressRouteCrossConnectionInner call(ServiceResponse<ExpressRouteCrossConnectionInner> response) {
return response.body();
}
});
} | java | public Observable<ExpressRouteCrossConnectionInner> getByResourceGroupAsync(String resourceGroupName, String crossConnectionName) {
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, crossConnectionName).map(new Func1<ServiceResponse<ExpressRouteCrossConnectionInner>, ExpressRouteCrossConnectionInner>() {
@Override
public ExpressRouteCrossConnectionInner call(ServiceResponse<ExpressRouteCrossConnectionInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ExpressRouteCrossConnectionInner",
">",
"getByResourceGroupAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"crossConnectionName",
")",
"{",
"return",
"getByResourceGroupWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"crossConnectionName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"ExpressRouteCrossConnectionInner",
">",
",",
"ExpressRouteCrossConnectionInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ExpressRouteCrossConnectionInner",
"call",
"(",
"ServiceResponse",
"<",
"ExpressRouteCrossConnectionInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Gets details about the specified ExpressRouteCrossConnection.
@param resourceGroupName The name of the resource group (peering location of the circuit).
@param crossConnectionName The name of the ExpressRouteCrossConnection (service key of the circuit).
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ExpressRouteCrossConnectionInner object | [
"Gets",
"details",
"about",
"the",
"specified",
"ExpressRouteCrossConnection",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/ExpressRouteCrossConnectionsInner.java#L384-L391 |
UrielCh/ovh-java-sdk | ovh-java-sdk-emailexchange/src/main/java/net/minidev/ovh/api/ApiOvhEmailexchange.java | ApiOvhEmailexchange.organizationName_service_exchangeService_GET | public OvhExchangeService organizationName_service_exchangeService_GET(String organizationName, String exchangeService) throws IOException {
"""
Get this object properties
REST: GET /email/exchange/{organizationName}/service/{exchangeService}
@param organizationName [required] The internal name of your exchange organization
@param exchangeService [required] The internal name of your exchange service
"""
String qPath = "/email/exchange/{organizationName}/service/{exchangeService}";
StringBuilder sb = path(qPath, organizationName, exchangeService);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhExchangeService.class);
} | java | public OvhExchangeService organizationName_service_exchangeService_GET(String organizationName, String exchangeService) throws IOException {
String qPath = "/email/exchange/{organizationName}/service/{exchangeService}";
StringBuilder sb = path(qPath, organizationName, exchangeService);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhExchangeService.class);
} | [
"public",
"OvhExchangeService",
"organizationName_service_exchangeService_GET",
"(",
"String",
"organizationName",
",",
"String",
"exchangeService",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/email/exchange/{organizationName}/service/{exchangeService}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"organizationName",
",",
"exchangeService",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhExchangeService",
".",
"class",
")",
";",
"}"
] | Get this object properties
REST: GET /email/exchange/{organizationName}/service/{exchangeService}
@param organizationName [required] The internal name of your exchange organization
@param exchangeService [required] The internal name of your exchange service | [
"Get",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-emailexchange/src/main/java/net/minidev/ovh/api/ApiOvhEmailexchange.java#L96-L101 |
javagl/ND | nd-arrays/src/main/java/de/javagl/nd/arrays/Utils.java | Utils.checkForEqualSizes | public static void checkForEqualSizes(ArrayND a0, ArrayND a1) {
"""
Checks whether given given {@link ArrayND}s have equal sizes,
and throws an <code>IllegalArgumentException</code> if not.
@param a0 The first array
@param a1 The second array
@throws NullPointerException If any argument is <code>null</code>
@throws IllegalArgumentException If the given arrays
do not have equal sizes
"""
if (!a0.getSize().equals(a1.getSize()))
{
throw new IllegalArgumentException(
"Arrays have different sizes: "+a0.getSize() +
" and "+a1.getSize());
}
} | java | public static void checkForEqualSizes(ArrayND a0, ArrayND a1)
{
if (!a0.getSize().equals(a1.getSize()))
{
throw new IllegalArgumentException(
"Arrays have different sizes: "+a0.getSize() +
" and "+a1.getSize());
}
} | [
"public",
"static",
"void",
"checkForEqualSizes",
"(",
"ArrayND",
"a0",
",",
"ArrayND",
"a1",
")",
"{",
"if",
"(",
"!",
"a0",
".",
"getSize",
"(",
")",
".",
"equals",
"(",
"a1",
".",
"getSize",
"(",
")",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Arrays have different sizes: \"",
"+",
"a0",
".",
"getSize",
"(",
")",
"+",
"\" and \"",
"+",
"a1",
".",
"getSize",
"(",
")",
")",
";",
"}",
"}"
] | Checks whether given given {@link ArrayND}s have equal sizes,
and throws an <code>IllegalArgumentException</code> if not.
@param a0 The first array
@param a1 The second array
@throws NullPointerException If any argument is <code>null</code>
@throws IllegalArgumentException If the given arrays
do not have equal sizes | [
"Checks",
"whether",
"given",
"given",
"{",
"@link",
"ArrayND",
"}",
"s",
"have",
"equal",
"sizes",
"and",
"throws",
"an",
"<code",
">",
"IllegalArgumentException<",
"/",
"code",
">",
"if",
"not",
"."
] | train | https://github.com/javagl/ND/blob/bcb655aaf5fc88af6194f73a27cca079186ff559/nd-arrays/src/main/java/de/javagl/nd/arrays/Utils.java#L69-L77 |
wisdom-framework/wisdom | core/wisdom-maven-plugin/src/main/java/org/wisdom/maven/osgi/BundlePackager.java | BundlePackager.readMavenProperties | public static Properties readMavenProperties(File baseDir) throws IOException {
"""
We should have generated a {@code target/osgi/osgi.properties} file with the metadata we inherit from Maven.
@param baseDir the project directory
@return the computed set of properties
"""
return Instructions.load(new File(baseDir, org.wisdom.maven.Constants.OSGI_PROPERTIES));
} | java | public static Properties readMavenProperties(File baseDir) throws IOException {
return Instructions.load(new File(baseDir, org.wisdom.maven.Constants.OSGI_PROPERTIES));
} | [
"public",
"static",
"Properties",
"readMavenProperties",
"(",
"File",
"baseDir",
")",
"throws",
"IOException",
"{",
"return",
"Instructions",
".",
"load",
"(",
"new",
"File",
"(",
"baseDir",
",",
"org",
".",
"wisdom",
".",
"maven",
".",
"Constants",
".",
"OSGI_PROPERTIES",
")",
")",
";",
"}"
] | We should have generated a {@code target/osgi/osgi.properties} file with the metadata we inherit from Maven.
@param baseDir the project directory
@return the computed set of properties | [
"We",
"should",
"have",
"generated",
"a",
"{",
"@code",
"target",
"/",
"osgi",
"/",
"osgi",
".",
"properties",
"}",
"file",
"with",
"the",
"metadata",
"we",
"inherit",
"from",
"Maven",
"."
] | train | https://github.com/wisdom-framework/wisdom/blob/a35b6431200fec56b178c0ff60837ed73fd7874d/core/wisdom-maven-plugin/src/main/java/org/wisdom/maven/osgi/BundlePackager.java#L187-L189 |
Subsets and Splits