repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
sequencelengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
sequencelengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
m-m-m/util | exception/src/main/java/net/sf/mmm/util/exception/api/ThrowableHelper.java | ThrowableHelper.removeDetails | static void removeDetails(Throwable throwable, ExceptionTruncation truncation) {
"""
@see NlsThrowable#createCopy(ExceptionTruncation)
@param throwable is the {@link Throwable} to truncate.
@param truncation the {@link ExceptionTruncation} settings.
"""
if (truncation.isRemoveStacktrace()) {
throwable.setStackTrace(ExceptionUtil.NO_STACKTRACE);
}
if (truncation.isRemoveCause()) {
getHelper().setCause(throwable, null);
}
if (truncation.isRemoveSuppressed()) {
getHelper().setSuppressed(throwable, null);
}
} | java | static void removeDetails(Throwable throwable, ExceptionTruncation truncation) {
if (truncation.isRemoveStacktrace()) {
throwable.setStackTrace(ExceptionUtil.NO_STACKTRACE);
}
if (truncation.isRemoveCause()) {
getHelper().setCause(throwable, null);
}
if (truncation.isRemoveSuppressed()) {
getHelper().setSuppressed(throwable, null);
}
} | [
"static",
"void",
"removeDetails",
"(",
"Throwable",
"throwable",
",",
"ExceptionTruncation",
"truncation",
")",
"{",
"if",
"(",
"truncation",
".",
"isRemoveStacktrace",
"(",
")",
")",
"{",
"throwable",
".",
"setStackTrace",
"(",
"ExceptionUtil",
".",
"NO_STACKTRACE",
")",
";",
"}",
"if",
"(",
"truncation",
".",
"isRemoveCause",
"(",
")",
")",
"{",
"getHelper",
"(",
")",
".",
"setCause",
"(",
"throwable",
",",
"null",
")",
";",
"}",
"if",
"(",
"truncation",
".",
"isRemoveSuppressed",
"(",
")",
")",
"{",
"getHelper",
"(",
")",
".",
"setSuppressed",
"(",
"throwable",
",",
"null",
")",
";",
"}",
"}"
] | @see NlsThrowable#createCopy(ExceptionTruncation)
@param throwable is the {@link Throwable} to truncate.
@param truncation the {@link ExceptionTruncation} settings. | [
"@see",
"NlsThrowable#createCopy",
"(",
"ExceptionTruncation",
")"
] | train | https://github.com/m-m-m/util/blob/f0e4e084448f8dfc83ca682a9e1618034a094ce6/exception/src/main/java/net/sf/mmm/util/exception/api/ThrowableHelper.java#L48-L59 |
jcuda/jcuda | JCudaJava/src/main/java/jcuda/nvrtc/JNvrtc.java | JNvrtc.nvrtcCompileProgram | public static int nvrtcCompileProgram(nvrtcProgram prog,
int numOptions, String options[]) {
"""
Compiles the given program. See the
<a href="http://docs.nvidia.com/cuda/nvrtc/index.html#group__options"
target="_blank">Supported Compile Options (external site)</a>
@param prog CUDA Runtime Compilation program.
@param numOptions The number of options
@param options The options
@return An error code
"""
return checkResult(nvrtcCompileProgramNative(
prog, numOptions, options));
} | java | public static int nvrtcCompileProgram(nvrtcProgram prog,
int numOptions, String options[])
{
return checkResult(nvrtcCompileProgramNative(
prog, numOptions, options));
} | [
"public",
"static",
"int",
"nvrtcCompileProgram",
"(",
"nvrtcProgram",
"prog",
",",
"int",
"numOptions",
",",
"String",
"options",
"[",
"]",
")",
"{",
"return",
"checkResult",
"(",
"nvrtcCompileProgramNative",
"(",
"prog",
",",
"numOptions",
",",
"options",
")",
")",
";",
"}"
] | Compiles the given program. See the
<a href="http://docs.nvidia.com/cuda/nvrtc/index.html#group__options"
target="_blank">Supported Compile Options (external site)</a>
@param prog CUDA Runtime Compilation program.
@param numOptions The number of options
@param options The options
@return An error code | [
"Compiles",
"the",
"given",
"program",
".",
"See",
"the",
"<a",
"href",
"=",
"http",
":",
"//",
"docs",
".",
"nvidia",
".",
"com",
"/",
"cuda",
"/",
"nvrtc",
"/",
"index",
".",
"html#group__options",
"target",
"=",
"_blank",
">",
"Supported",
"Compile",
"Options",
"(",
"external",
"site",
")",
"<",
"/",
"a",
">"
] | train | https://github.com/jcuda/jcuda/blob/468528b5b9b37dfceb6ed83fcfd889e9b359f984/JCudaJava/src/main/java/jcuda/nvrtc/JNvrtc.java#L204-L209 |
SUSE/salt-netapi-client | src/main/java/com/suse/salt/netapi/calls/modules/File.java | File.getHash | public static LocalCall<String> getHash(String path) {
"""
Get the hash sum of a file
<p>
SHA256 algorithm is used by default
@param path Path to the file or directory
@return The {@link LocalCall} object to make the call
"""
return getHash(path, Optional.empty(), Optional.empty());
} | java | public static LocalCall<String> getHash(String path) {
return getHash(path, Optional.empty(), Optional.empty());
} | [
"public",
"static",
"LocalCall",
"<",
"String",
">",
"getHash",
"(",
"String",
"path",
")",
"{",
"return",
"getHash",
"(",
"path",
",",
"Optional",
".",
"empty",
"(",
")",
",",
"Optional",
".",
"empty",
"(",
")",
")",
";",
"}"
] | Get the hash sum of a file
<p>
SHA256 algorithm is used by default
@param path Path to the file or directory
@return The {@link LocalCall} object to make the call | [
"Get",
"the",
"hash",
"sum",
"of",
"a",
"file",
"<p",
">",
"SHA256",
"algorithm",
"is",
"used",
"by",
"default"
] | train | https://github.com/SUSE/salt-netapi-client/blob/a0bdf643c8e34fa4def4b915366594c1491fdad5/src/main/java/com/suse/salt/netapi/calls/modules/File.java#L120-L122 |
cdk/cdk | base/core/src/main/java/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java | CDKAtomTypeMatcher.isSingleHeteroAtom | private boolean isSingleHeteroAtom(IAtom atom, IAtomContainer container) {
"""
Determines whether the bonds (up to two spheres away) are only to non
hetroatoms. Currently used in N.planar3 perception of (e.g. pyrrole).
@param atom an atom to test
@param container container of the atom
@return whether the atom's only bonds are to heteroatoms
@see #perceiveNitrogens(IAtomContainer, IAtom, RingSearch, List)
"""
List<IAtom> connected = container.getConnectedAtomsList(atom);
for (IAtom atom1 : connected) {
boolean aromatic = container.getBond(atom, atom1).isAromatic();
// ignoring non-aromatic bonds
if (!aromatic) continue;
// found a hetroatom - we're not a single hetroatom
if (!"C".equals(atom1.getSymbol())) return false;
// check the second sphere
for (IAtom atom2 : container.getConnectedAtomsList(atom1)) {
if (!atom2.equals(atom) && container.getBond(atom1, atom2).isAromatic()
&& !"C".equals(atom2.getSymbol())) {
return false;
}
}
}
return true;
} | java | private boolean isSingleHeteroAtom(IAtom atom, IAtomContainer container) {
List<IAtom> connected = container.getConnectedAtomsList(atom);
for (IAtom atom1 : connected) {
boolean aromatic = container.getBond(atom, atom1).isAromatic();
// ignoring non-aromatic bonds
if (!aromatic) continue;
// found a hetroatom - we're not a single hetroatom
if (!"C".equals(atom1.getSymbol())) return false;
// check the second sphere
for (IAtom atom2 : container.getConnectedAtomsList(atom1)) {
if (!atom2.equals(atom) && container.getBond(atom1, atom2).isAromatic()
&& !"C".equals(atom2.getSymbol())) {
return false;
}
}
}
return true;
} | [
"private",
"boolean",
"isSingleHeteroAtom",
"(",
"IAtom",
"atom",
",",
"IAtomContainer",
"container",
")",
"{",
"List",
"<",
"IAtom",
">",
"connected",
"=",
"container",
".",
"getConnectedAtomsList",
"(",
"atom",
")",
";",
"for",
"(",
"IAtom",
"atom1",
":",
"connected",
")",
"{",
"boolean",
"aromatic",
"=",
"container",
".",
"getBond",
"(",
"atom",
",",
"atom1",
")",
".",
"isAromatic",
"(",
")",
";",
"// ignoring non-aromatic bonds",
"if",
"(",
"!",
"aromatic",
")",
"continue",
";",
"// found a hetroatom - we're not a single hetroatom",
"if",
"(",
"!",
"\"C\"",
".",
"equals",
"(",
"atom1",
".",
"getSymbol",
"(",
")",
")",
")",
"return",
"false",
";",
"// check the second sphere",
"for",
"(",
"IAtom",
"atom2",
":",
"container",
".",
"getConnectedAtomsList",
"(",
"atom1",
")",
")",
"{",
"if",
"(",
"!",
"atom2",
".",
"equals",
"(",
"atom",
")",
"&&",
"container",
".",
"getBond",
"(",
"atom1",
",",
"atom2",
")",
".",
"isAromatic",
"(",
")",
"&&",
"!",
"\"C\"",
".",
"equals",
"(",
"atom2",
".",
"getSymbol",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"return",
"true",
";",
"}"
] | Determines whether the bonds (up to two spheres away) are only to non
hetroatoms. Currently used in N.planar3 perception of (e.g. pyrrole).
@param atom an atom to test
@param container container of the atom
@return whether the atom's only bonds are to heteroatoms
@see #perceiveNitrogens(IAtomContainer, IAtom, RingSearch, List) | [
"Determines",
"whether",
"the",
"bonds",
"(",
"up",
"to",
"two",
"spheres",
"away",
")",
"are",
"only",
"to",
"non",
"hetroatoms",
".",
"Currently",
"used",
"in",
"N",
".",
"planar3",
"perception",
"of",
"(",
"e",
".",
"g",
".",
"pyrrole",
")",
"."
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/base/core/src/main/java/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java#L989-L1017 |
mbeiter/util | db/src/main/java/org/beiter/michael/db/ConnectionProperties.java | ConnectionProperties.setAdditionalProperties | public final void setAdditionalProperties(final Map<String, String> additionalProperties) {
"""
Any additional properties which have not been parsed, and for which no getter/setter exists, but are to be
stored in this object nevertheless.
<p>
This property is commonly used to preserve original properties from upstream components that are to be passed
on to downstream components unchanged. This properties set may or may not include properties that have been
extracted from the map, and been made available through this POJO.
<p>
Note that these additional properties may be <code>null</code> or empty, even in a fully populated POJO where
other properties commonly have values assigned to.
@param additionalProperties The additional properties to store
"""
// no need for validation, the method will create a new (empty) object if the provided parameter is null.
// create a defensive copy of the map and all its properties
if (additionalProperties == null) {
// create a new (empty) properties map if the provided parameter was null
this.additionalProperties = new ConcurrentHashMap<>();
} else {
// create a defensive copy of the map and all its properties
// the code looks a little more complicated than a simple "putAll()", but it catches situations
// where a Map is provided that supports null values (e.g. a HashMap) vs Map implementations
// that do not (e.g. ConcurrentHashMap).
this.additionalProperties = new ConcurrentHashMap<>();
for (final Map.Entry<String, String> entry : additionalProperties.entrySet()) {
final String key = entry.getKey();
final String value = entry.getValue();
if (value != null) {
this.additionalProperties.put(key, value);
}
}
}
} | java | public final void setAdditionalProperties(final Map<String, String> additionalProperties) {
// no need for validation, the method will create a new (empty) object if the provided parameter is null.
// create a defensive copy of the map and all its properties
if (additionalProperties == null) {
// create a new (empty) properties map if the provided parameter was null
this.additionalProperties = new ConcurrentHashMap<>();
} else {
// create a defensive copy of the map and all its properties
// the code looks a little more complicated than a simple "putAll()", but it catches situations
// where a Map is provided that supports null values (e.g. a HashMap) vs Map implementations
// that do not (e.g. ConcurrentHashMap).
this.additionalProperties = new ConcurrentHashMap<>();
for (final Map.Entry<String, String> entry : additionalProperties.entrySet()) {
final String key = entry.getKey();
final String value = entry.getValue();
if (value != null) {
this.additionalProperties.put(key, value);
}
}
}
} | [
"public",
"final",
"void",
"setAdditionalProperties",
"(",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"additionalProperties",
")",
"{",
"// no need for validation, the method will create a new (empty) object if the provided parameter is null.",
"// create a defensive copy of the map and all its properties",
"if",
"(",
"additionalProperties",
"==",
"null",
")",
"{",
"// create a new (empty) properties map if the provided parameter was null",
"this",
".",
"additionalProperties",
"=",
"new",
"ConcurrentHashMap",
"<>",
"(",
")",
";",
"}",
"else",
"{",
"// create a defensive copy of the map and all its properties",
"// the code looks a little more complicated than a simple \"putAll()\", but it catches situations",
"// where a Map is provided that supports null values (e.g. a HashMap) vs Map implementations",
"// that do not (e.g. ConcurrentHashMap).",
"this",
".",
"additionalProperties",
"=",
"new",
"ConcurrentHashMap",
"<>",
"(",
")",
";",
"for",
"(",
"final",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"additionalProperties",
".",
"entrySet",
"(",
")",
")",
"{",
"final",
"String",
"key",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"final",
"String",
"value",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"this",
".",
"additionalProperties",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"}",
"}",
"}",
"}"
] | Any additional properties which have not been parsed, and for which no getter/setter exists, but are to be
stored in this object nevertheless.
<p>
This property is commonly used to preserve original properties from upstream components that are to be passed
on to downstream components unchanged. This properties set may or may not include properties that have been
extracted from the map, and been made available through this POJO.
<p>
Note that these additional properties may be <code>null</code> or empty, even in a fully populated POJO where
other properties commonly have values assigned to.
@param additionalProperties The additional properties to store | [
"Any",
"additional",
"properties",
"which",
"have",
"not",
"been",
"parsed",
"and",
"for",
"which",
"no",
"getter",
"/",
"setter",
"exists",
"but",
"are",
"to",
"be",
"stored",
"in",
"this",
"object",
"nevertheless",
".",
"<p",
">",
"This",
"property",
"is",
"commonly",
"used",
"to",
"preserve",
"original",
"properties",
"from",
"upstream",
"components",
"that",
"are",
"to",
"be",
"passed",
"on",
"to",
"downstream",
"components",
"unchanged",
".",
"This",
"properties",
"set",
"may",
"or",
"may",
"not",
"include",
"properties",
"that",
"have",
"been",
"extracted",
"from",
"the",
"map",
"and",
"been",
"made",
"available",
"through",
"this",
"POJO",
".",
"<p",
">",
"Note",
"that",
"these",
"additional",
"properties",
"may",
"be",
"<code",
">",
"null<",
"/",
"code",
">",
"or",
"empty",
"even",
"in",
"a",
"fully",
"populated",
"POJO",
"where",
"other",
"properties",
"commonly",
"have",
"values",
"assigned",
"to",
"."
] | train | https://github.com/mbeiter/util/blob/490fcebecb936e00c2f2ce2096b679b2fd10865e/db/src/main/java/org/beiter/michael/db/ConnectionProperties.java#L889-L912 |
liyiorg/weixin-popular | src/main/java/weixin/popular/api/CustomserviceAPI.java | CustomserviceAPI.kfsessionClose | public static BaseResult kfsessionClose(String access_token, String kf_account, String openid, String text) {
"""
关闭会话
@param access_token access_token
@param kf_account 完整客服账号
@param openid 客户openid
@param text 附加信息,非必须
@return BaseResult
"""
String postJsonData = String.format("{\"kf_account\":\"%1s\",\"openid\":\"%2s\",\"text\":\"%3s\"}",
kf_account,
openid,
text);
HttpUriRequest httpUriRequest = RequestBuilder.post()
.setHeader(jsonHeader)
.setUri(BASE_URI + "/customservice/kfsession/close")
.addParameter(PARAM_ACCESS_TOKEN, API.accessToken(access_token))
.setEntity(new StringEntity(postJsonData, Charset.forName("utf-8")))
.build();
return LocalHttpClient.executeJsonResult(httpUriRequest, BaseResult.class);
} | java | public static BaseResult kfsessionClose(String access_token, String kf_account, String openid, String text) {
String postJsonData = String.format("{\"kf_account\":\"%1s\",\"openid\":\"%2s\",\"text\":\"%3s\"}",
kf_account,
openid,
text);
HttpUriRequest httpUriRequest = RequestBuilder.post()
.setHeader(jsonHeader)
.setUri(BASE_URI + "/customservice/kfsession/close")
.addParameter(PARAM_ACCESS_TOKEN, API.accessToken(access_token))
.setEntity(new StringEntity(postJsonData, Charset.forName("utf-8")))
.build();
return LocalHttpClient.executeJsonResult(httpUriRequest, BaseResult.class);
} | [
"public",
"static",
"BaseResult",
"kfsessionClose",
"(",
"String",
"access_token",
",",
"String",
"kf_account",
",",
"String",
"openid",
",",
"String",
"text",
")",
"{",
"String",
"postJsonData",
"=",
"String",
".",
"format",
"(",
"\"{\\\"kf_account\\\":\\\"%1s\\\",\\\"openid\\\":\\\"%2s\\\",\\\"text\\\":\\\"%3s\\\"}\"",
",",
"kf_account",
",",
"openid",
",",
"text",
")",
";",
"HttpUriRequest",
"httpUriRequest",
"=",
"RequestBuilder",
".",
"post",
"(",
")",
".",
"setHeader",
"(",
"jsonHeader",
")",
".",
"setUri",
"(",
"BASE_URI",
"+",
"\"/customservice/kfsession/close\"",
")",
".",
"addParameter",
"(",
"PARAM_ACCESS_TOKEN",
",",
"API",
".",
"accessToken",
"(",
"access_token",
")",
")",
".",
"setEntity",
"(",
"new",
"StringEntity",
"(",
"postJsonData",
",",
"Charset",
".",
"forName",
"(",
"\"utf-8\"",
")",
")",
")",
".",
"build",
"(",
")",
";",
"return",
"LocalHttpClient",
".",
"executeJsonResult",
"(",
"httpUriRequest",
",",
"BaseResult",
".",
"class",
")",
";",
"}"
] | 关闭会话
@param access_token access_token
@param kf_account 完整客服账号
@param openid 客户openid
@param text 附加信息,非必须
@return BaseResult | [
"关闭会话"
] | train | https://github.com/liyiorg/weixin-popular/blob/c64255292d41463bdb671938feaabf42a335d82c/src/main/java/weixin/popular/api/CustomserviceAPI.java#L166-L178 |
phax/ph-bdve | ph-bdve-ebinterface/src/main/java/com/helger/bdve/ebinterface/EbInterfaceValidation.java | EbInterfaceValidation.initEbInterface | public static void initEbInterface (@Nonnull final ValidationExecutorSetRegistry aRegistry) {
"""
Register all standard TEAPPS validation execution sets to the provided
registry.
@param aRegistry
The registry to add the artefacts. May not be <code>null</code>.
"""
ValueEnforcer.notNull (aRegistry, "Registry");
final boolean bNotDeprecated = false;
// No Schematrons here
for (final EEbInterfaceDocumentType e : EEbInterfaceDocumentType.values ())
{
final String sVersion = e.name ().charAt (3) + "." + e.name ().substring (4);
final VESID aVESID = new VESID (GROUP_ID, "invoice", sVersion);
// No Schematrons here
aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (aVESID,
"ebInterface " + sVersion,
bNotDeprecated,
ValidationExecutorXSD.create (e)));
}
} | java | public static void initEbInterface (@Nonnull final ValidationExecutorSetRegistry aRegistry)
{
ValueEnforcer.notNull (aRegistry, "Registry");
final boolean bNotDeprecated = false;
// No Schematrons here
for (final EEbInterfaceDocumentType e : EEbInterfaceDocumentType.values ())
{
final String sVersion = e.name ().charAt (3) + "." + e.name ().substring (4);
final VESID aVESID = new VESID (GROUP_ID, "invoice", sVersion);
// No Schematrons here
aRegistry.registerValidationExecutorSet (ValidationExecutorSet.create (aVESID,
"ebInterface " + sVersion,
bNotDeprecated,
ValidationExecutorXSD.create (e)));
}
} | [
"public",
"static",
"void",
"initEbInterface",
"(",
"@",
"Nonnull",
"final",
"ValidationExecutorSetRegistry",
"aRegistry",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aRegistry",
",",
"\"Registry\"",
")",
";",
"final",
"boolean",
"bNotDeprecated",
"=",
"false",
";",
"// No Schematrons here",
"for",
"(",
"final",
"EEbInterfaceDocumentType",
"e",
":",
"EEbInterfaceDocumentType",
".",
"values",
"(",
")",
")",
"{",
"final",
"String",
"sVersion",
"=",
"e",
".",
"name",
"(",
")",
".",
"charAt",
"(",
"3",
")",
"+",
"\".\"",
"+",
"e",
".",
"name",
"(",
")",
".",
"substring",
"(",
"4",
")",
";",
"final",
"VESID",
"aVESID",
"=",
"new",
"VESID",
"(",
"GROUP_ID",
",",
"\"invoice\"",
",",
"sVersion",
")",
";",
"// No Schematrons here",
"aRegistry",
".",
"registerValidationExecutorSet",
"(",
"ValidationExecutorSet",
".",
"create",
"(",
"aVESID",
",",
"\"ebInterface \"",
"+",
"sVersion",
",",
"bNotDeprecated",
",",
"ValidationExecutorXSD",
".",
"create",
"(",
"e",
")",
")",
")",
";",
"}",
"}"
] | Register all standard TEAPPS validation execution sets to the provided
registry.
@param aRegistry
The registry to add the artefacts. May not be <code>null</code>. | [
"Register",
"all",
"standard",
"TEAPPS",
"validation",
"execution",
"sets",
"to",
"the",
"provided",
"registry",
"."
] | train | https://github.com/phax/ph-bdve/blob/2438f491174cd8989567fcdf129b273bd217e89f/ph-bdve-ebinterface/src/main/java/com/helger/bdve/ebinterface/EbInterfaceValidation.java#L57-L75 |
JodaOrg/joda-time | src/main/java/org/joda/time/chrono/BasicChronology.java | BasicChronology.getDaysInMonthMax | int getDaysInMonthMax(long instant) {
"""
Gets the maximum number of days in the month specified by the instant.
@param instant millis from 1970-01-01T00:00:00Z
@return the maximum number of days in the month
"""
int thisYear = getYear(instant);
int thisMonth = getMonthOfYear(instant, thisYear);
return getDaysInYearMonth(thisYear, thisMonth);
} | java | int getDaysInMonthMax(long instant) {
int thisYear = getYear(instant);
int thisMonth = getMonthOfYear(instant, thisYear);
return getDaysInYearMonth(thisYear, thisMonth);
} | [
"int",
"getDaysInMonthMax",
"(",
"long",
"instant",
")",
"{",
"int",
"thisYear",
"=",
"getYear",
"(",
"instant",
")",
";",
"int",
"thisMonth",
"=",
"getMonthOfYear",
"(",
"instant",
",",
"thisYear",
")",
";",
"return",
"getDaysInYearMonth",
"(",
"thisYear",
",",
"thisMonth",
")",
";",
"}"
] | Gets the maximum number of days in the month specified by the instant.
@param instant millis from 1970-01-01T00:00:00Z
@return the maximum number of days in the month | [
"Gets",
"the",
"maximum",
"number",
"of",
"days",
"in",
"the",
"month",
"specified",
"by",
"the",
"instant",
"."
] | train | https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/chrono/BasicChronology.java#L601-L605 |
OpenLiberty/open-liberty | dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/webapp/WebGroup.java | WebGroup.stripURL | public static String stripURL(String url,boolean checkQuestionMark) {
"""
This method strips out the session identifier and the queryString (based on the boolean value)
from a request URI, and returns the resultant 'pure' URI
@param url
@param checkQuestionMark
@return
"""
if (url == null)
return null;
int index1 = url.indexOf(sessUrlRewritePrefix);
if (checkQuestionMark){
int index2 = url.indexOf("?");
if (index2 != -1)
{
if ( index1 > index2 )
throw new IllegalArgumentException( "'jsessionid' Must occur before '?' in URL." );
url = url.substring(0, index2);
}
}
if (index1 != -1)
{
// No query string so just remove the jsessionid
url = url.substring(0, index1);
}
return url;
} | java | public static String stripURL(String url,boolean checkQuestionMark)
{
if (url == null)
return null;
int index1 = url.indexOf(sessUrlRewritePrefix);
if (checkQuestionMark){
int index2 = url.indexOf("?");
if (index2 != -1)
{
if ( index1 > index2 )
throw new IllegalArgumentException( "'jsessionid' Must occur before '?' in URL." );
url = url.substring(0, index2);
}
}
if (index1 != -1)
{
// No query string so just remove the jsessionid
url = url.substring(0, index1);
}
return url;
} | [
"public",
"static",
"String",
"stripURL",
"(",
"String",
"url",
",",
"boolean",
"checkQuestionMark",
")",
"{",
"if",
"(",
"url",
"==",
"null",
")",
"return",
"null",
";",
"int",
"index1",
"=",
"url",
".",
"indexOf",
"(",
"sessUrlRewritePrefix",
")",
";",
"if",
"(",
"checkQuestionMark",
")",
"{",
"int",
"index2",
"=",
"url",
".",
"indexOf",
"(",
"\"?\"",
")",
";",
"if",
"(",
"index2",
"!=",
"-",
"1",
")",
"{",
"if",
"(",
"index1",
">",
"index2",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"'jsessionid' Must occur before '?' in URL.\"",
")",
";",
"url",
"=",
"url",
".",
"substring",
"(",
"0",
",",
"index2",
")",
";",
"}",
"}",
"if",
"(",
"index1",
"!=",
"-",
"1",
")",
"{",
"// No query string so just remove the jsessionid",
"url",
"=",
"url",
".",
"substring",
"(",
"0",
",",
"index1",
")",
";",
"}",
"return",
"url",
";",
"}"
] | This method strips out the session identifier and the queryString (based on the boolean value)
from a request URI, and returns the resultant 'pure' URI
@param url
@param checkQuestionMark
@return | [
"This",
"method",
"strips",
"out",
"the",
"session",
"identifier",
"and",
"the",
"queryString",
"(",
"based",
"on",
"the",
"boolean",
"value",
")",
"from",
"a",
"request",
"URI",
"and",
"returns",
"the",
"resultant",
"pure",
"URI"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/webapp/WebGroup.java#L361-L385 |
google/closure-compiler | src/com/google/javascript/jscomp/GlobalVarReferenceMap.java | GlobalVarReferenceMap.findSourceRefRange | private SourceRefRange findSourceRefRange(List<Reference> refList,
InputId inputId) {
"""
Finds the range of references associated to {@code sourceName}. Note that
even if there is no sourceName references the returned information can be
used to decide where to insert new sourceName refs.
"""
checkNotNull(inputId);
// TODO(bashir): We can do binary search here, but since this is fast enough
// right now, we just do a linear search for simplicity.
int lastBefore = -1;
int firstAfter = refList.size();
int index = 0;
checkState(inputOrder.containsKey(inputId), inputId.getIdName());
int sourceInputOrder = inputOrder.get(inputId);
for (Reference ref : refList) {
checkNotNull(ref.getInputId());
int order = inputOrder.get(ref.getInputId());
if (order < sourceInputOrder) {
lastBefore = index;
} else if (order > sourceInputOrder) {
firstAfter = index;
break;
}
index++;
}
return new SourceRefRange(refList, lastBefore, firstAfter);
} | java | private SourceRefRange findSourceRefRange(List<Reference> refList,
InputId inputId) {
checkNotNull(inputId);
// TODO(bashir): We can do binary search here, but since this is fast enough
// right now, we just do a linear search for simplicity.
int lastBefore = -1;
int firstAfter = refList.size();
int index = 0;
checkState(inputOrder.containsKey(inputId), inputId.getIdName());
int sourceInputOrder = inputOrder.get(inputId);
for (Reference ref : refList) {
checkNotNull(ref.getInputId());
int order = inputOrder.get(ref.getInputId());
if (order < sourceInputOrder) {
lastBefore = index;
} else if (order > sourceInputOrder) {
firstAfter = index;
break;
}
index++;
}
return new SourceRefRange(refList, lastBefore, firstAfter);
} | [
"private",
"SourceRefRange",
"findSourceRefRange",
"(",
"List",
"<",
"Reference",
">",
"refList",
",",
"InputId",
"inputId",
")",
"{",
"checkNotNull",
"(",
"inputId",
")",
";",
"// TODO(bashir): We can do binary search here, but since this is fast enough",
"// right now, we just do a linear search for simplicity.",
"int",
"lastBefore",
"=",
"-",
"1",
";",
"int",
"firstAfter",
"=",
"refList",
".",
"size",
"(",
")",
";",
"int",
"index",
"=",
"0",
";",
"checkState",
"(",
"inputOrder",
".",
"containsKey",
"(",
"inputId",
")",
",",
"inputId",
".",
"getIdName",
"(",
")",
")",
";",
"int",
"sourceInputOrder",
"=",
"inputOrder",
".",
"get",
"(",
"inputId",
")",
";",
"for",
"(",
"Reference",
"ref",
":",
"refList",
")",
"{",
"checkNotNull",
"(",
"ref",
".",
"getInputId",
"(",
")",
")",
";",
"int",
"order",
"=",
"inputOrder",
".",
"get",
"(",
"ref",
".",
"getInputId",
"(",
")",
")",
";",
"if",
"(",
"order",
"<",
"sourceInputOrder",
")",
"{",
"lastBefore",
"=",
"index",
";",
"}",
"else",
"if",
"(",
"order",
">",
"sourceInputOrder",
")",
"{",
"firstAfter",
"=",
"index",
";",
"break",
";",
"}",
"index",
"++",
";",
"}",
"return",
"new",
"SourceRefRange",
"(",
"refList",
",",
"lastBefore",
",",
"firstAfter",
")",
";",
"}"
] | Finds the range of references associated to {@code sourceName}. Note that
even if there is no sourceName references the returned information can be
used to decide where to insert new sourceName refs. | [
"Finds",
"the",
"range",
"of",
"references",
"associated",
"to",
"{"
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/GlobalVarReferenceMap.java#L161-L185 |
minio/minio-java | api/src/main/java/io/minio/MinioClient.java | MinioClient.listObjects | public Iterable<Result<Item>> listObjects(final String bucketName) throws XmlPullParserException {
"""
Lists object information in given bucket.
@param bucketName Bucket name.
@return an iterator of Result Items.
* @throws XmlPullParserException upon parsing response xml
"""
return listObjects(bucketName, null);
} | java | public Iterable<Result<Item>> listObjects(final String bucketName) throws XmlPullParserException {
return listObjects(bucketName, null);
} | [
"public",
"Iterable",
"<",
"Result",
"<",
"Item",
">",
">",
"listObjects",
"(",
"final",
"String",
"bucketName",
")",
"throws",
"XmlPullParserException",
"{",
"return",
"listObjects",
"(",
"bucketName",
",",
"null",
")",
";",
"}"
] | Lists object information in given bucket.
@param bucketName Bucket name.
@return an iterator of Result Items.
* @throws XmlPullParserException upon parsing response xml | [
"Lists",
"object",
"information",
"in",
"given",
"bucket",
"."
] | train | https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/MinioClient.java#L2797-L2799 |
ravendb/ravendb-jvm-client | src/main/java/net/ravendb/client/documents/subscriptions/DocumentSubscriptions.java | DocumentSubscriptions.getSubscriptionWorker | public SubscriptionWorker<ObjectNode> getSubscriptionWorker(String subscriptionName, String database) {
"""
It opens a subscription and starts pulling documents since a last processed document for that subscription.
The connection options determine client and server cooperation rules like document batch sizes or a timeout in a matter of which a client
needs to acknowledge that batch has been processed. The acknowledgment is sent after all documents are processed by subscription's handlers.
There can be only a single client that is connected to a subscription.
@param subscriptionName The name of subscription
@param database Target database
@return Subscription object that allows to add/remove subscription handlers.
"""
return getSubscriptionWorker(ObjectNode.class, subscriptionName, database);
} | java | public SubscriptionWorker<ObjectNode> getSubscriptionWorker(String subscriptionName, String database) {
return getSubscriptionWorker(ObjectNode.class, subscriptionName, database);
} | [
"public",
"SubscriptionWorker",
"<",
"ObjectNode",
">",
"getSubscriptionWorker",
"(",
"String",
"subscriptionName",
",",
"String",
"database",
")",
"{",
"return",
"getSubscriptionWorker",
"(",
"ObjectNode",
".",
"class",
",",
"subscriptionName",
",",
"database",
")",
";",
"}"
] | It opens a subscription and starts pulling documents since a last processed document for that subscription.
The connection options determine client and server cooperation rules like document batch sizes or a timeout in a matter of which a client
needs to acknowledge that batch has been processed. The acknowledgment is sent after all documents are processed by subscription's handlers.
There can be only a single client that is connected to a subscription.
@param subscriptionName The name of subscription
@param database Target database
@return Subscription object that allows to add/remove subscription handlers. | [
"It",
"opens",
"a",
"subscription",
"and",
"starts",
"pulling",
"documents",
"since",
"a",
"last",
"processed",
"document",
"for",
"that",
"subscription",
".",
"The",
"connection",
"options",
"determine",
"client",
"and",
"server",
"cooperation",
"rules",
"like",
"document",
"batch",
"sizes",
"or",
"a",
"timeout",
"in",
"a",
"matter",
"of",
"which",
"a",
"client",
"needs",
"to",
"acknowledge",
"that",
"batch",
"has",
"been",
"processed",
".",
"The",
"acknowledgment",
"is",
"sent",
"after",
"all",
"documents",
"are",
"processed",
"by",
"subscription",
"s",
"handlers",
"."
] | train | https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/subscriptions/DocumentSubscriptions.java#L194-L196 |
cdk/cdk | display/renderbasic/src/main/java/org/openscience/cdk/renderer/AbstractRenderer.java | AbstractRenderer.toScreenCoordinates | public Point2d toScreenCoordinates(double modelX, double modelY) {
"""
Convert a point in model space into a point in screen space.
@param modelX the model x-coordinate
@param modelY the model y-coordinate
@return the equivalent point in screen space
"""
double[] dest = new double[2];
transform.transform(new double[]{modelX, modelY}, 0, dest, 0, 1);
return new Point2d(dest[0], dest[1]);
} | java | public Point2d toScreenCoordinates(double modelX, double modelY) {
double[] dest = new double[2];
transform.transform(new double[]{modelX, modelY}, 0, dest, 0, 1);
return new Point2d(dest[0], dest[1]);
} | [
"public",
"Point2d",
"toScreenCoordinates",
"(",
"double",
"modelX",
",",
"double",
"modelY",
")",
"{",
"double",
"[",
"]",
"dest",
"=",
"new",
"double",
"[",
"2",
"]",
";",
"transform",
".",
"transform",
"(",
"new",
"double",
"[",
"]",
"{",
"modelX",
",",
"modelY",
"}",
",",
"0",
",",
"dest",
",",
"0",
",",
"1",
")",
";",
"return",
"new",
"Point2d",
"(",
"dest",
"[",
"0",
"]",
",",
"dest",
"[",
"1",
"]",
")",
";",
"}"
] | Convert a point in model space into a point in screen space.
@param modelX the model x-coordinate
@param modelY the model y-coordinate
@return the equivalent point in screen space | [
"Convert",
"a",
"point",
"in",
"model",
"space",
"into",
"a",
"point",
"in",
"screen",
"space",
"."
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/display/renderbasic/src/main/java/org/openscience/cdk/renderer/AbstractRenderer.java#L180-L184 |
jglobus/JGlobus | ssl-proxies/src/main/java/org/globus/gsi/X509Credential.java | X509Credential.verify | public void verify() throws CredentialException {
"""
Verifies the validity of the credentials. All certificate path validation is performed using trusted
certificates in default locations.
@exception CredentialException
if one of the certificates in the chain expired or if path validiation fails.
"""
try {
String caCertsLocation = "file:" + CoGProperties.getDefault().getCaCertLocations();
KeyStore keyStore = Stores.getTrustStore(caCertsLocation + "/" + Stores.getDefaultCAFilesPattern());
CertStore crlStore = Stores.getCRLStore(caCertsLocation + "/" + Stores.getDefaultCRLFilesPattern());
ResourceSigningPolicyStore sigPolStore = Stores.getSigningPolicyStore(caCertsLocation + "/" + Stores.getDefaultSigningPolicyFilesPattern());
X509ProxyCertPathParameters parameters = new X509ProxyCertPathParameters(keyStore, crlStore, sigPolStore, false);
X509ProxyCertPathValidator validator = new X509ProxyCertPathValidator();
validator.engineValidate(CertificateUtil.getCertPath(certChain), parameters);
} catch (Exception e) {
throw new CredentialException(e);
}
} | java | public void verify() throws CredentialException {
try {
String caCertsLocation = "file:" + CoGProperties.getDefault().getCaCertLocations();
KeyStore keyStore = Stores.getTrustStore(caCertsLocation + "/" + Stores.getDefaultCAFilesPattern());
CertStore crlStore = Stores.getCRLStore(caCertsLocation + "/" + Stores.getDefaultCRLFilesPattern());
ResourceSigningPolicyStore sigPolStore = Stores.getSigningPolicyStore(caCertsLocation + "/" + Stores.getDefaultSigningPolicyFilesPattern());
X509ProxyCertPathParameters parameters = new X509ProxyCertPathParameters(keyStore, crlStore, sigPolStore, false);
X509ProxyCertPathValidator validator = new X509ProxyCertPathValidator();
validator.engineValidate(CertificateUtil.getCertPath(certChain), parameters);
} catch (Exception e) {
throw new CredentialException(e);
}
} | [
"public",
"void",
"verify",
"(",
")",
"throws",
"CredentialException",
"{",
"try",
"{",
"String",
"caCertsLocation",
"=",
"\"file:\"",
"+",
"CoGProperties",
".",
"getDefault",
"(",
")",
".",
"getCaCertLocations",
"(",
")",
";",
"KeyStore",
"keyStore",
"=",
"Stores",
".",
"getTrustStore",
"(",
"caCertsLocation",
"+",
"\"/\"",
"+",
"Stores",
".",
"getDefaultCAFilesPattern",
"(",
")",
")",
";",
"CertStore",
"crlStore",
"=",
"Stores",
".",
"getCRLStore",
"(",
"caCertsLocation",
"+",
"\"/\"",
"+",
"Stores",
".",
"getDefaultCRLFilesPattern",
"(",
")",
")",
";",
"ResourceSigningPolicyStore",
"sigPolStore",
"=",
"Stores",
".",
"getSigningPolicyStore",
"(",
"caCertsLocation",
"+",
"\"/\"",
"+",
"Stores",
".",
"getDefaultSigningPolicyFilesPattern",
"(",
")",
")",
";",
"X509ProxyCertPathParameters",
"parameters",
"=",
"new",
"X509ProxyCertPathParameters",
"(",
"keyStore",
",",
"crlStore",
",",
"sigPolStore",
",",
"false",
")",
";",
"X509ProxyCertPathValidator",
"validator",
"=",
"new",
"X509ProxyCertPathValidator",
"(",
")",
";",
"validator",
".",
"engineValidate",
"(",
"CertificateUtil",
".",
"getCertPath",
"(",
"certChain",
")",
",",
"parameters",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"CredentialException",
"(",
"e",
")",
";",
"}",
"}"
] | Verifies the validity of the credentials. All certificate path validation is performed using trusted
certificates in default locations.
@exception CredentialException
if one of the certificates in the chain expired or if path validiation fails. | [
"Verifies",
"the",
"validity",
"of",
"the",
"credentials",
".",
"All",
"certificate",
"path",
"validation",
"is",
"performed",
"using",
"trusted",
"certificates",
"in",
"default",
"locations",
"."
] | train | https://github.com/jglobus/JGlobus/blob/e14f6f6636544fd84298f9cec749d626ea971930/ssl-proxies/src/main/java/org/globus/gsi/X509Credential.java#L435-L449 |
dlemmermann/CalendarFX | CalendarFXGoogle/src/main/java/com/calendarfx/google/model/GoogleAccount.java | GoogleAccount.createCalendar | public final GoogleCalendar createCalendar(String name, Calendar.Style style) {
"""
Creates one single calendar with the given name and style.
@param name The name of the calendar.
@param style The style of the calendar.
@return The new google calendar.
"""
GoogleCalendar calendar = new GoogleCalendar();
calendar.setName(name);
calendar.setStyle(style);
return calendar;
} | java | public final GoogleCalendar createCalendar(String name, Calendar.Style style) {
GoogleCalendar calendar = new GoogleCalendar();
calendar.setName(name);
calendar.setStyle(style);
return calendar;
} | [
"public",
"final",
"GoogleCalendar",
"createCalendar",
"(",
"String",
"name",
",",
"Calendar",
".",
"Style",
"style",
")",
"{",
"GoogleCalendar",
"calendar",
"=",
"new",
"GoogleCalendar",
"(",
")",
";",
"calendar",
".",
"setName",
"(",
"name",
")",
";",
"calendar",
".",
"setStyle",
"(",
"style",
")",
";",
"return",
"calendar",
";",
"}"
] | Creates one single calendar with the given name and style.
@param name The name of the calendar.
@param style The style of the calendar.
@return The new google calendar. | [
"Creates",
"one",
"single",
"calendar",
"with",
"the",
"given",
"name",
"and",
"style",
"."
] | train | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXGoogle/src/main/java/com/calendarfx/google/model/GoogleAccount.java#L51-L56 |
ReactiveX/RxJavaAsyncUtil | src/main/java/rx/util/async/Async.java | Async.toAsync | public static <T1, T2, T3, T4, T5, T6, T7, T8, T9> Func9<T1, T2, T3, T4, T5, T6, T7, T8, T9, Observable<Void>> toAsync(Action9<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, ? super T9> action) {
"""
Convert a synchronous action call into an asynchronous function call through an Observable.
<p>
<img width="640" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/toAsync.an.png" alt="">
@param <T1> the first parameter type
@param <T2> the second parameter type
@param <T3> the third parameter type
@param <T4> the fourth parameter type
@param <T5> the fifth parameter type
@param <T6> the sixth parameter type
@param <T7> the seventh parameter type
@param <T8> the eighth parameter type
@param <T9> the ninth parameter type
@param action the action to convert
@return a function that returns an Observable that executes the {@code action} and emits {@code null}
@see <a href="https://github.com/ReactiveX/RxJava/wiki/Async-Operators#wiki-toasync-or-asyncaction-or-asyncfunc">RxJava Wiki: toAsync()</a>
@see <a href="http://msdn.microsoft.com/en-us/library/hh211702.aspx">MSDN: Observable.ToAsync</a>
"""
return toAsync(action, Schedulers.computation());
} | java | public static <T1, T2, T3, T4, T5, T6, T7, T8, T9> Func9<T1, T2, T3, T4, T5, T6, T7, T8, T9, Observable<Void>> toAsync(Action9<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, ? super T9> action) {
return toAsync(action, Schedulers.computation());
} | [
"public",
"static",
"<",
"T1",
",",
"T2",
",",
"T3",
",",
"T4",
",",
"T5",
",",
"T6",
",",
"T7",
",",
"T8",
",",
"T9",
">",
"Func9",
"<",
"T1",
",",
"T2",
",",
"T3",
",",
"T4",
",",
"T5",
",",
"T6",
",",
"T7",
",",
"T8",
",",
"T9",
",",
"Observable",
"<",
"Void",
">",
">",
"toAsync",
"(",
"Action9",
"<",
"?",
"super",
"T1",
",",
"?",
"super",
"T2",
",",
"?",
"super",
"T3",
",",
"?",
"super",
"T4",
",",
"?",
"super",
"T5",
",",
"?",
"super",
"T6",
",",
"?",
"super",
"T7",
",",
"?",
"super",
"T8",
",",
"?",
"super",
"T9",
">",
"action",
")",
"{",
"return",
"toAsync",
"(",
"action",
",",
"Schedulers",
".",
"computation",
"(",
")",
")",
";",
"}"
] | Convert a synchronous action call into an asynchronous function call through an Observable.
<p>
<img width="640" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/toAsync.an.png" alt="">
@param <T1> the first parameter type
@param <T2> the second parameter type
@param <T3> the third parameter type
@param <T4> the fourth parameter type
@param <T5> the fifth parameter type
@param <T6> the sixth parameter type
@param <T7> the seventh parameter type
@param <T8> the eighth parameter type
@param <T9> the ninth parameter type
@param action the action to convert
@return a function that returns an Observable that executes the {@code action} and emits {@code null}
@see <a href="https://github.com/ReactiveX/RxJava/wiki/Async-Operators#wiki-toasync-or-asyncaction-or-asyncfunc">RxJava Wiki: toAsync()</a>
@see <a href="http://msdn.microsoft.com/en-us/library/hh211702.aspx">MSDN: Observable.ToAsync</a> | [
"Convert",
"a",
"synchronous",
"action",
"call",
"into",
"an",
"asynchronous",
"function",
"call",
"through",
"an",
"Observable",
".",
"<p",
">",
"<img",
"width",
"=",
"640",
"src",
"=",
"https",
":",
"//",
"raw",
".",
"github",
".",
"com",
"/",
"wiki",
"/",
"ReactiveX",
"/",
"RxJava",
"/",
"images",
"/",
"rx",
"-",
"operators",
"/",
"toAsync",
".",
"an",
".",
"png",
"alt",
"=",
">"
] | train | https://github.com/ReactiveX/RxJavaAsyncUtil/blob/6294e1da30e639df79f76399906229314c14e74d/src/main/java/rx/util/async/Async.java#L659-L661 |
OpenLiberty/open-liberty | dev/com.ibm.ws.microprofile.metrics/src/com/ibm/ws/microprofile/metrics/impl/MetricRegistryImpl.java | MetricRegistryImpl.getHistograms | @Override
public SortedMap<String, Histogram> getHistograms(MetricFilter filter) {
"""
Returns a map of all the histograms in the registry and their names which match the given
filter.
@param filter the metric filter to match
@return all the histograms in the registry
"""
return getMetrics(Histogram.class, filter);
} | java | @Override
public SortedMap<String, Histogram> getHistograms(MetricFilter filter) {
return getMetrics(Histogram.class, filter);
} | [
"@",
"Override",
"public",
"SortedMap",
"<",
"String",
",",
"Histogram",
">",
"getHistograms",
"(",
"MetricFilter",
"filter",
")",
"{",
"return",
"getMetrics",
"(",
"Histogram",
".",
"class",
",",
"filter",
")",
";",
"}"
] | Returns a map of all the histograms in the registry and their names which match the given
filter.
@param filter the metric filter to match
@return all the histograms in the registry | [
"Returns",
"a",
"map",
"of",
"all",
"the",
"histograms",
"in",
"the",
"registry",
"and",
"their",
"names",
"which",
"match",
"the",
"given",
"filter",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.microprofile.metrics/src/com/ibm/ws/microprofile/metrics/impl/MetricRegistryImpl.java#L384-L387 |
foundation-runtime/service-directory | 2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/ServiceDirectoryThread.java | ServiceDirectoryThread.doThread | private static Thread doThread(Runnable runnable, String name, boolean deamon) {
"""
Generate the Thread.
@param runnable
the runnable task.
@param name
the thread name.
@param deamon
the deamon flag.
@return
the Thread.
"""
String realname = getThreadName(name);
Thread t = new Thread(runnable);
t.setName(realname);
t.setDaemon(deamon);
return t;
} | java | private static Thread doThread(Runnable runnable, String name, boolean deamon){
String realname = getThreadName(name);
Thread t = new Thread(runnable);
t.setName(realname);
t.setDaemon(deamon);
return t;
} | [
"private",
"static",
"Thread",
"doThread",
"(",
"Runnable",
"runnable",
",",
"String",
"name",
",",
"boolean",
"deamon",
")",
"{",
"String",
"realname",
"=",
"getThreadName",
"(",
"name",
")",
";",
"Thread",
"t",
"=",
"new",
"Thread",
"(",
"runnable",
")",
";",
"t",
".",
"setName",
"(",
"realname",
")",
";",
"t",
".",
"setDaemon",
"(",
"deamon",
")",
";",
"return",
"t",
";",
"}"
] | Generate the Thread.
@param runnable
the runnable task.
@param name
the thread name.
@param deamon
the deamon flag.
@return
the Thread. | [
"Generate",
"the",
"Thread",
"."
] | train | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/ServiceDirectoryThread.java#L121-L127 |
hazelcast/hazelcast | hazelcast/src/main/java/com/hazelcast/util/ExceptionUtil.java | ExceptionUtil.fixAsyncStackTrace | public static void fixAsyncStackTrace(Throwable asyncCause, StackTraceElement[] localSideStackTrace,
String localExceptionMessage) {
"""
This method changes the given async cause, and it adds the also given local stacktrace separated by the
supplied exception message.<br/>
If the remoteCause is an {@link java.util.concurrent.ExecutionException} and it has a non-null inner
cause, this inner cause is unwrapped and the local stacktrace and exception message are added to the
that instead of the given remoteCause itself.
@param asyncCause the async exception
@param localSideStackTrace the local stacktrace to add to the exceptions stacktrace
@param localExceptionMessage a special exception message which is added to the stacktrace
"""
Throwable throwable = asyncCause;
if (asyncCause instanceof ExecutionException && throwable.getCause() != null) {
throwable = throwable.getCause();
}
String msg = EXCEPTION_MESSAGE_SEPARATOR.replace("%MSG%", localExceptionMessage);
StackTraceElement[] remoteStackTrace = throwable.getStackTrace();
StackTraceElement[] newStackTrace = new StackTraceElement[localSideStackTrace.length + remoteStackTrace.length + 1];
System.arraycopy(remoteStackTrace, 0, newStackTrace, 0, remoteStackTrace.length);
newStackTrace[remoteStackTrace.length] = new StackTraceElement(EXCEPTION_SEPARATOR, "", null, -1);
StackTraceElement nextElement = localSideStackTrace[1];
newStackTrace[remoteStackTrace.length + 1] = new StackTraceElement(msg, nextElement.getMethodName(),
nextElement.getFileName(), nextElement.getLineNumber());
System.arraycopy(localSideStackTrace, 1, newStackTrace, remoteStackTrace.length + 2, localSideStackTrace.length - 1);
throwable.setStackTrace(newStackTrace);
} | java | public static void fixAsyncStackTrace(Throwable asyncCause, StackTraceElement[] localSideStackTrace,
String localExceptionMessage) {
Throwable throwable = asyncCause;
if (asyncCause instanceof ExecutionException && throwable.getCause() != null) {
throwable = throwable.getCause();
}
String msg = EXCEPTION_MESSAGE_SEPARATOR.replace("%MSG%", localExceptionMessage);
StackTraceElement[] remoteStackTrace = throwable.getStackTrace();
StackTraceElement[] newStackTrace = new StackTraceElement[localSideStackTrace.length + remoteStackTrace.length + 1];
System.arraycopy(remoteStackTrace, 0, newStackTrace, 0, remoteStackTrace.length);
newStackTrace[remoteStackTrace.length] = new StackTraceElement(EXCEPTION_SEPARATOR, "", null, -1);
StackTraceElement nextElement = localSideStackTrace[1];
newStackTrace[remoteStackTrace.length + 1] = new StackTraceElement(msg, nextElement.getMethodName(),
nextElement.getFileName(), nextElement.getLineNumber());
System.arraycopy(localSideStackTrace, 1, newStackTrace, remoteStackTrace.length + 2, localSideStackTrace.length - 1);
throwable.setStackTrace(newStackTrace);
} | [
"public",
"static",
"void",
"fixAsyncStackTrace",
"(",
"Throwable",
"asyncCause",
",",
"StackTraceElement",
"[",
"]",
"localSideStackTrace",
",",
"String",
"localExceptionMessage",
")",
"{",
"Throwable",
"throwable",
"=",
"asyncCause",
";",
"if",
"(",
"asyncCause",
"instanceof",
"ExecutionException",
"&&",
"throwable",
".",
"getCause",
"(",
")",
"!=",
"null",
")",
"{",
"throwable",
"=",
"throwable",
".",
"getCause",
"(",
")",
";",
"}",
"String",
"msg",
"=",
"EXCEPTION_MESSAGE_SEPARATOR",
".",
"replace",
"(",
"\"%MSG%\"",
",",
"localExceptionMessage",
")",
";",
"StackTraceElement",
"[",
"]",
"remoteStackTrace",
"=",
"throwable",
".",
"getStackTrace",
"(",
")",
";",
"StackTraceElement",
"[",
"]",
"newStackTrace",
"=",
"new",
"StackTraceElement",
"[",
"localSideStackTrace",
".",
"length",
"+",
"remoteStackTrace",
".",
"length",
"+",
"1",
"]",
";",
"System",
".",
"arraycopy",
"(",
"remoteStackTrace",
",",
"0",
",",
"newStackTrace",
",",
"0",
",",
"remoteStackTrace",
".",
"length",
")",
";",
"newStackTrace",
"[",
"remoteStackTrace",
".",
"length",
"]",
"=",
"new",
"StackTraceElement",
"(",
"EXCEPTION_SEPARATOR",
",",
"\"\"",
",",
"null",
",",
"-",
"1",
")",
";",
"StackTraceElement",
"nextElement",
"=",
"localSideStackTrace",
"[",
"1",
"]",
";",
"newStackTrace",
"[",
"remoteStackTrace",
".",
"length",
"+",
"1",
"]",
"=",
"new",
"StackTraceElement",
"(",
"msg",
",",
"nextElement",
".",
"getMethodName",
"(",
")",
",",
"nextElement",
".",
"getFileName",
"(",
")",
",",
"nextElement",
".",
"getLineNumber",
"(",
")",
")",
";",
"System",
".",
"arraycopy",
"(",
"localSideStackTrace",
",",
"1",
",",
"newStackTrace",
",",
"remoteStackTrace",
".",
"length",
"+",
"2",
",",
"localSideStackTrace",
".",
"length",
"-",
"1",
")",
";",
"throwable",
".",
"setStackTrace",
"(",
"newStackTrace",
")",
";",
"}"
] | This method changes the given async cause, and it adds the also given local stacktrace separated by the
supplied exception message.<br/>
If the remoteCause is an {@link java.util.concurrent.ExecutionException} and it has a non-null inner
cause, this inner cause is unwrapped and the local stacktrace and exception message are added to the
that instead of the given remoteCause itself.
@param asyncCause the async exception
@param localSideStackTrace the local stacktrace to add to the exceptions stacktrace
@param localExceptionMessage a special exception message which is added to the stacktrace | [
"This",
"method",
"changes",
"the",
"given",
"async",
"cause",
"and",
"it",
"adds",
"the",
"also",
"given",
"local",
"stacktrace",
"separated",
"by",
"the",
"supplied",
"exception",
"message",
".",
"<br",
"/",
">",
"If",
"the",
"remoteCause",
"is",
"an",
"{",
"@link",
"java",
".",
"util",
".",
"concurrent",
".",
"ExecutionException",
"}",
"and",
"it",
"has",
"a",
"non",
"-",
"null",
"inner",
"cause",
"this",
"inner",
"cause",
"is",
"unwrapped",
"and",
"the",
"local",
"stacktrace",
"and",
"exception",
"message",
"are",
"added",
"to",
"the",
"that",
"instead",
"of",
"the",
"given",
"remoteCause",
"itself",
"."
] | train | https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/ExceptionUtil.java#L213-L230 |
Microsoft/azure-maven-plugins | azure-maven-plugin-lib/src/main/java/com/microsoft/azure/maven/Utils.java | Utils.assureServerExist | public static void assureServerExist(final Server server, final String serverId) throws MojoExecutionException {
"""
Assure the server with specified id does exist in settings.xml.
It could be the server used for azure authentication.
Or, the server used for docker hub authentication of runtime configuration.
@param server
@param serverId
@throws MojoExecutionException
"""
if (server == null) {
throw new MojoExecutionException(String.format("Server not found in settings.xml. ServerId=%s", serverId));
}
} | java | public static void assureServerExist(final Server server, final String serverId) throws MojoExecutionException {
if (server == null) {
throw new MojoExecutionException(String.format("Server not found in settings.xml. ServerId=%s", serverId));
}
} | [
"public",
"static",
"void",
"assureServerExist",
"(",
"final",
"Server",
"server",
",",
"final",
"String",
"serverId",
")",
"throws",
"MojoExecutionException",
"{",
"if",
"(",
"server",
"==",
"null",
")",
"{",
"throw",
"new",
"MojoExecutionException",
"(",
"String",
".",
"format",
"(",
"\"Server not found in settings.xml. ServerId=%s\"",
",",
"serverId",
")",
")",
";",
"}",
"}"
] | Assure the server with specified id does exist in settings.xml.
It could be the server used for azure authentication.
Or, the server used for docker hub authentication of runtime configuration.
@param server
@param serverId
@throws MojoExecutionException | [
"Assure",
"the",
"server",
"with",
"specified",
"id",
"does",
"exist",
"in",
"settings",
".",
"xml",
".",
"It",
"could",
"be",
"the",
"server",
"used",
"for",
"azure",
"authentication",
".",
"Or",
"the",
"server",
"used",
"for",
"docker",
"hub",
"authentication",
"of",
"runtime",
"configuration",
"."
] | train | https://github.com/Microsoft/azure-maven-plugins/blob/a254902e820185df1823b1d692c7c1d119490b1e/azure-maven-plugin-lib/src/main/java/com/microsoft/azure/maven/Utils.java#L54-L58 |
intive-FDV/DynamicJasper | src/main/java/ar/com/fdvs/dj/core/layout/Dj2JrCrosstabBuilder.java | Dj2JrCrosstabBuilder.registerRows | private void registerRows() {
"""
Register the Rowgroup buckets and places the header cells for the rows
"""
for (int i = 0; i < rows.length; i++) {
DJCrosstabRow crosstabRow = rows[i];
JRDesignCrosstabRowGroup ctRowGroup = new JRDesignCrosstabRowGroup();
ctRowGroup.setWidth(crosstabRow.getHeaderWidth());
ctRowGroup.setName(crosstabRow.getProperty().getProperty());
JRDesignCrosstabBucket rowBucket = new JRDesignCrosstabBucket();
//New in JR 4.1+
rowBucket.setValueClassName(crosstabRow.getProperty().getValueClassName());
ctRowGroup.setBucket(rowBucket);
JRDesignExpression bucketExp = ExpressionUtils.createExpression("$F{"+crosstabRow.getProperty().getProperty()+"}", crosstabRow.getProperty().getValueClassName());
rowBucket.setExpression(bucketExp);
JRDesignCellContents rowHeaderContents = new JRDesignCellContents();
JRDesignTextField rowTitle = new JRDesignTextField();
JRDesignExpression rowTitExp = new JRDesignExpression();
rowTitExp.setValueClassName(crosstabRow.getProperty().getValueClassName());
rowTitExp.setText("$V{"+crosstabRow.getProperty().getProperty()+"}");
rowTitle.setExpression(rowTitExp);
rowTitle.setWidth(crosstabRow.getHeaderWidth());
//The width can be the sum of the with of all the rows starting from the current one, up to the inner most one.
int auxHeight = getRowHeaderMaxHeight(crosstabRow);
// int auxHeight = crosstabRow.getHeight(); //FIXME getRowHeaderMaxHeight() must be FIXED because it breaks when 1rs row shows total and 2nd doesn't
rowTitle.setHeight(auxHeight);
Style headerstyle = crosstabRow.getHeaderStyle() == null ? this.djcross.getRowHeaderStyle(): crosstabRow.getHeaderStyle();
if (headerstyle != null){
layoutManager.applyStyleToElement(headerstyle, rowTitle);
rowHeaderContents.setBackcolor(headerstyle.getBackgroundColor());
}
rowHeaderContents.addElement(rowTitle);
rowHeaderContents.setMode( ModeEnum.OPAQUE );
boolean fullBorder = i <= 0; //Only outer most will have full border
applyCellBorder(rowHeaderContents, false, fullBorder);
ctRowGroup.setHeader(rowHeaderContents );
if (crosstabRow.isShowTotals())
createRowTotalHeader(ctRowGroup,crosstabRow,fullBorder);
try {
jrcross.addRowGroup(ctRowGroup);
} catch (JRException e) {
log.error(e.getMessage(),e);
}
}
} | java | private void registerRows() {
for (int i = 0; i < rows.length; i++) {
DJCrosstabRow crosstabRow = rows[i];
JRDesignCrosstabRowGroup ctRowGroup = new JRDesignCrosstabRowGroup();
ctRowGroup.setWidth(crosstabRow.getHeaderWidth());
ctRowGroup.setName(crosstabRow.getProperty().getProperty());
JRDesignCrosstabBucket rowBucket = new JRDesignCrosstabBucket();
//New in JR 4.1+
rowBucket.setValueClassName(crosstabRow.getProperty().getValueClassName());
ctRowGroup.setBucket(rowBucket);
JRDesignExpression bucketExp = ExpressionUtils.createExpression("$F{"+crosstabRow.getProperty().getProperty()+"}", crosstabRow.getProperty().getValueClassName());
rowBucket.setExpression(bucketExp);
JRDesignCellContents rowHeaderContents = new JRDesignCellContents();
JRDesignTextField rowTitle = new JRDesignTextField();
JRDesignExpression rowTitExp = new JRDesignExpression();
rowTitExp.setValueClassName(crosstabRow.getProperty().getValueClassName());
rowTitExp.setText("$V{"+crosstabRow.getProperty().getProperty()+"}");
rowTitle.setExpression(rowTitExp);
rowTitle.setWidth(crosstabRow.getHeaderWidth());
//The width can be the sum of the with of all the rows starting from the current one, up to the inner most one.
int auxHeight = getRowHeaderMaxHeight(crosstabRow);
// int auxHeight = crosstabRow.getHeight(); //FIXME getRowHeaderMaxHeight() must be FIXED because it breaks when 1rs row shows total and 2nd doesn't
rowTitle.setHeight(auxHeight);
Style headerstyle = crosstabRow.getHeaderStyle() == null ? this.djcross.getRowHeaderStyle(): crosstabRow.getHeaderStyle();
if (headerstyle != null){
layoutManager.applyStyleToElement(headerstyle, rowTitle);
rowHeaderContents.setBackcolor(headerstyle.getBackgroundColor());
}
rowHeaderContents.addElement(rowTitle);
rowHeaderContents.setMode( ModeEnum.OPAQUE );
boolean fullBorder = i <= 0; //Only outer most will have full border
applyCellBorder(rowHeaderContents, false, fullBorder);
ctRowGroup.setHeader(rowHeaderContents );
if (crosstabRow.isShowTotals())
createRowTotalHeader(ctRowGroup,crosstabRow,fullBorder);
try {
jrcross.addRowGroup(ctRowGroup);
} catch (JRException e) {
log.error(e.getMessage(),e);
}
}
} | [
"private",
"void",
"registerRows",
"(",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"rows",
".",
"length",
";",
"i",
"++",
")",
"{",
"DJCrosstabRow",
"crosstabRow",
"=",
"rows",
"[",
"i",
"]",
";",
"JRDesignCrosstabRowGroup",
"ctRowGroup",
"=",
"new",
"JRDesignCrosstabRowGroup",
"(",
")",
";",
"ctRowGroup",
".",
"setWidth",
"(",
"crosstabRow",
".",
"getHeaderWidth",
"(",
")",
")",
";",
"ctRowGroup",
".",
"setName",
"(",
"crosstabRow",
".",
"getProperty",
"(",
")",
".",
"getProperty",
"(",
")",
")",
";",
"JRDesignCrosstabBucket",
"rowBucket",
"=",
"new",
"JRDesignCrosstabBucket",
"(",
")",
";",
"//New in JR 4.1+",
"rowBucket",
".",
"setValueClassName",
"(",
"crosstabRow",
".",
"getProperty",
"(",
")",
".",
"getValueClassName",
"(",
")",
")",
";",
"ctRowGroup",
".",
"setBucket",
"(",
"rowBucket",
")",
";",
"JRDesignExpression",
"bucketExp",
"=",
"ExpressionUtils",
".",
"createExpression",
"(",
"\"$F{\"",
"+",
"crosstabRow",
".",
"getProperty",
"(",
")",
".",
"getProperty",
"(",
")",
"+",
"\"}\"",
",",
"crosstabRow",
".",
"getProperty",
"(",
")",
".",
"getValueClassName",
"(",
")",
")",
";",
"rowBucket",
".",
"setExpression",
"(",
"bucketExp",
")",
";",
"JRDesignCellContents",
"rowHeaderContents",
"=",
"new",
"JRDesignCellContents",
"(",
")",
";",
"JRDesignTextField",
"rowTitle",
"=",
"new",
"JRDesignTextField",
"(",
")",
";",
"JRDesignExpression",
"rowTitExp",
"=",
"new",
"JRDesignExpression",
"(",
")",
";",
"rowTitExp",
".",
"setValueClassName",
"(",
"crosstabRow",
".",
"getProperty",
"(",
")",
".",
"getValueClassName",
"(",
")",
")",
";",
"rowTitExp",
".",
"setText",
"(",
"\"$V{\"",
"+",
"crosstabRow",
".",
"getProperty",
"(",
")",
".",
"getProperty",
"(",
")",
"+",
"\"}\"",
")",
";",
"rowTitle",
".",
"setExpression",
"(",
"rowTitExp",
")",
";",
"rowTitle",
".",
"setWidth",
"(",
"crosstabRow",
".",
"getHeaderWidth",
"(",
")",
")",
";",
"//The width can be the sum of the with of all the rows starting from the current one, up to the inner most one.",
"int",
"auxHeight",
"=",
"getRowHeaderMaxHeight",
"(",
"crosstabRow",
")",
";",
"//\t\t\tint auxHeight = crosstabRow.getHeight(); //FIXME getRowHeaderMaxHeight() must be FIXED because it breaks when 1rs row shows total and 2nd doesn't",
"rowTitle",
".",
"setHeight",
"(",
"auxHeight",
")",
";",
"Style",
"headerstyle",
"=",
"crosstabRow",
".",
"getHeaderStyle",
"(",
")",
"==",
"null",
"?",
"this",
".",
"djcross",
".",
"getRowHeaderStyle",
"(",
")",
":",
"crosstabRow",
".",
"getHeaderStyle",
"(",
")",
";",
"if",
"(",
"headerstyle",
"!=",
"null",
")",
"{",
"layoutManager",
".",
"applyStyleToElement",
"(",
"headerstyle",
",",
"rowTitle",
")",
";",
"rowHeaderContents",
".",
"setBackcolor",
"(",
"headerstyle",
".",
"getBackgroundColor",
"(",
")",
")",
";",
"}",
"rowHeaderContents",
".",
"addElement",
"(",
"rowTitle",
")",
";",
"rowHeaderContents",
".",
"setMode",
"(",
"ModeEnum",
".",
"OPAQUE",
")",
";",
"boolean",
"fullBorder",
"=",
"i",
"<=",
"0",
";",
"//Only outer most will have full border",
"applyCellBorder",
"(",
"rowHeaderContents",
",",
"false",
",",
"fullBorder",
")",
";",
"ctRowGroup",
".",
"setHeader",
"(",
"rowHeaderContents",
")",
";",
"if",
"(",
"crosstabRow",
".",
"isShowTotals",
"(",
")",
")",
"createRowTotalHeader",
"(",
"ctRowGroup",
",",
"crosstabRow",
",",
"fullBorder",
")",
";",
"try",
"{",
"jrcross",
".",
"addRowGroup",
"(",
"ctRowGroup",
")",
";",
"}",
"catch",
"(",
"JRException",
"e",
")",
"{",
"log",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"}"
] | Register the Rowgroup buckets and places the header cells for the rows | [
"Register",
"the",
"Rowgroup",
"buckets",
"and",
"places",
"the",
"header",
"cells",
"for",
"the",
"rows"
] | train | https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/core/layout/Dj2JrCrosstabBuilder.java#L773-L835 |
line/centraldogma | server/src/main/java/com/linecorp/centraldogma/server/internal/api/ProjectServiceV1.java | ProjectServiceV1.patchProject | @Consumes("application/json-patch+json")
@Patch("/projects/ {
"""
PATCH /projects/{projectName}
<p>Patches a project with the JSON_PATCH. Currently, only unremove project operation is supported.
"""projectName}")
@RequiresAdministrator
public CompletableFuture<ProjectDto> patchProject(@Param("projectName") String projectName,
JsonNode node,
Author author) {
checkUnremoveArgument(node);
// Restore the project first then update its metadata as 'active'.
return execute(Command.unremoveProject(author, projectName))
.thenCompose(unused -> mds.restoreProject(author, projectName))
.handle(returnOrThrow(() -> DtoConverter.convert(projectManager().get(projectName))));
} | java | @Consumes("application/json-patch+json")
@Patch("/projects/{projectName}")
@RequiresAdministrator
public CompletableFuture<ProjectDto> patchProject(@Param("projectName") String projectName,
JsonNode node,
Author author) {
checkUnremoveArgument(node);
// Restore the project first then update its metadata as 'active'.
return execute(Command.unremoveProject(author, projectName))
.thenCompose(unused -> mds.restoreProject(author, projectName))
.handle(returnOrThrow(() -> DtoConverter.convert(projectManager().get(projectName))));
} | [
"@",
"Consumes",
"(",
"\"application/json-patch+json\"",
")",
"@",
"Patch",
"(",
"\"/projects/{projectName}\"",
")",
"@",
"RequiresAdministrator",
"public",
"CompletableFuture",
"<",
"ProjectDto",
">",
"patchProject",
"(",
"@",
"Param",
"(",
"\"projectName\"",
")",
"String",
"projectName",
",",
"JsonNode",
"node",
",",
"Author",
"author",
")",
"{",
"checkUnremoveArgument",
"(",
"node",
")",
";",
"// Restore the project first then update its metadata as 'active'.",
"return",
"execute",
"(",
"Command",
".",
"unremoveProject",
"(",
"author",
",",
"projectName",
")",
")",
".",
"thenCompose",
"(",
"unused",
"->",
"mds",
".",
"restoreProject",
"(",
"author",
",",
"projectName",
")",
")",
".",
"handle",
"(",
"returnOrThrow",
"(",
"(",
")",
"->",
"DtoConverter",
".",
"convert",
"(",
"projectManager",
"(",
")",
".",
"get",
"(",
"projectName",
")",
")",
")",
")",
";",
"}"
] | PATCH /projects/{projectName}
<p>Patches a project with the JSON_PATCH. Currently, only unremove project operation is supported. | [
"PATCH",
"/",
"projects",
"/",
"{",
"projectName",
"}"
] | train | https://github.com/line/centraldogma/blob/b9e46c67fbc26628c2186ce2f46e7fb303c831e9/server/src/main/java/com/linecorp/centraldogma/server/internal/api/ProjectServiceV1.java#L136-L147 |
RobotiumTech/robotium | robotium-solo/src/main/java/com/robotium/solo/Solo.java | Solo.setDatePicker | public void setDatePicker(int index, int year, int monthOfYear, int dayOfMonth) {
"""
Sets the date in a DatePicker matching the specified index.
@param index the index of the {@link DatePicker}. {@code 0} if only one is available
@param year the year e.g. 2011
@param monthOfYear the month which starts from zero e.g. 0 for January
@param dayOfMonth the day e.g. 10
"""
if(config.commandLogging){
Log.d(config.commandLoggingTag, "setDatePicker("+index+", "+year+", "+monthOfYear+", "+dayOfMonth+")");
}
setDatePicker(waiter.waitForAndGetView(index, DatePicker.class), year, monthOfYear, dayOfMonth);
} | java | public void setDatePicker(int index, int year, int monthOfYear, int dayOfMonth) {
if(config.commandLogging){
Log.d(config.commandLoggingTag, "setDatePicker("+index+", "+year+", "+monthOfYear+", "+dayOfMonth+")");
}
setDatePicker(waiter.waitForAndGetView(index, DatePicker.class), year, monthOfYear, dayOfMonth);
} | [
"public",
"void",
"setDatePicker",
"(",
"int",
"index",
",",
"int",
"year",
",",
"int",
"monthOfYear",
",",
"int",
"dayOfMonth",
")",
"{",
"if",
"(",
"config",
".",
"commandLogging",
")",
"{",
"Log",
".",
"d",
"(",
"config",
".",
"commandLoggingTag",
",",
"\"setDatePicker(\"",
"+",
"index",
"+",
"\", \"",
"+",
"year",
"+",
"\", \"",
"+",
"monthOfYear",
"+",
"\", \"",
"+",
"dayOfMonth",
"+",
"\")\"",
")",
";",
"}",
"setDatePicker",
"(",
"waiter",
".",
"waitForAndGetView",
"(",
"index",
",",
"DatePicker",
".",
"class",
")",
",",
"year",
",",
"monthOfYear",
",",
"dayOfMonth",
")",
";",
"}"
] | Sets the date in a DatePicker matching the specified index.
@param index the index of the {@link DatePicker}. {@code 0} if only one is available
@param year the year e.g. 2011
@param monthOfYear the month which starts from zero e.g. 0 for January
@param dayOfMonth the day e.g. 10 | [
"Sets",
"the",
"date",
"in",
"a",
"DatePicker",
"matching",
"the",
"specified",
"index",
"."
] | train | https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Solo.java#L2521-L2527 |
alkacon/opencms-core | src/org/opencms/workplace/editors/CmsEditor.java | CmsEditor.commitTempFile | protected void commitTempFile() throws CmsException {
"""
Writes the content of a temporary file back to the original file.<p>
@throws CmsException if something goes wrong
"""
CmsObject cms = getCms();
CmsFile tempFile;
List<CmsProperty> properties;
try {
switchToTempProject();
tempFile = cms.readFile(getParamTempfile(), CmsResourceFilter.ALL);
properties = cms.readPropertyObjects(getParamTempfile(), false);
} finally {
// make sure the project is reset in case of any exception
switchToCurrentProject();
}
if (cms.existsResource(getParamResource(), CmsResourceFilter.ALL)) {
// update properties of original file first (required if change in encoding occurred)
cms.writePropertyObjects(getParamResource(), properties);
// now replace the content of the original file
CmsFile orgFile = cms.readFile(getParamResource(), CmsResourceFilter.ALL);
orgFile.setContents(tempFile.getContents());
getCloneCms().writeFile(orgFile);
} else {
// original file does not exist, remove visibility permission entries and copy temporary file
// switch to the temporary file project
try {
switchToTempProject();
// lock the temporary file
cms.changeLock(getParamTempfile());
// remove visibility permissions for everybody on temporary file if possible
if (cms.hasPermissions(tempFile, CmsPermissionSet.ACCESS_CONTROL)) {
cms.rmacc(
getParamTempfile(),
I_CmsPrincipal.PRINCIPAL_GROUP,
OpenCms.getDefaultUsers().getGroupUsers());
}
} finally {
// make sure the project is reset in case of any exception
switchToCurrentProject();
}
cms.copyResource(getParamTempfile(), getParamResource(), CmsResource.COPY_AS_NEW);
// ensure the content handler is called
CmsFile orgFile = cms.readFile(getParamResource(), CmsResourceFilter.ALL);
getCloneCms().writeFile(orgFile);
}
// remove the temporary file flag
int flags = cms.readResource(getParamResource(), CmsResourceFilter.ALL).getFlags();
if ((flags & CmsResource.FLAG_TEMPFILE) == CmsResource.FLAG_TEMPFILE) {
flags ^= CmsResource.FLAG_TEMPFILE;
cms.chflags(getParamResource(), flags);
}
} | java | protected void commitTempFile() throws CmsException {
CmsObject cms = getCms();
CmsFile tempFile;
List<CmsProperty> properties;
try {
switchToTempProject();
tempFile = cms.readFile(getParamTempfile(), CmsResourceFilter.ALL);
properties = cms.readPropertyObjects(getParamTempfile(), false);
} finally {
// make sure the project is reset in case of any exception
switchToCurrentProject();
}
if (cms.existsResource(getParamResource(), CmsResourceFilter.ALL)) {
// update properties of original file first (required if change in encoding occurred)
cms.writePropertyObjects(getParamResource(), properties);
// now replace the content of the original file
CmsFile orgFile = cms.readFile(getParamResource(), CmsResourceFilter.ALL);
orgFile.setContents(tempFile.getContents());
getCloneCms().writeFile(orgFile);
} else {
// original file does not exist, remove visibility permission entries and copy temporary file
// switch to the temporary file project
try {
switchToTempProject();
// lock the temporary file
cms.changeLock(getParamTempfile());
// remove visibility permissions for everybody on temporary file if possible
if (cms.hasPermissions(tempFile, CmsPermissionSet.ACCESS_CONTROL)) {
cms.rmacc(
getParamTempfile(),
I_CmsPrincipal.PRINCIPAL_GROUP,
OpenCms.getDefaultUsers().getGroupUsers());
}
} finally {
// make sure the project is reset in case of any exception
switchToCurrentProject();
}
cms.copyResource(getParamTempfile(), getParamResource(), CmsResource.COPY_AS_NEW);
// ensure the content handler is called
CmsFile orgFile = cms.readFile(getParamResource(), CmsResourceFilter.ALL);
getCloneCms().writeFile(orgFile);
}
// remove the temporary file flag
int flags = cms.readResource(getParamResource(), CmsResourceFilter.ALL).getFlags();
if ((flags & CmsResource.FLAG_TEMPFILE) == CmsResource.FLAG_TEMPFILE) {
flags ^= CmsResource.FLAG_TEMPFILE;
cms.chflags(getParamResource(), flags);
}
} | [
"protected",
"void",
"commitTempFile",
"(",
")",
"throws",
"CmsException",
"{",
"CmsObject",
"cms",
"=",
"getCms",
"(",
")",
";",
"CmsFile",
"tempFile",
";",
"List",
"<",
"CmsProperty",
">",
"properties",
";",
"try",
"{",
"switchToTempProject",
"(",
")",
";",
"tempFile",
"=",
"cms",
".",
"readFile",
"(",
"getParamTempfile",
"(",
")",
",",
"CmsResourceFilter",
".",
"ALL",
")",
";",
"properties",
"=",
"cms",
".",
"readPropertyObjects",
"(",
"getParamTempfile",
"(",
")",
",",
"false",
")",
";",
"}",
"finally",
"{",
"// make sure the project is reset in case of any exception",
"switchToCurrentProject",
"(",
")",
";",
"}",
"if",
"(",
"cms",
".",
"existsResource",
"(",
"getParamResource",
"(",
")",
",",
"CmsResourceFilter",
".",
"ALL",
")",
")",
"{",
"// update properties of original file first (required if change in encoding occurred)",
"cms",
".",
"writePropertyObjects",
"(",
"getParamResource",
"(",
")",
",",
"properties",
")",
";",
"// now replace the content of the original file",
"CmsFile",
"orgFile",
"=",
"cms",
".",
"readFile",
"(",
"getParamResource",
"(",
")",
",",
"CmsResourceFilter",
".",
"ALL",
")",
";",
"orgFile",
".",
"setContents",
"(",
"tempFile",
".",
"getContents",
"(",
")",
")",
";",
"getCloneCms",
"(",
")",
".",
"writeFile",
"(",
"orgFile",
")",
";",
"}",
"else",
"{",
"// original file does not exist, remove visibility permission entries and copy temporary file",
"// switch to the temporary file project",
"try",
"{",
"switchToTempProject",
"(",
")",
";",
"// lock the temporary file",
"cms",
".",
"changeLock",
"(",
"getParamTempfile",
"(",
")",
")",
";",
"// remove visibility permissions for everybody on temporary file if possible",
"if",
"(",
"cms",
".",
"hasPermissions",
"(",
"tempFile",
",",
"CmsPermissionSet",
".",
"ACCESS_CONTROL",
")",
")",
"{",
"cms",
".",
"rmacc",
"(",
"getParamTempfile",
"(",
")",
",",
"I_CmsPrincipal",
".",
"PRINCIPAL_GROUP",
",",
"OpenCms",
".",
"getDefaultUsers",
"(",
")",
".",
"getGroupUsers",
"(",
")",
")",
";",
"}",
"}",
"finally",
"{",
"// make sure the project is reset in case of any exception",
"switchToCurrentProject",
"(",
")",
";",
"}",
"cms",
".",
"copyResource",
"(",
"getParamTempfile",
"(",
")",
",",
"getParamResource",
"(",
")",
",",
"CmsResource",
".",
"COPY_AS_NEW",
")",
";",
"// ensure the content handler is called",
"CmsFile",
"orgFile",
"=",
"cms",
".",
"readFile",
"(",
"getParamResource",
"(",
")",
",",
"CmsResourceFilter",
".",
"ALL",
")",
";",
"getCloneCms",
"(",
")",
".",
"writeFile",
"(",
"orgFile",
")",
";",
"}",
"// remove the temporary file flag",
"int",
"flags",
"=",
"cms",
".",
"readResource",
"(",
"getParamResource",
"(",
")",
",",
"CmsResourceFilter",
".",
"ALL",
")",
".",
"getFlags",
"(",
")",
";",
"if",
"(",
"(",
"flags",
"&",
"CmsResource",
".",
"FLAG_TEMPFILE",
")",
"==",
"CmsResource",
".",
"FLAG_TEMPFILE",
")",
"{",
"flags",
"^=",
"CmsResource",
".",
"FLAG_TEMPFILE",
";",
"cms",
".",
"chflags",
"(",
"getParamResource",
"(",
")",
",",
"flags",
")",
";",
"}",
"}"
] | Writes the content of a temporary file back to the original file.<p>
@throws CmsException if something goes wrong | [
"Writes",
"the",
"content",
"of",
"a",
"temporary",
"file",
"back",
"to",
"the",
"original",
"file",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/workplace/editors/CmsEditor.java#L786-L838 |
baratine/baratine | web/src/main/java/com/caucho/v5/log/impl/EnvironmentStream.java | EnvironmentStream.logStderr | public static void logStderr(String msg, Throwable e) {
"""
Logs a message to the original stderr in cases where java.util.logging
is dangerous, e.g. in the logging code itself.
"""
try {
long now = CurrentTime.currentTime();
//msg = QDate.formatLocal(now, "[%Y-%m-%d %H:%M:%S] ") + msg;
_origSystemErr.println(msg);
//e.printStackTrace(_origSystemErr.getPrintWriter());
_origSystemErr.flush();
} catch (Throwable e1) {
}
} | java | public static void logStderr(String msg, Throwable e)
{
try {
long now = CurrentTime.currentTime();
//msg = QDate.formatLocal(now, "[%Y-%m-%d %H:%M:%S] ") + msg;
_origSystemErr.println(msg);
//e.printStackTrace(_origSystemErr.getPrintWriter());
_origSystemErr.flush();
} catch (Throwable e1) {
}
} | [
"public",
"static",
"void",
"logStderr",
"(",
"String",
"msg",
",",
"Throwable",
"e",
")",
"{",
"try",
"{",
"long",
"now",
"=",
"CurrentTime",
".",
"currentTime",
"(",
")",
";",
"//msg = QDate.formatLocal(now, \"[%Y-%m-%d %H:%M:%S] \") + msg;",
"_origSystemErr",
".",
"println",
"(",
"msg",
")",
";",
"//e.printStackTrace(_origSystemErr.getPrintWriter());",
"_origSystemErr",
".",
"flush",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"e1",
")",
"{",
"}",
"}"
] | Logs a message to the original stderr in cases where java.util.logging
is dangerous, e.g. in the logging code itself. | [
"Logs",
"a",
"message",
"to",
"the",
"original",
"stderr",
"in",
"cases",
"where",
"java",
".",
"util",
".",
"logging",
"is",
"dangerous",
"e",
".",
"g",
".",
"in",
"the",
"logging",
"code",
"itself",
"."
] | train | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/log/impl/EnvironmentStream.java#L345-L359 |
netscaler/nitro | src/main/java/com/citrix/netscaler/nitro/resource/config/policy/policystringmap.java | policystringmap.get | public static policystringmap get(nitro_service service, String name) throws Exception {
"""
Use this API to fetch policystringmap resource of given name .
"""
policystringmap obj = new policystringmap();
obj.set_name(name);
policystringmap response = (policystringmap) obj.get_resource(service);
return response;
} | java | public static policystringmap get(nitro_service service, String name) throws Exception{
policystringmap obj = new policystringmap();
obj.set_name(name);
policystringmap response = (policystringmap) obj.get_resource(service);
return response;
} | [
"public",
"static",
"policystringmap",
"get",
"(",
"nitro_service",
"service",
",",
"String",
"name",
")",
"throws",
"Exception",
"{",
"policystringmap",
"obj",
"=",
"new",
"policystringmap",
"(",
")",
";",
"obj",
".",
"set_name",
"(",
"name",
")",
";",
"policystringmap",
"response",
"=",
"(",
"policystringmap",
")",
"obj",
".",
"get_resource",
"(",
"service",
")",
";",
"return",
"response",
";",
"}"
] | Use this API to fetch policystringmap resource of given name . | [
"Use",
"this",
"API",
"to",
"fetch",
"policystringmap",
"resource",
"of",
"given",
"name",
"."
] | train | https://github.com/netscaler/nitro/blob/2a98692dcf4e4ec430c7d7baab8382e4ba5a35e4/src/main/java/com/citrix/netscaler/nitro/resource/config/policy/policystringmap.java#L276-L281 |
Asana/java-asana | src/main/java/com/asana/resources/Attachments.java | Attachments.createOnTask | public ItemRequest<Attachment> createOnTask(String task, InputStream fileContent, String fileName, String fileType) {
"""
Upload a file and attach it to a task
@param task Globally unique identifier for the task.
@param fileContent Content of the file to be uploaded
@param fileName Name of the file to be uploaded
@param fileType MIME type of the file to be uploaded
@return Request object
"""
MultipartContent.Part part = new MultipartContent.Part()
.setContent(new InputStreamContent(fileType, fileContent))
.setHeaders(new HttpHeaders().set(
"Content-Disposition",
String.format("form-data; name=\"file\"; filename=\"%s\"", fileName) // TODO: escape fileName?
));
MultipartContent content = new MultipartContent()
.setMediaType(new HttpMediaType("multipart/form-data").setParameter("boundary", UUID.randomUUID().toString()))
.addPart(part);
String path = String.format("/tasks/%s/attachments", task);
return new ItemRequest<Attachment>(this, Attachment.class, path, "POST")
.data(content);
} | java | public ItemRequest<Attachment> createOnTask(String task, InputStream fileContent, String fileName, String fileType) {
MultipartContent.Part part = new MultipartContent.Part()
.setContent(new InputStreamContent(fileType, fileContent))
.setHeaders(new HttpHeaders().set(
"Content-Disposition",
String.format("form-data; name=\"file\"; filename=\"%s\"", fileName) // TODO: escape fileName?
));
MultipartContent content = new MultipartContent()
.setMediaType(new HttpMediaType("multipart/form-data").setParameter("boundary", UUID.randomUUID().toString()))
.addPart(part);
String path = String.format("/tasks/%s/attachments", task);
return new ItemRequest<Attachment>(this, Attachment.class, path, "POST")
.data(content);
} | [
"public",
"ItemRequest",
"<",
"Attachment",
">",
"createOnTask",
"(",
"String",
"task",
",",
"InputStream",
"fileContent",
",",
"String",
"fileName",
",",
"String",
"fileType",
")",
"{",
"MultipartContent",
".",
"Part",
"part",
"=",
"new",
"MultipartContent",
".",
"Part",
"(",
")",
".",
"setContent",
"(",
"new",
"InputStreamContent",
"(",
"fileType",
",",
"fileContent",
")",
")",
".",
"setHeaders",
"(",
"new",
"HttpHeaders",
"(",
")",
".",
"set",
"(",
"\"Content-Disposition\"",
",",
"String",
".",
"format",
"(",
"\"form-data; name=\\\"file\\\"; filename=\\\"%s\\\"\"",
",",
"fileName",
")",
"// TODO: escape fileName?",
")",
")",
";",
"MultipartContent",
"content",
"=",
"new",
"MultipartContent",
"(",
")",
".",
"setMediaType",
"(",
"new",
"HttpMediaType",
"(",
"\"multipart/form-data\"",
")",
".",
"setParameter",
"(",
"\"boundary\"",
",",
"UUID",
".",
"randomUUID",
"(",
")",
".",
"toString",
"(",
")",
")",
")",
".",
"addPart",
"(",
"part",
")",
";",
"String",
"path",
"=",
"String",
".",
"format",
"(",
"\"/tasks/%s/attachments\"",
",",
"task",
")",
";",
"return",
"new",
"ItemRequest",
"<",
"Attachment",
">",
"(",
"this",
",",
"Attachment",
".",
"class",
",",
"path",
",",
"\"POST\"",
")",
".",
"data",
"(",
"content",
")",
";",
"}"
] | Upload a file and attach it to a task
@param task Globally unique identifier for the task.
@param fileContent Content of the file to be uploaded
@param fileName Name of the file to be uploaded
@param fileType MIME type of the file to be uploaded
@return Request object | [
"Upload",
"a",
"file",
"and",
"attach",
"it",
"to",
"a",
"task"
] | train | https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/Attachments.java#L29-L43 |
op4j/op4j | src/main/java/org/op4j/functions/FnNumber.java | FnNumber.roundDouble | public static final Function<Double,Double> roundDouble(final int scale, final RoundingMode roundingMode) {
"""
<p>
It rounds the target object with the specified scale and rounding mode
</p>
@param scale the scale to be used
@param roundingMode the {@link RoundingMode} to round the input with
@return the {@link Double}
"""
return new RoundDouble(scale, roundingMode);
} | java | public static final Function<Double,Double> roundDouble(final int scale, final RoundingMode roundingMode) {
return new RoundDouble(scale, roundingMode);
} | [
"public",
"static",
"final",
"Function",
"<",
"Double",
",",
"Double",
">",
"roundDouble",
"(",
"final",
"int",
"scale",
",",
"final",
"RoundingMode",
"roundingMode",
")",
"{",
"return",
"new",
"RoundDouble",
"(",
"scale",
",",
"roundingMode",
")",
";",
"}"
] | <p>
It rounds the target object with the specified scale and rounding mode
</p>
@param scale the scale to be used
@param roundingMode the {@link RoundingMode} to round the input with
@return the {@link Double} | [
"<p",
">",
"It",
"rounds",
"the",
"target",
"object",
"with",
"the",
"specified",
"scale",
"and",
"rounding",
"mode",
"<",
"/",
"p",
">"
] | train | https://github.com/op4j/op4j/blob/b577596dfe462089d3dd169666defc6de7ad289a/src/main/java/org/op4j/functions/FnNumber.java#L306-L308 |
virgo47/javasimon | core/src/main/java/org/javasimon/callback/logging/LoggingCallback.java | LoggingCallback.onStopwatchStop | @Override
public void onStopwatchStop(Split split, StopwatchSample sample) {
"""
{@inheritDoc}
Split and stopwatch are logger to log template is enabled.
@param split Split
@param sample Stopwatch sample
"""
getStopwatchLogTemplate(split.getStopwatch()).log(split, stopwatchLogMessageSource);
} | java | @Override
public void onStopwatchStop(Split split, StopwatchSample sample) {
getStopwatchLogTemplate(split.getStopwatch()).log(split, stopwatchLogMessageSource);
} | [
"@",
"Override",
"public",
"void",
"onStopwatchStop",
"(",
"Split",
"split",
",",
"StopwatchSample",
"sample",
")",
"{",
"getStopwatchLogTemplate",
"(",
"split",
".",
"getStopwatch",
"(",
")",
")",
".",
"log",
"(",
"split",
",",
"stopwatchLogMessageSource",
")",
";",
"}"
] | {@inheritDoc}
Split and stopwatch are logger to log template is enabled.
@param split Split
@param sample Stopwatch sample | [
"{",
"@inheritDoc",
"}",
"Split",
"and",
"stopwatch",
"are",
"logger",
"to",
"log",
"template",
"is",
"enabled",
"."
] | train | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/callback/logging/LoggingCallback.java#L97-L100 |
fhoeben/hsac-fitnesse-fixtures | src/main/java/nl/hsac/fitnesse/fixture/util/selenium/SeleniumHelper.java | SeleniumHelper.setHiddenInputValue | public boolean setHiddenInputValue(String idOrName, String value) {
"""
Sets value of hidden input field.
@param idOrName id or name of input field to set.
@param value value to set.
@return whether input field was found.
"""
T element = findElement(By.id(idOrName));
if (element == null) {
element = findElement(By.name(idOrName));
if (element != null) {
executeJavascript("document.getElementsByName('%s')[0].value='%s'", idOrName, value);
}
} else {
executeJavascript("document.getElementById('%s').value='%s'", idOrName, value);
}
return element != null;
} | java | public boolean setHiddenInputValue(String idOrName, String value) {
T element = findElement(By.id(idOrName));
if (element == null) {
element = findElement(By.name(idOrName));
if (element != null) {
executeJavascript("document.getElementsByName('%s')[0].value='%s'", idOrName, value);
}
} else {
executeJavascript("document.getElementById('%s').value='%s'", idOrName, value);
}
return element != null;
} | [
"public",
"boolean",
"setHiddenInputValue",
"(",
"String",
"idOrName",
",",
"String",
"value",
")",
"{",
"T",
"element",
"=",
"findElement",
"(",
"By",
".",
"id",
"(",
"idOrName",
")",
")",
";",
"if",
"(",
"element",
"==",
"null",
")",
"{",
"element",
"=",
"findElement",
"(",
"By",
".",
"name",
"(",
"idOrName",
")",
")",
";",
"if",
"(",
"element",
"!=",
"null",
")",
"{",
"executeJavascript",
"(",
"\"document.getElementsByName('%s')[0].value='%s'\"",
",",
"idOrName",
",",
"value",
")",
";",
"}",
"}",
"else",
"{",
"executeJavascript",
"(",
"\"document.getElementById('%s').value='%s'\"",
",",
"idOrName",
",",
"value",
")",
";",
"}",
"return",
"element",
"!=",
"null",
";",
"}"
] | Sets value of hidden input field.
@param idOrName id or name of input field to set.
@param value value to set.
@return whether input field was found. | [
"Sets",
"value",
"of",
"hidden",
"input",
"field",
"."
] | train | https://github.com/fhoeben/hsac-fitnesse-fixtures/blob/4e9018d7386a9aa65bfcbf07eb28ae064edd1732/src/main/java/nl/hsac/fitnesse/fixture/util/selenium/SeleniumHelper.java#L413-L424 |
apache/flink | flink-core/src/main/java/org/apache/flink/api/java/typeutils/AvroUtils.java | AvroUtils.getAvroUtils | public static AvroUtils getAvroUtils() {
"""
Returns either the default {@link AvroUtils} which throw an exception in cases where Avro
would be needed or loads the specific utils for Avro from flink-avro.
"""
// try and load the special AvroUtils from the flink-avro package
try {
Class<?> clazz = Class.forName(AVRO_KRYO_UTILS, false, Thread.currentThread().getContextClassLoader());
return clazz.asSubclass(AvroUtils.class).getConstructor().newInstance();
} catch (ClassNotFoundException e) {
// cannot find the utils, return the default implementation
return new DefaultAvroUtils();
} catch (Exception e) {
throw new RuntimeException("Could not instantiate " + AVRO_KRYO_UTILS + ".", e);
}
} | java | public static AvroUtils getAvroUtils() {
// try and load the special AvroUtils from the flink-avro package
try {
Class<?> clazz = Class.forName(AVRO_KRYO_UTILS, false, Thread.currentThread().getContextClassLoader());
return clazz.asSubclass(AvroUtils.class).getConstructor().newInstance();
} catch (ClassNotFoundException e) {
// cannot find the utils, return the default implementation
return new DefaultAvroUtils();
} catch (Exception e) {
throw new RuntimeException("Could not instantiate " + AVRO_KRYO_UTILS + ".", e);
}
} | [
"public",
"static",
"AvroUtils",
"getAvroUtils",
"(",
")",
"{",
"// try and load the special AvroUtils from the flink-avro package",
"try",
"{",
"Class",
"<",
"?",
">",
"clazz",
"=",
"Class",
".",
"forName",
"(",
"AVRO_KRYO_UTILS",
",",
"false",
",",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
")",
";",
"return",
"clazz",
".",
"asSubclass",
"(",
"AvroUtils",
".",
"class",
")",
".",
"getConstructor",
"(",
")",
".",
"newInstance",
"(",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"e",
")",
"{",
"// cannot find the utils, return the default implementation",
"return",
"new",
"DefaultAvroUtils",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Could not instantiate \"",
"+",
"AVRO_KRYO_UTILS",
"+",
"\".\"",
",",
"e",
")",
";",
"}",
"}"
] | Returns either the default {@link AvroUtils} which throw an exception in cases where Avro
would be needed or loads the specific utils for Avro from flink-avro. | [
"Returns",
"either",
"the",
"default",
"{"
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/api/java/typeutils/AvroUtils.java#L44-L55 |
TheHortonMachine/hortonmachine | gears/src/main/java/oms3/ngmf/ui/TableListener.java | TableListener.parseString | private ArrayList<ArrayList<String>> parseString(String text) {
"""
turns the clipboard into a list of tokens
each array list is a line, each string in the list is a token in the line
@param text
@return
"""
ArrayList<ArrayList<String>> result = new ArrayList<ArrayList<String>>();
StringTokenizer linetoken = new StringTokenizer(text, "\n");
StringTokenizer token;
String current;
while (linetoken.hasMoreTokens()) {
current = linetoken.nextToken();
if (current.contains(",")) {
token = new StringTokenizer(current, ",");
} else {
token = new StringTokenizer(current);
}
ArrayList<String> line = new ArrayList<String>();
while (token.hasMoreTokens()) {
line.add(token.nextToken());
}
result.add(line);
}
return result;
} | java | private ArrayList<ArrayList<String>> parseString(String text) {
ArrayList<ArrayList<String>> result = new ArrayList<ArrayList<String>>();
StringTokenizer linetoken = new StringTokenizer(text, "\n");
StringTokenizer token;
String current;
while (linetoken.hasMoreTokens()) {
current = linetoken.nextToken();
if (current.contains(",")) {
token = new StringTokenizer(current, ",");
} else {
token = new StringTokenizer(current);
}
ArrayList<String> line = new ArrayList<String>();
while (token.hasMoreTokens()) {
line.add(token.nextToken());
}
result.add(line);
}
return result;
} | [
"private",
"ArrayList",
"<",
"ArrayList",
"<",
"String",
">",
">",
"parseString",
"(",
"String",
"text",
")",
"{",
"ArrayList",
"<",
"ArrayList",
"<",
"String",
">>",
"result",
"=",
"new",
"ArrayList",
"<",
"ArrayList",
"<",
"String",
">",
">",
"(",
")",
";",
"StringTokenizer",
"linetoken",
"=",
"new",
"StringTokenizer",
"(",
"text",
",",
"\"\\n\"",
")",
";",
"StringTokenizer",
"token",
";",
"String",
"current",
";",
"while",
"(",
"linetoken",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"current",
"=",
"linetoken",
".",
"nextToken",
"(",
")",
";",
"if",
"(",
"current",
".",
"contains",
"(",
"\",\"",
")",
")",
"{",
"token",
"=",
"new",
"StringTokenizer",
"(",
"current",
",",
"\",\"",
")",
";",
"}",
"else",
"{",
"token",
"=",
"new",
"StringTokenizer",
"(",
"current",
")",
";",
"}",
"ArrayList",
"<",
"String",
">",
"line",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"while",
"(",
"token",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"line",
".",
"add",
"(",
"token",
".",
"nextToken",
"(",
")",
")",
";",
"}",
"result",
".",
"add",
"(",
"line",
")",
";",
"}",
"return",
"result",
";",
"}"
] | turns the clipboard into a list of tokens
each array list is a line, each string in the list is a token in the line
@param text
@return | [
"turns",
"the",
"clipboard",
"into",
"a",
"list",
"of",
"tokens",
"each",
"array",
"list",
"is",
"a",
"line",
"each",
"string",
"in",
"the",
"list",
"is",
"a",
"token",
"in",
"the",
"line"
] | train | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/ngmf/ui/TableListener.java#L41-L61 |
hawtio/hawtio | hawtio-ide/src/main/java/io/hawt/ide/IdeFacade.java | IdeFacade.findInSourceFolders | protected String findInSourceFolders(File baseDir, String fileName) {
"""
Searches in this directory and in the source directories in src/main/* and src/test/* for the given file name path
@return the absolute file or null
"""
String answer = findInFolder(baseDir, fileName);
if (answer == null && baseDir.exists()) {
answer = findInChildFolders(new File(baseDir, "src/main"), fileName);
if (answer == null) {
answer = findInChildFolders(new File(baseDir, "src/test"), fileName);
}
}
return answer;
} | java | protected String findInSourceFolders(File baseDir, String fileName) {
String answer = findInFolder(baseDir, fileName);
if (answer == null && baseDir.exists()) {
answer = findInChildFolders(new File(baseDir, "src/main"), fileName);
if (answer == null) {
answer = findInChildFolders(new File(baseDir, "src/test"), fileName);
}
}
return answer;
} | [
"protected",
"String",
"findInSourceFolders",
"(",
"File",
"baseDir",
",",
"String",
"fileName",
")",
"{",
"String",
"answer",
"=",
"findInFolder",
"(",
"baseDir",
",",
"fileName",
")",
";",
"if",
"(",
"answer",
"==",
"null",
"&&",
"baseDir",
".",
"exists",
"(",
")",
")",
"{",
"answer",
"=",
"findInChildFolders",
"(",
"new",
"File",
"(",
"baseDir",
",",
"\"src/main\"",
")",
",",
"fileName",
")",
";",
"if",
"(",
"answer",
"==",
"null",
")",
"{",
"answer",
"=",
"findInChildFolders",
"(",
"new",
"File",
"(",
"baseDir",
",",
"\"src/test\"",
")",
",",
"fileName",
")",
";",
"}",
"}",
"return",
"answer",
";",
"}"
] | Searches in this directory and in the source directories in src/main/* and src/test/* for the given file name path
@return the absolute file or null | [
"Searches",
"in",
"this",
"directory",
"and",
"in",
"the",
"source",
"directories",
"in",
"src",
"/",
"main",
"/",
"*",
"and",
"src",
"/",
"test",
"/",
"*",
"for",
"the",
"given",
"file",
"name",
"path"
] | train | https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-ide/src/main/java/io/hawt/ide/IdeFacade.java#L88-L97 |
Jasig/uPortal | uPortal-layout/uPortal-layout-impl/src/main/java/org/apereo/portal/layout/dlm/PositionManager.java | PositionManager.applyToNodes | static void applyToNodes(List<NodeInfo> order, Element compViewParent) {
"""
This method applies the ordering specified in the passed in order list to the child nodes of
the compViewParent. Nodes specified in the list but located elsewhere are pulled in.
"""
// first set up a bogus node to assist with inserting
Node insertPoint = compViewParent.getOwnerDocument().createElement("bogus");
Node first = compViewParent.getFirstChild();
if (first != null) compViewParent.insertBefore(insertPoint, first);
else compViewParent.appendChild(insertPoint);
// now pass through the order list inserting the nodes as you go
for (int i = 0; i < order.size(); i++)
compViewParent.insertBefore(order.get(i).getNode(), insertPoint);
compViewParent.removeChild(insertPoint);
} | java | static void applyToNodes(List<NodeInfo> order, Element compViewParent) {
// first set up a bogus node to assist with inserting
Node insertPoint = compViewParent.getOwnerDocument().createElement("bogus");
Node first = compViewParent.getFirstChild();
if (first != null) compViewParent.insertBefore(insertPoint, first);
else compViewParent.appendChild(insertPoint);
// now pass through the order list inserting the nodes as you go
for (int i = 0; i < order.size(); i++)
compViewParent.insertBefore(order.get(i).getNode(), insertPoint);
compViewParent.removeChild(insertPoint);
} | [
"static",
"void",
"applyToNodes",
"(",
"List",
"<",
"NodeInfo",
">",
"order",
",",
"Element",
"compViewParent",
")",
"{",
"// first set up a bogus node to assist with inserting",
"Node",
"insertPoint",
"=",
"compViewParent",
".",
"getOwnerDocument",
"(",
")",
".",
"createElement",
"(",
"\"bogus\"",
")",
";",
"Node",
"first",
"=",
"compViewParent",
".",
"getFirstChild",
"(",
")",
";",
"if",
"(",
"first",
"!=",
"null",
")",
"compViewParent",
".",
"insertBefore",
"(",
"insertPoint",
",",
"first",
")",
";",
"else",
"compViewParent",
".",
"appendChild",
"(",
"insertPoint",
")",
";",
"// now pass through the order list inserting the nodes as you go",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"order",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"compViewParent",
".",
"insertBefore",
"(",
"order",
".",
"get",
"(",
"i",
")",
".",
"getNode",
"(",
")",
",",
"insertPoint",
")",
";",
"compViewParent",
".",
"removeChild",
"(",
"insertPoint",
")",
";",
"}"
] | This method applies the ordering specified in the passed in order list to the child nodes of
the compViewParent. Nodes specified in the list but located elsewhere are pulled in. | [
"This",
"method",
"applies",
"the",
"ordering",
"specified",
"in",
"the",
"passed",
"in",
"order",
"list",
"to",
"the",
"child",
"nodes",
"of",
"the",
"compViewParent",
".",
"Nodes",
"specified",
"in",
"the",
"list",
"but",
"located",
"elsewhere",
"are",
"pulled",
"in",
"."
] | train | https://github.com/Jasig/uPortal/blob/c1986542abb9acd214268f2df21c6305ad2f262b/uPortal-layout/uPortal-layout-impl/src/main/java/org/apereo/portal/layout/dlm/PositionManager.java#L241-L254 |
JOML-CI/JOML | src/org/joml/Matrix3f.java | Matrix3f.setSkewSymmetric | public Matrix3f setSkewSymmetric(float a, float b, float c) {
"""
Set this matrix to a skew-symmetric matrix using the following layout:
<pre>
0, a, -b
-a, 0, c
b, -c, 0
</pre>
Reference: <a href="https://en.wikipedia.org/wiki/Skew-symmetric_matrix">https://en.wikipedia.org</a>
@param a
the value used for the matrix elements m01 and m10
@param b
the value used for the matrix elements m02 and m20
@param c
the value used for the matrix elements m12 and m21
@return this
"""
m00 = m11 = m22 = 0;
m01 = -a;
m02 = b;
m10 = a;
m12 = -c;
m20 = -b;
m21 = c;
return this;
} | java | public Matrix3f setSkewSymmetric(float a, float b, float c) {
m00 = m11 = m22 = 0;
m01 = -a;
m02 = b;
m10 = a;
m12 = -c;
m20 = -b;
m21 = c;
return this;
} | [
"public",
"Matrix3f",
"setSkewSymmetric",
"(",
"float",
"a",
",",
"float",
"b",
",",
"float",
"c",
")",
"{",
"m00",
"=",
"m11",
"=",
"m22",
"=",
"0",
";",
"m01",
"=",
"-",
"a",
";",
"m02",
"=",
"b",
";",
"m10",
"=",
"a",
";",
"m12",
"=",
"-",
"c",
";",
"m20",
"=",
"-",
"b",
";",
"m21",
"=",
"c",
";",
"return",
"this",
";",
"}"
] | Set this matrix to a skew-symmetric matrix using the following layout:
<pre>
0, a, -b
-a, 0, c
b, -c, 0
</pre>
Reference: <a href="https://en.wikipedia.org/wiki/Skew-symmetric_matrix">https://en.wikipedia.org</a>
@param a
the value used for the matrix elements m01 and m10
@param b
the value used for the matrix elements m02 and m20
@param c
the value used for the matrix elements m12 and m21
@return this | [
"Set",
"this",
"matrix",
"to",
"a",
"skew",
"-",
"symmetric",
"matrix",
"using",
"the",
"following",
"layout",
":",
"<pre",
">",
"0",
"a",
"-",
"b",
"-",
"a",
"0",
"c",
"b",
"-",
"c",
"0",
"<",
"/",
"pre",
">"
] | train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Matrix3f.java#L3790-L3799 |
ironjacamar/ironjacamar | codegenerator/src/main/java/org/ironjacamar/codegenerator/code/AoInterfaceCodeGen.java | AoInterfaceCodeGen.writeClassBody | @Override
public void writeClassBody(Definition def, Writer out) throws IOException {
"""
Output class
@param def definition
@param out Writer
@throws IOException ioException
"""
out.write("public interface " + getClassName(def));
if (def.isAdminObjectImplRaAssociation())
{
out.write(" extends Referenceable, Serializable");
}
writeLeftCurlyBracket(out, 0);
writeEol(out);
int indent = 1;
writeConfigProps(def, out, indent);
writeRightCurlyBracket(out, 0);
} | java | @Override
public void writeClassBody(Definition def, Writer out) throws IOException
{
out.write("public interface " + getClassName(def));
if (def.isAdminObjectImplRaAssociation())
{
out.write(" extends Referenceable, Serializable");
}
writeLeftCurlyBracket(out, 0);
writeEol(out);
int indent = 1;
writeConfigProps(def, out, indent);
writeRightCurlyBracket(out, 0);
} | [
"@",
"Override",
"public",
"void",
"writeClassBody",
"(",
"Definition",
"def",
",",
"Writer",
"out",
")",
"throws",
"IOException",
"{",
"out",
".",
"write",
"(",
"\"public interface \"",
"+",
"getClassName",
"(",
"def",
")",
")",
";",
"if",
"(",
"def",
".",
"isAdminObjectImplRaAssociation",
"(",
")",
")",
"{",
"out",
".",
"write",
"(",
"\" extends Referenceable, Serializable\"",
")",
";",
"}",
"writeLeftCurlyBracket",
"(",
"out",
",",
"0",
")",
";",
"writeEol",
"(",
"out",
")",
";",
"int",
"indent",
"=",
"1",
";",
"writeConfigProps",
"(",
"def",
",",
"out",
",",
"indent",
")",
";",
"writeRightCurlyBracket",
"(",
"out",
",",
"0",
")",
";",
"}"
] | Output class
@param def definition
@param out Writer
@throws IOException ioException | [
"Output",
"class"
] | train | https://github.com/ironjacamar/ironjacamar/blob/f0389ee7e62aa8b40ba09b251edad76d220ea796/codegenerator/src/main/java/org/ironjacamar/codegenerator/code/AoInterfaceCodeGen.java#L87-L101 |
grails/grails-core | grails-core/src/main/groovy/grails/util/GrailsClassUtils.java | GrailsClassUtils.findPropertyNameForValue | public static String findPropertyNameForValue(Object target, Object obj) {
"""
Locates the name of a property for the given value on the target object using Groovy's meta APIs.
Note that this method uses the reference so the incorrect result could be returned for two properties
that refer to the same reference. Use with caution.
@param target The target
@param obj The property value
@return The property name or null
"""
MetaClass mc = GroovySystem.getMetaClassRegistry().getMetaClass(target.getClass());
List<MetaProperty> metaProperties = mc.getProperties();
for (MetaProperty metaProperty : metaProperties) {
if (isAssignableOrConvertibleFrom(metaProperty.getType(), obj.getClass())) {
Object val = metaProperty.getProperty(target);
if (val != null && val.equals(obj)) {
return metaProperty.getName();
}
}
}
return null;
} | java | public static String findPropertyNameForValue(Object target, Object obj) {
MetaClass mc = GroovySystem.getMetaClassRegistry().getMetaClass(target.getClass());
List<MetaProperty> metaProperties = mc.getProperties();
for (MetaProperty metaProperty : metaProperties) {
if (isAssignableOrConvertibleFrom(metaProperty.getType(), obj.getClass())) {
Object val = metaProperty.getProperty(target);
if (val != null && val.equals(obj)) {
return metaProperty.getName();
}
}
}
return null;
} | [
"public",
"static",
"String",
"findPropertyNameForValue",
"(",
"Object",
"target",
",",
"Object",
"obj",
")",
"{",
"MetaClass",
"mc",
"=",
"GroovySystem",
".",
"getMetaClassRegistry",
"(",
")",
".",
"getMetaClass",
"(",
"target",
".",
"getClass",
"(",
")",
")",
";",
"List",
"<",
"MetaProperty",
">",
"metaProperties",
"=",
"mc",
".",
"getProperties",
"(",
")",
";",
"for",
"(",
"MetaProperty",
"metaProperty",
":",
"metaProperties",
")",
"{",
"if",
"(",
"isAssignableOrConvertibleFrom",
"(",
"metaProperty",
".",
"getType",
"(",
")",
",",
"obj",
".",
"getClass",
"(",
")",
")",
")",
"{",
"Object",
"val",
"=",
"metaProperty",
".",
"getProperty",
"(",
"target",
")",
";",
"if",
"(",
"val",
"!=",
"null",
"&&",
"val",
".",
"equals",
"(",
"obj",
")",
")",
"{",
"return",
"metaProperty",
".",
"getName",
"(",
")",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] | Locates the name of a property for the given value on the target object using Groovy's meta APIs.
Note that this method uses the reference so the incorrect result could be returned for two properties
that refer to the same reference. Use with caution.
@param target The target
@param obj The property value
@return The property name or null | [
"Locates",
"the",
"name",
"of",
"a",
"property",
"for",
"the",
"given",
"value",
"on",
"the",
"target",
"object",
"using",
"Groovy",
"s",
"meta",
"APIs",
".",
"Note",
"that",
"this",
"method",
"uses",
"the",
"reference",
"so",
"the",
"incorrect",
"result",
"could",
"be",
"returned",
"for",
"two",
"properties",
"that",
"refer",
"to",
"the",
"same",
"reference",
".",
"Use",
"with",
"caution",
"."
] | train | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/GrailsClassUtils.java#L848-L860 |
ThreeTen/threetenbp | src/main/java/org/threeten/bp/ZoneRegion.java | ZoneRegion.ofId | static ZoneRegion ofId(String zoneId, boolean checkAvailable) {
"""
Obtains an instance of {@code ZoneId} from an identifier.
@param zoneId the time-zone ID, not null
@param checkAvailable whether to check if the zone ID is available
@return the zone ID, not null
@throws DateTimeException if the ID format is invalid
@throws DateTimeException if checking availability and the ID cannot be found
"""
Jdk8Methods.requireNonNull(zoneId, "zoneId");
if (zoneId.length() < 2 || PATTERN.matcher(zoneId).matches() == false) {
throw new DateTimeException("Invalid ID for region-based ZoneId, invalid format: " + zoneId);
}
ZoneRules rules = null;
try {
// always attempt load for better behavior after deserialization
rules = ZoneRulesProvider.getRules(zoneId, true);
} catch (ZoneRulesException ex) {
// special case as removed from data file
if (zoneId.equals("GMT0")) {
rules = ZoneOffset.UTC.getRules();
} else if (checkAvailable) {
throw ex;
}
}
return new ZoneRegion(zoneId, rules);
} | java | static ZoneRegion ofId(String zoneId, boolean checkAvailable) {
Jdk8Methods.requireNonNull(zoneId, "zoneId");
if (zoneId.length() < 2 || PATTERN.matcher(zoneId).matches() == false) {
throw new DateTimeException("Invalid ID for region-based ZoneId, invalid format: " + zoneId);
}
ZoneRules rules = null;
try {
// always attempt load for better behavior after deserialization
rules = ZoneRulesProvider.getRules(zoneId, true);
} catch (ZoneRulesException ex) {
// special case as removed from data file
if (zoneId.equals("GMT0")) {
rules = ZoneOffset.UTC.getRules();
} else if (checkAvailable) {
throw ex;
}
}
return new ZoneRegion(zoneId, rules);
} | [
"static",
"ZoneRegion",
"ofId",
"(",
"String",
"zoneId",
",",
"boolean",
"checkAvailable",
")",
"{",
"Jdk8Methods",
".",
"requireNonNull",
"(",
"zoneId",
",",
"\"zoneId\"",
")",
";",
"if",
"(",
"zoneId",
".",
"length",
"(",
")",
"<",
"2",
"||",
"PATTERN",
".",
"matcher",
"(",
"zoneId",
")",
".",
"matches",
"(",
")",
"==",
"false",
")",
"{",
"throw",
"new",
"DateTimeException",
"(",
"\"Invalid ID for region-based ZoneId, invalid format: \"",
"+",
"zoneId",
")",
";",
"}",
"ZoneRules",
"rules",
"=",
"null",
";",
"try",
"{",
"// always attempt load for better behavior after deserialization",
"rules",
"=",
"ZoneRulesProvider",
".",
"getRules",
"(",
"zoneId",
",",
"true",
")",
";",
"}",
"catch",
"(",
"ZoneRulesException",
"ex",
")",
"{",
"// special case as removed from data file",
"if",
"(",
"zoneId",
".",
"equals",
"(",
"\"GMT0\"",
")",
")",
"{",
"rules",
"=",
"ZoneOffset",
".",
"UTC",
".",
"getRules",
"(",
")",
";",
"}",
"else",
"if",
"(",
"checkAvailable",
")",
"{",
"throw",
"ex",
";",
"}",
"}",
"return",
"new",
"ZoneRegion",
"(",
"zoneId",
",",
"rules",
")",
";",
"}"
] | Obtains an instance of {@code ZoneId} from an identifier.
@param zoneId the time-zone ID, not null
@param checkAvailable whether to check if the zone ID is available
@return the zone ID, not null
@throws DateTimeException if the ID format is invalid
@throws DateTimeException if checking availability and the ID cannot be found | [
"Obtains",
"an",
"instance",
"of",
"{",
"@code",
"ZoneId",
"}",
"from",
"an",
"identifier",
"."
] | train | https://github.com/ThreeTen/threetenbp/blob/5f05b649f89f205aabd96b2f83c36796ec616fe6/src/main/java/org/threeten/bp/ZoneRegion.java#L135-L153 |
datumbox/datumbox-framework | datumbox-framework-core/src/main/java/com/datumbox/framework/core/statistics/parametrics/onesample/NormalOneSample.java | NormalOneSample.checkCriticalValue | private static boolean checkCriticalValue(double score, boolean is_twoTailed, double aLevel) {
"""
Checks the Critical Value to determine if the Hypothesis should be rejected
@param score
@param is_twoTailed
@param aLevel
@return
"""
double probability = ContinuousDistributions.gaussCdf(score);
boolean rejectH0=false;
double a=aLevel;
if(is_twoTailed) { //if to tailed test then split the statistical significance in half
a=aLevel/2.0;
}
if(probability<=a || probability>=(1.0-a)) {
rejectH0=true;
}
return rejectH0;
} | java | private static boolean checkCriticalValue(double score, boolean is_twoTailed, double aLevel) {
double probability = ContinuousDistributions.gaussCdf(score);
boolean rejectH0=false;
double a=aLevel;
if(is_twoTailed) { //if to tailed test then split the statistical significance in half
a=aLevel/2.0;
}
if(probability<=a || probability>=(1.0-a)) {
rejectH0=true;
}
return rejectH0;
} | [
"private",
"static",
"boolean",
"checkCriticalValue",
"(",
"double",
"score",
",",
"boolean",
"is_twoTailed",
",",
"double",
"aLevel",
")",
"{",
"double",
"probability",
"=",
"ContinuousDistributions",
".",
"gaussCdf",
"(",
"score",
")",
";",
"boolean",
"rejectH0",
"=",
"false",
";",
"double",
"a",
"=",
"aLevel",
";",
"if",
"(",
"is_twoTailed",
")",
"{",
"//if to tailed test then split the statistical significance in half",
"a",
"=",
"aLevel",
"/",
"2.0",
";",
"}",
"if",
"(",
"probability",
"<=",
"a",
"||",
"probability",
">=",
"(",
"1.0",
"-",
"a",
")",
")",
"{",
"rejectH0",
"=",
"true",
";",
"}",
"return",
"rejectH0",
";",
"}"
] | Checks the Critical Value to determine if the Hypothesis should be rejected
@param score
@param is_twoTailed
@param aLevel
@return | [
"Checks",
"the",
"Critical",
"Value",
"to",
"determine",
"if",
"the",
"Hypothesis",
"should",
"be",
"rejected"
] | train | https://github.com/datumbox/datumbox-framework/blob/909dff0476e80834f05ecdde0624dd2390e9b0ca/datumbox-framework-core/src/main/java/com/datumbox/framework/core/statistics/parametrics/onesample/NormalOneSample.java#L106-L120 |
Azure/azure-sdk-for-java | batch/data-plane/src/main/java/com/microsoft/azure/batch/protocol/implementation/AccountsImpl.java | AccountsImpl.listNodeAgentSkusNextAsync | public ServiceFuture<List<NodeAgentSku>> listNodeAgentSkusNextAsync(final String nextPageLink, final AccountListNodeAgentSkusNextOptions accountListNodeAgentSkusNextOptions, final ServiceFuture<List<NodeAgentSku>> serviceFuture, final ListOperationCallback<NodeAgentSku> serviceCallback) {
"""
Lists all node agent SKUs supported by the Azure Batch service.
@param nextPageLink The NextLink from the previous successful call to List operation.
@param accountListNodeAgentSkusNextOptions Additional parameters for the operation
@param serviceFuture the ServiceFuture object tracking the Retrofit calls
@param serviceCallback the async ServiceCallback to handle successful and failed responses.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceFuture} object
"""
return AzureServiceFuture.fromHeaderPageResponse(
listNodeAgentSkusNextSinglePageAsync(nextPageLink, accountListNodeAgentSkusNextOptions),
new Func1<String, Observable<ServiceResponseWithHeaders<Page<NodeAgentSku>, AccountListNodeAgentSkusHeaders>>>() {
@Override
public Observable<ServiceResponseWithHeaders<Page<NodeAgentSku>, AccountListNodeAgentSkusHeaders>> call(String nextPageLink) {
return listNodeAgentSkusNextSinglePageAsync(nextPageLink, accountListNodeAgentSkusNextOptions);
}
},
serviceCallback);
} | java | public ServiceFuture<List<NodeAgentSku>> listNodeAgentSkusNextAsync(final String nextPageLink, final AccountListNodeAgentSkusNextOptions accountListNodeAgentSkusNextOptions, final ServiceFuture<List<NodeAgentSku>> serviceFuture, final ListOperationCallback<NodeAgentSku> serviceCallback) {
return AzureServiceFuture.fromHeaderPageResponse(
listNodeAgentSkusNextSinglePageAsync(nextPageLink, accountListNodeAgentSkusNextOptions),
new Func1<String, Observable<ServiceResponseWithHeaders<Page<NodeAgentSku>, AccountListNodeAgentSkusHeaders>>>() {
@Override
public Observable<ServiceResponseWithHeaders<Page<NodeAgentSku>, AccountListNodeAgentSkusHeaders>> call(String nextPageLink) {
return listNodeAgentSkusNextSinglePageAsync(nextPageLink, accountListNodeAgentSkusNextOptions);
}
},
serviceCallback);
} | [
"public",
"ServiceFuture",
"<",
"List",
"<",
"NodeAgentSku",
">",
">",
"listNodeAgentSkusNextAsync",
"(",
"final",
"String",
"nextPageLink",
",",
"final",
"AccountListNodeAgentSkusNextOptions",
"accountListNodeAgentSkusNextOptions",
",",
"final",
"ServiceFuture",
"<",
"List",
"<",
"NodeAgentSku",
">",
">",
"serviceFuture",
",",
"final",
"ListOperationCallback",
"<",
"NodeAgentSku",
">",
"serviceCallback",
")",
"{",
"return",
"AzureServiceFuture",
".",
"fromHeaderPageResponse",
"(",
"listNodeAgentSkusNextSinglePageAsync",
"(",
"nextPageLink",
",",
"accountListNodeAgentSkusNextOptions",
")",
",",
"new",
"Func1",
"<",
"String",
",",
"Observable",
"<",
"ServiceResponseWithHeaders",
"<",
"Page",
"<",
"NodeAgentSku",
">",
",",
"AccountListNodeAgentSkusHeaders",
">",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Observable",
"<",
"ServiceResponseWithHeaders",
"<",
"Page",
"<",
"NodeAgentSku",
">",
",",
"AccountListNodeAgentSkusHeaders",
">",
">",
"call",
"(",
"String",
"nextPageLink",
")",
"{",
"return",
"listNodeAgentSkusNextSinglePageAsync",
"(",
"nextPageLink",
",",
"accountListNodeAgentSkusNextOptions",
")",
";",
"}",
"}",
",",
"serviceCallback",
")",
";",
"}"
] | Lists all node agent SKUs supported by the Azure Batch service.
@param nextPageLink The NextLink from the previous successful call to List operation.
@param accountListNodeAgentSkusNextOptions Additional parameters for the operation
@param serviceFuture the ServiceFuture object tracking the Retrofit calls
@param serviceCallback the async ServiceCallback to handle successful and failed responses.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceFuture} object | [
"Lists",
"all",
"node",
"agent",
"SKUs",
"supported",
"by",
"the",
"Azure",
"Batch",
"service",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batch/data-plane/src/main/java/com/microsoft/azure/batch/protocol/implementation/AccountsImpl.java#L779-L789 |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedConnection.java | MemcachedConnection.addOperations | public void addOperations(final Map<MemcachedNode, Operation> ops) {
"""
Enqueue the given list of operations on each handling node.
@param ops the operations for each node.
"""
for (Map.Entry<MemcachedNode, Operation> me : ops.entrySet()) {
addOperation(me.getKey(), me.getValue());
}
} | java | public void addOperations(final Map<MemcachedNode, Operation> ops) {
for (Map.Entry<MemcachedNode, Operation> me : ops.entrySet()) {
addOperation(me.getKey(), me.getValue());
}
} | [
"public",
"void",
"addOperations",
"(",
"final",
"Map",
"<",
"MemcachedNode",
",",
"Operation",
">",
"ops",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"MemcachedNode",
",",
"Operation",
">",
"me",
":",
"ops",
".",
"entrySet",
"(",
")",
")",
"{",
"addOperation",
"(",
"me",
".",
"getKey",
"(",
")",
",",
"me",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}"
] | Enqueue the given list of operations on each handling node.
@param ops the operations for each node. | [
"Enqueue",
"the",
"given",
"list",
"of",
"operations",
"on",
"each",
"handling",
"node",
"."
] | train | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedConnection.java#L1295-L1299 |
hyperledger/fabric-sdk-java | src/main/java/org/hyperledger/fabric/sdk/idemix/IdemixUtils.java | IdemixUtils.modAdd | static BIG modAdd(BIG a, BIG b, BIG m) {
"""
Takes input BIGs a, b, m and returns a+b modulo m
@param a the first BIG to add
@param b the second BIG to add
@param m the modulus
@return Returns a+b (mod m)
"""
BIG c = a.plus(b);
c.mod(m);
return c;
} | java | static BIG modAdd(BIG a, BIG b, BIG m) {
BIG c = a.plus(b);
c.mod(m);
return c;
} | [
"static",
"BIG",
"modAdd",
"(",
"BIG",
"a",
",",
"BIG",
"b",
",",
"BIG",
"m",
")",
"{",
"BIG",
"c",
"=",
"a",
".",
"plus",
"(",
"b",
")",
";",
"c",
".",
"mod",
"(",
"m",
")",
";",
"return",
"c",
";",
"}"
] | Takes input BIGs a, b, m and returns a+b modulo m
@param a the first BIG to add
@param b the second BIG to add
@param m the modulus
@return Returns a+b (mod m) | [
"Takes",
"input",
"BIGs",
"a",
"b",
"m",
"and",
"returns",
"a",
"+",
"b",
"modulo",
"m"
] | train | https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/idemix/IdemixUtils.java#L258-L262 |
liferay/com-liferay-commerce | commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPInstancePersistenceImpl.java | CPInstancePersistenceImpl.countByLtD_S | @Override
public int countByLtD_S(Date displayDate, int status) {
"""
Returns the number of cp instances where displayDate < ? and status = ?.
@param displayDate the display date
@param status the status
@return the number of matching cp instances
"""
FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S;
Object[] finderArgs = new Object[] { _getTime(displayDate), status };
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_CPINSTANCE_WHERE);
boolean bindDisplayDate = false;
if (displayDate == null) {
query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
}
else {
bindDisplayDate = true;
query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
}
query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (bindDisplayDate) {
qPos.add(new Timestamp(displayDate.getTime()));
}
qPos.add(status);
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 countByLtD_S(Date displayDate, int status) {
FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S;
Object[] finderArgs = new Object[] { _getTime(displayDate), status };
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_CPINSTANCE_WHERE);
boolean bindDisplayDate = false;
if (displayDate == null) {
query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
}
else {
bindDisplayDate = true;
query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
}
query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (bindDisplayDate) {
qPos.add(new Timestamp(displayDate.getTime()));
}
qPos.add(status);
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",
"countByLtD_S",
"(",
"Date",
"displayDate",
",",
"int",
"status",
")",
"{",
"FinderPath",
"finderPath",
"=",
"FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S",
";",
"Object",
"[",
"]",
"finderArgs",
"=",
"new",
"Object",
"[",
"]",
"{",
"_getTime",
"(",
"displayDate",
")",
",",
"status",
"}",
";",
"Long",
"count",
"=",
"(",
"Long",
")",
"finderCache",
".",
"getResult",
"(",
"finderPath",
",",
"finderArgs",
",",
"this",
")",
";",
"if",
"(",
"count",
"==",
"null",
")",
"{",
"StringBundler",
"query",
"=",
"new",
"StringBundler",
"(",
"3",
")",
";",
"query",
".",
"append",
"(",
"_SQL_COUNT_CPINSTANCE_WHERE",
")",
";",
"boolean",
"bindDisplayDate",
"=",
"false",
";",
"if",
"(",
"displayDate",
"==",
"null",
")",
"{",
"query",
".",
"append",
"(",
"_FINDER_COLUMN_LTD_S_DISPLAYDATE_1",
")",
";",
"}",
"else",
"{",
"bindDisplayDate",
"=",
"true",
";",
"query",
".",
"append",
"(",
"_FINDER_COLUMN_LTD_S_DISPLAYDATE_2",
")",
";",
"}",
"query",
".",
"append",
"(",
"_FINDER_COLUMN_LTD_S_STATUS_2",
")",
";",
"String",
"sql",
"=",
"query",
".",
"toString",
"(",
")",
";",
"Session",
"session",
"=",
"null",
";",
"try",
"{",
"session",
"=",
"openSession",
"(",
")",
";",
"Query",
"q",
"=",
"session",
".",
"createQuery",
"(",
"sql",
")",
";",
"QueryPos",
"qPos",
"=",
"QueryPos",
".",
"getInstance",
"(",
"q",
")",
";",
"if",
"(",
"bindDisplayDate",
")",
"{",
"qPos",
".",
"add",
"(",
"new",
"Timestamp",
"(",
"displayDate",
".",
"getTime",
"(",
")",
")",
")",
";",
"}",
"qPos",
".",
"add",
"(",
"status",
")",
";",
"count",
"=",
"(",
"Long",
")",
"q",
".",
"uniqueResult",
"(",
")",
";",
"finderCache",
".",
"putResult",
"(",
"finderPath",
",",
"finderArgs",
",",
"count",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"finderCache",
".",
"removeResult",
"(",
"finderPath",
",",
"finderArgs",
")",
";",
"throw",
"processException",
"(",
"e",
")",
";",
"}",
"finally",
"{",
"closeSession",
"(",
"session",
")",
";",
"}",
"}",
"return",
"count",
".",
"intValue",
"(",
")",
";",
"}"
] | Returns the number of cp instances where displayDate < ? and status = ?.
@param displayDate the display date
@param status the status
@return the number of matching cp instances | [
"Returns",
"the",
"number",
"of",
"cp",
"instances",
"where",
"displayDate",
"<",
";",
"?",
";",
"and",
"status",
"=",
"?",
";",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPInstancePersistenceImpl.java#L6134-L6192 |
marvinlabs/android-intents | library/src/main/java/com/marvinlabs/intents/PhoneIntents.java | PhoneIntents.newCallNumberIntent | public static Intent newCallNumberIntent(String phoneNumber) {
"""
Creates an intent that will immediately dispatch a call to the given number. NOTE that unlike
{@link #newDialNumberIntent(String)}, this intent requires the {@link android.Manifest.permission#CALL_PHONE}
permission to be set.
@param phoneNumber the number to call
@return the intent
"""
final Intent intent;
if (phoneNumber == null || phoneNumber.trim().length() <= 0) {
intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:"));
} else {
intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumber.replace(" ", "")));
}
return intent;
} | java | public static Intent newCallNumberIntent(String phoneNumber) {
final Intent intent;
if (phoneNumber == null || phoneNumber.trim().length() <= 0) {
intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:"));
} else {
intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumber.replace(" ", "")));
}
return intent;
} | [
"public",
"static",
"Intent",
"newCallNumberIntent",
"(",
"String",
"phoneNumber",
")",
"{",
"final",
"Intent",
"intent",
";",
"if",
"(",
"phoneNumber",
"==",
"null",
"||",
"phoneNumber",
".",
"trim",
"(",
")",
".",
"length",
"(",
")",
"<=",
"0",
")",
"{",
"intent",
"=",
"new",
"Intent",
"(",
"Intent",
".",
"ACTION_CALL",
",",
"Uri",
".",
"parse",
"(",
"\"tel:\"",
")",
")",
";",
"}",
"else",
"{",
"intent",
"=",
"new",
"Intent",
"(",
"Intent",
".",
"ACTION_CALL",
",",
"Uri",
".",
"parse",
"(",
"\"tel:\"",
"+",
"phoneNumber",
".",
"replace",
"(",
"\" \"",
",",
"\"\"",
")",
")",
")",
";",
"}",
"return",
"intent",
";",
"}"
] | Creates an intent that will immediately dispatch a call to the given number. NOTE that unlike
{@link #newDialNumberIntent(String)}, this intent requires the {@link android.Manifest.permission#CALL_PHONE}
permission to be set.
@param phoneNumber the number to call
@return the intent | [
"Creates",
"an",
"intent",
"that",
"will",
"immediately",
"dispatch",
"a",
"call",
"to",
"the",
"given",
"number",
".",
"NOTE",
"that",
"unlike",
"{",
"@link",
"#newDialNumberIntent",
"(",
"String",
")",
"}",
"this",
"intent",
"requires",
"the",
"{",
"@link",
"android",
".",
"Manifest",
".",
"permission#CALL_PHONE",
"}",
"permission",
"to",
"be",
"set",
"."
] | train | https://github.com/marvinlabs/android-intents/blob/33e79c825188b6a97601869522533cc825801f6e/library/src/main/java/com/marvinlabs/intents/PhoneIntents.java#L143-L151 |
pgjdbc/pgjdbc | pgjdbc/src/main/java/org/postgresql/jdbc/EscapedFunctions2.java | EscapedFunctions2.sqllog10 | public static void sqllog10(StringBuilder buf, List<? extends CharSequence> parsedArgs) throws SQLException {
"""
log10 to log translation
@param buf The buffer to append into
@param parsedArgs arguments
@throws SQLException if something wrong happens
"""
singleArgumentFunctionCall(buf, "log(", "log10", parsedArgs);
} | java | public static void sqllog10(StringBuilder buf, List<? extends CharSequence> parsedArgs) throws SQLException {
singleArgumentFunctionCall(buf, "log(", "log10", parsedArgs);
} | [
"public",
"static",
"void",
"sqllog10",
"(",
"StringBuilder",
"buf",
",",
"List",
"<",
"?",
"extends",
"CharSequence",
">",
"parsedArgs",
")",
"throws",
"SQLException",
"{",
"singleArgumentFunctionCall",
"(",
"buf",
",",
"\"log(\"",
",",
"\"log10\"",
",",
"parsedArgs",
")",
";",
"}"
] | log10 to log translation
@param buf The buffer to append into
@param parsedArgs arguments
@throws SQLException if something wrong happens | [
"log10",
"to",
"log",
"translation"
] | train | https://github.com/pgjdbc/pgjdbc/blob/95ba7b261e39754674c5817695ae5ebf9a341fae/pgjdbc/src/main/java/org/postgresql/jdbc/EscapedFunctions2.java#L109-L111 |
hdbeukel/james-core | src/main/java/org/jamesframework/core/subset/neigh/adv/MultiSwapNeighbourhood.java | MultiSwapNeighbourhood.maxSwaps | private int maxSwaps(Set<Integer> addCandidates, Set<Integer> deleteCandidates) {
"""
Computes the maximum number of swaps that can be performed, given the set of candidate IDs
for addition and deletion. Takes into account the desired maximum number of swaps \(k\) specified
at construction (if set). The maximum number of swaps is equal to the minimum of \(k\) and the
size of both candidate sets. Thus, if any of the given candidate sets is empty, zero is returned.
@param addCandidates candidate IDs to be added to the selection
@param deleteCandidates candidate IDs to be removed from the selection
@return maximum number of swaps to be performed
"""
return Math.min(maxSwaps, Math.min(addCandidates.size(), deleteCandidates.size()));
} | java | private int maxSwaps(Set<Integer> addCandidates, Set<Integer> deleteCandidates){
return Math.min(maxSwaps, Math.min(addCandidates.size(), deleteCandidates.size()));
} | [
"private",
"int",
"maxSwaps",
"(",
"Set",
"<",
"Integer",
">",
"addCandidates",
",",
"Set",
"<",
"Integer",
">",
"deleteCandidates",
")",
"{",
"return",
"Math",
".",
"min",
"(",
"maxSwaps",
",",
"Math",
".",
"min",
"(",
"addCandidates",
".",
"size",
"(",
")",
",",
"deleteCandidates",
".",
"size",
"(",
")",
")",
")",
";",
"}"
] | Computes the maximum number of swaps that can be performed, given the set of candidate IDs
for addition and deletion. Takes into account the desired maximum number of swaps \(k\) specified
at construction (if set). The maximum number of swaps is equal to the minimum of \(k\) and the
size of both candidate sets. Thus, if any of the given candidate sets is empty, zero is returned.
@param addCandidates candidate IDs to be added to the selection
@param deleteCandidates candidate IDs to be removed from the selection
@return maximum number of swaps to be performed | [
"Computes",
"the",
"maximum",
"number",
"of",
"swaps",
"that",
"can",
"be",
"performed",
"given",
"the",
"set",
"of",
"candidate",
"IDs",
"for",
"addition",
"and",
"deletion",
".",
"Takes",
"into",
"account",
"the",
"desired",
"maximum",
"number",
"of",
"swaps",
"\\",
"(",
"k",
"\\",
")",
"specified",
"at",
"construction",
"(",
"if",
"set",
")",
".",
"The",
"maximum",
"number",
"of",
"swaps",
"is",
"equal",
"to",
"the",
"minimum",
"of",
"\\",
"(",
"k",
"\\",
")",
"and",
"the",
"size",
"of",
"both",
"candidate",
"sets",
".",
"Thus",
"if",
"any",
"of",
"the",
"given",
"candidate",
"sets",
"is",
"empty",
"zero",
"is",
"returned",
"."
] | train | https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/subset/neigh/adv/MultiSwapNeighbourhood.java#L215-L217 |
otto-de/edison-hal | src/main/java/de/otto/edison/hal/HalRepresentation.java | HalRepresentation.withEmbedded | protected HalRepresentation withEmbedded(final String rel, final List<? extends HalRepresentation> embeddedItems) {
"""
Adds embedded items for a link-relation type to the HalRepresentation.
<p>
If {@code rel} is already present, it is replaced by the new embedded items.
</p>
@param rel the link-relation type of the embedded items that are added or replaced
@param embeddedItems the new values for the specified link-relation type
@return this
@since 0.5.0
"""
embedded = copyOf(embedded).with(rel, embeddedItems).using(curies).build();
return this;
} | java | protected HalRepresentation withEmbedded(final String rel, final List<? extends HalRepresentation> embeddedItems) {
embedded = copyOf(embedded).with(rel, embeddedItems).using(curies).build();
return this;
} | [
"protected",
"HalRepresentation",
"withEmbedded",
"(",
"final",
"String",
"rel",
",",
"final",
"List",
"<",
"?",
"extends",
"HalRepresentation",
">",
"embeddedItems",
")",
"{",
"embedded",
"=",
"copyOf",
"(",
"embedded",
")",
".",
"with",
"(",
"rel",
",",
"embeddedItems",
")",
".",
"using",
"(",
"curies",
")",
".",
"build",
"(",
")",
";",
"return",
"this",
";",
"}"
] | Adds embedded items for a link-relation type to the HalRepresentation.
<p>
If {@code rel} is already present, it is replaced by the new embedded items.
</p>
@param rel the link-relation type of the embedded items that are added or replaced
@param embeddedItems the new values for the specified link-relation type
@return this
@since 0.5.0 | [
"Adds",
"embedded",
"items",
"for",
"a",
"link",
"-",
"relation",
"type",
"to",
"the",
"HalRepresentation",
".",
"<p",
">",
"If",
"{",
"@code",
"rel",
"}",
"is",
"already",
"present",
"it",
"is",
"replaced",
"by",
"the",
"new",
"embedded",
"items",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/otto-de/edison-hal/blob/1582d2b49d1f0d9103e03bf742f18afa9d166992/src/main/java/de/otto/edison/hal/HalRepresentation.java#L206-L209 |
logic-ng/LogicNG | src/main/java/org/logicng/backbones/BackboneGeneration.java | BackboneGeneration.computePositive | public static Backbone computePositive(final Formula formula) {
"""
Computes the positive backbone variables for a given formula.
@param formula the given formula
@return the positive backbone or {@code null} if the formula is UNSAT
"""
return compute(formula, formula.variables(), BackboneType.ONLY_POSITIVE);
} | java | public static Backbone computePositive(final Formula formula) {
return compute(formula, formula.variables(), BackboneType.ONLY_POSITIVE);
} | [
"public",
"static",
"Backbone",
"computePositive",
"(",
"final",
"Formula",
"formula",
")",
"{",
"return",
"compute",
"(",
"formula",
",",
"formula",
".",
"variables",
"(",
")",
",",
"BackboneType",
".",
"ONLY_POSITIVE",
")",
";",
"}"
] | Computes the positive backbone variables for a given formula.
@param formula the given formula
@return the positive backbone or {@code null} if the formula is UNSAT | [
"Computes",
"the",
"positive",
"backbone",
"variables",
"for",
"a",
"given",
"formula",
"."
] | train | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/backbones/BackboneGeneration.java#L192-L194 |
zaproxy/zaproxy | src/org/zaproxy/zap/utils/ApiUtils.java | ApiUtils.getOptionalStringParam | public static String getOptionalStringParam(JSONObject params, String paramName) {
"""
Gets an optional string param, returning null if the parameter was not found.
@param params the params
@param paramName the param name
@return the optional string param
"""
if (params.containsKey(paramName)) {
return params.getString(paramName);
}
return null;
} | java | public static String getOptionalStringParam(JSONObject params, String paramName) {
if (params.containsKey(paramName)) {
return params.getString(paramName);
}
return null;
} | [
"public",
"static",
"String",
"getOptionalStringParam",
"(",
"JSONObject",
"params",
",",
"String",
"paramName",
")",
"{",
"if",
"(",
"params",
".",
"containsKey",
"(",
"paramName",
")",
")",
"{",
"return",
"params",
".",
"getString",
"(",
"paramName",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Gets an optional string param, returning null if the parameter was not found.
@param params the params
@param paramName the param name
@return the optional string param | [
"Gets",
"an",
"optional",
"string",
"param",
"returning",
"null",
"if",
"the",
"parameter",
"was",
"not",
"found",
"."
] | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/zaproxy/zap/utils/ApiUtils.java#L88-L93 |
sebastiangraf/jSCSI | bundles/commons/src/main/java/org/jscsi/parser/scsi/SCSICommandParser.java | SCSICommandParser.setCommandDescriptorBlock | public final void setCommandDescriptorBlock (final ByteBuffer newCDB) {
"""
Sets the new Command Descriptor Block.
@param newCDB The new Command Descriptor Block.
"""
if (newCDB.limit() - newCDB.position() > CDB_SIZE) { throw new IllegalArgumentException("Buffer cannot be longer than 16 bytes, because AHS-support is not implemented."); }
commandDescriptorBlock = newCDB;
} | java | public final void setCommandDescriptorBlock (final ByteBuffer newCDB) {
if (newCDB.limit() - newCDB.position() > CDB_SIZE) { throw new IllegalArgumentException("Buffer cannot be longer than 16 bytes, because AHS-support is not implemented."); }
commandDescriptorBlock = newCDB;
} | [
"public",
"final",
"void",
"setCommandDescriptorBlock",
"(",
"final",
"ByteBuffer",
"newCDB",
")",
"{",
"if",
"(",
"newCDB",
".",
"limit",
"(",
")",
"-",
"newCDB",
".",
"position",
"(",
")",
">",
"CDB_SIZE",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Buffer cannot be longer than 16 bytes, because AHS-support is not implemented.\"",
")",
";",
"}",
"commandDescriptorBlock",
"=",
"newCDB",
";",
"}"
] | Sets the new Command Descriptor Block.
@param newCDB The new Command Descriptor Block. | [
"Sets",
"the",
"new",
"Command",
"Descriptor",
"Block",
"."
] | train | https://github.com/sebastiangraf/jSCSI/blob/6169bfe73f0b15de7d6485453555389e782ae888/bundles/commons/src/main/java/org/jscsi/parser/scsi/SCSICommandParser.java#L355-L359 |
OpenLiberty/open-liberty | dev/com.ibm.ws.jpa.container.core/src/com/ibm/ws/jpa/management/JPAEMPool.java | JPAEMPool.getEntityManager | public EntityManager getEntityManager(boolean jtaTxExists, boolean unsynchronized) {
"""
Returns an EntityManager instance from the pool, or a newly created
instance if the pool is empty. <p>
If a global JTA transaction is present, the EntityManager will have
joined that transaction. <p>
@param jtaTxExists
true if a global jta transaction exists; otherwise false.
@param unsynchronized
true if SynchronizationType.UNSYNCHRONIZED is requested, false if not.
"""
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
Tr.entry(tc, "getEntityManager : [" + ivPoolSize + "] tx = " +
jtaTxExists + " unsynchronized = " + unsynchronized);
EntityManager em = ivPool.poll();
if (em != null)
{
synchronized (this)
{
--ivPoolSize;
}
if (jtaTxExists && !unsynchronized)
{
em.joinTransaction();
}
}
else
{
// createEntityManager will join transaction if present and is SYNCHRONIZED.
em = ivAbstractJpaComponent.getJPARuntime().createEntityManagerInstance(ivFactory, ivProperties, unsynchronized);
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
Tr.exit(tc, "getEntityManager : [" + ivPoolSize + "] " + em);
return em;
} | java | public EntityManager getEntityManager(boolean jtaTxExists, boolean unsynchronized)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
Tr.entry(tc, "getEntityManager : [" + ivPoolSize + "] tx = " +
jtaTxExists + " unsynchronized = " + unsynchronized);
EntityManager em = ivPool.poll();
if (em != null)
{
synchronized (this)
{
--ivPoolSize;
}
if (jtaTxExists && !unsynchronized)
{
em.joinTransaction();
}
}
else
{
// createEntityManager will join transaction if present and is SYNCHRONIZED.
em = ivAbstractJpaComponent.getJPARuntime().createEntityManagerInstance(ivFactory, ivProperties, unsynchronized);
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
Tr.exit(tc, "getEntityManager : [" + ivPoolSize + "] " + em);
return em;
} | [
"public",
"EntityManager",
"getEntityManager",
"(",
"boolean",
"jtaTxExists",
",",
"boolean",
"unsynchronized",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"entry",
"(",
"tc",
",",
"\"getEntityManager : [\"",
"+",
"ivPoolSize",
"+",
"\"] tx = \"",
"+",
"jtaTxExists",
"+",
"\" unsynchronized = \"",
"+",
"unsynchronized",
")",
";",
"EntityManager",
"em",
"=",
"ivPool",
".",
"poll",
"(",
")",
";",
"if",
"(",
"em",
"!=",
"null",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"--",
"ivPoolSize",
";",
"}",
"if",
"(",
"jtaTxExists",
"&&",
"!",
"unsynchronized",
")",
"{",
"em",
".",
"joinTransaction",
"(",
")",
";",
"}",
"}",
"else",
"{",
"// createEntityManager will join transaction if present and is SYNCHRONIZED.",
"em",
"=",
"ivAbstractJpaComponent",
".",
"getJPARuntime",
"(",
")",
".",
"createEntityManagerInstance",
"(",
"ivFactory",
",",
"ivProperties",
",",
"unsynchronized",
")",
";",
"}",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"exit",
"(",
"tc",
",",
"\"getEntityManager : [\"",
"+",
"ivPoolSize",
"+",
"\"] \"",
"+",
"em",
")",
";",
"return",
"em",
";",
"}"
] | Returns an EntityManager instance from the pool, or a newly created
instance if the pool is empty. <p>
If a global JTA transaction is present, the EntityManager will have
joined that transaction. <p>
@param jtaTxExists
true if a global jta transaction exists; otherwise false.
@param unsynchronized
true if SynchronizationType.UNSYNCHRONIZED is requested, false if not. | [
"Returns",
"an",
"EntityManager",
"instance",
"from",
"the",
"pool",
"or",
"a",
"newly",
"created",
"instance",
"if",
"the",
"pool",
"is",
"empty",
".",
"<p",
">"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jpa.container.core/src/com/ibm/ws/jpa/management/JPAEMPool.java#L133-L162 |
google/gson | gson/src/main/java/com/google/gson/JsonParser.java | JsonParser.parseReader | public static JsonElement parseReader(JsonReader reader)
throws JsonIOException, JsonSyntaxException {
"""
Returns the next value from the JSON stream as a parse tree.
@throws JsonParseException if there is an IOException or if the specified
text is not valid JSON
"""
boolean lenient = reader.isLenient();
reader.setLenient(true);
try {
return Streams.parse(reader);
} catch (StackOverflowError e) {
throw new JsonParseException("Failed parsing JSON source: " + reader + " to Json", e);
} catch (OutOfMemoryError e) {
throw new JsonParseException("Failed parsing JSON source: " + reader + " to Json", e);
} finally {
reader.setLenient(lenient);
}
} | java | public static JsonElement parseReader(JsonReader reader)
throws JsonIOException, JsonSyntaxException {
boolean lenient = reader.isLenient();
reader.setLenient(true);
try {
return Streams.parse(reader);
} catch (StackOverflowError e) {
throw new JsonParseException("Failed parsing JSON source: " + reader + " to Json", e);
} catch (OutOfMemoryError e) {
throw new JsonParseException("Failed parsing JSON source: " + reader + " to Json", e);
} finally {
reader.setLenient(lenient);
}
} | [
"public",
"static",
"JsonElement",
"parseReader",
"(",
"JsonReader",
"reader",
")",
"throws",
"JsonIOException",
",",
"JsonSyntaxException",
"{",
"boolean",
"lenient",
"=",
"reader",
".",
"isLenient",
"(",
")",
";",
"reader",
".",
"setLenient",
"(",
"true",
")",
";",
"try",
"{",
"return",
"Streams",
".",
"parse",
"(",
"reader",
")",
";",
"}",
"catch",
"(",
"StackOverflowError",
"e",
")",
"{",
"throw",
"new",
"JsonParseException",
"(",
"\"Failed parsing JSON source: \"",
"+",
"reader",
"+",
"\" to Json\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"OutOfMemoryError",
"e",
")",
"{",
"throw",
"new",
"JsonParseException",
"(",
"\"Failed parsing JSON source: \"",
"+",
"reader",
"+",
"\" to Json\"",
",",
"e",
")",
";",
"}",
"finally",
"{",
"reader",
".",
"setLenient",
"(",
"lenient",
")",
";",
"}",
"}"
] | Returns the next value from the JSON stream as a parse tree.
@throws JsonParseException if there is an IOException or if the specified
text is not valid JSON | [
"Returns",
"the",
"next",
"value",
"from",
"the",
"JSON",
"stream",
"as",
"a",
"parse",
"tree",
"."
] | train | https://github.com/google/gson/blob/63ee47cb642c8018e5cddd639aa2be143220ad4b/gson/src/main/java/com/google/gson/JsonParser.java#L80-L93 |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/system/exec/Exec.java | Exec.appAs | public static Execed appAs(String as, String... command) throws IOException {
"""
Runs a command, optionally executing as a different user (eg root)
@param as
@param command
@return
@throws IOException
"""
return appAs(as, Arrays.asList(command));
} | java | public static Execed appAs(String as, String... command) throws IOException
{
return appAs(as, Arrays.asList(command));
} | [
"public",
"static",
"Execed",
"appAs",
"(",
"String",
"as",
",",
"String",
"...",
"command",
")",
"throws",
"IOException",
"{",
"return",
"appAs",
"(",
"as",
",",
"Arrays",
".",
"asList",
"(",
"command",
")",
")",
";",
"}"
] | Runs a command, optionally executing as a different user (eg root)
@param as
@param command
@return
@throws IOException | [
"Runs",
"a",
"command",
"optionally",
"executing",
"as",
"a",
"different",
"user",
"(",
"eg",
"root",
")"
] | train | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/system/exec/Exec.java#L389-L392 |
mangstadt/biweekly | src/main/java/biweekly/component/ICalComponent.java | ICalComponent.removeComponents | public <T extends ICalComponent> List<T> removeComponents(Class<T> clazz) {
"""
Removes all sub-components of the given class from this component.
@param clazz the class of the components to remove (e.g. "VEvent.class")
@param <T> the component class
@return the removed components (this list is immutable)
"""
List<ICalComponent> removed = components.removeAll(clazz);
return castList(removed, clazz);
} | java | public <T extends ICalComponent> List<T> removeComponents(Class<T> clazz) {
List<ICalComponent> removed = components.removeAll(clazz);
return castList(removed, clazz);
} | [
"public",
"<",
"T",
"extends",
"ICalComponent",
">",
"List",
"<",
"T",
">",
"removeComponents",
"(",
"Class",
"<",
"T",
">",
"clazz",
")",
"{",
"List",
"<",
"ICalComponent",
">",
"removed",
"=",
"components",
".",
"removeAll",
"(",
"clazz",
")",
";",
"return",
"castList",
"(",
"removed",
",",
"clazz",
")",
";",
"}"
] | Removes all sub-components of the given class from this component.
@param clazz the class of the components to remove (e.g. "VEvent.class")
@param <T> the component class
@return the removed components (this list is immutable) | [
"Removes",
"all",
"sub",
"-",
"components",
"of",
"the",
"given",
"class",
"from",
"this",
"component",
"."
] | train | https://github.com/mangstadt/biweekly/blob/2e21350f85c13dfff52fdef98fdbebe2976fcf61/src/main/java/biweekly/component/ICalComponent.java#L175-L178 |
datumbox/datumbox-framework | datumbox-framework-common/src/main/java/com/datumbox/framework/common/storage/abstracts/AbstractFileStorageEngine.java | AbstractFileStorageEngine.moveDirectory | protected boolean moveDirectory(Path src, Path target) throws IOException {
"""
Moves a directory in the target location.
@param src
@param target
@return
@throws IOException
"""
if(Files.exists(src)) {
createDirectoryIfNotExists(target.getParent());
deleteDirectory(target, false);
Files.move(src, target);
cleanEmptyParentDirectory(src.getParent());
return true;
}
else {
return false;
}
} | java | protected boolean moveDirectory(Path src, Path target) throws IOException {
if(Files.exists(src)) {
createDirectoryIfNotExists(target.getParent());
deleteDirectory(target, false);
Files.move(src, target);
cleanEmptyParentDirectory(src.getParent());
return true;
}
else {
return false;
}
} | [
"protected",
"boolean",
"moveDirectory",
"(",
"Path",
"src",
",",
"Path",
"target",
")",
"throws",
"IOException",
"{",
"if",
"(",
"Files",
".",
"exists",
"(",
"src",
")",
")",
"{",
"createDirectoryIfNotExists",
"(",
"target",
".",
"getParent",
"(",
")",
")",
";",
"deleteDirectory",
"(",
"target",
",",
"false",
")",
";",
"Files",
".",
"move",
"(",
"src",
",",
"target",
")",
";",
"cleanEmptyParentDirectory",
"(",
"src",
".",
"getParent",
"(",
")",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | Moves a directory in the target location.
@param src
@param target
@return
@throws IOException | [
"Moves",
"a",
"directory",
"in",
"the",
"target",
"location",
"."
] | train | https://github.com/datumbox/datumbox-framework/blob/909dff0476e80834f05ecdde0624dd2390e9b0ca/datumbox-framework-common/src/main/java/com/datumbox/framework/common/storage/abstracts/AbstractFileStorageEngine.java#L143-L154 |
LearnLib/automatalib | commons/util/src/main/java/net/automatalib/commons/util/comparison/CmpUtil.java | CmpUtil.lexCompare | public static <U> int lexCompare(Iterable<? extends U> o1, Iterable<? extends U> o2, Comparator<U> elemComparator) {
"""
Lexicographically compares two {@link Iterable}s. Comparison of the elements is done using the specified
comparator.
@param o1
the first iterable.
@param o2
the second iterable.
@param elemComparator
the comparator.
@return <code>< 0</code> iff o1 is lexicographically smaller, <code>0</code> if o1 equals o2 and <code>>
0</code> otherwise.
"""
Iterator<? extends U> it1 = o1.iterator(), it2 = o2.iterator();
while (it1.hasNext() && it2.hasNext()) {
int cmp = elemComparator.compare(it1.next(), it2.next());
if (cmp != 0) {
return cmp;
}
}
if (it1.hasNext()) {
return 1;
} else if (it2.hasNext()) {
return -1;
}
return 0;
} | java | public static <U> int lexCompare(Iterable<? extends U> o1, Iterable<? extends U> o2, Comparator<U> elemComparator) {
Iterator<? extends U> it1 = o1.iterator(), it2 = o2.iterator();
while (it1.hasNext() && it2.hasNext()) {
int cmp = elemComparator.compare(it1.next(), it2.next());
if (cmp != 0) {
return cmp;
}
}
if (it1.hasNext()) {
return 1;
} else if (it2.hasNext()) {
return -1;
}
return 0;
} | [
"public",
"static",
"<",
"U",
">",
"int",
"lexCompare",
"(",
"Iterable",
"<",
"?",
"extends",
"U",
">",
"o1",
",",
"Iterable",
"<",
"?",
"extends",
"U",
">",
"o2",
",",
"Comparator",
"<",
"U",
">",
"elemComparator",
")",
"{",
"Iterator",
"<",
"?",
"extends",
"U",
">",
"it1",
"=",
"o1",
".",
"iterator",
"(",
")",
",",
"it2",
"=",
"o2",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"it1",
".",
"hasNext",
"(",
")",
"&&",
"it2",
".",
"hasNext",
"(",
")",
")",
"{",
"int",
"cmp",
"=",
"elemComparator",
".",
"compare",
"(",
"it1",
".",
"next",
"(",
")",
",",
"it2",
".",
"next",
"(",
")",
")",
";",
"if",
"(",
"cmp",
"!=",
"0",
")",
"{",
"return",
"cmp",
";",
"}",
"}",
"if",
"(",
"it1",
".",
"hasNext",
"(",
")",
")",
"{",
"return",
"1",
";",
"}",
"else",
"if",
"(",
"it2",
".",
"hasNext",
"(",
")",
")",
"{",
"return",
"-",
"1",
";",
"}",
"return",
"0",
";",
"}"
] | Lexicographically compares two {@link Iterable}s. Comparison of the elements is done using the specified
comparator.
@param o1
the first iterable.
@param o2
the second iterable.
@param elemComparator
the comparator.
@return <code>< 0</code> iff o1 is lexicographically smaller, <code>0</code> if o1 equals o2 and <code>>
0</code> otherwise. | [
"Lexicographically",
"compares",
"two",
"{",
"@link",
"Iterable",
"}",
"s",
".",
"Comparison",
"of",
"the",
"elements",
"is",
"done",
"using",
"the",
"specified",
"comparator",
"."
] | train | https://github.com/LearnLib/automatalib/blob/8a462ec52f6eaab9f8996e344f2163a72cb8aa6e/commons/util/src/main/java/net/automatalib/commons/util/comparison/CmpUtil.java#L103-L119 |
JOML-CI/JOML | src/org/joml/Intersectiond.java | Intersectiond.intersectRayCircle | public static boolean intersectRayCircle(Vector2dc origin, Vector2dc dir, Vector2dc center, double radiusSquared, Vector2d result) {
"""
Test whether the ray with the given <code>origin</code> and direction <code>dir</code>
intersects the circle with the given <code>center</code> and square radius <code>radiusSquared</code>,
and store the values of the parameter <i>t</i> in the ray equation <i>p(t) = origin + t * dir</i> for both points (near
and far) of intersections into the given <code>result</code> vector.
<p>
This method returns <code>true</code> for a ray whose origin lies inside the circle.
<p>
Reference: <a href="http://www.scratchapixel.com/lessons/3d-basic-rendering/minimal-ray-tracer-rendering-simple-shapes/ray-sphere-intersection">http://www.scratchapixel.com/</a>
@param origin
the ray's origin
@param dir
the ray's direction
@param center
the circle's center
@param radiusSquared
the circle radius squared
@param result
a vector that will contain the values of the parameter <i>t</i> in the ray equation
<i>p(t) = origin + t * dir</i> for both points (near, far) of intersections with the circle
@return <code>true</code> if the ray intersects the circle; <code>false</code> otherwise
"""
return intersectRayCircle(origin.x(), origin.y(), dir.x(), dir.y(), center.x(), center.y(), radiusSquared, result);
} | java | public static boolean intersectRayCircle(Vector2dc origin, Vector2dc dir, Vector2dc center, double radiusSquared, Vector2d result) {
return intersectRayCircle(origin.x(), origin.y(), dir.x(), dir.y(), center.x(), center.y(), radiusSquared, result);
} | [
"public",
"static",
"boolean",
"intersectRayCircle",
"(",
"Vector2dc",
"origin",
",",
"Vector2dc",
"dir",
",",
"Vector2dc",
"center",
",",
"double",
"radiusSquared",
",",
"Vector2d",
"result",
")",
"{",
"return",
"intersectRayCircle",
"(",
"origin",
".",
"x",
"(",
")",
",",
"origin",
".",
"y",
"(",
")",
",",
"dir",
".",
"x",
"(",
")",
",",
"dir",
".",
"y",
"(",
")",
",",
"center",
".",
"x",
"(",
")",
",",
"center",
".",
"y",
"(",
")",
",",
"radiusSquared",
",",
"result",
")",
";",
"}"
] | Test whether the ray with the given <code>origin</code> and direction <code>dir</code>
intersects the circle with the given <code>center</code> and square radius <code>radiusSquared</code>,
and store the values of the parameter <i>t</i> in the ray equation <i>p(t) = origin + t * dir</i> for both points (near
and far) of intersections into the given <code>result</code> vector.
<p>
This method returns <code>true</code> for a ray whose origin lies inside the circle.
<p>
Reference: <a href="http://www.scratchapixel.com/lessons/3d-basic-rendering/minimal-ray-tracer-rendering-simple-shapes/ray-sphere-intersection">http://www.scratchapixel.com/</a>
@param origin
the ray's origin
@param dir
the ray's direction
@param center
the circle's center
@param radiusSquared
the circle radius squared
@param result
a vector that will contain the values of the parameter <i>t</i> in the ray equation
<i>p(t) = origin + t * dir</i> for both points (near, far) of intersections with the circle
@return <code>true</code> if the ray intersects the circle; <code>false</code> otherwise | [
"Test",
"whether",
"the",
"ray",
"with",
"the",
"given",
"<code",
">",
"origin<",
"/",
"code",
">",
"and",
"direction",
"<code",
">",
"dir<",
"/",
"code",
">",
"intersects",
"the",
"circle",
"with",
"the",
"given",
"<code",
">",
"center<",
"/",
"code",
">",
"and",
"square",
"radius",
"<code",
">",
"radiusSquared<",
"/",
"code",
">",
"and",
"store",
"the",
"values",
"of",
"the",
"parameter",
"<i",
">",
"t<",
"/",
"i",
">",
"in",
"the",
"ray",
"equation",
"<i",
">",
"p",
"(",
"t",
")",
"=",
"origin",
"+",
"t",
"*",
"dir<",
"/",
"i",
">",
"for",
"both",
"points",
"(",
"near",
"and",
"far",
")",
"of",
"intersections",
"into",
"the",
"given",
"<code",
">",
"result<",
"/",
"code",
">",
"vector",
".",
"<p",
">",
"This",
"method",
"returns",
"<code",
">",
"true<",
"/",
"code",
">",
"for",
"a",
"ray",
"whose",
"origin",
"lies",
"inside",
"the",
"circle",
".",
"<p",
">",
"Reference",
":",
"<a",
"href",
"=",
"http",
":",
"//",
"www",
".",
"scratchapixel",
".",
"com",
"/",
"lessons",
"/",
"3d",
"-",
"basic",
"-",
"rendering",
"/",
"minimal",
"-",
"ray",
"-",
"tracer",
"-",
"rendering",
"-",
"simple",
"-",
"shapes",
"/",
"ray",
"-",
"sphere",
"-",
"intersection",
">",
"http",
":",
"//",
"www",
".",
"scratchapixel",
".",
"com",
"/",
"<",
"/",
"a",
">"
] | train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Intersectiond.java#L4267-L4269 |
haifengl/smile | nlp/src/main/java/smile/nlp/collocation/BigramCollocationFinder.java | BigramCollocationFinder.likelihoodRatio | private double likelihoodRatio(int c1, int c2, int c12, long N) {
"""
Returns the likelihood ratio test statistic -2 log λ
@param c1 the number of occurrences of w1.
@param c2 the number of occurrences of w2.
@param c12 the number of occurrences of w1 w2.
@param N the number of tokens in the corpus.
"""
double p = (double) c2 / N;
double p1 = (double) c12 / c1;
double p2 = (double) (c2 - c12) / (N - c1);
double logLambda = logL(c12, c1, p) + logL(c2-c12, N-c1, p) - logL(c12, c1, p1) - logL(c2-c12, N-c1, p2);
return -2 * logLambda;
} | java | private double likelihoodRatio(int c1, int c2, int c12, long N) {
double p = (double) c2 / N;
double p1 = (double) c12 / c1;
double p2 = (double) (c2 - c12) / (N - c1);
double logLambda = logL(c12, c1, p) + logL(c2-c12, N-c1, p) - logL(c12, c1, p1) - logL(c2-c12, N-c1, p2);
return -2 * logLambda;
} | [
"private",
"double",
"likelihoodRatio",
"(",
"int",
"c1",
",",
"int",
"c2",
",",
"int",
"c12",
",",
"long",
"N",
")",
"{",
"double",
"p",
"=",
"(",
"double",
")",
"c2",
"/",
"N",
";",
"double",
"p1",
"=",
"(",
"double",
")",
"c12",
"/",
"c1",
";",
"double",
"p2",
"=",
"(",
"double",
")",
"(",
"c2",
"-",
"c12",
")",
"/",
"(",
"N",
"-",
"c1",
")",
";",
"double",
"logLambda",
"=",
"logL",
"(",
"c12",
",",
"c1",
",",
"p",
")",
"+",
"logL",
"(",
"c2",
"-",
"c12",
",",
"N",
"-",
"c1",
",",
"p",
")",
"-",
"logL",
"(",
"c12",
",",
"c1",
",",
"p1",
")",
"-",
"logL",
"(",
"c2",
"-",
"c12",
",",
"N",
"-",
"c1",
",",
"p2",
")",
";",
"return",
"-",
"2",
"*",
"logLambda",
";",
"}"
] | Returns the likelihood ratio test statistic -2 log λ
@param c1 the number of occurrences of w1.
@param c2 the number of occurrences of w2.
@param c12 the number of occurrences of w1 w2.
@param N the number of tokens in the corpus. | [
"Returns",
"the",
"likelihood",
"ratio",
"test",
"statistic",
"-",
"2",
"log",
"&lambda",
";"
] | train | https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/nlp/src/main/java/smile/nlp/collocation/BigramCollocationFinder.java#L151-L158 |
mgledi/DRUMS | src/main/java/com/unister/semweb/drums/storable/GeneralStorable.java | GeneralStorable.setKey | public void setKey(int index, byte[] key) throws IOException {
"""
Sets the key belonging to the given field.
@param index
the index of the requested field
@param key
the key to set
@throws IOException
"""
if (index >= structure.keySizes.size()) {
throw new IOException("Index " + index + " is out of range.");
}
int length = structure.keySizes.get(index);
if (key.length != length) {
throw new IOException("The length of the given key is not equal to the expected one. (" + key.length
+ "!=" + length + ")");
}
Bytes.putBytes(this.key, structure.keyByteOffsets.get(index), key, 0, key.length);
} | java | public void setKey(int index, byte[] key) throws IOException {
if (index >= structure.keySizes.size()) {
throw new IOException("Index " + index + " is out of range.");
}
int length = structure.keySizes.get(index);
if (key.length != length) {
throw new IOException("The length of the given key is not equal to the expected one. (" + key.length
+ "!=" + length + ")");
}
Bytes.putBytes(this.key, structure.keyByteOffsets.get(index), key, 0, key.length);
} | [
"public",
"void",
"setKey",
"(",
"int",
"index",
",",
"byte",
"[",
"]",
"key",
")",
"throws",
"IOException",
"{",
"if",
"(",
"index",
">=",
"structure",
".",
"keySizes",
".",
"size",
"(",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Index \"",
"+",
"index",
"+",
"\" is out of range.\"",
")",
";",
"}",
"int",
"length",
"=",
"structure",
".",
"keySizes",
".",
"get",
"(",
"index",
")",
";",
"if",
"(",
"key",
".",
"length",
"!=",
"length",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"The length of the given key is not equal to the expected one. (\"",
"+",
"key",
".",
"length",
"+",
"\"!=\"",
"+",
"length",
"+",
"\")\"",
")",
";",
"}",
"Bytes",
".",
"putBytes",
"(",
"this",
".",
"key",
",",
"structure",
".",
"keyByteOffsets",
".",
"get",
"(",
"index",
")",
",",
"key",
",",
"0",
",",
"key",
".",
"length",
")",
";",
"}"
] | Sets the key belonging to the given field.
@param index
the index of the requested field
@param key
the key to set
@throws IOException | [
"Sets",
"the",
"key",
"belonging",
"to",
"the",
"given",
"field",
"."
] | train | https://github.com/mgledi/DRUMS/blob/a670f17a2186c9a15725f26617d77ce8e444e072/src/main/java/com/unister/semweb/drums/storable/GeneralStorable.java#L537-L547 |
gmessner/gitlab4j-api | src/main/java/org/gitlab4j/api/IssuesApi.java | IssuesApi.deleteIssue | public void deleteIssue(Object projectIdOrPath, Integer issueIid) throws GitLabApiException {
"""
Delete an issue.
<pre><code>GitLab Endpoint: DELETE /projects/:id/issues/:issue_iid</code></pre>
@param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance, required
@param issueIid the internal ID of a project's issue
@throws GitLabApiException if any exception occurs
"""
if (issueIid == null) {
throw new RuntimeException("issue IID cannot be null");
}
Response.Status expectedStatus = (isApiVersion(ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT);
delete(expectedStatus, getDefaultPerPageParam(), "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid);
} | java | public void deleteIssue(Object projectIdOrPath, Integer issueIid) throws GitLabApiException {
if (issueIid == null) {
throw new RuntimeException("issue IID cannot be null");
}
Response.Status expectedStatus = (isApiVersion(ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT);
delete(expectedStatus, getDefaultPerPageParam(), "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid);
} | [
"public",
"void",
"deleteIssue",
"(",
"Object",
"projectIdOrPath",
",",
"Integer",
"issueIid",
")",
"throws",
"GitLabApiException",
"{",
"if",
"(",
"issueIid",
"==",
"null",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"issue IID cannot be null\"",
")",
";",
"}",
"Response",
".",
"Status",
"expectedStatus",
"=",
"(",
"isApiVersion",
"(",
"ApiVersion",
".",
"V3",
")",
"?",
"Response",
".",
"Status",
".",
"OK",
":",
"Response",
".",
"Status",
".",
"NO_CONTENT",
")",
";",
"delete",
"(",
"expectedStatus",
",",
"getDefaultPerPageParam",
"(",
")",
",",
"\"projects\"",
",",
"getProjectIdOrPath",
"(",
"projectIdOrPath",
")",
",",
"\"issues\"",
",",
"issueIid",
")",
";",
"}"
] | Delete an issue.
<pre><code>GitLab Endpoint: DELETE /projects/:id/issues/:issue_iid</code></pre>
@param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance, required
@param issueIid the internal ID of a project's issue
@throws GitLabApiException if any exception occurs | [
"Delete",
"an",
"issue",
"."
] | train | https://github.com/gmessner/gitlab4j-api/blob/ab045070abac0a8f4ccbf17b5ed9bfdef5723eed/src/main/java/org/gitlab4j/api/IssuesApi.java#L440-L448 |
aws/aws-sdk-java | aws-java-sdk-apigatewayv2/src/main/java/com/amazonaws/services/apigatewayv2/model/GetRouteResponseResult.java | GetRouteResponseResult.withResponseModels | public GetRouteResponseResult withResponseModels(java.util.Map<String, String> responseModels) {
"""
<p>
Represents the response models of a route response.
</p>
@param responseModels
Represents the response models of a route response.
@return Returns a reference to this object so that method calls can be chained together.
"""
setResponseModels(responseModels);
return this;
} | java | public GetRouteResponseResult withResponseModels(java.util.Map<String, String> responseModels) {
setResponseModels(responseModels);
return this;
} | [
"public",
"GetRouteResponseResult",
"withResponseModels",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"responseModels",
")",
"{",
"setResponseModels",
"(",
"responseModels",
")",
";",
"return",
"this",
";",
"}"
] | <p>
Represents the response models of a route response.
</p>
@param responseModels
Represents the response models of a route response.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"Represents",
"the",
"response",
"models",
"of",
"a",
"route",
"response",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-apigatewayv2/src/main/java/com/amazonaws/services/apigatewayv2/model/GetRouteResponseResult.java#L127-L130 |
apache/flink | flink-streaming-java/src/main/java/org/apache/flink/streaming/api/datastream/DataStreamUtils.java | DataStreamUtils.collect | public static <OUT> Iterator<OUT> collect(DataStream<OUT> stream) throws IOException {
"""
Returns an iterator to iterate over the elements of the DataStream.
@return The iterator
"""
TypeSerializer<OUT> serializer = stream.getType().createSerializer(
stream.getExecutionEnvironment().getConfig());
SocketStreamIterator<OUT> iter = new SocketStreamIterator<OUT>(serializer);
//Find out what IP of us should be given to CollectSink, that it will be able to connect to
StreamExecutionEnvironment env = stream.getExecutionEnvironment();
InetAddress clientAddress;
if (env instanceof RemoteStreamEnvironment) {
String host = ((RemoteStreamEnvironment) env).getHost();
int port = ((RemoteStreamEnvironment) env).getPort();
try {
clientAddress = ConnectionUtils.findConnectingAddress(new InetSocketAddress(host, port), 2000, 400);
}
catch (Exception e) {
throw new IOException("Could not determine an suitable network address to " +
"receive back data from the streaming program.", e);
}
} else if (env instanceof LocalStreamEnvironment) {
clientAddress = InetAddress.getLoopbackAddress();
} else {
try {
clientAddress = InetAddress.getLocalHost();
} catch (UnknownHostException e) {
throw new IOException("Could not determine this machines own local address to " +
"receive back data from the streaming program.", e);
}
}
DataStreamSink<OUT> sink = stream.addSink(new CollectSink<OUT>(clientAddress, iter.getPort(), serializer));
sink.setParallelism(1); // It would not work if multiple instances would connect to the same port
(new CallExecute(env, iter)).start();
return iter;
} | java | public static <OUT> Iterator<OUT> collect(DataStream<OUT> stream) throws IOException {
TypeSerializer<OUT> serializer = stream.getType().createSerializer(
stream.getExecutionEnvironment().getConfig());
SocketStreamIterator<OUT> iter = new SocketStreamIterator<OUT>(serializer);
//Find out what IP of us should be given to CollectSink, that it will be able to connect to
StreamExecutionEnvironment env = stream.getExecutionEnvironment();
InetAddress clientAddress;
if (env instanceof RemoteStreamEnvironment) {
String host = ((RemoteStreamEnvironment) env).getHost();
int port = ((RemoteStreamEnvironment) env).getPort();
try {
clientAddress = ConnectionUtils.findConnectingAddress(new InetSocketAddress(host, port), 2000, 400);
}
catch (Exception e) {
throw new IOException("Could not determine an suitable network address to " +
"receive back data from the streaming program.", e);
}
} else if (env instanceof LocalStreamEnvironment) {
clientAddress = InetAddress.getLoopbackAddress();
} else {
try {
clientAddress = InetAddress.getLocalHost();
} catch (UnknownHostException e) {
throw new IOException("Could not determine this machines own local address to " +
"receive back data from the streaming program.", e);
}
}
DataStreamSink<OUT> sink = stream.addSink(new CollectSink<OUT>(clientAddress, iter.getPort(), serializer));
sink.setParallelism(1); // It would not work if multiple instances would connect to the same port
(new CallExecute(env, iter)).start();
return iter;
} | [
"public",
"static",
"<",
"OUT",
">",
"Iterator",
"<",
"OUT",
">",
"collect",
"(",
"DataStream",
"<",
"OUT",
">",
"stream",
")",
"throws",
"IOException",
"{",
"TypeSerializer",
"<",
"OUT",
">",
"serializer",
"=",
"stream",
".",
"getType",
"(",
")",
".",
"createSerializer",
"(",
"stream",
".",
"getExecutionEnvironment",
"(",
")",
".",
"getConfig",
"(",
")",
")",
";",
"SocketStreamIterator",
"<",
"OUT",
">",
"iter",
"=",
"new",
"SocketStreamIterator",
"<",
"OUT",
">",
"(",
"serializer",
")",
";",
"//Find out what IP of us should be given to CollectSink, that it will be able to connect to",
"StreamExecutionEnvironment",
"env",
"=",
"stream",
".",
"getExecutionEnvironment",
"(",
")",
";",
"InetAddress",
"clientAddress",
";",
"if",
"(",
"env",
"instanceof",
"RemoteStreamEnvironment",
")",
"{",
"String",
"host",
"=",
"(",
"(",
"RemoteStreamEnvironment",
")",
"env",
")",
".",
"getHost",
"(",
")",
";",
"int",
"port",
"=",
"(",
"(",
"RemoteStreamEnvironment",
")",
"env",
")",
".",
"getPort",
"(",
")",
";",
"try",
"{",
"clientAddress",
"=",
"ConnectionUtils",
".",
"findConnectingAddress",
"(",
"new",
"InetSocketAddress",
"(",
"host",
",",
"port",
")",
",",
"2000",
",",
"400",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Could not determine an suitable network address to \"",
"+",
"\"receive back data from the streaming program.\"",
",",
"e",
")",
";",
"}",
"}",
"else",
"if",
"(",
"env",
"instanceof",
"LocalStreamEnvironment",
")",
"{",
"clientAddress",
"=",
"InetAddress",
".",
"getLoopbackAddress",
"(",
")",
";",
"}",
"else",
"{",
"try",
"{",
"clientAddress",
"=",
"InetAddress",
".",
"getLocalHost",
"(",
")",
";",
"}",
"catch",
"(",
"UnknownHostException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Could not determine this machines own local address to \"",
"+",
"\"receive back data from the streaming program.\"",
",",
"e",
")",
";",
"}",
"}",
"DataStreamSink",
"<",
"OUT",
">",
"sink",
"=",
"stream",
".",
"addSink",
"(",
"new",
"CollectSink",
"<",
"OUT",
">",
"(",
"clientAddress",
",",
"iter",
".",
"getPort",
"(",
")",
",",
"serializer",
")",
")",
";",
"sink",
".",
"setParallelism",
"(",
"1",
")",
";",
"// It would not work if multiple instances would connect to the same port",
"(",
"new",
"CallExecute",
"(",
"env",
",",
"iter",
")",
")",
".",
"start",
"(",
")",
";",
"return",
"iter",
";",
"}"
] | Returns an iterator to iterate over the elements of the DataStream.
@return The iterator | [
"Returns",
"an",
"iterator",
"to",
"iterate",
"over",
"the",
"elements",
"of",
"the",
"DataStream",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/datastream/DataStreamUtils.java#L50-L88 |
google/error-prone | core/src/main/java/com/google/errorprone/bugpatterns/WildcardImport.java | WildcardImport.qualifiedNameFix | private static void qualifiedNameFix(
final SuggestedFix.Builder fix, final Symbol owner, VisitorState state) {
"""
Add an import for {@code owner}, and qualify all on demand imported references to members of
owner by owner's simple name.
"""
fix.addImport(owner.getQualifiedName().toString());
final JCCompilationUnit unit = (JCCompilationUnit) state.getPath().getCompilationUnit();
new TreePathScanner<Void, Void>() {
@Override
public Void visitIdentifier(IdentifierTree tree, Void unused) {
Symbol sym = ASTHelpers.getSymbol(tree);
if (sym == null) {
return null;
}
Tree parent = getCurrentPath().getParentPath().getLeaf();
if (parent.getKind() == Tree.Kind.CASE
&& ((CaseTree) parent).getExpression().equals(tree)
&& sym.owner.getKind() == ElementKind.ENUM) {
// switch cases can refer to enum constants by simple name without importing them
return null;
}
if (sym.owner.equals(owner) && unit.starImportScope.includes(sym)) {
fix.prefixWith(tree, owner.getSimpleName() + ".");
}
return null;
}
}.scan(unit, null);
} | java | private static void qualifiedNameFix(
final SuggestedFix.Builder fix, final Symbol owner, VisitorState state) {
fix.addImport(owner.getQualifiedName().toString());
final JCCompilationUnit unit = (JCCompilationUnit) state.getPath().getCompilationUnit();
new TreePathScanner<Void, Void>() {
@Override
public Void visitIdentifier(IdentifierTree tree, Void unused) {
Symbol sym = ASTHelpers.getSymbol(tree);
if (sym == null) {
return null;
}
Tree parent = getCurrentPath().getParentPath().getLeaf();
if (parent.getKind() == Tree.Kind.CASE
&& ((CaseTree) parent).getExpression().equals(tree)
&& sym.owner.getKind() == ElementKind.ENUM) {
// switch cases can refer to enum constants by simple name without importing them
return null;
}
if (sym.owner.equals(owner) && unit.starImportScope.includes(sym)) {
fix.prefixWith(tree, owner.getSimpleName() + ".");
}
return null;
}
}.scan(unit, null);
} | [
"private",
"static",
"void",
"qualifiedNameFix",
"(",
"final",
"SuggestedFix",
".",
"Builder",
"fix",
",",
"final",
"Symbol",
"owner",
",",
"VisitorState",
"state",
")",
"{",
"fix",
".",
"addImport",
"(",
"owner",
".",
"getQualifiedName",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"final",
"JCCompilationUnit",
"unit",
"=",
"(",
"JCCompilationUnit",
")",
"state",
".",
"getPath",
"(",
")",
".",
"getCompilationUnit",
"(",
")",
";",
"new",
"TreePathScanner",
"<",
"Void",
",",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"visitIdentifier",
"(",
"IdentifierTree",
"tree",
",",
"Void",
"unused",
")",
"{",
"Symbol",
"sym",
"=",
"ASTHelpers",
".",
"getSymbol",
"(",
"tree",
")",
";",
"if",
"(",
"sym",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"Tree",
"parent",
"=",
"getCurrentPath",
"(",
")",
".",
"getParentPath",
"(",
")",
".",
"getLeaf",
"(",
")",
";",
"if",
"(",
"parent",
".",
"getKind",
"(",
")",
"==",
"Tree",
".",
"Kind",
".",
"CASE",
"&&",
"(",
"(",
"CaseTree",
")",
"parent",
")",
".",
"getExpression",
"(",
")",
".",
"equals",
"(",
"tree",
")",
"&&",
"sym",
".",
"owner",
".",
"getKind",
"(",
")",
"==",
"ElementKind",
".",
"ENUM",
")",
"{",
"// switch cases can refer to enum constants by simple name without importing them",
"return",
"null",
";",
"}",
"if",
"(",
"sym",
".",
"owner",
".",
"equals",
"(",
"owner",
")",
"&&",
"unit",
".",
"starImportScope",
".",
"includes",
"(",
"sym",
")",
")",
"{",
"fix",
".",
"prefixWith",
"(",
"tree",
",",
"owner",
".",
"getSimpleName",
"(",
")",
"+",
"\".\"",
")",
";",
"}",
"return",
"null",
";",
"}",
"}",
".",
"scan",
"(",
"unit",
",",
"null",
")",
";",
"}"
] | Add an import for {@code owner}, and qualify all on demand imported references to members of
owner by owner's simple name. | [
"Add",
"an",
"import",
"for",
"{"
] | train | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/WildcardImport.java#L222-L246 |
WiQuery/wiquery | wiquery-jquery-ui/src/main/java/org/odlabs/wiquery/ui/tabs/Tabs.java | Tabs.setAjaxActivateEvent | public Tabs setAjaxActivateEvent(ITabsAjaxEvent activateEvent) {
"""
Sets the call-back for the AJAX activate event.
@param activateEvent
The ITabsAjaxEvent.
"""
this.ajaxEvents.put(TabEvent.activate, activateEvent);
setActivateEvent(new TabsAjaxJsScopeUiEvent(this, TabEvent.activate));
return this;
} | java | public Tabs setAjaxActivateEvent(ITabsAjaxEvent activateEvent)
{
this.ajaxEvents.put(TabEvent.activate, activateEvent);
setActivateEvent(new TabsAjaxJsScopeUiEvent(this, TabEvent.activate));
return this;
} | [
"public",
"Tabs",
"setAjaxActivateEvent",
"(",
"ITabsAjaxEvent",
"activateEvent",
")",
"{",
"this",
".",
"ajaxEvents",
".",
"put",
"(",
"TabEvent",
".",
"activate",
",",
"activateEvent",
")",
";",
"setActivateEvent",
"(",
"new",
"TabsAjaxJsScopeUiEvent",
"(",
"this",
",",
"TabEvent",
".",
"activate",
")",
")",
";",
"return",
"this",
";",
"}"
] | Sets the call-back for the AJAX activate event.
@param activateEvent
The ITabsAjaxEvent. | [
"Sets",
"the",
"call",
"-",
"back",
"for",
"the",
"AJAX",
"activate",
"event",
"."
] | train | https://github.com/WiQuery/wiquery/blob/1b8d60c7a3c37b90fd68c9cd0ff97178fcbcbb08/wiquery-jquery-ui/src/main/java/org/odlabs/wiquery/ui/tabs/Tabs.java#L654-L659 |
qatools/properties | src/main/java/ru/qatools/properties/PropertyLoader.java | PropertyLoader.setValueToField | protected void setValueToField(Field field, Object bean, Object value) {
"""
Set given value to specified field of given object.
@throws PropertyLoaderException if some exceptions occurs during reflection calls.
@see Field#setAccessible(boolean)
@see Field#set(Object, Object)
"""
try {
field.setAccessible(true);
field.set(bean, value);
} catch (Exception e) {
throw new PropertyLoaderException(
String.format("Can not set bean <%s> field <%s> value", bean, field), e
);
}
} | java | protected void setValueToField(Field field, Object bean, Object value) {
try {
field.setAccessible(true);
field.set(bean, value);
} catch (Exception e) {
throw new PropertyLoaderException(
String.format("Can not set bean <%s> field <%s> value", bean, field), e
);
}
} | [
"protected",
"void",
"setValueToField",
"(",
"Field",
"field",
",",
"Object",
"bean",
",",
"Object",
"value",
")",
"{",
"try",
"{",
"field",
".",
"setAccessible",
"(",
"true",
")",
";",
"field",
".",
"set",
"(",
"bean",
",",
"value",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"PropertyLoaderException",
"(",
"String",
".",
"format",
"(",
"\"Can not set bean <%s> field <%s> value\"",
",",
"bean",
",",
"field",
")",
",",
"e",
")",
";",
"}",
"}"
] | Set given value to specified field of given object.
@throws PropertyLoaderException if some exceptions occurs during reflection calls.
@see Field#setAccessible(boolean)
@see Field#set(Object, Object) | [
"Set",
"given",
"value",
"to",
"specified",
"field",
"of",
"given",
"object",
"."
] | train | https://github.com/qatools/properties/blob/ae50b460a6bb4fcb21afe888b2e86a7613cd2115/src/main/java/ru/qatools/properties/PropertyLoader.java#L104-L113 |
Azure/azure-sdk-for-java | resources/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/resources/v2016_09_01/implementation/ResourceGroupsInner.java | ResourceGroupsInner.listAsync | public Observable<Page<ResourceGroupInner>> listAsync(final String filter, final Integer top) {
"""
Gets all the resource groups for a subscription.
@param filter The filter to apply on the operation.
@param top The number of results to return. If null is passed, returns all resource groups.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<ResourceGroupInner> object
"""
return listWithServiceResponseAsync(filter, top)
.map(new Func1<ServiceResponse<Page<ResourceGroupInner>>, Page<ResourceGroupInner>>() {
@Override
public Page<ResourceGroupInner> call(ServiceResponse<Page<ResourceGroupInner>> response) {
return response.body();
}
});
} | java | public Observable<Page<ResourceGroupInner>> listAsync(final String filter, final Integer top) {
return listWithServiceResponseAsync(filter, top)
.map(new Func1<ServiceResponse<Page<ResourceGroupInner>>, Page<ResourceGroupInner>>() {
@Override
public Page<ResourceGroupInner> call(ServiceResponse<Page<ResourceGroupInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Page",
"<",
"ResourceGroupInner",
">",
">",
"listAsync",
"(",
"final",
"String",
"filter",
",",
"final",
"Integer",
"top",
")",
"{",
"return",
"listWithServiceResponseAsync",
"(",
"filter",
",",
"top",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"ResourceGroupInner",
">",
">",
",",
"Page",
"<",
"ResourceGroupInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Page",
"<",
"ResourceGroupInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"Page",
"<",
"ResourceGroupInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Gets all the resource groups for a subscription.
@param filter The filter to apply on the operation.
@param top The number of results to return. If null is passed, returns all resource groups.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<ResourceGroupInner> object | [
"Gets",
"all",
"the",
"resource",
"groups",
"for",
"a",
"subscription",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/resources/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/resources/v2016_09_01/implementation/ResourceGroupsInner.java#L1079-L1087 |
ngageoint/geopackage-core-java | src/main/java/mil/nga/geopackage/tiles/user/TileDaoUtils.java | TileDaoUtils.getMaxLength | public static double getMaxLength(double[] widths, double[] heights) {
"""
Get the max distance length that matches the tile widths and heights
@param widths
sorted tile matrix widths
@param heights
sorted tile matrix heights
@return max length
@since 1.2.0
"""
double maxWidth = getMaxLength(widths);
double maxHeight = getMaxLength(heights);
double maxLength = Math.min(maxWidth, maxHeight);
return maxLength;
} | java | public static double getMaxLength(double[] widths, double[] heights) {
double maxWidth = getMaxLength(widths);
double maxHeight = getMaxLength(heights);
double maxLength = Math.min(maxWidth, maxHeight);
return maxLength;
} | [
"public",
"static",
"double",
"getMaxLength",
"(",
"double",
"[",
"]",
"widths",
",",
"double",
"[",
"]",
"heights",
")",
"{",
"double",
"maxWidth",
"=",
"getMaxLength",
"(",
"widths",
")",
";",
"double",
"maxHeight",
"=",
"getMaxLength",
"(",
"heights",
")",
";",
"double",
"maxLength",
"=",
"Math",
".",
"min",
"(",
"maxWidth",
",",
"maxHeight",
")",
";",
"return",
"maxLength",
";",
"}"
] | Get the max distance length that matches the tile widths and heights
@param widths
sorted tile matrix widths
@param heights
sorted tile matrix heights
@return max length
@since 1.2.0 | [
"Get",
"the",
"max",
"distance",
"length",
"that",
"matches",
"the",
"tile",
"widths",
"and",
"heights"
] | train | https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/tiles/user/TileDaoUtils.java#L415-L420 |
jbossws/jbossws-cxf | modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/BeanCustomizer.java | BeanCustomizer.configureClientProxyFactoryBean | protected void configureClientProxyFactoryBean(ClientProxyFactoryBean factory) {
"""
Configure the client proxy factory; currently set the binding customization in the databinding (Client Side).
@param factory
"""
//Configure binding customization
if (customization != null)
{
//customize default databinding (early pulls in ServiceFactory default databinding and configure it, as it's lazily loaded)
ReflectionServiceFactoryBean serviceFactory = factory.getServiceFactory();
serviceFactory.reset();
DataBinding serviceFactoryDataBinding = serviceFactory.getDataBinding(true);
configureBindingCustomization(serviceFactoryDataBinding, customization);
serviceFactory.setDataBinding(serviceFactoryDataBinding);
//customize user provided databinding (CXF later overrides the ServiceFactory databinding using the user provided one)
if (factory.getDataBinding() == null)
{
//set the endpoint factory's databinding to prevent CXF resetting everything because user did not provide anything
factory.setDataBinding(serviceFactoryDataBinding);
}
else
{
configureBindingCustomization(factory.getDataBinding(), customization);
}
}
//add other configurations here below
} | java | protected void configureClientProxyFactoryBean(ClientProxyFactoryBean factory)
{
//Configure binding customization
if (customization != null)
{
//customize default databinding (early pulls in ServiceFactory default databinding and configure it, as it's lazily loaded)
ReflectionServiceFactoryBean serviceFactory = factory.getServiceFactory();
serviceFactory.reset();
DataBinding serviceFactoryDataBinding = serviceFactory.getDataBinding(true);
configureBindingCustomization(serviceFactoryDataBinding, customization);
serviceFactory.setDataBinding(serviceFactoryDataBinding);
//customize user provided databinding (CXF later overrides the ServiceFactory databinding using the user provided one)
if (factory.getDataBinding() == null)
{
//set the endpoint factory's databinding to prevent CXF resetting everything because user did not provide anything
factory.setDataBinding(serviceFactoryDataBinding);
}
else
{
configureBindingCustomization(factory.getDataBinding(), customization);
}
}
//add other configurations here below
} | [
"protected",
"void",
"configureClientProxyFactoryBean",
"(",
"ClientProxyFactoryBean",
"factory",
")",
"{",
"//Configure binding customization",
"if",
"(",
"customization",
"!=",
"null",
")",
"{",
"//customize default databinding (early pulls in ServiceFactory default databinding and configure it, as it's lazily loaded)",
"ReflectionServiceFactoryBean",
"serviceFactory",
"=",
"factory",
".",
"getServiceFactory",
"(",
")",
";",
"serviceFactory",
".",
"reset",
"(",
")",
";",
"DataBinding",
"serviceFactoryDataBinding",
"=",
"serviceFactory",
".",
"getDataBinding",
"(",
"true",
")",
";",
"configureBindingCustomization",
"(",
"serviceFactoryDataBinding",
",",
"customization",
")",
";",
"serviceFactory",
".",
"setDataBinding",
"(",
"serviceFactoryDataBinding",
")",
";",
"//customize user provided databinding (CXF later overrides the ServiceFactory databinding using the user provided one) ",
"if",
"(",
"factory",
".",
"getDataBinding",
"(",
")",
"==",
"null",
")",
"{",
"//set the endpoint factory's databinding to prevent CXF resetting everything because user did not provide anything",
"factory",
".",
"setDataBinding",
"(",
"serviceFactoryDataBinding",
")",
";",
"}",
"else",
"{",
"configureBindingCustomization",
"(",
"factory",
".",
"getDataBinding",
"(",
")",
",",
"customization",
")",
";",
"}",
"}",
"//add other configurations here below",
"}"
] | Configure the client proxy factory; currently set the binding customization in the databinding (Client Side).
@param factory | [
"Configure",
"the",
"client",
"proxy",
"factory",
";",
"currently",
"set",
"the",
"binding",
"customization",
"in",
"the",
"databinding",
"(",
"Client",
"Side",
")",
"."
] | train | https://github.com/jbossws/jbossws-cxf/blob/e1d5df3664cbc2482ebc83cafd355a4d60d12150/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/BeanCustomizer.java#L89-L112 |
threerings/narya | tools/src/main/java/com/threerings/presents/tools/InvocationTask.java | InvocationTask.createAndGatherImports | public ServiceMethod createAndGatherImports (Method method, ImportSet imports) {
"""
Creates a new service method and adds its basic imports to a set.
@param method the method to create
@param imports will be filled with the types required by the method
"""
ServiceMethod sm = new ServiceMethod(method);
sm.gatherImports(imports);
return sm;
} | java | public ServiceMethod createAndGatherImports (Method method, ImportSet imports)
{
ServiceMethod sm = new ServiceMethod(method);
sm.gatherImports(imports);
return sm;
} | [
"public",
"ServiceMethod",
"createAndGatherImports",
"(",
"Method",
"method",
",",
"ImportSet",
"imports",
")",
"{",
"ServiceMethod",
"sm",
"=",
"new",
"ServiceMethod",
"(",
"method",
")",
";",
"sm",
".",
"gatherImports",
"(",
"imports",
")",
";",
"return",
"sm",
";",
"}"
] | Creates a new service method and adds its basic imports to a set.
@param method the method to create
@param imports will be filled with the types required by the method | [
"Creates",
"a",
"new",
"service",
"method",
"and",
"adds",
"its",
"basic",
"imports",
"to",
"a",
"set",
"."
] | train | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/tools/src/main/java/com/threerings/presents/tools/InvocationTask.java#L95-L100 |
Azure/azure-sdk-for-java | appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServiceEnvironmentsInner.java | AppServiceEnvironmentsInner.suspendWithServiceResponseAsync | public Observable<ServiceResponse<Page<SiteInner>>> suspendWithServiceResponseAsync(final String resourceGroupName, final String name) {
"""
Suspend an App Service Environment.
Suspend an App Service Environment.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of the App Service Environment.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<SiteInner> object
"""
return suspendSinglePageAsync(resourceGroupName, name)
.concatMap(new Func1<ServiceResponse<Page<SiteInner>>, Observable<ServiceResponse<Page<SiteInner>>>>() {
@Override
public Observable<ServiceResponse<Page<SiteInner>>> call(ServiceResponse<Page<SiteInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(suspendNextWithServiceResponseAsync(nextPageLink));
}
});
} | java | public Observable<ServiceResponse<Page<SiteInner>>> suspendWithServiceResponseAsync(final String resourceGroupName, final String name) {
return suspendSinglePageAsync(resourceGroupName, name)
.concatMap(new Func1<ServiceResponse<Page<SiteInner>>, Observable<ServiceResponse<Page<SiteInner>>>>() {
@Override
public Observable<ServiceResponse<Page<SiteInner>>> call(ServiceResponse<Page<SiteInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(suspendNextWithServiceResponseAsync(nextPageLink));
}
});
} | [
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"SiteInner",
">",
">",
">",
"suspendWithServiceResponseAsync",
"(",
"final",
"String",
"resourceGroupName",
",",
"final",
"String",
"name",
")",
"{",
"return",
"suspendSinglePageAsync",
"(",
"resourceGroupName",
",",
"name",
")",
".",
"concatMap",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"SiteInner",
">",
">",
",",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"SiteInner",
">",
">",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"SiteInner",
">",
">",
">",
"call",
"(",
"ServiceResponse",
"<",
"Page",
"<",
"SiteInner",
">",
">",
"page",
")",
"{",
"String",
"nextPageLink",
"=",
"page",
".",
"body",
"(",
")",
".",
"nextPageLink",
"(",
")",
";",
"if",
"(",
"nextPageLink",
"==",
"null",
")",
"{",
"return",
"Observable",
".",
"just",
"(",
"page",
")",
";",
"}",
"return",
"Observable",
".",
"just",
"(",
"page",
")",
".",
"concatWith",
"(",
"suspendNextWithServiceResponseAsync",
"(",
"nextPageLink",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] | Suspend an App Service Environment.
Suspend an App Service Environment.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of the App Service Environment.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<SiteInner> object | [
"Suspend",
"an",
"App",
"Service",
"Environment",
".",
"Suspend",
"an",
"App",
"Service",
"Environment",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServiceEnvironmentsInner.java#L4510-L4522 |
pressgang-ccms/PressGangCCMSContentSpecProcessor | src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java | ContentSpecParser.changeCurrentLevel | protected void changeCurrentLevel(ParserData parserData, final Level newLevel, int newIndentationLevel) {
"""
Changes the current level that content is being processed for to a new level.
@param parserData
@param newLevel The new level to process for,
@param newIndentationLevel The new indentation level of the level in the Content Specification.
"""
parserData.setIndentationLevel(newIndentationLevel);
parserData.setCurrentLevel(newLevel);
} | java | protected void changeCurrentLevel(ParserData parserData, final Level newLevel, int newIndentationLevel) {
parserData.setIndentationLevel(newIndentationLevel);
parserData.setCurrentLevel(newLevel);
} | [
"protected",
"void",
"changeCurrentLevel",
"(",
"ParserData",
"parserData",
",",
"final",
"Level",
"newLevel",
",",
"int",
"newIndentationLevel",
")",
"{",
"parserData",
".",
"setIndentationLevel",
"(",
"newIndentationLevel",
")",
";",
"parserData",
".",
"setCurrentLevel",
"(",
"newLevel",
")",
";",
"}"
] | Changes the current level that content is being processed for to a new level.
@param parserData
@param newLevel The new level to process for,
@param newIndentationLevel The new indentation level of the level in the Content Specification. | [
"Changes",
"the",
"current",
"level",
"that",
"content",
"is",
"being",
"processed",
"for",
"to",
"a",
"new",
"level",
"."
] | train | https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java#L946-L949 |
javagl/ND | nd-tuples/src/main/java/de/javagl/nd/tuples/i/IntTuples.java | IntTuples.of | public static MutableIntTuple of(int x, int y, int z, int w) {
"""
Creates a new {@link MutableIntTuple} with the given values.
@param x The x coordinate
@param y The y coordinate
@param z The z coordinate
@param w The w coordinate
@return The new tuple
"""
return new DefaultIntTuple(new int[]{ x, y, z, w });
} | java | public static MutableIntTuple of(int x, int y, int z, int w)
{
return new DefaultIntTuple(new int[]{ x, y, z, w });
} | [
"public",
"static",
"MutableIntTuple",
"of",
"(",
"int",
"x",
",",
"int",
"y",
",",
"int",
"z",
",",
"int",
"w",
")",
"{",
"return",
"new",
"DefaultIntTuple",
"(",
"new",
"int",
"[",
"]",
"{",
"x",
",",
"y",
",",
"z",
",",
"w",
"}",
")",
";",
"}"
] | Creates a new {@link MutableIntTuple} with the given values.
@param x The x coordinate
@param y The y coordinate
@param z The z coordinate
@param w The w coordinate
@return The new tuple | [
"Creates",
"a",
"new",
"{",
"@link",
"MutableIntTuple",
"}",
"with",
"the",
"given",
"values",
"."
] | train | https://github.com/javagl/ND/blob/bcb655aaf5fc88af6194f73a27cca079186ff559/nd-tuples/src/main/java/de/javagl/nd/tuples/i/IntTuples.java#L1510-L1513 |
andrehertwig/admintool | admin-tools-filebrowser/src/main/java/de/chandre/admintool/filebrowser/AdminToolFilebrowserServiceImpl.java | AdminToolFilebrowserServiceImpl.formatFileSize | protected String formatFileSize(BigInteger fileLength, BigInteger divisor, String unit) {
"""
calculates the and formats files size
@see #getFileSize(long)
@param fileLength
@param divisor
@param unit the Unit for the divisor
@return
"""
BigDecimal size = new BigDecimal(fileLength);
size = size.setScale(config.getFileSizeDisplayScale()).divide(new BigDecimal(divisor), BigDecimal.ROUND_HALF_EVEN);
return String.format("%s %s", size.doubleValue(), unit);
} | java | protected String formatFileSize(BigInteger fileLength, BigInteger divisor, String unit) {
BigDecimal size = new BigDecimal(fileLength);
size = size.setScale(config.getFileSizeDisplayScale()).divide(new BigDecimal(divisor), BigDecimal.ROUND_HALF_EVEN);
return String.format("%s %s", size.doubleValue(), unit);
} | [
"protected",
"String",
"formatFileSize",
"(",
"BigInteger",
"fileLength",
",",
"BigInteger",
"divisor",
",",
"String",
"unit",
")",
"{",
"BigDecimal",
"size",
"=",
"new",
"BigDecimal",
"(",
"fileLength",
")",
";",
"size",
"=",
"size",
".",
"setScale",
"(",
"config",
".",
"getFileSizeDisplayScale",
"(",
")",
")",
".",
"divide",
"(",
"new",
"BigDecimal",
"(",
"divisor",
")",
",",
"BigDecimal",
".",
"ROUND_HALF_EVEN",
")",
";",
"return",
"String",
".",
"format",
"(",
"\"%s %s\"",
",",
"size",
".",
"doubleValue",
"(",
")",
",",
"unit",
")",
";",
"}"
] | calculates the and formats files size
@see #getFileSize(long)
@param fileLength
@param divisor
@param unit the Unit for the divisor
@return | [
"calculates",
"the",
"and",
"formats",
"files",
"size"
] | train | https://github.com/andrehertwig/admintool/blob/6d391e2d26969b70e3ccabfc34202abe8d915080/admin-tools-filebrowser/src/main/java/de/chandre/admintool/filebrowser/AdminToolFilebrowserServiceImpl.java#L341-L345 |
Kurento/kurento-module-creator | src/main/java/com/github/zafarkhaja/semver/expr/ExpressionParser.java | ExpressionParser.parseTildeExpression | private Expression parseTildeExpression() {
"""
Parses the {@literal <tilde-expr>} non-terminal.
<pre>
{@literal
<tilde-expr> ::= "~" <version>
}
</pre>
@return the expression AST
"""
consumeNextToken(TILDE);
int major = intOf(consumeNextToken(NUMERIC).lexeme);
if (!tokens.positiveLookahead(DOT)) {
return new GreaterOrEqual(versionOf(major, 0, 0));
}
consumeNextToken(DOT);
int minor = intOf(consumeNextToken(NUMERIC).lexeme);
if (!tokens.positiveLookahead(DOT)) {
return new And(new GreaterOrEqual(versionOf(major, minor, 0)),
new Less(versionOf(major + 1, 0, 0)));
}
consumeNextToken(DOT);
int patch = intOf(consumeNextToken(NUMERIC).lexeme);
return new And(new GreaterOrEqual(versionOf(major, minor, patch)),
new Less(versionOf(major, minor + 1, 0)));
} | java | private Expression parseTildeExpression() {
consumeNextToken(TILDE);
int major = intOf(consumeNextToken(NUMERIC).lexeme);
if (!tokens.positiveLookahead(DOT)) {
return new GreaterOrEqual(versionOf(major, 0, 0));
}
consumeNextToken(DOT);
int minor = intOf(consumeNextToken(NUMERIC).lexeme);
if (!tokens.positiveLookahead(DOT)) {
return new And(new GreaterOrEqual(versionOf(major, minor, 0)),
new Less(versionOf(major + 1, 0, 0)));
}
consumeNextToken(DOT);
int patch = intOf(consumeNextToken(NUMERIC).lexeme);
return new And(new GreaterOrEqual(versionOf(major, minor, patch)),
new Less(versionOf(major, minor + 1, 0)));
} | [
"private",
"Expression",
"parseTildeExpression",
"(",
")",
"{",
"consumeNextToken",
"(",
"TILDE",
")",
";",
"int",
"major",
"=",
"intOf",
"(",
"consumeNextToken",
"(",
"NUMERIC",
")",
".",
"lexeme",
")",
";",
"if",
"(",
"!",
"tokens",
".",
"positiveLookahead",
"(",
"DOT",
")",
")",
"{",
"return",
"new",
"GreaterOrEqual",
"(",
"versionOf",
"(",
"major",
",",
"0",
",",
"0",
")",
")",
";",
"}",
"consumeNextToken",
"(",
"DOT",
")",
";",
"int",
"minor",
"=",
"intOf",
"(",
"consumeNextToken",
"(",
"NUMERIC",
")",
".",
"lexeme",
")",
";",
"if",
"(",
"!",
"tokens",
".",
"positiveLookahead",
"(",
"DOT",
")",
")",
"{",
"return",
"new",
"And",
"(",
"new",
"GreaterOrEqual",
"(",
"versionOf",
"(",
"major",
",",
"minor",
",",
"0",
")",
")",
",",
"new",
"Less",
"(",
"versionOf",
"(",
"major",
"+",
"1",
",",
"0",
",",
"0",
")",
")",
")",
";",
"}",
"consumeNextToken",
"(",
"DOT",
")",
";",
"int",
"patch",
"=",
"intOf",
"(",
"consumeNextToken",
"(",
"NUMERIC",
")",
".",
"lexeme",
")",
";",
"return",
"new",
"And",
"(",
"new",
"GreaterOrEqual",
"(",
"versionOf",
"(",
"major",
",",
"minor",
",",
"patch",
")",
")",
",",
"new",
"Less",
"(",
"versionOf",
"(",
"major",
",",
"minor",
"+",
"1",
",",
"0",
")",
")",
")",
";",
"}"
] | Parses the {@literal <tilde-expr>} non-terminal.
<pre>
{@literal
<tilde-expr> ::= "~" <version>
}
</pre>
@return the expression AST | [
"Parses",
"the",
"{",
"@literal",
"<tilde",
"-",
"expr",
">",
"}",
"non",
"-",
"terminal",
"."
] | train | https://github.com/Kurento/kurento-module-creator/blob/c371516c665b902b5476433496a5aefcbca86d64/src/main/java/com/github/zafarkhaja/semver/expr/ExpressionParser.java#L247-L263 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.comms.client/src/com/ibm/ws/sib/comms/common/CommsUtils.java | CommsUtils.getRuntimeIntProperty | public static int getRuntimeIntProperty(String property, String defaultValue) {
"""
This method will get a runtime property from the sib.properties file and will convert the
value (if set) to an int. If the property in the file was set to something that was not
parseable as an integer, then the default value will be returned.
@param property The property key used to look up in the file.
@param defaultValue The default value if the property is not in the file.
@return Returns the property value.
"""
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "getRuntimeIntProperty", new Object[] {property, defaultValue});
// Note that we parse the default value outside of the try / catch so that if we muck
// up then we blow up. Customer settable properties however, we do not want to blow if they
// screw up.
int runtimeProp = Integer.parseInt(defaultValue);
try
{
runtimeProp = Integer.parseInt(RuntimeInfo.getPropertyWithMsg(property, defaultValue));
}
catch (NumberFormatException e)
{
FFDCFilter.processException(e, CLASS_NAME + ".getRuntimeIntProperty" ,
CommsConstants.COMMSUTILS_GETRUNTIMEINT_01);
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(tc, "NumberFormatException: ", e);
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "getRuntimeIntProperty", ""+runtimeProp);
return runtimeProp;
} | java | public static int getRuntimeIntProperty(String property, String defaultValue)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "getRuntimeIntProperty", new Object[] {property, defaultValue});
// Note that we parse the default value outside of the try / catch so that if we muck
// up then we blow up. Customer settable properties however, we do not want to blow if they
// screw up.
int runtimeProp = Integer.parseInt(defaultValue);
try
{
runtimeProp = Integer.parseInt(RuntimeInfo.getPropertyWithMsg(property, defaultValue));
}
catch (NumberFormatException e)
{
FFDCFilter.processException(e, CLASS_NAME + ".getRuntimeIntProperty" ,
CommsConstants.COMMSUTILS_GETRUNTIMEINT_01);
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(tc, "NumberFormatException: ", e);
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "getRuntimeIntProperty", ""+runtimeProp);
return runtimeProp;
} | [
"public",
"static",
"int",
"getRuntimeIntProperty",
"(",
"String",
"property",
",",
"String",
"defaultValue",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"tc",
",",
"\"getRuntimeIntProperty\"",
",",
"new",
"Object",
"[",
"]",
"{",
"property",
",",
"defaultValue",
"}",
")",
";",
"// Note that we parse the default value outside of the try / catch so that if we muck",
"// up then we blow up. Customer settable properties however, we do not want to blow if they",
"// screw up. ",
"int",
"runtimeProp",
"=",
"Integer",
".",
"parseInt",
"(",
"defaultValue",
")",
";",
"try",
"{",
"runtimeProp",
"=",
"Integer",
".",
"parseInt",
"(",
"RuntimeInfo",
".",
"getPropertyWithMsg",
"(",
"property",
",",
"defaultValue",
")",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"FFDCFilter",
".",
"processException",
"(",
"e",
",",
"CLASS_NAME",
"+",
"\".getRuntimeIntProperty\"",
",",
"CommsConstants",
".",
"COMMSUTILS_GETRUNTIMEINT_01",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"SibTr",
".",
"debug",
"(",
"tc",
",",
"\"NumberFormatException: \"",
",",
"e",
")",
";",
"}",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"tc",
",",
"\"getRuntimeIntProperty\"",
",",
"\"\"",
"+",
"runtimeProp",
")",
";",
"return",
"runtimeProp",
";",
"}"
] | This method will get a runtime property from the sib.properties file and will convert the
value (if set) to an int. If the property in the file was set to something that was not
parseable as an integer, then the default value will be returned.
@param property The property key used to look up in the file.
@param defaultValue The default value if the property is not in the file.
@return Returns the property value. | [
"This",
"method",
"will",
"get",
"a",
"runtime",
"property",
"from",
"the",
"sib",
".",
"properties",
"file",
"and",
"will",
"convert",
"the",
"value",
"(",
"if",
"set",
")",
"to",
"an",
"int",
".",
"If",
"the",
"property",
"in",
"the",
"file",
"was",
"set",
"to",
"something",
"that",
"was",
"not",
"parseable",
"as",
"an",
"integer",
"then",
"the",
"default",
"value",
"will",
"be",
"returned",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.comms.client/src/com/ibm/ws/sib/comms/common/CommsUtils.java#L97-L120 |
weld/core | impl/src/main/java/org/jboss/weld/util/bytecode/BytecodeUtils.java | BytecodeUtils.addLoadInstruction | public static void addLoadInstruction(CodeAttribute code, String type, int variable) {
"""
Adds the correct load instruction based on the type descriptor
@param code the bytecode to add the instruction to
@param type the type of the variable
@param variable the variable number
"""
char tp = type.charAt(0);
if (tp != 'L' && tp != '[') {
// we have a primitive type
switch (tp) {
case 'J':
code.lload(variable);
break;
case 'D':
code.dload(variable);
break;
case 'F':
code.fload(variable);
break;
default:
code.iload(variable);
}
} else {
code.aload(variable);
}
} | java | public static void addLoadInstruction(CodeAttribute code, String type, int variable) {
char tp = type.charAt(0);
if (tp != 'L' && tp != '[') {
// we have a primitive type
switch (tp) {
case 'J':
code.lload(variable);
break;
case 'D':
code.dload(variable);
break;
case 'F':
code.fload(variable);
break;
default:
code.iload(variable);
}
} else {
code.aload(variable);
}
} | [
"public",
"static",
"void",
"addLoadInstruction",
"(",
"CodeAttribute",
"code",
",",
"String",
"type",
",",
"int",
"variable",
")",
"{",
"char",
"tp",
"=",
"type",
".",
"charAt",
"(",
"0",
")",
";",
"if",
"(",
"tp",
"!=",
"'",
"'",
"&&",
"tp",
"!=",
"'",
"'",
")",
"{",
"// we have a primitive type",
"switch",
"(",
"tp",
")",
"{",
"case",
"'",
"'",
":",
"code",
".",
"lload",
"(",
"variable",
")",
";",
"break",
";",
"case",
"'",
"'",
":",
"code",
".",
"dload",
"(",
"variable",
")",
";",
"break",
";",
"case",
"'",
"'",
":",
"code",
".",
"fload",
"(",
"variable",
")",
";",
"break",
";",
"default",
":",
"code",
".",
"iload",
"(",
"variable",
")",
";",
"}",
"}",
"else",
"{",
"code",
".",
"aload",
"(",
"variable",
")",
";",
"}",
"}"
] | Adds the correct load instruction based on the type descriptor
@param code the bytecode to add the instruction to
@param type the type of the variable
@param variable the variable number | [
"Adds",
"the",
"correct",
"load",
"instruction",
"based",
"on",
"the",
"type",
"descriptor"
] | train | https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/util/bytecode/BytecodeUtils.java#L54-L74 |
wcm-io/wcm-io-handler | media/src/main/java/io/wcm/handler/mediasource/inline/InlineRendition.java | InlineRendition.buildScaledMediaUrl | private String buildScaledMediaUrl(Dimension dimension, CropDimension cropDimension) {
"""
Builds URL to rescaled version of the binary image.
@return Media URL
"""
String resourcePath = this.resource.getPath();
// if parent resource is a nt:file resource, use this one as path for scaled image
Resource parentResource = this.resource.getParent();
if (JcrBinary.isNtFile(parentResource)) {
resourcePath = parentResource.getPath();
}
// URL to render scaled image via {@link InlineRenditionServlet}
String path = resourcePath + "." + ImageFileServlet.SELECTOR
+ "." + dimension.getWidth() + "." + dimension.getHeight()
+ (cropDimension != null ? "." + cropDimension.getCropString() : "")
+ (this.mediaArgs.isContentDispositionAttachment() ? "." + MediaFileServlet.SELECTOR_DOWNLOAD : "")
+ "." + MediaFileServlet.EXTENSION + "/"
// replace extension based on the format supported by ImageFileServlet for rendering for this rendition
+ ImageFileServlet.getImageFileName(getFileName());
// build externalized URL
UrlHandler urlHandler = AdaptTo.notNull(this.adaptable, UrlHandler.class);
return urlHandler.get(path).urlMode(this.mediaArgs.getUrlMode()).buildExternalResourceUrl(this.resource);
} | java | private String buildScaledMediaUrl(Dimension dimension, CropDimension cropDimension) {
String resourcePath = this.resource.getPath();
// if parent resource is a nt:file resource, use this one as path for scaled image
Resource parentResource = this.resource.getParent();
if (JcrBinary.isNtFile(parentResource)) {
resourcePath = parentResource.getPath();
}
// URL to render scaled image via {@link InlineRenditionServlet}
String path = resourcePath + "." + ImageFileServlet.SELECTOR
+ "." + dimension.getWidth() + "." + dimension.getHeight()
+ (cropDimension != null ? "." + cropDimension.getCropString() : "")
+ (this.mediaArgs.isContentDispositionAttachment() ? "." + MediaFileServlet.SELECTOR_DOWNLOAD : "")
+ "." + MediaFileServlet.EXTENSION + "/"
// replace extension based on the format supported by ImageFileServlet for rendering for this rendition
+ ImageFileServlet.getImageFileName(getFileName());
// build externalized URL
UrlHandler urlHandler = AdaptTo.notNull(this.adaptable, UrlHandler.class);
return urlHandler.get(path).urlMode(this.mediaArgs.getUrlMode()).buildExternalResourceUrl(this.resource);
} | [
"private",
"String",
"buildScaledMediaUrl",
"(",
"Dimension",
"dimension",
",",
"CropDimension",
"cropDimension",
")",
"{",
"String",
"resourcePath",
"=",
"this",
".",
"resource",
".",
"getPath",
"(",
")",
";",
"// if parent resource is a nt:file resource, use this one as path for scaled image",
"Resource",
"parentResource",
"=",
"this",
".",
"resource",
".",
"getParent",
"(",
")",
";",
"if",
"(",
"JcrBinary",
".",
"isNtFile",
"(",
"parentResource",
")",
")",
"{",
"resourcePath",
"=",
"parentResource",
".",
"getPath",
"(",
")",
";",
"}",
"// URL to render scaled image via {@link InlineRenditionServlet}",
"String",
"path",
"=",
"resourcePath",
"+",
"\".\"",
"+",
"ImageFileServlet",
".",
"SELECTOR",
"+",
"\".\"",
"+",
"dimension",
".",
"getWidth",
"(",
")",
"+",
"\".\"",
"+",
"dimension",
".",
"getHeight",
"(",
")",
"+",
"(",
"cropDimension",
"!=",
"null",
"?",
"\".\"",
"+",
"cropDimension",
".",
"getCropString",
"(",
")",
":",
"\"\"",
")",
"+",
"(",
"this",
".",
"mediaArgs",
".",
"isContentDispositionAttachment",
"(",
")",
"?",
"\".\"",
"+",
"MediaFileServlet",
".",
"SELECTOR_DOWNLOAD",
":",
"\"\"",
")",
"+",
"\".\"",
"+",
"MediaFileServlet",
".",
"EXTENSION",
"+",
"\"/\"",
"// replace extension based on the format supported by ImageFileServlet for rendering for this rendition",
"+",
"ImageFileServlet",
".",
"getImageFileName",
"(",
"getFileName",
"(",
")",
")",
";",
"// build externalized URL",
"UrlHandler",
"urlHandler",
"=",
"AdaptTo",
".",
"notNull",
"(",
"this",
".",
"adaptable",
",",
"UrlHandler",
".",
"class",
")",
";",
"return",
"urlHandler",
".",
"get",
"(",
"path",
")",
".",
"urlMode",
"(",
"this",
".",
"mediaArgs",
".",
"getUrlMode",
"(",
")",
")",
".",
"buildExternalResourceUrl",
"(",
"this",
".",
"resource",
")",
";",
"}"
] | Builds URL to rescaled version of the binary image.
@return Media URL | [
"Builds",
"URL",
"to",
"rescaled",
"version",
"of",
"the",
"binary",
"image",
"."
] | train | https://github.com/wcm-io/wcm-io-handler/blob/b0fc1c11a3ceb89efb73826dcfd480d6a00c19af/media/src/main/java/io/wcm/handler/mediasource/inline/InlineRendition.java#L259-L280 |
threerings/gwt-utils | src/main/java/com/threerings/gwt/ui/PagedWidget.java | PagedWidget.removeItem | public void removeItem (T item) {
"""
Removes the specified item from the panel. If the item is currently being displayed, its
interface element will be removed as well.
"""
if (_model == null) {
return; // if we have no model, stop here
}
// remove the item from our data model
_model.removeItem(item);
// force a relayout of this page
displayPage(_page, true);
} | java | public void removeItem (T item)
{
if (_model == null) {
return; // if we have no model, stop here
}
// remove the item from our data model
_model.removeItem(item);
// force a relayout of this page
displayPage(_page, true);
} | [
"public",
"void",
"removeItem",
"(",
"T",
"item",
")",
"{",
"if",
"(",
"_model",
"==",
"null",
")",
"{",
"return",
";",
"// if we have no model, stop here",
"}",
"// remove the item from our data model",
"_model",
".",
"removeItem",
"(",
"item",
")",
";",
"// force a relayout of this page",
"displayPage",
"(",
"_page",
",",
"true",
")",
";",
"}"
] | Removes the specified item from the panel. If the item is currently being displayed, its
interface element will be removed as well. | [
"Removes",
"the",
"specified",
"item",
"from",
"the",
"panel",
".",
"If",
"the",
"item",
"is",
"currently",
"being",
"displayed",
"its",
"interface",
"element",
"will",
"be",
"removed",
"as",
"well",
"."
] | train | https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/ui/PagedWidget.java#L202-L211 |
rundeck/rundeck | core/src/main/java/com/dtolabs/rundeck/core/execution/workflow/steps/node/impl/DefaultScriptFileNodeStepUtils.java | DefaultScriptFileNodeStepUtils.executeRemoteScript | @Override
public NodeStepResult executeRemoteScript(
final ExecutionContext context,
final Framework framework,
final INodeEntry node,
final String[] args,
final String filepath
) throws NodeStepException {
"""
Execute a scriptfile already copied to a remote node with the given args
@param context context
@param framework framework
@param node the node
@param args arguments to script
@param filepath the remote path for the script
@return the result
@throws NodeStepException on error
"""
return executeRemoteScript(context, framework, node, args, filepath, null, false);
} | java | @Override
public NodeStepResult executeRemoteScript(
final ExecutionContext context,
final Framework framework,
final INodeEntry node,
final String[] args,
final String filepath
) throws NodeStepException
{
return executeRemoteScript(context, framework, node, args, filepath, null, false);
} | [
"@",
"Override",
"public",
"NodeStepResult",
"executeRemoteScript",
"(",
"final",
"ExecutionContext",
"context",
",",
"final",
"Framework",
"framework",
",",
"final",
"INodeEntry",
"node",
",",
"final",
"String",
"[",
"]",
"args",
",",
"final",
"String",
"filepath",
")",
"throws",
"NodeStepException",
"{",
"return",
"executeRemoteScript",
"(",
"context",
",",
"framework",
",",
"node",
",",
"args",
",",
"filepath",
",",
"null",
",",
"false",
")",
";",
"}"
] | Execute a scriptfile already copied to a remote node with the given args
@param context context
@param framework framework
@param node the node
@param args arguments to script
@param filepath the remote path for the script
@return the result
@throws NodeStepException on error | [
"Execute",
"a",
"scriptfile",
"already",
"copied",
"to",
"a",
"remote",
"node",
"with",
"the",
"given",
"args"
] | train | https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/execution/workflow/steps/node/impl/DefaultScriptFileNodeStepUtils.java#L210-L220 |
square/javapoet | src/main/java/com/squareup/javapoet/ParameterizedTypeName.java | ParameterizedTypeName.get | public static ParameterizedTypeName get(Class<?> rawType, Type... typeArguments) {
"""
Returns a parameterized type, applying {@code typeArguments} to {@code rawType}.
"""
return new ParameterizedTypeName(null, ClassName.get(rawType), list(typeArguments));
} | java | public static ParameterizedTypeName get(Class<?> rawType, Type... typeArguments) {
return new ParameterizedTypeName(null, ClassName.get(rawType), list(typeArguments));
} | [
"public",
"static",
"ParameterizedTypeName",
"get",
"(",
"Class",
"<",
"?",
">",
"rawType",
",",
"Type",
"...",
"typeArguments",
")",
"{",
"return",
"new",
"ParameterizedTypeName",
"(",
"null",
",",
"ClassName",
".",
"get",
"(",
"rawType",
")",
",",
"list",
"(",
"typeArguments",
")",
")",
";",
"}"
] | Returns a parameterized type, applying {@code typeArguments} to {@code rawType}. | [
"Returns",
"a",
"parameterized",
"type",
"applying",
"{"
] | train | https://github.com/square/javapoet/blob/0f93da9a3d9a1da8d29fc993409fcf83d40452bc/src/main/java/com/squareup/javapoet/ParameterizedTypeName.java#L118-L120 |
rhuss/jolokia | agent/core/src/main/java/org/jolokia/util/JmxUtil.java | JmxUtil.newObjectName | public static ObjectName newObjectName(String pName) {
"""
Factory method for creating a new object name, mapping any checked {@link MalformedObjectNameException} to
a runtime exception ({@link IllegalArgumentException})
@param pName name to convert
@return the created object name
"""
try {
return new ObjectName(pName);
} catch (MalformedObjectNameException e) {
throw new IllegalArgumentException("Invalid object name " + pName,e);
}
} | java | public static ObjectName newObjectName(String pName) {
try {
return new ObjectName(pName);
} catch (MalformedObjectNameException e) {
throw new IllegalArgumentException("Invalid object name " + pName,e);
}
} | [
"public",
"static",
"ObjectName",
"newObjectName",
"(",
"String",
"pName",
")",
"{",
"try",
"{",
"return",
"new",
"ObjectName",
"(",
"pName",
")",
";",
"}",
"catch",
"(",
"MalformedObjectNameException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid object name \"",
"+",
"pName",
",",
"e",
")",
";",
"}",
"}"
] | Factory method for creating a new object name, mapping any checked {@link MalformedObjectNameException} to
a runtime exception ({@link IllegalArgumentException})
@param pName name to convert
@return the created object name | [
"Factory",
"method",
"for",
"creating",
"a",
"new",
"object",
"name",
"mapping",
"any",
"checked",
"{"
] | train | https://github.com/rhuss/jolokia/blob/dc95e7bef859b1829776c5a84c8f7738f5d7d9c3/agent/core/src/main/java/org/jolokia/util/JmxUtil.java#L25-L31 |
hawkular/hawkular-agent | hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/inventory/InventoryIdUtil.java | InventoryIdUtil.parseResourceId | public static ResourceIdParts parseResourceId(String resourceId) {
"""
Given a resource ID generated via {@link InventoryIdUtil#generateResourceId}
this returns the different parts that make up that resource ID.
@param resourceId the full resource ID to be parsed
@return the parts of the resource ID
"""
if (resourceId == null) {
throw new IllegalArgumentException("Invalid resource ID - cannot be null");
}
String[] parts = resourceId.split("~", 3);
if (parts.length != 3) {
throw new IllegalArgumentException("Cannot parse invalid ID: " + resourceId);
}
return new ResourceIdParts(parts[0], parts[1], parts[2]);
} | java | public static ResourceIdParts parseResourceId(String resourceId) {
if (resourceId == null) {
throw new IllegalArgumentException("Invalid resource ID - cannot be null");
}
String[] parts = resourceId.split("~", 3);
if (parts.length != 3) {
throw new IllegalArgumentException("Cannot parse invalid ID: " + resourceId);
}
return new ResourceIdParts(parts[0], parts[1], parts[2]);
} | [
"public",
"static",
"ResourceIdParts",
"parseResourceId",
"(",
"String",
"resourceId",
")",
"{",
"if",
"(",
"resourceId",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid resource ID - cannot be null\"",
")",
";",
"}",
"String",
"[",
"]",
"parts",
"=",
"resourceId",
".",
"split",
"(",
"\"~\"",
",",
"3",
")",
";",
"if",
"(",
"parts",
".",
"length",
"!=",
"3",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Cannot parse invalid ID: \"",
"+",
"resourceId",
")",
";",
"}",
"return",
"new",
"ResourceIdParts",
"(",
"parts",
"[",
"0",
"]",
",",
"parts",
"[",
"1",
"]",
",",
"parts",
"[",
"2",
"]",
")",
";",
"}"
] | Given a resource ID generated via {@link InventoryIdUtil#generateResourceId}
this returns the different parts that make up that resource ID.
@param resourceId the full resource ID to be parsed
@return the parts of the resource ID | [
"Given",
"a",
"resource",
"ID",
"generated",
"via",
"{",
"@link",
"InventoryIdUtil#generateResourceId",
"}",
"this",
"returns",
"the",
"different",
"parts",
"that",
"make",
"up",
"that",
"resource",
"ID",
"."
] | train | https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/inventory/InventoryIdUtil.java#L59-L69 |
fcrepo3/fcrepo | fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multicast/LocalDirectoryTransport.java | LocalDirectoryTransport.openFile | @Override
public void openFile(String repositoryHash,
String filename,
Date currentDate) throws JournalException {
"""
On a request to open the file,
<ul>
<li>check that we are in a valid state,</li>
<li>create the file,</li>
<li>create the {@link XMLEventWriter} for use on the file,</li>
<li>ask the parent to write the header to the file,</li>
<li>set the state.</li>
</ul>
"""
try {
super.testStateChange(State.FILE_OPEN);
journalFile = new TransportOutputFile(directory, filename);
xmlWriter =
new IndentingXMLEventWriter(XMLOutputFactory.newInstance()
.createXMLEventWriter(journalFile.open()));
parent.writeDocumentHeader(xmlWriter, repositoryHash, currentDate);
super.setState(State.FILE_OPEN);
} catch (FactoryConfigurationError e) {
throw new JournalException(e);
} catch (XMLStreamException e) {
throw new JournalException(e);
} catch (IOException e) {
throw new JournalException(e);
}
} | java | @Override
public void openFile(String repositoryHash,
String filename,
Date currentDate) throws JournalException {
try {
super.testStateChange(State.FILE_OPEN);
journalFile = new TransportOutputFile(directory, filename);
xmlWriter =
new IndentingXMLEventWriter(XMLOutputFactory.newInstance()
.createXMLEventWriter(journalFile.open()));
parent.writeDocumentHeader(xmlWriter, repositoryHash, currentDate);
super.setState(State.FILE_OPEN);
} catch (FactoryConfigurationError e) {
throw new JournalException(e);
} catch (XMLStreamException e) {
throw new JournalException(e);
} catch (IOException e) {
throw new JournalException(e);
}
} | [
"@",
"Override",
"public",
"void",
"openFile",
"(",
"String",
"repositoryHash",
",",
"String",
"filename",
",",
"Date",
"currentDate",
")",
"throws",
"JournalException",
"{",
"try",
"{",
"super",
".",
"testStateChange",
"(",
"State",
".",
"FILE_OPEN",
")",
";",
"journalFile",
"=",
"new",
"TransportOutputFile",
"(",
"directory",
",",
"filename",
")",
";",
"xmlWriter",
"=",
"new",
"IndentingXMLEventWriter",
"(",
"XMLOutputFactory",
".",
"newInstance",
"(",
")",
".",
"createXMLEventWriter",
"(",
"journalFile",
".",
"open",
"(",
")",
")",
")",
";",
"parent",
".",
"writeDocumentHeader",
"(",
"xmlWriter",
",",
"repositoryHash",
",",
"currentDate",
")",
";",
"super",
".",
"setState",
"(",
"State",
".",
"FILE_OPEN",
")",
";",
"}",
"catch",
"(",
"FactoryConfigurationError",
"e",
")",
"{",
"throw",
"new",
"JournalException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"XMLStreamException",
"e",
")",
"{",
"throw",
"new",
"JournalException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"JournalException",
"(",
"e",
")",
";",
"}",
"}"
] | On a request to open the file,
<ul>
<li>check that we are in a valid state,</li>
<li>create the file,</li>
<li>create the {@link XMLEventWriter} for use on the file,</li>
<li>ask the parent to write the header to the file,</li>
<li>set the state.</li>
</ul> | [
"On",
"a",
"request",
"to",
"open",
"the",
"file",
"<ul",
">",
"<li",
">",
"check",
"that",
"we",
"are",
"in",
"a",
"valid",
"state",
"<",
"/",
"li",
">",
"<li",
">",
"create",
"the",
"file",
"<",
"/",
"li",
">",
"<li",
">",
"create",
"the",
"{"
] | train | https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multicast/LocalDirectoryTransport.java#L73-L96 |
google/closure-compiler | src/com/google/javascript/refactoring/Matchers.java | Matchers.assignmentWithRhs | public static Matcher assignmentWithRhs(final Matcher rhsMatcher) {
"""
Returns a Matcher that matches an ASSIGN node where the RHS of the assignment matches the given
rhsMatcher.
"""
return new Matcher() {
@Override public boolean matches(Node node, NodeMetadata metadata) {
return node.isAssign() && rhsMatcher.matches(node.getLastChild(), metadata);
}
};
} | java | public static Matcher assignmentWithRhs(final Matcher rhsMatcher) {
return new Matcher() {
@Override public boolean matches(Node node, NodeMetadata metadata) {
return node.isAssign() && rhsMatcher.matches(node.getLastChild(), metadata);
}
};
} | [
"public",
"static",
"Matcher",
"assignmentWithRhs",
"(",
"final",
"Matcher",
"rhsMatcher",
")",
"{",
"return",
"new",
"Matcher",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"matches",
"(",
"Node",
"node",
",",
"NodeMetadata",
"metadata",
")",
"{",
"return",
"node",
".",
"isAssign",
"(",
")",
"&&",
"rhsMatcher",
".",
"matches",
"(",
"node",
".",
"getLastChild",
"(",
")",
",",
"metadata",
")",
";",
"}",
"}",
";",
"}"
] | Returns a Matcher that matches an ASSIGN node where the RHS of the assignment matches the given
rhsMatcher. | [
"Returns",
"a",
"Matcher",
"that",
"matches",
"an",
"ASSIGN",
"node",
"where",
"the",
"RHS",
"of",
"the",
"assignment",
"matches",
"the",
"given",
"rhsMatcher",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/refactoring/Matchers.java#L306-L312 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/ReferenceStream.java | ReferenceStream.removeFirstMatching | public final ItemReference removeFirstMatching(final Filter filter, final Transaction transaction)
throws MessageStoreException {
"""
removeFirstMatching (aka DestructiveGet).
@param filter
@param transaction
must not be null.
@return Item may be null.
@throws {@link MessageStoreException} if the item was spilled and could not
be unspilled. Or if item not found in backing store.
@throws {@link MessageStoreException} indicates that an unrecoverable exception has
occurred in the underlying persistence mechanism.
@throws MessageStoreException
"""
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(this, tc, "removeFirstMatching", new Object[] { filter, transaction });
ReferenceCollection ic = ((ReferenceCollection) _getMembership());
ItemReference item = null;
if (ic != null)
{
item = (ItemReference) ic.removeFirstMatching(filter, transaction);
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(this, tc, "removeFirstMatching", item);
return item;
} | java | public final ItemReference removeFirstMatching(final Filter filter, final Transaction transaction)
throws MessageStoreException
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(this, tc, "removeFirstMatching", new Object[] { filter, transaction });
ReferenceCollection ic = ((ReferenceCollection) _getMembership());
ItemReference item = null;
if (ic != null)
{
item = (ItemReference) ic.removeFirstMatching(filter, transaction);
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(this, tc, "removeFirstMatching", item);
return item;
} | [
"public",
"final",
"ItemReference",
"removeFirstMatching",
"(",
"final",
"Filter",
"filter",
",",
"final",
"Transaction",
"transaction",
")",
"throws",
"MessageStoreException",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"this",
",",
"tc",
",",
"\"removeFirstMatching\"",
",",
"new",
"Object",
"[",
"]",
"{",
"filter",
",",
"transaction",
"}",
")",
";",
"ReferenceCollection",
"ic",
"=",
"(",
"(",
"ReferenceCollection",
")",
"_getMembership",
"(",
")",
")",
";",
"ItemReference",
"item",
"=",
"null",
";",
"if",
"(",
"ic",
"!=",
"null",
")",
"{",
"item",
"=",
"(",
"ItemReference",
")",
"ic",
".",
"removeFirstMatching",
"(",
"filter",
",",
"transaction",
")",
";",
"}",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"this",
",",
"tc",
",",
"\"removeFirstMatching\"",
",",
"item",
")",
";",
"return",
"item",
";",
"}"
] | removeFirstMatching (aka DestructiveGet).
@param filter
@param transaction
must not be null.
@return Item may be null.
@throws {@link MessageStoreException} if the item was spilled and could not
be unspilled. Or if item not found in backing store.
@throws {@link MessageStoreException} indicates that an unrecoverable exception has
occurred in the underlying persistence mechanism.
@throws MessageStoreException | [
"removeFirstMatching",
"(",
"aka",
"DestructiveGet",
")",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/ReferenceStream.java#L549-L565 |
threerings/nenya | core/src/main/java/com/threerings/media/image/ColorPository.java | ColorPository.getRandomStartingColor | public ColorRecord getRandomStartingColor (String className, Random rand) {
"""
Returns a random starting color from the specified color class.
"""
// make sure the class exists
ClassRecord record = getClassRecord(className);
return (record == null) ? null : record.randomStartingColor(rand);
} | java | public ColorRecord getRandomStartingColor (String className, Random rand)
{
// make sure the class exists
ClassRecord record = getClassRecord(className);
return (record == null) ? null : record.randomStartingColor(rand);
} | [
"public",
"ColorRecord",
"getRandomStartingColor",
"(",
"String",
"className",
",",
"Random",
"rand",
")",
"{",
"// make sure the class exists",
"ClassRecord",
"record",
"=",
"getClassRecord",
"(",
"className",
")",
";",
"return",
"(",
"record",
"==",
"null",
")",
"?",
"null",
":",
"record",
".",
"randomStartingColor",
"(",
"rand",
")",
";",
"}"
] | Returns a random starting color from the specified color class. | [
"Returns",
"a",
"random",
"starting",
"color",
"from",
"the",
"specified",
"color",
"class",
"."
] | train | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/image/ColorPository.java#L354-L359 |
apache/groovy | src/main/java/org/codehaus/groovy/classgen/asm/BytecodeHelper.java | BytecodeHelper.visitClassLiteral | public static void visitClassLiteral(MethodVisitor mv, ClassNode classNode) {
"""
Visits a class literal. If the type of the classnode is a primitive type,
the generated bytecode will be a GETSTATIC Integer.TYPE.
If the classnode is not a primitive type, we will generate a LDC instruction.
"""
if (ClassHelper.isPrimitiveType(classNode)) {
mv.visitFieldInsn(
GETSTATIC,
getClassInternalName(ClassHelper.getWrapper(classNode)),
"TYPE",
"Ljava/lang/Class;");
} else {
mv.visitLdcInsn(org.objectweb.asm.Type.getType(getTypeDescription(classNode)));
}
} | java | public static void visitClassLiteral(MethodVisitor mv, ClassNode classNode) {
if (ClassHelper.isPrimitiveType(classNode)) {
mv.visitFieldInsn(
GETSTATIC,
getClassInternalName(ClassHelper.getWrapper(classNode)),
"TYPE",
"Ljava/lang/Class;");
} else {
mv.visitLdcInsn(org.objectweb.asm.Type.getType(getTypeDescription(classNode)));
}
} | [
"public",
"static",
"void",
"visitClassLiteral",
"(",
"MethodVisitor",
"mv",
",",
"ClassNode",
"classNode",
")",
"{",
"if",
"(",
"ClassHelper",
".",
"isPrimitiveType",
"(",
"classNode",
")",
")",
"{",
"mv",
".",
"visitFieldInsn",
"(",
"GETSTATIC",
",",
"getClassInternalName",
"(",
"ClassHelper",
".",
"getWrapper",
"(",
"classNode",
")",
")",
",",
"\"TYPE\"",
",",
"\"Ljava/lang/Class;\"",
")",
";",
"}",
"else",
"{",
"mv",
".",
"visitLdcInsn",
"(",
"org",
".",
"objectweb",
".",
"asm",
".",
"Type",
".",
"getType",
"(",
"getTypeDescription",
"(",
"classNode",
")",
")",
")",
";",
"}",
"}"
] | Visits a class literal. If the type of the classnode is a primitive type,
the generated bytecode will be a GETSTATIC Integer.TYPE.
If the classnode is not a primitive type, we will generate a LDC instruction. | [
"Visits",
"a",
"class",
"literal",
".",
"If",
"the",
"type",
"of",
"the",
"classnode",
"is",
"a",
"primitive",
"type",
"the",
"generated",
"bytecode",
"will",
"be",
"a",
"GETSTATIC",
"Integer",
".",
"TYPE",
".",
"If",
"the",
"classnode",
"is",
"not",
"a",
"primitive",
"type",
"we",
"will",
"generate",
"a",
"LDC",
"instruction",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/classgen/asm/BytecodeHelper.java#L532-L542 |
springfox/springfox | springfox-core/src/main/java/springfox/documentation/schema/AlternateTypeRules.java | AlternateTypeRules.newRule | public static AlternateTypeRule newRule(Type original, Type alternate, int order) {
"""
Helper method to create a new alternate rule.
@param original the original
@param alternate the alternate
@param order the order in which the rule is applied. {@link org.springframework.core.Ordered}
@return the alternate type rule
"""
TypeResolver resolver = new TypeResolver();
return new AlternateTypeRule(resolver.resolve(original), resolver.resolve(alternate), order);
} | java | public static AlternateTypeRule newRule(Type original, Type alternate, int order) {
TypeResolver resolver = new TypeResolver();
return new AlternateTypeRule(resolver.resolve(original), resolver.resolve(alternate), order);
} | [
"public",
"static",
"AlternateTypeRule",
"newRule",
"(",
"Type",
"original",
",",
"Type",
"alternate",
",",
"int",
"order",
")",
"{",
"TypeResolver",
"resolver",
"=",
"new",
"TypeResolver",
"(",
")",
";",
"return",
"new",
"AlternateTypeRule",
"(",
"resolver",
".",
"resolve",
"(",
"original",
")",
",",
"resolver",
".",
"resolve",
"(",
"alternate",
")",
",",
"order",
")",
";",
"}"
] | Helper method to create a new alternate rule.
@param original the original
@param alternate the alternate
@param order the order in which the rule is applied. {@link org.springframework.core.Ordered}
@return the alternate type rule | [
"Helper",
"method",
"to",
"create",
"a",
"new",
"alternate",
"rule",
"."
] | train | https://github.com/springfox/springfox/blob/e40e2d6f4b345ffa35cd5c0ca7a12589036acaf7/springfox-core/src/main/java/springfox/documentation/schema/AlternateTypeRules.java#L56-L59 |
apache/incubator-gobblin | gobblin-utility/src/main/java/org/apache/gobblin/util/ParallelRunner.java | ParallelRunner.deletePath | public void deletePath(final Path path, final boolean recursive) {
"""
Delete a {@link Path}.
<p>
This method submits a task to delete a {@link Path} and returns immediately
after the task is submitted.
</p>
@param path path to be deleted.
"""
this.futures.add(new NamedFuture(this.executor.submit(new Callable<Void>() {
@Override
public Void call() throws Exception {
Lock lock = ParallelRunner.this.locks.get(path.toString());
lock.lock();
try {
HadoopUtils.deletePath(ParallelRunner.this.fs, path, recursive);
return null;
} finally {
lock.unlock();
}
}
}), "Delete path " + path));
} | java | public void deletePath(final Path path, final boolean recursive) {
this.futures.add(new NamedFuture(this.executor.submit(new Callable<Void>() {
@Override
public Void call() throws Exception {
Lock lock = ParallelRunner.this.locks.get(path.toString());
lock.lock();
try {
HadoopUtils.deletePath(ParallelRunner.this.fs, path, recursive);
return null;
} finally {
lock.unlock();
}
}
}), "Delete path " + path));
} | [
"public",
"void",
"deletePath",
"(",
"final",
"Path",
"path",
",",
"final",
"boolean",
"recursive",
")",
"{",
"this",
".",
"futures",
".",
"add",
"(",
"new",
"NamedFuture",
"(",
"this",
".",
"executor",
".",
"submit",
"(",
"new",
"Callable",
"<",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
")",
"throws",
"Exception",
"{",
"Lock",
"lock",
"=",
"ParallelRunner",
".",
"this",
".",
"locks",
".",
"get",
"(",
"path",
".",
"toString",
"(",
")",
")",
";",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"HadoopUtils",
".",
"deletePath",
"(",
"ParallelRunner",
".",
"this",
".",
"fs",
",",
"path",
",",
"recursive",
")",
";",
"return",
"null",
";",
"}",
"finally",
"{",
"lock",
".",
"unlock",
"(",
")",
";",
"}",
"}",
"}",
")",
",",
"\"Delete path \"",
"+",
"path",
")",
")",
";",
"}"
] | Delete a {@link Path}.
<p>
This method submits a task to delete a {@link Path} and returns immediately
after the task is submitted.
</p>
@param path path to be deleted. | [
"Delete",
"a",
"{",
"@link",
"Path",
"}",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/ParallelRunner.java#L231-L245 |
ngageoint/geopackage-core-java | src/main/java/mil/nga/geopackage/core/contents/ContentsDao.java | ContentsDao.deleteByIdCascade | public int deleteByIdCascade(String id, boolean userTable)
throws SQLException {
"""
Delete a Contents by id, cascading optionally including the user table
@param id
id
@param userTable
true if a user table
@return deleted count
@throws SQLException
upon deletion error
"""
int count = 0;
if (id != null) {
Contents contents = queryForId(id);
if (contents != null) {
count = deleteCascade(contents, userTable);
} else if (userTable) {
dropTable(id);
}
}
return count;
} | java | public int deleteByIdCascade(String id, boolean userTable)
throws SQLException {
int count = 0;
if (id != null) {
Contents contents = queryForId(id);
if (contents != null) {
count = deleteCascade(contents, userTable);
} else if (userTable) {
dropTable(id);
}
}
return count;
} | [
"public",
"int",
"deleteByIdCascade",
"(",
"String",
"id",
",",
"boolean",
"userTable",
")",
"throws",
"SQLException",
"{",
"int",
"count",
"=",
"0",
";",
"if",
"(",
"id",
"!=",
"null",
")",
"{",
"Contents",
"contents",
"=",
"queryForId",
"(",
"id",
")",
";",
"if",
"(",
"contents",
"!=",
"null",
")",
"{",
"count",
"=",
"deleteCascade",
"(",
"contents",
",",
"userTable",
")",
";",
"}",
"else",
"if",
"(",
"userTable",
")",
"{",
"dropTable",
"(",
"id",
")",
";",
"}",
"}",
"return",
"count",
";",
"}"
] | Delete a Contents by id, cascading optionally including the user table
@param id
id
@param userTable
true if a user table
@return deleted count
@throws SQLException
upon deletion error | [
"Delete",
"a",
"Contents",
"by",
"id",
"cascading",
"optionally",
"including",
"the",
"user",
"table"
] | train | https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/core/contents/ContentsDao.java#L463-L475 |
jenkinsci/java-client-api | jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildWithDetails.java | BuildWithDetails.updateDisplayNameAndDescription | public BuildWithDetails updateDisplayNameAndDescription(String displayName, String description, boolean crumbFlag)
throws IOException {
"""
Update <code>displayName</code> and the <code>description</code> of a
build.
@param displayName The new displayName which should be set.
@param description The description which should be set.
@param crumbFlag <code>true</code> or <code>false</code>.
@throws IOException in case of errors.
"""
Objects.requireNonNull(displayName, "displayName is not allowed to be null.");
Objects.requireNonNull(description, "description is not allowed to be null.");
//TODO:JDK9+ Map.of()...
Map<String, String> params = new HashMap<>();
params.put("displayName", displayName);
params.put("description", description);
// TODO: Check what the "core:apply" means?
params.put("core:apply", "");
params.put("Submit", "Save");
client.post_form(this.getUrl() + "/configSubmit?", params, crumbFlag);
return this;
} | java | public BuildWithDetails updateDisplayNameAndDescription(String displayName, String description, boolean crumbFlag)
throws IOException {
Objects.requireNonNull(displayName, "displayName is not allowed to be null.");
Objects.requireNonNull(description, "description is not allowed to be null.");
//TODO:JDK9+ Map.of()...
Map<String, String> params = new HashMap<>();
params.put("displayName", displayName);
params.put("description", description);
// TODO: Check what the "core:apply" means?
params.put("core:apply", "");
params.put("Submit", "Save");
client.post_form(this.getUrl() + "/configSubmit?", params, crumbFlag);
return this;
} | [
"public",
"BuildWithDetails",
"updateDisplayNameAndDescription",
"(",
"String",
"displayName",
",",
"String",
"description",
",",
"boolean",
"crumbFlag",
")",
"throws",
"IOException",
"{",
"Objects",
".",
"requireNonNull",
"(",
"displayName",
",",
"\"displayName is not allowed to be null.\"",
")",
";",
"Objects",
".",
"requireNonNull",
"(",
"description",
",",
"\"description is not allowed to be null.\"",
")",
";",
"//TODO:JDK9+ Map.of()...",
"Map",
"<",
"String",
",",
"String",
">",
"params",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"params",
".",
"put",
"(",
"\"displayName\"",
",",
"displayName",
")",
";",
"params",
".",
"put",
"(",
"\"description\"",
",",
"description",
")",
";",
"// TODO: Check what the \"core:apply\" means?",
"params",
".",
"put",
"(",
"\"core:apply\"",
",",
"\"\"",
")",
";",
"params",
".",
"put",
"(",
"\"Submit\"",
",",
"\"Save\"",
")",
";",
"client",
".",
"post_form",
"(",
"this",
".",
"getUrl",
"(",
")",
"+",
"\"/configSubmit?\"",
",",
"params",
",",
"crumbFlag",
")",
";",
"return",
"this",
";",
"}"
] | Update <code>displayName</code> and the <code>description</code> of a
build.
@param displayName The new displayName which should be set.
@param description The description which should be set.
@param crumbFlag <code>true</code> or <code>false</code>.
@throws IOException in case of errors. | [
"Update",
"<code",
">",
"displayName<",
"/",
"code",
">",
"and",
"the",
"<code",
">",
"description<",
"/",
"code",
">",
"of",
"a",
"build",
"."
] | train | https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildWithDetails.java#L181-L194 |
xvik/guice-persist-orient | src/main/java/ru/vyarus/guice/persist/orient/db/PersistentContext.java | PersistentContext.doWithoutTransaction | public <T> T doWithoutTransaction(final SpecificTxAction<T, C> action) {
"""
Execute action without transaction.
<p>
NOTE: If normal transaction already started, error will be thrown to prevent confusion
(direct call to template will ignore notx config in case of ongoing transaction, so this call is safer)
@param action action to execute within transaction (new or ongoing)
@param <T> expected return type
@return value produced by action
@see ru.vyarus.guice.persist.orient.db.transaction.template.SpecificTxTemplate
"""
checkNotx();
return template.doInTransaction(new TxConfig(OTransaction.TXTYPE.NOTX), action);
} | java | public <T> T doWithoutTransaction(final SpecificTxAction<T, C> action) {
checkNotx();
return template.doInTransaction(new TxConfig(OTransaction.TXTYPE.NOTX), action);
} | [
"public",
"<",
"T",
">",
"T",
"doWithoutTransaction",
"(",
"final",
"SpecificTxAction",
"<",
"T",
",",
"C",
">",
"action",
")",
"{",
"checkNotx",
"(",
")",
";",
"return",
"template",
".",
"doInTransaction",
"(",
"new",
"TxConfig",
"(",
"OTransaction",
".",
"TXTYPE",
".",
"NOTX",
")",
",",
"action",
")",
";",
"}"
] | Execute action without transaction.
<p>
NOTE: If normal transaction already started, error will be thrown to prevent confusion
(direct call to template will ignore notx config in case of ongoing transaction, so this call is safer)
@param action action to execute within transaction (new or ongoing)
@param <T> expected return type
@return value produced by action
@see ru.vyarus.guice.persist.orient.db.transaction.template.SpecificTxTemplate | [
"Execute",
"action",
"without",
"transaction",
".",
"<p",
">",
"NOTE",
":",
"If",
"normal",
"transaction",
"already",
"started",
"error",
"will",
"be",
"thrown",
"to",
"prevent",
"confusion",
"(",
"direct",
"call",
"to",
"template",
"will",
"ignore",
"notx",
"config",
"in",
"case",
"of",
"ongoing",
"transaction",
"so",
"this",
"call",
"is",
"safer",
")"
] | train | https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/db/PersistentContext.java#L161-L164 |
czyzby/gdx-lml | lml/src/main/java/com/github/czyzby/lml/util/LmlUtilities.java | LmlUtilities.toRangeArrayArgument | public static String toRangeArrayArgument(final Object base, final int rangeStart, final int rangeEnd) {
"""
Warning: uses default LML syntax. Will not work if you modified any LML markers.
@param base base of the range. Can be null - range will not have a base and will iterate solely over numbers.
@param rangeStart start of range. Can be negative. Does not have to be lower than end - if start is bigger, range
is iterating from bigger to lower values.
@param rangeEnd end of range. Can be negative.
@return range is format: base + rangeOpening + start + separator + end + rangeClosing. For example,
"base[4,2]".
"""
return Nullables.toString(base, Strings.EMPTY_STRING) + '[' + rangeStart + ',' + rangeEnd + ']';
} | java | public static String toRangeArrayArgument(final Object base, final int rangeStart, final int rangeEnd) {
return Nullables.toString(base, Strings.EMPTY_STRING) + '[' + rangeStart + ',' + rangeEnd + ']';
} | [
"public",
"static",
"String",
"toRangeArrayArgument",
"(",
"final",
"Object",
"base",
",",
"final",
"int",
"rangeStart",
",",
"final",
"int",
"rangeEnd",
")",
"{",
"return",
"Nullables",
".",
"toString",
"(",
"base",
",",
"Strings",
".",
"EMPTY_STRING",
")",
"+",
"'",
"'",
"+",
"rangeStart",
"+",
"'",
"'",
"+",
"rangeEnd",
"+",
"'",
"'",
";",
"}"
] | Warning: uses default LML syntax. Will not work if you modified any LML markers.
@param base base of the range. Can be null - range will not have a base and will iterate solely over numbers.
@param rangeStart start of range. Can be negative. Does not have to be lower than end - if start is bigger, range
is iterating from bigger to lower values.
@param rangeEnd end of range. Can be negative.
@return range is format: base + rangeOpening + start + separator + end + rangeClosing. For example,
"base[4,2]". | [
"Warning",
":",
"uses",
"default",
"LML",
"syntax",
".",
"Will",
"not",
"work",
"if",
"you",
"modified",
"any",
"LML",
"markers",
"."
] | train | https://github.com/czyzby/gdx-lml/blob/7623b322e6afe49ad4dd636c80c230150a1cfa4e/lml/src/main/java/com/github/czyzby/lml/util/LmlUtilities.java#L483-L485 |
threerings/narya | core/src/main/java/com/threerings/presents/peer/server/PeerManager.java | PeerManager.performWithLock | public void performWithLock (final NodeObject.Lock lock, final LockedOperation operation) {
"""
Tries to acquire the resource lock and, if successful, performs the operation and releases
the lock; if unsuccessful, calls the operation's failure handler. Please note: the lock will
be released immediately after the operation.
"""
acquireLock(lock, new ResultListener<String>() {
public void requestCompleted (String nodeName) {
if (getNodeObject().nodeName.equals(nodeName)) {
// lock acquired successfully - perform the operation, and release the lock.
try {
operation.run();
} finally {
releaseLock(lock, new ResultListener.NOOP<String>());
}
} else {
// some other peer beat us to it
operation.fail(nodeName);
if (nodeName == null) {
log.warning("Lock acquired by null?", "lock", lock);
}
}
}
public void requestFailed (Exception cause) {
log.warning("Lock acquisition failed", "lock", lock, cause);
operation.fail(null);
}
});
} | java | public void performWithLock (final NodeObject.Lock lock, final LockedOperation operation)
{
acquireLock(lock, new ResultListener<String>() {
public void requestCompleted (String nodeName) {
if (getNodeObject().nodeName.equals(nodeName)) {
// lock acquired successfully - perform the operation, and release the lock.
try {
operation.run();
} finally {
releaseLock(lock, new ResultListener.NOOP<String>());
}
} else {
// some other peer beat us to it
operation.fail(nodeName);
if (nodeName == null) {
log.warning("Lock acquired by null?", "lock", lock);
}
}
}
public void requestFailed (Exception cause) {
log.warning("Lock acquisition failed", "lock", lock, cause);
operation.fail(null);
}
});
} | [
"public",
"void",
"performWithLock",
"(",
"final",
"NodeObject",
".",
"Lock",
"lock",
",",
"final",
"LockedOperation",
"operation",
")",
"{",
"acquireLock",
"(",
"lock",
",",
"new",
"ResultListener",
"<",
"String",
">",
"(",
")",
"{",
"public",
"void",
"requestCompleted",
"(",
"String",
"nodeName",
")",
"{",
"if",
"(",
"getNodeObject",
"(",
")",
".",
"nodeName",
".",
"equals",
"(",
"nodeName",
")",
")",
"{",
"// lock acquired successfully - perform the operation, and release the lock.",
"try",
"{",
"operation",
".",
"run",
"(",
")",
";",
"}",
"finally",
"{",
"releaseLock",
"(",
"lock",
",",
"new",
"ResultListener",
".",
"NOOP",
"<",
"String",
">",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"// some other peer beat us to it",
"operation",
".",
"fail",
"(",
"nodeName",
")",
";",
"if",
"(",
"nodeName",
"==",
"null",
")",
"{",
"log",
".",
"warning",
"(",
"\"Lock acquired by null?\"",
",",
"\"lock\"",
",",
"lock",
")",
";",
"}",
"}",
"}",
"public",
"void",
"requestFailed",
"(",
"Exception",
"cause",
")",
"{",
"log",
".",
"warning",
"(",
"\"Lock acquisition failed\"",
",",
"\"lock\"",
",",
"lock",
",",
"cause",
")",
";",
"operation",
".",
"fail",
"(",
"null",
")",
";",
"}",
"}",
")",
";",
"}"
] | Tries to acquire the resource lock and, if successful, performs the operation and releases
the lock; if unsuccessful, calls the operation's failure handler. Please note: the lock will
be released immediately after the operation. | [
"Tries",
"to",
"acquire",
"the",
"resource",
"lock",
"and",
"if",
"successful",
"performs",
"the",
"operation",
"and",
"releases",
"the",
"lock",
";",
"if",
"unsuccessful",
"calls",
"the",
"operation",
"s",
"failure",
"handler",
".",
"Please",
"note",
":",
"the",
"lock",
"will",
"be",
"released",
"immediately",
"after",
"the",
"operation",
"."
] | train | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/peer/server/PeerManager.java#L908-L932 |
kaazing/gateway | transport/spi/src/main/java/org/kaazing/gateway/transport/LoggingUtils.java | LoggingUtils.addSession | public static String addSession(String message, IoSession session) {
"""
Prepends short session details (result of getId) for the session in square brackets to the message.
@param message the message to be logged
@param session an instance of IoSessionEx
@return example: "[wsn#34 127.0.0.0.1:41234] this is the log message"
"""
return format("[%s] %s", getId(session), message);
} | java | public static String addSession(String message, IoSession session) {
return format("[%s] %s", getId(session), message);
} | [
"public",
"static",
"String",
"addSession",
"(",
"String",
"message",
",",
"IoSession",
"session",
")",
"{",
"return",
"format",
"(",
"\"[%s] %s\"",
",",
"getId",
"(",
"session",
")",
",",
"message",
")",
";",
"}"
] | Prepends short session details (result of getId) for the session in square brackets to the message.
@param message the message to be logged
@param session an instance of IoSessionEx
@return example: "[wsn#34 127.0.0.0.1:41234] this is the log message" | [
"Prepends",
"short",
"session",
"details",
"(",
"result",
"of",
"getId",
")",
"for",
"the",
"session",
"in",
"square",
"brackets",
"to",
"the",
"message",
"."
] | train | https://github.com/kaazing/gateway/blob/06017b19273109b3b992e528e702586446168d57/transport/spi/src/main/java/org/kaazing/gateway/transport/LoggingUtils.java#L55-L57 |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/alg/denoise/wavelet/SubbandShrink.java | SubbandShrink.performShrinkage | protected void performShrinkage( I transform , int numLevels ) {
"""
Performs wavelet shrinking using the specified rule and by computing a threshold
for each subband.
@param transform The image being transformed.
@param numLevels Number of levels in the transform.
"""
// step through each layer in the pyramid.
for( int i = 0; i < numLevels; i++ ) {
int w = transform.width;
int h = transform.height;
int ww = w/2;
int hh = h/2;
Number threshold;
I subband;
// HL
subband = transform.subimage(ww,0,w,hh, null);
threshold = computeThreshold(subband);
rule.process(subband,threshold);
// System.out.print("HL = "+threshold);
// LH
subband = transform.subimage(0,hh,ww,h, null);
threshold = computeThreshold(subband);
rule.process(subband,threshold);
// System.out.print(" LH = "+threshold);
// HH
subband = transform.subimage(ww,hh,w,h, null);
threshold = computeThreshold(subband);
rule.process(subband,threshold);
// System.out.println(" HH = "+threshold);
transform = transform.subimage(0,0,ww,hh, null);
}
} | java | protected void performShrinkage( I transform , int numLevels ) {
// step through each layer in the pyramid.
for( int i = 0; i < numLevels; i++ ) {
int w = transform.width;
int h = transform.height;
int ww = w/2;
int hh = h/2;
Number threshold;
I subband;
// HL
subband = transform.subimage(ww,0,w,hh, null);
threshold = computeThreshold(subband);
rule.process(subband,threshold);
// System.out.print("HL = "+threshold);
// LH
subband = transform.subimage(0,hh,ww,h, null);
threshold = computeThreshold(subband);
rule.process(subband,threshold);
// System.out.print(" LH = "+threshold);
// HH
subband = transform.subimage(ww,hh,w,h, null);
threshold = computeThreshold(subband);
rule.process(subband,threshold);
// System.out.println(" HH = "+threshold);
transform = transform.subimage(0,0,ww,hh, null);
}
} | [
"protected",
"void",
"performShrinkage",
"(",
"I",
"transform",
",",
"int",
"numLevels",
")",
"{",
"// step through each layer in the pyramid.",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"numLevels",
";",
"i",
"++",
")",
"{",
"int",
"w",
"=",
"transform",
".",
"width",
";",
"int",
"h",
"=",
"transform",
".",
"height",
";",
"int",
"ww",
"=",
"w",
"/",
"2",
";",
"int",
"hh",
"=",
"h",
"/",
"2",
";",
"Number",
"threshold",
";",
"I",
"subband",
";",
"// HL",
"subband",
"=",
"transform",
".",
"subimage",
"(",
"ww",
",",
"0",
",",
"w",
",",
"hh",
",",
"null",
")",
";",
"threshold",
"=",
"computeThreshold",
"(",
"subband",
")",
";",
"rule",
".",
"process",
"(",
"subband",
",",
"threshold",
")",
";",
"//\t\t\tSystem.out.print(\"HL = \"+threshold);",
"// LH",
"subband",
"=",
"transform",
".",
"subimage",
"(",
"0",
",",
"hh",
",",
"ww",
",",
"h",
",",
"null",
")",
";",
"threshold",
"=",
"computeThreshold",
"(",
"subband",
")",
";",
"rule",
".",
"process",
"(",
"subband",
",",
"threshold",
")",
";",
"//\t\t\tSystem.out.print(\" LH = \"+threshold);",
"// HH",
"subband",
"=",
"transform",
".",
"subimage",
"(",
"ww",
",",
"hh",
",",
"w",
",",
"h",
",",
"null",
")",
";",
"threshold",
"=",
"computeThreshold",
"(",
"subband",
")",
";",
"rule",
".",
"process",
"(",
"subband",
",",
"threshold",
")",
";",
"//\t\t\tSystem.out.println(\" HH = \"+threshold);",
"transform",
"=",
"transform",
".",
"subimage",
"(",
"0",
",",
"0",
",",
"ww",
",",
"hh",
",",
"null",
")",
";",
"}",
"}"
] | Performs wavelet shrinking using the specified rule and by computing a threshold
for each subband.
@param transform The image being transformed.
@param numLevels Number of levels in the transform. | [
"Performs",
"wavelet",
"shrinking",
"using",
"the",
"specified",
"rule",
"and",
"by",
"computing",
"a",
"threshold",
"for",
"each",
"subband",
"."
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/denoise/wavelet/SubbandShrink.java#L56-L91 |
javalite/activejdbc | activejdbc/src/main/java/org/javalite/activejdbc/Model.java | Model.dateFormat | protected static void dateFormat(DateFormat format, String... attributeNames) {
"""
Registers date format for specified attributes. This format will be used to convert between
Date -> String -> java.sql.Date when using the appropriate getters and setters.
<p>See example in {@link #dateFormat(String, String...)}.
@param format format to use for conversion
@param attributeNames attribute names
"""
ModelDelegate.dateFormat(modelClass(), format, attributeNames);
} | java | protected static void dateFormat(DateFormat format, String... attributeNames) {
ModelDelegate.dateFormat(modelClass(), format, attributeNames);
} | [
"protected",
"static",
"void",
"dateFormat",
"(",
"DateFormat",
"format",
",",
"String",
"...",
"attributeNames",
")",
"{",
"ModelDelegate",
".",
"dateFormat",
"(",
"modelClass",
"(",
")",
",",
"format",
",",
"attributeNames",
")",
";",
"}"
] | Registers date format for specified attributes. This format will be used to convert between
Date -> String -> java.sql.Date when using the appropriate getters and setters.
<p>See example in {@link #dateFormat(String, String...)}.
@param format format to use for conversion
@param attributeNames attribute names | [
"Registers",
"date",
"format",
"for",
"specified",
"attributes",
".",
"This",
"format",
"will",
"be",
"used",
"to",
"convert",
"between",
"Date",
"-",
">",
"String",
"-",
">",
"java",
".",
"sql",
".",
"Date",
"when",
"using",
"the",
"appropriate",
"getters",
"and",
"setters",
"."
] | train | https://github.com/javalite/activejdbc/blob/ffcf5457cace19622a8f71e856cbbbe9e7dd5fcc/activejdbc/src/main/java/org/javalite/activejdbc/Model.java#L2139-L2141 |
aalmiray/Json-lib | src/main/java/net/sf/json/JsonConfig.java | JsonConfig.registerJsonPropertyNameProcessor | public void registerJsonPropertyNameProcessor( Class target, PropertyNameProcessor propertyNameProcessor ) {
"""
Registers a PropertyNameProcessor.<br>
[Java -> JSON]
@param target the class to use as key
@param propertyNameProcessor the processor to register
"""
if( target != null && propertyNameProcessor != null ) {
jsonPropertyNameProcessorMap.put( target, propertyNameProcessor );
}
} | java | public void registerJsonPropertyNameProcessor( Class target, PropertyNameProcessor propertyNameProcessor ) {
if( target != null && propertyNameProcessor != null ) {
jsonPropertyNameProcessorMap.put( target, propertyNameProcessor );
}
} | [
"public",
"void",
"registerJsonPropertyNameProcessor",
"(",
"Class",
"target",
",",
"PropertyNameProcessor",
"propertyNameProcessor",
")",
"{",
"if",
"(",
"target",
"!=",
"null",
"&&",
"propertyNameProcessor",
"!=",
"null",
")",
"{",
"jsonPropertyNameProcessorMap",
".",
"put",
"(",
"target",
",",
"propertyNameProcessor",
")",
";",
"}",
"}"
] | Registers a PropertyNameProcessor.<br>
[Java -> JSON]
@param target the class to use as key
@param propertyNameProcessor the processor to register | [
"Registers",
"a",
"PropertyNameProcessor",
".",
"<br",
">",
"[",
"Java",
"-",
">",
";",
"JSON",
"]"
] | train | https://github.com/aalmiray/Json-lib/blob/9e2b3376ee8f511a48aa7ac05f75a7414e02280f/src/main/java/net/sf/json/JsonConfig.java#L799-L803 |
Bedework/bw-util | bw-util-misc/src/main/java/org/bedework/util/misc/Util.java | Util.fmtMsg | public static String fmtMsg(final String fmt, final String arg1, final String arg2) {
"""
Format a message consisting of a format string plus two string parameters
@param fmt
@param arg1
@param arg2
@return String formatted message
"""
Object[] o = new Object[2];
o[0] = arg1;
o[1] = arg2;
return MessageFormat.format(fmt, o);
} | java | public static String fmtMsg(final String fmt, final String arg1, final String arg2) {
Object[] o = new Object[2];
o[0] = arg1;
o[1] = arg2;
return MessageFormat.format(fmt, o);
} | [
"public",
"static",
"String",
"fmtMsg",
"(",
"final",
"String",
"fmt",
",",
"final",
"String",
"arg1",
",",
"final",
"String",
"arg2",
")",
"{",
"Object",
"[",
"]",
"o",
"=",
"new",
"Object",
"[",
"2",
"]",
";",
"o",
"[",
"0",
"]",
"=",
"arg1",
";",
"o",
"[",
"1",
"]",
"=",
"arg2",
";",
"return",
"MessageFormat",
".",
"format",
"(",
"fmt",
",",
"o",
")",
";",
"}"
] | Format a message consisting of a format string plus two string parameters
@param fmt
@param arg1
@param arg2
@return String formatted message | [
"Format",
"a",
"message",
"consisting",
"of",
"a",
"format",
"string",
"plus",
"two",
"string",
"parameters"
] | train | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-misc/src/main/java/org/bedework/util/misc/Util.java#L422-L428 |
j256/ormlite-core | src/main/java/com/j256/ormlite/table/TableUtils.java | TableUtils.getCreateTableStatements | public static <T, ID> List<String> getCreateTableStatements(ConnectionSource connectionSource,
DatabaseTableConfig<T> tableConfig) throws SQLException {
"""
Return an list of SQL statements that need to be run to create a table. To do the work of creating, you should
call {@link #createTable}.
@param connectionSource
Our connect source which is used to get the database type, not to apply the creates.
@param tableConfig
Hand or spring wired table configuration. If null then the class must have {@link DatabaseField}
annotations.
@return The list of table create statements.
"""
Dao<T, ID> dao = DaoManager.createDao(connectionSource, tableConfig);
DatabaseType databaseType = connectionSource.getDatabaseType();
if (dao instanceof BaseDaoImpl<?, ?>) {
return addCreateTableStatements(databaseType, ((BaseDaoImpl<?, ?>) dao).getTableInfo(), false, false);
} else {
tableConfig.extractFieldTypes(databaseType);
TableInfo<T, ID> tableInfo = new TableInfo<T, ID>(databaseType, tableConfig);
return addCreateTableStatements(databaseType, tableInfo, false, false);
}
} | java | public static <T, ID> List<String> getCreateTableStatements(ConnectionSource connectionSource,
DatabaseTableConfig<T> tableConfig) throws SQLException {
Dao<T, ID> dao = DaoManager.createDao(connectionSource, tableConfig);
DatabaseType databaseType = connectionSource.getDatabaseType();
if (dao instanceof BaseDaoImpl<?, ?>) {
return addCreateTableStatements(databaseType, ((BaseDaoImpl<?, ?>) dao).getTableInfo(), false, false);
} else {
tableConfig.extractFieldTypes(databaseType);
TableInfo<T, ID> tableInfo = new TableInfo<T, ID>(databaseType, tableConfig);
return addCreateTableStatements(databaseType, tableInfo, false, false);
}
} | [
"public",
"static",
"<",
"T",
",",
"ID",
">",
"List",
"<",
"String",
">",
"getCreateTableStatements",
"(",
"ConnectionSource",
"connectionSource",
",",
"DatabaseTableConfig",
"<",
"T",
">",
"tableConfig",
")",
"throws",
"SQLException",
"{",
"Dao",
"<",
"T",
",",
"ID",
">",
"dao",
"=",
"DaoManager",
".",
"createDao",
"(",
"connectionSource",
",",
"tableConfig",
")",
";",
"DatabaseType",
"databaseType",
"=",
"connectionSource",
".",
"getDatabaseType",
"(",
")",
";",
"if",
"(",
"dao",
"instanceof",
"BaseDaoImpl",
"<",
"?",
",",
"?",
">",
")",
"{",
"return",
"addCreateTableStatements",
"(",
"databaseType",
",",
"(",
"(",
"BaseDaoImpl",
"<",
"?",
",",
"?",
">",
")",
"dao",
")",
".",
"getTableInfo",
"(",
")",
",",
"false",
",",
"false",
")",
";",
"}",
"else",
"{",
"tableConfig",
".",
"extractFieldTypes",
"(",
"databaseType",
")",
";",
"TableInfo",
"<",
"T",
",",
"ID",
">",
"tableInfo",
"=",
"new",
"TableInfo",
"<",
"T",
",",
"ID",
">",
"(",
"databaseType",
",",
"tableConfig",
")",
";",
"return",
"addCreateTableStatements",
"(",
"databaseType",
",",
"tableInfo",
",",
"false",
",",
"false",
")",
";",
"}",
"}"
] | Return an list of SQL statements that need to be run to create a table. To do the work of creating, you should
call {@link #createTable}.
@param connectionSource
Our connect source which is used to get the database type, not to apply the creates.
@param tableConfig
Hand or spring wired table configuration. If null then the class must have {@link DatabaseField}
annotations.
@return The list of table create statements. | [
"Return",
"an",
"list",
"of",
"SQL",
"statements",
"that",
"need",
"to",
"be",
"run",
"to",
"create",
"a",
"table",
".",
"To",
"do",
"the",
"work",
"of",
"creating",
"you",
"should",
"call",
"{",
"@link",
"#createTable",
"}",
"."
] | train | https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/table/TableUtils.java#L123-L134 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.