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
|
---|---|---|---|---|---|---|---|---|---|---|
linkedin/PalDB
|
paldb/src/main/java/com/linkedin/paldb/api/Configuration.java
|
Configuration.getDouble
|
public double getDouble(String key, double defaultValue) {
"""
Gets the double value for <code>key</code> or <code>defaultValue</code> if not found.
@param key key to get value for
@param defaultValue default value if key not found
@return value or <code>defaultValue</code> if not found
"""
if (containsKey(key)) {
return Double.parseDouble(get(key));
} else {
return defaultValue;
}
}
|
java
|
public double getDouble(String key, double defaultValue) {
if (containsKey(key)) {
return Double.parseDouble(get(key));
} else {
return defaultValue;
}
}
|
[
"public",
"double",
"getDouble",
"(",
"String",
"key",
",",
"double",
"defaultValue",
")",
"{",
"if",
"(",
"containsKey",
"(",
"key",
")",
")",
"{",
"return",
"Double",
".",
"parseDouble",
"(",
"get",
"(",
"key",
")",
")",
";",
"}",
"else",
"{",
"return",
"defaultValue",
";",
"}",
"}"
] |
Gets the double value for <code>key</code> or <code>defaultValue</code> if not found.
@param key key to get value for
@param defaultValue default value if key not found
@return value or <code>defaultValue</code> if not found
|
[
"Gets",
"the",
"double",
"value",
"for",
"<code",
">",
"key<",
"/",
"code",
">",
"or",
"<code",
">",
"defaultValue<",
"/",
"code",
">",
"if",
"not",
"found",
"."
] |
train
|
https://github.com/linkedin/PalDB/blob/d05ccdd3f67855eb2675dbd82599f19aa7a9f650/paldb/src/main/java/com/linkedin/paldb/api/Configuration.java#L288-L294
|
datasift/datasift-java
|
src/main/java/com/datasift/client/managedsource/sources/Instagram.java
|
Instagram.byTag
|
public Instagram byTag(String tag, boolean exactMatch) {
"""
/*
Adds a resource by tag
@param tag the tag, e.g cat
@param exactMatch true when a tag must be an exact match or false when the tag should match the instragram tag
search behaviour
@return this
"""
addResource(Type.TAG, tag, -1, -1, -1, exactMatch, null);
return this;
}
|
java
|
public Instagram byTag(String tag, boolean exactMatch) {
addResource(Type.TAG, tag, -1, -1, -1, exactMatch, null);
return this;
}
|
[
"public",
"Instagram",
"byTag",
"(",
"String",
"tag",
",",
"boolean",
"exactMatch",
")",
"{",
"addResource",
"(",
"Type",
".",
"TAG",
",",
"tag",
",",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
",",
"exactMatch",
",",
"null",
")",
";",
"return",
"this",
";",
"}"
] |
/*
Adds a resource by tag
@param tag the tag, e.g cat
@param exactMatch true when a tag must be an exact match or false when the tag should match the instragram tag
search behaviour
@return this
|
[
"/",
"*",
"Adds",
"a",
"resource",
"by",
"tag"
] |
train
|
https://github.com/datasift/datasift-java/blob/09de124f2a1a507ff6181e59875c6f325290850e/src/main/java/com/datasift/client/managedsource/sources/Instagram.java#L58-L61
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-dbaaslogs/src/main/java/net/minidev/ovh/api/ApiOvhDbaaslogs.java
|
ApiOvhDbaaslogs.serviceName_cluster_clusterId_allowedNetwork_POST
|
public OvhOperation serviceName_cluster_clusterId_allowedNetwork_POST(String serviceName, String clusterId, OvhClusterAllowedNetworkFlowTypeEnum flowType, String network) throws IOException {
"""
Allow an IP to contact cluster
REST: POST /dbaas/logs/{serviceName}/cluster/{clusterId}/allowedNetwork
@param serviceName [required] Service name
@param clusterId [required] Cluster ID
@param network [required] IP block
@param flowType [required] Flow type
"""
String qPath = "/dbaas/logs/{serviceName}/cluster/{clusterId}/allowedNetwork";
StringBuilder sb = path(qPath, serviceName, clusterId);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "flowType", flowType);
addBody(o, "network", network);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhOperation.class);
}
|
java
|
public OvhOperation serviceName_cluster_clusterId_allowedNetwork_POST(String serviceName, String clusterId, OvhClusterAllowedNetworkFlowTypeEnum flowType, String network) throws IOException {
String qPath = "/dbaas/logs/{serviceName}/cluster/{clusterId}/allowedNetwork";
StringBuilder sb = path(qPath, serviceName, clusterId);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "flowType", flowType);
addBody(o, "network", network);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhOperation.class);
}
|
[
"public",
"OvhOperation",
"serviceName_cluster_clusterId_allowedNetwork_POST",
"(",
"String",
"serviceName",
",",
"String",
"clusterId",
",",
"OvhClusterAllowedNetworkFlowTypeEnum",
"flowType",
",",
"String",
"network",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/dbaas/logs/{serviceName}/cluster/{clusterId}/allowedNetwork\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"clusterId",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"flowType\"",
",",
"flowType",
")",
";",
"addBody",
"(",
"o",
",",
"\"network\"",
",",
"network",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhOperation",
".",
"class",
")",
";",
"}"
] |
Allow an IP to contact cluster
REST: POST /dbaas/logs/{serviceName}/cluster/{clusterId}/allowedNetwork
@param serviceName [required] Service name
@param clusterId [required] Cluster ID
@param network [required] IP block
@param flowType [required] Flow type
|
[
"Allow",
"an",
"IP",
"to",
"contact",
"cluster"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-dbaaslogs/src/main/java/net/minidev/ovh/api/ApiOvhDbaaslogs.java#L158-L166
|
artikcloud/artikcloud-java
|
src/main/java/cloud/artik/api/MessagesApi.java
|
MessagesApi.getNormalizedActions
|
public NormalizedActionsEnvelope getNormalizedActions(String uid, String ddid, String mid, String offset, Integer count, Long startDate, Long endDate, String order) throws ApiException {
"""
Get Normalized Actions
Get the actions normalized
@param uid User ID. If not specified, assume that of the current authenticated user. If specified, it must be that of a user for which the current authenticated user has read access to. (optional)
@param ddid Destination device ID of the actions being searched. (optional)
@param mid The message ID being searched. (optional)
@param offset A string that represents the starting item, should be the value of 'next' field received in the last response. (required for pagination) (optional)
@param count count (optional)
@param startDate startDate (optional)
@param endDate endDate (optional)
@param order Desired sort order: 'asc' or 'desc' (optional)
@return NormalizedActionsEnvelope
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
"""
ApiResponse<NormalizedActionsEnvelope> resp = getNormalizedActionsWithHttpInfo(uid, ddid, mid, offset, count, startDate, endDate, order);
return resp.getData();
}
|
java
|
public NormalizedActionsEnvelope getNormalizedActions(String uid, String ddid, String mid, String offset, Integer count, Long startDate, Long endDate, String order) throws ApiException {
ApiResponse<NormalizedActionsEnvelope> resp = getNormalizedActionsWithHttpInfo(uid, ddid, mid, offset, count, startDate, endDate, order);
return resp.getData();
}
|
[
"public",
"NormalizedActionsEnvelope",
"getNormalizedActions",
"(",
"String",
"uid",
",",
"String",
"ddid",
",",
"String",
"mid",
",",
"String",
"offset",
",",
"Integer",
"count",
",",
"Long",
"startDate",
",",
"Long",
"endDate",
",",
"String",
"order",
")",
"throws",
"ApiException",
"{",
"ApiResponse",
"<",
"NormalizedActionsEnvelope",
">",
"resp",
"=",
"getNormalizedActionsWithHttpInfo",
"(",
"uid",
",",
"ddid",
",",
"mid",
",",
"offset",
",",
"count",
",",
"startDate",
",",
"endDate",
",",
"order",
")",
";",
"return",
"resp",
".",
"getData",
"(",
")",
";",
"}"
] |
Get Normalized Actions
Get the actions normalized
@param uid User ID. If not specified, assume that of the current authenticated user. If specified, it must be that of a user for which the current authenticated user has read access to. (optional)
@param ddid Destination device ID of the actions being searched. (optional)
@param mid The message ID being searched. (optional)
@param offset A string that represents the starting item, should be the value of 'next' field received in the last response. (required for pagination) (optional)
@param count count (optional)
@param startDate startDate (optional)
@param endDate endDate (optional)
@param order Desired sort order: 'asc' or 'desc' (optional)
@return NormalizedActionsEnvelope
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
|
[
"Get",
"Normalized",
"Actions",
"Get",
"the",
"actions",
"normalized"
] |
train
|
https://github.com/artikcloud/artikcloud-java/blob/412f447573e7796ab4f685c0bdd5eb76185a365c/src/main/java/cloud/artik/api/MessagesApi.java#L844-L847
|
looly/hutool
|
hutool-extra/src/main/java/cn/hutool/extra/qrcode/QrCodeUtil.java
|
QrCodeUtil.generate
|
public static void generate(String content, int width, int height, String imageType, OutputStream out) {
"""
生成二维码到输出流
@param content 文本内容
@param width 宽度
@param height 高度
@param imageType 图片类型(图片扩展名),见{@link ImgUtil}
@param out 目标流
"""
final BufferedImage image = generate(content, width, height);
ImgUtil.write(image, imageType, out);
}
|
java
|
public static void generate(String content, int width, int height, String imageType, OutputStream out) {
final BufferedImage image = generate(content, width, height);
ImgUtil.write(image, imageType, out);
}
|
[
"public",
"static",
"void",
"generate",
"(",
"String",
"content",
",",
"int",
"width",
",",
"int",
"height",
",",
"String",
"imageType",
",",
"OutputStream",
"out",
")",
"{",
"final",
"BufferedImage",
"image",
"=",
"generate",
"(",
"content",
",",
"width",
",",
"height",
")",
";",
"ImgUtil",
".",
"write",
"(",
"image",
",",
"imageType",
",",
"out",
")",
";",
"}"
] |
生成二维码到输出流
@param content 文本内容
@param width 宽度
@param height 高度
@param imageType 图片类型(图片扩展名),见{@link ImgUtil}
@param out 目标流
|
[
"生成二维码到输出流"
] |
train
|
https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-extra/src/main/java/cn/hutool/extra/qrcode/QrCodeUtil.java#L106-L109
|
brianwhu/xillium
|
data/src/main/java/org/xillium/data/validation/Reifier.java
|
Reifier.addTypeSet
|
public Reifier addTypeSet(Class<?> spec) {
"""
Adds a set of data type specifications.
@param spec - a class that defines data types as member fields
"""
for (Field field: spec.getDeclaredFields()) {
if (Modifier.isPublic(field.getModifiers())) {
String name = field.getName();
try {
_named.put(name, new Validator(name, field.getType(), field));
} catch (IllegalArgumentException x) {
Trace.g.std.note(Reifier.class, "Ignored " + name + ": " + x.getMessage());
}
} else {
Trace.g.std.note(Reifier.class, "Ignored non-public field: " + field.getName());
}
}
return this;
}
|
java
|
public Reifier addTypeSet(Class<?> spec) {
for (Field field: spec.getDeclaredFields()) {
if (Modifier.isPublic(field.getModifiers())) {
String name = field.getName();
try {
_named.put(name, new Validator(name, field.getType(), field));
} catch (IllegalArgumentException x) {
Trace.g.std.note(Reifier.class, "Ignored " + name + ": " + x.getMessage());
}
} else {
Trace.g.std.note(Reifier.class, "Ignored non-public field: " + field.getName());
}
}
return this;
}
|
[
"public",
"Reifier",
"addTypeSet",
"(",
"Class",
"<",
"?",
">",
"spec",
")",
"{",
"for",
"(",
"Field",
"field",
":",
"spec",
".",
"getDeclaredFields",
"(",
")",
")",
"{",
"if",
"(",
"Modifier",
".",
"isPublic",
"(",
"field",
".",
"getModifiers",
"(",
")",
")",
")",
"{",
"String",
"name",
"=",
"field",
".",
"getName",
"(",
")",
";",
"try",
"{",
"_named",
".",
"put",
"(",
"name",
",",
"new",
"Validator",
"(",
"name",
",",
"field",
".",
"getType",
"(",
")",
",",
"field",
")",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"x",
")",
"{",
"Trace",
".",
"g",
".",
"std",
".",
"note",
"(",
"Reifier",
".",
"class",
",",
"\"Ignored \"",
"+",
"name",
"+",
"\": \"",
"+",
"x",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"Trace",
".",
"g",
".",
"std",
".",
"note",
"(",
"Reifier",
".",
"class",
",",
"\"Ignored non-public field: \"",
"+",
"field",
".",
"getName",
"(",
")",
")",
";",
"}",
"}",
"return",
"this",
";",
"}"
] |
Adds a set of data type specifications.
@param spec - a class that defines data types as member fields
|
[
"Adds",
"a",
"set",
"of",
"data",
"type",
"specifications",
"."
] |
train
|
https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/validation/Reifier.java#L35-L50
|
jamesagnew/hapi-fhir
|
hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/param/DateRangeParam.java
|
DateRangeParam.setRangeFromDatesInclusive
|
public void setRangeFromDatesInclusive(Date theLowerBound, Date theUpperBound) {
"""
Sets the range from a pair of dates, inclusive on both ends
@param theLowerBound A qualified date param representing the lower date bound (optionally may include time), e.g.
"2011-02-22" or "2011-02-22T13:12:00Z". Will be treated inclusively. Either theLowerBound or
theUpperBound may both be populated, or one may be null, but it is not valid for both to be null.
@param theUpperBound A qualified date param representing the upper date bound (optionally may include time), e.g.
"2011-02-22" or "2011-02-22T13:12:00Z". Will be treated inclusively. Either theLowerBound or
theUpperBound may both be populated, or one may be null, but it is not valid for both to be null.
"""
DateParam lowerBound = theLowerBound != null
? new DateParam(GREATERTHAN_OR_EQUALS, theLowerBound) : null;
DateParam upperBound = theUpperBound != null
? new DateParam(LESSTHAN_OR_EQUALS, theUpperBound) : null;
validateAndSet(lowerBound, upperBound);
}
|
java
|
public void setRangeFromDatesInclusive(Date theLowerBound, Date theUpperBound) {
DateParam lowerBound = theLowerBound != null
? new DateParam(GREATERTHAN_OR_EQUALS, theLowerBound) : null;
DateParam upperBound = theUpperBound != null
? new DateParam(LESSTHAN_OR_EQUALS, theUpperBound) : null;
validateAndSet(lowerBound, upperBound);
}
|
[
"public",
"void",
"setRangeFromDatesInclusive",
"(",
"Date",
"theLowerBound",
",",
"Date",
"theUpperBound",
")",
"{",
"DateParam",
"lowerBound",
"=",
"theLowerBound",
"!=",
"null",
"?",
"new",
"DateParam",
"(",
"GREATERTHAN_OR_EQUALS",
",",
"theLowerBound",
")",
":",
"null",
";",
"DateParam",
"upperBound",
"=",
"theUpperBound",
"!=",
"null",
"?",
"new",
"DateParam",
"(",
"LESSTHAN_OR_EQUALS",
",",
"theUpperBound",
")",
":",
"null",
";",
"validateAndSet",
"(",
"lowerBound",
",",
"upperBound",
")",
";",
"}"
] |
Sets the range from a pair of dates, inclusive on both ends
@param theLowerBound A qualified date param representing the lower date bound (optionally may include time), e.g.
"2011-02-22" or "2011-02-22T13:12:00Z". Will be treated inclusively. Either theLowerBound or
theUpperBound may both be populated, or one may be null, but it is not valid for both to be null.
@param theUpperBound A qualified date param representing the upper date bound (optionally may include time), e.g.
"2011-02-22" or "2011-02-22T13:12:00Z". Will be treated inclusively. Either theLowerBound or
theUpperBound may both be populated, or one may be null, but it is not valid for both to be null.
|
[
"Sets",
"the",
"range",
"from",
"a",
"pair",
"of",
"dates",
"inclusive",
"on",
"both",
"ends"
] |
train
|
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/param/DateRangeParam.java#L387-L393
|
ngageoint/geopackage-java
|
src/main/java/mil/nga/geopackage/extension/coverage/CoverageDataPng.java
|
CoverageDataPng.getUnsignedPixelValue
|
public int getUnsignedPixelValue(WritableRaster raster, int x, int y) {
"""
Get the pixel value as a 16 bit unsigned integer value
@param raster
image raster
@param x
x coordinate
@param y
y coordinate
@return unsigned integer pixel value
"""
short pixelValue = getPixelValue(raster, x, y);
int unsignedPixelValue = getUnsignedPixelValue(pixelValue);
return unsignedPixelValue;
}
|
java
|
public int getUnsignedPixelValue(WritableRaster raster, int x, int y) {
short pixelValue = getPixelValue(raster, x, y);
int unsignedPixelValue = getUnsignedPixelValue(pixelValue);
return unsignedPixelValue;
}
|
[
"public",
"int",
"getUnsignedPixelValue",
"(",
"WritableRaster",
"raster",
",",
"int",
"x",
",",
"int",
"y",
")",
"{",
"short",
"pixelValue",
"=",
"getPixelValue",
"(",
"raster",
",",
"x",
",",
"y",
")",
";",
"int",
"unsignedPixelValue",
"=",
"getUnsignedPixelValue",
"(",
"pixelValue",
")",
";",
"return",
"unsignedPixelValue",
";",
"}"
] |
Get the pixel value as a 16 bit unsigned integer value
@param raster
image raster
@param x
x coordinate
@param y
y coordinate
@return unsigned integer pixel value
|
[
"Get",
"the",
"pixel",
"value",
"as",
"a",
"16",
"bit",
"unsigned",
"integer",
"value"
] |
train
|
https://github.com/ngageoint/geopackage-java/blob/889bffb5d18330a3f4bd89443acf7959ebe3a376/src/main/java/mil/nga/geopackage/extension/coverage/CoverageDataPng.java#L177-L181
|
hankcs/HanLP
|
src/main/java/com/hankcs/hanlp/tokenizer/lexical/AbstractLexicalAnalyzer.java
|
AbstractLexicalAnalyzer.segment
|
protected void segment(final String sentence, final String normalized, final List<String> wordList, final List<CoreDictionary.Attribute> attributeList) {
"""
分词
@param sentence 文本
@param normalized 正规化后的文本
@param wordList 储存单词列表
@param attributeList 储存用户词典中的词性,设为null表示不查询用户词典
"""
if (attributeList != null)
{
final int[] offset = new int[]{0};
CustomDictionary.parseLongestText(sentence, new AhoCorasickDoubleArrayTrie.IHit<CoreDictionary.Attribute>()
{
@Override
public void hit(int begin, int end, CoreDictionary.Attribute value)
{
if (begin != offset[0])
{
segmentAfterRule(sentence.substring(offset[0], begin), normalized.substring(offset[0], begin), wordList);
}
while (attributeList.size() < wordList.size())
attributeList.add(null);
wordList.add(sentence.substring(begin, end));
attributeList.add(value);
assert wordList.size() == attributeList.size() : "词语列表与属性列表不等长";
offset[0] = end;
}
});
if (offset[0] != sentence.length())
{
segmentAfterRule(sentence.substring(offset[0]), normalized.substring(offset[0]), wordList);
}
}
else
{
segmentAfterRule(sentence, normalized, wordList);
}
}
|
java
|
protected void segment(final String sentence, final String normalized, final List<String> wordList, final List<CoreDictionary.Attribute> attributeList)
{
if (attributeList != null)
{
final int[] offset = new int[]{0};
CustomDictionary.parseLongestText(sentence, new AhoCorasickDoubleArrayTrie.IHit<CoreDictionary.Attribute>()
{
@Override
public void hit(int begin, int end, CoreDictionary.Attribute value)
{
if (begin != offset[0])
{
segmentAfterRule(sentence.substring(offset[0], begin), normalized.substring(offset[0], begin), wordList);
}
while (attributeList.size() < wordList.size())
attributeList.add(null);
wordList.add(sentence.substring(begin, end));
attributeList.add(value);
assert wordList.size() == attributeList.size() : "词语列表与属性列表不等长";
offset[0] = end;
}
});
if (offset[0] != sentence.length())
{
segmentAfterRule(sentence.substring(offset[0]), normalized.substring(offset[0]), wordList);
}
}
else
{
segmentAfterRule(sentence, normalized, wordList);
}
}
|
[
"protected",
"void",
"segment",
"(",
"final",
"String",
"sentence",
",",
"final",
"String",
"normalized",
",",
"final",
"List",
"<",
"String",
">",
"wordList",
",",
"final",
"List",
"<",
"CoreDictionary",
".",
"Attribute",
">",
"attributeList",
")",
"{",
"if",
"(",
"attributeList",
"!=",
"null",
")",
"{",
"final",
"int",
"[",
"]",
"offset",
"=",
"new",
"int",
"[",
"]",
"{",
"0",
"}",
";",
"CustomDictionary",
".",
"parseLongestText",
"(",
"sentence",
",",
"new",
"AhoCorasickDoubleArrayTrie",
".",
"IHit",
"<",
"CoreDictionary",
".",
"Attribute",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"hit",
"(",
"int",
"begin",
",",
"int",
"end",
",",
"CoreDictionary",
".",
"Attribute",
"value",
")",
"{",
"if",
"(",
"begin",
"!=",
"offset",
"[",
"0",
"]",
")",
"{",
"segmentAfterRule",
"(",
"sentence",
".",
"substring",
"(",
"offset",
"[",
"0",
"]",
",",
"begin",
")",
",",
"normalized",
".",
"substring",
"(",
"offset",
"[",
"0",
"]",
",",
"begin",
")",
",",
"wordList",
")",
";",
"}",
"while",
"(",
"attributeList",
".",
"size",
"(",
")",
"<",
"wordList",
".",
"size",
"(",
")",
")",
"attributeList",
".",
"add",
"(",
"null",
")",
";",
"wordList",
".",
"add",
"(",
"sentence",
".",
"substring",
"(",
"begin",
",",
"end",
")",
")",
";",
"attributeList",
".",
"add",
"(",
"value",
")",
";",
"assert",
"wordList",
".",
"size",
"(",
")",
"==",
"attributeList",
".",
"size",
"(",
")",
":",
"\"词语列表与属性列表不等长\";",
"",
"offset",
"[",
"0",
"]",
"=",
"end",
";",
"}",
"}",
")",
";",
"if",
"(",
"offset",
"[",
"0",
"]",
"!=",
"sentence",
".",
"length",
"(",
")",
")",
"{",
"segmentAfterRule",
"(",
"sentence",
".",
"substring",
"(",
"offset",
"[",
"0",
"]",
")",
",",
"normalized",
".",
"substring",
"(",
"offset",
"[",
"0",
"]",
")",
",",
"wordList",
")",
";",
"}",
"}",
"else",
"{",
"segmentAfterRule",
"(",
"sentence",
",",
"normalized",
",",
"wordList",
")",
";",
"}",
"}"
] |
分词
@param sentence 文本
@param normalized 正规化后的文本
@param wordList 储存单词列表
@param attributeList 储存用户词典中的词性,设为null表示不查询用户词典
|
[
"分词"
] |
train
|
https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/tokenizer/lexical/AbstractLexicalAnalyzer.java#L109-L140
|
actframework/actframework
|
src/main/java/act/ws/WebSocketConnectionRegistry.java
|
WebSocketConnectionRegistry.signIn
|
public void signIn(String key, WebSocketConnection connection) {
"""
Sign in a connection to the registry by key.
Note multiple connections can be attached to the same key
@param key
the key
@param connection
the websocket connection
@see #register(String, WebSocketConnection)
"""
ConcurrentMap<WebSocketConnection, WebSocketConnection> bag = ensureConnectionList(key);
bag.put(connection, connection);
}
|
java
|
public void signIn(String key, WebSocketConnection connection) {
ConcurrentMap<WebSocketConnection, WebSocketConnection> bag = ensureConnectionList(key);
bag.put(connection, connection);
}
|
[
"public",
"void",
"signIn",
"(",
"String",
"key",
",",
"WebSocketConnection",
"connection",
")",
"{",
"ConcurrentMap",
"<",
"WebSocketConnection",
",",
"WebSocketConnection",
">",
"bag",
"=",
"ensureConnectionList",
"(",
"key",
")",
";",
"bag",
".",
"put",
"(",
"connection",
",",
"connection",
")",
";",
"}"
] |
Sign in a connection to the registry by key.
Note multiple connections can be attached to the same key
@param key
the key
@param connection
the websocket connection
@see #register(String, WebSocketConnection)
|
[
"Sign",
"in",
"a",
"connection",
"to",
"the",
"registry",
"by",
"key",
"."
] |
train
|
https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/ws/WebSocketConnectionRegistry.java#L131-L134
|
sawano/java-commons
|
src/main/java/se/sawano/java/commons/lang/validate/AbstractValidate.java
|
AbstractValidate.matchesPattern
|
public CharSequence matchesPattern(final CharSequence input, final String pattern) {
"""
<p>Validate that the specified argument character sequence matches the specified regular expression pattern; otherwise throwing an exception.</p>
<pre>Validate.matchesPattern("hi", "[a-z]*");</pre>
<p>The syntax of the pattern is the one used in the {@link java.util.regex.Pattern} class.</p>
@param input
the character sequence to validate, not null
@param pattern
the regular expression pattern, not null
@return the input
@throws IllegalArgumentValidationException
if the character sequence does not match the pattern
@see #matchesPattern(CharSequence, String, String, Object...)
"""
if (!Pattern.matches(pattern, input)) {
fail(String.format(DEFAULT_MATCHES_PATTERN_EX, input, pattern));
}
return input;
}
|
java
|
public CharSequence matchesPattern(final CharSequence input, final String pattern) {
if (!Pattern.matches(pattern, input)) {
fail(String.format(DEFAULT_MATCHES_PATTERN_EX, input, pattern));
}
return input;
}
|
[
"public",
"CharSequence",
"matchesPattern",
"(",
"final",
"CharSequence",
"input",
",",
"final",
"String",
"pattern",
")",
"{",
"if",
"(",
"!",
"Pattern",
".",
"matches",
"(",
"pattern",
",",
"input",
")",
")",
"{",
"fail",
"(",
"String",
".",
"format",
"(",
"DEFAULT_MATCHES_PATTERN_EX",
",",
"input",
",",
"pattern",
")",
")",
";",
"}",
"return",
"input",
";",
"}"
] |
<p>Validate that the specified argument character sequence matches the specified regular expression pattern; otherwise throwing an exception.</p>
<pre>Validate.matchesPattern("hi", "[a-z]*");</pre>
<p>The syntax of the pattern is the one used in the {@link java.util.regex.Pattern} class.</p>
@param input
the character sequence to validate, not null
@param pattern
the regular expression pattern, not null
@return the input
@throws IllegalArgumentValidationException
if the character sequence does not match the pattern
@see #matchesPattern(CharSequence, String, String, Object...)
|
[
"<p",
">",
"Validate",
"that",
"the",
"specified",
"argument",
"character",
"sequence",
"matches",
"the",
"specified",
"regular",
"expression",
"pattern",
";",
"otherwise",
"throwing",
"an",
"exception",
".",
"<",
"/",
"p",
">",
"<pre",
">",
"Validate",
".",
"matchesPattern",
"(",
"hi",
"[",
"a",
"-",
"z",
"]",
"*",
")",
";",
"<",
"/",
"pre",
">",
"<p",
">",
"The",
"syntax",
"of",
"the",
"pattern",
"is",
"the",
"one",
"used",
"in",
"the",
"{",
"@link",
"java",
".",
"util",
".",
"regex",
".",
"Pattern",
"}",
"class",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/sawano/java-commons/blob/6f219c9e8dec4401dbe528d17ae6ec1ef9c0d284/src/main/java/se/sawano/java/commons/lang/validate/AbstractValidate.java#L1170-L1175
|
mgledi/DRUMS
|
src/main/java/com/unister/semweb/drums/storable/GeneralStructure.java
|
GeneralStructure.addValuePart
|
public boolean addValuePart(String name, int size) throws IOException {
"""
Adds a new ValuePart
@param name
the name of the key part. With this name you can access this part
@param size
the size of the key part in bytes
@return true if adding the value part was successful
@throws IOException
"""
if (INSTANCE_EXISITS) {
throw new IOException("A GeneralStroable was already instantiated. You cant further add Value Parts");
}
int hash = Arrays.hashCode(name.getBytes());
int index = valuePartNames.size();
if (valueHash2Index.containsKey(hash)) {
logger.error("A valuePart with the name {} already exists", name);
return false;
}
valuePartNames.add(name);
valueHash2Index.put(hash, index);
valueIndex2Hash.add(hash);
valueSizes.add(size);
valueByteOffsets.add(valueSize);
valueSize += size;
return true;
}
|
java
|
public boolean addValuePart(String name, int size) throws IOException {
if (INSTANCE_EXISITS) {
throw new IOException("A GeneralStroable was already instantiated. You cant further add Value Parts");
}
int hash = Arrays.hashCode(name.getBytes());
int index = valuePartNames.size();
if (valueHash2Index.containsKey(hash)) {
logger.error("A valuePart with the name {} already exists", name);
return false;
}
valuePartNames.add(name);
valueHash2Index.put(hash, index);
valueIndex2Hash.add(hash);
valueSizes.add(size);
valueByteOffsets.add(valueSize);
valueSize += size;
return true;
}
|
[
"public",
"boolean",
"addValuePart",
"(",
"String",
"name",
",",
"int",
"size",
")",
"throws",
"IOException",
"{",
"if",
"(",
"INSTANCE_EXISITS",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"A GeneralStroable was already instantiated. You cant further add Value Parts\"",
")",
";",
"}",
"int",
"hash",
"=",
"Arrays",
".",
"hashCode",
"(",
"name",
".",
"getBytes",
"(",
")",
")",
";",
"int",
"index",
"=",
"valuePartNames",
".",
"size",
"(",
")",
";",
"if",
"(",
"valueHash2Index",
".",
"containsKey",
"(",
"hash",
")",
")",
"{",
"logger",
".",
"error",
"(",
"\"A valuePart with the name {} already exists\"",
",",
"name",
")",
";",
"return",
"false",
";",
"}",
"valuePartNames",
".",
"add",
"(",
"name",
")",
";",
"valueHash2Index",
".",
"put",
"(",
"hash",
",",
"index",
")",
";",
"valueIndex2Hash",
".",
"add",
"(",
"hash",
")",
";",
"valueSizes",
".",
"add",
"(",
"size",
")",
";",
"valueByteOffsets",
".",
"add",
"(",
"valueSize",
")",
";",
"valueSize",
"+=",
"size",
";",
"return",
"true",
";",
"}"
] |
Adds a new ValuePart
@param name
the name of the key part. With this name you can access this part
@param size
the size of the key part in bytes
@return true if adding the value part was successful
@throws IOException
|
[
"Adds",
"a",
"new",
"ValuePart"
] |
train
|
https://github.com/mgledi/DRUMS/blob/a670f17a2186c9a15725f26617d77ce8e444e072/src/main/java/com/unister/semweb/drums/storable/GeneralStructure.java#L82-L99
|
salesforce/Argus
|
ArgusWebServices/src/main/java/com/salesforce/dva/argus/ws/resources/AlertResources.java
|
AlertResources.updateAlert
|
@PUT
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Path("/ {
"""
Updates existing alert.
@param req The HttpServlet request object. Cannot be null.
@param alertId The id of an alert. Cannot be null.
@param alertDto The new alert object. Cannot be null.
@return Updated alert object.
@throws WebApplicationException The exception with 404 status will be thrown if the alert does not exist.
"""alertId}")
@Description("Updates an alert having the given ID.")
public AlertDto updateAlert(@Context HttpServletRequest req, @PathParam("alertId") BigInteger alertId, AlertDto alertDto) {
if (alertId == null || alertId.compareTo(BigInteger.ZERO) < 1) {
throw new WebApplicationException("Alert Id cannot be null and must be a positive non-zero number.", Status.BAD_REQUEST);
}
if (alertDto == null) {
throw new WebApplicationException("Null object cannot be updated.", Status.BAD_REQUEST);
}
PrincipalUser owner = validateAndGetOwner(req, alertDto.getOwnerName());
Alert oldAlert = alertService.findAlertByPrimaryKey(alertId);
if (oldAlert == null) {
throw new WebApplicationException(Response.Status.NOT_FOUND.getReasonPhrase(), Response.Status.NOT_FOUND);
}
validateResourceAuthorization(req, oldAlert.getOwner(), owner);
copyProperties(oldAlert, alertDto);
oldAlert.setModifiedBy(getRemoteUser(req));
return AlertDto.transformToDto(alertService.updateAlert(oldAlert));
}
|
java
|
@PUT
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Path("/{alertId}")
@Description("Updates an alert having the given ID.")
public AlertDto updateAlert(@Context HttpServletRequest req, @PathParam("alertId") BigInteger alertId, AlertDto alertDto) {
if (alertId == null || alertId.compareTo(BigInteger.ZERO) < 1) {
throw new WebApplicationException("Alert Id cannot be null and must be a positive non-zero number.", Status.BAD_REQUEST);
}
if (alertDto == null) {
throw new WebApplicationException("Null object cannot be updated.", Status.BAD_REQUEST);
}
PrincipalUser owner = validateAndGetOwner(req, alertDto.getOwnerName());
Alert oldAlert = alertService.findAlertByPrimaryKey(alertId);
if (oldAlert == null) {
throw new WebApplicationException(Response.Status.NOT_FOUND.getReasonPhrase(), Response.Status.NOT_FOUND);
}
validateResourceAuthorization(req, oldAlert.getOwner(), owner);
copyProperties(oldAlert, alertDto);
oldAlert.setModifiedBy(getRemoteUser(req));
return AlertDto.transformToDto(alertService.updateAlert(oldAlert));
}
|
[
"@",
"PUT",
"@",
"Produces",
"(",
"MediaType",
".",
"APPLICATION_JSON",
")",
"@",
"Consumes",
"(",
"MediaType",
".",
"APPLICATION_JSON",
")",
"@",
"Path",
"(",
"\"/{alertId}\"",
")",
"@",
"Description",
"(",
"\"Updates an alert having the given ID.\"",
")",
"public",
"AlertDto",
"updateAlert",
"(",
"@",
"Context",
"HttpServletRequest",
"req",
",",
"@",
"PathParam",
"(",
"\"alertId\"",
")",
"BigInteger",
"alertId",
",",
"AlertDto",
"alertDto",
")",
"{",
"if",
"(",
"alertId",
"==",
"null",
"||",
"alertId",
".",
"compareTo",
"(",
"BigInteger",
".",
"ZERO",
")",
"<",
"1",
")",
"{",
"throw",
"new",
"WebApplicationException",
"(",
"\"Alert Id cannot be null and must be a positive non-zero number.\"",
",",
"Status",
".",
"BAD_REQUEST",
")",
";",
"}",
"if",
"(",
"alertDto",
"==",
"null",
")",
"{",
"throw",
"new",
"WebApplicationException",
"(",
"\"Null object cannot be updated.\"",
",",
"Status",
".",
"BAD_REQUEST",
")",
";",
"}",
"PrincipalUser",
"owner",
"=",
"validateAndGetOwner",
"(",
"req",
",",
"alertDto",
".",
"getOwnerName",
"(",
")",
")",
";",
"Alert",
"oldAlert",
"=",
"alertService",
".",
"findAlertByPrimaryKey",
"(",
"alertId",
")",
";",
"if",
"(",
"oldAlert",
"==",
"null",
")",
"{",
"throw",
"new",
"WebApplicationException",
"(",
"Response",
".",
"Status",
".",
"NOT_FOUND",
".",
"getReasonPhrase",
"(",
")",
",",
"Response",
".",
"Status",
".",
"NOT_FOUND",
")",
";",
"}",
"validateResourceAuthorization",
"(",
"req",
",",
"oldAlert",
".",
"getOwner",
"(",
")",
",",
"owner",
")",
";",
"copyProperties",
"(",
"oldAlert",
",",
"alertDto",
")",
";",
"oldAlert",
".",
"setModifiedBy",
"(",
"getRemoteUser",
"(",
"req",
")",
")",
";",
"return",
"AlertDto",
".",
"transformToDto",
"(",
"alertService",
".",
"updateAlert",
"(",
"oldAlert",
")",
")",
";",
"}"
] |
Updates existing alert.
@param req The HttpServlet request object. Cannot be null.
@param alertId The id of an alert. Cannot be null.
@param alertDto The new alert object. Cannot be null.
@return Updated alert object.
@throws WebApplicationException The exception with 404 status will be thrown if the alert does not exist.
|
[
"Updates",
"existing",
"alert",
"."
] |
train
|
https://github.com/salesforce/Argus/blob/121b59a268da264316cded6a3e9271366a23cd86/ArgusWebServices/src/main/java/com/salesforce/dva/argus/ws/resources/AlertResources.java#L663-L689
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/networking/OutboundHandler.java
|
OutboundHandler.initDstBuffer
|
protected final void initDstBuffer(int sizeBytes, byte[] bytes) {
"""
Initializes the dst ByteBuffer with the configured size.
The buffer created is reading mode.
@param sizeBytes the size of the dst ByteBuffer.
@param bytes the bytes added to the buffer. Can be null if nothing
should be added.
@throws IllegalArgumentException if the size of the buffer is too small.
"""
if (bytes != null && bytes.length > sizeBytes) {
throw new IllegalArgumentException("Buffer overflow. Can't initialize dstBuffer for "
+ this + " and channel" + channel + " because too many bytes, sizeBytes " + sizeBytes
+ ". bytes.length " + bytes.length);
}
ChannelOptions config = channel.options();
ByteBuffer buffer = newByteBuffer(sizeBytes, config.getOption(DIRECT_BUF));
if (bytes != null) {
buffer.put(bytes);
}
buffer.flip();
dst = (D) buffer;
}
|
java
|
protected final void initDstBuffer(int sizeBytes, byte[] bytes) {
if (bytes != null && bytes.length > sizeBytes) {
throw new IllegalArgumentException("Buffer overflow. Can't initialize dstBuffer for "
+ this + " and channel" + channel + " because too many bytes, sizeBytes " + sizeBytes
+ ". bytes.length " + bytes.length);
}
ChannelOptions config = channel.options();
ByteBuffer buffer = newByteBuffer(sizeBytes, config.getOption(DIRECT_BUF));
if (bytes != null) {
buffer.put(bytes);
}
buffer.flip();
dst = (D) buffer;
}
|
[
"protected",
"final",
"void",
"initDstBuffer",
"(",
"int",
"sizeBytes",
",",
"byte",
"[",
"]",
"bytes",
")",
"{",
"if",
"(",
"bytes",
"!=",
"null",
"&&",
"bytes",
".",
"length",
">",
"sizeBytes",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Buffer overflow. Can't initialize dstBuffer for \"",
"+",
"this",
"+",
"\" and channel\"",
"+",
"channel",
"+",
"\" because too many bytes, sizeBytes \"",
"+",
"sizeBytes",
"+",
"\". bytes.length \"",
"+",
"bytes",
".",
"length",
")",
";",
"}",
"ChannelOptions",
"config",
"=",
"channel",
".",
"options",
"(",
")",
";",
"ByteBuffer",
"buffer",
"=",
"newByteBuffer",
"(",
"sizeBytes",
",",
"config",
".",
"getOption",
"(",
"DIRECT_BUF",
")",
")",
";",
"if",
"(",
"bytes",
"!=",
"null",
")",
"{",
"buffer",
".",
"put",
"(",
"bytes",
")",
";",
"}",
"buffer",
".",
"flip",
"(",
")",
";",
"dst",
"=",
"(",
"D",
")",
"buffer",
";",
"}"
] |
Initializes the dst ByteBuffer with the configured size.
The buffer created is reading mode.
@param sizeBytes the size of the dst ByteBuffer.
@param bytes the bytes added to the buffer. Can be null if nothing
should be added.
@throws IllegalArgumentException if the size of the buffer is too small.
|
[
"Initializes",
"the",
"dst",
"ByteBuffer",
"with",
"the",
"configured",
"size",
"."
] |
train
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/networking/OutboundHandler.java#L108-L122
|
lucee/Lucee
|
core/src/main/java/lucee/runtime/db/Executer.java
|
Executer.executeConstant
|
private Object executeConstant(SQL sql, Query qr, ZConstant constant, int row) throws PageException {
"""
Executes a constant value
@param sql
@param qr
@param constant
@param row
@return result
@throws PageException
"""
switch (constant.getType()) {
case ZConstant.COLUMNNAME: {
if (constant.getValue().equals(SQLPrettyfier.PLACEHOLDER_QUESTION)) {
int pos = sql.getPosition();
sql.setPosition(pos + 1);
if (sql.getItems().length <= pos) throw new DatabaseException("invalid syntax for SQL Statement", null, sql, null);
return sql.getItems()[pos].getValueForCF();
}
return qr.getAt(ListUtil.last(constant.getValue(), ".", true), row);
}
case ZConstant.NULL:
return null;
case ZConstant.NUMBER:
return Caster.toDouble(constant.getValue());
case ZConstant.STRING:
return constant.getValue();
case ZConstant.UNKNOWN:
default:
throw new DatabaseException("invalid constant value", null, sql, null);
}
}
|
java
|
private Object executeConstant(SQL sql, Query qr, ZConstant constant, int row) throws PageException {
switch (constant.getType()) {
case ZConstant.COLUMNNAME: {
if (constant.getValue().equals(SQLPrettyfier.PLACEHOLDER_QUESTION)) {
int pos = sql.getPosition();
sql.setPosition(pos + 1);
if (sql.getItems().length <= pos) throw new DatabaseException("invalid syntax for SQL Statement", null, sql, null);
return sql.getItems()[pos].getValueForCF();
}
return qr.getAt(ListUtil.last(constant.getValue(), ".", true), row);
}
case ZConstant.NULL:
return null;
case ZConstant.NUMBER:
return Caster.toDouble(constant.getValue());
case ZConstant.STRING:
return constant.getValue();
case ZConstant.UNKNOWN:
default:
throw new DatabaseException("invalid constant value", null, sql, null);
}
}
|
[
"private",
"Object",
"executeConstant",
"(",
"SQL",
"sql",
",",
"Query",
"qr",
",",
"ZConstant",
"constant",
",",
"int",
"row",
")",
"throws",
"PageException",
"{",
"switch",
"(",
"constant",
".",
"getType",
"(",
")",
")",
"{",
"case",
"ZConstant",
".",
"COLUMNNAME",
":",
"{",
"if",
"(",
"constant",
".",
"getValue",
"(",
")",
".",
"equals",
"(",
"SQLPrettyfier",
".",
"PLACEHOLDER_QUESTION",
")",
")",
"{",
"int",
"pos",
"=",
"sql",
".",
"getPosition",
"(",
")",
";",
"sql",
".",
"setPosition",
"(",
"pos",
"+",
"1",
")",
";",
"if",
"(",
"sql",
".",
"getItems",
"(",
")",
".",
"length",
"<=",
"pos",
")",
"throw",
"new",
"DatabaseException",
"(",
"\"invalid syntax for SQL Statement\"",
",",
"null",
",",
"sql",
",",
"null",
")",
";",
"return",
"sql",
".",
"getItems",
"(",
")",
"[",
"pos",
"]",
".",
"getValueForCF",
"(",
")",
";",
"}",
"return",
"qr",
".",
"getAt",
"(",
"ListUtil",
".",
"last",
"(",
"constant",
".",
"getValue",
"(",
")",
",",
"\".\"",
",",
"true",
")",
",",
"row",
")",
";",
"}",
"case",
"ZConstant",
".",
"NULL",
":",
"return",
"null",
";",
"case",
"ZConstant",
".",
"NUMBER",
":",
"return",
"Caster",
".",
"toDouble",
"(",
"constant",
".",
"getValue",
"(",
")",
")",
";",
"case",
"ZConstant",
".",
"STRING",
":",
"return",
"constant",
".",
"getValue",
"(",
")",
";",
"case",
"ZConstant",
".",
"UNKNOWN",
":",
"default",
":",
"throw",
"new",
"DatabaseException",
"(",
"\"invalid constant value\"",
",",
"null",
",",
"sql",
",",
"null",
")",
";",
"}",
"}"
] |
Executes a constant value
@param sql
@param qr
@param constant
@param row
@return result
@throws PageException
|
[
"Executes",
"a",
"constant",
"value"
] |
train
|
https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/runtime/db/Executer.java#L707-L728
|
VoltDB/voltdb
|
src/frontend/org/voltdb/sysprocs/UpdateApplicationBase.java
|
UpdateApplicationBase.addDDLToCatalog
|
protected static InMemoryJarfile addDDLToCatalog(Catalog oldCatalog, InMemoryJarfile jarfile, String[] adhocDDLStmts, boolean isXDCR)
throws IOException, VoltCompilerException {
"""
Append the supplied adhoc DDL to the current catalog's DDL and recompile the
jarfile
@throws VoltCompilerException
"""
StringBuilder sb = new StringBuilder();
compilerLog.info("Applying the following DDL to cluster:");
for (String stmt : adhocDDLStmts) {
compilerLog.info("\t" + stmt);
sb.append(stmt);
sb.append(";\n");
}
String newDDL = sb.toString();
compilerLog.trace("Adhoc-modified DDL:\n" + newDDL);
VoltCompiler compiler = new VoltCompiler(isXDCR);
compiler.compileInMemoryJarfileWithNewDDL(jarfile, newDDL, oldCatalog);
return jarfile;
}
|
java
|
protected static InMemoryJarfile addDDLToCatalog(Catalog oldCatalog, InMemoryJarfile jarfile, String[] adhocDDLStmts, boolean isXDCR)
throws IOException, VoltCompilerException
{
StringBuilder sb = new StringBuilder();
compilerLog.info("Applying the following DDL to cluster:");
for (String stmt : adhocDDLStmts) {
compilerLog.info("\t" + stmt);
sb.append(stmt);
sb.append(";\n");
}
String newDDL = sb.toString();
compilerLog.trace("Adhoc-modified DDL:\n" + newDDL);
VoltCompiler compiler = new VoltCompiler(isXDCR);
compiler.compileInMemoryJarfileWithNewDDL(jarfile, newDDL, oldCatalog);
return jarfile;
}
|
[
"protected",
"static",
"InMemoryJarfile",
"addDDLToCatalog",
"(",
"Catalog",
"oldCatalog",
",",
"InMemoryJarfile",
"jarfile",
",",
"String",
"[",
"]",
"adhocDDLStmts",
",",
"boolean",
"isXDCR",
")",
"throws",
"IOException",
",",
"VoltCompilerException",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"compilerLog",
".",
"info",
"(",
"\"Applying the following DDL to cluster:\"",
")",
";",
"for",
"(",
"String",
"stmt",
":",
"adhocDDLStmts",
")",
"{",
"compilerLog",
".",
"info",
"(",
"\"\\t\"",
"+",
"stmt",
")",
";",
"sb",
".",
"append",
"(",
"stmt",
")",
";",
"sb",
".",
"append",
"(",
"\";\\n\"",
")",
";",
"}",
"String",
"newDDL",
"=",
"sb",
".",
"toString",
"(",
")",
";",
"compilerLog",
".",
"trace",
"(",
"\"Adhoc-modified DDL:\\n\"",
"+",
"newDDL",
")",
";",
"VoltCompiler",
"compiler",
"=",
"new",
"VoltCompiler",
"(",
"isXDCR",
")",
";",
"compiler",
".",
"compileInMemoryJarfileWithNewDDL",
"(",
"jarfile",
",",
"newDDL",
",",
"oldCatalog",
")",
";",
"return",
"jarfile",
";",
"}"
] |
Append the supplied adhoc DDL to the current catalog's DDL and recompile the
jarfile
@throws VoltCompilerException
|
[
"Append",
"the",
"supplied",
"adhoc",
"DDL",
"to",
"the",
"current",
"catalog",
"s",
"DDL",
"and",
"recompile",
"the",
"jarfile"
] |
train
|
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/sysprocs/UpdateApplicationBase.java#L312-L328
|
xhsun/gw2wrapper
|
src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java
|
AsynchronousRequest.getPriceInfo
|
public void getPriceInfo(int[] ids, Callback<List<Prices>> callback) throws GuildWars2Exception, NullPointerException {
"""
For more info on Listing Price API go <a href="https://wiki.guildwars2.com/wiki/API:2/commerce/prices">here</a><br/>
Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions
@param ids list of item id
@param callback callback that is going to be used for {@link Call#enqueue(Callback)}
@throws GuildWars2Exception empty ID list
@throws NullPointerException if given {@link Callback} is empty
@see Prices listing item price info
"""
isParamValid(new ParamChecker(ids));
gw2API.getTPPriceInfo(processIds(ids)).enqueue(callback);
}
|
java
|
public void getPriceInfo(int[] ids, Callback<List<Prices>> callback) throws GuildWars2Exception, NullPointerException {
isParamValid(new ParamChecker(ids));
gw2API.getTPPriceInfo(processIds(ids)).enqueue(callback);
}
|
[
"public",
"void",
"getPriceInfo",
"(",
"int",
"[",
"]",
"ids",
",",
"Callback",
"<",
"List",
"<",
"Prices",
">",
">",
"callback",
")",
"throws",
"GuildWars2Exception",
",",
"NullPointerException",
"{",
"isParamValid",
"(",
"new",
"ParamChecker",
"(",
"ids",
")",
")",
";",
"gw2API",
".",
"getTPPriceInfo",
"(",
"processIds",
"(",
"ids",
")",
")",
".",
"enqueue",
"(",
"callback",
")",
";",
"}"
] |
For more info on Listing Price API go <a href="https://wiki.guildwars2.com/wiki/API:2/commerce/prices">here</a><br/>
Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions
@param ids list of item id
@param callback callback that is going to be used for {@link Call#enqueue(Callback)}
@throws GuildWars2Exception empty ID list
@throws NullPointerException if given {@link Callback} is empty
@see Prices listing item price info
|
[
"For",
"more",
"info",
"on",
"Listing",
"Price",
"API",
"go",
"<a",
"href",
"=",
"https",
":",
"//",
"wiki",
".",
"guildwars2",
".",
"com",
"/",
"wiki",
"/",
"API",
":",
"2",
"/",
"commerce",
"/",
"prices",
">",
"here<",
"/",
"a",
">",
"<br",
"/",
">",
"Give",
"user",
"the",
"access",
"to",
"{",
"@link",
"Callback#onResponse",
"(",
"Call",
"Response",
")",
"}",
"and",
"{",
"@link",
"Callback#onFailure",
"(",
"Call",
"Throwable",
")",
"}",
"methods",
"for",
"custom",
"interactions"
] |
train
|
https://github.com/xhsun/gw2wrapper/blob/c8a43b51f363b032074fb152ee6efe657e33e525/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java#L985-L988
|
lievendoclo/Valkyrie-RCP
|
valkyrie-rcp-core/src/main/java/org/valkyriercp/security/support/AuthorityConfigurableSecurityController.java
|
AuthorityConfigurableSecurityController.shouldAuthorize
|
protected boolean shouldAuthorize(Authentication authentication, Authorizable controlledObject) {
"""
Determine if our controlled objects should be authorized based on the
provided authentication token.
@param authentication
token
@return true if should authorize
"""
Assert.state(getAccessDecisionManager() != null, "The AccessDecisionManager can not be null!");
boolean authorize = false;
try
{
if (authentication != null)
{
List<ConfigAttribute> cad = getConfigAttributeDefinition(controlledObject);
if (cad != null)
{
getAccessDecisionManager().decide(authentication, null, cad);
}
authorize = true;
} else {
// authentication must be disabled, going through
authorize = true;
}
}
catch (AccessDeniedException e)
{
authorize = false;
// This means the secured objects should not be authorized
}
return authorize;
}
|
java
|
protected boolean shouldAuthorize(Authentication authentication, Authorizable controlledObject)
{
Assert.state(getAccessDecisionManager() != null, "The AccessDecisionManager can not be null!");
boolean authorize = false;
try
{
if (authentication != null)
{
List<ConfigAttribute> cad = getConfigAttributeDefinition(controlledObject);
if (cad != null)
{
getAccessDecisionManager().decide(authentication, null, cad);
}
authorize = true;
} else {
// authentication must be disabled, going through
authorize = true;
}
}
catch (AccessDeniedException e)
{
authorize = false;
// This means the secured objects should not be authorized
}
return authorize;
}
|
[
"protected",
"boolean",
"shouldAuthorize",
"(",
"Authentication",
"authentication",
",",
"Authorizable",
"controlledObject",
")",
"{",
"Assert",
".",
"state",
"(",
"getAccessDecisionManager",
"(",
")",
"!=",
"null",
",",
"\"The AccessDecisionManager can not be null!\"",
")",
";",
"boolean",
"authorize",
"=",
"false",
";",
"try",
"{",
"if",
"(",
"authentication",
"!=",
"null",
")",
"{",
"List",
"<",
"ConfigAttribute",
">",
"cad",
"=",
"getConfigAttributeDefinition",
"(",
"controlledObject",
")",
";",
"if",
"(",
"cad",
"!=",
"null",
")",
"{",
"getAccessDecisionManager",
"(",
")",
".",
"decide",
"(",
"authentication",
",",
"null",
",",
"cad",
")",
";",
"}",
"authorize",
"=",
"true",
";",
"}",
"else",
"{",
"// authentication must be disabled, going through",
"authorize",
"=",
"true",
";",
"}",
"}",
"catch",
"(",
"AccessDeniedException",
"e",
")",
"{",
"authorize",
"=",
"false",
";",
"// This means the secured objects should not be authorized",
"}",
"return",
"authorize",
";",
"}"
] |
Determine if our controlled objects should be authorized based on the
provided authentication token.
@param authentication
token
@return true if should authorize
|
[
"Determine",
"if",
"our",
"controlled",
"objects",
"should",
"be",
"authorized",
"based",
"on",
"the",
"provided",
"authentication",
"token",
"."
] |
train
|
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/security/support/AuthorityConfigurableSecurityController.java#L156-L181
|
carewebframework/carewebframework-core
|
org.carewebframework.api-parent/org.carewebframework.api.core/src/main/java/org/carewebframework/api/event/GlobalEventDispatcher.java
|
GlobalEventDispatcher.fireRemoteEvent
|
@Override
public void fireRemoteEvent(String eventName, Serializable eventData, Recipient... recipients) {
"""
Queues the specified event for delivery via the messaging service.
@param eventName Name of the event.
@param eventData Data object associated with the event.
@param recipients Optional list of recipients for the event.
"""
Message message = new EventMessage(eventName, eventData);
producer.publish(EventUtil.getChannelName(eventName), message, recipients);
}
|
java
|
@Override
public void fireRemoteEvent(String eventName, Serializable eventData, Recipient... recipients) {
Message message = new EventMessage(eventName, eventData);
producer.publish(EventUtil.getChannelName(eventName), message, recipients);
}
|
[
"@",
"Override",
"public",
"void",
"fireRemoteEvent",
"(",
"String",
"eventName",
",",
"Serializable",
"eventData",
",",
"Recipient",
"...",
"recipients",
")",
"{",
"Message",
"message",
"=",
"new",
"EventMessage",
"(",
"eventName",
",",
"eventData",
")",
";",
"producer",
".",
"publish",
"(",
"EventUtil",
".",
"getChannelName",
"(",
"eventName",
")",
",",
"message",
",",
"recipients",
")",
";",
"}"
] |
Queues the specified event for delivery via the messaging service.
@param eventName Name of the event.
@param eventData Data object associated with the event.
@param recipients Optional list of recipients for the event.
|
[
"Queues",
"the",
"specified",
"event",
"for",
"delivery",
"via",
"the",
"messaging",
"service",
"."
] |
train
|
https://github.com/carewebframework/carewebframework-core/blob/fa3252d4f7541dbe151b92c3d4f6f91433cd1673/org.carewebframework.api-parent/org.carewebframework.api.core/src/main/java/org/carewebframework/api/event/GlobalEventDispatcher.java#L126-L130
|
qiujuer/Genius-Android
|
caprice/ui/src/main/java/net/qiujuer/genius/ui/Ui.java
|
Ui.getBackgroundColor
|
public static int getBackgroundColor(Context context, AttributeSet attrs) {
"""
Get Background color if the attr is color value
@param context Context
@param attrs AttributeSet
@return Color
"""
int color = Color.TRANSPARENT;
if (isHaveAttribute(attrs, "background")) {
int styleId = attrs.getStyleAttribute();
int[] attributesArray = new int[]{android.R.attr.background};
try {
TypedArray typedArray = context.obtainStyledAttributes(styleId, attributesArray);
if (typedArray.length() > 0)
color = typedArray.getColor(0, color);
typedArray.recycle();
} catch (Resources.NotFoundException e) {
e.printStackTrace();
}
}
return color;
}
|
java
|
public static int getBackgroundColor(Context context, AttributeSet attrs) {
int color = Color.TRANSPARENT;
if (isHaveAttribute(attrs, "background")) {
int styleId = attrs.getStyleAttribute();
int[] attributesArray = new int[]{android.R.attr.background};
try {
TypedArray typedArray = context.obtainStyledAttributes(styleId, attributesArray);
if (typedArray.length() > 0)
color = typedArray.getColor(0, color);
typedArray.recycle();
} catch (Resources.NotFoundException e) {
e.printStackTrace();
}
}
return color;
}
|
[
"public",
"static",
"int",
"getBackgroundColor",
"(",
"Context",
"context",
",",
"AttributeSet",
"attrs",
")",
"{",
"int",
"color",
"=",
"Color",
".",
"TRANSPARENT",
";",
"if",
"(",
"isHaveAttribute",
"(",
"attrs",
",",
"\"background\"",
")",
")",
"{",
"int",
"styleId",
"=",
"attrs",
".",
"getStyleAttribute",
"(",
")",
";",
"int",
"[",
"]",
"attributesArray",
"=",
"new",
"int",
"[",
"]",
"{",
"android",
".",
"R",
".",
"attr",
".",
"background",
"}",
";",
"try",
"{",
"TypedArray",
"typedArray",
"=",
"context",
".",
"obtainStyledAttributes",
"(",
"styleId",
",",
"attributesArray",
")",
";",
"if",
"(",
"typedArray",
".",
"length",
"(",
")",
">",
"0",
")",
"color",
"=",
"typedArray",
".",
"getColor",
"(",
"0",
",",
"color",
")",
";",
"typedArray",
".",
"recycle",
"(",
")",
";",
"}",
"catch",
"(",
"Resources",
".",
"NotFoundException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"return",
"color",
";",
"}"
] |
Get Background color if the attr is color value
@param context Context
@param attrs AttributeSet
@return Color
|
[
"Get",
"Background",
"color",
"if",
"the",
"attr",
"is",
"color",
"value"
] |
train
|
https://github.com/qiujuer/Genius-Android/blob/babefaf1321f5883a21cada582b6fa5104adc648/caprice/ui/src/main/java/net/qiujuer/genius/ui/Ui.java#L189-L207
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ws/ejbcontainer/util/ParsedScheduleExpression.java
|
ParsedScheduleExpression.advance
|
private static void advance(Calendar cal, int field, int nextField, long haystack, int needle) {
"""
Moves the value of the specified field forward in time to satisfy
constraints of the specified bitmask. If a position higher than
needle is found in haystack, then that higher position is set as the
value in field. Otherwise, the lowest value in haystack is set as the
value in field, and the value in nextField is incremented.
<p>For example, if field=Calendar.SECOND, haystack is {30, 40, 50},
and needle is 35, then the seconds field will be set to 40, and the
minutes field will be unchanged. However, if haystack={10, 20, 30},
then the value in the seconds field will be set to 10, and the value of
the minutes field will be incremented.
@param cal the current time
@param field a field from <tt>java.util.Calendar</tt>
@param field the next coarser field after <tt>field</tt>; for example,
if field=Calendar.SECOND, nextField=Calendar.MINUTE
@param haystack the bitmask
@param needle the current position in the bitmask; only higher
"""
long higher = higher(haystack, needle);
if (higher != 0)
{
cal.set(field, first(higher));
}
else
{
cal.set(field, first(haystack));
cal.add(nextField, 1);
}
}
|
java
|
private static void advance(Calendar cal, int field, int nextField, long haystack, int needle)
{
long higher = higher(haystack, needle);
if (higher != 0)
{
cal.set(field, first(higher));
}
else
{
cal.set(field, first(haystack));
cal.add(nextField, 1);
}
}
|
[
"private",
"static",
"void",
"advance",
"(",
"Calendar",
"cal",
",",
"int",
"field",
",",
"int",
"nextField",
",",
"long",
"haystack",
",",
"int",
"needle",
")",
"{",
"long",
"higher",
"=",
"higher",
"(",
"haystack",
",",
"needle",
")",
";",
"if",
"(",
"higher",
"!=",
"0",
")",
"{",
"cal",
".",
"set",
"(",
"field",
",",
"first",
"(",
"higher",
")",
")",
";",
"}",
"else",
"{",
"cal",
".",
"set",
"(",
"field",
",",
"first",
"(",
"haystack",
")",
")",
";",
"cal",
".",
"add",
"(",
"nextField",
",",
"1",
")",
";",
"}",
"}"
] |
Moves the value of the specified field forward in time to satisfy
constraints of the specified bitmask. If a position higher than
needle is found in haystack, then that higher position is set as the
value in field. Otherwise, the lowest value in haystack is set as the
value in field, and the value in nextField is incremented.
<p>For example, if field=Calendar.SECOND, haystack is {30, 40, 50},
and needle is 35, then the seconds field will be set to 40, and the
minutes field will be unchanged. However, if haystack={10, 20, 30},
then the value in the seconds field will be set to 10, and the value of
the minutes field will be incremented.
@param cal the current time
@param field a field from <tt>java.util.Calendar</tt>
@param field the next coarser field after <tt>field</tt>; for example,
if field=Calendar.SECOND, nextField=Calendar.MINUTE
@param haystack the bitmask
@param needle the current position in the bitmask; only higher
|
[
"Moves",
"the",
"value",
"of",
"the",
"specified",
"field",
"forward",
"in",
"time",
"to",
"satisfy",
"constraints",
"of",
"the",
"specified",
"bitmask",
".",
"If",
"a",
"position",
"higher",
"than",
"needle",
"is",
"found",
"in",
"haystack",
"then",
"that",
"higher",
"position",
"is",
"set",
"as",
"the",
"value",
"in",
"field",
".",
"Otherwise",
"the",
"lowest",
"value",
"in",
"haystack",
"is",
"set",
"as",
"the",
"value",
"in",
"field",
"and",
"the",
"value",
"in",
"nextField",
"is",
"incremented",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ws/ejbcontainer/util/ParsedScheduleExpression.java#L892-L904
|
tvesalainen/util
|
util/src/main/java/org/vesalainen/nio/channels/ChannelHelper.java
|
ChannelHelper.traceableChannel
|
public static final ByteChannel traceableChannel(ByteChannel channel, Consumer<ByteBuffer> tracer) {
"""
Returns a ByteChannel having feature that for every read/write method the
tracer function is called with read/write data between position and limit.
<p>
This is planned to support calculating digestives.
@param channel
@param tracer
@return
"""
return new TraceableByteChannel(channel, tracer);
}
|
java
|
public static final ByteChannel traceableChannel(ByteChannel channel, Consumer<ByteBuffer> tracer)
{
return new TraceableByteChannel(channel, tracer);
}
|
[
"public",
"static",
"final",
"ByteChannel",
"traceableChannel",
"(",
"ByteChannel",
"channel",
",",
"Consumer",
"<",
"ByteBuffer",
">",
"tracer",
")",
"{",
"return",
"new",
"TraceableByteChannel",
"(",
"channel",
",",
"tracer",
")",
";",
"}"
] |
Returns a ByteChannel having feature that for every read/write method the
tracer function is called with read/write data between position and limit.
<p>
This is planned to support calculating digestives.
@param channel
@param tracer
@return
|
[
"Returns",
"a",
"ByteChannel",
"having",
"feature",
"that",
"for",
"every",
"read",
"/",
"write",
"method",
"the",
"tracer",
"function",
"is",
"called",
"with",
"read",
"/",
"write",
"data",
"between",
"position",
"and",
"limit",
".",
"<p",
">",
"This",
"is",
"planned",
"to",
"support",
"calculating",
"digestives",
"."
] |
train
|
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/nio/channels/ChannelHelper.java#L614-L617
|
looly/hutool
|
hutool-core/src/main/java/cn/hutool/core/util/ArrayUtil.java
|
ArrayUtil.append
|
@SafeVarargs
public static <T> Object append(Object array, T... newElements) {
"""
将新元素添加到已有数组中<br>
添加新元素会生成一个新的数组,不影响原数组
@param <T> 数组元素类型
@param array 已有数组
@param newElements 新元素
@return 新数组
"""
if(isEmpty(array)) {
return newElements;
}
return insert(array, length(array), newElements);
}
|
java
|
@SafeVarargs
public static <T> Object append(Object array, T... newElements) {
if(isEmpty(array)) {
return newElements;
}
return insert(array, length(array), newElements);
}
|
[
"@",
"SafeVarargs",
"public",
"static",
"<",
"T",
">",
"Object",
"append",
"(",
"Object",
"array",
",",
"T",
"...",
"newElements",
")",
"{",
"if",
"(",
"isEmpty",
"(",
"array",
")",
")",
"{",
"return",
"newElements",
";",
"}",
"return",
"insert",
"(",
"array",
",",
"length",
"(",
"array",
")",
",",
"newElements",
")",
";",
"}"
] |
将新元素添加到已有数组中<br>
添加新元素会生成一个新的数组,不影响原数组
@param <T> 数组元素类型
@param array 已有数组
@param newElements 新元素
@return 新数组
|
[
"将新元素添加到已有数组中<br",
">",
"添加新元素会生成一个新的数组,不影响原数组"
] |
train
|
https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/ArrayUtil.java#L399-L405
|
GenesysPureEngage/authentication-client-java
|
src/main/java/com/genesys/internal/authentication/api/AuthenticationApi.java
|
AuthenticationApi.authorizeAsync
|
public com.squareup.okhttp.Call authorizeAsync(String clientId, String redirectUri, String responseType, String authorization, Boolean hideTenant, String scope, final ApiCallback<Void> callback) throws ApiException {
"""
Perform authorization (asynchronously)
Perform authorization based on the code grant type &mdash; either Authorization Code Grant or Implicit Grant. For more information, see [Authorization Endpoint](https://tools.ietf.org/html/rfc6749#section-3.1). **Note:** For the optional **scope** parameter, the Authentication API supports only the `*` value.
@param clientId The ID of the application or service that is registered as the client. You'll need to get this value from your PureEngage Cloud representative. (required)
@param redirectUri The URI that you want users to be redirected to after entering valid credentials during an Implicit or Authorization Code grant. The Authentication API includes this as part of the URI it returns in the 'Location' header. (required)
@param responseType The response type to let the Authentication API know which grant flow you're using. Possible values are `code` for Authorization Code Grant or `token` for Implicit Grant. For more information about this parameter, see [Response Type](https://tools.ietf.org/html/rfc6749#section-3.1.1). (required)
@param authorization Basic authorization. For example: 'Authorization: Basic Y3...MQ==' (optional)
@param hideTenant Hide the **tenant** field in the UI for Authorization Code Grant. (optional, default to false)
@param scope The scope of the access request. The Authentication API supports only the `*` value. (optional)
@param callback The callback to be executed when the API call finishes
@return The request call
@throws ApiException If fail to process the API call, e.g. serializing the request body object
"""
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
callback.onDownloadProgress(bytesRead, contentLength, done);
}
};
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
@Override
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
callback.onUploadProgress(bytesWritten, contentLength, done);
}
};
}
com.squareup.okhttp.Call call = authorizeValidateBeforeCall(clientId, redirectUri, responseType, authorization, hideTenant, scope, progressListener, progressRequestListener);
apiClient.executeAsync(call, callback);
return call;
}
|
java
|
public com.squareup.okhttp.Call authorizeAsync(String clientId, String redirectUri, String responseType, String authorization, Boolean hideTenant, String scope, final ApiCallback<Void> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
callback.onDownloadProgress(bytesRead, contentLength, done);
}
};
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
@Override
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
callback.onUploadProgress(bytesWritten, contentLength, done);
}
};
}
com.squareup.okhttp.Call call = authorizeValidateBeforeCall(clientId, redirectUri, responseType, authorization, hideTenant, scope, progressListener, progressRequestListener);
apiClient.executeAsync(call, callback);
return call;
}
|
[
"public",
"com",
".",
"squareup",
".",
"okhttp",
".",
"Call",
"authorizeAsync",
"(",
"String",
"clientId",
",",
"String",
"redirectUri",
",",
"String",
"responseType",
",",
"String",
"authorization",
",",
"Boolean",
"hideTenant",
",",
"String",
"scope",
",",
"final",
"ApiCallback",
"<",
"Void",
">",
"callback",
")",
"throws",
"ApiException",
"{",
"ProgressResponseBody",
".",
"ProgressListener",
"progressListener",
"=",
"null",
";",
"ProgressRequestBody",
".",
"ProgressRequestListener",
"progressRequestListener",
"=",
"null",
";",
"if",
"(",
"callback",
"!=",
"null",
")",
"{",
"progressListener",
"=",
"new",
"ProgressResponseBody",
".",
"ProgressListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"update",
"(",
"long",
"bytesRead",
",",
"long",
"contentLength",
",",
"boolean",
"done",
")",
"{",
"callback",
".",
"onDownloadProgress",
"(",
"bytesRead",
",",
"contentLength",
",",
"done",
")",
";",
"}",
"}",
";",
"progressRequestListener",
"=",
"new",
"ProgressRequestBody",
".",
"ProgressRequestListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onRequestProgress",
"(",
"long",
"bytesWritten",
",",
"long",
"contentLength",
",",
"boolean",
"done",
")",
"{",
"callback",
".",
"onUploadProgress",
"(",
"bytesWritten",
",",
"contentLength",
",",
"done",
")",
";",
"}",
"}",
";",
"}",
"com",
".",
"squareup",
".",
"okhttp",
".",
"Call",
"call",
"=",
"authorizeValidateBeforeCall",
"(",
"clientId",
",",
"redirectUri",
",",
"responseType",
",",
"authorization",
",",
"hideTenant",
",",
"scope",
",",
"progressListener",
",",
"progressRequestListener",
")",
";",
"apiClient",
".",
"executeAsync",
"(",
"call",
",",
"callback",
")",
";",
"return",
"call",
";",
"}"
] |
Perform authorization (asynchronously)
Perform authorization based on the code grant type &mdash; either Authorization Code Grant or Implicit Grant. For more information, see [Authorization Endpoint](https://tools.ietf.org/html/rfc6749#section-3.1). **Note:** For the optional **scope** parameter, the Authentication API supports only the `*` value.
@param clientId The ID of the application or service that is registered as the client. You'll need to get this value from your PureEngage Cloud representative. (required)
@param redirectUri The URI that you want users to be redirected to after entering valid credentials during an Implicit or Authorization Code grant. The Authentication API includes this as part of the URI it returns in the 'Location' header. (required)
@param responseType The response type to let the Authentication API know which grant flow you're using. Possible values are `code` for Authorization Code Grant or `token` for Implicit Grant. For more information about this parameter, see [Response Type](https://tools.ietf.org/html/rfc6749#section-3.1.1). (required)
@param authorization Basic authorization. For example: 'Authorization: Basic Y3...MQ==' (optional)
@param hideTenant Hide the **tenant** field in the UI for Authorization Code Grant. (optional, default to false)
@param scope The scope of the access request. The Authentication API supports only the `*` value. (optional)
@param callback The callback to be executed when the API call finishes
@return The request call
@throws ApiException If fail to process the API call, e.g. serializing the request body object
|
[
"Perform",
"authorization",
"(",
"asynchronously",
")",
"Perform",
"authorization",
"based",
"on",
"the",
"code",
"grant",
"type",
"&",
";",
"mdash",
";",
"either",
"Authorization",
"Code",
"Grant",
"or",
"Implicit",
"Grant",
".",
"For",
"more",
"information",
"see",
"[",
"Authorization",
"Endpoint",
"]",
"(",
"https",
":",
"//",
"tools",
".",
"ietf",
".",
"org",
"/",
"html",
"/",
"rfc6749#section",
"-",
"3",
".",
"1",
")",
".",
"**",
"Note",
":",
"**",
"For",
"the",
"optional",
"**",
"scope",
"**",
"parameter",
"the",
"Authentication",
"API",
"supports",
"only",
"the",
"`",
";",
"*",
"`",
";",
"value",
"."
] |
train
|
https://github.com/GenesysPureEngage/authentication-client-java/blob/eb0d58343ee42ebd3c037163c1137f611dfcbb3a/src/main/java/com/genesys/internal/authentication/api/AuthenticationApi.java#L198-L222
|
ist-dresden/composum
|
sling/core/commons/src/main/java/com/composum/sling/clientlibs/handle/ClientlibLink.java
|
ClientlibLink.getUrl
|
public String getUrl(SlingHttpServletRequest request, RendererContext context) {
"""
Determines the URL we render into the page. We don't want to access resources here, so at least for files we need
already to know the exact path with .min or not.
<p>
Cases: <ul> <li>Clientlib category: refers to the {@link com.composum.sling.clientlibs.servlet.ClientlibCategoryServlet},
parameterized by type and minified according to {@link RendererContext#useMinifiedFiles()}. </li> <li>Clientlib:
path to the client library plus minified and type.</li> <li>File:</li> </ul>
@param request the request
@param context the context
@return the url
"""
String uri;
switch (kind) {
case FILE: // we can only refer to that exact resource.
uri = path;
break;
case CLIENTLIB:
uri = ClientlibServlet.makePath(path, type, context.useMinifiedFiles(), hash);
break;
case CATEGORY:
uri = ClientlibCategoryServlet.makePath(path, type, context.useMinifiedFiles(), hash);
break;
case EXTERNALURI:
uri = path;
break;
default:
throw new UnsupportedOperationException("Bug - impossible.");
}
String url;
if (context.mapClientlibURLs()) {
url = LinkUtil.getUrl(request, uri);
} else {
url = LinkUtil.getUnmappedUrl(request, uri);
}
return url;
}
|
java
|
public String getUrl(SlingHttpServletRequest request, RendererContext context) {
String uri;
switch (kind) {
case FILE: // we can only refer to that exact resource.
uri = path;
break;
case CLIENTLIB:
uri = ClientlibServlet.makePath(path, type, context.useMinifiedFiles(), hash);
break;
case CATEGORY:
uri = ClientlibCategoryServlet.makePath(path, type, context.useMinifiedFiles(), hash);
break;
case EXTERNALURI:
uri = path;
break;
default:
throw new UnsupportedOperationException("Bug - impossible.");
}
String url;
if (context.mapClientlibURLs()) {
url = LinkUtil.getUrl(request, uri);
} else {
url = LinkUtil.getUnmappedUrl(request, uri);
}
return url;
}
|
[
"public",
"String",
"getUrl",
"(",
"SlingHttpServletRequest",
"request",
",",
"RendererContext",
"context",
")",
"{",
"String",
"uri",
";",
"switch",
"(",
"kind",
")",
"{",
"case",
"FILE",
":",
"// we can only refer to that exact resource.",
"uri",
"=",
"path",
";",
"break",
";",
"case",
"CLIENTLIB",
":",
"uri",
"=",
"ClientlibServlet",
".",
"makePath",
"(",
"path",
",",
"type",
",",
"context",
".",
"useMinifiedFiles",
"(",
")",
",",
"hash",
")",
";",
"break",
";",
"case",
"CATEGORY",
":",
"uri",
"=",
"ClientlibCategoryServlet",
".",
"makePath",
"(",
"path",
",",
"type",
",",
"context",
".",
"useMinifiedFiles",
"(",
")",
",",
"hash",
")",
";",
"break",
";",
"case",
"EXTERNALURI",
":",
"uri",
"=",
"path",
";",
"break",
";",
"default",
":",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Bug - impossible.\"",
")",
";",
"}",
"String",
"url",
";",
"if",
"(",
"context",
".",
"mapClientlibURLs",
"(",
")",
")",
"{",
"url",
"=",
"LinkUtil",
".",
"getUrl",
"(",
"request",
",",
"uri",
")",
";",
"}",
"else",
"{",
"url",
"=",
"LinkUtil",
".",
"getUnmappedUrl",
"(",
"request",
",",
"uri",
")",
";",
"}",
"return",
"url",
";",
"}"
] |
Determines the URL we render into the page. We don't want to access resources here, so at least for files we need
already to know the exact path with .min or not.
<p>
Cases: <ul> <li>Clientlib category: refers to the {@link com.composum.sling.clientlibs.servlet.ClientlibCategoryServlet},
parameterized by type and minified according to {@link RendererContext#useMinifiedFiles()}. </li> <li>Clientlib:
path to the client library plus minified and type.</li> <li>File:</li> </ul>
@param request the request
@param context the context
@return the url
|
[
"Determines",
"the",
"URL",
"we",
"render",
"into",
"the",
"page",
".",
"We",
"don",
"t",
"want",
"to",
"access",
"resources",
"here",
"so",
"at",
"least",
"for",
"files",
"we",
"need",
"already",
"to",
"know",
"the",
"exact",
"path",
"with",
".",
"min",
"or",
"not",
".",
"<p",
">",
"Cases",
":",
"<ul",
">",
"<li",
">",
"Clientlib",
"category",
":",
"refers",
"to",
"the",
"{",
"@link",
"com",
".",
"composum",
".",
"sling",
".",
"clientlibs",
".",
"servlet",
".",
"ClientlibCategoryServlet",
"}",
"parameterized",
"by",
"type",
"and",
"minified",
"according",
"to",
"{",
"@link",
"RendererContext#useMinifiedFiles",
"()",
"}",
".",
"<",
"/",
"li",
">",
"<li",
">",
"Clientlib",
":",
"path",
"to",
"the",
"client",
"library",
"plus",
"minified",
"and",
"type",
".",
"<",
"/",
"li",
">",
"<li",
">",
"File",
":",
"<",
"/",
"li",
">",
"<",
"/",
"ul",
">"
] |
train
|
https://github.com/ist-dresden/composum/blob/ebc79f559f6022c935240c19102539bdfb1bd1e2/sling/core/commons/src/main/java/com/composum/sling/clientlibs/handle/ClientlibLink.java#L168-L193
|
aws/aws-sdk-java
|
aws-java-sdk-medialive/src/main/java/com/amazonaws/services/medialive/model/Reservation.java
|
Reservation.withTags
|
public Reservation withTags(java.util.Map<String, String> tags) {
"""
A collection of key-value pairs
@param tags
A collection of key-value pairs
@return Returns a reference to this object so that method calls can be chained together.
"""
setTags(tags);
return this;
}
|
java
|
public Reservation withTags(java.util.Map<String, String> tags) {
setTags(tags);
return this;
}
|
[
"public",
"Reservation",
"withTags",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"tags",
")",
"{",
"setTags",
"(",
"tags",
")",
";",
"return",
"this",
";",
"}"
] |
A collection of key-value pairs
@param tags
A collection of key-value pairs
@return Returns a reference to this object so that method calls can be chained together.
|
[
"A",
"collection",
"of",
"key",
"-",
"value",
"pairs"
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-medialive/src/main/java/com/amazonaws/services/medialive/model/Reservation.java#L690-L693
|
orbisgis/h2gis
|
h2gis-functions/src/main/java/org/h2gis/functions/io/tsv/TSVWrite.java
|
TSVWrite.writeTSV
|
public static void writeTSV(Connection connection, String fileName, String tableReference, String encoding) throws SQLException, IOException {
"""
Export a table into a Tab-separated values file
@param connection
@param fileName
@param tableReference
@param encoding
@throws SQLException
@throws IOException
"""
TSVDriverFunction tSVDriverFunction = new TSVDriverFunction();
tSVDriverFunction.exportTable(connection, tableReference, URIUtilities.fileFromString(fileName), new EmptyProgressVisitor(), encoding);
}
|
java
|
public static void writeTSV(Connection connection, String fileName, String tableReference, String encoding) throws SQLException, IOException {
TSVDriverFunction tSVDriverFunction = new TSVDriverFunction();
tSVDriverFunction.exportTable(connection, tableReference, URIUtilities.fileFromString(fileName), new EmptyProgressVisitor(), encoding);
}
|
[
"public",
"static",
"void",
"writeTSV",
"(",
"Connection",
"connection",
",",
"String",
"fileName",
",",
"String",
"tableReference",
",",
"String",
"encoding",
")",
"throws",
"SQLException",
",",
"IOException",
"{",
"TSVDriverFunction",
"tSVDriverFunction",
"=",
"new",
"TSVDriverFunction",
"(",
")",
";",
"tSVDriverFunction",
".",
"exportTable",
"(",
"connection",
",",
"tableReference",
",",
"URIUtilities",
".",
"fileFromString",
"(",
"fileName",
")",
",",
"new",
"EmptyProgressVisitor",
"(",
")",
",",
"encoding",
")",
";",
"}"
] |
Export a table into a Tab-separated values file
@param connection
@param fileName
@param tableReference
@param encoding
@throws SQLException
@throws IOException
|
[
"Export",
"a",
"table",
"into",
"a",
"Tab",
"-",
"separated",
"values",
"file"
] |
train
|
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/tsv/TSVWrite.java#L71-L74
|
wnameless/rubycollect4j
|
src/main/java/net/sf/rubycollect4j/RubyObject.java
|
RubyObject.send
|
public static <E> E send(Object o, String methodName, Integer arg) {
"""
Executes a method of any Object by Java reflection.
@param o
an Object
@param methodName
name of the method
@param arg
an Integer
@return the result of the method called
"""
return send(o, methodName, (Object) arg);
}
|
java
|
public static <E> E send(Object o, String methodName, Integer arg) {
return send(o, methodName, (Object) arg);
}
|
[
"public",
"static",
"<",
"E",
">",
"E",
"send",
"(",
"Object",
"o",
",",
"String",
"methodName",
",",
"Integer",
"arg",
")",
"{",
"return",
"send",
"(",
"o",
",",
"methodName",
",",
"(",
"Object",
")",
"arg",
")",
";",
"}"
] |
Executes a method of any Object by Java reflection.
@param o
an Object
@param methodName
name of the method
@param arg
an Integer
@return the result of the method called
|
[
"Executes",
"a",
"method",
"of",
"any",
"Object",
"by",
"Java",
"reflection",
"."
] |
train
|
https://github.com/wnameless/rubycollect4j/blob/b8b8d8eccaca2254a3d09b91745882fb7a0d5add/src/main/java/net/sf/rubycollect4j/RubyObject.java#L183-L185
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/webapp/StartupServletContextListener.java
|
StartupServletContextListener.dispatchInitializationEvent
|
private void dispatchInitializationEvent(ServletContextEvent event, int operation) {
"""
the central initialisation event dispatcher which calls
our listeners
@param event
@param operation
"""
if (operation == FACES_INIT_PHASE_PREINIT)
{
if (!loadFacesInitPluginsJDK6())
{
loadFacesInitPluginsJDK5();
}
}
List<StartupListener> pluginEntries = (List<StartupListener>) _servletContext.getAttribute(FACES_INIT_PLUGINS);
if (pluginEntries == null)
{
return;
}
//now we process the plugins
for (StartupListener initializer : pluginEntries)
{
log.info("Processing plugin");
//for now the initializers have to be stateless to
//so that we do not have to enforce that the initializer
//must be serializable
switch (operation)
{
case FACES_INIT_PHASE_PREINIT:
initializer.preInit(event);
break;
case FACES_INIT_PHASE_POSTINIT:
initializer.postInit(event);
break;
case FACES_INIT_PHASE_PREDESTROY:
initializer.preDestroy(event);
break;
default:
initializer.postDestroy(event);
break;
}
}
log.info("Processing MyFaces plugins done");
}
|
java
|
private void dispatchInitializationEvent(ServletContextEvent event, int operation)
{
if (operation == FACES_INIT_PHASE_PREINIT)
{
if (!loadFacesInitPluginsJDK6())
{
loadFacesInitPluginsJDK5();
}
}
List<StartupListener> pluginEntries = (List<StartupListener>) _servletContext.getAttribute(FACES_INIT_PLUGINS);
if (pluginEntries == null)
{
return;
}
//now we process the plugins
for (StartupListener initializer : pluginEntries)
{
log.info("Processing plugin");
//for now the initializers have to be stateless to
//so that we do not have to enforce that the initializer
//must be serializable
switch (operation)
{
case FACES_INIT_PHASE_PREINIT:
initializer.preInit(event);
break;
case FACES_INIT_PHASE_POSTINIT:
initializer.postInit(event);
break;
case FACES_INIT_PHASE_PREDESTROY:
initializer.preDestroy(event);
break;
default:
initializer.postDestroy(event);
break;
}
}
log.info("Processing MyFaces plugins done");
}
|
[
"private",
"void",
"dispatchInitializationEvent",
"(",
"ServletContextEvent",
"event",
",",
"int",
"operation",
")",
"{",
"if",
"(",
"operation",
"==",
"FACES_INIT_PHASE_PREINIT",
")",
"{",
"if",
"(",
"!",
"loadFacesInitPluginsJDK6",
"(",
")",
")",
"{",
"loadFacesInitPluginsJDK5",
"(",
")",
";",
"}",
"}",
"List",
"<",
"StartupListener",
">",
"pluginEntries",
"=",
"(",
"List",
"<",
"StartupListener",
">",
")",
"_servletContext",
".",
"getAttribute",
"(",
"FACES_INIT_PLUGINS",
")",
";",
"if",
"(",
"pluginEntries",
"==",
"null",
")",
"{",
"return",
";",
"}",
"//now we process the plugins",
"for",
"(",
"StartupListener",
"initializer",
":",
"pluginEntries",
")",
"{",
"log",
".",
"info",
"(",
"\"Processing plugin\"",
")",
";",
"//for now the initializers have to be stateless to",
"//so that we do not have to enforce that the initializer",
"//must be serializable",
"switch",
"(",
"operation",
")",
"{",
"case",
"FACES_INIT_PHASE_PREINIT",
":",
"initializer",
".",
"preInit",
"(",
"event",
")",
";",
"break",
";",
"case",
"FACES_INIT_PHASE_POSTINIT",
":",
"initializer",
".",
"postInit",
"(",
"event",
")",
";",
"break",
";",
"case",
"FACES_INIT_PHASE_PREDESTROY",
":",
"initializer",
".",
"preDestroy",
"(",
"event",
")",
";",
"break",
";",
"default",
":",
"initializer",
".",
"postDestroy",
"(",
"event",
")",
";",
"break",
";",
"}",
"}",
"log",
".",
"info",
"(",
"\"Processing MyFaces plugins done\"",
")",
";",
"}"
] |
the central initialisation event dispatcher which calls
our listeners
@param event
@param operation
|
[
"the",
"central",
"initialisation",
"event",
"dispatcher",
"which",
"calls",
"our",
"listeners"
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/webapp/StartupServletContextListener.java#L300-L342
|
Drivemode/TypefaceHelper
|
TypefaceHelper/src/main/java/com/drivemode/android/typeface/TypefaceHelper.java
|
TypefaceHelper.supportSetTypeface
|
public <F extends android.support.v4.app.Fragment> void supportSetTypeface(F fragment, String typefaceName) {
"""
Set the typeface to the all text views belong to the fragment.
Make sure to call this method after fragment view creation.
And this is a support package fragments only.
@param fragment the fragment.
@param typefaceName typeface name.
"""
supportSetTypeface(fragment, typefaceName, 0);
}
|
java
|
public <F extends android.support.v4.app.Fragment> void supportSetTypeface(F fragment, String typefaceName) {
supportSetTypeface(fragment, typefaceName, 0);
}
|
[
"public",
"<",
"F",
"extends",
"android",
".",
"support",
".",
"v4",
".",
"app",
".",
"Fragment",
">",
"void",
"supportSetTypeface",
"(",
"F",
"fragment",
",",
"String",
"typefaceName",
")",
"{",
"supportSetTypeface",
"(",
"fragment",
",",
"typefaceName",
",",
"0",
")",
";",
"}"
] |
Set the typeface to the all text views belong to the fragment.
Make sure to call this method after fragment view creation.
And this is a support package fragments only.
@param fragment the fragment.
@param typefaceName typeface name.
|
[
"Set",
"the",
"typeface",
"to",
"the",
"all",
"text",
"views",
"belong",
"to",
"the",
"fragment",
".",
"Make",
"sure",
"to",
"call",
"this",
"method",
"after",
"fragment",
"view",
"creation",
".",
"And",
"this",
"is",
"a",
"support",
"package",
"fragments",
"only",
"."
] |
train
|
https://github.com/Drivemode/TypefaceHelper/blob/86bef9ce16b9626b7076559e846db1b9f043c008/TypefaceHelper/src/main/java/com/drivemode/android/typeface/TypefaceHelper.java#L417-L419
|
xvik/generics-resolver
|
src/main/java/ru/vyarus/java/generics/resolver/error/UnknownGenericException.java
|
UnknownGenericException.rethrowWithType
|
public UnknownGenericException rethrowWithType(final Class<?> type) {
"""
Throw more specific exception.
@param type context type
@return new exception if type is different, same exception instance if type is the same
"""
final boolean sameType = contextType != null && contextType.equals(type);
if (!sameType && contextType != null) {
// not allow changing type if it's already set
throw new IllegalStateException("Context type can't be changed");
}
return sameType ? this : new UnknownGenericException(type, genericName, genericSource, this);
}
|
java
|
public UnknownGenericException rethrowWithType(final Class<?> type) {
final boolean sameType = contextType != null && contextType.equals(type);
if (!sameType && contextType != null) {
// not allow changing type if it's already set
throw new IllegalStateException("Context type can't be changed");
}
return sameType ? this : new UnknownGenericException(type, genericName, genericSource, this);
}
|
[
"public",
"UnknownGenericException",
"rethrowWithType",
"(",
"final",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"final",
"boolean",
"sameType",
"=",
"contextType",
"!=",
"null",
"&&",
"contextType",
".",
"equals",
"(",
"type",
")",
";",
"if",
"(",
"!",
"sameType",
"&&",
"contextType",
"!=",
"null",
")",
"{",
"// not allow changing type if it's already set",
"throw",
"new",
"IllegalStateException",
"(",
"\"Context type can't be changed\"",
")",
";",
"}",
"return",
"sameType",
"?",
"this",
":",
"new",
"UnknownGenericException",
"(",
"type",
",",
"genericName",
",",
"genericSource",
",",
"this",
")",
";",
"}"
] |
Throw more specific exception.
@param type context type
@return new exception if type is different, same exception instance if type is the same
|
[
"Throw",
"more",
"specific",
"exception",
"."
] |
train
|
https://github.com/xvik/generics-resolver/blob/d7d9d2783265df1178230e8f0b7cb6d853b67a7b/src/main/java/ru/vyarus/java/generics/resolver/error/UnknownGenericException.java#L75-L82
|
Stratio/stratio-connector-commons
|
connector-commons/src/main/java/com/stratio/connector/commons/engine/CommonsMetadataEngine.java
|
CommonsMetadataEngine.createTable
|
@Override
public final void createTable(ClusterName targetCluster, TableMetadata tableMetadata) throws UnsupportedException,
ExecutionException {
"""
This method creates a table.
@param targetCluster the target cluster where the table will be created.
@param tableMetadata the table metadata.
@throws UnsupportedException if an operation is not supported.
@throws ExecutionException if an error happens.
"""
try {
connectionHandler.startJob(targetCluster.getName());
if (logger.isDebugEnabled()) {
logger.debug("Creating table [" + tableMetadata.getName().getName() + "] in cluster [" + targetCluster
.getName() + "]");
}
createTable(tableMetadata, connectionHandler.getConnection(targetCluster.getName()));
if (logger.isDebugEnabled()) {
logger.debug(
"Catalog [" + tableMetadata.getName().getName() + "] has been created successfully in cluster ["
+ targetCluster.getName() + "]");
}
} finally {
connectionHandler.endJob(targetCluster.getName());
}
}
|
java
|
@Override
public final void createTable(ClusterName targetCluster, TableMetadata tableMetadata) throws UnsupportedException,
ExecutionException {
try {
connectionHandler.startJob(targetCluster.getName());
if (logger.isDebugEnabled()) {
logger.debug("Creating table [" + tableMetadata.getName().getName() + "] in cluster [" + targetCluster
.getName() + "]");
}
createTable(tableMetadata, connectionHandler.getConnection(targetCluster.getName()));
if (logger.isDebugEnabled()) {
logger.debug(
"Catalog [" + tableMetadata.getName().getName() + "] has been created successfully in cluster ["
+ targetCluster.getName() + "]");
}
} finally {
connectionHandler.endJob(targetCluster.getName());
}
}
|
[
"@",
"Override",
"public",
"final",
"void",
"createTable",
"(",
"ClusterName",
"targetCluster",
",",
"TableMetadata",
"tableMetadata",
")",
"throws",
"UnsupportedException",
",",
"ExecutionException",
"{",
"try",
"{",
"connectionHandler",
".",
"startJob",
"(",
"targetCluster",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Creating table [\"",
"+",
"tableMetadata",
".",
"getName",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\"] in cluster [\"",
"+",
"targetCluster",
".",
"getName",
"(",
")",
"+",
"\"]\"",
")",
";",
"}",
"createTable",
"(",
"tableMetadata",
",",
"connectionHandler",
".",
"getConnection",
"(",
"targetCluster",
".",
"getName",
"(",
")",
")",
")",
";",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Catalog [\"",
"+",
"tableMetadata",
".",
"getName",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\"] has been created successfully in cluster [\"",
"+",
"targetCluster",
".",
"getName",
"(",
")",
"+",
"\"]\"",
")",
";",
"}",
"}",
"finally",
"{",
"connectionHandler",
".",
"endJob",
"(",
"targetCluster",
".",
"getName",
"(",
")",
")",
";",
"}",
"}"
] |
This method creates a table.
@param targetCluster the target cluster where the table will be created.
@param tableMetadata the table metadata.
@throws UnsupportedException if an operation is not supported.
@throws ExecutionException if an error happens.
|
[
"This",
"method",
"creates",
"a",
"table",
"."
] |
train
|
https://github.com/Stratio/stratio-connector-commons/blob/d7cc66cb9591344a13055962e87a91f01c3707d1/connector-commons/src/main/java/com/stratio/connector/commons/engine/CommonsMetadataEngine.java#L109-L132
|
aNNiMON/Lightweight-Stream-API
|
stream/src/main/java/com/annimon/stream/Stream.java
|
Stream.mapToDouble
|
@NotNull
public DoubleStream mapToDouble(@NotNull final ToDoubleFunction<? super T> mapper) {
"""
Returns {@code DoubleStream} with elements that obtained by applying the given function.
<p>This is an intermediate operation.
@param mapper the mapper function used to apply to each element
@return the new {@code DoubleStream}
@since 1.1.4
@see #map(com.annimon.stream.function.Function)
"""
return new DoubleStream(params, new ObjMapToDouble<T>(iterator, mapper));
}
|
java
|
@NotNull
public DoubleStream mapToDouble(@NotNull final ToDoubleFunction<? super T> mapper) {
return new DoubleStream(params, new ObjMapToDouble<T>(iterator, mapper));
}
|
[
"@",
"NotNull",
"public",
"DoubleStream",
"mapToDouble",
"(",
"@",
"NotNull",
"final",
"ToDoubleFunction",
"<",
"?",
"super",
"T",
">",
"mapper",
")",
"{",
"return",
"new",
"DoubleStream",
"(",
"params",
",",
"new",
"ObjMapToDouble",
"<",
"T",
">",
"(",
"iterator",
",",
"mapper",
")",
")",
";",
"}"
] |
Returns {@code DoubleStream} with elements that obtained by applying the given function.
<p>This is an intermediate operation.
@param mapper the mapper function used to apply to each element
@return the new {@code DoubleStream}
@since 1.1.4
@see #map(com.annimon.stream.function.Function)
|
[
"Returns",
"{",
"@code",
"DoubleStream",
"}",
"with",
"elements",
"that",
"obtained",
"by",
"applying",
"the",
"given",
"function",
"."
] |
train
|
https://github.com/aNNiMON/Lightweight-Stream-API/blob/f29fd57208c20252a4549b084d55ed082c3e58f0/stream/src/main/java/com/annimon/stream/Stream.java#L841-L844
|
airbnb/lottie-android
|
lottie/src/main/java/com/airbnb/lottie/LottieCompositionFactory.java
|
LottieCompositionFactory.fromUrl
|
public static LottieTask<LottieComposition> fromUrl(final Context context, final String url) {
"""
Fetch an animation from an http url. Once it is downloaded once, Lottie will cache the file to disk for
future use. Because of this, you may call `fromUrl` ahead of time to warm the cache if you think you
might need an animation in the future.
"""
String urlCacheKey = "url_" + url;
return cache(urlCacheKey, new Callable<LottieResult<LottieComposition>>() {
@Override public LottieResult<LottieComposition> call() {
return NetworkFetcher.fetchSync(context, url);
}
});
}
|
java
|
public static LottieTask<LottieComposition> fromUrl(final Context context, final String url) {
String urlCacheKey = "url_" + url;
return cache(urlCacheKey, new Callable<LottieResult<LottieComposition>>() {
@Override public LottieResult<LottieComposition> call() {
return NetworkFetcher.fetchSync(context, url);
}
});
}
|
[
"public",
"static",
"LottieTask",
"<",
"LottieComposition",
">",
"fromUrl",
"(",
"final",
"Context",
"context",
",",
"final",
"String",
"url",
")",
"{",
"String",
"urlCacheKey",
"=",
"\"url_\"",
"+",
"url",
";",
"return",
"cache",
"(",
"urlCacheKey",
",",
"new",
"Callable",
"<",
"LottieResult",
"<",
"LottieComposition",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"LottieResult",
"<",
"LottieComposition",
">",
"call",
"(",
")",
"{",
"return",
"NetworkFetcher",
".",
"fetchSync",
"(",
"context",
",",
"url",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Fetch an animation from an http url. Once it is downloaded once, Lottie will cache the file to disk for
future use. Because of this, you may call `fromUrl` ahead of time to warm the cache if you think you
might need an animation in the future.
|
[
"Fetch",
"an",
"animation",
"from",
"an",
"http",
"url",
".",
"Once",
"it",
"is",
"downloaded",
"once",
"Lottie",
"will",
"cache",
"the",
"file",
"to",
"disk",
"for",
"future",
"use",
".",
"Because",
"of",
"this",
"you",
"may",
"call",
"fromUrl",
"ahead",
"of",
"time",
"to",
"warm",
"the",
"cache",
"if",
"you",
"think",
"you",
"might",
"need",
"an",
"animation",
"in",
"the",
"future",
"."
] |
train
|
https://github.com/airbnb/lottie-android/blob/126dabdc9f586c87822f85fe1128cdad439d30fa/lottie/src/main/java/com/airbnb/lottie/LottieCompositionFactory.java#L63-L70
|
apache/groovy
|
subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/PositionConfigureUtils.java
|
PositionConfigureUtils.configureAST
|
public static <T extends ASTNode> T configureAST(T astNode, GroovyParser.GroovyParserRuleContext ctx) {
"""
Sets location(lineNumber, colNumber, lastLineNumber, lastColumnNumber) for node using standard context information.
Note: this method is implemented to be closed over ASTNode. It returns same node as it received in arguments.
@param astNode Node to be modified.
@param ctx Context from which information is obtained.
@return Modified astNode.
"""
Token start = ctx.getStart();
Token stop = ctx.getStop();
astNode.setLineNumber(start.getLine());
astNode.setColumnNumber(start.getCharPositionInLine() + 1);
configureEndPosition(astNode, stop);
return astNode;
}
|
java
|
public static <T extends ASTNode> T configureAST(T astNode, GroovyParser.GroovyParserRuleContext ctx) {
Token start = ctx.getStart();
Token stop = ctx.getStop();
astNode.setLineNumber(start.getLine());
astNode.setColumnNumber(start.getCharPositionInLine() + 1);
configureEndPosition(astNode, stop);
return astNode;
}
|
[
"public",
"static",
"<",
"T",
"extends",
"ASTNode",
">",
"T",
"configureAST",
"(",
"T",
"astNode",
",",
"GroovyParser",
".",
"GroovyParserRuleContext",
"ctx",
")",
"{",
"Token",
"start",
"=",
"ctx",
".",
"getStart",
"(",
")",
";",
"Token",
"stop",
"=",
"ctx",
".",
"getStop",
"(",
")",
";",
"astNode",
".",
"setLineNumber",
"(",
"start",
".",
"getLine",
"(",
")",
")",
";",
"astNode",
".",
"setColumnNumber",
"(",
"start",
".",
"getCharPositionInLine",
"(",
")",
"+",
"1",
")",
";",
"configureEndPosition",
"(",
"astNode",
",",
"stop",
")",
";",
"return",
"astNode",
";",
"}"
] |
Sets location(lineNumber, colNumber, lastLineNumber, lastColumnNumber) for node using standard context information.
Note: this method is implemented to be closed over ASTNode. It returns same node as it received in arguments.
@param astNode Node to be modified.
@param ctx Context from which information is obtained.
@return Modified astNode.
|
[
"Sets",
"location",
"(",
"lineNumber",
"colNumber",
"lastLineNumber",
"lastColumnNumber",
")",
"for",
"node",
"using",
"standard",
"context",
"information",
".",
"Note",
":",
"this",
"method",
"is",
"implemented",
"to",
"be",
"closed",
"over",
"ASTNode",
".",
"It",
"returns",
"same",
"node",
"as",
"it",
"received",
"in",
"arguments",
"."
] |
train
|
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/PositionConfigureUtils.java#L42-L52
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/execution/utils/ResponderTask.java
|
ResponderTask.chainResponder
|
private ResponderTask chainResponder(final Responder responder, final ResultHandler resultHandler) {
"""
Set up a chained ResponderTask, where the new instance will use the same input/output streams and buffers.
However they must both be invoked individually, use {@link #createSequence(Responder,
ResponderTask.ResultHandler)} to set up a sequential invocation of
another responder.
"""
return new ResponderTask(responder, reader, outputStream, resultHandler, partialLineBuffer);
}
|
java
|
private ResponderTask chainResponder(final Responder responder, final ResultHandler resultHandler) {
return new ResponderTask(responder, reader, outputStream, resultHandler, partialLineBuffer);
}
|
[
"private",
"ResponderTask",
"chainResponder",
"(",
"final",
"Responder",
"responder",
",",
"final",
"ResultHandler",
"resultHandler",
")",
"{",
"return",
"new",
"ResponderTask",
"(",
"responder",
",",
"reader",
",",
"outputStream",
",",
"resultHandler",
",",
"partialLineBuffer",
")",
";",
"}"
] |
Set up a chained ResponderTask, where the new instance will use the same input/output streams and buffers.
However they must both be invoked individually, use {@link #createSequence(Responder,
ResponderTask.ResultHandler)} to set up a sequential invocation of
another responder.
|
[
"Set",
"up",
"a",
"chained",
"ResponderTask",
"where",
"the",
"new",
"instance",
"will",
"use",
"the",
"same",
"input",
"/",
"output",
"streams",
"and",
"buffers",
".",
"However",
"they",
"must",
"both",
"be",
"invoked",
"individually",
"use",
"{"
] |
train
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/execution/utils/ResponderTask.java#L217-L219
|
Azure/azure-sdk-for-java
|
keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java
|
KeyVaultClientBaseImpl.deleteStorageAccountAsync
|
public ServiceFuture<DeletedStorageBundle> deleteStorageAccountAsync(String vaultBaseUrl, String storageAccountName, final ServiceCallback<DeletedStorageBundle> serviceCallback) {
"""
Deletes a storage account. This operation requires the storage/delete permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param storageAccountName The name of the storage account.
@param serviceCallback the async ServiceCallback to handle successful and failed responses.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceFuture} object
"""
return ServiceFuture.fromResponse(deleteStorageAccountWithServiceResponseAsync(vaultBaseUrl, storageAccountName), serviceCallback);
}
|
java
|
public ServiceFuture<DeletedStorageBundle> deleteStorageAccountAsync(String vaultBaseUrl, String storageAccountName, final ServiceCallback<DeletedStorageBundle> serviceCallback) {
return ServiceFuture.fromResponse(deleteStorageAccountWithServiceResponseAsync(vaultBaseUrl, storageAccountName), serviceCallback);
}
|
[
"public",
"ServiceFuture",
"<",
"DeletedStorageBundle",
">",
"deleteStorageAccountAsync",
"(",
"String",
"vaultBaseUrl",
",",
"String",
"storageAccountName",
",",
"final",
"ServiceCallback",
"<",
"DeletedStorageBundle",
">",
"serviceCallback",
")",
"{",
"return",
"ServiceFuture",
".",
"fromResponse",
"(",
"deleteStorageAccountWithServiceResponseAsync",
"(",
"vaultBaseUrl",
",",
"storageAccountName",
")",
",",
"serviceCallback",
")",
";",
"}"
] |
Deletes a storage account. This operation requires the storage/delete permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param storageAccountName The name of the storage account.
@param serviceCallback the async ServiceCallback to handle successful and failed responses.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceFuture} object
|
[
"Deletes",
"a",
"storage",
"account",
".",
"This",
"operation",
"requires",
"the",
"storage",
"/",
"delete",
"permission",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java#L9710-L9712
|
microfocus-idol/java-content-parameter-api
|
src/main/java/com/hp/autonomy/aci/content/fieldtext/AbstractFieldText.java
|
AbstractFieldText.WHEN
|
@Override
public FieldText WHEN(final int depth, final FieldText fieldText) {
"""
Appends another fieldtext expression onto the end of this expression using the WHEN<i>n</i> operator. The
returned {@link FieldText} object is equivalent to:
<pre>(this) WHEN<i>n</i> (fieldText)</pre>
@param depth The <i>n</i> in WHEN<i>n</i>
@param fieldText A fieldtext expression or specifier.
@return The combined expression.
"""
return new FieldTextBuilder(this).WHEN(depth, fieldText);
}
|
java
|
@Override
public FieldText WHEN(final int depth, final FieldText fieldText) {
return new FieldTextBuilder(this).WHEN(depth, fieldText);
}
|
[
"@",
"Override",
"public",
"FieldText",
"WHEN",
"(",
"final",
"int",
"depth",
",",
"final",
"FieldText",
"fieldText",
")",
"{",
"return",
"new",
"FieldTextBuilder",
"(",
"this",
")",
".",
"WHEN",
"(",
"depth",
",",
"fieldText",
")",
";",
"}"
] |
Appends another fieldtext expression onto the end of this expression using the WHEN<i>n</i> operator. The
returned {@link FieldText} object is equivalent to:
<pre>(this) WHEN<i>n</i> (fieldText)</pre>
@param depth The <i>n</i> in WHEN<i>n</i>
@param fieldText A fieldtext expression or specifier.
@return The combined expression.
|
[
"Appends",
"another",
"fieldtext",
"expression",
"onto",
"the",
"end",
"of",
"this",
"expression",
"using",
"the",
"WHEN<i",
">",
"n<",
"/",
"i",
">",
"operator",
".",
"The",
"returned",
"{",
"@link",
"FieldText",
"}",
"object",
"is",
"equivalent",
"to",
":"
] |
train
|
https://github.com/microfocus-idol/java-content-parameter-api/blob/8d33dc633f8df2a470a571ac7694e423e7004ad0/src/main/java/com/hp/autonomy/aci/content/fieldtext/AbstractFieldText.java#L98-L101
|
BorderTech/wcomponents
|
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WTemplateRenderer.java
|
WTemplateRenderer.doRender
|
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
"""
Paints the given WTemplate.
@param component the WTemplate to paint.
@param renderContext the RenderContext to paint to.
"""
WTemplate template = (WTemplate) component;
// Setup the context
Map<String, Object> context = new HashMap<>();
// Make the component available under the "wc" key.
context.put("wc", template);
// Load the parameters
context.putAll(template.getParameters());
// Get template renderer for the engine
String engine = template.getEngineName();
if (Util.empty(engine)) {
engine = ConfigurationProperties.getDefaultRenderingEngine();
}
TemplateRenderer templateRenderer = TemplateRendererFactory.newInstance(engine);
// Render
if (!Util.empty(template.getTemplateName())) {
// Render the template
templateRenderer.renderTemplate(template.getTemplateName(), context, template.getTaggedComponents(), renderContext.getWriter(),
template.getEngineOptions());
} else if (!Util.empty(template.getInlineTemplate())) {
// Render inline
templateRenderer.renderInline(template.getInlineTemplate(), context, template.getTaggedComponents(), renderContext.getWriter(),
template.getEngineOptions());
}
}
|
java
|
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WTemplate template = (WTemplate) component;
// Setup the context
Map<String, Object> context = new HashMap<>();
// Make the component available under the "wc" key.
context.put("wc", template);
// Load the parameters
context.putAll(template.getParameters());
// Get template renderer for the engine
String engine = template.getEngineName();
if (Util.empty(engine)) {
engine = ConfigurationProperties.getDefaultRenderingEngine();
}
TemplateRenderer templateRenderer = TemplateRendererFactory.newInstance(engine);
// Render
if (!Util.empty(template.getTemplateName())) {
// Render the template
templateRenderer.renderTemplate(template.getTemplateName(), context, template.getTaggedComponents(), renderContext.getWriter(),
template.getEngineOptions());
} else if (!Util.empty(template.getInlineTemplate())) {
// Render inline
templateRenderer.renderInline(template.getInlineTemplate(), context, template.getTaggedComponents(), renderContext.getWriter(),
template.getEngineOptions());
}
}
|
[
"@",
"Override",
"public",
"void",
"doRender",
"(",
"final",
"WComponent",
"component",
",",
"final",
"WebXmlRenderContext",
"renderContext",
")",
"{",
"WTemplate",
"template",
"=",
"(",
"WTemplate",
")",
"component",
";",
"// Setup the context",
"Map",
"<",
"String",
",",
"Object",
">",
"context",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"// Make the component available under the \"wc\" key.",
"context",
".",
"put",
"(",
"\"wc\"",
",",
"template",
")",
";",
"// Load the parameters",
"context",
".",
"putAll",
"(",
"template",
".",
"getParameters",
"(",
")",
")",
";",
"// Get template renderer for the engine",
"String",
"engine",
"=",
"template",
".",
"getEngineName",
"(",
")",
";",
"if",
"(",
"Util",
".",
"empty",
"(",
"engine",
")",
")",
"{",
"engine",
"=",
"ConfigurationProperties",
".",
"getDefaultRenderingEngine",
"(",
")",
";",
"}",
"TemplateRenderer",
"templateRenderer",
"=",
"TemplateRendererFactory",
".",
"newInstance",
"(",
"engine",
")",
";",
"// Render",
"if",
"(",
"!",
"Util",
".",
"empty",
"(",
"template",
".",
"getTemplateName",
"(",
")",
")",
")",
"{",
"// Render the template",
"templateRenderer",
".",
"renderTemplate",
"(",
"template",
".",
"getTemplateName",
"(",
")",
",",
"context",
",",
"template",
".",
"getTaggedComponents",
"(",
")",
",",
"renderContext",
".",
"getWriter",
"(",
")",
",",
"template",
".",
"getEngineOptions",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"!",
"Util",
".",
"empty",
"(",
"template",
".",
"getInlineTemplate",
"(",
")",
")",
")",
"{",
"// Render inline",
"templateRenderer",
".",
"renderInline",
"(",
"template",
".",
"getInlineTemplate",
"(",
")",
",",
"context",
",",
"template",
".",
"getTaggedComponents",
"(",
")",
",",
"renderContext",
".",
"getWriter",
"(",
")",
",",
"template",
".",
"getEngineOptions",
"(",
")",
")",
";",
"}",
"}"
] |
Paints the given WTemplate.
@param component the WTemplate to paint.
@param renderContext the RenderContext to paint to.
|
[
"Paints",
"the",
"given",
"WTemplate",
"."
] |
train
|
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WTemplateRenderer.java#L28-L56
|
Hygieia/Hygieia
|
collectors/misc/score/src/main/java/com/capitalone/dashboard/widget/QualityWidgetScore.java
|
QualityWidgetScore.processQualityViolationsScore
|
private void processQualityViolationsScore(
QualityScoreSettings.ViolationsScoreSettings qualityViolationsSettings,
Iterable<CodeQuality> codeQualityIterable,
List<ScoreWeight> categoryScores) {
"""
Calculate Violations score based on Blocker, Critical & Major violations
@param qualityViolationsSettings Violations Param Settings
@param codeQualityIterable Quality values
@param categoryScores List of category scores
"""
ScoreWeight qualityViolationsScore = getCategoryScoreByIdName(categoryScores, WIDGET_QUALITY_VIOLATIONS_ID_NAME);
Double qualityBlockerRatio = fetchQualityValue(codeQualityIterable, QUALITY_PARAM_BLOCKER_VIOLATIONS);
Double qualityCriticalRatio = fetchQualityValue(codeQualityIterable, QUALITY_PARAM_CRITICAL_VIOLATIONS);
Double qualityMajorRatio = fetchQualityValue(codeQualityIterable, QUALITY_PARAM_MAJOR_VIOLATIONS);
if (null == qualityBlockerRatio && null == qualityCriticalRatio && null == qualityMajorRatio) {
qualityViolationsScore.setScore(
qualityViolationsSettings.getCriteria().getNoDataFound()
);
qualityViolationsScore.setMessage(Constants.SCORE_ERROR_NO_DATA_FOUND);
qualityViolationsScore.setState(ScoreWeight.ProcessingState.criteria_failed);
} else {
try {
//Violation score is calculated based on weight for each type
// Blocker
// Critical
// Major
Double violationScore = Double.valueOf(Constants.MAX_SCORE) - (
getViolationScore(qualityBlockerRatio, qualityViolationsSettings.getBlockerViolationsWeight()) +
getViolationScore(qualityCriticalRatio, qualityViolationsSettings.getCriticalViolationsWeight()) +
getViolationScore(qualityMajorRatio, qualityViolationsSettings.getMajorViolationWeight())
);
if (!qualityViolationsSettings.isAllowNegative() && violationScore.compareTo(Constants.ZERO_SCORE) < 0) {
violationScore = Constants.ZERO_SCORE;
}
//Check thresholds at widget level
checkPercentThresholds(qualityViolationsSettings, violationScore);
qualityViolationsScore.setScore(
new ScoreTypeValue(violationScore)
);
qualityViolationsScore.setState(ScoreWeight.ProcessingState.complete);
} catch (ThresholdException ex) {
setThresholdFailureWeight(ex, qualityViolationsScore);
}
}
}
|
java
|
private void processQualityViolationsScore(
QualityScoreSettings.ViolationsScoreSettings qualityViolationsSettings,
Iterable<CodeQuality> codeQualityIterable,
List<ScoreWeight> categoryScores) {
ScoreWeight qualityViolationsScore = getCategoryScoreByIdName(categoryScores, WIDGET_QUALITY_VIOLATIONS_ID_NAME);
Double qualityBlockerRatio = fetchQualityValue(codeQualityIterable, QUALITY_PARAM_BLOCKER_VIOLATIONS);
Double qualityCriticalRatio = fetchQualityValue(codeQualityIterable, QUALITY_PARAM_CRITICAL_VIOLATIONS);
Double qualityMajorRatio = fetchQualityValue(codeQualityIterable, QUALITY_PARAM_MAJOR_VIOLATIONS);
if (null == qualityBlockerRatio && null == qualityCriticalRatio && null == qualityMajorRatio) {
qualityViolationsScore.setScore(
qualityViolationsSettings.getCriteria().getNoDataFound()
);
qualityViolationsScore.setMessage(Constants.SCORE_ERROR_NO_DATA_FOUND);
qualityViolationsScore.setState(ScoreWeight.ProcessingState.criteria_failed);
} else {
try {
//Violation score is calculated based on weight for each type
// Blocker
// Critical
// Major
Double violationScore = Double.valueOf(Constants.MAX_SCORE) - (
getViolationScore(qualityBlockerRatio, qualityViolationsSettings.getBlockerViolationsWeight()) +
getViolationScore(qualityCriticalRatio, qualityViolationsSettings.getCriticalViolationsWeight()) +
getViolationScore(qualityMajorRatio, qualityViolationsSettings.getMajorViolationWeight())
);
if (!qualityViolationsSettings.isAllowNegative() && violationScore.compareTo(Constants.ZERO_SCORE) < 0) {
violationScore = Constants.ZERO_SCORE;
}
//Check thresholds at widget level
checkPercentThresholds(qualityViolationsSettings, violationScore);
qualityViolationsScore.setScore(
new ScoreTypeValue(violationScore)
);
qualityViolationsScore.setState(ScoreWeight.ProcessingState.complete);
} catch (ThresholdException ex) {
setThresholdFailureWeight(ex, qualityViolationsScore);
}
}
}
|
[
"private",
"void",
"processQualityViolationsScore",
"(",
"QualityScoreSettings",
".",
"ViolationsScoreSettings",
"qualityViolationsSettings",
",",
"Iterable",
"<",
"CodeQuality",
">",
"codeQualityIterable",
",",
"List",
"<",
"ScoreWeight",
">",
"categoryScores",
")",
"{",
"ScoreWeight",
"qualityViolationsScore",
"=",
"getCategoryScoreByIdName",
"(",
"categoryScores",
",",
"WIDGET_QUALITY_VIOLATIONS_ID_NAME",
")",
";",
"Double",
"qualityBlockerRatio",
"=",
"fetchQualityValue",
"(",
"codeQualityIterable",
",",
"QUALITY_PARAM_BLOCKER_VIOLATIONS",
")",
";",
"Double",
"qualityCriticalRatio",
"=",
"fetchQualityValue",
"(",
"codeQualityIterable",
",",
"QUALITY_PARAM_CRITICAL_VIOLATIONS",
")",
";",
"Double",
"qualityMajorRatio",
"=",
"fetchQualityValue",
"(",
"codeQualityIterable",
",",
"QUALITY_PARAM_MAJOR_VIOLATIONS",
")",
";",
"if",
"(",
"null",
"==",
"qualityBlockerRatio",
"&&",
"null",
"==",
"qualityCriticalRatio",
"&&",
"null",
"==",
"qualityMajorRatio",
")",
"{",
"qualityViolationsScore",
".",
"setScore",
"(",
"qualityViolationsSettings",
".",
"getCriteria",
"(",
")",
".",
"getNoDataFound",
"(",
")",
")",
";",
"qualityViolationsScore",
".",
"setMessage",
"(",
"Constants",
".",
"SCORE_ERROR_NO_DATA_FOUND",
")",
";",
"qualityViolationsScore",
".",
"setState",
"(",
"ScoreWeight",
".",
"ProcessingState",
".",
"criteria_failed",
")",
";",
"}",
"else",
"{",
"try",
"{",
"//Violation score is calculated based on weight for each type",
"// Blocker",
"// Critical",
"// Major",
"Double",
"violationScore",
"=",
"Double",
".",
"valueOf",
"(",
"Constants",
".",
"MAX_SCORE",
")",
"-",
"(",
"getViolationScore",
"(",
"qualityBlockerRatio",
",",
"qualityViolationsSettings",
".",
"getBlockerViolationsWeight",
"(",
")",
")",
"+",
"getViolationScore",
"(",
"qualityCriticalRatio",
",",
"qualityViolationsSettings",
".",
"getCriticalViolationsWeight",
"(",
")",
")",
"+",
"getViolationScore",
"(",
"qualityMajorRatio",
",",
"qualityViolationsSettings",
".",
"getMajorViolationWeight",
"(",
")",
")",
")",
";",
"if",
"(",
"!",
"qualityViolationsSettings",
".",
"isAllowNegative",
"(",
")",
"&&",
"violationScore",
".",
"compareTo",
"(",
"Constants",
".",
"ZERO_SCORE",
")",
"<",
"0",
")",
"{",
"violationScore",
"=",
"Constants",
".",
"ZERO_SCORE",
";",
"}",
"//Check thresholds at widget level",
"checkPercentThresholds",
"(",
"qualityViolationsSettings",
",",
"violationScore",
")",
";",
"qualityViolationsScore",
".",
"setScore",
"(",
"new",
"ScoreTypeValue",
"(",
"violationScore",
")",
")",
";",
"qualityViolationsScore",
".",
"setState",
"(",
"ScoreWeight",
".",
"ProcessingState",
".",
"complete",
")",
";",
"}",
"catch",
"(",
"ThresholdException",
"ex",
")",
"{",
"setThresholdFailureWeight",
"(",
"ex",
",",
"qualityViolationsScore",
")",
";",
"}",
"}",
"}"
] |
Calculate Violations score based on Blocker, Critical & Major violations
@param qualityViolationsSettings Violations Param Settings
@param codeQualityIterable Quality values
@param categoryScores List of category scores
|
[
"Calculate",
"Violations",
"score",
"based",
"on",
"Blocker",
"Critical",
"&",
"Major",
"violations"
] |
train
|
https://github.com/Hygieia/Hygieia/blob/d8b67a590da2744acf59bcd99d9b34ef1bb84890/collectors/misc/score/src/main/java/com/capitalone/dashboard/widget/QualityWidgetScore.java#L219-L260
|
jmeetsma/Iglu-Common
|
src/main/java/org/ijsberg/iglu/util/xml/Node.java
|
Node.setAttribute
|
public void setAttribute(String key, String value) {
"""
Sets a name-value pair that appears as attribute in the opening tag
@param key
@param value
"""
/* if (!attributes.containsKey(key))
{
sortedAttributes.add(key);
}*/
if (nodeAttributes == null) {
nodeAttributes = new Properties();
}
nodeAttributes.setProperty(key, value);
}
|
java
|
public void setAttribute(String key, String value) {
/* if (!attributes.containsKey(key))
{
sortedAttributes.add(key);
}*/
if (nodeAttributes == null) {
nodeAttributes = new Properties();
}
nodeAttributes.setProperty(key, value);
}
|
[
"public",
"void",
"setAttribute",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"/*\t\tif (!attributes.containsKey(key))\r\n\t\t{\r\n\t\t\tsortedAttributes.add(key);\r\n\t\t}*/",
"if",
"(",
"nodeAttributes",
"==",
"null",
")",
"{",
"nodeAttributes",
"=",
"new",
"Properties",
"(",
")",
";",
"}",
"nodeAttributes",
".",
"setProperty",
"(",
"key",
",",
"value",
")",
";",
"}"
] |
Sets a name-value pair that appears as attribute in the opening tag
@param key
@param value
|
[
"Sets",
"a",
"name",
"-",
"value",
"pair",
"that",
"appears",
"as",
"attribute",
"in",
"the",
"opening",
"tag"
] |
train
|
https://github.com/jmeetsma/Iglu-Common/blob/0fb0885775b576209ff1b5a0f67e3c25a99a6420/src/main/java/org/ijsberg/iglu/util/xml/Node.java#L179-L188
|
thymeleaf/thymeleaf-spring
|
thymeleaf-spring5/src/main/java/org/thymeleaf/spring5/view/reactive/ThymeleafReactiveViewResolver.java
|
ThymeleafReactiveViewResolver.setRedirectViewProvider
|
public void setRedirectViewProvider(final Function<String, RedirectView> redirectViewProvider) {
"""
<p>
Sets the provider function for creating {@link RedirectView} instances when a redirect
request is passed to the view resolver.
</p>
<p>
Note the parameter specified to the function will be the {@code URL} of the redirect
(as specified in the view name returned by the controller, without the {@code redirect:}
prefix).
</p>
@param redirectViewProvider the redirect-view provider function.
"""
Validate.notNull(redirectViewProvider, "RedirectView provider cannot be null");
this.redirectViewProvider = redirectViewProvider;
}
|
java
|
public void setRedirectViewProvider(final Function<String, RedirectView> redirectViewProvider) {
Validate.notNull(redirectViewProvider, "RedirectView provider cannot be null");
this.redirectViewProvider = redirectViewProvider;
}
|
[
"public",
"void",
"setRedirectViewProvider",
"(",
"final",
"Function",
"<",
"String",
",",
"RedirectView",
">",
"redirectViewProvider",
")",
"{",
"Validate",
".",
"notNull",
"(",
"redirectViewProvider",
",",
"\"RedirectView provider cannot be null\"",
")",
";",
"this",
".",
"redirectViewProvider",
"=",
"redirectViewProvider",
";",
"}"
] |
<p>
Sets the provider function for creating {@link RedirectView} instances when a redirect
request is passed to the view resolver.
</p>
<p>
Note the parameter specified to the function will be the {@code URL} of the redirect
(as specified in the view name returned by the controller, without the {@code redirect:}
prefix).
</p>
@param redirectViewProvider the redirect-view provider function.
|
[
"<p",
">",
"Sets",
"the",
"provider",
"function",
"for",
"creating",
"{",
"@link",
"RedirectView",
"}",
"instances",
"when",
"a",
"redirect",
"request",
"is",
"passed",
"to",
"the",
"view",
"resolver",
".",
"<",
"/",
"p",
">",
"<p",
">",
"Note",
"the",
"parameter",
"specified",
"to",
"the",
"function",
"will",
"be",
"the",
"{",
"@code",
"URL",
"}",
"of",
"the",
"redirect",
"(",
"as",
"specified",
"in",
"the",
"view",
"name",
"returned",
"by",
"the",
"controller",
"without",
"the",
"{",
"@code",
"redirect",
":",
"}",
"prefix",
")",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/thymeleaf/thymeleaf-spring/blob/9aa15a19017a0938e57646e3deefb8a90ab78dcb/thymeleaf-spring5/src/main/java/org/thymeleaf/spring5/view/reactive/ThymeleafReactiveViewResolver.java#L389-L392
|
moparisthebest/beehive
|
beehive-netui-tags/src/main/java/org/apache/beehive/netui/tags/javascript/ScriptContainer.java
|
ScriptContainer.addTagIdMappings
|
public void addTagIdMappings(String tagId, String realId, String realName) {
"""
This will add the mapping between the tagId and the real name to the NameMap hashmap.
@param tagId
@param realId
@param realName
"""
assert (tagId != null) : "The parameter 'tagId' must not be null";
assert (realId != null) : "The parameter 'realId' must not be null";
_writeId = true;
if (realName != null) {
if (_idToNameMap == null)
_idToNameMap = new HashMap/*<String, String>*/();
_idToNameMap.put(tagId, realName);
}
}
|
java
|
public void addTagIdMappings(String tagId, String realId, String realName)
{
assert (tagId != null) : "The parameter 'tagId' must not be null";
assert (realId != null) : "The parameter 'realId' must not be null";
_writeId = true;
if (realName != null) {
if (_idToNameMap == null)
_idToNameMap = new HashMap/*<String, String>*/();
_idToNameMap.put(tagId, realName);
}
}
|
[
"public",
"void",
"addTagIdMappings",
"(",
"String",
"tagId",
",",
"String",
"realId",
",",
"String",
"realName",
")",
"{",
"assert",
"(",
"tagId",
"!=",
"null",
")",
":",
"\"The parameter 'tagId' must not be null\"",
";",
"assert",
"(",
"realId",
"!=",
"null",
")",
":",
"\"The parameter 'realId' must not be null\"",
";",
"_writeId",
"=",
"true",
";",
"if",
"(",
"realName",
"!=",
"null",
")",
"{",
"if",
"(",
"_idToNameMap",
"==",
"null",
")",
"_idToNameMap",
"=",
"new",
"HashMap",
"/*<String, String>*/",
"(",
")",
";",
"_idToNameMap",
".",
"put",
"(",
"tagId",
",",
"realName",
")",
";",
"}",
"}"
] |
This will add the mapping between the tagId and the real name to the NameMap hashmap.
@param tagId
@param realId
@param realName
|
[
"This",
"will",
"add",
"the",
"mapping",
"between",
"the",
"tagId",
"and",
"the",
"real",
"name",
"to",
"the",
"NameMap",
"hashmap",
"."
] |
train
|
https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-tags/src/main/java/org/apache/beehive/netui/tags/javascript/ScriptContainer.java#L161-L173
|
ironjacamar/ironjacamar
|
codegenerator/src/main/java/org/ironjacamar/codegenerator/code/CfInterfaceCodeGen.java
|
CfInterfaceCodeGen.writeClassBody
|
@Override
public void writeClassBody(Definition def, Writer out) throws IOException {
"""
Output class code
@param def definition
@param out Writer
@throws IOException ioException
"""
out.write("public interface " + getClassName(def) + " extends Serializable, Referenceable");
writeLeftCurlyBracket(out, 0);
int indent = 1;
writeConnection(def, out, indent);
writeRightCurlyBracket(out, 0);
}
|
java
|
@Override
public void writeClassBody(Definition def, Writer out) throws IOException
{
out.write("public interface " + getClassName(def) + " extends Serializable, Referenceable");
writeLeftCurlyBracket(out, 0);
int indent = 1;
writeConnection(def, out, indent);
writeRightCurlyBracket(out, 0);
}
|
[
"@",
"Override",
"public",
"void",
"writeClassBody",
"(",
"Definition",
"def",
",",
"Writer",
"out",
")",
"throws",
"IOException",
"{",
"out",
".",
"write",
"(",
"\"public interface \"",
"+",
"getClassName",
"(",
"def",
")",
"+",
"\" extends Serializable, Referenceable\"",
")",
";",
"writeLeftCurlyBracket",
"(",
"out",
",",
"0",
")",
";",
"int",
"indent",
"=",
"1",
";",
"writeConnection",
"(",
"def",
",",
"out",
",",
"indent",
")",
";",
"writeRightCurlyBracket",
"(",
"out",
",",
"0",
")",
";",
"}"
] |
Output class code
@param def definition
@param out Writer
@throws IOException ioException
|
[
"Output",
"class",
"code"
] |
train
|
https://github.com/ironjacamar/ironjacamar/blob/f0389ee7e62aa8b40ba09b251edad76d220ea796/codegenerator/src/main/java/org/ironjacamar/codegenerator/code/CfInterfaceCodeGen.java#L43-L53
|
Azure/azure-sdk-for-java
|
policyinsights/resource-manager/v2018_04_04/src/main/java/com/microsoft/azure/management/policyinsights/v2018_04_04/implementation/PolicyEventsInner.java
|
PolicyEventsInner.listQueryResultsForSubscriptionLevelPolicyAssignment
|
public PolicyEventsQueryResultsInner listQueryResultsForSubscriptionLevelPolicyAssignment(String subscriptionId, String policyAssignmentName, QueryOptions queryOptions) {
"""
Queries policy events for the subscription level policy assignment.
@param subscriptionId Microsoft Azure subscription ID.
@param policyAssignmentName Policy assignment name.
@param queryOptions Additional parameters for the operation
@throws IllegalArgumentException thrown if parameters fail the validation
@throws QueryFailureException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the PolicyEventsQueryResultsInner object if successful.
"""
return listQueryResultsForSubscriptionLevelPolicyAssignmentWithServiceResponseAsync(subscriptionId, policyAssignmentName, queryOptions).toBlocking().single().body();
}
|
java
|
public PolicyEventsQueryResultsInner listQueryResultsForSubscriptionLevelPolicyAssignment(String subscriptionId, String policyAssignmentName, QueryOptions queryOptions) {
return listQueryResultsForSubscriptionLevelPolicyAssignmentWithServiceResponseAsync(subscriptionId, policyAssignmentName, queryOptions).toBlocking().single().body();
}
|
[
"public",
"PolicyEventsQueryResultsInner",
"listQueryResultsForSubscriptionLevelPolicyAssignment",
"(",
"String",
"subscriptionId",
",",
"String",
"policyAssignmentName",
",",
"QueryOptions",
"queryOptions",
")",
"{",
"return",
"listQueryResultsForSubscriptionLevelPolicyAssignmentWithServiceResponseAsync",
"(",
"subscriptionId",
",",
"policyAssignmentName",
",",
"queryOptions",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] |
Queries policy events for the subscription level policy assignment.
@param subscriptionId Microsoft Azure subscription ID.
@param policyAssignmentName Policy assignment name.
@param queryOptions Additional parameters for the operation
@throws IllegalArgumentException thrown if parameters fail the validation
@throws QueryFailureException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the PolicyEventsQueryResultsInner object if successful.
|
[
"Queries",
"policy",
"events",
"for",
"the",
"subscription",
"level",
"policy",
"assignment",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/policyinsights/resource-manager/v2018_04_04/src/main/java/com/microsoft/azure/management/policyinsights/v2018_04_04/implementation/PolicyEventsInner.java#L1369-L1371
|
jbundle/jbundle
|
base/screen/model/src/main/java/org/jbundle/base/screen/model/BasePanel.java
|
BasePanel.makeWindow
|
public static BasePanel makeWindow(App application) {
"""
Make a screen window to put a screen in.
<br/>NOTE: This method returns the AppletScreen NOT the FrameScreen,
because the AppletScreen is where you add your controls!
"""
FrameScreen frameScreen = new FrameScreen(null, null, null, ScreenConstants.DONT_DISPLAY_FIELD_DESC, null);
AppletScreen appletScreen = new AppletScreen(null, frameScreen, null, ScreenConstants.DONT_DISPLAY_FIELD_DESC, null);
appletScreen.setupDefaultTask((Application)application);
return appletScreen;
}
|
java
|
public static BasePanel makeWindow(App application)
{
FrameScreen frameScreen = new FrameScreen(null, null, null, ScreenConstants.DONT_DISPLAY_FIELD_DESC, null);
AppletScreen appletScreen = new AppletScreen(null, frameScreen, null, ScreenConstants.DONT_DISPLAY_FIELD_DESC, null);
appletScreen.setupDefaultTask((Application)application);
return appletScreen;
}
|
[
"public",
"static",
"BasePanel",
"makeWindow",
"(",
"App",
"application",
")",
"{",
"FrameScreen",
"frameScreen",
"=",
"new",
"FrameScreen",
"(",
"null",
",",
"null",
",",
"null",
",",
"ScreenConstants",
".",
"DONT_DISPLAY_FIELD_DESC",
",",
"null",
")",
";",
"AppletScreen",
"appletScreen",
"=",
"new",
"AppletScreen",
"(",
"null",
",",
"frameScreen",
",",
"null",
",",
"ScreenConstants",
".",
"DONT_DISPLAY_FIELD_DESC",
",",
"null",
")",
";",
"appletScreen",
".",
"setupDefaultTask",
"(",
"(",
"Application",
")",
"application",
")",
";",
"return",
"appletScreen",
";",
"}"
] |
Make a screen window to put a screen in.
<br/>NOTE: This method returns the AppletScreen NOT the FrameScreen,
because the AppletScreen is where you add your controls!
|
[
"Make",
"a",
"screen",
"window",
"to",
"put",
"a",
"screen",
"in",
".",
"<br",
"/",
">",
"NOTE",
":",
"This",
"method",
"returns",
"the",
"AppletScreen",
"NOT",
"the",
"FrameScreen",
"because",
"the",
"AppletScreen",
"is",
"where",
"you",
"add",
"your",
"controls!"
] |
train
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/model/src/main/java/org/jbundle/base/screen/model/BasePanel.java#L706-L714
|
landawn/AbacusUtil
|
src/com/landawn/abacus/util/Sheet.java
|
Sheet.replaceIf
|
public <X extends Exception> void replaceIf(final Try.TriPredicate<R, C, E, X> predicate, final E newValue) throws X {
"""
Replace elements by <code>Predicate.test(i, j)</code> based on points
@param predicate
@param newValue
"""
checkFrozen();
if (rowLength() > 0 && columnLength() > 0) {
this.init();
final int rowLength = rowLength();
int columnIndex = 0;
R rowKey = null;
C columnKey = null;
E val = null;
for (List<E> column : _columnList) {
columnKey = _columnKeyIndexMap.getByValue(columnIndex);
for (int rowIndex = 0; rowIndex < rowLength; rowIndex++) {
rowKey = _rowKeyIndexMap.getByValue(rowIndex);
val = column.get(rowIndex);
if (predicate.test(rowKey, columnKey, val)) {
column.set(rowIndex, newValue);
}
}
columnIndex++;
}
}
}
|
java
|
public <X extends Exception> void replaceIf(final Try.TriPredicate<R, C, E, X> predicate, final E newValue) throws X {
checkFrozen();
if (rowLength() > 0 && columnLength() > 0) {
this.init();
final int rowLength = rowLength();
int columnIndex = 0;
R rowKey = null;
C columnKey = null;
E val = null;
for (List<E> column : _columnList) {
columnKey = _columnKeyIndexMap.getByValue(columnIndex);
for (int rowIndex = 0; rowIndex < rowLength; rowIndex++) {
rowKey = _rowKeyIndexMap.getByValue(rowIndex);
val = column.get(rowIndex);
if (predicate.test(rowKey, columnKey, val)) {
column.set(rowIndex, newValue);
}
}
columnIndex++;
}
}
}
|
[
"public",
"<",
"X",
"extends",
"Exception",
">",
"void",
"replaceIf",
"(",
"final",
"Try",
".",
"TriPredicate",
"<",
"R",
",",
"C",
",",
"E",
",",
"X",
">",
"predicate",
",",
"final",
"E",
"newValue",
")",
"throws",
"X",
"{",
"checkFrozen",
"(",
")",
";",
"if",
"(",
"rowLength",
"(",
")",
">",
"0",
"&&",
"columnLength",
"(",
")",
">",
"0",
")",
"{",
"this",
".",
"init",
"(",
")",
";",
"final",
"int",
"rowLength",
"=",
"rowLength",
"(",
")",
";",
"int",
"columnIndex",
"=",
"0",
";",
"R",
"rowKey",
"=",
"null",
";",
"C",
"columnKey",
"=",
"null",
";",
"E",
"val",
"=",
"null",
";",
"for",
"(",
"List",
"<",
"E",
">",
"column",
":",
"_columnList",
")",
"{",
"columnKey",
"=",
"_columnKeyIndexMap",
".",
"getByValue",
"(",
"columnIndex",
")",
";",
"for",
"(",
"int",
"rowIndex",
"=",
"0",
";",
"rowIndex",
"<",
"rowLength",
";",
"rowIndex",
"++",
")",
"{",
"rowKey",
"=",
"_rowKeyIndexMap",
".",
"getByValue",
"(",
"rowIndex",
")",
";",
"val",
"=",
"column",
".",
"get",
"(",
"rowIndex",
")",
";",
"if",
"(",
"predicate",
".",
"test",
"(",
"rowKey",
",",
"columnKey",
",",
"val",
")",
")",
"{",
"column",
".",
"set",
"(",
"rowIndex",
",",
"newValue",
")",
";",
"}",
"}",
"columnIndex",
"++",
";",
"}",
"}",
"}"
] |
Replace elements by <code>Predicate.test(i, j)</code> based on points
@param predicate
@param newValue
|
[
"Replace",
"elements",
"by",
"<code",
">",
"Predicate",
".",
"test",
"(",
"i",
"j",
")",
"<",
"/",
"code",
">",
"based",
"on",
"points"
] |
train
|
https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/util/Sheet.java#L1074-L1101
|
apache/incubator-gobblin
|
gobblin-utility/src/main/java/org/apache/gobblin/util/HadoopUtils.java
|
HadoopUtils.unsafeRenameIfNotExists
|
public static boolean unsafeRenameIfNotExists(FileSystem fs, Path from, Path to) throws IOException {
"""
Renames from to to if to doesn't exist in a non-thread-safe way.
@param fs filesystem where rename will be executed.
@param from origin {@link Path}.
@param to target {@link Path}.
@return true if rename succeeded, false if the target already exists.
@throws IOException if rename failed for reasons other than target exists.
"""
if (!fs.exists(to)) {
if (!fs.exists(to.getParent())) {
fs.mkdirs(to.getParent());
}
if (!renamePathHandleLocalFSRace(fs, from, to)) {
if (!fs.exists(to)) {
throw new IOException(String.format("Failed to rename %s to %s.", from, to));
}
return false;
}
return true;
}
return false;
}
|
java
|
public static boolean unsafeRenameIfNotExists(FileSystem fs, Path from, Path to) throws IOException {
if (!fs.exists(to)) {
if (!fs.exists(to.getParent())) {
fs.mkdirs(to.getParent());
}
if (!renamePathHandleLocalFSRace(fs, from, to)) {
if (!fs.exists(to)) {
throw new IOException(String.format("Failed to rename %s to %s.", from, to));
}
return false;
}
return true;
}
return false;
}
|
[
"public",
"static",
"boolean",
"unsafeRenameIfNotExists",
"(",
"FileSystem",
"fs",
",",
"Path",
"from",
",",
"Path",
"to",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"fs",
".",
"exists",
"(",
"to",
")",
")",
"{",
"if",
"(",
"!",
"fs",
".",
"exists",
"(",
"to",
".",
"getParent",
"(",
")",
")",
")",
"{",
"fs",
".",
"mkdirs",
"(",
"to",
".",
"getParent",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"renamePathHandleLocalFSRace",
"(",
"fs",
",",
"from",
",",
"to",
")",
")",
"{",
"if",
"(",
"!",
"fs",
".",
"exists",
"(",
"to",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"String",
".",
"format",
"(",
"\"Failed to rename %s to %s.\"",
",",
"from",
",",
"to",
")",
")",
";",
"}",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Renames from to to if to doesn't exist in a non-thread-safe way.
@param fs filesystem where rename will be executed.
@param from origin {@link Path}.
@param to target {@link Path}.
@return true if rename succeeded, false if the target already exists.
@throws IOException if rename failed for reasons other than target exists.
|
[
"Renames",
"from",
"to",
"to",
"if",
"to",
"doesn",
"t",
"exist",
"in",
"a",
"non",
"-",
"thread",
"-",
"safe",
"way",
"."
] |
train
|
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/HadoopUtils.java#L648-L664
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-dedicatedserver/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedserver.java
|
ApiOvhDedicatedserver.serviceName_networkInterfaceController_mac_GET
|
public OvhNetworkInterfaceController serviceName_networkInterfaceController_mac_GET(String serviceName, String mac) throws IOException {
"""
Get this object properties
REST: GET /dedicated/server/{serviceName}/networkInterfaceController/{mac}
@param serviceName [required] The internal name of your dedicated server
@param mac [required] NetworkInterfaceController mac
API beta
"""
String qPath = "/dedicated/server/{serviceName}/networkInterfaceController/{mac}";
StringBuilder sb = path(qPath, serviceName, mac);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhNetworkInterfaceController.class);
}
|
java
|
public OvhNetworkInterfaceController serviceName_networkInterfaceController_mac_GET(String serviceName, String mac) throws IOException {
String qPath = "/dedicated/server/{serviceName}/networkInterfaceController/{mac}";
StringBuilder sb = path(qPath, serviceName, mac);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhNetworkInterfaceController.class);
}
|
[
"public",
"OvhNetworkInterfaceController",
"serviceName_networkInterfaceController_mac_GET",
"(",
"String",
"serviceName",
",",
"String",
"mac",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/dedicated/server/{serviceName}/networkInterfaceController/{mac}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"mac",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhNetworkInterfaceController",
".",
"class",
")",
";",
"}"
] |
Get this object properties
REST: GET /dedicated/server/{serviceName}/networkInterfaceController/{mac}
@param serviceName [required] The internal name of your dedicated server
@param mac [required] NetworkInterfaceController mac
API beta
|
[
"Get",
"this",
"object",
"properties"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-dedicatedserver/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedserver.java#L466-L471
|
lucee/Lucee
|
core/src/main/java/lucee/transformer/library/function/FunctionLibFactory.java
|
FunctionLibFactory.loadFromDirectory
|
public static FunctionLib[] loadFromDirectory(Resource dir, Identification id) throws FunctionLibException {
"""
Laedt mehrere FunctionLib's die innerhalb eines Verzeichnisses liegen.
@param dir Verzeichnis im dem die FunctionLib's liegen.
@param saxParser Definition des Sax Parser mit dem die FunctionLib's eingelesen werden sollen.
@return FunctionLib's als Array
@throws FunctionLibException
"""
if (!dir.isDirectory()) return new FunctionLib[0];
ArrayList<FunctionLib> arr = new ArrayList<FunctionLib>();
Resource[] files = dir.listResources(new ExtensionResourceFilter(new String[] { "fld", "fldx" }));
for (int i = 0; i < files.length; i++) {
if (files[i].isFile()) arr.add(FunctionLibFactory.loadFromFile(files[i], id));
}
return arr.toArray(new FunctionLib[arr.size()]);
}
|
java
|
public static FunctionLib[] loadFromDirectory(Resource dir, Identification id) throws FunctionLibException {
if (!dir.isDirectory()) return new FunctionLib[0];
ArrayList<FunctionLib> arr = new ArrayList<FunctionLib>();
Resource[] files = dir.listResources(new ExtensionResourceFilter(new String[] { "fld", "fldx" }));
for (int i = 0; i < files.length; i++) {
if (files[i].isFile()) arr.add(FunctionLibFactory.loadFromFile(files[i], id));
}
return arr.toArray(new FunctionLib[arr.size()]);
}
|
[
"public",
"static",
"FunctionLib",
"[",
"]",
"loadFromDirectory",
"(",
"Resource",
"dir",
",",
"Identification",
"id",
")",
"throws",
"FunctionLibException",
"{",
"if",
"(",
"!",
"dir",
".",
"isDirectory",
"(",
")",
")",
"return",
"new",
"FunctionLib",
"[",
"0",
"]",
";",
"ArrayList",
"<",
"FunctionLib",
">",
"arr",
"=",
"new",
"ArrayList",
"<",
"FunctionLib",
">",
"(",
")",
";",
"Resource",
"[",
"]",
"files",
"=",
"dir",
".",
"listResources",
"(",
"new",
"ExtensionResourceFilter",
"(",
"new",
"String",
"[",
"]",
"{",
"\"fld\"",
",",
"\"fldx\"",
"}",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"files",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"files",
"[",
"i",
"]",
".",
"isFile",
"(",
")",
")",
"arr",
".",
"add",
"(",
"FunctionLibFactory",
".",
"loadFromFile",
"(",
"files",
"[",
"i",
"]",
",",
"id",
")",
")",
";",
"}",
"return",
"arr",
".",
"toArray",
"(",
"new",
"FunctionLib",
"[",
"arr",
".",
"size",
"(",
")",
"]",
")",
";",
"}"
] |
Laedt mehrere FunctionLib's die innerhalb eines Verzeichnisses liegen.
@param dir Verzeichnis im dem die FunctionLib's liegen.
@param saxParser Definition des Sax Parser mit dem die FunctionLib's eingelesen werden sollen.
@return FunctionLib's als Array
@throws FunctionLibException
|
[
"Laedt",
"mehrere",
"FunctionLib",
"s",
"die",
"innerhalb",
"eines",
"Verzeichnisses",
"liegen",
"."
] |
train
|
https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/transformer/library/function/FunctionLibFactory.java#L353-L363
|
VoltDB/voltdb
|
src/frontend/org/voltdb/plannodes/WindowFunctionPlanNode.java
|
WindowFunctionPlanNode.loadFromJSONObject
|
@Override
public void loadFromJSONObject(JSONObject jobj, Database db)
throws JSONException {
"""
Deserialize a PartitionByPlanNode from JSON. Since we don't need the
sort directions, and we don't serialize them in toJSONString, then we
can't in general get them here.
"""
helpLoadFromJSONObject(jobj, db);
JSONArray jarray = jobj.getJSONArray( Members.AGGREGATE_COLUMNS.name() );
int size = jarray.length();
for (int i = 0; i < size; i++) {
// We only expect one of these for now.
assert(i == 0);
JSONObject tempObj = jarray.getJSONObject( i );
m_aggregateTypes.add( ExpressionType.get( tempObj.getString( Members.AGGREGATE_TYPE.name() )));
m_aggregateOutputColumns.add( tempObj.getInt( Members.AGGREGATE_OUTPUT_COLUMN.name() ));
m_aggregateExpressions.add(
AbstractExpression.loadFromJSONArrayChild(null,
tempObj,
Members.AGGREGATE_EXPRESSIONS.name(),
null));
}
m_partitionByExpressions
= AbstractExpression.loadFromJSONArrayChild(null,
jobj,
Members.PARTITIONBY_EXPRESSIONS.name(),
null);
m_orderByExpressions = new ArrayList<>();
AbstractExpression.loadSortListFromJSONArray(m_orderByExpressions,
null,
jobj);
}
|
java
|
@Override
public void loadFromJSONObject(JSONObject jobj, Database db)
throws JSONException {
helpLoadFromJSONObject(jobj, db);
JSONArray jarray = jobj.getJSONArray( Members.AGGREGATE_COLUMNS.name() );
int size = jarray.length();
for (int i = 0; i < size; i++) {
// We only expect one of these for now.
assert(i == 0);
JSONObject tempObj = jarray.getJSONObject( i );
m_aggregateTypes.add( ExpressionType.get( tempObj.getString( Members.AGGREGATE_TYPE.name() )));
m_aggregateOutputColumns.add( tempObj.getInt( Members.AGGREGATE_OUTPUT_COLUMN.name() ));
m_aggregateExpressions.add(
AbstractExpression.loadFromJSONArrayChild(null,
tempObj,
Members.AGGREGATE_EXPRESSIONS.name(),
null));
}
m_partitionByExpressions
= AbstractExpression.loadFromJSONArrayChild(null,
jobj,
Members.PARTITIONBY_EXPRESSIONS.name(),
null);
m_orderByExpressions = new ArrayList<>();
AbstractExpression.loadSortListFromJSONArray(m_orderByExpressions,
null,
jobj);
}
|
[
"@",
"Override",
"public",
"void",
"loadFromJSONObject",
"(",
"JSONObject",
"jobj",
",",
"Database",
"db",
")",
"throws",
"JSONException",
"{",
"helpLoadFromJSONObject",
"(",
"jobj",
",",
"db",
")",
";",
"JSONArray",
"jarray",
"=",
"jobj",
".",
"getJSONArray",
"(",
"Members",
".",
"AGGREGATE_COLUMNS",
".",
"name",
"(",
")",
")",
";",
"int",
"size",
"=",
"jarray",
".",
"length",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"// We only expect one of these for now.",
"assert",
"(",
"i",
"==",
"0",
")",
";",
"JSONObject",
"tempObj",
"=",
"jarray",
".",
"getJSONObject",
"(",
"i",
")",
";",
"m_aggregateTypes",
".",
"add",
"(",
"ExpressionType",
".",
"get",
"(",
"tempObj",
".",
"getString",
"(",
"Members",
".",
"AGGREGATE_TYPE",
".",
"name",
"(",
")",
")",
")",
")",
";",
"m_aggregateOutputColumns",
".",
"add",
"(",
"tempObj",
".",
"getInt",
"(",
"Members",
".",
"AGGREGATE_OUTPUT_COLUMN",
".",
"name",
"(",
")",
")",
")",
";",
"m_aggregateExpressions",
".",
"add",
"(",
"AbstractExpression",
".",
"loadFromJSONArrayChild",
"(",
"null",
",",
"tempObj",
",",
"Members",
".",
"AGGREGATE_EXPRESSIONS",
".",
"name",
"(",
")",
",",
"null",
")",
")",
";",
"}",
"m_partitionByExpressions",
"=",
"AbstractExpression",
".",
"loadFromJSONArrayChild",
"(",
"null",
",",
"jobj",
",",
"Members",
".",
"PARTITIONBY_EXPRESSIONS",
".",
"name",
"(",
")",
",",
"null",
")",
";",
"m_orderByExpressions",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"AbstractExpression",
".",
"loadSortListFromJSONArray",
"(",
"m_orderByExpressions",
",",
"null",
",",
"jobj",
")",
";",
"}"
] |
Deserialize a PartitionByPlanNode from JSON. Since we don't need the
sort directions, and we don't serialize them in toJSONString, then we
can't in general get them here.
|
[
"Deserialize",
"a",
"PartitionByPlanNode",
"from",
"JSON",
".",
"Since",
"we",
"don",
"t",
"need",
"the",
"sort",
"directions",
"and",
"we",
"don",
"t",
"serialize",
"them",
"in",
"toJSONString",
"then",
"we",
"can",
"t",
"in",
"general",
"get",
"them",
"here",
"."
] |
train
|
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/plannodes/WindowFunctionPlanNode.java#L153-L180
|
structlogging/structlogger
|
structlogger/src/main/java/com/github/structlogging/utils/MessageFormatterUtils.java
|
MessageFormatterUtils.format
|
public static String format(final String pattern, Object... params) {
"""
based on String pattern, which contains placeholder <code>{}</code>, inserts params into
the pattern and returns resulting String
@param pattern string pattern with placeholders {}
@param params to replace placeholders with
@return String with params inserted into pattern
"""
return MessageFormatter.arrayFormat(pattern, params).getMessage();
}
|
java
|
public static String format(final String pattern, Object... params) {
return MessageFormatter.arrayFormat(pattern, params).getMessage();
}
|
[
"public",
"static",
"String",
"format",
"(",
"final",
"String",
"pattern",
",",
"Object",
"...",
"params",
")",
"{",
"return",
"MessageFormatter",
".",
"arrayFormat",
"(",
"pattern",
",",
"params",
")",
".",
"getMessage",
"(",
")",
";",
"}"
] |
based on String pattern, which contains placeholder <code>{}</code>, inserts params into
the pattern and returns resulting String
@param pattern string pattern with placeholders {}
@param params to replace placeholders with
@return String with params inserted into pattern
|
[
"based",
"on",
"String",
"pattern",
"which",
"contains",
"placeholder",
"<code",
">",
"{}",
"<",
"/",
"code",
">",
"inserts",
"params",
"into",
"the",
"pattern",
"and",
"returns",
"resulting",
"String"
] |
train
|
https://github.com/structlogging/structlogger/blob/1fcca4e962ef53cbdb94bd72cb556de7f5f9469f/structlogger/src/main/java/com/github/structlogging/utils/MessageFormatterUtils.java#L47-L49
|
vatbub/common
|
updater/src/main/java/com/github/vatbub/common/updater/UpdateChecker.java
|
UpdateChecker.isUpdateAvailable
|
public static UpdateInfo isUpdateAvailable(URL repoBaseURL, String mavenGroupID, String mavenArtifactID,
String mavenClassifier) {
"""
Checks if a new release has been published on the website. This does not
compare the current app version to the release version on the website,
just checks if something happened on the website. This ensures that
updates that were ignored by the user do not show up again. Assumes that
the artifact has a jar-packaging.
@param repoBaseURL The base url of the maven repo to use
@param mavenGroupID The maven groupId of the artifact to update
@param mavenArtifactID The maven artifactId of the artifact to update
@param mavenClassifier The maven classifier of the artifact to update
@return {@code true} if a new release is available and the user did not
ignore it.
"""
return isUpdateAvailable(repoBaseURL, mavenGroupID, mavenArtifactID, mavenClassifier, "jar");
}
|
java
|
public static UpdateInfo isUpdateAvailable(URL repoBaseURL, String mavenGroupID, String mavenArtifactID,
String mavenClassifier) {
return isUpdateAvailable(repoBaseURL, mavenGroupID, mavenArtifactID, mavenClassifier, "jar");
}
|
[
"public",
"static",
"UpdateInfo",
"isUpdateAvailable",
"(",
"URL",
"repoBaseURL",
",",
"String",
"mavenGroupID",
",",
"String",
"mavenArtifactID",
",",
"String",
"mavenClassifier",
")",
"{",
"return",
"isUpdateAvailable",
"(",
"repoBaseURL",
",",
"mavenGroupID",
",",
"mavenArtifactID",
",",
"mavenClassifier",
",",
"\"jar\"",
")",
";",
"}"
] |
Checks if a new release has been published on the website. This does not
compare the current app version to the release version on the website,
just checks if something happened on the website. This ensures that
updates that were ignored by the user do not show up again. Assumes that
the artifact has a jar-packaging.
@param repoBaseURL The base url of the maven repo to use
@param mavenGroupID The maven groupId of the artifact to update
@param mavenArtifactID The maven artifactId of the artifact to update
@param mavenClassifier The maven classifier of the artifact to update
@return {@code true} if a new release is available and the user did not
ignore it.
|
[
"Checks",
"if",
"a",
"new",
"release",
"has",
"been",
"published",
"on",
"the",
"website",
".",
"This",
"does",
"not",
"compare",
"the",
"current",
"app",
"version",
"to",
"the",
"release",
"version",
"on",
"the",
"website",
"just",
"checks",
"if",
"something",
"happened",
"on",
"the",
"website",
".",
"This",
"ensures",
"that",
"updates",
"that",
"were",
"ignored",
"by",
"the",
"user",
"do",
"not",
"show",
"up",
"again",
".",
"Assumes",
"that",
"the",
"artifact",
"has",
"a",
"jar",
"-",
"packaging",
"."
] |
train
|
https://github.com/vatbub/common/blob/8b9fd2ece0a23d520ce53b66c84cbd094e378443/updater/src/main/java/com/github/vatbub/common/updater/UpdateChecker.java#L104-L107
|
nyla-solutions/nyla
|
nyla.solutions.core/src/main/java/nyla/solutions/core/util/Scheduler.java
|
Scheduler.toDateAddDaysSetOfWeek
|
public static Date toDateAddDaysSetOfWeek(int days, int dayOfWeek) {
"""
Add days of the year (positive or negative),
then set day of week
@param days the days to add or subtract
@param dayOfWeek the day of week to set
@return the new date time
"""
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_YEAR, days);
return cal.getTime();
}
|
java
|
public static Date toDateAddDaysSetOfWeek(int days, int dayOfWeek)
{
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_YEAR, days);
return cal.getTime();
}
|
[
"public",
"static",
"Date",
"toDateAddDaysSetOfWeek",
"(",
"int",
"days",
",",
"int",
"dayOfWeek",
")",
"{",
"Calendar",
"cal",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"cal",
".",
"add",
"(",
"Calendar",
".",
"DAY_OF_YEAR",
",",
"days",
")",
";",
"return",
"cal",
".",
"getTime",
"(",
")",
";",
"}"
] |
Add days of the year (positive or negative),
then set day of week
@param days the days to add or subtract
@param dayOfWeek the day of week to set
@return the new date time
|
[
"Add",
"days",
"of",
"the",
"year",
"(",
"positive",
"or",
"negative",
")",
"then",
"set",
"day",
"of",
"week"
] |
train
|
https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Scheduler.java#L57-L65
|
kuali/ojb-1.0.4
|
src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldBase.java
|
PersistentFieldBase.getFieldRecursive
|
private Field getFieldRecursive(Class c, String name) throws NoSuchFieldException {
"""
try to find a field in class c, recurse through class hierarchy if necessary
@throws NoSuchFieldException if no Field was found into the class hierarchy
"""
try
{
return c.getDeclaredField(name);
}
catch (NoSuchFieldException e)
{
// if field could not be found in the inheritance hierarchy, signal error
if ((c == Object.class) || (c.getSuperclass() == null) || c.isInterface())
{
throw e;
}
// if field could not be found in class c try in superclass
else
{
return getFieldRecursive(c.getSuperclass(), name);
}
}
}
|
java
|
private Field getFieldRecursive(Class c, String name) throws NoSuchFieldException
{
try
{
return c.getDeclaredField(name);
}
catch (NoSuchFieldException e)
{
// if field could not be found in the inheritance hierarchy, signal error
if ((c == Object.class) || (c.getSuperclass() == null) || c.isInterface())
{
throw e;
}
// if field could not be found in class c try in superclass
else
{
return getFieldRecursive(c.getSuperclass(), name);
}
}
}
|
[
"private",
"Field",
"getFieldRecursive",
"(",
"Class",
"c",
",",
"String",
"name",
")",
"throws",
"NoSuchFieldException",
"{",
"try",
"{",
"return",
"c",
".",
"getDeclaredField",
"(",
"name",
")",
";",
"}",
"catch",
"(",
"NoSuchFieldException",
"e",
")",
"{",
"// if field could not be found in the inheritance hierarchy, signal error\r",
"if",
"(",
"(",
"c",
"==",
"Object",
".",
"class",
")",
"||",
"(",
"c",
".",
"getSuperclass",
"(",
")",
"==",
"null",
")",
"||",
"c",
".",
"isInterface",
"(",
")",
")",
"{",
"throw",
"e",
";",
"}",
"// if field could not be found in class c try in superclass\r",
"else",
"{",
"return",
"getFieldRecursive",
"(",
"c",
".",
"getSuperclass",
"(",
")",
",",
"name",
")",
";",
"}",
"}",
"}"
] |
try to find a field in class c, recurse through class hierarchy if necessary
@throws NoSuchFieldException if no Field was found into the class hierarchy
|
[
"try",
"to",
"find",
"a",
"field",
"in",
"class",
"c",
"recurse",
"through",
"class",
"hierarchy",
"if",
"necessary"
] |
train
|
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldBase.java#L113-L132
|
lucee/Lucee
|
core/src/main/java/lucee/runtime/converter/JSConverter.java
|
JSConverter._serializeMap
|
private String _serializeMap(String name, Map map, StringBuilder sb, Set<Object> done) throws ConverterException {
"""
serialize a Map (as Struct)
@param name
@param map Map to serialize
@param done
@param sb2
@return serialized map
@throws ConverterException
"""
if (useShortcuts) sb.append("{}");
else sb.append("new Object();");
Iterator it = map.keySet().iterator();
while (it.hasNext()) {
Object key = it.next();
String skey = StringUtil.toLowerCase(StringUtil.escapeJS(key.toString(), '"'));
sb.append(name + "[" + skey + "]=");
_serialize(name + "[" + skey + "]", map.get(key), sb, done);
// sb.append(";");
}
return sb.toString();
}
|
java
|
private String _serializeMap(String name, Map map, StringBuilder sb, Set<Object> done) throws ConverterException {
if (useShortcuts) sb.append("{}");
else sb.append("new Object();");
Iterator it = map.keySet().iterator();
while (it.hasNext()) {
Object key = it.next();
String skey = StringUtil.toLowerCase(StringUtil.escapeJS(key.toString(), '"'));
sb.append(name + "[" + skey + "]=");
_serialize(name + "[" + skey + "]", map.get(key), sb, done);
// sb.append(";");
}
return sb.toString();
}
|
[
"private",
"String",
"_serializeMap",
"(",
"String",
"name",
",",
"Map",
"map",
",",
"StringBuilder",
"sb",
",",
"Set",
"<",
"Object",
">",
"done",
")",
"throws",
"ConverterException",
"{",
"if",
"(",
"useShortcuts",
")",
"sb",
".",
"append",
"(",
"\"{}\"",
")",
";",
"else",
"sb",
".",
"append",
"(",
"\"new Object();\"",
")",
";",
"Iterator",
"it",
"=",
"map",
".",
"keySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"Object",
"key",
"=",
"it",
".",
"next",
"(",
")",
";",
"String",
"skey",
"=",
"StringUtil",
".",
"toLowerCase",
"(",
"StringUtil",
".",
"escapeJS",
"(",
"key",
".",
"toString",
"(",
")",
",",
"'",
"'",
")",
")",
";",
"sb",
".",
"append",
"(",
"name",
"+",
"\"[\"",
"+",
"skey",
"+",
"\"]=\"",
")",
";",
"_serialize",
"(",
"name",
"+",
"\"[\"",
"+",
"skey",
"+",
"\"]\"",
",",
"map",
".",
"get",
"(",
"key",
")",
",",
"sb",
",",
"done",
")",
";",
"// sb.append(\";\");",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] |
serialize a Map (as Struct)
@param name
@param map Map to serialize
@param done
@param sb2
@return serialized map
@throws ConverterException
|
[
"serialize",
"a",
"Map",
"(",
"as",
"Struct",
")"
] |
train
|
https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/runtime/converter/JSConverter.java#L244-L257
|
sksamuel/scrimage
|
scrimage-filters/src/main/java/thirdparty/jhlabs/image/ArrayColormap.java
|
ArrayColormap.setColorInterpolated
|
public void setColorInterpolated(int index, int firstIndex, int lastIndex, int color) {
"""
Set the color at "index" to "color". Entries are interpolated linearly from
the existing entries at "firstIndex" and "lastIndex" to the new entry.
firstIndex < index < lastIndex must hold.
@param index the position to set
@param firstIndex the position of the first color from which to interpolate
@param lastIndex the position of the second color from which to interpolate
@param color the color to set
"""
int firstColor = map[firstIndex];
int lastColor = map[lastIndex];
for (int i = firstIndex; i <= index; i++)
map[i] = ImageMath.mixColors((float)(i-firstIndex)/(index-firstIndex), firstColor, color);
for (int i = index; i < lastIndex; i++)
map[i] = ImageMath.mixColors((float)(i-index)/(lastIndex-index), color, lastColor);
}
|
java
|
public void setColorInterpolated(int index, int firstIndex, int lastIndex, int color) {
int firstColor = map[firstIndex];
int lastColor = map[lastIndex];
for (int i = firstIndex; i <= index; i++)
map[i] = ImageMath.mixColors((float)(i-firstIndex)/(index-firstIndex), firstColor, color);
for (int i = index; i < lastIndex; i++)
map[i] = ImageMath.mixColors((float)(i-index)/(lastIndex-index), color, lastColor);
}
|
[
"public",
"void",
"setColorInterpolated",
"(",
"int",
"index",
",",
"int",
"firstIndex",
",",
"int",
"lastIndex",
",",
"int",
"color",
")",
"{",
"int",
"firstColor",
"=",
"map",
"[",
"firstIndex",
"]",
";",
"int",
"lastColor",
"=",
"map",
"[",
"lastIndex",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"firstIndex",
";",
"i",
"<=",
"index",
";",
"i",
"++",
")",
"map",
"[",
"i",
"]",
"=",
"ImageMath",
".",
"mixColors",
"(",
"(",
"float",
")",
"(",
"i",
"-",
"firstIndex",
")",
"/",
"(",
"index",
"-",
"firstIndex",
")",
"",
",",
"firstColor",
",",
"color",
")",
";",
"for",
"(",
"int",
"i",
"=",
"index",
";",
"i",
"<",
"lastIndex",
";",
"i",
"++",
")",
"map",
"[",
"i",
"]",
"=",
"ImageMath",
".",
"mixColors",
"(",
"(",
"float",
")",
"(",
"i",
"-",
"index",
")",
"/",
"(",
"lastIndex",
"-",
"index",
")",
"",
",",
"color",
",",
"lastColor",
")",
";",
"}"
] |
Set the color at "index" to "color". Entries are interpolated linearly from
the existing entries at "firstIndex" and "lastIndex" to the new entry.
firstIndex < index < lastIndex must hold.
@param index the position to set
@param firstIndex the position of the first color from which to interpolate
@param lastIndex the position of the second color from which to interpolate
@param color the color to set
|
[
"Set",
"the",
"color",
"at",
"index",
"to",
"color",
".",
"Entries",
"are",
"interpolated",
"linearly",
"from",
"the",
"existing",
"entries",
"at",
"firstIndex",
"and",
"lastIndex",
"to",
"the",
"new",
"entry",
".",
"firstIndex",
"<",
"index",
"<",
"lastIndex",
"must",
"hold",
"."
] |
train
|
https://github.com/sksamuel/scrimage/blob/52dab448136e6657a71951b0e6b7d5e64dc979ac/scrimage-filters/src/main/java/thirdparty/jhlabs/image/ArrayColormap.java#L107-L114
|
Azure/azure-sdk-for-java
|
mediaservices/resource-manager/v2018_06_01_preview/src/main/java/com/microsoft/azure/management/mediaservices/v2018_06_01_preview/implementation/LiveEventsInner.java
|
LiveEventsInner.beginCreate
|
public LiveEventInner beginCreate(String resourceGroupName, String accountName, String liveEventName, LiveEventInner parameters) {
"""
Create Live Event.
Creates a Live Event.
@param resourceGroupName The name of the resource group within the Azure subscription.
@param accountName The Media Services account name.
@param liveEventName The name of the Live Event.
@param parameters Live Event properties needed for creation.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ApiErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the LiveEventInner object if successful.
"""
return beginCreateWithServiceResponseAsync(resourceGroupName, accountName, liveEventName, parameters).toBlocking().single().body();
}
|
java
|
public LiveEventInner beginCreate(String resourceGroupName, String accountName, String liveEventName, LiveEventInner parameters) {
return beginCreateWithServiceResponseAsync(resourceGroupName, accountName, liveEventName, parameters).toBlocking().single().body();
}
|
[
"public",
"LiveEventInner",
"beginCreate",
"(",
"String",
"resourceGroupName",
",",
"String",
"accountName",
",",
"String",
"liveEventName",
",",
"LiveEventInner",
"parameters",
")",
"{",
"return",
"beginCreateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"accountName",
",",
"liveEventName",
",",
"parameters",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] |
Create Live Event.
Creates a Live Event.
@param resourceGroupName The name of the resource group within the Azure subscription.
@param accountName The Media Services account name.
@param liveEventName The name of the Live Event.
@param parameters Live Event properties needed for creation.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ApiErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the LiveEventInner object if successful.
|
[
"Create",
"Live",
"Event",
".",
"Creates",
"a",
"Live",
"Event",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/mediaservices/resource-manager/v2018_06_01_preview/src/main/java/com/microsoft/azure/management/mediaservices/v2018_06_01_preview/implementation/LiveEventsInner.java#L548-L550
|
carewebframework/carewebframework-core
|
org.carewebframework.shell/src/main/java/org/carewebframework/shell/CareWebShellEx.java
|
CareWebShellEx.registerFromId
|
public ElementBase registerFromId(String path, String id) throws Exception {
"""
Registers the plugin with the specified id and path. If a tree path is absent, the plugin is
associated with the tab itself.
@param path Format is <tab name>\<tree node path>
@param id Unique id of plugin
@return Container created for the plugin.
@throws Exception Unspecified exception.
"""
return registerFromId(path, id, null);
}
|
java
|
public ElementBase registerFromId(String path, String id) throws Exception {
return registerFromId(path, id, null);
}
|
[
"public",
"ElementBase",
"registerFromId",
"(",
"String",
"path",
",",
"String",
"id",
")",
"throws",
"Exception",
"{",
"return",
"registerFromId",
"(",
"path",
",",
"id",
",",
"null",
")",
";",
"}"
] |
Registers the plugin with the specified id and path. If a tree path is absent, the plugin is
associated with the tab itself.
@param path Format is <tab name>\<tree node path>
@param id Unique id of plugin
@return Container created for the plugin.
@throws Exception Unspecified exception.
|
[
"Registers",
"the",
"plugin",
"with",
"the",
"specified",
"id",
"and",
"path",
".",
"If",
"a",
"tree",
"path",
"is",
"absent",
"the",
"plugin",
"is",
"associated",
"with",
"the",
"tab",
"itself",
"."
] |
train
|
https://github.com/carewebframework/carewebframework-core/blob/fa3252d4f7541dbe151b92c3d4f6f91433cd1673/org.carewebframework.shell/src/main/java/org/carewebframework/shell/CareWebShellEx.java#L148-L150
|
facebookarchive/hive-dwrf
|
hive-dwrf-shims/src/main/java/org/apache/hadoop/hive/ql/io/slice/Slice.java
|
Slice.setBytes
|
public void setBytes(int index, byte[] source, int sourceIndex, int length) {
"""
Transfers data from the specified array into this buffer starting at
the specified absolute {@code index}.
@throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0},
if the specified {@code sourceIndex} is less than {@code 0},
if {@code index + length} is greater than
{@code this.length()}, or
if {@code sourceIndex + length} is greater than {@code source.length}
"""
checkPositionIndexes(sourceIndex, sourceIndex + length, source.length);
copyMemory(source, (long) SizeOf.ARRAY_BYTE_BASE_OFFSET + sourceIndex, base, address + index, length);
}
|
java
|
public void setBytes(int index, byte[] source, int sourceIndex, int length)
{
checkPositionIndexes(sourceIndex, sourceIndex + length, source.length);
copyMemory(source, (long) SizeOf.ARRAY_BYTE_BASE_OFFSET + sourceIndex, base, address + index, length);
}
|
[
"public",
"void",
"setBytes",
"(",
"int",
"index",
",",
"byte",
"[",
"]",
"source",
",",
"int",
"sourceIndex",
",",
"int",
"length",
")",
"{",
"checkPositionIndexes",
"(",
"sourceIndex",
",",
"sourceIndex",
"+",
"length",
",",
"source",
".",
"length",
")",
";",
"copyMemory",
"(",
"source",
",",
"(",
"long",
")",
"SizeOf",
".",
"ARRAY_BYTE_BASE_OFFSET",
"+",
"sourceIndex",
",",
"base",
",",
"address",
"+",
"index",
",",
"length",
")",
";",
"}"
] |
Transfers data from the specified array into this buffer starting at
the specified absolute {@code index}.
@throws IndexOutOfBoundsException if the specified {@code index} is less than {@code 0},
if the specified {@code sourceIndex} is less than {@code 0},
if {@code index + length} is greater than
{@code this.length()}, or
if {@code sourceIndex + length} is greater than {@code source.length}
|
[
"Transfers",
"data",
"from",
"the",
"specified",
"array",
"into",
"this",
"buffer",
"starting",
"at",
"the",
"specified",
"absolute",
"{",
"@code",
"index",
"}",
"."
] |
train
|
https://github.com/facebookarchive/hive-dwrf/blob/a7b4fcf28a57e006a2fc041d40cf7e5ad16e6b45/hive-dwrf-shims/src/main/java/org/apache/hadoop/hive/ql/io/slice/Slice.java#L533-L537
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/renderkit/html/HtmlMenuRendererBase.java
|
HtmlMenuRendererBase.encodeEnd
|
public void encodeEnd(FacesContext facesContext, UIComponent component)
throws IOException {
"""
private static final Log log = LogFactory.getLog(HtmlMenuRenderer.class);
"""
RendererUtils.checkParamValidity(facesContext, component, null);
Map<String, List<ClientBehavior>> behaviors = null;
if (component instanceof ClientBehaviorHolder)
{
behaviors = ((ClientBehaviorHolder) component).getClientBehaviors();
if (!behaviors.isEmpty())
{
ResourceUtils.renderDefaultJsfJsInlineIfNecessary(
facesContext, facesContext.getResponseWriter());
}
}
if (component instanceof UISelectMany)
{
renderMenu(facesContext,
(UISelectMany)component,
isDisabled(facesContext, component),
getConverter(facesContext, component));
}
else if (component instanceof UISelectOne)
{
renderMenu(facesContext,
(UISelectOne)component,
isDisabled(facesContext, component),
getConverter(facesContext, component));
}
else
{
throw new IllegalArgumentException("Unsupported component class " + component.getClass().getName());
}
}
|
java
|
public void encodeEnd(FacesContext facesContext, UIComponent component)
throws IOException
{
RendererUtils.checkParamValidity(facesContext, component, null);
Map<String, List<ClientBehavior>> behaviors = null;
if (component instanceof ClientBehaviorHolder)
{
behaviors = ((ClientBehaviorHolder) component).getClientBehaviors();
if (!behaviors.isEmpty())
{
ResourceUtils.renderDefaultJsfJsInlineIfNecessary(
facesContext, facesContext.getResponseWriter());
}
}
if (component instanceof UISelectMany)
{
renderMenu(facesContext,
(UISelectMany)component,
isDisabled(facesContext, component),
getConverter(facesContext, component));
}
else if (component instanceof UISelectOne)
{
renderMenu(facesContext,
(UISelectOne)component,
isDisabled(facesContext, component),
getConverter(facesContext, component));
}
else
{
throw new IllegalArgumentException("Unsupported component class " + component.getClass().getName());
}
}
|
[
"public",
"void",
"encodeEnd",
"(",
"FacesContext",
"facesContext",
",",
"UIComponent",
"component",
")",
"throws",
"IOException",
"{",
"RendererUtils",
".",
"checkParamValidity",
"(",
"facesContext",
",",
"component",
",",
"null",
")",
";",
"Map",
"<",
"String",
",",
"List",
"<",
"ClientBehavior",
">",
">",
"behaviors",
"=",
"null",
";",
"if",
"(",
"component",
"instanceof",
"ClientBehaviorHolder",
")",
"{",
"behaviors",
"=",
"(",
"(",
"ClientBehaviorHolder",
")",
"component",
")",
".",
"getClientBehaviors",
"(",
")",
";",
"if",
"(",
"!",
"behaviors",
".",
"isEmpty",
"(",
")",
")",
"{",
"ResourceUtils",
".",
"renderDefaultJsfJsInlineIfNecessary",
"(",
"facesContext",
",",
"facesContext",
".",
"getResponseWriter",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"component",
"instanceof",
"UISelectMany",
")",
"{",
"renderMenu",
"(",
"facesContext",
",",
"(",
"UISelectMany",
")",
"component",
",",
"isDisabled",
"(",
"facesContext",
",",
"component",
")",
",",
"getConverter",
"(",
"facesContext",
",",
"component",
")",
")",
";",
"}",
"else",
"if",
"(",
"component",
"instanceof",
"UISelectOne",
")",
"{",
"renderMenu",
"(",
"facesContext",
",",
"(",
"UISelectOne",
")",
"component",
",",
"isDisabled",
"(",
"facesContext",
",",
"component",
")",
",",
"getConverter",
"(",
"facesContext",
",",
"component",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unsupported component class \"",
"+",
"component",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"}"
] |
private static final Log log = LogFactory.getLog(HtmlMenuRenderer.class);
|
[
"private",
"static",
"final",
"Log",
"log",
"=",
"LogFactory",
".",
"getLog",
"(",
"HtmlMenuRenderer",
".",
"class",
")",
";"
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/renderkit/html/HtmlMenuRendererBase.java#L47-L81
|
ansell/csvstream
|
src/main/java/com/github/ansell/csv/stream/CSVStream.java
|
CSVStream.newCSVWriter
|
public static SequenceWriter newCSVWriter(final OutputStream outputStream, List<String> headers)
throws IOException {
"""
Returns a Jackson {@link SequenceWriter} which will write CSV lines to the
given {@link OutputStream} using the headers provided.
@param outputStream
The writer which will receive the CSV file.
@param headers
The column headers that will be used by the returned Jackson
{@link SequenceWriter}.
@return A Jackson {@link SequenceWriter} that can have
{@link SequenceWriter#write(Object)} called on it to emit CSV lines
to the given {@link OutputStream}.
@throws IOException
If there is a problem writing the CSV header line to the
{@link OutputStream}.
"""
return newCSVWriter(outputStream, buildSchema(headers));
}
|
java
|
public static SequenceWriter newCSVWriter(final OutputStream outputStream, List<String> headers)
throws IOException {
return newCSVWriter(outputStream, buildSchema(headers));
}
|
[
"public",
"static",
"SequenceWriter",
"newCSVWriter",
"(",
"final",
"OutputStream",
"outputStream",
",",
"List",
"<",
"String",
">",
"headers",
")",
"throws",
"IOException",
"{",
"return",
"newCSVWriter",
"(",
"outputStream",
",",
"buildSchema",
"(",
"headers",
")",
")",
";",
"}"
] |
Returns a Jackson {@link SequenceWriter} which will write CSV lines to the
given {@link OutputStream} using the headers provided.
@param outputStream
The writer which will receive the CSV file.
@param headers
The column headers that will be used by the returned Jackson
{@link SequenceWriter}.
@return A Jackson {@link SequenceWriter} that can have
{@link SequenceWriter#write(Object)} called on it to emit CSV lines
to the given {@link OutputStream}.
@throws IOException
If there is a problem writing the CSV header line to the
{@link OutputStream}.
|
[
"Returns",
"a",
"Jackson",
"{",
"@link",
"SequenceWriter",
"}",
"which",
"will",
"write",
"CSV",
"lines",
"to",
"the",
"given",
"{",
"@link",
"OutputStream",
"}",
"using",
"the",
"headers",
"provided",
"."
] |
train
|
https://github.com/ansell/csvstream/blob/9468bfbd6997fbc4237eafc990ba811cd5905dc1/src/main/java/com/github/ansell/csv/stream/CSVStream.java#L476-L479
|
TheHortonMachine/hortonmachine
|
apps/src/main/java/org/hortonmachine/database/SqlDocument.java
|
SqlDocument.commentLinesBefore
|
private boolean commentLinesBefore( String content, int line ) {
"""
/*
Highlight lines when a multi line comment is still 'open'
(ie. matching end delimiter has not yet been encountered)
"""
int offset = rootElement.getElement(line).getStartOffset();
// Start of comment not found, nothing to do
int startDelimiter = lastIndexOf(content, getStartDelimiter(), offset - 2);
if (startDelimiter < 0)
return false;
// Matching start/end of comment found, nothing to do
int endDelimiter = indexOf(content, getEndDelimiter(), startDelimiter);
if (endDelimiter < offset & endDelimiter != -1)
return false;
// End of comment not found, highlight the lines
doc.setCharacterAttributes(startDelimiter, offset - startDelimiter + 1, comment, false);
return true;
}
|
java
|
private boolean commentLinesBefore( String content, int line ) {
int offset = rootElement.getElement(line).getStartOffset();
// Start of comment not found, nothing to do
int startDelimiter = lastIndexOf(content, getStartDelimiter(), offset - 2);
if (startDelimiter < 0)
return false;
// Matching start/end of comment found, nothing to do
int endDelimiter = indexOf(content, getEndDelimiter(), startDelimiter);
if (endDelimiter < offset & endDelimiter != -1)
return false;
// End of comment not found, highlight the lines
doc.setCharacterAttributes(startDelimiter, offset - startDelimiter + 1, comment, false);
return true;
}
|
[
"private",
"boolean",
"commentLinesBefore",
"(",
"String",
"content",
",",
"int",
"line",
")",
"{",
"int",
"offset",
"=",
"rootElement",
".",
"getElement",
"(",
"line",
")",
".",
"getStartOffset",
"(",
")",
";",
"// Start of comment not found, nothing to do",
"int",
"startDelimiter",
"=",
"lastIndexOf",
"(",
"content",
",",
"getStartDelimiter",
"(",
")",
",",
"offset",
"-",
"2",
")",
";",
"if",
"(",
"startDelimiter",
"<",
"0",
")",
"return",
"false",
";",
"// Matching start/end of comment found, nothing to do",
"int",
"endDelimiter",
"=",
"indexOf",
"(",
"content",
",",
"getEndDelimiter",
"(",
")",
",",
"startDelimiter",
")",
";",
"if",
"(",
"endDelimiter",
"<",
"offset",
"&",
"endDelimiter",
"!=",
"-",
"1",
")",
"return",
"false",
";",
"// End of comment not found, highlight the lines",
"doc",
".",
"setCharacterAttributes",
"(",
"startDelimiter",
",",
"offset",
"-",
"startDelimiter",
"+",
"1",
",",
"comment",
",",
"false",
")",
";",
"return",
"true",
";",
"}"
] |
/*
Highlight lines when a multi line comment is still 'open'
(ie. matching end delimiter has not yet been encountered)
|
[
"/",
"*",
"Highlight",
"lines",
"when",
"a",
"multi",
"line",
"comment",
"is",
"still",
"open",
"(",
"ie",
".",
"matching",
"end",
"delimiter",
"has",
"not",
"yet",
"been",
"encountered",
")"
] |
train
|
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/apps/src/main/java/org/hortonmachine/database/SqlDocument.java#L128-L141
|
alkacon/opencms-core
|
src/org/opencms/file/wrapper/CmsResourceWrapperXmlPage.java
|
CmsResourceWrapperXmlPage.getStringValue
|
private String getStringValue(CmsObject cms, CmsResource resource, byte[] content) throws CmsException {
"""
Returns the content as a string while using the correct encoding.<p>
@param cms the initialized CmsObject
@param resource the resource where the content belongs to
@param content the byte array which should be converted into a string
@return the content as a string
@throws CmsException if something goes wrong
"""
// get the encoding for the resource
CmsProperty prop = cms.readPropertyObject(resource, CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING, true);
String enc = prop.getValue();
if (enc == null) {
enc = OpenCms.getSystemInfo().getDefaultEncoding();
}
// create a String with the right encoding
return CmsEncoder.createString(content, enc);
}
|
java
|
private String getStringValue(CmsObject cms, CmsResource resource, byte[] content) throws CmsException {
// get the encoding for the resource
CmsProperty prop = cms.readPropertyObject(resource, CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING, true);
String enc = prop.getValue();
if (enc == null) {
enc = OpenCms.getSystemInfo().getDefaultEncoding();
}
// create a String with the right encoding
return CmsEncoder.createString(content, enc);
}
|
[
"private",
"String",
"getStringValue",
"(",
"CmsObject",
"cms",
",",
"CmsResource",
"resource",
",",
"byte",
"[",
"]",
"content",
")",
"throws",
"CmsException",
"{",
"// get the encoding for the resource",
"CmsProperty",
"prop",
"=",
"cms",
".",
"readPropertyObject",
"(",
"resource",
",",
"CmsPropertyDefinition",
".",
"PROPERTY_CONTENT_ENCODING",
",",
"true",
")",
";",
"String",
"enc",
"=",
"prop",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"enc",
"==",
"null",
")",
"{",
"enc",
"=",
"OpenCms",
".",
"getSystemInfo",
"(",
")",
".",
"getDefaultEncoding",
"(",
")",
";",
"}",
"// create a String with the right encoding",
"return",
"CmsEncoder",
".",
"createString",
"(",
"content",
",",
"enc",
")",
";",
"}"
] |
Returns the content as a string while using the correct encoding.<p>
@param cms the initialized CmsObject
@param resource the resource where the content belongs to
@param content the byte array which should be converted into a string
@return the content as a string
@throws CmsException if something goes wrong
|
[
"Returns",
"the",
"content",
"as",
"a",
"string",
"while",
"using",
"the",
"correct",
"encoding",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/file/wrapper/CmsResourceWrapperXmlPage.java#L1076-L1087
|
mgm-tp/jfunk
|
jfunk-web/src/main/java/com/mgmtp/jfunk/web/util/MultipartPostRequest.java
|
MultipartPostRequest.setParameter
|
public void setParameter(final String name, final String filename, final InputStream is) throws IOException {
"""
Adds a file parameter to the request
@param name
parameter name
@param filename
the name of the file
@param is
input stream to read the contents of the file from
"""
boundary();
writeName(name);
write("; filename=\"");
write(filename);
write('"');
newline();
write("Content-Type: ");
String type = URLConnection.guessContentTypeFromName(filename);
if (type == null) {
type = "application/octet-stream";
}
writeln(type);
newline();
pipe(is, os);
newline();
}
|
java
|
public void setParameter(final String name, final String filename, final InputStream is) throws IOException {
boundary();
writeName(name);
write("; filename=\"");
write(filename);
write('"');
newline();
write("Content-Type: ");
String type = URLConnection.guessContentTypeFromName(filename);
if (type == null) {
type = "application/octet-stream";
}
writeln(type);
newline();
pipe(is, os);
newline();
}
|
[
"public",
"void",
"setParameter",
"(",
"final",
"String",
"name",
",",
"final",
"String",
"filename",
",",
"final",
"InputStream",
"is",
")",
"throws",
"IOException",
"{",
"boundary",
"(",
")",
";",
"writeName",
"(",
"name",
")",
";",
"write",
"(",
"\"; filename=\\\"\"",
")",
";",
"write",
"(",
"filename",
")",
";",
"write",
"(",
"'",
"'",
")",
";",
"newline",
"(",
")",
";",
"write",
"(",
"\"Content-Type: \"",
")",
";",
"String",
"type",
"=",
"URLConnection",
".",
"guessContentTypeFromName",
"(",
"filename",
")",
";",
"if",
"(",
"type",
"==",
"null",
")",
"{",
"type",
"=",
"\"application/octet-stream\"",
";",
"}",
"writeln",
"(",
"type",
")",
";",
"newline",
"(",
")",
";",
"pipe",
"(",
"is",
",",
"os",
")",
";",
"newline",
"(",
")",
";",
"}"
] |
Adds a file parameter to the request
@param name
parameter name
@param filename
the name of the file
@param is
input stream to read the contents of the file from
|
[
"Adds",
"a",
"file",
"parameter",
"to",
"the",
"request"
] |
train
|
https://github.com/mgm-tp/jfunk/blob/5b9fecac5778b988bb458085ded39ea9a4c7c2ae/jfunk-web/src/main/java/com/mgmtp/jfunk/web/util/MultipartPostRequest.java#L115-L131
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java
|
ApiOvhTelephony.billingAccount_voicemail_serviceName_migrateOnNewVersion_POST
|
public void billingAccount_voicemail_serviceName_migrateOnNewVersion_POST(String billingAccount, String serviceName) throws IOException {
"""
Change the voicemail on a new version to manager greetings, directories and extra settings.
REST: POST /telephony/{billingAccount}/voicemail/{serviceName}/migrateOnNewVersion
@param billingAccount [required] The name of your billingAccount
@param serviceName [required]
"""
String qPath = "/telephony/{billingAccount}/voicemail/{serviceName}/migrateOnNewVersion";
StringBuilder sb = path(qPath, billingAccount, serviceName);
exec(qPath, "POST", sb.toString(), null);
}
|
java
|
public void billingAccount_voicemail_serviceName_migrateOnNewVersion_POST(String billingAccount, String serviceName) throws IOException {
String qPath = "/telephony/{billingAccount}/voicemail/{serviceName}/migrateOnNewVersion";
StringBuilder sb = path(qPath, billingAccount, serviceName);
exec(qPath, "POST", sb.toString(), null);
}
|
[
"public",
"void",
"billingAccount_voicemail_serviceName_migrateOnNewVersion_POST",
"(",
"String",
"billingAccount",
",",
"String",
"serviceName",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/telephony/{billingAccount}/voicemail/{serviceName}/migrateOnNewVersion\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"billingAccount",
",",
"serviceName",
")",
";",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"}"
] |
Change the voicemail on a new version to manager greetings, directories and extra settings.
REST: POST /telephony/{billingAccount}/voicemail/{serviceName}/migrateOnNewVersion
@param billingAccount [required] The name of your billingAccount
@param serviceName [required]
|
[
"Change",
"the",
"voicemail",
"on",
"a",
"new",
"version",
"to",
"manager",
"greetings",
"directories",
"and",
"extra",
"settings",
"."
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L7878-L7882
|
elki-project/elki
|
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/CauchyDistribution.java
|
CauchyDistribution.cdf
|
public static double cdf(double x, double location, double shape) {
"""
PDF function, static version.
@param x Value
@param location Location (x0)
@param shape Shape (gamma)
@return PDF value
"""
return FastMath.atan2(x - location, shape) / Math.PI + .5;
}
|
java
|
public static double cdf(double x, double location, double shape) {
return FastMath.atan2(x - location, shape) / Math.PI + .5;
}
|
[
"public",
"static",
"double",
"cdf",
"(",
"double",
"x",
",",
"double",
"location",
",",
"double",
"shape",
")",
"{",
"return",
"FastMath",
".",
"atan2",
"(",
"x",
"-",
"location",
",",
"shape",
")",
"/",
"Math",
".",
"PI",
"+",
".5",
";",
"}"
] |
PDF function, static version.
@param x Value
@param location Location (x0)
@param shape Shape (gamma)
@return PDF value
|
[
"PDF",
"function",
"static",
"version",
"."
] |
train
|
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/CauchyDistribution.java#L162-L164
|
mebigfatguy/fb-contrib
|
src/main/java/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
|
BloatedAssignmentScope.findSynchronizedScopeBlock
|
private ScopeBlock findSynchronizedScopeBlock(ScopeBlock sb, int monitorEnterPC) {
"""
finds the scope block that is the active synchronized block
@param sb
the parent scope block to start with
@param monitorEnterPC
the pc where the current synchronized block starts
@return the scope block
"""
ScopeBlock monitorBlock = sb;
if (sb.hasChildren()) {
for (ScopeBlock child : sb.getChildren()) {
if (child.isSync() && (child.getStart() > monitorBlock.getStart())) {
monitorBlock = child;
monitorBlock = findSynchronizedScopeBlock(monitorBlock, monitorEnterPC);
}
}
}
return monitorBlock;
}
|
java
|
private ScopeBlock findSynchronizedScopeBlock(ScopeBlock sb, int monitorEnterPC) {
ScopeBlock monitorBlock = sb;
if (sb.hasChildren()) {
for (ScopeBlock child : sb.getChildren()) {
if (child.isSync() && (child.getStart() > monitorBlock.getStart())) {
monitorBlock = child;
monitorBlock = findSynchronizedScopeBlock(monitorBlock, monitorEnterPC);
}
}
}
return monitorBlock;
}
|
[
"private",
"ScopeBlock",
"findSynchronizedScopeBlock",
"(",
"ScopeBlock",
"sb",
",",
"int",
"monitorEnterPC",
")",
"{",
"ScopeBlock",
"monitorBlock",
"=",
"sb",
";",
"if",
"(",
"sb",
".",
"hasChildren",
"(",
")",
")",
"{",
"for",
"(",
"ScopeBlock",
"child",
":",
"sb",
".",
"getChildren",
"(",
")",
")",
"{",
"if",
"(",
"child",
".",
"isSync",
"(",
")",
"&&",
"(",
"child",
".",
"getStart",
"(",
")",
">",
"monitorBlock",
".",
"getStart",
"(",
")",
")",
")",
"{",
"monitorBlock",
"=",
"child",
";",
"monitorBlock",
"=",
"findSynchronizedScopeBlock",
"(",
"monitorBlock",
",",
"monitorEnterPC",
")",
";",
"}",
"}",
"}",
"return",
"monitorBlock",
";",
"}"
] |
finds the scope block that is the active synchronized block
@param sb
the parent scope block to start with
@param monitorEnterPC
the pc where the current synchronized block starts
@return the scope block
|
[
"finds",
"the",
"scope",
"block",
"that",
"is",
"the",
"active",
"synchronized",
"block"
] |
train
|
https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java#L718-L732
|
lessthanoptimal/BoofCV
|
main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/splitmerge/PolylineSplitMerge.java
|
PolylineSplitMerge.distanceSq
|
static double distanceSq( Point2D_I32 a , Point2D_I32 b ) {
"""
Using double prevision here instead of int due to fear of overflow in very large images
"""
double dx = b.x-a.x;
double dy = b.y-a.y;
return dx*dx + dy*dy;
}
|
java
|
static double distanceSq( Point2D_I32 a , Point2D_I32 b ) {
double dx = b.x-a.x;
double dy = b.y-a.y;
return dx*dx + dy*dy;
}
|
[
"static",
"double",
"distanceSq",
"(",
"Point2D_I32",
"a",
",",
"Point2D_I32",
"b",
")",
"{",
"double",
"dx",
"=",
"b",
".",
"x",
"-",
"a",
".",
"x",
";",
"double",
"dy",
"=",
"b",
".",
"y",
"-",
"a",
".",
"y",
";",
"return",
"dx",
"*",
"dx",
"+",
"dy",
"*",
"dy",
";",
"}"
] |
Using double prevision here instead of int due to fear of overflow in very large images
|
[
"Using",
"double",
"prevision",
"here",
"instead",
"of",
"int",
"due",
"to",
"fear",
"of",
"overflow",
"in",
"very",
"large",
"images"
] |
train
|
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/splitmerge/PolylineSplitMerge.java#L791-L796
|
Bandwidth/java-bandwidth
|
src/main/java/com/bandwidth/sdk/model/Conference.java
|
Conference.createConference
|
public static Conference createConference(final BandwidthClient client, final Map<String, Object> params) throws Exception {
"""
Factory method to create a conference given a set of params and a client object
@param client the bandwidth client configuration.
@param params the params
@return the conference
@throws IOException unexpected error.
"""
final String conferencesUri = client.getUserResourceUri(BandwidthConstants.CONFERENCES_URI_PATH);
final RestResponse response = client.post(conferencesUri, params);
final String id = response.getLocation().substring(client.getPath(conferencesUri).length() + 1);
return getConference(client, id);
}
|
java
|
public static Conference createConference(final BandwidthClient client, final Map<String, Object> params) throws Exception {
final String conferencesUri = client.getUserResourceUri(BandwidthConstants.CONFERENCES_URI_PATH);
final RestResponse response = client.post(conferencesUri, params);
final String id = response.getLocation().substring(client.getPath(conferencesUri).length() + 1);
return getConference(client, id);
}
|
[
"public",
"static",
"Conference",
"createConference",
"(",
"final",
"BandwidthClient",
"client",
",",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"params",
")",
"throws",
"Exception",
"{",
"final",
"String",
"conferencesUri",
"=",
"client",
".",
"getUserResourceUri",
"(",
"BandwidthConstants",
".",
"CONFERENCES_URI_PATH",
")",
";",
"final",
"RestResponse",
"response",
"=",
"client",
".",
"post",
"(",
"conferencesUri",
",",
"params",
")",
";",
"final",
"String",
"id",
"=",
"response",
".",
"getLocation",
"(",
")",
".",
"substring",
"(",
"client",
".",
"getPath",
"(",
"conferencesUri",
")",
".",
"length",
"(",
")",
"+",
"1",
")",
";",
"return",
"getConference",
"(",
"client",
",",
"id",
")",
";",
"}"
] |
Factory method to create a conference given a set of params and a client object
@param client the bandwidth client configuration.
@param params the params
@return the conference
@throws IOException unexpected error.
|
[
"Factory",
"method",
"to",
"create",
"a",
"conference",
"given",
"a",
"set",
"of",
"params",
"and",
"a",
"client",
"object"
] |
train
|
https://github.com/Bandwidth/java-bandwidth/blob/2124c85148ad6a54d2f2949cb952eb3985830e2a/src/main/java/com/bandwidth/sdk/model/Conference.java#L70-L77
|
alkacon/opencms-core
|
src-gwt/org/opencms/gwt/client/ui/input/colorpicker/CmsColor.java
|
CmsColor.MIN
|
private float MIN(float first, float second, float third) {
"""
Calculates the smallest value between the three inputs.
@param first value
@param second value
@param third value
@return the smallest value between the three inputs
"""
float min = Integer.MAX_VALUE;
if (first < min) {
min = first;
}
if (second < min) {
min = second;
}
if (third < min) {
min = third;
}
return min;
}
|
java
|
private float MIN(float first, float second, float third) {
float min = Integer.MAX_VALUE;
if (first < min) {
min = first;
}
if (second < min) {
min = second;
}
if (third < min) {
min = third;
}
return min;
}
|
[
"private",
"float",
"MIN",
"(",
"float",
"first",
",",
"float",
"second",
",",
"float",
"third",
")",
"{",
"float",
"min",
"=",
"Integer",
".",
"MAX_VALUE",
";",
"if",
"(",
"first",
"<",
"min",
")",
"{",
"min",
"=",
"first",
";",
"}",
"if",
"(",
"second",
"<",
"min",
")",
"{",
"min",
"=",
"second",
";",
"}",
"if",
"(",
"third",
"<",
"min",
")",
"{",
"min",
"=",
"third",
";",
"}",
"return",
"min",
";",
"}"
] |
Calculates the smallest value between the three inputs.
@param first value
@param second value
@param third value
@return the smallest value between the three inputs
|
[
"Calculates",
"the",
"smallest",
"value",
"between",
"the",
"three",
"inputs",
"."
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/gwt/client/ui/input/colorpicker/CmsColor.java#L281-L294
|
eurekaclinical/protempa
|
protempa-dsb-relationaldb/src/main/java/org/protempa/backend/dsb/relationaldb/JDBCDecimalDayParser.java
|
JDBCDecimalDayParser.toPosition
|
@Override
public Long toPosition(ResultSet resultSet, int columnIndex, int colType)
throws SQLException {
"""
Parses strings with format <code>yyyyMMdd</code> into a position with a
granularity of
{@link org.protempa.proposition.value.AbsoluteTimeGranularity} with a
granularity of DAY.
@param resultSet a {@link ResultSet}.
@param columnIndex the column to parse.
@param colType the type of the column as a {@link java.sql.Types}.
@return a position with a granularity of
{@link org.protempa.proposition.value.AbsoluteTimeGranularity} with a
granularity of DAY.
@throws SQLException if an error occurred retrieving the value from
the result set.
"""
int date = resultSet.getInt(columnIndex);
if (date < 10000000) {
return null;
}
int year = date / 10000;
int monthDay = date - year * 10000;
int month = monthDay / 100;
int day = monthDay - month * 100;
synchronized (calendar) {
calendar.clear();
calendar.set(year, month - 1, day);
return AbsoluteTimeGranularityUtil.asPosition(calendar.getTime());
}
}
|
java
|
@Override
public Long toPosition(ResultSet resultSet, int columnIndex, int colType)
throws SQLException {
int date = resultSet.getInt(columnIndex);
if (date < 10000000) {
return null;
}
int year = date / 10000;
int monthDay = date - year * 10000;
int month = monthDay / 100;
int day = monthDay - month * 100;
synchronized (calendar) {
calendar.clear();
calendar.set(year, month - 1, day);
return AbsoluteTimeGranularityUtil.asPosition(calendar.getTime());
}
}
|
[
"@",
"Override",
"public",
"Long",
"toPosition",
"(",
"ResultSet",
"resultSet",
",",
"int",
"columnIndex",
",",
"int",
"colType",
")",
"throws",
"SQLException",
"{",
"int",
"date",
"=",
"resultSet",
".",
"getInt",
"(",
"columnIndex",
")",
";",
"if",
"(",
"date",
"<",
"10000000",
")",
"{",
"return",
"null",
";",
"}",
"int",
"year",
"=",
"date",
"/",
"10000",
";",
"int",
"monthDay",
"=",
"date",
"-",
"year",
"*",
"10000",
";",
"int",
"month",
"=",
"monthDay",
"/",
"100",
";",
"int",
"day",
"=",
"monthDay",
"-",
"month",
"*",
"100",
";",
"synchronized",
"(",
"calendar",
")",
"{",
"calendar",
".",
"clear",
"(",
")",
";",
"calendar",
".",
"set",
"(",
"year",
",",
"month",
"-",
"1",
",",
"day",
")",
";",
"return",
"AbsoluteTimeGranularityUtil",
".",
"asPosition",
"(",
"calendar",
".",
"getTime",
"(",
")",
")",
";",
"}",
"}"
] |
Parses strings with format <code>yyyyMMdd</code> into a position with a
granularity of
{@link org.protempa.proposition.value.AbsoluteTimeGranularity} with a
granularity of DAY.
@param resultSet a {@link ResultSet}.
@param columnIndex the column to parse.
@param colType the type of the column as a {@link java.sql.Types}.
@return a position with a granularity of
{@link org.protempa.proposition.value.AbsoluteTimeGranularity} with a
granularity of DAY.
@throws SQLException if an error occurred retrieving the value from
the result set.
|
[
"Parses",
"strings",
"with",
"format",
"<code",
">",
"yyyyMMdd<",
"/",
"code",
">",
"into",
"a",
"position",
"with",
"a",
"granularity",
"of",
"{",
"@link",
"org",
".",
"protempa",
".",
"proposition",
".",
"value",
".",
"AbsoluteTimeGranularity",
"}",
"with",
"a",
"granularity",
"of",
"DAY",
"."
] |
train
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-dsb-relationaldb/src/main/java/org/protempa/backend/dsb/relationaldb/JDBCDecimalDayParser.java#L64-L80
|
couchbase/couchbase-java-client
|
src/main/java/com/couchbase/client/java/query/dsl/functions/Collections.java
|
Collections.everyIn
|
public static SatisfiesBuilder everyIn(String variable, Expression expression) {
"""
Create an EVERY comprehension with a first IN range.
EVERY is a range predicate that allows you to test a Boolean condition over the elements or attributes of a
collection, object, or objects. It uses the IN and WITHIN operators to range through the collection.
IN ranges in the direct elements of its array expression, WITHIN also ranges in its descendants.
If every array element satisfies the EVERY expression, it returns TRUE. Otherwise it returns FALSE.
If the array is empty, it returns TRUE.
"""
return new SatisfiesBuilder(x("EVERY"), variable, expression, true);
}
|
java
|
public static SatisfiesBuilder everyIn(String variable, Expression expression) {
return new SatisfiesBuilder(x("EVERY"), variable, expression, true);
}
|
[
"public",
"static",
"SatisfiesBuilder",
"everyIn",
"(",
"String",
"variable",
",",
"Expression",
"expression",
")",
"{",
"return",
"new",
"SatisfiesBuilder",
"(",
"x",
"(",
"\"EVERY\"",
")",
",",
"variable",
",",
"expression",
",",
"true",
")",
";",
"}"
] |
Create an EVERY comprehension with a first IN range.
EVERY is a range predicate that allows you to test a Boolean condition over the elements or attributes of a
collection, object, or objects. It uses the IN and WITHIN operators to range through the collection.
IN ranges in the direct elements of its array expression, WITHIN also ranges in its descendants.
If every array element satisfies the EVERY expression, it returns TRUE. Otherwise it returns FALSE.
If the array is empty, it returns TRUE.
|
[
"Create",
"an",
"EVERY",
"comprehension",
"with",
"a",
"first",
"IN",
"range",
"."
] |
train
|
https://github.com/couchbase/couchbase-java-client/blob/f36a0ee0c66923bdde47838ca543e50cbaa99e14/src/main/java/com/couchbase/client/java/query/dsl/functions/Collections.java#L199-L201
|
mangstadt/biweekly
|
src/main/java/biweekly/property/Trigger.java
|
Trigger.setDuration
|
public void setDuration(Duration duration, Related related) {
"""
Sets a relative time at which the alarm will trigger.
@param duration the relative time
@param related the date-time field that the duration is relative to
"""
this.date = null;
this.duration = duration;
setRelated(related);
}
|
java
|
public void setDuration(Duration duration, Related related) {
this.date = null;
this.duration = duration;
setRelated(related);
}
|
[
"public",
"void",
"setDuration",
"(",
"Duration",
"duration",
",",
"Related",
"related",
")",
"{",
"this",
".",
"date",
"=",
"null",
";",
"this",
".",
"duration",
"=",
"duration",
";",
"setRelated",
"(",
"related",
")",
";",
"}"
] |
Sets a relative time at which the alarm will trigger.
@param duration the relative time
@param related the date-time field that the duration is relative to
|
[
"Sets",
"a",
"relative",
"time",
"at",
"which",
"the",
"alarm",
"will",
"trigger",
"."
] |
train
|
https://github.com/mangstadt/biweekly/blob/2e21350f85c13dfff52fdef98fdbebe2976fcf61/src/main/java/biweekly/property/Trigger.java#L103-L107
|
astrapi69/jaulp-wicket
|
jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/link/LinkUtils.java
|
LinkUtils.newExternalLink
|
public static ExternalLink newExternalLink(final String linkId, final String url,
final String labelId, final ResourceBundleKey resourceBundleKey, final Component component) {
"""
Creates an external link from the given parameters.
@param linkId
the link id
@param url
the external url
@param labelId
the label id
@param resourceBundleKey
the resource model key
@param component
the component
@return the external link
"""
final ExternalLink externalLink = new ExternalLink(linkId, Model.of(url));
externalLink.add(new Label(labelId,
ResourceModelFactory.newResourceModel(resourceBundleKey, component)));
return externalLink;
}
|
java
|
public static ExternalLink newExternalLink(final String linkId, final String url,
final String labelId, final ResourceBundleKey resourceBundleKey, final Component component)
{
final ExternalLink externalLink = new ExternalLink(linkId, Model.of(url));
externalLink.add(new Label(labelId,
ResourceModelFactory.newResourceModel(resourceBundleKey, component)));
return externalLink;
}
|
[
"public",
"static",
"ExternalLink",
"newExternalLink",
"(",
"final",
"String",
"linkId",
",",
"final",
"String",
"url",
",",
"final",
"String",
"labelId",
",",
"final",
"ResourceBundleKey",
"resourceBundleKey",
",",
"final",
"Component",
"component",
")",
"{",
"final",
"ExternalLink",
"externalLink",
"=",
"new",
"ExternalLink",
"(",
"linkId",
",",
"Model",
".",
"of",
"(",
"url",
")",
")",
";",
"externalLink",
".",
"add",
"(",
"new",
"Label",
"(",
"labelId",
",",
"ResourceModelFactory",
".",
"newResourceModel",
"(",
"resourceBundleKey",
",",
"component",
")",
")",
")",
";",
"return",
"externalLink",
";",
"}"
] |
Creates an external link from the given parameters.
@param linkId
the link id
@param url
the external url
@param labelId
the label id
@param resourceBundleKey
the resource model key
@param component
the component
@return the external link
|
[
"Creates",
"an",
"external",
"link",
"from",
"the",
"given",
"parameters",
"."
] |
train
|
https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/link/LinkUtils.java#L154-L161
|
Abnaxos/markdown-doclet
|
doclet/jdk8/src/main/java/ch/raffael/mddoclet/mdtaglet/argval/PredefinedArgumentValidators.java
|
PredefinedArgumentValidators.allOf
|
public static ArgumentValidator allOf(String description, ArgumentValidator... argumentValidators) {
"""
# Creates a {@link ArgumentValidator} which iterates over all `argumentValidators` until the first NOT {@link Type#VALID}
has been found.
This is of course a logical AND.
- If all are `VALID` then the result is also `VALID`.
- If at least one is *NOT VALID*, the first will be the result of the entire expression, but the error message will be replaced
with `description`
@param argumentValidators 1 or more argument validators
@param description any description
@return a AllOf validator
"""
return new AllOf(Arrays.asList(argumentValidators), description);
}
|
java
|
public static ArgumentValidator allOf(String description, ArgumentValidator... argumentValidators) {
return new AllOf(Arrays.asList(argumentValidators), description);
}
|
[
"public",
"static",
"ArgumentValidator",
"allOf",
"(",
"String",
"description",
",",
"ArgumentValidator",
"...",
"argumentValidators",
")",
"{",
"return",
"new",
"AllOf",
"(",
"Arrays",
".",
"asList",
"(",
"argumentValidators",
")",
",",
"description",
")",
";",
"}"
] |
# Creates a {@link ArgumentValidator} which iterates over all `argumentValidators` until the first NOT {@link Type#VALID}
has been found.
This is of course a logical AND.
- If all are `VALID` then the result is also `VALID`.
- If at least one is *NOT VALID*, the first will be the result of the entire expression, but the error message will be replaced
with `description`
@param argumentValidators 1 or more argument validators
@param description any description
@return a AllOf validator
|
[
"#",
"Creates",
"a",
"{",
"@link",
"ArgumentValidator",
"}",
"which",
"iterates",
"over",
"all",
"argumentValidators",
"until",
"the",
"first",
"NOT",
"{",
"@link",
"Type#VALID",
"}",
"has",
"been",
"found",
"."
] |
train
|
https://github.com/Abnaxos/markdown-doclet/blob/e98a9630206fc9c8d813cf2349ff594be8630054/doclet/jdk8/src/main/java/ch/raffael/mddoclet/mdtaglet/argval/PredefinedArgumentValidators.java#L252-L254
|
Esri/geometry-api-java
|
src/main/java/com/esri/core/geometry/Envelope2D.java
|
Envelope2D.containsExclusive
|
public boolean containsExclusive(double x, double y) {
"""
Returns True if the envelope contains the point (boundary exclusive).
@param x
@param y
@return True if this contains the point.
"""
// Note: This will return False, if envelope is empty, thus no need to
// call is_empty().
return x > xmin && x < xmax && y > ymin && y < ymax;
}
|
java
|
public boolean containsExclusive(double x, double y) {
// Note: This will return False, if envelope is empty, thus no need to
// call is_empty().
return x > xmin && x < xmax && y > ymin && y < ymax;
}
|
[
"public",
"boolean",
"containsExclusive",
"(",
"double",
"x",
",",
"double",
"y",
")",
"{",
"// Note: This will return False, if envelope is empty, thus no need to",
"// call is_empty().",
"return",
"x",
">",
"xmin",
"&&",
"x",
"<",
"xmax",
"&&",
"y",
">",
"ymin",
"&&",
"y",
"<",
"ymax",
";",
"}"
] |
Returns True if the envelope contains the point (boundary exclusive).
@param x
@param y
@return True if this contains the point.
|
[
"Returns",
"True",
"if",
"the",
"envelope",
"contains",
"the",
"point",
"(",
"boundary",
"exclusive",
")",
"."
] |
train
|
https://github.com/Esri/geometry-api-java/blob/494da8ec953d76e7c6072afbc081abfe48ff07cf/src/main/java/com/esri/core/geometry/Envelope2D.java#L655-L659
|
Squarespace/cldr
|
compiler/src/main/java/com/squarespace/cldr/codegen/parse/PluralRulePrinter.java
|
PluralRulePrinter.print
|
private static void print(StringBuilder buf, Node<PluralType> node) {
"""
Recursively visit the structs and atoms in the pluralization node or tree,
appending the representations to a string buffer.
"""
switch (node.type()) {
case RULE:
join(buf, node, " ");
break;
case AND_CONDITION:
join(buf, node, " and ");
break;
case OR_CONDITION:
join(buf, node, " or ");
break;
case RANGELIST:
join(buf, node, ",");
break;
case RANGE:
join(buf, node, "..");
break;
case EXPR:
join(buf, node, " ");
break;
case MODOP:
buf.append("% ").append(node.asAtom().value());
break;
case INTEGER:
case OPERAND:
case RELOP:
case SAMPLE:
buf.append(node.asAtom().value());
break;
}
}
|
java
|
private static void print(StringBuilder buf, Node<PluralType> node) {
switch (node.type()) {
case RULE:
join(buf, node, " ");
break;
case AND_CONDITION:
join(buf, node, " and ");
break;
case OR_CONDITION:
join(buf, node, " or ");
break;
case RANGELIST:
join(buf, node, ",");
break;
case RANGE:
join(buf, node, "..");
break;
case EXPR:
join(buf, node, " ");
break;
case MODOP:
buf.append("% ").append(node.asAtom().value());
break;
case INTEGER:
case OPERAND:
case RELOP:
case SAMPLE:
buf.append(node.asAtom().value());
break;
}
}
|
[
"private",
"static",
"void",
"print",
"(",
"StringBuilder",
"buf",
",",
"Node",
"<",
"PluralType",
">",
"node",
")",
"{",
"switch",
"(",
"node",
".",
"type",
"(",
")",
")",
"{",
"case",
"RULE",
":",
"join",
"(",
"buf",
",",
"node",
",",
"\" \"",
")",
";",
"break",
";",
"case",
"AND_CONDITION",
":",
"join",
"(",
"buf",
",",
"node",
",",
"\" and \"",
")",
";",
"break",
";",
"case",
"OR_CONDITION",
":",
"join",
"(",
"buf",
",",
"node",
",",
"\" or \"",
")",
";",
"break",
";",
"case",
"RANGELIST",
":",
"join",
"(",
"buf",
",",
"node",
",",
"\",\"",
")",
";",
"break",
";",
"case",
"RANGE",
":",
"join",
"(",
"buf",
",",
"node",
",",
"\"..\"",
")",
";",
"break",
";",
"case",
"EXPR",
":",
"join",
"(",
"buf",
",",
"node",
",",
"\" \"",
")",
";",
"break",
";",
"case",
"MODOP",
":",
"buf",
".",
"append",
"(",
"\"% \"",
")",
".",
"append",
"(",
"node",
".",
"asAtom",
"(",
")",
".",
"value",
"(",
")",
")",
";",
"break",
";",
"case",
"INTEGER",
":",
"case",
"OPERAND",
":",
"case",
"RELOP",
":",
"case",
"SAMPLE",
":",
"buf",
".",
"append",
"(",
"node",
".",
"asAtom",
"(",
")",
".",
"value",
"(",
")",
")",
";",
"break",
";",
"}",
"}"
] |
Recursively visit the structs and atoms in the pluralization node or tree,
appending the representations to a string buffer.
|
[
"Recursively",
"visit",
"the",
"structs",
"and",
"atoms",
"in",
"the",
"pluralization",
"node",
"or",
"tree",
"appending",
"the",
"representations",
"to",
"a",
"string",
"buffer",
"."
] |
train
|
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/compiler/src/main/java/com/squarespace/cldr/codegen/parse/PluralRulePrinter.java#L27-L64
|
aws/aws-sdk-java
|
aws-java-sdk-cloudsearch/src/main/java/com/amazonaws/services/cloudsearchdomain/model/SearchResult.java
|
SearchResult.withFacets
|
public SearchResult withFacets(java.util.Map<String, BucketInfo> facets) {
"""
<p>
The requested facet information.
</p>
@param facets
The requested facet information.
@return Returns a reference to this object so that method calls can be chained together.
"""
setFacets(facets);
return this;
}
|
java
|
public SearchResult withFacets(java.util.Map<String, BucketInfo> facets) {
setFacets(facets);
return this;
}
|
[
"public",
"SearchResult",
"withFacets",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"BucketInfo",
">",
"facets",
")",
"{",
"setFacets",
"(",
"facets",
")",
";",
"return",
"this",
";",
"}"
] |
<p>
The requested facet information.
</p>
@param facets
The requested facet information.
@return Returns a reference to this object so that method calls can be chained together.
|
[
"<p",
">",
"The",
"requested",
"facet",
"information",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-cloudsearch/src/main/java/com/amazonaws/services/cloudsearchdomain/model/SearchResult.java#L170-L173
|
molgenis/molgenis
|
molgenis-data-import/src/main/java/org/molgenis/data/importer/emx/EmxMetadataParser.java
|
EmxMetadataParser.parseBoolean
|
static boolean parseBoolean(String booleanString, int rowIndex, String columnName) {
"""
Validates whether an EMX value for a boolean attribute is valid and returns the parsed boolean
value.
@param booleanString boolean string
@param rowIndex row index
@param columnName column name
@return true or false
@throws InvalidValueException if the given boolean string value is not one of [true, false]
(case insensitive)
"""
if (booleanString.equalsIgnoreCase(TRUE.toString())) return true;
else if (booleanString.equalsIgnoreCase(FALSE.toString())) return false;
else
throw new InvalidValueException(
booleanString, columnName, "TRUE, FALSE", EMX_ATTRIBUTES, rowIndex);
}
|
java
|
static boolean parseBoolean(String booleanString, int rowIndex, String columnName) {
if (booleanString.equalsIgnoreCase(TRUE.toString())) return true;
else if (booleanString.equalsIgnoreCase(FALSE.toString())) return false;
else
throw new InvalidValueException(
booleanString, columnName, "TRUE, FALSE", EMX_ATTRIBUTES, rowIndex);
}
|
[
"static",
"boolean",
"parseBoolean",
"(",
"String",
"booleanString",
",",
"int",
"rowIndex",
",",
"String",
"columnName",
")",
"{",
"if",
"(",
"booleanString",
".",
"equalsIgnoreCase",
"(",
"TRUE",
".",
"toString",
"(",
")",
")",
")",
"return",
"true",
";",
"else",
"if",
"(",
"booleanString",
".",
"equalsIgnoreCase",
"(",
"FALSE",
".",
"toString",
"(",
")",
")",
")",
"return",
"false",
";",
"else",
"throw",
"new",
"InvalidValueException",
"(",
"booleanString",
",",
"columnName",
",",
"\"TRUE, FALSE\"",
",",
"EMX_ATTRIBUTES",
",",
"rowIndex",
")",
";",
"}"
] |
Validates whether an EMX value for a boolean attribute is valid and returns the parsed boolean
value.
@param booleanString boolean string
@param rowIndex row index
@param columnName column name
@return true or false
@throws InvalidValueException if the given boolean string value is not one of [true, false]
(case insensitive)
|
[
"Validates",
"whether",
"an",
"EMX",
"value",
"for",
"a",
"boolean",
"attribute",
"is",
"valid",
"and",
"returns",
"the",
"parsed",
"boolean",
"value",
"."
] |
train
|
https://github.com/molgenis/molgenis/blob/b4d0d6b27e6f6c8d7505a3863dc03b589601f987/molgenis-data-import/src/main/java/org/molgenis/data/importer/emx/EmxMetadataParser.java#L1277-L1283
|
puniverse/capsule
|
capsule-util/src/main/java/co/paralleluniverse/capsule/Jar.java
|
Jar.setAttribute
|
public final Jar setAttribute(String section, String name, String value) {
"""
Sets an attribute in a non-main section of the manifest.
@param section the section's name
@param name the attribute's name
@param value the attribute's value
@return {@code this}
@throws IllegalStateException if entries have been added or the JAR has been written prior to calling this methods.
"""
verifyNotSealed();
if (jos != null)
throw new IllegalStateException("Manifest cannot be modified after entries are added.");
Attributes attr = getManifest().getAttributes(section);
if (attr == null) {
attr = new Attributes();
getManifest().getEntries().put(section, attr);
}
attr.putValue(name, value);
return this;
}
|
java
|
public final Jar setAttribute(String section, String name, String value) {
verifyNotSealed();
if (jos != null)
throw new IllegalStateException("Manifest cannot be modified after entries are added.");
Attributes attr = getManifest().getAttributes(section);
if (attr == null) {
attr = new Attributes();
getManifest().getEntries().put(section, attr);
}
attr.putValue(name, value);
return this;
}
|
[
"public",
"final",
"Jar",
"setAttribute",
"(",
"String",
"section",
",",
"String",
"name",
",",
"String",
"value",
")",
"{",
"verifyNotSealed",
"(",
")",
";",
"if",
"(",
"jos",
"!=",
"null",
")",
"throw",
"new",
"IllegalStateException",
"(",
"\"Manifest cannot be modified after entries are added.\"",
")",
";",
"Attributes",
"attr",
"=",
"getManifest",
"(",
")",
".",
"getAttributes",
"(",
"section",
")",
";",
"if",
"(",
"attr",
"==",
"null",
")",
"{",
"attr",
"=",
"new",
"Attributes",
"(",
")",
";",
"getManifest",
"(",
")",
".",
"getEntries",
"(",
")",
".",
"put",
"(",
"section",
",",
"attr",
")",
";",
"}",
"attr",
".",
"putValue",
"(",
"name",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] |
Sets an attribute in a non-main section of the manifest.
@param section the section's name
@param name the attribute's name
@param value the attribute's value
@return {@code this}
@throws IllegalStateException if entries have been added or the JAR has been written prior to calling this methods.
|
[
"Sets",
"an",
"attribute",
"in",
"a",
"non",
"-",
"main",
"section",
"of",
"the",
"manifest",
"."
] |
train
|
https://github.com/puniverse/capsule/blob/291a54e501a32aaf0284707b8c1fbff6a566822b/capsule-util/src/main/java/co/paralleluniverse/capsule/Jar.java#L152-L163
|
GoogleCloudPlatform/bigdata-interop
|
gcsio/src/main/java/com/google/cloud/hadoop/gcsio/GoogleCloudStorageImpl.java
|
GoogleCloudStorageImpl.listObjectInfo
|
@Override
public List<GoogleCloudStorageItemInfo> listObjectInfo(
String bucketName, String objectNamePrefix, String delimiter, long maxResults)
throws IOException {
"""
See {@link GoogleCloudStorage#listObjectInfo(String, String, String, long)} for details about
expected behavior.
"""
logger.atFine().log(
"listObjectInfo(%s, %s, %s, %s)", bucketName, objectNamePrefix, delimiter, maxResults);
// Helper will handle going through pages of list results and accumulating them.
List<StorageObject> listedObjects = new ArrayList<>();
List<String> listedPrefixes = new ArrayList<>();
listStorageObjectsAndPrefixes(
bucketName,
objectNamePrefix,
delimiter,
/* includeTrailingDelimiter= */ true,
maxResults,
listedObjects,
listedPrefixes);
// For the listedObjects, we simply parse each item into a GoogleCloudStorageItemInfo without
// further work.
List<GoogleCloudStorageItemInfo> objectInfos = new ArrayList<>(listedObjects.size());
for (StorageObject obj : listedObjects) {
objectInfos.add(
createItemInfoForStorageObject(new StorageResourceId(bucketName, obj.getName()), obj));
}
if (listedPrefixes.isEmpty()) {
return objectInfos;
}
handlePrefixes(bucketName, listedPrefixes, objectInfos);
return objectInfos;
}
|
java
|
@Override
public List<GoogleCloudStorageItemInfo> listObjectInfo(
String bucketName, String objectNamePrefix, String delimiter, long maxResults)
throws IOException {
logger.atFine().log(
"listObjectInfo(%s, %s, %s, %s)", bucketName, objectNamePrefix, delimiter, maxResults);
// Helper will handle going through pages of list results and accumulating them.
List<StorageObject> listedObjects = new ArrayList<>();
List<String> listedPrefixes = new ArrayList<>();
listStorageObjectsAndPrefixes(
bucketName,
objectNamePrefix,
delimiter,
/* includeTrailingDelimiter= */ true,
maxResults,
listedObjects,
listedPrefixes);
// For the listedObjects, we simply parse each item into a GoogleCloudStorageItemInfo without
// further work.
List<GoogleCloudStorageItemInfo> objectInfos = new ArrayList<>(listedObjects.size());
for (StorageObject obj : listedObjects) {
objectInfos.add(
createItemInfoForStorageObject(new StorageResourceId(bucketName, obj.getName()), obj));
}
if (listedPrefixes.isEmpty()) {
return objectInfos;
}
handlePrefixes(bucketName, listedPrefixes, objectInfos);
return objectInfos;
}
|
[
"@",
"Override",
"public",
"List",
"<",
"GoogleCloudStorageItemInfo",
">",
"listObjectInfo",
"(",
"String",
"bucketName",
",",
"String",
"objectNamePrefix",
",",
"String",
"delimiter",
",",
"long",
"maxResults",
")",
"throws",
"IOException",
"{",
"logger",
".",
"atFine",
"(",
")",
".",
"log",
"(",
"\"listObjectInfo(%s, %s, %s, %s)\"",
",",
"bucketName",
",",
"objectNamePrefix",
",",
"delimiter",
",",
"maxResults",
")",
";",
"// Helper will handle going through pages of list results and accumulating them.",
"List",
"<",
"StorageObject",
">",
"listedObjects",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"List",
"<",
"String",
">",
"listedPrefixes",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"listStorageObjectsAndPrefixes",
"(",
"bucketName",
",",
"objectNamePrefix",
",",
"delimiter",
",",
"/* includeTrailingDelimiter= */",
"true",
",",
"maxResults",
",",
"listedObjects",
",",
"listedPrefixes",
")",
";",
"// For the listedObjects, we simply parse each item into a GoogleCloudStorageItemInfo without",
"// further work.",
"List",
"<",
"GoogleCloudStorageItemInfo",
">",
"objectInfos",
"=",
"new",
"ArrayList",
"<>",
"(",
"listedObjects",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"StorageObject",
"obj",
":",
"listedObjects",
")",
"{",
"objectInfos",
".",
"add",
"(",
"createItemInfoForStorageObject",
"(",
"new",
"StorageResourceId",
"(",
"bucketName",
",",
"obj",
".",
"getName",
"(",
")",
")",
",",
"obj",
")",
")",
";",
"}",
"if",
"(",
"listedPrefixes",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"objectInfos",
";",
"}",
"handlePrefixes",
"(",
"bucketName",
",",
"listedPrefixes",
",",
"objectInfos",
")",
";",
"return",
"objectInfos",
";",
"}"
] |
See {@link GoogleCloudStorage#listObjectInfo(String, String, String, long)} for details about
expected behavior.
|
[
"See",
"{"
] |
train
|
https://github.com/GoogleCloudPlatform/bigdata-interop/blob/918d91c80a63e36046edb28972a5c65d3326a858/gcsio/src/main/java/com/google/cloud/hadoop/gcsio/GoogleCloudStorageImpl.java#L1357-L1391
|
netty/netty
|
handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslContext.java
|
ReferenceCountedOpenSslContext.providerFor
|
static OpenSslKeyMaterialProvider providerFor(KeyManagerFactory factory, String password) {
"""
Returns the {@link OpenSslKeyMaterialProvider} that should be used for OpenSSL. Depending on the given
{@link KeyManagerFactory} this may cache the {@link OpenSslKeyMaterial} for better performance if it can
ensure that the same material is always returned for the same alias.
"""
if (factory instanceof OpenSslX509KeyManagerFactory) {
return ((OpenSslX509KeyManagerFactory) factory).newProvider();
}
X509KeyManager keyManager = chooseX509KeyManager(factory.getKeyManagers());
if (factory instanceof OpenSslCachingX509KeyManagerFactory) {
// The user explicit used OpenSslCachingX509KeyManagerFactory which signals us that its fine to cache.
return new OpenSslCachingKeyMaterialProvider(keyManager, password);
}
// We can not be sure if the material may change at runtime so we will not cache it.
return new OpenSslKeyMaterialProvider(keyManager, password);
}
|
java
|
static OpenSslKeyMaterialProvider providerFor(KeyManagerFactory factory, String password) {
if (factory instanceof OpenSslX509KeyManagerFactory) {
return ((OpenSslX509KeyManagerFactory) factory).newProvider();
}
X509KeyManager keyManager = chooseX509KeyManager(factory.getKeyManagers());
if (factory instanceof OpenSslCachingX509KeyManagerFactory) {
// The user explicit used OpenSslCachingX509KeyManagerFactory which signals us that its fine to cache.
return new OpenSslCachingKeyMaterialProvider(keyManager, password);
}
// We can not be sure if the material may change at runtime so we will not cache it.
return new OpenSslKeyMaterialProvider(keyManager, password);
}
|
[
"static",
"OpenSslKeyMaterialProvider",
"providerFor",
"(",
"KeyManagerFactory",
"factory",
",",
"String",
"password",
")",
"{",
"if",
"(",
"factory",
"instanceof",
"OpenSslX509KeyManagerFactory",
")",
"{",
"return",
"(",
"(",
"OpenSslX509KeyManagerFactory",
")",
"factory",
")",
".",
"newProvider",
"(",
")",
";",
"}",
"X509KeyManager",
"keyManager",
"=",
"chooseX509KeyManager",
"(",
"factory",
".",
"getKeyManagers",
"(",
")",
")",
";",
"if",
"(",
"factory",
"instanceof",
"OpenSslCachingX509KeyManagerFactory",
")",
"{",
"// The user explicit used OpenSslCachingX509KeyManagerFactory which signals us that its fine to cache.",
"return",
"new",
"OpenSslCachingKeyMaterialProvider",
"(",
"keyManager",
",",
"password",
")",
";",
"}",
"// We can not be sure if the material may change at runtime so we will not cache it.",
"return",
"new",
"OpenSslKeyMaterialProvider",
"(",
"keyManager",
",",
"password",
")",
";",
"}"
] |
Returns the {@link OpenSslKeyMaterialProvider} that should be used for OpenSSL. Depending on the given
{@link KeyManagerFactory} this may cache the {@link OpenSslKeyMaterial} for better performance if it can
ensure that the same material is always returned for the same alias.
|
[
"Returns",
"the",
"{"
] |
train
|
https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslContext.java#L899-L911
|
LearnLib/automatalib
|
serialization/etf/src/main/java/net/automatalib/serialization/etf/writer/Mealy2ETFWriterIO.java
|
Mealy2ETFWriterIO.writeETF
|
@Override
protected void writeETF(PrintWriter pw, MealyMachine<?, I, ?, O> mealy, Alphabet<I> inputs) {
"""
Write ETF parts specific for Mealy machines with IO semantics.
Writes:
- the initial state,
- the valuations for the state ids,
- the transitions,
- the input alphabet (for the input labels on edges),
- the output alphabet (for the output labels on edges).
@param pw the Writer.
@param mealy the Mealy machine to write.
@param inputs the alphabet.
"""
writeETFInternal(pw, mealy, inputs);
}
|
java
|
@Override
protected void writeETF(PrintWriter pw, MealyMachine<?, I, ?, O> mealy, Alphabet<I> inputs) {
writeETFInternal(pw, mealy, inputs);
}
|
[
"@",
"Override",
"protected",
"void",
"writeETF",
"(",
"PrintWriter",
"pw",
",",
"MealyMachine",
"<",
"?",
",",
"I",
",",
"?",
",",
"O",
">",
"mealy",
",",
"Alphabet",
"<",
"I",
">",
"inputs",
")",
"{",
"writeETFInternal",
"(",
"pw",
",",
"mealy",
",",
"inputs",
")",
";",
"}"
] |
Write ETF parts specific for Mealy machines with IO semantics.
Writes:
- the initial state,
- the valuations for the state ids,
- the transitions,
- the input alphabet (for the input labels on edges),
- the output alphabet (for the output labels on edges).
@param pw the Writer.
@param mealy the Mealy machine to write.
@param inputs the alphabet.
|
[
"Write",
"ETF",
"parts",
"specific",
"for",
"Mealy",
"machines",
"with",
"IO",
"semantics",
"."
] |
train
|
https://github.com/LearnLib/automatalib/blob/8a462ec52f6eaab9f8996e344f2163a72cb8aa6e/serialization/etf/src/main/java/net/automatalib/serialization/etf/writer/Mealy2ETFWriterIO.java#L67-L70
|
xcesco/kripton
|
kripton-processor/src/main/java/com/abubusoft/kripton/processor/sqlite/grammars/uri/ContentUriChecker.java
|
ContentUriChecker.analyzePathInternal
|
private <L extends UriBaseListener> void analyzePathInternal(final String input, L listener) {
"""
Analyze path internal.
@param <L> the generic type
@param input the input
@param listener the listener
"""
pathSegmentIndex = -1;
walker.walk(listener, preparePath(input).value0);
}
|
java
|
private <L extends UriBaseListener> void analyzePathInternal(final String input, L listener) {
pathSegmentIndex = -1;
walker.walk(listener, preparePath(input).value0);
}
|
[
"private",
"<",
"L",
"extends",
"UriBaseListener",
">",
"void",
"analyzePathInternal",
"(",
"final",
"String",
"input",
",",
"L",
"listener",
")",
"{",
"pathSegmentIndex",
"=",
"-",
"1",
";",
"walker",
".",
"walk",
"(",
"listener",
",",
"preparePath",
"(",
"input",
")",
".",
"value0",
")",
";",
"}"
] |
Analyze path internal.
@param <L> the generic type
@param input the input
@param listener the listener
|
[
"Analyze",
"path",
"internal",
"."
] |
train
|
https://github.com/xcesco/kripton/blob/90de2c0523d39b99e81b8d38aa996898762f594a/kripton-processor/src/main/java/com/abubusoft/kripton/processor/sqlite/grammars/uri/ContentUriChecker.java#L122-L125
|
medallia/Word2VecJava
|
src/main/java/com/medallia/word2vec/util/Common.java
|
Common.getResourceAsStream
|
public static InputStream getResourceAsStream(Class<?> clazz, String fn) throws IOException {
"""
Get an input stream to read the raw contents of the given resource, remember to close it :)
"""
InputStream stream = clazz.getResourceAsStream(fn);
if (stream == null) {
throw new IOException("resource \"" + fn + "\" relative to " + clazz + " not found.");
}
return unpackStream(stream, fn);
}
|
java
|
public static InputStream getResourceAsStream(Class<?> clazz, String fn) throws IOException {
InputStream stream = clazz.getResourceAsStream(fn);
if (stream == null) {
throw new IOException("resource \"" + fn + "\" relative to " + clazz + " not found.");
}
return unpackStream(stream, fn);
}
|
[
"public",
"static",
"InputStream",
"getResourceAsStream",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"String",
"fn",
")",
"throws",
"IOException",
"{",
"InputStream",
"stream",
"=",
"clazz",
".",
"getResourceAsStream",
"(",
"fn",
")",
";",
"if",
"(",
"stream",
"==",
"null",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"resource \\\"\"",
"+",
"fn",
"+",
"\"\\\" relative to \"",
"+",
"clazz",
"+",
"\" not found.\"",
")",
";",
"}",
"return",
"unpackStream",
"(",
"stream",
",",
"fn",
")",
";",
"}"
] |
Get an input stream to read the raw contents of the given resource, remember to close it :)
|
[
"Get",
"an",
"input",
"stream",
"to",
"read",
"the",
"raw",
"contents",
"of",
"the",
"given",
"resource",
"remember",
"to",
"close",
"it",
":",
")"
] |
train
|
https://github.com/medallia/Word2VecJava/blob/eb31fbb99ac6bbab82d7f807b3e2240edca50eb7/src/main/java/com/medallia/word2vec/util/Common.java#L103-L109
|
b3log/latke
|
latke-core/src/main/java/org/b3log/latke/plugin/AbstractPlugin.java
|
AbstractPlugin.handleLangs
|
private void handleLangs(final Map<String, Object> dataModel) {
"""
Processes languages. Retrieves language labels with default locale, then sets them into the specified data model.
@param dataModel the specified data model
"""
final Locale locale = Latkes.getLocale();
final String language = locale.getLanguage();
final String country = locale.getCountry();
final String variant = locale.getVariant();
final StringBuilder keyBuilder = new StringBuilder(language);
if (StringUtils.isNotBlank(country)) {
keyBuilder.append("_").append(country);
}
if (StringUtils.isNotBlank(variant)) {
keyBuilder.append("_").append(variant);
}
final String localKey = keyBuilder.toString();
final Properties props = langs.get(localKey);
if (null == props) {
return;
}
final Set<Object> keySet = props.keySet();
for (final Object key : keySet) {
dataModel.put((String) key, props.getProperty((String) key));
}
}
|
java
|
private void handleLangs(final Map<String, Object> dataModel) {
final Locale locale = Latkes.getLocale();
final String language = locale.getLanguage();
final String country = locale.getCountry();
final String variant = locale.getVariant();
final StringBuilder keyBuilder = new StringBuilder(language);
if (StringUtils.isNotBlank(country)) {
keyBuilder.append("_").append(country);
}
if (StringUtils.isNotBlank(variant)) {
keyBuilder.append("_").append(variant);
}
final String localKey = keyBuilder.toString();
final Properties props = langs.get(localKey);
if (null == props) {
return;
}
final Set<Object> keySet = props.keySet();
for (final Object key : keySet) {
dataModel.put((String) key, props.getProperty((String) key));
}
}
|
[
"private",
"void",
"handleLangs",
"(",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"dataModel",
")",
"{",
"final",
"Locale",
"locale",
"=",
"Latkes",
".",
"getLocale",
"(",
")",
";",
"final",
"String",
"language",
"=",
"locale",
".",
"getLanguage",
"(",
")",
";",
"final",
"String",
"country",
"=",
"locale",
".",
"getCountry",
"(",
")",
";",
"final",
"String",
"variant",
"=",
"locale",
".",
"getVariant",
"(",
")",
";",
"final",
"StringBuilder",
"keyBuilder",
"=",
"new",
"StringBuilder",
"(",
"language",
")",
";",
"if",
"(",
"StringUtils",
".",
"isNotBlank",
"(",
"country",
")",
")",
"{",
"keyBuilder",
".",
"append",
"(",
"\"_\"",
")",
".",
"append",
"(",
"country",
")",
";",
"}",
"if",
"(",
"StringUtils",
".",
"isNotBlank",
"(",
"variant",
")",
")",
"{",
"keyBuilder",
".",
"append",
"(",
"\"_\"",
")",
".",
"append",
"(",
"variant",
")",
";",
"}",
"final",
"String",
"localKey",
"=",
"keyBuilder",
".",
"toString",
"(",
")",
";",
"final",
"Properties",
"props",
"=",
"langs",
".",
"get",
"(",
"localKey",
")",
";",
"if",
"(",
"null",
"==",
"props",
")",
"{",
"return",
";",
"}",
"final",
"Set",
"<",
"Object",
">",
"keySet",
"=",
"props",
".",
"keySet",
"(",
")",
";",
"for",
"(",
"final",
"Object",
"key",
":",
"keySet",
")",
"{",
"dataModel",
".",
"put",
"(",
"(",
"String",
")",
"key",
",",
"props",
".",
"getProperty",
"(",
"(",
"String",
")",
"key",
")",
")",
";",
"}",
"}"
] |
Processes languages. Retrieves language labels with default locale, then sets them into the specified data model.
@param dataModel the specified data model
|
[
"Processes",
"languages",
".",
"Retrieves",
"language",
"labels",
"with",
"default",
"locale",
"then",
"sets",
"them",
"into",
"the",
"specified",
"data",
"model",
"."
] |
train
|
https://github.com/b3log/latke/blob/f7e08a47eeecea5f7c94006382c24f353585de33/latke-core/src/main/java/org/b3log/latke/plugin/AbstractPlugin.java#L301-L328
|
augustd/burp-suite-utils
|
src/main/java/com/codemagi/burp/parser/HttpResponse.java
|
HttpResponse.setHeader
|
public final String setHeader(String name, String value) {
"""
Sets a header field value based on its name.
@param name The header name to set
@param value The header value to set
@return the previous value or null if the field was previously unset.
"""
sortedHeaders = null;
return headers.put(name, value);
}
|
java
|
public final String setHeader(String name, String value) {
sortedHeaders = null;
return headers.put(name, value);
}
|
[
"public",
"final",
"String",
"setHeader",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"sortedHeaders",
"=",
"null",
";",
"return",
"headers",
".",
"put",
"(",
"name",
",",
"value",
")",
";",
"}"
] |
Sets a header field value based on its name.
@param name The header name to set
@param value The header value to set
@return the previous value or null if the field was previously unset.
|
[
"Sets",
"a",
"header",
"field",
"value",
"based",
"on",
"its",
"name",
"."
] |
train
|
https://github.com/augustd/burp-suite-utils/blob/5e34a6b9147f5705382f98049dd9e4f387b78629/src/main/java/com/codemagi/burp/parser/HttpResponse.java#L150-L153
|
nextreports/nextreports-engine
|
src/ro/nextreports/engine/util/QueryUtil.java
|
QueryUtil.isValidProcedureCall
|
public static boolean isValidProcedureCall(String sql, Dialect dialect) {
"""
See if the sql contains only one '?' character
@param sql
sql to execute
@param dialect
dialect
@return true if the sql contains only one '?' character, false otherwise
"""
if (sql == null) {
return false;
}
if (dialect instanceof OracleDialect) {
return sql.split("\\?").length == 2;
} else {
return true;
}
}
|
java
|
public static boolean isValidProcedureCall(String sql, Dialect dialect) {
if (sql == null) {
return false;
}
if (dialect instanceof OracleDialect) {
return sql.split("\\?").length == 2;
} else {
return true;
}
}
|
[
"public",
"static",
"boolean",
"isValidProcedureCall",
"(",
"String",
"sql",
",",
"Dialect",
"dialect",
")",
"{",
"if",
"(",
"sql",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"dialect",
"instanceof",
"OracleDialect",
")",
"{",
"return",
"sql",
".",
"split",
"(",
"\"\\\\?\"",
")",
".",
"length",
"==",
"2",
";",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}"
] |
See if the sql contains only one '?' character
@param sql
sql to execute
@param dialect
dialect
@return true if the sql contains only one '?' character, false otherwise
|
[
"See",
"if",
"the",
"sql",
"contains",
"only",
"one",
"?",
"character"
] |
train
|
https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/QueryUtil.java#L385-L394
|
albfernandez/itext2
|
src/main/java/com/lowagie/text/pdf/PdfDocument.java
|
PdfDocument.setMargins
|
public boolean setMargins(float marginLeft, float marginRight, float marginTop, float marginBottom) {
"""
Sets the margins.
@param marginLeft the margin on the left
@param marginRight the margin on the right
@param marginTop the margin on the top
@param marginBottom the margin on the bottom
@return a <CODE>boolean</CODE>
"""
if (writer != null && writer.isPaused()) {
return false;
}
nextMarginLeft = marginLeft;
nextMarginRight = marginRight;
nextMarginTop = marginTop;
nextMarginBottom = marginBottom;
return true;
}
|
java
|
public boolean setMargins(float marginLeft, float marginRight, float marginTop, float marginBottom) {
if (writer != null && writer.isPaused()) {
return false;
}
nextMarginLeft = marginLeft;
nextMarginRight = marginRight;
nextMarginTop = marginTop;
nextMarginBottom = marginBottom;
return true;
}
|
[
"public",
"boolean",
"setMargins",
"(",
"float",
"marginLeft",
",",
"float",
"marginRight",
",",
"float",
"marginTop",
",",
"float",
"marginBottom",
")",
"{",
"if",
"(",
"writer",
"!=",
"null",
"&&",
"writer",
".",
"isPaused",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"nextMarginLeft",
"=",
"marginLeft",
";",
"nextMarginRight",
"=",
"marginRight",
";",
"nextMarginTop",
"=",
"marginTop",
";",
"nextMarginBottom",
"=",
"marginBottom",
";",
"return",
"true",
";",
"}"
] |
Sets the margins.
@param marginLeft the margin on the left
@param marginRight the margin on the right
@param marginTop the margin on the top
@param marginBottom the margin on the bottom
@return a <CODE>boolean</CODE>
|
[
"Sets",
"the",
"margins",
"."
] |
train
|
https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/pdf/PdfDocument.java#L1012-L1021
|
Azure/azure-sdk-for-java
|
automation/resource-manager/v2015_10_31/src/main/java/com/microsoft/azure/management/automation/v2015_10_31/implementation/CredentialsInner.java
|
CredentialsInner.updateAsync
|
public Observable<CredentialInner> updateAsync(String resourceGroupName, String automationAccountName, String credentialName, CredentialUpdateParameters parameters) {
"""
Update a credential.
@param resourceGroupName Name of an Azure Resource group.
@param automationAccountName The name of the automation account.
@param credentialName The parameters supplied to the Update credential operation.
@param parameters The parameters supplied to the Update credential operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the CredentialInner object
"""
return updateWithServiceResponseAsync(resourceGroupName, automationAccountName, credentialName, parameters).map(new Func1<ServiceResponse<CredentialInner>, CredentialInner>() {
@Override
public CredentialInner call(ServiceResponse<CredentialInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<CredentialInner> updateAsync(String resourceGroupName, String automationAccountName, String credentialName, CredentialUpdateParameters parameters) {
return updateWithServiceResponseAsync(resourceGroupName, automationAccountName, credentialName, parameters).map(new Func1<ServiceResponse<CredentialInner>, CredentialInner>() {
@Override
public CredentialInner call(ServiceResponse<CredentialInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"CredentialInner",
">",
"updateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"automationAccountName",
",",
"String",
"credentialName",
",",
"CredentialUpdateParameters",
"parameters",
")",
"{",
"return",
"updateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"automationAccountName",
",",
"credentialName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"CredentialInner",
">",
",",
"CredentialInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"CredentialInner",
"call",
"(",
"ServiceResponse",
"<",
"CredentialInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Update a credential.
@param resourceGroupName Name of an Azure Resource group.
@param automationAccountName The name of the automation account.
@param credentialName The parameters supplied to the Update credential operation.
@param parameters The parameters supplied to the Update credential operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the CredentialInner object
|
[
"Update",
"a",
"credential",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/automation/resource-manager/v2015_10_31/src/main/java/com/microsoft/azure/management/automation/v2015_10_31/implementation/CredentialsInner.java#L416-L423
|
infinispan/infinispan
|
commons/src/main/java/org/infinispan/commons/io/UnsignedNumeric.java
|
UnsignedNumeric.writeUnsignedLong
|
public static void writeUnsignedLong(byte[] bytes, int offset, long i) {
"""
Writes an int in a variable-length format. Writes between one and nine bytes. Smaller values take fewer bytes.
Negative numbers are not supported.
@param i int to write
"""
while ((i & ~0x7F) != 0) {
bytes[offset++] = (byte) ((i & 0x7f) | 0x80);
i >>>= 7;
}
bytes[offset] = (byte) i;
}
|
java
|
public static void writeUnsignedLong(byte[] bytes, int offset, long i) {
while ((i & ~0x7F) != 0) {
bytes[offset++] = (byte) ((i & 0x7f) | 0x80);
i >>>= 7;
}
bytes[offset] = (byte) i;
}
|
[
"public",
"static",
"void",
"writeUnsignedLong",
"(",
"byte",
"[",
"]",
"bytes",
",",
"int",
"offset",
",",
"long",
"i",
")",
"{",
"while",
"(",
"(",
"i",
"&",
"~",
"0x7F",
")",
"!=",
"0",
")",
"{",
"bytes",
"[",
"offset",
"++",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"i",
"&",
"0x7f",
")",
"|",
"0x80",
")",
";",
"i",
">>>=",
"7",
";",
"}",
"bytes",
"[",
"offset",
"]",
"=",
"(",
"byte",
")",
"i",
";",
"}"
] |
Writes an int in a variable-length format. Writes between one and nine bytes. Smaller values take fewer bytes.
Negative numbers are not supported.
@param i int to write
|
[
"Writes",
"an",
"int",
"in",
"a",
"variable",
"-",
"length",
"format",
".",
"Writes",
"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#L204-L210
|
threerings/nenya
|
core/src/main/java/com/threerings/resource/ResourceManager.java
|
ResourceManager.getResource
|
public InputStream getResource (String rset, String path)
throws IOException {
"""
Returns an input stream from which the requested resource can be loaded. <em>Note:</em> this
performs a linear search of all of the bundles in the set and returns the first resource
found with the specified path, thus it is not extremely efficient and will behave
unexpectedly if you use the same paths in different resource bundles.
@exception FileNotFoundException thrown if the resource could not be located in any of the
bundles in the specified set, or if the specified set does not exist.
@exception IOException thrown if a problem occurs locating or reading the resource.
"""
// grab the resource bundles in the specified resource set
ResourceBundle[] bundles = getResourceSet(rset);
if (bundles == null) {
throw new FileNotFoundException(
"Unable to locate resource [set=" + rset + ", path=" + path + "]");
}
String localePath = getLocalePath(path);
// look for the resource in any of the bundles
for (ResourceBundle bundle : bundles) {
InputStream in;
// Try a localized version first.
if (localePath != null) {
in = bundle.getResource(localePath);
if (in != null) {
return in;
}
}
// If we didn't find that, try a generic.
in = bundle.getResource(path);
if (in != null) {
return in;
}
}
throw new FileNotFoundException(
"Unable to locate resource [set=" + rset + ", path=" + path + "]");
}
|
java
|
public InputStream getResource (String rset, String path)
throws IOException
{
// grab the resource bundles in the specified resource set
ResourceBundle[] bundles = getResourceSet(rset);
if (bundles == null) {
throw new FileNotFoundException(
"Unable to locate resource [set=" + rset + ", path=" + path + "]");
}
String localePath = getLocalePath(path);
// look for the resource in any of the bundles
for (ResourceBundle bundle : bundles) {
InputStream in;
// Try a localized version first.
if (localePath != null) {
in = bundle.getResource(localePath);
if (in != null) {
return in;
}
}
// If we didn't find that, try a generic.
in = bundle.getResource(path);
if (in != null) {
return in;
}
}
throw new FileNotFoundException(
"Unable to locate resource [set=" + rset + ", path=" + path + "]");
}
|
[
"public",
"InputStream",
"getResource",
"(",
"String",
"rset",
",",
"String",
"path",
")",
"throws",
"IOException",
"{",
"// grab the resource bundles in the specified resource set",
"ResourceBundle",
"[",
"]",
"bundles",
"=",
"getResourceSet",
"(",
"rset",
")",
";",
"if",
"(",
"bundles",
"==",
"null",
")",
"{",
"throw",
"new",
"FileNotFoundException",
"(",
"\"Unable to locate resource [set=\"",
"+",
"rset",
"+",
"\", path=\"",
"+",
"path",
"+",
"\"]\"",
")",
";",
"}",
"String",
"localePath",
"=",
"getLocalePath",
"(",
"path",
")",
";",
"// look for the resource in any of the bundles",
"for",
"(",
"ResourceBundle",
"bundle",
":",
"bundles",
")",
"{",
"InputStream",
"in",
";",
"// Try a localized version first.",
"if",
"(",
"localePath",
"!=",
"null",
")",
"{",
"in",
"=",
"bundle",
".",
"getResource",
"(",
"localePath",
")",
";",
"if",
"(",
"in",
"!=",
"null",
")",
"{",
"return",
"in",
";",
"}",
"}",
"// If we didn't find that, try a generic.",
"in",
"=",
"bundle",
".",
"getResource",
"(",
"path",
")",
";",
"if",
"(",
"in",
"!=",
"null",
")",
"{",
"return",
"in",
";",
"}",
"}",
"throw",
"new",
"FileNotFoundException",
"(",
"\"Unable to locate resource [set=\"",
"+",
"rset",
"+",
"\", path=\"",
"+",
"path",
"+",
"\"]\"",
")",
";",
"}"
] |
Returns an input stream from which the requested resource can be loaded. <em>Note:</em> this
performs a linear search of all of the bundles in the set and returns the first resource
found with the specified path, thus it is not extremely efficient and will behave
unexpectedly if you use the same paths in different resource bundles.
@exception FileNotFoundException thrown if the resource could not be located in any of the
bundles in the specified set, or if the specified set does not exist.
@exception IOException thrown if a problem occurs locating or reading the resource.
|
[
"Returns",
"an",
"input",
"stream",
"from",
"which",
"the",
"requested",
"resource",
"can",
"be",
"loaded",
".",
"<em",
">",
"Note",
":",
"<",
"/",
"em",
">",
"this",
"performs",
"a",
"linear",
"search",
"of",
"all",
"of",
"the",
"bundles",
"in",
"the",
"set",
"and",
"returns",
"the",
"first",
"resource",
"found",
"with",
"the",
"specified",
"path",
"thus",
"it",
"is",
"not",
"extremely",
"efficient",
"and",
"will",
"behave",
"unexpectedly",
"if",
"you",
"use",
"the",
"same",
"paths",
"in",
"different",
"resource",
"bundles",
"."
] |
train
|
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/resource/ResourceManager.java#L641-L671
|
Netflix/spectator
|
spectator-api/src/main/java/com/netflix/spectator/api/patterns/LongTaskTimer.java
|
LongTaskTimer.get
|
public static LongTaskTimer get(Registry registry, Id id) {
"""
Creates a timer for tracking long running tasks.
@param registry
Registry to use.
@param id
Identifier for the metric being registered.
@return
Timer instance.
"""
ConcurrentMap<Id, Object> state = registry.state();
Object obj = Utils.computeIfAbsent(state, id, i -> {
LongTaskTimer timer = new LongTaskTimer(registry, id);
PolledMeter.using(registry)
.withId(id)
.withTag(Statistic.activeTasks)
.monitorValue(timer, LongTaskTimer::activeTasks);
PolledMeter.using(registry)
.withId(id)
.withTag(Statistic.duration)
.monitorValue(timer, t -> t.duration() / NANOS_PER_SECOND);
return timer;
});
if (!(obj instanceof LongTaskTimer)) {
Utils.propagateTypeError(registry, id, LongTaskTimer.class, obj.getClass());
obj = new LongTaskTimer(new NoopRegistry(), id);
}
return (LongTaskTimer) obj;
}
|
java
|
public static LongTaskTimer get(Registry registry, Id id) {
ConcurrentMap<Id, Object> state = registry.state();
Object obj = Utils.computeIfAbsent(state, id, i -> {
LongTaskTimer timer = new LongTaskTimer(registry, id);
PolledMeter.using(registry)
.withId(id)
.withTag(Statistic.activeTasks)
.monitorValue(timer, LongTaskTimer::activeTasks);
PolledMeter.using(registry)
.withId(id)
.withTag(Statistic.duration)
.monitorValue(timer, t -> t.duration() / NANOS_PER_SECOND);
return timer;
});
if (!(obj instanceof LongTaskTimer)) {
Utils.propagateTypeError(registry, id, LongTaskTimer.class, obj.getClass());
obj = new LongTaskTimer(new NoopRegistry(), id);
}
return (LongTaskTimer) obj;
}
|
[
"public",
"static",
"LongTaskTimer",
"get",
"(",
"Registry",
"registry",
",",
"Id",
"id",
")",
"{",
"ConcurrentMap",
"<",
"Id",
",",
"Object",
">",
"state",
"=",
"registry",
".",
"state",
"(",
")",
";",
"Object",
"obj",
"=",
"Utils",
".",
"computeIfAbsent",
"(",
"state",
",",
"id",
",",
"i",
"->",
"{",
"LongTaskTimer",
"timer",
"=",
"new",
"LongTaskTimer",
"(",
"registry",
",",
"id",
")",
";",
"PolledMeter",
".",
"using",
"(",
"registry",
")",
".",
"withId",
"(",
"id",
")",
".",
"withTag",
"(",
"Statistic",
".",
"activeTasks",
")",
".",
"monitorValue",
"(",
"timer",
",",
"LongTaskTimer",
"::",
"activeTasks",
")",
";",
"PolledMeter",
".",
"using",
"(",
"registry",
")",
".",
"withId",
"(",
"id",
")",
".",
"withTag",
"(",
"Statistic",
".",
"duration",
")",
".",
"monitorValue",
"(",
"timer",
",",
"t",
"->",
"t",
".",
"duration",
"(",
")",
"/",
"NANOS_PER_SECOND",
")",
";",
"return",
"timer",
";",
"}",
")",
";",
"if",
"(",
"!",
"(",
"obj",
"instanceof",
"LongTaskTimer",
")",
")",
"{",
"Utils",
".",
"propagateTypeError",
"(",
"registry",
",",
"id",
",",
"LongTaskTimer",
".",
"class",
",",
"obj",
".",
"getClass",
"(",
")",
")",
";",
"obj",
"=",
"new",
"LongTaskTimer",
"(",
"new",
"NoopRegistry",
"(",
")",
",",
"id",
")",
";",
"}",
"return",
"(",
"LongTaskTimer",
")",
"obj",
";",
"}"
] |
Creates a timer for tracking long running tasks.
@param registry
Registry to use.
@param id
Identifier for the metric being registered.
@return
Timer instance.
|
[
"Creates",
"a",
"timer",
"for",
"tracking",
"long",
"running",
"tasks",
"."
] |
train
|
https://github.com/Netflix/spectator/blob/259318252770de3bad581b85adff187d8f2c6537/spectator-api/src/main/java/com/netflix/spectator/api/patterns/LongTaskTimer.java#L50-L69
|
reactor/reactor-netty
|
src/main/java/reactor/netty/http/client/HttpClient.java
|
HttpClient.cookieCodec
|
public final HttpClient cookieCodec(ClientCookieEncoder encoder, ClientCookieDecoder decoder) {
"""
Configure the
{@link ClientCookieEncoder} and {@link ClientCookieDecoder}
@param encoder the preferred ClientCookieEncoder
@param decoder the preferred ClientCookieDecoder
@return a new {@link HttpClient}
"""
return tcpConfiguration(tcp -> tcp.bootstrap(
b -> HttpClientConfiguration.cookieCodec(b, encoder, decoder)));
}
|
java
|
public final HttpClient cookieCodec(ClientCookieEncoder encoder, ClientCookieDecoder decoder) {
return tcpConfiguration(tcp -> tcp.bootstrap(
b -> HttpClientConfiguration.cookieCodec(b, encoder, decoder)));
}
|
[
"public",
"final",
"HttpClient",
"cookieCodec",
"(",
"ClientCookieEncoder",
"encoder",
",",
"ClientCookieDecoder",
"decoder",
")",
"{",
"return",
"tcpConfiguration",
"(",
"tcp",
"->",
"tcp",
".",
"bootstrap",
"(",
"b",
"->",
"HttpClientConfiguration",
".",
"cookieCodec",
"(",
"b",
",",
"encoder",
",",
"decoder",
")",
")",
")",
";",
"}"
] |
Configure the
{@link ClientCookieEncoder} and {@link ClientCookieDecoder}
@param encoder the preferred ClientCookieEncoder
@param decoder the preferred ClientCookieDecoder
@return a new {@link HttpClient}
|
[
"Configure",
"the",
"{",
"@link",
"ClientCookieEncoder",
"}",
"and",
"{",
"@link",
"ClientCookieDecoder",
"}"
] |
train
|
https://github.com/reactor/reactor-netty/blob/4ed14316e1d7fca3cecd18d6caa5f2251e159e49/src/main/java/reactor/netty/http/client/HttpClient.java#L474-L477
|
nguillaumin/slick2d-maven
|
slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GradientEditor.java
|
GradientEditor.selectPoint
|
private void selectPoint(int mx, int my) {
"""
Select the control point at the specified mouse coordinate
@param mx The mouse x coordinate
@param my The mouse y coordinate
"""
if (!isEnabled()) {
return;
}
for (int i=1;i<list.size()-1;i++) {
if (checkPoint(mx,my,(ControlPoint) list.get(i))) {
selected = (ControlPoint) list.get(i);
return;
}
}
if (checkPoint(mx,my,(ControlPoint) list.get(0))) {
selected = (ControlPoint) list.get(0);
return;
}
if (checkPoint(mx,my,(ControlPoint) list.get(list.size()-1))) {
selected = (ControlPoint) list.get(list.size()-1);
return;
}
selected = null;
}
|
java
|
private void selectPoint(int mx, int my) {
if (!isEnabled()) {
return;
}
for (int i=1;i<list.size()-1;i++) {
if (checkPoint(mx,my,(ControlPoint) list.get(i))) {
selected = (ControlPoint) list.get(i);
return;
}
}
if (checkPoint(mx,my,(ControlPoint) list.get(0))) {
selected = (ControlPoint) list.get(0);
return;
}
if (checkPoint(mx,my,(ControlPoint) list.get(list.size()-1))) {
selected = (ControlPoint) list.get(list.size()-1);
return;
}
selected = null;
}
|
[
"private",
"void",
"selectPoint",
"(",
"int",
"mx",
",",
"int",
"my",
")",
"{",
"if",
"(",
"!",
"isEnabled",
"(",
")",
")",
"{",
"return",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"list",
".",
"size",
"(",
")",
"-",
"1",
";",
"i",
"++",
")",
"{",
"if",
"(",
"checkPoint",
"(",
"mx",
",",
"my",
",",
"(",
"ControlPoint",
")",
"list",
".",
"get",
"(",
"i",
")",
")",
")",
"{",
"selected",
"=",
"(",
"ControlPoint",
")",
"list",
".",
"get",
"(",
"i",
")",
";",
"return",
";",
"}",
"}",
"if",
"(",
"checkPoint",
"(",
"mx",
",",
"my",
",",
"(",
"ControlPoint",
")",
"list",
".",
"get",
"(",
"0",
")",
")",
")",
"{",
"selected",
"=",
"(",
"ControlPoint",
")",
"list",
".",
"get",
"(",
"0",
")",
";",
"return",
";",
"}",
"if",
"(",
"checkPoint",
"(",
"mx",
",",
"my",
",",
"(",
"ControlPoint",
")",
"list",
".",
"get",
"(",
"list",
".",
"size",
"(",
")",
"-",
"1",
")",
")",
")",
"{",
"selected",
"=",
"(",
"ControlPoint",
")",
"list",
".",
"get",
"(",
"list",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"return",
";",
"}",
"selected",
"=",
"null",
";",
"}"
] |
Select the control point at the specified mouse coordinate
@param mx The mouse x coordinate
@param my The mouse y coordinate
|
[
"Select",
"the",
"control",
"point",
"at",
"the",
"specified",
"mouse",
"coordinate"
] |
train
|
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GradientEditor.java#L241-L262
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.event/src/com/ibm/ws/event/internal/TopicBasedCache.java
|
TopicBasedCache.addHandler
|
synchronized void addHandler(ServiceReference<?> serviceReference, boolean osgiHandler) {
"""
Add an <code>EventHandler</code> <code>ServiceReference</code> to our
collection. Adding a handler reference will populate the maps that
associate topics with handlers.
@param serviceReference
the <code>EventHandler</code> reference
@param osgiHandler
the serviceReference refers to an OSGi Event Handler
"""
HandlerHolder holder = new HandlerHolder(eventEngine, serviceReference, osgiHandler);
serviceReferenceMap.put(serviceReference, holder);
for (String topic : holder.getDiscreteTopics()) {
addTopicHandlerToMap(topic, holder, discreteEventHandlers);
}
for (String topic : holder.getWildcardTopics()) {
addTopicHandlerToMap(topic, holder, wildcardEventHandlers);
}
// Clear the cache since it's no longer up to date
clearTopicDataCache();
}
|
java
|
synchronized void addHandler(ServiceReference<?> serviceReference, boolean osgiHandler) {
HandlerHolder holder = new HandlerHolder(eventEngine, serviceReference, osgiHandler);
serviceReferenceMap.put(serviceReference, holder);
for (String topic : holder.getDiscreteTopics()) {
addTopicHandlerToMap(topic, holder, discreteEventHandlers);
}
for (String topic : holder.getWildcardTopics()) {
addTopicHandlerToMap(topic, holder, wildcardEventHandlers);
}
// Clear the cache since it's no longer up to date
clearTopicDataCache();
}
|
[
"synchronized",
"void",
"addHandler",
"(",
"ServiceReference",
"<",
"?",
">",
"serviceReference",
",",
"boolean",
"osgiHandler",
")",
"{",
"HandlerHolder",
"holder",
"=",
"new",
"HandlerHolder",
"(",
"eventEngine",
",",
"serviceReference",
",",
"osgiHandler",
")",
";",
"serviceReferenceMap",
".",
"put",
"(",
"serviceReference",
",",
"holder",
")",
";",
"for",
"(",
"String",
"topic",
":",
"holder",
".",
"getDiscreteTopics",
"(",
")",
")",
"{",
"addTopicHandlerToMap",
"(",
"topic",
",",
"holder",
",",
"discreteEventHandlers",
")",
";",
"}",
"for",
"(",
"String",
"topic",
":",
"holder",
".",
"getWildcardTopics",
"(",
")",
")",
"{",
"addTopicHandlerToMap",
"(",
"topic",
",",
"holder",
",",
"wildcardEventHandlers",
")",
";",
"}",
"// Clear the cache since it's no longer up to date",
"clearTopicDataCache",
"(",
")",
";",
"}"
] |
Add an <code>EventHandler</code> <code>ServiceReference</code> to our
collection. Adding a handler reference will populate the maps that
associate topics with handlers.
@param serviceReference
the <code>EventHandler</code> reference
@param osgiHandler
the serviceReference refers to an OSGi Event Handler
|
[
"Add",
"an",
"<code",
">",
"EventHandler<",
"/",
"code",
">",
"<code",
">",
"ServiceReference<",
"/",
"code",
">",
"to",
"our",
"collection",
".",
"Adding",
"a",
"handler",
"reference",
"will",
"populate",
"the",
"maps",
"that",
"associate",
"topics",
"with",
"handlers",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.event/src/com/ibm/ws/event/internal/TopicBasedCache.java#L148-L162
|
eclipse/xtext-extras
|
org.eclipse.xtext.xbase/src/org/eclipse/xtext/xbase/typesystem/computation/XbaseTypeComputer.java
|
XbaseTypeComputer._computeTypes
|
protected void _computeTypes(XDoWhileExpression object, ITypeComputationState state) {
"""
Since we are sure that the loop body is executed at least once, the early exit information
of the loop body expression can be used for the outer expression.
"""
ITypeComputationResult loopBodyResult = computeWhileLoopBody(object, state, false);
boolean noImplicitReturn = (loopBodyResult.getConformanceFlags() & ConformanceFlags.NO_IMPLICIT_RETURN) != 0;
LightweightTypeReference primitiveVoid = getPrimitiveVoid(state);
if (noImplicitReturn)
state.acceptActualType(primitiveVoid, ConformanceFlags.NO_IMPLICIT_RETURN | ConformanceFlags.UNCHECKED);
else
state.acceptActualType(primitiveVoid);
}
|
java
|
protected void _computeTypes(XDoWhileExpression object, ITypeComputationState state) {
ITypeComputationResult loopBodyResult = computeWhileLoopBody(object, state, false);
boolean noImplicitReturn = (loopBodyResult.getConformanceFlags() & ConformanceFlags.NO_IMPLICIT_RETURN) != 0;
LightweightTypeReference primitiveVoid = getPrimitiveVoid(state);
if (noImplicitReturn)
state.acceptActualType(primitiveVoid, ConformanceFlags.NO_IMPLICIT_RETURN | ConformanceFlags.UNCHECKED);
else
state.acceptActualType(primitiveVoid);
}
|
[
"protected",
"void",
"_computeTypes",
"(",
"XDoWhileExpression",
"object",
",",
"ITypeComputationState",
"state",
")",
"{",
"ITypeComputationResult",
"loopBodyResult",
"=",
"computeWhileLoopBody",
"(",
"object",
",",
"state",
",",
"false",
")",
";",
"boolean",
"noImplicitReturn",
"=",
"(",
"loopBodyResult",
".",
"getConformanceFlags",
"(",
")",
"&",
"ConformanceFlags",
".",
"NO_IMPLICIT_RETURN",
")",
"!=",
"0",
";",
"LightweightTypeReference",
"primitiveVoid",
"=",
"getPrimitiveVoid",
"(",
"state",
")",
";",
"if",
"(",
"noImplicitReturn",
")",
"state",
".",
"acceptActualType",
"(",
"primitiveVoid",
",",
"ConformanceFlags",
".",
"NO_IMPLICIT_RETURN",
"|",
"ConformanceFlags",
".",
"UNCHECKED",
")",
";",
"else",
"state",
".",
"acceptActualType",
"(",
"primitiveVoid",
")",
";",
"}"
] |
Since we are sure that the loop body is executed at least once, the early exit information
of the loop body expression can be used for the outer expression.
|
[
"Since",
"we",
"are",
"sure",
"that",
"the",
"loop",
"body",
"is",
"executed",
"at",
"least",
"once",
"the",
"early",
"exit",
"information",
"of",
"the",
"loop",
"body",
"expression",
"can",
"be",
"used",
"for",
"the",
"outer",
"expression",
"."
] |
train
|
https://github.com/eclipse/xtext-extras/blob/451359541295323a29f5855e633f770cec02069a/org.eclipse.xtext.xbase/src/org/eclipse/xtext/xbase/typesystem/computation/XbaseTypeComputer.java#L953-L961
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.jmx.connector.server.rest/src/com/ibm/ws/jmx/connector/server/rest/JMXRESTProxyServlet.java
|
JMXRESTProxyServlet.handleWithDelegate
|
private void handleWithDelegate(final HttpServletRequest request, final HttpServletResponse response) throws IOException {
"""
For any request URL other than the context root, delegate to the
appropriate handler. If no handler is available, a 404 will be set
into the response.
@param request
@param response
@param pathInfo
@throws IOException
"""
//Delegate to handler
boolean foundHandler = REST_HANDLER_CONTAINER.handleRequest(new ServletRESTRequestImpl(request), new ServletRESTResponseImpl(response));
if (!foundHandler) {
//No handler found, so we send back a 404 "not found" response.
String errorMsg = TraceNLS.getFormattedMessage(this.getClass(),
TraceConstants.TRACE_BUNDLE_CORE,
"HANDLER_NOT_FOUND_ERROR",
new Object[] { request.getRequestURI() },
"CWWKO1000E: There are no registered handlers that match the requested URL {0}");
response.sendError(HttpServletResponse.SC_NOT_FOUND, errorMsg);
}
}
|
java
|
private void handleWithDelegate(final HttpServletRequest request, final HttpServletResponse response) throws IOException {
//Delegate to handler
boolean foundHandler = REST_HANDLER_CONTAINER.handleRequest(new ServletRESTRequestImpl(request), new ServletRESTResponseImpl(response));
if (!foundHandler) {
//No handler found, so we send back a 404 "not found" response.
String errorMsg = TraceNLS.getFormattedMessage(this.getClass(),
TraceConstants.TRACE_BUNDLE_CORE,
"HANDLER_NOT_FOUND_ERROR",
new Object[] { request.getRequestURI() },
"CWWKO1000E: There are no registered handlers that match the requested URL {0}");
response.sendError(HttpServletResponse.SC_NOT_FOUND, errorMsg);
}
}
|
[
"private",
"void",
"handleWithDelegate",
"(",
"final",
"HttpServletRequest",
"request",
",",
"final",
"HttpServletResponse",
"response",
")",
"throws",
"IOException",
"{",
"//Delegate to handler",
"boolean",
"foundHandler",
"=",
"REST_HANDLER_CONTAINER",
".",
"handleRequest",
"(",
"new",
"ServletRESTRequestImpl",
"(",
"request",
")",
",",
"new",
"ServletRESTResponseImpl",
"(",
"response",
")",
")",
";",
"if",
"(",
"!",
"foundHandler",
")",
"{",
"//No handler found, so we send back a 404 \"not found\" response.",
"String",
"errorMsg",
"=",
"TraceNLS",
".",
"getFormattedMessage",
"(",
"this",
".",
"getClass",
"(",
")",
",",
"TraceConstants",
".",
"TRACE_BUNDLE_CORE",
",",
"\"HANDLER_NOT_FOUND_ERROR\"",
",",
"new",
"Object",
"[",
"]",
"{",
"request",
".",
"getRequestURI",
"(",
")",
"}",
",",
"\"CWWKO1000E: There are no registered handlers that match the requested URL {0}\"",
")",
";",
"response",
".",
"sendError",
"(",
"HttpServletResponse",
".",
"SC_NOT_FOUND",
",",
"errorMsg",
")",
";",
"}",
"}"
] |
For any request URL other than the context root, delegate to the
appropriate handler. If no handler is available, a 404 will be set
into the response.
@param request
@param response
@param pathInfo
@throws IOException
|
[
"For",
"any",
"request",
"URL",
"other",
"than",
"the",
"context",
"root",
"delegate",
"to",
"the",
"appropriate",
"handler",
".",
"If",
"no",
"handler",
"is",
"available",
"a",
"404",
"will",
"be",
"set",
"into",
"the",
"response",
"."
] |
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/JMXRESTProxyServlet.java#L56-L69
|
carewebframework/carewebframework-core
|
org.carewebframework.mvn-parent/org.carewebframework.mvn.plugin-parent/org.carewebframework.mvn.plugin.core/src/main/java/org/carewebframework/maven/plugin/core/BaseMojo.java
|
BaseMojo.assembleArchive
|
protected void assembleArchive() throws Exception {
"""
Assembles the archive file. Optionally, copies to the war application directory if the
packaging type is "war".
@throws Exception Unspecified exception.
"""
getLog().info("Assembling " + classifier + " archive");
if (resources != null && !resources.isEmpty()) {
getLog().info("Copying additional resources.");
new ResourceProcessor(this, moduleBase, resources).transform();
}
if (configTemplate != null) {
getLog().info("Creating config file.");
configTemplate.addEntry("info", pluginDescriptor.getName(), pluginDescriptor.getVersion(),
new Date().toString());
configTemplate.createFile(stagingDirectory);
}
try {
File archive = createArchive();
if ("war".equalsIgnoreCase(mavenProject.getPackaging()) && this.warInclusion) {
webappLibDirectory.mkdirs();
File webappLibArchive = new File(this.webappLibDirectory, archive.getName());
Files.copy(archive, webappLibArchive);
}
} catch (Exception e) {
throw new RuntimeException("Exception occurred assembling archive.", e);
}
}
|
java
|
protected void assembleArchive() throws Exception {
getLog().info("Assembling " + classifier + " archive");
if (resources != null && !resources.isEmpty()) {
getLog().info("Copying additional resources.");
new ResourceProcessor(this, moduleBase, resources).transform();
}
if (configTemplate != null) {
getLog().info("Creating config file.");
configTemplate.addEntry("info", pluginDescriptor.getName(), pluginDescriptor.getVersion(),
new Date().toString());
configTemplate.createFile(stagingDirectory);
}
try {
File archive = createArchive();
if ("war".equalsIgnoreCase(mavenProject.getPackaging()) && this.warInclusion) {
webappLibDirectory.mkdirs();
File webappLibArchive = new File(this.webappLibDirectory, archive.getName());
Files.copy(archive, webappLibArchive);
}
} catch (Exception e) {
throw new RuntimeException("Exception occurred assembling archive.", e);
}
}
|
[
"protected",
"void",
"assembleArchive",
"(",
")",
"throws",
"Exception",
"{",
"getLog",
"(",
")",
".",
"info",
"(",
"\"Assembling \"",
"+",
"classifier",
"+",
"\" archive\"",
")",
";",
"if",
"(",
"resources",
"!=",
"null",
"&&",
"!",
"resources",
".",
"isEmpty",
"(",
")",
")",
"{",
"getLog",
"(",
")",
".",
"info",
"(",
"\"Copying additional resources.\"",
")",
";",
"new",
"ResourceProcessor",
"(",
"this",
",",
"moduleBase",
",",
"resources",
")",
".",
"transform",
"(",
")",
";",
"}",
"if",
"(",
"configTemplate",
"!=",
"null",
")",
"{",
"getLog",
"(",
")",
".",
"info",
"(",
"\"Creating config file.\"",
")",
";",
"configTemplate",
".",
"addEntry",
"(",
"\"info\"",
",",
"pluginDescriptor",
".",
"getName",
"(",
")",
",",
"pluginDescriptor",
".",
"getVersion",
"(",
")",
",",
"new",
"Date",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"configTemplate",
".",
"createFile",
"(",
"stagingDirectory",
")",
";",
"}",
"try",
"{",
"File",
"archive",
"=",
"createArchive",
"(",
")",
";",
"if",
"(",
"\"war\"",
".",
"equalsIgnoreCase",
"(",
"mavenProject",
".",
"getPackaging",
"(",
")",
")",
"&&",
"this",
".",
"warInclusion",
")",
"{",
"webappLibDirectory",
".",
"mkdirs",
"(",
")",
";",
"File",
"webappLibArchive",
"=",
"new",
"File",
"(",
"this",
".",
"webappLibDirectory",
",",
"archive",
".",
"getName",
"(",
")",
")",
";",
"Files",
".",
"copy",
"(",
"archive",
",",
"webappLibArchive",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Exception occurred assembling archive.\"",
",",
"e",
")",
";",
"}",
"}"
] |
Assembles the archive file. Optionally, copies to the war application directory if the
packaging type is "war".
@throws Exception Unspecified exception.
|
[
"Assembles",
"the",
"archive",
"file",
".",
"Optionally",
"copies",
"to",
"the",
"war",
"application",
"directory",
"if",
"the",
"packaging",
"type",
"is",
"war",
"."
] |
train
|
https://github.com/carewebframework/carewebframework-core/blob/fa3252d4f7541dbe151b92c3d4f6f91433cd1673/org.carewebframework.mvn-parent/org.carewebframework.mvn.plugin-parent/org.carewebframework.mvn.plugin.core/src/main/java/org/carewebframework/maven/plugin/core/BaseMojo.java#L270-L297
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.