repository_name stringlengths 7 58 | func_path_in_repository stringlengths 18 194 | func_name stringlengths 6 111 | whole_func_string stringlengths 80 3.8k | language stringclasses 1
value | func_code_string stringlengths 80 3.8k | func_code_tokens listlengths 20 697 | func_documentation_string stringlengths 61 2k | func_documentation_tokens listlengths 1 434 | split_name stringclasses 1
value | func_code_url stringlengths 111 308 |
|---|---|---|---|---|---|---|---|---|---|---|
apache/incubator-gobblin | gobblin-metrics-libs/gobblin-metrics/src/main/java/org/apache/gobblin/metrics/GobblinMetricsRegistry.java | GobblinMetricsRegistry.getOrDefault | public GobblinMetrics getOrDefault(String id, Callable<? extends GobblinMetrics> valueLoader) {
try {
return this.metricsCache.get(id, valueLoader);
} catch (ExecutionException ee) {
throw Throwables.propagate(ee);
}
} | java | public GobblinMetrics getOrDefault(String id, Callable<? extends GobblinMetrics> valueLoader) {
try {
return this.metricsCache.get(id, valueLoader);
} catch (ExecutionException ee) {
throw Throwables.propagate(ee);
}
} | [
"public",
"GobblinMetrics",
"getOrDefault",
"(",
"String",
"id",
",",
"Callable",
"<",
"?",
"extends",
"GobblinMetrics",
">",
"valueLoader",
")",
"{",
"try",
"{",
"return",
"this",
".",
"metricsCache",
".",
"get",
"(",
"id",
",",
"valueLoader",
")",
";",
"... | Get the {@link GobblinMetrics} instance associated with a given ID. If the ID is not found this method returns the
{@link GobblinMetrics} returned by the given {@link Callable}, and creates a mapping between the specified ID
and the {@link GobblinMetrics} instance returned by the {@link Callable}.
@param id the given {@link GobblinMetrics} ID
@param valueLoader a {@link Callable} that returns a {@link GobblinMetrics}, the {@link Callable} is only invoked
if the given id is not found
@return a {@link GobblinMetrics} instance associated with the id | [
"Get",
"the",
"{",
"@link",
"GobblinMetrics",
"}",
"instance",
"associated",
"with",
"a",
"given",
"ID",
".",
"If",
"the",
"ID",
"is",
"not",
"found",
"this",
"method",
"returns",
"the",
"{",
"@link",
"GobblinMetrics",
"}",
"returned",
"by",
"the",
"given"... | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-metrics-libs/gobblin-metrics/src/main/java/org/apache/gobblin/metrics/GobblinMetricsRegistry.java#L90-L96 |
Chorus-bdd/Chorus | interpreter/chorus-interpreter/src/main/java/org/chorusbdd/chorus/interpreter/interpreter/HandlerManager.java | HandlerManager.processEndOfScope | public void processEndOfScope(Scope scopeEnding, Iterable<Object> handlerInstances) throws Exception {
for (Object handler : handlerInstances) {
Handler handlerAnnotation = handler.getClass().getAnnotation(Handler.class);
Scope scope = handlerAnnotation.scope();
runLifecycleMethods(handler, scope, scopeEnding, true);
//dispose handler instances with a scope which matches the scopeEnding
if (scope == scopeEnding) {
disposeSpringResources(handler, scopeEnding);
}
}
} | java | public void processEndOfScope(Scope scopeEnding, Iterable<Object> handlerInstances) throws Exception {
for (Object handler : handlerInstances) {
Handler handlerAnnotation = handler.getClass().getAnnotation(Handler.class);
Scope scope = handlerAnnotation.scope();
runLifecycleMethods(handler, scope, scopeEnding, true);
//dispose handler instances with a scope which matches the scopeEnding
if (scope == scopeEnding) {
disposeSpringResources(handler, scopeEnding);
}
}
} | [
"public",
"void",
"processEndOfScope",
"(",
"Scope",
"scopeEnding",
",",
"Iterable",
"<",
"Object",
">",
"handlerInstances",
")",
"throws",
"Exception",
"{",
"for",
"(",
"Object",
"handler",
":",
"handlerInstances",
")",
"{",
"Handler",
"handlerAnnotation",
"=",
... | Scope is ending, perform the required processing on the supplied handlers. | [
"Scope",
"is",
"ending",
"perform",
"the",
"required",
"processing",
"on",
"the",
"supplied",
"handlers",
"."
] | train | https://github.com/Chorus-bdd/Chorus/blob/1eea7ca858876bce821bb49b43fd5b6ba1737997/interpreter/chorus-interpreter/src/main/java/org/chorusbdd/chorus/interpreter/interpreter/HandlerManager.java#L149-L161 |
SG-O/miIO | src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java | Vacuum.setTimezone | public boolean setTimezone(TimeZone zone) throws CommandExecutionException {
if (zone == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS);
JSONArray tz = new JSONArray();
tz.put(zone.getID());
return sendOk("set_timezone", tz);
} | java | public boolean setTimezone(TimeZone zone) throws CommandExecutionException {
if (zone == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS);
JSONArray tz = new JSONArray();
tz.put(zone.getID());
return sendOk("set_timezone", tz);
} | [
"public",
"boolean",
"setTimezone",
"(",
"TimeZone",
"zone",
")",
"throws",
"CommandExecutionException",
"{",
"if",
"(",
"zone",
"==",
"null",
")",
"throw",
"new",
"CommandExecutionException",
"(",
"CommandExecutionException",
".",
"Error",
".",
"INVALID_PARAMETERS",
... | Set the vacuums timezone
@param zone The new timezone to set.
@return True if the command has been received successfully.
@throws CommandExecutionException When there has been a error during the communication or the response was invalid. | [
"Set",
"the",
"vacuums",
"timezone"
] | train | https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java#L74-L79 |
alkacon/opencms-core | src/org/opencms/jsp/util/CmsJspImageBean.java | CmsJspImageBean.checkCropRegionContainsFocalPoint | private static boolean checkCropRegionContainsFocalPoint(CmsImageScaler scaler, CmsPoint focalPoint) {
if (!scaler.isCropping()) {
return true;
}
double x = focalPoint.getX();
double y = focalPoint.getY();
return (scaler.getCropX() <= x)
&& (x < (scaler.getCropX() + scaler.getCropWidth()))
&& (scaler.getCropY() <= y)
&& (y < (scaler.getCropY() + scaler.getCropHeight()));
} | java | private static boolean checkCropRegionContainsFocalPoint(CmsImageScaler scaler, CmsPoint focalPoint) {
if (!scaler.isCropping()) {
return true;
}
double x = focalPoint.getX();
double y = focalPoint.getY();
return (scaler.getCropX() <= x)
&& (x < (scaler.getCropX() + scaler.getCropWidth()))
&& (scaler.getCropY() <= y)
&& (y < (scaler.getCropY() + scaler.getCropHeight()));
} | [
"private",
"static",
"boolean",
"checkCropRegionContainsFocalPoint",
"(",
"CmsImageScaler",
"scaler",
",",
"CmsPoint",
"focalPoint",
")",
"{",
"if",
"(",
"!",
"scaler",
".",
"isCropping",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"double",
"x",
"=",
"f... | Helper method to check whether the focal point in the scaler is contained in the scaler's crop region.<p>
If the scaler has no crop region, true is returned.
@param scaler the scaler
@param focalPoint the focal point to check
@return true if the scaler's crop region contains the focal point | [
"Helper",
"method",
"to",
"check",
"whether",
"the",
"focal",
"point",
"in",
"the",
"scaler",
"is",
"contained",
"in",
"the",
"scaler",
"s",
"crop",
"region",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/util/CmsJspImageBean.java#L344-L355 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/security/cert/X509CertSelector.java | X509CertSelector.setNameConstraints | public void setNameConstraints(byte[] bytes) throws IOException {
if (bytes == null) {
ncBytes = null;
nc = null;
} else {
ncBytes = bytes.clone();
nc = new NameConstraintsExtension(FALSE, bytes);
}
} | java | public void setNameConstraints(byte[] bytes) throws IOException {
if (bytes == null) {
ncBytes = null;
nc = null;
} else {
ncBytes = bytes.clone();
nc = new NameConstraintsExtension(FALSE, bytes);
}
} | [
"public",
"void",
"setNameConstraints",
"(",
"byte",
"[",
"]",
"bytes",
")",
"throws",
"IOException",
"{",
"if",
"(",
"bytes",
"==",
"null",
")",
"{",
"ncBytes",
"=",
"null",
";",
"nc",
"=",
"null",
";",
"}",
"else",
"{",
"ncBytes",
"=",
"bytes",
"."... | Sets the name constraints criterion. The {@code X509Certificate}
must have subject and subject alternative names that
meet the specified name constraints.
<p>
The name constraints are specified as a byte array. This byte array
should contain the DER encoded form of the name constraints, as they
would appear in the NameConstraints structure defined in RFC 3280
and X.509. The ASN.1 definition of this structure appears below.
<pre>{@code
NameConstraints ::= SEQUENCE {
permittedSubtrees [0] GeneralSubtrees OPTIONAL,
excludedSubtrees [1] GeneralSubtrees OPTIONAL }
GeneralSubtrees ::= SEQUENCE SIZE (1..MAX) OF GeneralSubtree
GeneralSubtree ::= SEQUENCE {
base GeneralName,
minimum [0] BaseDistance DEFAULT 0,
maximum [1] BaseDistance OPTIONAL }
BaseDistance ::= INTEGER (0..MAX)
GeneralName ::= CHOICE {
otherName [0] OtherName,
rfc822Name [1] IA5String,
dNSName [2] IA5String,
x400Address [3] ORAddress,
directoryName [4] Name,
ediPartyName [5] EDIPartyName,
uniformResourceIdentifier [6] IA5String,
iPAddress [7] OCTET STRING,
registeredID [8] OBJECT IDENTIFIER}
}</pre>
<p>
Note that the byte array supplied here is cloned to protect against
subsequent modifications.
@param bytes a byte array containing the ASN.1 DER encoding of
a NameConstraints extension to be used for checking
name constraints. Only the value of the extension is
included, not the OID or criticality flag. Can be
{@code null},
in which case no name constraints check will be performed.
@throws IOException if a parsing error occurs
@see #getNameConstraints | [
"Sets",
"the",
"name",
"constraints",
"criterion",
".",
"The",
"{",
"@code",
"X509Certificate",
"}",
"must",
"have",
"subject",
"and",
"subject",
"alternative",
"names",
"that",
"meet",
"the",
"specified",
"name",
"constraints",
".",
"<p",
">",
"The",
"name",
... | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/security/cert/X509CertSelector.java#L1040-L1048 |
jeremylong/DependencyCheck | core/src/main/java/org/owasp/dependencycheck/xml/suppression/SuppressionHandler.java | SuppressionHandler.endElement | @Override
public void endElement(String uri, String localName, String qName) throws SAXException {
if (null != qName) {
switch (qName) {
case SUPPRESS:
if (rule.getUntil() != null && rule.getUntil().before(Calendar.getInstance())) {
LOGGER.info("Suppression is expired for rule: {}", rule);
} else {
suppressionRules.add(rule);
}
rule = null;
break;
case FILE_PATH:
rule.setFilePath(processPropertyType());
break;
case SHA1:
rule.setSha1(currentText.toString());
break;
case GAV:
rule.setGav(processPropertyType());
break;
case CPE:
rule.addCpe(processPropertyType());
break;
case CWE:
rule.addCwe(currentText.toString());
break;
case CVE:
rule.addCve(currentText.toString());
break;
case NOTES:
rule.addNotes(currentText.toString());
break;
case CVSS_BELOW:
final float cvss = Float.parseFloat(currentText.toString());
rule.addCvssBelow(cvss);
break;
default:
break;
}
}
} | java | @Override
public void endElement(String uri, String localName, String qName) throws SAXException {
if (null != qName) {
switch (qName) {
case SUPPRESS:
if (rule.getUntil() != null && rule.getUntil().before(Calendar.getInstance())) {
LOGGER.info("Suppression is expired for rule: {}", rule);
} else {
suppressionRules.add(rule);
}
rule = null;
break;
case FILE_PATH:
rule.setFilePath(processPropertyType());
break;
case SHA1:
rule.setSha1(currentText.toString());
break;
case GAV:
rule.setGav(processPropertyType());
break;
case CPE:
rule.addCpe(processPropertyType());
break;
case CWE:
rule.addCwe(currentText.toString());
break;
case CVE:
rule.addCve(currentText.toString());
break;
case NOTES:
rule.addNotes(currentText.toString());
break;
case CVSS_BELOW:
final float cvss = Float.parseFloat(currentText.toString());
rule.addCvssBelow(cvss);
break;
default:
break;
}
}
} | [
"@",
"Override",
"public",
"void",
"endElement",
"(",
"String",
"uri",
",",
"String",
"localName",
",",
"String",
"qName",
")",
"throws",
"SAXException",
"{",
"if",
"(",
"null",
"!=",
"qName",
")",
"{",
"switch",
"(",
"qName",
")",
"{",
"case",
"SUPPRESS... | Handles the end element event.
@param uri the URI of the element
@param localName the local name of the element
@param qName the qName of the element
@throws SAXException thrown if there is an exception processing | [
"Handles",
"the",
"end",
"element",
"event",
"."
] | train | https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/core/src/main/java/org/owasp/dependencycheck/xml/suppression/SuppressionHandler.java#L150-L191 |
xhsun/gw2wrapper | src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java | AsynchronousRequest.getLegendInfo | public void getLegendInfo(String[] ids, Callback<List<Legend>> callback) throws GuildWars2Exception, NullPointerException {
isParamValid(new ParamChecker(ids));
gw2API.getLegendInfo(processIds(ids)).enqueue(callback);
} | java | public void getLegendInfo(String[] ids, Callback<List<Legend>> callback) throws GuildWars2Exception, NullPointerException {
isParamValid(new ParamChecker(ids));
gw2API.getLegendInfo(processIds(ids)).enqueue(callback);
} | [
"public",
"void",
"getLegendInfo",
"(",
"String",
"[",
"]",
"ids",
",",
"Callback",
"<",
"List",
"<",
"Legend",
">",
">",
"callback",
")",
"throws",
"GuildWars2Exception",
",",
"NullPointerException",
"{",
"isParamValid",
"(",
"new",
"ParamChecker",
"(",
"ids"... | For more info on legends API go <a href="https://wiki.guildwars2.com/wiki/API:2/legends">here</a><br/>
Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions
@param ids list of legend id
@param callback callback that is going to be used for {@link Call#enqueue(Callback)}
@throws GuildWars2Exception empty ID list
@throws NullPointerException if given {@link Callback} is empty
@see Legend legend info | [
"For",
"more",
"info",
"on",
"legends",
"API",
"go",
"<a",
"href",
"=",
"https",
":",
"//",
"wiki",
".",
"guildwars2",
".",
"com",
"/",
"wiki",
"/",
"API",
":",
"2",
"/",
"legends",
">",
"here<",
"/",
"a",
">",
"<br",
"/",
">",
"Give",
"user",
... | train | https://github.com/xhsun/gw2wrapper/blob/c8a43b51f363b032074fb152ee6efe657e33e525/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java#L1747-L1750 |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/alg/misc/PixelMath.java | PixelMath.boundImage | public static void boundImage( GrayS16 img , int min , int max ) {
ImplPixelMath.boundImage(img,min,max);
} | java | public static void boundImage( GrayS16 img , int min , int max ) {
ImplPixelMath.boundImage(img,min,max);
} | [
"public",
"static",
"void",
"boundImage",
"(",
"GrayS16",
"img",
",",
"int",
"min",
",",
"int",
"max",
")",
"{",
"ImplPixelMath",
".",
"boundImage",
"(",
"img",
",",
"min",
",",
"max",
")",
";",
"}"
] | Bounds image pixels to be between these two values
@param img Image
@param min minimum value.
@param max maximum value. | [
"Bounds",
"image",
"pixels",
"to",
"be",
"between",
"these",
"two",
"values"
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/misc/PixelMath.java#L4391-L4393 |
eurekaclinical/datastore | src/main/java/org/eurekaclinical/datastore/bdb/BdbStoreFactory.java | BdbStoreFactory.createEnvironment | private Environment createEnvironment() {
EnvironmentConfig envConf = createEnvConfig();
if (!envFile.exists()) {
envFile.mkdirs();
}
LOGGER.log(Level.INFO,
"Initialized BerkeleyDB cache environment at {0}",
envFile.getAbsolutePath());
return new Environment(this.envFile, envConf);
} | java | private Environment createEnvironment() {
EnvironmentConfig envConf = createEnvConfig();
if (!envFile.exists()) {
envFile.mkdirs();
}
LOGGER.log(Level.INFO,
"Initialized BerkeleyDB cache environment at {0}",
envFile.getAbsolutePath());
return new Environment(this.envFile, envConf);
} | [
"private",
"Environment",
"createEnvironment",
"(",
")",
"{",
"EnvironmentConfig",
"envConf",
"=",
"createEnvConfig",
"(",
")",
";",
"if",
"(",
"!",
"envFile",
".",
"exists",
"(",
")",
")",
"{",
"envFile",
".",
"mkdirs",
"(",
")",
";",
"}",
"LOGGER",
"."... | Creates a Berkeley DB database environment from the provided environment
configuration.
@return an environment instance.
@throws SecurityException if the directory for storing the databases
could not be created.
@throws EnvironmentNotFoundException if the environment does not exist
(does not contain at least one log file) and the EnvironmentConfig
AllowCreate parameter is false.
@throws EnvironmentLockedException when an environment cannot be opened
for write access because another process has the same environment open
for write access. Warning: This exception should be handled when an
environment is opened by more than one process.
@throws VersionMismatchException when the existing log is not compatible
with the version of JE that is running. This occurs when a later version
of JE was used to create the log. Warning: This exception should be
handled when more than one version of JE may be used to access an
environment.
@throws EnvironmentFailureException if an unexpected, internal or
environment-wide failure occurs.
@throws java.lang.UnsupportedOperationException if this environment was
previously opened for replication and is not being opened read-only.
@throws java.lang.IllegalArgumentException if an invalid parameter is
specified, for example, an invalid EnvironmentConfig parameter. | [
"Creates",
"a",
"Berkeley",
"DB",
"database",
"environment",
"from",
"the",
"provided",
"environment",
"configuration",
"."
] | train | https://github.com/eurekaclinical/datastore/blob/a03a70819bb562ba45eac66ca49f778035ee45e0/src/main/java/org/eurekaclinical/datastore/bdb/BdbStoreFactory.java#L244-L254 |
ocelotds/ocelot | ocelot-processor/src/main/java/org/ocelotds/processors/visitors/DataServiceVisitorJsBuilder.java | DataServiceVisitorJsBuilder.createReturnOcelotPromiseFactory | void createReturnOcelotPromiseFactory(String classname, String methodName, boolean ws, String args, String keys, Writer writer) throws IOException {
String md5 = keyMaker.getMd5(classname + DOT + methodName);
writer.append(TAB3).append("return promiseFactory.create").append(OPENPARENTHESIS).append("_ds").append(COMMA).append(SPACEOPTIONAL)
.append(QUOTE).append(md5).append(UNDERSCORE).append(QUOTE)
.append(" + JSON.stringify([").append(keys).append("]).md5()").append(COMMA).append(SPACEOPTIONAL)
.append(QUOTE).append(methodName).append(QUOTE).append(COMMA).append(SPACEOPTIONAL).append(""+ws).append(COMMA)
.append(SPACEOPTIONAL).append(OPENBRACKET).append(args).append(CLOSEBRACKET).append(CLOSEPARENTHESIS)
.append(SEMICOLON).append(CR);
} | java | void createReturnOcelotPromiseFactory(String classname, String methodName, boolean ws, String args, String keys, Writer writer) throws IOException {
String md5 = keyMaker.getMd5(classname + DOT + methodName);
writer.append(TAB3).append("return promiseFactory.create").append(OPENPARENTHESIS).append("_ds").append(COMMA).append(SPACEOPTIONAL)
.append(QUOTE).append(md5).append(UNDERSCORE).append(QUOTE)
.append(" + JSON.stringify([").append(keys).append("]).md5()").append(COMMA).append(SPACEOPTIONAL)
.append(QUOTE).append(methodName).append(QUOTE).append(COMMA).append(SPACEOPTIONAL).append(""+ws).append(COMMA)
.append(SPACEOPTIONAL).append(OPENBRACKET).append(args).append(CLOSEBRACKET).append(CLOSEPARENTHESIS)
.append(SEMICOLON).append(CR);
} | [
"void",
"createReturnOcelotPromiseFactory",
"(",
"String",
"classname",
",",
"String",
"methodName",
",",
"boolean",
"ws",
",",
"String",
"args",
",",
"String",
"keys",
",",
"Writer",
"writer",
")",
"throws",
"IOException",
"{",
"String",
"md5",
"=",
"keyMaker",... | Return body js line that return the OcelotPromise
@param classname
@param methodName
@param args
@param keys
@param writer
@throws IOException | [
"Return",
"body",
"js",
"line",
"that",
"return",
"the",
"OcelotPromise"
] | train | https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-processor/src/main/java/org/ocelotds/processors/visitors/DataServiceVisitorJsBuilder.java#L239-L247 |
ManfredTremmel/gwt-commons-lang3 | src/main/java/org/apache/commons/lang3/Validate.java | Validate.validIndex | public static <T extends Collection<?>> T validIndex(final T collection, final int index) {
return validIndex(collection, index, DEFAULT_VALID_INDEX_COLLECTION_EX_MESSAGE, Integer.valueOf(index));
} | java | public static <T extends Collection<?>> T validIndex(final T collection, final int index) {
return validIndex(collection, index, DEFAULT_VALID_INDEX_COLLECTION_EX_MESSAGE, Integer.valueOf(index));
} | [
"public",
"static",
"<",
"T",
"extends",
"Collection",
"<",
"?",
">",
">",
"T",
"validIndex",
"(",
"final",
"T",
"collection",
",",
"final",
"int",
"index",
")",
"{",
"return",
"validIndex",
"(",
"collection",
",",
"index",
",",
"DEFAULT_VALID_INDEX_COLLECTI... | <p>Validates that the index is within the bounds of the argument
collection; otherwise throwing an exception.</p>
<pre>Validate.validIndex(myCollection, 2);</pre>
<p>If the index is invalid, then the message of the exception
is "The validated collection index is invalid: "
followed by the index.</p>
@param <T> the collection type
@param collection the collection to check, validated not null by this method
@param index the index to check
@return the validated collection (never {@code null} for method chaining)
@throws NullPointerException if the collection is {@code null}
@throws IndexOutOfBoundsException if the index is invalid
@see #validIndex(Collection, int, String, Object...)
@since 3.0 | [
"<p",
">",
"Validates",
"that",
"the",
"index",
"is",
"within",
"the",
"bounds",
"of",
"the",
"argument",
"collection",
";",
"otherwise",
"throwing",
"an",
"exception",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/Validate.java#L724-L726 |
mozilla/rhino | src/org/mozilla/javascript/ScriptRuntime.java | ScriptRuntime.nameIncrDecr | @Deprecated
public static Object nameIncrDecr(Scriptable scopeChain, String id,
int incrDecrMask)
{
return nameIncrDecr(scopeChain, id, Context.getContext(), incrDecrMask);
} | java | @Deprecated
public static Object nameIncrDecr(Scriptable scopeChain, String id,
int incrDecrMask)
{
return nameIncrDecr(scopeChain, id, Context.getContext(), incrDecrMask);
} | [
"@",
"Deprecated",
"public",
"static",
"Object",
"nameIncrDecr",
"(",
"Scriptable",
"scopeChain",
",",
"String",
"id",
",",
"int",
"incrDecrMask",
")",
"{",
"return",
"nameIncrDecr",
"(",
"scopeChain",
",",
"id",
",",
"Context",
".",
"getContext",
"(",
")",
... | The method is only present for compatibility.
@deprecated Use {@link #nameIncrDecr(Scriptable, String, Context, int)} instead | [
"The",
"method",
"is",
"only",
"present",
"for",
"compatibility",
"."
] | train | https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptRuntime.java#L2963-L2968 |
wildfly/wildfly-core | embedded/src/main/java/org/wildfly/core/embedded/SystemPropertyContext.java | SystemPropertyContext.resolveBaseDir | Path resolveBaseDir(final String name, final String dirName) {
final String currentDir = SecurityActions.getPropertyPrivileged(name);
if (currentDir == null) {
return jbossHomeDir.resolve(dirName);
}
return Paths.get(currentDir);
} | java | Path resolveBaseDir(final String name, final String dirName) {
final String currentDir = SecurityActions.getPropertyPrivileged(name);
if (currentDir == null) {
return jbossHomeDir.resolve(dirName);
}
return Paths.get(currentDir);
} | [
"Path",
"resolveBaseDir",
"(",
"final",
"String",
"name",
",",
"final",
"String",
"dirName",
")",
"{",
"final",
"String",
"currentDir",
"=",
"SecurityActions",
".",
"getPropertyPrivileged",
"(",
"name",
")",
";",
"if",
"(",
"currentDir",
"==",
"null",
")",
"... | Resolves the base directory. If the system property is set that value will be used. Otherwise the path is
resolved from the home directory.
@param name the system property name
@param dirName the directory name relative to the base directory
@return the resolved base directory | [
"Resolves",
"the",
"base",
"directory",
".",
"If",
"the",
"system",
"property",
"is",
"set",
"that",
"value",
"will",
"be",
"used",
".",
"Otherwise",
"the",
"path",
"is",
"resolved",
"from",
"the",
"home",
"directory",
"."
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/embedded/src/main/java/org/wildfly/core/embedded/SystemPropertyContext.java#L151-L157 |
Azure/azure-sdk-for-java | edgegateway/resource-manager/v2019_03_01/src/main/java/com/microsoft/azure/management/edgegateway/v2019_03_01/implementation/StorageAccountCredentialsInner.java | StorageAccountCredentialsInner.createOrUpdateAsync | public Observable<StorageAccountCredentialInner> createOrUpdateAsync(String deviceName, String name, String resourceGroupName, StorageAccountCredentialInner storageAccountCredential) {
return createOrUpdateWithServiceResponseAsync(deviceName, name, resourceGroupName, storageAccountCredential).map(new Func1<ServiceResponse<StorageAccountCredentialInner>, StorageAccountCredentialInner>() {
@Override
public StorageAccountCredentialInner call(ServiceResponse<StorageAccountCredentialInner> response) {
return response.body();
}
});
} | java | public Observable<StorageAccountCredentialInner> createOrUpdateAsync(String deviceName, String name, String resourceGroupName, StorageAccountCredentialInner storageAccountCredential) {
return createOrUpdateWithServiceResponseAsync(deviceName, name, resourceGroupName, storageAccountCredential).map(new Func1<ServiceResponse<StorageAccountCredentialInner>, StorageAccountCredentialInner>() {
@Override
public StorageAccountCredentialInner call(ServiceResponse<StorageAccountCredentialInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"StorageAccountCredentialInner",
">",
"createOrUpdateAsync",
"(",
"String",
"deviceName",
",",
"String",
"name",
",",
"String",
"resourceGroupName",
",",
"StorageAccountCredentialInner",
"storageAccountCredential",
")",
"{",
"return",
"createOrU... | Creates or updates the storage account credential.
@param deviceName The device name.
@param name The storage account credential name.
@param resourceGroupName The resource group name.
@param storageAccountCredential The storage account credential.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Creates",
"or",
"updates",
"the",
"storage",
"account",
"credential",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/edgegateway/resource-manager/v2019_03_01/src/main/java/com/microsoft/azure/management/edgegateway/v2019_03_01/implementation/StorageAccountCredentialsInner.java#L351-L358 |
Harium/keel | src/main/java/com/harium/keel/catalano/core/DoublePoint.java | DoublePoint.Divide | public DoublePoint Divide(DoublePoint point1, DoublePoint point2) {
DoublePoint result = new DoublePoint(point1);
result.Divide(point2);
return result;
} | java | public DoublePoint Divide(DoublePoint point1, DoublePoint point2) {
DoublePoint result = new DoublePoint(point1);
result.Divide(point2);
return result;
} | [
"public",
"DoublePoint",
"Divide",
"(",
"DoublePoint",
"point1",
",",
"DoublePoint",
"point2",
")",
"{",
"DoublePoint",
"result",
"=",
"new",
"DoublePoint",
"(",
"point1",
")",
";",
"result",
".",
"Divide",
"(",
"point2",
")",
";",
"return",
"result",
";",
... | Divides values of two points.
@param point1 DoublePoint.
@param point2 DoublePoint.
@return A new DoublePoint with the division operation. | [
"Divides",
"values",
"of",
"two",
"points",
"."
] | train | https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/core/DoublePoint.java#L238-L242 |
algolia/algoliasearch-client-java | src/main/java/com/algolia/search/saas/Query.java | Query.addInsidePolygon | public Query addInsidePolygon(float latitude, float longitude) {
if (insidePolygon == null) {
insidePolygon = "insidePolygon=" + latitude + "," + longitude;
} else if (insidePolygon.length() > 14) {
insidePolygon += "," + latitude + "," + longitude;
}
return this;
} | java | public Query addInsidePolygon(float latitude, float longitude) {
if (insidePolygon == null) {
insidePolygon = "insidePolygon=" + latitude + "," + longitude;
} else if (insidePolygon.length() > 14) {
insidePolygon += "," + latitude + "," + longitude;
}
return this;
} | [
"public",
"Query",
"addInsidePolygon",
"(",
"float",
"latitude",
",",
"float",
"longitude",
")",
"{",
"if",
"(",
"insidePolygon",
"==",
"null",
")",
"{",
"insidePolygon",
"=",
"\"insidePolygon=\"",
"+",
"latitude",
"+",
"\",\"",
"+",
"longitude",
";",
"}",
"... | Add a point to the polygon of geo-search (requires a minimum of three points to define a valid polygon)
At indexing, you should specify geoloc of an object with the _geoloc attribute (in the form "_geoloc":{"lat":48.853409, "lng":2.348800} or
"_geoloc":[{"lat":48.853409, "lng":2.348800},{"lat":48.547456, "lng":2.972075}] if you have several geo-locations in your record). | [
"Add",
"a",
"point",
"to",
"the",
"polygon",
"of",
"geo",
"-",
"search",
"(",
"requires",
"a",
"minimum",
"of",
"three",
"points",
"to",
"define",
"a",
"valid",
"polygon",
")",
"At",
"indexing",
"you",
"should",
"specify",
"geoloc",
"of",
"an",
"object",... | train | https://github.com/algolia/algoliasearch-client-java/blob/a05da2f66c099fe6f77295c7b6a8a12c24e95f9b/src/main/java/com/algolia/search/saas/Query.java#L542-L549 |
camunda/camunda-bpm-platform | engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/parser/EventSubscriptionDeclaration.java | EventSubscriptionDeclaration.createSubscriptionForExecution | public EventSubscriptionEntity createSubscriptionForExecution(ExecutionEntity execution) {
EventSubscriptionEntity eventSubscriptionEntity = new EventSubscriptionEntity(execution, eventType);
String eventName = resolveExpressionOfEventName(execution);
eventSubscriptionEntity.setEventName(eventName);
if (activityId != null) {
ActivityImpl activity = execution.getProcessDefinition().findActivity(activityId);
eventSubscriptionEntity.setActivity(activity);
}
eventSubscriptionEntity.insert();
LegacyBehavior.removeLegacySubscriptionOnParent(execution, eventSubscriptionEntity);
return eventSubscriptionEntity;
} | java | public EventSubscriptionEntity createSubscriptionForExecution(ExecutionEntity execution) {
EventSubscriptionEntity eventSubscriptionEntity = new EventSubscriptionEntity(execution, eventType);
String eventName = resolveExpressionOfEventName(execution);
eventSubscriptionEntity.setEventName(eventName);
if (activityId != null) {
ActivityImpl activity = execution.getProcessDefinition().findActivity(activityId);
eventSubscriptionEntity.setActivity(activity);
}
eventSubscriptionEntity.insert();
LegacyBehavior.removeLegacySubscriptionOnParent(execution, eventSubscriptionEntity);
return eventSubscriptionEntity;
} | [
"public",
"EventSubscriptionEntity",
"createSubscriptionForExecution",
"(",
"ExecutionEntity",
"execution",
")",
"{",
"EventSubscriptionEntity",
"eventSubscriptionEntity",
"=",
"new",
"EventSubscriptionEntity",
"(",
"execution",
",",
"eventType",
")",
";",
"String",
"eventNam... | Creates and inserts a subscription entity depending on the message type of this declaration. | [
"Creates",
"and",
"inserts",
"a",
"subscription",
"entity",
"depending",
"on",
"the",
"message",
"type",
"of",
"this",
"declaration",
"."
] | train | https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/parser/EventSubscriptionDeclaration.java#L152-L166 |
pravega/pravega | segmentstore/server/host/src/main/java/io/pravega/segmentstore/server/host/admin/commands/BookKeeperCommand.java | BookKeeperCommand.createContext | protected Context createContext() throws DurableDataLogException {
val serviceConfig = getServiceConfig();
val bkConfig = getCommandArgs().getState().getConfigBuilder()
.include(BookKeeperConfig.builder().with(BookKeeperConfig.ZK_ADDRESS, serviceConfig.getZkURL()))
.build().getConfig(BookKeeperConfig::builder);
val zkClient = createZKClient();
val factory = new BookKeeperLogFactory(bkConfig, zkClient, getCommandArgs().getState().getExecutor());
try {
factory.initialize();
} catch (DurableDataLogException ex) {
zkClient.close();
throw ex;
}
val bkAdmin = new BookKeeperAdmin(factory.getBookKeeperClient());
return new Context(serviceConfig, bkConfig, zkClient, factory, bkAdmin);
} | java | protected Context createContext() throws DurableDataLogException {
val serviceConfig = getServiceConfig();
val bkConfig = getCommandArgs().getState().getConfigBuilder()
.include(BookKeeperConfig.builder().with(BookKeeperConfig.ZK_ADDRESS, serviceConfig.getZkURL()))
.build().getConfig(BookKeeperConfig::builder);
val zkClient = createZKClient();
val factory = new BookKeeperLogFactory(bkConfig, zkClient, getCommandArgs().getState().getExecutor());
try {
factory.initialize();
} catch (DurableDataLogException ex) {
zkClient.close();
throw ex;
}
val bkAdmin = new BookKeeperAdmin(factory.getBookKeeperClient());
return new Context(serviceConfig, bkConfig, zkClient, factory, bkAdmin);
} | [
"protected",
"Context",
"createContext",
"(",
")",
"throws",
"DurableDataLogException",
"{",
"val",
"serviceConfig",
"=",
"getServiceConfig",
"(",
")",
";",
"val",
"bkConfig",
"=",
"getCommandArgs",
"(",
")",
".",
"getState",
"(",
")",
".",
"getConfigBuilder",
"... | Creates a new Context to be used by the BookKeeper command.
@return A new Context.
@throws DurableDataLogException If the BookKeeperLogFactory could not be initialized. | [
"Creates",
"a",
"new",
"Context",
"to",
"be",
"used",
"by",
"the",
"BookKeeper",
"command",
"."
] | train | https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/segmentstore/server/host/src/main/java/io/pravega/segmentstore/server/host/admin/commands/BookKeeperCommand.java#L57-L73 |
Deep-Symmetry/beat-link | src/main/java/org/deepsymmetry/beatlink/Util.java | Util.writeFully | public static void writeFully(ByteBuffer buffer, WritableByteChannel channel) throws IOException {
while (buffer.hasRemaining()) {
channel.write(buffer);
}
} | java | public static void writeFully(ByteBuffer buffer, WritableByteChannel channel) throws IOException {
while (buffer.hasRemaining()) {
channel.write(buffer);
}
} | [
"public",
"static",
"void",
"writeFully",
"(",
"ByteBuffer",
"buffer",
",",
"WritableByteChannel",
"channel",
")",
"throws",
"IOException",
"{",
"while",
"(",
"buffer",
".",
"hasRemaining",
"(",
")",
")",
"{",
"channel",
".",
"write",
"(",
"buffer",
")",
";"... | Writes the entire remaining contents of the buffer to the channel. May complete in one operation, but the
documentation is vague, so this keeps going until we are sure.
@param buffer the data to be written
@param channel the channel to which we want to write data
@throws IOException if there is a problem writing to the channel | [
"Writes",
"the",
"entire",
"remaining",
"contents",
"of",
"the",
"buffer",
"to",
"the",
"channel",
".",
"May",
"complete",
"in",
"one",
"operation",
"but",
"the",
"documentation",
"is",
"vague",
"so",
"this",
"keeps",
"going",
"until",
"we",
"are",
"sure",
... | train | https://github.com/Deep-Symmetry/beat-link/blob/f958a2a70e8a87a31a75326d7b4db77c2f0b4212/src/main/java/org/deepsymmetry/beatlink/Util.java#L348-L352 |
dbracewell/mango | src/main/java/com/davidbracewell/string/StringUtils.java | StringUtils.randomString | public static String randomString(int length, int min, int max, @NonNull CharMatcher validChar) {
if (length <= 0) {
return EMPTY;
}
Random random = new Random();
int maxRandom = max - min;
char[] array = new char[length];
for (int i = 0; i < array.length; i++) {
char c;
do {
c = (char) (random.nextInt(maxRandom) + min);
} while (Character.isLowSurrogate(c) ||
Character.isHighSurrogate(c) ||
!validChar.matches(c));
array[i] = c;
}
return new String(array);
} | java | public static String randomString(int length, int min, int max, @NonNull CharMatcher validChar) {
if (length <= 0) {
return EMPTY;
}
Random random = new Random();
int maxRandom = max - min;
char[] array = new char[length];
for (int i = 0; i < array.length; i++) {
char c;
do {
c = (char) (random.nextInt(maxRandom) + min);
} while (Character.isLowSurrogate(c) ||
Character.isHighSurrogate(c) ||
!validChar.matches(c));
array[i] = c;
}
return new String(array);
} | [
"public",
"static",
"String",
"randomString",
"(",
"int",
"length",
",",
"int",
"min",
",",
"int",
"max",
",",
"@",
"NonNull",
"CharMatcher",
"validChar",
")",
"{",
"if",
"(",
"length",
"<=",
"0",
")",
"{",
"return",
"EMPTY",
";",
"}",
"Random",
"rando... | Generates a random string of a given length
@param length The length of the string
@param min The min character in the string
@param max The max character in the string
@param validChar CharPredicate that must match for a character to be returned in the string
@return A string of random characters | [
"Generates",
"a",
"random",
"string",
"of",
"a",
"given",
"length"
] | train | https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/string/StringUtils.java#L401-L418 |
Carbonado/Carbonado | src/main/java/com/amazon/carbonado/raw/KeyEncoder.java | KeyEncoder.encodeDesc | public static int encodeDesc(Long value, byte[] dst, int dstOffset) {
if (value == null) {
dst[dstOffset] = NULL_BYTE_LOW;
return 1;
} else {
dst[dstOffset] = NOT_NULL_BYTE_LOW;
DataEncoder.encode(~value.longValue(), dst, dstOffset + 1);
return 9;
}
} | java | public static int encodeDesc(Long value, byte[] dst, int dstOffset) {
if (value == null) {
dst[dstOffset] = NULL_BYTE_LOW;
return 1;
} else {
dst[dstOffset] = NOT_NULL_BYTE_LOW;
DataEncoder.encode(~value.longValue(), dst, dstOffset + 1);
return 9;
}
} | [
"public",
"static",
"int",
"encodeDesc",
"(",
"Long",
"value",
",",
"byte",
"[",
"]",
"dst",
",",
"int",
"dstOffset",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"dst",
"[",
"dstOffset",
"]",
"=",
"NULL_BYTE_LOW",
";",
"return",
"1",
";",
... | Encodes the given signed Long object into exactly 1 or 9 bytes for
descending order. If the Long object is never expected to be null,
consider encoding as a long primitive.
@param value optional signed Long value to encode
@param dst destination for encoded bytes
@param dstOffset offset into destination array
@return amount of bytes written | [
"Encodes",
"the",
"given",
"signed",
"Long",
"object",
"into",
"exactly",
"1",
"or",
"9",
"bytes",
"for",
"descending",
"order",
".",
"If",
"the",
"Long",
"object",
"is",
"never",
"expected",
"to",
"be",
"null",
"consider",
"encoding",
"as",
"a",
"long",
... | train | https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyEncoder.java#L94-L103 |
lucee/Lucee | core/src/main/java/lucee/runtime/reflection/Invoker.java | Invoker.getProperty | public static Object getProperty(Object o, String prop) throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
Field f = getFieldIgnoreCase(o.getClass(), prop);
return f.get(o);
} | java | public static Object getProperty(Object o, String prop) throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
Field f = getFieldIgnoreCase(o.getClass(), prop);
return f.get(o);
} | [
"public",
"static",
"Object",
"getProperty",
"(",
"Object",
"o",
",",
"String",
"prop",
")",
"throws",
"NoSuchFieldException",
",",
"IllegalArgumentException",
",",
"IllegalAccessException",
"{",
"Field",
"f",
"=",
"getFieldIgnoreCase",
"(",
"o",
".",
"getClass",
... | to get a visible Property of a object
@param o Object to invoke
@param prop property to call
@return property value
@throws NoSuchFieldException
@throws IllegalArgumentException
@throws IllegalAccessException | [
"to",
"get",
"a",
"visible",
"Property",
"of",
"a",
"object"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/runtime/reflection/Invoker.java#L361-L364 |
j256/ormlite-android | src/main/java/com/j256/ormlite/android/DatabaseTableConfigUtil.java | DatabaseTableConfigUtil.buildConfig | private static DatabaseFieldConfig buildConfig(DatabaseField databaseField, String tableName, Field field)
throws Exception {
InvocationHandler proxy = Proxy.getInvocationHandler(databaseField);
if (proxy.getClass() != annotationFactoryClazz) {
return null;
}
// this should be an array of AnnotationMember objects
Object elementsObject = elementsField.get(proxy);
if (elementsObject == null) {
return null;
}
DatabaseFieldConfig config = new DatabaseFieldConfig(field.getName());
Object[] objs = (Object[]) elementsObject;
for (int i = 0; i < configFieldNums.length; i++) {
Object value = valueField.get(objs[i]);
if (value != null) {
assignConfigField(configFieldNums[i], config, field, value);
}
}
return config;
} | java | private static DatabaseFieldConfig buildConfig(DatabaseField databaseField, String tableName, Field field)
throws Exception {
InvocationHandler proxy = Proxy.getInvocationHandler(databaseField);
if (proxy.getClass() != annotationFactoryClazz) {
return null;
}
// this should be an array of AnnotationMember objects
Object elementsObject = elementsField.get(proxy);
if (elementsObject == null) {
return null;
}
DatabaseFieldConfig config = new DatabaseFieldConfig(field.getName());
Object[] objs = (Object[]) elementsObject;
for (int i = 0; i < configFieldNums.length; i++) {
Object value = valueField.get(objs[i]);
if (value != null) {
assignConfigField(configFieldNums[i], config, field, value);
}
}
return config;
} | [
"private",
"static",
"DatabaseFieldConfig",
"buildConfig",
"(",
"DatabaseField",
"databaseField",
",",
"String",
"tableName",
",",
"Field",
"field",
")",
"throws",
"Exception",
"{",
"InvocationHandler",
"proxy",
"=",
"Proxy",
".",
"getInvocationHandler",
"(",
"databas... | Instead of calling the annotation methods directly, we peer inside the proxy and investigate the array of
AnnotationMember objects stored by the AnnotationFactory. | [
"Instead",
"of",
"calling",
"the",
"annotation",
"methods",
"directly",
"we",
"peer",
"inside",
"the",
"proxy",
"and",
"investigate",
"the",
"array",
"of",
"AnnotationMember",
"objects",
"stored",
"by",
"the",
"AnnotationFactory",
"."
] | train | https://github.com/j256/ormlite-android/blob/e82327a868ae242f994730fe2389f79684d7bcab/src/main/java/com/j256/ormlite/android/DatabaseTableConfigUtil.java#L292-L312 |
michael-rapp/AndroidUtil | library/src/main/java/de/mrapp/android/util/view/ExpandableGridView.java | ExpandableGridView.notifyOnItemClicked | private void notifyOnItemClicked(@NonNull final View view, final int position, final long id) {
if (itemClickListener != null) {
itemClickListener.onItemClick(this, view, position, id);
}
} | java | private void notifyOnItemClicked(@NonNull final View view, final int position, final long id) {
if (itemClickListener != null) {
itemClickListener.onItemClick(this, view, position, id);
}
} | [
"private",
"void",
"notifyOnItemClicked",
"(",
"@",
"NonNull",
"final",
"View",
"view",
",",
"final",
"int",
"position",
",",
"final",
"long",
"id",
")",
"{",
"if",
"(",
"itemClickListener",
"!=",
"null",
")",
"{",
"itemClickListener",
".",
"onItemClick",
"(... | Notifies, the listener, which has been registered to be notified, when any item has been
clicked, about an item being clicked.
@param view
The view within the expandable grid view, which has been clicked, as an instance of
the class {@link View}. The view may not be null
@param position
The position of the item, which has been clicked, as an {@link Integer} value
@param id
The id of the item, which has been clicked, as a {@link Long} value | [
"Notifies",
"the",
"listener",
"which",
"has",
"been",
"registered",
"to",
"be",
"notified",
"when",
"any",
"item",
"has",
"been",
"clicked",
"about",
"an",
"item",
"being",
"clicked",
"."
] | train | https://github.com/michael-rapp/AndroidUtil/blob/67ec0e5732344eeb4d946dd1f96d782939e449f4/library/src/main/java/de/mrapp/android/util/view/ExpandableGridView.java#L557-L561 |
alkacon/opencms-core | src-modules/org/opencms/workplace/commons/CmsProgressWidget.java | CmsProgressWidget.createError | private String createError(String errorMsg, Throwable t) {
StringBuffer msg = new StringBuffer();
msg.append(errorMsg);
msg.append("\n");
msg.append(t.getMessage());
msg.append("\n");
msg.append(CmsException.getStackTraceAsString(t));
return createError(msg.toString());
} | java | private String createError(String errorMsg, Throwable t) {
StringBuffer msg = new StringBuffer();
msg.append(errorMsg);
msg.append("\n");
msg.append(t.getMessage());
msg.append("\n");
msg.append(CmsException.getStackTraceAsString(t));
return createError(msg.toString());
} | [
"private",
"String",
"createError",
"(",
"String",
"errorMsg",
",",
"Throwable",
"t",
")",
"{",
"StringBuffer",
"msg",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"msg",
".",
"append",
"(",
"errorMsg",
")",
";",
"msg",
".",
"append",
"(",
"\"\\n\"",
")",
... | Creates the html code for the given error message and the
provided Exception.<p>
@param errorMsg the error message to place in the html code
@param t the exception to add to the error message
@return the html code for the error message | [
"Creates",
"the",
"html",
"code",
"for",
"the",
"given",
"error",
"message",
"and",
"the",
"provided",
"Exception",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-modules/org/opencms/workplace/commons/CmsProgressWidget.java#L745-L755 |
aws/aws-cloudtrail-processing-library | src/main/java/com/amazonaws/services/cloudtrail/processinglibrary/utils/SourceIdentifier.java | SourceIdentifier.identifyWithEventName | public SourceType identifyWithEventName(String source, String eventName) {
if (eventName.startsWith(CREATE_EVENT_PREFIX)) {
return getCloudTrailSourceType(source);
}
return SourceType.Other;
} | java | public SourceType identifyWithEventName(String source, String eventName) {
if (eventName.startsWith(CREATE_EVENT_PREFIX)) {
return getCloudTrailSourceType(source);
}
return SourceType.Other;
} | [
"public",
"SourceType",
"identifyWithEventName",
"(",
"String",
"source",
",",
"String",
"eventName",
")",
"{",
"if",
"(",
"eventName",
".",
"startsWith",
"(",
"CREATE_EVENT_PREFIX",
")",
")",
"{",
"return",
"getCloudTrailSourceType",
"(",
"source",
")",
";",
"}... | Identify the source type with event action.
@param source the S3 object name
@param eventName the event name defined by Amazon S3.
@return {@link SourceType} | [
"Identify",
"the",
"source",
"type",
"with",
"event",
"action",
"."
] | train | https://github.com/aws/aws-cloudtrail-processing-library/blob/411315808d8d3dc6b45e4182212e3e04d82e3782/src/main/java/com/amazonaws/services/cloudtrail/processinglibrary/utils/SourceIdentifier.java#L38-L43 |
protostuff/protostuff | protostuff-json/src/main/java/io/protostuff/JsonIOUtil.java | JsonIOUtil.writeListTo | public static <T> void writeListTo(JsonGenerator generator, List<T> messages,
Schema<T> schema, boolean numeric) throws IOException
{
generator.writeStartArray();
if (messages.isEmpty())
{
generator.writeEndArray();
return;
}
final JsonOutput output = new JsonOutput(generator, numeric, schema);
for (T m : messages)
{
generator.writeStartObject();
schema.writeTo(output, m);
if (output.isLastRepeated())
generator.writeEndArray();
generator.writeEndObject();
output.reset();
}
generator.writeEndArray();
} | java | public static <T> void writeListTo(JsonGenerator generator, List<T> messages,
Schema<T> schema, boolean numeric) throws IOException
{
generator.writeStartArray();
if (messages.isEmpty())
{
generator.writeEndArray();
return;
}
final JsonOutput output = new JsonOutput(generator, numeric, schema);
for (T m : messages)
{
generator.writeStartObject();
schema.writeTo(output, m);
if (output.isLastRepeated())
generator.writeEndArray();
generator.writeEndObject();
output.reset();
}
generator.writeEndArray();
} | [
"public",
"static",
"<",
"T",
">",
"void",
"writeListTo",
"(",
"JsonGenerator",
"generator",
",",
"List",
"<",
"T",
">",
"messages",
",",
"Schema",
"<",
"T",
">",
"schema",
",",
"boolean",
"numeric",
")",
"throws",
"IOException",
"{",
"generator",
".",
"... | Serializes the {@code messages} into the generator using the given schema. | [
"Serializes",
"the",
"{"
] | train | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-json/src/main/java/io/protostuff/JsonIOUtil.java#L534-L559 |
cdapio/tigon | tigon-queue/src/main/java/co/cask/tigon/data/transaction/queue/QueueEntryRow.java | QueueEntryRow.isQueueEntry | public static boolean isQueueEntry(byte[] queueRowPrefix, byte[] rowBuffer, int rowOffset, int rowLength) {
return isPrefix(rowBuffer,
rowOffset + 1 + HBaseQueueAdmin.SALT_BYTES,
rowLength - 1 - HBaseQueueAdmin.SALT_BYTES,
queueRowPrefix);
} | java | public static boolean isQueueEntry(byte[] queueRowPrefix, byte[] rowBuffer, int rowOffset, int rowLength) {
return isPrefix(rowBuffer,
rowOffset + 1 + HBaseQueueAdmin.SALT_BYTES,
rowLength - 1 - HBaseQueueAdmin.SALT_BYTES,
queueRowPrefix);
} | [
"public",
"static",
"boolean",
"isQueueEntry",
"(",
"byte",
"[",
"]",
"queueRowPrefix",
",",
"byte",
"[",
"]",
"rowBuffer",
",",
"int",
"rowOffset",
",",
"int",
"rowLength",
")",
"{",
"return",
"isPrefix",
"(",
"rowBuffer",
",",
"rowOffset",
"+",
"1",
"+",... | Returns true if the given KeyValue row is a queue entry of the given queue based on queue row prefix | [
"Returns",
"true",
"if",
"the",
"given",
"KeyValue",
"row",
"is",
"a",
"queue",
"entry",
"of",
"the",
"given",
"queue",
"based",
"on",
"queue",
"row",
"prefix"
] | train | https://github.com/cdapio/tigon/blob/5be6dffd7c79519d1211bb08f75be7dcfbbad392/tigon-queue/src/main/java/co/cask/tigon/data/transaction/queue/QueueEntryRow.java#L141-L146 |
shekhargulati/strman-java | src/main/java/strman/Strman.java | Strman.prependArray | public static String prependArray(final String value, final String[] prepends) {
validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
if (prepends == null || prepends.length == 0) {
return value;
}
StringJoiner joiner = new StringJoiner("");
for (String prepend : prepends) {
joiner.add(prepend);
}
return joiner.toString() + value;
} | java | public static String prependArray(final String value, final String[] prepends) {
validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
if (prepends == null || prepends.length == 0) {
return value;
}
StringJoiner joiner = new StringJoiner("");
for (String prepend : prepends) {
joiner.add(prepend);
}
return joiner.toString() + value;
} | [
"public",
"static",
"String",
"prependArray",
"(",
"final",
"String",
"value",
",",
"final",
"String",
"[",
"]",
"prepends",
")",
"{",
"validate",
"(",
"value",
",",
"NULL_STRING_PREDICATE",
",",
"NULL_STRING_MSG_SUPPLIER",
")",
";",
"if",
"(",
"prepends",
"==... | Return a new String starting with prepends
@param value The input String
@param prepends Strings to prepend
@return The prepended String | [
"Return",
"a",
"new",
"String",
"starting",
"with",
"prepends"
] | train | https://github.com/shekhargulati/strman-java/blob/d0c2a10a6273fd6082f084e95156653ca55ce1be/src/main/java/strman/Strman.java#L693-L703 |
thorntail/thorntail | arquillian/gradle-adapter/src/main/java/org/wildfly/swarm/arquillian/adapter/gradle/GradleDependencyDeclarationFactory.java | GradleDependencyDeclarationFactory.resolveDependencies | private static void resolveDependencies(Collection<ArtifactSpec> collection, ShrinkwrapArtifactResolvingHelper helper) {
// Identify the artifact specs that need resolution.
// Ideally, there should be none at this point.
collection.forEach(spec -> {
if (spec.file == null) {
// Resolve it.
ArtifactSpec resolved = helper.resolve(spec);
if (resolved != null) {
spec.file = resolved.file;
} else {
throw new IllegalStateException("Unable to resolve artifact: " + spec.toString());
}
}
});
} | java | private static void resolveDependencies(Collection<ArtifactSpec> collection, ShrinkwrapArtifactResolvingHelper helper) {
// Identify the artifact specs that need resolution.
// Ideally, there should be none at this point.
collection.forEach(spec -> {
if (spec.file == null) {
// Resolve it.
ArtifactSpec resolved = helper.resolve(spec);
if (resolved != null) {
spec.file = resolved.file;
} else {
throw new IllegalStateException("Unable to resolve artifact: " + spec.toString());
}
}
});
} | [
"private",
"static",
"void",
"resolveDependencies",
"(",
"Collection",
"<",
"ArtifactSpec",
">",
"collection",
",",
"ShrinkwrapArtifactResolvingHelper",
"helper",
")",
"{",
"// Identify the artifact specs that need resolution.",
"// Ideally, there should be none at this point.",
"c... | Resolve the given collection of ArtifactSpec references. This method attempts the resolution and ensures that the
references are updated to be as complete as possible.
@param collection the collection artifact specifications. | [
"Resolve",
"the",
"given",
"collection",
"of",
"ArtifactSpec",
"references",
".",
"This",
"method",
"attempts",
"the",
"resolution",
"and",
"ensures",
"that",
"the",
"references",
"are",
"updated",
"to",
"be",
"as",
"complete",
"as",
"possible",
"."
] | train | https://github.com/thorntail/thorntail/blob/4a391b68ffae98c6e66d30a3bfb99dadc9509f14/arquillian/gradle-adapter/src/main/java/org/wildfly/swarm/arquillian/adapter/gradle/GradleDependencyDeclarationFactory.java#L56-L70 |
geomajas/geomajas-project-client-gwt | client/src/main/java/org/geomajas/gwt/client/map/feature/Feature.java | Feature.addOneToManyValue | public void addOneToManyValue(String name, AssociationValue value) {
Attribute attribute = getAttributes().get(name);
if (!(attribute instanceof OneToManyAttribute)) {
throw new IllegalStateException("Cannot set oneToMany value on attribute with different type, " +
attribute.getClass().getName() + " setting value " + value);
}
OneToManyAttribute oneToMany = (OneToManyAttribute) attribute;
if (oneToMany.getValue() == null) {
oneToMany.setValue(new ArrayList<AssociationValue>());
}
oneToMany.getValue().add(value);
} | java | public void addOneToManyValue(String name, AssociationValue value) {
Attribute attribute = getAttributes().get(name);
if (!(attribute instanceof OneToManyAttribute)) {
throw new IllegalStateException("Cannot set oneToMany value on attribute with different type, " +
attribute.getClass().getName() + " setting value " + value);
}
OneToManyAttribute oneToMany = (OneToManyAttribute) attribute;
if (oneToMany.getValue() == null) {
oneToMany.setValue(new ArrayList<AssociationValue>());
}
oneToMany.getValue().add(value);
} | [
"public",
"void",
"addOneToManyValue",
"(",
"String",
"name",
",",
"AssociationValue",
"value",
")",
"{",
"Attribute",
"attribute",
"=",
"getAttributes",
"(",
")",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"!",
"(",
"attribute",
"instanceof",
"OneToManyA... | Set attribute value of given type.
@param name attribute name
@param value attribute value | [
"Set",
"attribute",
"value",
"of",
"given",
"type",
"."
] | train | https://github.com/geomajas/geomajas-project-client-gwt/blob/1c1adc48deb192ed825265eebcc74d70bbf45670/client/src/main/java/org/geomajas/gwt/client/map/feature/Feature.java#L395-L406 |
eurekaclinical/protempa | protempa-framework/src/main/java/org/protempa/graph/Weight.java | Weight.max | public static Weight max(Weight w1, Weight w2) {
if (w1 == null) {
throw new IllegalArgumentException("Argument w1 cannot be null");
}
if (w2 == null) {
throw new IllegalArgumentException("Argument w2 cannot be null");
}
if ((w1.isInfinity && w1.posOrNeg) || (w2.isInfinity && !w2.posOrNeg)) {
return w1;
} else if ((w2.isInfinity && w2.posOrNeg)
|| (w1.isInfinity && !w1.posOrNeg)) {
return w2;
} else if (w1.val >= w2.val) {
return w1;
} else {
return w2;
}
} | java | public static Weight max(Weight w1, Weight w2) {
if (w1 == null) {
throw new IllegalArgumentException("Argument w1 cannot be null");
}
if (w2 == null) {
throw new IllegalArgumentException("Argument w2 cannot be null");
}
if ((w1.isInfinity && w1.posOrNeg) || (w2.isInfinity && !w2.posOrNeg)) {
return w1;
} else if ((w2.isInfinity && w2.posOrNeg)
|| (w1.isInfinity && !w1.posOrNeg)) {
return w2;
} else if (w1.val >= w2.val) {
return w1;
} else {
return w2;
}
} | [
"public",
"static",
"Weight",
"max",
"(",
"Weight",
"w1",
",",
"Weight",
"w2",
")",
"{",
"if",
"(",
"w1",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Argument w1 cannot be null\"",
")",
";",
"}",
"if",
"(",
"w2",
"==",
"nu... | Gets the larger of the two given weights.
@param w1
a weight. Cannot be <code>null</code>.
@param w2
a weight. Cannot be <code>null</code>.
@return a weight. | [
"Gets",
"the",
"larger",
"of",
"the",
"two",
"given",
"weights",
"."
] | train | https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/graph/Weight.java#L280-L297 |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/util/Util.java | Util.getThemeColorFromAttrOrRes | public static int getThemeColorFromAttrOrRes(Context ctx, int attr, int res) {
int color = getThemeColor(ctx, attr);
// If this color is not styled, use the default from the resource
if (color == 0) {
color = ContextCompat.getColor(ctx, res);
}
return color;
} | java | public static int getThemeColorFromAttrOrRes(Context ctx, int attr, int res) {
int color = getThemeColor(ctx, attr);
// If this color is not styled, use the default from the resource
if (color == 0) {
color = ContextCompat.getColor(ctx, res);
}
return color;
} | [
"public",
"static",
"int",
"getThemeColorFromAttrOrRes",
"(",
"Context",
"ctx",
",",
"int",
"attr",
",",
"int",
"res",
")",
"{",
"int",
"color",
"=",
"getThemeColor",
"(",
"ctx",
",",
"attr",
")",
";",
"// If this color is not styled, use the default from the resour... | helper method to get the color by attr (if defined in the style) or by resource.
@param ctx
@param attr attribute that defines the color
@param res color resource id
@return | [
"helper",
"method",
"to",
"get",
"the",
"color",
"by",
"attr",
"(",
"if",
"defined",
"in",
"the",
"style",
")",
"or",
"by",
"resource",
"."
] | train | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/util/Util.java#L427-L434 |
moparisthebest/beehive | beehive-netui-core/src/main/java/org/apache/beehive/netui/util/Bundle.java | Bundle.getString | public static String getString(String aKey, Object arg)
{
return getString(aKey,new Object[]{arg});
} | java | public static String getString(String aKey, Object arg)
{
return getString(aKey,new Object[]{arg});
} | [
"public",
"static",
"String",
"getString",
"(",
"String",
"aKey",
",",
"Object",
"arg",
")",
"{",
"return",
"getString",
"(",
"aKey",
",",
"new",
"Object",
"[",
"]",
"{",
"arg",
"}",
")",
";",
"}"
] | Returns the string specified by aKey from the errors.properties bundle.
@param aKey The key for the message pattern in the bundle.
@param arg The arg to use in the message format. | [
"Returns",
"the",
"string",
"specified",
"by",
"aKey",
"from",
"the",
"errors",
".",
"properties",
"bundle",
"."
] | train | https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-core/src/main/java/org/apache/beehive/netui/util/Bundle.java#L66-L69 |
elki-project/elki | elki-core/src/main/java/de/lmu/ifi/dbs/elki/result/ResultUtil.java | ResultUtil.removeRecursive | public static void removeRecursive(ResultHierarchy hierarchy, Result child) {
for(It<Result> iter = hierarchy.iterParents(child); iter.valid(); iter.advance()) {
hierarchy.remove(iter.get(), child);
}
for(It<Result> iter = hierarchy.iterChildren(child); iter.valid(); iter.advance()) {
removeRecursive(hierarchy, iter.get());
}
} | java | public static void removeRecursive(ResultHierarchy hierarchy, Result child) {
for(It<Result> iter = hierarchy.iterParents(child); iter.valid(); iter.advance()) {
hierarchy.remove(iter.get(), child);
}
for(It<Result> iter = hierarchy.iterChildren(child); iter.valid(); iter.advance()) {
removeRecursive(hierarchy, iter.get());
}
} | [
"public",
"static",
"void",
"removeRecursive",
"(",
"ResultHierarchy",
"hierarchy",
",",
"Result",
"child",
")",
"{",
"for",
"(",
"It",
"<",
"Result",
">",
"iter",
"=",
"hierarchy",
".",
"iterParents",
"(",
"child",
")",
";",
"iter",
".",
"valid",
"(",
"... | Recursively remove a result and its children.
@param hierarchy Result hierarchy
@param child Result to remove | [
"Recursively",
"remove",
"a",
"result",
"and",
"its",
"children",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core/src/main/java/de/lmu/ifi/dbs/elki/result/ResultUtil.java#L188-L195 |
DDTH/ddth-dlock | ddth-dlock-core/src/main/java/com/github/ddth/dlock/impl/AbstractDLockFactory.java | AbstractDLockFactory.createAndInitLockInstance | protected AbstractDLock createAndInitLockInstance(String name, Properties lockProps) {
AbstractDLock lock = createLockInternal(name, lockProps);
lock.init();
return lock;
} | java | protected AbstractDLock createAndInitLockInstance(String name, Properties lockProps) {
AbstractDLock lock = createLockInternal(name, lockProps);
lock.init();
return lock;
} | [
"protected",
"AbstractDLock",
"createAndInitLockInstance",
"(",
"String",
"name",
",",
"Properties",
"lockProps",
")",
"{",
"AbstractDLock",
"lock",
"=",
"createLockInternal",
"(",
"name",
",",
"lockProps",
")",
";",
"lock",
".",
"init",
"(",
")",
";",
"return",... | Create and initializes an {@link IDLock} instance, ready for use.
@param name
@param lockProps
@return | [
"Create",
"and",
"initializes",
"an",
"{",
"@link",
"IDLock",
"}",
"instance",
"ready",
"for",
"use",
"."
] | train | https://github.com/DDTH/ddth-dlock/blob/56786c61a04fe505556a834133b3de36562c6cb6/ddth-dlock-core/src/main/java/com/github/ddth/dlock/impl/AbstractDLockFactory.java#L141-L145 |
facebookarchive/hadoop-20 | src/hdfs/org/apache/hadoop/hdfs/server/namenode/NameNode.java | NameNode.stopRPC | protected void stopRPC(boolean interruptClientHandlers)
throws IOException, InterruptedException {
// stop client handlers
stopRPCInternal(server, "client", interruptClientHandlers);
// stop datanode handlers
stopRPCInternal(dnProtocolServer, "datanode", interruptClientHandlers);
// waiting for the ongoing requests to complete
stopWaitRPCInternal(server, "client");
stopWaitRPCInternal(dnProtocolServer, "datanode");
} | java | protected void stopRPC(boolean interruptClientHandlers)
throws IOException, InterruptedException {
// stop client handlers
stopRPCInternal(server, "client", interruptClientHandlers);
// stop datanode handlers
stopRPCInternal(dnProtocolServer, "datanode", interruptClientHandlers);
// waiting for the ongoing requests to complete
stopWaitRPCInternal(server, "client");
stopWaitRPCInternal(dnProtocolServer, "datanode");
} | [
"protected",
"void",
"stopRPC",
"(",
"boolean",
"interruptClientHandlers",
")",
"throws",
"IOException",
",",
"InterruptedException",
"{",
"// stop client handlers",
"stopRPCInternal",
"(",
"server",
",",
"\"client\"",
",",
"interruptClientHandlers",
")",
";",
"// stop da... | Quiescess all communication to namenode cleanly.
Ensures all RPC handlers have exited.
@param interruptClientHandlers should the handlers be interrupted | [
"Quiescess",
"all",
"communication",
"to",
"namenode",
"cleanly",
".",
"Ensures",
"all",
"RPC",
"handlers",
"have",
"exited",
"."
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/hdfs/org/apache/hadoop/hdfs/server/namenode/NameNode.java#L674-L685 |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/CommonOps_DDRM.java | CommonOps_DDRM.multTransAB | public static void multTransAB(double alpha , DMatrix1Row a , DMatrix1Row b , DMatrix1Row c )
{
// TODO add a matrix vectory multiply here
if( a.numCols >= EjmlParameters.MULT_TRANAB_COLUMN_SWITCH ) {
MatrixMatrixMult_DDRM.multTransAB_aux(alpha, a, b, c, null);
} else {
MatrixMatrixMult_DDRM.multTransAB(alpha, a, b, c);
}
} | java | public static void multTransAB(double alpha , DMatrix1Row a , DMatrix1Row b , DMatrix1Row c )
{
// TODO add a matrix vectory multiply here
if( a.numCols >= EjmlParameters.MULT_TRANAB_COLUMN_SWITCH ) {
MatrixMatrixMult_DDRM.multTransAB_aux(alpha, a, b, c, null);
} else {
MatrixMatrixMult_DDRM.multTransAB(alpha, a, b, c);
}
} | [
"public",
"static",
"void",
"multTransAB",
"(",
"double",
"alpha",
",",
"DMatrix1Row",
"a",
",",
"DMatrix1Row",
"b",
",",
"DMatrix1Row",
"c",
")",
"{",
"// TODO add a matrix vectory multiply here",
"if",
"(",
"a",
".",
"numCols",
">=",
"EjmlParameters",
".",
"MU... | <p>
Performs the following operation:<br>
<br>
c = α * a<sup>T</sup> * b<sup>T</sup><br>
c<sub>ij</sub> = α ∑<sub>k=1:n</sub> { a<sub>ki</sub> * b<sub>jk</sub>}
</p>
@param alpha Scaling factor.
@param a The left matrix in the multiplication operation. Not modified.
@param b The right matrix in the multiplication operation. Not modified.
@param c Where the results of the operation are stored. Modified. | [
"<p",
">",
"Performs",
"the",
"following",
"operation",
":",
"<br",
">",
"<br",
">",
"c",
"=",
"&alpha",
";",
"*",
"a<sup",
">",
"T<",
"/",
"sup",
">",
"*",
"b<sup",
">",
"T<",
"/",
"sup",
">",
"<br",
">",
"c<sub",
">",
"ij<",
"/",
"sub",
">",
... | train | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/CommonOps_DDRM.java#L244-L252 |
rzwitserloot/lombok | src/core/lombok/javac/handlers/JavacHandlerUtil.java | JavacHandlerUtil.createAnnotation | public static <A extends Annotation> AnnotationValues<A> createAnnotation(Class<A> type, final JavacNode node) {
return createAnnotation(type, (JCAnnotation) node.get(), node);
} | java | public static <A extends Annotation> AnnotationValues<A> createAnnotation(Class<A> type, final JavacNode node) {
return createAnnotation(type, (JCAnnotation) node.get(), node);
} | [
"public",
"static",
"<",
"A",
"extends",
"Annotation",
">",
"AnnotationValues",
"<",
"A",
">",
"createAnnotation",
"(",
"Class",
"<",
"A",
">",
"type",
",",
"final",
"JavacNode",
"node",
")",
"{",
"return",
"createAnnotation",
"(",
"type",
",",
"(",
"JCAnn... | Creates an instance of {@code AnnotationValues} for the provided AST Node.
@param type An annotation class type, such as {@code lombok.Getter.class}.
@param node A Lombok AST node representing an annotation in source code. | [
"Creates",
"an",
"instance",
"of",
"{",
"@code",
"AnnotationValues",
"}",
"for",
"the",
"provided",
"AST",
"Node",
"."
] | train | https://github.com/rzwitserloot/lombok/blob/75601240760bd81ff95fcde7a1b8185769ce64e8/src/core/lombok/javac/handlers/JavacHandlerUtil.java#L350-L352 |
Coveros/selenified | src/main/java/com/coveros/selenified/Selenified.java | Selenified.setAppURL | protected static void setAppURL(Selenified clazz, ITestContext context, String siteURL) {
context.setAttribute(clazz.getClass().getName() + APP_URL, siteURL);
} | java | protected static void setAppURL(Selenified clazz, ITestContext context, String siteURL) {
context.setAttribute(clazz.getClass().getName() + APP_URL, siteURL);
} | [
"protected",
"static",
"void",
"setAppURL",
"(",
"Selenified",
"clazz",
",",
"ITestContext",
"context",
",",
"String",
"siteURL",
")",
"{",
"context",
".",
"setAttribute",
"(",
"clazz",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"APP_URL",
"... | Sets the URL of the application under test. If the site was provided as a
system property, this method ignores the passed in value, and uses the
system property.
@param clazz - the test suite class, used for making threadsafe storage of
application, allowing suites to have independent applications
under test, run at the same time
@param context - the TestNG context associated with the test suite, used for
storing app url information
@param siteURL - the URL of the application under test | [
"Sets",
"the",
"URL",
"of",
"the",
"application",
"under",
"test",
".",
"If",
"the",
"site",
"was",
"provided",
"as",
"a",
"system",
"property",
"this",
"method",
"ignores",
"the",
"passed",
"in",
"value",
"and",
"uses",
"the",
"system",
"property",
"."
] | train | https://github.com/Coveros/selenified/blob/396cc1f010dd69eed33cc5061c41253de246a4cd/src/main/java/com/coveros/selenified/Selenified.java#L106-L108 |
rzwitserloot/lombok | src/core/lombok/eclipse/handlers/HandleGetter.java | HandleGetter.generateGetterForField | public void generateGetterForField(EclipseNode fieldNode, ASTNode pos, AccessLevel level, boolean lazy, List<Annotation> onMethod) {
if (hasAnnotation(Getter.class, fieldNode)) {
//The annotation will make it happen, so we can skip it.
return;
}
createGetterForField(level, fieldNode, fieldNode, pos, false, lazy, onMethod);
} | java | public void generateGetterForField(EclipseNode fieldNode, ASTNode pos, AccessLevel level, boolean lazy, List<Annotation> onMethod) {
if (hasAnnotation(Getter.class, fieldNode)) {
//The annotation will make it happen, so we can skip it.
return;
}
createGetterForField(level, fieldNode, fieldNode, pos, false, lazy, onMethod);
} | [
"public",
"void",
"generateGetterForField",
"(",
"EclipseNode",
"fieldNode",
",",
"ASTNode",
"pos",
",",
"AccessLevel",
"level",
",",
"boolean",
"lazy",
",",
"List",
"<",
"Annotation",
">",
"onMethod",
")",
"{",
"if",
"(",
"hasAnnotation",
"(",
"Getter",
".",
... | Generates a getter on the stated field.
Used by {@link HandleData}.
The difference between this call and the handle method is as follows:
If there is a {@code lombok.Getter} annotation on the field, it is used and the
same rules apply (e.g. warning if the method already exists, stated access level applies).
If not, the getter is still generated if it isn't already there, though there will not
be a warning if its already there. The default access level is used. | [
"Generates",
"a",
"getter",
"on",
"the",
"stated",
"field",
"."
] | train | https://github.com/rzwitserloot/lombok/blob/75601240760bd81ff95fcde7a1b8185769ce64e8/src/core/lombok/eclipse/handlers/HandleGetter.java#L125-L132 |
PeterisP/LVTagger | src/main/java/edu/stanford/nlp/util/StringUtils.java | StringUtils.argsToMap | public static Map<String, String[]> argsToMap(String[] args) {
return argsToMap(args, new HashMap<String, Integer>());
} | java | public static Map<String, String[]> argsToMap(String[] args) {
return argsToMap(args, new HashMap<String, Integer>());
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"argsToMap",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"return",
"argsToMap",
"(",
"args",
",",
"new",
"HashMap",
"<",
"String",
",",
"Integer",
">",
"(",
")",
")",
";",
"}"
] | Parses command line arguments into a Map. Arguments of the form
<p/>
-flag1 arg1a arg1b ... arg1m -flag2 -flag3 arg3a ... arg3n
<p/>
will be parsed so that the flag is a key in the Map (including
the hyphen) and its value will be a {@link String}[] containing
the optional arguments (if present). The non-flag values not
captured as flag arguments are collected into a String[] array
and returned as the value of <code>null</code> in the Map. In
this invocation, flags cannot take arguments, so all the {@link
String} array values other than the value for <code>null</code>
will be zero-length.
@param args A command-line arguments array
@return a {@link Map} of flag names to flag argument {@link
String} arrays. | [
"Parses",
"command",
"line",
"arguments",
"into",
"a",
"Map",
".",
"Arguments",
"of",
"the",
"form",
"<p",
"/",
">",
"-",
"flag1",
"arg1a",
"arg1b",
"...",
"arg1m",
"-",
"flag2",
"-",
"flag3",
"arg3a",
"...",
"arg3n",
"<p",
"/",
">",
"will",
"be",
"p... | train | https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/util/StringUtils.java#L629-L631 |
marklogic/java-client-api | marklogic-client-api/src/main/java/com/marklogic/client/impl/ServerEvaluationCallImpl.java | ServerEvaluationCallImpl.addVariableAs | @Override
public ServerEvaluationCall addVariableAs(String name, Object value) {
if (value == null) return this;
Class<?> as = value.getClass();
AbstractWriteHandle writeHandle = null;
if (AbstractWriteHandle.class.isAssignableFrom(as)) {
writeHandle = (AbstractWriteHandle) value;
} else {
ContentHandle<?> contentHandle = handleRegistry.makeHandle(as);
Utilities.setHandleContent(contentHandle, value);
writeHandle = contentHandle;
}
return addVariable(name, writeHandle);
} | java | @Override
public ServerEvaluationCall addVariableAs(String name, Object value) {
if (value == null) return this;
Class<?> as = value.getClass();
AbstractWriteHandle writeHandle = null;
if (AbstractWriteHandle.class.isAssignableFrom(as)) {
writeHandle = (AbstractWriteHandle) value;
} else {
ContentHandle<?> contentHandle = handleRegistry.makeHandle(as);
Utilities.setHandleContent(contentHandle, value);
writeHandle = contentHandle;
}
return addVariable(name, writeHandle);
} | [
"@",
"Override",
"public",
"ServerEvaluationCall",
"addVariableAs",
"(",
"String",
"name",
",",
"Object",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"return",
"this",
";",
"Class",
"<",
"?",
">",
"as",
"=",
"value",
".",
"getClass",
"(",
... | Like other *As convenience methods throughout the API, the Object value
is managed by the Handle registered for that Class. | [
"Like",
"other",
"*",
"As",
"convenience",
"methods",
"throughout",
"the",
"API",
"the",
"Object",
"value",
"is",
"managed",
"by",
"the",
"Handle",
"registered",
"for",
"that",
"Class",
"."
] | train | https://github.com/marklogic/java-client-api/blob/acf60229a928abd4a8cc4b21b641d56957467da7/marklogic-client-api/src/main/java/com/marklogic/client/impl/ServerEvaluationCallImpl.java#L114-L128 |
cdk/cdk | descriptor/qsaratomic/src/main/java/org/openscience/cdk/qsar/descriptors/atomic/ProtonTotalPartialChargeDescriptor.java | ProtonTotalPartialChargeDescriptor.calculate | @Override
public DescriptorValue calculate(IAtom atom, IAtomContainer ac) {
neighboors = ac.getConnectedAtomsList(atom);
IAtomContainer clone;
try {
clone = (IAtomContainer) ac.clone();
} catch (CloneNotSupportedException e) {
return getDummyDescriptorValue(e);
}
try {
peoe = new GasteigerMarsiliPartialCharges();
peoe.setMaxGasteigerIters(6);
// HydrogenAdder hAdder = new HydrogenAdder();
// hAdder.addExplicitHydrogensToSatisfyValency(mol);
peoe.assignGasteigerMarsiliSigmaPartialCharges(clone, true);
} catch (Exception exception) {
return getDummyDescriptorValue(exception);
}
IAtom localAtom = clone.getAtom(ac.indexOf(atom));
neighboors = clone.getConnectedAtomsList(localAtom);
// we assume that an atom has a mxa number of protons = MAX_PROTON_COUNT
// if it has less, we pad with NaN
DoubleArrayResult protonPartialCharge = new DoubleArrayResult(MAX_PROTON_COUNT);
assert (neighboors.size() < MAX_PROTON_COUNT);
protonPartialCharge.add(localAtom.getCharge());
int hydrogenNeighbors = 0;
for (IAtom neighboor : neighboors) {
if (neighboor.getSymbol().equals("H")) {
hydrogenNeighbors++;
protonPartialCharge.add(neighboor.getCharge());
}
}
int remainder = MAX_PROTON_COUNT - (hydrogenNeighbors + 1);
for (int i = 0; i < remainder; i++)
protonPartialCharge.add(Double.NaN);
return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), protonPartialCharge,
getDescriptorNames());
} | java | @Override
public DescriptorValue calculate(IAtom atom, IAtomContainer ac) {
neighboors = ac.getConnectedAtomsList(atom);
IAtomContainer clone;
try {
clone = (IAtomContainer) ac.clone();
} catch (CloneNotSupportedException e) {
return getDummyDescriptorValue(e);
}
try {
peoe = new GasteigerMarsiliPartialCharges();
peoe.setMaxGasteigerIters(6);
// HydrogenAdder hAdder = new HydrogenAdder();
// hAdder.addExplicitHydrogensToSatisfyValency(mol);
peoe.assignGasteigerMarsiliSigmaPartialCharges(clone, true);
} catch (Exception exception) {
return getDummyDescriptorValue(exception);
}
IAtom localAtom = clone.getAtom(ac.indexOf(atom));
neighboors = clone.getConnectedAtomsList(localAtom);
// we assume that an atom has a mxa number of protons = MAX_PROTON_COUNT
// if it has less, we pad with NaN
DoubleArrayResult protonPartialCharge = new DoubleArrayResult(MAX_PROTON_COUNT);
assert (neighboors.size() < MAX_PROTON_COUNT);
protonPartialCharge.add(localAtom.getCharge());
int hydrogenNeighbors = 0;
for (IAtom neighboor : neighboors) {
if (neighboor.getSymbol().equals("H")) {
hydrogenNeighbors++;
protonPartialCharge.add(neighboor.getCharge());
}
}
int remainder = MAX_PROTON_COUNT - (hydrogenNeighbors + 1);
for (int i = 0; i < remainder; i++)
protonPartialCharge.add(Double.NaN);
return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), protonPartialCharge,
getDescriptorNames());
} | [
"@",
"Override",
"public",
"DescriptorValue",
"calculate",
"(",
"IAtom",
"atom",
",",
"IAtomContainer",
"ac",
")",
"{",
"neighboors",
"=",
"ac",
".",
"getConnectedAtomsList",
"(",
"atom",
")",
";",
"IAtomContainer",
"clone",
";",
"try",
"{",
"clone",
"=",
"(... | The method returns partial charges assigned to an heavy atom and its protons through Gasteiger Marsili
It is needed to call the addExplicitHydrogensToSatisfyValency method from the class tools.HydrogenAdder.
@param atom The IAtom for which the DescriptorValue is requested
@param ac AtomContainer
@return an array of doubles with partial charges of [heavy, proton_1 ... proton_n] | [
"The",
"method",
"returns",
"partial",
"charges",
"assigned",
"to",
"an",
"heavy",
"atom",
"and",
"its",
"protons",
"through",
"Gasteiger",
"Marsili",
"It",
"is",
"needed",
"to",
"call",
"the",
"addExplicitHydrogensToSatisfyValency",
"method",
"from",
"the",
"clas... | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/descriptor/qsaratomic/src/main/java/org/openscience/cdk/qsar/descriptors/atomic/ProtonTotalPartialChargeDescriptor.java#L116-L159 |
cdk/cdk | display/renderbasic/src/main/java/org/openscience/cdk/renderer/AbstractRenderer.java | AbstractRenderer.shiftDrawCenter | public void shiftDrawCenter(double shiftX, double shiftY) {
drawCenter.set(drawCenter.x + shiftX, drawCenter.y + shiftY);
setup();
} | java | public void shiftDrawCenter(double shiftX, double shiftY) {
drawCenter.set(drawCenter.x + shiftX, drawCenter.y + shiftY);
setup();
} | [
"public",
"void",
"shiftDrawCenter",
"(",
"double",
"shiftX",
",",
"double",
"shiftY",
")",
"{",
"drawCenter",
".",
"set",
"(",
"drawCenter",
".",
"x",
"+",
"shiftX",
",",
"drawCenter",
".",
"y",
"+",
"shiftY",
")",
";",
"setup",
"(",
")",
";",
"}"
] | Move the draw center by dx and dy.
@param shiftX the x shift
@param shiftY the y shift | [
"Move",
"the",
"draw",
"center",
"by",
"dx",
"and",
"dy",
"."
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/display/renderbasic/src/main/java/org/openscience/cdk/renderer/AbstractRenderer.java#L260-L263 |
elki-project/elki | elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/StatisticalMoments.java | StatisticalMoments.put | @Override
public void put(double val, double weight) {
if(weight <= 0) {
return;
}
if(this.n == 0) {
n = weight;
min = max = val;
sum = val * weight;
m2 = m3 = m4 = 0;
return;
}
final double nn = weight + this.n;
final double deltan = val * this.n - this.sum;
final double inc = deltan * weight;
// Some factors used below:
final double delta_nn = deltan / (this.n * nn);
final double delta_nnw = delta_nn * weight;
final double delta_nn2 = delta_nn * delta_nn;
final double delta_nn3 = delta_nn2 * delta_nn;
final double nb2 = weight * weight;
final double tmp1 = this.n - weight;
final double tmp2 = this.n * tmp1 + nb2;
this.m4 += inc * delta_nn3 * tmp2 + 6. * nb2 * this.m2 * delta_nn2 - 4. * this.m3 * delta_nnw;
this.m3 += inc * delta_nn2 * tmp1 - 3. * this.m2 * delta_nnw;
this.m2 += inc * delta_nn;
this.sum += weight * val;
this.n = nn;
min = val < min ? val : min;
max = val > max ? val : max;
} | java | @Override
public void put(double val, double weight) {
if(weight <= 0) {
return;
}
if(this.n == 0) {
n = weight;
min = max = val;
sum = val * weight;
m2 = m3 = m4 = 0;
return;
}
final double nn = weight + this.n;
final double deltan = val * this.n - this.sum;
final double inc = deltan * weight;
// Some factors used below:
final double delta_nn = deltan / (this.n * nn);
final double delta_nnw = delta_nn * weight;
final double delta_nn2 = delta_nn * delta_nn;
final double delta_nn3 = delta_nn2 * delta_nn;
final double nb2 = weight * weight;
final double tmp1 = this.n - weight;
final double tmp2 = this.n * tmp1 + nb2;
this.m4 += inc * delta_nn3 * tmp2 + 6. * nb2 * this.m2 * delta_nn2 - 4. * this.m3 * delta_nnw;
this.m3 += inc * delta_nn2 * tmp1 - 3. * this.m2 * delta_nnw;
this.m2 += inc * delta_nn;
this.sum += weight * val;
this.n = nn;
min = val < min ? val : min;
max = val > max ? val : max;
} | [
"@",
"Override",
"public",
"void",
"put",
"(",
"double",
"val",
",",
"double",
"weight",
")",
"{",
"if",
"(",
"weight",
"<=",
"0",
")",
"{",
"return",
";",
"}",
"if",
"(",
"this",
".",
"n",
"==",
"0",
")",
"{",
"n",
"=",
"weight",
";",
"min",
... | Add data with a given weight.
@param val data
@param weight weight | [
"Add",
"data",
"with",
"a",
"given",
"weight",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/StatisticalMoments.java#L149-L182 |
pgjdbc/pgjdbc | pgjdbc/src/main/java/org/postgresql/jdbc/EscapedFunctions2.java | EscapedFunctions2.sqltruncate | public static void sqltruncate(StringBuilder buf, List<? extends CharSequence> parsedArgs) throws SQLException {
twoArgumentsFunctionCall(buf, "trunc(", "truncate", parsedArgs);
} | java | public static void sqltruncate(StringBuilder buf, List<? extends CharSequence> parsedArgs) throws SQLException {
twoArgumentsFunctionCall(buf, "trunc(", "truncate", parsedArgs);
} | [
"public",
"static",
"void",
"sqltruncate",
"(",
"StringBuilder",
"buf",
",",
"List",
"<",
"?",
"extends",
"CharSequence",
">",
"parsedArgs",
")",
"throws",
"SQLException",
"{",
"twoArgumentsFunctionCall",
"(",
"buf",
",",
"\"trunc(\"",
",",
"\"truncate\"",
",",
... | truncate to trunc translation
@param buf The buffer to append into
@param parsedArgs arguments
@throws SQLException if something wrong happens | [
"truncate",
"to",
"trunc",
"translation"
] | train | https://github.com/pgjdbc/pgjdbc/blob/95ba7b261e39754674c5817695ae5ebf9a341fae/pgjdbc/src/main/java/org/postgresql/jdbc/EscapedFunctions2.java#L131-L133 |
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.beginStartEnvironmentAsync | public Observable<Void> beginStartEnvironmentAsync(String userName, String environmentId) {
return beginStartEnvironmentWithServiceResponseAsync(userName, environmentId).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | java | public Observable<Void> beginStartEnvironmentAsync(String userName, String environmentId) {
return beginStartEnvironmentWithServiceResponseAsync(userName, environmentId).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Void",
">",
"beginStartEnvironmentAsync",
"(",
"String",
"userName",
",",
"String",
"environmentId",
")",
"{",
"return",
"beginStartEnvironmentWithServiceResponseAsync",
"(",
"userName",
",",
"environmentId",
")",
".",
"map",
"(",
"new",
... | Starts an environment by starting all resources inside the environment. This operation can take a while to complete.
@param userName The name of the user.
@param environmentId The resourceId of the environment
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful. | [
"Starts",
"an",
"environment",
"by",
"starting",
"all",
"resources",
"inside",
"the",
"environment",
".",
"This",
"operation",
"can",
"take",
"a",
"while",
"to",
"complete",
"."
] | 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#L1174-L1181 |
citrusframework/citrus | modules/citrus-core/src/main/java/com/consol/citrus/actions/ExecutePLSQLAction.java | ExecutePLSQLAction.createStatementsFromScript | private List<String> createStatementsFromScript(TestContext context) {
List<String> stmts = new ArrayList<>();
script = context.replaceDynamicContentInString(script);
if (log.isDebugEnabled()) {
log.debug("Found inline PLSQL script " + script);
}
StringTokenizer tok = new StringTokenizer(script, PLSQL_STMT_ENDING);
while (tok.hasMoreTokens()) {
String next = tok.nextToken().trim();
if (StringUtils.hasText(next)) {
stmts.add(next);
}
}
return stmts;
} | java | private List<String> createStatementsFromScript(TestContext context) {
List<String> stmts = new ArrayList<>();
script = context.replaceDynamicContentInString(script);
if (log.isDebugEnabled()) {
log.debug("Found inline PLSQL script " + script);
}
StringTokenizer tok = new StringTokenizer(script, PLSQL_STMT_ENDING);
while (tok.hasMoreTokens()) {
String next = tok.nextToken().trim();
if (StringUtils.hasText(next)) {
stmts.add(next);
}
}
return stmts;
} | [
"private",
"List",
"<",
"String",
">",
"createStatementsFromScript",
"(",
"TestContext",
"context",
")",
"{",
"List",
"<",
"String",
">",
"stmts",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"script",
"=",
"context",
".",
"replaceDynamicContentInString",
"("... | Create SQL statements from inline script.
@param context the current test context.
@return list of SQL statements. | [
"Create",
"SQL",
"statements",
"from",
"inline",
"script",
"."
] | train | https://github.com/citrusframework/citrus/blob/55c58ef74c01d511615e43646ca25c1b2301c56d/modules/citrus-core/src/main/java/com/consol/citrus/actions/ExecutePLSQLAction.java#L119-L136 |
b3dgs/lionengine | lionengine-core/src/main/java/com/b3dgs/lionengine/UtilFile.java | UtilFile.isType | public static boolean isType(File file, String extension)
{
Check.notNull(extension);
if (file != null && file.isFile())
{
final String current = getExtension(file);
return current.equals(extension.replace(Constant.DOT, Constant.EMPTY_STRING));
}
return false;
} | java | public static boolean isType(File file, String extension)
{
Check.notNull(extension);
if (file != null && file.isFile())
{
final String current = getExtension(file);
return current.equals(extension.replace(Constant.DOT, Constant.EMPTY_STRING));
}
return false;
} | [
"public",
"static",
"boolean",
"isType",
"(",
"File",
"file",
",",
"String",
"extension",
")",
"{",
"Check",
".",
"notNull",
"(",
"extension",
")",
";",
"if",
"(",
"file",
"!=",
"null",
"&&",
"file",
".",
"isFile",
"(",
")",
")",
"{",
"final",
"Strin... | Check if the following type is the expected type.
@param file The file to check (can be <code>null</code>).
@param extension The expected extension (must not be <code>null</code>).
@return <code>true</code> if correct, <code>false</code> else.
@throws LionEngineException If invalid argument. | [
"Check",
"if",
"the",
"following",
"type",
"is",
"the",
"expected",
"type",
"."
] | train | https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-core/src/main/java/com/b3dgs/lionengine/UtilFile.java#L233-L243 |
Azure/azure-sdk-for-java | containerinstance/resource-manager/v2018_02_01_preview/src/main/java/com/microsoft/azure/management/containerinstance/v2018_02_01_preview/implementation/ContainerGroupsInner.java | ContainerGroupsInner.getByResourceGroup | public ContainerGroupInner getByResourceGroup(String resourceGroupName, String containerGroupName) {
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, containerGroupName).toBlocking().single().body();
} | java | public ContainerGroupInner getByResourceGroup(String resourceGroupName, String containerGroupName) {
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, containerGroupName).toBlocking().single().body();
} | [
"public",
"ContainerGroupInner",
"getByResourceGroup",
"(",
"String",
"resourceGroupName",
",",
"String",
"containerGroupName",
")",
"{",
"return",
"getByResourceGroupWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"containerGroupName",
")",
".",
"toBlocking",
"(",
... | Get the properties of the specified container group.
Gets the properties of the specified container group in the specified subscription and resource group. The operation returns the properties of each container group including containers, image registry credentials, restart policy, IP address type, OS type, state, and volumes.
@param resourceGroupName The name of the resource group.
@param containerGroupName The name of the container group.
@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 ContainerGroupInner object if successful. | [
"Get",
"the",
"properties",
"of",
"the",
"specified",
"container",
"group",
".",
"Gets",
"the",
"properties",
"of",
"the",
"specified",
"container",
"group",
"in",
"the",
"specified",
"subscription",
"and",
"resource",
"group",
".",
"The",
"operation",
"returns"... | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/containerinstance/resource-manager/v2018_02_01_preview/src/main/java/com/microsoft/azure/management/containerinstance/v2018_02_01_preview/implementation/ContainerGroupsInner.java#L350-L352 |
jbundle/jbundle | base/screen/model/src/main/java/org/jbundle/base/screen/model/BasePanel.java | BasePanel.onForm | public BasePanel onForm(Record recordMain, int iDocMode, boolean bReadCurrentRecord, int iCommandOptions, Map<String,Object> properties)
{
boolean bLinkGridToQuery = false;
if ((iCommandOptions & ScreenConstants.USE_NEW_WINDOW) == ScreenConstants.USE_NEW_WINDOW)
bLinkGridToQuery = true;
return this.onForm(recordMain, iDocMode, bReadCurrentRecord, iCommandOptions, bLinkGridToQuery, properties);
} | java | public BasePanel onForm(Record recordMain, int iDocMode, boolean bReadCurrentRecord, int iCommandOptions, Map<String,Object> properties)
{
boolean bLinkGridToQuery = false;
if ((iCommandOptions & ScreenConstants.USE_NEW_WINDOW) == ScreenConstants.USE_NEW_WINDOW)
bLinkGridToQuery = true;
return this.onForm(recordMain, iDocMode, bReadCurrentRecord, iCommandOptions, bLinkGridToQuery, properties);
} | [
"public",
"BasePanel",
"onForm",
"(",
"Record",
"recordMain",
",",
"int",
"iDocMode",
",",
"boolean",
"bReadCurrentRecord",
",",
"int",
"iCommandOptions",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"properties",
")",
"{",
"boolean",
"bLinkGridToQuery",
"=",
... | Create a data entry screen with this main record.
(null means use this screen's main record)
@param recordMain The main record for the new form.
@param iDocMode The document type of the new form.
@param bReadCurrentRecord Sync the new screen with my current record?
@param bUseSameWindow Use the same window?
@return true if successful. | [
"Create",
"a",
"data",
"entry",
"screen",
"with",
"this",
"main",
"record",
".",
"(",
"null",
"means",
"use",
"this",
"screen",
"s",
"main",
"record",
")"
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/model/src/main/java/org/jbundle/base/screen/model/BasePanel.java#L808-L814 |
liferay/com-liferay-commerce | commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPMeasurementUnitPersistenceImpl.java | CPMeasurementUnitPersistenceImpl.countByG_K_T | @Override
public int countByG_K_T(long groupId, String key, int type) {
FinderPath finderPath = FINDER_PATH_COUNT_BY_G_K_T;
Object[] finderArgs = new Object[] { groupId, key, type };
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_COUNT_CPMEASUREMENTUNIT_WHERE);
query.append(_FINDER_COLUMN_G_K_T_GROUPID_2);
boolean bindKey = false;
if (key == null) {
query.append(_FINDER_COLUMN_G_K_T_KEY_1);
}
else if (key.equals("")) {
query.append(_FINDER_COLUMN_G_K_T_KEY_3);
}
else {
bindKey = true;
query.append(_FINDER_COLUMN_G_K_T_KEY_2);
}
query.append(_FINDER_COLUMN_G_K_T_TYPE_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
if (bindKey) {
qPos.add(StringUtil.toLowerCase(key));
}
qPos.add(type);
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_K_T(long groupId, String key, int type) {
FinderPath finderPath = FINDER_PATH_COUNT_BY_G_K_T;
Object[] finderArgs = new Object[] { groupId, key, type };
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_COUNT_CPMEASUREMENTUNIT_WHERE);
query.append(_FINDER_COLUMN_G_K_T_GROUPID_2);
boolean bindKey = false;
if (key == null) {
query.append(_FINDER_COLUMN_G_K_T_KEY_1);
}
else if (key.equals("")) {
query.append(_FINDER_COLUMN_G_K_T_KEY_3);
}
else {
bindKey = true;
query.append(_FINDER_COLUMN_G_K_T_KEY_2);
}
query.append(_FINDER_COLUMN_G_K_T_TYPE_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
if (bindKey) {
qPos.add(StringUtil.toLowerCase(key));
}
qPos.add(type);
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_K_T",
"(",
"long",
"groupId",
",",
"String",
"key",
",",
"int",
"type",
")",
"{",
"FinderPath",
"finderPath",
"=",
"FINDER_PATH_COUNT_BY_G_K_T",
";",
"Object",
"[",
"]",
"finderArgs",
"=",
"new",
"Object",
"[",
"]"... | Returns the number of cp measurement units where groupId = ? and key = ? and type = ?.
@param groupId the group ID
@param key the key
@param type the type
@return the number of matching cp measurement units | [
"Returns",
"the",
"number",
"of",
"cp",
"measurement",
"units",
"where",
"groupId",
"=",
"?",
";",
"and",
"key",
"=",
"?",
";",
"and",
"type",
"=",
"?",
";",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPMeasurementUnitPersistenceImpl.java#L2740-L2805 |
google/error-prone-javac | src/jdk.compiler/share/classes/com/sun/tools/javac/file/PathFileObject.java | PathFileObject.forDirectoryPath | static PathFileObject forDirectoryPath(BaseFileManager fileManager, Path path,
Path userPackageRootDir, RelativePath relativePath) {
return new DirectoryFileObject(fileManager, path, userPackageRootDir, relativePath);
} | java | static PathFileObject forDirectoryPath(BaseFileManager fileManager, Path path,
Path userPackageRootDir, RelativePath relativePath) {
return new DirectoryFileObject(fileManager, path, userPackageRootDir, relativePath);
} | [
"static",
"PathFileObject",
"forDirectoryPath",
"(",
"BaseFileManager",
"fileManager",
",",
"Path",
"path",
",",
"Path",
"userPackageRootDir",
",",
"RelativePath",
"relativePath",
")",
"{",
"return",
"new",
"DirectoryFileObject",
"(",
"fileManager",
",",
"path",
",",
... | Create a PathFileObject for a file within a directory, such that the
binary name can be inferred from the relationship to an enclosing directory.
The binary name is derived from {@code relativePath}.
The name is derived from the composition of {@code userPackageRootDir}
and {@code relativePath}.
@param fileManager the file manager creating this file object
@param path the absolute path referred to by this file object
@param userPackageRootDir the path of the directory containing the
root of the package hierarchy
@param relativePath the path of this file relative to {@code userPackageRootDir} | [
"Create",
"a",
"PathFileObject",
"for",
"a",
"file",
"within",
"a",
"directory",
"such",
"that",
"the",
"binary",
"name",
"can",
"be",
"inferred",
"from",
"the",
"relationship",
"to",
"an",
"enclosing",
"directory",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.compiler/share/classes/com/sun/tools/javac/file/PathFileObject.java#L100-L103 |
graknlabs/grakn | server/src/server/keyspace/KeyspaceManager.java | KeyspaceManager.putKeyspace | public void putKeyspace(KeyspaceImpl keyspace) {
if (containsKeyspace(keyspace)) return;
try (TransactionOLTP tx = systemKeyspaceSession.transaction().write()) {
AttributeType<String> keyspaceName = tx.getSchemaConcept(KEYSPACE_RESOURCE);
if (keyspaceName == null) {
throw GraknServerException.initializationException(keyspace);
}
Attribute<String> attribute = keyspaceName.create(keyspace.name());
if (attribute.owner() == null) {
tx.<EntityType>getSchemaConcept(KEYSPACE_ENTITY).create().has(attribute);
}
tx.commit();
// add to cache
existingKeyspaces.add(keyspace);
} catch (InvalidKBException e) {
throw new RuntimeException("Could not add keyspace [" + keyspace + "] to system graph", e);
}
} | java | public void putKeyspace(KeyspaceImpl keyspace) {
if (containsKeyspace(keyspace)) return;
try (TransactionOLTP tx = systemKeyspaceSession.transaction().write()) {
AttributeType<String> keyspaceName = tx.getSchemaConcept(KEYSPACE_RESOURCE);
if (keyspaceName == null) {
throw GraknServerException.initializationException(keyspace);
}
Attribute<String> attribute = keyspaceName.create(keyspace.name());
if (attribute.owner() == null) {
tx.<EntityType>getSchemaConcept(KEYSPACE_ENTITY).create().has(attribute);
}
tx.commit();
// add to cache
existingKeyspaces.add(keyspace);
} catch (InvalidKBException e) {
throw new RuntimeException("Could not add keyspace [" + keyspace + "] to system graph", e);
}
} | [
"public",
"void",
"putKeyspace",
"(",
"KeyspaceImpl",
"keyspace",
")",
"{",
"if",
"(",
"containsKeyspace",
"(",
"keyspace",
")",
")",
"return",
";",
"try",
"(",
"TransactionOLTP",
"tx",
"=",
"systemKeyspaceSession",
".",
"transaction",
"(",
")",
".",
"write",
... | Logs a new KeyspaceImpl to the KeyspaceManager.
@param keyspace The new KeyspaceImpl we have just created | [
"Logs",
"a",
"new",
"KeyspaceImpl",
"to",
"the",
"KeyspaceManager",
"."
] | train | https://github.com/graknlabs/grakn/blob/6aaee75ea846202474d591f8809d62028262fac5/server/src/server/keyspace/KeyspaceManager.java#L72-L91 |
eclipse/xtext-extras | org.eclipse.xtext.xbase/src/org/eclipse/xtext/xbase/typesystem/internal/FeatureLinkingCandidate.java | FeatureLinkingCandidate.getArguments | @Override
protected List<XExpression> getArguments() {
List<XExpression> syntacticArguments = getSyntacticArguments();
XExpression firstArgument = getFirstArgument();
if (firstArgument != null) {
return createArgumentList(firstArgument, syntacticArguments);
}
return syntacticArguments;
} | java | @Override
protected List<XExpression> getArguments() {
List<XExpression> syntacticArguments = getSyntacticArguments();
XExpression firstArgument = getFirstArgument();
if (firstArgument != null) {
return createArgumentList(firstArgument, syntacticArguments);
}
return syntacticArguments;
} | [
"@",
"Override",
"protected",
"List",
"<",
"XExpression",
">",
"getArguments",
"(",
")",
"{",
"List",
"<",
"XExpression",
">",
"syntacticArguments",
"=",
"getSyntacticArguments",
"(",
")",
";",
"XExpression",
"firstArgument",
"=",
"getFirstArgument",
"(",
")",
"... | Returns the actual arguments of the expression. These do not include the
receiver. | [
"Returns",
"the",
"actual",
"arguments",
"of",
"the",
"expression",
".",
"These",
"do",
"not",
"include",
"the",
"receiver",
"."
] | train | https://github.com/eclipse/xtext-extras/blob/451359541295323a29f5855e633f770cec02069a/org.eclipse.xtext.xbase/src/org/eclipse/xtext/xbase/typesystem/internal/FeatureLinkingCandidate.java#L122-L130 |
Red5/red5-server-common | src/main/java/org/red5/server/stream/StreamService.java | StreamService.play2 | public void play2(String oldStreamName, int start, String transition, int length, double offset, String streamName) {
Map<String, Object> playOptions = new HashMap<String, Object>();
playOptions.put("oldStreamName", oldStreamName);
playOptions.put("streamName", streamName);
playOptions.put("start", start);
playOptions.put("len", length);
playOptions.put("offset", offset);
play2(playOptions);
} | java | public void play2(String oldStreamName, int start, String transition, int length, double offset, String streamName) {
Map<String, Object> playOptions = new HashMap<String, Object>();
playOptions.put("oldStreamName", oldStreamName);
playOptions.put("streamName", streamName);
playOptions.put("start", start);
playOptions.put("len", length);
playOptions.put("offset", offset);
play2(playOptions);
} | [
"public",
"void",
"play2",
"(",
"String",
"oldStreamName",
",",
"int",
"start",
",",
"String",
"transition",
",",
"int",
"length",
",",
"double",
"offset",
",",
"String",
"streamName",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"playOptions",
"=",... | Dynamic streaming play method. This is a convenience method.
@param oldStreamName
old
@param start
start pos
@param transition
type of transition
@param length
length to play
@param offset
offset
@param streamName
stream name | [
"Dynamic",
"streaming",
"play",
"method",
".",
"This",
"is",
"a",
"convenience",
"method",
"."
] | train | https://github.com/Red5/red5-server-common/blob/39ae73710c25bda86d70b13ef37ae707962217b9/src/main/java/org/red5/server/stream/StreamService.java#L462-L470 |
Azure/azure-sdk-for-java | sql/resource-manager/v2015_05_01_preview/src/main/java/com/microsoft/azure/management/sql/v2015_05_01_preview/implementation/EncryptionProtectorsInner.java | EncryptionProtectorsInner.listByServerAsync | public Observable<Page<EncryptionProtectorInner>> listByServerAsync(final String resourceGroupName, final String serverName) {
return listByServerWithServiceResponseAsync(resourceGroupName, serverName)
.map(new Func1<ServiceResponse<Page<EncryptionProtectorInner>>, Page<EncryptionProtectorInner>>() {
@Override
public Page<EncryptionProtectorInner> call(ServiceResponse<Page<EncryptionProtectorInner>> response) {
return response.body();
}
});
} | java | public Observable<Page<EncryptionProtectorInner>> listByServerAsync(final String resourceGroupName, final String serverName) {
return listByServerWithServiceResponseAsync(resourceGroupName, serverName)
.map(new Func1<ServiceResponse<Page<EncryptionProtectorInner>>, Page<EncryptionProtectorInner>>() {
@Override
public Page<EncryptionProtectorInner> call(ServiceResponse<Page<EncryptionProtectorInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Page",
"<",
"EncryptionProtectorInner",
">",
">",
"listByServerAsync",
"(",
"final",
"String",
"resourceGroupName",
",",
"final",
"String",
"serverName",
")",
"{",
"return",
"listByServerWithServiceResponseAsync",
"(",
"resourceGroupName",
... | Gets a list of server encryption protectors.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<EncryptionProtectorInner> object | [
"Gets",
"a",
"list",
"of",
"server",
"encryption",
"protectors",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2015_05_01_preview/src/main/java/com/microsoft/azure/management/sql/v2015_05_01_preview/implementation/EncryptionProtectorsInner.java#L134-L142 |
apache/reef | lang/java/reef-applications/reef-vortex/src/main/java/org/apache/reef/vortex/driver/VortexRequestor.java | VortexRequestor.sendAsync | void sendAsync(final RunningTask reefTask, final MasterToWorkerRequest masterToWorkerRequest) {
executorService.execute(new Runnable() {
@Override
public void run() {
// Possible race condition with VortexWorkerManager#terminate is addressed by the global lock in VortexMaster
send(reefTask, masterToWorkerRequest);
}
});
} | java | void sendAsync(final RunningTask reefTask, final MasterToWorkerRequest masterToWorkerRequest) {
executorService.execute(new Runnable() {
@Override
public void run() {
// Possible race condition with VortexWorkerManager#terminate is addressed by the global lock in VortexMaster
send(reefTask, masterToWorkerRequest);
}
});
} | [
"void",
"sendAsync",
"(",
"final",
"RunningTask",
"reefTask",
",",
"final",
"MasterToWorkerRequest",
"masterToWorkerRequest",
")",
"{",
"executorService",
".",
"execute",
"(",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
... | Sends a {@link MasterToWorkerRequest} asynchronously to a {@link org.apache.reef.vortex.evaluator.VortexWorker}. | [
"Sends",
"a",
"{"
] | train | https://github.com/apache/reef/blob/e2c47121cde21108a602c560cf76565a40d0e916/lang/java/reef-applications/reef-vortex/src/main/java/org/apache/reef/vortex/driver/VortexRequestor.java#L46-L54 |
jbundle/jbundle | main/msg/src/main/java/org/jbundle/main/msg/db/CalcTimeoutTimeHandler.java | CalcTimeoutTimeHandler.doRecordChange | public int doRecordChange(FieldInfo field, int iChangeType, boolean bDisplayOption)
{
switch (iChangeType)
{
case DBConstants.ADD_TYPE:
case DBConstants.UPDATE_TYPE:
if (this.getOwner().getField(MessageLog.LAST_CHANGED) != null) // Always
if (this.getOwner().getField(MessageLog.TIMEOUT_SECONDS).getValue() > 0)
if (this.getOwner().getField(MessageLog.TIMEOUT_TIME).getValue() == 0) // Don't change timeout after it was set
{
if (MessageStatus.SENT.equalsIgnoreCase(((ReferenceField)this.getOwner().getField(MessageLog.MESSAGE_STATUS_ID)).getReference().getField(MessageStatus.CODE).toString()))
{
Calendar cal = ((DateTimeField)this.getOwner().getField(MessageLog.LAST_CHANGED)).getCalendar();
int iSeconds = (int)this.getOwner().getField(MessageLog.TIMEOUT_SECONDS).getValue();
cal.add(Calendar.SECOND, iSeconds);
((DateTimeField)this.getOwner().getField(MessageLog.TIMEOUT_TIME)).setCalendar(cal, bDisplayOption, DBConstants.SCREEN_MOVE);
}
else
{ // Clear the timeout
((DateTimeField)this.getOwner().getField(MessageLog.TIMEOUT_TIME)).setData(null, bDisplayOption, DBConstants.SCREEN_MOVE);
}
}
break;
}
return super.doRecordChange(field, iChangeType, bDisplayOption);
} | java | public int doRecordChange(FieldInfo field, int iChangeType, boolean bDisplayOption)
{
switch (iChangeType)
{
case DBConstants.ADD_TYPE:
case DBConstants.UPDATE_TYPE:
if (this.getOwner().getField(MessageLog.LAST_CHANGED) != null) // Always
if (this.getOwner().getField(MessageLog.TIMEOUT_SECONDS).getValue() > 0)
if (this.getOwner().getField(MessageLog.TIMEOUT_TIME).getValue() == 0) // Don't change timeout after it was set
{
if (MessageStatus.SENT.equalsIgnoreCase(((ReferenceField)this.getOwner().getField(MessageLog.MESSAGE_STATUS_ID)).getReference().getField(MessageStatus.CODE).toString()))
{
Calendar cal = ((DateTimeField)this.getOwner().getField(MessageLog.LAST_CHANGED)).getCalendar();
int iSeconds = (int)this.getOwner().getField(MessageLog.TIMEOUT_SECONDS).getValue();
cal.add(Calendar.SECOND, iSeconds);
((DateTimeField)this.getOwner().getField(MessageLog.TIMEOUT_TIME)).setCalendar(cal, bDisplayOption, DBConstants.SCREEN_MOVE);
}
else
{ // Clear the timeout
((DateTimeField)this.getOwner().getField(MessageLog.TIMEOUT_TIME)).setData(null, bDisplayOption, DBConstants.SCREEN_MOVE);
}
}
break;
}
return super.doRecordChange(field, iChangeType, bDisplayOption);
} | [
"public",
"int",
"doRecordChange",
"(",
"FieldInfo",
"field",
",",
"int",
"iChangeType",
",",
"boolean",
"bDisplayOption",
")",
"{",
"switch",
"(",
"iChangeType",
")",
"{",
"case",
"DBConstants",
".",
"ADD_TYPE",
":",
"case",
"DBConstants",
".",
"UPDATE_TYPE",
... | Called when a change is the record status is about to happen/has happened.
@param field If this file change is due to a field, this is the field.
@param iChangeType The type of change that occurred.
@param bDisplayOption If true, display any changes.
@return an error code.
ADD_TYPE - Before a write.
UPDATE_TYPE - Before an update.
DELETE_TYPE - Before a delete.
AFTER_UPDATE_TYPE - After a write or update.
LOCK_TYPE - Before a lock.
SELECT_TYPE - After a select.
DESELECT_TYPE - After a deselect.
MOVE_NEXT_TYPE - After a move.
AFTER_REQUERY_TYPE - Record opened.
SELECT_EOF_TYPE - EOF Hit. | [
"Called",
"when",
"a",
"change",
"is",
"the",
"record",
"status",
"is",
"about",
"to",
"happen",
"/",
"has",
"happened",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/main/msg/src/main/java/org/jbundle/main/msg/db/CalcTimeoutTimeHandler.java#L73-L98 |
UrielCh/ovh-java-sdk | ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java | ApiOvhTelephony.billingAccount_easyHunting_serviceName_hunting_eventToken_POST | public String billingAccount_easyHunting_serviceName_hunting_eventToken_POST(String billingAccount, String serviceName, OvhTokenExpirationEnum expiration) throws IOException {
String qPath = "/telephony/{billingAccount}/easyHunting/{serviceName}/hunting/eventToken";
StringBuilder sb = path(qPath, billingAccount, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "expiration", expiration);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, String.class);
} | java | public String billingAccount_easyHunting_serviceName_hunting_eventToken_POST(String billingAccount, String serviceName, OvhTokenExpirationEnum expiration) throws IOException {
String qPath = "/telephony/{billingAccount}/easyHunting/{serviceName}/hunting/eventToken";
StringBuilder sb = path(qPath, billingAccount, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "expiration", expiration);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, String.class);
} | [
"public",
"String",
"billingAccount_easyHunting_serviceName_hunting_eventToken_POST",
"(",
"String",
"billingAccount",
",",
"String",
"serviceName",
",",
"OvhTokenExpirationEnum",
"expiration",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/telephony/{billingAcc... | Create a new token
REST: POST /telephony/{billingAccount}/easyHunting/{serviceName}/hunting/eventToken
@param expiration [required] Time to live in seconds for the token
@param billingAccount [required] The name of your billingAccount
@param serviceName [required] | [
"Create",
"a",
"new",
"token"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L2313-L2320 |
code4everything/util | src/main/java/com/zhazhapan/util/dialog/Alerts.java | Alerts.showWarning | public static Optional<ButtonType> showWarning(String title, String header, String content) {
return alert(title, header, content, AlertType.WARNING);
} | java | public static Optional<ButtonType> showWarning(String title, String header, String content) {
return alert(title, header, content, AlertType.WARNING);
} | [
"public",
"static",
"Optional",
"<",
"ButtonType",
">",
"showWarning",
"(",
"String",
"title",
",",
"String",
"header",
",",
"String",
"content",
")",
"{",
"return",
"alert",
"(",
"title",
",",
"header",
",",
"content",
",",
"AlertType",
".",
"WARNING",
")... | 弹出警告框
@param title 标题
@param header 信息头
@param content 内容
@return {@link ButtonType} | [
"弹出警告框"
] | train | https://github.com/code4everything/util/blob/1fc9f0ead1108f4d7208ba7c000df4244f708418/src/main/java/com/zhazhapan/util/dialog/Alerts.java#L70-L72 |
gallandarakhneorg/afc | advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d3/dfx/RectangularPrism3dfx.java | RectangularPrism3dfx.depthProperty | @Pure
public DoubleProperty depthProperty() {
if (this.depth == null) {
this.depth = new ReadOnlyDoubleWrapper(this, MathFXAttributeNames.DEPTH);
this.depth.bind(Bindings.subtract(maxZProperty(), minZProperty()));
}
return this.depth;
} | java | @Pure
public DoubleProperty depthProperty() {
if (this.depth == null) {
this.depth = new ReadOnlyDoubleWrapper(this, MathFXAttributeNames.DEPTH);
this.depth.bind(Bindings.subtract(maxZProperty(), minZProperty()));
}
return this.depth;
} | [
"@",
"Pure",
"public",
"DoubleProperty",
"depthProperty",
"(",
")",
"{",
"if",
"(",
"this",
".",
"depth",
"==",
"null",
")",
"{",
"this",
".",
"depth",
"=",
"new",
"ReadOnlyDoubleWrapper",
"(",
"this",
",",
"MathFXAttributeNames",
".",
"DEPTH",
")",
";",
... | Replies the property that is the depth of the box.
@return the depth property. | [
"Replies",
"the",
"property",
"that",
"is",
"the",
"depth",
"of",
"the",
"box",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d3/dfx/RectangularPrism3dfx.java#L404-L411 |
zaproxy/zaproxy | src/org/parosproxy/paros/network/SSLConnector.java | SSLConnector.createSocket | @Override
public Socket createSocket(final String host, final int port,
final InetAddress localAddress, final int localPort,
final HttpConnectionParams params) throws IOException,
UnknownHostException, ConnectTimeoutException {
if (params == null) {
throw new IllegalArgumentException("Parameters may not be null");
}
int timeout = params.getConnectionTimeout();
if (timeout == 0) {
InetAddress hostAddress = getCachedMisconfiguredHost(host, port);
if (hostAddress != null) {
return clientSSLSockFactory.createSocket(hostAddress, port, localAddress, localPort);
}
try {
SSLSocket sslSocket = (SSLSocket) clientSSLSockFactory.createSocket(host, port, localAddress, localPort);
sslSocket.startHandshake();
return sslSocket;
} catch (SSLException e) {
if (!e.getMessage().contains(CONTENTS_UNRECOGNIZED_NAME_EXCEPTION)) {
throw e;
}
hostAddress = InetAddress.getByName(host);
cacheMisconfiguredHost(host, port, hostAddress);
return clientSSLSockFactory.createSocket(hostAddress, port, localAddress, localPort);
}
}
Socket socket = clientSSLSockFactory.createSocket();
SocketAddress localAddr = new InetSocketAddress(localAddress, localPort);
socket.bind(localAddr);
SocketAddress remoteAddr = new InetSocketAddress(host, port);
socket.connect(remoteAddr, timeout);
return socket;
} | java | @Override
public Socket createSocket(final String host, final int port,
final InetAddress localAddress, final int localPort,
final HttpConnectionParams params) throws IOException,
UnknownHostException, ConnectTimeoutException {
if (params == null) {
throw new IllegalArgumentException("Parameters may not be null");
}
int timeout = params.getConnectionTimeout();
if (timeout == 0) {
InetAddress hostAddress = getCachedMisconfiguredHost(host, port);
if (hostAddress != null) {
return clientSSLSockFactory.createSocket(hostAddress, port, localAddress, localPort);
}
try {
SSLSocket sslSocket = (SSLSocket) clientSSLSockFactory.createSocket(host, port, localAddress, localPort);
sslSocket.startHandshake();
return sslSocket;
} catch (SSLException e) {
if (!e.getMessage().contains(CONTENTS_UNRECOGNIZED_NAME_EXCEPTION)) {
throw e;
}
hostAddress = InetAddress.getByName(host);
cacheMisconfiguredHost(host, port, hostAddress);
return clientSSLSockFactory.createSocket(hostAddress, port, localAddress, localPort);
}
}
Socket socket = clientSSLSockFactory.createSocket();
SocketAddress localAddr = new InetSocketAddress(localAddress, localPort);
socket.bind(localAddr);
SocketAddress remoteAddr = new InetSocketAddress(host, port);
socket.connect(remoteAddr, timeout);
return socket;
} | [
"@",
"Override",
"public",
"Socket",
"createSocket",
"(",
"final",
"String",
"host",
",",
"final",
"int",
"port",
",",
"final",
"InetAddress",
"localAddress",
",",
"final",
"int",
"localPort",
",",
"final",
"HttpConnectionParams",
"params",
")",
"throws",
"IOExc... | Attempts to get a new socket connection to the given host within the
given time limit.
@param host
the host name/IP
@param port
the port on the host
@param localAddress
the local host name/IP to bind the socket to
@param localPort
the port on the local machine
@param params
{@link HttpConnectionParams Http connection parameters}
@return Socket a new socket
@throws IOException
if an I/O error occurs while creating the socket
@throws UnknownHostException
if the IP address of the host cannot be determined
@throws ConnectTimeoutException | [
"Attempts",
"to",
"get",
"a",
"new",
"socket",
"connection",
"to",
"the",
"given",
"host",
"within",
"the",
"given",
"time",
"limit",
"."
] | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/parosproxy/paros/network/SSLConnector.java#L409-L445 |
datacleaner/DataCleaner | engine/core/src/main/java/org/datacleaner/output/csv/CsvOutputWriterFactory.java | CsvOutputWriterFactory.getWriter | public static OutputWriter getWriter(final String filename, final List<InputColumn<?>> columns) {
final InputColumn<?>[] columnArray = columns.toArray(new InputColumn<?>[columns.size()]);
final String[] headers = new String[columnArray.length];
for (int i = 0; i < headers.length; i++) {
headers[i] = columnArray[i].getName();
}
return getWriter(filename, headers, ',', '"', '\\', true, columnArray);
} | java | public static OutputWriter getWriter(final String filename, final List<InputColumn<?>> columns) {
final InputColumn<?>[] columnArray = columns.toArray(new InputColumn<?>[columns.size()]);
final String[] headers = new String[columnArray.length];
for (int i = 0; i < headers.length; i++) {
headers[i] = columnArray[i].getName();
}
return getWriter(filename, headers, ',', '"', '\\', true, columnArray);
} | [
"public",
"static",
"OutputWriter",
"getWriter",
"(",
"final",
"String",
"filename",
",",
"final",
"List",
"<",
"InputColumn",
"<",
"?",
">",
">",
"columns",
")",
"{",
"final",
"InputColumn",
"<",
"?",
">",
"[",
"]",
"columnArray",
"=",
"columns",
".",
"... | Creates a CSV output writer with default configuration
@param filename
@param columns
@return | [
"Creates",
"a",
"CSV",
"output",
"writer",
"with",
"default",
"configuration"
] | train | https://github.com/datacleaner/DataCleaner/blob/9aa01fdac3560cef51c55df3cb2ac5c690b57639/engine/core/src/main/java/org/datacleaner/output/csv/CsvOutputWriterFactory.java#L47-L54 |
apache/groovy | src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java | DefaultGroovyMethods.mixin | public static void mixin(Class self, List<Class> categoryClasses) {
mixin(getMetaClass(self), categoryClasses);
} | java | public static void mixin(Class self, List<Class> categoryClasses) {
mixin(getMetaClass(self), categoryClasses);
} | [
"public",
"static",
"void",
"mixin",
"(",
"Class",
"self",
",",
"List",
"<",
"Class",
">",
"categoryClasses",
")",
"{",
"mixin",
"(",
"getMetaClass",
"(",
"self",
")",
",",
"categoryClasses",
")",
";",
"}"
] | Extend class globally with category methods.
All methods for given class and all super classes will be added to the class.
@param self any Class
@param categoryClasses a category classes to use
@since 1.6.0 | [
"Extend",
"class",
"globally",
"with",
"category",
"methods",
".",
"All",
"methods",
"for",
"given",
"class",
"and",
"all",
"super",
"classes",
"will",
"be",
"added",
"to",
"the",
"class",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L578-L580 |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSegment.java | IPAddressSegment.isChangedByMask | protected boolean isChangedByMask(int maskValue, Integer segmentPrefixLength) throws IncompatibleAddressException {
boolean hasBits = (segmentPrefixLength != null);
if(hasBits && (segmentPrefixLength < 0 || segmentPrefixLength > getBitCount())) {
throw new PrefixLenException(this, segmentPrefixLength);
}
//note that the mask can represent a range (for example a CIDR mask),
//but we use the lowest value (maskSegment.value) in the range when masking (ie we discard the range)
int value = getSegmentValue();
int upperValue = getUpperSegmentValue();
return value != (value & maskValue) ||
upperValue != (upperValue & maskValue) ||
(isPrefixed() ? !getSegmentPrefixLength().equals(segmentPrefixLength) : hasBits);
} | java | protected boolean isChangedByMask(int maskValue, Integer segmentPrefixLength) throws IncompatibleAddressException {
boolean hasBits = (segmentPrefixLength != null);
if(hasBits && (segmentPrefixLength < 0 || segmentPrefixLength > getBitCount())) {
throw new PrefixLenException(this, segmentPrefixLength);
}
//note that the mask can represent a range (for example a CIDR mask),
//but we use the lowest value (maskSegment.value) in the range when masking (ie we discard the range)
int value = getSegmentValue();
int upperValue = getUpperSegmentValue();
return value != (value & maskValue) ||
upperValue != (upperValue & maskValue) ||
(isPrefixed() ? !getSegmentPrefixLength().equals(segmentPrefixLength) : hasBits);
} | [
"protected",
"boolean",
"isChangedByMask",
"(",
"int",
"maskValue",
",",
"Integer",
"segmentPrefixLength",
")",
"throws",
"IncompatibleAddressException",
"{",
"boolean",
"hasBits",
"=",
"(",
"segmentPrefixLength",
"!=",
"null",
")",
";",
"if",
"(",
"hasBits",
"&&",
... | returns a new segment masked by the given mask
This method applies the mask first to every address in the range, and it does not preserve any existing prefix.
The given prefix will be applied to the range of addresses after the mask.
If the combination of the two does not result in a contiguous range, then {@link IncompatibleAddressException} is thrown. | [
"returns",
"a",
"new",
"segment",
"masked",
"by",
"the",
"given",
"mask"
] | train | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSegment.java#L273-L286 |
Multifarious/MacroManager | src/main/java/com/fasterxml/mama/balancing/BalancingPolicy.java | BalancingPolicy.attemptToClaim | boolean attemptToClaim(String workUnit, boolean claimForHandoff)
throws InterruptedException
{
LOG.debug("Attempting to claim {}. For handoff? {}", workUnit, claimForHandoff);
String path = claimForHandoff
? String.format("/%s/handoff-result/%s", cluster.name, workUnit)
: cluster.workUnitClaimPath(workUnit);
final boolean created = ZKUtils.createEphemeral(cluster.zk, path, cluster.myNodeID);
if (created) {
if (claimForHandoff) {
cluster.claimedForHandoff.add(workUnit);
}
cluster.startWork(workUnit);
return true;
}
if (isPeggedToMe(workUnit)) {
claimWorkPeggedToMe(workUnit);
return true;
}
return false;
} | java | boolean attemptToClaim(String workUnit, boolean claimForHandoff)
throws InterruptedException
{
LOG.debug("Attempting to claim {}. For handoff? {}", workUnit, claimForHandoff);
String path = claimForHandoff
? String.format("/%s/handoff-result/%s", cluster.name, workUnit)
: cluster.workUnitClaimPath(workUnit);
final boolean created = ZKUtils.createEphemeral(cluster.zk, path, cluster.myNodeID);
if (created) {
if (claimForHandoff) {
cluster.claimedForHandoff.add(workUnit);
}
cluster.startWork(workUnit);
return true;
}
if (isPeggedToMe(workUnit)) {
claimWorkPeggedToMe(workUnit);
return true;
}
return false;
} | [
"boolean",
"attemptToClaim",
"(",
"String",
"workUnit",
",",
"boolean",
"claimForHandoff",
")",
"throws",
"InterruptedException",
"{",
"LOG",
".",
"debug",
"(",
"\"Attempting to claim {}. For handoff? {}\"",
",",
"workUnit",
",",
"claimForHandoff",
")",
";",
"String",
... | Attempts to claim a given work unit by creating an ephemeral node in ZooKeeper
with this node's ID. If the claim succeeds, start work. If not, move on.
@throws ZooKeeperConnectionException
@throws KeeperException | [
"Attempts",
"to",
"claim",
"a",
"given",
"work",
"unit",
"by",
"creating",
"an",
"ephemeral",
"node",
"in",
"ZooKeeper",
"with",
"this",
"node",
"s",
"ID",
".",
"If",
"the",
"claim",
"succeeds",
"start",
"work",
".",
"If",
"not",
"move",
"on",
"."
] | train | https://github.com/Multifarious/MacroManager/blob/559785839981f460aaeba3c3fddff7fb667d9581/src/main/java/com/fasterxml/mama/balancing/BalancingPolicy.java#L130-L153 |
apache/flink | flink-java/src/main/java/org/apache/flink/api/java/ExecutionEnvironment.java | ExecutionEnvironment.registerTypeWithKryoSerializer | public void registerTypeWithKryoSerializer(Class<?> type, Class<? extends Serializer<?>> serializerClass) {
config.registerTypeWithKryoSerializer(type, serializerClass);
} | java | public void registerTypeWithKryoSerializer(Class<?> type, Class<? extends Serializer<?>> serializerClass) {
config.registerTypeWithKryoSerializer(type, serializerClass);
} | [
"public",
"void",
"registerTypeWithKryoSerializer",
"(",
"Class",
"<",
"?",
">",
"type",
",",
"Class",
"<",
"?",
"extends",
"Serializer",
"<",
"?",
">",
">",
"serializerClass",
")",
"{",
"config",
".",
"registerTypeWithKryoSerializer",
"(",
"type",
",",
"seria... | Registers the given Serializer via its class as a serializer for the given type at the KryoSerializer.
@param type The class of the types serialized with the given serializer.
@param serializerClass The class of the serializer to use. | [
"Registers",
"the",
"given",
"Serializer",
"via",
"its",
"class",
"as",
"a",
"serializer",
"for",
"the",
"given",
"type",
"at",
"the",
"KryoSerializer",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-java/src/main/java/org/apache/flink/api/java/ExecutionEnvironment.java#L354-L356 |
lucee/Lucee | core/src/main/java/lucee/runtime/converter/JSONConverter.java | JSONConverter._serializeArray | private void _serializeArray(PageContext pc, Set test, Array array, StringBuilder sb, boolean serializeQueryByColumns, Set<Object> done) throws ConverterException {
_serializeList(pc, test, array.toList(), sb, serializeQueryByColumns, done);
} | java | private void _serializeArray(PageContext pc, Set test, Array array, StringBuilder sb, boolean serializeQueryByColumns, Set<Object> done) throws ConverterException {
_serializeList(pc, test, array.toList(), sb, serializeQueryByColumns, done);
} | [
"private",
"void",
"_serializeArray",
"(",
"PageContext",
"pc",
",",
"Set",
"test",
",",
"Array",
"array",
",",
"StringBuilder",
"sb",
",",
"boolean",
"serializeQueryByColumns",
",",
"Set",
"<",
"Object",
">",
"done",
")",
"throws",
"ConverterException",
"{",
... | serialize a Array
@param array Array to serialize
@param sb
@param serializeQueryByColumns
@param done
@throws ConverterException | [
"serialize",
"a",
"Array"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/runtime/converter/JSONConverter.java#L201-L203 |
softindex/datakernel | core-http/src/main/java/io/datakernel/http/HttpUtils.java | HttpUtils.urlEncode | public static String urlEncode(String string, String enc) {
try {
return URLEncoder.encode(string, enc);
} catch (UnsupportedEncodingException e) {
throw new IllegalArgumentException("Can't encode with supplied encoding: " + enc, e);
}
} | java | public static String urlEncode(String string, String enc) {
try {
return URLEncoder.encode(string, enc);
} catch (UnsupportedEncodingException e) {
throw new IllegalArgumentException("Can't encode with supplied encoding: " + enc, e);
}
} | [
"public",
"static",
"String",
"urlEncode",
"(",
"String",
"string",
",",
"String",
"enc",
")",
"{",
"try",
"{",
"return",
"URLEncoder",
".",
"encode",
"(",
"string",
",",
"enc",
")",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"e",
")",
"{",
... | Translates a string into application/x-www-form-urlencoded format using a specific encoding scheme.
This method uses the supplied encoding scheme to obtain the bytes for unsafe characters
@param string string for encoding
@param enc new encoding
@return the translated String. | [
"Translates",
"a",
"string",
"into",
"application",
"/",
"x",
"-",
"www",
"-",
"form",
"-",
"urlencoded",
"format",
"using",
"a",
"specific",
"encoding",
"scheme",
".",
"This",
"method",
"uses",
"the",
"supplied",
"encoding",
"scheme",
"to",
"obtain",
"the",... | train | https://github.com/softindex/datakernel/blob/090ca1116416c14d463d49d275cb1daaafa69c56/core-http/src/main/java/io/datakernel/http/HttpUtils.java#L214-L220 |
googleapis/google-cloud-java | google-cloud-clients/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/ProductSearchClient.java | ProductSearchClient.createProduct | public final Product createProduct(String parent, Product product, String productId) {
CreateProductRequest request =
CreateProductRequest.newBuilder()
.setParent(parent)
.setProduct(product)
.setProductId(productId)
.build();
return createProduct(request);
} | java | public final Product createProduct(String parent, Product product, String productId) {
CreateProductRequest request =
CreateProductRequest.newBuilder()
.setParent(parent)
.setProduct(product)
.setProductId(productId)
.build();
return createProduct(request);
} | [
"public",
"final",
"Product",
"createProduct",
"(",
"String",
"parent",
",",
"Product",
"product",
",",
"String",
"productId",
")",
"{",
"CreateProductRequest",
"request",
"=",
"CreateProductRequest",
".",
"newBuilder",
"(",
")",
".",
"setParent",
"(",
"parent",
... | Creates and returns a new product resource.
<p>Possible errors:
<p>* Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters.
* Returns INVALID_ARGUMENT if description is longer than 4096 characters. * Returns
INVALID_ARGUMENT if product_category is missing or invalid.
<p>Sample code:
<pre><code>
try (ProductSearchClient productSearchClient = ProductSearchClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Product product = Product.newBuilder().build();
String productId = "";
Product response = productSearchClient.createProduct(parent.toString(), product, productId);
}
</code></pre>
@param parent The project in which the Product should be created.
<p>Format is `projects/PROJECT_ID/locations/LOC_ID`.
@param product The product to create.
@param productId A user-supplied resource id for this Product. If set, the server will attempt
to use this value as the resource id. If it is already in use, an error is returned with
code ALREADY_EXISTS. Must be at most 128 characters long. It cannot contain the character
`/`.
@throws com.google.api.gax.rpc.ApiException if the remote call fails | [
"Creates",
"and",
"returns",
"a",
"new",
"product",
"resource",
"."
] | train | https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/ProductSearchClient.java#L457-L466 |
networknt/light-4j | body/src/main/java/com/networknt/body/BodyHandler.java | BodyHandler.attachJsonBody | private void attachJsonBody(final HttpServerExchange exchange, String string) throws IOException {
Object body;
if (string != null) {
string = string.trim();
if (string.startsWith("{")) {
body = Config.getInstance().getMapper().readValue(string, new TypeReference<Map<String, Object>>() {
});
} else if (string.startsWith("[")) {
body = Config.getInstance().getMapper().readValue(string, new TypeReference<List<Object>>() {
});
} else {
// error here. The content type in head doesn't match the body.
setExchangeStatus(exchange, CONTENT_TYPE_MISMATCH, "application/json");
return;
}
exchange.putAttachment(REQUEST_BODY, body);
}
} | java | private void attachJsonBody(final HttpServerExchange exchange, String string) throws IOException {
Object body;
if (string != null) {
string = string.trim();
if (string.startsWith("{")) {
body = Config.getInstance().getMapper().readValue(string, new TypeReference<Map<String, Object>>() {
});
} else if (string.startsWith("[")) {
body = Config.getInstance().getMapper().readValue(string, new TypeReference<List<Object>>() {
});
} else {
// error here. The content type in head doesn't match the body.
setExchangeStatus(exchange, CONTENT_TYPE_MISMATCH, "application/json");
return;
}
exchange.putAttachment(REQUEST_BODY, body);
}
} | [
"private",
"void",
"attachJsonBody",
"(",
"final",
"HttpServerExchange",
"exchange",
",",
"String",
"string",
")",
"throws",
"IOException",
"{",
"Object",
"body",
";",
"if",
"(",
"string",
"!=",
"null",
")",
"{",
"string",
"=",
"string",
".",
"trim",
"(",
... | Method used to parse the body into a Map or a List and attach it into exchange
@param exchange exchange to be attached
@param string unparsed request body
@throws IOException | [
"Method",
"used",
"to",
"parse",
"the",
"body",
"into",
"a",
"Map",
"or",
"a",
"List",
"and",
"attach",
"it",
"into",
"exchange"
] | train | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/body/src/main/java/com/networknt/body/BodyHandler.java#L143-L160 |
alipay/sofa-rpc | core/common/src/main/java/com/alipay/sofa/rpc/common/utils/CodecUtils.java | CodecUtils.hex2byte | public static byte[] hex2byte(String str) {
byte[] bytes = str.getBytes();
if ((bytes.length % 2) != 0) {
throw new IllegalArgumentException();
}
byte[] b2 = new byte[bytes.length / 2];
for (int n = 0; n < bytes.length; n += 2) {
String item = new String(bytes, n, 2);
b2[n / 2] = (byte) Integer.parseInt(item, 16);
}
return b2;
} | java | public static byte[] hex2byte(String str) {
byte[] bytes = str.getBytes();
if ((bytes.length % 2) != 0) {
throw new IllegalArgumentException();
}
byte[] b2 = new byte[bytes.length / 2];
for (int n = 0; n < bytes.length; n += 2) {
String item = new String(bytes, n, 2);
b2[n / 2] = (byte) Integer.parseInt(item, 16);
}
return b2;
} | [
"public",
"static",
"byte",
"[",
"]",
"hex2byte",
"(",
"String",
"str",
")",
"{",
"byte",
"[",
"]",
"bytes",
"=",
"str",
".",
"getBytes",
"(",
")",
";",
"if",
"(",
"(",
"bytes",
".",
"length",
"%",
"2",
")",
"!=",
"0",
")",
"{",
"throw",
"new",... | hex string to byte[], such as "0001" -> [0,1]
@param str hex string
@return byte[] | [
"hex",
"string",
"to",
"byte",
"[]",
"such",
"as",
"0001",
"-",
">",
"[",
"0",
"1",
"]"
] | train | https://github.com/alipay/sofa-rpc/blob/a31406410291e56696185a29c3ba4bd1f54488fd/core/common/src/main/java/com/alipay/sofa/rpc/common/utils/CodecUtils.java#L249-L260 |
line/armeria | tomcat/src/main/java/com/linecorp/armeria/server/tomcat/TomcatService.java | TomcatService.forConnector | public static TomcatService forConnector(String hostname, Connector connector) {
requireNonNull(hostname, "hostname");
requireNonNull(connector, "connector");
return new UnmanagedTomcatService(hostname, connector);
} | java | public static TomcatService forConnector(String hostname, Connector connector) {
requireNonNull(hostname, "hostname");
requireNonNull(connector, "connector");
return new UnmanagedTomcatService(hostname, connector);
} | [
"public",
"static",
"TomcatService",
"forConnector",
"(",
"String",
"hostname",
",",
"Connector",
"connector",
")",
"{",
"requireNonNull",
"(",
"hostname",
",",
"\"hostname\"",
")",
";",
"requireNonNull",
"(",
"connector",
",",
"\"connector\"",
")",
";",
"return",... | Creates a new {@link TomcatService} from an existing Tomcat {@link Connector} instance.
If the specified {@link Connector} instance is not configured properly, the returned
{@link TomcatService} may respond with '503 Service Not Available' error.
@return a new {@link TomcatService}, which will not manage the provided {@link Connector} instance. | [
"Creates",
"a",
"new",
"{",
"@link",
"TomcatService",
"}",
"from",
"an",
"existing",
"Tomcat",
"{",
"@link",
"Connector",
"}",
"instance",
".",
"If",
"the",
"specified",
"{",
"@link",
"Connector",
"}",
"instance",
"is",
"not",
"configured",
"properly",
"the"... | train | https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/tomcat/src/main/java/com/linecorp/armeria/server/tomcat/TomcatService.java#L212-L217 |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/metadata/MetadataManager.java | MetadataManager.readDescriptorRepository | public DescriptorRepository readDescriptorRepository(String fileName)
{
try
{
RepositoryPersistor persistor = new RepositoryPersistor();
return persistor.readDescriptorRepository(fileName);
}
catch (Exception e)
{
throw new MetadataException("Can not read repository " + fileName, e);
}
} | java | public DescriptorRepository readDescriptorRepository(String fileName)
{
try
{
RepositoryPersistor persistor = new RepositoryPersistor();
return persistor.readDescriptorRepository(fileName);
}
catch (Exception e)
{
throw new MetadataException("Can not read repository " + fileName, e);
}
} | [
"public",
"DescriptorRepository",
"readDescriptorRepository",
"(",
"String",
"fileName",
")",
"{",
"try",
"{",
"RepositoryPersistor",
"persistor",
"=",
"new",
"RepositoryPersistor",
"(",
")",
";",
"return",
"persistor",
".",
"readDescriptorRepository",
"(",
"fileName",
... | Read ClassDescriptors from the given repository file.
@see #mergeDescriptorRepository | [
"Read",
"ClassDescriptors",
"from",
"the",
"given",
"repository",
"file",
"."
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/metadata/MetadataManager.java#L334-L345 |
joniles/mpxj | src/main/java/net/sf/mpxj/primavera/PrimaveraXERFileReader.java | PrimaveraXERFileReader.processFile | private void processFile(InputStream is) throws MPXJException
{
int line = 1;
try
{
//
// Test the header and extract the separator. If this is successful,
// we reset the stream back as far as we can. The design of the
// BufferedInputStream class means that we can't get back to character
// zero, so the first record we will read will get "RMHDR" rather than
// "ERMHDR" in the first field position.
//
BufferedInputStream bis = new BufferedInputStream(is);
byte[] data = new byte[6];
data[0] = (byte) bis.read();
bis.mark(1024);
bis.read(data, 1, 5);
if (!new String(data).equals("ERMHDR"))
{
throw new MPXJException(MPXJException.INVALID_FILE);
}
bis.reset();
InputStreamReader reader = new InputStreamReader(bis, getCharset());
Tokenizer tk = new ReaderTokenizer(reader);
tk.setDelimiter('\t');
List<String> record = new ArrayList<String>();
while (tk.getType() != Tokenizer.TT_EOF)
{
readRecord(tk, record);
if (!record.isEmpty())
{
if (processRecord(record))
{
break;
}
}
++line;
}
}
catch (Exception ex)
{
throw new MPXJException(MPXJException.READ_ERROR + " (failed at line " + line + ")", ex);
}
} | java | private void processFile(InputStream is) throws MPXJException
{
int line = 1;
try
{
//
// Test the header and extract the separator. If this is successful,
// we reset the stream back as far as we can. The design of the
// BufferedInputStream class means that we can't get back to character
// zero, so the first record we will read will get "RMHDR" rather than
// "ERMHDR" in the first field position.
//
BufferedInputStream bis = new BufferedInputStream(is);
byte[] data = new byte[6];
data[0] = (byte) bis.read();
bis.mark(1024);
bis.read(data, 1, 5);
if (!new String(data).equals("ERMHDR"))
{
throw new MPXJException(MPXJException.INVALID_FILE);
}
bis.reset();
InputStreamReader reader = new InputStreamReader(bis, getCharset());
Tokenizer tk = new ReaderTokenizer(reader);
tk.setDelimiter('\t');
List<String> record = new ArrayList<String>();
while (tk.getType() != Tokenizer.TT_EOF)
{
readRecord(tk, record);
if (!record.isEmpty())
{
if (processRecord(record))
{
break;
}
}
++line;
}
}
catch (Exception ex)
{
throw new MPXJException(MPXJException.READ_ERROR + " (failed at line " + line + ")", ex);
}
} | [
"private",
"void",
"processFile",
"(",
"InputStream",
"is",
")",
"throws",
"MPXJException",
"{",
"int",
"line",
"=",
"1",
";",
"try",
"{",
"//",
"// Test the header and extract the separator. If this is successful,",
"// we reset the stream back as far as we can. The design of ... | Reads the XER file table and row structure ready for processing.
@param is input stream
@throws MPXJException | [
"Reads",
"the",
"XER",
"file",
"table",
"and",
"row",
"structure",
"ready",
"for",
"processing",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/primavera/PrimaveraXERFileReader.java#L258-L307 |
cdk/cdk | legacy/src/main/java/org/openscience/cdk/smsd/algorithm/rgraph/CDKMCS.java | CDKMCS.queryAdjacency | private static boolean queryAdjacency(IBond bondA1, IBond bondB1, IBond bondA2, IBond bondB2) {
IAtom atom1 = null;
IAtom atom2 = null;
if (bondA1.contains(bondB1.getBegin())) {
atom1 = bondB1.getBegin();
} else if (bondA1.contains(bondB1.getEnd())) {
atom1 = bondB1.getEnd();
}
if (bondA2.contains(bondB2.getBegin())) {
atom2 = bondB2.getBegin();
} else if (bondA2.contains(bondB2.getEnd())) {
atom2 = bondB2.getEnd();
}
if (atom1 != null && atom2 != null) {
// well, this looks fishy: the atom2 is not always atom IQueryAtom !
return ((IQueryAtom) atom2).matches(atom1);
} else {
return atom1 == null && atom2 == null;
}
} | java | private static boolean queryAdjacency(IBond bondA1, IBond bondB1, IBond bondA2, IBond bondB2) {
IAtom atom1 = null;
IAtom atom2 = null;
if (bondA1.contains(bondB1.getBegin())) {
atom1 = bondB1.getBegin();
} else if (bondA1.contains(bondB1.getEnd())) {
atom1 = bondB1.getEnd();
}
if (bondA2.contains(bondB2.getBegin())) {
atom2 = bondB2.getBegin();
} else if (bondA2.contains(bondB2.getEnd())) {
atom2 = bondB2.getEnd();
}
if (atom1 != null && atom2 != null) {
// well, this looks fishy: the atom2 is not always atom IQueryAtom !
return ((IQueryAtom) atom2).matches(atom1);
} else {
return atom1 == null && atom2 == null;
}
} | [
"private",
"static",
"boolean",
"queryAdjacency",
"(",
"IBond",
"bondA1",
",",
"IBond",
"bondB1",
",",
"IBond",
"bondA2",
",",
"IBond",
"bondB2",
")",
"{",
"IAtom",
"atom1",
"=",
"null",
";",
"IAtom",
"atom2",
"=",
"null",
";",
"if",
"(",
"bondA1",
".",
... | Determines if 2 bondA1 have 1 atom in common if second is atom query AtomContainer
@param atom1 first bondA1
@param bondB1 second bondA1
@return the symbol of the common atom or "" if
the 2 bonds have no common atom | [
"Determines",
"if",
"2",
"bondA1",
"have",
"1",
"atom",
"in",
"common",
"if",
"second",
"is",
"atom",
"query",
"AtomContainer"
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/legacy/src/main/java/org/openscience/cdk/smsd/algorithm/rgraph/CDKMCS.java#L940-L964 |
osglworks/java-tool | src/main/java/org/osgl/util/FastStr.java | FastStr.equalsIgnoreCase | public boolean equalsIgnoreCase(CharSequence x) {
if (x == this) return true;
if (null == x || size() != x.length()) return false;
if (isEmpty() && x.length() == 0) return true;
return regionMatches(true, 0, x, 0, size());
} | java | public boolean equalsIgnoreCase(CharSequence x) {
if (x == this) return true;
if (null == x || size() != x.length()) return false;
if (isEmpty() && x.length() == 0) return true;
return regionMatches(true, 0, x, 0, size());
} | [
"public",
"boolean",
"equalsIgnoreCase",
"(",
"CharSequence",
"x",
")",
"{",
"if",
"(",
"x",
"==",
"this",
")",
"return",
"true",
";",
"if",
"(",
"null",
"==",
"x",
"||",
"size",
"(",
")",
"!=",
"x",
".",
"length",
"(",
")",
")",
"return",
"false",... | Wrapper of {@link String#equalsIgnoreCase(String)}
@param x the char sequence to be compared
@return {@code true} if the argument is not {@code null} and it
represents an equivalent {@code String} ignoring case; {@code
false} otherwise | [
"Wrapper",
"of",
"{",
"@link",
"String#equalsIgnoreCase",
"(",
"String",
")",
"}"
] | train | https://github.com/osglworks/java-tool/blob/8b6eee2bccb067eb32e6a7bc4a4dfef7a7d9008b/src/main/java/org/osgl/util/FastStr.java#L739-L744 |
facebookarchive/hadoop-20 | src/core/org/apache/hadoop/util/ProcfsBasedProcessTree.java | ProcfsBasedProcessTree.assertAndDestroyProcessGroup | public static void assertAndDestroyProcessGroup(String pgrpId, long interval,
boolean inBackground)
throws IOException {
// Make sure that the pid given is a process group leader
if (!checkPidPgrpidForMatch(pgrpId, PROCFS)) {
throw new IOException("Process with PID " + pgrpId +
" is not a process group leader.");
}
destroyProcessGroup(pgrpId, interval, inBackground);
} | java | public static void assertAndDestroyProcessGroup(String pgrpId, long interval,
boolean inBackground)
throws IOException {
// Make sure that the pid given is a process group leader
if (!checkPidPgrpidForMatch(pgrpId, PROCFS)) {
throw new IOException("Process with PID " + pgrpId +
" is not a process group leader.");
}
destroyProcessGroup(pgrpId, interval, inBackground);
} | [
"public",
"static",
"void",
"assertAndDestroyProcessGroup",
"(",
"String",
"pgrpId",
",",
"long",
"interval",
",",
"boolean",
"inBackground",
")",
"throws",
"IOException",
"{",
"// Make sure that the pid given is a process group leader",
"if",
"(",
"!",
"checkPidPgrpidForMa... | Make sure that the given pid is a process group leader and then
destroy the process group.
@param pgrpId Process group id of to-be-killed-processes
@param interval The time to wait before sending SIGKILL
after sending SIGTERM
@param inBackground Process is to be killed in the back ground with
a separate thread | [
"Make",
"sure",
"that",
"the",
"given",
"pid",
"is",
"a",
"process",
"group",
"leader",
"and",
"then",
"destroy",
"the",
"process",
"group",
"."
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/core/org/apache/hadoop/util/ProcfsBasedProcessTree.java#L299-L308 |
querydsl/querydsl | querydsl-core/src/main/java/com/querydsl/core/types/dsl/Expressions.java | Expressions.stringTemplate | public static StringTemplate stringTemplate(String template, List<?> args) {
return stringTemplate(createTemplate(template), args);
} | java | public static StringTemplate stringTemplate(String template, List<?> args) {
return stringTemplate(createTemplate(template), args);
} | [
"public",
"static",
"StringTemplate",
"stringTemplate",
"(",
"String",
"template",
",",
"List",
"<",
"?",
">",
"args",
")",
"{",
"return",
"stringTemplate",
"(",
"createTemplate",
"(",
"template",
")",
",",
"args",
")",
";",
"}"
] | Create a new Template expression
@param template template
@param args template parameters
@return template expression | [
"Create",
"a",
"new",
"Template",
"expression"
] | train | https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/types/dsl/Expressions.java#L913-L915 |
before/uadetector | modules/uadetector-resources/src/main/java/net/sf/uadetector/service/UADetectorServiceFactory.java | UADetectorServiceFactory.getCachingAndUpdatingParser | public static UserAgentStringParser getCachingAndUpdatingParser(final URL dataUrl, final URL versionUrl, final URL fallbackDataURL, final URL fallbackVersionURL) {
return CachingAndUpdatingParserHolder.getParser(dataUrl, versionUrl, getCustomFallbackXmlDataStore(fallbackDataURL, fallbackVersionURL));
} | java | public static UserAgentStringParser getCachingAndUpdatingParser(final URL dataUrl, final URL versionUrl, final URL fallbackDataURL, final URL fallbackVersionURL) {
return CachingAndUpdatingParserHolder.getParser(dataUrl, versionUrl, getCustomFallbackXmlDataStore(fallbackDataURL, fallbackVersionURL));
} | [
"public",
"static",
"UserAgentStringParser",
"getCachingAndUpdatingParser",
"(",
"final",
"URL",
"dataUrl",
",",
"final",
"URL",
"versionUrl",
",",
"final",
"URL",
"fallbackDataURL",
",",
"final",
"URL",
"fallbackVersionURL",
")",
"{",
"return",
"CachingAndUpdatingParse... | Returns an implementation of {@link UserAgentStringParser} which checks at regular intervals for new versions of
<em>UAS data</em> (also known as database). When newer data available, it automatically loads and updates it.
Additionally the loaded data are stored in a cache file.
<p>
At initialization time the returned parser will be loaded with the <em>UAS data</em> of the cache file. If the
cache file doesn't exist or is empty the data of this module will be loaded. The initialization is started only
when this method is called the first time.
<p>
The update of the data store runs as background task. With this feature we try to reduce the initialization time
of this <code>UserAgentStringParser</code>, because a network connection is involved and the remote system can be
not available or slow.
<p>
The static class definition {@code CachingAndUpdatingParserHolder} within this factory class is <em>not</em>
initialized until the JVM determines that {@code CachingAndUpdatingParserHolder} must be executed. The static
class {@code CachingAndUpdatingParserHolder} is only executed when the static method
{@code getOnlineUserAgentStringParser} is invoked on the class {@code UADetectorServiceFactory}, and the first
time this happens the JVM will load and initialize the {@code CachingAndUpdatingParserHolder} class.
<p>
If during the operation the Internet connection gets lost, then this instance continues to work properly (and
under correct log level settings you will get an corresponding log messages).
@param dataUrl
@param versionUrl
@param fallbackDataURL
@param fallbackVersionURL
@return an user agent string parser with updating service | [
"Returns",
"an",
"implementation",
"of",
"{",
"@link",
"UserAgentStringParser",
"}",
"which",
"checks",
"at",
"regular",
"intervals",
"for",
"new",
"versions",
"of",
"<em",
">",
"UAS",
"data<",
"/",
"em",
">",
"(",
"also",
"known",
"as",
"database",
")",
"... | train | https://github.com/before/uadetector/blob/215fb652723c52866572cff885f52a3fe67b9db5/modules/uadetector-resources/src/main/java/net/sf/uadetector/service/UADetectorServiceFactory.java#L206-L208 |
elki-project/elki | elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/geometry/SweepHullDelaunay2D.java | SweepHullDelaunay2D.quadraticEuclidean | public static double quadraticEuclidean(double[] v1, double[] v2) {
final double d1 = v1[0] - v2[0], d2 = v1[1] - v2[1];
return (d1 * d1) + (d2 * d2);
} | java | public static double quadraticEuclidean(double[] v1, double[] v2) {
final double d1 = v1[0] - v2[0], d2 = v1[1] - v2[1];
return (d1 * d1) + (d2 * d2);
} | [
"public",
"static",
"double",
"quadraticEuclidean",
"(",
"double",
"[",
"]",
"v1",
",",
"double",
"[",
"]",
"v2",
")",
"{",
"final",
"double",
"d1",
"=",
"v1",
"[",
"0",
"]",
"-",
"v2",
"[",
"0",
"]",
",",
"d2",
"=",
"v1",
"[",
"1",
"]",
"-",
... | Squared euclidean distance. 2d.
@param v1 First double[]
@param v2 Second double[]
@return Quadratic distance | [
"Squared",
"euclidean",
"distance",
".",
"2d",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/geometry/SweepHullDelaunay2D.java#L693-L696 |
wildfly/wildfly-core | patching/src/main/java/org/jboss/as/patching/metadata/ModificationBuilderTarget.java | ModificationBuilderTarget.modifyModule | public T modifyModule(final String moduleName, final String slot, final byte[] existingHash, final byte[] newHash) {
final ContentItem item = createModuleItem(moduleName, slot, newHash);
addContentModification(createContentModification(item, ModificationType.MODIFY, existingHash));
return returnThis();
} | java | public T modifyModule(final String moduleName, final String slot, final byte[] existingHash, final byte[] newHash) {
final ContentItem item = createModuleItem(moduleName, slot, newHash);
addContentModification(createContentModification(item, ModificationType.MODIFY, existingHash));
return returnThis();
} | [
"public",
"T",
"modifyModule",
"(",
"final",
"String",
"moduleName",
",",
"final",
"String",
"slot",
",",
"final",
"byte",
"[",
"]",
"existingHash",
",",
"final",
"byte",
"[",
"]",
"newHash",
")",
"{",
"final",
"ContentItem",
"item",
"=",
"createModuleItem",... | Modify a module.
@param moduleName the module name
@param slot the module slot
@param existingHash the existing hash
@param newHash the new hash of the modified content
@return the builder | [
"Modify",
"a",
"module",
"."
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/patching/src/main/java/org/jboss/as/patching/metadata/ModificationBuilderTarget.java#L189-L193 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.jms.2.0/src/com/ibm/ws/sib/api/jms/impl/MsgDestEncodingUtilsImpl.java | MsgDestEncodingUtilsImpl.decodeOtherProperties | private static void decodeOtherProperties(JmsDestination newDest, byte[] msgForm, int offset) throws JMSException {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "decodeOtherProperties", new Object[]{newDest, msgForm, offset});
PropertyInputStream stream = new PropertyInputStream(msgForm, offset);
while (stream.hasMore()) {
String shortName = stream.readShortName();
String longName = reverseMap.get(shortName);
if (longName != null) {
PropertyEntry propEntry = propertyMap.get(longName); // This can't be null, as we just got the name from the reverseMap!
Object propValue = propEntry.getPropertyCoder().decodeProperty(stream);
setProperty(newDest, longName, propEntry.getIntValue(), propValue);
}
else {
// If there is no mapping for the short name, then the property is not known.
// The most likely situation is that we have been sent a property for a newer release.
//
throw (JMSException)JmsErrorUtils.newThrowable(JMSException.class
,"UNKNOWN_PROPERTY_CWSIA0363"
,new Object[] {shortName}
,null
,"MsgDestEncodingUtilsImpl.decodeOtherProperties#1"
,null
,tc);
}
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "decodeOtherProperties");
} | java | private static void decodeOtherProperties(JmsDestination newDest, byte[] msgForm, int offset) throws JMSException {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "decodeOtherProperties", new Object[]{newDest, msgForm, offset});
PropertyInputStream stream = new PropertyInputStream(msgForm, offset);
while (stream.hasMore()) {
String shortName = stream.readShortName();
String longName = reverseMap.get(shortName);
if (longName != null) {
PropertyEntry propEntry = propertyMap.get(longName); // This can't be null, as we just got the name from the reverseMap!
Object propValue = propEntry.getPropertyCoder().decodeProperty(stream);
setProperty(newDest, longName, propEntry.getIntValue(), propValue);
}
else {
// If there is no mapping for the short name, then the property is not known.
// The most likely situation is that we have been sent a property for a newer release.
//
throw (JMSException)JmsErrorUtils.newThrowable(JMSException.class
,"UNKNOWN_PROPERTY_CWSIA0363"
,new Object[] {shortName}
,null
,"MsgDestEncodingUtilsImpl.decodeOtherProperties#1"
,null
,tc);
}
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "decodeOtherProperties");
} | [
"private",
"static",
"void",
"decodeOtherProperties",
"(",
"JmsDestination",
"newDest",
",",
"byte",
"[",
"]",
"msgForm",
",",
"int",
"offset",
")",
"throws",
"JMSException",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
"... | decodeOtherProperties
Decode the more interesting JmsDestination properties, which may or may not be included:
Queue/Topic name
TopicSpace
ReadAhead
Cluster properties
@param newDest The Destination to apply the properties to
@param msgForm The byte array containing the encoded Destination values
@param offset The current offset into msgForm
@exception JMSException Thrown if anything goes horribly wrong | [
"decodeOtherProperties",
"Decode",
"the",
"more",
"interesting",
"JmsDestination",
"properties",
"which",
"may",
"or",
"may",
"not",
"be",
"included",
":",
"Queue",
"/",
"Topic",
"name",
"TopicSpace",
"ReadAhead",
"Cluster",
"properties"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.jms.2.0/src/com/ibm/ws/sib/api/jms/impl/MsgDestEncodingUtilsImpl.java#L760-L788 |
anotheria/moskito | moskito-extensions/moskito-php/src/main/java/net/anotheria/extensions/php/ConnectorsRegistry.java | ConnectorsRegistry.enableConnector | public void enableConnector(String connectorClass, Properties connectorInitProperties) throws ConnectorInitException {
ConnectorEntry connector = connectors.get(connectorClass);
if(connector != null)
connectors.get(connectorClass).enableConnector(connectorInitProperties);
} | java | public void enableConnector(String connectorClass, Properties connectorInitProperties) throws ConnectorInitException {
ConnectorEntry connector = connectors.get(connectorClass);
if(connector != null)
connectors.get(connectorClass).enableConnector(connectorInitProperties);
} | [
"public",
"void",
"enableConnector",
"(",
"String",
"connectorClass",
",",
"Properties",
"connectorInitProperties",
")",
"throws",
"ConnectorInitException",
"{",
"ConnectorEntry",
"connector",
"=",
"connectors",
".",
"get",
"(",
"connectorClass",
")",
";",
"if",
"(",
... | Makes enable connector with given class name if
it registered and not already enabled.
Non-existing or already enabled connectors be ignored
@param connectorClass connector class canonical name
@param connectorInitProperties initialization properties of connector
@throws ConnectorInitException | [
"Makes",
"enable",
"connector",
"with",
"given",
"class",
"name",
"if",
"it",
"registered",
"and",
"not",
"already",
"enabled",
".",
"Non",
"-",
"existing",
"or",
"already",
"enabled",
"connectors",
"be",
"ignored"
] | train | https://github.com/anotheria/moskito/blob/0fdb79053b98a6ece610fa159f59bc3331e4cf05/moskito-extensions/moskito-php/src/main/java/net/anotheria/extensions/php/ConnectorsRegistry.java#L50-L57 |
UrielCh/ovh-java-sdk | ovh-java-sdk-dedicatedserver/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedserver.java | ApiOvhDedicatedserver.serviceName_statistics_raid_unit_volume_volume_GET | public OvhRtmRaidVolume serviceName_statistics_raid_unit_volume_volume_GET(String serviceName, String unit, String volume) throws IOException {
String qPath = "/dedicated/server/{serviceName}/statistics/raid/{unit}/volume/{volume}";
StringBuilder sb = path(qPath, serviceName, unit, volume);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhRtmRaidVolume.class);
} | java | public OvhRtmRaidVolume serviceName_statistics_raid_unit_volume_volume_GET(String serviceName, String unit, String volume) throws IOException {
String qPath = "/dedicated/server/{serviceName}/statistics/raid/{unit}/volume/{volume}";
StringBuilder sb = path(qPath, serviceName, unit, volume);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhRtmRaidVolume.class);
} | [
"public",
"OvhRtmRaidVolume",
"serviceName_statistics_raid_unit_volume_volume_GET",
"(",
"String",
"serviceName",
",",
"String",
"unit",
",",
"String",
"volume",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/dedicated/server/{serviceName}/statistics/raid/{unit}... | Get this object properties
REST: GET /dedicated/server/{serviceName}/statistics/raid/{unit}/volume/{volume}
@param serviceName [required] The internal name of your dedicated server
@param unit [required] Raid unit
@param volume [required] Raid volume name | [
"Get",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-dedicatedserver/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedserver.java#L1401-L1406 |
nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/util/Config.java | Config.getPropertyDouble | public static Double getPropertyDouble(Class<?> cls, String key)
{
return getSettings().getPropertyDouble(cls, key);
} | java | public static Double getPropertyDouble(Class<?> cls, String key)
{
return getSettings().getPropertyDouble(cls, key);
} | [
"public",
"static",
"Double",
"getPropertyDouble",
"(",
"Class",
"<",
"?",
">",
"cls",
",",
"String",
"key",
")",
"{",
"return",
"getSettings",
"(",
")",
".",
"getPropertyDouble",
"(",
"cls",
",",
"key",
")",
";",
"}"
] | Get a double property
@param cls the class associated with the property
@param key the property key name
@return the double property value | [
"Get",
"a",
"double",
"property"
] | train | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Config.java#L316-L320 |
Impetus/Kundera | examples/polyglot/kvapps/src/main/java/com/impetus/kvapps/runner/ExecutorService.java | ExecutorService.findByKey | static User findByKey(final EntityManager em, final String userId)
{
User user = em.find(User.class, userId);
logger.info("[On Find by key]");
System.out.println("#######################START##########################################");
logger.info("\n");
logger.info("\t\t User's first name:" + user.getFirstName());
logger.info("\t\t User's emailId:" + user.getEmailId());
logger.info("\t\t User's Personal Details:" + user.getPersonalDetail().getName());
logger.info("\t\t User's Personal Details:" + user.getPersonalDetail().getPassword());
logger.info("\t\t User's total tweets:" + user.getTweets().size());
logger.info("\n");
System.out.println("#######################END############################################");
logger.info("\n");
return user;
} | java | static User findByKey(final EntityManager em, final String userId)
{
User user = em.find(User.class, userId);
logger.info("[On Find by key]");
System.out.println("#######################START##########################################");
logger.info("\n");
logger.info("\t\t User's first name:" + user.getFirstName());
logger.info("\t\t User's emailId:" + user.getEmailId());
logger.info("\t\t User's Personal Details:" + user.getPersonalDetail().getName());
logger.info("\t\t User's Personal Details:" + user.getPersonalDetail().getPassword());
logger.info("\t\t User's total tweets:" + user.getTweets().size());
logger.info("\n");
System.out.println("#######################END############################################");
logger.info("\n");
return user;
} | [
"static",
"User",
"findByKey",
"(",
"final",
"EntityManager",
"em",
",",
"final",
"String",
"userId",
")",
"{",
"User",
"user",
"=",
"em",
".",
"find",
"(",
"User",
".",
"class",
",",
"userId",
")",
";",
"logger",
".",
"info",
"(",
"\"[On Find by key]\""... | On find by user id.
@param em entity manager instance.
@param userId user id. | [
"On",
"find",
"by",
"user",
"id",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/examples/polyglot/kvapps/src/main/java/com/impetus/kvapps/runner/ExecutorService.java#L96-L111 |
VoltDB/voltdb | src/frontend/org/voltdb/TheHashinator.java | TheHashinator.serializeConfiguredHashinator | public static HashinatorSnapshotData serializeConfiguredHashinator()
throws IOException
{
Pair<Long, ? extends TheHashinator> currentInstance = instance.get();
byte[] cookedData = currentInstance.getSecond().getCookedBytes();
return new HashinatorSnapshotData(cookedData, currentInstance.getFirst());
} | java | public static HashinatorSnapshotData serializeConfiguredHashinator()
throws IOException
{
Pair<Long, ? extends TheHashinator> currentInstance = instance.get();
byte[] cookedData = currentInstance.getSecond().getCookedBytes();
return new HashinatorSnapshotData(cookedData, currentInstance.getFirst());
} | [
"public",
"static",
"HashinatorSnapshotData",
"serializeConfiguredHashinator",
"(",
")",
"throws",
"IOException",
"{",
"Pair",
"<",
"Long",
",",
"?",
"extends",
"TheHashinator",
">",
"currentInstance",
"=",
"instance",
".",
"get",
"(",
")",
";",
"byte",
"[",
"]"... | Get optimized configuration data for wire serialization.
@return optimized configuration data
@throws IOException | [
"Get",
"optimized",
"configuration",
"data",
"for",
"wire",
"serialization",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/TheHashinator.java#L427-L433 |
CubeEngine/Dirigent | src/main/java/org/cubeengine/dirigent/formatter/DateTimeFormatter.java | DateTimeFormatter.parseDateFormatStyle | private int parseDateFormatStyle(String text, int defaultStyle)
{
if (text == null)
{
return defaultStyle;
}
if (SHORT_STYLE.equalsIgnoreCase(text))
{
return DateFormat.SHORT;
}
else if (MEDIUM_STYLE.equalsIgnoreCase(text))
{
return DateFormat.MEDIUM;
}
else if (LONG_STYLE.equalsIgnoreCase(text))
{
return DateFormat.LONG;
}
else if (FULL_STYLE.equalsIgnoreCase(text))
{
return DateFormat.FULL;
}
return defaultStyle;
} | java | private int parseDateFormatStyle(String text, int defaultStyle)
{
if (text == null)
{
return defaultStyle;
}
if (SHORT_STYLE.equalsIgnoreCase(text))
{
return DateFormat.SHORT;
}
else if (MEDIUM_STYLE.equalsIgnoreCase(text))
{
return DateFormat.MEDIUM;
}
else if (LONG_STYLE.equalsIgnoreCase(text))
{
return DateFormat.LONG;
}
else if (FULL_STYLE.equalsIgnoreCase(text))
{
return DateFormat.FULL;
}
return defaultStyle;
} | [
"private",
"int",
"parseDateFormatStyle",
"(",
"String",
"text",
",",
"int",
"defaultStyle",
")",
"{",
"if",
"(",
"text",
"==",
"null",
")",
"{",
"return",
"defaultStyle",
";",
"}",
"if",
"(",
"SHORT_STYLE",
".",
"equalsIgnoreCase",
"(",
"text",
")",
")",
... | Parses the style of the {@link DateFormat} from a string label.
@param text The string label.
@param defaultStyle The default style.
@return the parsed style or the default style if it's an incorrect style. | [
"Parses",
"the",
"style",
"of",
"the",
"{",
"@link",
"DateFormat",
"}",
"from",
"a",
"string",
"label",
"."
] | train | https://github.com/CubeEngine/Dirigent/blob/68587a8202754a6a6b629cc15e14c516806badaa/src/main/java/org/cubeengine/dirigent/formatter/DateTimeFormatter.java#L172-L196 |
undertow-io/undertow | core/src/main/java/io/undertow/util/DateUtils.java | DateUtils.parseDate | public static Date parseDate(final String date) {
/*
IE9 sends a superflous lenght parameter after date in the
If-Modified-Since header, which needs to be stripped before
parsing.
*/
final int semicolonIndex = date.indexOf(';');
final String trimmedDate = semicolonIndex >= 0 ? date.substring(0, semicolonIndex) : date;
ParsePosition pp = new ParsePosition(0);
SimpleDateFormat dateFormat = RFC1123_PATTERN_FORMAT.get();
dateFormat.setTimeZone(GMT_ZONE);
Date val = dateFormat.parse(trimmedDate, pp);
if (val != null && pp.getIndex() == trimmedDate.length()) {
return val;
}
pp = new ParsePosition(0);
dateFormat = new SimpleDateFormat(RFC1036_PATTERN, LOCALE_US);
dateFormat.setTimeZone(GMT_ZONE);
val = dateFormat.parse(trimmedDate, pp);
if (val != null && pp.getIndex() == trimmedDate.length()) {
return val;
}
pp = new ParsePosition(0);
dateFormat = new SimpleDateFormat(ASCITIME_PATTERN, LOCALE_US);
dateFormat.setTimeZone(GMT_ZONE);
val = dateFormat.parse(trimmedDate, pp);
if (val != null && pp.getIndex() == trimmedDate.length()) {
return val;
}
pp = new ParsePosition(0);
dateFormat = new SimpleDateFormat(OLD_COOKIE_PATTERN, LOCALE_US);
dateFormat.setTimeZone(GMT_ZONE);
val = dateFormat.parse(trimmedDate, pp);
if (val != null && pp.getIndex() == trimmedDate.length()) {
return val;
}
return null;
} | java | public static Date parseDate(final String date) {
/*
IE9 sends a superflous lenght parameter after date in the
If-Modified-Since header, which needs to be stripped before
parsing.
*/
final int semicolonIndex = date.indexOf(';');
final String trimmedDate = semicolonIndex >= 0 ? date.substring(0, semicolonIndex) : date;
ParsePosition pp = new ParsePosition(0);
SimpleDateFormat dateFormat = RFC1123_PATTERN_FORMAT.get();
dateFormat.setTimeZone(GMT_ZONE);
Date val = dateFormat.parse(trimmedDate, pp);
if (val != null && pp.getIndex() == trimmedDate.length()) {
return val;
}
pp = new ParsePosition(0);
dateFormat = new SimpleDateFormat(RFC1036_PATTERN, LOCALE_US);
dateFormat.setTimeZone(GMT_ZONE);
val = dateFormat.parse(trimmedDate, pp);
if (val != null && pp.getIndex() == trimmedDate.length()) {
return val;
}
pp = new ParsePosition(0);
dateFormat = new SimpleDateFormat(ASCITIME_PATTERN, LOCALE_US);
dateFormat.setTimeZone(GMT_ZONE);
val = dateFormat.parse(trimmedDate, pp);
if (val != null && pp.getIndex() == trimmedDate.length()) {
return val;
}
pp = new ParsePosition(0);
dateFormat = new SimpleDateFormat(OLD_COOKIE_PATTERN, LOCALE_US);
dateFormat.setTimeZone(GMT_ZONE);
val = dateFormat.parse(trimmedDate, pp);
if (val != null && pp.getIndex() == trimmedDate.length()) {
return val;
}
return null;
} | [
"public",
"static",
"Date",
"parseDate",
"(",
"final",
"String",
"date",
")",
"{",
"/*\n IE9 sends a superflous lenght parameter after date in the\n If-Modified-Since header, which needs to be stripped before\n parsing.\n\n */",
"final",
"int",
"sem... | Attempts to pass a HTTP date.
@param date The date to parse
@return The parsed date, or null if parsing failed | [
"Attempts",
"to",
"pass",
"a",
"HTTP",
"date",
"."
] | train | https://github.com/undertow-io/undertow/blob/87de0b856a7a4ba8faf5b659537b9af07b763263/core/src/main/java/io/undertow/util/DateUtils.java#L126-L171 |
cryptomator/webdav-nio-adapter | src/main/java/org/cryptomator/frontend/webdav/mount/ProcessUtil.java | ProcessUtil.assertExitValue | public static void assertExitValue(Process proc, int expectedExitValue) throws CommandFailedException {
int actualExitValue = proc.exitValue();
if (actualExitValue != expectedExitValue) {
try {
String error = toString(proc.getErrorStream(), StandardCharsets.UTF_8);
throw new CommandFailedException("Command failed with exit code " + actualExitValue + ". Expected " + expectedExitValue + ". Stderr: " + error);
} catch (IOException e) {
throw new CommandFailedException("Command failed with exit code " + actualExitValue + ". Expected " + expectedExitValue + ".");
}
}
} | java | public static void assertExitValue(Process proc, int expectedExitValue) throws CommandFailedException {
int actualExitValue = proc.exitValue();
if (actualExitValue != expectedExitValue) {
try {
String error = toString(proc.getErrorStream(), StandardCharsets.UTF_8);
throw new CommandFailedException("Command failed with exit code " + actualExitValue + ". Expected " + expectedExitValue + ". Stderr: " + error);
} catch (IOException e) {
throw new CommandFailedException("Command failed with exit code " + actualExitValue + ". Expected " + expectedExitValue + ".");
}
}
} | [
"public",
"static",
"void",
"assertExitValue",
"(",
"Process",
"proc",
",",
"int",
"expectedExitValue",
")",
"throws",
"CommandFailedException",
"{",
"int",
"actualExitValue",
"=",
"proc",
".",
"exitValue",
"(",
")",
";",
"if",
"(",
"actualExitValue",
"!=",
"exp... | Fails with a CommandFailedException, if the process did not finish with the expected exit code.
@param proc A finished process
@param expectedExitValue Exit code returned by the process
@throws CommandFailedException Thrown in case of unexpected exit values | [
"Fails",
"with",
"a",
"CommandFailedException",
"if",
"the",
"process",
"did",
"not",
"finish",
"with",
"the",
"expected",
"exit",
"code",
"."
] | train | https://github.com/cryptomator/webdav-nio-adapter/blob/55b0d7dccea9a4ede0a30a95583d8f04c8a86d18/src/main/java/org/cryptomator/frontend/webdav/mount/ProcessUtil.java#L23-L33 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/ops/SDBaseOps.java | SDBaseOps.batchMmul | public SDVariable[] batchMmul(String[] names, SDVariable[] matricesA, SDVariable[] matricesB,
boolean transposeA, boolean transposeB) {
validateSameType("batchMmul", true, matricesA);
validateSameType("batchMmul", true, matricesB);
SDVariable[] result = f().batchMmul(matricesA, matricesB, transposeA, transposeB);
return updateVariableNamesAndReferences(result, names);
} | java | public SDVariable[] batchMmul(String[] names, SDVariable[] matricesA, SDVariable[] matricesB,
boolean transposeA, boolean transposeB) {
validateSameType("batchMmul", true, matricesA);
validateSameType("batchMmul", true, matricesB);
SDVariable[] result = f().batchMmul(matricesA, matricesB, transposeA, transposeB);
return updateVariableNamesAndReferences(result, names);
} | [
"public",
"SDVariable",
"[",
"]",
"batchMmul",
"(",
"String",
"[",
"]",
"names",
",",
"SDVariable",
"[",
"]",
"matricesA",
",",
"SDVariable",
"[",
"]",
"matricesB",
",",
"boolean",
"transposeA",
",",
"boolean",
"transposeB",
")",
"{",
"validateSameType",
"("... | Matrix multiply a batch of matrices. matricesA and matricesB have to be arrays of same
length and each pair taken from these sets has to have dimensions (M, N) and (N, K),
respectively. If transposeA is true, matrices from matricesA will have shape (N, M) instead.
Likewise, if transposeB is true, matrices from matricesB will have shape (K, N).
<p>
<p>
The result of this operation will be a batch of multiplied matrices. The
result has the same length as both input batches and each output matrix is of shape (M, K).
@param matricesA First array of input matrices, all of shape (M, N) or (N, M)
@param matricesB Second array of input matrices, all of shape (N, K) or (K, N)
@param transposeA whether first batch of matrices is transposed.
@param transposeB whether second batch of matrices is transposed.
@param names names for all provided SDVariables
@return Array of multiplied SDVariables of shape (M, K) | [
"Matrix",
"multiply",
"a",
"batch",
"of",
"matrices",
".",
"matricesA",
"and",
"matricesB",
"have",
"to",
"be",
"arrays",
"of",
"same",
"length",
"and",
"each",
"pair",
"taken",
"from",
"these",
"sets",
"has",
"to",
"have",
"dimensions",
"(",
"M",
"N",
"... | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/ops/SDBaseOps.java#L247-L253 |
j-a-w-r/jawr-main-repo | jawr/jawr-core/src/main/java/net/jawr/web/util/FileUtils.java | FileUtils.copyDirectory | public static void copyDirectory(File srcDir, File destDir, FileFilter filter) throws IOException {
copyDirectory(srcDir, destDir, filter, true);
} | java | public static void copyDirectory(File srcDir, File destDir, FileFilter filter) throws IOException {
copyDirectory(srcDir, destDir, filter, true);
} | [
"public",
"static",
"void",
"copyDirectory",
"(",
"File",
"srcDir",
",",
"File",
"destDir",
",",
"FileFilter",
"filter",
")",
"throws",
"IOException",
"{",
"copyDirectory",
"(",
"srcDir",
",",
"destDir",
",",
"filter",
",",
"true",
")",
";",
"}"
] | Copies a filtered directory to a new location preserving the file dates.
<p>
This method copies the contents of the specified source directory to
within the specified destination directory.
<p>
The destination directory is created if it does not exist. If the
destination directory did exist, then this method merges the source with
the destination, with the source taking precedence.
<h4>Example: Copy directories only</h4>
<pre>
// only copy the directory structure
FileUtils.copyDirectory(srcDir, destDir, DirectoryFileFilter.DIRECTORY);
</pre>
<h4>Example: Copy directories and txt files</h4>
<pre>
// Create a filter for ".txt" files
IOFileFilter txtSuffixFilter = FileFilterUtils.suffixFileFilter(".txt");
IOFileFilter txtFiles = FileFilterUtils.andFileFilter(FileFileFilter.FILE, txtSuffixFilter);
// Create a filter for either directories or ".txt" files
FileFilter filter = FileFilterUtils.orFileFilter(DirectoryFileFilter.DIRECTORY, txtFiles);
// Copy using the filter
FileUtils.copyDirectory(srcDir, destDir, filter);
</pre>
@param srcDir
an existing directory to copy, must not be <code>null</code>
@param destDir
the new directory, must not be <code>null</code>
@param filter
the filter to apply, null means copy all directories and files
should be the same as the original
@throws NullPointerException
if source or destination is <code>null</code>
@throws IOException
if source or destination is invalid
@throws IOException
if an IO error occurs during copying
@since Commons IO 1.4 | [
"Copies",
"a",
"filtered",
"directory",
"to",
"a",
"new",
"location",
"preserving",
"the",
"file",
"dates",
".",
"<p",
">",
"This",
"method",
"copies",
"the",
"contents",
"of",
"the",
"specified",
"source",
"directory",
"to",
"within",
"the",
"specified",
"d... | train | https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/util/FileUtils.java#L350-L352 |
google/j2objc | jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | BigDecimal.needIncrement | private static boolean needIncrement(long ldivisor, int roundingMode,
int qsign, MutableBigInteger mq, long r) {
assert r != 0L;
int cmpFracHalf;
if (r <= HALF_LONG_MIN_VALUE || r > HALF_LONG_MAX_VALUE) {
cmpFracHalf = 1; // 2 * r can't fit into long
} else {
cmpFracHalf = longCompareMagnitude(2 * r, ldivisor);
}
return commonNeedIncrement(roundingMode, qsign, cmpFracHalf, mq.isOdd());
} | java | private static boolean needIncrement(long ldivisor, int roundingMode,
int qsign, MutableBigInteger mq, long r) {
assert r != 0L;
int cmpFracHalf;
if (r <= HALF_LONG_MIN_VALUE || r > HALF_LONG_MAX_VALUE) {
cmpFracHalf = 1; // 2 * r can't fit into long
} else {
cmpFracHalf = longCompareMagnitude(2 * r, ldivisor);
}
return commonNeedIncrement(roundingMode, qsign, cmpFracHalf, mq.isOdd());
} | [
"private",
"static",
"boolean",
"needIncrement",
"(",
"long",
"ldivisor",
",",
"int",
"roundingMode",
",",
"int",
"qsign",
",",
"MutableBigInteger",
"mq",
",",
"long",
"r",
")",
"{",
"assert",
"r",
"!=",
"0L",
";",
"int",
"cmpFracHalf",
";",
"if",
"(",
"... | Tests if quotient has to be incremented according the roundingMode | [
"Tests",
"if",
"quotient",
"has",
"to",
"be",
"incremented",
"according",
"the",
"roundingMode"
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java#L4275-L4287 |
alkacon/opencms-core | src/org/opencms/ui/components/CmsVerticalMenu.java | CmsVerticalMenu.addMenuEntry | public Button addMenuEntry(String label, Resource icon) {
Button button = new Button(label, icon);
button.setPrimaryStyleName(OpenCmsTheme.VERTICAL_MENU_ITEM);
addComponent(button);
return button;
} | java | public Button addMenuEntry(String label, Resource icon) {
Button button = new Button(label, icon);
button.setPrimaryStyleName(OpenCmsTheme.VERTICAL_MENU_ITEM);
addComponent(button);
return button;
} | [
"public",
"Button",
"addMenuEntry",
"(",
"String",
"label",
",",
"Resource",
"icon",
")",
"{",
"Button",
"button",
"=",
"new",
"Button",
"(",
"label",
",",
"icon",
")",
";",
"button",
".",
"setPrimaryStyleName",
"(",
"OpenCmsTheme",
".",
"VERTICAL_MENU_ITEM",
... | Adds an entry to the menu, returns the entry button.<p>
@param label the label
@param icon the icon
@return the entry button | [
"Adds",
"an",
"entry",
"to",
"the",
"menu",
"returns",
"the",
"entry",
"button",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/components/CmsVerticalMenu.java#L69-L75 |
stephenc/redmine-java-api | src/main/java/org/redmine/ta/internal/RedmineJSONParser.java | RedmineJSONParser.parseStatus | public static IssueStatus parseStatus(JSONObject object)
throws JSONException {
final int id = JsonInput.getInt(object, "id");
final String name = JsonInput.getStringNotNull(object, "name");
final IssueStatus result = new IssueStatus(id, name);
if (object.has("is_default"))
result.setDefaultStatus(JsonInput.getOptionalBool(object,
"is_default"));
if (object.has("is_closed"))
result.setClosed(JsonInput.getOptionalBool(object, "is_closed"));
return result;
} | java | public static IssueStatus parseStatus(JSONObject object)
throws JSONException {
final int id = JsonInput.getInt(object, "id");
final String name = JsonInput.getStringNotNull(object, "name");
final IssueStatus result = new IssueStatus(id, name);
if (object.has("is_default"))
result.setDefaultStatus(JsonInput.getOptionalBool(object,
"is_default"));
if (object.has("is_closed"))
result.setClosed(JsonInput.getOptionalBool(object, "is_closed"));
return result;
} | [
"public",
"static",
"IssueStatus",
"parseStatus",
"(",
"JSONObject",
"object",
")",
"throws",
"JSONException",
"{",
"final",
"int",
"id",
"=",
"JsonInput",
".",
"getInt",
"(",
"object",
",",
"\"id\"",
")",
";",
"final",
"String",
"name",
"=",
"JsonInput",
".... | Parses a status.
@param object
object to parse.
@return parsed tracker.
@throws RedmineFormatException
if object is not a valid tracker. | [
"Parses",
"a",
"status",
"."
] | train | https://github.com/stephenc/redmine-java-api/blob/7e5270c84aba32d74a506260ec47ff86ab6c9d84/src/main/java/org/redmine/ta/internal/RedmineJSONParser.java#L205-L216 |
jtrfp/javamod | src/main/java/de/quippy/javamod/multimedia/mp3/id3/MPEGAudioFrameHeader.java | MPEGAudioFrameHeader.findFrame | private long findFrame(RandomAccessInputStream raf, int offset) throws IOException
{
long loc = -1;
raf.seek(offset);
while (loc == -1)
{
byte test = raf.readByte();
if ((test & 0xFF) == 0xFF)
{
test = raf.readByte();
if ((test & 0xE0) == 0xE0)
{
return raf.getFilePointer() - 2;
}
}
}
return -1;
} | java | private long findFrame(RandomAccessInputStream raf, int offset) throws IOException
{
long loc = -1;
raf.seek(offset);
while (loc == -1)
{
byte test = raf.readByte();
if ((test & 0xFF) == 0xFF)
{
test = raf.readByte();
if ((test & 0xE0) == 0xE0)
{
return raf.getFilePointer() - 2;
}
}
}
return -1;
} | [
"private",
"long",
"findFrame",
"(",
"RandomAccessInputStream",
"raf",
",",
"int",
"offset",
")",
"throws",
"IOException",
"{",
"long",
"loc",
"=",
"-",
"1",
";",
"raf",
".",
"seek",
"(",
"offset",
")",
";",
"while",
"(",
"loc",
"==",
"-",
"1",
")",
... | Searches through the file and finds the first occurrence of an mpeg
frame. Returns the location of the header of the frame.
@param offset the offset to start searching from
@return the location of the header of the frame
@exception FileNotFoundException if an error occurs
@exception IOException if an error occurs | [
"Searches",
"through",
"the",
"file",
"and",
"finds",
"the",
"first",
"occurrence",
"of",
"an",
"mpeg",
"frame",
".",
"Returns",
"the",
"location",
"of",
"the",
"header",
"of",
"the",
"frame",
"."
] | train | https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/javamod/multimedia/mp3/id3/MPEGAudioFrameHeader.java#L194-L215 |
powermock/powermock | powermock-reflect/src/main/java/org/powermock/reflect/internal/WhiteboxImpl.java | WhiteboxImpl.getInternalState | @SuppressWarnings("unchecked")
public static <T> T getInternalState(Object object, String fieldName) {
Field foundField = findFieldInHierarchy(object, fieldName);
try {
return (T) foundField.get(object);
} catch (IllegalAccessException e) {
throw new RuntimeException("Internal error: Failed to get field in method getInternalState.", e);
}
} | java | @SuppressWarnings("unchecked")
public static <T> T getInternalState(Object object, String fieldName) {
Field foundField = findFieldInHierarchy(object, fieldName);
try {
return (T) foundField.get(object);
} catch (IllegalAccessException e) {
throw new RuntimeException("Internal error: Failed to get field in method getInternalState.", e);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"T",
">",
"T",
"getInternalState",
"(",
"Object",
"object",
",",
"String",
"fieldName",
")",
"{",
"Field",
"foundField",
"=",
"findFieldInHierarchy",
"(",
"object",
",",
"fieldName",
... | Get the value of a field using reflection. This method will iterate
through the entire class hierarchy and return the value of the first
field named <tt>fieldName</tt>. If you want to get a specific field value
at specific place in the class hierarchy please refer to
@param <T> the generic type
@param object the object to modify
@param fieldName the name of the field
@return the internal state
{@link #getInternalState(Object, String, Class)}. | [
"Get",
"the",
"value",
"of",
"a",
"field",
"using",
"reflection",
".",
"This",
"method",
"will",
"iterate",
"through",
"the",
"entire",
"class",
"hierarchy",
"and",
"return",
"the",
"value",
"of",
"the",
"first",
"field",
"named",
"<tt",
">",
"fieldName<",
... | train | https://github.com/powermock/powermock/blob/e8cd68026c284c6a7efe66959809eeebd8d1f9ad/powermock-reflect/src/main/java/org/powermock/reflect/internal/WhiteboxImpl.java#L424-L432 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.