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
|
---|---|---|---|---|---|---|---|---|---|---|
op4j/op4j
|
src/main/java/org/op4j/functions/FnString.java
|
FnString.toCalendar
|
public static final Function<String,Calendar> toCalendar(final String pattern, final Locale locale) {
"""
<p>
Converts the target String to a <tt>java.util.Calendar</tt> by applying the specified
pattern and locale. The locale is needed for correctly parsing month names.
</p>
<p>
Pattern format is that of <tt>java.text.SimpleDateFormat</tt>.
</p>
@param pattern the pattern to be used.
@param locale the locale which will be used for parsing month names
@return the resulting Calendar
"""
return new ToCalendar(pattern, locale);
}
|
java
|
public static final Function<String,Calendar> toCalendar(final String pattern, final Locale locale) {
return new ToCalendar(pattern, locale);
}
|
[
"public",
"static",
"final",
"Function",
"<",
"String",
",",
"Calendar",
">",
"toCalendar",
"(",
"final",
"String",
"pattern",
",",
"final",
"Locale",
"locale",
")",
"{",
"return",
"new",
"ToCalendar",
"(",
"pattern",
",",
"locale",
")",
";",
"}"
] |
<p>
Converts the target String to a <tt>java.util.Calendar</tt> by applying the specified
pattern and locale. The locale is needed for correctly parsing month names.
</p>
<p>
Pattern format is that of <tt>java.text.SimpleDateFormat</tt>.
</p>
@param pattern the pattern to be used.
@param locale the locale which will be used for parsing month names
@return the resulting Calendar
|
[
"<p",
">",
"Converts",
"the",
"target",
"String",
"to",
"a",
"<tt",
">",
"java",
".",
"util",
".",
"Calendar<",
"/",
"tt",
">",
"by",
"applying",
"the",
"specified",
"pattern",
"and",
"locale",
".",
"The",
"locale",
"is",
"needed",
"for",
"correctly",
"parsing",
"month",
"names",
".",
"<",
"/",
"p",
">",
"<p",
">",
"Pattern",
"format",
"is",
"that",
"of",
"<tt",
">",
"java",
".",
"text",
".",
"SimpleDateFormat<",
"/",
"tt",
">",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/op4j/op4j/blob/b577596dfe462089d3dd169666defc6de7ad289a/src/main/java/org/op4j/functions/FnString.java#L1680-L1682
|
ppicas/custom-typeface
|
library/src/main/java/cat/ppicas/customtypeface/CustomTypefaceSpan.java
|
CustomTypefaceSpan.createText
|
public static CharSequence createText(CharSequence charSequence, Typeface typeface) {
"""
Creates a new {@link Spanned} {@link CharSequence} that has applied
{@link CustomTypefaceSpan} along the whole string.
@param charSequence a {@code CharSequence} containing the text that you want stylize
@param typeface the {@code Typeface} that you want to be applied on the text
@return a new {@code CharSequence} with the {@code CustomTypefaceSpan} applied from the
beginning to the end
@see Spannable#setSpan
"""
Spannable spannable = new SpannableString(charSequence);
spannable.setSpan(getInstance(typeface), 0, spannable.length(),
Spanned.SPAN_INCLUSIVE_INCLUSIVE);
return spannable;
}
|
java
|
public static CharSequence createText(CharSequence charSequence, Typeface typeface) {
Spannable spannable = new SpannableString(charSequence);
spannable.setSpan(getInstance(typeface), 0, spannable.length(),
Spanned.SPAN_INCLUSIVE_INCLUSIVE);
return spannable;
}
|
[
"public",
"static",
"CharSequence",
"createText",
"(",
"CharSequence",
"charSequence",
",",
"Typeface",
"typeface",
")",
"{",
"Spannable",
"spannable",
"=",
"new",
"SpannableString",
"(",
"charSequence",
")",
";",
"spannable",
".",
"setSpan",
"(",
"getInstance",
"(",
"typeface",
")",
",",
"0",
",",
"spannable",
".",
"length",
"(",
")",
",",
"Spanned",
".",
"SPAN_INCLUSIVE_INCLUSIVE",
")",
";",
"return",
"spannable",
";",
"}"
] |
Creates a new {@link Spanned} {@link CharSequence} that has applied
{@link CustomTypefaceSpan} along the whole string.
@param charSequence a {@code CharSequence} containing the text that you want stylize
@param typeface the {@code Typeface} that you want to be applied on the text
@return a new {@code CharSequence} with the {@code CustomTypefaceSpan} applied from the
beginning to the end
@see Spannable#setSpan
|
[
"Creates",
"a",
"new",
"{",
"@link",
"Spanned",
"}",
"{",
"@link",
"CharSequence",
"}",
"that",
"has",
"applied",
"{",
"@link",
"CustomTypefaceSpan",
"}",
"along",
"the",
"whole",
"string",
"."
] |
train
|
https://github.com/ppicas/custom-typeface/blob/3a2a68cc8584a72076c545a8b7c9f741f6002241/library/src/main/java/cat/ppicas/customtypeface/CustomTypefaceSpan.java#L70-L75
|
wcm-io-caravan/caravan-hal
|
resource/src/main/java/io/wcm/caravan/hal/resource/HalResource.java
|
HalResource.addEmbedded
|
public HalResource addEmbedded(String relation, HalResource... resources) {
"""
Embed resources for the given relation
@param relation Embedded resource relation
@param resources Resources to embed
@return HAL resource
"""
return addResources(HalResourceType.EMBEDDED, relation, true, resources);
}
|
java
|
public HalResource addEmbedded(String relation, HalResource... resources) {
return addResources(HalResourceType.EMBEDDED, relation, true, resources);
}
|
[
"public",
"HalResource",
"addEmbedded",
"(",
"String",
"relation",
",",
"HalResource",
"...",
"resources",
")",
"{",
"return",
"addResources",
"(",
"HalResourceType",
".",
"EMBEDDED",
",",
"relation",
",",
"true",
",",
"resources",
")",
";",
"}"
] |
Embed resources for the given relation
@param relation Embedded resource relation
@param resources Resources to embed
@return HAL resource
|
[
"Embed",
"resources",
"for",
"the",
"given",
"relation"
] |
train
|
https://github.com/wcm-io-caravan/caravan-hal/blob/25d58756b58c70c8c48a17fe781e673dd93d5085/resource/src/main/java/io/wcm/caravan/hal/resource/HalResource.java#L352-L354
|
jbundle/jbundle
|
base/screen/model/src/main/java/org/jbundle/base/screen/model/report/parser/XMLParser.java
|
XMLParser.getTagData
|
public String getTagData(String strData, String strTag) {
"""
Find the data between these XML tags.
@param strData The XML code to find the tags in.
@param strTag The tag to find.
"""
int iStartData = strData.indexOf('<' + strTag + '>');
if (iStartData == -1)
return null;
iStartData = iStartData + strTag.length() + 2;
int iEndData = strData.indexOf("</" + strTag + '>');
if (iStartData == -1)
return null;
return strData.substring(iStartData, iEndData);
}
|
java
|
public String getTagData(String strData, String strTag)
{
int iStartData = strData.indexOf('<' + strTag + '>');
if (iStartData == -1)
return null;
iStartData = iStartData + strTag.length() + 2;
int iEndData = strData.indexOf("</" + strTag + '>');
if (iStartData == -1)
return null;
return strData.substring(iStartData, iEndData);
}
|
[
"public",
"String",
"getTagData",
"(",
"String",
"strData",
",",
"String",
"strTag",
")",
"{",
"int",
"iStartData",
"=",
"strData",
".",
"indexOf",
"(",
"'",
"'",
"+",
"strTag",
"+",
"'",
"'",
")",
";",
"if",
"(",
"iStartData",
"==",
"-",
"1",
")",
"return",
"null",
";",
"iStartData",
"=",
"iStartData",
"+",
"strTag",
".",
"length",
"(",
")",
"+",
"2",
";",
"int",
"iEndData",
"=",
"strData",
".",
"indexOf",
"(",
"\"</\"",
"+",
"strTag",
"+",
"'",
"'",
")",
";",
"if",
"(",
"iStartData",
"==",
"-",
"1",
")",
"return",
"null",
";",
"return",
"strData",
".",
"substring",
"(",
"iStartData",
",",
"iEndData",
")",
";",
"}"
] |
Find the data between these XML tags.
@param strData The XML code to find the tags in.
@param strTag The tag to find.
|
[
"Find",
"the",
"data",
"between",
"these",
"XML",
"tags",
"."
] |
train
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/model/src/main/java/org/jbundle/base/screen/model/report/parser/XMLParser.java#L81-L91
|
metafacture/metafacture-core
|
metafacture-biblio/src/main/java/org/metafacture/biblio/iso2709/Iso646ByteBuffer.java
|
Iso646ByteBuffer.distanceTo
|
int distanceTo(final byte[] bytes, final int fromIndex) {
"""
Returns the distance from {@code fromIndex} to the next occurrence of one
of the bytes in {@code bytes}. If the byte at {@code fromIndex} is in
{@code bytes} zero is returned. If there are no matching bytes between
{@code fromIndex} and the end of the buffer then the distance to the
end of the buffer is returned.
@param bytes bytes to search for.
@param fromIndex the position in the buffer from which to start searching.
@return the distance in bytes to the next byte with the given value or if
none is found to the end of the buffer.
"""
assert 0 <= fromIndex && fromIndex < byteArray.length;
int index = fromIndex;
for (; index < byteArray.length; ++index) {
if (containsByte(bytes, byteArray[index])) {
break;
}
}
return index - fromIndex;
}
|
java
|
int distanceTo(final byte[] bytes, final int fromIndex) {
assert 0 <= fromIndex && fromIndex < byteArray.length;
int index = fromIndex;
for (; index < byteArray.length; ++index) {
if (containsByte(bytes, byteArray[index])) {
break;
}
}
return index - fromIndex;
}
|
[
"int",
"distanceTo",
"(",
"final",
"byte",
"[",
"]",
"bytes",
",",
"final",
"int",
"fromIndex",
")",
"{",
"assert",
"0",
"<=",
"fromIndex",
"&&",
"fromIndex",
"<",
"byteArray",
".",
"length",
";",
"int",
"index",
"=",
"fromIndex",
";",
"for",
"(",
";",
"index",
"<",
"byteArray",
".",
"length",
";",
"++",
"index",
")",
"{",
"if",
"(",
"containsByte",
"(",
"bytes",
",",
"byteArray",
"[",
"index",
"]",
")",
")",
"{",
"break",
";",
"}",
"}",
"return",
"index",
"-",
"fromIndex",
";",
"}"
] |
Returns the distance from {@code fromIndex} to the next occurrence of one
of the bytes in {@code bytes}. If the byte at {@code fromIndex} is in
{@code bytes} zero is returned. If there are no matching bytes between
{@code fromIndex} and the end of the buffer then the distance to the
end of the buffer is returned.
@param bytes bytes to search for.
@param fromIndex the position in the buffer from which to start searching.
@return the distance in bytes to the next byte with the given value or if
none is found to the end of the buffer.
|
[
"Returns",
"the",
"distance",
"from",
"{",
"@code",
"fromIndex",
"}",
"to",
"the",
"next",
"occurrence",
"of",
"one",
"of",
"the",
"bytes",
"in",
"{",
"@code",
"bytes",
"}",
".",
"If",
"the",
"byte",
"at",
"{",
"@code",
"fromIndex",
"}",
"is",
"in",
"{",
"@code",
"bytes",
"}",
"zero",
"is",
"returned",
".",
"If",
"there",
"are",
"no",
"matching",
"bytes",
"between",
"{",
"@code",
"fromIndex",
"}",
"and",
"the",
"end",
"of",
"the",
"buffer",
"then",
"the",
"distance",
"to",
"the",
"end",
"of",
"the",
"buffer",
"is",
"returned",
"."
] |
train
|
https://github.com/metafacture/metafacture-core/blob/cb43933ec8eb01a4ddce4019c14b2415cc441918/metafacture-biblio/src/main/java/org/metafacture/biblio/iso2709/Iso646ByteBuffer.java#L105-L114
|
boncey/Flickr4Java
|
src/main/java/com/flickr4java/flickr/util/UrlUtilities.java
|
UrlUtilities.buildPostUrl
|
public static URL buildPostUrl(String host, int port, String path) throws MalformedURLException {
"""
Build a POST URL with {@code http} scheme.
@param host the host
@param port the port
@param path the path
@return
@throws MalformedURLException
"""
return buildPostUrl("http", host, port, path);
}
|
java
|
public static URL buildPostUrl(String host, int port, String path) throws MalformedURLException {
return buildPostUrl("http", host, port, path);
}
|
[
"public",
"static",
"URL",
"buildPostUrl",
"(",
"String",
"host",
",",
"int",
"port",
",",
"String",
"path",
")",
"throws",
"MalformedURLException",
"{",
"return",
"buildPostUrl",
"(",
"\"http\"",
",",
"host",
",",
"port",
",",
"path",
")",
";",
"}"
] |
Build a POST URL with {@code http} scheme.
@param host the host
@param port the port
@param path the path
@return
@throws MalformedURLException
|
[
"Build",
"a",
"POST",
"URL",
"with",
"{"
] |
train
|
https://github.com/boncey/Flickr4Java/blob/f66987ba0e360e5fb7730efbbb8c51f3d978fc25/src/main/java/com/flickr4java/flickr/util/UrlUtilities.java#L150-L152
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.microprofile.config.1.3/src/com/ibm/ws/microprofile/config13/sources/OSGiConfigUtils.java
|
OSGiConfigUtils.getService
|
public static <T> T getService(BundleContext bundleContext, Class<T> serviceClass) {
"""
Find a service of the given type
@param bundleContext The context to use to find the service
@param serviceClass The class of the required service
@return the service instance or null
"""
T service = null;
if (FrameworkState.isValid()) {
ServiceReference<T> ref = bundleContext.getServiceReference(serviceClass);
if (ref != null) {
service = bundleContext.getService(ref);
}
}
return service;
}
|
java
|
public static <T> T getService(BundleContext bundleContext, Class<T> serviceClass) {
T service = null;
if (FrameworkState.isValid()) {
ServiceReference<T> ref = bundleContext.getServiceReference(serviceClass);
if (ref != null) {
service = bundleContext.getService(ref);
}
}
return service;
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"getService",
"(",
"BundleContext",
"bundleContext",
",",
"Class",
"<",
"T",
">",
"serviceClass",
")",
"{",
"T",
"service",
"=",
"null",
";",
"if",
"(",
"FrameworkState",
".",
"isValid",
"(",
")",
")",
"{",
"ServiceReference",
"<",
"T",
">",
"ref",
"=",
"bundleContext",
".",
"getServiceReference",
"(",
"serviceClass",
")",
";",
"if",
"(",
"ref",
"!=",
"null",
")",
"{",
"service",
"=",
"bundleContext",
".",
"getService",
"(",
"ref",
")",
";",
"}",
"}",
"return",
"service",
";",
"}"
] |
Find a service of the given type
@param bundleContext The context to use to find the service
@param serviceClass The class of the required service
@return the service instance or null
|
[
"Find",
"a",
"service",
"of",
"the",
"given",
"type"
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.microprofile.config.1.3/src/com/ibm/ws/microprofile/config13/sources/OSGiConfigUtils.java#L143-L153
|
DataSketches/sketches-core
|
src/main/java/com/yahoo/sketches/hash/MurmurHash3Adaptor.java
|
MurmurHash3Adaptor.asInt
|
public static int asInt(final long[] data, final int n) {
"""
Returns a deterministic uniform random integer between zero (inclusive) and
n (exclusive) given the input data.
@param data the input long array.
@param n The upper exclusive bound of the integers produced. Must be > 1.
@return deterministic uniform random integer
"""
if ((data == null) || (data.length == 0)) {
throw new SketchesArgumentException("Input is null or empty.");
}
return asInteger(data, n); //data is long[]
}
|
java
|
public static int asInt(final long[] data, final int n) {
if ((data == null) || (data.length == 0)) {
throw new SketchesArgumentException("Input is null or empty.");
}
return asInteger(data, n); //data is long[]
}
|
[
"public",
"static",
"int",
"asInt",
"(",
"final",
"long",
"[",
"]",
"data",
",",
"final",
"int",
"n",
")",
"{",
"if",
"(",
"(",
"data",
"==",
"null",
")",
"||",
"(",
"data",
".",
"length",
"==",
"0",
")",
")",
"{",
"throw",
"new",
"SketchesArgumentException",
"(",
"\"Input is null or empty.\"",
")",
";",
"}",
"return",
"asInteger",
"(",
"data",
",",
"n",
")",
";",
"//data is long[]",
"}"
] |
Returns a deterministic uniform random integer between zero (inclusive) and
n (exclusive) given the input data.
@param data the input long array.
@param n The upper exclusive bound of the integers produced. Must be > 1.
@return deterministic uniform random integer
|
[
"Returns",
"a",
"deterministic",
"uniform",
"random",
"integer",
"between",
"zero",
"(",
"inclusive",
")",
"and",
"n",
"(",
"exclusive",
")",
"given",
"the",
"input",
"data",
"."
] |
train
|
https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/hash/MurmurHash3Adaptor.java#L238-L243
|
lessthanoptimal/ejml
|
main/ejml-ddense/src/org/ejml/dense/row/CommonOps_DDRM.java
|
CommonOps_DDRM.elementPower
|
public static void elementPower(double a , DMatrixD1 B , DMatrixD1 C ) {
"""
<p>
Element-wise power operation <br>
c<sub>ij</sub> = a ^ b<sub>ij</sub>
<p>
@param a left scalar
@param B right side
@param C output (modified)
"""
if( B.numRows != C.numRows || B.numCols != C.numCols ) {
throw new MatrixDimensionException("All matrices must be the same shape");
}
int size = B.getNumElements();
for( int i = 0; i < size; i++ ) {
C.data[i] = Math.pow(a, B.data[i]);
}
}
|
java
|
public static void elementPower(double a , DMatrixD1 B , DMatrixD1 C ) {
if( B.numRows != C.numRows || B.numCols != C.numCols ) {
throw new MatrixDimensionException("All matrices must be the same shape");
}
int size = B.getNumElements();
for( int i = 0; i < size; i++ ) {
C.data[i] = Math.pow(a, B.data[i]);
}
}
|
[
"public",
"static",
"void",
"elementPower",
"(",
"double",
"a",
",",
"DMatrixD1",
"B",
",",
"DMatrixD1",
"C",
")",
"{",
"if",
"(",
"B",
".",
"numRows",
"!=",
"C",
".",
"numRows",
"||",
"B",
".",
"numCols",
"!=",
"C",
".",
"numCols",
")",
"{",
"throw",
"new",
"MatrixDimensionException",
"(",
"\"All matrices must be the same shape\"",
")",
";",
"}",
"int",
"size",
"=",
"B",
".",
"getNumElements",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"C",
".",
"data",
"[",
"i",
"]",
"=",
"Math",
".",
"pow",
"(",
"a",
",",
"B",
".",
"data",
"[",
"i",
"]",
")",
";",
"}",
"}"
] |
<p>
Element-wise power operation <br>
c<sub>ij</sub> = a ^ b<sub>ij</sub>
<p>
@param a left scalar
@param B right side
@param C output (modified)
|
[
"<p",
">",
"Element",
"-",
"wise",
"power",
"operation",
"<br",
">",
"c<sub",
">",
"ij<",
"/",
"sub",
">",
"=",
"a",
"^",
"b<sub",
">",
"ij<",
"/",
"sub",
">",
"<p",
">"
] |
train
|
https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/CommonOps_DDRM.java#L1664-L1674
|
oboehm/jfachwert
|
src/main/java/de/jfachwert/bank/Geldbetrag.java
|
Geldbetrag.divideAndRemainder
|
@Override
public Geldbetrag[] divideAndRemainder(double divisor) {
"""
Liefert ein zwei-elementiges {@code Geldbatrag}-Array mit dem Ergebnis
{@code divideToIntegralValue} und{@code remainder}.
@param divisor Teiler
@return ein zwei-elementiges {@code Geldbatrag}-Array
@throws ArithmeticException bei {@code divisor==0}
@see #divideToIntegralValue(double)
@see #remainder(double)
"""
if (isInfinite(divisor)) {
return toGeldbetragArray(BigDecimal.ZERO, BigDecimal.ZERO);
}
return divideAndRemainder(BigDecimal.valueOf(divisor));
}
|
java
|
@Override
public Geldbetrag[] divideAndRemainder(double divisor) {
if (isInfinite(divisor)) {
return toGeldbetragArray(BigDecimal.ZERO, BigDecimal.ZERO);
}
return divideAndRemainder(BigDecimal.valueOf(divisor));
}
|
[
"@",
"Override",
"public",
"Geldbetrag",
"[",
"]",
"divideAndRemainder",
"(",
"double",
"divisor",
")",
"{",
"if",
"(",
"isInfinite",
"(",
"divisor",
")",
")",
"{",
"return",
"toGeldbetragArray",
"(",
"BigDecimal",
".",
"ZERO",
",",
"BigDecimal",
".",
"ZERO",
")",
";",
"}",
"return",
"divideAndRemainder",
"(",
"BigDecimal",
".",
"valueOf",
"(",
"divisor",
")",
")",
";",
"}"
] |
Liefert ein zwei-elementiges {@code Geldbatrag}-Array mit dem Ergebnis
{@code divideToIntegralValue} und{@code remainder}.
@param divisor Teiler
@return ein zwei-elementiges {@code Geldbatrag}-Array
@throws ArithmeticException bei {@code divisor==0}
@see #divideToIntegralValue(double)
@see #remainder(double)
|
[
"Liefert",
"ein",
"zwei",
"-",
"elementiges",
"{",
"@code",
"Geldbatrag",
"}",
"-",
"Array",
"mit",
"dem",
"Ergebnis",
"{",
"@code",
"divideToIntegralValue",
"}",
"und",
"{",
"@code",
"remainder",
"}",
"."
] |
train
|
https://github.com/oboehm/jfachwert/blob/67b513d29e3114c7aee65cd1ea7a5b7e540b0d1b/src/main/java/de/jfachwert/bank/Geldbetrag.java#L973-L979
|
Netflix/ndbench
|
ndbench-dyno-plugins/src/main/java/com/netflix/ndbench/plugin/dyno/DynoJedisUtils.java
|
DynoJedisUtils.pipelineReadHGETALL
|
public String pipelineReadHGETALL(String key, String hm_key_prefix) throws Exception {
"""
This the pipelined HGETALL
@param key
@return the contents of the hash
@throws Exception
"""
DynoJedisPipeline pipeline = jedisClient.get().pipelined();
Response<Map<byte[], byte[]>> resp = pipeline.hgetAll((hm_key_prefix + key).getBytes());
pipeline.sync();
if (resp == null || resp.get() == null) {
logger.info("Cache Miss: key:" + key);
return null;
} else {
StringBuilder sb = new StringBuilder();
for (byte[] bytes : resp.get().keySet()) {
if (sb.length() > 0) {
sb.append(",");
}
sb.append(new String(bytes));
}
return "HGETALL:" + sb.toString();
}
}
|
java
|
public String pipelineReadHGETALL(String key, String hm_key_prefix) throws Exception {
DynoJedisPipeline pipeline = jedisClient.get().pipelined();
Response<Map<byte[], byte[]>> resp = pipeline.hgetAll((hm_key_prefix + key).getBytes());
pipeline.sync();
if (resp == null || resp.get() == null) {
logger.info("Cache Miss: key:" + key);
return null;
} else {
StringBuilder sb = new StringBuilder();
for (byte[] bytes : resp.get().keySet()) {
if (sb.length() > 0) {
sb.append(",");
}
sb.append(new String(bytes));
}
return "HGETALL:" + sb.toString();
}
}
|
[
"public",
"String",
"pipelineReadHGETALL",
"(",
"String",
"key",
",",
"String",
"hm_key_prefix",
")",
"throws",
"Exception",
"{",
"DynoJedisPipeline",
"pipeline",
"=",
"jedisClient",
".",
"get",
"(",
")",
".",
"pipelined",
"(",
")",
";",
"Response",
"<",
"Map",
"<",
"byte",
"[",
"]",
",",
"byte",
"[",
"]",
">",
">",
"resp",
"=",
"pipeline",
".",
"hgetAll",
"(",
"(",
"hm_key_prefix",
"+",
"key",
")",
".",
"getBytes",
"(",
")",
")",
";",
"pipeline",
".",
"sync",
"(",
")",
";",
"if",
"(",
"resp",
"==",
"null",
"||",
"resp",
".",
"get",
"(",
")",
"==",
"null",
")",
"{",
"logger",
".",
"info",
"(",
"\"Cache Miss: key:\"",
"+",
"key",
")",
";",
"return",
"null",
";",
"}",
"else",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"byte",
"[",
"]",
"bytes",
":",
"resp",
".",
"get",
"(",
")",
".",
"keySet",
"(",
")",
")",
"{",
"if",
"(",
"sb",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"sb",
".",
"append",
"(",
"\",\"",
")",
";",
"}",
"sb",
".",
"append",
"(",
"new",
"String",
"(",
"bytes",
")",
")",
";",
"}",
"return",
"\"HGETALL:\"",
"+",
"sb",
".",
"toString",
"(",
")",
";",
"}",
"}"
] |
This the pipelined HGETALL
@param key
@return the contents of the hash
@throws Exception
|
[
"This",
"the",
"pipelined",
"HGETALL"
] |
train
|
https://github.com/Netflix/ndbench/blob/8d664244b5f9d01395248a296b86a3c822e6d764/ndbench-dyno-plugins/src/main/java/com/netflix/ndbench/plugin/dyno/DynoJedisUtils.java#L119-L136
|
Azure/azure-sdk-for-java
|
mixedreality/resource-manager/v2019_02_28_preview/src/main/java/com/microsoft/azure/management/mixedreality/v2019_02_28_preview/implementation/SpatialAnchorsAccountsInner.java
|
SpatialAnchorsAccountsInner.createAsync
|
public Observable<SpatialAnchorsAccountInner> createAsync(String resourceGroupName, String spatialAnchorsAccountName, SpatialAnchorsAccountInner spatialAnchorsAccount) {
"""
Creating or Updating a Spatial Anchors Account.
@param resourceGroupName Name of an Azure resource group.
@param spatialAnchorsAccountName Name of an Mixed Reality Spatial Anchors Account.
@param spatialAnchorsAccount Spatial Anchors Account parameter.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the SpatialAnchorsAccountInner object
"""
return createWithServiceResponseAsync(resourceGroupName, spatialAnchorsAccountName, spatialAnchorsAccount).map(new Func1<ServiceResponse<SpatialAnchorsAccountInner>, SpatialAnchorsAccountInner>() {
@Override
public SpatialAnchorsAccountInner call(ServiceResponse<SpatialAnchorsAccountInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<SpatialAnchorsAccountInner> createAsync(String resourceGroupName, String spatialAnchorsAccountName, SpatialAnchorsAccountInner spatialAnchorsAccount) {
return createWithServiceResponseAsync(resourceGroupName, spatialAnchorsAccountName, spatialAnchorsAccount).map(new Func1<ServiceResponse<SpatialAnchorsAccountInner>, SpatialAnchorsAccountInner>() {
@Override
public SpatialAnchorsAccountInner call(ServiceResponse<SpatialAnchorsAccountInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"SpatialAnchorsAccountInner",
">",
"createAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"spatialAnchorsAccountName",
",",
"SpatialAnchorsAccountInner",
"spatialAnchorsAccount",
")",
"{",
"return",
"createWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"spatialAnchorsAccountName",
",",
"spatialAnchorsAccount",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"SpatialAnchorsAccountInner",
">",
",",
"SpatialAnchorsAccountInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"SpatialAnchorsAccountInner",
"call",
"(",
"ServiceResponse",
"<",
"SpatialAnchorsAccountInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Creating or Updating a Spatial Anchors Account.
@param resourceGroupName Name of an Azure resource group.
@param spatialAnchorsAccountName Name of an Mixed Reality Spatial Anchors Account.
@param spatialAnchorsAccount Spatial Anchors Account parameter.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the SpatialAnchorsAccountInner object
|
[
"Creating",
"or",
"Updating",
"a",
"Spatial",
"Anchors",
"Account",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/mixedreality/resource-manager/v2019_02_28_preview/src/main/java/com/microsoft/azure/management/mixedreality/v2019_02_28_preview/implementation/SpatialAnchorsAccountsInner.java#L638-L645
|
overturetool/overture
|
core/interpreter/src/main/java/org/overture/interpreter/commands/CommandReader.java
|
CommandReader.setBreakpoint
|
private void setBreakpoint(String name, String condition) throws Exception {
"""
Set a breakpoint at the given function or operation name with a condition.
@param name
The function or operation name.
@param condition
Any condition for the breakpoint, or null.
@throws Exception
Problems parsing condition.
"""
LexTokenReader ltr = new LexTokenReader(name, Dialect.VDM_SL);
LexToken token = ltr.nextToken();
ltr.close();
Value v = null;
if (token.is(VDMToken.IDENTIFIER))
{
LexIdentifierToken id = (LexIdentifierToken) token;
LexNameToken lnt = new LexNameToken(interpreter.getDefaultName(), id);
v = interpreter.findGlobal(lnt);
} else if (token.is(VDMToken.NAME))
{
v = interpreter.findGlobal((LexNameToken) token);
}
if (v instanceof FunctionValue)
{
FunctionValue fv = (FunctionValue) v;
PExp exp = fv.body;
interpreter.clearBreakpoint(BreakpointManager.getBreakpoint(exp).number);
Breakpoint bp = interpreter.setBreakpoint(exp, condition);
println("Created " + bp);
println(interpreter.getSourceLine(bp.location));
} else if (v instanceof OperationValue)
{
OperationValue ov = (OperationValue) v;
PStm stmt = ov.body;
interpreter.clearBreakpoint(BreakpointManager.getBreakpoint(stmt).number);
Breakpoint bp = interpreter.setBreakpoint(stmt, condition);
println("Created " + bp);
println(interpreter.getSourceLine(bp.location));
} else if (v == null)
{
println(name + " is not visible or not found");
} else
{
println(name + " is not a function or operation");
}
}
|
java
|
private void setBreakpoint(String name, String condition) throws Exception
{
LexTokenReader ltr = new LexTokenReader(name, Dialect.VDM_SL);
LexToken token = ltr.nextToken();
ltr.close();
Value v = null;
if (token.is(VDMToken.IDENTIFIER))
{
LexIdentifierToken id = (LexIdentifierToken) token;
LexNameToken lnt = new LexNameToken(interpreter.getDefaultName(), id);
v = interpreter.findGlobal(lnt);
} else if (token.is(VDMToken.NAME))
{
v = interpreter.findGlobal((LexNameToken) token);
}
if (v instanceof FunctionValue)
{
FunctionValue fv = (FunctionValue) v;
PExp exp = fv.body;
interpreter.clearBreakpoint(BreakpointManager.getBreakpoint(exp).number);
Breakpoint bp = interpreter.setBreakpoint(exp, condition);
println("Created " + bp);
println(interpreter.getSourceLine(bp.location));
} else if (v instanceof OperationValue)
{
OperationValue ov = (OperationValue) v;
PStm stmt = ov.body;
interpreter.clearBreakpoint(BreakpointManager.getBreakpoint(stmt).number);
Breakpoint bp = interpreter.setBreakpoint(stmt, condition);
println("Created " + bp);
println(interpreter.getSourceLine(bp.location));
} else if (v == null)
{
println(name + " is not visible or not found");
} else
{
println(name + " is not a function or operation");
}
}
|
[
"private",
"void",
"setBreakpoint",
"(",
"String",
"name",
",",
"String",
"condition",
")",
"throws",
"Exception",
"{",
"LexTokenReader",
"ltr",
"=",
"new",
"LexTokenReader",
"(",
"name",
",",
"Dialect",
".",
"VDM_SL",
")",
";",
"LexToken",
"token",
"=",
"ltr",
".",
"nextToken",
"(",
")",
";",
"ltr",
".",
"close",
"(",
")",
";",
"Value",
"v",
"=",
"null",
";",
"if",
"(",
"token",
".",
"is",
"(",
"VDMToken",
".",
"IDENTIFIER",
")",
")",
"{",
"LexIdentifierToken",
"id",
"=",
"(",
"LexIdentifierToken",
")",
"token",
";",
"LexNameToken",
"lnt",
"=",
"new",
"LexNameToken",
"(",
"interpreter",
".",
"getDefaultName",
"(",
")",
",",
"id",
")",
";",
"v",
"=",
"interpreter",
".",
"findGlobal",
"(",
"lnt",
")",
";",
"}",
"else",
"if",
"(",
"token",
".",
"is",
"(",
"VDMToken",
".",
"NAME",
")",
")",
"{",
"v",
"=",
"interpreter",
".",
"findGlobal",
"(",
"(",
"LexNameToken",
")",
"token",
")",
";",
"}",
"if",
"(",
"v",
"instanceof",
"FunctionValue",
")",
"{",
"FunctionValue",
"fv",
"=",
"(",
"FunctionValue",
")",
"v",
";",
"PExp",
"exp",
"=",
"fv",
".",
"body",
";",
"interpreter",
".",
"clearBreakpoint",
"(",
"BreakpointManager",
".",
"getBreakpoint",
"(",
"exp",
")",
".",
"number",
")",
";",
"Breakpoint",
"bp",
"=",
"interpreter",
".",
"setBreakpoint",
"(",
"exp",
",",
"condition",
")",
";",
"println",
"(",
"\"Created \"",
"+",
"bp",
")",
";",
"println",
"(",
"interpreter",
".",
"getSourceLine",
"(",
"bp",
".",
"location",
")",
")",
";",
"}",
"else",
"if",
"(",
"v",
"instanceof",
"OperationValue",
")",
"{",
"OperationValue",
"ov",
"=",
"(",
"OperationValue",
")",
"v",
";",
"PStm",
"stmt",
"=",
"ov",
".",
"body",
";",
"interpreter",
".",
"clearBreakpoint",
"(",
"BreakpointManager",
".",
"getBreakpoint",
"(",
"stmt",
")",
".",
"number",
")",
";",
"Breakpoint",
"bp",
"=",
"interpreter",
".",
"setBreakpoint",
"(",
"stmt",
",",
"condition",
")",
";",
"println",
"(",
"\"Created \"",
"+",
"bp",
")",
";",
"println",
"(",
"interpreter",
".",
"getSourceLine",
"(",
"bp",
".",
"location",
")",
")",
";",
"}",
"else",
"if",
"(",
"v",
"==",
"null",
")",
"{",
"println",
"(",
"name",
"+",
"\" is not visible or not found\"",
")",
";",
"}",
"else",
"{",
"println",
"(",
"name",
"+",
"\" is not a function or operation\"",
")",
";",
"}",
"}"
] |
Set a breakpoint at the given function or operation name with a condition.
@param name
The function or operation name.
@param condition
Any condition for the breakpoint, or null.
@throws Exception
Problems parsing condition.
|
[
"Set",
"a",
"breakpoint",
"at",
"the",
"given",
"function",
"or",
"operation",
"name",
"with",
"a",
"condition",
"."
] |
train
|
https://github.com/overturetool/overture/blob/83175dc6c24fa171cde4fcf61ecb648eba3bdbc1/core/interpreter/src/main/java/org/overture/interpreter/commands/CommandReader.java#L1366-L1407
|
apache/groovy
|
src/main/java/org/codehaus/groovy/runtime/memoize/LRUCache.java
|
LRUCache.getAndPut
|
@Override
public V getAndPut(K key, ValueProvider<? super K, ? extends V> valueProvider) {
"""
Try to get the value from cache.
If not found, create the value by {@link MemoizeCache.ValueProvider} and put it into the cache, at last return the value.
The operation is completed atomically.
@param key
@param valueProvider provide the value if the associated value not found
"""
return map.computeIfAbsent(key, valueProvider::provide);
}
|
java
|
@Override
public V getAndPut(K key, ValueProvider<? super K, ? extends V> valueProvider) {
return map.computeIfAbsent(key, valueProvider::provide);
}
|
[
"@",
"Override",
"public",
"V",
"getAndPut",
"(",
"K",
"key",
",",
"ValueProvider",
"<",
"?",
"super",
"K",
",",
"?",
"extends",
"V",
">",
"valueProvider",
")",
"{",
"return",
"map",
".",
"computeIfAbsent",
"(",
"key",
",",
"valueProvider",
"::",
"provide",
")",
";",
"}"
] |
Try to get the value from cache.
If not found, create the value by {@link MemoizeCache.ValueProvider} and put it into the cache, at last return the value.
The operation is completed atomically.
@param key
@param valueProvider provide the value if the associated value not found
|
[
"Try",
"to",
"get",
"the",
"value",
"from",
"cache",
".",
"If",
"not",
"found",
"create",
"the",
"value",
"by",
"{",
"@link",
"MemoizeCache",
".",
"ValueProvider",
"}",
"and",
"put",
"it",
"into",
"the",
"cache",
"at",
"last",
"return",
"the",
"value",
"."
] |
train
|
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/memoize/LRUCache.java#L61-L64
|
gallandarakhneorg/afc
|
core/vmutils/src/main/java/org/arakhne/afc/vmutil/FileSystem.java
|
FileSystem.toJarURL
|
@Pure
public static URL toJarURL(URL jarFile, String insideFile) throws MalformedURLException {
"""
Replies the jar-schemed URL composed of the two given components.
<p>If the inputs are {@code file:/path1/archive.jar} and @{code /path2/file},
the output of this function is {@code jar:file:/path1/archive.jar!/path2/file}.
@param jarFile is the URL to the jar file.
@param insideFile is the name of the file inside the jar.
@return the jar-schemed URL.
@throws MalformedURLException when the URL is malformed.
"""
if (jarFile == null || insideFile == null) {
return null;
}
final StringBuilder buf = new StringBuilder();
buf.append("jar:"); //$NON-NLS-1$
buf.append(jarFile.toExternalForm());
buf.append(JAR_URL_FILE_ROOT);
final String path = fromFileStandardToURLStandard(insideFile);
if (path.startsWith(URL_PATH_SEPARATOR)) {
buf.append(path.substring(URL_PATH_SEPARATOR.length()));
} else {
buf.append(path);
}
return new URL(buf.toString());
}
|
java
|
@Pure
public static URL toJarURL(URL jarFile, String insideFile) throws MalformedURLException {
if (jarFile == null || insideFile == null) {
return null;
}
final StringBuilder buf = new StringBuilder();
buf.append("jar:"); //$NON-NLS-1$
buf.append(jarFile.toExternalForm());
buf.append(JAR_URL_FILE_ROOT);
final String path = fromFileStandardToURLStandard(insideFile);
if (path.startsWith(URL_PATH_SEPARATOR)) {
buf.append(path.substring(URL_PATH_SEPARATOR.length()));
} else {
buf.append(path);
}
return new URL(buf.toString());
}
|
[
"@",
"Pure",
"public",
"static",
"URL",
"toJarURL",
"(",
"URL",
"jarFile",
",",
"String",
"insideFile",
")",
"throws",
"MalformedURLException",
"{",
"if",
"(",
"jarFile",
"==",
"null",
"||",
"insideFile",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"final",
"StringBuilder",
"buf",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"buf",
".",
"append",
"(",
"\"jar:\"",
")",
";",
"//$NON-NLS-1$",
"buf",
".",
"append",
"(",
"jarFile",
".",
"toExternalForm",
"(",
")",
")",
";",
"buf",
".",
"append",
"(",
"JAR_URL_FILE_ROOT",
")",
";",
"final",
"String",
"path",
"=",
"fromFileStandardToURLStandard",
"(",
"insideFile",
")",
";",
"if",
"(",
"path",
".",
"startsWith",
"(",
"URL_PATH_SEPARATOR",
")",
")",
"{",
"buf",
".",
"append",
"(",
"path",
".",
"substring",
"(",
"URL_PATH_SEPARATOR",
".",
"length",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"buf",
".",
"append",
"(",
"path",
")",
";",
"}",
"return",
"new",
"URL",
"(",
"buf",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
Replies the jar-schemed URL composed of the two given components.
<p>If the inputs are {@code file:/path1/archive.jar} and @{code /path2/file},
the output of this function is {@code jar:file:/path1/archive.jar!/path2/file}.
@param jarFile is the URL to the jar file.
@param insideFile is the name of the file inside the jar.
@return the jar-schemed URL.
@throws MalformedURLException when the URL is malformed.
|
[
"Replies",
"the",
"jar",
"-",
"schemed",
"URL",
"composed",
"of",
"the",
"two",
"given",
"components",
"."
] |
train
|
https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/FileSystem.java#L350-L366
|
riversun/d6
|
src/main/java/org/riversun/d6/core/D6DateUtil.java
|
D6DateUtil.getSqlTime
|
public static java.sql.Time getSqlTime(int hour, int minute, int second) {
"""
Get SQL Time(java.sql.Time) from supplied parameters
@param hour
@param minute
@param second
@return
"""
Calendar cal = Calendar.getInstance();
cal.setTime(new java.util.Date(0));
cal.set(Calendar.HOUR_OF_DAY, hour);
cal.set(Calendar.MINUTE, minute);
cal.set(Calendar.SECOND, second);
cal.set(Calendar.MILLISECOND, 0);
return getSqlTime(cal.getTime());
}
|
java
|
public static java.sql.Time getSqlTime(int hour, int minute, int second) {
Calendar cal = Calendar.getInstance();
cal.setTime(new java.util.Date(0));
cal.set(Calendar.HOUR_OF_DAY, hour);
cal.set(Calendar.MINUTE, minute);
cal.set(Calendar.SECOND, second);
cal.set(Calendar.MILLISECOND, 0);
return getSqlTime(cal.getTime());
}
|
[
"public",
"static",
"java",
".",
"sql",
".",
"Time",
"getSqlTime",
"(",
"int",
"hour",
",",
"int",
"minute",
",",
"int",
"second",
")",
"{",
"Calendar",
"cal",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"cal",
".",
"setTime",
"(",
"new",
"java",
".",
"util",
".",
"Date",
"(",
"0",
")",
")",
";",
"cal",
".",
"set",
"(",
"Calendar",
".",
"HOUR_OF_DAY",
",",
"hour",
")",
";",
"cal",
".",
"set",
"(",
"Calendar",
".",
"MINUTE",
",",
"minute",
")",
";",
"cal",
".",
"set",
"(",
"Calendar",
".",
"SECOND",
",",
"second",
")",
";",
"cal",
".",
"set",
"(",
"Calendar",
".",
"MILLISECOND",
",",
"0",
")",
";",
"return",
"getSqlTime",
"(",
"cal",
".",
"getTime",
"(",
")",
")",
";",
"}"
] |
Get SQL Time(java.sql.Time) from supplied parameters
@param hour
@param minute
@param second
@return
|
[
"Get",
"SQL",
"Time",
"(",
"java",
".",
"sql",
".",
"Time",
")",
"from",
"supplied",
"parameters"
] |
train
|
https://github.com/riversun/d6/blob/2798bd876b9380dbfea8182d11ad306cb1b0e114/src/main/java/org/riversun/d6/core/D6DateUtil.java#L77-L86
|
Azure/azure-sdk-for-java
|
logic/resource-manager/v2016_06_01/src/main/java/com/microsoft/azure/management/logic/v2016_06_01/implementation/WorkflowTriggerHistoriesInner.java
|
WorkflowTriggerHistoriesInner.resubmitAsync
|
public Observable<Void> resubmitAsync(String resourceGroupName, String workflowName, String triggerName, String historyName) {
"""
Resubmits a workflow run based on the trigger history.
@param resourceGroupName The resource group name.
@param workflowName The workflow name.
@param triggerName The workflow trigger name.
@param historyName The workflow trigger history name. Corresponds to the run name for triggers that resulted in a run.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful.
"""
return resubmitWithServiceResponseAsync(resourceGroupName, workflowName, triggerName, historyName).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
}
|
java
|
public Observable<Void> resubmitAsync(String resourceGroupName, String workflowName, String triggerName, String historyName) {
return resubmitWithServiceResponseAsync(resourceGroupName, workflowName, triggerName, historyName).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"Void",
">",
"resubmitAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"workflowName",
",",
"String",
"triggerName",
",",
"String",
"historyName",
")",
"{",
"return",
"resubmitWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"workflowName",
",",
"triggerName",
",",
"historyName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Void",
">",
",",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
"ServiceResponse",
"<",
"Void",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Resubmits a workflow run based on the trigger history.
@param resourceGroupName The resource group name.
@param workflowName The workflow name.
@param triggerName The workflow trigger name.
@param historyName The workflow trigger history name. Corresponds to the run name for triggers that resulted in a run.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful.
|
[
"Resubmits",
"a",
"workflow",
"run",
"based",
"on",
"the",
"trigger",
"history",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/logic/resource-manager/v2016_06_01/src/main/java/com/microsoft/azure/management/logic/v2016_06_01/implementation/WorkflowTriggerHistoriesInner.java#L486-L493
|
couchbase/CouchbaseMock
|
src/main/java/com/couchbase/mock/CouchbaseMock.java
|
CouchbaseMock.startHarakiriMonitor
|
public void startHarakiriMonitor(String host, boolean terminate) throws IOException {
"""
Start the monitor
see {@link #startHarakiriMonitor(java.net.InetSocketAddress, boolean)}
@param host A string in the form of {@code host:port}
@param terminate Whether the application should terminate on disconnect
@throws IOException If an I/O error occurs
"""
int idx = host.indexOf(':');
String h = host.substring(0, idx);
int p = Integer.parseInt(host.substring(idx + 1));
startHarakiriMonitor(new InetSocketAddress(h, p), terminate);
}
|
java
|
public void startHarakiriMonitor(String host, boolean terminate) throws IOException {
int idx = host.indexOf(':');
String h = host.substring(0, idx);
int p = Integer.parseInt(host.substring(idx + 1));
startHarakiriMonitor(new InetSocketAddress(h, p), terminate);
}
|
[
"public",
"void",
"startHarakiriMonitor",
"(",
"String",
"host",
",",
"boolean",
"terminate",
")",
"throws",
"IOException",
"{",
"int",
"idx",
"=",
"host",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"String",
"h",
"=",
"host",
".",
"substring",
"(",
"0",
",",
"idx",
")",
";",
"int",
"p",
"=",
"Integer",
".",
"parseInt",
"(",
"host",
".",
"substring",
"(",
"idx",
"+",
"1",
")",
")",
";",
"startHarakiriMonitor",
"(",
"new",
"InetSocketAddress",
"(",
"h",
",",
"p",
")",
",",
"terminate",
")",
";",
"}"
] |
Start the monitor
see {@link #startHarakiriMonitor(java.net.InetSocketAddress, boolean)}
@param host A string in the form of {@code host:port}
@param terminate Whether the application should terminate on disconnect
@throws IOException If an I/O error occurs
|
[
"Start",
"the",
"monitor",
"see",
"{",
"@link",
"#startHarakiriMonitor",
"(",
"java",
".",
"net",
".",
"InetSocketAddress",
"boolean",
")",
"}"
] |
train
|
https://github.com/couchbase/CouchbaseMock/blob/2085bbebade1d5b6356480e7bf335139d08383da/src/main/java/com/couchbase/mock/CouchbaseMock.java#L113-L118
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/asta/AstaReader.java
|
AstaReader.populateMilestone
|
private void populateMilestone(Row row, Task task) {
"""
Populate a milestone from a Row instance.
@param row Row instance
@param task Task instance
"""
task.setMilestone(true);
//PROJID
task.setUniqueID(row.getInteger("MILESTONEID"));
task.setStart(row.getDate("GIVEN_DATE_TIME"));
task.setFinish(row.getDate("GIVEN_DATE_TIME"));
//PROGREST_PERIOD
//SYMBOL_APPEARANCE
//MILESTONE_TYPE
//PLACEMENU
task.setPercentageComplete(row.getBoolean("COMPLETED") ? COMPLETE : INCOMPLETE);
//INTERRUPTIBLE_X
//ACTUAL_DURATIONTYPF
//ACTUAL_DURATIONELA_MONTHS
//ACTUAL_DURATIONHOURS
task.setEarlyStart(row.getDate("EARLY_START_DATE"));
task.setLateStart(row.getDate("LATE_START_DATE"));
//FREE_START_DATE
//START_CONSTRAINT_DATE
//END_CONSTRAINT_DATE
//EFFORT_BUDGET
//NATURAO_ORDER
//LOGICAL_PRECEDENCE
//SPAVE_INTEGER
//SWIM_LANE
//USER_PERCENT_COMPLETE
//OVERALL_PERCENV_COMPLETE
//OVERALL_PERCENT_COMPL_WEIGHT
task.setName(row.getString("NARE"));
//NOTET
task.setText(1, row.getString("UNIQUE_TASK_ID"));
task.setCalendar(m_project.getCalendarByUniqueID(row.getInteger("CALENDAU")));
//EFFORT_TIMI_UNIT
//WORL_UNIT
//LATEST_ALLOC_PROGRESS_PERIOD
//WORN
//CONSTRAINU
//PRIORITB
//CRITICAM
//USE_PARENU_CALENDAR
//BUFFER_TASK
//MARK_FOS_HIDING
//OWNED_BY_TIMESHEEV_X
//START_ON_NEX_DAY
//LONGEST_PATH
//DURATIOTTYPF
//DURATIOTELA_MONTHS
//DURATIOTHOURS
//STARZ
//ENJ
//DURATION_TIMJ_UNIT
//UNSCHEDULABLG
//SUBPROJECT_ID
//ALT_ID
//LAST_EDITED_DATE
//LAST_EDITED_BY
task.setDuration(Duration.getInstance(0, TimeUnit.HOURS));
}
|
java
|
private void populateMilestone(Row row, Task task)
{
task.setMilestone(true);
//PROJID
task.setUniqueID(row.getInteger("MILESTONEID"));
task.setStart(row.getDate("GIVEN_DATE_TIME"));
task.setFinish(row.getDate("GIVEN_DATE_TIME"));
//PROGREST_PERIOD
//SYMBOL_APPEARANCE
//MILESTONE_TYPE
//PLACEMENU
task.setPercentageComplete(row.getBoolean("COMPLETED") ? COMPLETE : INCOMPLETE);
//INTERRUPTIBLE_X
//ACTUAL_DURATIONTYPF
//ACTUAL_DURATIONELA_MONTHS
//ACTUAL_DURATIONHOURS
task.setEarlyStart(row.getDate("EARLY_START_DATE"));
task.setLateStart(row.getDate("LATE_START_DATE"));
//FREE_START_DATE
//START_CONSTRAINT_DATE
//END_CONSTRAINT_DATE
//EFFORT_BUDGET
//NATURAO_ORDER
//LOGICAL_PRECEDENCE
//SPAVE_INTEGER
//SWIM_LANE
//USER_PERCENT_COMPLETE
//OVERALL_PERCENV_COMPLETE
//OVERALL_PERCENT_COMPL_WEIGHT
task.setName(row.getString("NARE"));
//NOTET
task.setText(1, row.getString("UNIQUE_TASK_ID"));
task.setCalendar(m_project.getCalendarByUniqueID(row.getInteger("CALENDAU")));
//EFFORT_TIMI_UNIT
//WORL_UNIT
//LATEST_ALLOC_PROGRESS_PERIOD
//WORN
//CONSTRAINU
//PRIORITB
//CRITICAM
//USE_PARENU_CALENDAR
//BUFFER_TASK
//MARK_FOS_HIDING
//OWNED_BY_TIMESHEEV_X
//START_ON_NEX_DAY
//LONGEST_PATH
//DURATIOTTYPF
//DURATIOTELA_MONTHS
//DURATIOTHOURS
//STARZ
//ENJ
//DURATION_TIMJ_UNIT
//UNSCHEDULABLG
//SUBPROJECT_ID
//ALT_ID
//LAST_EDITED_DATE
//LAST_EDITED_BY
task.setDuration(Duration.getInstance(0, TimeUnit.HOURS));
}
|
[
"private",
"void",
"populateMilestone",
"(",
"Row",
"row",
",",
"Task",
"task",
")",
"{",
"task",
".",
"setMilestone",
"(",
"true",
")",
";",
"//PROJID",
"task",
".",
"setUniqueID",
"(",
"row",
".",
"getInteger",
"(",
"\"MILESTONEID\"",
")",
")",
";",
"task",
".",
"setStart",
"(",
"row",
".",
"getDate",
"(",
"\"GIVEN_DATE_TIME\"",
")",
")",
";",
"task",
".",
"setFinish",
"(",
"row",
".",
"getDate",
"(",
"\"GIVEN_DATE_TIME\"",
")",
")",
";",
"//PROGREST_PERIOD",
"//SYMBOL_APPEARANCE",
"//MILESTONE_TYPE",
"//PLACEMENU",
"task",
".",
"setPercentageComplete",
"(",
"row",
".",
"getBoolean",
"(",
"\"COMPLETED\"",
")",
"?",
"COMPLETE",
":",
"INCOMPLETE",
")",
";",
"//INTERRUPTIBLE_X",
"//ACTUAL_DURATIONTYPF",
"//ACTUAL_DURATIONELA_MONTHS",
"//ACTUAL_DURATIONHOURS",
"task",
".",
"setEarlyStart",
"(",
"row",
".",
"getDate",
"(",
"\"EARLY_START_DATE\"",
")",
")",
";",
"task",
".",
"setLateStart",
"(",
"row",
".",
"getDate",
"(",
"\"LATE_START_DATE\"",
")",
")",
";",
"//FREE_START_DATE",
"//START_CONSTRAINT_DATE",
"//END_CONSTRAINT_DATE",
"//EFFORT_BUDGET",
"//NATURAO_ORDER",
"//LOGICAL_PRECEDENCE",
"//SPAVE_INTEGER",
"//SWIM_LANE",
"//USER_PERCENT_COMPLETE",
"//OVERALL_PERCENV_COMPLETE",
"//OVERALL_PERCENT_COMPL_WEIGHT",
"task",
".",
"setName",
"(",
"row",
".",
"getString",
"(",
"\"NARE\"",
")",
")",
";",
"//NOTET",
"task",
".",
"setText",
"(",
"1",
",",
"row",
".",
"getString",
"(",
"\"UNIQUE_TASK_ID\"",
")",
")",
";",
"task",
".",
"setCalendar",
"(",
"m_project",
".",
"getCalendarByUniqueID",
"(",
"row",
".",
"getInteger",
"(",
"\"CALENDAU\"",
")",
")",
")",
";",
"//EFFORT_TIMI_UNIT",
"//WORL_UNIT",
"//LATEST_ALLOC_PROGRESS_PERIOD",
"//WORN",
"//CONSTRAINU",
"//PRIORITB",
"//CRITICAM",
"//USE_PARENU_CALENDAR",
"//BUFFER_TASK",
"//MARK_FOS_HIDING",
"//OWNED_BY_TIMESHEEV_X",
"//START_ON_NEX_DAY",
"//LONGEST_PATH",
"//DURATIOTTYPF",
"//DURATIOTELA_MONTHS",
"//DURATIOTHOURS",
"//STARZ",
"//ENJ",
"//DURATION_TIMJ_UNIT",
"//UNSCHEDULABLG",
"//SUBPROJECT_ID",
"//ALT_ID",
"//LAST_EDITED_DATE",
"//LAST_EDITED_BY",
"task",
".",
"setDuration",
"(",
"Duration",
".",
"getInstance",
"(",
"0",
",",
"TimeUnit",
".",
"HOURS",
")",
")",
";",
"}"
] |
Populate a milestone from a Row instance.
@param row Row instance
@param task Task instance
|
[
"Populate",
"a",
"milestone",
"from",
"a",
"Row",
"instance",
"."
] |
train
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/asta/AstaReader.java#L528-L586
|
banq/jdonframework
|
src/main/java/com/jdon/util/jdom/XMLFilterBase.java
|
XMLFilterBase.emptyElement
|
public void emptyElement (String uri, String localName)
throws SAXException {
"""
Add an empty element without a qname or attributes.
<p>This method will supply an empty string for the qname
and an empty attribute list. It invokes
{@link #emptyElement(String, String, String, Attributes)}
directly.</p>
@param uri The element's Namespace URI.
@param localName The element's local name.
@exception org.xml.sax.SAXException If a filter
further down the chain raises an exception.
@see #emptyElement(String, String, String, Attributes)
"""
emptyElement(uri, localName, "", EMPTY_ATTS);
}
|
java
|
public void emptyElement (String uri, String localName)
throws SAXException
{
emptyElement(uri, localName, "", EMPTY_ATTS);
}
|
[
"public",
"void",
"emptyElement",
"(",
"String",
"uri",
",",
"String",
"localName",
")",
"throws",
"SAXException",
"{",
"emptyElement",
"(",
"uri",
",",
"localName",
",",
"\"\"",
",",
"EMPTY_ATTS",
")",
";",
"}"
] |
Add an empty element without a qname or attributes.
<p>This method will supply an empty string for the qname
and an empty attribute list. It invokes
{@link #emptyElement(String, String, String, Attributes)}
directly.</p>
@param uri The element's Namespace URI.
@param localName The element's local name.
@exception org.xml.sax.SAXException If a filter
further down the chain raises an exception.
@see #emptyElement(String, String, String, Attributes)
|
[
"Add",
"an",
"empty",
"element",
"without",
"a",
"qname",
"or",
"attributes",
"."
] |
train
|
https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/util/jdom/XMLFilterBase.java#L303-L307
|
oehf/ipf-oht-atna
|
nodeauth/src/main/java/org/openhealthtools/ihe/atna/nodeauth/SecurityDomainManager.java
|
SecurityDomainManager.formatKey
|
public String formatKey(String host, int port) throws URISyntaxException {
"""
Concatenates a host string and port integer into a "host:port" string
@param host
@param port
@return
@throws URISyntaxException
"""
if (port < 1) {
throw new URISyntaxException("","The port value must be greater than zero");
}
if (!"".equals(host)) {
return host + ":" + port;
} else {
throw new URISyntaxException("","The host cannot be null");
}
}
|
java
|
public String formatKey(String host, int port) throws URISyntaxException
{
if (port < 1) {
throw new URISyntaxException("","The port value must be greater than zero");
}
if (!"".equals(host)) {
return host + ":" + port;
} else {
throw new URISyntaxException("","The host cannot be null");
}
}
|
[
"public",
"String",
"formatKey",
"(",
"String",
"host",
",",
"int",
"port",
")",
"throws",
"URISyntaxException",
"{",
"if",
"(",
"port",
"<",
"1",
")",
"{",
"throw",
"new",
"URISyntaxException",
"(",
"\"\"",
",",
"\"The port value must be greater than zero\"",
")",
";",
"}",
"if",
"(",
"!",
"\"\"",
".",
"equals",
"(",
"host",
")",
")",
"{",
"return",
"host",
"+",
"\":\"",
"+",
"port",
";",
"}",
"else",
"{",
"throw",
"new",
"URISyntaxException",
"(",
"\"\"",
",",
"\"The host cannot be null\"",
")",
";",
"}",
"}"
] |
Concatenates a host string and port integer into a "host:port" string
@param host
@param port
@return
@throws URISyntaxException
|
[
"Concatenates",
"a",
"host",
"string",
"and",
"port",
"integer",
"into",
"a",
"host",
":",
"port",
"string"
] |
train
|
https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/nodeauth/src/main/java/org/openhealthtools/ihe/atna/nodeauth/SecurityDomainManager.java#L255-L266
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.security.openidconnect.clients.common/src/com/ibm/ws/security/openidconnect/clients/common/HashUtils.java
|
HashUtils.digest
|
@Sensitive
@Trivial
public static String digest(@Sensitive String input) {
"""
generate hash code by using SHA-256
If there is some error, log the error.
"""
if (input == null || input.isEmpty())
return null;
return digest(input, DEFAULT_ALGORITHM, DEFAULT_CHARSET);
}
|
java
|
@Sensitive
@Trivial
public static String digest(@Sensitive String input) {
if (input == null || input.isEmpty())
return null;
return digest(input, DEFAULT_ALGORITHM, DEFAULT_CHARSET);
}
|
[
"@",
"Sensitive",
"@",
"Trivial",
"public",
"static",
"String",
"digest",
"(",
"@",
"Sensitive",
"String",
"input",
")",
"{",
"if",
"(",
"input",
"==",
"null",
"||",
"input",
".",
"isEmpty",
"(",
")",
")",
"return",
"null",
";",
"return",
"digest",
"(",
"input",
",",
"DEFAULT_ALGORITHM",
",",
"DEFAULT_CHARSET",
")",
";",
"}"
] |
generate hash code by using SHA-256
If there is some error, log the error.
|
[
"generate",
"hash",
"code",
"by",
"using",
"SHA",
"-",
"256",
"If",
"there",
"is",
"some",
"error",
"log",
"the",
"error",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.openidconnect.clients.common/src/com/ibm/ws/security/openidconnect/clients/common/HashUtils.java#L36-L42
|
PeterisP/LVTagger
|
src/main/java/edu/stanford/nlp/util/StringUtils.java
|
StringUtils.columnStringToObject
|
public static <T> T columnStringToObject(Class<?> objClass, String str, Pattern delimiterPattern, String[] fieldNames)
throws InstantiationException, IllegalAccessException, NoSuchMethodException, NoSuchFieldException, InvocationTargetException {
"""
Converts a tab delimited string into an object with given fields
Requires the object has public access for the specified fields
@param objClass Class of object to be created
@param str string to convert
@param delimiterPattern delimiter
@param fieldNames fieldnames
@param <T> type to return
@return Object created from string
"""
String[] fields = delimiterPattern.split(str);
T item = ErasureUtils.<T>uncheckedCast(objClass.newInstance());
for (int i = 0; i < fields.length; i++) {
try {
Field field = objClass.getDeclaredField(fieldNames[i]);
field.set(item, fields[i]);
} catch (IllegalAccessException ex) {
Method method = objClass.getDeclaredMethod("set" + StringUtils.capitalize(fieldNames[i]), String.class);
method.invoke(item, fields[i]);
}
}
return item;
}
|
java
|
public static <T> T columnStringToObject(Class<?> objClass, String str, Pattern delimiterPattern, String[] fieldNames)
throws InstantiationException, IllegalAccessException, NoSuchMethodException, NoSuchFieldException, InvocationTargetException
{
String[] fields = delimiterPattern.split(str);
T item = ErasureUtils.<T>uncheckedCast(objClass.newInstance());
for (int i = 0; i < fields.length; i++) {
try {
Field field = objClass.getDeclaredField(fieldNames[i]);
field.set(item, fields[i]);
} catch (IllegalAccessException ex) {
Method method = objClass.getDeclaredMethod("set" + StringUtils.capitalize(fieldNames[i]), String.class);
method.invoke(item, fields[i]);
}
}
return item;
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"columnStringToObject",
"(",
"Class",
"<",
"?",
">",
"objClass",
",",
"String",
"str",
",",
"Pattern",
"delimiterPattern",
",",
"String",
"[",
"]",
"fieldNames",
")",
"throws",
"InstantiationException",
",",
"IllegalAccessException",
",",
"NoSuchMethodException",
",",
"NoSuchFieldException",
",",
"InvocationTargetException",
"{",
"String",
"[",
"]",
"fields",
"=",
"delimiterPattern",
".",
"split",
"(",
"str",
")",
";",
"T",
"item",
"=",
"ErasureUtils",
".",
"<",
"T",
">",
"uncheckedCast",
"(",
"objClass",
".",
"newInstance",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"fields",
".",
"length",
";",
"i",
"++",
")",
"{",
"try",
"{",
"Field",
"field",
"=",
"objClass",
".",
"getDeclaredField",
"(",
"fieldNames",
"[",
"i",
"]",
")",
";",
"field",
".",
"set",
"(",
"item",
",",
"fields",
"[",
"i",
"]",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"ex",
")",
"{",
"Method",
"method",
"=",
"objClass",
".",
"getDeclaredMethod",
"(",
"\"set\"",
"+",
"StringUtils",
".",
"capitalize",
"(",
"fieldNames",
"[",
"i",
"]",
")",
",",
"String",
".",
"class",
")",
";",
"method",
".",
"invoke",
"(",
"item",
",",
"fields",
"[",
"i",
"]",
")",
";",
"}",
"}",
"return",
"item",
";",
"}"
] |
Converts a tab delimited string into an object with given fields
Requires the object has public access for the specified fields
@param objClass Class of object to be created
@param str string to convert
@param delimiterPattern delimiter
@param fieldNames fieldnames
@param <T> type to return
@return Object created from string
|
[
"Converts",
"a",
"tab",
"delimited",
"string",
"into",
"an",
"object",
"with",
"given",
"fields",
"Requires",
"the",
"object",
"has",
"public",
"access",
"for",
"the",
"specified",
"fields"
] |
train
|
https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/util/StringUtils.java#L1363-L1378
|
Squarespace/cldr
|
runtime/src/main/java/com/squarespace/cldr/DistanceTable.java
|
DistanceTable.scanTerritory
|
private Node scanTerritory(DistanceMap map, String desired, String supported) {
"""
Scan the desired region against the supported partitions and vice versa.
Return the first matching node.
"""
Node node;
for (String partition : PARTITION_TABLE.getRegionPartition(desired)) {
node = map.get(partition, supported);
if (node != null) {
return node;
}
}
for (String partition : PARTITION_TABLE.getRegionPartition(supported)) {
node = map.get(desired, partition);
if (node != null) {
return node;
}
}
return null;
}
|
java
|
private Node scanTerritory(DistanceMap map, String desired, String supported) {
Node node;
for (String partition : PARTITION_TABLE.getRegionPartition(desired)) {
node = map.get(partition, supported);
if (node != null) {
return node;
}
}
for (String partition : PARTITION_TABLE.getRegionPartition(supported)) {
node = map.get(desired, partition);
if (node != null) {
return node;
}
}
return null;
}
|
[
"private",
"Node",
"scanTerritory",
"(",
"DistanceMap",
"map",
",",
"String",
"desired",
",",
"String",
"supported",
")",
"{",
"Node",
"node",
";",
"for",
"(",
"String",
"partition",
":",
"PARTITION_TABLE",
".",
"getRegionPartition",
"(",
"desired",
")",
")",
"{",
"node",
"=",
"map",
".",
"get",
"(",
"partition",
",",
"supported",
")",
";",
"if",
"(",
"node",
"!=",
"null",
")",
"{",
"return",
"node",
";",
"}",
"}",
"for",
"(",
"String",
"partition",
":",
"PARTITION_TABLE",
".",
"getRegionPartition",
"(",
"supported",
")",
")",
"{",
"node",
"=",
"map",
".",
"get",
"(",
"desired",
",",
"partition",
")",
";",
"if",
"(",
"node",
"!=",
"null",
")",
"{",
"return",
"node",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Scan the desired region against the supported partitions and vice versa.
Return the first matching node.
|
[
"Scan",
"the",
"desired",
"region",
"against",
"the",
"supported",
"partitions",
"and",
"vice",
"versa",
".",
"Return",
"the",
"first",
"matching",
"node",
"."
] |
train
|
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/DistanceTable.java#L172-L189
|
albfernandez/itext2
|
src/main/java/com/lowagie/text/pdf/PdfStamper.java
|
PdfStamper.addFileAttachment
|
public void addFileAttachment(String description, byte fileStore[], String file, String fileDisplay) throws IOException {
"""
Adds a file attachment at the document level. Existing attachments will be kept.
@param description the file description
@param fileStore an array with the file. If it's <CODE>null</CODE>
the file will be read from the disk
@param file the path to the file. It will only be used if
<CODE>fileStore</CODE> is not <CODE>null</CODE>
@param fileDisplay the actual file name stored in the pdf
@throws IOException on error
"""
addFileAttachment(description, PdfFileSpecification.fileEmbedded(stamper, file, fileDisplay, fileStore));
}
|
java
|
public void addFileAttachment(String description, byte fileStore[], String file, String fileDisplay) throws IOException {
addFileAttachment(description, PdfFileSpecification.fileEmbedded(stamper, file, fileDisplay, fileStore));
}
|
[
"public",
"void",
"addFileAttachment",
"(",
"String",
"description",
",",
"byte",
"fileStore",
"[",
"]",
",",
"String",
"file",
",",
"String",
"fileDisplay",
")",
"throws",
"IOException",
"{",
"addFileAttachment",
"(",
"description",
",",
"PdfFileSpecification",
".",
"fileEmbedded",
"(",
"stamper",
",",
"file",
",",
"fileDisplay",
",",
"fileStore",
")",
")",
";",
"}"
] |
Adds a file attachment at the document level. Existing attachments will be kept.
@param description the file description
@param fileStore an array with the file. If it's <CODE>null</CODE>
the file will be read from the disk
@param file the path to the file. It will only be used if
<CODE>fileStore</CODE> is not <CODE>null</CODE>
@param fileDisplay the actual file name stored in the pdf
@throws IOException on error
|
[
"Adds",
"a",
"file",
"attachment",
"at",
"the",
"document",
"level",
".",
"Existing",
"attachments",
"will",
"be",
"kept",
"."
] |
train
|
https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/pdf/PdfStamper.java#L503-L505
|
infinispan/infinispan
|
commons/src/main/java/org/infinispan/commons/io/UnsignedNumeric.java
|
UnsignedNumeric.readUnsignedLong
|
public static long readUnsignedLong(byte[] bytes, int offset) {
"""
Reads an int stored in variable-length format. Reads between one and nine bytes. Smaller values take fewer
bytes. Negative numbers are not supported.
"""
byte b = bytes[offset++];
long i = b & 0x7F;
for (int shift = 7; (b & 0x80) != 0; shift += 7) {
b = bytes[offset++];
i |= (b & 0x7FL) << shift;
}
return i;
}
|
java
|
public static long readUnsignedLong(byte[] bytes, int offset) {
byte b = bytes[offset++];
long i = b & 0x7F;
for (int shift = 7; (b & 0x80) != 0; shift += 7) {
b = bytes[offset++];
i |= (b & 0x7FL) << shift;
}
return i;
}
|
[
"public",
"static",
"long",
"readUnsignedLong",
"(",
"byte",
"[",
"]",
"bytes",
",",
"int",
"offset",
")",
"{",
"byte",
"b",
"=",
"bytes",
"[",
"offset",
"++",
"]",
";",
"long",
"i",
"=",
"b",
"&",
"0x7F",
";",
"for",
"(",
"int",
"shift",
"=",
"7",
";",
"(",
"b",
"&",
"0x80",
")",
"!=",
"0",
";",
"shift",
"+=",
"7",
")",
"{",
"b",
"=",
"bytes",
"[",
"offset",
"++",
"]",
";",
"i",
"|=",
"(",
"b",
"&",
"0x7F",
"L",
")",
"<<",
"shift",
";",
"}",
"return",
"i",
";",
"}"
] |
Reads an int stored in variable-length format. Reads between one and nine bytes. Smaller values take fewer
bytes. Negative numbers are not supported.
|
[
"Reads",
"an",
"int",
"stored",
"in",
"variable",
"-",
"length",
"format",
".",
"Reads",
"between",
"one",
"and",
"nine",
"bytes",
".",
"Smaller",
"values",
"take",
"fewer",
"bytes",
".",
"Negative",
"numbers",
"are",
"not",
"supported",
"."
] |
train
|
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/io/UnsignedNumeric.java#L188-L196
|
RobotiumTech/robotium
|
robotium-solo/src/main/java/com/robotium/solo/Clicker.java
|
Clicker.clickLongOnScreen
|
public void clickLongOnScreen(float x, float y, int time, View view) {
"""
Long clicks a given coordinate on the screen.
@param x the x coordinate
@param y the y coordinate
@param time the amount of time to long click
"""
boolean successfull = false;
int retry = 0;
SecurityException ex = null;
long downTime = SystemClock.uptimeMillis();
long eventTime = SystemClock.uptimeMillis();
MotionEvent event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, x, y, 0);
while(!successfull && retry < 20) {
try{
inst.sendPointerSync(event);
successfull = true;
sleeper.sleep(MINI_WAIT);
}catch(SecurityException e){
ex = e;
dialogUtils.hideSoftKeyboard(null, false, true);
sleeper.sleep(MINI_WAIT);
retry++;
View identicalView = viewFetcher.getIdenticalView(view);
if(identicalView != null){
float[] xyToClick = getClickCoordinates(identicalView);
x = xyToClick[0];
y = xyToClick[1];
}
}
}
if(!successfull) {
Assert.fail("Long click at ("+x+", "+y+") can not be completed! ("+(ex != null ? ex.getClass().getName()+": "+ex.getMessage() : "null")+")");
}
eventTime = SystemClock.uptimeMillis();
event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE, x + 1.0f, y + 1.0f, 0);
inst.sendPointerSync(event);
if(time > 0)
sleeper.sleep(time);
else
sleeper.sleep((int)(ViewConfiguration.getLongPressTimeout() * 2.5f));
eventTime = SystemClock.uptimeMillis();
event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_UP, x, y, 0);
inst.sendPointerSync(event);
sleeper.sleep();
}
|
java
|
public void clickLongOnScreen(float x, float y, int time, View view) {
boolean successfull = false;
int retry = 0;
SecurityException ex = null;
long downTime = SystemClock.uptimeMillis();
long eventTime = SystemClock.uptimeMillis();
MotionEvent event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, x, y, 0);
while(!successfull && retry < 20) {
try{
inst.sendPointerSync(event);
successfull = true;
sleeper.sleep(MINI_WAIT);
}catch(SecurityException e){
ex = e;
dialogUtils.hideSoftKeyboard(null, false, true);
sleeper.sleep(MINI_WAIT);
retry++;
View identicalView = viewFetcher.getIdenticalView(view);
if(identicalView != null){
float[] xyToClick = getClickCoordinates(identicalView);
x = xyToClick[0];
y = xyToClick[1];
}
}
}
if(!successfull) {
Assert.fail("Long click at ("+x+", "+y+") can not be completed! ("+(ex != null ? ex.getClass().getName()+": "+ex.getMessage() : "null")+")");
}
eventTime = SystemClock.uptimeMillis();
event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE, x + 1.0f, y + 1.0f, 0);
inst.sendPointerSync(event);
if(time > 0)
sleeper.sleep(time);
else
sleeper.sleep((int)(ViewConfiguration.getLongPressTimeout() * 2.5f));
eventTime = SystemClock.uptimeMillis();
event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_UP, x, y, 0);
inst.sendPointerSync(event);
sleeper.sleep();
}
|
[
"public",
"void",
"clickLongOnScreen",
"(",
"float",
"x",
",",
"float",
"y",
",",
"int",
"time",
",",
"View",
"view",
")",
"{",
"boolean",
"successfull",
"=",
"false",
";",
"int",
"retry",
"=",
"0",
";",
"SecurityException",
"ex",
"=",
"null",
";",
"long",
"downTime",
"=",
"SystemClock",
".",
"uptimeMillis",
"(",
")",
";",
"long",
"eventTime",
"=",
"SystemClock",
".",
"uptimeMillis",
"(",
")",
";",
"MotionEvent",
"event",
"=",
"MotionEvent",
".",
"obtain",
"(",
"downTime",
",",
"eventTime",
",",
"MotionEvent",
".",
"ACTION_DOWN",
",",
"x",
",",
"y",
",",
"0",
")",
";",
"while",
"(",
"!",
"successfull",
"&&",
"retry",
"<",
"20",
")",
"{",
"try",
"{",
"inst",
".",
"sendPointerSync",
"(",
"event",
")",
";",
"successfull",
"=",
"true",
";",
"sleeper",
".",
"sleep",
"(",
"MINI_WAIT",
")",
";",
"}",
"catch",
"(",
"SecurityException",
"e",
")",
"{",
"ex",
"=",
"e",
";",
"dialogUtils",
".",
"hideSoftKeyboard",
"(",
"null",
",",
"false",
",",
"true",
")",
";",
"sleeper",
".",
"sleep",
"(",
"MINI_WAIT",
")",
";",
"retry",
"++",
";",
"View",
"identicalView",
"=",
"viewFetcher",
".",
"getIdenticalView",
"(",
"view",
")",
";",
"if",
"(",
"identicalView",
"!=",
"null",
")",
"{",
"float",
"[",
"]",
"xyToClick",
"=",
"getClickCoordinates",
"(",
"identicalView",
")",
";",
"x",
"=",
"xyToClick",
"[",
"0",
"]",
";",
"y",
"=",
"xyToClick",
"[",
"1",
"]",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"successfull",
")",
"{",
"Assert",
".",
"fail",
"(",
"\"Long click at (\"",
"+",
"x",
"+",
"\", \"",
"+",
"y",
"+",
"\") can not be completed! (\"",
"+",
"(",
"ex",
"!=",
"null",
"?",
"ex",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\": \"",
"+",
"ex",
".",
"getMessage",
"(",
")",
":",
"\"null\"",
")",
"+",
"\")\"",
")",
";",
"}",
"eventTime",
"=",
"SystemClock",
".",
"uptimeMillis",
"(",
")",
";",
"event",
"=",
"MotionEvent",
".",
"obtain",
"(",
"downTime",
",",
"eventTime",
",",
"MotionEvent",
".",
"ACTION_MOVE",
",",
"x",
"+",
"1.0f",
",",
"y",
"+",
"1.0f",
",",
"0",
")",
";",
"inst",
".",
"sendPointerSync",
"(",
"event",
")",
";",
"if",
"(",
"time",
">",
"0",
")",
"sleeper",
".",
"sleep",
"(",
"time",
")",
";",
"else",
"sleeper",
".",
"sleep",
"(",
"(",
"int",
")",
"(",
"ViewConfiguration",
".",
"getLongPressTimeout",
"(",
")",
"*",
"2.5f",
")",
")",
";",
"eventTime",
"=",
"SystemClock",
".",
"uptimeMillis",
"(",
")",
";",
"event",
"=",
"MotionEvent",
".",
"obtain",
"(",
"downTime",
",",
"eventTime",
",",
"MotionEvent",
".",
"ACTION_UP",
",",
"x",
",",
"y",
",",
"0",
")",
";",
"inst",
".",
"sendPointerSync",
"(",
"event",
")",
";",
"sleeper",
".",
"sleep",
"(",
")",
";",
"}"
] |
Long clicks a given coordinate on the screen.
@param x the x coordinate
@param y the y coordinate
@param time the amount of time to long click
|
[
"Long",
"clicks",
"a",
"given",
"coordinate",
"on",
"the",
"screen",
"."
] |
train
|
https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Clicker.java#L121-L163
|
m-m-m/util
|
value/src/main/java/net/sf/mmm/util/value/api/Range.java
|
Range.verifyContained
|
public void verifyContained(V value) throws ValueOutOfRangeException {
"""
This method verifies that the given {@code value} is {@link #isContained(Object) contained in this range} .
@param value is the value to check.
@throws ValueOutOfRangeException if not {@link #isContained(Object) contained}.
"""
if (!isContained(value)) {
throw new ValueOutOfRangeException(null, value, this.min, this.max);
}
}
|
java
|
public void verifyContained(V value) throws ValueOutOfRangeException {
if (!isContained(value)) {
throw new ValueOutOfRangeException(null, value, this.min, this.max);
}
}
|
[
"public",
"void",
"verifyContained",
"(",
"V",
"value",
")",
"throws",
"ValueOutOfRangeException",
"{",
"if",
"(",
"!",
"isContained",
"(",
"value",
")",
")",
"{",
"throw",
"new",
"ValueOutOfRangeException",
"(",
"null",
",",
"value",
",",
"this",
".",
"min",
",",
"this",
".",
"max",
")",
";",
"}",
"}"
] |
This method verifies that the given {@code value} is {@link #isContained(Object) contained in this range} .
@param value is the value to check.
@throws ValueOutOfRangeException if not {@link #isContained(Object) contained}.
|
[
"This",
"method",
"verifies",
"that",
"the",
"given",
"{",
"@code",
"value",
"}",
"is",
"{",
"@link",
"#isContained",
"(",
"Object",
")",
"contained",
"in",
"this",
"range",
"}",
"."
] |
train
|
https://github.com/m-m-m/util/blob/f0e4e084448f8dfc83ca682a9e1618034a094ce6/value/src/main/java/net/sf/mmm/util/value/api/Range.java#L191-L196
|
xfcjscn/sudoor-server-lib
|
src/main/java/net/gplatform/sudoor/server/cors/CorsFilter.java
|
CorsFilter.handleInvalidCORS
|
private void handleInvalidCORS(final HttpServletRequest request, final HttpServletResponse response, final FilterChain filterChain) {
"""
Handles a CORS request that violates specification.
@param request
The {@link HttpServletRequest} object.
@param response
The {@link HttpServletResponse} object.
@param filterChain
The {@link FilterChain} object.
"""
String origin = request.getHeader(CorsFilter.REQUEST_HEADER_ORIGIN);
String method = request.getMethod();
String accessControlRequestHeaders = request.getHeader(REQUEST_HEADER_ACCESS_CONTROL_REQUEST_HEADERS);
response.setContentType("text/plain");
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
response.resetBuffer();
if (log.isDebugEnabled()) {
// Debug so no need for i18n
StringBuilder message = new StringBuilder("Invalid CORS request; Origin=");
message.append(origin);
message.append(";Method=");
message.append(method);
if (accessControlRequestHeaders != null) {
message.append(";Access-Control-Request-Headers=");
message.append(accessControlRequestHeaders);
}
log.debug(message.toString());
}
}
|
java
|
private void handleInvalidCORS(final HttpServletRequest request, final HttpServletResponse response, final FilterChain filterChain) {
String origin = request.getHeader(CorsFilter.REQUEST_HEADER_ORIGIN);
String method = request.getMethod();
String accessControlRequestHeaders = request.getHeader(REQUEST_HEADER_ACCESS_CONTROL_REQUEST_HEADERS);
response.setContentType("text/plain");
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
response.resetBuffer();
if (log.isDebugEnabled()) {
// Debug so no need for i18n
StringBuilder message = new StringBuilder("Invalid CORS request; Origin=");
message.append(origin);
message.append(";Method=");
message.append(method);
if (accessControlRequestHeaders != null) {
message.append(";Access-Control-Request-Headers=");
message.append(accessControlRequestHeaders);
}
log.debug(message.toString());
}
}
|
[
"private",
"void",
"handleInvalidCORS",
"(",
"final",
"HttpServletRequest",
"request",
",",
"final",
"HttpServletResponse",
"response",
",",
"final",
"FilterChain",
"filterChain",
")",
"{",
"String",
"origin",
"=",
"request",
".",
"getHeader",
"(",
"CorsFilter",
".",
"REQUEST_HEADER_ORIGIN",
")",
";",
"String",
"method",
"=",
"request",
".",
"getMethod",
"(",
")",
";",
"String",
"accessControlRequestHeaders",
"=",
"request",
".",
"getHeader",
"(",
"REQUEST_HEADER_ACCESS_CONTROL_REQUEST_HEADERS",
")",
";",
"response",
".",
"setContentType",
"(",
"\"text/plain\"",
")",
";",
"response",
".",
"setStatus",
"(",
"HttpServletResponse",
".",
"SC_FORBIDDEN",
")",
";",
"response",
".",
"resetBuffer",
"(",
")",
";",
"if",
"(",
"log",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"// Debug so no need for i18n\r",
"StringBuilder",
"message",
"=",
"new",
"StringBuilder",
"(",
"\"Invalid CORS request; Origin=\"",
")",
";",
"message",
".",
"append",
"(",
"origin",
")",
";",
"message",
".",
"append",
"(",
"\";Method=\"",
")",
";",
"message",
".",
"append",
"(",
"method",
")",
";",
"if",
"(",
"accessControlRequestHeaders",
"!=",
"null",
")",
"{",
"message",
".",
"append",
"(",
"\";Access-Control-Request-Headers=\"",
")",
";",
"message",
".",
"append",
"(",
"accessControlRequestHeaders",
")",
";",
"}",
"log",
".",
"debug",
"(",
"message",
".",
"toString",
"(",
")",
")",
";",
"}",
"}"
] |
Handles a CORS request that violates specification.
@param request
The {@link HttpServletRequest} object.
@param response
The {@link HttpServletResponse} object.
@param filterChain
The {@link FilterChain} object.
|
[
"Handles",
"a",
"CORS",
"request",
"that",
"violates",
"specification",
"."
] |
train
|
https://github.com/xfcjscn/sudoor-server-lib/blob/37dc1996eaa9cad25c82abd1de315ba565e32097/src/main/java/net/gplatform/sudoor/server/cors/CorsFilter.java#L444-L465
|
jenkinsci/jenkins
|
core/src/main/java/jenkins/model/ParameterizedJobMixIn.java
|
ParameterizedJobMixIn.getBuildCause
|
@Restricted(NoExternalUse.class)
public static CauseAction getBuildCause(ParameterizedJob job, StaplerRequest req) {
"""
Computes the build cause, using RemoteCause or UserCause as appropriate.
"""
Cause cause;
@SuppressWarnings("deprecation")
hudson.model.BuildAuthorizationToken authToken = job.getAuthToken();
if (authToken != null && authToken.getToken() != null && req.getParameter("token") != null) {
// Optional additional cause text when starting via token
String causeText = req.getParameter("cause");
cause = new Cause.RemoteCause(req.getRemoteAddr(), causeText);
} else {
cause = new Cause.UserIdCause();
}
return new CauseAction(cause);
}
|
java
|
@Restricted(NoExternalUse.class)
public static CauseAction getBuildCause(ParameterizedJob job, StaplerRequest req) {
Cause cause;
@SuppressWarnings("deprecation")
hudson.model.BuildAuthorizationToken authToken = job.getAuthToken();
if (authToken != null && authToken.getToken() != null && req.getParameter("token") != null) {
// Optional additional cause text when starting via token
String causeText = req.getParameter("cause");
cause = new Cause.RemoteCause(req.getRemoteAddr(), causeText);
} else {
cause = new Cause.UserIdCause();
}
return new CauseAction(cause);
}
|
[
"@",
"Restricted",
"(",
"NoExternalUse",
".",
"class",
")",
"public",
"static",
"CauseAction",
"getBuildCause",
"(",
"ParameterizedJob",
"job",
",",
"StaplerRequest",
"req",
")",
"{",
"Cause",
"cause",
";",
"@",
"SuppressWarnings",
"(",
"\"deprecation\"",
")",
"hudson",
".",
"model",
".",
"BuildAuthorizationToken",
"authToken",
"=",
"job",
".",
"getAuthToken",
"(",
")",
";",
"if",
"(",
"authToken",
"!=",
"null",
"&&",
"authToken",
".",
"getToken",
"(",
")",
"!=",
"null",
"&&",
"req",
".",
"getParameter",
"(",
"\"token\"",
")",
"!=",
"null",
")",
"{",
"// Optional additional cause text when starting via token",
"String",
"causeText",
"=",
"req",
".",
"getParameter",
"(",
"\"cause\"",
")",
";",
"cause",
"=",
"new",
"Cause",
".",
"RemoteCause",
"(",
"req",
".",
"getRemoteAddr",
"(",
")",
",",
"causeText",
")",
";",
"}",
"else",
"{",
"cause",
"=",
"new",
"Cause",
".",
"UserIdCause",
"(",
")",
";",
"}",
"return",
"new",
"CauseAction",
"(",
"cause",
")",
";",
"}"
] |
Computes the build cause, using RemoteCause or UserCause as appropriate.
|
[
"Computes",
"the",
"build",
"cause",
"using",
"RemoteCause",
"or",
"UserCause",
"as",
"appropriate",
"."
] |
train
|
https://github.com/jenkinsci/jenkins/blob/44c4d3989232082c254d27ae360aa810669f44b7/core/src/main/java/jenkins/model/ParameterizedJobMixIn.java#L268-L281
|
Netflix/Nicobar
|
nicobar-core/src/main/java/com/netflix/nicobar/core/module/jboss/JBossModuleUtils.java
|
JBossModuleUtils.buildFilters
|
private static PathFilter buildFilters(Set<String> filterPaths, boolean failedMatchValue) {
"""
Build a PathFilter for a set of filter paths
@param filterPaths the set of paths to filter on.
Can be null to indicate that no filters should be applied (accept all),
can be empty to indicate that everything should be filtered (reject all).
@param failedMatchValue the value the PathFilter returns when a path does not match.
@return a PathFilter.
"""
if (filterPaths == null)
return PathFilters.acceptAll();
else if (filterPaths.isEmpty()) {
return PathFilters.rejectAll();
} else {
MultiplePathFilterBuilder builder = PathFilters.multiplePathFilterBuilder(failedMatchValue);
for (String importPathGlob : filterPaths)
builder.addFilter(PathFilters.match(importPathGlob), !failedMatchValue);
return builder.create();
}
}
|
java
|
private static PathFilter buildFilters(Set<String> filterPaths, boolean failedMatchValue) {
if (filterPaths == null)
return PathFilters.acceptAll();
else if (filterPaths.isEmpty()) {
return PathFilters.rejectAll();
} else {
MultiplePathFilterBuilder builder = PathFilters.multiplePathFilterBuilder(failedMatchValue);
for (String importPathGlob : filterPaths)
builder.addFilter(PathFilters.match(importPathGlob), !failedMatchValue);
return builder.create();
}
}
|
[
"private",
"static",
"PathFilter",
"buildFilters",
"(",
"Set",
"<",
"String",
">",
"filterPaths",
",",
"boolean",
"failedMatchValue",
")",
"{",
"if",
"(",
"filterPaths",
"==",
"null",
")",
"return",
"PathFilters",
".",
"acceptAll",
"(",
")",
";",
"else",
"if",
"(",
"filterPaths",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"PathFilters",
".",
"rejectAll",
"(",
")",
";",
"}",
"else",
"{",
"MultiplePathFilterBuilder",
"builder",
"=",
"PathFilters",
".",
"multiplePathFilterBuilder",
"(",
"failedMatchValue",
")",
";",
"for",
"(",
"String",
"importPathGlob",
":",
"filterPaths",
")",
"builder",
".",
"addFilter",
"(",
"PathFilters",
".",
"match",
"(",
"importPathGlob",
")",
",",
"!",
"failedMatchValue",
")",
";",
"return",
"builder",
".",
"create",
"(",
")",
";",
"}",
"}"
] |
Build a PathFilter for a set of filter paths
@param filterPaths the set of paths to filter on.
Can be null to indicate that no filters should be applied (accept all),
can be empty to indicate that everything should be filtered (reject all).
@param failedMatchValue the value the PathFilter returns when a path does not match.
@return a PathFilter.
|
[
"Build",
"a",
"PathFilter",
"for",
"a",
"set",
"of",
"filter",
"paths"
] |
train
|
https://github.com/Netflix/Nicobar/blob/507173dcae4a86a955afc3df222a855862fab8d7/nicobar-core/src/main/java/com/netflix/nicobar/core/module/jboss/JBossModuleUtils.java#L297-L308
|
jsonld-java/jsonld-java
|
core/src/main/java/com/github/jsonldjava/core/RDFDataset.java
|
RDFDataset.addTriple
|
public void addTriple(final String subject, final String predicate, final String object) {
"""
Adds a triple to the default graph of this dataset
@param subject
the subject for the triple
@param predicate
the predicate for the triple
@param object
the object for the triple
"""
addQuad(subject, predicate, object, "@default");
}
|
java
|
public void addTriple(final String subject, final String predicate, final String object) {
addQuad(subject, predicate, object, "@default");
}
|
[
"public",
"void",
"addTriple",
"(",
"final",
"String",
"subject",
",",
"final",
"String",
"predicate",
",",
"final",
"String",
"object",
")",
"{",
"addQuad",
"(",
"subject",
",",
"predicate",
",",
"object",
",",
"\"@default\"",
")",
";",
"}"
] |
Adds a triple to the default graph of this dataset
@param subject
the subject for the triple
@param predicate
the predicate for the triple
@param object
the object for the triple
|
[
"Adds",
"a",
"triple",
"to",
"the",
"default",
"graph",
"of",
"this",
"dataset"
] |
train
|
https://github.com/jsonld-java/jsonld-java/blob/efeef6ee96029a0011649633457035fa6be42da1/core/src/main/java/com/github/jsonldjava/core/RDFDataset.java#L516-L518
|
code4everything/util
|
src/main/java/com/zhazhapan/util/encryption/SimpleEncrypt.java
|
SimpleEncrypt.xor
|
public static String xor(String string, String key) {
"""
异或加密
@param string {@link String}
@param key {@link String}
@return {@link String}
"""
return xor(string, CryptUtils.stringToKey(string));
}
|
java
|
public static String xor(String string, String key) {
return xor(string, CryptUtils.stringToKey(string));
}
|
[
"public",
"static",
"String",
"xor",
"(",
"String",
"string",
",",
"String",
"key",
")",
"{",
"return",
"xor",
"(",
"string",
",",
"CryptUtils",
".",
"stringToKey",
"(",
"string",
")",
")",
";",
"}"
] |
异或加密
@param string {@link String}
@param key {@link String}
@return {@link String}
|
[
"异或加密"
] |
train
|
https://github.com/code4everything/util/blob/1fc9f0ead1108f4d7208ba7c000df4244f708418/src/main/java/com/zhazhapan/util/encryption/SimpleEncrypt.java#L48-L50
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.monitor/src/com/ibm/ws/monitor/internal/ProbeManagerImpl.java
|
ProbeManagerImpl.removeInterestedByClass
|
synchronized void removeInterestedByClass(Class<?> clazz, ProbeListener listener) {
"""
Remove the specified listener from the collection of listeners with {@link ProbeFilter}s that match the specified class.
@param clazz the candidate probe source
@param listener the listener with a filter that matched {@code clazz}
"""
Set<ProbeListener> listeners = listenersByClass.get(clazz);
if (listeners != null) {
listeners.remove(listener);
if (listeners.isEmpty()) {
listenersByClass.remove(clazz);
}
}
}
|
java
|
synchronized void removeInterestedByClass(Class<?> clazz, ProbeListener listener) {
Set<ProbeListener> listeners = listenersByClass.get(clazz);
if (listeners != null) {
listeners.remove(listener);
if (listeners.isEmpty()) {
listenersByClass.remove(clazz);
}
}
}
|
[
"synchronized",
"void",
"removeInterestedByClass",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"ProbeListener",
"listener",
")",
"{",
"Set",
"<",
"ProbeListener",
">",
"listeners",
"=",
"listenersByClass",
".",
"get",
"(",
"clazz",
")",
";",
"if",
"(",
"listeners",
"!=",
"null",
")",
"{",
"listeners",
".",
"remove",
"(",
"listener",
")",
";",
"if",
"(",
"listeners",
".",
"isEmpty",
"(",
")",
")",
"{",
"listenersByClass",
".",
"remove",
"(",
"clazz",
")",
";",
"}",
"}",
"}"
] |
Remove the specified listener from the collection of listeners with {@link ProbeFilter}s that match the specified class.
@param clazz the candidate probe source
@param listener the listener with a filter that matched {@code clazz}
|
[
"Remove",
"the",
"specified",
"listener",
"from",
"the",
"collection",
"of",
"listeners",
"with",
"{",
"@link",
"ProbeFilter",
"}",
"s",
"that",
"match",
"the",
"specified",
"class",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.monitor/src/com/ibm/ws/monitor/internal/ProbeManagerImpl.java#L579-L587
|
lessthanoptimal/BoofCV
|
main/boofcv-feature/src/main/java/boofcv/alg/feature/dense/DescribeDenseSiftAlg.java
|
DescribeDenseSiftAlg.setImageGradient
|
public void setImageGradient(D derivX , D derivY ) {
"""
Sets the gradient and precomputes pixel orientation and magnitude
@param derivX image derivative x-axis
@param derivY image derivative y-axis
"""
InputSanityCheck.checkSameShape(derivX,derivY);
if( derivX.stride != derivY.stride || derivX.startIndex != derivY.startIndex )
throw new IllegalArgumentException("stride and start index must be the same");
savedAngle.reshape(derivX.width,derivX.height);
savedMagnitude.reshape(derivX.width,derivX.height);
imageDerivX.wrap(derivX);
imageDerivY.wrap(derivY);
precomputeAngles(derivX);
}
|
java
|
public void setImageGradient(D derivX , D derivY ) {
InputSanityCheck.checkSameShape(derivX,derivY);
if( derivX.stride != derivY.stride || derivX.startIndex != derivY.startIndex )
throw new IllegalArgumentException("stride and start index must be the same");
savedAngle.reshape(derivX.width,derivX.height);
savedMagnitude.reshape(derivX.width,derivX.height);
imageDerivX.wrap(derivX);
imageDerivY.wrap(derivY);
precomputeAngles(derivX);
}
|
[
"public",
"void",
"setImageGradient",
"(",
"D",
"derivX",
",",
"D",
"derivY",
")",
"{",
"InputSanityCheck",
".",
"checkSameShape",
"(",
"derivX",
",",
"derivY",
")",
";",
"if",
"(",
"derivX",
".",
"stride",
"!=",
"derivY",
".",
"stride",
"||",
"derivX",
".",
"startIndex",
"!=",
"derivY",
".",
"startIndex",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"stride and start index must be the same\"",
")",
";",
"savedAngle",
".",
"reshape",
"(",
"derivX",
".",
"width",
",",
"derivX",
".",
"height",
")",
";",
"savedMagnitude",
".",
"reshape",
"(",
"derivX",
".",
"width",
",",
"derivX",
".",
"height",
")",
";",
"imageDerivX",
".",
"wrap",
"(",
"derivX",
")",
";",
"imageDerivY",
".",
"wrap",
"(",
"derivY",
")",
";",
"precomputeAngles",
"(",
"derivX",
")",
";",
"}"
] |
Sets the gradient and precomputes pixel orientation and magnitude
@param derivX image derivative x-axis
@param derivY image derivative y-axis
|
[
"Sets",
"the",
"gradient",
"and",
"precomputes",
"pixel",
"orientation",
"and",
"magnitude"
] |
train
|
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/dense/DescribeDenseSiftAlg.java#L103-L115
|
couchbase/java-dcp-client
|
src/main/java/com/couchbase/client/dcp/Client.java
|
Client.rollbackAndRestartStream
|
public Completable rollbackAndRestartStream(final short partition, final long seqno) {
"""
Helper method to rollback the partition state and stop/restart the stream.
<p>
The stream is stopped (if not already done). Then:
<p>
The rollback seqno state is applied. Note that this will also remove all the failover logs for the partition
that are higher than the given seqno, since the server told us we are ahead of it.
<p>
Finally, the stream is restarted again.
@param partition the partition id
@param seqno the sequence number to rollback to
"""
return stopStreaming(partition)
.andThen(Completable.create(new Completable.OnSubscribe() {
@Override
public void call(CompletableSubscriber subscriber) {
sessionState().rollbackToPosition(partition, seqno);
subscriber.onCompleted();
}
}))
.andThen(startStreaming(partition));
}
|
java
|
public Completable rollbackAndRestartStream(final short partition, final long seqno) {
return stopStreaming(partition)
.andThen(Completable.create(new Completable.OnSubscribe() {
@Override
public void call(CompletableSubscriber subscriber) {
sessionState().rollbackToPosition(partition, seqno);
subscriber.onCompleted();
}
}))
.andThen(startStreaming(partition));
}
|
[
"public",
"Completable",
"rollbackAndRestartStream",
"(",
"final",
"short",
"partition",
",",
"final",
"long",
"seqno",
")",
"{",
"return",
"stopStreaming",
"(",
"partition",
")",
".",
"andThen",
"(",
"Completable",
".",
"create",
"(",
"new",
"Completable",
".",
"OnSubscribe",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"call",
"(",
"CompletableSubscriber",
"subscriber",
")",
"{",
"sessionState",
"(",
")",
".",
"rollbackToPosition",
"(",
"partition",
",",
"seqno",
")",
";",
"subscriber",
".",
"onCompleted",
"(",
")",
";",
"}",
"}",
")",
")",
".",
"andThen",
"(",
"startStreaming",
"(",
"partition",
")",
")",
";",
"}"
] |
Helper method to rollback the partition state and stop/restart the stream.
<p>
The stream is stopped (if not already done). Then:
<p>
The rollback seqno state is applied. Note that this will also remove all the failover logs for the partition
that are higher than the given seqno, since the server told us we are ahead of it.
<p>
Finally, the stream is restarted again.
@param partition the partition id
@param seqno the sequence number to rollback to
|
[
"Helper",
"method",
"to",
"rollback",
"the",
"partition",
"state",
"and",
"stop",
"/",
"restart",
"the",
"stream",
".",
"<p",
">",
"The",
"stream",
"is",
"stopped",
"(",
"if",
"not",
"already",
"done",
")",
".",
"Then",
":",
"<p",
">",
"The",
"rollback",
"seqno",
"state",
"is",
"applied",
".",
"Note",
"that",
"this",
"will",
"also",
"remove",
"all",
"the",
"failover",
"logs",
"for",
"the",
"partition",
"that",
"are",
"higher",
"than",
"the",
"given",
"seqno",
"since",
"the",
"server",
"told",
"us",
"we",
"are",
"ahead",
"of",
"it",
".",
"<p",
">",
"Finally",
"the",
"stream",
"is",
"restarted",
"again",
"."
] |
train
|
https://github.com/couchbase/java-dcp-client/blob/75359d8c081d6c575f8087cf7c28d24ab24c6421/src/main/java/com/couchbase/client/dcp/Client.java#L522-L532
|
hawkular/hawkular-agent
|
hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/inventory/ResourceManager.java
|
ResourceManager.getAllDescendants
|
private void getAllDescendants(Resource<L> parent, List<Resource<L>> descendants) {
"""
make sure you call this with a graph lock - either read or write
"""
for (Resource<L> child : getChildren(parent)) {
if (!descendants.contains(child)) {
getAllDescendants(child, descendants);
descendants.add(child);
}
}
return;
}
|
java
|
private void getAllDescendants(Resource<L> parent, List<Resource<L>> descendants) {
for (Resource<L> child : getChildren(parent)) {
if (!descendants.contains(child)) {
getAllDescendants(child, descendants);
descendants.add(child);
}
}
return;
}
|
[
"private",
"void",
"getAllDescendants",
"(",
"Resource",
"<",
"L",
">",
"parent",
",",
"List",
"<",
"Resource",
"<",
"L",
">",
">",
"descendants",
")",
"{",
"for",
"(",
"Resource",
"<",
"L",
">",
"child",
":",
"getChildren",
"(",
"parent",
")",
")",
"{",
"if",
"(",
"!",
"descendants",
".",
"contains",
"(",
"child",
")",
")",
"{",
"getAllDescendants",
"(",
"child",
",",
"descendants",
")",
";",
"descendants",
".",
"add",
"(",
"child",
")",
";",
"}",
"}",
"return",
";",
"}"
] |
make sure you call this with a graph lock - either read or write
|
[
"make",
"sure",
"you",
"call",
"this",
"with",
"a",
"graph",
"lock",
"-",
"either",
"read",
"or",
"write"
] |
train
|
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/inventory/ResourceManager.java#L537-L545
|
ironjacamar/ironjacamar
|
codegenerator/src/main/java/org/ironjacamar/codegenerator/BaseProfile.java
|
BaseProfile.generateIronjacamarXml
|
void generateIronjacamarXml(Definition def, String outputDir) {
"""
generate ant ironjacamar.xml
@param def Definition
@param outputDir output directory
"""
try
{
String resourceDir = outputDir + File.separatorChar + "src" + File.separatorChar +
"main" + File.separatorChar + "resources";
writeIronjacamarXml(def, resourceDir);
if (def.getBuild().equals("maven"))
{
String rarDir = outputDir + File.separatorChar + "src" + File.separatorChar +
"main" + File.separatorChar + "rar";
writeIronjacamarXml(def, rarDir);
}
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
}
|
java
|
void generateIronjacamarXml(Definition def, String outputDir)
{
try
{
String resourceDir = outputDir + File.separatorChar + "src" + File.separatorChar +
"main" + File.separatorChar + "resources";
writeIronjacamarXml(def, resourceDir);
if (def.getBuild().equals("maven"))
{
String rarDir = outputDir + File.separatorChar + "src" + File.separatorChar +
"main" + File.separatorChar + "rar";
writeIronjacamarXml(def, rarDir);
}
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
}
|
[
"void",
"generateIronjacamarXml",
"(",
"Definition",
"def",
",",
"String",
"outputDir",
")",
"{",
"try",
"{",
"String",
"resourceDir",
"=",
"outputDir",
"+",
"File",
".",
"separatorChar",
"+",
"\"src\"",
"+",
"File",
".",
"separatorChar",
"+",
"\"main\"",
"+",
"File",
".",
"separatorChar",
"+",
"\"resources\"",
";",
"writeIronjacamarXml",
"(",
"def",
",",
"resourceDir",
")",
";",
"if",
"(",
"def",
".",
"getBuild",
"(",
")",
".",
"equals",
"(",
"\"maven\"",
")",
")",
"{",
"String",
"rarDir",
"=",
"outputDir",
"+",
"File",
".",
"separatorChar",
"+",
"\"src\"",
"+",
"File",
".",
"separatorChar",
"+",
"\"main\"",
"+",
"File",
".",
"separatorChar",
"+",
"\"rar\"",
";",
"writeIronjacamarXml",
"(",
"def",
",",
"rarDir",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"ioe",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}"
] |
generate ant ironjacamar.xml
@param def Definition
@param outputDir output directory
|
[
"generate",
"ant",
"ironjacamar",
".",
"xml"
] |
train
|
https://github.com/ironjacamar/ironjacamar/blob/f0389ee7e62aa8b40ba09b251edad76d220ea796/codegenerator/src/main/java/org/ironjacamar/codegenerator/BaseProfile.java#L468-L487
|
kaazing/gateway
|
mina.netty/src/main/java/org/kaazing/mina/netty/channel/DefaultChannelFutureEx.java
|
DefaultChannelFutureEx.reset
|
public synchronized void reset(Channel channel, boolean cancellable) {
"""
Creates a new instance.
@param channel
the {@link Channel} associated with this future
@param cancellable
{@code true} if and only if this future can be canceled
"""
this.channel = channel;
this.cancellable = cancellable;
assert this.firstListener == null;
assert this.otherListeners == null || this.otherListeners.isEmpty();
assert this.progressListeners == null || this.progressListeners.isEmpty();
this.done = false;
this.cause = null;
assert this.waiters == 0;
}
|
java
|
public synchronized void reset(Channel channel, boolean cancellable) {
this.channel = channel;
this.cancellable = cancellable;
assert this.firstListener == null;
assert this.otherListeners == null || this.otherListeners.isEmpty();
assert this.progressListeners == null || this.progressListeners.isEmpty();
this.done = false;
this.cause = null;
assert this.waiters == 0;
}
|
[
"public",
"synchronized",
"void",
"reset",
"(",
"Channel",
"channel",
",",
"boolean",
"cancellable",
")",
"{",
"this",
".",
"channel",
"=",
"channel",
";",
"this",
".",
"cancellable",
"=",
"cancellable",
";",
"assert",
"this",
".",
"firstListener",
"==",
"null",
";",
"assert",
"this",
".",
"otherListeners",
"==",
"null",
"||",
"this",
".",
"otherListeners",
".",
"isEmpty",
"(",
")",
";",
"assert",
"this",
".",
"progressListeners",
"==",
"null",
"||",
"this",
".",
"progressListeners",
".",
"isEmpty",
"(",
")",
";",
"this",
".",
"done",
"=",
"false",
";",
"this",
".",
"cause",
"=",
"null",
";",
"assert",
"this",
".",
"waiters",
"==",
"0",
";",
"}"
] |
Creates a new instance.
@param channel
the {@link Channel} associated with this future
@param cancellable
{@code true} if and only if this future can be canceled
|
[
"Creates",
"a",
"new",
"instance",
"."
] |
train
|
https://github.com/kaazing/gateway/blob/06017b19273109b3b992e528e702586446168d57/mina.netty/src/main/java/org/kaazing/mina/netty/channel/DefaultChannelFutureEx.java#L72-L82
|
elvishew/xLog
|
library/src/main/java/com/elvishew/xlog/flattener/PatternFlattener.java
|
PatternFlattener.parseTagParameter
|
static TagFiller parseTagParameter(String wrappedParameter, String trimmedParameter) {
"""
Try to create a tag filler if the given parameter is a tag parameter.
@return created tag filler, or null if the given parameter is not a tag parameter
"""
if (trimmedParameter.equals(PARAMETER_TAG)) {
return new TagFiller(wrappedParameter, trimmedParameter);
}
return null;
}
|
java
|
static TagFiller parseTagParameter(String wrappedParameter, String trimmedParameter) {
if (trimmedParameter.equals(PARAMETER_TAG)) {
return new TagFiller(wrappedParameter, trimmedParameter);
}
return null;
}
|
[
"static",
"TagFiller",
"parseTagParameter",
"(",
"String",
"wrappedParameter",
",",
"String",
"trimmedParameter",
")",
"{",
"if",
"(",
"trimmedParameter",
".",
"equals",
"(",
"PARAMETER_TAG",
")",
")",
"{",
"return",
"new",
"TagFiller",
"(",
"wrappedParameter",
",",
"trimmedParameter",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Try to create a tag filler if the given parameter is a tag parameter.
@return created tag filler, or null if the given parameter is not a tag parameter
|
[
"Try",
"to",
"create",
"a",
"tag",
"filler",
"if",
"the",
"given",
"parameter",
"is",
"a",
"tag",
"parameter",
"."
] |
train
|
https://github.com/elvishew/xLog/blob/c6fb95555ce619d3e527f5ba6c45d4d247c5a838/library/src/main/java/com/elvishew/xlog/flattener/PatternFlattener.java#L221-L226
|
alkacon/opencms-core
|
src/org/opencms/ui/A_CmsUI.java
|
A_CmsUI.setContentToDialog
|
public void setContentToDialog(String caption, CmsBasicDialog dialog) {
"""
Replaces the ui content with a single dialog.<p>
@param caption the caption
@param dialog the dialog content
"""
setContent(new Label());
Window window = CmsBasicDialog.prepareWindow(DialogWidth.narrow);
window.setContent(dialog);
window.setCaption(caption);
window.setClosable(false);
addWindow(window);
window.center();
}
|
java
|
public void setContentToDialog(String caption, CmsBasicDialog dialog) {
setContent(new Label());
Window window = CmsBasicDialog.prepareWindow(DialogWidth.narrow);
window.setContent(dialog);
window.setCaption(caption);
window.setClosable(false);
addWindow(window);
window.center();
}
|
[
"public",
"void",
"setContentToDialog",
"(",
"String",
"caption",
",",
"CmsBasicDialog",
"dialog",
")",
"{",
"setContent",
"(",
"new",
"Label",
"(",
")",
")",
";",
"Window",
"window",
"=",
"CmsBasicDialog",
".",
"prepareWindow",
"(",
"DialogWidth",
".",
"narrow",
")",
";",
"window",
".",
"setContent",
"(",
"dialog",
")",
";",
"window",
".",
"setCaption",
"(",
"caption",
")",
";",
"window",
".",
"setClosable",
"(",
"false",
")",
";",
"addWindow",
"(",
"window",
")",
";",
"window",
".",
"center",
"(",
")",
";",
"}"
] |
Replaces the ui content with a single dialog.<p>
@param caption the caption
@param dialog the dialog content
|
[
"Replaces",
"the",
"ui",
"content",
"with",
"a",
"single",
"dialog",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/A_CmsUI.java#L278-L287
|
ykrasik/jaci
|
jaci-cli-core/src/main/java/com/github/ykrasik/jaci/cli/assist/AutoComplete.java
|
AutoComplete.union
|
public AutoComplete union(AutoComplete other) {
"""
Create a new auto-complete by merging this auto-complete with the given auto-complete.
The resulting auto-complete will contain possibilities from both this and the given auto-complete.
@param other Auto-complete to merge with.
@return A merged auto-complete containing possibilities from both this and the given auto-complete.
"""
if (possibilities.isEmpty()) {
return other;
}
if (other.possibilities.isEmpty()) {
return this;
}
// TODO: Make sure this can't happen.
if (!this.prefix.equals(other.prefix)) {
throw new IllegalArgumentException("Trying to perform union on different prefixes: prefix1='"+this.prefix+"', prefix2='"+other.prefix+'\'');
}
final Trie<CliValueType> unifiedPossibilities = this.possibilities.union(other.possibilities);
return new AutoComplete(prefix, unifiedPossibilities);
}
|
java
|
public AutoComplete union(AutoComplete other) {
if (possibilities.isEmpty()) {
return other;
}
if (other.possibilities.isEmpty()) {
return this;
}
// TODO: Make sure this can't happen.
if (!this.prefix.equals(other.prefix)) {
throw new IllegalArgumentException("Trying to perform union on different prefixes: prefix1='"+this.prefix+"', prefix2='"+other.prefix+'\'');
}
final Trie<CliValueType> unifiedPossibilities = this.possibilities.union(other.possibilities);
return new AutoComplete(prefix, unifiedPossibilities);
}
|
[
"public",
"AutoComplete",
"union",
"(",
"AutoComplete",
"other",
")",
"{",
"if",
"(",
"possibilities",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"other",
";",
"}",
"if",
"(",
"other",
".",
"possibilities",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"this",
";",
"}",
"// TODO: Make sure this can't happen.",
"if",
"(",
"!",
"this",
".",
"prefix",
".",
"equals",
"(",
"other",
".",
"prefix",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Trying to perform union on different prefixes: prefix1='\"",
"+",
"this",
".",
"prefix",
"+",
"\"', prefix2='\"",
"+",
"other",
".",
"prefix",
"+",
"'",
"'",
")",
";",
"}",
"final",
"Trie",
"<",
"CliValueType",
">",
"unifiedPossibilities",
"=",
"this",
".",
"possibilities",
".",
"union",
"(",
"other",
".",
"possibilities",
")",
";",
"return",
"new",
"AutoComplete",
"(",
"prefix",
",",
"unifiedPossibilities",
")",
";",
"}"
] |
Create a new auto-complete by merging this auto-complete with the given auto-complete.
The resulting auto-complete will contain possibilities from both this and the given auto-complete.
@param other Auto-complete to merge with.
@return A merged auto-complete containing possibilities from both this and the given auto-complete.
|
[
"Create",
"a",
"new",
"auto",
"-",
"complete",
"by",
"merging",
"this",
"auto",
"-",
"complete",
"with",
"the",
"given",
"auto",
"-",
"complete",
".",
"The",
"resulting",
"auto",
"-",
"complete",
"will",
"contain",
"possibilities",
"from",
"both",
"this",
"and",
"the",
"given",
"auto",
"-",
"complete",
"."
] |
train
|
https://github.com/ykrasik/jaci/blob/4615edef7c76288ad5ea8d678132b161645ca1e3/jaci-cli-core/src/main/java/com/github/ykrasik/jaci/cli/assist/AutoComplete.java#L115-L130
|
alkacon/opencms-core
|
src/org/opencms/ui/error/CmsErrorUI.java
|
CmsErrorUI.getBootstrapPage
|
public static String getBootstrapPage(CmsObject cms, Throwable throwable, HttpServletRequest request) {
"""
Returns the error bootstrap page HTML.<p>
@param cms the cms context
@param throwable the throwable
@param request the current request
@return the error bootstrap page HTML
"""
try {
setErrorAttributes(cms, throwable, request);
byte[] pageBytes = CmsFileUtil.readFully(
Thread.currentThread().getContextClassLoader().getResourceAsStream(
"org/opencms/ui/error/error-page.html"));
String page = new String(pageBytes, "UTF-8");
CmsMacroResolver resolver = new CmsMacroResolver();
String context = OpenCms.getSystemInfo().getContextPath();
String vaadinDir = CmsStringUtil.joinPaths(context, "VAADIN/");
String vaadinVersion = Version.getFullVersion();
String vaadinServlet = CmsStringUtil.joinPaths(context, "workplace/", ERROR_PAGE_PATH_FRAQUMENT);
String vaadinBootstrap = CmsStringUtil.joinPaths(context, "VAADIN/vaadinBootstrap.js");
resolver.addMacro("loadingHtml", CmsVaadinConstants.LOADING_INDICATOR_HTML);
resolver.addMacro("vaadinDir", vaadinDir);
resolver.addMacro("vaadinVersion", vaadinVersion);
resolver.addMacro("vaadinServlet", vaadinServlet);
resolver.addMacro("vaadinBootstrap", vaadinBootstrap);
resolver.addMacro("title", "Error page");
page = resolver.resolveMacros(page);
return page;
} catch (Exception e) {
LOG.error("Failed to display error page.", e);
return "<!--Error-->";
}
}
|
java
|
public static String getBootstrapPage(CmsObject cms, Throwable throwable, HttpServletRequest request) {
try {
setErrorAttributes(cms, throwable, request);
byte[] pageBytes = CmsFileUtil.readFully(
Thread.currentThread().getContextClassLoader().getResourceAsStream(
"org/opencms/ui/error/error-page.html"));
String page = new String(pageBytes, "UTF-8");
CmsMacroResolver resolver = new CmsMacroResolver();
String context = OpenCms.getSystemInfo().getContextPath();
String vaadinDir = CmsStringUtil.joinPaths(context, "VAADIN/");
String vaadinVersion = Version.getFullVersion();
String vaadinServlet = CmsStringUtil.joinPaths(context, "workplace/", ERROR_PAGE_PATH_FRAQUMENT);
String vaadinBootstrap = CmsStringUtil.joinPaths(context, "VAADIN/vaadinBootstrap.js");
resolver.addMacro("loadingHtml", CmsVaadinConstants.LOADING_INDICATOR_HTML);
resolver.addMacro("vaadinDir", vaadinDir);
resolver.addMacro("vaadinVersion", vaadinVersion);
resolver.addMacro("vaadinServlet", vaadinServlet);
resolver.addMacro("vaadinBootstrap", vaadinBootstrap);
resolver.addMacro("title", "Error page");
page = resolver.resolveMacros(page);
return page;
} catch (Exception e) {
LOG.error("Failed to display error page.", e);
return "<!--Error-->";
}
}
|
[
"public",
"static",
"String",
"getBootstrapPage",
"(",
"CmsObject",
"cms",
",",
"Throwable",
"throwable",
",",
"HttpServletRequest",
"request",
")",
"{",
"try",
"{",
"setErrorAttributes",
"(",
"cms",
",",
"throwable",
",",
"request",
")",
";",
"byte",
"[",
"]",
"pageBytes",
"=",
"CmsFileUtil",
".",
"readFully",
"(",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
".",
"getResourceAsStream",
"(",
"\"org/opencms/ui/error/error-page.html\"",
")",
")",
";",
"String",
"page",
"=",
"new",
"String",
"(",
"pageBytes",
",",
"\"UTF-8\"",
")",
";",
"CmsMacroResolver",
"resolver",
"=",
"new",
"CmsMacroResolver",
"(",
")",
";",
"String",
"context",
"=",
"OpenCms",
".",
"getSystemInfo",
"(",
")",
".",
"getContextPath",
"(",
")",
";",
"String",
"vaadinDir",
"=",
"CmsStringUtil",
".",
"joinPaths",
"(",
"context",
",",
"\"VAADIN/\"",
")",
";",
"String",
"vaadinVersion",
"=",
"Version",
".",
"getFullVersion",
"(",
")",
";",
"String",
"vaadinServlet",
"=",
"CmsStringUtil",
".",
"joinPaths",
"(",
"context",
",",
"\"workplace/\"",
",",
"ERROR_PAGE_PATH_FRAQUMENT",
")",
";",
"String",
"vaadinBootstrap",
"=",
"CmsStringUtil",
".",
"joinPaths",
"(",
"context",
",",
"\"VAADIN/vaadinBootstrap.js\"",
")",
";",
"resolver",
".",
"addMacro",
"(",
"\"loadingHtml\"",
",",
"CmsVaadinConstants",
".",
"LOADING_INDICATOR_HTML",
")",
";",
"resolver",
".",
"addMacro",
"(",
"\"vaadinDir\"",
",",
"vaadinDir",
")",
";",
"resolver",
".",
"addMacro",
"(",
"\"vaadinVersion\"",
",",
"vaadinVersion",
")",
";",
"resolver",
".",
"addMacro",
"(",
"\"vaadinServlet\"",
",",
"vaadinServlet",
")",
";",
"resolver",
".",
"addMacro",
"(",
"\"vaadinBootstrap\"",
",",
"vaadinBootstrap",
")",
";",
"resolver",
".",
"addMacro",
"(",
"\"title\"",
",",
"\"Error page\"",
")",
";",
"page",
"=",
"resolver",
".",
"resolveMacros",
"(",
"page",
")",
";",
"return",
"page",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Failed to display error page.\"",
",",
"e",
")",
";",
"return",
"\"<!--Error-->\"",
";",
"}",
"}"
] |
Returns the error bootstrap page HTML.<p>
@param cms the cms context
@param throwable the throwable
@param request the current request
@return the error bootstrap page HTML
|
[
"Returns",
"the",
"error",
"bootstrap",
"page",
"HTML",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/error/CmsErrorUI.java#L93-L122
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java
|
ApiOvhTelephony.billingAccount_line_serviceName_phone_phonebook_bookKey_PUT
|
public void billingAccount_line_serviceName_phone_phonebook_bookKey_PUT(String billingAccount, String serviceName, String bookKey, OvhPhonebook body) throws IOException {
"""
Alter this object properties
REST: PUT /telephony/{billingAccount}/line/{serviceName}/phone/phonebook/{bookKey}
@param body [required] New object properties
@param billingAccount [required] The name of your billingAccount
@param serviceName [required]
@param bookKey [required] Identifier of the phonebook
"""
String qPath = "/telephony/{billingAccount}/line/{serviceName}/phone/phonebook/{bookKey}";
StringBuilder sb = path(qPath, billingAccount, serviceName, bookKey);
exec(qPath, "PUT", sb.toString(), body);
}
|
java
|
public void billingAccount_line_serviceName_phone_phonebook_bookKey_PUT(String billingAccount, String serviceName, String bookKey, OvhPhonebook body) throws IOException {
String qPath = "/telephony/{billingAccount}/line/{serviceName}/phone/phonebook/{bookKey}";
StringBuilder sb = path(qPath, billingAccount, serviceName, bookKey);
exec(qPath, "PUT", sb.toString(), body);
}
|
[
"public",
"void",
"billingAccount_line_serviceName_phone_phonebook_bookKey_PUT",
"(",
"String",
"billingAccount",
",",
"String",
"serviceName",
",",
"String",
"bookKey",
",",
"OvhPhonebook",
"body",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/telephony/{billingAccount}/line/{serviceName}/phone/phonebook/{bookKey}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"billingAccount",
",",
"serviceName",
",",
"bookKey",
")",
";",
"exec",
"(",
"qPath",
",",
"\"PUT\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"body",
")",
";",
"}"
] |
Alter this object properties
REST: PUT /telephony/{billingAccount}/line/{serviceName}/phone/phonebook/{bookKey}
@param body [required] New object properties
@param billingAccount [required] The name of your billingAccount
@param serviceName [required]
@param bookKey [required] Identifier of the phonebook
|
[
"Alter",
"this",
"object",
"properties"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L1259-L1263
|
Axway/Grapes
|
utils/src/main/java/org/axway/grapes/utils/client/GrapesClient.java
|
GrapesClient.getModules
|
public List<Module> getModules(final Map<String, String> filters) throws GrapesCommunicationException {
"""
Get a list of modules regarding filters
@param filters Map<String,String>
@return List<Module>
@throws GrapesCommunicationException
"""
final Client client = getClient();
WebResource resource = client.resource(serverURL).path(RequestUtils.getAllModulesPath());
for(final Map.Entry<String,String> queryParam: filters.entrySet()){
resource = resource.queryParam(queryParam.getKey(), queryParam.getValue());
}
final ClientResponse response = resource.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
client.destroy();
if(ClientResponse.Status.OK.getStatusCode() != response.getStatus()){
final String message = "Failed to get filtered modules.";
if(LOG.isErrorEnabled()) {
LOG.error(String.format(HTTP_STATUS_TEMPLATE_MSG, message, response.getStatus()));
}
throw new GrapesCommunicationException(message, response.getStatus());
}
return response.getEntity(new GenericType<List<Module>>(){});
}
|
java
|
public List<Module> getModules(final Map<String, String> filters) throws GrapesCommunicationException {
final Client client = getClient();
WebResource resource = client.resource(serverURL).path(RequestUtils.getAllModulesPath());
for(final Map.Entry<String,String> queryParam: filters.entrySet()){
resource = resource.queryParam(queryParam.getKey(), queryParam.getValue());
}
final ClientResponse response = resource.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
client.destroy();
if(ClientResponse.Status.OK.getStatusCode() != response.getStatus()){
final String message = "Failed to get filtered modules.";
if(LOG.isErrorEnabled()) {
LOG.error(String.format(HTTP_STATUS_TEMPLATE_MSG, message, response.getStatus()));
}
throw new GrapesCommunicationException(message, response.getStatus());
}
return response.getEntity(new GenericType<List<Module>>(){});
}
|
[
"public",
"List",
"<",
"Module",
">",
"getModules",
"(",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"filters",
")",
"throws",
"GrapesCommunicationException",
"{",
"final",
"Client",
"client",
"=",
"getClient",
"(",
")",
";",
"WebResource",
"resource",
"=",
"client",
".",
"resource",
"(",
"serverURL",
")",
".",
"path",
"(",
"RequestUtils",
".",
"getAllModulesPath",
"(",
")",
")",
";",
"for",
"(",
"final",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"queryParam",
":",
"filters",
".",
"entrySet",
"(",
")",
")",
"{",
"resource",
"=",
"resource",
".",
"queryParam",
"(",
"queryParam",
".",
"getKey",
"(",
")",
",",
"queryParam",
".",
"getValue",
"(",
")",
")",
";",
"}",
"final",
"ClientResponse",
"response",
"=",
"resource",
".",
"accept",
"(",
"MediaType",
".",
"APPLICATION_JSON",
")",
".",
"get",
"(",
"ClientResponse",
".",
"class",
")",
";",
"client",
".",
"destroy",
"(",
")",
";",
"if",
"(",
"ClientResponse",
".",
"Status",
".",
"OK",
".",
"getStatusCode",
"(",
")",
"!=",
"response",
".",
"getStatus",
"(",
")",
")",
"{",
"final",
"String",
"message",
"=",
"\"Failed to get filtered modules.\"",
";",
"if",
"(",
"LOG",
".",
"isErrorEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"error",
"(",
"String",
".",
"format",
"(",
"HTTP_STATUS_TEMPLATE_MSG",
",",
"message",
",",
"response",
".",
"getStatus",
"(",
")",
")",
")",
";",
"}",
"throw",
"new",
"GrapesCommunicationException",
"(",
"message",
",",
"response",
".",
"getStatus",
"(",
")",
")",
";",
"}",
"return",
"response",
".",
"getEntity",
"(",
"new",
"GenericType",
"<",
"List",
"<",
"Module",
">",
">",
"(",
")",
"{",
"}",
")",
";",
"}"
] |
Get a list of modules regarding filters
@param filters Map<String,String>
@return List<Module>
@throws GrapesCommunicationException
|
[
"Get",
"a",
"list",
"of",
"modules",
"regarding",
"filters"
] |
train
|
https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/utils/src/main/java/org/axway/grapes/utils/client/GrapesClient.java#L249-L268
|
netty/netty
|
codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyStreamStatus.java
|
SpdyStreamStatus.valueOf
|
public static SpdyStreamStatus valueOf(int code) {
"""
Returns the {@link SpdyStreamStatus} represented by the specified code.
If the specified code is a defined SPDY status code, a cached instance
will be returned. Otherwise, a new instance will be returned.
"""
if (code == 0) {
throw new IllegalArgumentException(
"0 is not a valid status code for a RST_STREAM");
}
switch (code) {
case 1:
return PROTOCOL_ERROR;
case 2:
return INVALID_STREAM;
case 3:
return REFUSED_STREAM;
case 4:
return UNSUPPORTED_VERSION;
case 5:
return CANCEL;
case 6:
return INTERNAL_ERROR;
case 7:
return FLOW_CONTROL_ERROR;
case 8:
return STREAM_IN_USE;
case 9:
return STREAM_ALREADY_CLOSED;
case 10:
return INVALID_CREDENTIALS;
case 11:
return FRAME_TOO_LARGE;
}
return new SpdyStreamStatus(code, "UNKNOWN (" + code + ')');
}
|
java
|
public static SpdyStreamStatus valueOf(int code) {
if (code == 0) {
throw new IllegalArgumentException(
"0 is not a valid status code for a RST_STREAM");
}
switch (code) {
case 1:
return PROTOCOL_ERROR;
case 2:
return INVALID_STREAM;
case 3:
return REFUSED_STREAM;
case 4:
return UNSUPPORTED_VERSION;
case 5:
return CANCEL;
case 6:
return INTERNAL_ERROR;
case 7:
return FLOW_CONTROL_ERROR;
case 8:
return STREAM_IN_USE;
case 9:
return STREAM_ALREADY_CLOSED;
case 10:
return INVALID_CREDENTIALS;
case 11:
return FRAME_TOO_LARGE;
}
return new SpdyStreamStatus(code, "UNKNOWN (" + code + ')');
}
|
[
"public",
"static",
"SpdyStreamStatus",
"valueOf",
"(",
"int",
"code",
")",
"{",
"if",
"(",
"code",
"==",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"0 is not a valid status code for a RST_STREAM\"",
")",
";",
"}",
"switch",
"(",
"code",
")",
"{",
"case",
"1",
":",
"return",
"PROTOCOL_ERROR",
";",
"case",
"2",
":",
"return",
"INVALID_STREAM",
";",
"case",
"3",
":",
"return",
"REFUSED_STREAM",
";",
"case",
"4",
":",
"return",
"UNSUPPORTED_VERSION",
";",
"case",
"5",
":",
"return",
"CANCEL",
";",
"case",
"6",
":",
"return",
"INTERNAL_ERROR",
";",
"case",
"7",
":",
"return",
"FLOW_CONTROL_ERROR",
";",
"case",
"8",
":",
"return",
"STREAM_IN_USE",
";",
"case",
"9",
":",
"return",
"STREAM_ALREADY_CLOSED",
";",
"case",
"10",
":",
"return",
"INVALID_CREDENTIALS",
";",
"case",
"11",
":",
"return",
"FRAME_TOO_LARGE",
";",
"}",
"return",
"new",
"SpdyStreamStatus",
"(",
"code",
",",
"\"UNKNOWN (\"",
"+",
"code",
"+",
"'",
"'",
")",
";",
"}"
] |
Returns the {@link SpdyStreamStatus} represented by the specified code.
If the specified code is a defined SPDY status code, a cached instance
will be returned. Otherwise, a new instance will be returned.
|
[
"Returns",
"the",
"{"
] |
train
|
https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyStreamStatus.java#L94-L126
|
janus-project/guava.janusproject.io
|
guava/src/com/google/common/eventbus/EventBus.java
|
EventBus.handleSubscriberException
|
void handleSubscriberException(Throwable e, SubscriberExceptionContext context) {
"""
Handles the given exception thrown by a subscriber with the given context.
"""
checkNotNull(e);
checkNotNull(context);
try {
exceptionHandler.handleException(e, context);
} catch (Throwable e2) {
// if the handler threw an exception... well, just log it
logger.log(Level.SEVERE,
String.format("Exception %s thrown while handling exception: %s", e2, e), e2);
}
}
|
java
|
void handleSubscriberException(Throwable e, SubscriberExceptionContext context) {
checkNotNull(e);
checkNotNull(context);
try {
exceptionHandler.handleException(e, context);
} catch (Throwable e2) {
// if the handler threw an exception... well, just log it
logger.log(Level.SEVERE,
String.format("Exception %s thrown while handling exception: %s", e2, e), e2);
}
}
|
[
"void",
"handleSubscriberException",
"(",
"Throwable",
"e",
",",
"SubscriberExceptionContext",
"context",
")",
"{",
"checkNotNull",
"(",
"e",
")",
";",
"checkNotNull",
"(",
"context",
")",
";",
"try",
"{",
"exceptionHandler",
".",
"handleException",
"(",
"e",
",",
"context",
")",
";",
"}",
"catch",
"(",
"Throwable",
"e2",
")",
"{",
"// if the handler threw an exception... well, just log it",
"logger",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"String",
".",
"format",
"(",
"\"Exception %s thrown while handling exception: %s\"",
",",
"e2",
",",
"e",
")",
",",
"e2",
")",
";",
"}",
"}"
] |
Handles the given exception thrown by a subscriber with the given context.
|
[
"Handles",
"the",
"given",
"exception",
"thrown",
"by",
"a",
"subscriber",
"with",
"the",
"given",
"context",
"."
] |
train
|
https://github.com/janus-project/guava.janusproject.io/blob/1c48fb672c9fdfddf276970570f703fa1115f588/guava/src/com/google/common/eventbus/EventBus.java#L215-L225
|
wisdom-framework/wisdom
|
core/wisdom-api/src/main/java/org/wisdom/api/router/AbstractRouter.java
|
AbstractRouter.getReverseRouteFor
|
@Override
public String getReverseRouteFor(Controller controller, String method, Map<String, Object> params) {
"""
Gets the url of the route handled by the specified action method. This
implementation delegates to {@link #getReverseRouteFor(java.lang.Class, String, java.util.Map)}.
@param controller the controller object
@param method the controller method
@param params map of parameter name - value
@return the url, {@literal null} if the action method is not found
"""
return getReverseRouteFor(controller.getClass(), method, params);
}
|
java
|
@Override
public String getReverseRouteFor(Controller controller, String method, Map<String, Object> params) {
return getReverseRouteFor(controller.getClass(), method, params);
}
|
[
"@",
"Override",
"public",
"String",
"getReverseRouteFor",
"(",
"Controller",
"controller",
",",
"String",
"method",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"params",
")",
"{",
"return",
"getReverseRouteFor",
"(",
"controller",
".",
"getClass",
"(",
")",
",",
"method",
",",
"params",
")",
";",
"}"
] |
Gets the url of the route handled by the specified action method. This
implementation delegates to {@link #getReverseRouteFor(java.lang.Class, String, java.util.Map)}.
@param controller the controller object
@param method the controller method
@param params map of parameter name - value
@return the url, {@literal null} if the action method is not found
|
[
"Gets",
"the",
"url",
"of",
"the",
"route",
"handled",
"by",
"the",
"specified",
"action",
"method",
".",
"This",
"implementation",
"delegates",
"to",
"{",
"@link",
"#getReverseRouteFor",
"(",
"java",
".",
"lang",
".",
"Class",
"String",
"java",
".",
"util",
".",
"Map",
")",
"}",
"."
] |
train
|
https://github.com/wisdom-framework/wisdom/blob/a35b6431200fec56b178c0ff60837ed73fd7874d/core/wisdom-api/src/main/java/org/wisdom/api/router/AbstractRouter.java#L115-L118
|
vkostyukov/la4j
|
src/main/java/org/la4j/Matrix.java
|
Matrix.foldColumn
|
public double foldColumn(int j, VectorAccumulator accumulator) {
"""
Folds all elements of specified column in this matrix with given {@code accumulator}.
@param j the column index
@param accumulator the vector accumulator
@return the accumulated value
"""
eachInColumn(j, Vectors.asAccumulatorProcedure(accumulator));
return accumulator.accumulate();
}
|
java
|
public double foldColumn(int j, VectorAccumulator accumulator) {
eachInColumn(j, Vectors.asAccumulatorProcedure(accumulator));
return accumulator.accumulate();
}
|
[
"public",
"double",
"foldColumn",
"(",
"int",
"j",
",",
"VectorAccumulator",
"accumulator",
")",
"{",
"eachInColumn",
"(",
"j",
",",
"Vectors",
".",
"asAccumulatorProcedure",
"(",
"accumulator",
")",
")",
";",
"return",
"accumulator",
".",
"accumulate",
"(",
")",
";",
"}"
] |
Folds all elements of specified column in this matrix with given {@code accumulator}.
@param j the column index
@param accumulator the vector accumulator
@return the accumulated value
|
[
"Folds",
"all",
"elements",
"of",
"specified",
"column",
"in",
"this",
"matrix",
"with",
"given",
"{",
"@code",
"accumulator",
"}",
"."
] |
train
|
https://github.com/vkostyukov/la4j/blob/dd1b917caf9606399a49afa6b0d738934cd3a7b3/src/main/java/org/la4j/Matrix.java#L1646-L1649
|
lshift/jamume
|
src/main/java/net/lshift/java/dispatch/ImplementsOnlyDirectSuperclasses.java
|
ImplementsOnlyDirectSuperclasses.directSuperclasses
|
public List<Class<?>> directSuperclasses(Class<?> c) {
"""
Get the direct superclasses of a class.
Interfaces, followed by the superclasses. Interfaces with
no super interfaces extend Object.
"""
if(c.isPrimitive()) {
return primitiveSuperclasses(c);
}
else if(c.isArray()) {
return arrayDirectSuperclasses(0, c);
}
else {
Class<?> [] interfaces = c.getInterfaces();
Class<?> superclass = c.getSuperclass();
List<Class<?>> classes = new LinkedList<Class<?>>();
classes.addAll(Arrays.asList(interfaces));
if(superclass == null) {
if(interfaces.length == 0 &&
c != Object.class)
classes.add(Object.class);
}
else {
classes.add(superclass);
}
return classes;
}
}
|
java
|
public List<Class<?>> directSuperclasses(Class<?> c)
{
if(c.isPrimitive()) {
return primitiveSuperclasses(c);
}
else if(c.isArray()) {
return arrayDirectSuperclasses(0, c);
}
else {
Class<?> [] interfaces = c.getInterfaces();
Class<?> superclass = c.getSuperclass();
List<Class<?>> classes = new LinkedList<Class<?>>();
classes.addAll(Arrays.asList(interfaces));
if(superclass == null) {
if(interfaces.length == 0 &&
c != Object.class)
classes.add(Object.class);
}
else {
classes.add(superclass);
}
return classes;
}
}
|
[
"public",
"List",
"<",
"Class",
"<",
"?",
">",
">",
"directSuperclasses",
"(",
"Class",
"<",
"?",
">",
"c",
")",
"{",
"if",
"(",
"c",
".",
"isPrimitive",
"(",
")",
")",
"{",
"return",
"primitiveSuperclasses",
"(",
"c",
")",
";",
"}",
"else",
"if",
"(",
"c",
".",
"isArray",
"(",
")",
")",
"{",
"return",
"arrayDirectSuperclasses",
"(",
"0",
",",
"c",
")",
";",
"}",
"else",
"{",
"Class",
"<",
"?",
">",
"[",
"]",
"interfaces",
"=",
"c",
".",
"getInterfaces",
"(",
")",
";",
"Class",
"<",
"?",
">",
"superclass",
"=",
"c",
".",
"getSuperclass",
"(",
")",
";",
"List",
"<",
"Class",
"<",
"?",
">",
">",
"classes",
"=",
"new",
"LinkedList",
"<",
"Class",
"<",
"?",
">",
">",
"(",
")",
";",
"classes",
".",
"addAll",
"(",
"Arrays",
".",
"asList",
"(",
"interfaces",
")",
")",
";",
"if",
"(",
"superclass",
"==",
"null",
")",
"{",
"if",
"(",
"interfaces",
".",
"length",
"==",
"0",
"&&",
"c",
"!=",
"Object",
".",
"class",
")",
"classes",
".",
"add",
"(",
"Object",
".",
"class",
")",
";",
"}",
"else",
"{",
"classes",
".",
"add",
"(",
"superclass",
")",
";",
"}",
"return",
"classes",
";",
"}",
"}"
] |
Get the direct superclasses of a class.
Interfaces, followed by the superclasses. Interfaces with
no super interfaces extend Object.
|
[
"Get",
"the",
"direct",
"superclasses",
"of",
"a",
"class",
".",
"Interfaces",
"followed",
"by",
"the",
"superclasses",
".",
"Interfaces",
"with",
"no",
"super",
"interfaces",
"extend",
"Object",
"."
] |
train
|
https://github.com/lshift/jamume/blob/754d9ab29311601328a2f39928775e4e010305b7/src/main/java/net/lshift/java/dispatch/ImplementsOnlyDirectSuperclasses.java#L23-L48
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.jmx.connector.server.rest/src/com/ibm/ws/jmx/connector/server/rest/handlers/FileStatusTaskPropertyHandler.java
|
FileStatusTaskPropertyHandler.taskProperties
|
private void taskProperties(RESTRequest request, RESTResponse response) {
"""
Returns the list of available properties and their corresponding URLs.
"""
String taskID = RESTHelper.getRequiredParam(request, APIConstants.PARAM_TASK_ID);
String taskPropertiesText = getMultipleRoutingHelper().getTaskProperties(taskID);
OutputHelper.writeTextOutput(response, taskPropertiesText);
}
|
java
|
private void taskProperties(RESTRequest request, RESTResponse response) {
String taskID = RESTHelper.getRequiredParam(request, APIConstants.PARAM_TASK_ID);
String taskPropertiesText = getMultipleRoutingHelper().getTaskProperties(taskID);
OutputHelper.writeTextOutput(response, taskPropertiesText);
}
|
[
"private",
"void",
"taskProperties",
"(",
"RESTRequest",
"request",
",",
"RESTResponse",
"response",
")",
"{",
"String",
"taskID",
"=",
"RESTHelper",
".",
"getRequiredParam",
"(",
"request",
",",
"APIConstants",
".",
"PARAM_TASK_ID",
")",
";",
"String",
"taskPropertiesText",
"=",
"getMultipleRoutingHelper",
"(",
")",
".",
"getTaskProperties",
"(",
"taskID",
")",
";",
"OutputHelper",
".",
"writeTextOutput",
"(",
"response",
",",
"taskPropertiesText",
")",
";",
"}"
] |
Returns the list of available properties and their corresponding URLs.
|
[
"Returns",
"the",
"list",
"of",
"available",
"properties",
"and",
"their",
"corresponding",
"URLs",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jmx.connector.server.rest/src/com/ibm/ws/jmx/connector/server/rest/handlers/FileStatusTaskPropertyHandler.java#L86-L91
|
kiegroup/drools
|
drools-core/src/main/java/org/drools/core/common/ConcurrentNodeMemories.java
|
ConcurrentNodeMemories.getNodeMemory
|
public Memory getNodeMemory(MemoryFactory node, InternalWorkingMemory wm) {
"""
The implementation tries to delay locking as much as possible, by running
some potentially unsafe operations out of the critical session. In case it
fails the checks, it will move into the critical sessions and re-check everything
before effectively doing any change on data structures.
"""
if( node.getMemoryId() >= this.memories.length() ) {
resize( node );
}
Memory memory = this.memories.get( node.getMemoryId() );
if( memory == null ) {
memory = createNodeMemory( node, wm );
}
return memory;
}
|
java
|
public Memory getNodeMemory(MemoryFactory node, InternalWorkingMemory wm) {
if( node.getMemoryId() >= this.memories.length() ) {
resize( node );
}
Memory memory = this.memories.get( node.getMemoryId() );
if( memory == null ) {
memory = createNodeMemory( node, wm );
}
return memory;
}
|
[
"public",
"Memory",
"getNodeMemory",
"(",
"MemoryFactory",
"node",
",",
"InternalWorkingMemory",
"wm",
")",
"{",
"if",
"(",
"node",
".",
"getMemoryId",
"(",
")",
">=",
"this",
".",
"memories",
".",
"length",
"(",
")",
")",
"{",
"resize",
"(",
"node",
")",
";",
"}",
"Memory",
"memory",
"=",
"this",
".",
"memories",
".",
"get",
"(",
"node",
".",
"getMemoryId",
"(",
")",
")",
";",
"if",
"(",
"memory",
"==",
"null",
")",
"{",
"memory",
"=",
"createNodeMemory",
"(",
"node",
",",
"wm",
")",
";",
"}",
"return",
"memory",
";",
"}"
] |
The implementation tries to delay locking as much as possible, by running
some potentially unsafe operations out of the critical session. In case it
fails the checks, it will move into the critical sessions and re-check everything
before effectively doing any change on data structures.
|
[
"The",
"implementation",
"tries",
"to",
"delay",
"locking",
"as",
"much",
"as",
"possible",
"by",
"running",
"some",
"potentially",
"unsafe",
"operations",
"out",
"of",
"the",
"critical",
"session",
".",
"In",
"case",
"it",
"fails",
"the",
"checks",
"it",
"will",
"move",
"into",
"the",
"critical",
"sessions",
"and",
"re",
"-",
"check",
"everything",
"before",
"effectively",
"doing",
"any",
"change",
"on",
"data",
"structures",
"."
] |
train
|
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/common/ConcurrentNodeMemories.java#L79-L90
|
actorapp/actor-platform
|
actor-sdk/sdk-core/core/core-shared/src/main/java/im/actor/core/Messenger.java
|
Messenger.unbindRawFile
|
@ObjectiveCName("unbindRawFileWithFileId:autoCancel:withCallback:")
public void unbindRawFile(long fileId, boolean isAutoCancel, FileCallback callback) {
"""
Unbind Raw File
@param fileId file id
@param isAutoCancel automatically cancel download
@param callback file state callback
"""
modules.getFilesModule().unbindFile(fileId, callback, isAutoCancel);
}
|
java
|
@ObjectiveCName("unbindRawFileWithFileId:autoCancel:withCallback:")
public void unbindRawFile(long fileId, boolean isAutoCancel, FileCallback callback) {
modules.getFilesModule().unbindFile(fileId, callback, isAutoCancel);
}
|
[
"@",
"ObjectiveCName",
"(",
"\"unbindRawFileWithFileId:autoCancel:withCallback:\"",
")",
"public",
"void",
"unbindRawFile",
"(",
"long",
"fileId",
",",
"boolean",
"isAutoCancel",
",",
"FileCallback",
"callback",
")",
"{",
"modules",
".",
"getFilesModule",
"(",
")",
".",
"unbindFile",
"(",
"fileId",
",",
"callback",
",",
"isAutoCancel",
")",
";",
"}"
] |
Unbind Raw File
@param fileId file id
@param isAutoCancel automatically cancel download
@param callback file state callback
|
[
"Unbind",
"Raw",
"File"
] |
train
|
https://github.com/actorapp/actor-platform/blob/5123c1584757c6eeea0ed2a0e7e043629871a0c6/actor-sdk/sdk-core/core/core-shared/src/main/java/im/actor/core/Messenger.java#L1942-L1945
|
RuedigerMoeller/kontraktor
|
modules/kontraktor-http/src/main/java/org/nustaq/kontraktor/remoting/http/undertow/UndertowHttpServerConnector.java
|
UndertowHttpServerConnector.handleRegularRequest
|
protected void handleRegularRequest(HttpServerExchange exchange, HttpObjectSocket httpObjectSocket, Object[] received, StreamSinkChannel sinkchannel) {
"""
handle a remote method call (not a long poll)
@param exchange
@param httpObjectSocket
@param received
@param sinkchannel
"""
ArrayList<IPromise> futures = new ArrayList<>();
httpObjectSocket.getSink().receiveObject(received, futures, exchange.getRequestHeaders().getFirst("JWT") );
Runnable reply = () -> {
// piggy back outstanding lp messages, outstanding lp request is untouched
Pair<byte[], Integer> nextQueuedMessage = httpObjectSocket.getNextQueuedMessage();
byte response[] = nextQueuedMessage.getFirst();
exchange.setResponseContentLength(response.length);
if (response.length == 0) {
exchange.endExchange();
} else {
httpObjectSocket.storeLPMessage(nextQueuedMessage.cdr(), response);
//FIXME: ASYNC !!!
long tim = System.nanoTime();
ByteBuffer responseBuf = ByteBuffer.wrap(response);
try {
while (responseBuf.remaining()>0) {
sinkchannel.write(responseBuf);
}
} catch (IOException e) {
Log.Warn(this,e);
}
// System.out.println("syncwrite time micros:"+(System.nanoTime()-tim)/1000);
exchange.endExchange();
}
};
if ( futures == null || futures.size() == 0 ) {
reply.run();
} else {
Actors.all((List) futures).timeoutIn(REQUEST_RESULTING_FUTURE_TIMEOUT).then( () -> {
reply.run();
}).onTimeout( () -> reply.run() );
sinkchannel.resumeWrites();
}
}
|
java
|
protected void handleRegularRequest(HttpServerExchange exchange, HttpObjectSocket httpObjectSocket, Object[] received, StreamSinkChannel sinkchannel) {
ArrayList<IPromise> futures = new ArrayList<>();
httpObjectSocket.getSink().receiveObject(received, futures, exchange.getRequestHeaders().getFirst("JWT") );
Runnable reply = () -> {
// piggy back outstanding lp messages, outstanding lp request is untouched
Pair<byte[], Integer> nextQueuedMessage = httpObjectSocket.getNextQueuedMessage();
byte response[] = nextQueuedMessage.getFirst();
exchange.setResponseContentLength(response.length);
if (response.length == 0) {
exchange.endExchange();
} else {
httpObjectSocket.storeLPMessage(nextQueuedMessage.cdr(), response);
//FIXME: ASYNC !!!
long tim = System.nanoTime();
ByteBuffer responseBuf = ByteBuffer.wrap(response);
try {
while (responseBuf.remaining()>0) {
sinkchannel.write(responseBuf);
}
} catch (IOException e) {
Log.Warn(this,e);
}
// System.out.println("syncwrite time micros:"+(System.nanoTime()-tim)/1000);
exchange.endExchange();
}
};
if ( futures == null || futures.size() == 0 ) {
reply.run();
} else {
Actors.all((List) futures).timeoutIn(REQUEST_RESULTING_FUTURE_TIMEOUT).then( () -> {
reply.run();
}).onTimeout( () -> reply.run() );
sinkchannel.resumeWrites();
}
}
|
[
"protected",
"void",
"handleRegularRequest",
"(",
"HttpServerExchange",
"exchange",
",",
"HttpObjectSocket",
"httpObjectSocket",
",",
"Object",
"[",
"]",
"received",
",",
"StreamSinkChannel",
"sinkchannel",
")",
"{",
"ArrayList",
"<",
"IPromise",
">",
"futures",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"httpObjectSocket",
".",
"getSink",
"(",
")",
".",
"receiveObject",
"(",
"received",
",",
"futures",
",",
"exchange",
".",
"getRequestHeaders",
"(",
")",
".",
"getFirst",
"(",
"\"JWT\"",
")",
")",
";",
"Runnable",
"reply",
"=",
"(",
")",
"->",
"{",
"// piggy back outstanding lp messages, outstanding lp request is untouched",
"Pair",
"<",
"byte",
"[",
"]",
",",
"Integer",
">",
"nextQueuedMessage",
"=",
"httpObjectSocket",
".",
"getNextQueuedMessage",
"(",
")",
";",
"byte",
"response",
"[",
"]",
"=",
"nextQueuedMessage",
".",
"getFirst",
"(",
")",
";",
"exchange",
".",
"setResponseContentLength",
"(",
"response",
".",
"length",
")",
";",
"if",
"(",
"response",
".",
"length",
"==",
"0",
")",
"{",
"exchange",
".",
"endExchange",
"(",
")",
";",
"}",
"else",
"{",
"httpObjectSocket",
".",
"storeLPMessage",
"(",
"nextQueuedMessage",
".",
"cdr",
"(",
")",
",",
"response",
")",
";",
"//FIXME: ASYNC !!!",
"long",
"tim",
"=",
"System",
".",
"nanoTime",
"(",
")",
";",
"ByteBuffer",
"responseBuf",
"=",
"ByteBuffer",
".",
"wrap",
"(",
"response",
")",
";",
"try",
"{",
"while",
"(",
"responseBuf",
".",
"remaining",
"(",
")",
">",
"0",
")",
"{",
"sinkchannel",
".",
"write",
"(",
"responseBuf",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"Log",
".",
"Warn",
"(",
"this",
",",
"e",
")",
";",
"}",
"// System.out.println(\"syncwrite time micros:\"+(System.nanoTime()-tim)/1000);",
"exchange",
".",
"endExchange",
"(",
")",
";",
"}",
"}",
";",
"if",
"(",
"futures",
"==",
"null",
"||",
"futures",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"reply",
".",
"run",
"(",
")",
";",
"}",
"else",
"{",
"Actors",
".",
"all",
"(",
"(",
"List",
")",
"futures",
")",
".",
"timeoutIn",
"(",
"REQUEST_RESULTING_FUTURE_TIMEOUT",
")",
".",
"then",
"(",
"(",
")",
"->",
"{",
"reply",
".",
"run",
"(",
")",
";",
"}",
")",
".",
"onTimeout",
"(",
"(",
")",
"->",
"reply",
".",
"run",
"(",
")",
")",
";",
"sinkchannel",
".",
"resumeWrites",
"(",
")",
";",
"}",
"}"
] |
handle a remote method call (not a long poll)
@param exchange
@param httpObjectSocket
@param received
@param sinkchannel
|
[
"handle",
"a",
"remote",
"method",
"call",
"(",
"not",
"a",
"long",
"poll",
")"
] |
train
|
https://github.com/RuedigerMoeller/kontraktor/blob/d5f3817f9476f3786187b8ef00400b7a4f25a404/modules/kontraktor-http/src/main/java/org/nustaq/kontraktor/remoting/http/undertow/UndertowHttpServerConnector.java#L269-L305
|
Azure/azure-sdk-for-java
|
cognitiveservices/data-plane/vision/computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/implementation/ComputerVisionImpl.java
|
ComputerVisionImpl.generateThumbnailInStream
|
public InputStream generateThumbnailInStream(int width, int height, byte[] image, GenerateThumbnailInStreamOptionalParameter generateThumbnailInStreamOptionalParameter) {
"""
This operation generates a thumbnail image with the user-specified width and height. By default, the service analyzes the image, identifies the region of interest (ROI), and generates smart cropping coordinates based on the ROI. Smart cropping helps when you specify an aspect ratio that differs from that of the input image. A successful response contains the thumbnail image binary. If the request failed, the response contains an error code and a message to help determine what went wrong.
@param width Width of the thumbnail. It must be between 1 and 1024. Recommended minimum of 50.
@param height Height of the thumbnail. It must be between 1 and 1024. Recommended minimum of 50.
@param image An image stream.
@param generateThumbnailInStreamOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the InputStream object if successful.
"""
return generateThumbnailInStreamWithServiceResponseAsync(width, height, image, generateThumbnailInStreamOptionalParameter).toBlocking().single().body();
}
|
java
|
public InputStream generateThumbnailInStream(int width, int height, byte[] image, GenerateThumbnailInStreamOptionalParameter generateThumbnailInStreamOptionalParameter) {
return generateThumbnailInStreamWithServiceResponseAsync(width, height, image, generateThumbnailInStreamOptionalParameter).toBlocking().single().body();
}
|
[
"public",
"InputStream",
"generateThumbnailInStream",
"(",
"int",
"width",
",",
"int",
"height",
",",
"byte",
"[",
"]",
"image",
",",
"GenerateThumbnailInStreamOptionalParameter",
"generateThumbnailInStreamOptionalParameter",
")",
"{",
"return",
"generateThumbnailInStreamWithServiceResponseAsync",
"(",
"width",
",",
"height",
",",
"image",
",",
"generateThumbnailInStreamOptionalParameter",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] |
This operation generates a thumbnail image with the user-specified width and height. By default, the service analyzes the image, identifies the region of interest (ROI), and generates smart cropping coordinates based on the ROI. Smart cropping helps when you specify an aspect ratio that differs from that of the input image. A successful response contains the thumbnail image binary. If the request failed, the response contains an error code and a message to help determine what went wrong.
@param width Width of the thumbnail. It must be between 1 and 1024. Recommended minimum of 50.
@param height Height of the thumbnail. It must be between 1 and 1024. Recommended minimum of 50.
@param image An image stream.
@param generateThumbnailInStreamOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the InputStream object if successful.
|
[
"This",
"operation",
"generates",
"a",
"thumbnail",
"image",
"with",
"the",
"user",
"-",
"specified",
"width",
"and",
"height",
".",
"By",
"default",
"the",
"service",
"analyzes",
"the",
"image",
"identifies",
"the",
"region",
"of",
"interest",
"(",
"ROI",
")",
"and",
"generates",
"smart",
"cropping",
"coordinates",
"based",
"on",
"the",
"ROI",
".",
"Smart",
"cropping",
"helps",
"when",
"you",
"specify",
"an",
"aspect",
"ratio",
"that",
"differs",
"from",
"that",
"of",
"the",
"input",
"image",
".",
"A",
"successful",
"response",
"contains",
"the",
"thumbnail",
"image",
"binary",
".",
"If",
"the",
"request",
"failed",
"the",
"response",
"contains",
"an",
"error",
"code",
"and",
"a",
"message",
"to",
"help",
"determine",
"what",
"went",
"wrong",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/vision/computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/implementation/ComputerVisionImpl.java#L905-L907
|
box/box-android-sdk
|
box-content-sdk/src/main/java/com/box/androidsdk/content/auth/OAuthActivity.java
|
OAuthActivity.onReceivedAuthCode
|
public void onReceivedAuthCode(String code, String baseDomain) {
"""
Callback method to be called when authentication code is received along with a base domain. The code will then be used to make an API call to create OAuth tokens.
"""
if (authType == AUTH_TYPE_WEBVIEW) {
oauthView.setVisibility(View.INVISIBLE);
}
startMakingOAuthAPICall(code, baseDomain);
}
|
java
|
public void onReceivedAuthCode(String code, String baseDomain) {
if (authType == AUTH_TYPE_WEBVIEW) {
oauthView.setVisibility(View.INVISIBLE);
}
startMakingOAuthAPICall(code, baseDomain);
}
|
[
"public",
"void",
"onReceivedAuthCode",
"(",
"String",
"code",
",",
"String",
"baseDomain",
")",
"{",
"if",
"(",
"authType",
"==",
"AUTH_TYPE_WEBVIEW",
")",
"{",
"oauthView",
".",
"setVisibility",
"(",
"View",
".",
"INVISIBLE",
")",
";",
"}",
"startMakingOAuthAPICall",
"(",
"code",
",",
"baseDomain",
")",
";",
"}"
] |
Callback method to be called when authentication code is received along with a base domain. The code will then be used to make an API call to create OAuth tokens.
|
[
"Callback",
"method",
"to",
"be",
"called",
"when",
"authentication",
"code",
"is",
"received",
"along",
"with",
"a",
"base",
"domain",
".",
"The",
"code",
"will",
"then",
"be",
"used",
"to",
"make",
"an",
"API",
"call",
"to",
"create",
"OAuth",
"tokens",
"."
] |
train
|
https://github.com/box/box-android-sdk/blob/a621ad5ddebf23067fec27529130d72718fc0e88/box-content-sdk/src/main/java/com/box/androidsdk/content/auth/OAuthActivity.java#L172-L177
|
DDTH/ddth-zookeeper
|
src/main/java/com/github/ddth/zookeeper/ZooKeeperClient.java
|
ZooKeeperClient.setData
|
public boolean setData(String path, String value) throws ZooKeeperException {
"""
Writes data to a node.
@param path
@param value
@return {@code true} if write successfully, {@code false} otherwise (note
does not exist, for example)
@throws ZooKeeperException
"""
return setData(path, value, false);
}
|
java
|
public boolean setData(String path, String value) throws ZooKeeperException {
return setData(path, value, false);
}
|
[
"public",
"boolean",
"setData",
"(",
"String",
"path",
",",
"String",
"value",
")",
"throws",
"ZooKeeperException",
"{",
"return",
"setData",
"(",
"path",
",",
"value",
",",
"false",
")",
";",
"}"
] |
Writes data to a node.
@param path
@param value
@return {@code true} if write successfully, {@code false} otherwise (note
does not exist, for example)
@throws ZooKeeperException
|
[
"Writes",
"data",
"to",
"a",
"node",
"."
] |
train
|
https://github.com/DDTH/ddth-zookeeper/blob/0994eea8b25fa3d885f3da4579768b7d08c1c32b/src/main/java/com/github/ddth/zookeeper/ZooKeeperClient.java#L670-L672
|
groovy/groovy-core
|
src/main/org/codehaus/groovy/vmplugin/v7/IndyInterface.java
|
IndyInterface.bootstrapCurrent
|
public static CallSite bootstrapCurrent(Lookup caller, String name, MethodType type) {
"""
bootstrap method for method calls with "this" as receiver
@deprecated since Groovy 2.1.0
"""
return realBootstrap(caller, name, CALL_TYPES.METHOD.ordinal(), type, false, true, false);
}
|
java
|
public static CallSite bootstrapCurrent(Lookup caller, String name, MethodType type) {
return realBootstrap(caller, name, CALL_TYPES.METHOD.ordinal(), type, false, true, false);
}
|
[
"public",
"static",
"CallSite",
"bootstrapCurrent",
"(",
"Lookup",
"caller",
",",
"String",
"name",
",",
"MethodType",
"type",
")",
"{",
"return",
"realBootstrap",
"(",
"caller",
",",
"name",
",",
"CALL_TYPES",
".",
"METHOD",
".",
"ordinal",
"(",
")",
",",
"type",
",",
"false",
",",
"true",
",",
"false",
")",
";",
"}"
] |
bootstrap method for method calls with "this" as receiver
@deprecated since Groovy 2.1.0
|
[
"bootstrap",
"method",
"for",
"method",
"calls",
"with",
"this",
"as",
"receiver"
] |
train
|
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/vmplugin/v7/IndyInterface.java#L157-L159
|
calrissian/mango
|
mango-core/src/main/java/org/calrissian/mango/net/MoreInetAddresses.java
|
MoreInetAddresses.forIPv4String
|
public static Inet4Address forIPv4String(String ipString) {
"""
Generates a new Inet4Address instance from the provided address. This will NOT do a dns lookup on the address if it
does not represent a valid ip address like {@code InetAddress.getByName()}.
"""
requireNonNull(ipString);
try{
InetAddress parsed = forString(ipString);
if (parsed instanceof Inet4Address)
return (Inet4Address) parsed;
} catch(Exception ignored){}
throw new IllegalArgumentException(format("Invalid IPv4 representation: %s", ipString));
}
|
java
|
public static Inet4Address forIPv4String(String ipString) {
requireNonNull(ipString);
try{
InetAddress parsed = forString(ipString);
if (parsed instanceof Inet4Address)
return (Inet4Address) parsed;
} catch(Exception ignored){}
throw new IllegalArgumentException(format("Invalid IPv4 representation: %s", ipString));
}
|
[
"public",
"static",
"Inet4Address",
"forIPv4String",
"(",
"String",
"ipString",
")",
"{",
"requireNonNull",
"(",
"ipString",
")",
";",
"try",
"{",
"InetAddress",
"parsed",
"=",
"forString",
"(",
"ipString",
")",
";",
"if",
"(",
"parsed",
"instanceof",
"Inet4Address",
")",
"return",
"(",
"Inet4Address",
")",
"parsed",
";",
"}",
"catch",
"(",
"Exception",
"ignored",
")",
"{",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
"format",
"(",
"\"Invalid IPv4 representation: %s\"",
",",
"ipString",
")",
")",
";",
"}"
] |
Generates a new Inet4Address instance from the provided address. This will NOT do a dns lookup on the address if it
does not represent a valid ip address like {@code InetAddress.getByName()}.
|
[
"Generates",
"a",
"new",
"Inet4Address",
"instance",
"from",
"the",
"provided",
"address",
".",
"This",
"will",
"NOT",
"do",
"a",
"dns",
"lookup",
"on",
"the",
"address",
"if",
"it",
"does",
"not",
"represent",
"a",
"valid",
"ip",
"address",
"like",
"{"
] |
train
|
https://github.com/calrissian/mango/blob/a95aa5e77af9aa0e629787228d80806560023452/mango-core/src/main/java/org/calrissian/mango/net/MoreInetAddresses.java#L119-L131
|
xvik/guice-persist-orient
|
src/main/java/ru/vyarus/guice/persist/orient/db/PersistentContext.java
|
PersistentContext.doInTransaction
|
public <T> T doInTransaction(final SpecificTxAction<T, C> action) {
"""
Execute specific action within transaction.
@param action action to execute within transaction (new or ongoing)
@param <T> expected return type
@return value produced by action
@see ru.vyarus.guice.persist.orient.db.transaction.template.SpecificTxTemplate
"""
return template.doInTransaction(action);
}
|
java
|
public <T> T doInTransaction(final SpecificTxAction<T, C> action) {
return template.doInTransaction(action);
}
|
[
"public",
"<",
"T",
">",
"T",
"doInTransaction",
"(",
"final",
"SpecificTxAction",
"<",
"T",
",",
"C",
">",
"action",
")",
"{",
"return",
"template",
".",
"doInTransaction",
"(",
"action",
")",
";",
"}"
] |
Execute specific action within transaction.
@param action action to execute within transaction (new or ongoing)
@param <T> expected return type
@return value produced by action
@see ru.vyarus.guice.persist.orient.db.transaction.template.SpecificTxTemplate
|
[
"Execute",
"specific",
"action",
"within",
"transaction",
"."
] |
train
|
https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/db/PersistentContext.java#L130-L132
|
deeplearning4j/deeplearning4j
|
nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/blas/BlasBufferUtil.java
|
BlasBufferUtil.getDimension
|
public static int getDimension(INDArray arr, boolean defaultRows) {
"""
Get the dimension associated with
the given ordering.
When working with blas routines, they typically assume
c ordering, instead you can invert the rows/columns
which enable you to do no copy blas operations.
@param arr
@param defaultRows
@return
"""
// FIXME: int cast
//ignore ordering for vectors
if (arr.isVector()) {
return defaultRows ? (int) arr.rows() : (int) arr.columns();
}
if (arr.ordering() == NDArrayFactory.C)
return defaultRows ? (int) arr.columns() : (int) arr.rows();
return defaultRows ? (int) arr.rows() : (int) arr.columns();
}
|
java
|
public static int getDimension(INDArray arr, boolean defaultRows) {
// FIXME: int cast
//ignore ordering for vectors
if (arr.isVector()) {
return defaultRows ? (int) arr.rows() : (int) arr.columns();
}
if (arr.ordering() == NDArrayFactory.C)
return defaultRows ? (int) arr.columns() : (int) arr.rows();
return defaultRows ? (int) arr.rows() : (int) arr.columns();
}
|
[
"public",
"static",
"int",
"getDimension",
"(",
"INDArray",
"arr",
",",
"boolean",
"defaultRows",
")",
"{",
"// FIXME: int cast",
"//ignore ordering for vectors",
"if",
"(",
"arr",
".",
"isVector",
"(",
")",
")",
"{",
"return",
"defaultRows",
"?",
"(",
"int",
")",
"arr",
".",
"rows",
"(",
")",
":",
"(",
"int",
")",
"arr",
".",
"columns",
"(",
")",
";",
"}",
"if",
"(",
"arr",
".",
"ordering",
"(",
")",
"==",
"NDArrayFactory",
".",
"C",
")",
"return",
"defaultRows",
"?",
"(",
"int",
")",
"arr",
".",
"columns",
"(",
")",
":",
"(",
"int",
")",
"arr",
".",
"rows",
"(",
")",
";",
"return",
"defaultRows",
"?",
"(",
"int",
")",
"arr",
".",
"rows",
"(",
")",
":",
"(",
"int",
")",
"arr",
".",
"columns",
"(",
")",
";",
"}"
] |
Get the dimension associated with
the given ordering.
When working with blas routines, they typically assume
c ordering, instead you can invert the rows/columns
which enable you to do no copy blas operations.
@param arr
@param defaultRows
@return
|
[
"Get",
"the",
"dimension",
"associated",
"with",
"the",
"given",
"ordering",
"."
] |
train
|
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/blas/BlasBufferUtil.java#L145-L155
|
aws/aws-sdk-java
|
aws-java-sdk-secretsmanager/src/main/java/com/amazonaws/services/secretsmanager/model/DescribeSecretResult.java
|
DescribeSecretResult.withVersionIdsToStages
|
public DescribeSecretResult withVersionIdsToStages(java.util.Map<String, java.util.List<String>> versionIdsToStages) {
"""
<p>
A list of all of the currently assigned <code>VersionStage</code> staging labels and the <code>VersionId</code>
that each is attached to. Staging labels are used to keep track of the different versions during the rotation
process.
</p>
<note>
<p>
A version that does not have any staging labels attached is considered deprecated and subject to deletion. Such
versions are not included in this list.
</p>
</note>
@param versionIdsToStages
A list of all of the currently assigned <code>VersionStage</code> staging labels and the
<code>VersionId</code> that each is attached to. Staging labels are used to keep track of the different
versions during the rotation process.</p> <note>
<p>
A version that does not have any staging labels attached is considered deprecated and subject to deletion.
Such versions are not included in this list.
</p>
@return Returns a reference to this object so that method calls can be chained together.
"""
setVersionIdsToStages(versionIdsToStages);
return this;
}
|
java
|
public DescribeSecretResult withVersionIdsToStages(java.util.Map<String, java.util.List<String>> versionIdsToStages) {
setVersionIdsToStages(versionIdsToStages);
return this;
}
|
[
"public",
"DescribeSecretResult",
"withVersionIdsToStages",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"java",
".",
"util",
".",
"List",
"<",
"String",
">",
">",
"versionIdsToStages",
")",
"{",
"setVersionIdsToStages",
"(",
"versionIdsToStages",
")",
";",
"return",
"this",
";",
"}"
] |
<p>
A list of all of the currently assigned <code>VersionStage</code> staging labels and the <code>VersionId</code>
that each is attached to. Staging labels are used to keep track of the different versions during the rotation
process.
</p>
<note>
<p>
A version that does not have any staging labels attached is considered deprecated and subject to deletion. Such
versions are not included in this list.
</p>
</note>
@param versionIdsToStages
A list of all of the currently assigned <code>VersionStage</code> staging labels and the
<code>VersionId</code> that each is attached to. Staging labels are used to keep track of the different
versions during the rotation process.</p> <note>
<p>
A version that does not have any staging labels attached is considered deprecated and subject to deletion.
Such versions are not included in this list.
</p>
@return Returns a reference to this object so that method calls can be chained together.
|
[
"<p",
">",
"A",
"list",
"of",
"all",
"of",
"the",
"currently",
"assigned",
"<code",
">",
"VersionStage<",
"/",
"code",
">",
"staging",
"labels",
"and",
"the",
"<code",
">",
"VersionId<",
"/",
"code",
">",
"that",
"each",
"is",
"attached",
"to",
".",
"Staging",
"labels",
"are",
"used",
"to",
"keep",
"track",
"of",
"the",
"different",
"versions",
"during",
"the",
"rotation",
"process",
".",
"<",
"/",
"p",
">",
"<note",
">",
"<p",
">",
"A",
"version",
"that",
"does",
"not",
"have",
"any",
"staging",
"labels",
"attached",
"is",
"considered",
"deprecated",
"and",
"subject",
"to",
"deletion",
".",
"Such",
"versions",
"are",
"not",
"included",
"in",
"this",
"list",
".",
"<",
"/",
"p",
">",
"<",
"/",
"note",
">"
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-secretsmanager/src/main/java/com/amazonaws/services/secretsmanager/model/DescribeSecretResult.java#L827-L830
|
deeplearning4j/deeplearning4j
|
nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/indexing/BooleanIndexing.java
|
BooleanIndexing.replaceWhere
|
public static void replaceWhere(@NonNull INDArray to, @NonNull INDArray from, @NonNull Condition condition) {
"""
This method does element-wise comparison for 2 equal-sized matrices, for each element that matches Condition
@param to
@param from
@param condition
"""
if (!(condition instanceof BaseCondition))
throw new UnsupportedOperationException("Only static Conditions are supported");
if (to.length() != from.length())
throw new IllegalStateException("Mis matched length for to and from");
Nd4j.getExecutioner().exec(new CompareAndReplace(to, from, condition));
}
|
java
|
public static void replaceWhere(@NonNull INDArray to, @NonNull INDArray from, @NonNull Condition condition) {
if (!(condition instanceof BaseCondition))
throw new UnsupportedOperationException("Only static Conditions are supported");
if (to.length() != from.length())
throw new IllegalStateException("Mis matched length for to and from");
Nd4j.getExecutioner().exec(new CompareAndReplace(to, from, condition));
}
|
[
"public",
"static",
"void",
"replaceWhere",
"(",
"@",
"NonNull",
"INDArray",
"to",
",",
"@",
"NonNull",
"INDArray",
"from",
",",
"@",
"NonNull",
"Condition",
"condition",
")",
"{",
"if",
"(",
"!",
"(",
"condition",
"instanceof",
"BaseCondition",
")",
")",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Only static Conditions are supported\"",
")",
";",
"if",
"(",
"to",
".",
"length",
"(",
")",
"!=",
"from",
".",
"length",
"(",
")",
")",
"throw",
"new",
"IllegalStateException",
"(",
"\"Mis matched length for to and from\"",
")",
";",
"Nd4j",
".",
"getExecutioner",
"(",
")",
".",
"exec",
"(",
"new",
"CompareAndReplace",
"(",
"to",
",",
"from",
",",
"condition",
")",
")",
";",
"}"
] |
This method does element-wise comparison for 2 equal-sized matrices, for each element that matches Condition
@param to
@param from
@param condition
|
[
"This",
"method",
"does",
"element",
"-",
"wise",
"comparison",
"for",
"2",
"equal",
"-",
"sized",
"matrices",
"for",
"each",
"element",
"that",
"matches",
"Condition"
] |
train
|
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/indexing/BooleanIndexing.java#L174-L182
|
intendia-oss/rxjava-gwt
|
src/main/modified/io/reactivex/super/io/reactivex/Flowable.java
|
Flowable.repeatUntil
|
@CheckReturnValue
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
public final Flowable<T> repeatUntil(BooleanSupplier stop) {
"""
Returns a Flowable that repeats the sequence of items emitted by the source Publisher until
the provided stop function returns true.
<p>
<img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/repeat.on.png" alt="">
<dl>
<dt><b>Backpressure:</b></dt>
<dd>The operator honors downstream backpressure and expects the source {@code Publisher} to honor backpressure as well.
If this expectation is violated, the operator <em>may</em> throw an {@code IllegalStateException}.</dd>
<dt><b>Scheduler:</b></dt>
<dd>{@code repeatUntil} does not operate by default on a particular {@link Scheduler}.</dd>
</dl>
@param stop
a boolean supplier that is called when the current Flowable completes and unless it returns
false, the current Flowable is resubscribed
@return the new Flowable instance
@throws NullPointerException
if {@code stop} is null
@see <a href="http://reactivex.io/documentation/operators/repeat.html">ReactiveX operators documentation: Repeat</a>
"""
ObjectHelper.requireNonNull(stop, "stop is null");
return RxJavaPlugins.onAssembly(new FlowableRepeatUntil<T>(this, stop));
}
|
java
|
@CheckReturnValue
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
public final Flowable<T> repeatUntil(BooleanSupplier stop) {
ObjectHelper.requireNonNull(stop, "stop is null");
return RxJavaPlugins.onAssembly(new FlowableRepeatUntil<T>(this, stop));
}
|
[
"@",
"CheckReturnValue",
"@",
"BackpressureSupport",
"(",
"BackpressureKind",
".",
"FULL",
")",
"@",
"SchedulerSupport",
"(",
"SchedulerSupport",
".",
"NONE",
")",
"public",
"final",
"Flowable",
"<",
"T",
">",
"repeatUntil",
"(",
"BooleanSupplier",
"stop",
")",
"{",
"ObjectHelper",
".",
"requireNonNull",
"(",
"stop",
",",
"\"stop is null\"",
")",
";",
"return",
"RxJavaPlugins",
".",
"onAssembly",
"(",
"new",
"FlowableRepeatUntil",
"<",
"T",
">",
"(",
"this",
",",
"stop",
")",
")",
";",
"}"
] |
Returns a Flowable that repeats the sequence of items emitted by the source Publisher until
the provided stop function returns true.
<p>
<img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/repeat.on.png" alt="">
<dl>
<dt><b>Backpressure:</b></dt>
<dd>The operator honors downstream backpressure and expects the source {@code Publisher} to honor backpressure as well.
If this expectation is violated, the operator <em>may</em> throw an {@code IllegalStateException}.</dd>
<dt><b>Scheduler:</b></dt>
<dd>{@code repeatUntil} does not operate by default on a particular {@link Scheduler}.</dd>
</dl>
@param stop
a boolean supplier that is called when the current Flowable completes and unless it returns
false, the current Flowable is resubscribed
@return the new Flowable instance
@throws NullPointerException
if {@code stop} is null
@see <a href="http://reactivex.io/documentation/operators/repeat.html">ReactiveX operators documentation: Repeat</a>
|
[
"Returns",
"a",
"Flowable",
"that",
"repeats",
"the",
"sequence",
"of",
"items",
"emitted",
"by",
"the",
"source",
"Publisher",
"until",
"the",
"provided",
"stop",
"function",
"returns",
"true",
".",
"<p",
">",
"<img",
"width",
"=",
"640",
"height",
"=",
"310",
"src",
"=",
"https",
":",
"//",
"raw",
".",
"github",
".",
"com",
"/",
"wiki",
"/",
"ReactiveX",
"/",
"RxJava",
"/",
"images",
"/",
"rx",
"-",
"operators",
"/",
"repeat",
".",
"on",
".",
"png",
"alt",
"=",
">",
"<dl",
">",
"<dt",
">",
"<b",
">",
"Backpressure",
":",
"<",
"/",
"b",
">",
"<",
"/",
"dt",
">",
"<dd",
">",
"The",
"operator",
"honors",
"downstream",
"backpressure",
"and",
"expects",
"the",
"source",
"{",
"@code",
"Publisher",
"}",
"to",
"honor",
"backpressure",
"as",
"well",
".",
"If",
"this",
"expectation",
"is",
"violated",
"the",
"operator",
"<em",
">",
"may<",
"/",
"em",
">",
"throw",
"an",
"{",
"@code",
"IllegalStateException",
"}",
".",
"<",
"/",
"dd",
">",
"<dt",
">",
"<b",
">",
"Scheduler",
":",
"<",
"/",
"b",
">",
"<",
"/",
"dt",
">",
"<dd",
">",
"{",
"@code",
"repeatUntil",
"}",
"does",
"not",
"operate",
"by",
"default",
"on",
"a",
"particular",
"{",
"@link",
"Scheduler",
"}",
".",
"<",
"/",
"dd",
">",
"<",
"/",
"dl",
">"
] |
train
|
https://github.com/intendia-oss/rxjava-gwt/blob/8d5635b12ce40da99e76b59dc6bfe6fc2fffc1fa/src/main/modified/io/reactivex/super/io/reactivex/Flowable.java#L12359-L12365
|
att/AAF
|
authz/authz-cass/src/main/java/com/att/dao/Loader.java
|
Loader.writeStringSet
|
public static void writeStringSet(DataOutputStream os, Collection<String> set) throws IOException {
"""
Write a set with proper sizing
Note: at the moment, this is just String. Probably can develop system where types
are supported too... but not now.
@param os
@param set
@throws IOException
"""
if(set==null) {
os.writeInt(-1);
} else {
os.writeInt(set.size());
for(String s : set) {
writeString(os, s);
}
}
}
|
java
|
public static void writeStringSet(DataOutputStream os, Collection<String> set) throws IOException {
if(set==null) {
os.writeInt(-1);
} else {
os.writeInt(set.size());
for(String s : set) {
writeString(os, s);
}
}
}
|
[
"public",
"static",
"void",
"writeStringSet",
"(",
"DataOutputStream",
"os",
",",
"Collection",
"<",
"String",
">",
"set",
")",
"throws",
"IOException",
"{",
"if",
"(",
"set",
"==",
"null",
")",
"{",
"os",
".",
"writeInt",
"(",
"-",
"1",
")",
";",
"}",
"else",
"{",
"os",
".",
"writeInt",
"(",
"set",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"String",
"s",
":",
"set",
")",
"{",
"writeString",
"(",
"os",
",",
"s",
")",
";",
"}",
"}",
"}"
] |
Write a set with proper sizing
Note: at the moment, this is just String. Probably can develop system where types
are supported too... but not now.
@param os
@param set
@throws IOException
|
[
"Write",
"a",
"set",
"with",
"proper",
"sizing"
] |
train
|
https://github.com/att/AAF/blob/090562e956c0035db972aafba844dc6d3fc948ee/authz/authz-cass/src/main/java/com/att/dao/Loader.java#L110-L120
|
wellner/jcarafe
|
jcarafe-core/src/main/java/cern/colt/list/ObjectArrayList.java
|
ObjectArrayList.shuffleFromTo
|
public void shuffleFromTo(int from, int to) {
"""
Randomly permutes the part of the receiver between <code>from</code> (inclusive) and <code>to</code> (inclusive).
@param from the index of the first element (inclusive) to be permuted.
@param to the index of the last element (inclusive) to be permuted.
@exception IndexOutOfBoundsException index is out of range (<tt>size()>0 && (from<0 || from>to || to>=size())</tt>).
"""
if (size == 0) return;
checkRangeFromTo(from, to, size);
//cern.jet.random.Uniform gen = new cern.jet.random.Uniform(new cern.jet.random.engine.DRand(new java.util.Date()));
java.util.Random gen = new java.util.Random();
Object tmpElement;
Object[] theElements = elements;
int random;
for (int i = from; i < to; i++) {
//random = gen.nextIntFromTo(i, to);
int rp = gen.nextInt(to-i);
random = rp + i;
//swap(i, random)
tmpElement = theElements[random];
theElements[random] = theElements[i];
theElements[i] = tmpElement;
}
}
|
java
|
public void shuffleFromTo(int from, int to) {
if (size == 0) return;
checkRangeFromTo(from, to, size);
//cern.jet.random.Uniform gen = new cern.jet.random.Uniform(new cern.jet.random.engine.DRand(new java.util.Date()));
java.util.Random gen = new java.util.Random();
Object tmpElement;
Object[] theElements = elements;
int random;
for (int i = from; i < to; i++) {
//random = gen.nextIntFromTo(i, to);
int rp = gen.nextInt(to-i);
random = rp + i;
//swap(i, random)
tmpElement = theElements[random];
theElements[random] = theElements[i];
theElements[i] = tmpElement;
}
}
|
[
"public",
"void",
"shuffleFromTo",
"(",
"int",
"from",
",",
"int",
"to",
")",
"{",
"if",
"(",
"size",
"==",
"0",
")",
"return",
";",
"checkRangeFromTo",
"(",
"from",
",",
"to",
",",
"size",
")",
";",
"//cern.jet.random.Uniform gen = new cern.jet.random.Uniform(new cern.jet.random.engine.DRand(new java.util.Date()));\r",
"java",
".",
"util",
".",
"Random",
"gen",
"=",
"new",
"java",
".",
"util",
".",
"Random",
"(",
")",
";",
"Object",
"tmpElement",
";",
"Object",
"[",
"]",
"theElements",
"=",
"elements",
";",
"int",
"random",
";",
"for",
"(",
"int",
"i",
"=",
"from",
";",
"i",
"<",
"to",
";",
"i",
"++",
")",
"{",
"//random = gen.nextIntFromTo(i, to);\r",
"int",
"rp",
"=",
"gen",
".",
"nextInt",
"(",
"to",
"-",
"i",
")",
";",
"random",
"=",
"rp",
"+",
"i",
";",
"//swap(i, random)\r",
"tmpElement",
"=",
"theElements",
"[",
"random",
"]",
";",
"theElements",
"[",
"random",
"]",
"=",
"theElements",
"[",
"i",
"]",
";",
"theElements",
"[",
"i",
"]",
"=",
"tmpElement",
";",
"}",
"}"
] |
Randomly permutes the part of the receiver between <code>from</code> (inclusive) and <code>to</code> (inclusive).
@param from the index of the first element (inclusive) to be permuted.
@param to the index of the last element (inclusive) to be permuted.
@exception IndexOutOfBoundsException index is out of range (<tt>size()>0 && (from<0 || from>to || to>=size())</tt>).
|
[
"Randomly",
"permutes",
"the",
"part",
"of",
"the",
"receiver",
"between",
"<code",
">",
"from<",
"/",
"code",
">",
"(",
"inclusive",
")",
"and",
"<code",
">",
"to<",
"/",
"code",
">",
"(",
"inclusive",
")",
"."
] |
train
|
https://github.com/wellner/jcarafe/blob/ab8b0a83dbf600fe80c27711815c90bd3055b217/jcarafe-core/src/main/java/cern/colt/list/ObjectArrayList.java#L863-L881
|
CenturyLinkCloud/mdw
|
mdw-common/src/com/centurylink/mdw/cli/Setup.java
|
Setup.getRelativePath
|
public String getRelativePath(File from, File to) {
"""
Returns 'to' file or dir path relative to 'from' dir.
Result always uses forward slashes and has no trailing slash.
"""
Path fromPath = Paths.get(from.getPath()).normalize().toAbsolutePath();
Path toPath = Paths.get(to.getPath()).normalize().toAbsolutePath();
return fromPath.relativize(toPath).toString().replace('\\', '/');
}
|
java
|
public String getRelativePath(File from, File to) {
Path fromPath = Paths.get(from.getPath()).normalize().toAbsolutePath();
Path toPath = Paths.get(to.getPath()).normalize().toAbsolutePath();
return fromPath.relativize(toPath).toString().replace('\\', '/');
}
|
[
"public",
"String",
"getRelativePath",
"(",
"File",
"from",
",",
"File",
"to",
")",
"{",
"Path",
"fromPath",
"=",
"Paths",
".",
"get",
"(",
"from",
".",
"getPath",
"(",
")",
")",
".",
"normalize",
"(",
")",
".",
"toAbsolutePath",
"(",
")",
";",
"Path",
"toPath",
"=",
"Paths",
".",
"get",
"(",
"to",
".",
"getPath",
"(",
")",
")",
".",
"normalize",
"(",
")",
".",
"toAbsolutePath",
"(",
")",
";",
"return",
"fromPath",
".",
"relativize",
"(",
"toPath",
")",
".",
"toString",
"(",
")",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
";",
"}"
] |
Returns 'to' file or dir path relative to 'from' dir.
Result always uses forward slashes and has no trailing slash.
|
[
"Returns",
"to",
"file",
"or",
"dir",
"path",
"relative",
"to",
"from",
"dir",
".",
"Result",
"always",
"uses",
"forward",
"slashes",
"and",
"has",
"no",
"trailing",
"slash",
"."
] |
train
|
https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/cli/Setup.java#L405-L409
|
jglobus/JGlobus
|
gram/src/main/java/org/globus/rsl/RslAttributes.java
|
RslAttributes.addVariable
|
public void addVariable(String attribute, String varName, String value) {
"""
Adds a new variable definition to the specified variable definitions
attribute.
@param attribute the variable definitions attribute - rsl_subsititution.
@param varName the variable name to add.
@param value the value of the variable to add.
"""
Bindings binds = rslTree.getBindings(attribute);
if (binds == null) {
binds = new Bindings(attribute);
rslTree.put(binds);
}
binds.add(new Binding(varName, value));
}
|
java
|
public void addVariable(String attribute, String varName, String value) {
Bindings binds = rslTree.getBindings(attribute);
if (binds == null) {
binds = new Bindings(attribute);
rslTree.put(binds);
}
binds.add(new Binding(varName, value));
}
|
[
"public",
"void",
"addVariable",
"(",
"String",
"attribute",
",",
"String",
"varName",
",",
"String",
"value",
")",
"{",
"Bindings",
"binds",
"=",
"rslTree",
".",
"getBindings",
"(",
"attribute",
")",
";",
"if",
"(",
"binds",
"==",
"null",
")",
"{",
"binds",
"=",
"new",
"Bindings",
"(",
"attribute",
")",
";",
"rslTree",
".",
"put",
"(",
"binds",
")",
";",
"}",
"binds",
".",
"add",
"(",
"new",
"Binding",
"(",
"varName",
",",
"value",
")",
")",
";",
"}"
] |
Adds a new variable definition to the specified variable definitions
attribute.
@param attribute the variable definitions attribute - rsl_subsititution.
@param varName the variable name to add.
@param value the value of the variable to add.
|
[
"Adds",
"a",
"new",
"variable",
"definition",
"to",
"the",
"specified",
"variable",
"definitions",
"attribute",
"."
] |
train
|
https://github.com/jglobus/JGlobus/blob/e14f6f6636544fd84298f9cec749d626ea971930/gram/src/main/java/org/globus/rsl/RslAttributes.java#L189-L196
|
apache/incubator-gobblin
|
gobblin-utility/src/main/java/org/apache/gobblin/util/EmailUtils.java
|
EmailUtils.sendJobCancellationEmail
|
public static void sendJobCancellationEmail(String jobId, String message, State jobState) throws EmailException {
"""
Send a job cancellation notification email.
@param jobId job name
@param message email message
@param jobState a {@link State} object carrying job configuration properties
@throws EmailException if there is anything wrong sending the email
"""
sendEmail(jobState, String.format("Gobblin notification: job %s has been cancelled", jobId), message);
}
|
java
|
public static void sendJobCancellationEmail(String jobId, String message, State jobState) throws EmailException {
sendEmail(jobState, String.format("Gobblin notification: job %s has been cancelled", jobId), message);
}
|
[
"public",
"static",
"void",
"sendJobCancellationEmail",
"(",
"String",
"jobId",
",",
"String",
"message",
",",
"State",
"jobState",
")",
"throws",
"EmailException",
"{",
"sendEmail",
"(",
"jobState",
",",
"String",
".",
"format",
"(",
"\"Gobblin notification: job %s has been cancelled\"",
",",
"jobId",
")",
",",
"message",
")",
";",
"}"
] |
Send a job cancellation notification email.
@param jobId job name
@param message email message
@param jobState a {@link State} object carrying job configuration properties
@throws EmailException if there is anything wrong sending the email
|
[
"Send",
"a",
"job",
"cancellation",
"notification",
"email",
"."
] |
train
|
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/EmailUtils.java#L107-L109
|
OpenNTF/JavascriptAggregator
|
jaggr-core/src/main/java/com/ibm/jaggr/core/impl/AbstractAggregatorImpl.java
|
AbstractAggregatorImpl.writeResponse
|
protected boolean writeResponse(InputStream in, HttpServletRequest request, HttpServletResponse response) throws IOException {
"""
Writes the response to the response object. IOExceptions that occur when writing to the
response output stream are not propagated, but are handled internally. Such exceptions
are assumed to be caused by the client closing the connection and are not real errors.
@param in
the input stream.
@param request
the http request object
@param response
the http response object
@return true if all of the data from the input stream was written to the response
@throws IOException
"""
final String sourceMethod = "writeResponse"; //$NON-NLS-1$
final boolean isTraceLogging = log.isLoggable(Level.FINER);
if (isTraceLogging) {
log.entering(AbstractAggregatorImpl.class.getName(), sourceMethod, new Object[]{in, response});
}
boolean success = true;
int n = 0;
byte[] buffer = new byte[4096];
OutputStream out = response.getOutputStream();
try {
while (-1 != (n = in.read(buffer))) {
try {
out.write(buffer, 0, n);
} catch (IOException e) {
// Error writing to the output stream, probably because the connection
// was closed by the client. Don't attempt to write anything else to
// the response and just log the error using FINE level logging.
logException(request, Level.FINE, sourceMethod, e);
success = false;
break;
}
}
} finally {
IOUtils.closeQuietly(in);
IOUtils.closeQuietly(out);
}
if (isTraceLogging) {
log.exiting(AbstractAggregatorImpl.class.getName(), sourceMethod, success);
}
return success;
}
|
java
|
protected boolean writeResponse(InputStream in, HttpServletRequest request, HttpServletResponse response) throws IOException {
final String sourceMethod = "writeResponse"; //$NON-NLS-1$
final boolean isTraceLogging = log.isLoggable(Level.FINER);
if (isTraceLogging) {
log.entering(AbstractAggregatorImpl.class.getName(), sourceMethod, new Object[]{in, response});
}
boolean success = true;
int n = 0;
byte[] buffer = new byte[4096];
OutputStream out = response.getOutputStream();
try {
while (-1 != (n = in.read(buffer))) {
try {
out.write(buffer, 0, n);
} catch (IOException e) {
// Error writing to the output stream, probably because the connection
// was closed by the client. Don't attempt to write anything else to
// the response and just log the error using FINE level logging.
logException(request, Level.FINE, sourceMethod, e);
success = false;
break;
}
}
} finally {
IOUtils.closeQuietly(in);
IOUtils.closeQuietly(out);
}
if (isTraceLogging) {
log.exiting(AbstractAggregatorImpl.class.getName(), sourceMethod, success);
}
return success;
}
|
[
"protected",
"boolean",
"writeResponse",
"(",
"InputStream",
"in",
",",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
")",
"throws",
"IOException",
"{",
"final",
"String",
"sourceMethod",
"=",
"\"writeResponse\"",
";",
"//$NON-NLS-1$\r",
"final",
"boolean",
"isTraceLogging",
"=",
"log",
".",
"isLoggable",
"(",
"Level",
".",
"FINER",
")",
";",
"if",
"(",
"isTraceLogging",
")",
"{",
"log",
".",
"entering",
"(",
"AbstractAggregatorImpl",
".",
"class",
".",
"getName",
"(",
")",
",",
"sourceMethod",
",",
"new",
"Object",
"[",
"]",
"{",
"in",
",",
"response",
"}",
")",
";",
"}",
"boolean",
"success",
"=",
"true",
";",
"int",
"n",
"=",
"0",
";",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"4096",
"]",
";",
"OutputStream",
"out",
"=",
"response",
".",
"getOutputStream",
"(",
")",
";",
"try",
"{",
"while",
"(",
"-",
"1",
"!=",
"(",
"n",
"=",
"in",
".",
"read",
"(",
"buffer",
")",
")",
")",
"{",
"try",
"{",
"out",
".",
"write",
"(",
"buffer",
",",
"0",
",",
"n",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"// Error writing to the output stream, probably because the connection\r",
"// was closed by the client. Don't attempt to write anything else to\r",
"// the response and just log the error using FINE level logging.\r",
"logException",
"(",
"request",
",",
"Level",
".",
"FINE",
",",
"sourceMethod",
",",
"e",
")",
";",
"success",
"=",
"false",
";",
"break",
";",
"}",
"}",
"}",
"finally",
"{",
"IOUtils",
".",
"closeQuietly",
"(",
"in",
")",
";",
"IOUtils",
".",
"closeQuietly",
"(",
"out",
")",
";",
"}",
"if",
"(",
"isTraceLogging",
")",
"{",
"log",
".",
"exiting",
"(",
"AbstractAggregatorImpl",
".",
"class",
".",
"getName",
"(",
")",
",",
"sourceMethod",
",",
"success",
")",
";",
"}",
"return",
"success",
";",
"}"
] |
Writes the response to the response object. IOExceptions that occur when writing to the
response output stream are not propagated, but are handled internally. Such exceptions
are assumed to be caused by the client closing the connection and are not real errors.
@param in
the input stream.
@param request
the http request object
@param response
the http response object
@return true if all of the data from the input stream was written to the response
@throws IOException
|
[
"Writes",
"the",
"response",
"to",
"the",
"response",
"object",
".",
"IOExceptions",
"that",
"occur",
"when",
"writing",
"to",
"the",
"response",
"output",
"stream",
"are",
"not",
"propagated",
"but",
"are",
"handled",
"internally",
".",
"Such",
"exceptions",
"are",
"assumed",
"to",
"be",
"caused",
"by",
"the",
"client",
"closing",
"the",
"connection",
"and",
"are",
"not",
"real",
"errors",
"."
] |
train
|
https://github.com/OpenNTF/JavascriptAggregator/blob/9f47a96d778251638b1df9a368462176216d5b29/jaggr-core/src/main/java/com/ibm/jaggr/core/impl/AbstractAggregatorImpl.java#L917-L948
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java
|
ApiOvhTelephony.billingAccount_rsva_serviceName_PUT
|
public void billingAccount_rsva_serviceName_PUT(String billingAccount, String serviceName, OvhRsva body) throws IOException {
"""
Alter this object properties
REST: PUT /telephony/{billingAccount}/rsva/{serviceName}
@param body [required] New object properties
@param billingAccount [required] The name of your billingAccount
@param serviceName [required]
"""
String qPath = "/telephony/{billingAccount}/rsva/{serviceName}";
StringBuilder sb = path(qPath, billingAccount, serviceName);
exec(qPath, "PUT", sb.toString(), body);
}
|
java
|
public void billingAccount_rsva_serviceName_PUT(String billingAccount, String serviceName, OvhRsva body) throws IOException {
String qPath = "/telephony/{billingAccount}/rsva/{serviceName}";
StringBuilder sb = path(qPath, billingAccount, serviceName);
exec(qPath, "PUT", sb.toString(), body);
}
|
[
"public",
"void",
"billingAccount_rsva_serviceName_PUT",
"(",
"String",
"billingAccount",
",",
"String",
"serviceName",
",",
"OvhRsva",
"body",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/telephony/{billingAccount}/rsva/{serviceName}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"billingAccount",
",",
"serviceName",
")",
";",
"exec",
"(",
"qPath",
",",
"\"PUT\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"body",
")",
";",
"}"
] |
Alter this object properties
REST: PUT /telephony/{billingAccount}/rsva/{serviceName}
@param body [required] New object properties
@param billingAccount [required] The name of your billingAccount
@param serviceName [required]
|
[
"Alter",
"this",
"object",
"properties"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L5937-L5941
|
apache/flink
|
flink-table/flink-table-common/src/main/java/org/apache/flink/table/functions/FunctionContext.java
|
FunctionContext.getJobParameter
|
public String getJobParameter(String key, String defaultValue) {
"""
Gets the global job parameter value associated with the given key as a string.
@param key key pointing to the associated value
@param defaultValue default value which is returned in case global job parameter is null
or there is no value associated with the given key
@return (default) value associated with the given key
"""
final GlobalJobParameters conf = context.getExecutionConfig().getGlobalJobParameters();
if (conf != null && conf.toMap().containsKey(key)) {
return conf.toMap().get(key);
} else {
return defaultValue;
}
}
|
java
|
public String getJobParameter(String key, String defaultValue) {
final GlobalJobParameters conf = context.getExecutionConfig().getGlobalJobParameters();
if (conf != null && conf.toMap().containsKey(key)) {
return conf.toMap().get(key);
} else {
return defaultValue;
}
}
|
[
"public",
"String",
"getJobParameter",
"(",
"String",
"key",
",",
"String",
"defaultValue",
")",
"{",
"final",
"GlobalJobParameters",
"conf",
"=",
"context",
".",
"getExecutionConfig",
"(",
")",
".",
"getGlobalJobParameters",
"(",
")",
";",
"if",
"(",
"conf",
"!=",
"null",
"&&",
"conf",
".",
"toMap",
"(",
")",
".",
"containsKey",
"(",
"key",
")",
")",
"{",
"return",
"conf",
".",
"toMap",
"(",
")",
".",
"get",
"(",
"key",
")",
";",
"}",
"else",
"{",
"return",
"defaultValue",
";",
"}",
"}"
] |
Gets the global job parameter value associated with the given key as a string.
@param key key pointing to the associated value
@param defaultValue default value which is returned in case global job parameter is null
or there is no value associated with the given key
@return (default) value associated with the given key
|
[
"Gets",
"the",
"global",
"job",
"parameter",
"value",
"associated",
"with",
"the",
"given",
"key",
"as",
"a",
"string",
"."
] |
train
|
https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-common/src/main/java/org/apache/flink/table/functions/FunctionContext.java#L76-L83
|
Jasig/uPortal
|
uPortal-utils/uPortal-utils-core/src/main/java/org/apereo/portal/jdbc/RDBMServices.java
|
RDBMServices.setAutoCommit
|
public static final void setAutoCommit(final Connection connection, boolean autocommit) {
"""
Set auto commit state for the connection. Unlike the underlying connection.setAutoCommit(),
this method does not throw SQLException or any other Exception. It fails silently from the
perspective of calling code, logging any errors encountered using Commons Logging.
@param connection
@param autocommit
"""
try {
connection.setAutoCommit(autocommit);
} catch (Exception e) {
if (LOG.isWarnEnabled())
LOG.warn("Error committing Connection: " + connection + " to: " + autocommit, e);
}
}
|
java
|
public static final void setAutoCommit(final Connection connection, boolean autocommit) {
try {
connection.setAutoCommit(autocommit);
} catch (Exception e) {
if (LOG.isWarnEnabled())
LOG.warn("Error committing Connection: " + connection + " to: " + autocommit, e);
}
}
|
[
"public",
"static",
"final",
"void",
"setAutoCommit",
"(",
"final",
"Connection",
"connection",
",",
"boolean",
"autocommit",
")",
"{",
"try",
"{",
"connection",
".",
"setAutoCommit",
"(",
"autocommit",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"if",
"(",
"LOG",
".",
"isWarnEnabled",
"(",
")",
")",
"LOG",
".",
"warn",
"(",
"\"Error committing Connection: \"",
"+",
"connection",
"+",
"\" to: \"",
"+",
"autocommit",
",",
"e",
")",
";",
"}",
"}"
] |
Set auto commit state for the connection. Unlike the underlying connection.setAutoCommit(),
this method does not throw SQLException or any other Exception. It fails silently from the
perspective of calling code, logging any errors encountered using Commons Logging.
@param connection
@param autocommit
|
[
"Set",
"auto",
"commit",
"state",
"for",
"the",
"connection",
".",
"Unlike",
"the",
"underlying",
"connection",
".",
"setAutoCommit",
"()",
"this",
"method",
"does",
"not",
"throw",
"SQLException",
"or",
"any",
"other",
"Exception",
".",
"It",
"fails",
"silently",
"from",
"the",
"perspective",
"of",
"calling",
"code",
"logging",
"any",
"errors",
"encountered",
"using",
"Commons",
"Logging",
"."
] |
train
|
https://github.com/Jasig/uPortal/blob/c1986542abb9acd214268f2df21c6305ad2f262b/uPortal-utils/uPortal-utils-core/src/main/java/org/apereo/portal/jdbc/RDBMServices.java#L270-L277
|
authlete/authlete-java-common
|
src/main/java/com/authlete/common/util/TypedProperties.java
|
TypedProperties.setLong
|
public void setLong(Enum<?> key, long value) {
"""
Equivalent to {@link #setLong(String, long)
setLong}{@code (key.name(), value)}.
If {@code key} is null, nothing is done.
"""
if (key == null)
{
return;
}
setLong(key.name(), value);
}
|
java
|
public void setLong(Enum<?> key, long value)
{
if (key == null)
{
return;
}
setLong(key.name(), value);
}
|
[
"public",
"void",
"setLong",
"(",
"Enum",
"<",
"?",
">",
"key",
",",
"long",
"value",
")",
"{",
"if",
"(",
"key",
"==",
"null",
")",
"{",
"return",
";",
"}",
"setLong",
"(",
"key",
".",
"name",
"(",
")",
",",
"value",
")",
";",
"}"
] |
Equivalent to {@link #setLong(String, long)
setLong}{@code (key.name(), value)}.
If {@code key} is null, nothing is done.
|
[
"Equivalent",
"to",
"{"
] |
train
|
https://github.com/authlete/authlete-java-common/blob/49c94c483713cbf5a04d805ff7dbd83766c9c964/src/main/java/com/authlete/common/util/TypedProperties.java#L726-L734
|
groupon/odo
|
client/src/main/java/com/groupon/odo/client/Client.java
|
Client.addServerGroup
|
public ServerGroup addServerGroup(String groupName) {
"""
Create a new server group
@param groupName name of server group
@return Created ServerGroup
"""
ServerGroup group = new ServerGroup();
BasicNameValuePair[] params = {
new BasicNameValuePair("name", groupName),
new BasicNameValuePair("profileIdentifier", this._profileName)
};
try {
JSONObject response = new JSONObject(doPost(BASE_SERVERGROUP, params));
group = getServerGroupFromJSON(response);
} catch (Exception e) {
e.printStackTrace();
return null;
}
return group;
}
|
java
|
public ServerGroup addServerGroup(String groupName) {
ServerGroup group = new ServerGroup();
BasicNameValuePair[] params = {
new BasicNameValuePair("name", groupName),
new BasicNameValuePair("profileIdentifier", this._profileName)
};
try {
JSONObject response = new JSONObject(doPost(BASE_SERVERGROUP, params));
group = getServerGroupFromJSON(response);
} catch (Exception e) {
e.printStackTrace();
return null;
}
return group;
}
|
[
"public",
"ServerGroup",
"addServerGroup",
"(",
"String",
"groupName",
")",
"{",
"ServerGroup",
"group",
"=",
"new",
"ServerGroup",
"(",
")",
";",
"BasicNameValuePair",
"[",
"]",
"params",
"=",
"{",
"new",
"BasicNameValuePair",
"(",
"\"name\"",
",",
"groupName",
")",
",",
"new",
"BasicNameValuePair",
"(",
"\"profileIdentifier\"",
",",
"this",
".",
"_profileName",
")",
"}",
";",
"try",
"{",
"JSONObject",
"response",
"=",
"new",
"JSONObject",
"(",
"doPost",
"(",
"BASE_SERVERGROUP",
",",
"params",
")",
")",
";",
"group",
"=",
"getServerGroupFromJSON",
"(",
"response",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"return",
"null",
";",
"}",
"return",
"group",
";",
"}"
] |
Create a new server group
@param groupName name of server group
@return Created ServerGroup
|
[
"Create",
"a",
"new",
"server",
"group"
] |
train
|
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/client/src/main/java/com/groupon/odo/client/Client.java#L1205-L1220
|
primefaces/primefaces
|
src/main/java/org/primefaces/component/repeat/UIRepeat.java
|
UIRepeat.saveInitialChildState
|
private void saveInitialChildState(FacesContext facesContext, UIComponent component) {
"""
Recursively create the initial state for the given component.
@param facesContext the Faces context.
@param component the UI component to save the state for.
@see #saveInitialChildState(javax.faces.context.FacesContext)
"""
if (component instanceof EditableValueHolder && !component.isTransient()) {
String clientId = component.getClientId(facesContext);
SavedState state = new SavedState();
initialChildState.put(clientId, state);
state.populate((EditableValueHolder) component);
}
Iterator<UIComponent> iterator = component.getFacetsAndChildren();
while (iterator.hasNext()) {
saveChildState(facesContext, iterator.next());
}
}
|
java
|
private void saveInitialChildState(FacesContext facesContext, UIComponent component) {
if (component instanceof EditableValueHolder && !component.isTransient()) {
String clientId = component.getClientId(facesContext);
SavedState state = new SavedState();
initialChildState.put(clientId, state);
state.populate((EditableValueHolder) component);
}
Iterator<UIComponent> iterator = component.getFacetsAndChildren();
while (iterator.hasNext()) {
saveChildState(facesContext, iterator.next());
}
}
|
[
"private",
"void",
"saveInitialChildState",
"(",
"FacesContext",
"facesContext",
",",
"UIComponent",
"component",
")",
"{",
"if",
"(",
"component",
"instanceof",
"EditableValueHolder",
"&&",
"!",
"component",
".",
"isTransient",
"(",
")",
")",
"{",
"String",
"clientId",
"=",
"component",
".",
"getClientId",
"(",
"facesContext",
")",
";",
"SavedState",
"state",
"=",
"new",
"SavedState",
"(",
")",
";",
"initialChildState",
".",
"put",
"(",
"clientId",
",",
"state",
")",
";",
"state",
".",
"populate",
"(",
"(",
"EditableValueHolder",
")",
"component",
")",
";",
"}",
"Iterator",
"<",
"UIComponent",
">",
"iterator",
"=",
"component",
".",
"getFacetsAndChildren",
"(",
")",
";",
"while",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"saveChildState",
"(",
"facesContext",
",",
"iterator",
".",
"next",
"(",
")",
")",
";",
"}",
"}"
] |
Recursively create the initial state for the given component.
@param facesContext the Faces context.
@param component the UI component to save the state for.
@see #saveInitialChildState(javax.faces.context.FacesContext)
|
[
"Recursively",
"create",
"the",
"initial",
"state",
"for",
"the",
"given",
"component",
"."
] |
train
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/component/repeat/UIRepeat.java#L470-L482
|
zeroturnaround/zt-zip
|
src/main/java/org/zeroturnaround/zip/commons/IOUtils.java
|
IOUtils.copyLarge
|
public static long copyLarge(Reader input, Writer output) throws IOException {
"""
Copy chars from a large (over 2GB) <code>Reader</code> to a <code>Writer</code>.
<p>
This method buffers the input internally, so there is no need to use a
<code>BufferedReader</code>.
<p>
The buffer size is given by {@link #DEFAULT_BUFFER_SIZE}.
@param input the <code>Reader</code> to read from
@param output the <code>Writer</code> to write to
@return the number of characters copied
@throws NullPointerException if the input or output is null
@throws IOException if an I/O error occurs
@since 1.3
"""
return copyLarge(input, output, new char[DEFAULT_BUFFER_SIZE]);
}
|
java
|
public static long copyLarge(Reader input, Writer output) throws IOException {
return copyLarge(input, output, new char[DEFAULT_BUFFER_SIZE]);
}
|
[
"public",
"static",
"long",
"copyLarge",
"(",
"Reader",
"input",
",",
"Writer",
"output",
")",
"throws",
"IOException",
"{",
"return",
"copyLarge",
"(",
"input",
",",
"output",
",",
"new",
"char",
"[",
"DEFAULT_BUFFER_SIZE",
"]",
")",
";",
"}"
] |
Copy chars from a large (over 2GB) <code>Reader</code> to a <code>Writer</code>.
<p>
This method buffers the input internally, so there is no need to use a
<code>BufferedReader</code>.
<p>
The buffer size is given by {@link #DEFAULT_BUFFER_SIZE}.
@param input the <code>Reader</code> to read from
@param output the <code>Writer</code> to write to
@return the number of characters copied
@throws NullPointerException if the input or output is null
@throws IOException if an I/O error occurs
@since 1.3
|
[
"Copy",
"chars",
"from",
"a",
"large",
"(",
"over",
"2GB",
")",
"<code",
">",
"Reader<",
"/",
"code",
">",
"to",
"a",
"<code",
">",
"Writer<",
"/",
"code",
">",
".",
"<p",
">",
"This",
"method",
"buffers",
"the",
"input",
"internally",
"so",
"there",
"is",
"no",
"need",
"to",
"use",
"a",
"<code",
">",
"BufferedReader<",
"/",
"code",
">",
".",
"<p",
">",
"The",
"buffer",
"size",
"is",
"given",
"by",
"{",
"@link",
"#DEFAULT_BUFFER_SIZE",
"}",
"."
] |
train
|
https://github.com/zeroturnaround/zt-zip/blob/abb4dc43583e4d19339c0c021035019798970a13/src/main/java/org/zeroturnaround/zip/commons/IOUtils.java#L422-L424
|
finsterwalder/fileutils
|
src/main/java/name/finsterwalder/utils/Ensure.java
|
Ensure.notEmpty
|
public static void notEmpty(final Collection<?> collection, final String parameterName) {
"""
Check that the provided Collection is not empty).
@param collection collection to check
@param parameterName name of the parameter to display in the error message
"""
if (collection.isEmpty()) {
throw new IllegalArgumentException("\"" + parameterName + "\" must not be null or empty, but was: " + collection);
}
}
|
java
|
public static void notEmpty(final Collection<?> collection, final String parameterName) {
if (collection.isEmpty()) {
throw new IllegalArgumentException("\"" + parameterName + "\" must not be null or empty, but was: " + collection);
}
}
|
[
"public",
"static",
"void",
"notEmpty",
"(",
"final",
"Collection",
"<",
"?",
">",
"collection",
",",
"final",
"String",
"parameterName",
")",
"{",
"if",
"(",
"collection",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"\\\"\"",
"+",
"parameterName",
"+",
"\"\\\" must not be null or empty, but was: \"",
"+",
"collection",
")",
";",
"}",
"}"
] |
Check that the provided Collection is not empty).
@param collection collection to check
@param parameterName name of the parameter to display in the error message
|
[
"Check",
"that",
"the",
"provided",
"Collection",
"is",
"not",
"empty",
")",
"."
] |
train
|
https://github.com/finsterwalder/fileutils/blob/db5e00f37a2c8bbdfd9bc070d187620c2ed1ad29/src/main/java/name/finsterwalder/utils/Ensure.java#L76-L80
|
graphql-java/graphql-java
|
src/main/java/graphql/analysis/QueryTraversal.java
|
QueryTraversal.reducePostOrder
|
@SuppressWarnings("unchecked")
public <T> T reducePostOrder(QueryReducer<T> queryReducer, T initialValue) {
"""
Reduces the fields of a Document (or parts of it) to a single value. The fields are visited in post-order.
@param queryReducer the query reducer
@param initialValue the initial value to pass to the reducer
@param <T> the type of reduced value
@return the calculated overall value
"""
// compiler hack to make acc final and mutable :-)
final Object[] acc = {initialValue};
visitPostOrder(new QueryVisitorStub() {
@Override
public void visitField(QueryVisitorFieldEnvironment env) {
acc[0] = queryReducer.reduceField(env, (T) acc[0]);
}
});
return (T) acc[0];
}
|
java
|
@SuppressWarnings("unchecked")
public <T> T reducePostOrder(QueryReducer<T> queryReducer, T initialValue) {
// compiler hack to make acc final and mutable :-)
final Object[] acc = {initialValue};
visitPostOrder(new QueryVisitorStub() {
@Override
public void visitField(QueryVisitorFieldEnvironment env) {
acc[0] = queryReducer.reduceField(env, (T) acc[0]);
}
});
return (T) acc[0];
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"T",
">",
"T",
"reducePostOrder",
"(",
"QueryReducer",
"<",
"T",
">",
"queryReducer",
",",
"T",
"initialValue",
")",
"{",
"// compiler hack to make acc final and mutable :-)",
"final",
"Object",
"[",
"]",
"acc",
"=",
"{",
"initialValue",
"}",
";",
"visitPostOrder",
"(",
"new",
"QueryVisitorStub",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"visitField",
"(",
"QueryVisitorFieldEnvironment",
"env",
")",
"{",
"acc",
"[",
"0",
"]",
"=",
"queryReducer",
".",
"reduceField",
"(",
"env",
",",
"(",
"T",
")",
"acc",
"[",
"0",
"]",
")",
";",
"}",
"}",
")",
";",
"return",
"(",
"T",
")",
"acc",
"[",
"0",
"]",
";",
"}"
] |
Reduces the fields of a Document (or parts of it) to a single value. The fields are visited in post-order.
@param queryReducer the query reducer
@param initialValue the initial value to pass to the reducer
@param <T> the type of reduced value
@return the calculated overall value
|
[
"Reduces",
"the",
"fields",
"of",
"a",
"Document",
"(",
"or",
"parts",
"of",
"it",
")",
"to",
"a",
"single",
"value",
".",
"The",
"fields",
"are",
"visited",
"in",
"post",
"-",
"order",
"."
] |
train
|
https://github.com/graphql-java/graphql-java/blob/9214b6044317849388bd88a14b54fc1c18c9f29f/src/main/java/graphql/analysis/QueryTraversal.java#L105-L116
|
Netflix/astyanax
|
astyanax-cassandra/src/main/java/com/netflix/astyanax/mapping/Mapping.java
|
Mapping.fillMutation
|
public void fillMutation(T instance, ColumnListMutation<String> mutation) {
"""
Map a bean to a column mutation. i.e. set the columns in the mutation to
the corresponding values from the instance
@param instance
instance
@param mutation
mutation
"""
for (String fieldName : getNames()) {
Coercions.setColumnMutationFromField(instance, fields.get(fieldName), fieldName, mutation);
}
}
|
java
|
public void fillMutation(T instance, ColumnListMutation<String> mutation) {
for (String fieldName : getNames()) {
Coercions.setColumnMutationFromField(instance, fields.get(fieldName), fieldName, mutation);
}
}
|
[
"public",
"void",
"fillMutation",
"(",
"T",
"instance",
",",
"ColumnListMutation",
"<",
"String",
">",
"mutation",
")",
"{",
"for",
"(",
"String",
"fieldName",
":",
"getNames",
"(",
")",
")",
"{",
"Coercions",
".",
"setColumnMutationFromField",
"(",
"instance",
",",
"fields",
".",
"get",
"(",
"fieldName",
")",
",",
"fieldName",
",",
"mutation",
")",
";",
"}",
"}"
] |
Map a bean to a column mutation. i.e. set the columns in the mutation to
the corresponding values from the instance
@param instance
instance
@param mutation
mutation
|
[
"Map",
"a",
"bean",
"to",
"a",
"column",
"mutation",
".",
"i",
".",
"e",
".",
"set",
"the",
"columns",
"in",
"the",
"mutation",
"to",
"the",
"corresponding",
"values",
"from",
"the",
"instance"
] |
train
|
https://github.com/Netflix/astyanax/blob/bcc3fd26e2dda05a923751aa32b139f6209fecdf/astyanax-cassandra/src/main/java/com/netflix/astyanax/mapping/Mapping.java#L241-L245
|
liferay/com-liferay-commerce
|
commerce-service/src/main/java/com/liferay/commerce/service/persistence/impl/CommerceWarehouseItemPersistenceImpl.java
|
CommerceWarehouseItemPersistenceImpl.findByCommerceWarehouseId
|
@Override
public List<CommerceWarehouseItem> findByCommerceWarehouseId(
long commerceWarehouseId, int start, int end) {
"""
Returns a range of all the commerce warehouse items where commerceWarehouseId = ?.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CommerceWarehouseItemModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param commerceWarehouseId the commerce warehouse ID
@param start the lower bound of the range of commerce warehouse items
@param end the upper bound of the range of commerce warehouse items (not inclusive)
@return the range of matching commerce warehouse items
"""
return findByCommerceWarehouseId(commerceWarehouseId, start, end, null);
}
|
java
|
@Override
public List<CommerceWarehouseItem> findByCommerceWarehouseId(
long commerceWarehouseId, int start, int end) {
return findByCommerceWarehouseId(commerceWarehouseId, start, end, null);
}
|
[
"@",
"Override",
"public",
"List",
"<",
"CommerceWarehouseItem",
">",
"findByCommerceWarehouseId",
"(",
"long",
"commerceWarehouseId",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"return",
"findByCommerceWarehouseId",
"(",
"commerceWarehouseId",
",",
"start",
",",
"end",
",",
"null",
")",
";",
"}"
] |
Returns a range of all the commerce warehouse items where commerceWarehouseId = ?.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CommerceWarehouseItemModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param commerceWarehouseId the commerce warehouse ID
@param start the lower bound of the range of commerce warehouse items
@param end the upper bound of the range of commerce warehouse items (not inclusive)
@return the range of matching commerce warehouse items
|
[
"Returns",
"a",
"range",
"of",
"all",
"the",
"commerce",
"warehouse",
"items",
"where",
"commerceWarehouseId",
"=",
"?",
";",
"."
] |
train
|
https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-service/src/main/java/com/liferay/commerce/service/persistence/impl/CommerceWarehouseItemPersistenceImpl.java#L143-L147
|
VoltDB/voltdb
|
src/frontend/org/voltdb/iv2/LeaderCache.java
|
LeaderCache.processChildEvent
|
private void processChildEvent(WatchedEvent event) throws Exception {
"""
Update a modified child and republish a new snapshot. This may indicate
a deleted child or a child with modified data.
"""
HashMap<Integer, LeaderCallBackInfo> cacheCopy = new HashMap<Integer, LeaderCallBackInfo>(m_publicCache);
ByteArrayCallback cb = new ByteArrayCallback();
m_zk.getData(event.getPath(), m_childWatch, cb, null);
try {
// cb.getData() and cb.getPath() throw KeeperException
byte payload[] = cb.get();
String data = new String(payload, "UTF-8");
LeaderCallBackInfo info = LeaderCache.buildLeaderCallbackFromString(data);
Integer partitionId = getPartitionIdFromZKPath(cb.getPath());
cacheCopy.put(partitionId, info);
} catch (KeeperException.NoNodeException e) {
// rtb: I think result's path is the same as cb.getPath()?
Integer partitionId = getPartitionIdFromZKPath(event.getPath());
cacheCopy.remove(partitionId);
}
m_publicCache = ImmutableMap.copyOf(cacheCopy);
if (m_cb != null) {
m_cb.run(m_publicCache);
}
}
|
java
|
private void processChildEvent(WatchedEvent event) throws Exception {
HashMap<Integer, LeaderCallBackInfo> cacheCopy = new HashMap<Integer, LeaderCallBackInfo>(m_publicCache);
ByteArrayCallback cb = new ByteArrayCallback();
m_zk.getData(event.getPath(), m_childWatch, cb, null);
try {
// cb.getData() and cb.getPath() throw KeeperException
byte payload[] = cb.get();
String data = new String(payload, "UTF-8");
LeaderCallBackInfo info = LeaderCache.buildLeaderCallbackFromString(data);
Integer partitionId = getPartitionIdFromZKPath(cb.getPath());
cacheCopy.put(partitionId, info);
} catch (KeeperException.NoNodeException e) {
// rtb: I think result's path is the same as cb.getPath()?
Integer partitionId = getPartitionIdFromZKPath(event.getPath());
cacheCopy.remove(partitionId);
}
m_publicCache = ImmutableMap.copyOf(cacheCopy);
if (m_cb != null) {
m_cb.run(m_publicCache);
}
}
|
[
"private",
"void",
"processChildEvent",
"(",
"WatchedEvent",
"event",
")",
"throws",
"Exception",
"{",
"HashMap",
"<",
"Integer",
",",
"LeaderCallBackInfo",
">",
"cacheCopy",
"=",
"new",
"HashMap",
"<",
"Integer",
",",
"LeaderCallBackInfo",
">",
"(",
"m_publicCache",
")",
";",
"ByteArrayCallback",
"cb",
"=",
"new",
"ByteArrayCallback",
"(",
")",
";",
"m_zk",
".",
"getData",
"(",
"event",
".",
"getPath",
"(",
")",
",",
"m_childWatch",
",",
"cb",
",",
"null",
")",
";",
"try",
"{",
"// cb.getData() and cb.getPath() throw KeeperException",
"byte",
"payload",
"[",
"]",
"=",
"cb",
".",
"get",
"(",
")",
";",
"String",
"data",
"=",
"new",
"String",
"(",
"payload",
",",
"\"UTF-8\"",
")",
";",
"LeaderCallBackInfo",
"info",
"=",
"LeaderCache",
".",
"buildLeaderCallbackFromString",
"(",
"data",
")",
";",
"Integer",
"partitionId",
"=",
"getPartitionIdFromZKPath",
"(",
"cb",
".",
"getPath",
"(",
")",
")",
";",
"cacheCopy",
".",
"put",
"(",
"partitionId",
",",
"info",
")",
";",
"}",
"catch",
"(",
"KeeperException",
".",
"NoNodeException",
"e",
")",
"{",
"// rtb: I think result's path is the same as cb.getPath()?",
"Integer",
"partitionId",
"=",
"getPartitionIdFromZKPath",
"(",
"event",
".",
"getPath",
"(",
")",
")",
";",
"cacheCopy",
".",
"remove",
"(",
"partitionId",
")",
";",
"}",
"m_publicCache",
"=",
"ImmutableMap",
".",
"copyOf",
"(",
"cacheCopy",
")",
";",
"if",
"(",
"m_cb",
"!=",
"null",
")",
"{",
"m_cb",
".",
"run",
"(",
"m_publicCache",
")",
";",
"}",
"}"
] |
Update a modified child and republish a new snapshot. This may indicate
a deleted child or a child with modified data.
|
[
"Update",
"a",
"modified",
"child",
"and",
"republish",
"a",
"new",
"snapshot",
".",
"This",
"may",
"indicate",
"a",
"deleted",
"child",
"or",
"a",
"child",
"with",
"modified",
"data",
"."
] |
train
|
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/iv2/LeaderCache.java#L352-L372
|
apache/flink
|
flink-yarn/src/main/java/org/apache/flink/yarn/Utils.java
|
Utils.setupLocalResource
|
static Tuple2<Path, LocalResource> setupLocalResource(
FileSystem fs,
String appId,
Path localSrcPath,
Path homedir,
String relativeTargetPath) throws IOException {
"""
Copy a local file to a remote file system.
@param fs
remote filesystem
@param appId
application ID
@param localSrcPath
path to the local file
@param homedir
remote home directory base (will be extended)
@param relativeTargetPath
relative target path of the file (will be prefixed be the full home directory we set up)
@return Path to remote file (usually hdfs)
"""
File localFile = new File(localSrcPath.toUri().getPath());
if (localFile.isDirectory()) {
throw new IllegalArgumentException("File to copy must not be a directory: " +
localSrcPath);
}
// copy resource to HDFS
String suffix =
".flink/"
+ appId
+ (relativeTargetPath.isEmpty() ? "" : "/" + relativeTargetPath)
+ "/" + localSrcPath.getName();
Path dst = new Path(homedir, suffix);
LOG.debug("Copying from {} to {}", localSrcPath, dst);
fs.copyFromLocalFile(false, true, localSrcPath, dst);
// Note: If we used registerLocalResource(FileSystem, Path) here, we would access the remote
// file once again which has problems with eventually consistent read-after-write file
// systems. Instead, we decide to preserve the modification time at the remote
// location because this and the size of the resource will be checked by YARN based on
// the values we provide to #registerLocalResource() below.
fs.setTimes(dst, localFile.lastModified(), -1);
// now create the resource instance
LocalResource resource = registerLocalResource(dst, localFile.length(), localFile.lastModified());
return Tuple2.of(dst, resource);
}
|
java
|
static Tuple2<Path, LocalResource> setupLocalResource(
FileSystem fs,
String appId,
Path localSrcPath,
Path homedir,
String relativeTargetPath) throws IOException {
File localFile = new File(localSrcPath.toUri().getPath());
if (localFile.isDirectory()) {
throw new IllegalArgumentException("File to copy must not be a directory: " +
localSrcPath);
}
// copy resource to HDFS
String suffix =
".flink/"
+ appId
+ (relativeTargetPath.isEmpty() ? "" : "/" + relativeTargetPath)
+ "/" + localSrcPath.getName();
Path dst = new Path(homedir, suffix);
LOG.debug("Copying from {} to {}", localSrcPath, dst);
fs.copyFromLocalFile(false, true, localSrcPath, dst);
// Note: If we used registerLocalResource(FileSystem, Path) here, we would access the remote
// file once again which has problems with eventually consistent read-after-write file
// systems. Instead, we decide to preserve the modification time at the remote
// location because this and the size of the resource will be checked by YARN based on
// the values we provide to #registerLocalResource() below.
fs.setTimes(dst, localFile.lastModified(), -1);
// now create the resource instance
LocalResource resource = registerLocalResource(dst, localFile.length(), localFile.lastModified());
return Tuple2.of(dst, resource);
}
|
[
"static",
"Tuple2",
"<",
"Path",
",",
"LocalResource",
">",
"setupLocalResource",
"(",
"FileSystem",
"fs",
",",
"String",
"appId",
",",
"Path",
"localSrcPath",
",",
"Path",
"homedir",
",",
"String",
"relativeTargetPath",
")",
"throws",
"IOException",
"{",
"File",
"localFile",
"=",
"new",
"File",
"(",
"localSrcPath",
".",
"toUri",
"(",
")",
".",
"getPath",
"(",
")",
")",
";",
"if",
"(",
"localFile",
".",
"isDirectory",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"File to copy must not be a directory: \"",
"+",
"localSrcPath",
")",
";",
"}",
"// copy resource to HDFS",
"String",
"suffix",
"=",
"\".flink/\"",
"+",
"appId",
"+",
"(",
"relativeTargetPath",
".",
"isEmpty",
"(",
")",
"?",
"\"\"",
":",
"\"/\"",
"+",
"relativeTargetPath",
")",
"+",
"\"/\"",
"+",
"localSrcPath",
".",
"getName",
"(",
")",
";",
"Path",
"dst",
"=",
"new",
"Path",
"(",
"homedir",
",",
"suffix",
")",
";",
"LOG",
".",
"debug",
"(",
"\"Copying from {} to {}\"",
",",
"localSrcPath",
",",
"dst",
")",
";",
"fs",
".",
"copyFromLocalFile",
"(",
"false",
",",
"true",
",",
"localSrcPath",
",",
"dst",
")",
";",
"// Note: If we used registerLocalResource(FileSystem, Path) here, we would access the remote",
"// file once again which has problems with eventually consistent read-after-write file",
"// systems. Instead, we decide to preserve the modification time at the remote",
"// location because this and the size of the resource will be checked by YARN based on",
"// the values we provide to #registerLocalResource() below.",
"fs",
".",
"setTimes",
"(",
"dst",
",",
"localFile",
".",
"lastModified",
"(",
")",
",",
"-",
"1",
")",
";",
"// now create the resource instance",
"LocalResource",
"resource",
"=",
"registerLocalResource",
"(",
"dst",
",",
"localFile",
".",
"length",
"(",
")",
",",
"localFile",
".",
"lastModified",
"(",
")",
")",
";",
"return",
"Tuple2",
".",
"of",
"(",
"dst",
",",
"resource",
")",
";",
"}"
] |
Copy a local file to a remote file system.
@param fs
remote filesystem
@param appId
application ID
@param localSrcPath
path to the local file
@param homedir
remote home directory base (will be extended)
@param relativeTargetPath
relative target path of the file (will be prefixed be the full home directory we set up)
@return Path to remote file (usually hdfs)
|
[
"Copy",
"a",
"local",
"file",
"to",
"a",
"remote",
"file",
"system",
"."
] |
train
|
https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-yarn/src/main/java/org/apache/flink/yarn/Utils.java#L138-L174
|
googleapis/google-cloud-java
|
google-cloud-clients/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SubscriptionAdminClient.java
|
SubscriptionAdminClient.modifyPushConfig
|
public final void modifyPushConfig(String subscription, PushConfig pushConfig) {
"""
Modifies the `PushConfig` for a specified subscription.
<p>This may be used to change a push subscription to a pull one (signified by an empty
`PushConfig`) or vice versa, or change the endpoint URL and other attributes of a push
subscription. Messages will accumulate for delivery continuously through the call regardless of
changes to the `PushConfig`.
<p>Sample code:
<pre><code>
try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
ProjectSubscriptionName subscription = ProjectSubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]");
PushConfig pushConfig = PushConfig.newBuilder().build();
subscriptionAdminClient.modifyPushConfig(subscription.toString(), pushConfig);
}
</code></pre>
@param subscription The name of the subscription. Format is
`projects/{project}/subscriptions/{sub}`.
@param pushConfig The push configuration for future deliveries.
<p>An empty `pushConfig` indicates that the Pub/Sub system should stop pushing messages
from the given subscription and allow messages to be pulled and acknowledged - effectively
pausing the subscription if `Pull` or `StreamingPull` is not called.
@throws com.google.api.gax.rpc.ApiException if the remote call fails
"""
ModifyPushConfigRequest request =
ModifyPushConfigRequest.newBuilder()
.setSubscription(subscription)
.setPushConfig(pushConfig)
.build();
modifyPushConfig(request);
}
|
java
|
public final void modifyPushConfig(String subscription, PushConfig pushConfig) {
ModifyPushConfigRequest request =
ModifyPushConfigRequest.newBuilder()
.setSubscription(subscription)
.setPushConfig(pushConfig)
.build();
modifyPushConfig(request);
}
|
[
"public",
"final",
"void",
"modifyPushConfig",
"(",
"String",
"subscription",
",",
"PushConfig",
"pushConfig",
")",
"{",
"ModifyPushConfigRequest",
"request",
"=",
"ModifyPushConfigRequest",
".",
"newBuilder",
"(",
")",
".",
"setSubscription",
"(",
"subscription",
")",
".",
"setPushConfig",
"(",
"pushConfig",
")",
".",
"build",
"(",
")",
";",
"modifyPushConfig",
"(",
"request",
")",
";",
"}"
] |
Modifies the `PushConfig` for a specified subscription.
<p>This may be used to change a push subscription to a pull one (signified by an empty
`PushConfig`) or vice versa, or change the endpoint URL and other attributes of a push
subscription. Messages will accumulate for delivery continuously through the call regardless of
changes to the `PushConfig`.
<p>Sample code:
<pre><code>
try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
ProjectSubscriptionName subscription = ProjectSubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]");
PushConfig pushConfig = PushConfig.newBuilder().build();
subscriptionAdminClient.modifyPushConfig(subscription.toString(), pushConfig);
}
</code></pre>
@param subscription The name of the subscription. Format is
`projects/{project}/subscriptions/{sub}`.
@param pushConfig The push configuration for future deliveries.
<p>An empty `pushConfig` indicates that the Pub/Sub system should stop pushing messages
from the given subscription and allow messages to be pulled and acknowledged - effectively
pausing the subscription if `Pull` or `StreamingPull` is not called.
@throws com.google.api.gax.rpc.ApiException if the remote call fails
|
[
"Modifies",
"the",
"PushConfig",
"for",
"a",
"specified",
"subscription",
"."
] |
train
|
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SubscriptionAdminClient.java#L1291-L1299
|
devnewton/jnuit
|
jpegdecoder/src/main/java/de/matthiasmann/jpegdecoder/JPEGDecoder.java
|
JPEGDecoder.decodeRGB
|
@Deprecated
public void decodeRGB(ByteBuffer dst, int stride, int numMCURows) throws IOException {
"""
Decodes a number of MCU rows into the specified ByteBuffer as RGBA data.
{@link #startDecode() } must be called before this method.
<p>The first decoded line is placed at {@code dst.position() },
the second line at {@code dst.position() + stride } and so on. After decoding
the buffer position is at {@code dst.position() + n*stride } where n is
the number of decoded lines which might be less than
{@code numMCURows * getMCURowHeight() } at the end of the image.</p>
<p>This method calls {@link #decode(java.nio.ByteBuffer, int, int, de.matthiasmann.jpegdecoder.YUVDecoder) }
with {@link YUVtoRGBA#instance} as decoder.</p>
@param dst the target ByteBuffer
@param stride the distance in bytes from the start of one line to the start of the next.
The absolute value should be >= {@link #getImageWidth() }*4, can also be negative.
@param numMCURows the number of MCU rows to decode.
@throws IOException if an IO error occurred
@throws IllegalArgumentException if numMCURows is invalid
@throws IllegalStateException if {@link #startDecode() } has not been called
@throws UnsupportedOperationException if the JPEG is not a color JPEG
@see #getNumComponents()
@see #getNumMCURows()
@deprecated This method should have been named {@code decodeRGBA}
"""
decode(dst, stride, numMCURows, YUVtoRGBA.instance);
}
|
java
|
@Deprecated
public void decodeRGB(ByteBuffer dst, int stride, int numMCURows) throws IOException {
decode(dst, stride, numMCURows, YUVtoRGBA.instance);
}
|
[
"@",
"Deprecated",
"public",
"void",
"decodeRGB",
"(",
"ByteBuffer",
"dst",
",",
"int",
"stride",
",",
"int",
"numMCURows",
")",
"throws",
"IOException",
"{",
"decode",
"(",
"dst",
",",
"stride",
",",
"numMCURows",
",",
"YUVtoRGBA",
".",
"instance",
")",
";",
"}"
] |
Decodes a number of MCU rows into the specified ByteBuffer as RGBA data.
{@link #startDecode() } must be called before this method.
<p>The first decoded line is placed at {@code dst.position() },
the second line at {@code dst.position() + stride } and so on. After decoding
the buffer position is at {@code dst.position() + n*stride } where n is
the number of decoded lines which might be less than
{@code numMCURows * getMCURowHeight() } at the end of the image.</p>
<p>This method calls {@link #decode(java.nio.ByteBuffer, int, int, de.matthiasmann.jpegdecoder.YUVDecoder) }
with {@link YUVtoRGBA#instance} as decoder.</p>
@param dst the target ByteBuffer
@param stride the distance in bytes from the start of one line to the start of the next.
The absolute value should be >= {@link #getImageWidth() }*4, can also be negative.
@param numMCURows the number of MCU rows to decode.
@throws IOException if an IO error occurred
@throws IllegalArgumentException if numMCURows is invalid
@throws IllegalStateException if {@link #startDecode() } has not been called
@throws UnsupportedOperationException if the JPEG is not a color JPEG
@see #getNumComponents()
@see #getNumMCURows()
@deprecated This method should have been named {@code decodeRGBA}
|
[
"Decodes",
"a",
"number",
"of",
"MCU",
"rows",
"into",
"the",
"specified",
"ByteBuffer",
"as",
"RGBA",
"data",
".",
"{",
"@link",
"#startDecode",
"()",
"}",
"must",
"be",
"called",
"before",
"this",
"method",
"."
] |
train
|
https://github.com/devnewton/jnuit/blob/191f19b55a17451d0f277c151c7e9b4427a12415/jpegdecoder/src/main/java/de/matthiasmann/jpegdecoder/JPEGDecoder.java#L288-L291
|
Harium/keel
|
src/main/java/com/harium/keel/catalano/statistics/HistogramStatistics.java
|
HistogramStatistics.StdDev
|
public static double StdDev( int[] values, double mean ) {
"""
Calculate standart deviation.
@param values Values.
@param mean Mean.
@return Standart deviation.
"""
double stddev = 0;
double diff;
int hits;
int total = 0;
// for all values
for ( int i = 0, n = values.length; i < n; i++ )
{
hits = values[i];
diff = (double) i - mean;
// accumulate std.dev.
stddev += diff * diff * hits;
// accumalate total
total += hits;
}
return ( total == 0 ) ? 0 : Math.sqrt( stddev / (total - 1) );
}
|
java
|
public static double StdDev( int[] values, double mean ){
double stddev = 0;
double diff;
int hits;
int total = 0;
// for all values
for ( int i = 0, n = values.length; i < n; i++ )
{
hits = values[i];
diff = (double) i - mean;
// accumulate std.dev.
stddev += diff * diff * hits;
// accumalate total
total += hits;
}
return ( total == 0 ) ? 0 : Math.sqrt( stddev / (total - 1) );
}
|
[
"public",
"static",
"double",
"StdDev",
"(",
"int",
"[",
"]",
"values",
",",
"double",
"mean",
")",
"{",
"double",
"stddev",
"=",
"0",
";",
"double",
"diff",
";",
"int",
"hits",
";",
"int",
"total",
"=",
"0",
";",
"// for all values",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"n",
"=",
"values",
".",
"length",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"hits",
"=",
"values",
"[",
"i",
"]",
";",
"diff",
"=",
"(",
"double",
")",
"i",
"-",
"mean",
";",
"// accumulate std.dev.",
"stddev",
"+=",
"diff",
"*",
"diff",
"*",
"hits",
";",
"// accumalate total",
"total",
"+=",
"hits",
";",
"}",
"return",
"(",
"total",
"==",
"0",
")",
"?",
"0",
":",
"Math",
".",
"sqrt",
"(",
"stddev",
"/",
"(",
"total",
"-",
"1",
")",
")",
";",
"}"
] |
Calculate standart deviation.
@param values Values.
@param mean Mean.
@return Standart deviation.
|
[
"Calculate",
"standart",
"deviation",
"."
] |
train
|
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/statistics/HistogramStatistics.java#L263-L281
|
sarxos/webcam-capture
|
webcam-capture-drivers/driver-ffmpeg-cli/src/main/java/com/github/sarxos/webcam/ds/ffmpegcli/FFmpegCliDevice.java
|
FFmpegCliDevice.buildImage
|
private BufferedImage buildImage(byte[] bgr) {
"""
Based on answer: https://stackoverflow.com/a/12062505/7030976
@param bgr - byte array in bgr format
@return new image
"""
BufferedImage image = new BufferedImage(resolution.width, resolution.height, BufferedImage.TYPE_3BYTE_BGR);
byte[] imageData = ((DataBufferByte) image.getRaster().getDataBuffer()).getData();
System.arraycopy(bgr, 0, imageData, 0, bgr.length);
return image;
}
|
java
|
private BufferedImage buildImage(byte[] bgr) {
BufferedImage image = new BufferedImage(resolution.width, resolution.height, BufferedImage.TYPE_3BYTE_BGR);
byte[] imageData = ((DataBufferByte) image.getRaster().getDataBuffer()).getData();
System.arraycopy(bgr, 0, imageData, 0, bgr.length);
return image;
}
|
[
"private",
"BufferedImage",
"buildImage",
"(",
"byte",
"[",
"]",
"bgr",
")",
"{",
"BufferedImage",
"image",
"=",
"new",
"BufferedImage",
"(",
"resolution",
".",
"width",
",",
"resolution",
".",
"height",
",",
"BufferedImage",
".",
"TYPE_3BYTE_BGR",
")",
";",
"byte",
"[",
"]",
"imageData",
"=",
"(",
"(",
"DataBufferByte",
")",
"image",
".",
"getRaster",
"(",
")",
".",
"getDataBuffer",
"(",
")",
")",
".",
"getData",
"(",
")",
";",
"System",
".",
"arraycopy",
"(",
"bgr",
",",
"0",
",",
"imageData",
",",
"0",
",",
"bgr",
".",
"length",
")",
";",
"return",
"image",
";",
"}"
] |
Based on answer: https://stackoverflow.com/a/12062505/7030976
@param bgr - byte array in bgr format
@return new image
|
[
"Based",
"on",
"answer",
":",
"https",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"a",
"/",
"12062505",
"/",
"7030976"
] |
train
|
https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture-drivers/driver-ffmpeg-cli/src/main/java/com/github/sarxos/webcam/ds/ffmpegcli/FFmpegCliDevice.java#L85-L91
|
yanzhenjie/Album
|
album/src/main/java/com/yanzhenjie/album/util/AlbumUtils.java
|
AlbumUtils.getColorText
|
@NonNull
public static SpannableString getColorText(@NonNull CharSequence content, int start, int end, @ColorInt int color) {
"""
Change part of the color of CharSequence.
@param content content text.
@param start start index.
@param end end index.
@param color color.
@return {@code SpannableString}.
"""
SpannableString stringSpan = new SpannableString(content);
stringSpan.setSpan(new ForegroundColorSpan(color), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return stringSpan;
}
|
java
|
@NonNull
public static SpannableString getColorText(@NonNull CharSequence content, int start, int end, @ColorInt int color) {
SpannableString stringSpan = new SpannableString(content);
stringSpan.setSpan(new ForegroundColorSpan(color), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return stringSpan;
}
|
[
"@",
"NonNull",
"public",
"static",
"SpannableString",
"getColorText",
"(",
"@",
"NonNull",
"CharSequence",
"content",
",",
"int",
"start",
",",
"int",
"end",
",",
"@",
"ColorInt",
"int",
"color",
")",
"{",
"SpannableString",
"stringSpan",
"=",
"new",
"SpannableString",
"(",
"content",
")",
";",
"stringSpan",
".",
"setSpan",
"(",
"new",
"ForegroundColorSpan",
"(",
"color",
")",
",",
"start",
",",
"end",
",",
"Spannable",
".",
"SPAN_EXCLUSIVE_EXCLUSIVE",
")",
";",
"return",
"stringSpan",
";",
"}"
] |
Change part of the color of CharSequence.
@param content content text.
@param start start index.
@param end end index.
@param color color.
@return {@code SpannableString}.
|
[
"Change",
"part",
"of",
"the",
"color",
"of",
"CharSequence",
"."
] |
train
|
https://github.com/yanzhenjie/Album/blob/b17506440d32909d42aba41f6a388041a25c8363/album/src/main/java/com/yanzhenjie/album/util/AlbumUtils.java#L351-L356
|
phax/ph-commons
|
ph-xml/src/main/java/com/helger/xml/serialize/write/XMLEmitter.java
|
XMLEmitter.onText
|
public void onText (@Nonnull final char [] aText, @Nonnegative final int nOfs, @Nonnegative final int nLen) {
"""
XML text node.
@param aText
The contained text array
@param nOfs
Offset into the array where to start
@param nLen
Number of chars to use, starting from the provided offset.
"""
onText (aText, nOfs, nLen, true);
}
|
java
|
public void onText (@Nonnull final char [] aText, @Nonnegative final int nOfs, @Nonnegative final int nLen)
{
onText (aText, nOfs, nLen, true);
}
|
[
"public",
"void",
"onText",
"(",
"@",
"Nonnull",
"final",
"char",
"[",
"]",
"aText",
",",
"@",
"Nonnegative",
"final",
"int",
"nOfs",
",",
"@",
"Nonnegative",
"final",
"int",
"nLen",
")",
"{",
"onText",
"(",
"aText",
",",
"nOfs",
",",
"nLen",
",",
"true",
")",
";",
"}"
] |
XML text node.
@param aText
The contained text array
@param nOfs
Offset into the array where to start
@param nLen
Number of chars to use, starting from the provided offset.
|
[
"XML",
"text",
"node",
"."
] |
train
|
https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-xml/src/main/java/com/helger/xml/serialize/write/XMLEmitter.java#L463-L466
|
deeplearning4j/deeplearning4j
|
datavec/datavec-spark/src/main/java/org/datavec/spark/storage/SparkStorageUtils.java
|
SparkStorageUtils.saveSequenceFile
|
public static void saveSequenceFile(String path, JavaRDD<List<Writable>> rdd) {
"""
Save a {@code JavaRDD<List<Writable>>} to a Hadoop {@link org.apache.hadoop.io.SequenceFile}. Each record is given
a unique (but noncontiguous) {@link LongWritable} key, and values are stored as {@link RecordWritable} instances.
<p>
Use {@link #restoreSequenceFile(String, JavaSparkContext)} to restore values saved with this method.
@param path Path to save the sequence file
@param rdd RDD to save
@see #saveSequenceFileSequences(String, JavaRDD)
@see #saveMapFile(String, JavaRDD)
"""
saveSequenceFile(path, rdd, null);
}
|
java
|
public static void saveSequenceFile(String path, JavaRDD<List<Writable>> rdd) {
saveSequenceFile(path, rdd, null);
}
|
[
"public",
"static",
"void",
"saveSequenceFile",
"(",
"String",
"path",
",",
"JavaRDD",
"<",
"List",
"<",
"Writable",
">",
">",
"rdd",
")",
"{",
"saveSequenceFile",
"(",
"path",
",",
"rdd",
",",
"null",
")",
";",
"}"
] |
Save a {@code JavaRDD<List<Writable>>} to a Hadoop {@link org.apache.hadoop.io.SequenceFile}. Each record is given
a unique (but noncontiguous) {@link LongWritable} key, and values are stored as {@link RecordWritable} instances.
<p>
Use {@link #restoreSequenceFile(String, JavaSparkContext)} to restore values saved with this method.
@param path Path to save the sequence file
@param rdd RDD to save
@see #saveSequenceFileSequences(String, JavaRDD)
@see #saveMapFile(String, JavaRDD)
|
[
"Save",
"a",
"{",
"@code",
"JavaRDD<List<Writable",
">>",
"}",
"to",
"a",
"Hadoop",
"{",
"@link",
"org",
".",
"apache",
".",
"hadoop",
".",
"io",
".",
"SequenceFile",
"}",
".",
"Each",
"record",
"is",
"given",
"a",
"unique",
"(",
"but",
"noncontiguous",
")",
"{",
"@link",
"LongWritable",
"}",
"key",
"and",
"values",
"are",
"stored",
"as",
"{",
"@link",
"RecordWritable",
"}",
"instances",
".",
"<p",
">",
"Use",
"{",
"@link",
"#restoreSequenceFile",
"(",
"String",
"JavaSparkContext",
")",
"}",
"to",
"restore",
"values",
"saved",
"with",
"this",
"method",
"."
] |
train
|
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/datavec/datavec-spark/src/main/java/org/datavec/spark/storage/SparkStorageUtils.java#L75-L77
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/processor/impl/DestinationManager.java
|
DestinationManager.createForeignDestination
|
private DestinationHandler createForeignDestination(DestinationForeignDefinition dfd, String busName) throws SIResourceException, SINotPossibleInCurrentConfigurationException {
"""
Create a foreign destination when passed an appropriate
and a valid targetDestinationHandler.
<p>
Assumes that the destination to create does not already exist.
@param destinationDefinition
@param destinationLocalizingMEs
@param busName
@return
"""
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(tc, "createForeignDestination", new Object[] { dfd, busName });
ForeignDestinationHandler fdh = null;
//The lock on the destinationManager is taken to stop 2 threads creating the same
//destination and also to synchronize dynamic deletes with the
//creation of aliases. This stops an alias destination being created that targets a
//destination in the process of being deleted.
synchronized (this)
{
// Create a new DestinationHandler, which is created locked
fdh = new ForeignDestinationHandler(dfd, messageProcessor, this, findBus(dfd.getBus()), busName);
DestinationIndex.Type type = new DestinationIndex.Type();
type.foreignDestination = Boolean.TRUE;
type.alias = Boolean.FALSE;
type.local = Boolean.FALSE;
type.remote = Boolean.FALSE;
type.queue = new Boolean(!fdh.isPubSub());
type.state = State.ACTIVE;
destinationIndex.put(fdh, type);
fdh.registerControlAdapters();
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "createForeignDestination", fdh);
return fdh;
}
|
java
|
private DestinationHandler createForeignDestination(DestinationForeignDefinition dfd, String busName) throws SIResourceException, SINotPossibleInCurrentConfigurationException
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(tc, "createForeignDestination", new Object[] { dfd, busName });
ForeignDestinationHandler fdh = null;
//The lock on the destinationManager is taken to stop 2 threads creating the same
//destination and also to synchronize dynamic deletes with the
//creation of aliases. This stops an alias destination being created that targets a
//destination in the process of being deleted.
synchronized (this)
{
// Create a new DestinationHandler, which is created locked
fdh = new ForeignDestinationHandler(dfd, messageProcessor, this, findBus(dfd.getBus()), busName);
DestinationIndex.Type type = new DestinationIndex.Type();
type.foreignDestination = Boolean.TRUE;
type.alias = Boolean.FALSE;
type.local = Boolean.FALSE;
type.remote = Boolean.FALSE;
type.queue = new Boolean(!fdh.isPubSub());
type.state = State.ACTIVE;
destinationIndex.put(fdh, type);
fdh.registerControlAdapters();
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "createForeignDestination", fdh);
return fdh;
}
|
[
"private",
"DestinationHandler",
"createForeignDestination",
"(",
"DestinationForeignDefinition",
"dfd",
",",
"String",
"busName",
")",
"throws",
"SIResourceException",
",",
"SINotPossibleInCurrentConfigurationException",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"tc",
",",
"\"createForeignDestination\"",
",",
"new",
"Object",
"[",
"]",
"{",
"dfd",
",",
"busName",
"}",
")",
";",
"ForeignDestinationHandler",
"fdh",
"=",
"null",
";",
"//The lock on the destinationManager is taken to stop 2 threads creating the same",
"//destination and also to synchronize dynamic deletes with the",
"//creation of aliases. This stops an alias destination being created that targets a",
"//destination in the process of being deleted.",
"synchronized",
"(",
"this",
")",
"{",
"// Create a new DestinationHandler, which is created locked",
"fdh",
"=",
"new",
"ForeignDestinationHandler",
"(",
"dfd",
",",
"messageProcessor",
",",
"this",
",",
"findBus",
"(",
"dfd",
".",
"getBus",
"(",
")",
")",
",",
"busName",
")",
";",
"DestinationIndex",
".",
"Type",
"type",
"=",
"new",
"DestinationIndex",
".",
"Type",
"(",
")",
";",
"type",
".",
"foreignDestination",
"=",
"Boolean",
".",
"TRUE",
";",
"type",
".",
"alias",
"=",
"Boolean",
".",
"FALSE",
";",
"type",
".",
"local",
"=",
"Boolean",
".",
"FALSE",
";",
"type",
".",
"remote",
"=",
"Boolean",
".",
"FALSE",
";",
"type",
".",
"queue",
"=",
"new",
"Boolean",
"(",
"!",
"fdh",
".",
"isPubSub",
"(",
")",
")",
";",
"type",
".",
"state",
"=",
"State",
".",
"ACTIVE",
";",
"destinationIndex",
".",
"put",
"(",
"fdh",
",",
"type",
")",
";",
"fdh",
".",
"registerControlAdapters",
"(",
")",
";",
"}",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"tc",
",",
"\"createForeignDestination\"",
",",
"fdh",
")",
";",
"return",
"fdh",
";",
"}"
] |
Create a foreign destination when passed an appropriate
and a valid targetDestinationHandler.
<p>
Assumes that the destination to create does not already exist.
@param destinationDefinition
@param destinationLocalizingMEs
@param busName
@return
|
[
"Create",
"a",
"foreign",
"destination",
"when",
"passed",
"an",
"appropriate",
"and",
"a",
"valid",
"targetDestinationHandler",
".",
"<p",
">",
"Assumes",
"that",
"the",
"destination",
"to",
"create",
"does",
"not",
"already",
"exist",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/processor/impl/DestinationManager.java#L6247-L6279
|
Deep-Symmetry/beat-link
|
src/main/java/org/deepsymmetry/beatlink/Util.java
|
Util.sameNetwork
|
public static boolean sameNetwork(int prefixLength, InetAddress address1, InetAddress address2) {
"""
Checks whether two internet addresses are on the same subnet.
@param prefixLength the number of bits within an address that identify the network
@param address1 the first address to be compared
@param address2 the second address to be compared
@return true if both addresses share the same network bits
"""
if (logger.isDebugEnabled()) {
logger.debug("Comparing address " + address1.getHostAddress() + " with " + address2.getHostAddress() + ", prefixLength=" + prefixLength);
}
long prefixMask = 0xffffffffL & (-1 << (32 - prefixLength));
return (addressToLong(address1) & prefixMask) == (addressToLong(address2) & prefixMask);
}
|
java
|
public static boolean sameNetwork(int prefixLength, InetAddress address1, InetAddress address2) {
if (logger.isDebugEnabled()) {
logger.debug("Comparing address " + address1.getHostAddress() + " with " + address2.getHostAddress() + ", prefixLength=" + prefixLength);
}
long prefixMask = 0xffffffffL & (-1 << (32 - prefixLength));
return (addressToLong(address1) & prefixMask) == (addressToLong(address2) & prefixMask);
}
|
[
"public",
"static",
"boolean",
"sameNetwork",
"(",
"int",
"prefixLength",
",",
"InetAddress",
"address1",
",",
"InetAddress",
"address2",
")",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Comparing address \"",
"+",
"address1",
".",
"getHostAddress",
"(",
")",
"+",
"\" with \"",
"+",
"address2",
".",
"getHostAddress",
"(",
")",
"+",
"\", prefixLength=\"",
"+",
"prefixLength",
")",
";",
"}",
"long",
"prefixMask",
"=",
"0xffffffff",
"",
"L",
"&",
"(",
"-",
"1",
"<<",
"(",
"32",
"-",
"prefixLength",
")",
")",
";",
"return",
"(",
"addressToLong",
"(",
"address1",
")",
"&",
"prefixMask",
")",
"==",
"(",
"addressToLong",
"(",
"address2",
")",
"&",
"prefixMask",
")",
";",
"}"
] |
Checks whether two internet addresses are on the same subnet.
@param prefixLength the number of bits within an address that identify the network
@param address1 the first address to be compared
@param address2 the second address to be compared
@return true if both addresses share the same network bits
|
[
"Checks",
"whether",
"two",
"internet",
"addresses",
"are",
"on",
"the",
"same",
"subnet",
"."
] |
train
|
https://github.com/Deep-Symmetry/beat-link/blob/f958a2a70e8a87a31a75326d7b4db77c2f0b4212/src/main/java/org/deepsymmetry/beatlink/Util.java#L309-L315
|
infinispan/infinispan
|
server/hotrod/src/main/java/org/infinispan/server/hotrod/tx/table/PerCacheTxTable.java
|
PerCacheTxTable.createLocalTx
|
public void createLocalTx(Xid xid, EmbeddedTransaction tx) {
"""
Adds the {@link EmbeddedTransaction} in the local transaction table.
"""
localTxTable.put(xid, tx);
if (trace) {
log.tracef("[%s] New tx=%s", xid, tx);
}
}
|
java
|
public void createLocalTx(Xid xid, EmbeddedTransaction tx) {
localTxTable.put(xid, tx);
if (trace) {
log.tracef("[%s] New tx=%s", xid, tx);
}
}
|
[
"public",
"void",
"createLocalTx",
"(",
"Xid",
"xid",
",",
"EmbeddedTransaction",
"tx",
")",
"{",
"localTxTable",
".",
"put",
"(",
"xid",
",",
"tx",
")",
";",
"if",
"(",
"trace",
")",
"{",
"log",
".",
"tracef",
"(",
"\"[%s] New tx=%s\"",
",",
"xid",
",",
"tx",
")",
";",
"}",
"}"
] |
Adds the {@link EmbeddedTransaction} in the local transaction table.
|
[
"Adds",
"the",
"{"
] |
train
|
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/server/hotrod/src/main/java/org/infinispan/server/hotrod/tx/table/PerCacheTxTable.java#L60-L65
|
apereo/cas
|
core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/scripting/ScriptingUtils.java
|
ScriptingUtils.executeGroovyScript
|
public static <T> T executeGroovyScript(final Resource groovyScript,
final String methodName,
final Class<T> clazz,
final Object... args) {
"""
Execute groovy script t.
@param <T> the type parameter
@param groovyScript the groovy script
@param methodName the method name
@param clazz the clazz
@param args the args
@return the type to return
"""
return executeGroovyScript(groovyScript, methodName, args, clazz, false);
}
|
java
|
public static <T> T executeGroovyScript(final Resource groovyScript,
final String methodName,
final Class<T> clazz,
final Object... args) {
return executeGroovyScript(groovyScript, methodName, args, clazz, false);
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"executeGroovyScript",
"(",
"final",
"Resource",
"groovyScript",
",",
"final",
"String",
"methodName",
",",
"final",
"Class",
"<",
"T",
">",
"clazz",
",",
"final",
"Object",
"...",
"args",
")",
"{",
"return",
"executeGroovyScript",
"(",
"groovyScript",
",",
"methodName",
",",
"args",
",",
"clazz",
",",
"false",
")",
";",
"}"
] |
Execute groovy script t.
@param <T> the type parameter
@param groovyScript the groovy script
@param methodName the method name
@param clazz the clazz
@param args the args
@return the type to return
|
[
"Execute",
"groovy",
"script",
"t",
"."
] |
train
|
https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/scripting/ScriptingUtils.java#L167-L172
|
alkacon/opencms-core
|
src/org/opencms/ade/contenteditor/shared/CmsContentDefinition.java
|
CmsContentDefinition.createDefaultValueEntity
|
protected static CmsEntity createDefaultValueEntity(
CmsType entityType,
Map<String, CmsType> entityTypes,
Map<String, CmsAttributeConfiguration> attributeConfigurations) {
"""
Creates an entity object containing the default values configured for it's type.<p>
@param entityType the entity type
@param entityTypes the entity types
@param attributeConfigurations the attribute configurations
@return the created entity
"""
CmsEntity result = new CmsEntity(null, entityType.getId());
for (String attributeName : entityType.getAttributeNames()) {
CmsType attributeType = entityTypes.get(entityType.getAttributeTypeName(attributeName));
for (int i = 0; i < entityType.getAttributeMinOccurrence(attributeName); i++) {
if (attributeType.isSimpleType()) {
result.addAttributeValue(
attributeName,
attributeConfigurations.get(attributeName).getDefaultValue());
} else {
result.addAttributeValue(
attributeName,
createDefaultValueEntity(attributeType, entityTypes, attributeConfigurations));
}
}
}
return result;
}
|
java
|
protected static CmsEntity createDefaultValueEntity(
CmsType entityType,
Map<String, CmsType> entityTypes,
Map<String, CmsAttributeConfiguration> attributeConfigurations) {
CmsEntity result = new CmsEntity(null, entityType.getId());
for (String attributeName : entityType.getAttributeNames()) {
CmsType attributeType = entityTypes.get(entityType.getAttributeTypeName(attributeName));
for (int i = 0; i < entityType.getAttributeMinOccurrence(attributeName); i++) {
if (attributeType.isSimpleType()) {
result.addAttributeValue(
attributeName,
attributeConfigurations.get(attributeName).getDefaultValue());
} else {
result.addAttributeValue(
attributeName,
createDefaultValueEntity(attributeType, entityTypes, attributeConfigurations));
}
}
}
return result;
}
|
[
"protected",
"static",
"CmsEntity",
"createDefaultValueEntity",
"(",
"CmsType",
"entityType",
",",
"Map",
"<",
"String",
",",
"CmsType",
">",
"entityTypes",
",",
"Map",
"<",
"String",
",",
"CmsAttributeConfiguration",
">",
"attributeConfigurations",
")",
"{",
"CmsEntity",
"result",
"=",
"new",
"CmsEntity",
"(",
"null",
",",
"entityType",
".",
"getId",
"(",
")",
")",
";",
"for",
"(",
"String",
"attributeName",
":",
"entityType",
".",
"getAttributeNames",
"(",
")",
")",
"{",
"CmsType",
"attributeType",
"=",
"entityTypes",
".",
"get",
"(",
"entityType",
".",
"getAttributeTypeName",
"(",
"attributeName",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"entityType",
".",
"getAttributeMinOccurrence",
"(",
"attributeName",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"attributeType",
".",
"isSimpleType",
"(",
")",
")",
"{",
"result",
".",
"addAttributeValue",
"(",
"attributeName",
",",
"attributeConfigurations",
".",
"get",
"(",
"attributeName",
")",
".",
"getDefaultValue",
"(",
")",
")",
";",
"}",
"else",
"{",
"result",
".",
"addAttributeValue",
"(",
"attributeName",
",",
"createDefaultValueEntity",
"(",
"attributeType",
",",
"entityTypes",
",",
"attributeConfigurations",
")",
")",
";",
"}",
"}",
"}",
"return",
"result",
";",
"}"
] |
Creates an entity object containing the default values configured for it's type.<p>
@param entityType the entity type
@param entityTypes the entity types
@param attributeConfigurations the attribute configurations
@return the created entity
|
[
"Creates",
"an",
"entity",
"object",
"containing",
"the",
"default",
"values",
"configured",
"for",
"it",
"s",
"type",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ade/contenteditor/shared/CmsContentDefinition.java#L390-L411
|
apache/incubator-gobblin
|
gobblin-modules/gobblin-azkaban/src/main/java/org/apache/gobblin/service/modules/orchestration/SessionHelper.java
|
SessionHelper.getSessionId
|
public static String getSessionId(CloseableHttpClient httpClient, String url, String username, String password)
throws AzkabanClientException {
"""
<p>Use Azkaban ajax api to fetch the session id. Required http request parameters are:
<br>action=login The fixed parameter indicating the login action.
<br>username The Azkaban username.
<br>password The corresponding password.
</pr>
@param httpClient An apache http client
@param url Azkaban ajax endpoint
@param username username for Azkaban login
@param password password for Azkaban login
@return session id
"""
try {
HttpPost httpPost = new HttpPost(url);
List<NameValuePair> nvps = new ArrayList<>();
nvps.add(new BasicNameValuePair(AzkabanClientParams.ACTION, "login"));
nvps.add(new BasicNameValuePair(AzkabanClientParams.USERNAME, username));
nvps.add(new BasicNameValuePair(AzkabanClientParams.PASSWORD, password));
httpPost.setEntity(new UrlEncodedFormEntity(nvps));
CloseableHttpResponse response = httpClient.execute(httpPost);
try {
HttpEntity entity = response.getEntity();
// retrieve session id from entity
String jsonResponseString = IOUtils.toString(entity.getContent(), "UTF-8");
String sessionId = AzkabanClient.parseResponse(jsonResponseString).get(AzkabanClientParams.SESSION_ID);
EntityUtils.consume(entity);
return sessionId;
} catch (Exception e) {
throw new AzkabanClientException("Azkaban client cannot consume session response.", e);
} finally {
response.close();
}
} catch (Exception e) {
throw new AzkabanClientException("Azkaban client cannot fetch session.", e);
}
}
|
java
|
public static String getSessionId(CloseableHttpClient httpClient, String url, String username, String password)
throws AzkabanClientException {
try {
HttpPost httpPost = new HttpPost(url);
List<NameValuePair> nvps = new ArrayList<>();
nvps.add(new BasicNameValuePair(AzkabanClientParams.ACTION, "login"));
nvps.add(new BasicNameValuePair(AzkabanClientParams.USERNAME, username));
nvps.add(new BasicNameValuePair(AzkabanClientParams.PASSWORD, password));
httpPost.setEntity(new UrlEncodedFormEntity(nvps));
CloseableHttpResponse response = httpClient.execute(httpPost);
try {
HttpEntity entity = response.getEntity();
// retrieve session id from entity
String jsonResponseString = IOUtils.toString(entity.getContent(), "UTF-8");
String sessionId = AzkabanClient.parseResponse(jsonResponseString).get(AzkabanClientParams.SESSION_ID);
EntityUtils.consume(entity);
return sessionId;
} catch (Exception e) {
throw new AzkabanClientException("Azkaban client cannot consume session response.", e);
} finally {
response.close();
}
} catch (Exception e) {
throw new AzkabanClientException("Azkaban client cannot fetch session.", e);
}
}
|
[
"public",
"static",
"String",
"getSessionId",
"(",
"CloseableHttpClient",
"httpClient",
",",
"String",
"url",
",",
"String",
"username",
",",
"String",
"password",
")",
"throws",
"AzkabanClientException",
"{",
"try",
"{",
"HttpPost",
"httpPost",
"=",
"new",
"HttpPost",
"(",
"url",
")",
";",
"List",
"<",
"NameValuePair",
">",
"nvps",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"nvps",
".",
"add",
"(",
"new",
"BasicNameValuePair",
"(",
"AzkabanClientParams",
".",
"ACTION",
",",
"\"login\"",
")",
")",
";",
"nvps",
".",
"add",
"(",
"new",
"BasicNameValuePair",
"(",
"AzkabanClientParams",
".",
"USERNAME",
",",
"username",
")",
")",
";",
"nvps",
".",
"add",
"(",
"new",
"BasicNameValuePair",
"(",
"AzkabanClientParams",
".",
"PASSWORD",
",",
"password",
")",
")",
";",
"httpPost",
".",
"setEntity",
"(",
"new",
"UrlEncodedFormEntity",
"(",
"nvps",
")",
")",
";",
"CloseableHttpResponse",
"response",
"=",
"httpClient",
".",
"execute",
"(",
"httpPost",
")",
";",
"try",
"{",
"HttpEntity",
"entity",
"=",
"response",
".",
"getEntity",
"(",
")",
";",
"// retrieve session id from entity",
"String",
"jsonResponseString",
"=",
"IOUtils",
".",
"toString",
"(",
"entity",
".",
"getContent",
"(",
")",
",",
"\"UTF-8\"",
")",
";",
"String",
"sessionId",
"=",
"AzkabanClient",
".",
"parseResponse",
"(",
"jsonResponseString",
")",
".",
"get",
"(",
"AzkabanClientParams",
".",
"SESSION_ID",
")",
";",
"EntityUtils",
".",
"consume",
"(",
"entity",
")",
";",
"return",
"sessionId",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"AzkabanClientException",
"(",
"\"Azkaban client cannot consume session response.\"",
",",
"e",
")",
";",
"}",
"finally",
"{",
"response",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"AzkabanClientException",
"(",
"\"Azkaban client cannot fetch session.\"",
",",
"e",
")",
";",
"}",
"}"
] |
<p>Use Azkaban ajax api to fetch the session id. Required http request parameters are:
<br>action=login The fixed parameter indicating the login action.
<br>username The Azkaban username.
<br>password The corresponding password.
</pr>
@param httpClient An apache http client
@param url Azkaban ajax endpoint
@param username username for Azkaban login
@param password password for Azkaban login
@return session id
|
[
"<p",
">",
"Use",
"Azkaban",
"ajax",
"api",
"to",
"fetch",
"the",
"session",
"id",
".",
"Required",
"http",
"request",
"parameters",
"are",
":",
"<br",
">",
"action",
"=",
"login",
"The",
"fixed",
"parameter",
"indicating",
"the",
"login",
"action",
".",
"<br",
">",
"username",
"The",
"Azkaban",
"username",
".",
"<br",
">",
"password",
"The",
"corresponding",
"password",
".",
"<",
"/",
"pr",
">"
] |
train
|
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-azkaban/src/main/java/org/apache/gobblin/service/modules/orchestration/SessionHelper.java#L56-L83
|
apiman/apiman
|
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java
|
AuditUtils.clientCreated
|
public static AuditEntryBean clientCreated(ClientBean bean, ISecurityContext securityContext) {
"""
Creates an audit entry for the 'client created' event.
@param bean the bean
@param securityContext the security context
@return the audit entry
"""
AuditEntryBean entry = newEntry(bean.getOrganization().getId(), AuditEntityType.Client, securityContext);
entry.setEntityId(bean.getId());
entry.setEntityVersion(null);
entry.setData(null);
entry.setWhat(AuditEntryType.Create);
return entry;
}
|
java
|
public static AuditEntryBean clientCreated(ClientBean bean, ISecurityContext securityContext) {
AuditEntryBean entry = newEntry(bean.getOrganization().getId(), AuditEntityType.Client, securityContext);
entry.setEntityId(bean.getId());
entry.setEntityVersion(null);
entry.setData(null);
entry.setWhat(AuditEntryType.Create);
return entry;
}
|
[
"public",
"static",
"AuditEntryBean",
"clientCreated",
"(",
"ClientBean",
"bean",
",",
"ISecurityContext",
"securityContext",
")",
"{",
"AuditEntryBean",
"entry",
"=",
"newEntry",
"(",
"bean",
".",
"getOrganization",
"(",
")",
".",
"getId",
"(",
")",
",",
"AuditEntityType",
".",
"Client",
",",
"securityContext",
")",
";",
"entry",
".",
"setEntityId",
"(",
"bean",
".",
"getId",
"(",
")",
")",
";",
"entry",
".",
"setEntityVersion",
"(",
"null",
")",
";",
"entry",
".",
"setData",
"(",
"null",
")",
";",
"entry",
".",
"setWhat",
"(",
"AuditEntryType",
".",
"Create",
")",
";",
"return",
"entry",
";",
"}"
] |
Creates an audit entry for the 'client created' event.
@param bean the bean
@param securityContext the security context
@return the audit entry
|
[
"Creates",
"an",
"audit",
"entry",
"for",
"the",
"client",
"created",
"event",
"."
] |
train
|
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java#L354-L361
|
deeplearning4j/deeplearning4j
|
nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/flow/FlowPath.java
|
FlowPath.markExecuted
|
public void markExecuted(@NonNull String nodeName, boolean executed) {
"""
This method allows to toggle wasExecuted() state for specified node
@param nodeName
@param executed
"""
states.get(nodeName).setExecuted(executed);
}
|
java
|
public void markExecuted(@NonNull String nodeName, boolean executed) {
states.get(nodeName).setExecuted(executed);
}
|
[
"public",
"void",
"markExecuted",
"(",
"@",
"NonNull",
"String",
"nodeName",
",",
"boolean",
"executed",
")",
"{",
"states",
".",
"get",
"(",
"nodeName",
")",
".",
"setExecuted",
"(",
"executed",
")",
";",
"}"
] |
This method allows to toggle wasExecuted() state for specified node
@param nodeName
@param executed
|
[
"This",
"method",
"allows",
"to",
"toggle",
"wasExecuted",
"()",
"state",
"for",
"specified",
"node"
] |
train
|
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/flow/FlowPath.java#L104-L107
|
sebastiangraf/treetank
|
interfacemodules/jax-rx/src/main/java/org/jaxrx/resource/XMLResource.java
|
XMLResource.deleteResource
|
@DELETE
public Response deleteResource(@PathParam(JaxRxConstants.SYSTEM) final String system,
@PathParam(JaxRxConstants.RESOURCE) final String resource, @Context final HttpHeaders headers) {
"""
This method will be called when an HTTP client sends a DELETE request to
delete an existing resource.
@param system
The associated system with this request.
@param resource
The name of the existing resource that has to be deleted.
@param headers
HTTP header attributes.
@return The HTTP response code for this call.
"""
final JaxRx impl = Systems.getInstance(system);
final String info = impl.delete(new ResourcePath(resource, headers));
return Response.ok().entity(info).build();
}
|
java
|
@DELETE
public Response deleteResource(@PathParam(JaxRxConstants.SYSTEM) final String system,
@PathParam(JaxRxConstants.RESOURCE) final String resource, @Context final HttpHeaders headers) {
final JaxRx impl = Systems.getInstance(system);
final String info = impl.delete(new ResourcePath(resource, headers));
return Response.ok().entity(info).build();
}
|
[
"@",
"DELETE",
"public",
"Response",
"deleteResource",
"(",
"@",
"PathParam",
"(",
"JaxRxConstants",
".",
"SYSTEM",
")",
"final",
"String",
"system",
",",
"@",
"PathParam",
"(",
"JaxRxConstants",
".",
"RESOURCE",
")",
"final",
"String",
"resource",
",",
"@",
"Context",
"final",
"HttpHeaders",
"headers",
")",
"{",
"final",
"JaxRx",
"impl",
"=",
"Systems",
".",
"getInstance",
"(",
"system",
")",
";",
"final",
"String",
"info",
"=",
"impl",
".",
"delete",
"(",
"new",
"ResourcePath",
"(",
"resource",
",",
"headers",
")",
")",
";",
"return",
"Response",
".",
"ok",
"(",
")",
".",
"entity",
"(",
"info",
")",
".",
"build",
"(",
")",
";",
"}"
] |
This method will be called when an HTTP client sends a DELETE request to
delete an existing resource.
@param system
The associated system with this request.
@param resource
The name of the existing resource that has to be deleted.
@param headers
HTTP header attributes.
@return The HTTP response code for this call.
|
[
"This",
"method",
"will",
"be",
"called",
"when",
"an",
"HTTP",
"client",
"sends",
"a",
"DELETE",
"request",
"to",
"delete",
"an",
"existing",
"resource",
"."
] |
train
|
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/jax-rx/src/main/java/org/jaxrx/resource/XMLResource.java#L177-L184
|
lievendoclo/Valkyrie-RCP
|
valkyrie-rcp-core/src/main/java/org/valkyriercp/util/WindowUtils.java
|
WindowUtils.getDimensionFromPercent
|
public static final Dimension getDimensionFromPercent(int percentWidth, int percentHeight) {
"""
Return a <code>Dimension</code> whose size is defined not in terms of
pixels, but in terms of a given percent of the screen's width and height.
<P>
Use to set the preferred size of a component to a certain percentage of
the screen.
@param percentWidth percentage width of the screen, in range
<code>1..100</code>.
@param percentHeight percentage height of the screen, in range
<code>1..100</code>.
"""
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
return calcDimensionFromPercent(screenSize, percentWidth, percentHeight);
}
|
java
|
public static final Dimension getDimensionFromPercent(int percentWidth, int percentHeight) {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
return calcDimensionFromPercent(screenSize, percentWidth, percentHeight);
}
|
[
"public",
"static",
"final",
"Dimension",
"getDimensionFromPercent",
"(",
"int",
"percentWidth",
",",
"int",
"percentHeight",
")",
"{",
"Dimension",
"screenSize",
"=",
"Toolkit",
".",
"getDefaultToolkit",
"(",
")",
".",
"getScreenSize",
"(",
")",
";",
"return",
"calcDimensionFromPercent",
"(",
"screenSize",
",",
"percentWidth",
",",
"percentHeight",
")",
";",
"}"
] |
Return a <code>Dimension</code> whose size is defined not in terms of
pixels, but in terms of a given percent of the screen's width and height.
<P>
Use to set the preferred size of a component to a certain percentage of
the screen.
@param percentWidth percentage width of the screen, in range
<code>1..100</code>.
@param percentHeight percentage height of the screen, in range
<code>1..100</code>.
|
[
"Return",
"a",
"<code",
">",
"Dimension<",
"/",
"code",
">",
"whose",
"size",
"is",
"defined",
"not",
"in",
"terms",
"of",
"pixels",
"but",
"in",
"terms",
"of",
"a",
"given",
"percent",
"of",
"the",
"screen",
"s",
"width",
"and",
"height",
"."
] |
train
|
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/util/WindowUtils.java#L138-L141
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.