repository_name
stringlengths 7
54
| func_path_in_repository
stringlengths 18
218
| func_name
stringlengths 5
140
| whole_func_string
stringlengths 79
3.99k
| language
stringclasses 1
value | func_code_string
stringlengths 79
3.99k
| func_code_tokens
listlengths 20
624
| func_documentation_string
stringlengths 61
1.96k
| func_documentation_tokens
listlengths 1
478
| split_name
stringclasses 1
value | func_code_url
stringlengths 107
339
|
---|---|---|---|---|---|---|---|---|---|---|
elki-project/elki
|
elki-database/src/main/java/de/lmu/ifi/dbs/elki/database/HashmapDatabase.java
|
HashmapDatabase.alignColumns
|
protected Relation<?>[] alignColumns(ObjectBundle pack) {
// align representations.
Relation<?>[] targets = new Relation<?>[pack.metaLength()];
long[] used = BitsUtil.zero(relations.size());
for(int i = 0; i < targets.length; i++) {
SimpleTypeInformation<?> meta = pack.meta(i);
// TODO: aggressively try to match exact metas first?
// Try to match unused representations only
for(int j = BitsUtil.nextClearBit(used, 0); j >= 0 && j < relations.size(); j = BitsUtil.nextClearBit(used, j + 1)) {
Relation<?> relation = relations.get(j);
if(relation.getDataTypeInformation().isAssignableFromType(meta)) {
targets[i] = relation;
BitsUtil.setI(used, j);
break;
}
}
if(targets[i] == null) {
targets[i] = addNewRelation(meta);
BitsUtil.setI(used, relations.size() - 1);
}
}
return targets;
}
|
java
|
protected Relation<?>[] alignColumns(ObjectBundle pack) {
// align representations.
Relation<?>[] targets = new Relation<?>[pack.metaLength()];
long[] used = BitsUtil.zero(relations.size());
for(int i = 0; i < targets.length; i++) {
SimpleTypeInformation<?> meta = pack.meta(i);
// TODO: aggressively try to match exact metas first?
// Try to match unused representations only
for(int j = BitsUtil.nextClearBit(used, 0); j >= 0 && j < relations.size(); j = BitsUtil.nextClearBit(used, j + 1)) {
Relation<?> relation = relations.get(j);
if(relation.getDataTypeInformation().isAssignableFromType(meta)) {
targets[i] = relation;
BitsUtil.setI(used, j);
break;
}
}
if(targets[i] == null) {
targets[i] = addNewRelation(meta);
BitsUtil.setI(used, relations.size() - 1);
}
}
return targets;
}
|
[
"protected",
"Relation",
"<",
"?",
">",
"[",
"]",
"alignColumns",
"(",
"ObjectBundle",
"pack",
")",
"{",
"// align representations.",
"Relation",
"<",
"?",
">",
"[",
"]",
"targets",
"=",
"new",
"Relation",
"<",
"?",
">",
"[",
"pack",
".",
"metaLength",
"(",
")",
"]",
";",
"long",
"[",
"]",
"used",
"=",
"BitsUtil",
".",
"zero",
"(",
"relations",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"targets",
".",
"length",
";",
"i",
"++",
")",
"{",
"SimpleTypeInformation",
"<",
"?",
">",
"meta",
"=",
"pack",
".",
"meta",
"(",
"i",
")",
";",
"// TODO: aggressively try to match exact metas first?",
"// Try to match unused representations only",
"for",
"(",
"int",
"j",
"=",
"BitsUtil",
".",
"nextClearBit",
"(",
"used",
",",
"0",
")",
";",
"j",
">=",
"0",
"&&",
"j",
"<",
"relations",
".",
"size",
"(",
")",
";",
"j",
"=",
"BitsUtil",
".",
"nextClearBit",
"(",
"used",
",",
"j",
"+",
"1",
")",
")",
"{",
"Relation",
"<",
"?",
">",
"relation",
"=",
"relations",
".",
"get",
"(",
"j",
")",
";",
"if",
"(",
"relation",
".",
"getDataTypeInformation",
"(",
")",
".",
"isAssignableFromType",
"(",
"meta",
")",
")",
"{",
"targets",
"[",
"i",
"]",
"=",
"relation",
";",
"BitsUtil",
".",
"setI",
"(",
"used",
",",
"j",
")",
";",
"break",
";",
"}",
"}",
"if",
"(",
"targets",
"[",
"i",
"]",
"==",
"null",
")",
"{",
"targets",
"[",
"i",
"]",
"=",
"addNewRelation",
"(",
"meta",
")",
";",
"BitsUtil",
".",
"setI",
"(",
"used",
",",
"relations",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"}",
"}",
"return",
"targets",
";",
"}"
] |
Find a mapping from package columns to database columns, eventually adding
new database columns when needed.
@param pack Package to process
@return Column mapping
|
[
"Find",
"a",
"mapping",
"from",
"package",
"columns",
"to",
"database",
"columns",
"eventually",
"adding",
"new",
"database",
"columns",
"when",
"needed",
"."
] |
train
|
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-database/src/main/java/de/lmu/ifi/dbs/elki/database/HashmapDatabase.java#L170-L192
|
Netflix/eureka
|
eureka-client/src/main/java/com/netflix/discovery/util/DeserializerStringCache.java
|
DeserializerStringCache.apply
|
public String apply(CharBuffer charValue, CacheScope cacheScope) {
int keyLength = charValue.length();
if ((lengthLimit < 0 || keyLength <= lengthLimit)) {
Map<CharBuffer, String> cache = (cacheScope == CacheScope.GLOBAL_SCOPE) ? globalCache : applicationCache;
String value = cache.get(charValue);
if (value == null) {
value = charValue.consume((k, v) -> {
cache.put(k, v);
});
} else {
// System.out.println("cache hit");
}
return value;
}
return charValue.toString();
}
|
java
|
public String apply(CharBuffer charValue, CacheScope cacheScope) {
int keyLength = charValue.length();
if ((lengthLimit < 0 || keyLength <= lengthLimit)) {
Map<CharBuffer, String> cache = (cacheScope == CacheScope.GLOBAL_SCOPE) ? globalCache : applicationCache;
String value = cache.get(charValue);
if (value == null) {
value = charValue.consume((k, v) -> {
cache.put(k, v);
});
} else {
// System.out.println("cache hit");
}
return value;
}
return charValue.toString();
}
|
[
"public",
"String",
"apply",
"(",
"CharBuffer",
"charValue",
",",
"CacheScope",
"cacheScope",
")",
"{",
"int",
"keyLength",
"=",
"charValue",
".",
"length",
"(",
")",
";",
"if",
"(",
"(",
"lengthLimit",
"<",
"0",
"||",
"keyLength",
"<=",
"lengthLimit",
")",
")",
"{",
"Map",
"<",
"CharBuffer",
",",
"String",
">",
"cache",
"=",
"(",
"cacheScope",
"==",
"CacheScope",
".",
"GLOBAL_SCOPE",
")",
"?",
"globalCache",
":",
"applicationCache",
";",
"String",
"value",
"=",
"cache",
".",
"get",
"(",
"charValue",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"value",
"=",
"charValue",
".",
"consume",
"(",
"(",
"k",
",",
"v",
")",
"->",
"{",
"cache",
".",
"put",
"(",
"k",
",",
"v",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"// System.out.println(\"cache hit\");",
"}",
"return",
"value",
";",
"}",
"return",
"charValue",
".",
"toString",
"(",
")",
";",
"}"
] |
returns a object of type T that may be interned at the specified scope to
reduce heap consumption
@param charValue
@param cacheScope
@param trabsform
@return a possibly interned instance of T
|
[
"returns",
"a",
"object",
"of",
"type",
"T",
"that",
"may",
"be",
"interned",
"at",
"the",
"specified",
"scope",
"to",
"reduce",
"heap",
"consumption"
] |
train
|
https://github.com/Netflix/eureka/blob/48446d956be09df6650a3c00b7ebd7e2d1e1544f/eureka-client/src/main/java/com/netflix/discovery/util/DeserializerStringCache.java#L233-L248
|
grails/grails-core
|
grails-core/src/main/groovy/grails/core/DefaultGrailsApplication.java
|
DefaultGrailsApplication.addArtefact
|
public GrailsClass addArtefact(String artefactType, GrailsClass artefactGrailsClass) {
ArtefactHandler handler = artefactHandlersByName.get(artefactType);
if (handler.isArtefactGrailsClass(artefactGrailsClass)) {
// Store the GrailsClass in cache
DefaultArtefactInfo info = getArtefactInfo(artefactType, true);
info.addGrailsClass(artefactGrailsClass);
info.updateComplete();
initializeArtefacts(artefactType);
return artefactGrailsClass;
}
throw new GrailsConfigurationException("Cannot add " + artefactType + " class [" +
artefactGrailsClass + "]. It is not a " + artefactType + "!");
}
|
java
|
public GrailsClass addArtefact(String artefactType, GrailsClass artefactGrailsClass) {
ArtefactHandler handler = artefactHandlersByName.get(artefactType);
if (handler.isArtefactGrailsClass(artefactGrailsClass)) {
// Store the GrailsClass in cache
DefaultArtefactInfo info = getArtefactInfo(artefactType, true);
info.addGrailsClass(artefactGrailsClass);
info.updateComplete();
initializeArtefacts(artefactType);
return artefactGrailsClass;
}
throw new GrailsConfigurationException("Cannot add " + artefactType + " class [" +
artefactGrailsClass + "]. It is not a " + artefactType + "!");
}
|
[
"public",
"GrailsClass",
"addArtefact",
"(",
"String",
"artefactType",
",",
"GrailsClass",
"artefactGrailsClass",
")",
"{",
"ArtefactHandler",
"handler",
"=",
"artefactHandlersByName",
".",
"get",
"(",
"artefactType",
")",
";",
"if",
"(",
"handler",
".",
"isArtefactGrailsClass",
"(",
"artefactGrailsClass",
")",
")",
"{",
"// Store the GrailsClass in cache",
"DefaultArtefactInfo",
"info",
"=",
"getArtefactInfo",
"(",
"artefactType",
",",
"true",
")",
";",
"info",
".",
"addGrailsClass",
"(",
"artefactGrailsClass",
")",
";",
"info",
".",
"updateComplete",
"(",
")",
";",
"initializeArtefacts",
"(",
"artefactType",
")",
";",
"return",
"artefactGrailsClass",
";",
"}",
"throw",
"new",
"GrailsConfigurationException",
"(",
"\"Cannot add \"",
"+",
"artefactType",
"+",
"\" class [\"",
"+",
"artefactGrailsClass",
"+",
"\"]. It is not a \"",
"+",
"artefactType",
"+",
"\"!\"",
")",
";",
"}"
] |
Adds an artefact of the given type for the given GrailsClass.
@param artefactType The type of the artefact as defined by a ArtefactHandler instance
@param artefactGrailsClass A GrailsClass instance that matches the type defined by the ArtefactHandler
@return The GrailsClass if successful or null if it couldn't be added
@throws GrailsConfigurationException If the specified GrailsClass is not the same as the type defined by the ArtefactHandler
@see grails.core.ArtefactHandler
|
[
"Adds",
"an",
"artefact",
"of",
"the",
"given",
"type",
"for",
"the",
"given",
"GrailsClass",
"."
] |
train
|
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/core/DefaultGrailsApplication.java#L516-L531
|
Metrink/croquet
|
croquet-core/src/main/java/com/metrink/croquet/CroquetRestBuilder.java
|
CroquetRestBuilder.checkLoggingSettings
|
protected void checkLoggingSettings() {
final LoggingSettings logSettings = settings.getLoggingSettings();
final LogFile logFileSettings = logSettings.getLogFile();
if(logFileSettings.getCurrentLogFilename() != null &&
logFileSettings.isEnabled() == false) {
LOG.warn("You specified a log file, but have it disabled");
}
if(logFileSettings.isEnabled() &&
logFileSettings.getCurrentLogFilename() == null) {
throw new IllegalStateException("You enabled logging to a file, but didn't specify the file name");
}
}
|
java
|
protected void checkLoggingSettings() {
final LoggingSettings logSettings = settings.getLoggingSettings();
final LogFile logFileSettings = logSettings.getLogFile();
if(logFileSettings.getCurrentLogFilename() != null &&
logFileSettings.isEnabled() == false) {
LOG.warn("You specified a log file, but have it disabled");
}
if(logFileSettings.isEnabled() &&
logFileSettings.getCurrentLogFilename() == null) {
throw new IllegalStateException("You enabled logging to a file, but didn't specify the file name");
}
}
|
[
"protected",
"void",
"checkLoggingSettings",
"(",
")",
"{",
"final",
"LoggingSettings",
"logSettings",
"=",
"settings",
".",
"getLoggingSettings",
"(",
")",
";",
"final",
"LogFile",
"logFileSettings",
"=",
"logSettings",
".",
"getLogFile",
"(",
")",
";",
"if",
"(",
"logFileSettings",
".",
"getCurrentLogFilename",
"(",
")",
"!=",
"null",
"&&",
"logFileSettings",
".",
"isEnabled",
"(",
")",
"==",
"false",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"You specified a log file, but have it disabled\"",
")",
";",
"}",
"if",
"(",
"logFileSettings",
".",
"isEnabled",
"(",
")",
"&&",
"logFileSettings",
".",
"getCurrentLogFilename",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"You enabled logging to a file, but didn't specify the file name\"",
")",
";",
"}",
"}"
] |
Runs some checks over the log settings before building a {@link Corquet} instance.
|
[
"Runs",
"some",
"checks",
"over",
"the",
"log",
"settings",
"before",
"building",
"a",
"{"
] |
train
|
https://github.com/Metrink/croquet/blob/1b0ed1327a104cf1f809ce4c3c5bf30a3d95384b/croquet-core/src/main/java/com/metrink/croquet/CroquetRestBuilder.java#L138-L151
|
apiman/apiman
|
manager/api/es/src/main/java/io/apiman/manager/api/es/EsMarshalling.java
|
EsMarshalling.unmarshallClientVersionSummary
|
public static ClientVersionSummaryBean unmarshallClientVersionSummary(Map<String, Object> source) {
if (source == null) {
return null;
}
ClientVersionSummaryBean bean = new ClientVersionSummaryBean();
bean.setDescription(asString(source.get("clientDescription")));
bean.setId(asString(source.get("clientId")));
bean.setName(asString(source.get("clientName")));
bean.setOrganizationId(asString(source.get("organizationId")));
bean.setOrganizationName(asString(source.get("organizationName")));
bean.setStatus(asEnum(source.get("status"), ClientStatus.class));
bean.setVersion(asString(source.get("version")));
bean.setApiKey(asString(source.get("apikey")));
postMarshall(bean);
return bean;
}
|
java
|
public static ClientVersionSummaryBean unmarshallClientVersionSummary(Map<String, Object> source) {
if (source == null) {
return null;
}
ClientVersionSummaryBean bean = new ClientVersionSummaryBean();
bean.setDescription(asString(source.get("clientDescription")));
bean.setId(asString(source.get("clientId")));
bean.setName(asString(source.get("clientName")));
bean.setOrganizationId(asString(source.get("organizationId")));
bean.setOrganizationName(asString(source.get("organizationName")));
bean.setStatus(asEnum(source.get("status"), ClientStatus.class));
bean.setVersion(asString(source.get("version")));
bean.setApiKey(asString(source.get("apikey")));
postMarshall(bean);
return bean;
}
|
[
"public",
"static",
"ClientVersionSummaryBean",
"unmarshallClientVersionSummary",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"source",
")",
"{",
"if",
"(",
"source",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"ClientVersionSummaryBean",
"bean",
"=",
"new",
"ClientVersionSummaryBean",
"(",
")",
";",
"bean",
".",
"setDescription",
"(",
"asString",
"(",
"source",
".",
"get",
"(",
"\"clientDescription\"",
")",
")",
")",
";",
"bean",
".",
"setId",
"(",
"asString",
"(",
"source",
".",
"get",
"(",
"\"clientId\"",
")",
")",
")",
";",
"bean",
".",
"setName",
"(",
"asString",
"(",
"source",
".",
"get",
"(",
"\"clientName\"",
")",
")",
")",
";",
"bean",
".",
"setOrganizationId",
"(",
"asString",
"(",
"source",
".",
"get",
"(",
"\"organizationId\"",
")",
")",
")",
";",
"bean",
".",
"setOrganizationName",
"(",
"asString",
"(",
"source",
".",
"get",
"(",
"\"organizationName\"",
")",
")",
")",
";",
"bean",
".",
"setStatus",
"(",
"asEnum",
"(",
"source",
".",
"get",
"(",
"\"status\"",
")",
",",
"ClientStatus",
".",
"class",
")",
")",
";",
"bean",
".",
"setVersion",
"(",
"asString",
"(",
"source",
".",
"get",
"(",
"\"version\"",
")",
")",
")",
";",
"bean",
".",
"setApiKey",
"(",
"asString",
"(",
"source",
".",
"get",
"(",
"\"apikey\"",
")",
")",
")",
";",
"postMarshall",
"(",
"bean",
")",
";",
"return",
"bean",
";",
"}"
] |
Unmarshals the given map source into a bean.
@param source the source
@return the client version summary
|
[
"Unmarshals",
"the",
"given",
"map",
"source",
"into",
"a",
"bean",
"."
] |
train
|
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/es/src/main/java/io/apiman/manager/api/es/EsMarshalling.java#L1084-L1099
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java
|
ApiOvhOrder.dedicatedCloud_serviceName_ip_duration_POST
|
public OvhOrder dedicatedCloud_serviceName_ip_duration_POST(String serviceName, String duration, OvhIpCountriesEnum country, String description, Long estimatedClientsNumber, String networkName, OvhOrderableIpBlockRangeEnum size, String usage) throws IOException {
String qPath = "/order/dedicatedCloud/{serviceName}/ip/{duration}";
StringBuilder sb = path(qPath, serviceName, duration);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "country", country);
addBody(o, "description", description);
addBody(o, "estimatedClientsNumber", estimatedClientsNumber);
addBody(o, "networkName", networkName);
addBody(o, "size", size);
addBody(o, "usage", usage);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhOrder.class);
}
|
java
|
public OvhOrder dedicatedCloud_serviceName_ip_duration_POST(String serviceName, String duration, OvhIpCountriesEnum country, String description, Long estimatedClientsNumber, String networkName, OvhOrderableIpBlockRangeEnum size, String usage) throws IOException {
String qPath = "/order/dedicatedCloud/{serviceName}/ip/{duration}";
StringBuilder sb = path(qPath, serviceName, duration);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "country", country);
addBody(o, "description", description);
addBody(o, "estimatedClientsNumber", estimatedClientsNumber);
addBody(o, "networkName", networkName);
addBody(o, "size", size);
addBody(o, "usage", usage);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhOrder.class);
}
|
[
"public",
"OvhOrder",
"dedicatedCloud_serviceName_ip_duration_POST",
"(",
"String",
"serviceName",
",",
"String",
"duration",
",",
"OvhIpCountriesEnum",
"country",
",",
"String",
"description",
",",
"Long",
"estimatedClientsNumber",
",",
"String",
"networkName",
",",
"OvhOrderableIpBlockRangeEnum",
"size",
",",
"String",
"usage",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/order/dedicatedCloud/{serviceName}/ip/{duration}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"duration",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"country\"",
",",
"country",
")",
";",
"addBody",
"(",
"o",
",",
"\"description\"",
",",
"description",
")",
";",
"addBody",
"(",
"o",
",",
"\"estimatedClientsNumber\"",
",",
"estimatedClientsNumber",
")",
";",
"addBody",
"(",
"o",
",",
"\"networkName\"",
",",
"networkName",
")",
";",
"addBody",
"(",
"o",
",",
"\"size\"",
",",
"size",
")",
";",
"addBody",
"(",
"o",
",",
"\"usage\"",
",",
"usage",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhOrder",
".",
"class",
")",
";",
"}"
] |
Create order
REST: POST /order/dedicatedCloud/{serviceName}/ip/{duration}
@param size [required] The network ranges orderable
@param usage [required] Basic information of how will this bloc be used (as "web","ssl","cloud" or other things)
@param description [required] Information visible on whois (minimum 3 and maximum 250 alphanumeric characters)
@param country [required] This Ip block country
@param estimatedClientsNumber [required] How much clients would be hosted on those ips ?
@param networkName [required] Information visible on whois (between 2 and maximum 20 alphanumeric characters)
@param serviceName [required]
@param duration [required] Duration
|
[
"Create",
"order"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java#L5850-L5862
|
RoaringBitmap/RoaringBitmap
|
roaringbitmap/src/main/java/org/roaringbitmap/RoaringBitmap.java
|
RoaringBitmap.maximumSerializedSize
|
public static long maximumSerializedSize(long cardinality, long universe_size) {
long contnbr = (universe_size + 65535) / 65536;
if (contnbr > cardinality) {
contnbr = cardinality;
// we can't have more containers than we have values
}
final long headermax = Math.max(8, 4 + (contnbr + 7) / 8) + 8 * contnbr;
final long valsarray = 2 * cardinality;
final long valsbitmap = contnbr * 8192;
final long valsbest = Math.min(valsarray, valsbitmap);
return valsbest + headermax;
}
|
java
|
public static long maximumSerializedSize(long cardinality, long universe_size) {
long contnbr = (universe_size + 65535) / 65536;
if (contnbr > cardinality) {
contnbr = cardinality;
// we can't have more containers than we have values
}
final long headermax = Math.max(8, 4 + (contnbr + 7) / 8) + 8 * contnbr;
final long valsarray = 2 * cardinality;
final long valsbitmap = contnbr * 8192;
final long valsbest = Math.min(valsarray, valsbitmap);
return valsbest + headermax;
}
|
[
"public",
"static",
"long",
"maximumSerializedSize",
"(",
"long",
"cardinality",
",",
"long",
"universe_size",
")",
"{",
"long",
"contnbr",
"=",
"(",
"universe_size",
"+",
"65535",
")",
"/",
"65536",
";",
"if",
"(",
"contnbr",
">",
"cardinality",
")",
"{",
"contnbr",
"=",
"cardinality",
";",
"// we can't have more containers than we have values",
"}",
"final",
"long",
"headermax",
"=",
"Math",
".",
"max",
"(",
"8",
",",
"4",
"+",
"(",
"contnbr",
"+",
"7",
")",
"/",
"8",
")",
"+",
"8",
"*",
"contnbr",
";",
"final",
"long",
"valsarray",
"=",
"2",
"*",
"cardinality",
";",
"final",
"long",
"valsbitmap",
"=",
"contnbr",
"*",
"8192",
";",
"final",
"long",
"valsbest",
"=",
"Math",
".",
"min",
"(",
"valsarray",
",",
"valsbitmap",
")",
";",
"return",
"valsbest",
"+",
"headermax",
";",
"}"
] |
Assume that one wants to store "cardinality" integers in [0, universe_size), this function
returns an upper bound on the serialized size in bytes.
@param cardinality maximal cardinality
@param universe_size maximal value
@return upper bound on the serialized size in bytes of the bitmap
|
[
"Assume",
"that",
"one",
"wants",
"to",
"store",
"cardinality",
"integers",
"in",
"[",
"0",
"universe_size",
")",
"this",
"function",
"returns",
"an",
"upper",
"bound",
"on",
"the",
"serialized",
"size",
"in",
"bytes",
"."
] |
train
|
https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/RoaringBitmap.java#L2532-L2543
|
io7m/jaffirm
|
com.io7m.jaffirm.core/src/main/java/com/io7m/jaffirm/core/Preconditions.java
|
Preconditions.checkPreconditionL
|
public static long checkPreconditionL(
final long value,
final boolean condition,
final LongFunction<String> describer)
{
return innerCheckL(value, condition, describer);
}
|
java
|
public static long checkPreconditionL(
final long value,
final boolean condition,
final LongFunction<String> describer)
{
return innerCheckL(value, condition, describer);
}
|
[
"public",
"static",
"long",
"checkPreconditionL",
"(",
"final",
"long",
"value",
",",
"final",
"boolean",
"condition",
",",
"final",
"LongFunction",
"<",
"String",
">",
"describer",
")",
"{",
"return",
"innerCheckL",
"(",
"value",
",",
"condition",
",",
"describer",
")",
";",
"}"
] |
A {@code long} specialized version of {@link #checkPrecondition(Object,
Predicate, Function)}
@param condition The predicate
@param value The value
@param describer The describer of the predicate
@return value
@throws PreconditionViolationException If the predicate is false
|
[
"A",
"{",
"@code",
"long",
"}",
"specialized",
"version",
"of",
"{",
"@link",
"#checkPrecondition",
"(",
"Object",
"Predicate",
"Function",
")",
"}"
] |
train
|
https://github.com/io7m/jaffirm/blob/c97d246242d381e48832838737418cfe4cb57b4d/com.io7m.jaffirm.core/src/main/java/com/io7m/jaffirm/core/Preconditions.java#L479-L485
|
jbundle/jbundle
|
base/screen/control/servlet/src/main/java/org/jbundle/base/screen/control/servlet/message/trx/transport/xml/XMLMessageTransport.java
|
XMLMessageTransport.createExternalMessage
|
public ExternalMessage createExternalMessage(BaseMessage message, Object rawData)
{
ExternalMessage externalTrxMessageOut = super.createExternalMessage(message, rawData);
if (externalTrxMessageOut == null)
{
if (MessageTypeModel.MESSAGE_IN.equalsIgnoreCase((String)message.get(TrxMessageHeader.MESSAGE_PROCESS_TYPE)))
externalTrxMessageOut = new XmlTrxMessageIn(message, rawData);
else
externalTrxMessageOut = new XmlTrxMessageOut(message, rawData);
}
return externalTrxMessageOut;
}
|
java
|
public ExternalMessage createExternalMessage(BaseMessage message, Object rawData)
{
ExternalMessage externalTrxMessageOut = super.createExternalMessage(message, rawData);
if (externalTrxMessageOut == null)
{
if (MessageTypeModel.MESSAGE_IN.equalsIgnoreCase((String)message.get(TrxMessageHeader.MESSAGE_PROCESS_TYPE)))
externalTrxMessageOut = new XmlTrxMessageIn(message, rawData);
else
externalTrxMessageOut = new XmlTrxMessageOut(message, rawData);
}
return externalTrxMessageOut;
}
|
[
"public",
"ExternalMessage",
"createExternalMessage",
"(",
"BaseMessage",
"message",
",",
"Object",
"rawData",
")",
"{",
"ExternalMessage",
"externalTrxMessageOut",
"=",
"super",
".",
"createExternalMessage",
"(",
"message",
",",
"rawData",
")",
";",
"if",
"(",
"externalTrxMessageOut",
"==",
"null",
")",
"{",
"if",
"(",
"MessageTypeModel",
".",
"MESSAGE_IN",
".",
"equalsIgnoreCase",
"(",
"(",
"String",
")",
"message",
".",
"get",
"(",
"TrxMessageHeader",
".",
"MESSAGE_PROCESS_TYPE",
")",
")",
")",
"externalTrxMessageOut",
"=",
"new",
"XmlTrxMessageIn",
"(",
"message",
",",
"rawData",
")",
";",
"else",
"externalTrxMessageOut",
"=",
"new",
"XmlTrxMessageOut",
"(",
"message",
",",
"rawData",
")",
";",
"}",
"return",
"externalTrxMessageOut",
";",
"}"
] |
Get the external message container for this Internal message.
Typically, the overriding class supplies a default format for the transport type.
<br/>NOTE: The message header from the internal message is copies, but not the message itself.
@param The internalTrxMessage that I will convert to this external format.
@return The (empty) External message.
|
[
"Get",
"the",
"external",
"message",
"container",
"for",
"this",
"Internal",
"message",
".",
"Typically",
"the",
"overriding",
"class",
"supplies",
"a",
"default",
"format",
"for",
"the",
"transport",
"type",
".",
"<br",
"/",
">",
"NOTE",
":",
"The",
"message",
"header",
"from",
"the",
"internal",
"message",
"is",
"copies",
"but",
"not",
"the",
"message",
"itself",
"."
] |
train
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/control/servlet/src/main/java/org/jbundle/base/screen/control/servlet/message/trx/transport/xml/XMLMessageTransport.java#L79-L90
|
andrehertwig/admintool
|
admin-tools-dbbrowser/src/main/java/de/chandre/admintool/db/AdminToolDBBrowserServiceImpl.java
|
AdminToolDBBrowserServiceImpl.getClobString
|
protected String getClobString(Clob clobObject, String encoding) throws IOException, SQLException, UnsupportedEncodingException
{
if (null == clobObject) {
return "";
}
InputStream in = clobObject.getAsciiStream();
Reader read = new InputStreamReader(in, encoding);
StringWriter write = new StringWriter();
String result = null;
try {
int c = -1;
while ((c = read.read()) != -1) {
write.write(c);
}
write.flush();
result = write.toString();
} finally {
closeStream(write);
closeStream(read);
//should we close the ascii stream from database? or is it handled by connection
// closeStream(in);
}
return result;
}
|
java
|
protected String getClobString(Clob clobObject, String encoding) throws IOException, SQLException, UnsupportedEncodingException
{
if (null == clobObject) {
return "";
}
InputStream in = clobObject.getAsciiStream();
Reader read = new InputStreamReader(in, encoding);
StringWriter write = new StringWriter();
String result = null;
try {
int c = -1;
while ((c = read.read()) != -1) {
write.write(c);
}
write.flush();
result = write.toString();
} finally {
closeStream(write);
closeStream(read);
//should we close the ascii stream from database? or is it handled by connection
// closeStream(in);
}
return result;
}
|
[
"protected",
"String",
"getClobString",
"(",
"Clob",
"clobObject",
",",
"String",
"encoding",
")",
"throws",
"IOException",
",",
"SQLException",
",",
"UnsupportedEncodingException",
"{",
"if",
"(",
"null",
"==",
"clobObject",
")",
"{",
"return",
"\"\"",
";",
"}",
"InputStream",
"in",
"=",
"clobObject",
".",
"getAsciiStream",
"(",
")",
";",
"Reader",
"read",
"=",
"new",
"InputStreamReader",
"(",
"in",
",",
"encoding",
")",
";",
"StringWriter",
"write",
"=",
"new",
"StringWriter",
"(",
")",
";",
"String",
"result",
"=",
"null",
";",
"try",
"{",
"int",
"c",
"=",
"-",
"1",
";",
"while",
"(",
"(",
"c",
"=",
"read",
".",
"read",
"(",
")",
")",
"!=",
"-",
"1",
")",
"{",
"write",
".",
"write",
"(",
"c",
")",
";",
"}",
"write",
".",
"flush",
"(",
")",
";",
"result",
"=",
"write",
".",
"toString",
"(",
")",
";",
"}",
"finally",
"{",
"closeStream",
"(",
"write",
")",
";",
"closeStream",
"(",
"read",
")",
";",
"//should we close the ascii stream from database? or is it handled by connection\r",
"// closeStream(in);\r",
"}",
"return",
"result",
";",
"}"
] |
turns clob into a string
@param clobObject
@param encoding
@return
@throws IOException
@throws SQLException
@throws UnsupportedEncodingException
|
[
"turns",
"clob",
"into",
"a",
"string"
] |
train
|
https://github.com/andrehertwig/admintool/blob/6d391e2d26969b70e3ccabfc34202abe8d915080/admin-tools-dbbrowser/src/main/java/de/chandre/admintool/db/AdminToolDBBrowserServiceImpl.java#L391-L414
|
liferay/com-liferay-commerce
|
commerce-service/src/main/java/com/liferay/commerce/service/persistence/impl/CommerceWarehousePersistenceImpl.java
|
CommerceWarehousePersistenceImpl.countByG_A_P
|
@Override
public int countByG_A_P(long groupId, boolean active, boolean primary) {
FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A_P;
Object[] finderArgs = new Object[] { groupId, active, primary };
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_COUNT_COMMERCEWAREHOUSE_WHERE);
query.append(_FINDER_COLUMN_G_A_P_GROUPID_2);
query.append(_FINDER_COLUMN_G_A_P_ACTIVE_2);
query.append(_FINDER_COLUMN_G_A_P_PRIMARY_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(active);
qPos.add(primary);
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
|
java
|
@Override
public int countByG_A_P(long groupId, boolean active, boolean primary) {
FinderPath finderPath = FINDER_PATH_COUNT_BY_G_A_P;
Object[] finderArgs = new Object[] { groupId, active, primary };
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_COUNT_COMMERCEWAREHOUSE_WHERE);
query.append(_FINDER_COLUMN_G_A_P_GROUPID_2);
query.append(_FINDER_COLUMN_G_A_P_ACTIVE_2);
query.append(_FINDER_COLUMN_G_A_P_PRIMARY_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(active);
qPos.add(primary);
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
|
[
"@",
"Override",
"public",
"int",
"countByG_A_P",
"(",
"long",
"groupId",
",",
"boolean",
"active",
",",
"boolean",
"primary",
")",
"{",
"FinderPath",
"finderPath",
"=",
"FINDER_PATH_COUNT_BY_G_A_P",
";",
"Object",
"[",
"]",
"finderArgs",
"=",
"new",
"Object",
"[",
"]",
"{",
"groupId",
",",
"active",
",",
"primary",
"}",
";",
"Long",
"count",
"=",
"(",
"Long",
")",
"finderCache",
".",
"getResult",
"(",
"finderPath",
",",
"finderArgs",
",",
"this",
")",
";",
"if",
"(",
"count",
"==",
"null",
")",
"{",
"StringBundler",
"query",
"=",
"new",
"StringBundler",
"(",
"4",
")",
";",
"query",
".",
"append",
"(",
"_SQL_COUNT_COMMERCEWAREHOUSE_WHERE",
")",
";",
"query",
".",
"append",
"(",
"_FINDER_COLUMN_G_A_P_GROUPID_2",
")",
";",
"query",
".",
"append",
"(",
"_FINDER_COLUMN_G_A_P_ACTIVE_2",
")",
";",
"query",
".",
"append",
"(",
"_FINDER_COLUMN_G_A_P_PRIMARY_2",
")",
";",
"String",
"sql",
"=",
"query",
".",
"toString",
"(",
")",
";",
"Session",
"session",
"=",
"null",
";",
"try",
"{",
"session",
"=",
"openSession",
"(",
")",
";",
"Query",
"q",
"=",
"session",
".",
"createQuery",
"(",
"sql",
")",
";",
"QueryPos",
"qPos",
"=",
"QueryPos",
".",
"getInstance",
"(",
"q",
")",
";",
"qPos",
".",
"add",
"(",
"groupId",
")",
";",
"qPos",
".",
"add",
"(",
"active",
")",
";",
"qPos",
".",
"add",
"(",
"primary",
")",
";",
"count",
"=",
"(",
"Long",
")",
"q",
".",
"uniqueResult",
"(",
")",
";",
"finderCache",
".",
"putResult",
"(",
"finderPath",
",",
"finderArgs",
",",
"count",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"finderCache",
".",
"removeResult",
"(",
"finderPath",
",",
"finderArgs",
")",
";",
"throw",
"processException",
"(",
"e",
")",
";",
"}",
"finally",
"{",
"closeSession",
"(",
"session",
")",
";",
"}",
"}",
"return",
"count",
".",
"intValue",
"(",
")",
";",
"}"
] |
Returns the number of commerce warehouses where groupId = ? and active = ? and primary = ?.
@param groupId the group ID
@param active the active
@param primary the primary
@return the number of matching commerce warehouses
|
[
"Returns",
"the",
"number",
"of",
"commerce",
"warehouses",
"where",
"groupId",
"=",
"?",
";",
"and",
"active",
"=",
"?",
";",
"and",
"primary",
"=",
"?",
";",
"."
] |
train
|
https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-service/src/main/java/com/liferay/commerce/service/persistence/impl/CommerceWarehousePersistenceImpl.java#L3374-L3425
|
FasterXML/woodstox
|
src/main/java/com/ctc/wstx/dtd/DTDAttribute.java
|
DTDAttribute.checkEntity
|
protected void checkEntity(InputProblemReporter rep, String id, EntityDecl ent)
throws XMLStreamException
{
if (ent == null) {
rep.reportValidationProblem("Referenced entity '"+id+"' not defined");
} else if (ent.isParsed()) {
rep.reportValidationProblem("Referenced entity '"+id+"' is not an unparsed entity");
}
}
|
java
|
protected void checkEntity(InputProblemReporter rep, String id, EntityDecl ent)
throws XMLStreamException
{
if (ent == null) {
rep.reportValidationProblem("Referenced entity '"+id+"' not defined");
} else if (ent.isParsed()) {
rep.reportValidationProblem("Referenced entity '"+id+"' is not an unparsed entity");
}
}
|
[
"protected",
"void",
"checkEntity",
"(",
"InputProblemReporter",
"rep",
",",
"String",
"id",
",",
"EntityDecl",
"ent",
")",
"throws",
"XMLStreamException",
"{",
"if",
"(",
"ent",
"==",
"null",
")",
"{",
"rep",
".",
"reportValidationProblem",
"(",
"\"Referenced entity '\"",
"+",
"id",
"+",
"\"' not defined\"",
")",
";",
"}",
"else",
"if",
"(",
"ent",
".",
"isParsed",
"(",
")",
")",
"{",
"rep",
".",
"reportValidationProblem",
"(",
"\"Referenced entity '\"",
"+",
"id",
"+",
"\"' is not an unparsed entity\"",
")",
";",
"}",
"}"
] |
/* Too bad this method can not be combined with previous segment --
the reason is that DTDValidator does not implement
InputProblemReporter...
|
[
"/",
"*",
"Too",
"bad",
"this",
"method",
"can",
"not",
"be",
"combined",
"with",
"previous",
"segment",
"--",
"the",
"reason",
"is",
"that",
"DTDValidator",
"does",
"not",
"implement",
"InputProblemReporter",
"..."
] |
train
|
https://github.com/FasterXML/woodstox/blob/ffcaabdc06672d9564c48c25d601d029b7fd6548/src/main/java/com/ctc/wstx/dtd/DTDAttribute.java#L469-L477
|
soabase/exhibitor
|
exhibitor-core/src/main/java/com/netflix/exhibitor/core/config/DefaultProperties.java
|
DefaultProperties.getFromInstanceConfig
|
public static Properties getFromInstanceConfig(InstanceConfig defaultInstanceConfig)
{
PropertyBasedInstanceConfig config = new PropertyBasedInstanceConfig(new ConfigCollectionImpl(defaultInstanceConfig, null));
return config.getProperties();
}
|
java
|
public static Properties getFromInstanceConfig(InstanceConfig defaultInstanceConfig)
{
PropertyBasedInstanceConfig config = new PropertyBasedInstanceConfig(new ConfigCollectionImpl(defaultInstanceConfig, null));
return config.getProperties();
}
|
[
"public",
"static",
"Properties",
"getFromInstanceConfig",
"(",
"InstanceConfig",
"defaultInstanceConfig",
")",
"{",
"PropertyBasedInstanceConfig",
"config",
"=",
"new",
"PropertyBasedInstanceConfig",
"(",
"new",
"ConfigCollectionImpl",
"(",
"defaultInstanceConfig",
",",
"null",
")",
")",
";",
"return",
"config",
".",
"getProperties",
"(",
")",
";",
"}"
] |
Return the default properties given an instance config
@param defaultInstanceConfig the default properties as an object
@return default properties
|
[
"Return",
"the",
"default",
"properties",
"given",
"an",
"instance",
"config"
] |
train
|
https://github.com/soabase/exhibitor/blob/d345d2d45c75b0694b562b6c346f8594f3a5d166/exhibitor-core/src/main/java/com/netflix/exhibitor/core/config/DefaultProperties.java#L58-L62
|
google/j2objc
|
jre_emul/android/platform/libcore/ojluni/src/main/java/java/time/chrono/AbstractChronology.java
|
AbstractChronology.registerChrono
|
static Chronology registerChrono(Chronology chrono, String id) {
Chronology prev = CHRONOS_BY_ID.putIfAbsent(id, chrono);
if (prev == null) {
String type = chrono.getCalendarType();
if (type != null) {
CHRONOS_BY_TYPE.putIfAbsent(type, chrono);
}
}
return prev;
}
|
java
|
static Chronology registerChrono(Chronology chrono, String id) {
Chronology prev = CHRONOS_BY_ID.putIfAbsent(id, chrono);
if (prev == null) {
String type = chrono.getCalendarType();
if (type != null) {
CHRONOS_BY_TYPE.putIfAbsent(type, chrono);
}
}
return prev;
}
|
[
"static",
"Chronology",
"registerChrono",
"(",
"Chronology",
"chrono",
",",
"String",
"id",
")",
"{",
"Chronology",
"prev",
"=",
"CHRONOS_BY_ID",
".",
"putIfAbsent",
"(",
"id",
",",
"chrono",
")",
";",
"if",
"(",
"prev",
"==",
"null",
")",
"{",
"String",
"type",
"=",
"chrono",
".",
"getCalendarType",
"(",
")",
";",
"if",
"(",
"type",
"!=",
"null",
")",
"{",
"CHRONOS_BY_TYPE",
".",
"putIfAbsent",
"(",
"type",
",",
"chrono",
")",
";",
"}",
"}",
"return",
"prev",
";",
"}"
] |
Register a Chronology by ID and type for lookup by {@link #of(String)}.
Chronos must not be registered until they are completely constructed.
Specifically, not in the constructor of Chronology.
@param chrono the chronology to register; not null
@param id the ID to register the chronology; not null
@return the already registered Chronology if any, may be null
|
[
"Register",
"a",
"Chronology",
"by",
"ID",
"and",
"type",
"for",
"lookup",
"by",
"{",
"@link",
"#of",
"(",
"String",
")",
"}",
".",
"Chronos",
"must",
"not",
"be",
"registered",
"until",
"they",
"are",
"completely",
"constructed",
".",
"Specifically",
"not",
"in",
"the",
"constructor",
"of",
"Chronology",
"."
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/time/chrono/AbstractChronology.java#L189-L198
|
JDBDT/jdbdt
|
src/main/java/org/jdbdt/JDBDT.java
|
JDBDT.assertTableExists
|
@SafeVarargs
public static void assertTableExists(DB db, String... tableNames) throws DBAssertionError {
multipleTableExistenceAssertions(CallInfo.create(), db, tableNames, true);
}
|
java
|
@SafeVarargs
public static void assertTableExists(DB db, String... tableNames) throws DBAssertionError {
multipleTableExistenceAssertions(CallInfo.create(), db, tableNames, true);
}
|
[
"@",
"SafeVarargs",
"public",
"static",
"void",
"assertTableExists",
"(",
"DB",
"db",
",",
"String",
"...",
"tableNames",
")",
"throws",
"DBAssertionError",
"{",
"multipleTableExistenceAssertions",
"(",
"CallInfo",
".",
"create",
"(",
")",
",",
"db",
",",
"tableNames",
",",
"true",
")",
";",
"}"
] |
Assert that tables exist in the database.
@param db Database.
@param tableNames Table names.
@throws DBAssertionError If the assertion fails.
@see #assertTableDoesNotExist(DB, String...)
@see #drop(Table...)
@since 1.2
|
[
"Assert",
"that",
"tables",
"exist",
"in",
"the",
"database",
"."
] |
train
|
https://github.com/JDBDT/jdbdt/blob/7e32845ad41dfbc5d6fd0fd561e3613697186df4/src/main/java/org/jdbdt/JDBDT.java#L794-L797
|
liferay/com-liferay-commerce
|
commerce-service/src/main/java/com/liferay/commerce/service/persistence/impl/CommerceRegionPersistenceImpl.java
|
CommerceRegionPersistenceImpl.findByC_A
|
@Override
public List<CommerceRegion> findByC_A(long commerceCountryId,
boolean active, int start, int end) {
return findByC_A(commerceCountryId, active, start, end, null);
}
|
java
|
@Override
public List<CommerceRegion> findByC_A(long commerceCountryId,
boolean active, int start, int end) {
return findByC_A(commerceCountryId, active, start, end, null);
}
|
[
"@",
"Override",
"public",
"List",
"<",
"CommerceRegion",
">",
"findByC_A",
"(",
"long",
"commerceCountryId",
",",
"boolean",
"active",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"return",
"findByC_A",
"(",
"commerceCountryId",
",",
"active",
",",
"start",
",",
"end",
",",
"null",
")",
";",
"}"
] |
Returns a range of all the commerce regions where commerceCountryId = ? and active = ?.
<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 CommerceRegionModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param commerceCountryId the commerce country ID
@param active the active
@param start the lower bound of the range of commerce regions
@param end the upper bound of the range of commerce regions (not inclusive)
@return the range of matching commerce regions
|
[
"Returns",
"a",
"range",
"of",
"all",
"the",
"commerce",
"regions",
"where",
"commerceCountryId",
"=",
"?",
";",
"and",
"active",
"=",
"?",
";",
"."
] |
train
|
https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-service/src/main/java/com/liferay/commerce/service/persistence/impl/CommerceRegionPersistenceImpl.java#L2300-L2304
|
redkale/redkale
|
src/org/redkale/util/ResourceFactory.java
|
ResourceFactory.register
|
public <A> A register(final String name, final A rs) {
return register(true, name, rs);
}
|
java
|
public <A> A register(final String name, final A rs) {
return register(true, name, rs);
}
|
[
"public",
"<",
"A",
">",
"A",
"register",
"(",
"final",
"String",
"name",
",",
"final",
"A",
"rs",
")",
"{",
"return",
"register",
"(",
"true",
",",
"name",
",",
"rs",
")",
";",
"}"
] |
将对象以指定资源名注入到资源池中,并同步已被注入的资源
@param <A> 泛型
@param name 资源名
@param rs 资源对象
@return 旧资源对象
|
[
"将对象以指定资源名注入到资源池中,并同步已被注入的资源"
] |
train
|
https://github.com/redkale/redkale/blob/ea5169b5c5ea7412fd762331c0c497165832e901/src/org/redkale/util/ResourceFactory.java#L334-L336
|
ngageoint/geopackage-java
|
src/main/java/mil/nga/geopackage/tiles/TileBoundingBoxJavaUtils.java
|
TileBoundingBoxJavaUtils.getFloatRectangle
|
public static ImageRectangleF getFloatRectangle(long width, long height,
BoundingBox boundingBox, BoundingBox boundingBoxSection) {
float left = TileBoundingBoxUtils.getXPixel(width, boundingBox,
boundingBoxSection.getMinLongitude());
float right = TileBoundingBoxUtils.getXPixel(width, boundingBox,
boundingBoxSection.getMaxLongitude());
float top = TileBoundingBoxUtils.getYPixel(height, boundingBox,
boundingBoxSection.getMaxLatitude());
float bottom = TileBoundingBoxUtils.getYPixel(height, boundingBox,
boundingBoxSection.getMinLatitude());
ImageRectangleF rect = new ImageRectangleF(left, top, right, bottom);
return rect;
}
|
java
|
public static ImageRectangleF getFloatRectangle(long width, long height,
BoundingBox boundingBox, BoundingBox boundingBoxSection) {
float left = TileBoundingBoxUtils.getXPixel(width, boundingBox,
boundingBoxSection.getMinLongitude());
float right = TileBoundingBoxUtils.getXPixel(width, boundingBox,
boundingBoxSection.getMaxLongitude());
float top = TileBoundingBoxUtils.getYPixel(height, boundingBox,
boundingBoxSection.getMaxLatitude());
float bottom = TileBoundingBoxUtils.getYPixel(height, boundingBox,
boundingBoxSection.getMinLatitude());
ImageRectangleF rect = new ImageRectangleF(left, top, right, bottom);
return rect;
}
|
[
"public",
"static",
"ImageRectangleF",
"getFloatRectangle",
"(",
"long",
"width",
",",
"long",
"height",
",",
"BoundingBox",
"boundingBox",
",",
"BoundingBox",
"boundingBoxSection",
")",
"{",
"float",
"left",
"=",
"TileBoundingBoxUtils",
".",
"getXPixel",
"(",
"width",
",",
"boundingBox",
",",
"boundingBoxSection",
".",
"getMinLongitude",
"(",
")",
")",
";",
"float",
"right",
"=",
"TileBoundingBoxUtils",
".",
"getXPixel",
"(",
"width",
",",
"boundingBox",
",",
"boundingBoxSection",
".",
"getMaxLongitude",
"(",
")",
")",
";",
"float",
"top",
"=",
"TileBoundingBoxUtils",
".",
"getYPixel",
"(",
"height",
",",
"boundingBox",
",",
"boundingBoxSection",
".",
"getMaxLatitude",
"(",
")",
")",
";",
"float",
"bottom",
"=",
"TileBoundingBoxUtils",
".",
"getYPixel",
"(",
"height",
",",
"boundingBox",
",",
"boundingBoxSection",
".",
"getMinLatitude",
"(",
")",
")",
";",
"ImageRectangleF",
"rect",
"=",
"new",
"ImageRectangleF",
"(",
"left",
",",
"top",
",",
"right",
",",
"bottom",
")",
";",
"return",
"rect",
";",
"}"
] |
Get a rectangle with floating point boundaries using the tile width,
height, bounding box, and the bounding box section within the outer box
to build the rectangle from
@param width
width
@param height
height
@param boundingBox
full bounding box
@param boundingBoxSection
rectangle bounding box section
@return floating point rectangle
@since 1.2.0
|
[
"Get",
"a",
"rectangle",
"with",
"floating",
"point",
"boundaries",
"using",
"the",
"tile",
"width",
"height",
"bounding",
"box",
"and",
"the",
"bounding",
"box",
"section",
"within",
"the",
"outer",
"box",
"to",
"build",
"the",
"rectangle",
"from"
] |
train
|
https://github.com/ngageoint/geopackage-java/blob/889bffb5d18330a3f4bd89443acf7959ebe3a376/src/main/java/mil/nga/geopackage/tiles/TileBoundingBoxJavaUtils.java#L81-L96
|
HubSpot/Singularity
|
SingularityClient/src/main/java/com/hubspot/singularity/client/SingularityClient.java
|
SingularityClient.getTaskLogs
|
public Collection<SingularityS3Log> getTaskLogs(String taskId) {
final Function<String, String> requestUri = (host) -> String.format(S3_LOG_GET_TASK_LOGS, getApiBase(host), taskId);
final String type = String.format("S3 logs for task %s", taskId);
return getCollection(requestUri, type, S3_LOG_COLLECTION);
}
|
java
|
public Collection<SingularityS3Log> getTaskLogs(String taskId) {
final Function<String, String> requestUri = (host) -> String.format(S3_LOG_GET_TASK_LOGS, getApiBase(host), taskId);
final String type = String.format("S3 logs for task %s", taskId);
return getCollection(requestUri, type, S3_LOG_COLLECTION);
}
|
[
"public",
"Collection",
"<",
"SingularityS3Log",
">",
"getTaskLogs",
"(",
"String",
"taskId",
")",
"{",
"final",
"Function",
"<",
"String",
",",
"String",
">",
"requestUri",
"=",
"(",
"host",
")",
"-",
">",
"String",
".",
"format",
"(",
"S3_LOG_GET_TASK_LOGS",
",",
"getApiBase",
"(",
"host",
")",
",",
"taskId",
")",
";",
"final",
"String",
"type",
"=",
"String",
".",
"format",
"(",
"\"S3 logs for task %s\"",
",",
"taskId",
")",
";",
"return",
"getCollection",
"(",
"requestUri",
",",
"type",
",",
"S3_LOG_COLLECTION",
")",
";",
"}"
] |
Retrieve the list of logs stored in S3 for a specific task
@param taskId
The task ID to search for
@return
A collection of {@link SingularityS3Log}
|
[
"Retrieve",
"the",
"list",
"of",
"logs",
"stored",
"in",
"S3",
"for",
"a",
"specific",
"task"
] |
train
|
https://github.com/HubSpot/Singularity/blob/384a8c16a10aa076af5ca45c8dfcedab9e5122c8/SingularityClient/src/main/java/com/hubspot/singularity/client/SingularityClient.java#L1338-L1344
|
liferay/com-liferay-commerce
|
commerce-service/src/main/java/com/liferay/commerce/service/persistence/impl/CommerceWarehousePersistenceImpl.java
|
CommerceWarehousePersistenceImpl.removeByG_P
|
@Override
public void removeByG_P(long groupId, boolean primary) {
for (CommerceWarehouse commerceWarehouse : findByG_P(groupId, primary,
QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(commerceWarehouse);
}
}
|
java
|
@Override
public void removeByG_P(long groupId, boolean primary) {
for (CommerceWarehouse commerceWarehouse : findByG_P(groupId, primary,
QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(commerceWarehouse);
}
}
|
[
"@",
"Override",
"public",
"void",
"removeByG_P",
"(",
"long",
"groupId",
",",
"boolean",
"primary",
")",
"{",
"for",
"(",
"CommerceWarehouse",
"commerceWarehouse",
":",
"findByG_P",
"(",
"groupId",
",",
"primary",
",",
"QueryUtil",
".",
"ALL_POS",
",",
"QueryUtil",
".",
"ALL_POS",
",",
"null",
")",
")",
"{",
"remove",
"(",
"commerceWarehouse",
")",
";",
"}",
"}"
] |
Removes all the commerce warehouses where groupId = ? and primary = ? from the database.
@param groupId the group ID
@param primary the primary
|
[
"Removes",
"all",
"the",
"commerce",
"warehouses",
"where",
"groupId",
"=",
"?",
";",
"and",
"primary",
"=",
"?",
";",
"from",
"the",
"database",
"."
] |
train
|
https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-service/src/main/java/com/liferay/commerce/service/persistence/impl/CommerceWarehousePersistenceImpl.java#L2182-L2188
|
seancfoley/IPAddress
|
IPAddress/src/inet.ipaddr/inet/ipaddr/ipv4/IPv4AddressSection.java
|
IPv4AddressSection.getIPv4Count
|
private long getIPv4Count(boolean excludeZeroHosts, int segCount) {
if(!isMultiple()) {
if(excludeZeroHosts && isZero()) {
return 0L;
}
return 1L;
}
long result = getCount(i -> getSegment(i).getValueCount(), segCount);
if(excludeZeroHosts && includesZeroHost()) {
int prefixedSegment = getNetworkSegmentIndex(getNetworkPrefixLength(), IPv4Address.BYTES_PER_SEGMENT, IPv4Address.BITS_PER_SEGMENT);
long zeroHostCount = getCount(i -> {
if(i == prefixedSegment) {
IPAddressSegment seg = getSegment(i);
int shift = seg.getBitCount() - seg.getSegmentPrefixLength();
int count = ((seg.getUpperSegmentValue() >>> shift) - (seg.getSegmentValue() >>> shift)) + 1;
return count;
}
return getSegment(i).getValueCount();
}, prefixedSegment + 1);
result -= zeroHostCount;
}
return result;
}
|
java
|
private long getIPv4Count(boolean excludeZeroHosts, int segCount) {
if(!isMultiple()) {
if(excludeZeroHosts && isZero()) {
return 0L;
}
return 1L;
}
long result = getCount(i -> getSegment(i).getValueCount(), segCount);
if(excludeZeroHosts && includesZeroHost()) {
int prefixedSegment = getNetworkSegmentIndex(getNetworkPrefixLength(), IPv4Address.BYTES_PER_SEGMENT, IPv4Address.BITS_PER_SEGMENT);
long zeroHostCount = getCount(i -> {
if(i == prefixedSegment) {
IPAddressSegment seg = getSegment(i);
int shift = seg.getBitCount() - seg.getSegmentPrefixLength();
int count = ((seg.getUpperSegmentValue() >>> shift) - (seg.getSegmentValue() >>> shift)) + 1;
return count;
}
return getSegment(i).getValueCount();
}, prefixedSegment + 1);
result -= zeroHostCount;
}
return result;
}
|
[
"private",
"long",
"getIPv4Count",
"(",
"boolean",
"excludeZeroHosts",
",",
"int",
"segCount",
")",
"{",
"if",
"(",
"!",
"isMultiple",
"(",
")",
")",
"{",
"if",
"(",
"excludeZeroHosts",
"&&",
"isZero",
"(",
")",
")",
"{",
"return",
"0L",
";",
"}",
"return",
"1L",
";",
"}",
"long",
"result",
"=",
"getCount",
"(",
"i",
"->",
"getSegment",
"(",
"i",
")",
".",
"getValueCount",
"(",
")",
",",
"segCount",
")",
";",
"if",
"(",
"excludeZeroHosts",
"&&",
"includesZeroHost",
"(",
")",
")",
"{",
"int",
"prefixedSegment",
"=",
"getNetworkSegmentIndex",
"(",
"getNetworkPrefixLength",
"(",
")",
",",
"IPv4Address",
".",
"BYTES_PER_SEGMENT",
",",
"IPv4Address",
".",
"BITS_PER_SEGMENT",
")",
";",
"long",
"zeroHostCount",
"=",
"getCount",
"(",
"i",
"->",
"{",
"if",
"(",
"i",
"==",
"prefixedSegment",
")",
"{",
"IPAddressSegment",
"seg",
"=",
"getSegment",
"(",
"i",
")",
";",
"int",
"shift",
"=",
"seg",
".",
"getBitCount",
"(",
")",
"-",
"seg",
".",
"getSegmentPrefixLength",
"(",
")",
";",
"int",
"count",
"=",
"(",
"(",
"seg",
".",
"getUpperSegmentValue",
"(",
")",
">>>",
"shift",
")",
"-",
"(",
"seg",
".",
"getSegmentValue",
"(",
")",
">>>",
"shift",
")",
")",
"+",
"1",
";",
"return",
"count",
";",
"}",
"return",
"getSegment",
"(",
"i",
")",
".",
"getValueCount",
"(",
")",
";",
"}",
",",
"prefixedSegment",
"+",
"1",
")",
";",
"result",
"-=",
"zeroHostCount",
";",
"}",
"return",
"result",
";",
"}"
] |
This was added so count available as a long and not as BigInteger
|
[
"This",
"was",
"added",
"so",
"count",
"available",
"as",
"a",
"long",
"and",
"not",
"as",
"BigInteger"
] |
train
|
https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/ipv4/IPv4AddressSection.java#L768-L790
|
moparisthebest/beehive
|
beehive-netui-core/src/main/java/org/apache/beehive/netui/core/urltemplates/URLTemplates.java
|
URLTemplates.getTemplateNameByRef
|
public String getTemplateNameByRef( String refGroupName, String key )
{
String templateName = null;
Map/*< String, String >*/ templateRefGroup = ( Map ) _templateRefGroups.get( refGroupName );
if ( templateRefGroup != null )
{
templateName = ( String ) templateRefGroup.get( key );
}
return templateName;
}
|
java
|
public String getTemplateNameByRef( String refGroupName, String key )
{
String templateName = null;
Map/*< String, String >*/ templateRefGroup = ( Map ) _templateRefGroups.get( refGroupName );
if ( templateRefGroup != null )
{
templateName = ( String ) templateRefGroup.get( key );
}
return templateName;
}
|
[
"public",
"String",
"getTemplateNameByRef",
"(",
"String",
"refGroupName",
",",
"String",
"key",
")",
"{",
"String",
"templateName",
"=",
"null",
";",
"Map",
"/*< String, String >*/",
"templateRefGroup",
"=",
"(",
"Map",
")",
"_templateRefGroups",
".",
"get",
"(",
"refGroupName",
")",
";",
"if",
"(",
"templateRefGroup",
"!=",
"null",
")",
"{",
"templateName",
"=",
"(",
"String",
")",
"templateRefGroup",
".",
"get",
"(",
"key",
")",
";",
"}",
"return",
"templateName",
";",
"}"
] |
Retrieve a template name from a reference group in url-template-config.
@param refGroupName the name of the template reference group.
@param key the key to the particular template reference in the group.
@return a template name from the reference group.
|
[
"Retrieve",
"a",
"template",
"name",
"from",
"a",
"reference",
"group",
"in",
"url",
"-",
"template",
"-",
"config",
"."
] |
train
|
https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-core/src/main/java/org/apache/beehive/netui/core/urltemplates/URLTemplates.java#L129-L139
|
rhuss/jolokia
|
agent/core/src/main/java/org/jolokia/util/DateUtil.java
|
DateUtil.fromISO8601
|
public static Date fromISO8601(String pDateString) {
if (datatypeFactory != null) {
return datatypeFactory.newXMLGregorianCalendar(pDateString.trim()).toGregorianCalendar().getTime();
} else {
try {
// Try on our own, works for most cases
String date = pDateString.replaceFirst("([+-])(0\\d)\\:(\\d{2})$", "$1$2$3");
date = date.replaceFirst("Z$","+0000");
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
return dateFormat.parse(date);
} catch (ParseException e) {
throw new IllegalArgumentException("Cannot parse date '" + pDateString + "': " +e,e);
}
}
}
|
java
|
public static Date fromISO8601(String pDateString) {
if (datatypeFactory != null) {
return datatypeFactory.newXMLGregorianCalendar(pDateString.trim()).toGregorianCalendar().getTime();
} else {
try {
// Try on our own, works for most cases
String date = pDateString.replaceFirst("([+-])(0\\d)\\:(\\d{2})$", "$1$2$3");
date = date.replaceFirst("Z$","+0000");
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
return dateFormat.parse(date);
} catch (ParseException e) {
throw new IllegalArgumentException("Cannot parse date '" + pDateString + "': " +e,e);
}
}
}
|
[
"public",
"static",
"Date",
"fromISO8601",
"(",
"String",
"pDateString",
")",
"{",
"if",
"(",
"datatypeFactory",
"!=",
"null",
")",
"{",
"return",
"datatypeFactory",
".",
"newXMLGregorianCalendar",
"(",
"pDateString",
".",
"trim",
"(",
")",
")",
".",
"toGregorianCalendar",
"(",
")",
".",
"getTime",
"(",
")",
";",
"}",
"else",
"{",
"try",
"{",
"// Try on our own, works for most cases",
"String",
"date",
"=",
"pDateString",
".",
"replaceFirst",
"(",
"\"([+-])(0\\\\d)\\\\:(\\\\d{2})$\"",
",",
"\"$1$2$3\"",
")",
";",
"date",
"=",
"date",
".",
"replaceFirst",
"(",
"\"Z$\"",
",",
"\"+0000\"",
")",
";",
"SimpleDateFormat",
"dateFormat",
"=",
"new",
"SimpleDateFormat",
"(",
"\"yyyy-MM-dd'T'HH:mm:ssZ\"",
")",
";",
"return",
"dateFormat",
".",
"parse",
"(",
"date",
")",
";",
"}",
"catch",
"(",
"ParseException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Cannot parse date '\"",
"+",
"pDateString",
"+",
"\"': \"",
"+",
"e",
",",
"e",
")",
";",
"}",
"}",
"}"
] |
Parse an ISO-8601 string into an date object
@param pDateString date string to parse
@return the parse date
@throws IllegalArgumentException if the provided string does not conform to ISO-8601
|
[
"Parse",
"an",
"ISO",
"-",
"8601",
"string",
"into",
"an",
"date",
"object"
] |
train
|
https://github.com/rhuss/jolokia/blob/dc95e7bef859b1829776c5a84c8f7738f5d7d9c3/agent/core/src/main/java/org/jolokia/util/DateUtil.java#L55-L69
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java
|
ProjectTreeController.addCalendar
|
private void addCalendar(MpxjTreeNode parentNode, final ProjectCalendar calendar)
{
MpxjTreeNode calendarNode = new MpxjTreeNode(calendar, CALENDAR_EXCLUDED_METHODS)
{
@Override public String toString()
{
return calendar.getName();
}
};
parentNode.add(calendarNode);
MpxjTreeNode daysFolder = new MpxjTreeNode("Days");
calendarNode.add(daysFolder);
for (Day day : Day.values())
{
addCalendarDay(daysFolder, calendar, day);
}
MpxjTreeNode exceptionsFolder = new MpxjTreeNode("Exceptions");
calendarNode.add(exceptionsFolder);
for (ProjectCalendarException exception : calendar.getCalendarExceptions())
{
addCalendarException(exceptionsFolder, exception);
}
}
|
java
|
private void addCalendar(MpxjTreeNode parentNode, final ProjectCalendar calendar)
{
MpxjTreeNode calendarNode = new MpxjTreeNode(calendar, CALENDAR_EXCLUDED_METHODS)
{
@Override public String toString()
{
return calendar.getName();
}
};
parentNode.add(calendarNode);
MpxjTreeNode daysFolder = new MpxjTreeNode("Days");
calendarNode.add(daysFolder);
for (Day day : Day.values())
{
addCalendarDay(daysFolder, calendar, day);
}
MpxjTreeNode exceptionsFolder = new MpxjTreeNode("Exceptions");
calendarNode.add(exceptionsFolder);
for (ProjectCalendarException exception : calendar.getCalendarExceptions())
{
addCalendarException(exceptionsFolder, exception);
}
}
|
[
"private",
"void",
"addCalendar",
"(",
"MpxjTreeNode",
"parentNode",
",",
"final",
"ProjectCalendar",
"calendar",
")",
"{",
"MpxjTreeNode",
"calendarNode",
"=",
"new",
"MpxjTreeNode",
"(",
"calendar",
",",
"CALENDAR_EXCLUDED_METHODS",
")",
"{",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"calendar",
".",
"getName",
"(",
")",
";",
"}",
"}",
";",
"parentNode",
".",
"add",
"(",
"calendarNode",
")",
";",
"MpxjTreeNode",
"daysFolder",
"=",
"new",
"MpxjTreeNode",
"(",
"\"Days\"",
")",
";",
"calendarNode",
".",
"add",
"(",
"daysFolder",
")",
";",
"for",
"(",
"Day",
"day",
":",
"Day",
".",
"values",
"(",
")",
")",
"{",
"addCalendarDay",
"(",
"daysFolder",
",",
"calendar",
",",
"day",
")",
";",
"}",
"MpxjTreeNode",
"exceptionsFolder",
"=",
"new",
"MpxjTreeNode",
"(",
"\"Exceptions\"",
")",
";",
"calendarNode",
".",
"add",
"(",
"exceptionsFolder",
")",
";",
"for",
"(",
"ProjectCalendarException",
"exception",
":",
"calendar",
".",
"getCalendarExceptions",
"(",
")",
")",
"{",
"addCalendarException",
"(",
"exceptionsFolder",
",",
"exception",
")",
";",
"}",
"}"
] |
Add a calendar node.
@param parentNode parent node
@param calendar calendar
|
[
"Add",
"a",
"calendar",
"node",
"."
] |
train
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java#L257-L283
|
hazelcast/hazelcast
|
hazelcast-client/src/main/java/com/hazelcast/client/config/ClientConfig.java
|
ClientConfig.setProperty
|
public ClientConfig setProperty(String name, String value) {
properties.put(name, value);
return this;
}
|
java
|
public ClientConfig setProperty(String name, String value) {
properties.put(name, value);
return this;
}
|
[
"public",
"ClientConfig",
"setProperty",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"properties",
".",
"put",
"(",
"name",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] |
Sets the value of a named property.
@param name property name
@param value value of the property
@return configured {@link com.hazelcast.client.config.ClientConfig} for chaining
|
[
"Sets",
"the",
"value",
"of",
"a",
"named",
"property",
"."
] |
train
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast-client/src/main/java/com/hazelcast/client/config/ClientConfig.java#L218-L221
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java
|
ApiOvhMe.deposit_depositId_details_depositDetailId_GET
|
public OvhDepositDetail deposit_depositId_details_depositDetailId_GET(String depositId, String depositDetailId) throws IOException {
String qPath = "/me/deposit/{depositId}/details/{depositDetailId}";
StringBuilder sb = path(qPath, depositId, depositDetailId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhDepositDetail.class);
}
|
java
|
public OvhDepositDetail deposit_depositId_details_depositDetailId_GET(String depositId, String depositDetailId) throws IOException {
String qPath = "/me/deposit/{depositId}/details/{depositDetailId}";
StringBuilder sb = path(qPath, depositId, depositDetailId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhDepositDetail.class);
}
|
[
"public",
"OvhDepositDetail",
"deposit_depositId_details_depositDetailId_GET",
"(",
"String",
"depositId",
",",
"String",
"depositDetailId",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/me/deposit/{depositId}/details/{depositDetailId}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"depositId",
",",
"depositDetailId",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhDepositDetail",
".",
"class",
")",
";",
"}"
] |
Get this object properties
REST: GET /me/deposit/{depositId}/details/{depositDetailId}
@param depositId [required]
@param depositDetailId [required]
|
[
"Get",
"this",
"object",
"properties"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java#L3278-L3283
|
lightblueseas/file-worker
|
src/main/java/de/alpharogroup/file/copy/CopyFileExtensions.java
|
CopyFileExtensions.copyFileToDirectory
|
public static boolean copyFileToDirectory(final File source, final File destinationDir)
throws FileIsNotADirectoryException, IOException, FileIsADirectoryException
{
return copyFileToDirectory(source, destinationDir, true);
}
|
java
|
public static boolean copyFileToDirectory(final File source, final File destinationDir)
throws FileIsNotADirectoryException, IOException, FileIsADirectoryException
{
return copyFileToDirectory(source, destinationDir, true);
}
|
[
"public",
"static",
"boolean",
"copyFileToDirectory",
"(",
"final",
"File",
"source",
",",
"final",
"File",
"destinationDir",
")",
"throws",
"FileIsNotADirectoryException",
",",
"IOException",
",",
"FileIsADirectoryException",
"{",
"return",
"copyFileToDirectory",
"(",
"source",
",",
"destinationDir",
",",
"true",
")",
";",
"}"
] |
Copies the given source file to the given destination directory.
@param source
The source file to copy in the destination directory.
@param destinationDir
The destination directory.
@return 's true if the file is copied to the destination directory, otherwise false.
@throws FileIsNotADirectoryException
Is thrown if the source file is not a directory.
@throws IOException
Is thrown if an error occurs by reading or writing.
@throws FileIsADirectoryException
Is thrown if the destination file is a directory.
|
[
"Copies",
"the",
"given",
"source",
"file",
"to",
"the",
"given",
"destination",
"directory",
"."
] |
train
|
https://github.com/lightblueseas/file-worker/blob/2c81de10fb5d68de64c1abc3ed64ca681ce76da8/src/main/java/de/alpharogroup/file/copy/CopyFileExtensions.java#L593-L597
|
MTDdk/jawn
|
jawn-core/src/main/java/net/javapla/jawn/core/images/ImageHandlerBuilder.java
|
ImageHandlerBuilder.cropToAspect
|
public ImageHandlerBuilder cropToAspect(int width, int height) {
int original_width = image.getWidth();
int original_height = image.getHeight();
int bound_width = width;
int bound_height = height;
int new_width = original_width;
int new_height = original_height;
int x = 0, y = 0;
// We need these if any resizing is going to happen, as the precision factors
// are no longer sufficiently precise
double wfactor = (double)original_width/bound_width;
double hfactor = (double)original_height/bound_height;
// Calculating the factor between the original dimensions and the wanted dimensions
// Using precision down to two decimals.
double precision = 100d;
double wprecisionfactor = ((int)((wfactor) * precision)) / precision;
double hprecisionfactor = ((int)((hfactor) * precision)) / precision;
if (wprecisionfactor == hprecisionfactor) {
// they are (relatively) equal
// just use the original image dimensions
return this;
}
if (wprecisionfactor < hprecisionfactor) {
// keep the original width
// calculate the new height from the wfactor
new_height = (int) (bound_height * wfactor);
// calculate new coordinate to keep center
y = Math.abs(original_height - new_height) >> 1; // divide by 2
} else if (wprecisionfactor > hprecisionfactor) {
// keep the original height
// calculate the new width from the hfactor
new_width = (int) (bound_width * hfactor);
// calculate new coordinate to keep center
x = Math.abs(original_width - new_width) >> 1; // divide by 2
}
BufferedImage crop = Scalr.crop(image, x, y, new_width, new_height);
image.flush();// cannot throw
image = crop;
return this;
}
|
java
|
public ImageHandlerBuilder cropToAspect(int width, int height) {
int original_width = image.getWidth();
int original_height = image.getHeight();
int bound_width = width;
int bound_height = height;
int new_width = original_width;
int new_height = original_height;
int x = 0, y = 0;
// We need these if any resizing is going to happen, as the precision factors
// are no longer sufficiently precise
double wfactor = (double)original_width/bound_width;
double hfactor = (double)original_height/bound_height;
// Calculating the factor between the original dimensions and the wanted dimensions
// Using precision down to two decimals.
double precision = 100d;
double wprecisionfactor = ((int)((wfactor) * precision)) / precision;
double hprecisionfactor = ((int)((hfactor) * precision)) / precision;
if (wprecisionfactor == hprecisionfactor) {
// they are (relatively) equal
// just use the original image dimensions
return this;
}
if (wprecisionfactor < hprecisionfactor) {
// keep the original width
// calculate the new height from the wfactor
new_height = (int) (bound_height * wfactor);
// calculate new coordinate to keep center
y = Math.abs(original_height - new_height) >> 1; // divide by 2
} else if (wprecisionfactor > hprecisionfactor) {
// keep the original height
// calculate the new width from the hfactor
new_width = (int) (bound_width * hfactor);
// calculate new coordinate to keep center
x = Math.abs(original_width - new_width) >> 1; // divide by 2
}
BufferedImage crop = Scalr.crop(image, x, y, new_width, new_height);
image.flush();// cannot throw
image = crop;
return this;
}
|
[
"public",
"ImageHandlerBuilder",
"cropToAspect",
"(",
"int",
"width",
",",
"int",
"height",
")",
"{",
"int",
"original_width",
"=",
"image",
".",
"getWidth",
"(",
")",
";",
"int",
"original_height",
"=",
"image",
".",
"getHeight",
"(",
")",
";",
"int",
"bound_width",
"=",
"width",
";",
"int",
"bound_height",
"=",
"height",
";",
"int",
"new_width",
"=",
"original_width",
";",
"int",
"new_height",
"=",
"original_height",
";",
"int",
"x",
"=",
"0",
",",
"y",
"=",
"0",
";",
"// We need these if any resizing is going to happen, as the precision factors",
"// are no longer sufficiently precise",
"double",
"wfactor",
"=",
"(",
"double",
")",
"original_width",
"/",
"bound_width",
";",
"double",
"hfactor",
"=",
"(",
"double",
")",
"original_height",
"/",
"bound_height",
";",
"// Calculating the factor between the original dimensions and the wanted dimensions",
"// Using precision down to two decimals.",
"double",
"precision",
"=",
"100d",
";",
"double",
"wprecisionfactor",
"=",
"(",
"(",
"int",
")",
"(",
"(",
"wfactor",
")",
"*",
"precision",
")",
")",
"/",
"precision",
";",
"double",
"hprecisionfactor",
"=",
"(",
"(",
"int",
")",
"(",
"(",
"hfactor",
")",
"*",
"precision",
")",
")",
"/",
"precision",
";",
"if",
"(",
"wprecisionfactor",
"==",
"hprecisionfactor",
")",
"{",
"// they are (relatively) equal",
"// just use the original image dimensions",
"return",
"this",
";",
"}",
"if",
"(",
"wprecisionfactor",
"<",
"hprecisionfactor",
")",
"{",
"// keep the original width",
"// calculate the new height from the wfactor",
"new_height",
"=",
"(",
"int",
")",
"(",
"bound_height",
"*",
"wfactor",
")",
";",
"// calculate new coordinate to keep center",
"y",
"=",
"Math",
".",
"abs",
"(",
"original_height",
"-",
"new_height",
")",
">>",
"1",
";",
"// divide by 2",
"}",
"else",
"if",
"(",
"wprecisionfactor",
">",
"hprecisionfactor",
")",
"{",
"// keep the original height",
"// calculate the new width from the hfactor",
"new_width",
"=",
"(",
"int",
")",
"(",
"bound_width",
"*",
"hfactor",
")",
";",
"// calculate new coordinate to keep center",
"x",
"=",
"Math",
".",
"abs",
"(",
"original_width",
"-",
"new_width",
")",
">>",
"1",
";",
"// divide by 2",
"}",
"BufferedImage",
"crop",
"=",
"Scalr",
".",
"crop",
"(",
"image",
",",
"x",
",",
"y",
",",
"new_width",
",",
"new_height",
")",
";",
"image",
".",
"flush",
"(",
")",
";",
"// cannot throw",
"image",
"=",
"crop",
";",
"return",
"this",
";",
"}"
] |
Crop the image to a given aspect.
<br>
The aspect is the desired proportions of the image, which will be kept when cropping.
<p>
The usecase for this method is when you have an image, that you want to crop into a certain proportion,
but want to keep the original dimensions as much as possible.
@param width
@param height
@return
|
[
"Crop",
"the",
"image",
"to",
"a",
"given",
"aspect",
".",
"<br",
">",
"The",
"aspect",
"is",
"the",
"desired",
"proportions",
"of",
"the",
"image",
"which",
"will",
"be",
"kept",
"when",
"cropping",
".",
"<p",
">",
"The",
"usecase",
"for",
"this",
"method",
"is",
"when",
"you",
"have",
"an",
"image",
"that",
"you",
"want",
"to",
"crop",
"into",
"a",
"certain",
"proportion",
"but",
"want",
"to",
"keep",
"the",
"original",
"dimensions",
"as",
"much",
"as",
"possible",
"."
] |
train
|
https://github.com/MTDdk/jawn/blob/4ec2d09b97d413efdead7487e6075e5bfd13b925/jawn-core/src/main/java/net/javapla/jawn/core/images/ImageHandlerBuilder.java#L123-L171
|
google/closure-templates
|
java/src/com/google/template/soy/jbcsrc/restricted/BytecodeUtils.java
|
BytecodeUtils.newHashMap
|
public static Expression newHashMap(
Iterable<? extends Expression> keys, Iterable<? extends Expression> values) {
return newMap(keys, values, ConstructorRef.HASH_MAP_CAPACITY, HASH_MAP_TYPE);
}
|
java
|
public static Expression newHashMap(
Iterable<? extends Expression> keys, Iterable<? extends Expression> values) {
return newMap(keys, values, ConstructorRef.HASH_MAP_CAPACITY, HASH_MAP_TYPE);
}
|
[
"public",
"static",
"Expression",
"newHashMap",
"(",
"Iterable",
"<",
"?",
"extends",
"Expression",
">",
"keys",
",",
"Iterable",
"<",
"?",
"extends",
"Expression",
">",
"values",
")",
"{",
"return",
"newMap",
"(",
"keys",
",",
"values",
",",
"ConstructorRef",
".",
"HASH_MAP_CAPACITY",
",",
"HASH_MAP_TYPE",
")",
";",
"}"
] |
Returns an expression that returns a new {@link HashMap} containing all the given entries.
|
[
"Returns",
"an",
"expression",
"that",
"returns",
"a",
"new",
"{"
] |
train
|
https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/restricted/BytecodeUtils.java#L898-L901
|
line/armeria
|
core/src/main/java/com/linecorp/armeria/client/SessionProtocolNegotiationCache.java
|
SessionProtocolNegotiationCache.isUnsupported
|
public static boolean isUnsupported(SocketAddress remoteAddress, SessionProtocol protocol) {
final String key = key(remoteAddress);
final CacheEntry e;
final long stamp = lock.readLock();
try {
e = cache.get(key);
} finally {
lock.unlockRead(stamp);
}
if (e == null) {
// Can't tell if it's unsupported
return false;
}
return e.isUnsupported(protocol);
}
|
java
|
public static boolean isUnsupported(SocketAddress remoteAddress, SessionProtocol protocol) {
final String key = key(remoteAddress);
final CacheEntry e;
final long stamp = lock.readLock();
try {
e = cache.get(key);
} finally {
lock.unlockRead(stamp);
}
if (e == null) {
// Can't tell if it's unsupported
return false;
}
return e.isUnsupported(protocol);
}
|
[
"public",
"static",
"boolean",
"isUnsupported",
"(",
"SocketAddress",
"remoteAddress",
",",
"SessionProtocol",
"protocol",
")",
"{",
"final",
"String",
"key",
"=",
"key",
"(",
"remoteAddress",
")",
";",
"final",
"CacheEntry",
"e",
";",
"final",
"long",
"stamp",
"=",
"lock",
".",
"readLock",
"(",
")",
";",
"try",
"{",
"e",
"=",
"cache",
".",
"get",
"(",
"key",
")",
";",
"}",
"finally",
"{",
"lock",
".",
"unlockRead",
"(",
"stamp",
")",
";",
"}",
"if",
"(",
"e",
"==",
"null",
")",
"{",
"// Can't tell if it's unsupported",
"return",
"false",
";",
"}",
"return",
"e",
".",
"isUnsupported",
"(",
"protocol",
")",
";",
"}"
] |
Returns {@code true} if the specified {@code remoteAddress} is known to have no support for
the specified {@link SessionProtocol}.
|
[
"Returns",
"{"
] |
train
|
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/client/SessionProtocolNegotiationCache.java#L63-L79
|
HanSolo/SteelSeries-Swing
|
src/main/java/eu/hansolo/steelseries/gauges/AbstractRadial.java
|
AbstractRadial.createArea3DEffectGradient
|
protected RadialGradientPaint createArea3DEffectGradient(final int WIDTH, final float RADIUS_FACTOR) {
final float[] FRACTIONS;
final Color[] COLORS;
FRACTIONS = new float[]{
0.0f,
0.6f,
1.0f
};
COLORS = new Color[]{
new Color(1.0f, 1.0f, 1.0f, 0.75f),
new Color(1.0f, 1.0f, 1.0f, 0.0f),
new Color(0.0f, 0.0f, 0.0f, 0.3f)
};
final Point2D GRADIENT_CENTER = new Point2D.Double(WIDTH / 2.0, WIDTH / 2.0);
return new RadialGradientPaint(GRADIENT_CENTER, WIDTH * RADIUS_FACTOR, FRACTIONS, COLORS);
}
|
java
|
protected RadialGradientPaint createArea3DEffectGradient(final int WIDTH, final float RADIUS_FACTOR) {
final float[] FRACTIONS;
final Color[] COLORS;
FRACTIONS = new float[]{
0.0f,
0.6f,
1.0f
};
COLORS = new Color[]{
new Color(1.0f, 1.0f, 1.0f, 0.75f),
new Color(1.0f, 1.0f, 1.0f, 0.0f),
new Color(0.0f, 0.0f, 0.0f, 0.3f)
};
final Point2D GRADIENT_CENTER = new Point2D.Double(WIDTH / 2.0, WIDTH / 2.0);
return new RadialGradientPaint(GRADIENT_CENTER, WIDTH * RADIUS_FACTOR, FRACTIONS, COLORS);
}
|
[
"protected",
"RadialGradientPaint",
"createArea3DEffectGradient",
"(",
"final",
"int",
"WIDTH",
",",
"final",
"float",
"RADIUS_FACTOR",
")",
"{",
"final",
"float",
"[",
"]",
"FRACTIONS",
";",
"final",
"Color",
"[",
"]",
"COLORS",
";",
"FRACTIONS",
"=",
"new",
"float",
"[",
"]",
"{",
"0.0f",
",",
"0.6f",
",",
"1.0f",
"}",
";",
"COLORS",
"=",
"new",
"Color",
"[",
"]",
"{",
"new",
"Color",
"(",
"1.0f",
",",
"1.0f",
",",
"1.0f",
",",
"0.75f",
")",
",",
"new",
"Color",
"(",
"1.0f",
",",
"1.0f",
",",
"1.0f",
",",
"0.0f",
")",
",",
"new",
"Color",
"(",
"0.0f",
",",
"0.0f",
",",
"0.0f",
",",
"0.3f",
")",
"}",
";",
"final",
"Point2D",
"GRADIENT_CENTER",
"=",
"new",
"Point2D",
".",
"Double",
"(",
"WIDTH",
"/",
"2.0",
",",
"WIDTH",
"/",
"2.0",
")",
";",
"return",
"new",
"RadialGradientPaint",
"(",
"GRADIENT_CENTER",
",",
"WIDTH",
"*",
"RADIUS_FACTOR",
",",
"FRACTIONS",
",",
"COLORS",
")",
";",
"}"
] |
Returns a radial gradient paint that will be used as overlay for the track or area image
to achieve some kind of a 3d effect.
@param WIDTH
@param RADIUS_FACTOR
@return a radial gradient paint that will be used as overlay for the track or area image
|
[
"Returns",
"a",
"radial",
"gradient",
"paint",
"that",
"will",
"be",
"used",
"as",
"overlay",
"for",
"the",
"track",
"or",
"area",
"image",
"to",
"achieve",
"some",
"kind",
"of",
"a",
"3d",
"effect",
"."
] |
train
|
https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/gauges/AbstractRadial.java#L1238-L1255
|
shrinkwrap/resolver
|
api/src/main/java/org/jboss/shrinkwrap/resolver/api/ResolverSystemFactory.java
|
ResolverSystemFactory.createFromUserView
|
static <RESOLVERSYSTEMTYPE extends ResolverSystem> RESOLVERSYSTEMTYPE createFromUserView(
final Class<RESOLVERSYSTEMTYPE> userViewClass, final ClassLoader cl) {
assert userViewClass != null : "user view class must be specified";
assert cl != null : "ClassLoader must be specified";
// get SPI service loader
final Object spiServiceLoader = new Invokable(cl, CLASS_NAME_SPISERVICELOADER)
.invokeConstructor(new Class[] { ClassLoader.class }, new Object[] { cl });
// return service loader implementation
final Object serviceLoader = new Invokable(cl, CLASS_NAME_SPISERVICELOADER).invokeMethod(METHOD_NAME_ONLY_ONE,
new Class[] { Class.class, Class.class }, spiServiceLoader,
new Object[] { Invokable.loadClass(cl, CLASS_NAME_SPISERVICELOADER), spiServiceLoader.getClass() });
// get registry
final Object serviceRegistry = new Invokable(cl, CLASS_NAME_SERVICEREGISTRY).invokeConstructor(
new Class<?>[] { Invokable.loadClass(cl, CLASS_NAME_SERVICELOADER) },
new Object[] { serviceLoader });
// register itself
new Invokable(cl, serviceRegistry.getClass()).invokeMethod(METHOD_NAME_REGISTER,
new Class<?>[] { serviceRegistry.getClass() }, null, new Object[] { serviceRegistry });
Object userViewObject = new Invokable(cl, serviceRegistry.getClass()).invokeMethod(METHOD_NAME_ONLY_ONE,
new Class<?>[] { Class.class }, serviceRegistry, new Object[] { userViewClass });
return userViewClass.cast(userViewObject);
}
|
java
|
static <RESOLVERSYSTEMTYPE extends ResolverSystem> RESOLVERSYSTEMTYPE createFromUserView(
final Class<RESOLVERSYSTEMTYPE> userViewClass, final ClassLoader cl) {
assert userViewClass != null : "user view class must be specified";
assert cl != null : "ClassLoader must be specified";
// get SPI service loader
final Object spiServiceLoader = new Invokable(cl, CLASS_NAME_SPISERVICELOADER)
.invokeConstructor(new Class[] { ClassLoader.class }, new Object[] { cl });
// return service loader implementation
final Object serviceLoader = new Invokable(cl, CLASS_NAME_SPISERVICELOADER).invokeMethod(METHOD_NAME_ONLY_ONE,
new Class[] { Class.class, Class.class }, spiServiceLoader,
new Object[] { Invokable.loadClass(cl, CLASS_NAME_SPISERVICELOADER), spiServiceLoader.getClass() });
// get registry
final Object serviceRegistry = new Invokable(cl, CLASS_NAME_SERVICEREGISTRY).invokeConstructor(
new Class<?>[] { Invokable.loadClass(cl, CLASS_NAME_SERVICELOADER) },
new Object[] { serviceLoader });
// register itself
new Invokable(cl, serviceRegistry.getClass()).invokeMethod(METHOD_NAME_REGISTER,
new Class<?>[] { serviceRegistry.getClass() }, null, new Object[] { serviceRegistry });
Object userViewObject = new Invokable(cl, serviceRegistry.getClass()).invokeMethod(METHOD_NAME_ONLY_ONE,
new Class<?>[] { Class.class }, serviceRegistry, new Object[] { userViewClass });
return userViewClass.cast(userViewObject);
}
|
[
"static",
"<",
"RESOLVERSYSTEMTYPE",
"extends",
"ResolverSystem",
">",
"RESOLVERSYSTEMTYPE",
"createFromUserView",
"(",
"final",
"Class",
"<",
"RESOLVERSYSTEMTYPE",
">",
"userViewClass",
",",
"final",
"ClassLoader",
"cl",
")",
"{",
"assert",
"userViewClass",
"!=",
"null",
":",
"\"user view class must be specified\"",
";",
"assert",
"cl",
"!=",
"null",
":",
"\"ClassLoader must be specified\"",
";",
"// get SPI service loader",
"final",
"Object",
"spiServiceLoader",
"=",
"new",
"Invokable",
"(",
"cl",
",",
"CLASS_NAME_SPISERVICELOADER",
")",
".",
"invokeConstructor",
"(",
"new",
"Class",
"[",
"]",
"{",
"ClassLoader",
".",
"class",
"}",
",",
"new",
"Object",
"[",
"]",
"{",
"cl",
"}",
")",
";",
"// return service loader implementation",
"final",
"Object",
"serviceLoader",
"=",
"new",
"Invokable",
"(",
"cl",
",",
"CLASS_NAME_SPISERVICELOADER",
")",
".",
"invokeMethod",
"(",
"METHOD_NAME_ONLY_ONE",
",",
"new",
"Class",
"[",
"]",
"{",
"Class",
".",
"class",
",",
"Class",
".",
"class",
"}",
",",
"spiServiceLoader",
",",
"new",
"Object",
"[",
"]",
"{",
"Invokable",
".",
"loadClass",
"(",
"cl",
",",
"CLASS_NAME_SPISERVICELOADER",
")",
",",
"spiServiceLoader",
".",
"getClass",
"(",
")",
"}",
")",
";",
"// get registry",
"final",
"Object",
"serviceRegistry",
"=",
"new",
"Invokable",
"(",
"cl",
",",
"CLASS_NAME_SERVICEREGISTRY",
")",
".",
"invokeConstructor",
"(",
"new",
"Class",
"<",
"?",
">",
"[",
"]",
"{",
"Invokable",
".",
"loadClass",
"(",
"cl",
",",
"CLASS_NAME_SERVICELOADER",
")",
"}",
",",
"new",
"Object",
"[",
"]",
"{",
"serviceLoader",
"}",
")",
";",
"// register itself",
"new",
"Invokable",
"(",
"cl",
",",
"serviceRegistry",
".",
"getClass",
"(",
")",
")",
".",
"invokeMethod",
"(",
"METHOD_NAME_REGISTER",
",",
"new",
"Class",
"<",
"?",
">",
"[",
"]",
"{",
"serviceRegistry",
".",
"getClass",
"(",
")",
"}",
",",
"null",
",",
"new",
"Object",
"[",
"]",
"{",
"serviceRegistry",
"}",
")",
";",
"Object",
"userViewObject",
"=",
"new",
"Invokable",
"(",
"cl",
",",
"serviceRegistry",
".",
"getClass",
"(",
")",
")",
".",
"invokeMethod",
"(",
"METHOD_NAME_ONLY_ONE",
",",
"new",
"Class",
"<",
"?",
">",
"[",
"]",
"{",
"Class",
".",
"class",
"}",
",",
"serviceRegistry",
",",
"new",
"Object",
"[",
"]",
"{",
"userViewClass",
"}",
")",
";",
"return",
"userViewClass",
".",
"cast",
"(",
"userViewObject",
")",
";",
"}"
] |
Creates a new {@link ResolverSystem} instance of the specified user view type using the specified {@link ClassLoader}.
Will consult a configuration file visible to the specified {@link ClassLoader} named
"META-INF/services/$fullyQualfiedClassName" which should contain a key=value format with the key
{@link ResolverSystemFactory#KEY_IMPL_CLASS_NAME}. The implementation class name must have a no-arg constructor.
@param userViewClass The user view type
@param cl The {@link ClassLoader}
@return The new {@link ResolverSystem} instance of the specified user view type created by using the specified
{@link ClassLoader}.
|
[
"Creates",
"a",
"new",
"{",
"@link",
"ResolverSystem",
"}",
"instance",
"of",
"the",
"specified",
"user",
"view",
"type",
"using",
"the",
"specified",
"{",
"@link",
"ClassLoader",
"}",
".",
"Will",
"consult",
"a",
"configuration",
"file",
"visible",
"to",
"the",
"specified",
"{",
"@link",
"ClassLoader",
"}",
"named",
"META",
"-",
"INF",
"/",
"services",
"/",
"$fullyQualfiedClassName",
"which",
"should",
"contain",
"a",
"key",
"=",
"value",
"format",
"with",
"the",
"key",
"{",
"@link",
"ResolverSystemFactory#KEY_IMPL_CLASS_NAME",
"}",
".",
"The",
"implementation",
"class",
"name",
"must",
"have",
"a",
"no",
"-",
"arg",
"constructor",
"."
] |
train
|
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/api/src/main/java/org/jboss/shrinkwrap/resolver/api/ResolverSystemFactory.java#L69-L98
|
ddf-project/DDF
|
core/src/main/java/io/ddf/util/DDFUtils.java
|
DDFUtils.generateObjectName
|
public static String generateObjectName(Object obj, String sourceName, String operation, String desiredName) {
if (Strings.isNullOrEmpty(desiredName)) {
if (Strings.isNullOrEmpty(sourceName)) {
return generateUniqueName(obj);
} else if (Strings.isNullOrEmpty(operation)) {
desiredName = sourceName;
} else {
desiredName = String.format("%s_%s", sourceName, operation);
}
}
desiredName = desiredName.replace("-", "_");
return (Strings.isNullOrEmpty(desiredName) || desiredName.length() > MAX_DESIRED_NAME_LEN) ? generateUniqueName(obj)
: ensureUniqueness(desiredName);
}
|
java
|
public static String generateObjectName(Object obj, String sourceName, String operation, String desiredName) {
if (Strings.isNullOrEmpty(desiredName)) {
if (Strings.isNullOrEmpty(sourceName)) {
return generateUniqueName(obj);
} else if (Strings.isNullOrEmpty(operation)) {
desiredName = sourceName;
} else {
desiredName = String.format("%s_%s", sourceName, operation);
}
}
desiredName = desiredName.replace("-", "_");
return (Strings.isNullOrEmpty(desiredName) || desiredName.length() > MAX_DESIRED_NAME_LEN) ? generateUniqueName(obj)
: ensureUniqueness(desiredName);
}
|
[
"public",
"static",
"String",
"generateObjectName",
"(",
"Object",
"obj",
",",
"String",
"sourceName",
",",
"String",
"operation",
",",
"String",
"desiredName",
")",
"{",
"if",
"(",
"Strings",
".",
"isNullOrEmpty",
"(",
"desiredName",
")",
")",
"{",
"if",
"(",
"Strings",
".",
"isNullOrEmpty",
"(",
"sourceName",
")",
")",
"{",
"return",
"generateUniqueName",
"(",
"obj",
")",
";",
"}",
"else",
"if",
"(",
"Strings",
".",
"isNullOrEmpty",
"(",
"operation",
")",
")",
"{",
"desiredName",
"=",
"sourceName",
";",
"}",
"else",
"{",
"desiredName",
"=",
"String",
".",
"format",
"(",
"\"%s_%s\"",
",",
"sourceName",
",",
"operation",
")",
";",
"}",
"}",
"desiredName",
"=",
"desiredName",
".",
"replace",
"(",
"\"-\"",
",",
"\"_\"",
")",
";",
"return",
"(",
"Strings",
".",
"isNullOrEmpty",
"(",
"desiredName",
")",
"||",
"desiredName",
".",
"length",
"(",
")",
">",
"MAX_DESIRED_NAME_LEN",
")",
"?",
"generateUniqueName",
"(",
"obj",
")",
":",
"ensureUniqueness",
"(",
"desiredName",
")",
";",
"}"
] |
Heuristic: if the source/parent already has a table name then we can add something that identifies the operation.
Plus a unique extension if needed. If the starting name is already too long, we call that a degenerate case, for
which we go back to UUID-based. All this is overridden if the caller specifies a desired name. For the desired name
we still attach an extension if needed to make it unique.
@param obj object to be named, no hyphens
@param sourceName the name of the source object, if any, based on which we will generate the name
@param operation the name/brief description of the operation, if any, which we would use as an extension to the sourceName
@param desiredName the desired name to be used, if any
@return
|
[
"Heuristic",
":",
"if",
"the",
"source",
"/",
"parent",
"already",
"has",
"a",
"table",
"name",
"then",
"we",
"can",
"add",
"something",
"that",
"identifies",
"the",
"operation",
".",
"Plus",
"a",
"unique",
"extension",
"if",
"needed",
".",
"If",
"the",
"starting",
"name",
"is",
"already",
"too",
"long",
"we",
"call",
"that",
"a",
"degenerate",
"case",
"for",
"which",
"we",
"go",
"back",
"to",
"UUID",
"-",
"based",
".",
"All",
"this",
"is",
"overridden",
"if",
"the",
"caller",
"specifies",
"a",
"desired",
"name",
".",
"For",
"the",
"desired",
"name",
"we",
"still",
"attach",
"an",
"extension",
"if",
"needed",
"to",
"make",
"it",
"unique",
"."
] |
train
|
https://github.com/ddf-project/DDF/blob/e4e68315dcec1ed8b287bf1ee73baa88e7e41eba/core/src/main/java/io/ddf/util/DDFUtils.java#L26-L44
|
cloudant/sync-android
|
cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/common/ValueListMap.java
|
ValueListMap.addValuesToKey
|
public void addValuesToKey(K key, Collection<V> valueCollection) {
if (!valueCollection.isEmpty()) {
// Create a new collection to store the values (will be changed to internal type by call
// to putIfAbsent anyway)
List<V> collectionToAppendValuesOn = new ArrayList<V>();
List<V> existing = this.putIfAbsent(key, collectionToAppendValuesOn);
if (existing != null) {
// Already had a collection, discard the new one and use existing
collectionToAppendValuesOn = existing;
}
collectionToAppendValuesOn.addAll(valueCollection);
}
}
|
java
|
public void addValuesToKey(K key, Collection<V> valueCollection) {
if (!valueCollection.isEmpty()) {
// Create a new collection to store the values (will be changed to internal type by call
// to putIfAbsent anyway)
List<V> collectionToAppendValuesOn = new ArrayList<V>();
List<V> existing = this.putIfAbsent(key, collectionToAppendValuesOn);
if (existing != null) {
// Already had a collection, discard the new one and use existing
collectionToAppendValuesOn = existing;
}
collectionToAppendValuesOn.addAll(valueCollection);
}
}
|
[
"public",
"void",
"addValuesToKey",
"(",
"K",
"key",
",",
"Collection",
"<",
"V",
">",
"valueCollection",
")",
"{",
"if",
"(",
"!",
"valueCollection",
".",
"isEmpty",
"(",
")",
")",
"{",
"// Create a new collection to store the values (will be changed to internal type by call",
"// to putIfAbsent anyway)",
"List",
"<",
"V",
">",
"collectionToAppendValuesOn",
"=",
"new",
"ArrayList",
"<",
"V",
">",
"(",
")",
";",
"List",
"<",
"V",
">",
"existing",
"=",
"this",
".",
"putIfAbsent",
"(",
"key",
",",
"collectionToAppendValuesOn",
")",
";",
"if",
"(",
"existing",
"!=",
"null",
")",
"{",
"// Already had a collection, discard the new one and use existing",
"collectionToAppendValuesOn",
"=",
"existing",
";",
"}",
"collectionToAppendValuesOn",
".",
"addAll",
"(",
"valueCollection",
")",
";",
"}",
"}"
] |
Add a collection of one or more values to the map under the existing key or creating a new key
if it does not yet exist in the map.
@param key the key to associate the values with
@param valueCollection a collection of values to add to the key
|
[
"Add",
"a",
"collection",
"of",
"one",
"or",
"more",
"values",
"to",
"the",
"map",
"under",
"the",
"existing",
"key",
"or",
"creating",
"a",
"new",
"key",
"if",
"it",
"does",
"not",
"yet",
"exist",
"in",
"the",
"map",
"."
] |
train
|
https://github.com/cloudant/sync-android/blob/5f1416ed1bd9ab05d7a4b8736480c8ae68bd7383/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/common/ValueListMap.java#L66-L78
|
exoplatform/jcr
|
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MatchAllWeight.java
|
MatchAllWeight.createScorer
|
@Override
protected Scorer createScorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException {
return new MatchAllScorer(reader, field);
}
|
java
|
@Override
protected Scorer createScorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException {
return new MatchAllScorer(reader, field);
}
|
[
"@",
"Override",
"protected",
"Scorer",
"createScorer",
"(",
"IndexReader",
"reader",
",",
"boolean",
"scoreDocsInOrder",
",",
"boolean",
"topScorer",
")",
"throws",
"IOException",
"{",
"return",
"new",
"MatchAllScorer",
"(",
"reader",
",",
"field",
")",
";",
"}"
] |
Creates a {@link MatchAllScorer} instance.
@param reader index reader
@return a {@link MatchAllScorer} instance
|
[
"Creates",
"a",
"{",
"@link",
"MatchAllScorer",
"}",
"instance",
"."
] |
train
|
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MatchAllWeight.java#L80-L83
|
Azure/azure-sdk-for-java
|
datalakestore/resource-manager/v2016_11_01/src/main/java/com/microsoft/azure/management/datalakestore/v2016_11_01/implementation/AccountsInner.java
|
AccountsInner.listWithServiceResponseAsync
|
public Observable<ServiceResponse<Page<DataLakeStoreAccountBasicInner>>> listWithServiceResponseAsync(final String filter, final Integer top, final Integer skip, final String select, final String orderby, final Boolean count) {
return listSinglePageAsync(filter, top, skip, select, orderby, count)
.concatMap(new Func1<ServiceResponse<Page<DataLakeStoreAccountBasicInner>>, Observable<ServiceResponse<Page<DataLakeStoreAccountBasicInner>>>>() {
@Override
public Observable<ServiceResponse<Page<DataLakeStoreAccountBasicInner>>> call(ServiceResponse<Page<DataLakeStoreAccountBasicInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink));
}
});
}
|
java
|
public Observable<ServiceResponse<Page<DataLakeStoreAccountBasicInner>>> listWithServiceResponseAsync(final String filter, final Integer top, final Integer skip, final String select, final String orderby, final Boolean count) {
return listSinglePageAsync(filter, top, skip, select, orderby, count)
.concatMap(new Func1<ServiceResponse<Page<DataLakeStoreAccountBasicInner>>, Observable<ServiceResponse<Page<DataLakeStoreAccountBasicInner>>>>() {
@Override
public Observable<ServiceResponse<Page<DataLakeStoreAccountBasicInner>>> call(ServiceResponse<Page<DataLakeStoreAccountBasicInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink));
}
});
}
|
[
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"DataLakeStoreAccountBasicInner",
">",
">",
">",
"listWithServiceResponseAsync",
"(",
"final",
"String",
"filter",
",",
"final",
"Integer",
"top",
",",
"final",
"Integer",
"skip",
",",
"final",
"String",
"select",
",",
"final",
"String",
"orderby",
",",
"final",
"Boolean",
"count",
")",
"{",
"return",
"listSinglePageAsync",
"(",
"filter",
",",
"top",
",",
"skip",
",",
"select",
",",
"orderby",
",",
"count",
")",
".",
"concatMap",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"DataLakeStoreAccountBasicInner",
">",
">",
",",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"DataLakeStoreAccountBasicInner",
">",
">",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"DataLakeStoreAccountBasicInner",
">",
">",
">",
"call",
"(",
"ServiceResponse",
"<",
"Page",
"<",
"DataLakeStoreAccountBasicInner",
">",
">",
"page",
")",
"{",
"String",
"nextPageLink",
"=",
"page",
".",
"body",
"(",
")",
".",
"nextPageLink",
"(",
")",
";",
"if",
"(",
"nextPageLink",
"==",
"null",
")",
"{",
"return",
"Observable",
".",
"just",
"(",
"page",
")",
";",
"}",
"return",
"Observable",
".",
"just",
"(",
"page",
")",
".",
"concatWith",
"(",
"listNextWithServiceResponseAsync",
"(",
"nextPageLink",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Lists the Data Lake Store accounts within the subscription. The response includes a link to the next page of results, if any.
@param filter OData filter. Optional.
@param top The number of items to return. Optional.
@param skip The number of items to skip over before returning elements. Optional.
@param select OData Select statement. Limits the properties on each entry to just those requested, e.g. Categories?$select=CategoryName,Description. Optional.
@param orderby OrderBy clause. One or more comma-separated expressions with an optional "asc" (the default) or "desc" depending on the order you'd like the values sorted, e.g. Categories?$orderby=CategoryName desc. Optional.
@param count The Boolean value of true or false to request a count of the matching resources included with the resources in the response, e.g. Categories?$count=true. Optional.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<DataLakeStoreAccountBasicInner> object
|
[
"Lists",
"the",
"Data",
"Lake",
"Store",
"accounts",
"within",
"the",
"subscription",
".",
"The",
"response",
"includes",
"a",
"link",
"to",
"the",
"next",
"page",
"of",
"results",
"if",
"any",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/datalakestore/resource-manager/v2016_11_01/src/main/java/com/microsoft/azure/management/datalakestore/v2016_11_01/implementation/AccountsInner.java#L315-L327
|
junit-team/junit4
|
src/main/java/org/junit/runners/model/FrameworkMethod.java
|
FrameworkMethod.validatePublicVoid
|
public void validatePublicVoid(boolean isStatic, List<Throwable> errors) {
if (isStatic() != isStatic) {
String state = isStatic ? "should" : "should not";
errors.add(new Exception("Method " + method.getName() + "() " + state + " be static"));
}
if (!isPublic()) {
errors.add(new Exception("Method " + method.getName() + "() should be public"));
}
if (method.getReturnType() != Void.TYPE) {
errors.add(new Exception("Method " + method.getName() + "() should be void"));
}
}
|
java
|
public void validatePublicVoid(boolean isStatic, List<Throwable> errors) {
if (isStatic() != isStatic) {
String state = isStatic ? "should" : "should not";
errors.add(new Exception("Method " + method.getName() + "() " + state + " be static"));
}
if (!isPublic()) {
errors.add(new Exception("Method " + method.getName() + "() should be public"));
}
if (method.getReturnType() != Void.TYPE) {
errors.add(new Exception("Method " + method.getName() + "() should be void"));
}
}
|
[
"public",
"void",
"validatePublicVoid",
"(",
"boolean",
"isStatic",
",",
"List",
"<",
"Throwable",
">",
"errors",
")",
"{",
"if",
"(",
"isStatic",
"(",
")",
"!=",
"isStatic",
")",
"{",
"String",
"state",
"=",
"isStatic",
"?",
"\"should\"",
":",
"\"should not\"",
";",
"errors",
".",
"add",
"(",
"new",
"Exception",
"(",
"\"Method \"",
"+",
"method",
".",
"getName",
"(",
")",
"+",
"\"() \"",
"+",
"state",
"+",
"\" be static\"",
")",
")",
";",
"}",
"if",
"(",
"!",
"isPublic",
"(",
")",
")",
"{",
"errors",
".",
"add",
"(",
"new",
"Exception",
"(",
"\"Method \"",
"+",
"method",
".",
"getName",
"(",
")",
"+",
"\"() should be public\"",
")",
")",
";",
"}",
"if",
"(",
"method",
".",
"getReturnType",
"(",
")",
"!=",
"Void",
".",
"TYPE",
")",
"{",
"errors",
".",
"add",
"(",
"new",
"Exception",
"(",
"\"Method \"",
"+",
"method",
".",
"getName",
"(",
")",
"+",
"\"() should be void\"",
")",
")",
";",
"}",
"}"
] |
Adds to {@code errors} if this method:
<ul>
<li>is not public, or
<li>returns something other than void, or
<li>is static (given {@code isStatic is false}), or
<li>is not static (given {@code isStatic is true}).
</ul>
|
[
"Adds",
"to",
"{"
] |
train
|
https://github.com/junit-team/junit4/blob/d9861ecdb6e487f6c352437ee823879aca3b81d4/src/main/java/org/junit/runners/model/FrameworkMethod.java#L99-L110
|
astrapi69/mystic-crypt
|
crypt-data/src/main/java/de/alpharogroup/crypto/key/reader/PrivateKeyReader.java
|
PrivateKeyReader.readPemPrivateKey
|
public static PrivateKey readPemPrivateKey(final String privateKeyAsString,
final String algorithm)
throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchProviderException
{
final byte[] decoded = new Base64().decode(privateKeyAsString);
return readPrivateKey(decoded, algorithm);
}
|
java
|
public static PrivateKey readPemPrivateKey(final String privateKeyAsString,
final String algorithm)
throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchProviderException
{
final byte[] decoded = new Base64().decode(privateKeyAsString);
return readPrivateKey(decoded, algorithm);
}
|
[
"public",
"static",
"PrivateKey",
"readPemPrivateKey",
"(",
"final",
"String",
"privateKeyAsString",
",",
"final",
"String",
"algorithm",
")",
"throws",
"NoSuchAlgorithmException",
",",
"InvalidKeySpecException",
",",
"NoSuchProviderException",
"{",
"final",
"byte",
"[",
"]",
"decoded",
"=",
"new",
"Base64",
"(",
")",
".",
"decode",
"(",
"privateKeyAsString",
")",
";",
"return",
"readPrivateKey",
"(",
"decoded",
",",
"algorithm",
")",
";",
"}"
] |
Reads the given {@link String}( in *.pem format) with given algorithm and returns the
{@link PrivateKey} object.
@param privateKeyAsString
the private key as string( in *.pem format)
@param algorithm
the algorithm
@return the {@link PrivateKey} object
@throws NoSuchAlgorithmException
is thrown if instantiation of the SecretKeyFactory object fails.
@throws InvalidKeySpecException
is thrown if generation of the SecretKey object fails.
@throws NoSuchProviderException
is thrown if the specified provider is not registered in the security provider
list.
|
[
"Reads",
"the",
"given",
"{",
"@link",
"String",
"}",
"(",
"in",
"*",
".",
"pem",
"format",
")",
"with",
"given",
"algorithm",
"and",
"returns",
"the",
"{",
"@link",
"PrivateKey",
"}",
"object",
"."
] |
train
|
https://github.com/astrapi69/mystic-crypt/blob/7f51ef5e4457e24de7ff391f10bfc5609e6f1a34/crypt-data/src/main/java/de/alpharogroup/crypto/key/reader/PrivateKeyReader.java#L307-L313
|
infinispan/infinispan
|
server/hotrod/src/main/java/org/infinispan/server/hotrod/transport/ExtendedByteBuf.java
|
ExtendedByteBuf.readMaybeString
|
public static Optional<String> readMaybeString(ByteBuf bf) {
Optional<byte[]> bytes = readMaybeRangedBytes(bf);
return bytes.map(b -> {
if (b.length == 0) return "";
else return new String(b, CharsetUtil.UTF_8);
});
}
|
java
|
public static Optional<String> readMaybeString(ByteBuf bf) {
Optional<byte[]> bytes = readMaybeRangedBytes(bf);
return bytes.map(b -> {
if (b.length == 0) return "";
else return new String(b, CharsetUtil.UTF_8);
});
}
|
[
"public",
"static",
"Optional",
"<",
"String",
">",
"readMaybeString",
"(",
"ByteBuf",
"bf",
")",
"{",
"Optional",
"<",
"byte",
"[",
"]",
">",
"bytes",
"=",
"readMaybeRangedBytes",
"(",
"bf",
")",
";",
"return",
"bytes",
".",
"map",
"(",
"b",
"->",
"{",
"if",
"(",
"b",
".",
"length",
"==",
"0",
")",
"return",
"\"\"",
";",
"else",
"return",
"new",
"String",
"(",
"b",
",",
"CharsetUtil",
".",
"UTF_8",
")",
";",
"}",
")",
";",
"}"
] |
Reads a string if possible. If not present the reader index is reset to the last mark.
@param bf
@return
|
[
"Reads",
"a",
"string",
"if",
"possible",
".",
"If",
"not",
"present",
"the",
"reader",
"index",
"is",
"reset",
"to",
"the",
"last",
"mark",
"."
] |
train
|
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/server/hotrod/src/main/java/org/infinispan/server/hotrod/transport/ExtendedByteBuf.java#L244-L250
|
spotbugs/spotbugs
|
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/XFactory.java
|
XFactory.createXField
|
public static XField createXField(@DottedClassName String className, String fieldName, String fieldSignature, boolean isStatic) {
FieldDescriptor fieldDesc = DescriptorFactory.instance().getFieldDescriptor(ClassName.toSlashedClassName(className),
fieldName, fieldSignature, isStatic);
return createXField(fieldDesc);
}
|
java
|
public static XField createXField(@DottedClassName String className, String fieldName, String fieldSignature, boolean isStatic) {
FieldDescriptor fieldDesc = DescriptorFactory.instance().getFieldDescriptor(ClassName.toSlashedClassName(className),
fieldName, fieldSignature, isStatic);
return createXField(fieldDesc);
}
|
[
"public",
"static",
"XField",
"createXField",
"(",
"@",
"DottedClassName",
"String",
"className",
",",
"String",
"fieldName",
",",
"String",
"fieldSignature",
",",
"boolean",
"isStatic",
")",
"{",
"FieldDescriptor",
"fieldDesc",
"=",
"DescriptorFactory",
".",
"instance",
"(",
")",
".",
"getFieldDescriptor",
"(",
"ClassName",
".",
"toSlashedClassName",
"(",
"className",
")",
",",
"fieldName",
",",
"fieldSignature",
",",
"isStatic",
")",
";",
"return",
"createXField",
"(",
"fieldDesc",
")",
";",
"}"
] |
Create an XField object
@param className
@param fieldName
@param fieldSignature
@param isStatic
@return the created XField
|
[
"Create",
"an",
"XField",
"object"
] |
train
|
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/XFactory.java#L459-L464
|
JOML-CI/JOML
|
src/org/joml/Vector4i.java
|
Vector4i.set
|
public Vector4i set(int index, ByteBuffer buffer) {
MemUtil.INSTANCE.get(this, index, buffer);
return this;
}
|
java
|
public Vector4i set(int index, ByteBuffer buffer) {
MemUtil.INSTANCE.get(this, index, buffer);
return this;
}
|
[
"public",
"Vector4i",
"set",
"(",
"int",
"index",
",",
"ByteBuffer",
"buffer",
")",
"{",
"MemUtil",
".",
"INSTANCE",
".",
"get",
"(",
"this",
",",
"index",
",",
"buffer",
")",
";",
"return",
"this",
";",
"}"
] |
Read this vector from the supplied {@link ByteBuffer} starting at the
specified absolute buffer position/index.
<p>
This method will not increment the position of the given ByteBuffer.
@param index
the absolute position into the ByteBuffer
@param buffer
values will be read in <code>x, y, z, w</code> order
@return this
|
[
"Read",
"this",
"vector",
"from",
"the",
"supplied",
"{",
"@link",
"ByteBuffer",
"}",
"starting",
"at",
"the",
"specified",
"absolute",
"buffer",
"position",
"/",
"index",
".",
"<p",
">",
"This",
"method",
"will",
"not",
"increment",
"the",
"position",
"of",
"the",
"given",
"ByteBuffer",
"."
] |
train
|
https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Vector4i.java#L375-L378
|
sdl/odata
|
odata_client/src/main/java/com/sdl/odata/client/marshall/AtomEntityUnmarshaller.java
|
AtomEntityUnmarshaller.atomUnmarshall
|
public Object atomUnmarshall(String oDataEntityXml, String fullResponse, ODataClientQuery query)
throws UnsupportedEncodingException, ODataClientException {
Object unmarshalledEntity;
// build a dummy request context which contains the Xml
ODataRequest request = buildODataRequestFromString(oDataEntityXml, query);
ODataRequestContext requestContext =
new ODataRequestContext(request, createODataUri(url, query.getEdmEntityName()), entityDataModel);
// unmarshall the OData request context into an entity
try {
unmarshalledEntity = getODataAtomParser(requestContext).getODataEntity();
} catch (ODataException | RuntimeException e) {
throw new ODataClientParserException(
format("Caught exception {0}: {1} when parsing response received from OData service",
e.getClass().getSimpleName(), e.getMessage()),
e, oDataEntityXml, fullResponse);
}
return unmarshalledEntity;
}
|
java
|
public Object atomUnmarshall(String oDataEntityXml, String fullResponse, ODataClientQuery query)
throws UnsupportedEncodingException, ODataClientException {
Object unmarshalledEntity;
// build a dummy request context which contains the Xml
ODataRequest request = buildODataRequestFromString(oDataEntityXml, query);
ODataRequestContext requestContext =
new ODataRequestContext(request, createODataUri(url, query.getEdmEntityName()), entityDataModel);
// unmarshall the OData request context into an entity
try {
unmarshalledEntity = getODataAtomParser(requestContext).getODataEntity();
} catch (ODataException | RuntimeException e) {
throw new ODataClientParserException(
format("Caught exception {0}: {1} when parsing response received from OData service",
e.getClass().getSimpleName(), e.getMessage()),
e, oDataEntityXml, fullResponse);
}
return unmarshalledEntity;
}
|
[
"public",
"Object",
"atomUnmarshall",
"(",
"String",
"oDataEntityXml",
",",
"String",
"fullResponse",
",",
"ODataClientQuery",
"query",
")",
"throws",
"UnsupportedEncodingException",
",",
"ODataClientException",
"{",
"Object",
"unmarshalledEntity",
";",
"// build a dummy request context which contains the Xml",
"ODataRequest",
"request",
"=",
"buildODataRequestFromString",
"(",
"oDataEntityXml",
",",
"query",
")",
";",
"ODataRequestContext",
"requestContext",
"=",
"new",
"ODataRequestContext",
"(",
"request",
",",
"createODataUri",
"(",
"url",
",",
"query",
".",
"getEdmEntityName",
"(",
")",
")",
",",
"entityDataModel",
")",
";",
"// unmarshall the OData request context into an entity",
"try",
"{",
"unmarshalledEntity",
"=",
"getODataAtomParser",
"(",
"requestContext",
")",
".",
"getODataEntity",
"(",
")",
";",
"}",
"catch",
"(",
"ODataException",
"|",
"RuntimeException",
"e",
")",
"{",
"throw",
"new",
"ODataClientParserException",
"(",
"format",
"(",
"\"Caught exception {0}: {1} when parsing response received from OData service\"",
",",
"e",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
",",
"e",
".",
"getMessage",
"(",
")",
")",
",",
"e",
",",
"oDataEntityXml",
",",
"fullResponse",
")",
";",
"}",
"return",
"unmarshalledEntity",
";",
"}"
] |
Unmarshalls an Atom XML form of on OData entity into the actual entity (DTO) object.
@param oDataEntityXml the Atom XML form of on OData entity
@return an entity (DTO) object
@throws java.io.UnsupportedEncodingException
@throws ODataClientException
|
[
"Unmarshalls",
"an",
"Atom",
"XML",
"form",
"of",
"on",
"OData",
"entity",
"into",
"the",
"actual",
"entity",
"(",
"DTO",
")",
"object",
"."
] |
train
|
https://github.com/sdl/odata/blob/eb747d73e9af0f4e59a25b82ed656e526a7e2189/odata_client/src/main/java/com/sdl/odata/client/marshall/AtomEntityUnmarshaller.java#L147-L165
|
aol/cyclops
|
cyclops/src/main/java/cyclops/companion/Streams.java
|
Streams.streamToOptional
|
public final static <T> Optional<Seq<T>> streamToOptional(final Stream<T> stream) {
final List<T> collected = stream.collect(java.util.stream.Collectors.toList());
if (collected.size() == 0)
return Optional.empty();
return Optional.of(Seq.fromIterable(collected));
}
|
java
|
public final static <T> Optional<Seq<T>> streamToOptional(final Stream<T> stream) {
final List<T> collected = stream.collect(java.util.stream.Collectors.toList());
if (collected.size() == 0)
return Optional.empty();
return Optional.of(Seq.fromIterable(collected));
}
|
[
"public",
"final",
"static",
"<",
"T",
">",
"Optional",
"<",
"Seq",
"<",
"T",
">",
">",
"streamToOptional",
"(",
"final",
"Stream",
"<",
"T",
">",
"stream",
")",
"{",
"final",
"List",
"<",
"T",
">",
"collected",
"=",
"stream",
".",
"collect",
"(",
"java",
".",
"util",
".",
"stream",
".",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"if",
"(",
"collected",
".",
"size",
"(",
")",
"==",
"0",
")",
"return",
"Optional",
".",
"empty",
"(",
")",
";",
"return",
"Optional",
".",
"of",
"(",
"Seq",
".",
"fromIterable",
"(",
"collected",
")",
")",
";",
"}"
] |
Create an Optional containing a List materialized from a Stream
<pre>
{@code
Optional<Seq<Integer>> opt = Streams.streamToOptional(Stream.of(1,2,3));
//Optional[[1,2,3]]
}
</pre>
@param stream To convert into an Optional
@return Optional with a List of values
|
[
"Create",
"an",
"Optional",
"containing",
"a",
"List",
"materialized",
"from",
"a",
"Stream"
] |
train
|
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Streams.java#L473-L479
|
jboss/jboss-el-api_spec
|
src/main/java/javax/el/ELProcessor.java
|
ELProcessor.defineFunction
|
public void defineFunction(String prefix, String function, Method method)
throws NoSuchMethodException {
if (prefix == null || function == null || method == null) {
throw new NullPointerException("Null argument for defineFunction");
}
if (! Modifier.isStatic(method.getModifiers())) {
throw new NoSuchMethodException("The method specified in defineFunction must be static: " + method);
}
if (function.equals("")) {
function = method.getName();
}
elManager.mapFunction(prefix, function, method);
}
|
java
|
public void defineFunction(String prefix, String function, Method method)
throws NoSuchMethodException {
if (prefix == null || function == null || method == null) {
throw new NullPointerException("Null argument for defineFunction");
}
if (! Modifier.isStatic(method.getModifiers())) {
throw new NoSuchMethodException("The method specified in defineFunction must be static: " + method);
}
if (function.equals("")) {
function = method.getName();
}
elManager.mapFunction(prefix, function, method);
}
|
[
"public",
"void",
"defineFunction",
"(",
"String",
"prefix",
",",
"String",
"function",
",",
"Method",
"method",
")",
"throws",
"NoSuchMethodException",
"{",
"if",
"(",
"prefix",
"==",
"null",
"||",
"function",
"==",
"null",
"||",
"method",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"Null argument for defineFunction\"",
")",
";",
"}",
"if",
"(",
"!",
"Modifier",
".",
"isStatic",
"(",
"method",
".",
"getModifiers",
"(",
")",
")",
")",
"{",
"throw",
"new",
"NoSuchMethodException",
"(",
"\"The method specified in defineFunction must be static: \"",
"+",
"method",
")",
";",
"}",
"if",
"(",
"function",
".",
"equals",
"(",
"\"\"",
")",
")",
"{",
"function",
"=",
"method",
".",
"getName",
"(",
")",
";",
"}",
"elManager",
".",
"mapFunction",
"(",
"prefix",
",",
"function",
",",
"method",
")",
";",
"}"
] |
Define an EL function in the local function mapper.
@param prefix The namespace for the function or "" for no namesapce.
@param function The name of the function.
If empty (""), the method name is used as the function name.
@param method The <code>java.lang.reflect.Method</code> instance of
the method that implements the function.
@throws NullPointerException if any of the arguments is null.
@throws NoSuchMethodException if the method is not a static method
|
[
"Define",
"an",
"EL",
"function",
"in",
"the",
"local",
"function",
"mapper",
"."
] |
train
|
https://github.com/jboss/jboss-el-api_spec/blob/4cef117cae3ccf9f76439845687a8d219ad2eb43/src/main/java/javax/el/ELProcessor.java#L257-L269
|
Azure/azure-sdk-for-java
|
compute/resource-manager/v2017_03_30/src/main/java/com/microsoft/azure/management/compute/v2017_03_30/implementation/VirtualMachineScaleSetsInner.java
|
VirtualMachineScaleSetsInner.listSkusWithServiceResponseAsync
|
public Observable<ServiceResponse<Page<VirtualMachineScaleSetSkuInner>>> listSkusWithServiceResponseAsync(final String resourceGroupName, final String vmScaleSetName) {
return listSkusSinglePageAsync(resourceGroupName, vmScaleSetName)
.concatMap(new Func1<ServiceResponse<Page<VirtualMachineScaleSetSkuInner>>, Observable<ServiceResponse<Page<VirtualMachineScaleSetSkuInner>>>>() {
@Override
public Observable<ServiceResponse<Page<VirtualMachineScaleSetSkuInner>>> call(ServiceResponse<Page<VirtualMachineScaleSetSkuInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listSkusNextWithServiceResponseAsync(nextPageLink));
}
});
}
|
java
|
public Observable<ServiceResponse<Page<VirtualMachineScaleSetSkuInner>>> listSkusWithServiceResponseAsync(final String resourceGroupName, final String vmScaleSetName) {
return listSkusSinglePageAsync(resourceGroupName, vmScaleSetName)
.concatMap(new Func1<ServiceResponse<Page<VirtualMachineScaleSetSkuInner>>, Observable<ServiceResponse<Page<VirtualMachineScaleSetSkuInner>>>>() {
@Override
public Observable<ServiceResponse<Page<VirtualMachineScaleSetSkuInner>>> call(ServiceResponse<Page<VirtualMachineScaleSetSkuInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listSkusNextWithServiceResponseAsync(nextPageLink));
}
});
}
|
[
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"VirtualMachineScaleSetSkuInner",
">",
">",
">",
"listSkusWithServiceResponseAsync",
"(",
"final",
"String",
"resourceGroupName",
",",
"final",
"String",
"vmScaleSetName",
")",
"{",
"return",
"listSkusSinglePageAsync",
"(",
"resourceGroupName",
",",
"vmScaleSetName",
")",
".",
"concatMap",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"VirtualMachineScaleSetSkuInner",
">",
">",
",",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"VirtualMachineScaleSetSkuInner",
">",
">",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"VirtualMachineScaleSetSkuInner",
">",
">",
">",
"call",
"(",
"ServiceResponse",
"<",
"Page",
"<",
"VirtualMachineScaleSetSkuInner",
">",
">",
"page",
")",
"{",
"String",
"nextPageLink",
"=",
"page",
".",
"body",
"(",
")",
".",
"nextPageLink",
"(",
")",
";",
"if",
"(",
"nextPageLink",
"==",
"null",
")",
"{",
"return",
"Observable",
".",
"just",
"(",
"page",
")",
";",
"}",
"return",
"Observable",
".",
"just",
"(",
"page",
")",
".",
"concatWith",
"(",
"listSkusNextWithServiceResponseAsync",
"(",
"nextPageLink",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU.
@param resourceGroupName The name of the resource group.
@param vmScaleSetName The name of the VM scale set.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<VirtualMachineScaleSetSkuInner> object
|
[
"Gets",
"a",
"list",
"of",
"SKUs",
"available",
"for",
"your",
"VM",
"scale",
"set",
"including",
"the",
"minimum",
"and",
"maximum",
"VM",
"instances",
"allowed",
"for",
"each",
"SKU",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/compute/resource-manager/v2017_03_30/src/main/java/com/microsoft/azure/management/compute/v2017_03_30/implementation/VirtualMachineScaleSetsInner.java#L1660-L1672
|
qiniu/android-sdk
|
library/src/main/java/com/qiniu/android/http/MultipartBody.java
|
MultipartBody.appendQuotedString
|
static StringBuilder appendQuotedString(StringBuilder target, String key) {
target.append('"');
for (int i = 0, len = key.length(); i < len; i++) {
char ch = key.charAt(i);
switch (ch) {
case '\n':
target.append("%0A");
break;
case '\r':
target.append("%0D");
break;
case '"':
target.append("%22");
break;
default:
target.append(ch);
break;
}
}
target.append('"');
return target;
}
|
java
|
static StringBuilder appendQuotedString(StringBuilder target, String key) {
target.append('"');
for (int i = 0, len = key.length(); i < len; i++) {
char ch = key.charAt(i);
switch (ch) {
case '\n':
target.append("%0A");
break;
case '\r':
target.append("%0D");
break;
case '"':
target.append("%22");
break;
default:
target.append(ch);
break;
}
}
target.append('"');
return target;
}
|
[
"static",
"StringBuilder",
"appendQuotedString",
"(",
"StringBuilder",
"target",
",",
"String",
"key",
")",
"{",
"target",
".",
"append",
"(",
"'",
"'",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"len",
"=",
"key",
".",
"length",
"(",
")",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"char",
"ch",
"=",
"key",
".",
"charAt",
"(",
"i",
")",
";",
"switch",
"(",
"ch",
")",
"{",
"case",
"'",
"'",
":",
"target",
".",
"append",
"(",
"\"%0A\"",
")",
";",
"break",
";",
"case",
"'",
"'",
":",
"target",
".",
"append",
"(",
"\"%0D\"",
")",
";",
"break",
";",
"case",
"'",
"'",
":",
"target",
".",
"append",
"(",
"\"%22\"",
")",
";",
"break",
";",
"default",
":",
"target",
".",
"append",
"(",
"ch",
")",
";",
"break",
";",
"}",
"}",
"target",
".",
"append",
"(",
"'",
"'",
")",
";",
"return",
"target",
";",
"}"
] |
Appends a quoted-string to a StringBuilder.
<p>RFC 2388 is rather vague about how one should escape special characters in form-data
parameters, and as it turns out Firefox and Chrome actually do rather different things, and
both say in their comments that they're not really sure what the right approach is. We go with
Chrome's behavior (which also experimentally seems to match what IE does), but if you actually
want to have a good chance of things working, please avoid double-quotes, newlines, percent
signs, and the like in your field names.
|
[
"Appends",
"a",
"quoted",
"-",
"string",
"to",
"a",
"StringBuilder",
"."
] |
train
|
https://github.com/qiniu/android-sdk/blob/dbd2a01fb3bff7a5e75e8934bbf81713124d8466/library/src/main/java/com/qiniu/android/http/MultipartBody.java#L97-L118
|
dkpro/dkpro-jwpl
|
de.tudarmstadt.ukp.wikipedia.revisionmachine/src/main/java/de/tudarmstadt/ukp/wikipedia/revisionmachine/difftool/consumer/dump/codec/TimedSQLEncoder.java
|
TimedSQLEncoder.encodeDiff
|
protected String encodeDiff(final Task<Diff> task, final Diff diff)
throws ConfigurationException, UnsupportedEncodingException,
DecodingException, EncodingException, SQLConsumerException
{
String encoding = super.encodeDiff(task, diff);
this.encodedSize += encoding.length();
return encoding;
}
|
java
|
protected String encodeDiff(final Task<Diff> task, final Diff diff)
throws ConfigurationException, UnsupportedEncodingException,
DecodingException, EncodingException, SQLConsumerException
{
String encoding = super.encodeDiff(task, diff);
this.encodedSize += encoding.length();
return encoding;
}
|
[
"protected",
"String",
"encodeDiff",
"(",
"final",
"Task",
"<",
"Diff",
">",
"task",
",",
"final",
"Diff",
"diff",
")",
"throws",
"ConfigurationException",
",",
"UnsupportedEncodingException",
",",
"DecodingException",
",",
"EncodingException",
",",
"SQLConsumerException",
"{",
"String",
"encoding",
"=",
"super",
".",
"encodeDiff",
"(",
"task",
",",
"diff",
")",
";",
"this",
".",
"encodedSize",
"+=",
"encoding",
".",
"length",
"(",
")",
";",
"return",
"encoding",
";",
"}"
] |
Encodes the diff.
@param task
Reference to the DiffTask
@param diff
Diff to encode
@return Base 64 encoded Diff
@throws ConfigurationException
if an error occurred while accessing the configuration
@throws UnsupportedEncodingException
if the character encoding is unsupported
@throws DecodingException
if the decoding failed
@throws EncodingException
if the encoding failed
@throws SQLConsumerException
if an error occurred while encoding the diff
|
[
"Encodes",
"the",
"diff",
"."
] |
train
|
https://github.com/dkpro/dkpro-jwpl/blob/0a0304b6a0aa13acc18838957994e06dd4613a58/de.tudarmstadt.ukp.wikipedia.revisionmachine/src/main/java/de/tudarmstadt/ukp/wikipedia/revisionmachine/difftool/consumer/dump/codec/TimedSQLEncoder.java#L121-L131
|
infinispan/infinispan
|
object-filter/src/main/java/org/infinispan/objectfilter/impl/util/IntervalTree.java
|
IntervalTree.compareIntervals
|
private int compareIntervals(Interval<K> i1, Interval<K> i2) {
int res1 = compare(i1.up, i2.low);
if (res1 < 0 || res1 <= 0 && (!i1.includeUpper || !i2.includeLower)) {
return -1;
}
int res2 = compare(i2.up, i1.low);
if (res2 < 0 || res2 <= 0 && (!i2.includeUpper || !i1.includeLower)) {
return 1;
}
return 0;
}
|
java
|
private int compareIntervals(Interval<K> i1, Interval<K> i2) {
int res1 = compare(i1.up, i2.low);
if (res1 < 0 || res1 <= 0 && (!i1.includeUpper || !i2.includeLower)) {
return -1;
}
int res2 = compare(i2.up, i1.low);
if (res2 < 0 || res2 <= 0 && (!i2.includeUpper || !i1.includeLower)) {
return 1;
}
return 0;
}
|
[
"private",
"int",
"compareIntervals",
"(",
"Interval",
"<",
"K",
">",
"i1",
",",
"Interval",
"<",
"K",
">",
"i2",
")",
"{",
"int",
"res1",
"=",
"compare",
"(",
"i1",
".",
"up",
",",
"i2",
".",
"low",
")",
";",
"if",
"(",
"res1",
"<",
"0",
"||",
"res1",
"<=",
"0",
"&&",
"(",
"!",
"i1",
".",
"includeUpper",
"||",
"!",
"i2",
".",
"includeLower",
")",
")",
"{",
"return",
"-",
"1",
";",
"}",
"int",
"res2",
"=",
"compare",
"(",
"i2",
".",
"up",
",",
"i1",
".",
"low",
")",
";",
"if",
"(",
"res2",
"<",
"0",
"||",
"res2",
"<=",
"0",
"&&",
"(",
"!",
"i2",
".",
"includeUpper",
"||",
"!",
"i1",
".",
"includeLower",
")",
")",
"{",
"return",
"1",
";",
"}",
"return",
"0",
";",
"}"
] |
Compare two Intervals.
@return a negative integer, zero, or a positive integer depending if Interval i1 is to the left of i2, overlaps
with it, or is to the right of i2.
|
[
"Compare",
"two",
"Intervals",
"."
] |
train
|
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/object-filter/src/main/java/org/infinispan/objectfilter/impl/util/IntervalTree.java#L102-L112
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-packxdsl/src/main/java/net/minidev/ovh/api/ApiOvhPackxdsl.java
|
ApiOvhPackxdsl.packName_voipLine_options_customShippingAddress_POST
|
public Long packName_voipLine_options_customShippingAddress_POST(String packName, String address, String cityName, String firstName, String lastName, String zipCode) throws IOException {
String qPath = "/pack/xdsl/{packName}/voipLine/options/customShippingAddress";
StringBuilder sb = path(qPath, packName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "address", address);
addBody(o, "cityName", cityName);
addBody(o, "firstName", firstName);
addBody(o, "lastName", lastName);
addBody(o, "zipCode", zipCode);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, Long.class);
}
|
java
|
public Long packName_voipLine_options_customShippingAddress_POST(String packName, String address, String cityName, String firstName, String lastName, String zipCode) throws IOException {
String qPath = "/pack/xdsl/{packName}/voipLine/options/customShippingAddress";
StringBuilder sb = path(qPath, packName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "address", address);
addBody(o, "cityName", cityName);
addBody(o, "firstName", firstName);
addBody(o, "lastName", lastName);
addBody(o, "zipCode", zipCode);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, Long.class);
}
|
[
"public",
"Long",
"packName_voipLine_options_customShippingAddress_POST",
"(",
"String",
"packName",
",",
"String",
"address",
",",
"String",
"cityName",
",",
"String",
"firstName",
",",
"String",
"lastName",
",",
"String",
"zipCode",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/pack/xdsl/{packName}/voipLine/options/customShippingAddress\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"packName",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"address\"",
",",
"address",
")",
";",
"addBody",
"(",
"o",
",",
"\"cityName\"",
",",
"cityName",
")",
";",
"addBody",
"(",
"o",
",",
"\"firstName\"",
",",
"firstName",
")",
";",
"addBody",
"(",
"o",
",",
"\"lastName\"",
",",
"lastName",
")",
";",
"addBody",
"(",
"o",
",",
"\"zipCode\"",
",",
"zipCode",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"Long",
".",
"class",
")",
";",
"}"
] |
Create a new shippingId to be used for voipLine service creation
REST: POST /pack/xdsl/{packName}/voipLine/options/customShippingAddress
@param address [required] Address, including street name
@param lastName [required] Last name
@param firstName [required] First name
@param cityName [required] City name
@param zipCode [required] Zip code
@param packName [required] The internal name of your pack
|
[
"Create",
"a",
"new",
"shippingId",
"to",
"be",
"used",
"for",
"voipLine",
"service",
"creation"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-packxdsl/src/main/java/net/minidev/ovh/api/ApiOvhPackxdsl.java#L320-L331
|
TestFX/Monocle
|
src/main/java/com/sun/glass/ui/monocle/LinuxInput.java
|
LinuxInput.codeToString
|
static String codeToString(String type, short code) {
int i = type.indexOf("_");
if (i >= 0) {
String prefix = type.substring(i + 1);
String altPrefix = prefix.equals("KEY") ? "BTN" : prefix;
for (Field field : LinuxInput.class.getDeclaredFields()) {
String name = field.getName();
try {
if ((name.startsWith(prefix) || name.startsWith(altPrefix))
&& field.getType() == Short.TYPE
&& field.getShort(null) == code) {
return field.getName();
}
} catch (IllegalAccessException e) {
}
}
}
return new Formatter().format("0x%04x", code & 0xffff).out().toString();
}
|
java
|
static String codeToString(String type, short code) {
int i = type.indexOf("_");
if (i >= 0) {
String prefix = type.substring(i + 1);
String altPrefix = prefix.equals("KEY") ? "BTN" : prefix;
for (Field field : LinuxInput.class.getDeclaredFields()) {
String name = field.getName();
try {
if ((name.startsWith(prefix) || name.startsWith(altPrefix))
&& field.getType() == Short.TYPE
&& field.getShort(null) == code) {
return field.getName();
}
} catch (IllegalAccessException e) {
}
}
}
return new Formatter().format("0x%04x", code & 0xffff).out().toString();
}
|
[
"static",
"String",
"codeToString",
"(",
"String",
"type",
",",
"short",
"code",
")",
"{",
"int",
"i",
"=",
"type",
".",
"indexOf",
"(",
"\"_\"",
")",
";",
"if",
"(",
"i",
">=",
"0",
")",
"{",
"String",
"prefix",
"=",
"type",
".",
"substring",
"(",
"i",
"+",
"1",
")",
";",
"String",
"altPrefix",
"=",
"prefix",
".",
"equals",
"(",
"\"KEY\"",
")",
"?",
"\"BTN\"",
":",
"prefix",
";",
"for",
"(",
"Field",
"field",
":",
"LinuxInput",
".",
"class",
".",
"getDeclaredFields",
"(",
")",
")",
"{",
"String",
"name",
"=",
"field",
".",
"getName",
"(",
")",
";",
"try",
"{",
"if",
"(",
"(",
"name",
".",
"startsWith",
"(",
"prefix",
")",
"||",
"name",
".",
"startsWith",
"(",
"altPrefix",
")",
")",
"&&",
"field",
".",
"getType",
"(",
")",
"==",
"Short",
".",
"TYPE",
"&&",
"field",
".",
"getShort",
"(",
"null",
")",
"==",
"code",
")",
"{",
"return",
"field",
".",
"getName",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"IllegalAccessException",
"e",
")",
"{",
"}",
"}",
"}",
"return",
"new",
"Formatter",
"(",
")",
".",
"format",
"(",
"\"0x%04x\"",
",",
"code",
"&",
"0xffff",
")",
".",
"out",
"(",
")",
".",
"toString",
"(",
")",
";",
"}"
] |
Convert an event code to its equivalent string, given its type string.
The type string is needed because event codes are context sensitive. For
example, the code 1 is "SYN_CONFIG" for an EV_SYN event but "KEY_ESC" for
an EV_KEY event. This method is inefficient and is for debugging use
only.
|
[
"Convert",
"an",
"event",
"code",
"to",
"its",
"equivalent",
"string",
"given",
"its",
"type",
"string",
".",
"The",
"type",
"string",
"is",
"needed",
"because",
"event",
"codes",
"are",
"context",
"sensitive",
".",
"For",
"example",
"the",
"code",
"1",
"is",
"SYN_CONFIG",
"for",
"an",
"EV_SYN",
"event",
"but",
"KEY_ESC",
"for",
"an",
"EV_KEY",
"event",
".",
"This",
"method",
"is",
"inefficient",
"and",
"is",
"for",
"debugging",
"use",
"only",
"."
] |
train
|
https://github.com/TestFX/Monocle/blob/267ccba8889cab244bf8c562dbaa0345a612874c/src/main/java/com/sun/glass/ui/monocle/LinuxInput.java#L759-L777
|
xmlunit/xmlunit
|
xmlunit-core/src/main/java/org/xmlunit/diff/DefaultComparisonFormatter.java
|
DefaultComparisonFormatter.appendDocumentType
|
protected boolean appendDocumentType(StringBuilder sb, DocumentType type) {
if (type == null) {
return false;
}
sb.append("<!DOCTYPE ").append(type.getName());
boolean hasNoPublicId = true;
if (type.getPublicId() != null && type.getPublicId().length() > 0) {
sb.append(" PUBLIC \"").append(type.getPublicId()).append('"');
hasNoPublicId = false;
}
if (type.getSystemId() != null && type.getSystemId().length() > 0) {
if (hasNoPublicId) {
sb.append(" SYSTEM");
}
sb.append(" \"").append(type.getSystemId()).append("\"");
}
sb.append(">");
return true;
}
|
java
|
protected boolean appendDocumentType(StringBuilder sb, DocumentType type) {
if (type == null) {
return false;
}
sb.append("<!DOCTYPE ").append(type.getName());
boolean hasNoPublicId = true;
if (type.getPublicId() != null && type.getPublicId().length() > 0) {
sb.append(" PUBLIC \"").append(type.getPublicId()).append('"');
hasNoPublicId = false;
}
if (type.getSystemId() != null && type.getSystemId().length() > 0) {
if (hasNoPublicId) {
sb.append(" SYSTEM");
}
sb.append(" \"").append(type.getSystemId()).append("\"");
}
sb.append(">");
return true;
}
|
[
"protected",
"boolean",
"appendDocumentType",
"(",
"StringBuilder",
"sb",
",",
"DocumentType",
"type",
")",
"{",
"if",
"(",
"type",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"sb",
".",
"append",
"(",
"\"<!DOCTYPE \"",
")",
".",
"append",
"(",
"type",
".",
"getName",
"(",
")",
")",
";",
"boolean",
"hasNoPublicId",
"=",
"true",
";",
"if",
"(",
"type",
".",
"getPublicId",
"(",
")",
"!=",
"null",
"&&",
"type",
".",
"getPublicId",
"(",
")",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"sb",
".",
"append",
"(",
"\" PUBLIC \\\"\"",
")",
".",
"append",
"(",
"type",
".",
"getPublicId",
"(",
")",
")",
".",
"append",
"(",
"'",
"'",
")",
";",
"hasNoPublicId",
"=",
"false",
";",
"}",
"if",
"(",
"type",
".",
"getSystemId",
"(",
")",
"!=",
"null",
"&&",
"type",
".",
"getSystemId",
"(",
")",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"if",
"(",
"hasNoPublicId",
")",
"{",
"sb",
".",
"append",
"(",
"\" SYSTEM\"",
")",
";",
"}",
"sb",
".",
"append",
"(",
"\" \\\"\"",
")",
".",
"append",
"(",
"type",
".",
"getSystemId",
"(",
")",
")",
".",
"append",
"(",
"\"\\\"\"",
")",
";",
"}",
"sb",
".",
"append",
"(",
"\">\"",
")",
";",
"return",
"true",
";",
"}"
] |
Appends the XML DOCTYPE for {@link #getShortString} or {@link #appendFullDocumentHeader} if present.
@param sb the builder to append to
@param type the document type
@return true if the DOCTPYE has been appended
@since XMLUnit 2.4.0
|
[
"Appends",
"the",
"XML",
"DOCTYPE",
"for",
"{",
"@link",
"#getShortString",
"}",
"or",
"{",
"@link",
"#appendFullDocumentHeader",
"}",
"if",
"present",
"."
] |
train
|
https://github.com/xmlunit/xmlunit/blob/fe3d701d43f57ee83dcba336e4c1555619d3084b/xmlunit-core/src/main/java/org/xmlunit/diff/DefaultComparisonFormatter.java#L220-L238
|
cdk/cdk
|
tool/sdg/src/main/java/org/openscience/cdk/layout/OverlapResolver.java
|
OverlapResolver.areIntersected
|
public boolean areIntersected(IBond bond1, IBond bond2) {
double x1 = 0, x2 = 0, x3 = 0, x4 = 0;
double y1 = 0, y2 = 0, y3 = 0, y4 = 0;
//Point2D.Double p1 = null, p2 = null, p3 = null, p4 = null;
x1 = bond1.getBegin().getPoint2d().x;
x2 = bond1.getEnd().getPoint2d().x;
x3 = bond2.getBegin().getPoint2d().x;
x4 = bond2.getEnd().getPoint2d().x;
y1 = bond1.getBegin().getPoint2d().y;
y2 = bond1.getEnd().getPoint2d().y;
y3 = bond2.getBegin().getPoint2d().y;
y4 = bond2.getEnd().getPoint2d().y;
Line2D.Double line1 = new Line2D.Double(new Point2D.Double(x1, y1), new Point2D.Double(x2, y2));
Line2D.Double line2 = new Line2D.Double(new Point2D.Double(x3, y3), new Point2D.Double(x4, y4));
if (line1.intersectsLine(line2)) {
logger.debug("Two intersecting bonds detected.");
return true;
}
return false;
}
|
java
|
public boolean areIntersected(IBond bond1, IBond bond2) {
double x1 = 0, x2 = 0, x3 = 0, x4 = 0;
double y1 = 0, y2 = 0, y3 = 0, y4 = 0;
//Point2D.Double p1 = null, p2 = null, p3 = null, p4 = null;
x1 = bond1.getBegin().getPoint2d().x;
x2 = bond1.getEnd().getPoint2d().x;
x3 = bond2.getBegin().getPoint2d().x;
x4 = bond2.getEnd().getPoint2d().x;
y1 = bond1.getBegin().getPoint2d().y;
y2 = bond1.getEnd().getPoint2d().y;
y3 = bond2.getBegin().getPoint2d().y;
y4 = bond2.getEnd().getPoint2d().y;
Line2D.Double line1 = new Line2D.Double(new Point2D.Double(x1, y1), new Point2D.Double(x2, y2));
Line2D.Double line2 = new Line2D.Double(new Point2D.Double(x3, y3), new Point2D.Double(x4, y4));
if (line1.intersectsLine(line2)) {
logger.debug("Two intersecting bonds detected.");
return true;
}
return false;
}
|
[
"public",
"boolean",
"areIntersected",
"(",
"IBond",
"bond1",
",",
"IBond",
"bond2",
")",
"{",
"double",
"x1",
"=",
"0",
",",
"x2",
"=",
"0",
",",
"x3",
"=",
"0",
",",
"x4",
"=",
"0",
";",
"double",
"y1",
"=",
"0",
",",
"y2",
"=",
"0",
",",
"y3",
"=",
"0",
",",
"y4",
"=",
"0",
";",
"//Point2D.Double p1 = null, p2 = null, p3 = null, p4 = null;",
"x1",
"=",
"bond1",
".",
"getBegin",
"(",
")",
".",
"getPoint2d",
"(",
")",
".",
"x",
";",
"x2",
"=",
"bond1",
".",
"getEnd",
"(",
")",
".",
"getPoint2d",
"(",
")",
".",
"x",
";",
"x3",
"=",
"bond2",
".",
"getBegin",
"(",
")",
".",
"getPoint2d",
"(",
")",
".",
"x",
";",
"x4",
"=",
"bond2",
".",
"getEnd",
"(",
")",
".",
"getPoint2d",
"(",
")",
".",
"x",
";",
"y1",
"=",
"bond1",
".",
"getBegin",
"(",
")",
".",
"getPoint2d",
"(",
")",
".",
"y",
";",
"y2",
"=",
"bond1",
".",
"getEnd",
"(",
")",
".",
"getPoint2d",
"(",
")",
".",
"y",
";",
"y3",
"=",
"bond2",
".",
"getBegin",
"(",
")",
".",
"getPoint2d",
"(",
")",
".",
"y",
";",
"y4",
"=",
"bond2",
".",
"getEnd",
"(",
")",
".",
"getPoint2d",
"(",
")",
".",
"y",
";",
"Line2D",
".",
"Double",
"line1",
"=",
"new",
"Line2D",
".",
"Double",
"(",
"new",
"Point2D",
".",
"Double",
"(",
"x1",
",",
"y1",
")",
",",
"new",
"Point2D",
".",
"Double",
"(",
"x2",
",",
"y2",
")",
")",
";",
"Line2D",
".",
"Double",
"line2",
"=",
"new",
"Line2D",
".",
"Double",
"(",
"new",
"Point2D",
".",
"Double",
"(",
"x3",
",",
"y3",
")",
",",
"new",
"Point2D",
".",
"Double",
"(",
"x4",
",",
"y4",
")",
")",
";",
"if",
"(",
"line1",
".",
"intersectsLine",
"(",
"line2",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Two intersecting bonds detected.\"",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Checks if two bonds cross each other.
@param bond1 Description of the Parameter
@param bond2 Description of the Parameter
@return Description of the Return Value
|
[
"Checks",
"if",
"two",
"bonds",
"cross",
"each",
"other",
"."
] |
train
|
https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/tool/sdg/src/main/java/org/openscience/cdk/layout/OverlapResolver.java#L245-L268
|
googleapis/cloud-bigtable-client
|
bigtable-client-core-parent/bigtable-client-core/src/main/java/com/google/cloud/bigtable/grpc/BigtableClusterUtilities.java
|
BigtableClusterUtilities.lookupInstanceId
|
public static String lookupInstanceId(String projectId, String clusterId, String zoneId)
throws IOException {
BigtableClusterUtilities utils;
try {
utils = BigtableClusterUtilities.forAllInstances(projectId);
} catch (GeneralSecurityException e) {
throw new RuntimeException("Could not initialize BigtableClusterUtilities", e);
}
try {
Cluster cluster = utils.getCluster(clusterId, zoneId);
return new BigtableClusterName(cluster.getName()).getInstanceId();
} finally {
try {
utils.close();
} catch (Exception e) {
logger.warn("Error closing BigtableClusterUtilities: ", e);
}
}
}
|
java
|
public static String lookupInstanceId(String projectId, String clusterId, String zoneId)
throws IOException {
BigtableClusterUtilities utils;
try {
utils = BigtableClusterUtilities.forAllInstances(projectId);
} catch (GeneralSecurityException e) {
throw new RuntimeException("Could not initialize BigtableClusterUtilities", e);
}
try {
Cluster cluster = utils.getCluster(clusterId, zoneId);
return new BigtableClusterName(cluster.getName()).getInstanceId();
} finally {
try {
utils.close();
} catch (Exception e) {
logger.warn("Error closing BigtableClusterUtilities: ", e);
}
}
}
|
[
"public",
"static",
"String",
"lookupInstanceId",
"(",
"String",
"projectId",
",",
"String",
"clusterId",
",",
"String",
"zoneId",
")",
"throws",
"IOException",
"{",
"BigtableClusterUtilities",
"utils",
";",
"try",
"{",
"utils",
"=",
"BigtableClusterUtilities",
".",
"forAllInstances",
"(",
"projectId",
")",
";",
"}",
"catch",
"(",
"GeneralSecurityException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Could not initialize BigtableClusterUtilities\"",
",",
"e",
")",
";",
"}",
"try",
"{",
"Cluster",
"cluster",
"=",
"utils",
".",
"getCluster",
"(",
"clusterId",
",",
"zoneId",
")",
";",
"return",
"new",
"BigtableClusterName",
"(",
"cluster",
".",
"getName",
"(",
")",
")",
".",
"getInstanceId",
"(",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"utils",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Error closing BigtableClusterUtilities: \"",
",",
"e",
")",
";",
"}",
"}",
"}"
] |
@return The instance id associated with the given project, zone and cluster. We expect instance
and cluster to have one-to-one relationship.
@throws IllegalStateException if the cluster is not found
|
[
"@return",
"The",
"instance",
"id",
"associated",
"with",
"the",
"given",
"project",
"zone",
"and",
"cluster",
".",
"We",
"expect",
"instance",
"and",
"cluster",
"to",
"have",
"one",
"-",
"to",
"-",
"one",
"relationship",
"."
] |
train
|
https://github.com/googleapis/cloud-bigtable-client/blob/53543f36e4d6f9ed1963640d91a35be2a2047656/bigtable-client-core-parent/bigtable-client-core/src/main/java/com/google/cloud/bigtable/grpc/BigtableClusterUtilities.java#L79-L98
|
ManfredTremmel/gwt-commons-lang3
|
src/main/java/org/apache/commons/lang3/text/StrBuilder.java
|
StrBuilder.appendln
|
@GwtIncompatible("incompatible method")
public StrBuilder appendln(final String format, final Object... objs) {
return append(format, objs).appendNewLine();
}
|
java
|
@GwtIncompatible("incompatible method")
public StrBuilder appendln(final String format, final Object... objs) {
return append(format, objs).appendNewLine();
}
|
[
"@",
"GwtIncompatible",
"(",
"\"incompatible method\"",
")",
"public",
"StrBuilder",
"appendln",
"(",
"final",
"String",
"format",
",",
"final",
"Object",
"...",
"objs",
")",
"{",
"return",
"append",
"(",
"format",
",",
"objs",
")",
".",
"appendNewLine",
"(",
")",
";",
"}"
] |
Calls {@link String#format(String, Object...)} and appends the result.
@param format the format string
@param objs the objects to use in the format string
@return {@code this} to enable chaining
@see String#format(String, Object...)
@since 3.2
|
[
"Calls",
"{",
"@link",
"String#format",
"(",
"String",
"Object",
"...",
")",
"}",
"and",
"appends",
"the",
"result",
"."
] |
train
|
https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/text/StrBuilder.java#L1003-L1006
|
redkale/redkale
|
src/org/redkale/util/ResourceFactory.java
|
ResourceFactory.register
|
public <A> A register(final boolean autoSync, final String name, final Type clazz, final A rs) {
checkResourceName(name);
ConcurrentHashMap<String, ResourceEntry> map = this.store.get(clazz);
if (map == null) {
synchronized (clazz) {
map = this.store.get(clazz);
if (map == null) {
map = new ConcurrentHashMap();
store.put(clazz, map);
}
}
}
ResourceEntry re = map.get(name);
if (re == null) {
map.put(name, new ResourceEntry(rs));
} else {
map.put(name, new ResourceEntry(rs, name, re.elements, autoSync));
}
return re == null ? null : (A) re.value;
}
|
java
|
public <A> A register(final boolean autoSync, final String name, final Type clazz, final A rs) {
checkResourceName(name);
ConcurrentHashMap<String, ResourceEntry> map = this.store.get(clazz);
if (map == null) {
synchronized (clazz) {
map = this.store.get(clazz);
if (map == null) {
map = new ConcurrentHashMap();
store.put(clazz, map);
}
}
}
ResourceEntry re = map.get(name);
if (re == null) {
map.put(name, new ResourceEntry(rs));
} else {
map.put(name, new ResourceEntry(rs, name, re.elements, autoSync));
}
return re == null ? null : (A) re.value;
}
|
[
"public",
"<",
"A",
">",
"A",
"register",
"(",
"final",
"boolean",
"autoSync",
",",
"final",
"String",
"name",
",",
"final",
"Type",
"clazz",
",",
"final",
"A",
"rs",
")",
"{",
"checkResourceName",
"(",
"name",
")",
";",
"ConcurrentHashMap",
"<",
"String",
",",
"ResourceEntry",
">",
"map",
"=",
"this",
".",
"store",
".",
"get",
"(",
"clazz",
")",
";",
"if",
"(",
"map",
"==",
"null",
")",
"{",
"synchronized",
"(",
"clazz",
")",
"{",
"map",
"=",
"this",
".",
"store",
".",
"get",
"(",
"clazz",
")",
";",
"if",
"(",
"map",
"==",
"null",
")",
"{",
"map",
"=",
"new",
"ConcurrentHashMap",
"(",
")",
";",
"store",
".",
"put",
"(",
"clazz",
",",
"map",
")",
";",
"}",
"}",
"}",
"ResourceEntry",
"re",
"=",
"map",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"re",
"==",
"null",
")",
"{",
"map",
".",
"put",
"(",
"name",
",",
"new",
"ResourceEntry",
"(",
"rs",
")",
")",
";",
"}",
"else",
"{",
"map",
".",
"put",
"(",
"name",
",",
"new",
"ResourceEntry",
"(",
"rs",
",",
"name",
",",
"re",
".",
"elements",
",",
"autoSync",
")",
")",
";",
"}",
"return",
"re",
"==",
"null",
"?",
"null",
":",
"(",
"A",
")",
"re",
".",
"value",
";",
"}"
] |
将对象以指定资源名和类型注入到资源池中
@param <A> 泛型
@param autoSync 是否同步已被注入的资源
@param name 资源名
@param clazz 资源类型
@param rs 资源对象
@return 旧资源对象
|
[
"将对象以指定资源名和类型注入到资源池中"
] |
train
|
https://github.com/redkale/redkale/blob/ea5169b5c5ea7412fd762331c0c497165832e901/src/org/redkale/util/ResourceFactory.java#L401-L420
|
looly/hutool
|
hutool-poi/src/main/java/cn/hutool/poi/excel/style/StyleUtil.java
|
StyleUtil.setAlign
|
public static CellStyle setAlign(CellStyle cellStyle, HorizontalAlignment halign, VerticalAlignment valign) {
cellStyle.setAlignment(halign);
cellStyle.setVerticalAlignment(valign);
return cellStyle;
}
|
java
|
public static CellStyle setAlign(CellStyle cellStyle, HorizontalAlignment halign, VerticalAlignment valign) {
cellStyle.setAlignment(halign);
cellStyle.setVerticalAlignment(valign);
return cellStyle;
}
|
[
"public",
"static",
"CellStyle",
"setAlign",
"(",
"CellStyle",
"cellStyle",
",",
"HorizontalAlignment",
"halign",
",",
"VerticalAlignment",
"valign",
")",
"{",
"cellStyle",
".",
"setAlignment",
"(",
"halign",
")",
";",
"cellStyle",
".",
"setVerticalAlignment",
"(",
"valign",
")",
";",
"return",
"cellStyle",
";",
"}"
] |
设置cell文本对齐样式
@param cellStyle {@link CellStyle}
@param halign 横向位置
@param valign 纵向位置
@return {@link CellStyle}
|
[
"设置cell文本对齐样式"
] |
train
|
https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-poi/src/main/java/cn/hutool/poi/excel/style/StyleUtil.java#L55-L59
|
PeterisP/LVTagger
|
src/main/java/edu/stanford/nlp/stats/Counters.java
|
Counters.toSortedString
|
public static <T> String toSortedString(Counter<T> counter, int k, String itemFormat, String joiner) {
return toSortedString(counter, k, itemFormat, joiner, "%s");
}
|
java
|
public static <T> String toSortedString(Counter<T> counter, int k, String itemFormat, String joiner) {
return toSortedString(counter, k, itemFormat, joiner, "%s");
}
|
[
"public",
"static",
"<",
"T",
">",
"String",
"toSortedString",
"(",
"Counter",
"<",
"T",
">",
"counter",
",",
"int",
"k",
",",
"String",
"itemFormat",
",",
"String",
"joiner",
")",
"{",
"return",
"toSortedString",
"(",
"counter",
",",
"k",
",",
"itemFormat",
",",
"joiner",
",",
"\"%s\"",
")",
";",
"}"
] |
Returns a string representation of a Counter, displaying the keys and their
counts in decreasing order of count. At most k keys are displayed.
@param counter
A Counter.
@param k
The number of keys to include. Use Integer.MAX_VALUE to include
all keys.
@param itemFormat
The format string for key/count pairs, where the key is first and
the value is second. To display the value first, use argument
indices, e.g. "%2$f %1$s".
@param joiner
The string used between pairs of key/value strings.
@return The top k values from the Counter, formatted as specified.
|
[
"Returns",
"a",
"string",
"representation",
"of",
"a",
"Counter",
"displaying",
"the",
"keys",
"and",
"their",
"counts",
"in",
"decreasing",
"order",
"of",
"count",
".",
"At",
"most",
"k",
"keys",
"are",
"displayed",
"."
] |
train
|
https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/stats/Counters.java#L1792-L1794
|
Mozu/mozu-java
|
mozu-java-core/src/main/java/com/mozu/api/urls/commerce/catalog/admin/CategoryUrl.java
|
CategoryUrl.deleteCategoryByIdUrl
|
public static MozuUrl deleteCategoryByIdUrl(Boolean cascadeDelete, Integer categoryId, Boolean forceDelete, Boolean reassignToParent)
{
UrlFormatter formatter = new UrlFormatter("/api/commerce/catalog/admin/categories/{categoryId}/?cascadeDelete={cascadeDelete}&forceDelete={forceDelete}&reassignToParent={reassignToParent}");
formatter.formatUrl("cascadeDelete", cascadeDelete);
formatter.formatUrl("categoryId", categoryId);
formatter.formatUrl("forceDelete", forceDelete);
formatter.formatUrl("reassignToParent", reassignToParent);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
}
|
java
|
public static MozuUrl deleteCategoryByIdUrl(Boolean cascadeDelete, Integer categoryId, Boolean forceDelete, Boolean reassignToParent)
{
UrlFormatter formatter = new UrlFormatter("/api/commerce/catalog/admin/categories/{categoryId}/?cascadeDelete={cascadeDelete}&forceDelete={forceDelete}&reassignToParent={reassignToParent}");
formatter.formatUrl("cascadeDelete", cascadeDelete);
formatter.formatUrl("categoryId", categoryId);
formatter.formatUrl("forceDelete", forceDelete);
formatter.formatUrl("reassignToParent", reassignToParent);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
}
|
[
"public",
"static",
"MozuUrl",
"deleteCategoryByIdUrl",
"(",
"Boolean",
"cascadeDelete",
",",
"Integer",
"categoryId",
",",
"Boolean",
"forceDelete",
",",
"Boolean",
"reassignToParent",
")",
"{",
"UrlFormatter",
"formatter",
"=",
"new",
"UrlFormatter",
"(",
"\"/api/commerce/catalog/admin/categories/{categoryId}/?cascadeDelete={cascadeDelete}&forceDelete={forceDelete}&reassignToParent={reassignToParent}\"",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"cascadeDelete\"",
",",
"cascadeDelete",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"categoryId\"",
",",
"categoryId",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"forceDelete\"",
",",
"forceDelete",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"reassignToParent\"",
",",
"reassignToParent",
")",
";",
"return",
"new",
"MozuUrl",
"(",
"formatter",
".",
"getResourceUrl",
"(",
")",
",",
"MozuUrl",
".",
"UrlLocation",
".",
"TENANT_POD",
")",
";",
"}"
] |
Get Resource Url for DeleteCategoryById
@param cascadeDelete Specifies whether to also delete all subcategories associated with the specified category.If you set this value is false, only the specified category is deleted.The default value is false.
@param categoryId Unique identifier of the category to modify.
@param forceDelete Specifies whether the category, and any associated subcategories, are deleted even if there are products that reference them. The default value is false.
@param reassignToParent Specifies whether any subcategories of the specified category are reassigned to the parent of the specified category.This field only applies if the cascadeDelete parameter is false.The default value is false.
@return String Resource Url
|
[
"Get",
"Resource",
"Url",
"for",
"DeleteCategoryById"
] |
train
|
https://github.com/Mozu/mozu-java/blob/5beadde73601a859f845e3e2fc1077b39c8bea83/mozu-java-core/src/main/java/com/mozu/api/urls/commerce/catalog/admin/CategoryUrl.java#L152-L160
|
gallandarakhneorg/afc
|
advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapPolyline.java
|
MapPolyline.getNearestEndIndex
|
@Pure
public final int getNearestEndIndex(double x, double y, OutputParameter<Double> distance) {
final int count = getPointCount();
final Point2d firstPoint = getPointAt(0);
final Point2d lastPoint = getPointAt(count - 1);
final double d1 = Point2D.getDistancePointPoint(firstPoint.getX(), firstPoint.getY(), x, y);
final double d2 = Point2D.getDistancePointPoint(lastPoint.getX(), lastPoint.getY(), x, y);
if (d1 <= d2) {
if (distance != null) {
distance.set(d1);
}
return 0;
}
if (distance != null) {
distance.set(d2);
}
return count - 1;
}
|
java
|
@Pure
public final int getNearestEndIndex(double x, double y, OutputParameter<Double> distance) {
final int count = getPointCount();
final Point2d firstPoint = getPointAt(0);
final Point2d lastPoint = getPointAt(count - 1);
final double d1 = Point2D.getDistancePointPoint(firstPoint.getX(), firstPoint.getY(), x, y);
final double d2 = Point2D.getDistancePointPoint(lastPoint.getX(), lastPoint.getY(), x, y);
if (d1 <= d2) {
if (distance != null) {
distance.set(d1);
}
return 0;
}
if (distance != null) {
distance.set(d2);
}
return count - 1;
}
|
[
"@",
"Pure",
"public",
"final",
"int",
"getNearestEndIndex",
"(",
"double",
"x",
",",
"double",
"y",
",",
"OutputParameter",
"<",
"Double",
">",
"distance",
")",
"{",
"final",
"int",
"count",
"=",
"getPointCount",
"(",
")",
";",
"final",
"Point2d",
"firstPoint",
"=",
"getPointAt",
"(",
"0",
")",
";",
"final",
"Point2d",
"lastPoint",
"=",
"getPointAt",
"(",
"count",
"-",
"1",
")",
";",
"final",
"double",
"d1",
"=",
"Point2D",
".",
"getDistancePointPoint",
"(",
"firstPoint",
".",
"getX",
"(",
")",
",",
"firstPoint",
".",
"getY",
"(",
")",
",",
"x",
",",
"y",
")",
";",
"final",
"double",
"d2",
"=",
"Point2D",
".",
"getDistancePointPoint",
"(",
"lastPoint",
".",
"getX",
"(",
")",
",",
"lastPoint",
".",
"getY",
"(",
")",
",",
"x",
",",
"y",
")",
";",
"if",
"(",
"d1",
"<=",
"d2",
")",
"{",
"if",
"(",
"distance",
"!=",
"null",
")",
"{",
"distance",
".",
"set",
"(",
"d1",
")",
";",
"}",
"return",
"0",
";",
"}",
"if",
"(",
"distance",
"!=",
"null",
")",
"{",
"distance",
".",
"set",
"(",
"d2",
")",
";",
"}",
"return",
"count",
"-",
"1",
";",
"}"
] |
Replies the index of the nearest end of line according to the specified point.
@param x is the point coordinate from which the distance must be computed
@param y is the point coordinate from which the distance must be computed
@param distance is the distance value that will be set by this function (if the parameter is not <code>null</code>).
@return index of the nearest end point.
|
[
"Replies",
"the",
"index",
"of",
"the",
"nearest",
"end",
"of",
"line",
"according",
"to",
"the",
"specified",
"point",
"."
] |
train
|
https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapPolyline.java#L248-L265
|
PeterisP/LVTagger
|
src/main/java/edu/stanford/nlp/stats/Counters.java
|
Counters.saveCounter
|
public static <E> void saveCounter(Counter<E> c, OutputStream stream) {
PrintStream out = new PrintStream(stream);
for (E key : c.keySet()) {
out.println(key + " " + c.getCount(key));
}
}
|
java
|
public static <E> void saveCounter(Counter<E> c, OutputStream stream) {
PrintStream out = new PrintStream(stream);
for (E key : c.keySet()) {
out.println(key + " " + c.getCount(key));
}
}
|
[
"public",
"static",
"<",
"E",
">",
"void",
"saveCounter",
"(",
"Counter",
"<",
"E",
">",
"c",
",",
"OutputStream",
"stream",
")",
"{",
"PrintStream",
"out",
"=",
"new",
"PrintStream",
"(",
"stream",
")",
";",
"for",
"(",
"E",
"key",
":",
"c",
".",
"keySet",
"(",
")",
")",
"{",
"out",
".",
"println",
"(",
"key",
"+",
"\" \"",
"+",
"c",
".",
"getCount",
"(",
"key",
")",
")",
";",
"}",
"}"
] |
Saves a Counter as one key/count pair per line separated by white space to
the given OutputStream. Does not close the stream.
|
[
"Saves",
"a",
"Counter",
"as",
"one",
"key",
"/",
"count",
"pair",
"per",
"line",
"separated",
"by",
"white",
"space",
"to",
"the",
"given",
"OutputStream",
".",
"Does",
"not",
"close",
"the",
"stream",
"."
] |
train
|
https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/stats/Counters.java#L1632-L1637
|
recommenders/rival
|
rival-split/src/main/java/net/recommenders/rival/split/parser/AbstractLastfmCelmaParser.java
|
AbstractLastfmCelmaParser.getIndexMap
|
public static long getIndexMap(final File in, final Map<String, Long> map) throws IOException {
long id = 0;
if (in.exists()) {
BufferedReader br = SimpleParser.getBufferedReader(in);
String line;
while ((line = br.readLine()) != null) {
String[] toks = line.split("\t");
long i = Long.parseLong(toks[1]);
map.put(toks[0], i);
id = Math.max(i, id);
}
br.close();
}
return id + 1;
}
|
java
|
public static long getIndexMap(final File in, final Map<String, Long> map) throws IOException {
long id = 0;
if (in.exists()) {
BufferedReader br = SimpleParser.getBufferedReader(in);
String line;
while ((line = br.readLine()) != null) {
String[] toks = line.split("\t");
long i = Long.parseLong(toks[1]);
map.put(toks[0], i);
id = Math.max(i, id);
}
br.close();
}
return id + 1;
}
|
[
"public",
"static",
"long",
"getIndexMap",
"(",
"final",
"File",
"in",
",",
"final",
"Map",
"<",
"String",
",",
"Long",
">",
"map",
")",
"throws",
"IOException",
"{",
"long",
"id",
"=",
"0",
";",
"if",
"(",
"in",
".",
"exists",
"(",
")",
")",
"{",
"BufferedReader",
"br",
"=",
"SimpleParser",
".",
"getBufferedReader",
"(",
"in",
")",
";",
"String",
"line",
";",
"while",
"(",
"(",
"line",
"=",
"br",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"String",
"[",
"]",
"toks",
"=",
"line",
".",
"split",
"(",
"\"\\t\"",
")",
";",
"long",
"i",
"=",
"Long",
".",
"parseLong",
"(",
"toks",
"[",
"1",
"]",
")",
";",
"map",
".",
"put",
"(",
"toks",
"[",
"0",
"]",
",",
"i",
")",
";",
"id",
"=",
"Math",
".",
"max",
"(",
"i",
",",
"id",
")",
";",
"}",
"br",
".",
"close",
"(",
")",
";",
"}",
"return",
"id",
"+",
"1",
";",
"}"
] |
Read a user/item mapping (user/item original value, user/item internal
id) from a file and return the maximum index number in that file.
@param in The file with id mapping.
@param map The user/item mapping
@return The largest id number.
@throws IOException if file does not exist.
|
[
"Read",
"a",
"user",
"/",
"item",
"mapping",
"(",
"user",
"/",
"item",
"original",
"value",
"user",
"/",
"item",
"internal",
"id",
")",
"from",
"a",
"file",
"and",
"return",
"the",
"maximum",
"index",
"number",
"in",
"that",
"file",
"."
] |
train
|
https://github.com/recommenders/rival/blob/6ee8223e91810ae1c6052899595af3906e0c34c6/rival-split/src/main/java/net/recommenders/rival/split/parser/AbstractLastfmCelmaParser.java#L56-L70
|
pac4j/pac4j
|
pac4j-saml/src/main/java/org/pac4j/saml/transport/Pac4jHTTPPostSimpleSignEncoder.java
|
Pac4jHTTPPostSimpleSignEncoder.getEndpointURL
|
@Override
protected URI getEndpointURL(MessageContext<SAMLObject> messageContext) throws MessageEncodingException {
try {
return SAMLBindingSupport.getEndpointURL(messageContext);
} catch (BindingException e) {
throw new MessageEncodingException("Could not obtain message endpoint URL", e);
}
}
|
java
|
@Override
protected URI getEndpointURL(MessageContext<SAMLObject> messageContext) throws MessageEncodingException {
try {
return SAMLBindingSupport.getEndpointURL(messageContext);
} catch (BindingException e) {
throw new MessageEncodingException("Could not obtain message endpoint URL", e);
}
}
|
[
"@",
"Override",
"protected",
"URI",
"getEndpointURL",
"(",
"MessageContext",
"<",
"SAMLObject",
">",
"messageContext",
")",
"throws",
"MessageEncodingException",
"{",
"try",
"{",
"return",
"SAMLBindingSupport",
".",
"getEndpointURL",
"(",
"messageContext",
")",
";",
"}",
"catch",
"(",
"BindingException",
"e",
")",
"{",
"throw",
"new",
"MessageEncodingException",
"(",
"\"Could not obtain message endpoint URL\"",
",",
"e",
")",
";",
"}",
"}"
] |
Gets the response URL from the message context.
@param messageContext current message context
@return response URL from the message context
@throws MessageEncodingException throw if no relying party endpoint is available
|
[
"Gets",
"the",
"response",
"URL",
"from",
"the",
"message",
"context",
"."
] |
train
|
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-saml/src/main/java/org/pac4j/saml/transport/Pac4jHTTPPostSimpleSignEncoder.java#L40-L47
|
contentful/contentful-management.java
|
src/main/java/com/contentful/java/cma/ModuleUiExtensions.java
|
ModuleUiExtensions.fetchAll
|
public CMAArray<CMAUiExtension> fetchAll(String spaceId, String environmentId) {
return fetchAll(spaceId, environmentId, null);
}
|
java
|
public CMAArray<CMAUiExtension> fetchAll(String spaceId, String environmentId) {
return fetchAll(spaceId, environmentId, null);
}
|
[
"public",
"CMAArray",
"<",
"CMAUiExtension",
">",
"fetchAll",
"(",
"String",
"spaceId",
",",
"String",
"environmentId",
")",
"{",
"return",
"fetchAll",
"(",
"spaceId",
",",
"environmentId",
",",
"null",
")",
";",
"}"
] |
Fetch ui extensions from a given space.
{@link CMAClient.Builder#setSpaceId(String)} and will ignore
{@link CMAClient.Builder#setEnvironmentId(String)}.
@param spaceId the id of the space this is valid on.
@param environmentId the id of the environment this is valid on.
@return all the ui extensions for a specific space.
@throws IllegalArgumentException if spaceId is null.
@throws IllegalArgumentException if environmentId is null.
|
[
"Fetch",
"ui",
"extensions",
"from",
"a",
"given",
"space",
".",
"{",
"@link",
"CMAClient",
".",
"Builder#setSpaceId",
"(",
"String",
")",
"}",
"and",
"will",
"ignore",
"{",
"@link",
"CMAClient",
".",
"Builder#setEnvironmentId",
"(",
"String",
")",
"}",
"."
] |
train
|
https://github.com/contentful/contentful-management.java/blob/ca310fb9ea9577fcff0ca57949ab7c2315fa2534/src/main/java/com/contentful/java/cma/ModuleUiExtensions.java#L137-L139
|
FINRAOS/DataGenerator
|
dg-core/src/main/java/org/finra/datagenerator/consumer/DataPipe.java
|
DataPipe.getDelimited
|
public String getDelimited(String[] outTemplate, String separator) {
StringBuilder b = new StringBuilder(1024);
for (String var : outTemplate) {
if (b.length() > 0) {
b.append(separator);
}
b.append(getDataMap().get(var));
}
return b.toString();
}
|
java
|
public String getDelimited(String[] outTemplate, String separator) {
StringBuilder b = new StringBuilder(1024);
for (String var : outTemplate) {
if (b.length() > 0) {
b.append(separator);
}
b.append(getDataMap().get(var));
}
return b.toString();
}
|
[
"public",
"String",
"getDelimited",
"(",
"String",
"[",
"]",
"outTemplate",
",",
"String",
"separator",
")",
"{",
"StringBuilder",
"b",
"=",
"new",
"StringBuilder",
"(",
"1024",
")",
";",
"for",
"(",
"String",
"var",
":",
"outTemplate",
")",
"{",
"if",
"(",
"b",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"b",
".",
"append",
"(",
"separator",
")",
";",
"}",
"b",
".",
"append",
"(",
"getDataMap",
"(",
")",
".",
"get",
"(",
"var",
")",
")",
";",
"}",
"return",
"b",
".",
"toString",
"(",
")",
";",
"}"
] |
Given an array of variable names, returns a delimited {@link String}
of values.
@param outTemplate an array of {@link String}s containing the variable
names.
@param separator the delimiter to use
@return a pipe delimited {@link String} of values
|
[
"Given",
"an",
"array",
"of",
"variable",
"names",
"returns",
"a",
"delimited",
"{",
"@link",
"String",
"}",
"of",
"values",
"."
] |
train
|
https://github.com/FINRAOS/DataGenerator/blob/1f69f949401cbed4db4f553c3eb8350832c4d45a/dg-core/src/main/java/org/finra/datagenerator/consumer/DataPipe.java#L88-L99
|
Azure/azure-sdk-for-java
|
cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/PatternsImpl.java
|
PatternsImpl.addPatternAsync
|
public Observable<PatternRuleInfo> addPatternAsync(UUID appId, String versionId, PatternRuleCreateObject pattern) {
return addPatternWithServiceResponseAsync(appId, versionId, pattern).map(new Func1<ServiceResponse<PatternRuleInfo>, PatternRuleInfo>() {
@Override
public PatternRuleInfo call(ServiceResponse<PatternRuleInfo> response) {
return response.body();
}
});
}
|
java
|
public Observable<PatternRuleInfo> addPatternAsync(UUID appId, String versionId, PatternRuleCreateObject pattern) {
return addPatternWithServiceResponseAsync(appId, versionId, pattern).map(new Func1<ServiceResponse<PatternRuleInfo>, PatternRuleInfo>() {
@Override
public PatternRuleInfo call(ServiceResponse<PatternRuleInfo> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"PatternRuleInfo",
">",
"addPatternAsync",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"PatternRuleCreateObject",
"pattern",
")",
"{",
"return",
"addPatternWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"pattern",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"PatternRuleInfo",
">",
",",
"PatternRuleInfo",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"PatternRuleInfo",
"call",
"(",
"ServiceResponse",
"<",
"PatternRuleInfo",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Adds one pattern to the specified application.
@param appId The application ID.
@param versionId The version ID.
@param pattern The input pattern.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PatternRuleInfo object
|
[
"Adds",
"one",
"pattern",
"to",
"the",
"specified",
"application",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/PatternsImpl.java#L141-L148
|
nguillaumin/slick2d-maven
|
slick2d-core/src/main/java/org/newdawn/slick/util/xml/ObjectTreeParser.java
|
ObjectTreeParser.setField
|
private void setField(Field field, Object instance, Object value) throws SlickXMLException {
try {
field.setAccessible(true);
field.set(instance, value);
} catch (IllegalArgumentException e) {
throw new SlickXMLException("Failed to set: "+field+" for an XML attribute, is it valid?", e);
} catch (IllegalAccessException e) {
throw new SlickXMLException("Failed to set: "+field+" for an XML attribute, is it valid?", e);
} finally {
field.setAccessible(false);
}
}
|
java
|
private void setField(Field field, Object instance, Object value) throws SlickXMLException {
try {
field.setAccessible(true);
field.set(instance, value);
} catch (IllegalArgumentException e) {
throw new SlickXMLException("Failed to set: "+field+" for an XML attribute, is it valid?", e);
} catch (IllegalAccessException e) {
throw new SlickXMLException("Failed to set: "+field+" for an XML attribute, is it valid?", e);
} finally {
field.setAccessible(false);
}
}
|
[
"private",
"void",
"setField",
"(",
"Field",
"field",
",",
"Object",
"instance",
",",
"Object",
"value",
")",
"throws",
"SlickXMLException",
"{",
"try",
"{",
"field",
".",
"setAccessible",
"(",
"true",
")",
";",
"field",
".",
"set",
"(",
"instance",
",",
"value",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"throw",
"new",
"SlickXMLException",
"(",
"\"Failed to set: \"",
"+",
"field",
"+",
"\" for an XML attribute, is it valid?\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"e",
")",
"{",
"throw",
"new",
"SlickXMLException",
"(",
"\"Failed to set: \"",
"+",
"field",
"+",
"\" for an XML attribute, is it valid?\"",
",",
"e",
")",
";",
"}",
"finally",
"{",
"field",
".",
"setAccessible",
"(",
"false",
")",
";",
"}",
"}"
] |
Set a field value on a object instance
@param field The field to be set
@param instance The instance of the object to set it on
@param value The value to set
@throws SlickXMLException Indicates a failure to set or access the field
|
[
"Set",
"a",
"field",
"value",
"on",
"a",
"object",
"instance"
] |
train
|
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/xml/ObjectTreeParser.java#L429-L440
|
aws/aws-sdk-java
|
aws-java-sdk-greengrass/src/main/java/com/amazonaws/services/greengrass/model/GetResourceDefinitionResult.java
|
GetResourceDefinitionResult.withTags
|
public GetResourceDefinitionResult withTags(java.util.Map<String, String> tags) {
setTags(tags);
return this;
}
|
java
|
public GetResourceDefinitionResult withTags(java.util.Map<String, String> tags) {
setTags(tags);
return this;
}
|
[
"public",
"GetResourceDefinitionResult",
"withTags",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"tags",
")",
"{",
"setTags",
"(",
"tags",
")",
";",
"return",
"this",
";",
"}"
] |
The tags for the definition.
@param tags
The tags for the definition.
@return Returns a reference to this object so that method calls can be chained together.
|
[
"The",
"tags",
"for",
"the",
"definition",
"."
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-greengrass/src/main/java/com/amazonaws/services/greengrass/model/GetResourceDefinitionResult.java#L310-L313
|
eobermuhlner/big-math
|
ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigDecimalMath.java
|
BigDecimalMath.roundWithTrailingZeroes
|
public static BigDecimal roundWithTrailingZeroes(BigDecimal value, MathContext mathContext) {
if (value.precision() == mathContext.getPrecision()) {
return value;
}
if (value.signum() == 0) {
return BigDecimal.ZERO.setScale(mathContext.getPrecision() - 1);
}
try {
BigDecimal stripped = value.stripTrailingZeros();
int exponentStripped = exponent(stripped); // value.precision() - value.scale() - 1;
BigDecimal zero;
if (exponentStripped < -1) {
zero = BigDecimal.ZERO.setScale(mathContext.getPrecision() - exponentStripped);
} else {
zero = BigDecimal.ZERO.setScale(mathContext.getPrecision() + exponentStripped + 1);
}
return stripped.add(zero, mathContext);
} catch (ArithmeticException ex) {
return value.round(mathContext);
}
}
|
java
|
public static BigDecimal roundWithTrailingZeroes(BigDecimal value, MathContext mathContext) {
if (value.precision() == mathContext.getPrecision()) {
return value;
}
if (value.signum() == 0) {
return BigDecimal.ZERO.setScale(mathContext.getPrecision() - 1);
}
try {
BigDecimal stripped = value.stripTrailingZeros();
int exponentStripped = exponent(stripped); // value.precision() - value.scale() - 1;
BigDecimal zero;
if (exponentStripped < -1) {
zero = BigDecimal.ZERO.setScale(mathContext.getPrecision() - exponentStripped);
} else {
zero = BigDecimal.ZERO.setScale(mathContext.getPrecision() + exponentStripped + 1);
}
return stripped.add(zero, mathContext);
} catch (ArithmeticException ex) {
return value.round(mathContext);
}
}
|
[
"public",
"static",
"BigDecimal",
"roundWithTrailingZeroes",
"(",
"BigDecimal",
"value",
",",
"MathContext",
"mathContext",
")",
"{",
"if",
"(",
"value",
".",
"precision",
"(",
")",
"==",
"mathContext",
".",
"getPrecision",
"(",
")",
")",
"{",
"return",
"value",
";",
"}",
"if",
"(",
"value",
".",
"signum",
"(",
")",
"==",
"0",
")",
"{",
"return",
"BigDecimal",
".",
"ZERO",
".",
"setScale",
"(",
"mathContext",
".",
"getPrecision",
"(",
")",
"-",
"1",
")",
";",
"}",
"try",
"{",
"BigDecimal",
"stripped",
"=",
"value",
".",
"stripTrailingZeros",
"(",
")",
";",
"int",
"exponentStripped",
"=",
"exponent",
"(",
"stripped",
")",
";",
"// value.precision() - value.scale() - 1;",
"BigDecimal",
"zero",
";",
"if",
"(",
"exponentStripped",
"<",
"-",
"1",
")",
"{",
"zero",
"=",
"BigDecimal",
".",
"ZERO",
".",
"setScale",
"(",
"mathContext",
".",
"getPrecision",
"(",
")",
"-",
"exponentStripped",
")",
";",
"}",
"else",
"{",
"zero",
"=",
"BigDecimal",
".",
"ZERO",
".",
"setScale",
"(",
"mathContext",
".",
"getPrecision",
"(",
")",
"+",
"exponentStripped",
"+",
"1",
")",
";",
"}",
"return",
"stripped",
".",
"add",
"(",
"zero",
",",
"mathContext",
")",
";",
"}",
"catch",
"(",
"ArithmeticException",
"ex",
")",
"{",
"return",
"value",
".",
"round",
"(",
"mathContext",
")",
";",
"}",
"}"
] |
Rounds the specified {@link BigDecimal} to the precision of the specified {@link MathContext} including trailing zeroes.
<p>This method is similar to {@link BigDecimal#round(MathContext)} but does <strong>not</strong> remove the trailing zeroes.</p>
<p>Example:</p>
<pre>
MathContext mc = new MathContext(5);
System.out.println(BigDecimalMath.roundWithTrailingZeroes(new BigDecimal("1.234567"), mc)); // 1.2346
System.out.println(BigDecimalMath.roundWithTrailingZeroes(new BigDecimal("123.4567"), mc)); // 123.46
System.out.println(BigDecimalMath.roundWithTrailingZeroes(new BigDecimal("0.001234567"), mc)); // 0.0012346
System.out.println(BigDecimalMath.roundWithTrailingZeroes(new BigDecimal("1.23"), mc)); // 1.2300
System.out.println(BigDecimalMath.roundWithTrailingZeroes(new BigDecimal("1.230000"), mc)); // 1.2300
System.out.println(BigDecimalMath.roundWithTrailingZeroes(new BigDecimal("0.00123"), mc)); // 0.0012300
System.out.println(BigDecimalMath.roundWithTrailingZeroes(new BigDecimal("0"), mc)); // 0.0000
System.out.println(BigDecimalMath.roundWithTrailingZeroes(new BigDecimal("0.00000000"), mc)); // 0.0000
</pre>
@param value the {@link BigDecimal} to round
@param mathContext the {@link MathContext} used for the result
@return the rounded {@link BigDecimal} value including trailing zeroes
@see BigDecimal#round(MathContext)
@see BigDecimalMath#round(BigDecimal, MathContext)
|
[
"Rounds",
"the",
"specified",
"{",
"@link",
"BigDecimal",
"}",
"to",
"the",
"precision",
"of",
"the",
"specified",
"{",
"@link",
"MathContext",
"}",
"including",
"trailing",
"zeroes",
"."
] |
train
|
https://github.com/eobermuhlner/big-math/blob/52c4fc334d0d722b295de740c1018ee400e3e8f2/ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/BigDecimalMath.java#L428-L450
|
groupon/odo
|
browsermob-proxy/src/main/java/com/groupon/odo/bmp/KeyStoreManager.java
|
KeyStoreManager.addCertAndPrivateKey
|
public synchronized void addCertAndPrivateKey(String hostname, final X509Certificate cert, final PrivateKey privKey)
throws KeyStoreException, CertificateException, NoSuchAlgorithmException
{
// String alias = ThumbprintUtil.getThumbprint(cert);
_ks.deleteEntry(hostname);
_ks.setCertificateEntry(hostname, cert);
_ks.setKeyEntry(hostname, privKey, _keypassword, new java.security.cert.Certificate[] {cert});
if(persistImmediately)
{
persist();
}
}
|
java
|
public synchronized void addCertAndPrivateKey(String hostname, final X509Certificate cert, final PrivateKey privKey)
throws KeyStoreException, CertificateException, NoSuchAlgorithmException
{
// String alias = ThumbprintUtil.getThumbprint(cert);
_ks.deleteEntry(hostname);
_ks.setCertificateEntry(hostname, cert);
_ks.setKeyEntry(hostname, privKey, _keypassword, new java.security.cert.Certificate[] {cert});
if(persistImmediately)
{
persist();
}
}
|
[
"public",
"synchronized",
"void",
"addCertAndPrivateKey",
"(",
"String",
"hostname",
",",
"final",
"X509Certificate",
"cert",
",",
"final",
"PrivateKey",
"privKey",
")",
"throws",
"KeyStoreException",
",",
"CertificateException",
",",
"NoSuchAlgorithmException",
"{",
"//\t\tString alias = ThumbprintUtil.getThumbprint(cert);",
"_ks",
".",
"deleteEntry",
"(",
"hostname",
")",
";",
"_ks",
".",
"setCertificateEntry",
"(",
"hostname",
",",
"cert",
")",
";",
"_ks",
".",
"setKeyEntry",
"(",
"hostname",
",",
"privKey",
",",
"_keypassword",
",",
"new",
"java",
".",
"security",
".",
"cert",
".",
"Certificate",
"[",
"]",
"{",
"cert",
"}",
")",
";",
"if",
"(",
"persistImmediately",
")",
"{",
"persist",
"(",
")",
";",
"}",
"}"
] |
Stores a new certificate and its associated private key in the keystore.
@param hostname
@param cert
@param privKey @throws KeyStoreException
@throws CertificateException
@throws NoSuchAlgorithmException
|
[
"Stores",
"a",
"new",
"certificate",
"and",
"its",
"associated",
"private",
"key",
"in",
"the",
"keystore",
"."
] |
train
|
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/browsermob-proxy/src/main/java/com/groupon/odo/bmp/KeyStoreManager.java#L547-L562
|
TheCoder4eu/BootsFaces-OSP
|
src/main/java/net/bootsfaces/component/well/WellRenderer.java
|
WellRenderer.encodeBegin
|
@Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
if (!component.isRendered()) {
return;
}
Well well = (Well) component;
ResponseWriter rw = context.getResponseWriter();
String clientId = well.getClientId();
String sz = well.getSize();
rw.startElement("div", well);
rw.writeAttribute("id", clientId, "id");
String style = well.getStyle();
if (null != style) {
rw.writeAttribute("style", style, null);
}
String styleClass = well.getStyleClass();
if (null == styleClass)
styleClass = "";
else
styleClass = " " + styleClass;
styleClass += Responsive.getResponsiveStyleClass(well, false);
Tooltip.generateTooltip(context, well, rw);
if (sz != null) {
rw.writeAttribute("class", "well well-" + sz + styleClass, "class");
} else {
rw.writeAttribute("class", "well" + styleClass, "class");
}
beginDisabledFieldset(well, rw);
Object value = well.getValue();
if (null != value) {
rw.writeText(String.valueOf(value), null);
}
}
|
java
|
@Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
if (!component.isRendered()) {
return;
}
Well well = (Well) component;
ResponseWriter rw = context.getResponseWriter();
String clientId = well.getClientId();
String sz = well.getSize();
rw.startElement("div", well);
rw.writeAttribute("id", clientId, "id");
String style = well.getStyle();
if (null != style) {
rw.writeAttribute("style", style, null);
}
String styleClass = well.getStyleClass();
if (null == styleClass)
styleClass = "";
else
styleClass = " " + styleClass;
styleClass += Responsive.getResponsiveStyleClass(well, false);
Tooltip.generateTooltip(context, well, rw);
if (sz != null) {
rw.writeAttribute("class", "well well-" + sz + styleClass, "class");
} else {
rw.writeAttribute("class", "well" + styleClass, "class");
}
beginDisabledFieldset(well, rw);
Object value = well.getValue();
if (null != value) {
rw.writeText(String.valueOf(value), null);
}
}
|
[
"@",
"Override",
"public",
"void",
"encodeBegin",
"(",
"FacesContext",
"context",
",",
"UIComponent",
"component",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"component",
".",
"isRendered",
"(",
")",
")",
"{",
"return",
";",
"}",
"Well",
"well",
"=",
"(",
"Well",
")",
"component",
";",
"ResponseWriter",
"rw",
"=",
"context",
".",
"getResponseWriter",
"(",
")",
";",
"String",
"clientId",
"=",
"well",
".",
"getClientId",
"(",
")",
";",
"String",
"sz",
"=",
"well",
".",
"getSize",
"(",
")",
";",
"rw",
".",
"startElement",
"(",
"\"div\"",
",",
"well",
")",
";",
"rw",
".",
"writeAttribute",
"(",
"\"id\"",
",",
"clientId",
",",
"\"id\"",
")",
";",
"String",
"style",
"=",
"well",
".",
"getStyle",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"style",
")",
"{",
"rw",
".",
"writeAttribute",
"(",
"\"style\"",
",",
"style",
",",
"null",
")",
";",
"}",
"String",
"styleClass",
"=",
"well",
".",
"getStyleClass",
"(",
")",
";",
"if",
"(",
"null",
"==",
"styleClass",
")",
"styleClass",
"=",
"\"\"",
";",
"else",
"styleClass",
"=",
"\" \"",
"+",
"styleClass",
";",
"styleClass",
"+=",
"Responsive",
".",
"getResponsiveStyleClass",
"(",
"well",
",",
"false",
")",
";",
"Tooltip",
".",
"generateTooltip",
"(",
"context",
",",
"well",
",",
"rw",
")",
";",
"if",
"(",
"sz",
"!=",
"null",
")",
"{",
"rw",
".",
"writeAttribute",
"(",
"\"class\"",
",",
"\"well well-\"",
"+",
"sz",
"+",
"styleClass",
",",
"\"class\"",
")",
";",
"}",
"else",
"{",
"rw",
".",
"writeAttribute",
"(",
"\"class\"",
",",
"\"well\"",
"+",
"styleClass",
",",
"\"class\"",
")",
";",
"}",
"beginDisabledFieldset",
"(",
"well",
",",
"rw",
")",
";",
"Object",
"value",
"=",
"well",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"value",
")",
"{",
"rw",
".",
"writeText",
"(",
"String",
".",
"valueOf",
"(",
"value",
")",
",",
"null",
")",
";",
"}",
"}"
] |
This methods generates the HTML code of the current b:well.
<code>encodeBegin</code> generates the start of the component. After the,
the JSF framework calls <code>encodeChildren()</code> to generate the
HTML code between the beginning and the end of the component. For
instance, in the case of a panel component the content of the panel is
generated by <code>encodeChildren()</code>. After that,
<code>encodeEnd()</code> is called to generate the rest of the HTML code.
@param context
the FacesContext.
@param component
the current b:well.
@throws IOException
thrown if something goes wrong when writing the HTML code.
|
[
"This",
"methods",
"generates",
"the",
"HTML",
"code",
"of",
"the",
"current",
"b",
":",
"well",
".",
"<code",
">",
"encodeBegin<",
"/",
"code",
">",
"generates",
"the",
"start",
"of",
"the",
"component",
".",
"After",
"the",
"the",
"JSF",
"framework",
"calls",
"<code",
">",
"encodeChildren",
"()",
"<",
"/",
"code",
">",
"to",
"generate",
"the",
"HTML",
"code",
"between",
"the",
"beginning",
"and",
"the",
"end",
"of",
"the",
"component",
".",
"For",
"instance",
"in",
"the",
"case",
"of",
"a",
"panel",
"component",
"the",
"content",
"of",
"the",
"panel",
"is",
"generated",
"by",
"<code",
">",
"encodeChildren",
"()",
"<",
"/",
"code",
">",
".",
"After",
"that",
"<code",
">",
"encodeEnd",
"()",
"<",
"/",
"code",
">",
"is",
"called",
"to",
"generate",
"the",
"rest",
"of",
"the",
"HTML",
"code",
"."
] |
train
|
https://github.com/TheCoder4eu/BootsFaces-OSP/blob/d1a70952bc240979b5272fa4fe1c7f100873add0/src/main/java/net/bootsfaces/component/well/WellRenderer.java#L52-L88
|
grails/grails-core
|
grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java
|
GrailsASTUtils.buildGetPropertyExpression
|
public static MethodCallExpression buildGetPropertyExpression(final Expression objectExpression, final String propertyName, final ClassNode targetClassNode, final boolean useBooleanGetter) {
String methodName = (useBooleanGetter ? "is" : "get") + MetaClassHelper.capitalize(propertyName);
MethodCallExpression methodCallExpression = new MethodCallExpression(objectExpression, methodName, MethodCallExpression.NO_ARGUMENTS);
MethodNode getterMethod = targetClassNode.getGetterMethod(methodName);
if(getterMethod != null) {
methodCallExpression.setMethodTarget(getterMethod);
}
return methodCallExpression;
}
|
java
|
public static MethodCallExpression buildGetPropertyExpression(final Expression objectExpression, final String propertyName, final ClassNode targetClassNode, final boolean useBooleanGetter) {
String methodName = (useBooleanGetter ? "is" : "get") + MetaClassHelper.capitalize(propertyName);
MethodCallExpression methodCallExpression = new MethodCallExpression(objectExpression, methodName, MethodCallExpression.NO_ARGUMENTS);
MethodNode getterMethod = targetClassNode.getGetterMethod(methodName);
if(getterMethod != null) {
methodCallExpression.setMethodTarget(getterMethod);
}
return methodCallExpression;
}
|
[
"public",
"static",
"MethodCallExpression",
"buildGetPropertyExpression",
"(",
"final",
"Expression",
"objectExpression",
",",
"final",
"String",
"propertyName",
",",
"final",
"ClassNode",
"targetClassNode",
",",
"final",
"boolean",
"useBooleanGetter",
")",
"{",
"String",
"methodName",
"=",
"(",
"useBooleanGetter",
"?",
"\"is\"",
":",
"\"get\"",
")",
"+",
"MetaClassHelper",
".",
"capitalize",
"(",
"propertyName",
")",
";",
"MethodCallExpression",
"methodCallExpression",
"=",
"new",
"MethodCallExpression",
"(",
"objectExpression",
",",
"methodName",
",",
"MethodCallExpression",
".",
"NO_ARGUMENTS",
")",
";",
"MethodNode",
"getterMethod",
"=",
"targetClassNode",
".",
"getGetterMethod",
"(",
"methodName",
")",
";",
"if",
"(",
"getterMethod",
"!=",
"null",
")",
"{",
"methodCallExpression",
".",
"setMethodTarget",
"(",
"getterMethod",
")",
";",
"}",
"return",
"methodCallExpression",
";",
"}"
] |
Build static direct call to getter of a property
@param objectExpression
@param propertyName
@param targetClassNode
@param useBooleanGetter
@return The method call expression
|
[
"Build",
"static",
"direct",
"call",
"to",
"getter",
"of",
"a",
"property"
] |
train
|
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java#L1314-L1322
|
hawkular/hawkular-agent
|
hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/inventory/ConnectionData.java
|
ConnectionData.createUri
|
private static URI createUri(String protocol, String host, int port) {
try {
return new URI(protocol, null, host, port, null, null, null);
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
|
java
|
private static URI createUri(String protocol, String host, int port) {
try {
return new URI(protocol, null, host, port, null, null, null);
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
|
[
"private",
"static",
"URI",
"createUri",
"(",
"String",
"protocol",
",",
"String",
"host",
",",
"int",
"port",
")",
"{",
"try",
"{",
"return",
"new",
"URI",
"(",
"protocol",
",",
"null",
",",
"host",
",",
"port",
",",
"null",
",",
"null",
",",
"null",
")",
";",
"}",
"catch",
"(",
"URISyntaxException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] |
A convenience method to create a new {@link URI} out of a protocol, host and port, hiding the
{@link URISyntaxException} behind a {@link RuntimeException}.
@param protocol the protocol such as http
@param host hostname or IP address
@param port port number
@return a new {@link URI}
|
[
"A",
"convenience",
"method",
"to",
"create",
"a",
"new",
"{",
"@link",
"URI",
"}",
"out",
"of",
"a",
"protocol",
"host",
"and",
"port",
"hiding",
"the",
"{",
"@link",
"URISyntaxException",
"}",
"behind",
"a",
"{",
"@link",
"RuntimeException",
"}",
"."
] |
train
|
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/inventory/ConnectionData.java#L39-L45
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-ipLoadbalancing/src/main/java/net/minidev/ovh/api/ApiOvhIpLoadbalancing.java
|
ApiOvhIpLoadbalancing.serviceName_availableFarmProbes_GET
|
public ArrayList<OvhFarmAvailableProbe> serviceName_availableFarmProbes_GET(String serviceName) throws IOException {
String qPath = "/ipLoadbalancing/{serviceName}/availableFarmProbes";
StringBuilder sb = path(qPath, serviceName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t5);
}
|
java
|
public ArrayList<OvhFarmAvailableProbe> serviceName_availableFarmProbes_GET(String serviceName) throws IOException {
String qPath = "/ipLoadbalancing/{serviceName}/availableFarmProbes";
StringBuilder sb = path(qPath, serviceName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t5);
}
|
[
"public",
"ArrayList",
"<",
"OvhFarmAvailableProbe",
">",
"serviceName_availableFarmProbes_GET",
"(",
"String",
"serviceName",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/ipLoadbalancing/{serviceName}/availableFarmProbes\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"t5",
")",
";",
"}"
] |
Available farm probes for health checks
REST: GET /ipLoadbalancing/{serviceName}/availableFarmProbes
@param serviceName [required] The internal name of your IP load balancing
|
[
"Available",
"farm",
"probes",
"for",
"health",
"checks"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-ipLoadbalancing/src/main/java/net/minidev/ovh/api/ApiOvhIpLoadbalancing.java#L710-L715
|
apiman/apiman
|
manager/api/es/src/main/java/io/apiman/manager/api/es/EsMarshalling.java
|
EsMarshalling.unmarshallRoleMembership
|
public static RoleMembershipBean unmarshallRoleMembership(Map<String, Object> source) {
if (source == null) {
return null;
}
RoleMembershipBean bean = new RoleMembershipBean();
bean.setId(asLong(source.get("id")));
bean.setOrganizationId(asString(source.get("organizationId")));
bean.setRoleId(asString(source.get("roleId")));
bean.setUserId(asString(source.get("userId")));
bean.setCreatedOn(asDate(source.get("createdOn")));
postMarshall(bean);
return bean;
}
|
java
|
public static RoleMembershipBean unmarshallRoleMembership(Map<String, Object> source) {
if (source == null) {
return null;
}
RoleMembershipBean bean = new RoleMembershipBean();
bean.setId(asLong(source.get("id")));
bean.setOrganizationId(asString(source.get("organizationId")));
bean.setRoleId(asString(source.get("roleId")));
bean.setUserId(asString(source.get("userId")));
bean.setCreatedOn(asDate(source.get("createdOn")));
postMarshall(bean);
return bean;
}
|
[
"public",
"static",
"RoleMembershipBean",
"unmarshallRoleMembership",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"source",
")",
"{",
"if",
"(",
"source",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"RoleMembershipBean",
"bean",
"=",
"new",
"RoleMembershipBean",
"(",
")",
";",
"bean",
".",
"setId",
"(",
"asLong",
"(",
"source",
".",
"get",
"(",
"\"id\"",
")",
")",
")",
";",
"bean",
".",
"setOrganizationId",
"(",
"asString",
"(",
"source",
".",
"get",
"(",
"\"organizationId\"",
")",
")",
")",
";",
"bean",
".",
"setRoleId",
"(",
"asString",
"(",
"source",
".",
"get",
"(",
"\"roleId\"",
")",
")",
")",
";",
"bean",
".",
"setUserId",
"(",
"asString",
"(",
"source",
".",
"get",
"(",
"\"userId\"",
")",
")",
")",
";",
"bean",
".",
"setCreatedOn",
"(",
"asDate",
"(",
"source",
".",
"get",
"(",
"\"createdOn\"",
")",
")",
")",
";",
"postMarshall",
"(",
"bean",
")",
";",
"return",
"bean",
";",
"}"
] |
Unmarshals the given map source into a bean.
@param source the source
@return the role membership
|
[
"Unmarshals",
"the",
"given",
"map",
"source",
"into",
"a",
"bean",
"."
] |
train
|
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/es/src/main/java/io/apiman/manager/api/es/EsMarshalling.java#L1190-L1202
|
alkacon/opencms-core
|
src/org/opencms/db/CmsAliasManager.java
|
CmsAliasManager.checkPermissionsForMassEdit
|
private void checkPermissionsForMassEdit(CmsObject cms, String siteRoot) throws CmsException {
String originalSiteRoot = cms.getRequestContext().getSiteRoot();
try {
cms.getRequestContext().setSiteRoot(siteRoot);
checkPermissionsForMassEdit(cms);
} finally {
cms.getRequestContext().setSiteRoot(originalSiteRoot);
}
}
|
java
|
private void checkPermissionsForMassEdit(CmsObject cms, String siteRoot) throws CmsException {
String originalSiteRoot = cms.getRequestContext().getSiteRoot();
try {
cms.getRequestContext().setSiteRoot(siteRoot);
checkPermissionsForMassEdit(cms);
} finally {
cms.getRequestContext().setSiteRoot(originalSiteRoot);
}
}
|
[
"private",
"void",
"checkPermissionsForMassEdit",
"(",
"CmsObject",
"cms",
",",
"String",
"siteRoot",
")",
"throws",
"CmsException",
"{",
"String",
"originalSiteRoot",
"=",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"getSiteRoot",
"(",
")",
";",
"try",
"{",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"setSiteRoot",
"(",
"siteRoot",
")",
";",
"checkPermissionsForMassEdit",
"(",
"cms",
")",
";",
"}",
"finally",
"{",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"setSiteRoot",
"(",
"originalSiteRoot",
")",
";",
"}",
"}"
] |
Checks that the user has permissions for a mass edit operation in a given site.<p>
@param cms the current CMS context
@param siteRoot the site for which the permissions should be checked
@throws CmsException if something goes wrong
|
[
"Checks",
"that",
"the",
"user",
"has",
"permissions",
"for",
"a",
"mass",
"edit",
"operation",
"in",
"a",
"given",
"site",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/db/CmsAliasManager.java#L512-L521
|
RKumsher/utils
|
src/main/java/com/github/rkumsher/date/RandomDateUtils.java
|
RandomDateUtils.randomInstantAfter
|
public static Instant randomInstantAfter(Instant after) {
checkArgument(after != null, "After must be non-null");
checkArgument(after.isBefore(MAX_INSTANT), "Cannot produce date after %s", MAX_INSTANT);
return randomInstant(after.plus(1, MILLIS), MAX_INSTANT);
}
|
java
|
public static Instant randomInstantAfter(Instant after) {
checkArgument(after != null, "After must be non-null");
checkArgument(after.isBefore(MAX_INSTANT), "Cannot produce date after %s", MAX_INSTANT);
return randomInstant(after.plus(1, MILLIS), MAX_INSTANT);
}
|
[
"public",
"static",
"Instant",
"randomInstantAfter",
"(",
"Instant",
"after",
")",
"{",
"checkArgument",
"(",
"after",
"!=",
"null",
",",
"\"After must be non-null\"",
")",
";",
"checkArgument",
"(",
"after",
".",
"isBefore",
"(",
"MAX_INSTANT",
")",
",",
"\"Cannot produce date after %s\"",
",",
"MAX_INSTANT",
")",
";",
"return",
"randomInstant",
"(",
"after",
".",
"plus",
"(",
"1",
",",
"MILLIS",
")",
",",
"MAX_INSTANT",
")",
";",
"}"
] |
Returns a random {@link Instant} that is after the given {@link Instant}.
@param after the value that returned {@link Instant} must be after
@return the random {@link Instant}
@throws IllegalArgumentException if after is null or if after is equal to or after {@link
RandomDateUtils#MAX_INSTANT}
|
[
"Returns",
"a",
"random",
"{",
"@link",
"Instant",
"}",
"that",
"is",
"after",
"the",
"given",
"{",
"@link",
"Instant",
"}",
"."
] |
train
|
https://github.com/RKumsher/utils/blob/fcdb190569cd0288249bf4b46fd418f8c01d1caf/src/main/java/com/github/rkumsher/date/RandomDateUtils.java#L487-L491
|
Azure/azure-sdk-for-java
|
labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/GlobalUsersInner.java
|
GlobalUsersInner.getOperationStatusAsync
|
public Observable<OperationStatusResponseInner> getOperationStatusAsync(String userName, String operationUrl) {
return getOperationStatusWithServiceResponseAsync(userName, operationUrl).map(new Func1<ServiceResponse<OperationStatusResponseInner>, OperationStatusResponseInner>() {
@Override
public OperationStatusResponseInner call(ServiceResponse<OperationStatusResponseInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<OperationStatusResponseInner> getOperationStatusAsync(String userName, String operationUrl) {
return getOperationStatusWithServiceResponseAsync(userName, operationUrl).map(new Func1<ServiceResponse<OperationStatusResponseInner>, OperationStatusResponseInner>() {
@Override
public OperationStatusResponseInner call(ServiceResponse<OperationStatusResponseInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"OperationStatusResponseInner",
">",
"getOperationStatusAsync",
"(",
"String",
"userName",
",",
"String",
"operationUrl",
")",
"{",
"return",
"getOperationStatusWithServiceResponseAsync",
"(",
"userName",
",",
"operationUrl",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"OperationStatusResponseInner",
">",
",",
"OperationStatusResponseInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"OperationStatusResponseInner",
"call",
"(",
"ServiceResponse",
"<",
"OperationStatusResponseInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Gets the status of long running operation.
@param userName The name of the user.
@param operationUrl The operation url of long running operation
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the OperationStatusResponseInner object
|
[
"Gets",
"the",
"status",
"of",
"long",
"running",
"operation",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/GlobalUsersInner.java#L407-L414
|
bwkimmel/jdcp
|
jdcp-worker/src/main/java/ca/eandb/jdcp/worker/DbCachingJobServiceClassLoaderStrategy.java
|
DbCachingJobServiceClassLoaderStrategy.prepareDataSource
|
public static void prepareDataSource(DataSource ds) throws SQLException {
Connection con = null;
String sql;
try {
con = ds.getConnection();
con.setAutoCommit(false);
DatabaseMetaData meta = con.getMetaData();
ResultSet rs = meta.getTables(null, null, null, new String[]{"TABLE"});
int tableNameColumn = rs.findColumn("TABLE_NAME");
int count = 0;
while (rs.next()) {
String tableName = rs.getString(tableNameColumn);
if (tableName.equalsIgnoreCase("CachedClasses")) {
count++;
}
}
if (count == 0) {
String blobType = DbUtil.getTypeName(Types.BLOB, con);
String nameType = DbUtil.getTypeName(Types.VARCHAR, 1024, con);
String md5Type = DbUtil.getTypeName(Types.BINARY, 16, con);
sql = "CREATE TABLE CachedClasses ( \n" +
" Name " + nameType + " NOT NULL, \n" +
" MD5 " + md5Type + " NOT NULL, \n" +
" Definition " + blobType + " NOT NULL, \n" +
" PRIMARY KEY (Name, MD5) \n" +
")";
DbUtil.update(ds, sql);
con.commit();
}
con.setAutoCommit(true);
} catch (SQLException e) {
DbUtil.rollback(con);
throw e;
} finally {
DbUtil.close(con);
}
}
|
java
|
public static void prepareDataSource(DataSource ds) throws SQLException {
Connection con = null;
String sql;
try {
con = ds.getConnection();
con.setAutoCommit(false);
DatabaseMetaData meta = con.getMetaData();
ResultSet rs = meta.getTables(null, null, null, new String[]{"TABLE"});
int tableNameColumn = rs.findColumn("TABLE_NAME");
int count = 0;
while (rs.next()) {
String tableName = rs.getString(tableNameColumn);
if (tableName.equalsIgnoreCase("CachedClasses")) {
count++;
}
}
if (count == 0) {
String blobType = DbUtil.getTypeName(Types.BLOB, con);
String nameType = DbUtil.getTypeName(Types.VARCHAR, 1024, con);
String md5Type = DbUtil.getTypeName(Types.BINARY, 16, con);
sql = "CREATE TABLE CachedClasses ( \n" +
" Name " + nameType + " NOT NULL, \n" +
" MD5 " + md5Type + " NOT NULL, \n" +
" Definition " + blobType + " NOT NULL, \n" +
" PRIMARY KEY (Name, MD5) \n" +
")";
DbUtil.update(ds, sql);
con.commit();
}
con.setAutoCommit(true);
} catch (SQLException e) {
DbUtil.rollback(con);
throw e;
} finally {
DbUtil.close(con);
}
}
|
[
"public",
"static",
"void",
"prepareDataSource",
"(",
"DataSource",
"ds",
")",
"throws",
"SQLException",
"{",
"Connection",
"con",
"=",
"null",
";",
"String",
"sql",
";",
"try",
"{",
"con",
"=",
"ds",
".",
"getConnection",
"(",
")",
";",
"con",
".",
"setAutoCommit",
"(",
"false",
")",
";",
"DatabaseMetaData",
"meta",
"=",
"con",
".",
"getMetaData",
"(",
")",
";",
"ResultSet",
"rs",
"=",
"meta",
".",
"getTables",
"(",
"null",
",",
"null",
",",
"null",
",",
"new",
"String",
"[",
"]",
"{",
"\"TABLE\"",
"}",
")",
";",
"int",
"tableNameColumn",
"=",
"rs",
".",
"findColumn",
"(",
"\"TABLE_NAME\"",
")",
";",
"int",
"count",
"=",
"0",
";",
"while",
"(",
"rs",
".",
"next",
"(",
")",
")",
"{",
"String",
"tableName",
"=",
"rs",
".",
"getString",
"(",
"tableNameColumn",
")",
";",
"if",
"(",
"tableName",
".",
"equalsIgnoreCase",
"(",
"\"CachedClasses\"",
")",
")",
"{",
"count",
"++",
";",
"}",
"}",
"if",
"(",
"count",
"==",
"0",
")",
"{",
"String",
"blobType",
"=",
"DbUtil",
".",
"getTypeName",
"(",
"Types",
".",
"BLOB",
",",
"con",
")",
";",
"String",
"nameType",
"=",
"DbUtil",
".",
"getTypeName",
"(",
"Types",
".",
"VARCHAR",
",",
"1024",
",",
"con",
")",
";",
"String",
"md5Type",
"=",
"DbUtil",
".",
"getTypeName",
"(",
"Types",
".",
"BINARY",
",",
"16",
",",
"con",
")",
";",
"sql",
"=",
"\"CREATE TABLE CachedClasses ( \\n\"",
"+",
"\" Name \"",
"+",
"nameType",
"+",
"\" NOT NULL, \\n\"",
"+",
"\" MD5 \"",
"+",
"md5Type",
"+",
"\" NOT NULL, \\n\"",
"+",
"\" Definition \"",
"+",
"blobType",
"+",
"\" NOT NULL, \\n\"",
"+",
"\" PRIMARY KEY (Name, MD5) \\n\"",
"+",
"\")\"",
";",
"DbUtil",
".",
"update",
"(",
"ds",
",",
"sql",
")",
";",
"con",
".",
"commit",
"(",
")",
";",
"}",
"con",
".",
"setAutoCommit",
"(",
"true",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"DbUtil",
".",
"rollback",
"(",
"con",
")",
";",
"throw",
"e",
";",
"}",
"finally",
"{",
"DbUtil",
".",
"close",
"(",
"con",
")",
";",
"}",
"}"
] |
Prepares the data source to store cached class definitions.
@param ds The <code>DataSource</code> to prepare.
@throws SQLException If an error occurs while communicating with the
database.
|
[
"Prepares",
"the",
"data",
"source",
"to",
"store",
"cached",
"class",
"definitions",
"."
] |
train
|
https://github.com/bwkimmel/jdcp/blob/630c5150c245054e2556ff370f4bad2ec793dfb7/jdcp-worker/src/main/java/ca/eandb/jdcp/worker/DbCachingJobServiceClassLoaderStrategy.java#L63-L103
|
albfernandez/itext2
|
src/main/java/com/lowagie/text/rtf/RtfWriter2.java
|
RtfWriter2.importRtfFragment
|
public void importRtfFragment(InputStream documentSource, RtfImportMappings mappings, EventListener[] events ) throws IOException, DocumentException {
if(!this.open) {
throw new DocumentException("The document must be open to import RTF fragments.");
}
RtfParser rtfImport = new RtfParser(this.document);
if(events != null) {
for(int idx=0;idx<events.length;idx++) {
rtfImport.addListener(events[idx]);
}
}
rtfImport.importRtfFragment(documentSource, this.rtfDoc, mappings);
}
|
java
|
public void importRtfFragment(InputStream documentSource, RtfImportMappings mappings, EventListener[] events ) throws IOException, DocumentException {
if(!this.open) {
throw new DocumentException("The document must be open to import RTF fragments.");
}
RtfParser rtfImport = new RtfParser(this.document);
if(events != null) {
for(int idx=0;idx<events.length;idx++) {
rtfImport.addListener(events[idx]);
}
}
rtfImport.importRtfFragment(documentSource, this.rtfDoc, mappings);
}
|
[
"public",
"void",
"importRtfFragment",
"(",
"InputStream",
"documentSource",
",",
"RtfImportMappings",
"mappings",
",",
"EventListener",
"[",
"]",
"events",
")",
"throws",
"IOException",
",",
"DocumentException",
"{",
"if",
"(",
"!",
"this",
".",
"open",
")",
"{",
"throw",
"new",
"DocumentException",
"(",
"\"The document must be open to import RTF fragments.\"",
")",
";",
"}",
"RtfParser",
"rtfImport",
"=",
"new",
"RtfParser",
"(",
"this",
".",
"document",
")",
";",
"if",
"(",
"events",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"idx",
"=",
"0",
";",
"idx",
"<",
"events",
".",
"length",
";",
"idx",
"++",
")",
"{",
"rtfImport",
".",
"addListener",
"(",
"events",
"[",
"idx",
"]",
")",
";",
"}",
"}",
"rtfImport",
".",
"importRtfFragment",
"(",
"documentSource",
",",
"this",
".",
"rtfDoc",
",",
"mappings",
")",
";",
"}"
] |
Adds a fragment of an RTF document to the current RTF document being generated.
Since this fragment doesn't contain font or color tables, all fonts and colors
are mapped to the default font and color. If the font and color mappings are
known, they can be specified via the mappings parameter.
Uses new RtfParser object.
(author: Howard Shank)
@param documentSource The InputStream to read the RTF fragment from.
@param mappings The RtfImportMappings that contain font and color mappings to apply to the fragment.
@param events The array of event listeners. May be null
@throws IOException On errors reading the RTF fragment.
@throws DocumentException On errors adding to this RTF fragment.
@see RtfImportMappings
@see RtfParser
@see RtfParser#importRtfFragment(InputStream, RtfDocument, RtfImportMappings)
@since 2.0.8
|
[
"Adds",
"a",
"fragment",
"of",
"an",
"RTF",
"document",
"to",
"the",
"current",
"RTF",
"document",
"being",
"generated",
".",
"Since",
"this",
"fragment",
"doesn",
"t",
"contain",
"font",
"or",
"color",
"tables",
"all",
"fonts",
"and",
"colors",
"are",
"mapped",
"to",
"the",
"default",
"font",
"and",
"color",
".",
"If",
"the",
"font",
"and",
"color",
"mappings",
"are",
"known",
"they",
"can",
"be",
"specified",
"via",
"the",
"mappings",
"parameter",
".",
"Uses",
"new",
"RtfParser",
"object",
"."
] |
train
|
https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/rtf/RtfWriter2.java#L335-L346
|
goldmansachs/reladomo
|
reladomo/src/main/java/com/gs/fw/common/mithra/databasetype/SybaseIqDatabaseType.java
|
SybaseIqDatabaseType.getTableColumnInfo
|
public TableColumnInfo getTableColumnInfo(Connection connection, String schema, String table) throws SQLException
{
if (schema == null || schema.length() == 0 || schema.equals(this.getTempDbSchemaName()))
{
schema = this.getCurrentSchema(connection);
}
return TableColumnInfo.createTableMetadataWithExtraSelect(connection, schema, table, this.getFullyQualifiedTableName(schema, table));
}
|
java
|
public TableColumnInfo getTableColumnInfo(Connection connection, String schema, String table) throws SQLException
{
if (schema == null || schema.length() == 0 || schema.equals(this.getTempDbSchemaName()))
{
schema = this.getCurrentSchema(connection);
}
return TableColumnInfo.createTableMetadataWithExtraSelect(connection, schema, table, this.getFullyQualifiedTableName(schema, table));
}
|
[
"public",
"TableColumnInfo",
"getTableColumnInfo",
"(",
"Connection",
"connection",
",",
"String",
"schema",
",",
"String",
"table",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"schema",
"==",
"null",
"||",
"schema",
".",
"length",
"(",
")",
"==",
"0",
"||",
"schema",
".",
"equals",
"(",
"this",
".",
"getTempDbSchemaName",
"(",
")",
")",
")",
"{",
"schema",
"=",
"this",
".",
"getCurrentSchema",
"(",
"connection",
")",
";",
"}",
"return",
"TableColumnInfo",
".",
"createTableMetadataWithExtraSelect",
"(",
"connection",
",",
"schema",
",",
"table",
",",
"this",
".",
"getFullyQualifiedTableName",
"(",
"schema",
",",
"table",
")",
")",
";",
"}"
] |
<p>Overridden to create the table metadata by hand rather than using the JDBC
<code>DatabaseMetadata.getColumns()</code> method. This is because the Sybase driver fails
when the connection is an XA connection unless you allow transactional DDL in tempdb.</p>
|
[
"<p",
">",
"Overridden",
"to",
"create",
"the",
"table",
"metadata",
"by",
"hand",
"rather",
"than",
"using",
"the",
"JDBC",
"<code",
">",
"DatabaseMetadata",
".",
"getColumns",
"()",
"<",
"/",
"code",
">",
"method",
".",
"This",
"is",
"because",
"the",
"Sybase",
"driver",
"fails",
"when",
"the",
"connection",
"is",
"an",
"XA",
"connection",
"unless",
"you",
"allow",
"transactional",
"DDL",
"in",
"tempdb",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/goldmansachs/reladomo/blob/e9a069452eece7a6ef9551caf81a69d3d9a3d990/reladomo/src/main/java/com/gs/fw/common/mithra/databasetype/SybaseIqDatabaseType.java#L225-L232
|
EdwardRaff/JSAT
|
JSAT/src/jsat/linear/RowColumnOps.java
|
RowColumnOps.divRow
|
public static void divRow(Matrix A, int i, int start, int to, double c)
{
for(int j = start; j < to; j++)
A.set(i, j, A.get(i, j)/c);
}
|
java
|
public static void divRow(Matrix A, int i, int start, int to, double c)
{
for(int j = start; j < to; j++)
A.set(i, j, A.get(i, j)/c);
}
|
[
"public",
"static",
"void",
"divRow",
"(",
"Matrix",
"A",
",",
"int",
"i",
",",
"int",
"start",
",",
"int",
"to",
",",
"double",
"c",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"start",
";",
"j",
"<",
"to",
";",
"j",
"++",
")",
"A",
".",
"set",
"(",
"i",
",",
"j",
",",
".",
"get",
"(",
"i",
",",
"j",
")",
"/",
")",
";",
"}"
] |
Updates the values of row <tt>i</tt> in the given matrix to be A[i,:] = A[i,:] / c
@param A the matrix to perform he update on
@param i the row to update
@param start the first index of the row to update from (inclusive)
@param to the last index of the row to update (exclusive)
@param c the constant to divide each element by
|
[
"Updates",
"the",
"values",
"of",
"row",
"<tt",
">",
"i<",
"/",
"tt",
">",
"in",
"the",
"given",
"matrix",
"to",
"be",
"A",
"[",
"i",
":",
"]",
"=",
"A",
"[",
"i",
":",
"]",
"/",
"c"
] |
train
|
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/linear/RowColumnOps.java#L150-L154
|
lawloretienne/ImageGallery
|
library/src/main/java/com/etiennelawlor/imagegallery/library/ui/TouchImageView.java
|
TouchImageView.translateMatrixAfterRotate
|
private void translateMatrixAfterRotate(int axis, float trans, float prevImageSize, float imageSize, int prevViewSize, int viewSize, int drawableSize) {
if (imageSize < viewSize) {
//
// The width/height of image is less than the view's width/height. Center it.
//
m[axis] = (viewSize - (drawableSize * m[Matrix.MSCALE_X])) * 0.5f;
} else if (trans > 0) {
//
// The image is larger than the view, but was not before rotation. Center it.
//
m[axis] = -((imageSize - viewSize) * 0.5f);
} else {
//
// Find the area of the image which was previously centered in the view. Determine its distance
// from the left/top side of the view as a fraction of the entire image's width/height. Use that percentage
// to calculate the trans in the new view width/height.
//
float percentage = (Math.abs(trans) + (0.5f * prevViewSize)) / prevImageSize;
m[axis] = -((percentage * imageSize) - (viewSize * 0.5f));
}
}
|
java
|
private void translateMatrixAfterRotate(int axis, float trans, float prevImageSize, float imageSize, int prevViewSize, int viewSize, int drawableSize) {
if (imageSize < viewSize) {
//
// The width/height of image is less than the view's width/height. Center it.
//
m[axis] = (viewSize - (drawableSize * m[Matrix.MSCALE_X])) * 0.5f;
} else if (trans > 0) {
//
// The image is larger than the view, but was not before rotation. Center it.
//
m[axis] = -((imageSize - viewSize) * 0.5f);
} else {
//
// Find the area of the image which was previously centered in the view. Determine its distance
// from the left/top side of the view as a fraction of the entire image's width/height. Use that percentage
// to calculate the trans in the new view width/height.
//
float percentage = (Math.abs(trans) + (0.5f * prevViewSize)) / prevImageSize;
m[axis] = -((percentage * imageSize) - (viewSize * 0.5f));
}
}
|
[
"private",
"void",
"translateMatrixAfterRotate",
"(",
"int",
"axis",
",",
"float",
"trans",
",",
"float",
"prevImageSize",
",",
"float",
"imageSize",
",",
"int",
"prevViewSize",
",",
"int",
"viewSize",
",",
"int",
"drawableSize",
")",
"{",
"if",
"(",
"imageSize",
"<",
"viewSize",
")",
"{",
"//",
"// The width/height of image is less than the view's width/height. Center it.",
"//",
"m",
"[",
"axis",
"]",
"=",
"(",
"viewSize",
"-",
"(",
"drawableSize",
"*",
"m",
"[",
"Matrix",
".",
"MSCALE_X",
"]",
")",
")",
"*",
"0.5f",
";",
"}",
"else",
"if",
"(",
"trans",
">",
"0",
")",
"{",
"//",
"// The image is larger than the view, but was not before rotation. Center it.",
"//",
"m",
"[",
"axis",
"]",
"=",
"-",
"(",
"(",
"imageSize",
"-",
"viewSize",
")",
"*",
"0.5f",
")",
";",
"}",
"else",
"{",
"//",
"// Find the area of the image which was previously centered in the view. Determine its distance",
"// from the left/top side of the view as a fraction of the entire image's width/height. Use that percentage",
"// to calculate the trans in the new view width/height.",
"//",
"float",
"percentage",
"=",
"(",
"Math",
".",
"abs",
"(",
"trans",
")",
"+",
"(",
"0.5f",
"*",
"prevViewSize",
")",
")",
"/",
"prevImageSize",
";",
"m",
"[",
"axis",
"]",
"=",
"-",
"(",
"(",
"percentage",
"*",
"imageSize",
")",
"-",
"(",
"viewSize",
"*",
"0.5f",
")",
")",
";",
"}",
"}"
] |
After rotating, the matrix needs to be translated. This function finds the area of image
which was previously centered and adjusts translations so that is again the center, post-rotation.
@param axis Matrix.MTRANS_X or Matrix.MTRANS_Y
@param trans the value of trans in that axis before the rotation
@param prevImageSize the width/height of the image before the rotation
@param imageSize width/height of the image after rotation
@param prevViewSize width/height of view before rotation
@param viewSize width/height of view after rotation
@param drawableSize width/height of drawable
|
[
"After",
"rotating",
"the",
"matrix",
"needs",
"to",
"be",
"translated",
".",
"This",
"function",
"finds",
"the",
"area",
"of",
"image",
"which",
"was",
"previously",
"centered",
"and",
"adjusts",
"translations",
"so",
"that",
"is",
"again",
"the",
"center",
"post",
"-",
"rotation",
"."
] |
train
|
https://github.com/lawloretienne/ImageGallery/blob/960d68dfb2b81d05322a576723ac4f090e10eda7/library/src/main/java/com/etiennelawlor/imagegallery/library/ui/TouchImageView.java#L710-L732
|
Azure/azure-sdk-for-java
|
sql/resource-manager/v2017_10_01_preview/src/main/java/com/microsoft/azure/management/sql/v2017_10_01_preview/implementation/InstanceFailoverGroupsInner.java
|
InstanceFailoverGroupsInner.listByLocationAsync
|
public Observable<Page<InstanceFailoverGroupInner>> listByLocationAsync(final String resourceGroupName, final String locationName) {
return listByLocationWithServiceResponseAsync(resourceGroupName, locationName)
.map(new Func1<ServiceResponse<Page<InstanceFailoverGroupInner>>, Page<InstanceFailoverGroupInner>>() {
@Override
public Page<InstanceFailoverGroupInner> call(ServiceResponse<Page<InstanceFailoverGroupInner>> response) {
return response.body();
}
});
}
|
java
|
public Observable<Page<InstanceFailoverGroupInner>> listByLocationAsync(final String resourceGroupName, final String locationName) {
return listByLocationWithServiceResponseAsync(resourceGroupName, locationName)
.map(new Func1<ServiceResponse<Page<InstanceFailoverGroupInner>>, Page<InstanceFailoverGroupInner>>() {
@Override
public Page<InstanceFailoverGroupInner> call(ServiceResponse<Page<InstanceFailoverGroupInner>> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"Page",
"<",
"InstanceFailoverGroupInner",
">",
">",
"listByLocationAsync",
"(",
"final",
"String",
"resourceGroupName",
",",
"final",
"String",
"locationName",
")",
"{",
"return",
"listByLocationWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"locationName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"InstanceFailoverGroupInner",
">",
">",
",",
"Page",
"<",
"InstanceFailoverGroupInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Page",
"<",
"InstanceFailoverGroupInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"Page",
"<",
"InstanceFailoverGroupInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Lists the failover groups in a location.
@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 locationName The name of the region where the resource is located.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<InstanceFailoverGroupInner> object
|
[
"Lists",
"the",
"failover",
"groups",
"in",
"a",
"location",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2017_10_01_preview/src/main/java/com/microsoft/azure/management/sql/v2017_10_01_preview/implementation/InstanceFailoverGroupsInner.java#L609-L617
|
airomem/airomem
|
airomem-core/src/main/java/pl/setblack/airomem/core/impl/PersistenceControllerImpl.java
|
PersistenceControllerImpl.executeAndQuery
|
@Override
public <R> R executeAndQuery(Command<ROOT, R> cmd) {
return this.executeAndQuery((ContextCommand<ROOT, R>) cmd);
}
|
java
|
@Override
public <R> R executeAndQuery(Command<ROOT, R> cmd) {
return this.executeAndQuery((ContextCommand<ROOT, R>) cmd);
}
|
[
"@",
"Override",
"public",
"<",
"R",
">",
"R",
"executeAndQuery",
"(",
"Command",
"<",
"ROOT",
",",
"R",
">",
"cmd",
")",
"{",
"return",
"this",
".",
"executeAndQuery",
"(",
"(",
"ContextCommand",
"<",
"ROOT",
",",
"R",
">",
")",
"cmd",
")",
";",
"}"
] |
Perform command on system.
<p>
Inside command can be any code doing any changes. Such changes are
guaranteed to be preserved (if only command ended without exception).
@param cmd
|
[
"Perform",
"command",
"on",
"system",
".",
"<p",
">",
"Inside",
"command",
"can",
"be",
"any",
"code",
"doing",
"any",
"changes",
".",
"Such",
"changes",
"are",
"guaranteed",
"to",
"be",
"preserved",
"(",
"if",
"only",
"command",
"ended",
"without",
"exception",
")",
"."
] |
train
|
https://github.com/airomem/airomem/blob/281ce18ff64836fccfb0edab18b8d677f1101a32/airomem-core/src/main/java/pl/setblack/airomem/core/impl/PersistenceControllerImpl.java#L108-L111
|
spotbugs/spotbugs
|
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/SignatureParser.java
|
SignatureParser.getNumParametersForInvocation
|
public static int getNumParametersForInvocation(InvokeInstruction inv, ConstantPoolGen cpg) {
SignatureParser sigParser = new SignatureParser(inv.getSignature(cpg));
return sigParser.getNumParameters();
}
|
java
|
public static int getNumParametersForInvocation(InvokeInstruction inv, ConstantPoolGen cpg) {
SignatureParser sigParser = new SignatureParser(inv.getSignature(cpg));
return sigParser.getNumParameters();
}
|
[
"public",
"static",
"int",
"getNumParametersForInvocation",
"(",
"InvokeInstruction",
"inv",
",",
"ConstantPoolGen",
"cpg",
")",
"{",
"SignatureParser",
"sigParser",
"=",
"new",
"SignatureParser",
"(",
"inv",
".",
"getSignature",
"(",
"cpg",
")",
")",
";",
"return",
"sigParser",
".",
"getNumParameters",
"(",
")",
";",
"}"
] |
Get the number of parameters passed to method invocation.
@param inv
@param cpg
@return int number of parameters
|
[
"Get",
"the",
"number",
"of",
"parameters",
"passed",
"to",
"method",
"invocation",
"."
] |
train
|
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/SignatureParser.java#L249-L252
|
reactor/reactor-netty
|
src/main/java/reactor/netty/http/client/HttpClient.java
|
HttpClient.doOnResponse
|
public final HttpClient doOnResponse(BiConsumer<? super HttpClientResponse, ? super Connection> doOnResponse) {
Objects.requireNonNull(doOnResponse, "doOnResponse");
return new HttpClientDoOn(this, null, null, doOnResponse, null);
}
|
java
|
public final HttpClient doOnResponse(BiConsumer<? super HttpClientResponse, ? super Connection> doOnResponse) {
Objects.requireNonNull(doOnResponse, "doOnResponse");
return new HttpClientDoOn(this, null, null, doOnResponse, null);
}
|
[
"public",
"final",
"HttpClient",
"doOnResponse",
"(",
"BiConsumer",
"<",
"?",
"super",
"HttpClientResponse",
",",
"?",
"super",
"Connection",
">",
"doOnResponse",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"doOnResponse",
",",
"\"doOnResponse\"",
")",
";",
"return",
"new",
"HttpClientDoOn",
"(",
"this",
",",
"null",
",",
"null",
",",
"doOnResponse",
",",
"null",
")",
";",
"}"
] |
Setup a callback called after {@link HttpClientResponse} headers have been
received
@param doOnResponse a consumer observing connected events
@return a new {@link HttpClient}
|
[
"Setup",
"a",
"callback",
"called",
"after",
"{",
"@link",
"HttpClientResponse",
"}",
"headers",
"have",
"been",
"received"
] |
train
|
https://github.com/reactor/reactor-netty/blob/4ed14316e1d7fca3cecd18d6caa5f2251e159e49/src/main/java/reactor/netty/http/client/HttpClient.java#L556-L559
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java
|
ApiOvhTelephony.billingAccount_service_serviceName_faxConsumption_consumptionId_GET
|
public OvhFaxConsumption billingAccount_service_serviceName_faxConsumption_consumptionId_GET(String billingAccount, String serviceName, Long consumptionId) throws IOException {
String qPath = "/telephony/{billingAccount}/service/{serviceName}/faxConsumption/{consumptionId}";
StringBuilder sb = path(qPath, billingAccount, serviceName, consumptionId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhFaxConsumption.class);
}
|
java
|
public OvhFaxConsumption billingAccount_service_serviceName_faxConsumption_consumptionId_GET(String billingAccount, String serviceName, Long consumptionId) throws IOException {
String qPath = "/telephony/{billingAccount}/service/{serviceName}/faxConsumption/{consumptionId}";
StringBuilder sb = path(qPath, billingAccount, serviceName, consumptionId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhFaxConsumption.class);
}
|
[
"public",
"OvhFaxConsumption",
"billingAccount_service_serviceName_faxConsumption_consumptionId_GET",
"(",
"String",
"billingAccount",
",",
"String",
"serviceName",
",",
"Long",
"consumptionId",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/telephony/{billingAccount}/service/{serviceName}/faxConsumption/{consumptionId}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"billingAccount",
",",
"serviceName",
",",
"consumptionId",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhFaxConsumption",
".",
"class",
")",
";",
"}"
] |
Get this object properties
REST: GET /telephony/{billingAccount}/service/{serviceName}/faxConsumption/{consumptionId}
@param billingAccount [required] The name of your billingAccount
@param serviceName [required]
@param consumptionId [required]
|
[
"Get",
"this",
"object",
"properties"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L4053-L4058
|
calimero-project/calimero-core
|
src/tuwien/auto/calimero/knxnetip/ConnectionBase.java
|
ConnectionBase.fireFrameReceived
|
protected void fireFrameReceived(final CEMI frame)
{
final FrameEvent fe = new FrameEvent(this, frame);
listeners.fire(l -> l.frameReceived(fe));
}
|
java
|
protected void fireFrameReceived(final CEMI frame)
{
final FrameEvent fe = new FrameEvent(this, frame);
listeners.fire(l -> l.frameReceived(fe));
}
|
[
"protected",
"void",
"fireFrameReceived",
"(",
"final",
"CEMI",
"frame",
")",
"{",
"final",
"FrameEvent",
"fe",
"=",
"new",
"FrameEvent",
"(",
"this",
",",
"frame",
")",
";",
"listeners",
".",
"fire",
"(",
"l",
"->",
"l",
".",
"frameReceived",
"(",
"fe",
")",
")",
";",
"}"
] |
Fires a frame received event ({@link KNXListener#frameReceived(FrameEvent)}) for the supplied cEMI
<code>frame</code>.
@param frame the cEMI to generate the event for
|
[
"Fires",
"a",
"frame",
"received",
"event",
"(",
"{",
"@link",
"KNXListener#frameReceived",
"(",
"FrameEvent",
")",
"}",
")",
"for",
"the",
"supplied",
"cEMI",
"<code",
">",
"frame<",
"/",
"code",
">",
"."
] |
train
|
https://github.com/calimero-project/calimero-core/blob/7e6f547c6bd75fa985bfeb5b47ba671df2ea01e8/src/tuwien/auto/calimero/knxnetip/ConnectionBase.java#L355-L359
|
payneteasy/superfly
|
superfly-service/src/main/java/com/payneteasy/superfly/spring/velocity/VelocityEngineFactory.java
|
VelocityEngineFactory.initSpringResourceLoader
|
protected void initSpringResourceLoader(VelocityEngine velocityEngine, String resourceLoaderPath) {
velocityEngine.setProperty(
RuntimeConstants.RESOURCE_LOADER, SpringResourceLoader.NAME);
velocityEngine.setProperty(
SpringResourceLoader.SPRING_RESOURCE_LOADER_CLASS, SpringResourceLoader.class.getName());
velocityEngine.setProperty(
SpringResourceLoader.SPRING_RESOURCE_LOADER_CACHE, "true");
velocityEngine.setApplicationAttribute(
SpringResourceLoader.SPRING_RESOURCE_LOADER, getResourceLoader());
velocityEngine.setApplicationAttribute(
SpringResourceLoader.SPRING_RESOURCE_LOADER_PATH, resourceLoaderPath);
}
|
java
|
protected void initSpringResourceLoader(VelocityEngine velocityEngine, String resourceLoaderPath) {
velocityEngine.setProperty(
RuntimeConstants.RESOURCE_LOADER, SpringResourceLoader.NAME);
velocityEngine.setProperty(
SpringResourceLoader.SPRING_RESOURCE_LOADER_CLASS, SpringResourceLoader.class.getName());
velocityEngine.setProperty(
SpringResourceLoader.SPRING_RESOURCE_LOADER_CACHE, "true");
velocityEngine.setApplicationAttribute(
SpringResourceLoader.SPRING_RESOURCE_LOADER, getResourceLoader());
velocityEngine.setApplicationAttribute(
SpringResourceLoader.SPRING_RESOURCE_LOADER_PATH, resourceLoaderPath);
}
|
[
"protected",
"void",
"initSpringResourceLoader",
"(",
"VelocityEngine",
"velocityEngine",
",",
"String",
"resourceLoaderPath",
")",
"{",
"velocityEngine",
".",
"setProperty",
"(",
"RuntimeConstants",
".",
"RESOURCE_LOADER",
",",
"SpringResourceLoader",
".",
"NAME",
")",
";",
"velocityEngine",
".",
"setProperty",
"(",
"SpringResourceLoader",
".",
"SPRING_RESOURCE_LOADER_CLASS",
",",
"SpringResourceLoader",
".",
"class",
".",
"getName",
"(",
")",
")",
";",
"velocityEngine",
".",
"setProperty",
"(",
"SpringResourceLoader",
".",
"SPRING_RESOURCE_LOADER_CACHE",
",",
"\"true\"",
")",
";",
"velocityEngine",
".",
"setApplicationAttribute",
"(",
"SpringResourceLoader",
".",
"SPRING_RESOURCE_LOADER",
",",
"getResourceLoader",
"(",
")",
")",
";",
"velocityEngine",
".",
"setApplicationAttribute",
"(",
"SpringResourceLoader",
".",
"SPRING_RESOURCE_LOADER_PATH",
",",
"resourceLoaderPath",
")",
";",
"}"
] |
Initialize a SpringResourceLoader for the given VelocityEngine.
<p>Called by {@code initVelocityResourceLoader}.
@param velocityEngine the VelocityEngine to configure
@param resourceLoaderPath the path to load Velocity resources from
@see SpringResourceLoader
@see #initVelocityResourceLoader
|
[
"Initialize",
"a",
"SpringResourceLoader",
"for",
"the",
"given",
"VelocityEngine",
".",
"<p",
">",
"Called",
"by",
"{"
] |
train
|
https://github.com/payneteasy/superfly/blob/4cad6d0f8e951a61f3c302c49b13a51d179076f8/superfly-service/src/main/java/com/payneteasy/superfly/spring/velocity/VelocityEngineFactory.java#L329-L340
|
khuxtable/seaglass
|
src/main/java/com/seaglasslookandfeel/ui/SeaGlassRootPaneUI.java
|
SeaGlassRootPaneUI.installBorder
|
public void installBorder(JRootPane root) {
int style = root.getWindowDecorationStyle();
if (style == JRootPane.NONE) {
LookAndFeel.uninstallBorder(root);
} else {
root.setBorder(new SeaGlassBorder(this, new Insets(0, 1, 1, 1)));
}
}
|
java
|
public void installBorder(JRootPane root) {
int style = root.getWindowDecorationStyle();
if (style == JRootPane.NONE) {
LookAndFeel.uninstallBorder(root);
} else {
root.setBorder(new SeaGlassBorder(this, new Insets(0, 1, 1, 1)));
}
}
|
[
"public",
"void",
"installBorder",
"(",
"JRootPane",
"root",
")",
"{",
"int",
"style",
"=",
"root",
".",
"getWindowDecorationStyle",
"(",
")",
";",
"if",
"(",
"style",
"==",
"JRootPane",
".",
"NONE",
")",
"{",
"LookAndFeel",
".",
"uninstallBorder",
"(",
"root",
")",
";",
"}",
"else",
"{",
"root",
".",
"setBorder",
"(",
"new",
"SeaGlassBorder",
"(",
"this",
",",
"new",
"Insets",
"(",
"0",
",",
"1",
",",
"1",
",",
"1",
")",
")",
")",
";",
"}",
"}"
] |
Installs the appropriate <code>Border</code> onto the <code>
JRootPane</code>.
@param root the root pane.
|
[
"Installs",
"the",
"appropriate",
"<code",
">",
"Border<",
"/",
"code",
">",
"onto",
"the",
"<code",
">",
"JRootPane<",
"/",
"code",
">",
"."
] |
train
|
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/ui/SeaGlassRootPaneUI.java#L318-L326
|
Azure/azure-sdk-for-java
|
eventgrid/resource-manager/v2018_05_01_preview/src/main/java/com/microsoft/azure/management/eventgrid/v2018_05_01_preview/implementation/EventSubscriptionsInner.java
|
EventSubscriptionsInner.beginCreateOrUpdate
|
public EventSubscriptionInner beginCreateOrUpdate(String scope, String eventSubscriptionName, EventSubscriptionInner eventSubscriptionInfo) {
return beginCreateOrUpdateWithServiceResponseAsync(scope, eventSubscriptionName, eventSubscriptionInfo).toBlocking().single().body();
}
|
java
|
public EventSubscriptionInner beginCreateOrUpdate(String scope, String eventSubscriptionName, EventSubscriptionInner eventSubscriptionInfo) {
return beginCreateOrUpdateWithServiceResponseAsync(scope, eventSubscriptionName, eventSubscriptionInfo).toBlocking().single().body();
}
|
[
"public",
"EventSubscriptionInner",
"beginCreateOrUpdate",
"(",
"String",
"scope",
",",
"String",
"eventSubscriptionName",
",",
"EventSubscriptionInner",
"eventSubscriptionInfo",
")",
"{",
"return",
"beginCreateOrUpdateWithServiceResponseAsync",
"(",
"scope",
",",
"eventSubscriptionName",
",",
"eventSubscriptionInfo",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] |
Create or update an event subscription.
Asynchronously creates a new event subscription or updates an existing event subscription based on the specified scope.
@param scope The identifier of the resource to which the event subscription needs to be created or updated. The scope can be a subscription, or a resource group, or a top level resource belonging to a resource provider namespace, or an EventGrid topic. For example, use '/subscriptions/{subscriptionId}/' for a subscription, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a resource group, and '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' for a resource, and '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' for an EventGrid topic.
@param eventSubscriptionName Name of the event subscription. Event subscription names must be between 3 and 64 characters in length and should use alphanumeric letters only.
@param eventSubscriptionInfo Event subscription properties containing the destination and filter information
@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 EventSubscriptionInner object if successful.
|
[
"Create",
"or",
"update",
"an",
"event",
"subscription",
".",
"Asynchronously",
"creates",
"a",
"new",
"event",
"subscription",
"or",
"updates",
"an",
"existing",
"event",
"subscription",
"based",
"on",
"the",
"specified",
"scope",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/eventgrid/resource-manager/v2018_05_01_preview/src/main/java/com/microsoft/azure/management/eventgrid/v2018_05_01_preview/implementation/EventSubscriptionsInner.java#L313-L315
|
google/j2objc
|
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/dtm/ref/DTMDefaultBase.java
|
DTMDefaultBase.getExpandedTypeID
|
public int getExpandedTypeID(String namespace, String localName, int type)
{
ExpandedNameTable ent = m_expandedNameTable;
return ent.getExpandedTypeID(namespace, localName, type);
}
|
java
|
public int getExpandedTypeID(String namespace, String localName, int type)
{
ExpandedNameTable ent = m_expandedNameTable;
return ent.getExpandedTypeID(namespace, localName, type);
}
|
[
"public",
"int",
"getExpandedTypeID",
"(",
"String",
"namespace",
",",
"String",
"localName",
",",
"int",
"type",
")",
"{",
"ExpandedNameTable",
"ent",
"=",
"m_expandedNameTable",
";",
"return",
"ent",
".",
"getExpandedTypeID",
"(",
"namespace",
",",
"localName",
",",
"type",
")",
";",
"}"
] |
Given an expanded name, return an ID. If the expanded-name does not
exist in the internal tables, the entry will be created, and the ID will
be returned. Any additional nodes that are created that have this
expanded name will use this ID.
@param type The simple type, i.e. one of ELEMENT, ATTRIBUTE, etc.
@param namespace The namespace URI, which may be null, may be an empty
string (which will be the same as null), or may be a
namespace URI.
@param localName The local name string, which must be a valid
<a href="http://www.w3.org/TR/REC-xml-names/">NCName</a>.
@return the expanded-name id of the node.
|
[
"Given",
"an",
"expanded",
"name",
"return",
"an",
"ID",
".",
"If",
"the",
"expanded",
"-",
"name",
"does",
"not",
"exist",
"in",
"the",
"internal",
"tables",
"the",
"entry",
"will",
"be",
"created",
"and",
"the",
"ID",
"will",
"be",
"returned",
".",
"Any",
"additional",
"nodes",
"that",
"are",
"created",
"that",
"have",
"this",
"expanded",
"name",
"will",
"use",
"this",
"ID",
"."
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/dtm/ref/DTMDefaultBase.java#L1704-L1710
|
pebble/pebble-android-sdk
|
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java
|
PebbleKit.registerReceivedAckHandler
|
public static BroadcastReceiver registerReceivedAckHandler(final Context context,
final PebbleAckReceiver receiver) {
return registerBroadcastReceiverInternal(context, INTENT_APP_RECEIVE_ACK, receiver);
}
|
java
|
public static BroadcastReceiver registerReceivedAckHandler(final Context context,
final PebbleAckReceiver receiver) {
return registerBroadcastReceiverInternal(context, INTENT_APP_RECEIVE_ACK, receiver);
}
|
[
"public",
"static",
"BroadcastReceiver",
"registerReceivedAckHandler",
"(",
"final",
"Context",
"context",
",",
"final",
"PebbleAckReceiver",
"receiver",
")",
"{",
"return",
"registerBroadcastReceiverInternal",
"(",
"context",
",",
"INTENT_APP_RECEIVE_ACK",
",",
"receiver",
")",
";",
"}"
] |
A convenience function to assist in programatically registering a broadcast receiver for the 'RECEIVE_ACK'
intent.
To avoid leaking memory, activities registering BroadcastReceivers <em>must</em> unregister them in the
Activity's {@link android.app.Activity#onPause()} method.
@param context
The context in which to register the BroadcastReceiver.
@param receiver
The receiver to be registered.
@return The registered receiver.
@see Constants#INTENT_APP_RECEIVE_ACK
|
[
"A",
"convenience",
"function",
"to",
"assist",
"in",
"programatically",
"registering",
"a",
"broadcast",
"receiver",
"for",
"the",
"RECEIVE_ACK",
"intent",
"."
] |
train
|
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java#L448-L451
|
MariaDB/mariadb-connector-j
|
src/main/java/org/mariadb/jdbc/MariaDbPooledConnection.java
|
MariaDbPooledConnection.fireConnectionErrorOccured
|
public void fireConnectionErrorOccured(SQLException ex) {
ConnectionEvent event = new ConnectionEvent(this, ex);
for (ConnectionEventListener listener : connectionEventListeners) {
listener.connectionErrorOccurred(event);
}
}
|
java
|
public void fireConnectionErrorOccured(SQLException ex) {
ConnectionEvent event = new ConnectionEvent(this, ex);
for (ConnectionEventListener listener : connectionEventListeners) {
listener.connectionErrorOccurred(event);
}
}
|
[
"public",
"void",
"fireConnectionErrorOccured",
"(",
"SQLException",
"ex",
")",
"{",
"ConnectionEvent",
"event",
"=",
"new",
"ConnectionEvent",
"(",
"this",
",",
"ex",
")",
";",
"for",
"(",
"ConnectionEventListener",
"listener",
":",
"connectionEventListeners",
")",
"{",
"listener",
".",
"connectionErrorOccurred",
"(",
"event",
")",
";",
"}",
"}"
] |
Fire connection error to listening listeners.
@param ex exception
|
[
"Fire",
"connection",
"error",
"to",
"listening",
"listeners",
"."
] |
train
|
https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/MariaDbPooledConnection.java#L228-L233
|
cybazeitalia/emaze-dysfunctional
|
src/main/java/net/emaze/dysfunctional/Spies.java
|
Spies.spyRes
|
public static <T1, T2, R> BiFunction<T1, T2, R> spyRes(BiFunction<T1, T2, R> function, Box<R> result) {
return spy(function, result, Box.<T1>empty(), Box.<T2>empty());
}
|
java
|
public static <T1, T2, R> BiFunction<T1, T2, R> spyRes(BiFunction<T1, T2, R> function, Box<R> result) {
return spy(function, result, Box.<T1>empty(), Box.<T2>empty());
}
|
[
"public",
"static",
"<",
"T1",
",",
"T2",
",",
"R",
">",
"BiFunction",
"<",
"T1",
",",
"T2",
",",
"R",
">",
"spyRes",
"(",
"BiFunction",
"<",
"T1",
",",
"T2",
",",
"R",
">",
"function",
",",
"Box",
"<",
"R",
">",
"result",
")",
"{",
"return",
"spy",
"(",
"function",
",",
"result",
",",
"Box",
".",
"<",
"T1",
">",
"empty",
"(",
")",
",",
"Box",
".",
"<",
"T2",
">",
"empty",
"(",
")",
")",
";",
"}"
] |
Proxies a binary function spying for result.
@param <T1> the function first parameter type
@param <T2> the function second parameter type
@param <R> the function result type
@param function the function that will be spied
@param result a box that will be containing spied result
@return the proxied function
|
[
"Proxies",
"a",
"binary",
"function",
"spying",
"for",
"result",
"."
] |
train
|
https://github.com/cybazeitalia/emaze-dysfunctional/blob/98115a436e35335c5e8831f9fdc12f6d93d524be/src/main/java/net/emaze/dysfunctional/Spies.java#L253-L255
|
looly/hutool
|
hutool-crypto/src/main/java/cn/hutool/crypto/SecureUtil.java
|
SecureUtil.generateKeyPair
|
public static KeyPair generateKeyPair(String algorithm, int keySize, byte[] seed) {
return KeyUtil.generateKeyPair(algorithm, keySize, seed);
}
|
java
|
public static KeyPair generateKeyPair(String algorithm, int keySize, byte[] seed) {
return KeyUtil.generateKeyPair(algorithm, keySize, seed);
}
|
[
"public",
"static",
"KeyPair",
"generateKeyPair",
"(",
"String",
"algorithm",
",",
"int",
"keySize",
",",
"byte",
"[",
"]",
"seed",
")",
"{",
"return",
"KeyUtil",
".",
"generateKeyPair",
"(",
"algorithm",
",",
"keySize",
",",
"seed",
")",
";",
"}"
] |
生成用于非对称加密的公钥和私钥<br>
密钥对生成算法见:https://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#KeyPairGenerator
@param algorithm 非对称加密算法
@param keySize 密钥模(modulus )长度
@param seed 种子
@return {@link KeyPair}
|
[
"生成用于非对称加密的公钥和私钥<br",
">",
"密钥对生成算法见:https",
":",
"//",
"docs",
".",
"oracle",
".",
"com",
"/",
"javase",
"/",
"7",
"/",
"docs",
"/",
"technotes",
"/",
"guides",
"/",
"security",
"/",
"StandardNames",
".",
"html#KeyPairGenerator"
] |
train
|
https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-crypto/src/main/java/cn/hutool/crypto/SecureUtil.java#L227-L229
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/format/DateTimeFormatter.java
|
DateTimeFormatter.printTo
|
public void printTo(Writer out, ReadableInstant instant) throws IOException {
printTo((Appendable) out, instant);
}
|
java
|
public void printTo(Writer out, ReadableInstant instant) throws IOException {
printTo((Appendable) out, instant);
}
|
[
"public",
"void",
"printTo",
"(",
"Writer",
"out",
",",
"ReadableInstant",
"instant",
")",
"throws",
"IOException",
"{",
"printTo",
"(",
"(",
"Appendable",
")",
"out",
",",
"instant",
")",
";",
"}"
] |
Prints a ReadableInstant, using the chronology supplied by the instant.
@param out the destination to format to, not null
@param instant instant to format, null means now
|
[
"Prints",
"a",
"ReadableInstant",
"using",
"the",
"chronology",
"supplied",
"by",
"the",
"instant",
"."
] |
train
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/format/DateTimeFormatter.java#L521-L523
|
allengeorge/libraft
|
libraft-agent/src/main/java/io/libraft/agent/RaftAgent.java
|
RaftAgent.setupCustomCommandSerializationAndDeserialization
|
public synchronized void setupCustomCommandSerializationAndDeserialization(CommandSerializer commandSerializer, CommandDeserializer commandDeserializer) {
checkState(!running);
checkState(!initialized);
checkState(!setupConversion);
jdbcLog.setupCustomCommandSerializerAndDeserializer(commandSerializer, commandDeserializer);
RaftRPC.setupCustomCommandSerializationAndDeserialization(mapper, commandSerializer, commandDeserializer);
setupConversion = true;
}
|
java
|
public synchronized void setupCustomCommandSerializationAndDeserialization(CommandSerializer commandSerializer, CommandDeserializer commandDeserializer) {
checkState(!running);
checkState(!initialized);
checkState(!setupConversion);
jdbcLog.setupCustomCommandSerializerAndDeserializer(commandSerializer, commandDeserializer);
RaftRPC.setupCustomCommandSerializationAndDeserialization(mapper, commandSerializer, commandDeserializer);
setupConversion = true;
}
|
[
"public",
"synchronized",
"void",
"setupCustomCommandSerializationAndDeserialization",
"(",
"CommandSerializer",
"commandSerializer",
",",
"CommandDeserializer",
"commandDeserializer",
")",
"{",
"checkState",
"(",
"!",
"running",
")",
";",
"checkState",
"(",
"!",
"initialized",
")",
";",
"checkState",
"(",
"!",
"setupConversion",
")",
";",
"jdbcLog",
".",
"setupCustomCommandSerializerAndDeserializer",
"(",
"commandSerializer",
",",
"commandDeserializer",
")",
";",
"RaftRPC",
".",
"setupCustomCommandSerializationAndDeserialization",
"(",
"mapper",
",",
"commandSerializer",
",",
"commandDeserializer",
")",
";",
"setupConversion",
"=",
"true",
";",
"}"
] |
Setup custom serialization and deserialization for POJO {@link Command} objects.
This method should <strong>only</strong> be called once.
@param commandSerializer {@code CommandSerializer} that can serialize a POJO {@code Command} into binary
@param commandDeserializer {@code CommandDeserializer} that can deserialize binary into a {@code Command} POJO
@throws IllegalStateException if this method is called multiple times
@see RaftRPC#setupCustomCommandSerializationAndDeserialization(ObjectMapper, CommandSerializer, CommandDeserializer)
|
[
"Setup",
"custom",
"serialization",
"and",
"deserialization",
"for",
"POJO",
"{",
"@link",
"Command",
"}",
"objects",
".",
"This",
"method",
"should",
"<strong",
">",
"only<",
"/",
"strong",
">",
"be",
"called",
"once",
"."
] |
train
|
https://github.com/allengeorge/libraft/blob/00d68bb5e68d4020af59df3c8a9a14380108ac89/libraft-agent/src/main/java/io/libraft/agent/RaftAgent.java#L315-L324
|
JOML-CI/JOML
|
src/org/joml/Matrix4d.java
|
Matrix4d.perspectiveLH
|
public Matrix4d perspectiveLH(double fovy, double aspect, double zNear, double zFar, boolean zZeroToOne) {
return perspectiveLH(fovy, aspect, zNear, zFar, zZeroToOne, this);
}
|
java
|
public Matrix4d perspectiveLH(double fovy, double aspect, double zNear, double zFar, boolean zZeroToOne) {
return perspectiveLH(fovy, aspect, zNear, zFar, zZeroToOne, this);
}
|
[
"public",
"Matrix4d",
"perspectiveLH",
"(",
"double",
"fovy",
",",
"double",
"aspect",
",",
"double",
"zNear",
",",
"double",
"zFar",
",",
"boolean",
"zZeroToOne",
")",
"{",
"return",
"perspectiveLH",
"(",
"fovy",
",",
"aspect",
",",
"zNear",
",",
"zFar",
",",
"zZeroToOne",
",",
"this",
")",
";",
"}"
] |
Apply a symmetric perspective projection frustum transformation for a left-handed coordinate system
using the given NDC z range to this matrix.
<p>
If <code>M</code> is <code>this</code> matrix and <code>P</code> the perspective projection matrix,
then the new matrix will be <code>M * P</code>. So when transforming a
vector <code>v</code> with the new matrix by using <code>M * P * v</code>,
the perspective projection will be applied first!
<p>
In order to set the matrix to a perspective frustum transformation without post-multiplying,
use {@link #setPerspectiveLH(double, double, double, double, boolean) setPerspectiveLH}.
@see #setPerspectiveLH(double, double, double, double, boolean)
@param fovy
the vertical field of view in radians (must be greater than zero and less than {@link Math#PI PI})
@param aspect
the aspect ratio (i.e. width / height; must be greater than zero)
@param zNear
near clipping plane distance. If the special value {@link Double#POSITIVE_INFINITY} is used, the near clipping plane will be at positive infinity.
In that case, <code>zFar</code> may not also be {@link Double#POSITIVE_INFINITY}.
@param zFar
far clipping plane distance. If the special value {@link Double#POSITIVE_INFINITY} is used, the far clipping plane will be at positive infinity.
In that case, <code>zNear</code> may not also be {@link Double#POSITIVE_INFINITY}.
@param zZeroToOne
whether to use Vulkan's and Direct3D's NDC z range of <code>[0..+1]</code> when <code>true</code>
or whether to use OpenGL's NDC z range of <code>[-1..+1]</code> when <code>false</code>
@return this
|
[
"Apply",
"a",
"symmetric",
"perspective",
"projection",
"frustum",
"transformation",
"for",
"a",
"left",
"-",
"handed",
"coordinate",
"system",
"using",
"the",
"given",
"NDC",
"z",
"range",
"to",
"this",
"matrix",
".",
"<p",
">",
"If",
"<code",
">",
"M<",
"/",
"code",
">",
"is",
"<code",
">",
"this<",
"/",
"code",
">",
"matrix",
"and",
"<code",
">",
"P<",
"/",
"code",
">",
"the",
"perspective",
"projection",
"matrix",
"then",
"the",
"new",
"matrix",
"will",
"be",
"<code",
">",
"M",
"*",
"P<",
"/",
"code",
">",
".",
"So",
"when",
"transforming",
"a",
"vector",
"<code",
">",
"v<",
"/",
"code",
">",
"with",
"the",
"new",
"matrix",
"by",
"using",
"<code",
">",
"M",
"*",
"P",
"*",
"v<",
"/",
"code",
">",
"the",
"perspective",
"projection",
"will",
"be",
"applied",
"first!",
"<p",
">",
"In",
"order",
"to",
"set",
"the",
"matrix",
"to",
"a",
"perspective",
"frustum",
"transformation",
"without",
"post",
"-",
"multiplying",
"use",
"{",
"@link",
"#setPerspectiveLH",
"(",
"double",
"double",
"double",
"double",
"boolean",
")",
"setPerspectiveLH",
"}",
"."
] |
train
|
https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Matrix4d.java#L12917-L12919
|
exoplatform/jcr
|
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/xpath/XPathQueryBuilder.java
|
XPathQueryBuilder.createLocationStep
|
private LocationStepQueryNode createLocationStep(SimpleNode node, NAryQueryNode parent) {
LocationStepQueryNode queryNode = null;
boolean descendant = false;
Node p = node.jjtGetParent();
for (int i = 0; i < p.jjtGetNumChildren(); i++) {
SimpleNode c = (SimpleNode) p.jjtGetChild(i);
if (c == node) { // NOSONAR
queryNode = factory.createLocationStepQueryNode(parent);
queryNode.setNameTest(null);
queryNode.setIncludeDescendants(descendant);
parent.addOperand(queryNode);
break;
}
descendant = (c.getId() == JJTSLASHSLASH
|| c.getId() == JJTROOTDESCENDANTS);
}
node.childrenAccept(this, queryNode);
return queryNode;
}
|
java
|
private LocationStepQueryNode createLocationStep(SimpleNode node, NAryQueryNode parent) {
LocationStepQueryNode queryNode = null;
boolean descendant = false;
Node p = node.jjtGetParent();
for (int i = 0; i < p.jjtGetNumChildren(); i++) {
SimpleNode c = (SimpleNode) p.jjtGetChild(i);
if (c == node) { // NOSONAR
queryNode = factory.createLocationStepQueryNode(parent);
queryNode.setNameTest(null);
queryNode.setIncludeDescendants(descendant);
parent.addOperand(queryNode);
break;
}
descendant = (c.getId() == JJTSLASHSLASH
|| c.getId() == JJTROOTDESCENDANTS);
}
node.childrenAccept(this, queryNode);
return queryNode;
}
|
[
"private",
"LocationStepQueryNode",
"createLocationStep",
"(",
"SimpleNode",
"node",
",",
"NAryQueryNode",
"parent",
")",
"{",
"LocationStepQueryNode",
"queryNode",
"=",
"null",
";",
"boolean",
"descendant",
"=",
"false",
";",
"Node",
"p",
"=",
"node",
".",
"jjtGetParent",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"p",
".",
"jjtGetNumChildren",
"(",
")",
";",
"i",
"++",
")",
"{",
"SimpleNode",
"c",
"=",
"(",
"SimpleNode",
")",
"p",
".",
"jjtGetChild",
"(",
"i",
")",
";",
"if",
"(",
"c",
"==",
"node",
")",
"{",
"// NOSONAR",
"queryNode",
"=",
"factory",
".",
"createLocationStepQueryNode",
"(",
"parent",
")",
";",
"queryNode",
".",
"setNameTest",
"(",
"null",
")",
";",
"queryNode",
".",
"setIncludeDescendants",
"(",
"descendant",
")",
";",
"parent",
".",
"addOperand",
"(",
"queryNode",
")",
";",
"break",
";",
"}",
"descendant",
"=",
"(",
"c",
".",
"getId",
"(",
")",
"==",
"JJTSLASHSLASH",
"||",
"c",
".",
"getId",
"(",
")",
"==",
"JJTROOTDESCENDANTS",
")",
";",
"}",
"node",
".",
"childrenAccept",
"(",
"this",
",",
"queryNode",
")",
";",
"return",
"queryNode",
";",
"}"
] |
Creates a <code>LocationStepQueryNode</code> at the current position
in parent.
@param node the current node in the xpath syntax tree.
@param parent the parent <code>PathQueryNode</code>.
@return the created <code>LocationStepQueryNode</code>.
|
[
"Creates",
"a",
"<code",
">",
"LocationStepQueryNode<",
"/",
"code",
">",
"at",
"the",
"current",
"position",
"in",
"parent",
"."
] |
train
|
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/xpath/XPathQueryBuilder.java#L603-L623
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.