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
|
---|---|---|---|---|---|---|---|---|---|---|
amzn/ion-java | src/com/amazon/ion/Timestamp.java | Timestamp.addHour | public final Timestamp addHour(int amount) {
"""
Returns a timestamp relative to this one by the given number of hours.
<p>
This method always returns a Timestamp with at least MINUTE precision.
For example, adding one hour to {@code 2011T} results in
{@code 2011-01-01T01:00-00:00}. To receive a Timestamp that always
maintains the same precision as the original, use {@link #adjustHour(int)}.
@param amount a number of hours.
"""
long delta = (long) amount * 60 * 60 * 1000;
return addMillisForPrecision(delta, Precision.MINUTE, false);
} | java | public final Timestamp addHour(int amount)
{
long delta = (long) amount * 60 * 60 * 1000;
return addMillisForPrecision(delta, Precision.MINUTE, false);
} | [
"public",
"final",
"Timestamp",
"addHour",
"(",
"int",
"amount",
")",
"{",
"long",
"delta",
"=",
"(",
"long",
")",
"amount",
"*",
"60",
"*",
"60",
"*",
"1000",
";",
"return",
"addMillisForPrecision",
"(",
"delta",
",",
"Precision",
".",
"MINUTE",
",",
"false",
")",
";",
"}"
] | Returns a timestamp relative to this one by the given number of hours.
<p>
This method always returns a Timestamp with at least MINUTE precision.
For example, adding one hour to {@code 2011T} results in
{@code 2011-01-01T01:00-00:00}. To receive a Timestamp that always
maintains the same precision as the original, use {@link #adjustHour(int)}.
@param amount a number of hours. | [
"Returns",
"a",
"timestamp",
"relative",
"to",
"this",
"one",
"by",
"the",
"given",
"number",
"of",
"hours",
".",
"<p",
">",
"This",
"method",
"always",
"returns",
"a",
"Timestamp",
"with",
"at",
"least",
"MINUTE",
"precision",
".",
"For",
"example",
"adding",
"one",
"hour",
"to",
"{",
"@code",
"2011T",
"}",
"results",
"in",
"{",
"@code",
"2011",
"-",
"01",
"-",
"01T01",
":",
"00",
"-",
"00",
":",
"00",
"}",
".",
"To",
"receive",
"a",
"Timestamp",
"that",
"always",
"maintains",
"the",
"same",
"precision",
"as",
"the",
"original",
"use",
"{",
"@link",
"#adjustHour",
"(",
"int",
")",
"}",
"."
] | train | https://github.com/amzn/ion-java/blob/4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270/src/com/amazon/ion/Timestamp.java#L2415-L2419 |
future-architect/uroborosql | src/main/java/jp/co/future/uroborosql/utils/BeanAccessor.java | BeanAccessor.walkFields | private static void walkFields(final Class<?> cls, final Map<String, Field> fieldMap) {
"""
指定したクラスの持つ全てのフィールドを再帰的に探索して取得する
@param cls 型
@param fieldMap {@literal Map<String, Field>j}
"""
if (cls.equals(Object.class)) {
return;
}
Class<?> superClass = cls.getSuperclass();
walkFields(superClass, fieldMap);
Arrays.stream(cls.getDeclaredFields())
.filter(f -> !Modifier.isStatic(f.getModifiers()))
.forEach(f -> fieldMap.put(f.getName(), f));
} | java | private static void walkFields(final Class<?> cls, final Map<String, Field> fieldMap) {
if (cls.equals(Object.class)) {
return;
}
Class<?> superClass = cls.getSuperclass();
walkFields(superClass, fieldMap);
Arrays.stream(cls.getDeclaredFields())
.filter(f -> !Modifier.isStatic(f.getModifiers()))
.forEach(f -> fieldMap.put(f.getName(), f));
} | [
"private",
"static",
"void",
"walkFields",
"(",
"final",
"Class",
"<",
"?",
">",
"cls",
",",
"final",
"Map",
"<",
"String",
",",
"Field",
">",
"fieldMap",
")",
"{",
"if",
"(",
"cls",
".",
"equals",
"(",
"Object",
".",
"class",
")",
")",
"{",
"return",
";",
"}",
"Class",
"<",
"?",
">",
"superClass",
"=",
"cls",
".",
"getSuperclass",
"(",
")",
";",
"walkFields",
"(",
"superClass",
",",
"fieldMap",
")",
";",
"Arrays",
".",
"stream",
"(",
"cls",
".",
"getDeclaredFields",
"(",
")",
")",
".",
"filter",
"(",
"f",
"->",
"!",
"Modifier",
".",
"isStatic",
"(",
"f",
".",
"getModifiers",
"(",
")",
")",
")",
".",
"forEach",
"(",
"f",
"->",
"fieldMap",
".",
"put",
"(",
"f",
".",
"getName",
"(",
")",
",",
"f",
")",
")",
";",
"}"
] | 指定したクラスの持つ全てのフィールドを再帰的に探索して取得する
@param cls 型
@param fieldMap {@literal Map<String, Field>j} | [
"指定したクラスの持つ全てのフィールドを再帰的に探索して取得する"
] | train | https://github.com/future-architect/uroborosql/blob/4c26db51defdac3c6ed16866e33ab45e190e2e0c/src/main/java/jp/co/future/uroborosql/utils/BeanAccessor.java#L103-L112 |
RestComm/jss7 | m3ua/impl/src/main/java/org/restcomm/protocols/ss7/m3ua/impl/M3UARouteManagement.java | M3UARouteManagement.removeRoute | protected void removeRoute(int dpc, int opc, int si, String asName) throws Exception {
"""
Removes the {@link AsImpl} from key (combination of DPC:OPC:Si)
@param dpc
@param opc
@param si
@param asName
@throws Exception If no As found, or this As is not serving this key
"""
AsImpl asImpl = null;
for (FastList.Node<As> n = this.m3uaManagement.appServers.head(), end = this.m3uaManagement.appServers.tail(); (n = n
.getNext()) != end;) {
if (n.getValue().getName().compareTo(asName) == 0) {
asImpl = (AsImpl) n.getValue();
break;
}
}
if (asImpl == null) {
throw new Exception(String.format(M3UAOAMMessages.NO_AS_FOUND, asName));
}
String key = (new StringBuffer().append(dpc).append(KEY_SEPARATOR).append(opc).append(KEY_SEPARATOR).append(si))
.toString();
RouteAsImpl asArray = route.get(key);
if (asArray == null) {
throw new Exception(String.format("No AS=%s configured for dpc=%d opc=%d si=%d", asImpl.getName(), dpc, opc, si));
}
asArray.removeRoute(dpc, opc, si, asImpl);
this.removeAsFromDPC(dpc, asImpl);
//Final check to remove RouteAs
if(!asArray.hasAs()){
route.remove(key);
}
this.m3uaManagement.store();
} | java | protected void removeRoute(int dpc, int opc, int si, String asName) throws Exception {
AsImpl asImpl = null;
for (FastList.Node<As> n = this.m3uaManagement.appServers.head(), end = this.m3uaManagement.appServers.tail(); (n = n
.getNext()) != end;) {
if (n.getValue().getName().compareTo(asName) == 0) {
asImpl = (AsImpl) n.getValue();
break;
}
}
if (asImpl == null) {
throw new Exception(String.format(M3UAOAMMessages.NO_AS_FOUND, asName));
}
String key = (new StringBuffer().append(dpc).append(KEY_SEPARATOR).append(opc).append(KEY_SEPARATOR).append(si))
.toString();
RouteAsImpl asArray = route.get(key);
if (asArray == null) {
throw new Exception(String.format("No AS=%s configured for dpc=%d opc=%d si=%d", asImpl.getName(), dpc, opc, si));
}
asArray.removeRoute(dpc, opc, si, asImpl);
this.removeAsFromDPC(dpc, asImpl);
//Final check to remove RouteAs
if(!asArray.hasAs()){
route.remove(key);
}
this.m3uaManagement.store();
} | [
"protected",
"void",
"removeRoute",
"(",
"int",
"dpc",
",",
"int",
"opc",
",",
"int",
"si",
",",
"String",
"asName",
")",
"throws",
"Exception",
"{",
"AsImpl",
"asImpl",
"=",
"null",
";",
"for",
"(",
"FastList",
".",
"Node",
"<",
"As",
">",
"n",
"=",
"this",
".",
"m3uaManagement",
".",
"appServers",
".",
"head",
"(",
")",
",",
"end",
"=",
"this",
".",
"m3uaManagement",
".",
"appServers",
".",
"tail",
"(",
")",
";",
"(",
"n",
"=",
"n",
".",
"getNext",
"(",
")",
")",
"!=",
"end",
";",
")",
"{",
"if",
"(",
"n",
".",
"getValue",
"(",
")",
".",
"getName",
"(",
")",
".",
"compareTo",
"(",
"asName",
")",
"==",
"0",
")",
"{",
"asImpl",
"=",
"(",
"AsImpl",
")",
"n",
".",
"getValue",
"(",
")",
";",
"break",
";",
"}",
"}",
"if",
"(",
"asImpl",
"==",
"null",
")",
"{",
"throw",
"new",
"Exception",
"(",
"String",
".",
"format",
"(",
"M3UAOAMMessages",
".",
"NO_AS_FOUND",
",",
"asName",
")",
")",
";",
"}",
"String",
"key",
"=",
"(",
"new",
"StringBuffer",
"(",
")",
".",
"append",
"(",
"dpc",
")",
".",
"append",
"(",
"KEY_SEPARATOR",
")",
".",
"append",
"(",
"opc",
")",
".",
"append",
"(",
"KEY_SEPARATOR",
")",
".",
"append",
"(",
"si",
")",
")",
".",
"toString",
"(",
")",
";",
"RouteAsImpl",
"asArray",
"=",
"route",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"asArray",
"==",
"null",
")",
"{",
"throw",
"new",
"Exception",
"(",
"String",
".",
"format",
"(",
"\"No AS=%s configured for dpc=%d opc=%d si=%d\"",
",",
"asImpl",
".",
"getName",
"(",
")",
",",
"dpc",
",",
"opc",
",",
"si",
")",
")",
";",
"}",
"asArray",
".",
"removeRoute",
"(",
"dpc",
",",
"opc",
",",
"si",
",",
"asImpl",
")",
";",
"this",
".",
"removeAsFromDPC",
"(",
"dpc",
",",
"asImpl",
")",
";",
"//Final check to remove RouteAs",
"if",
"(",
"!",
"asArray",
".",
"hasAs",
"(",
")",
")",
"{",
"route",
".",
"remove",
"(",
"key",
")",
";",
"}",
"this",
".",
"m3uaManagement",
".",
"store",
"(",
")",
";",
"}"
] | Removes the {@link AsImpl} from key (combination of DPC:OPC:Si)
@param dpc
@param opc
@param si
@param asName
@throws Exception If no As found, or this As is not serving this key | [
"Removes",
"the",
"{",
"@link",
"AsImpl",
"}",
"from",
"key",
"(",
"combination",
"of",
"DPC",
":",
"OPC",
":",
"Si",
")"
] | train | https://github.com/RestComm/jss7/blob/402b4b3984e581c581e309cb5f6a858fde6dbc33/m3ua/impl/src/main/java/org/restcomm/protocols/ss7/m3ua/impl/M3UARouteManagement.java#L233-L265 |
rhiot/rhiot | gateway/components/camel-gpsd/src/main/java/io/rhiot/component/gpsd/GpsdHelper.java | GpsdHelper.consumeTPVObject | public static void consumeTPVObject(TPVObject tpv, Processor processor, GpsdEndpoint endpoint, ExceptionHandler exceptionHandler) {
"""
Process the TPVObject, all params required.
@param tpv The time-position-velocity object to process
@param processor Processor that handles the exchange.
@param endpoint GpsdEndpoint receiving the exchange.
"""
// Simplify logging when https://github.com/taimos/GPSd4Java/pull/19 is merged into upstream.
LOG.debug("About to consume TPV object {},{} from {}", tpv.getLatitude(), tpv.getLongitude(), endpoint);
Validate.notNull(tpv);
Validate.notNull(processor);
Validate.notNull(endpoint);
GpsCoordinates coordinates = gpsCoordinates(new Date(new Double(tpv.getTimestamp()).longValue()), tpv.getLatitude(), tpv.getLongitude());
Exchange exchange = anExchange(endpoint.getCamelContext()).withPattern(OutOnly).
withHeader(TPV_HEADER, tpv).withBody(coordinates).build();
try {
processor.process(exchange);
} catch (Exception e) {
exceptionHandler.handleException(e);
}
} | java | public static void consumeTPVObject(TPVObject tpv, Processor processor, GpsdEndpoint endpoint, ExceptionHandler exceptionHandler) {
// Simplify logging when https://github.com/taimos/GPSd4Java/pull/19 is merged into upstream.
LOG.debug("About to consume TPV object {},{} from {}", tpv.getLatitude(), tpv.getLongitude(), endpoint);
Validate.notNull(tpv);
Validate.notNull(processor);
Validate.notNull(endpoint);
GpsCoordinates coordinates = gpsCoordinates(new Date(new Double(tpv.getTimestamp()).longValue()), tpv.getLatitude(), tpv.getLongitude());
Exchange exchange = anExchange(endpoint.getCamelContext()).withPattern(OutOnly).
withHeader(TPV_HEADER, tpv).withBody(coordinates).build();
try {
processor.process(exchange);
} catch (Exception e) {
exceptionHandler.handleException(e);
}
} | [
"public",
"static",
"void",
"consumeTPVObject",
"(",
"TPVObject",
"tpv",
",",
"Processor",
"processor",
",",
"GpsdEndpoint",
"endpoint",
",",
"ExceptionHandler",
"exceptionHandler",
")",
"{",
"// Simplify logging when https://github.com/taimos/GPSd4Java/pull/19 is merged into upstream.",
"LOG",
".",
"debug",
"(",
"\"About to consume TPV object {},{} from {}\"",
",",
"tpv",
".",
"getLatitude",
"(",
")",
",",
"tpv",
".",
"getLongitude",
"(",
")",
",",
"endpoint",
")",
";",
"Validate",
".",
"notNull",
"(",
"tpv",
")",
";",
"Validate",
".",
"notNull",
"(",
"processor",
")",
";",
"Validate",
".",
"notNull",
"(",
"endpoint",
")",
";",
"GpsCoordinates",
"coordinates",
"=",
"gpsCoordinates",
"(",
"new",
"Date",
"(",
"new",
"Double",
"(",
"tpv",
".",
"getTimestamp",
"(",
")",
")",
".",
"longValue",
"(",
")",
")",
",",
"tpv",
".",
"getLatitude",
"(",
")",
",",
"tpv",
".",
"getLongitude",
"(",
")",
")",
";",
"Exchange",
"exchange",
"=",
"anExchange",
"(",
"endpoint",
".",
"getCamelContext",
"(",
")",
")",
".",
"withPattern",
"(",
"OutOnly",
")",
".",
"withHeader",
"(",
"TPV_HEADER",
",",
"tpv",
")",
".",
"withBody",
"(",
"coordinates",
")",
".",
"build",
"(",
")",
";",
"try",
"{",
"processor",
".",
"process",
"(",
"exchange",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"exceptionHandler",
".",
"handleException",
"(",
"e",
")",
";",
"}",
"}"
] | Process the TPVObject, all params required.
@param tpv The time-position-velocity object to process
@param processor Processor that handles the exchange.
@param endpoint GpsdEndpoint receiving the exchange. | [
"Process",
"the",
"TPVObject",
"all",
"params",
"required",
"."
] | train | https://github.com/rhiot/rhiot/blob/82eac10e365f72bab9248b8c3bd0ec9a2fc0a721/gateway/components/camel-gpsd/src/main/java/io/rhiot/component/gpsd/GpsdHelper.java#L49-L66 |
fcrepo4/fcrepo4 | fcrepo-http-api/src/main/java/org/fcrepo/http/api/ContentExposingResource.java | ContentExposingResource.ensureValidACLAuthorization | private void ensureValidACLAuthorization(final FedoraResource resource, final Model inputModel) {
"""
This method does two things:
- Throws an exception if an authorization has both accessTo and accessToClass
- Adds a default accessTo target if an authorization has neither accessTo nor accessToClass
@param resource the fedora resource
@param inputModel to be checked and updated
"""
if (resource.isAcl()) {
final Set<Node> uniqueAuthSubjects = new HashSet<>();
inputModel.listStatements().forEachRemaining((final Statement s) -> {
LOGGER.debug("statement: s={}, p={}, o={}", s.getSubject(), s.getPredicate(), s.getObject());
final Node subject = s.getSubject().asNode();
// If subject is Authorization Hash Resource, add it to the map with its accessTo/accessToClass status.
if (subject.toString().contains("/" + FCR_ACL + "#")) {
uniqueAuthSubjects.add(subject);
}
});
final Graph graph = inputModel.getGraph();
uniqueAuthSubjects.forEach((final Node subject) -> {
if (graph.contains(subject, WEBAC_ACCESS_TO_URI, Node.ANY) &&
graph.contains(subject, WEBAC_ACCESS_TO_CLASS_URI, Node.ANY)) {
throw new ACLAuthorizationConstraintViolationException(
MessageFormat.format(
"Using both accessTo and accessToClass within " +
"a single Authorization is not allowed: {0}.",
subject.toString().substring(subject.toString().lastIndexOf("#"))));
} else if (!(graph.contains(subject, WEBAC_ACCESS_TO_URI, Node.ANY) ||
graph.contains(subject, WEBAC_ACCESS_TO_CLASS_URI, Node.ANY))) {
inputModel.add(createDefaultAccessToStatement(subject.toString()));
}
});
}
} | java | private void ensureValidACLAuthorization(final FedoraResource resource, final Model inputModel) {
if (resource.isAcl()) {
final Set<Node> uniqueAuthSubjects = new HashSet<>();
inputModel.listStatements().forEachRemaining((final Statement s) -> {
LOGGER.debug("statement: s={}, p={}, o={}", s.getSubject(), s.getPredicate(), s.getObject());
final Node subject = s.getSubject().asNode();
// If subject is Authorization Hash Resource, add it to the map with its accessTo/accessToClass status.
if (subject.toString().contains("/" + FCR_ACL + "#")) {
uniqueAuthSubjects.add(subject);
}
});
final Graph graph = inputModel.getGraph();
uniqueAuthSubjects.forEach((final Node subject) -> {
if (graph.contains(subject, WEBAC_ACCESS_TO_URI, Node.ANY) &&
graph.contains(subject, WEBAC_ACCESS_TO_CLASS_URI, Node.ANY)) {
throw new ACLAuthorizationConstraintViolationException(
MessageFormat.format(
"Using both accessTo and accessToClass within " +
"a single Authorization is not allowed: {0}.",
subject.toString().substring(subject.toString().lastIndexOf("#"))));
} else if (!(graph.contains(subject, WEBAC_ACCESS_TO_URI, Node.ANY) ||
graph.contains(subject, WEBAC_ACCESS_TO_CLASS_URI, Node.ANY))) {
inputModel.add(createDefaultAccessToStatement(subject.toString()));
}
});
}
} | [
"private",
"void",
"ensureValidACLAuthorization",
"(",
"final",
"FedoraResource",
"resource",
",",
"final",
"Model",
"inputModel",
")",
"{",
"if",
"(",
"resource",
".",
"isAcl",
"(",
")",
")",
"{",
"final",
"Set",
"<",
"Node",
">",
"uniqueAuthSubjects",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"inputModel",
".",
"listStatements",
"(",
")",
".",
"forEachRemaining",
"(",
"(",
"final",
"Statement",
"s",
")",
"->",
"{",
"LOGGER",
".",
"debug",
"(",
"\"statement: s={}, p={}, o={}\"",
",",
"s",
".",
"getSubject",
"(",
")",
",",
"s",
".",
"getPredicate",
"(",
")",
",",
"s",
".",
"getObject",
"(",
")",
")",
";",
"final",
"Node",
"subject",
"=",
"s",
".",
"getSubject",
"(",
")",
".",
"asNode",
"(",
")",
";",
"// If subject is Authorization Hash Resource, add it to the map with its accessTo/accessToClass status.",
"if",
"(",
"subject",
".",
"toString",
"(",
")",
".",
"contains",
"(",
"\"/\"",
"+",
"FCR_ACL",
"+",
"\"#\"",
")",
")",
"{",
"uniqueAuthSubjects",
".",
"add",
"(",
"subject",
")",
";",
"}",
"}",
")",
";",
"final",
"Graph",
"graph",
"=",
"inputModel",
".",
"getGraph",
"(",
")",
";",
"uniqueAuthSubjects",
".",
"forEach",
"(",
"(",
"final",
"Node",
"subject",
")",
"->",
"{",
"if",
"(",
"graph",
".",
"contains",
"(",
"subject",
",",
"WEBAC_ACCESS_TO_URI",
",",
"Node",
".",
"ANY",
")",
"&&",
"graph",
".",
"contains",
"(",
"subject",
",",
"WEBAC_ACCESS_TO_CLASS_URI",
",",
"Node",
".",
"ANY",
")",
")",
"{",
"throw",
"new",
"ACLAuthorizationConstraintViolationException",
"(",
"MessageFormat",
".",
"format",
"(",
"\"Using both accessTo and accessToClass within \"",
"+",
"\"a single Authorization is not allowed: {0}.\"",
",",
"subject",
".",
"toString",
"(",
")",
".",
"substring",
"(",
"subject",
".",
"toString",
"(",
")",
".",
"lastIndexOf",
"(",
"\"#\"",
")",
")",
")",
")",
";",
"}",
"else",
"if",
"(",
"!",
"(",
"graph",
".",
"contains",
"(",
"subject",
",",
"WEBAC_ACCESS_TO_URI",
",",
"Node",
".",
"ANY",
")",
"||",
"graph",
".",
"contains",
"(",
"subject",
",",
"WEBAC_ACCESS_TO_CLASS_URI",
",",
"Node",
".",
"ANY",
")",
")",
")",
"{",
"inputModel",
".",
"add",
"(",
"createDefaultAccessToStatement",
"(",
"subject",
".",
"toString",
"(",
")",
")",
")",
";",
"}",
"}",
")",
";",
"}",
"}"
] | This method does two things:
- Throws an exception if an authorization has both accessTo and accessToClass
- Adds a default accessTo target if an authorization has neither accessTo nor accessToClass
@param resource the fedora resource
@param inputModel to be checked and updated | [
"This",
"method",
"does",
"two",
"things",
":",
"-",
"Throws",
"an",
"exception",
"if",
"an",
"authorization",
"has",
"both",
"accessTo",
"and",
"accessToClass",
"-",
"Adds",
"a",
"default",
"accessTo",
"target",
"if",
"an",
"authorization",
"has",
"neither",
"accessTo",
"nor",
"accessToClass"
] | train | https://github.com/fcrepo4/fcrepo4/blob/7489ad5bc8fb44e2442c93eceb7d97ac54553ab6/fcrepo-http-api/src/main/java/org/fcrepo/http/api/ContentExposingResource.java#L1033-L1059 |
zaproxy/zaproxy | src/org/parosproxy/paros/core/scanner/VariantCustom.java | VariantCustom.addParam | public void addParam(String name, String value, int type) {
"""
Support method to add a new param to this custom variant
@param name the param name
@param value the value of this parameter
@param type the type of this parameter
"""
// Current size usually is equal to the position
params.add(new NameValuePair(type, name, value, params.size()));
} | java | public void addParam(String name, String value, int type) {
// Current size usually is equal to the position
params.add(new NameValuePair(type, name, value, params.size()));
} | [
"public",
"void",
"addParam",
"(",
"String",
"name",
",",
"String",
"value",
",",
"int",
"type",
")",
"{",
"// Current size usually is equal to the position\r",
"params",
".",
"add",
"(",
"new",
"NameValuePair",
"(",
"type",
",",
"name",
",",
"value",
",",
"params",
".",
"size",
"(",
")",
")",
")",
";",
"}"
] | Support method to add a new param to this custom variant
@param name the param name
@param value the value of this parameter
@param type the type of this parameter | [
"Support",
"method",
"to",
"add",
"a",
"new",
"param",
"to",
"this",
"custom",
"variant"
] | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/parosproxy/paros/core/scanner/VariantCustom.java#L142-L145 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/ops/SDMath.java | SDMath.eye | public SDVariable eye(String name, int rows, int cols, DataType dataType, int... batchDimension) {
"""
Generate an identity matrix with the specified number of rows and columns, with optional leading dims<br>
Example:<br>
batchShape: [3,3]<br>
numRows: 2<br>
numCols: 4<br>
returns a tensor of shape (3, 3, 2, 4) that consists of 3 * 3 batches of (2,4)-shaped identity matrices:<br>
1 0 0 0<br>
0 1 0 0<br>
@param rows Number of rows
@param cols Number of columns
@param batchDimension Batch dimensions. May be null
"""
SDVariable eye = new Eye(sd, rows, cols, dataType, batchDimension).outputVariables()[0];
return updateVariableNameAndReference(eye, name);
} | java | public SDVariable eye(String name, int rows, int cols, DataType dataType, int... batchDimension) {
SDVariable eye = new Eye(sd, rows, cols, dataType, batchDimension).outputVariables()[0];
return updateVariableNameAndReference(eye, name);
} | [
"public",
"SDVariable",
"eye",
"(",
"String",
"name",
",",
"int",
"rows",
",",
"int",
"cols",
",",
"DataType",
"dataType",
",",
"int",
"...",
"batchDimension",
")",
"{",
"SDVariable",
"eye",
"=",
"new",
"Eye",
"(",
"sd",
",",
"rows",
",",
"cols",
",",
"dataType",
",",
"batchDimension",
")",
".",
"outputVariables",
"(",
")",
"[",
"0",
"]",
";",
"return",
"updateVariableNameAndReference",
"(",
"eye",
",",
"name",
")",
";",
"}"
] | Generate an identity matrix with the specified number of rows and columns, with optional leading dims<br>
Example:<br>
batchShape: [3,3]<br>
numRows: 2<br>
numCols: 4<br>
returns a tensor of shape (3, 3, 2, 4) that consists of 3 * 3 batches of (2,4)-shaped identity matrices:<br>
1 0 0 0<br>
0 1 0 0<br>
@param rows Number of rows
@param cols Number of columns
@param batchDimension Batch dimensions. May be null | [
"Generate",
"an",
"identity",
"matrix",
"with",
"the",
"specified",
"number",
"of",
"rows",
"and",
"columns",
"with",
"optional",
"leading",
"dims<br",
">",
"Example",
":",
"<br",
">",
"batchShape",
":",
"[",
"3",
"3",
"]",
"<br",
">",
"numRows",
":",
"2<br",
">",
"numCols",
":",
"4<br",
">",
"returns",
"a",
"tensor",
"of",
"shape",
"(",
"3",
"3",
"2",
"4",
")",
"that",
"consists",
"of",
"3",
"*",
"3",
"batches",
"of",
"(",
"2",
"4",
")",
"-",
"shaped",
"identity",
"matrices",
":",
"<br",
">",
"1",
"0",
"0",
"0<br",
">",
"0",
"1",
"0",
"0<br",
">"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/ops/SDMath.java#L1043-L1046 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/TimeZone.java | TimeZone.getCustomTimeZone | private static TimeZone getCustomTimeZone(String id) {
"""
Returns a new SimpleTimeZone for an ID of the form "GMT[+|-]hh[[:]mm]", or null.
"""
Matcher m = NoImagePreloadHolder.CUSTOM_ZONE_ID_PATTERN.matcher(id);
if (!m.matches()) {
return null;
}
int hour;
int minute = 0;
try {
hour = Integer.parseInt(m.group(1));
if (m.group(3) != null) {
minute = Integer.parseInt(m.group(3));
}
} catch (NumberFormatException impossible) {
throw new AssertionError(impossible);
}
if (hour < 0 || hour > 23 || minute < 0 || minute > 59) {
return null;
}
char sign = id.charAt(3);
int raw = (hour * 3600000) + (minute * 60000);
if (sign == '-') {
raw = -raw;
}
String cleanId = String.format(Locale.ROOT, "GMT%c%02d:%02d", sign, hour, minute);
return new SimpleTimeZone(raw, cleanId);
} | java | private static TimeZone getCustomTimeZone(String id) {
Matcher m = NoImagePreloadHolder.CUSTOM_ZONE_ID_PATTERN.matcher(id);
if (!m.matches()) {
return null;
}
int hour;
int minute = 0;
try {
hour = Integer.parseInt(m.group(1));
if (m.group(3) != null) {
minute = Integer.parseInt(m.group(3));
}
} catch (NumberFormatException impossible) {
throw new AssertionError(impossible);
}
if (hour < 0 || hour > 23 || minute < 0 || minute > 59) {
return null;
}
char sign = id.charAt(3);
int raw = (hour * 3600000) + (minute * 60000);
if (sign == '-') {
raw = -raw;
}
String cleanId = String.format(Locale.ROOT, "GMT%c%02d:%02d", sign, hour, minute);
return new SimpleTimeZone(raw, cleanId);
} | [
"private",
"static",
"TimeZone",
"getCustomTimeZone",
"(",
"String",
"id",
")",
"{",
"Matcher",
"m",
"=",
"NoImagePreloadHolder",
".",
"CUSTOM_ZONE_ID_PATTERN",
".",
"matcher",
"(",
"id",
")",
";",
"if",
"(",
"!",
"m",
".",
"matches",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"int",
"hour",
";",
"int",
"minute",
"=",
"0",
";",
"try",
"{",
"hour",
"=",
"Integer",
".",
"parseInt",
"(",
"m",
".",
"group",
"(",
"1",
")",
")",
";",
"if",
"(",
"m",
".",
"group",
"(",
"3",
")",
"!=",
"null",
")",
"{",
"minute",
"=",
"Integer",
".",
"parseInt",
"(",
"m",
".",
"group",
"(",
"3",
")",
")",
";",
"}",
"}",
"catch",
"(",
"NumberFormatException",
"impossible",
")",
"{",
"throw",
"new",
"AssertionError",
"(",
"impossible",
")",
";",
"}",
"if",
"(",
"hour",
"<",
"0",
"||",
"hour",
">",
"23",
"||",
"minute",
"<",
"0",
"||",
"minute",
">",
"59",
")",
"{",
"return",
"null",
";",
"}",
"char",
"sign",
"=",
"id",
".",
"charAt",
"(",
"3",
")",
";",
"int",
"raw",
"=",
"(",
"hour",
"*",
"3600000",
")",
"+",
"(",
"minute",
"*",
"60000",
")",
";",
"if",
"(",
"sign",
"==",
"'",
"'",
")",
"{",
"raw",
"=",
"-",
"raw",
";",
"}",
"String",
"cleanId",
"=",
"String",
".",
"format",
"(",
"Locale",
".",
"ROOT",
",",
"\"GMT%c%02d:%02d\"",
",",
"sign",
",",
"hour",
",",
"minute",
")",
";",
"return",
"new",
"SimpleTimeZone",
"(",
"raw",
",",
"cleanId",
")",
";",
"}"
] | Returns a new SimpleTimeZone for an ID of the form "GMT[+|-]hh[[:]mm]", or null. | [
"Returns",
"a",
"new",
"SimpleTimeZone",
"for",
"an",
"ID",
"of",
"the",
"form",
"GMT",
"[",
"+",
"|",
"-",
"]",
"hh",
"[[",
":",
"]",
"mm",
"]",
"or",
"null",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/TimeZone.java#L578-L608 |
legsem/legstar.avro | legstar.avro.cob2avro/src/main/java/com/legstar/avro/cob2avro/io/ZosVarRdwDatumReader.java | ZosVarRdwDatumReader.getRawRdw | public static int getRawRdw(byte[] hostData, int start, int length) {
"""
RDW is a 4 bytes numeric where the first 2 bytes are the length of the
record (LL) including the 4 byte RDW.
@param hostData the mainframe data
@param start where the RDW starts
@param length the total size of the mainframe data
@return the integer content of the RDW
"""
if (length - start < RDW_LEN) {
throw new IllegalArgumentException("Not enough bytes for an RDW");
}
ByteBuffer buf = ByteBuffer.allocate(RDW_LEN);
buf.put(0, (byte) 0);
buf.put(1, (byte) 0);
buf.put(2, hostData[start + 0]);
buf.put(3, hostData[start + 1]);
return buf.getInt();
} | java | public static int getRawRdw(byte[] hostData, int start, int length) {
if (length - start < RDW_LEN) {
throw new IllegalArgumentException("Not enough bytes for an RDW");
}
ByteBuffer buf = ByteBuffer.allocate(RDW_LEN);
buf.put(0, (byte) 0);
buf.put(1, (byte) 0);
buf.put(2, hostData[start + 0]);
buf.put(3, hostData[start + 1]);
return buf.getInt();
} | [
"public",
"static",
"int",
"getRawRdw",
"(",
"byte",
"[",
"]",
"hostData",
",",
"int",
"start",
",",
"int",
"length",
")",
"{",
"if",
"(",
"length",
"-",
"start",
"<",
"RDW_LEN",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Not enough bytes for an RDW\"",
")",
";",
"}",
"ByteBuffer",
"buf",
"=",
"ByteBuffer",
".",
"allocate",
"(",
"RDW_LEN",
")",
";",
"buf",
".",
"put",
"(",
"0",
",",
"(",
"byte",
")",
"0",
")",
";",
"buf",
".",
"put",
"(",
"1",
",",
"(",
"byte",
")",
"0",
")",
";",
"buf",
".",
"put",
"(",
"2",
",",
"hostData",
"[",
"start",
"+",
"0",
"]",
")",
";",
"buf",
".",
"put",
"(",
"3",
",",
"hostData",
"[",
"start",
"+",
"1",
"]",
")",
";",
"return",
"buf",
".",
"getInt",
"(",
")",
";",
"}"
] | RDW is a 4 bytes numeric where the first 2 bytes are the length of the
record (LL) including the 4 byte RDW.
@param hostData the mainframe data
@param start where the RDW starts
@param length the total size of the mainframe data
@return the integer content of the RDW | [
"RDW",
"is",
"a",
"4",
"bytes",
"numeric",
"where",
"the",
"first",
"2",
"bytes",
"are",
"the",
"length",
"of",
"the",
"record",
"(",
"LL",
")",
"including",
"the",
"4",
"byte",
"RDW",
"."
] | train | https://github.com/legsem/legstar.avro/blob/bad5e0bf41700951eee1ad6a5d6d0c47b3da8f0b/legstar.avro.cob2avro/src/main/java/com/legstar/avro/cob2avro/io/ZosVarRdwDatumReader.java#L116-L127 |
katjahahn/PortEx | src/main/java/com/github/katjahahn/tools/Hasher.java | Hasher.computeHash | public static byte[] computeHash(File file, MessageDigest digest,
long from, long until) throws IOException {
"""
Computes the hash value for the file bytes from offset <code>from</code>
until offset <code>until</code>, using the hash instance as defined by
the hash type.
@param file
the file to compute the hash from
@param digest
the message digest instance
@param from
file offset to start from
@param until
file offset for the end
@return hash value as byte array
@throws IOException
"""
Preconditions.checkArgument(from >= 0, "negative offset");
Preconditions.checkArgument(until > from, "end offset is smaller or equal to start offset");
Preconditions.checkArgument(until <= file.length(), "end offset is greater than file length");
try (RandomAccessFile raf = new RandomAccessFile(file, "r")) {
byte[] buffer = new byte[BUFFER_SIZE];
int readbytes;
long byteSum = from;
raf.seek(from);
while ((readbytes = raf.read(buffer)) != -1 && byteSum <= until) {
byteSum += readbytes;
if (byteSum > until) {
readbytes -= (byteSum - until);
}
digest.update(buffer, 0, readbytes);
}
return digest.digest();
}
} | java | public static byte[] computeHash(File file, MessageDigest digest,
long from, long until) throws IOException {
Preconditions.checkArgument(from >= 0, "negative offset");
Preconditions.checkArgument(until > from, "end offset is smaller or equal to start offset");
Preconditions.checkArgument(until <= file.length(), "end offset is greater than file length");
try (RandomAccessFile raf = new RandomAccessFile(file, "r")) {
byte[] buffer = new byte[BUFFER_SIZE];
int readbytes;
long byteSum = from;
raf.seek(from);
while ((readbytes = raf.read(buffer)) != -1 && byteSum <= until) {
byteSum += readbytes;
if (byteSum > until) {
readbytes -= (byteSum - until);
}
digest.update(buffer, 0, readbytes);
}
return digest.digest();
}
} | [
"public",
"static",
"byte",
"[",
"]",
"computeHash",
"(",
"File",
"file",
",",
"MessageDigest",
"digest",
",",
"long",
"from",
",",
"long",
"until",
")",
"throws",
"IOException",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"from",
">=",
"0",
",",
"\"negative offset\"",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"until",
">",
"from",
",",
"\"end offset is smaller or equal to start offset\"",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"until",
"<=",
"file",
".",
"length",
"(",
")",
",",
"\"end offset is greater than file length\"",
")",
";",
"try",
"(",
"RandomAccessFile",
"raf",
"=",
"new",
"RandomAccessFile",
"(",
"file",
",",
"\"r\"",
")",
")",
"{",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"BUFFER_SIZE",
"]",
";",
"int",
"readbytes",
";",
"long",
"byteSum",
"=",
"from",
";",
"raf",
".",
"seek",
"(",
"from",
")",
";",
"while",
"(",
"(",
"readbytes",
"=",
"raf",
".",
"read",
"(",
"buffer",
")",
")",
"!=",
"-",
"1",
"&&",
"byteSum",
"<=",
"until",
")",
"{",
"byteSum",
"+=",
"readbytes",
";",
"if",
"(",
"byteSum",
">",
"until",
")",
"{",
"readbytes",
"-=",
"(",
"byteSum",
"-",
"until",
")",
";",
"}",
"digest",
".",
"update",
"(",
"buffer",
",",
"0",
",",
"readbytes",
")",
";",
"}",
"return",
"digest",
".",
"digest",
"(",
")",
";",
"}",
"}"
] | Computes the hash value for the file bytes from offset <code>from</code>
until offset <code>until</code>, using the hash instance as defined by
the hash type.
@param file
the file to compute the hash from
@param digest
the message digest instance
@param from
file offset to start from
@param until
file offset for the end
@return hash value as byte array
@throws IOException | [
"Computes",
"the",
"hash",
"value",
"for",
"the",
"file",
"bytes",
"from",
"offset",
"<code",
">",
"from<",
"/",
"code",
">",
"until",
"offset",
"<code",
">",
"until<",
"/",
"code",
">",
"using",
"the",
"hash",
"instance",
"as",
"defined",
"by",
"the",
"hash",
"type",
"."
] | train | https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/tools/Hasher.java#L147-L166 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/jmf/impl/JSMessageImpl.java | JSMessageImpl.getAssembledContent | public DataSlice getAssembledContent() {
"""
Locking: Requires the lock as it relies on, and may change, vital instance variable(s).
"""
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) JmfTr.entry(this, tc, "getAssembledContent");
DataSlice result = null;
// lock the message - we don't want someone clearing the contents while we're doing this
synchronized (getMessageLockArtefact()) {
// If contents isn't null, the message is assembled so we can return something useful
if (contents != null) {
// We must mark the contents as shared now we're handing them out
sharedContents = true; // d348294.1
result = new DataSlice(contents, messageOffset, length);
}
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) JmfTr.exit(this, tc, "getAssembledContent", result);
return result;
} | java | public DataSlice getAssembledContent() {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) JmfTr.entry(this, tc, "getAssembledContent");
DataSlice result = null;
// lock the message - we don't want someone clearing the contents while we're doing this
synchronized (getMessageLockArtefact()) {
// If contents isn't null, the message is assembled so we can return something useful
if (contents != null) {
// We must mark the contents as shared now we're handing them out
sharedContents = true; // d348294.1
result = new DataSlice(contents, messageOffset, length);
}
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) JmfTr.exit(this, tc, "getAssembledContent", result);
return result;
} | [
"public",
"DataSlice",
"getAssembledContent",
"(",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"JmfTr",
".",
"entry",
"(",
"this",
",",
"tc",
",",
"\"getAssembledContent\"",
")",
";",
"DataSlice",
"result",
"=",
"null",
";",
"// lock the message - we don't want someone clearing the contents while we're doing this",
"synchronized",
"(",
"getMessageLockArtefact",
"(",
")",
")",
"{",
"// If contents isn't null, the message is assembled so we can return something useful",
"if",
"(",
"contents",
"!=",
"null",
")",
"{",
"// We must mark the contents as shared now we're handing them out",
"sharedContents",
"=",
"true",
";",
"// d348294.1",
"result",
"=",
"new",
"DataSlice",
"(",
"contents",
",",
"messageOffset",
",",
"length",
")",
";",
"}",
"}",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"JmfTr",
".",
"exit",
"(",
"this",
",",
"tc",
",",
"\"getAssembledContent\"",
",",
"result",
")",
";",
"return",
"result",
";",
"}"
] | Locking: Requires the lock as it relies on, and may change, vital instance variable(s). | [
"Locking",
":",
"Requires",
"the",
"lock",
"as",
"it",
"relies",
"on",
"and",
"may",
"change",
"vital",
"instance",
"variable",
"(",
"s",
")",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/jmf/impl/JSMessageImpl.java#L1564-L1583 |
vincentk/joptimizer | src/main/java/com/joptimizer/optimizers/LPPrimalDualMethod.java | LPPrimalDualMethod.gradSum | protected DoubleMatrix1D gradSum(double t, DoubleMatrix1D fiX) {
"""
Calculates the second term of the first row of (11.55) "Convex Optimization".
@see "Convex Optimization, 11.55"
"""
DoubleMatrix1D gradSum = F1.make(getDim());
for(int i=0; i<dim; i++){
double d = 0;
d += 1. / (t * fiX.getQuick(i));
d += -1. / (t * fiX.getQuick(getDim() + i));
gradSum.setQuick(i, d);
}
return gradSum;
} | java | protected DoubleMatrix1D gradSum(double t, DoubleMatrix1D fiX) {
DoubleMatrix1D gradSum = F1.make(getDim());
for(int i=0; i<dim; i++){
double d = 0;
d += 1. / (t * fiX.getQuick(i));
d += -1. / (t * fiX.getQuick(getDim() + i));
gradSum.setQuick(i, d);
}
return gradSum;
} | [
"protected",
"DoubleMatrix1D",
"gradSum",
"(",
"double",
"t",
",",
"DoubleMatrix1D",
"fiX",
")",
"{",
"DoubleMatrix1D",
"gradSum",
"=",
"F1",
".",
"make",
"(",
"getDim",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"dim",
";",
"i",
"++",
")",
"{",
"double",
"d",
"=",
"0",
";",
"d",
"+=",
"1.",
"/",
"(",
"t",
"*",
"fiX",
".",
"getQuick",
"(",
"i",
")",
")",
";",
"d",
"+=",
"-",
"1.",
"/",
"(",
"t",
"*",
"fiX",
".",
"getQuick",
"(",
"getDim",
"(",
")",
"+",
"i",
")",
")",
";",
"gradSum",
".",
"setQuick",
"(",
"i",
",",
"d",
")",
";",
"}",
"return",
"gradSum",
";",
"}"
] | Calculates the second term of the first row of (11.55) "Convex Optimization".
@see "Convex Optimization, 11.55" | [
"Calculates",
"the",
"second",
"term",
"of",
"the",
"first",
"row",
"of",
"(",
"11",
".",
"55",
")",
"Convex",
"Optimization",
"."
] | train | https://github.com/vincentk/joptimizer/blob/65064c1bb0b26c7261358021e4c93d06dd43564f/src/main/java/com/joptimizer/optimizers/LPPrimalDualMethod.java#L718-L727 |
mapbox/mapbox-java | services-geojson/src/main/java/com/mapbox/geojson/BoundingBox.java | BoundingBox.fromCoordinates | @Deprecated
public static BoundingBox fromCoordinates(
@FloatRange(from = MIN_LONGITUDE, to = GeoJsonConstants.MAX_LONGITUDE) double west,
@FloatRange(from = MIN_LATITUDE, to = GeoJsonConstants.MAX_LATITUDE) double south,
@FloatRange(from = MIN_LONGITUDE, to = GeoJsonConstants.MAX_LONGITUDE) double east,
@FloatRange(from = MIN_LATITUDE, to = GeoJsonConstants.MAX_LATITUDE) double north) {
"""
Define a new instance of this class by passing in four coordinates in the same order they would
appear in the serialized GeoJson form. Limits are placed on the minimum and maximum coordinate
values which can exist and comply with the GeoJson spec.
@param west the left side of the bounding box when the map is facing due north
@param south the bottom side of the bounding box when the map is facing due north
@param east the right side of the bounding box when the map is facing due north
@param north the top side of the bounding box when the map is facing due north
@return a new instance of this class defined by the provided coordinates
@since 3.0.0
@deprecated As of 3.1.0, use {@link #fromLngLats} instead.
"""
return fromLngLats(west, south, east, north);
} | java | @Deprecated
public static BoundingBox fromCoordinates(
@FloatRange(from = MIN_LONGITUDE, to = GeoJsonConstants.MAX_LONGITUDE) double west,
@FloatRange(from = MIN_LATITUDE, to = GeoJsonConstants.MAX_LATITUDE) double south,
@FloatRange(from = MIN_LONGITUDE, to = GeoJsonConstants.MAX_LONGITUDE) double east,
@FloatRange(from = MIN_LATITUDE, to = GeoJsonConstants.MAX_LATITUDE) double north) {
return fromLngLats(west, south, east, north);
} | [
"@",
"Deprecated",
"public",
"static",
"BoundingBox",
"fromCoordinates",
"(",
"@",
"FloatRange",
"(",
"from",
"=",
"MIN_LONGITUDE",
",",
"to",
"=",
"GeoJsonConstants",
".",
"MAX_LONGITUDE",
")",
"double",
"west",
",",
"@",
"FloatRange",
"(",
"from",
"=",
"MIN_LATITUDE",
",",
"to",
"=",
"GeoJsonConstants",
".",
"MAX_LATITUDE",
")",
"double",
"south",
",",
"@",
"FloatRange",
"(",
"from",
"=",
"MIN_LONGITUDE",
",",
"to",
"=",
"GeoJsonConstants",
".",
"MAX_LONGITUDE",
")",
"double",
"east",
",",
"@",
"FloatRange",
"(",
"from",
"=",
"MIN_LATITUDE",
",",
"to",
"=",
"GeoJsonConstants",
".",
"MAX_LATITUDE",
")",
"double",
"north",
")",
"{",
"return",
"fromLngLats",
"(",
"west",
",",
"south",
",",
"east",
",",
"north",
")",
";",
"}"
] | Define a new instance of this class by passing in four coordinates in the same order they would
appear in the serialized GeoJson form. Limits are placed on the minimum and maximum coordinate
values which can exist and comply with the GeoJson spec.
@param west the left side of the bounding box when the map is facing due north
@param south the bottom side of the bounding box when the map is facing due north
@param east the right side of the bounding box when the map is facing due north
@param north the top side of the bounding box when the map is facing due north
@return a new instance of this class defined by the provided coordinates
@since 3.0.0
@deprecated As of 3.1.0, use {@link #fromLngLats} instead. | [
"Define",
"a",
"new",
"instance",
"of",
"this",
"class",
"by",
"passing",
"in",
"four",
"coordinates",
"in",
"the",
"same",
"order",
"they",
"would",
"appear",
"in",
"the",
"serialized",
"GeoJson",
"form",
".",
"Limits",
"are",
"placed",
"on",
"the",
"minimum",
"and",
"maximum",
"coordinate",
"values",
"which",
"can",
"exist",
"and",
"comply",
"with",
"the",
"GeoJson",
"spec",
"."
] | train | https://github.com/mapbox/mapbox-java/blob/c0be138f462f91441388584c668f3760ba0e18e2/services-geojson/src/main/java/com/mapbox/geojson/BoundingBox.java#L83-L90 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/paragraphvectors/ParagraphVectors.java | ParagraphVectors.similarityToLabel | public double similarityToLabel(LabelledDocument document, String label) {
"""
This method returns similarity of the document to specific label, based on mean value
@param document
@param label
@return
"""
if (document.getReferencedContent() != null) {
return similarityToLabel(document.getReferencedContent(), label);
} else
return similarityToLabel(document.getContent(), label);
} | java | public double similarityToLabel(LabelledDocument document, String label) {
if (document.getReferencedContent() != null) {
return similarityToLabel(document.getReferencedContent(), label);
} else
return similarityToLabel(document.getContent(), label);
} | [
"public",
"double",
"similarityToLabel",
"(",
"LabelledDocument",
"document",
",",
"String",
"label",
")",
"{",
"if",
"(",
"document",
".",
"getReferencedContent",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"similarityToLabel",
"(",
"document",
".",
"getReferencedContent",
"(",
")",
",",
"label",
")",
";",
"}",
"else",
"return",
"similarityToLabel",
"(",
"document",
".",
"getContent",
"(",
")",
",",
"label",
")",
";",
"}"
] | This method returns similarity of the document to specific label, based on mean value
@param document
@param label
@return | [
"This",
"method",
"returns",
"similarity",
"of",
"the",
"document",
"to",
"specific",
"label",
"based",
"on",
"mean",
"value"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/paragraphvectors/ParagraphVectors.java#L681-L686 |
Swagger2Markup/swagger2markup | src/main/java/io/github/swagger2markup/Swagger2MarkupConverter.java | Swagger2MarkupConverter.from | public static Builder from(Path swaggerPath) {
"""
Creates a Swagger2MarkupConverter.Builder using a local Path.
@param swaggerPath the local Path
@return a Swagger2MarkupConverter
"""
Validate.notNull(swaggerPath, "swaggerPath must not be null");
if (Files.notExists(swaggerPath)) {
throw new IllegalArgumentException(String.format("swaggerPath does not exist: %s", swaggerPath));
}
try {
if (Files.isHidden(swaggerPath)) {
throw new IllegalArgumentException("swaggerPath must not be a hidden file");
}
} catch (IOException e) {
throw new RuntimeException("Failed to check if swaggerPath is a hidden file", e);
}
return new Builder(swaggerPath);
} | java | public static Builder from(Path swaggerPath) {
Validate.notNull(swaggerPath, "swaggerPath must not be null");
if (Files.notExists(swaggerPath)) {
throw new IllegalArgumentException(String.format("swaggerPath does not exist: %s", swaggerPath));
}
try {
if (Files.isHidden(swaggerPath)) {
throw new IllegalArgumentException("swaggerPath must not be a hidden file");
}
} catch (IOException e) {
throw new RuntimeException("Failed to check if swaggerPath is a hidden file", e);
}
return new Builder(swaggerPath);
} | [
"public",
"static",
"Builder",
"from",
"(",
"Path",
"swaggerPath",
")",
"{",
"Validate",
".",
"notNull",
"(",
"swaggerPath",
",",
"\"swaggerPath must not be null\"",
")",
";",
"if",
"(",
"Files",
".",
"notExists",
"(",
"swaggerPath",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"swaggerPath does not exist: %s\"",
",",
"swaggerPath",
")",
")",
";",
"}",
"try",
"{",
"if",
"(",
"Files",
".",
"isHidden",
"(",
"swaggerPath",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"swaggerPath must not be a hidden file\"",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to check if swaggerPath is a hidden file\"",
",",
"e",
")",
";",
"}",
"return",
"new",
"Builder",
"(",
"swaggerPath",
")",
";",
"}"
] | Creates a Swagger2MarkupConverter.Builder using a local Path.
@param swaggerPath the local Path
@return a Swagger2MarkupConverter | [
"Creates",
"a",
"Swagger2MarkupConverter",
".",
"Builder",
"using",
"a",
"local",
"Path",
"."
] | train | https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/Swagger2MarkupConverter.java#L104-L117 |
finmath/finmath-lib | src/main/java/net/finmath/marketdata2/model/curves/DiscountCurveInterpolation.java | DiscountCurveInterpolation.createDiscountCurveFromMonteCarloLiborModel | public static DiscountCurveInterface createDiscountCurveFromMonteCarloLiborModel(String forwardCurveName, LIBORModelMonteCarloSimulationModel model, double startTime) throws CalculationException {
"""
Create a discount curve from forwards given by a LIBORMonteCarloModel. If the model uses multiple curves, return its discount curve.
@param forwardCurveName name of the forward curve.
@param model Monte Carlo model providing the forwards.
@param startTime time at which the curve starts, i.e. zero time for the curve
@return a discount curve from forwards given by a LIBORMonteCarloModel.
@throws CalculationException Thrown if the model failed to provide the forward rates.
"""
// Check if the LMM uses a discount curve which is created from a forward curve
if(model.getModel().getDiscountCurve()==null || model.getModel().getDiscountCurve().getName().toLowerCase().contains("DiscountCurveFromForwardCurve".toLowerCase())){
return new DiscountCurveFromForwardCurve(ForwardCurveInterpolation.createForwardCurveFromMonteCarloLiborModel(forwardCurveName, model, startTime));
}
else {
// i.e. forward curve of Libor Model not OIS. In this case return the OIS curve.
// Only at startTime 0!
return (DiscountCurveInterface) model.getModel().getDiscountCurve();
}
} | java | public static DiscountCurveInterface createDiscountCurveFromMonteCarloLiborModel(String forwardCurveName, LIBORModelMonteCarloSimulationModel model, double startTime) throws CalculationException{
// Check if the LMM uses a discount curve which is created from a forward curve
if(model.getModel().getDiscountCurve()==null || model.getModel().getDiscountCurve().getName().toLowerCase().contains("DiscountCurveFromForwardCurve".toLowerCase())){
return new DiscountCurveFromForwardCurve(ForwardCurveInterpolation.createForwardCurveFromMonteCarloLiborModel(forwardCurveName, model, startTime));
}
else {
// i.e. forward curve of Libor Model not OIS. In this case return the OIS curve.
// Only at startTime 0!
return (DiscountCurveInterface) model.getModel().getDiscountCurve();
}
} | [
"public",
"static",
"DiscountCurveInterface",
"createDiscountCurveFromMonteCarloLiborModel",
"(",
"String",
"forwardCurveName",
",",
"LIBORModelMonteCarloSimulationModel",
"model",
",",
"double",
"startTime",
")",
"throws",
"CalculationException",
"{",
"// Check if the LMM uses a discount curve which is created from a forward curve",
"if",
"(",
"model",
".",
"getModel",
"(",
")",
".",
"getDiscountCurve",
"(",
")",
"==",
"null",
"||",
"model",
".",
"getModel",
"(",
")",
".",
"getDiscountCurve",
"(",
")",
".",
"getName",
"(",
")",
".",
"toLowerCase",
"(",
")",
".",
"contains",
"(",
"\"DiscountCurveFromForwardCurve\"",
".",
"toLowerCase",
"(",
")",
")",
")",
"{",
"return",
"new",
"DiscountCurveFromForwardCurve",
"(",
"ForwardCurveInterpolation",
".",
"createForwardCurveFromMonteCarloLiborModel",
"(",
"forwardCurveName",
",",
"model",
",",
"startTime",
")",
")",
";",
"}",
"else",
"{",
"// i.e. forward curve of Libor Model not OIS. In this case return the OIS curve.",
"// Only at startTime 0!",
"return",
"(",
"DiscountCurveInterface",
")",
"model",
".",
"getModel",
"(",
")",
".",
"getDiscountCurve",
"(",
")",
";",
"}",
"}"
] | Create a discount curve from forwards given by a LIBORMonteCarloModel. If the model uses multiple curves, return its discount curve.
@param forwardCurveName name of the forward curve.
@param model Monte Carlo model providing the forwards.
@param startTime time at which the curve starts, i.e. zero time for the curve
@return a discount curve from forwards given by a LIBORMonteCarloModel.
@throws CalculationException Thrown if the model failed to provide the forward rates. | [
"Create",
"a",
"discount",
"curve",
"from",
"forwards",
"given",
"by",
"a",
"LIBORMonteCarloModel",
".",
"If",
"the",
"model",
"uses",
"multiple",
"curves",
"return",
"its",
"discount",
"curve",
"."
] | train | https://github.com/finmath/finmath-lib/blob/a3c067d52dd33feb97d851df6cab130e4116759f/src/main/java/net/finmath/marketdata2/model/curves/DiscountCurveInterpolation.java#L401-L412 |
dkmfbk/knowledgestore | ks-server/src/main/java/eu/fbk/knowledgestore/triplestore/SelectQuery.java | SelectQuery.replaceDataset | public SelectQuery replaceDataset(@Nullable final Dataset dataset) {
"""
Replaces the dataset of this query with the one specified, returning the resulting
<tt>SelectQuery</tt> object.
@param dataset
the new dataset; as usual, <tt>null</tt> denotes the default dataset (all the
graphs)
@return the resulting <tt>SelectQuery</tt> object (possibly <tt>this</tt> if no change is
required)
"""
if (Objects.equal(this.dataset, dataset)) {
return this;
} else {
try {
return from(this.expression, dataset);
} catch (final ParseException ex) {
throw new Error("Unexpected error - replacing dataset made the query invalid (!)",
ex);
}
}
} | java | public SelectQuery replaceDataset(@Nullable final Dataset dataset) {
if (Objects.equal(this.dataset, dataset)) {
return this;
} else {
try {
return from(this.expression, dataset);
} catch (final ParseException ex) {
throw new Error("Unexpected error - replacing dataset made the query invalid (!)",
ex);
}
}
} | [
"public",
"SelectQuery",
"replaceDataset",
"(",
"@",
"Nullable",
"final",
"Dataset",
"dataset",
")",
"{",
"if",
"(",
"Objects",
".",
"equal",
"(",
"this",
".",
"dataset",
",",
"dataset",
")",
")",
"{",
"return",
"this",
";",
"}",
"else",
"{",
"try",
"{",
"return",
"from",
"(",
"this",
".",
"expression",
",",
"dataset",
")",
";",
"}",
"catch",
"(",
"final",
"ParseException",
"ex",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Unexpected error - replacing dataset made the query invalid (!)\"",
",",
"ex",
")",
";",
"}",
"}",
"}"
] | Replaces the dataset of this query with the one specified, returning the resulting
<tt>SelectQuery</tt> object.
@param dataset
the new dataset; as usual, <tt>null</tt> denotes the default dataset (all the
graphs)
@return the resulting <tt>SelectQuery</tt> object (possibly <tt>this</tt> if no change is
required) | [
"Replaces",
"the",
"dataset",
"of",
"this",
"query",
"with",
"the",
"one",
"specified",
"returning",
"the",
"resulting",
"<tt",
">",
"SelectQuery<",
"/",
"tt",
">",
"object",
"."
] | train | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-server/src/main/java/eu/fbk/knowledgestore/triplestore/SelectQuery.java#L199-L210 |
alkacon/opencms-core | src/org/opencms/relations/CmsLinkUpdateUtil.java | CmsLinkUpdateUtil.updateNode | private static void updateNode(Element parent, String nodeName, String value, boolean cdata) {
"""
Updates the given xml node with the given value.<p>
@param parent the parent node
@param nodeName the node to update
@param value the value to use to update the given node, can be <code>null</code>
@param cdata if the value should be in a CDATA section or not
"""
// get current node element
Element nodeElement = parent.element(nodeName);
if (value != null) {
if (nodeElement == null) {
// element wasn't there before, add element and set value
nodeElement = parent.addElement(nodeName);
}
// element is there, update element value
nodeElement.clearContent();
if (cdata) {
nodeElement.addCDATA(value);
} else {
nodeElement.addText(value);
}
} else {
// remove only if element exists
if (nodeElement != null) {
// remove element
parent.remove(nodeElement);
}
}
} | java | private static void updateNode(Element parent, String nodeName, String value, boolean cdata) {
// get current node element
Element nodeElement = parent.element(nodeName);
if (value != null) {
if (nodeElement == null) {
// element wasn't there before, add element and set value
nodeElement = parent.addElement(nodeName);
}
// element is there, update element value
nodeElement.clearContent();
if (cdata) {
nodeElement.addCDATA(value);
} else {
nodeElement.addText(value);
}
} else {
// remove only if element exists
if (nodeElement != null) {
// remove element
parent.remove(nodeElement);
}
}
} | [
"private",
"static",
"void",
"updateNode",
"(",
"Element",
"parent",
",",
"String",
"nodeName",
",",
"String",
"value",
",",
"boolean",
"cdata",
")",
"{",
"// get current node element",
"Element",
"nodeElement",
"=",
"parent",
".",
"element",
"(",
"nodeName",
")",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"if",
"(",
"nodeElement",
"==",
"null",
")",
"{",
"// element wasn't there before, add element and set value",
"nodeElement",
"=",
"parent",
".",
"addElement",
"(",
"nodeName",
")",
";",
"}",
"// element is there, update element value",
"nodeElement",
".",
"clearContent",
"(",
")",
";",
"if",
"(",
"cdata",
")",
"{",
"nodeElement",
".",
"addCDATA",
"(",
"value",
")",
";",
"}",
"else",
"{",
"nodeElement",
".",
"addText",
"(",
"value",
")",
";",
"}",
"}",
"else",
"{",
"// remove only if element exists",
"if",
"(",
"nodeElement",
"!=",
"null",
")",
"{",
"// remove element",
"parent",
".",
"remove",
"(",
"nodeElement",
")",
";",
"}",
"}",
"}"
] | Updates the given xml node with the given value.<p>
@param parent the parent node
@param nodeName the node to update
@param value the value to use to update the given node, can be <code>null</code>
@param cdata if the value should be in a CDATA section or not | [
"Updates",
"the",
"given",
"xml",
"node",
"with",
"the",
"given",
"value",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/relations/CmsLinkUpdateUtil.java#L169-L192 |
seedstack/jms-addon | src/main/java/org/seedstack/jms/internal/JmsPlugin.java | JmsPlugin.registerConnection | public void registerConnection(Connection connection, ConnectionDefinition connectionDefinition) {
"""
Register an existing JMS connection to be managed by the JMS plugin.
@param connection the connection.
@param connectionDefinition the connection definition.
"""
checkNotNull(connection);
checkNotNull(connectionDefinition);
if (this.connectionDefinitions.putIfAbsent(connectionDefinition.getName(), connectionDefinition) != null) {
throw SeedException.createNew(JmsErrorCode.DUPLICATE_CONNECTION_NAME).put(ERROR_CONNECTION_NAME, connectionDefinition.getName());
}
if (this.connections.putIfAbsent(connectionDefinition.getName(), connection) != null) {
throw SeedException.createNew(JmsErrorCode.DUPLICATE_CONNECTION_NAME).put(ERROR_CONNECTION_NAME, connectionDefinition.getName());
}
if (shouldStartConnections.get()) {
try {
connection.start();
} catch (JMSException e) {
throw SeedException.wrap(e, JmsErrorCode.UNABLE_TO_START_JMS_CONNECTION).put(ERROR_CONNECTION_NAME, connectionDefinition.getName());
}
}
} | java | public void registerConnection(Connection connection, ConnectionDefinition connectionDefinition) {
checkNotNull(connection);
checkNotNull(connectionDefinition);
if (this.connectionDefinitions.putIfAbsent(connectionDefinition.getName(), connectionDefinition) != null) {
throw SeedException.createNew(JmsErrorCode.DUPLICATE_CONNECTION_NAME).put(ERROR_CONNECTION_NAME, connectionDefinition.getName());
}
if (this.connections.putIfAbsent(connectionDefinition.getName(), connection) != null) {
throw SeedException.createNew(JmsErrorCode.DUPLICATE_CONNECTION_NAME).put(ERROR_CONNECTION_NAME, connectionDefinition.getName());
}
if (shouldStartConnections.get()) {
try {
connection.start();
} catch (JMSException e) {
throw SeedException.wrap(e, JmsErrorCode.UNABLE_TO_START_JMS_CONNECTION).put(ERROR_CONNECTION_NAME, connectionDefinition.getName());
}
}
} | [
"public",
"void",
"registerConnection",
"(",
"Connection",
"connection",
",",
"ConnectionDefinition",
"connectionDefinition",
")",
"{",
"checkNotNull",
"(",
"connection",
")",
";",
"checkNotNull",
"(",
"connectionDefinition",
")",
";",
"if",
"(",
"this",
".",
"connectionDefinitions",
".",
"putIfAbsent",
"(",
"connectionDefinition",
".",
"getName",
"(",
")",
",",
"connectionDefinition",
")",
"!=",
"null",
")",
"{",
"throw",
"SeedException",
".",
"createNew",
"(",
"JmsErrorCode",
".",
"DUPLICATE_CONNECTION_NAME",
")",
".",
"put",
"(",
"ERROR_CONNECTION_NAME",
",",
"connectionDefinition",
".",
"getName",
"(",
")",
")",
";",
"}",
"if",
"(",
"this",
".",
"connections",
".",
"putIfAbsent",
"(",
"connectionDefinition",
".",
"getName",
"(",
")",
",",
"connection",
")",
"!=",
"null",
")",
"{",
"throw",
"SeedException",
".",
"createNew",
"(",
"JmsErrorCode",
".",
"DUPLICATE_CONNECTION_NAME",
")",
".",
"put",
"(",
"ERROR_CONNECTION_NAME",
",",
"connectionDefinition",
".",
"getName",
"(",
")",
")",
";",
"}",
"if",
"(",
"shouldStartConnections",
".",
"get",
"(",
")",
")",
"{",
"try",
"{",
"connection",
".",
"start",
"(",
")",
";",
"}",
"catch",
"(",
"JMSException",
"e",
")",
"{",
"throw",
"SeedException",
".",
"wrap",
"(",
"e",
",",
"JmsErrorCode",
".",
"UNABLE_TO_START_JMS_CONNECTION",
")",
".",
"put",
"(",
"ERROR_CONNECTION_NAME",
",",
"connectionDefinition",
".",
"getName",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Register an existing JMS connection to be managed by the JMS plugin.
@param connection the connection.
@param connectionDefinition the connection definition. | [
"Register",
"an",
"existing",
"JMS",
"connection",
"to",
"be",
"managed",
"by",
"the",
"JMS",
"plugin",
"."
] | train | https://github.com/seedstack/jms-addon/blob/d6014811daaac29f591b32bfd2358500fb25d804/src/main/java/org/seedstack/jms/internal/JmsPlugin.java#L299-L318 |
elki-project/elki | elki-index-preprocessed/src/main/java/de/lmu/ifi/dbs/elki/index/preprocessed/knn/MaterializeKNNAndRKNNPreprocessor.java | MaterializeKNNAndRKNNPreprocessor.affectedRkNN | protected ArrayDBIDs affectedRkNN(List<? extends Collection<DoubleDBIDPair>> extract, DBIDs remove) {
"""
Extracts and removes the DBIDs in the given collections.
@param extract a list of lists of DistanceResultPair to extract
@param remove the ids to remove
@return the DBIDs in the given collection
"""
HashSetModifiableDBIDs ids = DBIDUtil.newHashSet();
for(Collection<DoubleDBIDPair> drps : extract) {
for(DoubleDBIDPair drp : drps) {
ids.add(drp);
}
}
ids.removeDBIDs(remove);
// Convert back to array
return DBIDUtil.newArray(ids);
} | java | protected ArrayDBIDs affectedRkNN(List<? extends Collection<DoubleDBIDPair>> extract, DBIDs remove) {
HashSetModifiableDBIDs ids = DBIDUtil.newHashSet();
for(Collection<DoubleDBIDPair> drps : extract) {
for(DoubleDBIDPair drp : drps) {
ids.add(drp);
}
}
ids.removeDBIDs(remove);
// Convert back to array
return DBIDUtil.newArray(ids);
} | [
"protected",
"ArrayDBIDs",
"affectedRkNN",
"(",
"List",
"<",
"?",
"extends",
"Collection",
"<",
"DoubleDBIDPair",
">",
">",
"extract",
",",
"DBIDs",
"remove",
")",
"{",
"HashSetModifiableDBIDs",
"ids",
"=",
"DBIDUtil",
".",
"newHashSet",
"(",
")",
";",
"for",
"(",
"Collection",
"<",
"DoubleDBIDPair",
">",
"drps",
":",
"extract",
")",
"{",
"for",
"(",
"DoubleDBIDPair",
"drp",
":",
"drps",
")",
"{",
"ids",
".",
"add",
"(",
"drp",
")",
";",
"}",
"}",
"ids",
".",
"removeDBIDs",
"(",
"remove",
")",
";",
"// Convert back to array",
"return",
"DBIDUtil",
".",
"newArray",
"(",
"ids",
")",
";",
"}"
] | Extracts and removes the DBIDs in the given collections.
@param extract a list of lists of DistanceResultPair to extract
@param remove the ids to remove
@return the DBIDs in the given collection | [
"Extracts",
"and",
"removes",
"the",
"DBIDs",
"in",
"the",
"given",
"collections",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-preprocessed/src/main/java/de/lmu/ifi/dbs/elki/index/preprocessed/knn/MaterializeKNNAndRKNNPreprocessor.java#L307-L317 |
mojohaus/jaxb2-maven-plugin | src/main/java/org/codehaus/mojo/jaxb2/shared/environment/classloading/ThreadContextClassLoaderBuilder.java | ThreadContextClassLoaderBuilder.buildAndSet | public ThreadContextClassLoaderHolder buildAndSet() {
"""
<p>This method performs 2 things in order:</p>
<ol>
<li>Builds a ThreadContext ClassLoader from the URLs supplied to this Builder, and assigns the
newly built ClassLoader to the current Thread.</li>
<li>Stores the ThreadContextClassLoaderHolder for later restoration.</li>
</ol>
References to the original ThreadContextClassLoader and the currentThread are stored within the returned
ThreadContextClassLoaderHolder, and can be restored by a call to
{@code ThreadContextClassLoaderHolder.restoreClassLoaderAndReleaseThread()}.
@return A fully set up ThreadContextClassLoaderHolder which is used to set the
"""
// Create the URLClassLoader from the supplied URLs
final URL[] allURLs = new URL[urlList.size()];
urlList.toArray(allURLs);
final URLClassLoader classLoader = new URLClassLoader(allURLs, originalClassLoader);
// Assign the ThreadContext ClassLoader
final Thread currentThread = Thread.currentThread();
currentThread.setContextClassLoader(classLoader);
// Build the classpath argument
StringBuilder builder = new StringBuilder();
try {
for (URL current : Collections.list(classLoader.getResources(""))) {
final String toAppend = getClassPathElement(current, encoding);
if (toAppend != null) {
builder.append(toAppend).append(File.pathSeparator);
}
}
} catch (Exception e) {
// Restore the original classloader to the active thread before failing.
currentThread.setContextClassLoader(originalClassLoader);
throw new IllegalStateException("Could not synthesize classpath from original classloader.", e);
}
final String classPathString = builder.length() > 0
? builder.toString().substring(0, builder.length() - File.pathSeparator.length())
: "";
// All done.
return new DefaultHolder(currentThread, this.originalClassLoader, classPathString);
} | java | public ThreadContextClassLoaderHolder buildAndSet() {
// Create the URLClassLoader from the supplied URLs
final URL[] allURLs = new URL[urlList.size()];
urlList.toArray(allURLs);
final URLClassLoader classLoader = new URLClassLoader(allURLs, originalClassLoader);
// Assign the ThreadContext ClassLoader
final Thread currentThread = Thread.currentThread();
currentThread.setContextClassLoader(classLoader);
// Build the classpath argument
StringBuilder builder = new StringBuilder();
try {
for (URL current : Collections.list(classLoader.getResources(""))) {
final String toAppend = getClassPathElement(current, encoding);
if (toAppend != null) {
builder.append(toAppend).append(File.pathSeparator);
}
}
} catch (Exception e) {
// Restore the original classloader to the active thread before failing.
currentThread.setContextClassLoader(originalClassLoader);
throw new IllegalStateException("Could not synthesize classpath from original classloader.", e);
}
final String classPathString = builder.length() > 0
? builder.toString().substring(0, builder.length() - File.pathSeparator.length())
: "";
// All done.
return new DefaultHolder(currentThread, this.originalClassLoader, classPathString);
} | [
"public",
"ThreadContextClassLoaderHolder",
"buildAndSet",
"(",
")",
"{",
"// Create the URLClassLoader from the supplied URLs",
"final",
"URL",
"[",
"]",
"allURLs",
"=",
"new",
"URL",
"[",
"urlList",
".",
"size",
"(",
")",
"]",
";",
"urlList",
".",
"toArray",
"(",
"allURLs",
")",
";",
"final",
"URLClassLoader",
"classLoader",
"=",
"new",
"URLClassLoader",
"(",
"allURLs",
",",
"originalClassLoader",
")",
";",
"// Assign the ThreadContext ClassLoader",
"final",
"Thread",
"currentThread",
"=",
"Thread",
".",
"currentThread",
"(",
")",
";",
"currentThread",
".",
"setContextClassLoader",
"(",
"classLoader",
")",
";",
"// Build the classpath argument",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"try",
"{",
"for",
"(",
"URL",
"current",
":",
"Collections",
".",
"list",
"(",
"classLoader",
".",
"getResources",
"(",
"\"\"",
")",
")",
")",
"{",
"final",
"String",
"toAppend",
"=",
"getClassPathElement",
"(",
"current",
",",
"encoding",
")",
";",
"if",
"(",
"toAppend",
"!=",
"null",
")",
"{",
"builder",
".",
"append",
"(",
"toAppend",
")",
".",
"append",
"(",
"File",
".",
"pathSeparator",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// Restore the original classloader to the active thread before failing.",
"currentThread",
".",
"setContextClassLoader",
"(",
"originalClassLoader",
")",
";",
"throw",
"new",
"IllegalStateException",
"(",
"\"Could not synthesize classpath from original classloader.\"",
",",
"e",
")",
";",
"}",
"final",
"String",
"classPathString",
"=",
"builder",
".",
"length",
"(",
")",
">",
"0",
"?",
"builder",
".",
"toString",
"(",
")",
".",
"substring",
"(",
"0",
",",
"builder",
".",
"length",
"(",
")",
"-",
"File",
".",
"pathSeparator",
".",
"length",
"(",
")",
")",
":",
"\"\"",
";",
"// All done.",
"return",
"new",
"DefaultHolder",
"(",
"currentThread",
",",
"this",
".",
"originalClassLoader",
",",
"classPathString",
")",
";",
"}"
] | <p>This method performs 2 things in order:</p>
<ol>
<li>Builds a ThreadContext ClassLoader from the URLs supplied to this Builder, and assigns the
newly built ClassLoader to the current Thread.</li>
<li>Stores the ThreadContextClassLoaderHolder for later restoration.</li>
</ol>
References to the original ThreadContextClassLoader and the currentThread are stored within the returned
ThreadContextClassLoaderHolder, and can be restored by a call to
{@code ThreadContextClassLoaderHolder.restoreClassLoaderAndReleaseThread()}.
@return A fully set up ThreadContextClassLoaderHolder which is used to set the | [
"<p",
">",
"This",
"method",
"performs",
"2",
"things",
"in",
"order",
":",
"<",
"/",
"p",
">",
"<ol",
">",
"<li",
">",
"Builds",
"a",
"ThreadContext",
"ClassLoader",
"from",
"the",
"URLs",
"supplied",
"to",
"this",
"Builder",
"and",
"assigns",
"the",
"newly",
"built",
"ClassLoader",
"to",
"the",
"current",
"Thread",
".",
"<",
"/",
"li",
">",
"<li",
">",
"Stores",
"the",
"ThreadContextClassLoaderHolder",
"for",
"later",
"restoration",
".",
"<",
"/",
"li",
">",
"<",
"/",
"ol",
">",
"References",
"to",
"the",
"original",
"ThreadContextClassLoader",
"and",
"the",
"currentThread",
"are",
"stored",
"within",
"the",
"returned",
"ThreadContextClassLoaderHolder",
"and",
"can",
"be",
"restored",
"by",
"a",
"call",
"to",
"{",
"@code",
"ThreadContextClassLoaderHolder",
".",
"restoreClassLoaderAndReleaseThread",
"()",
"}",
"."
] | train | https://github.com/mojohaus/jaxb2-maven-plugin/blob/e3c4e47943b15282e5a6e850bbfb1588d8452a0a/src/main/java/org/codehaus/mojo/jaxb2/shared/environment/classloading/ThreadContextClassLoaderBuilder.java#L207-L240 |
phxql/argon2-jvm | src/main/java/de/mkammerer/argon2/Argon2Helper.java | Argon2Helper.findIterations | public static int findIterations(Argon2 argon2, long maxMillisecs, int memory, int parallelism, IterationLogger logger) {
"""
Finds the number of iterations so that the hash function takes at most the given number of milliseconds.
@param argon2 Argon2 instance.
@param maxMillisecs Maximum number of milliseconds the hash function must take.
@param memory Memory. See {@link Argon2#hash(int, int, int, char[])}.
@param parallelism Parallelism. See {@link Argon2#hash(int, int, int, char[])}.
@param logger Logger which gets called with the runtime of the tested iteration steps.
@return The number of iterations so that the hash function takes at most the given number of milliseconds.
"""
char[] password = "password".toCharArray();
warmup(argon2, password);
long took;
int iterations = 0;
do {
iterations++;
long start = System.nanoTime() / MILLIS_IN_NANOS;
argon2.hash(iterations, memory, parallelism, password);
long end = System.nanoTime() / MILLIS_IN_NANOS;
took = end - start;
logger.log(iterations, took);
} while (took <= maxMillisecs);
return iterations - 1;
} | java | public static int findIterations(Argon2 argon2, long maxMillisecs, int memory, int parallelism, IterationLogger logger) {
char[] password = "password".toCharArray();
warmup(argon2, password);
long took;
int iterations = 0;
do {
iterations++;
long start = System.nanoTime() / MILLIS_IN_NANOS;
argon2.hash(iterations, memory, parallelism, password);
long end = System.nanoTime() / MILLIS_IN_NANOS;
took = end - start;
logger.log(iterations, took);
} while (took <= maxMillisecs);
return iterations - 1;
} | [
"public",
"static",
"int",
"findIterations",
"(",
"Argon2",
"argon2",
",",
"long",
"maxMillisecs",
",",
"int",
"memory",
",",
"int",
"parallelism",
",",
"IterationLogger",
"logger",
")",
"{",
"char",
"[",
"]",
"password",
"=",
"\"password\"",
".",
"toCharArray",
"(",
")",
";",
"warmup",
"(",
"argon2",
",",
"password",
")",
";",
"long",
"took",
";",
"int",
"iterations",
"=",
"0",
";",
"do",
"{",
"iterations",
"++",
";",
"long",
"start",
"=",
"System",
".",
"nanoTime",
"(",
")",
"/",
"MILLIS_IN_NANOS",
";",
"argon2",
".",
"hash",
"(",
"iterations",
",",
"memory",
",",
"parallelism",
",",
"password",
")",
";",
"long",
"end",
"=",
"System",
".",
"nanoTime",
"(",
")",
"/",
"MILLIS_IN_NANOS",
";",
"took",
"=",
"end",
"-",
"start",
";",
"logger",
".",
"log",
"(",
"iterations",
",",
"took",
")",
";",
"}",
"while",
"(",
"took",
"<=",
"maxMillisecs",
")",
";",
"return",
"iterations",
"-",
"1",
";",
"}"
] | Finds the number of iterations so that the hash function takes at most the given number of milliseconds.
@param argon2 Argon2 instance.
@param maxMillisecs Maximum number of milliseconds the hash function must take.
@param memory Memory. See {@link Argon2#hash(int, int, int, char[])}.
@param parallelism Parallelism. See {@link Argon2#hash(int, int, int, char[])}.
@param logger Logger which gets called with the runtime of the tested iteration steps.
@return The number of iterations so that the hash function takes at most the given number of milliseconds. | [
"Finds",
"the",
"number",
"of",
"iterations",
"so",
"that",
"the",
"hash",
"function",
"takes",
"at",
"most",
"the",
"given",
"number",
"of",
"milliseconds",
"."
] | train | https://github.com/phxql/argon2-jvm/blob/27a13907729e67e98cca53eba279e109b60f04f1/src/main/java/de/mkammerer/argon2/Argon2Helper.java#L57-L75 |
docusign/docusign-java-client | src/main/java/com/docusign/esign/api/TemplatesApi.java | TemplatesApi.updateDocument | public EnvelopeDocument updateDocument(String accountId, String templateId, String documentId, EnvelopeDefinition envelopeDefinition) throws ApiException {
"""
Adds a document to a template document.
Adds the specified document to an existing template document.
@param accountId The external account number (int) or account ID Guid. (required)
@param templateId The ID of the template being accessed. (required)
@param documentId The ID of the document being accessed. (required)
@param envelopeDefinition (optional)
@return EnvelopeDocument
"""
return updateDocument(accountId, templateId, documentId, envelopeDefinition, null);
} | java | public EnvelopeDocument updateDocument(String accountId, String templateId, String documentId, EnvelopeDefinition envelopeDefinition) throws ApiException {
return updateDocument(accountId, templateId, documentId, envelopeDefinition, null);
} | [
"public",
"EnvelopeDocument",
"updateDocument",
"(",
"String",
"accountId",
",",
"String",
"templateId",
",",
"String",
"documentId",
",",
"EnvelopeDefinition",
"envelopeDefinition",
")",
"throws",
"ApiException",
"{",
"return",
"updateDocument",
"(",
"accountId",
",",
"templateId",
",",
"documentId",
",",
"envelopeDefinition",
",",
"null",
")",
";",
"}"
] | Adds a document to a template document.
Adds the specified document to an existing template document.
@param accountId The external account number (int) or account ID Guid. (required)
@param templateId The ID of the template being accessed. (required)
@param documentId The ID of the document being accessed. (required)
@param envelopeDefinition (optional)
@return EnvelopeDocument | [
"Adds",
"a",
"document",
"to",
"a",
"template",
"document",
".",
"Adds",
"the",
"specified",
"document",
"to",
"an",
"existing",
"template",
"document",
"."
] | train | https://github.com/docusign/docusign-java-client/blob/17ae82ace0f023e98edf813be832950568212e34/src/main/java/com/docusign/esign/api/TemplatesApi.java#L2954-L2956 |
Esri/geometry-api-java | src/main/java/com/esri/core/geometry/Transformation2D.java | Transformation2D.setRotate | public void setRotate(double cosA, double sinA) {
"""
Sets rotation for this transformation.
When the axis Y is directed up and X is directed to the right, the
positive angle corresponds to the anti-clockwise rotation. When the axis
Y is directed down and X is directed to the right, the positive angle
corresponds to the clockwise rotation.
@param cosA
The rotation angle.
@param sinA
The rotation angle.
"""
xx = cosA;
xy = -sinA;
xd = 0;
yx = sinA;
yy = cosA;
yd = 0;
} | java | public void setRotate(double cosA, double sinA) {
xx = cosA;
xy = -sinA;
xd = 0;
yx = sinA;
yy = cosA;
yd = 0;
} | [
"public",
"void",
"setRotate",
"(",
"double",
"cosA",
",",
"double",
"sinA",
")",
"{",
"xx",
"=",
"cosA",
";",
"xy",
"=",
"-",
"sinA",
";",
"xd",
"=",
"0",
";",
"yx",
"=",
"sinA",
";",
"yy",
"=",
"cosA",
";",
"yd",
"=",
"0",
";",
"}"
] | Sets rotation for this transformation.
When the axis Y is directed up and X is directed to the right, the
positive angle corresponds to the anti-clockwise rotation. When the axis
Y is directed down and X is directed to the right, the positive angle
corresponds to the clockwise rotation.
@param cosA
The rotation angle.
@param sinA
The rotation angle. | [
"Sets",
"rotation",
"for",
"this",
"transformation",
"."
] | train | https://github.com/Esri/geometry-api-java/blob/494da8ec953d76e7c6072afbc081abfe48ff07cf/src/main/java/com/esri/core/geometry/Transformation2D.java#L728-L735 |
hazelcast/hazelcast | hazelcast-client/src/main/java/com/hazelcast/client/proxy/ClientPNCounterProxy.java | ClientPNCounterProxy.invokeAddInternal | private ClientMessage invokeAddInternal(long delta, boolean getBeforeUpdate,
List<Address> excludedAddresses,
HazelcastException lastException,
Address target) {
"""
Adds the {@code delta} and returns the value of the counter before the
update if {@code getBeforeUpdate} is {@code true} or the value after
the update if it is {@code false}.
It will invoke client messages recursively on viable replica addresses
until successful or the list of viable replicas is exhausted.
Replicas with addresses contained in the {@code excludedAddresses} are
skipped. If there are no viable replicas, this method will throw the
{@code lastException} if not {@code null} or a
{@link NoDataMemberInClusterException} if the {@code lastException} is
{@code null}.
@param delta the delta to add to the counter value, can be negative
@param getBeforeUpdate {@code true} if the operation should return the
counter value before the addition, {@code false}
if it should return the value after the addition
@param excludedAddresses the addresses to exclude when choosing a replica
address, must not be {@code null}
@param lastException the exception thrown from the last invocation of
the {@code request} on a replica, may be {@code null}
@return the result of the request invocation on a replica
@throws NoDataMemberInClusterException if there are no replicas and the
{@code lastException} is {@code null}
"""
if (target == null) {
throw lastException != null
? lastException
: new NoDataMemberInClusterException(
"Cannot invoke operations on a CRDT because the cluster does not contain any data members");
}
try {
final ClientMessage request = PNCounterAddCodec.encodeRequest(
name, delta, getBeforeUpdate, observedClock.entrySet(), target);
return invokeOnAddress(request, target);
} catch (HazelcastException e) {
logger.fine("Unable to provide session guarantees when sending operations to " + target
+ ", choosing different target");
if (excludedAddresses == EMPTY_ADDRESS_LIST) {
excludedAddresses = new ArrayList<Address>();
}
excludedAddresses.add(target);
final Address newTarget = getCRDTOperationTarget(excludedAddresses);
return invokeAddInternal(delta, getBeforeUpdate, excludedAddresses, e, newTarget);
}
} | java | private ClientMessage invokeAddInternal(long delta, boolean getBeforeUpdate,
List<Address> excludedAddresses,
HazelcastException lastException,
Address target) {
if (target == null) {
throw lastException != null
? lastException
: new NoDataMemberInClusterException(
"Cannot invoke operations on a CRDT because the cluster does not contain any data members");
}
try {
final ClientMessage request = PNCounterAddCodec.encodeRequest(
name, delta, getBeforeUpdate, observedClock.entrySet(), target);
return invokeOnAddress(request, target);
} catch (HazelcastException e) {
logger.fine("Unable to provide session guarantees when sending operations to " + target
+ ", choosing different target");
if (excludedAddresses == EMPTY_ADDRESS_LIST) {
excludedAddresses = new ArrayList<Address>();
}
excludedAddresses.add(target);
final Address newTarget = getCRDTOperationTarget(excludedAddresses);
return invokeAddInternal(delta, getBeforeUpdate, excludedAddresses, e, newTarget);
}
} | [
"private",
"ClientMessage",
"invokeAddInternal",
"(",
"long",
"delta",
",",
"boolean",
"getBeforeUpdate",
",",
"List",
"<",
"Address",
">",
"excludedAddresses",
",",
"HazelcastException",
"lastException",
",",
"Address",
"target",
")",
"{",
"if",
"(",
"target",
"==",
"null",
")",
"{",
"throw",
"lastException",
"!=",
"null",
"?",
"lastException",
":",
"new",
"NoDataMemberInClusterException",
"(",
"\"Cannot invoke operations on a CRDT because the cluster does not contain any data members\"",
")",
";",
"}",
"try",
"{",
"final",
"ClientMessage",
"request",
"=",
"PNCounterAddCodec",
".",
"encodeRequest",
"(",
"name",
",",
"delta",
",",
"getBeforeUpdate",
",",
"observedClock",
".",
"entrySet",
"(",
")",
",",
"target",
")",
";",
"return",
"invokeOnAddress",
"(",
"request",
",",
"target",
")",
";",
"}",
"catch",
"(",
"HazelcastException",
"e",
")",
"{",
"logger",
".",
"fine",
"(",
"\"Unable to provide session guarantees when sending operations to \"",
"+",
"target",
"+",
"\", choosing different target\"",
")",
";",
"if",
"(",
"excludedAddresses",
"==",
"EMPTY_ADDRESS_LIST",
")",
"{",
"excludedAddresses",
"=",
"new",
"ArrayList",
"<",
"Address",
">",
"(",
")",
";",
"}",
"excludedAddresses",
".",
"add",
"(",
"target",
")",
";",
"final",
"Address",
"newTarget",
"=",
"getCRDTOperationTarget",
"(",
"excludedAddresses",
")",
";",
"return",
"invokeAddInternal",
"(",
"delta",
",",
"getBeforeUpdate",
",",
"excludedAddresses",
",",
"e",
",",
"newTarget",
")",
";",
"}",
"}"
] | Adds the {@code delta} and returns the value of the counter before the
update if {@code getBeforeUpdate} is {@code true} or the value after
the update if it is {@code false}.
It will invoke client messages recursively on viable replica addresses
until successful or the list of viable replicas is exhausted.
Replicas with addresses contained in the {@code excludedAddresses} are
skipped. If there are no viable replicas, this method will throw the
{@code lastException} if not {@code null} or a
{@link NoDataMemberInClusterException} if the {@code lastException} is
{@code null}.
@param delta the delta to add to the counter value, can be negative
@param getBeforeUpdate {@code true} if the operation should return the
counter value before the addition, {@code false}
if it should return the value after the addition
@param excludedAddresses the addresses to exclude when choosing a replica
address, must not be {@code null}
@param lastException the exception thrown from the last invocation of
the {@code request} on a replica, may be {@code null}
@return the result of the request invocation on a replica
@throws NoDataMemberInClusterException if there are no replicas and the
{@code lastException} is {@code null} | [
"Adds",
"the",
"{",
"@code",
"delta",
"}",
"and",
"returns",
"the",
"value",
"of",
"the",
"counter",
"before",
"the",
"update",
"if",
"{",
"@code",
"getBeforeUpdate",
"}",
"is",
"{",
"@code",
"true",
"}",
"or",
"the",
"value",
"after",
"the",
"update",
"if",
"it",
"is",
"{",
"@code",
"false",
"}",
".",
"It",
"will",
"invoke",
"client",
"messages",
"recursively",
"on",
"viable",
"replica",
"addresses",
"until",
"successful",
"or",
"the",
"list",
"of",
"viable",
"replicas",
"is",
"exhausted",
".",
"Replicas",
"with",
"addresses",
"contained",
"in",
"the",
"{",
"@code",
"excludedAddresses",
"}",
"are",
"skipped",
".",
"If",
"there",
"are",
"no",
"viable",
"replicas",
"this",
"method",
"will",
"throw",
"the",
"{",
"@code",
"lastException",
"}",
"if",
"not",
"{",
"@code",
"null",
"}",
"or",
"a",
"{",
"@link",
"NoDataMemberInClusterException",
"}",
"if",
"the",
"{",
"@code",
"lastException",
"}",
"is",
"{",
"@code",
"null",
"}",
"."
] | train | https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast-client/src/main/java/com/hazelcast/client/proxy/ClientPNCounterProxy.java#L245-L269 |
fhoeben/hsac-fitnesse-fixtures | src/main/java/nl/hsac/fitnesse/fixture/slim/CompareFixture.java | CompareFixture.countDifferencesBetweenIgnoreWhitespaceAnd | public int countDifferencesBetweenIgnoreWhitespaceAnd(String first, String second) {
"""
Determines number of differences (substrings that are not equal) between two strings,
ignoring differences in whitespace.
@param first first string to compare.
@param second second string to compare.
@return number of different substrings.
"""
String cleanFirst = allWhitespaceToSingleSpace(first);
String cleanSecond = allWhitespaceToSingleSpace(second);
return countDifferencesBetweenAnd(cleanFirst, cleanSecond);
} | java | public int countDifferencesBetweenIgnoreWhitespaceAnd(String first, String second) {
String cleanFirst = allWhitespaceToSingleSpace(first);
String cleanSecond = allWhitespaceToSingleSpace(second);
return countDifferencesBetweenAnd(cleanFirst, cleanSecond);
} | [
"public",
"int",
"countDifferencesBetweenIgnoreWhitespaceAnd",
"(",
"String",
"first",
",",
"String",
"second",
")",
"{",
"String",
"cleanFirst",
"=",
"allWhitespaceToSingleSpace",
"(",
"first",
")",
";",
"String",
"cleanSecond",
"=",
"allWhitespaceToSingleSpace",
"(",
"second",
")",
";",
"return",
"countDifferencesBetweenAnd",
"(",
"cleanFirst",
",",
"cleanSecond",
")",
";",
"}"
] | Determines number of differences (substrings that are not equal) between two strings,
ignoring differences in whitespace.
@param first first string to compare.
@param second second string to compare.
@return number of different substrings. | [
"Determines",
"number",
"of",
"differences",
"(",
"substrings",
"that",
"are",
"not",
"equal",
")",
"between",
"two",
"strings",
"ignoring",
"differences",
"in",
"whitespace",
"."
] | train | https://github.com/fhoeben/hsac-fitnesse-fixtures/blob/4e9018d7386a9aa65bfcbf07eb28ae064edd1732/src/main/java/nl/hsac/fitnesse/fixture/slim/CompareFixture.java#L127-L131 |
ben-manes/caffeine | jcache/src/main/java/com/github/benmanes/caffeine/jcache/CacheProxy.java | CacheProxy.writeAllToCacheWriter | private @Nullable CacheWriterException writeAllToCacheWriter(Map<? extends K, ? extends V> map) {
"""
Writes all of the entries to the cache writer if write-through is enabled.
"""
if (!configuration.isWriteThrough() || map.isEmpty()) {
return null;
}
List<Cache.Entry<? extends K, ? extends V>> entries = map.entrySet().stream()
.map(entry -> new EntryProxy<>(entry.getKey(), entry.getValue()))
.collect(toList());
try {
writer.writeAll(entries);
return null;
} catch (CacheWriterException e) {
entries.forEach(entry -> {
map.remove(entry.getKey());
});
throw e;
} catch (RuntimeException e) {
entries.forEach(entry -> {
map.remove(entry.getKey());
});
return new CacheWriterException("Exception in CacheWriter", e);
}
} | java | private @Nullable CacheWriterException writeAllToCacheWriter(Map<? extends K, ? extends V> map) {
if (!configuration.isWriteThrough() || map.isEmpty()) {
return null;
}
List<Cache.Entry<? extends K, ? extends V>> entries = map.entrySet().stream()
.map(entry -> new EntryProxy<>(entry.getKey(), entry.getValue()))
.collect(toList());
try {
writer.writeAll(entries);
return null;
} catch (CacheWriterException e) {
entries.forEach(entry -> {
map.remove(entry.getKey());
});
throw e;
} catch (RuntimeException e) {
entries.forEach(entry -> {
map.remove(entry.getKey());
});
return new CacheWriterException("Exception in CacheWriter", e);
}
} | [
"private",
"@",
"Nullable",
"CacheWriterException",
"writeAllToCacheWriter",
"(",
"Map",
"<",
"?",
"extends",
"K",
",",
"?",
"extends",
"V",
">",
"map",
")",
"{",
"if",
"(",
"!",
"configuration",
".",
"isWriteThrough",
"(",
")",
"||",
"map",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"List",
"<",
"Cache",
".",
"Entry",
"<",
"?",
"extends",
"K",
",",
"?",
"extends",
"V",
">",
">",
"entries",
"=",
"map",
".",
"entrySet",
"(",
")",
".",
"stream",
"(",
")",
".",
"map",
"(",
"entry",
"->",
"new",
"EntryProxy",
"<>",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
")",
")",
".",
"collect",
"(",
"toList",
"(",
")",
")",
";",
"try",
"{",
"writer",
".",
"writeAll",
"(",
"entries",
")",
";",
"return",
"null",
";",
"}",
"catch",
"(",
"CacheWriterException",
"e",
")",
"{",
"entries",
".",
"forEach",
"(",
"entry",
"->",
"{",
"map",
".",
"remove",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"}",
")",
";",
"throw",
"e",
";",
"}",
"catch",
"(",
"RuntimeException",
"e",
")",
"{",
"entries",
".",
"forEach",
"(",
"entry",
"->",
"{",
"map",
".",
"remove",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"}",
")",
";",
"return",
"new",
"CacheWriterException",
"(",
"\"Exception in CacheWriter\"",
",",
"e",
")",
";",
"}",
"}"
] | Writes all of the entries to the cache writer if write-through is enabled. | [
"Writes",
"all",
"of",
"the",
"entries",
"to",
"the",
"cache",
"writer",
"if",
"write",
"-",
"through",
"is",
"enabled",
"."
] | train | https://github.com/ben-manes/caffeine/blob/4cf6d6e6a18ea2e8088f166261e5949343b0f2eb/jcache/src/main/java/com/github/benmanes/caffeine/jcache/CacheProxy.java#L1008-L1029 |
VoltDB/voltdb | src/frontend/org/voltdb/iv2/DeterminismHash.java | DeterminismHash.offerStatement | public void offerStatement(int stmtHash, int offset, ByteBuffer psetBuffer) {
"""
Update the overall hash. Add a pair of ints to the array
if the size isn't too large.
"""
m_inputCRC.update(stmtHash);
m_inputCRC.updateFromPosition(offset, psetBuffer);
if (m_hashCount < MAX_HASHES_COUNT) {
m_hashes[m_hashCount] = stmtHash;
m_hashes[m_hashCount + 1] = (int) m_inputCRC.getValue();
}
m_hashCount += 2;
} | java | public void offerStatement(int stmtHash, int offset, ByteBuffer psetBuffer) {
m_inputCRC.update(stmtHash);
m_inputCRC.updateFromPosition(offset, psetBuffer);
if (m_hashCount < MAX_HASHES_COUNT) {
m_hashes[m_hashCount] = stmtHash;
m_hashes[m_hashCount + 1] = (int) m_inputCRC.getValue();
}
m_hashCount += 2;
} | [
"public",
"void",
"offerStatement",
"(",
"int",
"stmtHash",
",",
"int",
"offset",
",",
"ByteBuffer",
"psetBuffer",
")",
"{",
"m_inputCRC",
".",
"update",
"(",
"stmtHash",
")",
";",
"m_inputCRC",
".",
"updateFromPosition",
"(",
"offset",
",",
"psetBuffer",
")",
";",
"if",
"(",
"m_hashCount",
"<",
"MAX_HASHES_COUNT",
")",
"{",
"m_hashes",
"[",
"m_hashCount",
"]",
"=",
"stmtHash",
";",
"m_hashes",
"[",
"m_hashCount",
"+",
"1",
"]",
"=",
"(",
"int",
")",
"m_inputCRC",
".",
"getValue",
"(",
")",
";",
"}",
"m_hashCount",
"+=",
"2",
";",
"}"
] | Update the overall hash. Add a pair of ints to the array
if the size isn't too large. | [
"Update",
"the",
"overall",
"hash",
".",
"Add",
"a",
"pair",
"of",
"ints",
"to",
"the",
"array",
"if",
"the",
"size",
"isn",
"t",
"too",
"large",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/iv2/DeterminismHash.java#L96-L105 |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/BasePrefetcher.java | BasePrefetcher.buildPrefetchCriteriaSingleKey | private Criteria buildPrefetchCriteriaSingleKey(Collection ids, FieldDescriptor field) {
"""
Build the Criteria using IN(...) for single keys
@param ids collection of identities
@param field
@return Criteria
"""
Criteria crit = new Criteria();
ArrayList values = new ArrayList(ids.size());
Iterator iter = ids.iterator();
Identity id;
while (iter.hasNext())
{
id = (Identity) iter.next();
values.add(id.getPrimaryKeyValues()[0]);
}
switch (values.size())
{
case 0:
break;
case 1:
crit.addEqualTo(field.getAttributeName(), values.get(0));
break;
default:
// create IN (...) for the single key field
crit.addIn(field.getAttributeName(), values);
break;
}
return crit;
} | java | private Criteria buildPrefetchCriteriaSingleKey(Collection ids, FieldDescriptor field)
{
Criteria crit = new Criteria();
ArrayList values = new ArrayList(ids.size());
Iterator iter = ids.iterator();
Identity id;
while (iter.hasNext())
{
id = (Identity) iter.next();
values.add(id.getPrimaryKeyValues()[0]);
}
switch (values.size())
{
case 0:
break;
case 1:
crit.addEqualTo(field.getAttributeName(), values.get(0));
break;
default:
// create IN (...) for the single key field
crit.addIn(field.getAttributeName(), values);
break;
}
return crit;
} | [
"private",
"Criteria",
"buildPrefetchCriteriaSingleKey",
"(",
"Collection",
"ids",
",",
"FieldDescriptor",
"field",
")",
"{",
"Criteria",
"crit",
"=",
"new",
"Criteria",
"(",
")",
";",
"ArrayList",
"values",
"=",
"new",
"ArrayList",
"(",
"ids",
".",
"size",
"(",
")",
")",
";",
"Iterator",
"iter",
"=",
"ids",
".",
"iterator",
"(",
")",
";",
"Identity",
"id",
";",
"while",
"(",
"iter",
".",
"hasNext",
"(",
")",
")",
"{",
"id",
"=",
"(",
"Identity",
")",
"iter",
".",
"next",
"(",
")",
";",
"values",
".",
"add",
"(",
"id",
".",
"getPrimaryKeyValues",
"(",
")",
"[",
"0",
"]",
")",
";",
"}",
"switch",
"(",
"values",
".",
"size",
"(",
")",
")",
"{",
"case",
"0",
":",
"break",
";",
"case",
"1",
":",
"crit",
".",
"addEqualTo",
"(",
"field",
".",
"getAttributeName",
"(",
")",
",",
"values",
".",
"get",
"(",
"0",
")",
")",
";",
"break",
";",
"default",
":",
"// create IN (...) for the single key field\r",
"crit",
".",
"addIn",
"(",
"field",
".",
"getAttributeName",
"(",
")",
",",
"values",
")",
";",
"break",
";",
"}",
"return",
"crit",
";",
"}"
] | Build the Criteria using IN(...) for single keys
@param ids collection of identities
@param field
@return Criteria | [
"Build",
"the",
"Criteria",
"using",
"IN",
"(",
"...",
")",
"for",
"single",
"keys"
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/BasePrefetcher.java#L168-L195 |
lessthanoptimal/ddogleg | src/org/ddogleg/nn/alg/searches/KdTreeSearchNStandard.java | KdTreeSearchNStandard.findNeighbor | @Override
public void findNeighbor(P target, int searchN, FastQueue<KdTreeResult> results) {
"""
Finds the nodes which are closest to 'target' and within range of the maximum distance.
@param target A point
@param searchN Number of nearest-neighbors it will search for
@param results Storage for the found neighbors
"""
if( searchN <= 0 )
throw new IllegalArgumentException("I'm sorry, but I refuse to search for less than or equal to 0 neighbors.");
if( tree.root == null )
return;
this.searchN = searchN;
this.target = target;
this.mostDistantNeighborSq = maxDistanceSq;
stepClosest(tree.root,results);
} | java | @Override
public void findNeighbor(P target, int searchN, FastQueue<KdTreeResult> results) {
if( searchN <= 0 )
throw new IllegalArgumentException("I'm sorry, but I refuse to search for less than or equal to 0 neighbors.");
if( tree.root == null )
return;
this.searchN = searchN;
this.target = target;
this.mostDistantNeighborSq = maxDistanceSq;
stepClosest(tree.root,results);
} | [
"@",
"Override",
"public",
"void",
"findNeighbor",
"(",
"P",
"target",
",",
"int",
"searchN",
",",
"FastQueue",
"<",
"KdTreeResult",
">",
"results",
")",
"{",
"if",
"(",
"searchN",
"<=",
"0",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"I'm sorry, but I refuse to search for less than or equal to 0 neighbors.\"",
")",
";",
"if",
"(",
"tree",
".",
"root",
"==",
"null",
")",
"return",
";",
"this",
".",
"searchN",
"=",
"searchN",
";",
"this",
".",
"target",
"=",
"target",
";",
"this",
".",
"mostDistantNeighborSq",
"=",
"maxDistanceSq",
";",
"stepClosest",
"(",
"tree",
".",
"root",
",",
"results",
")",
";",
"}"
] | Finds the nodes which are closest to 'target' and within range of the maximum distance.
@param target A point
@param searchN Number of nearest-neighbors it will search for
@param results Storage for the found neighbors | [
"Finds",
"the",
"nodes",
"which",
"are",
"closest",
"to",
"target",
"and",
"within",
"range",
"of",
"the",
"maximum",
"distance",
"."
] | train | https://github.com/lessthanoptimal/ddogleg/blob/3786bf448ba23d0e04962dd08c34fa68de276029/src/org/ddogleg/nn/alg/searches/KdTreeSearchNStandard.java#L79-L92 |
jronrun/benayn | benayn-ustyle/src/main/java/com/benayn/ustyle/string/Strs.java | Strs.after | public static Betner after(String target, String separator) {
"""
Returns a {@code String} between matcher that matches any character in the given left and ending
@param target
@param separator
@return
"""
return betn(target).after(separator);
} | java | public static Betner after(String target, String separator) {
return betn(target).after(separator);
} | [
"public",
"static",
"Betner",
"after",
"(",
"String",
"target",
",",
"String",
"separator",
")",
"{",
"return",
"betn",
"(",
"target",
")",
".",
"after",
"(",
"separator",
")",
";",
"}"
] | Returns a {@code String} between matcher that matches any character in the given left and ending
@param target
@param separator
@return | [
"Returns",
"a",
"{",
"@code",
"String",
"}",
"between",
"matcher",
"that",
"matches",
"any",
"character",
"in",
"the",
"given",
"left",
"and",
"ending"
] | train | https://github.com/jronrun/benayn/blob/7585152e10e4cac07b4274c65f1c72ad7061ae69/benayn-ustyle/src/main/java/com/benayn/ustyle/string/Strs.java#L466-L468 |
vanilladb/vanillacore | src/main/java/org/vanilladb/core/storage/tx/recovery/RecoveryMgr.java | RecoveryMgr.logSetVal | public LogSeqNum logSetVal(Buffer buff, int offset, Constant newVal) {
"""
Writes a set value record to the log.
@param buff
the buffer containing the page
@param offset
the offset of the value in the page
@param newVal
the value to be written
@return the LSN of the log record, or -1 if updates to temporary files
"""
if (enableLogging) {
BlockId blk = buff.block();
if (isTempBlock(blk))
return null;
return new SetValueRecord(txNum, blk, offset, buff.getVal(offset, newVal.getType()), newVal).writeToLog();
} else
return null;
} | java | public LogSeqNum logSetVal(Buffer buff, int offset, Constant newVal) {
if (enableLogging) {
BlockId blk = buff.block();
if (isTempBlock(blk))
return null;
return new SetValueRecord(txNum, blk, offset, buff.getVal(offset, newVal.getType()), newVal).writeToLog();
} else
return null;
} | [
"public",
"LogSeqNum",
"logSetVal",
"(",
"Buffer",
"buff",
",",
"int",
"offset",
",",
"Constant",
"newVal",
")",
"{",
"if",
"(",
"enableLogging",
")",
"{",
"BlockId",
"blk",
"=",
"buff",
".",
"block",
"(",
")",
";",
"if",
"(",
"isTempBlock",
"(",
"blk",
")",
")",
"return",
"null",
";",
"return",
"new",
"SetValueRecord",
"(",
"txNum",
",",
"blk",
",",
"offset",
",",
"buff",
".",
"getVal",
"(",
"offset",
",",
"newVal",
".",
"getType",
"(",
")",
")",
",",
"newVal",
")",
".",
"writeToLog",
"(",
")",
";",
"}",
"else",
"return",
"null",
";",
"}"
] | Writes a set value record to the log.
@param buff
the buffer containing the page
@param offset
the offset of the value in the page
@param newVal
the value to be written
@return the LSN of the log record, or -1 if updates to temporary files | [
"Writes",
"a",
"set",
"value",
"record",
"to",
"the",
"log",
"."
] | train | https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/tx/recovery/RecoveryMgr.java#L142-L150 |
navnorth/LRJavaLib | src/com/navnorth/learningregistry/LRVerify.java | LRVerify.VerifyStrings | public static boolean VerifyStrings(String signature, String message, String publicKey) throws LRException {
"""
Converts input strings to input streams for the main verify function
@param signature String of the signature
@param message String of the message
@param publicKey String of the public key
@return true if signing is verified, false if not
@throws LRException NULL_FIELD if any field is null, INPUT_STREAM_FAILED if any field cannot be converted to an input stream
"""
// Check that none of the inputs are null
if (signature == null || message == null || publicKey == null)
{
throw new LRException(LRException.NULL_FIELD);
}
// Convert all inputs into input streams
InputStream isSignature = null;
InputStream isMessage = null;
InputStream isPublicKey = null;
try
{
isSignature = new ByteArrayInputStream(signature.getBytes());
isMessage = new ByteArrayInputStream(message.getBytes());
isPublicKey = new ByteArrayInputStream(publicKey.getBytes());
}
catch (Exception e)
{
throw new LRException(LRException.INPUT_STREAM_FAILED);
}
// Feed the input streams into the primary verify function
return Verify(isSignature, isMessage, isPublicKey);
} | java | public static boolean VerifyStrings(String signature, String message, String publicKey) throws LRException
{
// Check that none of the inputs are null
if (signature == null || message == null || publicKey == null)
{
throw new LRException(LRException.NULL_FIELD);
}
// Convert all inputs into input streams
InputStream isSignature = null;
InputStream isMessage = null;
InputStream isPublicKey = null;
try
{
isSignature = new ByteArrayInputStream(signature.getBytes());
isMessage = new ByteArrayInputStream(message.getBytes());
isPublicKey = new ByteArrayInputStream(publicKey.getBytes());
}
catch (Exception e)
{
throw new LRException(LRException.INPUT_STREAM_FAILED);
}
// Feed the input streams into the primary verify function
return Verify(isSignature, isMessage, isPublicKey);
} | [
"public",
"static",
"boolean",
"VerifyStrings",
"(",
"String",
"signature",
",",
"String",
"message",
",",
"String",
"publicKey",
")",
"throws",
"LRException",
"{",
"// Check that none of the inputs are null",
"if",
"(",
"signature",
"==",
"null",
"||",
"message",
"==",
"null",
"||",
"publicKey",
"==",
"null",
")",
"{",
"throw",
"new",
"LRException",
"(",
"LRException",
".",
"NULL_FIELD",
")",
";",
"}",
"// Convert all inputs into input streams",
"InputStream",
"isSignature",
"=",
"null",
";",
"InputStream",
"isMessage",
"=",
"null",
";",
"InputStream",
"isPublicKey",
"=",
"null",
";",
"try",
"{",
"isSignature",
"=",
"new",
"ByteArrayInputStream",
"(",
"signature",
".",
"getBytes",
"(",
")",
")",
";",
"isMessage",
"=",
"new",
"ByteArrayInputStream",
"(",
"message",
".",
"getBytes",
"(",
")",
")",
";",
"isPublicKey",
"=",
"new",
"ByteArrayInputStream",
"(",
"publicKey",
".",
"getBytes",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"LRException",
"(",
"LRException",
".",
"INPUT_STREAM_FAILED",
")",
";",
"}",
"// Feed the input streams into the primary verify function",
"return",
"Verify",
"(",
"isSignature",
",",
"isMessage",
",",
"isPublicKey",
")",
";",
"}"
] | Converts input strings to input streams for the main verify function
@param signature String of the signature
@param message String of the message
@param publicKey String of the public key
@return true if signing is verified, false if not
@throws LRException NULL_FIELD if any field is null, INPUT_STREAM_FAILED if any field cannot be converted to an input stream | [
"Converts",
"input",
"strings",
"to",
"input",
"streams",
"for",
"the",
"main",
"verify",
"function"
] | train | https://github.com/navnorth/LRJavaLib/blob/27af28b9f80d772273592414e7d0dccffaac09e1/src/com/navnorth/learningregistry/LRVerify.java#L69-L95 |
hazelcast/hazelcast | hazelcast/src/main/java/com/hazelcast/cache/impl/CacheProxyUtil.java | CacheProxyUtil.validateResults | public static void validateResults(Map<Integer, Object> results) {
"""
Cache clear response validator, loop on results to validate that no exception exists on the result map.
Throws the first exception in the map.
@param results map of {@link CacheClearResponse}.
"""
for (Object result : results.values()) {
if (result != null && result instanceof CacheClearResponse) {
Object response = ((CacheClearResponse) result).getResponse();
if (response instanceof Throwable) {
ExceptionUtil.sneakyThrow((Throwable) response);
}
}
}
} | java | public static void validateResults(Map<Integer, Object> results) {
for (Object result : results.values()) {
if (result != null && result instanceof CacheClearResponse) {
Object response = ((CacheClearResponse) result).getResponse();
if (response instanceof Throwable) {
ExceptionUtil.sneakyThrow((Throwable) response);
}
}
}
} | [
"public",
"static",
"void",
"validateResults",
"(",
"Map",
"<",
"Integer",
",",
"Object",
">",
"results",
")",
"{",
"for",
"(",
"Object",
"result",
":",
"results",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"result",
"!=",
"null",
"&&",
"result",
"instanceof",
"CacheClearResponse",
")",
"{",
"Object",
"response",
"=",
"(",
"(",
"CacheClearResponse",
")",
"result",
")",
".",
"getResponse",
"(",
")",
";",
"if",
"(",
"response",
"instanceof",
"Throwable",
")",
"{",
"ExceptionUtil",
".",
"sneakyThrow",
"(",
"(",
"Throwable",
")",
"response",
")",
";",
"}",
"}",
"}",
"}"
] | Cache clear response validator, loop on results to validate that no exception exists on the result map.
Throws the first exception in the map.
@param results map of {@link CacheClearResponse}. | [
"Cache",
"clear",
"response",
"validator",
"loop",
"on",
"results",
"to",
"validate",
"that",
"no",
"exception",
"exists",
"on",
"the",
"result",
"map",
".",
"Throws",
"the",
"first",
"exception",
"in",
"the",
"map",
"."
] | train | https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cache/impl/CacheProxyUtil.java#L52-L61 |
JodaOrg/joda-time | src/main/java/org/joda/time/format/DateTimeFormatterBuilder.java | DateTimeFormatterBuilder.appendText | public DateTimeFormatterBuilder appendText(DateTimeFieldType fieldType) {
"""
Instructs the printer to emit a field value as text, and the
parser to expect text.
@param fieldType type of field to append
@return this DateTimeFormatterBuilder, for chaining
@throws IllegalArgumentException if field type is null
"""
if (fieldType == null) {
throw new IllegalArgumentException("Field type must not be null");
}
return append0(new TextField(fieldType, false));
} | java | public DateTimeFormatterBuilder appendText(DateTimeFieldType fieldType) {
if (fieldType == null) {
throw new IllegalArgumentException("Field type must not be null");
}
return append0(new TextField(fieldType, false));
} | [
"public",
"DateTimeFormatterBuilder",
"appendText",
"(",
"DateTimeFieldType",
"fieldType",
")",
"{",
"if",
"(",
"fieldType",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Field type must not be null\"",
")",
";",
"}",
"return",
"append0",
"(",
"new",
"TextField",
"(",
"fieldType",
",",
"false",
")",
")",
";",
"}"
] | Instructs the printer to emit a field value as text, and the
parser to expect text.
@param fieldType type of field to append
@return this DateTimeFormatterBuilder, for chaining
@throws IllegalArgumentException if field type is null | [
"Instructs",
"the",
"printer",
"to",
"emit",
"a",
"field",
"value",
"as",
"text",
"and",
"the",
"parser",
"to",
"expect",
"text",
"."
] | train | https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/format/DateTimeFormatterBuilder.java#L534-L539 |
Azure/azure-sdk-for-java | sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/DatabasesInner.java | DatabasesInner.listMetricDefinitions | public List<MetricDefinitionInner> listMetricDefinitions(String resourceGroupName, String serverName, String databaseName) {
"""
Returns database metric definitions.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param databaseName The name of the database.
@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 List<MetricDefinitionInner> object if successful.
"""
return listMetricDefinitionsWithServiceResponseAsync(resourceGroupName, serverName, databaseName).toBlocking().single().body();
} | java | public List<MetricDefinitionInner> listMetricDefinitions(String resourceGroupName, String serverName, String databaseName) {
return listMetricDefinitionsWithServiceResponseAsync(resourceGroupName, serverName, databaseName).toBlocking().single().body();
} | [
"public",
"List",
"<",
"MetricDefinitionInner",
">",
"listMetricDefinitions",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"String",
"databaseName",
")",
"{",
"return",
"listMetricDefinitionsWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
",",
"databaseName",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Returns database metric definitions.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param databaseName The name of the database.
@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 List<MetricDefinitionInner> object if successful. | [
"Returns",
"database",
"metric",
"definitions",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/DatabasesInner.java#L2388-L2390 |
JOML-CI/JOML | src/org/joml/Matrix4f.java | Matrix4f.scaleLocal | public Matrix4f scaleLocal(float x, float y, float z) {
"""
Pre-multiply scaling to this matrix by scaling the base axes by the given x,
y and z factors.
<p>
If <code>M</code> is <code>this</code> matrix and <code>S</code> the scaling matrix,
then the new matrix will be <code>S * M</code>. So when transforming a
vector <code>v</code> with the new matrix by using <code>S * M * v</code>, the
scaling will be applied last!
@param x
the factor of the x component
@param y
the factor of the y component
@param z
the factor of the z component
@return a matrix holding the result
"""
return scaleLocal(x, y, z, thisOrNew());
} | java | public Matrix4f scaleLocal(float x, float y, float z) {
return scaleLocal(x, y, z, thisOrNew());
} | [
"public",
"Matrix4f",
"scaleLocal",
"(",
"float",
"x",
",",
"float",
"y",
",",
"float",
"z",
")",
"{",
"return",
"scaleLocal",
"(",
"x",
",",
"y",
",",
"z",
",",
"thisOrNew",
"(",
")",
")",
";",
"}"
] | Pre-multiply scaling to this matrix by scaling the base axes by the given x,
y and z factors.
<p>
If <code>M</code> is <code>this</code> matrix and <code>S</code> the scaling matrix,
then the new matrix will be <code>S * M</code>. So when transforming a
vector <code>v</code> with the new matrix by using <code>S * M * v</code>, the
scaling will be applied last!
@param x
the factor of the x component
@param y
the factor of the y component
@param z
the factor of the z component
@return a matrix holding the result | [
"Pre",
"-",
"multiply",
"scaling",
"to",
"this",
"matrix",
"by",
"scaling",
"the",
"base",
"axes",
"by",
"the",
"given",
"x",
"y",
"and",
"z",
"factors",
".",
"<p",
">",
"If",
"<code",
">",
"M<",
"/",
"code",
">",
"is",
"<code",
">",
"this<",
"/",
"code",
">",
"matrix",
"and",
"<code",
">",
"S<",
"/",
"code",
">",
"the",
"scaling",
"matrix",
"then",
"the",
"new",
"matrix",
"will",
"be",
"<code",
">",
"S",
"*",
"M<",
"/",
"code",
">",
".",
"So",
"when",
"transforming",
"a",
"vector",
"<code",
">",
"v<",
"/",
"code",
">",
"with",
"the",
"new",
"matrix",
"by",
"using",
"<code",
">",
"S",
"*",
"M",
"*",
"v<",
"/",
"code",
">",
"the",
"scaling",
"will",
"be",
"applied",
"last!"
] | train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Matrix4f.java#L4964-L4966 |
webmetrics/browsermob-proxy | src/main/java/org/browsermob/proxy/jetty/http/handler/SetResponseHeadersHandler.java | SetResponseHeadersHandler.setHeaderValues | public void setHeaderValues(String name,String[] values) {
"""
Set a multivalued header, every response handled will have
this header set with the provided values.
@param name The String name of the header.
@param values An Array of String values to use as the values for a Header.
"""
_fields.put(name,Arrays.asList(values));
} | java | public void setHeaderValues(String name,String[] values)
{
_fields.put(name,Arrays.asList(values));
} | [
"public",
"void",
"setHeaderValues",
"(",
"String",
"name",
",",
"String",
"[",
"]",
"values",
")",
"{",
"_fields",
".",
"put",
"(",
"name",
",",
"Arrays",
".",
"asList",
"(",
"values",
")",
")",
";",
"}"
] | Set a multivalued header, every response handled will have
this header set with the provided values.
@param name The String name of the header.
@param values An Array of String values to use as the values for a Header. | [
"Set",
"a",
"multivalued",
"header",
"every",
"response",
"handled",
"will",
"have",
"this",
"header",
"set",
"with",
"the",
"provided",
"values",
"."
] | train | https://github.com/webmetrics/browsermob-proxy/blob/a9252e62246ac33d55d51b993ba1159404e7d389/src/main/java/org/browsermob/proxy/jetty/http/handler/SetResponseHeadersHandler.java#L62-L65 |
apache/flink | flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/util/SegmentsUtil.java | SegmentsUtil.setChar | public static void setChar(MemorySegment[] segments, int offset, char value) {
"""
set char from segments.
@param segments target segments.
@param offset value offset.
"""
if (inFirstSegment(segments, offset, 2)) {
segments[0].putChar(offset, value);
} else {
setCharMultiSegments(segments, offset, value);
}
} | java | public static void setChar(MemorySegment[] segments, int offset, char value) {
if (inFirstSegment(segments, offset, 2)) {
segments[0].putChar(offset, value);
} else {
setCharMultiSegments(segments, offset, value);
}
} | [
"public",
"static",
"void",
"setChar",
"(",
"MemorySegment",
"[",
"]",
"segments",
",",
"int",
"offset",
",",
"char",
"value",
")",
"{",
"if",
"(",
"inFirstSegment",
"(",
"segments",
",",
"offset",
",",
"2",
")",
")",
"{",
"segments",
"[",
"0",
"]",
".",
"putChar",
"(",
"offset",
",",
"value",
")",
";",
"}",
"else",
"{",
"setCharMultiSegments",
"(",
"segments",
",",
"offset",
",",
"value",
")",
";",
"}",
"}"
] | set char from segments.
@param segments target segments.
@param offset value offset. | [
"set",
"char",
"from",
"segments",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/util/SegmentsUtil.java#L1002-L1008 |
facebook/fresco | imagepipeline/src/main/java/com/facebook/imagepipeline/nativecode/Bitmaps.java | Bitmaps.copyBitmap | public static void copyBitmap(Bitmap dest, Bitmap src) {
"""
This blits the pixel data from src to dest.
<p>The destination bitmap must have both a height and a width equal to the source. For maximum
speed stride should be equal as well.
<p>Both bitmaps must use the same {@link android.graphics.Bitmap.Config} format.
<p>If the src is purgeable, it will be decoded as part of this operation if it was purged.
The dest should not be purgeable. If it is, the copy will still take place,
but will be lost the next time the dest gets purged, without warning.
<p>The dest must be mutable.
@param dest Bitmap to copy into
@param src Bitmap to copy out of
"""
Preconditions.checkArgument(src.getConfig() == dest.getConfig());
Preconditions.checkArgument(dest.isMutable());
Preconditions.checkArgument(dest.getWidth() == src.getWidth());
Preconditions.checkArgument(dest.getHeight() == src.getHeight());
nativeCopyBitmap(
dest,
dest.getRowBytes(),
src,
src.getRowBytes(),
dest.getHeight());
} | java | public static void copyBitmap(Bitmap dest, Bitmap src) {
Preconditions.checkArgument(src.getConfig() == dest.getConfig());
Preconditions.checkArgument(dest.isMutable());
Preconditions.checkArgument(dest.getWidth() == src.getWidth());
Preconditions.checkArgument(dest.getHeight() == src.getHeight());
nativeCopyBitmap(
dest,
dest.getRowBytes(),
src,
src.getRowBytes(),
dest.getHeight());
} | [
"public",
"static",
"void",
"copyBitmap",
"(",
"Bitmap",
"dest",
",",
"Bitmap",
"src",
")",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"src",
".",
"getConfig",
"(",
")",
"==",
"dest",
".",
"getConfig",
"(",
")",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"dest",
".",
"isMutable",
"(",
")",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"dest",
".",
"getWidth",
"(",
")",
"==",
"src",
".",
"getWidth",
"(",
")",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"dest",
".",
"getHeight",
"(",
")",
"==",
"src",
".",
"getHeight",
"(",
")",
")",
";",
"nativeCopyBitmap",
"(",
"dest",
",",
"dest",
".",
"getRowBytes",
"(",
")",
",",
"src",
",",
"src",
".",
"getRowBytes",
"(",
")",
",",
"dest",
".",
"getHeight",
"(",
")",
")",
";",
"}"
] | This blits the pixel data from src to dest.
<p>The destination bitmap must have both a height and a width equal to the source. For maximum
speed stride should be equal as well.
<p>Both bitmaps must use the same {@link android.graphics.Bitmap.Config} format.
<p>If the src is purgeable, it will be decoded as part of this operation if it was purged.
The dest should not be purgeable. If it is, the copy will still take place,
but will be lost the next time the dest gets purged, without warning.
<p>The dest must be mutable.
@param dest Bitmap to copy into
@param src Bitmap to copy out of | [
"This",
"blits",
"the",
"pixel",
"data",
"from",
"src",
"to",
"dest",
".",
"<p",
">",
"The",
"destination",
"bitmap",
"must",
"have",
"both",
"a",
"height",
"and",
"a",
"width",
"equal",
"to",
"the",
"source",
".",
"For",
"maximum",
"speed",
"stride",
"should",
"be",
"equal",
"as",
"well",
".",
"<p",
">",
"Both",
"bitmaps",
"must",
"use",
"the",
"same",
"{"
] | train | https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline/src/main/java/com/facebook/imagepipeline/nativecode/Bitmaps.java#L39-L50 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/vision/customvision/training/src/main/java/com/microsoft/azure/cognitiveservices/vision/customvision/training/implementation/TrainingsImpl.java | TrainingsImpl.getUntaggedImagesWithServiceResponseAsync | public Observable<ServiceResponse<List<Image>>> getUntaggedImagesWithServiceResponseAsync(UUID projectId, GetUntaggedImagesOptionalParameter getUntaggedImagesOptionalParameter) {
"""
Get untagged images for a given project iteration.
This API supports batching and range selection. By default it will only return first 50 images matching images.
Use the {take} and {skip} parameters to control how many images to return in a given batch.
@param projectId The project id
@param getUntaggedImagesOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<Image> object
"""
if (projectId == null) {
throw new IllegalArgumentException("Parameter projectId is required and cannot be null.");
}
if (this.client.apiKey() == null) {
throw new IllegalArgumentException("Parameter this.client.apiKey() is required and cannot be null.");
}
final UUID iterationId = getUntaggedImagesOptionalParameter != null ? getUntaggedImagesOptionalParameter.iterationId() : null;
final String orderBy = getUntaggedImagesOptionalParameter != null ? getUntaggedImagesOptionalParameter.orderBy() : null;
final Integer take = getUntaggedImagesOptionalParameter != null ? getUntaggedImagesOptionalParameter.take() : null;
final Integer skip = getUntaggedImagesOptionalParameter != null ? getUntaggedImagesOptionalParameter.skip() : null;
return getUntaggedImagesWithServiceResponseAsync(projectId, iterationId, orderBy, take, skip);
} | java | public Observable<ServiceResponse<List<Image>>> getUntaggedImagesWithServiceResponseAsync(UUID projectId, GetUntaggedImagesOptionalParameter getUntaggedImagesOptionalParameter) {
if (projectId == null) {
throw new IllegalArgumentException("Parameter projectId is required and cannot be null.");
}
if (this.client.apiKey() == null) {
throw new IllegalArgumentException("Parameter this.client.apiKey() is required and cannot be null.");
}
final UUID iterationId = getUntaggedImagesOptionalParameter != null ? getUntaggedImagesOptionalParameter.iterationId() : null;
final String orderBy = getUntaggedImagesOptionalParameter != null ? getUntaggedImagesOptionalParameter.orderBy() : null;
final Integer take = getUntaggedImagesOptionalParameter != null ? getUntaggedImagesOptionalParameter.take() : null;
final Integer skip = getUntaggedImagesOptionalParameter != null ? getUntaggedImagesOptionalParameter.skip() : null;
return getUntaggedImagesWithServiceResponseAsync(projectId, iterationId, orderBy, take, skip);
} | [
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"List",
"<",
"Image",
">",
">",
">",
"getUntaggedImagesWithServiceResponseAsync",
"(",
"UUID",
"projectId",
",",
"GetUntaggedImagesOptionalParameter",
"getUntaggedImagesOptionalParameter",
")",
"{",
"if",
"(",
"projectId",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter projectId is required and cannot be null.\"",
")",
";",
"}",
"if",
"(",
"this",
".",
"client",
".",
"apiKey",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter this.client.apiKey() is required and cannot be null.\"",
")",
";",
"}",
"final",
"UUID",
"iterationId",
"=",
"getUntaggedImagesOptionalParameter",
"!=",
"null",
"?",
"getUntaggedImagesOptionalParameter",
".",
"iterationId",
"(",
")",
":",
"null",
";",
"final",
"String",
"orderBy",
"=",
"getUntaggedImagesOptionalParameter",
"!=",
"null",
"?",
"getUntaggedImagesOptionalParameter",
".",
"orderBy",
"(",
")",
":",
"null",
";",
"final",
"Integer",
"take",
"=",
"getUntaggedImagesOptionalParameter",
"!=",
"null",
"?",
"getUntaggedImagesOptionalParameter",
".",
"take",
"(",
")",
":",
"null",
";",
"final",
"Integer",
"skip",
"=",
"getUntaggedImagesOptionalParameter",
"!=",
"null",
"?",
"getUntaggedImagesOptionalParameter",
".",
"skip",
"(",
")",
":",
"null",
";",
"return",
"getUntaggedImagesWithServiceResponseAsync",
"(",
"projectId",
",",
"iterationId",
",",
"orderBy",
",",
"take",
",",
"skip",
")",
";",
"}"
] | Get untagged images for a given project iteration.
This API supports batching and range selection. By default it will only return first 50 images matching images.
Use the {take} and {skip} parameters to control how many images to return in a given batch.
@param projectId The project id
@param getUntaggedImagesOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<Image> object | [
"Get",
"untagged",
"images",
"for",
"a",
"given",
"project",
"iteration",
".",
"This",
"API",
"supports",
"batching",
"and",
"range",
"selection",
".",
"By",
"default",
"it",
"will",
"only",
"return",
"first",
"50",
"images",
"matching",
"images",
".",
"Use",
"the",
"{",
"take",
"}",
"and",
"{",
"skip",
"}",
"parameters",
"to",
"control",
"how",
"many",
"images",
"to",
"return",
"in",
"a",
"given",
"batch",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/vision/customvision/training/src/main/java/com/microsoft/azure/cognitiveservices/vision/customvision/training/implementation/TrainingsImpl.java#L4833-L4846 |
atbashEE/atbash-config | geronimo-config/src/main/java/org/apache/geronimo/config/cdi/ConfigInjectionBean.java | ConfigInjectionBean.getConfigKey | static String getConfigKey(InjectionPoint ip, ConfigProperty configProperty) {
"""
Get the property key to use.
In case the {@link ConfigProperty#name()} is empty we will try to determine the key name from the InjectionPoint.
"""
String key = configProperty.name();
if (key.length() > 0) {
return key;
}
if (ip.getAnnotated() instanceof AnnotatedMember) {
AnnotatedMember member = (AnnotatedMember) ip.getAnnotated();
AnnotatedType declaringType = member.getDeclaringType();
if (declaringType != null) {
return declaringType.getJavaClass().getCanonicalName() + "." + member.getJavaMember().getName();
}
}
throw new IllegalStateException("Could not find default name for @ConfigProperty InjectionPoint " + ip);
} | java | static String getConfigKey(InjectionPoint ip, ConfigProperty configProperty) {
String key = configProperty.name();
if (key.length() > 0) {
return key;
}
if (ip.getAnnotated() instanceof AnnotatedMember) {
AnnotatedMember member = (AnnotatedMember) ip.getAnnotated();
AnnotatedType declaringType = member.getDeclaringType();
if (declaringType != null) {
return declaringType.getJavaClass().getCanonicalName() + "." + member.getJavaMember().getName();
}
}
throw new IllegalStateException("Could not find default name for @ConfigProperty InjectionPoint " + ip);
} | [
"static",
"String",
"getConfigKey",
"(",
"InjectionPoint",
"ip",
",",
"ConfigProperty",
"configProperty",
")",
"{",
"String",
"key",
"=",
"configProperty",
".",
"name",
"(",
")",
";",
"if",
"(",
"key",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"return",
"key",
";",
"}",
"if",
"(",
"ip",
".",
"getAnnotated",
"(",
")",
"instanceof",
"AnnotatedMember",
")",
"{",
"AnnotatedMember",
"member",
"=",
"(",
"AnnotatedMember",
")",
"ip",
".",
"getAnnotated",
"(",
")",
";",
"AnnotatedType",
"declaringType",
"=",
"member",
".",
"getDeclaringType",
"(",
")",
";",
"if",
"(",
"declaringType",
"!=",
"null",
")",
"{",
"return",
"declaringType",
".",
"getJavaClass",
"(",
")",
".",
"getCanonicalName",
"(",
")",
"+",
"\".\"",
"+",
"member",
".",
"getJavaMember",
"(",
")",
".",
"getName",
"(",
")",
";",
"}",
"}",
"throw",
"new",
"IllegalStateException",
"(",
"\"Could not find default name for @ConfigProperty InjectionPoint \"",
"+",
"ip",
")",
";",
"}"
] | Get the property key to use.
In case the {@link ConfigProperty#name()} is empty we will try to determine the key name from the InjectionPoint. | [
"Get",
"the",
"property",
"key",
"to",
"use",
".",
"In",
"case",
"the",
"{"
] | train | https://github.com/atbashEE/atbash-config/blob/80c06c6e535957514ffb51380948ecd351d5068c/geronimo-config/src/main/java/org/apache/geronimo/config/cdi/ConfigInjectionBean.java#L170-L184 |
artikcloud/artikcloud-java | src/main/java/cloud/artik/api/DevicesStatusApi.java | DevicesStatusApi.getDeviceStatusAsync | public com.squareup.okhttp.Call getDeviceStatusAsync(String deviceId, Boolean includeSnapshot, Boolean includeSnapshotTimestamp, final ApiCallback<DeviceStatus> callback) throws ApiException {
"""
Get Device Status (asynchronously)
Get Device Status
@param deviceId Device ID. (required)
@param includeSnapshot Include device snapshot into the response (optional)
@param includeSnapshotTimestamp Include device snapshot timestamp into the response (optional)
@param callback The callback to be executed when the API call finishes
@return The request call
@throws ApiException If fail to process the API call, e.g. serializing the request body object
"""
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
callback.onDownloadProgress(bytesRead, contentLength, done);
}
};
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
@Override
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
callback.onUploadProgress(bytesWritten, contentLength, done);
}
};
}
com.squareup.okhttp.Call call = getDeviceStatusValidateBeforeCall(deviceId, includeSnapshot, includeSnapshotTimestamp, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken<DeviceStatus>(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
} | java | public com.squareup.okhttp.Call getDeviceStatusAsync(String deviceId, Boolean includeSnapshot, Boolean includeSnapshotTimestamp, final ApiCallback<DeviceStatus> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
callback.onDownloadProgress(bytesRead, contentLength, done);
}
};
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
@Override
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
callback.onUploadProgress(bytesWritten, contentLength, done);
}
};
}
com.squareup.okhttp.Call call = getDeviceStatusValidateBeforeCall(deviceId, includeSnapshot, includeSnapshotTimestamp, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken<DeviceStatus>(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
} | [
"public",
"com",
".",
"squareup",
".",
"okhttp",
".",
"Call",
"getDeviceStatusAsync",
"(",
"String",
"deviceId",
",",
"Boolean",
"includeSnapshot",
",",
"Boolean",
"includeSnapshotTimestamp",
",",
"final",
"ApiCallback",
"<",
"DeviceStatus",
">",
"callback",
")",
"throws",
"ApiException",
"{",
"ProgressResponseBody",
".",
"ProgressListener",
"progressListener",
"=",
"null",
";",
"ProgressRequestBody",
".",
"ProgressRequestListener",
"progressRequestListener",
"=",
"null",
";",
"if",
"(",
"callback",
"!=",
"null",
")",
"{",
"progressListener",
"=",
"new",
"ProgressResponseBody",
".",
"ProgressListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"update",
"(",
"long",
"bytesRead",
",",
"long",
"contentLength",
",",
"boolean",
"done",
")",
"{",
"callback",
".",
"onDownloadProgress",
"(",
"bytesRead",
",",
"contentLength",
",",
"done",
")",
";",
"}",
"}",
";",
"progressRequestListener",
"=",
"new",
"ProgressRequestBody",
".",
"ProgressRequestListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onRequestProgress",
"(",
"long",
"bytesWritten",
",",
"long",
"contentLength",
",",
"boolean",
"done",
")",
"{",
"callback",
".",
"onUploadProgress",
"(",
"bytesWritten",
",",
"contentLength",
",",
"done",
")",
";",
"}",
"}",
";",
"}",
"com",
".",
"squareup",
".",
"okhttp",
".",
"Call",
"call",
"=",
"getDeviceStatusValidateBeforeCall",
"(",
"deviceId",
",",
"includeSnapshot",
",",
"includeSnapshotTimestamp",
",",
"progressListener",
",",
"progressRequestListener",
")",
";",
"Type",
"localVarReturnType",
"=",
"new",
"TypeToken",
"<",
"DeviceStatus",
">",
"(",
")",
"{",
"}",
".",
"getType",
"(",
")",
";",
"apiClient",
".",
"executeAsync",
"(",
"call",
",",
"localVarReturnType",
",",
"callback",
")",
";",
"return",
"call",
";",
"}"
] | Get Device Status (asynchronously)
Get Device Status
@param deviceId Device ID. (required)
@param includeSnapshot Include device snapshot into the response (optional)
@param includeSnapshotTimestamp Include device snapshot timestamp into the response (optional)
@param callback The callback to be executed when the API call finishes
@return The request call
@throws ApiException If fail to process the API call, e.g. serializing the request body object | [
"Get",
"Device",
"Status",
"(",
"asynchronously",
")",
"Get",
"Device",
"Status"
] | train | https://github.com/artikcloud/artikcloud-java/blob/412f447573e7796ab4f685c0bdd5eb76185a365c/src/main/java/cloud/artik/api/DevicesStatusApi.java#L162-L187 |
milaboratory/milib | src/main/java/com/milaboratory/core/alignment/AlignmentTrimmer.java | AlignmentTrimmer.rightTrimAlignment | public static <S extends Sequence<S>> Alignment<S> rightTrimAlignment(Alignment<S> alignment,
AlignmentScoring<S> scoring) {
"""
Try increase total alignment score by partially (or fully) trimming it from right side. If score can't be
increased the same alignment will be returned.
@param alignment input alignment
@param scoring scoring
@return resulting alignment
"""
if (scoring instanceof LinearGapAlignmentScoring)
return rightTrimAlignment(alignment, (LinearGapAlignmentScoring<S>) scoring);
else if (scoring instanceof AffineGapAlignmentScoring)
return rightTrimAlignment(alignment, (AffineGapAlignmentScoring<S>) scoring);
else
throw new IllegalArgumentException("Unknown scoring type");
} | java | public static <S extends Sequence<S>> Alignment<S> rightTrimAlignment(Alignment<S> alignment,
AlignmentScoring<S> scoring) {
if (scoring instanceof LinearGapAlignmentScoring)
return rightTrimAlignment(alignment, (LinearGapAlignmentScoring<S>) scoring);
else if (scoring instanceof AffineGapAlignmentScoring)
return rightTrimAlignment(alignment, (AffineGapAlignmentScoring<S>) scoring);
else
throw new IllegalArgumentException("Unknown scoring type");
} | [
"public",
"static",
"<",
"S",
"extends",
"Sequence",
"<",
"S",
">",
">",
"Alignment",
"<",
"S",
">",
"rightTrimAlignment",
"(",
"Alignment",
"<",
"S",
">",
"alignment",
",",
"AlignmentScoring",
"<",
"S",
">",
"scoring",
")",
"{",
"if",
"(",
"scoring",
"instanceof",
"LinearGapAlignmentScoring",
")",
"return",
"rightTrimAlignment",
"(",
"alignment",
",",
"(",
"LinearGapAlignmentScoring",
"<",
"S",
">",
")",
"scoring",
")",
";",
"else",
"if",
"(",
"scoring",
"instanceof",
"AffineGapAlignmentScoring",
")",
"return",
"rightTrimAlignment",
"(",
"alignment",
",",
"(",
"AffineGapAlignmentScoring",
"<",
"S",
">",
")",
"scoring",
")",
";",
"else",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unknown scoring type\"",
")",
";",
"}"
] | Try increase total alignment score by partially (or fully) trimming it from right side. If score can't be
increased the same alignment will be returned.
@param alignment input alignment
@param scoring scoring
@return resulting alignment | [
"Try",
"increase",
"total",
"alignment",
"score",
"by",
"partially",
"(",
"or",
"fully",
")",
"trimming",
"it",
"from",
"right",
"side",
".",
"If",
"score",
"can",
"t",
"be",
"increased",
"the",
"same",
"alignment",
"will",
"be",
"returned",
"."
] | train | https://github.com/milaboratory/milib/blob/2349b3dccdd3c7948643760e570238d6e30d5a34/src/main/java/com/milaboratory/core/alignment/AlignmentTrimmer.java#L178-L186 |
jnidzwetzki/bitfinex-v2-wss-api-java | src/main/java/com/github/jnidzwetzki/bitfinex/v2/BitfinexApiCallbackListeners.java | BitfinexApiCallbackListeners.onMyWalletEvent | public Closeable onMyWalletEvent(final BiConsumer<BitfinexAccountSymbol,Collection<BitfinexWallet>> listener) {
"""
registers listener for user account related events - wallet change events
@param listener of event
@return hook of this listener
"""
walletConsumers.offer(listener);
return () -> walletConsumers.remove(listener);
} | java | public Closeable onMyWalletEvent(final BiConsumer<BitfinexAccountSymbol,Collection<BitfinexWallet>> listener) {
walletConsumers.offer(listener);
return () -> walletConsumers.remove(listener);
} | [
"public",
"Closeable",
"onMyWalletEvent",
"(",
"final",
"BiConsumer",
"<",
"BitfinexAccountSymbol",
",",
"Collection",
"<",
"BitfinexWallet",
">",
">",
"listener",
")",
"{",
"walletConsumers",
".",
"offer",
"(",
"listener",
")",
";",
"return",
"(",
")",
"->",
"walletConsumers",
".",
"remove",
"(",
"listener",
")",
";",
"}"
] | registers listener for user account related events - wallet change events
@param listener of event
@return hook of this listener | [
"registers",
"listener",
"for",
"user",
"account",
"related",
"events",
"-",
"wallet",
"change",
"events"
] | train | https://github.com/jnidzwetzki/bitfinex-v2-wss-api-java/blob/2e6adf1eb6f8cd4c8722f1619f78ab2cc3c600ee/src/main/java/com/github/jnidzwetzki/bitfinex/v2/BitfinexApiCallbackListeners.java#L138-L141 |
camunda/camunda-commons | typed-values/src/main/java/org/camunda/bpm/engine/variable/Variables.java | Variables.untypedValue | public static TypedValue untypedValue(Object value) {
"""
Creates an untyped value, i.e. {@link TypedValue#getType()} returns <code>null</code>
for the returned instance.
"""
if (value instanceof TypedValue) {
return untypedValue(value, ((TypedValue) value).isTransient());
}
else return untypedValue(value, false);
} | java | public static TypedValue untypedValue(Object value) {
if (value instanceof TypedValue) {
return untypedValue(value, ((TypedValue) value).isTransient());
}
else return untypedValue(value, false);
} | [
"public",
"static",
"TypedValue",
"untypedValue",
"(",
"Object",
"value",
")",
"{",
"if",
"(",
"value",
"instanceof",
"TypedValue",
")",
"{",
"return",
"untypedValue",
"(",
"value",
",",
"(",
"(",
"TypedValue",
")",
"value",
")",
".",
"isTransient",
"(",
")",
")",
";",
"}",
"else",
"return",
"untypedValue",
"(",
"value",
",",
"false",
")",
";",
"}"
] | Creates an untyped value, i.e. {@link TypedValue#getType()} returns <code>null</code>
for the returned instance. | [
"Creates",
"an",
"untyped",
"value",
"i",
".",
"e",
".",
"{"
] | train | https://github.com/camunda/camunda-commons/blob/bd3195db47c92c25717288fe9e6735f8e882f247/typed-values/src/main/java/org/camunda/bpm/engine/variable/Variables.java#L362-L367 |
DiUS/pact-jvm | pact-jvm-consumer/src/main/java/au/com/dius/pact/consumer/dsl/PactDslJsonArray.java | PactDslJsonArray.eachLike | public PactDslJsonArray eachLike(PactDslJsonRootValue value, int numberExamples) {
"""
Array of values that are not objects where each item must match the provided example
@param value Value to use to match each item
@param numberExamples number of examples to generate
"""
if (numberExamples == 0) {
throw new IllegalArgumentException("Testing Zero examples is unsafe. Please make sure to provide at least one " +
"example in the Pact provider implementation. See https://github.com/DiUS/pact-jvm/issues/546");
}
matchers.addRule(rootPath + appendArrayIndex(1), matchMin(0));
PactDslJsonArray parent = new PactDslJsonArray(rootPath, "", this, true);
parent.setNumberExamples(numberExamples);
parent.putObject(value);
return (PactDslJsonArray) parent.closeArray();
} | java | public PactDslJsonArray eachLike(PactDslJsonRootValue value, int numberExamples) {
if (numberExamples == 0) {
throw new IllegalArgumentException("Testing Zero examples is unsafe. Please make sure to provide at least one " +
"example in the Pact provider implementation. See https://github.com/DiUS/pact-jvm/issues/546");
}
matchers.addRule(rootPath + appendArrayIndex(1), matchMin(0));
PactDslJsonArray parent = new PactDslJsonArray(rootPath, "", this, true);
parent.setNumberExamples(numberExamples);
parent.putObject(value);
return (PactDslJsonArray) parent.closeArray();
} | [
"public",
"PactDslJsonArray",
"eachLike",
"(",
"PactDslJsonRootValue",
"value",
",",
"int",
"numberExamples",
")",
"{",
"if",
"(",
"numberExamples",
"==",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Testing Zero examples is unsafe. Please make sure to provide at least one \"",
"+",
"\"example in the Pact provider implementation. See https://github.com/DiUS/pact-jvm/issues/546\"",
")",
";",
"}",
"matchers",
".",
"addRule",
"(",
"rootPath",
"+",
"appendArrayIndex",
"(",
"1",
")",
",",
"matchMin",
"(",
"0",
")",
")",
";",
"PactDslJsonArray",
"parent",
"=",
"new",
"PactDslJsonArray",
"(",
"rootPath",
",",
"\"\"",
",",
"this",
",",
"true",
")",
";",
"parent",
".",
"setNumberExamples",
"(",
"numberExamples",
")",
";",
"parent",
".",
"putObject",
"(",
"value",
")",
";",
"return",
"(",
"PactDslJsonArray",
")",
"parent",
".",
"closeArray",
"(",
")",
";",
"}"
] | Array of values that are not objects where each item must match the provided example
@param value Value to use to match each item
@param numberExamples number of examples to generate | [
"Array",
"of",
"values",
"that",
"are",
"not",
"objects",
"where",
"each",
"item",
"must",
"match",
"the",
"provided",
"example"
] | train | https://github.com/DiUS/pact-jvm/blob/2f447e9dd4ac152a6a36b7fcf8962d07de9ef3ef/pact-jvm-consumer/src/main/java/au/com/dius/pact/consumer/dsl/PactDslJsonArray.java#L1034-L1045 |
azkaban/azkaban | azkaban-common/src/main/java/azkaban/executor/ExecutionFlowDao.java | ExecutionFlowDao.fetchFlowHistory | public List<ExecutableFlow> fetchFlowHistory(final int projectId, final String flowId, final
long startTime) throws ExecutorManagerException {
"""
fetch flow execution history with specified {@code projectId}, {@code flowId} and flow start
time >= {@code startTime}
@return the list of flows meeting the specified criteria
"""
try {
return this.dbOperator.query(FetchExecutableFlows.FETCH_EXECUTABLE_FLOW_BY_START_TIME,
new FetchExecutableFlows(), projectId, flowId, startTime);
} catch (final SQLException e) {
throw new ExecutorManagerException("Error fetching historic flows", e);
}
} | java | public List<ExecutableFlow> fetchFlowHistory(final int projectId, final String flowId, final
long startTime) throws ExecutorManagerException {
try {
return this.dbOperator.query(FetchExecutableFlows.FETCH_EXECUTABLE_FLOW_BY_START_TIME,
new FetchExecutableFlows(), projectId, flowId, startTime);
} catch (final SQLException e) {
throw new ExecutorManagerException("Error fetching historic flows", e);
}
} | [
"public",
"List",
"<",
"ExecutableFlow",
">",
"fetchFlowHistory",
"(",
"final",
"int",
"projectId",
",",
"final",
"String",
"flowId",
",",
"final",
"long",
"startTime",
")",
"throws",
"ExecutorManagerException",
"{",
"try",
"{",
"return",
"this",
".",
"dbOperator",
".",
"query",
"(",
"FetchExecutableFlows",
".",
"FETCH_EXECUTABLE_FLOW_BY_START_TIME",
",",
"new",
"FetchExecutableFlows",
"(",
")",
",",
"projectId",
",",
"flowId",
",",
"startTime",
")",
";",
"}",
"catch",
"(",
"final",
"SQLException",
"e",
")",
"{",
"throw",
"new",
"ExecutorManagerException",
"(",
"\"Error fetching historic flows\"",
",",
"e",
")",
";",
"}",
"}"
] | fetch flow execution history with specified {@code projectId}, {@code flowId} and flow start
time >= {@code startTime}
@return the list of flows meeting the specified criteria | [
"fetch",
"flow",
"execution",
"history",
"with",
"specified",
"{",
"@code",
"projectId",
"}",
"{",
"@code",
"flowId",
"}",
"and",
"flow",
"start",
"time",
">",
"=",
"{",
"@code",
"startTime",
"}"
] | train | https://github.com/azkaban/azkaban/blob/d258ea7d6e66807c6eff79c5325d6d3443618dff/azkaban-common/src/main/java/azkaban/executor/ExecutionFlowDao.java#L127-L135 |
schallee/alib4j | jvm/src/main/java/net/darkmist/alib/jvm/JVMLauncher.java | JVMLauncher.getProcess | @Deprecated
public static Process getProcess(String mainClass, String... args) throws LauncherException, IOException {
"""
Get a process for a JVM. The class path for the JVM is computed
based on the class loaders for the main class.
@param mainClass Fully qualified class name of the main class
@param args Additional command line parameters
@return ProcessBuilder that has not been started.
@deprecated This acquires the mainClass class by using the
{@link Thread#getContextClassLoader() thread context class loader}
or this class's class loader. Depending on where mainClass
was loaded from neither of these may work.
@see #getProcessBuilder(Class, String[])
"""
return getProcessBuilder(mainClass, args).start();
} | java | @Deprecated
public static Process getProcess(String mainClass, String... args) throws LauncherException, IOException
{
return getProcessBuilder(mainClass, args).start();
} | [
"@",
"Deprecated",
"public",
"static",
"Process",
"getProcess",
"(",
"String",
"mainClass",
",",
"String",
"...",
"args",
")",
"throws",
"LauncherException",
",",
"IOException",
"{",
"return",
"getProcessBuilder",
"(",
"mainClass",
",",
"args",
")",
".",
"start",
"(",
")",
";",
"}"
] | Get a process for a JVM. The class path for the JVM is computed
based on the class loaders for the main class.
@param mainClass Fully qualified class name of the main class
@param args Additional command line parameters
@return ProcessBuilder that has not been started.
@deprecated This acquires the mainClass class by using the
{@link Thread#getContextClassLoader() thread context class loader}
or this class's class loader. Depending on where mainClass
was loaded from neither of these may work.
@see #getProcessBuilder(Class, String[]) | [
"Get",
"a",
"process",
"for",
"a",
"JVM",
".",
"The",
"class",
"path",
"for",
"the",
"JVM",
"is",
"computed",
"based",
"on",
"the",
"class",
"loaders",
"for",
"the",
"main",
"class",
"."
] | train | https://github.com/schallee/alib4j/blob/0e0718aee574bbb62268e1cf58e99286529ce529/jvm/src/main/java/net/darkmist/alib/jvm/JVMLauncher.java#L252-L256 |
UrielCh/ovh-java-sdk | ovh-java-sdk-price/src/main/java/net/minidev/ovh/api/ApiOvhPrice.java | ApiOvhPrice.xdsl_options_ipv4_ipRange_GET | public OvhPrice xdsl_options_ipv4_ipRange_GET(net.minidev.ovh.api.price.xdsl.options.OvhIpv4Enum ipRange) throws IOException {
"""
Get the price of IPv4 options
REST: GET /price/xdsl/options/ipv4/{ipRange}
@param ipRange [required] The range of the IPv4
"""
String qPath = "/price/xdsl/options/ipv4/{ipRange}";
StringBuilder sb = path(qPath, ipRange);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhPrice.class);
} | java | public OvhPrice xdsl_options_ipv4_ipRange_GET(net.minidev.ovh.api.price.xdsl.options.OvhIpv4Enum ipRange) throws IOException {
String qPath = "/price/xdsl/options/ipv4/{ipRange}";
StringBuilder sb = path(qPath, ipRange);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhPrice.class);
} | [
"public",
"OvhPrice",
"xdsl_options_ipv4_ipRange_GET",
"(",
"net",
".",
"minidev",
".",
"ovh",
".",
"api",
".",
"price",
".",
"xdsl",
".",
"options",
".",
"OvhIpv4Enum",
"ipRange",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/price/xdsl/options/ipv4/{ipRange}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"ipRange",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhPrice",
".",
"class",
")",
";",
"}"
] | Get the price of IPv4 options
REST: GET /price/xdsl/options/ipv4/{ipRange}
@param ipRange [required] The range of the IPv4 | [
"Get",
"the",
"price",
"of",
"IPv4",
"options"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-price/src/main/java/net/minidev/ovh/api/ApiOvhPrice.java#L50-L55 |
op4j/op4j-jodatime | src/main/java/org/op4j/jodatime/functions/FnInterval.java | FnInterval.strFieldArrayToInterval | public static final Function<String[], Interval> strFieldArrayToInterval(String pattern, DateTimeZone dateTimeZone) {
"""
<p>
It converts the input {@link String} elements into an {@link Interval}.
The target {@link String} elements represent the start and end of the {@link Interval}.
</p>
<p>
The accepted input String[] are:
</p>
<ul>
<li>year, month, day, year, month, day</li>
<li>year, month, day, hour, minute, year, month, day, hour, minute</li>
<li>year, month, day, hour, minute, second, year, month, day, hour, minute, second</li>
<li>year, month, day, hour, minute, second, millisecond, year, month, day, hour, minute, second, millisecond</li>
</ul>
@param pattern string with the format of the input String
@param dateTimeZone the the time zone ({@link DateTimeZone}) to be used
@return the {@link Interval} created from the input and arguments
"""
return new StringFieldArrayToInterval(pattern, dateTimeZone);
} | java | public static final Function<String[], Interval> strFieldArrayToInterval(String pattern, DateTimeZone dateTimeZone) {
return new StringFieldArrayToInterval(pattern, dateTimeZone);
} | [
"public",
"static",
"final",
"Function",
"<",
"String",
"[",
"]",
",",
"Interval",
">",
"strFieldArrayToInterval",
"(",
"String",
"pattern",
",",
"DateTimeZone",
"dateTimeZone",
")",
"{",
"return",
"new",
"StringFieldArrayToInterval",
"(",
"pattern",
",",
"dateTimeZone",
")",
";",
"}"
] | <p>
It converts the input {@link String} elements into an {@link Interval}.
The target {@link String} elements represent the start and end of the {@link Interval}.
</p>
<p>
The accepted input String[] are:
</p>
<ul>
<li>year, month, day, year, month, day</li>
<li>year, month, day, hour, minute, year, month, day, hour, minute</li>
<li>year, month, day, hour, minute, second, year, month, day, hour, minute, second</li>
<li>year, month, day, hour, minute, second, millisecond, year, month, day, hour, minute, second, millisecond</li>
</ul>
@param pattern string with the format of the input String
@param dateTimeZone the the time zone ({@link DateTimeZone}) to be used
@return the {@link Interval} created from the input and arguments | [
"<p",
">",
"It",
"converts",
"the",
"input",
"{",
"@link",
"String",
"}",
"elements",
"into",
"an",
"{",
"@link",
"Interval",
"}",
".",
"The",
"target",
"{",
"@link",
"String",
"}",
"elements",
"represent",
"the",
"start",
"and",
"end",
"of",
"the",
"{",
"@link",
"Interval",
"}",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/op4j/op4j-jodatime/blob/26e5b8cda8553fb3b5a4a64b3109dbbf5df21194/src/main/java/org/op4j/jodatime/functions/FnInterval.java#L376-L378 |
JoeKerouac/utils | src/main/java/com/joe/utils/common/DateUtil.java | DateUtil.isToday | public static boolean isToday(String date, String format) {
"""
查询时间是否在今日
@param date 时间字符串
@param format 时间字符串的格式
@return 如果指定日期对象在今天则返回<code>true</code>
"""
String now = getFormatDate(SHORT);
String target = getFormatDate(SHORT, parse(date, format));
return now.equals(target);
} | java | public static boolean isToday(String date, String format) {
String now = getFormatDate(SHORT);
String target = getFormatDate(SHORT, parse(date, format));
return now.equals(target);
} | [
"public",
"static",
"boolean",
"isToday",
"(",
"String",
"date",
",",
"String",
"format",
")",
"{",
"String",
"now",
"=",
"getFormatDate",
"(",
"SHORT",
")",
";",
"String",
"target",
"=",
"getFormatDate",
"(",
"SHORT",
",",
"parse",
"(",
"date",
",",
"format",
")",
")",
";",
"return",
"now",
".",
"equals",
"(",
"target",
")",
";",
"}"
] | 查询时间是否在今日
@param date 时间字符串
@param format 时间字符串的格式
@return 如果指定日期对象在今天则返回<code>true</code> | [
"查询时间是否在今日"
] | train | https://github.com/JoeKerouac/utils/blob/45e1b2dc4d736956674fc4dcbe6cf84eaee69278/src/main/java/com/joe/utils/common/DateUtil.java#L240-L244 |
h2oai/h2o-3 | h2o-algos/src/main/java/hex/tree/Score.java | Score.makeModelMetrics | private ModelMetrics makeModelMetrics(SharedTreeModel model, Frame fr, Frame adaptedFr, Frame preds) {
"""
Run after the doAll scoring to convert the MetricsBuilder to a ModelMetrics
"""
ModelMetrics mm;
if (model._output.nclasses() == 2 && _computeGainsLift) {
assert preds != null : "Predictions were pre-created";
mm = _mb.makeModelMetrics(model, fr, adaptedFr, preds);
} else {
boolean calculatePreds = preds == null && model._parms._distribution == DistributionFamily.huber;
// FIXME: PUBDEV-4992 we should avoid doing full scoring!
if (calculatePreds) {
Log.warn("Going to calculate predictions from scratch. This can be expensive for large models! See PUBDEV-4992");
preds = model.score(fr);
}
mm = _mb.makeModelMetrics(model, fr, null, preds);
if (calculatePreds && (preds != null))
preds.remove();
}
return mm;
} | java | private ModelMetrics makeModelMetrics(SharedTreeModel model, Frame fr, Frame adaptedFr, Frame preds) {
ModelMetrics mm;
if (model._output.nclasses() == 2 && _computeGainsLift) {
assert preds != null : "Predictions were pre-created";
mm = _mb.makeModelMetrics(model, fr, adaptedFr, preds);
} else {
boolean calculatePreds = preds == null && model._parms._distribution == DistributionFamily.huber;
// FIXME: PUBDEV-4992 we should avoid doing full scoring!
if (calculatePreds) {
Log.warn("Going to calculate predictions from scratch. This can be expensive for large models! See PUBDEV-4992");
preds = model.score(fr);
}
mm = _mb.makeModelMetrics(model, fr, null, preds);
if (calculatePreds && (preds != null))
preds.remove();
}
return mm;
} | [
"private",
"ModelMetrics",
"makeModelMetrics",
"(",
"SharedTreeModel",
"model",
",",
"Frame",
"fr",
",",
"Frame",
"adaptedFr",
",",
"Frame",
"preds",
")",
"{",
"ModelMetrics",
"mm",
";",
"if",
"(",
"model",
".",
"_output",
".",
"nclasses",
"(",
")",
"==",
"2",
"&&",
"_computeGainsLift",
")",
"{",
"assert",
"preds",
"!=",
"null",
":",
"\"Predictions were pre-created\"",
";",
"mm",
"=",
"_mb",
".",
"makeModelMetrics",
"(",
"model",
",",
"fr",
",",
"adaptedFr",
",",
"preds",
")",
";",
"}",
"else",
"{",
"boolean",
"calculatePreds",
"=",
"preds",
"==",
"null",
"&&",
"model",
".",
"_parms",
".",
"_distribution",
"==",
"DistributionFamily",
".",
"huber",
";",
"// FIXME: PUBDEV-4992 we should avoid doing full scoring!",
"if",
"(",
"calculatePreds",
")",
"{",
"Log",
".",
"warn",
"(",
"\"Going to calculate predictions from scratch. This can be expensive for large models! See PUBDEV-4992\"",
")",
";",
"preds",
"=",
"model",
".",
"score",
"(",
"fr",
")",
";",
"}",
"mm",
"=",
"_mb",
".",
"makeModelMetrics",
"(",
"model",
",",
"fr",
",",
"null",
",",
"preds",
")",
";",
"if",
"(",
"calculatePreds",
"&&",
"(",
"preds",
"!=",
"null",
")",
")",
"preds",
".",
"remove",
"(",
")",
";",
"}",
"return",
"mm",
";",
"}"
] | Run after the doAll scoring to convert the MetricsBuilder to a ModelMetrics | [
"Run",
"after",
"the",
"doAll",
"scoring",
"to",
"convert",
"the",
"MetricsBuilder",
"to",
"a",
"ModelMetrics"
] | train | https://github.com/h2oai/h2o-3/blob/845eb49dfeaadf638b6e2f779d82fac996391fad/h2o-algos/src/main/java/hex/tree/Score.java#L142-L159 |
UrielCh/ovh-java-sdk | ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java | ApiOvhMe.ipxeScript_POST | public OvhIpxe ipxeScript_POST(String description, String name, String script) throws IOException {
"""
Add an IPXE script
REST: POST /me/ipxeScript
@param script [required] Content of your IPXE script
@param description [required] A personnal description of this script
@param name [required] name of your script
"""
String qPath = "/me/ipxeScript";
StringBuilder sb = path(qPath);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "description", description);
addBody(o, "name", name);
addBody(o, "script", script);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhIpxe.class);
} | java | public OvhIpxe ipxeScript_POST(String description, String name, String script) throws IOException {
String qPath = "/me/ipxeScript";
StringBuilder sb = path(qPath);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "description", description);
addBody(o, "name", name);
addBody(o, "script", script);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhIpxe.class);
} | [
"public",
"OvhIpxe",
"ipxeScript_POST",
"(",
"String",
"description",
",",
"String",
"name",
",",
"String",
"script",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/me/ipxeScript\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"description\"",
",",
"description",
")",
";",
"addBody",
"(",
"o",
",",
"\"name\"",
",",
"name",
")",
";",
"addBody",
"(",
"o",
",",
"\"script\"",
",",
"script",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhIpxe",
".",
"class",
")",
";",
"}"
] | Add an IPXE script
REST: POST /me/ipxeScript
@param script [required] Content of your IPXE script
@param description [required] A personnal description of this script
@param name [required] name of your script | [
"Add",
"an",
"IPXE",
"script"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java#L976-L985 |
urish/gwt-titanium | src/main/java/org/urish/gwtit/client/util/Timers.java | Timers.setTimeout | public static Timer setTimeout(int milliseconds, TimerCallback callback) {
"""
Defines a one-shot timer.
@param milliseconds Time until the timeout callback fires
@param callback Callback to fire
@return The new timer object
"""
TimeoutTimer timeout = new TimeoutTimer();
timeout.setId(nativeSetTimeout(milliseconds, callback, timeout));
return timeout;
} | java | public static Timer setTimeout(int milliseconds, TimerCallback callback) {
TimeoutTimer timeout = new TimeoutTimer();
timeout.setId(nativeSetTimeout(milliseconds, callback, timeout));
return timeout;
} | [
"public",
"static",
"Timer",
"setTimeout",
"(",
"int",
"milliseconds",
",",
"TimerCallback",
"callback",
")",
"{",
"TimeoutTimer",
"timeout",
"=",
"new",
"TimeoutTimer",
"(",
")",
";",
"timeout",
".",
"setId",
"(",
"nativeSetTimeout",
"(",
"milliseconds",
",",
"callback",
",",
"timeout",
")",
")",
";",
"return",
"timeout",
";",
"}"
] | Defines a one-shot timer.
@param milliseconds Time until the timeout callback fires
@param callback Callback to fire
@return The new timer object | [
"Defines",
"a",
"one",
"-",
"shot",
"timer",
"."
] | train | https://github.com/urish/gwt-titanium/blob/5b53a312093a84f235366932430f02006a570612/src/main/java/org/urish/gwtit/client/util/Timers.java#L114-L118 |
google/closure-compiler | src/com/google/javascript/rhino/jstype/ObjectType.java | ObjectType.defineSynthesizedProperty | public final boolean defineSynthesizedProperty(String propertyName,
JSType type, Node propertyNode) {
"""
Defines a property whose type is on a synthesized object. These objects
don't actually exist in the user's program. They're just used for
bookkeeping in the type system.
"""
return defineProperty(propertyName, type, false, propertyNode);
} | java | public final boolean defineSynthesizedProperty(String propertyName,
JSType type, Node propertyNode) {
return defineProperty(propertyName, type, false, propertyNode);
} | [
"public",
"final",
"boolean",
"defineSynthesizedProperty",
"(",
"String",
"propertyName",
",",
"JSType",
"type",
",",
"Node",
"propertyNode",
")",
"{",
"return",
"defineProperty",
"(",
"propertyName",
",",
"type",
",",
"false",
",",
"propertyNode",
")",
";",
"}"
] | Defines a property whose type is on a synthesized object. These objects
don't actually exist in the user's program. They're just used for
bookkeeping in the type system. | [
"Defines",
"a",
"property",
"whose",
"type",
"is",
"on",
"a",
"synthesized",
"object",
".",
"These",
"objects",
"don",
"t",
"actually",
"exist",
"in",
"the",
"user",
"s",
"program",
".",
"They",
"re",
"just",
"used",
"for",
"bookkeeping",
"in",
"the",
"type",
"system",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/ObjectType.java#L385-L388 |
Harium/keel | src/main/java/com/harium/keel/core/helper/ColorHelper.java | ColorHelper.fromHSL | public static int fromHSL(float h, float s, float l) {
"""
Method to transform from HSL to RGB (this method sets alpha as 0xff)
@param h - hue
@param s - saturation
@param l - lightness
@return rgb
"""
int alpha = MAX_INT;
return fromHSL(h, s, l, alpha);
} | java | public static int fromHSL(float h, float s, float l) {
int alpha = MAX_INT;
return fromHSL(h, s, l, alpha);
} | [
"public",
"static",
"int",
"fromHSL",
"(",
"float",
"h",
",",
"float",
"s",
",",
"float",
"l",
")",
"{",
"int",
"alpha",
"=",
"MAX_INT",
";",
"return",
"fromHSL",
"(",
"h",
",",
"s",
",",
"l",
",",
"alpha",
")",
";",
"}"
] | Method to transform from HSL to RGB (this method sets alpha as 0xff)
@param h - hue
@param s - saturation
@param l - lightness
@return rgb | [
"Method",
"to",
"transform",
"from",
"HSL",
"to",
"RGB",
"(",
"this",
"method",
"sets",
"alpha",
"as",
"0xff",
")"
] | train | https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/core/helper/ColorHelper.java#L451-L454 |
BioPAX/Paxtools | paxtools-core/src/main/java/org/biopax/paxtools/controller/Fetcher.java | Fetcher.fetch | public Set<BioPAXElement> fetch(final BioPAXElement bpe, int depth) {
"""
Recursively collects unique child objects from
BioPAX object type properties that pass
all the filters (as set via Constructor).
The #isSkipSubPathways flag is ignored.
Note: this method might return different objects with the same URI if such
are present among the child elements for some reason (for a self-integral BioPAX Model, this should not happen).
@param bpe biopax object to traverse into properties of
@param depth positive int.; 1 means - get only direct children, 2 - include children of children, etc.;
@return set of child objects
@throws IllegalArgumentException when depth is less or equals 0
"""
//a sanity check
if(depth <= 0) {
throw new IllegalArgumentException("fetch(..), not a positive 'depth':" + depth);
}
final Set<BioPAXElement> children = new HashSet<BioPAXElement>();
//create a simple traverser to collect direct child elements
Traverser traverser = new Traverser(editorMap,
new Visitor() {
@Override
public void visit(BioPAXElement domain, Object range, Model model, PropertyEditor<?, ?> editor) {
children.add((BioPAXElement) range);
}
}, filters);
//run
traverser.traverse(bpe, null);
if(!children.isEmpty() && --depth > 0) {
for (BioPAXElement element : new HashSet<BioPAXElement>(children)) {
if(skipSubPathways && (element instanceof Pathway))
continue;
Set<BioPAXElement> nextLevelElements = fetch(element, depth); //recursion goes on
children.addAll(nextLevelElements);
}
}
//remove itself (if added due to tricky loops in the model...)
children.remove(bpe);
return children;
} | java | public Set<BioPAXElement> fetch(final BioPAXElement bpe, int depth)
{
//a sanity check
if(depth <= 0) {
throw new IllegalArgumentException("fetch(..), not a positive 'depth':" + depth);
}
final Set<BioPAXElement> children = new HashSet<BioPAXElement>();
//create a simple traverser to collect direct child elements
Traverser traverser = new Traverser(editorMap,
new Visitor() {
@Override
public void visit(BioPAXElement domain, Object range, Model model, PropertyEditor<?, ?> editor) {
children.add((BioPAXElement) range);
}
}, filters);
//run
traverser.traverse(bpe, null);
if(!children.isEmpty() && --depth > 0) {
for (BioPAXElement element : new HashSet<BioPAXElement>(children)) {
if(skipSubPathways && (element instanceof Pathway))
continue;
Set<BioPAXElement> nextLevelElements = fetch(element, depth); //recursion goes on
children.addAll(nextLevelElements);
}
}
//remove itself (if added due to tricky loops in the model...)
children.remove(bpe);
return children;
} | [
"public",
"Set",
"<",
"BioPAXElement",
">",
"fetch",
"(",
"final",
"BioPAXElement",
"bpe",
",",
"int",
"depth",
")",
"{",
"//a sanity check",
"if",
"(",
"depth",
"<=",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"fetch(..), not a positive 'depth':\"",
"+",
"depth",
")",
";",
"}",
"final",
"Set",
"<",
"BioPAXElement",
">",
"children",
"=",
"new",
"HashSet",
"<",
"BioPAXElement",
">",
"(",
")",
";",
"//create a simple traverser to collect direct child elements",
"Traverser",
"traverser",
"=",
"new",
"Traverser",
"(",
"editorMap",
",",
"new",
"Visitor",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"visit",
"(",
"BioPAXElement",
"domain",
",",
"Object",
"range",
",",
"Model",
"model",
",",
"PropertyEditor",
"<",
"?",
",",
"?",
">",
"editor",
")",
"{",
"children",
".",
"add",
"(",
"(",
"BioPAXElement",
")",
"range",
")",
";",
"}",
"}",
",",
"filters",
")",
";",
"//run",
"traverser",
".",
"traverse",
"(",
"bpe",
",",
"null",
")",
";",
"if",
"(",
"!",
"children",
".",
"isEmpty",
"(",
")",
"&&",
"--",
"depth",
">",
"0",
")",
"{",
"for",
"(",
"BioPAXElement",
"element",
":",
"new",
"HashSet",
"<",
"BioPAXElement",
">",
"(",
"children",
")",
")",
"{",
"if",
"(",
"skipSubPathways",
"&&",
"(",
"element",
"instanceof",
"Pathway",
")",
")",
"continue",
";",
"Set",
"<",
"BioPAXElement",
">",
"nextLevelElements",
"=",
"fetch",
"(",
"element",
",",
"depth",
")",
";",
"//recursion goes on",
"children",
".",
"addAll",
"(",
"nextLevelElements",
")",
";",
"}",
"}",
"//remove itself (if added due to tricky loops in the model...)",
"children",
".",
"remove",
"(",
"bpe",
")",
";",
"return",
"children",
";",
"}"
] | Recursively collects unique child objects from
BioPAX object type properties that pass
all the filters (as set via Constructor).
The #isSkipSubPathways flag is ignored.
Note: this method might return different objects with the same URI if such
are present among the child elements for some reason (for a self-integral BioPAX Model, this should not happen).
@param bpe biopax object to traverse into properties of
@param depth positive int.; 1 means - get only direct children, 2 - include children of children, etc.;
@return set of child objects
@throws IllegalArgumentException when depth is less or equals 0 | [
"Recursively",
"collects",
"unique",
"child",
"objects",
"from",
"BioPAX",
"object",
"type",
"properties",
"that",
"pass",
"all",
"the",
"filters",
"(",
"as",
"set",
"via",
"Constructor",
")",
"."
] | train | https://github.com/BioPAX/Paxtools/blob/2f93afa94426bf8b5afc2e0e61cd4b269a83288d/paxtools-core/src/main/java/org/biopax/paxtools/controller/Fetcher.java#L175-L209 |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.appendLikeCriteria | private void appendLikeCriteria(TableAlias alias, PathInfo pathInfo, LikeCriteria c, StringBuffer buf) {
"""
Answer the SQL-Clause for a LikeCriteria
@param c
@param buf
"""
appendColName(alias, pathInfo, c.isTranslateAttribute(), buf);
buf.append(c.getClause());
appendParameter(c.getValue(), buf);
buf.append(m_platform.getEscapeClause(c));
} | java | private void appendLikeCriteria(TableAlias alias, PathInfo pathInfo, LikeCriteria c, StringBuffer buf)
{
appendColName(alias, pathInfo, c.isTranslateAttribute(), buf);
buf.append(c.getClause());
appendParameter(c.getValue(), buf);
buf.append(m_platform.getEscapeClause(c));
} | [
"private",
"void",
"appendLikeCriteria",
"(",
"TableAlias",
"alias",
",",
"PathInfo",
"pathInfo",
",",
"LikeCriteria",
"c",
",",
"StringBuffer",
"buf",
")",
"{",
"appendColName",
"(",
"alias",
",",
"pathInfo",
",",
"c",
".",
"isTranslateAttribute",
"(",
")",
",",
"buf",
")",
";",
"buf",
".",
"append",
"(",
"c",
".",
"getClause",
"(",
")",
")",
";",
"appendParameter",
"(",
"c",
".",
"getValue",
"(",
")",
",",
"buf",
")",
";",
"buf",
".",
"append",
"(",
"m_platform",
".",
"getEscapeClause",
"(",
"c",
")",
")",
";",
"}"
] | Answer the SQL-Clause for a LikeCriteria
@param c
@param buf | [
"Answer",
"the",
"SQL",
"-",
"Clause",
"for",
"a",
"LikeCriteria"
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L833-L840 |
anotheria/moskito | moskito-integration/moskito-cdi/src/main/java/net/anotheria/moskito/integration/cdi/AbstractInterceptor.java | AbstractInterceptor.createClassLevelAccumulators | private void createClassLevelAccumulators(OnDemandStatsProducer<T> producer, Class producerClass) {
"""
Create accumulators for class.
@param producer {@link OnDemandStatsProducer}
@param producerClass producer class
"""
//several @Accumulators in accumulators holder
Accumulates accAnnotationHolder = AnnotationUtils.findAnnotation(producerClass, Accumulates.class);//(Accumulates) producerClass.getAnnotation(Accumulates.class);
if (accAnnotationHolder != null) {
Accumulate[] accAnnotations = accAnnotationHolder.value();
for (Accumulate accAnnotation : accAnnotations) {
createAccumulator(
producer.getProducerId(),
accAnnotation,
formAccumulatorNameForClass(producer, accAnnotation),
"cumulated");
}
}
//If there is no @Accumulates annotation but @Accumulate is present
Accumulate annotation = AnnotationUtils.findAnnotation(producerClass, Accumulate.class);//producerClass.getAnnotation(Accumulate.class);
createAccumulator(
producer.getProducerId(),
annotation,
formAccumulatorNameForClass(producer, annotation),
"cumulated"
);
} | java | private void createClassLevelAccumulators(OnDemandStatsProducer<T> producer, Class producerClass) {
//several @Accumulators in accumulators holder
Accumulates accAnnotationHolder = AnnotationUtils.findAnnotation(producerClass, Accumulates.class);//(Accumulates) producerClass.getAnnotation(Accumulates.class);
if (accAnnotationHolder != null) {
Accumulate[] accAnnotations = accAnnotationHolder.value();
for (Accumulate accAnnotation : accAnnotations) {
createAccumulator(
producer.getProducerId(),
accAnnotation,
formAccumulatorNameForClass(producer, accAnnotation),
"cumulated");
}
}
//If there is no @Accumulates annotation but @Accumulate is present
Accumulate annotation = AnnotationUtils.findAnnotation(producerClass, Accumulate.class);//producerClass.getAnnotation(Accumulate.class);
createAccumulator(
producer.getProducerId(),
annotation,
formAccumulatorNameForClass(producer, annotation),
"cumulated"
);
} | [
"private",
"void",
"createClassLevelAccumulators",
"(",
"OnDemandStatsProducer",
"<",
"T",
">",
"producer",
",",
"Class",
"producerClass",
")",
"{",
"//several @Accumulators in accumulators holder",
"Accumulates",
"accAnnotationHolder",
"=",
"AnnotationUtils",
".",
"findAnnotation",
"(",
"producerClass",
",",
"Accumulates",
".",
"class",
")",
";",
"//(Accumulates) producerClass.getAnnotation(Accumulates.class);",
"if",
"(",
"accAnnotationHolder",
"!=",
"null",
")",
"{",
"Accumulate",
"[",
"]",
"accAnnotations",
"=",
"accAnnotationHolder",
".",
"value",
"(",
")",
";",
"for",
"(",
"Accumulate",
"accAnnotation",
":",
"accAnnotations",
")",
"{",
"createAccumulator",
"(",
"producer",
".",
"getProducerId",
"(",
")",
",",
"accAnnotation",
",",
"formAccumulatorNameForClass",
"(",
"producer",
",",
"accAnnotation",
")",
",",
"\"cumulated\"",
")",
";",
"}",
"}",
"//If there is no @Accumulates annotation but @Accumulate is present",
"Accumulate",
"annotation",
"=",
"AnnotationUtils",
".",
"findAnnotation",
"(",
"producerClass",
",",
"Accumulate",
".",
"class",
")",
";",
"//producerClass.getAnnotation(Accumulate.class);",
"createAccumulator",
"(",
"producer",
".",
"getProducerId",
"(",
")",
",",
"annotation",
",",
"formAccumulatorNameForClass",
"(",
"producer",
",",
"annotation",
")",
",",
"\"cumulated\"",
")",
";",
"}"
] | Create accumulators for class.
@param producer {@link OnDemandStatsProducer}
@param producerClass producer class | [
"Create",
"accumulators",
"for",
"class",
"."
] | train | https://github.com/anotheria/moskito/blob/0fdb79053b98a6ece610fa159f59bc3331e4cf05/moskito-integration/moskito-cdi/src/main/java/net/anotheria/moskito/integration/cdi/AbstractInterceptor.java#L181-L203 |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/alg/geo/h/HomographyDirectLinearTransform.java | HomographyDirectLinearTransform.addConics | protected int addConics(List<AssociatedPairConic> points , DMatrixRMaj A, int rows ) {
"""
<p>Adds the 9x9 matrix constraint for each pair of conics. To avoid O(N^2) growth the default option only
adds O(N) pairs. if only conics are used then a minimum of 3 is required. See [2].</p>
inv(C[1]')*(C[2]')*H - H*invC[1]*C[2] == 0
Note: x' = H*x. C' is conic from the same view as x' and C from x. It can be shown that C = H^T*C'*H
"""
if( exhaustiveConics ) {
// adds an exhaustive set of linear conics
for (int i = 0; i < points.size(); i++) {
for (int j = i+1; j < points.size(); j++) {
rows = addConicPairConstraints(points.get(i),points.get(j),A,rows);
}
}
} else {
// adds pairs and has linear time complexity
for (int i = 1; i < points.size(); i++) {
rows = addConicPairConstraints(points.get(i-1),points.get(i),A,rows);
}
int N = points.size();
rows = addConicPairConstraints(points.get(0),points.get(N-1),A,rows);
}
return rows;
} | java | protected int addConics(List<AssociatedPairConic> points , DMatrixRMaj A, int rows ) {
if( exhaustiveConics ) {
// adds an exhaustive set of linear conics
for (int i = 0; i < points.size(); i++) {
for (int j = i+1; j < points.size(); j++) {
rows = addConicPairConstraints(points.get(i),points.get(j),A,rows);
}
}
} else {
// adds pairs and has linear time complexity
for (int i = 1; i < points.size(); i++) {
rows = addConicPairConstraints(points.get(i-1),points.get(i),A,rows);
}
int N = points.size();
rows = addConicPairConstraints(points.get(0),points.get(N-1),A,rows);
}
return rows;
} | [
"protected",
"int",
"addConics",
"(",
"List",
"<",
"AssociatedPairConic",
">",
"points",
",",
"DMatrixRMaj",
"A",
",",
"int",
"rows",
")",
"{",
"if",
"(",
"exhaustiveConics",
")",
"{",
"// adds an exhaustive set of linear conics",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"points",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"i",
"+",
"1",
";",
"j",
"<",
"points",
".",
"size",
"(",
")",
";",
"j",
"++",
")",
"{",
"rows",
"=",
"addConicPairConstraints",
"(",
"points",
".",
"get",
"(",
"i",
")",
",",
"points",
".",
"get",
"(",
"j",
")",
",",
"A",
",",
"rows",
")",
";",
"}",
"}",
"}",
"else",
"{",
"// adds pairs and has linear time complexity",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"points",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"rows",
"=",
"addConicPairConstraints",
"(",
"points",
".",
"get",
"(",
"i",
"-",
"1",
")",
",",
"points",
".",
"get",
"(",
"i",
")",
",",
"A",
",",
"rows",
")",
";",
"}",
"int",
"N",
"=",
"points",
".",
"size",
"(",
")",
";",
"rows",
"=",
"addConicPairConstraints",
"(",
"points",
".",
"get",
"(",
"0",
")",
",",
"points",
".",
"get",
"(",
"N",
"-",
"1",
")",
",",
"A",
",",
"rows",
")",
";",
"}",
"return",
"rows",
";",
"}"
] | <p>Adds the 9x9 matrix constraint for each pair of conics. To avoid O(N^2) growth the default option only
adds O(N) pairs. if only conics are used then a minimum of 3 is required. See [2].</p>
inv(C[1]')*(C[2]')*H - H*invC[1]*C[2] == 0
Note: x' = H*x. C' is conic from the same view as x' and C from x. It can be shown that C = H^T*C'*H | [
"<p",
">",
"Adds",
"the",
"9x9",
"matrix",
"constraint",
"for",
"each",
"pair",
"of",
"conics",
".",
"To",
"avoid",
"O",
"(",
"N^2",
")",
"growth",
"the",
"default",
"option",
"only",
"adds",
"O",
"(",
"N",
")",
"pairs",
".",
"if",
"only",
"conics",
"are",
"used",
"then",
"a",
"minimum",
"of",
"3",
"is",
"required",
".",
"See",
"[",
"2",
"]",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/h/HomographyDirectLinearTransform.java#L310-L329 |
elki-project/elki | elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/LaplaceDistribution.java | LaplaceDistribution.logpdf | public static double logpdf(double val, double rate) {
"""
PDF, static version
@param val Value to compute PDF at
@param rate Rate parameter (1/scale)
@return probability density
"""
return FastMath.log(.5 * rate) - rate * Math.abs(val);
} | java | public static double logpdf(double val, double rate) {
return FastMath.log(.5 * rate) - rate * Math.abs(val);
} | [
"public",
"static",
"double",
"logpdf",
"(",
"double",
"val",
",",
"double",
"rate",
")",
"{",
"return",
"FastMath",
".",
"log",
"(",
".5",
"*",
"rate",
")",
"-",
"rate",
"*",
"Math",
".",
"abs",
"(",
"val",
")",
";",
"}"
] | PDF, static version
@param val Value to compute PDF at
@param rate Rate parameter (1/scale)
@return probability density | [
"PDF",
"static",
"version"
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/LaplaceDistribution.java#L151-L153 |
metamx/extendedset | src/main/java/it/uniroma3/mat/extendedset/wrappers/matrix/PairSet.java | PairSet.indexOf | @Override
public int indexOf(Pair<T, I> element) {
"""
Provides position of element within the set.
<p>
It returns -1 if the element does not exist within the set.
@param element
element of the set
@return the element position
"""
return matrix.indexOf(
transactionToIndex(element.transaction),
itemToIndex(element.item));
} | java | @Override
public int indexOf(Pair<T, I> element) {
return matrix.indexOf(
transactionToIndex(element.transaction),
itemToIndex(element.item));
} | [
"@",
"Override",
"public",
"int",
"indexOf",
"(",
"Pair",
"<",
"T",
",",
"I",
">",
"element",
")",
"{",
"return",
"matrix",
".",
"indexOf",
"(",
"transactionToIndex",
"(",
"element",
".",
"transaction",
")",
",",
"itemToIndex",
"(",
"element",
".",
"item",
")",
")",
";",
"}"
] | Provides position of element within the set.
<p>
It returns -1 if the element does not exist within the set.
@param element
element of the set
@return the element position | [
"Provides",
"position",
"of",
"element",
"within",
"the",
"set",
".",
"<p",
">",
"It",
"returns",
"-",
"1",
"if",
"the",
"element",
"does",
"not",
"exist",
"within",
"the",
"set",
"."
] | train | https://github.com/metamx/extendedset/blob/0f77c28057fac9c1bd6d79fbe5425b8efe5742a8/src/main/java/it/uniroma3/mat/extendedset/wrappers/matrix/PairSet.java#L779-L784 |
dropbox/dropbox-sdk-java | examples/web-file-browser/src/main/java/com/dropbox/core/examples/web_file_browser/DropboxBrowse.java | DropboxBrowse.slurpUtf8Part | private static String slurpUtf8Part(HttpServletRequest request, HttpServletResponse response, String name, int maxLength)
throws IOException, ServletException {
"""
Reads in a single field of a multipart/form-data request. If the field is not present
or the field is longer than maxLength, we'll use the given HttpServletResponse to respond
with an error and then return null.
Otherwise, process it as UTF-8 bytes and return the equivalent String.
"""
Part part = request.getPart(name);
if (part == null) {
response.sendError(400, "Form field " + jq(name) + " is missing");
return null;
}
byte[] bytes = new byte[maxLength];
InputStream in = part.getInputStream();
int bytesRead = in.read(bytes);
if (bytesRead == -1) {
return "";
}
String s = StringUtil.utf8ToString(bytes, 0, bytesRead);
if (in.read() != -1) {
response.sendError(400, "Field " + jq(name) + " is too long (the limit is " + maxLength + " bytes): " + jq(s));
return null;
}
// TODO: We're just assuming the content is UTF-8 text. We should actually check it.
return s;
} | java | private static String slurpUtf8Part(HttpServletRequest request, HttpServletResponse response, String name, int maxLength)
throws IOException, ServletException
{
Part part = request.getPart(name);
if (part == null) {
response.sendError(400, "Form field " + jq(name) + " is missing");
return null;
}
byte[] bytes = new byte[maxLength];
InputStream in = part.getInputStream();
int bytesRead = in.read(bytes);
if (bytesRead == -1) {
return "";
}
String s = StringUtil.utf8ToString(bytes, 0, bytesRead);
if (in.read() != -1) {
response.sendError(400, "Field " + jq(name) + " is too long (the limit is " + maxLength + " bytes): " + jq(s));
return null;
}
// TODO: We're just assuming the content is UTF-8 text. We should actually check it.
return s;
} | [
"private",
"static",
"String",
"slurpUtf8Part",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
",",
"String",
"name",
",",
"int",
"maxLength",
")",
"throws",
"IOException",
",",
"ServletException",
"{",
"Part",
"part",
"=",
"request",
".",
"getPart",
"(",
"name",
")",
";",
"if",
"(",
"part",
"==",
"null",
")",
"{",
"response",
".",
"sendError",
"(",
"400",
",",
"\"Form field \"",
"+",
"jq",
"(",
"name",
")",
"+",
"\" is missing\"",
")",
";",
"return",
"null",
";",
"}",
"byte",
"[",
"]",
"bytes",
"=",
"new",
"byte",
"[",
"maxLength",
"]",
";",
"InputStream",
"in",
"=",
"part",
".",
"getInputStream",
"(",
")",
";",
"int",
"bytesRead",
"=",
"in",
".",
"read",
"(",
"bytes",
")",
";",
"if",
"(",
"bytesRead",
"==",
"-",
"1",
")",
"{",
"return",
"\"\"",
";",
"}",
"String",
"s",
"=",
"StringUtil",
".",
"utf8ToString",
"(",
"bytes",
",",
"0",
",",
"bytesRead",
")",
";",
"if",
"(",
"in",
".",
"read",
"(",
")",
"!=",
"-",
"1",
")",
"{",
"response",
".",
"sendError",
"(",
"400",
",",
"\"Field \"",
"+",
"jq",
"(",
"name",
")",
"+",
"\" is too long (the limit is \"",
"+",
"maxLength",
"+",
"\" bytes): \"",
"+",
"jq",
"(",
"s",
")",
")",
";",
"return",
"null",
";",
"}",
"// TODO: We're just assuming the content is UTF-8 text. We should actually check it.",
"return",
"s",
";",
"}"
] | Reads in a single field of a multipart/form-data request. If the field is not present
or the field is longer than maxLength, we'll use the given HttpServletResponse to respond
with an error and then return null.
Otherwise, process it as UTF-8 bytes and return the equivalent String. | [
"Reads",
"in",
"a",
"single",
"field",
"of",
"a",
"multipart",
"/",
"form",
"-",
"data",
"request",
".",
"If",
"the",
"field",
"is",
"not",
"present",
"or",
"the",
"field",
"is",
"longer",
"than",
"maxLength",
"we",
"ll",
"use",
"the",
"given",
"HttpServletResponse",
"to",
"respond",
"with",
"an",
"error",
"and",
"then",
"return",
"null",
"."
] | train | https://github.com/dropbox/dropbox-sdk-java/blob/d86157005fad6233c18b4b0f10f00b8d9d56ae92/examples/web-file-browser/src/main/java/com/dropbox/core/examples/web_file_browser/DropboxBrowse.java#L317-L343 |
spring-projects/spring-loaded | springloaded/src/main/java/org/springsource/loaded/ISMgr.java | ISMgr.setValue | public void setValue(ReloadableType rtype, Object instance, Object value, String name)
throws IllegalAccessException {
"""
Set the value of a field.
@param rtype the reloadabletype
@param instance the instance upon which to set the field
@param value the value to put into the field
@param name the name of the field
@throws IllegalAccessException if there is a problem setting the field value
"""
// System.err.println(">setValue(rtype=" + rtype + ",instance=" + instance + ",value=" + value + ",name=" + name + ")");
// Look up through our reloadable hierarchy to find it
FieldMember fieldmember = rtype.findInstanceField(name);
if (fieldmember == null) {
// If the field is null, there are two possible reasons:
// 1. The field does not exist in the hierarchy at all
// 2. The field is on a type just above our topmost reloadable type
FieldReaderWriter frw = rtype.locateField(name);
if (frw == null) {
// bad code redeployed?
log.info("Unexpectedly unable to locate instance field " + name + " starting from type "
+ rtype.dottedtypename
+ ": clinit running late?");
return;
}
frw.setValue(instance, value, this);
}
else {
if (fieldmember.isStatic()) {
throw new IncompatibleClassChangeError("Expected non-static field " + rtype.dottedtypename + "."
+ fieldmember.getName());
}
Map<String, Object> typeValues = values.get(fieldmember.getDeclaringTypeName());
if (typeValues == null) {
typeValues = new HashMap<String, Object>();
values.put(fieldmember.getDeclaringTypeName(), typeValues);
}
typeValues.put(name, value);
}
} | java | public void setValue(ReloadableType rtype, Object instance, Object value, String name)
throws IllegalAccessException {
// System.err.println(">setValue(rtype=" + rtype + ",instance=" + instance + ",value=" + value + ",name=" + name + ")");
// Look up through our reloadable hierarchy to find it
FieldMember fieldmember = rtype.findInstanceField(name);
if (fieldmember == null) {
// If the field is null, there are two possible reasons:
// 1. The field does not exist in the hierarchy at all
// 2. The field is on a type just above our topmost reloadable type
FieldReaderWriter frw = rtype.locateField(name);
if (frw == null) {
// bad code redeployed?
log.info("Unexpectedly unable to locate instance field " + name + " starting from type "
+ rtype.dottedtypename
+ ": clinit running late?");
return;
}
frw.setValue(instance, value, this);
}
else {
if (fieldmember.isStatic()) {
throw new IncompatibleClassChangeError("Expected non-static field " + rtype.dottedtypename + "."
+ fieldmember.getName());
}
Map<String, Object> typeValues = values.get(fieldmember.getDeclaringTypeName());
if (typeValues == null) {
typeValues = new HashMap<String, Object>();
values.put(fieldmember.getDeclaringTypeName(), typeValues);
}
typeValues.put(name, value);
}
} | [
"public",
"void",
"setValue",
"(",
"ReloadableType",
"rtype",
",",
"Object",
"instance",
",",
"Object",
"value",
",",
"String",
"name",
")",
"throws",
"IllegalAccessException",
"{",
"//\t\tSystem.err.println(\">setValue(rtype=\" + rtype + \",instance=\" + instance + \",value=\" + value + \",name=\" + name + \")\");",
"// Look up through our reloadable hierarchy to find it",
"FieldMember",
"fieldmember",
"=",
"rtype",
".",
"findInstanceField",
"(",
"name",
")",
";",
"if",
"(",
"fieldmember",
"==",
"null",
")",
"{",
"// If the field is null, there are two possible reasons:",
"// 1. The field does not exist in the hierarchy at all",
"// 2. The field is on a type just above our topmost reloadable type",
"FieldReaderWriter",
"frw",
"=",
"rtype",
".",
"locateField",
"(",
"name",
")",
";",
"if",
"(",
"frw",
"==",
"null",
")",
"{",
"// bad code redeployed?",
"log",
".",
"info",
"(",
"\"Unexpectedly unable to locate instance field \"",
"+",
"name",
"+",
"\" starting from type \"",
"+",
"rtype",
".",
"dottedtypename",
"+",
"\": clinit running late?\"",
")",
";",
"return",
";",
"}",
"frw",
".",
"setValue",
"(",
"instance",
",",
"value",
",",
"this",
")",
";",
"}",
"else",
"{",
"if",
"(",
"fieldmember",
".",
"isStatic",
"(",
")",
")",
"{",
"throw",
"new",
"IncompatibleClassChangeError",
"(",
"\"Expected non-static field \"",
"+",
"rtype",
".",
"dottedtypename",
"+",
"\".\"",
"+",
"fieldmember",
".",
"getName",
"(",
")",
")",
";",
"}",
"Map",
"<",
"String",
",",
"Object",
">",
"typeValues",
"=",
"values",
".",
"get",
"(",
"fieldmember",
".",
"getDeclaringTypeName",
"(",
")",
")",
";",
"if",
"(",
"typeValues",
"==",
"null",
")",
"{",
"typeValues",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"values",
".",
"put",
"(",
"fieldmember",
".",
"getDeclaringTypeName",
"(",
")",
",",
"typeValues",
")",
";",
"}",
"typeValues",
".",
"put",
"(",
"name",
",",
"value",
")",
";",
"}",
"}"
] | Set the value of a field.
@param rtype the reloadabletype
@param instance the instance upon which to set the field
@param value the value to put into the field
@param name the name of the field
@throws IllegalAccessException if there is a problem setting the field value | [
"Set",
"the",
"value",
"of",
"a",
"field",
"."
] | train | https://github.com/spring-projects/spring-loaded/blob/59b32f957a05c6d9f149148158053605e2a6205a/springloaded/src/main/java/org/springsource/loaded/ISMgr.java#L168-L201 |
elki-project/elki | elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/vafile/PartialVAFile.java | PartialVAFile.calculateFullApproximation | protected VectorApproximation calculateFullApproximation(DBID id, V dv) {
"""
Calculate the VA file position given the existing borders.
@param id Object ID
@param dv Data vector
@return Vector approximation
"""
int[] approximation = new int[dv.getDimensionality()];
for(int d = 0; d < splitPartitions.length; d++) {
double[] split = daFiles.get(d).getSplitPositions();
final double val = dv.doubleValue(d);
final int lastBorderIndex = split.length - 1;
// Value is below data grid
if(val < split[0]) {
approximation[d] = 0;
if(id != null) {
LOG.warning("Vector outside of VAFile grid!");
}
} // Value is above data grid
else if(val > split[lastBorderIndex]) {
approximation[d] = lastBorderIndex - 1;
if(id != null) {
LOG.warning("Vector outside of VAFile grid!");
}
} // normal case
else {
// Search grid position
int pos = Arrays.binarySearch(split, val);
pos = (pos >= 0) ? pos : ((-pos) - 2);
approximation[d] = pos;
}
}
return new VectorApproximation(id, approximation);
} | java | protected VectorApproximation calculateFullApproximation(DBID id, V dv) {
int[] approximation = new int[dv.getDimensionality()];
for(int d = 0; d < splitPartitions.length; d++) {
double[] split = daFiles.get(d).getSplitPositions();
final double val = dv.doubleValue(d);
final int lastBorderIndex = split.length - 1;
// Value is below data grid
if(val < split[0]) {
approximation[d] = 0;
if(id != null) {
LOG.warning("Vector outside of VAFile grid!");
}
} // Value is above data grid
else if(val > split[lastBorderIndex]) {
approximation[d] = lastBorderIndex - 1;
if(id != null) {
LOG.warning("Vector outside of VAFile grid!");
}
} // normal case
else {
// Search grid position
int pos = Arrays.binarySearch(split, val);
pos = (pos >= 0) ? pos : ((-pos) - 2);
approximation[d] = pos;
}
}
return new VectorApproximation(id, approximation);
} | [
"protected",
"VectorApproximation",
"calculateFullApproximation",
"(",
"DBID",
"id",
",",
"V",
"dv",
")",
"{",
"int",
"[",
"]",
"approximation",
"=",
"new",
"int",
"[",
"dv",
".",
"getDimensionality",
"(",
")",
"]",
";",
"for",
"(",
"int",
"d",
"=",
"0",
";",
"d",
"<",
"splitPartitions",
".",
"length",
";",
"d",
"++",
")",
"{",
"double",
"[",
"]",
"split",
"=",
"daFiles",
".",
"get",
"(",
"d",
")",
".",
"getSplitPositions",
"(",
")",
";",
"final",
"double",
"val",
"=",
"dv",
".",
"doubleValue",
"(",
"d",
")",
";",
"final",
"int",
"lastBorderIndex",
"=",
"split",
".",
"length",
"-",
"1",
";",
"// Value is below data grid",
"if",
"(",
"val",
"<",
"split",
"[",
"0",
"]",
")",
"{",
"approximation",
"[",
"d",
"]",
"=",
"0",
";",
"if",
"(",
"id",
"!=",
"null",
")",
"{",
"LOG",
".",
"warning",
"(",
"\"Vector outside of VAFile grid!\"",
")",
";",
"}",
"}",
"// Value is above data grid",
"else",
"if",
"(",
"val",
">",
"split",
"[",
"lastBorderIndex",
"]",
")",
"{",
"approximation",
"[",
"d",
"]",
"=",
"lastBorderIndex",
"-",
"1",
";",
"if",
"(",
"id",
"!=",
"null",
")",
"{",
"LOG",
".",
"warning",
"(",
"\"Vector outside of VAFile grid!\"",
")",
";",
"}",
"}",
"// normal case",
"else",
"{",
"// Search grid position",
"int",
"pos",
"=",
"Arrays",
".",
"binarySearch",
"(",
"split",
",",
"val",
")",
";",
"pos",
"=",
"(",
"pos",
">=",
"0",
")",
"?",
"pos",
":",
"(",
"(",
"-",
"pos",
")",
"-",
"2",
")",
";",
"approximation",
"[",
"d",
"]",
"=",
"pos",
";",
"}",
"}",
"return",
"new",
"VectorApproximation",
"(",
"id",
",",
"approximation",
")",
";",
"}"
] | Calculate the VA file position given the existing borders.
@param id Object ID
@param dv Data vector
@return Vector approximation | [
"Calculate",
"the",
"VA",
"file",
"position",
"given",
"the",
"existing",
"borders",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/vafile/PartialVAFile.java#L193-L221 |
probedock/probedock-java | src/main/java/io/probedock/client/common/utils/Inflector.java | Inflector.forgeName | public static String forgeName(Class cl, Method m, ProbeTest methodAnnotation) {
"""
Forge a name from a class and a method. If an annotation is provided, then the method
content is used.
@param cl Class to get the name
@param m Method to get the name
@param methodAnnotation The method annotation to override the normal forged name
@return The name forge and humanize
"""
return forgeName(cl, m.getName(), methodAnnotation);
} | java | public static String forgeName(Class cl, Method m, ProbeTest methodAnnotation) {
return forgeName(cl, m.getName(), methodAnnotation);
} | [
"public",
"static",
"String",
"forgeName",
"(",
"Class",
"cl",
",",
"Method",
"m",
",",
"ProbeTest",
"methodAnnotation",
")",
"{",
"return",
"forgeName",
"(",
"cl",
",",
"m",
".",
"getName",
"(",
")",
",",
"methodAnnotation",
")",
";",
"}"
] | Forge a name from a class and a method. If an annotation is provided, then the method
content is used.
@param cl Class to get the name
@param m Method to get the name
@param methodAnnotation The method annotation to override the normal forged name
@return The name forge and humanize | [
"Forge",
"a",
"name",
"from",
"a",
"class",
"and",
"a",
"method",
".",
"If",
"an",
"annotation",
"is",
"provided",
"then",
"the",
"method",
"content",
"is",
"used",
"."
] | train | https://github.com/probedock/probedock-java/blob/92ee6634ba4fe3fdffeb4e202f5372ef947a67c3/src/main/java/io/probedock/client/common/utils/Inflector.java#L23-L25 |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/transform/TransformerRegistry.java | TransformerRegistry.getHostRegistration | public TransformersSubRegistration getHostRegistration(final ModelVersionRange range) {
"""
Get the sub registry for the hosts.
@param range the version range
@return the sub registry
"""
final PathAddress address = PathAddress.EMPTY_ADDRESS.append(HOST);
return new TransformersSubRegistrationImpl(range, domain, address);
} | java | public TransformersSubRegistration getHostRegistration(final ModelVersionRange range) {
final PathAddress address = PathAddress.EMPTY_ADDRESS.append(HOST);
return new TransformersSubRegistrationImpl(range, domain, address);
} | [
"public",
"TransformersSubRegistration",
"getHostRegistration",
"(",
"final",
"ModelVersionRange",
"range",
")",
"{",
"final",
"PathAddress",
"address",
"=",
"PathAddress",
".",
"EMPTY_ADDRESS",
".",
"append",
"(",
"HOST",
")",
";",
"return",
"new",
"TransformersSubRegistrationImpl",
"(",
"range",
",",
"domain",
",",
"address",
")",
";",
"}"
] | Get the sub registry for the hosts.
@param range the version range
@return the sub registry | [
"Get",
"the",
"sub",
"registry",
"for",
"the",
"hosts",
"."
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/transform/TransformerRegistry.java#L174-L177 |
xhsun/gw2wrapper | src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java | AsynchronousRequest.getEventDetailedInfo | public void getEventDetailedInfo(String id, Callback<EventDetail> callback) throws GuildWars2Exception, NullPointerException {
"""
For more info on event detail API go <a href="https://wiki.guildwars2.com/wiki/API:1/event_details">here</a><br/>
@param id event id
@param callback callback that is going to be used for {@link Call#enqueue(Callback)}
@throws GuildWars2Exception invalid id
@throws NullPointerException if given {@link Callback} is null
@see EventDetail event detail
"""
isParamValid(new ParamChecker(ParamType.ID, id));
gw2API.getEventDetailedInfo(id, GuildWars2.lang.getValue()).enqueue(callback);
} | java | public void getEventDetailedInfo(String id, Callback<EventDetail> callback) throws GuildWars2Exception, NullPointerException {
isParamValid(new ParamChecker(ParamType.ID, id));
gw2API.getEventDetailedInfo(id, GuildWars2.lang.getValue()).enqueue(callback);
} | [
"public",
"void",
"getEventDetailedInfo",
"(",
"String",
"id",
",",
"Callback",
"<",
"EventDetail",
">",
"callback",
")",
"throws",
"GuildWars2Exception",
",",
"NullPointerException",
"{",
"isParamValid",
"(",
"new",
"ParamChecker",
"(",
"ParamType",
".",
"ID",
",",
"id",
")",
")",
";",
"gw2API",
".",
"getEventDetailedInfo",
"(",
"id",
",",
"GuildWars2",
".",
"lang",
".",
"getValue",
"(",
")",
")",
".",
"enqueue",
"(",
"callback",
")",
";",
"}"
] | For more info on event detail API go <a href="https://wiki.guildwars2.com/wiki/API:1/event_details">here</a><br/>
@param id event id
@param callback callback that is going to be used for {@link Call#enqueue(Callback)}
@throws GuildWars2Exception invalid id
@throws NullPointerException if given {@link Callback} is null
@see EventDetail event detail | [
"For",
"more",
"info",
"on",
"event",
"detail",
"API",
"go",
"<a",
"href",
"=",
"https",
":",
"//",
"wiki",
".",
"guildwars2",
".",
"com",
"/",
"wiki",
"/",
"API",
":",
"1",
"/",
"event_details",
">",
"here<",
"/",
"a",
">",
"<br",
"/",
">"
] | train | https://github.com/xhsun/gw2wrapper/blob/c8a43b51f363b032074fb152ee6efe657e33e525/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java#L78-L81 |
marklogic/java-client-api | marklogic-client-api/src/main/java/com/marklogic/client/query/StructuredQueryBuilder.java | StructuredQueryBuilder.temporalPeriodRange | public StructuredQueryDefinition temporalPeriodRange(Axis[] axes, TemporalOperator operator,
Period[] periods, String... options) {
"""
Matches documents that have a value in the specified axis that matches the specified
periods using the specified operator.
@param axes the set of axes of document temporal values used to determine which documents have
values that match this query
@param operator the operator used to determine if values in the axis match the specified period
@param periods the periods considered using the operator. When multiple periods are specified,
the query matches if a value matches any period.
@param options string options from the list for
<a href="http://docs.marklogic.com/cts:period-range-query">cts:period-range-query calls</a>
@return a query to filter by comparing a temporal axis to period values
@see <a href="http://docs.marklogic.com/cts:period-range-query">cts:period-range-query</a>
@see <a href="http://docs.marklogic.com/guide/search-dev/structured-query#id_91434">
Structured Queries: period-range-query</a>
"""
if ( axes == null ) throw new IllegalArgumentException("axes cannot be null");
if ( operator == null ) throw new IllegalArgumentException("operator cannot be null");
if ( periods == null ) throw new IllegalArgumentException("periods cannot be null");
return new TemporalPeriodRangeQuery(axes, operator, periods, options);
} | java | public StructuredQueryDefinition temporalPeriodRange(Axis[] axes, TemporalOperator operator,
Period[] periods, String... options)
{
if ( axes == null ) throw new IllegalArgumentException("axes cannot be null");
if ( operator == null ) throw new IllegalArgumentException("operator cannot be null");
if ( periods == null ) throw new IllegalArgumentException("periods cannot be null");
return new TemporalPeriodRangeQuery(axes, operator, periods, options);
} | [
"public",
"StructuredQueryDefinition",
"temporalPeriodRange",
"(",
"Axis",
"[",
"]",
"axes",
",",
"TemporalOperator",
"operator",
",",
"Period",
"[",
"]",
"periods",
",",
"String",
"...",
"options",
")",
"{",
"if",
"(",
"axes",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"axes cannot be null\"",
")",
";",
"if",
"(",
"operator",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"operator cannot be null\"",
")",
";",
"if",
"(",
"periods",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"periods cannot be null\"",
")",
";",
"return",
"new",
"TemporalPeriodRangeQuery",
"(",
"axes",
",",
"operator",
",",
"periods",
",",
"options",
")",
";",
"}"
] | Matches documents that have a value in the specified axis that matches the specified
periods using the specified operator.
@param axes the set of axes of document temporal values used to determine which documents have
values that match this query
@param operator the operator used to determine if values in the axis match the specified period
@param periods the periods considered using the operator. When multiple periods are specified,
the query matches if a value matches any period.
@param options string options from the list for
<a href="http://docs.marklogic.com/cts:period-range-query">cts:period-range-query calls</a>
@return a query to filter by comparing a temporal axis to period values
@see <a href="http://docs.marklogic.com/cts:period-range-query">cts:period-range-query</a>
@see <a href="http://docs.marklogic.com/guide/search-dev/structured-query#id_91434">
Structured Queries: period-range-query</a> | [
"Matches",
"documents",
"that",
"have",
"a",
"value",
"in",
"the",
"specified",
"axis",
"that",
"matches",
"the",
"specified",
"periods",
"using",
"the",
"specified",
"operator",
"."
] | train | https://github.com/marklogic/java-client-api/blob/acf60229a928abd4a8cc4b21b641d56957467da7/marklogic-client-api/src/main/java/com/marklogic/client/query/StructuredQueryBuilder.java#L2802-L2809 |
threerings/gwt-utils | src/main/java/com/threerings/gwt/util/ServiceBackedDataModel.java | ServiceBackedDataModel.callFetchService | protected void callFetchService (PagedRequest request, AsyncCallback<R> callback) {
"""
Calls the service to obtain data. Implementations should make a service call using the
callback provided. If needCount is set, the implementation should also request the total
number of items from the server (this is normally done in the same call that requests a
page but may be optional for performance reasons). By default, this calls
{@link #callFetchService(int, int, boolean, AsyncCallback)} method with the
{@code requests}'s members.
NOTE: subclasses must override one of the two callFetchService methods
"""
callFetchService(request.offset, request.count, request.needCount, callback);
} | java | protected void callFetchService (PagedRequest request, AsyncCallback<R> callback)
{
callFetchService(request.offset, request.count, request.needCount, callback);
} | [
"protected",
"void",
"callFetchService",
"(",
"PagedRequest",
"request",
",",
"AsyncCallback",
"<",
"R",
">",
"callback",
")",
"{",
"callFetchService",
"(",
"request",
".",
"offset",
",",
"request",
".",
"count",
",",
"request",
".",
"needCount",
",",
"callback",
")",
";",
"}"
] | Calls the service to obtain data. Implementations should make a service call using the
callback provided. If needCount is set, the implementation should also request the total
number of items from the server (this is normally done in the same call that requests a
page but may be optional for performance reasons). By default, this calls
{@link #callFetchService(int, int, boolean, AsyncCallback)} method with the
{@code requests}'s members.
NOTE: subclasses must override one of the two callFetchService methods | [
"Calls",
"the",
"service",
"to",
"obtain",
"data",
".",
"Implementations",
"should",
"make",
"a",
"service",
"call",
"using",
"the",
"callback",
"provided",
".",
"If",
"needCount",
"is",
"set",
"the",
"implementation",
"should",
"also",
"request",
"the",
"total",
"number",
"of",
"items",
"from",
"the",
"server",
"(",
"this",
"is",
"normally",
"done",
"in",
"the",
"same",
"call",
"that",
"requests",
"a",
"page",
"but",
"may",
"be",
"optional",
"for",
"performance",
"reasons",
")",
".",
"By",
"default",
"this",
"calls",
"{"
] | train | https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/util/ServiceBackedDataModel.java#L154-L157 |
google/error-prone-javac | src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java | HtmlDocletWriter.addSummaryComment | public void addSummaryComment(Element element, Content htmltree) {
"""
Adds the summary content.
@param element the Element for which the summary will be generated
@param htmltree the documentation tree to which the summary will be added
"""
addSummaryComment(element, utils.getFirstSentenceTrees(element), htmltree);
} | java | public void addSummaryComment(Element element, Content htmltree) {
addSummaryComment(element, utils.getFirstSentenceTrees(element), htmltree);
} | [
"public",
"void",
"addSummaryComment",
"(",
"Element",
"element",
",",
"Content",
"htmltree",
")",
"{",
"addSummaryComment",
"(",
"element",
",",
"utils",
".",
"getFirstSentenceTrees",
"(",
"element",
")",
",",
"htmltree",
")",
";",
"}"
] | Adds the summary content.
@param element the Element for which the summary will be generated
@param htmltree the documentation tree to which the summary will be added | [
"Adds",
"the",
"summary",
"content",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java#L1658-L1660 |
googleads/googleads-java-lib | modules/ads_lib/src/main/java/com/google/api/ads/adwords/lib/utils/logging/ReportServiceLogger.java | ReportServiceLogger.appendMapAsString | private StringBuilder appendMapAsString(StringBuilder messageBuilder, Map<String, Object> map) {
"""
Converts the map of key/value pairs to a multi-line string (one line per key). Masks sensitive
information for a predefined set of header keys.
@param map a non-null Map
@return a non-null String
"""
for (Entry<String, Object> mapEntry : map.entrySet()) {
Object headerValue = mapEntry.getValue();
// Perform a case-insensitive check if the header should be scrubbed.
if (SCRUBBED_HEADERS.contains(mapEntry.getKey().toLowerCase())) {
headerValue = REDACTED_HEADER;
}
messageBuilder.append(String.format("%s: %s%n", mapEntry.getKey(), headerValue));
}
return messageBuilder;
} | java | private StringBuilder appendMapAsString(StringBuilder messageBuilder, Map<String, Object> map) {
for (Entry<String, Object> mapEntry : map.entrySet()) {
Object headerValue = mapEntry.getValue();
// Perform a case-insensitive check if the header should be scrubbed.
if (SCRUBBED_HEADERS.contains(mapEntry.getKey().toLowerCase())) {
headerValue = REDACTED_HEADER;
}
messageBuilder.append(String.format("%s: %s%n", mapEntry.getKey(), headerValue));
}
return messageBuilder;
} | [
"private",
"StringBuilder",
"appendMapAsString",
"(",
"StringBuilder",
"messageBuilder",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
")",
"{",
"for",
"(",
"Entry",
"<",
"String",
",",
"Object",
">",
"mapEntry",
":",
"map",
".",
"entrySet",
"(",
")",
")",
"{",
"Object",
"headerValue",
"=",
"mapEntry",
".",
"getValue",
"(",
")",
";",
"// Perform a case-insensitive check if the header should be scrubbed.",
"if",
"(",
"SCRUBBED_HEADERS",
".",
"contains",
"(",
"mapEntry",
".",
"getKey",
"(",
")",
".",
"toLowerCase",
"(",
")",
")",
")",
"{",
"headerValue",
"=",
"REDACTED_HEADER",
";",
"}",
"messageBuilder",
".",
"append",
"(",
"String",
".",
"format",
"(",
"\"%s: %s%n\"",
",",
"mapEntry",
".",
"getKey",
"(",
")",
",",
"headerValue",
")",
")",
";",
"}",
"return",
"messageBuilder",
";",
"}"
] | Converts the map of key/value pairs to a multi-line string (one line per key). Masks sensitive
information for a predefined set of header keys.
@param map a non-null Map
@return a non-null String | [
"Converts",
"the",
"map",
"of",
"key",
"/",
"value",
"pairs",
"to",
"a",
"multi",
"-",
"line",
"string",
"(",
"one",
"line",
"per",
"key",
")",
".",
"Masks",
"sensitive",
"information",
"for",
"a",
"predefined",
"set",
"of",
"header",
"keys",
"."
] | train | https://github.com/googleads/googleads-java-lib/blob/967957cc4f6076514e3a7926fe653e4f1f7cc9c9/modules/ads_lib/src/main/java/com/google/api/ads/adwords/lib/utils/logging/ReportServiceLogger.java#L180-L190 |
ops4j/org.ops4j.base | ops4j-base-util-collections/src/main/java/org/ops4j/util/collections/PropertiesUtils.java | PropertiesUtils.readProperties | public static Properties readProperties( InputStream stream, Properties mappings, boolean closeStream )
throws IOException {
"""
Read a set of properties from a property file provided as an Inputstream.
<p/>
Property files may reference symbolic properties in the form ${name}. Translations occur from both the
<code>mappings</code> properties as well as all values within the Properties that are being read.
</p>
<p/>
Example;
</p>
<code><pre>
Properties mappings = System.getProperties();
Properties myProps = PropertiesUtils.readProperties( "mine.properties", mappings );
</pre></code>
<p/>
and the "mine.properties" file contains;
</p>
<code><pre>
mything=${myplace}/mything
myplace=${user.home}/myplace
</pre></code>
<p/>
then the Properties object <i>myProps</i> will contain;
</p>
<code><pre>
mything=/home/niclas/myplace/mything
myplace=/home/niclas/myplace
</pre></code>
@param stream the InputStream of the property file to read.
@param mappings Properties that will be available for translations initially.
@param closeStream true if the method should close the stream before returning, false otherwise.
@return the resolved properties.
@throws IOException if an io error occurs
"""
try
{
Properties p = new Properties();
p.load( stream );
mappings.putAll( p );
boolean doAgain = true;
while( doAgain )
{
doAgain = false;
for( Map.Entry<Object, Object> entry : p.entrySet() )
{
String value = (String) entry.getValue();
if( value.indexOf( "${" ) >= 0 )
{
value = resolveProperty( mappings, value );
entry.setValue( value );
doAgain = true;
}
}
}
return p;
}
finally
{
if( closeStream )
{
stream.close();
}
}
} | java | public static Properties readProperties( InputStream stream, Properties mappings, boolean closeStream )
throws IOException
{
try
{
Properties p = new Properties();
p.load( stream );
mappings.putAll( p );
boolean doAgain = true;
while( doAgain )
{
doAgain = false;
for( Map.Entry<Object, Object> entry : p.entrySet() )
{
String value = (String) entry.getValue();
if( value.indexOf( "${" ) >= 0 )
{
value = resolveProperty( mappings, value );
entry.setValue( value );
doAgain = true;
}
}
}
return p;
}
finally
{
if( closeStream )
{
stream.close();
}
}
} | [
"public",
"static",
"Properties",
"readProperties",
"(",
"InputStream",
"stream",
",",
"Properties",
"mappings",
",",
"boolean",
"closeStream",
")",
"throws",
"IOException",
"{",
"try",
"{",
"Properties",
"p",
"=",
"new",
"Properties",
"(",
")",
";",
"p",
".",
"load",
"(",
"stream",
")",
";",
"mappings",
".",
"putAll",
"(",
"p",
")",
";",
"boolean",
"doAgain",
"=",
"true",
";",
"while",
"(",
"doAgain",
")",
"{",
"doAgain",
"=",
"false",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Object",
",",
"Object",
">",
"entry",
":",
"p",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"value",
"=",
"(",
"String",
")",
"entry",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"value",
".",
"indexOf",
"(",
"\"${\"",
")",
">=",
"0",
")",
"{",
"value",
"=",
"resolveProperty",
"(",
"mappings",
",",
"value",
")",
";",
"entry",
".",
"setValue",
"(",
"value",
")",
";",
"doAgain",
"=",
"true",
";",
"}",
"}",
"}",
"return",
"p",
";",
"}",
"finally",
"{",
"if",
"(",
"closeStream",
")",
"{",
"stream",
".",
"close",
"(",
")",
";",
"}",
"}",
"}"
] | Read a set of properties from a property file provided as an Inputstream.
<p/>
Property files may reference symbolic properties in the form ${name}. Translations occur from both the
<code>mappings</code> properties as well as all values within the Properties that are being read.
</p>
<p/>
Example;
</p>
<code><pre>
Properties mappings = System.getProperties();
Properties myProps = PropertiesUtils.readProperties( "mine.properties", mappings );
</pre></code>
<p/>
and the "mine.properties" file contains;
</p>
<code><pre>
mything=${myplace}/mything
myplace=${user.home}/myplace
</pre></code>
<p/>
then the Properties object <i>myProps</i> will contain;
</p>
<code><pre>
mything=/home/niclas/myplace/mything
myplace=/home/niclas/myplace
</pre></code>
@param stream the InputStream of the property file to read.
@param mappings Properties that will be available for translations initially.
@param closeStream true if the method should close the stream before returning, false otherwise.
@return the resolved properties.
@throws IOException if an io error occurs | [
"Read",
"a",
"set",
"of",
"properties",
"from",
"a",
"property",
"file",
"provided",
"as",
"an",
"Inputstream",
".",
"<p",
"/",
">",
"Property",
"files",
"may",
"reference",
"symbolic",
"properties",
"in",
"the",
"form",
"$",
"{",
"name",
"}",
".",
"Translations",
"occur",
"from",
"both",
"the",
"<code",
">",
"mappings<",
"/",
"code",
">",
"properties",
"as",
"well",
"as",
"all",
"values",
"within",
"the",
"Properties",
"that",
"are",
"being",
"read",
".",
"<",
"/",
"p",
">",
"<p",
"/",
">",
"Example",
";",
"<",
"/",
"p",
">",
"<code",
">",
"<pre",
">",
"Properties",
"mappings",
"=",
"System",
".",
"getProperties",
"()",
";",
"Properties",
"myProps",
"=",
"PropertiesUtils",
".",
"readProperties",
"(",
"mine",
".",
"properties",
"mappings",
")",
";",
"<",
"/",
"pre",
">",
"<",
"/",
"code",
">",
"<p",
"/",
">",
"and",
"the",
"mine",
".",
"properties",
"file",
"contains",
";",
"<",
"/",
"p",
">",
"<code",
">",
"<pre",
">",
"mything",
"=",
"$",
"{",
"myplace",
"}",
"/",
"mything",
"myplace",
"=",
"$",
"{",
"user",
".",
"home",
"}",
"/",
"myplace",
"<",
"/",
"pre",
">",
"<",
"/",
"code",
">",
"<p",
"/",
">",
"then",
"the",
"Properties",
"object",
"<i",
">",
"myProps<",
"/",
"i",
">",
"will",
"contain",
";",
"<",
"/",
"p",
">",
"<code",
">",
"<pre",
">",
"mything",
"=",
"/",
"home",
"/",
"niclas",
"/",
"myplace",
"/",
"mything",
"myplace",
"=",
"/",
"home",
"/",
"niclas",
"/",
"myplace",
"<",
"/",
"pre",
">",
"<",
"/",
"code",
">"
] | train | https://github.com/ops4j/org.ops4j.base/blob/b0e742c0d9511f6b19ca64da2ebaf30b7a47256a/ops4j-base-util-collections/src/main/java/org/ops4j/util/collections/PropertiesUtils.java#L97-L129 |
aalmiray/Json-lib | src/main/java/net/sf/json/JSONSerializer.java | JSONSerializer.toJava | public static Object toJava( JSON json, JsonConfig jsonConfig ) {
"""
Transform a JSON value to a java object.<br>
Depending on the configured values for conversion this will return a
DynaBean, a bean, a List, or and array.
@param json a JSON value
@param jsonConfig additional configuration
@return depends on the nature of the source object (JSONObject, JSONArray,
JSONNull) and the configured rootClass, classMap and arrayMode
"""
if( JSONUtils.isNull( json ) ){
return null;
}
Object object = null;
if( json instanceof JSONArray ){
if( jsonConfig.getArrayMode() == JsonConfig.MODE_OBJECT_ARRAY ){
object = JSONArray.toArray( (JSONArray) json, jsonConfig );
}else{
object = JSONArray.toCollection( (JSONArray) json, jsonConfig );
}
}else{
object = JSONObject.toBean( (JSONObject) json, jsonConfig );
}
return object;
} | java | public static Object toJava( JSON json, JsonConfig jsonConfig ) {
if( JSONUtils.isNull( json ) ){
return null;
}
Object object = null;
if( json instanceof JSONArray ){
if( jsonConfig.getArrayMode() == JsonConfig.MODE_OBJECT_ARRAY ){
object = JSONArray.toArray( (JSONArray) json, jsonConfig );
}else{
object = JSONArray.toCollection( (JSONArray) json, jsonConfig );
}
}else{
object = JSONObject.toBean( (JSONObject) json, jsonConfig );
}
return object;
} | [
"public",
"static",
"Object",
"toJava",
"(",
"JSON",
"json",
",",
"JsonConfig",
"jsonConfig",
")",
"{",
"if",
"(",
"JSONUtils",
".",
"isNull",
"(",
"json",
")",
")",
"{",
"return",
"null",
";",
"}",
"Object",
"object",
"=",
"null",
";",
"if",
"(",
"json",
"instanceof",
"JSONArray",
")",
"{",
"if",
"(",
"jsonConfig",
".",
"getArrayMode",
"(",
")",
"==",
"JsonConfig",
".",
"MODE_OBJECT_ARRAY",
")",
"{",
"object",
"=",
"JSONArray",
".",
"toArray",
"(",
"(",
"JSONArray",
")",
"json",
",",
"jsonConfig",
")",
";",
"}",
"else",
"{",
"object",
"=",
"JSONArray",
".",
"toCollection",
"(",
"(",
"JSONArray",
")",
"json",
",",
"jsonConfig",
")",
";",
"}",
"}",
"else",
"{",
"object",
"=",
"JSONObject",
".",
"toBean",
"(",
"(",
"JSONObject",
")",
"json",
",",
"jsonConfig",
")",
";",
"}",
"return",
"object",
";",
"}"
] | Transform a JSON value to a java object.<br>
Depending on the configured values for conversion this will return a
DynaBean, a bean, a List, or and array.
@param json a JSON value
@param jsonConfig additional configuration
@return depends on the nature of the source object (JSONObject, JSONArray,
JSONNull) and the configured rootClass, classMap and arrayMode | [
"Transform",
"a",
"JSON",
"value",
"to",
"a",
"java",
"object",
".",
"<br",
">",
"Depending",
"on",
"the",
"configured",
"values",
"for",
"conversion",
"this",
"will",
"return",
"a",
"DynaBean",
"a",
"bean",
"a",
"List",
"or",
"and",
"array",
"."
] | train | https://github.com/aalmiray/Json-lib/blob/9e2b3376ee8f511a48aa7ac05f75a7414e02280f/src/main/java/net/sf/json/JSONSerializer.java#L55-L73 |
lets-blade/blade | src/main/java/com/blade/mvc/RouteContext.java | RouteContext.queryLong | public Long queryLong(String paramName, Long defaultValue) {
"""
Returns a request parameter for a Long type
@param paramName Parameter name
@param defaultValue default long value
@return Return Long parameter values
"""
return this.request.queryLong(paramName, defaultValue);
} | java | public Long queryLong(String paramName, Long defaultValue) {
return this.request.queryLong(paramName, defaultValue);
} | [
"public",
"Long",
"queryLong",
"(",
"String",
"paramName",
",",
"Long",
"defaultValue",
")",
"{",
"return",
"this",
".",
"request",
".",
"queryLong",
"(",
"paramName",
",",
"defaultValue",
")",
";",
"}"
] | Returns a request parameter for a Long type
@param paramName Parameter name
@param defaultValue default long value
@return Return Long parameter values | [
"Returns",
"a",
"request",
"parameter",
"for",
"a",
"Long",
"type"
] | train | https://github.com/lets-blade/blade/blob/60624ee528be12122c49a9ad1713e336b959e59a/src/main/java/com/blade/mvc/RouteContext.java#L215-L217 |
doubledutch/LazyJSON | src/main/java/me/doubledutch/lazyjson/LazyNode.java | LazyNode.getDoubleValue | protected double getDoubleValue() throws LazyException {
"""
Parses the characters of this token and attempts to construct a double
value from them.
@return the double value if it could be parsed
@throws LazyException if the value could not be parsed
"""
double d=0.0;
String str=getStringValue();
try{
d=Double.parseDouble(str);
}catch(NumberFormatException nfe){
// This basically can't happen since we already validate the numeric format when parsing
// throw new LazyException("'"+str+"' is not a valid double",startIndex);
}
return d;
} | java | protected double getDoubleValue() throws LazyException{
double d=0.0;
String str=getStringValue();
try{
d=Double.parseDouble(str);
}catch(NumberFormatException nfe){
// This basically can't happen since we already validate the numeric format when parsing
// throw new LazyException("'"+str+"' is not a valid double",startIndex);
}
return d;
} | [
"protected",
"double",
"getDoubleValue",
"(",
")",
"throws",
"LazyException",
"{",
"double",
"d",
"=",
"0.0",
";",
"String",
"str",
"=",
"getStringValue",
"(",
")",
";",
"try",
"{",
"d",
"=",
"Double",
".",
"parseDouble",
"(",
"str",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"nfe",
")",
"{",
"// This basically can't happen since we already validate the numeric format when parsing",
"// throw new LazyException(\"'\"+str+\"' is not a valid double\",startIndex);",
"}",
"return",
"d",
";",
"}"
] | Parses the characters of this token and attempts to construct a double
value from them.
@return the double value if it could be parsed
@throws LazyException if the value could not be parsed | [
"Parses",
"the",
"characters",
"of",
"this",
"token",
"and",
"attempts",
"to",
"construct",
"a",
"double",
"value",
"from",
"them",
"."
] | train | https://github.com/doubledutch/LazyJSON/blob/1a223f57fc0cb9941bc175739697ac95da5618cc/src/main/java/me/doubledutch/lazyjson/LazyNode.java#L386-L396 |
Wadpam/guja | guja-core/src/main/java/com/wadpam/guja/oauth2/dao/GeneratedDUserDaoImpl.java | GeneratedDUserDaoImpl.queryByAddress2 | public Iterable<DUser> queryByAddress2(java.lang.String address2) {
"""
query-by method for field address2
@param address2 the specified attribute
@return an Iterable of DUsers for the specified address2
"""
return queryByField(null, DUserMapper.Field.ADDRESS2.getFieldName(), address2);
} | java | public Iterable<DUser> queryByAddress2(java.lang.String address2) {
return queryByField(null, DUserMapper.Field.ADDRESS2.getFieldName(), address2);
} | [
"public",
"Iterable",
"<",
"DUser",
">",
"queryByAddress2",
"(",
"java",
".",
"lang",
".",
"String",
"address2",
")",
"{",
"return",
"queryByField",
"(",
"null",
",",
"DUserMapper",
".",
"Field",
".",
"ADDRESS2",
".",
"getFieldName",
"(",
")",
",",
"address2",
")",
";",
"}"
] | query-by method for field address2
@param address2 the specified attribute
@return an Iterable of DUsers for the specified address2 | [
"query",
"-",
"by",
"method",
"for",
"field",
"address2"
] | train | https://github.com/Wadpam/guja/blob/eb8ba8e6794a96ea0dd9744cada4f9ad9618f114/guja-core/src/main/java/com/wadpam/guja/oauth2/dao/GeneratedDUserDaoImpl.java#L79-L81 |
cycorp/api-suite | core-api/src/main/java/com/cyc/session/exception/SessionManagerConfigurationException.java | SessionManagerConfigurationException.fromThrowable | public static SessionManagerConfigurationException fromThrowable(String message, Throwable cause) {
"""
Converts a Throwable to a SessionManagerConfigurationException with the specified detail message. If the
Throwable is a SessionManagerConfigurationException and if the Throwable's message is identical to the
one supplied, the Throwable will be passed through unmodified; otherwise, it will be wrapped in
a new SessionManagerConfigurationException with the detail message.
@param cause the Throwable to convert
@param message the specified detail message
@return a SessionManagerConfigurationException
"""
return (cause instanceof SessionManagerConfigurationException && Objects.equals(message, cause.getMessage()))
? (SessionManagerConfigurationException) cause
: new SessionManagerConfigurationException(message, cause);
} | java | public static SessionManagerConfigurationException fromThrowable(String message, Throwable cause) {
return (cause instanceof SessionManagerConfigurationException && Objects.equals(message, cause.getMessage()))
? (SessionManagerConfigurationException) cause
: new SessionManagerConfigurationException(message, cause);
} | [
"public",
"static",
"SessionManagerConfigurationException",
"fromThrowable",
"(",
"String",
"message",
",",
"Throwable",
"cause",
")",
"{",
"return",
"(",
"cause",
"instanceof",
"SessionManagerConfigurationException",
"&&",
"Objects",
".",
"equals",
"(",
"message",
",",
"cause",
".",
"getMessage",
"(",
")",
")",
")",
"?",
"(",
"SessionManagerConfigurationException",
")",
"cause",
":",
"new",
"SessionManagerConfigurationException",
"(",
"message",
",",
"cause",
")",
";",
"}"
] | Converts a Throwable to a SessionManagerConfigurationException with the specified detail message. If the
Throwable is a SessionManagerConfigurationException and if the Throwable's message is identical to the
one supplied, the Throwable will be passed through unmodified; otherwise, it will be wrapped in
a new SessionManagerConfigurationException with the detail message.
@param cause the Throwable to convert
@param message the specified detail message
@return a SessionManagerConfigurationException | [
"Converts",
"a",
"Throwable",
"to",
"a",
"SessionManagerConfigurationException",
"with",
"the",
"specified",
"detail",
"message",
".",
"If",
"the",
"Throwable",
"is",
"a",
"SessionManagerConfigurationException",
"and",
"if",
"the",
"Throwable",
"s",
"message",
"is",
"identical",
"to",
"the",
"one",
"supplied",
"the",
"Throwable",
"will",
"be",
"passed",
"through",
"unmodified",
";",
"otherwise",
"it",
"will",
"be",
"wrapped",
"in",
"a",
"new",
"SessionManagerConfigurationException",
"with",
"the",
"detail",
"message",
"."
] | train | https://github.com/cycorp/api-suite/blob/1d52affabc4635e3715a059e38741712cbdbf2d5/core-api/src/main/java/com/cyc/session/exception/SessionManagerConfigurationException.java#L63-L67 |
networknt/light-4j | handler/src/main/java/com/networknt/handler/Handler.java | Handler.getNext | public static HttpHandler getNext(HttpServerExchange httpServerExchange, HttpHandler next) throws Exception {
"""
Returns the instance of the next handler, or the given next param if it's not
null.
@param httpServerExchange
The current requests server exchange.
@param next
If not null, return this.
@return The next handler in the chain, or next if it's not null.
@throws Exception exception
"""
if (next != null) {
return next;
}
return getNext(httpServerExchange);
} | java | public static HttpHandler getNext(HttpServerExchange httpServerExchange, HttpHandler next) throws Exception {
if (next != null) {
return next;
}
return getNext(httpServerExchange);
} | [
"public",
"static",
"HttpHandler",
"getNext",
"(",
"HttpServerExchange",
"httpServerExchange",
",",
"HttpHandler",
"next",
")",
"throws",
"Exception",
"{",
"if",
"(",
"next",
"!=",
"null",
")",
"{",
"return",
"next",
";",
"}",
"return",
"getNext",
"(",
"httpServerExchange",
")",
";",
"}"
] | Returns the instance of the next handler, or the given next param if it's not
null.
@param httpServerExchange
The current requests server exchange.
@param next
If not null, return this.
@return The next handler in the chain, or next if it's not null.
@throws Exception exception | [
"Returns",
"the",
"instance",
"of",
"the",
"next",
"handler",
"or",
"the",
"given",
"next",
"param",
"if",
"it",
"s",
"not",
"null",
"."
] | train | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/handler/src/main/java/com/networknt/handler/Handler.java#L295-L300 |
VoltDB/voltdb | third_party/java/src/org/apache/zookeeper_voltpatches/ZooKeeper.java | ZooKeeper.getData | public void getData(final String path, Watcher watcher, DataCallback cb,
Object ctx) {
"""
The Asynchronous version of getData. The request doesn't actually until
the asynchronous callback is called.
@see #getData(String, Watcher, Stat)
"""
verbotenThreadCheck();
final String clientPath = path;
PathUtils.validatePath(clientPath);
// the watch contains the un-chroot path
WatchRegistration wcb = null;
if (watcher != null) {
wcb = new DataWatchRegistration(watcher, clientPath);
}
final String serverPath = prependChroot(clientPath);
RequestHeader h = new RequestHeader();
h.setType(ZooDefs.OpCode.getData);
GetDataRequest request = new GetDataRequest();
request.setPath(serverPath);
request.setWatch(watcher != null);
GetDataResponse response = new GetDataResponse();
cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
clientPath, serverPath, ctx, wcb);
} | java | public void getData(final String path, Watcher watcher, DataCallback cb,
Object ctx) {
verbotenThreadCheck();
final String clientPath = path;
PathUtils.validatePath(clientPath);
// the watch contains the un-chroot path
WatchRegistration wcb = null;
if (watcher != null) {
wcb = new DataWatchRegistration(watcher, clientPath);
}
final String serverPath = prependChroot(clientPath);
RequestHeader h = new RequestHeader();
h.setType(ZooDefs.OpCode.getData);
GetDataRequest request = new GetDataRequest();
request.setPath(serverPath);
request.setWatch(watcher != null);
GetDataResponse response = new GetDataResponse();
cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
clientPath, serverPath, ctx, wcb);
} | [
"public",
"void",
"getData",
"(",
"final",
"String",
"path",
",",
"Watcher",
"watcher",
",",
"DataCallback",
"cb",
",",
"Object",
"ctx",
")",
"{",
"verbotenThreadCheck",
"(",
")",
";",
"final",
"String",
"clientPath",
"=",
"path",
";",
"PathUtils",
".",
"validatePath",
"(",
"clientPath",
")",
";",
"// the watch contains the un-chroot path",
"WatchRegistration",
"wcb",
"=",
"null",
";",
"if",
"(",
"watcher",
"!=",
"null",
")",
"{",
"wcb",
"=",
"new",
"DataWatchRegistration",
"(",
"watcher",
",",
"clientPath",
")",
";",
"}",
"final",
"String",
"serverPath",
"=",
"prependChroot",
"(",
"clientPath",
")",
";",
"RequestHeader",
"h",
"=",
"new",
"RequestHeader",
"(",
")",
";",
"h",
".",
"setType",
"(",
"ZooDefs",
".",
"OpCode",
".",
"getData",
")",
";",
"GetDataRequest",
"request",
"=",
"new",
"GetDataRequest",
"(",
")",
";",
"request",
".",
"setPath",
"(",
"serverPath",
")",
";",
"request",
".",
"setWatch",
"(",
"watcher",
"!=",
"null",
")",
";",
"GetDataResponse",
"response",
"=",
"new",
"GetDataResponse",
"(",
")",
";",
"cnxn",
".",
"queuePacket",
"(",
"h",
",",
"new",
"ReplyHeader",
"(",
")",
",",
"request",
",",
"response",
",",
"cb",
",",
"clientPath",
",",
"serverPath",
",",
"ctx",
",",
"wcb",
")",
";",
"}"
] | The Asynchronous version of getData. The request doesn't actually until
the asynchronous callback is called.
@see #getData(String, Watcher, Stat) | [
"The",
"Asynchronous",
"version",
"of",
"getData",
".",
"The",
"request",
"doesn",
"t",
"actually",
"until",
"the",
"asynchronous",
"callback",
"is",
"called",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/zookeeper_voltpatches/ZooKeeper.java#L1009-L1031 |
google/error-prone | core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/GuardedByChecker.java | GuardedByChecker.isRWLock | private static boolean isRWLock(GuardedByExpression guard, VisitorState state) {
"""
Returns true if the lock expression corresponds to a {@code
java.util.concurrent.locks.ReadWriteLock}.
"""
Type guardType = guard.type();
if (guardType == null) {
return false;
}
Symbol rwLockSymbol = state.getSymbolFromString(JUC_READ_WRITE_LOCK);
if (rwLockSymbol == null) {
return false;
}
return state.getTypes().isSubtype(guardType, rwLockSymbol.type);
} | java | private static boolean isRWLock(GuardedByExpression guard, VisitorState state) {
Type guardType = guard.type();
if (guardType == null) {
return false;
}
Symbol rwLockSymbol = state.getSymbolFromString(JUC_READ_WRITE_LOCK);
if (rwLockSymbol == null) {
return false;
}
return state.getTypes().isSubtype(guardType, rwLockSymbol.type);
} | [
"private",
"static",
"boolean",
"isRWLock",
"(",
"GuardedByExpression",
"guard",
",",
"VisitorState",
"state",
")",
"{",
"Type",
"guardType",
"=",
"guard",
".",
"type",
"(",
")",
";",
"if",
"(",
"guardType",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"Symbol",
"rwLockSymbol",
"=",
"state",
".",
"getSymbolFromString",
"(",
"JUC_READ_WRITE_LOCK",
")",
";",
"if",
"(",
"rwLockSymbol",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"state",
".",
"getTypes",
"(",
")",
".",
"isSubtype",
"(",
"guardType",
",",
"rwLockSymbol",
".",
"type",
")",
";",
"}"
] | Returns true if the lock expression corresponds to a {@code
java.util.concurrent.locks.ReadWriteLock}. | [
"Returns",
"true",
"if",
"the",
"lock",
"expression",
"corresponds",
"to",
"a",
"{"
] | train | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/GuardedByChecker.java#L191-L203 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSetSpanner.java | UnicodeSetSpanner.replaceFrom | public String replaceFrom(CharSequence sequence, CharSequence replacement) {
"""
Replace all matching spans in sequence by the replacement,
counting by CountMethod.MIN_ELEMENTS using SpanCondition.SIMPLE.
The code alternates spans; see the class doc for {@link UnicodeSetSpanner} for a note about boundary conditions.
@param sequence
charsequence to replace matching spans in.
@param replacement
replacement sequence. To delete, use ""
@return modified string.
"""
return replaceFrom(sequence, replacement, CountMethod.MIN_ELEMENTS, SpanCondition.SIMPLE);
} | java | public String replaceFrom(CharSequence sequence, CharSequence replacement) {
return replaceFrom(sequence, replacement, CountMethod.MIN_ELEMENTS, SpanCondition.SIMPLE);
} | [
"public",
"String",
"replaceFrom",
"(",
"CharSequence",
"sequence",
",",
"CharSequence",
"replacement",
")",
"{",
"return",
"replaceFrom",
"(",
"sequence",
",",
"replacement",
",",
"CountMethod",
".",
"MIN_ELEMENTS",
",",
"SpanCondition",
".",
"SIMPLE",
")",
";",
"}"
] | Replace all matching spans in sequence by the replacement,
counting by CountMethod.MIN_ELEMENTS using SpanCondition.SIMPLE.
The code alternates spans; see the class doc for {@link UnicodeSetSpanner} for a note about boundary conditions.
@param sequence
charsequence to replace matching spans in.
@param replacement
replacement sequence. To delete, use ""
@return modified string. | [
"Replace",
"all",
"matching",
"spans",
"in",
"sequence",
"by",
"the",
"replacement",
"counting",
"by",
"CountMethod",
".",
"MIN_ELEMENTS",
"using",
"SpanCondition",
".",
"SIMPLE",
".",
"The",
"code",
"alternates",
"spans",
";",
"see",
"the",
"class",
"doc",
"for",
"{"
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSetSpanner.java#L208-L210 |
google/gson | gson/src/main/java/com/google/gson/Gson.java | Gson.fromJson | @SuppressWarnings("unchecked")
public <T> T fromJson(Reader json, Type typeOfT) throws JsonIOException, JsonSyntaxException {
"""
This method deserializes the Json read from the specified reader into an object of the
specified type. This method is useful if the specified object is a generic type. For
non-generic objects, use {@link #fromJson(Reader, Class)} instead. If you have the Json in a
String form instead of a {@link Reader}, use {@link #fromJson(String, Type)} instead.
@param <T> the type of the desired object
@param json the reader producing Json from which the object is to be deserialized
@param typeOfT The specific genericized type of src. You can obtain this type by using the
{@link com.google.gson.reflect.TypeToken} class. For example, to get the type for
{@code Collection<Foo>}, you should use:
<pre>
Type typeOfT = new TypeToken<Collection<Foo>>(){}.getType();
</pre>
@return an object of type T from the json. Returns {@code null} if {@code json} is at EOF.
@throws JsonIOException if there was a problem reading from the Reader
@throws JsonSyntaxException if json is not a valid representation for an object of type
@since 1.2
"""
JsonReader jsonReader = newJsonReader(json);
T object = (T) fromJson(jsonReader, typeOfT);
assertFullConsumption(object, jsonReader);
return object;
} | java | @SuppressWarnings("unchecked")
public <T> T fromJson(Reader json, Type typeOfT) throws JsonIOException, JsonSyntaxException {
JsonReader jsonReader = newJsonReader(json);
T object = (T) fromJson(jsonReader, typeOfT);
assertFullConsumption(object, jsonReader);
return object;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"T",
">",
"T",
"fromJson",
"(",
"Reader",
"json",
",",
"Type",
"typeOfT",
")",
"throws",
"JsonIOException",
",",
"JsonSyntaxException",
"{",
"JsonReader",
"jsonReader",
"=",
"newJsonReader",
"(",
"json",
")",
";",
"T",
"object",
"=",
"(",
"T",
")",
"fromJson",
"(",
"jsonReader",
",",
"typeOfT",
")",
";",
"assertFullConsumption",
"(",
"object",
",",
"jsonReader",
")",
";",
"return",
"object",
";",
"}"
] | This method deserializes the Json read from the specified reader into an object of the
specified type. This method is useful if the specified object is a generic type. For
non-generic objects, use {@link #fromJson(Reader, Class)} instead. If you have the Json in a
String form instead of a {@link Reader}, use {@link #fromJson(String, Type)} instead.
@param <T> the type of the desired object
@param json the reader producing Json from which the object is to be deserialized
@param typeOfT The specific genericized type of src. You can obtain this type by using the
{@link com.google.gson.reflect.TypeToken} class. For example, to get the type for
{@code Collection<Foo>}, you should use:
<pre>
Type typeOfT = new TypeToken<Collection<Foo>>(){}.getType();
</pre>
@return an object of type T from the json. Returns {@code null} if {@code json} is at EOF.
@throws JsonIOException if there was a problem reading from the Reader
@throws JsonSyntaxException if json is not a valid representation for an object of type
@since 1.2 | [
"This",
"method",
"deserializes",
"the",
"Json",
"read",
"from",
"the",
"specified",
"reader",
"into",
"an",
"object",
"of",
"the",
"specified",
"type",
".",
"This",
"method",
"is",
"useful",
"if",
"the",
"specified",
"object",
"is",
"a",
"generic",
"type",
".",
"For",
"non",
"-",
"generic",
"objects",
"use",
"{",
"@link",
"#fromJson",
"(",
"Reader",
"Class",
")",
"}",
"instead",
".",
"If",
"you",
"have",
"the",
"Json",
"in",
"a",
"String",
"form",
"instead",
"of",
"a",
"{",
"@link",
"Reader",
"}",
"use",
"{",
"@link",
"#fromJson",
"(",
"String",
"Type",
")",
"}",
"instead",
"."
] | train | https://github.com/google/gson/blob/63ee47cb642c8018e5cddd639aa2be143220ad4b/gson/src/main/java/com/google/gson/Gson.java#L894-L900 |
voldemort/voldemort | src/java/voldemort/client/ClientConfig.java | ClientConfig.setNodeBannagePeriod | @Deprecated
public ClientConfig setNodeBannagePeriod(int nodeBannagePeriod, TimeUnit unit) {
"""
The period of time to ban a node that gives an error on an operation.
@param nodeBannagePeriod The period of time to ban the node
@param unit The time unit of the given value
@deprecated Use {@link #setFailureDetectorBannagePeriod(long)} instead
"""
this.failureDetectorBannagePeriod = unit.toMillis(nodeBannagePeriod);
return this;
} | java | @Deprecated
public ClientConfig setNodeBannagePeriod(int nodeBannagePeriod, TimeUnit unit) {
this.failureDetectorBannagePeriod = unit.toMillis(nodeBannagePeriod);
return this;
} | [
"@",
"Deprecated",
"public",
"ClientConfig",
"setNodeBannagePeriod",
"(",
"int",
"nodeBannagePeriod",
",",
"TimeUnit",
"unit",
")",
"{",
"this",
".",
"failureDetectorBannagePeriod",
"=",
"unit",
".",
"toMillis",
"(",
"nodeBannagePeriod",
")",
";",
"return",
"this",
";",
"}"
] | The period of time to ban a node that gives an error on an operation.
@param nodeBannagePeriod The period of time to ban the node
@param unit The time unit of the given value
@deprecated Use {@link #setFailureDetectorBannagePeriod(long)} instead | [
"The",
"period",
"of",
"time",
"to",
"ban",
"a",
"node",
"that",
"gives",
"an",
"error",
"on",
"an",
"operation",
"."
] | train | https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/client/ClientConfig.java#L721-L725 |
OpenLiberty/open-liberty | dev/com.ibm.ws.security.social/src/com/ibm/ws/security/social/twitter/TwitterEndpointServices.java | TwitterEndpointServices.createAuthzHeaderForRequestTokenEndpoint | public String createAuthzHeaderForRequestTokenEndpoint(String callbackUrl, String endpointUrl) {
"""
Generates the Authorization header value required for a {@value TwitterConstants#TWITTER_ENDPOINT_REQUEST_TOKEN} endpoint
request. See {@link https://dev.twitter.com/oauth/reference/post/oauth/request_token} for details.
@param callbackUrl
@param endpointUrl
@return
"""
Map<String, String> parameters = populateRequestTokenEndpointAuthzHeaderParams(callbackUrl);
return signAndCreateAuthzHeader(endpointUrl, parameters);
} | java | public String createAuthzHeaderForRequestTokenEndpoint(String callbackUrl, String endpointUrl) {
Map<String, String> parameters = populateRequestTokenEndpointAuthzHeaderParams(callbackUrl);
return signAndCreateAuthzHeader(endpointUrl, parameters);
} | [
"public",
"String",
"createAuthzHeaderForRequestTokenEndpoint",
"(",
"String",
"callbackUrl",
",",
"String",
"endpointUrl",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"parameters",
"=",
"populateRequestTokenEndpointAuthzHeaderParams",
"(",
"callbackUrl",
")",
";",
"return",
"signAndCreateAuthzHeader",
"(",
"endpointUrl",
",",
"parameters",
")",
";",
"}"
] | Generates the Authorization header value required for a {@value TwitterConstants#TWITTER_ENDPOINT_REQUEST_TOKEN} endpoint
request. See {@link https://dev.twitter.com/oauth/reference/post/oauth/request_token} for details.
@param callbackUrl
@param endpointUrl
@return | [
"Generates",
"the",
"Authorization",
"header",
"value",
"required",
"for",
"a",
"{",
"@value",
"TwitterConstants#TWITTER_ENDPOINT_REQUEST_TOKEN",
"}",
"endpoint",
"request",
".",
"See",
"{",
"@link",
"https",
":",
"//",
"dev",
".",
"twitter",
".",
"com",
"/",
"oauth",
"/",
"reference",
"/",
"post",
"/",
"oauth",
"/",
"request_token",
"}",
"for",
"details",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.social/src/com/ibm/ws/security/social/twitter/TwitterEndpointServices.java#L425-L428 |
zaproxy/zaproxy | src/org/parosproxy/paros/view/WorkbenchPanel.java | WorkbenchPanel.addPanels | private static void addPanels(TabbedPanel2 tabbedPanel, List<AbstractPanel> panels, boolean visible) {
"""
Adds the given {@code panels} to the given {@code tabbedPanel} and whether they should be visible.
<p>
After adding all the panels the tabbed panel is revalidated.
@param tabbedPanel the tabbed panel to add the panels
@param panels the panels to add
@param visible {@code true} if the panel should be visible, {@code false} otherwise.
@see #addPanel(TabbedPanel2, AbstractPanel, boolean)
@see javax.swing.JComponent#revalidate()
"""
for (AbstractPanel panel : panels) {
addPanel(tabbedPanel, panel, visible);
}
tabbedPanel.revalidate();
} | java | private static void addPanels(TabbedPanel2 tabbedPanel, List<AbstractPanel> panels, boolean visible) {
for (AbstractPanel panel : panels) {
addPanel(tabbedPanel, panel, visible);
}
tabbedPanel.revalidate();
} | [
"private",
"static",
"void",
"addPanels",
"(",
"TabbedPanel2",
"tabbedPanel",
",",
"List",
"<",
"AbstractPanel",
">",
"panels",
",",
"boolean",
"visible",
")",
"{",
"for",
"(",
"AbstractPanel",
"panel",
":",
"panels",
")",
"{",
"addPanel",
"(",
"tabbedPanel",
",",
"panel",
",",
"visible",
")",
";",
"}",
"tabbedPanel",
".",
"revalidate",
"(",
")",
";",
"}"
] | Adds the given {@code panels} to the given {@code tabbedPanel} and whether they should be visible.
<p>
After adding all the panels the tabbed panel is revalidated.
@param tabbedPanel the tabbed panel to add the panels
@param panels the panels to add
@param visible {@code true} if the panel should be visible, {@code false} otherwise.
@see #addPanel(TabbedPanel2, AbstractPanel, boolean)
@see javax.swing.JComponent#revalidate() | [
"Adds",
"the",
"given",
"{",
"@code",
"panels",
"}",
"to",
"the",
"given",
"{",
"@code",
"tabbedPanel",
"}",
"and",
"whether",
"they",
"should",
"be",
"visible",
".",
"<p",
">",
"After",
"adding",
"all",
"the",
"panels",
"the",
"tabbed",
"panel",
"is",
"revalidated",
"."
] | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/parosproxy/paros/view/WorkbenchPanel.java#L878-L883 |
googleapis/google-cloud-java | google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminClient.java | BigtableInstanceAdminClient.create | public static BigtableInstanceAdminClient create(
@Nonnull String projectId, @Nonnull BigtableInstanceAdminStub stub) {
"""
Constructs an instance of BigtableInstanceAdminClient with the given project id and stub.
"""
return new BigtableInstanceAdminClient(projectId, stub);
} | java | public static BigtableInstanceAdminClient create(
@Nonnull String projectId, @Nonnull BigtableInstanceAdminStub stub) {
return new BigtableInstanceAdminClient(projectId, stub);
} | [
"public",
"static",
"BigtableInstanceAdminClient",
"create",
"(",
"@",
"Nonnull",
"String",
"projectId",
",",
"@",
"Nonnull",
"BigtableInstanceAdminStub",
"stub",
")",
"{",
"return",
"new",
"BigtableInstanceAdminClient",
"(",
"projectId",
",",
"stub",
")",
";",
"}"
] | Constructs an instance of BigtableInstanceAdminClient with the given project id and stub. | [
"Constructs",
"an",
"instance",
"of",
"BigtableInstanceAdminClient",
"with",
"the",
"given",
"project",
"id",
"and",
"stub",
"."
] | train | https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminClient.java#L128-L131 |
JosePaumard/streams-utils | src/main/java/org/paumard/streams/StreamsUtils.java | StreamsUtils.shiftingWindowAveragingDouble | public static <E> DoubleStream shiftingWindowAveragingDouble(Stream<E> stream, int rollingFactor, ToDoubleFunction<? super E> mapper) {
"""
<p>Generates a stream that is computed from a provided stream following two steps.</p>
<p>The first steps maps this stream to an <code>DoubleStream</code> that is then rolled following
the same principle as the <code>roll()</code> method. This steps builds a <code>Stream<DoubleStream></code>.
</p>
<p>Then the <code>average()</code> method is called on each <code>DoubleStream</code> using a mapper, and a
<code>DoubleStream</code> of averages is returned.</p>
<p>The resulting stream has the same number of elements as the provided stream,
minus the size of the window width, to preserve consistency of each collection. </p>
<p>A <code>NullPointerException</code> will be thrown if the provided stream or the mapper is null.</p>
@param stream the processed stream
@param rollingFactor the size of the window to apply the collector on
@param mapper the mapper applied
@param <E> the type of the provided stream
@return a stream in which each value is the collection of the provided stream
"""
Objects.requireNonNull(stream);
Objects.requireNonNull(mapper);
DoubleStream doubleStream = stream.mapToDouble(mapper);
return shiftingWindowAveragingDouble(doubleStream, rollingFactor);
} | java | public static <E> DoubleStream shiftingWindowAveragingDouble(Stream<E> stream, int rollingFactor, ToDoubleFunction<? super E> mapper) {
Objects.requireNonNull(stream);
Objects.requireNonNull(mapper);
DoubleStream doubleStream = stream.mapToDouble(mapper);
return shiftingWindowAveragingDouble(doubleStream, rollingFactor);
} | [
"public",
"static",
"<",
"E",
">",
"DoubleStream",
"shiftingWindowAveragingDouble",
"(",
"Stream",
"<",
"E",
">",
"stream",
",",
"int",
"rollingFactor",
",",
"ToDoubleFunction",
"<",
"?",
"super",
"E",
">",
"mapper",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"stream",
")",
";",
"Objects",
".",
"requireNonNull",
"(",
"mapper",
")",
";",
"DoubleStream",
"doubleStream",
"=",
"stream",
".",
"mapToDouble",
"(",
"mapper",
")",
";",
"return",
"shiftingWindowAveragingDouble",
"(",
"doubleStream",
",",
"rollingFactor",
")",
";",
"}"
] | <p>Generates a stream that is computed from a provided stream following two steps.</p>
<p>The first steps maps this stream to an <code>DoubleStream</code> that is then rolled following
the same principle as the <code>roll()</code> method. This steps builds a <code>Stream<DoubleStream></code>.
</p>
<p>Then the <code>average()</code> method is called on each <code>DoubleStream</code> using a mapper, and a
<code>DoubleStream</code> of averages is returned.</p>
<p>The resulting stream has the same number of elements as the provided stream,
minus the size of the window width, to preserve consistency of each collection. </p>
<p>A <code>NullPointerException</code> will be thrown if the provided stream or the mapper is null.</p>
@param stream the processed stream
@param rollingFactor the size of the window to apply the collector on
@param mapper the mapper applied
@param <E> the type of the provided stream
@return a stream in which each value is the collection of the provided stream | [
"<p",
">",
"Generates",
"a",
"stream",
"that",
"is",
"computed",
"from",
"a",
"provided",
"stream",
"following",
"two",
"steps",
".",
"<",
"/",
"p",
">",
"<p",
">",
"The",
"first",
"steps",
"maps",
"this",
"stream",
"to",
"an",
"<code",
">",
"DoubleStream<",
"/",
"code",
">",
"that",
"is",
"then",
"rolled",
"following",
"the",
"same",
"principle",
"as",
"the",
"<code",
">",
"roll",
"()",
"<",
"/",
"code",
">",
"method",
".",
"This",
"steps",
"builds",
"a",
"<code",
">",
"Stream<",
";",
"DoubleStream>",
";",
"<",
"/",
"code",
">",
".",
"<",
"/",
"p",
">",
"<p",
">",
"Then",
"the",
"<code",
">",
"average",
"()",
"<",
"/",
"code",
">",
"method",
"is",
"called",
"on",
"each",
"<code",
">",
"DoubleStream<",
"/",
"code",
">",
"using",
"a",
"mapper",
"and",
"a",
"<code",
">",
"DoubleStream<",
"/",
"code",
">",
"of",
"averages",
"is",
"returned",
".",
"<",
"/",
"p",
">",
"<p",
">",
"The",
"resulting",
"stream",
"has",
"the",
"same",
"number",
"of",
"elements",
"as",
"the",
"provided",
"stream",
"minus",
"the",
"size",
"of",
"the",
"window",
"width",
"to",
"preserve",
"consistency",
"of",
"each",
"collection",
".",
"<",
"/",
"p",
">",
"<p",
">",
"A",
"<code",
">",
"NullPointerException<",
"/",
"code",
">",
"will",
"be",
"thrown",
"if",
"the",
"provided",
"stream",
"or",
"the",
"mapper",
"is",
"null",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/JosePaumard/streams-utils/blob/56152574af0aca44c5f679761202a8f90984ab73/src/main/java/org/paumard/streams/StreamsUtils.java#L652-L658 |
PunchThrough/bean-sdk-android | sdk/src/main/java/com/punchthrough/bean/sdk/internal/upload/firmware/OADProfile.java | OADProfile.writeToCharacteristic | private boolean writeToCharacteristic(BluetoothGattCharacteristic charc, byte[] data) {
"""
Write to a OAD characteristic
@param charc The characteristic being inspected
@return true if it's the OAD Block characteristic
"""
charc.setValue(data);
boolean result = mGattClient.writeCharacteristic(charc);
if (result) {
Log.d(TAG, "Wrote to characteristic: " + charc.getUuid() +
", data: " + Arrays.toString(data));
} else {
Log.e(TAG, "Write failed to characteristic: " + charc.getUuid() +
", data: " + Arrays.toString(data));
}
return result;
} | java | private boolean writeToCharacteristic(BluetoothGattCharacteristic charc, byte[] data) {
charc.setValue(data);
boolean result = mGattClient.writeCharacteristic(charc);
if (result) {
Log.d(TAG, "Wrote to characteristic: " + charc.getUuid() +
", data: " + Arrays.toString(data));
} else {
Log.e(TAG, "Write failed to characteristic: " + charc.getUuid() +
", data: " + Arrays.toString(data));
}
return result;
} | [
"private",
"boolean",
"writeToCharacteristic",
"(",
"BluetoothGattCharacteristic",
"charc",
",",
"byte",
"[",
"]",
"data",
")",
"{",
"charc",
".",
"setValue",
"(",
"data",
")",
";",
"boolean",
"result",
"=",
"mGattClient",
".",
"writeCharacteristic",
"(",
"charc",
")",
";",
"if",
"(",
"result",
")",
"{",
"Log",
".",
"d",
"(",
"TAG",
",",
"\"Wrote to characteristic: \"",
"+",
"charc",
".",
"getUuid",
"(",
")",
"+",
"\", data: \"",
"+",
"Arrays",
".",
"toString",
"(",
"data",
")",
")",
";",
"}",
"else",
"{",
"Log",
".",
"e",
"(",
"TAG",
",",
"\"Write failed to characteristic: \"",
"+",
"charc",
".",
"getUuid",
"(",
")",
"+",
"\", data: \"",
"+",
"Arrays",
".",
"toString",
"(",
"data",
")",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Write to a OAD characteristic
@param charc The characteristic being inspected
@return true if it's the OAD Block characteristic | [
"Write",
"to",
"a",
"OAD",
"characteristic"
] | train | https://github.com/PunchThrough/bean-sdk-android/blob/dc33e8cc9258d6e028e0788d74735c75b54d1133/sdk/src/main/java/com/punchthrough/bean/sdk/internal/upload/firmware/OADProfile.java#L317-L328 |
Netflix/conductor | common/src/main/java/com/netflix/conductor/common/utils/RetryUtil.java | RetryUtil.retryOnException | @SuppressWarnings("Guava")
public T retryOnException(Supplier<T> supplierCommand,
Predicate<Throwable> throwablePredicate,
Predicate<T> resultRetryPredicate,
int retryCount,
String shortDescription, String operationName) throws RuntimeException {
"""
A helper method which has the ability to execute a flaky supplier function and retry in case of failures.
@param supplierCommand: Any function that is flaky and needs multiple retries.
@param throwablePredicate: A Guava {@link Predicate} housing the exceptional
criteria to perform informed filtering before retrying.
@param resultRetryPredicate: a predicate to be evaluated for a valid condition of the expected result
@param retryCount: Number of times the function is to be retried before failure
@param shortDescription: A short description of the function that will be used in logging and error propagation.
The intention of this description is to provide context for Operability.
@param operationName: The name of the function for traceability in logs
@return an instance of return type of the supplierCommand
@throws RuntimeException in case of failed attempts to get T, which needs to be returned by the supplierCommand.
The instance of the returned exception has:
<ul>
<li>A message with shortDescription and operationName with the number of retries made</li>
<li>And a reference to the original exception generated during the last {@link Attempt} of the retry</li>
</ul>
"""
Retryer<T> retryer = RetryerBuilder.<T>newBuilder()
.retryIfException(Optional.ofNullable(throwablePredicate).orElse(exception -> true))
.retryIfResult(Optional.ofNullable(resultRetryPredicate).orElse(result -> false))
.withWaitStrategy(WaitStrategies.join(
WaitStrategies.exponentialWait(1000, 90, TimeUnit.SECONDS),
WaitStrategies.randomWait(100, TimeUnit.MILLISECONDS, 500, TimeUnit.MILLISECONDS)
))
.withStopStrategy(StopStrategies.stopAfterAttempt(retryCount))
.withBlockStrategy(BlockStrategies.threadSleepStrategy())
.withRetryListener(new RetryListener() {
@Override
public <V> void onRetry(Attempt<V> attempt) {
logger.debug("Attempt # {}, {} millis since first attempt. Operation: {}, description:{}",
attempt.getAttemptNumber(), attempt.getDelaySinceFirstAttempt(), operationName, shortDescription);
internalNumberOfRetries.incrementAndGet();
}
})
.build();
try {
return retryer.call(supplierCommand::get);
} catch (ExecutionException executionException) {
String errorMessage = String.format("Operation '%s:%s' failed for the %d time in RetryUtil", operationName,
shortDescription, internalNumberOfRetries.get());
logger.debug(errorMessage);
throw new RuntimeException(errorMessage, executionException.getCause());
} catch (RetryException retryException) {
String errorMessage = String.format("Operation '%s:%s' failed after retrying %d times, retry limit %d", operationName,
shortDescription, internalNumberOfRetries.get(), 3);
logger.debug(errorMessage, retryException.getLastFailedAttempt().getExceptionCause());
throw new RuntimeException(errorMessage, retryException.getLastFailedAttempt().getExceptionCause());
}
} | java | @SuppressWarnings("Guava")
public T retryOnException(Supplier<T> supplierCommand,
Predicate<Throwable> throwablePredicate,
Predicate<T> resultRetryPredicate,
int retryCount,
String shortDescription, String operationName) throws RuntimeException {
Retryer<T> retryer = RetryerBuilder.<T>newBuilder()
.retryIfException(Optional.ofNullable(throwablePredicate).orElse(exception -> true))
.retryIfResult(Optional.ofNullable(resultRetryPredicate).orElse(result -> false))
.withWaitStrategy(WaitStrategies.join(
WaitStrategies.exponentialWait(1000, 90, TimeUnit.SECONDS),
WaitStrategies.randomWait(100, TimeUnit.MILLISECONDS, 500, TimeUnit.MILLISECONDS)
))
.withStopStrategy(StopStrategies.stopAfterAttempt(retryCount))
.withBlockStrategy(BlockStrategies.threadSleepStrategy())
.withRetryListener(new RetryListener() {
@Override
public <V> void onRetry(Attempt<V> attempt) {
logger.debug("Attempt # {}, {} millis since first attempt. Operation: {}, description:{}",
attempt.getAttemptNumber(), attempt.getDelaySinceFirstAttempt(), operationName, shortDescription);
internalNumberOfRetries.incrementAndGet();
}
})
.build();
try {
return retryer.call(supplierCommand::get);
} catch (ExecutionException executionException) {
String errorMessage = String.format("Operation '%s:%s' failed for the %d time in RetryUtil", operationName,
shortDescription, internalNumberOfRetries.get());
logger.debug(errorMessage);
throw new RuntimeException(errorMessage, executionException.getCause());
} catch (RetryException retryException) {
String errorMessage = String.format("Operation '%s:%s' failed after retrying %d times, retry limit %d", operationName,
shortDescription, internalNumberOfRetries.get(), 3);
logger.debug(errorMessage, retryException.getLastFailedAttempt().getExceptionCause());
throw new RuntimeException(errorMessage, retryException.getLastFailedAttempt().getExceptionCause());
}
} | [
"@",
"SuppressWarnings",
"(",
"\"Guava\"",
")",
"public",
"T",
"retryOnException",
"(",
"Supplier",
"<",
"T",
">",
"supplierCommand",
",",
"Predicate",
"<",
"Throwable",
">",
"throwablePredicate",
",",
"Predicate",
"<",
"T",
">",
"resultRetryPredicate",
",",
"int",
"retryCount",
",",
"String",
"shortDescription",
",",
"String",
"operationName",
")",
"throws",
"RuntimeException",
"{",
"Retryer",
"<",
"T",
">",
"retryer",
"=",
"RetryerBuilder",
".",
"<",
"T",
">",
"newBuilder",
"(",
")",
".",
"retryIfException",
"(",
"Optional",
".",
"ofNullable",
"(",
"throwablePredicate",
")",
".",
"orElse",
"(",
"exception",
"->",
"true",
")",
")",
".",
"retryIfResult",
"(",
"Optional",
".",
"ofNullable",
"(",
"resultRetryPredicate",
")",
".",
"orElse",
"(",
"result",
"->",
"false",
")",
")",
".",
"withWaitStrategy",
"(",
"WaitStrategies",
".",
"join",
"(",
"WaitStrategies",
".",
"exponentialWait",
"(",
"1000",
",",
"90",
",",
"TimeUnit",
".",
"SECONDS",
")",
",",
"WaitStrategies",
".",
"randomWait",
"(",
"100",
",",
"TimeUnit",
".",
"MILLISECONDS",
",",
"500",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
")",
")",
".",
"withStopStrategy",
"(",
"StopStrategies",
".",
"stopAfterAttempt",
"(",
"retryCount",
")",
")",
".",
"withBlockStrategy",
"(",
"BlockStrategies",
".",
"threadSleepStrategy",
"(",
")",
")",
".",
"withRetryListener",
"(",
"new",
"RetryListener",
"(",
")",
"{",
"@",
"Override",
"public",
"<",
"V",
">",
"void",
"onRetry",
"(",
"Attempt",
"<",
"V",
">",
"attempt",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Attempt # {}, {} millis since first attempt. Operation: {}, description:{}\"",
",",
"attempt",
".",
"getAttemptNumber",
"(",
")",
",",
"attempt",
".",
"getDelaySinceFirstAttempt",
"(",
")",
",",
"operationName",
",",
"shortDescription",
")",
";",
"internalNumberOfRetries",
".",
"incrementAndGet",
"(",
")",
";",
"}",
"}",
")",
".",
"build",
"(",
")",
";",
"try",
"{",
"return",
"retryer",
".",
"call",
"(",
"supplierCommand",
"::",
"get",
")",
";",
"}",
"catch",
"(",
"ExecutionException",
"executionException",
")",
"{",
"String",
"errorMessage",
"=",
"String",
".",
"format",
"(",
"\"Operation '%s:%s' failed for the %d time in RetryUtil\"",
",",
"operationName",
",",
"shortDescription",
",",
"internalNumberOfRetries",
".",
"get",
"(",
")",
")",
";",
"logger",
".",
"debug",
"(",
"errorMessage",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"errorMessage",
",",
"executionException",
".",
"getCause",
"(",
")",
")",
";",
"}",
"catch",
"(",
"RetryException",
"retryException",
")",
"{",
"String",
"errorMessage",
"=",
"String",
".",
"format",
"(",
"\"Operation '%s:%s' failed after retrying %d times, retry limit %d\"",
",",
"operationName",
",",
"shortDescription",
",",
"internalNumberOfRetries",
".",
"get",
"(",
")",
",",
"3",
")",
";",
"logger",
".",
"debug",
"(",
"errorMessage",
",",
"retryException",
".",
"getLastFailedAttempt",
"(",
")",
".",
"getExceptionCause",
"(",
")",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"errorMessage",
",",
"retryException",
".",
"getLastFailedAttempt",
"(",
")",
".",
"getExceptionCause",
"(",
")",
")",
";",
"}",
"}"
] | A helper method which has the ability to execute a flaky supplier function and retry in case of failures.
@param supplierCommand: Any function that is flaky and needs multiple retries.
@param throwablePredicate: A Guava {@link Predicate} housing the exceptional
criteria to perform informed filtering before retrying.
@param resultRetryPredicate: a predicate to be evaluated for a valid condition of the expected result
@param retryCount: Number of times the function is to be retried before failure
@param shortDescription: A short description of the function that will be used in logging and error propagation.
The intention of this description is to provide context for Operability.
@param operationName: The name of the function for traceability in logs
@return an instance of return type of the supplierCommand
@throws RuntimeException in case of failed attempts to get T, which needs to be returned by the supplierCommand.
The instance of the returned exception has:
<ul>
<li>A message with shortDescription and operationName with the number of retries made</li>
<li>And a reference to the original exception generated during the last {@link Attempt} of the retry</li>
</ul> | [
"A",
"helper",
"method",
"which",
"has",
"the",
"ability",
"to",
"execute",
"a",
"flaky",
"supplier",
"function",
"and",
"retry",
"in",
"case",
"of",
"failures",
"."
] | train | https://github.com/Netflix/conductor/blob/78fae0ed9ddea22891f9eebb96a2ec0b2783dca0/common/src/main/java/com/netflix/conductor/common/utils/RetryUtil.java#L87-L126 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/io/IoUtil.java | IoUtil.read | public static String read(ReadableByteChannel channel, Charset charset) throws IORuntimeException {
"""
从流中读取内容,读取完毕后并不关闭流
@param channel 可读通道,读取完毕后并不关闭通道
@param charset 字符集
@return 内容
@throws IORuntimeException IO异常
@since 4.5.0
"""
FastByteArrayOutputStream out = read(channel);
return null == charset ? out.toString() : out.toString(charset);
} | java | public static String read(ReadableByteChannel channel, Charset charset) throws IORuntimeException {
FastByteArrayOutputStream out = read(channel);
return null == charset ? out.toString() : out.toString(charset);
} | [
"public",
"static",
"String",
"read",
"(",
"ReadableByteChannel",
"channel",
",",
"Charset",
"charset",
")",
"throws",
"IORuntimeException",
"{",
"FastByteArrayOutputStream",
"out",
"=",
"read",
"(",
"channel",
")",
";",
"return",
"null",
"==",
"charset",
"?",
"out",
".",
"toString",
"(",
")",
":",
"out",
".",
"toString",
"(",
"charset",
")",
";",
"}"
] | 从流中读取内容,读取完毕后并不关闭流
@param channel 可读通道,读取完毕后并不关闭通道
@param charset 字符集
@return 内容
@throws IORuntimeException IO异常
@since 4.5.0 | [
"从流中读取内容,读取完毕后并不关闭流"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/IoUtil.java#L423-L426 |
icode/ameba | src/main/java/ameba/message/jackson/internal/JacksonUtils.java | JacksonUtils.configureGenerator | public static void configureGenerator(UriInfo uriInfo, JsonGenerator generator, boolean isDev) {
"""
<p>configureGenerator.</p>
@param uriInfo a {@link javax.ws.rs.core.UriInfo} object.
@param generator a {@link com.fasterxml.jackson.core.JsonGenerator} object.
@param isDev a boolean.
"""
MultivaluedMap<String, String> params = uriInfo.getQueryParameters();
String pretty = params.getFirst("pretty");
if ("false".equalsIgnoreCase(pretty)) {
generator.setPrettyPrinter(null);
} else if (pretty != null && !"false".equalsIgnoreCase(pretty) || isDev) {
generator.useDefaultPrettyPrinter();
}
String unicode = params.getFirst("unicode");
if (unicode != null && !"false".equalsIgnoreCase(unicode)) {
generator.enable(JsonGenerator.Feature.ESCAPE_NON_ASCII);
}
} | java | public static void configureGenerator(UriInfo uriInfo, JsonGenerator generator, boolean isDev) {
MultivaluedMap<String, String> params = uriInfo.getQueryParameters();
String pretty = params.getFirst("pretty");
if ("false".equalsIgnoreCase(pretty)) {
generator.setPrettyPrinter(null);
} else if (pretty != null && !"false".equalsIgnoreCase(pretty) || isDev) {
generator.useDefaultPrettyPrinter();
}
String unicode = params.getFirst("unicode");
if (unicode != null && !"false".equalsIgnoreCase(unicode)) {
generator.enable(JsonGenerator.Feature.ESCAPE_NON_ASCII);
}
} | [
"public",
"static",
"void",
"configureGenerator",
"(",
"UriInfo",
"uriInfo",
",",
"JsonGenerator",
"generator",
",",
"boolean",
"isDev",
")",
"{",
"MultivaluedMap",
"<",
"String",
",",
"String",
">",
"params",
"=",
"uriInfo",
".",
"getQueryParameters",
"(",
")",
";",
"String",
"pretty",
"=",
"params",
".",
"getFirst",
"(",
"\"pretty\"",
")",
";",
"if",
"(",
"\"false\"",
".",
"equalsIgnoreCase",
"(",
"pretty",
")",
")",
"{",
"generator",
".",
"setPrettyPrinter",
"(",
"null",
")",
";",
"}",
"else",
"if",
"(",
"pretty",
"!=",
"null",
"&&",
"!",
"\"false\"",
".",
"equalsIgnoreCase",
"(",
"pretty",
")",
"||",
"isDev",
")",
"{",
"generator",
".",
"useDefaultPrettyPrinter",
"(",
")",
";",
"}",
"String",
"unicode",
"=",
"params",
".",
"getFirst",
"(",
"\"unicode\"",
")",
";",
"if",
"(",
"unicode",
"!=",
"null",
"&&",
"!",
"\"false\"",
".",
"equalsIgnoreCase",
"(",
"unicode",
")",
")",
"{",
"generator",
".",
"enable",
"(",
"JsonGenerator",
".",
"Feature",
".",
"ESCAPE_NON_ASCII",
")",
";",
"}",
"}"
] | <p>configureGenerator.</p>
@param uriInfo a {@link javax.ws.rs.core.UriInfo} object.
@param generator a {@link com.fasterxml.jackson.core.JsonGenerator} object.
@param isDev a boolean. | [
"<p",
">",
"configureGenerator",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/icode/ameba/blob/9d4956e935898e41331b2745e400ef869cd265e0/src/main/java/ameba/message/jackson/internal/JacksonUtils.java#L116-L128 |
onelogin/onelogin-java-sdk | src/main/java/com/onelogin/sdk/conn/Client.java | Client.createSessionLoginToken | public Object createSessionLoginToken(Map<String, Object> queryParams) throws OAuthSystemException, OAuthProblemException, URISyntaxException {
"""
Generate a session login token in scenarios in which MFA may or may not be required.
A session login token expires two minutes after creation.
@param queryParams
Query Parameters (username_or_email, password, subdomain, return_to_url, ip_address, browser_id)
@return SessionTokenInfo or SessionTokenMFAInfo object if success
@throws OAuthSystemException - if there is a IOException reading parameters of the httpURLConnection
@throws OAuthProblemException - if there are errors validating the OneloginOAuthJSONResourceResponse and throwOAuthProblemException is enabled
@throws URISyntaxException - if there is an error when generating the target URL at the URIBuilder constructor
@see <a target="_blank" href="https://developers.onelogin.com/api-docs/1/users/create-session-login-token">Create Session Login Token documentation</a>
"""
return createSessionLoginToken(queryParams, null);
} | java | public Object createSessionLoginToken(Map<String, Object> queryParams) throws OAuthSystemException, OAuthProblemException, URISyntaxException {
return createSessionLoginToken(queryParams, null);
} | [
"public",
"Object",
"createSessionLoginToken",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"queryParams",
")",
"throws",
"OAuthSystemException",
",",
"OAuthProblemException",
",",
"URISyntaxException",
"{",
"return",
"createSessionLoginToken",
"(",
"queryParams",
",",
"null",
")",
";",
"}"
] | Generate a session login token in scenarios in which MFA may or may not be required.
A session login token expires two minutes after creation.
@param queryParams
Query Parameters (username_or_email, password, subdomain, return_to_url, ip_address, browser_id)
@return SessionTokenInfo or SessionTokenMFAInfo object if success
@throws OAuthSystemException - if there is a IOException reading parameters of the httpURLConnection
@throws OAuthProblemException - if there are errors validating the OneloginOAuthJSONResourceResponse and throwOAuthProblemException is enabled
@throws URISyntaxException - if there is an error when generating the target URL at the URIBuilder constructor
@see <a target="_blank" href="https://developers.onelogin.com/api-docs/1/users/create-session-login-token">Create Session Login Token documentation</a> | [
"Generate",
"a",
"session",
"login",
"token",
"in",
"scenarios",
"in",
"which",
"MFA",
"may",
"or",
"may",
"not",
"be",
"required",
".",
"A",
"session",
"login",
"token",
"expires",
"two",
"minutes",
"after",
"creation",
"."
] | train | https://github.com/onelogin/onelogin-java-sdk/blob/1570b78033dcc1c7387099e77fe41b6b0638df8c/src/main/java/com/onelogin/sdk/conn/Client.java#L870-L872 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/objects/XRTreeFragSelectWrapper.java | XRTreeFragSelectWrapper.fixupVariables | public void fixupVariables(java.util.Vector vars, int globalsSize) {
"""
This function is used to fixup variables from QNames to stack frame
indexes at stylesheet build time.
@param vars List of QNames that correspond to variables. This list
should be searched backwards for the first qualified name that
corresponds to the variable reference qname. The position of the
QName in the vector from the start of the vector will be its position
in the stack frame (but variables above the globalsTop value will need
to be offset to the current stack frame).
"""
((Expression)m_obj).fixupVariables(vars, globalsSize);
} | java | public void fixupVariables(java.util.Vector vars, int globalsSize)
{
((Expression)m_obj).fixupVariables(vars, globalsSize);
} | [
"public",
"void",
"fixupVariables",
"(",
"java",
".",
"util",
".",
"Vector",
"vars",
",",
"int",
"globalsSize",
")",
"{",
"(",
"(",
"Expression",
")",
"m_obj",
")",
".",
"fixupVariables",
"(",
"vars",
",",
"globalsSize",
")",
";",
"}"
] | This function is used to fixup variables from QNames to stack frame
indexes at stylesheet build time.
@param vars List of QNames that correspond to variables. This list
should be searched backwards for the first qualified name that
corresponds to the variable reference qname. The position of the
QName in the vector from the start of the vector will be its position
in the stack frame (but variables above the globalsTop value will need
to be offset to the current stack frame). | [
"This",
"function",
"is",
"used",
"to",
"fixup",
"variables",
"from",
"QNames",
"to",
"stack",
"frame",
"indexes",
"at",
"stylesheet",
"build",
"time",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/objects/XRTreeFragSelectWrapper.java#L51-L54 |
aws/aws-sdk-java | aws-java-sdk-route53/src/main/java/com/amazonaws/services/route53domains/model/GetDomainDetailResult.java | GetDomainDetailResult.getStatusList | public java.util.List<String> getStatusList() {
"""
<p>
An array of domain name status codes, also known as Extensible Provisioning Protocol (EPP) status codes.
</p>
<p>
ICANN, the organization that maintains a central database of domain names, has developed a set of domain name
status codes that tell you the status of a variety of operations on a domain name, for example, registering a
domain name, transferring a domain name to another registrar, renewing the registration for a domain name, and so
on. All registrars use this same set of status codes.
</p>
<p>
For a current list of domain name status codes and an explanation of what each code means, go to the <a
href="https://www.icann.org/">ICANN website</a> and search for <code>epp status codes</code>. (Search on the
ICANN website; web searches sometimes return an old version of the document.)
</p>
@return An array of domain name status codes, also known as Extensible Provisioning Protocol (EPP) status
codes.</p>
<p>
ICANN, the organization that maintains a central database of domain names, has developed a set of domain
name status codes that tell you the status of a variety of operations on a domain name, for example,
registering a domain name, transferring a domain name to another registrar, renewing the registration for
a domain name, and so on. All registrars use this same set of status codes.
</p>
<p>
For a current list of domain name status codes and an explanation of what each code means, go to the <a
href="https://www.icann.org/">ICANN website</a> and search for <code>epp status codes</code>. (Search on
the ICANN website; web searches sometimes return an old version of the document.)
"""
if (statusList == null) {
statusList = new com.amazonaws.internal.SdkInternalList<String>();
}
return statusList;
} | java | public java.util.List<String> getStatusList() {
if (statusList == null) {
statusList = new com.amazonaws.internal.SdkInternalList<String>();
}
return statusList;
} | [
"public",
"java",
".",
"util",
".",
"List",
"<",
"String",
">",
"getStatusList",
"(",
")",
"{",
"if",
"(",
"statusList",
"==",
"null",
")",
"{",
"statusList",
"=",
"new",
"com",
".",
"amazonaws",
".",
"internal",
".",
"SdkInternalList",
"<",
"String",
">",
"(",
")",
";",
"}",
"return",
"statusList",
";",
"}"
] | <p>
An array of domain name status codes, also known as Extensible Provisioning Protocol (EPP) status codes.
</p>
<p>
ICANN, the organization that maintains a central database of domain names, has developed a set of domain name
status codes that tell you the status of a variety of operations on a domain name, for example, registering a
domain name, transferring a domain name to another registrar, renewing the registration for a domain name, and so
on. All registrars use this same set of status codes.
</p>
<p>
For a current list of domain name status codes and an explanation of what each code means, go to the <a
href="https://www.icann.org/">ICANN website</a> and search for <code>epp status codes</code>. (Search on the
ICANN website; web searches sometimes return an old version of the document.)
</p>
@return An array of domain name status codes, also known as Extensible Provisioning Protocol (EPP) status
codes.</p>
<p>
ICANN, the organization that maintains a central database of domain names, has developed a set of domain
name status codes that tell you the status of a variety of operations on a domain name, for example,
registering a domain name, transferring a domain name to another registrar, renewing the registration for
a domain name, and so on. All registrars use this same set of status codes.
</p>
<p>
For a current list of domain name status codes and an explanation of what each code means, go to the <a
href="https://www.icann.org/">ICANN website</a> and search for <code>epp status codes</code>. (Search on
the ICANN website; web searches sometimes return an old version of the document.) | [
"<p",
">",
"An",
"array",
"of",
"domain",
"name",
"status",
"codes",
"also",
"known",
"as",
"Extensible",
"Provisioning",
"Protocol",
"(",
"EPP",
")",
"status",
"codes",
".",
"<",
"/",
"p",
">",
"<p",
">",
"ICANN",
"the",
"organization",
"that",
"maintains",
"a",
"central",
"database",
"of",
"domain",
"names",
"has",
"developed",
"a",
"set",
"of",
"domain",
"name",
"status",
"codes",
"that",
"tell",
"you",
"the",
"status",
"of",
"a",
"variety",
"of",
"operations",
"on",
"a",
"domain",
"name",
"for",
"example",
"registering",
"a",
"domain",
"name",
"transferring",
"a",
"domain",
"name",
"to",
"another",
"registrar",
"renewing",
"the",
"registration",
"for",
"a",
"domain",
"name",
"and",
"so",
"on",
".",
"All",
"registrars",
"use",
"this",
"same",
"set",
"of",
"status",
"codes",
".",
"<",
"/",
"p",
">",
"<p",
">",
"For",
"a",
"current",
"list",
"of",
"domain",
"name",
"status",
"codes",
"and",
"an",
"explanation",
"of",
"what",
"each",
"code",
"means",
"go",
"to",
"the",
"<a",
"href",
"=",
"https",
":",
"//",
"www",
".",
"icann",
".",
"org",
"/",
">",
"ICANN",
"website<",
"/",
"a",
">",
"and",
"search",
"for",
"<code",
">",
"epp",
"status",
"codes<",
"/",
"code",
">",
".",
"(",
"Search",
"on",
"the",
"ICANN",
"website",
";",
"web",
"searches",
"sometimes",
"return",
"an",
"old",
"version",
"of",
"the",
"document",
".",
")",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-route53/src/main/java/com/amazonaws/services/route53domains/model/GetDomainDetailResult.java#L1211-L1216 |
liferay/com-liferay-commerce | commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPInstancePersistenceImpl.java | CPInstancePersistenceImpl.findByLtD_S | @Override
public List<CPInstance> findByLtD_S(Date displayDate, int status,
int start, int end) {
"""
Returns a range of all the cp instances where displayDate < ? and status = ?.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CPInstanceModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param displayDate the display date
@param status the status
@param start the lower bound of the range of cp instances
@param end the upper bound of the range of cp instances (not inclusive)
@return the range of matching cp instances
"""
return findByLtD_S(displayDate, status, start, end, null);
} | java | @Override
public List<CPInstance> findByLtD_S(Date displayDate, int status,
int start, int end) {
return findByLtD_S(displayDate, status, start, end, null);
} | [
"@",
"Override",
"public",
"List",
"<",
"CPInstance",
">",
"findByLtD_S",
"(",
"Date",
"displayDate",
",",
"int",
"status",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"return",
"findByLtD_S",
"(",
"displayDate",
",",
"status",
",",
"start",
",",
"end",
",",
"null",
")",
";",
"}"
] | Returns a range of all the cp instances where displayDate < ? and status = ?.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CPInstanceModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param displayDate the display date
@param status the status
@param start the lower bound of the range of cp instances
@param end the upper bound of the range of cp instances (not inclusive)
@return the range of matching cp instances | [
"Returns",
"a",
"range",
"of",
"all",
"the",
"cp",
"instances",
"where",
"displayDate",
"<",
";",
"?",
";",
"and",
"status",
"=",
"?",
";",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPInstancePersistenceImpl.java#L5674-L5678 |
elki-project/elki | elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/evaluation/clustering/internal/EvaluateConcordantPairs.java | EvaluateConcordantPairs.computeTau | @Reference(authors = "F. J. Rohlf", title = "Methods of comparing classifications", //
booktitle = "Annual Review of Ecology and Systematics", //
url = "https://doi.org/10.1146/annurev.es.05.110174.000533", //
bibkey = "doi:10.1146/annurev.es.05.110174.000533")
public double computeTau(long c, long d, double m, long wd, long bd) {
"""
Compute the Tau correlation measure
@param c Concordant pairs
@param d Discordant pairs
@param m Total number of pairs
@param wd Number of within distances
@param bd Number of between distances
@return Gamma plus statistic
"""
double tie = (wd * (wd - 1) + bd * (bd - 1)) >>> 1;
return (c - d) / FastMath.sqrt((m - tie) * m);
// return (4. * c - m) / m;
} | java | @Reference(authors = "F. J. Rohlf", title = "Methods of comparing classifications", //
booktitle = "Annual Review of Ecology and Systematics", //
url = "https://doi.org/10.1146/annurev.es.05.110174.000533", //
bibkey = "doi:10.1146/annurev.es.05.110174.000533")
public double computeTau(long c, long d, double m, long wd, long bd) {
double tie = (wd * (wd - 1) + bd * (bd - 1)) >>> 1;
return (c - d) / FastMath.sqrt((m - tie) * m);
// return (4. * c - m) / m;
} | [
"@",
"Reference",
"(",
"authors",
"=",
"\"F. J. Rohlf\"",
",",
"title",
"=",
"\"Methods of comparing classifications\"",
",",
"//",
"booktitle",
"=",
"\"Annual Review of Ecology and Systematics\"",
",",
"//",
"url",
"=",
"\"https://doi.org/10.1146/annurev.es.05.110174.000533\"",
",",
"//",
"bibkey",
"=",
"\"doi:10.1146/annurev.es.05.110174.000533\"",
")",
"public",
"double",
"computeTau",
"(",
"long",
"c",
",",
"long",
"d",
",",
"double",
"m",
",",
"long",
"wd",
",",
"long",
"bd",
")",
"{",
"double",
"tie",
"=",
"(",
"wd",
"*",
"(",
"wd",
"-",
"1",
")",
"+",
"bd",
"*",
"(",
"bd",
"-",
"1",
")",
")",
">>>",
"1",
";",
"return",
"(",
"c",
"-",
"d",
")",
"/",
"FastMath",
".",
"sqrt",
"(",
"(",
"m",
"-",
"tie",
")",
"*",
"m",
")",
";",
"// return (4. * c - m) / m;",
"}"
] | Compute the Tau correlation measure
@param c Concordant pairs
@param d Discordant pairs
@param m Total number of pairs
@param wd Number of within distances
@param bd Number of between distances
@return Gamma plus statistic | [
"Compute",
"the",
"Tau",
"correlation",
"measure"
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/evaluation/clustering/internal/EvaluateConcordantPairs.java#L280-L288 |
primefaces-extensions/core | src/main/java/org/primefaces/extensions/component/sheet/SheetRenderer.java | SheetRenderer.encodeHiddenInputs | private void encodeHiddenInputs(final ResponseWriter responseWriter, final Sheet sheet, final String clientId)
throws IOException {
"""
Encode hidden input fields
@param responseWriter
@param sheet
@param clientId
@throws IOException
"""
responseWriter.startElement("input", null);
responseWriter.writeAttribute("id", clientId + "_input", "id");
responseWriter.writeAttribute("name", clientId + "_input", "name");
responseWriter.writeAttribute("type", "hidden", null);
responseWriter.writeAttribute("value", "", null);
responseWriter.endElement("input");
responseWriter.startElement("input", null);
responseWriter.writeAttribute("id", clientId + "_focus", "id");
responseWriter.writeAttribute("name", clientId + "_focus", "name");
responseWriter.writeAttribute("type", "hidden", null);
if (sheet.getFocusId() == null) {
responseWriter.writeAttribute("value", "", null);
}
else {
responseWriter.writeAttribute("value", sheet.getFocusId(), null);
}
responseWriter.endElement("input");
responseWriter.startElement("input", null);
responseWriter.writeAttribute("id", clientId + "_selection", "id");
responseWriter.writeAttribute("name", clientId + "_selection", "name");
responseWriter.writeAttribute("type", "hidden", null);
if (sheet.getSelection() == null) {
responseWriter.writeAttribute("value", "", null);
}
else {
responseWriter.writeAttribute("value", sheet.getSelection(), null);
}
responseWriter.endElement("input");
// sort col and order if specified and supported
final int sortCol = sheet.getSortColRenderIndex();
responseWriter.startElement("input", null);
responseWriter.writeAttribute("id", clientId + "_sortby", "id");
responseWriter.writeAttribute("name", clientId + "_sortby", "name");
responseWriter.writeAttribute("type", "hidden", null);
responseWriter.writeAttribute("value", sortCol, null);
responseWriter.endElement("input");
responseWriter.startElement("input", null);
responseWriter.writeAttribute("id", clientId + "_sortorder", "id");
responseWriter.writeAttribute("name", clientId + "_sortorder", "name");
responseWriter.writeAttribute("type", "hidden", null);
responseWriter.writeAttribute("value", sheet.getSortOrder().toLowerCase(), null);
responseWriter.endElement("input");
} | java | private void encodeHiddenInputs(final ResponseWriter responseWriter, final Sheet sheet, final String clientId)
throws IOException {
responseWriter.startElement("input", null);
responseWriter.writeAttribute("id", clientId + "_input", "id");
responseWriter.writeAttribute("name", clientId + "_input", "name");
responseWriter.writeAttribute("type", "hidden", null);
responseWriter.writeAttribute("value", "", null);
responseWriter.endElement("input");
responseWriter.startElement("input", null);
responseWriter.writeAttribute("id", clientId + "_focus", "id");
responseWriter.writeAttribute("name", clientId + "_focus", "name");
responseWriter.writeAttribute("type", "hidden", null);
if (sheet.getFocusId() == null) {
responseWriter.writeAttribute("value", "", null);
}
else {
responseWriter.writeAttribute("value", sheet.getFocusId(), null);
}
responseWriter.endElement("input");
responseWriter.startElement("input", null);
responseWriter.writeAttribute("id", clientId + "_selection", "id");
responseWriter.writeAttribute("name", clientId + "_selection", "name");
responseWriter.writeAttribute("type", "hidden", null);
if (sheet.getSelection() == null) {
responseWriter.writeAttribute("value", "", null);
}
else {
responseWriter.writeAttribute("value", sheet.getSelection(), null);
}
responseWriter.endElement("input");
// sort col and order if specified and supported
final int sortCol = sheet.getSortColRenderIndex();
responseWriter.startElement("input", null);
responseWriter.writeAttribute("id", clientId + "_sortby", "id");
responseWriter.writeAttribute("name", clientId + "_sortby", "name");
responseWriter.writeAttribute("type", "hidden", null);
responseWriter.writeAttribute("value", sortCol, null);
responseWriter.endElement("input");
responseWriter.startElement("input", null);
responseWriter.writeAttribute("id", clientId + "_sortorder", "id");
responseWriter.writeAttribute("name", clientId + "_sortorder", "name");
responseWriter.writeAttribute("type", "hidden", null);
responseWriter.writeAttribute("value", sheet.getSortOrder().toLowerCase(), null);
responseWriter.endElement("input");
} | [
"private",
"void",
"encodeHiddenInputs",
"(",
"final",
"ResponseWriter",
"responseWriter",
",",
"final",
"Sheet",
"sheet",
",",
"final",
"String",
"clientId",
")",
"throws",
"IOException",
"{",
"responseWriter",
".",
"startElement",
"(",
"\"input\"",
",",
"null",
")",
";",
"responseWriter",
".",
"writeAttribute",
"(",
"\"id\"",
",",
"clientId",
"+",
"\"_input\"",
",",
"\"id\"",
")",
";",
"responseWriter",
".",
"writeAttribute",
"(",
"\"name\"",
",",
"clientId",
"+",
"\"_input\"",
",",
"\"name\"",
")",
";",
"responseWriter",
".",
"writeAttribute",
"(",
"\"type\"",
",",
"\"hidden\"",
",",
"null",
")",
";",
"responseWriter",
".",
"writeAttribute",
"(",
"\"value\"",
",",
"\"\"",
",",
"null",
")",
";",
"responseWriter",
".",
"endElement",
"(",
"\"input\"",
")",
";",
"responseWriter",
".",
"startElement",
"(",
"\"input\"",
",",
"null",
")",
";",
"responseWriter",
".",
"writeAttribute",
"(",
"\"id\"",
",",
"clientId",
"+",
"\"_focus\"",
",",
"\"id\"",
")",
";",
"responseWriter",
".",
"writeAttribute",
"(",
"\"name\"",
",",
"clientId",
"+",
"\"_focus\"",
",",
"\"name\"",
")",
";",
"responseWriter",
".",
"writeAttribute",
"(",
"\"type\"",
",",
"\"hidden\"",
",",
"null",
")",
";",
"if",
"(",
"sheet",
".",
"getFocusId",
"(",
")",
"==",
"null",
")",
"{",
"responseWriter",
".",
"writeAttribute",
"(",
"\"value\"",
",",
"\"\"",
",",
"null",
")",
";",
"}",
"else",
"{",
"responseWriter",
".",
"writeAttribute",
"(",
"\"value\"",
",",
"sheet",
".",
"getFocusId",
"(",
")",
",",
"null",
")",
";",
"}",
"responseWriter",
".",
"endElement",
"(",
"\"input\"",
")",
";",
"responseWriter",
".",
"startElement",
"(",
"\"input\"",
",",
"null",
")",
";",
"responseWriter",
".",
"writeAttribute",
"(",
"\"id\"",
",",
"clientId",
"+",
"\"_selection\"",
",",
"\"id\"",
")",
";",
"responseWriter",
".",
"writeAttribute",
"(",
"\"name\"",
",",
"clientId",
"+",
"\"_selection\"",
",",
"\"name\"",
")",
";",
"responseWriter",
".",
"writeAttribute",
"(",
"\"type\"",
",",
"\"hidden\"",
",",
"null",
")",
";",
"if",
"(",
"sheet",
".",
"getSelection",
"(",
")",
"==",
"null",
")",
"{",
"responseWriter",
".",
"writeAttribute",
"(",
"\"value\"",
",",
"\"\"",
",",
"null",
")",
";",
"}",
"else",
"{",
"responseWriter",
".",
"writeAttribute",
"(",
"\"value\"",
",",
"sheet",
".",
"getSelection",
"(",
")",
",",
"null",
")",
";",
"}",
"responseWriter",
".",
"endElement",
"(",
"\"input\"",
")",
";",
"// sort col and order if specified and supported",
"final",
"int",
"sortCol",
"=",
"sheet",
".",
"getSortColRenderIndex",
"(",
")",
";",
"responseWriter",
".",
"startElement",
"(",
"\"input\"",
",",
"null",
")",
";",
"responseWriter",
".",
"writeAttribute",
"(",
"\"id\"",
",",
"clientId",
"+",
"\"_sortby\"",
",",
"\"id\"",
")",
";",
"responseWriter",
".",
"writeAttribute",
"(",
"\"name\"",
",",
"clientId",
"+",
"\"_sortby\"",
",",
"\"name\"",
")",
";",
"responseWriter",
".",
"writeAttribute",
"(",
"\"type\"",
",",
"\"hidden\"",
",",
"null",
")",
";",
"responseWriter",
".",
"writeAttribute",
"(",
"\"value\"",
",",
"sortCol",
",",
"null",
")",
";",
"responseWriter",
".",
"endElement",
"(",
"\"input\"",
")",
";",
"responseWriter",
".",
"startElement",
"(",
"\"input\"",
",",
"null",
")",
";",
"responseWriter",
".",
"writeAttribute",
"(",
"\"id\"",
",",
"clientId",
"+",
"\"_sortorder\"",
",",
"\"id\"",
")",
";",
"responseWriter",
".",
"writeAttribute",
"(",
"\"name\"",
",",
"clientId",
"+",
"\"_sortorder\"",
",",
"\"name\"",
")",
";",
"responseWriter",
".",
"writeAttribute",
"(",
"\"type\"",
",",
"\"hidden\"",
",",
"null",
")",
";",
"responseWriter",
".",
"writeAttribute",
"(",
"\"value\"",
",",
"sheet",
".",
"getSortOrder",
"(",
")",
".",
"toLowerCase",
"(",
")",
",",
"null",
")",
";",
"responseWriter",
".",
"endElement",
"(",
"\"input\"",
")",
";",
"}"
] | Encode hidden input fields
@param responseWriter
@param sheet
@param clientId
@throws IOException | [
"Encode",
"hidden",
"input",
"fields"
] | train | https://github.com/primefaces-extensions/core/blob/afdbca591f60f47898e3517e1e939bc2f63d5355/src/main/java/org/primefaces/extensions/component/sheet/SheetRenderer.java#L529-L577 |
albfernandez/itext2 | src/main/java/com/lowagie/text/pdf/BidiOrder.java | BidiOrder.setTypes | private void setTypes(int start, int limit, byte newType) {
"""
Set resultTypes from start up to (but not including) limit to newType.
"""
for (int i = start; i < limit; ++i) {
resultTypes[i] = newType;
}
} | java | private void setTypes(int start, int limit, byte newType) {
for (int i = start; i < limit; ++i) {
resultTypes[i] = newType;
}
} | [
"private",
"void",
"setTypes",
"(",
"int",
"start",
",",
"int",
"limit",
",",
"byte",
"newType",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"start",
";",
"i",
"<",
"limit",
";",
"++",
"i",
")",
"{",
"resultTypes",
"[",
"i",
"]",
"=",
"newType",
";",
"}",
"}"
] | Set resultTypes from start up to (but not including) limit to newType. | [
"Set",
"resultTypes",
"from",
"start",
"up",
"to",
"(",
"but",
"not",
"including",
")",
"limit",
"to",
"newType",
"."
] | train | https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/pdf/BidiOrder.java#L1059-L1063 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.