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
listlengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
listlengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
gallandarakhneorg/afc
|
core/vmutils/src/main/java/org/arakhne/afc/vmutil/FileSystem.java
|
FileSystem.unzipFile
|
public static void unzipFile(InputStream input, File output) throws IOException {
"""
Unzip the given stream and write out the file in the output.
If the input file is a directory, the content of the directory is zipped.
If the input file is a standard file, it is zipped.
@param input the ZIP file to uncompress.
@param output the uncompressed file to create.
@throws IOException when uncompressing is failing.
@since 6.2
"""
if (output == null) {
return;
}
output.mkdirs();
if (!output.isDirectory()) {
throw new IOException(Locale.getString("E3", output)); //$NON-NLS-1$
}
try (ZipInputStream zis = new ZipInputStream(input)) {
final byte[] buffer = new byte[BUFFER_SIZE];
int len;
ZipEntry zipEntry = zis.getNextEntry();
while (zipEntry != null) {
final String name = zipEntry.getName();
final File outFile = new File(output, name).getCanonicalFile();
if (zipEntry.isDirectory()) {
outFile.mkdirs();
} else {
outFile.getParentFile().mkdirs();
try (FileOutputStream fos = new FileOutputStream(outFile)) {
while ((len = zis.read(buffer)) > 0) {
fos.write(buffer, 0, len);
}
}
}
zipEntry = zis.getNextEntry();
}
}
}
|
java
|
public static void unzipFile(InputStream input, File output) throws IOException {
if (output == null) {
return;
}
output.mkdirs();
if (!output.isDirectory()) {
throw new IOException(Locale.getString("E3", output)); //$NON-NLS-1$
}
try (ZipInputStream zis = new ZipInputStream(input)) {
final byte[] buffer = new byte[BUFFER_SIZE];
int len;
ZipEntry zipEntry = zis.getNextEntry();
while (zipEntry != null) {
final String name = zipEntry.getName();
final File outFile = new File(output, name).getCanonicalFile();
if (zipEntry.isDirectory()) {
outFile.mkdirs();
} else {
outFile.getParentFile().mkdirs();
try (FileOutputStream fos = new FileOutputStream(outFile)) {
while ((len = zis.read(buffer)) > 0) {
fos.write(buffer, 0, len);
}
}
}
zipEntry = zis.getNextEntry();
}
}
}
|
[
"public",
"static",
"void",
"unzipFile",
"(",
"InputStream",
"input",
",",
"File",
"output",
")",
"throws",
"IOException",
"{",
"if",
"(",
"output",
"==",
"null",
")",
"{",
"return",
";",
"}",
"output",
".",
"mkdirs",
"(",
")",
";",
"if",
"(",
"!",
"output",
".",
"isDirectory",
"(",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"Locale",
".",
"getString",
"(",
"\"E3\"",
",",
"output",
")",
")",
";",
"//$NON-NLS-1$",
"}",
"try",
"(",
"ZipInputStream",
"zis",
"=",
"new",
"ZipInputStream",
"(",
"input",
")",
")",
"{",
"final",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"BUFFER_SIZE",
"]",
";",
"int",
"len",
";",
"ZipEntry",
"zipEntry",
"=",
"zis",
".",
"getNextEntry",
"(",
")",
";",
"while",
"(",
"zipEntry",
"!=",
"null",
")",
"{",
"final",
"String",
"name",
"=",
"zipEntry",
".",
"getName",
"(",
")",
";",
"final",
"File",
"outFile",
"=",
"new",
"File",
"(",
"output",
",",
"name",
")",
".",
"getCanonicalFile",
"(",
")",
";",
"if",
"(",
"zipEntry",
".",
"isDirectory",
"(",
")",
")",
"{",
"outFile",
".",
"mkdirs",
"(",
")",
";",
"}",
"else",
"{",
"outFile",
".",
"getParentFile",
"(",
")",
".",
"mkdirs",
"(",
")",
";",
"try",
"(",
"FileOutputStream",
"fos",
"=",
"new",
"FileOutputStream",
"(",
"outFile",
")",
")",
"{",
"while",
"(",
"(",
"len",
"=",
"zis",
".",
"read",
"(",
"buffer",
")",
")",
">",
"0",
")",
"{",
"fos",
".",
"write",
"(",
"buffer",
",",
"0",
",",
"len",
")",
";",
"}",
"}",
"}",
"zipEntry",
"=",
"zis",
".",
"getNextEntry",
"(",
")",
";",
"}",
"}",
"}"
] |
Unzip the given stream and write out the file in the output.
If the input file is a directory, the content of the directory is zipped.
If the input file is a standard file, it is zipped.
@param input the ZIP file to uncompress.
@param output the uncompressed file to create.
@throws IOException when uncompressing is failing.
@since 6.2
|
[
"Unzip",
"the",
"given",
"stream",
"and",
"write",
"out",
"the",
"file",
"in",
"the",
"output",
".",
"If",
"the",
"input",
"file",
"is",
"a",
"directory",
"the",
"content",
"of",
"the",
"directory",
"is",
"zipped",
".",
"If",
"the",
"input",
"file",
"is",
"a",
"standard",
"file",
"it",
"is",
"zipped",
"."
] |
train
|
https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/FileSystem.java#L3002-L3031
|
Wadpam/guja
|
guja-core/src/main/java/com/wadpam/guja/oauth2/dao/GeneratedDUserDaoImpl.java
|
GeneratedDUserDaoImpl.queryByCreatedBy
|
public Iterable<DUser> queryByCreatedBy(java.lang.String createdBy) {
"""
query-by method for field createdBy
@param createdBy the specified attribute
@return an Iterable of DUsers for the specified createdBy
"""
return queryByField(null, DUserMapper.Field.CREATEDBY.getFieldName(), createdBy);
}
|
java
|
public Iterable<DUser> queryByCreatedBy(java.lang.String createdBy) {
return queryByField(null, DUserMapper.Field.CREATEDBY.getFieldName(), createdBy);
}
|
[
"public",
"Iterable",
"<",
"DUser",
">",
"queryByCreatedBy",
"(",
"java",
".",
"lang",
".",
"String",
"createdBy",
")",
"{",
"return",
"queryByField",
"(",
"null",
",",
"DUserMapper",
".",
"Field",
".",
"CREATEDBY",
".",
"getFieldName",
"(",
")",
",",
"createdBy",
")",
";",
"}"
] |
query-by method for field createdBy
@param createdBy the specified attribute
@return an Iterable of DUsers for the specified createdBy
|
[
"query",
"-",
"by",
"method",
"for",
"field",
"createdBy"
] |
train
|
https://github.com/Wadpam/guja/blob/eb8ba8e6794a96ea0dd9744cada4f9ad9618f114/guja-core/src/main/java/com/wadpam/guja/oauth2/dao/GeneratedDUserDaoImpl.java#L115-L117
|
alkacon/opencms-core
|
src-gwt/org/opencms/gwt/client/ui/input/location/CmsLocationSuggestOracle.java
|
CmsLocationSuggestOracle.addSuggestion
|
private static void addSuggestion(List<LocationSuggestion> suggestions, String address) {
"""
Adds a location suggestion to the list.<p>
@param suggestions the suggestions list
@param address the address
"""
suggestions.add(new LocationSuggestion(address));
}
|
java
|
private static void addSuggestion(List<LocationSuggestion> suggestions, String address) {
suggestions.add(new LocationSuggestion(address));
}
|
[
"private",
"static",
"void",
"addSuggestion",
"(",
"List",
"<",
"LocationSuggestion",
">",
"suggestions",
",",
"String",
"address",
")",
"{",
"suggestions",
".",
"add",
"(",
"new",
"LocationSuggestion",
"(",
"address",
")",
")",
";",
"}"
] |
Adds a location suggestion to the list.<p>
@param suggestions the suggestions list
@param address the address
|
[
"Adds",
"a",
"location",
"suggestion",
"to",
"the",
"list",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/gwt/client/ui/input/location/CmsLocationSuggestOracle.java#L99-L102
|
FasterXML/woodstox
|
src/main/java/com/ctc/wstx/dtd/DTDSubsetImpl.java
|
DTDSubsetImpl.combineElements
|
private void combineElements(InputProblemReporter rep, HashMap<PrefixedName,DTDElement> intElems, HashMap<PrefixedName,DTDElement> extElems)
throws XMLStreamException {
"""
Method that will try to merge in elements defined in the external
subset, into internal subset; it will also check for redeclarations
when doing this, as it's invalid to redeclare elements. Care has to
be taken to only check actual redeclarations: placeholders should
not cause problems.
"""
for (Map.Entry<PrefixedName,DTDElement> me : extElems.entrySet()) {
PrefixedName key = me.getKey();
DTDElement extElem = me.getValue();
DTDElement intElem = intElems.get(key);
// If there was no old value, can just merge new one in and continue
if (intElem == null) {
intElems.put(key, extElem);
continue;
}
// Which one is defined (if either)?
if (extElem.isDefined()) { // one from the ext subset
if (intElem.isDefined()) { // but both can't be; that's an error
throwElementException(intElem, extElem.getLocation());
} else {
/* Note: can/should not modify the external element (by
* for example adding attributes); external element may
* be cached and shared... so, need to do the reverse,
* define the one from internal subset.
*/
intElem.defineFrom(rep, extElem, mFullyValidating);
}
} else {
if (!intElem.isDefined()) {
/* ??? Should we warn about neither of them being really
* declared?
*/
rep.reportProblem(intElem.getLocation(),
ErrorConsts.WT_ENT_DECL,
ErrorConsts.W_UNDEFINED_ELEM,
extElem.getDisplayName(), null);
} else {
intElem.mergeMissingAttributesFrom(rep, extElem, mFullyValidating);
}
}
}
}
|
java
|
private void combineElements(InputProblemReporter rep, HashMap<PrefixedName,DTDElement> intElems, HashMap<PrefixedName,DTDElement> extElems)
throws XMLStreamException
{
for (Map.Entry<PrefixedName,DTDElement> me : extElems.entrySet()) {
PrefixedName key = me.getKey();
DTDElement extElem = me.getValue();
DTDElement intElem = intElems.get(key);
// If there was no old value, can just merge new one in and continue
if (intElem == null) {
intElems.put(key, extElem);
continue;
}
// Which one is defined (if either)?
if (extElem.isDefined()) { // one from the ext subset
if (intElem.isDefined()) { // but both can't be; that's an error
throwElementException(intElem, extElem.getLocation());
} else {
/* Note: can/should not modify the external element (by
* for example adding attributes); external element may
* be cached and shared... so, need to do the reverse,
* define the one from internal subset.
*/
intElem.defineFrom(rep, extElem, mFullyValidating);
}
} else {
if (!intElem.isDefined()) {
/* ??? Should we warn about neither of them being really
* declared?
*/
rep.reportProblem(intElem.getLocation(),
ErrorConsts.WT_ENT_DECL,
ErrorConsts.W_UNDEFINED_ELEM,
extElem.getDisplayName(), null);
} else {
intElem.mergeMissingAttributesFrom(rep, extElem, mFullyValidating);
}
}
}
}
|
[
"private",
"void",
"combineElements",
"(",
"InputProblemReporter",
"rep",
",",
"HashMap",
"<",
"PrefixedName",
",",
"DTDElement",
">",
"intElems",
",",
"HashMap",
"<",
"PrefixedName",
",",
"DTDElement",
">",
"extElems",
")",
"throws",
"XMLStreamException",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"PrefixedName",
",",
"DTDElement",
">",
"me",
":",
"extElems",
".",
"entrySet",
"(",
")",
")",
"{",
"PrefixedName",
"key",
"=",
"me",
".",
"getKey",
"(",
")",
";",
"DTDElement",
"extElem",
"=",
"me",
".",
"getValue",
"(",
")",
";",
"DTDElement",
"intElem",
"=",
"intElems",
".",
"get",
"(",
"key",
")",
";",
"// If there was no old value, can just merge new one in and continue",
"if",
"(",
"intElem",
"==",
"null",
")",
"{",
"intElems",
".",
"put",
"(",
"key",
",",
"extElem",
")",
";",
"continue",
";",
"}",
"// Which one is defined (if either)?",
"if",
"(",
"extElem",
".",
"isDefined",
"(",
")",
")",
"{",
"// one from the ext subset",
"if",
"(",
"intElem",
".",
"isDefined",
"(",
")",
")",
"{",
"// but both can't be; that's an error",
"throwElementException",
"(",
"intElem",
",",
"extElem",
".",
"getLocation",
"(",
")",
")",
";",
"}",
"else",
"{",
"/* Note: can/should not modify the external element (by\n * for example adding attributes); external element may\n * be cached and shared... so, need to do the reverse,\n * define the one from internal subset.\n */",
"intElem",
".",
"defineFrom",
"(",
"rep",
",",
"extElem",
",",
"mFullyValidating",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"!",
"intElem",
".",
"isDefined",
"(",
")",
")",
"{",
"/* ??? Should we warn about neither of them being really\n * declared?\n */",
"rep",
".",
"reportProblem",
"(",
"intElem",
".",
"getLocation",
"(",
")",
",",
"ErrorConsts",
".",
"WT_ENT_DECL",
",",
"ErrorConsts",
".",
"W_UNDEFINED_ELEM",
",",
"extElem",
".",
"getDisplayName",
"(",
")",
",",
"null",
")",
";",
"}",
"else",
"{",
"intElem",
".",
"mergeMissingAttributesFrom",
"(",
"rep",
",",
"extElem",
",",
"mFullyValidating",
")",
";",
"}",
"}",
"}",
"}"
] |
Method that will try to merge in elements defined in the external
subset, into internal subset; it will also check for redeclarations
when doing this, as it's invalid to redeclare elements. Care has to
be taken to only check actual redeclarations: placeholders should
not cause problems.
|
[
"Method",
"that",
"will",
"try",
"to",
"merge",
"in",
"elements",
"defined",
"in",
"the",
"external",
"subset",
"into",
"internal",
"subset",
";",
"it",
"will",
"also",
"check",
"for",
"redeclarations",
"when",
"doing",
"this",
"as",
"it",
"s",
"invalid",
"to",
"redeclare",
"elements",
".",
"Care",
"has",
"to",
"be",
"taken",
"to",
"only",
"check",
"actual",
"redeclarations",
":",
"placeholders",
"should",
"not",
"cause",
"problems",
"."
] |
train
|
https://github.com/FasterXML/woodstox/blob/ffcaabdc06672d9564c48c25d601d029b7fd6548/src/main/java/com/ctc/wstx/dtd/DTDSubsetImpl.java#L473-L514
|
networknt/light-4j
|
utility/src/main/java/com/networknt/utility/RegExUtils.java
|
RegExUtils.replaceAll
|
public static String replaceAll(final String text, final String regex, final String replacement) {
"""
<p>Replaces each substring of the text String that matches the given regular expression
with the given replacement.</p>
This method is a {@code null} safe equivalent to:
<ul>
<li>{@code text.replaceAll(regex, replacement)}</li>
<li>{@code Pattern.compile(regex).matcher(text).replaceAll(replacement)}</li>
</ul>
<p>A {@code null} reference passed to this method is a no-op.</p>
<p>Unlike in the {@link #replacePattern(String, String, String)} method, the {@link Pattern#DOTALL} option
is NOT automatically added.
To use the DOTALL option prepend <code>"(?s)"</code> to the regex.
DOTALL is also known as single-line mode in Perl.</p>
<pre>
StringUtils.replaceAll(null, *, *) = null
StringUtils.replaceAll("any", (String) null, *) = "any"
StringUtils.replaceAll("any", *, null) = "any"
StringUtils.replaceAll("", "", "zzz") = "zzz"
StringUtils.replaceAll("", ".*", "zzz") = "zzz"
StringUtils.replaceAll("", ".+", "zzz") = ""
StringUtils.replaceAll("abc", "", "ZZ") = "ZZaZZbZZcZZ"
StringUtils.replaceAll("<__>\n<__>", "<.*>", "z") = "z\nz"
StringUtils.replaceAll("<__>\n<__>", "(?s)<.*>", "z") = "z"
StringUtils.replaceAll("ABCabc123", "[a-z]", "_") = "ABC___123"
StringUtils.replaceAll("ABCabc123", "[^A-Z0-9]+", "_") = "ABC_123"
StringUtils.replaceAll("ABCabc123", "[^A-Z0-9]+", "") = "ABC123"
StringUtils.replaceAll("Lorem ipsum dolor sit", "( +)([a-z]+)", "_$2") = "Lorem_ipsum_dolor_sit"
</pre>
@param text text to search and replace in, may be null
@param regex the regular expression to which this string is to be matched
@param replacement the string to be substituted for each match
@return the text with any replacements processed,
{@code null} if null String input
@throws java.util.regex.PatternSyntaxException
if the regular expression's syntax is invalid
@see #replacePattern(String, String, String)
@see String#replaceAll(String, String)
@see java.util.regex.Pattern
@see java.util.regex.Pattern#DOTALL
"""
if (text == null || regex == null || replacement == null) {
return text;
}
return text.replaceAll(regex, replacement);
}
|
java
|
public static String replaceAll(final String text, final String regex, final String replacement) {
if (text == null || regex == null || replacement == null) {
return text;
}
return text.replaceAll(regex, replacement);
}
|
[
"public",
"static",
"String",
"replaceAll",
"(",
"final",
"String",
"text",
",",
"final",
"String",
"regex",
",",
"final",
"String",
"replacement",
")",
"{",
"if",
"(",
"text",
"==",
"null",
"||",
"regex",
"==",
"null",
"||",
"replacement",
"==",
"null",
")",
"{",
"return",
"text",
";",
"}",
"return",
"text",
".",
"replaceAll",
"(",
"regex",
",",
"replacement",
")",
";",
"}"
] |
<p>Replaces each substring of the text String that matches the given regular expression
with the given replacement.</p>
This method is a {@code null} safe equivalent to:
<ul>
<li>{@code text.replaceAll(regex, replacement)}</li>
<li>{@code Pattern.compile(regex).matcher(text).replaceAll(replacement)}</li>
</ul>
<p>A {@code null} reference passed to this method is a no-op.</p>
<p>Unlike in the {@link #replacePattern(String, String, String)} method, the {@link Pattern#DOTALL} option
is NOT automatically added.
To use the DOTALL option prepend <code>"(?s)"</code> to the regex.
DOTALL is also known as single-line mode in Perl.</p>
<pre>
StringUtils.replaceAll(null, *, *) = null
StringUtils.replaceAll("any", (String) null, *) = "any"
StringUtils.replaceAll("any", *, null) = "any"
StringUtils.replaceAll("", "", "zzz") = "zzz"
StringUtils.replaceAll("", ".*", "zzz") = "zzz"
StringUtils.replaceAll("", ".+", "zzz") = ""
StringUtils.replaceAll("abc", "", "ZZ") = "ZZaZZbZZcZZ"
StringUtils.replaceAll("<__>\n<__>", "<.*>", "z") = "z\nz"
StringUtils.replaceAll("<__>\n<__>", "(?s)<.*>", "z") = "z"
StringUtils.replaceAll("ABCabc123", "[a-z]", "_") = "ABC___123"
StringUtils.replaceAll("ABCabc123", "[^A-Z0-9]+", "_") = "ABC_123"
StringUtils.replaceAll("ABCabc123", "[^A-Z0-9]+", "") = "ABC123"
StringUtils.replaceAll("Lorem ipsum dolor sit", "( +)([a-z]+)", "_$2") = "Lorem_ipsum_dolor_sit"
</pre>
@param text text to search and replace in, may be null
@param regex the regular expression to which this string is to be matched
@param replacement the string to be substituted for each match
@return the text with any replacements processed,
{@code null} if null String input
@throws java.util.regex.PatternSyntaxException
if the regular expression's syntax is invalid
@see #replacePattern(String, String, String)
@see String#replaceAll(String, String)
@see java.util.regex.Pattern
@see java.util.regex.Pattern#DOTALL
|
[
"<p",
">",
"Replaces",
"each",
"substring",
"of",
"the",
"text",
"String",
"that",
"matches",
"the",
"given",
"regular",
"expression",
"with",
"the",
"given",
"replacement",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/utility/src/main/java/com/networknt/utility/RegExUtils.java#L312-L317
|
dlemmermann/CalendarFX
|
CalendarFXGoogle/src/main/java/com/calendarfx/google/model/GoogleCalendar.java
|
GoogleCalendar.createEntry
|
public final GoogleEntry createEntry(ZonedDateTime start, boolean fullDay) {
"""
Creates a new google entry by using the given parameters, this assigns a
default name by using a consecutive number. The entry is of course
associated to this calendar, but it is not sent to google for storing.
@param start
The start date/time of the new entry.
@param fullDay
A flag indicating if the new entry is going to be full day.
@return The new google entry created, this is not send to server side.
@see #generateEntryConsecutive()
"""
GoogleEntry entry = new GoogleEntry();
entry.setTitle("New Entry " + generateEntryConsecutive());
entry.setInterval(new Interval(start.toLocalDate(), start.toLocalTime(), start.toLocalDate(), start.toLocalTime().plusHours(1)));
entry.setFullDay(fullDay);
entry.setAttendeesCanInviteOthers(true);
entry.setAttendeesCanSeeOthers(true);
return entry;
}
|
java
|
public final GoogleEntry createEntry(ZonedDateTime start, boolean fullDay) {
GoogleEntry entry = new GoogleEntry();
entry.setTitle("New Entry " + generateEntryConsecutive());
entry.setInterval(new Interval(start.toLocalDate(), start.toLocalTime(), start.toLocalDate(), start.toLocalTime().plusHours(1)));
entry.setFullDay(fullDay);
entry.setAttendeesCanInviteOthers(true);
entry.setAttendeesCanSeeOthers(true);
return entry;
}
|
[
"public",
"final",
"GoogleEntry",
"createEntry",
"(",
"ZonedDateTime",
"start",
",",
"boolean",
"fullDay",
")",
"{",
"GoogleEntry",
"entry",
"=",
"new",
"GoogleEntry",
"(",
")",
";",
"entry",
".",
"setTitle",
"(",
"\"New Entry \"",
"+",
"generateEntryConsecutive",
"(",
")",
")",
";",
"entry",
".",
"setInterval",
"(",
"new",
"Interval",
"(",
"start",
".",
"toLocalDate",
"(",
")",
",",
"start",
".",
"toLocalTime",
"(",
")",
",",
"start",
".",
"toLocalDate",
"(",
")",
",",
"start",
".",
"toLocalTime",
"(",
")",
".",
"plusHours",
"(",
"1",
")",
")",
")",
";",
"entry",
".",
"setFullDay",
"(",
"fullDay",
")",
";",
"entry",
".",
"setAttendeesCanInviteOthers",
"(",
"true",
")",
";",
"entry",
".",
"setAttendeesCanSeeOthers",
"(",
"true",
")",
";",
"return",
"entry",
";",
"}"
] |
Creates a new google entry by using the given parameters, this assigns a
default name by using a consecutive number. The entry is of course
associated to this calendar, but it is not sent to google for storing.
@param start
The start date/time of the new entry.
@param fullDay
A flag indicating if the new entry is going to be full day.
@return The new google entry created, this is not send to server side.
@see #generateEntryConsecutive()
|
[
"Creates",
"a",
"new",
"google",
"entry",
"by",
"using",
"the",
"given",
"parameters",
"this",
"assigns",
"a",
"default",
"name",
"by",
"using",
"a",
"consecutive",
"number",
".",
"The",
"entry",
"is",
"of",
"course",
"associated",
"to",
"this",
"calendar",
"but",
"it",
"is",
"not",
"sent",
"to",
"google",
"for",
"storing",
"."
] |
train
|
https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXGoogle/src/main/java/com/calendarfx/google/model/GoogleCalendar.java#L143-L151
|
gsi-upm/Shanks
|
shanks-core/src/main/java/es/upm/dit/gsi/shanks/agent/capability/reasoning/bayes/unbbayes/ShanksAgentBayesianReasoningCapability.java
|
ShanksAgentBayesianReasoningCapability.getNode
|
public static ProbabilisticNode getNode(ProbabilisticNetwork bn,
String nodeName) throws ShanksException {
"""
Return the complete node
@param bn
@param nodeName
@return the ProbabilisticNode object
@throws UnknownNodeException
"""
ProbabilisticNode node = (ProbabilisticNode) bn.getNode(nodeName);
if (node == null) {
throw new UnknownNodeException(bn, nodeName);
}
return node;
}
|
java
|
public static ProbabilisticNode getNode(ProbabilisticNetwork bn,
String nodeName) throws ShanksException {
ProbabilisticNode node = (ProbabilisticNode) bn.getNode(nodeName);
if (node == null) {
throw new UnknownNodeException(bn, nodeName);
}
return node;
}
|
[
"public",
"static",
"ProbabilisticNode",
"getNode",
"(",
"ProbabilisticNetwork",
"bn",
",",
"String",
"nodeName",
")",
"throws",
"ShanksException",
"{",
"ProbabilisticNode",
"node",
"=",
"(",
"ProbabilisticNode",
")",
"bn",
".",
"getNode",
"(",
"nodeName",
")",
";",
"if",
"(",
"node",
"==",
"null",
")",
"{",
"throw",
"new",
"UnknownNodeException",
"(",
"bn",
",",
"nodeName",
")",
";",
"}",
"return",
"node",
";",
"}"
] |
Return the complete node
@param bn
@param nodeName
@return the ProbabilisticNode object
@throws UnknownNodeException
|
[
"Return",
"the",
"complete",
"node"
] |
train
|
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/agent/capability/reasoning/bayes/unbbayes/ShanksAgentBayesianReasoningCapability.java#L399-L406
|
gallandarakhneorg/afc
|
core/inputoutput/src/main/java/org/arakhne/afc/inputoutput/xml/XMLUtil.java
|
XMLUtil.writeXML
|
public static void writeXML(DocumentFragment fragment, File file) throws ParserConfigurationException, IOException {
"""
Write the given node tree into a XML file.
@param fragment is the object that contains the node tree
@param file is the file name.
@throws IOException if the stream cannot be read.
@throws ParserConfigurationException if the parser cannot be configured.
"""
assert fragment != null : AssertMessages.notNullParameter(0);
assert file != null : AssertMessages.notNullParameter(1);
try (FileOutputStream fos = new FileOutputStream(file)) {
writeNode(fragment, fos);
}
}
|
java
|
public static void writeXML(DocumentFragment fragment, File file) throws ParserConfigurationException, IOException {
assert fragment != null : AssertMessages.notNullParameter(0);
assert file != null : AssertMessages.notNullParameter(1);
try (FileOutputStream fos = new FileOutputStream(file)) {
writeNode(fragment, fos);
}
}
|
[
"public",
"static",
"void",
"writeXML",
"(",
"DocumentFragment",
"fragment",
",",
"File",
"file",
")",
"throws",
"ParserConfigurationException",
",",
"IOException",
"{",
"assert",
"fragment",
"!=",
"null",
":",
"AssertMessages",
".",
"notNullParameter",
"(",
"0",
")",
";",
"assert",
"file",
"!=",
"null",
":",
"AssertMessages",
".",
"notNullParameter",
"(",
"1",
")",
";",
"try",
"(",
"FileOutputStream",
"fos",
"=",
"new",
"FileOutputStream",
"(",
"file",
")",
")",
"{",
"writeNode",
"(",
"fragment",
",",
"fos",
")",
";",
"}",
"}"
] |
Write the given node tree into a XML file.
@param fragment is the object that contains the node tree
@param file is the file name.
@throws IOException if the stream cannot be read.
@throws ParserConfigurationException if the parser cannot be configured.
|
[
"Write",
"the",
"given",
"node",
"tree",
"into",
"a",
"XML",
"file",
"."
] |
train
|
https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/inputoutput/src/main/java/org/arakhne/afc/inputoutput/xml/XMLUtil.java#L2403-L2409
|
Azure/azure-sdk-for-java
|
datamigration/resource-manager/v2018_07_15_preview/src/main/java/com/microsoft/azure/management/datamigration/v2018_07_15_preview/implementation/TasksInner.java
|
TasksInner.commandAsync
|
public Observable<CommandPropertiesInner> commandAsync(String groupName, String serviceName, String projectName, String taskName, CommandPropertiesInner parameters) {
"""
Execute a command on a task.
The tasks resource is a nested, proxy-only resource representing work performed by a DMS instance. This method executes a command on a running task.
@param groupName Name of the resource group
@param serviceName Name of the service
@param projectName Name of the project
@param taskName Name of the Task
@param parameters Command to execute
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the CommandPropertiesInner object
"""
return commandWithServiceResponseAsync(groupName, serviceName, projectName, taskName, parameters).map(new Func1<ServiceResponse<CommandPropertiesInner>, CommandPropertiesInner>() {
@Override
public CommandPropertiesInner call(ServiceResponse<CommandPropertiesInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<CommandPropertiesInner> commandAsync(String groupName, String serviceName, String projectName, String taskName, CommandPropertiesInner parameters) {
return commandWithServiceResponseAsync(groupName, serviceName, projectName, taskName, parameters).map(new Func1<ServiceResponse<CommandPropertiesInner>, CommandPropertiesInner>() {
@Override
public CommandPropertiesInner call(ServiceResponse<CommandPropertiesInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"CommandPropertiesInner",
">",
"commandAsync",
"(",
"String",
"groupName",
",",
"String",
"serviceName",
",",
"String",
"projectName",
",",
"String",
"taskName",
",",
"CommandPropertiesInner",
"parameters",
")",
"{",
"return",
"commandWithServiceResponseAsync",
"(",
"groupName",
",",
"serviceName",
",",
"projectName",
",",
"taskName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"CommandPropertiesInner",
">",
",",
"CommandPropertiesInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"CommandPropertiesInner",
"call",
"(",
"ServiceResponse",
"<",
"CommandPropertiesInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Execute a command on a task.
The tasks resource is a nested, proxy-only resource representing work performed by a DMS instance. This method executes a command on a running task.
@param groupName Name of the resource group
@param serviceName Name of the service
@param projectName Name of the project
@param taskName Name of the Task
@param parameters Command to execute
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the CommandPropertiesInner object
|
[
"Execute",
"a",
"command",
"on",
"a",
"task",
".",
"The",
"tasks",
"resource",
"is",
"a",
"nested",
"proxy",
"-",
"only",
"resource",
"representing",
"work",
"performed",
"by",
"a",
"DMS",
"instance",
".",
"This",
"method",
"executes",
"a",
"command",
"on",
"a",
"running",
"task",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/datamigration/resource-manager/v2018_07_15_preview/src/main/java/com/microsoft/azure/management/datamigration/v2018_07_15_preview/implementation/TasksInner.java#L1158-L1165
|
TheCoder4eu/BootsFaces-OSP
|
src/main/java/net/bootsfaces/component/buttonToolbar/ButtonToolbarRenderer.java
|
ButtonToolbarRenderer.encodeBegin
|
@Override
public void encodeBegin(FacesContext fc, UIComponent component) throws IOException {
"""
This methods generates the HTML code of the current b:buttonToolbar.
<code>encodeBegin</code> generates the start of the component. After the,
the JSF framework calls <code>encodeChildren()</code> to generate the
HTML code between the beginning and the end of the component. For
instance, in the case of a panel component the content of the panel is
generated by <code>encodeChildren()</code>. After that,
<code>encodeEnd()</code> is called to generate the rest of the HTML code.
@param fc
the FacesContext.
@param component
the current b:buttonToolbar.
@throws IOException
thrown if something goes wrong when writing the HTML code.
"""
if (!component.isRendered()) {
return;
}
ResponseWriter rw = fc.getResponseWriter();
ButtonToolbar buttonToolbar = (ButtonToolbar) component;
String pull = buttonToolbar.getPull();
rw.startElement("div", buttonToolbar);
rw.writeAttribute("id", component.getClientId(fc), "id");
Tooltip.generateTooltip(fc, buttonToolbar, rw);
String styleClasses = "btn-toolbar " + Responsive.getResponsiveStyleClass(buttonToolbar, false);
if (null != buttonToolbar.getStyleClass()) {
styleClasses += " " + buttonToolbar.getStyleClass();
}
if (pull != null && (pull.equals("right") || pull.equals("left"))) {
rw.writeAttribute("class", styleClasses.concat(" ").concat("pull").concat("-").concat(pull),
"class");
} else {
rw.writeAttribute("class", styleClasses, "class");
}
if (null != buttonToolbar.getStyle()) {
rw.writeAttribute("style", buttonToolbar.getStyle(), "style");
}
beginDisabledFieldset(buttonToolbar, rw);
}
|
java
|
@Override
public void encodeBegin(FacesContext fc, UIComponent component) throws IOException {
if (!component.isRendered()) {
return;
}
ResponseWriter rw = fc.getResponseWriter();
ButtonToolbar buttonToolbar = (ButtonToolbar) component;
String pull = buttonToolbar.getPull();
rw.startElement("div", buttonToolbar);
rw.writeAttribute("id", component.getClientId(fc), "id");
Tooltip.generateTooltip(fc, buttonToolbar, rw);
String styleClasses = "btn-toolbar " + Responsive.getResponsiveStyleClass(buttonToolbar, false);
if (null != buttonToolbar.getStyleClass()) {
styleClasses += " " + buttonToolbar.getStyleClass();
}
if (pull != null && (pull.equals("right") || pull.equals("left"))) {
rw.writeAttribute("class", styleClasses.concat(" ").concat("pull").concat("-").concat(pull),
"class");
} else {
rw.writeAttribute("class", styleClasses, "class");
}
if (null != buttonToolbar.getStyle()) {
rw.writeAttribute("style", buttonToolbar.getStyle(), "style");
}
beginDisabledFieldset(buttonToolbar, rw);
}
|
[
"@",
"Override",
"public",
"void",
"encodeBegin",
"(",
"FacesContext",
"fc",
",",
"UIComponent",
"component",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"component",
".",
"isRendered",
"(",
")",
")",
"{",
"return",
";",
"}",
"ResponseWriter",
"rw",
"=",
"fc",
".",
"getResponseWriter",
"(",
")",
";",
"ButtonToolbar",
"buttonToolbar",
"=",
"(",
"ButtonToolbar",
")",
"component",
";",
"String",
"pull",
"=",
"buttonToolbar",
".",
"getPull",
"(",
")",
";",
"rw",
".",
"startElement",
"(",
"\"div\"",
",",
"buttonToolbar",
")",
";",
"rw",
".",
"writeAttribute",
"(",
"\"id\"",
",",
"component",
".",
"getClientId",
"(",
"fc",
")",
",",
"\"id\"",
")",
";",
"Tooltip",
".",
"generateTooltip",
"(",
"fc",
",",
"buttonToolbar",
",",
"rw",
")",
";",
"String",
"styleClasses",
"=",
"\"btn-toolbar \"",
"+",
"Responsive",
".",
"getResponsiveStyleClass",
"(",
"buttonToolbar",
",",
"false",
")",
";",
"if",
"(",
"null",
"!=",
"buttonToolbar",
".",
"getStyleClass",
"(",
")",
")",
"{",
"styleClasses",
"+=",
"\" \"",
"+",
"buttonToolbar",
".",
"getStyleClass",
"(",
")",
";",
"}",
"if",
"(",
"pull",
"!=",
"null",
"&&",
"(",
"pull",
".",
"equals",
"(",
"\"right\"",
")",
"||",
"pull",
".",
"equals",
"(",
"\"left\"",
")",
")",
")",
"{",
"rw",
".",
"writeAttribute",
"(",
"\"class\"",
",",
"styleClasses",
".",
"concat",
"(",
"\" \"",
")",
".",
"concat",
"(",
"\"pull\"",
")",
".",
"concat",
"(",
"\"-\"",
")",
".",
"concat",
"(",
"pull",
")",
",",
"\"class\"",
")",
";",
"}",
"else",
"{",
"rw",
".",
"writeAttribute",
"(",
"\"class\"",
",",
"styleClasses",
",",
"\"class\"",
")",
";",
"}",
"if",
"(",
"null",
"!=",
"buttonToolbar",
".",
"getStyle",
"(",
")",
")",
"{",
"rw",
".",
"writeAttribute",
"(",
"\"style\"",
",",
"buttonToolbar",
".",
"getStyle",
"(",
")",
",",
"\"style\"",
")",
";",
"}",
"beginDisabledFieldset",
"(",
"buttonToolbar",
",",
"rw",
")",
";",
"}"
] |
This methods generates the HTML code of the current b:buttonToolbar.
<code>encodeBegin</code> generates the start of the component. After the,
the JSF framework calls <code>encodeChildren()</code> to generate the
HTML code between the beginning and the end of the component. For
instance, in the case of a panel component the content of the panel is
generated by <code>encodeChildren()</code>. After that,
<code>encodeEnd()</code> is called to generate the rest of the HTML code.
@param fc
the FacesContext.
@param component
the current b:buttonToolbar.
@throws IOException
thrown if something goes wrong when writing the HTML code.
|
[
"This",
"methods",
"generates",
"the",
"HTML",
"code",
"of",
"the",
"current",
"b",
":",
"buttonToolbar",
".",
"<code",
">",
"encodeBegin<",
"/",
"code",
">",
"generates",
"the",
"start",
"of",
"the",
"component",
".",
"After",
"the",
"the",
"JSF",
"framework",
"calls",
"<code",
">",
"encodeChildren",
"()",
"<",
"/",
"code",
">",
"to",
"generate",
"the",
"HTML",
"code",
"between",
"the",
"beginning",
"and",
"the",
"end",
"of",
"the",
"component",
".",
"For",
"instance",
"in",
"the",
"case",
"of",
"a",
"panel",
"component",
"the",
"content",
"of",
"the",
"panel",
"is",
"generated",
"by",
"<code",
">",
"encodeChildren",
"()",
"<",
"/",
"code",
">",
".",
"After",
"that",
"<code",
">",
"encodeEnd",
"()",
"<",
"/",
"code",
">",
"is",
"called",
"to",
"generate",
"the",
"rest",
"of",
"the",
"HTML",
"code",
"."
] |
train
|
https://github.com/TheCoder4eu/BootsFaces-OSP/blob/d1a70952bc240979b5272fa4fe1c7f100873add0/src/main/java/net/bootsfaces/component/buttonToolbar/ButtonToolbarRenderer.java#L52-L80
|
biojava/biojava
|
biojava-structure/src/main/java/org/biojava/nbio/structure/geometry/UnitQuaternions.java
|
UnitQuaternions.orientationAngle
|
public static double orientationAngle(Point3d[] fixed, Point3d[] moved) {
"""
The angle of the relative orientation of the two sets of points in 3D.
Equivalent to {@link #angle(Quat4d)} of the unit quaternion obtained by
{@link #relativeOrientation(Point3d[], Point3d[])}.
<p>
The arrays of points need to be centered at the origin. To center the
points use {@link CalcPoint#center(Point3d[])}.
@param fixed
array of Point3d, centered at origin. Original coordinates
will not be modified.
@param moved
array of Point3d, centered at origin. Original coordinates
will not be modified.
@return the angle in radians of the relative orientation of the points,
angle to rotate moved to bring it to the same orientation as
fixed.
"""
Quat4d q = relativeOrientation(fixed, moved);
return angle(q);
}
|
java
|
public static double orientationAngle(Point3d[] fixed, Point3d[] moved) {
Quat4d q = relativeOrientation(fixed, moved);
return angle(q);
}
|
[
"public",
"static",
"double",
"orientationAngle",
"(",
"Point3d",
"[",
"]",
"fixed",
",",
"Point3d",
"[",
"]",
"moved",
")",
"{",
"Quat4d",
"q",
"=",
"relativeOrientation",
"(",
"fixed",
",",
"moved",
")",
";",
"return",
"angle",
"(",
"q",
")",
";",
"}"
] |
The angle of the relative orientation of the two sets of points in 3D.
Equivalent to {@link #angle(Quat4d)} of the unit quaternion obtained by
{@link #relativeOrientation(Point3d[], Point3d[])}.
<p>
The arrays of points need to be centered at the origin. To center the
points use {@link CalcPoint#center(Point3d[])}.
@param fixed
array of Point3d, centered at origin. Original coordinates
will not be modified.
@param moved
array of Point3d, centered at origin. Original coordinates
will not be modified.
@return the angle in radians of the relative orientation of the points,
angle to rotate moved to bring it to the same orientation as
fixed.
|
[
"The",
"angle",
"of",
"the",
"relative",
"orientation",
"of",
"the",
"two",
"sets",
"of",
"points",
"in",
"3D",
".",
"Equivalent",
"to",
"{",
"@link",
"#angle",
"(",
"Quat4d",
")",
"}",
"of",
"the",
"unit",
"quaternion",
"obtained",
"by",
"{",
"@link",
"#relativeOrientation",
"(",
"Point3d",
"[]",
"Point3d",
"[]",
")",
"}",
".",
"<p",
">",
"The",
"arrays",
"of",
"points",
"need",
"to",
"be",
"centered",
"at",
"the",
"origin",
".",
"To",
"center",
"the",
"points",
"use",
"{",
"@link",
"CalcPoint#center",
"(",
"Point3d",
"[]",
")",
"}",
"."
] |
train
|
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/geometry/UnitQuaternions.java#L158-L161
|
rhuss/jolokia
|
agent/jvm/src/main/java/org/jolokia/jvmagent/client/util/VirtualMachineHandler.java
|
VirtualMachineHandler.listProcesses
|
public List<ProcessDescription> listProcesses() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
"""
Return a list of all Java processes
@return list of java processes
@throws NoSuchMethodException reflection error
@throws InvocationTargetException reflection error
@throws IllegalAccessException reflection error
"""
List<ProcessDescription> ret = new ArrayList<ProcessDescription>();
Class vmClass = lookupVirtualMachineClass();
Method method = vmClass.getMethod("list");
List vmDescriptors = (List) method.invoke(null);
for (Object descriptor : vmDescriptors) {
Method idMethod = descriptor.getClass().getMethod("id");
String id = (String) idMethod.invoke(descriptor);
Method displayMethod = descriptor.getClass().getMethod("displayName");
String display = (String) displayMethod.invoke(descriptor);
ret.add(new ProcessDescription(id, display));
}
return ret;
}
|
java
|
public List<ProcessDescription> listProcesses() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
List<ProcessDescription> ret = new ArrayList<ProcessDescription>();
Class vmClass = lookupVirtualMachineClass();
Method method = vmClass.getMethod("list");
List vmDescriptors = (List) method.invoke(null);
for (Object descriptor : vmDescriptors) {
Method idMethod = descriptor.getClass().getMethod("id");
String id = (String) idMethod.invoke(descriptor);
Method displayMethod = descriptor.getClass().getMethod("displayName");
String display = (String) displayMethod.invoke(descriptor);
ret.add(new ProcessDescription(id, display));
}
return ret;
}
|
[
"public",
"List",
"<",
"ProcessDescription",
">",
"listProcesses",
"(",
")",
"throws",
"NoSuchMethodException",
",",
"InvocationTargetException",
",",
"IllegalAccessException",
"{",
"List",
"<",
"ProcessDescription",
">",
"ret",
"=",
"new",
"ArrayList",
"<",
"ProcessDescription",
">",
"(",
")",
";",
"Class",
"vmClass",
"=",
"lookupVirtualMachineClass",
"(",
")",
";",
"Method",
"method",
"=",
"vmClass",
".",
"getMethod",
"(",
"\"list\"",
")",
";",
"List",
"vmDescriptors",
"=",
"(",
"List",
")",
"method",
".",
"invoke",
"(",
"null",
")",
";",
"for",
"(",
"Object",
"descriptor",
":",
"vmDescriptors",
")",
"{",
"Method",
"idMethod",
"=",
"descriptor",
".",
"getClass",
"(",
")",
".",
"getMethod",
"(",
"\"id\"",
")",
";",
"String",
"id",
"=",
"(",
"String",
")",
"idMethod",
".",
"invoke",
"(",
"descriptor",
")",
";",
"Method",
"displayMethod",
"=",
"descriptor",
".",
"getClass",
"(",
")",
".",
"getMethod",
"(",
"\"displayName\"",
")",
";",
"String",
"display",
"=",
"(",
"String",
")",
"displayMethod",
".",
"invoke",
"(",
"descriptor",
")",
";",
"ret",
".",
"add",
"(",
"new",
"ProcessDescription",
"(",
"id",
",",
"display",
")",
")",
";",
"}",
"return",
"ret",
";",
"}"
] |
Return a list of all Java processes
@return list of java processes
@throws NoSuchMethodException reflection error
@throws InvocationTargetException reflection error
@throws IllegalAccessException reflection error
|
[
"Return",
"a",
"list",
"of",
"all",
"Java",
"processes"
] |
train
|
https://github.com/rhuss/jolokia/blob/dc95e7bef859b1829776c5a84c8f7738f5d7d9c3/agent/jvm/src/main/java/org/jolokia/jvmagent/client/util/VirtualMachineHandler.java#L116-L129
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java
|
ApiOvhTelephony.billingAccount_ovhPabx_serviceName_dialplan_POST
|
public OvhOvhPabxDialplan billingAccount_ovhPabx_serviceName_dialplan_POST(String billingAccount, String serviceName, Boolean anonymousRejection, String name, OvhOvhPabxDialplanNumberPresentationEnum showCallerNumber, Long transferTimeout) throws IOException {
"""
Create a new dialplan
REST: POST /telephony/{billingAccount}/ovhPabx/{serviceName}/dialplan
@param transferTimeout [required] The timeout (in seconds) when bridging calls
@param anonymousRejection [required] Reject (hangup) anonymous calls
@param name [required] The dialplan name
@param showCallerNumber [required] The presented number when bridging calls
@param billingAccount [required] The name of your billingAccount
@param serviceName [required]
"""
String qPath = "/telephony/{billingAccount}/ovhPabx/{serviceName}/dialplan";
StringBuilder sb = path(qPath, billingAccount, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "anonymousRejection", anonymousRejection);
addBody(o, "name", name);
addBody(o, "showCallerNumber", showCallerNumber);
addBody(o, "transferTimeout", transferTimeout);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhOvhPabxDialplan.class);
}
|
java
|
public OvhOvhPabxDialplan billingAccount_ovhPabx_serviceName_dialplan_POST(String billingAccount, String serviceName, Boolean anonymousRejection, String name, OvhOvhPabxDialplanNumberPresentationEnum showCallerNumber, Long transferTimeout) throws IOException {
String qPath = "/telephony/{billingAccount}/ovhPabx/{serviceName}/dialplan";
StringBuilder sb = path(qPath, billingAccount, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "anonymousRejection", anonymousRejection);
addBody(o, "name", name);
addBody(o, "showCallerNumber", showCallerNumber);
addBody(o, "transferTimeout", transferTimeout);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhOvhPabxDialplan.class);
}
|
[
"public",
"OvhOvhPabxDialplan",
"billingAccount_ovhPabx_serviceName_dialplan_POST",
"(",
"String",
"billingAccount",
",",
"String",
"serviceName",
",",
"Boolean",
"anonymousRejection",
",",
"String",
"name",
",",
"OvhOvhPabxDialplanNumberPresentationEnum",
"showCallerNumber",
",",
"Long",
"transferTimeout",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/telephony/{billingAccount}/ovhPabx/{serviceName}/dialplan\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"billingAccount",
",",
"serviceName",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"anonymousRejection\"",
",",
"anonymousRejection",
")",
";",
"addBody",
"(",
"o",
",",
"\"name\"",
",",
"name",
")",
";",
"addBody",
"(",
"o",
",",
"\"showCallerNumber\"",
",",
"showCallerNumber",
")",
";",
"addBody",
"(",
"o",
",",
"\"transferTimeout\"",
",",
"transferTimeout",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhOvhPabxDialplan",
".",
"class",
")",
";",
"}"
] |
Create a new dialplan
REST: POST /telephony/{billingAccount}/ovhPabx/{serviceName}/dialplan
@param transferTimeout [required] The timeout (in seconds) when bridging calls
@param anonymousRejection [required] Reject (hangup) anonymous calls
@param name [required] The dialplan name
@param showCallerNumber [required] The presented number when bridging calls
@param billingAccount [required] The name of your billingAccount
@param serviceName [required]
|
[
"Create",
"a",
"new",
"dialplan"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L7432-L7442
|
groovy/groovy-core
|
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
|
StringGroovyMethods.replaceFirst
|
public static String replaceFirst(final CharSequence self, final CharSequence regex, final CharSequence replacement) {
"""
Replaces the first substring of this CharSequence that matches the given
regular expression with the given replacement.
@param self a CharSequence
@param regex the capturing regex
@param replacement the CharSequence to be substituted for each match
@return a CharSequence with replaced content
@throws java.util.regex.PatternSyntaxException if the regular expression's syntax is invalid
@see String#replaceFirst(String, String)
@since 1.8.2
"""
return self.toString().replaceFirst(regex.toString(), replacement.toString());
}
|
java
|
public static String replaceFirst(final CharSequence self, final CharSequence regex, final CharSequence replacement) {
return self.toString().replaceFirst(regex.toString(), replacement.toString());
}
|
[
"public",
"static",
"String",
"replaceFirst",
"(",
"final",
"CharSequence",
"self",
",",
"final",
"CharSequence",
"regex",
",",
"final",
"CharSequence",
"replacement",
")",
"{",
"return",
"self",
".",
"toString",
"(",
")",
".",
"replaceFirst",
"(",
"regex",
".",
"toString",
"(",
")",
",",
"replacement",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
Replaces the first substring of this CharSequence that matches the given
regular expression with the given replacement.
@param self a CharSequence
@param regex the capturing regex
@param replacement the CharSequence to be substituted for each match
@return a CharSequence with replaced content
@throws java.util.regex.PatternSyntaxException if the regular expression's syntax is invalid
@see String#replaceFirst(String, String)
@since 1.8.2
|
[
"Replaces",
"the",
"first",
"substring",
"of",
"this",
"CharSequence",
"that",
"matches",
"the",
"given",
"regular",
"expression",
"with",
"the",
"given",
"replacement",
"."
] |
train
|
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L2629-L2631
|
VoltDB/voltdb
|
src/frontend/org/voltdb/planner/SubPlanAssembler.java
|
SubPlanAssembler.getRelevantNaivePath
|
protected static AccessPath getRelevantNaivePath(List<AbstractExpression> joinExprs, List<AbstractExpression> filterExprs) {
"""
Generate the naive (scan) pass given a join and filter expressions
@param joinExprs join expressions
@param filterExprs filter expressions
@return Naive access path
"""
AccessPath naivePath = new AccessPath();
if (filterExprs != null) {
naivePath.otherExprs.addAll(filterExprs);
}
if (joinExprs != null) {
naivePath.joinExprs.addAll(joinExprs);
}
return naivePath;
}
|
java
|
protected static AccessPath getRelevantNaivePath(List<AbstractExpression> joinExprs, List<AbstractExpression> filterExprs) {
AccessPath naivePath = new AccessPath();
if (filterExprs != null) {
naivePath.otherExprs.addAll(filterExprs);
}
if (joinExprs != null) {
naivePath.joinExprs.addAll(joinExprs);
}
return naivePath;
}
|
[
"protected",
"static",
"AccessPath",
"getRelevantNaivePath",
"(",
"List",
"<",
"AbstractExpression",
">",
"joinExprs",
",",
"List",
"<",
"AbstractExpression",
">",
"filterExprs",
")",
"{",
"AccessPath",
"naivePath",
"=",
"new",
"AccessPath",
"(",
")",
";",
"if",
"(",
"filterExprs",
"!=",
"null",
")",
"{",
"naivePath",
".",
"otherExprs",
".",
"addAll",
"(",
"filterExprs",
")",
";",
"}",
"if",
"(",
"joinExprs",
"!=",
"null",
")",
"{",
"naivePath",
".",
"joinExprs",
".",
"addAll",
"(",
"joinExprs",
")",
";",
"}",
"return",
"naivePath",
";",
"}"
] |
Generate the naive (scan) pass given a join and filter expressions
@param joinExprs join expressions
@param filterExprs filter expressions
@return Naive access path
|
[
"Generate",
"the",
"naive",
"(",
"scan",
")",
"pass",
"given",
"a",
"join",
"and",
"filter",
"expressions"
] |
train
|
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/SubPlanAssembler.java#L228-L238
|
probedock/probedock-java
|
src/main/java/io/probedock/client/common/utils/Inflector.java
|
Inflector.forgeName
|
public static String forgeName(Class cl, String methodName, ProbeTest methodAnnotation) {
"""
Forge a name from a class and a method. If an annotation is provided, then the method
content is used.
@param cl Class to get the name
@param methodName The method name
@param methodAnnotation The method annotation to override the normal forged name
@return The name forge and humanize
"""
if (methodAnnotation != null && !"".equalsIgnoreCase(methodAnnotation.name())) {
return methodAnnotation.name();
} else {
return getHumanName(cl.getSimpleName() + ": " + methodName);
}
}
|
java
|
public static String forgeName(Class cl, String methodName, ProbeTest methodAnnotation) {
if (methodAnnotation != null && !"".equalsIgnoreCase(methodAnnotation.name())) {
return methodAnnotation.name();
} else {
return getHumanName(cl.getSimpleName() + ": " + methodName);
}
}
|
[
"public",
"static",
"String",
"forgeName",
"(",
"Class",
"cl",
",",
"String",
"methodName",
",",
"ProbeTest",
"methodAnnotation",
")",
"{",
"if",
"(",
"methodAnnotation",
"!=",
"null",
"&&",
"!",
"\"\"",
".",
"equalsIgnoreCase",
"(",
"methodAnnotation",
".",
"name",
"(",
")",
")",
")",
"{",
"return",
"methodAnnotation",
".",
"name",
"(",
")",
";",
"}",
"else",
"{",
"return",
"getHumanName",
"(",
"cl",
".",
"getSimpleName",
"(",
")",
"+",
"\": \"",
"+",
"methodName",
")",
";",
"}",
"}"
] |
Forge a name from a class and a method. If an annotation is provided, then the method
content is used.
@param cl Class to get the name
@param methodName The method name
@param methodAnnotation The method annotation to override the normal forged name
@return The name forge and humanize
|
[
"Forge",
"a",
"name",
"from",
"a",
"class",
"and",
"a",
"method",
".",
"If",
"an",
"annotation",
"is",
"provided",
"then",
"the",
"method",
"content",
"is",
"used",
"."
] |
train
|
https://github.com/probedock/probedock-java/blob/92ee6634ba4fe3fdffeb4e202f5372ef947a67c3/src/main/java/io/probedock/client/common/utils/Inflector.java#L36-L42
|
liferay/com-liferay-commerce
|
commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPInstancePersistenceImpl.java
|
CPInstancePersistenceImpl.removeByC_ERC
|
@Override
public CPInstance removeByC_ERC(long companyId, String externalReferenceCode)
throws NoSuchCPInstanceException {
"""
Removes the cp instance where companyId = ? and externalReferenceCode = ? from the database.
@param companyId the company ID
@param externalReferenceCode the external reference code
@return the cp instance that was removed
"""
CPInstance cpInstance = findByC_ERC(companyId, externalReferenceCode);
return remove(cpInstance);
}
|
java
|
@Override
public CPInstance removeByC_ERC(long companyId, String externalReferenceCode)
throws NoSuchCPInstanceException {
CPInstance cpInstance = findByC_ERC(companyId, externalReferenceCode);
return remove(cpInstance);
}
|
[
"@",
"Override",
"public",
"CPInstance",
"removeByC_ERC",
"(",
"long",
"companyId",
",",
"String",
"externalReferenceCode",
")",
"throws",
"NoSuchCPInstanceException",
"{",
"CPInstance",
"cpInstance",
"=",
"findByC_ERC",
"(",
"companyId",
",",
"externalReferenceCode",
")",
";",
"return",
"remove",
"(",
"cpInstance",
")",
";",
"}"
] |
Removes the cp instance where companyId = ? and externalReferenceCode = ? from the database.
@param companyId the company ID
@param externalReferenceCode the external reference code
@return the cp instance that was removed
|
[
"Removes",
"the",
"cp",
"instance",
"where",
"companyId",
"=",
"?",
";",
"and",
"externalReferenceCode",
"=",
"?",
";",
"from",
"the",
"database",
"."
] |
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#L6984-L6990
|
jbundle/jbundle
|
app/program/manual/backup/src/main/java/org/jbundle/app/program/manual/backup/BackupServerApp.java
|
BackupServerApp.init
|
public void init(Object env, Map<String,Object> properties, Object applet) {
"""
Chat Screen Constructor.
@param parent Typically, you pass the BaseApplet as the parent.
@param @record and the record or GridTableModel as the parent.
"""
super.init(env, properties, applet);
if (this.registerUniqueApplication(BACKUP_QUEUE_NAME, BACKUP_QUEUE_TYPE) != Constants.NORMAL_RETURN)
{
this.free(); // Don't start this application (It's already running somewhere)
return;
}
MessageManager messageManager = RemoteMessageManager.getMessageManager(this);
BaseMessageReceiver receiver = (BaseMessageReceiver)messageManager.getMessageQueue(BACKUP_QUEUE_NAME, BACKUP_QUEUE_TYPE).getMessageReceiver();
m_messageFilter = new BaseMessageFilter(BACKUP_QUEUE_NAME, BACKUP_QUEUE_TYPE, this, null);
new BaseMessageListener(m_messageFilter) // Listener added to filter.
{
public int handleMessage(BaseMessage message)
{
Object objMessage = message.get(MESSAGE_PARAM);
backupTrxLog(objMessage);
return Constants.NORMAL_RETURN;
}
};
receiver.addMessageFilter(m_messageFilter);
}
|
java
|
public void init(Object env, Map<String,Object> properties, Object applet)
{
super.init(env, properties, applet);
if (this.registerUniqueApplication(BACKUP_QUEUE_NAME, BACKUP_QUEUE_TYPE) != Constants.NORMAL_RETURN)
{
this.free(); // Don't start this application (It's already running somewhere)
return;
}
MessageManager messageManager = RemoteMessageManager.getMessageManager(this);
BaseMessageReceiver receiver = (BaseMessageReceiver)messageManager.getMessageQueue(BACKUP_QUEUE_NAME, BACKUP_QUEUE_TYPE).getMessageReceiver();
m_messageFilter = new BaseMessageFilter(BACKUP_QUEUE_NAME, BACKUP_QUEUE_TYPE, this, null);
new BaseMessageListener(m_messageFilter) // Listener added to filter.
{
public int handleMessage(BaseMessage message)
{
Object objMessage = message.get(MESSAGE_PARAM);
backupTrxLog(objMessage);
return Constants.NORMAL_RETURN;
}
};
receiver.addMessageFilter(m_messageFilter);
}
|
[
"public",
"void",
"init",
"(",
"Object",
"env",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"properties",
",",
"Object",
"applet",
")",
"{",
"super",
".",
"init",
"(",
"env",
",",
"properties",
",",
"applet",
")",
";",
"if",
"(",
"this",
".",
"registerUniqueApplication",
"(",
"BACKUP_QUEUE_NAME",
",",
"BACKUP_QUEUE_TYPE",
")",
"!=",
"Constants",
".",
"NORMAL_RETURN",
")",
"{",
"this",
".",
"free",
"(",
")",
";",
"// Don't start this application (It's already running somewhere)",
"return",
";",
"}",
"MessageManager",
"messageManager",
"=",
"RemoteMessageManager",
".",
"getMessageManager",
"(",
"this",
")",
";",
"BaseMessageReceiver",
"receiver",
"=",
"(",
"BaseMessageReceiver",
")",
"messageManager",
".",
"getMessageQueue",
"(",
"BACKUP_QUEUE_NAME",
",",
"BACKUP_QUEUE_TYPE",
")",
".",
"getMessageReceiver",
"(",
")",
";",
"m_messageFilter",
"=",
"new",
"BaseMessageFilter",
"(",
"BACKUP_QUEUE_NAME",
",",
"BACKUP_QUEUE_TYPE",
",",
"this",
",",
"null",
")",
";",
"new",
"BaseMessageListener",
"(",
"m_messageFilter",
")",
"// Listener added to filter.",
"{",
"public",
"int",
"handleMessage",
"(",
"BaseMessage",
"message",
")",
"{",
"Object",
"objMessage",
"=",
"message",
".",
"get",
"(",
"MESSAGE_PARAM",
")",
";",
"backupTrxLog",
"(",
"objMessage",
")",
";",
"return",
"Constants",
".",
"NORMAL_RETURN",
";",
"}",
"}",
";",
"receiver",
".",
"addMessageFilter",
"(",
"m_messageFilter",
")",
";",
"}"
] |
Chat Screen Constructor.
@param parent Typically, you pass the BaseApplet as the parent.
@param @record and the record or GridTableModel as the parent.
|
[
"Chat",
"Screen",
"Constructor",
"."
] |
train
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/app/program/manual/backup/src/main/java/org/jbundle/app/program/manual/backup/BackupServerApp.java#L95-L117
|
Azure/azure-sdk-for-java
|
applicationinsights/resource-manager/v2015_05_01/src/main/java/com/microsoft/azure/management/applicationinsights/v2015_05_01/implementation/ProactiveDetectionConfigurationsInner.java
|
ProactiveDetectionConfigurationsInner.listAsync
|
public Observable<List<ApplicationInsightsComponentProactiveDetectionConfigurationInner>> listAsync(String resourceGroupName, String resourceName) {
"""
Gets a list of ProactiveDetection configurations of an Application Insights component.
@param resourceGroupName The name of the resource group.
@param resourceName The name of the Application Insights component resource.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<ApplicationInsightsComponentProactiveDetectionConfigurationInner> object
"""
return listWithServiceResponseAsync(resourceGroupName, resourceName).map(new Func1<ServiceResponse<List<ApplicationInsightsComponentProactiveDetectionConfigurationInner>>, List<ApplicationInsightsComponentProactiveDetectionConfigurationInner>>() {
@Override
public List<ApplicationInsightsComponentProactiveDetectionConfigurationInner> call(ServiceResponse<List<ApplicationInsightsComponentProactiveDetectionConfigurationInner>> response) {
return response.body();
}
});
}
|
java
|
public Observable<List<ApplicationInsightsComponentProactiveDetectionConfigurationInner>> listAsync(String resourceGroupName, String resourceName) {
return listWithServiceResponseAsync(resourceGroupName, resourceName).map(new Func1<ServiceResponse<List<ApplicationInsightsComponentProactiveDetectionConfigurationInner>>, List<ApplicationInsightsComponentProactiveDetectionConfigurationInner>>() {
@Override
public List<ApplicationInsightsComponentProactiveDetectionConfigurationInner> call(ServiceResponse<List<ApplicationInsightsComponentProactiveDetectionConfigurationInner>> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"List",
"<",
"ApplicationInsightsComponentProactiveDetectionConfigurationInner",
">",
">",
"listAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"resourceName",
")",
"{",
"return",
"listWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"resourceName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"List",
"<",
"ApplicationInsightsComponentProactiveDetectionConfigurationInner",
">",
">",
",",
"List",
"<",
"ApplicationInsightsComponentProactiveDetectionConfigurationInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"List",
"<",
"ApplicationInsightsComponentProactiveDetectionConfigurationInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"List",
"<",
"ApplicationInsightsComponentProactiveDetectionConfigurationInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Gets a list of ProactiveDetection configurations of an Application Insights component.
@param resourceGroupName The name of the resource group.
@param resourceName The name of the Application Insights component resource.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<ApplicationInsightsComponentProactiveDetectionConfigurationInner> object
|
[
"Gets",
"a",
"list",
"of",
"ProactiveDetection",
"configurations",
"of",
"an",
"Application",
"Insights",
"component",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/applicationinsights/resource-manager/v2015_05_01/src/main/java/com/microsoft/azure/management/applicationinsights/v2015_05_01/implementation/ProactiveDetectionConfigurationsInner.java#L107-L114
|
apache/incubator-gobblin
|
gobblin-core/src/main/java/org/apache/gobblin/publisher/BaseDataPublisher.java
|
BaseDataPublisher.getPublisherOutputDir
|
protected Path getPublisherOutputDir(WorkUnitState workUnitState, int branchId) {
"""
Get the output directory path this {@link BaseDataPublisher} will write to.
<p>
This is the default implementation. Subclasses of {@link BaseDataPublisher} may override this
to write to a custom directory or write using a custom directory structure or naming pattern.
</p>
@param workUnitState a {@link WorkUnitState} object
@param branchId the fork branch ID
@return the output directory path this {@link BaseDataPublisher} will write to
"""
return WriterUtils.getDataPublisherFinalDir(workUnitState, this.numBranches, branchId);
}
|
java
|
protected Path getPublisherOutputDir(WorkUnitState workUnitState, int branchId) {
return WriterUtils.getDataPublisherFinalDir(workUnitState, this.numBranches, branchId);
}
|
[
"protected",
"Path",
"getPublisherOutputDir",
"(",
"WorkUnitState",
"workUnitState",
",",
"int",
"branchId",
")",
"{",
"return",
"WriterUtils",
".",
"getDataPublisherFinalDir",
"(",
"workUnitState",
",",
"this",
".",
"numBranches",
",",
"branchId",
")",
";",
"}"
] |
Get the output directory path this {@link BaseDataPublisher} will write to.
<p>
This is the default implementation. Subclasses of {@link BaseDataPublisher} may override this
to write to a custom directory or write using a custom directory structure or naming pattern.
</p>
@param workUnitState a {@link WorkUnitState} object
@param branchId the fork branch ID
@return the output directory path this {@link BaseDataPublisher} will write to
|
[
"Get",
"the",
"output",
"directory",
"path",
"this",
"{",
"@link",
"BaseDataPublisher",
"}",
"will",
"write",
"to",
"."
] |
train
|
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-core/src/main/java/org/apache/gobblin/publisher/BaseDataPublisher.java#L455-L457
|
alkacon/opencms-core
|
src/org/opencms/db/generic/CmsHistoryDriver.java
|
CmsHistoryDriver.internalValidateResource
|
protected boolean internalValidateResource(CmsDbContext dbc, CmsResource resource, int publishTag)
throws CmsDataAccessException {
"""
Tests if a history resource does exist.<p>
@param dbc the current database context
@param resource the resource to test
@param publishTag the publish tag of the resource to test
@return <code>true</code> if the resource already exists, <code>false</code> otherwise
@throws CmsDataAccessException if something goes wrong
"""
Connection conn = null;
PreparedStatement stmt = null;
ResultSet res = null;
boolean exists = false;
try {
conn = m_sqlManager.getConnection(dbc);
stmt = m_sqlManager.getPreparedStatement(conn, "C_HISTORY_EXISTS_RESOURCE");
stmt.setString(1, resource.getResourceId().toString());
stmt.setInt(2, publishTag);
res = stmt.executeQuery();
exists = res.next();
} catch (SQLException e) {
throw new CmsDbSqlException(
Messages.get().container(Messages.ERR_GENERIC_SQL_1, CmsDbSqlException.getErrorQuery(stmt)),
e);
} finally {
m_sqlManager.closeAll(dbc, conn, stmt, res);
}
return exists;
}
|
java
|
protected boolean internalValidateResource(CmsDbContext dbc, CmsResource resource, int publishTag)
throws CmsDataAccessException {
Connection conn = null;
PreparedStatement stmt = null;
ResultSet res = null;
boolean exists = false;
try {
conn = m_sqlManager.getConnection(dbc);
stmt = m_sqlManager.getPreparedStatement(conn, "C_HISTORY_EXISTS_RESOURCE");
stmt.setString(1, resource.getResourceId().toString());
stmt.setInt(2, publishTag);
res = stmt.executeQuery();
exists = res.next();
} catch (SQLException e) {
throw new CmsDbSqlException(
Messages.get().container(Messages.ERR_GENERIC_SQL_1, CmsDbSqlException.getErrorQuery(stmt)),
e);
} finally {
m_sqlManager.closeAll(dbc, conn, stmt, res);
}
return exists;
}
|
[
"protected",
"boolean",
"internalValidateResource",
"(",
"CmsDbContext",
"dbc",
",",
"CmsResource",
"resource",
",",
"int",
"publishTag",
")",
"throws",
"CmsDataAccessException",
"{",
"Connection",
"conn",
"=",
"null",
";",
"PreparedStatement",
"stmt",
"=",
"null",
";",
"ResultSet",
"res",
"=",
"null",
";",
"boolean",
"exists",
"=",
"false",
";",
"try",
"{",
"conn",
"=",
"m_sqlManager",
".",
"getConnection",
"(",
"dbc",
")",
";",
"stmt",
"=",
"m_sqlManager",
".",
"getPreparedStatement",
"(",
"conn",
",",
"\"C_HISTORY_EXISTS_RESOURCE\"",
")",
";",
"stmt",
".",
"setString",
"(",
"1",
",",
"resource",
".",
"getResourceId",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"stmt",
".",
"setInt",
"(",
"2",
",",
"publishTag",
")",
";",
"res",
"=",
"stmt",
".",
"executeQuery",
"(",
")",
";",
"exists",
"=",
"res",
".",
"next",
"(",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"new",
"CmsDbSqlException",
"(",
"Messages",
".",
"get",
"(",
")",
".",
"container",
"(",
"Messages",
".",
"ERR_GENERIC_SQL_1",
",",
"CmsDbSqlException",
".",
"getErrorQuery",
"(",
"stmt",
")",
")",
",",
"e",
")",
";",
"}",
"finally",
"{",
"m_sqlManager",
".",
"closeAll",
"(",
"dbc",
",",
"conn",
",",
"stmt",
",",
"res",
")",
";",
"}",
"return",
"exists",
";",
"}"
] |
Tests if a history resource does exist.<p>
@param dbc the current database context
@param resource the resource to test
@param publishTag the publish tag of the resource to test
@return <code>true</code> if the resource already exists, <code>false</code> otherwise
@throws CmsDataAccessException if something goes wrong
|
[
"Tests",
"if",
"a",
"history",
"resource",
"does",
"exist",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/db/generic/CmsHistoryDriver.java#L1894-L1918
|
RobotiumTech/robotium
|
robotium-solo/src/main/java/com/robotium/solo/Waiter.java
|
Waiter.waitForView
|
public <T extends View> boolean waitForView(final Class<T> viewClass, final int index, boolean sleep, boolean scroll) {
"""
Waits for a view to be shown.
@param viewClass the {@code View} class to wait for
@param index the index of the view that is expected to be shown
@param sleep true if should sleep
@param scroll {@code true} if scrolling should be performed
@return {@code true} if view is shown and {@code false} if it is not shown before the timeout
"""
Set<T> uniqueViews = new HashSet<T>();
boolean foundMatchingView;
while(true){
if(sleep)
sleeper.sleep();
foundMatchingView = searcher.searchFor(uniqueViews, viewClass, index);
if(foundMatchingView)
return true;
if(scroll && !scroller.scrollDown())
return false;
if(!scroll)
return false;
}
}
|
java
|
public <T extends View> boolean waitForView(final Class<T> viewClass, final int index, boolean sleep, boolean scroll){
Set<T> uniqueViews = new HashSet<T>();
boolean foundMatchingView;
while(true){
if(sleep)
sleeper.sleep();
foundMatchingView = searcher.searchFor(uniqueViews, viewClass, index);
if(foundMatchingView)
return true;
if(scroll && !scroller.scrollDown())
return false;
if(!scroll)
return false;
}
}
|
[
"public",
"<",
"T",
"extends",
"View",
">",
"boolean",
"waitForView",
"(",
"final",
"Class",
"<",
"T",
">",
"viewClass",
",",
"final",
"int",
"index",
",",
"boolean",
"sleep",
",",
"boolean",
"scroll",
")",
"{",
"Set",
"<",
"T",
">",
"uniqueViews",
"=",
"new",
"HashSet",
"<",
"T",
">",
"(",
")",
";",
"boolean",
"foundMatchingView",
";",
"while",
"(",
"true",
")",
"{",
"if",
"(",
"sleep",
")",
"sleeper",
".",
"sleep",
"(",
")",
";",
"foundMatchingView",
"=",
"searcher",
".",
"searchFor",
"(",
"uniqueViews",
",",
"viewClass",
",",
"index",
")",
";",
"if",
"(",
"foundMatchingView",
")",
"return",
"true",
";",
"if",
"(",
"scroll",
"&&",
"!",
"scroller",
".",
"scrollDown",
"(",
")",
")",
"return",
"false",
";",
"if",
"(",
"!",
"scroll",
")",
"return",
"false",
";",
"}",
"}"
] |
Waits for a view to be shown.
@param viewClass the {@code View} class to wait for
@param index the index of the view that is expected to be shown
@param sleep true if should sleep
@param scroll {@code true} if scrolling should be performed
@return {@code true} if view is shown and {@code false} if it is not shown before the timeout
|
[
"Waits",
"for",
"a",
"view",
"to",
"be",
"shown",
"."
] |
train
|
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Waiter.java#L212-L232
|
legsem/legstar-core2
|
legstar-base/src/main/java/com/legstar/base/visitor/FromCobolVisitor.java
|
FromCobolVisitor.isCustomVariable
|
public boolean isCustomVariable(CobolPrimitiveType < ? > type, String name) {
"""
A primitive type is a custom variable if it has been marked as so via one
of the available mechanisms or is needed to make choice decisions.
@param type the primitive type
@param name the variable name
@return true if this is a custom variable
"""
if (type.isCustomVariable()) {
return true;
}
if (customVariables != null && customVariables.contains(name)) {
return true;
}
if (customChoiceStrategy != null
&& customChoiceStrategy.getVariableNames() != null
&& customChoiceStrategy.getVariableNames().contains(name)) {
return true;
}
return false;
}
|
java
|
public boolean isCustomVariable(CobolPrimitiveType < ? > type, String name) {
if (type.isCustomVariable()) {
return true;
}
if (customVariables != null && customVariables.contains(name)) {
return true;
}
if (customChoiceStrategy != null
&& customChoiceStrategy.getVariableNames() != null
&& customChoiceStrategy.getVariableNames().contains(name)) {
return true;
}
return false;
}
|
[
"public",
"boolean",
"isCustomVariable",
"(",
"CobolPrimitiveType",
"<",
"?",
">",
"type",
",",
"String",
"name",
")",
"{",
"if",
"(",
"type",
".",
"isCustomVariable",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"customVariables",
"!=",
"null",
"&&",
"customVariables",
".",
"contains",
"(",
"name",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"customChoiceStrategy",
"!=",
"null",
"&&",
"customChoiceStrategy",
".",
"getVariableNames",
"(",
")",
"!=",
"null",
"&&",
"customChoiceStrategy",
".",
"getVariableNames",
"(",
")",
".",
"contains",
"(",
"name",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
A primitive type is a custom variable if it has been marked as so via one
of the available mechanisms or is needed to make choice decisions.
@param type the primitive type
@param name the variable name
@return true if this is a custom variable
|
[
"A",
"primitive",
"type",
"is",
"a",
"custom",
"variable",
"if",
"it",
"has",
"been",
"marked",
"as",
"so",
"via",
"one",
"of",
"the",
"available",
"mechanisms",
"or",
"is",
"needed",
"to",
"make",
"choice",
"decisions",
"."
] |
train
|
https://github.com/legsem/legstar-core2/blob/f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6/legstar-base/src/main/java/com/legstar/base/visitor/FromCobolVisitor.java#L588-L601
|
cdk/cdk
|
legacy/src/main/java/org/openscience/cdk/geometry/GeometryTools.java
|
GeometryTools.shiftContainer
|
public static Rectangle2D shiftContainer(IAtomContainer container, Rectangle2D bounds, Rectangle2D last, double gap) {
"""
Shift the container horizontally to the right to make its bounds not
overlap with the other bounds.
@param container the {@link IAtomContainer} to shift to the right
@param bounds the {@link Rectangle2D} of the {@link IAtomContainer}
to shift
@param last the bounds that is used as reference
@param gap the gap between the two {@link Rectangle2D}s
@return the {@link Rectangle2D} of the {@link IAtomContainer}
after the shift
"""
// determine if the containers are overlapping
if (last.getMaxX() + gap >= bounds.getMinX()) {
double xShift = last.getMaxX() + gap - bounds.getMinX();
Vector2d shift = new Vector2d(xShift, 0.0);
GeometryTools.translate2D(container, shift);
return new Rectangle2D.Double(bounds.getX() + xShift, bounds.getY(), bounds.getWidth(), bounds.getHeight());
} else {
// the containers are not overlapping
return bounds;
}
}
|
java
|
public static Rectangle2D shiftContainer(IAtomContainer container, Rectangle2D bounds, Rectangle2D last, double gap) {
// determine if the containers are overlapping
if (last.getMaxX() + gap >= bounds.getMinX()) {
double xShift = last.getMaxX() + gap - bounds.getMinX();
Vector2d shift = new Vector2d(xShift, 0.0);
GeometryTools.translate2D(container, shift);
return new Rectangle2D.Double(bounds.getX() + xShift, bounds.getY(), bounds.getWidth(), bounds.getHeight());
} else {
// the containers are not overlapping
return bounds;
}
}
|
[
"public",
"static",
"Rectangle2D",
"shiftContainer",
"(",
"IAtomContainer",
"container",
",",
"Rectangle2D",
"bounds",
",",
"Rectangle2D",
"last",
",",
"double",
"gap",
")",
"{",
"// determine if the containers are overlapping",
"if",
"(",
"last",
".",
"getMaxX",
"(",
")",
"+",
"gap",
">=",
"bounds",
".",
"getMinX",
"(",
")",
")",
"{",
"double",
"xShift",
"=",
"last",
".",
"getMaxX",
"(",
")",
"+",
"gap",
"-",
"bounds",
".",
"getMinX",
"(",
")",
";",
"Vector2d",
"shift",
"=",
"new",
"Vector2d",
"(",
"xShift",
",",
"0.0",
")",
";",
"GeometryTools",
".",
"translate2D",
"(",
"container",
",",
"shift",
")",
";",
"return",
"new",
"Rectangle2D",
".",
"Double",
"(",
"bounds",
".",
"getX",
"(",
")",
"+",
"xShift",
",",
"bounds",
".",
"getY",
"(",
")",
",",
"bounds",
".",
"getWidth",
"(",
")",
",",
"bounds",
".",
"getHeight",
"(",
")",
")",
";",
"}",
"else",
"{",
"// the containers are not overlapping",
"return",
"bounds",
";",
"}",
"}"
] |
Shift the container horizontally to the right to make its bounds not
overlap with the other bounds.
@param container the {@link IAtomContainer} to shift to the right
@param bounds the {@link Rectangle2D} of the {@link IAtomContainer}
to shift
@param last the bounds that is used as reference
@param gap the gap between the two {@link Rectangle2D}s
@return the {@link Rectangle2D} of the {@link IAtomContainer}
after the shift
|
[
"Shift",
"the",
"container",
"horizontally",
"to",
"the",
"right",
"to",
"make",
"its",
"bounds",
"not",
"overlap",
"with",
"the",
"other",
"bounds",
"."
] |
train
|
https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/legacy/src/main/java/org/openscience/cdk/geometry/GeometryTools.java#L1649-L1660
|
lievendoclo/Valkyrie-RCP
|
valkyrie-rcp-core/src/main/java/org/valkyriercp/form/builder/GridBagLayoutFormBuilder.java
|
GridBagLayoutFormBuilder.appendLabeledField
|
public GridBagLayoutFormBuilder appendLabeledField(String propertyName, LabelOrientation labelOrientation,
int colSpan) {
"""
Appends a label and field to the end of the current line.
<p />
The label will be to the left of the field, and be right-justified.
<br />
The field will "grow" horizontally as space allows.
<p />
@param propertyName the name of the property to create the controls for
@param colSpan the number of columns the field should span
@return "this" to make it easier to string together append calls
"""
final JComponent field = createDefaultBinding(propertyName).getControl();
return appendLabeledField(propertyName, field, labelOrientation, colSpan);
}
|
java
|
public GridBagLayoutFormBuilder appendLabeledField(String propertyName, LabelOrientation labelOrientation,
int colSpan) {
final JComponent field = createDefaultBinding(propertyName).getControl();
return appendLabeledField(propertyName, field, labelOrientation, colSpan);
}
|
[
"public",
"GridBagLayoutFormBuilder",
"appendLabeledField",
"(",
"String",
"propertyName",
",",
"LabelOrientation",
"labelOrientation",
",",
"int",
"colSpan",
")",
"{",
"final",
"JComponent",
"field",
"=",
"createDefaultBinding",
"(",
"propertyName",
")",
".",
"getControl",
"(",
")",
";",
"return",
"appendLabeledField",
"(",
"propertyName",
",",
"field",
",",
"labelOrientation",
",",
"colSpan",
")",
";",
"}"
] |
Appends a label and field to the end of the current line.
<p />
The label will be to the left of the field, and be right-justified.
<br />
The field will "grow" horizontally as space allows.
<p />
@param propertyName the name of the property to create the controls for
@param colSpan the number of columns the field should span
@return "this" to make it easier to string together append calls
|
[
"Appends",
"a",
"label",
"and",
"field",
"to",
"the",
"end",
"of",
"the",
"current",
"line",
".",
"<p",
"/",
">"
] |
train
|
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/form/builder/GridBagLayoutFormBuilder.java#L114-L119
|
groovyfx-project/groovyfx
|
src/main/groovy/groovyx/javafx/beans/FXBindableASTTransformation.java
|
FXBindableASTTransformation.createFieldNodeCopy
|
private FieldNode createFieldNodeCopy(String newName, ClassNode newType, FieldNode f) {
"""
Creates a copy of a FieldNode with a new name and, optionally, a new type.
@param newName The name for the new field node.
@param newType The new type of the field. If null, the old FieldNode's type will be used.
@param f The FieldNode to copy.
@return The new FieldNode.
"""
if (newType == null)
newType = f.getType();
newType = newType.getPlainNodeReference();
return new FieldNode(newName, f.getModifiers(), newType, f.getOwner(), f.getInitialValueExpression());
}
|
java
|
private FieldNode createFieldNodeCopy(String newName, ClassNode newType, FieldNode f) {
if (newType == null)
newType = f.getType();
newType = newType.getPlainNodeReference();
return new FieldNode(newName, f.getModifiers(), newType, f.getOwner(), f.getInitialValueExpression());
}
|
[
"private",
"FieldNode",
"createFieldNodeCopy",
"(",
"String",
"newName",
",",
"ClassNode",
"newType",
",",
"FieldNode",
"f",
")",
"{",
"if",
"(",
"newType",
"==",
"null",
")",
"newType",
"=",
"f",
".",
"getType",
"(",
")",
";",
"newType",
"=",
"newType",
".",
"getPlainNodeReference",
"(",
")",
";",
"return",
"new",
"FieldNode",
"(",
"newName",
",",
"f",
".",
"getModifiers",
"(",
")",
",",
"newType",
",",
"f",
".",
"getOwner",
"(",
")",
",",
"f",
".",
"getInitialValueExpression",
"(",
")",
")",
";",
"}"
] |
Creates a copy of a FieldNode with a new name and, optionally, a new type.
@param newName The name for the new field node.
@param newType The new type of the field. If null, the old FieldNode's type will be used.
@param f The FieldNode to copy.
@return The new FieldNode.
|
[
"Creates",
"a",
"copy",
"of",
"a",
"FieldNode",
"with",
"a",
"new",
"name",
"and",
"optionally",
"a",
"new",
"type",
"."
] |
train
|
https://github.com/groovyfx-project/groovyfx/blob/7067d76793601ce4de9c642d4c0c0e11db7907cb/src/main/groovy/groovyx/javafx/beans/FXBindableASTTransformation.java#L658-L664
|
elki-project/elki
|
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java
|
SVGPlot.svgCircle
|
public Element svgCircle(double cx, double cy, double r) {
"""
Create a SVG circle
@param cx center X
@param cy center Y
@param r radius
@return new element
"""
return SVGUtil.svgCircle(document, cx, cy, r);
}
|
java
|
public Element svgCircle(double cx, double cy, double r) {
return SVGUtil.svgCircle(document, cx, cy, r);
}
|
[
"public",
"Element",
"svgCircle",
"(",
"double",
"cx",
",",
"double",
"cy",
",",
"double",
"r",
")",
"{",
"return",
"SVGUtil",
".",
"svgCircle",
"(",
"document",
",",
"cx",
",",
"cy",
",",
"r",
")",
";",
"}"
] |
Create a SVG circle
@param cx center X
@param cy center Y
@param r radius
@return new element
|
[
"Create",
"a",
"SVG",
"circle"
] |
train
|
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java#L266-L268
|
auth0/Auth0.Android
|
auth0/src/main/java/com/auth0/android/provider/AuthProvider.java
|
AuthProvider.requestPermissions
|
private void requestPermissions(Activity activity, int requestCode) {
"""
Starts the async Permission Request. The caller activity will be notified of the result on the
onRequestPermissionsResult method, from the ActivityCompat.OnRequestPermissionsResultCallback
interface.
@param activity a valid activity context. It will receive the permissions
request result on the onRequestPermissionsResult method.
@param requestCode the code to use for the Permissions Request.
"""
String[] permissions = getRequiredAndroidPermissions();
handler.requestPermissions(activity, permissions, requestCode);
}
|
java
|
private void requestPermissions(Activity activity, int requestCode) {
String[] permissions = getRequiredAndroidPermissions();
handler.requestPermissions(activity, permissions, requestCode);
}
|
[
"private",
"void",
"requestPermissions",
"(",
"Activity",
"activity",
",",
"int",
"requestCode",
")",
"{",
"String",
"[",
"]",
"permissions",
"=",
"getRequiredAndroidPermissions",
"(",
")",
";",
"handler",
".",
"requestPermissions",
"(",
"activity",
",",
"permissions",
",",
"requestCode",
")",
";",
"}"
] |
Starts the async Permission Request. The caller activity will be notified of the result on the
onRequestPermissionsResult method, from the ActivityCompat.OnRequestPermissionsResultCallback
interface.
@param activity a valid activity context. It will receive the permissions
request result on the onRequestPermissionsResult method.
@param requestCode the code to use for the Permissions Request.
|
[
"Starts",
"the",
"async",
"Permission",
"Request",
".",
"The",
"caller",
"activity",
"will",
"be",
"notified",
"of",
"the",
"result",
"on",
"the",
"onRequestPermissionsResult",
"method",
"from",
"the",
"ActivityCompat",
".",
"OnRequestPermissionsResultCallback",
"interface",
"."
] |
train
|
https://github.com/auth0/Auth0.Android/blob/ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156/auth0/src/main/java/com/auth0/android/provider/AuthProvider.java#L199-L202
|
Azure/azure-sdk-for-java
|
cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/PersonGroupPersonsImpl.java
|
PersonGroupPersonsImpl.deleteFaceAsync
|
public Observable<Void> deleteFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId) {
"""
Delete a face from a person. Relative image for the persisted face will also be deleted.
@param personGroupId Id referencing a particular person group.
@param personId Id referencing a particular person.
@param persistedFaceId Id referencing a particular persistedFaceId of an existing face.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful.
"""
return deleteFaceWithServiceResponseAsync(personGroupId, personId, persistedFaceId).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
}
|
java
|
public Observable<Void> deleteFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId) {
return deleteFaceWithServiceResponseAsync(personGroupId, personId, persistedFaceId).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"Void",
">",
"deleteFaceAsync",
"(",
"String",
"personGroupId",
",",
"UUID",
"personId",
",",
"UUID",
"persistedFaceId",
")",
"{",
"return",
"deleteFaceWithServiceResponseAsync",
"(",
"personGroupId",
",",
"personId",
",",
"persistedFaceId",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Void",
">",
",",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
"ServiceResponse",
"<",
"Void",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Delete a face from a person. Relative image for the persisted face will also be deleted.
@param personGroupId Id referencing a particular person group.
@param personId Id referencing a particular person.
@param persistedFaceId Id referencing a particular persistedFaceId of an existing face.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful.
|
[
"Delete",
"a",
"face",
"from",
"a",
"person",
".",
"Relative",
"image",
"for",
"the",
"persisted",
"face",
"will",
"also",
"be",
"deleted",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/PersonGroupPersonsImpl.java#L826-L833
|
chocoteam/choco-graph
|
src/main/java/org/chocosolver/graphsolver/util/LCAGraphManager.java
|
LCAGraphManager.getLCADFS
|
private int getLCADFS(int x, int y) {
"""
Get the lowest common ancestor of two nodes in O(1) time
Query by Chris Lewis
1. Find the lowest common ancestor b in the binary tree of nodes I(x) and I(y).
2. Find the smallest position j ≥ h(b) such that both numbers A x and A y have 1-bits in position j.
This gives j = h(I(z)).
3. Find node x', the closest node to x on the same run as z:
a. Find the position l of the right-most 1 bit in A x
b. If l = j, then set x' = x {x and z are on the same run in the general graph} and go to step 4.
c. Find the position k of the left-most 1-bit in A x that is to the right of position j.
Form the number consisting of the bits of I(x) to the left of the position k,
followed by a 1-bit in position k, followed by all zeros. {That number will be I(w)}
Look up node L(I(w)), which must be node w. Set node x' to be the parent of node w in the general tree.
4. Find node y', the closest node to y on the same run as z using the approach described in step 3.
5. If x' < y' then set z to x' else set z to y'
@param x node dfs number
@param y node dfs number
@return the dfs number of the lowest common ancestor of a and b in the dfs tree
"""
// trivial cases
if (x == y || x == father[y]) {
return x;
}
if (y == father[x]) {
return y;
}
// step 1
int b = BitOperations.binaryLCA(I[x] + 1, I[y] + 1);
// step 2
int hb = BitOperations.getFirstExp(b);
if (hb == -1) {
throw new UnsupportedOperationException();
}
int j = BitOperations.getFirstExpInBothXYfromI(A[x], A[y], hb);
if (j == -1) {
throw new UnsupportedOperationException();
}
// step 3 & 4
int xPrim = closestFrom(x, j);
int yPrim = closestFrom(y, j);
// step 5
if (xPrim < yPrim) {
return xPrim;
}
return yPrim;
}
|
java
|
private int getLCADFS(int x, int y) {
// trivial cases
if (x == y || x == father[y]) {
return x;
}
if (y == father[x]) {
return y;
}
// step 1
int b = BitOperations.binaryLCA(I[x] + 1, I[y] + 1);
// step 2
int hb = BitOperations.getFirstExp(b);
if (hb == -1) {
throw new UnsupportedOperationException();
}
int j = BitOperations.getFirstExpInBothXYfromI(A[x], A[y], hb);
if (j == -1) {
throw new UnsupportedOperationException();
}
// step 3 & 4
int xPrim = closestFrom(x, j);
int yPrim = closestFrom(y, j);
// step 5
if (xPrim < yPrim) {
return xPrim;
}
return yPrim;
}
|
[
"private",
"int",
"getLCADFS",
"(",
"int",
"x",
",",
"int",
"y",
")",
"{",
"// trivial cases",
"if",
"(",
"x",
"==",
"y",
"||",
"x",
"==",
"father",
"[",
"y",
"]",
")",
"{",
"return",
"x",
";",
"}",
"if",
"(",
"y",
"==",
"father",
"[",
"x",
"]",
")",
"{",
"return",
"y",
";",
"}",
"// step 1",
"int",
"b",
"=",
"BitOperations",
".",
"binaryLCA",
"(",
"I",
"[",
"x",
"]",
"+",
"1",
",",
"I",
"[",
"y",
"]",
"+",
"1",
")",
";",
"// step 2",
"int",
"hb",
"=",
"BitOperations",
".",
"getFirstExp",
"(",
"b",
")",
";",
"if",
"(",
"hb",
"==",
"-",
"1",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"int",
"j",
"=",
"BitOperations",
".",
"getFirstExpInBothXYfromI",
"(",
"A",
"[",
"x",
"]",
",",
"A",
"[",
"y",
"]",
",",
"hb",
")",
";",
"if",
"(",
"j",
"==",
"-",
"1",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"// step 3 & 4",
"int",
"xPrim",
"=",
"closestFrom",
"(",
"x",
",",
"j",
")",
";",
"int",
"yPrim",
"=",
"closestFrom",
"(",
"y",
",",
"j",
")",
";",
"// step 5",
"if",
"(",
"xPrim",
"<",
"yPrim",
")",
"{",
"return",
"xPrim",
";",
"}",
"return",
"yPrim",
";",
"}"
] |
Get the lowest common ancestor of two nodes in O(1) time
Query by Chris Lewis
1. Find the lowest common ancestor b in the binary tree of nodes I(x) and I(y).
2. Find the smallest position j ≥ h(b) such that both numbers A x and A y have 1-bits in position j.
This gives j = h(I(z)).
3. Find node x', the closest node to x on the same run as z:
a. Find the position l of the right-most 1 bit in A x
b. If l = j, then set x' = x {x and z are on the same run in the general graph} and go to step 4.
c. Find the position k of the left-most 1-bit in A x that is to the right of position j.
Form the number consisting of the bits of I(x) to the left of the position k,
followed by a 1-bit in position k, followed by all zeros. {That number will be I(w)}
Look up node L(I(w)), which must be node w. Set node x' to be the parent of node w in the general tree.
4. Find node y', the closest node to y on the same run as z using the approach described in step 3.
5. If x' < y' then set z to x' else set z to y'
@param x node dfs number
@param y node dfs number
@return the dfs number of the lowest common ancestor of a and b in the dfs tree
|
[
"Get",
"the",
"lowest",
"common",
"ancestor",
"of",
"two",
"nodes",
"in",
"O",
"(",
"1",
")",
"time",
"Query",
"by",
"Chris",
"Lewis",
"1",
".",
"Find",
"the",
"lowest",
"common",
"ancestor",
"b",
"in",
"the",
"binary",
"tree",
"of",
"nodes",
"I",
"(",
"x",
")",
"and",
"I",
"(",
"y",
")",
".",
"2",
".",
"Find",
"the",
"smallest",
"position",
"j",
"&ge",
";",
"h",
"(",
"b",
")",
"such",
"that",
"both",
"numbers",
"A",
"x",
"and",
"A",
"y",
"have",
"1",
"-",
"bits",
"in",
"position",
"j",
".",
"This",
"gives",
"j",
"=",
"h",
"(",
"I",
"(",
"z",
"))",
".",
"3",
".",
"Find",
"node",
"x",
"the",
"closest",
"node",
"to",
"x",
"on",
"the",
"same",
"run",
"as",
"z",
":",
"a",
".",
"Find",
"the",
"position",
"l",
"of",
"the",
"right",
"-",
"most",
"1",
"bit",
"in",
"A",
"x",
"b",
".",
"If",
"l",
"=",
"j",
"then",
"set",
"x",
"=",
"x",
"{",
"x",
"and",
"z",
"are",
"on",
"the",
"same",
"run",
"in",
"the",
"general",
"graph",
"}",
"and",
"go",
"to",
"step",
"4",
".",
"c",
".",
"Find",
"the",
"position",
"k",
"of",
"the",
"left",
"-",
"most",
"1",
"-",
"bit",
"in",
"A",
"x",
"that",
"is",
"to",
"the",
"right",
"of",
"position",
"j",
".",
"Form",
"the",
"number",
"consisting",
"of",
"the",
"bits",
"of",
"I",
"(",
"x",
")",
"to",
"the",
"left",
"of",
"the",
"position",
"k",
"followed",
"by",
"a",
"1",
"-",
"bit",
"in",
"position",
"k",
"followed",
"by",
"all",
"zeros",
".",
"{",
"That",
"number",
"will",
"be",
"I",
"(",
"w",
")",
"}",
"Look",
"up",
"node",
"L",
"(",
"I",
"(",
"w",
"))",
"which",
"must",
"be",
"node",
"w",
".",
"Set",
"node",
"x",
"to",
"be",
"the",
"parent",
"of",
"node",
"w",
"in",
"the",
"general",
"tree",
".",
"4",
".",
"Find",
"node",
"y",
"the",
"closest",
"node",
"to",
"y",
"on",
"the",
"same",
"run",
"as",
"z",
"using",
"the",
"approach",
"described",
"in",
"step",
"3",
".",
"5",
".",
"If",
"x",
"<",
"y",
"then",
"set",
"z",
"to",
"x",
"else",
"set",
"z",
"to",
"y"
] |
train
|
https://github.com/chocoteam/choco-graph/blob/0a03b0aafc86601977728c7e3fcb5ed376f1fae9/src/main/java/org/chocosolver/graphsolver/util/LCAGraphManager.java#L232-L259
|
liferay/com-liferay-commerce
|
commerce-service/src/main/java/com/liferay/commerce/service/persistence/impl/CommerceAddressPersistenceImpl.java
|
CommerceAddressPersistenceImpl.countByG_C_C
|
@Override
public int countByG_C_C(long groupId, long classNameId, long classPK) {
"""
Returns the number of commerce addresses where groupId = ? and classNameId = ? and classPK = ?.
@param groupId the group ID
@param classNameId the class name ID
@param classPK the class pk
@return the number of matching commerce addresses
"""
FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_C;
Object[] finderArgs = new Object[] { groupId, classNameId, classPK };
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_COUNT_COMMERCEADDRESS_WHERE);
query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(classNameId);
qPos.add(classPK);
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
|
java
|
@Override
public int countByG_C_C(long groupId, long classNameId, long classPK) {
FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C_C;
Object[] finderArgs = new Object[] { groupId, classNameId, classPK };
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_COUNT_COMMERCEADDRESS_WHERE);
query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(groupId);
qPos.add(classNameId);
qPos.add(classPK);
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
|
[
"@",
"Override",
"public",
"int",
"countByG_C_C",
"(",
"long",
"groupId",
",",
"long",
"classNameId",
",",
"long",
"classPK",
")",
"{",
"FinderPath",
"finderPath",
"=",
"FINDER_PATH_COUNT_BY_G_C_C",
";",
"Object",
"[",
"]",
"finderArgs",
"=",
"new",
"Object",
"[",
"]",
"{",
"groupId",
",",
"classNameId",
",",
"classPK",
"}",
";",
"Long",
"count",
"=",
"(",
"Long",
")",
"finderCache",
".",
"getResult",
"(",
"finderPath",
",",
"finderArgs",
",",
"this",
")",
";",
"if",
"(",
"count",
"==",
"null",
")",
"{",
"StringBundler",
"query",
"=",
"new",
"StringBundler",
"(",
"4",
")",
";",
"query",
".",
"append",
"(",
"_SQL_COUNT_COMMERCEADDRESS_WHERE",
")",
";",
"query",
".",
"append",
"(",
"_FINDER_COLUMN_G_C_C_GROUPID_2",
")",
";",
"query",
".",
"append",
"(",
"_FINDER_COLUMN_G_C_C_CLASSNAMEID_2",
")",
";",
"query",
".",
"append",
"(",
"_FINDER_COLUMN_G_C_C_CLASSPK_2",
")",
";",
"String",
"sql",
"=",
"query",
".",
"toString",
"(",
")",
";",
"Session",
"session",
"=",
"null",
";",
"try",
"{",
"session",
"=",
"openSession",
"(",
")",
";",
"Query",
"q",
"=",
"session",
".",
"createQuery",
"(",
"sql",
")",
";",
"QueryPos",
"qPos",
"=",
"QueryPos",
".",
"getInstance",
"(",
"q",
")",
";",
"qPos",
".",
"add",
"(",
"groupId",
")",
";",
"qPos",
".",
"add",
"(",
"classNameId",
")",
";",
"qPos",
".",
"add",
"(",
"classPK",
")",
";",
"count",
"=",
"(",
"Long",
")",
"q",
".",
"uniqueResult",
"(",
")",
";",
"finderCache",
".",
"putResult",
"(",
"finderPath",
",",
"finderArgs",
",",
"count",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"finderCache",
".",
"removeResult",
"(",
"finderPath",
",",
"finderArgs",
")",
";",
"throw",
"processException",
"(",
"e",
")",
";",
"}",
"finally",
"{",
"closeSession",
"(",
"session",
")",
";",
"}",
"}",
"return",
"count",
".",
"intValue",
"(",
")",
";",
"}"
] |
Returns the number of commerce addresses where groupId = ? and classNameId = ? and classPK = ?.
@param groupId the group ID
@param classNameId the class name ID
@param classPK the class pk
@return the number of matching commerce addresses
|
[
"Returns",
"the",
"number",
"of",
"commerce",
"addresses",
"where",
"groupId",
"=",
"?",
";",
"and",
"classNameId",
"=",
"?",
";",
"and",
"classPK",
"=",
"?",
";",
"."
] |
train
|
https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-service/src/main/java/com/liferay/commerce/service/persistence/impl/CommerceAddressPersistenceImpl.java#L2210-L2261
|
apache/incubator-druid
|
sql/src/main/java/org/apache/druid/sql/calcite/expression/Expressions.java
|
Expressions.buildTimeFloorFilter
|
private static DimFilter buildTimeFloorFilter(
final String column,
final Granularity granularity,
final SqlKind operatorKind,
final long rhsMillis
) {
"""
Build a filter for an expression like FLOOR(column TO granularity) [operator] rhsMillis
"""
final BoundRefKey boundRefKey = new BoundRefKey(column, null, StringComparators.NUMERIC);
final Interval rhsInterval = granularity.bucket(DateTimes.utc(rhsMillis));
// Is rhs aligned on granularity boundaries?
final boolean rhsAligned = rhsInterval.getStartMillis() == rhsMillis;
return getBoundTimeDimFilter(operatorKind, boundRefKey, rhsInterval, rhsAligned);
}
|
java
|
private static DimFilter buildTimeFloorFilter(
final String column,
final Granularity granularity,
final SqlKind operatorKind,
final long rhsMillis
)
{
final BoundRefKey boundRefKey = new BoundRefKey(column, null, StringComparators.NUMERIC);
final Interval rhsInterval = granularity.bucket(DateTimes.utc(rhsMillis));
// Is rhs aligned on granularity boundaries?
final boolean rhsAligned = rhsInterval.getStartMillis() == rhsMillis;
return getBoundTimeDimFilter(operatorKind, boundRefKey, rhsInterval, rhsAligned);
}
|
[
"private",
"static",
"DimFilter",
"buildTimeFloorFilter",
"(",
"final",
"String",
"column",
",",
"final",
"Granularity",
"granularity",
",",
"final",
"SqlKind",
"operatorKind",
",",
"final",
"long",
"rhsMillis",
")",
"{",
"final",
"BoundRefKey",
"boundRefKey",
"=",
"new",
"BoundRefKey",
"(",
"column",
",",
"null",
",",
"StringComparators",
".",
"NUMERIC",
")",
";",
"final",
"Interval",
"rhsInterval",
"=",
"granularity",
".",
"bucket",
"(",
"DateTimes",
".",
"utc",
"(",
"rhsMillis",
")",
")",
";",
"// Is rhs aligned on granularity boundaries?",
"final",
"boolean",
"rhsAligned",
"=",
"rhsInterval",
".",
"getStartMillis",
"(",
")",
"==",
"rhsMillis",
";",
"return",
"getBoundTimeDimFilter",
"(",
"operatorKind",
",",
"boundRefKey",
",",
"rhsInterval",
",",
"rhsAligned",
")",
";",
"}"
] |
Build a filter for an expression like FLOOR(column TO granularity) [operator] rhsMillis
|
[
"Build",
"a",
"filter",
"for",
"an",
"expression",
"like",
"FLOOR",
"(",
"column",
"TO",
"granularity",
")",
"[",
"operator",
"]",
"rhsMillis"
] |
train
|
https://github.com/apache/incubator-druid/blob/f776b9408962b9006cfcfe4d6c1794751972cc8e/sql/src/main/java/org/apache/druid/sql/calcite/expression/Expressions.java#L610-L624
|
xiancloud/xian
|
xian-zookeeper/xian-curator/xian-curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedValue.java
|
SharedValue.trySetValue
|
public boolean trySetValue(VersionedValue<byte[]> previous, byte[] newValue) throws Exception {
"""
Changes the shared value only if its value has not changed since the version specified by
newValue. If the value has changed, the value is not set and this client's view of the
value is updated. i.e. if the value is not successful you can get the updated value
by calling {@link #getValue()}.
@param newValue the new value to attempt
@return true if the change attempt was successful, false if not. If the change
was not successful, {@link #getValue()} will return the updated value
@throws Exception ZK errors, interruptions, etc.
"""
Preconditions.checkState(state.get() == State.STARTED, "not started");
VersionedValue<byte[]> current = currentValue.get();
if ( previous.getVersion() != current.getVersion() || !Arrays.equals(previous.getValue(), current.getValue()) )
{
return false;
}
try
{
Stat result = client.setData().withVersion(previous.getVersion()).forPath(path, newValue);
updateValue(result.getVersion(), Arrays.copyOf(newValue, newValue.length));
return true;
}
catch ( KeeperException.BadVersionException ignore )
{
// ignore
}
readValue();
return false;
}
|
java
|
public boolean trySetValue(VersionedValue<byte[]> previous, byte[] newValue) throws Exception
{
Preconditions.checkState(state.get() == State.STARTED, "not started");
VersionedValue<byte[]> current = currentValue.get();
if ( previous.getVersion() != current.getVersion() || !Arrays.equals(previous.getValue(), current.getValue()) )
{
return false;
}
try
{
Stat result = client.setData().withVersion(previous.getVersion()).forPath(path, newValue);
updateValue(result.getVersion(), Arrays.copyOf(newValue, newValue.length));
return true;
}
catch ( KeeperException.BadVersionException ignore )
{
// ignore
}
readValue();
return false;
}
|
[
"public",
"boolean",
"trySetValue",
"(",
"VersionedValue",
"<",
"byte",
"[",
"]",
">",
"previous",
",",
"byte",
"[",
"]",
"newValue",
")",
"throws",
"Exception",
"{",
"Preconditions",
".",
"checkState",
"(",
"state",
".",
"get",
"(",
")",
"==",
"State",
".",
"STARTED",
",",
"\"not started\"",
")",
";",
"VersionedValue",
"<",
"byte",
"[",
"]",
">",
"current",
"=",
"currentValue",
".",
"get",
"(",
")",
";",
"if",
"(",
"previous",
".",
"getVersion",
"(",
")",
"!=",
"current",
".",
"getVersion",
"(",
")",
"||",
"!",
"Arrays",
".",
"equals",
"(",
"previous",
".",
"getValue",
"(",
")",
",",
"current",
".",
"getValue",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"try",
"{",
"Stat",
"result",
"=",
"client",
".",
"setData",
"(",
")",
".",
"withVersion",
"(",
"previous",
".",
"getVersion",
"(",
")",
")",
".",
"forPath",
"(",
"path",
",",
"newValue",
")",
";",
"updateValue",
"(",
"result",
".",
"getVersion",
"(",
")",
",",
"Arrays",
".",
"copyOf",
"(",
"newValue",
",",
"newValue",
".",
"length",
")",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"KeeperException",
".",
"BadVersionException",
"ignore",
")",
"{",
"// ignore",
"}",
"readValue",
"(",
")",
";",
"return",
"false",
";",
"}"
] |
Changes the shared value only if its value has not changed since the version specified by
newValue. If the value has changed, the value is not set and this client's view of the
value is updated. i.e. if the value is not successful you can get the updated value
by calling {@link #getValue()}.
@param newValue the new value to attempt
@return true if the change attempt was successful, false if not. If the change
was not successful, {@link #getValue()} will return the updated value
@throws Exception ZK errors, interruptions, etc.
|
[
"Changes",
"the",
"shared",
"value",
"only",
"if",
"its",
"value",
"has",
"not",
"changed",
"since",
"the",
"version",
"specified",
"by",
"newValue",
".",
"If",
"the",
"value",
"has",
"changed",
"the",
"value",
"is",
"not",
"set",
"and",
"this",
"client",
"s",
"view",
"of",
"the",
"value",
"is",
"updated",
".",
"i",
".",
"e",
".",
"if",
"the",
"value",
"is",
"not",
"successful",
"you",
"can",
"get",
"the",
"updated",
"value",
"by",
"calling",
"{",
"@link",
"#getValue",
"()",
"}",
"."
] |
train
|
https://github.com/xiancloud/xian/blob/1948e088545553d2745b2c86d8b5a64988bb850e/xian-zookeeper/xian-curator/xian-curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedValue.java#L162-L185
|
elki-project/elki
|
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/heap/UpdatableHeap.java
|
UpdatableHeap.heapifyUp
|
@Override
protected void heapifyUp(int pos, Object cur) {
"""
Execute a "Heapify Upwards" aka "SiftUp". Used in insertions.
@param pos insertion position
@param cur Element to insert
"""
while(pos > 0) {
final int parent = (pos - 1) >>> 1;
Object par = queue[parent];
if(comparator.compare(cur, par) >= 0) {
break;
}
queue[pos] = par;
index.put(par, pos);
pos = parent;
}
queue[pos] = cur;
index.put(cur, pos);
}
|
java
|
@Override
protected void heapifyUp(int pos, Object cur) {
while(pos > 0) {
final int parent = (pos - 1) >>> 1;
Object par = queue[parent];
if(comparator.compare(cur, par) >= 0) {
break;
}
queue[pos] = par;
index.put(par, pos);
pos = parent;
}
queue[pos] = cur;
index.put(cur, pos);
}
|
[
"@",
"Override",
"protected",
"void",
"heapifyUp",
"(",
"int",
"pos",
",",
"Object",
"cur",
")",
"{",
"while",
"(",
"pos",
">",
"0",
")",
"{",
"final",
"int",
"parent",
"=",
"(",
"pos",
"-",
"1",
")",
">>>",
"1",
";",
"Object",
"par",
"=",
"queue",
"[",
"parent",
"]",
";",
"if",
"(",
"comparator",
".",
"compare",
"(",
"cur",
",",
"par",
")",
">=",
"0",
")",
"{",
"break",
";",
"}",
"queue",
"[",
"pos",
"]",
"=",
"par",
";",
"index",
".",
"put",
"(",
"par",
",",
"pos",
")",
";",
"pos",
"=",
"parent",
";",
"}",
"queue",
"[",
"pos",
"]",
"=",
"cur",
";",
"index",
".",
"put",
"(",
"cur",
",",
"pos",
")",
";",
"}"
] |
Execute a "Heapify Upwards" aka "SiftUp". Used in insertions.
@param pos insertion position
@param cur Element to insert
|
[
"Execute",
"a",
"Heapify",
"Upwards",
"aka",
"SiftUp",
".",
"Used",
"in",
"insertions",
"."
] |
train
|
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/heap/UpdatableHeap.java#L189-L204
|
OpenLiberty/open-liberty
|
dev/com.ibm.websphere.javaee.el.3.0/src/javax/el/ELContext.java
|
ELContext.convertToType
|
public Object convertToType(Object obj, Class<?> type) {
"""
Coerce the supplied object to the requested type.
@param obj The object to be coerced
@param type The type to which the object should be coerced
@return An instance of the requested type.
@throws ELException
If the conversion fails
@since EL 3.0
"""
boolean originalResolved = isPropertyResolved();
setPropertyResolved(false);
try {
ELResolver resolver = getELResolver();
if (resolver != null) {
Object result = resolver.convertToType(this, obj, type);
if (isPropertyResolved()) {
return result;
}
}
} finally {
setPropertyResolved(originalResolved);
}
return ELManager.getExpressionFactory().coerceToType(obj, type);
}
|
java
|
public Object convertToType(Object obj, Class<?> type) {
boolean originalResolved = isPropertyResolved();
setPropertyResolved(false);
try {
ELResolver resolver = getELResolver();
if (resolver != null) {
Object result = resolver.convertToType(this, obj, type);
if (isPropertyResolved()) {
return result;
}
}
} finally {
setPropertyResolved(originalResolved);
}
return ELManager.getExpressionFactory().coerceToType(obj, type);
}
|
[
"public",
"Object",
"convertToType",
"(",
"Object",
"obj",
",",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"boolean",
"originalResolved",
"=",
"isPropertyResolved",
"(",
")",
";",
"setPropertyResolved",
"(",
"false",
")",
";",
"try",
"{",
"ELResolver",
"resolver",
"=",
"getELResolver",
"(",
")",
";",
"if",
"(",
"resolver",
"!=",
"null",
")",
"{",
"Object",
"result",
"=",
"resolver",
".",
"convertToType",
"(",
"this",
",",
"obj",
",",
"type",
")",
";",
"if",
"(",
"isPropertyResolved",
"(",
")",
")",
"{",
"return",
"result",
";",
"}",
"}",
"}",
"finally",
"{",
"setPropertyResolved",
"(",
"originalResolved",
")",
";",
"}",
"return",
"ELManager",
".",
"getExpressionFactory",
"(",
")",
".",
"coerceToType",
"(",
"obj",
",",
"type",
")",
";",
"}"
] |
Coerce the supplied object to the requested type.
@param obj The object to be coerced
@param type The type to which the object should be coerced
@return An instance of the requested type.
@throws ELException
If the conversion fails
@since EL 3.0
|
[
"Coerce",
"the",
"supplied",
"object",
"to",
"the",
"requested",
"type",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.websphere.javaee.el.3.0/src/javax/el/ELContext.java#L290-L307
|
molgenis/molgenis
|
molgenis-data-i18n/src/main/java/org/molgenis/data/i18n/LocalizationService.java
|
LocalizationService.resolveCodeWithoutArguments
|
@Override
@RunAsSystem
public String resolveCodeWithoutArguments(String code, Locale locale) {
"""
Looks up a single localized message.
@param code messageID
@param locale the Locale for the language
@return String containing the message or null if not specified
"""
return Optional.ofNullable(
dataService.query(L10N_STRING, L10nString.class).eq(MSGID, code).findOne())
.map(l10nString -> l10nString.getString(locale))
.orElse(null);
}
|
java
|
@Override
@RunAsSystem
public String resolveCodeWithoutArguments(String code, Locale locale) {
return Optional.ofNullable(
dataService.query(L10N_STRING, L10nString.class).eq(MSGID, code).findOne())
.map(l10nString -> l10nString.getString(locale))
.orElse(null);
}
|
[
"@",
"Override",
"@",
"RunAsSystem",
"public",
"String",
"resolveCodeWithoutArguments",
"(",
"String",
"code",
",",
"Locale",
"locale",
")",
"{",
"return",
"Optional",
".",
"ofNullable",
"(",
"dataService",
".",
"query",
"(",
"L10N_STRING",
",",
"L10nString",
".",
"class",
")",
".",
"eq",
"(",
"MSGID",
",",
"code",
")",
".",
"findOne",
"(",
")",
")",
".",
"map",
"(",
"l10nString",
"->",
"l10nString",
".",
"getString",
"(",
"locale",
")",
")",
".",
"orElse",
"(",
"null",
")",
";",
"}"
] |
Looks up a single localized message.
@param code messageID
@param locale the Locale for the language
@return String containing the message or null if not specified
|
[
"Looks",
"up",
"a",
"single",
"localized",
"message",
"."
] |
train
|
https://github.com/molgenis/molgenis/blob/b4d0d6b27e6f6c8d7505a3863dc03b589601f987/molgenis-data-i18n/src/main/java/org/molgenis/data/i18n/LocalizationService.java#L51-L58
|
CenturyLinkCloud/mdw
|
mdw-hub/src/com/centurylink/mdw/hub/servlet/SoapServlet.java
|
SoapServlet.getSoapVersion
|
private String getSoapVersion(String requestString, boolean goodguess) {
"""
<p>
Gives a hint as to which version of SOAP using the rudimentary check
below. If the hint fails, it'll try the other version anyway.
</p>
<ul>
<li>SOAP 1.1 : http://schemas.xmlsoap.org/soap/envelope/</li>
<li>SOAP 1.2 : http://www.w3.org/2003/05/soap-envelope</li>
</ul>
<p>
This is on a per-request basis and can't be static since we need to
support SOAP 1.1 and 1.2
</p>
@param requestString
@param goodguess
@return SOAP version 1 or 2
@throws IOException
@throws SOAPException
"""
String guessedVersion = SOAPConstants.SOAP_1_1_PROTOCOL;
String otherVersion = SOAPConstants.SOAP_1_2_PROTOCOL;
if (requestString.contains(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE)) {
guessedVersion = SOAPConstants.SOAP_1_2_PROTOCOL;
otherVersion = SOAPConstants.SOAP_1_1_PROTOCOL;
}
return goodguess ? guessedVersion : otherVersion;
}
|
java
|
private String getSoapVersion(String requestString, boolean goodguess) {
String guessedVersion = SOAPConstants.SOAP_1_1_PROTOCOL;
String otherVersion = SOAPConstants.SOAP_1_2_PROTOCOL;
if (requestString.contains(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE)) {
guessedVersion = SOAPConstants.SOAP_1_2_PROTOCOL;
otherVersion = SOAPConstants.SOAP_1_1_PROTOCOL;
}
return goodguess ? guessedVersion : otherVersion;
}
|
[
"private",
"String",
"getSoapVersion",
"(",
"String",
"requestString",
",",
"boolean",
"goodguess",
")",
"{",
"String",
"guessedVersion",
"=",
"SOAPConstants",
".",
"SOAP_1_1_PROTOCOL",
";",
"String",
"otherVersion",
"=",
"SOAPConstants",
".",
"SOAP_1_2_PROTOCOL",
";",
"if",
"(",
"requestString",
".",
"contains",
"(",
"SOAPConstants",
".",
"URI_NS_SOAP_1_2_ENVELOPE",
")",
")",
"{",
"guessedVersion",
"=",
"SOAPConstants",
".",
"SOAP_1_2_PROTOCOL",
";",
"otherVersion",
"=",
"SOAPConstants",
".",
"SOAP_1_1_PROTOCOL",
";",
"}",
"return",
"goodguess",
"?",
"guessedVersion",
":",
"otherVersion",
";",
"}"
] |
<p>
Gives a hint as to which version of SOAP using the rudimentary check
below. If the hint fails, it'll try the other version anyway.
</p>
<ul>
<li>SOAP 1.1 : http://schemas.xmlsoap.org/soap/envelope/</li>
<li>SOAP 1.2 : http://www.w3.org/2003/05/soap-envelope</li>
</ul>
<p>
This is on a per-request basis and can't be static since we need to
support SOAP 1.1 and 1.2
</p>
@param requestString
@param goodguess
@return SOAP version 1 or 2
@throws IOException
@throws SOAPException
|
[
"<p",
">",
"Gives",
"a",
"hint",
"as",
"to",
"which",
"version",
"of",
"SOAP",
"using",
"the",
"rudimentary",
"check",
"below",
".",
"If",
"the",
"hint",
"fails",
"it",
"ll",
"try",
"the",
"other",
"version",
"anyway",
".",
"<",
"/",
"p",
">",
"<ul",
">",
"<li",
">",
"SOAP",
"1",
".",
"1",
":",
"http",
":",
"//",
"schemas",
".",
"xmlsoap",
".",
"org",
"/",
"soap",
"/",
"envelope",
"/",
"<",
"/",
"li",
">",
"<li",
">",
"SOAP",
"1",
".",
"2",
":",
"http",
":",
"//",
"www",
".",
"w3",
".",
"org",
"/",
"2003",
"/",
"05",
"/",
"soap",
"-",
"envelope<",
"/",
"li",
">",
"<",
"/",
"ul",
">",
"<p",
">",
"This",
"is",
"on",
"a",
"per",
"-",
"request",
"basis",
"and",
"can",
"t",
"be",
"static",
"since",
"we",
"need",
"to",
"support",
"SOAP",
"1",
".",
"1",
"and",
"1",
".",
"2",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-hub/src/com/centurylink/mdw/hub/servlet/SoapServlet.java#L308-L318
|
virgo47/javasimon
|
console-embed/src/main/java/org/javasimon/console/reflect/GetterFactory.java
|
GetterFactory.getSubType
|
private static String getSubType(Class type, String propertyName) {
"""
Get subtype for given Class and property.
@param type Parent class
@param propertyName Property name
@return Sub type name
"""
@SuppressWarnings("unchecked")
Class normalizedType = SimonTypeFactory.normalizeType(type);
if (normalizedType == null) {
return null;
} else {
return subTypeProperties.getProperty(normalizedType.getName() + "." + propertyName);
}
}
|
java
|
private static String getSubType(Class type, String propertyName) {
@SuppressWarnings("unchecked")
Class normalizedType = SimonTypeFactory.normalizeType(type);
if (normalizedType == null) {
return null;
} else {
return subTypeProperties.getProperty(normalizedType.getName() + "." + propertyName);
}
}
|
[
"private",
"static",
"String",
"getSubType",
"(",
"Class",
"type",
",",
"String",
"propertyName",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"Class",
"normalizedType",
"=",
"SimonTypeFactory",
".",
"normalizeType",
"(",
"type",
")",
";",
"if",
"(",
"normalizedType",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"subTypeProperties",
".",
"getProperty",
"(",
"normalizedType",
".",
"getName",
"(",
")",
"+",
"\".\"",
"+",
"propertyName",
")",
";",
"}",
"}"
] |
Get subtype for given Class and property.
@param type Parent class
@param propertyName Property name
@return Sub type name
|
[
"Get",
"subtype",
"for",
"given",
"Class",
"and",
"property",
"."
] |
train
|
https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/console-embed/src/main/java/org/javasimon/console/reflect/GetterFactory.java#L61-L69
|
pravega/pravega
|
common/src/main/java/io/pravega/common/concurrent/ExecutorServiceHelpers.java
|
ExecutorServiceHelpers.getShrinkingExecutor
|
public static ThreadPoolExecutor getShrinkingExecutor(int maxThreadCount, int threadTimeout, String poolName) {
"""
Operates like Executors.cachedThreadPool but with a custom thread timeout and pool name.
@return A new threadPool
@param maxThreadCount The maximum number of threads to allow in the pool.
@param threadTimeout the number of milliseconds that a thread should sit idle before shutting down.
@param poolName The name of the threadpool.
"""
return new ThreadPoolExecutor(0, maxThreadCount, threadTimeout, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(),
getThreadFactory(poolName), new CallerRuns()); // Caller runs only occurs after shutdown, as queue size is unbounded.
}
|
java
|
public static ThreadPoolExecutor getShrinkingExecutor(int maxThreadCount, int threadTimeout, String poolName) {
return new ThreadPoolExecutor(0, maxThreadCount, threadTimeout, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(),
getThreadFactory(poolName), new CallerRuns()); // Caller runs only occurs after shutdown, as queue size is unbounded.
}
|
[
"public",
"static",
"ThreadPoolExecutor",
"getShrinkingExecutor",
"(",
"int",
"maxThreadCount",
",",
"int",
"threadTimeout",
",",
"String",
"poolName",
")",
"{",
"return",
"new",
"ThreadPoolExecutor",
"(",
"0",
",",
"maxThreadCount",
",",
"threadTimeout",
",",
"TimeUnit",
".",
"MILLISECONDS",
",",
"new",
"LinkedBlockingQueue",
"<>",
"(",
")",
",",
"getThreadFactory",
"(",
"poolName",
")",
",",
"new",
"CallerRuns",
"(",
")",
")",
";",
"// Caller runs only occurs after shutdown, as queue size is unbounded.",
"}"
] |
Operates like Executors.cachedThreadPool but with a custom thread timeout and pool name.
@return A new threadPool
@param maxThreadCount The maximum number of threads to allow in the pool.
@param threadTimeout the number of milliseconds that a thread should sit idle before shutting down.
@param poolName The name of the threadpool.
|
[
"Operates",
"like",
"Executors",
".",
"cachedThreadPool",
"but",
"with",
"a",
"custom",
"thread",
"timeout",
"and",
"pool",
"name",
"."
] |
train
|
https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/common/src/main/java/io/pravega/common/concurrent/ExecutorServiceHelpers.java#L113-L116
|
bmwcarit/joynr
|
java/messaging/messaging-common/src/main/java/io/joynr/messaging/util/Utilities.java
|
Utilities.getSessionId
|
public static String getSessionId(String url, String sessionIdName) {
"""
Returns the session id from a URL. It is expected that the URL contains a
session, which can be checked by calling
{@link Utilities#isSessionEncodedInUrl(String, String)}
@param url
the url to get the session ID from
@param sessionIdName
the name of the session ID, e.g. jsessionid
@return
the session ID
"""
String sessionIdSubstring = getSessionIdSubstring(sessionIdName);
String sessionId = url.substring(url.indexOf(sessionIdSubstring) + sessionIdSubstring.length());
if (sessionId.endsWith("/")) {
sessionId = sessionId.substring(0, sessionId.length() - 1);
}
return sessionId;
}
|
java
|
public static String getSessionId(String url, String sessionIdName) {
String sessionIdSubstring = getSessionIdSubstring(sessionIdName);
String sessionId = url.substring(url.indexOf(sessionIdSubstring) + sessionIdSubstring.length());
if (sessionId.endsWith("/")) {
sessionId = sessionId.substring(0, sessionId.length() - 1);
}
return sessionId;
}
|
[
"public",
"static",
"String",
"getSessionId",
"(",
"String",
"url",
",",
"String",
"sessionIdName",
")",
"{",
"String",
"sessionIdSubstring",
"=",
"getSessionIdSubstring",
"(",
"sessionIdName",
")",
";",
"String",
"sessionId",
"=",
"url",
".",
"substring",
"(",
"url",
".",
"indexOf",
"(",
"sessionIdSubstring",
")",
"+",
"sessionIdSubstring",
".",
"length",
"(",
")",
")",
";",
"if",
"(",
"sessionId",
".",
"endsWith",
"(",
"\"/\"",
")",
")",
"{",
"sessionId",
"=",
"sessionId",
".",
"substring",
"(",
"0",
",",
"sessionId",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"}",
"return",
"sessionId",
";",
"}"
] |
Returns the session id from a URL. It is expected that the URL contains a
session, which can be checked by calling
{@link Utilities#isSessionEncodedInUrl(String, String)}
@param url
the url to get the session ID from
@param sessionIdName
the name of the session ID, e.g. jsessionid
@return
the session ID
|
[
"Returns",
"the",
"session",
"id",
"from",
"a",
"URL",
".",
"It",
"is",
"expected",
"that",
"the",
"URL",
"contains",
"a",
"session",
"which",
"can",
"be",
"checked",
"by",
"calling",
"{",
"@link",
"Utilities#isSessionEncodedInUrl",
"(",
"String",
"String",
")",
"}"
] |
train
|
https://github.com/bmwcarit/joynr/blob/b7a92bad1cf2f093de080facd2c803560f4c6c26/java/messaging/messaging-common/src/main/java/io/joynr/messaging/util/Utilities.java#L158-L167
|
google/j2objc
|
jre_emul/android/frameworks/base/core/java/android/text/SpannableStringBuilder.java
|
SpannableStringBuilder.setSpan
|
public void setSpan(Object what, int start, int end, int flags) {
"""
Mark the specified range of text with the specified object.
The flags determine how the span will behave when text is
inserted at the start or end of the span's range.
"""
setSpan(true, what, start, end, flags);
}
|
java
|
public void setSpan(Object what, int start, int end, int flags) {
setSpan(true, what, start, end, flags);
}
|
[
"public",
"void",
"setSpan",
"(",
"Object",
"what",
",",
"int",
"start",
",",
"int",
"end",
",",
"int",
"flags",
")",
"{",
"setSpan",
"(",
"true",
",",
"what",
",",
"start",
",",
"end",
",",
"flags",
")",
";",
"}"
] |
Mark the specified range of text with the specified object.
The flags determine how the span will behave when text is
inserted at the start or end of the span's range.
|
[
"Mark",
"the",
"specified",
"range",
"of",
"text",
"with",
"the",
"specified",
"object",
".",
"The",
"flags",
"determine",
"how",
"the",
"span",
"will",
"behave",
"when",
"text",
"is",
"inserted",
"at",
"the",
"start",
"or",
"end",
"of",
"the",
"span",
"s",
"range",
"."
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/frameworks/base/core/java/android/text/SpannableStringBuilder.java#L585-L587
|
aws/aws-sdk-java
|
aws-java-sdk-marketplaceentitlement/src/main/java/com/amazonaws/services/marketplaceentitlement/model/GetEntitlementsRequest.java
|
GetEntitlementsRequest.withFilter
|
public GetEntitlementsRequest withFilter(java.util.Map<String, java.util.List<String>> filter) {
"""
<p>
Filter is used to return entitlements for a specific customer or for a specific dimension. Filters are described
as keys mapped to a lists of values. Filtered requests are <i>unioned</i> for each value in the value list, and
then <i>intersected</i> for each filter key.
</p>
@param filter
Filter is used to return entitlements for a specific customer or for a specific dimension. Filters are
described as keys mapped to a lists of values. Filtered requests are <i>unioned</i> for each value in the
value list, and then <i>intersected</i> for each filter key.
@return Returns a reference to this object so that method calls can be chained together.
"""
setFilter(filter);
return this;
}
|
java
|
public GetEntitlementsRequest withFilter(java.util.Map<String, java.util.List<String>> filter) {
setFilter(filter);
return this;
}
|
[
"public",
"GetEntitlementsRequest",
"withFilter",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"java",
".",
"util",
".",
"List",
"<",
"String",
">",
">",
"filter",
")",
"{",
"setFilter",
"(",
"filter",
")",
";",
"return",
"this",
";",
"}"
] |
<p>
Filter is used to return entitlements for a specific customer or for a specific dimension. Filters are described
as keys mapped to a lists of values. Filtered requests are <i>unioned</i> for each value in the value list, and
then <i>intersected</i> for each filter key.
</p>
@param filter
Filter is used to return entitlements for a specific customer or for a specific dimension. Filters are
described as keys mapped to a lists of values. Filtered requests are <i>unioned</i> for each value in the
value list, and then <i>intersected</i> for each filter key.
@return Returns a reference to this object so that method calls can be chained together.
|
[
"<p",
">",
"Filter",
"is",
"used",
"to",
"return",
"entitlements",
"for",
"a",
"specific",
"customer",
"or",
"for",
"a",
"specific",
"dimension",
".",
"Filters",
"are",
"described",
"as",
"keys",
"mapped",
"to",
"a",
"lists",
"of",
"values",
".",
"Filtered",
"requests",
"are",
"<i",
">",
"unioned<",
"/",
"i",
">",
"for",
"each",
"value",
"in",
"the",
"value",
"list",
"and",
"then",
"<i",
">",
"intersected<",
"/",
"i",
">",
"for",
"each",
"filter",
"key",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-marketplaceentitlement/src/main/java/com/amazonaws/services/marketplaceentitlement/model/GetEntitlementsRequest.java#L153-L156
|
spotbugs/spotbugs
|
spotbugs/src/main/java/edu/umd/cs/findbugs/FindBugs.java
|
FindBugs.configureBaselineFilter
|
public static BugReporter configureBaselineFilter(BugReporter bugReporter, String baselineFileName) throws IOException,
DocumentException {
"""
Configure a baseline bug instance filter.
@param bugReporter
a DelegatingBugReporter
@param baselineFileName
filename of baseline Filter
@throws java.io.IOException
@throws org.dom4j.DocumentException
"""
return new ExcludingHashesBugReporter(bugReporter, baselineFileName);
}
|
java
|
public static BugReporter configureBaselineFilter(BugReporter bugReporter, String baselineFileName) throws IOException,
DocumentException {
return new ExcludingHashesBugReporter(bugReporter, baselineFileName);
}
|
[
"public",
"static",
"BugReporter",
"configureBaselineFilter",
"(",
"BugReporter",
"bugReporter",
",",
"String",
"baselineFileName",
")",
"throws",
"IOException",
",",
"DocumentException",
"{",
"return",
"new",
"ExcludingHashesBugReporter",
"(",
"bugReporter",
",",
"baselineFileName",
")",
";",
"}"
] |
Configure a baseline bug instance filter.
@param bugReporter
a DelegatingBugReporter
@param baselineFileName
filename of baseline Filter
@throws java.io.IOException
@throws org.dom4j.DocumentException
|
[
"Configure",
"a",
"baseline",
"bug",
"instance",
"filter",
"."
] |
train
|
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/FindBugs.java#L500-L503
|
jcuda/jcudnn
|
JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java
|
JCudnn.cudnnGetConvolutionBackwardFilterWorkspaceSize
|
public static int cudnnGetConvolutionBackwardFilterWorkspaceSize(
cudnnHandle handle,
cudnnTensorDescriptor xDesc,
cudnnTensorDescriptor dyDesc,
cudnnConvolutionDescriptor convDesc,
cudnnFilterDescriptor gradDesc,
int algo,
long[] sizeInBytes) {
"""
Helper function to return the minimum size of the workspace to be passed to the convolution given an algo
"""
return checkResult(cudnnGetConvolutionBackwardFilterWorkspaceSizeNative(handle, xDesc, dyDesc, convDesc, gradDesc, algo, sizeInBytes));
}
|
java
|
public static int cudnnGetConvolutionBackwardFilterWorkspaceSize(
cudnnHandle handle,
cudnnTensorDescriptor xDesc,
cudnnTensorDescriptor dyDesc,
cudnnConvolutionDescriptor convDesc,
cudnnFilterDescriptor gradDesc,
int algo,
long[] sizeInBytes)
{
return checkResult(cudnnGetConvolutionBackwardFilterWorkspaceSizeNative(handle, xDesc, dyDesc, convDesc, gradDesc, algo, sizeInBytes));
}
|
[
"public",
"static",
"int",
"cudnnGetConvolutionBackwardFilterWorkspaceSize",
"(",
"cudnnHandle",
"handle",
",",
"cudnnTensorDescriptor",
"xDesc",
",",
"cudnnTensorDescriptor",
"dyDesc",
",",
"cudnnConvolutionDescriptor",
"convDesc",
",",
"cudnnFilterDescriptor",
"gradDesc",
",",
"int",
"algo",
",",
"long",
"[",
"]",
"sizeInBytes",
")",
"{",
"return",
"checkResult",
"(",
"cudnnGetConvolutionBackwardFilterWorkspaceSizeNative",
"(",
"handle",
",",
"xDesc",
",",
"dyDesc",
",",
"convDesc",
",",
"gradDesc",
",",
"algo",
",",
"sizeInBytes",
")",
")",
";",
"}"
] |
Helper function to return the minimum size of the workspace to be passed to the convolution given an algo
|
[
"Helper",
"function",
"to",
"return",
"the",
"minimum",
"size",
"of",
"the",
"workspace",
"to",
"be",
"passed",
"to",
"the",
"convolution",
"given",
"an",
"algo"
] |
train
|
https://github.com/jcuda/jcudnn/blob/ce71f2fc02817cecace51a80e6db5f0c7f10cffc/JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java#L1372-L1382
|
Squarespace/cldr
|
runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java
|
CalendarFormatterBase.formatHours
|
void formatHours(StringBuilder b, ZonedDateTime d, int width, boolean twelveHour) {
"""
Format the hours in 12- or 24-hour format, optionally zero-padded.
"""
int hours = d.getHour();
if (twelveHour && hours > 12) {
hours = hours - 12;
}
if (twelveHour && hours == 0) {
hours = 12;
}
zeroPad2(b, hours, width);
}
|
java
|
void formatHours(StringBuilder b, ZonedDateTime d, int width, boolean twelveHour) {
int hours = d.getHour();
if (twelveHour && hours > 12) {
hours = hours - 12;
}
if (twelveHour && hours == 0) {
hours = 12;
}
zeroPad2(b, hours, width);
}
|
[
"void",
"formatHours",
"(",
"StringBuilder",
"b",
",",
"ZonedDateTime",
"d",
",",
"int",
"width",
",",
"boolean",
"twelveHour",
")",
"{",
"int",
"hours",
"=",
"d",
".",
"getHour",
"(",
")",
";",
"if",
"(",
"twelveHour",
"&&",
"hours",
">",
"12",
")",
"{",
"hours",
"=",
"hours",
"-",
"12",
";",
"}",
"if",
"(",
"twelveHour",
"&&",
"hours",
"==",
"0",
")",
"{",
"hours",
"=",
"12",
";",
"}",
"zeroPad2",
"(",
"b",
",",
"hours",
",",
"width",
")",
";",
"}"
] |
Format the hours in 12- or 24-hour format, optionally zero-padded.
|
[
"Format",
"the",
"hours",
"in",
"12",
"-",
"or",
"24",
"-",
"hour",
"format",
"optionally",
"zero",
"-",
"padded",
"."
] |
train
|
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java#L729-L738
|
albfernandez/itext2
|
src/main/java/com/lowagie/text/pdf/PdfContentByte.java
|
PdfContentByte.addImage
|
public void addImage(Image image, float a, float b, float c, float d, float e, float f) throws DocumentException {
"""
Adds an <CODE>Image</CODE> to the page. The positioning of the <CODE>Image</CODE>
is done with the transformation matrix. To position an <CODE>image</CODE> at (x,y)
use addImage(image, image_width, 0, 0, image_height, x, y).
@param image the <CODE>Image</CODE> object
@param a an element of the transformation matrix
@param b an element of the transformation matrix
@param c an element of the transformation matrix
@param d an element of the transformation matrix
@param e an element of the transformation matrix
@param f an element of the transformation matrix
@throws DocumentException on error
"""
addImage(image, a, b, c, d, e, f, false);
}
|
java
|
public void addImage(Image image, float a, float b, float c, float d, float e, float f) throws DocumentException {
addImage(image, a, b, c, d, e, f, false);
}
|
[
"public",
"void",
"addImage",
"(",
"Image",
"image",
",",
"float",
"a",
",",
"float",
"b",
",",
"float",
"c",
",",
"float",
"d",
",",
"float",
"e",
",",
"float",
"f",
")",
"throws",
"DocumentException",
"{",
"addImage",
"(",
"image",
",",
"a",
",",
"b",
",",
"c",
",",
"d",
",",
"e",
",",
"f",
",",
"false",
")",
";",
"}"
] |
Adds an <CODE>Image</CODE> to the page. The positioning of the <CODE>Image</CODE>
is done with the transformation matrix. To position an <CODE>image</CODE> at (x,y)
use addImage(image, image_width, 0, 0, image_height, x, y).
@param image the <CODE>Image</CODE> object
@param a an element of the transformation matrix
@param b an element of the transformation matrix
@param c an element of the transformation matrix
@param d an element of the transformation matrix
@param e an element of the transformation matrix
@param f an element of the transformation matrix
@throws DocumentException on error
|
[
"Adds",
"an",
"<CODE",
">",
"Image<",
"/",
"CODE",
">",
"to",
"the",
"page",
".",
"The",
"positioning",
"of",
"the",
"<CODE",
">",
"Image<",
"/",
"CODE",
">",
"is",
"done",
"with",
"the",
"transformation",
"matrix",
".",
"To",
"position",
"an",
"<CODE",
">",
"image<",
"/",
"CODE",
">",
"at",
"(",
"x",
"y",
")",
"use",
"addImage",
"(",
"image",
"image_width",
"0",
"0",
"image_height",
"x",
"y",
")",
"."
] |
train
|
https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/pdf/PdfContentByte.java#L1133-L1135
|
ops4j/org.ops4j.pax.logging
|
pax-logging-api/src/main/java/org/jboss/logging/Logger.java
|
Logger.warnf
|
public void warnf(Throwable t, String format, Object... params) {
"""
Issue a formatted log message with a level of WARN.
@param t the throwable
@param format the format string, as per {@link String#format(String, Object...)}
@param params the parameters
"""
doLogf(Level.WARN, FQCN, format, params, t);
}
|
java
|
public void warnf(Throwable t, String format, Object... params) {
doLogf(Level.WARN, FQCN, format, params, t);
}
|
[
"public",
"void",
"warnf",
"(",
"Throwable",
"t",
",",
"String",
"format",
",",
"Object",
"...",
"params",
")",
"{",
"doLogf",
"(",
"Level",
".",
"WARN",
",",
"FQCN",
",",
"format",
",",
"params",
",",
"t",
")",
";",
"}"
] |
Issue a formatted log message with a level of WARN.
@param t the throwable
@param format the format string, as per {@link String#format(String, Object...)}
@param params the parameters
|
[
"Issue",
"a",
"formatted",
"log",
"message",
"with",
"a",
"level",
"of",
"WARN",
"."
] |
train
|
https://github.com/ops4j/org.ops4j.pax.logging/blob/493de4e1db4fe9f981f3dd78b8e40e5bf2b2e59d/pax-logging-api/src/main/java/org/jboss/logging/Logger.java#L1445-L1447
|
aws/aws-sdk-java
|
aws-java-sdk-amplify/src/main/java/com/amazonaws/services/amplify/model/Branch.java
|
Branch.withTags
|
public Branch withTags(java.util.Map<String, String> tags) {
"""
<p>
Tag for branch for Amplify App.
</p>
@param tags
Tag for branch for Amplify App.
@return Returns a reference to this object so that method calls can be chained together.
"""
setTags(tags);
return this;
}
|
java
|
public Branch withTags(java.util.Map<String, String> tags) {
setTags(tags);
return this;
}
|
[
"public",
"Branch",
"withTags",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"tags",
")",
"{",
"setTags",
"(",
"tags",
")",
";",
"return",
"this",
";",
"}"
] |
<p>
Tag for branch for Amplify App.
</p>
@param tags
Tag for branch for Amplify App.
@return Returns a reference to this object so that method calls can be chained together.
|
[
"<p",
">",
"Tag",
"for",
"branch",
"for",
"Amplify",
"App",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-amplify/src/main/java/com/amazonaws/services/amplify/model/Branch.java#L307-L310
|
eclipse/hawkbit
|
hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIComponentProvider.java
|
SPUIComponentProvider.createNameValueLabel
|
public static Label createNameValueLabel(final String label, final String... values) {
"""
Method to CreateName value labels.
@param label
as string
@param values
as string
@return Label
"""
final String valueStr = StringUtils.arrayToDelimitedString(values, " ");
final Label nameValueLabel = new Label(getBoldHTMLText(label) + valueStr, ContentMode.HTML);
nameValueLabel.setSizeFull();
nameValueLabel.addStyleName(SPUIDefinitions.TEXT_STYLE);
nameValueLabel.addStyleName("label-style");
return nameValueLabel;
}
|
java
|
public static Label createNameValueLabel(final String label, final String... values) {
final String valueStr = StringUtils.arrayToDelimitedString(values, " ");
final Label nameValueLabel = new Label(getBoldHTMLText(label) + valueStr, ContentMode.HTML);
nameValueLabel.setSizeFull();
nameValueLabel.addStyleName(SPUIDefinitions.TEXT_STYLE);
nameValueLabel.addStyleName("label-style");
return nameValueLabel;
}
|
[
"public",
"static",
"Label",
"createNameValueLabel",
"(",
"final",
"String",
"label",
",",
"final",
"String",
"...",
"values",
")",
"{",
"final",
"String",
"valueStr",
"=",
"StringUtils",
".",
"arrayToDelimitedString",
"(",
"values",
",",
"\" \"",
")",
";",
"final",
"Label",
"nameValueLabel",
"=",
"new",
"Label",
"(",
"getBoldHTMLText",
"(",
"label",
")",
"+",
"valueStr",
",",
"ContentMode",
".",
"HTML",
")",
";",
"nameValueLabel",
".",
"setSizeFull",
"(",
")",
";",
"nameValueLabel",
".",
"addStyleName",
"(",
"SPUIDefinitions",
".",
"TEXT_STYLE",
")",
";",
"nameValueLabel",
".",
"addStyleName",
"(",
"\"label-style\"",
")",
";",
"return",
"nameValueLabel",
";",
"}"
] |
Method to CreateName value labels.
@param label
as string
@param values
as string
@return Label
|
[
"Method",
"to",
"CreateName",
"value",
"labels",
"."
] |
train
|
https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIComponentProvider.java#L200-L207
|
Azure/azure-sdk-for-java
|
keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java
|
KeyVaultClientBaseImpl.createKeyAsync
|
public Observable<KeyBundle> createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List<JsonWebKeyOperation> keyOps, KeyAttributes keyAttributes, Map<String, String> tags, JsonWebKeyCurveName curve) {
"""
Creates a new key, stores it, then returns key parameters and attributes to the client.
The create key operation can be used to create any key type in Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. It requires the keys/create permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param keyName The name for the new key. The system will generate the version name for the new key.
@param kty The type of key to create. For valid values, see JsonWebKeyType. Possible values include: 'EC', 'EC-HSM', 'RSA', 'RSA-HSM', 'oct'
@param keySize The key size in bits. For example: 2048, 3072, or 4096 for RSA.
@param keyOps the List<JsonWebKeyOperation> value
@param keyAttributes the KeyAttributes value
@param tags Application specific metadata in the form of key-value pairs.
@param curve Elliptic curve name. For valid values, see JsonWebKeyCurveName. Possible values include: 'P-256', 'P-384', 'P-521', 'P-256K'
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the KeyBundle object
"""
return createKeyWithServiceResponseAsync(vaultBaseUrl, keyName, kty, keySize, keyOps, keyAttributes, tags, curve).map(new Func1<ServiceResponse<KeyBundle>, KeyBundle>() {
@Override
public KeyBundle call(ServiceResponse<KeyBundle> response) {
return response.body();
}
});
}
|
java
|
public Observable<KeyBundle> createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List<JsonWebKeyOperation> keyOps, KeyAttributes keyAttributes, Map<String, String> tags, JsonWebKeyCurveName curve) {
return createKeyWithServiceResponseAsync(vaultBaseUrl, keyName, kty, keySize, keyOps, keyAttributes, tags, curve).map(new Func1<ServiceResponse<KeyBundle>, KeyBundle>() {
@Override
public KeyBundle call(ServiceResponse<KeyBundle> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"KeyBundle",
">",
"createKeyAsync",
"(",
"String",
"vaultBaseUrl",
",",
"String",
"keyName",
",",
"JsonWebKeyType",
"kty",
",",
"Integer",
"keySize",
",",
"List",
"<",
"JsonWebKeyOperation",
">",
"keyOps",
",",
"KeyAttributes",
"keyAttributes",
",",
"Map",
"<",
"String",
",",
"String",
">",
"tags",
",",
"JsonWebKeyCurveName",
"curve",
")",
"{",
"return",
"createKeyWithServiceResponseAsync",
"(",
"vaultBaseUrl",
",",
"keyName",
",",
"kty",
",",
"keySize",
",",
"keyOps",
",",
"keyAttributes",
",",
"tags",
",",
"curve",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"KeyBundle",
">",
",",
"KeyBundle",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"KeyBundle",
"call",
"(",
"ServiceResponse",
"<",
"KeyBundle",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Creates a new key, stores it, then returns key parameters and attributes to the client.
The create key operation can be used to create any key type in Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. It requires the keys/create permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param keyName The name for the new key. The system will generate the version name for the new key.
@param kty The type of key to create. For valid values, see JsonWebKeyType. Possible values include: 'EC', 'EC-HSM', 'RSA', 'RSA-HSM', 'oct'
@param keySize The key size in bits. For example: 2048, 3072, or 4096 for RSA.
@param keyOps the List<JsonWebKeyOperation> value
@param keyAttributes the KeyAttributes value
@param tags Application specific metadata in the form of key-value pairs.
@param curve Elliptic curve name. For valid values, see JsonWebKeyCurveName. Possible values include: 'P-256', 'P-384', 'P-521', 'P-256K'
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the KeyBundle object
|
[
"Creates",
"a",
"new",
"key",
"stores",
"it",
"then",
"returns",
"key",
"parameters",
"and",
"attributes",
"to",
"the",
"client",
".",
"The",
"create",
"key",
"operation",
"can",
"be",
"used",
"to",
"create",
"any",
"key",
"type",
"in",
"Azure",
"Key",
"Vault",
".",
"If",
"the",
"named",
"key",
"already",
"exists",
"Azure",
"Key",
"Vault",
"creates",
"a",
"new",
"version",
"of",
"the",
"key",
".",
"It",
"requires",
"the",
"keys",
"/",
"create",
"permission",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java#L795-L802
|
google/j2objc
|
jre_emul/android/platform/libcore/xml/src/main/java/org/xmlpull/v1/sax2/Driver.java
|
Driver.startElement
|
protected void startElement(String namespace, String localName, String qName) throws SAXException {
"""
Calls {@link ContentHandler#startElement(String, String, String, Attributes) startElement}
on the <code>ContentHandler</code> with <code>this</code> driver object as the
{@link Attributes} implementation. In default implementation
{@link Attributes} object is valid only during this method call and may not
be stored. Sub-classes can overwrite this method to cache attributes.
"""
contentHandler.startElement(namespace, localName, qName, this);
}
|
java
|
protected void startElement(String namespace, String localName, String qName) throws SAXException {
contentHandler.startElement(namespace, localName, qName, this);
}
|
[
"protected",
"void",
"startElement",
"(",
"String",
"namespace",
",",
"String",
"localName",
",",
"String",
"qName",
")",
"throws",
"SAXException",
"{",
"contentHandler",
".",
"startElement",
"(",
"namespace",
",",
"localName",
",",
"qName",
",",
"this",
")",
";",
"}"
] |
Calls {@link ContentHandler#startElement(String, String, String, Attributes) startElement}
on the <code>ContentHandler</code> with <code>this</code> driver object as the
{@link Attributes} implementation. In default implementation
{@link Attributes} object is valid only during this method call and may not
be stored. Sub-classes can overwrite this method to cache attributes.
|
[
"Calls",
"{"
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/xml/src/main/java/org/xmlpull/v1/sax2/Driver.java#L466-L468
|
camunda/camunda-bpm-platform
|
engine/src/main/java/org/camunda/bpm/engine/impl/javax/el/CompositeELResolver.java
|
CompositeELResolver.getValue
|
@Override
public Object getValue(ELContext context, Object base, Object property) {
"""
Attempts to resolve the given property object on the given base object by querying all
component resolvers. If this resolver handles the given (base, property) pair, the
propertyResolved property of the ELContext object must be set to true by the resolver, before
returning. If this property is not true after this method is called, the caller should ignore
the return value. First, propertyResolved is set to false on the provided ELContext. Next,
for each component resolver in this composite:
<ol>
<li>The getValue() method is called, passing in the provided context, base and property.</li>
<li>If the ELContext's propertyResolved flag is false then iteration continues.</li>
<li>Otherwise, iteration stops and no more component resolvers are considered. The value
returned by getValue() is returned by this method.</li>
</ol>
If none of the component resolvers were able to perform this operation, the value null is
returned and the propertyResolved flag remains set to false. Any exception thrown by
component resolvers during the iteration is propagated to the caller of this method.
@param context
The context of this evaluation.
@param base
The base object to return the most general property type for, or null to enumerate
the set of top-level variables that this resolver can evaluate.
@param property
The property or variable to return the acceptable type for.
@return If the propertyResolved property of ELContext was set to true, then the result of the
variable or property resolution; otherwise undefined.
@throws NullPointerException
if context is null
@throws PropertyNotFoundException
if base is not null and the specified property does not exist or is not readable.
@throws ELException
if an exception was thrown while performing the property or variable resolution.
The thrown exception must be included as the cause property of this exception, if
available.
"""
context.setPropertyResolved(false);
for (ELResolver resolver : resolvers) {
Object value = resolver.getValue(context, base, property);
if (context.isPropertyResolved()) {
return value;
}
}
return null;
}
|
java
|
@Override
public Object getValue(ELContext context, Object base, Object property) {
context.setPropertyResolved(false);
for (ELResolver resolver : resolvers) {
Object value = resolver.getValue(context, base, property);
if (context.isPropertyResolved()) {
return value;
}
}
return null;
}
|
[
"@",
"Override",
"public",
"Object",
"getValue",
"(",
"ELContext",
"context",
",",
"Object",
"base",
",",
"Object",
"property",
")",
"{",
"context",
".",
"setPropertyResolved",
"(",
"false",
")",
";",
"for",
"(",
"ELResolver",
"resolver",
":",
"resolvers",
")",
"{",
"Object",
"value",
"=",
"resolver",
".",
"getValue",
"(",
"context",
",",
"base",
",",
"property",
")",
";",
"if",
"(",
"context",
".",
"isPropertyResolved",
"(",
")",
")",
"{",
"return",
"value",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Attempts to resolve the given property object on the given base object by querying all
component resolvers. If this resolver handles the given (base, property) pair, the
propertyResolved property of the ELContext object must be set to true by the resolver, before
returning. If this property is not true after this method is called, the caller should ignore
the return value. First, propertyResolved is set to false on the provided ELContext. Next,
for each component resolver in this composite:
<ol>
<li>The getValue() method is called, passing in the provided context, base and property.</li>
<li>If the ELContext's propertyResolved flag is false then iteration continues.</li>
<li>Otherwise, iteration stops and no more component resolvers are considered. The value
returned by getValue() is returned by this method.</li>
</ol>
If none of the component resolvers were able to perform this operation, the value null is
returned and the propertyResolved flag remains set to false. Any exception thrown by
component resolvers during the iteration is propagated to the caller of this method.
@param context
The context of this evaluation.
@param base
The base object to return the most general property type for, or null to enumerate
the set of top-level variables that this resolver can evaluate.
@param property
The property or variable to return the acceptable type for.
@return If the propertyResolved property of ELContext was set to true, then the result of the
variable or property resolution; otherwise undefined.
@throws NullPointerException
if context is null
@throws PropertyNotFoundException
if base is not null and the specified property does not exist or is not readable.
@throws ELException
if an exception was thrown while performing the property or variable resolution.
The thrown exception must be included as the cause property of this exception, if
available.
|
[
"Attempts",
"to",
"resolve",
"the",
"given",
"property",
"object",
"on",
"the",
"given",
"base",
"object",
"by",
"querying",
"all",
"component",
"resolvers",
".",
"If",
"this",
"resolver",
"handles",
"the",
"given",
"(",
"base",
"property",
")",
"pair",
"the",
"propertyResolved",
"property",
"of",
"the",
"ELContext",
"object",
"must",
"be",
"set",
"to",
"true",
"by",
"the",
"resolver",
"before",
"returning",
".",
"If",
"this",
"property",
"is",
"not",
"true",
"after",
"this",
"method",
"is",
"called",
"the",
"caller",
"should",
"ignore",
"the",
"return",
"value",
".",
"First",
"propertyResolved",
"is",
"set",
"to",
"false",
"on",
"the",
"provided",
"ELContext",
".",
"Next",
"for",
"each",
"component",
"resolver",
"in",
"this",
"composite",
":",
"<ol",
">",
"<li",
">",
"The",
"getValue",
"()",
"method",
"is",
"called",
"passing",
"in",
"the",
"provided",
"context",
"base",
"and",
"property",
".",
"<",
"/",
"li",
">",
"<li",
">",
"If",
"the",
"ELContext",
"s",
"propertyResolved",
"flag",
"is",
"false",
"then",
"iteration",
"continues",
".",
"<",
"/",
"li",
">",
"<li",
">",
"Otherwise",
"iteration",
"stops",
"and",
"no",
"more",
"component",
"resolvers",
"are",
"considered",
".",
"The",
"value",
"returned",
"by",
"getValue",
"()",
"is",
"returned",
"by",
"this",
"method",
".",
"<",
"/",
"li",
">",
"<",
"/",
"ol",
">",
"If",
"none",
"of",
"the",
"component",
"resolvers",
"were",
"able",
"to",
"perform",
"this",
"operation",
"the",
"value",
"null",
"is",
"returned",
"and",
"the",
"propertyResolved",
"flag",
"remains",
"set",
"to",
"false",
".",
"Any",
"exception",
"thrown",
"by",
"component",
"resolvers",
"during",
"the",
"iteration",
"is",
"propagated",
"to",
"the",
"caller",
"of",
"this",
"method",
"."
] |
train
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/javax/el/CompositeELResolver.java#L227-L237
|
alkacon/opencms-core
|
src/org/opencms/search/fields/CmsLuceneFieldConfiguration.java
|
CmsLuceneFieldConfiguration.getAnalyzer
|
public Analyzer getAnalyzer(Analyzer analyzer) {
"""
Returns an analyzer that wraps the given base analyzer with the analyzers of this individual field configuration.<p>
@param analyzer the base analyzer to wrap
@return an analyzer that wraps the given base analyzer with the analyzers of this individual field configuration
"""
// parent folder and last modified lookup fields must use whitespace analyzer
WhitespaceAnalyzer ws = new WhitespaceAnalyzer();
Map<String, Analyzer> analyzers = new HashMap<String, Analyzer>();
// first make map the default hard coded fields
analyzers.put(CmsSearchField.FIELD_PARENT_FOLDERS, ws);
analyzers.put(CmsSearchField.FIELD_CATEGORY, ws);
analyzers.put(CmsSearchField.FIELD_DATE_LASTMODIFIED_LOOKUP, ws);
analyzers.put(CmsSearchField.FIELD_DATE_CREATED_LOOKUP, ws);
for (CmsLuceneField field : getLuceneFields()) {
Analyzer fieldAnalyzer = field.getAnalyzer();
if (fieldAnalyzer != null) {
// this field has an individual analyzer configured
analyzers.put(field.getName(), fieldAnalyzer);
}
}
// return the individual field configured analyzer
return new PerFieldAnalyzerWrapper(analyzer, analyzers);
}
|
java
|
public Analyzer getAnalyzer(Analyzer analyzer) {
// parent folder and last modified lookup fields must use whitespace analyzer
WhitespaceAnalyzer ws = new WhitespaceAnalyzer();
Map<String, Analyzer> analyzers = new HashMap<String, Analyzer>();
// first make map the default hard coded fields
analyzers.put(CmsSearchField.FIELD_PARENT_FOLDERS, ws);
analyzers.put(CmsSearchField.FIELD_CATEGORY, ws);
analyzers.put(CmsSearchField.FIELD_DATE_LASTMODIFIED_LOOKUP, ws);
analyzers.put(CmsSearchField.FIELD_DATE_CREATED_LOOKUP, ws);
for (CmsLuceneField field : getLuceneFields()) {
Analyzer fieldAnalyzer = field.getAnalyzer();
if (fieldAnalyzer != null) {
// this field has an individual analyzer configured
analyzers.put(field.getName(), fieldAnalyzer);
}
}
// return the individual field configured analyzer
return new PerFieldAnalyzerWrapper(analyzer, analyzers);
}
|
[
"public",
"Analyzer",
"getAnalyzer",
"(",
"Analyzer",
"analyzer",
")",
"{",
"// parent folder and last modified lookup fields must use whitespace analyzer",
"WhitespaceAnalyzer",
"ws",
"=",
"new",
"WhitespaceAnalyzer",
"(",
")",
";",
"Map",
"<",
"String",
",",
"Analyzer",
">",
"analyzers",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Analyzer",
">",
"(",
")",
";",
"// first make map the default hard coded fields",
"analyzers",
".",
"put",
"(",
"CmsSearchField",
".",
"FIELD_PARENT_FOLDERS",
",",
"ws",
")",
";",
"analyzers",
".",
"put",
"(",
"CmsSearchField",
".",
"FIELD_CATEGORY",
",",
"ws",
")",
";",
"analyzers",
".",
"put",
"(",
"CmsSearchField",
".",
"FIELD_DATE_LASTMODIFIED_LOOKUP",
",",
"ws",
")",
";",
"analyzers",
".",
"put",
"(",
"CmsSearchField",
".",
"FIELD_DATE_CREATED_LOOKUP",
",",
"ws",
")",
";",
"for",
"(",
"CmsLuceneField",
"field",
":",
"getLuceneFields",
"(",
")",
")",
"{",
"Analyzer",
"fieldAnalyzer",
"=",
"field",
".",
"getAnalyzer",
"(",
")",
";",
"if",
"(",
"fieldAnalyzer",
"!=",
"null",
")",
"{",
"// this field has an individual analyzer configured",
"analyzers",
".",
"put",
"(",
"field",
".",
"getName",
"(",
")",
",",
"fieldAnalyzer",
")",
";",
"}",
"}",
"// return the individual field configured analyzer",
"return",
"new",
"PerFieldAnalyzerWrapper",
"(",
"analyzer",
",",
"analyzers",
")",
";",
"}"
] |
Returns an analyzer that wraps the given base analyzer with the analyzers of this individual field configuration.<p>
@param analyzer the base analyzer to wrap
@return an analyzer that wraps the given base analyzer with the analyzers of this individual field configuration
|
[
"Returns",
"an",
"analyzer",
"that",
"wraps",
"the",
"given",
"base",
"analyzer",
"with",
"the",
"analyzers",
"of",
"this",
"individual",
"field",
"configuration",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/search/fields/CmsLuceneFieldConfiguration.java#L190-L210
|
Azure/azure-sdk-for-java
|
cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/PatternsImpl.java
|
PatternsImpl.deletePattern
|
public OperationStatus deletePattern(UUID appId, String versionId, UUID patternId) {
"""
Deletes the pattern with the specified ID.
@param appId The application ID.
@param versionId The version ID.
@param patternId The pattern ID.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the OperationStatus object if successful.
"""
return deletePatternWithServiceResponseAsync(appId, versionId, patternId).toBlocking().single().body();
}
|
java
|
public OperationStatus deletePattern(UUID appId, String versionId, UUID patternId) {
return deletePatternWithServiceResponseAsync(appId, versionId, patternId).toBlocking().single().body();
}
|
[
"public",
"OperationStatus",
"deletePattern",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"UUID",
"patternId",
")",
"{",
"return",
"deletePatternWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"patternId",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] |
Deletes the pattern with the specified ID.
@param appId The application ID.
@param versionId The version ID.
@param patternId The pattern ID.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the OperationStatus object if successful.
|
[
"Deletes",
"the",
"pattern",
"with",
"the",
"specified",
"ID",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/PatternsImpl.java#L759-L761
|
box/box-android-sdk
|
box-content-sdk/src/main/java/com/box/androidsdk/content/views/DefaultAvatarController.java
|
DefaultAvatarController.cleanOutOldAvatars
|
protected void cleanOutOldAvatars(File directory, int maxLifeInDays) {
"""
Delete all files for user that is older than maxLifeInDays
@param directory the directory where avatar files are being held.
@param maxLifeInDays the number of days avatar files are allowed to live for.
"""
if (directory != null){
if (mCleanedDirectories.contains(directory.getAbsolutePath())){
return;
}
long oldestTimeAllowed = System.currentTimeMillis() - maxLifeInDays * TimeUnit.DAYS.toMillis(maxLifeInDays);
File[] files = directory.listFiles();
if (files != null){
for (File file : files){
if (file.getName().startsWith(DEFAULT_AVATAR_FILE_PREFIX) && file.lastModified() < oldestTimeAllowed){
file.delete();
}
}
}
}
}
|
java
|
protected void cleanOutOldAvatars(File directory, int maxLifeInDays){
if (directory != null){
if (mCleanedDirectories.contains(directory.getAbsolutePath())){
return;
}
long oldestTimeAllowed = System.currentTimeMillis() - maxLifeInDays * TimeUnit.DAYS.toMillis(maxLifeInDays);
File[] files = directory.listFiles();
if (files != null){
for (File file : files){
if (file.getName().startsWith(DEFAULT_AVATAR_FILE_PREFIX) && file.lastModified() < oldestTimeAllowed){
file.delete();
}
}
}
}
}
|
[
"protected",
"void",
"cleanOutOldAvatars",
"(",
"File",
"directory",
",",
"int",
"maxLifeInDays",
")",
"{",
"if",
"(",
"directory",
"!=",
"null",
")",
"{",
"if",
"(",
"mCleanedDirectories",
".",
"contains",
"(",
"directory",
".",
"getAbsolutePath",
"(",
")",
")",
")",
"{",
"return",
";",
"}",
"long",
"oldestTimeAllowed",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"maxLifeInDays",
"*",
"TimeUnit",
".",
"DAYS",
".",
"toMillis",
"(",
"maxLifeInDays",
")",
";",
"File",
"[",
"]",
"files",
"=",
"directory",
".",
"listFiles",
"(",
")",
";",
"if",
"(",
"files",
"!=",
"null",
")",
"{",
"for",
"(",
"File",
"file",
":",
"files",
")",
"{",
"if",
"(",
"file",
".",
"getName",
"(",
")",
".",
"startsWith",
"(",
"DEFAULT_AVATAR_FILE_PREFIX",
")",
"&&",
"file",
".",
"lastModified",
"(",
")",
"<",
"oldestTimeAllowed",
")",
"{",
"file",
".",
"delete",
"(",
")",
";",
"}",
"}",
"}",
"}",
"}"
] |
Delete all files for user that is older than maxLifeInDays
@param directory the directory where avatar files are being held.
@param maxLifeInDays the number of days avatar files are allowed to live for.
|
[
"Delete",
"all",
"files",
"for",
"user",
"that",
"is",
"older",
"than",
"maxLifeInDays"
] |
train
|
https://github.com/box/box-android-sdk/blob/a621ad5ddebf23067fec27529130d72718fc0e88/box-content-sdk/src/main/java/com/box/androidsdk/content/views/DefaultAvatarController.java#L88-L103
|
jbundle/jbundle
|
base/base/src/main/java/org/jbundle/base/field/event/StickyValueHandler.java
|
StickyValueHandler.fieldChanged
|
public int fieldChanged(boolean bDisplayOption, int iMoveMode) {
"""
The Field has Changed.
@param bDisplayOption If true, display the change.
@param iMoveMode The type of move being done (init/read/screen).
@return The error code (or NORMAL_RETURN if okay).
"""
int iErrorCode = super.fieldChanged(bDisplayOption, iMoveMode);
if (iErrorCode != DBConstants.NORMAL_RETURN)
return iErrorCode;
if (iMoveMode == DBConstants.INIT_MOVE)
this.retrieveValue();
if (iMoveMode == DBConstants.SCREEN_MOVE)
this.saveValue();
return iErrorCode;
}
|
java
|
public int fieldChanged(boolean bDisplayOption, int iMoveMode)
{
int iErrorCode = super.fieldChanged(bDisplayOption, iMoveMode);
if (iErrorCode != DBConstants.NORMAL_RETURN)
return iErrorCode;
if (iMoveMode == DBConstants.INIT_MOVE)
this.retrieveValue();
if (iMoveMode == DBConstants.SCREEN_MOVE)
this.saveValue();
return iErrorCode;
}
|
[
"public",
"int",
"fieldChanged",
"(",
"boolean",
"bDisplayOption",
",",
"int",
"iMoveMode",
")",
"{",
"int",
"iErrorCode",
"=",
"super",
".",
"fieldChanged",
"(",
"bDisplayOption",
",",
"iMoveMode",
")",
";",
"if",
"(",
"iErrorCode",
"!=",
"DBConstants",
".",
"NORMAL_RETURN",
")",
"return",
"iErrorCode",
";",
"if",
"(",
"iMoveMode",
"==",
"DBConstants",
".",
"INIT_MOVE",
")",
"this",
".",
"retrieveValue",
"(",
")",
";",
"if",
"(",
"iMoveMode",
"==",
"DBConstants",
".",
"SCREEN_MOVE",
")",
"this",
".",
"saveValue",
"(",
")",
";",
"return",
"iErrorCode",
";",
"}"
] |
The Field has Changed.
@param bDisplayOption If true, display the change.
@param iMoveMode The type of move being done (init/read/screen).
@return The error code (or NORMAL_RETURN if okay).
|
[
"The",
"Field",
"has",
"Changed",
"."
] |
train
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/event/StickyValueHandler.java#L98-L108
|
upwork/java-upwork
|
src/com/Upwork/api/Routers/Reports/Finance/Billings.java
|
Billings.getByBuyersTeam
|
public JSONObject getByBuyersTeam(String buyerTeamReference, HashMap<String, String> params) throws JSONException {
"""
Generate Billing Reports for a Specific Buyer's Team
@param buyerTeamReference Buyer team reference
@param params Parameters
@throws JSONException If error occurred
@return {@link JSONObject}
"""
return oClient.get("/finreports/v2/buyer_teams/" + buyerTeamReference + "/billings", params);
}
|
java
|
public JSONObject getByBuyersTeam(String buyerTeamReference, HashMap<String, String> params) throws JSONException {
return oClient.get("/finreports/v2/buyer_teams/" + buyerTeamReference + "/billings", params);
}
|
[
"public",
"JSONObject",
"getByBuyersTeam",
"(",
"String",
"buyerTeamReference",
",",
"HashMap",
"<",
"String",
",",
"String",
">",
"params",
")",
"throws",
"JSONException",
"{",
"return",
"oClient",
".",
"get",
"(",
"\"/finreports/v2/buyer_teams/\"",
"+",
"buyerTeamReference",
"+",
"\"/billings\"",
",",
"params",
")",
";",
"}"
] |
Generate Billing Reports for a Specific Buyer's Team
@param buyerTeamReference Buyer team reference
@param params Parameters
@throws JSONException If error occurred
@return {@link JSONObject}
|
[
"Generate",
"Billing",
"Reports",
"for",
"a",
"Specific",
"Buyer",
"s",
"Team"
] |
train
|
https://github.com/upwork/java-upwork/blob/342297161503a74e9e0bddbd381ab5eebf4dc454/src/com/Upwork/api/Routers/Reports/Finance/Billings.java#L90-L92
|
elki-project/elki
|
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/spatial/SpatialUtil.java
|
SpatialUtil.assertSameDimensionality
|
public static int assertSameDimensionality(SpatialComparable box1, SpatialComparable box2) {
"""
Check that two spatial objects have the same dimensionality.
@param box1 First object
@param box2 Second object
@return Dimensionality
@throws IllegalArgumentException when the dimensionalities do not agree
"""
final int dim = box1.getDimensionality();
if(dim != box2.getDimensionality()) {
throw new IllegalArgumentException("The spatial objects do not have the same dimensionality!");
}
return dim;
}
|
java
|
public static int assertSameDimensionality(SpatialComparable box1, SpatialComparable box2) {
final int dim = box1.getDimensionality();
if(dim != box2.getDimensionality()) {
throw new IllegalArgumentException("The spatial objects do not have the same dimensionality!");
}
return dim;
}
|
[
"public",
"static",
"int",
"assertSameDimensionality",
"(",
"SpatialComparable",
"box1",
",",
"SpatialComparable",
"box2",
")",
"{",
"final",
"int",
"dim",
"=",
"box1",
".",
"getDimensionality",
"(",
")",
";",
"if",
"(",
"dim",
"!=",
"box2",
".",
"getDimensionality",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The spatial objects do not have the same dimensionality!\"",
")",
";",
"}",
"return",
"dim",
";",
"}"
] |
Check that two spatial objects have the same dimensionality.
@param box1 First object
@param box2 Second object
@return Dimensionality
@throws IllegalArgumentException when the dimensionalities do not agree
|
[
"Check",
"that",
"two",
"spatial",
"objects",
"have",
"the",
"same",
"dimensionality",
"."
] |
train
|
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/spatial/SpatialUtil.java#L55-L61
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheOnDisk.java
|
CacheOnDisk.writeTemplateEntry
|
public int writeTemplateEntry(String template, Object entry) {
"""
Call this method to add a cache id for a specified template to the disk.
@param template
- template id.
@param entry
- cache id.
"""
int returnCode = htod.writeTemplateEntry(template, entry);
if (returnCode == HTODDynacache.DISK_EXCEPTION) {
stopOnError(this.htod.diskCacheException);
}
return returnCode;
}
|
java
|
public int writeTemplateEntry(String template, Object entry) {
int returnCode = htod.writeTemplateEntry(template, entry);
if (returnCode == HTODDynacache.DISK_EXCEPTION) {
stopOnError(this.htod.diskCacheException);
}
return returnCode;
}
|
[
"public",
"int",
"writeTemplateEntry",
"(",
"String",
"template",
",",
"Object",
"entry",
")",
"{",
"int",
"returnCode",
"=",
"htod",
".",
"writeTemplateEntry",
"(",
"template",
",",
"entry",
")",
";",
"if",
"(",
"returnCode",
"==",
"HTODDynacache",
".",
"DISK_EXCEPTION",
")",
"{",
"stopOnError",
"(",
"this",
".",
"htod",
".",
"diskCacheException",
")",
";",
"}",
"return",
"returnCode",
";",
"}"
] |
Call this method to add a cache id for a specified template to the disk.
@param template
- template id.
@param entry
- cache id.
|
[
"Call",
"this",
"method",
"to",
"add",
"a",
"cache",
"id",
"for",
"a",
"specified",
"template",
"to",
"the",
"disk",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheOnDisk.java#L1612-L1618
|
nguillaumin/slick2d-maven
|
slick2d-core/src/main/java/org/newdawn/slick/util/BufferedImageUtil.java
|
BufferedImageUtil.getTexture
|
public static Texture getTexture(String resourceName,
BufferedImage resourceimage, int target, int dstPixelFormat,
int minFilter, int magFilter) throws IOException {
"""
Load a texture into OpenGL from a BufferedImage
@param resourceName
The location of the resource to load
@param resourceimage
The BufferedImage we are converting
@param target
The GL target to load the texture against
@param dstPixelFormat
The pixel format of the screen
@param minFilter
The minimising filter
@param magFilter
The magnification filter
@return The loaded texture
@throws IOException
Indicates a failure to access the resource
"""
ImageIOImageData data = new ImageIOImageData();int srcPixelFormat = 0;
// create the texture ID for this texture
int textureID = InternalTextureLoader.createTextureID();
TextureImpl texture = new TextureImpl(resourceName, target, textureID);
// Enable texturing
Renderer.get().glEnable(SGL.GL_TEXTURE_2D);
// bind this texture
Renderer.get().glBindTexture(target, textureID);
BufferedImage bufferedImage = resourceimage;
texture.setWidth(bufferedImage.getWidth());
texture.setHeight(bufferedImage.getHeight());
if (bufferedImage.getColorModel().hasAlpha()) {
srcPixelFormat = SGL.GL_RGBA;
} else {
srcPixelFormat = SGL.GL_RGB;
}
// convert that image into a byte buffer of texture data
ByteBuffer textureBuffer = data.imageToByteBuffer(bufferedImage, false, false, null);
texture.setTextureHeight(data.getTexHeight());
texture.setTextureWidth(data.getTexWidth());
texture.setAlpha(data.getDepth() == 32);
if (target == SGL.GL_TEXTURE_2D) {
Renderer.get().glTexParameteri(target, SGL.GL_TEXTURE_MIN_FILTER, minFilter);
Renderer.get().glTexParameteri(target, SGL.GL_TEXTURE_MAG_FILTER, magFilter);
if (Renderer.get().canTextureMirrorClamp()) {
Renderer.get().glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_S, SGL.GL_MIRROR_CLAMP_TO_EDGE_EXT);
Renderer.get().glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_T, SGL.GL_MIRROR_CLAMP_TO_EDGE_EXT);
} else {
Renderer.get().glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_S, SGL.GL_CLAMP);
Renderer.get().glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_T, SGL.GL_CLAMP);
}
}
Renderer.get().glTexImage2D(target,
0,
dstPixelFormat,
texture.getTextureWidth(),
texture.getTextureHeight(),
0,
srcPixelFormat,
SGL.GL_UNSIGNED_BYTE,
textureBuffer);
return texture;
}
|
java
|
public static Texture getTexture(String resourceName,
BufferedImage resourceimage, int target, int dstPixelFormat,
int minFilter, int magFilter) throws IOException {
ImageIOImageData data = new ImageIOImageData();int srcPixelFormat = 0;
// create the texture ID for this texture
int textureID = InternalTextureLoader.createTextureID();
TextureImpl texture = new TextureImpl(resourceName, target, textureID);
// Enable texturing
Renderer.get().glEnable(SGL.GL_TEXTURE_2D);
// bind this texture
Renderer.get().glBindTexture(target, textureID);
BufferedImage bufferedImage = resourceimage;
texture.setWidth(bufferedImage.getWidth());
texture.setHeight(bufferedImage.getHeight());
if (bufferedImage.getColorModel().hasAlpha()) {
srcPixelFormat = SGL.GL_RGBA;
} else {
srcPixelFormat = SGL.GL_RGB;
}
// convert that image into a byte buffer of texture data
ByteBuffer textureBuffer = data.imageToByteBuffer(bufferedImage, false, false, null);
texture.setTextureHeight(data.getTexHeight());
texture.setTextureWidth(data.getTexWidth());
texture.setAlpha(data.getDepth() == 32);
if (target == SGL.GL_TEXTURE_2D) {
Renderer.get().glTexParameteri(target, SGL.GL_TEXTURE_MIN_FILTER, minFilter);
Renderer.get().glTexParameteri(target, SGL.GL_TEXTURE_MAG_FILTER, magFilter);
if (Renderer.get().canTextureMirrorClamp()) {
Renderer.get().glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_S, SGL.GL_MIRROR_CLAMP_TO_EDGE_EXT);
Renderer.get().glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_T, SGL.GL_MIRROR_CLAMP_TO_EDGE_EXT);
} else {
Renderer.get().glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_S, SGL.GL_CLAMP);
Renderer.get().glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_T, SGL.GL_CLAMP);
}
}
Renderer.get().glTexImage2D(target,
0,
dstPixelFormat,
texture.getTextureWidth(),
texture.getTextureHeight(),
0,
srcPixelFormat,
SGL.GL_UNSIGNED_BYTE,
textureBuffer);
return texture;
}
|
[
"public",
"static",
"Texture",
"getTexture",
"(",
"String",
"resourceName",
",",
"BufferedImage",
"resourceimage",
",",
"int",
"target",
",",
"int",
"dstPixelFormat",
",",
"int",
"minFilter",
",",
"int",
"magFilter",
")",
"throws",
"IOException",
"{",
"ImageIOImageData",
"data",
"=",
"new",
"ImageIOImageData",
"(",
")",
";",
"int",
"srcPixelFormat",
"=",
"0",
";",
"// create the texture ID for this texture\r",
"int",
"textureID",
"=",
"InternalTextureLoader",
".",
"createTextureID",
"(",
")",
";",
"TextureImpl",
"texture",
"=",
"new",
"TextureImpl",
"(",
"resourceName",
",",
"target",
",",
"textureID",
")",
";",
"// Enable texturing\r",
"Renderer",
".",
"get",
"(",
")",
".",
"glEnable",
"(",
"SGL",
".",
"GL_TEXTURE_2D",
")",
";",
"// bind this texture\r",
"Renderer",
".",
"get",
"(",
")",
".",
"glBindTexture",
"(",
"target",
",",
"textureID",
")",
";",
"BufferedImage",
"bufferedImage",
"=",
"resourceimage",
";",
"texture",
".",
"setWidth",
"(",
"bufferedImage",
".",
"getWidth",
"(",
")",
")",
";",
"texture",
".",
"setHeight",
"(",
"bufferedImage",
".",
"getHeight",
"(",
")",
")",
";",
"if",
"(",
"bufferedImage",
".",
"getColorModel",
"(",
")",
".",
"hasAlpha",
"(",
")",
")",
"{",
"srcPixelFormat",
"=",
"SGL",
".",
"GL_RGBA",
";",
"}",
"else",
"{",
"srcPixelFormat",
"=",
"SGL",
".",
"GL_RGB",
";",
"}",
"// convert that image into a byte buffer of texture data\r",
"ByteBuffer",
"textureBuffer",
"=",
"data",
".",
"imageToByteBuffer",
"(",
"bufferedImage",
",",
"false",
",",
"false",
",",
"null",
")",
";",
"texture",
".",
"setTextureHeight",
"(",
"data",
".",
"getTexHeight",
"(",
")",
")",
";",
"texture",
".",
"setTextureWidth",
"(",
"data",
".",
"getTexWidth",
"(",
")",
")",
";",
"texture",
".",
"setAlpha",
"(",
"data",
".",
"getDepth",
"(",
")",
"==",
"32",
")",
";",
"if",
"(",
"target",
"==",
"SGL",
".",
"GL_TEXTURE_2D",
")",
"{",
"Renderer",
".",
"get",
"(",
")",
".",
"glTexParameteri",
"(",
"target",
",",
"SGL",
".",
"GL_TEXTURE_MIN_FILTER",
",",
"minFilter",
")",
";",
"Renderer",
".",
"get",
"(",
")",
".",
"glTexParameteri",
"(",
"target",
",",
"SGL",
".",
"GL_TEXTURE_MAG_FILTER",
",",
"magFilter",
")",
";",
"if",
"(",
"Renderer",
".",
"get",
"(",
")",
".",
"canTextureMirrorClamp",
"(",
")",
")",
"{",
"Renderer",
".",
"get",
"(",
")",
".",
"glTexParameteri",
"(",
"SGL",
".",
"GL_TEXTURE_2D",
",",
"SGL",
".",
"GL_TEXTURE_WRAP_S",
",",
"SGL",
".",
"GL_MIRROR_CLAMP_TO_EDGE_EXT",
")",
";",
"Renderer",
".",
"get",
"(",
")",
".",
"glTexParameteri",
"(",
"SGL",
".",
"GL_TEXTURE_2D",
",",
"SGL",
".",
"GL_TEXTURE_WRAP_T",
",",
"SGL",
".",
"GL_MIRROR_CLAMP_TO_EDGE_EXT",
")",
";",
"}",
"else",
"{",
"Renderer",
".",
"get",
"(",
")",
".",
"glTexParameteri",
"(",
"SGL",
".",
"GL_TEXTURE_2D",
",",
"SGL",
".",
"GL_TEXTURE_WRAP_S",
",",
"SGL",
".",
"GL_CLAMP",
")",
";",
"Renderer",
".",
"get",
"(",
")",
".",
"glTexParameteri",
"(",
"SGL",
".",
"GL_TEXTURE_2D",
",",
"SGL",
".",
"GL_TEXTURE_WRAP_T",
",",
"SGL",
".",
"GL_CLAMP",
")",
";",
"}",
"}",
"Renderer",
".",
"get",
"(",
")",
".",
"glTexImage2D",
"(",
"target",
",",
"0",
",",
"dstPixelFormat",
",",
"texture",
".",
"getTextureWidth",
"(",
")",
",",
"texture",
".",
"getTextureHeight",
"(",
")",
",",
"0",
",",
"srcPixelFormat",
",",
"SGL",
".",
"GL_UNSIGNED_BYTE",
",",
"textureBuffer",
")",
";",
"return",
"texture",
";",
"}"
] |
Load a texture into OpenGL from a BufferedImage
@param resourceName
The location of the resource to load
@param resourceimage
The BufferedImage we are converting
@param target
The GL target to load the texture against
@param dstPixelFormat
The pixel format of the screen
@param minFilter
The minimising filter
@param magFilter
The magnification filter
@return The loaded texture
@throws IOException
Indicates a failure to access the resource
|
[
"Load",
"a",
"texture",
"into",
"OpenGL",
"from",
"a",
"BufferedImage"
] |
train
|
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/util/BufferedImageUtil.java#L89-L144
|
google/closure-compiler
|
src/com/google/javascript/jscomp/TypeInference.java
|
TypeInference.traverseCatch
|
@CheckReturnValue
private FlowScope traverseCatch(Node catchNode, FlowScope scope) {
"""
Any value can be thrown, so it's really impossible to determine the type of a CATCH param.
Treat it as the UNKNOWN type.
"""
Node catchTarget = catchNode.getFirstChild();
if (catchTarget.isName()) {
// TODO(lharker): is this case even necessary? seems like TypedScopeCreator handles it
Node name = catchNode.getFirstChild();
JSType type;
// If the catch expression name was declared in the catch use that type,
// otherwise use "unknown".
JSDocInfo info = name.getJSDocInfo();
if (info != null && info.hasType()) {
type = info.getType().evaluate(scope.getDeclarationScope(), registry);
} else {
type = getNativeType(JSTypeNative.UNKNOWN_TYPE);
}
name.setJSType(type);
return redeclareSimpleVar(scope, name, type);
} else if (catchTarget.isDestructuringPattern()) {
Node pattern = catchNode.getFirstChild();
return traverseDestructuringPattern(pattern, scope, unknownType, AssignmentType.DECLARATION);
} else {
checkState(catchTarget.isEmpty(), catchTarget);
// ES2019 allows `try {} catch {}` with no catch expression
return scope;
}
}
|
java
|
@CheckReturnValue
private FlowScope traverseCatch(Node catchNode, FlowScope scope) {
Node catchTarget = catchNode.getFirstChild();
if (catchTarget.isName()) {
// TODO(lharker): is this case even necessary? seems like TypedScopeCreator handles it
Node name = catchNode.getFirstChild();
JSType type;
// If the catch expression name was declared in the catch use that type,
// otherwise use "unknown".
JSDocInfo info = name.getJSDocInfo();
if (info != null && info.hasType()) {
type = info.getType().evaluate(scope.getDeclarationScope(), registry);
} else {
type = getNativeType(JSTypeNative.UNKNOWN_TYPE);
}
name.setJSType(type);
return redeclareSimpleVar(scope, name, type);
} else if (catchTarget.isDestructuringPattern()) {
Node pattern = catchNode.getFirstChild();
return traverseDestructuringPattern(pattern, scope, unknownType, AssignmentType.DECLARATION);
} else {
checkState(catchTarget.isEmpty(), catchTarget);
// ES2019 allows `try {} catch {}` with no catch expression
return scope;
}
}
|
[
"@",
"CheckReturnValue",
"private",
"FlowScope",
"traverseCatch",
"(",
"Node",
"catchNode",
",",
"FlowScope",
"scope",
")",
"{",
"Node",
"catchTarget",
"=",
"catchNode",
".",
"getFirstChild",
"(",
")",
";",
"if",
"(",
"catchTarget",
".",
"isName",
"(",
")",
")",
"{",
"// TODO(lharker): is this case even necessary? seems like TypedScopeCreator handles it",
"Node",
"name",
"=",
"catchNode",
".",
"getFirstChild",
"(",
")",
";",
"JSType",
"type",
";",
"// If the catch expression name was declared in the catch use that type,",
"// otherwise use \"unknown\".",
"JSDocInfo",
"info",
"=",
"name",
".",
"getJSDocInfo",
"(",
")",
";",
"if",
"(",
"info",
"!=",
"null",
"&&",
"info",
".",
"hasType",
"(",
")",
")",
"{",
"type",
"=",
"info",
".",
"getType",
"(",
")",
".",
"evaluate",
"(",
"scope",
".",
"getDeclarationScope",
"(",
")",
",",
"registry",
")",
";",
"}",
"else",
"{",
"type",
"=",
"getNativeType",
"(",
"JSTypeNative",
".",
"UNKNOWN_TYPE",
")",
";",
"}",
"name",
".",
"setJSType",
"(",
"type",
")",
";",
"return",
"redeclareSimpleVar",
"(",
"scope",
",",
"name",
",",
"type",
")",
";",
"}",
"else",
"if",
"(",
"catchTarget",
".",
"isDestructuringPattern",
"(",
")",
")",
"{",
"Node",
"pattern",
"=",
"catchNode",
".",
"getFirstChild",
"(",
")",
";",
"return",
"traverseDestructuringPattern",
"(",
"pattern",
",",
"scope",
",",
"unknownType",
",",
"AssignmentType",
".",
"DECLARATION",
")",
";",
"}",
"else",
"{",
"checkState",
"(",
"catchTarget",
".",
"isEmpty",
"(",
")",
",",
"catchTarget",
")",
";",
"// ES2019 allows `try {} catch {}` with no catch expression",
"return",
"scope",
";",
"}",
"}"
] |
Any value can be thrown, so it's really impossible to determine the type of a CATCH param.
Treat it as the UNKNOWN type.
|
[
"Any",
"value",
"can",
"be",
"thrown",
"so",
"it",
"s",
"really",
"impossible",
"to",
"determine",
"the",
"type",
"of",
"a",
"CATCH",
"param",
".",
"Treat",
"it",
"as",
"the",
"UNKNOWN",
"type",
"."
] |
train
|
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/TypeInference.java#L852-L877
|
igniterealtime/Smack
|
smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLight.java
|
MultiUserChatLight.changeRoomName
|
public void changeRoomName(String roomName)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
"""
Change the name of the room.
@param roomName
@throws NoResponseException
@throws XMPPErrorException
@throws NotConnectedException
@throws InterruptedException
"""
MUCLightSetConfigsIQ mucLightSetConfigIQ = new MUCLightSetConfigsIQ(room, roomName, null);
connection.createStanzaCollectorAndSend(mucLightSetConfigIQ).nextResultOrThrow();
}
|
java
|
public void changeRoomName(String roomName)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
MUCLightSetConfigsIQ mucLightSetConfigIQ = new MUCLightSetConfigsIQ(room, roomName, null);
connection.createStanzaCollectorAndSend(mucLightSetConfigIQ).nextResultOrThrow();
}
|
[
"public",
"void",
"changeRoomName",
"(",
"String",
"roomName",
")",
"throws",
"NoResponseException",
",",
"XMPPErrorException",
",",
"NotConnectedException",
",",
"InterruptedException",
"{",
"MUCLightSetConfigsIQ",
"mucLightSetConfigIQ",
"=",
"new",
"MUCLightSetConfigsIQ",
"(",
"room",
",",
"roomName",
",",
"null",
")",
";",
"connection",
".",
"createStanzaCollectorAndSend",
"(",
"mucLightSetConfigIQ",
")",
".",
"nextResultOrThrow",
"(",
")",
";",
"}"
] |
Change the name of the room.
@param roomName
@throws NoResponseException
@throws XMPPErrorException
@throws NotConnectedException
@throws InterruptedException
|
[
"Change",
"the",
"name",
"of",
"the",
"room",
"."
] |
train
|
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLight.java#L469-L473
|
alkacon/opencms-core
|
src/org/opencms/util/CmsFileUtil.java
|
CmsFileUtil.getRepositoryName
|
public static String getRepositoryName(String repository, String vfspath, boolean online) {
"""
Returns the file name for a given VFS name that has to be written to a repository in the "real" file system,
by appending the VFS root path to the given base repository path, also adding an
folder for the "online" or "offline" project.<p>
@param repository the base repository path
@param vfspath the VFS root path to write to use
@param online flag indicates if the result should be used for the online project (<code>true</code>) or not
@return The full uri to the JSP
"""
StringBuffer result = new StringBuffer(64);
result.append(repository);
result.append(online ? CmsFlexCache.REPOSITORY_ONLINE : CmsFlexCache.REPOSITORY_OFFLINE);
result.append(vfspath);
return result.toString();
}
|
java
|
public static String getRepositoryName(String repository, String vfspath, boolean online) {
StringBuffer result = new StringBuffer(64);
result.append(repository);
result.append(online ? CmsFlexCache.REPOSITORY_ONLINE : CmsFlexCache.REPOSITORY_OFFLINE);
result.append(vfspath);
return result.toString();
}
|
[
"public",
"static",
"String",
"getRepositoryName",
"(",
"String",
"repository",
",",
"String",
"vfspath",
",",
"boolean",
"online",
")",
"{",
"StringBuffer",
"result",
"=",
"new",
"StringBuffer",
"(",
"64",
")",
";",
"result",
".",
"append",
"(",
"repository",
")",
";",
"result",
".",
"append",
"(",
"online",
"?",
"CmsFlexCache",
".",
"REPOSITORY_ONLINE",
":",
"CmsFlexCache",
".",
"REPOSITORY_OFFLINE",
")",
";",
"result",
".",
"append",
"(",
"vfspath",
")",
";",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}"
] |
Returns the file name for a given VFS name that has to be written to a repository in the "real" file system,
by appending the VFS root path to the given base repository path, also adding an
folder for the "online" or "offline" project.<p>
@param repository the base repository path
@param vfspath the VFS root path to write to use
@param online flag indicates if the result should be used for the online project (<code>true</code>) or not
@return The full uri to the JSP
|
[
"Returns",
"the",
"file",
"name",
"for",
"a",
"given",
"VFS",
"name",
"that",
"has",
"to",
"be",
"written",
"to",
"a",
"repository",
"in",
"the",
"real",
"file",
"system",
"by",
"appending",
"the",
"VFS",
"root",
"path",
"to",
"the",
"given",
"base",
"repository",
"path",
"also",
"adding",
"an",
"folder",
"for",
"the",
"online",
"or",
"offline",
"project",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/util/CmsFileUtil.java#L419-L426
|
groovy/groovy-core
|
subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java
|
Sql.withInstance
|
public static void withInstance(Map<String, Object> args, Closure c) throws SQLException, ClassNotFoundException {
"""
Invokes a closure passing it a new Sql instance created from the given map of arguments.
The created connection will be closed if required.
@param args a Map contain further arguments
@param c the Closure to call
@see #newInstance(java.util.Map)
@throws SQLException if a database access error occurs
@throws ClassNotFoundException if the driver class cannot be found or loaded
"""
Sql sql = null;
try {
sql = newInstance(args);
c.call(sql);
} finally {
if (sql != null) sql.close();
}
}
|
java
|
public static void withInstance(Map<String, Object> args, Closure c) throws SQLException, ClassNotFoundException {
Sql sql = null;
try {
sql = newInstance(args);
c.call(sql);
} finally {
if (sql != null) sql.close();
}
}
|
[
"public",
"static",
"void",
"withInstance",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"args",
",",
"Closure",
"c",
")",
"throws",
"SQLException",
",",
"ClassNotFoundException",
"{",
"Sql",
"sql",
"=",
"null",
";",
"try",
"{",
"sql",
"=",
"newInstance",
"(",
"args",
")",
";",
"c",
".",
"call",
"(",
"sql",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"sql",
"!=",
"null",
")",
"sql",
".",
"close",
"(",
")",
";",
"}",
"}"
] |
Invokes a closure passing it a new Sql instance created from the given map of arguments.
The created connection will be closed if required.
@param args a Map contain further arguments
@param c the Closure to call
@see #newInstance(java.util.Map)
@throws SQLException if a database access error occurs
@throws ClassNotFoundException if the driver class cannot be found or loaded
|
[
"Invokes",
"a",
"closure",
"passing",
"it",
"a",
"new",
"Sql",
"instance",
"created",
"from",
"the",
"given",
"map",
"of",
"arguments",
".",
"The",
"created",
"connection",
"will",
"be",
"closed",
"if",
"required",
"."
] |
train
|
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java#L608-L616
|
tvesalainen/util
|
util/src/main/java/org/vesalainen/math/CircleFitter.java
|
CircleFitter.filterInnerPoints
|
public static void filterInnerPoints(DenseMatrix64F points, DenseMatrix64F center, int minLeft, double percent) {
"""
Filters points which are closes to the last estimated tempCenter.
@param points
@param center
"""
assert points.numCols == 2;
assert center.numCols == 1;
assert center.numRows == 2;
if (percent <= 0 || percent >= 1)
{
throw new IllegalArgumentException("percent "+percent+" is not between 0 & 1");
}
DistComp dc = new DistComp(center.data[0], center.data[1]);
Matrices.sort(points, dc);
int rows = points.numRows;
double[] d = points.data;
double limit = dc.distance(d[0], d[1])*percent;
for (int r=minLeft;r<rows;r++)
{
double distance = dc.distance(d[2*r], d[2*r+1]);
if (distance < limit)
{
points.reshape(r/2, 2, true);
break;
}
}
}
|
java
|
public static void filterInnerPoints(DenseMatrix64F points, DenseMatrix64F center, int minLeft, double percent)
{
assert points.numCols == 2;
assert center.numCols == 1;
assert center.numRows == 2;
if (percent <= 0 || percent >= 1)
{
throw new IllegalArgumentException("percent "+percent+" is not between 0 & 1");
}
DistComp dc = new DistComp(center.data[0], center.data[1]);
Matrices.sort(points, dc);
int rows = points.numRows;
double[] d = points.data;
double limit = dc.distance(d[0], d[1])*percent;
for (int r=minLeft;r<rows;r++)
{
double distance = dc.distance(d[2*r], d[2*r+1]);
if (distance < limit)
{
points.reshape(r/2, 2, true);
break;
}
}
}
|
[
"public",
"static",
"void",
"filterInnerPoints",
"(",
"DenseMatrix64F",
"points",
",",
"DenseMatrix64F",
"center",
",",
"int",
"minLeft",
",",
"double",
"percent",
")",
"{",
"assert",
"points",
".",
"numCols",
"==",
"2",
";",
"assert",
"center",
".",
"numCols",
"==",
"1",
";",
"assert",
"center",
".",
"numRows",
"==",
"2",
";",
"if",
"(",
"percent",
"<=",
"0",
"||",
"percent",
">=",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"percent \"",
"+",
"percent",
"+",
"\" is not between 0 & 1\"",
")",
";",
"}",
"DistComp",
"dc",
"=",
"new",
"DistComp",
"(",
"center",
".",
"data",
"[",
"0",
"]",
",",
"center",
".",
"data",
"[",
"1",
"]",
")",
";",
"Matrices",
".",
"sort",
"(",
"points",
",",
"dc",
")",
";",
"int",
"rows",
"=",
"points",
".",
"numRows",
";",
"double",
"[",
"]",
"d",
"=",
"points",
".",
"data",
";",
"double",
"limit",
"=",
"dc",
".",
"distance",
"(",
"d",
"[",
"0",
"]",
",",
"d",
"[",
"1",
"]",
")",
"*",
"percent",
";",
"for",
"(",
"int",
"r",
"=",
"minLeft",
";",
"r",
"<",
"rows",
";",
"r",
"++",
")",
"{",
"double",
"distance",
"=",
"dc",
".",
"distance",
"(",
"d",
"[",
"2",
"*",
"r",
"]",
",",
"d",
"[",
"2",
"*",
"r",
"+",
"1",
"]",
")",
";",
"if",
"(",
"distance",
"<",
"limit",
")",
"{",
"points",
".",
"reshape",
"(",
"r",
"/",
"2",
",",
"2",
",",
"true",
")",
";",
"break",
";",
"}",
"}",
"}"
] |
Filters points which are closes to the last estimated tempCenter.
@param points
@param center
|
[
"Filters",
"points",
"which",
"are",
"closes",
"to",
"the",
"last",
"estimated",
"tempCenter",
"."
] |
train
|
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/math/CircleFitter.java#L115-L138
|
michael-rapp/AndroidPreferenceActivity
|
library/src/main/java/de/mrapp/android/preference/activity/animation/HideViewOnScrollAnimation.java
|
HideViewOnScrollAnimation.notifyOnScrollingUp
|
private void notifyOnScrollingUp(@NonNull final View animatedView, final int scrollPosition) {
"""
Notifies all listeners, which have been registered to be notified about the animation's
internal state, when the observed list view is scrolling upwards.
@param animatedView
The view, which is animated by the observed animation, as an instance of the class
{@link View}
@param scrollPosition
The current scroll position of the list view's first item in pixels as an {@link
Integer} value
"""
for (HideViewOnScrollAnimationListener listener : listeners) {
listener.onScrollingUp(this, animatedView, scrollPosition);
}
}
|
java
|
private void notifyOnScrollingUp(@NonNull final View animatedView, final int scrollPosition) {
for (HideViewOnScrollAnimationListener listener : listeners) {
listener.onScrollingUp(this, animatedView, scrollPosition);
}
}
|
[
"private",
"void",
"notifyOnScrollingUp",
"(",
"@",
"NonNull",
"final",
"View",
"animatedView",
",",
"final",
"int",
"scrollPosition",
")",
"{",
"for",
"(",
"HideViewOnScrollAnimationListener",
"listener",
":",
"listeners",
")",
"{",
"listener",
".",
"onScrollingUp",
"(",
"this",
",",
"animatedView",
",",
"scrollPosition",
")",
";",
"}",
"}"
] |
Notifies all listeners, which have been registered to be notified about the animation's
internal state, when the observed list view is scrolling upwards.
@param animatedView
The view, which is animated by the observed animation, as an instance of the class
{@link View}
@param scrollPosition
The current scroll position of the list view's first item in pixels as an {@link
Integer} value
|
[
"Notifies",
"all",
"listeners",
"which",
"have",
"been",
"registered",
"to",
"be",
"notified",
"about",
"the",
"animation",
"s",
"internal",
"state",
"when",
"the",
"observed",
"list",
"view",
"is",
"scrolling",
"upwards",
"."
] |
train
|
https://github.com/michael-rapp/AndroidPreferenceActivity/blob/0fcde73815b4b3bf6bcb36acd3d5733e301bbba5/library/src/main/java/de/mrapp/android/preference/activity/animation/HideViewOnScrollAnimation.java#L124-L128
|
goshippo/shippo-java-client
|
src/main/java/com/shippo/model/Track.java
|
Track.getTrackingInfo
|
public static Track getTrackingInfo(String carrier, String trackingNumber, String apiKey)
throws AuthenticationException, InvalidRequestException, APIConnectionException, APIException {
"""
Get tracking information of any package from given carrier. This
corresponds to https://api.goshippo.com/tracks/<i>carrier</i>/<i>tracking_number</i>
API defined in https://goshippo.com/docs/reference#tracks-retrieve
@param carrier
Name of the carrier (like "usps") tracking the package
@param trackingNumber
Tracking number provided by the carrier for a package
@return Track object containing tracking info
"""
return request(RequestMethod.GET, trackingNumberURL(carrier, trackingNumber), null, Track.class, apiKey);
}
|
java
|
public static Track getTrackingInfo(String carrier, String trackingNumber, String apiKey)
throws AuthenticationException, InvalidRequestException, APIConnectionException, APIException {
return request(RequestMethod.GET, trackingNumberURL(carrier, trackingNumber), null, Track.class, apiKey);
}
|
[
"public",
"static",
"Track",
"getTrackingInfo",
"(",
"String",
"carrier",
",",
"String",
"trackingNumber",
",",
"String",
"apiKey",
")",
"throws",
"AuthenticationException",
",",
"InvalidRequestException",
",",
"APIConnectionException",
",",
"APIException",
"{",
"return",
"request",
"(",
"RequestMethod",
".",
"GET",
",",
"trackingNumberURL",
"(",
"carrier",
",",
"trackingNumber",
")",
",",
"null",
",",
"Track",
".",
"class",
",",
"apiKey",
")",
";",
"}"
] |
Get tracking information of any package from given carrier. This
corresponds to https://api.goshippo.com/tracks/<i>carrier</i>/<i>tracking_number</i>
API defined in https://goshippo.com/docs/reference#tracks-retrieve
@param carrier
Name of the carrier (like "usps") tracking the package
@param trackingNumber
Tracking number provided by the carrier for a package
@return Track object containing tracking info
|
[
"Get",
"tracking",
"information",
"of",
"any",
"package",
"from",
"given",
"carrier",
".",
"This",
"corresponds",
"to",
"https",
":",
"//",
"api",
".",
"goshippo",
".",
"com",
"/",
"tracks",
"/",
"<i",
">",
"carrier<",
"/",
"i",
">",
"/",
"<i",
">",
"tracking_number<",
"/",
"i",
">",
"API",
"defined",
"in",
"https",
":",
"//",
"goshippo",
".",
"com",
"/",
"docs",
"/",
"reference#tracks",
"-",
"retrieve"
] |
train
|
https://github.com/goshippo/shippo-java-client/blob/eecf801c7e07a627c3677a331c0cfcf36cb1678b/src/main/java/com/shippo/model/Track.java#L187-L190
|
buschmais/jqa-maven-plugin
|
src/main/java/com/buschmais/jqassistant/scm/maven/ProjectResolver.java
|
ProjectResolver.getOutputFile
|
static File getOutputFile(MavenProject rootModule, File reportFile, String defaultFile) throws MojoExecutionException {
"""
Determines a report file name.
@param rootModule The base project.
@param reportFile The report file as specified in the pom.xml file or on the command line.
@return The resolved {@link java.io.File}.
@throws MojoExecutionException If the file cannot be determined.
"""
File selectedXmlReportFile;
if (reportFile != null) {
selectedXmlReportFile = reportFile;
} else if (rootModule != null) {
selectedXmlReportFile = new File(getOutputDirectory(rootModule) + "/" + defaultFile);
} else {
throw new MojoExecutionException("Cannot determine report file.");
}
return selectedXmlReportFile;
}
|
java
|
static File getOutputFile(MavenProject rootModule, File reportFile, String defaultFile) throws MojoExecutionException {
File selectedXmlReportFile;
if (reportFile != null) {
selectedXmlReportFile = reportFile;
} else if (rootModule != null) {
selectedXmlReportFile = new File(getOutputDirectory(rootModule) + "/" + defaultFile);
} else {
throw new MojoExecutionException("Cannot determine report file.");
}
return selectedXmlReportFile;
}
|
[
"static",
"File",
"getOutputFile",
"(",
"MavenProject",
"rootModule",
",",
"File",
"reportFile",
",",
"String",
"defaultFile",
")",
"throws",
"MojoExecutionException",
"{",
"File",
"selectedXmlReportFile",
";",
"if",
"(",
"reportFile",
"!=",
"null",
")",
"{",
"selectedXmlReportFile",
"=",
"reportFile",
";",
"}",
"else",
"if",
"(",
"rootModule",
"!=",
"null",
")",
"{",
"selectedXmlReportFile",
"=",
"new",
"File",
"(",
"getOutputDirectory",
"(",
"rootModule",
")",
"+",
"\"/\"",
"+",
"defaultFile",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"MojoExecutionException",
"(",
"\"Cannot determine report file.\"",
")",
";",
"}",
"return",
"selectedXmlReportFile",
";",
"}"
] |
Determines a report file name.
@param rootModule The base project.
@param reportFile The report file as specified in the pom.xml file or on the command line.
@return The resolved {@link java.io.File}.
@throws MojoExecutionException If the file cannot be determined.
|
[
"Determines",
"a",
"report",
"file",
"name",
"."
] |
train
|
https://github.com/buschmais/jqa-maven-plugin/blob/5c21a8058fc1b013333081907fbf00d3525e11c3/src/main/java/com/buschmais/jqassistant/scm/maven/ProjectResolver.java#L156-L166
|
krotscheck/data-file-reader
|
data-file-reader-bson/src/main/java/net/krotscheck/dfr/bson/BSONDataEncoder.java
|
BSONDataEncoder.writeToOutput
|
@Override
protected void writeToOutput(final Map<String, Object> row)
throws IOException {
"""
Write a row to the file.
@param row A row of data.
@throws java.io.IOException Thrown when there are problems writing to the
destination.
"""
if (generator == null) {
ObjectMapper mapper = new ObjectMapper();
BsonFactory factory = new BsonFactory(mapper);
factory.enable(BsonGenerator.Feature.ENABLE_STREAMING);
generator = factory.createJsonGenerator(getOutputStream());
generator.writeStartArray(); // [
}
// Convert the tuple into a map
generator.writeObject(row);
}
|
java
|
@Override
protected void writeToOutput(final Map<String, Object> row)
throws IOException {
if (generator == null) {
ObjectMapper mapper = new ObjectMapper();
BsonFactory factory = new BsonFactory(mapper);
factory.enable(BsonGenerator.Feature.ENABLE_STREAMING);
generator = factory.createJsonGenerator(getOutputStream());
generator.writeStartArray(); // [
}
// Convert the tuple into a map
generator.writeObject(row);
}
|
[
"@",
"Override",
"protected",
"void",
"writeToOutput",
"(",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"row",
")",
"throws",
"IOException",
"{",
"if",
"(",
"generator",
"==",
"null",
")",
"{",
"ObjectMapper",
"mapper",
"=",
"new",
"ObjectMapper",
"(",
")",
";",
"BsonFactory",
"factory",
"=",
"new",
"BsonFactory",
"(",
"mapper",
")",
";",
"factory",
".",
"enable",
"(",
"BsonGenerator",
".",
"Feature",
".",
"ENABLE_STREAMING",
")",
";",
"generator",
"=",
"factory",
".",
"createJsonGenerator",
"(",
"getOutputStream",
"(",
")",
")",
";",
"generator",
".",
"writeStartArray",
"(",
")",
";",
"// [",
"}",
"// Convert the tuple into a map",
"generator",
".",
"writeObject",
"(",
"row",
")",
";",
"}"
] |
Write a row to the file.
@param row A row of data.
@throws java.io.IOException Thrown when there are problems writing to the
destination.
|
[
"Write",
"a",
"row",
"to",
"the",
"file",
"."
] |
train
|
https://github.com/krotscheck/data-file-reader/blob/b9a85bd07dc9f9b8291ffbfb6945443d96371811/data-file-reader-bson/src/main/java/net/krotscheck/dfr/bson/BSONDataEncoder.java#L54-L67
|
sagiegurari/fax4j
|
src/main/java/org/fax4j/spi/http/MultiPartFaxJob2HTTPRequestConverter.java
|
MultiPartFaxJob2HTTPRequestConverter.createCommonHTTPRequest
|
protected HTTPRequest createCommonHTTPRequest(HTTPFaxClientSpi faxClientSpi,FaxActionType faxActionType) {
"""
Creates a HTTP request with the common data.
@param faxClientSpi
The HTTP fax client SPI
@param faxActionType
The fax action type
@return The HTTP request to send
"""
//setup common request data
HTTPRequest httpRequest=new HTTPRequest();
String resource=faxClientSpi.getHTTPResource(faxActionType);
httpRequest.setResource(resource);
String urlParameters=faxClientSpi.getHTTPURLParameters();
httpRequest.setParametersText(urlParameters);
return httpRequest;
}
|
java
|
protected HTTPRequest createCommonHTTPRequest(HTTPFaxClientSpi faxClientSpi,FaxActionType faxActionType)
{
//setup common request data
HTTPRequest httpRequest=new HTTPRequest();
String resource=faxClientSpi.getHTTPResource(faxActionType);
httpRequest.setResource(resource);
String urlParameters=faxClientSpi.getHTTPURLParameters();
httpRequest.setParametersText(urlParameters);
return httpRequest;
}
|
[
"protected",
"HTTPRequest",
"createCommonHTTPRequest",
"(",
"HTTPFaxClientSpi",
"faxClientSpi",
",",
"FaxActionType",
"faxActionType",
")",
"{",
"//setup common request data",
"HTTPRequest",
"httpRequest",
"=",
"new",
"HTTPRequest",
"(",
")",
";",
"String",
"resource",
"=",
"faxClientSpi",
".",
"getHTTPResource",
"(",
"faxActionType",
")",
";",
"httpRequest",
".",
"setResource",
"(",
"resource",
")",
";",
"String",
"urlParameters",
"=",
"faxClientSpi",
".",
"getHTTPURLParameters",
"(",
")",
";",
"httpRequest",
".",
"setParametersText",
"(",
"urlParameters",
")",
";",
"return",
"httpRequest",
";",
"}"
] |
Creates a HTTP request with the common data.
@param faxClientSpi
The HTTP fax client SPI
@param faxActionType
The fax action type
@return The HTTP request to send
|
[
"Creates",
"a",
"HTTP",
"request",
"with",
"the",
"common",
"data",
"."
] |
train
|
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/http/MultiPartFaxJob2HTTPRequestConverter.java#L470-L480
|
QSFT/Doradus
|
doradus-server/src/main/java/com/dell/doradus/service/spider/ObjectUpdater.java
|
ObjectUpdater.deleteObject
|
public ObjectResult deleteObject(SpiderTransaction parentTran, String objID) {
"""
Delete the object with the given object ID. Because of idempotent update semantics,
it is not an error if the object does not exist. If an object is actually deleted,
updates are merged to the given parent SpiderTransaction.
@param parentTran Parent {@link SpiderTransaction} to which updates are applied
if the delete is successful.
@param objID ID of object to be deleted.
@return {@link ObjectResult} representing the results of the delete.
Includes a comment if the object was not found.
"""
ObjectResult result = new ObjectResult(objID);
try {
result.setObjectID(objID);
DBObject dbObj = SpiderService.instance().getObject(m_tableDef, objID);
if (dbObj != null) {
deleteObject(dbObj);
result.setUpdated(true);
parentTran.mergeSubTransaction(m_dbTran);
m_logger.trace("deleteObject(): object deleted with ID={}", objID);
} else {
result.setComment("Object not found");
m_logger.trace("deleteObject(): no object with ID={}", objID);
}
} catch (Throwable ex) {
buildErrorStatus(result, objID, ex);
}
return result;
}
|
java
|
public ObjectResult deleteObject(SpiderTransaction parentTran, String objID) {
ObjectResult result = new ObjectResult(objID);
try {
result.setObjectID(objID);
DBObject dbObj = SpiderService.instance().getObject(m_tableDef, objID);
if (dbObj != null) {
deleteObject(dbObj);
result.setUpdated(true);
parentTran.mergeSubTransaction(m_dbTran);
m_logger.trace("deleteObject(): object deleted with ID={}", objID);
} else {
result.setComment("Object not found");
m_logger.trace("deleteObject(): no object with ID={}", objID);
}
} catch (Throwable ex) {
buildErrorStatus(result, objID, ex);
}
return result;
}
|
[
"public",
"ObjectResult",
"deleteObject",
"(",
"SpiderTransaction",
"parentTran",
",",
"String",
"objID",
")",
"{",
"ObjectResult",
"result",
"=",
"new",
"ObjectResult",
"(",
"objID",
")",
";",
"try",
"{",
"result",
".",
"setObjectID",
"(",
"objID",
")",
";",
"DBObject",
"dbObj",
"=",
"SpiderService",
".",
"instance",
"(",
")",
".",
"getObject",
"(",
"m_tableDef",
",",
"objID",
")",
";",
"if",
"(",
"dbObj",
"!=",
"null",
")",
"{",
"deleteObject",
"(",
"dbObj",
")",
";",
"result",
".",
"setUpdated",
"(",
"true",
")",
";",
"parentTran",
".",
"mergeSubTransaction",
"(",
"m_dbTran",
")",
";",
"m_logger",
".",
"trace",
"(",
"\"deleteObject(): object deleted with ID={}\"",
",",
"objID",
")",
";",
"}",
"else",
"{",
"result",
".",
"setComment",
"(",
"\"Object not found\"",
")",
";",
"m_logger",
".",
"trace",
"(",
"\"deleteObject(): no object with ID={}\"",
",",
"objID",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"ex",
")",
"{",
"buildErrorStatus",
"(",
"result",
",",
"objID",
",",
"ex",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Delete the object with the given object ID. Because of idempotent update semantics,
it is not an error if the object does not exist. If an object is actually deleted,
updates are merged to the given parent SpiderTransaction.
@param parentTran Parent {@link SpiderTransaction} to which updates are applied
if the delete is successful.
@param objID ID of object to be deleted.
@return {@link ObjectResult} representing the results of the delete.
Includes a comment if the object was not found.
|
[
"Delete",
"the",
"object",
"with",
"the",
"given",
"object",
"ID",
".",
"Because",
"of",
"idempotent",
"update",
"semantics",
"it",
"is",
"not",
"an",
"error",
"if",
"the",
"object",
"does",
"not",
"exist",
".",
"If",
"an",
"object",
"is",
"actually",
"deleted",
"updates",
"are",
"merged",
"to",
"the",
"given",
"parent",
"SpiderTransaction",
"."
] |
train
|
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/ObjectUpdater.java#L137-L155
|
beanshell/beanshell
|
src/main/java/bsh/BshClassManager.java
|
BshClassManager.createClassManager
|
public static BshClassManager createClassManager( Interpreter interpreter ) {
"""
Create a new instance of the class manager.
Class manager instnaces are now associated with the interpreter.
@see bsh.Interpreter.getClassManager()
@see bsh.Interpreter.setClassLoader( ClassLoader )
"""
BshClassManager manager;
// Do we have the optional package?
if ( Capabilities.classExists("bsh.classpath.ClassManagerImpl") )
try {
// Try to load the module
// don't refer to it directly here or we're dependent upon it
Class<?> clazz = Capabilities.getExisting("bsh.classpath.ClassManagerImpl");
manager = (BshClassManager) clazz.getConstructor().newInstance();
} catch ( IllegalArgumentException | ReflectiveOperationException | SecurityException e) {
throw new InterpreterError("Error loading classmanager", e);
}
else
manager = new BshClassManager();
manager.declaringInterpreter = interpreter;
return manager;
}
|
java
|
public static BshClassManager createClassManager( Interpreter interpreter )
{
BshClassManager manager;
// Do we have the optional package?
if ( Capabilities.classExists("bsh.classpath.ClassManagerImpl") )
try {
// Try to load the module
// don't refer to it directly here or we're dependent upon it
Class<?> clazz = Capabilities.getExisting("bsh.classpath.ClassManagerImpl");
manager = (BshClassManager) clazz.getConstructor().newInstance();
} catch ( IllegalArgumentException | ReflectiveOperationException | SecurityException e) {
throw new InterpreterError("Error loading classmanager", e);
}
else
manager = new BshClassManager();
manager.declaringInterpreter = interpreter;
return manager;
}
|
[
"public",
"static",
"BshClassManager",
"createClassManager",
"(",
"Interpreter",
"interpreter",
")",
"{",
"BshClassManager",
"manager",
";",
"// Do we have the optional package?",
"if",
"(",
"Capabilities",
".",
"classExists",
"(",
"\"bsh.classpath.ClassManagerImpl\"",
")",
")",
"try",
"{",
"// Try to load the module",
"// don't refer to it directly here or we're dependent upon it",
"Class",
"<",
"?",
">",
"clazz",
"=",
"Capabilities",
".",
"getExisting",
"(",
"\"bsh.classpath.ClassManagerImpl\"",
")",
";",
"manager",
"=",
"(",
"BshClassManager",
")",
"clazz",
".",
"getConstructor",
"(",
")",
".",
"newInstance",
"(",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"|",
"ReflectiveOperationException",
"|",
"SecurityException",
"e",
")",
"{",
"throw",
"new",
"InterpreterError",
"(",
"\"Error loading classmanager\"",
",",
"e",
")",
";",
"}",
"else",
"manager",
"=",
"new",
"BshClassManager",
"(",
")",
";",
"manager",
".",
"declaringInterpreter",
"=",
"interpreter",
";",
"return",
"manager",
";",
"}"
] |
Create a new instance of the class manager.
Class manager instnaces are now associated with the interpreter.
@see bsh.Interpreter.getClassManager()
@see bsh.Interpreter.setClassLoader( ClassLoader )
|
[
"Create",
"a",
"new",
"instance",
"of",
"the",
"class",
"manager",
".",
"Class",
"manager",
"instnaces",
"are",
"now",
"associated",
"with",
"the",
"interpreter",
"."
] |
train
|
https://github.com/beanshell/beanshell/blob/fdddee3de948c9e6babb2d1337028f6fd0a2ba5c/src/main/java/bsh/BshClassManager.java#L361-L380
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.org.apache.cxf.cxf.core.3.2/src/org/apache/cxf/common/classloader/ClassLoaderUtils.java
|
ClassLoaderUtils.getResourceAsStream
|
@FFDCIgnore( {
"""
This is a convenience method to load a resource as a stream. <p/> The
algorithm used to find the resource is given in getResource()
@param resourceName The name of the resource to load
@param callingClass The Class object of the calling object
"""IOException.class})
public static InputStream getResourceAsStream(String resourceName, Class<?> callingClass) {
URL url = getResource(resourceName, callingClass);
try {
return (url != null) ? url.openStream() : null;
} catch (IOException e) {
return null;
}
}
|
java
|
@FFDCIgnore({IOException.class})
public static InputStream getResourceAsStream(String resourceName, Class<?> callingClass) {
URL url = getResource(resourceName, callingClass);
try {
return (url != null) ? url.openStream() : null;
} catch (IOException e) {
return null;
}
}
|
[
"@",
"FFDCIgnore",
"(",
"{",
"IOException",
".",
"class",
"}",
")",
"public",
"static",
"InputStream",
"getResourceAsStream",
"(",
"String",
"resourceName",
",",
"Class",
"<",
"?",
">",
"callingClass",
")",
"{",
"URL",
"url",
"=",
"getResource",
"(",
"resourceName",
",",
"callingClass",
")",
";",
"try",
"{",
"return",
"(",
"url",
"!=",
"null",
")",
"?",
"url",
".",
"openStream",
"(",
")",
":",
"null",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}"
] |
This is a convenience method to load a resource as a stream. <p/> The
algorithm used to find the resource is given in getResource()
@param resourceName The name of the resource to load
@param callingClass The Class object of the calling object
|
[
"This",
"is",
"a",
"convenience",
"method",
"to",
"load",
"a",
"resource",
"as",
"a",
"stream",
".",
"<p",
"/",
">",
"The",
"algorithm",
"used",
"to",
"find",
"the",
"resource",
"is",
"given",
"in",
"getResource",
"()"
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.org.apache.cxf.cxf.core.3.2/src/org/apache/cxf/common/classloader/ClassLoaderUtils.java#L246-L255
|
intuit/QuickBooks-V3-Java-SDK
|
ipp-v3-java-devkit/src/main/java/com/intuit/ipp/serialization/IntuitResponseDeserializer.java
|
IntuitResponseDeserializer.getQueryResponse
|
private QueryResponse getQueryResponse(JsonNode jsonNode) throws IOException {
"""
Method to deserialize the QueryResponse object
@param jsonNode
@return QueryResponse
"""
ObjectMapper mapper = new ObjectMapper();
SimpleModule simpleModule = new SimpleModule("QueryResponseDeserializer", new Version(1, 0, 0, null));
simpleModule.addDeserializer(QueryResponse.class, new QueryResponseDeserializer());
mapper.registerModule(simpleModule);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
return mapper.treeToValue(jsonNode, QueryResponse.class);
}
|
java
|
private QueryResponse getQueryResponse(JsonNode jsonNode) throws IOException {
ObjectMapper mapper = new ObjectMapper();
SimpleModule simpleModule = new SimpleModule("QueryResponseDeserializer", new Version(1, 0, 0, null));
simpleModule.addDeserializer(QueryResponse.class, new QueryResponseDeserializer());
mapper.registerModule(simpleModule);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
return mapper.treeToValue(jsonNode, QueryResponse.class);
}
|
[
"private",
"QueryResponse",
"getQueryResponse",
"(",
"JsonNode",
"jsonNode",
")",
"throws",
"IOException",
"{",
"ObjectMapper",
"mapper",
"=",
"new",
"ObjectMapper",
"(",
")",
";",
"SimpleModule",
"simpleModule",
"=",
"new",
"SimpleModule",
"(",
"\"QueryResponseDeserializer\"",
",",
"new",
"Version",
"(",
"1",
",",
"0",
",",
"0",
",",
"null",
")",
")",
";",
"simpleModule",
".",
"addDeserializer",
"(",
"QueryResponse",
".",
"class",
",",
"new",
"QueryResponseDeserializer",
"(",
")",
")",
";",
"mapper",
".",
"registerModule",
"(",
"simpleModule",
")",
";",
"mapper",
".",
"configure",
"(",
"DeserializationFeature",
".",
"FAIL_ON_UNKNOWN_PROPERTIES",
",",
"false",
")",
";",
"return",
"mapper",
".",
"treeToValue",
"(",
"jsonNode",
",",
"QueryResponse",
".",
"class",
")",
";",
"}"
] |
Method to deserialize the QueryResponse object
@param jsonNode
@return QueryResponse
|
[
"Method",
"to",
"deserialize",
"the",
"QueryResponse",
"object"
] |
train
|
https://github.com/intuit/QuickBooks-V3-Java-SDK/blob/59f988d0776d46620d0b34711c411b2b5b1da06b/ipp-v3-java-devkit/src/main/java/com/intuit/ipp/serialization/IntuitResponseDeserializer.java#L318-L328
|
square/dagger
|
core/src/main/java/dagger/internal/Keys.java
|
Keys.get
|
public static String get(Type type, Annotation[] annotations, Object subject) {
"""
Returns a key for {@code type} annotated with {@code annotations},
reporting failures against {@code subject}.
@param annotations the annotations on a single method, field or parameter.
This array may contain at most one qualifier annotation.
"""
return get(type, extractQualifier(annotations, subject));
}
|
java
|
public static String get(Type type, Annotation[] annotations, Object subject) {
return get(type, extractQualifier(annotations, subject));
}
|
[
"public",
"static",
"String",
"get",
"(",
"Type",
"type",
",",
"Annotation",
"[",
"]",
"annotations",
",",
"Object",
"subject",
")",
"{",
"return",
"get",
"(",
"type",
",",
"extractQualifier",
"(",
"annotations",
",",
"subject",
")",
")",
";",
"}"
] |
Returns a key for {@code type} annotated with {@code annotations},
reporting failures against {@code subject}.
@param annotations the annotations on a single method, field or parameter.
This array may contain at most one qualifier annotation.
|
[
"Returns",
"a",
"key",
"for",
"{",
"@code",
"type",
"}",
"annotated",
"with",
"{",
"@code",
"annotations",
"}",
"reporting",
"failures",
"against",
"{",
"@code",
"subject",
"}",
"."
] |
train
|
https://github.com/square/dagger/blob/572cdd2fe97fc3c148fb3d8e1b2ce7beb4dcbcde/core/src/main/java/dagger/internal/Keys.java#L111-L113
|
VoltDB/voltdb
|
src/frontend/org/voltdb/planner/PlanAssembler.java
|
PlanAssembler.handleUnionLimitOperator
|
private AbstractPlanNode handleUnionLimitOperator(AbstractPlanNode root) {
"""
Add a limit, and return the new root.
@param root top of the original plan
@return new plan's root node
"""
// The coordinator's top limit graph fragment for a MP plan.
// If planning "order by ... limit", getNextUnionPlan()
// will have already added an order by to the coordinator frag.
// This is the only limit node in a SP plan
LimitPlanNode topLimit = m_parsedUnion.getLimitNodeTop();
assert(topLimit != null);
return inlineLimitOperator(root, topLimit);
}
|
java
|
private AbstractPlanNode handleUnionLimitOperator(AbstractPlanNode root) {
// The coordinator's top limit graph fragment for a MP plan.
// If planning "order by ... limit", getNextUnionPlan()
// will have already added an order by to the coordinator frag.
// This is the only limit node in a SP plan
LimitPlanNode topLimit = m_parsedUnion.getLimitNodeTop();
assert(topLimit != null);
return inlineLimitOperator(root, topLimit);
}
|
[
"private",
"AbstractPlanNode",
"handleUnionLimitOperator",
"(",
"AbstractPlanNode",
"root",
")",
"{",
"// The coordinator's top limit graph fragment for a MP plan.",
"// If planning \"order by ... limit\", getNextUnionPlan()",
"// will have already added an order by to the coordinator frag.",
"// This is the only limit node in a SP plan",
"LimitPlanNode",
"topLimit",
"=",
"m_parsedUnion",
".",
"getLimitNodeTop",
"(",
")",
";",
"assert",
"(",
"topLimit",
"!=",
"null",
")",
";",
"return",
"inlineLimitOperator",
"(",
"root",
",",
"topLimit",
")",
";",
"}"
] |
Add a limit, and return the new root.
@param root top of the original plan
@return new plan's root node
|
[
"Add",
"a",
"limit",
"and",
"return",
"the",
"new",
"root",
"."
] |
train
|
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/planner/PlanAssembler.java#L2206-L2214
|
Bedework/bw-util
|
bw-util-servlet-filters/src/main/java/org/bedework/util/servlet/filters/XSLTFilterConfigInfo.java
|
XSLTFilterConfigInfo.makeLocale
|
public static String makeLocale(String lang, String country) {
"""
If either the lang or country is null we provide a default value for
the whole locale. Otherwise we construct one.
@param lang
@param country
@return locale
"""
if ((lang == null) || (lang.length() == 0)) {
return localeInfoDefaultDefault;
}
if ((country == null) || (country.length() == 0)) {
return localeInfoDefaultDefault;
}
return lang + "_" + country;
}
|
java
|
public static String makeLocale(String lang, String country) {
if ((lang == null) || (lang.length() == 0)) {
return localeInfoDefaultDefault;
}
if ((country == null) || (country.length() == 0)) {
return localeInfoDefaultDefault;
}
return lang + "_" + country;
}
|
[
"public",
"static",
"String",
"makeLocale",
"(",
"String",
"lang",
",",
"String",
"country",
")",
"{",
"if",
"(",
"(",
"lang",
"==",
"null",
")",
"||",
"(",
"lang",
".",
"length",
"(",
")",
"==",
"0",
")",
")",
"{",
"return",
"localeInfoDefaultDefault",
";",
"}",
"if",
"(",
"(",
"country",
"==",
"null",
")",
"||",
"(",
"country",
".",
"length",
"(",
")",
"==",
"0",
")",
")",
"{",
"return",
"localeInfoDefaultDefault",
";",
"}",
"return",
"lang",
"+",
"\"_\"",
"+",
"country",
";",
"}"
] |
If either the lang or country is null we provide a default value for
the whole locale. Otherwise we construct one.
@param lang
@param country
@return locale
|
[
"If",
"either",
"the",
"lang",
"or",
"country",
"is",
"null",
"we",
"provide",
"a",
"default",
"value",
"for",
"the",
"whole",
"locale",
".",
"Otherwise",
"we",
"construct",
"one",
"."
] |
train
|
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-servlet-filters/src/main/java/org/bedework/util/servlet/filters/XSLTFilterConfigInfo.java#L355-L365
|
kite-sdk/kite
|
kite-data/kite-data-hbase/src/main/java/org/kitesdk/data/hbase/avro/AvroUtils.java
|
AvroUtils.writeAvroEntity
|
public static <T> void writeAvroEntity(T entity, Encoder encoder,
DatumWriter<T> writer) {
"""
Given an entity, an avro schema, and an encoder, write the entity to the
encoder's underlying output stream.
@param entity
The entity we want to encode.
@param encoder
The Avro Encoder we will write to.
@param writer
The DatumWriter we'll use to encode the entity to the encoder.
"""
try {
writer.write(entity, encoder);
encoder.flush();
} catch (IOException e) {
throw new SerializationException("Could not serialize Avro entity", e);
}
}
|
java
|
public static <T> void writeAvroEntity(T entity, Encoder encoder,
DatumWriter<T> writer) {
try {
writer.write(entity, encoder);
encoder.flush();
} catch (IOException e) {
throw new SerializationException("Could not serialize Avro entity", e);
}
}
|
[
"public",
"static",
"<",
"T",
">",
"void",
"writeAvroEntity",
"(",
"T",
"entity",
",",
"Encoder",
"encoder",
",",
"DatumWriter",
"<",
"T",
">",
"writer",
")",
"{",
"try",
"{",
"writer",
".",
"write",
"(",
"entity",
",",
"encoder",
")",
";",
"encoder",
".",
"flush",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"SerializationException",
"(",
"\"Could not serialize Avro entity\"",
",",
"e",
")",
";",
"}",
"}"
] |
Given an entity, an avro schema, and an encoder, write the entity to the
encoder's underlying output stream.
@param entity
The entity we want to encode.
@param encoder
The Avro Encoder we will write to.
@param writer
The DatumWriter we'll use to encode the entity to the encoder.
|
[
"Given",
"an",
"entity",
"an",
"avro",
"schema",
"and",
"an",
"encoder",
"write",
"the",
"entity",
"to",
"the",
"encoder",
"s",
"underlying",
"output",
"stream",
"."
] |
train
|
https://github.com/kite-sdk/kite/blob/72bfb4b1a881af85808cd7f14bc3e15160a1e811/kite-data/kite-data-hbase/src/main/java/org/kitesdk/data/hbase/avro/AvroUtils.java#L115-L123
|
HeidelTime/heideltime
|
src/jvntextpro/util/StringUtils.java
|
StringUtils.countOccurrences
|
public static int countOccurrences( String s, char c ) {
"""
Counts the number of occurrences of a character in the specified <tt>String</tt>.
@param s the <tt>String</tt> to analyze.
@param c the character to search for.
@return number of occurrences found.
"""
int count = 0;
int index = 0;
while( true )
{
index = s.indexOf( c, index );
if( index == -1 )
{
break;
}
count++;
}
return count;
}
|
java
|
public static int countOccurrences( String s, char c )
{
int count = 0;
int index = 0;
while( true )
{
index = s.indexOf( c, index );
if( index == -1 )
{
break;
}
count++;
}
return count;
}
|
[
"public",
"static",
"int",
"countOccurrences",
"(",
"String",
"s",
",",
"char",
"c",
")",
"{",
"int",
"count",
"=",
"0",
";",
"int",
"index",
"=",
"0",
";",
"while",
"(",
"true",
")",
"{",
"index",
"=",
"s",
".",
"indexOf",
"(",
"c",
",",
"index",
")",
";",
"if",
"(",
"index",
"==",
"-",
"1",
")",
"{",
"break",
";",
"}",
"count",
"++",
";",
"}",
"return",
"count",
";",
"}"
] |
Counts the number of occurrences of a character in the specified <tt>String</tt>.
@param s the <tt>String</tt> to analyze.
@param c the character to search for.
@return number of occurrences found.
|
[
"Counts",
"the",
"number",
"of",
"occurrences",
"of",
"a",
"character",
"in",
"the",
"specified",
"<tt",
">",
"String<",
"/",
"tt",
">",
"."
] |
train
|
https://github.com/HeidelTime/heideltime/blob/4ef5002eb5ecfeb818086ff7e394e792ee360335/src/jvntextpro/util/StringUtils.java#L532-L546
|
aws/aws-sdk-java
|
aws-java-sdk-logs/src/main/java/com/amazonaws/services/logs/model/GetLogRecordResult.java
|
GetLogRecordResult.setLogRecord
|
public void setLogRecord(java.util.Map<String, String> logRecord) {
"""
<p>
The requested log event, as a JSON string.
</p>
@param logRecord
The requested log event, as a JSON string.
"""
this.logRecord = logRecord == null ? null : new com.amazonaws.internal.SdkInternalMap<String, String>(logRecord);
}
|
java
|
public void setLogRecord(java.util.Map<String, String> logRecord) {
this.logRecord = logRecord == null ? null : new com.amazonaws.internal.SdkInternalMap<String, String>(logRecord);
}
|
[
"public",
"void",
"setLogRecord",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"logRecord",
")",
"{",
"this",
".",
"logRecord",
"=",
"logRecord",
"==",
"null",
"?",
"null",
":",
"new",
"com",
".",
"amazonaws",
".",
"internal",
".",
"SdkInternalMap",
"<",
"String",
",",
"String",
">",
"(",
"logRecord",
")",
";",
"}"
] |
<p>
The requested log event, as a JSON string.
</p>
@param logRecord
The requested log event, as a JSON string.
|
[
"<p",
">",
"The",
"requested",
"log",
"event",
"as",
"a",
"JSON",
"string",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-logs/src/main/java/com/amazonaws/services/logs/model/GetLogRecordResult.java#L57-L59
|
astrapi69/jaulp-wicket
|
jaulp-wicket-base/src/main/java/de/alpharogroup/wicket/base/util/parameter/PageParametersExtensions.java
|
PageParametersExtensions.getParameter
|
public static String getParameter(final PageParameters parameters, final String name) {
"""
Gets the parameter or returns null if it does not exists or is empty.
@param parameters
the parameters
@param name
the name
@return the parameter or returns null if it does not exists or is empty.
"""
return getString(parameters.get(name));
}
|
java
|
public static String getParameter(final PageParameters parameters, final String name)
{
return getString(parameters.get(name));
}
|
[
"public",
"static",
"String",
"getParameter",
"(",
"final",
"PageParameters",
"parameters",
",",
"final",
"String",
"name",
")",
"{",
"return",
"getString",
"(",
"parameters",
".",
"get",
"(",
"name",
")",
")",
";",
"}"
] |
Gets the parameter or returns null if it does not exists or is empty.
@param parameters
the parameters
@param name
the name
@return the parameter or returns null if it does not exists or is empty.
|
[
"Gets",
"the",
"parameter",
"or",
"returns",
"null",
"if",
"it",
"does",
"not",
"exists",
"or",
"is",
"empty",
"."
] |
train
|
https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-base/src/main/java/de/alpharogroup/wicket/base/util/parameter/PageParametersExtensions.java#L177-L180
|
lightblueseas/file-worker
|
src/main/java/de/alpharogroup/file/modify/ModifyFileExtensions.java
|
ModifyFileExtensions.modifyFile
|
public static void modifyFile(Path inFilePath, Path outFilePath, FileChangable modifier)
throws IOException {
"""
Modifies the input file line by line and writes the modification in the new output file
@param inFilePath
the in file path
@param outFilePath
the out file path
@param modifier
the modifier {@linkplain BiFunction}
@throws IOException
Signals that an I/O exception has occurred.
"""
try (
BufferedReader bufferedReader = new BufferedReader(new FileReader(inFilePath.toFile()));
Writer writer = new BufferedWriter(
new OutputStreamWriter(new FileOutputStream(outFilePath.toFile()), "utf-8")))
{
String readLine;
int counter = 0;
while ((readLine = bufferedReader.readLine()) != null)
{
writer.write(modifier.apply(counter, readLine));
counter++;
}
}
}
|
java
|
public static void modifyFile(Path inFilePath, Path outFilePath, FileChangable modifier)
throws IOException
{
try (
BufferedReader bufferedReader = new BufferedReader(new FileReader(inFilePath.toFile()));
Writer writer = new BufferedWriter(
new OutputStreamWriter(new FileOutputStream(outFilePath.toFile()), "utf-8")))
{
String readLine;
int counter = 0;
while ((readLine = bufferedReader.readLine()) != null)
{
writer.write(modifier.apply(counter, readLine));
counter++;
}
}
}
|
[
"public",
"static",
"void",
"modifyFile",
"(",
"Path",
"inFilePath",
",",
"Path",
"outFilePath",
",",
"FileChangable",
"modifier",
")",
"throws",
"IOException",
"{",
"try",
"(",
"BufferedReader",
"bufferedReader",
"=",
"new",
"BufferedReader",
"(",
"new",
"FileReader",
"(",
"inFilePath",
".",
"toFile",
"(",
")",
")",
")",
";",
"Writer",
"writer",
"=",
"new",
"BufferedWriter",
"(",
"new",
"OutputStreamWriter",
"(",
"new",
"FileOutputStream",
"(",
"outFilePath",
".",
"toFile",
"(",
")",
")",
",",
"\"utf-8\"",
")",
")",
")",
"{",
"String",
"readLine",
";",
"int",
"counter",
"=",
"0",
";",
"while",
"(",
"(",
"readLine",
"=",
"bufferedReader",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"writer",
".",
"write",
"(",
"modifier",
".",
"apply",
"(",
"counter",
",",
"readLine",
")",
")",
";",
"counter",
"++",
";",
"}",
"}",
"}"
] |
Modifies the input file line by line and writes the modification in the new output file
@param inFilePath
the in file path
@param outFilePath
the out file path
@param modifier
the modifier {@linkplain BiFunction}
@throws IOException
Signals that an I/O exception has occurred.
|
[
"Modifies",
"the",
"input",
"file",
"line",
"by",
"line",
"and",
"writes",
"the",
"modification",
"in",
"the",
"new",
"output",
"file"
] |
train
|
https://github.com/lightblueseas/file-worker/blob/2c81de10fb5d68de64c1abc3ed64ca681ce76da8/src/main/java/de/alpharogroup/file/modify/ModifyFileExtensions.java#L59-L75
|
eclipse/xtext-extras
|
org.eclipse.xtext.xbase/src/org/eclipse/xtext/xbase/scoping/batch/ConstructorScopes.java
|
ConstructorScopes.createConstructorScope
|
public IScope createConstructorScope(EObject context, EReference reference, IFeatureScopeSession session, IResolvedTypes resolvedTypes) {
"""
Creates the constructor scope for {@link XConstructorCall}.
The scope will likely contain descriptions for {@link JvmConstructor constructors}.
If there is not constructor declared, it may contain {@link JvmType types}.
@param session the currently available visibilityHelper data
@param reference the reference that will hold the resolved constructor
@param resolvedTypes the currently known resolved types
"""
if (!(context instanceof XConstructorCall)) {
return IScope.NULLSCOPE;
}
/*
* We use a type scope here in order to provide better feedback for users,
* e.g. if the constructor call refers to an interface or a primitive.
*/
final IScope delegateScope = typeScopes.createTypeScope(context, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, session, resolvedTypes);
IScope result = new ConstructorTypeScopeWrapper(context, session, delegateScope);
return result;
}
|
java
|
public IScope createConstructorScope(EObject context, EReference reference, IFeatureScopeSession session, IResolvedTypes resolvedTypes) {
if (!(context instanceof XConstructorCall)) {
return IScope.NULLSCOPE;
}
/*
* We use a type scope here in order to provide better feedback for users,
* e.g. if the constructor call refers to an interface or a primitive.
*/
final IScope delegateScope = typeScopes.createTypeScope(context, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, session, resolvedTypes);
IScope result = new ConstructorTypeScopeWrapper(context, session, delegateScope);
return result;
}
|
[
"public",
"IScope",
"createConstructorScope",
"(",
"EObject",
"context",
",",
"EReference",
"reference",
",",
"IFeatureScopeSession",
"session",
",",
"IResolvedTypes",
"resolvedTypes",
")",
"{",
"if",
"(",
"!",
"(",
"context",
"instanceof",
"XConstructorCall",
")",
")",
"{",
"return",
"IScope",
".",
"NULLSCOPE",
";",
"}",
"/*\n\t\t * We use a type scope here in order to provide better feedback for users,\n\t\t * e.g. if the constructor call refers to an interface or a primitive.\n\t\t */",
"final",
"IScope",
"delegateScope",
"=",
"typeScopes",
".",
"createTypeScope",
"(",
"context",
",",
"TypesPackage",
".",
"Literals",
".",
"JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE",
",",
"session",
",",
"resolvedTypes",
")",
";",
"IScope",
"result",
"=",
"new",
"ConstructorTypeScopeWrapper",
"(",
"context",
",",
"session",
",",
"delegateScope",
")",
";",
"return",
"result",
";",
"}"
] |
Creates the constructor scope for {@link XConstructorCall}.
The scope will likely contain descriptions for {@link JvmConstructor constructors}.
If there is not constructor declared, it may contain {@link JvmType types}.
@param session the currently available visibilityHelper data
@param reference the reference that will hold the resolved constructor
@param resolvedTypes the currently known resolved types
|
[
"Creates",
"the",
"constructor",
"scope",
"for",
"{",
"@link",
"XConstructorCall",
"}",
".",
"The",
"scope",
"will",
"likely",
"contain",
"descriptions",
"for",
"{",
"@link",
"JvmConstructor",
"constructors",
"}",
".",
"If",
"there",
"is",
"not",
"constructor",
"declared",
"it",
"may",
"contain",
"{",
"@link",
"JvmType",
"types",
"}",
"."
] |
train
|
https://github.com/eclipse/xtext-extras/blob/451359541295323a29f5855e633f770cec02069a/org.eclipse.xtext.xbase/src/org/eclipse/xtext/xbase/scoping/batch/ConstructorScopes.java#L59-L70
|
domaframework/doma-gen
|
src/main/java/org/seasar/doma/extension/gen/GlobalFactory.java
|
GlobalFactory.createDataSource
|
public DataSource createDataSource(Driver driver, String user, String password, String url) {
"""
データソースを作成します。
@param driver JDBCドライバー
@param user ユーザー
@param password パスワード
@param url 接続URL
@return データソース
"""
SimpleDataSource dataSource = new SimpleDataSource();
dataSource.setDriver(driver);
dataSource.setUser(user);
dataSource.setPassword(password);
dataSource.setUrl(url);
return dataSource;
}
|
java
|
public DataSource createDataSource(Driver driver, String user, String password, String url) {
SimpleDataSource dataSource = new SimpleDataSource();
dataSource.setDriver(driver);
dataSource.setUser(user);
dataSource.setPassword(password);
dataSource.setUrl(url);
return dataSource;
}
|
[
"public",
"DataSource",
"createDataSource",
"(",
"Driver",
"driver",
",",
"String",
"user",
",",
"String",
"password",
",",
"String",
"url",
")",
"{",
"SimpleDataSource",
"dataSource",
"=",
"new",
"SimpleDataSource",
"(",
")",
";",
"dataSource",
".",
"setDriver",
"(",
"driver",
")",
";",
"dataSource",
".",
"setUser",
"(",
"user",
")",
";",
"dataSource",
".",
"setPassword",
"(",
"password",
")",
";",
"dataSource",
".",
"setUrl",
"(",
"url",
")",
";",
"return",
"dataSource",
";",
"}"
] |
データソースを作成します。
@param driver JDBCドライバー
@param user ユーザー
@param password パスワード
@param url 接続URL
@return データソース
|
[
"データソースを作成します。"
] |
train
|
https://github.com/domaframework/doma-gen/blob/8046e0b28d2167d444125f206ce36e554b3ee616/src/main/java/org/seasar/doma/extension/gen/GlobalFactory.java#L25-L32
|
b3dgs/lionengine
|
lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/tile/map/transition/MapTileTransitionModel.java
|
MapTileTransitionModel.checkTransitives
|
private void checkTransitives(Collection<Tile> resolved, Tile tile) {
"""
Check tile transitive groups.
@param resolved The resolved tiles.
@param tile The tile to check.
"""
boolean isTransitive = false;
for (final Tile neighbor : map.getNeighbors(tile))
{
final String group = mapGroup.getGroup(tile);
final String neighborGroup = mapGroup.getGroup(neighbor);
final Collection<GroupTransition> transitives = getTransitives(group, neighborGroup);
if (transitives.size() > 1 && (getTransition(neighbor, group) == null || isCenter(neighbor)))
{
final int iterations = transitives.size() - 3;
int i = 0;
for (final GroupTransition transitive : transitives)
{
updateTransitive(resolved, tile, neighbor, transitive);
isTransitive = true;
i++;
if (i > iterations)
{
break;
}
}
}
}
// Restore initial tile once transition solved by transitive
if (isTransitive)
{
map.setTile(tile);
}
}
|
java
|
private void checkTransitives(Collection<Tile> resolved, Tile tile)
{
boolean isTransitive = false;
for (final Tile neighbor : map.getNeighbors(tile))
{
final String group = mapGroup.getGroup(tile);
final String neighborGroup = mapGroup.getGroup(neighbor);
final Collection<GroupTransition> transitives = getTransitives(group, neighborGroup);
if (transitives.size() > 1 && (getTransition(neighbor, group) == null || isCenter(neighbor)))
{
final int iterations = transitives.size() - 3;
int i = 0;
for (final GroupTransition transitive : transitives)
{
updateTransitive(resolved, tile, neighbor, transitive);
isTransitive = true;
i++;
if (i > iterations)
{
break;
}
}
}
}
// Restore initial tile once transition solved by transitive
if (isTransitive)
{
map.setTile(tile);
}
}
|
[
"private",
"void",
"checkTransitives",
"(",
"Collection",
"<",
"Tile",
">",
"resolved",
",",
"Tile",
"tile",
")",
"{",
"boolean",
"isTransitive",
"=",
"false",
";",
"for",
"(",
"final",
"Tile",
"neighbor",
":",
"map",
".",
"getNeighbors",
"(",
"tile",
")",
")",
"{",
"final",
"String",
"group",
"=",
"mapGroup",
".",
"getGroup",
"(",
"tile",
")",
";",
"final",
"String",
"neighborGroup",
"=",
"mapGroup",
".",
"getGroup",
"(",
"neighbor",
")",
";",
"final",
"Collection",
"<",
"GroupTransition",
">",
"transitives",
"=",
"getTransitives",
"(",
"group",
",",
"neighborGroup",
")",
";",
"if",
"(",
"transitives",
".",
"size",
"(",
")",
">",
"1",
"&&",
"(",
"getTransition",
"(",
"neighbor",
",",
"group",
")",
"==",
"null",
"||",
"isCenter",
"(",
"neighbor",
")",
")",
")",
"{",
"final",
"int",
"iterations",
"=",
"transitives",
".",
"size",
"(",
")",
"-",
"3",
";",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"final",
"GroupTransition",
"transitive",
":",
"transitives",
")",
"{",
"updateTransitive",
"(",
"resolved",
",",
"tile",
",",
"neighbor",
",",
"transitive",
")",
";",
"isTransitive",
"=",
"true",
";",
"i",
"++",
";",
"if",
"(",
"i",
">",
"iterations",
")",
"{",
"break",
";",
"}",
"}",
"}",
"}",
"// Restore initial tile once transition solved by transitive\r",
"if",
"(",
"isTransitive",
")",
"{",
"map",
".",
"setTile",
"(",
"tile",
")",
";",
"}",
"}"
] |
Check tile transitive groups.
@param resolved The resolved tiles.
@param tile The tile to check.
|
[
"Check",
"tile",
"transitive",
"groups",
"."
] |
train
|
https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/tile/map/transition/MapTileTransitionModel.java#L318-L348
|
apache/flink
|
flink-state-backends/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/RocksDBStateDownloader.java
|
RocksDBStateDownloader.downloadDataForAllStateHandles
|
private void downloadDataForAllStateHandles(
Map<StateHandleID, StreamStateHandle> stateHandleMap,
Path restoreInstancePath,
CloseableRegistry closeableRegistry) throws Exception {
"""
Copies all the files from the given stream state handles to the given path, renaming the files w.r.t. their
{@link StateHandleID}.
"""
try {
List<Runnable> runnables = createDownloadRunnables(stateHandleMap, restoreInstancePath, closeableRegistry);
List<CompletableFuture<Void>> futures = new ArrayList<>(runnables.size());
for (Runnable runnable : runnables) {
futures.add(CompletableFuture.runAsync(runnable, executorService));
}
FutureUtils.waitForAll(futures).get();
} catch (ExecutionException e) {
Throwable throwable = ExceptionUtils.stripExecutionException(e);
throwable = ExceptionUtils.stripException(throwable, RuntimeException.class);
if (throwable instanceof IOException) {
throw (IOException) throwable;
} else {
throw new FlinkRuntimeException("Failed to download data for state handles.", e);
}
}
}
|
java
|
private void downloadDataForAllStateHandles(
Map<StateHandleID, StreamStateHandle> stateHandleMap,
Path restoreInstancePath,
CloseableRegistry closeableRegistry) throws Exception {
try {
List<Runnable> runnables = createDownloadRunnables(stateHandleMap, restoreInstancePath, closeableRegistry);
List<CompletableFuture<Void>> futures = new ArrayList<>(runnables.size());
for (Runnable runnable : runnables) {
futures.add(CompletableFuture.runAsync(runnable, executorService));
}
FutureUtils.waitForAll(futures).get();
} catch (ExecutionException e) {
Throwable throwable = ExceptionUtils.stripExecutionException(e);
throwable = ExceptionUtils.stripException(throwable, RuntimeException.class);
if (throwable instanceof IOException) {
throw (IOException) throwable;
} else {
throw new FlinkRuntimeException("Failed to download data for state handles.", e);
}
}
}
|
[
"private",
"void",
"downloadDataForAllStateHandles",
"(",
"Map",
"<",
"StateHandleID",
",",
"StreamStateHandle",
">",
"stateHandleMap",
",",
"Path",
"restoreInstancePath",
",",
"CloseableRegistry",
"closeableRegistry",
")",
"throws",
"Exception",
"{",
"try",
"{",
"List",
"<",
"Runnable",
">",
"runnables",
"=",
"createDownloadRunnables",
"(",
"stateHandleMap",
",",
"restoreInstancePath",
",",
"closeableRegistry",
")",
";",
"List",
"<",
"CompletableFuture",
"<",
"Void",
">",
">",
"futures",
"=",
"new",
"ArrayList",
"<>",
"(",
"runnables",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"Runnable",
"runnable",
":",
"runnables",
")",
"{",
"futures",
".",
"add",
"(",
"CompletableFuture",
".",
"runAsync",
"(",
"runnable",
",",
"executorService",
")",
")",
";",
"}",
"FutureUtils",
".",
"waitForAll",
"(",
"futures",
")",
".",
"get",
"(",
")",
";",
"}",
"catch",
"(",
"ExecutionException",
"e",
")",
"{",
"Throwable",
"throwable",
"=",
"ExceptionUtils",
".",
"stripExecutionException",
"(",
"e",
")",
";",
"throwable",
"=",
"ExceptionUtils",
".",
"stripException",
"(",
"throwable",
",",
"RuntimeException",
".",
"class",
")",
";",
"if",
"(",
"throwable",
"instanceof",
"IOException",
")",
"{",
"throw",
"(",
"IOException",
")",
"throwable",
";",
"}",
"else",
"{",
"throw",
"new",
"FlinkRuntimeException",
"(",
"\"Failed to download data for state handles.\"",
",",
"e",
")",
";",
"}",
"}",
"}"
] |
Copies all the files from the given stream state handles to the given path, renaming the files w.r.t. their
{@link StateHandleID}.
|
[
"Copies",
"all",
"the",
"files",
"from",
"the",
"given",
"stream",
"state",
"handles",
"to",
"the",
"given",
"path",
"renaming",
"the",
"files",
"w",
".",
"r",
".",
"t",
".",
"their",
"{"
] |
train
|
https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-state-backends/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/RocksDBStateDownloader.java#L74-L95
|
nominanuda/zen-project
|
zen-base/src/main/java/com/nominanuda/xml/DOMBuilder.java
|
DOMBuilder.charactersRaw
|
public void charactersRaw(char ch[], int start, int length)
throws org.xml.sax.SAXException {
"""
If available, when the disable-output-escaping attribute is used, output
raw text without escaping. A PI will be inserted in front of the node
with the name "lotusxsl-next-is-raw" and a value of "formatter-to-dom".
@param ch
Array containing the characters
@param start
Index to start of characters in the array
@param length
Number of characters in the array
"""
if (isOutsideDocElem()
&& saxHelper.isWhiteSpace(ch, start, length))
return; // avoid DOM006 Hierarchy request error
String s = new String(ch, start, length);
append(m_doc.createProcessingInstruction("xslt-next-is-raw",
"formatter-to-dom"));
append(m_doc.createTextNode(s));
}
|
java
|
public void charactersRaw(char ch[], int start, int length)
throws org.xml.sax.SAXException {
if (isOutsideDocElem()
&& saxHelper.isWhiteSpace(ch, start, length))
return; // avoid DOM006 Hierarchy request error
String s = new String(ch, start, length);
append(m_doc.createProcessingInstruction("xslt-next-is-raw",
"formatter-to-dom"));
append(m_doc.createTextNode(s));
}
|
[
"public",
"void",
"charactersRaw",
"(",
"char",
"ch",
"[",
"]",
",",
"int",
"start",
",",
"int",
"length",
")",
"throws",
"org",
".",
"xml",
".",
"sax",
".",
"SAXException",
"{",
"if",
"(",
"isOutsideDocElem",
"(",
")",
"&&",
"saxHelper",
".",
"isWhiteSpace",
"(",
"ch",
",",
"start",
",",
"length",
")",
")",
"return",
";",
"// avoid DOM006 Hierarchy request error",
"String",
"s",
"=",
"new",
"String",
"(",
"ch",
",",
"start",
",",
"length",
")",
";",
"append",
"(",
"m_doc",
".",
"createProcessingInstruction",
"(",
"\"xslt-next-is-raw\"",
",",
"\"formatter-to-dom\"",
")",
")",
";",
"append",
"(",
"m_doc",
".",
"createTextNode",
"(",
"s",
")",
")",
";",
"}"
] |
If available, when the disable-output-escaping attribute is used, output
raw text without escaping. A PI will be inserted in front of the node
with the name "lotusxsl-next-is-raw" and a value of "formatter-to-dom".
@param ch
Array containing the characters
@param start
Index to start of characters in the array
@param length
Number of characters in the array
|
[
"If",
"available",
"when",
"the",
"disable",
"-",
"output",
"-",
"escaping",
"attribute",
"is",
"used",
"output",
"raw",
"text",
"without",
"escaping",
".",
"A",
"PI",
"will",
"be",
"inserted",
"in",
"front",
"of",
"the",
"node",
"with",
"the",
"name",
"lotusxsl",
"-",
"next",
"-",
"is",
"-",
"raw",
"and",
"a",
"value",
"of",
"formatter",
"-",
"to",
"-",
"dom",
"."
] |
train
|
https://github.com/nominanuda/zen-project/blob/fe48ae8da198eb7066c2b56bf2ffafe4cdfc451d/zen-base/src/main/java/com/nominanuda/xml/DOMBuilder.java#L477-L488
|
alkacon/opencms-core
|
src/org/opencms/ui/apps/git/CmsGitToolOptionsPanel.java
|
CmsGitToolOptionsPanel.addSelectableModule
|
public void addSelectableModule(final String moduleName) {
"""
Adds a check box and info widget for a module which should be selectable for check-in.<p>
@param moduleName the name of the module
"""
boolean enabled = true; /* OpenCms.getModuleManager().hasModule(moduleName); */
CheckBox moduleCheckBox = new CheckBox();
String iconUri = CmsWorkplace.getResourceUri("tools/modules/buttons/modules.png");
CmsResourceInfo info = new CmsResourceInfo(moduleName, "", iconUri);
HorizontalLayout line = new HorizontalLayout();
line.setWidth("100%");
line.addComponent(moduleCheckBox);
info.setWidth("100%");
line.addComponent(info);
line.setComponentAlignment(moduleCheckBox, Alignment.MIDDLE_CENTER);
line.setExpandRatio(info, 1.0f);
moduleCheckBox.setEnabled(true);
moduleCheckBox.setValue(Boolean.valueOf(enabled)); // If enabled, then checked by default
m_moduleCheckboxes.put(moduleName, moduleCheckBox);
m_moduleSelectionContainer.addComponent(line, m_moduleSelectionContainer.getComponentCount() - 1);
setTab(m_dialogTab);
}
|
java
|
public void addSelectableModule(final String moduleName) {
boolean enabled = true; /* OpenCms.getModuleManager().hasModule(moduleName); */
CheckBox moduleCheckBox = new CheckBox();
String iconUri = CmsWorkplace.getResourceUri("tools/modules/buttons/modules.png");
CmsResourceInfo info = new CmsResourceInfo(moduleName, "", iconUri);
HorizontalLayout line = new HorizontalLayout();
line.setWidth("100%");
line.addComponent(moduleCheckBox);
info.setWidth("100%");
line.addComponent(info);
line.setComponentAlignment(moduleCheckBox, Alignment.MIDDLE_CENTER);
line.setExpandRatio(info, 1.0f);
moduleCheckBox.setEnabled(true);
moduleCheckBox.setValue(Boolean.valueOf(enabled)); // If enabled, then checked by default
m_moduleCheckboxes.put(moduleName, moduleCheckBox);
m_moduleSelectionContainer.addComponent(line, m_moduleSelectionContainer.getComponentCount() - 1);
setTab(m_dialogTab);
}
|
[
"public",
"void",
"addSelectableModule",
"(",
"final",
"String",
"moduleName",
")",
"{",
"boolean",
"enabled",
"=",
"true",
";",
"/* OpenCms.getModuleManager().hasModule(moduleName); */",
"CheckBox",
"moduleCheckBox",
"=",
"new",
"CheckBox",
"(",
")",
";",
"String",
"iconUri",
"=",
"CmsWorkplace",
".",
"getResourceUri",
"(",
"\"tools/modules/buttons/modules.png\"",
")",
";",
"CmsResourceInfo",
"info",
"=",
"new",
"CmsResourceInfo",
"(",
"moduleName",
",",
"\"\"",
",",
"iconUri",
")",
";",
"HorizontalLayout",
"line",
"=",
"new",
"HorizontalLayout",
"(",
")",
";",
"line",
".",
"setWidth",
"(",
"\"100%\"",
")",
";",
"line",
".",
"addComponent",
"(",
"moduleCheckBox",
")",
";",
"info",
".",
"setWidth",
"(",
"\"100%\"",
")",
";",
"line",
".",
"addComponent",
"(",
"info",
")",
";",
"line",
".",
"setComponentAlignment",
"(",
"moduleCheckBox",
",",
"Alignment",
".",
"MIDDLE_CENTER",
")",
";",
"line",
".",
"setExpandRatio",
"(",
"info",
",",
"1.0f",
")",
";",
"moduleCheckBox",
".",
"setEnabled",
"(",
"true",
")",
";",
"moduleCheckBox",
".",
"setValue",
"(",
"Boolean",
".",
"valueOf",
"(",
"enabled",
")",
")",
";",
"// If enabled, then checked by default",
"m_moduleCheckboxes",
".",
"put",
"(",
"moduleName",
",",
"moduleCheckBox",
")",
";",
"m_moduleSelectionContainer",
".",
"addComponent",
"(",
"line",
",",
"m_moduleSelectionContainer",
".",
"getComponentCount",
"(",
")",
"-",
"1",
")",
";",
"setTab",
"(",
"m_dialogTab",
")",
";",
"}"
] |
Adds a check box and info widget for a module which should be selectable for check-in.<p>
@param moduleName the name of the module
|
[
"Adds",
"a",
"check",
"box",
"and",
"info",
"widget",
"for",
"a",
"module",
"which",
"should",
"be",
"selectable",
"for",
"check",
"-",
"in",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/apps/git/CmsGitToolOptionsPanel.java#L346-L364
|
google/j2objc
|
jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/SimpleTimeZone.java
|
SimpleTimeZone.setEndRule
|
public void setEndRule(int month, int dayOfWeekInMonth, int dayOfWeek, int time) {
"""
Sets the daylight savings ending rule. For example, if Daylight Savings Time
ends at the last (-1) Sunday in October, at 2 AM in standard time,
you can set the end rule by calling:
<code>setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2*60*60*1000);</code>
@param month The daylight savings ending month. Month is
0-based. eg, 0 for January.
@param dayOfWeekInMonth The daylight savings ending
day-of-week-in-month. Please see the member
description for an example.
@param dayOfWeek The daylight savings ending day-of-week. Please
see the member description for an example.
@param time The daylight savings ending time in local wall time,
which is daylight time in this case. Please see the
member description for an example.
@throws IllegalArgumentException the month, dayOfWeekInMonth,
dayOfWeek, or time parameters are out of range
"""
if (isFrozen()) {
throw new UnsupportedOperationException("Attempt to modify a frozen SimpleTimeZone instance.");
}
getSTZInfo().setEnd(month, dayOfWeekInMonth, dayOfWeek, time, -1, false);
setEndRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME);
}
|
java
|
public void setEndRule(int month, int dayOfWeekInMonth, int dayOfWeek, int time) {
if (isFrozen()) {
throw new UnsupportedOperationException("Attempt to modify a frozen SimpleTimeZone instance.");
}
getSTZInfo().setEnd(month, dayOfWeekInMonth, dayOfWeek, time, -1, false);
setEndRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME);
}
|
[
"public",
"void",
"setEndRule",
"(",
"int",
"month",
",",
"int",
"dayOfWeekInMonth",
",",
"int",
"dayOfWeek",
",",
"int",
"time",
")",
"{",
"if",
"(",
"isFrozen",
"(",
")",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Attempt to modify a frozen SimpleTimeZone instance.\"",
")",
";",
"}",
"getSTZInfo",
"(",
")",
".",
"setEnd",
"(",
"month",
",",
"dayOfWeekInMonth",
",",
"dayOfWeek",
",",
"time",
",",
"-",
"1",
",",
"false",
")",
";",
"setEndRule",
"(",
"month",
",",
"dayOfWeekInMonth",
",",
"dayOfWeek",
",",
"time",
",",
"WALL_TIME",
")",
";",
"}"
] |
Sets the daylight savings ending rule. For example, if Daylight Savings Time
ends at the last (-1) Sunday in October, at 2 AM in standard time,
you can set the end rule by calling:
<code>setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2*60*60*1000);</code>
@param month The daylight savings ending month. Month is
0-based. eg, 0 for January.
@param dayOfWeekInMonth The daylight savings ending
day-of-week-in-month. Please see the member
description for an example.
@param dayOfWeek The daylight savings ending day-of-week. Please
see the member description for an example.
@param time The daylight savings ending time in local wall time,
which is daylight time in this case. Please see the
member description for an example.
@throws IllegalArgumentException the month, dayOfWeekInMonth,
dayOfWeek, or time parameters are out of range
|
[
"Sets",
"the",
"daylight",
"savings",
"ending",
"rule",
".",
"For",
"example",
"if",
"Daylight",
"Savings",
"Time",
"ends",
"at",
"the",
"last",
"(",
"-",
"1",
")",
"Sunday",
"in",
"October",
"at",
"2",
"AM",
"in",
"standard",
"time",
"you",
"can",
"set",
"the",
"end",
"rule",
"by",
"calling",
":",
"<code",
">",
"setEndRule",
"(",
"Calendar",
".",
"OCTOBER",
"-",
"1",
"Calendar",
".",
"SUNDAY",
"2",
"*",
"60",
"*",
"60",
"*",
"1000",
")",
";",
"<",
"/",
"code",
">"
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/SimpleTimeZone.java#L432-L439
|
fcrepo4-labs/fcrepo4-client
|
fcrepo-client-impl/src/main/java/org/fcrepo/client/utils/HttpHelper.java
|
HttpHelper.createMoveMethod
|
public HttpMove createMoveMethod(final String sourcePath, final String destinationPath) {
"""
Create MOVE method
@param sourcePath Source path, relative to repository baseURL
@param destinationPath Destination path, relative to repository baseURL
@return MOVE method
"""
return new HttpMove(repositoryURL + sourcePath, repositoryURL + destinationPath);
}
|
java
|
public HttpMove createMoveMethod(final String sourcePath, final String destinationPath) {
return new HttpMove(repositoryURL + sourcePath, repositoryURL + destinationPath);
}
|
[
"public",
"HttpMove",
"createMoveMethod",
"(",
"final",
"String",
"sourcePath",
",",
"final",
"String",
"destinationPath",
")",
"{",
"return",
"new",
"HttpMove",
"(",
"repositoryURL",
"+",
"sourcePath",
",",
"repositoryURL",
"+",
"destinationPath",
")",
";",
"}"
] |
Create MOVE method
@param sourcePath Source path, relative to repository baseURL
@param destinationPath Destination path, relative to repository baseURL
@return MOVE method
|
[
"Create",
"MOVE",
"method"
] |
train
|
https://github.com/fcrepo4-labs/fcrepo4-client/blob/21eaf27200c5b2542095f6ebb9dd8ec865b95bbd/fcrepo-client-impl/src/main/java/org/fcrepo/client/utils/HttpHelper.java#L411-L413
|
codeprimate-software/cp-elements
|
src/main/java/org/cp/elements/util/CollectionUtils.java
|
CollectionUtils.defaultIfEmpty
|
public static <E, T extends Iterable<E>> T defaultIfEmpty(T iterable, T defaultIterable) {
"""
Returns the given {@link Iterable} if not {@literal null} or empty, otherwise returns the {@code defaultIterable}.
@param <E> {@link Class} type of the elements in the {@link Iterable Iterables}.
@param <T> concrete {@link Class} type of the {@link Iterable}.
@param iterable {@link Iterable} to evaluate.
@param defaultIterable {@link Iterable} to return if the given {@code iterable} is {@literal null} or empty.
@return {@code iterable} if not {@literal null} or empty otherwise return {@code defaultIterable}.
@see java.lang.Iterable
"""
return iterable != null && iterable.iterator().hasNext() ? iterable : defaultIterable;
}
|
java
|
public static <E, T extends Iterable<E>> T defaultIfEmpty(T iterable, T defaultIterable) {
return iterable != null && iterable.iterator().hasNext() ? iterable : defaultIterable;
}
|
[
"public",
"static",
"<",
"E",
",",
"T",
"extends",
"Iterable",
"<",
"E",
">",
">",
"T",
"defaultIfEmpty",
"(",
"T",
"iterable",
",",
"T",
"defaultIterable",
")",
"{",
"return",
"iterable",
"!=",
"null",
"&&",
"iterable",
".",
"iterator",
"(",
")",
".",
"hasNext",
"(",
")",
"?",
"iterable",
":",
"defaultIterable",
";",
"}"
] |
Returns the given {@link Iterable} if not {@literal null} or empty, otherwise returns the {@code defaultIterable}.
@param <E> {@link Class} type of the elements in the {@link Iterable Iterables}.
@param <T> concrete {@link Class} type of the {@link Iterable}.
@param iterable {@link Iterable} to evaluate.
@param defaultIterable {@link Iterable} to return if the given {@code iterable} is {@literal null} or empty.
@return {@code iterable} if not {@literal null} or empty otherwise return {@code defaultIterable}.
@see java.lang.Iterable
|
[
"Returns",
"the",
"given",
"{",
"@link",
"Iterable",
"}",
"if",
"not",
"{",
"@literal",
"null",
"}",
"or",
"empty",
"otherwise",
"returns",
"the",
"{",
"@code",
"defaultIterable",
"}",
"."
] |
train
|
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/util/CollectionUtils.java#L315-L317
|
albfernandez/itext2
|
src/main/java/com/lowagie/text/pdf/PdfAction.java
|
PdfAction.createResetForm
|
public static PdfAction createResetForm(Object names[], int flags) {
"""
Creates a resetform.
@param names the objects to reset
@param flags submit properties
@return A PdfAction
"""
PdfAction action = new PdfAction();
action.put(PdfName.S, PdfName.RESETFORM);
if (names != null)
action.put(PdfName.FIELDS, buildArray(names));
action.put(PdfName.FLAGS, new PdfNumber(flags));
return action;
}
|
java
|
public static PdfAction createResetForm(Object names[], int flags) {
PdfAction action = new PdfAction();
action.put(PdfName.S, PdfName.RESETFORM);
if (names != null)
action.put(PdfName.FIELDS, buildArray(names));
action.put(PdfName.FLAGS, new PdfNumber(flags));
return action;
}
|
[
"public",
"static",
"PdfAction",
"createResetForm",
"(",
"Object",
"names",
"[",
"]",
",",
"int",
"flags",
")",
"{",
"PdfAction",
"action",
"=",
"new",
"PdfAction",
"(",
")",
";",
"action",
".",
"put",
"(",
"PdfName",
".",
"S",
",",
"PdfName",
".",
"RESETFORM",
")",
";",
"if",
"(",
"names",
"!=",
"null",
")",
"action",
".",
"put",
"(",
"PdfName",
".",
"FIELDS",
",",
"buildArray",
"(",
"names",
")",
")",
";",
"action",
".",
"put",
"(",
"PdfName",
".",
"FLAGS",
",",
"new",
"PdfNumber",
"(",
"flags",
")",
")",
";",
"return",
"action",
";",
"}"
] |
Creates a resetform.
@param names the objects to reset
@param flags submit properties
@return A PdfAction
|
[
"Creates",
"a",
"resetform",
"."
] |
train
|
https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/pdf/PdfAction.java#L411-L418
|
uber/NullAway
|
nullaway/src/main/java/com/uber/nullaway/dataflow/AccessPathNullnessPropagation.java
|
AccessPathNullnessPropagation.setNonnullIfAnalyzeable
|
private void setNonnullIfAnalyzeable(Updates updates, Node node) {
"""
If node represents a local, field access, or method call we can track, set it to be non-null in
the updates
"""
AccessPath ap = AccessPath.getAccessPathForNodeWithMapGet(node, types);
if (ap != null) {
updates.set(ap, NONNULL);
}
}
|
java
|
private void setNonnullIfAnalyzeable(Updates updates, Node node) {
AccessPath ap = AccessPath.getAccessPathForNodeWithMapGet(node, types);
if (ap != null) {
updates.set(ap, NONNULL);
}
}
|
[
"private",
"void",
"setNonnullIfAnalyzeable",
"(",
"Updates",
"updates",
",",
"Node",
"node",
")",
"{",
"AccessPath",
"ap",
"=",
"AccessPath",
".",
"getAccessPathForNodeWithMapGet",
"(",
"node",
",",
"types",
")",
";",
"if",
"(",
"ap",
"!=",
"null",
")",
"{",
"updates",
".",
"set",
"(",
"ap",
",",
"NONNULL",
")",
";",
"}",
"}"
] |
If node represents a local, field access, or method call we can track, set it to be non-null in
the updates
|
[
"If",
"node",
"represents",
"a",
"local",
"field",
"access",
"or",
"method",
"call",
"we",
"can",
"track",
"set",
"it",
"to",
"be",
"non",
"-",
"null",
"in",
"the",
"updates"
] |
train
|
https://github.com/uber/NullAway/blob/c3979b4241f80411dbba6aac3ff653acbb88d00b/nullaway/src/main/java/com/uber/nullaway/dataflow/AccessPathNullnessPropagation.java#L635-L640
|
cesarferreira/AndroidQuickUtils
|
library/src/main/java/quickutils/core/categories/share.java
|
share.genericSharing
|
public static void genericSharing(String subject, String message) {
"""
Generic method for sharing that Deliver some data to someone else. Who
the data is being delivered to is not specified; it is up to the receiver
of this action to ask the user where the data should be sent.
@param subject The title, if applied
@param message Message to be delivered
"""
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, message);
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
QuickUtils.getContext().startActivity(intent);
}
|
java
|
public static void genericSharing(String subject, String message) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, message);
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
QuickUtils.getContext().startActivity(intent);
}
|
[
"public",
"static",
"void",
"genericSharing",
"(",
"String",
"subject",
",",
"String",
"message",
")",
"{",
"Intent",
"intent",
"=",
"new",
"Intent",
"(",
"Intent",
".",
"ACTION_SEND",
")",
";",
"intent",
".",
"setType",
"(",
"\"text/plain\"",
")",
";",
"intent",
".",
"putExtra",
"(",
"Intent",
".",
"EXTRA_TEXT",
",",
"message",
")",
";",
"intent",
".",
"putExtra",
"(",
"Intent",
".",
"EXTRA_SUBJECT",
",",
"subject",
")",
";",
"intent",
".",
"setFlags",
"(",
"Intent",
".",
"FLAG_ACTIVITY_NEW_TASK",
")",
";",
"QuickUtils",
".",
"getContext",
"(",
")",
".",
"startActivity",
"(",
"intent",
")",
";",
"}"
] |
Generic method for sharing that Deliver some data to someone else. Who
the data is being delivered to is not specified; it is up to the receiver
of this action to ask the user where the data should be sent.
@param subject The title, if applied
@param message Message to be delivered
|
[
"Generic",
"method",
"for",
"sharing",
"that",
"Deliver",
"some",
"data",
"to",
"someone",
"else",
".",
"Who",
"the",
"data",
"is",
"being",
"delivered",
"to",
"is",
"not",
"specified",
";",
"it",
"is",
"up",
"to",
"the",
"receiver",
"of",
"this",
"action",
"to",
"ask",
"the",
"user",
"where",
"the",
"data",
"should",
"be",
"sent",
"."
] |
train
|
https://github.com/cesarferreira/AndroidQuickUtils/blob/73a91daedbb9f7be7986ea786fbc441c9e5a881c/library/src/main/java/quickutils/core/categories/share.java#L80-L87
|
atbashEE/atbash-config
|
impl/src/main/java/be/atbash/config/AbstractConfiguration.java
|
AbstractConfiguration.getOptionalValue
|
protected <T> T getOptionalValue(String propertyName, T defaultValue, Class<T> propertyType) {
"""
Reads the configuration property as an optional value, so it is not required to have a value for the key/propertyName, and
returns the <code>defaultValue</code> when the value isn't defined.
@param <T> the property type
@param propertyName The configuration propertyName.
@param propertyType The type into which the resolve property value should be converted
@return the resolved property value as an value of the requested type. (defaultValue when not found)
"""
T result = ConfigOptionalValue.getValue(propertyName, propertyType);
if (result == null) {
result = defaultValue;
}
return result;
}
|
java
|
protected <T> T getOptionalValue(String propertyName, T defaultValue, Class<T> propertyType) {
T result = ConfigOptionalValue.getValue(propertyName, propertyType);
if (result == null) {
result = defaultValue;
}
return result;
}
|
[
"protected",
"<",
"T",
">",
"T",
"getOptionalValue",
"(",
"String",
"propertyName",
",",
"T",
"defaultValue",
",",
"Class",
"<",
"T",
">",
"propertyType",
")",
"{",
"T",
"result",
"=",
"ConfigOptionalValue",
".",
"getValue",
"(",
"propertyName",
",",
"propertyType",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"result",
"=",
"defaultValue",
";",
"}",
"return",
"result",
";",
"}"
] |
Reads the configuration property as an optional value, so it is not required to have a value for the key/propertyName, and
returns the <code>defaultValue</code> when the value isn't defined.
@param <T> the property type
@param propertyName The configuration propertyName.
@param propertyType The type into which the resolve property value should be converted
@return the resolved property value as an value of the requested type. (defaultValue when not found)
|
[
"Reads",
"the",
"configuration",
"property",
"as",
"an",
"optional",
"value",
"so",
"it",
"is",
"not",
"required",
"to",
"have",
"a",
"value",
"for",
"the",
"key",
"/",
"propertyName",
"and",
"returns",
"the",
"<code",
">",
"defaultValue<",
"/",
"code",
">",
"when",
"the",
"value",
"isn",
"t",
"defined",
"."
] |
train
|
https://github.com/atbashEE/atbash-config/blob/80c06c6e535957514ffb51380948ecd351d5068c/impl/src/main/java/be/atbash/config/AbstractConfiguration.java#L36-L43
|
deeplearning4j/deeplearning4j
|
nd4j/nd4j-serde/nd4j-aeron/src/main/java/org/nd4j/aeron/ipc/AeronConnectionInformation.java
|
AeronConnectionInformation.of
|
public static AeronConnectionInformation of(String connectionHost, int connectionPort, int streamId) {
"""
Traditional static generator method
@param connectionHost
@param connectionPort
@param streamId
@return
"""
return AeronConnectionInformation.builder().connectionHost(connectionHost).connectionPort(connectionPort)
.streamId(streamId).build();
}
|
java
|
public static AeronConnectionInformation of(String connectionHost, int connectionPort, int streamId) {
return AeronConnectionInformation.builder().connectionHost(connectionHost).connectionPort(connectionPort)
.streamId(streamId).build();
}
|
[
"public",
"static",
"AeronConnectionInformation",
"of",
"(",
"String",
"connectionHost",
",",
"int",
"connectionPort",
",",
"int",
"streamId",
")",
"{",
"return",
"AeronConnectionInformation",
".",
"builder",
"(",
")",
".",
"connectionHost",
"(",
"connectionHost",
")",
".",
"connectionPort",
"(",
"connectionPort",
")",
".",
"streamId",
"(",
"streamId",
")",
".",
"build",
"(",
")",
";",
"}"
] |
Traditional static generator method
@param connectionHost
@param connectionPort
@param streamId
@return
|
[
"Traditional",
"static",
"generator",
"method"
] |
train
|
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-serde/nd4j-aeron/src/main/java/org/nd4j/aeron/ipc/AeronConnectionInformation.java#L44-L47
|
xwiki/xwiki-rendering
|
xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/WikiParameters.java
|
WikiParameters.addParameter
|
public WikiParameters addParameter(String key, String value) {
"""
Creates a new copy of this parameter object with new specified key/value
pair.
@param key the parameter name
@param value the value of the parameter
@return a new copy of parameters object with the given key/value pair
"""
WikiParameters result = new WikiParameters();
result.fList.addAll(fList);
result.fList.add(new WikiParameter(key, value));
return result;
}
|
java
|
public WikiParameters addParameter(String key, String value)
{
WikiParameters result = new WikiParameters();
result.fList.addAll(fList);
result.fList.add(new WikiParameter(key, value));
return result;
}
|
[
"public",
"WikiParameters",
"addParameter",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"WikiParameters",
"result",
"=",
"new",
"WikiParameters",
"(",
")",
";",
"result",
".",
"fList",
".",
"addAll",
"(",
"fList",
")",
";",
"result",
".",
"fList",
".",
"add",
"(",
"new",
"WikiParameter",
"(",
"key",
",",
"value",
")",
")",
";",
"return",
"result",
";",
"}"
] |
Creates a new copy of this parameter object with new specified key/value
pair.
@param key the parameter name
@param value the value of the parameter
@return a new copy of parameters object with the given key/value pair
|
[
"Creates",
"a",
"new",
"copy",
"of",
"this",
"parameter",
"object",
"with",
"new",
"specified",
"key",
"/",
"value",
"pair",
"."
] |
train
|
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/WikiParameters.java#L124-L130
|
windup/windup
|
forks/jdt/src/main/java/org/eclipse/jdt/internal/compiler/Compiler.java
|
Compiler.reportWorked
|
protected void reportWorked(int workIncrement, int currentUnitIndex) {
"""
Checks whether the compilation has been canceled and reports the given work increment to the compiler progress.
"""
if (this.progress != null) {
if (this.progress.isCanceled()) {
// Only AbortCompilation can stop the compiler cleanly.
// We check cancellation again following the call to compile.
throw new AbortCompilation(true, null);
}
this.progress.worked(workIncrement, (this.totalUnits* this.remainingIterations) - currentUnitIndex - 1);
}
}
|
java
|
protected void reportWorked(int workIncrement, int currentUnitIndex) {
if (this.progress != null) {
if (this.progress.isCanceled()) {
// Only AbortCompilation can stop the compiler cleanly.
// We check cancellation again following the call to compile.
throw new AbortCompilation(true, null);
}
this.progress.worked(workIncrement, (this.totalUnits* this.remainingIterations) - currentUnitIndex - 1);
}
}
|
[
"protected",
"void",
"reportWorked",
"(",
"int",
"workIncrement",
",",
"int",
"currentUnitIndex",
")",
"{",
"if",
"(",
"this",
".",
"progress",
"!=",
"null",
")",
"{",
"if",
"(",
"this",
".",
"progress",
".",
"isCanceled",
"(",
")",
")",
"{",
"// Only AbortCompilation can stop the compiler cleanly.",
"// We check cancellation again following the call to compile.",
"throw",
"new",
"AbortCompilation",
"(",
"true",
",",
"null",
")",
";",
"}",
"this",
".",
"progress",
".",
"worked",
"(",
"workIncrement",
",",
"(",
"this",
".",
"totalUnits",
"*",
"this",
".",
"remainingIterations",
")",
"-",
"currentUnitIndex",
"-",
"1",
")",
";",
"}",
"}"
] |
Checks whether the compilation has been canceled and reports the given work increment to the compiler progress.
|
[
"Checks",
"whether",
"the",
"compilation",
"has",
"been",
"canceled",
"and",
"reports",
"the",
"given",
"work",
"increment",
"to",
"the",
"compiler",
"progress",
"."
] |
train
|
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/forks/jdt/src/main/java/org/eclipse/jdt/internal/compiler/Compiler.java#L428-L437
|
esmasui/AndroidJUnit4
|
android-junit4/src/main/java/android/os/PerformanceCollector.java
|
PerformanceCollector.addMeasurement
|
public void addMeasurement(String label, String value) {
"""
Add a string field to the collector.
@param label short description of the metric that was measured
@param value string summary of the measurement
"""
if (mPerfWriter != null)
mPerfWriter.writeMeasurement(label, value);
}
|
java
|
public void addMeasurement(String label, String value) {
if (mPerfWriter != null)
mPerfWriter.writeMeasurement(label, value);
}
|
[
"public",
"void",
"addMeasurement",
"(",
"String",
"label",
",",
"String",
"value",
")",
"{",
"if",
"(",
"mPerfWriter",
"!=",
"null",
")",
"mPerfWriter",
".",
"writeMeasurement",
"(",
"label",
",",
"value",
")",
";",
"}"
] |
Add a string field to the collector.
@param label short description of the metric that was measured
@param value string summary of the measurement
|
[
"Add",
"a",
"string",
"field",
"to",
"the",
"collector",
"."
] |
train
|
https://github.com/esmasui/AndroidJUnit4/blob/173b050663844f81ca9da6c9076dd13e1bde6a75/android-junit4/src/main/java/android/os/PerformanceCollector.java#L446-L449
|
GoogleCloudPlatform/appengine-gcs-client
|
java/src/main/java/com/google/appengine/tools/cloudstorage/oauth/OauthRawGcsService.java
|
OauthRawGcsService.handlePutResponse
|
GcsRestCreationToken handlePutResponse(final GcsRestCreationToken token,
final boolean isFinalChunk,
final int length,
final HTTPRequestInfo reqInfo,
HTTPResponse resp) throws Error, IOException {
"""
Given a HTTPResponce, process it, throwing an error if needed and return a Token for the next
request.
"""
switch (resp.getResponseCode()) {
case 200:
if (!isFinalChunk) {
throw new RuntimeException("Unexpected response code 200 on non-final chunk. Request: \n"
+ URLFetchUtils.describeRequestAndResponse(reqInfo, resp));
} else {
return null;
}
case 308:
if (isFinalChunk) {
throw new RuntimeException("Unexpected response code 308 on final chunk: "
+ URLFetchUtils.describeRequestAndResponse(reqInfo, resp));
} else {
return new GcsRestCreationToken(token.filename, token.uploadId, token.offset + length);
}
default:
throw HttpErrorHandler.error(resp.getResponseCode(),
URLFetchUtils.describeRequestAndResponse(reqInfo, resp));
}
}
|
java
|
GcsRestCreationToken handlePutResponse(final GcsRestCreationToken token,
final boolean isFinalChunk,
final int length,
final HTTPRequestInfo reqInfo,
HTTPResponse resp) throws Error, IOException {
switch (resp.getResponseCode()) {
case 200:
if (!isFinalChunk) {
throw new RuntimeException("Unexpected response code 200 on non-final chunk. Request: \n"
+ URLFetchUtils.describeRequestAndResponse(reqInfo, resp));
} else {
return null;
}
case 308:
if (isFinalChunk) {
throw new RuntimeException("Unexpected response code 308 on final chunk: "
+ URLFetchUtils.describeRequestAndResponse(reqInfo, resp));
} else {
return new GcsRestCreationToken(token.filename, token.uploadId, token.offset + length);
}
default:
throw HttpErrorHandler.error(resp.getResponseCode(),
URLFetchUtils.describeRequestAndResponse(reqInfo, resp));
}
}
|
[
"GcsRestCreationToken",
"handlePutResponse",
"(",
"final",
"GcsRestCreationToken",
"token",
",",
"final",
"boolean",
"isFinalChunk",
",",
"final",
"int",
"length",
",",
"final",
"HTTPRequestInfo",
"reqInfo",
",",
"HTTPResponse",
"resp",
")",
"throws",
"Error",
",",
"IOException",
"{",
"switch",
"(",
"resp",
".",
"getResponseCode",
"(",
")",
")",
"{",
"case",
"200",
":",
"if",
"(",
"!",
"isFinalChunk",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unexpected response code 200 on non-final chunk. Request: \\n\"",
"+",
"URLFetchUtils",
".",
"describeRequestAndResponse",
"(",
"reqInfo",
",",
"resp",
")",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"case",
"308",
":",
"if",
"(",
"isFinalChunk",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unexpected response code 308 on final chunk: \"",
"+",
"URLFetchUtils",
".",
"describeRequestAndResponse",
"(",
"reqInfo",
",",
"resp",
")",
")",
";",
"}",
"else",
"{",
"return",
"new",
"GcsRestCreationToken",
"(",
"token",
".",
"filename",
",",
"token",
".",
"uploadId",
",",
"token",
".",
"offset",
"+",
"length",
")",
";",
"}",
"default",
":",
"throw",
"HttpErrorHandler",
".",
"error",
"(",
"resp",
".",
"getResponseCode",
"(",
")",
",",
"URLFetchUtils",
".",
"describeRequestAndResponse",
"(",
"reqInfo",
",",
"resp",
")",
")",
";",
"}",
"}"
] |
Given a HTTPResponce, process it, throwing an error if needed and return a Token for the next
request.
|
[
"Given",
"a",
"HTTPResponce",
"process",
"it",
"throwing",
"an",
"error",
"if",
"needed",
"and",
"return",
"a",
"Token",
"for",
"the",
"next",
"request",
"."
] |
train
|
https://github.com/GoogleCloudPlatform/appengine-gcs-client/blob/d11078331ecd915d753c886e96a80133599f3f98/java/src/main/java/com/google/appengine/tools/cloudstorage/oauth/OauthRawGcsService.java#L375-L399
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.